layerscape: add 64b/32b target for ls1043ardb device
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.4 / 7015-fmd-add-fman-driver.patch
1 From 9a69168a7ab58035571d9d19d531a40aa7f909dd Mon Sep 17 00:00:00 2001
2 From: Zhao Qiang <qiang.zhao@nxp.com>
3 Date: Wed, 16 Dec 2015 21:46:52 +0200
4 Subject: [PATCH 15/70] fmd: add fman driver
5
6 Add fman driver code of dpaa, put it to drivers/net/ethernet/freescale/sdk_fman.
7 fman is frame manager, combining ethernet MACs with packet parsing and
8 classification logic, providing intelligent distribution and queuing
9 decisions for incomming traffic.
10
11 Signed-off-by: Mandy Lavi <mandy.lavi@freescale.com>
12 Signed-off-by: Madalin Bucur <madalin.bucur@freescale.com>
13 Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
14 ---
15 drivers/net/ethernet/freescale/Kconfig | 1 +
16 drivers/net/ethernet/freescale/Makefile | 1 +
17 drivers/net/ethernet/freescale/sdk_fman/Kconfig | 151 +
18 drivers/net/ethernet/freescale/sdk_fman/Makefile | 11 +
19 .../freescale/sdk_fman/Peripherals/FM/HC/Makefile | 15 +
20 .../freescale/sdk_fman/Peripherals/FM/HC/hc.c | 1232 ++++
21 .../freescale/sdk_fman/Peripherals/FM/MAC/Makefile | 28 +
22 .../freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c | 1463 ++++
23 .../freescale/sdk_fman/Peripherals/FM/MAC/dtsec.h | 228 +
24 .../sdk_fman/Peripherals/FM/MAC/dtsec_mii_acc.c | 97 +
25 .../sdk_fman/Peripherals/FM/MAC/dtsec_mii_acc.h | 42 +
26 .../freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c | 646 ++
27 .../freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h | 224 +
28 .../sdk_fman/Peripherals/FM/MAC/fman_crc32.c | 119 +
29 .../sdk_fman/Peripherals/FM/MAC/fman_crc32.h | 43 +
30 .../sdk_fman/Peripherals/FM/MAC/fman_dtsec.c | 845 +++
31 .../Peripherals/FM/MAC/fman_dtsec_mii_acc.c | 163 +
32 .../sdk_fman/Peripherals/FM/MAC/fman_memac.c | 511 ++
33 .../Peripherals/FM/MAC/fman_memac_mii_acc.c | 213 +
34 .../sdk_fman/Peripherals/FM/MAC/fman_tgec.c | 367 +
35 .../freescale/sdk_fman/Peripherals/FM/MAC/memac.c | 1088 +++
36 .../freescale/sdk_fman/Peripherals/FM/MAC/memac.h | 110 +
37 .../sdk_fman/Peripherals/FM/MAC/memac_mii_acc.c | 78 +
38 .../sdk_fman/Peripherals/FM/MAC/memac_mii_acc.h | 73 +
39 .../freescale/sdk_fman/Peripherals/FM/MAC/tgec.c | 974 +++
40 .../freescale/sdk_fman/Peripherals/FM/MAC/tgec.h | 151 +
41 .../sdk_fman/Peripherals/FM/MAC/tgec_mii_acc.c | 139 +
42 .../sdk_fman/Peripherals/FM/MAC/tgec_mii_acc.h | 80 +
43 .../sdk_fman/Peripherals/FM/MACSEC/Makefile | 15 +
44 .../sdk_fman/Peripherals/FM/MACSEC/fm_macsec.c | 237 +
45 .../sdk_fman/Peripherals/FM/MACSEC/fm_macsec.h | 203 +
46 .../Peripherals/FM/MACSEC/fm_macsec_guest.c | 59 +
47 .../Peripherals/FM/MACSEC/fm_macsec_master.c | 1031 +++
48 .../Peripherals/FM/MACSEC/fm_macsec_master.h | 479 ++
49 .../Peripherals/FM/MACSEC/fm_macsec_secy.c | 883 +++
50 .../Peripherals/FM/MACSEC/fm_macsec_secy.h | 144 +
51 .../freescale/sdk_fman/Peripherals/FM/Makefile | 23 +
52 .../freescale/sdk_fman/Peripherals/FM/Pcd/Makefile | 26 +
53 .../freescale/sdk_fman/Peripherals/FM/Pcd/crc64.h | 360 +
54 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.c | 7538 ++++++++++++++++++++
55 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.h | 399 ++
56 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c | 3242 +++++++++
57 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.h | 206 +
58 .../sdk_fman/Peripherals/FM/Pcd/fm_manip.c | 5571 +++++++++++++++
59 .../sdk_fman/Peripherals/FM/Pcd/fm_manip.h | 555 ++
60 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_pcd.c | 2094 ++++++
61 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_pcd.h | 543 ++
62 .../sdk_fman/Peripherals/FM/Pcd/fm_pcd_ipc.h | 280 +
63 .../sdk_fman/Peripherals/FM/Pcd/fm_plcr.c | 1846 +++++
64 .../sdk_fman/Peripherals/FM/Pcd/fm_plcr.h | 165 +
65 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_prs.c | 422 ++
66 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_prs.h | 316 +
67 .../sdk_fman/Peripherals/FM/Pcd/fm_replic.c | 984 +++
68 .../sdk_fman/Peripherals/FM/Pcd/fm_replic.h | 101 +
69 .../sdk_fman/Peripherals/FM/Pcd/fman_kg.c | 888 +++
70 .../sdk_fman/Peripherals/FM/Pcd/fman_prs.c | 129 +
71 .../sdk_fman/Peripherals/FM/Port/Makefile | 15 +
72 .../sdk_fman/Peripherals/FM/Port/fm_port.c | 6436 +++++++++++++++++
73 .../sdk_fman/Peripherals/FM/Port/fm_port.h | 999 +++
74 .../sdk_fman/Peripherals/FM/Port/fm_port_dsar.h | 494 ++
75 .../sdk_fman/Peripherals/FM/Port/fm_port_im.c | 753 ++
76 .../sdk_fman/Peripherals/FM/Port/fman_port.c | 1568 ++++
77 .../freescale/sdk_fman/Peripherals/FM/Rtc/Makefile | 15 +
78 .../freescale/sdk_fman/Peripherals/FM/Rtc/fm_rtc.c | 692 ++
79 .../freescale/sdk_fman/Peripherals/FM/Rtc/fm_rtc.h | 96 +
80 .../sdk_fman/Peripherals/FM/Rtc/fman_rtc.c | 334 +
81 .../freescale/sdk_fman/Peripherals/FM/SP/Makefile | 15 +
82 .../freescale/sdk_fman/Peripherals/FM/SP/fm_sp.c | 757 ++
83 .../freescale/sdk_fman/Peripherals/FM/SP/fm_sp.h | 85 +
84 .../freescale/sdk_fman/Peripherals/FM/SP/fman_sp.c | 197 +
85 .../freescale/sdk_fman/Peripherals/FM/fm.c | 5195 ++++++++++++++
86 .../freescale/sdk_fman/Peripherals/FM/fm.h | 646 ++
87 .../freescale/sdk_fman/Peripherals/FM/fm_ipc.h | 465 ++
88 .../freescale/sdk_fman/Peripherals/FM/fm_muram.c | 174 +
89 .../freescale/sdk_fman/Peripherals/FM/fman.c | 1399 ++++
90 .../sdk_fman/Peripherals/FM/inc/fm_common.h | 1203 ++++
91 .../freescale/sdk_fman/Peripherals/FM/inc/fm_hc.h | 93 +
92 .../sdk_fman/Peripherals/FM/inc/fm_sp_common.h | 117 +
93 .../net/ethernet/freescale/sdk_fman/etc/Makefile | 12 +
94 .../net/ethernet/freescale/sdk_fman/etc/error.c | 95 +
95 drivers/net/ethernet/freescale/sdk_fman/etc/list.c | 71 +
96 .../net/ethernet/freescale/sdk_fman/etc/memcpy.c | 620 ++
97 drivers/net/ethernet/freescale/sdk_fman/etc/mm.c | 1155 +++
98 drivers/net/ethernet/freescale/sdk_fman/etc/mm.h | 105 +
99 .../net/ethernet/freescale/sdk_fman/etc/sprint.c | 81 +
100 .../ethernet/freescale/sdk_fman/fmanv3h_dflags.h | 57 +
101 .../ethernet/freescale/sdk_fman/fmanv3l_dflags.h | 56 +
102 .../sdk_fman/inc/Peripherals/crc_mac_addr_ext.h | 364 +
103 .../freescale/sdk_fman/inc/Peripherals/dpaa_ext.h | 207 +
104 .../freescale/sdk_fman/inc/Peripherals/fm_ext.h | 1705 +++++
105 .../sdk_fman/inc/Peripherals/fm_mac_ext.h | 846 +++
106 .../sdk_fman/inc/Peripherals/fm_macsec_ext.h | 1271 ++++
107 .../sdk_fman/inc/Peripherals/fm_muram_ext.h | 170 +
108 .../sdk_fman/inc/Peripherals/fm_pcd_ext.h | 3974 +++++++++++
109 .../sdk_fman/inc/Peripherals/fm_port_ext.h | 2608 +++++++
110 .../sdk_fman/inc/Peripherals/fm_rtc_ext.h | 619 ++
111 .../sdk_fman/inc/Peripherals/fm_vsp_ext.h | 411 ++
112 .../sdk_fman/inc/Peripherals/mii_acc_ext.h | 76 +
113 .../net/ethernet/freescale/sdk_fman/inc/core_ext.h | 90 +
114 .../freescale/sdk_fman/inc/cores/arm_ext.h | 55 +
115 .../freescale/sdk_fman/inc/cores/e500v2_ext.h | 476 ++
116 .../freescale/sdk_fman/inc/cores/ppc_ext.h | 141 +
117 .../ethernet/freescale/sdk_fman/inc/ddr_std_ext.h | 77 +
118 .../ethernet/freescale/sdk_fman/inc/debug_ext.h | 233 +
119 .../ethernet/freescale/sdk_fman/inc/endian_ext.h | 447 ++
120 .../net/ethernet/freescale/sdk_fman/inc/enet_ext.h | 205 +
121 .../ethernet/freescale/sdk_fman/inc/error_ext.h | 529 ++
122 .../ethernet/freescale/sdk_fman/inc/etc/list_ext.h | 358 +
123 .../ethernet/freescale/sdk_fman/inc/etc/mem_ext.h | 318 +
124 .../freescale/sdk_fman/inc/etc/memcpy_ext.h | 208 +
125 .../ethernet/freescale/sdk_fman/inc/etc/mm_ext.h | 310 +
126 .../freescale/sdk_fman/inc/etc/sprint_ext.h | 118 +
127 .../sdk_fman/inc/flib/common/arch/ppc_access.h | 37 +
128 .../freescale/sdk_fman/inc/flib/common/general.h | 52 +
129 .../freescale/sdk_fman/inc/flib/fman_common.h | 78 +
130 .../freescale/sdk_fman/inc/flib/fsl_enet.h | 273 +
131 .../freescale/sdk_fman/inc/flib/fsl_fman.h | 825 +++
132 .../freescale/sdk_fman/inc/flib/fsl_fman_dtsec.h | 1096 +++
133 .../sdk_fman/inc/flib/fsl_fman_dtsec_mii_acc.h | 107 +
134 .../freescale/sdk_fman/inc/flib/fsl_fman_kg.h | 514 ++
135 .../freescale/sdk_fman/inc/flib/fsl_fman_memac.h | 427 ++
136 .../sdk_fman/inc/flib/fsl_fman_memac_mii_acc.h | 78 +
137 .../freescale/sdk_fman/inc/flib/fsl_fman_port.h | 593 ++
138 .../freescale/sdk_fman/inc/flib/fsl_fman_prs.h | 102 +
139 .../freescale/sdk_fman/inc/flib/fsl_fman_rtc.h | 449 ++
140 .../freescale/sdk_fman/inc/flib/fsl_fman_sp.h | 138 +
141 .../freescale/sdk_fman/inc/flib/fsl_fman_tgec.h | 479 ++
142 .../integrations/FMANV3H/dpaa_integration_ext.h | 290 +
143 .../sdk_fman/inc/integrations/FMANV3H/part_ext.h | 71 +
144 .../integrations/FMANV3H/part_integration_ext.h | 304 +
145 .../integrations/FMANV3L/dpaa_integration_ext.h | 292 +
146 .../sdk_fman/inc/integrations/FMANV3L/part_ext.h | 59 +
147 .../integrations/FMANV3L/part_integration_ext.h | 304 +
148 .../inc/integrations/LS1043/dpaa_integration_ext.h | 291 +
149 .../sdk_fman/inc/integrations/LS1043/part_ext.h | 64 +
150 .../inc/integrations/LS1043/part_integration_ext.h | 185 +
151 .../inc/integrations/P1023/dpaa_integration_ext.h | 213 +
152 .../sdk_fman/inc/integrations/P1023/part_ext.h | 82 +
153 .../inc/integrations/P1023/part_integration_ext.h | 635 ++
154 .../P3040_P4080_P5020/dpaa_integration_ext.h | 276 +
155 .../inc/integrations/P3040_P4080_P5020/part_ext.h | 83 +
156 .../P3040_P4080_P5020/part_integration_ext.h | 336 +
157 .../net/ethernet/freescale/sdk_fman/inc/math_ext.h | 99 +
158 .../net/ethernet/freescale/sdk_fman/inc/ncsw_ext.h | 435 ++
159 .../net/ethernet/freescale/sdk_fman/inc/net_ext.h | 430 ++
160 .../net/ethernet/freescale/sdk_fman/inc/std_ext.h | 48 +
161 .../ethernet/freescale/sdk_fman/inc/stdarg_ext.h | 49 +
162 .../ethernet/freescale/sdk_fman/inc/stdlib_ext.h | 162 +
163 .../ethernet/freescale/sdk_fman/inc/string_ext.h | 56 +
164 .../ethernet/freescale/sdk_fman/inc/types_ext.h | 62 +
165 .../ethernet/freescale/sdk_fman/inc/xx_common.h | 56 +
166 .../net/ethernet/freescale/sdk_fman/inc/xx_ext.h | 791 ++
167 .../ethernet/freescale/sdk_fman/ls1043_dflags.h | 56 +
168 .../net/ethernet/freescale/sdk_fman/ncsw_config.mk | 53 +
169 .../net/ethernet/freescale/sdk_fman/p1023_dflags.h | 65 +
170 .../freescale/sdk_fman/p3040_4080_5020_dflags.h | 62 +
171 .../net/ethernet/freescale/sdk_fman/src/Makefile | 11 +
172 .../freescale/sdk_fman/src/inc/system/sys_ext.h | 118 +
173 .../freescale/sdk_fman/src/inc/system/sys_io_ext.h | 46 +
174 .../freescale/sdk_fman/src/inc/types_linux.h | 208 +
175 .../sdk_fman/src/inc/wrapper/fsl_fman_test.h | 84 +
176 .../sdk_fman/src/inc/wrapper/lnxwrp_exp_sym.h | 127 +
177 .../sdk_fman/src/inc/wrapper/lnxwrp_fm_ext.h | 163 +
178 .../sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h | 919 +++
179 .../ethernet/freescale/sdk_fman/src/inc/xx/xx.h | 50 +
180 .../freescale/sdk_fman/src/system/Makefile | 10 +
181 .../freescale/sdk_fman/src/system/sys_io.c | 171 +
182 .../freescale/sdk_fman/src/wrapper/Makefile | 19 +
183 .../freescale/sdk_fman/src/wrapper/fman_test.c | 1665 +++++
184 .../freescale/sdk_fman/src/wrapper/lnxwrp_fm.c | 2795 ++++++++
185 .../freescale/sdk_fman/src/wrapper/lnxwrp_fm.h | 294 +
186 .../sdk_fman/src/wrapper/lnxwrp_fm_port.c | 1507 ++++
187 .../sdk_fman/src/wrapper/lnxwrp_ioctls_fm.c | 4813 +++++++++++++
188 .../sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.c | 1300 ++++
189 .../sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.h | 755 ++
190 .../sdk_fman/src/wrapper/lnxwrp_resources.h | 121 +
191 .../sdk_fman/src/wrapper/lnxwrp_resources_ut.c | 191 +
192 .../sdk_fman/src/wrapper/lnxwrp_resources_ut.h | 144 +
193 .../sdk_fman/src/wrapper/lnxwrp_resources_ut.make | 28 +
194 .../freescale/sdk_fman/src/wrapper/lnxwrp_sysfs.c | 60 +
195 .../freescale/sdk_fman/src/wrapper/lnxwrp_sysfs.h | 60 +
196 .../sdk_fman/src/wrapper/lnxwrp_sysfs_fm.c | 1855 +++++
197 .../sdk_fman/src/wrapper/lnxwrp_sysfs_fm.h | 136 +
198 .../sdk_fman/src/wrapper/lnxwrp_sysfs_fm_port.c | 1255 ++++
199 .../sdk_fman/src/wrapper/lnxwrp_sysfs_fm_port.h | 56 +
200 .../ethernet/freescale/sdk_fman/src/xx/Makefile | 18 +
201 .../freescale/sdk_fman/src/xx/module_strings.c | 45 +
202 .../ethernet/freescale/sdk_fman/src/xx/udivdi3.c | 132 +
203 .../freescale/sdk_fman/src/xx/xx_arm_linux.c | 905 +++
204 .../ethernet/freescale/sdk_fman/src/xx/xx_linux.c | 918 +++
205 include/uapi/linux/fmd/Kbuild | 5 +
206 include/uapi/linux/fmd/Peripherals/Kbuild | 4 +
207 include/uapi/linux/fmd/Peripherals/fm_ioctls.h | 628 ++
208 include/uapi/linux/fmd/Peripherals/fm_pcd_ioctls.h | 3084 ++++++++
209 .../uapi/linux/fmd/Peripherals/fm_port_ioctls.h | 948 +++
210 .../uapi/linux/fmd/Peripherals/fm_test_ioctls.h | 208 +
211 include/uapi/linux/fmd/integrations/Kbuild | 1 +
212 .../linux/fmd/integrations/integration_ioctls.h | 56 +
213 include/uapi/linux/fmd/ioctls.h | 96 +
214 include/uapi/linux/fmd/net_ioctls.h | 430 ++
215 200 files changed, 115244 insertions(+)
216 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Kconfig
217 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Makefile
218 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/HC/Makefile
219 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/HC/hc.c
220 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/Makefile
221 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c
222 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.h
223 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec_mii_acc.c
224 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec_mii_acc.h
225 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c
226 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h
227 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_crc32.c
228 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_crc32.h
229 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_dtsec.c
230 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_dtsec_mii_acc.c
231 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_memac.c
232 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_memac_mii_acc.c
233 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_tgec.c
234 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.c
235 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.h
236 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac_mii_acc.c
237 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac_mii_acc.h
238 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec.c
239 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec.h
240 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec_mii_acc.c
241 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec_mii_acc.h
242 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/Makefile
243 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec.c
244 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec.h
245 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_guest.c
246 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_master.c
247 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_master.h
248 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_secy.c
249 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_secy.h
250 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Makefile
251 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/Makefile
252 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/crc64.h
253 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.c
254 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.h
255 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c
256 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.h
257 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_manip.c
258 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_manip.h
259 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_pcd.c
260 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_pcd.h
261 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_pcd_ipc.h
262 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_plcr.c
263 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_plcr.h
264 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_prs.c
265 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_prs.h
266 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_replic.c
267 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_replic.h
268 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fman_kg.c
269 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fman_prs.c
270 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/Makefile
271 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c
272 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.h
273 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port_dsar.h
274 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port_im.c
275 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fman_port.c
276 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Rtc/Makefile
277 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Rtc/fm_rtc.c
278 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Rtc/fm_rtc.h
279 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Rtc/fman_rtc.c
280 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/SP/Makefile
281 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/SP/fm_sp.c
282 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/SP/fm_sp.h
283 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/SP/fman_sp.c
284 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.c
285 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.h
286 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm_ipc.h
287 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm_muram.c
288 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fman.c
289 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc/fm_common.h
290 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc/fm_hc.h
291 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc/fm_sp_common.h
292 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/Makefile
293 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/error.c
294 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/list.c
295 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/memcpy.c
296 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/mm.c
297 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/mm.h
298 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/sprint.c
299 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/fmanv3h_dflags.h
300 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/fmanv3l_dflags.h
301 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/crc_mac_addr_ext.h
302 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/dpaa_ext.h
303 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_ext.h
304 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_mac_ext.h
305 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_macsec_ext.h
306 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_muram_ext.h
307 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_pcd_ext.h
308 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_port_ext.h
309 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_rtc_ext.h
310 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_vsp_ext.h
311 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/mii_acc_ext.h
312 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/core_ext.h
313 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/cores/arm_ext.h
314 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/cores/e500v2_ext.h
315 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/cores/ppc_ext.h
316 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/ddr_std_ext.h
317 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/debug_ext.h
318 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/endian_ext.h
319 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/enet_ext.h
320 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/error_ext.h
321 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/etc/list_ext.h
322 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/etc/mem_ext.h
323 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/etc/memcpy_ext.h
324 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/etc/mm_ext.h
325 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/etc/sprint_ext.h
326 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/common/arch/ppc_access.h
327 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/common/general.h
328 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fman_common.h
329 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_enet.h
330 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman.h
331 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_dtsec.h
332 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_dtsec_mii_acc.h
333 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_kg.h
334 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_memac.h
335 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_memac_mii_acc.h
336 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_port.h
337 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_prs.h
338 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_rtc.h
339 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_sp.h
340 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_tgec.h
341 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3H/dpaa_integration_ext.h
342 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3H/part_ext.h
343 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3H/part_integration_ext.h
344 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3L/dpaa_integration_ext.h
345 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3L/part_ext.h
346 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3L/part_integration_ext.h
347 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/dpaa_integration_ext.h
348 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/part_ext.h
349 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/part_integration_ext.h
350 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P1023/dpaa_integration_ext.h
351 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P1023/part_ext.h
352 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P1023/part_integration_ext.h
353 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P3040_P4080_P5020/dpaa_integration_ext.h
354 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P3040_P4080_P5020/part_ext.h
355 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P3040_P4080_P5020/part_integration_ext.h
356 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/math_ext.h
357 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/ncsw_ext.h
358 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/net_ext.h
359 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/std_ext.h
360 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/stdarg_ext.h
361 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/stdlib_ext.h
362 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/string_ext.h
363 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/types_ext.h
364 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/xx_common.h
365 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/xx_ext.h
366 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/ls1043_dflags.h
367 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
368 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/p1023_dflags.h
369 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/p3040_4080_5020_dflags.h
370 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/Makefile
371 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/system/sys_ext.h
372 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/system/sys_io_ext.h
373 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/types_linux.h
374 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/fsl_fman_test.h
375 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_exp_sym.h
376 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fm_ext.h
377 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
378 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/xx/xx.h
379 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/system/Makefile
380 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/system/sys_io.c
381 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/Makefile
382 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/fman_test.c
383 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
384 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.h
385 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm_port.c
386 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm.c
387 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.c
388 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.h
389 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_resources.h
390 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_resources_ut.c
391 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_resources_ut.h
392 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_resources_ut.make
393 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs.c
394 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs.h
395 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm.c
396 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm.h
397 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm_port.c
398 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm_port.h
399 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/xx/Makefile
400 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/xx/module_strings.c
401 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/xx/udivdi3.c
402 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/xx/xx_arm_linux.c
403 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/xx/xx_linux.c
404 create mode 100644 include/uapi/linux/fmd/Kbuild
405 create mode 100644 include/uapi/linux/fmd/Peripherals/Kbuild
406 create mode 100644 include/uapi/linux/fmd/Peripherals/fm_ioctls.h
407 create mode 100644 include/uapi/linux/fmd/Peripherals/fm_pcd_ioctls.h
408 create mode 100644 include/uapi/linux/fmd/Peripherals/fm_port_ioctls.h
409 create mode 100644 include/uapi/linux/fmd/Peripherals/fm_test_ioctls.h
410 create mode 100644 include/uapi/linux/fmd/integrations/Kbuild
411 create mode 100644 include/uapi/linux/fmd/integrations/integration_ioctls.h
412 create mode 100644 include/uapi/linux/fmd/ioctls.h
413 create mode 100644 include/uapi/linux/fmd/net_ioctls.h
414
415 --- a/drivers/net/ethernet/freescale/Kconfig
416 +++ b/drivers/net/ethernet/freescale/Kconfig
417 @@ -92,4 +92,5 @@ config GIANFAR
418 and MPC86xx family of chips, the eTSEC on LS1021A and the FEC
419 on the 8540.
420
421 +source "drivers/net/ethernet/freescale/sdk_fman/Kconfig"
422 endif # NET_VENDOR_FREESCALE
423 --- a/drivers/net/ethernet/freescale/Makefile
424 +++ b/drivers/net/ethernet/freescale/Makefile
425 @@ -17,3 +17,4 @@ gianfar_driver-objs := gianfar.o \
426 gianfar_ethtool.o
427 obj-$(CONFIG_UCC_GETH) += ucc_geth_driver.o
428 ucc_geth_driver-objs := ucc_geth.o ucc_geth_ethtool.o
429 +obj-$(if $(CONFIG_FSL_SDK_FMAN),y) += sdk_fman/
430 --- /dev/null
431 +++ b/drivers/net/ethernet/freescale/sdk_fman/Kconfig
432 @@ -0,0 +1,151 @@
433 +menu "Frame Manager support"
434 +
435 +menuconfig FSL_SDK_FMAN
436 + bool "Freescale Frame Manager (datapath) support - SDK driver"
437 + depends on (FSL_SOC || ARM64 || ARM) && FSL_BMAN && FSL_QMAN
438 + default y
439 + ---help---
440 + If unsure, say Y.
441 +
442 +if FSL_SDK_FMAN
443 +
444 +config FSL_SDK_FMAN_TEST
445 + bool "FMan test module"
446 + default n
447 + select FSL_DPAA_HOOKS
448 + ---help---
449 + This option compiles test code for FMan.
450 +
451 +menu "FMAN Processor support"
452 +choice
453 + depends on FSL_SDK_FMAN
454 + prompt "Processor Type"
455 +
456 +config FMAN_ARM
457 + bool "LS1043"
458 + depends on ARM64 || ARM
459 + ---help---
460 + Choose "LS1043" for the ARM platforms:
461 + LS1043
462 +
463 +config FMAN_P3040_P4080_P5020
464 + bool "P3040 P4080 5020"
465 +
466 +config FMAN_P1023
467 + bool "P1023"
468 +
469 +config FMAN_V3H
470 + bool "FmanV3H"
471 + ---help---
472 + Choose "FmanV3H" for Fman rev3H:
473 + B4860, T4240, T4160, etc
474 +
475 +config FMAN_V3L
476 + bool "FmanV3L"
477 + ---help---
478 + Choose "FmanV3L" for Fman rev3L:
479 + T1040, T1042, T1020, T1022, T1023, T1024, etc
480 +
481 +endchoice
482 +endmenu
483 +
484 +config FMAN_MIB_CNT_OVF_IRQ_EN
485 + bool "Enable the dTSEC MIB counters overflow interrupt"
486 + default n
487 + ---help---
488 + Enable the dTSEC MIB counters overflow interrupt to get
489 + accurate MIB counters values. Enabled it compensates
490 + for the counters overflow but reduces performance and
491 + triggers error messages in HV setups.
492 +
493 +config FSL_FM_MAX_FRAME_SIZE
494 + int "Maximum L2 frame size"
495 + depends on FSL_SDK_FMAN
496 + range 64 9600
497 + default "1522"
498 + help
499 + Configure this in relation to the maximum possible MTU of your
500 + network configuration. In particular, one would need to
501 + increase this value in order to use jumbo frames.
502 + FSL_FM_MAX_FRAME_SIZE must accommodate the Ethernet FCS (4 bytes)
503 + and one ETH+VLAN header (18 bytes), to a total of 22 bytes in
504 + excess of the desired L3 MTU.
505 +
506 + Note that having too large a FSL_FM_MAX_FRAME_SIZE (much larger
507 + than the actual MTU) may lead to buffer exhaustion, especially
508 + in the case of badly fragmented datagrams on the Rx path.
509 + Conversely, having a FSL_FM_MAX_FRAME_SIZE smaller than the actual
510 + MTU will lead to frames being dropped.
511 +
512 + This can be overridden by specifying "fsl_fm_max_frm" in
513 + the kernel bootargs:
514 + * in Hypervisor-based scenarios, by adding a "chosen" node
515 + with the "bootargs" property specifying
516 + "fsl_fm_max_frm=<YourValue>";
517 + * in non-Hypervisor-based scenarios, via u-boot's env, by
518 + modifying the "bootargs" env variable.
519 +
520 +config FSL_FM_RX_EXTRA_HEADROOM
521 + int "Add extra headroom at beginning of data buffers"
522 + depends on FSL_SDK_FMAN
523 + range 16 384
524 + default "64"
525 + help
526 + Configure this to tell the Frame Manager to reserve some extra
527 + space at the beginning of a data buffer on the receive path,
528 + before Internal Context fields are copied. This is in addition
529 + to the private data area already reserved for driver internal
530 + use. The provided value must be a multiple of 16.
531 +
532 + This setting can be overridden by specifying
533 + "fsl_fm_rx_extra_headroom" in the kernel bootargs:
534 + * in Hypervisor-based scenarios, by adding a "chosen" node
535 + with the "bootargs" property specifying
536 + "fsl_fm_rx_extra_headroom=<YourValue>";
537 + * in non-Hypervisor-based scenarios, via u-boot's env, by
538 + modifying the "bootargs" env variable.
539 +
540 +config FMAN_PFC
541 + bool "FMan PFC support (EXPERIMENTAL)"
542 + depends on ( FMAN_V3H || FMAN_V3L || FMAN_ARM) && FSL_SDK_FMAN
543 + default n
544 + ---help---
545 + This option enables PFC support on FMan v3 ports.
546 + Data Center Bridging defines Classes of Service that are
547 + flow-controlled using PFC pause frames.
548 +
549 +if FMAN_PFC
550 +config FMAN_PFC_COS_COUNT
551 + int "Number of PFC Classes of Service"
552 + depends on FMAN_PFC && FSL_SDK_FMAN
553 + range 1 4
554 + default "3"
555 +
556 +config FMAN_PFC_QUANTA_0
557 + int "The pause quanta for PFC CoS 0"
558 + depends on FMAN_PFC && FSL_SDK_FMAN
559 + range 0 65535
560 + default "65535"
561 +
562 +config FMAN_PFC_QUANTA_1
563 + int "The pause quanta for PFC CoS 1"
564 + depends on FMAN_PFC && FSL_SDK_FMAN
565 + range 0 65535
566 + default "65535"
567 +
568 +config FMAN_PFC_QUANTA_2
569 + int "The pause quanta for PFC CoS 2"
570 + depends on FMAN_PFC && FSL_SDK_FMAN
571 + range 0 65535
572 + default "65535"
573 +
574 +config FMAN_PFC_QUANTA_3
575 + int "The pause quanta for PFC CoS 3"
576 + depends on FMAN_PFC && FSL_SDK_FMAN
577 + range 0 65535
578 + default "65535"
579 +endif
580 +
581 +endif # FSL_SDK_FMAN
582 +
583 +endmenu
584 --- /dev/null
585 +++ b/drivers/net/ethernet/freescale/sdk_fman/Makefile
586 @@ -0,0 +1,11 @@
587 +#
588 +# Makefile for the Freescale Ethernet controllers
589 +#
590 +ccflags-y += -DVERSION=\"\"
591 +#
592 +#Include netcomm SW specific definitions
593 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
594 +#
595 +obj-y += etc/
596 +obj-y += Peripherals/FM/
597 +obj-y += src/
598 --- /dev/null
599 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/HC/Makefile
600 @@ -0,0 +1,15 @@
601 +#
602 +# Makefile for the Freescale Ethernet controllers
603 +#
604 +ccflags-y += -DVERSION=\"\"
605 +#
606 +#Include netcomm SW specific definitions
607 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
608 +
609 +NCSW_FM_INC = $(srctree)/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc
610 +
611 +ccflags-y += -I$(NCSW_FM_INC)
612 +
613 +obj-y += fsl-ncsw-Hc.o
614 +
615 +fsl-ncsw-Hc-objs := hc.o
616 --- /dev/null
617 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/HC/hc.c
618 @@ -0,0 +1,1232 @@
619 +/*
620 + * Copyright 2008-2012 Freescale Semiconductor Inc.
621 + *
622 + * Redistribution and use in source and binary forms, with or without
623 + * modification, are permitted provided that the following conditions are met:
624 + * * Redistributions of source code must retain the above copyright
625 + * notice, this list of conditions and the following disclaimer.
626 + * * Redistributions in binary form must reproduce the above copyright
627 + * notice, this list of conditions and the following disclaimer in the
628 + * documentation and/or other materials provided with the distribution.
629 + * * Neither the name of Freescale Semiconductor nor the
630 + * names of its contributors may be used to endorse or promote products
631 + * derived from this software without specific prior written permission.
632 + *
633 + *
634 + * ALTERNATIVELY, this software may be distributed under the terms of the
635 + * GNU General Public License ("GPL") as published by the Free Software
636 + * Foundation, either version 2 of that License or (at your option) any
637 + * later version.
638 + *
639 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
640 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
641 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
642 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
643 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
644 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
645 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
646 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
647 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
648 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
649 + */
650 +
651 +
652 +#include "std_ext.h"
653 +#include "error_ext.h"
654 +#include "sprint_ext.h"
655 +#include "string_ext.h"
656 +
657 +#include "fm_common.h"
658 +#include "fm_hc.h"
659 +
660 +
661 +/**************************************************************************//**
662 + @Description defaults
663 +*//***************************************************************************/
664 +#define DEFAULT_dataMemId 0
665 +
666 +#define HC_HCOR_OPCODE_PLCR_PRFL 0x0
667 +#define HC_HCOR_OPCODE_KG_SCM 0x1
668 +#define HC_HCOR_OPCODE_SYNC 0x2
669 +#define HC_HCOR_OPCODE_CC 0x3
670 +#define HC_HCOR_OPCODE_CC_AGE_MASK 0x4
671 +#define HC_HCOR_OPCODE_CC_CAPWAP_REASSM_TIMEOUT 0x5
672 +#define HC_HCOR_OPCODE_CC_REASSM_TIMEOUT 0x10
673 +#define HC_HCOR_OPCODE_CC_IP_FRAG_INITIALIZATION 0x11
674 +#define HC_HCOR_OPCODE_CC_UPDATE_WITH_AGING 0x13
675 +#define HC_HCOR_ACTION_REG_REASSM_TIMEOUT_ACTIVE_SHIFT 24
676 +#define HC_HCOR_EXTRA_REG_REASSM_TIMEOUT_TSBS_SHIFT 24
677 +#define HC_HCOR_EXTRA_REG_CC_AGING_ADD 0x80000000
678 +#define HC_HCOR_EXTRA_REG_CC_AGING_REMOVE 0x40000000
679 +#define HC_HCOR_EXTRA_REG_CC_AGING_CHANGE_MASK 0xC0000000
680 +#define HC_HCOR_EXTRA_REG_CC_REMOVE_INDX_SHIFT 24
681 +#define HC_HCOR_EXTRA_REG_CC_REMOVE_INDX_MASK 0x1F000000
682 +#define HC_HCOR_ACTION_REG_REASSM_TIMEOUT_RES_SHIFT 16
683 +#define HC_HCOR_ACTION_REG_REASSM_TIMEOUT_RES_MASK 0xF
684 +#define HC_HCOR_ACTION_REG_IP_FRAG_SCRATCH_POOL_CMD_SHIFT 24
685 +#define HC_HCOR_ACTION_REG_IP_FRAG_SCRATCH_POOL_BPID 16
686 +
687 +#define HC_HCOR_GBL 0x20000000
688 +
689 +#define HC_HCOR_KG_SCHEME_COUNTER 0x00000400
690 +
691 +#if (DPAA_VERSION == 10)
692 +#define HC_HCOR_KG_SCHEME_REGS_MASK 0xFFFFF800
693 +#else
694 +#define HC_HCOR_KG_SCHEME_REGS_MASK 0xFFFFFE00
695 +#endif /* (DPAA_VERSION == 10) */
696 +
697 +#define SIZE_OF_HC_FRAME_PORT_REGS (sizeof(t_HcFrame)-sizeof(struct fman_kg_scheme_regs)+sizeof(t_FmPcdKgPortRegs))
698 +#define SIZE_OF_HC_FRAME_SCHEME_REGS sizeof(t_HcFrame)
699 +#define SIZE_OF_HC_FRAME_PROFILES_REGS (sizeof(t_HcFrame)-sizeof(struct fman_kg_scheme_regs)+sizeof(t_FmPcdPlcrProfileRegs))
700 +#define SIZE_OF_HC_FRAME_PROFILE_CNT (sizeof(t_HcFrame)-sizeof(t_FmPcdPlcrProfileRegs)+sizeof(uint32_t))
701 +#define SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC 16
702 +
703 +#define HC_CMD_POOL_SIZE (INTG_MAX_NUM_OF_CORES)
704 +
705 +#define BUILD_FD(len) \
706 +do { \
707 + memset(&fmFd, 0, sizeof(t_DpaaFD)); \
708 + DPAA_FD_SET_ADDR(&fmFd, p_HcFrame); \
709 + DPAA_FD_SET_OFFSET(&fmFd, 0); \
710 + DPAA_FD_SET_LENGTH(&fmFd, len); \
711 +} while (0)
712 +
713 +
714 +#if defined(__MWERKS__) && !defined(__GNUC__)
715 +#pragma pack(push,1)
716 +#endif /* defined(__MWERKS__) && ... */
717 +
718 +typedef struct t_FmPcdKgPortRegs {
719 + volatile uint32_t spReg;
720 + volatile uint32_t cppReg;
721 +} t_FmPcdKgPortRegs;
722 +
723 +typedef struct t_HcFrame {
724 + volatile uint32_t opcode;
725 + volatile uint32_t actionReg;
726 + volatile uint32_t extraReg;
727 + volatile uint32_t commandSequence;
728 + union {
729 + struct fman_kg_scheme_regs schemeRegs;
730 + struct fman_kg_scheme_regs schemeRegsWithoutCounter;
731 + t_FmPcdPlcrProfileRegs profileRegs;
732 + volatile uint32_t singleRegForWrite; /* for writing SP, CPP, profile counter */
733 + t_FmPcdKgPortRegs portRegsForRead;
734 + volatile uint32_t clsPlanEntries[CLS_PLAN_NUM_PER_GRP];
735 + t_FmPcdCcCapwapReassmTimeoutParams ccCapwapReassmTimeout;
736 + t_FmPcdCcReassmTimeoutParams ccReassmTimeout;
737 + } hcSpecificData;
738 +} t_HcFrame;
739 +
740 +#if defined(__MWERKS__) && !defined(__GNUC__)
741 +#pragma pack(pop)
742 +#endif /* defined(__MWERKS__) && ... */
743 +
744 +
745 +typedef struct t_FmHc {
746 + t_Handle h_FmPcd;
747 + t_Handle h_HcPortDev;
748 + t_FmPcdQmEnqueueCallback *f_QmEnqueue; /**< A callback for enqueuing frames to the QM */
749 + t_Handle h_QmArg; /**< A handle to the QM module */
750 + uint8_t dataMemId; /**< Memory partition ID for data buffers */
751 +
752 + uint32_t seqNum[HC_CMD_POOL_SIZE]; /* FIFO of seqNum to use when
753 + taking buffer */
754 + uint32_t nextSeqNumLocation; /* seqNum location in seqNum[] for next buffer */
755 + volatile bool enqueued[HC_CMD_POOL_SIZE]; /* HC is active - frame is enqueued
756 + and not confirmed yet */
757 + t_HcFrame *p_Frm[HC_CMD_POOL_SIZE];
758 +} t_FmHc;
759 +
760 +
761 +static t_Error FillBufPool(t_FmHc *p_FmHc)
762 +{
763 + uint32_t i;
764 +
765 + ASSERT_COND(p_FmHc);
766 +
767 + for (i = 0; i < HC_CMD_POOL_SIZE; i++)
768 + {
769 +#ifdef FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004
770 + p_FmHc->p_Frm[i] = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + (16 - (sizeof(t_FmHc) % 16))),
771 + p_FmHc->dataMemId,
772 + 16);
773 +#else
774 + p_FmHc->p_Frm[i] = (t_HcFrame *)XX_MallocSmart(sizeof(t_HcFrame),
775 + p_FmHc->dataMemId,
776 + 16);
777 +#endif /* FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004 */
778 + if (!p_FmHc->p_Frm[i])
779 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FM HC frames!"));
780 + }
781 +
782 + /* Initialize FIFO of seqNum to use during GetBuf */
783 + for (i = 0; i < HC_CMD_POOL_SIZE; i++)
784 + {
785 + p_FmHc->seqNum[i] = i;
786 + }
787 + p_FmHc->nextSeqNumLocation = 0;
788 +
789 + return E_OK;
790 +}
791 +
792 +static __inline__ t_HcFrame * GetBuf(t_FmHc *p_FmHc, uint32_t *p_SeqNum)
793 +{
794 + uint32_t intFlags;
795 +
796 + ASSERT_COND(p_FmHc);
797 +
798 + intFlags = FmPcdLock(p_FmHc->h_FmPcd);
799 +
800 + if (p_FmHc->nextSeqNumLocation == HC_CMD_POOL_SIZE)
801 + {
802 + /* No more buffers */
803 + FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
804 + return NULL;
805 + }
806 +
807 + *p_SeqNum = p_FmHc->seqNum[p_FmHc->nextSeqNumLocation];
808 + p_FmHc->nextSeqNumLocation++;
809 +
810 + FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
811 + return p_FmHc->p_Frm[*p_SeqNum];
812 +}
813 +
814 +static __inline__ void PutBuf(t_FmHc *p_FmHc, t_HcFrame *p_Buf, uint32_t seqNum)
815 +{
816 + uint32_t intFlags;
817 +
818 + UNUSED(p_Buf);
819 +
820 + intFlags = FmPcdLock(p_FmHc->h_FmPcd);
821 + ASSERT_COND(p_FmHc->nextSeqNumLocation);
822 + p_FmHc->nextSeqNumLocation--;
823 + p_FmHc->seqNum[p_FmHc->nextSeqNumLocation] = seqNum;
824 + FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
825 +}
826 +
827 +static __inline__ t_Error EnQFrm(t_FmHc *p_FmHc, t_DpaaFD *p_FmFd, uint32_t seqNum)
828 +{
829 + t_Error err = E_OK;
830 + uint32_t intFlags;
831 + uint32_t timeout=100;
832 +
833 + intFlags = FmPcdLock(p_FmHc->h_FmPcd);
834 + ASSERT_COND(!p_FmHc->enqueued[seqNum]);
835 + p_FmHc->enqueued[seqNum] = TRUE;
836 + FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
837 + DBG(TRACE, ("Send Hc, SeqNum %d, buff@0x%x, fd offset 0x%x",
838 + seqNum,
839 + DPAA_FD_GET_ADDR(p_FmFd),
840 + DPAA_FD_GET_OFFSET(p_FmFd)));
841 + err = p_FmHc->f_QmEnqueue(p_FmHc->h_QmArg, (void *)p_FmFd);
842 + if (err)
843 + RETURN_ERROR(MINOR, err, ("HC enqueue failed"));
844 +
845 + while (p_FmHc->enqueued[seqNum] && --timeout)
846 + XX_UDelay(100);
847 +
848 + if (!timeout)
849 + RETURN_ERROR(MINOR, E_TIMEOUT, ("HC Callback, timeout exceeded"));
850 +
851 + return err;
852 +}
853 +
854 +
855 +t_Handle FmHcConfigAndInit(t_FmHcParams *p_FmHcParams)
856 +{
857 + t_FmHc *p_FmHc;
858 + t_FmPortParams fmPortParam;
859 + t_Error err;
860 +
861 + p_FmHc = (t_FmHc *)XX_Malloc(sizeof(t_FmHc));
862 + if (!p_FmHc)
863 + {
864 + REPORT_ERROR(MINOR, E_NO_MEMORY, ("HC obj"));
865 + return NULL;
866 + }
867 + memset(p_FmHc,0,sizeof(t_FmHc));
868 +
869 + p_FmHc->h_FmPcd = p_FmHcParams->h_FmPcd;
870 + p_FmHc->f_QmEnqueue = p_FmHcParams->params.f_QmEnqueue;
871 + p_FmHc->h_QmArg = p_FmHcParams->params.h_QmArg;
872 + p_FmHc->dataMemId = DEFAULT_dataMemId;
873 +
874 + err = FillBufPool(p_FmHc);
875 + if (err != E_OK)
876 + {
877 + REPORT_ERROR(MAJOR, err, NO_MSG);
878 + FmHcFree(p_FmHc);
879 + return NULL;
880 + }
881 +
882 + if (!FmIsMaster(p_FmHcParams->h_Fm))
883 + return (t_Handle)p_FmHc;
884 +
885 + memset(&fmPortParam, 0, sizeof(fmPortParam));
886 + fmPortParam.baseAddr = p_FmHcParams->params.portBaseAddr;
887 + fmPortParam.portType = e_FM_PORT_TYPE_OH_HOST_COMMAND;
888 + fmPortParam.portId = p_FmHcParams->params.portId;
889 + fmPortParam.liodnBase = p_FmHcParams->params.liodnBase;
890 + fmPortParam.h_Fm = p_FmHcParams->h_Fm;
891 +
892 + fmPortParam.specificParams.nonRxParams.errFqid = p_FmHcParams->params.errFqid;
893 + fmPortParam.specificParams.nonRxParams.dfltFqid = p_FmHcParams->params.confFqid;
894 + fmPortParam.specificParams.nonRxParams.qmChannel = p_FmHcParams->params.qmChannel;
895 +
896 + p_FmHc->h_HcPortDev = FM_PORT_Config(&fmPortParam);
897 + if (!p_FmHc->h_HcPortDev)
898 + {
899 + REPORT_ERROR(MAJOR, E_INVALID_HANDLE, ("FM HC port!"));
900 + XX_Free(p_FmHc);
901 + return NULL;
902 + }
903 +
904 + err = FM_PORT_ConfigMaxFrameLength(p_FmHc->h_HcPortDev,
905 + (uint16_t)sizeof(t_HcFrame));
906 +
907 + if (err != E_OK)
908 + {
909 + REPORT_ERROR(MAJOR, err, ("FM HC port init!"));
910 + FmHcFree(p_FmHc);
911 + return NULL;
912 + }
913 +
914 + /* final init */
915 + err = FM_PORT_Init(p_FmHc->h_HcPortDev);
916 + if (err != E_OK)
917 + {
918 + REPORT_ERROR(MAJOR, err, ("FM HC port init!"));
919 + FmHcFree(p_FmHc);
920 + return NULL;
921 + }
922 +
923 + err = FM_PORT_Enable(p_FmHc->h_HcPortDev);
924 + if (err != E_OK)
925 + {
926 + REPORT_ERROR(MAJOR, err, ("FM HC port enable!"));
927 + FmHcFree(p_FmHc);
928 + return NULL;
929 + }
930 +
931 + return (t_Handle)p_FmHc;
932 +}
933 +
934 +void FmHcFree(t_Handle h_FmHc)
935 +{
936 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
937 + int i;
938 +
939 + if (!p_FmHc)
940 + return;
941 +
942 + for (i=0; i<HC_CMD_POOL_SIZE; i++)
943 + if (p_FmHc->p_Frm[i])
944 + XX_FreeSmart(p_FmHc->p_Frm[i]);
945 + else
946 + break;
947 +
948 + if (p_FmHc->h_HcPortDev)
949 + FM_PORT_Free(p_FmHc->h_HcPortDev);
950 +
951 + XX_Free(p_FmHc);
952 +}
953 +
954 +/*****************************************************************************/
955 +t_Error FmHcSetFramesDataMemory(t_Handle h_FmHc,
956 + uint8_t memId)
957 +{
958 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
959 + int i;
960 +
961 + SANITY_CHECK_RETURN_ERROR(p_FmHc, E_INVALID_HANDLE);
962 +
963 + p_FmHc->dataMemId = memId;
964 +
965 + for (i=0; i<HC_CMD_POOL_SIZE; i++)
966 + if (p_FmHc->p_Frm[i])
967 + XX_FreeSmart(p_FmHc->p_Frm[i]);
968 +
969 + return FillBufPool(p_FmHc);
970 +}
971 +
972 +void FmHcTxConf(t_Handle h_FmHc, t_DpaaFD *p_Fd)
973 +{
974 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
975 + t_HcFrame *p_HcFrame;
976 + uint32_t intFlags;
977 +
978 + ASSERT_COND(p_FmHc);
979 +
980 + intFlags = FmPcdLock(p_FmHc->h_FmPcd);
981 + p_HcFrame = (t_HcFrame *)PTR_MOVE(DPAA_FD_GET_ADDR(p_Fd), DPAA_FD_GET_OFFSET(p_Fd));
982 +
983 + DBG(TRACE, ("Hc Conf, SeqNum %d, FD@0x%x, fd offset 0x%x",
984 + p_HcFrame->commandSequence, DPAA_FD_GET_ADDR(p_Fd), DPAA_FD_GET_OFFSET(p_Fd)));
985 +
986 + if (!(p_FmHc->enqueued[p_HcFrame->commandSequence]))
987 + REPORT_ERROR(MINOR, E_INVALID_FRAME, ("Not an Host-Command frame received!"));
988 + else
989 + p_FmHc->enqueued[p_HcFrame->commandSequence] = FALSE;
990 + FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
991 +}
992 +
993 +t_Error FmHcPcdKgSetScheme(t_Handle h_FmHc,
994 + t_Handle h_Scheme,
995 + struct fman_kg_scheme_regs *p_SchemeRegs,
996 + bool updateCounter)
997 +{
998 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
999 + t_Error err = E_OK;
1000 + t_HcFrame *p_HcFrame;
1001 + t_DpaaFD fmFd;
1002 + uint8_t physicalSchemeId;
1003 + uint32_t seqNum;
1004 +
1005 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1006 + if (!p_HcFrame)
1007 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1008 +
1009 + physicalSchemeId = FmPcdKgGetSchemeId(h_Scheme);
1010 +
1011 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1012 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
1013 + p_HcFrame->actionReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, updateCounter);
1014 + p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
1015 + memcpy(&p_HcFrame->hcSpecificData.schemeRegs, p_SchemeRegs, sizeof(struct fman_kg_scheme_regs));
1016 + if (!updateCounter)
1017 + {
1018 + p_HcFrame->hcSpecificData.schemeRegs.kgse_dv0 = p_SchemeRegs->kgse_dv0;
1019 + p_HcFrame->hcSpecificData.schemeRegs.kgse_dv1 = p_SchemeRegs->kgse_dv1;
1020 + p_HcFrame->hcSpecificData.schemeRegs.kgse_ccbs = p_SchemeRegs->kgse_ccbs;
1021 + p_HcFrame->hcSpecificData.schemeRegs.kgse_mv = p_SchemeRegs->kgse_mv;
1022 + }
1023 + p_HcFrame->commandSequence = seqNum;
1024 +
1025 + BUILD_FD(sizeof(t_HcFrame));
1026 +
1027 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1028 +
1029 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1030 +
1031 + if (err != E_OK)
1032 + RETURN_ERROR(MINOR, err, NO_MSG);
1033 +
1034 + return E_OK;
1035 +}
1036 +
1037 +t_Error FmHcPcdKgDeleteScheme(t_Handle h_FmHc, t_Handle h_Scheme)
1038 +{
1039 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1040 + t_Error err = E_OK;
1041 + t_HcFrame *p_HcFrame;
1042 + t_DpaaFD fmFd;
1043 + uint8_t physicalSchemeId = FmPcdKgGetSchemeId(h_Scheme);
1044 + uint32_t seqNum;
1045 +
1046 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1047 + if (!p_HcFrame)
1048 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1049 +
1050 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1051 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
1052 + p_HcFrame->actionReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, TRUE);
1053 + p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
1054 + memset(&p_HcFrame->hcSpecificData.schemeRegs, 0, sizeof(struct fman_kg_scheme_regs));
1055 + p_HcFrame->commandSequence = seqNum;
1056 +
1057 + BUILD_FD(sizeof(t_HcFrame));
1058 +
1059 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1060 +
1061 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1062 +
1063 + if (err != E_OK)
1064 + RETURN_ERROR(MINOR, err, NO_MSG);
1065 +
1066 + return E_OK;
1067 +}
1068 +
1069 +t_Error FmHcPcdKgCcGetSetParams(t_Handle h_FmHc, t_Handle h_Scheme, uint32_t requiredAction, uint32_t value)
1070 +{
1071 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1072 + t_Error err = E_OK;
1073 + t_HcFrame *p_HcFrame;
1074 + t_DpaaFD fmFd;
1075 + uint8_t relativeSchemeId;
1076 + uint8_t physicalSchemeId = FmPcdKgGetSchemeId(h_Scheme);
1077 + uint32_t tmpReg32 = 0;
1078 + uint32_t seqNum;
1079 +
1080 + /* Scheme is locked by calling routine */
1081 + /* WARNING - this lock will not be efficient if other HC routine will attempt to change
1082 + * "kgse_mode" or "kgse_om" without locking scheme !
1083 + */
1084 +
1085 + relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmHc->h_FmPcd, physicalSchemeId);
1086 + if ( relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
1087 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
1088 +
1089 + if (!FmPcdKgGetRequiredActionFlag(p_FmHc->h_FmPcd, relativeSchemeId) ||
1090 + !(FmPcdKgGetRequiredAction(p_FmHc->h_FmPcd, relativeSchemeId) & requiredAction))
1091 + {
1092 + if ((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA) &&
1093 + (FmPcdKgGetNextEngine(p_FmHc->h_FmPcd, relativeSchemeId) == e_FM_PCD_PLCR))
1094 + {
1095 + if ((FmPcdKgIsDirectPlcr(p_FmHc->h_FmPcd, relativeSchemeId) == FALSE) ||
1096 + (FmPcdKgIsDistrOnPlcrProfile(p_FmHc->h_FmPcd, relativeSchemeId) == TRUE))
1097 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("In this situation PP can not be with distribution and has to be shared"));
1098 + err = FmPcdPlcrCcGetSetParams(p_FmHc->h_FmPcd, FmPcdKgGetRelativeProfileId(p_FmHc->h_FmPcd, relativeSchemeId), requiredAction);
1099 + if (err)
1100 + RETURN_ERROR(MAJOR, err, NO_MSG);
1101 + }
1102 + else /* From here we deal with KG-Schemes only */
1103 + {
1104 + /* Pre change general code */
1105 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1106 + if (!p_HcFrame)
1107 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1108 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1109 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
1110 + p_HcFrame->actionReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
1111 + p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
1112 + p_HcFrame->commandSequence = seqNum;
1113 + BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
1114 + if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
1115 + {
1116 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1117 + RETURN_ERROR(MINOR, err, NO_MSG);
1118 + }
1119 +
1120 + /* specific change */
1121 + if ((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA) &&
1122 + ((FmPcdKgGetNextEngine(p_FmHc->h_FmPcd, relativeSchemeId) == e_FM_PCD_DONE) &&
1123 + (FmPcdKgGetDoneAction(p_FmHc->h_FmPcd, relativeSchemeId) == e_FM_PCD_ENQ_FRAME)))
1124 + {
1125 + tmpReg32 = p_HcFrame->hcSpecificData.schemeRegs.kgse_mode;
1126 + ASSERT_COND(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME));
1127 + p_HcFrame->hcSpecificData.schemeRegs.kgse_mode = tmpReg32 | NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
1128 + }
1129 +
1130 + if ((requiredAction & UPDATE_KG_NIA_CC_WA) &&
1131 + (FmPcdKgGetNextEngine(p_FmHc->h_FmPcd, relativeSchemeId) == e_FM_PCD_CC))
1132 + {
1133 + tmpReg32 = p_HcFrame->hcSpecificData.schemeRegs.kgse_mode;
1134 + ASSERT_COND(tmpReg32 & (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_CC));
1135 + tmpReg32 &= ~NIA_FM_CTL_AC_CC;
1136 + p_HcFrame->hcSpecificData.schemeRegs.kgse_mode = tmpReg32 | NIA_FM_CTL_AC_PRE_CC;
1137 + }
1138 +
1139 + if (requiredAction & UPDATE_KG_OPT_MODE)
1140 + p_HcFrame->hcSpecificData.schemeRegs.kgse_om = value;
1141 +
1142 + if (requiredAction & UPDATE_KG_NIA)
1143 + {
1144 + tmpReg32 = p_HcFrame->hcSpecificData.schemeRegs.kgse_mode;
1145 + tmpReg32 &= ~(NIA_ENG_MASK | NIA_AC_MASK);
1146 + tmpReg32 |= value;
1147 + p_HcFrame->hcSpecificData.schemeRegs.kgse_mode = tmpReg32;
1148 + }
1149 +
1150 + /* Post change general code */
1151 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
1152 + p_HcFrame->actionReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, FALSE);
1153 + p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
1154 +
1155 + BUILD_FD(sizeof(t_HcFrame));
1156 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1157 +
1158 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1159 +
1160 + if (err != E_OK)
1161 + RETURN_ERROR(MINOR, err, NO_MSG);
1162 + }
1163 + }
1164 +
1165 + return E_OK;
1166 +}
1167 +
1168 +uint32_t FmHcPcdKgGetSchemeCounter(t_Handle h_FmHc, t_Handle h_Scheme)
1169 +{
1170 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1171 + t_Error err;
1172 + t_HcFrame *p_HcFrame;
1173 + t_DpaaFD fmFd;
1174 + uint32_t retVal;
1175 + uint8_t relativeSchemeId;
1176 + uint8_t physicalSchemeId = FmPcdKgGetSchemeId(h_Scheme);
1177 + uint32_t seqNum;
1178 +
1179 + relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmHc->h_FmPcd, physicalSchemeId);
1180 + if ( relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
1181 + {
1182 + REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
1183 + return 0;
1184 + }
1185 +
1186 + /* first read scheme and check that it is valid */
1187 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1188 + if (!p_HcFrame)
1189 + {
1190 + REPORT_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1191 + return 0;
1192 + }
1193 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1194 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
1195 + p_HcFrame->actionReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
1196 + p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
1197 + p_HcFrame->commandSequence = seqNum;
1198 +
1199 + BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
1200 +
1201 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1202 + if (err != E_OK)
1203 + {
1204 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1205 + REPORT_ERROR(MINOR, err, NO_MSG);
1206 + return 0;
1207 + }
1208 +
1209 + if (!FmPcdKgHwSchemeIsValid(p_HcFrame->hcSpecificData.schemeRegs.kgse_mode))
1210 + {
1211 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1212 + REPORT_ERROR(MAJOR, E_ALREADY_EXISTS, ("Scheme is invalid"));
1213 + return 0;
1214 + }
1215 +
1216 + retVal = p_HcFrame->hcSpecificData.schemeRegs.kgse_spc;
1217 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1218 +
1219 + return retVal;
1220 +}
1221 +
1222 +t_Error FmHcPcdKgSetSchemeCounter(t_Handle h_FmHc, t_Handle h_Scheme, uint32_t value)
1223 +{
1224 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1225 + t_Error err = E_OK;
1226 + t_HcFrame *p_HcFrame;
1227 + t_DpaaFD fmFd;
1228 + uint8_t relativeSchemeId, physicalSchemeId;
1229 + uint32_t seqNum;
1230 +
1231 + physicalSchemeId = FmPcdKgGetSchemeId(h_Scheme);
1232 + relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmHc->h_FmPcd, physicalSchemeId);
1233 + if ( relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
1234 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
1235 +
1236 + /* first read scheme and check that it is valid */
1237 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1238 + if (!p_HcFrame)
1239 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1240 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1241 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
1242 + p_HcFrame->actionReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, TRUE);
1243 + p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_COUNTER;
1244 + /* write counter */
1245 + p_HcFrame->hcSpecificData.singleRegForWrite = value;
1246 + p_HcFrame->commandSequence = seqNum;
1247 +
1248 + BUILD_FD(sizeof(t_HcFrame));
1249 +
1250 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1251 +
1252 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1253 + return err;
1254 +}
1255 +
1256 +t_Error FmHcPcdKgSetClsPlan(t_Handle h_FmHc, t_FmPcdKgInterModuleClsPlanSet *p_Set)
1257 +{
1258 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1259 + t_HcFrame *p_HcFrame;
1260 + t_DpaaFD fmFd;
1261 + uint8_t i, idx;
1262 + uint32_t seqNum;
1263 + t_Error err = E_OK;
1264 +
1265 + ASSERT_COND(p_FmHc);
1266 +
1267 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1268 + if (!p_HcFrame)
1269 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1270 +
1271 + for (i = p_Set->baseEntry; i < (p_Set->baseEntry+p_Set->numOfClsPlanEntries); i+=8)
1272 + {
1273 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1274 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
1275 + p_HcFrame->actionReg = FmPcdKgBuildWriteClsPlanBlockActionReg((uint8_t)(i / CLS_PLAN_NUM_PER_GRP));
1276 + p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
1277 +
1278 + idx = (uint8_t)(i - p_Set->baseEntry);
1279 + ASSERT_COND(idx < FM_PCD_MAX_NUM_OF_CLS_PLANS);
1280 + memcpy(&p_HcFrame->hcSpecificData.clsPlanEntries, &p_Set->vectors[idx], CLS_PLAN_NUM_PER_GRP*sizeof(uint32_t));
1281 + p_HcFrame->commandSequence = seqNum;
1282 +
1283 + BUILD_FD(sizeof(t_HcFrame));
1284 +
1285 + if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
1286 + {
1287 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1288 + RETURN_ERROR(MINOR, err, NO_MSG);
1289 + }
1290 + }
1291 +
1292 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1293 + return err;
1294 +}
1295 +
1296 +t_Error FmHcPcdKgDeleteClsPlan(t_Handle h_FmHc, uint8_t grpId)
1297 +{
1298 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1299 + t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet;
1300 +
1301 + p_ClsPlanSet = (t_FmPcdKgInterModuleClsPlanSet *)XX_Malloc(sizeof(t_FmPcdKgInterModuleClsPlanSet));
1302 + if (!p_ClsPlanSet)
1303 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Classification plan set"));
1304 +
1305 + memset(p_ClsPlanSet, 0, sizeof(t_FmPcdKgInterModuleClsPlanSet));
1306 +
1307 + p_ClsPlanSet->baseEntry = FmPcdKgGetClsPlanGrpBase(p_FmHc->h_FmPcd, grpId);
1308 + p_ClsPlanSet->numOfClsPlanEntries = FmPcdKgGetClsPlanGrpSize(p_FmHc->h_FmPcd, grpId);
1309 + ASSERT_COND(p_ClsPlanSet->numOfClsPlanEntries <= FM_PCD_MAX_NUM_OF_CLS_PLANS);
1310 +
1311 + if (FmHcPcdKgSetClsPlan(p_FmHc, p_ClsPlanSet) != E_OK)
1312 + {
1313 + XX_Free(p_ClsPlanSet);
1314 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
1315 + }
1316 +
1317 + XX_Free(p_ClsPlanSet);
1318 + FmPcdKgDestroyClsPlanGrp(p_FmHc->h_FmPcd, grpId);
1319 +
1320 + return E_OK;
1321 +}
1322 +
1323 +t_Error FmHcPcdCcCapwapTimeoutReassm(t_Handle h_FmHc, t_FmPcdCcCapwapReassmTimeoutParams *p_CcCapwapReassmTimeoutParams )
1324 +{
1325 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1326 + t_HcFrame *p_HcFrame;
1327 + t_DpaaFD fmFd;
1328 + t_Error err;
1329 + uint32_t seqNum;
1330 +
1331 + SANITY_CHECK_RETURN_VALUE(h_FmHc, E_INVALID_HANDLE,0);
1332 +
1333 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1334 + if (!p_HcFrame)
1335 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1336 +
1337 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1338 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_CC_CAPWAP_REASSM_TIMEOUT);
1339 + memcpy(&p_HcFrame->hcSpecificData.ccCapwapReassmTimeout, p_CcCapwapReassmTimeoutParams, sizeof(t_FmPcdCcCapwapReassmTimeoutParams));
1340 + p_HcFrame->commandSequence = seqNum;
1341 + BUILD_FD(sizeof(t_HcFrame));
1342 +
1343 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1344 +
1345 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1346 + return err;
1347 +}
1348 +
1349 +t_Error FmHcPcdCcIpFragScratchPollCmd(t_Handle h_FmHc, bool fill, t_FmPcdCcFragScratchPoolCmdParams *p_FmPcdCcFragScratchPoolCmdParams)
1350 +{
1351 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1352 + t_HcFrame *p_HcFrame;
1353 + t_DpaaFD fmFd;
1354 + t_Error err;
1355 + uint32_t seqNum;
1356 +
1357 + SANITY_CHECK_RETURN_VALUE(h_FmHc, E_INVALID_HANDLE,0);
1358 +
1359 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1360 + if (!p_HcFrame)
1361 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1362 +
1363 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1364 +
1365 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_CC_IP_FRAG_INITIALIZATION);
1366 + p_HcFrame->actionReg = (uint32_t)(((fill == TRUE) ? 0 : 1) << HC_HCOR_ACTION_REG_IP_FRAG_SCRATCH_POOL_CMD_SHIFT);
1367 + p_HcFrame->actionReg |= p_FmPcdCcFragScratchPoolCmdParams->bufferPoolId << HC_HCOR_ACTION_REG_IP_FRAG_SCRATCH_POOL_BPID;
1368 + if (fill == TRUE)
1369 + {
1370 + p_HcFrame->extraReg = p_FmPcdCcFragScratchPoolCmdParams->numOfBuffers;
1371 + }
1372 + p_HcFrame->commandSequence = seqNum;
1373 +
1374 + BUILD_FD(sizeof(t_HcFrame));
1375 + if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
1376 + {
1377 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1378 + RETURN_ERROR(MINOR, err, NO_MSG);
1379 + }
1380 +
1381 + p_FmPcdCcFragScratchPoolCmdParams->numOfBuffers = p_HcFrame->extraReg;
1382 +
1383 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1384 + return E_OK;
1385 +}
1386 +
1387 +t_Error FmHcPcdCcTimeoutReassm(t_Handle h_FmHc, t_FmPcdCcReassmTimeoutParams *p_CcReassmTimeoutParams, uint8_t *p_Result)
1388 +{
1389 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1390 + t_HcFrame *p_HcFrame;
1391 + t_DpaaFD fmFd;
1392 + t_Error err;
1393 + uint32_t seqNum;
1394 +
1395 + SANITY_CHECK_RETURN_VALUE(h_FmHc, E_INVALID_HANDLE,0);
1396 +
1397 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1398 + if (!p_HcFrame)
1399 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1400 +
1401 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1402 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_CC_REASSM_TIMEOUT);
1403 + p_HcFrame->actionReg = (uint32_t)((p_CcReassmTimeoutParams->activate ? 0 : 1) << HC_HCOR_ACTION_REG_REASSM_TIMEOUT_ACTIVE_SHIFT);
1404 + p_HcFrame->extraReg = (p_CcReassmTimeoutParams->tsbs << HC_HCOR_EXTRA_REG_REASSM_TIMEOUT_TSBS_SHIFT) | p_CcReassmTimeoutParams->iprcpt;
1405 + p_HcFrame->commandSequence = seqNum;
1406 +
1407 + BUILD_FD(sizeof(t_HcFrame));
1408 + if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
1409 + {
1410 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1411 + RETURN_ERROR(MINOR, err, NO_MSG);
1412 + }
1413 +
1414 + *p_Result = (uint8_t)
1415 + ((p_HcFrame->actionReg >> HC_HCOR_ACTION_REG_REASSM_TIMEOUT_RES_SHIFT) & HC_HCOR_ACTION_REG_REASSM_TIMEOUT_RES_MASK);
1416 +
1417 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1418 + return E_OK;
1419 +}
1420 +
1421 +t_Error FmHcPcdPlcrCcGetSetParams(t_Handle h_FmHc,uint16_t absoluteProfileId, uint32_t requiredAction)
1422 +{
1423 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1424 + t_HcFrame *p_HcFrame;
1425 + t_DpaaFD fmFd;
1426 + t_Error err;
1427 + uint32_t tmpReg32 = 0;
1428 + uint32_t requiredActionTmp, requiredActionFlag;
1429 + uint32_t seqNum;
1430 +
1431 + SANITY_CHECK_RETURN_VALUE(h_FmHc, E_INVALID_HANDLE,0);
1432 +
1433 + /* Profile is locked by calling routine */
1434 + /* WARNING - this lock will not be efficient if other HC routine will attempt to change
1435 + * "fmpl_pegnia" "fmpl_peynia" or "fmpl_pernia" without locking Profile !
1436 + */
1437 +
1438 + requiredActionTmp = FmPcdPlcrGetRequiredAction(p_FmHc->h_FmPcd, absoluteProfileId);
1439 + requiredActionFlag = FmPcdPlcrGetRequiredActionFlag(p_FmHc->h_FmPcd, absoluteProfileId);
1440 +
1441 + if (!requiredActionFlag || !(requiredActionTmp & requiredAction))
1442 + {
1443 + if (requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
1444 + {
1445 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1446 + if (!p_HcFrame)
1447 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1448 + /* first read scheme and check that it is valid */
1449 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1450 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
1451 + p_HcFrame->actionReg = FmPcdPlcrBuildReadPlcrActionReg(absoluteProfileId);
1452 + p_HcFrame->extraReg = 0x00008000;
1453 + p_HcFrame->commandSequence = seqNum;
1454 +
1455 + BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
1456 +
1457 + if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
1458 + {
1459 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1460 + RETURN_ERROR(MINOR, err, NO_MSG);
1461 + }
1462 +
1463 + tmpReg32 = p_HcFrame->hcSpecificData.profileRegs.fmpl_pegnia;
1464 + if (!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
1465 + {
1466 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1467 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
1468 + ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
1469 + }
1470 +
1471 + tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
1472 +
1473 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
1474 + p_HcFrame->actionReg = FmPcdPlcrBuildWritePlcrActionReg(absoluteProfileId);
1475 + p_HcFrame->actionReg |= FmPcdPlcrBuildNiaProfileReg(TRUE, FALSE, FALSE);
1476 + p_HcFrame->extraReg = 0x00008000;
1477 + p_HcFrame->hcSpecificData.singleRegForWrite = tmpReg32;
1478 +
1479 + BUILD_FD(SIZE_OF_HC_FRAME_PROFILE_CNT);
1480 +
1481 + if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
1482 + {
1483 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1484 + RETURN_ERROR(MINOR, err, NO_MSG);
1485 + }
1486 +
1487 + tmpReg32 = p_HcFrame->hcSpecificData.profileRegs.fmpl_peynia;
1488 + if (!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
1489 + {
1490 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1491 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
1492 + }
1493 +
1494 + tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
1495 +
1496 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
1497 + p_HcFrame->actionReg = FmPcdPlcrBuildWritePlcrActionReg(absoluteProfileId);
1498 + p_HcFrame->actionReg |= FmPcdPlcrBuildNiaProfileReg(FALSE, TRUE, FALSE);
1499 + p_HcFrame->extraReg = 0x00008000;
1500 + p_HcFrame->hcSpecificData.singleRegForWrite = tmpReg32;
1501 +
1502 + BUILD_FD(SIZE_OF_HC_FRAME_PROFILE_CNT);
1503 +
1504 + if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
1505 + {
1506 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1507 + RETURN_ERROR(MINOR, err, NO_MSG);
1508 + }
1509 +
1510 + tmpReg32 = p_HcFrame->hcSpecificData.profileRegs.fmpl_pernia;
1511 + if (!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
1512 + {
1513 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1514 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
1515 + }
1516 +
1517 + tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
1518 +
1519 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
1520 + p_HcFrame->actionReg = FmPcdPlcrBuildWritePlcrActionReg(absoluteProfileId);
1521 + p_HcFrame->actionReg |= FmPcdPlcrBuildNiaProfileReg(FALSE, FALSE, TRUE);
1522 + p_HcFrame->extraReg = 0x00008000;
1523 + p_HcFrame->hcSpecificData.singleRegForWrite = tmpReg32;
1524 +
1525 + BUILD_FD(SIZE_OF_HC_FRAME_PROFILE_CNT);
1526 +
1527 + if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
1528 + {
1529 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1530 + RETURN_ERROR(MINOR, err, NO_MSG);
1531 + }
1532 +
1533 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1534 + }
1535 + }
1536 +
1537 + return E_OK;
1538 +}
1539 +
1540 +t_Error FmHcPcdPlcrSetProfile(t_Handle h_FmHc, t_Handle h_Profile, t_FmPcdPlcrProfileRegs *p_PlcrRegs)
1541 +{
1542 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1543 + t_Error err = E_OK;
1544 + uint16_t profileIndx;
1545 + t_HcFrame *p_HcFrame;
1546 + t_DpaaFD fmFd;
1547 + uint32_t seqNum;
1548 +
1549 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1550 + if (!p_HcFrame)
1551 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1552 +
1553 + profileIndx = FmPcdPlcrProfileGetAbsoluteId(h_Profile);
1554 +
1555 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1556 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
1557 + p_HcFrame->actionReg = FmPcdPlcrBuildWritePlcrActionRegs(profileIndx);
1558 + p_HcFrame->extraReg = 0x00008000;
1559 + memcpy(&p_HcFrame->hcSpecificData.profileRegs, p_PlcrRegs, sizeof(t_FmPcdPlcrProfileRegs));
1560 + p_HcFrame->commandSequence = seqNum;
1561 +
1562 + BUILD_FD(sizeof(t_HcFrame));
1563 +
1564 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1565 +
1566 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1567 +
1568 + if (err != E_OK)
1569 + RETURN_ERROR(MINOR, err, NO_MSG);
1570 +
1571 + return E_OK;
1572 +}
1573 +
1574 +t_Error FmHcPcdPlcrDeleteProfile(t_Handle h_FmHc, t_Handle h_Profile)
1575 +{
1576 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1577 + uint16_t absoluteProfileId = FmPcdPlcrProfileGetAbsoluteId(h_Profile);
1578 + t_Error err = E_OK;
1579 + t_HcFrame *p_HcFrame;
1580 + t_DpaaFD fmFd;
1581 + uint32_t seqNum;
1582 +
1583 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1584 + if (!p_HcFrame)
1585 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1586 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1587 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
1588 + p_HcFrame->actionReg = FmPcdPlcrBuildWritePlcrActionReg(absoluteProfileId);
1589 + p_HcFrame->actionReg |= 0x00008000;
1590 + p_HcFrame->extraReg = 0x00008000;
1591 + memset(&p_HcFrame->hcSpecificData.profileRegs, 0, sizeof(t_FmPcdPlcrProfileRegs));
1592 + p_HcFrame->commandSequence = seqNum;
1593 +
1594 + BUILD_FD(sizeof(t_HcFrame));
1595 +
1596 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1597 +
1598 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1599 +
1600 + if (err != E_OK)
1601 + RETURN_ERROR(MINOR, err, NO_MSG);
1602 +
1603 + return E_OK;
1604 +}
1605 +
1606 +t_Error FmHcPcdPlcrSetProfileCounter(t_Handle h_FmHc, t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter, uint32_t value)
1607 +{
1608 +
1609 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1610 + uint16_t absoluteProfileId = FmPcdPlcrProfileGetAbsoluteId(h_Profile);
1611 + t_Error err = E_OK;
1612 + t_HcFrame *p_HcFrame;
1613 + t_DpaaFD fmFd;
1614 + uint32_t seqNum;
1615 +
1616 + /* first read scheme and check that it is valid */
1617 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1618 + if (!p_HcFrame)
1619 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1620 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1621 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
1622 + p_HcFrame->actionReg = FmPcdPlcrBuildWritePlcrActionReg(absoluteProfileId);
1623 + p_HcFrame->actionReg |= FmPcdPlcrBuildCounterProfileReg(counter);
1624 + p_HcFrame->extraReg = 0x00008000;
1625 + p_HcFrame->hcSpecificData.singleRegForWrite = value;
1626 + p_HcFrame->commandSequence = seqNum;
1627 +
1628 + BUILD_FD(SIZE_OF_HC_FRAME_PROFILE_CNT);
1629 +
1630 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1631 +
1632 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1633 +
1634 + if (err != E_OK)
1635 + RETURN_ERROR(MINOR, err, NO_MSG);
1636 +
1637 + return E_OK;
1638 +}
1639 +
1640 +uint32_t FmHcPcdPlcrGetProfileCounter(t_Handle h_FmHc, t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter)
1641 +{
1642 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1643 + uint16_t absoluteProfileId = FmPcdPlcrProfileGetAbsoluteId(h_Profile);
1644 + t_Error err;
1645 + t_HcFrame *p_HcFrame;
1646 + t_DpaaFD fmFd;
1647 + uint32_t retVal = 0;
1648 + uint32_t seqNum;
1649 +
1650 + SANITY_CHECK_RETURN_VALUE(h_FmHc, E_INVALID_HANDLE,0);
1651 +
1652 + /* first read scheme and check that it is valid */
1653 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1654 + if (!p_HcFrame)
1655 + {
1656 + REPORT_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1657 + return 0;
1658 + }
1659 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1660 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
1661 + p_HcFrame->actionReg = FmPcdPlcrBuildReadPlcrActionReg(absoluteProfileId);
1662 + p_HcFrame->extraReg = 0x00008000;
1663 + p_HcFrame->commandSequence = seqNum;
1664 +
1665 + BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
1666 +
1667 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1668 + if (err != E_OK)
1669 + {
1670 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1671 + REPORT_ERROR(MINOR, err, NO_MSG);
1672 + return 0;
1673 + }
1674 +
1675 + switch (counter)
1676 + {
1677 + case e_FM_PCD_PLCR_PROFILE_GREEN_PACKET_TOTAL_COUNTER:
1678 + retVal = p_HcFrame->hcSpecificData.profileRegs.fmpl_pegpc;
1679 + break;
1680 + case e_FM_PCD_PLCR_PROFILE_YELLOW_PACKET_TOTAL_COUNTER:
1681 + retVal = p_HcFrame->hcSpecificData.profileRegs.fmpl_peypc;
1682 + break;
1683 + case e_FM_PCD_PLCR_PROFILE_RED_PACKET_TOTAL_COUNTER:
1684 + retVal = p_HcFrame->hcSpecificData.profileRegs.fmpl_perpc;
1685 + break;
1686 + case e_FM_PCD_PLCR_PROFILE_RECOLOURED_YELLOW_PACKET_TOTAL_COUNTER:
1687 + retVal = p_HcFrame->hcSpecificData.profileRegs.fmpl_perypc;
1688 + break;
1689 + case e_FM_PCD_PLCR_PROFILE_RECOLOURED_RED_PACKET_TOTAL_COUNTER:
1690 + retVal = p_HcFrame->hcSpecificData.profileRegs.fmpl_perrpc;
1691 + break;
1692 + default:
1693 + REPORT_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
1694 + }
1695 +
1696 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1697 + return retVal;
1698 +}
1699 +
1700 +t_Error FmHcKgWriteSp(t_Handle h_FmHc, uint8_t hardwarePortId, uint32_t spReg, bool add)
1701 +{
1702 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1703 + t_HcFrame *p_HcFrame;
1704 + t_DpaaFD fmFd;
1705 + t_Error err = E_OK;
1706 + uint32_t seqNum;
1707 +
1708 + ASSERT_COND(p_FmHc);
1709 +
1710 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1711 + if (!p_HcFrame)
1712 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1713 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1714 + /* first read SP register */
1715 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
1716 + p_HcFrame->actionReg = FmPcdKgBuildReadPortSchemeBindActionReg(hardwarePortId);
1717 + p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
1718 + p_HcFrame->commandSequence = seqNum;
1719 +
1720 + BUILD_FD(SIZE_OF_HC_FRAME_PORT_REGS);
1721 +
1722 + if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
1723 + {
1724 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1725 + RETURN_ERROR(MINOR, err, NO_MSG);
1726 + }
1727 +
1728 + /* spReg is the first reg, so we can use it both for read and for write */
1729 + if (add)
1730 + p_HcFrame->hcSpecificData.portRegsForRead.spReg |= spReg;
1731 + else
1732 + p_HcFrame->hcSpecificData.portRegsForRead.spReg &= ~spReg;
1733 +
1734 + p_HcFrame->actionReg = FmPcdKgBuildWritePortSchemeBindActionReg(hardwarePortId);
1735 +
1736 + BUILD_FD(sizeof(t_HcFrame));
1737 +
1738 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1739 +
1740 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1741 +
1742 + if (err != E_OK)
1743 + RETURN_ERROR(MINOR, err, NO_MSG);
1744 +
1745 + return E_OK;
1746 +}
1747 +
1748 +t_Error FmHcKgWriteCpp(t_Handle h_FmHc, uint8_t hardwarePortId, uint32_t cppReg)
1749 +{
1750 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1751 + t_HcFrame *p_HcFrame;
1752 + t_DpaaFD fmFd;
1753 + t_Error err = E_OK;
1754 + uint32_t seqNum;
1755 +
1756 + ASSERT_COND(p_FmHc);
1757 +
1758 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1759 + if (!p_HcFrame)
1760 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1761 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1762 + /* first read SP register */
1763 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
1764 + p_HcFrame->actionReg = FmPcdKgBuildWritePortClsPlanBindActionReg(hardwarePortId);
1765 + p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
1766 + p_HcFrame->hcSpecificData.singleRegForWrite = cppReg;
1767 + p_HcFrame->commandSequence = seqNum;
1768 +
1769 + BUILD_FD(sizeof(t_HcFrame));
1770 +
1771 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1772 +
1773 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1774 +
1775 + if (err != E_OK)
1776 + RETURN_ERROR(MINOR, err, NO_MSG);
1777 +
1778 + return E_OK;
1779 +}
1780 +
1781 +t_Error FmHcPcdCcDoDynamicChange(t_Handle h_FmHc, uint32_t oldAdAddrOffset, uint32_t newAdAddrOffset)
1782 +{
1783 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1784 + t_HcFrame *p_HcFrame;
1785 + t_DpaaFD fmFd;
1786 + t_Error err = E_OK;
1787 + uint32_t seqNum;
1788 +
1789 + SANITY_CHECK_RETURN_ERROR(p_FmHc, E_INVALID_HANDLE);
1790 +
1791 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1792 + if (!p_HcFrame)
1793 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1794 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1795 +
1796 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_CC);
1797 + p_HcFrame->actionReg = newAdAddrOffset;
1798 + p_HcFrame->actionReg |= 0xc0000000;
1799 + p_HcFrame->extraReg = oldAdAddrOffset;
1800 + p_HcFrame->commandSequence = seqNum;
1801 +
1802 + BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
1803 +
1804 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1805 +
1806 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1807 +
1808 + if (err != E_OK)
1809 + RETURN_ERROR(MAJOR, err, NO_MSG);
1810 +
1811 + return E_OK;
1812 +}
1813 +
1814 +t_Error FmHcPcdSync(t_Handle h_FmHc)
1815 +{
1816 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1817 + t_HcFrame *p_HcFrame;
1818 + t_DpaaFD fmFd;
1819 + t_Error err = E_OK;
1820 + uint32_t seqNum;
1821 +
1822 + ASSERT_COND(p_FmHc);
1823 +
1824 + p_HcFrame = GetBuf(p_FmHc, &seqNum);
1825 + if (!p_HcFrame)
1826 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
1827 + memset(p_HcFrame, 0, sizeof(t_HcFrame));
1828 + /* first read SP register */
1829 + p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_SYNC);
1830 + p_HcFrame->actionReg = 0;
1831 + p_HcFrame->extraReg = 0;
1832 + p_HcFrame->commandSequence = seqNum;
1833 +
1834 + BUILD_FD(sizeof(t_HcFrame));
1835 +
1836 + err = EnQFrm(p_FmHc, &fmFd, seqNum);
1837 +
1838 + PutBuf(p_FmHc, p_HcFrame, seqNum);
1839 +
1840 + if (err != E_OK)
1841 + RETURN_ERROR(MINOR, err, NO_MSG);
1842 +
1843 + return E_OK;
1844 +}
1845 +
1846 +t_Handle FmHcGetPort(t_Handle h_FmHc)
1847 +{
1848 + t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
1849 + return p_FmHc->h_HcPortDev;
1850 +}
1851 --- /dev/null
1852 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/Makefile
1853 @@ -0,0 +1,28 @@
1854 +#
1855 +# Makefile for the Freescale Ethernet controllers
1856 +#
1857 +ccflags-y += -DVERSION=\"\"
1858 +#
1859 +#Include netcomm SW specific definitions
1860 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
1861 +
1862 +NCSW_FM_INC = $(srctree)/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc
1863 +
1864 +ccflags-y += -I$(NCSW_FM_INC)
1865 +
1866 +obj-y += fsl-ncsw-MAC.o
1867 +
1868 +fsl-ncsw-MAC-objs := dtsec.o dtsec_mii_acc.o fm_mac.o tgec.o tgec_mii_acc.o \
1869 + fman_dtsec.o fman_dtsec_mii_acc.o fman_memac.o \
1870 + fman_tgec.o fman_crc32.o
1871 +
1872 +ifeq ($(CONFIG_FMAN_V3H),y)
1873 +fsl-ncsw-MAC-objs += memac.o memac_mii_acc.o fman_memac_mii_acc.o
1874 +endif
1875 +ifeq ($(CONFIG_FMAN_V3L),y)
1876 +fsl-ncsw-MAC-objs += memac.o memac_mii_acc.o fman_memac_mii_acc.o
1877 +endif
1878 +ifeq ($(CONFIG_FMAN_ARM),y)
1879 +fsl-ncsw-MAC-objs += memac.o memac_mii_acc.o fman_memac_mii_acc.o
1880 +endif
1881 +
1882 --- /dev/null
1883 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c
1884 @@ -0,0 +1,1463 @@
1885 +/*
1886 + * Copyright 2008-2013 Freescale Semiconductor Inc.
1887 + *
1888 + * Redistribution and use in source and binary forms, with or without
1889 + * modification, are permitted provided that the following conditions are met:
1890 + * * Redistributions of source code must retain the above copyright
1891 + * notice, this list of conditions and the following disclaimer.
1892 + * * Redistributions in binary form must reproduce the above copyright
1893 + * notice, this list of conditions and the following disclaimer in the
1894 + * documentation and/or other materials provided with the distribution.
1895 + * * Neither the name of Freescale Semiconductor nor the
1896 + * names of its contributors may be used to endorse or promote products
1897 + * derived from this software without specific prior written permission.
1898 + *
1899 + *
1900 + * ALTERNATIVELY, this software may be distributed under the terms of the
1901 + * GNU General Public License ("GPL") as published by the Free Software
1902 + * Foundation, either version 2 of that License or (at your option) any
1903 + * later version.
1904 + *
1905 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
1906 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1907 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1908 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
1909 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1910 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1911 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1912 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1913 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1914 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1915 + */
1916 +
1917 +/******************************************************************************
1918 + @File dtsec.c
1919 +
1920 + @Description FMan dTSEC driver
1921 +*//***************************************************************************/
1922 +
1923 +#include "std_ext.h"
1924 +#include "error_ext.h"
1925 +#include "string_ext.h"
1926 +#include "xx_ext.h"
1927 +#include "endian_ext.h"
1928 +#include "debug_ext.h"
1929 +#include "crc_mac_addr_ext.h"
1930 +
1931 +#include "fm_common.h"
1932 +#include "dtsec.h"
1933 +#include "fsl_fman_dtsec.h"
1934 +#include "fsl_fman_dtsec_mii_acc.h"
1935 +
1936 +/*****************************************************************************/
1937 +/* Internal routines */
1938 +/*****************************************************************************/
1939 +
1940 +static t_Error CheckInitParameters(t_Dtsec *p_Dtsec)
1941 +{
1942 + if (ENET_SPEED_FROM_MODE(p_Dtsec->enetMode) >= e_ENET_SPEED_10000)
1943 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Ethernet 1G MAC driver only supports 1G or lower speeds"));
1944 + if (p_Dtsec->macId >= FM_MAX_NUM_OF_1G_MACS)
1945 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("macId can not be greater than the number of 1G MACs"));
1946 + if (p_Dtsec->addr == 0)
1947 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Ethernet MAC Must have a valid MAC Address"));
1948 + if ((ENET_SPEED_FROM_MODE(p_Dtsec->enetMode) >= e_ENET_SPEED_1000) &&
1949 + p_Dtsec->p_DtsecDriverParam->halfdup_on)
1950 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Ethernet MAC 1G can't work in half duplex"));
1951 + if (p_Dtsec->p_DtsecDriverParam->halfdup_on && (p_Dtsec->p_DtsecDriverParam)->loopback)
1952 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("LoopBack is not supported in halfDuplex mode"));
1953 +#ifdef FM_RX_PREAM_4_ERRATA_DTSEC_A001
1954 + if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev <= 6) /* fixed for rev3 */
1955 + if (p_Dtsec->p_DtsecDriverParam->rx_preamble)
1956 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("preambleRxEn"));
1957 +#endif /* FM_RX_PREAM_4_ERRATA_DTSEC_A001 */
1958 + if (((p_Dtsec->p_DtsecDriverParam)->tx_preamble || (p_Dtsec->p_DtsecDriverParam)->rx_preamble) &&( (p_Dtsec->p_DtsecDriverParam)->preamble_len != 0x7))
1959 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Preamble length should be 0x7 bytes"));
1960 + if ((p_Dtsec->p_DtsecDriverParam)->halfdup_on &&
1961 + (p_Dtsec->p_DtsecDriverParam->tx_time_stamp_en || p_Dtsec->p_DtsecDriverParam->rx_time_stamp_en))
1962 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dTSEC in half duplex mode has to be with 1588 timeStamping diable"));
1963 + if ((p_Dtsec->p_DtsecDriverParam)->rx_flow && (p_Dtsec->p_DtsecDriverParam)->rx_ctrl_acc )
1964 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Receive control frame are not passed to the system memory so it can not be accept "));
1965 + if ((p_Dtsec->p_DtsecDriverParam)->rx_prepend > MAX_PACKET_ALIGNMENT)
1966 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("packetAlignmentPadding can't be greater than %d ",MAX_PACKET_ALIGNMENT ));
1967 + if (((p_Dtsec->p_DtsecDriverParam)->non_back_to_back_ipg1 > MAX_INTER_PACKET_GAP) ||
1968 + ((p_Dtsec->p_DtsecDriverParam)->non_back_to_back_ipg2 > MAX_INTER_PACKET_GAP) ||
1969 + ((p_Dtsec->p_DtsecDriverParam)->back_to_back_ipg > MAX_INTER_PACKET_GAP))
1970 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inter packet gap can't be greater than %d ",MAX_INTER_PACKET_GAP ));
1971 + if ((p_Dtsec->p_DtsecDriverParam)->halfdup_alt_backoff_val > MAX_INTER_PALTERNATE_BEB)
1972 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("alternateBackoffVal can't be greater than %d ",MAX_INTER_PALTERNATE_BEB ));
1973 + if ((p_Dtsec->p_DtsecDriverParam)->halfdup_retransmit > MAX_RETRANSMISSION)
1974 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("maxRetransmission can't be greater than %d ",MAX_RETRANSMISSION ));
1975 + if ((p_Dtsec->p_DtsecDriverParam)->halfdup_coll_window > MAX_COLLISION_WINDOW)
1976 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("collisionWindow can't be greater than %d ",MAX_COLLISION_WINDOW ));
1977 +
1978 + /* If Auto negotiation process is disabled, need to */
1979 + /* Set up the PHY using the MII Management Interface */
1980 + if (p_Dtsec->p_DtsecDriverParam->tbipa > MAX_PHYS)
1981 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, ("PHY address (should be 0-%d)", MAX_PHYS));
1982 + if (!p_Dtsec->f_Exception)
1983 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("uninitialized f_Exception"));
1984 + if (!p_Dtsec->f_Event)
1985 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("uninitialized f_Event"));
1986 +
1987 +#ifdef FM_LEN_CHECK_ERRATA_FMAN_SW002
1988 + if (p_Dtsec->p_DtsecDriverParam->rx_len_check)
1989 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("LengthCheck!"));
1990 +#endif /* FM_LEN_CHECK_ERRATA_FMAN_SW002 */
1991 +
1992 + return E_OK;
1993 +}
1994 +
1995 +/* ......................................................................... */
1996 +
1997 +static uint32_t GetMacAddrHashCode(uint64_t ethAddr)
1998 +{
1999 + uint32_t crc;
2000 +
2001 + /* CRC calculation */
2002 + GET_MAC_ADDR_CRC(ethAddr, crc);
2003 +
2004 + crc = GetMirror32(crc);
2005 +
2006 + return crc;
2007 +}
2008 +
2009 +/* ......................................................................... */
2010 +
2011 +static void UpdateStatistics(t_Dtsec *p_Dtsec)
2012 +{
2013 + uint32_t car1, car2;
2014 +
2015 + fman_dtsec_get_clear_carry_regs(p_Dtsec->p_MemMap, &car1, &car2);
2016 +
2017 + if (car1)
2018 + {
2019 + if (car1 & CAR1_TR64)
2020 + p_Dtsec->internalStatistics.tr64 += VAL22BIT;
2021 + if (car1 & CAR1_TR127)
2022 + p_Dtsec->internalStatistics.tr127 += VAL22BIT;
2023 + if (car1 & CAR1_TR255)
2024 + p_Dtsec->internalStatistics.tr255 += VAL22BIT;
2025 + if (car1 & CAR1_TR511)
2026 + p_Dtsec->internalStatistics.tr511 += VAL22BIT;
2027 + if (car1 & CAR1_TRK1)
2028 + p_Dtsec->internalStatistics.tr1k += VAL22BIT;
2029 + if (car1 & CAR1_TRMAX)
2030 + p_Dtsec->internalStatistics.trmax += VAL22BIT;
2031 + if (car1 & CAR1_TRMGV)
2032 + p_Dtsec->internalStatistics.trmgv += VAL22BIT;
2033 + if (car1 & CAR1_RBYT)
2034 + p_Dtsec->internalStatistics.rbyt += (uint64_t)VAL32BIT;
2035 + if (car1 & CAR1_RPKT)
2036 + p_Dtsec->internalStatistics.rpkt += VAL22BIT;
2037 + if (car1 & CAR1_RMCA)
2038 + p_Dtsec->internalStatistics.rmca += VAL22BIT;
2039 + if (car1 & CAR1_RBCA)
2040 + p_Dtsec->internalStatistics.rbca += VAL22BIT;
2041 + if (car1 & CAR1_RXPF)
2042 + p_Dtsec->internalStatistics.rxpf += VAL16BIT;
2043 + if (car1 & CAR1_RALN)
2044 + p_Dtsec->internalStatistics.raln += VAL16BIT;
2045 + if (car1 & CAR1_RFLR)
2046 + p_Dtsec->internalStatistics.rflr += VAL16BIT;
2047 + if (car1 & CAR1_RCDE)
2048 + p_Dtsec->internalStatistics.rcde += VAL16BIT;
2049 + if (car1 & CAR1_RCSE)
2050 + p_Dtsec->internalStatistics.rcse += VAL16BIT;
2051 + if (car1 & CAR1_RUND)
2052 + p_Dtsec->internalStatistics.rund += VAL16BIT;
2053 + if (car1 & CAR1_ROVR)
2054 + p_Dtsec->internalStatistics.rovr += VAL16BIT;
2055 + if (car1 & CAR1_RFRG)
2056 + p_Dtsec->internalStatistics.rfrg += VAL16BIT;
2057 + if (car1 & CAR1_RJBR)
2058 + p_Dtsec->internalStatistics.rjbr += VAL16BIT;
2059 + if (car1 & CAR1_RDRP)
2060 + p_Dtsec->internalStatistics.rdrp += VAL16BIT;
2061 + }
2062 + if (car2)
2063 + {
2064 + if (car2 & CAR2_TFCS)
2065 + p_Dtsec->internalStatistics.tfcs += VAL12BIT;
2066 + if (car2 & CAR2_TBYT)
2067 + p_Dtsec->internalStatistics.tbyt += (uint64_t)VAL32BIT;
2068 + if (car2 & CAR2_TPKT)
2069 + p_Dtsec->internalStatistics.tpkt += VAL22BIT;
2070 + if (car2 & CAR2_TMCA)
2071 + p_Dtsec->internalStatistics.tmca += VAL22BIT;
2072 + if (car2 & CAR2_TBCA)
2073 + p_Dtsec->internalStatistics.tbca += VAL22BIT;
2074 + if (car2 & CAR2_TXPF)
2075 + p_Dtsec->internalStatistics.txpf += VAL16BIT;
2076 + if (car2 & CAR2_TDRP)
2077 + p_Dtsec->internalStatistics.tdrp += VAL16BIT;
2078 + }
2079 +}
2080 +
2081 +/* .............................................................................. */
2082 +
2083 +static uint16_t DtsecGetMaxFrameLength(t_Handle h_Dtsec)
2084 +{
2085 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2086 +
2087 + SANITY_CHECK_RETURN_VALUE(p_Dtsec, E_INVALID_HANDLE, 0);
2088 + SANITY_CHECK_RETURN_VALUE(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE, 0);
2089 +
2090 + return fman_dtsec_get_max_frame_len(p_Dtsec->p_MemMap);
2091 +}
2092 +
2093 +/* .............................................................................. */
2094 +
2095 +static void DtsecIsr(t_Handle h_Dtsec)
2096 +{
2097 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2098 + uint32_t event;
2099 + struct dtsec_regs *p_DtsecMemMap = p_Dtsec->p_MemMap;
2100 +
2101 + /* do not handle MDIO events */
2102 + event = fman_dtsec_get_event(p_DtsecMemMap, (uint32_t)(~(DTSEC_IMASK_MMRDEN | DTSEC_IMASK_MMWREN)));
2103 +
2104 + event &= fman_dtsec_get_interrupt_mask(p_DtsecMemMap);
2105 +
2106 + fman_dtsec_ack_event(p_DtsecMemMap, event);
2107 +
2108 + if (event & DTSEC_IMASK_BREN)
2109 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_BAB_RX);
2110 + if (event & DTSEC_IMASK_RXCEN)
2111 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_RX_CTL);
2112 + if (event & DTSEC_IMASK_MSROEN)
2113 + UpdateStatistics(p_Dtsec);
2114 + if (event & DTSEC_IMASK_GTSCEN)
2115 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET);
2116 + if (event & DTSEC_IMASK_BTEN)
2117 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_BAB_TX);
2118 + if (event & DTSEC_IMASK_TXCEN)
2119 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_TX_CTL);
2120 + if (event & DTSEC_IMASK_TXEEN)
2121 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_TX_ERR);
2122 + if (event & DTSEC_IMASK_LCEN)
2123 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_LATE_COL);
2124 + if (event & DTSEC_IMASK_CRLEN)
2125 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_COL_RET_LMT);
2126 + if (event & DTSEC_IMASK_XFUNEN)
2127 + {
2128 +#ifdef FM_TX_LOCKUP_ERRATA_DTSEC6
2129 + if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
2130 + {
2131 + uint32_t tpkt1, tmpReg1, tpkt2, tmpReg2, i;
2132 + /* a. Write 0x00E0_0C00 to DTSEC_ID */
2133 + /* This is a read only regidter */
2134 +
2135 + /* b. Read and save the value of TPKT */
2136 + tpkt1 = GET_UINT32(p_DtsecMemMap->tpkt);
2137 +
2138 + /* c. Read the register at dTSEC address offset 0x32C */
2139 + tmpReg1 = GET_UINT32(*(uint32_t*)((uint8_t*)p_DtsecMemMap + 0x32c));
2140 +
2141 + /* d. Compare bits [9:15] to bits [25:31] of the register at address offset 0x32C. */
2142 + if ((tmpReg1 & 0x007F0000) != (tmpReg1 & 0x0000007F))
2143 + {
2144 + /* If they are not equal, save the value of this register and wait for at least
2145 + * MAXFRM*16 ns */
2146 + XX_UDelay((uint32_t)(MIN(DtsecGetMaxFrameLength(p_Dtsec)*16/1000, 1)));
2147 + }
2148 +
2149 + /* e. Read and save TPKT again and read the register at dTSEC address offset
2150 + 0x32C again*/
2151 + tpkt2 = GET_UINT32(p_DtsecMemMap->tpkt);
2152 + tmpReg2 = GET_UINT32(*(uint32_t*)((uint8_t*)p_DtsecMemMap + 0x32c));
2153 +
2154 + /* f. Compare the value of TPKT saved in step b to value read in step e. Also
2155 + compare bits [9:15] of the register at offset 0x32C saved in step d to the value
2156 + of bits [9:15] saved in step e. If the two registers values are unchanged, then
2157 + the transmit portion of the dTSEC controller is locked up and the user should
2158 + proceed to the recover sequence. */
2159 + if ((tpkt1 == tpkt2) && ((tmpReg1 & 0x007F0000) == (tmpReg2 & 0x007F0000)))
2160 + {
2161 + /* recover sequence */
2162 +
2163 + /* a.Write a 1 to RCTRL[GRS]*/
2164 +
2165 + WRITE_UINT32(p_DtsecMemMap->rctrl, GET_UINT32(p_DtsecMemMap->rctrl) | RCTRL_GRS);
2166 +
2167 + /* b.Wait until IEVENT[GRSC]=1, or at least 100 us has elapsed. */
2168 + for (i = 0 ; i < 100 ; i++ )
2169 + {
2170 + if (GET_UINT32(p_DtsecMemMap->ievent) & DTSEC_IMASK_GRSCEN)
2171 + break;
2172 + XX_UDelay(1);
2173 + }
2174 + if (GET_UINT32(p_DtsecMemMap->ievent) & DTSEC_IMASK_GRSCEN)
2175 + WRITE_UINT32(p_DtsecMemMap->ievent, DTSEC_IMASK_GRSCEN);
2176 + else
2177 + DBG(INFO,("Rx lockup due to dTSEC Tx lockup"));
2178 +
2179 + /* c.Write a 1 to bit n of FM_RSTC (offset 0x0CC of FPM)*/
2180 + FmResetMac(p_Dtsec->fmMacControllerDriver.h_Fm, e_FM_MAC_1G, p_Dtsec->fmMacControllerDriver.macId);
2181 +
2182 + /* d.Wait 4 Tx clocks (32 ns) */
2183 + XX_UDelay(1);
2184 +
2185 + /* e.Write a 0 to bit n of FM_RSTC. */
2186 + /* cleared by FMAN */
2187 + }
2188 + }
2189 +#endif /* FM_TX_LOCKUP_ERRATA_DTSEC6 */
2190 +
2191 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_TX_FIFO_UNDRN);
2192 + }
2193 + if (event & DTSEC_IMASK_MAGEN)
2194 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_MAG_PCKT);
2195 + if (event & DTSEC_IMASK_GRSCEN)
2196 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET);
2197 + if (event & DTSEC_IMASK_TDPEEN)
2198 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_TX_DATA_ERR);
2199 + if (event & DTSEC_IMASK_RDPEEN)
2200 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_RX_DATA_ERR);
2201 +
2202 + /* - masked interrupts */
2203 + ASSERT_COND(!(event & DTSEC_IMASK_ABRTEN));
2204 + ASSERT_COND(!(event & DTSEC_IMASK_IFERREN));
2205 +}
2206 +
2207 +static void DtsecMdioIsr(t_Handle h_Dtsec)
2208 +{
2209 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2210 + uint32_t event;
2211 + struct dtsec_regs *p_DtsecMemMap = p_Dtsec->p_MemMap;
2212 +
2213 + event = GET_UINT32(p_DtsecMemMap->ievent);
2214 + /* handle only MDIO events */
2215 + event &= (DTSEC_IMASK_MMRDEN | DTSEC_IMASK_MMWREN);
2216 + if (event)
2217 + {
2218 + event &= GET_UINT32(p_DtsecMemMap->imask);
2219 +
2220 + WRITE_UINT32(p_DtsecMemMap->ievent, event);
2221 +
2222 + if (event & DTSEC_IMASK_MMRDEN)
2223 + p_Dtsec->f_Event(p_Dtsec->h_App, e_FM_MAC_EX_1G_MII_MNG_RD_COMPLET);
2224 + if (event & DTSEC_IMASK_MMWREN)
2225 + p_Dtsec->f_Event(p_Dtsec->h_App, e_FM_MAC_EX_1G_MII_MNG_WR_COMPLET);
2226 + }
2227 +}
2228 +
2229 +static void Dtsec1588Isr(t_Handle h_Dtsec)
2230 +{
2231 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2232 + uint32_t event;
2233 + struct dtsec_regs *p_DtsecMemMap = p_Dtsec->p_MemMap;
2234 +
2235 + if (p_Dtsec->ptpTsuEnabled)
2236 + {
2237 + event = fman_dtsec_check_and_clear_tmr_event(p_DtsecMemMap);
2238 +
2239 + if (event)
2240 + {
2241 + ASSERT_COND(event & TMR_PEVENT_TSRE);
2242 + p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_1588_TS_RX_ERR);
2243 + }
2244 + }
2245 +}
2246 +
2247 +/* ........................................................................... */
2248 +
2249 +static void FreeInitResources(t_Dtsec *p_Dtsec)
2250 +{
2251 + if (p_Dtsec->mdioIrq != NO_IRQ)
2252 + {
2253 + XX_DisableIntr(p_Dtsec->mdioIrq);
2254 + XX_FreeIntr(p_Dtsec->mdioIrq);
2255 + }
2256 + FmUnregisterIntr(p_Dtsec->fmMacControllerDriver.h_Fm, e_FM_MOD_1G_MAC, p_Dtsec->macId, e_FM_INTR_TYPE_ERR);
2257 + FmUnregisterIntr(p_Dtsec->fmMacControllerDriver.h_Fm, e_FM_MOD_1G_MAC, p_Dtsec->macId, e_FM_INTR_TYPE_NORMAL);
2258 +
2259 + /* release the driver's group hash table */
2260 + FreeHashTable(p_Dtsec->p_MulticastAddrHash);
2261 + p_Dtsec->p_MulticastAddrHash = NULL;
2262 +
2263 + /* release the driver's individual hash table */
2264 + FreeHashTable(p_Dtsec->p_UnicastAddrHash);
2265 + p_Dtsec->p_UnicastAddrHash = NULL;
2266 +}
2267 +
2268 +/* ........................................................................... */
2269 +
2270 +static t_Error GracefulStop(t_Dtsec *p_Dtsec, e_CommMode mode)
2271 +{
2272 + struct dtsec_regs *p_MemMap;
2273 +
2274 + ASSERT_COND(p_Dtsec);
2275 +
2276 + p_MemMap = p_Dtsec->p_MemMap;
2277 + ASSERT_COND(p_MemMap);
2278 +
2279 + /* Assert the graceful transmit stop bit */
2280 + if (mode & e_COMM_MODE_RX)
2281 + {
2282 + fman_dtsec_stop_rx(p_MemMap);
2283 +
2284 +#ifdef FM_GRS_ERRATA_DTSEC_A002
2285 + if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
2286 + XX_UDelay(100);
2287 +#else /* FM_GRS_ERRATA_DTSEC_A002 */
2288 +#ifdef FM_GTS_AFTER_DROPPED_FRAME_ERRATA_DTSEC_A004839
2289 + XX_UDelay(10);
2290 +#endif /* FM_GTS_AFTER_DROPPED_FRAME_ERRATA_DTSEC_A004839 */
2291 +#endif /* FM_GRS_ERRATA_DTSEC_A002 */
2292 + }
2293 +
2294 + if (mode & e_COMM_MODE_TX)
2295 +#if defined(FM_GTS_ERRATA_DTSEC_A004) || defined(FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012)
2296 + if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
2297 + DBG(INFO, ("GTS not supported due to DTSEC_A004 errata."));
2298 +#else /* not defined(FM_GTS_ERRATA_DTSEC_A004) ||... */
2299 +#ifdef FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014
2300 + DBG(INFO, ("GTS not supported due to DTSEC_A0014 errata."));
2301 +#else /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 */
2302 + fman_dtsec_stop_tx(p_MemMap);
2303 +#endif /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 */
2304 +#endif /* defined(FM_GTS_ERRATA_DTSEC_A004) ||... */
2305 +
2306 + return E_OK;
2307 +}
2308 +
2309 +/* .............................................................................. */
2310 +
2311 +static t_Error GracefulRestart(t_Dtsec *p_Dtsec, e_CommMode mode)
2312 +{
2313 + struct dtsec_regs *p_MemMap;
2314 +
2315 + ASSERT_COND(p_Dtsec);
2316 + p_MemMap = p_Dtsec->p_MemMap;
2317 + ASSERT_COND(p_MemMap);
2318 +
2319 + /* clear the graceful receive stop bit */
2320 + if (mode & e_COMM_MODE_TX)
2321 + fman_dtsec_start_tx(p_MemMap);
2322 +
2323 + if (mode & e_COMM_MODE_RX)
2324 + fman_dtsec_start_rx(p_MemMap);
2325 +
2326 + return E_OK;
2327 +}
2328 +
2329 +
2330 +/*****************************************************************************/
2331 +/* dTSEC Configs modification functions */
2332 +/*****************************************************************************/
2333 +
2334 +/* .............................................................................. */
2335 +
2336 +static t_Error DtsecConfigLoopback(t_Handle h_Dtsec, bool newVal)
2337 +{
2338 +
2339 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2340 +
2341 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2342 + SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2343 +
2344 + p_Dtsec->p_DtsecDriverParam->loopback = newVal;
2345 +
2346 + return E_OK;
2347 +}
2348 +
2349 +/* .............................................................................. */
2350 +
2351 +static t_Error DtsecConfigMaxFrameLength(t_Handle h_Dtsec, uint16_t newVal)
2352 +{
2353 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2354 +
2355 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2356 + SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2357 +
2358 + p_Dtsec->p_DtsecDriverParam->maximum_frame = newVal;
2359 +
2360 + return E_OK;
2361 +}
2362 +
2363 +/* .............................................................................. */
2364 +
2365 +static t_Error DtsecConfigPadAndCrc(t_Handle h_Dtsec, bool newVal)
2366 +{
2367 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2368 +
2369 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2370 + SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2371 +
2372 + p_Dtsec->p_DtsecDriverParam->tx_pad_crc = newVal;
2373 +
2374 + return E_OK;
2375 +}
2376 +
2377 +/* .............................................................................. */
2378 +
2379 +static t_Error DtsecConfigHalfDuplex(t_Handle h_Dtsec, bool newVal)
2380 +{
2381 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2382 +
2383 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2384 + SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2385 +
2386 + p_Dtsec->p_DtsecDriverParam->halfdup_on = newVal;
2387 +
2388 + return E_OK;
2389 +}
2390 +
2391 +/* .............................................................................. */
2392 +
2393 +static t_Error DtsecConfigTbiPhyAddr(t_Handle h_Dtsec, uint8_t newVal)
2394 +{
2395 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2396 +
2397 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2398 + SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2399 +
2400 + p_Dtsec->p_DtsecDriverParam->tbi_phy_addr = newVal;
2401 +
2402 + return E_OK;
2403 +}
2404 +
2405 +/* .............................................................................. */
2406 +
2407 +static t_Error DtsecConfigLengthCheck(t_Handle h_Dtsec, bool newVal)
2408 +{
2409 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2410 +
2411 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2412 + SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2413 +
2414 + p_Dtsec->p_DtsecDriverParam->rx_len_check = newVal;
2415 +
2416 + return E_OK;
2417 +}
2418 +
2419 +/* .............................................................................. */
2420 +
2421 +static t_Error DtsecConfigException(t_Handle h_Dtsec, e_FmMacExceptions exception, bool enable)
2422 +{
2423 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2424 + uint32_t bitMask = 0;
2425 +
2426 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2427 + SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2428 +
2429 + if (exception != e_FM_MAC_EX_1G_1588_TS_RX_ERR)
2430 + {
2431 + GET_EXCEPTION_FLAG(bitMask, exception);
2432 + if (bitMask)
2433 + {
2434 + if (enable)
2435 + p_Dtsec->exceptions |= bitMask;
2436 + else
2437 + p_Dtsec->exceptions &= ~bitMask;
2438 + }
2439 + else
2440 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
2441 + }
2442 + else
2443 + {
2444 + if (!p_Dtsec->ptpTsuEnabled)
2445 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exception valid for 1588 only"));
2446 +
2447 + if (enable)
2448 + p_Dtsec->enTsuErrExeption = TRUE;
2449 + else
2450 + p_Dtsec->enTsuErrExeption = FALSE;
2451 + }
2452 +
2453 + return E_OK;
2454 +}
2455 +
2456 +
2457 +/*****************************************************************************/
2458 +/* dTSEC Run Time API functions */
2459 +/*****************************************************************************/
2460 +
2461 +/* .............................................................................. */
2462 +
2463 +static t_Error DtsecEnable(t_Handle h_Dtsec, e_CommMode mode)
2464 +{
2465 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2466 +
2467 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2468 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2469 +
2470 + fman_dtsec_enable(p_Dtsec->p_MemMap,
2471 + (bool)!!(mode & e_COMM_MODE_RX),
2472 + (bool)!!(mode & e_COMM_MODE_TX));
2473 +
2474 + GracefulRestart(p_Dtsec, mode);
2475 +
2476 + return E_OK;
2477 +}
2478 +
2479 +/* .............................................................................. */
2480 +
2481 +static t_Error DtsecDisable (t_Handle h_Dtsec, e_CommMode mode)
2482 +{
2483 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2484 +
2485 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2486 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2487 +
2488 + GracefulStop(p_Dtsec, mode);
2489 +
2490 + fman_dtsec_disable(p_Dtsec->p_MemMap,
2491 + (bool)!!(mode & e_COMM_MODE_RX),
2492 + (bool)!!(mode & e_COMM_MODE_TX));
2493 +
2494 + return E_OK;
2495 +}
2496 +
2497 +/* .............................................................................. */
2498 +
2499 +static t_Error DtsecSetTxPauseFrames(t_Handle h_Dtsec,
2500 + uint8_t priority,
2501 + uint16_t pauseTime,
2502 + uint16_t threshTime)
2503 +{
2504 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2505 +
2506 + UNUSED(priority);UNUSED(threshTime);
2507 +
2508 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_STATE);
2509 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2510 +
2511 +#ifdef FM_BAD_TX_TS_IN_B_2_B_ERRATA_DTSEC_A003
2512 + if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
2513 + if (0 < pauseTime && pauseTime <= 320)
2514 + RETURN_ERROR(MINOR, E_INVALID_VALUE,
2515 + ("This pause-time value of %d is illegal due to errata dTSEC-A003!"
2516 + " value should be greater than 320."));
2517 +#endif /* FM_BAD_TX_TS_IN_B_2_B_ERRATA_DTSEC_A003 */
2518 +
2519 + fman_dtsec_set_tx_pause_frames(p_Dtsec->p_MemMap, pauseTime);
2520 + return E_OK;
2521 +}
2522 +
2523 +/* .............................................................................. */
2524 +/* backward compatibility. will be removed in the future. */
2525 +static t_Error DtsecTxMacPause(t_Handle h_Dtsec, uint16_t pauseTime)
2526 +{
2527 + return DtsecSetTxPauseFrames(h_Dtsec, 0, pauseTime, 0);
2528 +}
2529 +
2530 +/* .............................................................................. */
2531 +
2532 +static t_Error DtsecRxIgnoreMacPause(t_Handle h_Dtsec, bool en)
2533 +{
2534 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2535 + bool accept_pause = !en;
2536 +
2537 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_STATE);
2538 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2539 +
2540 + fman_dtsec_handle_rx_pause(p_Dtsec->p_MemMap, accept_pause);
2541 +
2542 + return E_OK;
2543 +}
2544 +
2545 +/* .............................................................................. */
2546 +
2547 +static t_Error DtsecEnable1588TimeStamp(t_Handle h_Dtsec)
2548 +{
2549 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2550 +
2551 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2552 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2553 +
2554 + p_Dtsec->ptpTsuEnabled = TRUE;
2555 + fman_dtsec_set_ts(p_Dtsec->p_MemMap, TRUE);
2556 +
2557 + return E_OK;
2558 +}
2559 +
2560 +/* .............................................................................. */
2561 +
2562 +static t_Error DtsecDisable1588TimeStamp(t_Handle h_Dtsec)
2563 +{
2564 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2565 +
2566 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2567 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2568 +
2569 + p_Dtsec->ptpTsuEnabled = FALSE;
2570 + fman_dtsec_set_ts(p_Dtsec->p_MemMap, FALSE);
2571 +
2572 + return E_OK;
2573 +}
2574 +
2575 +/* .............................................................................. */
2576 +
2577 +static t_Error DtsecGetStatistics(t_Handle h_Dtsec, t_FmMacStatistics *p_Statistics)
2578 +{
2579 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2580 + struct dtsec_regs *p_DtsecMemMap;
2581 +
2582 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2583 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2584 + SANITY_CHECK_RETURN_ERROR(p_Statistics, E_NULL_POINTER);
2585 +
2586 + p_DtsecMemMap = p_Dtsec->p_MemMap;
2587 +
2588 + if (p_Dtsec->statisticsLevel == e_FM_MAC_NONE_STATISTICS)
2589 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Statistics disabled"));
2590 +
2591 + memset(p_Statistics, 0xff, sizeof(t_FmMacStatistics));
2592 +
2593 + if (p_Dtsec->statisticsLevel == e_FM_MAC_FULL_STATISTICS)
2594 + {
2595 + p_Statistics->eStatPkts64 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TR64)
2596 + + p_Dtsec->internalStatistics.tr64;
2597 + p_Statistics->eStatPkts65to127 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TR127)
2598 + + p_Dtsec->internalStatistics.tr127;
2599 + p_Statistics->eStatPkts128to255 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TR255)
2600 + + p_Dtsec->internalStatistics.tr255;
2601 + p_Statistics->eStatPkts256to511 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TR511)
2602 + + p_Dtsec->internalStatistics.tr511;
2603 + p_Statistics->eStatPkts512to1023 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TR1K)
2604 + + p_Dtsec->internalStatistics.tr1k;
2605 + p_Statistics->eStatPkts1024to1518 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TRMAX)
2606 + + p_Dtsec->internalStatistics.trmax;
2607 + p_Statistics->eStatPkts1519to1522 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TRMGV)
2608 + + p_Dtsec->internalStatistics.trmgv;
2609 +
2610 + /* MIB II */
2611 + p_Statistics->ifInOctets = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RBYT)
2612 + + p_Dtsec->internalStatistics.rbyt;
2613 + p_Statistics->ifInPkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RPKT)
2614 + + p_Dtsec->internalStatistics.rpkt;
2615 + p_Statistics->ifInUcastPkts = 0;
2616 + p_Statistics->ifInMcastPkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RMCA)
2617 + + p_Dtsec->internalStatistics.rmca;
2618 + p_Statistics->ifInBcastPkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RBCA)
2619 + + p_Dtsec->internalStatistics.rbca;
2620 + p_Statistics->ifOutOctets = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TBYT)
2621 + + p_Dtsec->internalStatistics.tbyt;
2622 + p_Statistics->ifOutPkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TPKT)
2623 + + p_Dtsec->internalStatistics.tpkt;
2624 + p_Statistics->ifOutUcastPkts = 0;
2625 + p_Statistics->ifOutMcastPkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TMCA)
2626 + + p_Dtsec->internalStatistics.tmca;
2627 + p_Statistics->ifOutBcastPkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TBCA)
2628 + + p_Dtsec->internalStatistics.tbca;
2629 + }
2630 +
2631 + p_Statistics->eStatFragments = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RFRG)
2632 + + p_Dtsec->internalStatistics.rfrg;
2633 + p_Statistics->eStatJabbers = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RJBR)
2634 + + p_Dtsec->internalStatistics.rjbr;
2635 + p_Statistics->eStatsDropEvents = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RDRP)
2636 + + p_Dtsec->internalStatistics.rdrp;
2637 + p_Statistics->eStatCRCAlignErrors = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RALN)
2638 + + p_Dtsec->internalStatistics.raln;
2639 + p_Statistics->eStatUndersizePkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RUND)
2640 + + p_Dtsec->internalStatistics.rund;
2641 + p_Statistics->eStatOversizePkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_ROVR)
2642 + + p_Dtsec->internalStatistics.rovr;
2643 + p_Statistics->reStatPause = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RXPF)
2644 + + p_Dtsec->internalStatistics.rxpf;
2645 + p_Statistics->teStatPause = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TXPF)
2646 + + p_Dtsec->internalStatistics.txpf;
2647 + p_Statistics->ifInDiscards = p_Statistics->eStatsDropEvents;
2648 + p_Statistics->ifInErrors = p_Statistics->eStatsDropEvents + p_Statistics->eStatCRCAlignErrors
2649 + + fman_dtsec_get_stat_counter(p_DtsecMemMap,E_DTSEC_STAT_RFLR) + p_Dtsec->internalStatistics.rflr
2650 + + fman_dtsec_get_stat_counter(p_DtsecMemMap,E_DTSEC_STAT_RCDE) + p_Dtsec->internalStatistics.rcde
2651 + + fman_dtsec_get_stat_counter(p_DtsecMemMap,E_DTSEC_STAT_RCSE) + p_Dtsec->internalStatistics.rcse;
2652 +
2653 + p_Statistics->ifOutDiscards = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TDRP)
2654 + + p_Dtsec->internalStatistics.tdrp;
2655 + p_Statistics->ifOutErrors = p_Statistics->ifOutDiscards /**< Number of frames transmitted with error: */
2656 + + fman_dtsec_get_stat_counter(p_DtsecMemMap,E_DTSEC_STAT_TFCS)
2657 + + p_Dtsec->internalStatistics.tfcs;
2658 +
2659 + return E_OK;
2660 +}
2661 +
2662 +/* .............................................................................. */
2663 +
2664 +static t_Error DtsecModifyMacAddress (t_Handle h_Dtsec, t_EnetAddr *p_EnetAddr)
2665 +{
2666 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2667 +
2668 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2669 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2670 +
2671 + /* Initialize MAC Station Address registers (1 & 2) */
2672 + /* Station address have to be swapped (big endian to little endian */
2673 + p_Dtsec->addr = ENET_ADDR_TO_UINT64(*p_EnetAddr);
2674 + fman_dtsec_set_mac_address(p_Dtsec->p_MemMap, (uint8_t *)(*p_EnetAddr));
2675 +
2676 + return E_OK;
2677 +}
2678 +
2679 +/* .............................................................................. */
2680 +
2681 +static t_Error DtsecResetCounters (t_Handle h_Dtsec)
2682 +{
2683 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2684 +
2685 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2686 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2687 +
2688 + /* clear HW counters */
2689 + fman_dtsec_reset_stat(p_Dtsec->p_MemMap);
2690 +
2691 + /* clear SW counters holding carries */
2692 + memset(&p_Dtsec->internalStatistics, 0, sizeof(t_InternalStatistics));
2693 +
2694 + return E_OK;
2695 +}
2696 +
2697 +/* .............................................................................. */
2698 +
2699 +static t_Error DtsecAddExactMatchMacAddress(t_Handle h_Dtsec, t_EnetAddr *p_EthAddr)
2700 +{
2701 + t_Dtsec *p_Dtsec = (t_Dtsec *) h_Dtsec;
2702 + uint64_t ethAddr;
2703 + uint8_t paddrNum;
2704 +
2705 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2706 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2707 +
2708 + ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
2709 +
2710 + if (ethAddr & GROUP_ADDRESS)
2711 + /* Multicast address has no effect in PADDR */
2712 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Multicast address"));
2713 +
2714 + /* Make sure no PADDR contains this address */
2715 + for (paddrNum = 0; paddrNum < DTSEC_NUM_OF_PADDRS; paddrNum++)
2716 + if (p_Dtsec->indAddrRegUsed[paddrNum])
2717 + if (p_Dtsec->paddr[paddrNum] == ethAddr)
2718 + RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, NO_MSG);
2719 +
2720 + /* Find first unused PADDR */
2721 + for (paddrNum = 0; paddrNum < DTSEC_NUM_OF_PADDRS; paddrNum++)
2722 + if (!(p_Dtsec->indAddrRegUsed[paddrNum]))
2723 + {
2724 + /* mark this PADDR as used */
2725 + p_Dtsec->indAddrRegUsed[paddrNum] = TRUE;
2726 + /* store address */
2727 + p_Dtsec->paddr[paddrNum] = ethAddr;
2728 +
2729 + /* put in hardware */
2730 + fman_dtsec_add_addr_in_paddr(p_Dtsec->p_MemMap, (uint64_t)PTR_TO_UINT(&ethAddr), paddrNum);
2731 + p_Dtsec->numOfIndAddrInRegs++;
2732 +
2733 + return E_OK;
2734 + }
2735 +
2736 + /* No free PADDR */
2737 + RETURN_ERROR(MAJOR, E_FULL, NO_MSG);
2738 +}
2739 +
2740 +/* .............................................................................. */
2741 +
2742 +static t_Error DtsecDelExactMatchMacAddress(t_Handle h_Dtsec, t_EnetAddr *p_EthAddr)
2743 +{
2744 + t_Dtsec *p_Dtsec = (t_Dtsec *) h_Dtsec;
2745 + uint64_t ethAddr;
2746 + uint8_t paddrNum;
2747 +
2748 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2749 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2750 +
2751 + ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
2752 +
2753 + /* Find used PADDR containing this address */
2754 + for (paddrNum = 0; paddrNum < DTSEC_NUM_OF_PADDRS; paddrNum++)
2755 + {
2756 + if ((p_Dtsec->indAddrRegUsed[paddrNum]) &&
2757 + (p_Dtsec->paddr[paddrNum] == ethAddr))
2758 + {
2759 + /* mark this PADDR as not used */
2760 + p_Dtsec->indAddrRegUsed[paddrNum] = FALSE;
2761 + /* clear in hardware */
2762 + fman_dtsec_clear_addr_in_paddr(p_Dtsec->p_MemMap, paddrNum);
2763 + p_Dtsec->numOfIndAddrInRegs--;
2764 +
2765 + return E_OK;
2766 + }
2767 + }
2768 +
2769 + RETURN_ERROR(MAJOR, E_NOT_FOUND, NO_MSG);
2770 +}
2771 +
2772 +/* .............................................................................. */
2773 +
2774 +static t_Error DtsecAddHashMacAddress(t_Handle h_Dtsec, t_EnetAddr *p_EthAddr)
2775 +{
2776 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2777 + t_EthHashEntry *p_HashEntry;
2778 + uint64_t ethAddr;
2779 + int32_t bucket;
2780 + uint32_t crc;
2781 + bool mcast, ghtx;
2782 +
2783 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2784 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2785 +
2786 + ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
2787 +
2788 + ghtx = (bool)((fman_dtsec_get_rctrl(p_Dtsec->p_MemMap) & RCTRL_GHTX) ? TRUE : FALSE);
2789 + mcast = (bool)((ethAddr & MAC_GROUP_ADDRESS) ? TRUE : FALSE);
2790 +
2791 + if (ghtx && !mcast) /* Cannot handle unicast mac addr when GHTX is on */
2792 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Could not compute hash bucket"));
2793 +
2794 + crc = GetMacAddrHashCode(ethAddr);
2795 +
2796 + /* considering the 9 highest order bits in crc H[8:0]:
2797 + * if ghtx = 0 H[8:6] (highest order 3 bits) identify the hash register
2798 + * and H[5:1] (next 5 bits) identify the hash bit
2799 + * if ghts = 1 H[8:5] (highest order 4 bits) identify the hash register
2800 + * and H[4:0] (next 5 bits) identify the hash bit.
2801 + *
2802 + * In bucket index output the low 5 bits identify the hash register bit,
2803 + * while the higher 4 bits identify the hash register
2804 + */
2805 +
2806 + if (ghtx)
2807 + bucket = (int32_t)((crc >> 23) & 0x1ff);
2808 + else {
2809 + bucket = (int32_t)((crc >> 24) & 0xff);
2810 + /* if !ghtx and mcast the bit must be set in gaddr instead of igaddr. */
2811 + if (mcast)
2812 + bucket += 0x100;
2813 + }
2814 +
2815 + fman_dtsec_set_bucket(p_Dtsec->p_MemMap, bucket, TRUE);
2816 +
2817 + /* Create element to be added to the driver hash table */
2818 + p_HashEntry = (t_EthHashEntry *)XX_Malloc(sizeof(t_EthHashEntry));
2819 + p_HashEntry->addr = ethAddr;
2820 + INIT_LIST(&p_HashEntry->node);
2821 +
2822 + if (ethAddr & MAC_GROUP_ADDRESS)
2823 + /* Group Address */
2824 + LIST_AddToTail(&(p_HashEntry->node), &(p_Dtsec->p_MulticastAddrHash->p_Lsts[bucket]));
2825 + else
2826 + LIST_AddToTail(&(p_HashEntry->node), &(p_Dtsec->p_UnicastAddrHash->p_Lsts[bucket]));
2827 +
2828 + return E_OK;
2829 +}
2830 +
2831 +/* .............................................................................. */
2832 +
2833 +static t_Error DtsecDelHashMacAddress(t_Handle h_Dtsec, t_EnetAddr *p_EthAddr)
2834 +{
2835 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2836 + t_List *p_Pos;
2837 + t_EthHashEntry *p_HashEntry = NULL;
2838 + uint64_t ethAddr;
2839 + int32_t bucket;
2840 + uint32_t crc;
2841 + bool mcast, ghtx;
2842 +
2843 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2844 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2845 +
2846 + ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
2847 +
2848 + ghtx = (bool)((fman_dtsec_get_rctrl(p_Dtsec->p_MemMap) & RCTRL_GHTX) ? TRUE : FALSE);
2849 + mcast = (bool)((ethAddr & MAC_GROUP_ADDRESS) ? TRUE : FALSE);
2850 +
2851 + if (ghtx && !mcast) /* Cannot handle unicast mac addr when GHTX is on */
2852 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Could not compute hash bucket"));
2853 +
2854 + crc = GetMacAddrHashCode(ethAddr);
2855 +
2856 + if (ghtx)
2857 + bucket = (int32_t)((crc >> 23) & 0x1ff);
2858 + else {
2859 + bucket = (int32_t)((crc >> 24) & 0xff);
2860 + /* if !ghtx and mcast the bit must be set in gaddr instead of igaddr. */
2861 + if (mcast)
2862 + bucket += 0x100;
2863 + }
2864 +
2865 + if (ethAddr & MAC_GROUP_ADDRESS)
2866 + {
2867 + /* Group Address */
2868 + LIST_FOR_EACH(p_Pos, &(p_Dtsec->p_MulticastAddrHash->p_Lsts[bucket]))
2869 + {
2870 + p_HashEntry = ETH_HASH_ENTRY_OBJ(p_Pos);
2871 + if (p_HashEntry->addr == ethAddr)
2872 + {
2873 + LIST_DelAndInit(&p_HashEntry->node);
2874 + XX_Free(p_HashEntry);
2875 + break;
2876 + }
2877 + }
2878 + if (LIST_IsEmpty(&p_Dtsec->p_MulticastAddrHash->p_Lsts[bucket]))
2879 + fman_dtsec_set_bucket(p_Dtsec->p_MemMap, bucket, FALSE);
2880 + }
2881 + else
2882 + {
2883 + /* Individual Address */
2884 + LIST_FOR_EACH(p_Pos, &(p_Dtsec->p_UnicastAddrHash->p_Lsts[bucket]))
2885 + {
2886 + p_HashEntry = ETH_HASH_ENTRY_OBJ(p_Pos);
2887 + if (p_HashEntry->addr == ethAddr)
2888 + {
2889 + LIST_DelAndInit(&p_HashEntry->node);
2890 + XX_Free(p_HashEntry);
2891 + break;
2892 + }
2893 + }
2894 + if (LIST_IsEmpty(&p_Dtsec->p_UnicastAddrHash->p_Lsts[bucket]))
2895 + fman_dtsec_set_bucket(p_Dtsec->p_MemMap, bucket, FALSE);
2896 + }
2897 +
2898 + /* address does not exist */
2899 + ASSERT_COND(p_HashEntry != NULL);
2900 +
2901 + return E_OK;
2902 +}
2903 +
2904 +/* .............................................................................. */
2905 +
2906 +static t_Error DtsecSetPromiscuous(t_Handle h_Dtsec, bool newVal)
2907 +{
2908 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2909 +
2910 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2911 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2912 +
2913 + fman_dtsec_set_uc_promisc(p_Dtsec->p_MemMap, newVal);
2914 + fman_dtsec_set_mc_promisc(p_Dtsec->p_MemMap, newVal);
2915 +
2916 + return E_OK;
2917 +}
2918 +
2919 +/* .............................................................................. */
2920 +
2921 +static t_Error DtsecSetStatistics(t_Handle h_Dtsec, e_FmMacStatisticsLevel statisticsLevel)
2922 +{
2923 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2924 + t_Error err;
2925 +
2926 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2927 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2928 +
2929 + p_Dtsec->statisticsLevel = statisticsLevel;
2930 +
2931 + err = (t_Error)fman_dtsec_set_stat_level(p_Dtsec->p_MemMap,
2932 + (enum dtsec_stat_level)statisticsLevel);
2933 + if (err != E_OK)
2934 + return err;
2935 +
2936 + switch (statisticsLevel)
2937 + {
2938 + case (e_FM_MAC_NONE_STATISTICS):
2939 + p_Dtsec->exceptions &= ~DTSEC_IMASK_MSROEN;
2940 + break;
2941 + case (e_FM_MAC_PARTIAL_STATISTICS):
2942 + p_Dtsec->exceptions |= DTSEC_IMASK_MSROEN;
2943 + break;
2944 + case (e_FM_MAC_FULL_STATISTICS):
2945 + p_Dtsec->exceptions |= DTSEC_IMASK_MSROEN;
2946 + break;
2947 + default:
2948 + RETURN_ERROR(MINOR, E_INVALID_SELECTION, NO_MSG);
2949 + }
2950 +
2951 + return E_OK;
2952 +}
2953 +
2954 +/* .............................................................................. */
2955 +
2956 +static t_Error DtsecSetWakeOnLan(t_Handle h_Dtsec, bool en)
2957 +{
2958 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2959 +
2960 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_STATE);
2961 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2962 +
2963 + fman_dtsec_set_wol(p_Dtsec->p_MemMap, en);
2964 +
2965 + return E_OK;
2966 +}
2967 +
2968 +/* .............................................................................. */
2969 +
2970 +static t_Error DtsecAdjustLink(t_Handle h_Dtsec, e_EnetSpeed speed, bool fullDuplex)
2971 +{
2972 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2973 + int err;
2974 + enum enet_interface enet_interface;
2975 + enum enet_speed enet_speed;
2976 +
2977 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
2978 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
2979 +
2980 + p_Dtsec->enetMode = MAKE_ENET_MODE(ENET_INTERFACE_FROM_MODE(p_Dtsec->enetMode), speed);
2981 + enet_interface = (enum enet_interface) ENET_INTERFACE_FROM_MODE(p_Dtsec->enetMode);
2982 + enet_speed = (enum enet_speed) ENET_SPEED_FROM_MODE(p_Dtsec->enetMode);
2983 + p_Dtsec->halfDuplex = !fullDuplex;
2984 +
2985 + err = fman_dtsec_adjust_link(p_Dtsec->p_MemMap, enet_interface, enet_speed, fullDuplex);
2986 +
2987 + if (err == -EINVAL)
2988 + RETURN_ERROR(MAJOR, E_CONFLICT, ("Ethernet interface does not support Half Duplex mode"));
2989 +
2990 + return (t_Error)err;
2991 +}
2992 +
2993 +/* .............................................................................. */
2994 +
2995 +static t_Error DtsecRestartAutoneg(t_Handle h_Dtsec)
2996 +{
2997 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
2998 + uint16_t tmpReg16;
2999 +
3000 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
3001 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
3002 +
3003 + DTSEC_MII_ReadPhyReg(p_Dtsec, p_Dtsec->tbi_phy_addr, 0, &tmpReg16);
3004 +
3005 + tmpReg16 &= ~( PHY_CR_SPEED0 | PHY_CR_SPEED1 );
3006 + tmpReg16 |= (PHY_CR_ANE | PHY_CR_RESET_AN | PHY_CR_FULLDUPLEX | PHY_CR_SPEED1);
3007 +
3008 + DTSEC_MII_WritePhyReg(p_Dtsec, p_Dtsec->tbi_phy_addr, 0, tmpReg16);
3009 +
3010 + return E_OK;
3011 +}
3012 +
3013 +/* .............................................................................. */
3014 +
3015 +static t_Error DtsecGetId(t_Handle h_Dtsec, uint32_t *macId)
3016 +{
3017 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
3018 +
3019 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
3020 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
3021 +
3022 + *macId = p_Dtsec->macId;
3023 +
3024 + return E_OK;
3025 +}
3026 +
3027 +/* .............................................................................. */
3028 +
3029 +static t_Error DtsecGetVersion(t_Handle h_Dtsec, uint32_t *macVersion)
3030 +{
3031 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
3032 +
3033 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
3034 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
3035 +
3036 + *macVersion = fman_dtsec_get_revision(p_Dtsec->p_MemMap);
3037 +
3038 + return E_OK;
3039 +}
3040 +
3041 +/* .............................................................................. */
3042 +
3043 +static t_Error DtsecSetException(t_Handle h_Dtsec, e_FmMacExceptions exception, bool enable)
3044 +{
3045 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
3046 + uint32_t bitMask = 0;
3047 +
3048 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
3049 + SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
3050 +
3051 + if (exception != e_FM_MAC_EX_1G_1588_TS_RX_ERR)
3052 + {
3053 + GET_EXCEPTION_FLAG(bitMask, exception);
3054 + if (bitMask)
3055 + {
3056 + if (enable)
3057 + p_Dtsec->exceptions |= bitMask;
3058 + else
3059 + p_Dtsec->exceptions &= ~bitMask;
3060 + }
3061 + else
3062 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
3063 +
3064 + if (enable)
3065 + fman_dtsec_enable_interrupt(p_Dtsec->p_MemMap, bitMask);
3066 + else
3067 + fman_dtsec_disable_interrupt(p_Dtsec->p_MemMap, bitMask);
3068 + }
3069 + else
3070 + {
3071 + if (!p_Dtsec->ptpTsuEnabled)
3072 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exception valid for 1588 only"));
3073 +
3074 + if (enable)
3075 + {
3076 + p_Dtsec->enTsuErrExeption = TRUE;
3077 + fman_dtsec_enable_tmr_interrupt(p_Dtsec->p_MemMap);
3078 + }
3079 + else
3080 + {
3081 + p_Dtsec->enTsuErrExeption = FALSE;
3082 + fman_dtsec_disable_tmr_interrupt(p_Dtsec->p_MemMap);
3083 + }
3084 + }
3085 +
3086 + return E_OK;
3087 +}
3088 +
3089 +
3090 +/*****************************************************************************/
3091 +/* dTSEC Init & Free API */
3092 +/*****************************************************************************/
3093 +
3094 +/* .............................................................................. */
3095 +
3096 +static t_Error DtsecInit(t_Handle h_Dtsec)
3097 +{
3098 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
3099 + struct dtsec_cfg *p_DtsecDriverParam;
3100 + t_Error err;
3101 + uint16_t maxFrmLn;
3102 + enum enet_interface enet_interface;
3103 + enum enet_speed enet_speed;
3104 + t_EnetAddr ethAddr;
3105 +
3106 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
3107 + SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
3108 + SANITY_CHECK_RETURN_ERROR(p_Dtsec->fmMacControllerDriver.h_Fm, E_INVALID_HANDLE);
3109 +
3110 + FM_GetRevision(p_Dtsec->fmMacControllerDriver.h_Fm, &p_Dtsec->fmMacControllerDriver.fmRevInfo);
3111 + CHECK_INIT_PARAMETERS(p_Dtsec, CheckInitParameters);
3112 +
3113 + p_DtsecDriverParam = p_Dtsec->p_DtsecDriverParam;
3114 + p_Dtsec->halfDuplex = p_DtsecDriverParam->halfdup_on;
3115 +
3116 + enet_interface = (enum enet_interface)ENET_INTERFACE_FROM_MODE(p_Dtsec->enetMode);
3117 + enet_speed = (enum enet_speed)ENET_SPEED_FROM_MODE(p_Dtsec->enetMode);
3118 + MAKE_ENET_ADDR_FROM_UINT64(p_Dtsec->addr, ethAddr);
3119 +
3120 + err = (t_Error)fman_dtsec_init(p_Dtsec->p_MemMap,
3121 + p_DtsecDriverParam,
3122 + enet_interface,
3123 + enet_speed,
3124 + (uint8_t*)ethAddr,
3125 + p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev,
3126 + p_Dtsec->fmMacControllerDriver.fmRevInfo.minorRev,
3127 + p_Dtsec->exceptions);
3128 + if (err)
3129 + {
3130 + FreeInitResources(p_Dtsec);
3131 + RETURN_ERROR(MAJOR, err, ("This DTSEC version does not support the required i/f mode"));
3132 + }
3133 +
3134 + if (ENET_INTERFACE_FROM_MODE(p_Dtsec->enetMode) == e_ENET_IF_SGMII)
3135 + {
3136 + uint16_t tmpReg16;
3137 +
3138 + /* Configure the TBI PHY Control Register */
3139 + tmpReg16 = PHY_TBICON_CLK_SEL | PHY_TBICON_SRESET;
3140 + DTSEC_MII_WritePhyReg(p_Dtsec, (uint8_t)p_DtsecDriverParam->tbipa, 17, tmpReg16);
3141 +
3142 + tmpReg16 = PHY_TBICON_CLK_SEL;
3143 + DTSEC_MII_WritePhyReg(p_Dtsec, (uint8_t)p_DtsecDriverParam->tbipa, 17, tmpReg16);
3144 +
3145 + tmpReg16 = (PHY_CR_PHY_RESET | PHY_CR_ANE | PHY_CR_FULLDUPLEX | PHY_CR_SPEED1);
3146 + DTSEC_MII_WritePhyReg(p_Dtsec, (uint8_t)p_DtsecDriverParam->tbipa, 0, tmpReg16);
3147 +
3148 + if (p_Dtsec->enetMode & ENET_IF_SGMII_BASEX)
3149 + tmpReg16 = PHY_TBIANA_1000X;
3150 + else
3151 + tmpReg16 = PHY_TBIANA_SGMII;
3152 + DTSEC_MII_WritePhyReg(p_Dtsec, (uint8_t)p_DtsecDriverParam->tbipa, 4, tmpReg16);
3153 +
3154 + tmpReg16 = (PHY_CR_ANE | PHY_CR_RESET_AN | PHY_CR_FULLDUPLEX | PHY_CR_SPEED1);
3155 +
3156 + DTSEC_MII_WritePhyReg(p_Dtsec, (uint8_t)p_DtsecDriverParam->tbipa, 0, tmpReg16);
3157 + }
3158 +
3159 + /* Max Frame Length */
3160 + maxFrmLn = fman_dtsec_get_max_frame_len(p_Dtsec->p_MemMap);
3161 + err = FmSetMacMaxFrame(p_Dtsec->fmMacControllerDriver.h_Fm, e_FM_MAC_1G,
3162 + p_Dtsec->fmMacControllerDriver.macId, maxFrmLn);
3163 + if (err)
3164 + RETURN_ERROR(MINOR,err, NO_MSG);
3165 +
3166 + p_Dtsec->p_MulticastAddrHash = AllocHashTable(EXTENDED_HASH_TABLE_SIZE);
3167 + if (!p_Dtsec->p_MulticastAddrHash) {
3168 + FreeInitResources(p_Dtsec);
3169 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MC hash table is FAILED"));
3170 + }
3171 +
3172 + p_Dtsec->p_UnicastAddrHash = AllocHashTable(HASH_TABLE_SIZE);
3173 + if (!p_Dtsec->p_UnicastAddrHash)
3174 + {
3175 + FreeInitResources(p_Dtsec);
3176 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("UC hash table is FAILED"));
3177 + }
3178 +
3179 + /* register err intr handler for dtsec to FPM (err)*/
3180 + FmRegisterIntr(p_Dtsec->fmMacControllerDriver.h_Fm,
3181 + e_FM_MOD_1G_MAC,
3182 + p_Dtsec->macId,
3183 + e_FM_INTR_TYPE_ERR,
3184 + DtsecIsr,
3185 + p_Dtsec);
3186 + /* register 1588 intr handler for TMR to FPM (normal)*/
3187 + FmRegisterIntr(p_Dtsec->fmMacControllerDriver.h_Fm,
3188 + e_FM_MOD_1G_MAC,
3189 + p_Dtsec->macId,
3190 + e_FM_INTR_TYPE_NORMAL,
3191 + Dtsec1588Isr,
3192 + p_Dtsec);
3193 + /* register normal intr handler for dtsec to main interrupt controller. */
3194 + if (p_Dtsec->mdioIrq != NO_IRQ)
3195 + {
3196 + XX_SetIntr(p_Dtsec->mdioIrq, DtsecMdioIsr, p_Dtsec);
3197 + XX_EnableIntr(p_Dtsec->mdioIrq);
3198 + }
3199 +
3200 + XX_Free(p_DtsecDriverParam);
3201 + p_Dtsec->p_DtsecDriverParam = NULL;
3202 +
3203 + err = DtsecSetStatistics(h_Dtsec, e_FM_MAC_FULL_STATISTICS);
3204 + if (err)
3205 + {
3206 + FreeInitResources(p_Dtsec);
3207 + RETURN_ERROR(MAJOR, err, ("Undefined statistics level"));
3208 + }
3209 +
3210 + return E_OK;
3211 +}
3212 +
3213 +/* ........................................................................... */
3214 +
3215 +static t_Error DtsecFree(t_Handle h_Dtsec)
3216 +{
3217 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
3218 +
3219 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
3220 +
3221 + if (p_Dtsec->p_DtsecDriverParam)
3222 + {
3223 + /* Called after config */
3224 + XX_Free(p_Dtsec->p_DtsecDriverParam);
3225 + p_Dtsec->p_DtsecDriverParam = NULL;
3226 + }
3227 + else
3228 + /* Called after init */
3229 + FreeInitResources(p_Dtsec);
3230 +
3231 + XX_Free(p_Dtsec);
3232 +
3233 + return E_OK;
3234 +}
3235 +
3236 +/* .............................................................................. */
3237 +
3238 +static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacControllerDriver)
3239 +{
3240 + p_FmMacControllerDriver->f_FM_MAC_Init = DtsecInit;
3241 + p_FmMacControllerDriver->f_FM_MAC_Free = DtsecFree;
3242 +
3243 + p_FmMacControllerDriver->f_FM_MAC_SetStatistics = DtsecSetStatistics;
3244 + p_FmMacControllerDriver->f_FM_MAC_ConfigLoopback = DtsecConfigLoopback;
3245 + p_FmMacControllerDriver->f_FM_MAC_ConfigMaxFrameLength = DtsecConfigMaxFrameLength;
3246 +
3247 + p_FmMacControllerDriver->f_FM_MAC_ConfigWan = NULL; /* Not supported on dTSEC */
3248 +
3249 + p_FmMacControllerDriver->f_FM_MAC_ConfigPadAndCrc = DtsecConfigPadAndCrc;
3250 + p_FmMacControllerDriver->f_FM_MAC_ConfigHalfDuplex = DtsecConfigHalfDuplex;
3251 + p_FmMacControllerDriver->f_FM_MAC_ConfigLengthCheck = DtsecConfigLengthCheck;
3252 + p_FmMacControllerDriver->f_FM_MAC_ConfigTbiPhyAddr = DtsecConfigTbiPhyAddr;
3253 + p_FmMacControllerDriver->f_FM_MAC_ConfigException = DtsecConfigException;
3254 + p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit = NULL;
3255 +
3256 + p_FmMacControllerDriver->f_FM_MAC_Enable = DtsecEnable;
3257 + p_FmMacControllerDriver->f_FM_MAC_Disable = DtsecDisable;
3258 +
3259 + p_FmMacControllerDriver->f_FM_MAC_SetException = DtsecSetException;
3260 +
3261 + p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous = DtsecSetPromiscuous;
3262 + p_FmMacControllerDriver->f_FM_MAC_AdjustLink = DtsecAdjustLink;
3263 + p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan = DtsecSetWakeOnLan;
3264 + p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg = DtsecRestartAutoneg;
3265 +
3266 + p_FmMacControllerDriver->f_FM_MAC_Enable1588TimeStamp = DtsecEnable1588TimeStamp;
3267 + p_FmMacControllerDriver->f_FM_MAC_Disable1588TimeStamp = DtsecDisable1588TimeStamp;
3268 +
3269 + p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames = DtsecTxMacPause;
3270 + p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames = DtsecSetTxPauseFrames;
3271 + p_FmMacControllerDriver->f_FM_MAC_SetRxIgnorePauseFrames = DtsecRxIgnoreMacPause;
3272 +
3273 + p_FmMacControllerDriver->f_FM_MAC_ResetCounters = DtsecResetCounters;
3274 + p_FmMacControllerDriver->f_FM_MAC_GetStatistics = DtsecGetStatistics;
3275 +
3276 + p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr = DtsecModifyMacAddress;
3277 + p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr = DtsecAddHashMacAddress;
3278 + p_FmMacControllerDriver->f_FM_MAC_RemoveHashMacAddr = DtsecDelHashMacAddress;
3279 + p_FmMacControllerDriver->f_FM_MAC_AddExactMatchMacAddr = DtsecAddExactMatchMacAddress;
3280 + p_FmMacControllerDriver->f_FM_MAC_RemovelExactMatchMacAddr = DtsecDelExactMatchMacAddress;
3281 + p_FmMacControllerDriver->f_FM_MAC_GetId = DtsecGetId;
3282 + p_FmMacControllerDriver->f_FM_MAC_GetVersion = DtsecGetVersion;
3283 + p_FmMacControllerDriver->f_FM_MAC_GetMaxFrameLength = DtsecGetMaxFrameLength;
3284 +
3285 + p_FmMacControllerDriver->f_FM_MAC_MII_WritePhyReg = DTSEC_MII_WritePhyReg;
3286 + p_FmMacControllerDriver->f_FM_MAC_MII_ReadPhyReg = DTSEC_MII_ReadPhyReg;
3287 +
3288 +}
3289 +
3290 +
3291 +/*****************************************************************************/
3292 +/* dTSEC Config Main Entry */
3293 +/*****************************************************************************/
3294 +
3295 +/* .............................................................................. */
3296 +
3297 +t_Handle DTSEC_Config(t_FmMacParams *p_FmMacParam)
3298 +{
3299 + t_Dtsec *p_Dtsec;
3300 + struct dtsec_cfg *p_DtsecDriverParam;
3301 + uintptr_t baseAddr;
3302 +
3303 + SANITY_CHECK_RETURN_VALUE(p_FmMacParam, E_NULL_POINTER, NULL);
3304 +
3305 + baseAddr = p_FmMacParam->baseAddr;
3306 +
3307 + /* allocate memory for the UCC GETH data structure. */
3308 + p_Dtsec = (t_Dtsec *)XX_Malloc(sizeof(t_Dtsec));
3309 + if (!p_Dtsec)
3310 + {
3311 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("dTSEC driver structure"));
3312 + return NULL;
3313 + }
3314 + memset(p_Dtsec, 0, sizeof(t_Dtsec));
3315 + InitFmMacControllerDriver(&p_Dtsec->fmMacControllerDriver);
3316 +
3317 + /* allocate memory for the dTSEC driver parameters data structure. */
3318 + p_DtsecDriverParam = (struct dtsec_cfg *) XX_Malloc(sizeof(struct dtsec_cfg));
3319 + if (!p_DtsecDriverParam)
3320 + {
3321 + XX_Free(p_Dtsec);
3322 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("dTSEC driver parameters"));
3323 + return NULL;
3324 + }
3325 + memset(p_DtsecDriverParam, 0, sizeof(struct dtsec_cfg));
3326 +
3327 + /* Plant parameter structure pointer */
3328 + p_Dtsec->p_DtsecDriverParam = p_DtsecDriverParam;
3329 +
3330 + fman_dtsec_defconfig(p_DtsecDriverParam);
3331 +
3332 + p_Dtsec->p_MemMap = (struct dtsec_regs *)UINT_TO_PTR(baseAddr);
3333 + p_Dtsec->p_MiiMemMap = (struct dtsec_mii_reg *)UINT_TO_PTR(baseAddr + DTSEC_TO_MII_OFFSET);
3334 + p_Dtsec->addr = ENET_ADDR_TO_UINT64(p_FmMacParam->addr);
3335 + p_Dtsec->enetMode = p_FmMacParam->enetMode;
3336 + p_Dtsec->macId = p_FmMacParam->macId;
3337 + p_Dtsec->exceptions = DEFAULT_exceptions;
3338 + p_Dtsec->mdioIrq = p_FmMacParam->mdioIrq;
3339 + p_Dtsec->f_Exception = p_FmMacParam->f_Exception;
3340 + p_Dtsec->f_Event = p_FmMacParam->f_Event;
3341 + p_Dtsec->h_App = p_FmMacParam->h_App;
3342 + p_Dtsec->ptpTsuEnabled = p_Dtsec->p_DtsecDriverParam->ptp_tsu_en;
3343 + p_Dtsec->enTsuErrExeption = p_Dtsec->p_DtsecDriverParam->ptp_exception_en;
3344 + p_Dtsec->tbi_phy_addr = p_Dtsec->p_DtsecDriverParam->tbi_phy_addr;
3345 +
3346 + return p_Dtsec;
3347 +}
3348 --- /dev/null
3349 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.h
3350 @@ -0,0 +1,228 @@
3351 +/*
3352 + * Copyright 2008-2013 Freescale Semiconductor Inc.
3353 + *
3354 + * Redistribution and use in source and binary forms, with or without
3355 + * modification, are permitted provided that the following conditions are met:
3356 + * * Redistributions of source code must retain the above copyright
3357 + * notice, this list of conditions and the following disclaimer.
3358 + * * Redistributions in binary form must reproduce the above copyright
3359 + * notice, this list of conditions and the following disclaimer in the
3360 + * documentation and/or other materials provided with the distribution.
3361 + * * Neither the name of Freescale Semiconductor nor the
3362 + * names of its contributors may be used to endorse or promote products
3363 + * derived from this software without specific prior written permission.
3364 + *
3365 + *
3366 + * ALTERNATIVELY, this software may be distributed under the terms of the
3367 + * GNU General Public License ("GPL") as published by the Free Software
3368 + * Foundation, either version 2 of that License or (at your option) any
3369 + * later version.
3370 + *
3371 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
3372 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3373 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3374 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
3375 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
3376 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
3377 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3378 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3379 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3380 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3381 + */
3382 +
3383 +/******************************************************************************
3384 + @File dtsec.h
3385 +
3386 + @Description FM dTSEC ...
3387 +*//***************************************************************************/
3388 +#ifndef __DTSEC_H
3389 +#define __DTSEC_H
3390 +
3391 +#include "std_ext.h"
3392 +#include "error_ext.h"
3393 +#include "list_ext.h"
3394 +#include "enet_ext.h"
3395 +
3396 +#include "dtsec_mii_acc.h"
3397 +#include "fm_mac.h"
3398 +
3399 +
3400 +#define DEFAULT_exceptions \
3401 + ((uint32_t)(DTSEC_IMASK_BREN | \
3402 + DTSEC_IMASK_RXCEN | \
3403 + DTSEC_IMASK_BTEN | \
3404 + DTSEC_IMASK_TXCEN | \
3405 + DTSEC_IMASK_TXEEN | \
3406 + DTSEC_IMASK_ABRTEN | \
3407 + DTSEC_IMASK_LCEN | \
3408 + DTSEC_IMASK_CRLEN | \
3409 + DTSEC_IMASK_XFUNEN | \
3410 + DTSEC_IMASK_IFERREN | \
3411 + DTSEC_IMASK_MAGEN | \
3412 + DTSEC_IMASK_TDPEEN | \
3413 + DTSEC_IMASK_RDPEEN))
3414 +
3415 +#define GET_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \
3416 + case e_FM_MAC_EX_1G_BAB_RX: \
3417 + bitMask = DTSEC_IMASK_BREN; break; \
3418 + case e_FM_MAC_EX_1G_RX_CTL: \
3419 + bitMask = DTSEC_IMASK_RXCEN; break; \
3420 + case e_FM_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET: \
3421 + bitMask = DTSEC_IMASK_GTSCEN ; break; \
3422 + case e_FM_MAC_EX_1G_BAB_TX: \
3423 + bitMask = DTSEC_IMASK_BTEN ; break; \
3424 + case e_FM_MAC_EX_1G_TX_CTL: \
3425 + bitMask = DTSEC_IMASK_TXCEN ; break; \
3426 + case e_FM_MAC_EX_1G_TX_ERR: \
3427 + bitMask = DTSEC_IMASK_TXEEN ; break; \
3428 + case e_FM_MAC_EX_1G_LATE_COL: \
3429 + bitMask = DTSEC_IMASK_LCEN ; break; \
3430 + case e_FM_MAC_EX_1G_COL_RET_LMT: \
3431 + bitMask = DTSEC_IMASK_CRLEN ; break; \
3432 + case e_FM_MAC_EX_1G_TX_FIFO_UNDRN: \
3433 + bitMask = DTSEC_IMASK_XFUNEN ; break; \
3434 + case e_FM_MAC_EX_1G_MAG_PCKT: \
3435 + bitMask = DTSEC_IMASK_MAGEN ; break; \
3436 + case e_FM_MAC_EX_1G_MII_MNG_RD_COMPLET: \
3437 + bitMask = DTSEC_IMASK_MMRDEN; break; \
3438 + case e_FM_MAC_EX_1G_MII_MNG_WR_COMPLET: \
3439 + bitMask = DTSEC_IMASK_MMWREN ; break; \
3440 + case e_FM_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET: \
3441 + bitMask = DTSEC_IMASK_GRSCEN; break; \
3442 + case e_FM_MAC_EX_1G_TX_DATA_ERR: \
3443 + bitMask = DTSEC_IMASK_TDPEEN; break; \
3444 + case e_FM_MAC_EX_1G_RX_MIB_CNT_OVFL: \
3445 + bitMask = DTSEC_IMASK_MSROEN ; break; \
3446 + default: bitMask = 0;break;}
3447 +
3448 +
3449 +#define MAX_PACKET_ALIGNMENT 31
3450 +#define MAX_INTER_PACKET_GAP 0x7f
3451 +#define MAX_INTER_PALTERNATE_BEB 0x0f
3452 +#define MAX_RETRANSMISSION 0x0f
3453 +#define MAX_COLLISION_WINDOW 0x03ff
3454 +
3455 +
3456 +/********************* From mac ext ******************************************/
3457 +typedef uint32_t t_ErrorDisable;
3458 +
3459 +#define ERROR_DISABLE_TRANSMIT 0x00400000
3460 +#define ERROR_DISABLE_LATE_COLLISION 0x00040000
3461 +#define ERROR_DISABLE_COLLISION_RETRY_LIMIT 0x00020000
3462 +#define ERROR_DISABLE_TxFIFO_UNDERRUN 0x00010000
3463 +#define ERROR_DISABLE_TxABORT 0x00008000
3464 +#define ERROR_DISABLE_INTERFACE 0x00004000
3465 +#define ERROR_DISABLE_TxDATA_PARITY 0x00000002
3466 +#define ERROR_DISABLE_RxDATA_PARITY 0x00000001
3467 +
3468 +/*****************************************************************************/
3469 +#define DTSEC_NUM_OF_PADDRS 15 /* number of pattern match registers (entries) */
3470 +
3471 +#define GROUP_ADDRESS 0x0000010000000000LL /* Group address bit indication */
3472 +
3473 +#define HASH_TABLE_SIZE 256 /* Hash table size (= 32 bits * 8 regs) */
3474 +
3475 +#define HASH_TABLE_SIZE 256 /* Hash table size (32 bits * 8 regs) */
3476 +#define EXTENDED_HASH_TABLE_SIZE 512 /* Extended Hash table size (32 bits * 16 regs) */
3477 +
3478 +#define DTSEC_TO_MII_OFFSET 0x1000 /* number of pattern match registers (entries) */
3479 +
3480 +#define MAX_PHYS 32 /* maximum number of phys */
3481 +
3482 +#define VAL32BIT 0x100000000LL
3483 +#define VAL22BIT 0x00400000
3484 +#define VAL16BIT 0x00010000
3485 +#define VAL12BIT 0x00001000
3486 +
3487 +/* CAR1/2 bits */
3488 +#define CAR1_TR64 0x80000000
3489 +#define CAR1_TR127 0x40000000
3490 +#define CAR1_TR255 0x20000000
3491 +#define CAR1_TR511 0x10000000
3492 +#define CAR1_TRK1 0x08000000
3493 +#define CAR1_TRMAX 0x04000000
3494 +#define CAR1_TRMGV 0x02000000
3495 +
3496 +#define CAR1_RBYT 0x00010000
3497 +#define CAR1_RPKT 0x00008000
3498 +#define CAR1_RMCA 0x00002000
3499 +#define CAR1_RBCA 0x00001000
3500 +#define CAR1_RXPF 0x00000400
3501 +#define CAR1_RALN 0x00000100
3502 +#define CAR1_RFLR 0x00000080
3503 +#define CAR1_RCDE 0x00000040
3504 +#define CAR1_RCSE 0x00000020
3505 +#define CAR1_RUND 0x00000010
3506 +#define CAR1_ROVR 0x00000008
3507 +#define CAR1_RFRG 0x00000004
3508 +#define CAR1_RJBR 0x00000002
3509 +#define CAR1_RDRP 0x00000001
3510 +
3511 +#define CAR2_TFCS 0x00040000
3512 +#define CAR2_TBYT 0x00002000
3513 +#define CAR2_TPKT 0x00001000
3514 +#define CAR2_TMCA 0x00000800
3515 +#define CAR2_TBCA 0x00000400
3516 +#define CAR2_TXPF 0x00000200
3517 +#define CAR2_TDRP 0x00000001
3518 +
3519 +typedef struct t_InternalStatistics
3520 +{
3521 + uint64_t tr64;
3522 + uint64_t tr127;
3523 + uint64_t tr255;
3524 + uint64_t tr511;
3525 + uint64_t tr1k;
3526 + uint64_t trmax;
3527 + uint64_t trmgv;
3528 + uint64_t rfrg;
3529 + uint64_t rjbr;
3530 + uint64_t rdrp;
3531 + uint64_t raln;
3532 + uint64_t rund;
3533 + uint64_t rovr;
3534 + uint64_t rxpf;
3535 + uint64_t txpf;
3536 + uint64_t rbyt;
3537 + uint64_t rpkt;
3538 + uint64_t rmca;
3539 + uint64_t rbca;
3540 + uint64_t rflr;
3541 + uint64_t rcde;
3542 + uint64_t rcse;
3543 + uint64_t tbyt;
3544 + uint64_t tpkt;
3545 + uint64_t tmca;
3546 + uint64_t tbca;
3547 + uint64_t tdrp;
3548 + uint64_t tfcs;
3549 +} t_InternalStatistics;
3550 +
3551 +typedef struct {
3552 + t_FmMacControllerDriver fmMacControllerDriver;
3553 + t_Handle h_App; /**< Handle to the upper layer application */
3554 + struct dtsec_regs *p_MemMap; /**< pointer to dTSEC memory mapped registers. */
3555 + struct dtsec_mii_reg *p_MiiMemMap; /**< pointer to dTSEC MII memory mapped registers. */
3556 + uint64_t addr; /**< MAC address of device; */
3557 + e_EnetMode enetMode; /**< Ethernet physical interface */
3558 + t_FmMacExceptionCallback *f_Exception;
3559 + int mdioIrq;
3560 + t_FmMacExceptionCallback *f_Event;
3561 + bool indAddrRegUsed[DTSEC_NUM_OF_PADDRS]; /**< Whether a particular individual address recognition register is being used */
3562 + uint64_t paddr[DTSEC_NUM_OF_PADDRS]; /**< MAC address for particular individual address recognition register */
3563 + uint8_t numOfIndAddrInRegs; /**< Number of individual addresses in registers for this station. */
3564 + bool halfDuplex;
3565 + t_InternalStatistics internalStatistics;
3566 + t_EthHash *p_MulticastAddrHash; /* pointer to driver's global address hash table */
3567 + t_EthHash *p_UnicastAddrHash; /* pointer to driver's individual address hash table */
3568 + uint8_t macId;
3569 + uint8_t tbi_phy_addr;
3570 + uint32_t exceptions;
3571 + bool ptpTsuEnabled;
3572 + bool enTsuErrExeption;
3573 + e_FmMacStatisticsLevel statisticsLevel;
3574 + struct dtsec_cfg *p_DtsecDriverParam;
3575 +} t_Dtsec;
3576 +
3577 +
3578 +#endif /* __DTSEC_H */
3579 --- /dev/null
3580 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec_mii_acc.c
3581 @@ -0,0 +1,97 @@
3582 +/*
3583 + * Copyright 2008-2013 Freescale Semiconductor Inc.
3584 + *
3585 + * Redistribution and use in source and binary forms, with or without
3586 + * modification, are permitted provided that the following conditions are met:
3587 + * * Redistributions of source code must retain the above copyright
3588 + * notice, this list of conditions and the following disclaimer.
3589 + * * Redistributions in binary form must reproduce the above copyright
3590 + * notice, this list of conditions and the following disclaimer in the
3591 + * documentation and/or other materials provided with the distribution.
3592 + * * Neither the name of Freescale Semiconductor nor the
3593 + * names of its contributors may be used to endorse or promote products
3594 + * derived from this software without specific prior written permission.
3595 + *
3596 + *
3597 + * ALTERNATIVELY, this software may be distributed under the terms of the
3598 + * GNU General Public License ("GPL") as published by the Free Software
3599 + * Foundation, either version 2 of that License or (at your option) any
3600 + * later version.
3601 + *
3602 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
3603 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3604 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3605 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
3606 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
3607 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
3608 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3609 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3610 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3611 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3612 + */
3613 +
3614 +
3615 +/******************************************************************************
3616 + @File dtsec_mii_acc.c
3617 +
3618 + @Description FM dtsec MII register access MAC ...
3619 +*//***************************************************************************/
3620 +
3621 +#include "error_ext.h"
3622 +#include "std_ext.h"
3623 +#include "fm_mac.h"
3624 +#include "dtsec.h"
3625 +#include "fsl_fman_dtsec_mii_acc.h"
3626 +
3627 +
3628 +/*****************************************************************************/
3629 +t_Error DTSEC_MII_WritePhyReg(t_Handle h_Dtsec,
3630 + uint8_t phyAddr,
3631 + uint8_t reg,
3632 + uint16_t data)
3633 +{
3634 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
3635 + struct dtsec_mii_reg *miiregs;
3636 + uint16_t dtsec_freq;
3637 + t_Error err;
3638 +
3639 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
3640 + SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MiiMemMap, E_INVALID_HANDLE);
3641 +
3642 + dtsec_freq = (uint16_t)(p_Dtsec->fmMacControllerDriver.clkFreq >> 1);
3643 + miiregs = p_Dtsec->p_MiiMemMap;
3644 +
3645 + err = (t_Error)fman_dtsec_mii_write_reg(miiregs, phyAddr, reg, data, dtsec_freq);
3646 +
3647 + return err;
3648 +}
3649 +
3650 +/*****************************************************************************/
3651 +t_Error DTSEC_MII_ReadPhyReg(t_Handle h_Dtsec,
3652 + uint8_t phyAddr,
3653 + uint8_t reg,
3654 + uint16_t *p_Data)
3655 +{
3656 + t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
3657 + struct dtsec_mii_reg *miiregs;
3658 + uint16_t dtsec_freq;
3659 + t_Error err;
3660 +
3661 + SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
3662 + SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MiiMemMap, E_INVALID_HANDLE);
3663 +
3664 + dtsec_freq = (uint16_t)(p_Dtsec->fmMacControllerDriver.clkFreq >> 1);
3665 + miiregs = p_Dtsec->p_MiiMemMap;
3666 +
3667 + err = fman_dtsec_mii_read_reg(miiregs, phyAddr, reg, p_Data, dtsec_freq);
3668 +
3669 + if (*p_Data == 0xffff)
3670 + RETURN_ERROR(MINOR, E_NO_DEVICE,
3671 + ("Read wrong data (0xffff): phyAddr 0x%x, reg 0x%x",
3672 + phyAddr, reg));
3673 + if (err)
3674 + RETURN_ERROR(MINOR, (t_Error)err, NO_MSG);
3675 +
3676 + return E_OK;
3677 +}
3678 +
3679 --- /dev/null
3680 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec_mii_acc.h
3681 @@ -0,0 +1,42 @@
3682 +/*
3683 + * Copyright 2008-2013 Freescale Semiconductor Inc.
3684 + *
3685 + * Redistribution and use in source and binary forms, with or without
3686 + * modification, are permitted provided that the following conditions are met:
3687 + * * Redistributions of source code must retain the above copyright
3688 + * notice, this list of conditions and the following disclaimer.
3689 + * * Redistributions in binary form must reproduce the above copyright
3690 + * notice, this list of conditions and the following disclaimer in the
3691 + * documentation and/or other materials provided with the distribution.
3692 + * * Neither the name of Freescale Semiconductor nor the
3693 + * names of its contributors may be used to endorse or promote products
3694 + * derived from this software without specific prior written permission.
3695 + *
3696 + *
3697 + * ALTERNATIVELY, this software may be distributed under the terms of the
3698 + * GNU General Public License ("GPL") as published by the Free Software
3699 + * Foundation, either version 2 of that License or (at your option) any
3700 + * later version.
3701 + *
3702 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
3703 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3704 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3705 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
3706 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
3707 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
3708 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3709 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3710 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3711 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3712 + */
3713 +
3714 +#ifndef __DTSEC_MII_ACC_H
3715 +#define __DTSEC_MII_ACC_H
3716 +
3717 +#include "std_ext.h"
3718 +
3719 +
3720 +t_Error DTSEC_MII_WritePhyReg(t_Handle h_Dtsec, uint8_t phyAddr, uint8_t reg, uint16_t data);
3721 +t_Error DTSEC_MII_ReadPhyReg(t_Handle h_Dtsec, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);
3722 +
3723 +#endif /* __DTSEC_MII_ACC_H */
3724 --- /dev/null
3725 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c
3726 @@ -0,0 +1,646 @@
3727 +/*
3728 + * Copyright 2008-2012 Freescale Semiconductor Inc.
3729 + *
3730 + * Redistribution and use in source and binary forms, with or without
3731 + * modification, are permitted provided that the following conditions are met:
3732 + * * Redistributions of source code must retain the above copyright
3733 + * notice, this list of conditions and the following disclaimer.
3734 + * * Redistributions in binary form must reproduce the above copyright
3735 + * notice, this list of conditions and the following disclaimer in the
3736 + * documentation and/or other materials provided with the distribution.
3737 + * * Neither the name of Freescale Semiconductor nor the
3738 + * names of its contributors may be used to endorse or promote products
3739 + * derived from this software without specific prior written permission.
3740 + *
3741 + *
3742 + * ALTERNATIVELY, this software may be distributed under the terms of the
3743 + * GNU General Public License ("GPL") as published by the Free Software
3744 + * Foundation, either version 2 of that License or (at your option) any
3745 + * later version.
3746 + *
3747 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
3748 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3749 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3750 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
3751 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
3752 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
3753 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3754 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3755 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3756 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3757 + */
3758 +
3759 +
3760 +/******************************************************************************
3761 + @File fm_mac.c
3762 +
3763 + @Description FM MAC ...
3764 +*//***************************************************************************/
3765 +#include "std_ext.h"
3766 +#include "string_ext.h"
3767 +#include "sprint_ext.h"
3768 +#include "error_ext.h"
3769 +#include "fm_ext.h"
3770 +
3771 +#include "fm_common.h"
3772 +#include "fm_mac.h"
3773 +
3774 +
3775 +/* ......................................................................... */
3776 +
3777 +t_Handle FM_MAC_Config (t_FmMacParams *p_FmMacParam)
3778 +{
3779 + t_FmMacControllerDriver *p_FmMacControllerDriver;
3780 + uint16_t fmClkFreq;
3781 +
3782 + SANITY_CHECK_RETURN_VALUE(p_FmMacParam, E_INVALID_HANDLE, NULL);
3783 +
3784 + fmClkFreq = FmGetClockFreq(p_FmMacParam->h_Fm);
3785 + if (fmClkFreq == 0)
3786 + {
3787 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Can't get clock for MAC!"));
3788 + return NULL;
3789 + }
3790 +
3791 +#if (DPAA_VERSION == 10)
3792 + if (ENET_SPEED_FROM_MODE(p_FmMacParam->enetMode) < e_ENET_SPEED_10000)
3793 + p_FmMacControllerDriver = (t_FmMacControllerDriver *)DTSEC_Config(p_FmMacParam);
3794 + else
3795 +#if FM_MAX_NUM_OF_10G_MACS > 0
3796 + p_FmMacControllerDriver = (t_FmMacControllerDriver *)TGEC_Config(p_FmMacParam);
3797 +#else
3798 + p_FmMacControllerDriver = NULL;
3799 +#endif /* FM_MAX_NUM_OF_10G_MACS > 0 */
3800 +#else
3801 + p_FmMacControllerDriver = (t_FmMacControllerDriver *)MEMAC_Config(p_FmMacParam);
3802 +#endif /* (DPAA_VERSION == 10) */
3803 +
3804 + if (!p_FmMacControllerDriver)
3805 + return NULL;
3806 +
3807 + p_FmMacControllerDriver->h_Fm = p_FmMacParam->h_Fm;
3808 + p_FmMacControllerDriver->enetMode = p_FmMacParam->enetMode;
3809 + p_FmMacControllerDriver->macId = p_FmMacParam->macId;
3810 + p_FmMacControllerDriver->resetOnInit = DEFAULT_resetOnInit;
3811 +
3812 + p_FmMacControllerDriver->clkFreq = fmClkFreq;
3813 +
3814 + return (t_Handle)p_FmMacControllerDriver;
3815 +}
3816 +
3817 +/* ......................................................................... */
3818 +
3819 +t_Error FM_MAC_Init (t_Handle h_FmMac)
3820 +{
3821 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
3822 +
3823 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
3824 +
3825 + if (p_FmMacControllerDriver->resetOnInit &&
3826 + !p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit &&
3827 + (FmResetMac(p_FmMacControllerDriver->h_Fm,
3828 + ((ENET_INTERFACE_FROM_MODE(p_FmMacControllerDriver->enetMode) == e_ENET_IF_XGMII) ?
3829 + e_FM_MAC_10G : e_FM_MAC_1G),
3830 + p_FmMacControllerDriver->macId) != E_OK))
3831 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Can't reset MAC!"));
3832 +
3833 + if (p_FmMacControllerDriver->f_FM_MAC_Init)
3834 + return p_FmMacControllerDriver->f_FM_MAC_Init(h_FmMac);
3835 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
3836 +}
3837 +
3838 +/* ......................................................................... */
3839 +
3840 +t_Error FM_MAC_Free (t_Handle h_FmMac)
3841 +{
3842 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
3843 +
3844 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
3845 +
3846 + if (p_FmMacControllerDriver->f_FM_MAC_Free)
3847 + return p_FmMacControllerDriver->f_FM_MAC_Free(h_FmMac);
3848 +
3849 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
3850 +}
3851 +
3852 +/* ......................................................................... */
3853 +
3854 +t_Error FM_MAC_ConfigResetOnInit (t_Handle h_FmMac, bool enable)
3855 +{
3856 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
3857 +
3858 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
3859 +
3860 + if (p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit)
3861 + return p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit(h_FmMac, enable);
3862 +
3863 + p_FmMacControllerDriver->resetOnInit = enable;
3864 +
3865 + return E_OK;
3866 +}
3867 +
3868 +/* ......................................................................... */
3869 +
3870 +t_Error FM_MAC_ConfigLoopback (t_Handle h_FmMac, bool newVal)
3871 +{
3872 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
3873 +
3874 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
3875 +
3876 + if (p_FmMacControllerDriver->f_FM_MAC_ConfigLoopback)
3877 + return p_FmMacControllerDriver->f_FM_MAC_ConfigLoopback(h_FmMac, newVal);
3878 +
3879 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
3880 +}
3881 +
3882 +/* ......................................................................... */
3883 +
3884 +t_Error FM_MAC_ConfigMaxFrameLength (t_Handle h_FmMac, uint16_t newVal)
3885 +{
3886 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
3887 +
3888 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
3889 +
3890 + if (p_FmMacControllerDriver->f_FM_MAC_ConfigMaxFrameLength)
3891 + return p_FmMacControllerDriver->f_FM_MAC_ConfigMaxFrameLength(h_FmMac, newVal);
3892 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
3893 +}
3894 +
3895 +/* ......................................................................... */
3896 +
3897 +t_Error FM_MAC_ConfigWan (t_Handle h_FmMac, bool flag)
3898 +{
3899 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
3900 +
3901 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
3902 +
3903 + if (p_FmMacControllerDriver->f_FM_MAC_ConfigWan)
3904 + return p_FmMacControllerDriver->f_FM_MAC_ConfigWan(h_FmMac, flag);
3905 +
3906 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
3907 +}
3908 +
3909 +/* ......................................................................... */
3910 +
3911 +t_Error FM_MAC_ConfigPadAndCrc (t_Handle h_FmMac, bool newVal)
3912 +{
3913 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
3914 +
3915 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
3916 +
3917 + if (p_FmMacControllerDriver->f_FM_MAC_ConfigPadAndCrc)
3918 + return p_FmMacControllerDriver->f_FM_MAC_ConfigPadAndCrc(h_FmMac, newVal);
3919 +
3920 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
3921 +}
3922 +
3923 +/* ......................................................................... */
3924 +
3925 +t_Error FM_MAC_ConfigHalfDuplex (t_Handle h_FmMac, bool newVal)
3926 +{
3927 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
3928 +
3929 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
3930 +
3931 + if (p_FmMacControllerDriver->f_FM_MAC_ConfigHalfDuplex)
3932 + return p_FmMacControllerDriver->f_FM_MAC_ConfigHalfDuplex(h_FmMac,newVal);
3933 +
3934 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
3935 +}
3936 +
3937 +/* ......................................................................... */
3938 +
3939 +t_Error FM_MAC_ConfigTbiPhyAddr (t_Handle h_FmMac, uint8_t newVal)
3940 +{
3941 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
3942 +
3943 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
3944 +
3945 + if (p_FmMacControllerDriver->f_FM_MAC_ConfigTbiPhyAddr)
3946 + return p_FmMacControllerDriver->f_FM_MAC_ConfigTbiPhyAddr(h_FmMac,newVal);
3947 +
3948 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
3949 +}
3950 +
3951 +/* ......................................................................... */
3952 +
3953 +t_Error FM_MAC_ConfigLengthCheck (t_Handle h_FmMac, bool newVal)
3954 +{
3955 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
3956 +
3957 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
3958 +
3959 + if (p_FmMacControllerDriver->f_FM_MAC_ConfigLengthCheck)
3960 + return p_FmMacControllerDriver->f_FM_MAC_ConfigLengthCheck(h_FmMac,newVal);
3961 +
3962 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
3963 +}
3964 +
3965 +/* ......................................................................... */
3966 +
3967 +t_Error FM_MAC_ConfigException (t_Handle h_FmMac, e_FmMacExceptions ex, bool enable)
3968 +{
3969 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
3970 +
3971 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
3972 +
3973 + if (p_FmMacControllerDriver->f_FM_MAC_ConfigException)
3974 + return p_FmMacControllerDriver->f_FM_MAC_ConfigException(h_FmMac, ex, enable);
3975 +
3976 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
3977 +}
3978 +
3979 +#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
3980 +/* ......................................................................... */
3981 +
3982 +t_Error FM_MAC_ConfigSkipFman11Workaround (t_Handle h_FmMac)
3983 +{
3984 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
3985 +
3986 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
3987 +
3988 + if (p_FmMacControllerDriver->f_FM_MAC_ConfigSkipFman11Workaround)
3989 + return p_FmMacControllerDriver->f_FM_MAC_ConfigSkipFman11Workaround(h_FmMac);
3990 +
3991 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
3992 +}
3993 +#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
3994 +
3995 +
3996 +/*****************************************************************************/
3997 +/* Run Time Control */
3998 +/*****************************************************************************/
3999 +
4000 +/* ......................................................................... */
4001 +
4002 +t_Error FM_MAC_Enable (t_Handle h_FmMac, e_CommMode mode)
4003 +{
4004 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4005 +
4006 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4007 +
4008 + if (p_FmMacControllerDriver->f_FM_MAC_Enable)
4009 + return p_FmMacControllerDriver->f_FM_MAC_Enable(h_FmMac, mode);
4010 +
4011 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4012 +}
4013 +
4014 +/* ......................................................................... */
4015 +
4016 +t_Error FM_MAC_Disable (t_Handle h_FmMac, e_CommMode mode)
4017 +{
4018 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4019 +
4020 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4021 +
4022 + if (p_FmMacControllerDriver->f_FM_MAC_Disable)
4023 + return p_FmMacControllerDriver->f_FM_MAC_Disable(h_FmMac, mode);
4024 +
4025 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4026 +}
4027 +
4028 +/* ......................................................................... */
4029 +
4030 +t_Error FM_MAC_Enable1588TimeStamp (t_Handle h_FmMac)
4031 +{
4032 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4033 +
4034 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4035 +
4036 + if (p_FmMacControllerDriver->f_FM_MAC_Enable1588TimeStamp)
4037 + return p_FmMacControllerDriver->f_FM_MAC_Enable1588TimeStamp(h_FmMac);
4038 +
4039 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4040 +}
4041 +
4042 +/* ......................................................................... */
4043 +
4044 +t_Error FM_MAC_Disable1588TimeStamp (t_Handle h_FmMac)
4045 +{
4046 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4047 +
4048 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4049 +
4050 + if (p_FmMacControllerDriver->f_FM_MAC_Disable1588TimeStamp)
4051 + return p_FmMacControllerDriver->f_FM_MAC_Disable1588TimeStamp(h_FmMac);
4052 +
4053 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4054 +}
4055 +
4056 +/* ......................................................................... */
4057 +
4058 +t_Error FM_MAC_SetTxAutoPauseFrames(t_Handle h_FmMac,
4059 + uint16_t pauseTime)
4060 +{
4061 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4062 +
4063 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4064 +
4065 + if (p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames)
4066 + return p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames(h_FmMac,
4067 + pauseTime);
4068 +
4069 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4070 +}
4071 +
4072 +/* ......................................................................... */
4073 +
4074 +t_Error FM_MAC_SetTxPauseFrames(t_Handle h_FmMac,
4075 + uint8_t priority,
4076 + uint16_t pauseTime,
4077 + uint16_t threshTime)
4078 +{
4079 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4080 +
4081 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4082 +
4083 + if (p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames)
4084 + return p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames(h_FmMac,
4085 + priority,
4086 + pauseTime,
4087 + threshTime);
4088 +
4089 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, NO_MSG);
4090 +}
4091 +
4092 +/* ......................................................................... */
4093 +
4094 +t_Error FM_MAC_SetRxIgnorePauseFrames (t_Handle h_FmMac, bool en)
4095 +{
4096 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4097 +
4098 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4099 +
4100 + if (p_FmMacControllerDriver->f_FM_MAC_SetRxIgnorePauseFrames)
4101 + return p_FmMacControllerDriver->f_FM_MAC_SetRxIgnorePauseFrames(h_FmMac, en);
4102 +
4103 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4104 +}
4105 +
4106 +/* ......................................................................... */
4107 +
4108 +t_Error FM_MAC_SetWakeOnLan (t_Handle h_FmMac, bool en)
4109 +{
4110 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4111 +
4112 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4113 +
4114 + if (p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan)
4115 + return p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan(h_FmMac, en);
4116 +
4117 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4118 +}
4119 +
4120 +/* ......................................................................... */
4121 +
4122 +t_Error FM_MAC_ResetCounters (t_Handle h_FmMac)
4123 +{
4124 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4125 +
4126 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4127 +
4128 + if (p_FmMacControllerDriver->f_FM_MAC_ResetCounters)
4129 + return p_FmMacControllerDriver->f_FM_MAC_ResetCounters(h_FmMac);
4130 +
4131 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4132 +}
4133 +
4134 +/* ......................................................................... */
4135 +
4136 +t_Error FM_MAC_SetException(t_Handle h_FmMac, e_FmMacExceptions ex, bool enable)
4137 +{
4138 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4139 +
4140 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4141 +
4142 + if (p_FmMacControllerDriver->f_FM_MAC_SetException)
4143 + return p_FmMacControllerDriver->f_FM_MAC_SetException(h_FmMac, ex, enable);
4144 +
4145 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4146 +}
4147 +
4148 +/* ......................................................................... */
4149 +
4150 +t_Error FM_MAC_SetStatistics (t_Handle h_FmMac, e_FmMacStatisticsLevel statisticsLevel)
4151 +{
4152 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4153 +
4154 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4155 +
4156 + if (p_FmMacControllerDriver->f_FM_MAC_SetStatistics)
4157 + return p_FmMacControllerDriver->f_FM_MAC_SetStatistics(h_FmMac, statisticsLevel);
4158 +
4159 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4160 +}
4161 +
4162 +/* ......................................................................... */
4163 +
4164 +t_Error FM_MAC_GetStatistics (t_Handle h_FmMac, t_FmMacStatistics *p_Statistics)
4165 +{
4166 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4167 +
4168 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4169 +
4170 + if (p_FmMacControllerDriver->f_FM_MAC_GetStatistics)
4171 + return p_FmMacControllerDriver->f_FM_MAC_GetStatistics(h_FmMac, p_Statistics);
4172 +
4173 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4174 +}
4175 +
4176 +/* ......................................................................... */
4177 +
4178 +t_Error FM_MAC_ModifyMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
4179 +{
4180 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4181 +
4182 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4183 +
4184 + if (p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr)
4185 + return p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr(h_FmMac, p_EnetAddr);
4186 +
4187 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4188 +}
4189 +
4190 +/* ......................................................................... */
4191 +
4192 +t_Error FM_MAC_AddHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
4193 +{
4194 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4195 +
4196 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4197 +
4198 + if (p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr)
4199 + return p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr(h_FmMac, p_EnetAddr);
4200 +
4201 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4202 +}
4203 +
4204 +/* ......................................................................... */
4205 +
4206 +t_Error FM_MAC_RemoveHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
4207 +{
4208 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4209 +
4210 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4211 +
4212 + if (p_FmMacControllerDriver->f_FM_MAC_RemoveHashMacAddr)
4213 + return p_FmMacControllerDriver->f_FM_MAC_RemoveHashMacAddr(h_FmMac, p_EnetAddr);
4214 +
4215 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4216 +}
4217 +
4218 +/* ......................................................................... */
4219 +
4220 +t_Error FM_MAC_AddExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
4221 +{
4222 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4223 +
4224 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4225 +
4226 + if (p_FmMacControllerDriver->f_FM_MAC_AddExactMatchMacAddr)
4227 + return p_FmMacControllerDriver->f_FM_MAC_AddExactMatchMacAddr(h_FmMac, p_EnetAddr);
4228 +
4229 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4230 +}
4231 +
4232 +/* ......................................................................... */
4233 +
4234 +t_Error FM_MAC_RemovelExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
4235 +{
4236 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4237 +
4238 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4239 +
4240 + if (p_FmMacControllerDriver->f_FM_MAC_RemovelExactMatchMacAddr)
4241 + return p_FmMacControllerDriver->f_FM_MAC_RemovelExactMatchMacAddr(h_FmMac, p_EnetAddr);
4242 +
4243 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4244 +}
4245 +
4246 +/* ......................................................................... */
4247 +
4248 +t_Error FM_MAC_GetVesrion (t_Handle h_FmMac, uint32_t *macVresion)
4249 +{
4250 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4251 +
4252 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4253 +
4254 + if (p_FmMacControllerDriver->f_FM_MAC_GetVersion)
4255 + return p_FmMacControllerDriver->f_FM_MAC_GetVersion(h_FmMac, macVresion);
4256 +
4257 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4258 +
4259 +}
4260 +
4261 +/* ......................................................................... */
4262 +
4263 +t_Error FM_MAC_GetId (t_Handle h_FmMac, uint32_t *macId)
4264 +{
4265 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4266 +
4267 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4268 +
4269 + if (p_FmMacControllerDriver->f_FM_MAC_GetId)
4270 + return p_FmMacControllerDriver->f_FM_MAC_GetId(h_FmMac, macId);
4271 +
4272 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4273 +}
4274 +
4275 +/* ......................................................................... */
4276 +
4277 +t_Error FM_MAC_SetPromiscuous (t_Handle h_FmMac, bool newVal)
4278 +{
4279 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4280 +
4281 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4282 +
4283 + if (p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous)
4284 + return p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous(h_FmMac, newVal);
4285 +
4286 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4287 +}
4288 +
4289 +/* ......................................................................... */
4290 +
4291 +t_Error FM_MAC_AdjustLink(t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex)
4292 +{
4293 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4294 +
4295 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4296 +
4297 + if (p_FmMacControllerDriver->f_FM_MAC_AdjustLink)
4298 + return p_FmMacControllerDriver->f_FM_MAC_AdjustLink(h_FmMac, speed, fullDuplex);
4299 +
4300 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4301 +}
4302 +
4303 +/* ......................................................................... */
4304 +
4305 +t_Error FM_MAC_RestartAutoneg(t_Handle h_FmMac)
4306 +{
4307 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4308 +
4309 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4310 +
4311 + if (p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg)
4312 + return p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg(h_FmMac);
4313 +
4314 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4315 +}
4316 +
4317 +/* ......................................................................... */
4318 +
4319 +t_Error FM_MAC_MII_WritePhyReg (t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t data)
4320 +{
4321 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4322 +
4323 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4324 +
4325 + if (p_FmMacControllerDriver->f_FM_MAC_MII_WritePhyReg)
4326 + return p_FmMacControllerDriver->f_FM_MAC_MII_WritePhyReg(h_FmMac, phyAddr, reg, data);
4327 +
4328 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4329 +}
4330 +
4331 +/* ......................................................................... */
4332 +
4333 +t_Error FM_MAC_MII_ReadPhyReg(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data)
4334 +{
4335 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4336 +
4337 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4338 +
4339 + if (p_FmMacControllerDriver->f_FM_MAC_MII_ReadPhyReg)
4340 + return p_FmMacControllerDriver->f_FM_MAC_MII_ReadPhyReg(h_FmMac, phyAddr, reg, p_Data);
4341 +
4342 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4343 +}
4344 +
4345 +/* ......................................................................... */
4346 +
4347 +uint16_t FM_MAC_GetMaxFrameLength(t_Handle h_FmMac)
4348 +{
4349 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4350 +
4351 + SANITY_CHECK_RETURN_VALUE(p_FmMacControllerDriver, E_INVALID_HANDLE, 0);
4352 +
4353 + if (p_FmMacControllerDriver->f_FM_MAC_GetMaxFrameLength)
4354 + return p_FmMacControllerDriver->f_FM_MAC_GetMaxFrameLength(h_FmMac);
4355 +
4356 + REPORT_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4357 + return 0;
4358 +}
4359 +
4360 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
4361 +/*****************************************************************************/
4362 +t_Error FM_MAC_DumpRegs(t_Handle h_FmMac)
4363 +{
4364 + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
4365 +
4366 + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
4367 +
4368 + if (p_FmMacControllerDriver->f_FM_MAC_DumpRegs)
4369 + return p_FmMacControllerDriver->f_FM_MAC_DumpRegs(h_FmMac);
4370 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
4371 +}
4372 +#endif /* (defined(DEBUG_ERRORS) && ... */
4373 --- /dev/null
4374 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h
4375 @@ -0,0 +1,224 @@
4376 +/*
4377 + * Copyright 2008-2012 Freescale Semiconductor Inc.
4378 + *
4379 + * Redistribution and use in source and binary forms, with or without
4380 + * modification, are permitted provided that the following conditions are met:
4381 + * * Redistributions of source code must retain the above copyright
4382 + * notice, this list of conditions and the following disclaimer.
4383 + * * Redistributions in binary form must reproduce the above copyright
4384 + * notice, this list of conditions and the following disclaimer in the
4385 + * documentation and/or other materials provided with the distribution.
4386 + * * Neither the name of Freescale Semiconductor nor the
4387 + * names of its contributors may be used to endorse or promote products
4388 + * derived from this software without specific prior written permission.
4389 + *
4390 + *
4391 + * ALTERNATIVELY, this software may be distributed under the terms of the
4392 + * GNU General Public License ("GPL") as published by the Free Software
4393 + * Foundation, either version 2 of that License or (at your option) any
4394 + * later version.
4395 + *
4396 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
4397 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
4398 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
4399 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
4400 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
4401 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4402 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
4403 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4404 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
4405 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4406 + */
4407 +
4408 +
4409 +/******************************************************************************
4410 + @File fm_mac.h
4411 +
4412 + @Description FM MAC ...
4413 +*//***************************************************************************/
4414 +#ifndef __FM_MAC_H
4415 +#define __FM_MAC_H
4416 +
4417 +#include "std_ext.h"
4418 +#include "error_ext.h"
4419 +#include "list_ext.h"
4420 +#include "fm_mac_ext.h"
4421 +#include "fm_common.h"
4422 +
4423 +
4424 +#define __ERR_MODULE__ MODULE_FM_MAC
4425 +
4426 +/**************************************************************************//**
4427 + @Description defaults
4428 +*//***************************************************************************/
4429 +
4430 +
4431 +#define DEFAULT_halfDuplex FALSE
4432 +#define DEFAULT_padAndCrcEnable TRUE
4433 +#define DEFAULT_resetOnInit FALSE
4434 +
4435 +
4436 +typedef struct {
4437 + uint64_t addr; /* Ethernet Address */
4438 + t_List node;
4439 +} t_EthHashEntry;
4440 +#define ETH_HASH_ENTRY_OBJ(ptr) LIST_OBJECT(ptr, t_EthHashEntry, node)
4441 +
4442 +typedef struct {
4443 + uint16_t size;
4444 + t_List *p_Lsts;
4445 +} t_EthHash;
4446 +
4447 +typedef struct {
4448 + t_Error (*f_FM_MAC_Init) (t_Handle h_FmMac);
4449 + t_Error (*f_FM_MAC_Free) (t_Handle h_FmMac);
4450 +
4451 + t_Error (*f_FM_MAC_SetStatistics) (t_Handle h_FmMac, e_FmMacStatisticsLevel statisticsLevel);
4452 + t_Error (*f_FM_MAC_ConfigLoopback) (t_Handle h_FmMac, bool newVal);
4453 + t_Error (*f_FM_MAC_ConfigMaxFrameLength) (t_Handle h_FmMac, uint16_t newVal);
4454 + t_Error (*f_FM_MAC_ConfigWan) (t_Handle h_FmMac, bool flag);
4455 + t_Error (*f_FM_MAC_ConfigPadAndCrc) (t_Handle h_FmMac, bool newVal);
4456 + t_Error (*f_FM_MAC_ConfigHalfDuplex) (t_Handle h_FmMac, bool newVal);
4457 + t_Error (*f_FM_MAC_ConfigLengthCheck) (t_Handle h_FmMac, bool newVal);
4458 + t_Error (*f_FM_MAC_ConfigTbiPhyAddr) (t_Handle h_FmMac, uint8_t newVal);
4459 + t_Error (*f_FM_MAC_ConfigException) (t_Handle h_FmMac, e_FmMacExceptions, bool enable);
4460 + t_Error (*f_FM_MAC_ConfigResetOnInit) (t_Handle h_FmMac, bool enable);
4461 +#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
4462 + t_Error (*f_FM_MAC_ConfigSkipFman11Workaround) (t_Handle h_FmMac);
4463 +#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
4464 +
4465 + t_Error (*f_FM_MAC_SetException) (t_Handle h_FmMac, e_FmMacExceptions ex, bool enable);
4466 +
4467 + t_Error (*f_FM_MAC_Enable) (t_Handle h_FmMac, e_CommMode mode);
4468 + t_Error (*f_FM_MAC_Disable) (t_Handle h_FmMac, e_CommMode mode);
4469 + t_Error (*f_FM_MAC_Enable1588TimeStamp) (t_Handle h_FmMac);
4470 + t_Error (*f_FM_MAC_Disable1588TimeStamp) (t_Handle h_FmMac);
4471 + t_Error (*f_FM_MAC_Reset) (t_Handle h_FmMac, bool wait);
4472 +
4473 + t_Error (*f_FM_MAC_SetTxAutoPauseFrames) (t_Handle h_FmMac,
4474 + uint16_t pauseTime);
4475 + t_Error (*f_FM_MAC_SetTxPauseFrames) (t_Handle h_FmMac,
4476 + uint8_t priority,
4477 + uint16_t pauseTime,
4478 + uint16_t threshTime);
4479 + t_Error (*f_FM_MAC_SetRxIgnorePauseFrames) (t_Handle h_FmMac, bool en);
4480 +
4481 + t_Error (*f_FM_MAC_ResetCounters) (t_Handle h_FmMac);
4482 + t_Error (*f_FM_MAC_GetStatistics) (t_Handle h_FmMac, t_FmMacStatistics *p_Statistics);
4483 +
4484 + t_Error (*f_FM_MAC_ModifyMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
4485 + t_Error (*f_FM_MAC_AddHashMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
4486 + t_Error (*f_FM_MAC_RemoveHashMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
4487 + t_Error (*f_FM_MAC_AddExactMatchMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
4488 + t_Error (*f_FM_MAC_RemovelExactMatchMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
4489 +
4490 + t_Error (*f_FM_MAC_SetPromiscuous) (t_Handle h_FmMac, bool newVal);
4491 + t_Error (*f_FM_MAC_AdjustLink) (t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex);
4492 + t_Error (*f_FM_MAC_RestartAutoneg) (t_Handle h_FmMac);
4493 +
4494 + t_Error (*f_FM_MAC_SetWakeOnLan) (t_Handle h_FmMac, bool en);
4495 +
4496 + t_Error (*f_FM_MAC_GetId) (t_Handle h_FmMac, uint32_t *macId);
4497 +
4498 + t_Error (*f_FM_MAC_GetVersion) (t_Handle h_FmMac, uint32_t *macVersion);
4499 +
4500 + uint16_t (*f_FM_MAC_GetMaxFrameLength) (t_Handle h_FmMac);
4501 +
4502 + t_Error (*f_FM_MAC_MII_WritePhyReg)(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t data);
4503 + t_Error (*f_FM_MAC_MII_ReadPhyReg)(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);
4504 +
4505 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
4506 + t_Error (*f_FM_MAC_DumpRegs) (t_Handle h_FmMac);
4507 +#endif /* (defined(DEBUG_ERRORS) && ... */
4508 +
4509 + t_Handle h_Fm;
4510 + t_FmRevisionInfo fmRevInfo;
4511 + e_EnetMode enetMode;
4512 + uint8_t macId;
4513 + bool resetOnInit;
4514 + uint16_t clkFreq;
4515 +} t_FmMacControllerDriver;
4516 +
4517 +
4518 +#if (DPAA_VERSION == 10)
4519 +t_Handle DTSEC_Config(t_FmMacParams *p_FmMacParam);
4520 +t_Handle TGEC_Config(t_FmMacParams *p_FmMacParams);
4521 +#else
4522 +t_Handle MEMAC_Config(t_FmMacParams *p_FmMacParam);
4523 +#endif /* (DPAA_VERSION == 10) */
4524 +uint16_t FM_MAC_GetMaxFrameLength(t_Handle FmMac);
4525 +
4526 +
4527 +/* ........................................................................... */
4528 +
4529 +static __inline__ t_EthHashEntry *DequeueAddrFromHashEntry(t_List *p_AddrLst)
4530 +{
4531 + t_EthHashEntry *p_HashEntry = NULL;
4532 + if (!LIST_IsEmpty(p_AddrLst))
4533 + {
4534 + p_HashEntry = ETH_HASH_ENTRY_OBJ(p_AddrLst->p_Next);
4535 + LIST_DelAndInit(&p_HashEntry->node);
4536 + }
4537 + return p_HashEntry;
4538 +}
4539 +
4540 +/* ........................................................................... */
4541 +
4542 +static __inline__ void FreeHashTable(t_EthHash *p_Hash)
4543 +{
4544 + t_EthHashEntry *p_HashEntry;
4545 + int i = 0;
4546 +
4547 + if (p_Hash)
4548 + {
4549 + if (p_Hash->p_Lsts)
4550 + {
4551 + for (i=0; i<p_Hash->size; i++)
4552 + {
4553 + p_HashEntry = DequeueAddrFromHashEntry(&p_Hash->p_Lsts[i]);
4554 + while (p_HashEntry)
4555 + {
4556 + XX_Free(p_HashEntry);
4557 + p_HashEntry = DequeueAddrFromHashEntry(&p_Hash->p_Lsts[i]);
4558 + }
4559 + }
4560 +
4561 + XX_Free(p_Hash->p_Lsts);
4562 + }
4563 +
4564 + XX_Free(p_Hash);
4565 + }
4566 +}
4567 +
4568 +/* ........................................................................... */
4569 +
4570 +static __inline__ t_EthHash * AllocHashTable(uint16_t size)
4571 +{
4572 + uint32_t i;
4573 + t_EthHash *p_Hash;
4574 +
4575 + /* Allocate address hash table */
4576 + p_Hash = (t_EthHash *)XX_Malloc(sizeof(t_EthHash));
4577 + if (!p_Hash)
4578 + {
4579 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Address hash table"));
4580 + return NULL;
4581 + }
4582 + p_Hash->size = size;
4583 +
4584 + p_Hash->p_Lsts = (t_List *)XX_Malloc(p_Hash->size*sizeof(t_List));
4585 + if (!p_Hash->p_Lsts)
4586 + {
4587 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Address hash table"));
4588 + XX_Free(p_Hash);
4589 + return NULL;
4590 + }
4591 +
4592 + for (i=0 ; i<p_Hash->size; i++)
4593 + INIT_LIST(&p_Hash->p_Lsts[i]);
4594 +
4595 + return p_Hash;
4596 +}
4597 +
4598 +
4599 +#endif /* __FM_MAC_H */
4600 --- /dev/null
4601 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_crc32.c
4602 @@ -0,0 +1,119 @@
4603 +/*
4604 + * Copyright 2008-2012 Freescale Semiconductor Inc.
4605 + *
4606 + * Redistribution and use in source and binary forms, with or without
4607 + * modification, are permitted provided that the following conditions are met:
4608 + * * Redistributions of source code must retain the above copyright
4609 + * notice, this list of conditions and the following disclaimer.
4610 + * * Redistributions in binary form must reproduce the above copyright
4611 + * notice, this list of conditions and the following disclaimer in the
4612 + * documentation and/or other materials provided with the distribution.
4613 + * * Neither the name of Freescale Semiconductor nor the
4614 + * names of its contributors may be used to endorse or promote products
4615 + * derived from this software without specific prior written permission.
4616 + *
4617 + *
4618 + * ALTERNATIVELY, this software may be distributed under the terms of the
4619 + * GNU General Public License ("GPL") as published by the Free Software
4620 + * Foundation, either version 2 of that License or (at your option) any
4621 + * later version.
4622 + *
4623 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
4624 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
4625 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
4626 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
4627 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
4628 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4629 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
4630 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4631 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
4632 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4633 + */
4634 +
4635 +
4636 +#include "fman_crc32.h"
4637 +#include "common/general.h"
4638 +
4639 +
4640 +/* precomputed CRC values for address hashing */
4641 +static const uint32_t crc_tbl[256] = {
4642 + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
4643 + 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
4644 + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
4645 + 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
4646 + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
4647 + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
4648 + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
4649 + 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
4650 + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
4651 + 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
4652 + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
4653 + 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
4654 + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
4655 + 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
4656 + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
4657 + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
4658 + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
4659 + 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
4660 + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
4661 + 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
4662 + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
4663 + 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
4664 + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
4665 + 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
4666 + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
4667 + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
4668 + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
4669 + 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
4670 + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
4671 + 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
4672 + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
4673 + 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
4674 + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
4675 + 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
4676 + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
4677 + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
4678 + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
4679 + 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
4680 + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
4681 + 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
4682 + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
4683 + 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
4684 + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
4685 +};
4686 +
4687 +/* Get the mirrored value of a byte size number. (0x11010011 --> 0x11001011) */
4688 +static inline uint8_t get_mirror8(uint8_t n)
4689 +{
4690 + uint8_t mirror[16] = {
4691 + 0x00, 0x08, 0x04, 0x0c, 0x02, 0x0a, 0x06, 0x0e,
4692 + 0x01, 0x09, 0x05, 0x0d, 0x03, 0x0b, 0x07, 0x0f
4693 + };
4694 + return (uint8_t)(((mirror[n & 0x0f] << 4) | (mirror[n >> 4])));
4695 +}
4696 +
4697 +static inline uint32_t get_mirror32(uint32_t n)
4698 +{
4699 + return ((uint32_t)get_mirror8((uint8_t)(n))<<24) |
4700 + ((uint32_t)get_mirror8((uint8_t)(n>>8))<<16) |
4701 + ((uint32_t)get_mirror8((uint8_t)(n>>16))<<8) |
4702 + ((uint32_t)get_mirror8((uint8_t)(n>>24)));
4703 +}
4704 +
4705 +uint32_t get_mac_addr_crc(uint64_t _addr)
4706 +{
4707 + uint32_t i;
4708 + uint8_t data;
4709 + uint32_t crc;
4710 +
4711 + /* CRC calculation */
4712 + crc = 0xffffffff;
4713 + for (i = 0; i < 6; i++) {
4714 + data = (uint8_t)(_addr >> ((5-i)*8));
4715 + crc = crc ^ data;
4716 + crc = crc_tbl[crc&0xff] ^ (crc>>8);
4717 + }
4718 +
4719 + crc = get_mirror32(crc);
4720 + return crc;
4721 +}
4722 --- /dev/null
4723 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_crc32.h
4724 @@ -0,0 +1,43 @@
4725 +/*
4726 + * Copyright 2008-2012 Freescale Semiconductor Inc.
4727 + *
4728 + * Redistribution and use in source and binary forms, with or without
4729 + * modification, are permitted provided that the following conditions are met:
4730 + * * Redistributions of source code must retain the above copyright
4731 + * notice, this list of conditions and the following disclaimer.
4732 + * * Redistributions in binary form must reproduce the above copyright
4733 + * notice, this list of conditions and the following disclaimer in the
4734 + * documentation and/or other materials provided with the distribution.
4735 + * * Neither the name of Freescale Semiconductor nor the
4736 + * names of its contributors may be used to endorse or promote products
4737 + * derived from this software without specific prior written permission.
4738 + *
4739 + *
4740 + * ALTERNATIVELY, this software may be distributed under the terms of the
4741 + * GNU General Public License ("GPL") as published by the Free Software
4742 + * Foundation, either version 2 of that License or (at your option) any
4743 + * later version.
4744 + *
4745 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
4746 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
4747 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
4748 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
4749 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
4750 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4751 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
4752 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4753 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
4754 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4755 + */
4756 +
4757 +
4758 +#ifndef __FMAN_CRC32_H
4759 +#define __FMAN_CRC32_H
4760 +
4761 +#include "common/general.h"
4762 +
4763 +
4764 +uint32_t get_mac_addr_crc(uint64_t _addr);
4765 +
4766 +
4767 +#endif /* __FMAN_CRC32_H */
4768 --- /dev/null
4769 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_dtsec.c
4770 @@ -0,0 +1,845 @@
4771 +/*
4772 + * Copyright 2008-2012 Freescale Semiconductor Inc.
4773 + *
4774 + * Redistribution and use in source and binary forms, with or without
4775 + * modification, are permitted provided that the following conditions are met:
4776 + * * Redistributions of source code must retain the above copyright
4777 + * notice, this list of conditions and the following disclaimer.
4778 + * * Redistributions in binary form must reproduce the above copyright
4779 + * notice, this list of conditions and the following disclaimer in the
4780 + * documentation and/or other materials provided with the distribution.
4781 + * * Neither the name of Freescale Semiconductor nor the
4782 + * names of its contributors may be used to endorse or promote products
4783 + * derived from this software without specific prior written permission.
4784 + *
4785 + *
4786 + * ALTERNATIVELY, this software may be distributed under the terms of the
4787 + * GNU General Public License ("GPL") as published by the Free Software
4788 + * Foundation, either version 2 of that License or (at your option) any
4789 + * later version.
4790 + *
4791 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
4792 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
4793 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
4794 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
4795 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
4796 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4797 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
4798 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4799 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
4800 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4801 + */
4802 +
4803 +
4804 +#include "fsl_fman_dtsec.h"
4805 +
4806 +
4807 +void fman_dtsec_stop_rx(struct dtsec_regs *regs)
4808 +{
4809 + /* Assert the graceful stop bit */
4810 + iowrite32be(ioread32be(&regs->rctrl) | RCTRL_GRS, &regs->rctrl);
4811 +}
4812 +
4813 +void fman_dtsec_stop_tx(struct dtsec_regs *regs)
4814 +{
4815 + /* Assert the graceful stop bit */
4816 + iowrite32be(ioread32be(&regs->tctrl) | DTSEC_TCTRL_GTS, &regs->tctrl);
4817 +}
4818 +
4819 +void fman_dtsec_start_tx(struct dtsec_regs *regs)
4820 +{
4821 + /* clear the graceful stop bit */
4822 + iowrite32be(ioread32be(&regs->tctrl) & ~DTSEC_TCTRL_GTS, &regs->tctrl);
4823 +}
4824 +
4825 +void fman_dtsec_start_rx(struct dtsec_regs *regs)
4826 +{
4827 + /* clear the graceful stop bit */
4828 + iowrite32be(ioread32be(&regs->rctrl) & ~RCTRL_GRS, &regs->rctrl);
4829 +}
4830 +
4831 +void fman_dtsec_defconfig(struct dtsec_cfg *cfg)
4832 +{
4833 + cfg->halfdup_on = DEFAULT_HALFDUP_ON;
4834 + cfg->halfdup_retransmit = DEFAULT_HALFDUP_RETRANSMIT;
4835 + cfg->halfdup_coll_window = DEFAULT_HALFDUP_COLL_WINDOW;
4836 + cfg->halfdup_excess_defer = DEFAULT_HALFDUP_EXCESS_DEFER;
4837 + cfg->halfdup_no_backoff = DEFAULT_HALFDUP_NO_BACKOFF;
4838 + cfg->halfdup_bp_no_backoff = DEFAULT_HALFDUP_BP_NO_BACKOFF;
4839 + cfg->halfdup_alt_backoff_val = DEFAULT_HALFDUP_ALT_BACKOFF_VAL;
4840 + cfg->halfdup_alt_backoff_en = DEFAULT_HALFDUP_ALT_BACKOFF_EN;
4841 + cfg->rx_drop_bcast = DEFAULT_RX_DROP_BCAST;
4842 + cfg->rx_short_frm = DEFAULT_RX_SHORT_FRM;
4843 + cfg->rx_len_check = DEFAULT_RX_LEN_CHECK;
4844 + cfg->tx_pad_crc = DEFAULT_TX_PAD_CRC;
4845 + cfg->tx_crc = DEFAULT_TX_CRC;
4846 + cfg->rx_ctrl_acc = DEFAULT_RX_CTRL_ACC;
4847 + cfg->tx_pause_time = DEFAULT_TX_PAUSE_TIME;
4848 + cfg->tbipa = DEFAULT_TBIPA; /* PHY address 0 is reserved (DPAA RM)*/
4849 + cfg->rx_prepend = DEFAULT_RX_PREPEND;
4850 + cfg->ptp_tsu_en = DEFAULT_PTP_TSU_EN;
4851 + cfg->ptp_exception_en = DEFAULT_PTP_EXCEPTION_EN;
4852 + cfg->preamble_len = DEFAULT_PREAMBLE_LEN;
4853 + cfg->rx_preamble = DEFAULT_RX_PREAMBLE;
4854 + cfg->tx_preamble = DEFAULT_TX_PREAMBLE;
4855 + cfg->loopback = DEFAULT_LOOPBACK;
4856 + cfg->rx_time_stamp_en = DEFAULT_RX_TIME_STAMP_EN;
4857 + cfg->tx_time_stamp_en = DEFAULT_TX_TIME_STAMP_EN;
4858 + cfg->rx_flow = DEFAULT_RX_FLOW;
4859 + cfg->tx_flow = DEFAULT_TX_FLOW;
4860 + cfg->rx_group_hash_exd = DEFAULT_RX_GROUP_HASH_EXD;
4861 + cfg->tx_pause_time_extd = DEFAULT_TX_PAUSE_TIME_EXTD;
4862 + cfg->rx_promisc = DEFAULT_RX_PROMISC;
4863 + cfg->non_back_to_back_ipg1 = DEFAULT_NON_BACK_TO_BACK_IPG1;
4864 + cfg->non_back_to_back_ipg2 = DEFAULT_NON_BACK_TO_BACK_IPG2;
4865 + cfg->min_ifg_enforcement = DEFAULT_MIN_IFG_ENFORCEMENT;
4866 + cfg->back_to_back_ipg = DEFAULT_BACK_TO_BACK_IPG;
4867 + cfg->maximum_frame = DEFAULT_MAXIMUM_FRAME;
4868 + cfg->tbi_phy_addr = DEFAULT_TBI_PHY_ADDR;
4869 + cfg->wake_on_lan = DEFAULT_WAKE_ON_LAN;
4870 +}
4871 +
4872 +int fman_dtsec_init(struct dtsec_regs *regs, struct dtsec_cfg *cfg,
4873 + enum enet_interface iface_mode,
4874 + enum enet_speed iface_speed,
4875 + uint8_t *macaddr,
4876 + uint8_t fm_rev_maj,
4877 + uint8_t fm_rev_min,
4878 + uint32_t exception_mask)
4879 +{
4880 + bool is_rgmii = FALSE;
4881 + bool is_sgmii = FALSE;
4882 + bool is_qsgmii = FALSE;
4883 + int i;
4884 + uint32_t tmp;
4885 +
4886 +UNUSED(fm_rev_maj);UNUSED(fm_rev_min);
4887 +
4888 + /* let's start with a soft reset */
4889 + iowrite32be(MACCFG1_SOFT_RESET, &regs->maccfg1);
4890 + iowrite32be(0, &regs->maccfg1);
4891 +
4892 + /*************dtsec_id2******************/
4893 + tmp = ioread32be(&regs->tsec_id2);
4894 +
4895 + /* check RGMII support */
4896 + if (iface_mode == E_ENET_IF_RGMII ||
4897 + iface_mode == E_ENET_IF_RMII)
4898 + if (tmp & DTSEC_ID2_INT_REDUCED_OFF)
4899 + return -EINVAL;
4900 +
4901 + if (iface_mode == E_ENET_IF_SGMII ||
4902 + iface_mode == E_ENET_IF_MII)
4903 + if (tmp & DTSEC_ID2_INT_REDUCED_OFF)
4904 + return -EINVAL;
4905 +
4906 + /***************ECNTRL************************/
4907 +
4908 + is_rgmii = (bool)((iface_mode == E_ENET_IF_RGMII) ? TRUE : FALSE);
4909 + is_sgmii = (bool)((iface_mode == E_ENET_IF_SGMII) ? TRUE : FALSE);
4910 + is_qsgmii = (bool)((iface_mode == E_ENET_IF_QSGMII) ? TRUE : FALSE);
4911 +
4912 + tmp = 0;
4913 + if (is_rgmii || iface_mode == E_ENET_IF_GMII)
4914 + tmp |= DTSEC_ECNTRL_GMIIM;
4915 + if (is_sgmii)
4916 + tmp |= (DTSEC_ECNTRL_SGMIIM | DTSEC_ECNTRL_TBIM);
4917 + if (is_qsgmii)
4918 + tmp |= (DTSEC_ECNTRL_SGMIIM | DTSEC_ECNTRL_TBIM |
4919 + DTSEC_ECNTRL_QSGMIIM);
4920 + if (is_rgmii)
4921 + tmp |= DTSEC_ECNTRL_RPM;
4922 + if (iface_speed == E_ENET_SPEED_100)
4923 + tmp |= DTSEC_ECNTRL_R100M;
4924 +
4925 + iowrite32be(tmp, &regs->ecntrl);
4926 + /***************ECNTRL************************/
4927 +
4928 + /***************TCTRL************************/
4929 + tmp = 0;
4930 + if (cfg->halfdup_on)
4931 + tmp |= DTSEC_TCTRL_THDF;
4932 + if (cfg->tx_time_stamp_en)
4933 + tmp |= DTSEC_TCTRL_TTSE;
4934 +
4935 + iowrite32be(tmp, &regs->tctrl);
4936 +
4937 + /***************TCTRL************************/
4938 +
4939 + /***************PTV************************/
4940 + tmp = 0;
4941 +
4942 +#ifdef FM_SHORT_PAUSE_TIME_ERRATA_DTSEC1
4943 + if ((fm_rev_maj == 1) && (fm_rev_min == 0))
4944 + cfg->tx_pause_time += 2;
4945 +#endif /* FM_SHORT_PAUSE_TIME_ERRATA_DTSEC1 */
4946 +
4947 + if (cfg->tx_pause_time)
4948 + tmp |= cfg->tx_pause_time;
4949 + if (cfg->tx_pause_time_extd)
4950 + tmp |= cfg->tx_pause_time_extd << PTV_PTE_OFST;
4951 + iowrite32be(tmp, &regs->ptv);
4952 +
4953 + /***************RCTRL************************/
4954 + tmp = 0;
4955 + tmp |= ((uint32_t)(cfg->rx_prepend & 0x0000001f)) << 16;
4956 + if (cfg->rx_ctrl_acc)
4957 + tmp |= RCTRL_CFA;
4958 + if (cfg->rx_group_hash_exd)
4959 + tmp |= RCTRL_GHTX;
4960 + if (cfg->rx_time_stamp_en)
4961 + tmp |= RCTRL_RTSE;
4962 + if (cfg->rx_drop_bcast)
4963 + tmp |= RCTRL_BC_REJ;
4964 + if (cfg->rx_short_frm)
4965 + tmp |= RCTRL_RSF;
4966 + if (cfg->rx_promisc)
4967 + tmp |= RCTRL_PROM;
4968 +
4969 + iowrite32be(tmp, &regs->rctrl);
4970 + /***************RCTRL************************/
4971 +
4972 + /*
4973 + * Assign a Phy Address to the TBI (TBIPA).
4974 + * Done also in cases where TBI is not selected to avoid conflict with
4975 + * the external PHY's Physical address
4976 + */
4977 + iowrite32be(cfg->tbipa, &regs->tbipa);
4978 +
4979 + /***************TMR_CTL************************/
4980 + iowrite32be(0, &regs->tmr_ctrl);
4981 +
4982 + if (cfg->ptp_tsu_en) {
4983 + tmp = 0;
4984 + tmp |= TMR_PEVENT_TSRE;
4985 + iowrite32be(tmp, &regs->tmr_pevent);
4986 +
4987 + if (cfg->ptp_exception_en) {
4988 + tmp = 0;
4989 + tmp |= TMR_PEMASK_TSREEN;
4990 + iowrite32be(tmp, &regs->tmr_pemask);
4991 + }
4992 + }
4993 +
4994 + /***************MACCFG1***********************/
4995 + tmp = 0;
4996 + if (cfg->loopback)
4997 + tmp |= MACCFG1_LOOPBACK;
4998 + if (cfg->rx_flow)
4999 + tmp |= MACCFG1_RX_FLOW;
5000 + if (cfg->tx_flow)
5001 + tmp |= MACCFG1_TX_FLOW;
5002 + iowrite32be(tmp, &regs->maccfg1);
5003 +
5004 + /***************MACCFG1***********************/
5005 +
5006 + /***************MACCFG2***********************/
5007 + tmp = 0;
5008 +
5009 + if (iface_speed < E_ENET_SPEED_1000)
5010 + tmp |= MACCFG2_NIBBLE_MODE;
5011 + else if (iface_speed == E_ENET_SPEED_1000)
5012 + tmp |= MACCFG2_BYTE_MODE;
5013 +
5014 + tmp |= ((uint32_t) cfg->preamble_len & 0x0000000f)
5015 + << PREAMBLE_LENGTH_SHIFT;
5016 +
5017 + if (cfg->rx_preamble)
5018 + tmp |= MACCFG2_PRE_AM_Rx_EN;
5019 + if (cfg->tx_preamble)
5020 + tmp |= MACCFG2_PRE_AM_Tx_EN;
5021 + if (cfg->rx_len_check)
5022 + tmp |= MACCFG2_LENGTH_CHECK;
5023 + if (cfg->tx_pad_crc)
5024 + tmp |= MACCFG2_PAD_CRC_EN;
5025 + if (cfg->tx_crc)
5026 + tmp |= MACCFG2_CRC_EN;
5027 + if (!cfg->halfdup_on)
5028 + tmp |= MACCFG2_FULL_DUPLEX;
5029 + iowrite32be(tmp, &regs->maccfg2);
5030 +
5031 + /***************MACCFG2***********************/
5032 +
5033 + /***************IPGIFG************************/
5034 + tmp = (((cfg->non_back_to_back_ipg1 <<
5035 + IPGIFG_NON_BACK_TO_BACK_IPG_1_SHIFT)
5036 + & IPGIFG_NON_BACK_TO_BACK_IPG_1)
5037 + | ((cfg->non_back_to_back_ipg2 <<
5038 + IPGIFG_NON_BACK_TO_BACK_IPG_2_SHIFT)
5039 + & IPGIFG_NON_BACK_TO_BACK_IPG_2)
5040 + | ((cfg->min_ifg_enforcement <<
5041 + IPGIFG_MIN_IFG_ENFORCEMENT_SHIFT)
5042 + & IPGIFG_MIN_IFG_ENFORCEMENT)
5043 + | (cfg->back_to_back_ipg & IPGIFG_BACK_TO_BACK_IPG));
5044 + iowrite32be(tmp, &regs->ipgifg);
5045 +
5046 + /***************IPGIFG************************/
5047 +
5048 + /***************HAFDUP************************/
5049 + tmp = 0;
5050 +
5051 + if (cfg->halfdup_alt_backoff_en)
5052 + tmp = (uint32_t)(HAFDUP_ALT_BEB |
5053 + ((cfg->halfdup_alt_backoff_val & 0x0000000f)
5054 + << HAFDUP_ALTERNATE_BEB_TRUNCATION_SHIFT));
5055 + if (cfg->halfdup_bp_no_backoff)
5056 + tmp |= HAFDUP_BP_NO_BACKOFF;
5057 + if (cfg->halfdup_no_backoff)
5058 + tmp |= HAFDUP_NO_BACKOFF;
5059 + if (cfg->halfdup_excess_defer)
5060 + tmp |= HAFDUP_EXCESS_DEFER;
5061 + tmp |= ((cfg->halfdup_retransmit << HAFDUP_RETRANSMISSION_MAX_SHIFT)
5062 + & HAFDUP_RETRANSMISSION_MAX);
5063 + tmp |= (cfg->halfdup_coll_window & HAFDUP_COLLISION_WINDOW);
5064 +
5065 + iowrite32be(tmp, &regs->hafdup);
5066 + /***************HAFDUP************************/
5067 +
5068 + /***************MAXFRM************************/
5069 + /* Initialize MAXFRM */
5070 + iowrite32be(cfg->maximum_frame, &regs->maxfrm);
5071 +
5072 + /***************MAXFRM************************/
5073 +
5074 + /***************CAM1************************/
5075 + iowrite32be(0xffffffff, &regs->cam1);
5076 + iowrite32be(0xffffffff, &regs->cam2);
5077 +
5078 + /***************IMASK************************/
5079 + iowrite32be(exception_mask, &regs->imask);
5080 + /***************IMASK************************/
5081 +
5082 + /***************IEVENT************************/
5083 + iowrite32be(0xffffffff, &regs->ievent);
5084 +
5085 + /***************MACSTNADDR1/2*****************/
5086 +
5087 + tmp = (uint32_t)((macaddr[5] << 24) |
5088 + (macaddr[4] << 16) |
5089 + (macaddr[3] << 8) |
5090 + macaddr[2]);
5091 + iowrite32be(tmp, &regs->macstnaddr1);
5092 +
5093 + tmp = (uint32_t)((macaddr[1] << 24) |
5094 + (macaddr[0] << 16));
5095 + iowrite32be(tmp, &regs->macstnaddr2);
5096 +
5097 + /***************MACSTNADDR1/2*****************/
5098 +
5099 + /*****************HASH************************/
5100 + for (i = 0; i < NUM_OF_HASH_REGS ; i++) {
5101 + /* Initialize IADDRx */
5102 + iowrite32be(0, &regs->igaddr[i]);
5103 + /* Initialize GADDRx */
5104 + iowrite32be(0, &regs->gaddr[i]);
5105 + }
5106 +
5107 + fman_dtsec_reset_stat(regs);
5108 +
5109 + return 0;
5110 +}
5111 +
5112 +uint16_t fman_dtsec_get_max_frame_len(struct dtsec_regs *regs)
5113 +{
5114 + return (uint16_t)ioread32be(&regs->maxfrm);
5115 +}
5116 +
5117 +void fman_dtsec_set_max_frame_len(struct dtsec_regs *regs, uint16_t length)
5118 +{
5119 + iowrite32be(length, &regs->maxfrm);
5120 +}
5121 +
5122 +void fman_dtsec_set_mac_address(struct dtsec_regs *regs, uint8_t *adr)
5123 +{
5124 + uint32_t tmp;
5125 +
5126 + tmp = (uint32_t)((adr[5] << 24) |
5127 + (adr[4] << 16) |
5128 + (adr[3] << 8) |
5129 + adr[2]);
5130 + iowrite32be(tmp, &regs->macstnaddr1);
5131 +
5132 + tmp = (uint32_t)((adr[1] << 24) |
5133 + (adr[0] << 16));
5134 + iowrite32be(tmp, &regs->macstnaddr2);
5135 +}
5136 +
5137 +void fman_dtsec_get_mac_address(struct dtsec_regs *regs, uint8_t *macaddr)
5138 +{
5139 + uint32_t tmp1, tmp2;
5140 +
5141 + tmp1 = ioread32be(&regs->macstnaddr1);
5142 + tmp2 = ioread32be(&regs->macstnaddr2);
5143 +
5144 + macaddr[0] = (uint8_t)((tmp2 & 0x00ff0000) >> 16);
5145 + macaddr[1] = (uint8_t)((tmp2 & 0xff000000) >> 24);
5146 + macaddr[2] = (uint8_t)(tmp1 & 0x000000ff);
5147 + macaddr[3] = (uint8_t)((tmp1 & 0x0000ff00) >> 8);
5148 + macaddr[4] = (uint8_t)((tmp1 & 0x00ff0000) >> 16);
5149 + macaddr[5] = (uint8_t)((tmp1 & 0xff000000) >> 24);
5150 +}
5151 +
5152 +void fman_dtsec_set_hash_table(struct dtsec_regs *regs, uint32_t crc, bool mcast, bool ghtx)
5153 +{
5154 + int32_t bucket;
5155 + if (ghtx)
5156 + bucket = (int32_t)((crc >> 23) & 0x1ff);
5157 + else {
5158 + bucket = (int32_t)((crc >> 24) & 0xff);
5159 + /* if !ghtx and mcast the bit must be set in gaddr instead of igaddr. */
5160 + if (mcast)
5161 + bucket += 0x100;
5162 + }
5163 + fman_dtsec_set_bucket(regs, bucket, TRUE);
5164 +}
5165 +
5166 +void fman_dtsec_set_bucket(struct dtsec_regs *regs, int bucket, bool enable)
5167 +{
5168 + int reg_idx = (bucket >> 5) & 0xf;
5169 + int bit_idx = bucket & 0x1f;
5170 + uint32_t bit_mask = 0x80000000 >> bit_idx;
5171 + uint32_t *reg;
5172 +
5173 + if (reg_idx > 7)
5174 + reg = &regs->gaddr[reg_idx-8];
5175 + else
5176 + reg = &regs->igaddr[reg_idx];
5177 +
5178 + if (enable)
5179 + iowrite32be(ioread32be(reg) | bit_mask, reg);
5180 + else
5181 + iowrite32be(ioread32be(reg) & (~bit_mask), reg);
5182 +}
5183 +
5184 +void fman_dtsec_reset_filter_table(struct dtsec_regs *regs, bool mcast, bool ucast)
5185 +{
5186 + int i;
5187 + bool ghtx;
5188 +
5189 + ghtx = (bool)((ioread32be(&regs->rctrl) & RCTRL_GHTX) ? TRUE : FALSE);
5190 +
5191 + if (ucast || (ghtx && mcast)) {
5192 + for (i = 0; i < NUM_OF_HASH_REGS; i++)
5193 + iowrite32be(0, &regs->igaddr[i]);
5194 + }
5195 + if (mcast) {
5196 + for (i = 0; i < NUM_OF_HASH_REGS; i++)
5197 + iowrite32be(0, &regs->gaddr[i]);
5198 + }
5199 +}
5200 +
5201 +int fman_dtsec_set_tbi_phy_addr(struct dtsec_regs *regs,
5202 + uint8_t addr)
5203 +{
5204 + if (addr > 0 && addr < 32)
5205 + iowrite32be(addr, &regs->tbipa);
5206 + else
5207 + return -EINVAL;
5208 +
5209 + return 0;
5210 +}
5211 +
5212 +void fman_dtsec_set_wol(struct dtsec_regs *regs, bool en)
5213 +{
5214 + uint32_t tmp;
5215 +
5216 + tmp = ioread32be(&regs->maccfg2);
5217 + if (en)
5218 + tmp |= MACCFG2_MAGIC_PACKET_EN;
5219 + else
5220 + tmp &= ~MACCFG2_MAGIC_PACKET_EN;
5221 + iowrite32be(tmp, &regs->maccfg2);
5222 +}
5223 +
5224 +int fman_dtsec_adjust_link(struct dtsec_regs *regs,
5225 + enum enet_interface iface_mode,
5226 + enum enet_speed speed, bool full_dx)
5227 +{
5228 + uint32_t tmp;
5229 +
5230 + UNUSED(iface_mode);
5231 +
5232 + if ((speed == E_ENET_SPEED_1000) && !full_dx)
5233 + return -EINVAL;
5234 +
5235 + tmp = ioread32be(&regs->maccfg2);
5236 + if (!full_dx)
5237 + tmp &= ~MACCFG2_FULL_DUPLEX;
5238 + else
5239 + tmp |= MACCFG2_FULL_DUPLEX;
5240 +
5241 + tmp &= ~(MACCFG2_NIBBLE_MODE | MACCFG2_BYTE_MODE);
5242 + if (speed < E_ENET_SPEED_1000)
5243 + tmp |= MACCFG2_NIBBLE_MODE;
5244 + else if (speed == E_ENET_SPEED_1000)
5245 + tmp |= MACCFG2_BYTE_MODE;
5246 + iowrite32be(tmp, &regs->maccfg2);
5247 +
5248 + tmp = ioread32be(&regs->ecntrl);
5249 + if (speed == E_ENET_SPEED_100)
5250 + tmp |= DTSEC_ECNTRL_R100M;
5251 + else
5252 + tmp &= ~DTSEC_ECNTRL_R100M;
5253 + iowrite32be(tmp, &regs->ecntrl);
5254 +
5255 + return 0;
5256 +}
5257 +
5258 +void fman_dtsec_set_uc_promisc(struct dtsec_regs *regs, bool enable)
5259 +{
5260 + uint32_t tmp;
5261 +
5262 + tmp = ioread32be(&regs->rctrl);
5263 +
5264 + if (enable)
5265 + tmp |= RCTRL_UPROM;
5266 + else
5267 + tmp &= ~RCTRL_UPROM;
5268 +
5269 + iowrite32be(tmp, &regs->rctrl);
5270 +}
5271 +
5272 +void fman_dtsec_set_mc_promisc(struct dtsec_regs *regs, bool enable)
5273 +{
5274 + uint32_t tmp;
5275 +
5276 + tmp = ioread32be(&regs->rctrl);
5277 +
5278 + if (enable)
5279 + tmp |= RCTRL_MPROM;
5280 + else
5281 + tmp &= ~RCTRL_MPROM;
5282 +
5283 + iowrite32be(tmp, &regs->rctrl);
5284 +}
5285 +
5286 +bool fman_dtsec_get_clear_carry_regs(struct dtsec_regs *regs,
5287 + uint32_t *car1, uint32_t *car2)
5288 +{
5289 + /* read carry registers */
5290 + *car1 = ioread32be(&regs->car1);
5291 + *car2 = ioread32be(&regs->car2);
5292 + /* clear carry registers */
5293 + if (*car1)
5294 + iowrite32be(*car1, &regs->car1);
5295 + if (*car2)
5296 + iowrite32be(*car2, &regs->car2);
5297 +
5298 + return (bool)((*car1 | *car2) ? TRUE : FALSE);
5299 +}
5300 +
5301 +void fman_dtsec_reset_stat(struct dtsec_regs *regs)
5302 +{
5303 + /* clear HW counters */
5304 + iowrite32be(ioread32be(&regs->ecntrl) |
5305 + DTSEC_ECNTRL_CLRCNT, &regs->ecntrl);
5306 +}
5307 +
5308 +int fman_dtsec_set_stat_level(struct dtsec_regs *regs, enum dtsec_stat_level level)
5309 +{
5310 + switch (level) {
5311 + case E_MAC_STAT_NONE:
5312 + iowrite32be(0xffffffff, &regs->cam1);
5313 + iowrite32be(0xffffffff, &regs->cam2);
5314 + iowrite32be(ioread32be(&regs->ecntrl) & ~DTSEC_ECNTRL_STEN,
5315 + &regs->ecntrl);
5316 + iowrite32be(ioread32be(&regs->imask) & ~DTSEC_IMASK_MSROEN,
5317 + &regs->imask);
5318 + break;
5319 + case E_MAC_STAT_PARTIAL:
5320 + iowrite32be(CAM1_ERRORS_ONLY, &regs->cam1);
5321 + iowrite32be(CAM2_ERRORS_ONLY, &regs->cam2);
5322 + iowrite32be(ioread32be(&regs->ecntrl) | DTSEC_ECNTRL_STEN,
5323 + &regs->ecntrl);
5324 + iowrite32be(ioread32be(&regs->imask) | DTSEC_IMASK_MSROEN,
5325 + &regs->imask);
5326 + break;
5327 + case E_MAC_STAT_MIB_GRP1:
5328 + iowrite32be((uint32_t)~CAM1_MIB_GRP_1, &regs->cam1);
5329 + iowrite32be((uint32_t)~CAM2_MIB_GRP_1, &regs->cam2);
5330 + iowrite32be(ioread32be(&regs->ecntrl) | DTSEC_ECNTRL_STEN,
5331 + &regs->ecntrl);
5332 + iowrite32be(ioread32be(&regs->imask) | DTSEC_IMASK_MSROEN,
5333 + &regs->imask);
5334 + break;
5335 + case E_MAC_STAT_FULL:
5336 + iowrite32be(0, &regs->cam1);
5337 + iowrite32be(0, &regs->cam2);
5338 + iowrite32be(ioread32be(&regs->ecntrl) | DTSEC_ECNTRL_STEN,
5339 + &regs->ecntrl);
5340 + iowrite32be(ioread32be(&regs->imask) | DTSEC_IMASK_MSROEN,
5341 + &regs->imask);
5342 + break;
5343 + default:
5344 + return -EINVAL;
5345 + }
5346 +
5347 + return 0;
5348 +}
5349 +
5350 +void fman_dtsec_set_ts(struct dtsec_regs *regs, bool en)
5351 +{
5352 + if (en) {
5353 + iowrite32be(ioread32be(&regs->rctrl) | RCTRL_RTSE,
5354 + &regs->rctrl);
5355 + iowrite32be(ioread32be(&regs->tctrl) | DTSEC_TCTRL_TTSE,
5356 + &regs->tctrl);
5357 + } else {
5358 + iowrite32be(ioread32be(&regs->rctrl) & ~RCTRL_RTSE,
5359 + &regs->rctrl);
5360 + iowrite32be(ioread32be(&regs->tctrl) & ~DTSEC_TCTRL_TTSE,
5361 + &regs->tctrl);
5362 + }
5363 +}
5364 +
5365 +void fman_dtsec_enable(struct dtsec_regs *regs, bool apply_rx, bool apply_tx)
5366 +{
5367 + uint32_t tmp;
5368 +
5369 + tmp = ioread32be(&regs->maccfg1);
5370 +
5371 + if (apply_rx)
5372 + tmp |= MACCFG1_RX_EN ;
5373 +
5374 + if (apply_tx)
5375 + tmp |= MACCFG1_TX_EN ;
5376 +
5377 + iowrite32be(tmp, &regs->maccfg1);
5378 +}
5379 +
5380 +void fman_dtsec_clear_addr_in_paddr(struct dtsec_regs *regs, uint8_t paddr_num)
5381 +{
5382 + iowrite32be(0, &regs->macaddr[paddr_num].exact_match1);
5383 + iowrite32be(0, &regs->macaddr[paddr_num].exact_match2);
5384 +}
5385 +
5386 +void fman_dtsec_add_addr_in_paddr(struct dtsec_regs *regs,
5387 + uint64_t addr,
5388 + uint8_t paddr_num)
5389 +{
5390 + uint32_t tmp;
5391 +
5392 + tmp = (uint32_t)(addr);
5393 + /* swap */
5394 + tmp = (((tmp & 0x000000FF) << 24) |
5395 + ((tmp & 0x0000FF00) << 8) |
5396 + ((tmp & 0x00FF0000) >> 8) |
5397 + ((tmp & 0xFF000000) >> 24));
5398 + iowrite32be(tmp, &regs->macaddr[paddr_num].exact_match1);
5399 +
5400 + tmp = (uint32_t)(addr>>32);
5401 + /* swap */
5402 + tmp = (((tmp & 0x000000FF) << 24) |
5403 + ((tmp & 0x0000FF00) << 8) |
5404 + ((tmp & 0x00FF0000) >> 8) |
5405 + ((tmp & 0xFF000000) >> 24));
5406 + iowrite32be(tmp, &regs->macaddr[paddr_num].exact_match2);
5407 +}
5408 +
5409 +void fman_dtsec_disable(struct dtsec_regs *regs, bool apply_rx, bool apply_tx)
5410 +{
5411 + uint32_t tmp;
5412 +
5413 + tmp = ioread32be(&regs->maccfg1);
5414 +
5415 + if (apply_rx)
5416 + tmp &= ~MACCFG1_RX_EN;
5417 +
5418 + if (apply_tx)
5419 + tmp &= ~MACCFG1_TX_EN;
5420 +
5421 + iowrite32be(tmp, &regs->maccfg1);
5422 +}
5423 +
5424 +void fman_dtsec_set_tx_pause_frames(struct dtsec_regs *regs, uint16_t time)
5425 +{
5426 + uint32_t ptv = 0;
5427 +
5428 + /* fixme: don't enable tx pause for half-duplex */
5429 +
5430 + if (time) {
5431 + ptv = ioread32be(&regs->ptv);
5432 + ptv &= 0xffff0000;
5433 + ptv |= time & 0x0000ffff;
5434 + iowrite32be(ptv, &regs->ptv);
5435 +
5436 + /* trigger the transmission of a flow-control pause frame */
5437 + iowrite32be(ioread32be(&regs->maccfg1) | MACCFG1_TX_FLOW,
5438 + &regs->maccfg1);
5439 + } else
5440 + iowrite32be(ioread32be(&regs->maccfg1) & ~MACCFG1_TX_FLOW,
5441 + &regs->maccfg1);
5442 +}
5443 +
5444 +void fman_dtsec_handle_rx_pause(struct dtsec_regs *regs, bool en)
5445 +{
5446 + uint32_t tmp;
5447 +
5448 + /* todo: check if mac is set to full-duplex */
5449 +
5450 + tmp = ioread32be(&regs->maccfg1);
5451 + if (en)
5452 + tmp |= MACCFG1_RX_FLOW;
5453 + else
5454 + tmp &= ~MACCFG1_RX_FLOW;
5455 + iowrite32be(tmp, &regs->maccfg1);
5456 +}
5457 +
5458 +uint32_t fman_dtsec_get_rctrl(struct dtsec_regs *regs)
5459 +{
5460 + return ioread32be(&regs->rctrl);
5461 +}
5462 +
5463 +uint32_t fman_dtsec_get_revision(struct dtsec_regs *regs)
5464 +{
5465 + return ioread32be(&regs->tsec_id);
5466 +}
5467 +
5468 +uint32_t fman_dtsec_get_event(struct dtsec_regs *regs, uint32_t ev_mask)
5469 +{
5470 + return ioread32be(&regs->ievent) & ev_mask;
5471 +}
5472 +
5473 +void fman_dtsec_ack_event(struct dtsec_regs *regs, uint32_t ev_mask)
5474 +{
5475 + iowrite32be(ev_mask, &regs->ievent);
5476 +}
5477 +
5478 +uint32_t fman_dtsec_get_interrupt_mask(struct dtsec_regs *regs)
5479 +{
5480 + return ioread32be(&regs->imask);
5481 +}
5482 +
5483 +uint32_t fman_dtsec_check_and_clear_tmr_event(struct dtsec_regs *regs)
5484 +{
5485 + uint32_t event;
5486 +
5487 + event = ioread32be(&regs->tmr_pevent);
5488 + event &= ioread32be(&regs->tmr_pemask);
5489 +
5490 + if (event)
5491 + iowrite32be(event, &regs->tmr_pevent);
5492 + return event;
5493 +}
5494 +
5495 +void fman_dtsec_enable_tmr_interrupt(struct dtsec_regs *regs)
5496 +{
5497 + iowrite32be(ioread32be(&regs->tmr_pemask) | TMR_PEMASK_TSREEN,
5498 + &regs->tmr_pemask);
5499 +}
5500 +
5501 +void fman_dtsec_disable_tmr_interrupt(struct dtsec_regs *regs)
5502 +{
5503 + iowrite32be(ioread32be(&regs->tmr_pemask) & ~TMR_PEMASK_TSREEN,
5504 + &regs->tmr_pemask);
5505 +}
5506 +
5507 +void fman_dtsec_enable_interrupt(struct dtsec_regs *regs, uint32_t ev_mask)
5508 +{
5509 + iowrite32be(ioread32be(&regs->imask) | ev_mask, &regs->imask);
5510 +}
5511 +
5512 +void fman_dtsec_disable_interrupt(struct dtsec_regs *regs, uint32_t ev_mask)
5513 +{
5514 + iowrite32be(ioread32be(&regs->imask) & ~ev_mask, &regs->imask);
5515 +}
5516 +
5517 +uint32_t fman_dtsec_get_stat_counter(struct dtsec_regs *regs,
5518 + enum dtsec_stat_counters reg_name)
5519 +{
5520 + uint32_t ret_val;
5521 +
5522 + switch (reg_name) {
5523 + case E_DTSEC_STAT_TR64:
5524 + ret_val = ioread32be(&regs->tr64);
5525 + break;
5526 + case E_DTSEC_STAT_TR127:
5527 + ret_val = ioread32be(&regs->tr127);
5528 + break;
5529 + case E_DTSEC_STAT_TR255:
5530 + ret_val = ioread32be(&regs->tr255);
5531 + break;
5532 + case E_DTSEC_STAT_TR511:
5533 + ret_val = ioread32be(&regs->tr511);
5534 + break;
5535 + case E_DTSEC_STAT_TR1K:
5536 + ret_val = ioread32be(&regs->tr1k);
5537 + break;
5538 + case E_DTSEC_STAT_TRMAX:
5539 + ret_val = ioread32be(&regs->trmax);
5540 + break;
5541 + case E_DTSEC_STAT_TRMGV:
5542 + ret_val = ioread32be(&regs->trmgv);
5543 + break;
5544 + case E_DTSEC_STAT_RBYT:
5545 + ret_val = ioread32be(&regs->rbyt);
5546 + break;
5547 + case E_DTSEC_STAT_RPKT:
5548 + ret_val = ioread32be(&regs->rpkt);
5549 + break;
5550 + case E_DTSEC_STAT_RMCA:
5551 + ret_val = ioread32be(&regs->rmca);
5552 + break;
5553 + case E_DTSEC_STAT_RBCA:
5554 + ret_val = ioread32be(&regs->rbca);
5555 + break;
5556 + case E_DTSEC_STAT_RXPF:
5557 + ret_val = ioread32be(&regs->rxpf);
5558 + break;
5559 + case E_DTSEC_STAT_RALN:
5560 + ret_val = ioread32be(&regs->raln);
5561 + break;
5562 + case E_DTSEC_STAT_RFLR:
5563 + ret_val = ioread32be(&regs->rflr);
5564 + break;
5565 + case E_DTSEC_STAT_RCDE:
5566 + ret_val = ioread32be(&regs->rcde);
5567 + break;
5568 + case E_DTSEC_STAT_RCSE:
5569 + ret_val = ioread32be(&regs->rcse);
5570 + break;
5571 + case E_DTSEC_STAT_RUND:
5572 + ret_val = ioread32be(&regs->rund);
5573 + break;
5574 + case E_DTSEC_STAT_ROVR:
5575 + ret_val = ioread32be(&regs->rovr);
5576 + break;
5577 + case E_DTSEC_STAT_RFRG:
5578 + ret_val = ioread32be(&regs->rfrg);
5579 + break;
5580 + case E_DTSEC_STAT_RJBR:
5581 + ret_val = ioread32be(&regs->rjbr);
5582 + break;
5583 + case E_DTSEC_STAT_RDRP:
5584 + ret_val = ioread32be(&regs->rdrp);
5585 + break;
5586 + case E_DTSEC_STAT_TFCS:
5587 + ret_val = ioread32be(&regs->tfcs);
5588 + break;
5589 + case E_DTSEC_STAT_TBYT:
5590 + ret_val = ioread32be(&regs->tbyt);
5591 + break;
5592 + case E_DTSEC_STAT_TPKT:
5593 + ret_val = ioread32be(&regs->tpkt);
5594 + break;
5595 + case E_DTSEC_STAT_TMCA:
5596 + ret_val = ioread32be(&regs->tmca);
5597 + break;
5598 + case E_DTSEC_STAT_TBCA:
5599 + ret_val = ioread32be(&regs->tbca);
5600 + break;
5601 + case E_DTSEC_STAT_TXPF:
5602 + ret_val = ioread32be(&regs->txpf);
5603 + break;
5604 + case E_DTSEC_STAT_TNCL:
5605 + ret_val = ioread32be(&regs->tncl);
5606 + break;
5607 + case E_DTSEC_STAT_TDRP:
5608 + ret_val = ioread32be(&regs->tdrp);
5609 + break;
5610 + default:
5611 + ret_val = 0;
5612 + }
5613 +
5614 + return ret_val;
5615 +}
5616 --- /dev/null
5617 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_dtsec_mii_acc.c
5618 @@ -0,0 +1,163 @@
5619 +/*
5620 + * Copyright 2008-2013 Freescale Semiconductor Inc.
5621 + *
5622 + * Redistribution and use in source and binary forms, with or without
5623 + * modification, are permitted provided that the following conditions are met:
5624 + * * Redistributions of source code must retain the above copyright
5625 + * notice, this list of conditions and the following disclaimer.
5626 + * * Redistributions in binary form must reproduce the above copyright
5627 + * notice, this list of conditions and the following disclaimer in the
5628 + * documentation and/or other materials provided with the distribution.
5629 + * * Neither the name of Freescale Semiconductor nor the
5630 + * names of its contributors may be used to endorse or promote products
5631 + * derived from this software without specific prior written permission.
5632 + *
5633 + *
5634 + * ALTERNATIVELY, this software may be distributed under the terms of the
5635 + * GNU General Public License ("GPL") as published by the Free Software
5636 + * Foundation, either version 2 of that License or (at your option) any
5637 + * later version.
5638 + *
5639 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
5640 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
5641 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5642 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
5643 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
5644 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
5645 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
5646 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5647 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
5648 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5649 + */
5650 +
5651 +
5652 +#include "common/general.h"
5653 +#include "fsl_fman_dtsec_mii_acc.h"
5654 +
5655 +
5656 +/**
5657 + * dtsec_mii_get_div() - calculates the value of the dtsec mii divider
5658 + * @dtsec_freq: dtsec clock frequency (in Mhz)
5659 + *
5660 + * This function calculates the dtsec mii clock divider that determines
5661 + * the MII MDC clock. MII MDC clock will be set to work in the range
5662 + * of 1.5 to 2.5Mhz
5663 + * The output of this function is the value of MIIMCFG[MgmtClk] which
5664 + * implicitly determines the divider value.
5665 + * Note: the dTSEC system clock is equal to 1/2 of the FMan clock.
5666 + *
5667 + * The table below which reflects dtsec_mii_get_div() functionality
5668 + * shows the relations among dtsec_freq, MgmtClk, actual divider
5669 + * and the MII frequency:
5670 + *
5671 + * dtsec freq MgmtClk div MII freq Mhz
5672 + * [0.....80] 1 (1/4)(1/8) [0 to 2.5]
5673 + * [81...120] 2 (1/6)(1/8) [1.6 to 2.5]
5674 + * [121..160] 3 (1/8)(1/8) [1.8 to 2.5]
5675 + * [161..200] 4 (1/10)(1/8) [2.0 to 2.5]
5676 + * [201..280] 5 (1/14)(1/8) [1.8 to 2.5]
5677 + * [281..400] 6 (1/20)(1/8) [1.1 to 2.5]
5678 + * [401..560] 7 (1/28)(1/8) [1.8 to 2.5]
5679 + * [560..frq] 7 (1/28)(1/8) [frq/224]
5680 + *
5681 + * Returns: the MIIMCFG[MgmtClk] appropriate value
5682 + */
5683 +
5684 +static uint8_t dtsec_mii_get_div(uint16_t dtsec_freq)
5685 +{
5686 + uint16_t mgmt_clk;
5687 +
5688 + if (dtsec_freq < 80) mgmt_clk = 1;
5689 + else if (dtsec_freq < 120) mgmt_clk = 2;
5690 + else if (dtsec_freq < 160) mgmt_clk = 3;
5691 + else if (dtsec_freq < 200) mgmt_clk = 4;
5692 + else if (dtsec_freq < 280) mgmt_clk = 5;
5693 + else if (dtsec_freq < 400) mgmt_clk = 6;
5694 + else mgmt_clk = 7;
5695 +
5696 + return (uint8_t)mgmt_clk;
5697 +}
5698 +
5699 +void fman_dtsec_mii_reset(struct dtsec_mii_reg *regs)
5700 +{
5701 + /* Reset the management interface */
5702 + iowrite32be(ioread32be(&regs->miimcfg) | MIIMCFG_RESET_MGMT,
5703 + &regs->miimcfg);
5704 + iowrite32be(ioread32be(&regs->miimcfg) & ~MIIMCFG_RESET_MGMT,
5705 + &regs->miimcfg);
5706 +}
5707 +
5708 +
5709 +int fman_dtsec_mii_write_reg(struct dtsec_mii_reg *regs, uint8_t addr,
5710 + uint8_t reg, uint16_t data, uint16_t dtsec_freq)
5711 +{
5712 + uint32_t tmp;
5713 +
5714 + /* Setup the MII Mgmt clock speed */
5715 + iowrite32be((uint32_t)dtsec_mii_get_div(dtsec_freq), &regs->miimcfg);
5716 + wmb();
5717 +
5718 + /* Stop the MII management read cycle */
5719 + iowrite32be(0, &regs->miimcom);
5720 + /* Dummy read to make sure MIIMCOM is written */
5721 + tmp = ioread32be(&regs->miimcom);
5722 + wmb();
5723 +
5724 + /* Setting up MII Management Address Register */
5725 + tmp = (uint32_t)((addr << MIIMADD_PHY_ADDR_SHIFT) | reg);
5726 + iowrite32be(tmp, &regs->miimadd);
5727 + wmb();
5728 +
5729 + /* Setting up MII Management Control Register with data */
5730 + iowrite32be((uint32_t)data, &regs->miimcon);
5731 + /* Dummy read to make sure MIIMCON is written */
5732 + tmp = ioread32be(&regs->miimcon);
5733 + wmb();
5734 +
5735 + /* Wait until MII management write is complete */
5736 + /* todo: a timeout could be useful here */
5737 + while ((ioread32be(&regs->miimind)) & MIIMIND_BUSY)
5738 + /* busy wait */;
5739 +
5740 + return 0;
5741 +}
5742 +
5743 +int fman_dtsec_mii_read_reg(struct dtsec_mii_reg *regs, uint8_t addr,
5744 + uint8_t reg, uint16_t *data, uint16_t dtsec_freq)
5745 +{
5746 + uint32_t tmp;
5747 +
5748 + /* Setup the MII Mgmt clock speed */
5749 + iowrite32be((uint32_t)dtsec_mii_get_div(dtsec_freq), &regs->miimcfg);
5750 + wmb();
5751 +
5752 + /* Setting up the MII Management Address Register */
5753 + tmp = (uint32_t)((addr << MIIMADD_PHY_ADDR_SHIFT) | reg);
5754 + iowrite32be(tmp, &regs->miimadd);
5755 + wmb();
5756 +
5757 + /* Perform an MII management read cycle */
5758 + iowrite32be(MIIMCOM_READ_CYCLE, &regs->miimcom);
5759 + /* Dummy read to make sure MIIMCOM is written */
5760 + tmp = ioread32be(&regs->miimcom);
5761 + wmb();
5762 +
5763 + /* Wait until MII management read is complete */
5764 + /* todo: a timeout could be useful here */
5765 + while ((ioread32be(&regs->miimind)) & MIIMIND_BUSY)
5766 + /* busy wait */;
5767 +
5768 + /* Read MII management status */
5769 + *data = (uint16_t)ioread32be(&regs->miimstat);
5770 + wmb();
5771 +
5772 + iowrite32be(0, &regs->miimcom);
5773 + /* Dummy read to make sure MIIMCOM is written */
5774 + tmp = ioread32be(&regs->miimcom);
5775 +
5776 + if (*data == 0xffff)
5777 + return -ENXIO;
5778 +
5779 + return 0;
5780 +}
5781 +
5782 --- /dev/null
5783 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_memac.c
5784 @@ -0,0 +1,511 @@
5785 +/*
5786 + * Copyright 2008-2012 Freescale Semiconductor Inc.
5787 + *
5788 + * Redistribution and use in source and binary forms, with or without
5789 + * modification, are permitted provided that the following conditions are met:
5790 + * * Redistributions of source code must retain the above copyright
5791 + * notice, this list of conditions and the following disclaimer.
5792 + * * Redistributions in binary form must reproduce the above copyright
5793 + * notice, this list of conditions and the following disclaimer in the
5794 + * documentation and/or other materials provided with the distribution.
5795 + * * Neither the name of Freescale Semiconductor nor the
5796 + * names of its contributors may be used to endorse or promote products
5797 + * derived from this software without specific prior written permission.
5798 + *
5799 + *
5800 + * ALTERNATIVELY, this software may be distributed under the terms of the
5801 + * GNU General Public License ("GPL") as published by the Free Software
5802 + * Foundation, either version 2 of that License or (at your option) any
5803 + * later version.
5804 + *
5805 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
5806 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
5807 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5808 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
5809 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
5810 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
5811 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
5812 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5813 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
5814 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5815 + */
5816 +
5817 +
5818 +#include "fsl_fman_memac.h"
5819 +
5820 +
5821 +uint32_t fman_memac_get_event(struct memac_regs *regs, uint32_t ev_mask)
5822 +{
5823 + return ioread32be(&regs->ievent) & ev_mask;
5824 +}
5825 +
5826 +uint32_t fman_memac_get_interrupt_mask(struct memac_regs *regs)
5827 +{
5828 + return ioread32be(&regs->imask);
5829 +}
5830 +
5831 +void fman_memac_ack_event(struct memac_regs *regs, uint32_t ev_mask)
5832 +{
5833 + iowrite32be(ev_mask, &regs->ievent);
5834 +}
5835 +
5836 +void fman_memac_set_promiscuous(struct memac_regs *regs, bool val)
5837 +{
5838 + uint32_t tmp;
5839 +
5840 + tmp = ioread32be(&regs->command_config);
5841 +
5842 + if (val)
5843 + tmp |= CMD_CFG_PROMIS_EN;
5844 + else
5845 + tmp &= ~CMD_CFG_PROMIS_EN;
5846 +
5847 + iowrite32be(tmp, &regs->command_config);
5848 +}
5849 +
5850 +void fman_memac_clear_addr_in_paddr(struct memac_regs *regs,
5851 + uint8_t paddr_num)
5852 +{
5853 + if (paddr_num == 0) {
5854 + iowrite32be(0, &regs->mac_addr0.mac_addr_l);
5855 + iowrite32be(0, &regs->mac_addr0.mac_addr_u);
5856 + } else {
5857 + iowrite32be(0x0, &regs->mac_addr[paddr_num - 1].mac_addr_l);
5858 + iowrite32be(0x0, &regs->mac_addr[paddr_num - 1].mac_addr_u);
5859 + }
5860 +}
5861 +
5862 +void fman_memac_add_addr_in_paddr(struct memac_regs *regs,
5863 + uint8_t *adr,
5864 + uint8_t paddr_num)
5865 +{
5866 + uint32_t tmp0, tmp1;
5867 +
5868 + tmp0 = (uint32_t)(adr[0] |
5869 + adr[1] << 8 |
5870 + adr[2] << 16 |
5871 + adr[3] << 24);
5872 + tmp1 = (uint32_t)(adr[4] | adr[5] << 8);
5873 +
5874 + if (paddr_num == 0) {
5875 + iowrite32be(tmp0, &regs->mac_addr0.mac_addr_l);
5876 + iowrite32be(tmp1, &regs->mac_addr0.mac_addr_u);
5877 + } else {
5878 + iowrite32be(tmp0, &regs->mac_addr[paddr_num-1].mac_addr_l);
5879 + iowrite32be(tmp1, &regs->mac_addr[paddr_num-1].mac_addr_u);
5880 + }
5881 +}
5882 +
5883 +void fman_memac_enable(struct memac_regs *regs, bool apply_rx, bool apply_tx)
5884 +{
5885 + uint32_t tmp;
5886 +
5887 + tmp = ioread32be(&regs->command_config);
5888 +
5889 + if (apply_rx)
5890 + tmp |= CMD_CFG_RX_EN;
5891 +
5892 + if (apply_tx)
5893 + tmp |= CMD_CFG_TX_EN;
5894 +
5895 + iowrite32be(tmp, &regs->command_config);
5896 +}
5897 +
5898 +void fman_memac_disable(struct memac_regs *regs, bool apply_rx, bool apply_tx)
5899 +{
5900 + uint32_t tmp;
5901 +
5902 + tmp = ioread32be(&regs->command_config);
5903 +
5904 + if (apply_rx)
5905 + tmp &= ~CMD_CFG_RX_EN;
5906 +
5907 + if (apply_tx)
5908 + tmp &= ~CMD_CFG_TX_EN;
5909 +
5910 + iowrite32be(tmp, &regs->command_config);
5911 +}
5912 +
5913 +void fman_memac_reset_stat(struct memac_regs *regs)
5914 +{
5915 + uint32_t tmp;
5916 +
5917 + tmp = ioread32be(&regs->statn_config);
5918 +
5919 + tmp |= STATS_CFG_CLR;
5920 +
5921 + iowrite32be(tmp, &regs->statn_config);
5922 +
5923 + while (ioread32be(&regs->statn_config) & STATS_CFG_CLR);
5924 +}
5925 +
5926 +void fman_memac_reset(struct memac_regs *regs)
5927 +{
5928 + uint32_t tmp;
5929 +
5930 + tmp = ioread32be(&regs->command_config);
5931 +
5932 + tmp |= CMD_CFG_SW_RESET;
5933 +
5934 + iowrite32be(tmp, &regs->command_config);
5935 +
5936 + while (ioread32be(&regs->command_config) & CMD_CFG_SW_RESET);
5937 +}
5938 +
5939 +int fman_memac_init(struct memac_regs *regs,
5940 + struct memac_cfg *cfg,
5941 + enum enet_interface enet_interface,
5942 + enum enet_speed enet_speed,
5943 + bool slow_10g_if,
5944 + uint32_t exceptions)
5945 +{
5946 + uint32_t tmp;
5947 +
5948 + /* Config */
5949 + tmp = 0;
5950 + if (cfg->wan_mode_enable)
5951 + tmp |= CMD_CFG_WAN_MODE;
5952 + if (cfg->promiscuous_mode_enable)
5953 + tmp |= CMD_CFG_PROMIS_EN;
5954 + if (cfg->pause_forward_enable)
5955 + tmp |= CMD_CFG_PAUSE_FWD;
5956 + if (cfg->pause_ignore)
5957 + tmp |= CMD_CFG_PAUSE_IGNORE;
5958 + if (cfg->tx_addr_ins_enable)
5959 + tmp |= CMD_CFG_TX_ADDR_INS;
5960 + if (cfg->loopback_enable)
5961 + tmp |= CMD_CFG_LOOPBACK_EN;
5962 + if (cfg->cmd_frame_enable)
5963 + tmp |= CMD_CFG_CNT_FRM_EN;
5964 + if (cfg->send_idle_enable)
5965 + tmp |= CMD_CFG_SEND_IDLE;
5966 + if (cfg->no_length_check_enable)
5967 + tmp |= CMD_CFG_NO_LEN_CHK;
5968 + if (cfg->rx_sfd_any)
5969 + tmp |= CMD_CFG_SFD_ANY;
5970 + if (cfg->pad_enable)
5971 + tmp |= CMD_CFG_TX_PAD_EN;
5972 + if (cfg->wake_on_lan)
5973 + tmp |= CMD_CFG_MG;
5974 +
5975 + tmp |= CMD_CFG_CRC_FWD;
5976 +
5977 + iowrite32be(tmp, &regs->command_config);
5978 +
5979 + /* Max Frame Length */
5980 + iowrite32be((uint32_t)cfg->max_frame_length, &regs->maxfrm);
5981 +
5982 + /* Pause Time */
5983 + iowrite32be((uint32_t)cfg->pause_quanta, &regs->pause_quanta[0]);
5984 + iowrite32be((uint32_t)0, &regs->pause_thresh[0]);
5985 +
5986 + /* IF_MODE */
5987 + tmp = 0;
5988 + switch (enet_interface) {
5989 + case E_ENET_IF_XGMII:
5990 + case E_ENET_IF_XFI:
5991 + tmp |= IF_MODE_XGMII;
5992 + break;
5993 + default:
5994 + tmp |= IF_MODE_GMII;
5995 + if (enet_interface == E_ENET_IF_RGMII && !cfg->loopback_enable)
5996 + tmp |= IF_MODE_RGMII | IF_MODE_RGMII_AUTO;
5997 + }
5998 + iowrite32be(tmp, &regs->if_mode);
5999 +
6000 + /* TX_FIFO_SECTIONS */
6001 + tmp = 0;
6002 + if (enet_interface == E_ENET_IF_XGMII ||
6003 + enet_interface == E_ENET_IF_XFI) {
6004 + if(slow_10g_if) {
6005 + tmp |= (TX_FIFO_SECTIONS_TX_AVAIL_SLOW_10G |
6006 + TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_10G);
6007 + } else {
6008 + tmp |= (TX_FIFO_SECTIONS_TX_AVAIL_10G |
6009 + TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_10G);
6010 + }
6011 + } else {
6012 + tmp |= (TX_FIFO_SECTIONS_TX_AVAIL_1G |
6013 + TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_1G);
6014 + }
6015 + iowrite32be(tmp, &regs->tx_fifo_sections);
6016 +
6017 + /* clear all pending events and set-up interrupts */
6018 + fman_memac_ack_event(regs, 0xffffffff);
6019 + fman_memac_set_exception(regs, exceptions, TRUE);
6020 +
6021 + return 0;
6022 +}
6023 +
6024 +void fman_memac_set_exception(struct memac_regs *regs, uint32_t val, bool enable)
6025 +{
6026 + uint32_t tmp;
6027 +
6028 + tmp = ioread32be(&regs->imask);
6029 + if (enable)
6030 + tmp |= val;
6031 + else
6032 + tmp &= ~val;
6033 +
6034 + iowrite32be(tmp, &regs->imask);
6035 +}
6036 +
6037 +void fman_memac_reset_filter_table(struct memac_regs *regs)
6038 +{
6039 + uint32_t i;
6040 + for (i = 0; i < 64; i++)
6041 + iowrite32be(i & ~HASH_CTRL_MCAST_EN, &regs->hashtable_ctrl);
6042 +}
6043 +
6044 +void fman_memac_set_hash_table_entry(struct memac_regs *regs, uint32_t crc)
6045 +{
6046 + iowrite32be(crc | HASH_CTRL_MCAST_EN, &regs->hashtable_ctrl);
6047 +}
6048 +
6049 +void fman_memac_set_hash_table(struct memac_regs *regs, uint32_t val)
6050 +{
6051 + iowrite32be(val, &regs->hashtable_ctrl);
6052 +}
6053 +
6054 +uint16_t fman_memac_get_max_frame_len(struct memac_regs *regs)
6055 +{
6056 + uint32_t tmp;
6057 +
6058 + tmp = ioread32be(&regs->maxfrm);
6059 +
6060 + return(uint16_t)tmp;
6061 +}
6062 +
6063 +
6064 +void fman_memac_set_tx_pause_frames(struct memac_regs *regs,
6065 + uint8_t priority,
6066 + uint16_t pause_time,
6067 + uint16_t thresh_time)
6068 +{
6069 + uint32_t tmp;
6070 +
6071 + tmp = ioread32be(&regs->tx_fifo_sections);
6072 +
6073 + if (priority == 0xff) {
6074 + GET_TX_EMPTY_DEFAULT_VALUE(tmp);
6075 + iowrite32be(tmp, &regs->tx_fifo_sections);
6076 +
6077 + tmp = ioread32be(&regs->command_config);
6078 + tmp &= ~CMD_CFG_PFC_MODE;
6079 + priority = 0;
6080 + } else {
6081 + GET_TX_EMPTY_PFC_VALUE(tmp);
6082 + iowrite32be(tmp, &regs->tx_fifo_sections);
6083 +
6084 + tmp = ioread32be(&regs->command_config);
6085 + tmp |= CMD_CFG_PFC_MODE;
6086 + }
6087 +
6088 + iowrite32be(tmp, &regs->command_config);
6089 +
6090 + tmp = ioread32be(&regs->pause_quanta[priority / 2]);
6091 + if (priority % 2)
6092 + tmp &= 0x0000FFFF;
6093 + else
6094 + tmp &= 0xFFFF0000;
6095 + tmp |= ((uint32_t)pause_time << (16 * (priority % 2)));
6096 + iowrite32be(tmp, &regs->pause_quanta[priority / 2]);
6097 +
6098 + tmp = ioread32be(&regs->pause_thresh[priority / 2]);
6099 + if (priority % 2)
6100 + tmp &= 0x0000FFFF;
6101 + else
6102 + tmp &= 0xFFFF0000;
6103 + tmp |= ((uint32_t)thresh_time<<(16 * (priority % 2)));
6104 + iowrite32be(tmp, &regs->pause_thresh[priority / 2]);
6105 +}
6106 +
6107 +void fman_memac_set_rx_ignore_pause_frames(struct memac_regs *regs,bool enable)
6108 +{
6109 + uint32_t tmp;
6110 +
6111 + tmp = ioread32be(&regs->command_config);
6112 + if (enable)
6113 + tmp |= CMD_CFG_PAUSE_IGNORE;
6114 + else
6115 + tmp &= ~CMD_CFG_PAUSE_IGNORE;
6116 +
6117 + iowrite32be(tmp, &regs->command_config);
6118 +}
6119 +
6120 +void fman_memac_set_wol(struct memac_regs *regs, bool enable)
6121 +{
6122 + uint32_t tmp;
6123 +
6124 + tmp = ioread32be(&regs->command_config);
6125 +
6126 + if (enable)
6127 + tmp |= CMD_CFG_MG;
6128 + else
6129 + tmp &= ~CMD_CFG_MG;
6130 +
6131 + iowrite32be(tmp, &regs->command_config);
6132 +}
6133 +
6134 +#define GET_MEMAC_CNTR_64(bn) \
6135 + (ioread32be(&regs->bn ## _l) | \
6136 + ((uint64_t)ioread32be(&regs->bn ## _u) << 32))
6137 +
6138 +uint64_t fman_memac_get_counter(struct memac_regs *regs,
6139 + enum memac_counters reg_name)
6140 +{
6141 + uint64_t ret_val;
6142 +
6143 + switch (reg_name) {
6144 + case E_MEMAC_COUNTER_R64:
6145 + ret_val = GET_MEMAC_CNTR_64(r64);
6146 + break;
6147 + case E_MEMAC_COUNTER_R127:
6148 + ret_val = GET_MEMAC_CNTR_64(r127);
6149 + break;
6150 + case E_MEMAC_COUNTER_R255:
6151 + ret_val = GET_MEMAC_CNTR_64(r255);
6152 + break;
6153 + case E_MEMAC_COUNTER_R511:
6154 + ret_val = GET_MEMAC_CNTR_64(r511);
6155 + break;
6156 + case E_MEMAC_COUNTER_R1023:
6157 + ret_val = GET_MEMAC_CNTR_64(r1023);
6158 + break;
6159 + case E_MEMAC_COUNTER_R1518:
6160 + ret_val = GET_MEMAC_CNTR_64(r1518);
6161 + break;
6162 + case E_MEMAC_COUNTER_R1519X:
6163 + ret_val = GET_MEMAC_CNTR_64(r1519x);
6164 + break;
6165 + case E_MEMAC_COUNTER_RFRG:
6166 + ret_val = GET_MEMAC_CNTR_64(rfrg);
6167 + break;
6168 + case E_MEMAC_COUNTER_RJBR:
6169 + ret_val = GET_MEMAC_CNTR_64(rjbr);
6170 + break;
6171 + case E_MEMAC_COUNTER_RDRP:
6172 + ret_val = GET_MEMAC_CNTR_64(rdrp);
6173 + break;
6174 + case E_MEMAC_COUNTER_RALN:
6175 + ret_val = GET_MEMAC_CNTR_64(raln);
6176 + break;
6177 + case E_MEMAC_COUNTER_TUND:
6178 + ret_val = GET_MEMAC_CNTR_64(tund);
6179 + break;
6180 + case E_MEMAC_COUNTER_ROVR:
6181 + ret_val = GET_MEMAC_CNTR_64(rovr);
6182 + break;
6183 + case E_MEMAC_COUNTER_RXPF:
6184 + ret_val = GET_MEMAC_CNTR_64(rxpf);
6185 + break;
6186 + case E_MEMAC_COUNTER_TXPF:
6187 + ret_val = GET_MEMAC_CNTR_64(txpf);
6188 + break;
6189 + case E_MEMAC_COUNTER_ROCT:
6190 + ret_val = GET_MEMAC_CNTR_64(roct);
6191 + break;
6192 + case E_MEMAC_COUNTER_RMCA:
6193 + ret_val = GET_MEMAC_CNTR_64(rmca);
6194 + break;
6195 + case E_MEMAC_COUNTER_RBCA:
6196 + ret_val = GET_MEMAC_CNTR_64(rbca);
6197 + break;
6198 + case E_MEMAC_COUNTER_RPKT:
6199 + ret_val = GET_MEMAC_CNTR_64(rpkt);
6200 + break;
6201 + case E_MEMAC_COUNTER_RUCA:
6202 + ret_val = GET_MEMAC_CNTR_64(ruca);
6203 + break;
6204 + case E_MEMAC_COUNTER_RERR:
6205 + ret_val = GET_MEMAC_CNTR_64(rerr);
6206 + break;
6207 + case E_MEMAC_COUNTER_TOCT:
6208 + ret_val = GET_MEMAC_CNTR_64(toct);
6209 + break;
6210 + case E_MEMAC_COUNTER_TMCA:
6211 + ret_val = GET_MEMAC_CNTR_64(tmca);
6212 + break;
6213 + case E_MEMAC_COUNTER_TBCA:
6214 + ret_val = GET_MEMAC_CNTR_64(tbca);
6215 + break;
6216 + case E_MEMAC_COUNTER_TUCA:
6217 + ret_val = GET_MEMAC_CNTR_64(tuca);
6218 + break;
6219 + case E_MEMAC_COUNTER_TERR:
6220 + ret_val = GET_MEMAC_CNTR_64(terr);
6221 + break;
6222 + default:
6223 + ret_val = 0;
6224 + }
6225 +
6226 + return ret_val;
6227 +}
6228 +
6229 +void fman_memac_adjust_link(struct memac_regs *regs,
6230 + enum enet_interface iface_mode,
6231 + enum enet_speed speed, bool full_dx)
6232 +{
6233 + uint32_t tmp;
6234 +
6235 + tmp = ioread32be(&regs->if_mode);
6236 +
6237 + if (full_dx)
6238 + tmp &= ~IF_MODE_HD;
6239 + else
6240 + tmp |= IF_MODE_HD;
6241 +
6242 + if (iface_mode == E_ENET_IF_RGMII) {
6243 + /* Configure RGMII in manual mode */
6244 + tmp &= ~IF_MODE_RGMII_AUTO;
6245 + tmp &= ~IF_MODE_RGMII_SP_MASK;
6246 +
6247 + if (full_dx)
6248 + tmp |= IF_MODE_RGMII_FD;
6249 + else
6250 + tmp &= ~IF_MODE_RGMII_FD;
6251 +
6252 + switch (speed) {
6253 + case E_ENET_SPEED_1000:
6254 + tmp |= IF_MODE_RGMII_1000;
6255 + break;
6256 + case E_ENET_SPEED_100:
6257 + tmp |= IF_MODE_RGMII_100;
6258 + break;
6259 + case E_ENET_SPEED_10:
6260 + tmp |= IF_MODE_RGMII_10;
6261 + break;
6262 + default:
6263 + break;
6264 + }
6265 + }
6266 +
6267 + iowrite32be(tmp, &regs->if_mode);
6268 +}
6269 +
6270 +void fman_memac_defconfig(struct memac_cfg *cfg)
6271 +{
6272 + cfg->reset_on_init = FALSE;
6273 + cfg->wan_mode_enable = FALSE;
6274 + cfg->promiscuous_mode_enable = FALSE;
6275 + cfg->pause_forward_enable = FALSE;
6276 + cfg->pause_ignore = FALSE;
6277 + cfg->tx_addr_ins_enable = FALSE;
6278 + cfg->loopback_enable = FALSE;
6279 + cfg->cmd_frame_enable = FALSE;
6280 + cfg->rx_error_discard = FALSE;
6281 + cfg->send_idle_enable = FALSE;
6282 + cfg->no_length_check_enable = TRUE;
6283 + cfg->lgth_check_nostdr = FALSE;
6284 + cfg->time_stamp_enable = FALSE;
6285 + cfg->tx_ipg_length = DEFAULT_TX_IPG_LENGTH;
6286 + cfg->max_frame_length = DEFAULT_FRAME_LENGTH;
6287 + cfg->pause_quanta = DEFAULT_PAUSE_QUANTA;
6288 + cfg->pad_enable = TRUE;
6289 + cfg->phy_tx_ena_on = FALSE;
6290 + cfg->rx_sfd_any = FALSE;
6291 + cfg->rx_pbl_fwd = FALSE;
6292 + cfg->tx_pbl_fwd = FALSE;
6293 + cfg->debug_mode = FALSE;
6294 + cfg->wake_on_lan = FALSE;
6295 +}
6296 --- /dev/null
6297 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_memac_mii_acc.c
6298 @@ -0,0 +1,213 @@
6299 +/*
6300 + * Copyright 2008-2013 Freescale Semiconductor Inc.
6301 + *
6302 + * Redistribution and use in source and binary forms, with or without
6303 + * modification, are permitted provided that the following conditions are met:
6304 + * * Redistributions of source code must retain the above copyright
6305 + * notice, this list of conditions and the following disclaimer.
6306 + * * Redistributions in binary form must reproduce the above copyright
6307 + * notice, this list of conditions and the following disclaimer in the
6308 + * documentation and/or other materials provided with the distribution.
6309 + * * Neither the name of Freescale Semiconductor nor the
6310 + * names of its contributors may be used to endorse or promote products
6311 + * derived from this software without specific prior written permission.
6312 + *
6313 + *
6314 + * ALTERNATIVELY, this software may be distributed under the terms of the
6315 + * GNU General Public License ("GPL") as published by the Free Software
6316 + * Foundation, either version 2 of that License or (at your option) any
6317 + * later version.
6318 + *
6319 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
6320 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6321 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
6322 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
6323 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
6324 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
6325 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
6326 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
6327 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
6328 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6329 + */
6330 +
6331 +
6332 +#include "fsl_fman_memac_mii_acc.h"
6333 +
6334 +static void write_phy_reg_10g(struct memac_mii_access_mem_map *mii_regs,
6335 + uint8_t phy_addr, uint8_t reg, uint16_t data)
6336 +{
6337 + uint32_t tmp_reg;
6338 +
6339 + tmp_reg = ioread32be(&mii_regs->mdio_cfg);
6340 + /* Leave only MDIO_CLK_DIV bits set on */
6341 + tmp_reg &= MDIO_CFG_CLK_DIV_MASK;
6342 + /* Set maximum MDIO_HOLD value to allow phy to see
6343 + change of data signal */
6344 + tmp_reg |= MDIO_CFG_HOLD_MASK;
6345 + /* Add 10G interface mode */
6346 + tmp_reg |= MDIO_CFG_ENC45;
6347 + iowrite32be(tmp_reg, &mii_regs->mdio_cfg);
6348 +
6349 + /* Wait for command completion */
6350 + while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
6351 + udelay(1);
6352 +
6353 + /* Specify phy and register to be accessed */
6354 + iowrite32be(phy_addr, &mii_regs->mdio_ctrl);
6355 + iowrite32be(reg, &mii_regs->mdio_addr);
6356 + wmb();
6357 +
6358 + while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
6359 + udelay(1);
6360 +
6361 + /* Write data */
6362 + iowrite32be(data, &mii_regs->mdio_data);
6363 + wmb();
6364 +
6365 + /* Wait for write transaction end */
6366 + while ((ioread32be(&mii_regs->mdio_data)) & MDIO_DATA_BSY)
6367 + udelay(1);
6368 +}
6369 +
6370 +static uint32_t read_phy_reg_10g(struct memac_mii_access_mem_map *mii_regs,
6371 + uint8_t phy_addr, uint8_t reg, uint16_t *data)
6372 +{
6373 + uint32_t tmp_reg;
6374 +
6375 + tmp_reg = ioread32be(&mii_regs->mdio_cfg);
6376 + /* Leave only MDIO_CLK_DIV bits set on */
6377 + tmp_reg &= MDIO_CFG_CLK_DIV_MASK;
6378 + /* Set maximum MDIO_HOLD value to allow phy to see
6379 + change of data signal */
6380 + tmp_reg |= MDIO_CFG_HOLD_MASK;
6381 + /* Add 10G interface mode */
6382 + tmp_reg |= MDIO_CFG_ENC45;
6383 + iowrite32be(tmp_reg, &mii_regs->mdio_cfg);
6384 +
6385 + /* Wait for command completion */
6386 + while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
6387 + udelay(1);
6388 +
6389 + /* Specify phy and register to be accessed */
6390 + iowrite32be(phy_addr, &mii_regs->mdio_ctrl);
6391 + iowrite32be(reg, &mii_regs->mdio_addr);
6392 + wmb();
6393 +
6394 + while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
6395 + udelay(1);
6396 +
6397 + /* Read cycle */
6398 + tmp_reg = phy_addr;
6399 + tmp_reg |= MDIO_CTL_READ;
6400 + iowrite32be(tmp_reg, &mii_regs->mdio_ctrl);
6401 + wmb();
6402 +
6403 + /* Wait for data to be available */
6404 + while ((ioread32be(&mii_regs->mdio_data)) & MDIO_DATA_BSY)
6405 + udelay(1);
6406 +
6407 + *data = (uint16_t)ioread32be(&mii_regs->mdio_data);
6408 +
6409 + /* Check if there was an error */
6410 + return ioread32be(&mii_regs->mdio_cfg);
6411 +}
6412 +
6413 +static void write_phy_reg_1g(struct memac_mii_access_mem_map *mii_regs,
6414 + uint8_t phy_addr, uint8_t reg, uint16_t data)
6415 +{
6416 + uint32_t tmp_reg;
6417 +
6418 + /* Leave only MDIO_CLK_DIV and MDIO_HOLD bits set on */
6419 + tmp_reg = ioread32be(&mii_regs->mdio_cfg);
6420 + tmp_reg &= (MDIO_CFG_CLK_DIV_MASK | MDIO_CFG_HOLD_MASK);
6421 + iowrite32be(tmp_reg, &mii_regs->mdio_cfg);
6422 +
6423 + /* Wait for command completion */
6424 + while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
6425 + udelay(1);
6426 +
6427 + /* Write transaction */
6428 + tmp_reg = (phy_addr << MDIO_CTL_PHY_ADDR_SHIFT);
6429 + tmp_reg |= reg;
6430 + iowrite32be(tmp_reg, &mii_regs->mdio_ctrl);
6431 +
6432 + while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
6433 + udelay(1);
6434 +
6435 + iowrite32be(data, &mii_regs->mdio_data);
6436 +
6437 + wmb();
6438 +
6439 + /* Wait for write transaction to end */
6440 + while ((ioread32be(&mii_regs->mdio_data)) & MDIO_DATA_BSY)
6441 + udelay(1);
6442 +}
6443 +
6444 +static uint32_t read_phy_reg_1g(struct memac_mii_access_mem_map *mii_regs,
6445 + uint8_t phy_addr, uint8_t reg, uint16_t *data)
6446 +{
6447 + uint32_t tmp_reg;
6448 +
6449 + /* Leave only MDIO_CLK_DIV and MDIO_HOLD bits set on */
6450 + tmp_reg = ioread32be(&mii_regs->mdio_cfg);
6451 + tmp_reg &= (MDIO_CFG_CLK_DIV_MASK | MDIO_CFG_HOLD_MASK);
6452 + iowrite32be(tmp_reg, &mii_regs->mdio_cfg);
6453 +
6454 + /* Wait for command completion */
6455 + while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
6456 + udelay(1);
6457 +
6458 + /* Read transaction */
6459 + tmp_reg = (phy_addr << MDIO_CTL_PHY_ADDR_SHIFT);
6460 + tmp_reg |= reg;
6461 + tmp_reg |= MDIO_CTL_READ;
6462 + iowrite32be(tmp_reg, &mii_regs->mdio_ctrl);
6463 +
6464 + while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
6465 + udelay(1);
6466 +
6467 + /* Wait for data to be available */
6468 + while ((ioread32be(&mii_regs->mdio_data)) & MDIO_DATA_BSY)
6469 + udelay(1);
6470 +
6471 + *data = (uint16_t)ioread32be(&mii_regs->mdio_data);
6472 +
6473 + /* Check error */
6474 + return ioread32be(&mii_regs->mdio_cfg);
6475 +}
6476 +
6477 +/*****************************************************************************/
6478 +int fman_memac_mii_write_phy_reg(struct memac_mii_access_mem_map *mii_regs,
6479 + uint8_t phy_addr, uint8_t reg, uint16_t data,
6480 + enum enet_speed enet_speed)
6481 +{
6482 + /* Figure out interface type - 10G vs 1G.
6483 + In 10G interface both phy_addr and devAddr present. */
6484 + if (enet_speed == E_ENET_SPEED_10000)
6485 + write_phy_reg_10g(mii_regs, phy_addr, reg, data);
6486 + else
6487 + write_phy_reg_1g(mii_regs, phy_addr, reg, data);
6488 +
6489 + return 0;
6490 +}
6491 +
6492 +/*****************************************************************************/
6493 +int fman_memac_mii_read_phy_reg(struct memac_mii_access_mem_map *mii_regs,
6494 + uint8_t phy_addr, uint8_t reg, uint16_t *data,
6495 + enum enet_speed enet_speed)
6496 +{
6497 + uint32_t ans;
6498 + /* Figure out interface type - 10G vs 1G.
6499 + In 10G interface both phy_addr and devAddr present. */
6500 + if (enet_speed == E_ENET_SPEED_10000)
6501 + ans = read_phy_reg_10g(mii_regs, phy_addr, reg, data);
6502 + else
6503 + ans = read_phy_reg_1g(mii_regs, phy_addr, reg, data);
6504 +
6505 + if (ans & MDIO_CFG_READ_ERR)
6506 + return -EINVAL;
6507 + return 0;
6508 +}
6509 +
6510 +/* ......................................................................... */
6511 +
6512 --- /dev/null
6513 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_tgec.c
6514 @@ -0,0 +1,367 @@
6515 +/*
6516 + * Copyright 2008-2012 Freescale Semiconductor Inc.
6517 + *
6518 + * Redistribution and use in source and binary forms, with or without
6519 + * modification, are permitted provided that the following conditions are met:
6520 + * * Redistributions of source code must retain the above copyright
6521 + * notice, this list of conditions and the following disclaimer.
6522 + * * Redistributions in binary form must reproduce the above copyright
6523 + * notice, this list of conditions and the following disclaimer in the
6524 + * documentation and/or other materials provided with the distribution.
6525 + * * Neither the name of Freescale Semiconductor nor the
6526 + * names of its contributors may be used to endorse or promote products
6527 + * derived from this software without specific prior written permission.
6528 + *
6529 + *
6530 + * ALTERNATIVELY, this software may be distributed under the terms of the
6531 + * GNU General Public License ("GPL") as published by the Free Software
6532 + * Foundation, either version 2 of that License or (at your option) any
6533 + * later version.
6534 + *
6535 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
6536 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6537 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
6538 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
6539 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
6540 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
6541 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
6542 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
6543 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
6544 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6545 + */
6546 +
6547 +
6548 +#include "fsl_fman_tgec.h"
6549 +
6550 +
6551 +void fman_tgec_set_mac_address(struct tgec_regs *regs, uint8_t *adr)
6552 +{
6553 + uint32_t tmp0, tmp1;
6554 +
6555 + tmp0 = (uint32_t)(adr[0] |
6556 + adr[1] << 8 |
6557 + adr[2] << 16 |
6558 + adr[3] << 24);
6559 + tmp1 = (uint32_t)(adr[4] | adr[5] << 8);
6560 + iowrite32be(tmp0, &regs->mac_addr_0);
6561 + iowrite32be(tmp1, &regs->mac_addr_1);
6562 +}
6563 +
6564 +void fman_tgec_reset_stat(struct tgec_regs *regs)
6565 +{
6566 + uint32_t tmp;
6567 +
6568 + tmp = ioread32be(&regs->command_config);
6569 +
6570 + tmp |= CMD_CFG_STAT_CLR;
6571 +
6572 + iowrite32be(tmp, &regs->command_config);
6573 +
6574 + while (ioread32be(&regs->command_config) & CMD_CFG_STAT_CLR) ;
6575 +}
6576 +
6577 +#define GET_TGEC_CNTR_64(bn) \
6578 + (((uint64_t)ioread32be(&regs->bn ## _u) << 32) | \
6579 + ioread32be(&regs->bn ## _l))
6580 +
6581 +uint64_t fman_tgec_get_counter(struct tgec_regs *regs, enum tgec_counters reg_name)
6582 +{
6583 + uint64_t ret_val;
6584 +
6585 + switch (reg_name) {
6586 + case E_TGEC_COUNTER_R64:
6587 + ret_val = GET_TGEC_CNTR_64(r64);
6588 + break;
6589 + case E_TGEC_COUNTER_R127:
6590 + ret_val = GET_TGEC_CNTR_64(r127);
6591 + break;
6592 + case E_TGEC_COUNTER_R255:
6593 + ret_val = GET_TGEC_CNTR_64(r255);
6594 + break;
6595 + case E_TGEC_COUNTER_R511:
6596 + ret_val = GET_TGEC_CNTR_64(r511);
6597 + break;
6598 + case E_TGEC_COUNTER_R1023:
6599 + ret_val = GET_TGEC_CNTR_64(r1023);
6600 + break;
6601 + case E_TGEC_COUNTER_R1518:
6602 + ret_val = GET_TGEC_CNTR_64(r1518);
6603 + break;
6604 + case E_TGEC_COUNTER_R1519X:
6605 + ret_val = GET_TGEC_CNTR_64(r1519x);
6606 + break;
6607 + case E_TGEC_COUNTER_TRFRG:
6608 + ret_val = GET_TGEC_CNTR_64(trfrg);
6609 + break;
6610 + case E_TGEC_COUNTER_TRJBR:
6611 + ret_val = GET_TGEC_CNTR_64(trjbr);
6612 + break;
6613 + case E_TGEC_COUNTER_RDRP:
6614 + ret_val = GET_TGEC_CNTR_64(rdrp);
6615 + break;
6616 + case E_TGEC_COUNTER_RALN:
6617 + ret_val = GET_TGEC_CNTR_64(raln);
6618 + break;
6619 + case E_TGEC_COUNTER_TRUND:
6620 + ret_val = GET_TGEC_CNTR_64(trund);
6621 + break;
6622 + case E_TGEC_COUNTER_TROVR:
6623 + ret_val = GET_TGEC_CNTR_64(trovr);
6624 + break;
6625 + case E_TGEC_COUNTER_RXPF:
6626 + ret_val = GET_TGEC_CNTR_64(rxpf);
6627 + break;
6628 + case E_TGEC_COUNTER_TXPF:
6629 + ret_val = GET_TGEC_CNTR_64(txpf);
6630 + break;
6631 + case E_TGEC_COUNTER_ROCT:
6632 + ret_val = GET_TGEC_CNTR_64(roct);
6633 + break;
6634 + case E_TGEC_COUNTER_RMCA:
6635 + ret_val = GET_TGEC_CNTR_64(rmca);
6636 + break;
6637 + case E_TGEC_COUNTER_RBCA:
6638 + ret_val = GET_TGEC_CNTR_64(rbca);
6639 + break;
6640 + case E_TGEC_COUNTER_RPKT:
6641 + ret_val = GET_TGEC_CNTR_64(rpkt);
6642 + break;
6643 + case E_TGEC_COUNTER_RUCA:
6644 + ret_val = GET_TGEC_CNTR_64(ruca);
6645 + break;
6646 + case E_TGEC_COUNTER_RERR:
6647 + ret_val = GET_TGEC_CNTR_64(rerr);
6648 + break;
6649 + case E_TGEC_COUNTER_TOCT:
6650 + ret_val = GET_TGEC_CNTR_64(toct);
6651 + break;
6652 + case E_TGEC_COUNTER_TMCA:
6653 + ret_val = GET_TGEC_CNTR_64(tmca);
6654 + break;
6655 + case E_TGEC_COUNTER_TBCA:
6656 + ret_val = GET_TGEC_CNTR_64(tbca);
6657 + break;
6658 + case E_TGEC_COUNTER_TUCA:
6659 + ret_val = GET_TGEC_CNTR_64(tuca);
6660 + break;
6661 + case E_TGEC_COUNTER_TERR:
6662 + ret_val = GET_TGEC_CNTR_64(terr);
6663 + break;
6664 + default:
6665 + ret_val = 0;
6666 + }
6667 +
6668 + return ret_val;
6669 +}
6670 +
6671 +void fman_tgec_enable(struct tgec_regs *regs, bool apply_rx, bool apply_tx)
6672 +{
6673 + uint32_t tmp;
6674 +
6675 + tmp = ioread32be(&regs->command_config);
6676 + if (apply_rx)
6677 + tmp |= CMD_CFG_RX_EN;
6678 + if (apply_tx)
6679 + tmp |= CMD_CFG_TX_EN;
6680 + iowrite32be(tmp, &regs->command_config);
6681 +}
6682 +
6683 +void fman_tgec_disable(struct tgec_regs *regs, bool apply_rx, bool apply_tx)
6684 +{
6685 + uint32_t tmp_reg_32;
6686 +
6687 + tmp_reg_32 = ioread32be(&regs->command_config);
6688 + if (apply_rx)
6689 + tmp_reg_32 &= ~CMD_CFG_RX_EN;
6690 + if (apply_tx)
6691 + tmp_reg_32 &= ~CMD_CFG_TX_EN;
6692 + iowrite32be(tmp_reg_32, &regs->command_config);
6693 +}
6694 +
6695 +void fman_tgec_set_promiscuous(struct tgec_regs *regs, bool val)
6696 +{
6697 + uint32_t tmp;
6698 +
6699 + tmp = ioread32be(&regs->command_config);
6700 + if (val)
6701 + tmp |= CMD_CFG_PROMIS_EN;
6702 + else
6703 + tmp &= ~CMD_CFG_PROMIS_EN;
6704 + iowrite32be(tmp, &regs->command_config);
6705 +}
6706 +
6707 +void fman_tgec_reset_filter_table(struct tgec_regs *regs)
6708 +{
6709 + uint32_t i;
6710 + for (i = 0; i < 512; i++)
6711 + iowrite32be(i & ~TGEC_HASH_MCAST_EN, &regs->hashtable_ctrl);
6712 +}
6713 +
6714 +void fman_tgec_set_hash_table_entry(struct tgec_regs *regs, uint32_t crc)
6715 +{
6716 + uint32_t hash = (crc >> TGEC_HASH_MCAST_SHIFT) & TGEC_HASH_ADR_MSK; /* Take 9 MSB bits */
6717 + iowrite32be(hash | TGEC_HASH_MCAST_EN, &regs->hashtable_ctrl);
6718 +}
6719 +
6720 +void fman_tgec_set_hash_table(struct tgec_regs *regs, uint32_t value)
6721 +{
6722 + iowrite32be(value, &regs->hashtable_ctrl);
6723 +}
6724 +
6725 +void fman_tgec_set_tx_pause_frames(struct tgec_regs *regs, uint16_t pause_time)
6726 +{
6727 + iowrite32be((uint32_t)pause_time, &regs->pause_quant);
6728 +}
6729 +
6730 +void fman_tgec_set_rx_ignore_pause_frames(struct tgec_regs *regs, bool en)
6731 +{
6732 + uint32_t tmp;
6733 +
6734 + tmp = ioread32be(&regs->command_config);
6735 + if (en)
6736 + tmp |= CMD_CFG_PAUSE_IGNORE;
6737 + else
6738 + tmp &= ~CMD_CFG_PAUSE_IGNORE;
6739 + iowrite32be(tmp, &regs->command_config);
6740 +}
6741 +
6742 +void fman_tgec_enable_1588_time_stamp(struct tgec_regs *regs, bool en)
6743 +{
6744 + uint32_t tmp;
6745 +
6746 + tmp = ioread32be(&regs->command_config);
6747 + if (en)
6748 + tmp |= CMD_CFG_EN_TIMESTAMP;
6749 + else
6750 + tmp &= ~CMD_CFG_EN_TIMESTAMP;
6751 + iowrite32be(tmp, &regs->command_config);
6752 +}
6753 +
6754 +uint32_t fman_tgec_get_event(struct tgec_regs *regs, uint32_t ev_mask)
6755 +{
6756 + return ioread32be(&regs->ievent) & ev_mask;
6757 +}
6758 +
6759 +void fman_tgec_ack_event(struct tgec_regs *regs, uint32_t ev_mask)
6760 +{
6761 + iowrite32be(ev_mask, &regs->ievent);
6762 +}
6763 +
6764 +uint32_t fman_tgec_get_interrupt_mask(struct tgec_regs *regs)
6765 +{
6766 + return ioread32be(&regs->imask);
6767 +}
6768 +
6769 +void fman_tgec_add_addr_in_paddr(struct tgec_regs *regs, uint8_t *adr)
6770 +{
6771 + uint32_t tmp0, tmp1;
6772 +
6773 + tmp0 = (uint32_t)(adr[0] |
6774 + adr[1] << 8 |
6775 + adr[2] << 16 |
6776 + adr[3] << 24);
6777 + tmp1 = (uint32_t)(adr[4] | adr[5] << 8);
6778 + iowrite32be(tmp0, &regs->mac_addr_2);
6779 + iowrite32be(tmp1, &regs->mac_addr_3);
6780 +}
6781 +
6782 +void fman_tgec_clear_addr_in_paddr(struct tgec_regs *regs)
6783 +{
6784 + iowrite32be(0, &regs->mac_addr_2);
6785 + iowrite32be(0, &regs->mac_addr_3);
6786 +}
6787 +
6788 +uint32_t fman_tgec_get_revision(struct tgec_regs *regs)
6789 +{
6790 + return ioread32be(&regs->tgec_id);
6791 +}
6792 +
6793 +void fman_tgec_enable_interrupt(struct tgec_regs *regs, uint32_t ev_mask)
6794 +{
6795 + iowrite32be(ioread32be(&regs->imask) | ev_mask, &regs->imask);
6796 +}
6797 +
6798 +void fman_tgec_disable_interrupt(struct tgec_regs *regs, uint32_t ev_mask)
6799 +{
6800 + iowrite32be(ioread32be(&regs->imask) & ~ev_mask, &regs->imask);
6801 +}
6802 +
6803 +uint16_t fman_tgec_get_max_frame_len(struct tgec_regs *regs)
6804 +{
6805 + return (uint16_t) ioread32be(&regs->maxfrm);
6806 +}
6807 +
6808 +void fman_tgec_defconfig(struct tgec_cfg *cfg)
6809 +{
6810 + cfg->wan_mode_enable = DEFAULT_WAN_MODE_ENABLE;
6811 + cfg->promiscuous_mode_enable = DEFAULT_PROMISCUOUS_MODE_ENABLE;
6812 + cfg->pause_forward_enable = DEFAULT_PAUSE_FORWARD_ENABLE;
6813 + cfg->pause_ignore = DEFAULT_PAUSE_IGNORE;
6814 + cfg->tx_addr_ins_enable = DEFAULT_TX_ADDR_INS_ENABLE;
6815 + cfg->loopback_enable = DEFAULT_LOOPBACK_ENABLE;
6816 + cfg->cmd_frame_enable = DEFAULT_CMD_FRAME_ENABLE;
6817 + cfg->rx_error_discard = DEFAULT_RX_ERROR_DISCARD;
6818 + cfg->send_idle_enable = DEFAULT_SEND_IDLE_ENABLE;
6819 + cfg->no_length_check_enable = DEFAULT_NO_LENGTH_CHECK_ENABLE;
6820 + cfg->lgth_check_nostdr = DEFAULT_LGTH_CHECK_NOSTDR;
6821 + cfg->time_stamp_enable = DEFAULT_TIME_STAMP_ENABLE;
6822 + cfg->tx_ipg_length = DEFAULT_TX_IPG_LENGTH;
6823 + cfg->max_frame_length = DEFAULT_MAX_FRAME_LENGTH;
6824 + cfg->pause_quant = DEFAULT_PAUSE_QUANT;
6825 +#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
6826 + cfg->skip_fman11_workaround = FALSE;
6827 +#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
6828 +}
6829 +
6830 +int fman_tgec_init(struct tgec_regs *regs, struct tgec_cfg *cfg,
6831 + uint32_t exception_mask)
6832 +{
6833 + uint32_t tmp;
6834 +
6835 + /* Config */
6836 + tmp = 0x40; /* CRC forward */
6837 + if (cfg->wan_mode_enable)
6838 + tmp |= CMD_CFG_WAN_MODE;
6839 + if (cfg->promiscuous_mode_enable)
6840 + tmp |= CMD_CFG_PROMIS_EN;
6841 + if (cfg->pause_forward_enable)
6842 + tmp |= CMD_CFG_PAUSE_FWD;
6843 + if (cfg->pause_ignore)
6844 + tmp |= CMD_CFG_PAUSE_IGNORE;
6845 + if (cfg->tx_addr_ins_enable)
6846 + tmp |= CMD_CFG_TX_ADDR_INS;
6847 + if (cfg->loopback_enable)
6848 + tmp |= CMD_CFG_LOOPBACK_EN;
6849 + if (cfg->cmd_frame_enable)
6850 + tmp |= CMD_CFG_CMD_FRM_EN;
6851 + if (cfg->rx_error_discard)
6852 + tmp |= CMD_CFG_RX_ER_DISC;
6853 + if (cfg->send_idle_enable)
6854 + tmp |= CMD_CFG_SEND_IDLE;
6855 + if (cfg->no_length_check_enable)
6856 + tmp |= CMD_CFG_NO_LEN_CHK;
6857 + if (cfg->time_stamp_enable)
6858 + tmp |= CMD_CFG_EN_TIMESTAMP;
6859 + iowrite32be(tmp, &regs->command_config);
6860 +
6861 + /* Max Frame Length */
6862 + iowrite32be((uint32_t)cfg->max_frame_length, &regs->maxfrm);
6863 + /* Pause Time */
6864 + iowrite32be(cfg->pause_quant, &regs->pause_quant);
6865 +
6866 + /* clear all pending events and set-up interrupts */
6867 + fman_tgec_ack_event(regs, 0xffffffff);
6868 + fman_tgec_enable_interrupt(regs, exception_mask);
6869 +
6870 + return 0;
6871 +}
6872 +
6873 +void fman_tgec_set_erratum_tx_fifo_corruption_10gmac_a007(struct tgec_regs *regs)
6874 +{
6875 + uint32_t tmp;
6876 +
6877 + /* restore the default tx ipg Length */
6878 + tmp = (ioread32be(&regs->tx_ipg_len) & ~TGEC_TX_IPG_LENGTH_MASK) | 12;
6879 +
6880 + iowrite32be(tmp, &regs->tx_ipg_len);
6881 +}
6882 --- /dev/null
6883 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.c
6884 @@ -0,0 +1,1088 @@
6885 +/*
6886 + * Copyright 2008-2012 Freescale Semiconductor Inc.
6887 + *
6888 + * Redistribution and use in source and binary forms, with or without
6889 + * modification, are permitted provided that the following conditions are met:
6890 + * * Redistributions of source code must retain the above copyright
6891 + * notice, this list of conditions and the following disclaimer.
6892 + * * Redistributions in binary form must reproduce the above copyright
6893 + * notice, this list of conditions and the following disclaimer in the
6894 + * documentation and/or other materials provided with the distribution.
6895 + * * Neither the name of Freescale Semiconductor nor the
6896 + * names of its contributors may be used to endorse or promote products
6897 + * derived from this software without specific prior written permission.
6898 + *
6899 + *
6900 + * ALTERNATIVELY, this software may be distributed under the terms of the
6901 + * GNU General Public License ("GPL") as published by the Free Software
6902 + * Foundation, either version 2 of that License or (at your option) any
6903 + * later version.
6904 + *
6905 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
6906 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6907 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
6908 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
6909 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
6910 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
6911 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
6912 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
6913 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
6914 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6915 + */
6916 +
6917 +
6918 +/******************************************************************************
6919 + @File memac.c
6920 +
6921 + @Description FM mEMAC driver
6922 +*//***************************************************************************/
6923 +
6924 +#include "std_ext.h"
6925 +#include "string_ext.h"
6926 +#include "error_ext.h"
6927 +#include "xx_ext.h"
6928 +#include "endian_ext.h"
6929 +#include "debug_ext.h"
6930 +
6931 +#include "fm_common.h"
6932 +#include "memac.h"
6933 +
6934 +
6935 +/*****************************************************************************/
6936 +/* Internal routines */
6937 +/*****************************************************************************/
6938 +
6939 +/* ......................................................................... */
6940 +
6941 +static uint32_t GetMacAddrHashCode(uint64_t ethAddr)
6942 +{
6943 + uint64_t mask1, mask2;
6944 + uint32_t xorVal = 0;
6945 + uint8_t i, j;
6946 +
6947 + for (i=0; i<6; i++)
6948 + {
6949 + mask1 = ethAddr & (uint64_t)0x01;
6950 + ethAddr >>= 1;
6951 +
6952 + for (j=0; j<7; j++)
6953 + {
6954 + mask2 = ethAddr & (uint64_t)0x01;
6955 + mask1 ^= mask2;
6956 + ethAddr >>= 1;
6957 + }
6958 +
6959 + xorVal |= (mask1 << (5-i));
6960 + }
6961 +
6962 + return xorVal;
6963 +}
6964 +
6965 +/* ......................................................................... */
6966 +
6967 +static void SetupSgmiiInternalPhy(t_Memac *p_Memac, uint8_t phyAddr)
6968 +{
6969 + uint16_t tmpReg16;
6970 + e_EnetMode enetMode;
6971 +
6972 + /* In case the higher MACs are used (i.e. the MACs that should support 10G),
6973 + speed=10000 is provided for SGMII ports. Temporary modify enet mode
6974 + to 1G one, so MII functions can work correctly. */
6975 + enetMode = p_Memac->enetMode;
6976 +
6977 + /* SGMII mode + AN enable */
6978 + tmpReg16 = PHY_SGMII_IF_MODE_AN | PHY_SGMII_IF_MODE_SGMII;
6979 + if ((p_Memac->enetMode) == e_ENET_MODE_SGMII_2500)
6980 + tmpReg16 = PHY_SGMII_CR_PHY_RESET | PHY_SGMII_IF_SPEED_GIGABIT | PHY_SGMII_IF_MODE_SGMII;
6981 +
6982 + p_Memac->enetMode = MAKE_ENET_MODE(ENET_INTERFACE_FROM_MODE(p_Memac->enetMode), e_ENET_SPEED_1000);
6983 + MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x14, tmpReg16);
6984 +
6985 + /* Device ability according to SGMII specification */
6986 + tmpReg16 = PHY_SGMII_DEV_ABILITY_SGMII;
6987 + MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x4, tmpReg16);
6988 +
6989 + /* Adjust link timer for SGMII -
6990 + According to Cisco SGMII specification the timer should be 1.6 ms.
6991 + The link_timer register is configured in units of the clock.
6992 + - When running as 1G SGMII, Serdes clock is 125 MHz, so
6993 + unit = 1 / (125*10^6 Hz) = 8 ns.
6994 + 1.6 ms in units of 8 ns = 1.6ms / 8ns = 2 * 10^5 = 0x30d40
6995 + - When running as 2.5G SGMII, Serdes clock is 312.5 MHz, so
6996 + unit = 1 / (312.5*10^6 Hz) = 3.2 ns.
6997 + 1.6 ms in units of 3.2 ns = 1.6ms / 3.2ns = 5 * 10^5 = 0x7a120.
6998 + Since link_timer value of 1G SGMII will be too short for 2.5 SGMII,
6999 + we always set up here a value of 2.5 SGMII. */
7000 + MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x13, 0x0007);
7001 + MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x12, 0xa120);
7002 +
7003 + /* Restart AN */
7004 + tmpReg16 = PHY_SGMII_CR_DEF_VAL | PHY_SGMII_CR_RESET_AN;
7005 + MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x0, tmpReg16);
7006 +
7007 + /* Restore original enet mode */
7008 + p_Memac->enetMode = enetMode;
7009 +}
7010 +
7011 +/* ......................................................................... */
7012 +
7013 +static void SetupSgmiiInternalPhyBaseX(t_Memac *p_Memac, uint8_t phyAddr)
7014 +{
7015 + uint16_t tmpReg16;
7016 + e_EnetMode enetMode;
7017 +
7018 + /* In case the higher MACs are used (i.e. the MACs that should support 10G),
7019 + speed=10000 is provided for SGMII ports. Temporary modify enet mode
7020 + to 1G one, so MII functions can work correctly. */
7021 + enetMode = p_Memac->enetMode;
7022 + p_Memac->enetMode = MAKE_ENET_MODE(ENET_INTERFACE_FROM_MODE(p_Memac->enetMode), e_ENET_SPEED_1000);
7023 +
7024 + /* 1000BaseX mode */
7025 + tmpReg16 = PHY_SGMII_IF_MODE_1000X;
7026 + MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x14, tmpReg16);
7027 +
7028 + /* AN Device capability */
7029 + tmpReg16 = PHY_SGMII_DEV_ABILITY_1000X;
7030 + MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x4, tmpReg16);
7031 +
7032 + /* Adjust link timer for SGMII -
7033 + For Serdes 1000BaseX auto-negotiation the timer should be 10 ms.
7034 + The link_timer register is configured in units of the clock.
7035 + - When running as 1G SGMII, Serdes clock is 125 MHz, so
7036 + unit = 1 / (125*10^6 Hz) = 8 ns.
7037 + 10 ms in units of 8 ns = 10ms / 8ns = 1250000 = 0x1312d0
7038 + - When running as 2.5G SGMII, Serdes clock is 312.5 MHz, so
7039 + unit = 1 / (312.5*10^6 Hz) = 3.2 ns.
7040 + 10 ms in units of 3.2 ns = 10ms / 3.2ns = 3125000 = 0x2faf08.
7041 + Since link_timer value of 1G SGMII will be too short for 2.5 SGMII,
7042 + we always set up here a value of 2.5 SGMII. */
7043 + MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x13, 0x002f);
7044 + MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x12, 0xaf08);
7045 +
7046 + /* Restart AN */
7047 + tmpReg16 = PHY_SGMII_CR_DEF_VAL | PHY_SGMII_CR_RESET_AN;
7048 + MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x0, tmpReg16);
7049 +
7050 + /* Restore original enet mode */
7051 + p_Memac->enetMode = enetMode;
7052 +}
7053 +
7054 +/* ......................................................................... */
7055 +
7056 +static t_Error CheckInitParameters(t_Memac *p_Memac)
7057 +{
7058 + e_FmMacType portType;
7059 +
7060 + portType = ((ENET_SPEED_FROM_MODE(p_Memac->enetMode) < e_ENET_SPEED_10000) ? e_FM_MAC_1G : e_FM_MAC_10G);
7061 +
7062 +#if (FM_MAX_NUM_OF_10G_MACS > 0)
7063 + if ((portType == e_FM_MAC_10G) && (p_Memac->macId >= FM_MAX_NUM_OF_10G_MACS))
7064 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("10G MAC ID must be less than %d", FM_MAX_NUM_OF_10G_MACS));
7065 +#endif /* (FM_MAX_NUM_OF_10G_MACS > 0) */
7066 +
7067 + if ((portType == e_FM_MAC_1G) && (p_Memac->macId >= FM_MAX_NUM_OF_1G_MACS))
7068 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("1G MAC ID must be less than %d", FM_MAX_NUM_OF_1G_MACS));
7069 + if (p_Memac->addr == 0)
7070 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Ethernet MAC must have a valid MAC address"));
7071 + if (!p_Memac->f_Exception)
7072 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Uninitialized f_Exception"));
7073 + if (!p_Memac->f_Event)
7074 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Uninitialized f_Event"));
7075 +#ifdef FM_LEN_CHECK_ERRATA_FMAN_SW002
7076 + if (!p_Memac->p_MemacDriverParam->no_length_check_enable)
7077 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("LengthCheck!"));
7078 +#endif /* FM_LEN_CHECK_ERRATA_FMAN_SW002 */
7079 +
7080 + return E_OK;
7081 +}
7082 +
7083 +/* ........................................................................... */
7084 +
7085 +static void MemacErrException(t_Handle h_Memac)
7086 +{
7087 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7088 + uint32_t event, imask;
7089 +
7090 + event = fman_memac_get_event(p_Memac->p_MemMap, 0xffffffff);
7091 + imask = fman_memac_get_interrupt_mask(p_Memac->p_MemMap);
7092 +
7093 + /* Imask include both error and notification/event bits.
7094 + Leaving only error bits enabled by imask.
7095 + The imask error bits are shifted by 16 bits offset from
7096 + their corresponding location in the ievent - hence the >> 16 */
7097 + event &= ((imask & MEMAC_ALL_ERRS_IMASK) >> 16);
7098 +
7099 + fman_memac_ack_event(p_Memac->p_MemMap, event);
7100 +
7101 + if (event & MEMAC_IEVNT_TS_ECC_ER)
7102 + p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_TS_FIFO_ECC_ERR);
7103 + if (event & MEMAC_IEVNT_TX_ECC_ER)
7104 + p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_10G_1TX_ECC_ER);
7105 + if (event & MEMAC_IEVNT_RX_ECC_ER)
7106 + p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_10G_RX_ECC_ER);
7107 +}
7108 +
7109 +static void MemacException(t_Handle h_Memac)
7110 +{
7111 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7112 + uint32_t event, imask;
7113 +
7114 + event = fman_memac_get_event(p_Memac->p_MemMap, 0xffffffff);
7115 + imask = fman_memac_get_interrupt_mask(p_Memac->p_MemMap);
7116 +
7117 + /* Imask include both error and notification/event bits.
7118 + Leaving only error bits enabled by imask.
7119 + The imask error bits are shifted by 16 bits offset from
7120 + their corresponding location in the ievent - hence the >> 16 */
7121 + event &= ((imask & MEMAC_ALL_ERRS_IMASK) >> 16);
7122 +
7123 + fman_memac_ack_event(p_Memac->p_MemMap, event);
7124 +
7125 + if (event & MEMAC_IEVNT_MGI)
7126 + p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_MAGIC_PACKET_INDICATION);
7127 +}
7128 +
7129 +/* ......................................................................... */
7130 +
7131 +static void FreeInitResources(t_Memac *p_Memac)
7132 +{
7133 + e_FmMacType portType;
7134 +
7135 + portType =
7136 + ((ENET_SPEED_FROM_MODE(p_Memac->enetMode) < e_ENET_SPEED_10000) ? e_FM_MAC_1G : e_FM_MAC_10G);
7137 +
7138 + if (portType == e_FM_MAC_10G)
7139 + FmUnregisterIntr(p_Memac->fmMacControllerDriver.h_Fm, e_FM_MOD_10G_MAC, p_Memac->macId, e_FM_INTR_TYPE_ERR);
7140 + else
7141 + FmUnregisterIntr(p_Memac->fmMacControllerDriver.h_Fm, e_FM_MOD_1G_MAC, p_Memac->macId, e_FM_INTR_TYPE_ERR);
7142 +
7143 + /* release the driver's group hash table */
7144 + FreeHashTable(p_Memac->p_MulticastAddrHash);
7145 + p_Memac->p_MulticastAddrHash = NULL;
7146 +
7147 + /* release the driver's individual hash table */
7148 + FreeHashTable(p_Memac->p_UnicastAddrHash);
7149 + p_Memac->p_UnicastAddrHash = NULL;
7150 +}
7151 +
7152 +
7153 +/*****************************************************************************/
7154 +/* mEMAC API routines */
7155 +/*****************************************************************************/
7156 +
7157 +/* ......................................................................... */
7158 +
7159 +static t_Error MemacEnable(t_Handle h_Memac, e_CommMode mode)
7160 +{
7161 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7162 +
7163 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7164 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7165 +
7166 + fman_memac_enable(p_Memac->p_MemMap, (mode & e_COMM_MODE_RX), (mode & e_COMM_MODE_TX));
7167 +
7168 + return E_OK;
7169 +}
7170 +
7171 +/* ......................................................................... */
7172 +
7173 +static t_Error MemacDisable (t_Handle h_Memac, e_CommMode mode)
7174 +{
7175 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7176 +
7177 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7178 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7179 +
7180 + fman_memac_disable(p_Memac->p_MemMap, (mode & e_COMM_MODE_RX), (mode & e_COMM_MODE_TX));
7181 +
7182 + return E_OK;
7183 +}
7184 +
7185 +/* ......................................................................... */
7186 +
7187 +static t_Error MemacSetPromiscuous(t_Handle h_Memac, bool newVal)
7188 +{
7189 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7190 +
7191 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7192 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7193 +
7194 + fman_memac_set_promiscuous(p_Memac->p_MemMap, newVal);
7195 +
7196 + return E_OK;
7197 +}
7198 +
7199 +/* .............................................................................. */
7200 +
7201 +static t_Error MemacAdjustLink(t_Handle h_Memac, e_EnetSpeed speed, bool fullDuplex)
7202 +{
7203 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7204 +
7205 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7206 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7207 +
7208 + if ((speed >= e_ENET_SPEED_1000) && (!fullDuplex))
7209 + RETURN_ERROR(MAJOR, E_CONFLICT,
7210 + ("Ethernet MAC 1G or 10G does not support half-duplex"));
7211 +
7212 + fman_memac_adjust_link(p_Memac->p_MemMap,
7213 + (enum enet_interface)ENET_INTERFACE_FROM_MODE(p_Memac->enetMode),
7214 + (enum enet_speed)speed,
7215 + fullDuplex);
7216 + return E_OK;
7217 +}
7218 +
7219 +
7220 +/*****************************************************************************/
7221 +/* Memac Configs modification functions */
7222 +/*****************************************************************************/
7223 +
7224 +/* ......................................................................... */
7225 +
7226 +static t_Error MemacConfigLoopback(t_Handle h_Memac, bool newVal)
7227 +{
7228 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7229 +
7230 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7231 + SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7232 +
7233 + p_Memac->p_MemacDriverParam->loopback_enable = newVal;
7234 +
7235 + return E_OK;
7236 +}
7237 +
7238 +/* ......................................................................... */
7239 +
7240 +static t_Error MemacConfigWan(t_Handle h_Memac, bool newVal)
7241 +{
7242 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7243 +
7244 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7245 + SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7246 +
7247 + p_Memac->p_MemacDriverParam->wan_mode_enable = newVal;
7248 +
7249 + return E_OK;
7250 +}
7251 +
7252 +/* ......................................................................... */
7253 +
7254 +static t_Error MemacConfigMaxFrameLength(t_Handle h_Memac, uint16_t newVal)
7255 +{
7256 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7257 +
7258 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7259 + SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7260 +
7261 + p_Memac->p_MemacDriverParam->max_frame_length = newVal;
7262 +
7263 + return E_OK;
7264 +}
7265 +
7266 +/* ......................................................................... */
7267 +
7268 +static t_Error MemacConfigPad(t_Handle h_Memac, bool newVal)
7269 +{
7270 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7271 +
7272 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7273 + SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7274 +
7275 + p_Memac->p_MemacDriverParam->pad_enable = newVal;
7276 +
7277 + return E_OK;
7278 +}
7279 +
7280 +/* ......................................................................... */
7281 +
7282 +static t_Error MemacConfigLengthCheck(t_Handle h_Memac, bool newVal)
7283 +{
7284 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7285 +
7286 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7287 + SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7288 +
7289 + p_Memac->p_MemacDriverParam->no_length_check_enable = !newVal;
7290 +
7291 + return E_OK;
7292 +}
7293 +
7294 +/* ......................................................................... */
7295 +
7296 +static t_Error MemacConfigException(t_Handle h_Memac, e_FmMacExceptions exception, bool enable)
7297 +{
7298 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7299 + uint32_t bitMask = 0;
7300 +
7301 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7302 + SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7303 +
7304 + GET_EXCEPTION_FLAG(bitMask, exception);
7305 + if (bitMask)
7306 + {
7307 + if (enable)
7308 + p_Memac->exceptions |= bitMask;
7309 + else
7310 + p_Memac->exceptions &= ~bitMask;
7311 + }
7312 + else
7313 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
7314 +
7315 + return E_OK;
7316 +}
7317 +
7318 +/* ......................................................................... */
7319 +
7320 +static t_Error MemacConfigResetOnInit(t_Handle h_Memac, bool enable)
7321 +{
7322 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7323 +
7324 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7325 + SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7326 +
7327 + p_Memac->p_MemacDriverParam->reset_on_init = enable;
7328 +
7329 + return E_OK;
7330 +}
7331 +
7332 +
7333 +/*****************************************************************************/
7334 +/* Memac Run Time API functions */
7335 +/*****************************************************************************/
7336 +
7337 +/* ......................................................................... */
7338 +
7339 +static t_Error MemacSetTxPauseFrames(t_Handle h_Memac,
7340 + uint8_t priority,
7341 + uint16_t pauseTime,
7342 + uint16_t threshTime)
7343 +{
7344 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7345 +
7346 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_STATE);
7347 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7348 +
7349 + if (priority != 0xFF)
7350 + {
7351 + bool PortConfigured, PreFetchEnabled;
7352 +
7353 + if (FmGetTnumAgingPeriod(p_Memac->fmMacControllerDriver.h_Fm) == 0)
7354 + RETURN_ERROR(MAJOR, E_CONFLICT, ("For PFC operation, TNUM aging must be enabled"));
7355 +
7356 + FmGetPortPreFetchConfiguration(p_Memac->fmMacControllerDriver.h_Fm,
7357 + p_Memac->fmMacControllerDriver.macId,
7358 + &PortConfigured,
7359 + &PreFetchEnabled);
7360 +
7361 + if ((ENET_SPEED_FROM_MODE(p_Memac->fmMacControllerDriver.enetMode) == e_ENET_SPEED_1000) && !PortConfigured)
7362 + DBG(INFO, ("For PFC correct operation, prefetch must be configured on the FM Tx PORT"));
7363 +
7364 + if ((ENET_SPEED_FROM_MODE(p_Memac->fmMacControllerDriver.enetMode) == e_ENET_SPEED_1000) && PortConfigured && !PreFetchEnabled)
7365 + DBG(WARNING, ("For PFC correct operation, prefetch must be configured on the FM Tx PORT"));
7366 + }
7367 +
7368 + fman_memac_set_tx_pause_frames(p_Memac->p_MemMap, priority, pauseTime, threshTime);
7369 +
7370 + return E_OK;
7371 +}
7372 +
7373 +/* ......................................................................... */
7374 +
7375 +static t_Error MemacSetTxAutoPauseFrames(t_Handle h_Memac,
7376 + uint16_t pauseTime)
7377 +{
7378 + return MemacSetTxPauseFrames(h_Memac, FM_MAC_NO_PFC, pauseTime, 0);
7379 +}
7380 +
7381 +/* ......................................................................... */
7382 +
7383 +static t_Error MemacSetRxIgnorePauseFrames(t_Handle h_Memac, bool en)
7384 +{
7385 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7386 +
7387 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_STATE);
7388 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7389 +
7390 + fman_memac_set_rx_ignore_pause_frames(p_Memac->p_MemMap, en);
7391 +
7392 + return E_OK;
7393 +}
7394 +
7395 +/* ......................................................................... */
7396 +
7397 +static t_Error MemacSetWakeOnLan(t_Handle h_Memac, bool en)
7398 +{
7399 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7400 +
7401 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_STATE);
7402 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7403 +
7404 + fman_memac_set_wol(p_Memac->p_MemMap, en);
7405 +
7406 + return E_OK;
7407 +}
7408 +
7409 +/* .............................................................................. */
7410 +
7411 +static t_Error MemacEnable1588TimeStamp(t_Handle h_Memac)
7412 +{
7413 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7414 +
7415 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7416 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7417 +UNUSED(p_Memac);
7418 +DBG(WARNING, ("mEMAC has 1588 always enabled!"));
7419 +
7420 + return E_OK;
7421 +}
7422 +
7423 +/* Counters handling */
7424 +/* ......................................................................... */
7425 +
7426 +static t_Error MemacGetStatistics(t_Handle h_Memac, t_FmMacStatistics *p_Statistics)
7427 +{
7428 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7429 +
7430 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER);
7431 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7432 + SANITY_CHECK_RETURN_ERROR(p_Statistics, E_NULL_POINTER);
7433 +
7434 + p_Statistics->eStatPkts64 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R64);
7435 + p_Statistics->eStatPkts65to127 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R127);
7436 + p_Statistics->eStatPkts128to255 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R255);
7437 + p_Statistics->eStatPkts256to511 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R511);
7438 + p_Statistics->eStatPkts512to1023 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1023);
7439 + p_Statistics->eStatPkts1024to1518 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1518);
7440 + p_Statistics->eStatPkts1519to1522 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1519X);
7441 +/* */
7442 + p_Statistics->eStatFragments = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RFRG);
7443 + p_Statistics->eStatJabbers = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RJBR);
7444 +
7445 + p_Statistics->eStatsDropEvents = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RDRP);
7446 + p_Statistics->eStatCRCAlignErrors = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RALN);
7447 +
7448 + p_Statistics->eStatUndersizePkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TUND);
7449 + p_Statistics->eStatOversizePkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_ROVR);
7450 +/* Pause */
7451 + p_Statistics->reStatPause = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RXPF);
7452 + p_Statistics->teStatPause = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TXPF);
7453 +
7454 +/* MIB II */
7455 + p_Statistics->ifInOctets = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_ROCT);
7456 + p_Statistics->ifInUcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RUCA);
7457 + p_Statistics->ifInMcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RMCA);
7458 + p_Statistics->ifInBcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RBCA);
7459 + p_Statistics->ifInPkts = p_Statistics->ifInUcastPkts
7460 + + p_Statistics->ifInMcastPkts
7461 + + p_Statistics->ifInBcastPkts;
7462 + p_Statistics->ifInDiscards = 0;
7463 + p_Statistics->ifInErrors = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RERR);
7464 +
7465 + p_Statistics->ifOutOctets = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TOCT);
7466 + p_Statistics->ifOutUcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TUCA);
7467 + p_Statistics->ifOutMcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TMCA);
7468 + p_Statistics->ifOutBcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TBCA);
7469 + p_Statistics->ifOutPkts = p_Statistics->ifOutUcastPkts
7470 + + p_Statistics->ifOutMcastPkts
7471 + + p_Statistics->ifOutBcastPkts;
7472 + p_Statistics->ifOutDiscards = 0;
7473 + p_Statistics->ifOutErrors = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TERR);
7474 +
7475 + return E_OK;
7476 +}
7477 +
7478 +/* ......................................................................... */
7479 +
7480 +static t_Error MemacModifyMacAddress (t_Handle h_Memac, t_EnetAddr *p_EnetAddr)
7481 +{
7482 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7483 +
7484 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER);
7485 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7486 +
7487 + fman_memac_add_addr_in_paddr(p_Memac->p_MemMap, (uint8_t *)(*p_EnetAddr), 0);
7488 +
7489 + return E_OK;
7490 +}
7491 +
7492 +/* ......................................................................... */
7493 +
7494 +static t_Error MemacResetCounters (t_Handle h_Memac)
7495 +{
7496 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7497 +
7498 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7499 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7500 +
7501 + fman_memac_reset_stat(p_Memac->p_MemMap);
7502 +
7503 + return E_OK;
7504 +}
7505 +
7506 +/* ......................................................................... */
7507 +
7508 +static t_Error MemacAddExactMatchMacAddress(t_Handle h_Memac, t_EnetAddr *p_EthAddr)
7509 +{
7510 + t_Memac *p_Memac = (t_Memac *) h_Memac;
7511 + uint64_t ethAddr;
7512 + uint8_t paddrNum;
7513 +
7514 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7515 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7516 +
7517 + ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
7518 +
7519 + if (ethAddr & GROUP_ADDRESS)
7520 + /* Multicast address has no effect in PADDR */
7521 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Multicast address"));
7522 +
7523 + /* Make sure no PADDR contains this address */
7524 + for (paddrNum = 0; paddrNum < MEMAC_NUM_OF_PADDRS; paddrNum++)
7525 + if (p_Memac->indAddrRegUsed[paddrNum])
7526 + if (p_Memac->paddr[paddrNum] == ethAddr)
7527 + RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, NO_MSG);
7528 +
7529 + /* Find first unused PADDR */
7530 + for (paddrNum = 0; paddrNum < MEMAC_NUM_OF_PADDRS; paddrNum++)
7531 + if (!(p_Memac->indAddrRegUsed[paddrNum]))
7532 + {
7533 + /* mark this PADDR as used */
7534 + p_Memac->indAddrRegUsed[paddrNum] = TRUE;
7535 + /* store address */
7536 + p_Memac->paddr[paddrNum] = ethAddr;
7537 +
7538 + /* put in hardware */
7539 + fman_memac_add_addr_in_paddr(p_Memac->p_MemMap, (uint8_t*)(*p_EthAddr), paddrNum);
7540 + p_Memac->numOfIndAddrInRegs++;
7541 +
7542 + return E_OK;
7543 + }
7544 +
7545 + /* No free PADDR */
7546 + RETURN_ERROR(MAJOR, E_FULL, NO_MSG);
7547 +}
7548 +
7549 +/* ......................................................................... */
7550 +
7551 +static t_Error MemacDelExactMatchMacAddress(t_Handle h_Memac, t_EnetAddr *p_EthAddr)
7552 +{
7553 + t_Memac *p_Memac = (t_Memac *) h_Memac;
7554 + uint64_t ethAddr;
7555 + uint8_t paddrNum;
7556 +
7557 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7558 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7559 +
7560 + ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
7561 +
7562 + /* Find used PADDR containing this address */
7563 + for (paddrNum = 0; paddrNum < MEMAC_NUM_OF_PADDRS; paddrNum++)
7564 + {
7565 + if ((p_Memac->indAddrRegUsed[paddrNum]) &&
7566 + (p_Memac->paddr[paddrNum] == ethAddr))
7567 + {
7568 + /* mark this PADDR as not used */
7569 + p_Memac->indAddrRegUsed[paddrNum] = FALSE;
7570 + /* clear in hardware */
7571 + fman_memac_clear_addr_in_paddr(p_Memac->p_MemMap, paddrNum);
7572 + p_Memac->numOfIndAddrInRegs--;
7573 +
7574 + return E_OK;
7575 + }
7576 + }
7577 +
7578 + RETURN_ERROR(MAJOR, E_NOT_FOUND, NO_MSG);
7579 +}
7580 +
7581 +/* ......................................................................... */
7582 +
7583 +static t_Error MemacGetId(t_Handle h_Memac, uint32_t *macId)
7584 +{
7585 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7586 +
7587 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7588 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7589 +
7590 + *macId = p_Memac->macId;
7591 +
7592 + return E_OK;
7593 +}
7594 +
7595 +/* ......................................................................... */
7596 +
7597 +
7598 +static t_Error MemacAddHashMacAddress(t_Handle h_Memac, t_EnetAddr *p_EthAddr)
7599 +{
7600 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7601 + t_EthHashEntry *p_HashEntry;
7602 + uint32_t hash;
7603 + uint64_t ethAddr;
7604 +
7605 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER);
7606 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7607 +
7608 + ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
7609 +
7610 + if (!(ethAddr & GROUP_ADDRESS))
7611 + /* Unicast addresses not supported in hash */
7612 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unicast Address"));
7613 +
7614 + hash = GetMacAddrHashCode(ethAddr) & HASH_CTRL_ADDR_MASK;
7615 +
7616 + /* Create element to be added to the driver hash table */
7617 + p_HashEntry = (t_EthHashEntry *)XX_Malloc(sizeof(t_EthHashEntry));
7618 + p_HashEntry->addr = ethAddr;
7619 + INIT_LIST(&p_HashEntry->node);
7620 +
7621 + LIST_AddToTail(&(p_HashEntry->node), &(p_Memac->p_MulticastAddrHash->p_Lsts[hash]));
7622 + fman_memac_set_hash_table(p_Memac->p_MemMap, (hash | HASH_CTRL_MCAST_EN));
7623 +
7624 + return E_OK;
7625 +}
7626 +
7627 +/* ......................................................................... */
7628 +
7629 +static t_Error MemacDelHashMacAddress(t_Handle h_Memac, t_EnetAddr *p_EthAddr)
7630 +{
7631 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7632 + t_EthHashEntry *p_HashEntry = NULL;
7633 + t_List *p_Pos;
7634 + uint32_t hash;
7635 + uint64_t ethAddr;
7636 +
7637 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER);
7638 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7639 +
7640 + ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
7641 +
7642 + hash = GetMacAddrHashCode(ethAddr) & HASH_CTRL_ADDR_MASK;
7643 +
7644 + LIST_FOR_EACH(p_Pos, &(p_Memac->p_MulticastAddrHash->p_Lsts[hash]))
7645 + {
7646 + p_HashEntry = ETH_HASH_ENTRY_OBJ(p_Pos);
7647 + if (p_HashEntry->addr == ethAddr)
7648 + {
7649 + LIST_DelAndInit(&p_HashEntry->node);
7650 + XX_Free(p_HashEntry);
7651 + break;
7652 + }
7653 + }
7654 + if (LIST_IsEmpty(&p_Memac->p_MulticastAddrHash->p_Lsts[hash]))
7655 + fman_memac_set_hash_table(p_Memac->p_MemMap, (hash & ~HASH_CTRL_MCAST_EN));
7656 +
7657 + return E_OK;
7658 +}
7659 +
7660 +
7661 +/* ......................................................................... */
7662 +
7663 +static t_Error MemacSetException(t_Handle h_Memac, e_FmMacExceptions exception, bool enable)
7664 +{
7665 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7666 + uint32_t bitMask = 0;
7667 +
7668 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7669 + SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7670 +
7671 + GET_EXCEPTION_FLAG(bitMask, exception);
7672 + if (bitMask)
7673 + {
7674 + if (enable)
7675 + p_Memac->exceptions |= bitMask;
7676 + else
7677 + p_Memac->exceptions &= ~bitMask;
7678 + }
7679 + else
7680 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
7681 +
7682 + fman_memac_set_exception(p_Memac->p_MemMap, bitMask, enable);
7683 +
7684 + return E_OK;
7685 +}
7686 +
7687 +/* ......................................................................... */
7688 +
7689 +static uint16_t MemacGetMaxFrameLength(t_Handle h_Memac)
7690 +{
7691 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7692 +
7693 + SANITY_CHECK_RETURN_VALUE(p_Memac, E_INVALID_HANDLE, 0);
7694 + SANITY_CHECK_RETURN_VALUE(!p_Memac->p_MemacDriverParam, E_INVALID_STATE, 0);
7695 +
7696 + return fman_memac_get_max_frame_len(p_Memac->p_MemMap);
7697 +}
7698 +
7699 +
7700 +/*****************************************************************************/
7701 +/* mEMAC Init & Free API */
7702 +/*****************************************************************************/
7703 +
7704 +/* ......................................................................... */
7705 +void *g_MemacRegs;
7706 +static t_Error MemacInit(t_Handle h_Memac)
7707 +{
7708 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7709 + struct memac_cfg *p_MemacDriverParam;
7710 + enum enet_interface enet_interface;
7711 + enum enet_speed enet_speed;
7712 + uint8_t i, phyAddr;
7713 + t_EnetAddr ethAddr;
7714 + e_FmMacType portType;
7715 + t_Error err;
7716 + bool slow_10g_if = FALSE;
7717 + if (p_Memac->macId == 3) /* This is a quick WA */
7718 + g_MemacRegs = p_Memac->p_MemMap;
7719 +
7720 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7721 + SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
7722 + SANITY_CHECK_RETURN_ERROR(p_Memac->fmMacControllerDriver.h_Fm, E_INVALID_HANDLE);
7723 +
7724 + FM_GetRevision(p_Memac->fmMacControllerDriver.h_Fm, &p_Memac->fmMacControllerDriver.fmRevInfo);
7725 + if (p_Memac->fmMacControllerDriver.fmRevInfo.majorRev == 6 &&
7726 + p_Memac->fmMacControllerDriver.fmRevInfo.minorRev == 4)
7727 + slow_10g_if = TRUE;
7728 +
7729 + CHECK_INIT_PARAMETERS(p_Memac, CheckInitParameters);
7730 +
7731 + p_MemacDriverParam = p_Memac->p_MemacDriverParam;
7732 +
7733 + portType =
7734 + ((ENET_SPEED_FROM_MODE(p_Memac->enetMode) < e_ENET_SPEED_10000) ? e_FM_MAC_1G : e_FM_MAC_10G);
7735 +
7736 + /* First, reset the MAC if desired. */
7737 + if (p_MemacDriverParam->reset_on_init)
7738 + fman_memac_reset(p_Memac->p_MemMap);
7739 +
7740 + /* MAC Address */
7741 + MAKE_ENET_ADDR_FROM_UINT64(p_Memac->addr, ethAddr);
7742 + fman_memac_add_addr_in_paddr(p_Memac->p_MemMap, (uint8_t*)ethAddr, 0);
7743 +
7744 + enet_interface = (enum enet_interface) ENET_INTERFACE_FROM_MODE(p_Memac->enetMode);
7745 + enet_speed = (enum enet_speed) ENET_SPEED_FROM_MODE(p_Memac->enetMode);
7746 +
7747 + fman_memac_init(p_Memac->p_MemMap,
7748 + p_Memac->p_MemacDriverParam,
7749 + enet_interface,
7750 + enet_speed,
7751 + slow_10g_if,
7752 + p_Memac->exceptions);
7753 +
7754 +#ifdef FM_RX_FIFO_CORRUPT_ERRATA_10GMAC_A006320
7755 + {
7756 + uint32_t tmpReg = 0;
7757 +
7758 + FM_GetRevision(p_Memac->fmMacControllerDriver.h_Fm, &p_Memac->fmMacControllerDriver.fmRevInfo);
7759 + /* check the FMAN version - the bug exists only in rev1 */
7760 + if ((p_Memac->fmMacControllerDriver.fmRevInfo.majorRev == 6) &&
7761 + (p_Memac->fmMacControllerDriver.fmRevInfo.minorRev == 0))
7762 + {
7763 + /* MAC strips CRC from received frames - this workaround should
7764 + decrease the likelihood of bug appearance
7765 + */
7766 + tmpReg = GET_UINT32(p_Memac->p_MemMap->command_config);
7767 + tmpReg &= ~CMD_CFG_CRC_FWD;
7768 + WRITE_UINT32(p_Memac->p_MemMap->command_config, tmpReg);
7769 + /* DBG(WARNING, ("mEMAC strips CRC from received frames as part of A006320 errata workaround"));*/
7770 + }
7771 + }
7772 +#endif /* FM_RX_FIFO_CORRUPT_ERRATA_10GMAC_A006320 */
7773 +
7774 + if (ENET_INTERFACE_FROM_MODE(p_Memac->enetMode) == e_ENET_IF_SGMII)
7775 + {
7776 + /* Configure internal SGMII PHY */
7777 + if (p_Memac->enetMode & ENET_IF_SGMII_BASEX)
7778 + SetupSgmiiInternalPhyBaseX(p_Memac, PHY_MDIO_ADDR);
7779 + else
7780 + SetupSgmiiInternalPhy(p_Memac, PHY_MDIO_ADDR);
7781 + }
7782 + else if (ENET_INTERFACE_FROM_MODE(p_Memac->enetMode) == e_ENET_IF_QSGMII)
7783 + {
7784 + /* Configure 4 internal SGMII PHYs */
7785 + for (i = 0; i < 4; i++)
7786 + {
7787 + /* QSGMII PHY address occupies 3 upper bits of 5-bit
7788 + phyAddress; the lower 2 bits are used to extend
7789 + register address space and access each one of 4
7790 + ports inside QSGMII. */
7791 + phyAddr = (uint8_t)((PHY_MDIO_ADDR << 2) | i);
7792 + if (p_Memac->enetMode & ENET_IF_SGMII_BASEX)
7793 + SetupSgmiiInternalPhyBaseX(p_Memac, phyAddr);
7794 + else
7795 + SetupSgmiiInternalPhy(p_Memac, phyAddr);
7796 + }
7797 + }
7798 +
7799 + /* Max Frame Length */
7800 + err = FmSetMacMaxFrame(p_Memac->fmMacControllerDriver.h_Fm,
7801 + portType,
7802 + p_Memac->fmMacControllerDriver.macId,
7803 + p_MemacDriverParam->max_frame_length);
7804 + if (err)
7805 + RETURN_ERROR(MAJOR, err, ("settings Mac max frame length is FAILED"));
7806 +
7807 + p_Memac->p_MulticastAddrHash = AllocHashTable(HASH_TABLE_SIZE);
7808 + if (!p_Memac->p_MulticastAddrHash)
7809 + {
7810 + FreeInitResources(p_Memac);
7811 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("allocation hash table is FAILED"));
7812 + }
7813 +
7814 + p_Memac->p_UnicastAddrHash = AllocHashTable(HASH_TABLE_SIZE);
7815 + if (!p_Memac->p_UnicastAddrHash)
7816 + {
7817 + FreeInitResources(p_Memac);
7818 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("allocation hash table is FAILED"));
7819 + }
7820 +
7821 + FmRegisterIntr(p_Memac->fmMacControllerDriver.h_Fm,
7822 + (portType == e_FM_MAC_10G) ? e_FM_MOD_10G_MAC : e_FM_MOD_1G_MAC,
7823 + p_Memac->macId,
7824 + e_FM_INTR_TYPE_ERR,
7825 + MemacErrException,
7826 + p_Memac);
7827 +
7828 + FmRegisterIntr(p_Memac->fmMacControllerDriver.h_Fm,
7829 + (portType == e_FM_MAC_10G) ? e_FM_MOD_10G_MAC : e_FM_MOD_1G_MAC,
7830 + p_Memac->macId,
7831 + e_FM_INTR_TYPE_NORMAL,
7832 + MemacException,
7833 + p_Memac);
7834 +
7835 + XX_Free(p_MemacDriverParam);
7836 + p_Memac->p_MemacDriverParam = NULL;
7837 +
7838 + return E_OK;
7839 +}
7840 +
7841 +/* ......................................................................... */
7842 +
7843 +static t_Error MemacFree(t_Handle h_Memac)
7844 +{
7845 + t_Memac *p_Memac = (t_Memac *)h_Memac;
7846 +
7847 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
7848 +
7849 + if (p_Memac->p_MemacDriverParam)
7850 + {
7851 + /* Called after config */
7852 + XX_Free(p_Memac->p_MemacDriverParam);
7853 + p_Memac->p_MemacDriverParam = NULL;
7854 + }
7855 + else
7856 + /* Called after init */
7857 + FreeInitResources(p_Memac);
7858 +
7859 + XX_Free(p_Memac);
7860 +
7861 + return E_OK;
7862 +}
7863 +
7864 +/* ......................................................................... */
7865 +
7866 +static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacControllerDriver)
7867 +{
7868 + p_FmMacControllerDriver->f_FM_MAC_Init = MemacInit;
7869 + p_FmMacControllerDriver->f_FM_MAC_Free = MemacFree;
7870 +
7871 + p_FmMacControllerDriver->f_FM_MAC_SetStatistics = NULL;
7872 + p_FmMacControllerDriver->f_FM_MAC_ConfigLoopback = MemacConfigLoopback;
7873 + p_FmMacControllerDriver->f_FM_MAC_ConfigMaxFrameLength = MemacConfigMaxFrameLength;
7874 +
7875 + p_FmMacControllerDriver->f_FM_MAC_ConfigWan = MemacConfigWan;
7876 +
7877 + p_FmMacControllerDriver->f_FM_MAC_ConfigPadAndCrc = MemacConfigPad;
7878 + p_FmMacControllerDriver->f_FM_MAC_ConfigHalfDuplex = NULL; /* half-duplex is detected automatically */
7879 + p_FmMacControllerDriver->f_FM_MAC_ConfigLengthCheck = MemacConfigLengthCheck;
7880 +
7881 + p_FmMacControllerDriver->f_FM_MAC_ConfigException = MemacConfigException;
7882 + p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit = MemacConfigResetOnInit;
7883 +
7884 + p_FmMacControllerDriver->f_FM_MAC_SetException = MemacSetException;
7885 +
7886 + p_FmMacControllerDriver->f_FM_MAC_Enable1588TimeStamp = MemacEnable1588TimeStamp; /* always enabled */
7887 + p_FmMacControllerDriver->f_FM_MAC_Disable1588TimeStamp = NULL;
7888 +
7889 + p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous = MemacSetPromiscuous;
7890 + p_FmMacControllerDriver->f_FM_MAC_AdjustLink = MemacAdjustLink;
7891 + p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg = NULL;
7892 +
7893 + p_FmMacControllerDriver->f_FM_MAC_Enable = MemacEnable;
7894 + p_FmMacControllerDriver->f_FM_MAC_Disable = MemacDisable;
7895 +
7896 + p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames = MemacSetTxAutoPauseFrames;
7897 + p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames = MemacSetTxPauseFrames;
7898 + p_FmMacControllerDriver->f_FM_MAC_SetRxIgnorePauseFrames = MemacSetRxIgnorePauseFrames;
7899 +
7900 + p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan = MemacSetWakeOnLan;
7901 +
7902 + p_FmMacControllerDriver->f_FM_MAC_ResetCounters = MemacResetCounters;
7903 + p_FmMacControllerDriver->f_FM_MAC_GetStatistics = MemacGetStatistics;
7904 +
7905 + p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr = MemacModifyMacAddress;
7906 + p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr = MemacAddHashMacAddress;
7907 + p_FmMacControllerDriver->f_FM_MAC_RemoveHashMacAddr = MemacDelHashMacAddress;
7908 + p_FmMacControllerDriver->f_FM_MAC_AddExactMatchMacAddr = MemacAddExactMatchMacAddress;
7909 + p_FmMacControllerDriver->f_FM_MAC_RemovelExactMatchMacAddr = MemacDelExactMatchMacAddress;
7910 + p_FmMacControllerDriver->f_FM_MAC_GetId = MemacGetId;
7911 + p_FmMacControllerDriver->f_FM_MAC_GetVersion = NULL;
7912 + p_FmMacControllerDriver->f_FM_MAC_GetMaxFrameLength = MemacGetMaxFrameLength;
7913 +
7914 + p_FmMacControllerDriver->f_FM_MAC_MII_WritePhyReg = MEMAC_MII_WritePhyReg;
7915 + p_FmMacControllerDriver->f_FM_MAC_MII_ReadPhyReg = MEMAC_MII_ReadPhyReg;
7916 +}
7917 +
7918 +
7919 +/*****************************************************************************/
7920 +/* mEMAC Config Main Entry */
7921 +/*****************************************************************************/
7922 +
7923 +/* ......................................................................... */
7924 +
7925 +t_Handle MEMAC_Config(t_FmMacParams *p_FmMacParam)
7926 +{
7927 + t_Memac *p_Memac;
7928 + struct memac_cfg *p_MemacDriverParam;
7929 + uintptr_t baseAddr;
7930 +
7931 + SANITY_CHECK_RETURN_VALUE(p_FmMacParam, E_NULL_POINTER, NULL);
7932 +
7933 + baseAddr = p_FmMacParam->baseAddr;
7934 + /* Allocate memory for the mEMAC data structure */
7935 + p_Memac = (t_Memac *)XX_Malloc(sizeof(t_Memac));
7936 + if (!p_Memac)
7937 + {
7938 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("mEMAC driver structure"));
7939 + return NULL;
7940 + }
7941 + memset(p_Memac, 0, sizeof(t_Memac));
7942 + InitFmMacControllerDriver(&p_Memac->fmMacControllerDriver);
7943 +
7944 + /* Allocate memory for the mEMAC driver parameters data structure */
7945 + p_MemacDriverParam = (struct memac_cfg *)XX_Malloc(sizeof(struct memac_cfg));
7946 + if (!p_MemacDriverParam)
7947 + {
7948 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("mEMAC driver parameters"));
7949 + XX_Free(p_Memac);
7950 + return NULL;
7951 + }
7952 + memset(p_MemacDriverParam, 0, sizeof(struct memac_cfg));
7953 +
7954 + /* Plant parameter structure pointer */
7955 + p_Memac->p_MemacDriverParam = p_MemacDriverParam;
7956 +
7957 + fman_memac_defconfig(p_MemacDriverParam);
7958 +
7959 + p_Memac->addr = ENET_ADDR_TO_UINT64(p_FmMacParam->addr);
7960 +
7961 + p_Memac->p_MemMap = (struct memac_regs *)UINT_TO_PTR(baseAddr);
7962 + p_Memac->p_MiiMemMap = (struct memac_mii_access_mem_map*)UINT_TO_PTR(baseAddr + MEMAC_TO_MII_OFFSET);
7963 +
7964 + p_Memac->enetMode = p_FmMacParam->enetMode;
7965 + p_Memac->macId = p_FmMacParam->macId;
7966 + p_Memac->exceptions = MEMAC_default_exceptions;
7967 + p_Memac->f_Exception = p_FmMacParam->f_Exception;
7968 + p_Memac->f_Event = p_FmMacParam->f_Event;
7969 + p_Memac->h_App = p_FmMacParam->h_App;
7970 +
7971 + return p_Memac;
7972 +}
7973 --- /dev/null
7974 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.h
7975 @@ -0,0 +1,110 @@
7976 +/*
7977 + * Copyright 2008-2012 Freescale Semiconductor Inc.
7978 + *
7979 + * Redistribution and use in source and binary forms, with or without
7980 + * modification, are permitted provided that the following conditions are met:
7981 + * * Redistributions of source code must retain the above copyright
7982 + * notice, this list of conditions and the following disclaimer.
7983 + * * Redistributions in binary form must reproduce the above copyright
7984 + * notice, this list of conditions and the following disclaimer in the
7985 + * documentation and/or other materials provided with the distribution.
7986 + * * Neither the name of Freescale Semiconductor nor the
7987 + * names of its contributors may be used to endorse or promote products
7988 + * derived from this software without specific prior written permission.
7989 + *
7990 + *
7991 + * ALTERNATIVELY, this software may be distributed under the terms of the
7992 + * GNU General Public License ("GPL") as published by the Free Software
7993 + * Foundation, either version 2 of that License or (at your option) any
7994 + * later version.
7995 + *
7996 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
7997 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
7998 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
7999 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
8000 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
8001 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
8002 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
8003 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8004 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
8005 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8006 + */
8007 +
8008 +
8009 +/******************************************************************************
8010 + @File memac.h
8011 +
8012 + @Description FM Multirate Ethernet MAC (mEMAC)
8013 +*//***************************************************************************/
8014 +#ifndef __MEMAC_H
8015 +#define __MEMAC_H
8016 +
8017 +#include "std_ext.h"
8018 +#include "error_ext.h"
8019 +#include "list_ext.h"
8020 +
8021 +#include "fsl_fman_memac_mii_acc.h"
8022 +#include "fm_mac.h"
8023 +#include "fsl_fman_memac.h"
8024 +
8025 +
8026 +#define MEMAC_default_exceptions \
8027 + ((uint32_t)(MEMAC_IMASK_TSECC_ER | MEMAC_IMASK_TECC_ER | MEMAC_IMASK_RECC_ER | MEMAC_IMASK_MGI))
8028 +
8029 +#define GET_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \
8030 + case e_FM_MAC_EX_10G_1TX_ECC_ER: \
8031 + bitMask = MEMAC_IMASK_TECC_ER; break; \
8032 + case e_FM_MAC_EX_10G_RX_ECC_ER: \
8033 + bitMask = MEMAC_IMASK_RECC_ER; break; \
8034 + case e_FM_MAC_EX_TS_FIFO_ECC_ERR: \
8035 + bitMask = MEMAC_IMASK_TSECC_ER; break; \
8036 + case e_FM_MAC_EX_MAGIC_PACKET_INDICATION: \
8037 + bitMask = MEMAC_IMASK_MGI; break; \
8038 + default: bitMask = 0;break;}
8039 +
8040 +
8041 +typedef struct
8042 +{
8043 + t_FmMacControllerDriver fmMacControllerDriver; /**< Upper Mac control block */
8044 + t_Handle h_App; /**< Handle to the upper layer application */
8045 + struct memac_regs *p_MemMap; /**< Pointer to MAC memory mapped registers */
8046 + struct memac_mii_access_mem_map *p_MiiMemMap; /**< Pointer to MII memory mapped registers */
8047 + uint64_t addr; /**< MAC address of device */
8048 + e_EnetMode enetMode; /**< Ethernet physical interface */
8049 + t_FmMacExceptionCallback *f_Exception;
8050 + int mdioIrq;
8051 + t_FmMacExceptionCallback *f_Event;
8052 + bool indAddrRegUsed[MEMAC_NUM_OF_PADDRS]; /**< Whether a particular individual address recognition register is being used */
8053 + uint64_t paddr[MEMAC_NUM_OF_PADDRS]; /**< MAC address for particular individual address recognition register */
8054 + uint8_t numOfIndAddrInRegs; /**< Number of individual addresses in registers for this station. */
8055 + t_EthHash *p_MulticastAddrHash; /**< Pointer to driver's global address hash table */
8056 + t_EthHash *p_UnicastAddrHash; /**< Pointer to driver's individual address hash table */
8057 + bool debugMode;
8058 + uint8_t macId;
8059 + uint32_t exceptions;
8060 + struct memac_cfg *p_MemacDriverParam;
8061 +} t_Memac;
8062 +
8063 +
8064 +/* Internal PHY access */
8065 +#define PHY_MDIO_ADDR 0
8066 +
8067 +/* Internal PHY Registers - SGMII */
8068 +#define PHY_SGMII_CR_PHY_RESET 0x8000
8069 +#define PHY_SGMII_CR_RESET_AN 0x0200
8070 +#define PHY_SGMII_CR_DEF_VAL 0x1140
8071 +#define PHY_SGMII_DEV_ABILITY_SGMII 0x4001
8072 +#define PHY_SGMII_DEV_ABILITY_1000X 0x01A0
8073 +#define PHY_SGMII_IF_SPEED_GIGABIT 0x0008
8074 +#define PHY_SGMII_IF_MODE_AN 0x0002
8075 +#define PHY_SGMII_IF_MODE_SGMII 0x0001
8076 +#define PHY_SGMII_IF_MODE_1000X 0x0000
8077 +
8078 +
8079 +#define MEMAC_TO_MII_OFFSET 0x030 /* Offset from the MEM map to the MDIO mem map */
8080 +
8081 +t_Error MEMAC_MII_WritePhyReg(t_Handle h_Memac, uint8_t phyAddr, uint8_t reg, uint16_t data);
8082 +t_Error MEMAC_MII_ReadPhyReg(t_Handle h_Memac, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);
8083 +
8084 +
8085 +#endif /* __MEMAC_H */
8086 --- /dev/null
8087 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac_mii_acc.c
8088 @@ -0,0 +1,78 @@
8089 +/*
8090 + * Copyright 2008-2012 Freescale Semiconductor Inc.
8091 + *
8092 + * Redistribution and use in source and binary forms, with or without
8093 + * modification, are permitted provided that the following conditions are met:
8094 + * * Redistributions of source code must retain the above copyright
8095 + * notice, this list of conditions and the following disclaimer.
8096 + * * Redistributions in binary form must reproduce the above copyright
8097 + * notice, this list of conditions and the following disclaimer in the
8098 + * documentation and/or other materials provided with the distribution.
8099 + * * Neither the name of Freescale Semiconductor nor the
8100 + * names of its contributors may be used to endorse or promote products
8101 + * derived from this software without specific prior written permission.
8102 + *
8103 + *
8104 + * ALTERNATIVELY, this software may be distributed under the terms of the
8105 + * GNU General Public License ("GPL") as published by the Free Software
8106 + * Foundation, either version 2 of that License or (at your option) any
8107 + * later version.
8108 + *
8109 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
8110 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
8111 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
8112 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
8113 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
8114 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
8115 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
8116 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8117 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
8118 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8119 + */
8120 +
8121 +
8122 +#include "error_ext.h"
8123 +#include "std_ext.h"
8124 +#include "fm_mac.h"
8125 +#include "memac.h"
8126 +#include "xx_ext.h"
8127 +
8128 +#include "fm_common.h"
8129 +#include "memac_mii_acc.h"
8130 +
8131 +
8132 +/*****************************************************************************/
8133 +t_Error MEMAC_MII_WritePhyReg(t_Handle h_Memac,
8134 + uint8_t phyAddr,
8135 + uint8_t reg,
8136 + uint16_t data)
8137 +{
8138 + t_Memac *p_Memac = (t_Memac *)h_Memac;
8139 +
8140 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
8141 + SANITY_CHECK_RETURN_ERROR(p_Memac->p_MiiMemMap, E_INVALID_HANDLE);
8142 +
8143 + return (t_Error)fman_memac_mii_write_phy_reg(p_Memac->p_MiiMemMap,
8144 + phyAddr,
8145 + reg,
8146 + data,
8147 + (enum enet_speed)ENET_SPEED_FROM_MODE(p_Memac->enetMode));
8148 +}
8149 +
8150 +/*****************************************************************************/
8151 +t_Error MEMAC_MII_ReadPhyReg(t_Handle h_Memac,
8152 + uint8_t phyAddr,
8153 + uint8_t reg,
8154 + uint16_t *p_Data)
8155 +{
8156 + t_Memac *p_Memac = (t_Memac *)h_Memac;
8157 +
8158 + SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
8159 + SANITY_CHECK_RETURN_ERROR(p_Memac->p_MiiMemMap, E_INVALID_HANDLE);
8160 +
8161 + return fman_memac_mii_read_phy_reg(p_Memac->p_MiiMemMap,
8162 + phyAddr,
8163 + reg,
8164 + p_Data,
8165 + (enum enet_speed)ENET_SPEED_FROM_MODE(p_Memac->enetMode));
8166 +}
8167 --- /dev/null
8168 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac_mii_acc.h
8169 @@ -0,0 +1,73 @@
8170 +/*
8171 + * Copyright 2008-2012 Freescale Semiconductor Inc.
8172 + *
8173 + * Redistribution and use in source and binary forms, with or without
8174 + * modification, are permitted provided that the following conditions are met:
8175 + * * Redistributions of source code must retain the above copyright
8176 + * notice, this list of conditions and the following disclaimer.
8177 + * * Redistributions in binary form must reproduce the above copyright
8178 + * notice, this list of conditions and the following disclaimer in the
8179 + * documentation and/or other materials provided with the distribution.
8180 + * * Neither the name of Freescale Semiconductor nor the
8181 + * names of its contributors may be used to endorse or promote products
8182 + * derived from this software without specific prior written permission.
8183 + *
8184 + *
8185 + * ALTERNATIVELY, this software may be distributed under the terms of the
8186 + * GNU General Public License ("GPL") as published by the Free Software
8187 + * Foundation, either version 2 of that License or (at your option) any
8188 + * later version.
8189 + *
8190 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
8191 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
8192 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
8193 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
8194 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
8195 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
8196 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
8197 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8198 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
8199 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8200 + */
8201 +
8202 +
8203 +#ifndef __MEMAC_MII_ACC_H
8204 +#define __MEMAC_MII_ACC_H
8205 +
8206 +#include "std_ext.h"
8207 +
8208 +
8209 +/* MII Management Registers */
8210 +#define MDIO_CFG_CLK_DIV_MASK 0x0080ff80
8211 +#define MDIO_CFG_CLK_DIV_SHIFT 7
8212 +#define MDIO_CFG_HOLD_MASK 0x0000001c
8213 +#define MDIO_CFG_ENC45 0x00000040
8214 +#define MDIO_CFG_READ_ERR 0x00000002
8215 +#define MDIO_CFG_BSY 0x00000001
8216 +
8217 +#define MDIO_CTL_PHY_ADDR_SHIFT 5
8218 +#define MDIO_CTL_READ 0x00008000
8219 +
8220 +#define MDIO_DATA_BSY 0x80000000
8221 +
8222 +#if defined(__MWERKS__) && !defined(__GNUC__)
8223 +#pragma pack(push,1)
8224 +#endif /* defined(__MWERKS__) && ... */
8225 +
8226 +/*----------------------------------------------------*/
8227 +/* MII Configuration Control Memory Map Registers */
8228 +/*----------------------------------------------------*/
8229 +typedef struct t_MemacMiiAccessMemMap
8230 +{
8231 + volatile uint32_t mdio_cfg; /* 0x030 */
8232 + volatile uint32_t mdio_ctrl; /* 0x034 */
8233 + volatile uint32_t mdio_data; /* 0x038 */
8234 + volatile uint32_t mdio_addr; /* 0x03c */
8235 +} t_MemacMiiAccessMemMap ;
8236 +
8237 +#if defined(__MWERKS__) && !defined(__GNUC__)
8238 +#pragma pack(pop)
8239 +#endif /* defined(__MWERKS__) && ... */
8240 +
8241 +
8242 +#endif /* __MEMAC_MII_ACC_H */
8243 --- /dev/null
8244 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec.c
8245 @@ -0,0 +1,974 @@
8246 +/*
8247 + * Copyright 2008-2012 Freescale Semiconductor Inc.
8248 + *
8249 + * Redistribution and use in source and binary forms, with or without
8250 + * modification, are permitted provided that the following conditions are met:
8251 + * * Redistributions of source code must retain the above copyright
8252 + * notice, this list of conditions and the following disclaimer.
8253 + * * Redistributions in binary form must reproduce the above copyright
8254 + * notice, this list of conditions and the following disclaimer in the
8255 + * documentation and/or other materials provided with the distribution.
8256 + * * Neither the name of Freescale Semiconductor nor the
8257 + * names of its contributors may be used to endorse or promote products
8258 + * derived from this software without specific prior written permission.
8259 + *
8260 + *
8261 + * ALTERNATIVELY, this software may be distributed under the terms of the
8262 + * GNU General Public License ("GPL") as published by the Free Software
8263 + * Foundation, either version 2 of that License or (at your option) any
8264 + * later version.
8265 + *
8266 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
8267 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
8268 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
8269 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
8270 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
8271 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
8272 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
8273 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8274 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
8275 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8276 + */
8277 +
8278 +
8279 +/******************************************************************************
8280 + @File tgec.c
8281 +
8282 + @Description FM 10G MAC ...
8283 +*//***************************************************************************/
8284 +
8285 +#include "std_ext.h"
8286 +#include "string_ext.h"
8287 +#include "error_ext.h"
8288 +#include "xx_ext.h"
8289 +#include "endian_ext.h"
8290 +#include "debug_ext.h"
8291 +#include "crc_mac_addr_ext.h"
8292 +
8293 +#include "fm_common.h"
8294 +#include "fsl_fman_tgec.h"
8295 +#include "tgec.h"
8296 +
8297 +
8298 +/*****************************************************************************/
8299 +/* Internal routines */
8300 +/*****************************************************************************/
8301 +
8302 +static t_Error CheckInitParameters(t_Tgec *p_Tgec)
8303 +{
8304 + if (ENET_SPEED_FROM_MODE(p_Tgec->enetMode) < e_ENET_SPEED_10000)
8305 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Ethernet 10G MAC driver only support 10G speed"));
8306 +#if (FM_MAX_NUM_OF_10G_MACS > 0)
8307 + if (p_Tgec->macId >= FM_MAX_NUM_OF_10G_MACS)
8308 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("macId of 10G can not be greater than 0"));
8309 +#endif /* (FM_MAX_NUM_OF_10G_MACS > 0) */
8310 +
8311 + if (p_Tgec->addr == 0)
8312 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Ethernet 10G MAC Must have a valid MAC Address"));
8313 + if (!p_Tgec->f_Exception)
8314 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("uninitialized f_Exception"));
8315 + if (!p_Tgec->f_Event)
8316 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("uninitialized f_Event"));
8317 +#ifdef FM_LEN_CHECK_ERRATA_FMAN_SW002
8318 + if (!p_Tgec->p_TgecDriverParam->no_length_check_enable)
8319 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("LengthCheck!"));
8320 +#endif /* FM_LEN_CHECK_ERRATA_FMAN_SW002 */
8321 + return E_OK;
8322 +}
8323 +
8324 +/* ......................................................................... */
8325 +
8326 +static uint32_t GetMacAddrHashCode(uint64_t ethAddr)
8327 +{
8328 + uint32_t crc;
8329 +
8330 + /* CRC calculation */
8331 + GET_MAC_ADDR_CRC(ethAddr, crc);
8332 +
8333 + crc = GetMirror32(crc);
8334 +
8335 + return crc;
8336 +}
8337 +
8338 +/* ......................................................................... */
8339 +
8340 +static void TgecErrException(t_Handle h_Tgec)
8341 +{
8342 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8343 + uint32_t event;
8344 + struct tgec_regs *p_TgecMemMap = p_Tgec->p_MemMap;
8345 +
8346 + /* do not handle MDIO events */
8347 + event = fman_tgec_get_event(p_TgecMemMap, ~(TGEC_IMASK_MDIO_SCAN_EVENT | TGEC_IMASK_MDIO_CMD_CMPL));
8348 + event &= fman_tgec_get_interrupt_mask(p_TgecMemMap);
8349 +
8350 + fman_tgec_ack_event(p_TgecMemMap, event);
8351 +
8352 + if (event & TGEC_IMASK_REM_FAULT)
8353 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_REM_FAULT);
8354 + if (event & TGEC_IMASK_LOC_FAULT)
8355 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_LOC_FAULT);
8356 + if (event & TGEC_IMASK_TX_ECC_ER)
8357 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_1TX_ECC_ER);
8358 + if (event & TGEC_IMASK_TX_FIFO_UNFL)
8359 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_TX_FIFO_UNFL);
8360 + if (event & TGEC_IMASK_TX_FIFO_OVFL)
8361 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_TX_FIFO_OVFL);
8362 + if (event & TGEC_IMASK_TX_ER)
8363 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_TX_ER);
8364 + if (event & TGEC_IMASK_RX_FIFO_OVFL)
8365 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_FIFO_OVFL);
8366 + if (event & TGEC_IMASK_RX_ECC_ER)
8367 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_ECC_ER);
8368 + if (event & TGEC_IMASK_RX_JAB_FRM)
8369 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_JAB_FRM);
8370 + if (event & TGEC_IMASK_RX_OVRSZ_FRM)
8371 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_OVRSZ_FRM);
8372 + if (event & TGEC_IMASK_RX_RUNT_FRM)
8373 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_RUNT_FRM);
8374 + if (event & TGEC_IMASK_RX_FRAG_FRM)
8375 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_FRAG_FRM);
8376 + if (event & TGEC_IMASK_RX_LEN_ER)
8377 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_LEN_ER);
8378 + if (event & TGEC_IMASK_RX_CRC_ER)
8379 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_CRC_ER);
8380 + if (event & TGEC_IMASK_RX_ALIGN_ER)
8381 + p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_ALIGN_ER);
8382 +}
8383 +
8384 +/* ......................................................................... */
8385 +
8386 +static void TgecException(t_Handle h_Tgec)
8387 +{
8388 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8389 + uint32_t event;
8390 + struct tgec_regs *p_TgecMemMap = p_Tgec->p_MemMap;
8391 +
8392 + /* handle only MDIO events */
8393 + event = fman_tgec_get_event(p_TgecMemMap, (TGEC_IMASK_MDIO_SCAN_EVENT | TGEC_IMASK_MDIO_CMD_CMPL));
8394 + event &= fman_tgec_get_interrupt_mask(p_TgecMemMap);
8395 +
8396 + fman_tgec_ack_event(p_TgecMemMap, event);
8397 +
8398 + if (event & TGEC_IMASK_MDIO_SCAN_EVENT)
8399 + p_Tgec->f_Event(p_Tgec->h_App, e_FM_MAC_EX_10G_MDIO_SCAN_EVENTMDIO);
8400 + if (event & TGEC_IMASK_MDIO_CMD_CMPL)
8401 + p_Tgec->f_Event(p_Tgec->h_App, e_FM_MAC_EX_10G_MDIO_CMD_CMPL);
8402 +}
8403 +
8404 +/* ......................................................................... */
8405 +
8406 +static void FreeInitResources(t_Tgec *p_Tgec)
8407 +{
8408 + if (p_Tgec->mdioIrq != NO_IRQ)
8409 + {
8410 + XX_DisableIntr(p_Tgec->mdioIrq);
8411 + XX_FreeIntr(p_Tgec->mdioIrq);
8412 + }
8413 +
8414 + FmUnregisterIntr(p_Tgec->fmMacControllerDriver.h_Fm, e_FM_MOD_10G_MAC, p_Tgec->macId, e_FM_INTR_TYPE_ERR);
8415 +
8416 + /* release the driver's group hash table */
8417 + FreeHashTable(p_Tgec->p_MulticastAddrHash);
8418 + p_Tgec->p_MulticastAddrHash = NULL;
8419 +
8420 + /* release the driver's individual hash table */
8421 + FreeHashTable(p_Tgec->p_UnicastAddrHash);
8422 + p_Tgec->p_UnicastAddrHash = NULL;
8423 +}
8424 +
8425 +
8426 +/*****************************************************************************/
8427 +/* 10G MAC API routines */
8428 +/*****************************************************************************/
8429 +
8430 +/* ......................................................................... */
8431 +
8432 +static t_Error TgecEnable(t_Handle h_Tgec, e_CommMode mode)
8433 +{
8434 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8435 +
8436 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8437 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8438 +
8439 + fman_tgec_enable(p_Tgec->p_MemMap, (mode & e_COMM_MODE_RX), (mode & e_COMM_MODE_TX));
8440 +
8441 + return E_OK;
8442 +}
8443 +
8444 +/* ......................................................................... */
8445 +
8446 +static t_Error TgecDisable (t_Handle h_Tgec, e_CommMode mode)
8447 +{
8448 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8449 +
8450 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8451 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8452 +
8453 + fman_tgec_disable(p_Tgec->p_MemMap, (mode & e_COMM_MODE_RX), (mode & e_COMM_MODE_TX));
8454 +
8455 + return E_OK;
8456 +}
8457 +
8458 +/* ......................................................................... */
8459 +
8460 +static t_Error TgecSetPromiscuous(t_Handle h_Tgec, bool newVal)
8461 +{
8462 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8463 +
8464 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8465 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8466 +
8467 + fman_tgec_set_promiscuous(p_Tgec->p_MemMap, newVal);
8468 +
8469 + return E_OK;
8470 +}
8471 +
8472 +
8473 +/*****************************************************************************/
8474 +/* Tgec Configs modification functions */
8475 +/*****************************************************************************/
8476 +
8477 +/* ......................................................................... */
8478 +
8479 +static t_Error TgecConfigLoopback(t_Handle h_Tgec, bool newVal)
8480 +{
8481 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8482 +
8483 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8484 + SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8485 +
8486 + p_Tgec->p_TgecDriverParam->loopback_enable = newVal;
8487 +
8488 + return E_OK;
8489 +}
8490 +
8491 +/* ......................................................................... */
8492 +
8493 +static t_Error TgecConfigWan(t_Handle h_Tgec, bool newVal)
8494 +{
8495 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8496 +
8497 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8498 + SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8499 +
8500 + p_Tgec->p_TgecDriverParam->wan_mode_enable = newVal;
8501 +
8502 + return E_OK;
8503 +}
8504 +
8505 +/* ......................................................................... */
8506 +
8507 +static t_Error TgecConfigMaxFrameLength(t_Handle h_Tgec, uint16_t newVal)
8508 +{
8509 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8510 +
8511 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8512 + SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8513 +
8514 + p_Tgec->p_TgecDriverParam->max_frame_length = newVal;
8515 +
8516 + return E_OK;
8517 +}
8518 +
8519 +/* ......................................................................... */
8520 +
8521 +static t_Error TgecConfigLengthCheck(t_Handle h_Tgec, bool newVal)
8522 +{
8523 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8524 +
8525 + UNUSED(newVal);
8526 +
8527 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8528 + SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8529 +
8530 + p_Tgec->p_TgecDriverParam->no_length_check_enable = !newVal;
8531 +
8532 + return E_OK;
8533 +}
8534 +
8535 +/* ......................................................................... */
8536 +
8537 +static t_Error TgecConfigException(t_Handle h_Tgec, e_FmMacExceptions exception, bool enable)
8538 +{
8539 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8540 + uint32_t bitMask = 0;
8541 +
8542 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8543 + SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8544 +
8545 + GET_EXCEPTION_FLAG(bitMask, exception);
8546 + if (bitMask)
8547 + {
8548 + if (enable)
8549 + p_Tgec->exceptions |= bitMask;
8550 + else
8551 + p_Tgec->exceptions &= ~bitMask;
8552 + }
8553 + else
8554 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
8555 +
8556 + return E_OK;
8557 +}
8558 +
8559 +#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
8560 +/* ......................................................................... */
8561 +
8562 +static t_Error TgecConfigSkipFman11Workaround(t_Handle h_Tgec)
8563 +{
8564 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8565 +
8566 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8567 + SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8568 +
8569 + p_Tgec->p_TgecDriverParam->skip_fman11_workaround = TRUE;
8570 +
8571 + return E_OK;
8572 +}
8573 +#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
8574 +
8575 +
8576 +/*****************************************************************************/
8577 +/* Tgec Run Time API functions */
8578 +/*****************************************************************************/
8579 +
8580 +/* ......................................................................... */
8581 +/* backward compatibility. will be removed in the future. */
8582 +static t_Error TgecTxMacPause(t_Handle h_Tgec, uint16_t pauseTime)
8583 +{
8584 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8585 +
8586 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_STATE);
8587 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8588 + fman_tgec_set_tx_pause_frames(p_Tgec->p_MemMap, pauseTime);
8589 +
8590 +
8591 + return E_OK;
8592 +}
8593 +
8594 +/* ......................................................................... */
8595 +
8596 +static t_Error TgecSetTxPauseFrames(t_Handle h_Tgec,
8597 + uint8_t priority,
8598 + uint16_t pauseTime,
8599 + uint16_t threshTime)
8600 +{
8601 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8602 +
8603 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_STATE);
8604 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8605 +
8606 + UNUSED(priority); UNUSED(threshTime);
8607 +
8608 + fman_tgec_set_tx_pause_frames(p_Tgec->p_MemMap, pauseTime);
8609 +
8610 + return E_OK;
8611 +}
8612 +
8613 +/* ......................................................................... */
8614 +
8615 +static t_Error TgecRxIgnoreMacPause(t_Handle h_Tgec, bool en)
8616 +{
8617 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8618 +
8619 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_STATE);
8620 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8621 +
8622 + fman_tgec_set_rx_ignore_pause_frames(p_Tgec->p_MemMap, en);
8623 +
8624 + return E_OK;
8625 +}
8626 +
8627 +/* ......................................................................... */
8628 +
8629 +static t_Error TgecGetStatistics(t_Handle h_Tgec, t_FmMacStatistics *p_Statistics)
8630 +{
8631 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8632 + struct tgec_regs *p_TgecMemMap;
8633 +
8634 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_NULL_POINTER);
8635 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8636 + SANITY_CHECK_RETURN_ERROR(p_Statistics, E_NULL_POINTER);
8637 +
8638 + p_TgecMemMap = p_Tgec->p_MemMap;
8639 +
8640 + p_Statistics->eStatPkts64 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R64);
8641 + p_Statistics->eStatPkts65to127 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R127);
8642 + p_Statistics->eStatPkts128to255 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R255);
8643 + p_Statistics->eStatPkts256to511 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R511);
8644 + p_Statistics->eStatPkts512to1023 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R1023);
8645 + p_Statistics->eStatPkts1024to1518 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R1518);
8646 + p_Statistics->eStatPkts1519to1522 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R1519X);
8647 +/* */
8648 + p_Statistics->eStatFragments = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TRFRG);
8649 + p_Statistics->eStatJabbers = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TRJBR);
8650 +
8651 + p_Statistics->eStatsDropEvents = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RDRP);
8652 + p_Statistics->eStatCRCAlignErrors = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RALN);
8653 +
8654 + p_Statistics->eStatUndersizePkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TRUND);
8655 + p_Statistics->eStatOversizePkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TROVR);
8656 +/* Pause */
8657 + p_Statistics->reStatPause = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RXPF);
8658 + p_Statistics->teStatPause = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TXPF);
8659 +
8660 +/* MIB II */
8661 + p_Statistics->ifInOctets = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_ROCT);
8662 + p_Statistics->ifInUcastPkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RUCA);
8663 + p_Statistics->ifInMcastPkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RMCA);
8664 + p_Statistics->ifInBcastPkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RBCA);
8665 + p_Statistics->ifInPkts = p_Statistics->ifInUcastPkts
8666 + + p_Statistics->ifInMcastPkts
8667 + + p_Statistics->ifInBcastPkts;
8668 + p_Statistics->ifInDiscards = 0;
8669 + p_Statistics->ifInErrors = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RERR);
8670 +
8671 + p_Statistics->ifOutOctets = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TOCT);
8672 + p_Statistics->ifOutUcastPkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TUCA);
8673 + p_Statistics->ifOutMcastPkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TMCA);
8674 + p_Statistics->ifOutBcastPkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TBCA);
8675 + p_Statistics->ifOutPkts = p_Statistics->ifOutUcastPkts
8676 + + p_Statistics->ifOutMcastPkts
8677 + + p_Statistics->ifOutBcastPkts;
8678 + p_Statistics->ifOutDiscards = 0;
8679 + p_Statistics->ifOutErrors = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TERR);
8680 +
8681 + return E_OK;
8682 +}
8683 +
8684 +/* ......................................................................... */
8685 +
8686 +static t_Error TgecEnable1588TimeStamp(t_Handle h_Tgec)
8687 +{
8688 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8689 +
8690 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8691 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8692 +
8693 + fman_tgec_enable_1588_time_stamp(p_Tgec->p_MemMap, 1);
8694 +
8695 + return E_OK;
8696 +}
8697 +
8698 +/* ......................................................................... */
8699 +
8700 +static t_Error TgecDisable1588TimeStamp(t_Handle h_Tgec)
8701 +{
8702 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8703 +
8704 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8705 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8706 +
8707 + fman_tgec_enable_1588_time_stamp(p_Tgec->p_MemMap, 0);
8708 +
8709 + return E_OK;
8710 +}
8711 +
8712 +/* ......................................................................... */
8713 +
8714 +static t_Error TgecModifyMacAddress (t_Handle h_Tgec, t_EnetAddr *p_EnetAddr)
8715 +{
8716 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8717 +
8718 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_NULL_POINTER);
8719 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8720 +
8721 + p_Tgec->addr = ENET_ADDR_TO_UINT64(*p_EnetAddr);
8722 + fman_tgec_set_mac_address(p_Tgec->p_MemMap, (uint8_t *)(*p_EnetAddr));
8723 +
8724 + return E_OK;
8725 +}
8726 +
8727 +/* ......................................................................... */
8728 +
8729 +static t_Error TgecResetCounters (t_Handle h_Tgec)
8730 +{
8731 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8732 +
8733 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8734 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8735 +
8736 + fman_tgec_reset_stat(p_Tgec->p_MemMap);
8737 +
8738 + return E_OK;
8739 +}
8740 +
8741 +/* ......................................................................... */
8742 +
8743 +static t_Error TgecAddExactMatchMacAddress(t_Handle h_Tgec, t_EnetAddr *p_EthAddr)
8744 +{
8745 + t_Tgec *p_Tgec = (t_Tgec *) h_Tgec;
8746 + uint64_t ethAddr;
8747 + uint8_t paddrNum;
8748 +
8749 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8750 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8751 +
8752 + ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
8753 +
8754 + if (ethAddr & GROUP_ADDRESS)
8755 + /* Multicast address has no effect in PADDR */
8756 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Multicast address"));
8757 +
8758 + /* Make sure no PADDR contains this address */
8759 + for (paddrNum = 0; paddrNum < TGEC_NUM_OF_PADDRS; paddrNum++)
8760 + if (p_Tgec->indAddrRegUsed[paddrNum])
8761 + if (p_Tgec->paddr[paddrNum] == ethAddr)
8762 + RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, NO_MSG);
8763 +
8764 + /* Find first unused PADDR */
8765 + for (paddrNum = 0; paddrNum < TGEC_NUM_OF_PADDRS; paddrNum++)
8766 + {
8767 + if (!(p_Tgec->indAddrRegUsed[paddrNum]))
8768 + {
8769 + /* mark this PADDR as used */
8770 + p_Tgec->indAddrRegUsed[paddrNum] = TRUE;
8771 + /* store address */
8772 + p_Tgec->paddr[paddrNum] = ethAddr;
8773 +
8774 + /* put in hardware */
8775 + fman_tgec_add_addr_in_paddr(p_Tgec->p_MemMap, (uint8_t*)(*p_EthAddr)/* , paddrNum */);
8776 + p_Tgec->numOfIndAddrInRegs++;
8777 +
8778 + return E_OK;
8779 + }
8780 + }
8781 +
8782 + /* No free PADDR */
8783 + RETURN_ERROR(MAJOR, E_FULL, NO_MSG);
8784 +}
8785 +
8786 +/* ......................................................................... */
8787 +
8788 +static t_Error TgecDelExactMatchMacAddress(t_Handle h_Tgec, t_EnetAddr *p_EthAddr)
8789 +{
8790 + t_Tgec *p_Tgec = (t_Tgec *) h_Tgec;
8791 + uint64_t ethAddr;
8792 + uint8_t paddrNum;
8793 +
8794 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8795 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8796 +
8797 + ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
8798 +
8799 + /* Find used PADDR containing this address */
8800 + for (paddrNum = 0; paddrNum < TGEC_NUM_OF_PADDRS; paddrNum++)
8801 + {
8802 + if ((p_Tgec->indAddrRegUsed[paddrNum]) &&
8803 + (p_Tgec->paddr[paddrNum] == ethAddr))
8804 + {
8805 + /* mark this PADDR as not used */
8806 + p_Tgec->indAddrRegUsed[paddrNum] = FALSE;
8807 + /* clear in hardware */
8808 + fman_tgec_clear_addr_in_paddr(p_Tgec->p_MemMap /*, paddrNum */);
8809 + p_Tgec->numOfIndAddrInRegs--;
8810 +
8811 + return E_OK;
8812 + }
8813 + }
8814 +
8815 + RETURN_ERROR(MAJOR, E_NOT_FOUND, NO_MSG);
8816 +}
8817 +
8818 +/* ......................................................................... */
8819 +
8820 +static t_Error TgecAddHashMacAddress(t_Handle h_Tgec, t_EnetAddr *p_EthAddr)
8821 +{
8822 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8823 + t_EthHashEntry *p_HashEntry;
8824 + uint32_t crc;
8825 + uint32_t hash;
8826 + uint64_t ethAddr;
8827 +
8828 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_NULL_POINTER);
8829 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8830 +
8831 + ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
8832 +
8833 + if (!(ethAddr & GROUP_ADDRESS))
8834 + /* Unicast addresses not supported in hash */
8835 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unicast Address"));
8836 +
8837 + /* CRC calculation */
8838 + crc = GetMacAddrHashCode(ethAddr);
8839 +
8840 + hash = (crc >> TGEC_HASH_MCAST_SHIFT) & TGEC_HASH_ADR_MSK; /* Take 9 MSB bits */
8841 +
8842 + /* Create element to be added to the driver hash table */
8843 + p_HashEntry = (t_EthHashEntry *)XX_Malloc(sizeof(t_EthHashEntry));
8844 + p_HashEntry->addr = ethAddr;
8845 + INIT_LIST(&p_HashEntry->node);
8846 +
8847 + LIST_AddToTail(&(p_HashEntry->node), &(p_Tgec->p_MulticastAddrHash->p_Lsts[hash]));
8848 + fman_tgec_set_hash_table(p_Tgec->p_MemMap, (hash | TGEC_HASH_MCAST_EN));
8849 +
8850 + return E_OK;
8851 +}
8852 +
8853 +/* ......................................................................... */
8854 +
8855 +static t_Error TgecDelHashMacAddress(t_Handle h_Tgec, t_EnetAddr *p_EthAddr)
8856 +{
8857 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8858 + t_EthHashEntry *p_HashEntry = NULL;
8859 + t_List *p_Pos;
8860 + uint32_t crc;
8861 + uint32_t hash;
8862 + uint64_t ethAddr;
8863 +
8864 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_NULL_POINTER);
8865 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8866 +
8867 + ethAddr = ((*(uint64_t *)p_EthAddr) >> 16);
8868 +
8869 + /* CRC calculation */
8870 + crc = GetMacAddrHashCode(ethAddr);
8871 +
8872 + hash = (crc >> TGEC_HASH_MCAST_SHIFT) & TGEC_HASH_ADR_MSK; /* Take 9 MSB bits */
8873 +
8874 + LIST_FOR_EACH(p_Pos, &(p_Tgec->p_MulticastAddrHash->p_Lsts[hash]))
8875 + {
8876 + p_HashEntry = ETH_HASH_ENTRY_OBJ(p_Pos);
8877 + if (p_HashEntry->addr == ethAddr)
8878 + {
8879 + LIST_DelAndInit(&p_HashEntry->node);
8880 + XX_Free(p_HashEntry);
8881 + break;
8882 + }
8883 + }
8884 + if (LIST_IsEmpty(&p_Tgec->p_MulticastAddrHash->p_Lsts[hash]))
8885 + fman_tgec_set_hash_table(p_Tgec->p_MemMap, (hash & ~TGEC_HASH_MCAST_EN));
8886 +
8887 + return E_OK;
8888 +}
8889 +
8890 +/* ......................................................................... */
8891 +
8892 +static t_Error TgecGetId(t_Handle h_Tgec, uint32_t *macId)
8893 +{
8894 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8895 +
8896 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8897 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8898 +
8899 + UNUSED(p_Tgec);
8900 + UNUSED(macId);
8901 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("TgecGetId Not Supported"));
8902 +}
8903 +
8904 +/* ......................................................................... */
8905 +
8906 +static t_Error TgecGetVersion(t_Handle h_Tgec, uint32_t *macVersion)
8907 +{
8908 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8909 +
8910 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8911 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8912 +
8913 + *macVersion = fman_tgec_get_revision(p_Tgec->p_MemMap);
8914 +
8915 + return E_OK;
8916 +}
8917 +
8918 +/* ......................................................................... */
8919 +
8920 +static t_Error TgecSetExcpetion(t_Handle h_Tgec, e_FmMacExceptions exception, bool enable)
8921 +{
8922 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8923 + uint32_t bitMask = 0;
8924 +
8925 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
8926 + SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
8927 +
8928 + GET_EXCEPTION_FLAG(bitMask, exception);
8929 + if (bitMask)
8930 + {
8931 + if (enable)
8932 + p_Tgec->exceptions |= bitMask;
8933 + else
8934 + p_Tgec->exceptions &= ~bitMask;
8935 + }
8936 + else
8937 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
8938 +
8939 + if (enable)
8940 + fman_tgec_enable_interrupt(p_Tgec->p_MemMap, bitMask);
8941 + else
8942 + fman_tgec_disable_interrupt(p_Tgec->p_MemMap, bitMask);
8943 +
8944 + return E_OK;
8945 +}
8946 +
8947 +/* ......................................................................... */
8948 +
8949 +static uint16_t TgecGetMaxFrameLength(t_Handle h_Tgec)
8950 +{
8951 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8952 +
8953 + SANITY_CHECK_RETURN_VALUE(p_Tgec, E_INVALID_HANDLE, 0);
8954 + SANITY_CHECK_RETURN_VALUE(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE, 0);
8955 +
8956 + return fman_tgec_get_max_frame_len(p_Tgec->p_MemMap);
8957 +}
8958 +
8959 +/* ......................................................................... */
8960 +
8961 +#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
8962 +static t_Error TgecTxEccWorkaround(t_Tgec *p_Tgec)
8963 +{
8964 + t_Error err;
8965 +
8966 +#if defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)
8967 + XX_Print("Applying 10G TX ECC workaround (10GMAC-A004) ... ");
8968 +#endif /* (DEBUG_ERRORS > 0) */
8969 + /* enable and set promiscuous */
8970 + fman_tgec_enable(p_Tgec->p_MemMap, TRUE, TRUE);
8971 + fman_tgec_set_promiscuous(p_Tgec->p_MemMap, TRUE);
8972 + err = Fm10GTxEccWorkaround(p_Tgec->fmMacControllerDriver.h_Fm, p_Tgec->macId);
8973 + /* disable */
8974 + fman_tgec_set_promiscuous(p_Tgec->p_MemMap, FALSE);
8975 + fman_tgec_enable(p_Tgec->p_MemMap, FALSE, FALSE);
8976 + fman_tgec_reset_stat(p_Tgec->p_MemMap);
8977 + fman_tgec_ack_event(p_Tgec->p_MemMap, 0xffffffff);
8978 +#if defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)
8979 + if (err)
8980 + XX_Print("FAILED!\n");
8981 + else
8982 + XX_Print("done.\n");
8983 +#endif /* (DEBUG_ERRORS > 0) */
8984 +
8985 + return err;
8986 +}
8987 +#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
8988 +
8989 +/*****************************************************************************/
8990 +/* FM Init & Free API */
8991 +/*****************************************************************************/
8992 +
8993 +/* ......................................................................... */
8994 +
8995 +static t_Error TgecInit(t_Handle h_Tgec)
8996 +{
8997 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
8998 + struct tgec_cfg *p_TgecDriverParam;
8999 + t_EnetAddr ethAddr;
9000 + t_Error err;
9001 +
9002 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
9003 + SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
9004 + SANITY_CHECK_RETURN_ERROR(p_Tgec->fmMacControllerDriver.h_Fm, E_INVALID_HANDLE);
9005 +
9006 + FM_GetRevision(p_Tgec->fmMacControllerDriver.h_Fm, &p_Tgec->fmMacControllerDriver.fmRevInfo);
9007 + CHECK_INIT_PARAMETERS(p_Tgec, CheckInitParameters);
9008 +
9009 + p_TgecDriverParam = p_Tgec->p_TgecDriverParam;
9010 +
9011 + MAKE_ENET_ADDR_FROM_UINT64(p_Tgec->addr, ethAddr);
9012 + fman_tgec_set_mac_address(p_Tgec->p_MemMap, (uint8_t *)ethAddr);
9013 +
9014 + /* interrupts */
9015 +#ifdef FM_10G_REM_N_LCL_FLT_EX_10GMAC_ERRATA_SW005
9016 + {
9017 + if (p_Tgec->fmMacControllerDriver.fmRevInfo.majorRev <=2)
9018 + p_Tgec->exceptions &= ~(TGEC_IMASK_REM_FAULT | TGEC_IMASK_LOC_FAULT);
9019 + }
9020 +#endif /* FM_10G_REM_N_LCL_FLT_EX_10GMAC_ERRATA_SW005 */
9021 +
9022 +#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
9023 + if (!p_Tgec->p_TgecDriverParam->skip_fman11_workaround &&
9024 + ((err = TgecTxEccWorkaround(p_Tgec)) != E_OK))
9025 + {
9026 + FreeInitResources(p_Tgec);
9027 + REPORT_ERROR(MINOR, err, ("TgecTxEccWorkaround FAILED"));
9028 + }
9029 +#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
9030 +
9031 + err = fman_tgec_init(p_Tgec->p_MemMap, p_TgecDriverParam, p_Tgec->exceptions);
9032 + if (err)
9033 + {
9034 + FreeInitResources(p_Tgec);
9035 + RETURN_ERROR(MAJOR, err, ("This TGEC version does not support the required i/f mode"));
9036 + }
9037 +
9038 + /* Max Frame Length */
9039 + err = FmSetMacMaxFrame(p_Tgec->fmMacControllerDriver.h_Fm,
9040 + e_FM_MAC_10G,
9041 + p_Tgec->fmMacControllerDriver.macId,
9042 + p_TgecDriverParam->max_frame_length);
9043 + if (err != E_OK)
9044 + {
9045 + FreeInitResources(p_Tgec);
9046 + RETURN_ERROR(MINOR, err, NO_MSG);
9047 + }
9048 +/* we consider having no IPC a non crasher... */
9049 +
9050 +#ifdef FM_TX_FIFO_CORRUPTION_ERRATA_10GMAC_A007
9051 + if (p_Tgec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
9052 + fman_tgec_set_erratum_tx_fifo_corruption_10gmac_a007(p_Tgec->p_MemMap);
9053 +#endif /* FM_TX_FIFO_CORRUPTION_ERRATA_10GMAC_A007 */
9054 +
9055 + p_Tgec->p_MulticastAddrHash = AllocHashTable(HASH_TABLE_SIZE);
9056 + if (!p_Tgec->p_MulticastAddrHash)
9057 + {
9058 + FreeInitResources(p_Tgec);
9059 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("allocation hash table is FAILED"));
9060 + }
9061 +
9062 + p_Tgec->p_UnicastAddrHash = AllocHashTable(HASH_TABLE_SIZE);
9063 + if (!p_Tgec->p_UnicastAddrHash)
9064 + {
9065 + FreeInitResources(p_Tgec);
9066 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("allocation hash table is FAILED"));
9067 + }
9068 +
9069 + FmRegisterIntr(p_Tgec->fmMacControllerDriver.h_Fm,
9070 + e_FM_MOD_10G_MAC,
9071 + p_Tgec->macId,
9072 + e_FM_INTR_TYPE_ERR,
9073 + TgecErrException,
9074 + p_Tgec);
9075 + if (p_Tgec->mdioIrq != NO_IRQ)
9076 + {
9077 + XX_SetIntr(p_Tgec->mdioIrq, TgecException, p_Tgec);
9078 + XX_EnableIntr(p_Tgec->mdioIrq);
9079 + }
9080 +
9081 + XX_Free(p_TgecDriverParam);
9082 + p_Tgec->p_TgecDriverParam = NULL;
9083 +
9084 + return E_OK;
9085 +}
9086 +
9087 +/* ......................................................................... */
9088 +
9089 +static t_Error TgecFree(t_Handle h_Tgec)
9090 +{
9091 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
9092 +
9093 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
9094 +
9095 + if (p_Tgec->p_TgecDriverParam)
9096 + {
9097 + /* Called after config */
9098 + XX_Free(p_Tgec->p_TgecDriverParam);
9099 + p_Tgec->p_TgecDriverParam = NULL;
9100 + }
9101 + else
9102 + /* Called after init */
9103 + FreeInitResources(p_Tgec);
9104 +
9105 + XX_Free(p_Tgec);
9106 +
9107 + return E_OK;
9108 +}
9109 +
9110 +/* ......................................................................... */
9111 +
9112 +static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacControllerDriver)
9113 +{
9114 + p_FmMacControllerDriver->f_FM_MAC_Init = TgecInit;
9115 + p_FmMacControllerDriver->f_FM_MAC_Free = TgecFree;
9116 +
9117 + p_FmMacControllerDriver->f_FM_MAC_SetStatistics = NULL;
9118 + p_FmMacControllerDriver->f_FM_MAC_ConfigLoopback = TgecConfigLoopback;
9119 + p_FmMacControllerDriver->f_FM_MAC_ConfigMaxFrameLength = TgecConfigMaxFrameLength;
9120 +
9121 + p_FmMacControllerDriver->f_FM_MAC_ConfigWan = TgecConfigWan;
9122 +
9123 + p_FmMacControllerDriver->f_FM_MAC_ConfigPadAndCrc = NULL; /* TGEC always works with pad+crc */
9124 + p_FmMacControllerDriver->f_FM_MAC_ConfigHalfDuplex = NULL; /* half-duplex is not supported in xgec */
9125 + p_FmMacControllerDriver->f_FM_MAC_ConfigLengthCheck = TgecConfigLengthCheck;
9126 + p_FmMacControllerDriver->f_FM_MAC_ConfigException = TgecConfigException;
9127 + p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit = NULL;
9128 +
9129 +#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
9130 + p_FmMacControllerDriver->f_FM_MAC_ConfigSkipFman11Workaround= TgecConfigSkipFman11Workaround;
9131 +#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
9132 +
9133 + p_FmMacControllerDriver->f_FM_MAC_SetException = TgecSetExcpetion;
9134 +
9135 + p_FmMacControllerDriver->f_FM_MAC_Enable1588TimeStamp = TgecEnable1588TimeStamp;
9136 + p_FmMacControllerDriver->f_FM_MAC_Disable1588TimeStamp = TgecDisable1588TimeStamp;
9137 +
9138 + p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous = TgecSetPromiscuous;
9139 + p_FmMacControllerDriver->f_FM_MAC_AdjustLink = NULL;
9140 + p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan = NULL;
9141 + p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg = NULL;
9142 +
9143 + p_FmMacControllerDriver->f_FM_MAC_Enable = TgecEnable;
9144 + p_FmMacControllerDriver->f_FM_MAC_Disable = TgecDisable;
9145 +
9146 + p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames = TgecTxMacPause;
9147 + p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames = TgecSetTxPauseFrames;
9148 + p_FmMacControllerDriver->f_FM_MAC_SetRxIgnorePauseFrames = TgecRxIgnoreMacPause;
9149 +
9150 + p_FmMacControllerDriver->f_FM_MAC_ResetCounters = TgecResetCounters;
9151 + p_FmMacControllerDriver->f_FM_MAC_GetStatistics = TgecGetStatistics;
9152 +
9153 + p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr = TgecModifyMacAddress;
9154 + p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr = TgecAddHashMacAddress;
9155 + p_FmMacControllerDriver->f_FM_MAC_RemoveHashMacAddr = TgecDelHashMacAddress;
9156 + p_FmMacControllerDriver->f_FM_MAC_AddExactMatchMacAddr = TgecAddExactMatchMacAddress;
9157 + p_FmMacControllerDriver->f_FM_MAC_RemovelExactMatchMacAddr = TgecDelExactMatchMacAddress;
9158 + p_FmMacControllerDriver->f_FM_MAC_GetId = TgecGetId;
9159 + p_FmMacControllerDriver->f_FM_MAC_GetVersion = TgecGetVersion;
9160 + p_FmMacControllerDriver->f_FM_MAC_GetMaxFrameLength = TgecGetMaxFrameLength;
9161 +
9162 + p_FmMacControllerDriver->f_FM_MAC_MII_WritePhyReg = TGEC_MII_WritePhyReg;
9163 + p_FmMacControllerDriver->f_FM_MAC_MII_ReadPhyReg = TGEC_MII_ReadPhyReg;
9164 +}
9165 +
9166 +
9167 +/*****************************************************************************/
9168 +/* Tgec Config Main Entry */
9169 +/*****************************************************************************/
9170 +
9171 +/* ......................................................................... */
9172 +
9173 +t_Handle TGEC_Config(t_FmMacParams *p_FmMacParam)
9174 +{
9175 + t_Tgec *p_Tgec;
9176 + struct tgec_cfg *p_TgecDriverParam;
9177 + uintptr_t baseAddr;
9178 +
9179 + SANITY_CHECK_RETURN_VALUE(p_FmMacParam, E_NULL_POINTER, NULL);
9180 +
9181 + baseAddr = p_FmMacParam->baseAddr;
9182 + /* allocate memory for the UCC GETH data structure. */
9183 + p_Tgec = (t_Tgec *)XX_Malloc(sizeof(t_Tgec));
9184 + if (!p_Tgec)
9185 + {
9186 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("10G MAC driver structure"));
9187 + return NULL;
9188 + }
9189 + memset(p_Tgec, 0, sizeof(t_Tgec));
9190 + InitFmMacControllerDriver(&p_Tgec->fmMacControllerDriver);
9191 +
9192 + /* allocate memory for the 10G MAC driver parameters data structure. */
9193 + p_TgecDriverParam = (struct tgec_cfg *) XX_Malloc(sizeof(struct tgec_cfg));
9194 + if (!p_TgecDriverParam)
9195 + {
9196 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("10G MAC driver parameters"));
9197 + XX_Free(p_Tgec);
9198 + return NULL;
9199 + }
9200 + memset(p_TgecDriverParam, 0, sizeof(struct tgec_cfg));
9201 +
9202 + /* Plant parameter structure pointer */
9203 + p_Tgec->p_TgecDriverParam = p_TgecDriverParam;
9204 +
9205 + fman_tgec_defconfig(p_TgecDriverParam);
9206 +
9207 + p_Tgec->p_MemMap = (struct tgec_regs *)UINT_TO_PTR(baseAddr);
9208 + p_Tgec->p_MiiMemMap = (t_TgecMiiAccessMemMap *)UINT_TO_PTR(baseAddr + TGEC_TO_MII_OFFSET);
9209 + p_Tgec->addr = ENET_ADDR_TO_UINT64(p_FmMacParam->addr);
9210 + p_Tgec->enetMode = p_FmMacParam->enetMode;
9211 + p_Tgec->macId = p_FmMacParam->macId;
9212 + p_Tgec->exceptions = DEFAULT_exceptions;
9213 + p_Tgec->mdioIrq = p_FmMacParam->mdioIrq;
9214 + p_Tgec->f_Exception = p_FmMacParam->f_Exception;
9215 + p_Tgec->f_Event = p_FmMacParam->f_Event;
9216 + p_Tgec->h_App = p_FmMacParam->h_App;
9217 +
9218 + return p_Tgec;
9219 +}
9220 --- /dev/null
9221 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec.h
9222 @@ -0,0 +1,151 @@
9223 +/*
9224 + * Copyright 2008-2012 Freescale Semiconductor Inc.
9225 + *
9226 + * Redistribution and use in source and binary forms, with or without
9227 + * modification, are permitted provided that the following conditions are met:
9228 + * * Redistributions of source code must retain the above copyright
9229 + * notice, this list of conditions and the following disclaimer.
9230 + * * Redistributions in binary form must reproduce the above copyright
9231 + * notice, this list of conditions and the following disclaimer in the
9232 + * documentation and/or other materials provided with the distribution.
9233 + * * Neither the name of Freescale Semiconductor nor the
9234 + * names of its contributors may be used to endorse or promote products
9235 + * derived from this software without specific prior written permission.
9236 + *
9237 + *
9238 + * ALTERNATIVELY, this software may be distributed under the terms of the
9239 + * GNU General Public License ("GPL") as published by the Free Software
9240 + * Foundation, either version 2 of that License or (at your option) any
9241 + * later version.
9242 + *
9243 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
9244 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9245 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
9246 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
9247 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
9248 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
9249 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
9250 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
9251 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
9252 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9253 + */
9254 +
9255 +
9256 +/******************************************************************************
9257 + @File tgec.h
9258 +
9259 + @Description FM 10G MAC ...
9260 +*//***************************************************************************/
9261 +#ifndef __TGEC_H
9262 +#define __TGEC_H
9263 +
9264 +#include "std_ext.h"
9265 +#include "error_ext.h"
9266 +#include "list_ext.h"
9267 +#include "enet_ext.h"
9268 +
9269 +#include "tgec_mii_acc.h"
9270 +#include "fm_mac.h"
9271 +
9272 +
9273 +#define DEFAULT_exceptions \
9274 + ((uint32_t)(TGEC_IMASK_MDIO_SCAN_EVENT | \
9275 + TGEC_IMASK_REM_FAULT | \
9276 + TGEC_IMASK_LOC_FAULT | \
9277 + TGEC_IMASK_TX_ECC_ER | \
9278 + TGEC_IMASK_TX_FIFO_UNFL | \
9279 + TGEC_IMASK_TX_FIFO_OVFL | \
9280 + TGEC_IMASK_TX_ER | \
9281 + TGEC_IMASK_RX_FIFO_OVFL | \
9282 + TGEC_IMASK_RX_ECC_ER | \
9283 + TGEC_IMASK_RX_JAB_FRM | \
9284 + TGEC_IMASK_RX_OVRSZ_FRM | \
9285 + TGEC_IMASK_RX_RUNT_FRM | \
9286 + TGEC_IMASK_RX_FRAG_FRM | \
9287 + TGEC_IMASK_RX_CRC_ER | \
9288 + TGEC_IMASK_RX_ALIGN_ER))
9289 +
9290 +#define GET_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \
9291 + case e_FM_MAC_EX_10G_MDIO_SCAN_EVENTMDIO: \
9292 + bitMask = TGEC_IMASK_MDIO_SCAN_EVENT ; break; \
9293 + case e_FM_MAC_EX_10G_MDIO_CMD_CMPL: \
9294 + bitMask = TGEC_IMASK_MDIO_CMD_CMPL ; break; \
9295 + case e_FM_MAC_EX_10G_REM_FAULT: \
9296 + bitMask = TGEC_IMASK_REM_FAULT ; break; \
9297 + case e_FM_MAC_EX_10G_LOC_FAULT: \
9298 + bitMask = TGEC_IMASK_LOC_FAULT ; break; \
9299 + case e_FM_MAC_EX_10G_1TX_ECC_ER: \
9300 + bitMask = TGEC_IMASK_TX_ECC_ER ; break; \
9301 + case e_FM_MAC_EX_10G_TX_FIFO_UNFL: \
9302 + bitMask = TGEC_IMASK_TX_FIFO_UNFL ; break; \
9303 + case e_FM_MAC_EX_10G_TX_FIFO_OVFL: \
9304 + bitMask = TGEC_IMASK_TX_FIFO_OVFL ; break; \
9305 + case e_FM_MAC_EX_10G_TX_ER: \
9306 + bitMask = TGEC_IMASK_TX_ER ; break; \
9307 + case e_FM_MAC_EX_10G_RX_FIFO_OVFL: \
9308 + bitMask = TGEC_IMASK_RX_FIFO_OVFL ; break; \
9309 + case e_FM_MAC_EX_10G_RX_ECC_ER: \
9310 + bitMask = TGEC_IMASK_RX_ECC_ER ; break; \
9311 + case e_FM_MAC_EX_10G_RX_JAB_FRM: \
9312 + bitMask = TGEC_IMASK_RX_JAB_FRM ; break; \
9313 + case e_FM_MAC_EX_10G_RX_OVRSZ_FRM: \
9314 + bitMask = TGEC_IMASK_RX_OVRSZ_FRM ; break; \
9315 + case e_FM_MAC_EX_10G_RX_RUNT_FRM: \
9316 + bitMask = TGEC_IMASK_RX_RUNT_FRM ; break; \
9317 + case e_FM_MAC_EX_10G_RX_FRAG_FRM: \
9318 + bitMask = TGEC_IMASK_RX_FRAG_FRM ; break; \
9319 + case e_FM_MAC_EX_10G_RX_LEN_ER: \
9320 + bitMask = TGEC_IMASK_RX_LEN_ER ; break; \
9321 + case e_FM_MAC_EX_10G_RX_CRC_ER: \
9322 + bitMask = TGEC_IMASK_RX_CRC_ER ; break; \
9323 + case e_FM_MAC_EX_10G_RX_ALIGN_ER: \
9324 + bitMask = TGEC_IMASK_RX_ALIGN_ER ; break; \
9325 + default: bitMask = 0;break;}
9326 +
9327 +#define MAX_PACKET_ALIGNMENT 31
9328 +#define MAX_INTER_PACKET_GAP 0x7f
9329 +#define MAX_INTER_PALTERNATE_BEB 0x0f
9330 +#define MAX_RETRANSMISSION 0x0f
9331 +#define MAX_COLLISION_WINDOW 0x03ff
9332 +
9333 +#define TGEC_NUM_OF_PADDRS 1 /* number of pattern match registers (entries) */
9334 +
9335 +#define GROUP_ADDRESS 0x0000010000000000LL /* Group address bit indication */
9336 +
9337 +#define HASH_TABLE_SIZE 512 /* Hash table size (= 32 bits * 8 regs) */
9338 +
9339 +#define TGEC_TO_MII_OFFSET 0x1030 /* Offset from the MEM map to the MDIO mem map */
9340 +
9341 +/* 10-gigabit Ethernet MAC Controller ID (10GEC_ID) */
9342 +#define TGEC_ID_ID 0xffff0000
9343 +#define TGEC_ID_MAC_VERSION 0x0000FF00
9344 +#define TGEC_ID_MAC_REV 0x000000ff
9345 +
9346 +
9347 +typedef struct {
9348 + t_FmMacControllerDriver fmMacControllerDriver; /**< Upper Mac control block */
9349 + t_Handle h_App; /**< Handle to the upper layer application */
9350 + struct tgec_regs *p_MemMap; /**< pointer to 10G memory mapped registers. */
9351 + t_TgecMiiAccessMemMap *p_MiiMemMap; /**< pointer to MII memory mapped registers. */
9352 + uint64_t addr; /**< MAC address of device; */
9353 + e_EnetMode enetMode; /**< Ethernet physical interface */
9354 + t_FmMacExceptionCallback *f_Exception;
9355 + int mdioIrq;
9356 + t_FmMacExceptionCallback *f_Event;
9357 + bool indAddrRegUsed[TGEC_NUM_OF_PADDRS]; /**< Whether a particular individual address recognition register is being used */
9358 + uint64_t paddr[TGEC_NUM_OF_PADDRS]; /**< MAC address for particular individual address recognition register */
9359 + uint8_t numOfIndAddrInRegs; /**< Number of individual addresses in registers for this station. */
9360 + t_EthHash *p_MulticastAddrHash; /**< pointer to driver's global address hash table */
9361 + t_EthHash *p_UnicastAddrHash; /**< pointer to driver's individual address hash table */
9362 + bool debugMode;
9363 + uint8_t macId;
9364 + uint32_t exceptions;
9365 + struct tgec_cfg *p_TgecDriverParam;
9366 +} t_Tgec;
9367 +
9368 +
9369 +t_Error TGEC_MII_WritePhyReg(t_Handle h_Tgec, uint8_t phyAddr, uint8_t reg, uint16_t data);
9370 +t_Error TGEC_MII_ReadPhyReg(t_Handle h_Tgec, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);
9371 +
9372 +
9373 +#endif /* __TGEC_H */
9374 --- /dev/null
9375 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec_mii_acc.c
9376 @@ -0,0 +1,139 @@
9377 +/*
9378 + * Copyright 2008-2012 Freescale Semiconductor Inc.
9379 + *
9380 + * Redistribution and use in source and binary forms, with or without
9381 + * modification, are permitted provided that the following conditions are met:
9382 + * * Redistributions of source code must retain the above copyright
9383 + * notice, this list of conditions and the following disclaimer.
9384 + * * Redistributions in binary form must reproduce the above copyright
9385 + * notice, this list of conditions and the following disclaimer in the
9386 + * documentation and/or other materials provided with the distribution.
9387 + * * Neither the name of Freescale Semiconductor nor the
9388 + * names of its contributors may be used to endorse or promote products
9389 + * derived from this software without specific prior written permission.
9390 + *
9391 + *
9392 + * ALTERNATIVELY, this software may be distributed under the terms of the
9393 + * GNU General Public License ("GPL") as published by the Free Software
9394 + * Foundation, either version 2 of that License or (at your option) any
9395 + * later version.
9396 + *
9397 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
9398 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9399 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
9400 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
9401 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
9402 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
9403 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
9404 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
9405 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
9406 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9407 + */
9408 +
9409 +
9410 +
9411 +#include "error_ext.h"
9412 +#include "std_ext.h"
9413 +#include "fm_mac.h"
9414 +#include "tgec.h"
9415 +#include "xx_ext.h"
9416 +
9417 +#include "fm_common.h"
9418 +
9419 +
9420 +/*****************************************************************************/
9421 +t_Error TGEC_MII_WritePhyReg(t_Handle h_Tgec,
9422 + uint8_t phyAddr,
9423 + uint8_t reg,
9424 + uint16_t data)
9425 +{
9426 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
9427 + t_TgecMiiAccessMemMap *p_MiiAccess;
9428 + uint32_t cfgStatusReg;
9429 +
9430 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
9431 + SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MiiMemMap, E_INVALID_HANDLE);
9432 +
9433 + p_MiiAccess = p_Tgec->p_MiiMemMap;
9434 +
9435 + /* Configure MII */
9436 + cfgStatusReg = GET_UINT32(p_MiiAccess->mdio_cfg_status);
9437 + cfgStatusReg &= ~MIIMCOM_DIV_MASK;
9438 + /* (one half of fm clock => 2.5Mhz) */
9439 + cfgStatusReg |=((((p_Tgec->fmMacControllerDriver.clkFreq*10)/2)/25) << MIIMCOM_DIV_SHIFT);
9440 + WRITE_UINT32(p_MiiAccess->mdio_cfg_status, cfgStatusReg);
9441 +
9442 + while ((GET_UINT32(p_MiiAccess->mdio_cfg_status)) & MIIMIND_BUSY)
9443 + XX_UDelay (1);
9444 +
9445 + WRITE_UINT32(p_MiiAccess->mdio_command, phyAddr);
9446 +
9447 + WRITE_UINT32(p_MiiAccess->mdio_regaddr, reg);
9448 +
9449 + CORE_MemoryBarrier();
9450 +
9451 + while ((GET_UINT32(p_MiiAccess->mdio_cfg_status)) & MIIMIND_BUSY)
9452 + XX_UDelay (1);
9453 +
9454 + WRITE_UINT32(p_MiiAccess->mdio_data, data);
9455 +
9456 + CORE_MemoryBarrier();
9457 +
9458 + while ((GET_UINT32(p_MiiAccess->mdio_data)) & MIIDATA_BUSY)
9459 + XX_UDelay (1);
9460 +
9461 + return E_OK;
9462 +}
9463 +
9464 +/*****************************************************************************/
9465 +t_Error TGEC_MII_ReadPhyReg(t_Handle h_Tgec,
9466 + uint8_t phyAddr,
9467 + uint8_t reg,
9468 + uint16_t *p_Data)
9469 +{
9470 + t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
9471 + t_TgecMiiAccessMemMap *p_MiiAccess;
9472 + uint32_t cfgStatusReg;
9473 +
9474 + SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
9475 + SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MiiMemMap, E_INVALID_HANDLE);
9476 +
9477 + p_MiiAccess = p_Tgec->p_MiiMemMap;
9478 +
9479 + /* Configure MII */
9480 + cfgStatusReg = GET_UINT32(p_MiiAccess->mdio_cfg_status);
9481 + cfgStatusReg &= ~MIIMCOM_DIV_MASK;
9482 + /* (one half of fm clock => 2.5Mhz) */
9483 + cfgStatusReg |=((((p_Tgec->fmMacControllerDriver.clkFreq*10)/2)/25) << MIIMCOM_DIV_SHIFT);
9484 + WRITE_UINT32(p_MiiAccess->mdio_cfg_status, cfgStatusReg);
9485 +
9486 + while ((GET_UINT32(p_MiiAccess->mdio_cfg_status)) & MIIMIND_BUSY)
9487 + XX_UDelay (1);
9488 +
9489 + WRITE_UINT32(p_MiiAccess->mdio_command, phyAddr);
9490 +
9491 + WRITE_UINT32(p_MiiAccess->mdio_regaddr, reg);
9492 +
9493 + CORE_MemoryBarrier();
9494 +
9495 + while ((GET_UINT32(p_MiiAccess->mdio_cfg_status)) & MIIMIND_BUSY)
9496 + XX_UDelay (1);
9497 +
9498 + WRITE_UINT32(p_MiiAccess->mdio_command, (uint32_t)(phyAddr | MIIMCOM_READ_CYCLE));
9499 +
9500 + CORE_MemoryBarrier();
9501 +
9502 + while ((GET_UINT32(p_MiiAccess->mdio_data)) & MIIDATA_BUSY)
9503 + XX_UDelay (1);
9504 +
9505 + *p_Data = (uint16_t)GET_UINT32(p_MiiAccess->mdio_data);
9506 +
9507 + cfgStatusReg = GET_UINT32(p_MiiAccess->mdio_cfg_status);
9508 +
9509 + if (cfgStatusReg & MIIMIND_READ_ERROR)
9510 + RETURN_ERROR(MINOR, E_INVALID_VALUE,
9511 + ("Read Error: phyAddr 0x%x, dev 0x%x, reg 0x%x, cfgStatusReg 0x%x",
9512 + ((phyAddr & 0xe0)>>5), (phyAddr & 0x1f), reg, cfgStatusReg));
9513 +
9514 + return E_OK;
9515 +}
9516 --- /dev/null
9517 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec_mii_acc.h
9518 @@ -0,0 +1,80 @@
9519 +/*
9520 + * Copyright 2008-2012 Freescale Semiconductor Inc.
9521 + *
9522 + * Redistribution and use in source and binary forms, with or without
9523 + * modification, are permitted provided that the following conditions are met:
9524 + * * Redistributions of source code must retain the above copyright
9525 + * notice, this list of conditions and the following disclaimer.
9526 + * * Redistributions in binary form must reproduce the above copyright
9527 + * notice, this list of conditions and the following disclaimer in the
9528 + * documentation and/or other materials provided with the distribution.
9529 + * * Neither the name of Freescale Semiconductor nor the
9530 + * names of its contributors may be used to endorse or promote products
9531 + * derived from this software without specific prior written permission.
9532 + *
9533 + *
9534 + * ALTERNATIVELY, this software may be distributed under the terms of the
9535 + * GNU General Public License ("GPL") as published by the Free Software
9536 + * Foundation, either version 2 of that License or (at your option) any
9537 + * later version.
9538 + *
9539 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
9540 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9541 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
9542 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
9543 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
9544 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
9545 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
9546 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
9547 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
9548 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9549 + */
9550 +
9551 +
9552 +#ifndef __TGEC_MII_ACC_H
9553 +#define __TGEC_MII_ACC_H
9554 +
9555 +#include "std_ext.h"
9556 +
9557 +
9558 +/* MII Management Command Register */
9559 +#define MIIMCOM_READ_POST_INCREMENT 0x00004000
9560 +#define MIIMCOM_READ_CYCLE 0x00008000
9561 +#define MIIMCOM_SCAN_CYCLE 0x00000800
9562 +#define MIIMCOM_PREAMBLE_DISABLE 0x00000400
9563 +
9564 +#define MIIMCOM_MDIO_HOLD_1_REG_CLK 0
9565 +#define MIIMCOM_MDIO_HOLD_2_REG_CLK 1
9566 +#define MIIMCOM_MDIO_HOLD_3_REG_CLK 2
9567 +#define MIIMCOM_MDIO_HOLD_4_REG_CLK 3
9568 +
9569 +#define MIIMCOM_DIV_MASK 0x0000ff00
9570 +#define MIIMCOM_DIV_SHIFT 8
9571 +
9572 +/* MII Management Indicator Register */
9573 +#define MIIMIND_BUSY 0x00000001
9574 +#define MIIMIND_READ_ERROR 0x00000002
9575 +
9576 +#define MIIDATA_BUSY 0x80000000
9577 +
9578 +#if defined(__MWERKS__) && !defined(__GNUC__)
9579 +#pragma pack(push,1)
9580 +#endif /* defined(__MWERKS__) && ... */
9581 +
9582 +/*----------------------------------------------------*/
9583 +/* MII Configuration Control Memory Map Registers */
9584 +/*----------------------------------------------------*/
9585 +typedef _Packed struct t_TgecMiiAccessMemMap
9586 +{
9587 + volatile uint32_t mdio_cfg_status; /* 0x030 */
9588 + volatile uint32_t mdio_command; /* 0x034 */
9589 + volatile uint32_t mdio_data; /* 0x038 */
9590 + volatile uint32_t mdio_regaddr; /* 0x03c */
9591 +} _PackedType t_TgecMiiAccessMemMap ;
9592 +
9593 +#if defined(__MWERKS__) && !defined(__GNUC__)
9594 +#pragma pack(pop)
9595 +#endif /* defined(__MWERKS__) && ... */
9596 +
9597 +
9598 +#endif /* __TGEC_MII_ACC_H */
9599 --- /dev/null
9600 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/Makefile
9601 @@ -0,0 +1,15 @@
9602 +#
9603 +# Makefile for the Freescale Ethernet controllers
9604 +#
9605 +ccflags-y += -DVERSION=\"\"
9606 +#
9607 +#Include netcomm SW specific definitions
9608 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
9609 +
9610 +NCSW_FM_INC = $(srctree)/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc
9611 +
9612 +ccflags-y += -I$(NCSW_FM_INC)
9613 +
9614 +obj-y += fsl-ncsw-macsec.o
9615 +
9616 +fsl-ncsw-macsec-objs := fm_macsec.o fm_macsec_guest.o fm_macsec_master.o fm_macsec_secy.o
9617 --- /dev/null
9618 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec.c
9619 @@ -0,0 +1,237 @@
9620 +/*
9621 + * Copyright 2008-2015 Freescale Semiconductor Inc.
9622 + *
9623 + * Redistribution and use in source and binary forms, with or without
9624 + * modification, are permitted provided that the following conditions are met:
9625 + * * Redistributions of source code must retain the above copyright
9626 + * notice, this list of conditions and the following disclaimer.
9627 + * * Redistributions in binary form must reproduce the above copyright
9628 + * notice, this list of conditions and the following disclaimer in the
9629 + * documentation and/or other materials provided with the distribution.
9630 + * * Neither the name of Freescale Semiconductor nor the
9631 + * names of its contributors may be used to endorse or promote products
9632 + * derived from this software without specific prior written permission.
9633 + *
9634 + *
9635 + * ALTERNATIVELY, this software may be distributed under the terms of the
9636 + * GNU General Public License ("GPL") as published by the Free Software
9637 + * Foundation, either version 2 of that License or (at your option) any
9638 + * later version.
9639 + *
9640 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
9641 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9642 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
9643 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
9644 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
9645 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
9646 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
9647 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
9648 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
9649 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9650 + */
9651 +/******************************************************************************
9652 +
9653 + @File fm_macsec.c
9654 +
9655 + @Description FM MACSEC driver routines implementation.
9656 +*//***************************************************************************/
9657 +
9658 +#include "std_ext.h"
9659 +#include "error_ext.h"
9660 +#include "xx_ext.h"
9661 +#include "string_ext.h"
9662 +#include "sprint_ext.h"
9663 +#include "debug_ext.h"
9664 +
9665 +#include "fm_macsec.h"
9666 +
9667 +
9668 +/****************************************/
9669 +/* API Init unit functions */
9670 +/****************************************/
9671 +t_Handle FM_MACSEC_Config(t_FmMacsecParams *p_FmMacsecParam)
9672 +{
9673 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver;
9674 +
9675 + SANITY_CHECK_RETURN_VALUE(p_FmMacsecParam, E_INVALID_HANDLE, NULL);
9676 +
9677 + if (p_FmMacsecParam->guestMode)
9678 + p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)FM_MACSEC_GUEST_Config(p_FmMacsecParam);
9679 + else
9680 + p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)FM_MACSEC_MASTER_Config(p_FmMacsecParam);
9681 +
9682 + if (!p_FmMacsecControllerDriver)
9683 + return NULL;
9684 +
9685 + return (t_Handle)p_FmMacsecControllerDriver;
9686 +}
9687 +
9688 +t_Error FM_MACSEC_Init(t_Handle h_FmMacsec)
9689 +{
9690 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9691 +
9692 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9693 +
9694 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_Init)
9695 + return p_FmMacsecControllerDriver->f_FM_MACSEC_Init(h_FmMacsec);
9696 +
9697 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9698 +}
9699 +
9700 +t_Error FM_MACSEC_Free(t_Handle h_FmMacsec)
9701 +{
9702 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9703 +
9704 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9705 +
9706 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_Free)
9707 + return p_FmMacsecControllerDriver->f_FM_MACSEC_Free(h_FmMacsec);
9708 +
9709 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9710 +}
9711 +
9712 +t_Error FM_MACSEC_ConfigUnknownSciFrameTreatment(t_Handle h_FmMacsec, e_FmMacsecUnknownSciFrameTreatment treatMode)
9713 +{
9714 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9715 +
9716 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9717 +
9718 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigUnknownSciFrameTreatment)
9719 + return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigUnknownSciFrameTreatment(h_FmMacsec, treatMode);
9720 +
9721 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9722 +}
9723 +
9724 +t_Error FM_MACSEC_ConfigInvalidTagsFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled)
9725 +{
9726 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9727 +
9728 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9729 +
9730 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigInvalidTagsFrameTreatment)
9731 + return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigInvalidTagsFrameTreatment(h_FmMacsec, deliverUncontrolled);
9732 +
9733 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9734 +}
9735 +
9736 +t_Error FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment(t_Handle h_FmMacsec, bool discardUncontrolled)
9737 +{
9738 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9739 +
9740 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9741 +
9742 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment)
9743 + return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment(h_FmMacsec, discardUncontrolled);
9744 +
9745 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9746 +}
9747 +
9748 +t_Error FM_MACSEC_ConfigUntagFrameTreatment(t_Handle h_FmMacsec, e_FmMacsecUntagFrameTreatment treatMode)
9749 +{
9750 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9751 +
9752 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9753 +
9754 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigUntagFrameTreatment)
9755 + return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigUntagFrameTreatment(h_FmMacsec, treatMode);
9756 +
9757 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9758 +}
9759 +
9760 +t_Error FM_MACSEC_ConfigPnExhaustionThreshold(t_Handle h_FmMacsec, uint32_t pnExhThr)
9761 +{
9762 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9763 +
9764 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9765 +
9766 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigPnExhaustionThreshold)
9767 + return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigPnExhaustionThreshold(h_FmMacsec, pnExhThr);
9768 +
9769 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9770 +}
9771 +
9772 +t_Error FM_MACSEC_ConfigKeysUnreadable(t_Handle h_FmMacsec)
9773 +{
9774 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9775 +
9776 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9777 +
9778 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigKeysUnreadable)
9779 + return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigKeysUnreadable(h_FmMacsec);
9780 +
9781 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9782 +}
9783 +
9784 +t_Error FM_MACSEC_ConfigSectagWithoutSCI(t_Handle h_FmMacsec)
9785 +{
9786 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9787 +
9788 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9789 +
9790 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigSectagWithoutSCI)
9791 + return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigSectagWithoutSCI(h_FmMacsec);
9792 +
9793 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9794 +}
9795 +
9796 +t_Error FM_MACSEC_ConfigException(t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable)
9797 +{
9798 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9799 +
9800 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9801 +
9802 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigException)
9803 + return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigException(h_FmMacsec, exception, enable);
9804 +
9805 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9806 +}
9807 +
9808 +t_Error FM_MACSEC_GetRevision(t_Handle h_FmMacsec, uint32_t *p_MacsecRevision)
9809 +{
9810 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9811 +
9812 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9813 +
9814 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_GetRevision)
9815 + return p_FmMacsecControllerDriver->f_FM_MACSEC_GetRevision(h_FmMacsec, p_MacsecRevision);
9816 +
9817 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9818 +}
9819 +
9820 +
9821 +t_Error FM_MACSEC_Enable(t_Handle h_FmMacsec)
9822 +{
9823 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9824 +
9825 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9826 +
9827 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_Enable)
9828 + return p_FmMacsecControllerDriver->f_FM_MACSEC_Enable(h_FmMacsec);
9829 +
9830 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9831 +}
9832 +
9833 +t_Error FM_MACSEC_Disable(t_Handle h_FmMacsec)
9834 +{
9835 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9836 +
9837 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9838 +
9839 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_Disable)
9840 + return p_FmMacsecControllerDriver->f_FM_MACSEC_Disable(h_FmMacsec);
9841 +
9842 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9843 +}
9844 +
9845 +t_Error FM_MACSEC_SetException(t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable)
9846 +{
9847 + t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
9848 +
9849 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
9850 +
9851 + if (p_FmMacsecControllerDriver->f_FM_MACSEC_SetException)
9852 + return p_FmMacsecControllerDriver->f_FM_MACSEC_SetException(h_FmMacsec, exception, enable);
9853 +
9854 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
9855 +}
9856 +
9857 --- /dev/null
9858 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec.h
9859 @@ -0,0 +1,203 @@
9860 +/*
9861 + * Copyright 2008-2015 Freescale Semiconductor Inc.
9862 + *
9863 + * Redistribution and use in source and binary forms, with or without
9864 + * modification, are permitted provided that the following conditions are met:
9865 + * * Redistributions of source code must retain the above copyright
9866 + * notice, this list of conditions and the following disclaimer.
9867 + * * Redistributions in binary form must reproduce the above copyright
9868 + * notice, this list of conditions and the following disclaimer in the
9869 + * documentation and/or other materials provided with the distribution.
9870 + * * Neither the name of Freescale Semiconductor nor the
9871 + * names of its contributors may be used to endorse or promote products
9872 + * derived from this software without specific prior written permission.
9873 + *
9874 + *
9875 + * ALTERNATIVELY, this software may be distributed under the terms of the
9876 + * GNU General Public License ("GPL") as published by the Free Software
9877 + * Foundation, either version 2 of that License or (at your option) any
9878 + * later version.
9879 + *
9880 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
9881 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9882 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
9883 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
9884 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
9885 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
9886 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
9887 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
9888 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
9889 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9890 + */
9891 +
9892 +/******************************************************************************
9893 + @File fm_macsec.h
9894 +
9895 + @Description FM MACSEC internal structures and definitions.
9896 +*//***************************************************************************/
9897 +#ifndef __FM_MACSEC_H
9898 +#define __FM_MACSEC_H
9899 +
9900 +#include "error_ext.h"
9901 +#include "std_ext.h"
9902 +#include "fm_macsec_ext.h"
9903 +
9904 +#include "fm_common.h"
9905 +
9906 +
9907 +#define __ERR_MODULE__ MODULE_FM_MACSEC
9908 +
9909 +
9910 +typedef struct
9911 +{
9912 + t_Error (*f_FM_MACSEC_Init) (t_Handle h_FmMacsec);
9913 + t_Error (*f_FM_MACSEC_Free) (t_Handle h_FmMacsec);
9914 +
9915 + t_Error (*f_FM_MACSEC_ConfigUnknownSciFrameTreatment) (t_Handle h_FmMacsec, e_FmMacsecUnknownSciFrameTreatment treatMode);
9916 + t_Error (*f_FM_MACSEC_ConfigInvalidTagsFrameTreatment) (t_Handle h_FmMacsec, bool deliverUncontrolled);
9917 + t_Error (*f_FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment) (t_Handle h_FmMacsec, bool discardUncontrolled);
9918 + t_Error (*f_FM_MACSEC_ConfigChangedTextWithNoEncryptFrameTreatment) (t_Handle h_FmMacsec, bool deliverUncontrolled);
9919 + t_Error (*f_FM_MACSEC_ConfigUntagFrameTreatment) (t_Handle h_FmMacsec, e_FmMacsecUntagFrameTreatment treatMode);
9920 + t_Error (*f_FM_MACSEC_ConfigOnlyScbIsSetFrameTreatment) (t_Handle h_FmMacsec, bool deliverUncontrolled);
9921 + t_Error (*f_FM_MACSEC_ConfigPnExhaustionThreshold) (t_Handle h_FmMacsec, uint32_t pnExhThr);
9922 + t_Error (*f_FM_MACSEC_ConfigKeysUnreadable) (t_Handle h_FmMacsec);
9923 + t_Error (*f_FM_MACSEC_ConfigSectagWithoutSCI) (t_Handle h_FmMacsec);
9924 + t_Error (*f_FM_MACSEC_ConfigException) (t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable);
9925 +
9926 + t_Error (*f_FM_MACSEC_GetRevision) (t_Handle h_FmMacsec, uint32_t *p_MacsecRevision);
9927 + t_Error (*f_FM_MACSEC_Enable) (t_Handle h_FmMacsec);
9928 + t_Error (*f_FM_MACSEC_Disable) (t_Handle h_FmMacsec);
9929 + t_Error (*f_FM_MACSEC_SetException) (t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable);
9930 +
9931 +} t_FmMacsecControllerDriver;
9932 +
9933 +t_Handle FM_MACSEC_GUEST_Config(t_FmMacsecParams *p_FmMacsecParam);
9934 +t_Handle FM_MACSEC_MASTER_Config(t_FmMacsecParams *p_FmMacsecParams);
9935 +
9936 +/***********************************************************************/
9937 +/* MACSEC internal routines */
9938 +/***********************************************************************/
9939 +
9940 +/**************************************************************************//**
9941 +
9942 + @Group FM_MACSEC_InterModule_grp FM MACSEC Inter-Module Unit
9943 +
9944 + @Description FM MACSEC Inter Module functions -
9945 + These are not User API routines but routines that may be called
9946 + from other modules. This will be the case in a single core environment,
9947 + where instead of using the XX messaging mechanism, the routines may be
9948 + called from other modules. In a multicore environment, the other modules may
9949 + be run by other cores and therefore these routines may not be called directly.
9950 +
9951 + @{
9952 +*//***************************************************************************/
9953 +
9954 +#define MAX_NUM_OF_SA_PER_SC 4
9955 +
9956 +typedef enum
9957 +{
9958 + e_SC_RX = 0,
9959 + e_SC_TX
9960 +} e_ScType;
9961 +
9962 +typedef enum
9963 +{
9964 + e_SC_SA_A = 0,
9965 + e_SC_SA_B ,
9966 + e_SC_SA_C ,
9967 + e_SC_SA_D
9968 +} e_ScSaId;
9969 +
9970 +typedef struct
9971 +{
9972 + uint32_t scId;
9973 + macsecSCI_t sci;
9974 + bool replayProtect;
9975 + uint32_t replayWindow;
9976 + e_FmMacsecValidFrameBehavior validateFrames;
9977 + uint16_t confidentialityOffset;
9978 + e_FmMacsecSecYCipherSuite cipherSuite;
9979 +} t_RxScParams;
9980 +
9981 +typedef struct
9982 +{
9983 + uint32_t scId;
9984 + macsecSCI_t sci;
9985 + bool protectFrames;
9986 + e_FmMacsecSciInsertionMode sciInsertionMode;
9987 + bool confidentialityEnable;
9988 + uint16_t confidentialityOffset;
9989 + e_FmMacsecSecYCipherSuite cipherSuite;
9990 +} t_TxScParams;
9991 +
9992 +typedef enum e_FmMacsecGlobalExceptions {
9993 + e_FM_MACSEC_EX_TX_SC, /**< Tx Sc 0 frame discarded error. */
9994 + e_FM_MACSEC_EX_ECC /**< MACSEC memory ECC multiple-bit error. */
9995 +} e_FmMacsecGlobalExceptions;
9996 +
9997 +typedef enum e_FmMacsecGlobalEvents {
9998 + e_FM_MACSEC_EV_TX_SC_NEXT_PN /**< Tx Sc 0 Next Pn exhaustion threshold reached. */
9999 +} e_FmMacsecGlobalEvents;
10000 +
10001 +/**************************************************************************//**
10002 + @Description Enum for inter-module interrupts registration
10003 +*//***************************************************************************/
10004 +typedef enum e_FmMacsecEventModules{
10005 + e_FM_MACSEC_MOD_SC_TX,
10006 + e_FM_MACSEC_MOD_DUMMY_LAST
10007 +} e_FmMacsecEventModules;
10008 +
10009 +typedef enum e_FmMacsecInterModuleEvent {
10010 + e_FM_MACSEC_EV_SC_TX,
10011 + e_FM_MACSEC_EV_ERR_SC_TX,
10012 + e_FM_MACSEC_EV_DUMMY_LAST
10013 +} e_FmMacsecInterModuleEvent;
10014 +
10015 +#define NUM_OF_INTER_MODULE_EVENTS (NUM_OF_TX_SC * 2)
10016 +
10017 +#define GET_MACSEC_MODULE_EVENT(mod, id, intrType, event) \
10018 + switch(mod){ \
10019 + case e_FM_MACSEC_MOD_SC_TX: \
10020 + event = (intrType == e_FM_INTR_TYPE_ERR) ? \
10021 + e_FM_MACSEC_EV_ERR_SC_TX: \
10022 + e_FM_MACSEC_EV_SC_TX; \
10023 + event += (uint8_t)(2 * id);break; \
10024 + break; \
10025 + default:event = e_FM_MACSEC_EV_DUMMY_LAST; \
10026 + break;}
10027 +
10028 +void FmMacsecRegisterIntr(t_Handle h_FmMacsec,
10029 + e_FmMacsecEventModules module,
10030 + uint8_t modId,
10031 + e_FmIntrType intrType,
10032 + void (*f_Isr) (t_Handle h_Arg, uint32_t id),
10033 + t_Handle h_Arg);
10034 +
10035 +void FmMacsecUnregisterIntr(t_Handle h_FmMacsec,
10036 + e_FmMacsecEventModules module,
10037 + uint8_t modId,
10038 + e_FmIntrType intrType);
10039 +
10040 +t_Error FmMacsecAllocScs(t_Handle h_FmMacsec, e_ScType type, bool isPtp, uint32_t numOfScs, uint32_t *p_ScIds);
10041 +t_Error FmMacsecFreeScs(t_Handle h_FmMacsec, e_ScType type, uint32_t numOfScs, uint32_t *p_ScIds);
10042 +t_Error FmMacsecCreateRxSc(t_Handle h_FmMacsec, t_RxScParams *p_RxScParams);
10043 +t_Error FmMacsecDeleteRxSc(t_Handle h_FmMacsec, uint32_t scId);
10044 +t_Error FmMacsecCreateTxSc(t_Handle h_FmMacsec, t_TxScParams *p_RxScParams);
10045 +t_Error FmMacsecDeleteTxSc(t_Handle h_FmMacsec, uint32_t scId);
10046 +t_Error FmMacsecCreateRxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecAN_t an, uint32_t lowestPn, macsecSAKey_t key);
10047 +t_Error FmMacsecCreateTxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecSAKey_t key);
10048 +t_Error FmMacsecDeleteRxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId);
10049 +t_Error FmMacsecDeleteTxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId);
10050 +t_Error FmMacsecRxSaSetReceive(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, bool enableReceive);
10051 +t_Error FmMacsecRxSaUpdateNextPn(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, uint32_t updtNextPN);
10052 +t_Error FmMacsecRxSaUpdateLowestPn(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, uint32_t updtLowestPN);
10053 +t_Error FmMacsecTxSaSetActive(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecAN_t an);
10054 +t_Error FmMacsecTxSaGetActive(t_Handle h_FmMacsec, uint32_t scId, macsecAN_t *p_An);
10055 +t_Error FmMacsecSetPTP(t_Handle h_FmMacsec, bool enable);
10056 +
10057 +t_Error FmMacsecSetException(t_Handle h_FmMacsec, e_FmMacsecGlobalExceptions exception, uint32_t scId, bool enable);
10058 +t_Error FmMacsecSetEvent(t_Handle h_FmMacsec, e_FmMacsecGlobalEvents event, uint32_t scId, bool enable);
10059 +
10060 +
10061 +
10062 +#endif /* __FM_MACSEC_H */
10063 --- /dev/null
10064 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_guest.c
10065 @@ -0,0 +1,59 @@
10066 +/*
10067 + * Copyright 2008-2015 Freescale Semiconductor Inc.
10068 + *
10069 + * Redistribution and use in source and binary forms, with or without
10070 + * modification, are permitted provided that the following conditions are met:
10071 + * * Redistributions of source code must retain the above copyright
10072 + * notice, this list of conditions and the following disclaimer.
10073 + * * Redistributions in binary form must reproduce the above copyright
10074 + * notice, this list of conditions and the following disclaimer in the
10075 + * documentation and/or other materials provided with the distribution.
10076 + * * Neither the name of Freescale Semiconductor nor the
10077 + * names of its contributors may be used to endorse or promote products
10078 + * derived from this software without specific prior written permission.
10079 + *
10080 + *
10081 + * ALTERNATIVELY, this software may be distributed under the terms of the
10082 + * GNU General Public License ("GPL") as published by the Free Software
10083 + * Foundation, either version 2 of that License or (at your option) any
10084 + * later version.
10085 + *
10086 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
10087 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10088 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
10089 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
10090 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
10091 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
10092 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
10093 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
10094 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
10095 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10096 + */
10097 +
10098 +/******************************************************************************
10099 + @File fm_macsec.c
10100 +
10101 + @Description FM MACSEC driver routines implementation.
10102 +*//***************************************************************************/
10103 +
10104 +#include "std_ext.h"
10105 +#include "error_ext.h"
10106 +#include "xx_ext.h"
10107 +#include "string_ext.h"
10108 +#include "sprint_ext.h"
10109 +#include "debug_ext.h"
10110 +#include "fm_macsec.h"
10111 +
10112 +
10113 +/****************************************/
10114 +/* static functions */
10115 +/****************************************/
10116 +
10117 +/****************************************/
10118 +/* API Init unit functions */
10119 +/****************************************/
10120 +t_Handle FM_MACSEC_GUEST_Config(t_FmMacsecParams *p_FmMacsecParam)
10121 +{
10122 + UNUSED(p_FmMacsecParam);
10123 + return NULL;
10124 +}
10125 --- /dev/null
10126 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_master.c
10127 @@ -0,0 +1,1031 @@
10128 +/*
10129 + * Copyright 2008-2015 Freescale Semiconductor Inc.
10130 + *
10131 + * Redistribution and use in source and binary forms, with or without
10132 + * modification, are permitted provided that the following conditions are met:
10133 + * * Redistributions of source code must retain the above copyright
10134 + * notice, this list of conditions and the following disclaimer.
10135 + * * Redistributions in binary form must reproduce the above copyright
10136 + * notice, this list of conditions and the following disclaimer in the
10137 + * documentation and/or other materials provided with the distribution.
10138 + * * Neither the name of Freescale Semiconductor nor the
10139 + * names of its contributors may be used to endorse or promote products
10140 + * derived from this software without specific prior written permission.
10141 + *
10142 + *
10143 + * ALTERNATIVELY, this software may be distributed under the terms of the
10144 + * GNU General Public License ("GPL") as published by the Free Software
10145 + * Foundation, either version 2 of that License or (at your option) any
10146 + * later version.
10147 + *
10148 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
10149 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10150 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
10151 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
10152 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
10153 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
10154 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
10155 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
10156 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
10157 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10158 + */
10159 +
10160 +/******************************************************************************
10161 + @File fm_macsec.c
10162 +
10163 + @Description FM MACSEC driver routines implementation.
10164 +*//***************************************************************************/
10165 +
10166 +#include "std_ext.h"
10167 +#include "error_ext.h"
10168 +#include "xx_ext.h"
10169 +#include "string_ext.h"
10170 +#include "sprint_ext.h"
10171 +#include "fm_mac_ext.h"
10172 +
10173 +#include "fm_macsec_master.h"
10174 +
10175 +
10176 +extern uint16_t FM_MAC_GetMaxFrameLength(t_Handle FmMac);
10177 +
10178 +
10179 +/****************************************/
10180 +/* static functions */
10181 +/****************************************/
10182 +static t_Error CheckFmMacsecParameters(t_FmMacsec *p_FmMacsec)
10183 +{
10184 + if (!p_FmMacsec->f_Exception)
10185 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exceptions callback not provided"));
10186 +
10187 + return E_OK;
10188 +}
10189 +
10190 +static void UnimplementedIsr(t_Handle h_Arg, uint32_t id)
10191 +{
10192 + UNUSED(h_Arg); UNUSED(id);
10193 +
10194 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unimplemented Isr!"));
10195 +}
10196 +
10197 +static void MacsecEventIsr(t_Handle h_FmMacsec)
10198 +{
10199 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10200 + uint32_t events,event,i;
10201 +
10202 + SANITY_CHECK_RETURN(p_FmMacsec, E_INVALID_HANDLE);
10203 +
10204 + events = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->evr);
10205 + events |= GET_UINT32(p_FmMacsec->p_FmMacsecRegs->ever);
10206 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->evr,events);
10207 +
10208 + for (i=0; i<NUM_OF_TX_SC; i++)
10209 + if (events & FM_MACSEC_EV_TX_SC_NEXT_PN(i))
10210 + {
10211 + GET_MACSEC_MODULE_EVENT(e_FM_MACSEC_MOD_SC_TX, i, e_FM_INTR_TYPE_NORMAL, event);
10212 + p_FmMacsec->intrMng[event].f_Isr(p_FmMacsec->intrMng[event].h_SrcHandle, i);
10213 + }
10214 +}
10215 +
10216 +static void MacsecErrorIsr(t_Handle h_FmMacsec)
10217 +{
10218 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10219 + uint32_t errors,error,i;
10220 +
10221 + SANITY_CHECK_RETURN(p_FmMacsec, E_INVALID_HANDLE);
10222 +
10223 + errors = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->err);
10224 + errors |= GET_UINT32(p_FmMacsec->p_FmMacsecRegs->erer);
10225 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->err,errors);
10226 +
10227 + for (i=0; i<NUM_OF_TX_SC; i++)
10228 + if (errors & FM_MACSEC_EX_TX_SC(i))
10229 + {
10230 + GET_MACSEC_MODULE_EVENT(e_FM_MACSEC_MOD_SC_TX, i, e_FM_INTR_TYPE_ERR, error);
10231 + p_FmMacsec->intrMng[error].f_Isr(p_FmMacsec->intrMng[error].h_SrcHandle, i);
10232 + }
10233 +
10234 + if (errors & FM_MACSEC_EX_ECC)
10235 + {
10236 + uint8_t eccType;
10237 + uint32_t tmpReg;
10238 +
10239 + tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->meec);
10240 + ASSERT_COND(tmpReg & MECC_CAP);
10241 + eccType = (uint8_t)((tmpReg & MECC_CET) >> MECC_CET_SHIFT);
10242 +
10243 + if (!eccType && (p_FmMacsec->userExceptions & FM_MACSEC_USER_EX_SINGLE_BIT_ECC))
10244 + p_FmMacsec->f_Exception(p_FmMacsec->h_App,e_FM_MACSEC_EX_SINGLE_BIT_ECC);
10245 + else if (eccType && (p_FmMacsec->userExceptions & FM_MACSEC_USER_EX_MULTI_BIT_ECC))
10246 + p_FmMacsec->f_Exception(p_FmMacsec->h_App,e_FM_MACSEC_EX_MULTI_BIT_ECC);
10247 + else
10248 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->meec,tmpReg);
10249 + }
10250 +}
10251 +
10252 +static t_Error MacsecInit(t_Handle h_FmMacsec)
10253 +{
10254 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10255 + t_FmMacsecDriverParam *p_FmMacsecDriverParam = NULL;
10256 + uint32_t tmpReg,i,macId;
10257 +
10258 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10259 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10260 +
10261 + CHECK_INIT_PARAMETERS(p_FmMacsec, CheckFmMacsecParameters);
10262 +
10263 + p_FmMacsecDriverParam = p_FmMacsec->p_FmMacsecDriverParam;
10264 +
10265 + for (i=0;i<e_FM_MACSEC_EV_DUMMY_LAST;i++)
10266 + p_FmMacsec->intrMng[i].f_Isr = UnimplementedIsr;
10267 +
10268 + tmpReg = 0;
10269 + tmpReg |= (p_FmMacsecDriverParam->changedTextWithNoEncryptDeliverUncontrolled << CFG_UECT_SHIFT)|
10270 + (p_FmMacsecDriverParam->onlyScbIsSetDeliverUncontrolled << CFG_ESCBT_SHIFT) |
10271 + (p_FmMacsecDriverParam->unknownSciTreatMode << CFG_USFT_SHIFT) |
10272 + (p_FmMacsecDriverParam->invalidTagsDeliverUncontrolled << CFG_ITT_SHIFT) |
10273 + (p_FmMacsecDriverParam->encryptWithNoChangedTextDiscardUncontrolled << CFG_KFT_SHIFT) |
10274 + (p_FmMacsecDriverParam->untagTreatMode << CFG_UFT_SHIFT) |
10275 + (p_FmMacsecDriverParam->keysUnreadable << CFG_KSS_SHIFT) |
10276 + (p_FmMacsecDriverParam->reservedSc0 << CFG_S0I_SHIFT) |
10277 + (p_FmMacsecDriverParam->byPassMode << CFG_BYPN_SHIFT);
10278 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg, tmpReg);
10279 +
10280 + tmpReg = FM_MAC_GetMaxFrameLength(p_FmMacsec->h_FmMac);
10281 + /* At least Ethernet FCS (4 bytes) overhead must be subtracted from MFL.
10282 + * In addition, the SCI (8 bytes) overhead might be subtracted as well. */
10283 + tmpReg -= p_FmMacsecDriverParam->mflSubtract;
10284 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->mfl, tmpReg);
10285 +
10286 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->tpnet, p_FmMacsecDriverParam->pnExhThr);
10287 +
10288 + if (!p_FmMacsec->userExceptions)
10289 + p_FmMacsec->exceptions &= ~FM_MACSEC_EX_ECC;
10290 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->erer, p_FmMacsec->exceptions);
10291 +
10292 + p_FmMacsec->numRxScAvailable = NUM_OF_RX_SC;
10293 + if (p_FmMacsecDriverParam->reservedSc0)
10294 + p_FmMacsec->numRxScAvailable --;
10295 + p_FmMacsec->numTxScAvailable = NUM_OF_TX_SC;
10296 +
10297 + XX_Free(p_FmMacsecDriverParam);
10298 + p_FmMacsec->p_FmMacsecDriverParam = NULL;
10299 +
10300 + FM_MAC_GetId(p_FmMacsec->h_FmMac, &macId);
10301 + FmRegisterIntr(p_FmMacsec->h_Fm,
10302 + e_FM_MOD_MACSEC,
10303 + (uint8_t)macId,
10304 + e_FM_INTR_TYPE_NORMAL,
10305 + MacsecEventIsr,
10306 + p_FmMacsec);
10307 +
10308 + FmRegisterIntr(p_FmMacsec->h_Fm,
10309 + e_FM_MOD_MACSEC,
10310 + 0,
10311 + e_FM_INTR_TYPE_ERR,
10312 + MacsecErrorIsr,
10313 + p_FmMacsec);
10314 +
10315 + return E_OK;
10316 +}
10317 +
10318 +static t_Error MacsecFree(t_Handle h_FmMacsec)
10319 +{
10320 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10321 + uint32_t macId;
10322 +
10323 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10324 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10325 +
10326 + FM_MAC_GetId(p_FmMacsec->h_FmMac, &macId);
10327 + FmUnregisterIntr(p_FmMacsec->h_Fm,
10328 + e_FM_MOD_MACSEC,
10329 + (uint8_t)macId,
10330 + e_FM_INTR_TYPE_NORMAL);
10331 +
10332 + FmUnregisterIntr(p_FmMacsec->h_Fm,
10333 + e_FM_MOD_MACSEC,
10334 + 0,
10335 + e_FM_INTR_TYPE_ERR);
10336 +
10337 + if (p_FmMacsec->rxScSpinLock)
10338 + XX_FreeSpinlock(p_FmMacsec->rxScSpinLock);
10339 + if (p_FmMacsec->txScSpinLock)
10340 + XX_FreeSpinlock(p_FmMacsec->txScSpinLock);
10341 +
10342 + XX_Free(p_FmMacsec);
10343 +
10344 + return E_OK;
10345 +}
10346 +
10347 +static t_Error MacsecConfigUnknownSciFrameTreatment(t_Handle h_FmMacsec, e_FmMacsecUnknownSciFrameTreatment treatMode)
10348 +{
10349 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10350 +
10351 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10352 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10353 +
10354 + p_FmMacsec->p_FmMacsecDriverParam->unknownSciTreatMode = treatMode;
10355 +
10356 + return E_OK;
10357 +}
10358 +
10359 +static t_Error MacsecConfigInvalidTagsFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled)
10360 +{
10361 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10362 +
10363 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10364 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10365 +
10366 + p_FmMacsec->p_FmMacsecDriverParam->invalidTagsDeliverUncontrolled = deliverUncontrolled;
10367 +
10368 + return E_OK;
10369 +}
10370 +
10371 +static t_Error MacsecConfigChangedTextWithNoEncryptFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled)
10372 +{
10373 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10374 +
10375 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10376 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10377 +
10378 + p_FmMacsec->p_FmMacsecDriverParam->changedTextWithNoEncryptDeliverUncontrolled = deliverUncontrolled;
10379 +
10380 + return E_OK;
10381 +}
10382 +
10383 +static t_Error MacsecConfigOnlyScbIsSetFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled)
10384 +{
10385 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10386 +
10387 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10388 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10389 +
10390 + p_FmMacsec->p_FmMacsecDriverParam->onlyScbIsSetDeliverUncontrolled = deliverUncontrolled;
10391 +
10392 + return E_OK;
10393 +}
10394 +
10395 +static t_Error MacsecConfigEncryptWithNoChangedTextFrameTreatment(t_Handle h_FmMacsec, bool discardUncontrolled)
10396 +{
10397 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10398 +
10399 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10400 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10401 +
10402 + p_FmMacsec->p_FmMacsecDriverParam->encryptWithNoChangedTextDiscardUncontrolled = discardUncontrolled;
10403 +
10404 + return E_OK;
10405 +}
10406 +
10407 +static t_Error MacsecConfigUntagFrameTreatment(t_Handle h_FmMacsec, e_FmMacsecUntagFrameTreatment treatMode)
10408 +{
10409 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10410 +
10411 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10412 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10413 +
10414 + p_FmMacsec->p_FmMacsecDriverParam->untagTreatMode = treatMode;
10415 +
10416 + return E_OK;
10417 +}
10418 +
10419 +static t_Error MacsecConfigPnExhaustionThreshold(t_Handle h_FmMacsec, uint32_t pnExhThr)
10420 +{
10421 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10422 +
10423 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10424 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10425 +
10426 + p_FmMacsec->p_FmMacsecDriverParam->pnExhThr = pnExhThr;
10427 +
10428 + return E_OK;
10429 +}
10430 +
10431 +static t_Error MacsecConfigKeysUnreadable(t_Handle h_FmMacsec)
10432 +{
10433 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10434 +
10435 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10436 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10437 +
10438 + p_FmMacsec->p_FmMacsecDriverParam->keysUnreadable = TRUE;
10439 +
10440 + return E_OK;
10441 +}
10442 +
10443 +static t_Error MacsecConfigSectagWithoutSCI(t_Handle h_FmMacsec)
10444 +{
10445 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10446 +
10447 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10448 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10449 +
10450 + p_FmMacsec->p_FmMacsecDriverParam->sectagOverhead -= MACSEC_SCI_SIZE;
10451 + p_FmMacsec->p_FmMacsecDriverParam->mflSubtract += MACSEC_SCI_SIZE;
10452 +
10453 + return E_OK;
10454 +}
10455 +
10456 +static t_Error MacsecConfigException(t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable)
10457 +{
10458 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10459 + uint32_t bitMask = 0;
10460 +
10461 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10462 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10463 +
10464 + GET_USER_EXCEPTION_FLAG(bitMask, exception);
10465 + if (bitMask)
10466 + {
10467 + if (enable)
10468 + p_FmMacsec->userExceptions |= bitMask;
10469 + else
10470 + p_FmMacsec->userExceptions &= ~bitMask;
10471 + }
10472 + else
10473 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
10474 +
10475 + return E_OK;
10476 +}
10477 +
10478 +static t_Error MacsecGetRevision(t_Handle h_FmMacsec, uint32_t *p_MacsecRevision)
10479 +{
10480 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10481 +
10482 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10483 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10484 +
10485 + *p_MacsecRevision = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->ip_rev1);
10486 +
10487 + return E_OK;
10488 +}
10489 +
10490 +static t_Error MacsecEnable(t_Handle h_FmMacsec)
10491 +{
10492 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10493 + uint32_t tmpReg;
10494 +
10495 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10496 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10497 +
10498 + tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg);
10499 + tmpReg |= CFG_BYPN;
10500 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg,tmpReg);
10501 +
10502 + return E_OK;
10503 +}
10504 +
10505 +static t_Error MacsecDisable(t_Handle h_FmMacsec)
10506 +{
10507 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10508 + uint32_t tmpReg;
10509 +
10510 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10511 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10512 +
10513 + tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg);
10514 + tmpReg &= ~CFG_BYPN;
10515 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg,tmpReg);
10516 +
10517 + return E_OK;
10518 +}
10519 +
10520 +static t_Error MacsecSetException(t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable)
10521 +{
10522 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10523 + uint32_t bitMask;
10524 +
10525 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10526 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
10527 +
10528 + GET_USER_EXCEPTION_FLAG(bitMask, exception);
10529 + if (bitMask)
10530 + {
10531 + if (enable)
10532 + p_FmMacsec->userExceptions |= bitMask;
10533 + else
10534 + p_FmMacsec->userExceptions &= ~bitMask;
10535 + }
10536 + else
10537 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
10538 +
10539 + if (!p_FmMacsec->userExceptions)
10540 + p_FmMacsec->exceptions &= ~FM_MACSEC_EX_ECC;
10541 + else
10542 + p_FmMacsec->exceptions |= FM_MACSEC_EX_ECC;
10543 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->erer, p_FmMacsec->exceptions);
10544 +
10545 + return E_OK;
10546 +}
10547 +
10548 +static void InitFmMacsecControllerDriver(t_FmMacsecControllerDriver *p_FmMacsecControllerDriver)
10549 +{
10550 + p_FmMacsecControllerDriver->f_FM_MACSEC_Init = MacsecInit;
10551 + p_FmMacsecControllerDriver->f_FM_MACSEC_Free = MacsecFree;
10552 + p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigUnknownSciFrameTreatment = MacsecConfigUnknownSciFrameTreatment;
10553 + p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigInvalidTagsFrameTreatment = MacsecConfigInvalidTagsFrameTreatment;
10554 + p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment = MacsecConfigEncryptWithNoChangedTextFrameTreatment;
10555 + p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigUntagFrameTreatment = MacsecConfigUntagFrameTreatment;
10556 + p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigChangedTextWithNoEncryptFrameTreatment = MacsecConfigChangedTextWithNoEncryptFrameTreatment;
10557 + p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigOnlyScbIsSetFrameTreatment = MacsecConfigOnlyScbIsSetFrameTreatment;
10558 + p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigPnExhaustionThreshold = MacsecConfigPnExhaustionThreshold;
10559 + p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigKeysUnreadable = MacsecConfigKeysUnreadable;
10560 + p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigSectagWithoutSCI = MacsecConfigSectagWithoutSCI;
10561 + p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigException = MacsecConfigException;
10562 + p_FmMacsecControllerDriver->f_FM_MACSEC_GetRevision = MacsecGetRevision;
10563 + p_FmMacsecControllerDriver->f_FM_MACSEC_Enable = MacsecEnable;
10564 + p_FmMacsecControllerDriver->f_FM_MACSEC_Disable = MacsecDisable;
10565 + p_FmMacsecControllerDriver->f_FM_MACSEC_SetException = MacsecSetException;
10566 +}
10567 +
10568 +/****************************************/
10569 +/* Inter-Module functions */
10570 +/****************************************/
10571 +
10572 +void FmMacsecRegisterIntr(t_Handle h_FmMacsec,
10573 + e_FmMacsecEventModules module,
10574 + uint8_t modId,
10575 + e_FmIntrType intrType,
10576 + void (*f_Isr) (t_Handle h_Arg, uint32_t id),
10577 + t_Handle h_Arg)
10578 +{
10579 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10580 + uint8_t event= 0;
10581 +
10582 + SANITY_CHECK_RETURN(p_FmMacsec, E_INVALID_HANDLE);
10583 +
10584 + GET_MACSEC_MODULE_EVENT(module, modId, intrType, event);
10585 +
10586 + ASSERT_COND(event != e_FM_MACSEC_EV_DUMMY_LAST);
10587 + p_FmMacsec->intrMng[event].f_Isr = f_Isr;
10588 + p_FmMacsec->intrMng[event].h_SrcHandle = h_Arg;
10589 +}
10590 +
10591 +void FmMacsecUnregisterIntr(t_Handle h_FmMacsec,
10592 + e_FmMacsecEventModules module,
10593 + uint8_t modId,
10594 + e_FmIntrType intrType)
10595 +{
10596 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10597 + uint8_t event= 0;
10598 +
10599 + SANITY_CHECK_RETURN(p_FmMacsec, E_INVALID_HANDLE);
10600 +
10601 + GET_MACSEC_MODULE_EVENT(module, modId,intrType, event);
10602 +
10603 + ASSERT_COND(event != e_FM_MACSEC_EV_DUMMY_LAST);
10604 + p_FmMacsec->intrMng[event].f_Isr = NULL;
10605 + p_FmMacsec->intrMng[event].h_SrcHandle = NULL;
10606 +}
10607 +
10608 +t_Error FmMacsecAllocScs(t_Handle h_FmMacsec, e_ScType type, bool isPtp, uint32_t numOfScs, uint32_t *p_ScIds)
10609 +{
10610 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10611 + t_Error err = E_OK;
10612 + bool *p_ScTable;
10613 + uint32_t *p_ScAvailable,i;
10614 +
10615 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10616 + SANITY_CHECK_RETURN_ERROR(p_ScIds, E_INVALID_HANDLE);
10617 + SANITY_CHECK_RETURN_ERROR(numOfScs, E_INVALID_HANDLE);
10618 +
10619 + if (type == e_SC_RX)
10620 + {
10621 + p_ScTable = (bool *)p_FmMacsec->rxScTable;
10622 + p_ScAvailable = &p_FmMacsec->numRxScAvailable;
10623 + i = (NUM_OF_RX_SC - 1);
10624 + }
10625 + else
10626 + {
10627 + p_ScTable = (bool *)p_FmMacsec->txScTable;
10628 + p_ScAvailable = &p_FmMacsec->numTxScAvailable;
10629 + i = (NUM_OF_TX_SC - 1);
10630 +
10631 + }
10632 + if (*p_ScAvailable < numOfScs)
10633 + RETURN_ERROR(MINOR, E_NOT_AVAILABLE, ("Not enough SCs available"));
10634 +
10635 + if (isPtp)
10636 + {
10637 + i = 0;
10638 + if (p_ScTable[i])
10639 + RETURN_ERROR(MINOR, E_NOT_AVAILABLE, ("Sc 0 Not available"));
10640 + }
10641 +
10642 + for (;numOfScs;i--)
10643 + {
10644 + if (p_ScTable[i])
10645 + continue;
10646 + numOfScs --;
10647 + (*p_ScAvailable)--;
10648 + p_ScIds[numOfScs] = i;
10649 + p_ScTable[i] = TRUE;
10650 + }
10651 +
10652 + return err;
10653 +}
10654 +
10655 +t_Error FmMacsecFreeScs(t_Handle h_FmMacsec, e_ScType type, uint32_t numOfScs, uint32_t *p_ScIds)
10656 +{
10657 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10658 + t_Error err = E_OK;
10659 + bool *p_ScTable;
10660 + uint32_t *p_ScAvailable,maxNumOfSc,i;
10661 +
10662 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10663 + SANITY_CHECK_RETURN_ERROR(p_ScIds, E_INVALID_HANDLE);
10664 + SANITY_CHECK_RETURN_ERROR(numOfScs, E_INVALID_HANDLE);
10665 +
10666 + if (type == e_SC_RX)
10667 + {
10668 + p_ScTable = (bool *)p_FmMacsec->rxScTable;
10669 + p_ScAvailable = &p_FmMacsec->numRxScAvailable;
10670 + maxNumOfSc = NUM_OF_RX_SC;
10671 + }
10672 + else
10673 + {
10674 + p_ScTable = (bool *)p_FmMacsec->txScTable;
10675 + p_ScAvailable = &p_FmMacsec->numTxScAvailable;
10676 + maxNumOfSc = NUM_OF_TX_SC;
10677 + }
10678 +
10679 + if ((*p_ScAvailable + numOfScs) > maxNumOfSc)
10680 + RETURN_ERROR(MINOR, E_FULL, ("Too much SCs"));
10681 +
10682 + for (i=0;i<numOfScs;i++)
10683 + {
10684 + p_ScTable[p_ScIds[i]] = FALSE;
10685 + (*p_ScAvailable)++;
10686 + }
10687 +
10688 + return err;
10689 +
10690 +}
10691 +
10692 +t_Error FmMacsecSetPTP(t_Handle h_FmMacsec, bool enable)
10693 +{
10694 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10695 + uint32_t tmpReg = 0;
10696 +
10697 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10698 +
10699 + tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg);
10700 + if (enable && (tmpReg & CFG_S0I))
10701 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("MACSEC already in point-to-point mode"));
10702 +
10703 + if (enable)
10704 + tmpReg |= CFG_S0I;
10705 + else
10706 + tmpReg &= ~CFG_S0I;
10707 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg, tmpReg);
10708 +
10709 + return E_OK;
10710 +}
10711 +
10712 +t_Error FmMacsecCreateRxSc(t_Handle h_FmMacsec, t_RxScParams *p_RxScParams)
10713 +{
10714 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10715 + t_Error err = E_OK;
10716 + uint32_t tmpReg = 0, intFlags;
10717 +
10718 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10719 + SANITY_CHECK_RETURN_ERROR(p_RxScParams, E_INVALID_HANDLE);
10720 + SANITY_CHECK_RETURN_ERROR(p_RxScParams->scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
10721 +
10722 + intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
10723 +
10724 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, p_RxScParams->scId);
10725 + tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsccfg);
10726 + if (tmpReg & RX_SCCFG_SCI_EN_MASK)
10727 + {
10728 + XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
10729 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Rx Sc %d must be disable",p_RxScParams->scId));
10730 + }
10731 +
10732 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsci1h, GET_SCI_FIRST_HALF(p_RxScParams->sci));
10733 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsci2h, GET_SCI_SECOND_HALF(p_RxScParams->sci));
10734 + tmpReg |= ((p_RxScParams->replayProtect << RX_SCCFG_RP_SHIFT) & RX_SCCFG_RP_MASK);
10735 + tmpReg |= ((p_RxScParams->validateFrames << RX_SCCFG_VF_SHIFT) & RX_SCCFG_VF_MASK);
10736 + tmpReg |= ((p_RxScParams->confidentialityOffset << RX_SCCFG_CO_SHIFT) & RX_SCCFG_CO_MASK);
10737 + tmpReg |= RX_SCCFG_SCI_EN_MASK;
10738 + tmpReg |= (p_RxScParams->cipherSuite << RX_SCCFG_CS_SHIFT);
10739 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsccfg, tmpReg);
10740 +
10741 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rpw, p_RxScParams->replayWindow);
10742 +
10743 + XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
10744 +
10745 + return err;
10746 +}
10747 +
10748 +t_Error FmMacsecDeleteRxSc(t_Handle h_FmMacsec, uint32_t scId)
10749 +{
10750 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10751 + t_Error err = E_OK;
10752 + uint32_t tmpReg = 0, intFlags;
10753 +
10754 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10755 + SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
10756 +
10757 + intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
10758 +
10759 + tmpReg &= ~RX_SCCFG_SCI_EN_MASK;
10760 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, scId);
10761 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsccfg, tmpReg);
10762 +
10763 + XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
10764 +
10765 + return err;
10766 +}
10767 +
10768 +t_Error FmMacsecCreateTxSc(t_Handle h_FmMacsec, t_TxScParams *p_TxScParams)
10769 +{
10770 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10771 + t_Error err = E_OK;
10772 + uint32_t tmpReg = 0, intFlags;
10773 + bool alwaysIncludeSCI = FALSE, useES = FALSE, useSCB = FALSE;
10774 +
10775 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10776 + SANITY_CHECK_RETURN_ERROR(p_TxScParams, E_INVALID_HANDLE);
10777 + SANITY_CHECK_RETURN_ERROR(p_TxScParams->scId < NUM_OF_TX_SC, E_INVALID_HANDLE);
10778 +
10779 + intFlags = XX_LockIntrSpinlock(p_FmMacsec->txScSpinLock);
10780 +
10781 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsca, p_TxScParams->scId);
10782 +
10783 + tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->txsccfg);
10784 + if (tmpReg & TX_SCCFG_SCE_MASK)
10785 + {
10786 + XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
10787 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Tx Sc %d must be disable",p_TxScParams->scId));
10788 + }
10789 +
10790 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsci1h, GET_SCI_FIRST_HALF(p_TxScParams->sci));
10791 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsci2h, GET_SCI_SECOND_HALF(p_TxScParams->sci));
10792 + alwaysIncludeSCI = (p_TxScParams->sciInsertionMode == e_FM_MACSEC_SCI_INSERTION_MODE_EXPLICIT_SECTAG);
10793 + useES = (p_TxScParams->sciInsertionMode == e_FM_MACSEC_SCI_INSERTION_MODE_EXPLICIT_MAC_SA);
10794 +
10795 + tmpReg |= ((p_TxScParams->protectFrames << TX_SCCFG_PF_SHIFT) & TX_SCCFG_PF_MASK);
10796 + tmpReg |= ((alwaysIncludeSCI << TX_SCCFG_AIS_SHIFT) & TX_SCCFG_AIS_MASK);
10797 + tmpReg |= ((useES << TX_SCCFG_UES_SHIFT) & TX_SCCFG_UES_MASK);
10798 + tmpReg |= ((useSCB << TX_SCCFG_USCB_SHIFT) & TX_SCCFG_USCB_MASK);
10799 + tmpReg |= ((p_TxScParams->confidentialityEnable << TX_SCCFG_CE_SHIFT) & TX_SCCFG_CE_MASK);
10800 + tmpReg |= ((p_TxScParams->confidentialityOffset << TX_SCCFG_CO_SHIFT) & TX_SCCFG_CO_MASK);
10801 + tmpReg |= TX_SCCFG_SCE_MASK;
10802 + tmpReg |= (p_TxScParams->cipherSuite << TX_SCCFG_CS_SHIFT);
10803 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsccfg, tmpReg);
10804 +
10805 + XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
10806 +
10807 + return err;
10808 +}
10809 +
10810 +t_Error FmMacsecDeleteTxSc(t_Handle h_FmMacsec, uint32_t scId)
10811 +{
10812 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10813 + t_Error err = E_OK;
10814 + uint32_t tmpReg = 0, intFlags;
10815 +
10816 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10817 + SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_TX_SC, E_INVALID_HANDLE);
10818 +
10819 + intFlags = XX_LockIntrSpinlock(p_FmMacsec->txScSpinLock);
10820 +
10821 + tmpReg &= ~TX_SCCFG_SCE_MASK;
10822 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsca, scId);
10823 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsccfg, tmpReg);
10824 +
10825 + XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
10826 +
10827 + return err;
10828 +}
10829 +
10830 +t_Error FmMacsecCreateRxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecAN_t an, uint32_t lowestPn, macsecSAKey_t key)
10831 +{
10832 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10833 + t_Error err = E_OK;
10834 + uint32_t tmpReg = 0, intFlags;
10835 +
10836 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10837 + SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
10838 + SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_RX_SC, E_INVALID_HANDLE);
10839 +
10840 + intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
10841 +
10842 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, scId);
10843 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsanpn, DEFAULT_initNextPn);
10844 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsalpn, lowestPn);
10845 + MemCpy8((void*)p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsak, key, sizeof(macsecSAKey_t));
10846 +
10847 + tmpReg |= RX_SACFG_ACTIVE;
10848 + tmpReg |= ((an << RX_SACFG_AN_SHIFT) & RX_SACFG_AN_MASK);
10849 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsacs, tmpReg);
10850 +
10851 + XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
10852 +
10853 + return err;
10854 +}
10855 +
10856 +t_Error FmMacsecCreateTxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecSAKey_t key)
10857 +{
10858 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10859 + t_Error err = E_OK;
10860 + uint32_t tmpReg = 0, intFlags;
10861 +
10862 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10863 + SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
10864 + SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_TX_SC, E_INVALID_HANDLE);
10865 +
10866 + intFlags = XX_LockIntrSpinlock(p_FmMacsec->txScSpinLock);
10867 +
10868 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsca, scId);
10869 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecTxScSa[saId].txsanpn, DEFAULT_initNextPn);
10870 + MemCpy8((void*)p_FmMacsec->p_FmMacsecRegs->fmMacsecTxScSa[saId].txsak, key, sizeof(macsecSAKey_t));
10871 +
10872 + tmpReg |= TX_SACFG_ACTIVE;
10873 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecTxScSa[saId].txsacs, tmpReg);
10874 +
10875 + XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
10876 +
10877 + return err;
10878 +}
10879 +
10880 +t_Error FmMacsecDeleteRxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId)
10881 +{
10882 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10883 + t_Error err = E_OK;
10884 + uint32_t tmpReg = 0, i, intFlags;
10885 +
10886 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10887 + SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
10888 + SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_RX_SC, E_INVALID_HANDLE);
10889 +
10890 + intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
10891 +
10892 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, scId);
10893 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsanpn, 0x0);
10894 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsalpn, 0x0);
10895 + for (i=0; i<4; i++)
10896 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsak[i], 0x0);
10897 +
10898 + tmpReg |= RX_SACFG_ACTIVE;
10899 + tmpReg &= ~RX_SACFG_EN_MASK;
10900 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsacs, tmpReg);
10901 +
10902 + XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
10903 +
10904 + return err;
10905 +}
10906 +
10907 +t_Error FmMacsecDeleteTxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId)
10908 +{
10909 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10910 + t_Error err = E_OK;
10911 + uint32_t tmpReg = 0, i, intFlags;
10912 +
10913 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10914 + SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
10915 + SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_TX_SC, E_INVALID_HANDLE);
10916 +
10917 + intFlags = XX_LockIntrSpinlock(p_FmMacsec->txScSpinLock);
10918 +
10919 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsca, scId);
10920 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecTxScSa[saId].txsanpn, 0x0);
10921 + for (i=0; i<4; i++)
10922 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecTxScSa[saId].txsak[i], 0x0);
10923 +
10924 + tmpReg |= TX_SACFG_ACTIVE;
10925 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecTxScSa[saId].txsacs, tmpReg);
10926 +
10927 + XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
10928 +
10929 + return err;
10930 +}
10931 +
10932 +t_Error FmMacsecRxSaSetReceive(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, bool enableReceive)
10933 +{
10934 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10935 + t_Error err = E_OK;
10936 + uint32_t tmpReg = 0, intFlags;
10937 +
10938 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10939 + SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
10940 + SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_RX_SC, E_INVALID_HANDLE);
10941 +
10942 + intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
10943 +
10944 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, scId);
10945 + tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsacs);
10946 + if (enableReceive)
10947 + tmpReg |= RX_SACFG_EN_MASK;
10948 + else
10949 + tmpReg &= ~RX_SACFG_EN_MASK;
10950 +
10951 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsacs, tmpReg);
10952 +
10953 + XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
10954 +
10955 + return err;
10956 +}
10957 +
10958 +t_Error FmMacsecRxSaUpdateNextPn(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, uint32_t updtNextPN)
10959 +{
10960 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10961 + t_Error err = E_OK;
10962 + uint32_t intFlags;
10963 +
10964 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10965 + SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
10966 + SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_RX_SC, E_INVALID_HANDLE);
10967 +
10968 + intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
10969 +
10970 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, scId);
10971 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsanpn, updtNextPN);
10972 +
10973 + XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
10974 +
10975 + return err;
10976 +}
10977 +
10978 +t_Error FmMacsecRxSaUpdateLowestPn(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, uint32_t updtLowestPN)
10979 +{
10980 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
10981 + t_Error err = E_OK;
10982 + uint32_t intFlags;
10983 +
10984 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
10985 + SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
10986 + SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_RX_SC, E_INVALID_HANDLE);
10987 +
10988 + intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
10989 +
10990 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, scId);
10991 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsalpn, updtLowestPN);
10992 +
10993 + XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
10994 +
10995 + return err;
10996 +}
10997 +
10998 +t_Error FmMacsecTxSaSetActive(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecAN_t an)
10999 +{
11000 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
11001 + t_Error err = E_OK;
11002 + uint32_t tmpReg = 0, intFlags;
11003 +
11004 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
11005 + SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
11006 + SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_TX_SC, E_INVALID_HANDLE);
11007 +
11008 + intFlags = XX_LockIntrSpinlock(p_FmMacsec->txScSpinLock);
11009 +
11010 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsca, scId);
11011 +
11012 + tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->txsccfg);
11013 +
11014 + tmpReg |= ((an << TX_SCCFG_AN_SHIFT) & TX_SCCFG_AN_MASK);
11015 + tmpReg |= ((saId << TX_SCCFG_ASA_SHIFT) & TX_SCCFG_ASA_MASK);
11016 +
11017 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsccfg, tmpReg);
11018 +
11019 + XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
11020 +
11021 + return err;
11022 +}
11023 +
11024 +t_Error FmMacsecTxSaGetActive(t_Handle h_FmMacsec, uint32_t scId, macsecAN_t *p_An)
11025 +{
11026 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
11027 + t_Error err = E_OK;
11028 + uint32_t tmpReg = 0, intFlags;
11029 +
11030 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
11031 + SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
11032 + SANITY_CHECK_RETURN_ERROR(p_An, E_INVALID_HANDLE);
11033 +
11034 + intFlags = XX_LockIntrSpinlock(p_FmMacsec->txScSpinLock);
11035 +
11036 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsca, scId);
11037 +
11038 + tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->txsccfg);
11039 +
11040 + XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
11041 +
11042 + *p_An = (macsecAN_t)((tmpReg & TX_SCCFG_AN_MASK) >> TX_SCCFG_AN_SHIFT);
11043 +
11044 + return err;
11045 +}
11046 +
11047 +t_Error FmMacsecSetException(t_Handle h_FmMacsec, e_FmMacsecGlobalExceptions exception, uint32_t scId, bool enable)
11048 +{
11049 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
11050 + uint32_t bitMask;
11051 +
11052 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
11053 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
11054 +
11055 + GET_EXCEPTION_FLAG(bitMask, exception, scId);
11056 + if (bitMask)
11057 + {
11058 + if (enable)
11059 + p_FmMacsec->exceptions |= bitMask;
11060 + else
11061 + p_FmMacsec->exceptions &= ~bitMask;
11062 + }
11063 + else
11064 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
11065 +
11066 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->erer, p_FmMacsec->exceptions);
11067 +
11068 + return E_OK;
11069 +}
11070 +
11071 +t_Error FmMacsecSetEvent(t_Handle h_FmMacsec, e_FmMacsecGlobalEvents event, uint32_t scId, bool enable)
11072 +{
11073 + t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
11074 + uint32_t bitMask;
11075 +
11076 + SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
11077 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
11078 +
11079 + GET_EVENT_FLAG(bitMask, event, scId);
11080 + if (bitMask)
11081 + {
11082 + if (enable)
11083 + p_FmMacsec->events |= bitMask;
11084 + else
11085 + p_FmMacsec->events &= ~bitMask;
11086 + }
11087 + else
11088 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined event"));
11089 +
11090 + WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->ever, p_FmMacsec->events);
11091 +
11092 + return E_OK;
11093 +}
11094 +
11095 +/****************************************/
11096 +/* API Init unit functions */
11097 +/****************************************/
11098 +t_Handle FM_MACSEC_MASTER_Config(t_FmMacsecParams *p_FmMacsecParam)
11099 +{
11100 + t_FmMacsec *p_FmMacsec;
11101 + uint32_t macId;
11102 +
11103 + /* Allocate FM MACSEC structure */
11104 + p_FmMacsec = (t_FmMacsec *) XX_Malloc(sizeof(t_FmMacsec));
11105 + if (!p_FmMacsec)
11106 + {
11107 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC driver structure"));
11108 + return NULL;
11109 + }
11110 + memset(p_FmMacsec, 0, sizeof(t_FmMacsec));
11111 + InitFmMacsecControllerDriver(&p_FmMacsec->fmMacsecControllerDriver);
11112 +
11113 + /* Allocate the FM MACSEC driver's parameters structure */
11114 + p_FmMacsec->p_FmMacsecDriverParam = (t_FmMacsecDriverParam *)XX_Malloc(sizeof(t_FmMacsecDriverParam));
11115 + if (!p_FmMacsec->p_FmMacsecDriverParam)
11116 + {
11117 + XX_Free(p_FmMacsec);
11118 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC driver parameters"));
11119 + return NULL;
11120 + }
11121 + memset(p_FmMacsec->p_FmMacsecDriverParam, 0, sizeof(t_FmMacsecDriverParam));
11122 +
11123 + /* Initialize FM MACSEC parameters which will be kept by the driver */
11124 + p_FmMacsec->h_Fm = p_FmMacsecParam->h_Fm;
11125 + p_FmMacsec->h_FmMac = p_FmMacsecParam->nonGuestParams.h_FmMac;
11126 + p_FmMacsec->p_FmMacsecRegs = (t_FmMacsecRegs *)UINT_TO_PTR(p_FmMacsecParam->nonGuestParams.baseAddr);
11127 + p_FmMacsec->f_Exception = p_FmMacsecParam->nonGuestParams.f_Exception;
11128 + p_FmMacsec->h_App = p_FmMacsecParam->nonGuestParams.h_App;
11129 + p_FmMacsec->userExceptions = DEFAULT_userExceptions;
11130 + p_FmMacsec->exceptions = DEFAULT_exceptions;
11131 + p_FmMacsec->events = DEFAULT_events;
11132 + p_FmMacsec->rxScSpinLock = XX_InitSpinlock();
11133 + p_FmMacsec->txScSpinLock = XX_InitSpinlock();
11134 +
11135 + /* Initialize FM MACSEC driver parameters parameters (for initialization phase only) */
11136 + p_FmMacsec->p_FmMacsecDriverParam->unknownSciTreatMode = DEFAULT_unknownSciFrameTreatment;
11137 + p_FmMacsec->p_FmMacsecDriverParam->invalidTagsDeliverUncontrolled = DEFAULT_invalidTagsFrameTreatment;
11138 + p_FmMacsec->p_FmMacsecDriverParam->encryptWithNoChangedTextDiscardUncontrolled = DEFAULT_encryptWithNoChangedTextFrameTreatment;
11139 + p_FmMacsec->p_FmMacsecDriverParam->untagTreatMode = DEFAULT_untagFrameTreatment;
11140 + p_FmMacsec->p_FmMacsecDriverParam->keysUnreadable = DEFAULT_keysUnreadable;
11141 + p_FmMacsec->p_FmMacsecDriverParam->reservedSc0 = DEFAULT_sc0ReservedForPTP;
11142 + p_FmMacsec->p_FmMacsecDriverParam->byPassMode = !DEFAULT_normalMode;
11143 + p_FmMacsec->p_FmMacsecDriverParam->pnExhThr = DEFAULT_pnExhThr;
11144 + p_FmMacsec->p_FmMacsecDriverParam->sectagOverhead = DEFAULT_sectagOverhead;
11145 + p_FmMacsec->p_FmMacsecDriverParam->mflSubtract = DEFAULT_mflSubtract;
11146 + /* build the FM MACSEC master IPC address */
11147 + memset(p_FmMacsec->fmMacsecModuleName, 0, (sizeof(char))*MODULE_NAME_SIZE);
11148 + FM_MAC_GetId(p_FmMacsec->h_FmMac,&macId);
11149 + if (Sprint (p_FmMacsec->fmMacsecModuleName, "FM-%d-MAC-%d-MACSEC-Master",
11150 + FmGetId(p_FmMacsec->h_Fm),macId) != 24)
11151 + {
11152 + XX_Free(p_FmMacsec->p_FmMacsecDriverParam);
11153 + XX_Free(p_FmMacsec);
11154 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
11155 + return NULL;
11156 + }
11157 + return p_FmMacsec;
11158 +}
11159 --- /dev/null
11160 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_master.h
11161 @@ -0,0 +1,479 @@
11162 +/*
11163 + * Copyright 2008-2015 Freescale Semiconductor Inc.
11164 + *
11165 + * Redistribution and use in source and binary forms, with or without
11166 + * modification, are permitted provided that the following conditions are met:
11167 + * * Redistributions of source code must retain the above copyright
11168 + * notice, this list of conditions and the following disclaimer.
11169 + * * Redistributions in binary form must reproduce the above copyright
11170 + * notice, this list of conditions and the following disclaimer in the
11171 + * documentation and/or other materials provided with the distribution.
11172 + * * Neither the name of Freescale Semiconductor nor the
11173 + * names of its contributors may be used to endorse or promote products
11174 + * derived from this software without specific prior written permission.
11175 + *
11176 + *
11177 + * ALTERNATIVELY, this software may be distributed under the terms of the
11178 + * GNU General Public License ("GPL") as published by the Free Software
11179 + * Foundation, either version 2 of that License or (at your option) any
11180 + * later version.
11181 + *
11182 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
11183 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
11184 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
11185 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
11186 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
11187 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
11188 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
11189 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11190 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
11191 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11192 + */
11193 +
11194 +/******************************************************************************
11195 + @File fm_macsec_master.h
11196 +
11197 + @Description FM MACSEC internal structures and definitions.
11198 +*//***************************************************************************/
11199 +#ifndef __FM_MACSEC_MASTER_H
11200 +#define __FM_MACSEC_MASTER_H
11201 +
11202 +#include "error_ext.h"
11203 +#include "std_ext.h"
11204 +
11205 +#include "fm_macsec.h"
11206 +
11207 +
11208 +#define MACSEC_ICV_SIZE 16
11209 +#define MACSEC_SECTAG_SIZE 16
11210 +#define MACSEC_SCI_SIZE 8
11211 +#define MACSEC_FCS_SIZE 4
11212 +
11213 +/**************************************************************************//**
11214 + @Description Exceptions
11215 +*//***************************************************************************/
11216 +
11217 +#define FM_MACSEC_EX_TX_SC_0 0x80000000
11218 +#define FM_MACSEC_EX_TX_SC(sc) (FM_MACSEC_EX_TX_SC_0 >> (sc))
11219 +#define FM_MACSEC_EX_ECC 0x00000001
11220 +
11221 +#define GET_EXCEPTION_FLAG(bitMask, exception, id) switch (exception){ \
11222 + case e_FM_MACSEC_EX_TX_SC: \
11223 + bitMask = FM_MACSEC_EX_TX_SC(id); break; \
11224 + case e_FM_MACSEC_EX_ECC: \
11225 + bitMask = FM_MACSEC_EX_ECC; break; \
11226 + default: bitMask = 0;break;}
11227 +
11228 +#define FM_MACSEC_USER_EX_SINGLE_BIT_ECC 0x80000000
11229 +#define FM_MACSEC_USER_EX_MULTI_BIT_ECC 0x40000000
11230 +
11231 +#define GET_USER_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \
11232 + case e_FM_MACSEC_EX_SINGLE_BIT_ECC: \
11233 + bitMask = FM_MACSEC_USER_EX_SINGLE_BIT_ECC; break; \
11234 + case e_FM_MACSEC_EX_MULTI_BIT_ECC: \
11235 + bitMask = FM_MACSEC_USER_EX_MULTI_BIT_ECC; break; \
11236 + default: bitMask = 0;break;}
11237 +
11238 +/**************************************************************************//**
11239 + @Description Events
11240 +*//***************************************************************************/
11241 +
11242 +#define FM_MACSEC_EV_TX_SC_0_NEXT_PN 0x80000000
11243 +#define FM_MACSEC_EV_TX_SC_NEXT_PN(sc) (FM_MACSEC_EV_TX_SC_0_NEXT_PN >> (sc))
11244 +
11245 +#define GET_EVENT_FLAG(bitMask, event, id) switch (event){ \
11246 + case e_FM_MACSEC_EV_TX_SC_NEXT_PN: \
11247 + bitMask = FM_MACSEC_EV_TX_SC_NEXT_PN(id); break; \
11248 + default: bitMask = 0;break;}
11249 +
11250 +/**************************************************************************//**
11251 + @Description Defaults
11252 +*//***************************************************************************/
11253 +#define DEFAULT_userExceptions (FM_MACSEC_USER_EX_SINGLE_BIT_ECC |\
11254 + FM_MACSEC_USER_EX_MULTI_BIT_ECC)
11255 +
11256 +#define DEFAULT_exceptions (FM_MACSEC_EX_TX_SC(0) |\
11257 + FM_MACSEC_EX_TX_SC(1) |\
11258 + FM_MACSEC_EX_TX_SC(2) |\
11259 + FM_MACSEC_EX_TX_SC(3) |\
11260 + FM_MACSEC_EX_TX_SC(4) |\
11261 + FM_MACSEC_EX_TX_SC(5) |\
11262 + FM_MACSEC_EX_TX_SC(6) |\
11263 + FM_MACSEC_EX_TX_SC(7) |\
11264 + FM_MACSEC_EX_TX_SC(8) |\
11265 + FM_MACSEC_EX_TX_SC(9) |\
11266 + FM_MACSEC_EX_TX_SC(10) |\
11267 + FM_MACSEC_EX_TX_SC(11) |\
11268 + FM_MACSEC_EX_TX_SC(12) |\
11269 + FM_MACSEC_EX_TX_SC(13) |\
11270 + FM_MACSEC_EX_TX_SC(14) |\
11271 + FM_MACSEC_EX_TX_SC(15) |\
11272 + FM_MACSEC_EX_ECC )
11273 +
11274 +#define DEFAULT_events (FM_MACSEC_EV_TX_SC_NEXT_PN(0) |\
11275 + FM_MACSEC_EV_TX_SC_NEXT_PN(1) |\
11276 + FM_MACSEC_EV_TX_SC_NEXT_PN(2) |\
11277 + FM_MACSEC_EV_TX_SC_NEXT_PN(3) |\
11278 + FM_MACSEC_EV_TX_SC_NEXT_PN(4) |\
11279 + FM_MACSEC_EV_TX_SC_NEXT_PN(5) |\
11280 + FM_MACSEC_EV_TX_SC_NEXT_PN(6) |\
11281 + FM_MACSEC_EV_TX_SC_NEXT_PN(7) |\
11282 + FM_MACSEC_EV_TX_SC_NEXT_PN(8) |\
11283 + FM_MACSEC_EV_TX_SC_NEXT_PN(9) |\
11284 + FM_MACSEC_EV_TX_SC_NEXT_PN(10) |\
11285 + FM_MACSEC_EV_TX_SC_NEXT_PN(11) |\
11286 + FM_MACSEC_EV_TX_SC_NEXT_PN(12) |\
11287 + FM_MACSEC_EV_TX_SC_NEXT_PN(13) |\
11288 + FM_MACSEC_EV_TX_SC_NEXT_PN(14) |\
11289 + FM_MACSEC_EV_TX_SC_NEXT_PN(15) )
11290 +
11291 +#define DEFAULT_unknownSciFrameTreatment e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DISCARD_BOTH
11292 +#define DEFAULT_invalidTagsFrameTreatment FALSE
11293 +#define DEFAULT_encryptWithNoChangedTextFrameTreatment FALSE
11294 +#define DEFAULT_untagFrameTreatment e_FM_MACSEC_UNTAG_FRAME_TREATMENT_DELIVER_UNCONTROLLED_DISCARD_CONTROLLED
11295 +#define DEFAULT_changedTextWithNoEncryptFrameTreatment FALSE
11296 +#define DEFAULT_onlyScbIsSetFrameTreatment FALSE
11297 +#define DEFAULT_keysUnreadable FALSE
11298 +#define DEFAULT_normalMode TRUE
11299 +#define DEFAULT_sc0ReservedForPTP FALSE
11300 +#define DEFAULT_initNextPn 1
11301 +#define DEFAULT_pnExhThr 0xffffffff
11302 +#define DEFAULT_sectagOverhead (MACSEC_ICV_SIZE + MACSEC_SECTAG_SIZE)
11303 +#define DEFAULT_mflSubtract MACSEC_FCS_SIZE
11304 +
11305 +
11306 +/**************************************************************************//**
11307 + @Description Memory Mapped Registers
11308 +*//***************************************************************************/
11309 +
11310 +#if defined(__MWERKS__) && !defined(__GNUC__)
11311 +#pragma pack(push,1)
11312 +#endif /* defined(__MWERKS__) && ... */
11313 +
11314 +typedef _Packed struct
11315 +{
11316 + /* MACsec configuration */
11317 + volatile uint32_t cfg; /**< MACsec configuration */
11318 + volatile uint32_t et; /**< MACsec EtherType */
11319 + volatile uint8_t res1[56]; /**< reserved */
11320 + volatile uint32_t mfl; /**< Maximum Frame Length */
11321 + volatile uint32_t tpnet; /**< TX Packet Number exhaustion threshold */
11322 + volatile uint8_t res2[56]; /**< reserved */
11323 + volatile uint32_t rxsca; /**< RX SC access select */
11324 + volatile uint8_t res3[60]; /**< reserved */
11325 + volatile uint32_t txsca; /**< TX SC access select */
11326 + volatile uint8_t res4[60]; /**< reserved */
11327 +
11328 + /* RX configuration, status and statistic */
11329 + volatile uint32_t rxsci1h; /**< RX Secure Channel Identifier first half */
11330 + volatile uint32_t rxsci2h; /**< RX Secure Channel Identifier second half */
11331 + volatile uint8_t res5[8]; /**< reserved */
11332 + volatile uint32_t ifio1hs; /**< ifInOctets first half Statistic */
11333 + volatile uint32_t ifio2hs; /**< ifInOctets second half Statistic */
11334 + volatile uint32_t ifiups; /**< ifInUcastPkts Statistic */
11335 + volatile uint8_t res6[4]; /**< reserved */
11336 + volatile uint32_t ifimps; /**< ifInMulticastPkts Statistic */
11337 + volatile uint32_t ifibps; /**< ifInBroadcastPkts Statistic */
11338 + volatile uint32_t rxsccfg; /**< RX Secure Channel configuration */
11339 + volatile uint32_t rpw; /**< replayWindow */
11340 + volatile uint8_t res7[16]; /**< reserved */
11341 + volatile uint32_t inov1hs; /**< InOctetsValidated first half Statistic */
11342 + volatile uint32_t inov2hs; /**< InOctetsValidated second half Statistic */
11343 + volatile uint32_t inod1hs; /**< InOctetsDecrypted first half Statistic */
11344 + volatile uint32_t inod2hs; /**< InOctetsDecrypted second half Statistic */
11345 + volatile uint32_t rxscipus; /**< RX Secure Channel InPktsUnchecked Statistic */
11346 + volatile uint32_t rxscipds; /**< RX Secure Channel InPktsDelayed Statistic */
11347 + volatile uint32_t rxscipls; /**< RX Secure Channel InPktsLate Statistic */
11348 + volatile uint8_t res8[4]; /**< reserved */
11349 + volatile uint32_t rxaninuss[MAX_NUM_OF_SA_PER_SC]; /**< RX AN 0-3 InNotUsingSA Statistic */
11350 + volatile uint32_t rxanipuss[MAX_NUM_OF_SA_PER_SC]; /**< RX AN 0-3 InPktsUnusedSA Statistic */
11351 + _Packed struct
11352 + {
11353 + volatile uint32_t rxsacs; /**< RX Security Association configuration and status */
11354 + volatile uint32_t rxsanpn; /**< RX Security Association nextPN */
11355 + volatile uint32_t rxsalpn; /**< RX Security Association lowestPN */
11356 + volatile uint32_t rxsaipos; /**< RX Security Association InPktsOK Statistic */
11357 + volatile uint32_t rxsak[4]; /**< RX Security Association key (128 bit) */
11358 + volatile uint32_t rxsah[4]; /**< RX Security Association hash (128 bit) */
11359 + volatile uint32_t rxsaipis; /**< RX Security Association InPktsInvalid Statistic */
11360 + volatile uint32_t rxsaipnvs; /**< RX Security Association InPktsNotValid Statistic */
11361 + volatile uint8_t res9[8]; /**< reserved */
11362 + } _PackedType fmMacsecRxScSa[NUM_OF_SA_PER_RX_SC];
11363 +
11364 + /* TX configuration, status and statistic */
11365 + volatile uint32_t txsci1h; /**< TX Secure Channel Identifier first half */
11366 + volatile uint32_t txsci2h; /**< TX Secure Channel Identifier second half */
11367 + volatile uint8_t res10[8]; /**< reserved */
11368 + volatile uint32_t ifoo1hs; /**< ifOutOctets first half Statistic */
11369 + volatile uint32_t ifoo2hs; /**< ifOutOctets second half Statistic */
11370 + volatile uint32_t ifoups; /**< ifOutUcastPkts Statistic */
11371 + volatile uint32_t opus; /**< OutPktsUntagged Statistic */
11372 + volatile uint32_t ifomps; /**< ifOutMulticastPkts Statistic */
11373 + volatile uint32_t ifobps; /**< ifOutBroadcastPkts Statistic */
11374 + volatile uint32_t txsccfg; /**< TX Secure Channel configuration */
11375 + volatile uint32_t optls; /**< OutPktsTooLong Statistic */
11376 + volatile uint8_t res11[16]; /**< reserved */
11377 + volatile uint32_t oop1hs; /**< OutOctetsProtected first half Statistic */
11378 + volatile uint32_t oop2hs; /**< OutOctetsProtected second half Statistic */
11379 + volatile uint32_t ooe1hs; /**< OutOctetsEncrypted first half Statistic */
11380 + volatile uint32_t ooe2hs; /**< OutOctetsEncrypted second half Statistic */
11381 + volatile uint8_t res12[48]; /**< reserved */
11382 + _Packed struct
11383 + {
11384 + volatile uint32_t txsacs; /**< TX Security Association configuration and status */
11385 + volatile uint32_t txsanpn; /**< TX Security Association nextPN */
11386 + volatile uint32_t txsaopps; /**< TX Security Association OutPktsProtected Statistic */
11387 + volatile uint32_t txsaopes; /**< TX Security Association OutPktsEncrypted Statistic */
11388 + volatile uint32_t txsak[4]; /**< TX Security Association key (128 bit) */
11389 + volatile uint32_t txsah[4]; /**< TX Security Association hash (128 bit) */
11390 + volatile uint8_t res13[16]; /**< reserved */
11391 + } _PackedType fmMacsecTxScSa[NUM_OF_SA_PER_TX_SC];
11392 + volatile uint8_t res14[248]; /**< reserved */
11393 +
11394 + /* Global configuration and status */
11395 + volatile uint32_t ip_rev1; /**< MACsec IP Block Revision 1 register */
11396 + volatile uint32_t ip_rev2; /**< MACsec IP Block Revision 2 register */
11397 + volatile uint32_t evr; /**< MACsec Event Register */
11398 + volatile uint32_t ever; /**< MACsec Event Enable Register */
11399 + volatile uint32_t evfr; /**< MACsec Event Force Register */
11400 + volatile uint32_t err; /**< MACsec Error Register */
11401 + volatile uint32_t erer; /**< MACsec Error Enable Register */
11402 + volatile uint32_t erfr; /**< MACsec Error Force Register */
11403 + volatile uint8_t res15[40]; /**< reserved */
11404 + volatile uint32_t meec; /**< MACsec Memory ECC Error Capture Register */
11405 + volatile uint32_t idle; /**< MACsec Idle status Register */
11406 + volatile uint8_t res16[184]; /**< reserved */
11407 + /* DEBUG */
11408 + volatile uint32_t rxec; /**< MACsec RX error capture Register */
11409 + volatile uint8_t res17[28]; /**< reserved */
11410 + volatile uint32_t txec; /**< MACsec TX error capture Register */
11411 + volatile uint8_t res18[220]; /**< reserved */
11412 +
11413 + /* Macsec Rx global statistic */
11414 + volatile uint32_t ifiocp1hs; /**< ifInOctetsCp first half Statistic */
11415 + volatile uint32_t ifiocp2hs; /**< ifInOctetsCp second half Statistic */
11416 + volatile uint32_t ifiupcps; /**< ifInUcastPktsCp Statistic */
11417 + volatile uint8_t res19[4]; /**< reserved */
11418 + volatile uint32_t ifioup1hs; /**< ifInOctetsUp first half Statistic */
11419 + volatile uint32_t ifioup2hs; /**< ifInOctetsUp second half Statistic */
11420 + volatile uint32_t ifiupups; /**< ifInUcastPktsUp Statistic */
11421 + volatile uint8_t res20[4]; /**< reserved */
11422 + volatile uint32_t ifimpcps; /**< ifInMulticastPktsCp Statistic */
11423 + volatile uint32_t ifibpcps; /**< ifInBroadcastPktsCp Statistic */
11424 + volatile uint32_t ifimpups; /**< ifInMulticastPktsUp Statistic */
11425 + volatile uint32_t ifibpups; /**< ifInBroadcastPktsUp Statistic */
11426 + volatile uint32_t ipwts; /**< InPktsWithoutTag Statistic */
11427 + volatile uint32_t ipkays; /**< InPktsKaY Statistic */
11428 + volatile uint32_t ipbts; /**< InPktsBadTag Statistic */
11429 + volatile uint32_t ipsnfs; /**< InPktsSCINotFound Statistic */
11430 + volatile uint32_t ipuecs; /**< InPktsUnsupportedEC Statistic */
11431 + volatile uint32_t ipescbs; /**< InPktsEponSingleCopyBroadcast Statistic */
11432 + volatile uint32_t iptls; /**< InPktsTooLong Statistic */
11433 + volatile uint8_t res21[52]; /**< reserved */
11434 +
11435 + /* Macsec Tx global statistic */
11436 + volatile uint32_t opds; /**< OutPktsDiscarded Statistic */
11437 +#if (DPAA_VERSION >= 11)
11438 + volatile uint8_t res22[124]; /**< reserved */
11439 + _Packed struct
11440 + {
11441 + volatile uint32_t rxsak[8]; /**< RX Security Association key (128/256 bit) */
11442 + volatile uint8_t res23[32]; /**< reserved */
11443 + } _PackedType rxScSaKey[NUM_OF_SA_PER_RX_SC];
11444 + _Packed struct
11445 + {
11446 + volatile uint32_t txsak[8]; /**< TX Security Association key (128/256 bit) */
11447 + volatile uint8_t res24[32]; /**< reserved */
11448 + } _PackedType txScSaKey[NUM_OF_SA_PER_TX_SC];
11449 +#endif /* (DPAA_VERSION >= 11) */
11450 +} _PackedType t_FmMacsecRegs;
11451 +
11452 +#if defined(__MWERKS__) && !defined(__GNUC__)
11453 +#pragma pack(pop)
11454 +#endif /* defined(__MWERKS__) && ... */
11455 +
11456 +
11457 +/**************************************************************************//**
11458 + @Description General defines
11459 +*//***************************************************************************/
11460 +
11461 +#define SCI_HIGH_MASK 0xffffffff00000000LL
11462 +#define SCI_LOW_MASK 0x00000000ffffffffLL
11463 +
11464 +#define LONG_SHIFT 32
11465 +
11466 +#define GET_SCI_FIRST_HALF(sci) (uint32_t)((macsecSCI_t)((macsecSCI_t)(sci) & SCI_HIGH_MASK) >> LONG_SHIFT)
11467 +#define GET_SCI_SECOND_HALF(sci) (uint32_t)((macsecSCI_t)(sci) & SCI_LOW_MASK)
11468 +
11469 +/**************************************************************************//**
11470 + @Description Configuration defines
11471 +*//***************************************************************************/
11472 +
11473 +/* masks */
11474 +#define CFG_UECT 0x00000800
11475 +#define CFG_ESCBT 0x00000400
11476 +#define CFG_USFT 0x00000300
11477 +#define CFG_ITT 0x00000080
11478 +#define CFG_KFT 0x00000040
11479 +#define CFG_UFT 0x00000030
11480 +#define CFG_KSS 0x00000004
11481 +#define CFG_BYPN 0x00000002
11482 +#define CFG_S0I 0x00000001
11483 +
11484 +#define ET_TYPE 0x0000ffff
11485 +
11486 +#define MFL_MAX_LEN 0x0000ffff
11487 +
11488 +#define RXSCA_SC_SEL 0x0000000f
11489 +
11490 +#define TXSCA_SC_SEL 0x0000000f
11491 +
11492 +#define IP_REV_1_IP_ID 0xffff0000
11493 +#define IP_REV_1_IP_MJ 0x0000ff00
11494 +#define IP_REV_1_IP_MM 0x000000ff
11495 +
11496 +#define IP_REV_2_IP_INT 0x00ff0000
11497 +#define IP_REV_2_IP_ERR 0x0000ff00
11498 +#define IP_REV_2_IP_CFG 0x000000ff
11499 +
11500 +#define MECC_CAP 0x80000000
11501 +#define MECC_CET 0x40000000
11502 +#define MECC_SERCNT 0x00ff0000
11503 +#define MECC_MEMADDR 0x000001ff
11504 +
11505 +/* shifts */
11506 +#define CFG_UECT_SHIFT (31-20)
11507 +#define CFG_ESCBT_SHIFT (31-21)
11508 +#define CFG_USFT_SHIFT (31-23)
11509 +#define CFG_ITT_SHIFT (31-24)
11510 +#define CFG_KFT_SHIFT (31-25)
11511 +#define CFG_UFT_SHIFT (31-27)
11512 +#define CFG_KSS_SHIFT (31-29)
11513 +#define CFG_BYPN_SHIFT (31-30)
11514 +#define CFG_S0I_SHIFT (31-31)
11515 +
11516 +#define IP_REV_1_IP_ID_SHIFT (31-15)
11517 +#define IP_REV_1_IP_MJ_SHIFT (31-23)
11518 +#define IP_REV_1_IP_MM_SHIFT (31-31)
11519 +
11520 +#define IP_REV_2_IP_INT_SHIFT (31-15)
11521 +#define IP_REV_2_IP_ERR_SHIFT (31-23)
11522 +#define IP_REV_2_IP_CFG_SHIFT (31-31)
11523 +
11524 +#define MECC_CAP_SHIFT (31-0)
11525 +#define MECC_CET_SHIFT (31-1)
11526 +#define MECC_SERCNT_SHIFT (31-15)
11527 +#define MECC_MEMADDR_SHIFT (31-31)
11528 +
11529 +/**************************************************************************//**
11530 + @Description RX SC defines
11531 +*//***************************************************************************/
11532 +
11533 +/* masks */
11534 +#define RX_SCCFG_SCI_EN_MASK 0x00000800
11535 +#define RX_SCCFG_RP_MASK 0x00000400
11536 +#define RX_SCCFG_VF_MASK 0x00000300
11537 +#define RX_SCCFG_CO_MASK 0x0000003f
11538 +
11539 +/* shifts */
11540 +#define RX_SCCFG_SCI_EN_SHIFT (31-20)
11541 +#define RX_SCCFG_RP_SHIFT (31-21)
11542 +#define RX_SCCFG_VF_SHIFT (31-23)
11543 +#define RX_SCCFG_CO_SHIFT (31-31)
11544 +#define RX_SCCFG_CS_SHIFT (31-7)
11545 +
11546 +/**************************************************************************//**
11547 + @Description RX SA defines
11548 +*//***************************************************************************/
11549 +
11550 +/* masks */
11551 +#define RX_SACFG_ACTIVE 0x80000000
11552 +#define RX_SACFG_AN_MASK 0x00000006
11553 +#define RX_SACFG_EN_MASK 0x00000001
11554 +
11555 +/* shifts */
11556 +#define RX_SACFG_AN_SHIFT (31-30)
11557 +#define RX_SACFG_EN_SHIFT (31-31)
11558 +
11559 +/**************************************************************************//**
11560 + @Description TX SC defines
11561 +*//***************************************************************************/
11562 +
11563 +/* masks */
11564 +#define TX_SCCFG_AN_MASK 0x000c0000
11565 +#define TX_SCCFG_ASA_MASK 0x00020000
11566 +#define TX_SCCFG_SCE_MASK 0x00010000
11567 +#define TX_SCCFG_CO_MASK 0x00003f00
11568 +#define TX_SCCFG_CE_MASK 0x00000010
11569 +#define TX_SCCFG_PF_MASK 0x00000008
11570 +#define TX_SCCFG_AIS_MASK 0x00000004
11571 +#define TX_SCCFG_UES_MASK 0x00000002
11572 +#define TX_SCCFG_USCB_MASK 0x00000001
11573 +
11574 +/* shifts */
11575 +#define TX_SCCFG_AN_SHIFT (31-13)
11576 +#define TX_SCCFG_ASA_SHIFT (31-14)
11577 +#define TX_SCCFG_SCE_SHIFT (31-15)
11578 +#define TX_SCCFG_CO_SHIFT (31-23)
11579 +#define TX_SCCFG_CE_SHIFT (31-27)
11580 +#define TX_SCCFG_PF_SHIFT (31-28)
11581 +#define TX_SCCFG_AIS_SHIFT (31-29)
11582 +#define TX_SCCFG_UES_SHIFT (31-30)
11583 +#define TX_SCCFG_USCB_SHIFT (31-31)
11584 +#define TX_SCCFG_CS_SHIFT (31-7)
11585 +
11586 +/**************************************************************************//**
11587 + @Description TX SA defines
11588 +*//***************************************************************************/
11589 +
11590 +/* masks */
11591 +#define TX_SACFG_ACTIVE 0x80000000
11592 +
11593 +
11594 +typedef struct
11595 +{
11596 + void (*f_Isr) (t_Handle h_Arg, uint32_t id);
11597 + t_Handle h_SrcHandle;
11598 +} t_FmMacsecIntrSrc;
11599 +
11600 +typedef struct
11601 +{
11602 + e_FmMacsecUnknownSciFrameTreatment unknownSciTreatMode;
11603 + bool invalidTagsDeliverUncontrolled;
11604 + bool changedTextWithNoEncryptDeliverUncontrolled;
11605 + bool onlyScbIsSetDeliverUncontrolled;
11606 + bool encryptWithNoChangedTextDiscardUncontrolled;
11607 + e_FmMacsecUntagFrameTreatment untagTreatMode;
11608 + uint32_t pnExhThr;
11609 + bool keysUnreadable;
11610 + bool byPassMode;
11611 + bool reservedSc0;
11612 + uint32_t sectagOverhead;
11613 + uint32_t mflSubtract;
11614 +} t_FmMacsecDriverParam;
11615 +
11616 +typedef struct
11617 +{
11618 + t_FmMacsecControllerDriver fmMacsecControllerDriver;
11619 + t_Handle h_Fm;
11620 + t_FmMacsecRegs *p_FmMacsecRegs;
11621 + t_Handle h_FmMac; /**< A handle to the FM MAC object related to */
11622 + char fmMacsecModuleName[MODULE_NAME_SIZE];
11623 + t_FmMacsecIntrSrc intrMng[NUM_OF_INTER_MODULE_EVENTS];
11624 + uint32_t events;
11625 + uint32_t exceptions;
11626 + uint32_t userExceptions;
11627 + t_FmMacsecExceptionsCallback *f_Exception; /**< Exception Callback Routine */
11628 + t_Handle h_App; /**< A handle to an application layer object; This handle will
11629 + be passed by the driver upon calling the above callbacks */
11630 + bool rxScTable[NUM_OF_RX_SC];
11631 + uint32_t numRxScAvailable;
11632 + bool txScTable[NUM_OF_TX_SC];
11633 + uint32_t numTxScAvailable;
11634 + t_Handle rxScSpinLock;
11635 + t_Handle txScSpinLock;
11636 + t_FmMacsecDriverParam *p_FmMacsecDriverParam;
11637 +} t_FmMacsec;
11638 +
11639 +
11640 +#endif /* __FM_MACSEC_MASTER_H */
11641 --- /dev/null
11642 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_secy.c
11643 @@ -0,0 +1,883 @@
11644 +/*
11645 + * Copyright 2008-2015 Freescale Semiconductor Inc.
11646 + *
11647 + * Redistribution and use in source and binary forms, with or without
11648 + * modification, are permitted provided that the following conditions are met:
11649 + * * Redistributions of source code must retain the above copyright
11650 + * notice, this list of conditions and the following disclaimer.
11651 + * * Redistributions in binary form must reproduce the above copyright
11652 + * notice, this list of conditions and the following disclaimer in the
11653 + * documentation and/or other materials provided with the distribution.
11654 + * * Neither the name of Freescale Semiconductor nor the
11655 + * names of its contributors may be used to endorse or promote products
11656 + * derived from this software without specific prior written permission.
11657 + *
11658 + *
11659 + * ALTERNATIVELY, this software may be distributed under the terms of the
11660 + * GNU General Public License ("GPL") as published by the Free Software
11661 + * Foundation, either version 2 of that License or (at your option) any
11662 + * later version.
11663 + *
11664 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
11665 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
11666 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
11667 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
11668 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
11669 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
11670 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
11671 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11672 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
11673 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11674 + */
11675 +
11676 +/******************************************************************************
11677 + @File fm_macsec_secy.c
11678 +
11679 + @Description FM MACSEC SECY driver routines implementation.
11680 +*//***************************************************************************/
11681 +
11682 +#include "std_ext.h"
11683 +#include "error_ext.h"
11684 +#include "xx_ext.h"
11685 +#include "string_ext.h"
11686 +#include "sprint_ext.h"
11687 +
11688 +#include "fm_macsec_secy.h"
11689 +
11690 +
11691 +/****************************************/
11692 +/* static functions */
11693 +/****************************************/
11694 +static void FmMacsecSecYExceptionsIsr(t_Handle h_FmMacsecSecY, uint32_t id)
11695 +{
11696 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
11697 +
11698 + UNUSED(id);
11699 + SANITY_CHECK_RETURN(p_FmMacsecSecY, E_INVALID_HANDLE);
11700 +
11701 + if (p_FmMacsecSecY->exceptions & FM_MACSEC_SECY_EX_FRAME_DISCARDED)
11702 + p_FmMacsecSecY->f_Exception(p_FmMacsecSecY->h_App, e_FM_MACSEC_SECY_EX_FRAME_DISCARDED);
11703 +}
11704 +
11705 +static void FmMacsecSecYEventsIsr(t_Handle h_FmMacsecSecY, uint32_t id)
11706 +{
11707 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
11708 +
11709 + UNUSED(id);
11710 + SANITY_CHECK_RETURN(p_FmMacsecSecY, E_INVALID_HANDLE);
11711 +
11712 + if (p_FmMacsecSecY->events & FM_MACSEC_SECY_EV_NEXT_PN)
11713 + p_FmMacsecSecY->f_Event(p_FmMacsecSecY->h_App, e_FM_MACSEC_SECY_EV_NEXT_PN);
11714 +}
11715 +
11716 +static t_Error CheckFmMacsecSecYParameters(t_FmMacsecSecY *p_FmMacsecSecY)
11717 +{
11718 + if (!p_FmMacsecSecY->f_Exception)
11719 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exceptions callback not provided"));
11720 +
11721 + if (!p_FmMacsecSecY->f_Event)
11722 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Events callback not provided"));
11723 +
11724 + if (!p_FmMacsecSecY->numOfRxSc)
11725 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Num of Rx Scs must be greater than '0'"));
11726 +
11727 +
11728 + return E_OK;
11729 +}
11730 +
11731 +static t_Handle FmMacsecSecYCreateSc(t_FmMacsecSecY *p_FmMacsecSecY,
11732 + macsecSCI_t sci,
11733 + e_FmMacsecSecYCipherSuite cipherSuite,
11734 + e_ScType type)
11735 +{
11736 + t_SecYSc *p_ScTable;
11737 + void *p_Params;
11738 + uint32_t numOfSc,i;
11739 + t_Error err = E_OK;
11740 + t_RxScParams rxScParams;
11741 + t_TxScParams txScParams;
11742 +
11743 + ASSERT_COND(p_FmMacsecSecY);
11744 + ASSERT_COND(p_FmMacsecSecY->h_FmMacsec);
11745 +
11746 + if (type == e_SC_RX)
11747 + {
11748 + memset(&rxScParams, 0, sizeof(rxScParams));
11749 + i = (NUM_OF_RX_SC - 1);
11750 + p_ScTable = p_FmMacsecSecY->p_RxSc;
11751 + numOfSc = p_FmMacsecSecY->numOfRxSc;
11752 + rxScParams.confidentialityOffset = p_FmMacsecSecY->confidentialityOffset;
11753 + rxScParams.replayProtect = p_FmMacsecSecY->replayProtect;
11754 + rxScParams.replayWindow = p_FmMacsecSecY->replayWindow;
11755 + rxScParams.validateFrames = p_FmMacsecSecY->validateFrames;
11756 + rxScParams.cipherSuite = cipherSuite;
11757 + p_Params = &rxScParams;
11758 + }
11759 + else
11760 + {
11761 + memset(&txScParams, 0, sizeof(txScParams));
11762 + i = (NUM_OF_TX_SC - 1);
11763 + p_ScTable = p_FmMacsecSecY->p_TxSc;
11764 + numOfSc = p_FmMacsecSecY->numOfTxSc;
11765 + txScParams.sciInsertionMode = p_FmMacsecSecY->sciInsertionMode;
11766 + txScParams.protectFrames = p_FmMacsecSecY->protectFrames;
11767 + txScParams.confidentialityEnable = p_FmMacsecSecY->confidentialityEnable;
11768 + txScParams.confidentialityOffset = p_FmMacsecSecY->confidentialityOffset;
11769 + txScParams.cipherSuite = cipherSuite;
11770 + p_Params = &txScParams;
11771 + }
11772 +
11773 + for (i=0;i<numOfSc;i++)
11774 + if (!p_ScTable[i].inUse)
11775 + break;
11776 + if (i == numOfSc)
11777 + {
11778 + REPORT_ERROR(MAJOR, E_FULL, ("FM MACSEC SECY SC"));
11779 + return NULL;
11780 + }
11781 +
11782 + if (type == e_SC_RX)
11783 + {
11784 + ((t_RxScParams *)p_Params)->scId = p_ScTable[i].scId;
11785 + ((t_RxScParams *)p_Params)->sci = sci;
11786 + if ((err = FmMacsecCreateRxSc(p_FmMacsecSecY->h_FmMacsec, (t_RxScParams *)p_Params)) != E_OK)
11787 + {
11788 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC SECY RX SC"));
11789 + return NULL;
11790 + }
11791 + }
11792 + else
11793 + {
11794 + ((t_TxScParams *)p_Params)->scId = p_ScTable[i].scId;
11795 + ((t_TxScParams *)p_Params)->sci = sci;
11796 + if ((err = FmMacsecCreateTxSc(p_FmMacsecSecY->h_FmMacsec, (t_TxScParams *)p_Params)) != E_OK)
11797 + {
11798 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC SECY TX SC"));
11799 + return NULL;
11800 + }
11801 + }
11802 +
11803 + p_ScTable[i].inUse = TRUE;
11804 + return &p_ScTable[i];
11805 +}
11806 +
11807 +static t_Error FmMacsecSecYDeleteSc(t_FmMacsecSecY *p_FmMacsecSecY, t_SecYSc *p_FmSecYSc, e_ScType type)
11808 +{
11809 + t_Error err = E_OK;
11810 +
11811 + ASSERT_COND(p_FmMacsecSecY);
11812 + ASSERT_COND(p_FmMacsecSecY->h_FmMacsec);
11813 + ASSERT_COND(p_FmSecYSc);
11814 +
11815 + if (type == e_SC_RX)
11816 + {
11817 + if ((err = FmMacsecDeleteRxSc(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId)) != E_OK)
11818 + RETURN_ERROR(MINOR, err, NO_MSG);
11819 + }
11820 + else
11821 + if ((err = FmMacsecDeleteTxSc(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId)) != E_OK)
11822 + RETURN_ERROR(MINOR, err, NO_MSG);
11823 +
11824 + p_FmSecYSc->inUse = FALSE;
11825 +
11826 + return err;
11827 +}
11828 +
11829 +/****************************************/
11830 +/* API Init unit functions */
11831 +/****************************************/
11832 +t_Handle FM_MACSEC_SECY_Config(t_FmMacsecSecYParams *p_FmMacsecSecYParam)
11833 +{
11834 + t_FmMacsecSecY *p_FmMacsecSecY;
11835 +
11836 + /* Allocate FM MACSEC structure */
11837 + p_FmMacsecSecY = (t_FmMacsecSecY *) XX_Malloc(sizeof(t_FmMacsecSecY));
11838 + if (!p_FmMacsecSecY)
11839 + {
11840 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC SECY driver structure"));
11841 + return NULL;
11842 + }
11843 + memset(p_FmMacsecSecY, 0, sizeof(t_FmMacsecSecY));
11844 +
11845 + /* Allocate the FM MACSEC driver's parameters structure */
11846 + p_FmMacsecSecY->p_FmMacsecSecYDriverParam = (t_FmMacsecSecYDriverParam *)XX_Malloc(sizeof(t_FmMacsecSecYDriverParam));
11847 + if (!p_FmMacsecSecY->p_FmMacsecSecYDriverParam)
11848 + {
11849 + XX_Free(p_FmMacsecSecY);
11850 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC SECY driver parameters"));
11851 + return NULL;
11852 + }
11853 + memset(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, 0, sizeof(t_FmMacsecSecYDriverParam));
11854 +
11855 + /* Initialize FM MACSEC SECY parameters which will be kept by the driver */
11856 + p_FmMacsecSecY->h_FmMacsec = p_FmMacsecSecYParam->h_FmMacsec;
11857 + p_FmMacsecSecY->f_Event = p_FmMacsecSecYParam->f_Event;
11858 + p_FmMacsecSecY->f_Exception = p_FmMacsecSecYParam->f_Exception;
11859 + p_FmMacsecSecY->h_App = p_FmMacsecSecYParam->h_App;
11860 + p_FmMacsecSecY->confidentialityEnable = DEFAULT_confidentialityEnable;
11861 + p_FmMacsecSecY->confidentialityOffset = DEFAULT_confidentialityOffset;
11862 + p_FmMacsecSecY->validateFrames = DEFAULT_validateFrames;
11863 + p_FmMacsecSecY->replayProtect = DEFAULT_replayEnable;
11864 + p_FmMacsecSecY->replayWindow = DEFAULT_replayWindow;
11865 + p_FmMacsecSecY->protectFrames = DEFAULT_protectFrames;
11866 + p_FmMacsecSecY->sciInsertionMode = DEFAULT_sciInsertionMode;
11867 + p_FmMacsecSecY->isPointToPoint = DEFAULT_ptp;
11868 + p_FmMacsecSecY->numOfRxSc = p_FmMacsecSecYParam->numReceiveChannels;
11869 + p_FmMacsecSecY->numOfTxSc = DEFAULT_numOfTxSc;
11870 + p_FmMacsecSecY->exceptions = DEFAULT_exceptions;
11871 + p_FmMacsecSecY->events = DEFAULT_events;
11872 +
11873 + memcpy(&p_FmMacsecSecY->p_FmMacsecSecYDriverParam->txScParams,
11874 + &p_FmMacsecSecYParam->txScParams,
11875 + sizeof(t_FmMacsecSecYSCParams));
11876 + return p_FmMacsecSecY;
11877 +}
11878 +
11879 +t_Error FM_MACSEC_SECY_Init(t_Handle h_FmMacsecSecY)
11880 +{
11881 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
11882 + t_FmMacsecSecYDriverParam *p_FmMacsecSecYDriverParam = NULL;
11883 + uint32_t rxScIds[NUM_OF_RX_SC], txScIds[NUM_OF_TX_SC], i, j;
11884 + t_Error err;
11885 +
11886 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
11887 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_HANDLE);
11888 +
11889 + CHECK_INIT_PARAMETERS(p_FmMacsecSecY, CheckFmMacsecSecYParameters);
11890 +
11891 + p_FmMacsecSecYDriverParam = p_FmMacsecSecY->p_FmMacsecSecYDriverParam;
11892 +
11893 + if ((p_FmMacsecSecY->isPointToPoint) &&
11894 + ((err = FmMacsecSetPTP(p_FmMacsecSecY->h_FmMacsec, TRUE)) != E_OK))
11895 + RETURN_ERROR(MAJOR, err, ("Can't set Poin-to-Point"));
11896 +
11897 + /* Rx Sc Allocation */
11898 + p_FmMacsecSecY->p_RxSc = (t_SecYSc *)XX_Malloc(sizeof(t_SecYSc) * p_FmMacsecSecY->numOfRxSc);
11899 + if (!p_FmMacsecSecY->p_RxSc)
11900 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC SECY RX SC"));
11901 + memset(p_FmMacsecSecY->p_RxSc, 0, sizeof(t_SecYSc) * p_FmMacsecSecY->numOfRxSc);
11902 + if ((err = FmMacsecAllocScs(p_FmMacsecSecY->h_FmMacsec, e_SC_RX, p_FmMacsecSecY->isPointToPoint, p_FmMacsecSecY->numOfRxSc, rxScIds)) != E_OK)
11903 + {
11904 + if (p_FmMacsecSecY->p_TxSc)
11905 + XX_Free(p_FmMacsecSecY->p_TxSc);
11906 + if (p_FmMacsecSecY->p_RxSc)
11907 + XX_Free(p_FmMacsecSecY->p_RxSc);
11908 + return ERROR_CODE(err);
11909 + }
11910 + for (i=0; i<p_FmMacsecSecY->numOfRxSc; i++)
11911 + {
11912 + p_FmMacsecSecY->p_RxSc[i].scId = rxScIds[i];
11913 + p_FmMacsecSecY->p_RxSc[i].type = e_SC_RX;
11914 + for (j=0; j<MAX_NUM_OF_SA_PER_SC;j++)
11915 + p_FmMacsecSecY->p_RxSc[i].sa[j].saId = (e_ScSaId)SECY_AN_FREE_VALUE;
11916 + }
11917 +
11918 + /* Tx Sc Allocation */
11919 + p_FmMacsecSecY->p_TxSc = (t_SecYSc *)XX_Malloc(sizeof(t_SecYSc) * p_FmMacsecSecY->numOfTxSc);
11920 + if (!p_FmMacsecSecY->p_TxSc)
11921 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC SECY TX SC"));
11922 + memset(p_FmMacsecSecY->p_TxSc, 0, sizeof(t_SecYSc) * p_FmMacsecSecY->numOfTxSc);
11923 +
11924 + if ((err = FmMacsecAllocScs(p_FmMacsecSecY->h_FmMacsec, e_SC_TX, p_FmMacsecSecY->isPointToPoint, p_FmMacsecSecY->numOfTxSc, txScIds)) != E_OK)
11925 + {
11926 + if (p_FmMacsecSecY->p_TxSc)
11927 + XX_Free(p_FmMacsecSecY->p_TxSc);
11928 + if (p_FmMacsecSecY->p_RxSc)
11929 + XX_Free(p_FmMacsecSecY->p_RxSc);
11930 + return ERROR_CODE(err);
11931 + }
11932 + for (i=0; i<p_FmMacsecSecY->numOfTxSc; i++)
11933 + {
11934 + p_FmMacsecSecY->p_TxSc[i].scId = txScIds[i];
11935 + p_FmMacsecSecY->p_TxSc[i].type = e_SC_TX;
11936 + for (j=0; j<MAX_NUM_OF_SA_PER_SC;j++)
11937 + p_FmMacsecSecY->p_TxSc[i].sa[j].saId = (e_ScSaId)SECY_AN_FREE_VALUE;
11938 + FmMacsecRegisterIntr(p_FmMacsecSecY->h_FmMacsec,
11939 + e_FM_MACSEC_MOD_SC_TX,
11940 + (uint8_t)txScIds[i],
11941 + e_FM_INTR_TYPE_ERR,
11942 + FmMacsecSecYExceptionsIsr,
11943 + p_FmMacsecSecY);
11944 + FmMacsecRegisterIntr(p_FmMacsecSecY->h_FmMacsec,
11945 + e_FM_MACSEC_MOD_SC_TX,
11946 + (uint8_t)txScIds[i],
11947 + e_FM_INTR_TYPE_NORMAL,
11948 + FmMacsecSecYEventsIsr,
11949 + p_FmMacsecSecY);
11950 +
11951 + if (p_FmMacsecSecY->exceptions & FM_MACSEC_SECY_EX_FRAME_DISCARDED)
11952 + FmMacsecSetException(p_FmMacsecSecY->h_FmMacsec, e_FM_MACSEC_EX_TX_SC, txScIds[i], TRUE);
11953 + if (p_FmMacsecSecY->events & FM_MACSEC_SECY_EV_NEXT_PN)
11954 + FmMacsecSetEvent(p_FmMacsecSecY->h_FmMacsec, e_FM_MACSEC_EV_TX_SC_NEXT_PN, txScIds[i], TRUE);
11955 + }
11956 +
11957 + FmMacsecSecYCreateSc(p_FmMacsecSecY,
11958 + p_FmMacsecSecYDriverParam->txScParams.sci,
11959 + p_FmMacsecSecYDriverParam->txScParams.cipherSuite,
11960 + e_SC_TX);
11961 + XX_Free(p_FmMacsecSecYDriverParam);
11962 + p_FmMacsecSecY->p_FmMacsecSecYDriverParam = NULL;
11963 +
11964 + return E_OK;
11965 +}
11966 +
11967 +t_Error FM_MACSEC_SECY_Free(t_Handle h_FmMacsecSecY)
11968 +{
11969 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
11970 + t_Error err = E_OK;
11971 + uint32_t rxScIds[NUM_OF_RX_SC], txScIds[NUM_OF_TX_SC], i;
11972 +
11973 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
11974 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
11975 +
11976 + if (p_FmMacsecSecY->isPointToPoint)
11977 + FmMacsecSetPTP(p_FmMacsecSecY->h_FmMacsec, FALSE);
11978 + if (p_FmMacsecSecY->p_RxSc)
11979 + {
11980 + for (i=0; i<p_FmMacsecSecY->numOfRxSc; i++)
11981 + rxScIds[i] = p_FmMacsecSecY->p_RxSc[i].scId;
11982 + if ((err = FmMacsecFreeScs(p_FmMacsecSecY->h_FmMacsec, e_SC_RX, p_FmMacsecSecY->numOfRxSc, rxScIds)) != E_OK)
11983 + return ERROR_CODE(err);
11984 + XX_Free(p_FmMacsecSecY->p_RxSc);
11985 + }
11986 + if (p_FmMacsecSecY->p_TxSc)
11987 + {
11988 + FmMacsecSecYDeleteSc(p_FmMacsecSecY, &p_FmMacsecSecY->p_TxSc[0], e_SC_TX);
11989 +
11990 + for (i=0; i<p_FmMacsecSecY->numOfTxSc; i++) {
11991 + txScIds[i] = p_FmMacsecSecY->p_TxSc[i].scId;
11992 + FmMacsecUnregisterIntr(p_FmMacsecSecY->h_FmMacsec,
11993 + e_FM_MACSEC_MOD_SC_TX,
11994 + (uint8_t)txScIds[i],
11995 + e_FM_INTR_TYPE_ERR);
11996 + FmMacsecUnregisterIntr(p_FmMacsecSecY->h_FmMacsec,
11997 + e_FM_MACSEC_MOD_SC_TX,
11998 + (uint8_t)txScIds[i],
11999 + e_FM_INTR_TYPE_NORMAL);
12000 +
12001 + if (p_FmMacsecSecY->exceptions & FM_MACSEC_SECY_EX_FRAME_DISCARDED)
12002 + FmMacsecSetException(p_FmMacsecSecY->h_FmMacsec, e_FM_MACSEC_EX_TX_SC, txScIds[i], FALSE);
12003 + if (p_FmMacsecSecY->events & FM_MACSEC_SECY_EV_NEXT_PN)
12004 + FmMacsecSetEvent(p_FmMacsecSecY->h_FmMacsec, e_FM_MACSEC_EV_TX_SC_NEXT_PN, txScIds[i], FALSE);
12005 + }
12006 +
12007 + if ((err = FmMacsecFreeScs(p_FmMacsecSecY->h_FmMacsec, e_SC_TX, p_FmMacsecSecY->numOfTxSc, txScIds)) != E_OK)
12008 + return ERROR_CODE(err);
12009 + XX_Free(p_FmMacsecSecY->p_TxSc);
12010 + }
12011 +
12012 + XX_Free(p_FmMacsecSecY);
12013 +
12014 + return err;
12015 +}
12016 +
12017 +t_Error FM_MACSEC_SECY_ConfigSciInsertionMode(t_Handle h_FmMacsecSecY, e_FmMacsecSciInsertionMode sciInsertionMode)
12018 +{
12019 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12020 +
12021 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12022 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12023 +
12024 + p_FmMacsecSecY->sciInsertionMode = sciInsertionMode;
12025 +
12026 + return E_OK;
12027 +}
12028 +
12029 +t_Error FM_MACSEC_SECY_ConfigProtectFrames(t_Handle h_FmMacsecSecY, bool protectFrames)
12030 +{
12031 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12032 +
12033 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12034 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12035 +
12036 + p_FmMacsecSecY->protectFrames = protectFrames;
12037 +
12038 + return E_OK;
12039 +}
12040 +
12041 +t_Error FM_MACSEC_SECY_ConfigReplayWindow(t_Handle h_FmMacsecSecY, bool replayProtect, uint32_t replayWindow)
12042 +{
12043 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12044 +
12045 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12046 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12047 +
12048 + p_FmMacsecSecY->replayProtect = replayProtect;
12049 + p_FmMacsecSecY->replayWindow = replayWindow;
12050 +
12051 + return E_OK;
12052 +}
12053 +
12054 +t_Error FM_MACSEC_SECY_ConfigValidationMode(t_Handle h_FmMacsecSecY, e_FmMacsecValidFrameBehavior validateFrames)
12055 +{
12056 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12057 +
12058 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12059 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12060 +
12061 + p_FmMacsecSecY->validateFrames = validateFrames;
12062 +
12063 + return E_OK;
12064 +}
12065 +
12066 +t_Error FM_MACSEC_SECY_ConfigConfidentiality(t_Handle h_FmMacsecSecY, bool confidentialityEnable, uint16_t confidentialityOffset)
12067 +{
12068 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12069 +
12070 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12071 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12072 +
12073 + p_FmMacsecSecY->confidentialityEnable = confidentialityEnable;
12074 + p_FmMacsecSecY->confidentialityOffset = confidentialityOffset;
12075 +
12076 + return E_OK;
12077 +}
12078 +
12079 +t_Error FM_MACSEC_SECY_ConfigPointToPoint(t_Handle h_FmMacsecSecY)
12080 +{
12081 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12082 +
12083 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12084 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12085 +
12086 + p_FmMacsecSecY->numOfRxSc = 1;
12087 + p_FmMacsecSecY->isPointToPoint = TRUE;
12088 + p_FmMacsecSecY->sciInsertionMode = e_FM_MACSEC_SCI_INSERTION_MODE_IMPLICT_PTP;
12089 +
12090 + return E_OK;
12091 +}
12092 +
12093 +t_Error FM_MACSEC_SECY_ConfigException(t_Handle h_FmMacsecSecY, e_FmMacsecSecYExceptions exception, bool enable)
12094 +{
12095 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12096 + uint32_t bitMask = 0;
12097 +
12098 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12099 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12100 +
12101 + GET_EXCEPTION_FLAG(bitMask, exception);
12102 + if (bitMask)
12103 + {
12104 + if (enable)
12105 + p_FmMacsecSecY->exceptions |= bitMask;
12106 + else
12107 + p_FmMacsecSecY->exceptions &= ~bitMask;
12108 + }
12109 + else
12110 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
12111 +
12112 + return E_OK;
12113 +}
12114 +
12115 +t_Error FM_MACSEC_SECY_ConfigEvent(t_Handle h_FmMacsecSecY, e_FmMacsecSecYEvents event, bool enable)
12116 +{
12117 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12118 + uint32_t bitMask = 0;
12119 +
12120 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12121 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12122 +
12123 + GET_EVENT_FLAG(bitMask, event);
12124 + if (bitMask)
12125 + {
12126 + if (enable)
12127 + p_FmMacsecSecY->events |= bitMask;
12128 + else
12129 + p_FmMacsecSecY->events &= ~bitMask;
12130 + }
12131 + else
12132 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined event"));
12133 +
12134 + return E_OK;
12135 +}
12136 +
12137 +t_Handle FM_MACSEC_SECY_CreateRxSc(t_Handle h_FmMacsecSecY, t_FmMacsecSecYSCParams *p_ScParams)
12138 +{
12139 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12140 +
12141 + SANITY_CHECK_RETURN_VALUE(p_FmMacsecSecY, E_INVALID_HANDLE, NULL);
12142 + SANITY_CHECK_RETURN_VALUE(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE, NULL);
12143 + SANITY_CHECK_RETURN_VALUE(p_ScParams, E_NULL_POINTER, NULL);
12144 + SANITY_CHECK_RETURN_VALUE(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE, NULL);
12145 +
12146 + return FmMacsecSecYCreateSc(p_FmMacsecSecY, p_ScParams->sci, p_ScParams->cipherSuite, e_SC_RX);
12147 +}
12148 +
12149 +t_Error FM_MACSEC_SECY_DeleteRxSc(t_Handle h_FmMacsecSecY, t_Handle h_Sc)
12150 +{
12151 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12152 + t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
12153 +
12154 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12155 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12156 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12157 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12158 +
12159 + return FmMacsecSecYDeleteSc(p_FmMacsecSecY, p_FmSecYSc, e_SC_RX);
12160 +}
12161 +
12162 +t_Error FM_MACSEC_SECY_CreateRxSa(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, uint32_t lowestPn, macsecSAKey_t key)
12163 +{
12164 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12165 + t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
12166 + t_Error err = E_OK;
12167 +
12168 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12169 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12170 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12171 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12172 + SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
12173 +
12174 + if (p_FmSecYSc->sa[an].saId != SECY_AN_FREE_VALUE)
12175 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is already assigned",an));
12176 +
12177 + if ((err = FmMacsecCreateRxSa(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, (e_ScSaId)p_FmSecYSc->numOfSa, an, lowestPn, key)) != E_OK)
12178 + RETURN_ERROR(MINOR, err, NO_MSG);
12179 +
12180 + p_FmSecYSc->sa[an].saId = (e_ScSaId)p_FmSecYSc->numOfSa++;
12181 + return err;
12182 +}
12183 +
12184 +t_Error FM_MACSEC_SECY_DeleteRxSa(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an)
12185 +{
12186 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12187 + t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
12188 + t_Error err = E_OK;
12189 +
12190 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12191 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12192 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12193 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12194 + SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
12195 +
12196 + if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
12197 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is already deleted",an));
12198 +
12199 + if ((err = FmMacsecDeleteRxSa(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId)) != E_OK)
12200 + RETURN_ERROR(MINOR, err, NO_MSG);
12201 +
12202 + p_FmSecYSc->numOfSa--;
12203 + p_FmSecYSc->sa[an].saId = (e_ScSaId)SECY_AN_FREE_VALUE;
12204 + /* TODO - check if statistics need to be read*/
12205 + return err;
12206 +}
12207 +
12208 +t_Error FM_MACSEC_SECY_RxSaEnableReceive(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an)
12209 +{
12210 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12211 + t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
12212 + t_Error err = E_OK;
12213 +
12214 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12215 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12216 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12217 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12218 + SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
12219 +
12220 + if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
12221 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is not configured",an));
12222 +
12223 + if ((err = FmMacsecRxSaSetReceive(p_FmMacsecSecY->h_FmMacsec,p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, TRUE)) != E_OK)
12224 + RETURN_ERROR(MINOR, err, NO_MSG);
12225 +
12226 + p_FmSecYSc->sa[an].active = TRUE;
12227 + return err;
12228 +}
12229 +
12230 +t_Error FM_MACSEC_SECY_RxSaDisableReceive(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an)
12231 +{
12232 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12233 + t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
12234 + t_Error err = E_OK;
12235 +
12236 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12237 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12238 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12239 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12240 + SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
12241 +
12242 + if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
12243 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is not configured",an));
12244 +
12245 + if ((err = FmMacsecRxSaSetReceive(p_FmMacsecSecY->h_FmMacsec,p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, FALSE)) != E_OK)
12246 + RETURN_ERROR(MINOR, err, NO_MSG);
12247 +
12248 + p_FmSecYSc->sa[an].active = FALSE;
12249 + return err;
12250 +}
12251 +
12252 +t_Error FM_MACSEC_SECY_RxSaUpdateNextPn(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, uint32_t updtNextPN)
12253 +{
12254 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12255 + t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
12256 + t_Error err = E_OK;
12257 +
12258 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12259 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12260 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12261 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12262 + SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
12263 +
12264 + if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
12265 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is not configured",an));
12266 +
12267 + if ((err = FmMacsecRxSaUpdateNextPn(p_FmMacsecSecY->h_FmMacsec,p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, updtNextPN)) != E_OK)
12268 + RETURN_ERROR(MINOR, err, NO_MSG);
12269 +
12270 + return err;
12271 +}
12272 +
12273 +t_Error FM_MACSEC_SECY_RxSaUpdateLowestPn(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, uint32_t updtLowestPN)
12274 +{
12275 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12276 + t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
12277 + t_Error err = E_OK;
12278 +
12279 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12280 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12281 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12282 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12283 + SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
12284 +
12285 + if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
12286 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is not configured",an));
12287 +
12288 + if ((err = FmMacsecRxSaUpdateLowestPn(p_FmMacsecSecY->h_FmMacsec,p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, updtLowestPN)) != E_OK)
12289 + RETURN_ERROR(MINOR, err, NO_MSG);
12290 +
12291 + return err;
12292 +}
12293 +
12294 +t_Error FM_MACSEC_SECY_RxSaModifyKey(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, macsecSAKey_t key)
12295 +{
12296 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12297 + t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
12298 + t_Error err = E_OK;
12299 +
12300 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12301 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12302 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12303 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12304 + SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
12305 +
12306 + if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
12307 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is not configured",an));
12308 +
12309 + if (p_FmSecYSc->sa[an].active)
12310 + if ((err = FmMacsecRxSaSetReceive(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, FALSE)) != E_OK)
12311 + RETURN_ERROR(MINOR, err, NO_MSG);
12312 +
12313 + /* TODO - statistics should be read */
12314 +
12315 + if ((err = FmMacsecCreateRxSa(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, an, 1, key)) != E_OK)
12316 + RETURN_ERROR(MINOR, err, NO_MSG);
12317 +
12318 + if (p_FmSecYSc->sa[an].active)
12319 + if ((err = FmMacsecRxSaSetReceive(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, TRUE)) != E_OK)
12320 + RETURN_ERROR(MINOR, err, NO_MSG);
12321 + return err;
12322 +}
12323 +
12324 +
12325 +t_Error FM_MACSEC_SECY_CreateTxSa(t_Handle h_FmMacsecSecY, macsecAN_t an, macsecSAKey_t key)
12326 +{
12327 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12328 + t_SecYSc *p_FmSecYSc;
12329 + t_Error err = E_OK;
12330 +
12331 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12332 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12333 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12334 + p_FmSecYSc = &p_FmMacsecSecY->p_TxSc[0];
12335 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12336 + SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
12337 +
12338 + if (p_FmSecYSc->sa[an].saId != SECY_AN_FREE_VALUE)
12339 + RETURN_ERROR(MINOR, err, ("An %d is already assigned",an));
12340 +
12341 + if ((err = FmMacsecCreateTxSa(p_FmMacsecSecY->h_FmMacsec,p_FmSecYSc->scId, (e_ScSaId)p_FmSecYSc->numOfSa, key)) != E_OK)
12342 + RETURN_ERROR(MINOR, err, NO_MSG);
12343 +
12344 + p_FmSecYSc->sa[an].saId = (e_ScSaId)p_FmSecYSc->numOfSa++;
12345 + return err;
12346 +}
12347 +
12348 +t_Error FM_MACSEC_SECY_DeleteTxSa(t_Handle h_FmMacsecSecY, macsecAN_t an)
12349 +{
12350 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12351 + t_SecYSc *p_FmSecYSc;
12352 + t_Error err = E_OK;
12353 +
12354 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12355 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12356 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12357 + p_FmSecYSc = &p_FmMacsecSecY->p_TxSc[0];
12358 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12359 + SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
12360 +
12361 + if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
12362 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is already deleted",an));
12363 +
12364 + if ((err = FmMacsecDeleteTxSa(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId)) != E_OK)
12365 + RETURN_ERROR(MINOR, err, NO_MSG);
12366 +
12367 + p_FmSecYSc->numOfSa--;
12368 + p_FmSecYSc->sa[an].saId = (e_ScSaId)SECY_AN_FREE_VALUE;
12369 + /* TODO - check if statistics need to be read*/
12370 + return err;
12371 +}
12372 +
12373 +t_Error FM_MACSEC_SECY_TxSaModifyKey(t_Handle h_FmMacsecSecY, macsecAN_t nextActiveAn, macsecSAKey_t key)
12374 +{
12375 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12376 + t_SecYSc *p_FmSecYSc;
12377 + macsecAN_t currentAn;
12378 + t_Error err = E_OK;
12379 +
12380 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12381 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12382 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12383 + p_FmSecYSc = &p_FmMacsecSecY->p_TxSc[0];
12384 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12385 + SANITY_CHECK_RETURN_ERROR(nextActiveAn < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
12386 +
12387 + if ((err = FmMacsecTxSaGetActive(p_FmMacsecSecY->h_FmMacsec,
12388 + p_FmSecYSc->scId,
12389 + &currentAn)) != E_OK)
12390 + RETURN_ERROR(MINOR, err, NO_MSG);
12391 +
12392 + if ((err = FmMacsecTxSaSetActive(p_FmMacsecSecY->h_FmMacsec,
12393 + p_FmSecYSc->scId,
12394 + p_FmSecYSc->sa[nextActiveAn].saId,
12395 + nextActiveAn)) != E_OK)
12396 + RETURN_ERROR(MINOR, err, NO_MSG);
12397 +
12398 + /* TODO - statistics should be read */
12399 +
12400 + if ((err = FmMacsecCreateTxSa(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, p_FmSecYSc->sa[currentAn].saId, key)) != E_OK)
12401 + RETURN_ERROR(MINOR, err, NO_MSG);
12402 +
12403 + return err;
12404 +}
12405 +
12406 +t_Error FM_MACSEC_SECY_TxSaSetActive(t_Handle h_FmMacsecSecY, macsecAN_t an)
12407 +{
12408 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12409 + t_SecYSc *p_FmSecYSc;
12410 + t_Error err = E_OK;
12411 +
12412 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12413 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12414 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12415 + p_FmSecYSc = &p_FmMacsecSecY->p_TxSc[0];
12416 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12417 + SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
12418 +
12419 + if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
12420 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is not configured",an));
12421 +
12422 + if ((err = FmMacsecTxSaSetActive(p_FmMacsecSecY->h_FmMacsec,
12423 + p_FmSecYSc->scId,
12424 + p_FmSecYSc->sa[an].saId,
12425 + an)) != E_OK)
12426 + RETURN_ERROR(MINOR, err, NO_MSG);
12427 +
12428 + return err;
12429 +}
12430 +
12431 +t_Error FM_MACSEC_SECY_TxSaGetActive(t_Handle h_FmMacsecSecY, macsecAN_t *p_An)
12432 +{
12433 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12434 + t_SecYSc *p_FmSecYSc;
12435 + t_Error err = E_OK;
12436 +
12437 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12438 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12439 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12440 + p_FmSecYSc = &p_FmMacsecSecY->p_TxSc[0];
12441 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12442 + SANITY_CHECK_RETURN_ERROR(p_An, E_INVALID_HANDLE);
12443 +
12444 + if ((err = FmMacsecTxSaGetActive(p_FmMacsecSecY->h_FmMacsec,
12445 + p_FmSecYSc->scId,
12446 + p_An)) != E_OK)
12447 + RETURN_ERROR(MINOR, err, NO_MSG);
12448 +
12449 + return err;
12450 +}
12451 +
12452 +t_Error FM_MACSEC_SECY_GetRxScPhysId(t_Handle h_FmMacsecSecY, t_Handle h_Sc, uint32_t *p_ScPhysId)
12453 +{
12454 + t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
12455 + t_Error err = E_OK;
12456 +
12457 + SANITY_CHECK_RETURN_ERROR(h_FmMacsecSecY, E_INVALID_HANDLE);
12458 + SANITY_CHECK_RETURN_ERROR(((t_FmMacsecSecY *)h_FmMacsecSecY)->h_FmMacsec, E_INVALID_HANDLE);
12459 + SANITY_CHECK_RETURN_ERROR(!((t_FmMacsecSecY *)h_FmMacsecSecY)->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12460 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12461 +#ifdef DISABLE_SANITY_CHECKS
12462 + UNUSED(h_FmMacsecSecY);
12463 +#endif /* DISABLE_SANITY_CHECKS */
12464 +
12465 + *p_ScPhysId = p_FmSecYSc->scId;
12466 + return err;
12467 +}
12468 +
12469 +t_Error FM_MACSEC_SECY_GetTxScPhysId(t_Handle h_FmMacsecSecY, uint32_t *p_ScPhysId)
12470 +{
12471 + t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
12472 + t_SecYSc *p_FmSecYSc;
12473 + t_Error err = E_OK;
12474 +
12475 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
12476 + SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
12477 + SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
12478 + p_FmSecYSc = &p_FmMacsecSecY->p_TxSc[0];
12479 + SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
12480 +
12481 + *p_ScPhysId = p_FmSecYSc->scId;
12482 + return err;
12483 +}
12484 +
12485 +t_Error FM_MACSEC_SECY_SetException(t_Handle h_FmMacsecSecY, e_FmMacsecExceptions exception, bool enable)
12486 +{
12487 + UNUSED(h_FmMacsecSecY);UNUSED(exception);UNUSED(enable);
12488 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
12489 +}
12490 +
12491 +t_Error FM_MACSEC_SECY_SetEvent(t_Handle h_FmMacsecSecY, e_FmMacsecSecYEvents event, bool enable)
12492 +{
12493 + UNUSED(h_FmMacsecSecY);UNUSED(event);UNUSED(enable);
12494 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
12495 +}
12496 +
12497 +t_Error FM_MACSEC_SECY_GetStatistics(t_Handle h_FmMacsecSecY, t_FmMacsecSecYStatistics *p_Statistics)
12498 +{
12499 + UNUSED(h_FmMacsecSecY);UNUSED(p_Statistics);
12500 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
12501 +}
12502 +
12503 +t_Error FM_MACSEC_SECY_RxScGetStatistics(t_Handle h_FmMacsecSecY, t_Handle h_Sc, t_FmMacsecSecYRxScStatistics *p_Statistics)
12504 +{
12505 + UNUSED(h_FmMacsecSecY);UNUSED(h_Sc);UNUSED(p_Statistics);
12506 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
12507 +}
12508 +
12509 +t_Error FM_MACSEC_SECY_RxSaGetStatistics(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, t_FmMacsecSecYRxSaStatistics *p_Statistics)
12510 +{
12511 + UNUSED(h_FmMacsecSecY);UNUSED(h_Sc);UNUSED(an);UNUSED(p_Statistics);
12512 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
12513 +}
12514 +
12515 +t_Error FM_MACSEC_SECY_TxScGetStatistics(t_Handle h_FmMacsecSecY, t_FmMacsecSecYTxScStatistics *p_Statistics)
12516 +{
12517 + UNUSED(h_FmMacsecSecY);UNUSED(p_Statistics);
12518 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
12519 +}
12520 +
12521 +t_Error FM_MACSEC_SECY_TxSaGetStatistics(t_Handle h_FmMacsecSecY, macsecAN_t an, t_FmMacsecSecYTxSaStatistics *p_Statistics)
12522 +{
12523 + UNUSED(h_FmMacsecSecY);UNUSED(an);UNUSED(p_Statistics);
12524 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
12525 +}
12526 +
12527 --- /dev/null
12528 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_secy.h
12529 @@ -0,0 +1,144 @@
12530 +/*
12531 + * Copyright 2008-2015 Freescale Semiconductor Inc.
12532 + *
12533 + * Redistribution and use in source and binary forms, with or without
12534 + * modification, are permitted provided that the following conditions are met:
12535 + * * Redistributions of source code must retain the above copyright
12536 + * notice, this list of conditions and the following disclaimer.
12537 + * * Redistributions in binary form must reproduce the above copyright
12538 + * notice, this list of conditions and the following disclaimer in the
12539 + * documentation and/or other materials provided with the distribution.
12540 + * * Neither the name of Freescale Semiconductor nor the
12541 + * names of its contributors may be used to endorse or promote products
12542 + * derived from this software without specific prior written permission.
12543 + *
12544 + *
12545 + * ALTERNATIVELY, this software may be distributed under the terms of the
12546 + * GNU General Public License ("GPL") as published by the Free Software
12547 + * Foundation, either version 2 of that License or (at your option) any
12548 + * later version.
12549 + *
12550 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
12551 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
12552 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
12553 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
12554 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
12555 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
12556 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
12557 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12558 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
12559 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12560 + */
12561 +
12562 +/******************************************************************************
12563 + @File fm_macsec_secy.h
12564 +
12565 + @Description FM MACSEC SecY internal structures and definitions.
12566 +*//***************************************************************************/
12567 +#ifndef __FM_MACSEC_SECY_H
12568 +#define __FM_MACSEC_SECY_H
12569 +
12570 +#include "error_ext.h"
12571 +#include "std_ext.h"
12572 +
12573 +#include "fm_macsec.h"
12574 +
12575 +
12576 +/**************************************************************************//**
12577 + @Description Exceptions
12578 +*//***************************************************************************/
12579 +
12580 +#define FM_MACSEC_SECY_EX_FRAME_DISCARDED 0x80000000
12581 +
12582 +#define GET_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \
12583 + case e_FM_MACSEC_SECY_EX_FRAME_DISCARDED: \
12584 + bitMask = FM_MACSEC_SECY_EX_FRAME_DISCARDED; break; \
12585 + default: bitMask = 0;break;}
12586 +
12587 +/**************************************************************************//**
12588 + @Description Events
12589 +*//***************************************************************************/
12590 +
12591 +#define FM_MACSEC_SECY_EV_NEXT_PN 0x80000000
12592 +
12593 +#define GET_EVENT_FLAG(bitMask, event) switch (event){ \
12594 + case e_FM_MACSEC_SECY_EV_NEXT_PN: \
12595 + bitMask = FM_MACSEC_SECY_EV_NEXT_PN; break; \
12596 + default: bitMask = 0;break;}
12597 +
12598 +/**************************************************************************//**
12599 + @Description Defaults
12600 +*//***************************************************************************/
12601 +
12602 +#define DEFAULT_exceptions (FM_MACSEC_SECY_EX_FRAME_DISCARDED)
12603 +#define DEFAULT_events (FM_MACSEC_SECY_EV_NEXT_PN)
12604 +#define DEFAULT_numOfTxSc 1
12605 +#define DEFAULT_confidentialityEnable FALSE
12606 +#define DEFAULT_confidentialityOffset 0
12607 +#define DEFAULT_sciInsertionMode e_FM_MACSEC_SCI_INSERTION_MODE_EXPLICIT_SECTAG
12608 +#define DEFAULT_validateFrames e_FM_MACSEC_VALID_FRAME_BEHAVIOR_STRICT
12609 +#define DEFAULT_replayEnable FALSE
12610 +#define DEFAULT_replayWindow 0
12611 +#define DEFAULT_protectFrames TRUE
12612 +#define DEFAULT_ptp FALSE
12613 +
12614 +/**************************************************************************//**
12615 + @Description General defines
12616 +*//***************************************************************************/
12617 +
12618 +#define SECY_AN_FREE_VALUE MAX_NUM_OF_SA_PER_SC
12619 +
12620 +
12621 +typedef struct {
12622 + e_ScSaId saId;
12623 + bool active;
12624 + union {
12625 + t_FmMacsecSecYRxSaStatistics rxSaStatistics;
12626 + t_FmMacsecSecYTxSaStatistics txSaStatistics;
12627 + };
12628 +} t_SecYSa;
12629 +
12630 +typedef struct {
12631 + bool inUse;
12632 + uint32_t scId;
12633 + e_ScType type;
12634 + uint8_t numOfSa;
12635 + t_SecYSa sa[MAX_NUM_OF_SA_PER_SC];
12636 + union {
12637 + t_FmMacsecSecYRxScStatistics rxScStatistics;
12638 + t_FmMacsecSecYTxScStatistics txScStatistics;
12639 + };
12640 +} t_SecYSc;
12641 +
12642 +typedef struct {
12643 + t_FmMacsecSecYSCParams txScParams; /**< Tx SC Params */
12644 +} t_FmMacsecSecYDriverParam;
12645 +
12646 +typedef struct {
12647 + t_Handle h_FmMacsec;
12648 + bool confidentialityEnable; /**< TRUE - confidentiality protection and integrity protection
12649 + FALSE - no confidentiality protection, only integrity protection*/
12650 + uint16_t confidentialityOffset; /**< The number of initial octets of each MSDU without confidentiality protection
12651 + common values are 0, 30, and 50 */
12652 + bool replayProtect; /**< replay protection function mode */
12653 + uint32_t replayWindow; /**< the size of the replay window */
12654 + e_FmMacsecValidFrameBehavior validateFrames; /**< validation function mode */
12655 + e_FmMacsecSciInsertionMode sciInsertionMode;
12656 + bool protectFrames;
12657 + bool isPointToPoint;
12658 + e_FmMacsecSecYCipherSuite cipherSuite; /**< Cipher suite to be used for this SecY */
12659 + uint32_t numOfRxSc; /**< Number of receive channels */
12660 + uint32_t numOfTxSc; /**< Number of transmit channels */
12661 + t_SecYSc *p_RxSc;
12662 + t_SecYSc *p_TxSc;
12663 + uint32_t events;
12664 + uint32_t exceptions;
12665 + t_FmMacsecSecYExceptionsCallback *f_Exception; /**< TODO */
12666 + t_FmMacsecSecYEventsCallback *f_Event; /**< TODO */
12667 + t_Handle h_App;
12668 + t_FmMacsecSecYStatistics statistics;
12669 + t_FmMacsecSecYDriverParam *p_FmMacsecSecYDriverParam;
12670 +} t_FmMacsecSecY;
12671 +
12672 +
12673 +#endif /* __FM_MACSEC_SECY_H */
12674 --- /dev/null
12675 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Makefile
12676 @@ -0,0 +1,23 @@
12677 +#
12678 +# Makefile for the Freescale Ethernet controllers
12679 +#
12680 +ccflags-y += -DVERSION=\"\"
12681 +#
12682 +#Include netcomm SW specific definitions
12683 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
12684 +NCSW_FM_INC = $(srctree)/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc
12685 +
12686 +ccflags-y += -I$(NCSW_FM_INC)
12687 +
12688 +
12689 +obj-y += fsl-ncsw-PFM1.o
12690 +
12691 +fsl-ncsw-PFM1-objs := fm.o fm_muram.o fman.o
12692 +
12693 +obj-y += MAC/
12694 +obj-y += Pcd/
12695 +obj-y += SP/
12696 +obj-y += Port/
12697 +obj-y += HC/
12698 +obj-y += Rtc/
12699 +obj-y += MACSEC/
12700 --- /dev/null
12701 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/Makefile
12702 @@ -0,0 +1,26 @@
12703 +#
12704 +# Makefile for the Freescale Ethernet controllers
12705 +#
12706 +ccflags-y += -DVERSION=\"\"
12707 +#
12708 +#Include netcomm SW specific definitions
12709 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
12710 +
12711 +NCSW_FM_INC = $(srctree)/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc
12712 +
12713 +ccflags-y += -I$(NCSW_FM_INC)
12714 +
12715 +obj-y += fsl-ncsw-Pcd.o
12716 +
12717 +fsl-ncsw-Pcd-objs := fman_kg.o fman_prs.o fm_cc.o fm_kg.o fm_pcd.o fm_plcr.o fm_prs.o fm_manip.o
12718 +
12719 +ifeq ($(CONFIG_FMAN_V3H),y)
12720 +fsl-ncsw-Pcd-objs += fm_replic.o
12721 +endif
12722 +ifeq ($(CONFIG_FMAN_V3L),y)
12723 +fsl-ncsw-Pcd-objs += fm_replic.o
12724 +endif
12725 +ifeq ($(CONFIG_FMAN_ARM),y)
12726 +fsl-ncsw-Pcd-objs += fm_replic.o
12727 +endif
12728 +
12729 --- /dev/null
12730 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/crc64.h
12731 @@ -0,0 +1,360 @@
12732 +/*
12733 + * Copyright 2008-2012 Freescale Semiconductor Inc.
12734 + *
12735 + * Redistribution and use in source and binary forms, with or without
12736 + * modification, are permitted provided that the following conditions are met:
12737 + * * Redistributions of source code must retain the above copyright
12738 + * notice, this list of conditions and the following disclaimer.
12739 + * * Redistributions in binary form must reproduce the above copyright
12740 + * notice, this list of conditions and the following disclaimer in the
12741 + * documentation and/or other materials provided with the distribution.
12742 + * * Neither the name of Freescale Semiconductor nor the
12743 + * names of its contributors may be used to endorse or promote products
12744 + * derived from this software without specific prior written permission.
12745 + *
12746 + *
12747 + * ALTERNATIVELY, this software may be distributed under the terms of the
12748 + * GNU General Public License ("GPL") as published by the Free Software
12749 + * Foundation, either version 2 of that License or (at your option) any
12750 + * later version.
12751 + *
12752 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
12753 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
12754 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
12755 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
12756 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
12757 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
12758 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
12759 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12760 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
12761 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12762 + */
12763 +
12764 +
12765 + /**************************************************************************//**
12766 + @File crc64.h
12767 +
12768 + @Description brief This file contains the CRC64 Table, and __inline__
12769 + functions used for calculating crc.
12770 +*//***************************************************************************/
12771 +#ifndef __CRC64_H
12772 +#define __CRC64_H
12773 +
12774 +#include "std_ext.h"
12775 +
12776 +
12777 +#define BITS_PER_BYTE 8
12778 +
12779 +#define CRC64_EXPON_ECMA_182 0xC96C5795D7870F42ULL
12780 +#define CRC64_DEFAULT_INITVAL 0xFFFFFFFFFFFFFFFFULL
12781 +
12782 +#define CRC64_BYTE_MASK 0xFF
12783 +#define CRC64_TABLE_ENTRIES ( 1 << BITS_PER_BYTE )
12784 +#define CRC64_ODD_MASK 1
12785 +
12786 +
12787 +/**
12788 + \brief '64 bit crc' Table
12789 + */
12790 +struct crc64_t {
12791 + uint64_t initial; /**< Initial seed */
12792 + uint64_t table[CRC64_TABLE_ENTRIES]; /**< CRC table entries */
12793 +};
12794 +
12795 +
12796 +static struct crc64_t CRC64_ECMA_182 = {
12797 + CRC64_DEFAULT_INITVAL,
12798 + {
12799 + 0x0000000000000000ULL,
12800 + 0xb32e4cbe03a75f6fULL,
12801 + 0xf4843657a840a05bULL,
12802 + 0x47aa7ae9abe7ff34ULL,
12803 + 0x7bd0c384ff8f5e33ULL,
12804 + 0xc8fe8f3afc28015cULL,
12805 + 0x8f54f5d357cffe68ULL,
12806 + 0x3c7ab96d5468a107ULL,
12807 + 0xf7a18709ff1ebc66ULL,
12808 + 0x448fcbb7fcb9e309ULL,
12809 + 0x0325b15e575e1c3dULL,
12810 + 0xb00bfde054f94352ULL,
12811 + 0x8c71448d0091e255ULL,
12812 + 0x3f5f08330336bd3aULL,
12813 + 0x78f572daa8d1420eULL,
12814 + 0xcbdb3e64ab761d61ULL,
12815 + 0x7d9ba13851336649ULL,
12816 + 0xceb5ed8652943926ULL,
12817 + 0x891f976ff973c612ULL,
12818 + 0x3a31dbd1fad4997dULL,
12819 + 0x064b62bcaebc387aULL,
12820 + 0xb5652e02ad1b6715ULL,
12821 + 0xf2cf54eb06fc9821ULL,
12822 + 0x41e11855055bc74eULL,
12823 + 0x8a3a2631ae2dda2fULL,
12824 + 0x39146a8fad8a8540ULL,
12825 + 0x7ebe1066066d7a74ULL,
12826 + 0xcd905cd805ca251bULL,
12827 + 0xf1eae5b551a2841cULL,
12828 + 0x42c4a90b5205db73ULL,
12829 + 0x056ed3e2f9e22447ULL,
12830 + 0xb6409f5cfa457b28ULL,
12831 + 0xfb374270a266cc92ULL,
12832 + 0x48190ecea1c193fdULL,
12833 + 0x0fb374270a266cc9ULL,
12834 + 0xbc9d3899098133a6ULL,
12835 + 0x80e781f45de992a1ULL,
12836 + 0x33c9cd4a5e4ecdceULL,
12837 + 0x7463b7a3f5a932faULL,
12838 + 0xc74dfb1df60e6d95ULL,
12839 + 0x0c96c5795d7870f4ULL,
12840 + 0xbfb889c75edf2f9bULL,
12841 + 0xf812f32ef538d0afULL,
12842 + 0x4b3cbf90f69f8fc0ULL,
12843 + 0x774606fda2f72ec7ULL,
12844 + 0xc4684a43a15071a8ULL,
12845 + 0x83c230aa0ab78e9cULL,
12846 + 0x30ec7c140910d1f3ULL,
12847 + 0x86ace348f355aadbULL,
12848 + 0x3582aff6f0f2f5b4ULL,
12849 + 0x7228d51f5b150a80ULL,
12850 + 0xc10699a158b255efULL,
12851 + 0xfd7c20cc0cdaf4e8ULL,
12852 + 0x4e526c720f7dab87ULL,
12853 + 0x09f8169ba49a54b3ULL,
12854 + 0xbad65a25a73d0bdcULL,
12855 + 0x710d64410c4b16bdULL,
12856 + 0xc22328ff0fec49d2ULL,
12857 + 0x85895216a40bb6e6ULL,
12858 + 0x36a71ea8a7ace989ULL,
12859 + 0x0adda7c5f3c4488eULL,
12860 + 0xb9f3eb7bf06317e1ULL,
12861 + 0xfe5991925b84e8d5ULL,
12862 + 0x4d77dd2c5823b7baULL,
12863 + 0x64b62bcaebc387a1ULL,
12864 + 0xd7986774e864d8ceULL,
12865 + 0x90321d9d438327faULL,
12866 + 0x231c512340247895ULL,
12867 + 0x1f66e84e144cd992ULL,
12868 + 0xac48a4f017eb86fdULL,
12869 + 0xebe2de19bc0c79c9ULL,
12870 + 0x58cc92a7bfab26a6ULL,
12871 + 0x9317acc314dd3bc7ULL,
12872 + 0x2039e07d177a64a8ULL,
12873 + 0x67939a94bc9d9b9cULL,
12874 + 0xd4bdd62abf3ac4f3ULL,
12875 + 0xe8c76f47eb5265f4ULL,
12876 + 0x5be923f9e8f53a9bULL,
12877 + 0x1c4359104312c5afULL,
12878 + 0xaf6d15ae40b59ac0ULL,
12879 + 0x192d8af2baf0e1e8ULL,
12880 + 0xaa03c64cb957be87ULL,
12881 + 0xeda9bca512b041b3ULL,
12882 + 0x5e87f01b11171edcULL,
12883 + 0x62fd4976457fbfdbULL,
12884 + 0xd1d305c846d8e0b4ULL,
12885 + 0x96797f21ed3f1f80ULL,
12886 + 0x2557339fee9840efULL,
12887 + 0xee8c0dfb45ee5d8eULL,
12888 + 0x5da24145464902e1ULL,
12889 + 0x1a083bacedaefdd5ULL,
12890 + 0xa9267712ee09a2baULL,
12891 + 0x955cce7fba6103bdULL,
12892 + 0x267282c1b9c65cd2ULL,
12893 + 0x61d8f8281221a3e6ULL,
12894 + 0xd2f6b4961186fc89ULL,
12895 + 0x9f8169ba49a54b33ULL,
12896 + 0x2caf25044a02145cULL,
12897 + 0x6b055fede1e5eb68ULL,
12898 + 0xd82b1353e242b407ULL,
12899 + 0xe451aa3eb62a1500ULL,
12900 + 0x577fe680b58d4a6fULL,
12901 + 0x10d59c691e6ab55bULL,
12902 + 0xa3fbd0d71dcdea34ULL,
12903 + 0x6820eeb3b6bbf755ULL,
12904 + 0xdb0ea20db51ca83aULL,
12905 + 0x9ca4d8e41efb570eULL,
12906 + 0x2f8a945a1d5c0861ULL,
12907 + 0x13f02d374934a966ULL,
12908 + 0xa0de61894a93f609ULL,
12909 + 0xe7741b60e174093dULL,
12910 + 0x545a57dee2d35652ULL,
12911 + 0xe21ac88218962d7aULL,
12912 + 0x5134843c1b317215ULL,
12913 + 0x169efed5b0d68d21ULL,
12914 + 0xa5b0b26bb371d24eULL,
12915 + 0x99ca0b06e7197349ULL,
12916 + 0x2ae447b8e4be2c26ULL,
12917 + 0x6d4e3d514f59d312ULL,
12918 + 0xde6071ef4cfe8c7dULL,
12919 + 0x15bb4f8be788911cULL,
12920 + 0xa6950335e42fce73ULL,
12921 + 0xe13f79dc4fc83147ULL,
12922 + 0x521135624c6f6e28ULL,
12923 + 0x6e6b8c0f1807cf2fULL,
12924 + 0xdd45c0b11ba09040ULL,
12925 + 0x9aefba58b0476f74ULL,
12926 + 0x29c1f6e6b3e0301bULL,
12927 + 0xc96c5795d7870f42ULL,
12928 + 0x7a421b2bd420502dULL,
12929 + 0x3de861c27fc7af19ULL,
12930 + 0x8ec62d7c7c60f076ULL,
12931 + 0xb2bc941128085171ULL,
12932 + 0x0192d8af2baf0e1eULL,
12933 + 0x4638a2468048f12aULL,
12934 + 0xf516eef883efae45ULL,
12935 + 0x3ecdd09c2899b324ULL,
12936 + 0x8de39c222b3eec4bULL,
12937 + 0xca49e6cb80d9137fULL,
12938 + 0x7967aa75837e4c10ULL,
12939 + 0x451d1318d716ed17ULL,
12940 + 0xf6335fa6d4b1b278ULL,
12941 + 0xb199254f7f564d4cULL,
12942 + 0x02b769f17cf11223ULL,
12943 + 0xb4f7f6ad86b4690bULL,
12944 + 0x07d9ba1385133664ULL,
12945 + 0x4073c0fa2ef4c950ULL,
12946 + 0xf35d8c442d53963fULL,
12947 + 0xcf273529793b3738ULL,
12948 + 0x7c0979977a9c6857ULL,
12949 + 0x3ba3037ed17b9763ULL,
12950 + 0x888d4fc0d2dcc80cULL,
12951 + 0x435671a479aad56dULL,
12952 + 0xf0783d1a7a0d8a02ULL,
12953 + 0xb7d247f3d1ea7536ULL,
12954 + 0x04fc0b4dd24d2a59ULL,
12955 + 0x3886b22086258b5eULL,
12956 + 0x8ba8fe9e8582d431ULL,
12957 + 0xcc0284772e652b05ULL,
12958 + 0x7f2cc8c92dc2746aULL,
12959 + 0x325b15e575e1c3d0ULL,
12960 + 0x8175595b76469cbfULL,
12961 + 0xc6df23b2dda1638bULL,
12962 + 0x75f16f0cde063ce4ULL,
12963 + 0x498bd6618a6e9de3ULL,
12964 + 0xfaa59adf89c9c28cULL,
12965 + 0xbd0fe036222e3db8ULL,
12966 + 0x0e21ac88218962d7ULL,
12967 + 0xc5fa92ec8aff7fb6ULL,
12968 + 0x76d4de52895820d9ULL,
12969 + 0x317ea4bb22bfdfedULL,
12970 + 0x8250e80521188082ULL,
12971 + 0xbe2a516875702185ULL,
12972 + 0x0d041dd676d77eeaULL,
12973 + 0x4aae673fdd3081deULL,
12974 + 0xf9802b81de97deb1ULL,
12975 + 0x4fc0b4dd24d2a599ULL,
12976 + 0xfceef8632775faf6ULL,
12977 + 0xbb44828a8c9205c2ULL,
12978 + 0x086ace348f355aadULL,
12979 + 0x34107759db5dfbaaULL,
12980 + 0x873e3be7d8faa4c5ULL,
12981 + 0xc094410e731d5bf1ULL,
12982 + 0x73ba0db070ba049eULL,
12983 + 0xb86133d4dbcc19ffULL,
12984 + 0x0b4f7f6ad86b4690ULL,
12985 + 0x4ce50583738cb9a4ULL,
12986 + 0xffcb493d702be6cbULL,
12987 + 0xc3b1f050244347ccULL,
12988 + 0x709fbcee27e418a3ULL,
12989 + 0x3735c6078c03e797ULL,
12990 + 0x841b8ab98fa4b8f8ULL,
12991 + 0xadda7c5f3c4488e3ULL,
12992 + 0x1ef430e13fe3d78cULL,
12993 + 0x595e4a08940428b8ULL,
12994 + 0xea7006b697a377d7ULL,
12995 + 0xd60abfdbc3cbd6d0ULL,
12996 + 0x6524f365c06c89bfULL,
12997 + 0x228e898c6b8b768bULL,
12998 + 0x91a0c532682c29e4ULL,
12999 + 0x5a7bfb56c35a3485ULL,
13000 + 0xe955b7e8c0fd6beaULL,
13001 + 0xaeffcd016b1a94deULL,
13002 + 0x1dd181bf68bdcbb1ULL,
13003 + 0x21ab38d23cd56ab6ULL,
13004 + 0x9285746c3f7235d9ULL,
13005 + 0xd52f0e859495caedULL,
13006 + 0x6601423b97329582ULL,
13007 + 0xd041dd676d77eeaaULL,
13008 + 0x636f91d96ed0b1c5ULL,
13009 + 0x24c5eb30c5374ef1ULL,
13010 + 0x97eba78ec690119eULL,
13011 + 0xab911ee392f8b099ULL,
13012 + 0x18bf525d915feff6ULL,
13013 + 0x5f1528b43ab810c2ULL,
13014 + 0xec3b640a391f4fadULL,
13015 + 0x27e05a6e926952ccULL,
13016 + 0x94ce16d091ce0da3ULL,
13017 + 0xd3646c393a29f297ULL,
13018 + 0x604a2087398eadf8ULL,
13019 + 0x5c3099ea6de60cffULL,
13020 + 0xef1ed5546e415390ULL,
13021 + 0xa8b4afbdc5a6aca4ULL,
13022 + 0x1b9ae303c601f3cbULL,
13023 + 0x56ed3e2f9e224471ULL,
13024 + 0xe5c372919d851b1eULL,
13025 + 0xa26908783662e42aULL,
13026 + 0x114744c635c5bb45ULL,
13027 + 0x2d3dfdab61ad1a42ULL,
13028 + 0x9e13b115620a452dULL,
13029 + 0xd9b9cbfcc9edba19ULL,
13030 + 0x6a978742ca4ae576ULL,
13031 + 0xa14cb926613cf817ULL,
13032 + 0x1262f598629ba778ULL,
13033 + 0x55c88f71c97c584cULL,
13034 + 0xe6e6c3cfcadb0723ULL,
13035 + 0xda9c7aa29eb3a624ULL,
13036 + 0x69b2361c9d14f94bULL,
13037 + 0x2e184cf536f3067fULL,
13038 + 0x9d36004b35545910ULL,
13039 + 0x2b769f17cf112238ULL,
13040 + 0x9858d3a9ccb67d57ULL,
13041 + 0xdff2a94067518263ULL,
13042 + 0x6cdce5fe64f6dd0cULL,
13043 + 0x50a65c93309e7c0bULL,
13044 + 0xe388102d33392364ULL,
13045 + 0xa4226ac498dedc50ULL,
13046 + 0x170c267a9b79833fULL,
13047 + 0xdcd7181e300f9e5eULL,
13048 + 0x6ff954a033a8c131ULL,
13049 + 0x28532e49984f3e05ULL,
13050 + 0x9b7d62f79be8616aULL,
13051 + 0xa707db9acf80c06dULL,
13052 + 0x14299724cc279f02ULL,
13053 + 0x5383edcd67c06036ULL,
13054 + 0xe0ada17364673f59ULL
13055 + }
13056 +};
13057 +
13058 +
13059 +/**
13060 + \brief Initializes the crc seed
13061 + */
13062 +static __inline__ uint64_t crc64_init(void)
13063 +{
13064 + return CRC64_ECMA_182.initial;
13065 +}
13066 +
13067 +/**
13068 + \brief Computes 64 bit the crc
13069 + \param[in] data Pointer to the Data in the frame
13070 + \param[in] len Length of the Data
13071 + \param[in] crc seed
13072 + \return calculated crc
13073 + */
13074 +static __inline__ uint64_t crc64_compute(void const *data,
13075 + uint32_t len,
13076 + uint64_t seed)
13077 +{
13078 + uint32_t i;
13079 + uint64_t crc = seed;
13080 + uint8_t *bdata = (uint8_t *) data;
13081 +
13082 + for (i = 0; i < len; i++)
13083 + crc =
13084 + CRC64_ECMA_182.
13085 + table[(crc ^ *bdata++) & CRC64_BYTE_MASK] ^ (crc >> 8);
13086 +
13087 + return crc;
13088 +}
13089 +
13090 +
13091 +#endif /* __CRC64_H */
13092 --- /dev/null
13093 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.c
13094 @@ -0,0 +1,7538 @@
13095 +/*
13096 + * Copyright 2008-2012 Freescale Semiconductor Inc.
13097 + *
13098 + * Redistribution and use in source and binary forms, with or without
13099 + * modification, are permitted provided that the following conditions are met:
13100 + * * Redistributions of source code must retain the above copyright
13101 + * notice, this list of conditions and the following disclaimer.
13102 + * * Redistributions in binary form must reproduce the above copyright
13103 + * notice, this list of conditions and the following disclaimer in the
13104 + * documentation and/or other materials provided with the distribution.
13105 + * * Neither the name of Freescale Semiconductor nor the
13106 + * names of its contributors may be used to endorse or promote products
13107 + * derived from this software without specific prior written permission.
13108 + *
13109 + *
13110 + * ALTERNATIVELY, this software may be distributed under the terms of the
13111 + * GNU General Public License ("GPL") as published by the Free Software
13112 + * Foundation, either version 2 of that License or (at your option) any
13113 + * later version.
13114 + *
13115 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
13116 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
13117 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
13118 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
13119 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
13120 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
13121 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
13122 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
13123 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
13124 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13125 + */
13126 +
13127 +
13128 +/******************************************************************************
13129 + @File fm_cc.c
13130 +
13131 + @Description FM Coarse Classifier implementation
13132 + *//***************************************************************************/
13133 +#include "std_ext.h"
13134 +#include "error_ext.h"
13135 +#include "string_ext.h"
13136 +#include "debug_ext.h"
13137 +#include "fm_pcd_ext.h"
13138 +#include "fm_muram_ext.h"
13139 +
13140 +#include "fm_common.h"
13141 +#include "fm_pcd.h"
13142 +#include "fm_hc.h"
13143 +#include "fm_cc.h"
13144 +#include "crc64.h"
13145 +
13146 +/****************************************/
13147 +/* static functions */
13148 +/****************************************/
13149 +
13150 +
13151 +static t_Error CcRootTryLock(t_Handle h_FmPcdCcTree)
13152 +{
13153 + t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
13154 +
13155 + ASSERT_COND(h_FmPcdCcTree);
13156 +
13157 + if (FmPcdLockTryLock(p_FmPcdCcTree->p_Lock))
13158 + return E_OK;
13159 +
13160 + return ERROR_CODE(E_BUSY);
13161 +}
13162 +
13163 +static void CcRootReleaseLock(t_Handle h_FmPcdCcTree)
13164 +{
13165 + t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
13166 +
13167 + ASSERT_COND(h_FmPcdCcTree);
13168 +
13169 + FmPcdLockUnlock(p_FmPcdCcTree->p_Lock);
13170 +}
13171 +
13172 +static void UpdateNodeOwner(t_FmPcdCcNode *p_CcNode, bool add)
13173 +{
13174 + uint32_t intFlags;
13175 +
13176 + ASSERT_COND(p_CcNode);
13177 +
13178 + intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);
13179 +
13180 + if (add)
13181 + p_CcNode->owners++;
13182 + else
13183 + {
13184 + ASSERT_COND(p_CcNode->owners);
13185 + p_CcNode->owners--;
13186 + }
13187 +
13188 + XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
13189 +}
13190 +
13191 +static __inline__ t_FmPcdStatsObj* DequeueStatsObj(t_List *p_List)
13192 +{
13193 + t_FmPcdStatsObj *p_StatsObj = NULL;
13194 + t_List *p_Next;
13195 +
13196 + if (!LIST_IsEmpty(p_List))
13197 + {
13198 + p_Next = LIST_FIRST(p_List);
13199 + p_StatsObj = LIST_OBJECT(p_Next, t_FmPcdStatsObj, node);
13200 + ASSERT_COND(p_StatsObj);
13201 + LIST_DelAndInit(p_Next);
13202 + }
13203 +
13204 + return p_StatsObj;
13205 +}
13206 +
13207 +static __inline__ void EnqueueStatsObj(t_List *p_List,
13208 + t_FmPcdStatsObj *p_StatsObj)
13209 +{
13210 + LIST_AddToTail(&p_StatsObj->node, p_List);
13211 +}
13212 +
13213 +static void FreeStatObjects(t_List *p_List, t_Handle h_FmMuram)
13214 +{
13215 + t_FmPcdStatsObj *p_StatsObj;
13216 +
13217 + while (!LIST_IsEmpty(p_List))
13218 + {
13219 + p_StatsObj = DequeueStatsObj(p_List);
13220 + ASSERT_COND(p_StatsObj);
13221 +
13222 + FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsAd);
13223 + FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsCounters);
13224 +
13225 + XX_Free(p_StatsObj);
13226 + }
13227 +}
13228 +
13229 +static t_FmPcdStatsObj* GetStatsObj(t_FmPcdCcNode *p_CcNode)
13230 +{
13231 + t_FmPcdStatsObj* p_StatsObj;
13232 + t_Handle h_FmMuram;
13233 +
13234 + ASSERT_COND(p_CcNode);
13235 +
13236 + /* If 'maxNumOfKeys' was passed, all statistics object were preallocated
13237 + upon node initialization */
13238 + if (p_CcNode->maxNumOfKeys)
13239 + {
13240 + p_StatsObj = DequeueStatsObj(&p_CcNode->availableStatsLst);
13241 + }
13242 + else
13243 + {
13244 + h_FmMuram = ((t_FmPcd *)(p_CcNode->h_FmPcd))->h_FmMuram;
13245 + ASSERT_COND(h_FmMuram);
13246 +
13247 + p_StatsObj = XX_Malloc(sizeof(t_FmPcdStatsObj));
13248 + if (!p_StatsObj)
13249 + {
13250 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("statistics object"));
13251 + return NULL;
13252 + }
13253 +
13254 + p_StatsObj->h_StatsAd = (t_Handle)FM_MURAM_AllocMem(
13255 + h_FmMuram, FM_PCD_CC_AD_ENTRY_SIZE, FM_PCD_CC_AD_TABLE_ALIGN);
13256 + if (!p_StatsObj->h_StatsAd)
13257 + {
13258 + XX_Free(p_StatsObj);
13259 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for statistics ADs"));
13260 + return NULL;
13261 + }
13262 + MemSet8(p_StatsObj->h_StatsAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
13263 +
13264 + p_StatsObj->h_StatsCounters = (t_Handle)FM_MURAM_AllocMem(
13265 + h_FmMuram, p_CcNode->countersArraySize,
13266 + FM_PCD_CC_AD_TABLE_ALIGN);
13267 + if (!p_StatsObj->h_StatsCounters)
13268 + {
13269 + FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsAd);
13270 + XX_Free(p_StatsObj);
13271 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for statistics counters"));
13272 + return NULL;
13273 + }
13274 + MemSet8(p_StatsObj->h_StatsCounters, 0, p_CcNode->countersArraySize);
13275 + }
13276 +
13277 + return p_StatsObj;
13278 +}
13279 +
13280 +static void PutStatsObj(t_FmPcdCcNode *p_CcNode, t_FmPcdStatsObj *p_StatsObj)
13281 +{
13282 + t_Handle h_FmMuram;
13283 +
13284 + ASSERT_COND(p_CcNode);
13285 + ASSERT_COND(p_StatsObj);
13286 +
13287 + /* If 'maxNumOfKeys' was passed, all statistics object were preallocated
13288 + upon node initialization and now will be enqueued back to the list */
13289 + if (p_CcNode->maxNumOfKeys)
13290 + {
13291 + /* Nullify counters */
13292 + MemSet8(p_StatsObj->h_StatsCounters, 0, p_CcNode->countersArraySize);
13293 +
13294 + EnqueueStatsObj(&p_CcNode->availableStatsLst, p_StatsObj);
13295 + }
13296 + else
13297 + {
13298 + h_FmMuram = ((t_FmPcd *)(p_CcNode->h_FmPcd))->h_FmMuram;
13299 + ASSERT_COND(h_FmMuram);
13300 +
13301 + FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsAd);
13302 + FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsCounters);
13303 +
13304 + XX_Free(p_StatsObj);
13305 + }
13306 +}
13307 +
13308 +static void SetStatsCounters(t_AdOfTypeStats *p_StatsAd,
13309 + uint32_t statsCountersAddr)
13310 +{
13311 + uint32_t tmp = (statsCountersAddr & FM_PCD_AD_STATS_COUNTERS_ADDR_MASK);
13312 +
13313 + WRITE_UINT32(p_StatsAd->statsTableAddr, tmp);
13314 +}
13315 +
13316 +
13317 +static void UpdateStatsAd(t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,
13318 + t_Handle h_Ad, uint64_t physicalMuramBase)
13319 +{
13320 + t_AdOfTypeStats *p_StatsAd;
13321 + uint32_t statsCountersAddr, nextActionAddr, tmp;
13322 +#if (DPAA_VERSION >= 11)
13323 + uint32_t frameLengthRangesAddr;
13324 +#endif /* (DPAA_VERSION >= 11) */
13325 +
13326 + p_StatsAd = (t_AdOfTypeStats *)p_FmPcdCcStatsParams->h_StatsAd;
13327 +
13328 + tmp = FM_PCD_AD_STATS_TYPE;
13329 +
13330 +#if (DPAA_VERSION >= 11)
13331 + if (p_FmPcdCcStatsParams->h_StatsFLRs)
13332 + {
13333 + frameLengthRangesAddr = (uint32_t)((XX_VirtToPhys(
13334 + p_FmPcdCcStatsParams->h_StatsFLRs) - physicalMuramBase));
13335 + tmp |= (frameLengthRangesAddr & FM_PCD_AD_STATS_FLR_ADDR_MASK);
13336 + }
13337 +#endif /* (DPAA_VERSION >= 11) */
13338 + WRITE_UINT32(p_StatsAd->profileTableAddr, tmp);
13339 +
13340 + nextActionAddr = (uint32_t)((XX_VirtToPhys(h_Ad) - physicalMuramBase));
13341 + tmp = 0;
13342 + tmp |= (uint32_t)((nextActionAddr << FM_PCD_AD_STATS_NEXT_ACTION_SHIFT)
13343 + & FM_PCD_AD_STATS_NEXT_ACTION_MASK);
13344 + tmp |= (FM_PCD_AD_STATS_NAD_EN | FM_PCD_AD_STATS_OP_CODE);
13345 +
13346 +#if (DPAA_VERSION >= 11)
13347 + if (p_FmPcdCcStatsParams->h_StatsFLRs)
13348 + tmp |= FM_PCD_AD_STATS_FLR_EN;
13349 +#endif /* (DPAA_VERSION >= 11) */
13350 +
13351 + WRITE_UINT32(p_StatsAd->nextActionIndx, tmp);
13352 +
13353 + statsCountersAddr = (uint32_t)((XX_VirtToPhys(
13354 + p_FmPcdCcStatsParams->h_StatsCounters) - physicalMuramBase));
13355 + SetStatsCounters(p_StatsAd, statsCountersAddr);
13356 +}
13357 +
13358 +static void FillAdOfTypeContLookup(t_Handle h_Ad,
13359 + t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,
13360 + t_Handle h_FmPcd, t_Handle p_CcNode,
13361 + t_Handle h_Manip, t_Handle h_FrmReplic)
13362 +{
13363 + t_FmPcdCcNode *p_Node = (t_FmPcdCcNode *)p_CcNode;
13364 + t_AdOfTypeContLookup *p_AdContLookup = (t_AdOfTypeContLookup *)h_Ad;
13365 + t_Handle h_TmpAd;
13366 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
13367 + uint32_t tmpReg32;
13368 + t_Handle p_AdNewPtr = NULL;
13369 +
13370 + UNUSED(h_Manip);
13371 + UNUSED(h_FrmReplic);
13372 +
13373 + /* there are 3 cases handled in this routine of building a "Continue lookup" type AD.
13374 + * Case 1: No Manip. The action descriptor is built within the match table.
13375 + * p_AdResult = p_AdNewPtr;
13376 + * Case 2: Manip exists. A new AD is created - p_AdNewPtr. It is initialized
13377 + * either in the FmPcdManipUpdateAdResultForCc routine or it was already
13378 + * initialized and returned here.
13379 + * p_AdResult (within the match table) will be initialized after
13380 + * this routine returns and point to the existing AD.
13381 + * Case 3: Manip exists. The action descriptor is built within the match table.
13382 + * FmPcdManipUpdateAdContLookupForCc returns a NULL p_AdNewPtr.
13383 + */
13384 +
13385 + /* As default, the "new" ptr is the current one. i.e. the content of the result
13386 + * AD will be written into the match table itself (case (1))*/
13387 + p_AdNewPtr = p_AdContLookup;
13388 +
13389 + /* Initialize an action descriptor, if current statistics mode requires an Ad */
13390 + if (p_FmPcdCcStatsParams)
13391 + {
13392 + ASSERT_COND(p_FmPcdCcStatsParams->h_StatsAd);
13393 + ASSERT_COND(p_FmPcdCcStatsParams->h_StatsCounters);
13394 +
13395 + /* Swapping addresses between statistics Ad and the current lookup AD */
13396 + h_TmpAd = p_FmPcdCcStatsParams->h_StatsAd;
13397 + p_FmPcdCcStatsParams->h_StatsAd = h_Ad;
13398 + h_Ad = h_TmpAd;
13399 +
13400 + p_AdNewPtr = h_Ad;
13401 + p_AdContLookup = h_Ad;
13402 +
13403 + /* Init statistics Ad and connect current lookup AD as 'next action' from statistics Ad */
13404 + UpdateStatsAd(p_FmPcdCcStatsParams, h_Ad, p_FmPcd->physicalMuramBase);
13405 + }
13406 +
13407 +#if DPAA_VERSION >= 11
13408 + if (h_Manip && h_FrmReplic)
13409 + FmPcdManipUpdateAdContLookupForCc(
13410 + h_Manip,
13411 + h_Ad,
13412 + &p_AdNewPtr,
13413 + (uint32_t)((XX_VirtToPhys(
13414 + FrmReplicGroupGetSourceTableDescriptor(h_FrmReplic))
13415 + - p_FmPcd->physicalMuramBase)));
13416 + else
13417 + if (h_FrmReplic)
13418 + FrmReplicGroupUpdateAd(h_FrmReplic, h_Ad, &p_AdNewPtr);
13419 + else
13420 +#endif /* (DPAA_VERSION >= 11) */
13421 + if (h_Manip)
13422 + FmPcdManipUpdateAdContLookupForCc(
13423 + h_Manip,
13424 + h_Ad,
13425 + &p_AdNewPtr,
13426 +
13427 +#ifdef FM_CAPWAP_SUPPORT
13428 + /*no check for opcode of manip - this step can be reached only with capwap_applic_specific*/
13429 + (uint32_t)((XX_VirtToPhys(p_Node->h_AdTable) - p_FmPcd->physicalMuramBase))
13430 +#else /* not FM_CAPWAP_SUPPORT */
13431 + (uint32_t)((XX_VirtToPhys(p_Node->h_Ad)
13432 + - p_FmPcd->physicalMuramBase))
13433 +#endif /* not FM_CAPWAP_SUPPORT */
13434 + );
13435 +
13436 + /* if (p_AdNewPtr = NULL) --> Done. (case (3)) */
13437 + if (p_AdNewPtr)
13438 + {
13439 + /* cases (1) & (2) */
13440 + tmpReg32 = 0;
13441 + tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
13442 + tmpReg32 |=
13443 + p_Node->sizeOfExtraction ? ((p_Node->sizeOfExtraction - 1) << 24) :
13444 + 0;
13445 + tmpReg32 |= (uint32_t)(XX_VirtToPhys(p_Node->h_AdTable)
13446 + - p_FmPcd->physicalMuramBase);
13447 + WRITE_UINT32(p_AdContLookup->ccAdBase, tmpReg32);
13448 +
13449 + tmpReg32 = 0;
13450 + tmpReg32 |= p_Node->numOfKeys << 24;
13451 + tmpReg32 |= (p_Node->lclMask ? FM_PCD_AD_CONT_LOOKUP_LCL_MASK : 0);
13452 + tmpReg32 |=
13453 + p_Node->h_KeysMatchTable ? (uint32_t)(XX_VirtToPhys(
13454 + p_Node->h_KeysMatchTable) - p_FmPcd->physicalMuramBase) :
13455 + 0;
13456 + WRITE_UINT32(p_AdContLookup->matchTblPtr, tmpReg32);
13457 +
13458 + tmpReg32 = 0;
13459 + tmpReg32 |= p_Node->prsArrayOffset << 24;
13460 + tmpReg32 |= p_Node->offset << 16;
13461 + tmpReg32 |= p_Node->parseCode;
13462 + WRITE_UINT32(p_AdContLookup->pcAndOffsets, tmpReg32);
13463 +
13464 + MemCpy8((void*)&p_AdContLookup->gmask, p_Node->p_GlblMask,
13465 + CC_GLBL_MASK_SIZE);
13466 + }
13467 +}
13468 +
13469 +static t_Error AllocAndFillAdForContLookupManip(t_Handle h_CcNode)
13470 +{
13471 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
13472 + uint32_t intFlags;
13473 +
13474 + ASSERT_COND(p_CcNode);
13475 +
13476 + intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);
13477 +
13478 + if (!p_CcNode->h_Ad)
13479 + {
13480 + if (p_CcNode->maxNumOfKeys)
13481 + p_CcNode->h_Ad = p_CcNode->h_TmpAd;
13482 + else
13483 + p_CcNode->h_Ad = (t_Handle)FM_MURAM_AllocMem(
13484 + ((t_FmPcd *)(p_CcNode->h_FmPcd))->h_FmMuram,
13485 + FM_PCD_CC_AD_ENTRY_SIZE, FM_PCD_CC_AD_TABLE_ALIGN);
13486 +
13487 + XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
13488 +
13489 + if (!p_CcNode->h_Ad)
13490 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
13491 + ("MURAM allocation for CC action descriptor"));
13492 +
13493 + MemSet8(p_CcNode->h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
13494 +
13495 + FillAdOfTypeContLookup(p_CcNode->h_Ad, NULL, p_CcNode->h_FmPcd,
13496 + p_CcNode, NULL, NULL);
13497 + }
13498 + else
13499 + XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
13500 +
13501 + return E_OK;
13502 +}
13503 +
13504 +static t_Error SetRequiredAction1(
13505 + t_Handle h_FmPcd, uint32_t requiredAction,
13506 + t_FmPcdCcKeyAndNextEngineParams *p_CcKeyAndNextEngineParamsTmp,
13507 + t_Handle h_AdTmp, uint16_t numOfEntries, t_Handle h_Tree)
13508 +{
13509 + t_AdOfTypeResult *p_AdTmp = (t_AdOfTypeResult *)h_AdTmp;
13510 + uint32_t tmpReg32;
13511 + t_Error err;
13512 + t_FmPcdCcNode *p_CcNode;
13513 + int i = 0;
13514 + uint16_t tmp = 0;
13515 + uint16_t profileId;
13516 + uint8_t relativeSchemeId, physicalSchemeId;
13517 + t_CcNodeInformation ccNodeInfo;
13518 +
13519 + for (i = 0; i < numOfEntries; i++)
13520 + {
13521 + if (i == 0)
13522 + h_AdTmp = PTR_MOVE(h_AdTmp, i*FM_PCD_CC_AD_ENTRY_SIZE);
13523 + else
13524 + h_AdTmp = PTR_MOVE(h_AdTmp, FM_PCD_CC_AD_ENTRY_SIZE);
13525 +
13526 + switch (p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.nextEngine)
13527 + {
13528 + case (e_FM_PCD_CC):
13529 + if (requiredAction)
13530 + {
13531 + p_CcNode =
13532 + p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.ccParams.h_CcNode;
13533 + ASSERT_COND(p_CcNode);
13534 + if (p_CcNode->shadowAction == requiredAction)
13535 + break;
13536 + if ((requiredAction & UPDATE_CC_WITH_TREE)
13537 + && !(p_CcNode->shadowAction & UPDATE_CC_WITH_TREE))
13538 + {
13539 +
13540 + memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
13541 + ccNodeInfo.h_CcNode = h_Tree;
13542 + EnqueueNodeInfoToRelevantLst(&p_CcNode->ccTreesLst,
13543 + &ccNodeInfo, NULL);
13544 + p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=
13545 + UPDATE_CC_WITH_TREE;
13546 + }
13547 + if ((requiredAction & UPDATE_CC_SHADOW_CLEAR)
13548 + && !(p_CcNode->shadowAction & UPDATE_CC_SHADOW_CLEAR))
13549 + {
13550 +
13551 + p_CcNode->shadowAction = 0;
13552 + }
13553 +
13554 + if ((requiredAction & UPDATE_CC_WITH_DELETE_TREE)
13555 + && !(p_CcNode->shadowAction
13556 + & UPDATE_CC_WITH_DELETE_TREE))
13557 + {
13558 + DequeueNodeInfoFromRelevantLst(&p_CcNode->ccTreesLst,
13559 + h_Tree, NULL);
13560 + p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=
13561 + UPDATE_CC_WITH_DELETE_TREE;
13562 + }
13563 + if (p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.nextEngine
13564 + != e_FM_PCD_INVALID)
13565 + tmp = (uint8_t)(p_CcNode->numOfKeys + 1);
13566 + else
13567 + tmp = p_CcNode->numOfKeys;
13568 + err = SetRequiredAction1(h_FmPcd, requiredAction,
13569 + p_CcNode->keyAndNextEngineParams,
13570 + p_CcNode->h_AdTable, tmp, h_Tree);
13571 + if (err != E_OK)
13572 + return err;
13573 + if (requiredAction != UPDATE_CC_SHADOW_CLEAR)
13574 + p_CcNode->shadowAction |= requiredAction;
13575 + }
13576 + break;
13577 +
13578 + case (e_FM_PCD_KG):
13579 + if ((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
13580 + && !(p_CcKeyAndNextEngineParamsTmp[i].shadowAction
13581 + & UPDATE_NIA_ENQ_WITHOUT_DMA))
13582 + {
13583 + physicalSchemeId =
13584 + FmPcdKgGetSchemeId(
13585 + p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.kgParams.h_DirectScheme);
13586 + relativeSchemeId = FmPcdKgGetRelativeSchemeId(
13587 + h_FmPcd, physicalSchemeId);
13588 + if (relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
13589 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
13590 + if (!FmPcdKgIsSchemeValidSw(
13591 + p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.kgParams.h_DirectScheme))
13592 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
13593 + ("Invalid direct scheme."));
13594 + if (!KgIsSchemeAlwaysDirect(h_FmPcd, relativeSchemeId))
13595 + RETURN_ERROR(
13596 + MAJOR, E_INVALID_STATE,
13597 + ("For this action scheme has to be direct."));
13598 + err =
13599 + FmPcdKgCcGetSetParams(
13600 + h_FmPcd,
13601 + p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.kgParams.h_DirectScheme,
13602 + requiredAction, 0);
13603 + if (err != E_OK)
13604 + RETURN_ERROR(MAJOR, err, NO_MSG);
13605 + p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=
13606 + requiredAction;
13607 + }
13608 + break;
13609 +
13610 + case (e_FM_PCD_PLCR):
13611 + if ((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
13612 + && !(p_CcKeyAndNextEngineParamsTmp[i].shadowAction
13613 + & UPDATE_NIA_ENQ_WITHOUT_DMA))
13614 + {
13615 + if (!p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.plcrParams.overrideParams)
13616 + RETURN_ERROR(
13617 + MAJOR,
13618 + E_NOT_SUPPORTED,
13619 + ("In this initialization only overrideFqid can be initialized"));
13620 + if (!p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.plcrParams.sharedProfile)
13621 + RETURN_ERROR(
13622 + MAJOR,
13623 + E_NOT_SUPPORTED,
13624 + ("In this initialization only overrideFqid can be initialized"));
13625 + err =
13626 + FmPcdPlcrGetAbsoluteIdByProfileParams(
13627 + h_FmPcd,
13628 + e_FM_PCD_PLCR_SHARED,
13629 + NULL,
13630 + p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.plcrParams.newRelativeProfileId,
13631 + &profileId);
13632 + if (err != E_OK)
13633 + RETURN_ERROR(MAJOR, err, NO_MSG);
13634 + err = FmPcdPlcrCcGetSetParams(h_FmPcd, profileId,
13635 + requiredAction);
13636 + if (err != E_OK)
13637 + RETURN_ERROR(MAJOR, err, NO_MSG);
13638 + p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=
13639 + requiredAction;
13640 + }
13641 + break;
13642 +
13643 + case (e_FM_PCD_DONE):
13644 + if ((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
13645 + && !(p_CcKeyAndNextEngineParamsTmp[i].shadowAction
13646 + & UPDATE_NIA_ENQ_WITHOUT_DMA))
13647 + {
13648 + tmpReg32 = GET_UINT32(p_AdTmp->nia);
13649 + if ((tmpReg32 & GET_NIA_BMI_AC_ENQ_FRAME(h_FmPcd))
13650 + != GET_NIA_BMI_AC_ENQ_FRAME(h_FmPcd))
13651 + RETURN_ERROR(
13652 + MAJOR,
13653 + E_INVALID_STATE,
13654 + ("Next engine was previously assigned not as PCD_DONE"));
13655 + tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
13656 + WRITE_UINT32(p_AdTmp->nia, tmpReg32);
13657 + p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=
13658 + requiredAction;
13659 + }
13660 + break;
13661 +
13662 + default:
13663 + break;
13664 + }
13665 + }
13666 +
13667 + return E_OK;
13668 +}
13669 +
13670 +static t_Error SetRequiredAction(
13671 + t_Handle h_FmPcd, uint32_t requiredAction,
13672 + t_FmPcdCcKeyAndNextEngineParams *p_CcKeyAndNextEngineParamsTmp,
13673 + t_Handle h_AdTmp, uint16_t numOfEntries, t_Handle h_Tree)
13674 +{
13675 + t_Error err = SetRequiredAction1(h_FmPcd, requiredAction,
13676 + p_CcKeyAndNextEngineParamsTmp, h_AdTmp,
13677 + numOfEntries, h_Tree);
13678 + if (err != E_OK)
13679 + return err;
13680 + return SetRequiredAction1(h_FmPcd, UPDATE_CC_SHADOW_CLEAR,
13681 + p_CcKeyAndNextEngineParamsTmp, h_AdTmp,
13682 + numOfEntries, h_Tree);
13683 +}
13684 +
13685 +static t_Error ReleaseModifiedDataStructure(
13686 + t_Handle h_FmPcd, t_List *h_FmPcdOldPointersLst,
13687 + t_List *h_FmPcdNewPointersLst,
13688 + t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalParams,
13689 + bool useShadowStructs)
13690 +{
13691 + t_List *p_Pos;
13692 + t_Error err = E_OK;
13693 + t_CcNodeInformation ccNodeInfo, *p_CcNodeInformation;
13694 + t_Handle h_Muram;
13695 + t_FmPcdCcNode *p_FmPcdCcNextNode, *p_FmPcdCcWorkingOnNode;
13696 + t_List *p_UpdateLst;
13697 + uint32_t intFlags;
13698 +
13699 + SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
13700 + SANITY_CHECK_RETURN_ERROR(p_AdditionalParams->h_CurrentNode,
13701 + E_INVALID_HANDLE);
13702 + SANITY_CHECK_RETURN_ERROR(h_FmPcdOldPointersLst, E_INVALID_HANDLE);
13703 + SANITY_CHECK_RETURN_ERROR(h_FmPcdNewPointersLst, E_INVALID_HANDLE);
13704 +
13705 + /* We don't update subtree of the new node with new tree because it was done in the previous stage */
13706 + if (p_AdditionalParams->h_NodeForAdd)
13707 + {
13708 + p_FmPcdCcNextNode = (t_FmPcdCcNode*)p_AdditionalParams->h_NodeForAdd;
13709 +
13710 + if (!p_AdditionalParams->tree)
13711 + p_UpdateLst = &p_FmPcdCcNextNode->ccPrevNodesLst;
13712 + else
13713 + p_UpdateLst = &p_FmPcdCcNextNode->ccTreeIdLst;
13714 +
13715 + p_CcNodeInformation = FindNodeInfoInReleventLst(
13716 + p_UpdateLst, p_AdditionalParams->h_CurrentNode,
13717 + p_FmPcdCcNextNode->h_Spinlock);
13718 +
13719 + if (p_CcNodeInformation)
13720 + p_CcNodeInformation->index++;
13721 + else
13722 + {
13723 + memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
13724 + ccNodeInfo.h_CcNode = (t_Handle)p_AdditionalParams->h_CurrentNode;
13725 + ccNodeInfo.index = 1;
13726 + EnqueueNodeInfoToRelevantLst(p_UpdateLst, &ccNodeInfo,
13727 + p_FmPcdCcNextNode->h_Spinlock);
13728 + }
13729 + if (p_AdditionalParams->h_ManipForAdd)
13730 + {
13731 + p_CcNodeInformation = FindNodeInfoInReleventLst(
13732 + FmPcdManipGetNodeLstPointedOnThisManip(
13733 + p_AdditionalParams->h_ManipForAdd),
13734 + p_AdditionalParams->h_CurrentNode,
13735 + FmPcdManipGetSpinlock(p_AdditionalParams->h_ManipForAdd));
13736 +
13737 + if (p_CcNodeInformation)
13738 + p_CcNodeInformation->index++;
13739 + else
13740 + {
13741 + memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
13742 + ccNodeInfo.h_CcNode =
13743 + (t_Handle)p_AdditionalParams->h_CurrentNode;
13744 + ccNodeInfo.index = 1;
13745 + EnqueueNodeInfoToRelevantLst(
13746 + FmPcdManipGetNodeLstPointedOnThisManip(
13747 + p_AdditionalParams->h_ManipForAdd),
13748 + &ccNodeInfo,
13749 + FmPcdManipGetSpinlock(
13750 + p_AdditionalParams->h_ManipForAdd));
13751 + }
13752 + }
13753 + }
13754 +
13755 + if (p_AdditionalParams->h_NodeForRmv)
13756 + {
13757 + p_FmPcdCcNextNode = (t_FmPcdCcNode*)p_AdditionalParams->h_NodeForRmv;
13758 +
13759 + if (!p_AdditionalParams->tree)
13760 + {
13761 + p_UpdateLst = &p_FmPcdCcNextNode->ccPrevNodesLst;
13762 + p_FmPcdCcWorkingOnNode =
13763 + (t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode);
13764 +
13765 + for (p_Pos = LIST_FIRST(&p_FmPcdCcWorkingOnNode->ccTreesLst);
13766 + p_Pos != (&p_FmPcdCcWorkingOnNode->ccTreesLst); p_Pos =
13767 + LIST_NEXT(p_Pos))
13768 + {
13769 + p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
13770 +
13771 + ASSERT_COND(p_CcNodeInformation->h_CcNode);
13772 +
13773 + err =
13774 + SetRequiredAction(
13775 + h_FmPcd,
13776 + UPDATE_CC_WITH_DELETE_TREE,
13777 + &((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->keyAndNextEngineParams[p_AdditionalParams->savedKeyIndex],
13778 + PTR_MOVE(((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_AdTable, p_AdditionalParams->savedKeyIndex*FM_PCD_CC_AD_ENTRY_SIZE),
13779 + 1, p_CcNodeInformation->h_CcNode);
13780 + }
13781 + }
13782 + else
13783 + {
13784 + p_UpdateLst = &p_FmPcdCcNextNode->ccTreeIdLst;
13785 +
13786 + err =
13787 + SetRequiredAction(
13788 + h_FmPcd,
13789 + UPDATE_CC_WITH_DELETE_TREE,
13790 + &((t_FmPcdCcTree *)(p_AdditionalParams->h_CurrentNode))->keyAndNextEngineParams[p_AdditionalParams->savedKeyIndex],
13791 + UINT_TO_PTR(((t_FmPcdCcTree *)(p_AdditionalParams->h_CurrentNode))->ccTreeBaseAddr + p_AdditionalParams->savedKeyIndex*FM_PCD_CC_AD_ENTRY_SIZE),
13792 + 1, p_AdditionalParams->h_CurrentNode);
13793 + }
13794 + if (err)
13795 + return err;
13796 +
13797 + /* We remove from the subtree of the removed node tree because it wasn't done in the previous stage
13798 + Update ccPrevNodesLst or ccTreeIdLst of the removed node
13799 + Update of the node owner */
13800 + p_CcNodeInformation = FindNodeInfoInReleventLst(
13801 + p_UpdateLst, p_AdditionalParams->h_CurrentNode,
13802 + p_FmPcdCcNextNode->h_Spinlock);
13803 +
13804 + ASSERT_COND(p_CcNodeInformation);
13805 + ASSERT_COND(p_CcNodeInformation->index);
13806 +
13807 + p_CcNodeInformation->index--;
13808 +
13809 + if (p_CcNodeInformation->index == 0)
13810 + DequeueNodeInfoFromRelevantLst(p_UpdateLst,
13811 + p_AdditionalParams->h_CurrentNode,
13812 + p_FmPcdCcNextNode->h_Spinlock);
13813 +
13814 + UpdateNodeOwner(p_FmPcdCcNextNode, FALSE);
13815 +
13816 + if (p_AdditionalParams->h_ManipForRmv)
13817 + {
13818 + p_CcNodeInformation = FindNodeInfoInReleventLst(
13819 + FmPcdManipGetNodeLstPointedOnThisManip(
13820 + p_AdditionalParams->h_ManipForRmv),
13821 + p_AdditionalParams->h_CurrentNode,
13822 + FmPcdManipGetSpinlock(p_AdditionalParams->h_ManipForRmv));
13823 +
13824 + ASSERT_COND(p_CcNodeInformation);
13825 + ASSERT_COND(p_CcNodeInformation->index);
13826 +
13827 + p_CcNodeInformation->index--;
13828 +
13829 + if (p_CcNodeInformation->index == 0)
13830 + DequeueNodeInfoFromRelevantLst(
13831 + FmPcdManipGetNodeLstPointedOnThisManip(
13832 + p_AdditionalParams->h_ManipForRmv),
13833 + p_AdditionalParams->h_CurrentNode,
13834 + FmPcdManipGetSpinlock(
13835 + p_AdditionalParams->h_ManipForRmv));
13836 + }
13837 + }
13838 +
13839 + if (p_AdditionalParams->h_ManipForRmv)
13840 + FmPcdManipUpdateOwner(p_AdditionalParams->h_ManipForRmv, FALSE);
13841 +
13842 + if (p_AdditionalParams->p_StatsObjForRmv)
13843 + PutStatsObj((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode),
13844 + p_AdditionalParams->p_StatsObjForRmv);
13845 +
13846 +#if (DPAA_VERSION >= 11)
13847 + if (p_AdditionalParams->h_FrmReplicForRmv)
13848 + FrmReplicGroupUpdateOwner(p_AdditionalParams->h_FrmReplicForRmv,
13849 + FALSE/* remove */);
13850 +#endif /* (DPAA_VERSION >= 11) */
13851 +
13852 + if (!useShadowStructs)
13853 + {
13854 + h_Muram = FmPcdGetMuramHandle(h_FmPcd);
13855 + ASSERT_COND(h_Muram);
13856 +
13857 + if ((p_AdditionalParams->tree && !((t_FmPcd *)h_FmPcd)->p_CcShadow)
13858 + || (!p_AdditionalParams->tree
13859 + && !((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->maxNumOfKeys))
13860 + {
13861 + /* We release new AD which was allocated and updated for copy from to actual AD */
13862 + for (p_Pos = LIST_FIRST(h_FmPcdNewPointersLst);
13863 + p_Pos != (h_FmPcdNewPointersLst); p_Pos = LIST_NEXT(p_Pos))
13864 + {
13865 +
13866 + p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
13867 + ASSERT_COND(p_CcNodeInformation->h_CcNode);
13868 + FM_MURAM_FreeMem(h_Muram, p_CcNodeInformation->h_CcNode);
13869 + }
13870 + }
13871 +
13872 + /* Free Old data structure if it has to be freed - new data structure was allocated*/
13873 + if (p_AdditionalParams->p_AdTableOld)
13874 + FM_MURAM_FreeMem(h_Muram, p_AdditionalParams->p_AdTableOld);
13875 +
13876 + if (p_AdditionalParams->p_KeysMatchTableOld)
13877 + FM_MURAM_FreeMem(h_Muram, p_AdditionalParams->p_KeysMatchTableOld);
13878 + }
13879 +
13880 + /* Update current modified node with changed fields if it's required*/
13881 + if (!p_AdditionalParams->tree)
13882 + {
13883 + if (p_AdditionalParams->p_AdTableNew)
13884 + ((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_AdTable =
13885 + p_AdditionalParams->p_AdTableNew;
13886 +
13887 + if (p_AdditionalParams->p_KeysMatchTableNew)
13888 + ((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_KeysMatchTable =
13889 + p_AdditionalParams->p_KeysMatchTableNew;
13890 +
13891 + /* Locking node's spinlock before updating 'keys and next engine' structure,
13892 + as it maybe used to retrieve keys statistics */
13893 + intFlags =
13894 + XX_LockIntrSpinlock(
13895 + ((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_Spinlock);
13896 +
13897 + ((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->numOfKeys =
13898 + p_AdditionalParams->numOfKeys;
13899 +
13900 + memcpy(((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->keyAndNextEngineParams,
13901 + &p_AdditionalParams->keyAndNextEngineParams,
13902 + sizeof(t_FmPcdCcKeyAndNextEngineParams) * (CC_MAX_NUM_OF_KEYS));
13903 +
13904 + XX_UnlockIntrSpinlock(
13905 + ((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_Spinlock,
13906 + intFlags);
13907 + }
13908 + else
13909 + {
13910 + uint8_t numEntries =
13911 + ((t_FmPcdCcTree *)(p_AdditionalParams->h_CurrentNode))->numOfEntries;
13912 + ASSERT_COND(numEntries < FM_PCD_MAX_NUM_OF_CC_GROUPS);
13913 + memcpy(&((t_FmPcdCcTree *)(p_AdditionalParams->h_CurrentNode))->keyAndNextEngineParams,
13914 + &p_AdditionalParams->keyAndNextEngineParams,
13915 + sizeof(t_FmPcdCcKeyAndNextEngineParams) * numEntries);
13916 + }
13917 +
13918 + ReleaseLst(h_FmPcdOldPointersLst);
13919 + ReleaseLst(h_FmPcdNewPointersLst);
13920 +
13921 + XX_Free(p_AdditionalParams);
13922 +
13923 + return E_OK;
13924 +}
13925 +
13926 +static t_Handle BuildNewAd(
13927 + t_Handle h_Ad,
13928 + t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams,
13929 + t_FmPcdCcNode *p_CcNode,
13930 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
13931 +{
13932 + t_FmPcdCcNode *p_FmPcdCcNodeTmp;
13933 + t_Handle h_OrigAd = NULL;
13934 +
13935 + p_FmPcdCcNodeTmp = (t_FmPcdCcNode*)XX_Malloc(sizeof(t_FmPcdCcNode));
13936 + if (!p_FmPcdCcNodeTmp)
13937 + {
13938 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_FmPcdCcNodeTmp"));
13939 + return NULL;
13940 + }
13941 + memset(p_FmPcdCcNodeTmp, 0, sizeof(t_FmPcdCcNode));
13942 +
13943 + p_FmPcdCcNodeTmp->numOfKeys = p_FmPcdModifyCcKeyAdditionalParams->numOfKeys;
13944 + p_FmPcdCcNodeTmp->h_KeysMatchTable =
13945 + p_FmPcdModifyCcKeyAdditionalParams->p_KeysMatchTableNew;
13946 + p_FmPcdCcNodeTmp->h_AdTable =
13947 + p_FmPcdModifyCcKeyAdditionalParams->p_AdTableNew;
13948 +
13949 + p_FmPcdCcNodeTmp->lclMask = p_CcNode->lclMask;
13950 + p_FmPcdCcNodeTmp->parseCode = p_CcNode->parseCode;
13951 + p_FmPcdCcNodeTmp->offset = p_CcNode->offset;
13952 + p_FmPcdCcNodeTmp->prsArrayOffset = p_CcNode->prsArrayOffset;
13953 + p_FmPcdCcNodeTmp->ctrlFlow = p_CcNode->ctrlFlow;
13954 + p_FmPcdCcNodeTmp->ccKeySizeAccExtraction = p_CcNode->ccKeySizeAccExtraction;
13955 + p_FmPcdCcNodeTmp->sizeOfExtraction = p_CcNode->sizeOfExtraction;
13956 + p_FmPcdCcNodeTmp->glblMaskSize = p_CcNode->glblMaskSize;
13957 + p_FmPcdCcNodeTmp->p_GlblMask = p_CcNode->p_GlblMask;
13958 +
13959 + if (p_FmPcdCcNextEngineParams->nextEngine == e_FM_PCD_CC)
13960 + {
13961 + if (p_FmPcdCcNextEngineParams->h_Manip)
13962 + {
13963 + h_OrigAd = p_CcNode->h_Ad;
13964 + if (AllocAndFillAdForContLookupManip(
13965 + p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode)
13966 + != E_OK)
13967 + {
13968 + REPORT_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
13969 + XX_Free(p_FmPcdCcNodeTmp);
13970 + return NULL;
13971 + }
13972 + }
13973 + FillAdOfTypeContLookup(h_Ad, NULL, p_CcNode->h_FmPcd, p_FmPcdCcNodeTmp,
13974 + h_OrigAd ? NULL : p_FmPcdCcNextEngineParams->h_Manip, NULL);
13975 + }
13976 +
13977 +#if (DPAA_VERSION >= 11)
13978 + if ((p_FmPcdCcNextEngineParams->nextEngine == e_FM_PCD_FR)
13979 + && (p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic))
13980 + {
13981 + FillAdOfTypeContLookup(
13982 + h_Ad, NULL, p_CcNode->h_FmPcd, p_FmPcdCcNodeTmp,
13983 + p_FmPcdCcNextEngineParams->h_Manip,
13984 + p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic);
13985 + }
13986 +#endif /* (DPAA_VERSION >= 11) */
13987 +
13988 + XX_Free(p_FmPcdCcNodeTmp);
13989 +
13990 + return E_OK;
13991 +}
13992 +
13993 +static t_Error DynamicChangeHc(
13994 + t_Handle h_FmPcd, t_List *h_OldPointersLst, t_List *h_NewPointersLst,
13995 + t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalParams,
13996 + bool useShadowStructs)
13997 +{
13998 + t_List *p_PosOld, *p_PosNew;
13999 + uint32_t oldAdAddrOffset, newAdAddrOffset;
14000 + uint16_t i = 0;
14001 + t_Error err = E_OK;
14002 + uint8_t numOfModifiedPtr;
14003 +
14004 + ASSERT_COND(h_FmPcd);
14005 + ASSERT_COND(h_OldPointersLst);
14006 + ASSERT_COND(h_NewPointersLst);
14007 +
14008 + numOfModifiedPtr = (uint8_t)LIST_NumOfObjs(h_OldPointersLst);
14009 +
14010 + if (numOfModifiedPtr)
14011 + {
14012 + p_PosNew = LIST_FIRST(h_NewPointersLst);
14013 + p_PosOld = LIST_FIRST(h_OldPointersLst);
14014 +
14015 + /* Retrieve address of new AD */
14016 + newAdAddrOffset = FmPcdCcGetNodeAddrOffsetFromNodeInfo(h_FmPcd,
14017 + p_PosNew);
14018 + if (newAdAddrOffset == (uint32_t)ILLEGAL_BASE)
14019 + {
14020 + ReleaseModifiedDataStructure(h_FmPcd, h_OldPointersLst,
14021 + h_NewPointersLst,
14022 + p_AdditionalParams, useShadowStructs);
14023 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("New AD address"));
14024 + }
14025 +
14026 + for (i = 0; i < numOfModifiedPtr; i++)
14027 + {
14028 + /* Retrieve address of current AD */
14029 + oldAdAddrOffset = FmPcdCcGetNodeAddrOffsetFromNodeInfo(h_FmPcd,
14030 + p_PosOld);
14031 + if (oldAdAddrOffset == (uint32_t)ILLEGAL_BASE)
14032 + {
14033 + ReleaseModifiedDataStructure(h_FmPcd, h_OldPointersLst,
14034 + h_NewPointersLst,
14035 + p_AdditionalParams,
14036 + useShadowStructs);
14037 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Old AD address"));
14038 + }
14039 +
14040 + /* Invoke host command to copy from new AD to old AD */
14041 + err = FmHcPcdCcDoDynamicChange(((t_FmPcd *)h_FmPcd)->h_Hc,
14042 + oldAdAddrOffset, newAdAddrOffset);
14043 + if (err)
14044 + {
14045 + ReleaseModifiedDataStructure(h_FmPcd, h_OldPointersLst,
14046 + h_NewPointersLst,
14047 + p_AdditionalParams,
14048 + useShadowStructs);
14049 + RETURN_ERROR(
14050 + MAJOR,
14051 + err,
14052 + ("For part of nodes changes are done - situation is danger"));
14053 + }
14054 +
14055 + p_PosOld = LIST_NEXT(p_PosOld);
14056 + }
14057 + }
14058 + return E_OK;
14059 +}
14060 +
14061 +static t_Error DoDynamicChange(
14062 + t_Handle h_FmPcd, t_List *h_OldPointersLst, t_List *h_NewPointersLst,
14063 + t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalParams,
14064 + bool useShadowStructs)
14065 +{
14066 + t_FmPcdCcNode *p_CcNode =
14067 + (t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode);
14068 + t_List *p_PosNew;
14069 + t_CcNodeInformation *p_CcNodeInfo;
14070 + t_FmPcdCcNextEngineParams nextEngineParams;
14071 + t_Handle h_Ad;
14072 + uint32_t keySize;
14073 + t_Error err = E_OK;
14074 + uint8_t numOfModifiedPtr;
14075 +
14076 + ASSERT_COND(h_FmPcd);
14077 +
14078 + memset(&nextEngineParams, 0, sizeof(t_FmPcdCcNextEngineParams));
14079 +
14080 + numOfModifiedPtr = (uint8_t)LIST_NumOfObjs(h_OldPointersLst);
14081 +
14082 + if (numOfModifiedPtr)
14083 + {
14084 +
14085 + p_PosNew = LIST_FIRST(h_NewPointersLst);
14086 +
14087 + /* Invoke host-command to copy from the new Ad to existing Ads */
14088 + err = DynamicChangeHc(h_FmPcd, h_OldPointersLst, h_NewPointersLst,
14089 + p_AdditionalParams, useShadowStructs);
14090 + if (err)
14091 + RETURN_ERROR(MAJOR, err, NO_MSG);
14092 +
14093 + if (useShadowStructs)
14094 + {
14095 + /* When the host-command above has ended, the old structures are 'free'and we can update
14096 + them by copying from the new shadow structures. */
14097 + if (p_CcNode->lclMask)
14098 + keySize = (uint32_t)(2 * p_CcNode->ccKeySizeAccExtraction);
14099 + else
14100 + keySize = p_CcNode->ccKeySizeAccExtraction;
14101 +
14102 + MemCpy8(p_AdditionalParams->p_KeysMatchTableOld,
14103 + p_AdditionalParams->p_KeysMatchTableNew,
14104 + p_CcNode->maxNumOfKeys * keySize * sizeof(uint8_t));
14105 +
14106 + MemCpy8(
14107 + p_AdditionalParams->p_AdTableOld,
14108 + p_AdditionalParams->p_AdTableNew,
14109 + (uint32_t)((p_CcNode->maxNumOfKeys + 1)
14110 + * FM_PCD_CC_AD_ENTRY_SIZE));
14111 +
14112 + /* Retrieve the address of the allocated Ad */
14113 + p_CcNodeInfo = CC_NODE_F_OBJECT(p_PosNew);
14114 + h_Ad = p_CcNodeInfo->h_CcNode;
14115 +
14116 + /* Build a new Ad that holds the old (now updated) structures */
14117 + p_AdditionalParams->p_KeysMatchTableNew =
14118 + p_AdditionalParams->p_KeysMatchTableOld;
14119 + p_AdditionalParams->p_AdTableNew = p_AdditionalParams->p_AdTableOld;
14120 +
14121 + nextEngineParams.nextEngine = e_FM_PCD_CC;
14122 + nextEngineParams.params.ccParams.h_CcNode = (t_Handle)p_CcNode;
14123 +
14124 + BuildNewAd(h_Ad, p_AdditionalParams, p_CcNode, &nextEngineParams);
14125 +
14126 + /* HC to copy from the new Ad (old updated structures) to current Ad (uses shadow structures) */
14127 + err = DynamicChangeHc(h_FmPcd, h_OldPointersLst, h_NewPointersLst,
14128 + p_AdditionalParams, useShadowStructs);
14129 + if (err)
14130 + RETURN_ERROR(MAJOR, err, NO_MSG);
14131 + }
14132 + }
14133 +
14134 + err = ReleaseModifiedDataStructure(h_FmPcd, h_OldPointersLst,
14135 + h_NewPointersLst,
14136 + p_AdditionalParams, useShadowStructs);
14137 + if (err)
14138 + RETURN_ERROR(MAJOR, err, NO_MSG);
14139 +
14140 + return E_OK;
14141 +}
14142 +
14143 +#ifdef FM_CAPWAP_SUPPORT
14144 +static bool IsCapwapApplSpecific(t_Handle h_Node)
14145 +{
14146 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_Node;
14147 + bool isManipForCapwapApplSpecificBuild = FALSE;
14148 + int i = 0;
14149 +
14150 + ASSERT_COND(h_Node);
14151 + /* assumption that this function called only for INDEXED_FLOW_ID - so no miss*/
14152 + for (i = 0; i < p_CcNode->numOfKeys; i++)
14153 + {
14154 + if ( p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip &&
14155 + FmPcdManipIsCapwapApplSpecific(p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip))
14156 + {
14157 + isManipForCapwapApplSpecificBuild = TRUE;
14158 + break;
14159 + }
14160 + }
14161 + return isManipForCapwapApplSpecificBuild;
14162 +
14163 +}
14164 +#endif /* FM_CAPWAP_SUPPORT */
14165 +
14166 +static t_Error CcUpdateParam(
14167 + t_Handle h_FmPcd, t_Handle h_PcdParams, t_Handle h_FmPort,
14168 + t_FmPcdCcKeyAndNextEngineParams *p_CcKeyAndNextEngineParams,
14169 + uint16_t numOfEntries, t_Handle h_Ad, bool validate, uint16_t level,
14170 + t_Handle h_FmTree, bool modify)
14171 +{
14172 + t_FmPcdCcNode *p_CcNode;
14173 + t_Error err;
14174 + uint16_t tmp = 0;
14175 + int i = 0;
14176 + t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *)h_FmTree;
14177 +
14178 + level++;
14179 +
14180 + if (p_CcTree->h_IpReassemblyManip)
14181 + {
14182 + err = FmPcdManipUpdate(h_FmPcd, h_PcdParams, h_FmPort,
14183 + p_CcTree->h_IpReassemblyManip, NULL, validate,
14184 + level, h_FmTree, modify);
14185 + if (err)
14186 + RETURN_ERROR(MAJOR, err, NO_MSG);
14187 + }
14188 +
14189 + if (p_CcTree->h_CapwapReassemblyManip)
14190 + {
14191 + err = FmPcdManipUpdate(h_FmPcd, h_PcdParams, h_FmPort,
14192 + p_CcTree->h_CapwapReassemblyManip, NULL, validate,
14193 + level, h_FmTree, modify);
14194 + if (err)
14195 + RETURN_ERROR(MAJOR, err, NO_MSG);
14196 + }
14197 +
14198 + if (numOfEntries)
14199 + {
14200 + for (i = 0; i < numOfEntries; i++)
14201 + {
14202 + if (i == 0)
14203 + h_Ad = PTR_MOVE(h_Ad, i*FM_PCD_CC_AD_ENTRY_SIZE);
14204 + else
14205 + h_Ad = PTR_MOVE(h_Ad, FM_PCD_CC_AD_ENTRY_SIZE);
14206 +
14207 + if (p_CcKeyAndNextEngineParams[i].nextEngineParams.nextEngine
14208 + == e_FM_PCD_CC)
14209 + {
14210 + p_CcNode =
14211 + p_CcKeyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode;
14212 + ASSERT_COND(p_CcNode);
14213 +
14214 + if (p_CcKeyAndNextEngineParams[i].nextEngineParams.h_Manip)
14215 + {
14216 + err =
14217 + FmPcdManipUpdate(
14218 + h_FmPcd,
14219 + NULL,
14220 + h_FmPort,
14221 + p_CcKeyAndNextEngineParams[i].nextEngineParams.h_Manip,
14222 + h_Ad, validate, level, h_FmTree, modify);
14223 + if (err)
14224 + RETURN_ERROR(MAJOR, err, NO_MSG);
14225 + }
14226 +
14227 + if (p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.nextEngine
14228 + != e_FM_PCD_INVALID)
14229 + tmp = (uint8_t)(p_CcNode->numOfKeys + 1);
14230 + else
14231 + tmp = p_CcNode->numOfKeys;
14232 +
14233 + err = CcUpdateParam(h_FmPcd, h_PcdParams, h_FmPort,
14234 + p_CcNode->keyAndNextEngineParams, tmp,
14235 + p_CcNode->h_AdTable, validate, level,
14236 + h_FmTree, modify);
14237 + if (err)
14238 + RETURN_ERROR(MAJOR, err, NO_MSG);
14239 + }
14240 + else
14241 + {
14242 + if (p_CcKeyAndNextEngineParams[i].nextEngineParams.h_Manip)
14243 + {
14244 + err =
14245 + FmPcdManipUpdate(
14246 + h_FmPcd,
14247 + NULL,
14248 + h_FmPort,
14249 + p_CcKeyAndNextEngineParams[i].nextEngineParams.h_Manip,
14250 + h_Ad, validate, level, h_FmTree, modify);
14251 + if (err)
14252 + RETURN_ERROR(MAJOR, err, NO_MSG);
14253 + }
14254 + }
14255 + }
14256 + }
14257 +
14258 + return E_OK;
14259 +}
14260 +
14261 +static ccPrivateInfo_t IcDefineCode(t_FmPcdCcNodeParams *p_CcNodeParam)
14262 +{
14263 + switch (p_CcNodeParam->extractCcParams.extractNonHdr.action)
14264 + {
14265 + case (e_FM_PCD_ACTION_EXACT_MATCH):
14266 + switch (p_CcNodeParam->extractCcParams.extractNonHdr.src)
14267 + {
14268 + case (e_FM_PCD_EXTRACT_FROM_KEY):
14269 + return CC_PRIVATE_INFO_IC_KEY_EXACT_MATCH;
14270 + case (e_FM_PCD_EXTRACT_FROM_HASH):
14271 + return CC_PRIVATE_INFO_IC_HASH_EXACT_MATCH;
14272 + default:
14273 + return CC_PRIVATE_INFO_NONE;
14274 + }
14275 +
14276 + case (e_FM_PCD_ACTION_INDEXED_LOOKUP):
14277 + switch (p_CcNodeParam->extractCcParams.extractNonHdr.src)
14278 + {
14279 + case (e_FM_PCD_EXTRACT_FROM_HASH):
14280 + return CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP;
14281 + case (e_FM_PCD_EXTRACT_FROM_FLOW_ID):
14282 + return CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP;
14283 + default:
14284 + return CC_PRIVATE_INFO_NONE;
14285 + }
14286 +
14287 + default:
14288 + break;
14289 + }
14290 +
14291 + return CC_PRIVATE_INFO_NONE;
14292 +}
14293 +
14294 +static t_CcNodeInformation * DequeueAdditionalInfoFromRelevantLst(
14295 + t_List *p_List)
14296 +{
14297 + t_CcNodeInformation *p_CcNodeInfo = NULL;
14298 +
14299 + if (!LIST_IsEmpty(p_List))
14300 + {
14301 + p_CcNodeInfo = CC_NODE_F_OBJECT(p_List->p_Next);
14302 + LIST_DelAndInit(&p_CcNodeInfo->node);
14303 + }
14304 +
14305 + return p_CcNodeInfo;
14306 +}
14307 +
14308 +void ReleaseLst(t_List *p_List)
14309 +{
14310 + t_CcNodeInformation *p_CcNodeInfo = NULL;
14311 +
14312 + if (!LIST_IsEmpty(p_List))
14313 + {
14314 + p_CcNodeInfo = DequeueAdditionalInfoFromRelevantLst(p_List);
14315 + while (p_CcNodeInfo)
14316 + {
14317 + XX_Free(p_CcNodeInfo);
14318 + p_CcNodeInfo = DequeueAdditionalInfoFromRelevantLst(p_List);
14319 + }
14320 + }
14321 +
14322 + LIST_Del(p_List);
14323 +}
14324 +
14325 +static void DeleteNode(t_FmPcdCcNode *p_CcNode)
14326 +{
14327 + uint32_t i;
14328 +
14329 + if (!p_CcNode)
14330 + return;
14331 +
14332 + if (p_CcNode->p_GlblMask)
14333 + {
14334 + XX_Free(p_CcNode->p_GlblMask);
14335 + p_CcNode->p_GlblMask = NULL;
14336 + }
14337 +
14338 + if (p_CcNode->h_KeysMatchTable)
14339 + {
14340 + FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),
14341 + p_CcNode->h_KeysMatchTable);
14342 + p_CcNode->h_KeysMatchTable = NULL;
14343 + }
14344 +
14345 + if (p_CcNode->h_AdTable)
14346 + {
14347 + FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),
14348 + p_CcNode->h_AdTable);
14349 + p_CcNode->h_AdTable = NULL;
14350 + }
14351 +
14352 + if (p_CcNode->h_Ad)
14353 + {
14354 + FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),
14355 + p_CcNode->h_Ad);
14356 + p_CcNode->h_Ad = NULL;
14357 + p_CcNode->h_TmpAd = NULL;
14358 + }
14359 +
14360 + if (p_CcNode->h_StatsFLRs)
14361 + {
14362 + FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),
14363 + p_CcNode->h_StatsFLRs);
14364 + p_CcNode->h_StatsFLRs = NULL;
14365 + }
14366 +
14367 + if (p_CcNode->h_Spinlock)
14368 + {
14369 + XX_FreeSpinlock(p_CcNode->h_Spinlock);
14370 + p_CcNode->h_Spinlock = NULL;
14371 + }
14372 +
14373 + /* Restore the original counters pointer instead of the mutual pointer (mutual to all hash buckets) */
14374 + if (p_CcNode->isHashBucket
14375 + && (p_CcNode->statisticsMode != e_FM_PCD_CC_STATS_MODE_NONE))
14376 + p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].p_StatsObj->h_StatsCounters =
14377 + p_CcNode->h_PrivMissStatsCounters;
14378 +
14379 + /* Releasing all currently used statistics objects, including 'miss' entry */
14380 + for (i = 0; i < p_CcNode->numOfKeys + 1; i++)
14381 + if (p_CcNode->keyAndNextEngineParams[i].p_StatsObj)
14382 + PutStatsObj(p_CcNode,
14383 + p_CcNode->keyAndNextEngineParams[i].p_StatsObj);
14384 +
14385 + if (!LIST_IsEmpty(&p_CcNode->availableStatsLst))
14386 + {
14387 + t_Handle h_FmMuram = FmPcdGetMuramHandle(p_CcNode->h_FmPcd);
14388 + ASSERT_COND(h_FmMuram);
14389 +
14390 + FreeStatObjects(&p_CcNode->availableStatsLst, h_FmMuram);
14391 + }
14392 +
14393 + LIST_Del(&p_CcNode->availableStatsLst);
14394 +
14395 + ReleaseLst(&p_CcNode->ccPrevNodesLst);
14396 + ReleaseLst(&p_CcNode->ccTreeIdLst);
14397 + ReleaseLst(&p_CcNode->ccTreesLst);
14398 +
14399 + XX_Free(p_CcNode);
14400 +}
14401 +
14402 +static void DeleteTree(t_FmPcdCcTree *p_FmPcdTree, t_FmPcd *p_FmPcd)
14403 +{
14404 + if (p_FmPcdTree)
14405 + {
14406 + if (p_FmPcdTree->ccTreeBaseAddr)
14407 + {
14408 + FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_FmPcd),
14409 + UINT_TO_PTR(p_FmPcdTree->ccTreeBaseAddr));
14410 + p_FmPcdTree->ccTreeBaseAddr = 0;
14411 + }
14412 +
14413 + ReleaseLst(&p_FmPcdTree->fmPortsLst);
14414 +
14415 + XX_Free(p_FmPcdTree);
14416 + }
14417 +}
14418 +
14419 +static void GetCcExtractKeySize(uint8_t parseCodeRealSize,
14420 + uint8_t *parseCodeCcSize)
14421 +{
14422 + if ((parseCodeRealSize > 0) && (parseCodeRealSize < 2))
14423 + *parseCodeCcSize = 1;
14424 + else
14425 + if (parseCodeRealSize == 2)
14426 + *parseCodeCcSize = 2;
14427 + else
14428 + if ((parseCodeRealSize > 2) && (parseCodeRealSize <= 4))
14429 + *parseCodeCcSize = 4;
14430 + else
14431 + if ((parseCodeRealSize > 4) && (parseCodeRealSize <= 8))
14432 + *parseCodeCcSize = 8;
14433 + else
14434 + if ((parseCodeRealSize > 8) && (parseCodeRealSize <= 16))
14435 + *parseCodeCcSize = 16;
14436 + else
14437 + if ((parseCodeRealSize > 16)
14438 + && (parseCodeRealSize <= 24))
14439 + *parseCodeCcSize = 24;
14440 + else
14441 + if ((parseCodeRealSize > 24)
14442 + && (parseCodeRealSize <= 32))
14443 + *parseCodeCcSize = 32;
14444 + else
14445 + if ((parseCodeRealSize > 32)
14446 + && (parseCodeRealSize <= 40))
14447 + *parseCodeCcSize = 40;
14448 + else
14449 + if ((parseCodeRealSize > 40)
14450 + && (parseCodeRealSize <= 48))
14451 + *parseCodeCcSize = 48;
14452 + else
14453 + if ((parseCodeRealSize > 48)
14454 + && (parseCodeRealSize <= 56))
14455 + *parseCodeCcSize = 56;
14456 + else
14457 + *parseCodeCcSize = 0;
14458 +}
14459 +
14460 +static void GetSizeHeaderField(e_NetHeaderType hdr, t_FmPcdFields field,
14461 + uint8_t *parseCodeRealSize)
14462 +{
14463 + switch (hdr)
14464 + {
14465 + case (HEADER_TYPE_ETH):
14466 + switch (field.eth)
14467 + {
14468 + case (NET_HEADER_FIELD_ETH_DA):
14469 + *parseCodeRealSize = 6;
14470 + break;
14471 +
14472 + case (NET_HEADER_FIELD_ETH_SA):
14473 + *parseCodeRealSize = 6;
14474 + break;
14475 +
14476 + case (NET_HEADER_FIELD_ETH_TYPE):
14477 + *parseCodeRealSize = 2;
14478 + break;
14479 +
14480 + default:
14481 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported1"));
14482 + *parseCodeRealSize = CC_SIZE_ILLEGAL;
14483 + break;
14484 + }
14485 + break;
14486 +
14487 + case (HEADER_TYPE_PPPoE):
14488 + switch (field.pppoe)
14489 + {
14490 + case (NET_HEADER_FIELD_PPPoE_PID):
14491 + *parseCodeRealSize = 2;
14492 + break;
14493 +
14494 + default:
14495 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported1"));
14496 + *parseCodeRealSize = CC_SIZE_ILLEGAL;
14497 + break;
14498 + }
14499 + break;
14500 +
14501 + case (HEADER_TYPE_VLAN):
14502 + switch (field.vlan)
14503 + {
14504 + case (NET_HEADER_FIELD_VLAN_TCI):
14505 + *parseCodeRealSize = 2;
14506 + break;
14507 +
14508 + default:
14509 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported2"));
14510 + *parseCodeRealSize = CC_SIZE_ILLEGAL;
14511 + break;
14512 + }
14513 + break;
14514 +
14515 + case (HEADER_TYPE_MPLS):
14516 + switch (field.mpls)
14517 + {
14518 + case (NET_HEADER_FIELD_MPLS_LABEL_STACK):
14519 + *parseCodeRealSize = 4;
14520 + break;
14521 +
14522 + default:
14523 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported3"));
14524 + *parseCodeRealSize = CC_SIZE_ILLEGAL;
14525 + break;
14526 + }
14527 + break;
14528 +
14529 + case (HEADER_TYPE_IPv4):
14530 + switch (field.ipv4)
14531 + {
14532 + case (NET_HEADER_FIELD_IPv4_DST_IP):
14533 + case (NET_HEADER_FIELD_IPv4_SRC_IP):
14534 + *parseCodeRealSize = 4;
14535 + break;
14536 +
14537 + case (NET_HEADER_FIELD_IPv4_TOS):
14538 + case (NET_HEADER_FIELD_IPv4_PROTO):
14539 + *parseCodeRealSize = 1;
14540 + break;
14541 +
14542 + case (NET_HEADER_FIELD_IPv4_DST_IP
14543 + | NET_HEADER_FIELD_IPv4_SRC_IP):
14544 + *parseCodeRealSize = 8;
14545 + break;
14546 +
14547 + case (NET_HEADER_FIELD_IPv4_TTL):
14548 + *parseCodeRealSize = 1;
14549 + break;
14550 +
14551 + default:
14552 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported4"));
14553 + *parseCodeRealSize = CC_SIZE_ILLEGAL;
14554 + break;
14555 + }
14556 + break;
14557 +
14558 + case (HEADER_TYPE_IPv6):
14559 + switch (field.ipv6)
14560 + {
14561 + case (NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_FL
14562 + | NET_HEADER_FIELD_IPv6_TC):
14563 + *parseCodeRealSize = 4;
14564 + break;
14565 +
14566 + case (NET_HEADER_FIELD_IPv6_NEXT_HDR):
14567 + case (NET_HEADER_FIELD_IPv6_HOP_LIMIT):
14568 + *parseCodeRealSize = 1;
14569 + break;
14570 +
14571 + case (NET_HEADER_FIELD_IPv6_DST_IP):
14572 + case (NET_HEADER_FIELD_IPv6_SRC_IP):
14573 + *parseCodeRealSize = 16;
14574 + break;
14575 +
14576 + default:
14577 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported5"));
14578 + *parseCodeRealSize = CC_SIZE_ILLEGAL;
14579 + break;
14580 + }
14581 + break;
14582 +
14583 + case (HEADER_TYPE_IP):
14584 + switch (field.ip)
14585 + {
14586 + case (NET_HEADER_FIELD_IP_DSCP):
14587 + case (NET_HEADER_FIELD_IP_PROTO):
14588 + *parseCodeRealSize = 1;
14589 + break;
14590 +
14591 + default:
14592 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported5"));
14593 + *parseCodeRealSize = CC_SIZE_ILLEGAL;
14594 + break;
14595 + }
14596 + break;
14597 +
14598 + case (HEADER_TYPE_GRE):
14599 + switch (field.gre)
14600 + {
14601 + case (NET_HEADER_FIELD_GRE_TYPE):
14602 + *parseCodeRealSize = 2;
14603 + break;
14604 +
14605 + default:
14606 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported6"));
14607 + *parseCodeRealSize = CC_SIZE_ILLEGAL;
14608 + break;
14609 + }
14610 + break;
14611 +
14612 + case (HEADER_TYPE_MINENCAP):
14613 + switch (field.minencap)
14614 + {
14615 + case (NET_HEADER_FIELD_MINENCAP_TYPE):
14616 + *parseCodeRealSize = 1;
14617 + break;
14618 +
14619 + case (NET_HEADER_FIELD_MINENCAP_DST_IP):
14620 + case (NET_HEADER_FIELD_MINENCAP_SRC_IP):
14621 + *parseCodeRealSize = 4;
14622 + break;
14623 +
14624 + case (NET_HEADER_FIELD_MINENCAP_SRC_IP
14625 + | NET_HEADER_FIELD_MINENCAP_DST_IP):
14626 + *parseCodeRealSize = 8;
14627 + break;
14628 +
14629 + default:
14630 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported7"));
14631 + *parseCodeRealSize = CC_SIZE_ILLEGAL;
14632 + break;
14633 + }
14634 + break;
14635 +
14636 + case (HEADER_TYPE_TCP):
14637 + switch (field.tcp)
14638 + {
14639 + case (NET_HEADER_FIELD_TCP_PORT_SRC):
14640 + case (NET_HEADER_FIELD_TCP_PORT_DST):
14641 + *parseCodeRealSize = 2;
14642 + break;
14643 +
14644 + case (NET_HEADER_FIELD_TCP_PORT_SRC
14645 + | NET_HEADER_FIELD_TCP_PORT_DST):
14646 + *parseCodeRealSize = 4;
14647 + break;
14648 +
14649 + default:
14650 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported8"));
14651 + *parseCodeRealSize = CC_SIZE_ILLEGAL;
14652 + break;
14653 + }
14654 + break;
14655 +
14656 + case (HEADER_TYPE_UDP):
14657 + switch (field.udp)
14658 + {
14659 + case (NET_HEADER_FIELD_UDP_PORT_SRC):
14660 + case (NET_HEADER_FIELD_UDP_PORT_DST):
14661 + *parseCodeRealSize = 2;
14662 + break;
14663 +
14664 + case (NET_HEADER_FIELD_UDP_PORT_SRC
14665 + | NET_HEADER_FIELD_UDP_PORT_DST):
14666 + *parseCodeRealSize = 4;
14667 + break;
14668 +
14669 + default:
14670 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported9"));
14671 + *parseCodeRealSize = CC_SIZE_ILLEGAL;
14672 + break;
14673 + }
14674 + break;
14675 +
14676 + default:
14677 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported10"));
14678 + *parseCodeRealSize = CC_SIZE_ILLEGAL;
14679 + break;
14680 + }
14681 +}
14682 +
14683 +t_Error ValidateNextEngineParams(
14684 + t_Handle h_FmPcd, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,
14685 + e_FmPcdCcStatsMode statsMode)
14686 +{
14687 + uint16_t absoluteProfileId;
14688 + t_Error err = E_OK;
14689 + uint8_t relativeSchemeId;
14690 +
14691 + if ((statsMode == e_FM_PCD_CC_STATS_MODE_NONE)
14692 + && (p_FmPcdCcNextEngineParams->statisticsEn))
14693 + RETURN_ERROR(
14694 + MAJOR,
14695 + E_CONFLICT,
14696 + ("Statistics are requested for a key, but statistics mode was set"
14697 + "to 'NONE' upon initialization"));
14698 +
14699 + switch (p_FmPcdCcNextEngineParams->nextEngine)
14700 + {
14701 + case (e_FM_PCD_INVALID):
14702 + err = E_NOT_SUPPORTED;
14703 + break;
14704 +
14705 + case (e_FM_PCD_DONE):
14706 + if ((p_FmPcdCcNextEngineParams->params.enqueueParams.action
14707 + == e_FM_PCD_ENQ_FRAME)
14708 + && p_FmPcdCcNextEngineParams->params.enqueueParams.overrideFqid)
14709 + {
14710 + if (!p_FmPcdCcNextEngineParams->params.enqueueParams.newFqid)
14711 + RETURN_ERROR(
14712 + MAJOR,
14713 + E_CONFLICT,
14714 + ("When overrideFqid is set, newFqid must not be zero"));
14715 + if (p_FmPcdCcNextEngineParams->params.enqueueParams.newFqid
14716 + & ~0x00FFFFFF)
14717 + RETURN_ERROR(
14718 + MAJOR, E_INVALID_VALUE,
14719 + ("fqidForCtrlFlow must be between 1 and 2^24-1"));
14720 + }
14721 + break;
14722 +
14723 + case (e_FM_PCD_KG):
14724 + relativeSchemeId =
14725 + FmPcdKgGetRelativeSchemeId(
14726 + h_FmPcd,
14727 + FmPcdKgGetSchemeId(
14728 + p_FmPcdCcNextEngineParams->params.kgParams.h_DirectScheme));
14729 + if (relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
14730 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
14731 + if (!FmPcdKgIsSchemeValidSw(
14732 + p_FmPcdCcNextEngineParams->params.kgParams.h_DirectScheme))
14733 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
14734 + ("not valid schemeIndex in KG next engine param"));
14735 + if (!KgIsSchemeAlwaysDirect(h_FmPcd, relativeSchemeId))
14736 + RETURN_ERROR(
14737 + MAJOR,
14738 + E_INVALID_STATE,
14739 + ("CC Node may point only to a scheme that is always direct."));
14740 + break;
14741 +
14742 + case (e_FM_PCD_PLCR):
14743 + if (p_FmPcdCcNextEngineParams->params.plcrParams.overrideParams)
14744 + {
14745 + /* if private policer profile, it may be uninitialized yet, therefore no checks are done at this stage */
14746 + if (p_FmPcdCcNextEngineParams->params.plcrParams.sharedProfile)
14747 + {
14748 + err =
14749 + FmPcdPlcrGetAbsoluteIdByProfileParams(
14750 + h_FmPcd,
14751 + e_FM_PCD_PLCR_SHARED,
14752 + NULL,
14753 + p_FmPcdCcNextEngineParams->params.plcrParams.newRelativeProfileId,
14754 + &absoluteProfileId);
14755 + if (err)
14756 + RETURN_ERROR(MAJOR, err,
14757 + ("Shared profile offset is out of range"));
14758 + if (!FmPcdPlcrIsProfileValid(h_FmPcd, absoluteProfileId))
14759 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
14760 + ("Invalid profile"));
14761 + }
14762 + }
14763 + break;
14764 +
14765 + case (e_FM_PCD_HASH):
14766 + p_FmPcdCcNextEngineParams->nextEngine = e_FM_PCD_CC;
14767 + case (e_FM_PCD_CC):
14768 + if (!p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode)
14769 + RETURN_ERROR(MAJOR, E_NULL_POINTER,
14770 + ("handler to next Node is NULL"));
14771 + break;
14772 +
14773 +#if (DPAA_VERSION >= 11)
14774 + case (e_FM_PCD_FR):
14775 + if (!p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic)
14776 + err = E_NOT_SUPPORTED;
14777 + break;
14778 +#endif /* (DPAA_VERSION >= 11) */
14779 +
14780 + default:
14781 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
14782 + ("Next engine is not correct"));
14783 + }
14784 +
14785 +
14786 + return err;
14787 +}
14788 +
14789 +static uint8_t GetGenParseCode(e_FmPcdExtractFrom src,
14790 + uint32_t offset, bool glblMask,
14791 + uint8_t *parseArrayOffset, bool fromIc,
14792 + ccPrivateInfo_t icCode)
14793 +{
14794 + if (!fromIc)
14795 + {
14796 + switch (src)
14797 + {
14798 + case (e_FM_PCD_EXTRACT_FROM_FRAME_START):
14799 + if (glblMask)
14800 + return CC_PC_GENERIC_WITH_MASK;
14801 + else
14802 + return CC_PC_GENERIC_WITHOUT_MASK;
14803 +
14804 + case (e_FM_PCD_EXTRACT_FROM_CURR_END_OF_PARSE):
14805 + *parseArrayOffset = CC_PC_PR_NEXT_HEADER_OFFSET;
14806 + if (offset)
14807 + return CC_PR_OFFSET;
14808 + else
14809 + return CC_PR_WITHOUT_OFFSET;
14810 +
14811 + default:
14812 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 'extract from' src"));
14813 + return CC_PC_ILLEGAL;
14814 + }
14815 + }
14816 + else
14817 + {
14818 + switch (icCode)
14819 + {
14820 + case (CC_PRIVATE_INFO_IC_KEY_EXACT_MATCH):
14821 + *parseArrayOffset = 0x50;
14822 + return CC_PC_GENERIC_IC_GMASK;
14823 +
14824 + case (CC_PRIVATE_INFO_IC_HASH_EXACT_MATCH):
14825 + *parseArrayOffset = 0x48;
14826 + return CC_PC_GENERIC_IC_GMASK;
14827 +
14828 + case (CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP):
14829 + *parseArrayOffset = 0x48;
14830 + return CC_PC_GENERIC_IC_HASH_INDEXED;
14831 +
14832 + case (CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP):
14833 + *parseArrayOffset = 0x16;
14834 + return CC_PC_GENERIC_IC_HASH_INDEXED;
14835 +
14836 + default:
14837 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 'extract from' src"));
14838 + break;
14839 + }
14840 + }
14841 +
14842 + return CC_PC_ILLEGAL;
14843 +}
14844 +
14845 +static uint8_t GetFullFieldParseCode(e_NetHeaderType hdr, e_FmPcdHdrIndex index,
14846 + t_FmPcdFields field)
14847 +{
14848 + switch (hdr)
14849 + {
14850 + case (HEADER_TYPE_NONE):
14851 + ASSERT_COND(FALSE);
14852 + return CC_PC_ILLEGAL;
14853 +
14854 + case (HEADER_TYPE_ETH):
14855 + switch (field.eth)
14856 + {
14857 + case (NET_HEADER_FIELD_ETH_DA):
14858 + return CC_PC_FF_MACDST;
14859 + case (NET_HEADER_FIELD_ETH_SA):
14860 + return CC_PC_FF_MACSRC;
14861 + case (NET_HEADER_FIELD_ETH_TYPE):
14862 + return CC_PC_FF_ETYPE;
14863 + default:
14864 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
14865 + return CC_PC_ILLEGAL;
14866 + }
14867 +
14868 + case (HEADER_TYPE_VLAN):
14869 + switch (field.vlan)
14870 + {
14871 + case (NET_HEADER_FIELD_VLAN_TCI):
14872 + if ((index == e_FM_PCD_HDR_INDEX_NONE)
14873 + || (index == e_FM_PCD_HDR_INDEX_1))
14874 + return CC_PC_FF_TCI1;
14875 + if (index == e_FM_PCD_HDR_INDEX_LAST)
14876 + return CC_PC_FF_TCI2;
14877 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
14878 + return CC_PC_ILLEGAL;
14879 + default:
14880 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
14881 + return CC_PC_ILLEGAL;
14882 + }
14883 +
14884 + case (HEADER_TYPE_MPLS):
14885 + switch (field.mpls)
14886 + {
14887 + case (NET_HEADER_FIELD_MPLS_LABEL_STACK):
14888 + if ((index == e_FM_PCD_HDR_INDEX_NONE)
14889 + || (index == e_FM_PCD_HDR_INDEX_1))
14890 + return CC_PC_FF_MPLS1;
14891 + if (index == e_FM_PCD_HDR_INDEX_LAST)
14892 + return CC_PC_FF_MPLS_LAST;
14893 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal MPLS index"));
14894 + return CC_PC_ILLEGAL;
14895 + default:
14896 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
14897 + return CC_PC_ILLEGAL;
14898 + }
14899 +
14900 + case (HEADER_TYPE_IPv4):
14901 + switch (field.ipv4)
14902 + {
14903 + case (NET_HEADER_FIELD_IPv4_DST_IP):
14904 + if ((index == e_FM_PCD_HDR_INDEX_NONE)
14905 + || (index == e_FM_PCD_HDR_INDEX_1))
14906 + return CC_PC_FF_IPV4DST1;
14907 + if (index == e_FM_PCD_HDR_INDEX_2)
14908 + return CC_PC_FF_IPV4DST2;
14909 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
14910 + return CC_PC_ILLEGAL;
14911 + case (NET_HEADER_FIELD_IPv4_TOS):
14912 + if ((index == e_FM_PCD_HDR_INDEX_NONE)
14913 + || (index == e_FM_PCD_HDR_INDEX_1))
14914 + return CC_PC_FF_IPV4IPTOS_TC1;
14915 + if (index == e_FM_PCD_HDR_INDEX_2)
14916 + return CC_PC_FF_IPV4IPTOS_TC2;
14917 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
14918 + return CC_PC_ILLEGAL;
14919 + case (NET_HEADER_FIELD_IPv4_PROTO):
14920 + if ((index == e_FM_PCD_HDR_INDEX_NONE)
14921 + || (index == e_FM_PCD_HDR_INDEX_1))
14922 + return CC_PC_FF_IPV4PTYPE1;
14923 + if (index == e_FM_PCD_HDR_INDEX_2)
14924 + return CC_PC_FF_IPV4PTYPE2;
14925 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
14926 + return CC_PC_ILLEGAL;
14927 + case (NET_HEADER_FIELD_IPv4_SRC_IP):
14928 + if ((index == e_FM_PCD_HDR_INDEX_NONE)
14929 + || (index == e_FM_PCD_HDR_INDEX_1))
14930 + return CC_PC_FF_IPV4SRC1;
14931 + if (index == e_FM_PCD_HDR_INDEX_2)
14932 + return CC_PC_FF_IPV4SRC2;
14933 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
14934 + return CC_PC_ILLEGAL;
14935 + case (NET_HEADER_FIELD_IPv4_SRC_IP
14936 + | NET_HEADER_FIELD_IPv4_DST_IP):
14937 + if ((index == e_FM_PCD_HDR_INDEX_NONE)
14938 + || (index == e_FM_PCD_HDR_INDEX_1))
14939 + return CC_PC_FF_IPV4SRC1_IPV4DST1;
14940 + if (index == e_FM_PCD_HDR_INDEX_2)
14941 + return CC_PC_FF_IPV4SRC2_IPV4DST2;
14942 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
14943 + return CC_PC_ILLEGAL;
14944 + case (NET_HEADER_FIELD_IPv4_TTL):
14945 + return CC_PC_FF_IPV4TTL;
14946 + default:
14947 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
14948 + return CC_PC_ILLEGAL;
14949 + }
14950 +
14951 + case (HEADER_TYPE_IPv6):
14952 + switch (field.ipv6)
14953 + {
14954 + case (NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_FL
14955 + | NET_HEADER_FIELD_IPv6_TC):
14956 + if ((index == e_FM_PCD_HDR_INDEX_NONE)
14957 + || (index == e_FM_PCD_HDR_INDEX_1))
14958 + return CC_PC_FF_IPTOS_IPV6TC1_IPV6FLOW1;
14959 + if (index == e_FM_PCD_HDR_INDEX_2)
14960 + return CC_PC_FF_IPTOS_IPV6TC2_IPV6FLOW2;
14961 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
14962 + return CC_PC_ILLEGAL;
14963 +
14964 + case (NET_HEADER_FIELD_IPv6_NEXT_HDR):
14965 + if ((index == e_FM_PCD_HDR_INDEX_NONE)
14966 + || (index == e_FM_PCD_HDR_INDEX_1))
14967 + return CC_PC_FF_IPV6PTYPE1;
14968 + if (index == e_FM_PCD_HDR_INDEX_2)
14969 + return CC_PC_FF_IPV6PTYPE2;
14970 + if (index == e_FM_PCD_HDR_INDEX_LAST)
14971 + return CC_PC_FF_IPPID;
14972 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
14973 + return CC_PC_ILLEGAL;
14974 +
14975 + case (NET_HEADER_FIELD_IPv6_DST_IP):
14976 + if ((index == e_FM_PCD_HDR_INDEX_NONE)
14977 + || (index == e_FM_PCD_HDR_INDEX_1))
14978 + return CC_PC_FF_IPV6DST1;
14979 + if (index == e_FM_PCD_HDR_INDEX_2)
14980 + return CC_PC_FF_IPV6DST2;
14981 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
14982 + return CC_PC_ILLEGAL;
14983 +
14984 + case (NET_HEADER_FIELD_IPv6_SRC_IP):
14985 + if ((index == e_FM_PCD_HDR_INDEX_NONE)
14986 + || (index == e_FM_PCD_HDR_INDEX_1))
14987 + return CC_PC_FF_IPV6SRC1;
14988 + if (index == e_FM_PCD_HDR_INDEX_2)
14989 + return CC_PC_FF_IPV6SRC2;
14990 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
14991 + return CC_PC_ILLEGAL;
14992 +
14993 + case (NET_HEADER_FIELD_IPv6_HOP_LIMIT):
14994 + return CC_PC_FF_IPV6HOP_LIMIT;
14995 +
14996 + default:
14997 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
14998 + return CC_PC_ILLEGAL;
14999 + }
15000 +
15001 + case (HEADER_TYPE_IP):
15002 + switch (field.ip)
15003 + {
15004 + case (NET_HEADER_FIELD_IP_DSCP):
15005 + if ((index == e_FM_PCD_HDR_INDEX_NONE)
15006 + || (index == e_FM_PCD_HDR_INDEX_1))
15007 + return CC_PC_FF_IPDSCP;
15008 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP index"));
15009 + return CC_PC_ILLEGAL;
15010 +
15011 + case (NET_HEADER_FIELD_IP_PROTO):
15012 + if (index == e_FM_PCD_HDR_INDEX_LAST)
15013 + return CC_PC_FF_IPPID;
15014 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP index"));
15015 + return CC_PC_ILLEGAL;
15016 +
15017 + default:
15018 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
15019 + return CC_PC_ILLEGAL;
15020 + }
15021 +
15022 + case (HEADER_TYPE_GRE):
15023 + switch (field.gre)
15024 + {
15025 + case (NET_HEADER_FIELD_GRE_TYPE):
15026 + return CC_PC_FF_GREPTYPE;
15027 +
15028 + default:
15029 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
15030 + return CC_PC_ILLEGAL;
15031 + }
15032 +
15033 + case (HEADER_TYPE_MINENCAP):
15034 + switch (field.minencap)
15035 + {
15036 + case (NET_HEADER_FIELD_MINENCAP_TYPE):
15037 + return CC_PC_FF_MINENCAP_PTYPE;
15038 +
15039 + case (NET_HEADER_FIELD_MINENCAP_DST_IP):
15040 + return CC_PC_FF_MINENCAP_IPDST;
15041 +
15042 + case (NET_HEADER_FIELD_MINENCAP_SRC_IP):
15043 + return CC_PC_FF_MINENCAP_IPSRC;
15044 +
15045 + case (NET_HEADER_FIELD_MINENCAP_SRC_IP
15046 + | NET_HEADER_FIELD_MINENCAP_DST_IP):
15047 + return CC_PC_FF_MINENCAP_IPSRC_IPDST;
15048 +
15049 + default:
15050 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
15051 + return CC_PC_ILLEGAL;
15052 + }
15053 +
15054 + case (HEADER_TYPE_TCP):
15055 + switch (field.tcp)
15056 + {
15057 + case (NET_HEADER_FIELD_TCP_PORT_SRC):
15058 + return CC_PC_FF_L4PSRC;
15059 +
15060 + case (NET_HEADER_FIELD_TCP_PORT_DST):
15061 + return CC_PC_FF_L4PDST;
15062 +
15063 + case (NET_HEADER_FIELD_TCP_PORT_DST
15064 + | NET_HEADER_FIELD_TCP_PORT_SRC):
15065 + return CC_PC_FF_L4PSRC_L4PDST;
15066 +
15067 + default:
15068 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
15069 + return CC_PC_ILLEGAL;
15070 + }
15071 +
15072 + case (HEADER_TYPE_PPPoE):
15073 + switch (field.pppoe)
15074 + {
15075 + case (NET_HEADER_FIELD_PPPoE_PID):
15076 + return CC_PC_FF_PPPPID;
15077 +
15078 + default:
15079 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
15080 + return CC_PC_ILLEGAL;
15081 + }
15082 +
15083 + case (HEADER_TYPE_UDP):
15084 + switch (field.udp)
15085 + {
15086 + case (NET_HEADER_FIELD_UDP_PORT_SRC):
15087 + return CC_PC_FF_L4PSRC;
15088 +
15089 + case (NET_HEADER_FIELD_UDP_PORT_DST):
15090 + return CC_PC_FF_L4PDST;
15091 +
15092 + case (NET_HEADER_FIELD_UDP_PORT_DST
15093 + | NET_HEADER_FIELD_UDP_PORT_SRC):
15094 + return CC_PC_FF_L4PSRC_L4PDST;
15095 +
15096 + default:
15097 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
15098 + return CC_PC_ILLEGAL;
15099 + }
15100 +
15101 + default:
15102 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
15103 + return CC_PC_ILLEGAL;
15104 + }
15105 +}
15106 +
15107 +static uint8_t GetPrParseCode(e_NetHeaderType hdr, e_FmPcdHdrIndex hdrIndex,
15108 + uint32_t offset, bool glblMask,
15109 + uint8_t *parseArrayOffset)
15110 +{
15111 + bool offsetRelevant = FALSE;
15112 +
15113 + if (offset)
15114 + offsetRelevant = TRUE;
15115 +
15116 + switch (hdr)
15117 + {
15118 + case (HEADER_TYPE_NONE):
15119 + ASSERT_COND(FALSE);
15120 + return CC_PC_ILLEGAL;
15121 +
15122 + case (HEADER_TYPE_ETH):
15123 + *parseArrayOffset = (uint8_t)CC_PC_PR_ETH_OFFSET;
15124 + break;
15125 +
15126 + case (HEADER_TYPE_USER_DEFINED_SHIM1):
15127 + if (offset || glblMask)
15128 + *parseArrayOffset = (uint8_t)CC_PC_PR_USER_DEFINED_SHIM1_OFFSET;
15129 + else
15130 + return CC_PC_PR_SHIM1;
15131 + break;
15132 +
15133 + case (HEADER_TYPE_USER_DEFINED_SHIM2):
15134 + if (offset || glblMask)
15135 + *parseArrayOffset = (uint8_t)CC_PC_PR_USER_DEFINED_SHIM2_OFFSET;
15136 + else
15137 + return CC_PC_PR_SHIM2;
15138 + break;
15139 +
15140 + case (HEADER_TYPE_LLC_SNAP):
15141 + *parseArrayOffset = CC_PC_PR_USER_LLC_SNAP_OFFSET;
15142 + break;
15143 +
15144 + case (HEADER_TYPE_PPPoE):
15145 + *parseArrayOffset = CC_PC_PR_PPPOE_OFFSET;
15146 + break;
15147 +
15148 + case (HEADER_TYPE_MPLS):
15149 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)
15150 + || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
15151 + *parseArrayOffset = CC_PC_PR_MPLS1_OFFSET;
15152 + else
15153 + if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
15154 + *parseArrayOffset = CC_PC_PR_MPLS_LAST_OFFSET;
15155 + else
15156 + {
15157 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal MPLS header index"));
15158 + return CC_PC_ILLEGAL;
15159 + }
15160 + break;
15161 +
15162 + case (HEADER_TYPE_IPv4):
15163 + case (HEADER_TYPE_IPv6):
15164 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)
15165 + || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
15166 + *parseArrayOffset = CC_PC_PR_IP1_OFFSET;
15167 + else
15168 + if (hdrIndex == e_FM_PCD_HDR_INDEX_2)
15169 + *parseArrayOffset = CC_PC_PR_IP_LAST_OFFSET;
15170 + else
15171 + {
15172 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP header index"));
15173 + return CC_PC_ILLEGAL;
15174 + }
15175 + break;
15176 +
15177 + case (HEADER_TYPE_MINENCAP):
15178 + *parseArrayOffset = CC_PC_PR_MINENC_OFFSET;
15179 + break;
15180 +
15181 + case (HEADER_TYPE_GRE):
15182 + *parseArrayOffset = CC_PC_PR_GRE_OFFSET;
15183 + break;
15184 +
15185 + case (HEADER_TYPE_TCP):
15186 + case (HEADER_TYPE_UDP):
15187 + case (HEADER_TYPE_IPSEC_AH):
15188 + case (HEADER_TYPE_IPSEC_ESP):
15189 + case (HEADER_TYPE_DCCP):
15190 + case (HEADER_TYPE_SCTP):
15191 + *parseArrayOffset = CC_PC_PR_L4_OFFSET;
15192 + break;
15193 +
15194 + default:
15195 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP header for this type of operation"));
15196 + return CC_PC_ILLEGAL;
15197 + }
15198 +
15199 + if (offsetRelevant)
15200 + return CC_PR_OFFSET;
15201 + else
15202 + return CC_PR_WITHOUT_OFFSET;
15203 +}
15204 +
15205 +static uint8_t GetFieldParseCode(e_NetHeaderType hdr, t_FmPcdFields field,
15206 + uint32_t offset, uint8_t *parseArrayOffset,
15207 + e_FmPcdHdrIndex hdrIndex)
15208 +{
15209 + bool offsetRelevant = FALSE;
15210 +
15211 + if (offset)
15212 + offsetRelevant = TRUE;
15213 +
15214 + switch (hdr)
15215 + {
15216 + case (HEADER_TYPE_NONE):
15217 + ASSERT_COND(FALSE);
15218 + break;
15219 + case (HEADER_TYPE_ETH):
15220 + switch (field.eth)
15221 + {
15222 + case (NET_HEADER_FIELD_ETH_TYPE):
15223 + *parseArrayOffset = CC_PC_PR_ETYPE_LAST_OFFSET;
15224 + break;
15225 +
15226 + default:
15227 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
15228 + return CC_PC_ILLEGAL;
15229 + }
15230 + break;
15231 +
15232 + case (HEADER_TYPE_VLAN):
15233 + switch (field.vlan)
15234 + {
15235 + case (NET_HEADER_FIELD_VLAN_TCI):
15236 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)
15237 + || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
15238 + *parseArrayOffset = CC_PC_PR_VLAN1_OFFSET;
15239 + else
15240 + if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
15241 + *parseArrayOffset = CC_PC_PR_VLAN2_OFFSET;
15242 + break;
15243 +
15244 + default:
15245 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
15246 + return CC_PC_ILLEGAL;
15247 + }
15248 + break;
15249 +
15250 + default:
15251 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal header "));
15252 + return CC_PC_ILLEGAL;
15253 + }
15254 +
15255 + if (offsetRelevant)
15256 + return CC_PR_OFFSET;
15257 + else
15258 + return CC_PR_WITHOUT_OFFSET;
15259 +}
15260 +
15261 +static void FillAdOfTypeResult(t_Handle h_Ad,
15262 + t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,
15263 + t_FmPcd *p_FmPcd,
15264 + t_FmPcdCcNextEngineParams *p_CcNextEngineParams)
15265 +{
15266 + t_AdOfTypeResult *p_AdResult = (t_AdOfTypeResult *)h_Ad;
15267 + t_Handle h_TmpAd;
15268 + uint32_t tmp = 0, tmpNia = 0;
15269 + uint16_t profileId;
15270 + t_Handle p_AdNewPtr = NULL;
15271 +
15272 + /* There are 3 cases handled in this routine of building a "result" type AD.
15273 + * Case 1: No Manip. The action descriptor is built within the match table.
15274 + * Case 2: Manip exists. A new AD is created - p_AdNewPtr. It is initialized
15275 + * either in the FmPcdManipUpdateAdResultForCc routine or it was already
15276 + * initialized and returned here.
15277 + * p_AdResult (within the match table) will be initialized after
15278 + * this routine returns and point to the existing AD.
15279 + * Case 3: Manip exists. The action descriptor is built within the match table.
15280 + * FmPcdManipUpdateAdResultForCc returns a NULL p_AdNewPtr.
15281 + *
15282 + * If statistics were enabled and the statistics mode of this node requires
15283 + * a statistics Ad, it will be placed after the result Ad and before the
15284 + * manip Ad, if manip Ad exists here.
15285 + */
15286 +
15287 + /* As default, the "new" ptr is the current one. i.e. the content of the result
15288 + * AD will be written into the match table itself (case (1))*/
15289 + p_AdNewPtr = p_AdResult;
15290 +
15291 + /* Initialize an action descriptor, if current statistics mode requires an Ad */
15292 + if (p_FmPcdCcStatsParams)
15293 + {
15294 + ASSERT_COND(p_FmPcdCcStatsParams->h_StatsAd);
15295 + ASSERT_COND(p_FmPcdCcStatsParams->h_StatsCounters);
15296 +
15297 + /* Swapping addresses between statistics Ad and the current lookup AD addresses */
15298 + h_TmpAd = p_FmPcdCcStatsParams->h_StatsAd;
15299 + p_FmPcdCcStatsParams->h_StatsAd = h_Ad;
15300 + h_Ad = h_TmpAd;
15301 +
15302 + p_AdNewPtr = h_Ad;
15303 + p_AdResult = h_Ad;
15304 +
15305 + /* Init statistics Ad and connect current lookup AD as 'next action' from statistics Ad */
15306 + UpdateStatsAd(p_FmPcdCcStatsParams, h_Ad, p_FmPcd->physicalMuramBase);
15307 + }
15308 +
15309 + /* Create manip and return p_AdNewPtr to either a new descriptor or NULL */
15310 + if (p_CcNextEngineParams->h_Manip)
15311 + FmPcdManipUpdateAdResultForCc(p_CcNextEngineParams->h_Manip,
15312 + p_CcNextEngineParams, h_Ad, &p_AdNewPtr);
15313 +
15314 + /* if (p_AdNewPtr = NULL) --> Done. (case (3)) */
15315 + if (p_AdNewPtr)
15316 + {
15317 + /* case (1) and (2) */
15318 + switch (p_CcNextEngineParams->nextEngine)
15319 + {
15320 + case (e_FM_PCD_DONE):
15321 + if (p_CcNextEngineParams->params.enqueueParams.action
15322 + == e_FM_PCD_ENQ_FRAME)
15323 + {
15324 + if (p_CcNextEngineParams->params.enqueueParams.overrideFqid)
15325 + {
15326 + tmp = FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE;
15327 + tmp |=
15328 + p_CcNextEngineParams->params.enqueueParams.newFqid;
15329 +#if (DPAA_VERSION >= 11)
15330 + tmp |=
15331 + (p_CcNextEngineParams->params.enqueueParams.newRelativeStorageProfileId
15332 + & FM_PCD_AD_RESULT_VSP_MASK)
15333 + << FM_PCD_AD_RESULT_VSP_SHIFT;
15334 +#endif /* (DPAA_VERSION >= 11) */
15335 + }
15336 + else
15337 + {
15338 + tmp = FM_PCD_AD_RESULT_DATA_FLOW_TYPE;
15339 + tmp |= FM_PCD_AD_RESULT_PLCR_DIS;
15340 + }
15341 + }
15342 +
15343 + if (p_CcNextEngineParams->params.enqueueParams.action
15344 + == e_FM_PCD_DROP_FRAME)
15345 + tmpNia |= GET_NIA_BMI_AC_DISCARD_FRAME(p_FmPcd);
15346 + else
15347 + tmpNia |= GET_NIA_BMI_AC_ENQ_FRAME(p_FmPcd);
15348 + break;
15349 +
15350 + case (e_FM_PCD_KG):
15351 + if (p_CcNextEngineParams->params.kgParams.overrideFqid)
15352 + {
15353 + tmp = FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE;
15354 + tmp |= p_CcNextEngineParams->params.kgParams.newFqid;
15355 +#if (DPAA_VERSION >= 11)
15356 + tmp |=
15357 + (p_CcNextEngineParams->params.kgParams.newRelativeStorageProfileId
15358 + & FM_PCD_AD_RESULT_VSP_MASK)
15359 + << FM_PCD_AD_RESULT_VSP_SHIFT;
15360 +#endif /* (DPAA_VERSION >= 11) */
15361 + }
15362 + else
15363 + {
15364 + tmp = FM_PCD_AD_RESULT_DATA_FLOW_TYPE;
15365 + tmp |= FM_PCD_AD_RESULT_PLCR_DIS;
15366 + }
15367 + tmpNia = NIA_KG_DIRECT;
15368 + tmpNia |= NIA_ENG_KG;
15369 + tmpNia |= NIA_KG_CC_EN;
15370 + tmpNia |= FmPcdKgGetSchemeId(
15371 + p_CcNextEngineParams->params.kgParams.h_DirectScheme);
15372 + break;
15373 +
15374 + case (e_FM_PCD_PLCR):
15375 + if (p_CcNextEngineParams->params.plcrParams.overrideParams)
15376 + {
15377 + tmp = FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE;
15378 +
15379 + /* if private policer profile, it may be uninitialized yet, therefore no checks are done at this stage */
15380 + if (p_CcNextEngineParams->params.plcrParams.sharedProfile)
15381 + {
15382 + tmpNia |= NIA_PLCR_ABSOLUTE;
15383 + FmPcdPlcrGetAbsoluteIdByProfileParams(
15384 + (t_Handle)p_FmPcd,
15385 + e_FM_PCD_PLCR_SHARED,
15386 + NULL,
15387 + p_CcNextEngineParams->params.plcrParams.newRelativeProfileId,
15388 + &profileId);
15389 + }
15390 + else
15391 + profileId =
15392 + p_CcNextEngineParams->params.plcrParams.newRelativeProfileId;
15393 +
15394 + tmp |= p_CcNextEngineParams->params.plcrParams.newFqid;
15395 +#if (DPAA_VERSION >= 11)
15396 + tmp |=
15397 + (p_CcNextEngineParams->params.plcrParams.newRelativeStorageProfileId
15398 + & FM_PCD_AD_RESULT_VSP_MASK)
15399 + << FM_PCD_AD_RESULT_VSP_SHIFT;
15400 +#endif /* (DPAA_VERSION >= 11) */
15401 + WRITE_UINT32(
15402 + p_AdResult->plcrProfile,
15403 + (uint32_t)((uint32_t)profileId << FM_PCD_AD_PROFILEID_FOR_CNTRL_SHIFT));
15404 + }
15405 + else
15406 + tmp = FM_PCD_AD_RESULT_DATA_FLOW_TYPE;
15407 +
15408 + tmpNia |=
15409 + NIA_ENG_PLCR
15410 + | p_CcNextEngineParams->params.plcrParams.newRelativeProfileId;
15411 + break;
15412 +
15413 + default:
15414 + return;
15415 + }WRITE_UINT32(p_AdResult->fqid, tmp);
15416 +
15417 + if (p_CcNextEngineParams->h_Manip)
15418 + {
15419 + tmp = GET_UINT32(p_AdResult->plcrProfile);
15420 + tmp |= (uint32_t)(XX_VirtToPhys(p_AdNewPtr)
15421 + - (p_FmPcd->physicalMuramBase)) >> 4;
15422 + WRITE_UINT32(p_AdResult->plcrProfile, tmp);
15423 +
15424 + tmpNia |= FM_PCD_AD_RESULT_EXTENDED_MODE;
15425 + tmpNia |= FM_PCD_AD_RESULT_NADEN;
15426 + }
15427 +
15428 +#if (DPAA_VERSION >= 11)
15429 + tmpNia |= FM_PCD_AD_RESULT_NO_OM_VSPE;
15430 +#endif /* (DPAA_VERSION >= 11) */
15431 + WRITE_UINT32(p_AdResult->nia, tmpNia);
15432 + }
15433 +}
15434 +
15435 +static t_Error CcUpdateParams(t_Handle h_FmPcd, t_Handle h_PcdParams,
15436 + t_Handle h_FmPort, t_Handle h_FmTree,
15437 + bool validate)
15438 +{
15439 + t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *)h_FmTree;
15440 +
15441 + return CcUpdateParam(h_FmPcd, h_PcdParams, h_FmPort,
15442 + p_CcTree->keyAndNextEngineParams,
15443 + p_CcTree->numOfEntries,
15444 + UINT_TO_PTR(p_CcTree->ccTreeBaseAddr), validate, 0,
15445 + h_FmTree, FALSE);
15446 +}
15447 +
15448 +
15449 +static void ReleaseNewNodeCommonPart(
15450 + t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
15451 +{
15452 + if (p_AdditionalInfo->p_AdTableNew)
15453 + FM_MURAM_FreeMem(
15454 + FmPcdGetMuramHandle(
15455 + ((t_FmPcdCcNode *)(p_AdditionalInfo->h_CurrentNode))->h_FmPcd),
15456 + p_AdditionalInfo->p_AdTableNew);
15457 +
15458 + if (p_AdditionalInfo->p_KeysMatchTableNew)
15459 + FM_MURAM_FreeMem(
15460 + FmPcdGetMuramHandle(
15461 + ((t_FmPcdCcNode *)(p_AdditionalInfo->h_CurrentNode))->h_FmPcd),
15462 + p_AdditionalInfo->p_KeysMatchTableNew);
15463 +}
15464 +
15465 +static t_Error UpdateGblMask(t_FmPcdCcNode *p_CcNode, uint8_t keySize,
15466 + uint8_t *p_Mask)
15467 +{
15468 + uint8_t prvGlblMaskSize = p_CcNode->glblMaskSize;
15469 +
15470 + if (p_Mask && !p_CcNode->glblMaskUpdated && (keySize <= 4)
15471 + && !p_CcNode->lclMask)
15472 + {
15473 + if (p_CcNode->parseCode && (p_CcNode->parseCode != CC_PC_FF_TCI1)
15474 + && (p_CcNode->parseCode != CC_PC_FF_TCI2)
15475 + && (p_CcNode->parseCode != CC_PC_FF_MPLS1)
15476 + && (p_CcNode->parseCode != CC_PC_FF_MPLS_LAST)
15477 + && (p_CcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC1)
15478 + && (p_CcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC2)
15479 + && (p_CcNode->parseCode != CC_PC_FF_IPTOS_IPV6TC1_IPV6FLOW1)
15480 + && (p_CcNode->parseCode != CC_PC_FF_IPDSCP)
15481 + && (p_CcNode->parseCode != CC_PC_FF_IPTOS_IPV6TC2_IPV6FLOW2))
15482 + {
15483 + p_CcNode->glblMaskSize = 0;
15484 + p_CcNode->lclMask = TRUE;
15485 + }
15486 + else
15487 + {
15488 + memcpy(p_CcNode->p_GlblMask, p_Mask, (sizeof(uint8_t)) * keySize);
15489 + p_CcNode->glblMaskUpdated = TRUE;
15490 + p_CcNode->glblMaskSize = 4;
15491 + }
15492 + }
15493 + else
15494 + if (p_Mask && (keySize <= 4) && !p_CcNode->lclMask)
15495 + {
15496 + if (memcmp(p_CcNode->p_GlblMask, p_Mask, keySize) != 0)
15497 + {
15498 + p_CcNode->lclMask = TRUE;
15499 + p_CcNode->glblMaskSize = 0;
15500 + }
15501 + }
15502 + else
15503 + if (!p_Mask && p_CcNode->glblMaskUpdated && (keySize <= 4))
15504 + {
15505 + uint32_t tmpMask = 0xffffffff;
15506 + if (memcmp(p_CcNode->p_GlblMask, &tmpMask, 4) != 0)
15507 + {
15508 + p_CcNode->lclMask = TRUE;
15509 + p_CcNode->glblMaskSize = 0;
15510 + }
15511 + }
15512 + else
15513 + if (p_Mask)
15514 + {
15515 + p_CcNode->lclMask = TRUE;
15516 + p_CcNode->glblMaskSize = 0;
15517 + }
15518 +
15519 + /* In static mode (maxNumOfKeys > 0), local mask is supported
15520 + only is mask support was enabled at initialization */
15521 + if (p_CcNode->maxNumOfKeys && (!p_CcNode->maskSupport) && p_CcNode->lclMask)
15522 + {
15523 + p_CcNode->lclMask = FALSE;
15524 + p_CcNode->glblMaskSize = prvGlblMaskSize;
15525 + return ERROR_CODE(E_NOT_SUPPORTED);
15526 + }
15527 +
15528 + return E_OK;
15529 +}
15530 +
15531 +static __inline__ t_Handle GetNewAd(t_Handle h_FmPcdCcNodeOrTree, bool isTree)
15532 +{
15533 + t_FmPcd *p_FmPcd;
15534 + t_Handle h_Ad;
15535 +
15536 + if (isTree)
15537 + p_FmPcd = (t_FmPcd *)(((t_FmPcdCcTree *)h_FmPcdCcNodeOrTree)->h_FmPcd);
15538 + else
15539 + p_FmPcd = (t_FmPcd *)(((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->h_FmPcd);
15540 +
15541 + if ((isTree && p_FmPcd->p_CcShadow)
15542 + || (!isTree && ((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->maxNumOfKeys))
15543 + {
15544 + /* The allocated shadow is divided as follows:
15545 + 0 . . . 16 . . .
15546 + ---------------------------------------------------
15547 + | Shadow | Shadow Keys | Shadow Next |
15548 + | Ad | Match Table | Engine Table |
15549 + | (16 bytes) | (maximal size) | (maximal size) |
15550 + ---------------------------------------------------
15551 + */
15552 + if (!p_FmPcd->p_CcShadow)
15553 + {
15554 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("CC Shadow not allocated"));
15555 + return NULL;
15556 + }
15557 +
15558 + h_Ad = p_FmPcd->p_CcShadow;
15559 + }
15560 + else
15561 + {
15562 + h_Ad = (t_Handle)FM_MURAM_AllocMem(FmPcdGetMuramHandle(p_FmPcd),
15563 + FM_PCD_CC_AD_ENTRY_SIZE,
15564 + FM_PCD_CC_AD_TABLE_ALIGN);
15565 + if (!h_Ad)
15566 + {
15567 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CC node action descriptor"));
15568 + return NULL;
15569 + }
15570 + }
15571 +
15572 + return h_Ad;
15573 +}
15574 +
15575 +static t_Error BuildNewNodeCommonPart(
15576 + t_FmPcdCcNode *p_CcNode, int *size,
15577 + t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
15578 +{
15579 + t_FmPcd *p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
15580 +
15581 + if (p_CcNode->lclMask)
15582 + *size = 2 * p_CcNode->ccKeySizeAccExtraction;
15583 + else
15584 + *size = p_CcNode->ccKeySizeAccExtraction;
15585 +
15586 + if (p_CcNode->maxNumOfKeys == 0)
15587 + {
15588 + p_AdditionalInfo->p_AdTableNew = (t_Handle)FM_MURAM_AllocMem(
15589 + FmPcdGetMuramHandle(p_FmPcd),
15590 + (uint32_t)((p_AdditionalInfo->numOfKeys + 1)
15591 + * FM_PCD_CC_AD_ENTRY_SIZE),
15592 + FM_PCD_CC_AD_TABLE_ALIGN);
15593 + if (!p_AdditionalInfo->p_AdTableNew)
15594 + RETURN_ERROR(
15595 + MAJOR, E_NO_MEMORY,
15596 + ("MURAM allocation for CC node action descriptors table"));
15597 +
15598 + p_AdditionalInfo->p_KeysMatchTableNew = (t_Handle)FM_MURAM_AllocMem(
15599 + FmPcdGetMuramHandle(p_FmPcd),
15600 + (uint32_t)(*size * sizeof(uint8_t)
15601 + * (p_AdditionalInfo->numOfKeys + 1)),
15602 + FM_PCD_CC_KEYS_MATCH_TABLE_ALIGN);
15603 + if (!p_AdditionalInfo->p_KeysMatchTableNew)
15604 + {
15605 + FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),
15606 + p_AdditionalInfo->p_AdTableNew);
15607 + p_AdditionalInfo->p_AdTableNew = NULL;
15608 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
15609 + ("MURAM allocation for CC node key match table"));
15610 + }
15611 +
15612 + MemSet8(
15613 + (uint8_t*)p_AdditionalInfo->p_AdTableNew,
15614 + 0,
15615 + (uint32_t)((p_AdditionalInfo->numOfKeys + 1)
15616 + * FM_PCD_CC_AD_ENTRY_SIZE));
15617 + MemSet8((uint8_t*)p_AdditionalInfo->p_KeysMatchTableNew, 0,
15618 + *size * sizeof(uint8_t) * (p_AdditionalInfo->numOfKeys + 1));
15619 + }
15620 + else
15621 + {
15622 + /* The allocated shadow is divided as follows:
15623 + 0 . . . 16 . . .
15624 + ---------------------------------------------------
15625 + | Shadow | Shadow Keys | Shadow Next |
15626 + | Ad | Match Table | Engine Table |
15627 + | (16 bytes) | (maximal size) | (maximal size) |
15628 + ---------------------------------------------------
15629 + */
15630 +
15631 + if (!p_FmPcd->p_CcShadow)
15632 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("CC Shadow not allocated"));
15633 +
15634 + p_AdditionalInfo->p_KeysMatchTableNew =
15635 + PTR_MOVE(p_FmPcd->p_CcShadow, FM_PCD_CC_AD_ENTRY_SIZE);
15636 + p_AdditionalInfo->p_AdTableNew =
15637 + PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, p_CcNode->keysMatchTableMaxSize);
15638 +
15639 + MemSet8(
15640 + (uint8_t*)p_AdditionalInfo->p_AdTableNew,
15641 + 0,
15642 + (uint32_t)((p_CcNode->maxNumOfKeys + 1)
15643 + * FM_PCD_CC_AD_ENTRY_SIZE));
15644 + MemSet8((uint8_t*)p_AdditionalInfo->p_KeysMatchTableNew, 0,
15645 + (*size) * sizeof(uint8_t) * (p_CcNode->maxNumOfKeys));
15646 + }
15647 +
15648 + p_AdditionalInfo->p_AdTableOld = p_CcNode->h_AdTable;
15649 + p_AdditionalInfo->p_KeysMatchTableOld = p_CcNode->h_KeysMatchTable;
15650 +
15651 + return E_OK;
15652 +}
15653 +
15654 +static t_Error BuildNewNodeAddOrMdfyKeyAndNextEngine(
15655 + t_Handle h_FmPcd, t_FmPcdCcNode *p_CcNode, uint16_t keyIndex,
15656 + t_FmPcdCcKeyParams *p_KeyParams,
15657 + t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo, bool add)
15658 +{
15659 + t_Error err = E_OK;
15660 + t_Handle p_AdTableNewTmp, p_KeysMatchTableNewTmp;
15661 + t_Handle p_KeysMatchTableOldTmp, p_AdTableOldTmp;
15662 + int size;
15663 + int i = 0, j = 0;
15664 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
15665 + uint32_t requiredAction = 0;
15666 + bool prvLclMask;
15667 + t_CcNodeInformation *p_CcNodeInformation;
15668 + t_FmPcdCcStatsParams statsParams = { 0 };
15669 + t_List *p_Pos;
15670 + t_FmPcdStatsObj *p_StatsObj;
15671 +
15672 + /* Check that new NIA is legal */
15673 + err = ValidateNextEngineParams(h_FmPcd, &p_KeyParams->ccNextEngineParams,
15674 + p_CcNode->statisticsMode);
15675 + if (err)
15676 + RETURN_ERROR(MAJOR, err, NO_MSG);
15677 +
15678 + prvLclMask = p_CcNode->lclMask;
15679 +
15680 + /* Check that new key is not require update of localMask */
15681 + err = UpdateGblMask(p_CcNode, p_CcNode->ccKeySizeAccExtraction,
15682 + p_KeyParams->p_Mask);
15683 + if (err)
15684 + RETURN_ERROR(MAJOR, err, (NO_MSG));
15685 +
15686 + /* Update internal data structure with new next engine for the given index */
15687 + memcpy(&p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams,
15688 + &p_KeyParams->ccNextEngineParams, sizeof(t_FmPcdCcNextEngineParams));
15689 +
15690 + memcpy(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].key,
15691 + p_KeyParams->p_Key, p_CcNode->userSizeOfExtraction);
15692 +
15693 + if ((p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
15694 + == e_FM_PCD_CC)
15695 + && p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)
15696 + {
15697 + err =
15698 + AllocAndFillAdForContLookupManip(
15699 + p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode);
15700 + if (err)
15701 + RETURN_ERROR(MAJOR, err, (NO_MSG));
15702 + }
15703 +
15704 + if (p_KeyParams->p_Mask)
15705 + memcpy(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].mask,
15706 + p_KeyParams->p_Mask, p_CcNode->userSizeOfExtraction);
15707 + else
15708 + memset(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].mask, 0xFF,
15709 + p_CcNode->userSizeOfExtraction);
15710 +
15711 + /* Update numOfKeys */
15712 + if (add)
15713 + p_AdditionalInfo->numOfKeys = (uint8_t)(p_CcNode->numOfKeys + 1);
15714 + else
15715 + p_AdditionalInfo->numOfKeys = (uint8_t)p_CcNode->numOfKeys;
15716 +
15717 + /* Allocate new tables in MURAM: keys match table and action descriptors table */
15718 + err = BuildNewNodeCommonPart(p_CcNode, &size, p_AdditionalInfo);
15719 + if (err)
15720 + RETURN_ERROR(MAJOR, err, NO_MSG);
15721 +
15722 + /* Check that manip is legal and what requiredAction is necessary for this manip */
15723 + if (p_KeyParams->ccNextEngineParams.h_Manip)
15724 + {
15725 + err = FmPcdManipCheckParamsForCcNextEngine(
15726 + &p_KeyParams->ccNextEngineParams, &requiredAction);
15727 + if (err)
15728 + RETURN_ERROR(MAJOR, err, (NO_MSG));
15729 + }
15730 +
15731 + p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction =
15732 + requiredAction;
15733 + p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction |=
15734 + UPDATE_CC_WITH_TREE;
15735 +
15736 + /* Update new Ad and new Key Table according to new requirement */
15737 + i = 0;
15738 + for (j = 0; j < p_AdditionalInfo->numOfKeys; j++)
15739 + {
15740 + p_AdTableNewTmp =
15741 + PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j*FM_PCD_CC_AD_ENTRY_SIZE);
15742 +
15743 + if (j == keyIndex)
15744 + {
15745 + if (p_KeyParams->ccNextEngineParams.statisticsEn)
15746 + {
15747 + /* Allocate a statistics object that holds statistics AD and counters.
15748 + - For added key - New statistics AD and counters pointer need to be allocated
15749 + new statistics object. If statistics were enabled, we need to replace the
15750 + existing descriptor with a new descriptor with nullified counters.
15751 + */
15752 + p_StatsObj = GetStatsObj(p_CcNode);
15753 + ASSERT_COND(p_StatsObj);
15754 +
15755 + /* Store allocated statistics object */
15756 + ASSERT_COND(keyIndex < CC_MAX_NUM_OF_KEYS);
15757 + p_AdditionalInfo->keyAndNextEngineParams[keyIndex].p_StatsObj =
15758 + p_StatsObj;
15759 +
15760 + statsParams.h_StatsAd = p_StatsObj->h_StatsAd;
15761 + statsParams.h_StatsCounters = p_StatsObj->h_StatsCounters;
15762 +#if (DPAA_VERSION >= 11)
15763 + statsParams.h_StatsFLRs = p_CcNode->h_StatsFLRs;
15764 +
15765 +#endif /* (DPAA_VERSION >= 11) */
15766 +
15767 + /* Building action descriptor for the received new key */
15768 + NextStepAd(p_AdTableNewTmp, &statsParams,
15769 + &p_KeyParams->ccNextEngineParams, p_FmPcd);
15770 + }
15771 + else
15772 + {
15773 + /* Building action descriptor for the received new key */
15774 + NextStepAd(p_AdTableNewTmp, NULL,
15775 + &p_KeyParams->ccNextEngineParams, p_FmPcd);
15776 + }
15777 +
15778 + /* Copy the received new key into keys match table */
15779 + p_KeysMatchTableNewTmp =
15780 + PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j*size*sizeof(uint8_t));
15781 +
15782 + MemCpy8((void*)p_KeysMatchTableNewTmp, p_KeyParams->p_Key,
15783 + p_CcNode->userSizeOfExtraction);
15784 +
15785 + /* Update mask for the received new key */
15786 + if (p_CcNode->lclMask)
15787 + {
15788 + if (p_KeyParams->p_Mask)
15789 + {
15790 + MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,
15791 + p_CcNode->ccKeySizeAccExtraction),
15792 + p_KeyParams->p_Mask,
15793 + p_CcNode->userSizeOfExtraction);
15794 + }
15795 + else
15796 + if (p_CcNode->ccKeySizeAccExtraction > 4)
15797 + {
15798 + MemSet8(PTR_MOVE(p_KeysMatchTableNewTmp,
15799 + p_CcNode->ccKeySizeAccExtraction),
15800 + 0xff, p_CcNode->userSizeOfExtraction);
15801 + }
15802 + else
15803 + {
15804 + MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,
15805 + p_CcNode->ccKeySizeAccExtraction),
15806 + p_CcNode->p_GlblMask,
15807 + p_CcNode->userSizeOfExtraction);
15808 + }
15809 + }
15810 +
15811 + /* If key modification requested, the old entry is omitted and replaced by the new parameters */
15812 + if (!add)
15813 + i++;
15814 + }
15815 + else
15816 + {
15817 + /* Copy existing action descriptors to the newly allocated Ad table */
15818 + p_AdTableOldTmp =
15819 + PTR_MOVE(p_AdditionalInfo->p_AdTableOld, i*FM_PCD_CC_AD_ENTRY_SIZE);
15820 + MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp,
15821 + FM_PCD_CC_AD_ENTRY_SIZE);
15822 +
15823 + /* Copy existing keys and their masks to the newly allocated keys match table */
15824 + p_KeysMatchTableNewTmp =
15825 + PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j * size * sizeof(uint8_t));
15826 + p_KeysMatchTableOldTmp =
15827 + PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableOld, i * size * sizeof(uint8_t));
15828 +
15829 + if (p_CcNode->lclMask)
15830 + {
15831 + if (prvLclMask)
15832 + {
15833 + MemCpy8(
15834 + PTR_MOVE(p_KeysMatchTableNewTmp, p_CcNode->ccKeySizeAccExtraction),
15835 + PTR_MOVE(p_KeysMatchTableOldTmp, p_CcNode->ccKeySizeAccExtraction),
15836 + p_CcNode->ccKeySizeAccExtraction);
15837 + }
15838 + else
15839 + {
15840 + p_KeysMatchTableOldTmp =
15841 + PTR_MOVE(p_CcNode->h_KeysMatchTable,
15842 + i * (int)p_CcNode->ccKeySizeAccExtraction * sizeof(uint8_t));
15843 +
15844 + if (p_CcNode->ccKeySizeAccExtraction > 4)
15845 + {
15846 + MemSet8(PTR_MOVE(p_KeysMatchTableNewTmp,
15847 + p_CcNode->ccKeySizeAccExtraction),
15848 + 0xff, p_CcNode->userSizeOfExtraction);
15849 + }
15850 + else
15851 + {
15852 + MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,
15853 + p_CcNode->ccKeySizeAccExtraction),
15854 + p_CcNode->p_GlblMask,
15855 + p_CcNode->userSizeOfExtraction);
15856 + }
15857 + }
15858 + }
15859 +
15860 + MemCpy8(p_KeysMatchTableNewTmp, p_KeysMatchTableOldTmp,
15861 + p_CcNode->ccKeySizeAccExtraction);
15862 +
15863 + i++;
15864 + }
15865 + }
15866 +
15867 + /* Miss action descriptor */
15868 + p_AdTableNewTmp =
15869 + PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j * FM_PCD_CC_AD_ENTRY_SIZE);
15870 + p_AdTableOldTmp =
15871 + PTR_MOVE(p_AdditionalInfo->p_AdTableOld, i * FM_PCD_CC_AD_ENTRY_SIZE);
15872 + MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
15873 +
15874 + if (!LIST_IsEmpty(&p_CcNode->ccTreesLst))
15875 + {
15876 + LIST_FOR_EACH(p_Pos, &p_CcNode->ccTreesLst)
15877 + {
15878 + p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
15879 + ASSERT_COND(p_CcNodeInformation->h_CcNode);
15880 + /* Update the manipulation which has to be updated from parameters of the port */
15881 + /* It's has to be updated with restrictions defined in the function */
15882 + err =
15883 + SetRequiredAction(
15884 + p_CcNode->h_FmPcd,
15885 + p_CcNode->shadowAction
15886 + | p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction,
15887 + &p_AdditionalInfo->keyAndNextEngineParams[keyIndex],
15888 + PTR_MOVE(p_AdditionalInfo->p_AdTableNew, keyIndex*FM_PCD_CC_AD_ENTRY_SIZE),
15889 + 1, p_CcNodeInformation->h_CcNode);
15890 + if (err)
15891 + RETURN_ERROR(MAJOR, err, (NO_MSG));
15892 +
15893 + err =
15894 + CcUpdateParam(
15895 + p_CcNode->h_FmPcd,
15896 + NULL,
15897 + NULL,
15898 + &p_AdditionalInfo->keyAndNextEngineParams[keyIndex],
15899 + 1,
15900 + PTR_MOVE(p_AdditionalInfo->p_AdTableNew, keyIndex*FM_PCD_CC_AD_ENTRY_SIZE),
15901 + TRUE, p_CcNodeInformation->index,
15902 + p_CcNodeInformation->h_CcNode, TRUE);
15903 + if (err)
15904 + RETURN_ERROR(MAJOR, err, (NO_MSG));
15905 + }
15906 + }
15907 +
15908 + if (p_CcNode->lclMask)
15909 + memset(p_CcNode->p_GlblMask, 0xff, CC_GLBL_MASK_SIZE * sizeof(uint8_t));
15910 +
15911 + if (p_KeyParams->ccNextEngineParams.nextEngine == e_FM_PCD_CC)
15912 + p_AdditionalInfo->h_NodeForAdd =
15913 + p_KeyParams->ccNextEngineParams.params.ccParams.h_CcNode;
15914 + if (p_KeyParams->ccNextEngineParams.h_Manip)
15915 + p_AdditionalInfo->h_ManipForAdd =
15916 + p_KeyParams->ccNextEngineParams.h_Manip;
15917 +
15918 +#if (DPAA_VERSION >= 11)
15919 + if ((p_KeyParams->ccNextEngineParams.nextEngine == e_FM_PCD_FR)
15920 + && (p_KeyParams->ccNextEngineParams.params.frParams.h_FrmReplic))
15921 + p_AdditionalInfo->h_FrmReplicForAdd =
15922 + p_KeyParams->ccNextEngineParams.params.frParams.h_FrmReplic;
15923 +#endif /* (DPAA_VERSION >= 11) */
15924 +
15925 + if (!add)
15926 + {
15927 + if (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
15928 + == e_FM_PCD_CC)
15929 + p_AdditionalInfo->h_NodeForRmv =
15930 + p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode;
15931 +
15932 + if (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)
15933 + p_AdditionalInfo->h_ManipForRmv =
15934 + p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip;
15935 +
15936 + /* If statistics were previously enabled, store the old statistics object to be released */
15937 + if (p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)
15938 + {
15939 + p_AdditionalInfo->p_StatsObjForRmv =
15940 + p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj;
15941 + }
15942 +
15943 +#if (DPAA_VERSION >= 11)
15944 + if ((p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
15945 + == e_FM_PCD_FR)
15946 + && (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic))
15947 + p_AdditionalInfo->h_FrmReplicForRmv =
15948 + p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic;
15949 +#endif /* (DPAA_VERSION >= 11) */
15950 + }
15951 +
15952 + return E_OK;
15953 +}
15954 +
15955 +static t_Error BuildNewNodeRemoveKey(
15956 + t_FmPcdCcNode *p_CcNode, uint16_t keyIndex,
15957 + t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
15958 +{
15959 + int i = 0, j = 0;
15960 + t_Handle p_AdTableNewTmp, p_KeysMatchTableNewTmp;
15961 + t_Handle p_KeysMatchTableOldTmp, p_AdTableOldTmp;
15962 + int size;
15963 + t_Error err = E_OK;
15964 +
15965 + /*save new numOfKeys*/
15966 + p_AdditionalInfo->numOfKeys = (uint16_t)(p_CcNode->numOfKeys - 1);
15967 +
15968 + /*function which allocates in the memory new KeyTbl, AdTbl*/
15969 + err = BuildNewNodeCommonPart(p_CcNode, &size, p_AdditionalInfo);
15970 + if (err)
15971 + RETURN_ERROR(MAJOR, err, NO_MSG);
15972 +
15973 + /*update new Ad and new Key Table according to new requirement*/
15974 + for (i = 0, j = 0; j < p_CcNode->numOfKeys; i++, j++)
15975 + {
15976 + if (j == keyIndex)
15977 + j++;
15978 +
15979 + if (j == p_CcNode->numOfKeys)
15980 + break;
15981 + p_AdTableNewTmp =
15982 + PTR_MOVE(p_AdditionalInfo->p_AdTableNew, i * FM_PCD_CC_AD_ENTRY_SIZE);
15983 + p_AdTableOldTmp =
15984 + PTR_MOVE(p_AdditionalInfo->p_AdTableOld, j * FM_PCD_CC_AD_ENTRY_SIZE);
15985 + MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
15986 +
15987 + p_KeysMatchTableOldTmp =
15988 + PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableOld, j * size * sizeof(uint8_t));
15989 + p_KeysMatchTableNewTmp =
15990 + PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, i * size * sizeof(uint8_t));
15991 + MemCpy8(p_KeysMatchTableNewTmp, p_KeysMatchTableOldTmp,
15992 + size * sizeof(uint8_t));
15993 + }
15994 +
15995 + p_AdTableNewTmp =
15996 + PTR_MOVE(p_AdditionalInfo->p_AdTableNew, i * FM_PCD_CC_AD_ENTRY_SIZE);
15997 + p_AdTableOldTmp =
15998 + PTR_MOVE(p_AdditionalInfo->p_AdTableOld, j * FM_PCD_CC_AD_ENTRY_SIZE);
15999 + MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
16000 +
16001 + if (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
16002 + == e_FM_PCD_CC)
16003 + p_AdditionalInfo->h_NodeForRmv =
16004 + p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode;
16005 +
16006 + if (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)
16007 + p_AdditionalInfo->h_ManipForRmv =
16008 + p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip;
16009 +
16010 + /* If statistics were previously enabled, store the old statistics object to be released */
16011 + if (p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)
16012 + {
16013 + p_AdditionalInfo->p_StatsObjForRmv =
16014 + p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj;
16015 + }
16016 +
16017 +#if (DPAA_VERSION >= 11)
16018 + if ((p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
16019 + == e_FM_PCD_FR)
16020 + && (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic))
16021 + p_AdditionalInfo->h_FrmReplicForRmv =
16022 + p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic;
16023 +#endif /* (DPAA_VERSION >= 11) */
16024 +
16025 + return E_OK;
16026 +}
16027 +
16028 +static t_Error BuildNewNodeModifyKey(
16029 + t_FmPcdCcNode *p_CcNode, uint16_t keyIndex, uint8_t *p_Key,
16030 + uint8_t *p_Mask, t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
16031 +{
16032 + t_FmPcd *p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
16033 + t_Error err = E_OK;
16034 + t_Handle p_AdTableNewTmp, p_KeysMatchTableNewTmp;
16035 + t_Handle p_KeysMatchTableOldTmp, p_AdTableOldTmp;
16036 + int size;
16037 + int i = 0, j = 0;
16038 + bool prvLclMask;
16039 + t_FmPcdStatsObj *p_StatsObj, tmpStatsObj;
16040 + p_AdditionalInfo->numOfKeys = p_CcNode->numOfKeys;
16041 +
16042 + prvLclMask = p_CcNode->lclMask;
16043 +
16044 + /* Check that new key is not require update of localMask */
16045 + err = UpdateGblMask(p_CcNode, p_CcNode->ccKeySizeAccExtraction, p_Mask);
16046 + if (err)
16047 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16048 +
16049 + /* Update internal data structure with new next engine for the given index */
16050 + memcpy(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].key, p_Key,
16051 + p_CcNode->userSizeOfExtraction);
16052 +
16053 + if (p_Mask)
16054 + memcpy(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].mask, p_Mask,
16055 + p_CcNode->userSizeOfExtraction);
16056 + else
16057 + memset(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].mask, 0xFF,
16058 + p_CcNode->userSizeOfExtraction);
16059 +
16060 + /*function which build in the memory new KeyTbl, AdTbl*/
16061 + err = BuildNewNodeCommonPart(p_CcNode, &size, p_AdditionalInfo);
16062 + if (err)
16063 + RETURN_ERROR(MAJOR, err, NO_MSG);
16064 +
16065 + /*fill the New AdTable and New KeyTable*/
16066 + for (j = 0, i = 0; j < p_AdditionalInfo->numOfKeys; j++, i++)
16067 + {
16068 + p_AdTableNewTmp =
16069 + PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j*FM_PCD_CC_AD_ENTRY_SIZE);
16070 + p_AdTableOldTmp =
16071 + PTR_MOVE(p_AdditionalInfo->p_AdTableOld, i*FM_PCD_CC_AD_ENTRY_SIZE);
16072 +
16073 + MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
16074 +
16075 + if (j == keyIndex)
16076 + {
16077 + ASSERT_COND(keyIndex < CC_MAX_NUM_OF_KEYS);
16078 + if (p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)
16079 + {
16080 + /* As statistics were enabled, we need to update the existing
16081 + statistics descriptor with a new nullified counters. */
16082 + p_StatsObj = GetStatsObj(p_CcNode);
16083 + ASSERT_COND(p_StatsObj);
16084 +
16085 + SetStatsCounters(
16086 + p_AdTableNewTmp,
16087 + (uint32_t)((XX_VirtToPhys(p_StatsObj->h_StatsCounters)
16088 + - p_FmPcd->physicalMuramBase)));
16089 +
16090 + tmpStatsObj.h_StatsAd = p_StatsObj->h_StatsAd;
16091 + tmpStatsObj.h_StatsCounters = p_StatsObj->h_StatsCounters;
16092 +
16093 + /* As we need to replace only the counters, we build a new statistics
16094 + object that holds the old AD and the new counters - this will be the
16095 + currently used statistics object.
16096 + The newly allocated AD is not required and may be released back to
16097 + the available objects with the previous counters pointer. */
16098 + p_StatsObj->h_StatsAd =
16099 + p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsAd;
16100 +
16101 + p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsAd =
16102 + tmpStatsObj.h_StatsAd;
16103 +
16104 + /* Store allocated statistics object */
16105 + p_AdditionalInfo->keyAndNextEngineParams[keyIndex].p_StatsObj =
16106 + p_StatsObj;
16107 +
16108 + /* As statistics were previously enabled, store the old statistics object to be released */
16109 + p_AdditionalInfo->p_StatsObjForRmv =
16110 + p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj;
16111 + }
16112 +
16113 + p_KeysMatchTableNewTmp =
16114 + PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j * size * sizeof(uint8_t));
16115 +
16116 + MemCpy8(p_KeysMatchTableNewTmp, p_Key,
16117 + p_CcNode->userSizeOfExtraction);
16118 +
16119 + if (p_CcNode->lclMask)
16120 + {
16121 + if (p_Mask)
16122 + MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,
16123 + p_CcNode->ccKeySizeAccExtraction),
16124 + p_Mask, p_CcNode->userSizeOfExtraction);
16125 + else
16126 + if (p_CcNode->ccKeySizeAccExtraction > 4)
16127 + MemSet8(PTR_MOVE(p_KeysMatchTableNewTmp,
16128 + p_CcNode->ccKeySizeAccExtraction),
16129 + 0xff, p_CcNode->userSizeOfExtraction);
16130 + else
16131 + MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,
16132 + p_CcNode->ccKeySizeAccExtraction),
16133 + p_CcNode->p_GlblMask,
16134 + p_CcNode->userSizeOfExtraction);
16135 + }
16136 + }
16137 + else
16138 + {
16139 + p_KeysMatchTableNewTmp =
16140 + PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j * size * sizeof(uint8_t));
16141 + p_KeysMatchTableOldTmp =
16142 + PTR_MOVE(p_CcNode->h_KeysMatchTable, i * size * sizeof(uint8_t));
16143 +
16144 + if (p_CcNode->lclMask)
16145 + {
16146 + if (prvLclMask)
16147 + MemCpy8(
16148 + PTR_MOVE(p_KeysMatchTableNewTmp, p_CcNode->ccKeySizeAccExtraction),
16149 + PTR_MOVE(p_KeysMatchTableOldTmp, p_CcNode->ccKeySizeAccExtraction),
16150 + p_CcNode->userSizeOfExtraction);
16151 + else
16152 + {
16153 + p_KeysMatchTableOldTmp =
16154 + PTR_MOVE(p_CcNode->h_KeysMatchTable,
16155 + i * (int)p_CcNode->ccKeySizeAccExtraction * sizeof(uint8_t));
16156 +
16157 + if (p_CcNode->ccKeySizeAccExtraction > 4)
16158 + MemSet8(PTR_MOVE(p_KeysMatchTableNewTmp,
16159 + p_CcNode->ccKeySizeAccExtraction),
16160 + 0xff, p_CcNode->userSizeOfExtraction);
16161 + else
16162 + MemCpy8(
16163 + PTR_MOVE(p_KeysMatchTableNewTmp, p_CcNode->ccKeySizeAccExtraction),
16164 + p_CcNode->p_GlblMask,
16165 + p_CcNode->userSizeOfExtraction);
16166 + }
16167 + }
16168 + MemCpy8((void*)p_KeysMatchTableNewTmp, p_KeysMatchTableOldTmp,
16169 + p_CcNode->ccKeySizeAccExtraction);
16170 + }
16171 + }
16172 +
16173 + p_AdTableNewTmp =
16174 + PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j * FM_PCD_CC_AD_ENTRY_SIZE);
16175 + p_AdTableOldTmp = PTR_MOVE(p_CcNode->h_AdTable, i * FM_PCD_CC_AD_ENTRY_SIZE);
16176 +
16177 + MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
16178 +
16179 + return E_OK;
16180 +}
16181 +
16182 +static t_Error BuildNewNodeModifyNextEngine(
16183 + t_Handle h_FmPcd, t_Handle h_FmPcdCcNodeOrTree, uint16_t keyIndex,
16184 + t_FmPcdCcNextEngineParams *p_CcNextEngineParams, t_List *h_OldLst,
16185 + t_List *h_NewLst, t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
16186 +{
16187 + t_Error err = E_OK;
16188 + uint32_t requiredAction = 0;
16189 + t_List *p_Pos;
16190 + t_CcNodeInformation *p_CcNodeInformation, ccNodeInfo;
16191 + t_Handle p_Ad;
16192 + t_FmPcdCcNode *p_FmPcdCcNode1 = NULL;
16193 + t_FmPcdCcTree *p_FmPcdCcTree = NULL;
16194 + t_FmPcdStatsObj *p_StatsObj;
16195 + t_FmPcdCcStatsParams statsParams = { 0 };
16196 +
16197 + ASSERT_COND(p_CcNextEngineParams);
16198 +
16199 + /* check that new NIA is legal */
16200 + if (!p_AdditionalInfo->tree)
16201 + err = ValidateNextEngineParams(
16202 + h_FmPcd, p_CcNextEngineParams,
16203 + ((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->statisticsMode);
16204 + else
16205 + /* Statistics are not supported for CC root */
16206 + err = ValidateNextEngineParams(h_FmPcd, p_CcNextEngineParams,
16207 + e_FM_PCD_CC_STATS_MODE_NONE);
16208 + if (err)
16209 + RETURN_ERROR(MAJOR, err, NO_MSG);
16210 +
16211 + /* Update internal data structure for next engine per index (index - key) */
16212 + memcpy(&p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams,
16213 + p_CcNextEngineParams, sizeof(t_FmPcdCcNextEngineParams));
16214 +
16215 + /* Check that manip is legal and what requiredAction is necessary for this manip */
16216 + if (p_CcNextEngineParams->h_Manip)
16217 + {
16218 + err = FmPcdManipCheckParamsForCcNextEngine(p_CcNextEngineParams,
16219 + &requiredAction);
16220 + if (err)
16221 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16222 + }
16223 +
16224 + if (!p_AdditionalInfo->tree)
16225 + {
16226 + p_FmPcdCcNode1 = (t_FmPcdCcNode *)h_FmPcdCcNodeOrTree;
16227 + p_AdditionalInfo->numOfKeys = p_FmPcdCcNode1->numOfKeys;
16228 + p_Ad = p_FmPcdCcNode1->h_AdTable;
16229 +
16230 + if (p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
16231 + == e_FM_PCD_CC)
16232 + p_AdditionalInfo->h_NodeForRmv =
16233 + p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode;
16234 +
16235 + if (p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)
16236 + p_AdditionalInfo->h_ManipForRmv =
16237 + p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip;
16238 +
16239 +#if (DPAA_VERSION >= 11)
16240 + if ((p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
16241 + == e_FM_PCD_FR)
16242 + && (p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic))
16243 + p_AdditionalInfo->h_FrmReplicForRmv =
16244 + p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic;
16245 +#endif /* (DPAA_VERSION >= 11) */
16246 + }
16247 + else
16248 + {
16249 + p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcNodeOrTree;
16250 + p_Ad = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);
16251 +
16252 + if (p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
16253 + == e_FM_PCD_CC)
16254 + p_AdditionalInfo->h_NodeForRmv =
16255 + p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode;
16256 +
16257 + if (p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)
16258 + p_AdditionalInfo->h_ManipForRmv =
16259 + p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip;
16260 +
16261 +#if (DPAA_VERSION >= 11)
16262 + if ((p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
16263 + == e_FM_PCD_FR)
16264 + && (p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic))
16265 + p_AdditionalInfo->h_FrmReplicForRmv =
16266 + p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic;
16267 +#endif /* (DPAA_VERSION >= 11) */
16268 + }
16269 +
16270 + if ((p_CcNextEngineParams->nextEngine == e_FM_PCD_CC)
16271 + && p_CcNextEngineParams->h_Manip)
16272 + {
16273 + err = AllocAndFillAdForContLookupManip(
16274 + p_CcNextEngineParams->params.ccParams.h_CcNode);
16275 + if (err)
16276 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16277 + }
16278 +
16279 + ASSERT_COND(p_Ad);
16280 +
16281 + memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
16282 + ccNodeInfo.h_CcNode = PTR_MOVE(p_Ad, keyIndex * FM_PCD_CC_AD_ENTRY_SIZE);
16283 +
16284 + /* If statistics were enabled, this Ad is the statistics Ad. Need to follow its
16285 + nextAction to retrieve the actual Nia-Ad. If statistics should remain enabled,
16286 + only the actual Nia-Ad should be modified. */
16287 + if ((!p_AdditionalInfo->tree)
16288 + && (((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj)
16289 + && (p_CcNextEngineParams->statisticsEn))
16290 + ccNodeInfo.h_CcNode =
16291 + ((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsAd;
16292 +
16293 + EnqueueNodeInfoToRelevantLst(h_OldLst, &ccNodeInfo, NULL);
16294 +
16295 + memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
16296 + p_Ad = GetNewAd(h_FmPcdCcNodeOrTree, p_AdditionalInfo->tree);
16297 + if (!p_Ad)
16298 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
16299 + ("MURAM allocation for CC node action descriptor"));
16300 + MemSet8((uint8_t *)p_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
16301 +
16302 + /* If statistics were not enabled before, but requested now - Allocate a statistics
16303 + object that holds statistics AD and counters. */
16304 + if ((!p_AdditionalInfo->tree)
16305 + && (!((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj)
16306 + && (p_CcNextEngineParams->statisticsEn))
16307 + {
16308 + p_StatsObj = GetStatsObj((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree);
16309 + ASSERT_COND(p_StatsObj);
16310 +
16311 + /* Store allocated statistics object */
16312 + p_AdditionalInfo->keyAndNextEngineParams[keyIndex].p_StatsObj =
16313 + p_StatsObj;
16314 +
16315 + statsParams.h_StatsAd = p_StatsObj->h_StatsAd;
16316 + statsParams.h_StatsCounters = p_StatsObj->h_StatsCounters;
16317 +
16318 +#if (DPAA_VERSION >= 11)
16319 + statsParams.h_StatsFLRs =
16320 + ((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->h_StatsFLRs;
16321 +
16322 +#endif /* (DPAA_VERSION >= 11) */
16323 +
16324 + NextStepAd(p_Ad, &statsParams, p_CcNextEngineParams, h_FmPcd);
16325 + }
16326 + else
16327 + NextStepAd(p_Ad, NULL, p_CcNextEngineParams, h_FmPcd);
16328 +
16329 + ccNodeInfo.h_CcNode = p_Ad;
16330 + EnqueueNodeInfoToRelevantLst(h_NewLst, &ccNodeInfo, NULL);
16331 +
16332 + p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction =
16333 + requiredAction;
16334 + p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction |=
16335 + UPDATE_CC_WITH_TREE;
16336 +
16337 + if (!p_AdditionalInfo->tree)
16338 + {
16339 + ASSERT_COND(p_FmPcdCcNode1);
16340 + if (!LIST_IsEmpty(&p_FmPcdCcNode1->ccTreesLst))
16341 + {
16342 + LIST_FOR_EACH(p_Pos, &p_FmPcdCcNode1->ccTreesLst)
16343 + {
16344 + p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
16345 +
16346 + ASSERT_COND(p_CcNodeInformation->h_CcNode);
16347 + /* Update the manipulation which has to be updated from parameters of the port
16348 + it's has to be updated with restrictions defined in the function */
16349 +
16350 + err =
16351 + SetRequiredAction(
16352 + p_FmPcdCcNode1->h_FmPcd,
16353 + p_FmPcdCcNode1->shadowAction
16354 + | p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction,
16355 + &p_AdditionalInfo->keyAndNextEngineParams[keyIndex],
16356 + p_Ad, 1, p_CcNodeInformation->h_CcNode);
16357 + if (err)
16358 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16359 +
16360 + err = CcUpdateParam(
16361 + p_FmPcdCcNode1->h_FmPcd, NULL, NULL,
16362 + &p_AdditionalInfo->keyAndNextEngineParams[keyIndex], 1,
16363 + p_Ad, TRUE, p_CcNodeInformation->index,
16364 + p_CcNodeInformation->h_CcNode, TRUE);
16365 + if (err)
16366 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16367 + }
16368 + }
16369 + }
16370 + else
16371 + {
16372 + ASSERT_COND(p_FmPcdCcTree);
16373 +
16374 + err =
16375 + SetRequiredAction(
16376 + h_FmPcd,
16377 + p_FmPcdCcTree->requiredAction
16378 + | p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction,
16379 + &p_AdditionalInfo->keyAndNextEngineParams[keyIndex],
16380 + p_Ad, 1, (t_Handle)p_FmPcdCcTree);
16381 + if (err)
16382 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16383 +
16384 + err = CcUpdateParam(h_FmPcd, NULL, NULL,
16385 + &p_AdditionalInfo->keyAndNextEngineParams[keyIndex],
16386 + 1, p_Ad, TRUE, 0, (t_Handle)p_FmPcdCcTree, TRUE);
16387 + if (err)
16388 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16389 + }
16390 +
16391 + if (p_CcNextEngineParams->nextEngine == e_FM_PCD_CC)
16392 + p_AdditionalInfo->h_NodeForAdd =
16393 + p_CcNextEngineParams->params.ccParams.h_CcNode;
16394 + if (p_CcNextEngineParams->h_Manip)
16395 + p_AdditionalInfo->h_ManipForAdd = p_CcNextEngineParams->h_Manip;
16396 +
16397 + /* If statistics were previously enabled, but now are disabled,
16398 + store the old statistics object to be released */
16399 + if ((!p_AdditionalInfo->tree)
16400 + && (((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj)
16401 + && (!p_CcNextEngineParams->statisticsEn))
16402 + {
16403 + p_AdditionalInfo->p_StatsObjForRmv =
16404 + ((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj;
16405 +
16406 +
16407 + p_AdditionalInfo->keyAndNextEngineParams[keyIndex].p_StatsObj = NULL;
16408 + }
16409 +#if (DPAA_VERSION >= 11)
16410 + if ((p_CcNextEngineParams->nextEngine == e_FM_PCD_FR)
16411 + && (p_CcNextEngineParams->params.frParams.h_FrmReplic))
16412 + p_AdditionalInfo->h_FrmReplicForAdd =
16413 + p_CcNextEngineParams->params.frParams.h_FrmReplic;
16414 +#endif /* (DPAA_VERSION >= 11) */
16415 +
16416 + return E_OK;
16417 +}
16418 +
16419 +static void UpdateAdPtrOfNodesWhichPointsOnCrntMdfNode(
16420 + t_FmPcdCcNode *p_CrntMdfNode, t_List *h_OldLst,
16421 + t_FmPcdCcNextEngineParams **p_NextEngineParams)
16422 +{
16423 + t_CcNodeInformation *p_CcNodeInformation;
16424 + t_FmPcdCcNode *p_NodePtrOnCurrentMdfNode = NULL;
16425 + t_List *p_Pos;
16426 + int i = 0;
16427 + t_Handle p_AdTablePtOnCrntCurrentMdfNode/*, p_AdTableNewModified*/;
16428 + t_CcNodeInformation ccNodeInfo;
16429 +
16430 + LIST_FOR_EACH(p_Pos, &p_CrntMdfNode->ccPrevNodesLst)
16431 + {
16432 + p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
16433 + p_NodePtrOnCurrentMdfNode =
16434 + (t_FmPcdCcNode *)p_CcNodeInformation->h_CcNode;
16435 +
16436 + ASSERT_COND(p_NodePtrOnCurrentMdfNode);
16437 +
16438 + /* Search in the previous node which exact index points on this current modified node for getting AD */
16439 + for (i = 0; i < p_NodePtrOnCurrentMdfNode->numOfKeys + 1; i++)
16440 + {
16441 + if (p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine
16442 + == e_FM_PCD_CC)
16443 + {
16444 + if (p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode
16445 + == (t_Handle)p_CrntMdfNode)
16446 + {
16447 + if (p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip)
16448 + p_AdTablePtOnCrntCurrentMdfNode = p_CrntMdfNode->h_Ad;
16449 + else
16450 + if (p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].p_StatsObj)
16451 + p_AdTablePtOnCrntCurrentMdfNode =
16452 + p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].p_StatsObj->h_StatsAd;
16453 + else
16454 + p_AdTablePtOnCrntCurrentMdfNode =
16455 + PTR_MOVE(p_NodePtrOnCurrentMdfNode->h_AdTable, i*FM_PCD_CC_AD_ENTRY_SIZE);
16456 +
16457 + memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
16458 + ccNodeInfo.h_CcNode = p_AdTablePtOnCrntCurrentMdfNode;
16459 + EnqueueNodeInfoToRelevantLst(h_OldLst, &ccNodeInfo, NULL);
16460 +
16461 + if (!(*p_NextEngineParams))
16462 + *p_NextEngineParams =
16463 + &p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams;
16464 + }
16465 + }
16466 + }
16467 +
16468 + ASSERT_COND(i != p_NodePtrOnCurrentMdfNode->numOfKeys);
16469 + }
16470 +}
16471 +
16472 +static void UpdateAdPtrOfTreesWhichPointsOnCrntMdfNode(
16473 + t_FmPcdCcNode *p_CrntMdfNode, t_List *h_OldLst,
16474 + t_FmPcdCcNextEngineParams **p_NextEngineParams)
16475 +{
16476 + t_CcNodeInformation *p_CcNodeInformation;
16477 + t_FmPcdCcTree *p_TreePtrOnCurrentMdfNode = NULL;
16478 + t_List *p_Pos;
16479 + int i = 0;
16480 + t_Handle p_AdTableTmp;
16481 + t_CcNodeInformation ccNodeInfo;
16482 +
16483 + LIST_FOR_EACH(p_Pos, &p_CrntMdfNode->ccTreeIdLst)
16484 + {
16485 + p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
16486 + p_TreePtrOnCurrentMdfNode =
16487 + (t_FmPcdCcTree *)p_CcNodeInformation->h_CcNode;
16488 +
16489 + ASSERT_COND(p_TreePtrOnCurrentMdfNode);
16490 +
16491 + /*search in the trees which exact index points on this current modified node for getting AD */
16492 + for (i = 0; i < p_TreePtrOnCurrentMdfNode->numOfEntries; i++)
16493 + {
16494 + if (p_TreePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine
16495 + == e_FM_PCD_CC)
16496 + {
16497 + if (p_TreePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode
16498 + == (t_Handle)p_CrntMdfNode)
16499 + {
16500 + p_AdTableTmp =
16501 + UINT_TO_PTR(p_TreePtrOnCurrentMdfNode->ccTreeBaseAddr + i*FM_PCD_CC_AD_ENTRY_SIZE);
16502 + memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
16503 + ccNodeInfo.h_CcNode = p_AdTableTmp;
16504 + EnqueueNodeInfoToRelevantLst(h_OldLst, &ccNodeInfo, NULL);
16505 +
16506 + if (!(*p_NextEngineParams))
16507 + *p_NextEngineParams =
16508 + &p_TreePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams;
16509 + }
16510 + }
16511 + }
16512 +
16513 + ASSERT_COND(i == p_TreePtrOnCurrentMdfNode->numOfEntries);
16514 + }
16515 +}
16516 +
16517 +static t_FmPcdModifyCcKeyAdditionalParams * ModifyNodeCommonPart(
16518 + t_Handle h_FmPcdCcNodeOrTree, uint16_t keyIndex,
16519 + e_ModifyState modifyState, bool ttlCheck, bool hashCheck, bool tree)
16520 +{
16521 + t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams;
16522 + int i = 0, j = 0;
16523 + bool wasUpdate = FALSE;
16524 + t_FmPcdCcNode *p_CcNode = NULL;
16525 + t_FmPcdCcTree *p_FmPcdCcTree;
16526 + uint16_t numOfKeys;
16527 + t_FmPcdCcKeyAndNextEngineParams *p_KeyAndNextEngineParams;
16528 +
16529 + SANITY_CHECK_RETURN_VALUE(h_FmPcdCcNodeOrTree, E_INVALID_HANDLE, NULL);
16530 +
16531 + if (!tree)
16532 + {
16533 + p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNodeOrTree;
16534 + numOfKeys = p_CcNode->numOfKeys;
16535 +
16536 + /* node has to be pointed by another node or tree */
16537 +
16538 + p_KeyAndNextEngineParams = (t_FmPcdCcKeyAndNextEngineParams *)XX_Malloc(
16539 + sizeof(t_FmPcdCcKeyAndNextEngineParams) * (numOfKeys + 1));
16540 + if (!p_KeyAndNextEngineParams)
16541 + {
16542 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Next engine and required action structure"));
16543 + return NULL;
16544 + }
16545 + memcpy(p_KeyAndNextEngineParams, p_CcNode->keyAndNextEngineParams,
16546 + (numOfKeys + 1) * sizeof(t_FmPcdCcKeyAndNextEngineParams));
16547 +
16548 + if (ttlCheck)
16549 + {
16550 + if ((p_CcNode->parseCode == CC_PC_FF_IPV4TTL)
16551 + || (p_CcNode->parseCode == CC_PC_FF_IPV6HOP_LIMIT))
16552 + {
16553 + XX_Free(p_KeyAndNextEngineParams);
16554 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("nodeId of CC_PC_FF_IPV4TTL or CC_PC_FF_IPV6HOP_LIMIT can not be used for this operation"));
16555 + return NULL;
16556 + }
16557 + }
16558 +
16559 + if (hashCheck)
16560 + {
16561 + if (p_CcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED)
16562 + {
16563 + XX_Free(p_KeyAndNextEngineParams);
16564 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("nodeId of CC_PC_GENERIC_IC_HASH_INDEXED can not be used for this operation"));
16565 + return NULL;
16566 + }
16567 + }
16568 + }
16569 + else
16570 + {
16571 + p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcNodeOrTree;
16572 + numOfKeys = p_FmPcdCcTree->numOfEntries;
16573 +
16574 + p_KeyAndNextEngineParams = (t_FmPcdCcKeyAndNextEngineParams *)XX_Malloc(
16575 + sizeof(t_FmPcdCcKeyAndNextEngineParams)
16576 + * FM_PCD_MAX_NUM_OF_CC_GROUPS);
16577 + if (!p_KeyAndNextEngineParams)
16578 + {
16579 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Next engine and required action structure"));
16580 + return NULL;
16581 + }
16582 + memcpy(p_KeyAndNextEngineParams,
16583 + p_FmPcdCcTree->keyAndNextEngineParams,
16584 + FM_PCD_MAX_NUM_OF_CC_GROUPS
16585 + * sizeof(t_FmPcdCcKeyAndNextEngineParams));
16586 + }
16587 +
16588 + p_FmPcdModifyCcKeyAdditionalParams =
16589 + (t_FmPcdModifyCcKeyAdditionalParams *)XX_Malloc(
16590 + sizeof(t_FmPcdModifyCcKeyAdditionalParams));
16591 + if (!p_FmPcdModifyCcKeyAdditionalParams)
16592 + {
16593 + XX_Free(p_KeyAndNextEngineParams);
16594 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Allocation of internal data structure FAILED"));
16595 + return NULL;
16596 + }
16597 + memset(p_FmPcdModifyCcKeyAdditionalParams, 0,
16598 + sizeof(t_FmPcdModifyCcKeyAdditionalParams));
16599 +
16600 + p_FmPcdModifyCcKeyAdditionalParams->h_CurrentNode = h_FmPcdCcNodeOrTree;
16601 + p_FmPcdModifyCcKeyAdditionalParams->savedKeyIndex = keyIndex;
16602 +
16603 + while (i < numOfKeys)
16604 + {
16605 + if ((j == keyIndex) && !wasUpdate)
16606 + {
16607 + if (modifyState == e_MODIFY_STATE_ADD)
16608 + j++;
16609 + else
16610 + if (modifyState == e_MODIFY_STATE_REMOVE)
16611 + i++;
16612 + wasUpdate = TRUE;
16613 + }
16614 + else
16615 + {
16616 + memcpy(&p_FmPcdModifyCcKeyAdditionalParams->keyAndNextEngineParams[j],
16617 + p_KeyAndNextEngineParams + i,
16618 + sizeof(t_FmPcdCcKeyAndNextEngineParams));
16619 + i++;
16620 + j++;
16621 + }
16622 + }
16623 +
16624 + if (keyIndex == numOfKeys)
16625 + {
16626 + if (modifyState == e_MODIFY_STATE_ADD)
16627 + j++;
16628 + }
16629 +
16630 + memcpy(&p_FmPcdModifyCcKeyAdditionalParams->keyAndNextEngineParams[j],
16631 + p_KeyAndNextEngineParams + numOfKeys,
16632 + sizeof(t_FmPcdCcKeyAndNextEngineParams));
16633 +
16634 + XX_Free(p_KeyAndNextEngineParams);
16635 +
16636 + return p_FmPcdModifyCcKeyAdditionalParams;
16637 +}
16638 +
16639 +static t_Error UpdatePtrWhichPointOnCrntMdfNode(
16640 + t_FmPcdCcNode *p_CcNode,
16641 + t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams,
16642 + t_List *h_OldLst, t_List *h_NewLst)
16643 +{
16644 + t_FmPcdCcNextEngineParams *p_NextEngineParams = NULL;
16645 + t_CcNodeInformation ccNodeInfo = { 0 };
16646 + t_Handle h_NewAd;
16647 + t_Handle h_OrigAd = NULL;
16648 +
16649 + /* Building a list of all action descriptors that point to the previous node */
16650 + if (!LIST_IsEmpty(&p_CcNode->ccPrevNodesLst))
16651 + UpdateAdPtrOfNodesWhichPointsOnCrntMdfNode(p_CcNode, h_OldLst,
16652 + &p_NextEngineParams);
16653 +
16654 + if (!LIST_IsEmpty(&p_CcNode->ccTreeIdLst))
16655 + UpdateAdPtrOfTreesWhichPointsOnCrntMdfNode(p_CcNode, h_OldLst,
16656 + &p_NextEngineParams);
16657 +
16658 + /* This node must be found as next engine of one of its previous nodes or trees*/
16659 + if (p_NextEngineParams)
16660 + {
16661 + /* Building a new action descriptor that points to the modified node */
16662 + h_NewAd = GetNewAd(p_CcNode, FALSE);
16663 + if (!h_NewAd)
16664 + RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
16665 + MemSet8(h_NewAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
16666 +
16667 + h_OrigAd = p_CcNode->h_Ad;
16668 + BuildNewAd(h_NewAd, p_FmPcdModifyCcKeyAdditionalParams, p_CcNode,
16669 + p_NextEngineParams);
16670 +
16671 + ccNodeInfo.h_CcNode = h_NewAd;
16672 + EnqueueNodeInfoToRelevantLst(h_NewLst, &ccNodeInfo, NULL);
16673 +
16674 + if (p_NextEngineParams->h_Manip && !h_OrigAd)
16675 + FmPcdManipUpdateOwner(p_NextEngineParams->h_Manip, FALSE);
16676 + }
16677 + return E_OK;
16678 +}
16679 +
16680 +static void UpdateCcRootOwner(t_FmPcdCcTree *p_FmPcdCcTree, bool add)
16681 +{
16682 + ASSERT_COND(p_FmPcdCcTree);
16683 +
16684 + /* this routine must be protected by the calling routine! */
16685 +
16686 + if (add)
16687 + p_FmPcdCcTree->owners++;
16688 + else
16689 + {
16690 + ASSERT_COND(p_FmPcdCcTree->owners);
16691 + p_FmPcdCcTree->owners--;
16692 + }
16693 +}
16694 +
16695 +static t_Error CheckAndSetManipParamsWithCcNodeParams(t_FmPcdCcNode *p_CcNode)
16696 +{
16697 + t_Error err = E_OK;
16698 + int i = 0;
16699 +
16700 + for (i = 0; i < p_CcNode->numOfKeys; i++)
16701 + {
16702 + if (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip)
16703 + {
16704 + err =
16705 + FmPcdManipCheckParamsWithCcNodeParams(
16706 + p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip,
16707 + (t_Handle)p_CcNode);
16708 + if (err)
16709 + return err;
16710 + }
16711 + }
16712 +
16713 + return err;
16714 +}
16715 +static t_Error ValidateAndCalcStatsParams(t_FmPcdCcNode *p_CcNode,
16716 + t_FmPcdCcNodeParams *p_CcNodeParam,
16717 + uint32_t *p_NumOfRanges,
16718 + uint32_t *p_CountersArraySize)
16719 +{
16720 + e_FmPcdCcStatsMode statisticsMode = p_CcNode->statisticsMode;
16721 + uint32_t i;
16722 +
16723 + UNUSED(p_CcNodeParam);
16724 +
16725 + switch (statisticsMode)
16726 + {
16727 + case e_FM_PCD_CC_STATS_MODE_NONE:
16728 + for (i = 0; i < p_CcNode->numOfKeys; i++)
16729 + if (p_CcNodeParam->keysParams.keyParams[i].ccNextEngineParams.statisticsEn)
16730 + RETURN_ERROR(
16731 + MAJOR,
16732 + E_INVALID_VALUE,
16733 + ("Statistics cannot be enabled for key %d when statistics mode was set to 'NONE'", i));
16734 + return E_OK;
16735 +
16736 + case e_FM_PCD_CC_STATS_MODE_FRAME:
16737 + case e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME:
16738 + *p_NumOfRanges = 1;
16739 + *p_CountersArraySize = 2 * FM_PCD_CC_STATS_COUNTER_SIZE;
16740 + return E_OK;
16741 +
16742 +#if (DPAA_VERSION >= 11)
16743 + case e_FM_PCD_CC_STATS_MODE_RMON:
16744 + {
16745 + uint16_t *p_FrameLengthRanges =
16746 + p_CcNodeParam->keysParams.frameLengthRanges;
16747 + uint32_t i;
16748 +
16749 + if (p_FrameLengthRanges[0] <= 0)
16750 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Statistics mode"));
16751 +
16752 + if (p_FrameLengthRanges[0] == 0xFFFF)
16753 + {
16754 + *p_NumOfRanges = 1;
16755 + *p_CountersArraySize = 2 * FM_PCD_CC_STATS_COUNTER_SIZE;
16756 + return E_OK;
16757 + }
16758 +
16759 + for (i = 1; i < FM_PCD_CC_STATS_MAX_NUM_OF_FLR; i++)
16760 + {
16761 + if (p_FrameLengthRanges[i - 1] >= p_FrameLengthRanges[i])
16762 + RETURN_ERROR(
16763 + MAJOR,
16764 + E_INVALID_VALUE,
16765 + ("Frame length range must be larger at least by 1 from preceding range"));
16766 +
16767 + /* Stop when last range is reached */
16768 + if (p_FrameLengthRanges[i] == 0xFFFF)
16769 + break;
16770 + }
16771 +
16772 + if ((i >= FM_PCD_CC_STATS_MAX_NUM_OF_FLR)
16773 + || (p_FrameLengthRanges[i] != 0xFFFF))
16774 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
16775 + ("Last Frame length range must be 0xFFFF"));
16776 +
16777 + *p_NumOfRanges = i + 1;
16778 +
16779 + /* Allocate an extra counter for byte count, as counters
16780 + array always begins with byte count */
16781 + *p_CountersArraySize = (*p_NumOfRanges + 1)
16782 + * FM_PCD_CC_STATS_COUNTER_SIZE;
16783 +
16784 + }
16785 + return E_OK;
16786 +#endif /* (DPAA_VERSION >= 11) */
16787 +
16788 + default:
16789 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Statistics mode"));
16790 + }
16791 +}
16792 +
16793 +static t_Error CheckParams(t_Handle h_FmPcd, t_FmPcdCcNodeParams *p_CcNodeParam,
16794 + t_FmPcdCcNode *p_CcNode, bool *isKeyTblAlloc)
16795 +{
16796 + int tmp = 0;
16797 + t_FmPcdCcKeyParams *p_KeyParams;
16798 + t_Error err;
16799 + uint32_t requiredAction = 0;
16800 +
16801 + /* Validate statistics parameters */
16802 + err = ValidateAndCalcStatsParams(p_CcNode, p_CcNodeParam,
16803 + &(p_CcNode->numOfStatsFLRs),
16804 + &(p_CcNode->countersArraySize));
16805 + if (err)
16806 + RETURN_ERROR(MAJOR, err, ("Invalid statistics parameters"));
16807 +
16808 + /* Validate next engine parameters on Miss */
16809 + err = ValidateNextEngineParams(
16810 + h_FmPcd, &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
16811 + p_CcNode->statisticsMode);
16812 + if (err)
16813 + RETURN_ERROR(MAJOR, err,
16814 + ("For this node MissNextEngineParams are not valid"));
16815 +
16816 + if (p_CcNodeParam->keysParams.ccNextEngineParamsForMiss.h_Manip)
16817 + {
16818 + err = FmPcdManipCheckParamsForCcNextEngine(
16819 + &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
16820 + &requiredAction);
16821 + if (err)
16822 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16823 + }
16824 +
16825 + memcpy(&p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams,
16826 + &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
16827 + sizeof(t_FmPcdCcNextEngineParams));
16828 +
16829 + p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].requiredAction =
16830 + requiredAction;
16831 +
16832 + if ((p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.nextEngine
16833 + == e_FM_PCD_CC)
16834 + && p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.h_Manip)
16835 + {
16836 + err =
16837 + AllocAndFillAdForContLookupManip(
16838 + p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.params.ccParams.h_CcNode);
16839 + if (err)
16840 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16841 + }
16842 +
16843 + for (tmp = 0; tmp < p_CcNode->numOfKeys; tmp++)
16844 + {
16845 + p_KeyParams = &p_CcNodeParam->keysParams.keyParams[tmp];
16846 +
16847 + if (!p_KeyParams->p_Key)
16848 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("p_Key is not initialized"));
16849 +
16850 + err = ValidateNextEngineParams(h_FmPcd,
16851 + &p_KeyParams->ccNextEngineParams,
16852 + p_CcNode->statisticsMode);
16853 + if (err)
16854 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16855 +
16856 + err = UpdateGblMask(p_CcNode, p_CcNodeParam->keysParams.keySize,
16857 + p_KeyParams->p_Mask);
16858 + if (err)
16859 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16860 +
16861 + if (p_KeyParams->ccNextEngineParams.h_Manip)
16862 + {
16863 + err = FmPcdManipCheckParamsForCcNextEngine(
16864 + &p_KeyParams->ccNextEngineParams, &requiredAction);
16865 + if (err)
16866 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16867 + }
16868 +
16869 + /* Store 'key' parameters - key, mask (if passed by the user) */
16870 + memcpy(p_CcNode->keyAndNextEngineParams[tmp].key, p_KeyParams->p_Key,
16871 + p_CcNodeParam->keysParams.keySize);
16872 +
16873 + if (p_KeyParams->p_Mask)
16874 + memcpy(p_CcNode->keyAndNextEngineParams[tmp].mask,
16875 + p_KeyParams->p_Mask, p_CcNodeParam->keysParams.keySize);
16876 + else
16877 + memset((void *)(p_CcNode->keyAndNextEngineParams[tmp].mask), 0xFF,
16878 + p_CcNodeParam->keysParams.keySize);
16879 +
16880 + /* Store next engine parameters */
16881 + memcpy(&p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams,
16882 + &p_KeyParams->ccNextEngineParams,
16883 + sizeof(t_FmPcdCcNextEngineParams));
16884 +
16885 + p_CcNode->keyAndNextEngineParams[tmp].requiredAction = requiredAction;
16886 +
16887 + if ((p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.nextEngine
16888 + == e_FM_PCD_CC)
16889 + && p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip)
16890 + {
16891 + err =
16892 + AllocAndFillAdForContLookupManip(
16893 + p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.params.ccParams.h_CcNode);
16894 + if (err)
16895 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16896 + }
16897 + }
16898 +
16899 + if (p_CcNode->maxNumOfKeys)
16900 + {
16901 + if (p_CcNode->maxNumOfKeys < p_CcNode->numOfKeys)
16902 + RETURN_ERROR(
16903 + MAJOR,
16904 + E_INVALID_VALUE,
16905 + ("Number of keys exceed the provided maximal number of keys"));
16906 + }
16907 +
16908 + *isKeyTblAlloc = TRUE;
16909 +
16910 + return E_OK;
16911 +}
16912 +
16913 +static t_Error Ipv4TtlOrIpv6HopLimitCheckParams(
16914 + t_Handle h_FmPcd, t_FmPcdCcNodeParams *p_CcNodeParam,
16915 + t_FmPcdCcNode *p_CcNode, bool *isKeyTblAlloc)
16916 +{
16917 + int tmp = 0;
16918 + t_FmPcdCcKeyParams *p_KeyParams;
16919 + t_Error err;
16920 + uint8_t key = 0x01;
16921 + uint32_t requiredAction = 0;
16922 +
16923 + if (p_CcNode->numOfKeys != 1)
16924 + RETURN_ERROR(
16925 + MAJOR,
16926 + E_INVALID_VALUE,
16927 + ("For node of the type IPV4_TTL or IPV6_HOP_LIMIT the maximal supported 'numOfKeys' is 1"));
16928 +
16929 + if ((p_CcNodeParam->keysParams.maxNumOfKeys)
16930 + && (p_CcNodeParam->keysParams.maxNumOfKeys != 1))
16931 + RETURN_ERROR(
16932 + MAJOR,
16933 + E_INVALID_VALUE,
16934 + ("For node of the type IPV4_TTL or IPV6_HOP_LIMIT the maximal supported 'maxNumOfKeys' is 1"));
16935 +
16936 + /* Validate statistics parameters */
16937 + err = ValidateAndCalcStatsParams(p_CcNode, p_CcNodeParam,
16938 + &(p_CcNode->numOfStatsFLRs),
16939 + &(p_CcNode->countersArraySize));
16940 + if (err)
16941 + RETURN_ERROR(MAJOR, err, ("Invalid statistics parameters"));
16942 +
16943 + err = ValidateNextEngineParams(
16944 + h_FmPcd, &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
16945 + p_CcNodeParam->keysParams.statisticsMode);
16946 + if (err)
16947 + RETURN_ERROR(MAJOR, err,
16948 + ("For this node MissNextEngineParams are not valid"));
16949 +
16950 + if (p_CcNodeParam->keysParams.ccNextEngineParamsForMiss.h_Manip)
16951 + {
16952 + err = FmPcdManipCheckParamsForCcNextEngine(
16953 + &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
16954 + &requiredAction);
16955 + if (err)
16956 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16957 + }
16958 +
16959 + memcpy(&p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams,
16960 + &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
16961 + sizeof(t_FmPcdCcNextEngineParams));
16962 +
16963 + p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].requiredAction =
16964 + requiredAction;
16965 +
16966 + if ((p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.nextEngine
16967 + == e_FM_PCD_CC)
16968 + && p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.h_Manip)
16969 + {
16970 + err =
16971 + AllocAndFillAdForContLookupManip(
16972 + p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.params.ccParams.h_CcNode);
16973 + if (err)
16974 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16975 + }
16976 +
16977 + for (tmp = 0; tmp < p_CcNode->numOfKeys; tmp++)
16978 + {
16979 + p_KeyParams = &p_CcNodeParam->keysParams.keyParams[tmp];
16980 +
16981 + if (p_KeyParams->p_Mask)
16982 + RETURN_ERROR(
16983 + MAJOR,
16984 + E_INVALID_VALUE,
16985 + ("For node of the type IPV4_TTL or IPV6_HOP_LIMIT p_Mask can not be initialized"));
16986 +
16987 + if (memcmp(p_KeyParams->p_Key, &key, 1) != 0)
16988 + RETURN_ERROR(
16989 + MAJOR,
16990 + E_INVALID_VALUE,
16991 + ("For node of the type IPV4_TTL or IPV6_HOP_LIMIT p_Key has to be 1"));
16992 +
16993 + err = ValidateNextEngineParams(h_FmPcd,
16994 + &p_KeyParams->ccNextEngineParams,
16995 + p_CcNode->statisticsMode);
16996 + if (err)
16997 + RETURN_ERROR(MAJOR, err, (NO_MSG));
16998 +
16999 + if (p_KeyParams->ccNextEngineParams.h_Manip)
17000 + {
17001 + err = FmPcdManipCheckParamsForCcNextEngine(
17002 + &p_KeyParams->ccNextEngineParams, &requiredAction);
17003 + if (err)
17004 + RETURN_ERROR(MAJOR, err, (NO_MSG));
17005 + }
17006 +
17007 + /* Store 'key' parameters - key (fixed to 0x01), key size of 1 byte and full mask */
17008 + p_CcNode->keyAndNextEngineParams[tmp].key[0] = key;
17009 + p_CcNode->keyAndNextEngineParams[tmp].mask[0] = 0xFF;
17010 +
17011 + /* Store NextEngine parameters */
17012 + memcpy(&p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams,
17013 + &p_KeyParams->ccNextEngineParams,
17014 + sizeof(t_FmPcdCcNextEngineParams));
17015 +
17016 + if ((p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.nextEngine
17017 + == e_FM_PCD_CC)
17018 + && p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip)
17019 + {
17020 + err =
17021 + AllocAndFillAdForContLookupManip(
17022 + p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.params.ccParams.h_CcNode);
17023 + if (err)
17024 + RETURN_ERROR(MAJOR, err, (NO_MSG));
17025 + }
17026 + p_CcNode->keyAndNextEngineParams[tmp].requiredAction = requiredAction;
17027 + }
17028 +
17029 + *isKeyTblAlloc = FALSE;
17030 +
17031 + return E_OK;
17032 +}
17033 +
17034 +static t_Error IcHashIndexedCheckParams(t_Handle h_FmPcd,
17035 + t_FmPcdCcNodeParams *p_CcNodeParam,
17036 + t_FmPcdCcNode *p_CcNode,
17037 + bool *isKeyTblAlloc)
17038 +{
17039 + int tmp = 0, countOnes = 0;
17040 + t_FmPcdCcKeyParams *p_KeyParams;
17041 + t_Error err;
17042 + uint16_t glblMask = p_CcNodeParam->extractCcParams.extractNonHdr.icIndxMask;
17043 + uint16_t countMask = (uint16_t)(glblMask >> 4);
17044 + uint32_t requiredAction = 0;
17045 +
17046 + if (glblMask & 0x000f)
17047 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
17048 + ("icIndxMask has to be with last nibble 0"));
17049 +
17050 + while (countMask)
17051 + {
17052 + countOnes++;
17053 + countMask = (uint16_t)(countMask >> 1);
17054 + }
17055 +
17056 + if (!POWER_OF_2(p_CcNode->numOfKeys))
17057 + RETURN_ERROR(
17058 + MAJOR,
17059 + E_INVALID_VALUE,
17060 + ("For Node of the type INDEXED numOfKeys has to be powerOfTwo"));
17061 +
17062 + if (p_CcNode->numOfKeys != ((uint32_t)1 << countOnes))
17063 + RETURN_ERROR(
17064 + MAJOR,
17065 + E_INVALID_VALUE,
17066 + ("For Node of the type IC_HASH_INDEXED numOfKeys has to be powerOfTwo"));
17067 +
17068 + if (p_CcNodeParam->keysParams.maxNumOfKeys
17069 + && (p_CcNodeParam->keysParams.maxNumOfKeys != p_CcNode->numOfKeys))
17070 + RETURN_ERROR(
17071 + MAJOR,
17072 + E_INVALID_VALUE,
17073 + ("For Node of the type INDEXED 'maxNumOfKeys' should be 0 or equal 'numOfKeys'"));
17074 +
17075 + /* Validate statistics parameters */
17076 + err = ValidateAndCalcStatsParams(p_CcNode, p_CcNodeParam,
17077 + &(p_CcNode->numOfStatsFLRs),
17078 + &(p_CcNode->countersArraySize));
17079 + if (err)
17080 + RETURN_ERROR(MAJOR, err, ("Invalid statistics parameters"));
17081 +
17082 + err = ValidateNextEngineParams(
17083 + h_FmPcd, &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
17084 + p_CcNode->statisticsMode);
17085 + if (GET_ERROR_TYPE(err) != E_NOT_SUPPORTED)
17086 + RETURN_ERROR(
17087 + MAJOR,
17088 + err,
17089 + ("MissNextEngineParams for the node of the type IC_INDEX_HASH has to be UnInitialized"));
17090 +
17091 + for (tmp = 0; tmp < p_CcNode->numOfKeys; tmp++)
17092 + {
17093 + p_KeyParams = &p_CcNodeParam->keysParams.keyParams[tmp];
17094 +
17095 + if (p_KeyParams->p_Mask || p_KeyParams->p_Key)
17096 + RETURN_ERROR(
17097 + MAJOR,
17098 + E_INVALID_VALUE,
17099 + ("For Node of the type IC_HASH_INDEXED p_Key or p_Mask has to be NULL"));
17100 +
17101 + if ((glblMask & (tmp * 16)) == (tmp * 16))
17102 + {
17103 + err = ValidateNextEngineParams(h_FmPcd,
17104 + &p_KeyParams->ccNextEngineParams,
17105 + p_CcNode->statisticsMode);
17106 + if (err)
17107 + RETURN_ERROR(
17108 + MAJOR,
17109 + err,
17110 + ("This index has to be initialized for the node of the type IC_INDEX_HASH according to settings of GlobalMask "));
17111 +
17112 + if (p_KeyParams->ccNextEngineParams.h_Manip)
17113 + {
17114 + err = FmPcdManipCheckParamsForCcNextEngine(
17115 + &p_KeyParams->ccNextEngineParams, &requiredAction);
17116 + if (err)
17117 + RETURN_ERROR(MAJOR, err, (NO_MSG));
17118 + p_CcNode->keyAndNextEngineParams[tmp].requiredAction =
17119 + requiredAction;
17120 + }
17121 +
17122 + memcpy(&p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams,
17123 + &p_KeyParams->ccNextEngineParams,
17124 + sizeof(t_FmPcdCcNextEngineParams));
17125 +
17126 + if ((p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.nextEngine
17127 + == e_FM_PCD_CC)
17128 + && p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip)
17129 + {
17130 + err =
17131 + AllocAndFillAdForContLookupManip(
17132 + p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.params.ccParams.h_CcNode);
17133 + if (err)
17134 + RETURN_ERROR(MAJOR, err, (NO_MSG));
17135 + }
17136 + }
17137 + else
17138 + {
17139 + err = ValidateNextEngineParams(h_FmPcd,
17140 + &p_KeyParams->ccNextEngineParams,
17141 + p_CcNode->statisticsMode);
17142 + if (GET_ERROR_TYPE(err) != E_NOT_SUPPORTED)
17143 + RETURN_ERROR(
17144 + MAJOR,
17145 + err,
17146 + ("This index has to be UnInitialized for the node of the type IC_INDEX_HASH according to settings of GlobalMask"));
17147 + }
17148 + }
17149 +
17150 + *isKeyTblAlloc = FALSE;
17151 + cpu_to_be16s(&glblMask);
17152 + memcpy(PTR_MOVE(p_CcNode->p_GlblMask, 2), &glblMask, 2);
17153 +
17154 + return E_OK;
17155 +}
17156 +
17157 +static t_Error ModifyNextEngineParamNode(
17158 + t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint16_t keyIndex,
17159 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
17160 +{
17161 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
17162 + t_FmPcd *p_FmPcd;
17163 + t_List h_OldPointersLst, h_NewPointersLst;
17164 + t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
17165 + t_Error err = E_OK;
17166 +
17167 + SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_VALUE);
17168 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
17169 +
17170 + if (keyIndex >= p_CcNode->numOfKeys)
17171 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
17172 + ("keyIndex > previously cleared last index + 1"));
17173 +
17174 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
17175 +
17176 + INIT_LIST(&h_OldPointersLst);
17177 + INIT_LIST(&h_NewPointersLst);
17178 +
17179 + p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,
17180 + e_MODIFY_STATE_CHANGE, FALSE,
17181 + FALSE, FALSE);
17182 + if (!p_ModifyKeyParams)
17183 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
17184 +
17185 + if (p_CcNode->maxNumOfKeys
17186 + && !TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
17187 + {
17188 + XX_Free(p_ModifyKeyParams);
17189 + return ERROR_CODE(E_BUSY);
17190 + }
17191 +
17192 + err = BuildNewNodeModifyNextEngine(h_FmPcd, p_CcNode, keyIndex,
17193 + p_FmPcdCcNextEngineParams,
17194 + &h_OldPointersLst, &h_NewPointersLst,
17195 + p_ModifyKeyParams);
17196 + if (err)
17197 + {
17198 + XX_Free(p_ModifyKeyParams);
17199 + if (p_CcNode->maxNumOfKeys)
17200 + RELEASE_LOCK(p_FmPcd->shadowLock);
17201 + RETURN_ERROR(MAJOR, err, NO_MSG);
17202 + }
17203 +
17204 + err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
17205 + p_ModifyKeyParams, FALSE);
17206 +
17207 + if (p_CcNode->maxNumOfKeys)
17208 + RELEASE_LOCK(p_FmPcd->shadowLock);
17209 +
17210 + return err;
17211 +}
17212 +
17213 +static t_Error FindKeyIndex(t_Handle h_CcNode, uint8_t keySize, uint8_t *p_Key,
17214 + uint8_t *p_Mask, uint16_t *p_KeyIndex)
17215 +{
17216 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
17217 + uint8_t tmpMask[FM_PCD_MAX_SIZE_OF_KEY];
17218 + uint16_t i;
17219 +
17220 + ASSERT_COND(p_Key);
17221 + ASSERT_COND(p_KeyIndex);
17222 + ASSERT_COND(keySize < FM_PCD_MAX_SIZE_OF_KEY);
17223 +
17224 + if (keySize != p_CcNode->userSizeOfExtraction)
17225 + RETURN_ERROR(
17226 + MINOR, E_INVALID_VALUE,
17227 + ("Key size doesn't match the extraction size of the node"));
17228 +
17229 + /* If user didn't pass a mask for this key, we'll look for full extraction mask */
17230 + if (!p_Mask)
17231 + memset(tmpMask, 0xFF, keySize);
17232 +
17233 + for (i = 0; i < p_CcNode->numOfKeys; i++)
17234 + {
17235 + /* Comparing received key */
17236 + if (memcmp(p_Key, p_CcNode->keyAndNextEngineParams[i].key, keySize)
17237 + == 0)
17238 + {
17239 + if (p_Mask)
17240 + {
17241 + /* If a user passed a mask for this key, it must match to the existing key's mask for a correct match */
17242 + if (memcmp(p_Mask, p_CcNode->keyAndNextEngineParams[i].mask,
17243 + keySize) == 0)
17244 + {
17245 + *p_KeyIndex = i;
17246 + return E_OK;
17247 + }
17248 + }
17249 + else
17250 + {
17251 + /* If user didn't pass a mask for this key, check if the existing key mask is full extraction */
17252 + if (memcmp(tmpMask, p_CcNode->keyAndNextEngineParams[i].mask,
17253 + keySize) == 0)
17254 + {
17255 + *p_KeyIndex = i;
17256 + return E_OK;
17257 + }
17258 + }
17259 + }
17260 + }
17261 +
17262 + return ERROR_CODE(E_NOT_FOUND);
17263 +}
17264 +
17265 +static t_Error CalcAndUpdateCcShadow(t_FmPcdCcNode *p_CcNode,
17266 + bool isKeyTblAlloc,
17267 + uint32_t *p_MatchTableSize,
17268 + uint32_t *p_AdTableSize)
17269 +{
17270 + uint32_t shadowSize;
17271 + t_Error err;
17272 +
17273 + /* Calculate keys table maximal size - each entry consists of a key and a mask,
17274 + (if local mask support is requested) */
17275 + *p_MatchTableSize = p_CcNode->ccKeySizeAccExtraction * sizeof(uint8_t)
17276 + * p_CcNode->maxNumOfKeys;
17277 +
17278 + if (p_CcNode->maskSupport)
17279 + *p_MatchTableSize *= 2;
17280 +
17281 + /* Calculate next action descriptors table, including one more entry for miss */
17282 + *p_AdTableSize = (uint32_t)((p_CcNode->maxNumOfKeys + 1)
17283 + * FM_PCD_CC_AD_ENTRY_SIZE);
17284 +
17285 + /* Calculate maximal shadow size of this node.
17286 + All shadow structures will be used for runtime modifications host command. If
17287 + keys table was allocated for this node, the keys table and next engines table may
17288 + be modified in run time (entries added or removed), so shadow tables are requires.
17289 + Otherwise, the only supported runtime modification is a specific next engine update
17290 + and this requires shadow memory of a single AD */
17291 +
17292 + /* Shadow size should be enough to hold the following 3 structures:
17293 + * 1 - an action descriptor */
17294 + shadowSize = FM_PCD_CC_AD_ENTRY_SIZE;
17295 +
17296 + /* 2 - keys match table, if was allocated for the current node */
17297 + if (isKeyTblAlloc)
17298 + shadowSize += *p_MatchTableSize;
17299 +
17300 + /* 3 - next action descriptors table */
17301 + shadowSize += *p_AdTableSize;
17302 +
17303 + /* Update shadow to the calculated size */
17304 + err = FmPcdUpdateCcShadow(p_CcNode->h_FmPcd, (uint32_t)shadowSize,
17305 + FM_PCD_CC_AD_TABLE_ALIGN);
17306 + if (err != E_OK)
17307 + {
17308 + DeleteNode(p_CcNode);
17309 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CC node shadow"));
17310 + }
17311 +
17312 + return E_OK;
17313 +}
17314 +
17315 +static t_Error AllocStatsObjs(t_FmPcdCcNode *p_CcNode)
17316 +{
17317 + t_FmPcdStatsObj *p_StatsObj;
17318 + t_Handle h_FmMuram, h_StatsAd, h_StatsCounters;
17319 + uint32_t i;
17320 +
17321 + h_FmMuram = FmPcdGetMuramHandle(p_CcNode->h_FmPcd);
17322 + if (!h_FmMuram)
17323 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("FM MURAM"));
17324 +
17325 + /* Allocate statistics ADs and statistics counter. An extra pair (AD + counters)
17326 + will be allocated to support runtime modifications */
17327 + for (i = 0; i < p_CcNode->maxNumOfKeys + 2; i++)
17328 + {
17329 + /* Allocate list object structure */
17330 + p_StatsObj = XX_Malloc(sizeof(t_FmPcdStatsObj));
17331 + if (!p_StatsObj)
17332 + {
17333 + FreeStatObjects(&p_CcNode->availableStatsLst, h_FmMuram);
17334 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Statistics object"));
17335 + }
17336 + memset(p_StatsObj, 0, sizeof(t_FmPcdStatsObj));
17337 +
17338 + /* Allocate statistics AD from MURAM */
17339 + h_StatsAd = (t_Handle)FM_MURAM_AllocMem(h_FmMuram,
17340 + FM_PCD_CC_AD_ENTRY_SIZE,
17341 + FM_PCD_CC_AD_TABLE_ALIGN);
17342 + if (!h_StatsAd)
17343 + {
17344 + FreeStatObjects(&p_CcNode->availableStatsLst, h_FmMuram);
17345 + XX_Free(p_StatsObj);
17346 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
17347 + ("MURAM allocation for statistics ADs"));
17348 + }
17349 + MemSet8(h_StatsAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
17350 +
17351 + /* Allocate statistics counters from MURAM */
17352 + h_StatsCounters = (t_Handle)FM_MURAM_AllocMem(
17353 + h_FmMuram, p_CcNode->countersArraySize,
17354 + FM_PCD_CC_AD_TABLE_ALIGN);
17355 + if (!h_StatsCounters)
17356 + {
17357 + FreeStatObjects(&p_CcNode->availableStatsLst, h_FmMuram);
17358 + FM_MURAM_FreeMem(h_FmMuram, h_StatsAd);
17359 + XX_Free(p_StatsObj);
17360 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
17361 + ("MURAM allocation for statistics counters"));
17362 + }
17363 + MemSet8(h_StatsCounters, 0, p_CcNode->countersArraySize);
17364 +
17365 + p_StatsObj->h_StatsAd = h_StatsAd;
17366 + p_StatsObj->h_StatsCounters = h_StatsCounters;
17367 +
17368 + EnqueueStatsObj(&p_CcNode->availableStatsLst, p_StatsObj);
17369 + }
17370 +
17371 + return E_OK;
17372 +}
17373 +
17374 +static t_Error MatchTableGetKeyStatistics(
17375 + t_FmPcdCcNode *p_CcNode, uint16_t keyIndex,
17376 + t_FmPcdCcKeyStatistics *p_KeyStatistics)
17377 +{
17378 + uint32_t *p_StatsCounters, i;
17379 +
17380 + if (p_CcNode->statisticsMode == e_FM_PCD_CC_STATS_MODE_NONE)
17381 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
17382 + ("Statistics were not enabled for this match table"));
17383 +
17384 + if (!p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)
17385 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
17386 + ("Statistics were not enabled for this key"));
17387 +
17388 + memset(p_KeyStatistics, 0, sizeof(t_FmPcdCcKeyStatistics));
17389 +
17390 + p_StatsCounters =
17391 + p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsCounters;
17392 + ASSERT_COND(p_StatsCounters);
17393 +
17394 + p_KeyStatistics->byteCount = GET_UINT32(*p_StatsCounters);
17395 +
17396 + for (i = 1; i <= p_CcNode->numOfStatsFLRs; i++)
17397 + {
17398 + p_StatsCounters =
17399 + PTR_MOVE(p_StatsCounters, FM_PCD_CC_STATS_COUNTER_SIZE);
17400 +
17401 + p_KeyStatistics->frameCount += GET_UINT32(*p_StatsCounters);
17402 +
17403 +#if (DPAA_VERSION >= 11)
17404 + p_KeyStatistics->frameLengthRangeCount[i - 1] =
17405 + GET_UINT32(*p_StatsCounters);
17406 +#endif /* (DPAA_VERSION >= 11) */
17407 + }
17408 +
17409 + return E_OK;
17410 +}
17411 +
17412 +static t_Error MatchTableSet(t_Handle h_FmPcd, t_FmPcdCcNode *p_CcNode,
17413 + t_FmPcdCcNodeParams *p_CcNodeParam)
17414 +{
17415 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
17416 + t_FmPcdCcNode *p_FmPcdCcNextNode;
17417 + t_Error err = E_OK;
17418 + uint32_t tmp, keySize;
17419 + bool glblMask = FALSE;
17420 + t_FmPcdCcKeyParams *p_KeyParams;
17421 + t_Handle h_FmMuram, p_KeysMatchTblTmp, p_AdTableTmp;
17422 +#if (DPAA_VERSION >= 11)
17423 + t_Handle h_StatsFLRs;
17424 +#endif /* (DPAA_VERSION >= 11) */
17425 + bool fullField = FALSE;
17426 + ccPrivateInfo_t icCode = CC_PRIVATE_INFO_NONE;
17427 + bool isKeyTblAlloc, fromIc = FALSE;
17428 + uint32_t matchTableSize, adTableSize;
17429 + t_CcNodeInformation ccNodeInfo, *p_CcInformation;
17430 + t_FmPcdStatsObj *p_StatsObj;
17431 + t_FmPcdCcStatsParams statsParams = { 0 };
17432 + t_Handle h_Manip;
17433 +
17434 + ASSERT_COND(h_FmPcd);
17435 + ASSERT_COND(p_CcNode);
17436 + ASSERT_COND(p_CcNodeParam);
17437 +
17438 + p_CcNode->p_GlblMask = (t_Handle)XX_Malloc(
17439 + CC_GLBL_MASK_SIZE * sizeof(uint8_t));
17440 + memset(p_CcNode->p_GlblMask, 0, CC_GLBL_MASK_SIZE * sizeof(uint8_t));
17441 +
17442 + p_CcNode->h_FmPcd = h_FmPcd;
17443 + p_CcNode->numOfKeys = p_CcNodeParam->keysParams.numOfKeys;
17444 + p_CcNode->maxNumOfKeys = p_CcNodeParam->keysParams.maxNumOfKeys;
17445 + p_CcNode->maskSupport = p_CcNodeParam->keysParams.maskSupport;
17446 + p_CcNode->statisticsMode = p_CcNodeParam->keysParams.statisticsMode;
17447 +
17448 + /* For backward compatibility - even if statistics mode is nullified,
17449 + we'll fix it to frame mode so we can support per-key request for
17450 + statistics using 'statisticsEn' in next engine parameters */
17451 + if (!p_CcNode->maxNumOfKeys
17452 + && (p_CcNode->statisticsMode == e_FM_PCD_CC_STATS_MODE_NONE))
17453 + p_CcNode->statisticsMode = e_FM_PCD_CC_STATS_MODE_FRAME;
17454 +
17455 + h_FmMuram = FmPcdGetMuramHandle(h_FmPcd);
17456 + if (!h_FmMuram)
17457 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("FM MURAM"));
17458 +
17459 + INIT_LIST(&p_CcNode->ccPrevNodesLst);
17460 + INIT_LIST(&p_CcNode->ccTreeIdLst);
17461 + INIT_LIST(&p_CcNode->ccTreesLst);
17462 + INIT_LIST(&p_CcNode->availableStatsLst);
17463 +
17464 + p_CcNode->h_Spinlock = XX_InitSpinlock();
17465 + if (!p_CcNode->h_Spinlock)
17466 + {
17467 + DeleteNode(p_CcNode);
17468 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("CC node spinlock"));
17469 + }
17470 +
17471 + if ((p_CcNodeParam->extractCcParams.type == e_FM_PCD_EXTRACT_BY_HDR)
17472 + && ((p_CcNodeParam->extractCcParams.extractByHdr.hdr
17473 + == HEADER_TYPE_IPv4)
17474 + || (p_CcNodeParam->extractCcParams.extractByHdr.hdr
17475 + == HEADER_TYPE_IPv6))
17476 + && (p_CcNodeParam->extractCcParams.extractByHdr.type
17477 + == e_FM_PCD_EXTRACT_FULL_FIELD)
17478 + && ((p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField.ipv6
17479 + == NET_HEADER_FIELD_IPv6_HOP_LIMIT)
17480 + || (p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField.ipv4
17481 + == NET_HEADER_FIELD_IPv4_TTL)))
17482 + {
17483 + err = Ipv4TtlOrIpv6HopLimitCheckParams(h_FmPcd, p_CcNodeParam, p_CcNode,
17484 + &isKeyTblAlloc);
17485 + glblMask = FALSE;
17486 + }
17487 + else
17488 + if ((p_CcNodeParam->extractCcParams.type == e_FM_PCD_EXTRACT_NON_HDR)
17489 + && ((p_CcNodeParam->extractCcParams.extractNonHdr.src
17490 + == e_FM_PCD_EXTRACT_FROM_KEY)
17491 + || (p_CcNodeParam->extractCcParams.extractNonHdr.src
17492 + == e_FM_PCD_EXTRACT_FROM_HASH)
17493 + || (p_CcNodeParam->extractCcParams.extractNonHdr.src
17494 + == e_FM_PCD_EXTRACT_FROM_FLOW_ID)))
17495 + {
17496 + if ((p_CcNodeParam->extractCcParams.extractNonHdr.src
17497 + == e_FM_PCD_EXTRACT_FROM_FLOW_ID)
17498 + && (p_CcNodeParam->extractCcParams.extractNonHdr.offset != 0))
17499 + {
17500 + DeleteNode(p_CcNode);
17501 + RETURN_ERROR(
17502 + MAJOR,
17503 + E_INVALID_VALUE,
17504 + ("In the case of the extraction from e_FM_PCD_EXTRACT_FROM_FLOW_ID offset has to be 0"));
17505 + }
17506 +
17507 + icCode = IcDefineCode(p_CcNodeParam);
17508 + fromIc = TRUE;
17509 + if (icCode == CC_PRIVATE_INFO_NONE)
17510 + {
17511 + DeleteNode(p_CcNode);
17512 + RETURN_ERROR(
17513 + MAJOR,
17514 + E_INVALID_STATE,
17515 + ("user asked extraction from IC and field in internal context or action wasn't initialized in the right way"));
17516 + }
17517 +
17518 + if ((icCode == CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP)
17519 + || (icCode == CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP))
17520 + {
17521 + err = IcHashIndexedCheckParams(h_FmPcd, p_CcNodeParam, p_CcNode,
17522 + &isKeyTblAlloc);
17523 + glblMask = TRUE;
17524 + }
17525 + else
17526 + {
17527 + err = CheckParams(h_FmPcd, p_CcNodeParam, p_CcNode,
17528 + &isKeyTblAlloc);
17529 + if (p_CcNode->glblMaskSize)
17530 + glblMask = TRUE;
17531 + }
17532 + }
17533 + else
17534 + {
17535 + err = CheckParams(h_FmPcd, p_CcNodeParam, p_CcNode, &isKeyTblAlloc);
17536 + if (p_CcNode->glblMaskSize)
17537 + glblMask = TRUE;
17538 + }
17539 +
17540 + if (err)
17541 + {
17542 + DeleteNode(p_CcNode);
17543 + RETURN_ERROR(MAJOR, err, NO_MSG);
17544 + }
17545 +
17546 + switch (p_CcNodeParam->extractCcParams.type)
17547 + {
17548 + case (e_FM_PCD_EXTRACT_BY_HDR):
17549 + switch (p_CcNodeParam->extractCcParams.extractByHdr.type)
17550 + {
17551 + case (e_FM_PCD_EXTRACT_FULL_FIELD):
17552 + p_CcNode->parseCode =
17553 + GetFullFieldParseCode(
17554 + p_CcNodeParam->extractCcParams.extractByHdr.hdr,
17555 + p_CcNodeParam->extractCcParams.extractByHdr.hdrIndex,
17556 + p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField);
17557 + GetSizeHeaderField(
17558 + p_CcNodeParam->extractCcParams.extractByHdr.hdr,
17559 + p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField,
17560 + &p_CcNode->sizeOfExtraction);
17561 + fullField = TRUE;
17562 + if ((p_CcNode->parseCode != CC_PC_FF_TCI1)
17563 + && (p_CcNode->parseCode != CC_PC_FF_TCI2)
17564 + && (p_CcNode->parseCode != CC_PC_FF_MPLS1)
17565 + && (p_CcNode->parseCode != CC_PC_FF_MPLS_LAST)
17566 + && (p_CcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC1)
17567 + && (p_CcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC2)
17568 + && (p_CcNode->parseCode
17569 + != CC_PC_FF_IPTOS_IPV6TC1_IPV6FLOW1)
17570 + && (p_CcNode->parseCode != CC_PC_FF_IPDSCP)
17571 + && (p_CcNode->parseCode
17572 + != CC_PC_FF_IPTOS_IPV6TC2_IPV6FLOW2)
17573 + && glblMask)
17574 + {
17575 + glblMask = FALSE;
17576 + p_CcNode->glblMaskSize = 4;
17577 + p_CcNode->lclMask = TRUE;
17578 + }
17579 + break;
17580 +
17581 + case (e_FM_PCD_EXTRACT_FROM_HDR):
17582 + p_CcNode->sizeOfExtraction =
17583 + p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromHdr.size;
17584 + p_CcNode->offset =
17585 + p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromHdr.offset;
17586 + p_CcNode->userOffset =
17587 + p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromHdr.offset;
17588 + p_CcNode->parseCode =
17589 + GetPrParseCode(
17590 + p_CcNodeParam->extractCcParams.extractByHdr.hdr,
17591 + p_CcNodeParam->extractCcParams.extractByHdr.hdrIndex,
17592 + p_CcNode->offset, glblMask,
17593 + &p_CcNode->prsArrayOffset);
17594 + break;
17595 +
17596 + case (e_FM_PCD_EXTRACT_FROM_FIELD):
17597 + p_CcNode->offset =
17598 + p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.offset;
17599 + p_CcNode->userOffset =
17600 + p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.offset;
17601 + p_CcNode->sizeOfExtraction =
17602 + p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.size;
17603 + p_CcNode->parseCode =
17604 + GetFieldParseCode(
17605 + p_CcNodeParam->extractCcParams.extractByHdr.hdr,
17606 + p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.field,
17607 + p_CcNode->offset,
17608 + &p_CcNode->prsArrayOffset,
17609 + p_CcNodeParam->extractCcParams.extractByHdr.hdrIndex);
17610 + break;
17611 +
17612 + default:
17613 + DeleteNode(p_CcNode);
17614 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
17615 + }
17616 + break;
17617 +
17618 + case (e_FM_PCD_EXTRACT_NON_HDR):
17619 + /* get the field code for the generic extract */
17620 + p_CcNode->sizeOfExtraction =
17621 + p_CcNodeParam->extractCcParams.extractNonHdr.size;
17622 + p_CcNode->offset =
17623 + p_CcNodeParam->extractCcParams.extractNonHdr.offset;
17624 + p_CcNode->userOffset =
17625 + p_CcNodeParam->extractCcParams.extractNonHdr.offset;
17626 + p_CcNode->parseCode = GetGenParseCode(
17627 + p_CcNodeParam->extractCcParams.extractNonHdr.src,
17628 + p_CcNode->offset, glblMask, &p_CcNode->prsArrayOffset,
17629 + fromIc, icCode);
17630 +
17631 + if (p_CcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED)
17632 + {
17633 + if ((p_CcNode->offset + p_CcNode->sizeOfExtraction) > 8)
17634 + {
17635 + DeleteNode(p_CcNode);
17636 + RETURN_ERROR(
17637 + MAJOR,
17638 + E_INVALID_SELECTION,
17639 + ("when node of the type CC_PC_GENERIC_IC_HASH_INDEXED offset + size can not be bigger then size of HASH 64 bits (8 bytes)"));
17640 + }
17641 + }
17642 + if ((p_CcNode->parseCode == CC_PC_GENERIC_IC_GMASK)
17643 + || (p_CcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED))
17644 + {
17645 + p_CcNode->offset += p_CcNode->prsArrayOffset;
17646 + p_CcNode->prsArrayOffset = 0;
17647 + }
17648 + break;
17649 +
17650 + default:
17651 + DeleteNode(p_CcNode);
17652 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
17653 + }
17654 +
17655 + if (p_CcNode->parseCode == CC_PC_ILLEGAL)
17656 + {
17657 + DeleteNode(p_CcNode);
17658 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("illegal extraction type"));
17659 + }
17660 +
17661 + if ((p_CcNode->sizeOfExtraction > FM_PCD_MAX_SIZE_OF_KEY)
17662 + || !p_CcNode->sizeOfExtraction)
17663 + {
17664 + DeleteNode(p_CcNode);
17665 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
17666 + ("sizeOfExatrction can not be greater than 56 and not 0"));
17667 + }
17668 +
17669 + if (p_CcNodeParam->keysParams.keySize != p_CcNode->sizeOfExtraction)
17670 + {
17671 + DeleteNode(p_CcNode);
17672 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
17673 + ("keySize has to be equal to sizeOfExtraction"));
17674 + }
17675 +
17676 + p_CcNode->userSizeOfExtraction = p_CcNode->sizeOfExtraction;
17677 +
17678 + if (!glblMask)
17679 + memset(p_CcNode->p_GlblMask, 0xff, CC_GLBL_MASK_SIZE * sizeof(uint8_t));
17680 +
17681 + err = CheckAndSetManipParamsWithCcNodeParams(p_CcNode);
17682 + if (err != E_OK)
17683 + {
17684 + DeleteNode(p_CcNode);
17685 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
17686 + ("keySize has to be equal to sizeOfExtraction"));
17687 + }
17688 +
17689 + /* Calculating matching table entry size by rounding up the user-defined size of extraction to valid entry size */
17690 + GetCcExtractKeySize(p_CcNode->sizeOfExtraction,
17691 + &p_CcNode->ccKeySizeAccExtraction);
17692 +
17693 + /* If local mask is used, it is stored next to each key in the keys match table */
17694 + if (p_CcNode->lclMask)
17695 + keySize = (uint32_t)(2 * p_CcNode->ccKeySizeAccExtraction);
17696 + else
17697 + keySize = p_CcNode->ccKeySizeAccExtraction;
17698 +
17699 + /* Update CC shadow with maximal size required by this node */
17700 + if (p_CcNode->maxNumOfKeys)
17701 + {
17702 + err = CalcAndUpdateCcShadow(p_CcNode, isKeyTblAlloc, &matchTableSize,
17703 + &adTableSize);
17704 + if (err != E_OK)
17705 + {
17706 + DeleteNode(p_CcNode);
17707 + RETURN_ERROR(MAJOR, err, NO_MSG);
17708 + }
17709 +
17710 + p_CcNode->keysMatchTableMaxSize = matchTableSize;
17711 +
17712 + if (p_CcNode->statisticsMode != e_FM_PCD_CC_STATS_MODE_NONE)
17713 + {
17714 + err = AllocStatsObjs(p_CcNode);
17715 + if (err != E_OK)
17716 + {
17717 + DeleteNode(p_CcNode);
17718 + RETURN_ERROR(MAJOR, err, NO_MSG);
17719 + }
17720 + }
17721 +
17722 + /* If manipulation will be initialized before this node, it will use the table
17723 + descriptor in the AD table of previous node and this node will need an extra
17724 + AD as his table descriptor. */
17725 + p_CcNode->h_TmpAd = (t_Handle)FM_MURAM_AllocMem(
17726 + h_FmMuram, FM_PCD_CC_AD_ENTRY_SIZE, FM_PCD_CC_AD_TABLE_ALIGN);
17727 + if (!p_CcNode->h_TmpAd)
17728 + {
17729 + DeleteNode(p_CcNode);
17730 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
17731 + ("MURAM allocation for CC action descriptor"));
17732 + }
17733 + }
17734 + else
17735 + {
17736 + matchTableSize = (uint32_t)(keySize * sizeof(uint8_t)
17737 + * (p_CcNode->numOfKeys + 1));
17738 + adTableSize = (uint32_t)(FM_PCD_CC_AD_ENTRY_SIZE
17739 + * (p_CcNode->numOfKeys + 1));
17740 + }
17741 +
17742 +#if (DPAA_VERSION >= 11)
17743 + switch (p_CcNode->statisticsMode)
17744 + {
17745 +
17746 + case e_FM_PCD_CC_STATS_MODE_RMON:
17747 + /* If RMON statistics or RMON conditional statistics modes are requested,
17748 + allocate frame length ranges array */
17749 + p_CcNode->h_StatsFLRs = FM_MURAM_AllocMem(
17750 + h_FmMuram,
17751 + (uint32_t)(p_CcNode->numOfStatsFLRs)
17752 + * FM_PCD_CC_STATS_FLR_SIZE,
17753 + FM_PCD_CC_AD_TABLE_ALIGN);
17754 +
17755 + if (!p_CcNode->h_StatsFLRs)
17756 + {
17757 + DeleteNode(p_CcNode);
17758 + RETURN_ERROR(
17759 + MAJOR, E_NO_MEMORY,
17760 + ("MURAM allocation for CC frame length ranges array"));
17761 + }
17762 +
17763 + /* Initialize using value received from the user */
17764 + for (tmp = 0; tmp < p_CcNode->numOfStatsFLRs; tmp++)
17765 + {
17766 + uint16_t flr =
17767 + cpu_to_be16(p_CcNodeParam->keysParams.frameLengthRanges[tmp]);
17768 +
17769 + h_StatsFLRs =
17770 + PTR_MOVE(p_CcNode->h_StatsFLRs, tmp * FM_PCD_CC_STATS_FLR_SIZE);
17771 +
17772 + MemCpy8(h_StatsFLRs,
17773 + &flr,
17774 + FM_PCD_CC_STATS_FLR_SIZE);
17775 + }
17776 + break;
17777 +
17778 + default:
17779 + break;
17780 + }
17781 +#endif /* (DPAA_VERSION >= 11) */
17782 +
17783 + /* Allocate keys match table. Not required for some CC nodes, for example for IPv4 TTL
17784 + identification, IPv6 hop count identification, etc. */
17785 + if (isKeyTblAlloc)
17786 + {
17787 + p_CcNode->h_KeysMatchTable = (t_Handle)FM_MURAM_AllocMem(
17788 + h_FmMuram, matchTableSize, FM_PCD_CC_KEYS_MATCH_TABLE_ALIGN);
17789 + if (!p_CcNode->h_KeysMatchTable)
17790 + {
17791 + DeleteNode(p_CcNode);
17792 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
17793 + ("MURAM allocation for CC node key match table"));
17794 + }
17795 + MemSet8((uint8_t *)p_CcNode->h_KeysMatchTable, 0, matchTableSize);
17796 + }
17797 +
17798 + /* Allocate action descriptors table */
17799 + p_CcNode->h_AdTable = (t_Handle)FM_MURAM_AllocMem(h_FmMuram, adTableSize,
17800 + FM_PCD_CC_AD_TABLE_ALIGN);
17801 + if (!p_CcNode->h_AdTable)
17802 + {
17803 + DeleteNode(p_CcNode);
17804 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
17805 + ("MURAM allocation for CC node action descriptors table"));
17806 + }
17807 + MemSet8((uint8_t *)p_CcNode->h_AdTable, 0, adTableSize);
17808 +
17809 + p_KeysMatchTblTmp = p_CcNode->h_KeysMatchTable;
17810 + p_AdTableTmp = p_CcNode->h_AdTable;
17811 +
17812 + /* For each key, create the key and the next step AD */
17813 + for (tmp = 0; tmp < p_CcNode->numOfKeys; tmp++)
17814 + {
17815 + p_KeyParams = &p_CcNodeParam->keysParams.keyParams[tmp];
17816 +
17817 + if (p_KeysMatchTblTmp)
17818 + {
17819 + /* Copy the key */
17820 + MemCpy8((void*)p_KeysMatchTblTmp, p_KeyParams->p_Key,
17821 + p_CcNode->sizeOfExtraction);
17822 +
17823 + /* Copy the key mask or initialize it to 0xFF..F */
17824 + if (p_CcNode->lclMask && p_KeyParams->p_Mask)
17825 + {
17826 + MemCpy8(PTR_MOVE(p_KeysMatchTblTmp,
17827 + p_CcNode->ccKeySizeAccExtraction), /* User's size of extraction rounded up to a valid matching table entry size */
17828 + p_KeyParams->p_Mask, p_CcNode->sizeOfExtraction); /* Exact size of extraction as received from the user */
17829 + }
17830 + else
17831 + if (p_CcNode->lclMask)
17832 + {
17833 + MemSet8(PTR_MOVE(p_KeysMatchTblTmp,
17834 + p_CcNode->ccKeySizeAccExtraction), /* User's size of extraction rounded up to a valid matching table entry size */
17835 + 0xff, p_CcNode->sizeOfExtraction); /* Exact size of extraction as received from the user */
17836 + }
17837 +
17838 + p_KeysMatchTblTmp =
17839 + PTR_MOVE(p_KeysMatchTblTmp, keySize * sizeof(uint8_t));
17840 + }
17841 +
17842 + /* Create the next action descriptor in the match table */
17843 + if (p_KeyParams->ccNextEngineParams.statisticsEn)
17844 + {
17845 + p_StatsObj = GetStatsObj(p_CcNode);
17846 + ASSERT_COND(p_StatsObj);
17847 +
17848 + statsParams.h_StatsAd = p_StatsObj->h_StatsAd;
17849 + statsParams.h_StatsCounters = p_StatsObj->h_StatsCounters;
17850 +#if (DPAA_VERSION >= 11)
17851 + statsParams.h_StatsFLRs = p_CcNode->h_StatsFLRs;
17852 +
17853 +#endif /* (DPAA_VERSION >= 11) */
17854 + NextStepAd(p_AdTableTmp, &statsParams,
17855 + &p_KeyParams->ccNextEngineParams, p_FmPcd);
17856 +
17857 + p_CcNode->keyAndNextEngineParams[tmp].p_StatsObj = p_StatsObj;
17858 + }
17859 + else
17860 + {
17861 + NextStepAd(p_AdTableTmp, NULL, &p_KeyParams->ccNextEngineParams,
17862 + p_FmPcd);
17863 +
17864 + p_CcNode->keyAndNextEngineParams[tmp].p_StatsObj = NULL;
17865 + }
17866 +
17867 + p_AdTableTmp = PTR_MOVE(p_AdTableTmp, FM_PCD_CC_AD_ENTRY_SIZE);
17868 + }
17869 +
17870 + /* Update next engine for the 'miss' entry */
17871 + if (p_CcNodeParam->keysParams.ccNextEngineParamsForMiss.statisticsEn)
17872 + {
17873 + p_StatsObj = GetStatsObj(p_CcNode);
17874 + ASSERT_COND(p_StatsObj);
17875 +
17876 + /* All 'bucket' nodes of a hash table should share the same statistics counters,
17877 + allocated by the hash table. So, if this node is a bucket of a hash table,
17878 + we'll replace the locally allocated counters with the shared counters. */
17879 + if (p_CcNode->isHashBucket)
17880 + {
17881 + ASSERT_COND(p_CcNode->h_MissStatsCounters);
17882 +
17883 + /* Store original counters pointer and replace it with mutual preallocated pointer */
17884 + p_CcNode->h_PrivMissStatsCounters = p_StatsObj->h_StatsCounters;
17885 + p_StatsObj->h_StatsCounters = p_CcNode->h_MissStatsCounters;
17886 + }
17887 +
17888 + statsParams.h_StatsAd = p_StatsObj->h_StatsAd;
17889 + statsParams.h_StatsCounters = p_StatsObj->h_StatsCounters;
17890 +#if (DPAA_VERSION >= 11)
17891 + statsParams.h_StatsFLRs = p_CcNode->h_StatsFLRs;
17892 +
17893 +#endif /* (DPAA_VERSION >= 11) */
17894 +
17895 + NextStepAd(p_AdTableTmp, &statsParams,
17896 + &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
17897 + p_FmPcd);
17898 +
17899 + p_CcNode->keyAndNextEngineParams[tmp].p_StatsObj = p_StatsObj;
17900 + }
17901 + else
17902 + {
17903 + NextStepAd(p_AdTableTmp, NULL,
17904 + &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
17905 + p_FmPcd);
17906 +
17907 + p_CcNode->keyAndNextEngineParams[tmp].p_StatsObj = NULL;
17908 + }
17909 +
17910 + /* This parameter will be used to initialize the "key length" field in the action descriptor
17911 + that points to this node and it should be 0 for full field extraction */
17912 + if (fullField == TRUE)
17913 + p_CcNode->sizeOfExtraction = 0;
17914 +
17915 + for (tmp = 0; tmp < MIN(p_CcNode->numOfKeys + 1, CC_MAX_NUM_OF_KEYS); tmp++)
17916 + {
17917 + if (p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.nextEngine
17918 + == e_FM_PCD_CC)
17919 + {
17920 + p_FmPcdCcNextNode =
17921 + (t_FmPcdCcNode*)p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.params.ccParams.h_CcNode;
17922 + p_CcInformation = FindNodeInfoInReleventLst(
17923 + &p_FmPcdCcNextNode->ccPrevNodesLst, (t_Handle)p_CcNode,
17924 + p_FmPcdCcNextNode->h_Spinlock);
17925 + if (!p_CcInformation)
17926 + {
17927 + memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
17928 + ccNodeInfo.h_CcNode = (t_Handle)p_CcNode;
17929 + ccNodeInfo.index = 1;
17930 + EnqueueNodeInfoToRelevantLst(&p_FmPcdCcNextNode->ccPrevNodesLst,
17931 + &ccNodeInfo,
17932 + p_FmPcdCcNextNode->h_Spinlock);
17933 + }
17934 + else
17935 + p_CcInformation->index++;
17936 +
17937 + if (p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip)
17938 + {
17939 + h_Manip =
17940 + p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip;
17941 + p_CcInformation = FindNodeInfoInReleventLst(
17942 + FmPcdManipGetNodeLstPointedOnThisManip(h_Manip),
17943 + (t_Handle)p_CcNode, FmPcdManipGetSpinlock(h_Manip));
17944 + if (!p_CcInformation)
17945 + {
17946 + memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
17947 + ccNodeInfo.h_CcNode = (t_Handle)p_CcNode;
17948 + ccNodeInfo.index = 1;
17949 + EnqueueNodeInfoToRelevantLst(
17950 + FmPcdManipGetNodeLstPointedOnThisManip(h_Manip),
17951 + &ccNodeInfo, FmPcdManipGetSpinlock(h_Manip));
17952 + }
17953 + else
17954 + p_CcInformation->index++;
17955 + }
17956 + }
17957 + }
17958 +
17959 + p_AdTableTmp = p_CcNode->h_AdTable;
17960 +
17961 + if (!FmPcdLockTryLockAll(h_FmPcd))
17962 + {
17963 + FM_PCD_MatchTableDelete((t_Handle)p_CcNode);
17964 + DBG(TRACE, ("FmPcdLockTryLockAll failed"));
17965 + return ERROR_CODE(E_BUSY);
17966 + }
17967 +
17968 + /* Required action for each next engine */
17969 + for (tmp = 0; tmp < MIN(p_CcNode->numOfKeys + 1, CC_MAX_NUM_OF_KEYS); tmp++)
17970 + {
17971 + if (p_CcNode->keyAndNextEngineParams[tmp].requiredAction)
17972 + {
17973 + err = SetRequiredAction(
17974 + h_FmPcd,
17975 + p_CcNode->keyAndNextEngineParams[tmp].requiredAction,
17976 + &p_CcNode->keyAndNextEngineParams[tmp], p_AdTableTmp, 1,
17977 + NULL);
17978 + if (err)
17979 + {
17980 + FmPcdLockUnlockAll(h_FmPcd);
17981 + FM_PCD_MatchTableDelete((t_Handle)p_CcNode);
17982 + RETURN_ERROR(MAJOR, err, NO_MSG);
17983 + }
17984 + p_AdTableTmp = PTR_MOVE(p_AdTableTmp, FM_PCD_CC_AD_ENTRY_SIZE);
17985 + }
17986 + }
17987 +
17988 + FmPcdLockUnlockAll(h_FmPcd);
17989 +
17990 + return E_OK;
17991 +}
17992 +/************************** End of static functions **************************/
17993 +
17994 +/*****************************************************************************/
17995 +/* Inter-module API routines */
17996 +/*****************************************************************************/
17997 +
17998 +t_CcNodeInformation* FindNodeInfoInReleventLst(t_List *p_List, t_Handle h_Info,
17999 + t_Handle h_Spinlock)
18000 +{
18001 + t_CcNodeInformation *p_CcInformation;
18002 + t_List *p_Pos;
18003 + uint32_t intFlags;
18004 +
18005 + intFlags = XX_LockIntrSpinlock(h_Spinlock);
18006 +
18007 + for (p_Pos = LIST_FIRST(p_List); p_Pos != (p_List);
18008 + p_Pos = LIST_NEXT(p_Pos))
18009 + {
18010 + p_CcInformation = CC_NODE_F_OBJECT(p_Pos);
18011 +
18012 + ASSERT_COND(p_CcInformation->h_CcNode);
18013 +
18014 + if (p_CcInformation->h_CcNode == h_Info)
18015 + {
18016 + XX_UnlockIntrSpinlock(h_Spinlock, intFlags);
18017 + return p_CcInformation;
18018 + }
18019 + }
18020 +
18021 + XX_UnlockIntrSpinlock(h_Spinlock, intFlags);
18022 +
18023 + return NULL;
18024 +}
18025 +
18026 +void EnqueueNodeInfoToRelevantLst(t_List *p_List, t_CcNodeInformation *p_CcInfo,
18027 + t_Handle h_Spinlock)
18028 +{
18029 + t_CcNodeInformation *p_CcInformation;
18030 + uint32_t intFlags = 0;
18031 +
18032 + p_CcInformation = (t_CcNodeInformation *)XX_Malloc(
18033 + sizeof(t_CcNodeInformation));
18034 +
18035 + if (p_CcInformation)
18036 + {
18037 + memset(p_CcInformation, 0, sizeof(t_CcNodeInformation));
18038 + memcpy(p_CcInformation, p_CcInfo, sizeof(t_CcNodeInformation));
18039 + INIT_LIST(&p_CcInformation->node);
18040 +
18041 + if (h_Spinlock)
18042 + intFlags = XX_LockIntrSpinlock(h_Spinlock);
18043 +
18044 + LIST_AddToTail(&p_CcInformation->node, p_List);
18045 +
18046 + if (h_Spinlock)
18047 + XX_UnlockIntrSpinlock(h_Spinlock, intFlags);
18048 + }
18049 + else
18050 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("CC Node Information"));
18051 +}
18052 +
18053 +void DequeueNodeInfoFromRelevantLst(t_List *p_List, t_Handle h_Info,
18054 + t_Handle h_Spinlock)
18055 +{
18056 + t_CcNodeInformation *p_CcInformation = NULL;
18057 + uint32_t intFlags = 0;
18058 + t_List *p_Pos;
18059 +
18060 + if (h_Spinlock)
18061 + intFlags = XX_LockIntrSpinlock(h_Spinlock);
18062 +
18063 + if (LIST_IsEmpty(p_List))
18064 + {
18065 + XX_RestoreAllIntr(intFlags);
18066 + return;
18067 + }
18068 +
18069 + for (p_Pos = LIST_FIRST(p_List); p_Pos != (p_List);
18070 + p_Pos = LIST_NEXT(p_Pos))
18071 + {
18072 + p_CcInformation = CC_NODE_F_OBJECT(p_Pos);
18073 + ASSERT_COND(p_CcInformation);
18074 + ASSERT_COND(p_CcInformation->h_CcNode);
18075 + if (p_CcInformation->h_CcNode == h_Info)
18076 + break;
18077 + }
18078 +
18079 + if (p_CcInformation)
18080 + {
18081 + LIST_DelAndInit(&p_CcInformation->node);
18082 + XX_Free(p_CcInformation);
18083 + }
18084 +
18085 + if (h_Spinlock)
18086 + XX_UnlockIntrSpinlock(h_Spinlock, intFlags);
18087 +}
18088 +
18089 +void NextStepAd(t_Handle h_Ad, t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,
18090 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,
18091 + t_FmPcd *p_FmPcd)
18092 +{
18093 + switch (p_FmPcdCcNextEngineParams->nextEngine)
18094 + {
18095 + case (e_FM_PCD_KG):
18096 + case (e_FM_PCD_PLCR):
18097 + case (e_FM_PCD_DONE):
18098 + /* if NIA is not CC, create a "result" type AD */
18099 + FillAdOfTypeResult(h_Ad, p_FmPcdCcStatsParams, p_FmPcd,
18100 + p_FmPcdCcNextEngineParams);
18101 + break;
18102 +#if (DPAA_VERSION >= 11)
18103 + case (e_FM_PCD_FR):
18104 + if (p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic)
18105 + {
18106 + FillAdOfTypeContLookup(
18107 + h_Ad, p_FmPcdCcStatsParams, p_FmPcd,
18108 + p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode,
18109 + p_FmPcdCcNextEngineParams->h_Manip,
18110 + p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic);
18111 + FrmReplicGroupUpdateOwner(
18112 + p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic,
18113 + TRUE/* add */);
18114 + }
18115 + break;
18116 +#endif /* (DPAA_VERSION >= 11) */
18117 +
18118 + case (e_FM_PCD_CC):
18119 + /* if NIA is not CC, create a TD to continue the CC lookup */
18120 + FillAdOfTypeContLookup(
18121 + h_Ad, p_FmPcdCcStatsParams, p_FmPcd,
18122 + p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode,
18123 + p_FmPcdCcNextEngineParams->h_Manip, NULL);
18124 +
18125 + UpdateNodeOwner(p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode,
18126 + TRUE);
18127 + break;
18128 +
18129 + default:
18130 + return;
18131 + }
18132 +}
18133 +
18134 +t_Error FmPcdCcTreeAddIPR(t_Handle h_FmPcd, t_Handle h_FmTree,
18135 + t_Handle h_NetEnv, t_Handle h_IpReassemblyManip,
18136 + bool createSchemes)
18137 +{
18138 + t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;
18139 + t_FmPcdCcNextEngineParams nextEngineParams;
18140 + t_NetEnvParams netEnvParams;
18141 + t_Handle h_Ad;
18142 + bool isIpv6Present;
18143 + uint8_t ipv4GroupId, ipv6GroupId;
18144 + t_Error err;
18145 +
18146 + ASSERT_COND(p_FmPcdCcTree);
18147 +
18148 + /* this routine must be protected by the calling routine! */
18149 +
18150 + memset(&nextEngineParams, 0, sizeof(t_FmPcdCcNextEngineParams));
18151 + memset(&netEnvParams, 0, sizeof(t_NetEnvParams));
18152 +
18153 + h_Ad = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);
18154 +
18155 + isIpv6Present = FmPcdManipIpReassmIsIpv6Hdr(h_IpReassemblyManip);
18156 +
18157 + if (isIpv6Present
18158 + && (p_FmPcdCcTree->numOfEntries > (FM_PCD_MAX_NUM_OF_CC_GROUPS - 2)))
18159 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("need two free entries for IPR"));
18160 +
18161 + if (p_FmPcdCcTree->numOfEntries > (FM_PCD_MAX_NUM_OF_CC_GROUPS - 1))
18162 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("need two free entries for IPR"));
18163 +
18164 + nextEngineParams.nextEngine = e_FM_PCD_DONE;
18165 + nextEngineParams.h_Manip = h_IpReassemblyManip;
18166 +
18167 + /* Lock tree */
18168 + err = CcRootTryLock(p_FmPcdCcTree);
18169 + if (err)
18170 + return ERROR_CODE(E_BUSY);
18171 +
18172 + if (p_FmPcdCcTree->h_IpReassemblyManip == h_IpReassemblyManip)
18173 + {
18174 + CcRootReleaseLock(p_FmPcdCcTree);
18175 + return E_OK;
18176 + }
18177 +
18178 + if ((p_FmPcdCcTree->h_IpReassemblyManip)
18179 + && (p_FmPcdCcTree->h_IpReassemblyManip != h_IpReassemblyManip))
18180 + {
18181 + CcRootReleaseLock(p_FmPcdCcTree);
18182 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
18183 + ("This tree was previously updated with different IPR"));
18184 + }
18185 +
18186 + /* Initialize IPR for the first time for this tree */
18187 + if (isIpv6Present)
18188 + {
18189 + ipv6GroupId = p_FmPcdCcTree->numOfGrps++;
18190 + p_FmPcdCcTree->fmPcdGroupParam[ipv6GroupId].baseGroupEntry =
18191 + (FM_PCD_MAX_NUM_OF_CC_GROUPS - 2);
18192 +
18193 + if (createSchemes)
18194 + {
18195 + err = FmPcdManipBuildIpReassmScheme(h_FmPcd, h_NetEnv,
18196 + p_FmPcdCcTree,
18197 + h_IpReassemblyManip, FALSE,
18198 + ipv6GroupId);
18199 + if (err)
18200 + {
18201 + p_FmPcdCcTree->numOfGrps--;
18202 + CcRootReleaseLock(p_FmPcdCcTree);
18203 + RETURN_ERROR(MAJOR, err, NO_MSG);
18204 + }
18205 + }
18206 +
18207 + NextStepAd(
18208 + PTR_MOVE(h_Ad, (FM_PCD_MAX_NUM_OF_CC_GROUPS-2) * FM_PCD_CC_AD_ENTRY_SIZE),
18209 + NULL, &nextEngineParams, h_FmPcd);
18210 + }
18211 +
18212 + ipv4GroupId = p_FmPcdCcTree->numOfGrps++;
18213 + p_FmPcdCcTree->fmPcdGroupParam[ipv4GroupId].totalBitsMask = 0;
18214 + p_FmPcdCcTree->fmPcdGroupParam[ipv4GroupId].baseGroupEntry =
18215 + (FM_PCD_MAX_NUM_OF_CC_GROUPS - 1);
18216 +
18217 + if (createSchemes)
18218 + {
18219 + err = FmPcdManipBuildIpReassmScheme(h_FmPcd, h_NetEnv, p_FmPcdCcTree,
18220 + h_IpReassemblyManip, TRUE,
18221 + ipv4GroupId);
18222 + if (err)
18223 + {
18224 + p_FmPcdCcTree->numOfGrps--;
18225 + if (isIpv6Present)
18226 + {
18227 + p_FmPcdCcTree->numOfGrps--;
18228 + FmPcdManipDeleteIpReassmSchemes(h_IpReassemblyManip);
18229 + }
18230 + CcRootReleaseLock(p_FmPcdCcTree);
18231 + RETURN_ERROR(MAJOR, err, NO_MSG);
18232 + }
18233 + }
18234 +
18235 + NextStepAd(
18236 + PTR_MOVE(h_Ad, (FM_PCD_MAX_NUM_OF_CC_GROUPS-1) * FM_PCD_CC_AD_ENTRY_SIZE),
18237 + NULL, &nextEngineParams, h_FmPcd);
18238 +
18239 + p_FmPcdCcTree->h_IpReassemblyManip = h_IpReassemblyManip;
18240 +
18241 + CcRootReleaseLock(p_FmPcdCcTree);
18242 +
18243 + return E_OK;
18244 +}
18245 +
18246 +t_Error FmPcdCcTreeAddCPR(t_Handle h_FmPcd, t_Handle h_FmTree,
18247 + t_Handle h_NetEnv, t_Handle h_ReassemblyManip,
18248 + bool createSchemes)
18249 +{
18250 + t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;
18251 + t_FmPcdCcNextEngineParams nextEngineParams;
18252 + t_NetEnvParams netEnvParams;
18253 + t_Handle h_Ad;
18254 + uint8_t groupId;
18255 + t_Error err;
18256 +
18257 + ASSERT_COND(p_FmPcdCcTree);
18258 +
18259 + /* this routine must be protected by the calling routine! */
18260 + memset(&nextEngineParams, 0, sizeof(t_FmPcdCcNextEngineParams));
18261 + memset(&netEnvParams, 0, sizeof(t_NetEnvParams));
18262 +
18263 + h_Ad = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);
18264 +
18265 + if (p_FmPcdCcTree->numOfEntries > (FM_PCD_MAX_NUM_OF_CC_GROUPS - 1))
18266 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("need one free entries for CPR"));
18267 +
18268 + nextEngineParams.nextEngine = e_FM_PCD_DONE;
18269 + nextEngineParams.h_Manip = h_ReassemblyManip;
18270 +
18271 + /* Lock tree */
18272 + err = CcRootTryLock(p_FmPcdCcTree);
18273 + if (err)
18274 + return ERROR_CODE(E_BUSY);
18275 +
18276 + if (p_FmPcdCcTree->h_CapwapReassemblyManip == h_ReassemblyManip)
18277 + {
18278 + CcRootReleaseLock(p_FmPcdCcTree);
18279 + return E_OK;
18280 + }
18281 +
18282 + if ((p_FmPcdCcTree->h_CapwapReassemblyManip)
18283 + && (p_FmPcdCcTree->h_CapwapReassemblyManip != h_ReassemblyManip))
18284 + {
18285 + CcRootReleaseLock(p_FmPcdCcTree);
18286 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
18287 + ("This tree was previously updated with different CPR"));
18288 + }
18289 +
18290 + groupId = p_FmPcdCcTree->numOfGrps++;
18291 + p_FmPcdCcTree->fmPcdGroupParam[groupId].baseGroupEntry =
18292 + (FM_PCD_MAX_NUM_OF_CC_GROUPS - 1);
18293 +
18294 + if (createSchemes)
18295 + {
18296 + err = FmPcdManipBuildCapwapReassmScheme(h_FmPcd, h_NetEnv,
18297 + p_FmPcdCcTree,
18298 + h_ReassemblyManip, groupId);
18299 + if (err)
18300 + {
18301 + p_FmPcdCcTree->numOfGrps--;
18302 + CcRootReleaseLock(p_FmPcdCcTree);
18303 + RETURN_ERROR(MAJOR, err, NO_MSG);
18304 + }
18305 + }
18306 +
18307 + NextStepAd(
18308 + PTR_MOVE(h_Ad, (FM_PCD_MAX_NUM_OF_CC_GROUPS-1) * FM_PCD_CC_AD_ENTRY_SIZE),
18309 + NULL, &nextEngineParams, h_FmPcd);
18310 +
18311 + p_FmPcdCcTree->h_CapwapReassemblyManip = h_ReassemblyManip;
18312 +
18313 + CcRootReleaseLock(p_FmPcdCcTree);
18314 +
18315 + return E_OK;
18316 +}
18317 +
18318 +t_Handle FmPcdCcTreeGetSavedManipParams(t_Handle h_FmTree)
18319 +{
18320 + t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;
18321 +
18322 + ASSERT_COND(p_FmPcdCcTree);
18323 +
18324 + return p_FmPcdCcTree->h_FmPcdCcSavedManipParams;
18325 +}
18326 +
18327 +void FmPcdCcTreeSetSavedManipParams(t_Handle h_FmTree,
18328 + t_Handle h_SavedManipParams)
18329 +{
18330 + t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;
18331 +
18332 + ASSERT_COND(p_FmPcdCcTree);
18333 +
18334 + p_FmPcdCcTree->h_FmPcdCcSavedManipParams = h_SavedManipParams;
18335 +}
18336 +
18337 +uint8_t FmPcdCcGetParseCode(t_Handle h_CcNode)
18338 +{
18339 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
18340 +
18341 + ASSERT_COND(p_CcNode);
18342 +
18343 + return p_CcNode->parseCode;
18344 +}
18345 +
18346 +uint8_t FmPcdCcGetOffset(t_Handle h_CcNode)
18347 +{
18348 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
18349 +
18350 + ASSERT_COND(p_CcNode);
18351 +
18352 + return p_CcNode->offset;
18353 +}
18354 +
18355 +uint16_t FmPcdCcGetNumOfKeys(t_Handle h_CcNode)
18356 +{
18357 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
18358 +
18359 + ASSERT_COND(p_CcNode);
18360 +
18361 + return p_CcNode->numOfKeys;
18362 +}
18363 +
18364 +t_Error FmPcdCcModifyNextEngineParamTree(
18365 + t_Handle h_FmPcd, t_Handle h_FmPcdCcTree, uint8_t grpId, uint8_t index,
18366 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
18367 +{
18368 + t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
18369 + t_FmPcd *p_FmPcd;
18370 + t_List h_OldPointersLst, h_NewPointersLst;
18371 + uint16_t keyIndex;
18372 + t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
18373 + t_Error err = E_OK;
18374 +
18375 + SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
18376 + SANITY_CHECK_RETURN_ERROR(h_FmPcdCcTree, E_INVALID_HANDLE);
18377 + SANITY_CHECK_RETURN_ERROR((grpId <= 7), E_INVALID_VALUE);
18378 +
18379 + if (grpId >= p_FmPcdCcTree->numOfGrps)
18380 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE,
18381 + ("grpId you asked > numOfGroup of relevant tree"));
18382 +
18383 + if (index >= p_FmPcdCcTree->fmPcdGroupParam[grpId].numOfEntriesInGroup)
18384 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("index > numOfEntriesInGroup"));
18385 +
18386 + p_FmPcd = (t_FmPcd *)h_FmPcd;
18387 +
18388 + INIT_LIST(&h_OldPointersLst);
18389 + INIT_LIST(&h_NewPointersLst);
18390 +
18391 + keyIndex = (uint16_t)(p_FmPcdCcTree->fmPcdGroupParam[grpId].baseGroupEntry
18392 + + index);
18393 +
18394 + p_ModifyKeyParams = ModifyNodeCommonPart(p_FmPcdCcTree, keyIndex,
18395 + e_MODIFY_STATE_CHANGE, FALSE,
18396 + FALSE, TRUE);
18397 + if (!p_ModifyKeyParams)
18398 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
18399 +
18400 + p_ModifyKeyParams->tree = TRUE;
18401 +
18402 + if (p_FmPcd->p_CcShadow
18403 + && !TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
18404 + {
18405 + XX_Free(p_ModifyKeyParams);
18406 + return ERROR_CODE(E_BUSY);
18407 + }
18408 +
18409 + err = BuildNewNodeModifyNextEngine(p_FmPcd, p_FmPcdCcTree, keyIndex,
18410 + p_FmPcdCcNextEngineParams,
18411 + &h_OldPointersLst, &h_NewPointersLst,
18412 + p_ModifyKeyParams);
18413 + if (err)
18414 + {
18415 + XX_Free(p_ModifyKeyParams);
18416 + RETURN_ERROR(MAJOR, err, NO_MSG);
18417 + }
18418 +
18419 + err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
18420 + p_ModifyKeyParams, FALSE);
18421 +
18422 + if (p_FmPcd->p_CcShadow)
18423 + RELEASE_LOCK(p_FmPcd->shadowLock);
18424 +
18425 + return err;
18426 +
18427 +}
18428 +
18429 +t_Error FmPcdCcRemoveKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,
18430 + uint16_t keyIndex)
18431 +{
18432 +
18433 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
18434 + t_FmPcd *p_FmPcd;
18435 + t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
18436 + t_List h_OldPointersLst, h_NewPointersLst;
18437 + bool useShadowStructs = FALSE;
18438 + t_Error err = E_OK;
18439 +
18440 + if (keyIndex >= p_CcNode->numOfKeys)
18441 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
18442 + ("impossible to remove key when numOfKeys <= keyIndex"));
18443 +
18444 + if (p_CcNode->h_FmPcd != h_FmPcd)
18445 + RETURN_ERROR(
18446 + MAJOR,
18447 + E_INVALID_VALUE,
18448 + ("handler to FmPcd is different from the handle provided at node initialization time"));
18449 +
18450 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
18451 +
18452 + INIT_LIST(&h_OldPointersLst);
18453 + INIT_LIST(&h_NewPointersLst);
18454 +
18455 + p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,
18456 + e_MODIFY_STATE_REMOVE, TRUE, TRUE,
18457 + FALSE);
18458 + if (!p_ModifyKeyParams)
18459 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
18460 +
18461 + if (p_CcNode->maxNumOfKeys)
18462 + {
18463 + if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
18464 + {
18465 + XX_Free(p_ModifyKeyParams);
18466 + return ERROR_CODE(E_BUSY);
18467 + }
18468 +
18469 + useShadowStructs = TRUE;
18470 + }
18471 +
18472 + err = BuildNewNodeRemoveKey(p_CcNode, keyIndex, p_ModifyKeyParams);
18473 + if (err)
18474 + {
18475 + XX_Free(p_ModifyKeyParams);
18476 + if (p_CcNode->maxNumOfKeys)
18477 + RELEASE_LOCK(p_FmPcd->shadowLock);
18478 + RETURN_ERROR(MAJOR, err, NO_MSG);
18479 + }
18480 +
18481 + err = UpdatePtrWhichPointOnCrntMdfNode(p_CcNode, p_ModifyKeyParams,
18482 + &h_OldPointersLst,
18483 + &h_NewPointersLst);
18484 + if (err)
18485 + {
18486 + ReleaseNewNodeCommonPart(p_ModifyKeyParams);
18487 + XX_Free(p_ModifyKeyParams);
18488 + if (p_CcNode->maxNumOfKeys)
18489 + RELEASE_LOCK(p_FmPcd->shadowLock);
18490 + RETURN_ERROR(MAJOR, err, NO_MSG);
18491 + }
18492 +
18493 + err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
18494 + p_ModifyKeyParams, useShadowStructs);
18495 +
18496 + if (p_CcNode->maxNumOfKeys)
18497 + RELEASE_LOCK(p_FmPcd->shadowLock);
18498 +
18499 + return err;
18500 +}
18501 +
18502 +t_Error FmPcdCcModifyKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,
18503 + uint16_t keyIndex, uint8_t keySize, uint8_t *p_Key,
18504 + uint8_t *p_Mask)
18505 +{
18506 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
18507 + t_FmPcd *p_FmPcd;
18508 + t_List h_OldPointersLst, h_NewPointersLst;
18509 + t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
18510 + uint16_t tmpKeyIndex;
18511 + bool useShadowStructs = FALSE;
18512 + t_Error err = E_OK;
18513 +
18514 + if (keyIndex >= p_CcNode->numOfKeys)
18515 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
18516 + ("keyIndex > previously cleared last index + 1"));
18517 +
18518 + if (keySize != p_CcNode->userSizeOfExtraction)
18519 + RETURN_ERROR(
18520 + MAJOR,
18521 + E_INVALID_VALUE,
18522 + ("size for ModifyKey has to be the same as defined in SetNode"));
18523 +
18524 + if (p_CcNode->h_FmPcd != h_FmPcd)
18525 + RETURN_ERROR(
18526 + MAJOR,
18527 + E_INVALID_VALUE,
18528 + ("handler to FmPcd is different from the handle provided at node initialization time"));
18529 +
18530 + err = FindKeyIndex(h_FmPcdCcNode, keySize, p_Key, p_Mask, &tmpKeyIndex);
18531 + if (GET_ERROR_TYPE(err) != E_NOT_FOUND)
18532 + RETURN_ERROR(
18533 + MINOR,
18534 + E_ALREADY_EXISTS,
18535 + ("The received key and mask pair was already found in the match table of the provided node"));
18536 +
18537 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
18538 +
18539 + INIT_LIST(&h_OldPointersLst);
18540 + INIT_LIST(&h_NewPointersLst);
18541 +
18542 + p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,
18543 + e_MODIFY_STATE_CHANGE, TRUE, TRUE,
18544 + FALSE);
18545 + if (!p_ModifyKeyParams)
18546 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
18547 +
18548 + if (p_CcNode->maxNumOfKeys)
18549 + {
18550 + if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
18551 + {
18552 + XX_Free(p_ModifyKeyParams);
18553 + return ERROR_CODE(E_BUSY);
18554 + }
18555 +
18556 + useShadowStructs = TRUE;
18557 + }
18558 +
18559 + err = BuildNewNodeModifyKey(p_CcNode, keyIndex, p_Key, p_Mask,
18560 + p_ModifyKeyParams);
18561 + if (err)
18562 + {
18563 + XX_Free(p_ModifyKeyParams);
18564 + if (p_CcNode->maxNumOfKeys)
18565 + RELEASE_LOCK(p_FmPcd->shadowLock);
18566 + RETURN_ERROR(MAJOR, err, NO_MSG);
18567 + }
18568 +
18569 + err = UpdatePtrWhichPointOnCrntMdfNode(p_CcNode, p_ModifyKeyParams,
18570 + &h_OldPointersLst,
18571 + &h_NewPointersLst);
18572 + if (err)
18573 + {
18574 + ReleaseNewNodeCommonPart(p_ModifyKeyParams);
18575 + XX_Free(p_ModifyKeyParams);
18576 + if (p_CcNode->maxNumOfKeys)
18577 + RELEASE_LOCK(p_FmPcd->shadowLock);
18578 + RETURN_ERROR(MAJOR, err, NO_MSG);
18579 + }
18580 +
18581 + err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
18582 + p_ModifyKeyParams, useShadowStructs);
18583 +
18584 + if (p_CcNode->maxNumOfKeys)
18585 + RELEASE_LOCK(p_FmPcd->shadowLock);
18586 +
18587 + return err;
18588 +}
18589 +
18590 +t_Error FmPcdCcModifyMissNextEngineParamNode(
18591 + t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,
18592 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
18593 +{
18594 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
18595 + t_FmPcd *p_FmPcd;
18596 + t_List h_OldPointersLst, h_NewPointersLst;
18597 + uint16_t keyIndex;
18598 + t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
18599 + t_Error err = E_OK;
18600 +
18601 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_VALUE);
18602 +
18603 + keyIndex = p_CcNode->numOfKeys;
18604 +
18605 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
18606 +
18607 + INIT_LIST(&h_OldPointersLst);
18608 + INIT_LIST(&h_NewPointersLst);
18609 +
18610 + p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,
18611 + e_MODIFY_STATE_CHANGE, FALSE, TRUE,
18612 + FALSE);
18613 + if (!p_ModifyKeyParams)
18614 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
18615 +
18616 + if (p_CcNode->maxNumOfKeys
18617 + && !TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
18618 + {
18619 + XX_Free(p_ModifyKeyParams);
18620 + return ERROR_CODE(E_BUSY);
18621 + }
18622 +
18623 + err = BuildNewNodeModifyNextEngine(h_FmPcd, p_CcNode, keyIndex,
18624 + p_FmPcdCcNextEngineParams,
18625 + &h_OldPointersLst, &h_NewPointersLst,
18626 + p_ModifyKeyParams);
18627 + if (err)
18628 + {
18629 + XX_Free(p_ModifyKeyParams);
18630 + if (p_CcNode->maxNumOfKeys)
18631 + RELEASE_LOCK(p_FmPcd->shadowLock);
18632 + RETURN_ERROR(MAJOR, err, NO_MSG);
18633 + }
18634 +
18635 + err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
18636 + p_ModifyKeyParams, FALSE);
18637 +
18638 + if (p_CcNode->maxNumOfKeys)
18639 + RELEASE_LOCK(p_FmPcd->shadowLock);
18640 +
18641 + return err;
18642 +}
18643 +
18644 +t_Error FmPcdCcAddKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,
18645 + uint16_t keyIndex, uint8_t keySize,
18646 + t_FmPcdCcKeyParams *p_FmPcdCcKeyParams)
18647 +{
18648 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
18649 + t_FmPcd *p_FmPcd;
18650 + t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
18651 + t_List h_OldPointersLst, h_NewPointersLst;
18652 + bool useShadowStructs = FALSE;
18653 + uint16_t tmpKeyIndex;
18654 + t_Error err = E_OK;
18655 +
18656 + if (keyIndex > p_CcNode->numOfKeys)
18657 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE,
18658 + ("keyIndex > previously cleared last index + 1"));
18659 +
18660 + if (keySize != p_CcNode->userSizeOfExtraction)
18661 + RETURN_ERROR(
18662 + MAJOR,
18663 + E_INVALID_VALUE,
18664 + ("keySize has to be defined as it was defined in initialization step"));
18665 +
18666 + if (p_CcNode->h_FmPcd != h_FmPcd)
18667 + RETURN_ERROR(
18668 + MAJOR,
18669 + E_INVALID_VALUE,
18670 + ("handler to FmPcd is different from the handle provided at node initialization time"));
18671 +
18672 + if (p_CcNode->maxNumOfKeys)
18673 + {
18674 + if (p_CcNode->numOfKeys == p_CcNode->maxNumOfKeys)
18675 + RETURN_ERROR(
18676 + MAJOR,
18677 + E_FULL,
18678 + ("number of keys exceeds the maximal number of keys provided at node initialization time"));
18679 + }
18680 + else
18681 + if (p_CcNode->numOfKeys == FM_PCD_MAX_NUM_OF_KEYS)
18682 + RETURN_ERROR(
18683 + MAJOR,
18684 + E_INVALID_VALUE,
18685 + ("number of keys can not be larger than %d", FM_PCD_MAX_NUM_OF_KEYS));
18686 +
18687 + err = FindKeyIndex(h_FmPcdCcNode, keySize, p_FmPcdCcKeyParams->p_Key,
18688 + p_FmPcdCcKeyParams->p_Mask, &tmpKeyIndex);
18689 + if (GET_ERROR_TYPE(err) != E_NOT_FOUND)
18690 + RETURN_ERROR(
18691 + MAJOR,
18692 + E_ALREADY_EXISTS,
18693 + ("The received key and mask pair was already found in the match table of the provided node"));
18694 +
18695 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
18696 +
18697 + INIT_LIST(&h_OldPointersLst);
18698 + INIT_LIST(&h_NewPointersLst);
18699 +
18700 + p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,
18701 + e_MODIFY_STATE_ADD, TRUE, TRUE,
18702 + FALSE);
18703 + if (!p_ModifyKeyParams)
18704 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
18705 +
18706 + if (p_CcNode->maxNumOfKeys)
18707 + {
18708 + if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
18709 + {
18710 + XX_Free(p_ModifyKeyParams);
18711 + return ERROR_CODE(E_BUSY);
18712 + }
18713 +
18714 + useShadowStructs = TRUE;
18715 + }
18716 +
18717 + err = BuildNewNodeAddOrMdfyKeyAndNextEngine(h_FmPcd, p_CcNode, keyIndex,
18718 + p_FmPcdCcKeyParams,
18719 + p_ModifyKeyParams, TRUE);
18720 + if (err)
18721 + {
18722 + ReleaseNewNodeCommonPart(p_ModifyKeyParams);
18723 + XX_Free(p_ModifyKeyParams);
18724 + if (p_CcNode->maxNumOfKeys)
18725 + RELEASE_LOCK(p_FmPcd->shadowLock);
18726 + RETURN_ERROR(MAJOR, err, NO_MSG);
18727 + }
18728 +
18729 + err = UpdatePtrWhichPointOnCrntMdfNode(p_CcNode, p_ModifyKeyParams,
18730 + &h_OldPointersLst,
18731 + &h_NewPointersLst);
18732 + if (err)
18733 + {
18734 + ReleaseNewNodeCommonPart(p_ModifyKeyParams);
18735 + XX_Free(p_ModifyKeyParams);
18736 + if (p_CcNode->maxNumOfKeys)
18737 + RELEASE_LOCK(p_FmPcd->shadowLock);
18738 + RETURN_ERROR(MAJOR, err, NO_MSG);
18739 + }
18740 +
18741 + err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
18742 + p_ModifyKeyParams, useShadowStructs);
18743 + if (p_CcNode->maxNumOfKeys)
18744 + RELEASE_LOCK(p_FmPcd->shadowLock);
18745 +
18746 + return err;
18747 +}
18748 +
18749 +t_Error FmPcdCcModifyKeyAndNextEngine(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,
18750 + uint16_t keyIndex, uint8_t keySize,
18751 + t_FmPcdCcKeyParams *p_FmPcdCcKeyParams)
18752 +{
18753 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
18754 + t_FmPcd *p_FmPcd;
18755 + t_List h_OldPointersLst, h_NewPointersLst;
18756 + t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
18757 + uint16_t tmpKeyIndex;
18758 + bool useShadowStructs = FALSE;
18759 + t_Error err = E_OK;
18760 +
18761 + if (keyIndex > p_CcNode->numOfKeys)
18762 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
18763 + ("keyIndex > previously cleared last index + 1"));
18764 +
18765 + if (keySize != p_CcNode->userSizeOfExtraction)
18766 + RETURN_ERROR(
18767 + MAJOR,
18768 + E_INVALID_VALUE,
18769 + ("keySize has to be defined as it was defined in initialization step"));
18770 +
18771 + if (p_CcNode->h_FmPcd != h_FmPcd)
18772 + RETURN_ERROR(
18773 + MAJOR,
18774 + E_INVALID_VALUE,
18775 + ("handler to FmPcd is different from the handle provided at node initialization time"));
18776 +
18777 + err = FindKeyIndex(h_FmPcdCcNode, keySize, p_FmPcdCcKeyParams->p_Key,
18778 + p_FmPcdCcKeyParams->p_Mask, &tmpKeyIndex);
18779 + if (GET_ERROR_TYPE(err) != E_NOT_FOUND)
18780 + RETURN_ERROR(
18781 + MINOR,
18782 + E_ALREADY_EXISTS,
18783 + ("The received key and mask pair was already found in the match table of the provided node"));
18784 +
18785 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
18786 +
18787 + INIT_LIST(&h_OldPointersLst);
18788 + INIT_LIST(&h_NewPointersLst);
18789 +
18790 + p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,
18791 + e_MODIFY_STATE_CHANGE, TRUE, TRUE,
18792 + FALSE);
18793 + if (!p_ModifyKeyParams)
18794 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
18795 +
18796 + if (p_CcNode->maxNumOfKeys)
18797 + {
18798 + if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
18799 + {
18800 + XX_Free(p_ModifyKeyParams);
18801 + return ERROR_CODE(E_BUSY);
18802 + }
18803 +
18804 + useShadowStructs = TRUE;
18805 + }
18806 +
18807 + err = BuildNewNodeAddOrMdfyKeyAndNextEngine(h_FmPcd, p_CcNode, keyIndex,
18808 + p_FmPcdCcKeyParams,
18809 + p_ModifyKeyParams, FALSE);
18810 + if (err)
18811 + {
18812 + ReleaseNewNodeCommonPart(p_ModifyKeyParams);
18813 + XX_Free(p_ModifyKeyParams);
18814 + if (p_CcNode->maxNumOfKeys)
18815 + RELEASE_LOCK(p_FmPcd->shadowLock);
18816 + RETURN_ERROR(MAJOR, err, NO_MSG);
18817 + }
18818 +
18819 + err = UpdatePtrWhichPointOnCrntMdfNode(p_CcNode, p_ModifyKeyParams,
18820 + &h_OldPointersLst,
18821 + &h_NewPointersLst);
18822 + if (err)
18823 + {
18824 + ReleaseNewNodeCommonPart(p_ModifyKeyParams);
18825 + XX_Free(p_ModifyKeyParams);
18826 + if (p_CcNode->maxNumOfKeys)
18827 + RELEASE_LOCK(p_FmPcd->shadowLock);
18828 + RETURN_ERROR(MAJOR, err, NO_MSG);
18829 + }
18830 +
18831 + err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
18832 + p_ModifyKeyParams, useShadowStructs);
18833 +
18834 + if (p_CcNode->maxNumOfKeys)
18835 + RELEASE_LOCK(p_FmPcd->shadowLock);
18836 +
18837 + return err;
18838 +}
18839 +
18840 +uint32_t FmPcdCcGetNodeAddrOffsetFromNodeInfo(t_Handle h_FmPcd,
18841 + t_Handle h_Pointer)
18842 +{
18843 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
18844 + t_CcNodeInformation *p_CcNodeInfo;
18845 +
18846 + SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE,
18847 + (uint32_t)ILLEGAL_BASE);
18848 +
18849 + p_CcNodeInfo = CC_NODE_F_OBJECT(h_Pointer);
18850 +
18851 + return (uint32_t)(XX_VirtToPhys(p_CcNodeInfo->h_CcNode)
18852 + - p_FmPcd->physicalMuramBase);
18853 +}
18854 +
18855 +t_Error FmPcdCcGetGrpParams(t_Handle h_FmPcdCcTree, uint8_t grpId,
18856 + uint32_t *p_GrpBits, uint8_t *p_GrpBase)
18857 +{
18858 + t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
18859 +
18860 + SANITY_CHECK_RETURN_ERROR(h_FmPcdCcTree, E_INVALID_HANDLE);
18861 +
18862 + if (grpId >= p_FmPcdCcTree->numOfGrps)
18863 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE,
18864 + ("grpId you asked > numOfGroup of relevant tree"));
18865 +
18866 + *p_GrpBits = p_FmPcdCcTree->fmPcdGroupParam[grpId].totalBitsMask;
18867 + *p_GrpBase = p_FmPcdCcTree->fmPcdGroupParam[grpId].baseGroupEntry;
18868 +
18869 + return E_OK;
18870 +}
18871 +
18872 +t_Error FmPcdCcBindTree(t_Handle h_FmPcd, t_Handle h_PcdParams,
18873 + t_Handle h_FmPcdCcTree, uint32_t *p_Offset,
18874 + t_Handle h_FmPort)
18875 +{
18876 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
18877 + t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
18878 + t_Error err = E_OK;
18879 +
18880 + SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
18881 + SANITY_CHECK_RETURN_ERROR(h_FmPcdCcTree, E_INVALID_HANDLE);
18882 +
18883 + /* this routine must be protected by the calling routine by locking all PCD modules! */
18884 +
18885 + err = CcUpdateParams(h_FmPcd, h_PcdParams, h_FmPort, h_FmPcdCcTree, TRUE);
18886 +
18887 + if (err == E_OK)
18888 + UpdateCcRootOwner(p_FmPcdCcTree, TRUE);
18889 +
18890 + *p_Offset = (uint32_t)(XX_VirtToPhys(
18891 + UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr))
18892 + - p_FmPcd->physicalMuramBase);
18893 +
18894 + return err;
18895 +}
18896 +
18897 +t_Error FmPcdCcUnbindTree(t_Handle h_FmPcd, t_Handle h_FmPcdCcTree)
18898 +{
18899 + t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
18900 +
18901 + /* this routine must be protected by the calling routine by locking all PCD modules! */
18902 +
18903 + UNUSED(h_FmPcd);
18904 +
18905 + SANITY_CHECK_RETURN_ERROR(h_FmPcdCcTree, E_INVALID_HANDLE);
18906 +
18907 + UpdateCcRootOwner(p_FmPcdCcTree, FALSE);
18908 +
18909 + return E_OK;
18910 +}
18911 +
18912 +t_Error FmPcdCcNodeTreeTryLock(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,
18913 + t_List *p_List)
18914 +{
18915 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
18916 + t_List *p_Pos, *p_Tmp;
18917 + t_CcNodeInformation *p_CcNodeInfo, nodeInfo;
18918 + uint32_t intFlags;
18919 + t_Error err = E_OK;
18920 +
18921 + intFlags = FmPcdLock(h_FmPcd);
18922 +
18923 + LIST_FOR_EACH(p_Pos, &p_CcNode->ccTreesLst)
18924 + {
18925 + p_CcNodeInfo = CC_NODE_F_OBJECT(p_Pos);
18926 + ASSERT_COND(p_CcNodeInfo->h_CcNode);
18927 +
18928 + err = CcRootTryLock(p_CcNodeInfo->h_CcNode);
18929 +
18930 + if (err)
18931 + {
18932 + LIST_FOR_EACH(p_Tmp, &p_CcNode->ccTreesLst)
18933 + {
18934 + if (p_Tmp == p_Pos)
18935 + break;
18936 +
18937 + CcRootReleaseLock(p_CcNodeInfo->h_CcNode);
18938 + }
18939 + break;
18940 + }
18941 +
18942 + memset(&nodeInfo, 0, sizeof(t_CcNodeInformation));
18943 + nodeInfo.h_CcNode = p_CcNodeInfo->h_CcNode;
18944 + EnqueueNodeInfoToRelevantLst(p_List, &nodeInfo, NULL);
18945 + }
18946 +
18947 + FmPcdUnlock(h_FmPcd, intFlags);
18948 + CORE_MemoryBarrier();
18949 +
18950 + return err;
18951 +}
18952 +
18953 +void FmPcdCcNodeTreeReleaseLock(t_Handle h_FmPcd, t_List *p_List)
18954 +{
18955 + t_List *p_Pos;
18956 + t_CcNodeInformation *p_CcNodeInfo;
18957 + t_Handle h_FmPcdCcTree;
18958 + uint32_t intFlags;
18959 +
18960 + intFlags = FmPcdLock(h_FmPcd);
18961 +
18962 + LIST_FOR_EACH(p_Pos, p_List)
18963 + {
18964 + p_CcNodeInfo = CC_NODE_F_OBJECT(p_Pos);
18965 + h_FmPcdCcTree = p_CcNodeInfo->h_CcNode;
18966 + CcRootReleaseLock(h_FmPcdCcTree);
18967 + }
18968 +
18969 + ReleaseLst(p_List);
18970 +
18971 + FmPcdUnlock(h_FmPcd, intFlags);
18972 + CORE_MemoryBarrier();
18973 +}
18974 +
18975 +t_Error FmPcdUpdateCcShadow(t_FmPcd *p_FmPcd, uint32_t size, uint32_t align)
18976 +{
18977 + uint32_t intFlags;
18978 + uint32_t newSize = 0, newAlign = 0;
18979 + bool allocFail = FALSE;
18980 +
18981 + ASSERT_COND(p_FmPcd);
18982 +
18983 + if (!size)
18984 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("size must be larger then 0"));
18985 +
18986 + if (!POWER_OF_2(align))
18987 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("alignment must be power of 2"));
18988 +
18989 + newSize = p_FmPcd->ccShadowSize;
18990 + newAlign = p_FmPcd->ccShadowAlign;
18991 +
18992 + /* Check if current shadow is large enough to hold the requested size */
18993 + if (size > p_FmPcd->ccShadowSize)
18994 + newSize = size;
18995 +
18996 + /* Check if current shadow matches the requested alignment */
18997 + if (align > p_FmPcd->ccShadowAlign)
18998 + newAlign = align;
18999 +
19000 + /* If a bigger shadow size or bigger shadow alignment are required,
19001 + a new shadow will be allocated */
19002 + if ((newSize != p_FmPcd->ccShadowSize)
19003 + || (newAlign != p_FmPcd->ccShadowAlign))
19004 + {
19005 + intFlags = FmPcdLock(p_FmPcd);
19006 +
19007 + if (p_FmPcd->p_CcShadow)
19008 + {
19009 + FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_FmPcd), p_FmPcd->p_CcShadow);
19010 + p_FmPcd->ccShadowSize = 0;
19011 + p_FmPcd->ccShadowAlign = 0;
19012 + }
19013 +
19014 + p_FmPcd->p_CcShadow = FM_MURAM_AllocMem(FmPcdGetMuramHandle(p_FmPcd),
19015 + newSize, newAlign);
19016 + if (!p_FmPcd->p_CcShadow)
19017 + {
19018 + allocFail = TRUE;
19019 +
19020 + /* If new shadow size allocation failed,
19021 + re-allocate with previous parameters */
19022 + p_FmPcd->p_CcShadow = FM_MURAM_AllocMem(
19023 + FmPcdGetMuramHandle(p_FmPcd), p_FmPcd->ccShadowSize,
19024 + p_FmPcd->ccShadowAlign);
19025 + }
19026 +
19027 + FmPcdUnlock(p_FmPcd, intFlags);
19028 +
19029 + if (allocFail)
19030 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
19031 + ("MURAM allocation for CC Shadow memory"));
19032 +
19033 + p_FmPcd->ccShadowSize = newSize;
19034 + p_FmPcd->ccShadowAlign = newAlign;
19035 + }
19036 +
19037 + return E_OK;
19038 +}
19039 +
19040 +#if (DPAA_VERSION >= 11)
19041 +void FmPcdCcGetAdTablesThatPointOnReplicGroup(t_Handle h_Node,
19042 + t_Handle h_ReplicGroup,
19043 + t_List *p_AdTables,
19044 + uint32_t *p_NumOfAdTables)
19045 +{
19046 + t_FmPcdCcNode *p_CurrentNode = (t_FmPcdCcNode *)h_Node;
19047 + int i = 0;
19048 + void * p_AdTable;
19049 + t_CcNodeInformation ccNodeInfo;
19050 +
19051 + ASSERT_COND(h_Node);
19052 + *p_NumOfAdTables = 0;
19053 +
19054 + /* search in the current node which exact index points on this current replicator group for getting AD */
19055 + for (i = 0; i < p_CurrentNode->numOfKeys + 1; i++)
19056 + {
19057 + if ((p_CurrentNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine
19058 + == e_FM_PCD_FR)
19059 + && ((p_CurrentNode->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic
19060 + == (t_Handle)h_ReplicGroup)))
19061 + {
19062 + /* save the current ad table in the list */
19063 + /* this entry uses the input replicator group */
19064 + p_AdTable =
19065 + PTR_MOVE(p_CurrentNode->h_AdTable, i*FM_PCD_CC_AD_ENTRY_SIZE);
19066 + memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
19067 + ccNodeInfo.h_CcNode = p_AdTable;
19068 + EnqueueNodeInfoToRelevantLst(p_AdTables, &ccNodeInfo, NULL);
19069 + (*p_NumOfAdTables)++;
19070 + }
19071 + }
19072 +
19073 + ASSERT_COND(i != p_CurrentNode->numOfKeys);
19074 +}
19075 +#endif /* (DPAA_VERSION >= 11) */
19076 +/*********************** End of inter-module routines ************************/
19077 +
19078 +/****************************************/
19079 +/* API Init unit functions */
19080 +/****************************************/
19081 +
19082 +t_Handle FM_PCD_CcRootBuild(t_Handle h_FmPcd,
19083 + t_FmPcdCcTreeParams *p_PcdGroupsParam)
19084 +{
19085 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
19086 + t_Error err = E_OK;
19087 + int i = 0, j = 0, k = 0;
19088 + t_FmPcdCcTree *p_FmPcdCcTree;
19089 + uint8_t numOfEntries;
19090 + t_Handle p_CcTreeTmp;
19091 + t_FmPcdCcGrpParams *p_FmPcdCcGroupParams;
19092 + t_FmPcdCcKeyAndNextEngineParams *p_Params, *p_KeyAndNextEngineParams;
19093 + t_NetEnvParams netEnvParams;
19094 + uint8_t lastOne = 0;
19095 + uint32_t requiredAction = 0;
19096 + t_FmPcdCcNode *p_FmPcdCcNextNode;
19097 + t_CcNodeInformation ccNodeInfo, *p_CcInformation;
19098 +
19099 + SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);
19100 + SANITY_CHECK_RETURN_VALUE(p_PcdGroupsParam, E_INVALID_HANDLE, NULL);
19101 +
19102 + if (p_PcdGroupsParam->numOfGrps > FM_PCD_MAX_NUM_OF_CC_GROUPS)
19103 + {
19104 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("numOfGrps should not exceed %d", FM_PCD_MAX_NUM_OF_CC_GROUPS));
19105 + return NULL;
19106 + }
19107 +
19108 + p_FmPcdCcTree = (t_FmPcdCcTree*)XX_Malloc(sizeof(t_FmPcdCcTree));
19109 + if (!p_FmPcdCcTree)
19110 + {
19111 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("PCD tree structure"));
19112 + return NULL;
19113 + }
19114 + memset(p_FmPcdCcTree, 0, sizeof(t_FmPcdCcTree));
19115 + p_FmPcdCcTree->h_FmPcd = h_FmPcd;
19116 +
19117 + p_Params = (t_FmPcdCcKeyAndNextEngineParams*)XX_Malloc(
19118 + FM_PCD_MAX_NUM_OF_CC_GROUPS
19119 + * sizeof(t_FmPcdCcKeyAndNextEngineParams));
19120 + memset(p_Params,
19121 + 0,
19122 + FM_PCD_MAX_NUM_OF_CC_GROUPS
19123 + * sizeof(t_FmPcdCcKeyAndNextEngineParams));
19124 +
19125 + INIT_LIST(&p_FmPcdCcTree->fmPortsLst);
19126 +
19127 +#ifdef FM_CAPWAP_SUPPORT
19128 + if ((p_PcdGroupsParam->numOfGrps == 1) &&
19129 + (p_PcdGroupsParam->ccGrpParams[0].numOfDistinctionUnits == 0) &&
19130 + (p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].nextEngine == e_FM_PCD_CC) &&
19131 + p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].params.ccParams.h_CcNode &&
19132 + IsCapwapApplSpecific(p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].params.ccParams.h_CcNode))
19133 + {
19134 + p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].h_Manip = FmPcdManipApplSpecificBuild();
19135 + if (!p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].h_Manip)
19136 + {
19137 + DeleteTree(p_FmPcdCcTree,p_FmPcd);
19138 + XX_Free(p_Params);
19139 + REPORT_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
19140 + return NULL;
19141 + }
19142 + }
19143 +#endif /* FM_CAPWAP_SUPPORT */
19144 +
19145 + numOfEntries = 0;
19146 + p_FmPcdCcTree->netEnvId = FmPcdGetNetEnvId(p_PcdGroupsParam->h_NetEnv);
19147 +
19148 + for (i = 0; i < p_PcdGroupsParam->numOfGrps; i++)
19149 + {
19150 + p_FmPcdCcGroupParams = &p_PcdGroupsParam->ccGrpParams[i];
19151 +
19152 + if (p_FmPcdCcGroupParams->numOfDistinctionUnits
19153 + > FM_PCD_MAX_NUM_OF_CC_UNITS)
19154 + {
19155 + DeleteTree(p_FmPcdCcTree, p_FmPcd);
19156 + XX_Free(p_Params);
19157 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
19158 + ("numOfDistinctionUnits (group %d) should not exceed %d", i, FM_PCD_MAX_NUM_OF_CC_UNITS));
19159 + return NULL;
19160 + }
19161 +
19162 + p_FmPcdCcTree->fmPcdGroupParam[i].baseGroupEntry = numOfEntries;
19163 + p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup = (uint8_t)(0x01
19164 + << p_FmPcdCcGroupParams->numOfDistinctionUnits);
19165 + numOfEntries += p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup;
19166 + if (numOfEntries > FM_PCD_MAX_NUM_OF_CC_GROUPS)
19167 + {
19168 + DeleteTree(p_FmPcdCcTree, p_FmPcd);
19169 + XX_Free(p_Params);
19170 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("numOfEntries can not be larger than %d", FM_PCD_MAX_NUM_OF_CC_GROUPS));
19171 + return NULL;
19172 + }
19173 +
19174 + if (lastOne)
19175 + {
19176 + if (p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup > lastOne)
19177 + {
19178 + DeleteTree(p_FmPcdCcTree, p_FmPcd);
19179 + XX_Free(p_Params);
19180 + REPORT_ERROR(MAJOR, E_CONFLICT, ("numOfEntries per group must be set in descending order"));
19181 + return NULL;
19182 + }
19183 + }
19184 +
19185 + lastOne = p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup;
19186 +
19187 + netEnvParams.netEnvId = p_FmPcdCcTree->netEnvId;
19188 + netEnvParams.numOfDistinctionUnits =
19189 + p_FmPcdCcGroupParams->numOfDistinctionUnits;
19190 +
19191 + memcpy(netEnvParams.unitIds, &p_FmPcdCcGroupParams->unitIds,
19192 + (sizeof(uint8_t)) * p_FmPcdCcGroupParams->numOfDistinctionUnits);
19193 +
19194 + err = PcdGetUnitsVector(p_FmPcd, &netEnvParams);
19195 + if (err)
19196 + {
19197 + DeleteTree(p_FmPcdCcTree, p_FmPcd);
19198 + XX_Free(p_Params);
19199 + REPORT_ERROR(MAJOR, err, NO_MSG);
19200 + return NULL;
19201 + }
19202 +
19203 + p_FmPcdCcTree->fmPcdGroupParam[i].totalBitsMask = netEnvParams.vector;
19204 + for (j = 0; j < p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup;
19205 + j++)
19206 + {
19207 + err = ValidateNextEngineParams(
19208 + h_FmPcd,
19209 + &p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j],
19210 + e_FM_PCD_CC_STATS_MODE_NONE);
19211 + if (err)
19212 + {
19213 + DeleteTree(p_FmPcdCcTree, p_FmPcd);
19214 + XX_Free(p_Params);
19215 + REPORT_ERROR(MAJOR, err, (NO_MSG));
19216 + return NULL;
19217 + }
19218 +
19219 + if (p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j].h_Manip)
19220 + {
19221 + err = FmPcdManipCheckParamsForCcNextEngine(
19222 + &p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j],
19223 + &requiredAction);
19224 + if (err)
19225 + {
19226 + DeleteTree(p_FmPcdCcTree, p_FmPcd);
19227 + XX_Free(p_Params);
19228 + REPORT_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
19229 + return NULL;
19230 + }
19231 + }
19232 + p_KeyAndNextEngineParams = p_Params + k;
19233 +
19234 + memcpy(&p_KeyAndNextEngineParams->nextEngineParams,
19235 + &p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j],
19236 + sizeof(t_FmPcdCcNextEngineParams));
19237 +
19238 + if ((p_KeyAndNextEngineParams->nextEngineParams.nextEngine
19239 + == e_FM_PCD_CC)
19240 + && p_KeyAndNextEngineParams->nextEngineParams.h_Manip)
19241 + {
19242 + err =
19243 + AllocAndFillAdForContLookupManip(
19244 + p_KeyAndNextEngineParams->nextEngineParams.params.ccParams.h_CcNode);
19245 + if (err)
19246 + {
19247 + DeleteTree(p_FmPcdCcTree, p_FmPcd);
19248 + XX_Free(p_Params);
19249 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CC Tree"));
19250 + return NULL;
19251 + }
19252 + }
19253 +
19254 + requiredAction |= UPDATE_CC_WITH_TREE;
19255 + p_KeyAndNextEngineParams->requiredAction = requiredAction;
19256 +
19257 + k++;
19258 + }
19259 + }
19260 +
19261 + p_FmPcdCcTree->numOfEntries = (uint8_t)k;
19262 + p_FmPcdCcTree->numOfGrps = p_PcdGroupsParam->numOfGrps;
19263 +
19264 + p_FmPcdCcTree->ccTreeBaseAddr =
19265 + PTR_TO_UINT(FM_MURAM_AllocMem(FmPcdGetMuramHandle(h_FmPcd),
19266 + (uint32_t)( FM_PCD_MAX_NUM_OF_CC_GROUPS * FM_PCD_CC_AD_ENTRY_SIZE),
19267 + FM_PCD_CC_TREE_ADDR_ALIGN));
19268 + if (!p_FmPcdCcTree->ccTreeBaseAddr)
19269 + {
19270 + DeleteTree(p_FmPcdCcTree, p_FmPcd);
19271 + XX_Free(p_Params);
19272 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CC Tree"));
19273 + return NULL;
19274 + }
19275 + MemSet8(
19276 + UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr), 0,
19277 + (uint32_t)(FM_PCD_MAX_NUM_OF_CC_GROUPS * FM_PCD_CC_AD_ENTRY_SIZE));
19278 +
19279 + p_CcTreeTmp = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);
19280 +
19281 + for (i = 0; i < numOfEntries; i++)
19282 + {
19283 + p_KeyAndNextEngineParams = p_Params + i;
19284 +
19285 + NextStepAd(p_CcTreeTmp, NULL,
19286 + &p_KeyAndNextEngineParams->nextEngineParams, p_FmPcd);
19287 +
19288 + p_CcTreeTmp = PTR_MOVE(p_CcTreeTmp, FM_PCD_CC_AD_ENTRY_SIZE);
19289 +
19290 + memcpy(&p_FmPcdCcTree->keyAndNextEngineParams[i],
19291 + p_KeyAndNextEngineParams,
19292 + sizeof(t_FmPcdCcKeyAndNextEngineParams));
19293 +
19294 + if (p_FmPcdCcTree->keyAndNextEngineParams[i].nextEngineParams.nextEngine
19295 + == e_FM_PCD_CC)
19296 + {
19297 + p_FmPcdCcNextNode =
19298 + (t_FmPcdCcNode*)p_FmPcdCcTree->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode;
19299 + p_CcInformation = FindNodeInfoInReleventLst(
19300 + &p_FmPcdCcNextNode->ccTreeIdLst, (t_Handle)p_FmPcdCcTree,
19301 + p_FmPcdCcNextNode->h_Spinlock);
19302 +
19303 + if (!p_CcInformation)
19304 + {
19305 + memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
19306 + ccNodeInfo.h_CcNode = (t_Handle)p_FmPcdCcTree;
19307 + ccNodeInfo.index = 1;
19308 + EnqueueNodeInfoToRelevantLst(&p_FmPcdCcNextNode->ccTreeIdLst,
19309 + &ccNodeInfo,
19310 + p_FmPcdCcNextNode->h_Spinlock);
19311 + }
19312 + else
19313 + p_CcInformation->index++;
19314 + }
19315 + }
19316 +
19317 + FmPcdIncNetEnvOwners(h_FmPcd, p_FmPcdCcTree->netEnvId);
19318 + p_CcTreeTmp = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);
19319 +
19320 + if (!FmPcdLockTryLockAll(p_FmPcd))
19321 + {
19322 + FM_PCD_CcRootDelete(p_FmPcdCcTree);
19323 + XX_Free(p_Params);
19324 + DBG(TRACE, ("FmPcdLockTryLockAll failed"));
19325 + return NULL;
19326 + }
19327 +
19328 + for (i = 0; i < numOfEntries; i++)
19329 + {
19330 + if (p_FmPcdCcTree->keyAndNextEngineParams[i].requiredAction)
19331 + {
19332 + err = SetRequiredAction(
19333 + h_FmPcd,
19334 + p_FmPcdCcTree->keyAndNextEngineParams[i].requiredAction,
19335 + &p_FmPcdCcTree->keyAndNextEngineParams[i], p_CcTreeTmp, 1,
19336 + p_FmPcdCcTree);
19337 + if (err)
19338 + {
19339 + FmPcdLockUnlockAll(p_FmPcd);
19340 + FM_PCD_CcRootDelete(p_FmPcdCcTree);
19341 + XX_Free(p_Params);
19342 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));
19343 + return NULL;
19344 + }
19345 + p_CcTreeTmp = PTR_MOVE(p_CcTreeTmp, FM_PCD_CC_AD_ENTRY_SIZE);
19346 + }
19347 + }
19348 +
19349 + FmPcdLockUnlockAll(p_FmPcd);
19350 + p_FmPcdCcTree->p_Lock = FmPcdAcquireLock(p_FmPcd);
19351 + if (!p_FmPcdCcTree->p_Lock)
19352 + {
19353 + FM_PCD_CcRootDelete(p_FmPcdCcTree);
19354 + XX_Free(p_Params);
19355 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM CC lock"));
19356 + return NULL;
19357 + }
19358 +
19359 + XX_Free(p_Params);
19360 +
19361 + return p_FmPcdCcTree;
19362 +}
19363 +
19364 +t_Error FM_PCD_CcRootDelete(t_Handle h_CcTree)
19365 +{
19366 + t_FmPcd *p_FmPcd;
19367 + t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *)h_CcTree;
19368 + int i = 0;
19369 +
19370 + SANITY_CHECK_RETURN_ERROR(p_CcTree, E_INVALID_STATE);
19371 + p_FmPcd = (t_FmPcd *)p_CcTree->h_FmPcd;
19372 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
19373 +
19374 + FmPcdDecNetEnvOwners(p_FmPcd, p_CcTree->netEnvId);
19375 +
19376 + if (p_CcTree->owners)
19377 + RETURN_ERROR(
19378 + MAJOR,
19379 + E_INVALID_SELECTION,
19380 + ("the tree with this ID can not be removed because this tree is occupied, first - unbind this tree"));
19381 +
19382 + /* Delete ip-reassembly schemes if exist */
19383 + if (p_CcTree->h_IpReassemblyManip)
19384 + {
19385 + FmPcdManipDeleteIpReassmSchemes(p_CcTree->h_IpReassemblyManip);
19386 + FmPcdManipUpdateOwner(p_CcTree->h_IpReassemblyManip, FALSE);
19387 + }
19388 +
19389 + /* Delete capwap-reassembly schemes if exist */
19390 + if (p_CcTree->h_CapwapReassemblyManip)
19391 + {
19392 + FmPcdManipDeleteCapwapReassmSchemes(p_CcTree->h_CapwapReassemblyManip);
19393 + FmPcdManipUpdateOwner(p_CcTree->h_CapwapReassemblyManip, FALSE);
19394 + }
19395 +
19396 + for (i = 0; i < p_CcTree->numOfEntries; i++)
19397 + {
19398 + if (p_CcTree->keyAndNextEngineParams[i].nextEngineParams.nextEngine
19399 + == e_FM_PCD_CC)
19400 + UpdateNodeOwner(
19401 + p_CcTree->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode,
19402 + FALSE);
19403 +
19404 + if (p_CcTree->keyAndNextEngineParams[i].nextEngineParams.h_Manip)
19405 + FmPcdManipUpdateOwner(
19406 + p_CcTree->keyAndNextEngineParams[i].nextEngineParams.h_Manip,
19407 + FALSE);
19408 +
19409 +#ifdef FM_CAPWAP_SUPPORT
19410 + if ((p_CcTree->numOfGrps == 1) &&
19411 + (p_CcTree->fmPcdGroupParam[0].numOfEntriesInGroup == 1) &&
19412 + (p_CcTree->keyAndNextEngineParams[0].nextEngineParams.nextEngine == e_FM_PCD_CC) &&
19413 + p_CcTree->keyAndNextEngineParams[0].nextEngineParams.params.ccParams.h_CcNode &&
19414 + IsCapwapApplSpecific(p_CcTree->keyAndNextEngineParams[0].nextEngineParams.params.ccParams.h_CcNode))
19415 + {
19416 + if (FM_PCD_ManipNodeDelete(p_CcTree->keyAndNextEngineParams[0].nextEngineParams.h_Manip) != E_OK)
19417 + return E_INVALID_STATE;
19418 + }
19419 +#endif /* FM_CAPWAP_SUPPORT */
19420 +
19421 +#if (DPAA_VERSION >= 11)
19422 + if ((p_CcTree->keyAndNextEngineParams[i].nextEngineParams.nextEngine
19423 + == e_FM_PCD_FR)
19424 + && (p_CcTree->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic))
19425 + FrmReplicGroupUpdateOwner(
19426 + p_CcTree->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic,
19427 + FALSE);
19428 +#endif /* (DPAA_VERSION >= 11) */
19429 + }
19430 +
19431 + if (p_CcTree->p_Lock)
19432 + FmPcdReleaseLock(p_CcTree->h_FmPcd, p_CcTree->p_Lock);
19433 +
19434 + DeleteTree(p_CcTree, p_FmPcd);
19435 +
19436 + return E_OK;
19437 +}
19438 +
19439 +t_Error FM_PCD_CcRootModifyNextEngine(
19440 + t_Handle h_CcTree, uint8_t grpId, uint8_t index,
19441 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
19442 +{
19443 + t_FmPcd *p_FmPcd;
19444 + t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *)h_CcTree;
19445 + t_Error err = E_OK;
19446 +
19447 + SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
19448 + SANITY_CHECK_RETURN_ERROR(p_CcTree, E_INVALID_STATE);
19449 + p_FmPcd = (t_FmPcd *)p_CcTree->h_FmPcd;
19450 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
19451 +
19452 + if (!FmPcdLockTryLockAll(p_FmPcd))
19453 + {
19454 + DBG(TRACE, ("FmPcdLockTryLockAll failed"));
19455 + return ERROR_CODE(E_BUSY);
19456 + }
19457 +
19458 + err = FmPcdCcModifyNextEngineParamTree(p_FmPcd, p_CcTree, grpId, index,
19459 + p_FmPcdCcNextEngineParams);
19460 + FmPcdLockUnlockAll(p_FmPcd);
19461 +
19462 + if (err)
19463 + {
19464 + RETURN_ERROR(MAJOR, err, NO_MSG);
19465 + }
19466 +
19467 + return E_OK;
19468 +}
19469 +
19470 +t_Handle FM_PCD_MatchTableSet(t_Handle h_FmPcd,
19471 + t_FmPcdCcNodeParams *p_CcNodeParam)
19472 +{
19473 + t_FmPcdCcNode *p_CcNode;
19474 + t_Error err;
19475 +
19476 + SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);
19477 + SANITY_CHECK_RETURN_VALUE(p_CcNodeParam, E_NULL_POINTER, NULL);
19478 +
19479 + p_CcNode = (t_FmPcdCcNode*)XX_Malloc(sizeof(t_FmPcdCcNode));
19480 + if (!p_CcNode)
19481 + {
19482 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));
19483 + return NULL;
19484 + }
19485 + memset(p_CcNode, 0, sizeof(t_FmPcdCcNode));
19486 +
19487 + err = MatchTableSet(h_FmPcd, p_CcNode, p_CcNodeParam);
19488 +
19489 + switch(GET_ERROR_TYPE(err)
19490 +) {
19491 + case E_OK:
19492 + break;
19493 +
19494 + case E_BUSY:
19495 + DBG(TRACE, ("E_BUSY error"));
19496 + return NULL;
19497 +
19498 + default:
19499 + REPORT_ERROR(MAJOR, err, NO_MSG);
19500 + return NULL;
19501 + }
19502 +
19503 + return p_CcNode;
19504 +}
19505 +
19506 +t_Error FM_PCD_MatchTableDelete(t_Handle h_CcNode)
19507 +{
19508 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
19509 + int i = 0;
19510 +
19511 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
19512 + SANITY_CHECK_RETURN_ERROR(p_CcNode->h_FmPcd, E_INVALID_HANDLE);
19513 +
19514 + if (p_CcNode->owners)
19515 + RETURN_ERROR(
19516 + MAJOR,
19517 + E_INVALID_STATE,
19518 + ("This node cannot be removed because it is occupied; first unbind this node"));
19519 +
19520 + for (i = 0; i < p_CcNode->numOfKeys; i++)
19521 + if (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine
19522 + == e_FM_PCD_CC)
19523 + UpdateNodeOwner(
19524 + p_CcNode->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode,
19525 + FALSE);
19526 +
19527 + if (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine
19528 + == e_FM_PCD_CC)
19529 + UpdateNodeOwner(
19530 + p_CcNode->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode,
19531 + FALSE);
19532 +
19533 + /* Handle also Miss entry */
19534 + for (i = 0; i < p_CcNode->numOfKeys + 1; i++)
19535 + {
19536 + if (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip)
19537 + FmPcdManipUpdateOwner(
19538 + p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip,
19539 + FALSE);
19540 +
19541 +#if (DPAA_VERSION >= 11)
19542 + if ((p_CcNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine
19543 + == e_FM_PCD_FR)
19544 + && (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic))
19545 + {
19546 + FrmReplicGroupUpdateOwner(
19547 + p_CcNode->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic,
19548 + FALSE);
19549 + }
19550 +#endif /* (DPAA_VERSION >= 11) */
19551 + }
19552 +
19553 + DeleteNode(p_CcNode);
19554 +
19555 + return E_OK;
19556 +}
19557 +
19558 +t_Error FM_PCD_MatchTableAddKey(t_Handle h_CcNode, uint16_t keyIndex,
19559 + uint8_t keySize,
19560 + t_FmPcdCcKeyParams *p_KeyParams)
19561 +{
19562 + t_FmPcd *p_FmPcd;
19563 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
19564 + t_Error err = E_OK;
19565 +
19566 + SANITY_CHECK_RETURN_ERROR(p_KeyParams, E_NULL_POINTER);
19567 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
19568 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
19569 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
19570 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
19571 +
19572 + if (keyIndex == FM_PCD_LAST_KEY_INDEX)
19573 + keyIndex = p_CcNode->numOfKeys;
19574 +
19575 + if (!FmPcdLockTryLockAll(p_FmPcd))
19576 + {
19577 + DBG(TRACE, ("FmPcdLockTryLockAll failed"));
19578 + return ERROR_CODE(E_BUSY);
19579 + }
19580 +
19581 + err = FmPcdCcAddKey(p_FmPcd, p_CcNode, keyIndex, keySize, p_KeyParams);
19582 +
19583 + FmPcdLockUnlockAll(p_FmPcd);
19584 +
19585 + switch(GET_ERROR_TYPE(err)
19586 +) {
19587 + case E_OK:
19588 + return E_OK;
19589 +
19590 + case E_BUSY:
19591 + DBG(TRACE, ("E_BUSY error"));
19592 + return ERROR_CODE(E_BUSY);
19593 +
19594 + default:
19595 + RETURN_ERROR(MAJOR, err, NO_MSG);
19596 + }
19597 +}
19598 +
19599 +t_Error FM_PCD_MatchTableRemoveKey(t_Handle h_CcNode, uint16_t keyIndex)
19600 +{
19601 + t_FmPcd *p_FmPcd;
19602 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
19603 + t_Error err = E_OK;
19604 +
19605 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
19606 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
19607 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
19608 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
19609 +
19610 + if (!FmPcdLockTryLockAll(p_FmPcd))
19611 + {
19612 + DBG(TRACE, ("FmPcdLockTryLockAll failed"));
19613 + return ERROR_CODE(E_BUSY);
19614 + }
19615 +
19616 + err = FmPcdCcRemoveKey(p_FmPcd, p_CcNode, keyIndex);
19617 +
19618 + FmPcdLockUnlockAll(p_FmPcd);
19619 +
19620 + switch(GET_ERROR_TYPE(err)
19621 +) {
19622 + case E_OK:
19623 + return E_OK;
19624 +
19625 + case E_BUSY:
19626 + DBG(TRACE, ("E_BUSY error"));
19627 + return ERROR_CODE(E_BUSY);
19628 +
19629 + default:
19630 + RETURN_ERROR(MAJOR, err, NO_MSG);
19631 + }
19632 +
19633 + return E_OK;
19634 +}
19635 +
19636 +t_Error FM_PCD_MatchTableModifyKey(t_Handle h_CcNode, uint16_t keyIndex,
19637 + uint8_t keySize, uint8_t *p_Key,
19638 + uint8_t *p_Mask)
19639 +{
19640 + t_FmPcd *p_FmPcd;
19641 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
19642 + t_Error err = E_OK;
19643 +
19644 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
19645 + SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
19646 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
19647 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
19648 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
19649 +
19650 +
19651 + if (!FmPcdLockTryLockAll(p_FmPcd))
19652 + {
19653 + DBG(TRACE, ("FmPcdLockTryLockAll failed"));
19654 + return ERROR_CODE(E_BUSY);
19655 + }
19656 +
19657 + err = FmPcdCcModifyKey(p_FmPcd, p_CcNode, keyIndex, keySize, p_Key, p_Mask);
19658 +
19659 + FmPcdLockUnlockAll(p_FmPcd);
19660 +
19661 + switch(GET_ERROR_TYPE(err)
19662 +) {
19663 + case E_OK:
19664 + return E_OK;
19665 +
19666 + case E_BUSY:
19667 + DBG(TRACE, ("E_BUSY error"));
19668 + return ERROR_CODE(E_BUSY);
19669 +
19670 + default:
19671 + RETURN_ERROR(MAJOR, err, NO_MSG);
19672 + }
19673 +}
19674 +
19675 +t_Error FM_PCD_MatchTableModifyNextEngine(
19676 + t_Handle h_CcNode, uint16_t keyIndex,
19677 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
19678 +{
19679 + t_FmPcd *p_FmPcd;
19680 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
19681 + t_Error err = E_OK;
19682 +
19683 + SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
19684 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
19685 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
19686 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
19687 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
19688 +
19689 + if (!FmPcdLockTryLockAll(p_FmPcd))
19690 + {
19691 + DBG(TRACE, ("FmPcdLockTryLockAll failed"));
19692 + return ERROR_CODE(E_BUSY);
19693 + }
19694 +
19695 + err = ModifyNextEngineParamNode(p_FmPcd, p_CcNode, keyIndex,
19696 + p_FmPcdCcNextEngineParams);
19697 +
19698 + FmPcdLockUnlockAll(p_FmPcd);
19699 +
19700 + switch(GET_ERROR_TYPE(err)
19701 +) {
19702 + case E_OK:
19703 + return E_OK;
19704 +
19705 + case E_BUSY:
19706 + DBG(TRACE, ("E_BUSY error"));
19707 + return ERROR_CODE(E_BUSY);
19708 +
19709 + default:
19710 + RETURN_ERROR(MAJOR, err, NO_MSG);
19711 + }
19712 +}
19713 +
19714 +t_Error FM_PCD_MatchTableModifyMissNextEngine(
19715 + t_Handle h_CcNode, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
19716 +{
19717 + t_FmPcd *p_FmPcd;
19718 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
19719 + t_Error err = E_OK;
19720 +
19721 + SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
19722 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
19723 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
19724 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
19725 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
19726 +
19727 + if (!FmPcdLockTryLockAll(p_FmPcd))
19728 + {
19729 + DBG(TRACE, ("FmPcdLockTryLockAll failed"));
19730 + return ERROR_CODE(E_BUSY);
19731 + }
19732 +
19733 + err = FmPcdCcModifyMissNextEngineParamNode(p_FmPcd, p_CcNode,
19734 + p_FmPcdCcNextEngineParams);
19735 +
19736 + FmPcdLockUnlockAll(p_FmPcd);
19737 +
19738 + switch(GET_ERROR_TYPE(err)
19739 +) {
19740 + case E_OK:
19741 + return E_OK;
19742 +
19743 + case E_BUSY:
19744 + DBG(TRACE, ("E_BUSY error"));
19745 + return ERROR_CODE(E_BUSY);
19746 +
19747 + default:
19748 + RETURN_ERROR(MAJOR, err, NO_MSG);
19749 + }
19750 +}
19751 +
19752 +t_Error FM_PCD_MatchTableModifyKeyAndNextEngine(t_Handle h_CcNode,
19753 + uint16_t keyIndex,
19754 + uint8_t keySize,
19755 + t_FmPcdCcKeyParams *p_KeyParams)
19756 +{
19757 + t_FmPcd *p_FmPcd;
19758 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
19759 + t_Error err = E_OK;
19760 +
19761 + SANITY_CHECK_RETURN_ERROR(p_KeyParams, E_NULL_POINTER);
19762 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
19763 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
19764 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
19765 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
19766 +
19767 + if (!FmPcdLockTryLockAll(p_FmPcd))
19768 + {
19769 + DBG(TRACE, ("FmPcdLockTryLockAll failed"));
19770 + return ERROR_CODE(E_BUSY);
19771 + }
19772 +
19773 + err = FmPcdCcModifyKeyAndNextEngine(p_FmPcd, p_CcNode, keyIndex, keySize,
19774 + p_KeyParams);
19775 +
19776 + FmPcdLockUnlockAll(p_FmPcd);
19777 +
19778 + switch(GET_ERROR_TYPE(err)
19779 +) {
19780 + case E_OK:
19781 + return E_OK;
19782 +
19783 + case E_BUSY:
19784 + DBG(TRACE, ("E_BUSY error"));
19785 + return ERROR_CODE(E_BUSY);
19786 +
19787 + default:
19788 + RETURN_ERROR(MAJOR, err, NO_MSG);
19789 + }
19790 +}
19791 +
19792 +t_Error FM_PCD_MatchTableFindNRemoveKey(t_Handle h_CcNode, uint8_t keySize,
19793 + uint8_t *p_Key, uint8_t *p_Mask)
19794 +{
19795 + t_FmPcd *p_FmPcd;
19796 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
19797 + uint16_t keyIndex;
19798 + t_Error err;
19799 +
19800 + SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
19801 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
19802 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
19803 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
19804 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
19805 +
19806 + if (!FmPcdLockTryLockAll(p_FmPcd))
19807 + {
19808 + DBG(TRACE, ("FmPcdLockTryLockAll failed"));
19809 + return ERROR_CODE(E_BUSY);
19810 + }
19811 +
19812 + err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);
19813 + if (GET_ERROR_TYPE(err) != E_OK)
19814 + {
19815 + FmPcdLockUnlockAll(p_FmPcd);
19816 + RETURN_ERROR(
19817 + MAJOR,
19818 + err,
19819 + ("The received key and mask pair was not found in the match table of the provided node"));
19820 + }
19821 +
19822 + err = FmPcdCcRemoveKey(p_FmPcd, p_CcNode, keyIndex);
19823 +
19824 + FmPcdLockUnlockAll(p_FmPcd);
19825 +
19826 + switch(GET_ERROR_TYPE(err)
19827 +) {
19828 + case E_OK:
19829 + return E_OK;
19830 +
19831 + case E_BUSY:
19832 + DBG(TRACE, ("E_BUSY error"));
19833 + return ERROR_CODE(E_BUSY);
19834 +
19835 + default:
19836 + RETURN_ERROR(MAJOR, err, NO_MSG);
19837 + }
19838 +}
19839 +
19840 +t_Error FM_PCD_MatchTableFindNModifyNextEngine(
19841 + t_Handle h_CcNode, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask,
19842 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
19843 +{
19844 + t_FmPcd *p_FmPcd;
19845 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
19846 + uint16_t keyIndex;
19847 + t_Error err;
19848 +
19849 + SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
19850 + SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
19851 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
19852 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
19853 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
19854 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
19855 +
19856 + if (!FmPcdLockTryLockAll(p_FmPcd))
19857 + {
19858 + DBG(TRACE, ("FmPcdLockTryLockAll failed"));
19859 + return ERROR_CODE(E_BUSY);
19860 + }
19861 +
19862 + err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);
19863 + if (GET_ERROR_TYPE(err) != E_OK)
19864 + {
19865 + FmPcdLockUnlockAll(p_FmPcd);
19866 + RETURN_ERROR(
19867 + MAJOR,
19868 + err,
19869 + ("The received key and mask pair was not found in the match table of the provided node"));
19870 + }
19871 +
19872 + err = ModifyNextEngineParamNode(p_FmPcd, p_CcNode, keyIndex,
19873 + p_FmPcdCcNextEngineParams);
19874 +
19875 + FmPcdLockUnlockAll(p_FmPcd);
19876 +
19877 + switch(GET_ERROR_TYPE(err)
19878 +) {
19879 + case E_OK:
19880 + return E_OK;
19881 +
19882 + case E_BUSY:
19883 + DBG(TRACE, ("E_BUSY error"));
19884 + return ERROR_CODE(E_BUSY);
19885 +
19886 + default:
19887 + RETURN_ERROR(MAJOR, err, NO_MSG);
19888 + }
19889 +}
19890 +
19891 +t_Error FM_PCD_MatchTableFindNModifyKeyAndNextEngine(
19892 + t_Handle h_CcNode, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask,
19893 + t_FmPcdCcKeyParams *p_KeyParams)
19894 +{
19895 + t_FmPcd *p_FmPcd;
19896 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
19897 + uint16_t keyIndex;
19898 + t_Error err;
19899 +
19900 + SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
19901 + SANITY_CHECK_RETURN_ERROR(p_KeyParams, E_NULL_POINTER);
19902 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
19903 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
19904 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
19905 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
19906 +
19907 + if (!FmPcdLockTryLockAll(p_FmPcd))
19908 + {
19909 + DBG(TRACE, ("FmPcdLockTryLockAll failed"));
19910 + return ERROR_CODE(E_BUSY);
19911 + }
19912 +
19913 + err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);
19914 + if (GET_ERROR_TYPE(err) != E_OK)
19915 + {
19916 + FmPcdLockUnlockAll(p_FmPcd);
19917 + RETURN_ERROR(
19918 + MAJOR,
19919 + err,
19920 + ("The received key and mask pair was not found in the match table of the provided node"));
19921 + }
19922 +
19923 + err = FmPcdCcModifyKeyAndNextEngine(p_FmPcd, h_CcNode, keyIndex, keySize,
19924 + p_KeyParams);
19925 +
19926 + FmPcdLockUnlockAll(p_FmPcd);
19927 +
19928 + switch(GET_ERROR_TYPE(err)
19929 +) {
19930 + case E_OK:
19931 + return E_OK;
19932 +
19933 + case E_BUSY:
19934 + DBG(TRACE, ("E_BUSY error"));
19935 + return ERROR_CODE(E_BUSY);
19936 +
19937 + default:
19938 + RETURN_ERROR(MAJOR, err, NO_MSG);
19939 + }
19940 +}
19941 +
19942 +t_Error FM_PCD_MatchTableFindNModifyKey(t_Handle h_CcNode, uint8_t keySize,
19943 + uint8_t *p_Key, uint8_t *p_Mask,
19944 + uint8_t *p_NewKey, uint8_t *p_NewMask)
19945 +{
19946 + t_FmPcd *p_FmPcd;
19947 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
19948 + t_List h_List;
19949 + uint16_t keyIndex;
19950 + t_Error err;
19951 +
19952 + SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
19953 + SANITY_CHECK_RETURN_ERROR(p_NewKey, E_NULL_POINTER);
19954 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
19955 + p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
19956 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
19957 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
19958 +
19959 + INIT_LIST(&h_List);
19960 +
19961 + err = FmPcdCcNodeTreeTryLock(p_FmPcd, p_CcNode, &h_List);
19962 + if (err)
19963 + {
19964 + DBG(TRACE, ("Node's trees lock failed"));
19965 + return ERROR_CODE(E_BUSY);
19966 + }
19967 +
19968 + err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);
19969 + if (GET_ERROR_TYPE(err) != E_OK)
19970 + {
19971 + FmPcdCcNodeTreeReleaseLock(p_FmPcd, &h_List);
19972 + RETURN_ERROR(MAJOR, err,
19973 + ("The received key and mask pair was not found in the "
19974 + "match table of the provided node"));
19975 + }
19976 +
19977 + err = FmPcdCcModifyKey(p_FmPcd, p_CcNode, keyIndex, keySize, p_NewKey,
19978 + p_NewMask);
19979 +
19980 + FmPcdCcNodeTreeReleaseLock(p_FmPcd, &h_List);
19981 +
19982 + switch(GET_ERROR_TYPE(err)
19983 +) {
19984 + case E_OK:
19985 + return E_OK;
19986 +
19987 + case E_BUSY:
19988 + DBG(TRACE, ("E_BUSY error"));
19989 + return ERROR_CODE(E_BUSY);
19990 +
19991 + default:
19992 + RETURN_ERROR(MAJOR, err, NO_MSG);
19993 + }
19994 +}
19995 +
19996 +t_Error FM_PCD_MatchTableGetNextEngine(
19997 + t_Handle h_CcNode, uint16_t keyIndex,
19998 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
19999 +{
20000 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
20001 +
20002 + SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
20003 + SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
20004 +
20005 + if (keyIndex >= p_CcNode->numOfKeys)
20006 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
20007 + ("keyIndex exceeds current number of keys"));
20008 +
20009 + if (keyIndex > (FM_PCD_MAX_NUM_OF_KEYS - 1))
20010 + RETURN_ERROR(
20011 + MAJOR,
20012 + E_INVALID_VALUE,
20013 + ("keyIndex can not be larger than %d", (FM_PCD_MAX_NUM_OF_KEYS - 1)));
20014 +
20015 + memcpy(p_FmPcdCcNextEngineParams,
20016 + &p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams,
20017 + sizeof(t_FmPcdCcNextEngineParams));
20018 +
20019 + return E_OK;
20020 +}
20021 +
20022 +
20023 +uint32_t FM_PCD_MatchTableGetKeyCounter(t_Handle h_CcNode, uint16_t keyIndex)
20024 +{
20025 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
20026 + uint32_t *p_StatsCounters, frameCount;
20027 + uint32_t intFlags;
20028 +
20029 + SANITY_CHECK_RETURN_VALUE(p_CcNode, E_INVALID_HANDLE, 0);
20030 +
20031 + if (p_CcNode->statisticsMode == e_FM_PCD_CC_STATS_MODE_NONE)
20032 + {
20033 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Statistics were not enabled for this match table"));
20034 + return 0;
20035 + }
20036 +
20037 + if ((p_CcNode->statisticsMode != e_FM_PCD_CC_STATS_MODE_FRAME)
20038 + && (p_CcNode->statisticsMode
20039 + != e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME))
20040 + {
20041 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Frame count is not supported in the statistics mode of this match table"));
20042 + return 0;
20043 + }
20044 +
20045 + intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);
20046 +
20047 + if (keyIndex >= p_CcNode->numOfKeys)
20048 + {
20049 + XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
20050 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("The provided keyIndex exceeds the number of keys in this match table"));
20051 + return 0;
20052 + }
20053 +
20054 + if (!p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)
20055 + {
20056 + XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
20057 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Statistics were not enabled for this key"));
20058 + return 0;
20059 + }
20060 +
20061 + p_StatsCounters =
20062 + p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsCounters;
20063 + ASSERT_COND(p_StatsCounters);
20064 +
20065 + /* The first counter is byte counter, so we need to advance to the next counter */
20066 + frameCount = GET_UINT32(*(uint32_t *)(PTR_MOVE(p_StatsCounters,
20067 + FM_PCD_CC_STATS_COUNTER_SIZE)));
20068 +
20069 + XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
20070 +
20071 + return frameCount;
20072 +}
20073 +
20074 +t_Error FM_PCD_MatchTableGetKeyStatistics(
20075 + t_Handle h_CcNode, uint16_t keyIndex,
20076 + t_FmPcdCcKeyStatistics *p_KeyStatistics)
20077 +{
20078 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
20079 + uint32_t intFlags;
20080 + t_Error err;
20081 +
20082 + SANITY_CHECK_RETURN_ERROR(h_CcNode, E_INVALID_HANDLE);
20083 + SANITY_CHECK_RETURN_ERROR(p_KeyStatistics, E_NULL_POINTER);
20084 +
20085 + intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);
20086 +
20087 + if (keyIndex >= p_CcNode->numOfKeys)
20088 + RETURN_ERROR(
20089 + MAJOR,
20090 + E_INVALID_STATE,
20091 + ("The provided keyIndex exceeds the number of keys in this match table"));
20092 +
20093 + err = MatchTableGetKeyStatistics(p_CcNode, keyIndex, p_KeyStatistics);
20094 +
20095 + XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
20096 +
20097 + if (err != E_OK)
20098 + RETURN_ERROR(MAJOR, err, NO_MSG);
20099 +
20100 + return E_OK;
20101 +}
20102 +
20103 +t_Error FM_PCD_MatchTableGetMissStatistics(
20104 + t_Handle h_CcNode, t_FmPcdCcKeyStatistics *p_MissStatistics)
20105 +{
20106 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
20107 + uint32_t intFlags;
20108 + t_Error err;
20109 +
20110 + SANITY_CHECK_RETURN_ERROR(h_CcNode, E_INVALID_HANDLE);
20111 + SANITY_CHECK_RETURN_ERROR(p_MissStatistics, E_NULL_POINTER);
20112 +
20113 + intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);
20114 +
20115 + err = MatchTableGetKeyStatistics(p_CcNode, p_CcNode->numOfKeys,
20116 + p_MissStatistics);
20117 +
20118 + XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
20119 +
20120 + if (err != E_OK)
20121 + RETURN_ERROR(MAJOR, err, NO_MSG);
20122 +
20123 + return E_OK;
20124 +}
20125 +
20126 +t_Error FM_PCD_MatchTableFindNGetKeyStatistics(
20127 + t_Handle h_CcNode, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask,
20128 + t_FmPcdCcKeyStatistics *p_KeyStatistics)
20129 +{
20130 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
20131 + uint16_t keyIndex;
20132 + uint32_t intFlags;
20133 + t_Error err;
20134 +
20135 + SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
20136 + SANITY_CHECK_RETURN_ERROR(p_KeyStatistics, E_NULL_POINTER);
20137 +
20138 + intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);
20139 +
20140 + err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);
20141 + if (GET_ERROR_TYPE(err) != E_OK)
20142 + {
20143 + XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
20144 + RETURN_ERROR(MAJOR, err,
20145 + ("The received key and mask pair was not found in the "
20146 + "match table of the provided node"));
20147 + }
20148 +
20149 + ASSERT_COND(keyIndex < p_CcNode->numOfKeys);
20150 +
20151 + err = MatchTableGetKeyStatistics(p_CcNode, keyIndex, p_KeyStatistics);
20152 +
20153 + XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
20154 +
20155 + if (err != E_OK)
20156 + RETURN_ERROR(MAJOR, err, NO_MSG);
20157 +
20158 + return E_OK;
20159 +}
20160 +
20161 +t_Error FM_PCD_MatchTableGetIndexedHashBucket(t_Handle h_CcNode,
20162 + uint8_t keySize, uint8_t *p_Key,
20163 + uint8_t hashShift,
20164 + t_Handle *p_CcNodeBucketHandle,
20165 + uint8_t *p_BucketIndex,
20166 + uint16_t *p_LastIndex)
20167 +{
20168 + t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
20169 + uint16_t glblMask;
20170 + uint64_t crc64 = 0;
20171 +
20172 + SANITY_CHECK_RETURN_ERROR(h_CcNode, E_INVALID_HANDLE);
20173 + SANITY_CHECK_RETURN_ERROR(
20174 + p_CcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED,
20175 + E_INVALID_STATE);
20176 + SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
20177 + SANITY_CHECK_RETURN_ERROR(p_CcNodeBucketHandle, E_NULL_POINTER);
20178 +
20179 + memcpy(&glblMask, PTR_MOVE(p_CcNode->p_GlblMask, 2), 2);
20180 + be16_to_cpus(&glblMask);
20181 +
20182 + crc64 = crc64_init();
20183 + crc64 = crc64_compute(p_Key, keySize, crc64);
20184 + crc64 >>= hashShift;
20185 +
20186 + *p_BucketIndex = (uint8_t)(((crc64 >> (8 * (6 - p_CcNode->userOffset)))
20187 + & glblMask) >> 4);
20188 + if (*p_BucketIndex >= p_CcNode->numOfKeys)
20189 + RETURN_ERROR(MINOR, E_NOT_IN_RANGE, ("bucket index!"));
20190 +
20191 + *p_CcNodeBucketHandle =
20192 + p_CcNode->keyAndNextEngineParams[*p_BucketIndex].nextEngineParams.params.ccParams.h_CcNode;
20193 + if (!*p_CcNodeBucketHandle)
20194 + RETURN_ERROR(MINOR, E_NOT_FOUND, ("bucket!"));
20195 +
20196 + *p_LastIndex = ((t_FmPcdCcNode *)*p_CcNodeBucketHandle)->numOfKeys;
20197 +
20198 + return E_OK;
20199 +}
20200 +
20201 +t_Handle FM_PCD_HashTableSet(t_Handle h_FmPcd, t_FmPcdHashTableParams *p_Param)
20202 +{
20203 + t_FmPcdCcNode *p_CcNodeHashTbl;
20204 + t_FmPcdCcNodeParams *p_IndxHashCcNodeParam, *p_ExactMatchCcNodeParam;
20205 + t_FmPcdCcNode *p_CcNode;
20206 + t_Handle h_MissStatsCounters = NULL;
20207 + t_FmPcdCcKeyParams *p_HashKeyParams;
20208 + int i;
20209 + uint16_t numOfSets, numOfWays, countMask, onesCount = 0;
20210 + bool statsEnForMiss = FALSE;
20211 + t_Error err;
20212 +
20213 + SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);
20214 + SANITY_CHECK_RETURN_VALUE(p_Param, E_NULL_POINTER, NULL);
20215 +
20216 + if (p_Param->maxNumOfKeys == 0)
20217 + {
20218 + REPORT_ERROR(MINOR, E_INVALID_VALUE, ("Max number of keys must be higher then 0"));
20219 + return NULL;
20220 + }
20221 +
20222 + if (p_Param->hashResMask == 0)
20223 + {
20224 + REPORT_ERROR(MINOR, E_INVALID_VALUE, ("Hash result mask must differ from 0"));
20225 + return NULL;
20226 + }
20227 +
20228 +#if (DPAA_VERSION >= 11)
20229 + if (p_Param->statisticsMode == e_FM_PCD_CC_STATS_MODE_RMON)
20230 + {
20231 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
20232 + ("RMON statistics mode is not supported for hash table"));
20233 + return NULL;
20234 + }
20235 +#endif /* (DPAA_VERSION >= 11) */
20236 +
20237 + p_ExactMatchCcNodeParam = (t_FmPcdCcNodeParams*)XX_Malloc(
20238 + sizeof(t_FmPcdCcNodeParams));
20239 + if (!p_ExactMatchCcNodeParam)
20240 + {
20241 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_ExactMatchCcNodeParam"));
20242 + return NULL;
20243 + }
20244 + memset(p_ExactMatchCcNodeParam, 0, sizeof(t_FmPcdCcNodeParams));
20245 +
20246 + p_IndxHashCcNodeParam = (t_FmPcdCcNodeParams*)XX_Malloc(
20247 + sizeof(t_FmPcdCcNodeParams));
20248 + if (!p_IndxHashCcNodeParam)
20249 + {
20250 + XX_Free(p_ExactMatchCcNodeParam);
20251 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_IndxHashCcNodeParam"));
20252 + return NULL;
20253 + }
20254 + memset(p_IndxHashCcNodeParam, 0, sizeof(t_FmPcdCcNodeParams));
20255 +
20256 + /* Calculate number of sets and number of ways of the hash table */
20257 + countMask = (uint16_t)(p_Param->hashResMask >> 4);
20258 + while (countMask)
20259 + {
20260 + onesCount++;
20261 + countMask = (uint16_t)(countMask >> 1);
20262 + }
20263 +
20264 + numOfSets = (uint16_t)(1 << onesCount);
20265 + numOfWays = (uint16_t)DIV_CEIL(p_Param->maxNumOfKeys, numOfSets);
20266 +
20267 + if (p_Param->maxNumOfKeys % numOfSets)
20268 + DBG(INFO, ("'maxNumOfKeys' is not a multiple of hash number of ways, so number of ways will be rounded up"));
20269 +
20270 + if ((p_Param->statisticsMode == e_FM_PCD_CC_STATS_MODE_FRAME)
20271 + || (p_Param->statisticsMode == e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME))
20272 + {
20273 + /* Allocating a statistics counters table that will be used by all
20274 + 'miss' entries of the hash table */
20275 + h_MissStatsCounters = (t_Handle)FM_MURAM_AllocMem(
20276 + FmPcdGetMuramHandle(h_FmPcd), 2 * FM_PCD_CC_STATS_COUNTER_SIZE,
20277 + FM_PCD_CC_AD_TABLE_ALIGN);
20278 + if (!h_MissStatsCounters)
20279 + {
20280 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for statistics table for hash miss"));
20281 + XX_Free(p_IndxHashCcNodeParam);
20282 + XX_Free(p_ExactMatchCcNodeParam);
20283 + return NULL;
20284 + }
20285 + memset(h_MissStatsCounters, 0, (2 * FM_PCD_CC_STATS_COUNTER_SIZE));
20286 +
20287 + /* Always enable statistics for 'miss', so that a statistics AD will be
20288 + initialized from the start. We'll store the requested 'statistics enable'
20289 + value and it will be used when statistics are read by the user. */
20290 + statsEnForMiss = p_Param->ccNextEngineParamsForMiss.statisticsEn;
20291 + p_Param->ccNextEngineParamsForMiss.statisticsEn = TRUE;
20292 + }
20293 +
20294 + /* Building exact-match node params, will be used to create the hash buckets */
20295 + p_ExactMatchCcNodeParam->extractCcParams.type = e_FM_PCD_EXTRACT_NON_HDR;
20296 +
20297 + p_ExactMatchCcNodeParam->extractCcParams.extractNonHdr.src =
20298 + e_FM_PCD_EXTRACT_FROM_KEY;
20299 + p_ExactMatchCcNodeParam->extractCcParams.extractNonHdr.action =
20300 + e_FM_PCD_ACTION_EXACT_MATCH;
20301 + p_ExactMatchCcNodeParam->extractCcParams.extractNonHdr.offset = 0;
20302 + p_ExactMatchCcNodeParam->extractCcParams.extractNonHdr.size =
20303 + p_Param->matchKeySize;
20304 +
20305 + p_ExactMatchCcNodeParam->keysParams.maxNumOfKeys = numOfWays;
20306 + p_ExactMatchCcNodeParam->keysParams.maskSupport = FALSE;
20307 + p_ExactMatchCcNodeParam->keysParams.statisticsMode =
20308 + p_Param->statisticsMode;
20309 + p_ExactMatchCcNodeParam->keysParams.numOfKeys = 0;
20310 + p_ExactMatchCcNodeParam->keysParams.keySize = p_Param->matchKeySize;
20311 + p_ExactMatchCcNodeParam->keysParams.ccNextEngineParamsForMiss =
20312 + p_Param->ccNextEngineParamsForMiss;
20313 +
20314 + p_HashKeyParams = p_IndxHashCcNodeParam->keysParams.keyParams;
20315 +
20316 + for (i = 0; i < numOfSets; i++)
20317 + {
20318 + /* Each exact-match node will be marked as a 'bucket' and provided with
20319 + a pointer to statistics counters, to be used for 'miss' entry
20320 + statistics */
20321 + p_CcNode = (t_FmPcdCcNode *)XX_Malloc(sizeof(t_FmPcdCcNode));
20322 + if (!p_CcNode)
20323 + break;
20324 + memset(p_CcNode, 0, sizeof(t_FmPcdCcNode));
20325 +
20326 + p_CcNode->isHashBucket = TRUE;
20327 + p_CcNode->h_MissStatsCounters = h_MissStatsCounters;
20328 +
20329 + err = MatchTableSet(h_FmPcd, p_CcNode, p_ExactMatchCcNodeParam);
20330 + if (err)
20331 + break;
20332 +
20333 + p_HashKeyParams[i].ccNextEngineParams.nextEngine = e_FM_PCD_CC;
20334 + p_HashKeyParams[i].ccNextEngineParams.statisticsEn = FALSE;
20335 + p_HashKeyParams[i].ccNextEngineParams.params.ccParams.h_CcNode =
20336 + p_CcNode;
20337 + }
20338 +
20339 + if (i < numOfSets)
20340 + {
20341 + for (i = i - 1; i >= 0; i--)
20342 + FM_PCD_MatchTableDelete(
20343 + p_HashKeyParams[i].ccNextEngineParams.params.ccParams.h_CcNode);
20344 +
20345 + FM_MURAM_FreeMem(FmPcdGetMuramHandle(h_FmPcd), h_MissStatsCounters);
20346 +
20347 + REPORT_ERROR(MAJOR, E_NULL_POINTER, NO_MSG);
20348 + XX_Free(p_IndxHashCcNodeParam);
20349 + XX_Free(p_ExactMatchCcNodeParam);
20350 + return NULL;
20351 + }
20352 +
20353 + /* Creating indexed-hash CC node */
20354 + p_IndxHashCcNodeParam->extractCcParams.type = e_FM_PCD_EXTRACT_NON_HDR;
20355 + p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.src =
20356 + e_FM_PCD_EXTRACT_FROM_HASH;
20357 + p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.action =
20358 + e_FM_PCD_ACTION_INDEXED_LOOKUP;
20359 + p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.icIndxMask =
20360 + p_Param->hashResMask;
20361 + p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.offset =
20362 + p_Param->hashShift;
20363 + p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.size = 2;
20364 +
20365 + p_IndxHashCcNodeParam->keysParams.maxNumOfKeys = numOfSets;
20366 + p_IndxHashCcNodeParam->keysParams.maskSupport = FALSE;
20367 + p_IndxHashCcNodeParam->keysParams.statisticsMode =
20368 + e_FM_PCD_CC_STATS_MODE_NONE;
20369 + /* Number of keys of this node is number of sets of the hash */
20370 + p_IndxHashCcNodeParam->keysParams.numOfKeys = numOfSets;
20371 + p_IndxHashCcNodeParam->keysParams.keySize = 2;
20372 +
20373 + p_CcNodeHashTbl = FM_PCD_MatchTableSet(h_FmPcd, p_IndxHashCcNodeParam);
20374 +
20375 + if (p_CcNodeHashTbl)
20376 + {
20377 + p_CcNodeHashTbl->kgHashShift = p_Param->kgHashShift;
20378 +
20379 + /* Storing the allocated counters for buckets 'miss' in the hash table
20380 + and if statistics for miss were enabled. */
20381 + p_CcNodeHashTbl->h_MissStatsCounters = h_MissStatsCounters;
20382 + p_CcNodeHashTbl->statsEnForMiss = statsEnForMiss;
20383 + }
20384 +
20385 + XX_Free(p_IndxHashCcNodeParam);
20386 + XX_Free(p_ExactMatchCcNodeParam);
20387 +
20388 + return p_CcNodeHashTbl;
20389 +}
20390 +
20391 +t_Error FM_PCD_HashTableDelete(t_Handle h_HashTbl)
20392 +{
20393 + t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
20394 + t_Handle h_FmPcd;
20395 + t_Handle *p_HashBuckets, h_MissStatsCounters;
20396 + uint16_t i, numOfBuckets;
20397 + t_Error err;
20398 +
20399 + SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
20400 +
20401 + /* Store all hash buckets before the hash is freed */
20402 + numOfBuckets = p_HashTbl->numOfKeys;
20403 +
20404 + p_HashBuckets = (t_Handle *)XX_Malloc(numOfBuckets * sizeof(t_Handle));
20405 + if (!p_HashBuckets)
20406 + RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
20407 +
20408 + for (i = 0; i < numOfBuckets; i++)
20409 + p_HashBuckets[i] =
20410 + p_HashTbl->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode;
20411 +
20412 + h_FmPcd = p_HashTbl->h_FmPcd;
20413 + h_MissStatsCounters = p_HashTbl->h_MissStatsCounters;
20414 +
20415 + /* Free the hash */
20416 + err = FM_PCD_MatchTableDelete(p_HashTbl);
20417 +
20418 + /* Free each hash bucket */
20419 + for (i = 0; i < numOfBuckets; i++)
20420 + err |= FM_PCD_MatchTableDelete(p_HashBuckets[i]);
20421 +
20422 + XX_Free(p_HashBuckets);
20423 +
20424 + /* Free statistics counters for 'miss', if these were allocated */
20425 + if (h_MissStatsCounters)
20426 + FM_MURAM_FreeMem(FmPcdGetMuramHandle(h_FmPcd), h_MissStatsCounters);
20427 +
20428 + if (err)
20429 + RETURN_ERROR(MAJOR, err, NO_MSG);
20430 +
20431 + return E_OK;
20432 +}
20433 +
20434 +t_Error FM_PCD_HashTableAddKey(t_Handle h_HashTbl, uint8_t keySize,
20435 + t_FmPcdCcKeyParams *p_KeyParams)
20436 +{
20437 + t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
20438 + t_Handle h_HashBucket;
20439 + uint8_t bucketIndex;
20440 + uint16_t lastIndex;
20441 + t_Error err;
20442 +
20443 + SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
20444 + SANITY_CHECK_RETURN_ERROR(p_KeyParams, E_NULL_POINTER);
20445 + SANITY_CHECK_RETURN_ERROR(p_KeyParams->p_Key, E_NULL_POINTER);
20446 +
20447 + if (p_KeyParams->p_Mask)
20448 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
20449 + ("Keys masks not supported for hash table"));
20450 +
20451 + err = FM_PCD_MatchTableGetIndexedHashBucket(p_HashTbl, keySize,
20452 + p_KeyParams->p_Key,
20453 + p_HashTbl->kgHashShift,
20454 + &h_HashBucket, &bucketIndex,
20455 + &lastIndex);
20456 + if (err)
20457 + RETURN_ERROR(MAJOR, err, NO_MSG);
20458 +
20459 + return FM_PCD_MatchTableAddKey(h_HashBucket, FM_PCD_LAST_KEY_INDEX, keySize,
20460 + p_KeyParams);
20461 +}
20462 +
20463 +t_Error FM_PCD_HashTableRemoveKey(t_Handle h_HashTbl, uint8_t keySize,
20464 + uint8_t *p_Key)
20465 +{
20466 + t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
20467 + t_Handle h_HashBucket;
20468 + uint8_t bucketIndex;
20469 + uint16_t lastIndex;
20470 + t_Error err;
20471 +
20472 + SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
20473 + SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
20474 +
20475 + err = FM_PCD_MatchTableGetIndexedHashBucket(p_HashTbl, keySize, p_Key,
20476 + p_HashTbl->kgHashShift,
20477 + &h_HashBucket, &bucketIndex,
20478 + &lastIndex);
20479 + if (err)
20480 + RETURN_ERROR(MAJOR, err, NO_MSG);
20481 +
20482 + return FM_PCD_MatchTableFindNRemoveKey(h_HashBucket, keySize, p_Key, NULL);
20483 +}
20484 +
20485 +t_Error FM_PCD_HashTableModifyNextEngine(
20486 + t_Handle h_HashTbl, uint8_t keySize, uint8_t *p_Key,
20487 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
20488 +{
20489 + t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
20490 + t_Handle h_HashBucket;
20491 + uint8_t bucketIndex;
20492 + uint16_t lastIndex;
20493 + t_Error err;
20494 +
20495 + SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
20496 + SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
20497 + SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
20498 +
20499 + err = FM_PCD_MatchTableGetIndexedHashBucket(p_HashTbl, keySize, p_Key,
20500 + p_HashTbl->kgHashShift,
20501 + &h_HashBucket, &bucketIndex,
20502 + &lastIndex);
20503 + if (err)
20504 + RETURN_ERROR(MAJOR, err, NO_MSG);
20505 +
20506 + return FM_PCD_MatchTableFindNModifyNextEngine(h_HashBucket, keySize, p_Key,
20507 + NULL,
20508 + p_FmPcdCcNextEngineParams);
20509 +}
20510 +
20511 +t_Error FM_PCD_HashTableModifyMissNextEngine(
20512 + t_Handle h_HashTbl,
20513 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
20514 +{
20515 + t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
20516 + t_Handle h_HashBucket;
20517 + uint8_t i;
20518 + bool nullifyMissStats = FALSE;
20519 + t_Error err;
20520 +
20521 + SANITY_CHECK_RETURN_ERROR(h_HashTbl, E_INVALID_HANDLE);
20522 + SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
20523 +
20524 + if ((!p_HashTbl->h_MissStatsCounters)
20525 + && (p_FmPcdCcNextEngineParams->statisticsEn))
20526 + RETURN_ERROR(
20527 + MAJOR,
20528 + E_CONFLICT,
20529 + ("Statistics are requested for a key, but statistics mode was set"
20530 + "to 'NONE' upon initialization"));
20531 +
20532 + if (p_HashTbl->h_MissStatsCounters)
20533 + {
20534 + if ((!p_HashTbl->statsEnForMiss)
20535 + && (p_FmPcdCcNextEngineParams->statisticsEn))
20536 + nullifyMissStats = TRUE;
20537 +
20538 + if ((p_HashTbl->statsEnForMiss)
20539 + && (!p_FmPcdCcNextEngineParams->statisticsEn))
20540 + {
20541 + p_HashTbl->statsEnForMiss = FALSE;
20542 + p_FmPcdCcNextEngineParams->statisticsEn = TRUE;
20543 + }
20544 + }
20545 +
20546 + for (i = 0; i < p_HashTbl->numOfKeys; i++)
20547 + {
20548 + h_HashBucket =
20549 + p_HashTbl->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode;
20550 +
20551 + err = FM_PCD_MatchTableModifyMissNextEngine(h_HashBucket,
20552 + p_FmPcdCcNextEngineParams);
20553 + if (err)
20554 + RETURN_ERROR(MAJOR, err, NO_MSG);
20555 + }
20556 +
20557 + if (nullifyMissStats)
20558 + {
20559 + memset(p_HashTbl->h_MissStatsCounters, 0,
20560 + (2 * FM_PCD_CC_STATS_COUNTER_SIZE));
20561 + memset(p_HashTbl->h_MissStatsCounters, 0,
20562 + (2 * FM_PCD_CC_STATS_COUNTER_SIZE));
20563 + p_HashTbl->statsEnForMiss = TRUE;
20564 + }
20565 +
20566 + return E_OK;
20567 +}
20568 +
20569 +
20570 +t_Error FM_PCD_HashTableGetMissNextEngine(
20571 + t_Handle h_HashTbl,
20572 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
20573 +{
20574 + t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
20575 + t_FmPcdCcNode *p_HashBucket;
20576 +
20577 + SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
20578 +
20579 + /* Miss next engine of each bucket was initialized with the next engine of the hash table */
20580 + p_HashBucket =
20581 + p_HashTbl->keyAndNextEngineParams[0].nextEngineParams.params.ccParams.h_CcNode;
20582 +
20583 + memcpy(p_FmPcdCcNextEngineParams,
20584 + &p_HashBucket->keyAndNextEngineParams[p_HashBucket->numOfKeys].nextEngineParams,
20585 + sizeof(t_FmPcdCcNextEngineParams));
20586 +
20587 + return E_OK;
20588 +}
20589 +
20590 +t_Error FM_PCD_HashTableFindNGetKeyStatistics(
20591 + t_Handle h_HashTbl, uint8_t keySize, uint8_t *p_Key,
20592 + t_FmPcdCcKeyStatistics *p_KeyStatistics)
20593 +{
20594 + t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
20595 + t_Handle h_HashBucket;
20596 + uint8_t bucketIndex;
20597 + uint16_t lastIndex;
20598 + t_Error err;
20599 +
20600 + SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
20601 + SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
20602 + SANITY_CHECK_RETURN_ERROR(p_KeyStatistics, E_NULL_POINTER);
20603 +
20604 + err = FM_PCD_MatchTableGetIndexedHashBucket(p_HashTbl, keySize, p_Key,
20605 + p_HashTbl->kgHashShift,
20606 + &h_HashBucket, &bucketIndex,
20607 + &lastIndex);
20608 + if (err)
20609 + RETURN_ERROR(MAJOR, err, NO_MSG);
20610 +
20611 + return FM_PCD_MatchTableFindNGetKeyStatistics(h_HashBucket, keySize, p_Key,
20612 + NULL, p_KeyStatistics);
20613 +}
20614 +
20615 +t_Error FM_PCD_HashTableGetMissStatistics(
20616 + t_Handle h_HashTbl, t_FmPcdCcKeyStatistics *p_MissStatistics)
20617 +{
20618 + t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
20619 + t_Handle h_HashBucket;
20620 +
20621 + SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
20622 + SANITY_CHECK_RETURN_ERROR(p_MissStatistics, E_NULL_POINTER);
20623 +
20624 + if (!p_HashTbl->statsEnForMiss)
20625 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
20626 + ("Statistics were not enabled for miss"));
20627 +
20628 + h_HashBucket =
20629 + p_HashTbl->keyAndNextEngineParams[0].nextEngineParams.params.ccParams.h_CcNode;
20630 +
20631 + return FM_PCD_MatchTableGetMissStatistics(h_HashBucket, p_MissStatistics);
20632 +}
20633 --- /dev/null
20634 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.h
20635 @@ -0,0 +1,399 @@
20636 +/*
20637 + * Copyright 2008-2012 Freescale Semiconductor Inc.
20638 + *
20639 + * Redistribution and use in source and binary forms, with or without
20640 + * modification, are permitted provided that the following conditions are met:
20641 + * * Redistributions of source code must retain the above copyright
20642 + * notice, this list of conditions and the following disclaimer.
20643 + * * Redistributions in binary form must reproduce the above copyright
20644 + * notice, this list of conditions and the following disclaimer in the
20645 + * documentation and/or other materials provided with the distribution.
20646 + * * Neither the name of Freescale Semiconductor nor the
20647 + * names of its contributors may be used to endorse or promote products
20648 + * derived from this software without specific prior written permission.
20649 + *
20650 + *
20651 + * ALTERNATIVELY, this software may be distributed under the terms of the
20652 + * GNU General Public License ("GPL") as published by the Free Software
20653 + * Foundation, either version 2 of that License or (at your option) any
20654 + * later version.
20655 + *
20656 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
20657 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20658 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20659 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
20660 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20661 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20662 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20663 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20664 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
20665 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20666 + */
20667 +
20668 +
20669 +/******************************************************************************
20670 + @File fm_cc.h
20671 +
20672 + @Description FM PCD CC ...
20673 +*//***************************************************************************/
20674 +#ifndef __FM_CC_H
20675 +#define __FM_CC_H
20676 +
20677 +#include "std_ext.h"
20678 +#include "error_ext.h"
20679 +#include "list_ext.h"
20680 +
20681 +#include "fm_pcd.h"
20682 +
20683 +
20684 +/***********************************************************************/
20685 +/* Coarse classification defines */
20686 +/***********************************************************************/
20687 +
20688 +#define CC_MAX_NUM_OF_KEYS (FM_PCD_MAX_NUM_OF_KEYS + 1)
20689 +
20690 +#define CC_PC_FF_MACDST 0x00
20691 +#define CC_PC_FF_MACSRC 0x01
20692 +#define CC_PC_FF_ETYPE 0x02
20693 +
20694 +#define CC_PC_FF_TCI1 0x03
20695 +#define CC_PC_FF_TCI2 0x04
20696 +
20697 +#define CC_PC_FF_MPLS1 0x06
20698 +#define CC_PC_FF_MPLS_LAST 0x07
20699 +
20700 +#define CC_PC_FF_IPV4DST1 0x08
20701 +#define CC_PC_FF_IPV4DST2 0x16
20702 +#define CC_PC_FF_IPV4IPTOS_TC1 0x09
20703 +#define CC_PC_FF_IPV4IPTOS_TC2 0x17
20704 +#define CC_PC_FF_IPV4PTYPE1 0x0A
20705 +#define CC_PC_FF_IPV4PTYPE2 0x18
20706 +#define CC_PC_FF_IPV4SRC1 0x0b
20707 +#define CC_PC_FF_IPV4SRC2 0x19
20708 +#define CC_PC_FF_IPV4SRC1_IPV4DST1 0x0c
20709 +#define CC_PC_FF_IPV4SRC2_IPV4DST2 0x1a
20710 +#define CC_PC_FF_IPV4TTL 0x29
20711 +
20712 +
20713 +#define CC_PC_FF_IPTOS_IPV6TC1_IPV6FLOW1 0x0d /*TODO - CLASS - what is it? TOS*/
20714 +#define CC_PC_FF_IPTOS_IPV6TC2_IPV6FLOW2 0x1b
20715 +#define CC_PC_FF_IPV6PTYPE1 0x0e
20716 +#define CC_PC_FF_IPV6PTYPE2 0x1c
20717 +#define CC_PC_FF_IPV6DST1 0x0f
20718 +#define CC_PC_FF_IPV6DST2 0x1d
20719 +#define CC_PC_FF_IPV6SRC1 0x10
20720 +#define CC_PC_FF_IPV6SRC2 0x1e
20721 +#define CC_PC_FF_IPV6HOP_LIMIT 0x2a
20722 +#define CC_PC_FF_IPPID 0x24
20723 +#define CC_PC_FF_IPDSCP 0x76
20724 +
20725 +#define CC_PC_FF_GREPTYPE 0x11
20726 +
20727 +#define CC_PC_FF_MINENCAP_PTYPE 0x12
20728 +#define CC_PC_FF_MINENCAP_IPDST 0x13
20729 +#define CC_PC_FF_MINENCAP_IPSRC 0x14
20730 +#define CC_PC_FF_MINENCAP_IPSRC_IPDST 0x15
20731 +
20732 +#define CC_PC_FF_L4PSRC 0x1f
20733 +#define CC_PC_FF_L4PDST 0x20
20734 +#define CC_PC_FF_L4PSRC_L4PDST 0x21
20735 +
20736 +#define CC_PC_FF_PPPPID 0x05
20737 +
20738 +#define CC_PC_PR_SHIM1 0x22
20739 +#define CC_PC_PR_SHIM2 0x23
20740 +
20741 +#define CC_PC_GENERIC_WITHOUT_MASK 0x27
20742 +#define CC_PC_GENERIC_WITH_MASK 0x28
20743 +#define CC_PC_GENERIC_IC_GMASK 0x2B
20744 +#define CC_PC_GENERIC_IC_HASH_INDEXED 0x2C
20745 +#define CC_PC_GENERIC_IC_AGING_MASK 0x2D
20746 +
20747 +#define CC_PR_OFFSET 0x25
20748 +#define CC_PR_WITHOUT_OFFSET 0x26
20749 +
20750 +#define CC_PC_PR_ETH_OFFSET 19
20751 +#define CC_PC_PR_USER_DEFINED_SHIM1_OFFSET 16
20752 +#define CC_PC_PR_USER_DEFINED_SHIM2_OFFSET 17
20753 +#define CC_PC_PR_USER_LLC_SNAP_OFFSET 20
20754 +#define CC_PC_PR_VLAN1_OFFSET 21
20755 +#define CC_PC_PR_VLAN2_OFFSET 22
20756 +#define CC_PC_PR_PPPOE_OFFSET 24
20757 +#define CC_PC_PR_MPLS1_OFFSET 25
20758 +#define CC_PC_PR_MPLS_LAST_OFFSET 26
20759 +#define CC_PC_PR_IP1_OFFSET 27
20760 +#define CC_PC_PR_IP_LAST_OFFSET 28
20761 +#define CC_PC_PR_MINENC_OFFSET 28
20762 +#define CC_PC_PR_L4_OFFSET 30
20763 +#define CC_PC_PR_GRE_OFFSET 29
20764 +#define CC_PC_PR_ETYPE_LAST_OFFSET 23
20765 +#define CC_PC_PR_NEXT_HEADER_OFFSET 31
20766 +
20767 +#define CC_PC_ILLEGAL 0xff
20768 +#define CC_SIZE_ILLEGAL 0
20769 +
20770 +#define FM_PCD_CC_KEYS_MATCH_TABLE_ALIGN 16
20771 +#define FM_PCD_CC_AD_TABLE_ALIGN 16
20772 +#define FM_PCD_CC_AD_ENTRY_SIZE 16
20773 +#define FM_PCD_CC_NUM_OF_KEYS 255
20774 +#define FM_PCD_CC_TREE_ADDR_ALIGN 256
20775 +
20776 +#define FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE 0x00000000
20777 +#define FM_PCD_AD_RESULT_DATA_FLOW_TYPE 0x80000000
20778 +#define FM_PCD_AD_RESULT_PLCR_DIS 0x20000000
20779 +#define FM_PCD_AD_RESULT_EXTENDED_MODE 0x80000000
20780 +#define FM_PCD_AD_RESULT_NADEN 0x20000000
20781 +#define FM_PCD_AD_RESULT_STATISTICS_EN 0x40000000
20782 +
20783 +#define FM_PCD_AD_CONT_LOOKUP_TYPE 0x40000000
20784 +#define FM_PCD_AD_CONT_LOOKUP_LCL_MASK 0x00800000
20785 +
20786 +#define FM_PCD_AD_STATS_TYPE 0x40000000
20787 +#define FM_PCD_AD_STATS_FLR_ADDR_MASK 0x00FFFFFF
20788 +#define FM_PCD_AD_STATS_COUNTERS_ADDR_MASK 0x00FFFFFF
20789 +#define FM_PCD_AD_STATS_NEXT_ACTION_MASK 0xFFFF0000
20790 +#define FM_PCD_AD_STATS_NEXT_ACTION_SHIFT 12
20791 +#define FM_PCD_AD_STATS_NAD_EN 0x00008000
20792 +#define FM_PCD_AD_STATS_OP_CODE 0x00000036
20793 +#define FM_PCD_AD_STATS_FLR_EN 0x00004000
20794 +#define FM_PCD_AD_STATS_COND_EN 0x00002000
20795 +
20796 +
20797 +
20798 +#define FM_PCD_AD_BYPASS_TYPE 0xc0000000
20799 +
20800 +#define FM_PCD_AD_TYPE_MASK 0xc0000000
20801 +#define FM_PCD_AD_OPCODE_MASK 0x0000000f
20802 +
20803 +#define FM_PCD_AD_PROFILEID_FOR_CNTRL_SHIFT 16
20804 +#if (DPAA_VERSION >= 11)
20805 +#define FM_PCD_AD_RESULT_VSP_SHIFT 24
20806 +#define FM_PCD_AD_RESULT_NO_OM_VSPE 0x02000000
20807 +#define FM_PCD_AD_RESULT_VSP_MASK 0x3f
20808 +#define FM_PCD_AD_NCSPFQIDM_MASK 0x80000000
20809 +#endif /* (DPAA_VERSION >= 11) */
20810 +
20811 +#define GLBL_MASK_FOR_HASH_INDEXED 0xfff00000
20812 +#define CC_GLBL_MASK_SIZE 4
20813 +#define CC_AGING_MASK_SIZE 4
20814 +
20815 +typedef uint32_t ccPrivateInfo_t; /**< private info of CC: */
20816 +
20817 +#define CC_PRIVATE_INFO_NONE 0
20818 +#define CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP 0x80000000
20819 +#define CC_PRIVATE_INFO_IC_HASH_EXACT_MATCH 0x40000000
20820 +#define CC_PRIVATE_INFO_IC_KEY_EXACT_MATCH 0x20000000
20821 +#define CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP 0x10000000
20822 +
20823 +#define CC_BUILD_AGING_MASK(numOfKeys) ((((1LL << ((numOfKeys) + 1)) - 1)) << (31 - (numOfKeys)))
20824 +/***********************************************************************/
20825 +/* Memory map */
20826 +/***********************************************************************/
20827 +#if defined(__MWERKS__) && !defined(__GNUC__)
20828 +#pragma pack(push,1)
20829 +#endif /* defined(__MWERKS__) && ... */
20830 +
20831 +typedef struct
20832 +{
20833 + volatile uint32_t fqid;
20834 + volatile uint32_t plcrProfile;
20835 + volatile uint32_t nia;
20836 + volatile uint32_t res;
20837 +} t_AdOfTypeResult;
20838 +
20839 +typedef struct
20840 +{
20841 + volatile uint32_t ccAdBase;
20842 + volatile uint32_t matchTblPtr;
20843 + volatile uint32_t pcAndOffsets;
20844 + volatile uint32_t gmask;
20845 +} t_AdOfTypeContLookup;
20846 +
20847 +typedef struct
20848 +{
20849 + volatile uint32_t profileTableAddr;
20850 + volatile uint32_t reserved;
20851 + volatile uint32_t nextActionIndx;
20852 + volatile uint32_t statsTableAddr;
20853 +} t_AdOfTypeStats;
20854 +
20855 +typedef union
20856 +{
20857 + volatile t_AdOfTypeResult adResult;
20858 + volatile t_AdOfTypeContLookup adContLookup;
20859 +} t_Ad;
20860 +
20861 +#if defined(__MWERKS__) && !defined(__GNUC__)
20862 +#pragma pack(pop)
20863 +#endif /* defined(__MWERKS__) && ... */
20864 +
20865 +
20866 +/***********************************************************************/
20867 +/* Driver's internal structures */
20868 +/***********************************************************************/
20869 +
20870 +typedef struct t_FmPcdStatsObj
20871 +{
20872 + t_Handle h_StatsAd;
20873 + t_Handle h_StatsCounters;
20874 + t_List node;
20875 +} t_FmPcdStatsObj;
20876 +
20877 +typedef struct
20878 +{
20879 + uint8_t key[FM_PCD_MAX_SIZE_OF_KEY];
20880 + uint8_t mask[FM_PCD_MAX_SIZE_OF_KEY];
20881 +
20882 + t_FmPcdCcNextEngineParams nextEngineParams;
20883 + uint32_t requiredAction;
20884 + uint32_t shadowAction;
20885 +
20886 + t_FmPcdStatsObj *p_StatsObj;
20887 +
20888 +} t_FmPcdCcKeyAndNextEngineParams;
20889 +
20890 +typedef struct
20891 +{
20892 + t_Handle p_Ad;
20893 + e_FmPcdEngine fmPcdEngine;
20894 + bool adAllocated;
20895 + bool isTree;
20896 +
20897 + uint32_t myInfo;
20898 + t_List *h_CcNextNodesLst;
20899 + t_Handle h_AdditionalInfo;
20900 + t_Handle h_Node;
20901 +} t_FmPcdModifyCcAdditionalParams;
20902 +
20903 +typedef struct
20904 +{
20905 + t_Handle p_AdTableNew;
20906 + t_Handle p_KeysMatchTableNew;
20907 + t_Handle p_AdTableOld;
20908 + t_Handle p_KeysMatchTableOld;
20909 + uint16_t numOfKeys;
20910 + t_Handle h_CurrentNode;
20911 + uint16_t savedKeyIndex;
20912 + t_Handle h_NodeForAdd;
20913 + t_Handle h_NodeForRmv;
20914 + t_Handle h_ManipForRmv;
20915 + t_Handle h_ManipForAdd;
20916 + t_FmPcdStatsObj *p_StatsObjForRmv;
20917 +#if (DPAA_VERSION >= 11)
20918 + t_Handle h_FrmReplicForAdd;
20919 + t_Handle h_FrmReplicForRmv;
20920 +#endif /* (DPAA_VERSION >= 11) */
20921 + bool tree;
20922 +
20923 + t_FmPcdCcKeyAndNextEngineParams keyAndNextEngineParams[CC_MAX_NUM_OF_KEYS];
20924 +} t_FmPcdModifyCcKeyAdditionalParams;
20925 +
20926 +typedef struct
20927 +{
20928 + t_Handle h_Manip;
20929 + t_Handle h_CcNode;
20930 +} t_CcNextEngineInfo;
20931 +
20932 +typedef struct
20933 +{
20934 + uint16_t numOfKeys;
20935 + uint16_t maxNumOfKeys;
20936 +
20937 + bool maskSupport;
20938 + uint32_t keysMatchTableMaxSize;
20939 +
20940 + e_FmPcdCcStatsMode statisticsMode;
20941 + uint32_t numOfStatsFLRs;
20942 + uint32_t countersArraySize;
20943 +
20944 + bool isHashBucket; /**< Valid for match table node that is a bucket of a hash table only */
20945 + t_Handle h_MissStatsCounters; /**< Valid for hash table node and match table that is a bucket;
20946 + Holds the statistics counters allocated by the hash table and
20947 + are shared by all hash table buckets; */
20948 + t_Handle h_PrivMissStatsCounters; /**< Valid for match table node that is a bucket of a hash table only;
20949 + Holds the statistics counters that were allocated for this node
20950 + and replaced by the shared counters (allocated by the hash table); */
20951 + bool statsEnForMiss; /**< Valid for hash table node only; TRUE is statistics are currently
20952 + enabled for hash 'miss', FALSE otherwise; This parameter effects the
20953 + returned statistics count to user, statistics AD always present for 'miss'
20954 + for all hash buckets; */
20955 + bool glblMaskUpdated;
20956 + t_Handle p_GlblMask;
20957 + bool lclMask;
20958 + uint8_t parseCode;
20959 + uint8_t offset;
20960 + uint8_t prsArrayOffset;
20961 + bool ctrlFlow;
20962 + uint16_t owners;
20963 +
20964 + uint8_t ccKeySizeAccExtraction;
20965 + uint8_t sizeOfExtraction;
20966 + uint8_t glblMaskSize;
20967 +
20968 + t_Handle h_KeysMatchTable;
20969 + t_Handle h_AdTable;
20970 + t_Handle h_StatsAds;
20971 + t_Handle h_TmpAd;
20972 + t_Handle h_Ad;
20973 + t_Handle h_StatsFLRs;
20974 +
20975 + t_List availableStatsLst;
20976 +
20977 + t_List ccPrevNodesLst;
20978 +
20979 + t_List ccTreeIdLst;
20980 + t_List ccTreesLst;
20981 +
20982 + t_Handle h_FmPcd;
20983 + uint32_t shadowAction;
20984 + uint8_t userSizeOfExtraction;
20985 + uint8_t userOffset;
20986 + uint8_t kgHashShift; /* used in hash-table */
20987 +
20988 + t_Handle h_Spinlock;
20989 +
20990 + t_FmPcdCcKeyAndNextEngineParams keyAndNextEngineParams[CC_MAX_NUM_OF_KEYS];
20991 +} t_FmPcdCcNode;
20992 +
20993 +typedef struct
20994 +{
20995 + t_FmPcdCcNode *p_FmPcdCcNode;
20996 + bool occupied;
20997 + uint16_t owners;
20998 + volatile bool lock;
20999 +} t_FmPcdCcNodeArray;
21000 +
21001 +typedef struct
21002 +{
21003 + uint8_t numOfEntriesInGroup;
21004 + uint32_t totalBitsMask;
21005 + uint8_t baseGroupEntry;
21006 +} t_FmPcdCcGroupParam;
21007 +
21008 +typedef struct
21009 +{
21010 + t_Handle h_FmPcd;
21011 + uint8_t netEnvId;
21012 + uintptr_t ccTreeBaseAddr;
21013 + uint8_t numOfGrps;
21014 + t_FmPcdCcGroupParam fmPcdGroupParam[FM_PCD_MAX_NUM_OF_CC_GROUPS];
21015 + t_List fmPortsLst;
21016 + t_FmPcdLock *p_Lock;
21017 + uint8_t numOfEntries;
21018 + uint16_t owners;
21019 + t_Handle h_FmPcdCcSavedManipParams;
21020 + bool modifiedState;
21021 + uint32_t requiredAction;
21022 + t_Handle h_IpReassemblyManip;
21023 + t_Handle h_CapwapReassemblyManip;
21024 +
21025 + t_FmPcdCcKeyAndNextEngineParams keyAndNextEngineParams[FM_PCD_MAX_NUM_OF_CC_GROUPS];
21026 +} t_FmPcdCcTree;
21027 +
21028 +
21029 +t_Error FmPcdCcNodeTreeTryLock(t_Handle h_FmPcd,t_Handle h_FmPcdCcNode, t_List *p_List);
21030 +void FmPcdCcNodeTreeReleaseLock(t_Handle h_FmPcd, t_List *p_List);
21031 +t_Error FmPcdUpdateCcShadow (t_FmPcd *p_FmPcd, uint32_t size, uint32_t align);
21032 +
21033 +
21034 +#endif /* __FM_CC_H */
21035 --- /dev/null
21036 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c
21037 @@ -0,0 +1,3242 @@
21038 +/*
21039 + * Copyright 2008-2012 Freescale Semiconductor Inc.
21040 + *
21041 + * Redistribution and use in source and binary forms, with or without
21042 + * modification, are permitted provided that the following conditions are met:
21043 + * * Redistributions of source code must retain the above copyright
21044 + * notice, this list of conditions and the following disclaimer.
21045 + * * Redistributions in binary form must reproduce the above copyright
21046 + * notice, this list of conditions and the following disclaimer in the
21047 + * documentation and/or other materials provided with the distribution.
21048 + * * Neither the name of Freescale Semiconductor nor the
21049 + * names of its contributors may be used to endorse or promote products
21050 + * derived from this software without specific prior written permission.
21051 + *
21052 + *
21053 + * ALTERNATIVELY, this software may be distributed under the terms of the
21054 + * GNU General Public License ("GPL") as published by the Free Software
21055 + * Foundation, either version 2 of that License or (at your option) any
21056 + * later version.
21057 + *
21058 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
21059 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21060 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21061 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
21062 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21063 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21064 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21065 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21066 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21067 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21068 + */
21069 +
21070 +
21071 +/******************************************************************************
21072 + @File fm_kg.c
21073 +
21074 + @Description FM PCD ...
21075 +*//***************************************************************************/
21076 +#include "std_ext.h"
21077 +#include "error_ext.h"
21078 +#include "string_ext.h"
21079 +#include "debug_ext.h"
21080 +#include "net_ext.h"
21081 +#include "fm_port_ext.h"
21082 +
21083 +#include "fm_common.h"
21084 +#include "fm_pcd.h"
21085 +#include "fm_hc.h"
21086 +#include "fm_pcd_ipc.h"
21087 +#include "fm_kg.h"
21088 +#include "fsl_fman_kg.h"
21089 +
21090 +
21091 +/****************************************/
21092 +/* static functions */
21093 +/****************************************/
21094 +
21095 +static uint32_t KgHwLock(t_Handle h_FmPcdKg)
21096 +{
21097 + ASSERT_COND(h_FmPcdKg);
21098 + return XX_LockIntrSpinlock(((t_FmPcdKg *)h_FmPcdKg)->h_HwSpinlock);
21099 +}
21100 +
21101 +static void KgHwUnlock(t_Handle h_FmPcdKg, uint32_t intFlags)
21102 +{
21103 + ASSERT_COND(h_FmPcdKg);
21104 + XX_UnlockIntrSpinlock(((t_FmPcdKg *)h_FmPcdKg)->h_HwSpinlock, intFlags);
21105 +}
21106 +
21107 +static uint32_t KgSchemeLock(t_Handle h_Scheme)
21108 +{
21109 + ASSERT_COND(h_Scheme);
21110 + return FmPcdLockSpinlock(((t_FmPcdKgScheme *)h_Scheme)->p_Lock);
21111 +}
21112 +
21113 +static void KgSchemeUnlock(t_Handle h_Scheme, uint32_t intFlags)
21114 +{
21115 + ASSERT_COND(h_Scheme);
21116 + FmPcdUnlockSpinlock(((t_FmPcdKgScheme *)h_Scheme)->p_Lock, intFlags);
21117 +}
21118 +
21119 +static bool KgSchemeFlagTryLock(t_Handle h_Scheme)
21120 +{
21121 + ASSERT_COND(h_Scheme);
21122 + return FmPcdLockTryLock(((t_FmPcdKgScheme *)h_Scheme)->p_Lock);
21123 +}
21124 +
21125 +static void KgSchemeFlagUnlock(t_Handle h_Scheme)
21126 +{
21127 + ASSERT_COND(h_Scheme);
21128 + FmPcdLockUnlock(((t_FmPcdKgScheme *)h_Scheme)->p_Lock);
21129 +}
21130 +
21131 +static t_Error WriteKgarWait(t_FmPcd *p_FmPcd, uint32_t fmkg_ar)
21132 +{
21133 +
21134 + struct fman_kg_regs *regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
21135 +
21136 + if (fman_kg_write_ar_wait(regs, fmkg_ar))
21137 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Keygen scheme access violation"));
21138 +
21139 + return E_OK;
21140 +}
21141 +
21142 +static e_FmPcdKgExtractDfltSelect GetGenericSwDefault(t_FmPcdKgExtractDflt swDefaults[], uint8_t numOfSwDefaults, uint8_t code)
21143 +{
21144 + int i;
21145 +
21146 + switch (code)
21147 + {
21148 + case (KG_SCH_GEN_PARSE_RESULT_N_FQID):
21149 + case (KG_SCH_GEN_DEFAULT):
21150 + case (KG_SCH_GEN_NEXTHDR):
21151 + for (i=0 ; i<numOfSwDefaults ; i++)
21152 + if (swDefaults[i].type == e_FM_PCD_KG_GENERIC_NOT_FROM_DATA)
21153 + return swDefaults[i].dfltSelect;
21154 + break;
21155 + case (KG_SCH_GEN_SHIM1):
21156 + case (KG_SCH_GEN_SHIM2):
21157 + case (KG_SCH_GEN_IP_PID_NO_V):
21158 + case (KG_SCH_GEN_ETH_NO_V):
21159 + case (KG_SCH_GEN_SNAP_NO_V):
21160 + case (KG_SCH_GEN_VLAN1_NO_V):
21161 + case (KG_SCH_GEN_VLAN2_NO_V):
21162 + case (KG_SCH_GEN_ETH_TYPE_NO_V):
21163 + case (KG_SCH_GEN_PPP_NO_V):
21164 + case (KG_SCH_GEN_MPLS1_NO_V):
21165 + case (KG_SCH_GEN_MPLS_LAST_NO_V):
21166 + case (KG_SCH_GEN_L3_NO_V):
21167 + case (KG_SCH_GEN_IP2_NO_V):
21168 + case (KG_SCH_GEN_GRE_NO_V):
21169 + case (KG_SCH_GEN_L4_NO_V):
21170 + for (i=0 ; i<numOfSwDefaults ; i++)
21171 + if (swDefaults[i].type == e_FM_PCD_KG_GENERIC_FROM_DATA_NO_V)
21172 + return swDefaults[i].dfltSelect;
21173 + break;
21174 + case (KG_SCH_GEN_START_OF_FRM):
21175 + case (KG_SCH_GEN_ETH):
21176 + case (KG_SCH_GEN_SNAP):
21177 + case (KG_SCH_GEN_VLAN1):
21178 + case (KG_SCH_GEN_VLAN2):
21179 + case (KG_SCH_GEN_ETH_TYPE):
21180 + case (KG_SCH_GEN_PPP):
21181 + case (KG_SCH_GEN_MPLS1):
21182 + case (KG_SCH_GEN_MPLS2):
21183 + case (KG_SCH_GEN_MPLS3):
21184 + case (KG_SCH_GEN_MPLS_LAST):
21185 + case (KG_SCH_GEN_IPV4):
21186 + case (KG_SCH_GEN_IPV6):
21187 + case (KG_SCH_GEN_IPV4_TUNNELED):
21188 + case (KG_SCH_GEN_IPV6_TUNNELED):
21189 + case (KG_SCH_GEN_MIN_ENCAP):
21190 + case (KG_SCH_GEN_GRE):
21191 + case (KG_SCH_GEN_TCP):
21192 + case (KG_SCH_GEN_UDP):
21193 + case (KG_SCH_GEN_IPSEC_AH):
21194 + case (KG_SCH_GEN_SCTP):
21195 + case (KG_SCH_GEN_DCCP):
21196 + case (KG_SCH_GEN_IPSEC_ESP):
21197 + for (i=0 ; i<numOfSwDefaults ; i++)
21198 + if (swDefaults[i].type == e_FM_PCD_KG_GENERIC_FROM_DATA)
21199 + return swDefaults[i].dfltSelect;
21200 + break;
21201 + default:
21202 + break;
21203 + }
21204 +
21205 + return e_FM_PCD_KG_DFLT_ILLEGAL;
21206 +}
21207 +
21208 +static uint8_t GetGenCode(e_FmPcdExtractFrom src, uint8_t *p_Offset)
21209 +{
21210 + *p_Offset = 0;
21211 +
21212 + switch (src)
21213 + {
21214 + case (e_FM_PCD_EXTRACT_FROM_FRAME_START):
21215 + return KG_SCH_GEN_START_OF_FRM;
21216 + case (e_FM_PCD_EXTRACT_FROM_DFLT_VALUE):
21217 + return KG_SCH_GEN_DEFAULT;
21218 + case (e_FM_PCD_EXTRACT_FROM_PARSE_RESULT):
21219 + return KG_SCH_GEN_PARSE_RESULT_N_FQID;
21220 + case (e_FM_PCD_EXTRACT_FROM_ENQ_FQID):
21221 + *p_Offset = 32;
21222 + return KG_SCH_GEN_PARSE_RESULT_N_FQID;
21223 + case (e_FM_PCD_EXTRACT_FROM_CURR_END_OF_PARSE):
21224 + return KG_SCH_GEN_NEXTHDR;
21225 + default:
21226 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 'extract from' src"));
21227 + return 0;
21228 + }
21229 +}
21230 +
21231 +static uint8_t GetGenHdrCode(e_NetHeaderType hdr, e_FmPcdHdrIndex hdrIndex, bool ignoreProtocolValidation)
21232 +{
21233 + if (!ignoreProtocolValidation)
21234 + switch (hdr)
21235 + {
21236 + case (HEADER_TYPE_NONE):
21237 + ASSERT_COND(FALSE);
21238 + case (HEADER_TYPE_ETH):
21239 + return KG_SCH_GEN_ETH;
21240 + case (HEADER_TYPE_LLC_SNAP):
21241 + return KG_SCH_GEN_SNAP;
21242 + case (HEADER_TYPE_PPPoE):
21243 + return KG_SCH_GEN_PPP;
21244 + case (HEADER_TYPE_MPLS):
21245 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
21246 + return KG_SCH_GEN_MPLS1;
21247 + if (hdrIndex == e_FM_PCD_HDR_INDEX_2)
21248 + return KG_SCH_GEN_MPLS2;
21249 + if (hdrIndex == e_FM_PCD_HDR_INDEX_3)
21250 + return KG_SCH_GEN_MPLS3;
21251 + if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
21252 + return KG_SCH_GEN_MPLS_LAST;
21253 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal MPLS header index"));
21254 + return 0;
21255 + case (HEADER_TYPE_IPv4):
21256 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
21257 + return KG_SCH_GEN_IPV4;
21258 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_2) || (hdrIndex == e_FM_PCD_HDR_INDEX_LAST))
21259 + return KG_SCH_GEN_IPV4_TUNNELED;
21260 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 header index"));
21261 + return 0;
21262 + case (HEADER_TYPE_IPv6):
21263 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
21264 + return KG_SCH_GEN_IPV6;
21265 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_2) || (hdrIndex == e_FM_PCD_HDR_INDEX_LAST))
21266 + return KG_SCH_GEN_IPV6_TUNNELED;
21267 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 header index"));
21268 + return 0;
21269 + case (HEADER_TYPE_GRE):
21270 + return KG_SCH_GEN_GRE;
21271 + case (HEADER_TYPE_TCP):
21272 + return KG_SCH_GEN_TCP;
21273 + case (HEADER_TYPE_UDP):
21274 + return KG_SCH_GEN_UDP;
21275 + case (HEADER_TYPE_IPSEC_AH):
21276 + return KG_SCH_GEN_IPSEC_AH;
21277 + case (HEADER_TYPE_IPSEC_ESP):
21278 + return KG_SCH_GEN_IPSEC_ESP;
21279 + case (HEADER_TYPE_SCTP):
21280 + return KG_SCH_GEN_SCTP;
21281 + case (HEADER_TYPE_DCCP):
21282 + return KG_SCH_GEN_DCCP;
21283 + default:
21284 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21285 + return 0;
21286 + }
21287 + else
21288 + switch (hdr)
21289 + {
21290 + case (HEADER_TYPE_NONE):
21291 + ASSERT_COND(FALSE);
21292 + case (HEADER_TYPE_ETH):
21293 + return KG_SCH_GEN_ETH_NO_V;
21294 + case (HEADER_TYPE_LLC_SNAP):
21295 + return KG_SCH_GEN_SNAP_NO_V;
21296 + case (HEADER_TYPE_PPPoE):
21297 + return KG_SCH_GEN_PPP_NO_V;
21298 + case (HEADER_TYPE_MPLS):
21299 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
21300 + return KG_SCH_GEN_MPLS1_NO_V;
21301 + if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
21302 + return KG_SCH_GEN_MPLS_LAST_NO_V;
21303 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_2) || (hdrIndex == e_FM_PCD_HDR_INDEX_3) )
21304 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Indexed MPLS Extraction not supported"));
21305 + else
21306 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal MPLS header index"));
21307 + return 0;
21308 + case (HEADER_TYPE_IPv4):
21309 + case (HEADER_TYPE_IPv6):
21310 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
21311 + return KG_SCH_GEN_L3_NO_V;
21312 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_2) || (hdrIndex == e_FM_PCD_HDR_INDEX_LAST))
21313 + return KG_SCH_GEN_IP2_NO_V;
21314 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP header index"));
21315 + case (HEADER_TYPE_MINENCAP):
21316 + return KG_SCH_GEN_IP2_NO_V;
21317 + case (HEADER_TYPE_USER_DEFINED_L3):
21318 + return KG_SCH_GEN_L3_NO_V;
21319 + case (HEADER_TYPE_GRE):
21320 + return KG_SCH_GEN_GRE_NO_V;
21321 + case (HEADER_TYPE_TCP):
21322 + case (HEADER_TYPE_UDP):
21323 + case (HEADER_TYPE_IPSEC_AH):
21324 + case (HEADER_TYPE_IPSEC_ESP):
21325 + case (HEADER_TYPE_SCTP):
21326 + case (HEADER_TYPE_DCCP):
21327 + return KG_SCH_GEN_L4_NO_V;
21328 + case (HEADER_TYPE_USER_DEFINED_SHIM1):
21329 + return KG_SCH_GEN_SHIM1;
21330 + case (HEADER_TYPE_USER_DEFINED_SHIM2):
21331 + return KG_SCH_GEN_SHIM2;
21332 + default:
21333 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21334 + return 0;
21335 + }
21336 +}
21337 +static t_GenericCodes GetGenFieldCode(e_NetHeaderType hdr, t_FmPcdFields field, bool ignoreProtocolValidation, e_FmPcdHdrIndex hdrIndex)
21338 +{
21339 + if (!ignoreProtocolValidation)
21340 + switch (hdr)
21341 + {
21342 + case (HEADER_TYPE_NONE):
21343 + ASSERT_COND(FALSE);
21344 + break;
21345 + case (HEADER_TYPE_ETH):
21346 + switch (field.eth)
21347 + {
21348 + case (NET_HEADER_FIELD_ETH_TYPE):
21349 + return KG_SCH_GEN_ETH_TYPE;
21350 + default:
21351 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21352 + return 0;
21353 + }
21354 + break;
21355 + case (HEADER_TYPE_VLAN):
21356 + switch (field.vlan)
21357 + {
21358 + case (NET_HEADER_FIELD_VLAN_TCI):
21359 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
21360 + return KG_SCH_GEN_VLAN1;
21361 + if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
21362 + return KG_SCH_GEN_VLAN2;
21363 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal VLAN header index"));
21364 + return 0;
21365 + }
21366 + break;
21367 + case (HEADER_TYPE_MPLS):
21368 + case (HEADER_TYPE_IPSEC_AH):
21369 + case (HEADER_TYPE_IPSEC_ESP):
21370 + case (HEADER_TYPE_LLC_SNAP):
21371 + case (HEADER_TYPE_PPPoE):
21372 + case (HEADER_TYPE_IPv4):
21373 + case (HEADER_TYPE_IPv6):
21374 + case (HEADER_TYPE_GRE):
21375 + case (HEADER_TYPE_MINENCAP):
21376 + case (HEADER_TYPE_USER_DEFINED_L3):
21377 + case (HEADER_TYPE_TCP):
21378 + case (HEADER_TYPE_UDP):
21379 + case (HEADER_TYPE_SCTP):
21380 + case (HEADER_TYPE_DCCP):
21381 + case (HEADER_TYPE_USER_DEFINED_L4):
21382 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21383 + return 0;
21384 + default:
21385 + break;
21386 +
21387 + }
21388 + else
21389 + switch (hdr)
21390 + {
21391 + case (HEADER_TYPE_NONE):
21392 + ASSERT_COND(FALSE);
21393 + break;
21394 + case (HEADER_TYPE_ETH):
21395 + switch (field.eth)
21396 + {
21397 + case (NET_HEADER_FIELD_ETH_TYPE):
21398 + return KG_SCH_GEN_ETH_TYPE_NO_V;
21399 + default:
21400 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21401 + return 0;
21402 + }
21403 + break;
21404 + case (HEADER_TYPE_VLAN):
21405 + switch (field.vlan)
21406 + {
21407 + case (NET_HEADER_FIELD_VLAN_TCI) :
21408 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
21409 + return KG_SCH_GEN_VLAN1_NO_V;
21410 + if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
21411 + return KG_SCH_GEN_VLAN2_NO_V;
21412 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal VLAN header index"));
21413 + return 0;
21414 + }
21415 + break;
21416 + case (HEADER_TYPE_IPv4):
21417 + switch (field.ipv4)
21418 + {
21419 + case (NET_HEADER_FIELD_IPv4_PROTO):
21420 + return KG_SCH_GEN_IP_PID_NO_V;
21421 + default:
21422 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21423 + return 0;
21424 + }
21425 + break;
21426 + case (HEADER_TYPE_IPv6):
21427 + switch (field.ipv6)
21428 + {
21429 + case (NET_HEADER_FIELD_IPv6_NEXT_HDR):
21430 + return KG_SCH_GEN_IP_PID_NO_V;
21431 + default:
21432 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21433 + return 0;
21434 + }
21435 + break;
21436 + case (HEADER_TYPE_MPLS):
21437 + case (HEADER_TYPE_LLC_SNAP):
21438 + case (HEADER_TYPE_PPPoE):
21439 + case (HEADER_TYPE_GRE):
21440 + case (HEADER_TYPE_MINENCAP):
21441 + case (HEADER_TYPE_USER_DEFINED_L3):
21442 + case (HEADER_TYPE_TCP):
21443 + case (HEADER_TYPE_UDP):
21444 + case (HEADER_TYPE_IPSEC_AH):
21445 + case (HEADER_TYPE_IPSEC_ESP):
21446 + case (HEADER_TYPE_SCTP):
21447 + case (HEADER_TYPE_DCCP):
21448 + case (HEADER_TYPE_USER_DEFINED_L4):
21449 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21450 + return 0;
21451 + default:
21452 + break;
21453 + }
21454 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Header not supported"));
21455 + return 0;
21456 +}
21457 +
21458 +static t_KnownFieldsMasks GetKnownProtMask(t_FmPcd *p_FmPcd, e_NetHeaderType hdr, e_FmPcdHdrIndex index, t_FmPcdFields field)
21459 +{
21460 + UNUSED(p_FmPcd);
21461 +
21462 + switch (hdr)
21463 + {
21464 + case (HEADER_TYPE_NONE):
21465 + ASSERT_COND(FALSE);
21466 + break;
21467 + case (HEADER_TYPE_ETH):
21468 + switch (field.eth)
21469 + {
21470 + case (NET_HEADER_FIELD_ETH_DA):
21471 + return KG_SCH_KN_MACDST;
21472 + case (NET_HEADER_FIELD_ETH_SA):
21473 + return KG_SCH_KN_MACSRC;
21474 + case (NET_HEADER_FIELD_ETH_TYPE):
21475 + return KG_SCH_KN_ETYPE;
21476 + default:
21477 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21478 + return 0;
21479 + }
21480 + case (HEADER_TYPE_LLC_SNAP):
21481 + switch (field.llcSnap)
21482 + {
21483 + case (NET_HEADER_FIELD_LLC_SNAP_TYPE):
21484 + return KG_SCH_KN_ETYPE;
21485 + default:
21486 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21487 + return 0;
21488 + }
21489 + case (HEADER_TYPE_VLAN):
21490 + switch (field.vlan)
21491 + {
21492 + case (NET_HEADER_FIELD_VLAN_TCI):
21493 + if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
21494 + return KG_SCH_KN_TCI1;
21495 + if (index == e_FM_PCD_HDR_INDEX_LAST)
21496 + return KG_SCH_KN_TCI2;
21497 + else
21498 + {
21499 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21500 + return 0;
21501 + }
21502 + default:
21503 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21504 + return 0;
21505 + }
21506 + case (HEADER_TYPE_MPLS):
21507 + switch (field.mpls)
21508 + {
21509 + case (NET_HEADER_FIELD_MPLS_LABEL_STACK):
21510 + if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
21511 + return KG_SCH_KN_MPLS1;
21512 + if (index == e_FM_PCD_HDR_INDEX_2)
21513 + return KG_SCH_KN_MPLS2;
21514 + if (index == e_FM_PCD_HDR_INDEX_LAST)
21515 + return KG_SCH_KN_MPLS_LAST;
21516 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal MPLS index"));
21517 + return 0;
21518 + default:
21519 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21520 + return 0;
21521 + }
21522 + case (HEADER_TYPE_IPv4):
21523 + switch (field.ipv4)
21524 + {
21525 + case (NET_HEADER_FIELD_IPv4_SRC_IP):
21526 + if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
21527 + return KG_SCH_KN_IPSRC1;
21528 + if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
21529 + return KG_SCH_KN_IPSRC2;
21530 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
21531 + return 0;
21532 + case (NET_HEADER_FIELD_IPv4_DST_IP):
21533 + if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
21534 + return KG_SCH_KN_IPDST1;
21535 + if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
21536 + return KG_SCH_KN_IPDST2;
21537 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
21538 + return 0;
21539 + case (NET_HEADER_FIELD_IPv4_PROTO):
21540 + if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
21541 + return KG_SCH_KN_PTYPE1;
21542 + if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
21543 + return KG_SCH_KN_PTYPE2;
21544 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
21545 + return 0;
21546 + case (NET_HEADER_FIELD_IPv4_TOS):
21547 + if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
21548 + return KG_SCH_KN_IPTOS_TC1;
21549 + if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
21550 + return KG_SCH_KN_IPTOS_TC2;
21551 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
21552 + return 0;
21553 + default:
21554 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21555 + return 0;
21556 + }
21557 + case (HEADER_TYPE_IPv6):
21558 + switch (field.ipv6)
21559 + {
21560 + case (NET_HEADER_FIELD_IPv6_SRC_IP):
21561 + if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
21562 + return KG_SCH_KN_IPSRC1;
21563 + if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
21564 + return KG_SCH_KN_IPSRC2;
21565 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
21566 + return 0;
21567 + case (NET_HEADER_FIELD_IPv6_DST_IP):
21568 + if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
21569 + return KG_SCH_KN_IPDST1;
21570 + if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
21571 + return KG_SCH_KN_IPDST2;
21572 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
21573 + return 0;
21574 + case (NET_HEADER_FIELD_IPv6_NEXT_HDR):
21575 + if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
21576 + return KG_SCH_KN_PTYPE1;
21577 + if (index == e_FM_PCD_HDR_INDEX_2)
21578 + return KG_SCH_KN_PTYPE2;
21579 + if (index == e_FM_PCD_HDR_INDEX_LAST)
21580 +#ifdef FM_KG_NO_IPPID_SUPPORT
21581 + if (p_FmPcd->fmRevInfo.majorRev < 6)
21582 + return KG_SCH_KN_PTYPE2;
21583 +#endif /* FM_KG_NO_IPPID_SUPPORT */
21584 + return KG_SCH_KN_IPPID;
21585 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
21586 + return 0;
21587 + case (NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_FL | NET_HEADER_FIELD_IPv6_TC):
21588 + if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
21589 + return (KG_SCH_KN_IPV6FL1 | KG_SCH_KN_IPTOS_TC1);
21590 + if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
21591 + return (KG_SCH_KN_IPV6FL2 | KG_SCH_KN_IPTOS_TC2);
21592 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
21593 + return 0;
21594 + case (NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_TC):
21595 + if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
21596 + return KG_SCH_KN_IPTOS_TC1;
21597 + if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
21598 + return KG_SCH_KN_IPTOS_TC2;
21599 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
21600 + return 0;
21601 + case (NET_HEADER_FIELD_IPv6_FL):
21602 + if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
21603 + return KG_SCH_KN_IPV6FL1;
21604 + if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
21605 + return KG_SCH_KN_IPV6FL2;
21606 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
21607 + return 0;
21608 + default:
21609 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21610 + return 0;
21611 + }
21612 + case (HEADER_TYPE_GRE):
21613 + switch (field.gre)
21614 + {
21615 + case (NET_HEADER_FIELD_GRE_TYPE):
21616 + return KG_SCH_KN_GREPTYPE;
21617 + default:
21618 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21619 + return 0;
21620 + }
21621 + case (HEADER_TYPE_MINENCAP):
21622 + switch (field.minencap)
21623 + {
21624 + case (NET_HEADER_FIELD_MINENCAP_SRC_IP):
21625 + return KG_SCH_KN_IPSRC2;
21626 + case (NET_HEADER_FIELD_MINENCAP_DST_IP):
21627 + return KG_SCH_KN_IPDST2;
21628 + case (NET_HEADER_FIELD_MINENCAP_TYPE):
21629 + return KG_SCH_KN_PTYPE2;
21630 + default:
21631 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21632 + return 0;
21633 + }
21634 + case (HEADER_TYPE_TCP):
21635 + switch (field.tcp)
21636 + {
21637 + case (NET_HEADER_FIELD_TCP_PORT_SRC):
21638 + return KG_SCH_KN_L4PSRC;
21639 + case (NET_HEADER_FIELD_TCP_PORT_DST):
21640 + return KG_SCH_KN_L4PDST;
21641 + case (NET_HEADER_FIELD_TCP_FLAGS):
21642 + return KG_SCH_KN_TFLG;
21643 + default:
21644 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21645 + return 0;
21646 + }
21647 + case (HEADER_TYPE_UDP):
21648 + switch (field.udp)
21649 + {
21650 + case (NET_HEADER_FIELD_UDP_PORT_SRC):
21651 + return KG_SCH_KN_L4PSRC;
21652 + case (NET_HEADER_FIELD_UDP_PORT_DST):
21653 + return KG_SCH_KN_L4PDST;
21654 + default:
21655 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21656 + return 0;
21657 + }
21658 + case (HEADER_TYPE_IPSEC_AH):
21659 + switch (field.ipsecAh)
21660 + {
21661 + case (NET_HEADER_FIELD_IPSEC_AH_SPI):
21662 + return KG_SCH_KN_IPSEC_SPI;
21663 + case (NET_HEADER_FIELD_IPSEC_AH_NH):
21664 + return KG_SCH_KN_IPSEC_NH;
21665 + default:
21666 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21667 + return 0;
21668 + }
21669 + case (HEADER_TYPE_IPSEC_ESP):
21670 + switch (field.ipsecEsp)
21671 + {
21672 + case (NET_HEADER_FIELD_IPSEC_ESP_SPI):
21673 + return KG_SCH_KN_IPSEC_SPI;
21674 + default:
21675 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21676 + return 0;
21677 + }
21678 + case (HEADER_TYPE_SCTP):
21679 + switch (field.sctp)
21680 + {
21681 + case (NET_HEADER_FIELD_SCTP_PORT_SRC):
21682 + return KG_SCH_KN_L4PSRC;
21683 + case (NET_HEADER_FIELD_SCTP_PORT_DST):
21684 + return KG_SCH_KN_L4PDST;
21685 + default:
21686 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21687 + return 0;
21688 + }
21689 + case (HEADER_TYPE_DCCP):
21690 + switch (field.dccp)
21691 + {
21692 + case (NET_HEADER_FIELD_DCCP_PORT_SRC):
21693 + return KG_SCH_KN_L4PSRC;
21694 + case (NET_HEADER_FIELD_DCCP_PORT_DST):
21695 + return KG_SCH_KN_L4PDST;
21696 + default:
21697 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21698 + return 0;
21699 + }
21700 + case (HEADER_TYPE_PPPoE):
21701 + switch (field.pppoe)
21702 + {
21703 + case (NET_HEADER_FIELD_PPPoE_PID):
21704 + return KG_SCH_KN_PPPID;
21705 + case (NET_HEADER_FIELD_PPPoE_SID):
21706 + return KG_SCH_KN_PPPSID;
21707 + default:
21708 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21709 + return 0;
21710 + }
21711 + default:
21712 + break;
21713 +
21714 + }
21715 +
21716 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
21717 + return 0;
21718 +}
21719 +
21720 +
21721 +static uint8_t GetKnownFieldId(uint32_t bitMask)
21722 +{
21723 + uint8_t cnt = 0;
21724 +
21725 + while (bitMask)
21726 + if (bitMask & 0x80000000)
21727 + break;
21728 + else
21729 + {
21730 + cnt++;
21731 + bitMask <<= 1;
21732 + }
21733 + return cnt;
21734 +
21735 +}
21736 +
21737 +static uint8_t GetExtractedOrMask(uint8_t bitOffset, bool fqid)
21738 +{
21739 + uint8_t i, mask, numOfOnesToClear, walking1Mask = 1;
21740 +
21741 + /* bitOffset 1-7 --> mask 0x1-0x7F */
21742 + if (bitOffset<8)
21743 + {
21744 + mask = 0;
21745 + for (i = 0 ; i < bitOffset ; i++, walking1Mask <<= 1)
21746 + mask |= walking1Mask;
21747 + }
21748 + else
21749 + {
21750 + mask = 0xFF;
21751 + numOfOnesToClear = 0;
21752 + if (fqid && bitOffset>24)
21753 + /* bitOffset 25-31 --> mask 0xFE-0x80 */
21754 + numOfOnesToClear = (uint8_t)(bitOffset-24);
21755 + else
21756 + /* bitOffset 9-15 --> mask 0xFE-0x80 */
21757 + if (!fqid && bitOffset>8)
21758 + numOfOnesToClear = (uint8_t)(bitOffset-8);
21759 + for (i = 0 ; i < numOfOnesToClear ; i++, walking1Mask <<= 1)
21760 + mask &= ~walking1Mask;
21761 + /* bitOffset 8-24 for FQID, 8 for PP --> no mask (0xFF)*/
21762 + }
21763 + return mask;
21764 +}
21765 +
21766 +static void IncSchemeOwners(t_FmPcd *p_FmPcd, t_FmPcdKgInterModuleBindPortToSchemes *p_BindPort)
21767 +{
21768 + t_FmPcdKg *p_FmPcdKg;
21769 + t_FmPcdKgScheme *p_Scheme;
21770 + uint32_t intFlags;
21771 + uint8_t relativeSchemeId;
21772 + int i;
21773 +
21774 + p_FmPcdKg = p_FmPcd->p_FmPcdKg;
21775 +
21776 + /* for each scheme - update owners counters */
21777 + for (i = 0; i < p_BindPort->numOfSchemes; i++)
21778 + {
21779 + relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, p_BindPort->schemesIds[i]);
21780 + ASSERT_COND(relativeSchemeId < FM_PCD_KG_NUM_OF_SCHEMES);
21781 +
21782 + p_Scheme = &p_FmPcdKg->schemes[relativeSchemeId];
21783 +
21784 + /* increment owners number */
21785 + intFlags = KgSchemeLock(p_Scheme);
21786 + p_Scheme->owners++;
21787 + KgSchemeUnlock(p_Scheme, intFlags);
21788 + }
21789 +}
21790 +
21791 +static void DecSchemeOwners(t_FmPcd *p_FmPcd, t_FmPcdKgInterModuleBindPortToSchemes *p_BindPort)
21792 +{
21793 + t_FmPcdKg *p_FmPcdKg;
21794 + t_FmPcdKgScheme *p_Scheme;
21795 + uint32_t intFlags;
21796 + uint8_t relativeSchemeId;
21797 + int i;
21798 +
21799 + p_FmPcdKg = p_FmPcd->p_FmPcdKg;
21800 +
21801 + /* for each scheme - update owners counters */
21802 + for (i = 0; i < p_BindPort->numOfSchemes; i++)
21803 + {
21804 + relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, p_BindPort->schemesIds[i]);
21805 + ASSERT_COND(relativeSchemeId < FM_PCD_KG_NUM_OF_SCHEMES);
21806 +
21807 + p_Scheme = &p_FmPcdKg->schemes[relativeSchemeId];
21808 +
21809 + /* increment owners number */
21810 + ASSERT_COND(p_Scheme->owners);
21811 + intFlags = KgSchemeLock(p_Scheme);
21812 + p_Scheme->owners--;
21813 + KgSchemeUnlock(p_Scheme, intFlags);
21814 + }
21815 +}
21816 +
21817 +static void UpdateRequiredActionFlag(t_FmPcdKgScheme *p_Scheme, bool set)
21818 +{
21819 + /* this routine is locked by the calling routine */
21820 + ASSERT_COND(p_Scheme);
21821 + ASSERT_COND(p_Scheme->valid);
21822 +
21823 + if (set)
21824 + p_Scheme->requiredActionFlag = TRUE;
21825 + else
21826 + {
21827 + p_Scheme->requiredAction = 0;
21828 + p_Scheme->requiredActionFlag = FALSE;
21829 + }
21830 +}
21831 +
21832 +static t_Error KgWriteSp(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, uint32_t spReg, bool add)
21833 +{
21834 + struct fman_kg_regs *p_KgRegs;
21835 +
21836 + uint32_t tmpKgarReg = 0, intFlags;
21837 + t_Error err = E_OK;
21838 +
21839 + /* The calling routine had locked the port, so for each port only one core can access
21840 + * (so we don't need a lock here) */
21841 +
21842 + if (p_FmPcd->h_Hc)
21843 + return FmHcKgWriteSp(p_FmPcd->h_Hc, hardwarePortId, spReg, add);
21844 +
21845 + p_KgRegs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
21846 +
21847 + tmpKgarReg = FmPcdKgBuildReadPortSchemeBindActionReg(hardwarePortId);
21848 + /* lock a common KG reg */
21849 + intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
21850 + err = WriteKgarWait(p_FmPcd, tmpKgarReg);
21851 + if (err)
21852 + {
21853 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
21854 + RETURN_ERROR(MINOR, err, NO_MSG);
21855 + }
21856 +
21857 + fman_kg_write_sp(p_KgRegs, spReg, add);
21858 +
21859 + tmpKgarReg = FmPcdKgBuildWritePortSchemeBindActionReg(hardwarePortId);
21860 +
21861 + err = WriteKgarWait(p_FmPcd, tmpKgarReg);
21862 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
21863 + return err;
21864 +}
21865 +
21866 +static t_Error KgWriteCpp(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, uint32_t cppReg)
21867 +{
21868 + struct fman_kg_regs *p_KgRegs;
21869 + uint32_t tmpKgarReg, intFlags;
21870 + t_Error err;
21871 +
21872 + p_KgRegs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
21873 +
21874 + if (p_FmPcd->h_Hc)
21875 + {
21876 + err = FmHcKgWriteCpp(p_FmPcd->h_Hc, hardwarePortId, cppReg);
21877 + return err;
21878 + }
21879 +
21880 + intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
21881 + fman_kg_write_cpp(p_KgRegs, cppReg);
21882 + tmpKgarReg = FmPcdKgBuildWritePortClsPlanBindActionReg(hardwarePortId);
21883 + err = WriteKgarWait(p_FmPcd, tmpKgarReg);
21884 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
21885 +
21886 + return err;
21887 +}
21888 +
21889 +static uint32_t BuildCppReg(t_FmPcd *p_FmPcd, uint8_t clsPlanGrpId)
21890 +{
21891 + uint32_t tmpKgpeCpp;
21892 +
21893 + tmpKgpeCpp = (uint32_t)(p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId].baseEntry / 8);
21894 + tmpKgpeCpp |= (uint32_t)(((p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId].sizeOfGrp / 8) - 1) << FM_KG_PE_CPP_MASK_SHIFT);
21895 +
21896 + return tmpKgpeCpp;
21897 +}
21898 +
21899 +static t_Error BindPortToClsPlanGrp(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, uint8_t clsPlanGrpId)
21900 +{
21901 + uint32_t tmpKgpeCpp = 0;
21902 +
21903 + tmpKgpeCpp = BuildCppReg(p_FmPcd, clsPlanGrpId);
21904 + return KgWriteCpp(p_FmPcd, hardwarePortId, tmpKgpeCpp);
21905 +}
21906 +
21907 +static void UnbindPortToClsPlanGrp(t_FmPcd *p_FmPcd, uint8_t hardwarePortId)
21908 +{
21909 + KgWriteCpp(p_FmPcd, hardwarePortId, 0);
21910 +}
21911 +
21912 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
21913 +static uint32_t ReadClsPlanBlockActionReg(uint8_t grpId)
21914 +{
21915 + return (uint32_t)(FM_KG_KGAR_GO |
21916 + FM_KG_KGAR_READ |
21917 + FM_PCD_KG_KGAR_SEL_CLS_PLAN_ENTRY |
21918 + DUMMY_PORT_ID |
21919 + ((uint32_t)grpId << FM_PCD_KG_KGAR_NUM_SHIFT) |
21920 + FM_PCD_KG_KGAR_WSEL_MASK);
21921 +
21922 + /* if we ever want to write 1 by 1, use:
21923 + sel = (uint8_t)(0x01 << (7- (entryId % CLS_PLAN_NUM_PER_GRP)));
21924 + */
21925 +}
21926 +#endif /* (defined(DEBUG_ERRORS) && ... */
21927 +
21928 +static void PcdKgErrorException(t_Handle h_FmPcd)
21929 +{
21930 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
21931 + uint32_t event,schemeIndexes = 0, index = 0;
21932 + struct fman_kg_regs *p_KgRegs;
21933 +
21934 + ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
21935 + p_KgRegs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
21936 + fman_kg_get_event(p_KgRegs, &event, &schemeIndexes);
21937 +
21938 + if (event & FM_EX_KG_DOUBLE_ECC)
21939 + p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC);
21940 + if (event & FM_EX_KG_KEYSIZE_OVERFLOW)
21941 + {
21942 + if (schemeIndexes)
21943 + {
21944 + while (schemeIndexes)
21945 + {
21946 + if (schemeIndexes & 0x1)
21947 + p_FmPcd->f_FmPcdIndexedException(p_FmPcd->h_App,e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW, (uint16_t)(31 - index));
21948 + schemeIndexes >>= 1;
21949 + index+=1;
21950 + }
21951 + }
21952 + else /* this should happen only when interrupt is forced. */
21953 + p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW);
21954 + }
21955 +}
21956 +
21957 +static t_Error KgInitGuest(t_FmPcd *p_FmPcd)
21958 +{
21959 + t_Error err = E_OK;
21960 + t_FmPcdIpcKgSchemesParams kgAlloc;
21961 + uint32_t replyLength;
21962 + t_FmPcdIpcReply reply;
21963 + t_FmPcdIpcMsg msg;
21964 +
21965 + ASSERT_COND(p_FmPcd->guestId != NCSW_MASTER_ID);
21966 +
21967 + /* in GUEST_PARTITION, we use the IPC */
21968 + memset(&reply, 0, sizeof(reply));
21969 + memset(&msg, 0, sizeof(msg));
21970 + memset(&kgAlloc, 0, sizeof(t_FmPcdIpcKgSchemesParams));
21971 + kgAlloc.numOfSchemes = p_FmPcd->p_FmPcdKg->numOfSchemes;
21972 + kgAlloc.guestId = p_FmPcd->guestId;
21973 + msg.msgId = FM_PCD_ALLOC_KG_SCHEMES;
21974 + memcpy(msg.msgBody, &kgAlloc, sizeof(kgAlloc));
21975 + replyLength = sizeof(uint32_t) + p_FmPcd->p_FmPcdKg->numOfSchemes*sizeof(uint8_t);
21976 + if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
21977 + (uint8_t*)&msg,
21978 + sizeof(msg.msgId) + sizeof(kgAlloc),
21979 + (uint8_t*)&reply,
21980 + &replyLength,
21981 + NULL,
21982 + NULL)) != E_OK)
21983 + RETURN_ERROR(MAJOR, err, NO_MSG);
21984 + if (replyLength != (sizeof(uint32_t) + p_FmPcd->p_FmPcdKg->numOfSchemes*sizeof(uint8_t)))
21985 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
21986 + memcpy(p_FmPcd->p_FmPcdKg->schemesIds, (uint8_t*)(reply.replyBody),p_FmPcd->p_FmPcdKg->numOfSchemes*sizeof(uint8_t));
21987 +
21988 + return (t_Error)reply.error;
21989 +}
21990 +
21991 +static t_Error KgInitMaster(t_FmPcd *p_FmPcd)
21992 +{
21993 + t_Error err = E_OK;
21994 + struct fman_kg_regs *p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
21995 +
21996 + ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
21997 +
21998 + if (p_FmPcd->exceptions & FM_EX_KG_DOUBLE_ECC)
21999 + FmEnableRamsEcc(p_FmPcd->h_Fm);
22000 +
22001 + fman_kg_init(p_Regs, p_FmPcd->exceptions, GET_NIA_BMI_AC_ENQ_FRAME(p_FmPcd));
22002 +
22003 + /* register even if no interrupts enabled, to allow future enablement */
22004 + FmRegisterIntr(p_FmPcd->h_Fm,
22005 + e_FM_MOD_KG,
22006 + 0,
22007 + e_FM_INTR_TYPE_ERR,
22008 + PcdKgErrorException,
22009 + p_FmPcd);
22010 +
22011 + fman_kg_enable_scheme_interrupts(p_Regs);
22012 +
22013 + if (p_FmPcd->p_FmPcdKg->numOfSchemes)
22014 + {
22015 + err = FmPcdKgAllocSchemes(p_FmPcd,
22016 + p_FmPcd->p_FmPcdKg->numOfSchemes,
22017 + p_FmPcd->guestId,
22018 + p_FmPcd->p_FmPcdKg->schemesIds);
22019 + if (err)
22020 + RETURN_ERROR(MINOR, err, NO_MSG);
22021 + }
22022 +
22023 + return E_OK;
22024 +}
22025 +
22026 +static void ValidateSchemeSw(t_FmPcdKgScheme *p_Scheme)
22027 +{
22028 + ASSERT_COND(!p_Scheme->valid);
22029 + if (p_Scheme->netEnvId != ILLEGAL_NETENV)
22030 + FmPcdIncNetEnvOwners(p_Scheme->h_FmPcd, p_Scheme->netEnvId);
22031 + p_Scheme->valid = TRUE;
22032 +}
22033 +
22034 +static t_Error InvalidateSchemeSw(t_FmPcdKgScheme *p_Scheme)
22035 +{
22036 + if (p_Scheme->owners)
22037 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Trying to delete a scheme that has ports bound to"));
22038 +
22039 + if (p_Scheme->netEnvId != ILLEGAL_NETENV)
22040 + FmPcdDecNetEnvOwners(p_Scheme->h_FmPcd, p_Scheme->netEnvId);
22041 + p_Scheme->valid = FALSE;
22042 +
22043 + return E_OK;
22044 +}
22045 +
22046 +static t_Error BuildSchemeRegs(t_FmPcdKgScheme *p_Scheme,
22047 + t_FmPcdKgSchemeParams *p_SchemeParams,
22048 + struct fman_kg_scheme_regs *p_SchemeRegs)
22049 +{
22050 + t_FmPcd *p_FmPcd = (t_FmPcd *)(p_Scheme->h_FmPcd);
22051 + uint32_t grpBits = 0;
22052 + uint8_t grpBase;
22053 + bool direct=TRUE, absolute=FALSE;
22054 + uint16_t profileId=0, numOfProfiles=0, relativeProfileId;
22055 + t_Error err = E_OK;
22056 + int i = 0;
22057 + t_NetEnvParams netEnvParams;
22058 + uint32_t tmpReg, fqbTmp = 0, ppcTmp = 0, selectTmp, maskTmp, knownTmp, genTmp;
22059 + t_FmPcdKgKeyExtractAndHashParams *p_KeyAndHash = NULL;
22060 + uint8_t j, curr, idx;
22061 + uint8_t id, shift=0, code=0, offset=0, size=0;
22062 + t_FmPcdExtractEntry *p_Extract = NULL;
22063 + t_FmPcdKgExtractedOrParams *p_ExtractOr;
22064 + bool generic = FALSE;
22065 + t_KnownFieldsMasks bitMask;
22066 + e_FmPcdKgExtractDfltSelect swDefault = (e_FmPcdKgExtractDfltSelect)0;
22067 + t_FmPcdKgSchemesExtracts *p_LocalExtractsArray;
22068 + uint8_t numOfSwDefaults = 0;
22069 + t_FmPcdKgExtractDflt swDefaults[NUM_OF_SW_DEFAULTS];
22070 + uint8_t currGenId = 0;
22071 +
22072 + memset(swDefaults, 0, NUM_OF_SW_DEFAULTS*sizeof(t_FmPcdKgExtractDflt));
22073 + memset(p_SchemeRegs, 0, sizeof(struct fman_kg_scheme_regs));
22074 +
22075 + if (p_SchemeParams->netEnvParams.numOfDistinctionUnits > FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
22076 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
22077 + ("numOfDistinctionUnits should not exceed %d", FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS));
22078 +
22079 + /* by netEnv parameters, get match vector */
22080 + if (!p_SchemeParams->alwaysDirect)
22081 + {
22082 + p_Scheme->netEnvId = FmPcdGetNetEnvId(p_SchemeParams->netEnvParams.h_NetEnv);
22083 + netEnvParams.netEnvId = p_Scheme->netEnvId;
22084 + netEnvParams.numOfDistinctionUnits = p_SchemeParams->netEnvParams.numOfDistinctionUnits;
22085 + memcpy(netEnvParams.unitIds, p_SchemeParams->netEnvParams.unitIds, (sizeof(uint8_t))*p_SchemeParams->netEnvParams.numOfDistinctionUnits);
22086 + err = PcdGetUnitsVector(p_FmPcd, &netEnvParams);
22087 + if (err)
22088 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
22089 + p_Scheme->matchVector = netEnvParams.vector;
22090 + }
22091 + else
22092 + {
22093 + p_Scheme->matchVector = SCHEME_ALWAYS_DIRECT;
22094 + p_Scheme->netEnvId = ILLEGAL_NETENV;
22095 + }
22096 +
22097 + if (p_SchemeParams->nextEngine == e_FM_PCD_INVALID)
22098 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next Engine of the scheme is not Valid"));
22099 +
22100 + if (p_SchemeParams->bypassFqidGeneration)
22101 + {
22102 +#ifdef FM_KG_NO_BYPASS_FQID_GEN
22103 + if ((p_FmPcd->fmRevInfo.majorRev != 4) && (p_FmPcd->fmRevInfo.majorRev < 6))
22104 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("bypassFqidGeneration."));
22105 +#endif /* FM_KG_NO_BYPASS_FQID_GEN */
22106 + if (p_SchemeParams->baseFqid)
22107 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("baseFqid set for a scheme that does not generate an FQID"));
22108 + }
22109 + else
22110 + if (!p_SchemeParams->baseFqid)
22111 + DBG(WARNING, ("baseFqid is 0."));
22112 +
22113 + if (p_SchemeParams->nextEngine == e_FM_PCD_PLCR)
22114 + {
22115 + direct = p_SchemeParams->kgNextEngineParams.plcrProfile.direct;
22116 + p_Scheme->directPlcr = direct;
22117 + absolute = (bool)(p_SchemeParams->kgNextEngineParams.plcrProfile.sharedProfile ? TRUE : FALSE);
22118 + if (!direct && absolute)
22119 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Indirect policing is not available when profile is shared."));
22120 +
22121 + if (direct)
22122 + {
22123 + profileId = p_SchemeParams->kgNextEngineParams.plcrProfile.profileSelect.directRelativeProfileId;
22124 + numOfProfiles = 1;
22125 + }
22126 + else
22127 + {
22128 + profileId = p_SchemeParams->kgNextEngineParams.plcrProfile.profileSelect.indirectProfile.fqidOffsetRelativeProfileIdBase;
22129 + shift = p_SchemeParams->kgNextEngineParams.plcrProfile.profileSelect.indirectProfile.fqidOffsetShift;
22130 + numOfProfiles = p_SchemeParams->kgNextEngineParams.plcrProfile.profileSelect.indirectProfile.numOfProfiles;
22131 + }
22132 + }
22133 +
22134 + if (p_SchemeParams->nextEngine == e_FM_PCD_CC)
22135 + {
22136 +#ifdef FM_KG_NO_BYPASS_PLCR_PROFILE_GEN
22137 + if ((p_SchemeParams->kgNextEngineParams.cc.plcrNext) && (p_SchemeParams->kgNextEngineParams.cc.bypassPlcrProfileGeneration))
22138 + {
22139 + if ((p_FmPcd->fmRevInfo.majorRev != 4) && (p_FmPcd->fmRevInfo.majorRev < 6))
22140 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("bypassPlcrProfileGeneration."));
22141 + }
22142 +#endif /* FM_KG_NO_BYPASS_PLCR_PROFILE_GEN */
22143 +
22144 + err = FmPcdCcGetGrpParams(p_SchemeParams->kgNextEngineParams.cc.h_CcTree,
22145 + p_SchemeParams->kgNextEngineParams.cc.grpId,
22146 + &grpBits,
22147 + &grpBase);
22148 + if (err)
22149 + RETURN_ERROR(MAJOR, err, NO_MSG);
22150 + p_Scheme->ccUnits = grpBits;
22151 +
22152 + if ((p_SchemeParams->kgNextEngineParams.cc.plcrNext) &&
22153 + (!p_SchemeParams->kgNextEngineParams.cc.bypassPlcrProfileGeneration))
22154 + {
22155 + if (p_SchemeParams->kgNextEngineParams.cc.plcrProfile.sharedProfile)
22156 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Shared profile may not be used after Coarse classification."));
22157 + absolute = FALSE;
22158 + direct = p_SchemeParams->kgNextEngineParams.cc.plcrProfile.direct;
22159 + if (direct)
22160 + {
22161 + profileId = p_SchemeParams->kgNextEngineParams.cc.plcrProfile.profileSelect.directRelativeProfileId;
22162 + numOfProfiles = 1;
22163 + }
22164 + else
22165 + {
22166 + profileId = p_SchemeParams->kgNextEngineParams.cc.plcrProfile.profileSelect.indirectProfile.fqidOffsetRelativeProfileIdBase;
22167 + shift = p_SchemeParams->kgNextEngineParams.cc.plcrProfile.profileSelect.indirectProfile.fqidOffsetShift;
22168 + numOfProfiles = p_SchemeParams->kgNextEngineParams.cc.plcrProfile.profileSelect.indirectProfile.numOfProfiles;
22169 + }
22170 + }
22171 + }
22172 +
22173 + /* if policer is used directly after KG, or after CC */
22174 + if ((p_SchemeParams->nextEngine == e_FM_PCD_PLCR) ||
22175 + ((p_SchemeParams->nextEngine == e_FM_PCD_CC) &&
22176 + (p_SchemeParams->kgNextEngineParams.cc.plcrNext) &&
22177 + (!p_SchemeParams->kgNextEngineParams.cc.bypassPlcrProfileGeneration)))
22178 + {
22179 + /* if private policer profile, it may be uninitialized yet, therefore no checks are done at this stage */
22180 + if (absolute)
22181 + {
22182 + /* for absolute direct policy only, */
22183 + relativeProfileId = profileId;
22184 + err = FmPcdPlcrGetAbsoluteIdByProfileParams((t_Handle)p_FmPcd,e_FM_PCD_PLCR_SHARED,NULL, relativeProfileId, &profileId);
22185 + if (err)
22186 + RETURN_ERROR(MAJOR, err, ("Shared profile not valid offset"));
22187 + if (!FmPcdPlcrIsProfileValid(p_FmPcd, profileId))
22188 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Shared profile not valid."));
22189 + p_Scheme->relativeProfileId = profileId;
22190 + }
22191 + else
22192 + {
22193 + /* save relative profile id's for later check */
22194 + p_Scheme->nextRelativePlcrProfile = TRUE;
22195 + p_Scheme->relativeProfileId = profileId;
22196 + p_Scheme->numOfProfiles = numOfProfiles;
22197 + }
22198 + }
22199 + else
22200 + {
22201 + /* if policer is NOT going to be used after KG at all than if bypassFqidGeneration
22202 + is set, we do not need numOfUsedExtractedOrs and hashDistributionNumOfFqids */
22203 + if (p_SchemeParams->bypassFqidGeneration && p_SchemeParams->numOfUsedExtractedOrs)
22204 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
22205 + ("numOfUsedExtractedOrs is set in a scheme that does not generate FQID or policer profile ID"));
22206 + if (p_SchemeParams->bypassFqidGeneration &&
22207 + p_SchemeParams->useHash &&
22208 + p_SchemeParams->keyExtractAndHashParams.hashDistributionNumOfFqids)
22209 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
22210 + ("hashDistributionNumOfFqids is set in a scheme that does not generate FQID or policer profile ID"));
22211 + }
22212 +
22213 + /* configure all 21 scheme registers */
22214 + tmpReg = KG_SCH_MODE_EN;
22215 + switch (p_SchemeParams->nextEngine)
22216 + {
22217 + case (e_FM_PCD_PLCR):
22218 + /* add to mode register - NIA */
22219 + tmpReg |= KG_SCH_MODE_NIA_PLCR;
22220 + tmpReg |= NIA_ENG_PLCR;
22221 + tmpReg |= (uint32_t)(p_SchemeParams->kgNextEngineParams.plcrProfile.sharedProfile ? NIA_PLCR_ABSOLUTE:0);
22222 + /* initialize policer profile command - */
22223 + /* configure kgse_ppc */
22224 + if (direct)
22225 + /* use profileId as base, other fields are 0 */
22226 + p_SchemeRegs->kgse_ppc = (uint32_t)profileId;
22227 + else
22228 + {
22229 + if (shift > MAX_PP_SHIFT)
22230 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fqidOffsetShift may not be larger than %d", MAX_PP_SHIFT));
22231 +
22232 + if (!numOfProfiles || !POWER_OF_2(numOfProfiles))
22233 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfProfiles must not be 0 and must be a power of 2"));
22234 +
22235 + ppcTmp = ((uint32_t)shift << KG_SCH_PP_SHIFT_HIGH_SHIFT) & KG_SCH_PP_SHIFT_HIGH;
22236 + ppcTmp |= ((uint32_t)shift << KG_SCH_PP_SHIFT_LOW_SHIFT) & KG_SCH_PP_SHIFT_LOW;
22237 + ppcTmp |= ((uint32_t)(numOfProfiles-1) << KG_SCH_PP_MASK_SHIFT);
22238 + ppcTmp |= (uint32_t)profileId;
22239 +
22240 + p_SchemeRegs->kgse_ppc = ppcTmp;
22241 + }
22242 + break;
22243 + case (e_FM_PCD_CC):
22244 + /* mode reg - define NIA */
22245 + tmpReg |= (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_CC);
22246 +
22247 + p_SchemeRegs->kgse_ccbs = grpBits;
22248 + tmpReg |= (uint32_t)(grpBase << KG_SCH_MODE_CCOBASE_SHIFT);
22249 +
22250 + if (p_SchemeParams->kgNextEngineParams.cc.plcrNext)
22251 + {
22252 + if (!p_SchemeParams->kgNextEngineParams.cc.bypassPlcrProfileGeneration)
22253 + {
22254 + /* find out if absolute or relative */
22255 + if (absolute)
22256 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("It is illegal to request a shared profile in a scheme that is in a KG->CC->PLCR flow"));
22257 + if (direct)
22258 + {
22259 + /* mask = 0, base = directProfileId */
22260 + p_SchemeRegs->kgse_ppc = (uint32_t)profileId;
22261 + }
22262 + else
22263 + {
22264 + if (shift > MAX_PP_SHIFT)
22265 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fqidOffsetShift may not be larger than %d", MAX_PP_SHIFT));
22266 + if (!numOfProfiles || !POWER_OF_2(numOfProfiles))
22267 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfProfiles must not be 0 and must be a power of 2"));
22268 +
22269 + ppcTmp = ((uint32_t)shift << KG_SCH_PP_SHIFT_HIGH_SHIFT) & KG_SCH_PP_SHIFT_HIGH;
22270 + ppcTmp |= ((uint32_t)shift << KG_SCH_PP_SHIFT_LOW_SHIFT) & KG_SCH_PP_SHIFT_LOW;
22271 + ppcTmp |= ((uint32_t)(numOfProfiles-1) << KG_SCH_PP_MASK_SHIFT);
22272 + ppcTmp |= (uint32_t)profileId;
22273 +
22274 + p_SchemeRegs->kgse_ppc = ppcTmp;
22275 + }
22276 + }
22277 + }
22278 + break;
22279 + case (e_FM_PCD_DONE):
22280 + if (p_SchemeParams->kgNextEngineParams.doneAction == e_FM_PCD_DROP_FRAME)
22281 + tmpReg |= GET_NIA_BMI_AC_DISCARD_FRAME(p_FmPcd);
22282 + else
22283 + tmpReg |= GET_NIA_BMI_AC_ENQ_FRAME(p_FmPcd);
22284 + break;
22285 + default:
22286 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Next engine not supported"));
22287 + }
22288 + p_SchemeRegs->kgse_mode = tmpReg;
22289 +
22290 + p_SchemeRegs->kgse_mv = p_Scheme->matchVector;
22291 +
22292 +#if (DPAA_VERSION >= 11)
22293 + if (p_SchemeParams->overrideStorageProfile)
22294 + {
22295 + p_SchemeRegs->kgse_om |= KG_SCH_OM_VSPE;
22296 +
22297 + if (p_SchemeParams->storageProfile.direct)
22298 + {
22299 + profileId = p_SchemeParams->storageProfile.profileSelect.directRelativeProfileId;
22300 + shift = 0;
22301 + numOfProfiles = 1;
22302 + }
22303 + else
22304 + {
22305 + profileId = p_SchemeParams->storageProfile.profileSelect.indirectProfile.fqidOffsetRelativeProfileIdBase;
22306 + shift = p_SchemeParams->storageProfile.profileSelect.indirectProfile.fqidOffsetShift;
22307 + numOfProfiles = p_SchemeParams->storageProfile.profileSelect.indirectProfile.numOfProfiles;
22308 + }
22309 + if (shift > MAX_SP_SHIFT)
22310 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fqidOffsetShift may not be larger than %d", MAX_SP_SHIFT));
22311 +
22312 + if (!numOfProfiles || !POWER_OF_2(numOfProfiles))
22313 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfProfiles must not be 0 and must be a power of 2"));
22314 +
22315 + tmpReg = (uint32_t)shift << KG_SCH_VSP_SHIFT;
22316 + tmpReg |= ((uint32_t)(numOfProfiles-1) << KG_SCH_VSP_MASK_SHIFT);
22317 + tmpReg |= (uint32_t)profileId;
22318 +
22319 +
22320 + p_SchemeRegs->kgse_vsp = tmpReg;
22321 +
22322 + p_Scheme->vspe = TRUE;
22323 +
22324 + }
22325 + else
22326 + p_SchemeRegs->kgse_vsp = KG_SCH_VSP_NO_KSP_EN;
22327 +#endif /* (DPAA_VERSION >= 11) */
22328 +
22329 + if (p_SchemeParams->useHash)
22330 + {
22331 + p_KeyAndHash = &p_SchemeParams->keyExtractAndHashParams;
22332 +
22333 + if (p_KeyAndHash->numOfUsedExtracts >= FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY)
22334 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfUsedExtracts out of range"));
22335 +
22336 + /* configure kgse_dv0 */
22337 + p_SchemeRegs->kgse_dv0 = p_KeyAndHash->privateDflt0;
22338 +
22339 + /* configure kgse_dv1 */
22340 + p_SchemeRegs->kgse_dv1 = p_KeyAndHash->privateDflt1;
22341 +
22342 + if (!p_SchemeParams->bypassFqidGeneration)
22343 + {
22344 + if (!p_KeyAndHash->hashDistributionNumOfFqids || !POWER_OF_2(p_KeyAndHash->hashDistributionNumOfFqids))
22345 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("hashDistributionNumOfFqids must not be 0 and must be a power of 2"));
22346 + if ((p_KeyAndHash->hashDistributionNumOfFqids-1) & p_SchemeParams->baseFqid)
22347 + DBG(WARNING, ("baseFqid unaligned. Distribution may result in less than hashDistributionNumOfFqids queues."));
22348 + }
22349 +
22350 + /* configure kgse_ekdv */
22351 + tmpReg = 0;
22352 + for ( i=0 ;i<p_KeyAndHash->numOfUsedDflts ; i++)
22353 + {
22354 + switch (p_KeyAndHash->dflts[i].type)
22355 + {
22356 + case (e_FM_PCD_KG_MAC_ADDR):
22357 + tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_MAC_ADDR_SHIFT);
22358 + break;
22359 + case (e_FM_PCD_KG_TCI):
22360 + tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_TCI_SHIFT);
22361 + break;
22362 + case (e_FM_PCD_KG_ENET_TYPE):
22363 + tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_ENET_TYPE_SHIFT);
22364 + break;
22365 + case (e_FM_PCD_KG_PPP_SESSION_ID):
22366 + tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_PPP_SESSION_ID_SHIFT);
22367 + break;
22368 + case (e_FM_PCD_KG_PPP_PROTOCOL_ID):
22369 + tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_PPP_PROTOCOL_ID_SHIFT);
22370 + break;
22371 + case (e_FM_PCD_KG_MPLS_LABEL):
22372 + tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_MPLS_LABEL_SHIFT);
22373 + break;
22374 + case (e_FM_PCD_KG_IP_ADDR):
22375 + tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_IP_ADDR_SHIFT);
22376 + break;
22377 + case (e_FM_PCD_KG_PROTOCOL_TYPE):
22378 + tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_PROTOCOL_TYPE_SHIFT);
22379 + break;
22380 + case (e_FM_PCD_KG_IP_TOS_TC):
22381 + tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_IP_TOS_TC_SHIFT);
22382 + break;
22383 + case (e_FM_PCD_KG_IPV6_FLOW_LABEL):
22384 + tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_L4_PORT_SHIFT);
22385 + break;
22386 + case (e_FM_PCD_KG_IPSEC_SPI):
22387 + tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_IPSEC_SPI_SHIFT);
22388 + break;
22389 + case (e_FM_PCD_KG_L4_PORT):
22390 + tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_L4_PORT_SHIFT);
22391 + break;
22392 + case (e_FM_PCD_KG_TCP_FLAG):
22393 + tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_TCP_FLAG_SHIFT);
22394 + break;
22395 + case (e_FM_PCD_KG_GENERIC_FROM_DATA):
22396 + swDefaults[numOfSwDefaults].type = e_FM_PCD_KG_GENERIC_FROM_DATA;
22397 + swDefaults[numOfSwDefaults].dfltSelect = p_KeyAndHash->dflts[i].dfltSelect;
22398 + numOfSwDefaults ++;
22399 + break;
22400 + case (e_FM_PCD_KG_GENERIC_FROM_DATA_NO_V):
22401 + swDefaults[numOfSwDefaults].type = e_FM_PCD_KG_GENERIC_FROM_DATA_NO_V;
22402 + swDefaults[numOfSwDefaults].dfltSelect = p_KeyAndHash->dflts[i].dfltSelect;
22403 + numOfSwDefaults ++;
22404 + break;
22405 + case (e_FM_PCD_KG_GENERIC_NOT_FROM_DATA):
22406 + swDefaults[numOfSwDefaults].type = e_FM_PCD_KG_GENERIC_NOT_FROM_DATA;
22407 + swDefaults[numOfSwDefaults].dfltSelect = p_KeyAndHash->dflts[i].dfltSelect;
22408 + numOfSwDefaults ++;
22409 + break;
22410 + default:
22411 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
22412 + }
22413 + }
22414 + p_SchemeRegs->kgse_ekdv = tmpReg;
22415 +
22416 + p_LocalExtractsArray = (t_FmPcdKgSchemesExtracts *)XX_Malloc(sizeof(t_FmPcdKgSchemesExtracts));
22417 + if (!p_LocalExtractsArray)
22418 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));
22419 +
22420 + /* configure kgse_ekfc and kgse_gec */
22421 + knownTmp = 0;
22422 + for ( i=0 ;i<p_KeyAndHash->numOfUsedExtracts ; i++)
22423 + {
22424 + p_Extract = &p_KeyAndHash->extractArray[i];
22425 + switch (p_Extract->type)
22426 + {
22427 + case (e_FM_PCD_KG_EXTRACT_PORT_PRIVATE_INFO):
22428 + knownTmp |= KG_SCH_KN_PORT_ID;
22429 + /* save in driver structure */
22430 + p_LocalExtractsArray->extractsArray[i].id = GetKnownFieldId(KG_SCH_KN_PORT_ID);
22431 + p_LocalExtractsArray->extractsArray[i].known = TRUE;
22432 + break;
22433 + case (e_FM_PCD_EXTRACT_BY_HDR):
22434 + switch (p_Extract->extractByHdr.hdr)
22435 + {
22436 +#if (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
22437 + case (HEADER_TYPE_UDP_LITE):
22438 + p_Extract->extractByHdr.hdr = HEADER_TYPE_UDP;
22439 + break;
22440 +#endif /* (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
22441 + case (HEADER_TYPE_UDP_ENCAP_ESP):
22442 + switch (p_Extract->extractByHdr.type)
22443 + {
22444 + case (e_FM_PCD_EXTRACT_FROM_HDR):
22445 + /* case where extraction from ESP only */
22446 + if (p_Extract->extractByHdr.extractByHdrType.fromHdr.offset >= UDP_HEADER_SIZE)
22447 + {
22448 + p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_Scheme->netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
22449 + p_Extract->extractByHdr.extractByHdrType.fromHdr.offset -= UDP_HEADER_SIZE;
22450 + p_Extract->extractByHdr.ignoreProtocolValidation = TRUE;
22451 + }
22452 + else
22453 + {
22454 + p_Extract->extractByHdr.hdr = HEADER_TYPE_UDP;
22455 + p_Extract->extractByHdr.ignoreProtocolValidation = FALSE;
22456 + }
22457 + break;
22458 + case (e_FM_PCD_EXTRACT_FROM_FIELD):
22459 + switch (p_Extract->extractByHdr.extractByHdrType.fromField.field.udpEncapEsp)
22460 + {
22461 + case (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC):
22462 + case (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_DST):
22463 + case (NET_HEADER_FIELD_UDP_ENCAP_ESP_LEN):
22464 + case (NET_HEADER_FIELD_UDP_ENCAP_ESP_CKSUM):
22465 + p_Extract->extractByHdr.hdr = HEADER_TYPE_UDP;
22466 + break;
22467 + case (NET_HEADER_FIELD_UDP_ENCAP_ESP_SPI):
22468 + p_Extract->extractByHdr.type = e_FM_PCD_EXTRACT_FROM_HDR;
22469 + p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_Scheme->netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
22470 + /*p_Extract->extractByHdr.extractByHdrType.fromField.offset += ESP_SPI_OFFSET;*/
22471 + p_Extract->extractByHdr.ignoreProtocolValidation = TRUE;
22472 + break;
22473 + case (NET_HEADER_FIELD_UDP_ENCAP_ESP_SEQUENCE_NUM):
22474 + p_Extract->extractByHdr.type = e_FM_PCD_EXTRACT_FROM_HDR;
22475 + p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_Scheme->netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
22476 + p_Extract->extractByHdr.extractByHdrType.fromField.offset += ESP_SEQ_NUM_OFFSET;
22477 + p_Extract->extractByHdr.ignoreProtocolValidation = TRUE;
22478 + break;
22479 + }
22480 + break;
22481 + case (e_FM_PCD_EXTRACT_FULL_FIELD):
22482 + switch (p_Extract->extractByHdr.extractByHdrType.fullField.udpEncapEsp)
22483 + {
22484 + case (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC):
22485 + case (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_DST):
22486 + case (NET_HEADER_FIELD_UDP_ENCAP_ESP_LEN):
22487 + case (NET_HEADER_FIELD_UDP_ENCAP_ESP_CKSUM):
22488 + p_Extract->extractByHdr.hdr = HEADER_TYPE_UDP;
22489 + break;
22490 + case (NET_HEADER_FIELD_UDP_ENCAP_ESP_SPI):
22491 + p_Extract->extractByHdr.type = e_FM_PCD_EXTRACT_FROM_HDR;
22492 + p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_Scheme->netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
22493 + p_Extract->extractByHdr.extractByHdrType.fromHdr.size = ESP_SPI_SIZE;
22494 + p_Extract->extractByHdr.extractByHdrType.fromHdr.offset = ESP_SPI_OFFSET;
22495 + p_Extract->extractByHdr.ignoreProtocolValidation = TRUE;
22496 + break;
22497 + case (NET_HEADER_FIELD_UDP_ENCAP_ESP_SEQUENCE_NUM):
22498 + p_Extract->extractByHdr.type = e_FM_PCD_EXTRACT_FROM_HDR;
22499 + p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_Scheme->netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
22500 + p_Extract->extractByHdr.extractByHdrType.fromHdr.size = ESP_SEQ_NUM_SIZE;
22501 + p_Extract->extractByHdr.extractByHdrType.fromHdr.offset = ESP_SEQ_NUM_OFFSET;
22502 + p_Extract->extractByHdr.ignoreProtocolValidation = TRUE;
22503 + break;
22504 + }
22505 + break;
22506 + }
22507 + break;
22508 + default:
22509 + break;
22510 + }
22511 + switch (p_Extract->extractByHdr.type)
22512 + {
22513 + case (e_FM_PCD_EXTRACT_FROM_HDR):
22514 + generic = TRUE;
22515 + /* get the header code for the generic extract */
22516 + code = GetGenHdrCode(p_Extract->extractByHdr.hdr, p_Extract->extractByHdr.hdrIndex, p_Extract->extractByHdr.ignoreProtocolValidation);
22517 + /* set generic register fields */
22518 + offset = p_Extract->extractByHdr.extractByHdrType.fromHdr.offset;
22519 + size = p_Extract->extractByHdr.extractByHdrType.fromHdr.size;
22520 + break;
22521 + case (e_FM_PCD_EXTRACT_FROM_FIELD):
22522 + generic = TRUE;
22523 + /* get the field code for the generic extract */
22524 + code = GetGenFieldCode(p_Extract->extractByHdr.hdr,
22525 + p_Extract->extractByHdr.extractByHdrType.fromField.field, p_Extract->extractByHdr.ignoreProtocolValidation,p_Extract->extractByHdr.hdrIndex);
22526 + offset = p_Extract->extractByHdr.extractByHdrType.fromField.offset;
22527 + size = p_Extract->extractByHdr.extractByHdrType.fromField.size;
22528 + break;
22529 + case (e_FM_PCD_EXTRACT_FULL_FIELD):
22530 + if (!p_Extract->extractByHdr.ignoreProtocolValidation)
22531 + {
22532 + /* if we have a known field for it - use it, otherwise use generic */
22533 + bitMask = GetKnownProtMask(p_FmPcd, p_Extract->extractByHdr.hdr, p_Extract->extractByHdr.hdrIndex,
22534 + p_Extract->extractByHdr.extractByHdrType.fullField);
22535 + if (bitMask)
22536 + {
22537 + knownTmp |= bitMask;
22538 + /* save in driver structure */
22539 + p_LocalExtractsArray->extractsArray[i].id = GetKnownFieldId(bitMask);
22540 + p_LocalExtractsArray->extractsArray[i].known = TRUE;
22541 + }
22542 + else
22543 + generic = TRUE;
22544 + }
22545 + else
22546 + generic = TRUE;
22547 + if (generic)
22548 + {
22549 + /* tmp - till we cover more headers under generic */
22550 + XX_Free(p_LocalExtractsArray);
22551 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Full header selection not supported"));
22552 + }
22553 + break;
22554 + default:
22555 + XX_Free(p_LocalExtractsArray);
22556 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
22557 + }
22558 + break;
22559 + case (e_FM_PCD_EXTRACT_NON_HDR):
22560 + /* use generic */
22561 + generic = TRUE;
22562 + offset = 0;
22563 + /* get the field code for the generic extract */
22564 + code = GetGenCode(p_Extract->extractNonHdr.src, &offset);
22565 + offset += p_Extract->extractNonHdr.offset;
22566 + size = p_Extract->extractNonHdr.size;
22567 + break;
22568 + default:
22569 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
22570 + }
22571 +
22572 + if (generic)
22573 + {
22574 + /* set generic register fields */
22575 + if (currGenId >= FM_KG_NUM_OF_GENERIC_REGS)
22576 + {
22577 + XX_Free(p_LocalExtractsArray);
22578 + RETURN_ERROR(MAJOR, E_FULL, ("Generic registers are fully used"));
22579 + }
22580 + if (!code)
22581 + {
22582 + XX_Free(p_LocalExtractsArray);
22583 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, NO_MSG);
22584 + }
22585 +
22586 + genTmp = KG_SCH_GEN_VALID;
22587 + genTmp |= (uint32_t)(code << KG_SCH_GEN_HT_SHIFT);
22588 + genTmp |= offset;
22589 + if ((size > MAX_KG_SCH_SIZE) || (size < 1))
22590 + {
22591 + XX_Free(p_LocalExtractsArray);
22592 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal extraction (size out of range)"));
22593 + }
22594 + genTmp |= (uint32_t)((size - 1) << KG_SCH_GEN_SIZE_SHIFT);
22595 + swDefault = GetGenericSwDefault(swDefaults, numOfSwDefaults, code);
22596 + if (swDefault == e_FM_PCD_KG_DFLT_ILLEGAL)
22597 + DBG(WARNING, ("No sw default configured"));
22598 + else
22599 + genTmp |= swDefault << KG_SCH_GEN_DEF_SHIFT;
22600 +
22601 + genTmp |= KG_SCH_GEN_MASK;
22602 + p_SchemeRegs->kgse_gec[currGenId] = genTmp;
22603 + /* save in driver structure */
22604 + p_LocalExtractsArray->extractsArray[i].id = currGenId++;
22605 + p_LocalExtractsArray->extractsArray[i].known = FALSE;
22606 + generic = FALSE;
22607 + }
22608 + }
22609 + p_SchemeRegs->kgse_ekfc = knownTmp;
22610 +
22611 + selectTmp = 0;
22612 + maskTmp = 0xFFFFFFFF;
22613 + /* configure kgse_bmch, kgse_bmcl and kgse_fqb */
22614 +
22615 + if (p_KeyAndHash->numOfUsedMasks > FM_PCD_KG_NUM_OF_EXTRACT_MASKS)
22616 + {
22617 + XX_Free(p_LocalExtractsArray);
22618 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Only %d masks supported", FM_PCD_KG_NUM_OF_EXTRACT_MASKS));
22619 + }
22620 + for ( i=0 ;i<p_KeyAndHash->numOfUsedMasks ; i++)
22621 + {
22622 + /* Get the relative id of the extract (for known 0-0x1f, for generic 0-7) */
22623 + id = p_LocalExtractsArray->extractsArray[p_KeyAndHash->masks[i].extractArrayIndex].id;
22624 + /* Get the shift of the select field (depending on i) */
22625 + GET_MASK_SEL_SHIFT(shift,i);
22626 + if (p_LocalExtractsArray->extractsArray[p_KeyAndHash->masks[i].extractArrayIndex].known)
22627 + selectTmp |= id << shift;
22628 + else
22629 + selectTmp |= (id + MASK_FOR_GENERIC_BASE_ID) << shift;
22630 +
22631 + /* Get the shift of the offset field (depending on i) - may
22632 + be in kgse_bmch or in kgse_fqb (depending on i) */
22633 + GET_MASK_OFFSET_SHIFT(shift,i);
22634 + if (i<=1)
22635 + selectTmp |= p_KeyAndHash->masks[i].offset << shift;
22636 + else
22637 + fqbTmp |= p_KeyAndHash->masks[i].offset << shift;
22638 +
22639 + /* Get the shift of the mask field (depending on i) */
22640 + GET_MASK_SHIFT(shift,i);
22641 + /* pass all bits */
22642 + maskTmp |= KG_SCH_BITMASK_MASK << shift;
22643 + /* clear bits that need masking */
22644 + maskTmp &= ~(0xFF << shift) ;
22645 + /* set mask bits */
22646 + maskTmp |= (p_KeyAndHash->masks[i].mask << shift) ;
22647 + }
22648 + p_SchemeRegs->kgse_bmch = selectTmp;
22649 + p_SchemeRegs->kgse_bmcl = maskTmp;
22650 + /* kgse_fqb will be written t the end of the routine */
22651 +
22652 + /* configure kgse_hc */
22653 + if (p_KeyAndHash->hashShift > MAX_HASH_SHIFT)
22654 + {
22655 + XX_Free(p_LocalExtractsArray);
22656 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("hashShift must not be larger than %d", MAX_HASH_SHIFT));
22657 + }
22658 + if (p_KeyAndHash->hashDistributionFqidsShift > MAX_DIST_FQID_SHIFT)
22659 + {
22660 + XX_Free(p_LocalExtractsArray);
22661 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("hashDistributionFqidsShift must not be larger than %d", MAX_DIST_FQID_SHIFT));
22662 + }
22663 +
22664 + tmpReg = 0;
22665 +
22666 + tmpReg |= ((p_KeyAndHash->hashDistributionNumOfFqids - 1) << p_KeyAndHash->hashDistributionFqidsShift);
22667 + tmpReg |= p_KeyAndHash->hashShift << KG_SCH_HASH_CONFIG_SHIFT_SHIFT;
22668 +
22669 + if (p_KeyAndHash->symmetricHash)
22670 + {
22671 + if ((!!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_MACSRC) != !!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_MACDST)) ||
22672 + (!!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_IPSRC1) != !!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_IPDST1)) ||
22673 + (!!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_IPSRC2) != !!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_IPDST2)) ||
22674 + (!!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_L4PSRC) != !!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_L4PDST)))
22675 + {
22676 + XX_Free(p_LocalExtractsArray);
22677 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("symmetricHash set but src/dest extractions missing"));
22678 + }
22679 + tmpReg |= KG_SCH_HASH_CONFIG_SYM;
22680 + }
22681 + p_SchemeRegs->kgse_hc = tmpReg;
22682 +
22683 + /* build the return array describing the order of the extractions */
22684 +
22685 + /* the last currGenId places of the array
22686 + are for generic extracts that are always last.
22687 + We now sort for the calculation of the order of the known
22688 + extractions we sort the known extracts between orderedArray[0] and
22689 + orderedArray[p_KeyAndHash->numOfUsedExtracts - currGenId - 1].
22690 + for the calculation of the order of the generic extractions we use:
22691 + num_of_generic - currGenId
22692 + num_of_known - p_KeyAndHash->numOfUsedExtracts - currGenId
22693 + first_generic_index = num_of_known */
22694 + curr = 0;
22695 + for (i=0;i<p_KeyAndHash->numOfUsedExtracts ; i++)
22696 + {
22697 + if (p_LocalExtractsArray->extractsArray[i].known)
22698 + {
22699 + ASSERT_COND(curr<(p_KeyAndHash->numOfUsedExtracts - currGenId));
22700 + j = curr;
22701 + /* id is the extract id (port id = 0, mac src = 1 etc.). the value in the array is the original
22702 + index in the user's extractions array */
22703 + /* we compare the id of the current extract with the id of the extract in the orderedArray[j-1]
22704 + location */
22705 + while ((j > 0) && (p_LocalExtractsArray->extractsArray[i].id <
22706 + p_LocalExtractsArray->extractsArray[p_Scheme->orderedArray[j-1]].id))
22707 + {
22708 + p_Scheme->orderedArray[j] =
22709 + p_Scheme->orderedArray[j-1];
22710 + j--;
22711 + }
22712 + p_Scheme->orderedArray[j] = (uint8_t)i;
22713 + curr++;
22714 + }
22715 + else
22716 + {
22717 + /* index is first_generic_index + generic index (id) */
22718 + idx = (uint8_t)(p_KeyAndHash->numOfUsedExtracts - currGenId + p_LocalExtractsArray->extractsArray[i].id);
22719 + ASSERT_COND(idx < FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY);
22720 + p_Scheme->orderedArray[idx]= (uint8_t)i;
22721 + }
22722 + }
22723 + XX_Free(p_LocalExtractsArray);
22724 + }
22725 + else
22726 + {
22727 + /* clear all unused registers: */
22728 + p_SchemeRegs->kgse_ekfc = 0;
22729 + p_SchemeRegs->kgse_ekdv = 0;
22730 + p_SchemeRegs->kgse_bmch = 0;
22731 + p_SchemeRegs->kgse_bmcl = 0;
22732 + p_SchemeRegs->kgse_hc = 0;
22733 + p_SchemeRegs->kgse_dv0 = 0;
22734 + p_SchemeRegs->kgse_dv1 = 0;
22735 + }
22736 +
22737 + if (p_SchemeParams->bypassFqidGeneration)
22738 + p_SchemeRegs->kgse_hc |= KG_SCH_HASH_CONFIG_NO_FQID;
22739 +
22740 + /* configure kgse_spc */
22741 + if ( p_SchemeParams->schemeCounter.update)
22742 + p_SchemeRegs->kgse_spc = p_SchemeParams->schemeCounter.value;
22743 +
22744 +
22745 + /* check that are enough generic registers */
22746 + if (p_SchemeParams->numOfUsedExtractedOrs + currGenId > FM_KG_NUM_OF_GENERIC_REGS)
22747 + RETURN_ERROR(MAJOR, E_FULL, ("Generic registers are fully used"));
22748 +
22749 + /* extracted OR mask on Qid */
22750 + for ( i=0 ;i<p_SchemeParams->numOfUsedExtractedOrs ; i++)
22751 + {
22752 +
22753 + p_Scheme->extractedOrs = TRUE;
22754 + /* configure kgse_gec[i] */
22755 + p_ExtractOr = &p_SchemeParams->extractedOrs[i];
22756 + switch (p_ExtractOr->type)
22757 + {
22758 + case (e_FM_PCD_KG_EXTRACT_PORT_PRIVATE_INFO):
22759 + code = KG_SCH_GEN_PARSE_RESULT_N_FQID;
22760 + offset = 0;
22761 + break;
22762 + case (e_FM_PCD_EXTRACT_BY_HDR):
22763 + /* get the header code for the generic extract */
22764 + code = GetGenHdrCode(p_ExtractOr->extractByHdr.hdr, p_ExtractOr->extractByHdr.hdrIndex, p_ExtractOr->extractByHdr.ignoreProtocolValidation);
22765 + /* set generic register fields */
22766 + offset = p_ExtractOr->extractionOffset;
22767 + break;
22768 + case (e_FM_PCD_EXTRACT_NON_HDR):
22769 + /* get the field code for the generic extract */
22770 + offset = 0;
22771 + code = GetGenCode(p_ExtractOr->src, &offset);
22772 + offset += p_ExtractOr->extractionOffset;
22773 + break;
22774 + default:
22775 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
22776 + }
22777 +
22778 + /* set generic register fields */
22779 + if (!code)
22780 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, NO_MSG);
22781 + genTmp = KG_SCH_GEN_EXTRACT_TYPE | KG_SCH_GEN_VALID;
22782 + genTmp |= (uint32_t)(code << KG_SCH_GEN_HT_SHIFT);
22783 + genTmp |= offset;
22784 + if (!!p_ExtractOr->bitOffsetInFqid == !!p_ExtractOr->bitOffsetInPlcrProfile)
22785 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, (" extracted byte must effect either FQID or Policer profile"));
22786 +
22787 + /************************************************************************************
22788 + bitOffsetInFqid and bitOffsetInPolicerProfile are translated to rotate parameter
22789 + in the following way:
22790 +
22791 + Driver API and implementation:
22792 + ==============================
22793 + FQID: extracted OR byte may be shifted right 1-31 bits to effect parts of the FQID.
22794 + if shifted less than 8 bits, or more than 24 bits a mask is set on the bits that
22795 + are not overlapping FQID.
22796 + ------------------------
22797 + | FQID (24) |
22798 + ------------------------
22799 + --------
22800 + | | extracted OR byte
22801 + --------
22802 +
22803 + Policer Profile: extracted OR byte may be shifted right 1-15 bits to effect parts of the
22804 + PP id. Unless shifted exactly 8 bits to overlap the PP id, a mask is set on the bits that
22805 + are not overlapping PP id.
22806 +
22807 + --------
22808 + | PP (8) |
22809 + --------
22810 + --------
22811 + | | extracted OR byte
22812 + --------
22813 +
22814 + HW implementation
22815 + =================
22816 + FQID and PP construct a 32 bit word in the way describe below. Extracted byte is located
22817 + as the highest byte of that word and may be rotated to effect any part os the FQID or
22818 + the PP.
22819 + ------------------------ --------
22820 + | FQID (24) || PP (8) |
22821 + ------------------------ --------
22822 + --------
22823 + | | extracted OR byte
22824 + --------
22825 +
22826 + ************************************************************************************/
22827 +
22828 + if (p_ExtractOr->bitOffsetInFqid)
22829 + {
22830 + if (p_ExtractOr->bitOffsetInFqid > MAX_KG_SCH_FQID_BIT_OFFSET )
22831 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal extraction (bitOffsetInFqid out of range)"));
22832 + if (p_ExtractOr->bitOffsetInFqid<8)
22833 + genTmp |= (uint32_t)((p_ExtractOr->bitOffsetInFqid+24) << KG_SCH_GEN_SIZE_SHIFT);
22834 + else
22835 + genTmp |= (uint32_t)((p_ExtractOr->bitOffsetInFqid-8) << KG_SCH_GEN_SIZE_SHIFT);
22836 + p_ExtractOr->mask &= GetExtractedOrMask(p_ExtractOr->bitOffsetInFqid, TRUE);
22837 + }
22838 + else /* effect policer profile */
22839 + {
22840 + if (p_ExtractOr->bitOffsetInPlcrProfile > MAX_KG_SCH_PP_BIT_OFFSET )
22841 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal extraction (bitOffsetInPlcrProfile out of range)"));
22842 + p_Scheme->bitOffsetInPlcrProfile = p_ExtractOr->bitOffsetInPlcrProfile;
22843 + genTmp |= (uint32_t)((p_ExtractOr->bitOffsetInPlcrProfile+16) << KG_SCH_GEN_SIZE_SHIFT);
22844 + p_ExtractOr->mask &= GetExtractedOrMask(p_ExtractOr->bitOffsetInPlcrProfile, FALSE);
22845 + }
22846 +
22847 + genTmp |= (uint32_t)(p_ExtractOr->extractionOffset << KG_SCH_GEN_DEF_SHIFT);
22848 + /* clear bits that need masking */
22849 + genTmp &= ~KG_SCH_GEN_MASK ;
22850 + /* set mask bits */
22851 + genTmp |= (uint32_t)(p_ExtractOr->mask << KG_SCH_GEN_MASK_SHIFT);
22852 + p_SchemeRegs->kgse_gec[currGenId++] = genTmp;
22853 +
22854 + }
22855 + /* clear all unused GEC registers */
22856 + for ( i=currGenId ;i<FM_KG_NUM_OF_GENERIC_REGS ; i++)
22857 + p_SchemeRegs->kgse_gec[i] = 0;
22858 +
22859 + /* add base Qid for this scheme */
22860 + /* add configuration for kgse_fqb */
22861 + if (p_SchemeParams->baseFqid & ~0x00FFFFFF)
22862 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("baseFqid must be between 1 and 2^24-1"));
22863 +
22864 + fqbTmp |= p_SchemeParams->baseFqid;
22865 + p_SchemeRegs->kgse_fqb = fqbTmp;
22866 +
22867 + p_Scheme->nextEngine = p_SchemeParams->nextEngine;
22868 + p_Scheme->doneAction = p_SchemeParams->kgNextEngineParams.doneAction;
22869 +
22870 + return E_OK;
22871 +}
22872 +
22873 +
22874 +/*****************************************************************************/
22875 +/* Inter-module API routines */
22876 +/*****************************************************************************/
22877 +
22878 +t_Error FmPcdKgBuildClsPlanGrp(t_Handle h_FmPcd, t_FmPcdKgInterModuleClsPlanGrpParams *p_Grp, t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet)
22879 +{
22880 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
22881 + t_FmPcdKgClsPlanGrp *p_ClsPlanGrp;
22882 + t_FmPcdIpcKgClsPlanParams kgAlloc;
22883 + t_Error err = E_OK;
22884 + uint32_t oredVectors = 0;
22885 + int i, j;
22886 +
22887 + /* this routine is protected by the calling routine ! */
22888 + if (p_Grp->numOfOptions >= FM_PCD_MAX_NUM_OF_OPTIONS(FM_PCD_MAX_NUM_OF_CLS_PLANS))
22889 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,("Too many classification plan basic options selected."));
22890 +
22891 + /* find a new clsPlan group */
22892 + for (i = 0; i < FM_MAX_NUM_OF_PORTS; i++)
22893 + if (!p_FmPcd->p_FmPcdKg->clsPlanGrps[i].used)
22894 + break;
22895 + if (i == FM_MAX_NUM_OF_PORTS)
22896 + RETURN_ERROR(MAJOR, E_FULL,("No classification plan groups available."));
22897 +
22898 + p_FmPcd->p_FmPcdKg->clsPlanGrps[i].used = TRUE;
22899 +
22900 + p_Grp->clsPlanGrpId = (uint8_t)i;
22901 +
22902 + if (p_Grp->numOfOptions == 0)
22903 + p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId = (uint8_t)i;
22904 +
22905 + p_ClsPlanGrp = &p_FmPcd->p_FmPcdKg->clsPlanGrps[i];
22906 + p_ClsPlanGrp->netEnvId = p_Grp->netEnvId;
22907 + p_ClsPlanGrp->owners = 0;
22908 + FmPcdSetClsPlanGrpId(p_FmPcd, p_Grp->netEnvId, p_Grp->clsPlanGrpId);
22909 + if (p_Grp->numOfOptions != 0)
22910 + FmPcdIncNetEnvOwners(p_FmPcd, p_Grp->netEnvId);
22911 +
22912 + p_ClsPlanGrp->sizeOfGrp = (uint16_t)(1 << p_Grp->numOfOptions);
22913 + /* a minimal group of 8 is required */
22914 + if (p_ClsPlanGrp->sizeOfGrp < CLS_PLAN_NUM_PER_GRP)
22915 + p_ClsPlanGrp->sizeOfGrp = CLS_PLAN_NUM_PER_GRP;
22916 + if (p_FmPcd->guestId == NCSW_MASTER_ID)
22917 + {
22918 + err = KgAllocClsPlanEntries(h_FmPcd, p_ClsPlanGrp->sizeOfGrp, p_FmPcd->guestId, &p_ClsPlanGrp->baseEntry);
22919 +
22920 + if (err)
22921 + RETURN_ERROR(MINOR, E_INVALID_STATE, NO_MSG);
22922 + }
22923 + else
22924 + {
22925 + t_FmPcdIpcMsg msg;
22926 + uint32_t replyLength;
22927 + t_FmPcdIpcReply reply;
22928 +
22929 + /* in GUEST_PARTITION, we use the IPC, to also set a private driver group if required */
22930 + memset(&reply, 0, sizeof(reply));
22931 + memset(&msg, 0, sizeof(msg));
22932 + memset(&kgAlloc, 0, sizeof(kgAlloc));
22933 + kgAlloc.guestId = p_FmPcd->guestId;
22934 + kgAlloc.numOfClsPlanEntries = p_ClsPlanGrp->sizeOfGrp;
22935 + msg.msgId = FM_PCD_ALLOC_KG_CLSPLAN;
22936 + memcpy(msg.msgBody, &kgAlloc, sizeof(kgAlloc));
22937 + replyLength = (sizeof(uint32_t) + sizeof(p_ClsPlanGrp->baseEntry));
22938 + if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
22939 + (uint8_t*)&msg,
22940 + sizeof(msg.msgId) + sizeof(kgAlloc),
22941 + (uint8_t*)&reply,
22942 + &replyLength,
22943 + NULL,
22944 + NULL)) != E_OK)
22945 + RETURN_ERROR(MAJOR, err, NO_MSG);
22946 +
22947 + if (replyLength != (sizeof(uint32_t) + sizeof(p_ClsPlanGrp->baseEntry)))
22948 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
22949 + if ((t_Error)reply.error != E_OK)
22950 + RETURN_ERROR(MINOR, (t_Error)reply.error, NO_MSG);
22951 +
22952 + p_ClsPlanGrp->baseEntry = *(uint8_t*)(reply.replyBody);
22953 + }
22954 +
22955 + /* build classification plan entries parameters */
22956 + p_ClsPlanSet->baseEntry = p_ClsPlanGrp->baseEntry;
22957 + p_ClsPlanSet->numOfClsPlanEntries = p_ClsPlanGrp->sizeOfGrp;
22958 +
22959 + oredVectors = 0;
22960 + for (i = 0; i<p_Grp->numOfOptions; i++)
22961 + {
22962 + oredVectors |= p_Grp->optVectors[i];
22963 + /* save an array of used options - the indexes represent the power of 2 index */
22964 + p_ClsPlanGrp->optArray[i] = p_Grp->options[i];
22965 + }
22966 + /* set the classification plan relevant entries so that all bits
22967 + * relevant to the list of options is cleared
22968 + */
22969 + for (j = 0; j<p_ClsPlanGrp->sizeOfGrp; j++)
22970 + p_ClsPlanSet->vectors[j] = ~oredVectors;
22971 +
22972 + for (i = 0; i<p_Grp->numOfOptions; i++)
22973 + {
22974 + /* option i got the place 2^i in the clsPlan array. all entries that
22975 + * have bit i set, should have the vector bit cleared. So each option
22976 + * has one location that it is exclusive (1,2,4,8...) and represent the
22977 + * presence of that option only, and other locations that represent a
22978 + * combination of options.
22979 + * e.g:
22980 + * If ethernet-BC is option 1 it gets entry 2 in the table. Entry 2
22981 + * now represents a frame with ethernet-BC header - so the bit
22982 + * representing ethernet-BC should be set and all other option bits
22983 + * should be cleared.
22984 + * Entries 2,3,6,7,10... also have ethernet-BC and therefore have bit
22985 + * vector[1] set, but they also have other bits set:
22986 + * 3=1+2, options 0 and 1
22987 + * 6=2+4, options 1 and 2
22988 + * 7=1+2+4, options 0,1,and 2
22989 + * 10=2+8, options 1 and 3
22990 + * etc.
22991 + * */
22992 +
22993 + /* now for each option (i), we set their bits in all entries (j)
22994 + * that contain bit 2^i.
22995 + */
22996 + for (j = 0; j<p_ClsPlanGrp->sizeOfGrp; j++)
22997 + {
22998 + if (j & (1<<i))
22999 + p_ClsPlanSet->vectors[j] |= p_Grp->optVectors[i];
23000 + }
23001 + }
23002 +
23003 + return E_OK;
23004 +}
23005 +
23006 +void FmPcdKgDestroyClsPlanGrp(t_Handle h_FmPcd, uint8_t grpId)
23007 +{
23008 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23009 + t_FmPcdIpcKgClsPlanParams kgAlloc;
23010 + t_Error err;
23011 + t_FmPcdIpcMsg msg;
23012 + uint32_t replyLength;
23013 + t_FmPcdIpcReply reply;
23014 +
23015 + /* check that no port is bound to this clsPlan */
23016 + if (p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].owners)
23017 + {
23018 + REPORT_ERROR(MINOR, E_INVALID_STATE, ("Trying to delete a clsPlan grp that has ports bound to"));
23019 + return;
23020 + }
23021 +
23022 + FmPcdSetClsPlanGrpId(p_FmPcd, p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].netEnvId, ILLEGAL_CLS_PLAN);
23023 +
23024 + if (grpId == p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId)
23025 + p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId = ILLEGAL_CLS_PLAN;
23026 + else
23027 + FmPcdDecNetEnvOwners(p_FmPcd, p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].netEnvId);
23028 +
23029 + /* free blocks */
23030 + if (p_FmPcd->guestId == NCSW_MASTER_ID)
23031 + KgFreeClsPlanEntries(h_FmPcd,
23032 + p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].sizeOfGrp,
23033 + p_FmPcd->guestId,
23034 + p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].baseEntry);
23035 + else /* in GUEST_PARTITION, we use the IPC, to also set a private driver group if required */
23036 + {
23037 + memset(&reply, 0, sizeof(reply));
23038 + memset(&msg, 0, sizeof(msg));
23039 + kgAlloc.guestId = p_FmPcd->guestId;
23040 + kgAlloc.numOfClsPlanEntries = p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].sizeOfGrp;
23041 + kgAlloc.clsPlanBase = p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].baseEntry;
23042 + msg.msgId = FM_PCD_FREE_KG_CLSPLAN;
23043 + memcpy(msg.msgBody, &kgAlloc, sizeof(kgAlloc));
23044 + replyLength = sizeof(uint32_t);
23045 + err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
23046 + (uint8_t*)&msg,
23047 + sizeof(msg.msgId) + sizeof(kgAlloc),
23048 + (uint8_t*)&reply,
23049 + &replyLength,
23050 + NULL,
23051 + NULL);
23052 + if (err != E_OK)
23053 + {
23054 + REPORT_ERROR(MINOR, err, NO_MSG);
23055 + return;
23056 + }
23057 + if (replyLength != sizeof(uint32_t))
23058 + {
23059 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
23060 + return;
23061 + }
23062 + if ((t_Error)reply.error != E_OK)
23063 + {
23064 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Free KG clsPlan failed"));
23065 + return;
23066 + }
23067 + }
23068 +
23069 + /* clear clsPlan driver structure */
23070 + memset(&p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId], 0, sizeof(t_FmPcdKgClsPlanGrp));
23071 +}
23072 +
23073 +t_Error FmPcdKgBuildBindPortToSchemes(t_Handle h_FmPcd, t_FmPcdKgInterModuleBindPortToSchemes *p_BindPort, uint32_t *p_SpReg, bool add)
23074 +{
23075 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23076 + uint32_t j, schemesPerPortVector = 0;
23077 + t_FmPcdKgScheme *p_Scheme;
23078 + uint8_t i, relativeSchemeId;
23079 + uint32_t tmp, walking1Mask;
23080 + uint8_t swPortIndex = 0;
23081 +
23082 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
23083 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE);
23084 + SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
23085 +
23086 + /* for each scheme */
23087 + for (i = 0; i<p_BindPort->numOfSchemes; i++)
23088 + {
23089 + relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, p_BindPort->schemesIds[i]);
23090 + if (relativeSchemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
23091 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
23092 +
23093 + if (add)
23094 + {
23095 + p_Scheme = &p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId];
23096 + if (!FmPcdKgIsSchemeValidSw(p_Scheme))
23097 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Requested scheme is invalid."));
23098 + /* check netEnvId of the port against the scheme netEnvId */
23099 + if ((p_Scheme->netEnvId != p_BindPort->netEnvId) && (p_Scheme->netEnvId != ILLEGAL_NETENV))
23100 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Port may not be bound to requested scheme - differ in netEnvId"));
23101 +
23102 + /* if next engine is private port policer profile, we need to check that it is valid */
23103 + HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, p_BindPort->hardwarePortId);
23104 + if (p_Scheme->nextRelativePlcrProfile)
23105 + {
23106 + for (j = 0;j<p_Scheme->numOfProfiles;j++)
23107 + {
23108 + ASSERT_COND(p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].h_FmPort);
23109 + if (p_Scheme->relativeProfileId+j >= p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles)
23110 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Relative profile not in range"));
23111 + if (!FmPcdPlcrIsProfileValid(p_FmPcd, (uint16_t)(p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase + p_Scheme->relativeProfileId + j)))
23112 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Relative profile not valid."));
23113 + }
23114 + }
23115 + if (!p_BindPort->useClsPlan)
23116 + {
23117 + /* This check may be redundant as port is a assigned to the whole NetEnv */
23118 +
23119 + /* if this port does not use clsPlan, it may not be bound to schemes with units that contain
23120 + cls plan options. Schemes that are used only directly, should not be checked.
23121 + it also may not be bound to schemes that go to CC with units that are options - so we OR
23122 + the match vector and the grpBits (= ccUnits) */
23123 + if ((p_Scheme->matchVector != SCHEME_ALWAYS_DIRECT) || p_Scheme->ccUnits)
23124 + {
23125 + uint8_t netEnvId;
23126 + walking1Mask = 0x80000000;
23127 + netEnvId = (p_Scheme->netEnvId == ILLEGAL_NETENV)? p_BindPort->netEnvId:p_Scheme->netEnvId;
23128 + tmp = (p_Scheme->matchVector == SCHEME_ALWAYS_DIRECT)? 0:p_Scheme->matchVector;
23129 + tmp |= p_Scheme->ccUnits;
23130 + while (tmp)
23131 + {
23132 + if (tmp & walking1Mask)
23133 + {
23134 + tmp &= ~walking1Mask;
23135 + if (!PcdNetEnvIsUnitWithoutOpts(p_FmPcd, netEnvId, walking1Mask))
23136 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Port (without clsPlan) may not be bound to requested scheme - uses clsPlan options"));
23137 + }
23138 + walking1Mask >>= 1;
23139 + }
23140 + }
23141 + }
23142 + }
23143 + /* build vector */
23144 + schemesPerPortVector |= 1 << (31 - p_BindPort->schemesIds[i]);
23145 + }
23146 +
23147 + *p_SpReg = schemesPerPortVector;
23148 +
23149 + return E_OK;
23150 +}
23151 +
23152 +t_Error FmPcdKgBindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind)
23153 +{
23154 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23155 + uint32_t spReg;
23156 + t_Error err = E_OK;
23157 +
23158 + err = FmPcdKgBuildBindPortToSchemes(h_FmPcd, p_SchemeBind, &spReg, TRUE);
23159 + if (err)
23160 + RETURN_ERROR(MAJOR, err, NO_MSG);
23161 +
23162 + err = KgWriteSp(p_FmPcd, p_SchemeBind->hardwarePortId, spReg, TRUE);
23163 + if (err)
23164 + RETURN_ERROR(MAJOR, err, NO_MSG);
23165 +
23166 + IncSchemeOwners(p_FmPcd, p_SchemeBind);
23167 +
23168 + return E_OK;
23169 +}
23170 +
23171 +t_Error FmPcdKgUnbindPortToSchemes(t_Handle h_FmPcd, t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind)
23172 +{
23173 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23174 + uint32_t spReg;
23175 + t_Error err = E_OK;
23176 +
23177 + err = FmPcdKgBuildBindPortToSchemes(p_FmPcd, p_SchemeBind, &spReg, FALSE);
23178 + if (err)
23179 + RETURN_ERROR(MAJOR, err, NO_MSG);
23180 +
23181 + err = KgWriteSp(p_FmPcd, p_SchemeBind->hardwarePortId, spReg, FALSE);
23182 + if (err)
23183 + RETURN_ERROR(MAJOR, err, NO_MSG);
23184 +
23185 + DecSchemeOwners(p_FmPcd, p_SchemeBind);
23186 +
23187 + return E_OK;
23188 +}
23189 +
23190 +bool FmPcdKgIsSchemeValidSw(t_Handle h_Scheme)
23191 +{
23192 + t_FmPcdKgScheme *p_Scheme = (t_FmPcdKgScheme*)h_Scheme;
23193 +
23194 + return p_Scheme->valid;
23195 +}
23196 +
23197 +bool KgIsSchemeAlwaysDirect(t_Handle h_FmPcd, uint8_t schemeId)
23198 +{
23199 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23200 +
23201 + if (p_FmPcd->p_FmPcdKg->schemes[schemeId].matchVector == SCHEME_ALWAYS_DIRECT)
23202 + return TRUE;
23203 + else
23204 + return FALSE;
23205 +}
23206 +
23207 +t_Error FmPcdKgAllocSchemes(t_Handle h_FmPcd, uint8_t numOfSchemes, uint8_t guestId, uint8_t *p_SchemesIds)
23208 +{
23209 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
23210 + uint8_t i, j;
23211 +
23212 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
23213 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE);
23214 +
23215 + /* This routine is issued only on master core of master partition -
23216 + either directly or through IPC, so no need for lock */
23217 +
23218 + for (j = 0, i = 0; i < FM_PCD_KG_NUM_OF_SCHEMES && j < numOfSchemes; i++)
23219 + {
23220 + if (!p_FmPcd->p_FmPcdKg->schemesMng[i].allocated)
23221 + {
23222 + p_FmPcd->p_FmPcdKg->schemesMng[i].allocated = TRUE;
23223 + p_FmPcd->p_FmPcdKg->schemesMng[i].ownerId = guestId;
23224 + p_SchemesIds[j] = i;
23225 + j++;
23226 + }
23227 + }
23228 +
23229 + if (j != numOfSchemes)
23230 + {
23231 + /* roll back */
23232 + for (j--; j; j--)
23233 + {
23234 + p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[j]].allocated = FALSE;
23235 + p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[j]].ownerId = 0;
23236 + p_SchemesIds[j] = 0;
23237 + }
23238 +
23239 + RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("No schemes found"));
23240 + }
23241 +
23242 + return E_OK;
23243 +}
23244 +
23245 +t_Error FmPcdKgFreeSchemes(t_Handle h_FmPcd, uint8_t numOfSchemes, uint8_t guestId, uint8_t *p_SchemesIds)
23246 +{
23247 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
23248 + uint8_t i;
23249 +
23250 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
23251 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE);
23252 +
23253 + /* This routine is issued only on master core of master partition -
23254 + either directly or through IPC */
23255 +
23256 + for (i = 0; i < numOfSchemes; i++)
23257 + {
23258 + if (!p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[i]].allocated)
23259 + {
23260 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Scheme was not previously allocated"));
23261 + }
23262 + if (p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[i]].ownerId != guestId)
23263 + {
23264 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Scheme is not owned by caller. "));
23265 + }
23266 + p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[i]].allocated = FALSE;
23267 + p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[i]].ownerId = 0;
23268 + }
23269 +
23270 + return E_OK;
23271 +}
23272 +
23273 +t_Error KgAllocClsPlanEntries(t_Handle h_FmPcd, uint16_t numOfClsPlanEntries, uint8_t guestId, uint8_t *p_First)
23274 +{
23275 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
23276 + uint8_t numOfBlocks, blocksFound=0, first=0;
23277 + uint8_t i, j;
23278 +
23279 + /* This routine is issued only on master core of master partition -
23280 + either directly or through IPC, so no need for lock */
23281 +
23282 + if (!numOfClsPlanEntries)
23283 + return E_OK;
23284 +
23285 + if ((numOfClsPlanEntries % CLS_PLAN_NUM_PER_GRP) || (!POWER_OF_2(numOfClsPlanEntries)))
23286 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfClsPlanEntries must be a power of 2 and divisible by 8"));
23287 +
23288 + numOfBlocks = (uint8_t)(numOfClsPlanEntries/CLS_PLAN_NUM_PER_GRP);
23289 +
23290 + /* try to find consequent blocks */
23291 + first = 0;
23292 + for (i = 0; i < FM_PCD_MAX_NUM_OF_CLS_PLANS/CLS_PLAN_NUM_PER_GRP;)
23293 + {
23294 + if (!p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].allocated)
23295 + {
23296 + blocksFound++;
23297 + i++;
23298 + if (blocksFound == numOfBlocks)
23299 + break;
23300 + }
23301 + else
23302 + {
23303 + blocksFound = 0;
23304 + /* advance i to the next aligned address */
23305 + first = i = (uint8_t)(first + numOfBlocks);
23306 + }
23307 + }
23308 +
23309 + if (blocksFound == numOfBlocks)
23310 + {
23311 + *p_First = (uint8_t)(first * CLS_PLAN_NUM_PER_GRP);
23312 + for (j = first; j < (first + numOfBlocks); j++)
23313 + {
23314 + p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[j].allocated = TRUE;
23315 + p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[j].ownerId = guestId;
23316 + }
23317 + return E_OK;
23318 + }
23319 + else
23320 + RETURN_ERROR(MINOR, E_FULL, ("No resources for clsPlan"));
23321 +}
23322 +
23323 +void KgFreeClsPlanEntries(t_Handle h_FmPcd, uint16_t numOfClsPlanEntries, uint8_t guestId, uint8_t base)
23324 +{
23325 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23326 + uint8_t numOfBlocks;
23327 + uint8_t i, baseBlock;
23328 +
23329 +#ifdef DISABLE_ASSERTIONS
23330 +UNUSED(guestId);
23331 +#endif /* DISABLE_ASSERTIONS */
23332 +
23333 + /* This routine is issued only on master core of master partition -
23334 + either directly or through IPC, so no need for lock */
23335 +
23336 + numOfBlocks = (uint8_t)(numOfClsPlanEntries/CLS_PLAN_NUM_PER_GRP);
23337 + ASSERT_COND(!(base%CLS_PLAN_NUM_PER_GRP));
23338 +
23339 + baseBlock = (uint8_t)(base/CLS_PLAN_NUM_PER_GRP);
23340 + for (i=baseBlock;i<baseBlock+numOfBlocks;i++)
23341 + {
23342 + ASSERT_COND(p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].allocated);
23343 + ASSERT_COND(guestId == p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].ownerId);
23344 + p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].allocated = FALSE;
23345 + p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].ownerId = 0;
23346 + }
23347 +}
23348 +
23349 +void KgEnable(t_FmPcd *p_FmPcd)
23350 +{
23351 + struct fman_kg_regs *p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
23352 +
23353 + ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
23354 + fman_kg_enable(p_Regs);
23355 +}
23356 +
23357 +void KgDisable(t_FmPcd *p_FmPcd)
23358 +{
23359 + struct fman_kg_regs *p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
23360 +
23361 + ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
23362 + fman_kg_disable(p_Regs);
23363 +}
23364 +
23365 +void KgSetClsPlan(t_Handle h_FmPcd, t_FmPcdKgInterModuleClsPlanSet *p_Set)
23366 +{
23367 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
23368 + struct fman_kg_cp_regs *p_FmPcdKgPortRegs;
23369 + uint32_t tmpKgarReg = 0, intFlags;
23370 + uint16_t i, j;
23371 +
23372 + /* This routine is protected by the calling routine ! */
23373 + ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
23374 + p_FmPcdKgPortRegs = &p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->clsPlanRegs;
23375 +
23376 + intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
23377 + for (i=p_Set->baseEntry;i<p_Set->baseEntry+p_Set->numOfClsPlanEntries;i+=8)
23378 + {
23379 + tmpKgarReg = FmPcdKgBuildWriteClsPlanBlockActionReg((uint8_t)(i / CLS_PLAN_NUM_PER_GRP));
23380 +
23381 + for (j = i; j < i+8; j++)
23382 + {
23383 + ASSERT_COND(IN_RANGE(0, (j - p_Set->baseEntry), FM_PCD_MAX_NUM_OF_CLS_PLANS-1));
23384 + WRITE_UINT32(p_FmPcdKgPortRegs->kgcpe[j % CLS_PLAN_NUM_PER_GRP],p_Set->vectors[j - p_Set->baseEntry]);
23385 + }
23386 +
23387 + if (WriteKgarWait(p_FmPcd, tmpKgarReg) != E_OK)
23388 + {
23389 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("WriteKgarWait FAILED"));
23390 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
23391 + return;
23392 + }
23393 + }
23394 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
23395 +}
23396 +
23397 +t_Handle KgConfig( t_FmPcd *p_FmPcd, t_FmPcdParams *p_FmPcdParams)
23398 +{
23399 + t_FmPcdKg *p_FmPcdKg;
23400 +
23401 + UNUSED(p_FmPcd);
23402 +
23403 + if (p_FmPcdParams->numOfSchemes > FM_PCD_KG_NUM_OF_SCHEMES)
23404 + {
23405 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
23406 + ("numOfSchemes should not exceed %d", FM_PCD_KG_NUM_OF_SCHEMES));
23407 + return NULL;
23408 + }
23409 +
23410 + p_FmPcdKg = (t_FmPcdKg *)XX_Malloc(sizeof(t_FmPcdKg));
23411 + if (!p_FmPcdKg)
23412 + {
23413 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Keygen allocation FAILED"));
23414 + return NULL;
23415 + }
23416 + memset(p_FmPcdKg, 0, sizeof(t_FmPcdKg));
23417 +
23418 +
23419 + if (FmIsMaster(p_FmPcd->h_Fm))
23420 + {
23421 + p_FmPcdKg->p_FmPcdKgRegs = (struct fman_kg_regs *)UINT_TO_PTR(FmGetPcdKgBaseAddr(p_FmPcdParams->h_Fm));
23422 + p_FmPcd->exceptions |= DEFAULT_fmPcdKgErrorExceptions;
23423 + p_FmPcdKg->p_IndirectAccessRegs = (u_FmPcdKgIndirectAccessRegs *)&p_FmPcdKg->p_FmPcdKgRegs->fmkg_indirect[0];
23424 + }
23425 +
23426 + p_FmPcdKg->numOfSchemes = p_FmPcdParams->numOfSchemes;
23427 + if ((p_FmPcd->guestId == NCSW_MASTER_ID) && !p_FmPcdKg->numOfSchemes)
23428 + {
23429 + p_FmPcdKg->numOfSchemes = FM_PCD_KG_NUM_OF_SCHEMES;
23430 + DBG(WARNING, ("numOfSchemes was defined 0 by user, re-defined by driver to FM_PCD_KG_NUM_OF_SCHEMES"));
23431 + }
23432 +
23433 + p_FmPcdKg->emptyClsPlanGrpId = ILLEGAL_CLS_PLAN;
23434 +
23435 + return p_FmPcdKg;
23436 +}
23437 +
23438 +t_Error KgInit(t_FmPcd *p_FmPcd)
23439 +{
23440 + t_Error err = E_OK;
23441 +
23442 + p_FmPcd->p_FmPcdKg->h_HwSpinlock = XX_InitSpinlock();
23443 + if (!p_FmPcd->p_FmPcdKg->h_HwSpinlock)
23444 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FM KG HW spinlock"));
23445 +
23446 + if (p_FmPcd->guestId == NCSW_MASTER_ID)
23447 + err = KgInitMaster(p_FmPcd);
23448 + else
23449 + err = KgInitGuest(p_FmPcd);
23450 +
23451 + if (err != E_OK)
23452 + {
23453 + if (p_FmPcd->p_FmPcdKg->h_HwSpinlock)
23454 + XX_FreeSpinlock(p_FmPcd->p_FmPcdKg->h_HwSpinlock);
23455 + }
23456 +
23457 + return err;
23458 +}
23459 +
23460 +t_Error KgFree(t_FmPcd *p_FmPcd)
23461 +{
23462 + t_FmPcdIpcKgSchemesParams kgAlloc;
23463 + t_Error err = E_OK;
23464 + t_FmPcdIpcMsg msg;
23465 + uint32_t replyLength;
23466 + t_FmPcdIpcReply reply;
23467 +
23468 + FmUnregisterIntr(p_FmPcd->h_Fm, e_FM_MOD_KG, 0, e_FM_INTR_TYPE_ERR);
23469 +
23470 + if (p_FmPcd->guestId == NCSW_MASTER_ID)
23471 + {
23472 + err = FmPcdKgFreeSchemes(p_FmPcd,
23473 + p_FmPcd->p_FmPcdKg->numOfSchemes,
23474 + p_FmPcd->guestId,
23475 + p_FmPcd->p_FmPcdKg->schemesIds);
23476 + if (err)
23477 + RETURN_ERROR(MAJOR, err, NO_MSG);
23478 +
23479 + if (p_FmPcd->p_FmPcdKg->h_HwSpinlock)
23480 + XX_FreeSpinlock(p_FmPcd->p_FmPcdKg->h_HwSpinlock);
23481 +
23482 + return E_OK;
23483 + }
23484 +
23485 + /* guest */
23486 + memset(&reply, 0, sizeof(reply));
23487 + memset(&msg, 0, sizeof(msg));
23488 + kgAlloc.numOfSchemes = p_FmPcd->p_FmPcdKg->numOfSchemes;
23489 + kgAlloc.guestId = p_FmPcd->guestId;
23490 + ASSERT_COND(kgAlloc.numOfSchemes < FM_PCD_KG_NUM_OF_SCHEMES);
23491 + memcpy(kgAlloc.schemesIds, p_FmPcd->p_FmPcdKg->schemesIds, (sizeof(uint8_t))*kgAlloc.numOfSchemes);
23492 + msg.msgId = FM_PCD_FREE_KG_SCHEMES;
23493 + memcpy(msg.msgBody, &kgAlloc, sizeof(kgAlloc));
23494 + replyLength = sizeof(uint32_t);
23495 + if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
23496 + (uint8_t*)&msg,
23497 + sizeof(msg.msgId) + sizeof(kgAlloc),
23498 + (uint8_t*)&reply,
23499 + &replyLength,
23500 + NULL,
23501 + NULL)) != E_OK)
23502 + RETURN_ERROR(MAJOR, err, NO_MSG);
23503 + if (replyLength != sizeof(uint32_t))
23504 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
23505 +
23506 + if (p_FmPcd->p_FmPcdKg->h_HwSpinlock)
23507 + XX_FreeSpinlock(p_FmPcd->p_FmPcdKg->h_HwSpinlock);
23508 +
23509 + return (t_Error)reply.error;
23510 +}
23511 +
23512 +t_Error FmPcdKgSetOrBindToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t netEnvId, protocolOpt_t *p_OptArray, uint8_t *p_ClsPlanGrpId, bool *p_IsEmptyClsPlanGrp)
23513 +{
23514 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
23515 + t_FmPcdKgInterModuleClsPlanGrpParams grpParams, *p_GrpParams;
23516 + t_FmPcdKgClsPlanGrp *p_ClsPlanGrp;
23517 + t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet;
23518 + t_Error err;
23519 +
23520 + /* This function is issued only from FM_PORT_SetPcd which locked all PCD modules,
23521 + so no need for lock here */
23522 +
23523 + memset(&grpParams, 0, sizeof(grpParams));
23524 + grpParams.clsPlanGrpId = ILLEGAL_CLS_PLAN;
23525 + p_GrpParams = &grpParams;
23526 +
23527 + p_GrpParams->netEnvId = netEnvId;
23528 +
23529 + /* Get from the NetEnv the information of the clsPlan (can be already created,
23530 + * or needs to build) */
23531 + err = PcdGetClsPlanGrpParams(h_FmPcd, p_GrpParams);
23532 + if (err)
23533 + RETURN_ERROR(MINOR,err,NO_MSG);
23534 +
23535 + if (p_GrpParams->grpExists)
23536 + {
23537 + /* this group was already updated (at least) in SW */
23538 + *p_ClsPlanGrpId = p_GrpParams->clsPlanGrpId;
23539 + }
23540 + else
23541 + {
23542 + p_ClsPlanSet = (t_FmPcdKgInterModuleClsPlanSet *)XX_Malloc(sizeof(t_FmPcdKgInterModuleClsPlanSet));
23543 + if (!p_ClsPlanSet)
23544 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Classification plan set"));
23545 + memset(p_ClsPlanSet, 0, sizeof(t_FmPcdKgInterModuleClsPlanSet));
23546 + /* Build (in SW) the clsPlan parameters, including the vectors to be written to HW */
23547 + err = FmPcdKgBuildClsPlanGrp(h_FmPcd, p_GrpParams, p_ClsPlanSet);
23548 + if (err)
23549 + {
23550 + XX_Free(p_ClsPlanSet);
23551 + RETURN_ERROR(MINOR, err, NO_MSG);
23552 + }
23553 + *p_ClsPlanGrpId = p_GrpParams->clsPlanGrpId;
23554 +
23555 + if (p_FmPcd->h_Hc)
23556 + {
23557 + /* write clsPlan entries to memory */
23558 + err = FmHcPcdKgSetClsPlan(p_FmPcd->h_Hc, p_ClsPlanSet);
23559 + if (err)
23560 + {
23561 + XX_Free(p_ClsPlanSet);
23562 + RETURN_ERROR(MAJOR, err, NO_MSG);
23563 + }
23564 + }
23565 + else
23566 + /* write clsPlan entries to memory */
23567 + KgSetClsPlan(p_FmPcd, p_ClsPlanSet);
23568 +
23569 + XX_Free(p_ClsPlanSet);
23570 + }
23571 +
23572 + /* Set caller parameters */
23573 +
23574 + /* mark if this is an empty classification group */
23575 + if (*p_ClsPlanGrpId == p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId)
23576 + *p_IsEmptyClsPlanGrp = TRUE;
23577 + else
23578 + *p_IsEmptyClsPlanGrp = FALSE;
23579 +
23580 + p_ClsPlanGrp = &p_FmPcd->p_FmPcdKg->clsPlanGrps[*p_ClsPlanGrpId];
23581 +
23582 + /* increment owners number */
23583 + p_ClsPlanGrp->owners++;
23584 +
23585 + /* copy options array for port */
23586 + memcpy(p_OptArray, &p_FmPcd->p_FmPcdKg->clsPlanGrps[*p_ClsPlanGrpId].optArray, FM_PCD_MAX_NUM_OF_OPTIONS(FM_PCD_MAX_NUM_OF_CLS_PLANS)*sizeof(protocolOpt_t));
23587 +
23588 + /* bind port to the new or existing group */
23589 + err = BindPortToClsPlanGrp(p_FmPcd, hardwarePortId, p_GrpParams->clsPlanGrpId);
23590 + if (err)
23591 + RETURN_ERROR(MINOR, err, NO_MSG);
23592 +
23593 + return E_OK;
23594 +}
23595 +
23596 +t_Error FmPcdKgDeleteOrUnbindPortToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t clsPlanGrpId)
23597 +{
23598 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
23599 + t_FmPcdKgClsPlanGrp *p_ClsPlanGrp = &p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId];
23600 + t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet;
23601 + t_Error err;
23602 +
23603 + /* This function is issued only from FM_PORT_DeletePcd which locked all PCD modules,
23604 + so no need for lock here */
23605 +
23606 + UnbindPortToClsPlanGrp(p_FmPcd, hardwarePortId);
23607 +
23608 + /* decrement owners number */
23609 + ASSERT_COND(p_ClsPlanGrp->owners);
23610 + p_ClsPlanGrp->owners--;
23611 +
23612 + if (!p_ClsPlanGrp->owners)
23613 + {
23614 + if (p_FmPcd->h_Hc)
23615 + {
23616 + err = FmHcPcdKgDeleteClsPlan(p_FmPcd->h_Hc, clsPlanGrpId);
23617 + return err;
23618 + }
23619 + else
23620 + {
23621 + /* clear clsPlan entries in memory */
23622 + p_ClsPlanSet = (t_FmPcdKgInterModuleClsPlanSet *)XX_Malloc(sizeof(t_FmPcdKgInterModuleClsPlanSet));
23623 + if (!p_ClsPlanSet)
23624 + {
23625 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Classification plan set"));
23626 + }
23627 + memset(p_ClsPlanSet, 0, sizeof(t_FmPcdKgInterModuleClsPlanSet));
23628 +
23629 + p_ClsPlanSet->baseEntry = p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId].baseEntry;
23630 + p_ClsPlanSet->numOfClsPlanEntries = p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId].sizeOfGrp;
23631 + KgSetClsPlan(p_FmPcd, p_ClsPlanSet);
23632 + XX_Free(p_ClsPlanSet);
23633 +
23634 + FmPcdKgDestroyClsPlanGrp(h_FmPcd, clsPlanGrpId);
23635 + }
23636 + }
23637 + return E_OK;
23638 +}
23639 +
23640 +uint32_t FmPcdKgGetRequiredAction(t_Handle h_FmPcd, uint8_t schemeId)
23641 +{
23642 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23643 + ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
23644 +
23645 + return p_FmPcd->p_FmPcdKg->schemes[schemeId].requiredAction;
23646 +}
23647 +
23648 +uint32_t FmPcdKgGetRequiredActionFlag(t_Handle h_FmPcd, uint8_t schemeId)
23649 +{
23650 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23651 +
23652 + ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
23653 +
23654 + return p_FmPcd->p_FmPcdKg->schemes[schemeId].requiredActionFlag;
23655 +}
23656 +
23657 +bool FmPcdKgIsDirectPlcr(t_Handle h_FmPcd, uint8_t schemeId)
23658 +{
23659 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23660 +
23661 + ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
23662 +
23663 + return p_FmPcd->p_FmPcdKg->schemes[schemeId].directPlcr;
23664 +}
23665 +
23666 +
23667 +uint16_t FmPcdKgGetRelativeProfileId(t_Handle h_FmPcd, uint8_t schemeId)
23668 +{
23669 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23670 +
23671 + ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
23672 +
23673 + return p_FmPcd->p_FmPcdKg->schemes[schemeId].relativeProfileId;
23674 +}
23675 +
23676 +bool FmPcdKgIsDistrOnPlcrProfile(t_Handle h_FmPcd, uint8_t schemeId)
23677 +{
23678 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23679 +
23680 + ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
23681 +
23682 + if ((p_FmPcd->p_FmPcdKg->schemes[schemeId].extractedOrs &&
23683 + p_FmPcd->p_FmPcdKg->schemes[schemeId].bitOffsetInPlcrProfile) ||
23684 + p_FmPcd->p_FmPcdKg->schemes[schemeId].nextRelativePlcrProfile)
23685 + return TRUE;
23686 + else
23687 + return FALSE;
23688 +
23689 +}
23690 +
23691 +e_FmPcdEngine FmPcdKgGetNextEngine(t_Handle h_FmPcd, uint8_t relativeSchemeId)
23692 +{
23693 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23694 +
23695 + ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].valid);
23696 +
23697 + return p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].nextEngine;
23698 +}
23699 +
23700 +e_FmPcdDoneAction FmPcdKgGetDoneAction(t_Handle h_FmPcd, uint8_t schemeId)
23701 +{
23702 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23703 +
23704 + ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
23705 +
23706 + return p_FmPcd->p_FmPcdKg->schemes[schemeId].doneAction;
23707 +}
23708 +
23709 +void FmPcdKgUpdateRequiredAction(t_Handle h_Scheme, uint32_t requiredAction)
23710 +{
23711 + t_FmPcdKgScheme *p_Scheme = (t_FmPcdKgScheme *)h_Scheme;
23712 +
23713 + /* this routine is protected by calling routine */
23714 +
23715 + ASSERT_COND(p_Scheme->valid);
23716 +
23717 + p_Scheme->requiredAction |= requiredAction;
23718 +}
23719 +
23720 +bool FmPcdKgHwSchemeIsValid(uint32_t schemeModeReg)
23721 +{
23722 + return (bool)!!(schemeModeReg & KG_SCH_MODE_EN);
23723 +}
23724 +
23725 +uint32_t FmPcdKgBuildWriteSchemeActionReg(uint8_t schemeId, bool updateCounter)
23726 +{
23727 + return (uint32_t)(((uint32_t)schemeId << FM_PCD_KG_KGAR_NUM_SHIFT) |
23728 + FM_KG_KGAR_GO |
23729 + FM_KG_KGAR_WRITE |
23730 + FM_KG_KGAR_SEL_SCHEME_ENTRY |
23731 + DUMMY_PORT_ID |
23732 + (updateCounter ? FM_KG_KGAR_SCM_WSEL_UPDATE_CNT:0));
23733 +}
23734 +
23735 +uint32_t FmPcdKgBuildReadSchemeActionReg(uint8_t schemeId)
23736 +{
23737 + return (uint32_t)(((uint32_t)schemeId << FM_PCD_KG_KGAR_NUM_SHIFT) |
23738 + FM_KG_KGAR_GO |
23739 + FM_KG_KGAR_READ |
23740 + FM_KG_KGAR_SEL_SCHEME_ENTRY |
23741 + DUMMY_PORT_ID |
23742 + FM_KG_KGAR_SCM_WSEL_UPDATE_CNT);
23743 +
23744 +}
23745 +
23746 +uint32_t FmPcdKgBuildWriteClsPlanBlockActionReg(uint8_t grpId)
23747 +{
23748 + return (uint32_t)(FM_KG_KGAR_GO |
23749 + FM_KG_KGAR_WRITE |
23750 + FM_PCD_KG_KGAR_SEL_CLS_PLAN_ENTRY |
23751 + DUMMY_PORT_ID |
23752 + ((uint32_t)grpId << FM_PCD_KG_KGAR_NUM_SHIFT) |
23753 + FM_PCD_KG_KGAR_WSEL_MASK);
23754 +
23755 + /* if we ever want to write 1 by 1, use:
23756 + sel = (uint8_t)(0x01 << (7- (entryId % CLS_PLAN_NUM_PER_GRP)));
23757 + */
23758 +}
23759 +
23760 +uint32_t FmPcdKgBuildWritePortSchemeBindActionReg(uint8_t hardwarePortId)
23761 +{
23762 +
23763 + return (uint32_t)(FM_KG_KGAR_GO |
23764 + FM_KG_KGAR_WRITE |
23765 + FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
23766 + hardwarePortId |
23767 + FM_PCD_KG_KGAR_SEL_PORT_WSEL_SP);
23768 +}
23769 +
23770 +uint32_t FmPcdKgBuildReadPortSchemeBindActionReg(uint8_t hardwarePortId)
23771 +{
23772 +
23773 + return (uint32_t)(FM_KG_KGAR_GO |
23774 + FM_KG_KGAR_READ |
23775 + FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
23776 + hardwarePortId |
23777 + FM_PCD_KG_KGAR_SEL_PORT_WSEL_SP);
23778 +}
23779 +
23780 +uint32_t FmPcdKgBuildWritePortClsPlanBindActionReg(uint8_t hardwarePortId)
23781 +{
23782 +
23783 + return (uint32_t)(FM_KG_KGAR_GO |
23784 + FM_KG_KGAR_WRITE |
23785 + FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
23786 + hardwarePortId |
23787 + FM_PCD_KG_KGAR_SEL_PORT_WSEL_CPP);
23788 +}
23789 +
23790 +uint8_t FmPcdKgGetClsPlanGrpBase(t_Handle h_FmPcd, uint8_t clsPlanGrp)
23791 +{
23792 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23793 +
23794 + return p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrp].baseEntry;
23795 +}
23796 +
23797 +uint16_t FmPcdKgGetClsPlanGrpSize(t_Handle h_FmPcd, uint8_t clsPlanGrp)
23798 +{
23799 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23800 +
23801 + return p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrp].sizeOfGrp;
23802 +}
23803 +
23804 +
23805 +uint8_t FmPcdKgGetSchemeId(t_Handle h_Scheme)
23806 +{
23807 + return ((t_FmPcdKgScheme*)h_Scheme)->schemeId;
23808 +
23809 +}
23810 +
23811 +#if (DPAA_VERSION >= 11)
23812 +bool FmPcdKgGetVspe(t_Handle h_Scheme)
23813 +{
23814 + return ((t_FmPcdKgScheme*)h_Scheme)->vspe;
23815 +
23816 +}
23817 +#endif /* (DPAA_VERSION >= 11) */
23818 +
23819 +uint8_t FmPcdKgGetRelativeSchemeId(t_Handle h_FmPcd, uint8_t schemeId)
23820 +{
23821 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23822 + uint8_t i;
23823 +
23824 + for (i = 0;i<p_FmPcd->p_FmPcdKg->numOfSchemes;i++)
23825 + if (p_FmPcd->p_FmPcdKg->schemesIds[i] == schemeId)
23826 + return i;
23827 +
23828 + if (i == p_FmPcd->p_FmPcdKg->numOfSchemes)
23829 + REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, ("Scheme is out of partition range"));
23830 +
23831 + return FM_PCD_KG_NUM_OF_SCHEMES;
23832 +}
23833 +
23834 +t_Handle FmPcdKgGetSchemeHandle(t_Handle h_FmPcd, uint8_t relativeSchemeId)
23835 +{
23836 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23837 +
23838 + ASSERT_COND(p_FmPcd);
23839 +
23840 + /* check that schemeId is in range */
23841 + if (relativeSchemeId >= p_FmPcd->p_FmPcdKg->numOfSchemes)
23842 + {
23843 + REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, ("relative-scheme-id %d!", relativeSchemeId));
23844 + return NULL;
23845 + }
23846 +
23847 + if (!FmPcdKgIsSchemeValidSw(&p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId]))
23848 + return NULL;
23849 +
23850 + return &p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId];
23851 +}
23852 +
23853 +bool FmPcdKgIsSchemeHasOwners(t_Handle h_Scheme)
23854 +{
23855 + return (((t_FmPcdKgScheme*)h_Scheme)->owners == 0)?FALSE:TRUE;
23856 +}
23857 +
23858 +t_Error FmPcdKgCcGetSetParams(t_Handle h_FmPcd, t_Handle h_Scheme, uint32_t requiredAction, uint32_t value)
23859 +{
23860 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
23861 + uint8_t relativeSchemeId, physicalSchemeId;
23862 + uint32_t tmpKgarReg, tmpReg32 = 0, intFlags;
23863 + t_Error err;
23864 + t_FmPcdKgScheme *p_Scheme = (t_FmPcdKgScheme*)h_Scheme;
23865 +
23866 + SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, 0);
23867 + SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE, 0);
23868 + SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE, 0);
23869 +
23870 + /* Calling function locked all PCD modules, so no need to lock here */
23871 +
23872 + if (!FmPcdKgIsSchemeValidSw(h_Scheme))
23873 + RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, ("Scheme is Invalid"));
23874 +
23875 + if (p_FmPcd->h_Hc)
23876 + {
23877 + err = FmHcPcdKgCcGetSetParams(p_FmPcd->h_Hc, h_Scheme, requiredAction, value);
23878 +
23879 + UpdateRequiredActionFlag(h_Scheme,TRUE);
23880 + FmPcdKgUpdateRequiredAction(h_Scheme,requiredAction);
23881 + return err;
23882 + }
23883 +
23884 + physicalSchemeId = p_Scheme->schemeId;
23885 +
23886 + relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, physicalSchemeId);
23887 + if (relativeSchemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
23888 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
23889 +
23890 + if (!p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].requiredActionFlag ||
23891 + !(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].requiredAction & requiredAction))
23892 + {
23893 + if (requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
23894 + {
23895 + switch (p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].nextEngine)
23896 + {
23897 + case (e_FM_PCD_DONE):
23898 + if (p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].doneAction == e_FM_PCD_ENQ_FRAME)
23899 + {
23900 + tmpKgarReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
23901 + intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
23902 + WriteKgarWait(p_FmPcd, tmpKgarReg);
23903 + tmpReg32 = GET_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode);
23904 + ASSERT_COND(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME));
23905 + WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode, tmpReg32 | NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA);
23906 + /* call indirect command for scheme write */
23907 + tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, FALSE);
23908 + WriteKgarWait(p_FmPcd, tmpKgarReg);
23909 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
23910 + }
23911 + break;
23912 + case (e_FM_PCD_PLCR):
23913 + if (!p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].directPlcr ||
23914 + (p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].extractedOrs &&
23915 + p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].bitOffsetInPlcrProfile) ||
23916 + p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].nextRelativePlcrProfile)
23917 + {
23918 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("In this situation PP can not be with distribution and has to be shared"));
23919 + }
23920 + err = FmPcdPlcrCcGetSetParams(h_FmPcd, p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].relativeProfileId, requiredAction);
23921 + if (err)
23922 + {
23923 + RETURN_ERROR(MAJOR, err, NO_MSG);
23924 + }
23925 + break;
23926 + default:
23927 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,("in this situation the next engine after scheme can be or PLCR or ENQ_FRAME"));
23928 + }
23929 + }
23930 + if (requiredAction & UPDATE_KG_NIA_CC_WA)
23931 + {
23932 + if (p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].nextEngine == e_FM_PCD_CC)
23933 + {
23934 + tmpKgarReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
23935 + intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
23936 + WriteKgarWait(p_FmPcd, tmpKgarReg);
23937 + tmpReg32 = GET_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode);
23938 + ASSERT_COND(tmpReg32 & (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_CC));
23939 + tmpReg32 &= ~NIA_FM_CTL_AC_CC;
23940 + WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode, tmpReg32 | NIA_FM_CTL_AC_PRE_CC);
23941 + /* call indirect command for scheme write */
23942 + tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, FALSE);
23943 + WriteKgarWait(p_FmPcd, tmpKgarReg);
23944 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
23945 + }
23946 + }
23947 + if (requiredAction & UPDATE_KG_OPT_MODE)
23948 + {
23949 + tmpKgarReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
23950 + intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
23951 + WriteKgarWait(p_FmPcd, tmpKgarReg);
23952 + WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_om, value);
23953 + /* call indirect command for scheme write */
23954 + tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, FALSE);
23955 + WriteKgarWait(p_FmPcd, tmpKgarReg);
23956 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
23957 + }
23958 + if (requiredAction & UPDATE_KG_NIA)
23959 + {
23960 + tmpKgarReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
23961 + intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
23962 + WriteKgarWait(p_FmPcd, tmpKgarReg);
23963 + tmpReg32 = GET_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode);
23964 + tmpReg32 &= ~(NIA_ENG_MASK | NIA_AC_MASK);
23965 + tmpReg32 |= value;
23966 + WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode, tmpReg32);
23967 + /* call indirect command for scheme write */
23968 + tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, FALSE);
23969 + WriteKgarWait(p_FmPcd, tmpKgarReg);
23970 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
23971 + }
23972 + }
23973 +
23974 + UpdateRequiredActionFlag(h_Scheme, TRUE);
23975 + FmPcdKgUpdateRequiredAction(h_Scheme, requiredAction);
23976 +
23977 + return E_OK;
23978 +}
23979 +/*********************** End of inter-module routines ************************/
23980 +
23981 +
23982 +/****************************************/
23983 +/* API routines */
23984 +/****************************************/
23985 +
23986 +t_Handle FM_PCD_KgSchemeSet(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_SchemeParams)
23987 +{
23988 + t_FmPcd *p_FmPcd;
23989 + struct fman_kg_scheme_regs schemeRegs;
23990 + struct fman_kg_scheme_regs *p_MemRegs;
23991 + uint8_t i;
23992 + t_Error err = E_OK;
23993 + uint32_t tmpKgarReg;
23994 + uint32_t intFlags;
23995 + uint8_t physicalSchemeId, relativeSchemeId = 0;
23996 + t_FmPcdKgScheme *p_Scheme;
23997 +
23998 + if (p_SchemeParams->modify)
23999 + {
24000 + p_Scheme = (t_FmPcdKgScheme *)p_SchemeParams->id.h_Scheme;
24001 + p_FmPcd = p_Scheme->h_FmPcd;
24002 +
24003 + SANITY_CHECK_RETURN_VALUE(p_FmPcd, E_INVALID_HANDLE, NULL);
24004 + SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE, NULL);
24005 +
24006 + if (!FmPcdKgIsSchemeValidSw(p_Scheme))
24007 + {
24008 + REPORT_ERROR(MAJOR, E_ALREADY_EXISTS,
24009 + ("Scheme is invalid"));
24010 + return NULL;
24011 + }
24012 +
24013 + if (!KgSchemeFlagTryLock(p_Scheme))
24014 + {
24015 + DBG(TRACE, ("Scheme Try Lock - BUSY"));
24016 + /* Signal to caller BUSY condition */
24017 + p_SchemeParams->id.h_Scheme = NULL;
24018 + return NULL;
24019 + }
24020 + }
24021 + else
24022 + {
24023 + p_FmPcd = (t_FmPcd*)h_FmPcd;
24024 +
24025 + SANITY_CHECK_RETURN_VALUE(p_FmPcd, E_INVALID_HANDLE, NULL);
24026 + SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE, NULL);
24027 +
24028 + relativeSchemeId = p_SchemeParams->id.relativeSchemeId;
24029 + /* check that schemeId is in range */
24030 + if (relativeSchemeId >= p_FmPcd->p_FmPcdKg->numOfSchemes)
24031 + {
24032 + REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, ("relative-scheme-id %d!", relativeSchemeId));
24033 + return NULL;
24034 + }
24035 +
24036 + p_Scheme = &p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId];
24037 + if (FmPcdKgIsSchemeValidSw(p_Scheme))
24038 + {
24039 + REPORT_ERROR(MAJOR, E_ALREADY_EXISTS,
24040 + ("Scheme id (%d)!", relativeSchemeId));
24041 + return NULL;
24042 + }
24043 + /* Clear all fields, scheme may have beed previously used */
24044 + memset(p_Scheme, 0, sizeof(t_FmPcdKgScheme));
24045 +
24046 + p_Scheme->schemeId = p_FmPcd->p_FmPcdKg->schemesIds[relativeSchemeId];
24047 + p_Scheme->h_FmPcd = p_FmPcd;
24048 +
24049 + p_Scheme->p_Lock = FmPcdAcquireLock(p_FmPcd);
24050 + if (!p_Scheme->p_Lock)
24051 + REPORT_ERROR(MAJOR, E_NOT_AVAILABLE, ("FM KG Scheme lock obj!"));
24052 + }
24053 +
24054 + err = BuildSchemeRegs((t_Handle)p_Scheme, p_SchemeParams, &schemeRegs);
24055 + if (err)
24056 + {
24057 + REPORT_ERROR(MAJOR, err, NO_MSG);
24058 + if (p_SchemeParams->modify)
24059 + KgSchemeFlagUnlock(p_Scheme);
24060 + if (!p_SchemeParams->modify &&
24061 + p_Scheme->p_Lock)
24062 + FmPcdReleaseLock(p_FmPcd, p_Scheme->p_Lock);
24063 + return NULL;
24064 + }
24065 +
24066 + if (p_FmPcd->h_Hc)
24067 + {
24068 + err = FmHcPcdKgSetScheme(p_FmPcd->h_Hc,
24069 + (t_Handle)p_Scheme,
24070 + &schemeRegs,
24071 + p_SchemeParams->schemeCounter.update);
24072 + if (p_SchemeParams->modify)
24073 + KgSchemeFlagUnlock(p_Scheme);
24074 + if (err)
24075 + {
24076 + if (!p_SchemeParams->modify &&
24077 + p_Scheme->p_Lock)
24078 + FmPcdReleaseLock(p_FmPcd, p_Scheme->p_Lock);
24079 + return NULL;
24080 + }
24081 + if (!p_SchemeParams->modify)
24082 + ValidateSchemeSw(p_Scheme);
24083 + return (t_Handle)p_Scheme;
24084 + }
24085 +
24086 + physicalSchemeId = p_Scheme->schemeId;
24087 +
24088 + /* configure all 21 scheme registers */
24089 + p_MemRegs = &p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs;
24090 + intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
24091 + WRITE_UINT32(p_MemRegs->kgse_ppc, schemeRegs.kgse_ppc);
24092 + WRITE_UINT32(p_MemRegs->kgse_ccbs, schemeRegs.kgse_ccbs);
24093 + WRITE_UINT32(p_MemRegs->kgse_mode, schemeRegs.kgse_mode);
24094 + WRITE_UINT32(p_MemRegs->kgse_mv, schemeRegs.kgse_mv);
24095 + WRITE_UINT32(p_MemRegs->kgse_dv0, schemeRegs.kgse_dv0);
24096 + WRITE_UINT32(p_MemRegs->kgse_dv1, schemeRegs.kgse_dv1);
24097 + WRITE_UINT32(p_MemRegs->kgse_ekdv, schemeRegs.kgse_ekdv);
24098 + WRITE_UINT32(p_MemRegs->kgse_ekfc, schemeRegs.kgse_ekfc);
24099 + WRITE_UINT32(p_MemRegs->kgse_bmch, schemeRegs.kgse_bmch);
24100 + WRITE_UINT32(p_MemRegs->kgse_bmcl, schemeRegs.kgse_bmcl);
24101 + WRITE_UINT32(p_MemRegs->kgse_hc, schemeRegs.kgse_hc);
24102 + WRITE_UINT32(p_MemRegs->kgse_spc, schemeRegs.kgse_spc);
24103 + WRITE_UINT32(p_MemRegs->kgse_fqb, schemeRegs.kgse_fqb);
24104 + WRITE_UINT32(p_MemRegs->kgse_om, schemeRegs.kgse_om);
24105 + WRITE_UINT32(p_MemRegs->kgse_vsp, schemeRegs.kgse_vsp);
24106 + for (i=0 ; i<FM_KG_NUM_OF_GENERIC_REGS ; i++)
24107 + WRITE_UINT32(p_MemRegs->kgse_gec[i], schemeRegs.kgse_gec[i]);
24108 +
24109 + /* call indirect command for scheme write */
24110 + tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, p_SchemeParams->schemeCounter.update);
24111 +
24112 + WriteKgarWait(p_FmPcd, tmpKgarReg);
24113 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
24114 +
24115 + if (!p_SchemeParams->modify)
24116 + ValidateSchemeSw(p_Scheme);
24117 + else
24118 + KgSchemeFlagUnlock(p_Scheme);
24119 +
24120 + return (t_Handle)p_Scheme;
24121 +}
24122 +
24123 +t_Error FM_PCD_KgSchemeDelete(t_Handle h_Scheme)
24124 +{
24125 + t_FmPcd *p_FmPcd;
24126 + uint8_t physicalSchemeId;
24127 + uint32_t tmpKgarReg, intFlags;
24128 + t_Error err = E_OK;
24129 + t_FmPcdKgScheme *p_Scheme = (t_FmPcdKgScheme *)h_Scheme;
24130 +
24131 + SANITY_CHECK_RETURN_ERROR(h_Scheme, E_INVALID_HANDLE);
24132 +
24133 + p_FmPcd = (t_FmPcd*)(p_Scheme->h_FmPcd);
24134 +
24135 + UpdateRequiredActionFlag(h_Scheme, FALSE);
24136 +
24137 + /* check that no port is bound to this scheme */
24138 + err = InvalidateSchemeSw(h_Scheme);
24139 + if (err)
24140 + RETURN_ERROR(MINOR, err, NO_MSG);
24141 +
24142 + if (p_FmPcd->h_Hc)
24143 + {
24144 + err = FmHcPcdKgDeleteScheme(p_FmPcd->h_Hc, h_Scheme);
24145 + if (p_Scheme->p_Lock)
24146 + FmPcdReleaseLock(p_FmPcd, p_Scheme->p_Lock);
24147 + return err;
24148 + }
24149 +
24150 + physicalSchemeId = ((t_FmPcdKgScheme *)h_Scheme)->schemeId;
24151 +
24152 + intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
24153 + /* clear mode register, including enable bit */
24154 + WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode, 0);
24155 +
24156 + /* call indirect command for scheme write */
24157 + tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, FALSE);
24158 +
24159 + WriteKgarWait(p_FmPcd, tmpKgarReg);
24160 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
24161 +
24162 + if (p_Scheme->p_Lock)
24163 + FmPcdReleaseLock(p_FmPcd, p_Scheme->p_Lock);
24164 +
24165 + return E_OK;
24166 +}
24167 +
24168 +uint32_t FM_PCD_KgSchemeGetCounter(t_Handle h_Scheme)
24169 +{
24170 + t_FmPcd *p_FmPcd;
24171 + uint32_t tmpKgarReg, spc, intFlags;
24172 + uint8_t physicalSchemeId;
24173 +
24174 + SANITY_CHECK_RETURN_VALUE(h_Scheme, E_INVALID_HANDLE, 0);
24175 +
24176 + p_FmPcd = (t_FmPcd*)(((t_FmPcdKgScheme *)h_Scheme)->h_FmPcd);
24177 + if (p_FmPcd->h_Hc)
24178 + return FmHcPcdKgGetSchemeCounter(p_FmPcd->h_Hc, h_Scheme);
24179 +
24180 + physicalSchemeId = ((t_FmPcdKgScheme *)h_Scheme)->schemeId;
24181 +
24182 + if (FmPcdKgGetRelativeSchemeId(p_FmPcd, physicalSchemeId) == FM_PCD_KG_NUM_OF_SCHEMES)
24183 + REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
24184 +
24185 + tmpKgarReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
24186 + intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
24187 + WriteKgarWait(p_FmPcd, tmpKgarReg);
24188 + if (!(GET_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode) & KG_SCH_MODE_EN))
24189 + REPORT_ERROR(MAJOR, E_ALREADY_EXISTS, ("Scheme is Invalid"));
24190 + spc = GET_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_spc);
24191 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
24192 +
24193 + return spc;
24194 +}
24195 +
24196 +t_Error FM_PCD_KgSchemeSetCounter(t_Handle h_Scheme, uint32_t value)
24197 +{
24198 + t_FmPcd *p_FmPcd;
24199 + uint32_t tmpKgarReg, intFlags;
24200 + uint8_t physicalSchemeId;
24201 +
24202 + SANITY_CHECK_RETURN_VALUE(h_Scheme, E_INVALID_HANDLE, 0);
24203 +
24204 + p_FmPcd = (t_FmPcd*)(((t_FmPcdKgScheme *)h_Scheme)->h_FmPcd);
24205 +
24206 + if (!FmPcdKgIsSchemeValidSw(h_Scheme))
24207 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Requested scheme is invalid."));
24208 +
24209 + if (p_FmPcd->h_Hc)
24210 + return FmHcPcdKgSetSchemeCounter(p_FmPcd->h_Hc, h_Scheme, value);
24211 +
24212 + physicalSchemeId = ((t_FmPcdKgScheme *)h_Scheme)->schemeId;
24213 + /* check that schemeId is in range */
24214 + if (FmPcdKgGetRelativeSchemeId(p_FmPcd, physicalSchemeId) == FM_PCD_KG_NUM_OF_SCHEMES)
24215 + REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
24216 +
24217 + /* read specified scheme into scheme registers */
24218 + tmpKgarReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
24219 + intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
24220 + WriteKgarWait(p_FmPcd, tmpKgarReg);
24221 + if (!(GET_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode) & KG_SCH_MODE_EN))
24222 + {
24223 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
24224 + RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, ("Scheme is Invalid"));
24225 + }
24226 +
24227 + /* change counter value */
24228 + WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_spc, value);
24229 +
24230 + /* call indirect command for scheme write */
24231 + tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, TRUE);
24232 +
24233 + WriteKgarWait(p_FmPcd, tmpKgarReg);
24234 + KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
24235 +
24236 + return E_OK;
24237 +}
24238 +
24239 +t_Error FM_PCD_KgSetAdditionalDataAfterParsing(t_Handle h_FmPcd, uint8_t payloadOffset)
24240 +{
24241 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
24242 + struct fman_kg_regs *p_Regs;
24243 +
24244 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
24245 + SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_NULL_POINTER);
24246 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_NULL_POINTER);
24247 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs, E_NULL_POINTER);
24248 +
24249 + p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
24250 + if (!FmIsMaster(p_FmPcd->h_Fm))
24251 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_KgSetAdditionalDataAfterParsing - guest mode!"));
24252 +
24253 + WRITE_UINT32(p_Regs->fmkg_fdor,payloadOffset);
24254 +
24255 + return E_OK;
24256 +}
24257 +
24258 +t_Error FM_PCD_KgSetDfltValue(t_Handle h_FmPcd, uint8_t valueId, uint32_t value)
24259 +{
24260 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
24261 + struct fman_kg_regs *p_Regs;
24262 +
24263 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
24264 + SANITY_CHECK_RETURN_ERROR(((valueId == 0) || (valueId == 1)), E_INVALID_VALUE);
24265 + SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_NULL_POINTER);
24266 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_NULL_POINTER);
24267 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs, E_NULL_POINTER);
24268 +
24269 + p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
24270 +
24271 + if (!FmIsMaster(p_FmPcd->h_Fm))
24272 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_KgSetDfltValue - guest mode!"));
24273 +
24274 + if (valueId == 0)
24275 + WRITE_UINT32(p_Regs->fmkg_gdv0r,value);
24276 + else
24277 + WRITE_UINT32(p_Regs->fmkg_gdv1r,value);
24278 + return E_OK;
24279 +}
24280 --- /dev/null
24281 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.h
24282 @@ -0,0 +1,206 @@
24283 +/*
24284 + * Copyright 2008-2012 Freescale Semiconductor Inc.
24285 + *
24286 + * Redistribution and use in source and binary forms, with or without
24287 + * modification, are permitted provided that the following conditions are met:
24288 + * * Redistributions of source code must retain the above copyright
24289 + * notice, this list of conditions and the following disclaimer.
24290 + * * Redistributions in binary form must reproduce the above copyright
24291 + * notice, this list of conditions and the following disclaimer in the
24292 + * documentation and/or other materials provided with the distribution.
24293 + * * Neither the name of Freescale Semiconductor nor the
24294 + * names of its contributors may be used to endorse or promote products
24295 + * derived from this software without specific prior written permission.
24296 + *
24297 + *
24298 + * ALTERNATIVELY, this software may be distributed under the terms of the
24299 + * GNU General Public License ("GPL") as published by the Free Software
24300 + * Foundation, either version 2 of that License or (at your option) any
24301 + * later version.
24302 + *
24303 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24304 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24305 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24306 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
24307 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24308 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24309 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24310 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24311 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24312 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24313 + */
24314 +
24315 +
24316 +/******************************************************************************
24317 + @File fm_kg.h
24318 +
24319 + @Description FM KG private header
24320 +*//***************************************************************************/
24321 +#ifndef __FM_KG_H
24322 +#define __FM_KG_H
24323 +
24324 +#include "std_ext.h"
24325 +
24326 +/***********************************************************************/
24327 +/* Keygen defines */
24328 +/***********************************************************************/
24329 +/* maskes */
24330 +#if (DPAA_VERSION >= 11)
24331 +#define KG_SCH_VSP_SHIFT_MASK 0x0003f000
24332 +#define KG_SCH_OM_VSPE 0x00000001
24333 +#define KG_SCH_VSP_NO_KSP_EN 0x80000000
24334 +
24335 +#define MAX_SP_SHIFT 23
24336 +#define KG_SCH_VSP_MASK_SHIFT 12
24337 +#define KG_SCH_VSP_SHIFT 24
24338 +#endif /* (DPAA_VERSION >= 11) */
24339 +
24340 +typedef uint32_t t_KnownFieldsMasks;
24341 +#define KG_SCH_KN_PORT_ID 0x80000000
24342 +#define KG_SCH_KN_MACDST 0x40000000
24343 +#define KG_SCH_KN_MACSRC 0x20000000
24344 +#define KG_SCH_KN_TCI1 0x10000000
24345 +#define KG_SCH_KN_TCI2 0x08000000
24346 +#define KG_SCH_KN_ETYPE 0x04000000
24347 +#define KG_SCH_KN_PPPSID 0x02000000
24348 +#define KG_SCH_KN_PPPID 0x01000000
24349 +#define KG_SCH_KN_MPLS1 0x00800000
24350 +#define KG_SCH_KN_MPLS2 0x00400000
24351 +#define KG_SCH_KN_MPLS_LAST 0x00200000
24352 +#define KG_SCH_KN_IPSRC1 0x00100000
24353 +#define KG_SCH_KN_IPDST1 0x00080000
24354 +#define KG_SCH_KN_PTYPE1 0x00040000
24355 +#define KG_SCH_KN_IPTOS_TC1 0x00020000
24356 +#define KG_SCH_KN_IPV6FL1 0x00010000
24357 +#define KG_SCH_KN_IPSRC2 0x00008000
24358 +#define KG_SCH_KN_IPDST2 0x00004000
24359 +#define KG_SCH_KN_PTYPE2 0x00002000
24360 +#define KG_SCH_KN_IPTOS_TC2 0x00001000
24361 +#define KG_SCH_KN_IPV6FL2 0x00000800
24362 +#define KG_SCH_KN_GREPTYPE 0x00000400
24363 +#define KG_SCH_KN_IPSEC_SPI 0x00000200
24364 +#define KG_SCH_KN_IPSEC_NH 0x00000100
24365 +#define KG_SCH_KN_IPPID 0x00000080
24366 +#define KG_SCH_KN_L4PSRC 0x00000004
24367 +#define KG_SCH_KN_L4PDST 0x00000002
24368 +#define KG_SCH_KN_TFLG 0x00000001
24369 +
24370 +typedef uint8_t t_GenericCodes;
24371 +#define KG_SCH_GEN_SHIM1 0x70
24372 +#define KG_SCH_GEN_DEFAULT 0x10
24373 +#define KG_SCH_GEN_PARSE_RESULT_N_FQID 0x20
24374 +#define KG_SCH_GEN_START_OF_FRM 0x40
24375 +#define KG_SCH_GEN_SHIM2 0x71
24376 +#define KG_SCH_GEN_IP_PID_NO_V 0x72
24377 +#define KG_SCH_GEN_ETH 0x03
24378 +#define KG_SCH_GEN_ETH_NO_V 0x73
24379 +#define KG_SCH_GEN_SNAP 0x04
24380 +#define KG_SCH_GEN_SNAP_NO_V 0x74
24381 +#define KG_SCH_GEN_VLAN1 0x05
24382 +#define KG_SCH_GEN_VLAN1_NO_V 0x75
24383 +#define KG_SCH_GEN_VLAN2 0x06
24384 +#define KG_SCH_GEN_VLAN2_NO_V 0x76
24385 +#define KG_SCH_GEN_ETH_TYPE 0x07
24386 +#define KG_SCH_GEN_ETH_TYPE_NO_V 0x77
24387 +#define KG_SCH_GEN_PPP 0x08
24388 +#define KG_SCH_GEN_PPP_NO_V 0x78
24389 +#define KG_SCH_GEN_MPLS1 0x09
24390 +#define KG_SCH_GEN_MPLS2 0x19
24391 +#define KG_SCH_GEN_MPLS3 0x29
24392 +#define KG_SCH_GEN_MPLS1_NO_V 0x79
24393 +#define KG_SCH_GEN_MPLS_LAST 0x0a
24394 +#define KG_SCH_GEN_MPLS_LAST_NO_V 0x7a
24395 +#define KG_SCH_GEN_IPV4 0x0b
24396 +#define KG_SCH_GEN_IPV6 0x1b
24397 +#define KG_SCH_GEN_L3_NO_V 0x7b
24398 +#define KG_SCH_GEN_IPV4_TUNNELED 0x0c
24399 +#define KG_SCH_GEN_IPV6_TUNNELED 0x1c
24400 +#define KG_SCH_GEN_MIN_ENCAP 0x2c
24401 +#define KG_SCH_GEN_IP2_NO_V 0x7c
24402 +#define KG_SCH_GEN_GRE 0x0d
24403 +#define KG_SCH_GEN_GRE_NO_V 0x7d
24404 +#define KG_SCH_GEN_TCP 0x0e
24405 +#define KG_SCH_GEN_UDP 0x1e
24406 +#define KG_SCH_GEN_IPSEC_AH 0x2e
24407 +#define KG_SCH_GEN_SCTP 0x3e
24408 +#define KG_SCH_GEN_DCCP 0x4e
24409 +#define KG_SCH_GEN_IPSEC_ESP 0x6e
24410 +#define KG_SCH_GEN_L4_NO_V 0x7e
24411 +#define KG_SCH_GEN_NEXTHDR 0x7f
24412 +/* shifts */
24413 +#define KG_SCH_PP_SHIFT_HIGH_SHIFT 27
24414 +#define KG_SCH_PP_SHIFT_LOW_SHIFT 12
24415 +#define KG_SCH_PP_MASK_SHIFT 16
24416 +#define KG_SCH_MODE_CCOBASE_SHIFT 24
24417 +#define KG_SCH_DEF_MAC_ADDR_SHIFT 30
24418 +#define KG_SCH_DEF_TCI_SHIFT 28
24419 +#define KG_SCH_DEF_ENET_TYPE_SHIFT 26
24420 +#define KG_SCH_DEF_PPP_SESSION_ID_SHIFT 24
24421 +#define KG_SCH_DEF_PPP_PROTOCOL_ID_SHIFT 22
24422 +#define KG_SCH_DEF_MPLS_LABEL_SHIFT 20
24423 +#define KG_SCH_DEF_IP_ADDR_SHIFT 18
24424 +#define KG_SCH_DEF_PROTOCOL_TYPE_SHIFT 16
24425 +#define KG_SCH_DEF_IP_TOS_TC_SHIFT 14
24426 +#define KG_SCH_DEF_IPV6_FLOW_LABEL_SHIFT 12
24427 +#define KG_SCH_DEF_IPSEC_SPI_SHIFT 10
24428 +#define KG_SCH_DEF_L4_PORT_SHIFT 8
24429 +#define KG_SCH_DEF_TCP_FLAG_SHIFT 6
24430 +#define KG_SCH_HASH_CONFIG_SHIFT_SHIFT 24
24431 +#define KG_SCH_GEN_MASK_SHIFT 16
24432 +#define KG_SCH_GEN_HT_SHIFT 8
24433 +#define KG_SCH_GEN_SIZE_SHIFT 24
24434 +#define KG_SCH_GEN_DEF_SHIFT 29
24435 +#define FM_PCD_KG_KGAR_NUM_SHIFT 16
24436 +
24437 +/* others */
24438 +#define NUM_OF_SW_DEFAULTS 3
24439 +#define MAX_PP_SHIFT 23
24440 +#define MAX_KG_SCH_SIZE 16
24441 +#define MASK_FOR_GENERIC_BASE_ID 0x20
24442 +#define MAX_HASH_SHIFT 40
24443 +#define MAX_KG_SCH_FQID_BIT_OFFSET 31
24444 +#define MAX_KG_SCH_PP_BIT_OFFSET 15
24445 +#define MAX_DIST_FQID_SHIFT 23
24446 +
24447 +#define GET_MASK_SEL_SHIFT(shift,i) \
24448 +switch (i) { \
24449 + case (0):shift = 26;break; \
24450 + case (1):shift = 20;break; \
24451 + case (2):shift = 10;break; \
24452 + case (3):shift = 4;break; \
24453 + default: \
24454 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG); \
24455 +}
24456 +
24457 +#define GET_MASK_OFFSET_SHIFT(shift,i) \
24458 +switch (i) { \
24459 + case (0):shift = 16;break; \
24460 + case (1):shift = 0;break; \
24461 + case (2):shift = 28;break; \
24462 + case (3):shift = 24;break; \
24463 + default: \
24464 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG); \
24465 +}
24466 +
24467 +#define GET_MASK_SHIFT(shift,i) \
24468 +switch (i) { \
24469 + case (0):shift = 24;break; \
24470 + case (1):shift = 16;break; \
24471 + case (2):shift = 8;break; \
24472 + case (3):shift = 0;break; \
24473 + default: \
24474 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG); \
24475 +}
24476 +
24477 +/***********************************************************************/
24478 +/* Keygen defines */
24479 +/***********************************************************************/
24480 +
24481 +#define KG_DOUBLE_MEANING_REGS_OFFSET 0x100
24482 +#define NO_VALIDATION 0x70
24483 +#define KG_ACTION_REG_TO 1024
24484 +#define KG_MAX_PROFILE 255
24485 +#define SCHEME_ALWAYS_DIRECT 0xFFFFFFFF
24486 +
24487 +
24488 +#endif /* __FM_KG_H */
24489 --- /dev/null
24490 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_manip.c
24491 @@ -0,0 +1,5571 @@
24492 +/*
24493 + * Copyright 2008-2012 Freescale Semiconductor Inc.
24494 + *
24495 + * Redistribution and use in source and binary forms, with or without
24496 + * modification, are permitted provided that the following conditions are met:
24497 + * * Redistributions of source code must retain the above copyright
24498 + * notice, this list of conditions and the following disclaimer.
24499 + * * Redistributions in binary form must reproduce the above copyright
24500 + * notice, this list of conditions and the following disclaimer in the
24501 + * documentation and/or other materials provided with the distribution.
24502 + * * Neither the name of Freescale Semiconductor nor the
24503 + * names of its contributors may be used to endorse or promote products
24504 + * derived from this software without specific prior written permission.
24505 + *
24506 + *
24507 + * ALTERNATIVELY, this software may be distributed under the terms of the
24508 + * GNU General Public License ("GPL") as published by the Free Software
24509 + * Foundation, either version 2 of that License or (at your option) any
24510 + * later version.
24511 + *
24512 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24513 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24514 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24515 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
24516 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24517 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24518 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24519 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24520 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24521 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24522 + */
24523 +
24524 +
24525 +/******************************************************************************
24526 + @File fm_manip.c
24527 +
24528 + @Description FM PCD manip ...
24529 + *//***************************************************************************/
24530 +#include "std_ext.h"
24531 +#include "error_ext.h"
24532 +#include "string_ext.h"
24533 +#include "debug_ext.h"
24534 +#include "fm_pcd_ext.h"
24535 +#include "fm_port_ext.h"
24536 +#include "fm_muram_ext.h"
24537 +#include "memcpy_ext.h"
24538 +
24539 +#include "fm_common.h"
24540 +#include "fm_hc.h"
24541 +#include "fm_manip.h"
24542 +
24543 +/****************************************/
24544 +/* static functions */
24545 +/****************************************/
24546 +static t_Handle GetManipInfo(t_FmPcdManip *p_Manip, e_ManipInfo manipInfo)
24547 +{
24548 + t_FmPcdManip *p_CurManip = p_Manip;
24549 +
24550 + if (!MANIP_IS_UNIFIED(p_Manip))
24551 + p_CurManip = p_Manip;
24552 + else
24553 + {
24554 + /* go to first unified */
24555 + while (MANIP_IS_UNIFIED_NON_FIRST(p_CurManip))
24556 + p_CurManip = p_CurManip->h_PrevManip;
24557 + }
24558 +
24559 + switch (manipInfo)
24560 + {
24561 + case (e_MANIP_HMCT):
24562 + return p_CurManip->p_Hmct;
24563 + case (e_MANIP_HMTD):
24564 + return p_CurManip->h_Ad;
24565 + case (e_MANIP_HANDLER_TABLE_OWNER):
24566 + return (t_Handle)p_CurManip;
24567 + default:
24568 + return NULL;
24569 + }
24570 +}
24571 +
24572 +static uint16_t GetHmctSize(t_FmPcdManip *p_Manip)
24573 +{
24574 + uint16_t size = 0;
24575 + t_FmPcdManip *p_CurManip = p_Manip;
24576 +
24577 + if (!MANIP_IS_UNIFIED(p_Manip))
24578 + return p_Manip->tableSize;
24579 +
24580 + /* accumulate sizes, starting with the first node */
24581 + while (MANIP_IS_UNIFIED_NON_FIRST(p_CurManip))
24582 + p_CurManip = p_CurManip->h_PrevManip;
24583 +
24584 + while (MANIP_IS_UNIFIED_NON_LAST(p_CurManip))
24585 + {
24586 + size += p_CurManip->tableSize;
24587 + p_CurManip = (t_FmPcdManip *)p_CurManip->h_NextManip;
24588 + }
24589 + size += p_CurManip->tableSize; /* add last size */
24590 +
24591 + return (size);
24592 +}
24593 +
24594 +static uint16_t GetDataSize(t_FmPcdManip *p_Manip)
24595 +{
24596 + uint16_t size = 0;
24597 + t_FmPcdManip *p_CurManip = p_Manip;
24598 +
24599 + if (!MANIP_IS_UNIFIED(p_Manip))
24600 + return p_Manip->dataSize;
24601 +
24602 + /* accumulate sizes, starting with the first node */
24603 + while (MANIP_IS_UNIFIED_NON_FIRST(p_CurManip))
24604 + p_CurManip = p_CurManip->h_PrevManip;
24605 +
24606 + while (MANIP_IS_UNIFIED_NON_LAST(p_CurManip))
24607 + {
24608 + size += p_CurManip->dataSize;
24609 + p_CurManip = (t_FmPcdManip *)p_CurManip->h_NextManip;
24610 + }
24611 + size += p_CurManip->dataSize; /* add last size */
24612 +
24613 + return (size);
24614 +}
24615 +
24616 +static t_Error CalculateTableSize(t_FmPcdManipParams *p_FmPcdManipParams,
24617 + uint16_t *p_TableSize, uint8_t *p_DataSize)
24618 +{
24619 + uint8_t localDataSize, remain, tableSize = 0, dataSize = 0;
24620 +
24621 + if (p_FmPcdManipParams->u.hdr.rmv)
24622 + {
24623 + switch (p_FmPcdManipParams->u.hdr.rmvParams.type)
24624 + {
24625 + case (e_FM_PCD_MANIP_RMV_GENERIC):
24626 + tableSize += HMCD_BASIC_SIZE;
24627 + break;
24628 + case (e_FM_PCD_MANIP_RMV_BY_HDR):
24629 + switch (p_FmPcdManipParams->u.hdr.rmvParams.u.byHdr.type)
24630 + {
24631 + case (e_FM_PCD_MANIP_RMV_BY_HDR_SPECIFIC_L2):
24632 +#if (DPAA_VERSION >= 11)
24633 + case (e_FM_PCD_MANIP_RMV_BY_HDR_CAPWAP):
24634 + case (e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START):
24635 +#endif /* (DPAA_VERSION >= 11) */
24636 + tableSize += HMCD_BASIC_SIZE;
24637 + break;
24638 + default:
24639 + RETURN_ERROR(MINOR, E_INVALID_SELECTION,
24640 + ("Unknown byHdr.type"));
24641 + }
24642 + break;
24643 + default:
24644 + RETURN_ERROR(MINOR, E_INVALID_SELECTION,
24645 + ("Unknown rmvParams.type"));
24646 + }
24647 + }
24648 +
24649 + if (p_FmPcdManipParams->u.hdr.insrt)
24650 + {
24651 + switch (p_FmPcdManipParams->u.hdr.insrtParams.type)
24652 + {
24653 + case (e_FM_PCD_MANIP_INSRT_GENERIC):
24654 + remain =
24655 + (uint8_t)(p_FmPcdManipParams->u.hdr.insrtParams.u.generic.size
24656 + % 4);
24657 + if (remain)
24658 + localDataSize =
24659 + (uint8_t)(p_FmPcdManipParams->u.hdr.insrtParams.u.generic.size
24660 + + 4 - remain);
24661 + else
24662 + localDataSize =
24663 + p_FmPcdManipParams->u.hdr.insrtParams.u.generic.size;
24664 + tableSize += (uint8_t)(HMCD_BASIC_SIZE + localDataSize);
24665 + break;
24666 + case (e_FM_PCD_MANIP_INSRT_BY_HDR):
24667 + {
24668 + switch (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.type)
24669 + {
24670 +
24671 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2):
24672 + tableSize += HMCD_BASIC_SIZE + HMCD_PTR_SIZE;
24673 + switch (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.specificL2Params.specificL2)
24674 + {
24675 + case (e_FM_PCD_MANIP_HDR_INSRT_MPLS):
24676 + case (e_FM_PCD_MANIP_HDR_INSRT_PPPOE):
24677 + dataSize +=
24678 + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.specificL2Params.size;
24679 + break;
24680 + default:
24681 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
24682 + }
24683 + break;
24684 +#if (DPAA_VERSION >= 11)
24685 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_IP):
24686 + tableSize +=
24687 + (HMCD_BASIC_SIZE + HMCD_PTR_SIZE
24688 + + HMCD_PARAM_SIZE
24689 + + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.insrt.size);
24690 + dataSize += 2;
24691 + break;
24692 +
24693 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP):
24694 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE):
24695 + tableSize += (HMCD_BASIC_SIZE + HMCD_L4_HDR_SIZE);
24696 +
24697 + break;
24698 +
24699 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP):
24700 + tableSize +=
24701 + (HMCD_BASIC_SIZE
24702 + + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size);
24703 + break;
24704 +#endif /* (DPAA_VERSION >= 11) */
24705 + default:
24706 + RETURN_ERROR(MINOR, E_INVALID_SELECTION,
24707 + ("Unknown byHdr.type"));
24708 + }
24709 + }
24710 + break;
24711 + default:
24712 + RETURN_ERROR(MINOR, E_INVALID_SELECTION,
24713 + ("Unknown insrtParams.type"));
24714 + }
24715 + }
24716 +
24717 + if (p_FmPcdManipParams->u.hdr.fieldUpdate)
24718 + {
24719 + switch (p_FmPcdManipParams->u.hdr.fieldUpdateParams.type)
24720 + {
24721 + case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN):
24722 + tableSize += HMCD_BASIC_SIZE;
24723 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.vlan.updateType
24724 + == e_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN)
24725 + {
24726 + tableSize += HMCD_PTR_SIZE;
24727 + dataSize += DSCP_TO_VLAN_TABLE_SIZE;
24728 + }
24729 + break;
24730 + case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV4):
24731 + tableSize += HMCD_BASIC_SIZE;
24732 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
24733 + & HDR_MANIP_IPV4_ID)
24734 + {
24735 + tableSize += HMCD_PARAM_SIZE;
24736 + dataSize += 2;
24737 + }
24738 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
24739 + & HDR_MANIP_IPV4_SRC)
24740 + tableSize += HMCD_IPV4_ADDR_SIZE;
24741 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
24742 + & HDR_MANIP_IPV4_DST)
24743 + tableSize += HMCD_IPV4_ADDR_SIZE;
24744 + break;
24745 + case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV6):
24746 + tableSize += HMCD_BASIC_SIZE;
24747 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
24748 + & HDR_MANIP_IPV6_SRC)
24749 + tableSize += HMCD_IPV6_ADDR_SIZE;
24750 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
24751 + & HDR_MANIP_IPV6_DST)
24752 + tableSize += HMCD_IPV6_ADDR_SIZE;
24753 + break;
24754 + case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_TCP_UDP):
24755 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.validUpdates
24756 + == HDR_MANIP_TCP_UDP_CHECKSUM)
24757 + /* we implement this case with the update-checksum descriptor */
24758 + tableSize += HMCD_BASIC_SIZE;
24759 + else
24760 + /* we implement this case with the TCP/UDP-update descriptor */
24761 + tableSize += HMCD_BASIC_SIZE + HMCD_PARAM_SIZE;
24762 + break;
24763 + default:
24764 + RETURN_ERROR(MINOR, E_INVALID_SELECTION,
24765 + ("Unknown fieldUpdateParams.type"));
24766 + }
24767 + }
24768 +
24769 + if (p_FmPcdManipParams->u.hdr.custom)
24770 + {
24771 + switch (p_FmPcdManipParams->u.hdr.customParams.type)
24772 + {
24773 + case (e_FM_PCD_MANIP_HDR_CUSTOM_IP_REPLACE):
24774 + {
24775 + tableSize += HMCD_BASIC_SIZE + HMCD_PARAM_SIZE + HMCD_PARAM_SIZE;
24776 + dataSize +=
24777 + p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.hdrSize;
24778 + if ((p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.replaceType
24779 + == e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4)
24780 + && (p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.updateIpv4Id))
24781 + dataSize += 2;
24782 + }
24783 + break;
24784 + case (e_FM_PCD_MANIP_HDR_CUSTOM_GEN_FIELD_REPLACE):
24785 + tableSize += HMCD_BASIC_SIZE + HMCD_PARAM_SIZE;
24786 + break;
24787 + default:
24788 + RETURN_ERROR(MINOR, E_INVALID_SELECTION,
24789 + ("Unknown customParams.type"));
24790 + }
24791 + }
24792 +
24793 + *p_TableSize = tableSize;
24794 + *p_DataSize = dataSize;
24795 +
24796 + return E_OK;
24797 +}
24798 +
24799 +static t_Error GetPrOffsetByHeaderOrField(t_FmManipHdrInfo *p_HdrInfo,
24800 + uint8_t *parseArrayOffset)
24801 +{
24802 + e_NetHeaderType hdr = p_HdrInfo->hdr;
24803 + e_FmPcdHdrIndex hdrIndex = p_HdrInfo->hdrIndex;
24804 + bool byField = p_HdrInfo->byField;
24805 + t_FmPcdFields field;
24806 +
24807 + if (byField)
24808 + field = p_HdrInfo->fullField;
24809 +
24810 + if (byField)
24811 + {
24812 + switch (hdr)
24813 + {
24814 + case (HEADER_TYPE_ETH):
24815 + switch (field.eth)
24816 + {
24817 + case (NET_HEADER_FIELD_ETH_TYPE):
24818 + *parseArrayOffset = CC_PC_PR_ETYPE_LAST_OFFSET;
24819 + break;
24820 + default:
24821 + RETURN_ERROR(
24822 + MAJOR,
24823 + E_NOT_SUPPORTED,
24824 + ("Header manipulation of the type Ethernet with this field not supported"));
24825 + }
24826 + break;
24827 + case (HEADER_TYPE_VLAN):
24828 + switch (field.vlan)
24829 + {
24830 + case (NET_HEADER_FIELD_VLAN_TCI):
24831 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)
24832 + || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
24833 + *parseArrayOffset = CC_PC_PR_VLAN1_OFFSET;
24834 + else
24835 + if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
24836 + *parseArrayOffset = CC_PC_PR_VLAN2_OFFSET;
24837 + break;
24838 + default:
24839 + RETURN_ERROR(
24840 + MAJOR,
24841 + E_NOT_SUPPORTED,
24842 + ("Header manipulation of the type VLAN with this field not supported"));
24843 + }
24844 + break;
24845 + default:
24846 + RETURN_ERROR(
24847 + MAJOR,
24848 + E_NOT_SUPPORTED,
24849 + ("Header manipulation of this header by field not supported"));
24850 + }
24851 + }
24852 + else
24853 + {
24854 + switch (hdr)
24855 + {
24856 + case (HEADER_TYPE_ETH):
24857 + *parseArrayOffset = (uint8_t)CC_PC_PR_ETH_OFFSET;
24858 + break;
24859 + case (HEADER_TYPE_USER_DEFINED_SHIM1):
24860 + *parseArrayOffset = (uint8_t)CC_PC_PR_USER_DEFINED_SHIM1_OFFSET;
24861 + break;
24862 + case (HEADER_TYPE_USER_DEFINED_SHIM2):
24863 + *parseArrayOffset = (uint8_t)CC_PC_PR_USER_DEFINED_SHIM2_OFFSET;
24864 + break;
24865 + case (HEADER_TYPE_LLC_SNAP):
24866 + *parseArrayOffset = CC_PC_PR_USER_LLC_SNAP_OFFSET;
24867 + break;
24868 + case (HEADER_TYPE_PPPoE):
24869 + *parseArrayOffset = CC_PC_PR_PPPOE_OFFSET;
24870 + break;
24871 + case (HEADER_TYPE_MPLS):
24872 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)
24873 + || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
24874 + *parseArrayOffset = CC_PC_PR_MPLS1_OFFSET;
24875 + else
24876 + if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
24877 + *parseArrayOffset = CC_PC_PR_MPLS_LAST_OFFSET;
24878 + break;
24879 + case (HEADER_TYPE_IPv4):
24880 + case (HEADER_TYPE_IPv6):
24881 + if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)
24882 + || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
24883 + *parseArrayOffset = CC_PC_PR_IP1_OFFSET;
24884 + else
24885 + if (hdrIndex == e_FM_PCD_HDR_INDEX_2)
24886 + *parseArrayOffset = CC_PC_PR_IP_LAST_OFFSET;
24887 + break;
24888 + case (HEADER_TYPE_MINENCAP):
24889 + *parseArrayOffset = CC_PC_PR_MINENC_OFFSET;
24890 + break;
24891 + case (HEADER_TYPE_GRE):
24892 + *parseArrayOffset = CC_PC_PR_GRE_OFFSET;
24893 + break;
24894 + case (HEADER_TYPE_TCP):
24895 + case (HEADER_TYPE_UDP):
24896 + case (HEADER_TYPE_IPSEC_AH):
24897 + case (HEADER_TYPE_IPSEC_ESP):
24898 + case (HEADER_TYPE_DCCP):
24899 + case (HEADER_TYPE_SCTP):
24900 + *parseArrayOffset = CC_PC_PR_L4_OFFSET;
24901 + break;
24902 + case (HEADER_TYPE_CAPWAP):
24903 + case (HEADER_TYPE_CAPWAP_DTLS):
24904 + *parseArrayOffset = CC_PC_PR_NEXT_HEADER_OFFSET;
24905 + break;
24906 + default:
24907 + RETURN_ERROR(
24908 + MAJOR,
24909 + E_NOT_SUPPORTED,
24910 + ("Header manipulation of this header is not supported"));
24911 + }
24912 + }
24913 + return E_OK;
24914 +}
24915 +
24916 +static t_Error BuildHmct(t_FmPcdManip *p_Manip,
24917 + t_FmPcdManipParams *p_FmPcdManipParams,
24918 + uint8_t *p_DestHmct, uint8_t *p_DestData, bool new)
24919 +{
24920 + uint32_t *p_TmpHmct = (uint32_t*)p_DestHmct, *p_LocalData;
24921 + uint32_t tmpReg = 0, *p_Last = NULL, tmp_ipv6_addr;
24922 + uint8_t remain, i, size = 0, origSize, *p_UsrData = NULL, *p_TmpData =
24923 + p_DestData;
24924 + t_Handle h_FmPcd = p_Manip->h_FmPcd;
24925 + uint8_t j = 0;
24926 +
24927 + if (p_FmPcdManipParams->u.hdr.rmv)
24928 + {
24929 + if (p_FmPcdManipParams->u.hdr.rmvParams.type
24930 + == e_FM_PCD_MANIP_RMV_GENERIC)
24931 + {
24932 + /* initialize HMCD */
24933 + tmpReg = (uint32_t)(HMCD_OPCODE_GENERIC_RMV) << HMCD_OC_SHIFT;
24934 + /* tmp, should be conditional */
24935 + tmpReg |= p_FmPcdManipParams->u.hdr.rmvParams.u.generic.offset
24936 + << HMCD_RMV_OFFSET_SHIFT;
24937 + tmpReg |= p_FmPcdManipParams->u.hdr.rmvParams.u.generic.size
24938 + << HMCD_RMV_SIZE_SHIFT;
24939 + }
24940 + else
24941 + if (p_FmPcdManipParams->u.hdr.rmvParams.type
24942 + == e_FM_PCD_MANIP_RMV_BY_HDR)
24943 + {
24944 + switch (p_FmPcdManipParams->u.hdr.rmvParams.u.byHdr.type)
24945 + {
24946 + case (e_FM_PCD_MANIP_RMV_BY_HDR_SPECIFIC_L2):
24947 + {
24948 + uint8_t hmcdOpt;
24949 +
24950 + /* initialize HMCD */
24951 + tmpReg = (uint32_t)(HMCD_OPCODE_L2_RMV) << HMCD_OC_SHIFT;
24952 +
24953 + switch (p_FmPcdManipParams->u.hdr.rmvParams.u.byHdr.u.specificL2)
24954 + {
24955 + case (e_FM_PCD_MANIP_HDR_RMV_ETHERNET):
24956 + hmcdOpt = HMCD_RMV_L2_ETHERNET;
24957 + break;
24958 + case (e_FM_PCD_MANIP_HDR_RMV_STACKED_QTAGS):
24959 + hmcdOpt = HMCD_RMV_L2_STACKED_QTAGS;
24960 + break;
24961 + case (e_FM_PCD_MANIP_HDR_RMV_ETHERNET_AND_MPLS):
24962 + hmcdOpt = HMCD_RMV_L2_ETHERNET_AND_MPLS;
24963 + break;
24964 + case (e_FM_PCD_MANIP_HDR_RMV_MPLS):
24965 + hmcdOpt = HMCD_RMV_L2_MPLS;
24966 + break;
24967 + case (e_FM_PCD_MANIP_HDR_RMV_PPPOE):
24968 + hmcdOpt = HMCD_RMV_L2_PPPOE;
24969 + break;
24970 + default:
24971 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
24972 + }
24973 + tmpReg |= hmcdOpt << HMCD_L2_MODE_SHIFT;
24974 + break;
24975 + }
24976 +#if (DPAA_VERSION >= 11)
24977 + case (e_FM_PCD_MANIP_RMV_BY_HDR_CAPWAP):
24978 + tmpReg = (uint32_t)(HMCD_OPCODE_CAPWAP_RMV)
24979 + << HMCD_OC_SHIFT;
24980 + break;
24981 + case (e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START):
24982 + {
24983 + uint8_t prsArrayOffset;
24984 + t_Error err = E_OK;
24985 +
24986 + tmpReg = (uint32_t)(HMCD_OPCODE_RMV_TILL)
24987 + << HMCD_OC_SHIFT;
24988 +
24989 + err =
24990 + GetPrOffsetByHeaderOrField(
24991 + &p_FmPcdManipParams->u.hdr.rmvParams.u.byHdr.u.hdrInfo,
24992 + &prsArrayOffset);
24993 + ASSERT_COND(!err);
24994 + /* was previously checked */
24995 +
24996 + tmpReg |= ((uint32_t)prsArrayOffset << 16);
24997 + }
24998 + break;
24999 +#endif /* (DPAA_VERSION >= 11) */
25000 + default:
25001 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
25002 + ("manip header remove by hdr type!"));
25003 + }
25004 + }
25005 +
25006 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25007 + /* save a pointer to the "last" indication word */
25008 + p_Last = p_TmpHmct;
25009 + /* advance to next command */
25010 + p_TmpHmct += HMCD_BASIC_SIZE / 4;
25011 + }
25012 +
25013 + if (p_FmPcdManipParams->u.hdr.insrt)
25014 + {
25015 + if (p_FmPcdManipParams->u.hdr.insrtParams.type
25016 + == e_FM_PCD_MANIP_INSRT_GENERIC)
25017 + {
25018 + /* initialize HMCD */
25019 + if (p_FmPcdManipParams->u.hdr.insrtParams.u.generic.replace)
25020 + tmpReg = (uint32_t)(HMCD_OPCODE_GENERIC_REPLACE)
25021 + << HMCD_OC_SHIFT;
25022 + else
25023 + tmpReg = (uint32_t)(HMCD_OPCODE_GENERIC_INSRT) << HMCD_OC_SHIFT;
25024 +
25025 + tmpReg |= p_FmPcdManipParams->u.hdr.insrtParams.u.generic.offset
25026 + << HMCD_INSRT_OFFSET_SHIFT;
25027 + tmpReg |= p_FmPcdManipParams->u.hdr.insrtParams.u.generic.size
25028 + << HMCD_INSRT_SIZE_SHIFT;
25029 +
25030 + size = p_FmPcdManipParams->u.hdr.insrtParams.u.generic.size;
25031 + p_UsrData = p_FmPcdManipParams->u.hdr.insrtParams.u.generic.p_Data;
25032 +
25033 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25034 + /* save a pointer to the "last" indication word */
25035 + p_Last = p_TmpHmct;
25036 +
25037 + p_TmpHmct += HMCD_BASIC_SIZE / 4;
25038 +
25039 + /* initialize data to be inserted */
25040 + /* if size is not a multiple of 4, padd with 0's */
25041 + origSize = size;
25042 + remain = (uint8_t)(size % 4);
25043 + if (remain)
25044 + {
25045 + size += (uint8_t)(4 - remain);
25046 + p_LocalData = (uint32_t *)XX_Malloc(size);
25047 + memset((uint8_t *)p_LocalData, 0, size);
25048 + memcpy((uint8_t *)p_LocalData, p_UsrData, origSize);
25049 + }
25050 + else
25051 + p_LocalData = (uint32_t*)p_UsrData;
25052 +
25053 + /* initialize data and advance pointer to next command */
25054 + MemCpy8(p_TmpHmct, p_LocalData, size);
25055 + p_TmpHmct += size / sizeof(uint32_t);
25056 +
25057 + if (remain)
25058 + XX_Free(p_LocalData);
25059 + }
25060 +
25061 + else
25062 + if (p_FmPcdManipParams->u.hdr.insrtParams.type
25063 + == e_FM_PCD_MANIP_INSRT_BY_HDR)
25064 + {
25065 + switch (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.type)
25066 + {
25067 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2):
25068 + {
25069 + uint8_t hmcdOpt;
25070 +
25071 + /* initialize HMCD */
25072 + tmpReg = (uint32_t)(HMCD_OPCODE_L2_INSRT)
25073 + << HMCD_OC_SHIFT;
25074 +
25075 + switch (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.specificL2Params.specificL2)
25076 + {
25077 + case (e_FM_PCD_MANIP_HDR_INSRT_MPLS):
25078 + if (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.specificL2Params.update)
25079 + hmcdOpt = HMCD_INSRT_N_UPDATE_L2_MPLS;
25080 + else
25081 + hmcdOpt = HMCD_INSRT_L2_MPLS;
25082 + break;
25083 + case (e_FM_PCD_MANIP_HDR_INSRT_PPPOE):
25084 + hmcdOpt = HMCD_INSRT_L2_PPPOE;
25085 + break;
25086 + default:
25087 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
25088 + }
25089 + tmpReg |= hmcdOpt << HMCD_L2_MODE_SHIFT;
25090 +
25091 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25092 + /* save a pointer to the "last" indication word */
25093 + p_Last = p_TmpHmct;
25094 +
25095 + p_TmpHmct += HMCD_BASIC_SIZE / 4;
25096 +
25097 + /* set size and pointer of user's data */
25098 + size =
25099 + (uint8_t)p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.specificL2Params.size;
25100 +
25101 + ASSERT_COND(p_TmpData);
25102 + MemCpy8(
25103 + p_TmpData,
25104 + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.specificL2Params.p_Data,
25105 + size);
25106 + tmpReg =
25107 + (size << HMCD_INSRT_L2_SIZE_SHIFT)
25108 + | (uint32_t)(XX_VirtToPhys(p_TmpData)
25109 + - (((t_FmPcd*)h_FmPcd)->physicalMuramBase));
25110 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25111 + p_TmpHmct += HMCD_PTR_SIZE / 4;
25112 + p_TmpData += size;
25113 + }
25114 + break;
25115 +#if (DPAA_VERSION >= 11)
25116 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_IP):
25117 + tmpReg = (uint32_t)(HMCD_OPCODE_IP_INSRT)
25118 + << HMCD_OC_SHIFT;
25119 + if (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.calcL4Checksum)
25120 + tmpReg |= HMCD_IP_L4_CS_CALC;
25121 + if (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.mappingMode
25122 + == e_FM_PCD_MANIP_HDR_QOS_MAPPING_AS_IS)
25123 + tmpReg |= HMCD_IP_OR_QOS;
25124 + tmpReg |=
25125 + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.lastPidOffset
25126 + & HMCD_IP_LAST_PID_MASK;
25127 + tmpReg |=
25128 + ((p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.insrt.size
25129 + << HMCD_IP_SIZE_SHIFT)
25130 + & HMCD_IP_SIZE_MASK);
25131 + if (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.dontFragOverwrite)
25132 + tmpReg |= HMCD_IP_DF_MODE;
25133 +
25134 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25135 +
25136 + /* save a pointer to the "last" indication word */
25137 + p_Last = p_TmpHmct;
25138 +
25139 + p_TmpHmct += HMCD_BASIC_SIZE / 4;
25140 +
25141 + /* set IP id */
25142 + ASSERT_COND(p_TmpData);
25143 + WRITE_UINT16(
25144 + *(uint16_t*)p_TmpData,
25145 + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.id);
25146 + WRITE_UINT32(
25147 + *p_TmpHmct,
25148 + (uint32_t)(XX_VirtToPhys(p_TmpData) - (((t_FmPcd*)p_Manip->h_FmPcd)->physicalMuramBase)));
25149 + p_TmpData += 2;
25150 + p_TmpHmct += HMCD_PTR_SIZE / 4;
25151 +
25152 + WRITE_UINT8(*p_TmpHmct, p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.lastDstOffset);
25153 + p_TmpHmct += HMCD_PARAM_SIZE / 4;
25154 +
25155 + MemCpy8(
25156 + p_TmpHmct,
25157 + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.insrt.p_Data,
25158 + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.insrt.size);
25159 + p_TmpHmct +=
25160 + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.insrt.size
25161 + / 4;
25162 + break;
25163 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE):
25164 + tmpReg = HMCD_INSRT_UDP_LITE;
25165 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP):
25166 + tmpReg |= (uint32_t)(HMCD_OPCODE_UDP_INSRT)
25167 + << HMCD_OC_SHIFT;
25168 +
25169 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25170 +
25171 + /* save a pointer to the "last" indication word */
25172 + p_Last = p_TmpHmct;
25173 +
25174 + p_TmpHmct += HMCD_BASIC_SIZE / 4;
25175 +
25176 + MemCpy8(
25177 + p_TmpHmct,
25178 + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.p_Data,
25179 + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size);
25180 + p_TmpHmct +=
25181 + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size
25182 + / 4;
25183 + break;
25184 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP):
25185 + tmpReg = (uint32_t)(HMCD_OPCODE_CAPWAP_INSRT)
25186 + << HMCD_OC_SHIFT;
25187 + tmpReg |= HMCD_CAPWAP_INSRT;
25188 +
25189 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25190 +
25191 + /* save a pointer to the "last" indication word */
25192 + p_Last = p_TmpHmct;
25193 +
25194 + p_TmpHmct += HMCD_BASIC_SIZE / 4;
25195 +
25196 + MemCpy8(
25197 + p_TmpHmct,
25198 + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.p_Data,
25199 + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size);
25200 + p_TmpHmct +=
25201 + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size
25202 + / 4;
25203 + break;
25204 +#endif /* (DPAA_VERSION >= 11) */
25205 + default:
25206 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
25207 + ("manip header insert by header type!"));
25208 +
25209 + }
25210 + }
25211 + }
25212 +
25213 + if (p_FmPcdManipParams->u.hdr.fieldUpdate)
25214 + {
25215 + switch (p_FmPcdManipParams->u.hdr.fieldUpdateParams.type)
25216 + {
25217 + case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN):
25218 + /* set opcode */
25219 + tmpReg = (uint32_t)(HMCD_OPCODE_VLAN_PRI_UPDATE)
25220 + << HMCD_OC_SHIFT;
25221 +
25222 + /* set mode & table pointer */
25223 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.vlan.updateType
25224 + == e_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN)
25225 + {
25226 + /* set Mode */
25227 + tmpReg |= (uint32_t)(HMCD_VLAN_PRI_UPDATE_DSCP_TO_VPRI)
25228 + << HMCD_VLAN_PRI_REP_MODE_SHIFT;
25229 + /* set VPRI default */
25230 + tmpReg |=
25231 + p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.vlan.u.dscpToVpri.vpriDefVal;
25232 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25233 + /* save a pointer to the "last" indication word */
25234 + p_Last = p_TmpHmct;
25235 + /* write the table pointer into the Manip descriptor */
25236 + p_TmpHmct += HMCD_BASIC_SIZE / 4;
25237 +
25238 + tmpReg = 0;
25239 + ASSERT_COND(p_TmpData);
25240 + for (i = 0; i < HMCD_DSCP_VALUES; i++)
25241 + {
25242 + /* first we build from each 8 values a 32bit register */
25243 + tmpReg |=
25244 + (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.vlan.u.dscpToVpri.dscpToVpriTable[i])
25245 + << (32 - 4 * (j + 1));
25246 + j++;
25247 + /* Than we write this register to the next table word
25248 + * (i=7-->word 0, i=15-->word 1,... i=63-->word 7) */
25249 + if ((i % 8) == 7)
25250 + {
25251 + WRITE_UINT32(*((uint32_t*)p_TmpData + (i+1)/8-1),
25252 + tmpReg);
25253 + tmpReg = 0;
25254 + j = 0;
25255 + }
25256 + }
25257 +
25258 + WRITE_UINT32(
25259 + *p_TmpHmct,
25260 + (uint32_t)(XX_VirtToPhys(p_TmpData) - (((t_FmPcd*)h_FmPcd)->physicalMuramBase)));
25261 + p_TmpHmct += HMCD_PTR_SIZE / 4;
25262 +
25263 + p_TmpData += DSCP_TO_VLAN_TABLE_SIZE;
25264 + }
25265 + else
25266 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.vlan.updateType
25267 + == e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN_VPRI)
25268 + {
25269 + /* set Mode */
25270 + /* line commented out as it has no-side-effect ('0' value). */
25271 + /*tmpReg |= HMCD_VLAN_PRI_UPDATE << HMCD_VLAN_PRI_REP_MODE_SHIFT*/;
25272 + /* set VPRI parameter */
25273 + tmpReg |=
25274 + p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.vlan.u.vpri;
25275 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25276 + /* save a pointer to the "last" indication word */
25277 + p_Last = p_TmpHmct;
25278 + p_TmpHmct += HMCD_BASIC_SIZE / 4;
25279 + }
25280 + break;
25281 +
25282 + case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV4):
25283 + /* set opcode */
25284 + tmpReg = (uint32_t)(HMCD_OPCODE_IPV4_UPDATE) << HMCD_OC_SHIFT;
25285 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
25286 + & HDR_MANIP_IPV4_TTL)
25287 + tmpReg |= HMCD_IPV4_UPDATE_TTL;
25288 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
25289 + & HDR_MANIP_IPV4_TOS)
25290 + {
25291 + tmpReg |= HMCD_IPV4_UPDATE_TOS;
25292 + tmpReg |=
25293 + p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.tos
25294 + << HMCD_IPV4_UPDATE_TOS_SHIFT;
25295 + }
25296 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
25297 + & HDR_MANIP_IPV4_ID)
25298 + tmpReg |= HMCD_IPV4_UPDATE_ID;
25299 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
25300 + & HDR_MANIP_IPV4_SRC)
25301 + tmpReg |= HMCD_IPV4_UPDATE_SRC;
25302 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
25303 + & HDR_MANIP_IPV4_DST)
25304 + tmpReg |= HMCD_IPV4_UPDATE_DST;
25305 + /* write the first 4 bytes of the descriptor */
25306 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25307 + /* save a pointer to the "last" indication word */
25308 + p_Last = p_TmpHmct;
25309 +
25310 + p_TmpHmct += HMCD_BASIC_SIZE / 4;
25311 +
25312 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
25313 + & HDR_MANIP_IPV4_ID)
25314 + {
25315 + ASSERT_COND(p_TmpData);
25316 + WRITE_UINT16(
25317 + *(uint16_t*)p_TmpData,
25318 + p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.id);
25319 + WRITE_UINT32(
25320 + *p_TmpHmct,
25321 + (uint32_t)(XX_VirtToPhys(p_TmpData) - (((t_FmPcd*)p_Manip->h_FmPcd)->physicalMuramBase)));
25322 + p_TmpData += 2;
25323 + p_TmpHmct += HMCD_PTR_SIZE / 4;
25324 + }
25325 +
25326 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
25327 + & HDR_MANIP_IPV4_SRC)
25328 + {
25329 + WRITE_UINT32(
25330 + *p_TmpHmct,
25331 + p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.src);
25332 + p_TmpHmct += HMCD_IPV4_ADDR_SIZE / 4;
25333 + }
25334 +
25335 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
25336 + & HDR_MANIP_IPV4_DST)
25337 + {
25338 + WRITE_UINT32(
25339 + *p_TmpHmct,
25340 + p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.dst);
25341 + p_TmpHmct += HMCD_IPV4_ADDR_SIZE / 4;
25342 + }
25343 + break;
25344 +
25345 + case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV6):
25346 + /* set opcode */
25347 + tmpReg = (uint32_t)(HMCD_OPCODE_IPV6_UPDATE) << HMCD_OC_SHIFT;
25348 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.validUpdates
25349 + & HDR_MANIP_IPV6_HL)
25350 + tmpReg |= HMCD_IPV6_UPDATE_HL;
25351 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.validUpdates
25352 + & HDR_MANIP_IPV6_TC)
25353 + {
25354 + tmpReg |= HMCD_IPV6_UPDATE_TC;
25355 + tmpReg |=
25356 + p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.trafficClass
25357 + << HMCD_IPV6_UPDATE_TC_SHIFT;
25358 + }
25359 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.validUpdates
25360 + & HDR_MANIP_IPV6_SRC)
25361 + tmpReg |= HMCD_IPV6_UPDATE_SRC;
25362 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.validUpdates
25363 + & HDR_MANIP_IPV6_DST)
25364 + tmpReg |= HMCD_IPV6_UPDATE_DST;
25365 + /* write the first 4 bytes of the descriptor */
25366 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25367 + /* save a pointer to the "last" indication word */
25368 + p_Last = p_TmpHmct;
25369 +
25370 + p_TmpHmct += HMCD_BASIC_SIZE / 4;
25371 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.validUpdates
25372 + & HDR_MANIP_IPV6_SRC)
25373 + {
25374 + for (i = 0; i < NET_HEADER_FIELD_IPv6_ADDR_SIZE; i += 4)
25375 + {
25376 + memcpy(&tmp_ipv6_addr,
25377 + &p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.src[i],
25378 + sizeof(uint32_t));
25379 + WRITE_UINT32(*p_TmpHmct, tmp_ipv6_addr);
25380 + p_TmpHmct += HMCD_PTR_SIZE / 4;
25381 + }
25382 + }
25383 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.validUpdates
25384 + & HDR_MANIP_IPV6_DST)
25385 + {
25386 + for (i = 0; i < NET_HEADER_FIELD_IPv6_ADDR_SIZE; i += 4)
25387 + {
25388 + memcpy(&tmp_ipv6_addr,
25389 + &p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.dst[i],
25390 + sizeof(uint32_t));
25391 + WRITE_UINT32(*p_TmpHmct, tmp_ipv6_addr);
25392 + p_TmpHmct += HMCD_PTR_SIZE / 4;
25393 + }
25394 + }
25395 + break;
25396 +
25397 + case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_TCP_UDP):
25398 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.validUpdates
25399 + == HDR_MANIP_TCP_UDP_CHECKSUM)
25400 + {
25401 + /* we implement this case with the update-checksum descriptor */
25402 + /* set opcode */
25403 + tmpReg = (uint32_t)(HMCD_OPCODE_TCP_UDP_CHECKSUM)
25404 + << HMCD_OC_SHIFT;
25405 + /* write the first 4 bytes of the descriptor */
25406 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25407 + /* save a pointer to the "last" indication word */
25408 + p_Last = p_TmpHmct;
25409 +
25410 + p_TmpHmct += HMCD_BASIC_SIZE / 4;
25411 + }
25412 + else
25413 + {
25414 + /* we implement this case with the TCP/UDP update descriptor */
25415 + /* set opcode */
25416 + tmpReg = (uint32_t)(HMCD_OPCODE_TCP_UDP_UPDATE)
25417 + << HMCD_OC_SHIFT;
25418 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.validUpdates
25419 + & HDR_MANIP_TCP_UDP_DST)
25420 + tmpReg |= HMCD_TCP_UDP_UPDATE_DST;
25421 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.validUpdates
25422 + & HDR_MANIP_TCP_UDP_SRC)
25423 + tmpReg |= HMCD_TCP_UDP_UPDATE_SRC;
25424 + /* write the first 4 bytes of the descriptor */
25425 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25426 + /* save a pointer to the "last" indication word */
25427 + p_Last = p_TmpHmct;
25428 +
25429 + p_TmpHmct += HMCD_BASIC_SIZE / 4;
25430 +
25431 + tmpReg = 0;
25432 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.validUpdates
25433 + & HDR_MANIP_TCP_UDP_SRC)
25434 + tmpReg |=
25435 + ((uint32_t)p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.src)
25436 + << HMCD_TCP_UDP_UPDATE_SRC_SHIFT;
25437 + if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.validUpdates
25438 + & HDR_MANIP_TCP_UDP_DST)
25439 + tmpReg |=
25440 + ((uint32_t)p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.dst);
25441 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25442 + p_TmpHmct += HMCD_PTR_SIZE / 4;
25443 + }
25444 + break;
25445 +
25446 + default:
25447 + RETURN_ERROR(MINOR, E_INVALID_SELECTION,
25448 + ("Unknown fieldUpdateParams.type"));
25449 + }
25450 + }
25451 +
25452 + if (p_FmPcdManipParams->u.hdr.custom)
25453 + {
25454 + switch (p_FmPcdManipParams->u.hdr.customParams.type)
25455 + {
25456 + case (e_FM_PCD_MANIP_HDR_CUSTOM_IP_REPLACE):
25457 + /* set opcode */
25458 + tmpReg = (uint32_t)(HMCD_OPCODE_REPLACE_IP) << HMCD_OC_SHIFT;
25459 +
25460 + if (p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.decTtlHl)
25461 + tmpReg |= HMCD_IP_REPLACE_TTL_HL;
25462 + if (p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.replaceType
25463 + == e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV4_BY_IPV6)
25464 + /* line commented out as it has no-side-effect ('0' value). */
25465 + /*tmpReg |= HMCD_IP_REPLACE_REPLACE_IPV4*/;
25466 + else
25467 + if (p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.replaceType
25468 + == e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4)
25469 + {
25470 + tmpReg |= HMCD_IP_REPLACE_REPLACE_IPV6;
25471 + if (p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.updateIpv4Id)
25472 + tmpReg |= HMCD_IP_REPLACE_ID;
25473 + }
25474 + else
25475 + RETURN_ERROR(
25476 + MINOR,
25477 + E_NOT_SUPPORTED,
25478 + ("One flag out of HDR_MANIP_IP_REPLACE_IPV4, HDR_MANIP_IP_REPLACE_IPV6 - must be set."));
25479 +
25480 + /* write the first 4 bytes of the descriptor */
25481 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25482 + /* save a pointer to the "last" indication word */
25483 + p_Last = p_TmpHmct;
25484 +
25485 + p_TmpHmct += HMCD_BASIC_SIZE / 4;
25486 +
25487 + size =
25488 + p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.hdrSize;
25489 + ASSERT_COND(p_TmpData);
25490 + MemCpy8(
25491 + p_TmpData,
25492 + p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.hdr,
25493 + size);
25494 + tmpReg = (uint32_t)(size << HMCD_IP_REPLACE_L3HDRSIZE_SHIFT);
25495 + tmpReg |= (uint32_t)(XX_VirtToPhys(p_TmpData)
25496 + - (((t_FmPcd*)h_FmPcd)->physicalMuramBase));
25497 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25498 + p_TmpHmct += HMCD_PTR_SIZE / 4;
25499 + p_TmpData += size;
25500 +
25501 + if ((p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.replaceType
25502 + == e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4)
25503 + && (p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.updateIpv4Id))
25504 + {
25505 + WRITE_UINT16(
25506 + *(uint16_t*)p_TmpData,
25507 + p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.id);
25508 + WRITE_UINT32(
25509 + *p_TmpHmct,
25510 + (uint32_t)(XX_VirtToPhys(p_TmpData) - (((t_FmPcd*)h_FmPcd)->physicalMuramBase)));
25511 + p_TmpData += 2;
25512 + }
25513 + p_TmpHmct += HMCD_PTR_SIZE / 4;
25514 + break;
25515 + case (e_FM_PCD_MANIP_HDR_CUSTOM_GEN_FIELD_REPLACE):
25516 + /* set opcode */
25517 + tmpReg = (uint32_t)(HMCD_OPCODE_GEN_FIELD_REPLACE) << HMCD_OC_SHIFT;
25518 + tmpReg |= p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.size << HMCD_GEN_FIELD_SIZE_SHIFT;
25519 + tmpReg |= p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.srcOffset << HMCD_GEN_FIELD_SRC_OFF_SHIFT;
25520 + tmpReg |= p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.dstOffset << HMCD_GEN_FIELD_DST_OFF_SHIFT;
25521 + if (p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.mask)
25522 + tmpReg |= HMCD_GEN_FIELD_MASK_EN;
25523 +
25524 + /* write the first 4 bytes of the descriptor */
25525 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25526 + /* save a pointer to the "last" indication word */
25527 + p_Last = p_TmpHmct;
25528 +
25529 + p_TmpHmct += HMCD_BASIC_SIZE/4;
25530 +
25531 + if (p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.mask)
25532 + {
25533 + tmpReg = p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.mask << HMCD_GEN_FIELD_MASK_SHIFT;
25534 + tmpReg |= p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.maskOffset << HMCD_GEN_FIELD_MASK_OFF_SHIFT;
25535 + /* write the next 4 bytes of the descriptor */
25536 + WRITE_UINT32(*p_TmpHmct, tmpReg);
25537 + }
25538 + p_TmpHmct += HMCD_PARAM_SIZE/4;
25539 + break;
25540 + default:
25541 + RETURN_ERROR(MINOR, E_INVALID_SELECTION,
25542 + ("Unknown customParams.type"));
25543 + }
25544 + }
25545 +
25546 + /* If this node has a nextManip, and no parsing is required, the old table must be copied to the new table
25547 + the old table and should be freed */
25548 + if (p_FmPcdManipParams->h_NextManip
25549 + && (p_Manip->nextManipType == e_FM_PCD_MANIP_HDR)
25550 + && (MANIP_DONT_REPARSE(p_Manip)))
25551 + {
25552 + if (new)
25553 + {
25554 + /* If this is the first time this manip is created we need to free unused memory. If it
25555 + * is a dynamic changes case, the memory used is either the CC shadow or the existing
25556 + * table - no allocation, no free */
25557 + MANIP_UPDATE_UNIFIED_POSITION(p_FmPcdManipParams->h_NextManip);
25558 +
25559 + p_Manip->unifiedPosition = e_MANIP_UNIFIED_FIRST;
25560 + }
25561 + }
25562 + else
25563 + {
25564 + ASSERT_COND(p_Last);
25565 + /* set the "last" indication on the last command of the current table */
25566 + WRITE_UINT32(*p_Last, GET_UINT32(*p_Last) | HMCD_LAST);
25567 + }
25568 +
25569 + return E_OK;
25570 +}
25571 +
25572 +static t_Error CreateManipActionNew(t_FmPcdManip *p_Manip,
25573 + t_FmPcdManipParams *p_FmPcdManipParams)
25574 +{
25575 + t_FmPcdManip *p_CurManip;
25576 + t_Error err;
25577 + uint32_t nextSize = 0, totalSize;
25578 + uint16_t tmpReg;
25579 + uint8_t *p_OldHmct, *p_TmpHmctPtr, *p_TmpDataPtr;
25580 +
25581 + /* set Manip structure */
25582 +
25583 + p_Manip->dontParseAfterManip =
25584 + p_FmPcdManipParams->u.hdr.dontParseAfterManip;
25585 +
25586 + if (p_FmPcdManipParams->h_NextManip)
25587 + { /* Next Header manipulation exists */
25588 + p_Manip->nextManipType = MANIP_GET_TYPE(p_FmPcdManipParams->h_NextManip);
25589 +
25590 + if ((p_Manip->nextManipType == e_FM_PCD_MANIP_HDR) && p_Manip->dontParseAfterManip)
25591 + nextSize = (uint32_t)(GetHmctSize(p_FmPcdManipParams->h_NextManip)
25592 + + GetDataSize(p_FmPcdManipParams->h_NextManip));
25593 + else /* either parsing is required or next manip is Frag; no table merging. */
25594 + p_Manip->cascaded = TRUE;
25595 + /* pass up the "cascaded" attribute. The whole chain is cascaded
25596 + * if something is cascaded along the way. */
25597 + if (MANIP_IS_CASCADED(p_FmPcdManipParams->h_NextManip))
25598 + p_Manip->cascaded = TRUE;
25599 + }
25600 +
25601 + /* Allocate new table */
25602 + /* calculate table size according to manip parameters */
25603 + err = CalculateTableSize(p_FmPcdManipParams, &p_Manip->tableSize,
25604 + &p_Manip->dataSize);
25605 + if (err)
25606 + RETURN_ERROR(MINOR, err, NO_MSG);
25607 +
25608 + totalSize = (uint16_t)(p_Manip->tableSize + p_Manip->dataSize + nextSize);
25609 +
25610 + p_Manip->p_Hmct = (uint8_t*)FM_MURAM_AllocMem(
25611 + ((t_FmPcd *)p_Manip->h_FmPcd)->h_FmMuram, totalSize, 4);
25612 + if (!p_Manip->p_Hmct)
25613 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc failed"));
25614 +
25615 + if (p_Manip->dataSize)
25616 + p_Manip->p_Data =
25617 + (uint8_t*)PTR_MOVE(p_Manip->p_Hmct, (p_Manip->tableSize + nextSize));
25618 +
25619 + /* update shadow size to allow runtime replacement of Header manipulation */
25620 + /* The allocated shadow is divided as follows:
25621 + 0 . . . 16 . . .
25622 + --------------------------------
25623 + | Shadow | Shadow HMTD |
25624 + | HMTD | Match Table |
25625 + | (16 bytes) | (maximal size) |
25626 + --------------------------------
25627 + */
25628 +
25629 + err = FmPcdUpdateCcShadow(p_Manip->h_FmPcd, (uint32_t)(totalSize + 16),
25630 + (uint16_t)FM_PCD_CC_AD_TABLE_ALIGN);
25631 + if (err != E_OK)
25632 + {
25633 + FM_MURAM_FreeMem(p_Manip->h_FmPcd, p_Manip->p_Hmct);
25634 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
25635 + ("MURAM allocation for HdrManip node shadow"));
25636 + }
25637 +
25638 + if (p_FmPcdManipParams->h_NextManip
25639 + && (p_Manip->nextManipType == e_FM_PCD_MANIP_HDR)
25640 + && (MANIP_DONT_REPARSE(p_Manip)))
25641 + {
25642 + p_OldHmct = (uint8_t *)GetManipInfo(p_FmPcdManipParams->h_NextManip,
25643 + e_MANIP_HMCT);
25644 + p_CurManip = p_FmPcdManipParams->h_NextManip;
25645 + /* Run till the last Manip (which is the first to configure) */
25646 + while (MANIP_IS_UNIFIED_NON_LAST(p_CurManip))
25647 + p_CurManip = p_CurManip->h_NextManip;
25648 +
25649 + while (p_CurManip)
25650 + {
25651 + /* If this is a unified table, point to the part of the table
25652 + * which is the relative offset in HMCT.
25653 + */
25654 + p_TmpHmctPtr = (uint8_t*)PTR_MOVE(p_Manip->p_Hmct,
25655 + (p_Manip->tableSize +
25656 + (PTR_TO_UINT(p_CurManip->p_Hmct) -
25657 + PTR_TO_UINT(p_OldHmct))));
25658 + if (p_CurManip->p_Data)
25659 + p_TmpDataPtr = (uint8_t*)PTR_MOVE(p_Manip->p_Hmct,
25660 + (p_Manip->tableSize +
25661 + (PTR_TO_UINT(p_CurManip->p_Data) -
25662 + PTR_TO_UINT(p_OldHmct))));
25663 + else
25664 + p_TmpDataPtr = NULL;
25665 +
25666 + BuildHmct(p_CurManip, &p_CurManip->manipParams, p_TmpHmctPtr,
25667 + p_TmpDataPtr, FALSE);
25668 + /* update old manip table pointer */
25669 + MANIP_SET_HMCT_PTR(p_CurManip, p_TmpHmctPtr);
25670 + MANIP_SET_DATA_PTR(p_CurManip, p_TmpDataPtr);
25671 +
25672 + p_CurManip = p_CurManip->h_PrevManip;
25673 + }
25674 + /* We copied the HMCT to create a new large HMCT so we can free the old one */
25675 + FM_MURAM_FreeMem(MANIP_GET_MURAM(p_FmPcdManipParams->h_NextManip),
25676 + p_OldHmct);
25677 + }
25678 +
25679 + /* Fill table */
25680 + err = BuildHmct(p_Manip, p_FmPcdManipParams, p_Manip->p_Hmct,
25681 + p_Manip->p_Data, TRUE);
25682 + if (err)
25683 + {
25684 + FM_MURAM_FreeMem(p_Manip->h_FmPcd, p_Manip->p_Hmct);
25685 + RETURN_ERROR(MINOR, err, NO_MSG);
25686 + }
25687 +
25688 + /* Build HMTD (table descriptor) */
25689 + tmpReg = HMTD_CFG_TYPE; /* NADEN = 0 */
25690 +
25691 + /* add parseAfterManip */
25692 + if (!p_Manip->dontParseAfterManip)
25693 + tmpReg |= HMTD_CFG_PRS_AFTER_HM;
25694 +
25695 + /* create cascade */
25696 + /*if (p_FmPcdManipParams->h_NextManip
25697 + && (!MANIP_DONT_REPARSE(p_Manip) || (p_Manip->nextManipType != e_FM_PCD_MANIP_HDR)))*/
25698 + if (p_Manip->cascaded)
25699 + {
25700 + uint16_t nextAd;
25701 + /* indicate that there's another HM table descriptor */
25702 + tmpReg |= HMTD_CFG_NEXT_AD_EN;
25703 + /* get address of next HMTD (table descriptor; h_Ad).
25704 + * If the next HMTD was removed due to table unifing, get the address
25705 + * of the "next next" as written in the h_Ad of the next h_Manip node.
25706 + */
25707 + if (p_Manip->unifiedPosition != e_MANIP_UNIFIED_FIRST)
25708 + nextAd = (uint16_t)((uint32_t)(XX_VirtToPhys(MANIP_GET_HMTD_PTR(p_FmPcdManipParams->h_NextManip)) - (((t_FmPcd*)p_Manip->h_FmPcd)->physicalMuramBase)) >> 4);
25709 + else
25710 + nextAd = ((t_Hmtd *)((t_FmPcdManip *)p_FmPcdManipParams->h_NextManip)->h_Ad)->nextAdIdx;
25711 +
25712 + WRITE_UINT16(((t_Hmtd *)p_Manip->h_Ad)->nextAdIdx, nextAd);
25713 + }
25714 +
25715 + WRITE_UINT16(((t_Hmtd *)p_Manip->h_Ad)->cfg, tmpReg);
25716 + WRITE_UINT32(
25717 + ((t_Hmtd *)p_Manip->h_Ad)->hmcdBasePtr,
25718 + (uint32_t)(XX_VirtToPhys(p_Manip->p_Hmct) - (((t_FmPcd*)p_Manip->h_FmPcd)->physicalMuramBase)));
25719 +
25720 + WRITE_UINT8(((t_Hmtd *)p_Manip->h_Ad)->opCode, HMAN_OC);
25721 +
25722 + if (p_Manip->unifiedPosition == e_MANIP_UNIFIED_FIRST)
25723 + {
25724 + /* The HMTD of the next Manip is never going to be used */
25725 + if (((t_FmPcdManip *)p_FmPcdManipParams->h_NextManip)->muramAllocate)
25726 + FM_MURAM_FreeMem(
25727 + ((t_FmPcd *)((t_FmPcdManip *)p_FmPcdManipParams->h_NextManip)->h_FmPcd)->h_FmMuram,
25728 + ((t_FmPcdManip *)p_FmPcdManipParams->h_NextManip)->h_Ad);
25729 + else
25730 + XX_Free(((t_FmPcdManip *)p_FmPcdManipParams->h_NextManip)->h_Ad);
25731 + ((t_FmPcdManip *)p_FmPcdManipParams->h_NextManip)->h_Ad = NULL;
25732 + }
25733 +
25734 + return E_OK;
25735 +}
25736 +
25737 +static t_Error CreateManipActionShadow(t_FmPcdManip *p_Manip,
25738 + t_FmPcdManipParams *p_FmPcdManipParams)
25739 +{
25740 + uint8_t *p_WholeHmct, *p_TmpHmctPtr, newDataSize, *p_TmpDataPtr = NULL;
25741 + uint16_t newSize;
25742 + t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
25743 + t_Error err;
25744 + t_FmPcdManip *p_CurManip = p_Manip;
25745 +
25746 + err = CalculateTableSize(p_FmPcdManipParams, &newSize, &newDataSize);
25747 + if (err)
25748 + RETURN_ERROR(MINOR, err, NO_MSG);
25749 +
25750 + /* check coherency of new table parameters */
25751 + if (newSize > p_Manip->tableSize)
25752 + RETURN_ERROR(
25753 + MINOR,
25754 + E_INVALID_VALUE,
25755 + ("New Hdr Manip configuration requires larger size than current one (command table)."));
25756 + if (newDataSize > p_Manip->dataSize)
25757 + RETURN_ERROR(
25758 + MINOR,
25759 + E_INVALID_VALUE,
25760 + ("New Hdr Manip configuration requires larger size than current one (data)."));
25761 + if (p_FmPcdManipParams->h_NextManip)
25762 + RETURN_ERROR(
25763 + MINOR, E_INVALID_VALUE,
25764 + ("New Hdr Manip configuration can not contain h_NextManip."));
25765 + if (MANIP_IS_UNIFIED(p_Manip) && (newSize != p_Manip->tableSize))
25766 + RETURN_ERROR(
25767 + MINOR,
25768 + E_INVALID_VALUE,
25769 + ("New Hdr Manip configuration in a chained manipulation requires different size than current one."));
25770 + if (p_Manip->dontParseAfterManip
25771 + != p_FmPcdManipParams->u.hdr.dontParseAfterManip)
25772 + RETURN_ERROR(
25773 + MINOR,
25774 + E_INVALID_VALUE,
25775 + ("New Hdr Manip configuration differs in dontParseAfterManip value."));
25776 +
25777 + p_Manip->tableSize = newSize;
25778 + p_Manip->dataSize = newDataSize;
25779 +
25780 + /* Build the new table in the shadow */
25781 + if (!MANIP_IS_UNIFIED(p_Manip))
25782 + {
25783 + p_TmpHmctPtr = (uint8_t*)PTR_MOVE(p_FmPcd->p_CcShadow, 16);
25784 + if (p_Manip->p_Data)
25785 + p_TmpDataPtr =
25786 + (uint8_t*)PTR_MOVE(p_TmpHmctPtr,
25787 + (PTR_TO_UINT(p_Manip->p_Data) - PTR_TO_UINT(p_Manip->p_Hmct)));
25788 +
25789 + BuildHmct(p_Manip, p_FmPcdManipParams, p_TmpHmctPtr, p_Manip->p_Data,
25790 + FALSE);
25791 + }
25792 + else
25793 + {
25794 + p_WholeHmct = (uint8_t *)GetManipInfo(p_Manip, e_MANIP_HMCT);
25795 + ASSERT_COND(p_WholeHmct);
25796 +
25797 + /* Run till the last Manip (which is the first to configure) */
25798 + while (MANIP_IS_UNIFIED_NON_LAST(p_CurManip))
25799 + p_CurManip = p_CurManip->h_NextManip;
25800 +
25801 + while (p_CurManip)
25802 + {
25803 + /* If this is a non-head node in a unified table, point to the part of the shadow
25804 + * which is the relative offset in HMCT.
25805 + * else, point to the beginning of the
25806 + * shadow table (we save 16 for the HMTD.
25807 + */
25808 + p_TmpHmctPtr =
25809 + (uint8_t*)PTR_MOVE(p_FmPcd->p_CcShadow,
25810 + (16 + PTR_TO_UINT(p_CurManip->p_Hmct) - PTR_TO_UINT(p_WholeHmct)));
25811 + if (p_CurManip->p_Data)
25812 + p_TmpDataPtr =
25813 + (uint8_t*)PTR_MOVE(p_FmPcd->p_CcShadow,
25814 + (16 + PTR_TO_UINT(p_CurManip->p_Data) - PTR_TO_UINT(p_WholeHmct)));
25815 +
25816 + BuildHmct(p_CurManip, &p_CurManip->manipParams, p_TmpHmctPtr,
25817 + p_TmpDataPtr, FALSE);
25818 + p_CurManip = p_CurManip->h_PrevManip;
25819 + }
25820 + }
25821 +
25822 + return E_OK;
25823 +}
25824 +
25825 +static t_Error CreateManipActionBackToOrig(
25826 + t_FmPcdManip *p_Manip, t_FmPcdManipParams *p_FmPcdManipParams)
25827 +{
25828 + uint8_t *p_WholeHmct = NULL, *p_TmpHmctPtr, *p_TmpDataPtr;
25829 + t_FmPcdManip *p_CurManip = p_Manip;
25830 +
25831 + /* Build the new table in the shadow */
25832 + if (!MANIP_IS_UNIFIED(p_Manip))
25833 + BuildHmct(p_Manip, p_FmPcdManipParams, p_Manip->p_Hmct, p_Manip->p_Data,
25834 + FALSE);
25835 + else
25836 + {
25837 + p_WholeHmct = (uint8_t *)GetManipInfo(p_Manip, e_MANIP_HMCT);
25838 + ASSERT_COND(p_WholeHmct);
25839 +
25840 + /* Run till the last Manip (which is the first to configure) */
25841 + while (MANIP_IS_UNIFIED_NON_LAST(p_CurManip))
25842 + p_CurManip = p_CurManip->h_NextManip;
25843 +
25844 + while (p_CurManip)
25845 + {
25846 + /* If this is a unified table, point to the part of the table
25847 + * which is the relative offset in HMCT.
25848 + */
25849 + p_TmpHmctPtr = p_CurManip->p_Hmct; /*- (uint32_t)p_WholeHmct*/
25850 + p_TmpDataPtr = p_CurManip->p_Data; /*- (uint32_t)p_WholeHmct*/
25851 +
25852 + BuildHmct(p_CurManip, &p_CurManip->manipParams, p_TmpHmctPtr,
25853 + p_TmpDataPtr, FALSE);
25854 +
25855 + p_CurManip = p_CurManip->h_PrevManip;
25856 + }
25857 + }
25858 +
25859 + return E_OK;
25860 +}
25861 +
25862 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
25863 +static t_Error UpdateManipIc(t_Handle h_Manip, uint8_t icOffset)
25864 +{
25865 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
25866 + t_Handle p_Ad;
25867 + uint32_t tmpReg32 = 0;
25868 + SANITY_CHECK_RETURN_ERROR(h_Manip, E_INVALID_HANDLE);
25869 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad, E_INVALID_HANDLE);
25870 +
25871 + switch (p_Manip->opcode)
25872 + {
25873 + case (HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
25874 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
25875 + if (p_Manip->updateParams & INTERNAL_CONTEXT_OFFSET)
25876 + {
25877 + tmpReg32 =
25878 + *(uint32_t *)&((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets;
25879 + tmpReg32 |= (uint32_t)((uint32_t)icOffset << 16);
25880 + *(uint32_t *)&((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets =
25881 + tmpReg32;
25882 + p_Manip->updateParams &= ~INTERNAL_CONTEXT_OFFSET;
25883 + p_Manip->icOffset = icOffset;
25884 + }
25885 + else
25886 + {
25887 + if (p_Manip->icOffset != icOffset)
25888 + RETURN_ERROR(
25889 + MAJOR,
25890 + E_INVALID_VALUE,
25891 + ("this manipulation was updated previously by different value"););
25892 + }
25893 + break;
25894 + case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
25895 + if (p_Manip->h_Frag)
25896 + {
25897 + if (p_Manip->updateParams & INTERNAL_CONTEXT_OFFSET)
25898 + {
25899 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
25900 + tmpReg32 |= GET_UINT32(((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets);
25901 + tmpReg32 |= (uint32_t)((uint32_t)icOffset << 16);
25902 + WRITE_UINT32(((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets, tmpReg32);
25903 + p_Manip->updateParams &= ~INTERNAL_CONTEXT_OFFSET;
25904 + p_Manip->icOffset = icOffset;
25905 + }
25906 + else
25907 + {
25908 + if (p_Manip->icOffset != icOffset)
25909 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("this manipulation was updated previousely by different value"););
25910 + }
25911 + }
25912 + break;
25913 + }
25914 +
25915 + return E_OK;
25916 +}
25917 +
25918 +static t_Error UpdateInitMvIntFrameHeaderFromFrameToBufferPrefix(
25919 + t_Handle h_FmPort, t_FmPcdManip *p_Manip, t_Handle h_Ad, bool validate)
25920 +{
25921 +
25922 + t_AdOfTypeContLookup *p_Ad = (t_AdOfTypeContLookup *)h_Ad;
25923 + t_FmPortGetSetCcParams fmPortGetSetCcParams;
25924 + t_Error err;
25925 + uint32_t tmpReg32;
25926 +
25927 + memset(&fmPortGetSetCcParams, 0, sizeof(t_FmPortGetSetCcParams));
25928 +
25929 + SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
25930 + SANITY_CHECK_RETURN_ERROR(
25931 + (p_Manip->opcode & HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX),
25932 + E_INVALID_STATE);
25933 + SANITY_CHECK_RETURN_ERROR(!p_Manip->muramAllocate, E_INVALID_STATE);
25934 +
25935 + if (p_Manip->updateParams)
25936 + {
25937 + if ((!(p_Manip->updateParams & OFFSET_OF_PR))
25938 + || (p_Manip->shadowUpdateParams & OFFSET_OF_PR))
25939 + RETURN_ERROR(
25940 + MAJOR, E_INVALID_STATE,
25941 + ("in this stage parameters from Port has not be updated"));
25942 +
25943 + fmPortGetSetCcParams.getCcParams.type = p_Manip->updateParams;
25944 + fmPortGetSetCcParams.setCcParams.type = UPDATE_PSO;
25945 + fmPortGetSetCcParams.setCcParams.psoSize = 16;
25946 +
25947 + err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
25948 + if (err)
25949 + RETURN_ERROR(MAJOR, err, NO_MSG);
25950 + if (fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_PR)
25951 + RETURN_ERROR(
25952 + MAJOR, E_INVALID_STATE,
25953 + ("Parser result offset wasn't configured previousely"));
25954 +#ifdef FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004
25955 + ASSERT_COND(!(fmPortGetSetCcParams.getCcParams.prOffset % 16));
25956 +#endif
25957 + }
25958 + else
25959 + if (validate)
25960 + {
25961 + if ((!(p_Manip->shadowUpdateParams & OFFSET_OF_PR))
25962 + || (p_Manip->updateParams & OFFSET_OF_PR))
25963 + RETURN_ERROR(
25964 + MAJOR, E_INVALID_STATE,
25965 + ("in this stage parameters from Port has be updated"));
25966 + fmPortGetSetCcParams.getCcParams.type = p_Manip->shadowUpdateParams;
25967 + fmPortGetSetCcParams.setCcParams.type = UPDATE_PSO;
25968 + fmPortGetSetCcParams.setCcParams.psoSize = 16;
25969 +
25970 + err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
25971 + if (err)
25972 + RETURN_ERROR(MAJOR, err, NO_MSG);
25973 + if (fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_PR)
25974 + RETURN_ERROR(
25975 + MAJOR, E_INVALID_STATE,
25976 + ("Parser result offset wasn't configured previousely"));
25977 +
25978 + }
25979 +
25980 + ASSERT_COND(p_Ad);
25981 +
25982 + if (p_Manip->updateParams & OFFSET_OF_PR)
25983 + {
25984 + tmpReg32 = 0;
25985 + tmpReg32 |= fmPortGetSetCcParams.getCcParams.prOffset;
25986 + WRITE_UINT32(p_Ad->matchTblPtr,
25987 + (GET_UINT32(p_Ad->matchTblPtr) | tmpReg32));
25988 + p_Manip->updateParams &= ~OFFSET_OF_PR;
25989 + p_Manip->shadowUpdateParams |= OFFSET_OF_PR;
25990 + }
25991 + else
25992 + if (validate)
25993 + {
25994 + tmpReg32 = GET_UINT32(p_Ad->matchTblPtr);
25995 + if ((uint8_t)tmpReg32 != fmPortGetSetCcParams.getCcParams.prOffset)
25996 + RETURN_ERROR(
25997 + MAJOR,
25998 + E_INVALID_STATE,
25999 + ("this manipulation was updated previousely by different value"););
26000 + }
26001 +
26002 + return E_OK;
26003 +}
26004 +
26005 +static t_Error UpdateModifyCapwapFragmenation(t_FmPcdManip *p_Manip, t_Handle h_Ad, bool validate,t_Handle h_FmTree)
26006 +{
26007 + t_AdOfTypeContLookup *p_Ad = (t_AdOfTypeContLookup *)h_Ad;
26008 + t_FmPcdCcSavedManipParams *p_SavedManipParams = NULL;
26009 + uint32_t tmpReg32 = 0;
26010 +
26011 + SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
26012 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_Frag,E_INVALID_HANDLE);
26013 + SANITY_CHECK_RETURN_ERROR(p_Manip->frag,E_INVALID_HANDLE);
26014 + SANITY_CHECK_RETURN_ERROR(((p_Manip->opcode == HMAN_OC_CAPWAP_FRAGMENTATION) || (p_Manip->opcode == HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER)), E_INVALID_STATE);
26015 +
26016 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Frag;
26017 +
26018 + if (p_Manip->updateParams)
26019 + {
26020 +
26021 + if ((!(p_Manip->updateParams & OFFSET_OF_DATA)) ||
26022 + ((p_Manip->shadowUpdateParams & OFFSET_OF_DATA)))
26023 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has not be updated"));
26024 + p_SavedManipParams = FmPcdCcTreeGetSavedManipParams(h_FmTree);
26025 + if (!p_SavedManipParams)
26026 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("for this manipulation tree has to be configured previosely with this type"));
26027 + p_Manip->capwapFragParams.dataOffset = p_SavedManipParams->capwapParams.dataOffset;
26028 +
26029 + tmpReg32 = GET_UINT32(p_Ad->pcAndOffsets);
26030 + tmpReg32 |= ((uint32_t)p_Manip->capwapFragParams.dataOffset<< 16);
26031 + WRITE_UINT32(p_Ad->pcAndOffsets,tmpReg32);
26032 +
26033 + p_Manip->updateParams &= ~OFFSET_OF_DATA;
26034 + p_Manip->shadowUpdateParams |= OFFSET_OF_DATA;
26035 + }
26036 + else if (validate)
26037 + {
26038 +
26039 + p_SavedManipParams = FmPcdCcTreeGetSavedManipParams(h_FmTree);
26040 + if (!p_SavedManipParams)
26041 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("for this manipulation tree has to be configured previosely with this type"));
26042 + if (p_Manip->capwapFragParams.dataOffset != p_SavedManipParams->capwapParams.dataOffset)
26043 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("this manipulation was updated previousely by different value"));
26044 + }
26045 +
26046 + return E_OK;
26047 +}
26048 +
26049 +static t_Error UpdateInitCapwapFragmentation(t_Handle h_FmPort,
26050 + t_FmPcdManip *p_Manip,
26051 + t_Handle h_Ad,
26052 + bool validate,
26053 + t_Handle h_FmTree)
26054 +{
26055 + t_AdOfTypeContLookup *p_Ad;
26056 + t_FmPortGetSetCcParams fmPortGetSetCcParams;
26057 + t_Error err;
26058 + uint32_t tmpReg32 = 0;
26059 + t_FmPcdCcSavedManipParams *p_SavedManipParams;
26060 +
26061 + UNUSED(h_Ad);
26062 +
26063 + SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
26064 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_Frag,E_INVALID_HANDLE);
26065 + SANITY_CHECK_RETURN_ERROR(p_Manip->frag,E_INVALID_HANDLE);
26066 + SANITY_CHECK_RETURN_ERROR(((p_Manip->opcode == HMAN_OC_CAPWAP_FRAGMENTATION) ||
26067 + (p_Manip->opcode == HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER)), E_INVALID_STATE);
26068 +
26069 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Frag;
26070 +
26071 + if (p_Manip->updateParams)
26072 + {
26073 + if ((!(p_Manip->updateParams & OFFSET_OF_DATA)) ||
26074 + ((p_Manip->shadowUpdateParams & OFFSET_OF_DATA)))
26075 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has not be updated"));
26076 + fmPortGetSetCcParams.getCcParams.type = p_Manip->updateParams;
26077 + fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNEN | UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY;
26078 + fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_POP_TO_N_STEP | NIA_ENG_FM_CTL;
26079 + /* For CAPWAP Rassembly used FMAN_CTRL2 hardcoded - so for fragmentation its better to use FMAN_CTRL1 */
26080 + fmPortGetSetCcParams.setCcParams.orFmanCtrl = FPM_PORT_FM_CTL1;
26081 +
26082 + err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
26083 + if (err)
26084 + RETURN_ERROR(MAJOR, err, NO_MSG);
26085 +
26086 + if (fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
26087 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Data offset wasn't configured previousely"));
26088 +
26089 + p_SavedManipParams = (t_FmPcdCcSavedManipParams *)XX_Malloc(sizeof(t_FmPcdCcSavedManipParams));
26090 + p_SavedManipParams->capwapParams.dataOffset = fmPortGetSetCcParams.getCcParams.dataOffset;
26091 +
26092 +#ifdef FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004
26093 + ASSERT_COND(!(p_SavedManipParams->capwapParams.dataOffset % 16));
26094 +#endif /* FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004 */
26095 +
26096 + FmPcdCcTreeSetSavedManipParams(h_FmTree, (t_Handle)p_SavedManipParams);
26097 + }
26098 + else if (validate)
26099 + {
26100 + if ((!(p_Manip->shadowUpdateParams & OFFSET_OF_DATA)) ||
26101 + ((p_Manip->updateParams & OFFSET_OF_DATA)))
26102 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has be updated"));
26103 + fmPortGetSetCcParams.getCcParams.type = p_Manip->shadowUpdateParams;
26104 + fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNEN | UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY;
26105 + fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_POP_TO_N_STEP | NIA_ENG_FM_CTL;
26106 + err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
26107 + if (err)
26108 + RETURN_ERROR(MAJOR, err, NO_MSG);
26109 +
26110 + if (fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
26111 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Data offset wasn't configured previousely"));
26112 + }
26113 +
26114 + if (p_Manip->updateParams)
26115 + {
26116 + tmpReg32 = GET_UINT32(p_Ad->pcAndOffsets);
26117 + tmpReg32 |= ((uint32_t)fmPortGetSetCcParams.getCcParams.dataOffset<< 16);
26118 + WRITE_UINT32(p_Ad->pcAndOffsets,tmpReg32);
26119 +
26120 + p_Manip->updateParams &= ~OFFSET_OF_DATA;
26121 + p_Manip->shadowUpdateParams |= OFFSET_OF_DATA;
26122 + p_Manip->capwapFragParams.dataOffset = fmPortGetSetCcParams.getCcParams.dataOffset;
26123 + }
26124 + else if (validate)
26125 + {
26126 + if (p_Manip->capwapFragParams.dataOffset != fmPortGetSetCcParams.getCcParams.dataOffset)
26127 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("this manipulation was updated previousely by different value"));
26128 + }
26129 +
26130 + return E_OK;
26131 +}
26132 +
26133 +static t_Error UpdateInitCapwapReasm(t_Handle h_FmPcd,
26134 + t_Handle h_FmPort,
26135 + t_FmPcdManip *p_Manip,
26136 + t_Handle h_Ad,
26137 + bool validate)
26138 +{
26139 + t_CapwapReasmPram *p_ReassmTbl;
26140 + t_Error err;
26141 + t_FmPortGetSetCcParams fmPortGetSetCcParams;
26142 + uint8_t i = 0;
26143 + uint16_t size;
26144 + uint32_t tmpReg32;
26145 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
26146 + t_FmPcdCcCapwapReassmTimeoutParams ccCapwapReassmTimeoutParams;
26147 +
26148 + SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
26149 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_Frag,E_INVALID_HANDLE);
26150 + SANITY_CHECK_RETURN_ERROR(!p_Manip->frag,E_INVALID_HANDLE);
26151 + SANITY_CHECK_RETURN_ERROR((p_Manip->opcode == HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST), E_INVALID_STATE);
26152 + SANITY_CHECK_RETURN_ERROR(h_FmPcd,E_INVALID_HANDLE);
26153 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc,E_INVALID_HANDLE);
26154 +
26155 + if (p_Manip->h_FmPcd != h_FmPcd)
26156 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
26157 + ("handler of PCD previously was initiated by different value"));
26158 +
26159 + UNUSED(h_Ad);
26160 +
26161 + memset(&fmPortGetSetCcParams, 0, sizeof(t_FmPortGetSetCcParams));
26162 + p_ReassmTbl = (t_CapwapReasmPram *)p_Manip->h_Frag;
26163 +
26164 + if (p_Manip->updateParams)
26165 + {
26166 + if ((!(p_Manip->updateParams & NUM_OF_TASKS) &&
26167 + !(p_Manip->updateParams & OFFSET_OF_DATA) &&
26168 + !(p_Manip->updateParams & OFFSET_OF_PR) &&
26169 + !(p_Manip->updateParams & HW_PORT_ID)) ||
26170 + ((p_Manip->shadowUpdateParams & NUM_OF_TASKS) ||
26171 + (p_Manip->shadowUpdateParams & OFFSET_OF_DATA) || (p_Manip->shadowUpdateParams & OFFSET_OF_PR) ||
26172 + (p_Manip->shadowUpdateParams & HW_PORT_ID)))
26173 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has not be updated"));
26174 +
26175 + fmPortGetSetCcParams.getCcParams.type = p_Manip->updateParams;
26176 + fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNEN;
26177 + fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_POP_TO_N_STEP | NIA_ENG_FM_CTL;
26178 +
26179 + err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
26180 + if (err)
26181 + RETURN_ERROR(MAJOR, err, NO_MSG);
26182 +
26183 + if (fmPortGetSetCcParams.getCcParams.type & NUM_OF_TASKS)
26184 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Num of tasks wasn't configured previousely"));
26185 + if (fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
26186 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("offset of the data wasn't configured previousely"));
26187 + if (fmPortGetSetCcParams.getCcParams.type & HW_PORT_ID)
26188 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("hwPortId wasn't updated"));
26189 +#ifdef FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004
26190 + ASSERT_COND((fmPortGetSetCcParams.getCcParams.dataOffset % 16) == 0);
26191 +#endif /* FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004 */
26192 + }
26193 + else if (validate)
26194 + {
26195 + if ((!(p_Manip->shadowUpdateParams & NUM_OF_TASKS) &&
26196 + !(p_Manip->shadowUpdateParams & OFFSET_OF_DATA) &&
26197 + !(p_Manip->shadowUpdateParams & OFFSET_OF_PR) &&
26198 + !(p_Manip->shadowUpdateParams & HW_PORT_ID)) &&
26199 + ((p_Manip->updateParams & NUM_OF_TASKS) ||
26200 + (p_Manip->updateParams & OFFSET_OF_DATA) || (p_Manip->updateParams & OFFSET_OF_PR) ||
26201 + (p_Manip->updateParams & HW_PORT_ID)))
26202 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has be updated"));
26203 +
26204 + fmPortGetSetCcParams.getCcParams.type = p_Manip->shadowUpdateParams;
26205 + fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNEN;
26206 + fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_POP_TO_N_STEP | NIA_ENG_FM_CTL;
26207 +
26208 + err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
26209 + if (err)
26210 + RETURN_ERROR(MAJOR, err, NO_MSG);
26211 +
26212 + if (fmPortGetSetCcParams.getCcParams.type & NUM_OF_TASKS)
26213 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("NumOfTasks wasn't configured previously"));
26214 + if (fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
26215 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("offset of the data wasn't configured previously"));
26216 + if (fmPortGetSetCcParams.getCcParams.type & HW_PORT_ID)
26217 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("hwPortId wasn't updated"));
26218 + }
26219 +
26220 + if (p_Manip->updateParams)
26221 + {
26222 + if (p_Manip->updateParams & NUM_OF_TASKS)
26223 + {
26224 + /*recommendation of Microcode team - (maxNumFramesInProcess * 2) */
26225 + size = (uint16_t)(p_Manip->capwapFragParams.maxNumFramesInProcess*2 + fmPortGetSetCcParams.getCcParams.numOfTasks);
26226 + if (size > 255)
26227 + RETURN_ERROR(MAJOR,E_INVALID_VALUE, ("numOfOpenReassmEntries + numOfTasks per port can not be greater than 256"));
26228 +
26229 + p_Manip->capwapFragParams.numOfTasks = fmPortGetSetCcParams.getCcParams.numOfTasks;
26230 +
26231 + /*p_ReassmFrmDescrIndxPoolTbl*/
26232 + p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl =
26233 + (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
26234 + (uint32_t)(size + 1),
26235 + 4);
26236 + if (!p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl)
26237 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for CAPWAP Reassembly frame buffer index pool table"));
26238 +
26239 + MemSet8(p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl, 0, (uint32_t)(size + 1));
26240 +
26241 + for ( i = 0; i < size; i++)
26242 + WRITE_UINT8(*(uint8_t *)PTR_MOVE(p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl, i), (uint8_t)(i+1));
26243 +
26244 + tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl) - p_FmPcd->physicalMuramBase);
26245 +
26246 + WRITE_UINT32(p_ReassmTbl->reasmFrmDescIndexPoolTblPtr, tmpReg32);
26247 +
26248 + /*p_ReassmFrmDescrPoolTbl*/
26249 + p_Manip->capwapFragParams.p_ReassmFrmDescrPoolTbl =
26250 + (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
26251 + (uint32_t)((size + 1) * FM_PCD_MANIP_CAPWAP_REASM_RFD_SIZE),
26252 + 4);
26253 +
26254 + if (!p_Manip->capwapFragParams.p_ReassmFrmDescrPoolTbl)
26255 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for CAPWAP Reassembly frame buffer pool table"));
26256 +
26257 + MemSet8(p_Manip->capwapFragParams.p_ReassmFrmDescrPoolTbl, 0, (uint32_t)((size +1)* FM_PCD_MANIP_CAPWAP_REASM_RFD_SIZE));
26258 +
26259 + tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->capwapFragParams.p_ReassmFrmDescrPoolTbl) - p_FmPcd->physicalMuramBase);
26260 +
26261 + WRITE_UINT32(p_ReassmTbl->reasmFrmDescPoolTblPtr, tmpReg32);
26262 +
26263 + /*p_TimeOutTbl*/
26264 +
26265 + p_Manip->capwapFragParams.p_TimeOutTbl =
26266 + (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
26267 + (uint32_t)((size + 1)* FM_PCD_MANIP_CAPWAP_REASM_TIME_OUT_ENTRY_SIZE),
26268 + 4);
26269 +
26270 + if (!p_Manip->capwapFragParams.p_TimeOutTbl)
26271 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for CAPWAP Reassembly timeout table"));
26272 +
26273 + MemSet8(p_Manip->capwapFragParams.p_TimeOutTbl, 0, (uint16_t)((size + 1)*FM_PCD_MANIP_CAPWAP_REASM_TIME_OUT_ENTRY_SIZE));
26274 +
26275 + tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->capwapFragParams.p_TimeOutTbl) - p_FmPcd->physicalMuramBase);
26276 + WRITE_UINT32(p_ReassmTbl->timeOutTblPtr, tmpReg32);
26277 +
26278 + p_Manip->updateParams &= ~NUM_OF_TASKS;
26279 + p_Manip->shadowUpdateParams |= NUM_OF_TASKS;
26280 + }
26281 +
26282 + if (p_Manip->updateParams & OFFSET_OF_DATA)
26283 + {
26284 + p_Manip->capwapFragParams.dataOffset = fmPortGetSetCcParams.getCcParams.dataOffset;
26285 + tmpReg32 = GET_UINT32(p_ReassmTbl->mode);
26286 + tmpReg32|= p_Manip->capwapFragParams.dataOffset;
26287 + WRITE_UINT32(p_ReassmTbl->mode, tmpReg32);
26288 + p_Manip->updateParams &= ~OFFSET_OF_DATA;
26289 + p_Manip->shadowUpdateParams |= OFFSET_OF_DATA;
26290 + }
26291 +
26292 + if (!(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_PR))
26293 + {
26294 + p_Manip->capwapFragParams.prOffset = fmPortGetSetCcParams.getCcParams.prOffset;
26295 +
26296 + tmpReg32 = GET_UINT32(p_ReassmTbl->mode);
26297 + tmpReg32|= FM_PCD_MANIP_CAPWAP_REASM_PR_COPY;
26298 + WRITE_UINT32(p_ReassmTbl->mode, tmpReg32);
26299 +
26300 + tmpReg32 = GET_UINT32(p_ReassmTbl->intStatsTblPtr);
26301 + tmpReg32 |= (uint32_t)p_Manip->capwapFragParams.prOffset << 24;
26302 + WRITE_UINT32(p_ReassmTbl->intStatsTblPtr, tmpReg32);
26303 + p_Manip->updateParams &= ~OFFSET_OF_PR;
26304 + p_Manip->shadowUpdateParams |= OFFSET_OF_PR;
26305 + }
26306 + else
26307 + {
26308 + p_Manip->capwapFragParams.prOffset = 0xff;
26309 + p_Manip->updateParams &= ~OFFSET_OF_PR;
26310 + p_Manip->shadowUpdateParams |= OFFSET_OF_PR;
26311 + }
26312 +
26313 + p_Manip->capwapFragParams.hwPortId = fmPortGetSetCcParams.getCcParams.hardwarePortId;
26314 + p_Manip->updateParams &= ~HW_PORT_ID;
26315 + p_Manip->shadowUpdateParams |= HW_PORT_ID;
26316 +
26317 + /*timeout hc */
26318 + ccCapwapReassmTimeoutParams.fqidForTimeOutFrames = p_Manip->capwapFragParams.fqidForTimeOutFrames;
26319 + ccCapwapReassmTimeoutParams.portIdAndCapwapReassmTbl = (uint32_t)p_Manip->capwapFragParams.hwPortId << 24;
26320 + ccCapwapReassmTimeoutParams.portIdAndCapwapReassmTbl |= (uint32_t)((XX_VirtToPhys(p_ReassmTbl) - p_FmPcd->physicalMuramBase));
26321 + ccCapwapReassmTimeoutParams.timeoutRequestTime = (((uint32_t)1<<p_Manip->capwapFragParams.bitFor1Micro) * p_Manip->capwapFragParams.timeoutRoutineRequestTime)/2;
26322 + return FmHcPcdCcCapwapTimeoutReassm(p_FmPcd->h_Hc,&ccCapwapReassmTimeoutParams);
26323 + }
26324 +
26325 + else if (validate)
26326 + {
26327 + if (fmPortGetSetCcParams.getCcParams.hardwarePortId != p_Manip->capwapFragParams.hwPortId)
26328 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Reassembly manipulation previously was assigned to another port"));
26329 + if (fmPortGetSetCcParams.getCcParams.numOfTasks != p_Manip->capwapFragParams.numOfTasks)
26330 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfTasks for this manipulation previously was defined by another value "));
26331 +
26332 + if (!(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_PR))
26333 + {
26334 + if (p_Manip->capwapFragParams.prOffset != fmPortGetSetCcParams.getCcParams.prOffset)
26335 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Parse result offset previously was defined by another value "));
26336 + }
26337 + else
26338 + {
26339 + if (p_Manip->capwapFragParams.prOffset != 0xff)
26340 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Parse result offset previously was defined by another value "));
26341 + }
26342 + if (fmPortGetSetCcParams.getCcParams.dataOffset != p_Manip->capwapFragParams.dataOffset)
26343 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Data offset previously was defined by another value "));
26344 + }
26345 +
26346 + return E_OK;
26347 +}
26348 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
26349 +
26350 +t_Error FmPcdRegisterReassmPort(t_Handle h_FmPcd, t_Handle h_ReasmCommonPramTbl)
26351 +{
26352 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
26353 + t_FmPcdCcReassmTimeoutParams ccReassmTimeoutParams = { 0 };
26354 + t_Error err = E_OK;
26355 + uint8_t result;
26356 + uint32_t bitFor1Micro, tsbs, log2num;
26357 +
26358 + ASSERT_COND(p_FmPcd);
26359 + ASSERT_COND(h_ReasmCommonPramTbl);
26360 +
26361 + bitFor1Micro = FmGetTimeStampScale(p_FmPcd->h_Fm);
26362 + if (bitFor1Micro == 0)
26363 + RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("Timestamp scale"));
26364 +
26365 + bitFor1Micro = 32 - bitFor1Micro;
26366 + LOG2(FM_PCD_MANIP_REASM_TIMEOUT_THREAD_THRESH, log2num);
26367 + tsbs = bitFor1Micro - log2num;
26368 +
26369 + ccReassmTimeoutParams.iprcpt = (uint32_t)(XX_VirtToPhys(
26370 + h_ReasmCommonPramTbl) - p_FmPcd->physicalMuramBase);
26371 + ccReassmTimeoutParams.tsbs = (uint8_t)tsbs;
26372 + ccReassmTimeoutParams.activate = TRUE;
26373 + if ((err = FmHcPcdCcTimeoutReassm(p_FmPcd->h_Hc, &ccReassmTimeoutParams,
26374 + &result)) != E_OK)
26375 + RETURN_ERROR(MAJOR, err, NO_MSG);
26376 +
26377 + switch (result)
26378 + {
26379 + case (0):
26380 + return E_OK;
26381 + case (1):
26382 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("failed to allocate TNUM"));
26383 + case (2):
26384 + RETURN_ERROR(
26385 + MAJOR, E_NO_MEMORY,
26386 + ("failed to allocate internal buffer from the HC-Port"));
26387 + case (3):
26388 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
26389 + ("'Disable Timeout Task' with invalid IPRCPT"));
26390 + case (4):
26391 + RETURN_ERROR(MAJOR, E_FULL, ("too many timeout tasks"));
26392 + case (5):
26393 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("invalid sub command"));
26394 + default:
26395 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
26396 + }
26397 + return E_OK;
26398 +}
26399 +
26400 +static t_Error CreateReassCommonTable(t_FmPcdManip *p_Manip)
26401 +{
26402 + uint32_t tmpReg32 = 0, i, bitFor1Micro;
26403 + uint64_t tmpReg64, size;
26404 + t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
26405 + t_Error err = E_OK;
26406 +
26407 + bitFor1Micro = FmGetTimeStampScale(p_FmPcd->h_Fm);
26408 + if (bitFor1Micro == 0)
26409 + RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("Timestamp scale"));
26410 +
26411 + /* Allocation of the Reassembly Common Parameters table. This table is located in the
26412 + MURAM. Its size is 64 bytes and its base address should be 8-byte aligned. */
26413 + p_Manip->reassmParams.p_ReassCommonTbl =
26414 + (t_ReassCommonTbl *)FM_MURAM_AllocMem(
26415 + p_FmPcd->h_FmMuram,
26416 + FM_PCD_MANIP_REASM_COMMON_PARAM_TABLE_SIZE,
26417 + FM_PCD_MANIP_REASM_COMMON_PARAM_TABLE_ALIGN);
26418 +
26419 + if (!p_Manip->reassmParams.p_ReassCommonTbl)
26420 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
26421 + ("MURAM alloc for Reassembly common parameters table"));
26422 +
26423 + MemSet8(p_Manip->reassmParams.p_ReassCommonTbl, 0,
26424 + FM_PCD_MANIP_REASM_COMMON_PARAM_TABLE_SIZE);
26425 +
26426 + /* Setting the TimeOut Mode.*/
26427 + tmpReg32 = 0;
26428 + if (p_Manip->reassmParams.timeOutMode
26429 + == e_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAMES)
26430 + tmpReg32 |= FM_PCD_MANIP_REASM_TIME_OUT_BETWEEN_FRAMES;
26431 +
26432 + /* Setting TimeOut FQID - Frames that time out are enqueued to this FQID.
26433 + In order to cause TimeOut frames to be discarded, this queue should be configured accordingly*/
26434 + tmpReg32 |= p_Manip->reassmParams.fqidForTimeOutFrames;
26435 + WRITE_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->timeoutModeAndFqid,
26436 + tmpReg32);
26437 +
26438 + /* Calculation the size of IP Reassembly Frame Descriptor - number of frames that are allowed to be reassembled simultaneously + 129.*/
26439 + size = p_Manip->reassmParams.maxNumFramesInProcess + 129;
26440 +
26441 + /*Allocation of IP Reassembly Frame Descriptor Indexes Pool - This pool resides in the MURAM */
26442 + p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr =
26443 + PTR_TO_UINT(FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
26444 + (uint32_t)(size * 2),
26445 + 256));
26446 + if (!p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr)
26447 + RETURN_ERROR(
26448 + MAJOR, E_NO_MEMORY,
26449 + ("MURAM alloc for Reassembly frame descriptor indexes pool"));
26450 +
26451 + MemSet8(UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr),
26452 + 0, (uint32_t)(size * 2));
26453 +
26454 + /* The entries in IP Reassembly Frame Descriptor Indexes Pool contains indexes starting with 1 up to
26455 + the maximum number of frames that are allowed to be reassembled simultaneously + 128.
26456 + The last entry in this pool must contain the index zero*/
26457 + for (i = 0; i < (size - 1); i++)
26458 + WRITE_UINT16(
26459 + *(uint16_t *)PTR_MOVE(UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr), (i<<1)),
26460 + (uint16_t)(i+1));
26461 +
26462 + /* Sets the IP Reassembly Frame Descriptor Indexes Pool offset from MURAM */
26463 + tmpReg32 = (uint32_t)(XX_VirtToPhys(
26464 + UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr))
26465 + - p_FmPcd->physicalMuramBase);
26466 + WRITE_UINT32(
26467 + p_Manip->reassmParams.p_ReassCommonTbl->reassFrmDescIndexPoolTblPtr,
26468 + tmpReg32);
26469 +
26470 + /* Allocation of the Reassembly Frame Descriptors Pool - This pool resides in external memory.
26471 + The number of entries in this pool should be equal to the number of entries in IP Reassembly Frame Descriptor Indexes Pool.*/
26472 + p_Manip->reassmParams.reassFrmDescrPoolTblAddr =
26473 + PTR_TO_UINT(XX_MallocSmart((uint32_t)(size * 64), p_Manip->reassmParams.dataMemId, 64));
26474 +
26475 + if (!p_Manip->reassmParams.reassFrmDescrPoolTblAddr)
26476 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation FAILED"));
26477 +
26478 + MemSet8(UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrPoolTblAddr), 0,
26479 + (uint32_t)(size * 64));
26480 +
26481 + /* Sets the Reassembly Frame Descriptors Pool and liodn offset*/
26482 + tmpReg64 = (uint64_t)(XX_VirtToPhys(
26483 + UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrPoolTblAddr)));
26484 + tmpReg64 |= ((uint64_t)(p_Manip->reassmParams.dataLiodnOffset
26485 + & FM_PCD_MANIP_REASM_LIODN_MASK)
26486 + << (uint64_t)FM_PCD_MANIP_REASM_LIODN_SHIFT);
26487 + tmpReg64 |= ((uint64_t)(p_Manip->reassmParams.dataLiodnOffset
26488 + & FM_PCD_MANIP_REASM_ELIODN_MASK)
26489 + << (uint64_t)FM_PCD_MANIP_REASM_ELIODN_SHIFT);
26490 + WRITE_UINT32(
26491 + p_Manip->reassmParams.p_ReassCommonTbl->liodnAndReassFrmDescPoolPtrHi,
26492 + (uint32_t)(tmpReg64 >> 32));
26493 + WRITE_UINT32(
26494 + p_Manip->reassmParams.p_ReassCommonTbl->reassFrmDescPoolPtrLow,
26495 + (uint32_t)tmpReg64);
26496 +
26497 + /*Allocation of the TimeOut table - This table resides in the MURAM.
26498 + The number of entries in this table is identical to the number of entries in the Reassembly Frame Descriptors Pool*/
26499 + p_Manip->reassmParams.timeOutTblAddr =
26500 + PTR_TO_UINT(FM_MURAM_AllocMem(p_FmPcd->h_FmMuram, (uint32_t)(size * 8),8));
26501 +
26502 + if (!p_Manip->reassmParams.timeOutTblAddr)
26503 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
26504 + ("MURAM alloc for Reassembly timeout table"));
26505 +
26506 + MemSet8(UINT_TO_PTR(p_Manip->reassmParams.timeOutTblAddr), 0,
26507 + (uint16_t)(size * 8));
26508 +
26509 + /* Sets the TimeOut table offset from MURAM */
26510 + tmpReg32 = (uint32_t)(XX_VirtToPhys(
26511 + UINT_TO_PTR(p_Manip->reassmParams.timeOutTblAddr))
26512 + - p_FmPcd->physicalMuramBase);
26513 + WRITE_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->timeOutTblPtr,
26514 + tmpReg32);
26515 +
26516 + /* Sets the Expiration Delay */
26517 + tmpReg32 = 0;
26518 + tmpReg32 |= (((uint32_t)(1 << bitFor1Micro))
26519 + * p_Manip->reassmParams.timeoutThresholdForReassmProcess);
26520 + WRITE_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->expirationDelay,
26521 + tmpReg32);
26522 +
26523 + err = FmPcdRegisterReassmPort(p_FmPcd,
26524 + p_Manip->reassmParams.p_ReassCommonTbl);
26525 + if (err != E_OK)
26526 + {
26527 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
26528 + p_Manip->reassmParams.p_ReassCommonTbl);
26529 + RETURN_ERROR(MAJOR, err, ("port registration"));
26530 + }
26531 +
26532 + return err;
26533 +}
26534 +
26535 +static t_Error CreateReassTable(t_FmPcdManip *p_Manip, e_NetHeaderType hdr)
26536 +{
26537 + t_FmPcd *p_FmPcd = p_Manip->h_FmPcd;
26538 + uint32_t tmpReg32, autoLearnHashTblSize;
26539 + uint32_t numOfWays, setSize, setSizeCode, keySize;
26540 + uint32_t waySize, numOfSets, numOfEntries;
26541 + uint64_t tmpReg64;
26542 + uint16_t minFragSize;
26543 + uint16_t maxReassemSize;
26544 + uintptr_t *p_AutoLearnHashTblAddr, *p_AutoLearnSetLockTblAddr;
26545 + t_ReassTbl **p_ReassTbl;
26546 +
26547 + switch (hdr)
26548 + {
26549 + case HEADER_TYPE_IPv4:
26550 + p_ReassTbl = &p_Manip->reassmParams.ip.p_Ipv4ReassTbl;
26551 + p_AutoLearnHashTblAddr =
26552 + &p_Manip->reassmParams.ip.ipv4AutoLearnHashTblAddr;
26553 + p_AutoLearnSetLockTblAddr =
26554 + &p_Manip->reassmParams.ip.ipv4AutoLearnSetLockTblAddr;
26555 + minFragSize = p_Manip->reassmParams.ip.minFragSize[0];
26556 + maxReassemSize = 0;
26557 + numOfWays = p_Manip->reassmParams.ip.numOfFramesPerHashEntry[0];
26558 + keySize = 4 + 4 + 1 + 2; /* 3-tuple + IP-Id */
26559 + break;
26560 + case HEADER_TYPE_IPv6:
26561 + p_ReassTbl = &p_Manip->reassmParams.ip.p_Ipv6ReassTbl;
26562 + p_AutoLearnHashTblAddr =
26563 + &p_Manip->reassmParams.ip.ipv6AutoLearnHashTblAddr;
26564 + p_AutoLearnSetLockTblAddr =
26565 + &p_Manip->reassmParams.ip.ipv6AutoLearnSetLockTblAddr;
26566 + minFragSize = p_Manip->reassmParams.ip.minFragSize[1];
26567 + maxReassemSize = 0;
26568 + numOfWays = p_Manip->reassmParams.ip.numOfFramesPerHashEntry[1];
26569 + keySize = 16 + 16 + 4; /* 2-tuple + IP-Id */
26570 + if (numOfWays > e_FM_PCD_MANIP_SIX_WAYS_HASH)
26571 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("num of ways"));
26572 + break;
26573 + case HEADER_TYPE_CAPWAP:
26574 + p_ReassTbl = &p_Manip->reassmParams.capwap.p_ReassTbl;
26575 + p_AutoLearnHashTblAddr =
26576 + &p_Manip->reassmParams.capwap.autoLearnHashTblAddr;
26577 + p_AutoLearnSetLockTblAddr =
26578 + &p_Manip->reassmParams.capwap.autoLearnSetLockTblAddr;
26579 + minFragSize = 0;
26580 + maxReassemSize = p_Manip->reassmParams.capwap.maxRessembledsSize;
26581 + numOfWays = p_Manip->reassmParams.capwap.numOfFramesPerHashEntry;
26582 + keySize = 4;
26583 + break;
26584 + default:
26585 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("header type"));
26586 + }
26587 + keySize += 2; /* 2 bytes reserved for RFDIndex */
26588 +#if (DPAA_VERSION >= 11)
26589 + keySize += 2; /* 2 bytes reserved */
26590 +#endif /* (DPAA_VERSION >= 11) */
26591 + waySize = ROUND_UP(keySize, 8);
26592 +
26593 + /* Allocates the Reassembly Parameters Table - This table is located in the MURAM.*/
26594 + *p_ReassTbl = (t_ReassTbl *)FM_MURAM_AllocMem(
26595 + p_FmPcd->h_FmMuram, FM_PCD_MANIP_REASM_TABLE_SIZE,
26596 + FM_PCD_MANIP_REASM_TABLE_ALIGN);
26597 + if (!*p_ReassTbl)
26598 + RETURN_ERROR( MAJOR, E_NO_MEMORY,
26599 + ("MURAM alloc for Reassembly specific parameters table"));
26600 + memset(*p_ReassTbl, 0, sizeof(t_ReassTbl));
26601 +
26602 + /* Sets the Reassembly common Parameters table offset from MURAM in the Reassembly Table descriptor*/
26603 + tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->reassmParams.p_ReassCommonTbl)
26604 + - p_FmPcd->physicalMuramBase);
26605 + WRITE_UINT32((*p_ReassTbl)->reassCommonPrmTblPtr, tmpReg32);
26606 +
26607 + /* Calculate set size (set size is rounded-up to next power of 2) */
26608 + NEXT_POWER_OF_2(numOfWays * waySize, setSize);
26609 +
26610 + /* Get set size code */
26611 + LOG2(setSize, setSizeCode);
26612 +
26613 + /* Sets ways number and set size code */
26614 + WRITE_UINT16((*p_ReassTbl)->waysNumAndSetSize,
26615 + (uint16_t)((numOfWays << 8) | setSizeCode));
26616 +
26617 + /* It is recommended that the total number of entries in this table
26618 + (number of sets * number of ways) will be twice the number of frames that
26619 + are expected to be reassembled simultaneously.*/
26620 + numOfEntries = (uint32_t)(p_Manip->reassmParams.maxNumFramesInProcess * 2);
26621 +
26622 + /* sets number calculation - number of entries = number of sets * number of ways */
26623 + numOfSets = numOfEntries / numOfWays;
26624 +
26625 + /* Sets AutoLearnHashKeyMask*/
26626 + NEXT_POWER_OF_2(numOfSets, numOfSets);
26627 +
26628 + WRITE_UINT16((*p_ReassTbl)->autoLearnHashKeyMask,
26629 + (uint16_t)(numOfSets - 1));
26630 +
26631 + /* Allocation of Reassembly Automatic Learning Hash Table - This table resides in external memory.
26632 + The size of this table is determined by the number of sets and the set size.
26633 + Table size = set size * number of sets
26634 + This table base address should be aligned to SetSize.*/
26635 + autoLearnHashTblSize = numOfSets * setSize;
26636 +
26637 + *p_AutoLearnHashTblAddr =
26638 + PTR_TO_UINT(XX_MallocSmart(autoLearnHashTblSize, p_Manip->reassmParams.dataMemId, setSize));
26639 + if (!*p_AutoLearnHashTblAddr)
26640 + {
26641 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, *p_ReassTbl);
26642 + *p_ReassTbl = NULL;
26643 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation FAILED"));
26644 + }
26645 + MemSet8(UINT_TO_PTR(*p_AutoLearnHashTblAddr), 0, autoLearnHashTblSize);
26646 +
26647 + /* Sets the Reassembly Automatic Learning Hash Table and liodn offset */
26648 + tmpReg64 = ((uint64_t)(p_Manip->reassmParams.dataLiodnOffset
26649 + & FM_PCD_MANIP_REASM_LIODN_MASK)
26650 + << (uint64_t)FM_PCD_MANIP_REASM_LIODN_SHIFT);
26651 + tmpReg64 |= ((uint64_t)(p_Manip->reassmParams.dataLiodnOffset
26652 + & FM_PCD_MANIP_REASM_ELIODN_MASK)
26653 + << (uint64_t)FM_PCD_MANIP_REASM_ELIODN_SHIFT);
26654 + tmpReg64 |= XX_VirtToPhys(UINT_TO_PTR(*p_AutoLearnHashTblAddr));
26655 + WRITE_UINT32( (*p_ReassTbl)->liodnAlAndAutoLearnHashTblPtrHi,
26656 + (uint32_t)(tmpReg64 >> 32));
26657 + WRITE_UINT32((*p_ReassTbl)->autoLearnHashTblPtrLow, (uint32_t)tmpReg64);
26658 +
26659 + /* Allocation of the Set Lock table - This table resides in external memory
26660 + The size of this table is (number of sets in the Reassembly Automatic Learning Hash table)*4 bytes.
26661 + This table resides in external memory and its base address should be 4-byte aligned */
26662 + *p_AutoLearnSetLockTblAddr =
26663 + PTR_TO_UINT(XX_MallocSmart((uint32_t)(numOfSets * 4), p_Manip->reassmParams.dataMemId, 4));
26664 + if (!*p_AutoLearnSetLockTblAddr)
26665 + {
26666 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, *p_ReassTbl);
26667 + *p_ReassTbl = NULL;
26668 + XX_FreeSmart(UINT_TO_PTR(*p_AutoLearnHashTblAddr));
26669 + *p_AutoLearnHashTblAddr = 0;
26670 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation FAILED"));
26671 + }
26672 + MemSet8(UINT_TO_PTR(*p_AutoLearnSetLockTblAddr), 0, (numOfSets * 4));
26673 +
26674 + /* sets Set Lock table pointer and liodn offset*/
26675 + tmpReg64 = ((uint64_t)(p_Manip->reassmParams.dataLiodnOffset
26676 + & FM_PCD_MANIP_REASM_LIODN_MASK)
26677 + << (uint64_t)FM_PCD_MANIP_REASM_LIODN_SHIFT);
26678 + tmpReg64 |= ((uint64_t)(p_Manip->reassmParams.dataLiodnOffset
26679 + & FM_PCD_MANIP_REASM_ELIODN_MASK)
26680 + << (uint64_t)FM_PCD_MANIP_REASM_ELIODN_SHIFT);
26681 + tmpReg64 |= XX_VirtToPhys(UINT_TO_PTR(*p_AutoLearnSetLockTblAddr));
26682 + WRITE_UINT32( (*p_ReassTbl)->liodnSlAndAutoLearnSetLockTblPtrHi,
26683 + (uint32_t)(tmpReg64 >> 32));
26684 + WRITE_UINT32((*p_ReassTbl)->autoLearnSetLockTblPtrLow, (uint32_t)tmpReg64);
26685 +
26686 + /* Sets user's requested minimum fragment size (in Bytes) for First/Middle fragment */
26687 + WRITE_UINT16((*p_ReassTbl)->minFragSize, minFragSize);
26688 +
26689 + WRITE_UINT16((*p_ReassTbl)->maxReassemblySize, maxReassemSize);
26690 +
26691 + return E_OK;
26692 +}
26693 +
26694 +static t_Error UpdateInitReasm(t_Handle h_FmPcd, t_Handle h_PcdParams,
26695 + t_Handle h_FmPort, t_FmPcdManip *p_Manip,
26696 + t_Handle h_Ad, bool validate)
26697 +{
26698 + t_FmPortGetSetCcParams fmPortGetSetCcParams;
26699 + uint32_t tmpReg32;
26700 + t_Error err;
26701 + t_FmPortPcdParams *p_PcdParams = (t_FmPortPcdParams *)h_PcdParams;
26702 +#if (DPAA_VERSION >= 11)
26703 + t_FmPcdCtrlParamsPage *p_ParamsPage;
26704 +#endif /* (DPAA_VERSION >= 11) */
26705 +
26706 + SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
26707 + SANITY_CHECK_RETURN_ERROR(!p_Manip->frag, E_INVALID_HANDLE);
26708 + SANITY_CHECK_RETURN_ERROR(
26709 + (p_Manip->opcode == HMAN_OC_IP_REASSEMBLY) || (p_Manip->opcode == HMAN_OC_CAPWAP_REASSEMBLY),
26710 + E_INVALID_STATE);
26711 + SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
26712 + SANITY_CHECK_RETURN_ERROR(!p_Manip->updateParams || h_PcdParams,
26713 + E_INVALID_HANDLE);
26714 +
26715 + UNUSED(h_Ad);
26716 +
26717 + if (!p_Manip->updateParams)
26718 + return E_OK;
26719 +
26720 + if (p_Manip->h_FmPcd != h_FmPcd)
26721 + RETURN_ERROR(
26722 + MAJOR, E_INVALID_STATE,
26723 + ("handler of PCD previously was initiated by different value"));
26724 +
26725 + if (p_Manip->updateParams)
26726 + {
26727 + if ((!(p_Manip->updateParams
26728 + & (NUM_OF_TASKS | NUM_OF_EXTRA_TASKS | DISCARD_MASK)))
26729 + || ((p_Manip->shadowUpdateParams
26730 + & (NUM_OF_TASKS | NUM_OF_EXTRA_TASKS | DISCARD_MASK))))
26731 + RETURN_ERROR(
26732 + MAJOR, E_INVALID_STATE,
26733 + ("in this stage parameters from Port has not be updated"));
26734 +
26735 + fmPortGetSetCcParams.setCcParams.type = 0;
26736 + if (p_Manip->opcode == HMAN_OC_CAPWAP_REASSEMBLY)
26737 + {
26738 + fmPortGetSetCcParams.setCcParams.type |= UPDATE_OFP_DPTE;
26739 + fmPortGetSetCcParams.setCcParams.ofpDpde = 0xF;
26740 + }
26741 + fmPortGetSetCcParams.getCcParams.type = p_Manip->updateParams | FM_REV;
26742 + if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams))
26743 + != E_OK)
26744 + RETURN_ERROR(MAJOR, err, NO_MSG);
26745 + if (fmPortGetSetCcParams.getCcParams.type
26746 + & (NUM_OF_TASKS | NUM_OF_EXTRA_TASKS | DISCARD_MASK | FM_REV))
26747 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
26748 + ("offset of the data wasn't configured previously"));
26749 + if (p_Manip->updateParams
26750 + & (NUM_OF_TASKS | NUM_OF_EXTRA_TASKS | DISCARD_MASK))
26751 + {
26752 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
26753 + uint8_t *p_Ptr, i, totalNumOfTnums;
26754 +
26755 + totalNumOfTnums =
26756 + (uint8_t)(fmPortGetSetCcParams.getCcParams.numOfTasks
26757 + + fmPortGetSetCcParams.getCcParams.numOfExtraTasks);
26758 +
26759 + p_Manip->reassmParams.internalBufferPoolAddr =
26760 + PTR_TO_UINT(FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
26761 + (uint32_t)(totalNumOfTnums * BMI_FIFO_UNITS),
26762 + BMI_FIFO_UNITS));
26763 + if (!p_Manip->reassmParams.internalBufferPoolAddr)
26764 + RETURN_ERROR(
26765 + MAJOR, E_NO_MEMORY,
26766 + ("MURAM alloc for Reassembly internal buffers pool"));
26767 + MemSet8(
26768 + UINT_TO_PTR(p_Manip->reassmParams.internalBufferPoolAddr),
26769 + 0, (uint32_t)(totalNumOfTnums * BMI_FIFO_UNITS));
26770 +
26771 + p_Manip->reassmParams.internalBufferPoolManagementIndexAddr =
26772 + PTR_TO_UINT(FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
26773 + (uint32_t)(5 + totalNumOfTnums),
26774 + 4));
26775 + if (!p_Manip->reassmParams.internalBufferPoolManagementIndexAddr)
26776 + RETURN_ERROR(
26777 + MAJOR,
26778 + E_NO_MEMORY,
26779 + ("MURAM alloc for Reassembly internal buffers management"));
26780 +
26781 + p_Ptr =
26782 + (uint8_t*)UINT_TO_PTR(p_Manip->reassmParams.internalBufferPoolManagementIndexAddr);
26783 + WRITE_UINT32(
26784 + *(uint32_t*)p_Ptr,
26785 + (uint32_t)(XX_VirtToPhys(UINT_TO_PTR(p_Manip->reassmParams.internalBufferPoolAddr)) - p_FmPcd->physicalMuramBase));
26786 + for (i = 0, p_Ptr += 4; i < totalNumOfTnums; i++, p_Ptr++)
26787 + WRITE_UINT8(*p_Ptr, i);
26788 + WRITE_UINT8(*p_Ptr, 0xFF);
26789 +
26790 + tmpReg32 =
26791 + (4 << FM_PCD_MANIP_REASM_COMMON_INT_BUFFER_IDX_SHIFT)
26792 + | ((uint32_t)(XX_VirtToPhys(
26793 + UINT_TO_PTR(p_Manip->reassmParams.internalBufferPoolManagementIndexAddr))
26794 + - p_FmPcd->physicalMuramBase));
26795 + WRITE_UINT32(
26796 + p_Manip->reassmParams.p_ReassCommonTbl->internalBufferManagement,
26797 + tmpReg32);
26798 +
26799 + p_Manip->updateParams &= ~(NUM_OF_TASKS | NUM_OF_EXTRA_TASKS
26800 + | DISCARD_MASK);
26801 + p_Manip->shadowUpdateParams |= (NUM_OF_TASKS | NUM_OF_EXTRA_TASKS
26802 + | DISCARD_MASK);
26803 + }
26804 + }
26805 +
26806 + if (p_Manip->opcode == HMAN_OC_CAPWAP_REASSEMBLY)
26807 + {
26808 + if (p_Manip->reassmParams.capwap.h_Scheme)
26809 + {
26810 + p_PcdParams->p_KgParams->h_Schemes[p_PcdParams->p_KgParams->numOfSchemes] =
26811 + p_Manip->reassmParams.capwap.h_Scheme;
26812 + p_PcdParams->p_KgParams->numOfSchemes++;
26813 + }
26814 +
26815 + }
26816 + else
26817 + {
26818 + if (p_Manip->reassmParams.ip.h_Ipv4Scheme)
26819 + {
26820 + p_PcdParams->p_KgParams->h_Schemes[p_PcdParams->p_KgParams->numOfSchemes] =
26821 + p_Manip->reassmParams.ip.h_Ipv4Scheme;
26822 + p_PcdParams->p_KgParams->numOfSchemes++;
26823 + }
26824 + if (p_Manip->reassmParams.ip.h_Ipv6Scheme)
26825 + {
26826 + p_PcdParams->p_KgParams->h_Schemes[p_PcdParams->p_KgParams->numOfSchemes] =
26827 + p_Manip->reassmParams.ip.h_Ipv6Scheme;
26828 + p_PcdParams->p_KgParams->numOfSchemes++;
26829 + }
26830 +#if (DPAA_VERSION >= 11)
26831 + if (fmPortGetSetCcParams.getCcParams.revInfo.majorRev >= 6)
26832 + {
26833 + if ((err = FmPortSetGprFunc(h_FmPort, e_FM_PORT_GPR_MURAM_PAGE,
26834 + (void**)&p_ParamsPage)) != E_OK)
26835 + RETURN_ERROR(MAJOR, err, NO_MSG);
26836 +
26837 + tmpReg32 = NIA_ENG_KG;
26838 + if (p_Manip->reassmParams.ip.h_Ipv4Scheme)
26839 + {
26840 + tmpReg32 |= NIA_KG_DIRECT;
26841 + tmpReg32 |= NIA_KG_CC_EN;
26842 + tmpReg32 |= FmPcdKgGetSchemeId(
26843 + p_Manip->reassmParams.ip.h_Ipv4Scheme);
26844 + WRITE_UINT32(p_ParamsPage->iprIpv4Nia, tmpReg32);
26845 + }
26846 + if (p_Manip->reassmParams.ip.h_Ipv6Scheme)
26847 + {
26848 + tmpReg32 &= ~NIA_AC_MASK;
26849 + tmpReg32 |= NIA_KG_DIRECT;
26850 + tmpReg32 |= NIA_KG_CC_EN;
26851 + tmpReg32 |= FmPcdKgGetSchemeId(
26852 + p_Manip->reassmParams.ip.h_Ipv6Scheme);
26853 + WRITE_UINT32(p_ParamsPage->iprIpv6Nia, tmpReg32);
26854 + }
26855 + }
26856 +#else
26857 + if (fmPortGetSetCcParams.getCcParams.revInfo.majorRev < 6)
26858 + {
26859 + WRITE_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->discardMask,
26860 + fmPortGetSetCcParams.getCcParams.discardMask);
26861 + }
26862 +#endif /* (DPAA_VERSION >= 11) */
26863 + }
26864 + return E_OK;
26865 +}
26866 +
26867 +#if (DPAA_VERSION == 10)
26868 +static t_Error FmPcdFragHcScratchPoolFill(t_Handle h_FmPcd, uint8_t scratchBpid)
26869 +{
26870 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
26871 + t_FmPcdCcFragScratchPoolCmdParams fmPcdCcFragScratchPoolCmdParams;
26872 + t_Error err;
26873 +
26874 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
26875 +
26876 + memset(&fmPcdCcFragScratchPoolCmdParams, 0, sizeof(t_FmPcdCcFragScratchPoolCmdParams));
26877 +
26878 + fmPcdCcFragScratchPoolCmdParams.numOfBuffers = NUM_OF_SCRATCH_POOL_BUFFERS;
26879 + fmPcdCcFragScratchPoolCmdParams.bufferPoolId = scratchBpid;
26880 + if ((err = FmHcPcdCcIpFragScratchPollCmd(p_FmPcd->h_Hc, TRUE, &fmPcdCcFragScratchPoolCmdParams)) != E_OK)
26881 + RETURN_ERROR(MAJOR, err, NO_MSG);
26882 +
26883 + if (fmPcdCcFragScratchPoolCmdParams.numOfBuffers != 0)
26884 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Fill scratch pool failed,"
26885 + "Failed to release %d buffers to the BM (missing FBPRs)",
26886 + fmPcdCcFragScratchPoolCmdParams.numOfBuffers));
26887 +
26888 + return E_OK;
26889 +}
26890 +
26891 +static t_Error FmPcdFragHcScratchPoolEmpty(t_Handle h_FmPcd, uint8_t scratchBpid)
26892 +{
26893 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
26894 + t_FmPcdCcFragScratchPoolCmdParams fmPcdCcFragScratchPoolCmdParams;
26895 + t_Error err;
26896 +
26897 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
26898 +
26899 + memset(&fmPcdCcFragScratchPoolCmdParams, 0, sizeof(t_FmPcdCcFragScratchPoolCmdParams));
26900 +
26901 + fmPcdCcFragScratchPoolCmdParams.bufferPoolId = scratchBpid;
26902 + if ((err = FmHcPcdCcIpFragScratchPollCmd(p_FmPcd->h_Hc, FALSE, &fmPcdCcFragScratchPoolCmdParams)) != E_OK)
26903 + RETURN_ERROR(MAJOR, err, NO_MSG);
26904 +
26905 + return E_OK;
26906 +}
26907 +#endif /* (DPAA_VERSION == 10) */
26908 +
26909 +static void ReleaseManipHandler(t_FmPcdManip *p_Manip, t_FmPcd *p_FmPcd)
26910 +{
26911 + if (p_Manip->h_Ad)
26912 + {
26913 + if (p_Manip->muramAllocate)
26914 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->h_Ad);
26915 + else
26916 + XX_Free(p_Manip->h_Ad);
26917 + p_Manip->h_Ad = NULL;
26918 + }
26919 + if (p_Manip->p_Template)
26920 + {
26921 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->p_Template);
26922 + p_Manip->p_Template = NULL;
26923 + }
26924 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
26925 + if (p_Manip->h_Frag)
26926 + {
26927 + if (p_Manip->capwapFragParams.p_AutoLearnHashTbl)
26928 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
26929 + p_Manip->capwapFragParams.p_AutoLearnHashTbl);
26930 + if (p_Manip->capwapFragParams.p_ReassmFrmDescrPoolTbl)
26931 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
26932 + p_Manip->capwapFragParams.p_ReassmFrmDescrPoolTbl);
26933 + if (p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl)
26934 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
26935 + p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl);
26936 + if (p_Manip->capwapFragParams.p_TimeOutTbl)
26937 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
26938 + p_Manip->capwapFragParams.p_TimeOutTbl);
26939 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->h_Frag);
26940 +
26941 + }
26942 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
26943 + if (p_Manip->frag)
26944 + {
26945 + if (p_Manip->fragParams.p_Frag)
26946 + {
26947 +#if (DPAA_VERSION == 10)
26948 + FmPcdFragHcScratchPoolEmpty((t_Handle)p_FmPcd, p_Manip->fragParams.scratchBpid);
26949 +#endif /* (DPAA_VERSION == 10) */
26950 +
26951 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->fragParams.p_Frag);
26952 + }
26953 + }
26954 + else
26955 + if (p_Manip->reassm)
26956 + {
26957 + FmPcdUnregisterReassmPort(p_FmPcd,
26958 + p_Manip->reassmParams.p_ReassCommonTbl);
26959 +
26960 + if (p_Manip->reassmParams.timeOutTblAddr)
26961 + FM_MURAM_FreeMem(
26962 + p_FmPcd->h_FmMuram,
26963 + UINT_TO_PTR(p_Manip->reassmParams.timeOutTblAddr));
26964 + if (p_Manip->reassmParams.reassFrmDescrPoolTblAddr)
26965 + XX_FreeSmart(
26966 + UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrPoolTblAddr));
26967 + if (p_Manip->reassmParams.p_ReassCommonTbl)
26968 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
26969 + p_Manip->reassmParams.p_ReassCommonTbl);
26970 + if (p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr)
26971 + FM_MURAM_FreeMem(
26972 + p_FmPcd->h_FmMuram,
26973 + UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr));
26974 + if (p_Manip->reassmParams.internalBufferPoolManagementIndexAddr)
26975 + FM_MURAM_FreeMem(
26976 + p_FmPcd->h_FmMuram,
26977 + UINT_TO_PTR(p_Manip->reassmParams.internalBufferPoolManagementIndexAddr));
26978 + if (p_Manip->reassmParams.internalBufferPoolAddr)
26979 + FM_MURAM_FreeMem(
26980 + p_FmPcd->h_FmMuram,
26981 + UINT_TO_PTR(p_Manip->reassmParams.internalBufferPoolAddr));
26982 + if (p_Manip->reassmParams.hdr == HEADER_TYPE_CAPWAP)
26983 + {
26984 +
26985 + }
26986 + else
26987 + {
26988 + if (p_Manip->reassmParams.ip.ipv4AutoLearnHashTblAddr)
26989 + XX_FreeSmart(
26990 + UINT_TO_PTR(p_Manip->reassmParams.ip.ipv4AutoLearnHashTblAddr));
26991 + if (p_Manip->reassmParams.ip.ipv6AutoLearnHashTblAddr)
26992 + XX_FreeSmart(
26993 + UINT_TO_PTR(p_Manip->reassmParams.ip.ipv6AutoLearnHashTblAddr));
26994 + if (p_Manip->reassmParams.ip.ipv4AutoLearnSetLockTblAddr)
26995 + XX_FreeSmart(
26996 + UINT_TO_PTR(p_Manip->reassmParams.ip.ipv4AutoLearnSetLockTblAddr));
26997 + if (p_Manip->reassmParams.ip.ipv6AutoLearnSetLockTblAddr)
26998 + XX_FreeSmart(
26999 + UINT_TO_PTR(p_Manip->reassmParams.ip.ipv6AutoLearnSetLockTblAddr));
27000 + if (p_Manip->reassmParams.ip.p_Ipv4ReassTbl)
27001 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
27002 + p_Manip->reassmParams.ip.p_Ipv4ReassTbl);
27003 + if (p_Manip->reassmParams.ip.p_Ipv6ReassTbl)
27004 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
27005 + p_Manip->reassmParams.ip.p_Ipv6ReassTbl);
27006 + if (p_Manip->reassmParams.ip.h_Ipv6Ad)
27007 + XX_FreeSmart(p_Manip->reassmParams.ip.h_Ipv6Ad);
27008 + if (p_Manip->reassmParams.ip.h_Ipv4Ad)
27009 + XX_FreeSmart(p_Manip->reassmParams.ip.h_Ipv4Ad);
27010 + }
27011 + }
27012 +
27013 + if (p_Manip->p_StatsTbl)
27014 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->p_StatsTbl);
27015 +}
27016 +
27017 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
27018 +static t_Error CheckManipParamsAndSetType(t_FmPcdManip *p_Manip, t_FmPcdManipParams *p_ManipParams)
27019 +{
27020 + if (p_ManipParams->u.hdr.rmv)
27021 + {
27022 + switch (p_ManipParams->u.hdr.rmvParams.type)
27023 + {
27024 + case (e_FM_PCD_MANIP_RMV_BY_HDR):
27025 + switch (p_ManipParams->u.hdr.rmvParams.u.byHdr.type)
27026 + {
27027 + case (e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START) :
27028 + if (p_ManipParams->u.hdr.rmvParams.u.byHdr.u.fromStartByHdr.include)
27029 + {
27030 + switch (p_ManipParams->u.hdr.rmvParams.u.byHdr.u.fromStartByHdr.hdrInfo.hdr)
27031 + {
27032 + case (HEADER_TYPE_CAPWAP_DTLS) :
27033 + p_Manip->opcode = HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST;
27034 + p_Manip->muramAllocate = TRUE;
27035 + if (p_ManipParams->u.hdr.insrt)
27036 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("for CAPWAP_DTLS_HDR remove can not be insrt manipualtion after"));
27037 + if (p_ManipParams->fragOrReasm)
27038 + {
27039 + if (!p_ManipParams->fragOrReasmParams.frag)
27040 + {
27041 + switch (p_ManipParams->fragOrReasmParams.hdr)
27042 + {
27043 + case (HEADER_TYPE_CAPWAP):
27044 + p_Manip->opcode = HMAN_OC_CAPWAP_REASSEMBLY;
27045 + break;
27046 + default:
27047 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("unsupported header for Reassembly"));
27048 + }
27049 + }
27050 + else
27051 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("for this type of manipulation frag can not be TRUE"));
27052 + }
27053 + break;
27054 + default:
27055 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("non valid net header of remove location"));
27056 + }
27057 + }
27058 + else
27059 + {
27060 + switch (p_ManipParams->u.hdr.rmvParams.u.byHdr.u.fromStartByHdr.hdrInfo.hdr)
27061 + {
27062 + case (HEADER_TYPE_CAPWAP_DTLS) :
27063 + case (HEADER_TYPE_CAPWAP) :
27064 + if (p_ManipParams->fragOrReasm || p_ManipParams->u.hdr.insrt)
27065 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("for the type of remove e_FM_PCD_MANIP_RMV_FROM_START_OF_FRAME_TILL_CAPWAP can not be insert or fragOrReasm TRUE"));
27066 + p_Manip->opcode = HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR;
27067 + p_Manip->muramAllocate = TRUE;
27068 + p_ManipParams->u.hdr.insrt = TRUE; //internal frame header
27069 + break;
27070 + default :
27071 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("invalid type of remove manipulation"));
27072 + }
27073 + }
27074 + break;
27075 + default :
27076 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("invalid type of remove manipulation"));
27077 + }
27078 + break;
27079 + default:
27080 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("invalid type of remove manipulation"));
27081 + }
27082 + }
27083 + else if (p_ManipParams->u.hdr.insrt)
27084 + {
27085 + switch (p_ManipParams->u.hdr.insrtParams.type)
27086 + {
27087 + case (e_FM_PCD_MANIP_INSRT_BY_TEMPLATE) :
27088 +
27089 + p_Manip->opcode = HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER;
27090 + p_Manip->muramAllocate = FALSE;
27091 + if (p_ManipParams->fragOrReasm)
27092 + {
27093 + if (p_ManipParams->fragOrReasmParams.frag)
27094 + {
27095 + switch (p_ManipParams->fragOrReasmParams.hdr)
27096 + {
27097 + case (HEADER_TYPE_CAPWAP):
27098 + p_Manip->opcode = HMAN_OC_CAPWAP_FRAGMENTATION;
27099 + break;
27100 + default:
27101 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid header for fragmentation"));
27102 + }
27103 + }
27104 + else
27105 + RETURN_ERROR(MAJOR, E_INVALID_STATE,("can not reach this point"));
27106 + }
27107 + break;
27108 +
27109 + default:
27110 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("for only isert manipulation unsupported type"));
27111 + }
27112 + }
27113 + else if (p_ManipParams->fragOrReasm)
27114 + {
27115 + if (p_ManipParams->fragOrReasmParams.frag)
27116 + {
27117 + switch (p_ManipParams->fragOrReasmParams.hdr)
27118 + {
27119 + case (HEADER_TYPE_CAPWAP):
27120 + p_Manip->opcode = HMAN_OC_CAPWAP_FRAGMENTATION;
27121 + p_Manip->muramAllocate = FALSE;
27122 + break;
27123 + default:
27124 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Unsupported header for fragmentation"));
27125 + }
27126 + }
27127 + else
27128 + {
27129 + switch (p_ManipParams->fragOrReasmParams.hdr)
27130 + {
27131 + case (HEADER_TYPE_CAPWAP):
27132 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Reassembly has to be with additional operation - rmv = TRUE, type of remove - e_FM_PCD_MANIP_RMV_FROM_START_OF_FRAME_INCLUDE_SPECIFIC_LOCATION,type = e_FM_PCD_MANIP_LOC_BY_HDR, hdr = HEADER_TYPE_CAPWAP_DTLS"));
27133 + default:
27134 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Unsupported header for reassembly"));
27135 + }
27136 + }
27137 +
27138 + }
27139 + else
27140 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("User didn't ask for any manipulation"));
27141 +
27142 + p_Manip->insrt = p_ManipParams->u.hdr.insrt;
27143 + p_Manip->rmv = p_ManipParams->u.hdr.rmv;
27144 +
27145 + return E_OK;
27146 +}
27147 +
27148 +#else /* not (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
27149 +static t_Error CheckManipParamsAndSetType(t_FmPcdManip *p_Manip,
27150 + t_FmPcdManipParams *p_ManipParams)
27151 +{
27152 + switch (p_ManipParams->type)
27153 + {
27154 + case e_FM_PCD_MANIP_HDR:
27155 + /* Check that next-manip is not already used */
27156 + if (p_ManipParams->h_NextManip)
27157 + {
27158 + if (!MANIP_IS_FIRST(p_ManipParams->h_NextManip))
27159 + RETURN_ERROR(
27160 + MAJOR, E_INVALID_STATE,
27161 + ("h_NextManip is already a part of another chain"));
27162 + if ((MANIP_GET_TYPE(p_ManipParams->h_NextManip)
27163 + != e_FM_PCD_MANIP_HDR) &&
27164 + (MANIP_GET_TYPE(p_ManipParams->h_NextManip)
27165 + != e_FM_PCD_MANIP_FRAG))
27166 + RETURN_ERROR(
27167 + MAJOR,
27168 + E_NOT_SUPPORTED,
27169 + ("For a Header Manipulation node - no support of h_NextManip of type other than Header Manipulation or Fragmentation."));
27170 + }
27171 +
27172 + if (p_ManipParams->u.hdr.rmv)
27173 + {
27174 + switch (p_ManipParams->u.hdr.rmvParams.type)
27175 + {
27176 + case (e_FM_PCD_MANIP_RMV_BY_HDR):
27177 + switch (p_ManipParams->u.hdr.rmvParams.u.byHdr.type)
27178 + {
27179 + case (e_FM_PCD_MANIP_RMV_BY_HDR_SPECIFIC_L2):
27180 + break;
27181 +#if (DPAA_VERSION >= 11)
27182 + case (e_FM_PCD_MANIP_RMV_BY_HDR_CAPWAP):
27183 + break;
27184 + case (e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START):
27185 + {
27186 + t_Error err;
27187 + uint8_t prsArrayOffset;
27188 +
27189 + err =
27190 + GetPrOffsetByHeaderOrField(
27191 + &p_ManipParams->u.hdr.rmvParams.u.byHdr.u.hdrInfo,
27192 + &prsArrayOffset);
27193 + if (err)
27194 + RETURN_ERROR(MAJOR, err, NO_MSG);
27195 + break;
27196 + }
27197 +#endif /* (DPAA_VERSION >= 11) */
27198 + default:
27199 + RETURN_ERROR(
27200 + MAJOR,
27201 + E_INVALID_STATE,
27202 + ("invalid type of remove manipulation"));
27203 + }
27204 + break;
27205 + case (e_FM_PCD_MANIP_RMV_GENERIC):
27206 + break;
27207 + default:
27208 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
27209 + ("invalid type of remove manipulation"));
27210 + }
27211 + p_Manip->opcode = HMAN_OC;
27212 + p_Manip->muramAllocate = TRUE;
27213 + p_Manip->rmv = TRUE;
27214 + }
27215 + else
27216 + if (p_ManipParams->u.hdr.insrt)
27217 + {
27218 + switch (p_ManipParams->u.hdr.insrtParams.type)
27219 + {
27220 + case (e_FM_PCD_MANIP_INSRT_BY_HDR):
27221 + {
27222 + switch (p_ManipParams->u.hdr.insrtParams.u.byHdr.type)
27223 + {
27224 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2):
27225 + /* nothing to check */
27226 + break;
27227 +#if (DPAA_VERSION >= 11)
27228 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_IP):
27229 + if (p_ManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.insrt.size
27230 + % 4)
27231 + RETURN_ERROR(
27232 + MAJOR,
27233 + E_INVALID_VALUE,
27234 + ("IP inserted header must be of size which is a multiple of four bytes"));
27235 + break;
27236 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP):
27237 + if (p_ManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size
27238 + % 4)
27239 + RETURN_ERROR(
27240 + MAJOR,
27241 + E_INVALID_VALUE,
27242 + ("CAPWAP inserted header must be of size which is a multiple of four bytes"));
27243 + break;
27244 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP):
27245 + case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE):
27246 + if (p_ManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size
27247 + != 8)
27248 + RETURN_ERROR(
27249 + MAJOR,
27250 + E_INVALID_VALUE,
27251 + ("Inserted header must be of size 8"));
27252 + break;
27253 +#endif /* (DPAA_VERSION >= 11) */
27254 + default:
27255 + RETURN_ERROR(
27256 + MAJOR,
27257 + E_INVALID_STATE,
27258 + ("unsupported insert by header type"));
27259 + }
27260 + }
27261 + case (e_FM_PCD_MANIP_INSRT_GENERIC):
27262 + break;
27263 + default:
27264 + RETURN_ERROR(
27265 + MAJOR,
27266 + E_INVALID_STATE,
27267 + ("for only insert manipulation unsupported type"));
27268 + }
27269 + p_Manip->opcode = HMAN_OC;
27270 + p_Manip->muramAllocate = TRUE;
27271 + p_Manip->insrt = TRUE;
27272 + }
27273 + else
27274 + if (p_ManipParams->u.hdr.fieldUpdate)
27275 + {
27276 + /* Check parameters */
27277 + if (p_ManipParams->u.hdr.fieldUpdateParams.type
27278 + == e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN)
27279 + {
27280 + if ((p_ManipParams->u.hdr.fieldUpdateParams.u.vlan.updateType
27281 + == e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN_VPRI)
27282 + && (p_ManipParams->u.hdr.fieldUpdateParams.u.vlan.u.vpri
27283 + > 7))
27284 + RETURN_ERROR(
27285 + MAJOR, E_INVALID_VALUE,
27286 + ("vpri should get values of 0-7 "));
27287 + if (p_ManipParams->u.hdr.fieldUpdateParams.u.vlan.updateType
27288 + == e_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN)
27289 + {
27290 + int i;
27291 +
27292 + if (p_ManipParams->u.hdr.fieldUpdateParams.u.vlan.u.dscpToVpri.vpriDefVal
27293 + > 7)
27294 + RETURN_ERROR(
27295 + MAJOR,
27296 + E_INVALID_VALUE,
27297 + ("vpriDefVal should get values of 0-7 "));
27298 + for (i = 0; i < FM_PCD_MANIP_DSCP_TO_VLAN_TRANS;
27299 + i++)
27300 + if (p_ManipParams->u.hdr.fieldUpdateParams.u.vlan.u.dscpToVpri.dscpToVpriTable[i]
27301 + & 0xf0)
27302 + RETURN_ERROR(
27303 + MAJOR,
27304 + E_INVALID_VALUE,
27305 + ("dscpToVpriTabl value out of range (0-15)"));
27306 + }
27307 +
27308 + }
27309 +
27310 + p_Manip->opcode = HMAN_OC;
27311 + p_Manip->muramAllocate = TRUE;
27312 + p_Manip->fieldUpdate = TRUE;
27313 + }
27314 + else
27315 + if (p_ManipParams->u.hdr.custom)
27316 + {
27317 + if (p_ManipParams->u.hdr.customParams.type == e_FM_PCD_MANIP_HDR_CUSTOM_GEN_FIELD_REPLACE)
27318 + {
27319 +
27320 + if ((p_ManipParams->u.hdr.customParams.u.genFieldReplace.size == 0) ||
27321 + (p_ManipParams->u.hdr.customParams.u.genFieldReplace.size > 8))
27322 + RETURN_ERROR(
27323 + MAJOR, E_INVALID_VALUE,
27324 + ("size should get values of 1-8 "));
27325 +
27326 + if (p_ManipParams->u.hdr.customParams.u.genFieldReplace.srcOffset > 7)
27327 + RETURN_ERROR(
27328 + MAJOR, E_INVALID_VALUE,
27329 + ("srcOffset should be <= 7"));
27330 +
27331 + if ((p_ManipParams->u.hdr.customParams.u.genFieldReplace.srcOffset +
27332 + p_ManipParams->u.hdr.customParams.u.genFieldReplace.size) > 8)
27333 + RETURN_ERROR(
27334 + MAJOR, E_INVALID_VALUE,
27335 + ("(srcOffset + size) should be <= 8"));
27336 +
27337 + if ((p_ManipParams->u.hdr.customParams.u.genFieldReplace.dstOffset +
27338 + p_ManipParams->u.hdr.customParams.u.genFieldReplace.size) > 256)
27339 + RETURN_ERROR(
27340 + MAJOR, E_INVALID_VALUE,
27341 + ("(dstOffset + size) should be <= 256"));
27342 +
27343 + }
27344 +
27345 + p_Manip->opcode = HMAN_OC;
27346 + p_Manip->muramAllocate = TRUE;
27347 + p_Manip->custom = TRUE;
27348 + }
27349 + break;
27350 + case e_FM_PCD_MANIP_REASSEM:
27351 + if (p_ManipParams->h_NextManip)
27352 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
27353 + ("next manip with reassembly"));
27354 + switch (p_ManipParams->u.reassem.hdr)
27355 + {
27356 + case (HEADER_TYPE_IPv4):
27357 + p_Manip->reassmParams.hdr = HEADER_TYPE_IPv4;
27358 + p_Manip->opcode = HMAN_OC_IP_REASSEMBLY;
27359 + break;
27360 + case (HEADER_TYPE_IPv6):
27361 + p_Manip->reassmParams.hdr = HEADER_TYPE_IPv6;
27362 + p_Manip->opcode = HMAN_OC_IP_REASSEMBLY;
27363 + break;
27364 +#if (DPAA_VERSION >= 11)
27365 + case (HEADER_TYPE_CAPWAP):
27366 + p_Manip->reassmParams.hdr = HEADER_TYPE_CAPWAP;
27367 + p_Manip->opcode = HMAN_OC_CAPWAP_REASSEMBLY;
27368 + break;
27369 +#endif /* (DPAA_VERSION >= 11) */
27370 + default:
27371 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
27372 + ("header for reassembly"));
27373 + }
27374 + break;
27375 + case e_FM_PCD_MANIP_FRAG:
27376 + if (p_ManipParams->h_NextManip)
27377 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
27378 + ("next manip with fragmentation"));
27379 + switch (p_ManipParams->u.frag.hdr)
27380 + {
27381 + case (HEADER_TYPE_IPv4):
27382 + case (HEADER_TYPE_IPv6):
27383 + p_Manip->opcode = HMAN_OC_IP_FRAGMENTATION;
27384 + break;
27385 +#if (DPAA_VERSION >= 11)
27386 + case (HEADER_TYPE_CAPWAP):
27387 + p_Manip->opcode = HMAN_OC_CAPWAP_FRAGMENTATION;
27388 + break;
27389 +#endif /* (DPAA_VERSION >= 11) */
27390 + default:
27391 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
27392 + ("header for fragmentation"));
27393 + }
27394 + p_Manip->muramAllocate = TRUE;
27395 + break;
27396 + case e_FM_PCD_MANIP_SPECIAL_OFFLOAD:
27397 + switch (p_ManipParams->u.specialOffload.type)
27398 + {
27399 + case (e_FM_PCD_MANIP_SPECIAL_OFFLOAD_IPSEC):
27400 + p_Manip->opcode = HMAN_OC_IPSEC_MANIP;
27401 + p_Manip->muramAllocate = TRUE;
27402 + break;
27403 +#if (DPAA_VERSION >= 11)
27404 + case (e_FM_PCD_MANIP_SPECIAL_OFFLOAD_CAPWAP):
27405 + p_Manip->opcode = HMAN_OC_CAPWAP_MANIP;
27406 + p_Manip->muramAllocate = TRUE;
27407 + break;
27408 +#endif /* (DPAA_VERSION >= 11) */
27409 + default:
27410 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
27411 + ("special offload type"));
27412 + }
27413 + break;
27414 + default:
27415 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("manip type"));
27416 + }
27417 +
27418 + return E_OK;
27419 +}
27420 +#endif /* not (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
27421 +
27422 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
27423 +
27424 +static t_Error UpdateIndxStats(t_Handle h_FmPcd,
27425 + t_Handle h_FmPort,
27426 + t_FmPcdManip *p_Manip)
27427 +{
27428 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
27429 + uint32_t tmpReg32 = 0;
27430 + t_AdOfTypeContLookup *p_Ad;
27431 + t_FmPortGetSetCcParams fmPortGetSetCcParams;
27432 + t_Error err;
27433 +
27434 + SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
27435 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
27436 +
27437 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
27438 + if (p_Manip->h_FmPcd != h_FmPcd)
27439 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
27440 + ("handler of PCD previously was initiated by different value"));
27441 +
27442 + memset(&fmPortGetSetCcParams, 0, sizeof(t_FmPortGetSetCcParams));
27443 +
27444 + if (!p_Manip->p_StatsTbl)
27445 + {
27446 +
27447 + fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNDN;
27448 + fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_CC;
27449 + err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
27450 + if (err)
27451 + RETURN_ERROR(MAJOR, err, NO_MSG);
27452 +
27453 + tmpReg32 = GET_UINT32(p_Ad->ccAdBase);
27454 +
27455 + p_Manip->p_StatsTbl =
27456 + (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
27457 + (uint32_t)p_Manip->owner * FM_PCD_MANIP_INDEXED_STATS_ENTRY_SIZE,
27458 + 4);
27459 + if (!p_Manip->p_StatsTbl)
27460 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for Manipulation indexed statistics table"));
27461 +
27462 + MemSet8(p_Manip->p_StatsTbl, 0, (uint32_t)(p_Manip->owner * 4));
27463 +
27464 + tmpReg32 |= (uint32_t)(XX_VirtToPhys(p_Manip->p_StatsTbl) - p_FmPcd->physicalMuramBase);
27465 +
27466 + if (p_Manip->cnia)
27467 + tmpReg32 |= FM_PCD_MANIP_INDEXED_STATS_CNIA;
27468 +
27469 + tmpReg32 |= FM_PCD_MANIP_INDEXED_STATS_DPD;
27470 + WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
27471 + }
27472 + else
27473 + {
27474 + fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNDN;
27475 + fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_CC;
27476 + err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
27477 + if (err)
27478 + RETURN_ERROR(MAJOR, err, NO_MSG);
27479 + }
27480 +
27481 + return E_OK;
27482 +}
27483 +
27484 +static t_Error RmvHdrTillSpecLocNOrInsrtIntFrmHdr(t_FmPcdManipHdrRmvParams *p_ManipParams, t_FmPcdManip *p_Manip)
27485 +{
27486 + t_AdOfTypeContLookup *p_Ad;
27487 + uint32_t tmpReg32 = 0;
27488 + uint8_t prsArrayOffset = 0;
27489 + t_Error err;
27490 +
27491 + SANITY_CHECK_RETURN_ERROR(p_Manip,E_NULL_POINTER);
27492 + SANITY_CHECK_RETURN_ERROR(p_ManipParams,E_NULL_POINTER);
27493 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
27494 +
27495 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
27496 + if (p_Manip->rmv)
27497 + {
27498 + err = GetPrOffsetByHeaderOrField(&p_ManipParams->u.byHdr.u.fromStartByHdr.hdrInfo, &prsArrayOffset);
27499 + if (err)
27500 + RETURN_ERROR(MAJOR, err, NO_MSG);
27501 +
27502 + tmpReg32 |= (uint32_t)prsArrayOffset << 24;
27503 + tmpReg32 |= HMAN_RMV_HDR;
27504 + }
27505 +
27506 + if (p_Manip->insrt)
27507 + tmpReg32 |= HMAN_INSRT_INT_FRM_HDR;
27508 +
27509 + tmpReg32 |= (uint32_t)HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR;
27510 +
27511 + WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
27512 +
27513 + tmpReg32 = 0;
27514 + tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
27515 + WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
27516 +
27517 + return E_OK;
27518 +}
27519 +
27520 +static t_Error MvIntFrameHeaderFromFrameToBufferPrefix(t_FmPcdManip *p_Manip,
27521 + bool caamUsed)
27522 +{
27523 + t_AdOfTypeContLookup *p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
27524 + uint32_t tmpReg32 = 0;
27525 +
27526 + SANITY_CHECK_RETURN_ERROR(p_Ad, E_INVALID_HANDLE);
27527 +
27528 + p_Manip->updateParams |= OFFSET_OF_PR | INTERNAL_CONTEXT_OFFSET;
27529 +
27530 + tmpReg32 = 0;
27531 + tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
27532 + *(uint32_t *)&p_Ad->ccAdBase = tmpReg32;
27533 +
27534 + tmpReg32 = 0;
27535 + tmpReg32 |= HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX;
27536 + tmpReg32 |= (uint32_t)0x16 << 16;
27537 + *(uint32_t *)&p_Ad->pcAndOffsets = tmpReg32;
27538 +
27539 + if (caamUsed)
27540 + *(uint32_t *)&p_Ad->gmask = 0xf0000000;
27541 +
27542 + return E_OK;
27543 +}
27544 +
27545 +static t_Error CapwapRmvDtlsHdr(t_FmPcd *p_FmPcd, t_FmPcdManip *p_Manip)
27546 +{
27547 + t_AdOfTypeContLookup *p_Ad;
27548 + uint32_t tmpReg32 = 0;
27549 + t_Error err = E_OK;
27550 +
27551 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
27552 +
27553 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
27554 +
27555 + tmpReg32 = 0;
27556 + tmpReg32 |= (uint32_t)HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST;
27557 + WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
27558 +
27559 + tmpReg32 = 0;
27560 + tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
27561 +
27562 +
27563 + if (p_Manip->h_Frag)
27564 + {
27565 + p_Manip->updateParams |= INTERNAL_CONTEXT_OFFSET;
27566 + tmpReg32 |= (uint32_t)(XX_VirtToPhys(p_Manip->h_Frag) - (p_FmPcd->physicalMuramBase));
27567 + }
27568 +
27569 + WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
27570 +
27571 + return err;
27572 +}
27573 +
27574 +static t_Error CapwapReassembly(t_CapwapReassemblyParams *p_ManipParams,
27575 + t_FmPcdManip *p_Manip,
27576 + t_FmPcd *p_FmPcd,
27577 + uint8_t poolId)
27578 +{
27579 + t_Handle p_Table;
27580 + uint32_t tmpReg32 = 0;
27581 + int i = 0;
27582 + uint8_t log2Num;
27583 + uint8_t numOfSets;
27584 + uint32_t j = 0;
27585 + uint32_t bitFor1Micro;
27586 +
27587 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad, E_INVALID_HANDLE);
27588 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
27589 +
27590 + if (!p_FmPcd->h_Hc)
27591 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,("hc port has to be initialized in this mode"));
27592 + if (!POWER_OF_2(p_ManipParams->timeoutRoutineRequestTime))
27593 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("timeoutRoutineRequestTime has to be power of 2"));
27594 + if (!POWER_OF_2(p_ManipParams->maxNumFramesInProcess))
27595 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,("maxNumFramesInProcess has to be power of 2"));
27596 + if (!p_ManipParams->timeoutRoutineRequestTime && p_ManipParams->timeoutThresholdForReassmProcess)
27597 + DBG(WARNING, ("if timeoutRoutineRequestTime 0, timeoutThresholdForReassmProcess is uselessly"));
27598 + if (p_ManipParams->numOfFramesPerHashEntry == e_FM_PCD_MANIP_FOUR_WAYS_HASH)
27599 + {
27600 + if ((p_ManipParams->maxNumFramesInProcess < 4) ||
27601 + (p_ManipParams->maxNumFramesInProcess > 512))
27602 + RETURN_ERROR(MAJOR,E_INVALID_VALUE, ("In the case of numOfFramesPerHashEntry = e_FM_PCD_MANIP_EIGHT_WAYS_HASH maxNumFramesInProcess has to be in the range 4-512"));
27603 + }
27604 + else
27605 + {
27606 + if ((p_ManipParams->maxNumFramesInProcess < 8) ||
27607 + (p_ManipParams->maxNumFramesInProcess > 2048))
27608 + RETURN_ERROR(MAJOR,E_INVALID_VALUE, ("In the case of numOfFramesPerHashEntry = e_FM_PCD_MANIP_FOUR_WAYS_HASH maxNumFramesInProcess has to be in the range 8-2048"));
27609 + }
27610 +
27611 + bitFor1Micro = FmGetTimeStampScale(p_FmPcd->h_Fm);
27612 + if (bitFor1Micro == 0)
27613 + RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("Timestamp scale"));
27614 +
27615 + p_Manip->updateParams |= (NUM_OF_TASKS | OFFSET_OF_PR | OFFSET_OF_DATA | HW_PORT_ID);
27616 +
27617 + p_Manip->h_Frag = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
27618 + FM_PCD_MANIP_CAPWAP_REASM_TABLE_SIZE,
27619 + FM_PCD_MANIP_CAPWAP_REASM_TABLE_ALIGN);
27620 + if (!p_Manip->h_Frag)
27621 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc CAPWAP reassembly parameters table"));
27622 +
27623 + MemSet8(p_Manip->h_Frag, 0, FM_PCD_MANIP_CAPWAP_REASM_TABLE_SIZE);
27624 +
27625 + p_Table = (t_CapwapReasmPram *)p_Manip->h_Frag;
27626 +
27627 + p_Manip->capwapFragParams.p_AutoLearnHashTbl =
27628 + (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
27629 + (uint32_t)(p_ManipParams->maxNumFramesInProcess * 2 * FM_PCD_MANIP_CAPWAP_REASM_AUTO_LEARNING_HASH_ENTRY_SIZE),
27630 + FM_PCD_MANIP_CAPWAP_REASM_TABLE_ALIGN);
27631 +
27632 + if (!p_Manip->capwapFragParams.p_AutoLearnHashTbl)
27633 + RETURN_ERROR(MAJOR, E_NO_MEMORY,("MURAM alloc for CAPWAP automatic learning hash table"));
27634 +
27635 + MemSet8(p_Manip->capwapFragParams.p_AutoLearnHashTbl, 0, (uint32_t)(p_ManipParams->maxNumFramesInProcess * 2 * FM_PCD_MANIP_CAPWAP_REASM_AUTO_LEARNING_HASH_ENTRY_SIZE));
27636 +
27637 + tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->capwapFragParams.p_AutoLearnHashTbl) - p_FmPcd->physicalMuramBase);
27638 +
27639 + WRITE_UINT32(((t_CapwapReasmPram *)p_Table)->autoLearnHashTblPtr, tmpReg32);
27640 +
27641 + tmpReg32 = 0;
27642 + if (p_ManipParams->timeOutMode == e_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAMES)
27643 + tmpReg32 |= FM_PCD_MANIP_CAPWAP_REASM_TIME_OUT_BETWEEN_FRAMES;
27644 + if (p_ManipParams->haltOnDuplicationFrag)
27645 + tmpReg32 |= FM_PCD_MANIP_CAPWAP_REASM_HALT_ON_DUPLICATE_FRAG;
27646 + if (p_ManipParams->numOfFramesPerHashEntry == e_FM_PCD_MANIP_EIGHT_WAYS_HASH)
27647 + {
27648 + i = 8;
27649 + tmpReg32 |= FM_PCD_MANIP_CAPWAP_REASM_AUTOMATIC_LEARNIN_HASH_8_WAYS;
27650 + }
27651 + else
27652 + i = 4;
27653 +
27654 + numOfSets = (uint8_t)((p_ManipParams->maxNumFramesInProcess * 2) / i);
27655 + LOG2(numOfSets, log2Num);
27656 + tmpReg32 |= (uint32_t)(log2Num - 1) << 24;
27657 +
27658 + WRITE_UINT32(((t_CapwapReasmPram *)p_Table)->mode, tmpReg32);
27659 +
27660 + for (j=0; j<p_ManipParams->maxNumFramesInProcess*2; j++)
27661 + if (((j / i) % 2)== 0)
27662 + WRITE_UINT32(*(uint32_t *)PTR_MOVE(p_Manip->capwapFragParams.p_AutoLearnHashTbl, j * FM_PCD_MANIP_CAPWAP_REASM_AUTO_LEARNING_HASH_ENTRY_SIZE), 0x80000000);
27663 +
27664 + tmpReg32 = 0x00008000;
27665 + tmpReg32 |= (uint32_t)poolId << 16;
27666 + WRITE_UINT32(((t_CapwapReasmPram *)p_Table)->bufferPoolIdAndRisc1SetIndexes, tmpReg32);
27667 + WRITE_UINT32(((t_CapwapReasmPram *)p_Table)->risc23SetIndexes, 0x80008000);
27668 + WRITE_UINT32(((t_CapwapReasmPram *)p_Table)->risc4SetIndexesAndExtendedStatsTblPtr, 0x80000000);
27669 +
27670 + p_Manip->capwapFragParams.maxNumFramesInProcess = p_ManipParams->maxNumFramesInProcess;
27671 +
27672 + p_Manip->capwapFragParams.sgBpid = poolId;
27673 +
27674 + p_Manip->capwapFragParams.fqidForTimeOutFrames = p_ManipParams->fqidForTimeOutFrames;
27675 + p_Manip->capwapFragParams.timeoutRoutineRequestTime = p_ManipParams->timeoutRoutineRequestTime;
27676 + p_Manip->capwapFragParams.bitFor1Micro = bitFor1Micro;
27677 +
27678 + tmpReg32 = 0;
27679 + tmpReg32 |= (((uint32_t)1<<p_Manip->capwapFragParams.bitFor1Micro) * p_ManipParams->timeoutThresholdForReassmProcess);
27680 + WRITE_UINT32(((t_CapwapReasmPram *)p_Table)->expirationDelay, tmpReg32);
27681 +
27682 + return E_OK;
27683 +}
27684 +
27685 +static t_Error CapwapFragmentation(t_CapwapFragmentationParams *p_ManipParams,
27686 + t_FmPcdManip *p_Manip,
27687 + t_FmPcd *p_FmPcd,
27688 + uint8_t poolId)
27689 +{
27690 + t_AdOfTypeContLookup *p_Ad;
27691 + uint32_t tmpReg32 = 0;
27692 +
27693 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
27694 +
27695 + p_Manip->updateParams |= OFFSET_OF_DATA;
27696 +
27697 + p_Manip->frag = TRUE;
27698 +
27699 + p_Manip->h_Frag = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
27700 + FM_PCD_CC_AD_ENTRY_SIZE,
27701 + FM_PCD_CC_AD_TABLE_ALIGN);
27702 + if (!p_Manip->h_Frag)
27703 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for CAPWAP fragmentation table descriptor"));
27704 +
27705 + MemSet8(p_Manip->h_Frag, 0, FM_PCD_CC_AD_ENTRY_SIZE);
27706 +
27707 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Frag;
27708 +
27709 + tmpReg32 = 0;
27710 + tmpReg32 |= (uint32_t)HMAN_OC_CAPWAP_FRAGMENTATION;
27711 +
27712 + if (p_ManipParams->headerOptionsCompr)
27713 + tmpReg32 |= FM_PCD_MANIP_CAPWAP_FRAG_COMPR_OPTION_FIELD_EN;
27714 + tmpReg32 |= ((uint32_t)poolId << 8);
27715 + WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
27716 +
27717 + tmpReg32 = 0;
27718 + tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
27719 + WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
27720 +
27721 + p_Manip->sizeForFragmentation = p_ManipParams->sizeForFragmentation;
27722 + p_Manip->capwapFragParams.sgBpid = poolId;
27723 +
27724 + return E_OK;
27725 +}
27726 +
27727 +static t_Error IndxStats(t_FmPcdStatsParams *p_StatsParams,t_FmPcdManip *p_Manip,t_FmPcd *p_FmPcd)
27728 +{
27729 + t_AdOfTypeContLookup *p_Ad;
27730 + uint32_t tmpReg32 = 0;
27731 +
27732 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
27733 +
27734 + UNUSED(p_FmPcd);
27735 +
27736 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
27737 +
27738 + tmpReg32 = 0;
27739 + tmpReg32 |= (uint32_t)HMAN_OC_CAPWAP_INDEXED_STATS;
27740 + if (p_StatsParams->type == e_FM_PCD_STATS_PER_FLOWID)
27741 + tmpReg32 |= (uint32_t)0x16 << 16;
27742 + WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
27743 +
27744 + tmpReg32 = 0;
27745 + tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
27746 + WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
27747 +
27748 + return E_OK;
27749 +}
27750 +
27751 +static t_Error InsrtHdrByTempl(t_FmPcdManipHdrInsrtParams *p_ManipParams, t_FmPcdManip *p_Manip, t_FmPcd *p_FmPcd)
27752 +{
27753 + t_FmPcdManipHdrInsrtByTemplateParams *p_InsrtByTemplate = &p_ManipParams->u.byTemplate;
27754 + uint8_t tmpReg8 = 0xff;
27755 + t_AdOfTypeContLookup *p_Ad;
27756 + bool ipModify = FALSE;
27757 + uint32_t tmpReg32 = 0, tmpRegNia = 0;
27758 + uint16_t tmpReg16 = 0;
27759 + t_Error err = E_OK;
27760 + uint8_t extraAddedBytes = 0, blockSize = 0, extraAddedBytesAlignedToBlockSize = 0, log2Num = 0;
27761 + uint8_t *p_Template = NULL;
27762 +
27763 + SANITY_CHECK_RETURN_ERROR(p_ManipParams,E_NULL_POINTER);
27764 + SANITY_CHECK_RETURN_ERROR(p_Manip,E_NULL_POINTER);
27765 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
27766 + SANITY_CHECK_RETURN_ERROR(p_FmPcd,E_NULL_POINTER);
27767 +
27768 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
27769 + if (p_Manip->insrt)
27770 + {
27771 + if ((!p_InsrtByTemplate->size && p_InsrtByTemplate->modifyOuterIp) ||
27772 + (!p_InsrtByTemplate->size && p_InsrtByTemplate->modifyOuterVlan))
27773 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : asking for header template modifications with no template for insertion (template size)"));
27774 +
27775 + if (p_InsrtByTemplate->size && p_InsrtByTemplate->modifyOuterIp && (p_InsrtByTemplate->size <= p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset))
27776 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : size of template < ipOuterOffset"));
27777 +
27778 + if (p_InsrtByTemplate->size > 128)
27779 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Size of header template for insertion can not be more than 128"));
27780 +
27781 + if (p_InsrtByTemplate->size)
27782 + {
27783 + p_Manip->p_Template = (uint8_t *)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
27784 + p_InsrtByTemplate->size,
27785 + FM_PCD_CC_AD_TABLE_ALIGN);
27786 + if(!p_Manip->p_Template)
27787 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
27788 +
27789 + tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->p_Template) - (p_FmPcd->physicalMuramBase));
27790 + tmpReg32 |= (uint32_t)p_InsrtByTemplate->size << 24;
27791 + *(uint32_t *)&p_Ad->matchTblPtr = tmpReg32;
27792 + }
27793 +
27794 + tmpReg32 = 0;
27795 +
27796 + p_Template = (uint8_t *)XX_Malloc(p_InsrtByTemplate->size * sizeof(uint8_t));
27797 +
27798 + if (!p_Template)
27799 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("XX_Malloc allocation FAILED"));
27800 +
27801 + memcpy(p_Template, p_InsrtByTemplate->hdrTemplate, p_InsrtByTemplate->size * sizeof(uint8_t));
27802 +
27803 + if (p_InsrtByTemplate->modifyOuterIp)
27804 + {
27805 + ipModify = TRUE;
27806 +
27807 + tmpReg8 = (uint8_t)p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset];
27808 +
27809 + if((tmpReg8 & 0xf0) == 0x40)
27810 + tmpReg8 = 4;
27811 + else if((tmpReg8 & 0xf0) == 0x60)
27812 + tmpReg8 = 6;
27813 + else
27814 + tmpReg8 = 0xff;
27815 +
27816 + if (tmpReg8 != 0xff)
27817 + {
27818 + if(p_InsrtByTemplate->modifyOuterIpParams.dscpEcn & 0xff00)
27819 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : IPV4 present in header template, dscpEcn has to be only 1 byte"));
27820 + if(p_InsrtByTemplate->modifyOuterIpParams.recalculateLength)
27821 + {
27822 +
27823 + if((p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedAlignedToBlockSize + p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedNotAlignedToBlockSize) > 255)
27824 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("extra Byte added can not be more than 256 bytes"));
27825 + extraAddedBytes = (uint8_t) (p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedAlignedToBlockSize + p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedNotAlignedToBlockSize);
27826 + blockSize = p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.blockSize;
27827 + extraAddedBytesAlignedToBlockSize = p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedAlignedToBlockSize;
27828 + /*IP header template - IP totalLength -
27829 + (1 byte) extraByteForIp = headerTemplateSize - ipOffset + insertedBytesAfterThisStage ,
27830 + in the case of SEC insertedBytesAfterThisStage - SEC trailer (21/31) + header(13)
27831 + second byte - extraByteForIp = headerTemplate - ipOffset + insertedBytesAfterThisStage*/
27832 + }
27833 + if (blockSize)
27834 + {
27835 + if (!POWER_OF_2(blockSize))
27836 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("inputFrmPaddingUpToBlockSize has to be power of 2"));
27837 + }
27838 +
27839 + }
27840 + if (tmpReg8 == 4)
27841 + {
27842 + if ((IPv4_HDRCHECKSUM_FIELD_OFFSET_FROM_IP + p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset) > p_InsrtByTemplate->size)
27843 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : IP present in header template, user asked for IP modifications but ipOffset + ipTotalLengthFieldOffset in header template bigger than template size"));
27844 +
27845 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_DSCECN_FIELD_OFFSET_FROM_IP] = (uint8_t)p_InsrtByTemplate->modifyOuterIpParams.dscpEcn;
27846 +
27847 + if (blockSize)
27848 + blockSize -= 1;
27849 +
27850 + if ((p_InsrtByTemplate->size - p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + extraAddedBytes) > 255)
27851 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("p_InsrtByTemplate->size - p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + extraAddedBytes has to be less than 255"));
27852 +
27853 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_TOTALLENGTH_FIELD_OFFSET_FROM_IP + 1] = blockSize; // IPV6 - in AD instead of SEQ IND
27854 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_TOTALLENGTH_FIELD_OFFSET_FROM_IP] = (uint8_t)(p_InsrtByTemplate->size - p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + extraAddedBytes);// for IPV6 decrement additional 40 bytes of IPV6 heade size
27855 +
27856 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_ID_FIELD_OFFSET_FROM_IP] = 0x00;
27857 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_ID_FIELD_OFFSET_FROM_IP + 1] = extraAddedBytesAlignedToBlockSize;
27858 +
27859 + /*IP header template - relevant only for ipv4 CheckSum = 0*/
27860 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_HDRCHECKSUM_FIELD_OFFSET_FROM_IP] = 0x00;
27861 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_HDRCHECKSUM_FIELD_OFFSET_FROM_IP + 1] = 0x00;
27862 +
27863 + /*UDP checksum has to be 0*/
27864 + if (p_InsrtByTemplate->modifyOuterIpParams.udpPresent)
27865 + {
27866 + if ((p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP + UDP_CHECKSUM_FIELD_SIZE) > p_InsrtByTemplate->size)
27867 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : UDP present according to user but (UDP offset + UDP header size) < size of header template"));
27868 +
27869 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP ] = 0x00;
27870 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP + 1] = 0x00;
27871 +
27872 + }
27873 +
27874 + if (p_InsrtByTemplate->modifyOuterIpParams.ipIdentGenId > 7)
27875 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("ipIdentGenId has to be one out of 8 sequence number generators (0 - 7) for IP identification field"));
27876 +
27877 + tmpRegNia |= (uint32_t)p_InsrtByTemplate->modifyOuterIpParams.ipIdentGenId<<24;
27878 + }
27879 + else if (tmpReg8 == 6)
27880 + {
27881 + /*TODO - add check for maximum value of blockSize;*/
27882 + if (blockSize)
27883 + LOG2(blockSize, log2Num);
27884 + tmpRegNia |= (uint32_t)log2Num << 24;
27885 +
27886 + // for IPV6 decrement additional 40 bytes of IPV6 heade size - because IPV6 header size is not included in payloadLength
27887 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv6_PAYLOAD_LENGTH_OFFSET_FROM_IP] = (uint8_t)(p_InsrtByTemplate->size - p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + extraAddedBytes - 40);
27888 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv6_PAYLOAD_LENGTH_OFFSET_FROM_IP + 1] = extraAddedBytesAlignedToBlockSize;
27889 + if (p_InsrtByTemplate->modifyOuterIpParams.udpPresent)
27890 + {
27891 + if ((p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP + UDP_CHECKSUM_FIELD_SIZE) > p_InsrtByTemplate->size)
27892 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : UDP present according to user but (UDP offset + UDP header size) < size of header template"));
27893 + if (p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv6_NEXT_HEADER_OFFSET_FROM_IP] != 0x88)
27894 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("OUr suppport is only IPv6/UDPLite"));
27895 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_LENGTH_FIELD_OFFSET_FROM_UDP] = 0x00;
27896 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_LENGTH_FIELD_OFFSET_FROM_UDP + 1] = 0x08;
27897 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP] = 0x00;
27898 + p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP + 1] = 0x00;
27899 + }
27900 + }
27901 + else
27902 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("IP version supported only IPV4"));
27903 + }
27904 +
27905 + tmpReg32 = tmpReg16 = tmpReg8 = 0;
27906 + /*TODO - check it*/
27907 + if (p_InsrtByTemplate->modifyOuterVlan)
27908 + {
27909 + if (p_InsrtByTemplate->modifyOuterVlanParams.vpri & ~0x07)
27910 + RETURN_ERROR(MAJOR, E_INVALID_STATE,("Inconsistent parameters : user asked for VLAN modifications but VPRI more than 3 bits"));
27911 +
27912 + memcpy(&tmpReg16, &p_Template[VLAN_TAG_FIELD_OFFSET_FROM_ETH], 2*(sizeof(uint8_t)));
27913 + if ((tmpReg16 != 0x9100) && (tmpReg16!= 0x9200) && (tmpReg16 != 0x8100))
27914 + RETURN_ERROR(MAJOR, E_INVALID_STATE,("Inconsistent parameters : user asked for VLAN modifications but Tag Protocol identifier is not VLAN "));
27915 +
27916 + memcpy(&tmpReg8, &p_Template[14],1*(sizeof(uint8_t)));
27917 + tmpReg8 &= 0x1f;
27918 + tmpReg8 |= (uint8_t)(p_InsrtByTemplate->modifyOuterVlanParams.vpri << 5);
27919 +
27920 + p_Template[14] = tmpReg8;
27921 + }
27922 +
27923 + MemCpy8(p_Manip->p_Template, p_Template, p_InsrtByTemplate->size);
27924 +
27925 + XX_Free(p_Template);
27926 + }
27927 +
27928 + tmpReg32 = 0;
27929 + if (p_Manip->h_Frag)
27930 + {
27931 + tmpRegNia |= (uint32_t)(XX_VirtToPhys(p_Manip->h_Frag) - (p_FmPcd->physicalMuramBase));
27932 + tmpReg32 |= (uint32_t)p_Manip->sizeForFragmentation << 16;
27933 + }
27934 + else
27935 + tmpReg32 = 0xffff0000;
27936 +
27937 + if (ipModify)
27938 + tmpReg32 |= (uint32_t)p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset << 8;
27939 + else
27940 + tmpReg32 |= (uint32_t)0x0000ff00;
27941 +
27942 + tmpReg32 |= (uint32_t)HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER;
27943 + *(uint32_t *)&p_Ad->pcAndOffsets = tmpReg32;
27944 +
27945 + tmpRegNia |= FM_PCD_AD_CONT_LOOKUP_TYPE;
27946 + *(uint32_t *)&p_Ad->ccAdBase = tmpRegNia;
27947 +
27948 + return err;
27949 +}
27950 +
27951 +static t_Error CheckStatsParamsAndSetType(t_FmPcdManip *p_Manip, t_FmPcdStatsParams *p_StatsParams)
27952 +{
27953 +
27954 + switch (p_StatsParams->type)
27955 + {
27956 + case (e_FM_PCD_STATS_PER_FLOWID):
27957 + p_Manip->opcode = HMAN_OC_CAPWAP_INDEXED_STATS;
27958 + p_Manip->muramAllocate = TRUE;
27959 + break;
27960 + default:
27961 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Unsupported statistics type"));
27962 + }
27963 +
27964 + return E_OK;
27965 +}
27966 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
27967 +
27968 +static t_Error FillReassmManipParams(t_FmPcdManip *p_Manip, e_NetHeaderType hdr)
27969 +{
27970 + t_AdOfTypeContLookup *p_Ad;
27971 + t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
27972 + uint32_t tmpReg32;
27973 + t_Error err = E_OK;
27974 +
27975 + /* Creates the Reassembly Parameters table. It contains parameters that are specific to either the IPv4 reassembly
27976 + function or to the IPv6 reassembly function. If both IPv4 reassembly and IPv6 reassembly are required, then
27977 + two separate IP Reassembly Parameter tables are required.*/
27978 + if ((err = CreateReassTable(p_Manip, hdr)) != E_OK)
27979 + RETURN_ERROR(MAJOR, err, NO_MSG);
27980 +
27981 + /* Sets the first Ad register (ccAdBase) - Action Descriptor Type and Pointer to the Reassembly Parameters Table offset from MURAM*/
27982 + tmpReg32 = 0;
27983 + tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
27984 +
27985 + /* Gets the required Action descriptor table pointer */
27986 + switch (hdr)
27987 + {
27988 + case HEADER_TYPE_IPv4:
27989 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->reassmParams.ip.h_Ipv4Ad;
27990 + tmpReg32 |= (uint32_t)(XX_VirtToPhys(
27991 + p_Manip->reassmParams.ip.p_Ipv4ReassTbl)
27992 + - (p_FmPcd->physicalMuramBase));
27993 + break;
27994 + case HEADER_TYPE_IPv6:
27995 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->reassmParams.ip.h_Ipv6Ad;
27996 + tmpReg32 |= (uint32_t)(XX_VirtToPhys(
27997 + p_Manip->reassmParams.ip.p_Ipv6ReassTbl)
27998 + - (p_FmPcd->physicalMuramBase));
27999 + break;
28000 + case HEADER_TYPE_CAPWAP:
28001 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->reassmParams.capwap.h_Ad;
28002 + tmpReg32 |= (uint32_t)(XX_VirtToPhys(
28003 + p_Manip->reassmParams.capwap.p_ReassTbl)
28004 + - (p_FmPcd->physicalMuramBase));
28005 + break;
28006 + default:
28007 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("header type"));
28008 + }
28009 +
28010 + WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
28011 +
28012 + /* Sets the second Ad register (matchTblPtr) - Buffer pool ID (BPID for V2) and Scatter/Gather table offset*/
28013 + /* mark the Scatter/Gather table offset to be set later on when the port will be known */
28014 + p_Manip->updateParams = (NUM_OF_TASKS | NUM_OF_EXTRA_TASKS | DISCARD_MASK);
28015 +
28016 + if ((hdr == HEADER_TYPE_IPv6) || (hdr == HEADER_TYPE_IPv4))
28017 + {
28018 +#if (DPAA_VERSION == 10)
28019 + tmpReg32 = (uint32_t)(p_Manip->reassmParams.sgBpid << 8);
28020 + WRITE_UINT32(p_Ad->matchTblPtr, tmpReg32);
28021 +#endif /* (DPAA_VERSION == 10) */
28022 +#if (DPAA_VERSION >= 11)
28023 + if (p_Manip->reassmParams.ip.nonConsistentSpFqid != 0)
28024 + {
28025 + tmpReg32 = FM_PCD_AD_NCSPFQIDM_MASK
28026 + | (uint32_t)(p_Manip->reassmParams.ip.nonConsistentSpFqid);
28027 + WRITE_UINT32(p_Ad->gmask, tmpReg32);
28028 + }
28029 +#endif /* (DPAA_VERSION >= 11) */
28030 + /* Sets the third Ad register (pcAndOffsets)- IP Reassemble Operation Code*/
28031 + tmpReg32 = 0;
28032 + tmpReg32 |= (uint32_t)HMAN_OC_IP_REASSEMBLY;
28033 + }
28034 +#if (DPAA_VERSION >= 11)
28035 + else
28036 + if (hdr == HEADER_TYPE_CAPWAP)
28037 + {
28038 + tmpReg32 = 0;
28039 + tmpReg32 |= (uint32_t)HMAN_OC_CAPWAP_REASSEMBLY;
28040 + }
28041 +#endif /* (DPAA_VERSION >= 11) */
28042 +
28043 + WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
28044 +
28045 + p_Manip->reassm = TRUE;
28046 +
28047 + return E_OK;
28048 +}
28049 +
28050 +static t_Error SetIpv4ReassmManip(t_FmPcdManip *p_Manip)
28051 +{
28052 + t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
28053 +
28054 + /* Allocation if IPv4 Action descriptor */
28055 + p_Manip->reassmParams.ip.h_Ipv4Ad = (t_Handle)XX_MallocSmart(
28056 + FM_PCD_CC_AD_ENTRY_SIZE, p_Manip->reassmParams.dataMemId,
28057 + FM_PCD_CC_AD_TABLE_ALIGN);
28058 + if (!p_Manip->reassmParams.ip.h_Ipv4Ad)
28059 + {
28060 + ReleaseManipHandler(p_Manip, p_FmPcd);
28061 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
28062 + ("Allocation of IPv4 table descriptor"));
28063 + }
28064 +
28065 + memset(p_Manip->reassmParams.ip.h_Ipv4Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
28066 +
28067 + /* Fill reassembly manipulation parameter in the IP Reassembly Action Descriptor */
28068 + return FillReassmManipParams(p_Manip, HEADER_TYPE_IPv4);
28069 +}
28070 +
28071 +static t_Error SetIpv6ReassmManip(t_FmPcdManip *p_Manip)
28072 +{
28073 + t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
28074 +
28075 + /* Allocation if IPv6 Action descriptor */
28076 + p_Manip->reassmParams.ip.h_Ipv6Ad = (t_Handle)XX_MallocSmart(
28077 + FM_PCD_CC_AD_ENTRY_SIZE, p_Manip->reassmParams.dataMemId,
28078 + FM_PCD_CC_AD_TABLE_ALIGN);
28079 + if (!p_Manip->reassmParams.ip.h_Ipv6Ad)
28080 + {
28081 + ReleaseManipHandler(p_Manip, p_FmPcd);
28082 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
28083 + ("Allocation of IPv6 table descriptor"));
28084 + }
28085 +
28086 + memset(p_Manip->reassmParams.ip.h_Ipv6Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
28087 +
28088 + /* Fill reassembly manipulation parameter in the IP Reassembly Action Descriptor */
28089 + return FillReassmManipParams(p_Manip, HEADER_TYPE_IPv6);
28090 +}
28091 +
28092 +static t_Error IpReassembly(t_FmPcdManipReassemParams *p_ManipReassmParams,
28093 + t_FmPcdManip *p_Manip)
28094 +{
28095 + uint32_t maxSetNumber = 10000;
28096 + t_FmPcdManipReassemIpParams reassmManipParams =
28097 + p_ManipReassmParams->u.ipReassem;
28098 + t_Error res;
28099 +
28100 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_FmPcd, E_INVALID_HANDLE);
28101 + SANITY_CHECK_RETURN_ERROR(((t_FmPcd *)p_Manip->h_FmPcd)->h_Hc,
28102 + E_INVALID_HANDLE);
28103 +
28104 + /* Check validation of user's parameter.*/
28105 + if ((reassmManipParams.timeoutThresholdForReassmProcess < 1000)
28106 + || (reassmManipParams.timeoutThresholdForReassmProcess > 8000000))
28107 + RETURN_ERROR(
28108 + MAJOR, E_INVALID_VALUE,
28109 + ("timeoutThresholdForReassmProcess should be 1msec - 8sec"));
28110 + /* It is recommended that the total number of entries in this table (number of sets * number of ways)
28111 + will be twice the number of frames that are expected to be reassembled simultaneously.*/
28112 + if (reassmManipParams.maxNumFramesInProcess
28113 + > (reassmManipParams.maxNumFramesInProcess * maxSetNumber / 2))
28114 + RETURN_ERROR(
28115 + MAJOR,
28116 + E_INVALID_VALUE,
28117 + ("maxNumFramesInProcess has to be less than (maximun set number * number of ways / 2)"));
28118 +
28119 + if ((p_ManipReassmParams->hdr == HEADER_TYPE_IPv6)
28120 + && (reassmManipParams.minFragSize[1] < 256))
28121 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("minFragSize[1] must be >= 256"));
28122 +
28123 + /* Saves user's reassembly manipulation parameters */
28124 + p_Manip->reassmParams.ip.relativeSchemeId[0] =
28125 + reassmManipParams.relativeSchemeId[0];
28126 + p_Manip->reassmParams.ip.relativeSchemeId[1] =
28127 + reassmManipParams.relativeSchemeId[1];
28128 + p_Manip->reassmParams.ip.numOfFramesPerHashEntry[0] =
28129 + reassmManipParams.numOfFramesPerHashEntry[0];
28130 + p_Manip->reassmParams.ip.numOfFramesPerHashEntry[1] =
28131 + reassmManipParams.numOfFramesPerHashEntry[1];
28132 + p_Manip->reassmParams.ip.minFragSize[0] = reassmManipParams.minFragSize[0];
28133 + p_Manip->reassmParams.ip.minFragSize[1] = reassmManipParams.minFragSize[1];
28134 + p_Manip->reassmParams.maxNumFramesInProcess =
28135 + reassmManipParams.maxNumFramesInProcess;
28136 + p_Manip->reassmParams.timeOutMode = reassmManipParams.timeOutMode;
28137 + p_Manip->reassmParams.fqidForTimeOutFrames =
28138 + reassmManipParams.fqidForTimeOutFrames;
28139 + p_Manip->reassmParams.timeoutThresholdForReassmProcess =
28140 + reassmManipParams.timeoutThresholdForReassmProcess;
28141 + p_Manip->reassmParams.dataMemId = reassmManipParams.dataMemId;
28142 + p_Manip->reassmParams.dataLiodnOffset = reassmManipParams.dataLiodnOffset;
28143 +#if (DPAA_VERSION == 10)
28144 + p_Manip->reassmParams.sgBpid = reassmManipParams.sgBpid;
28145 +#endif /* (DPAA_VERSION == 10) */
28146 +#if (DPAA_VERSION >= 11)
28147 + if (reassmManipParams.nonConsistentSpFqid != 0)
28148 + {
28149 + p_Manip->reassmParams.ip.nonConsistentSpFqid =
28150 + reassmManipParams.nonConsistentSpFqid;
28151 + }
28152 +#endif /* (DPAA_VERSION >= 11) */
28153 +
28154 + /* Creates and initializes the IP Reassembly common parameter table */
28155 + CreateReassCommonTable(p_Manip);
28156 +
28157 + /* Creation of IPv4 reassembly manipulation */
28158 + if ((p_Manip->reassmParams.hdr == HEADER_TYPE_IPv6)
28159 + || (p_Manip->reassmParams.hdr == HEADER_TYPE_IPv4))
28160 + {
28161 + res = SetIpv4ReassmManip(p_Manip);
28162 + if (res != E_OK)
28163 + return res;
28164 + }
28165 +
28166 + /* Creation of IPv6 reassembly manipulation */
28167 + if (p_Manip->reassmParams.hdr == HEADER_TYPE_IPv6)
28168 + {
28169 + res = SetIpv6ReassmManip(p_Manip);
28170 + if (res != E_OK)
28171 + return res;
28172 + }
28173 +
28174 + return E_OK;
28175 +}
28176 +
28177 +static void setIpReassmSchemeParams(t_FmPcd* p_FmPcd,
28178 + t_FmPcdKgSchemeParams *p_Scheme,
28179 + t_Handle h_CcTree, bool ipv4,
28180 + uint8_t groupId)
28181 +{
28182 + uint32_t j;
28183 + uint8_t res;
28184 +
28185 + /* Configures scheme's network environment parameters */
28186 + p_Scheme->netEnvParams.numOfDistinctionUnits = 2;
28187 + if (ipv4)
28188 + res = FmPcdNetEnvGetUnitId(
28189 + p_FmPcd, FmPcdGetNetEnvId(p_Scheme->netEnvParams.h_NetEnv),
28190 + HEADER_TYPE_IPv4, FALSE, 0);
28191 + else
28192 + res = FmPcdNetEnvGetUnitId(
28193 + p_FmPcd, FmPcdGetNetEnvId(p_Scheme->netEnvParams.h_NetEnv),
28194 + HEADER_TYPE_IPv6, FALSE, 0);
28195 + ASSERT_COND(res != FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
28196 + p_Scheme->netEnvParams.unitIds[0] = res;
28197 +
28198 + res = FmPcdNetEnvGetUnitId(
28199 + p_FmPcd, FmPcdGetNetEnvId(p_Scheme->netEnvParams.h_NetEnv),
28200 + HEADER_TYPE_USER_DEFINED_SHIM2, FALSE, 0);
28201 + ASSERT_COND(res != FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
28202 + p_Scheme->netEnvParams.unitIds[1] = res;
28203 +
28204 + /* Configures scheme's next engine parameters*/
28205 + p_Scheme->nextEngine = e_FM_PCD_CC;
28206 + p_Scheme->kgNextEngineParams.cc.h_CcTree = h_CcTree;
28207 + p_Scheme->kgNextEngineParams.cc.grpId = groupId;
28208 + p_Scheme->useHash = TRUE;
28209 +
28210 + /* Configures scheme's key*/
28211 + if (ipv4 == TRUE)
28212 + {
28213 + p_Scheme->keyExtractAndHashParams.numOfUsedExtracts = 4;
28214 + p_Scheme->keyExtractAndHashParams.extractArray[0].type =
28215 + e_FM_PCD_EXTRACT_BY_HDR;
28216 + p_Scheme->keyExtractAndHashParams.extractArray[0].extractByHdr.type =
28217 + e_FM_PCD_EXTRACT_FULL_FIELD;
28218 + p_Scheme->keyExtractAndHashParams.extractArray[0].extractByHdr.hdr =
28219 + HEADER_TYPE_IPv4;
28220 + p_Scheme->keyExtractAndHashParams.extractArray[0].extractByHdr.extractByHdrType.fullField.ipv4 =
28221 + NET_HEADER_FIELD_IPv4_DST_IP;
28222 + p_Scheme->keyExtractAndHashParams.extractArray[1].type =
28223 + e_FM_PCD_EXTRACT_BY_HDR;
28224 + p_Scheme->keyExtractAndHashParams.extractArray[1].extractByHdr.type =
28225 + e_FM_PCD_EXTRACT_FULL_FIELD;
28226 + p_Scheme->keyExtractAndHashParams.extractArray[1].extractByHdr.hdr =
28227 + HEADER_TYPE_IPv4;
28228 + p_Scheme->keyExtractAndHashParams.extractArray[1].extractByHdr.extractByHdrType.fullField.ipv4 =
28229 + NET_HEADER_FIELD_IPv4_SRC_IP;
28230 + p_Scheme->keyExtractAndHashParams.extractArray[2].type =
28231 + e_FM_PCD_EXTRACT_BY_HDR;
28232 + p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.type =
28233 + e_FM_PCD_EXTRACT_FULL_FIELD;
28234 + p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.hdr =
28235 + HEADER_TYPE_IPv4;
28236 + p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.extractByHdrType.fullField.ipv4 =
28237 + NET_HEADER_FIELD_IPv4_PROTO;
28238 + p_Scheme->keyExtractAndHashParams.extractArray[3].type =
28239 + e_FM_PCD_EXTRACT_BY_HDR;
28240 + p_Scheme->keyExtractAndHashParams.extractArray[3].extractByHdr.hdr =
28241 + HEADER_TYPE_IPv4;
28242 + p_Scheme->keyExtractAndHashParams.extractArray[3].extractByHdr.type =
28243 + e_FM_PCD_EXTRACT_FROM_HDR;
28244 + p_Scheme->keyExtractAndHashParams.extractArray[3].extractByHdr.ignoreProtocolValidation =
28245 + FALSE;
28246 + p_Scheme->keyExtractAndHashParams.extractArray[3].extractByHdr.extractByHdrType.fromHdr.size =
28247 + 2;
28248 + p_Scheme->keyExtractAndHashParams.extractArray[3].extractByHdr.extractByHdrType.fromHdr.offset =
28249 + 4;
28250 + }
28251 + else /* IPv6 */
28252 + {
28253 + p_Scheme->keyExtractAndHashParams.numOfUsedExtracts = 3;
28254 + p_Scheme->keyExtractAndHashParams.extractArray[0].type =
28255 + e_FM_PCD_EXTRACT_BY_HDR;
28256 + p_Scheme->keyExtractAndHashParams.extractArray[0].extractByHdr.type =
28257 + e_FM_PCD_EXTRACT_FULL_FIELD;
28258 + p_Scheme->keyExtractAndHashParams.extractArray[0].extractByHdr.hdr =
28259 + HEADER_TYPE_IPv6;
28260 + p_Scheme->keyExtractAndHashParams.extractArray[0].extractByHdr.extractByHdrType.fullField.ipv6 =
28261 + NET_HEADER_FIELD_IPv6_DST_IP;
28262 + p_Scheme->keyExtractAndHashParams.extractArray[1].type =
28263 + e_FM_PCD_EXTRACT_BY_HDR;
28264 + p_Scheme->keyExtractAndHashParams.extractArray[1].extractByHdr.type =
28265 + e_FM_PCD_EXTRACT_FULL_FIELD;
28266 + p_Scheme->keyExtractAndHashParams.extractArray[1].extractByHdr.hdr =
28267 + HEADER_TYPE_IPv6;
28268 + p_Scheme->keyExtractAndHashParams.extractArray[1].extractByHdr.extractByHdrType.fullField.ipv6 =
28269 + NET_HEADER_FIELD_IPv6_SRC_IP;
28270 + p_Scheme->keyExtractAndHashParams.extractArray[2].type =
28271 + e_FM_PCD_EXTRACT_BY_HDR;
28272 + p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.hdr =
28273 + HEADER_TYPE_USER_DEFINED_SHIM2;
28274 + p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.type =
28275 + e_FM_PCD_EXTRACT_FROM_HDR;
28276 + p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.extractByHdrType.fromHdr.size =
28277 + 4;
28278 + p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.extractByHdrType.fromHdr.offset =
28279 + 4;
28280 + p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.ignoreProtocolValidation =
28281 + TRUE;
28282 + }
28283 +
28284 + p_Scheme->keyExtractAndHashParams.privateDflt0 = 0x01020304;
28285 + p_Scheme->keyExtractAndHashParams.privateDflt1 = 0x11121314;
28286 + p_Scheme->keyExtractAndHashParams.numOfUsedDflts =
28287 + FM_PCD_KG_NUM_OF_DEFAULT_GROUPS;
28288 + for (j = 0; j < FM_PCD_KG_NUM_OF_DEFAULT_GROUPS; j++)
28289 + {
28290 + p_Scheme->keyExtractAndHashParams.dflts[j].type =
28291 + (e_FmPcdKgKnownFieldsDfltTypes)j; /* all types */
28292 + p_Scheme->keyExtractAndHashParams.dflts[j].dfltSelect =
28293 + e_FM_PCD_KG_DFLT_GBL_0;
28294 + }
28295 +}
28296 +
28297 +static t_Error IpReassemblyStats(t_FmPcdManip *p_Manip,
28298 + t_FmPcdManipReassemIpStats *p_Stats)
28299 +{
28300 + ASSERT_COND(p_Manip);
28301 + ASSERT_COND(p_Stats);
28302 + ASSERT_COND(p_Manip->reassmParams.p_ReassCommonTbl);
28303 +
28304 + p_Stats->timeout =
28305 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalTimeOutCounter);
28306 + p_Stats->rfdPoolBusy =
28307 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalRfdPoolBusyCounter);
28308 + p_Stats->internalBufferBusy =
28309 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalInternalBufferBusy);
28310 + p_Stats->externalBufferBusy =
28311 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalExternalBufferBusy);
28312 + p_Stats->sgFragments =
28313 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalSgFragmentCounter);
28314 + p_Stats->dmaSemaphoreDepletion =
28315 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalDmaSemaphoreDepletionCounter);
28316 +#if (DPAA_VERSION >= 11)
28317 + p_Stats->nonConsistentSp =
28318 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalNCSPCounter);
28319 +#endif /* (DPAA_VERSION >= 11) */
28320 +
28321 + if (p_Manip->reassmParams.ip.p_Ipv4ReassTbl)
28322 + {
28323 + p_Stats->specificHdrStatistics[0].successfullyReassembled =
28324 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalSuccessfullyReasmFramesCounter);
28325 + p_Stats->specificHdrStatistics[0].validFragments =
28326 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalValidFragmentCounter);
28327 + p_Stats->specificHdrStatistics[0].processedFragments =
28328 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalProcessedFragCounter);
28329 + p_Stats->specificHdrStatistics[0].malformedFragments =
28330 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalMalformdFragCounter);
28331 + p_Stats->specificHdrStatistics[0].autoLearnBusy =
28332 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalSetBusyCounter);
28333 + p_Stats->specificHdrStatistics[0].discardedFragments =
28334 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalDiscardedFragsCounter);
28335 + p_Stats->specificHdrStatistics[0].moreThan16Fragments =
28336 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalMoreThan16FramesCounter);
28337 + }
28338 + if (p_Manip->reassmParams.ip.p_Ipv6ReassTbl)
28339 + {
28340 + p_Stats->specificHdrStatistics[1].successfullyReassembled =
28341 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalSuccessfullyReasmFramesCounter);
28342 + p_Stats->specificHdrStatistics[1].validFragments =
28343 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalValidFragmentCounter);
28344 + p_Stats->specificHdrStatistics[1].processedFragments =
28345 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalProcessedFragCounter);
28346 + p_Stats->specificHdrStatistics[1].malformedFragments =
28347 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalMalformdFragCounter);
28348 + p_Stats->specificHdrStatistics[1].autoLearnBusy =
28349 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalSetBusyCounter);
28350 + p_Stats->specificHdrStatistics[1].discardedFragments =
28351 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalDiscardedFragsCounter);
28352 + p_Stats->specificHdrStatistics[1].moreThan16Fragments =
28353 + GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalMoreThan16FramesCounter);
28354 + }
28355 + return E_OK;
28356 +}
28357 +
28358 +static t_Error IpFragmentationStats(t_FmPcdManip *p_Manip,
28359 + t_FmPcdManipFragIpStats *p_Stats)
28360 +{
28361 + t_AdOfTypeContLookup *p_Ad;
28362 +
28363 + ASSERT_COND(p_Manip);
28364 + ASSERT_COND(p_Stats);
28365 + ASSERT_COND(p_Manip->h_Ad);
28366 + ASSERT_COND(p_Manip->fragParams.p_Frag);
28367 +
28368 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
28369 +
28370 + p_Stats->totalFrames = GET_UINT32(p_Ad->gmask);
28371 + p_Stats->fragmentedFrames = GET_UINT32(p_Manip->fragParams.p_Frag->ccAdBase)
28372 + & 0x00ffffff;
28373 + p_Stats->generatedFragments =
28374 + GET_UINT32(p_Manip->fragParams.p_Frag->matchTblPtr);
28375 +
28376 + return E_OK;
28377 +}
28378 +
28379 +static t_Error IpFragmentation(t_FmPcdManipFragIpParams *p_ManipParams,
28380 + t_FmPcdManip *p_Manip)
28381 +{
28382 + uint32_t pcAndOffsetsReg = 0, ccAdBaseReg = 0, gmaskReg = 0;
28383 + t_FmPcd *p_FmPcd;
28384 +#if (DPAA_VERSION == 10)
28385 + t_Error err = E_OK;
28386 +#endif /* (DPAA_VERSION == 10) */
28387 +
28388 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad, E_INVALID_HANDLE);
28389 + SANITY_CHECK_RETURN_ERROR(p_ManipParams->sizeForFragmentation != 0xFFFF,
28390 + E_INVALID_VALUE);
28391 +
28392 + p_FmPcd = p_Manip->h_FmPcd;
28393 + /* Allocation of fragmentation Action Descriptor */
28394 + p_Manip->fragParams.p_Frag = (t_AdOfTypeContLookup *)FM_MURAM_AllocMem(
28395 + p_FmPcd->h_FmMuram, FM_PCD_CC_AD_ENTRY_SIZE,
28396 + FM_PCD_CC_AD_TABLE_ALIGN);
28397 + if (!p_Manip->fragParams.p_Frag)
28398 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
28399 + ("MURAM alloc for Fragmentation table descriptor"));
28400 + MemSet8(p_Manip->fragParams.p_Frag, 0, FM_PCD_CC_AD_ENTRY_SIZE);
28401 +
28402 + /* Prepare the third Ad register (pcAndOffsets)- OperationCode */
28403 + pcAndOffsetsReg = (uint32_t)HMAN_OC_IP_FRAGMENTATION;
28404 +
28405 + /* Prepare the first Ad register (ccAdBase) - Don't frag action and Action descriptor type*/
28406 + ccAdBaseReg = FM_PCD_AD_CONT_LOOKUP_TYPE;
28407 + ccAdBaseReg |= (p_ManipParams->dontFragAction
28408 + << FM_PCD_MANIP_IP_FRAG_DF_SHIFT);
28409 +
28410 +
28411 + /* Set Scatter/Gather BPid */
28412 + if (p_ManipParams->sgBpidEn)
28413 + {
28414 + ccAdBaseReg |= FM_PCD_MANIP_IP_FRAG_SG_BDID_EN;
28415 + pcAndOffsetsReg |= ((p_ManipParams->sgBpid
28416 + << FM_PCD_MANIP_IP_FRAG_SG_BDID_SHIFT)
28417 + & FM_PCD_MANIP_IP_FRAG_SG_BDID_MASK);
28418 + }
28419 +
28420 + /* Prepare the first Ad register (gmask) - scratch buffer pool id and Pointer to fragment ID */
28421 + gmaskReg = (uint32_t)(XX_VirtToPhys(UINT_TO_PTR(p_FmPcd->ipv6FrameIdAddr))
28422 + - p_FmPcd->physicalMuramBase);
28423 +#if (DPAA_VERSION == 10)
28424 + gmaskReg |= p_ManipParams->scratchBpid << FM_PCD_MANIP_IP_FRAG_SCRATCH_BPID;
28425 +#else
28426 + gmaskReg |= (0xFF) << FM_PCD_MANIP_IP_FRAG_SCRATCH_BPID;
28427 +#endif /* (DPAA_VERSION == 10) */
28428 +
28429 + /* Set all Ad registers */
28430 + WRITE_UINT32(p_Manip->fragParams.p_Frag->pcAndOffsets, pcAndOffsetsReg);
28431 + WRITE_UINT32(p_Manip->fragParams.p_Frag->ccAdBase, ccAdBaseReg);
28432 + WRITE_UINT32(p_Manip->fragParams.p_Frag->gmask, gmaskReg);
28433 +
28434 + /* Saves user's fragmentation manipulation parameters */
28435 + p_Manip->frag = TRUE;
28436 + p_Manip->sizeForFragmentation = p_ManipParams->sizeForFragmentation;
28437 +
28438 +#if (DPAA_VERSION == 10)
28439 + p_Manip->fragParams.scratchBpid = p_ManipParams->scratchBpid;
28440 +
28441 + /* scratch buffer pool initialization */
28442 + if ((err = FmPcdFragHcScratchPoolFill((t_Handle)p_FmPcd, p_ManipParams->scratchBpid)) != E_OK)
28443 + {
28444 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->fragParams.p_Frag);
28445 + p_Manip->fragParams.p_Frag = NULL;
28446 + RETURN_ERROR(MAJOR, err, NO_MSG);
28447 + }
28448 +#endif /* (DPAA_VERSION == 10) */
28449 +
28450 + return E_OK;
28451 +}
28452 +
28453 +static t_Error IPManip(t_FmPcdManip *p_Manip)
28454 +{
28455 + t_Error err = E_OK;
28456 + t_FmPcd *p_FmPcd;
28457 + t_AdOfTypeContLookup *p_Ad;
28458 + uint32_t tmpReg32 = 0, tmpRegNia = 0;
28459 +
28460 + SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
28461 + p_FmPcd = p_Manip->h_FmPcd;
28462 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
28463 +
28464 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
28465 +
28466 + tmpReg32 = FM_PCD_MANIP_IP_NO_FRAGMENTATION;
28467 + if (p_Manip->frag == TRUE)
28468 + {
28469 + tmpRegNia = (uint32_t)(XX_VirtToPhys(p_Manip->fragParams.p_Frag)
28470 + - (p_FmPcd->physicalMuramBase));
28471 + tmpReg32 = (uint32_t)p_Manip->sizeForFragmentation
28472 + << FM_PCD_MANIP_IP_MTU_SHIFT;
28473 + }
28474 +
28475 + tmpRegNia |= FM_PCD_AD_CONT_LOOKUP_TYPE;
28476 + tmpReg32 |= HMAN_OC_IP_MANIP;
28477 +
28478 +#if (DPAA_VERSION >= 11)
28479 + tmpRegNia |= FM_PCD_MANIP_IP_CNIA;
28480 +#endif /* (DPAA_VERSION >= 11) */
28481 +
28482 + WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
28483 + WRITE_UINT32(p_Ad->ccAdBase, tmpRegNia);
28484 + WRITE_UINT32(p_Ad->gmask, 0);
28485 + /* Total frame counter - MUST be initialized to zero.*/
28486 +
28487 + return err;
28488 +}
28489 +
28490 +static t_Error UpdateInitIpFrag(t_Handle h_FmPcd, t_Handle h_PcdParams,
28491 + t_Handle h_FmPort, t_FmPcdManip *p_Manip,
28492 + t_Handle h_Ad, bool validate)
28493 +{
28494 + t_FmPortGetSetCcParams fmPortGetSetCcParams;
28495 + t_Error err;
28496 +
28497 + SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
28498 + SANITY_CHECK_RETURN_ERROR((p_Manip->opcode == HMAN_OC_IP_FRAGMENTATION),
28499 + E_INVALID_STATE);
28500 + SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
28501 + SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
28502 +
28503 + UNUSED(h_FmPcd);
28504 + UNUSED(h_Ad);
28505 + UNUSED(h_PcdParams);
28506 + UNUSED(validate);
28507 + UNUSED(p_Manip);
28508 +
28509 + fmPortGetSetCcParams.setCcParams.type = 0;
28510 + fmPortGetSetCcParams.getCcParams.type = MANIP_EXTRA_SPACE;
28511 + if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams)) != E_OK)
28512 + RETURN_ERROR(MAJOR, err, NO_MSG);
28513 +
28514 + if (!fmPortGetSetCcParams.getCcParams.internalBufferOffset)
28515 + DBG(WARNING, ("manipExtraSpace must be larger than '0'"));
28516 +
28517 + return E_OK;
28518 +}
28519 +
28520 +static t_Error IPSecManip(t_FmPcdManipParams *p_ManipParams,
28521 + t_FmPcdManip *p_Manip)
28522 +{
28523 + t_AdOfTypeContLookup *p_Ad;
28524 + t_FmPcdManipSpecialOffloadIPSecParams *p_IPSecParams;
28525 + t_Error err = E_OK;
28526 + uint32_t tmpReg32 = 0;
28527 + uint32_t power;
28528 +
28529 + SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
28530 + SANITY_CHECK_RETURN_ERROR(p_ManipParams, E_INVALID_HANDLE);
28531 +
28532 + p_IPSecParams = &p_ManipParams->u.specialOffload.u.ipsec;
28533 +
28534 + SANITY_CHECK_RETURN_ERROR(
28535 + !p_IPSecParams->variableIpHdrLen || p_IPSecParams->decryption,
28536 + E_INVALID_VALUE);
28537 + SANITY_CHECK_RETURN_ERROR(
28538 + !p_IPSecParams->variableIpVersion || !p_IPSecParams->decryption,
28539 + E_INVALID_VALUE);
28540 + SANITY_CHECK_RETURN_ERROR(
28541 + !p_IPSecParams->variableIpVersion || p_IPSecParams->outerIPHdrLen,
28542 + E_INVALID_VALUE);
28543 + SANITY_CHECK_RETURN_ERROR(
28544 + !p_IPSecParams->arwSize || p_IPSecParams->arwAddr,
28545 + E_INVALID_VALUE);
28546 + SANITY_CHECK_RETURN_ERROR(
28547 + !p_IPSecParams->arwSize || p_IPSecParams->decryption,
28548 + E_INVALID_VALUE);
28549 + SANITY_CHECK_RETURN_ERROR((p_IPSecParams->arwSize % 16) == 0, E_INVALID_VALUE);
28550 +
28551 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
28552 +
28553 + tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
28554 + tmpReg32 |= (p_IPSecParams->decryption) ? FM_PCD_MANIP_IPSEC_DEC : 0;
28555 + tmpReg32 |= (p_IPSecParams->ecnCopy) ? FM_PCD_MANIP_IPSEC_ECN_EN : 0;
28556 + tmpReg32 |= (p_IPSecParams->dscpCopy) ? FM_PCD_MANIP_IPSEC_DSCP_EN : 0;
28557 + tmpReg32 |=
28558 + (p_IPSecParams->variableIpHdrLen) ? FM_PCD_MANIP_IPSEC_VIPL_EN : 0;
28559 + tmpReg32 |=
28560 + (p_IPSecParams->variableIpVersion) ? FM_PCD_MANIP_IPSEC_VIPV_EN : 0;
28561 + if (p_IPSecParams->arwSize)
28562 + tmpReg32 |= (uint32_t)((XX_VirtToPhys(UINT_TO_PTR(p_IPSecParams->arwAddr))-FM_MM_MURAM)
28563 + & (FM_MURAM_SIZE-1));
28564 + WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
28565 +
28566 + tmpReg32 = 0;
28567 + if (p_IPSecParams->arwSize) {
28568 + NEXT_POWER_OF_2((p_IPSecParams->arwSize + 32), power);
28569 + LOG2(power, power);
28570 + tmpReg32 = (p_IPSecParams->arwSize | (power - 5)) << FM_PCD_MANIP_IPSEC_ARW_SIZE_SHIFT;
28571 + }
28572 +
28573 + if (p_ManipParams->h_NextManip)
28574 + tmpReg32 |=
28575 + (uint32_t)(XX_VirtToPhys(((t_FmPcdManip *)p_ManipParams->h_NextManip)->h_Ad)-
28576 + (((t_FmPcd *)p_Manip->h_FmPcd)->physicalMuramBase)) >> 4;
28577 + WRITE_UINT32(p_Ad->matchTblPtr, tmpReg32);
28578 +
28579 + tmpReg32 = HMAN_OC_IPSEC_MANIP;
28580 + tmpReg32 |= p_IPSecParams->outerIPHdrLen
28581 + << FM_PCD_MANIP_IPSEC_IP_HDR_LEN_SHIFT;
28582 + if (p_ManipParams->h_NextManip)
28583 + tmpReg32 |= FM_PCD_MANIP_IPSEC_NADEN;
28584 + WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
28585 +
28586 + return err;
28587 +}
28588 +
28589 +static t_Error SetCapwapReassmManip(t_FmPcdManip *p_Manip)
28590 +{
28591 + t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
28592 +
28593 + /* Allocation if CAPWAP Action descriptor */
28594 + p_Manip->reassmParams.capwap.h_Ad = (t_Handle)XX_MallocSmart(
28595 + FM_PCD_CC_AD_ENTRY_SIZE, p_Manip->reassmParams.dataMemId,
28596 + FM_PCD_CC_AD_TABLE_ALIGN);
28597 + if (!p_Manip->reassmParams.capwap.h_Ad)
28598 + {
28599 + ReleaseManipHandler(p_Manip, p_FmPcd);
28600 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
28601 + ("Allocation of CAPWAP table descriptor"));
28602 + }
28603 +
28604 + memset(p_Manip->reassmParams.capwap.h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
28605 +
28606 + /* Fill reassembly manipulation parameter in the Reassembly Action Descriptor */
28607 + return FillReassmManipParams(p_Manip, HEADER_TYPE_CAPWAP);
28608 +}
28609 +
28610 +static void setCapwapReassmSchemeParams(t_FmPcd* p_FmPcd,
28611 + t_FmPcdKgSchemeParams *p_Scheme,
28612 + t_Handle h_CcTree, uint8_t groupId)
28613 +{
28614 + uint8_t res;
28615 +
28616 + /* Configures scheme's network environment parameters */
28617 + p_Scheme->netEnvParams.numOfDistinctionUnits = 1;
28618 + res = FmPcdNetEnvGetUnitId(
28619 + p_FmPcd, FmPcdGetNetEnvId(p_Scheme->netEnvParams.h_NetEnv),
28620 + HEADER_TYPE_USER_DEFINED_SHIM2, FALSE, 0);
28621 + ASSERT_COND(res != FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
28622 + p_Scheme->netEnvParams.unitIds[0] = res;
28623 +
28624 + /* Configures scheme's next engine parameters*/
28625 + p_Scheme->nextEngine = e_FM_PCD_CC;
28626 + p_Scheme->kgNextEngineParams.cc.h_CcTree = h_CcTree;
28627 + p_Scheme->kgNextEngineParams.cc.grpId = groupId;
28628 + p_Scheme->useHash = TRUE;
28629 +
28630 + /* Configures scheme's key*/
28631 + p_Scheme->keyExtractAndHashParams.numOfUsedExtracts = 2;
28632 + p_Scheme->keyExtractAndHashParams.extractArray[0].type =
28633 + e_FM_PCD_EXTRACT_NON_HDR;
28634 + p_Scheme->keyExtractAndHashParams.extractArray[0].extractNonHdr.src =
28635 + e_FM_PCD_EXTRACT_FROM_PARSE_RESULT;
28636 + p_Scheme->keyExtractAndHashParams.extractArray[0].extractNonHdr.action =
28637 + e_FM_PCD_ACTION_NONE;
28638 + p_Scheme->keyExtractAndHashParams.extractArray[0].extractNonHdr.offset = 20;
28639 + p_Scheme->keyExtractAndHashParams.extractArray[0].extractNonHdr.size = 4;
28640 + p_Scheme->keyExtractAndHashParams.extractArray[1].type =
28641 + e_FM_PCD_EXTRACT_NON_HDR;
28642 + p_Scheme->keyExtractAndHashParams.extractArray[1].extractNonHdr.src =
28643 + e_FM_PCD_EXTRACT_FROM_DFLT_VALUE;
28644 + p_Scheme->keyExtractAndHashParams.extractArray[1].extractNonHdr.action =
28645 + e_FM_PCD_ACTION_NONE;
28646 + p_Scheme->keyExtractAndHashParams.extractArray[1].extractNonHdr.offset = 0;
28647 + p_Scheme->keyExtractAndHashParams.extractArray[1].extractNonHdr.size = 1;
28648 +
28649 + p_Scheme->keyExtractAndHashParams.privateDflt0 = 0x0;
28650 + p_Scheme->keyExtractAndHashParams.privateDflt1 = 0x0;
28651 + p_Scheme->keyExtractAndHashParams.numOfUsedDflts = 1;
28652 + p_Scheme->keyExtractAndHashParams.dflts[0].type = e_FM_PCD_KG_GENERIC_NOT_FROM_DATA;
28653 + p_Scheme->keyExtractAndHashParams.dflts[0].dfltSelect = e_FM_PCD_KG_DFLT_PRIVATE_0;
28654 +}
28655 +
28656 +#if (DPAA_VERSION >= 11)
28657 +static t_Error CapwapReassemblyStats(t_FmPcdManip *p_Manip,
28658 + t_FmPcdManipReassemCapwapStats *p_Stats)
28659 +{
28660 + ASSERT_COND(p_Manip);
28661 + ASSERT_COND(p_Stats);
28662 + ASSERT_COND(p_Manip->reassmParams.p_ReassCommonTbl);
28663 +
28664 + p_Stats->timeout =
28665 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalTimeOutCounter);
28666 + p_Stats->rfdPoolBusy =
28667 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalRfdPoolBusyCounter);
28668 + p_Stats->internalBufferBusy =
28669 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalInternalBufferBusy);
28670 + p_Stats->externalBufferBusy =
28671 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalExternalBufferBusy);
28672 + p_Stats->sgFragments =
28673 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalSgFragmentCounter);
28674 + p_Stats->dmaSemaphoreDepletion =
28675 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalDmaSemaphoreDepletionCounter);
28676 + p_Stats->exceedMaxReassemblyFrameLen =
28677 + GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalNCSPCounter);
28678 +
28679 + p_Stats->successfullyReassembled =
28680 + GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalSuccessfullyReasmFramesCounter);
28681 + p_Stats->validFragments =
28682 + GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalValidFragmentCounter);
28683 + p_Stats->processedFragments =
28684 + GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalProcessedFragCounter);
28685 + p_Stats->malformedFragments =
28686 + GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalMalformdFragCounter);
28687 + p_Stats->autoLearnBusy =
28688 + GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalSetBusyCounter);
28689 + p_Stats->discardedFragments =
28690 + GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalDiscardedFragsCounter);
28691 + p_Stats->moreThan16Fragments =
28692 + GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalMoreThan16FramesCounter);
28693 +
28694 + return E_OK;
28695 +}
28696 +
28697 +static t_Error CapwapFragmentationStats(t_FmPcdManip *p_Manip,
28698 + t_FmPcdManipFragCapwapStats *p_Stats)
28699 +{
28700 + t_AdOfTypeContLookup *p_Ad;
28701 +
28702 + ASSERT_COND(p_Manip);
28703 + ASSERT_COND(p_Stats);
28704 + ASSERT_COND(p_Manip->h_Ad);
28705 + ASSERT_COND(p_Manip->fragParams.p_Frag);
28706 +
28707 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
28708 +
28709 + p_Stats->totalFrames = GET_UINT32(p_Ad->gmask);
28710 +
28711 + return E_OK;
28712 +}
28713 +
28714 +static t_Error CapwapReassembly(t_FmPcdManipReassemParams *p_ManipReassmParams,
28715 + t_FmPcdManip *p_Manip)
28716 +{
28717 + uint32_t maxSetNumber = 10000;
28718 + t_FmPcdManipReassemCapwapParams reassmManipParams =
28719 + p_ManipReassmParams->u.capwapReassem;
28720 + t_Error res;
28721 +
28722 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_FmPcd, E_INVALID_HANDLE);
28723 + SANITY_CHECK_RETURN_ERROR(((t_FmPcd *)p_Manip->h_FmPcd)->h_Hc,
28724 + E_INVALID_HANDLE);
28725 +
28726 + /* Check validation of user's parameter.*/
28727 + if ((reassmManipParams.timeoutThresholdForReassmProcess < 1000)
28728 + || (reassmManipParams.timeoutThresholdForReassmProcess > 8000000))
28729 + RETURN_ERROR(
28730 + MAJOR, E_INVALID_VALUE,
28731 + ("timeoutThresholdForReassmProcess should be 1msec - 8sec"));
28732 + /* It is recommended that the total number of entries in this table (number of sets * number of ways)
28733 + will be twice the number of frames that are expected to be reassembled simultaneously.*/
28734 + if (reassmManipParams.maxNumFramesInProcess
28735 + > (reassmManipParams.maxNumFramesInProcess * maxSetNumber / 2))
28736 + RETURN_ERROR(
28737 + MAJOR,
28738 + E_INVALID_VALUE,
28739 + ("maxNumFramesInProcess has to be less than (maximun set number * number of ways / 2)"));
28740 +
28741 + /* Saves user's reassembly manipulation parameters */
28742 + p_Manip->reassmParams.capwap.relativeSchemeId =
28743 + reassmManipParams.relativeSchemeId;
28744 + p_Manip->reassmParams.capwap.numOfFramesPerHashEntry =
28745 + reassmManipParams.numOfFramesPerHashEntry;
28746 + p_Manip->reassmParams.capwap.maxRessembledsSize =
28747 + reassmManipParams.maxReassembledFrameLength;
28748 + p_Manip->reassmParams.maxNumFramesInProcess =
28749 + reassmManipParams.maxNumFramesInProcess;
28750 + p_Manip->reassmParams.timeOutMode = reassmManipParams.timeOutMode;
28751 + p_Manip->reassmParams.fqidForTimeOutFrames =
28752 + reassmManipParams.fqidForTimeOutFrames;
28753 + p_Manip->reassmParams.timeoutThresholdForReassmProcess =
28754 + reassmManipParams.timeoutThresholdForReassmProcess;
28755 + p_Manip->reassmParams.dataMemId = reassmManipParams.dataMemId;
28756 + p_Manip->reassmParams.dataLiodnOffset = reassmManipParams.dataLiodnOffset;
28757 +
28758 + /* Creates and initializes the Reassembly common parameter table */
28759 + CreateReassCommonTable(p_Manip);
28760 +
28761 + res = SetCapwapReassmManip(p_Manip);
28762 + if (res != E_OK)
28763 + return res;
28764 +
28765 + return E_OK;
28766 +}
28767 +
28768 +static t_Error CapwapFragmentation(t_FmPcdManipFragCapwapParams *p_ManipParams,
28769 + t_FmPcdManip *p_Manip)
28770 +{
28771 + t_FmPcd *p_FmPcd;
28772 + t_AdOfTypeContLookup *p_Ad;
28773 + uint32_t pcAndOffsetsReg = 0, ccAdBaseReg = 0, gmaskReg = 0;
28774 + uint32_t tmpReg32 = 0, tmpRegNia = 0;
28775 +
28776 + SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad, E_INVALID_HANDLE);
28777 + SANITY_CHECK_RETURN_ERROR(p_ManipParams->sizeForFragmentation != 0xFFFF,
28778 + E_INVALID_VALUE);
28779 + p_FmPcd = p_Manip->h_FmPcd;
28780 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
28781 +
28782 + /* Allocation of fragmentation Action Descriptor */
28783 + p_Manip->fragParams.p_Frag = (t_AdOfTypeContLookup *)FM_MURAM_AllocMem(
28784 + p_FmPcd->h_FmMuram, FM_PCD_CC_AD_ENTRY_SIZE,
28785 + FM_PCD_CC_AD_TABLE_ALIGN);
28786 + if (!p_Manip->fragParams.p_Frag)
28787 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
28788 + ("MURAM alloc for Fragmentation table descriptor"));
28789 + MemSet8(p_Manip->fragParams.p_Frag, 0, FM_PCD_CC_AD_ENTRY_SIZE);
28790 +
28791 + /* Prepare the third Ad register (pcAndOffsets)- OperationCode */
28792 + pcAndOffsetsReg = (uint32_t)HMAN_OC_CAPWAP_FRAGMENTATION;
28793 +
28794 + /* Prepare the first Ad register (ccAdBase) - Don't frag action and Action descriptor type*/
28795 + ccAdBaseReg = FM_PCD_AD_CONT_LOOKUP_TYPE;
28796 + ccAdBaseReg |=
28797 + (p_ManipParams->compressModeEn) ? FM_PCD_MANIP_CAPWAP_FRAG_COMPRESS_EN :
28798 + 0;
28799 +
28800 + /* Set Scatter/Gather BPid */
28801 + if (p_ManipParams->sgBpidEn)
28802 + {
28803 + ccAdBaseReg |= FM_PCD_MANIP_CAPWAP_FRAG_SG_BDID_EN;
28804 + pcAndOffsetsReg |= ((p_ManipParams->sgBpid
28805 + << FM_PCD_MANIP_CAPWAP_FRAG_SG_BDID_SHIFT)
28806 + & FM_PCD_MANIP_CAPWAP_FRAG_SG_BDID_MASK);
28807 + }
28808 +
28809 + /* Prepare the first Ad register (gmask) - scratch buffer pool id and Pointer to fragment ID */
28810 + gmaskReg = (uint32_t)(XX_VirtToPhys(UINT_TO_PTR(p_FmPcd->capwapFrameIdAddr))
28811 + - p_FmPcd->physicalMuramBase);
28812 + gmaskReg |= (0xFF) << FM_PCD_MANIP_IP_FRAG_SCRATCH_BPID;
28813 +
28814 + /* Set all Ad registers */
28815 + WRITE_UINT32(p_Manip->fragParams.p_Frag->pcAndOffsets, pcAndOffsetsReg);
28816 + WRITE_UINT32(p_Manip->fragParams.p_Frag->ccAdBase, ccAdBaseReg);
28817 + WRITE_UINT32(p_Manip->fragParams.p_Frag->gmask, gmaskReg);
28818 +
28819 + /* Saves user's fragmentation manipulation parameters */
28820 + p_Manip->frag = TRUE;
28821 + p_Manip->sizeForFragmentation = p_ManipParams->sizeForFragmentation;
28822 +
28823 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
28824 +
28825 + tmpRegNia = (uint32_t)(XX_VirtToPhys(p_Manip->fragParams.p_Frag)
28826 + - (p_FmPcd->physicalMuramBase));
28827 + tmpReg32 = (uint32_t)p_Manip->sizeForFragmentation
28828 + << FM_PCD_MANIP_CAPWAP_FRAG_CHECK_MTU_SHIFT;
28829 +
28830 + tmpRegNia |= FM_PCD_AD_CONT_LOOKUP_TYPE;
28831 + tmpReg32 |= HMAN_OC_CAPWAP_FRAG_CHECK;
28832 +
28833 + tmpRegNia |= FM_PCD_MANIP_CAPWAP_FRAG_CHECK_CNIA;
28834 +
28835 + WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
28836 + WRITE_UINT32(p_Ad->ccAdBase, tmpRegNia);
28837 + WRITE_UINT32(p_Ad->gmask, 0);
28838 + /* Total frame counter - MUST be initialized to zero.*/
28839 +
28840 + return E_OK;
28841 +}
28842 +
28843 +static t_Error UpdateInitCapwapFrag(t_Handle h_FmPcd, t_Handle h_PcdParams,
28844 + t_Handle h_FmPort, t_FmPcdManip *p_Manip,
28845 + t_Handle h_Ad, bool validate)
28846 +{
28847 + t_FmPortGetSetCcParams fmPortGetSetCcParams;
28848 + t_Error err;
28849 +
28850 + SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
28851 + SANITY_CHECK_RETURN_ERROR((p_Manip->opcode == HMAN_OC_CAPWAP_FRAGMENTATION),
28852 + E_INVALID_STATE);
28853 + SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
28854 + SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
28855 +
28856 + UNUSED(h_FmPcd);
28857 + UNUSED(h_Ad);
28858 + UNUSED(h_PcdParams);
28859 + UNUSED(validate);
28860 + UNUSED(p_Manip);
28861 +
28862 + fmPortGetSetCcParams.setCcParams.type = 0;
28863 + fmPortGetSetCcParams.getCcParams.type = MANIP_EXTRA_SPACE;
28864 + if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams)) != E_OK)
28865 + RETURN_ERROR(MAJOR, err, NO_MSG);
28866 +
28867 + if (!fmPortGetSetCcParams.getCcParams.internalBufferOffset)
28868 + DBG(WARNING, ("manipExtraSpace must be larger than '0'"));
28869 +
28870 + return E_OK;
28871 +}
28872 +
28873 +static t_Error CapwapManip(t_FmPcdManipParams *p_ManipParams,
28874 + t_FmPcdManip *p_Manip)
28875 +{
28876 + t_AdOfTypeContLookup *p_Ad;
28877 + t_FmPcdManipSpecialOffloadCapwapParams *p_Params;
28878 + t_Error err = E_OK;
28879 + uint32_t tmpReg32 = 0;
28880 +
28881 + SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
28882 + SANITY_CHECK_RETURN_ERROR(p_ManipParams, E_INVALID_HANDLE);
28883 +
28884 + p_Params = &p_ManipParams->u.specialOffload.u.capwap;
28885 +
28886 + p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
28887 + tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
28888 + tmpReg32 |= (p_Params->dtls) ? FM_PCD_MANIP_CAPWAP_DTLS : 0;
28889 + /* TODO - add 'qosSrc' */
28890 + WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
28891 +
28892 + tmpReg32 = HMAN_OC_CAPWAP_MANIP;
28893 + if (p_ManipParams->h_NextManip)
28894 + {
28895 + WRITE_UINT32(
28896 + p_Ad->matchTblPtr,
28897 + (uint32_t)(XX_VirtToPhys(((t_FmPcdManip *)p_ManipParams->h_NextManip)->h_Ad)- (((t_FmPcd *)p_Manip->h_FmPcd)->physicalMuramBase)) >> 4);
28898 +
28899 + tmpReg32 |= FM_PCD_MANIP_CAPWAP_NADEN;
28900 + }
28901 +
28902 + WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
28903 +
28904 + return err;
28905 +}
28906 +#endif /* (DPAA_VERSION >= 11) */
28907 +
28908 +static t_Handle ManipOrStatsSetNode(t_Handle h_FmPcd, t_Handle *p_Params,
28909 + bool stats)
28910 +{
28911 + t_FmPcdManip *p_Manip;
28912 + t_Error err;
28913 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
28914 +
28915 + p_Manip = (t_FmPcdManip*)XX_Malloc(sizeof(t_FmPcdManip));
28916 + if (!p_Manip)
28917 + {
28918 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));
28919 + return NULL;
28920 + }
28921 + memset(p_Manip, 0, sizeof(t_FmPcdManip));
28922 +
28923 + p_Manip->type = ((t_FmPcdManipParams *)p_Params)->type;
28924 + memcpy((uint8_t*)&p_Manip->manipParams, p_Params,
28925 + sizeof(p_Manip->manipParams));
28926 +
28927 + if (!stats)
28928 + err = CheckManipParamsAndSetType(p_Manip,
28929 + (t_FmPcdManipParams *)p_Params);
28930 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
28931 + else
28932 + err = CheckStatsParamsAndSetType(p_Manip, (t_FmPcdStatsParams *)p_Params);
28933 +#else /* not (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
28934 + else
28935 + {
28936 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Statistics node!"));
28937 + XX_Free(p_Manip);
28938 + return NULL;
28939 + }
28940 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
28941 + if (err)
28942 + {
28943 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Invalid header manipulation type"));
28944 + XX_Free(p_Manip);
28945 + return NULL;
28946 + }
28947 +
28948 + if ((p_Manip->opcode != HMAN_OC_IP_REASSEMBLY) && (p_Manip->opcode != HMAN_OC_CAPWAP_REASSEMBLY))
28949 + {
28950 + /* In Case of reassembly manipulation the reassembly action descriptor will
28951 + be defines later on */
28952 + if (p_Manip->muramAllocate)
28953 + {
28954 + p_Manip->h_Ad = (t_Handle)FM_MURAM_AllocMem(
28955 + p_FmPcd->h_FmMuram, FM_PCD_CC_AD_ENTRY_SIZE,
28956 + FM_PCD_CC_AD_TABLE_ALIGN);
28957 + if (!p_Manip->h_Ad)
28958 + {
28959 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for Manipulation action descriptor"));
28960 + ReleaseManipHandler(p_Manip, p_FmPcd);
28961 + XX_Free(p_Manip);
28962 + return NULL;
28963 + }
28964 +
28965 + MemSet8(p_Manip->h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
28966 + }
28967 + else
28968 + {
28969 + p_Manip->h_Ad = (t_Handle)XX_Malloc(
28970 + FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t));
28971 + if (!p_Manip->h_Ad)
28972 + {
28973 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Allocation of Manipulation action descriptor"));
28974 + ReleaseManipHandler(p_Manip, p_FmPcd);
28975 + XX_Free(p_Manip);
28976 + return NULL;
28977 + }
28978 +
28979 + memset(p_Manip->h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t));
28980 + }
28981 + }
28982 +
28983 + p_Manip->h_FmPcd = h_FmPcd;
28984 +
28985 + return p_Manip;
28986 +}
28987 +
28988 +static void UpdateAdPtrOfNodesWhichPointsOnCrntMdfManip(
28989 + t_FmPcdManip *p_CrntMdfManip, t_List *h_NodesLst)
28990 +{
28991 + t_CcNodeInformation *p_CcNodeInformation;
28992 + t_FmPcdCcNode *p_NodePtrOnCurrentMdfManip = NULL;
28993 + t_List *p_Pos;
28994 + int i = 0;
28995 + t_Handle p_AdTablePtOnCrntCurrentMdfNode/*, p_AdTableNewModified*/;
28996 + t_CcNodeInformation ccNodeInfo;
28997 +
28998 + LIST_FOR_EACH(p_Pos, &p_CrntMdfManip->nodesLst)
28999 + {
29000 + p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
29001 + p_NodePtrOnCurrentMdfManip =
29002 + (t_FmPcdCcNode *)p_CcNodeInformation->h_CcNode;
29003 +
29004 + ASSERT_COND(p_NodePtrOnCurrentMdfManip);
29005 +
29006 + /* Search in the previous node which exact index points on this current modified node for getting AD */
29007 + for (i = 0; i < p_NodePtrOnCurrentMdfManip->numOfKeys + 1; i++)
29008 + {
29009 + if (p_NodePtrOnCurrentMdfManip->keyAndNextEngineParams[i].nextEngineParams.nextEngine
29010 + == e_FM_PCD_CC)
29011 + {
29012 + if (p_NodePtrOnCurrentMdfManip->keyAndNextEngineParams[i].nextEngineParams.h_Manip
29013 + == (t_Handle)p_CrntMdfManip)
29014 + {
29015 + if (p_NodePtrOnCurrentMdfManip->keyAndNextEngineParams[i].p_StatsObj)
29016 + p_AdTablePtOnCrntCurrentMdfNode =
29017 + p_NodePtrOnCurrentMdfManip->keyAndNextEngineParams[i].p_StatsObj->h_StatsAd;
29018 + else
29019 + p_AdTablePtOnCrntCurrentMdfNode =
29020 + PTR_MOVE(p_NodePtrOnCurrentMdfManip->h_AdTable, i*FM_PCD_CC_AD_ENTRY_SIZE);
29021 +
29022 + memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
29023 + ccNodeInfo.h_CcNode = p_AdTablePtOnCrntCurrentMdfNode;
29024 + EnqueueNodeInfoToRelevantLst(h_NodesLst, &ccNodeInfo, NULL);
29025 + }
29026 + }
29027 + }
29028 +
29029 + ASSERT_COND(i != p_NodePtrOnCurrentMdfManip->numOfKeys);
29030 + }
29031 +}
29032 +
29033 +static void BuildHmtd(uint8_t *p_Dest, uint8_t *p_Src, uint8_t *p_Hmcd,
29034 + t_FmPcd *p_FmPcd)
29035 +{
29036 + t_Error err;
29037 +
29038 + /* Copy the HMTD */
29039 + MemCpy8(p_Dest, (uint8_t*)p_Src, 16);
29040 + /* Replace the HMCT table pointer */
29041 + WRITE_UINT32(
29042 + ((t_Hmtd *)p_Dest)->hmcdBasePtr,
29043 + (uint32_t)(XX_VirtToPhys(p_Hmcd) - ((t_FmPcd*)p_FmPcd)->physicalMuramBase));
29044 + /* Call Host Command to replace HMTD by a new HMTD */
29045 + err = FmHcPcdCcDoDynamicChange(
29046 + p_FmPcd->h_Hc,
29047 + (uint32_t)(XX_VirtToPhys(p_Src) - p_FmPcd->physicalMuramBase),
29048 + (uint32_t)(XX_VirtToPhys(p_Dest) - p_FmPcd->physicalMuramBase));
29049 + if (err)
29050 + REPORT_ERROR(MINOR, err, ("Failed in dynamic manip change, continued to the rest of the owners."));
29051 +}
29052 +
29053 +static t_Error FmPcdManipInitUpdate(t_Handle h_FmPcd, t_Handle h_PcdParams,
29054 + t_Handle h_FmPort, t_Handle h_Manip,
29055 + t_Handle h_Ad, bool validate, int level,
29056 + t_Handle h_FmTree)
29057 +{
29058 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
29059 + t_Error err = E_OK;
29060 +
29061 + SANITY_CHECK_RETURN_ERROR(h_Manip, E_INVALID_HANDLE);
29062 +
29063 + UNUSED(level);
29064 + UNUSED(h_FmTree);
29065 +
29066 + switch (p_Manip->opcode)
29067 + {
29068 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
29069 + case (HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
29070 + err = UpdateInitMvIntFrameHeaderFromFrameToBufferPrefix(h_FmPort,
29071 + p_Manip,
29072 + h_Ad,
29073 + validate);
29074 + break;
29075 + case (HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
29076 + if (!p_Manip->h_Frag)
29077 + break;
29078 + case (HMAN_OC_CAPWAP_FRAGMENTATION):
29079 + err = UpdateInitCapwapFragmentation(h_FmPort, p_Manip, h_Ad, validate, h_FmTree);
29080 + break;
29081 + case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
29082 + if (p_Manip->h_Frag)
29083 + err = UpdateInitCapwapReasm(h_FmPcd, h_FmPort, p_Manip, h_Ad, validate);
29084 + break;
29085 + case (HMAN_OC_CAPWAP_INDEXED_STATS):
29086 + err = UpdateIndxStats(h_FmPcd, h_FmPort, p_Manip);
29087 + break;
29088 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
29089 + case (HMAN_OC_IP_REASSEMBLY):
29090 + err = UpdateInitReasm(h_FmPcd, h_PcdParams, h_FmPort, p_Manip, h_Ad,
29091 + validate);
29092 + break;
29093 + case (HMAN_OC_IP_FRAGMENTATION):
29094 + err = UpdateInitIpFrag(h_FmPcd, h_PcdParams, h_FmPort, p_Manip,
29095 + h_Ad, validate);
29096 + break;
29097 +#if (DPAA_VERSION >= 11)
29098 + case (HMAN_OC_CAPWAP_FRAGMENTATION):
29099 + err = UpdateInitCapwapFrag(h_FmPcd, h_PcdParams, h_FmPort, p_Manip,
29100 + h_Ad, validate);
29101 + break;
29102 + case (HMAN_OC_CAPWAP_REASSEMBLY):
29103 + err = UpdateInitReasm(h_FmPcd, h_PcdParams, h_FmPort, p_Manip, h_Ad,
29104 + validate);
29105 + break;
29106 +#endif /* (DPAA_VERSION >= 11) */
29107 + default:
29108 + return E_OK;
29109 + }
29110 +
29111 + return err;
29112 +}
29113 +
29114 +static t_Error FmPcdManipModifyUpdate(t_Handle h_Manip, t_Handle h_Ad,
29115 + bool validate, int level,
29116 + t_Handle h_FmTree)
29117 +{
29118 +
29119 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
29120 + t_Error err = E_OK;
29121 +
29122 + UNUSED(level);
29123 +
29124 + switch (p_Manip->opcode)
29125 + {
29126 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
29127 + case (HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
29128 + RETURN_ERROR(
29129 + MAJOR,
29130 + E_INVALID_STATE,
29131 + ("modify node with this type of manipulation is not suppported"));
29132 + case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
29133 +
29134 + if (p_Manip->h_Frag)
29135 + {
29136 + if (!(p_Manip->shadowUpdateParams & NUM_OF_TASKS)
29137 + && !(p_Manip->shadowUpdateParams & OFFSET_OF_DATA)
29138 + && !(p_Manip->shadowUpdateParams & OFFSET_OF_PR))
29139 + RETURN_ERROR(
29140 + MAJOR,
29141 + E_INVALID_STATE,
29142 + ("modify node with this type of manipulation requires manipulation be updated previously in SetPcd function"));
29143 + }
29144 + break;
29145 + case (HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
29146 + if (p_Manip->h_Frag)
29147 + err = UpdateModifyCapwapFragmenation(p_Manip, h_Ad, validate, h_FmTree);
29148 + break;
29149 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
29150 + default:
29151 + return E_OK;
29152 + }
29153 +
29154 + return err;
29155 +}
29156 +
29157 +/*****************************************************************************/
29158 +/* Inter-module API routines */
29159 +/*****************************************************************************/
29160 +
29161 +t_Error FmPcdManipUpdate(t_Handle h_FmPcd, t_Handle h_PcdParams,
29162 + t_Handle h_FmPort, t_Handle h_Manip, t_Handle h_Ad,
29163 + bool validate, int level, t_Handle h_FmTree,
29164 + bool modify)
29165 +{
29166 + t_Error err;
29167 +
29168 + if (!modify)
29169 + err = FmPcdManipInitUpdate(h_FmPcd, h_PcdParams, h_FmPort, h_Manip,
29170 + h_Ad, validate, level, h_FmTree);
29171 + else
29172 + err = FmPcdManipModifyUpdate(h_Manip, h_Ad, validate, level, h_FmTree);
29173 +
29174 + return err;
29175 +}
29176 +
29177 +void FmPcdManipUpdateOwner(t_Handle h_Manip, bool add)
29178 +{
29179 +
29180 + uint32_t intFlags;
29181 +
29182 + intFlags = XX_LockIntrSpinlock(((t_FmPcdManip *)h_Manip)->h_Spinlock);
29183 + if (add)
29184 + ((t_FmPcdManip *)h_Manip)->owner++;
29185 + else
29186 + {
29187 + ASSERT_COND(((t_FmPcdManip *)h_Manip)->owner);
29188 + ((t_FmPcdManip *)h_Manip)->owner--;
29189 + }
29190 + XX_UnlockIntrSpinlock(((t_FmPcdManip *)h_Manip)->h_Spinlock, intFlags);
29191 +}
29192 +
29193 +t_List *FmPcdManipGetNodeLstPointedOnThisManip(t_Handle h_Manip)
29194 +{
29195 + ASSERT_COND(h_Manip);
29196 + return &((t_FmPcdManip *)h_Manip)->nodesLst;
29197 +}
29198 +
29199 +t_List *FmPcdManipGetSpinlock(t_Handle h_Manip)
29200 +{
29201 + ASSERT_COND(h_Manip);
29202 + return ((t_FmPcdManip *)h_Manip)->h_Spinlock;
29203 +}
29204 +
29205 +t_Error FmPcdManipCheckParamsForCcNextEngine(
29206 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,
29207 + uint32_t *requiredAction)
29208 +{
29209 + t_FmPcdManip *p_Manip;
29210 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
29211 + t_Error err = E_OK;
29212 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))*/
29213 + bool pointFromCc = TRUE;
29214 +
29215 + SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
29216 + SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams->h_Manip,
29217 + E_NULL_POINTER);
29218 +
29219 + p_Manip = (t_FmPcdManip *)(p_FmPcdCcNextEngineParams->h_Manip);
29220 + *requiredAction = 0;
29221 +
29222 + while (p_Manip)
29223 + {
29224 + switch (p_Manip->opcode)
29225 + {
29226 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
29227 + case (HMAN_OC_CAPWAP_INDEXED_STATS):
29228 + if (p_FmPcdCcNextEngineParams->nextEngine != e_FM_PCD_DONE)
29229 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For this type of header manipulation has to be nextEngine e_FM_PCD_DONE"));
29230 + if (p_FmPcdCcNextEngineParams->params.enqueueParams.overrideFqid)
29231 + p_Manip->cnia = TRUE;
29232 + case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
29233 + *requiredAction = UPDATE_NIA_ENQ_WITHOUT_DMA;
29234 + case (HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR):
29235 + p_Manip->ownerTmp++;
29236 + break;
29237 + case (HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
29238 + if ((p_FmPcdCcNextEngineParams->nextEngine != e_FM_PCD_DONE)
29239 + && !p_FmPcdCcNextEngineParams->params.enqueueParams.overrideFqid)
29240 + RETURN_ERROR(
29241 + MAJOR,
29242 + E_INVALID_STATE,
29243 + ("For this type of header manipulation has to be nextEngine e_FM_PCD_DONE with fqidForCtrlFlow FALSE"));
29244 + p_Manip->ownerTmp++;
29245 + break;
29246 + case (HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
29247 + if ((p_FmPcdCcNextEngineParams->nextEngine != e_FM_PCD_CC)
29248 + && (FmPcdCcGetParseCode(p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode)
29249 + != CC_PC_GENERIC_IC_HASH_INDEXED))
29250 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For this type of header manipulation next engine has to be CC and action = e_FM_PCD_ACTION_INDEXED_LOOKUP"));
29251 + err = UpdateManipIc(p_FmPcdCcNextEngineParams->h_Manip,
29252 + FmPcdCcGetOffset(p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode));
29253 + if (err)
29254 + RETURN_ERROR(MAJOR, err, NO_MSG);
29255 + *requiredAction = UPDATE_NIA_ENQ_WITHOUT_DMA;
29256 + break;
29257 + #endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
29258 + case (HMAN_OC_IP_FRAGMENTATION):
29259 + case (HMAN_OC_IP_REASSEMBLY):
29260 +#if (DPAA_VERSION >= 11)
29261 + case (HMAN_OC_CAPWAP_REASSEMBLY):
29262 + case (HMAN_OC_CAPWAP_FRAGMENTATION):
29263 +#endif /* (DPAA_VERSION >= 11) */
29264 + if (p_FmPcdCcNextEngineParams->nextEngine != e_FM_PCD_DONE)
29265 + RETURN_ERROR(
29266 + MAJOR,
29267 + E_INVALID_STATE,
29268 + ("For this type of header manipulation has to be nextEngine e_FM_PCD_DONE"));
29269 + p_Manip->ownerTmp++;
29270 + break;
29271 + case (HMAN_OC_IPSEC_MANIP):
29272 +#if (DPAA_VERSION >= 11)
29273 + case (HMAN_OC_CAPWAP_MANIP):
29274 +#endif /* (DPAA_VERSION >= 11) */
29275 + p_Manip->ownerTmp++;
29276 + break;
29277 + case (HMAN_OC):
29278 + if ((p_FmPcdCcNextEngineParams->nextEngine == e_FM_PCD_CC)
29279 + && MANIP_IS_CASCADED(p_Manip))
29280 + RETURN_ERROR(
29281 + MINOR,
29282 + E_INVALID_STATE,
29283 + ("Can't have a cascaded manipulation when and Next Engine is CC"));
29284 + if (!MANIP_IS_FIRST(p_Manip) && pointFromCc)
29285 + RETURN_ERROR(
29286 + MAJOR,
29287 + E_INVALID_STATE,
29288 + ("h_Manip is already used and may not be shared (no sharing of non-head manip nodes)"));
29289 + break;
29290 + default:
29291 + RETURN_ERROR(
29292 + MAJOR, E_INVALID_STATE,
29293 + ("invalid type of header manipulation for this state"));
29294 + }
29295 + p_Manip = p_Manip->h_NextManip;
29296 + pointFromCc = FALSE;
29297 + }
29298 + return E_OK;
29299 +}
29300 +
29301 +
29302 +t_Error FmPcdManipCheckParamsWithCcNodeParams(t_Handle h_Manip,
29303 + t_Handle h_FmPcdCcNode)
29304 +{
29305 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
29306 + t_Error err = E_OK;
29307 +
29308 + SANITY_CHECK_RETURN_ERROR(h_Manip, E_INVALID_HANDLE);
29309 + SANITY_CHECK_RETURN_ERROR(h_FmPcdCcNode, E_INVALID_HANDLE);
29310 +
29311 + switch (p_Manip->opcode)
29312 + {
29313 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
29314 + case (HMAN_OC_CAPWAP_INDEXED_STATS):
29315 + if (p_Manip->ownerTmp != FmPcdCcGetNumOfKeys(h_FmPcdCcNode))
29316 + RETURN_ERROR(
29317 + MAJOR,
29318 + E_INVALID_VALUE,
29319 + ("The manipulation of the type statistics flowId if exist has to be pointed by all numOfKeys"));
29320 + break;
29321 + case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
29322 + if (p_Manip->h_Frag)
29323 + {
29324 + if (p_Manip->ownerTmp != FmPcdCcGetNumOfKeys(h_FmPcdCcNode))
29325 + RETURN_ERROR(
29326 + MAJOR,
29327 + E_INVALID_VALUE,
29328 + ("The manipulation of the type remove DTLS if exist has to be pointed by all numOfKeys"));
29329 + err = UpdateManipIc(h_Manip, FmPcdCcGetOffset(h_FmPcdCcNode));
29330 + if (err)
29331 + RETURN_ERROR(MAJOR, err, NO_MSG);
29332 + }
29333 + break;
29334 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
29335 + default:
29336 + break;
29337 + }
29338 +
29339 + return err;
29340 +}
29341 +
29342 +void FmPcdManipUpdateAdResultForCc(
29343 + t_Handle h_Manip, t_FmPcdCcNextEngineParams *p_CcNextEngineParams,
29344 + t_Handle p_Ad, t_Handle *p_AdNewPtr)
29345 +{
29346 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
29347 +
29348 + /* This routine creates a Manip AD and can return in "p_AdNewPtr"
29349 + * either the new descriptor or NULL if it writes the Manip AD into p_AD (into the match table) */
29350 +
29351 + ASSERT_COND(p_Manip);
29352 + ASSERT_COND(p_CcNextEngineParams);
29353 + ASSERT_COND(p_Ad);
29354 + ASSERT_COND(p_AdNewPtr);
29355 +
29356 + FmPcdManipUpdateOwner(h_Manip, TRUE);
29357 +
29358 + /* According to "type", either build & initialize a new AD (p_AdNew) or initialize
29359 + * p_Ad ( the AD in the match table) and set p_AdNew = NULL. */
29360 + switch (p_Manip->opcode)
29361 + {
29362 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
29363 + case (HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR):
29364 + case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
29365 + case (HMAN_OC_CAPWAP_INDEXED_STATS):
29366 + *p_AdNewPtr = p_Manip->h_Ad;
29367 + break;
29368 + case (HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
29369 + case (HMAN_OC_CAPWAP_FRAGMENTATION):
29370 + WRITE_UINT32(((t_AdOfTypeResult *)p_Ad)->fqid,
29371 + ((t_AdOfTypeResult *)(p_Manip->h_Ad))->fqid);
29372 + WRITE_UINT32(((t_AdOfTypeResult *)p_Ad)->plcrProfile,
29373 + ((t_AdOfTypeResult *)(p_Manip->h_Ad))->plcrProfile);
29374 + WRITE_UINT32(((t_AdOfTypeResult *)p_Ad)->nia,
29375 + ((t_AdOfTypeResult *)(p_Manip->h_Ad))->nia);
29376 + *p_AdNewPtr = NULL;
29377 + break;
29378 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
29379 + case (HMAN_OC_IPSEC_MANIP):
29380 +#if (DPAA_VERSION >= 11)
29381 + case (HMAN_OC_CAPWAP_MANIP):
29382 +#endif /* (DPAA_VERSION >= 11) */
29383 + *p_AdNewPtr = p_Manip->h_Ad;
29384 + break;
29385 + case (HMAN_OC_IP_FRAGMENTATION):
29386 +#if (DPAA_VERSION >= 11)
29387 + case (HMAN_OC_CAPWAP_FRAGMENTATION):
29388 +#endif /* (DPAA_VERSION >= 11) */
29389 + if ((p_CcNextEngineParams->nextEngine == e_FM_PCD_DONE)
29390 + && (!p_CcNextEngineParams->params.enqueueParams.overrideFqid))
29391 + {
29392 + memcpy((uint8_t *)p_Ad, (uint8_t *)p_Manip->h_Ad,
29393 + sizeof(t_AdOfTypeContLookup));
29394 +#if (DPAA_VERSION >= 11)
29395 + WRITE_UINT32(
29396 + ((t_AdOfTypeContLookup *)p_Ad)->ccAdBase,
29397 + GET_UINT32(((t_AdOfTypeContLookup *)p_Ad)->ccAdBase) & ~FM_PCD_MANIP_IP_CNIA);
29398 +#endif /* (DPAA_VERSION >= 11) */
29399 + *p_AdNewPtr = NULL;
29400 + }
29401 + else
29402 + *p_AdNewPtr = p_Manip->h_Ad;
29403 + break;
29404 + case (HMAN_OC_IP_REASSEMBLY):
29405 + if (FmPcdManipIpReassmIsIpv6Hdr(p_Manip))
29406 + {
29407 + if (!p_Manip->reassmParams.ip.ipv6Assigned)
29408 + {
29409 + *p_AdNewPtr = p_Manip->reassmParams.ip.h_Ipv6Ad;
29410 + p_Manip->reassmParams.ip.ipv6Assigned = TRUE;
29411 + FmPcdManipUpdateOwner(h_Manip, FALSE);
29412 + }
29413 + else
29414 + {
29415 + *p_AdNewPtr = p_Manip->reassmParams.ip.h_Ipv4Ad;
29416 + p_Manip->reassmParams.ip.ipv6Assigned = FALSE;
29417 + }
29418 + }
29419 + else
29420 + *p_AdNewPtr = p_Manip->reassmParams.ip.h_Ipv4Ad;
29421 + memcpy((uint8_t *)p_Ad, (uint8_t *)*p_AdNewPtr,
29422 + sizeof(t_AdOfTypeContLookup));
29423 + *p_AdNewPtr = NULL;
29424 + break;
29425 +#if (DPAA_VERSION >= 11)
29426 + case (HMAN_OC_CAPWAP_REASSEMBLY):
29427 + *p_AdNewPtr = p_Manip->reassmParams.capwap.h_Ad;
29428 + memcpy((uint8_t *)p_Ad, (uint8_t *)*p_AdNewPtr,
29429 + sizeof(t_AdOfTypeContLookup));
29430 + *p_AdNewPtr = NULL;
29431 + break;
29432 +#endif /* (DPAA_VERSION >= 11) */
29433 + case (HMAN_OC):
29434 + /* Allocate and initialize HMTD */
29435 + *p_AdNewPtr = p_Manip->h_Ad;
29436 + break;
29437 + default:
29438 + break;
29439 + }
29440 +}
29441 +
29442 +void FmPcdManipUpdateAdContLookupForCc(t_Handle h_Manip, t_Handle p_Ad,
29443 + t_Handle *p_AdNewPtr,
29444 + uint32_t adTableOffset)
29445 +{
29446 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
29447 +
29448 + /* This routine creates a Manip AD and can return in "p_AdNewPtr"
29449 + * either the new descriptor or NULL if it writes the Manip AD into p_AD (into the match table) */
29450 + ASSERT_COND(p_Manip);
29451 +
29452 + FmPcdManipUpdateOwner(h_Manip, TRUE);
29453 +
29454 + switch (p_Manip->opcode)
29455 + {
29456 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
29457 + case (HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
29458 + WRITE_UINT32(((t_AdOfTypeContLookup *)p_Ad)->ccAdBase,
29459 + ((t_AdOfTypeContLookup *)(p_Manip->h_Ad))->ccAdBase);
29460 + WRITE_UINT32(
29461 + ((t_AdOfTypeContLookup *)p_Ad)->matchTblPtr,
29462 + ((t_AdOfTypeContLookup *)(p_Manip->h_Ad))->matchTblPtr);
29463 + WRITE_UINT32(
29464 + ((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets,
29465 + ((t_AdOfTypeContLookup *)(p_Manip->h_Ad))->pcAndOffsets);
29466 + WRITE_UINT32(((t_AdOfTypeContLookup *)p_Ad)->gmask,
29467 + ((t_AdOfTypeContLookup *)(p_Manip->h_Ad))->gmask);
29468 + WRITE_UINT32(
29469 + ((t_AdOfTypeContLookup *)p_Ad)->ccAdBase,
29470 + (GET_UINT32(((t_AdOfTypeContLookup *)p_Ad)->ccAdBase) | adTableOffset));
29471 + *p_AdNewPtr = NULL;
29472 + break;
29473 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
29474 + case (HMAN_OC):
29475 + /* Initialize HMTD within the match table*/
29476 + MemSet8(p_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
29477 + /* copy the existing HMTD *//* ask Alla - memcpy??? */
29478 + memcpy((uint8_t*)p_Ad, p_Manip->h_Ad, sizeof(t_Hmtd));
29479 + /* update NADEN to be "1"*/
29480 + WRITE_UINT16(
29481 + ((t_Hmtd *)p_Ad)->cfg,
29482 + (uint16_t)(GET_UINT16(((t_Hmtd *)p_Ad)->cfg) | HMTD_CFG_NEXT_AD_EN));
29483 + /* update next action descriptor */
29484 + WRITE_UINT16(((t_Hmtd *)p_Ad)->nextAdIdx,
29485 + (uint16_t)(adTableOffset >> 4));
29486 + /* mark that Manip's HMTD is not used */
29487 + *p_AdNewPtr = NULL;
29488 + break;
29489 +
29490 + default:
29491 + break;
29492 + }
29493 +}
29494 +
29495 +t_Error FmPcdManipBuildIpReassmScheme(t_FmPcd *p_FmPcd, t_Handle h_NetEnv,
29496 + t_Handle h_CcTree, t_Handle h_Manip,
29497 + bool isIpv4, uint8_t groupId)
29498 +{
29499 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
29500 + t_FmPcdKgSchemeParams *p_SchemeParams = NULL;
29501 + t_Handle h_Scheme;
29502 +
29503 + ASSERT_COND(p_FmPcd);
29504 + ASSERT_COND(h_NetEnv);
29505 + ASSERT_COND(p_Manip);
29506 +
29507 + /* scheme was already build, no need to check for IPv6 */
29508 + if (p_Manip->reassmParams.ip.h_Ipv4Scheme)
29509 + return E_OK;
29510 +
29511 + if (isIpv4) {
29512 + h_Scheme = FmPcdKgGetSchemeHandle(p_FmPcd, p_Manip->reassmParams.ip.relativeSchemeId[0]);
29513 + if (h_Scheme) {
29514 + /* scheme was found */
29515 + p_Manip->reassmParams.ip.h_Ipv4Scheme = h_Scheme;
29516 + return E_OK;
29517 + }
29518 + } else {
29519 + h_Scheme = FmPcdKgGetSchemeHandle(p_FmPcd, p_Manip->reassmParams.ip.relativeSchemeId[1]);
29520 + if (h_Scheme) {
29521 + /* scheme was found */
29522 + p_Manip->reassmParams.ip.h_Ipv6Scheme = h_Scheme;
29523 + return E_OK;
29524 + }
29525 + }
29526 +
29527 + p_SchemeParams = XX_Malloc(sizeof(t_FmPcdKgSchemeParams));
29528 + if (!p_SchemeParams)
29529 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
29530 + ("Memory allocation failed for scheme"));
29531 +
29532 + /* Configures the IPv4 or IPv6 scheme*/
29533 + memset(p_SchemeParams, 0, sizeof(t_FmPcdKgSchemeParams));
29534 + p_SchemeParams->netEnvParams.h_NetEnv = h_NetEnv;
29535 + p_SchemeParams->id.relativeSchemeId = (uint8_t)(
29536 + (isIpv4 == TRUE) ? p_Manip->reassmParams.ip.relativeSchemeId[0] :
29537 + p_Manip->reassmParams.ip.relativeSchemeId[1]);
29538 + p_SchemeParams->schemeCounter.update = TRUE;
29539 +#if (DPAA_VERSION >= 11)
29540 + p_SchemeParams->alwaysDirect = TRUE;
29541 + p_SchemeParams->bypassFqidGeneration = TRUE;
29542 +#else
29543 + p_SchemeParams->keyExtractAndHashParams.hashDistributionNumOfFqids = 1;
29544 + p_SchemeParams->baseFqid = 0xFFFFFF; /*TODO- baseFqid*/
29545 +#endif /* (DPAA_VERSION >= 11) */
29546 +
29547 + setIpReassmSchemeParams(p_FmPcd, p_SchemeParams, h_CcTree, isIpv4, groupId);
29548 +
29549 + /* Sets the new scheme */
29550 + if (isIpv4)
29551 + p_Manip->reassmParams.ip.h_Ipv4Scheme = FM_PCD_KgSchemeSet(
29552 + p_FmPcd, p_SchemeParams);
29553 + else
29554 + p_Manip->reassmParams.ip.h_Ipv6Scheme = FM_PCD_KgSchemeSet(
29555 + p_FmPcd, p_SchemeParams);
29556 +
29557 + XX_Free(p_SchemeParams);
29558 +
29559 + return E_OK;
29560 +}
29561 +
29562 +t_Error FmPcdManipDeleteIpReassmSchemes(t_Handle h_Manip)
29563 +{
29564 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
29565 +
29566 + ASSERT_COND(p_Manip);
29567 +
29568 + if ((p_Manip->reassmParams.ip.h_Ipv4Scheme) &&
29569 + !FmPcdKgIsSchemeHasOwners(p_Manip->reassmParams.ip.h_Ipv4Scheme))
29570 + FM_PCD_KgSchemeDelete(p_Manip->reassmParams.ip.h_Ipv4Scheme);
29571 +
29572 + if ((p_Manip->reassmParams.ip.h_Ipv6Scheme) &&
29573 + !FmPcdKgIsSchemeHasOwners(p_Manip->reassmParams.ip.h_Ipv6Scheme))
29574 + FM_PCD_KgSchemeDelete(p_Manip->reassmParams.ip.h_Ipv6Scheme);
29575 +
29576 + return E_OK;
29577 +}
29578 +
29579 +bool FmPcdManipIpReassmIsIpv6Hdr(t_Handle h_Manip)
29580 +{
29581 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
29582 +
29583 + ASSERT_COND(p_Manip);
29584 +
29585 + return (p_Manip->reassmParams.hdr == HEADER_TYPE_IPv6);
29586 +}
29587 +
29588 +t_Error FmPcdManipBuildCapwapReassmScheme(t_FmPcd *p_FmPcd, t_Handle h_NetEnv,
29589 + t_Handle h_CcTree, t_Handle h_Manip,
29590 + uint8_t groupId)
29591 +{
29592 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
29593 + t_FmPcdKgSchemeParams *p_SchemeParams = NULL;
29594 +
29595 + ASSERT_COND(p_FmPcd);
29596 + ASSERT_COND(h_NetEnv);
29597 + ASSERT_COND(p_Manip);
29598 +
29599 + /* scheme was already build, no need to check for IPv6 */
29600 + if (p_Manip->reassmParams.capwap.h_Scheme)
29601 + return E_OK;
29602 +
29603 + p_SchemeParams = XX_Malloc(sizeof(t_FmPcdKgSchemeParams));
29604 + if (!p_SchemeParams)
29605 + RETURN_ERROR(MAJOR, E_NO_MEMORY,
29606 + ("Memory allocation failed for scheme"));
29607 +
29608 + memset(p_SchemeParams, 0, sizeof(t_FmPcdKgSchemeParams));
29609 + p_SchemeParams->netEnvParams.h_NetEnv = h_NetEnv;
29610 + p_SchemeParams->id.relativeSchemeId =
29611 + (uint8_t)p_Manip->reassmParams.capwap.relativeSchemeId;
29612 + p_SchemeParams->schemeCounter.update = TRUE;
29613 + p_SchemeParams->bypassFqidGeneration = TRUE;
29614 +
29615 + setCapwapReassmSchemeParams(p_FmPcd, p_SchemeParams, h_CcTree, groupId);
29616 +
29617 + p_Manip->reassmParams.capwap.h_Scheme = FM_PCD_KgSchemeSet(p_FmPcd,
29618 + p_SchemeParams);
29619 +
29620 + XX_Free(p_SchemeParams);
29621 +
29622 + return E_OK;
29623 +}
29624 +
29625 +t_Error FmPcdManipDeleteCapwapReassmSchemes(t_Handle h_Manip)
29626 +{
29627 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
29628 +
29629 + ASSERT_COND(p_Manip);
29630 +
29631 + if (p_Manip->reassmParams.capwap.h_Scheme)
29632 + FM_PCD_KgSchemeDelete(p_Manip->reassmParams.capwap.h_Scheme);
29633 +
29634 + return E_OK;
29635 +}
29636 +
29637 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
29638 +t_Handle FmPcdManipApplSpecificBuild(void)
29639 +{
29640 + t_FmPcdManip *p_Manip;
29641 +
29642 + p_Manip = (t_FmPcdManip*)XX_Malloc(sizeof(t_FmPcdManip));
29643 + if (!p_Manip)
29644 + {
29645 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));
29646 + return NULL;
29647 + }
29648 + memset(p_Manip, 0, sizeof(t_FmPcdManip));
29649 +
29650 + p_Manip->opcode = HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX;
29651 + p_Manip->muramAllocate = FALSE;
29652 +
29653 + p_Manip->h_Ad = (t_Handle)XX_Malloc(FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t));
29654 + if (!p_Manip->h_Ad)
29655 + {
29656 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Allocation of Manipulation action descriptor"));
29657 + XX_Free(p_Manip);
29658 + return NULL;
29659 + }
29660 +
29661 + memset(p_Manip->h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t));
29662 +
29663 + /*treatFdStatusFieldsAsErrors = TRUE hardcoded - assumption its always come after CAAM*/
29664 + /*Application specific = type of flowId index, move internal frame header from data to IC,
29665 + SEC errors check*/
29666 + if (MvIntFrameHeaderFromFrameToBufferPrefix(p_Manip, TRUE)!= E_OK)
29667 + {
29668 + XX_Free(p_Manip->h_Ad);
29669 + XX_Free(p_Manip);
29670 + return NULL;
29671 + }
29672 + return p_Manip;
29673 +}
29674 +
29675 +bool FmPcdManipIsCapwapApplSpecific(t_Handle h_Manip)
29676 +{
29677 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
29678 + ASSERT_COND(h_Manip);
29679 +
29680 + return (bool)((p_Manip->opcode == HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST) ? TRUE : FALSE);
29681 +}
29682 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
29683 +/*********************** End of inter-module routines ************************/
29684 +
29685 +/****************************************/
29686 +/* API Init unit functions */
29687 +/****************************************/
29688 +
29689 +t_Handle FM_PCD_ManipNodeSet(t_Handle h_FmPcd,
29690 + t_FmPcdManipParams *p_ManipParams)
29691 +{
29692 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
29693 + t_FmPcdManip *p_Manip;
29694 + t_Error err;
29695 +
29696 + SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);
29697 + SANITY_CHECK_RETURN_VALUE(p_ManipParams, E_INVALID_HANDLE, NULL);
29698 +
29699 + p_Manip = ManipOrStatsSetNode(h_FmPcd, (t_Handle)p_ManipParams, FALSE);
29700 + if (!p_Manip)
29701 + return NULL;
29702 +
29703 + if (((p_Manip->opcode == HMAN_OC_IP_REASSEMBLY)
29704 + || (p_Manip->opcode == HMAN_OC_IP_FRAGMENTATION)
29705 + || (p_Manip->opcode == HMAN_OC)
29706 + || (p_Manip->opcode == HMAN_OC_IPSEC_MANIP)
29707 +#if (DPAA_VERSION >= 11)
29708 + || (p_Manip->opcode == HMAN_OC_CAPWAP_MANIP)
29709 + || (p_Manip->opcode == HMAN_OC_CAPWAP_FRAGMENTATION)
29710 + || (p_Manip->opcode == HMAN_OC_CAPWAP_REASSEMBLY)
29711 +#endif /* (DPAA_VERSION >= 11) */
29712 + ) && (!FmPcdIsAdvancedOffloadSupported(p_FmPcd)))
29713 + {
29714 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Advanced-offload must be enabled"));
29715 + XX_Free(p_Manip);
29716 + return NULL;
29717 + }
29718 + p_Manip->h_Spinlock = XX_InitSpinlock();
29719 + if (!p_Manip->h_Spinlock)
29720 + {
29721 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED HEADER MANIPULATION TYPE"));
29722 + ReleaseManipHandler(p_Manip, p_FmPcd);
29723 + XX_Free(p_Manip);
29724 + return NULL;
29725 + }INIT_LIST(&p_Manip->nodesLst);
29726 +
29727 + switch (p_Manip->opcode)
29728 + {
29729 + case (HMAN_OC_IP_REASSEMBLY):
29730 + /* IpReassembly */
29731 + err = IpReassembly(&p_ManipParams->u.reassem, p_Manip);
29732 + break;
29733 + case (HMAN_OC_IP_FRAGMENTATION):
29734 + /* IpFragmentation */
29735 + err = IpFragmentation(&p_ManipParams->u.frag.u.ipFrag, p_Manip);
29736 + if (err)
29737 + break;
29738 + err = IPManip(p_Manip);
29739 + break;
29740 + case (HMAN_OC_IPSEC_MANIP):
29741 + err = IPSecManip(p_ManipParams, p_Manip);
29742 + break;
29743 +#if (DPAA_VERSION >= 11)
29744 + case (HMAN_OC_CAPWAP_REASSEMBLY):
29745 + /* CapwapReassembly */
29746 + err = CapwapReassembly(&p_ManipParams->u.reassem, p_Manip);
29747 + break;
29748 + case (HMAN_OC_CAPWAP_FRAGMENTATION):
29749 + /* CapwapFragmentation */
29750 + err = CapwapFragmentation(&p_ManipParams->u.frag.u.capwapFrag,
29751 + p_Manip);
29752 + break;
29753 + case (HMAN_OC_CAPWAP_MANIP):
29754 + err = CapwapManip(p_ManipParams, p_Manip);
29755 + break;
29756 +#endif /* (DPAA_VERSION >= 11) */
29757 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
29758 + case (HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR):
29759 + /* HmanType1 */
29760 + err = RmvHdrTillSpecLocNOrInsrtIntFrmHdr(&p_ManipParams->u.hdr.rmvParams, p_Manip);
29761 + break;
29762 + case (HMAN_OC_CAPWAP_FRAGMENTATION):
29763 + err = CapwapFragmentation(&p_ManipParams->fragOrReasmParams.u.capwapFragParams,
29764 + p_Manip,
29765 + p_FmPcd,
29766 + p_ManipParams->fragOrReasmParams.sgBpid);
29767 + if (err)
29768 + {
29769 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED HEADER MANIPULATION TYPE"));
29770 + ReleaseManipHandler(p_Manip, p_FmPcd);
29771 + XX_Free(p_Manip);
29772 + return NULL;
29773 + }
29774 + if (p_Manip->insrt)
29775 + p_Manip->opcode = HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER;
29776 + case (HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
29777 + /* HmanType2 + if user asked only for fragmentation still need to allocate HmanType2 */
29778 + err = InsrtHdrByTempl(&p_ManipParams->u.hdr.insrtParams, p_Manip, p_FmPcd);
29779 + break;
29780 + case (HMAN_OC_CAPWAP_REASSEMBLY):
29781 + err = CapwapReassembly(&p_ManipParams->fragOrReasmParams.u.capwapReasmParams,
29782 + p_Manip,
29783 + p_FmPcd,
29784 + p_ManipParams->fragOrReasmParams.sgBpid);
29785 + if (err)
29786 + {
29787 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED HEADER MANIPULATION TYPE"));
29788 + ReleaseManipHandler(p_Manip, p_FmPcd);
29789 + XX_Free(p_Manip);
29790 + return NULL;
29791 + }
29792 + if (p_Manip->rmv)
29793 + p_Manip->opcode = HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST;
29794 + case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
29795 + /*CAPWAP decapsulation + if user asked only for reassembly still need to allocate CAPWAP decapsulation*/
29796 + err = CapwapRmvDtlsHdr(p_FmPcd, p_Manip);
29797 + break;
29798 + case (HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
29799 + /*Application Specific type 1*/
29800 + err = MvIntFrameHeaderFromFrameToBufferPrefix(p_Manip, TRUE);
29801 + break;
29802 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
29803 + case (HMAN_OC):
29804 + /* New Manip */
29805 + err = CreateManipActionNew(p_Manip, p_ManipParams);
29806 + break;
29807 + default:
29808 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED HEADER MANIPULATION TYPE"));
29809 + ReleaseManipHandler(p_Manip, p_FmPcd);
29810 + XX_Free(p_Manip);
29811 + return NULL;
29812 + }
29813 +
29814 + if (err)
29815 + {
29816 + REPORT_ERROR(MAJOR, err, NO_MSG);
29817 + ReleaseManipHandler(p_Manip, p_FmPcd);
29818 + XX_Free(p_Manip);
29819 + return NULL;
29820 + }
29821 +
29822 + if (p_ManipParams->h_NextManip)
29823 + {
29824 + /* in the check routine we've verified that h_NextManip has no owners
29825 + * and that only supported types are allowed. */
29826 + p_Manip->h_NextManip = p_ManipParams->h_NextManip;
29827 + /* save a "prev" pointer in h_NextManip */
29828 + MANIP_SET_PREV(p_Manip->h_NextManip, p_Manip);
29829 + FmPcdManipUpdateOwner(p_Manip->h_NextManip, TRUE);
29830 + }
29831 +
29832 + return p_Manip;
29833 +}
29834 +
29835 +t_Error FM_PCD_ManipNodeReplace(t_Handle h_Manip,
29836 + t_FmPcdManipParams *p_ManipParams)
29837 +{
29838 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip, *p_FirstManip;
29839 + t_FmPcd *p_FmPcd = (t_FmPcd *)(p_Manip->h_FmPcd);
29840 + t_Error err;
29841 + uint8_t *p_WholeHmct = NULL, *p_ShadowHmct = NULL, *p_Hmtd = NULL;
29842 + t_List lstOfNodeshichPointsOnCrntMdfManip, *p_Pos;
29843 + t_CcNodeInformation *p_CcNodeInfo;
29844 + SANITY_CHECK_RETURN_ERROR(h_Manip, E_INVALID_HANDLE);
29845 + SANITY_CHECK_RETURN_ERROR(p_ManipParams, E_INVALID_HANDLE);
29846 +
29847 + INIT_LIST(&lstOfNodeshichPointsOnCrntMdfManip);
29848 +
29849 + if ((p_ManipParams->type != e_FM_PCD_MANIP_HDR)
29850 + || (p_Manip->type != e_FM_PCD_MANIP_HDR))
29851 + RETURN_ERROR(
29852 + MINOR,
29853 + E_NOT_SUPPORTED,
29854 + ("FM_PCD_ManipNodeReplace Functionality supported only for Header Manipulation."));
29855 +
29856 + ASSERT_COND(p_Manip->opcode == HMAN_OC);
29857 + ASSERT_COND(p_Manip->manipParams.h_NextManip == p_Manip->h_NextManip);
29858 + memcpy((uint8_t*)&p_Manip->manipParams, p_ManipParams,
29859 + sizeof(p_Manip->manipParams));
29860 + p_Manip->manipParams.h_NextManip = p_Manip->h_NextManip;
29861 +
29862 + /* The replacement of the HdrManip depends on the node type.*/
29863 + /*
29864 + * (1) If this is an independent node, all its owners should be updated.
29865 + *
29866 + * (2) If it is the head of a cascaded chain (it does not have a "prev" but
29867 + * it has a "next" and it has a "cascaded" indication), the next
29868 + * node remains unchanged, and the behavior is as in (1).
29869 + *
29870 + * (3) If it is not the head, but a part of a cascaded chain, in can be
29871 + * also replaced as a regular node with just one owner.
29872 + *
29873 + * (4) If it is a part of a chain implemented as a unified table, the
29874 + * whole table is replaced and the owners of the head node must be updated.
29875 + *
29876 + */
29877 + /* lock shadow */
29878 + if (!p_FmPcd->p_CcShadow)
29879 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("CC Shadow not allocated"));
29880 +
29881 + if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
29882 + return ERROR_CODE(E_BUSY);
29883 +
29884 + /* this routine creates a new manip action in the CC Shadow. */
29885 + err = CreateManipActionShadow(p_Manip, p_ManipParams);
29886 + if (err)
29887 + RETURN_ERROR(MINOR, err, NO_MSG);
29888 +
29889 + /* If the owners list is empty (these are NOT the "owners" counter, but pointers from CC)
29890 + * replace only HMTD and no lcok is required. Otherwise
29891 + * lock the whole PCD
29892 + * In case 4 MANIP_IS_UNIFIED_NON_FIRST(p_Manip) - Use the head node instead. */
29893 + if (!FmPcdLockTryLockAll(p_FmPcd))
29894 + {
29895 + DBG(TRACE, ("FmPcdLockTryLockAll failed"));
29896 + return ERROR_CODE(E_BUSY);
29897 + }
29898 +
29899 + p_ShadowHmct = (uint8_t*)PTR_MOVE(p_FmPcd->p_CcShadow, 16);
29900 +
29901 + p_FirstManip = (t_FmPcdManip*)GetManipInfo(p_Manip,
29902 + e_MANIP_HANDLER_TABLE_OWNER);
29903 + ASSERT_COND(p_FirstManip);
29904 +
29905 + if (!LIST_IsEmpty(&p_FirstManip->nodesLst))
29906 + UpdateAdPtrOfNodesWhichPointsOnCrntMdfManip(
29907 + p_FirstManip, &lstOfNodeshichPointsOnCrntMdfManip);
29908 +
29909 + p_Hmtd = (uint8_t *)GetManipInfo(p_Manip, e_MANIP_HMTD);
29910 + ASSERT_COND(p_Hmtd);
29911 + BuildHmtd(p_FmPcd->p_CcShadow, (uint8_t *)p_Hmtd, p_ShadowHmct,
29912 + ((t_FmPcd*)(p_Manip->h_FmPcd)));
29913 +
29914 + LIST_FOR_EACH(p_Pos, &lstOfNodeshichPointsOnCrntMdfManip)
29915 + {
29916 + p_CcNodeInfo = CC_NODE_F_OBJECT(p_Pos);
29917 + BuildHmtd(p_FmPcd->p_CcShadow, (uint8_t *)p_CcNodeInfo->h_CcNode,
29918 + p_ShadowHmct, ((t_FmPcd*)(p_Manip->h_FmPcd)));
29919 + }
29920 +
29921 + p_WholeHmct = (uint8_t *)GetManipInfo(p_Manip, e_MANIP_HMCT);
29922 + ASSERT_COND(p_WholeHmct);
29923 +
29924 + /* re-build the HMCT n the original location */
29925 + err = CreateManipActionBackToOrig(p_Manip, p_ManipParams);
29926 + if (err)
29927 + {
29928 + RELEASE_LOCK(p_FmPcd->shadowLock);
29929 + RETURN_ERROR(MINOR, err, NO_MSG);
29930 + }
29931 +
29932 + p_Hmtd = (uint8_t *)GetManipInfo(p_Manip, e_MANIP_HMTD);
29933 + ASSERT_COND(p_Hmtd);
29934 + BuildHmtd(p_FmPcd->p_CcShadow, (uint8_t *)p_Hmtd, p_WholeHmct,
29935 + ((t_FmPcd*)p_Manip->h_FmPcd));
29936 +
29937 + /* If LIST > 0, create a list of p_Ad's that point to the HMCT. Join also t_HMTD to this list.
29938 + * For each p_Hmct (from list+fixed):
29939 + * call Host Command to replace HMTD by a new one */LIST_FOR_EACH(p_Pos, &lstOfNodeshichPointsOnCrntMdfManip)
29940 + {
29941 + p_CcNodeInfo = CC_NODE_F_OBJECT(p_Pos);
29942 + BuildHmtd(p_FmPcd->p_CcShadow, (uint8_t *)p_CcNodeInfo->h_CcNode,
29943 + p_WholeHmct, ((t_FmPcd*)(p_Manip->h_FmPcd)));
29944 + }
29945 +
29946 +
29947 + ReleaseLst(&lstOfNodeshichPointsOnCrntMdfManip);
29948 +
29949 + FmPcdLockUnlockAll(p_FmPcd);
29950 +
29951 + /* unlock shadow */
29952 + RELEASE_LOCK(p_FmPcd->shadowLock);
29953 +
29954 + return E_OK;
29955 +}
29956 +
29957 +t_Error FM_PCD_ManipNodeDelete(t_Handle h_ManipNode)
29958 +{
29959 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_ManipNode;
29960 +
29961 + SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
29962 +
29963 + if (p_Manip->owner)
29964 + RETURN_ERROR(
29965 + MAJOR,
29966 + E_INVALID_STATE,
29967 + ("This manipulation node not be removed because this node is occupied, first - unbind this node "));
29968 +
29969 + if (p_Manip->h_NextManip)
29970 + {
29971 + MANIP_SET_PREV(p_Manip->h_NextManip, NULL);
29972 + FmPcdManipUpdateOwner(p_Manip->h_NextManip, FALSE);
29973 + }
29974 +
29975 + if (p_Manip->p_Hmct
29976 + && (MANIP_IS_UNIFIED_FIRST(p_Manip) || !MANIP_IS_UNIFIED(p_Manip)))
29977 + FM_MURAM_FreeMem(((t_FmPcd *)p_Manip->h_FmPcd)->h_FmMuram,
29978 + p_Manip->p_Hmct);
29979 +
29980 + if (p_Manip->h_Spinlock)
29981 + {
29982 + XX_FreeSpinlock(p_Manip->h_Spinlock);
29983 + p_Manip->h_Spinlock = NULL;
29984 + }
29985 +
29986 + ReleaseManipHandler(p_Manip, p_Manip->h_FmPcd);
29987 +
29988 + XX_Free(h_ManipNode);
29989 +
29990 + return E_OK;
29991 +}
29992 +
29993 +t_Error FM_PCD_ManipGetStatistics(t_Handle h_ManipNode,
29994 + t_FmPcdManipStats *p_FmPcdManipStats)
29995 +{
29996 + t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_ManipNode;
29997 +
29998 + SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
29999 + SANITY_CHECK_RETURN_ERROR(p_FmPcdManipStats, E_NULL_POINTER);
30000 +
30001 + switch (p_Manip->opcode)
30002 + {
30003 + case (HMAN_OC_IP_REASSEMBLY):
30004 + return IpReassemblyStats(p_Manip,
30005 + &p_FmPcdManipStats->u.reassem.u.ipReassem);
30006 + case (HMAN_OC_IP_FRAGMENTATION):
30007 + return IpFragmentationStats(p_Manip,
30008 + &p_FmPcdManipStats->u.frag.u.ipFrag);
30009 +#if (DPAA_VERSION >= 11)
30010 + case (HMAN_OC_CAPWAP_REASSEMBLY):
30011 + return CapwapReassemblyStats(
30012 + p_Manip, &p_FmPcdManipStats->u.reassem.u.capwapReassem);
30013 + case (HMAN_OC_CAPWAP_FRAGMENTATION):
30014 + return CapwapFragmentationStats(
30015 + p_Manip, &p_FmPcdManipStats->u.frag.u.capwapFrag);
30016 +#endif /* (DPAA_VERSION >= 11) */
30017 + default:
30018 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
30019 + ("no statistics to this type of manip"));
30020 + }
30021 +
30022 + return E_OK;
30023 +}
30024 +
30025 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
30026 +t_Handle FM_PCD_StatisticsSetNode(t_Handle h_FmPcd, t_FmPcdStatsParams *p_StatsParams)
30027 +{
30028 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
30029 + t_FmPcdManip *p_Manip;
30030 + t_Error err;
30031 +
30032 + SANITY_CHECK_RETURN_VALUE(h_FmPcd,E_INVALID_HANDLE,NULL);
30033 + SANITY_CHECK_RETURN_VALUE(p_StatsParams,E_INVALID_HANDLE,NULL);
30034 +
30035 + p_Manip = ManipOrStatsSetNode(h_FmPcd, (t_Handle)p_StatsParams, TRUE);
30036 + if (!p_Manip)
30037 + return NULL;
30038 +
30039 + switch (p_Manip->opcode)
30040 + {
30041 + case (HMAN_OC_CAPWAP_INDEXED_STATS):
30042 + /* Indexed statistics */
30043 + err = IndxStats(p_StatsParams, p_Manip, p_FmPcd);
30044 + break;
30045 + default:
30046 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED Statistics type"));
30047 + ReleaseManipHandler(p_Manip, p_FmPcd);
30048 + XX_Free(p_Manip);
30049 + return NULL;
30050 + }
30051 +
30052 + if (err)
30053 + {
30054 + REPORT_ERROR(MAJOR, err, NO_MSG);
30055 + ReleaseManipHandler(p_Manip, p_FmPcd);
30056 + XX_Free(p_Manip);
30057 + return NULL;
30058 + }
30059 +
30060 + return p_Manip;
30061 +}
30062 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
30063 --- /dev/null
30064 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_manip.h
30065 @@ -0,0 +1,555 @@
30066 +/*
30067 + * Copyright 2008-2012 Freescale Semiconductor Inc.
30068 + *
30069 + * Redistribution and use in source and binary forms, with or without
30070 + * modification, are permitted provided that the following conditions are met:
30071 + * * Redistributions of source code must retain the above copyright
30072 + * notice, this list of conditions and the following disclaimer.
30073 + * * Redistributions in binary form must reproduce the above copyright
30074 + * notice, this list of conditions and the following disclaimer in the
30075 + * documentation and/or other materials provided with the distribution.
30076 + * * Neither the name of Freescale Semiconductor nor the
30077 + * names of its contributors may be used to endorse or promote products
30078 + * derived from this software without specific prior written permission.
30079 + *
30080 + *
30081 + * ALTERNATIVELY, this software may be distributed under the terms of the
30082 + * GNU General Public License ("GPL") as published by the Free Software
30083 + * Foundation, either version 2 of that License or (at your option) any
30084 + * later version.
30085 + *
30086 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
30087 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
30088 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30089 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
30090 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30091 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30092 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30093 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30094 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30095 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30096 + */
30097 +
30098 +
30099 +/******************************************************************************
30100 + @File fm_manip.h
30101 +
30102 + @Description FM PCD manip...
30103 +*//***************************************************************************/
30104 +#ifndef __FM_MANIP_H
30105 +#define __FM_MANIP_H
30106 +
30107 +#include "std_ext.h"
30108 +#include "error_ext.h"
30109 +#include "list_ext.h"
30110 +
30111 +#include "fm_cc.h"
30112 +
30113 +
30114 +/***********************************************************************/
30115 +/* Header manipulations defines */
30116 +/***********************************************************************/
30117 +
30118 +#define NUM_OF_SCRATCH_POOL_BUFFERS 1000 /*TODO - Change it!!*/
30119 +
30120 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
30121 +#define HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR 0x2e
30122 +#define HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER 0x31
30123 +#define HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX 0x2f
30124 +#define HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST 0x30
30125 +#define HMAN_OC_CAPWAP_REASSEMBLY 0x11 /* dummy */
30126 +#define HMAN_OC_CAPWAP_INDEXED_STATS 0x32 /* dummy */
30127 +#define HMAN_OC_CAPWAP_FRAGMENTATION 0x33
30128 +#else
30129 +#define HMAN_OC_CAPWAP_MANIP 0x2F
30130 +#define HMAN_OC_CAPWAP_FRAG_CHECK 0x2E
30131 +#define HMAN_OC_CAPWAP_FRAGMENTATION 0x33
30132 +#define HMAN_OC_CAPWAP_REASSEMBLY 0x30
30133 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
30134 +#define HMAN_OC_IP_MANIP 0x34
30135 +#define HMAN_OC_IP_FRAGMENTATION 0x74
30136 +#define HMAN_OC_IP_REASSEMBLY 0xB4
30137 +#define HMAN_OC_IPSEC_MANIP 0xF4
30138 +#define HMAN_OC 0x35
30139 +
30140 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
30141 +#define HMAN_RMV_HDR 0x80000000
30142 +#define HMAN_INSRT_INT_FRM_HDR 0x40000000
30143 +
30144 +#define UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP 6
30145 +#define UDP_CHECKSUM_FIELD_SIZE 2
30146 +#define UDP_LENGTH_FIELD_OFFSET_FROM_UDP 4
30147 +
30148 +#define IPv4_DSCECN_FIELD_OFFSET_FROM_IP 1
30149 +#define IPv4_TOTALLENGTH_FIELD_OFFSET_FROM_IP 2
30150 +#define IPv4_HDRCHECKSUM_FIELD_OFFSET_FROM_IP 10
30151 +#define VLAN_TAG_FIELD_OFFSET_FROM_ETH 12
30152 +#define IPv4_ID_FIELD_OFFSET_FROM_IP 4
30153 +
30154 +#define IPv6_PAYLOAD_LENGTH_OFFSET_FROM_IP 4
30155 +#define IPv6_NEXT_HEADER_OFFSET_FROM_IP 6
30156 +
30157 +#define FM_PCD_MANIP_CAPWAP_REASM_TABLE_SIZE 0x80
30158 +#define FM_PCD_MANIP_CAPWAP_REASM_TABLE_ALIGN 8
30159 +#define FM_PCD_MANIP_CAPWAP_REASM_RFD_SIZE 32
30160 +#define FM_PCD_MANIP_CAPWAP_REASM_AUTO_LEARNING_HASH_ENTRY_SIZE 4
30161 +#define FM_PCD_MANIP_CAPWAP_REASM_TIME_OUT_ENTRY_SIZE 8
30162 +
30163 +
30164 +#define FM_PCD_MANIP_CAPWAP_REASM_TIME_OUT_BETWEEN_FRAMES 0x40000000
30165 +#define FM_PCD_MANIP_CAPWAP_REASM_HALT_ON_DUPLICATE_FRAG 0x10000000
30166 +#define FM_PCD_MANIP_CAPWAP_REASM_AUTOMATIC_LEARNIN_HASH_8_WAYS 0x08000000
30167 +#define FM_PCD_MANIP_CAPWAP_REASM_PR_COPY 0x00800000
30168 +
30169 +#define FM_PCD_MANIP_CAPWAP_FRAG_COMPR_OPTION_FIELD_EN 0x80000000
30170 +
30171 +#define FM_PCD_MANIP_INDEXED_STATS_ENTRY_SIZE 4
30172 +#define FM_PCD_MANIP_INDEXED_STATS_CNIA 0x20000000
30173 +#define FM_PCD_MANIP_INDEXED_STATS_DPD 0x10000000
30174 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
30175 +
30176 +#if (DPAA_VERSION >= 11)
30177 +#define FM_PCD_MANIP_CAPWAP_DTLS 0x00040000
30178 +#define FM_PCD_MANIP_CAPWAP_NADEN 0x20000000
30179 +
30180 +#define FM_PCD_MANIP_CAPWAP_FRAG_CHECK_MTU_SHIFT 16
30181 +#define FM_PCD_MANIP_CAPWAP_FRAG_CHECK_NO_FRAGMENTATION 0xFFFF0000
30182 +#define FM_PCD_MANIP_CAPWAP_FRAG_CHECK_CNIA 0x20000000
30183 +
30184 +#define FM_PCD_MANIP_CAPWAP_FRAG_COMPRESS_EN 0x04000000
30185 +#define FM_PCD_MANIP_CAPWAP_FRAG_SCRATCH_BPID 24
30186 +#define FM_PCD_MANIP_CAPWAP_FRAG_SG_BDID_EN 0x08000000
30187 +#define FM_PCD_MANIP_CAPWAP_FRAG_SG_BDID_MASK 0xFF000000
30188 +#define FM_PCD_MANIP_CAPWAP_FRAG_SG_BDID_SHIFT 24
30189 +#endif /* (DPAA_VERSION >= 11) */
30190 +
30191 +#define FM_PCD_MANIP_REASM_TABLE_SIZE 0x40
30192 +#define FM_PCD_MANIP_REASM_TABLE_ALIGN 8
30193 +
30194 +#define FM_PCD_MANIP_REASM_COMMON_PARAM_TABLE_SIZE 64
30195 +#define FM_PCD_MANIP_REASM_COMMON_PARAM_TABLE_ALIGN 8
30196 +#define FM_PCD_MANIP_REASM_TIME_OUT_BETWEEN_FRAMES 0x80000000
30197 +#define FM_PCD_MANIP_REASM_COUPLING_ENABLE 0x40000000
30198 +#define FM_PCD_MANIP_REASM_COUPLING_MASK 0xFF000000
30199 +#define FM_PCD_MANIP_REASM_COUPLING_SHIFT 24
30200 +#define FM_PCD_MANIP_REASM_LIODN_MASK 0x0000003F
30201 +#define FM_PCD_MANIP_REASM_LIODN_SHIFT 56
30202 +#define FM_PCD_MANIP_REASM_ELIODN_MASK 0x000003c0
30203 +#define FM_PCD_MANIP_REASM_ELIODN_SHIFT 38
30204 +#define FM_PCD_MANIP_REASM_COMMON_INT_BUFFER_IDX_MASK 0x000000FF
30205 +#define FM_PCD_MANIP_REASM_COMMON_INT_BUFFER_IDX_SHIFT 24
30206 +#define FM_PCD_MANIP_REASM_TIMEOUT_THREAD_THRESH 1024
30207 +
30208 +#define FM_PCD_MANIP_IP_MTU_SHIFT 16
30209 +#define FM_PCD_MANIP_IP_NO_FRAGMENTATION 0xFFFF0000
30210 +#define FM_PCD_MANIP_IP_CNIA 0x20000000
30211 +
30212 +#define FM_PCD_MANIP_IP_FRAG_DF_SHIFT 28
30213 +#define FM_PCD_MANIP_IP_FRAG_SCRATCH_BPID 24
30214 +#define FM_PCD_MANIP_IP_FRAG_SG_BDID_EN 0x08000000
30215 +#define FM_PCD_MANIP_IP_FRAG_SG_BDID_MASK 0xFF000000
30216 +#define FM_PCD_MANIP_IP_FRAG_SG_BDID_SHIFT 24
30217 +
30218 +#define FM_PCD_MANIP_IPSEC_DEC 0x10000000
30219 +#define FM_PCD_MANIP_IPSEC_VIPV_EN 0x08000000
30220 +#define FM_PCD_MANIP_IPSEC_ECN_EN 0x04000000
30221 +#define FM_PCD_MANIP_IPSEC_DSCP_EN 0x02000000
30222 +#define FM_PCD_MANIP_IPSEC_VIPL_EN 0x01000000
30223 +#define FM_PCD_MANIP_IPSEC_NADEN 0x20000000
30224 +
30225 +#define FM_PCD_MANIP_IPSEC_IP_HDR_LEN_MASK 0x00FF0000
30226 +#define FM_PCD_MANIP_IPSEC_IP_HDR_LEN_SHIFT 16
30227 +
30228 +#define FM_PCD_MANIP_IPSEC_ARW_SIZE_MASK 0xFFFF0000
30229 +#define FM_PCD_MANIP_IPSEC_ARW_SIZE_SHIFT 16
30230 +
30231 +#define e_FM_MANIP_IP_INDX 1
30232 +
30233 +#define HMCD_OPCODE_GENERIC_RMV 0x01
30234 +#define HMCD_OPCODE_GENERIC_INSRT 0x02
30235 +#define HMCD_OPCODE_GENERIC_REPLACE 0x05
30236 +#define HMCD_OPCODE_L2_RMV 0x08
30237 +#define HMCD_OPCODE_L2_INSRT 0x09
30238 +#define HMCD_OPCODE_VLAN_PRI_UPDATE 0x0B
30239 +#define HMCD_OPCODE_IPV4_UPDATE 0x0C
30240 +#define HMCD_OPCODE_IPV6_UPDATE 0x10
30241 +#define HMCD_OPCODE_TCP_UDP_UPDATE 0x0E
30242 +#define HMCD_OPCODE_TCP_UDP_CHECKSUM 0x14
30243 +#define HMCD_OPCODE_REPLACE_IP 0x12
30244 +#define HMCD_OPCODE_RMV_TILL 0x15
30245 +#define HMCD_OPCODE_UDP_INSRT 0x16
30246 +#define HMCD_OPCODE_IP_INSRT 0x17
30247 +#define HMCD_OPCODE_CAPWAP_RMV 0x18
30248 +#define HMCD_OPCODE_CAPWAP_INSRT 0x18
30249 +#define HMCD_OPCODE_GEN_FIELD_REPLACE 0x19
30250 +
30251 +#define HMCD_LAST 0x00800000
30252 +
30253 +#define HMCD_DSCP_VALUES 64
30254 +
30255 +#define HMCD_BASIC_SIZE 4
30256 +#define HMCD_PTR_SIZE 4
30257 +#define HMCD_PARAM_SIZE 4
30258 +#define HMCD_IPV4_ADDR_SIZE 4
30259 +#define HMCD_IPV6_ADDR_SIZE 0x10
30260 +#define HMCD_L4_HDR_SIZE 8
30261 +
30262 +#define HMCD_CAPWAP_INSRT 0x00010000
30263 +#define HMCD_INSRT_UDP_LITE 0x00010000
30264 +#define HMCD_IP_ID_MASK 0x0000FFFF
30265 +#define HMCD_IP_SIZE_MASK 0x0000FF00
30266 +#define HMCD_IP_SIZE_SHIFT 8
30267 +#define HMCD_IP_LAST_PID_MASK 0x000000FF
30268 +#define HMCD_IP_OR_QOS 0x00010000
30269 +#define HMCD_IP_L4_CS_CALC 0x00040000
30270 +#define HMCD_IP_DF_MODE 0x00400000
30271 +
30272 +
30273 +#define HMCD_OC_SHIFT 24
30274 +
30275 +#define HMCD_RMV_OFFSET_SHIFT 0
30276 +#define HMCD_RMV_SIZE_SHIFT 8
30277 +
30278 +#define HMCD_INSRT_OFFSET_SHIFT 0
30279 +#define HMCD_INSRT_SIZE_SHIFT 8
30280 +
30281 +#define HMTD_CFG_TYPE 0x4000
30282 +#define HMTD_CFG_EXT_HMCT 0x0080
30283 +#define HMTD_CFG_PRS_AFTER_HM 0x0040
30284 +#define HMTD_CFG_NEXT_AD_EN 0x0020
30285 +
30286 +#define HMCD_RMV_L2_ETHERNET 0
30287 +#define HMCD_RMV_L2_STACKED_QTAGS 1
30288 +#define HMCD_RMV_L2_ETHERNET_AND_MPLS 2
30289 +#define HMCD_RMV_L2_MPLS 3
30290 +#define HMCD_RMV_L2_PPPOE 4
30291 +
30292 +#define HMCD_INSRT_L2_MPLS 0
30293 +#define HMCD_INSRT_N_UPDATE_L2_MPLS 1
30294 +#define HMCD_INSRT_L2_PPPOE 2
30295 +#define HMCD_INSRT_L2_SIZE_SHIFT 24
30296 +
30297 +#define HMCD_L2_MODE_SHIFT 16
30298 +
30299 +#define HMCD_VLAN_PRI_REP_MODE_SHIFT 16
30300 +#define HMCD_VLAN_PRI_UPDATE 0
30301 +#define HMCD_VLAN_PRI_UPDATE_DSCP_TO_VPRI 1
30302 +
30303 +#define HMCD_IPV4_UPDATE_TTL 0x00000001
30304 +#define HMCD_IPV4_UPDATE_TOS 0x00000002
30305 +#define HMCD_IPV4_UPDATE_DST 0x00000020
30306 +#define HMCD_IPV4_UPDATE_SRC 0x00000040
30307 +#define HMCD_IPV4_UPDATE_ID 0x00000080
30308 +#define HMCD_IPV4_UPDATE_TOS_SHIFT 8
30309 +
30310 +#define HMCD_IPV6_UPDATE_HL 0x00000001
30311 +#define HMCD_IPV6_UPDATE_TC 0x00000002
30312 +#define HMCD_IPV6_UPDATE_DST 0x00000040
30313 +#define HMCD_IPV6_UPDATE_SRC 0x00000080
30314 +#define HMCD_IPV6_UPDATE_TC_SHIFT 8
30315 +
30316 +#define HMCD_TCP_UDP_UPDATE_DST 0x00004000
30317 +#define HMCD_TCP_UDP_UPDATE_SRC 0x00008000
30318 +#define HMCD_TCP_UDP_UPDATE_SRC_SHIFT 16
30319 +
30320 +#define HMCD_IP_REPLACE_REPLACE_IPV4 0x00000000
30321 +#define HMCD_IP_REPLACE_REPLACE_IPV6 0x00010000
30322 +#define HMCD_IP_REPLACE_TTL_HL 0x00200000
30323 +#define HMCD_IP_REPLACE_ID 0x00400000
30324 +
30325 +#define HMCD_IP_REPLACE_L3HDRSIZE_SHIFT 24
30326 +
30327 +#define HMCD_GEN_FIELD_SIZE_SHIFT 16
30328 +#define HMCD_GEN_FIELD_SRC_OFF_SHIFT 8
30329 +#define HMCD_GEN_FIELD_DST_OFF_SHIFT 0
30330 +#define HMCD_GEN_FIELD_MASK_EN 0x00400000
30331 +
30332 +#define HMCD_GEN_FIELD_MASK_OFF_SHIFT 16
30333 +#define HMCD_GEN_FIELD_MASK_SHIFT 24
30334 +
30335 +#define DSCP_TO_VLAN_TABLE_SIZE 32
30336 +
30337 +#define MANIP_GET_HMCT_SIZE(h_Manip) (((t_FmPcdManip *)h_Manip)->tableSize)
30338 +#define MANIP_GET_DATA_SIZE(h_Manip) (((t_FmPcdManip *)h_Manip)->dataSize)
30339 +
30340 +#define MANIP_GET_HMCT_PTR(h_Manip) (((t_FmPcdManip *)h_Manip)->p_Hmct)
30341 +#define MANIP_GET_DATA_PTR(h_Manip) (((t_FmPcdManip *)h_Manip)->p_Data)
30342 +
30343 +#define MANIP_SET_HMCT_PTR(h_Manip, h_NewPtr) (((t_FmPcdManip *)h_Manip)->p_Hmct = h_NewPtr)
30344 +#define MANIP_SET_DATA_PTR(h_Manip, h_NewPtr) (((t_FmPcdManip *)h_Manip)->p_Data = h_NewPtr)
30345 +
30346 +#define MANIP_GET_HMTD_PTR(h_Manip) (((t_FmPcdManip *)h_Manip)->h_Ad)
30347 +#define MANIP_DONT_REPARSE(h_Manip) (((t_FmPcdManip *)h_Manip)->dontParseAfterManip)
30348 +#define MANIP_SET_PREV(h_Manip, h_Prev) (((t_FmPcdManip *)h_Manip)->h_PrevManip = h_Prev)
30349 +#define MANIP_GET_OWNERS(h_Manip) (((t_FmPcdManip *)h_Manip)->owner)
30350 +#define MANIP_GET_TYPE(h_Manip) (((t_FmPcdManip *)h_Manip)->type)
30351 +#define MANIP_SET_UNIFIED_TBL_PTR_INDICATION(h_Manip) (((t_FmPcdManip *)h_Manip)->unifiedTablePtr = TRUE)
30352 +#define MANIP_GET_MURAM(h_Manip) (((t_FmPcd *)((t_FmPcdManip *)h_Manip)->h_FmPcd)->h_FmMuram)
30353 +#define MANIP_FREE_HMTD(h_Manip) \
30354 + {if (((t_FmPcdManip *)h_Manip)->muramAllocate) \
30355 + FM_MURAM_FreeMem(((t_FmPcd *)((t_FmPcdManip *)h_Manip)->h_FmPcd)->h_FmMuram, ((t_FmPcdManip *)h_Manip)->h_Ad);\
30356 + else \
30357 + XX_Free(((t_FmPcdManip *)h_Manip)->h_Ad); \
30358 + ((t_FmPcdManip *)h_Manip)->h_Ad = NULL; \
30359 + }
30360 +/* position regarding Manip SW structure */
30361 +#define MANIP_IS_FIRST(h_Manip) (!(((t_FmPcdManip *)h_Manip)->h_PrevManip))
30362 +#define MANIP_IS_CASCADED(h_Manip) (((t_FmPcdManip *)h_Manip)->cascaded)
30363 +#define MANIP_IS_UNIFIED(h_Manip) (!(((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_NONE))
30364 +#define MANIP_IS_UNIFIED_NON_FIRST(h_Manip) ((((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_MID) || \
30365 + (((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_LAST))
30366 +#define MANIP_IS_UNIFIED_NON_LAST(h_Manip) ((((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_FIRST) ||\
30367 + (((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_MID))
30368 +#define MANIP_IS_UNIFIED_FIRST(h_Manip) (((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_FIRST)
30369 +#define MANIP_IS_UNIFIED_LAST(h_Manip) (((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_LAST)
30370 +
30371 +#define MANIP_UPDATE_UNIFIED_POSITION(h_Manip) (((t_FmPcdManip *)h_Manip)->unifiedPosition = \
30372 + (((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_NONE)? \
30373 + e_MANIP_UNIFIED_LAST : e_MANIP_UNIFIED_MID)
30374 +
30375 +typedef enum e_ManipUnifiedPosition {
30376 + e_MANIP_UNIFIED_NONE = 0,
30377 + e_MANIP_UNIFIED_FIRST,
30378 + e_MANIP_UNIFIED_MID,
30379 + e_MANIP_UNIFIED_LAST
30380 +} e_ManipUnifiedPosition;
30381 +
30382 +typedef enum e_ManipInfo {
30383 + e_MANIP_HMTD,
30384 + e_MANIP_HMCT,
30385 + e_MANIP_HANDLER_TABLE_OWNER
30386 +}e_ManipInfo;
30387 +/***********************************************************************/
30388 +/* Memory map */
30389 +/***********************************************************************/
30390 +#if defined(__MWERKS__) && !defined(__GNUC__)
30391 +#pragma pack(push,1)
30392 +#endif /* defined(__MWERKS__) && ... */
30393 +
30394 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
30395 +typedef struct t_CapwapReasmPram {
30396 + volatile uint32_t mode;
30397 + volatile uint32_t autoLearnHashTblPtr;
30398 + volatile uint32_t intStatsTblPtr;
30399 + volatile uint32_t reasmFrmDescPoolTblPtr;
30400 + volatile uint32_t reasmFrmDescIndexPoolTblPtr;
30401 + volatile uint32_t timeOutTblPtr;
30402 + volatile uint32_t bufferPoolIdAndRisc1SetIndexes;
30403 + volatile uint32_t risc23SetIndexes;
30404 + volatile uint32_t risc4SetIndexesAndExtendedStatsTblPtr;
30405 + volatile uint32_t extendedStatsTblPtr;
30406 + volatile uint32_t expirationDelay;
30407 + volatile uint32_t totalProcessedFragCounter;
30408 + volatile uint32_t totalUnsuccessfulReasmFramesCounter;
30409 + volatile uint32_t totalDuplicatedFragCounter;
30410 + volatile uint32_t totalMalformdFragCounter;
30411 + volatile uint32_t totalTimeOutCounter;
30412 + volatile uint32_t totalSetBusyCounter;
30413 + volatile uint32_t totalRfdPoolBusyCounter;
30414 + volatile uint32_t totalDiscardedFragsCounter;
30415 + volatile uint32_t totalMoreThan16FramesCounter;
30416 + volatile uint32_t internalBufferBusy;
30417 + volatile uint32_t externalBufferBusy;
30418 + volatile uint32_t reserved1[4];
30419 +} t_CapwapReasmPram;
30420 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
30421 +
30422 +typedef _Packed struct t_ReassTbl {
30423 + volatile uint16_t waysNumAndSetSize;
30424 + volatile uint16_t autoLearnHashKeyMask;
30425 + volatile uint32_t reassCommonPrmTblPtr;
30426 + volatile uint32_t liodnAlAndAutoLearnHashTblPtrHi;
30427 + volatile uint32_t autoLearnHashTblPtrLow;
30428 + volatile uint32_t liodnSlAndAutoLearnSetLockTblPtrHi;
30429 + volatile uint32_t autoLearnSetLockTblPtrLow;
30430 + volatile uint16_t minFragSize; /* Not relevant for CAPWAP*/
30431 + volatile uint16_t maxReassemblySize; /* Only relevant for CAPWAP*/
30432 + volatile uint32_t totalSuccessfullyReasmFramesCounter;
30433 + volatile uint32_t totalValidFragmentCounter;
30434 + volatile uint32_t totalProcessedFragCounter;
30435 + volatile uint32_t totalMalformdFragCounter;
30436 + volatile uint32_t totalSetBusyCounter;
30437 + volatile uint32_t totalDiscardedFragsCounter;
30438 + volatile uint32_t totalMoreThan16FramesCounter;
30439 + volatile uint32_t reserved2[2];
30440 +} _PackedType t_ReassTbl;
30441 +
30442 +typedef struct t_ReassCommonTbl {
30443 + volatile uint32_t timeoutModeAndFqid;
30444 + volatile uint32_t reassFrmDescIndexPoolTblPtr;
30445 + volatile uint32_t liodnAndReassFrmDescPoolPtrHi;
30446 + volatile uint32_t reassFrmDescPoolPtrLow;
30447 + volatile uint32_t timeOutTblPtr;
30448 + volatile uint32_t expirationDelay;
30449 + volatile uint32_t internalBufferManagement;
30450 + volatile uint32_t reserved2;
30451 + volatile uint32_t totalTimeOutCounter;
30452 + volatile uint32_t totalRfdPoolBusyCounter;
30453 + volatile uint32_t totalInternalBufferBusy;
30454 + volatile uint32_t totalExternalBufferBusy;
30455 + volatile uint32_t totalSgFragmentCounter;
30456 + volatile uint32_t totalDmaSemaphoreDepletionCounter;
30457 + volatile uint32_t totalNCSPCounter;
30458 + volatile uint32_t discardMask;
30459 +} t_ReassCommonTbl;
30460 +
30461 +typedef _Packed struct t_Hmtd {
30462 + volatile uint16_t cfg;
30463 + volatile uint8_t eliodnOffset;
30464 + volatile uint8_t extHmcdBasePtrHi;
30465 + volatile uint32_t hmcdBasePtr;
30466 + volatile uint16_t nextAdIdx;
30467 + volatile uint8_t res1;
30468 + volatile uint8_t opCode;
30469 + volatile uint32_t res2;
30470 +} _PackedType t_Hmtd;
30471 +
30472 +#if defined(__MWERKS__) && !defined(__GNUC__)
30473 +#pragma pack(pop)
30474 +#endif /* defined(__MWERKS__) && ... */
30475 +
30476 +
30477 +/***********************************************************************/
30478 +/* Driver's internal structures */
30479 +/***********************************************************************/
30480 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
30481 +typedef struct
30482 +{
30483 + t_Handle p_AutoLearnHashTbl;
30484 + t_Handle p_ReassmFrmDescrPoolTbl;
30485 + t_Handle p_ReassmFrmDescrIndxPoolTbl;
30486 + t_Handle p_TimeOutTbl;
30487 + uint16_t maxNumFramesInProcess;
30488 + uint8_t numOfTasks;
30489 + //uint8_t poolId;
30490 + uint8_t prOffset;
30491 + uint16_t dataOffset;
30492 + uint8_t sgBpid;
30493 + uint8_t hwPortId;
30494 + uint32_t fqidForTimeOutFrames;
30495 + uint32_t timeoutRoutineRequestTime;
30496 + uint32_t bitFor1Micro;
30497 +} t_CapwapFragParams;
30498 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
30499 +
30500 +typedef struct
30501 +{
30502 + t_AdOfTypeContLookup *p_Frag;
30503 +#if (DPAA_VERSION == 10)
30504 + uint8_t scratchBpid;
30505 +#endif /* (DPAA_VERSION == 10) */
30506 +} t_FragParams;
30507 +
30508 +typedef struct t_ReassmParams
30509 +{
30510 + e_NetHeaderType hdr; /* Header selection */
30511 + t_ReassCommonTbl *p_ReassCommonTbl;
30512 + uintptr_t reassFrmDescrIndxPoolTblAddr;
30513 + uintptr_t reassFrmDescrPoolTblAddr;
30514 + uintptr_t timeOutTblAddr;
30515 + uintptr_t internalBufferPoolManagementIndexAddr;
30516 + uintptr_t internalBufferPoolAddr;
30517 + uint32_t maxNumFramesInProcess;
30518 + uint8_t sgBpid;
30519 + uint8_t dataMemId;
30520 + uint16_t dataLiodnOffset;
30521 + uint32_t fqidForTimeOutFrames;
30522 + e_FmPcdManipReassemTimeOutMode timeOutMode;
30523 + uint32_t timeoutThresholdForReassmProcess;
30524 + union {
30525 + struct {
30526 + t_Handle h_Ipv4Ad;
30527 + t_Handle h_Ipv6Ad;
30528 + bool ipv6Assigned;
30529 + t_ReassTbl *p_Ipv4ReassTbl;
30530 + t_ReassTbl *p_Ipv6ReassTbl;
30531 + uintptr_t ipv4AutoLearnHashTblAddr;
30532 + uintptr_t ipv6AutoLearnHashTblAddr;
30533 + uintptr_t ipv4AutoLearnSetLockTblAddr;
30534 + uintptr_t ipv6AutoLearnSetLockTblAddr;
30535 + uint16_t minFragSize[2];
30536 + e_FmPcdManipReassemWaysNumber numOfFramesPerHashEntry[2];
30537 + uint8_t relativeSchemeId[2];
30538 + t_Handle h_Ipv4Scheme;
30539 + t_Handle h_Ipv6Scheme;
30540 + uint32_t nonConsistentSpFqid;
30541 + } ip;
30542 + struct {
30543 + t_Handle h_Ad;
30544 + t_ReassTbl *p_ReassTbl;
30545 + uintptr_t autoLearnHashTblAddr;
30546 + uintptr_t autoLearnSetLockTblAddr;
30547 + uint16_t maxRessembledsSize;
30548 + e_FmPcdManipReassemWaysNumber numOfFramesPerHashEntry;
30549 + uint8_t relativeSchemeId;
30550 + t_Handle h_Scheme;
30551 + } capwap;
30552 + };
30553 +} t_ReassmParams;
30554 +
30555 +typedef struct{
30556 + e_FmPcdManipType type;
30557 + t_FmPcdManipParams manipParams;
30558 + bool muramAllocate;
30559 + t_Handle h_Ad;
30560 + uint32_t opcode;
30561 + bool rmv;
30562 + bool insrt;
30563 + t_Handle h_NextManip;
30564 + t_Handle h_PrevManip;
30565 + e_FmPcdManipType nextManipType;
30566 + /* HdrManip parameters*/
30567 + uint8_t *p_Hmct;
30568 + uint8_t *p_Data;
30569 + bool dontParseAfterManip;
30570 + bool fieldUpdate;
30571 + bool custom;
30572 + uint16_t tableSize;
30573 + uint8_t dataSize;
30574 + bool cascaded;
30575 + e_ManipUnifiedPosition unifiedPosition;
30576 + /* end HdrManip */
30577 + uint8_t *p_Template;
30578 + uint16_t owner;
30579 + uint32_t updateParams;
30580 + uint32_t shadowUpdateParams;
30581 + bool frag;
30582 + bool reassm;
30583 + uint16_t sizeForFragmentation;
30584 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
30585 + t_Handle h_Frag;
30586 + t_CapwapFragParams capwapFragParams;
30587 +#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
30588 + union {
30589 + t_ReassmParams reassmParams;
30590 + t_FragParams fragParams;
30591 + };
30592 + uint8_t icOffset;
30593 + uint16_t ownerTmp;
30594 + bool cnia;
30595 + t_Handle p_StatsTbl;
30596 + t_Handle h_FmPcd;
30597 + t_List nodesLst;
30598 + t_Handle h_Spinlock;
30599 +} t_FmPcdManip;
30600 +
30601 +typedef struct t_FmPcdCcSavedManipParams
30602 +{
30603 + union
30604 + {
30605 + struct
30606 + {
30607 + uint16_t dataOffset;
30608 + //uint8_t poolId;
30609 + }capwapParams;
30610 + struct
30611 + {
30612 + uint16_t dataOffset;
30613 + uint8_t poolId;
30614 + }ipParams;
30615 + };
30616 +
30617 +} t_FmPcdCcSavedManipParams;
30618 +
30619 +
30620 +#endif /* __FM_MANIP_H */
30621 --- /dev/null
30622 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_pcd.c
30623 @@ -0,0 +1,2094 @@
30624 +/*
30625 + * Copyright 2008-2012 Freescale Semiconductor Inc.
30626 + *
30627 + * Redistribution and use in source and binary forms, with or without
30628 + * modification, are permitted provided that the following conditions are met:
30629 + * * Redistributions of source code must retain the above copyright
30630 + * notice, this list of conditions and the following disclaimer.
30631 + * * Redistributions in binary form must reproduce the above copyright
30632 + * notice, this list of conditions and the following disclaimer in the
30633 + * documentation and/or other materials provided with the distribution.
30634 + * * Neither the name of Freescale Semiconductor nor the
30635 + * names of its contributors may be used to endorse or promote products
30636 + * derived from this software without specific prior written permission.
30637 + *
30638 + *
30639 + * ALTERNATIVELY, this software may be distributed under the terms of the
30640 + * GNU General Public License ("GPL") as published by the Free Software
30641 + * Foundation, either version 2 of that License or (at your option) any
30642 + * later version.
30643 + *
30644 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
30645 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
30646 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30647 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
30648 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30649 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30650 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30651 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30652 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30653 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30654 + */
30655 +
30656 +
30657 +/******************************************************************************
30658 + @File fm_pcd.c
30659 +
30660 + @Description FM PCD ...
30661 +*//***************************************************************************/
30662 +#include "std_ext.h"
30663 +#include "error_ext.h"
30664 +#include "string_ext.h"
30665 +#include "xx_ext.h"
30666 +#include "sprint_ext.h"
30667 +#include "debug_ext.h"
30668 +#include "net_ext.h"
30669 +#include "fm_ext.h"
30670 +#include "fm_pcd_ext.h"
30671 +
30672 +#include "fm_common.h"
30673 +#include "fm_pcd.h"
30674 +#include "fm_pcd_ipc.h"
30675 +#include "fm_hc.h"
30676 +#include "fm_muram_ext.h"
30677 +
30678 +
30679 +/****************************************/
30680 +/* static functions */
30681 +/****************************************/
30682 +
30683 +static t_Error CheckFmPcdParameters(t_FmPcd *p_FmPcd)
30684 +{
30685 + if (!p_FmPcd->h_Fm)
30686 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("h_Fm has to be initialized"));
30687 +
30688 + if (p_FmPcd->guestId == NCSW_MASTER_ID)
30689 + {
30690 + if (p_FmPcd->p_FmPcdKg && !p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs)
30691 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Something WRONG"));
30692 +
30693 + if (p_FmPcd->p_FmPcdPlcr && !p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs)
30694 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Something WRONG"));
30695 +
30696 + if (!p_FmPcd->f_Exception)
30697 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("f_FmPcdExceptions has to be initialized"));
30698 +
30699 + if ((!p_FmPcd->f_FmPcdIndexedException) && (p_FmPcd->p_FmPcdPlcr || p_FmPcd->p_FmPcdKg))
30700 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("f_FmPcdIndexedException has to be initialized"));
30701 +
30702 + if (p_FmPcd->p_FmPcdDriverParam->prsMaxParseCycleLimit > PRS_MAX_CYCLE_LIMIT)
30703 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("prsMaxParseCycleLimit has to be less than 8191"));
30704 + }
30705 +
30706 + return E_OK;
30707 +}
30708 +
30709 +static volatile bool blockingFlag = FALSE;
30710 +static void IpcMsgCompletionCB(t_Handle h_FmPcd,
30711 + uint8_t *p_Msg,
30712 + uint8_t *p_Reply,
30713 + uint32_t replyLength,
30714 + t_Error status)
30715 +{
30716 + UNUSED(h_FmPcd);UNUSED(p_Msg);UNUSED(p_Reply);UNUSED(replyLength);UNUSED(status);
30717 + blockingFlag = FALSE;
30718 +}
30719 +
30720 +static t_Error IpcMsgHandlerCB(t_Handle h_FmPcd,
30721 + uint8_t *p_Msg,
30722 + uint32_t msgLength,
30723 + uint8_t *p_Reply,
30724 + uint32_t *p_ReplyLength)
30725 +{
30726 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
30727 + t_Error err = E_OK;
30728 + t_FmPcdIpcMsg *p_IpcMsg = (t_FmPcdIpcMsg*)p_Msg;
30729 + t_FmPcdIpcReply *p_IpcReply = (t_FmPcdIpcReply*)p_Reply;
30730 +
30731 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
30732 + SANITY_CHECK_RETURN_ERROR((msgLength >= sizeof(uint32_t)), E_INVALID_VALUE);
30733 +
30734 +#ifdef DISABLE_SANITY_CHECKS
30735 + UNUSED(msgLength);
30736 +#endif /* DISABLE_SANITY_CHECKS */
30737 +
30738 + ASSERT_COND(p_Msg);
30739 +
30740 + memset(p_IpcReply, 0, (sizeof(uint8_t) * FM_PCD_MAX_REPLY_SIZE));
30741 + *p_ReplyLength = 0;
30742 +
30743 + switch (p_IpcMsg->msgId)
30744 + {
30745 + case (FM_PCD_MASTER_IS_ALIVE):
30746 + *(uint8_t*)(p_IpcReply->replyBody) = 1;
30747 + p_IpcReply->error = E_OK;
30748 + *p_ReplyLength = sizeof(uint32_t) + sizeof(uint8_t);
30749 + break;
30750 + case (FM_PCD_MASTER_IS_ENABLED):
30751 + /* count partitions registrations */
30752 + if (p_FmPcd->enabled)
30753 + p_FmPcd->numOfEnabledGuestPartitionsPcds++;
30754 + *(uint8_t*)(p_IpcReply->replyBody) = (uint8_t)p_FmPcd->enabled;
30755 + p_IpcReply->error = E_OK;
30756 + *p_ReplyLength = sizeof(uint32_t) + sizeof(uint8_t);
30757 + break;
30758 + case (FM_PCD_GUEST_DISABLE):
30759 + if (p_FmPcd->numOfEnabledGuestPartitionsPcds)
30760 + {
30761 + p_FmPcd->numOfEnabledGuestPartitionsPcds--;
30762 + p_IpcReply->error = E_OK;
30763 + }
30764 + else
30765 + {
30766 + REPORT_ERROR(MINOR, E_INVALID_STATE,("Trying to disable an unregistered partition"));
30767 + p_IpcReply->error = E_INVALID_STATE;
30768 + }
30769 + *p_ReplyLength = sizeof(uint32_t);
30770 + break;
30771 + case (FM_PCD_GET_COUNTER):
30772 + {
30773 + e_FmPcdCounters inCounter;
30774 + uint32_t outCounter;
30775 +
30776 + memcpy((uint8_t*)&inCounter, p_IpcMsg->msgBody, sizeof(uint32_t));
30777 + outCounter = FM_PCD_GetCounter(h_FmPcd, inCounter);
30778 + memcpy(p_IpcReply->replyBody, (uint8_t*)&outCounter, sizeof(uint32_t));
30779 + p_IpcReply->error = E_OK;
30780 + *p_ReplyLength = sizeof(uint32_t) + sizeof(uint32_t);
30781 + break;
30782 + }
30783 + case (FM_PCD_ALLOC_KG_SCHEMES):
30784 + {
30785 + t_FmPcdIpcKgSchemesParams ipcSchemesParams;
30786 +
30787 + memcpy((uint8_t*)&ipcSchemesParams, p_IpcMsg->msgBody, sizeof(t_FmPcdIpcKgSchemesParams));
30788 + err = FmPcdKgAllocSchemes(h_FmPcd,
30789 + ipcSchemesParams.numOfSchemes,
30790 + ipcSchemesParams.guestId,
30791 + p_IpcReply->replyBody);
30792 + p_IpcReply->error = err;
30793 + *p_ReplyLength = sizeof(uint32_t) + ipcSchemesParams.numOfSchemes*sizeof(uint8_t);
30794 + break;
30795 + }
30796 + case (FM_PCD_FREE_KG_SCHEMES):
30797 + {
30798 + t_FmPcdIpcKgSchemesParams ipcSchemesParams;
30799 +
30800 + memcpy((uint8_t*)&ipcSchemesParams, p_IpcMsg->msgBody, sizeof(t_FmPcdIpcKgSchemesParams));
30801 + err = FmPcdKgFreeSchemes(h_FmPcd,
30802 + ipcSchemesParams.numOfSchemes,
30803 + ipcSchemesParams.guestId,
30804 + ipcSchemesParams.schemesIds);
30805 + p_IpcReply->error = err;
30806 + *p_ReplyLength = sizeof(uint32_t);
30807 + break;
30808 + }
30809 + case (FM_PCD_ALLOC_KG_CLSPLAN):
30810 + {
30811 + t_FmPcdIpcKgClsPlanParams ipcKgClsPlanParams;
30812 +
30813 + memcpy((uint8_t*)&ipcKgClsPlanParams, p_IpcMsg->msgBody, sizeof(t_FmPcdIpcKgClsPlanParams));
30814 + err = KgAllocClsPlanEntries(h_FmPcd,
30815 + ipcKgClsPlanParams.numOfClsPlanEntries,
30816 + ipcKgClsPlanParams.guestId,
30817 + p_IpcReply->replyBody);
30818 + p_IpcReply->error = err;
30819 + *p_ReplyLength = sizeof(uint32_t) + sizeof(uint8_t);
30820 + break;
30821 + }
30822 + case (FM_PCD_FREE_KG_CLSPLAN):
30823 + {
30824 + t_FmPcdIpcKgClsPlanParams ipcKgClsPlanParams;
30825 +
30826 + memcpy((uint8_t*)&ipcKgClsPlanParams, p_IpcMsg->msgBody, sizeof(t_FmPcdIpcKgClsPlanParams));
30827 + KgFreeClsPlanEntries(h_FmPcd,
30828 + ipcKgClsPlanParams.numOfClsPlanEntries,
30829 + ipcKgClsPlanParams.guestId,
30830 + ipcKgClsPlanParams.clsPlanBase);
30831 + *p_ReplyLength = sizeof(uint32_t);
30832 + break;
30833 + }
30834 + case (FM_PCD_ALLOC_PROFILES):
30835 + {
30836 + t_FmIpcResourceAllocParams ipcAllocParams;
30837 + uint16_t base;
30838 + memcpy(&ipcAllocParams, p_IpcMsg->msgBody, sizeof(t_FmIpcResourceAllocParams));
30839 + base = PlcrAllocProfilesForPartition(h_FmPcd,
30840 + ipcAllocParams.base,
30841 + ipcAllocParams.num,
30842 + ipcAllocParams.guestId);
30843 + memcpy(p_IpcReply->replyBody, (uint16_t*)&base, sizeof(uint16_t));
30844 + *p_ReplyLength = sizeof(uint32_t) + sizeof(uint16_t);
30845 + break;
30846 + }
30847 + case (FM_PCD_FREE_PROFILES):
30848 + {
30849 + t_FmIpcResourceAllocParams ipcAllocParams;
30850 + memcpy(&ipcAllocParams, p_IpcMsg->msgBody, sizeof(t_FmIpcResourceAllocParams));
30851 + PlcrFreeProfilesForPartition(h_FmPcd,
30852 + ipcAllocParams.base,
30853 + ipcAllocParams.num,
30854 + ipcAllocParams.guestId);
30855 + break;
30856 + }
30857 + case (FM_PCD_SET_PORT_PROFILES):
30858 + {
30859 + t_FmIpcResourceAllocParams ipcAllocParams;
30860 + memcpy(&ipcAllocParams, p_IpcMsg->msgBody, sizeof(t_FmIpcResourceAllocParams));
30861 + PlcrSetPortProfiles(h_FmPcd,
30862 + ipcAllocParams.guestId,
30863 + ipcAllocParams.num,
30864 + ipcAllocParams.base);
30865 + break;
30866 + }
30867 + case (FM_PCD_CLEAR_PORT_PROFILES):
30868 + {
30869 + t_FmIpcResourceAllocParams ipcAllocParams;
30870 + memcpy(&ipcAllocParams, p_IpcMsg->msgBody, sizeof(t_FmIpcResourceAllocParams));
30871 + PlcrClearPortProfiles(h_FmPcd,
30872 + ipcAllocParams.guestId);
30873 + break;
30874 + }
30875 + case (FM_PCD_GET_SW_PRS_OFFSET):
30876 + {
30877 + t_FmPcdIpcSwPrsLable ipcSwPrsLable;
30878 + uint32_t swPrsOffset;
30879 +
30880 + memcpy((uint8_t*)&ipcSwPrsLable, p_IpcMsg->msgBody, sizeof(t_FmPcdIpcSwPrsLable));
30881 + swPrsOffset =
30882 + FmPcdGetSwPrsOffset(h_FmPcd,
30883 + (e_NetHeaderType)ipcSwPrsLable.enumHdr,
30884 + ipcSwPrsLable.indexPerHdr);
30885 + memcpy(p_IpcReply->replyBody, (uint8_t*)&swPrsOffset, sizeof(uint32_t));
30886 + *p_ReplyLength = sizeof(uint32_t) + sizeof(uint32_t);
30887 + break;
30888 + }
30889 + case (FM_PCD_PRS_INC_PORT_STATS):
30890 + {
30891 + t_FmPcdIpcPrsIncludePort ipcPrsIncludePort;
30892 +
30893 + memcpy((uint8_t*)&ipcPrsIncludePort, p_IpcMsg->msgBody, sizeof(t_FmPcdIpcPrsIncludePort));
30894 + PrsIncludePortInStatistics(h_FmPcd,
30895 + ipcPrsIncludePort.hardwarePortId,
30896 + ipcPrsIncludePort.include);
30897 + break;
30898 + }
30899 + default:
30900 + *p_ReplyLength = 0;
30901 + RETURN_ERROR(MINOR, E_INVALID_SELECTION, ("command not found!!!"));
30902 + }
30903 + return E_OK;
30904 +}
30905 +
30906 +static uint32_t NetEnvLock(t_Handle h_NetEnv)
30907 +{
30908 + ASSERT_COND(h_NetEnv);
30909 + return XX_LockIntrSpinlock(((t_FmPcdNetEnv*)h_NetEnv)->h_Spinlock);
30910 +}
30911 +
30912 +static void NetEnvUnlock(t_Handle h_NetEnv, uint32_t intFlags)
30913 +{
30914 + ASSERT_COND(h_NetEnv);
30915 + XX_UnlockIntrSpinlock(((t_FmPcdNetEnv*)h_NetEnv)->h_Spinlock, intFlags);
30916 +}
30917 +
30918 +static void EnqueueLockToFreeLst(t_FmPcd *p_FmPcd, t_FmPcdLock *p_Lock)
30919 +{
30920 + uint32_t intFlags;
30921 +
30922 + intFlags = XX_LockIntrSpinlock(p_FmPcd->h_Spinlock);
30923 + LIST_AddToTail(&p_Lock->node, &p_FmPcd->freeLocksLst);
30924 + XX_UnlockIntrSpinlock(p_FmPcd->h_Spinlock, intFlags);
30925 +}
30926 +
30927 +static t_FmPcdLock * DequeueLockFromFreeLst(t_FmPcd *p_FmPcd)
30928 +{
30929 + t_FmPcdLock *p_Lock = NULL;
30930 + uint32_t intFlags;
30931 +
30932 + intFlags = XX_LockIntrSpinlock(p_FmPcd->h_Spinlock);
30933 + if (!LIST_IsEmpty(&p_FmPcd->freeLocksLst))
30934 + {
30935 + p_Lock = FM_PCD_LOCK_OBJ(p_FmPcd->freeLocksLst.p_Next);
30936 + LIST_DelAndInit(&p_Lock->node);
30937 + }
30938 + XX_UnlockIntrSpinlock(p_FmPcd->h_Spinlock, intFlags);
30939 +
30940 + return p_Lock;
30941 +}
30942 +
30943 +static void EnqueueLockToAcquiredLst(t_FmPcd *p_FmPcd, t_FmPcdLock *p_Lock)
30944 +{
30945 + uint32_t intFlags;
30946 +
30947 + intFlags = XX_LockIntrSpinlock(p_FmPcd->h_Spinlock);
30948 + LIST_AddToTail(&p_Lock->node, &p_FmPcd->acquiredLocksLst);
30949 + XX_UnlockIntrSpinlock(p_FmPcd->h_Spinlock, intFlags);
30950 +}
30951 +
30952 +static t_Error FillFreeLocksLst(t_FmPcd *p_FmPcd)
30953 +{
30954 + t_FmPcdLock *p_Lock;
30955 + int i;
30956 +
30957 + for (i=0; i<10; i++)
30958 + {
30959 + p_Lock = (t_FmPcdLock *)XX_Malloc(sizeof(t_FmPcdLock));
30960 + if (!p_Lock)
30961 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("FM-PCD lock obj!"));
30962 + memset(p_Lock, 0, sizeof(t_FmPcdLock));
30963 + INIT_LIST(&p_Lock->node);
30964 + p_Lock->h_Spinlock = XX_InitSpinlock();
30965 + if (!p_Lock->h_Spinlock)
30966 + {
30967 + XX_Free(p_Lock);
30968 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("FM-PCD spinlock obj!"));
30969 + }
30970 + EnqueueLockToFreeLst(p_FmPcd, p_Lock);
30971 + }
30972 +
30973 + return E_OK;
30974 +}
30975 +
30976 +static void ReleaseFreeLocksLst(t_FmPcd *p_FmPcd)
30977 +{
30978 + t_FmPcdLock *p_Lock;
30979 +
30980 + p_Lock = DequeueLockFromFreeLst(p_FmPcd);
30981 + while (p_Lock)
30982 + {
30983 + XX_FreeSpinlock(p_Lock->h_Spinlock);
30984 + XX_Free(p_Lock);
30985 + p_Lock = DequeueLockFromFreeLst(p_FmPcd);
30986 + }
30987 +}
30988 +
30989 +
30990 +
30991 +/*****************************************************************************/
30992 +/* Inter-module API routines */
30993 +/*****************************************************************************/
30994 +
30995 +void FmPcdSetClsPlanGrpId(t_FmPcd *p_FmPcd, uint8_t netEnvId, uint8_t clsPlanGrpId)
30996 +{
30997 + ASSERT_COND(p_FmPcd);
30998 + p_FmPcd->netEnvs[netEnvId].clsPlanGrpId = clsPlanGrpId;
30999 +}
31000 +
31001 +t_Error PcdGetClsPlanGrpParams(t_FmPcd *p_FmPcd, t_FmPcdKgInterModuleClsPlanGrpParams *p_GrpParams)
31002 +{
31003 + uint8_t netEnvId = p_GrpParams->netEnvId;
31004 + int i, k, j;
31005 +
31006 + ASSERT_COND(p_FmPcd);
31007 + if (p_FmPcd->netEnvs[netEnvId].clsPlanGrpId != ILLEGAL_CLS_PLAN)
31008 + {
31009 + p_GrpParams->grpExists = TRUE;
31010 + p_GrpParams->clsPlanGrpId = p_FmPcd->netEnvs[netEnvId].clsPlanGrpId;
31011 + return E_OK;
31012 + }
31013 +
31014 + for (i=0; ((i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS) &&
31015 + (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE)); i++)
31016 + {
31017 + for (k=0; ((k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS) &&
31018 + (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].hdr != HEADER_TYPE_NONE)); k++)
31019 + {
31020 + /* if an option exists, add it to the opts list */
31021 + if (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].opt)
31022 + {
31023 + /* check if this option already exists, add if it doesn't */
31024 + for (j = 0;j<p_GrpParams->numOfOptions;j++)
31025 + {
31026 + if (p_GrpParams->options[j] == p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].opt)
31027 + break;
31028 + }
31029 + p_GrpParams->optVectors[j] |= p_FmPcd->netEnvs[netEnvId].unitsVectors[i];
31030 + if (j == p_GrpParams->numOfOptions)
31031 + {
31032 + p_GrpParams->options[p_GrpParams->numOfOptions] = p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].opt;
31033 + p_GrpParams->numOfOptions++;
31034 + }
31035 + }
31036 + }
31037 + }
31038 +
31039 + if (p_GrpParams->numOfOptions == 0)
31040 + {
31041 + if (p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId != ILLEGAL_CLS_PLAN)
31042 + {
31043 + p_GrpParams->grpExists = TRUE;
31044 + p_GrpParams->clsPlanGrpId = p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId;
31045 + }
31046 + }
31047 +
31048 + return E_OK;
31049 +
31050 +}
31051 +
31052 +t_Error PcdGetVectorForOpt(t_FmPcd *p_FmPcd, uint8_t netEnvId, protocolOpt_t opt, uint32_t *p_Vector)
31053 +{
31054 + uint8_t j,k;
31055 +
31056 + *p_Vector = 0;
31057 +
31058 + ASSERT_COND(p_FmPcd);
31059 + for (j=0; ((j < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS) &&
31060 + (p_FmPcd->netEnvs[netEnvId].units[j].hdrs[0].hdr != HEADER_TYPE_NONE)); j++)
31061 + {
31062 + for (k=0; ((k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS) &&
31063 + (p_FmPcd->netEnvs[netEnvId].units[j].hdrs[k].hdr != HEADER_TYPE_NONE)); k++)
31064 + {
31065 + if (p_FmPcd->netEnvs[netEnvId].units[j].hdrs[k].opt == opt)
31066 + *p_Vector |= p_FmPcd->netEnvs[netEnvId].unitsVectors[j];
31067 + }
31068 + }
31069 +
31070 + if (!*p_Vector)
31071 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Requested option was not defined for this Network Environment Characteristics module"));
31072 + else
31073 + return E_OK;
31074 +}
31075 +
31076 +t_Error PcdGetUnitsVector(t_FmPcd *p_FmPcd, t_NetEnvParams *p_Params)
31077 +{
31078 + int i;
31079 +
31080 + ASSERT_COND(p_FmPcd);
31081 + ASSERT_COND(p_Params->netEnvId < FM_MAX_NUM_OF_PORTS);
31082 +
31083 + p_Params->vector = 0;
31084 + for (i=0; i<p_Params->numOfDistinctionUnits ;i++)
31085 + {
31086 + if (p_FmPcd->netEnvs[p_Params->netEnvId].units[p_Params->unitIds[i]].hdrs[0].hdr == HEADER_TYPE_NONE)
31087 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Requested unit was not defined for this Network Environment Characteristics module"));
31088 + ASSERT_COND(p_FmPcd->netEnvs[p_Params->netEnvId].unitsVectors[p_Params->unitIds[i]]);
31089 + p_Params->vector |= p_FmPcd->netEnvs[p_Params->netEnvId].unitsVectors[p_Params->unitIds[i]];
31090 + }
31091 +
31092 + return E_OK;
31093 +}
31094 +
31095 +bool PcdNetEnvIsUnitWithoutOpts(t_FmPcd *p_FmPcd, uint8_t netEnvId, uint32_t unitVector)
31096 +{
31097 + int i=0, k;
31098 +
31099 + ASSERT_COND(p_FmPcd);
31100 + /* check whether a given unit may be used by non-clsPlan users. */
31101 + /* first, recognize the unit by its vector */
31102 + while (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE)
31103 + {
31104 + if (p_FmPcd->netEnvs[netEnvId].unitsVectors[i] == unitVector)
31105 + {
31106 + for (k=0;
31107 + ((k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS) &&
31108 + (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].hdr != HEADER_TYPE_NONE));
31109 + k++)
31110 + /* check that no option exists */
31111 + if ((protocolOpt_t)p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].opt)
31112 + return FALSE;
31113 + break;
31114 + }
31115 + i++;
31116 + }
31117 + /* assert that a unit was found to mach the vector */
31118 + ASSERT_COND(p_FmPcd->netEnvs[netEnvId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE);
31119 +
31120 + return TRUE;
31121 +}
31122 +bool FmPcdNetEnvIsHdrExist(t_Handle h_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr)
31123 +{
31124 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
31125 + int i, k;
31126 +
31127 + ASSERT_COND(p_FmPcd);
31128 +
31129 + for (i=0; ((i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS) &&
31130 + (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE)); i++)
31131 + {
31132 + for (k=0; ((k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS) &&
31133 + (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].hdr != HEADER_TYPE_NONE)); k++)
31134 + if (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].hdr == hdr)
31135 + return TRUE;
31136 + }
31137 + for (i=0; ((i < FM_PCD_MAX_NUM_OF_ALIAS_HDRS) &&
31138 + (p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].hdr != HEADER_TYPE_NONE)); i++)
31139 + {
31140 + if (p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].hdr == hdr)
31141 + return TRUE;
31142 + }
31143 +
31144 + return FALSE;
31145 +}
31146 +
31147 +uint8_t FmPcdNetEnvGetUnitId(t_FmPcd *p_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr, bool interchangeable, protocolOpt_t opt)
31148 +{
31149 + uint8_t i, k;
31150 +
31151 + ASSERT_COND(p_FmPcd);
31152 +
31153 + if (interchangeable)
31154 + {
31155 + for (i=0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS) &&
31156 + (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE); i++)
31157 + {
31158 + for (k=0; (k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS) &&
31159 + (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].hdr != HEADER_TYPE_NONE); k++)
31160 + {
31161 + if ((p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].hdr == hdr) &&
31162 + (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].opt == opt))
31163 +
31164 + return i;
31165 + }
31166 + }
31167 + }
31168 + else
31169 + {
31170 + for (i=0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS) &&
31171 + (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE); i++)
31172 + if ((p_FmPcd->netEnvs[netEnvId].units[i].hdrs[0].hdr == hdr) &&
31173 + (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[0].opt == opt) &&
31174 + (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[1].hdr == HEADER_TYPE_NONE))
31175 + return i;
31176 +
31177 + for (i=0; (i < FM_PCD_MAX_NUM_OF_ALIAS_HDRS) &&
31178 + (p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].hdr != HEADER_TYPE_NONE); i++)
31179 + if ((p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].hdr == hdr) &&
31180 + (p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].opt == opt))
31181 + return p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].aliasHdr;
31182 + }
31183 +
31184 + return FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS;
31185 +}
31186 +
31187 +t_Error FmPcdUnregisterReassmPort(t_Handle h_FmPcd, t_Handle h_ReasmCommonPramTbl)
31188 +{
31189 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
31190 + t_FmPcdCcReassmTimeoutParams ccReassmTimeoutParams = {0};
31191 + uint8_t result;
31192 + t_Error err = E_OK;
31193 +
31194 + ASSERT_COND(p_FmPcd);
31195 + ASSERT_COND(h_ReasmCommonPramTbl);
31196 +
31197 + ccReassmTimeoutParams.iprcpt = (uint32_t)(XX_VirtToPhys(h_ReasmCommonPramTbl) - p_FmPcd->physicalMuramBase);
31198 + ccReassmTimeoutParams.activate = FALSE; /*Disable Timeout Task*/
31199 +
31200 + if ((err = FmHcPcdCcTimeoutReassm(p_FmPcd->h_Hc, &ccReassmTimeoutParams, &result)) != E_OK)
31201 + RETURN_ERROR(MAJOR, err, NO_MSG);
31202 +
31203 + switch (result)
31204 + {
31205 + case (0):
31206 + return E_OK;
31207 + case (1):
31208 + RETURN_ERROR(MAJOR, E_INVALID_STATE, (""));
31209 + case (2):
31210 + RETURN_ERROR(MAJOR, E_INVALID_STATE, (""));
31211 + case (3):
31212 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("Disable Timeout Task with invalid IPRCPT"));
31213 + default:
31214 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
31215 + }
31216 +
31217 + return E_OK;
31218 +}
31219 +
31220 +e_NetHeaderType FmPcdGetAliasHdr(t_FmPcd *p_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr)
31221 +{
31222 + int i;
31223 +
31224 + ASSERT_COND(p_FmPcd);
31225 + ASSERT_COND(netEnvId < FM_MAX_NUM_OF_PORTS);
31226 +
31227 + for (i=0; (i < FM_PCD_MAX_NUM_OF_ALIAS_HDRS)
31228 + && (p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].hdr != HEADER_TYPE_NONE); i++)
31229 + {
31230 + if (p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].hdr == hdr)
31231 + return p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].aliasHdr;
31232 + }
31233 +
31234 + return HEADER_TYPE_NONE;
31235 +}
31236 +
31237 +void FmPcdPortRegister(t_Handle h_FmPcd, t_Handle h_FmPort, uint8_t hardwarePortId)
31238 +{
31239 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
31240 + uint16_t swPortIndex = 0;
31241 +
31242 + ASSERT_COND(h_FmPcd);
31243 + HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
31244 + p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].h_FmPort = h_FmPort;
31245 +}
31246 +
31247 +uint32_t FmPcdGetLcv(t_Handle h_FmPcd, uint32_t netEnvId, uint8_t hdrNum)
31248 +{
31249 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
31250 +
31251 + ASSERT_COND(h_FmPcd);
31252 + return p_FmPcd->netEnvs[netEnvId].lcvs[hdrNum];
31253 +}
31254 +
31255 +uint32_t FmPcdGetMacsecLcv(t_Handle h_FmPcd, uint32_t netEnvId)
31256 +{
31257 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
31258 +
31259 + ASSERT_COND(h_FmPcd);
31260 + return p_FmPcd->netEnvs[netEnvId].macsecVector;
31261 +}
31262 +
31263 +uint8_t FmPcdGetNetEnvId(t_Handle h_NetEnv)
31264 +{
31265 + return ((t_FmPcdNetEnv*)h_NetEnv)->netEnvId;
31266 +}
31267 +
31268 +void FmPcdIncNetEnvOwners(t_Handle h_FmPcd, uint8_t netEnvId)
31269 +{
31270 + uint32_t intFlags;
31271 +
31272 + ASSERT_COND(h_FmPcd);
31273 +
31274 + intFlags = NetEnvLock(&((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId]);
31275 + ((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId].owners++;
31276 + NetEnvUnlock(&((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId], intFlags);
31277 +}
31278 +
31279 +void FmPcdDecNetEnvOwners(t_Handle h_FmPcd, uint8_t netEnvId)
31280 +{
31281 + uint32_t intFlags;
31282 +
31283 + ASSERT_COND(h_FmPcd);
31284 + ASSERT_COND(((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId].owners);
31285 +
31286 + intFlags = NetEnvLock(&((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId]);
31287 + ((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId].owners--;
31288 + NetEnvUnlock(&((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId], intFlags);
31289 +}
31290 +
31291 +uint32_t FmPcdLock(t_Handle h_FmPcd)
31292 +{
31293 + ASSERT_COND(h_FmPcd);
31294 + return XX_LockIntrSpinlock(((t_FmPcd*)h_FmPcd)->h_Spinlock);
31295 +}
31296 +
31297 +void FmPcdUnlock(t_Handle h_FmPcd, uint32_t intFlags)
31298 +{
31299 + ASSERT_COND(h_FmPcd);
31300 + XX_UnlockIntrSpinlock(((t_FmPcd*)h_FmPcd)->h_Spinlock, intFlags);
31301 +}
31302 +
31303 +t_FmPcdLock * FmPcdAcquireLock(t_Handle h_FmPcd)
31304 +{
31305 + t_FmPcdLock *p_Lock;
31306 + ASSERT_COND(h_FmPcd);
31307 + p_Lock = DequeueLockFromFreeLst((t_FmPcd*)h_FmPcd);
31308 + if (!p_Lock)
31309 + {
31310 + FillFreeLocksLst(h_FmPcd);
31311 + p_Lock = DequeueLockFromFreeLst((t_FmPcd*)h_FmPcd);
31312 + }
31313 +
31314 + if (p_Lock)
31315 + EnqueueLockToAcquiredLst((t_FmPcd*)h_FmPcd, p_Lock);
31316 + return p_Lock;
31317 +}
31318 +
31319 +void FmPcdReleaseLock(t_Handle h_FmPcd, t_FmPcdLock *p_Lock)
31320 +{
31321 + uint32_t intFlags;
31322 + ASSERT_COND(h_FmPcd);
31323 + intFlags = FmPcdLock(h_FmPcd);
31324 + LIST_DelAndInit(&p_Lock->node);
31325 + FmPcdUnlock(h_FmPcd, intFlags);
31326 + EnqueueLockToFreeLst((t_FmPcd*)h_FmPcd, p_Lock);
31327 +}
31328 +
31329 +bool FmPcdLockTryLockAll(t_Handle h_FmPcd)
31330 +{
31331 + uint32_t intFlags;
31332 + t_List *p_Pos, *p_SavedPos=NULL;
31333 +
31334 + ASSERT_COND(h_FmPcd);
31335 + intFlags = FmPcdLock(h_FmPcd);
31336 + LIST_FOR_EACH(p_Pos, &((t_FmPcd*)h_FmPcd)->acquiredLocksLst)
31337 + {
31338 + t_FmPcdLock *p_Lock = FM_PCD_LOCK_OBJ(p_Pos);
31339 + if (!FmPcdLockTryLock(p_Lock))
31340 + {
31341 + p_SavedPos = p_Pos;
31342 + break;
31343 + }
31344 + }
31345 + if (p_SavedPos)
31346 + {
31347 + LIST_FOR_EACH(p_Pos, &((t_FmPcd*)h_FmPcd)->acquiredLocksLst)
31348 + {
31349 + t_FmPcdLock *p_Lock = FM_PCD_LOCK_OBJ(p_Pos);
31350 + if (p_Pos == p_SavedPos)
31351 + break;
31352 + FmPcdLockUnlock(p_Lock);
31353 + }
31354 + }
31355 + FmPcdUnlock(h_FmPcd, intFlags);
31356 +
31357 + CORE_MemoryBarrier();
31358 +
31359 + if (p_SavedPos)
31360 + return FALSE;
31361 +
31362 + return TRUE;
31363 +}
31364 +
31365 +void FmPcdLockUnlockAll(t_Handle h_FmPcd)
31366 +{
31367 + uint32_t intFlags;
31368 + t_List *p_Pos;
31369 +
31370 + ASSERT_COND(h_FmPcd);
31371 + intFlags = FmPcdLock(h_FmPcd);
31372 + LIST_FOR_EACH(p_Pos, &((t_FmPcd*)h_FmPcd)->acquiredLocksLst)
31373 + {
31374 + t_FmPcdLock *p_Lock = FM_PCD_LOCK_OBJ(p_Pos);
31375 + p_Lock->flag = FALSE;
31376 + }
31377 + FmPcdUnlock(h_FmPcd, intFlags);
31378 +
31379 + CORE_MemoryBarrier();
31380 +}
31381 +
31382 +t_Error FmPcdHcSync(t_Handle h_FmPcd)
31383 +{
31384 + ASSERT_COND(h_FmPcd);
31385 + ASSERT_COND(((t_FmPcd*)h_FmPcd)->h_Hc);
31386 +
31387 + return FmHcPcdSync(((t_FmPcd*)h_FmPcd)->h_Hc);
31388 +}
31389 +
31390 +t_Handle FmPcdGetHcHandle(t_Handle h_FmPcd)
31391 +{
31392 + ASSERT_COND(h_FmPcd);
31393 + return ((t_FmPcd*)h_FmPcd)->h_Hc;
31394 +}
31395 +
31396 +bool FmPcdIsAdvancedOffloadSupported(t_Handle h_FmPcd)
31397 +{
31398 + ASSERT_COND(h_FmPcd);
31399 + return ((t_FmPcd*)h_FmPcd)->advancedOffloadSupport;
31400 +}
31401 +/*********************** End of inter-module routines ************************/
31402 +
31403 +
31404 +/****************************************/
31405 +/* API Init unit functions */
31406 +/****************************************/
31407 +
31408 +t_Handle FM_PCD_Config(t_FmPcdParams *p_FmPcdParams)
31409 +{
31410 + t_FmPcd *p_FmPcd = NULL;
31411 + t_FmPhysAddr physicalMuramBase;
31412 + uint8_t i;
31413 +
31414 + SANITY_CHECK_RETURN_VALUE(p_FmPcdParams, E_INVALID_HANDLE,NULL);
31415 +
31416 + p_FmPcd = (t_FmPcd *) XX_Malloc(sizeof(t_FmPcd));
31417 + if (!p_FmPcd)
31418 + {
31419 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD"));
31420 + return NULL;
31421 + }
31422 + memset(p_FmPcd, 0, sizeof(t_FmPcd));
31423 +
31424 + p_FmPcd->p_FmPcdDriverParam = (t_FmPcdDriverParam *) XX_Malloc(sizeof(t_FmPcdDriverParam));
31425 + if (!p_FmPcd->p_FmPcdDriverParam)
31426 + {
31427 + XX_Free(p_FmPcd);
31428 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD Driver Param"));
31429 + return NULL;
31430 + }
31431 + memset(p_FmPcd->p_FmPcdDriverParam, 0, sizeof(t_FmPcdDriverParam));
31432 +
31433 + p_FmPcd->h_Fm = p_FmPcdParams->h_Fm;
31434 + p_FmPcd->guestId = FmGetGuestId(p_FmPcd->h_Fm);
31435 + p_FmPcd->h_FmMuram = FmGetMuramHandle(p_FmPcd->h_Fm);
31436 + if (p_FmPcd->h_FmMuram)
31437 + {
31438 + FmGetPhysicalMuramBase(p_FmPcdParams->h_Fm, &physicalMuramBase);
31439 + p_FmPcd->physicalMuramBase = (uint64_t)((uint64_t)(&physicalMuramBase)->low | ((uint64_t)(&physicalMuramBase)->high << 32));
31440 + }
31441 +
31442 + for (i = 0; i<FM_MAX_NUM_OF_PORTS; i++)
31443 + p_FmPcd->netEnvs[i].clsPlanGrpId = ILLEGAL_CLS_PLAN;
31444 +
31445 + if (p_FmPcdParams->useHostCommand)
31446 + {
31447 + t_FmHcParams hcParams;
31448 +
31449 + memset(&hcParams, 0, sizeof(hcParams));
31450 + hcParams.h_Fm = p_FmPcd->h_Fm;
31451 + hcParams.h_FmPcd = (t_Handle)p_FmPcd;
31452 + memcpy((uint8_t*)&hcParams.params, (uint8_t*)&p_FmPcdParams->hc, sizeof(t_FmPcdHcParams));
31453 + p_FmPcd->h_Hc = FmHcConfigAndInit(&hcParams);
31454 + if (!p_FmPcd->h_Hc)
31455 + {
31456 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD HC"));
31457 + FM_PCD_Free(p_FmPcd);
31458 + return NULL;
31459 + }
31460 + }
31461 + else if (p_FmPcd->guestId != NCSW_MASTER_ID)
31462 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("No Host Command defined for a guest partition."));
31463 +
31464 + if (p_FmPcdParams->kgSupport)
31465 + {
31466 + p_FmPcd->p_FmPcdKg = (t_FmPcdKg *)KgConfig(p_FmPcd, p_FmPcdParams);
31467 + if (!p_FmPcd->p_FmPcdKg)
31468 + {
31469 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD Keygen"));
31470 + FM_PCD_Free(p_FmPcd);
31471 + return NULL;
31472 + }
31473 + }
31474 +
31475 + if (p_FmPcdParams->plcrSupport)
31476 + {
31477 + p_FmPcd->p_FmPcdPlcr = (t_FmPcdPlcr *)PlcrConfig(p_FmPcd, p_FmPcdParams);
31478 + if (!p_FmPcd->p_FmPcdPlcr)
31479 + {
31480 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD Policer"));
31481 + FM_PCD_Free(p_FmPcd);
31482 + return NULL;
31483 + }
31484 + }
31485 +
31486 + if (p_FmPcdParams->prsSupport)
31487 + {
31488 + p_FmPcd->p_FmPcdPrs = (t_FmPcdPrs *)PrsConfig(p_FmPcd, p_FmPcdParams);
31489 + if (!p_FmPcd->p_FmPcdPrs)
31490 + {
31491 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD Parser"));
31492 + FM_PCD_Free(p_FmPcd);
31493 + return NULL;
31494 + }
31495 + }
31496 +
31497 + p_FmPcd->h_Spinlock = XX_InitSpinlock();
31498 + if (!p_FmPcd->h_Spinlock)
31499 + {
31500 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD spinlock"));
31501 + FM_PCD_Free(p_FmPcd);
31502 + return NULL;
31503 + }
31504 + INIT_LIST(&p_FmPcd->freeLocksLst);
31505 + INIT_LIST(&p_FmPcd->acquiredLocksLst);
31506 +
31507 + p_FmPcd->numOfEnabledGuestPartitionsPcds = 0;
31508 +
31509 + p_FmPcd->f_Exception = p_FmPcdParams->f_Exception;
31510 + p_FmPcd->f_FmPcdIndexedException = p_FmPcdParams->f_ExceptionId;
31511 + p_FmPcd->h_App = p_FmPcdParams->h_App;
31512 +
31513 + p_FmPcd->p_CcShadow = NULL;
31514 + p_FmPcd->ccShadowSize = 0;
31515 + p_FmPcd->ccShadowAlign = 0;
31516 +
31517 + p_FmPcd->h_ShadowSpinlock = XX_InitSpinlock();
31518 + if (!p_FmPcd->h_ShadowSpinlock)
31519 + {
31520 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD shadow spinlock"));
31521 + FM_PCD_Free(p_FmPcd);
31522 + return NULL;
31523 + }
31524 +
31525 + return p_FmPcd;
31526 +}
31527 +
31528 +t_Error FM_PCD_Init(t_Handle h_FmPcd)
31529 +{
31530 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
31531 + t_Error err = E_OK;
31532 + t_FmPcdIpcMsg msg;
31533 +
31534 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
31535 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
31536 +
31537 + FM_GetRevision(p_FmPcd->h_Fm, &p_FmPcd->fmRevInfo);
31538 +
31539 + if (p_FmPcd->guestId != NCSW_MASTER_ID)
31540 + {
31541 + memset(p_FmPcd->fmPcdIpcHandlerModuleName, 0, (sizeof(char)) * MODULE_NAME_SIZE);
31542 + if (Sprint (p_FmPcd->fmPcdIpcHandlerModuleName, "FM_PCD_%d_%d", FmGetId(p_FmPcd->h_Fm), NCSW_MASTER_ID) != 10)
31543 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
31544 + memset(p_FmPcd->fmPcdModuleName, 0, (sizeof(char)) * MODULE_NAME_SIZE);
31545 + if (Sprint (p_FmPcd->fmPcdModuleName, "FM_PCD_%d_%d",FmGetId(p_FmPcd->h_Fm), p_FmPcd->guestId) != (p_FmPcd->guestId<10 ? 10:11))
31546 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
31547 +
31548 + p_FmPcd->h_IpcSession = XX_IpcInitSession(p_FmPcd->fmPcdIpcHandlerModuleName, p_FmPcd->fmPcdModuleName);
31549 + if (p_FmPcd->h_IpcSession)
31550 + {
31551 + t_FmPcdIpcReply reply;
31552 + uint32_t replyLength;
31553 + uint8_t isMasterAlive = 0;
31554 +
31555 + memset(&msg, 0, sizeof(msg));
31556 + memset(&reply, 0, sizeof(reply));
31557 + msg.msgId = FM_PCD_MASTER_IS_ALIVE;
31558 + msg.msgBody[0] = p_FmPcd->guestId;
31559 + blockingFlag = TRUE;
31560 +
31561 + do
31562 + {
31563 + replyLength = sizeof(uint32_t) + sizeof(isMasterAlive);
31564 + if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
31565 + (uint8_t*)&msg,
31566 + sizeof(msg.msgId)+sizeof(p_FmPcd->guestId),
31567 + (uint8_t*)&reply,
31568 + &replyLength,
31569 + IpcMsgCompletionCB,
31570 + h_FmPcd)) != E_OK)
31571 + REPORT_ERROR(MAJOR, err, NO_MSG);
31572 + while (blockingFlag) ;
31573 + if (replyLength != (sizeof(uint32_t) + sizeof(isMasterAlive)))
31574 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
31575 + isMasterAlive = *(uint8_t*)(reply.replyBody);
31576 + } while (!isMasterAlive);
31577 + }
31578 + }
31579 +
31580 + CHECK_INIT_PARAMETERS(p_FmPcd, CheckFmPcdParameters);
31581 +
31582 + if (p_FmPcd->p_FmPcdKg)
31583 + {
31584 + err = KgInit(p_FmPcd);
31585 + if (err)
31586 + RETURN_ERROR(MAJOR, err, NO_MSG);
31587 + }
31588 +
31589 + if (p_FmPcd->p_FmPcdPlcr)
31590 + {
31591 + err = PlcrInit(p_FmPcd);
31592 + if (err)
31593 + RETURN_ERROR(MAJOR, err, NO_MSG);
31594 + }
31595 +
31596 + if (p_FmPcd->p_FmPcdPrs)
31597 + {
31598 + err = PrsInit(p_FmPcd);
31599 + if (err)
31600 + RETURN_ERROR(MAJOR, err, NO_MSG);
31601 + }
31602 +
31603 + if (p_FmPcd->guestId == NCSW_MASTER_ID)
31604 + {
31605 + /* register to inter-core messaging mechanism */
31606 + memset(p_FmPcd->fmPcdModuleName, 0, (sizeof(char)) * MODULE_NAME_SIZE);
31607 + if (Sprint (p_FmPcd->fmPcdModuleName, "FM_PCD_%d_%d",FmGetId(p_FmPcd->h_Fm),NCSW_MASTER_ID) != 10)
31608 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
31609 + err = XX_IpcRegisterMsgHandler(p_FmPcd->fmPcdModuleName, IpcMsgHandlerCB, p_FmPcd, FM_PCD_MAX_REPLY_SIZE);
31610 + if (err)
31611 + RETURN_ERROR(MAJOR, err, NO_MSG);
31612 + }
31613 +
31614 + /* IPv6 Frame-Id used for fragmentation */
31615 + p_FmPcd->ipv6FrameIdAddr = PTR_TO_UINT(FM_MURAM_AllocMem(p_FmPcd->h_FmMuram, 4, 4));
31616 + if (!p_FmPcd->ipv6FrameIdAddr)
31617 + {
31618 + FM_PCD_Free(p_FmPcd);
31619 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for IPv6 Frame-Id"));
31620 + }
31621 + IOMemSet32(UINT_TO_PTR(p_FmPcd->ipv6FrameIdAddr), 0, 4);
31622 +
31623 + /* CAPWAP Frame-Id used for fragmentation */
31624 + p_FmPcd->capwapFrameIdAddr = PTR_TO_UINT(FM_MURAM_AllocMem(p_FmPcd->h_FmMuram, 2, 4));
31625 + if (!p_FmPcd->capwapFrameIdAddr)
31626 + {
31627 + FM_PCD_Free(p_FmPcd);
31628 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CAPWAP Frame-Id"));
31629 + }
31630 + IOMemSet32(UINT_TO_PTR(p_FmPcd->capwapFrameIdAddr), 0, 2);
31631 +
31632 + XX_Free(p_FmPcd->p_FmPcdDriverParam);
31633 + p_FmPcd->p_FmPcdDriverParam = NULL;
31634 +
31635 + FmRegisterPcd(p_FmPcd->h_Fm, p_FmPcd);
31636 +
31637 + return E_OK;
31638 +}
31639 +
31640 +t_Error FM_PCD_Free(t_Handle h_FmPcd)
31641 +{
31642 + t_FmPcd *p_FmPcd =(t_FmPcd *)h_FmPcd;
31643 + t_Error err = E_OK;
31644 +
31645 + if (p_FmPcd->ipv6FrameIdAddr)
31646 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, UINT_TO_PTR(p_FmPcd->ipv6FrameIdAddr));
31647 +
31648 + if (p_FmPcd->capwapFrameIdAddr)
31649 + FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, UINT_TO_PTR(p_FmPcd->capwapFrameIdAddr));
31650 +
31651 + if (p_FmPcd->enabled)
31652 + FM_PCD_Disable(p_FmPcd);
31653 +
31654 + if (p_FmPcd->p_FmPcdDriverParam)
31655 + {
31656 + XX_Free(p_FmPcd->p_FmPcdDriverParam);
31657 + p_FmPcd->p_FmPcdDriverParam = NULL;
31658 + }
31659 +
31660 + if (p_FmPcd->p_FmPcdKg)
31661 + {
31662 + if ((err = KgFree(p_FmPcd)) != E_OK)
31663 + RETURN_ERROR(MINOR, err, NO_MSG);
31664 + XX_Free(p_FmPcd->p_FmPcdKg);
31665 + p_FmPcd->p_FmPcdKg = NULL;
31666 + }
31667 +
31668 + if (p_FmPcd->p_FmPcdPlcr)
31669 + {
31670 + PlcrFree(p_FmPcd);
31671 + XX_Free(p_FmPcd->p_FmPcdPlcr);
31672 + p_FmPcd->p_FmPcdPlcr = NULL;
31673 + }
31674 +
31675 + if (p_FmPcd->p_FmPcdPrs)
31676 + {
31677 + if (p_FmPcd->guestId == NCSW_MASTER_ID)
31678 + PrsFree(p_FmPcd);
31679 + XX_Free(p_FmPcd->p_FmPcdPrs);
31680 + p_FmPcd->p_FmPcdPrs = NULL;
31681 + }
31682 +
31683 + if (p_FmPcd->h_Hc)
31684 + {
31685 + FmHcFree(p_FmPcd->h_Hc);
31686 + p_FmPcd->h_Hc = NULL;
31687 + }
31688 +
31689 + XX_IpcUnregisterMsgHandler(p_FmPcd->fmPcdModuleName);
31690 +
31691 + FmUnregisterPcd(p_FmPcd->h_Fm);
31692 +
31693 + ReleaseFreeLocksLst(p_FmPcd);
31694 +
31695 + if (p_FmPcd->h_Spinlock)
31696 + XX_FreeSpinlock(p_FmPcd->h_Spinlock);
31697 +
31698 + if (p_FmPcd->h_ShadowSpinlock)
31699 + XX_FreeSpinlock(p_FmPcd->h_ShadowSpinlock);
31700 +
31701 + XX_Free(p_FmPcd);
31702 +
31703 + return E_OK;
31704 +}
31705 +
31706 +t_Error FM_PCD_ConfigException(t_Handle h_FmPcd, e_FmPcdExceptions exception, bool enable)
31707 +{
31708 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
31709 + uint32_t bitMask = 0;
31710 +
31711 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
31712 +
31713 + if (p_FmPcd->guestId != NCSW_MASTER_ID)
31714 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_ConfigException - guest mode!"));
31715 +
31716 + GET_FM_PCD_EXCEPTION_FLAG(bitMask, exception);
31717 + if (bitMask)
31718 + {
31719 + if (enable)
31720 + p_FmPcd->exceptions |= bitMask;
31721 + else
31722 + p_FmPcd->exceptions &= ~bitMask;
31723 + }
31724 + else
31725 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
31726 +
31727 + return E_OK;
31728 +}
31729 +
31730 +t_Error FM_PCD_ConfigHcFramesDataMemory(t_Handle h_FmPcd, uint8_t memId)
31731 +{
31732 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
31733 +
31734 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
31735 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
31736 +
31737 + return FmHcSetFramesDataMemory(p_FmPcd->h_Hc, memId);
31738 +}
31739 +
31740 +t_Error FM_PCD_Enable(t_Handle h_FmPcd)
31741 +{
31742 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
31743 + t_Error err = E_OK;
31744 +
31745 + SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
31746 +
31747 + if (p_FmPcd->enabled)
31748 + return E_OK;
31749 +
31750 + if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
31751 + p_FmPcd->h_IpcSession)
31752 + {
31753 + uint8_t enabled;
31754 + t_FmPcdIpcMsg msg;
31755 + t_FmPcdIpcReply reply;
31756 + uint32_t replyLength;
31757 +
31758 + memset(&reply, 0, sizeof(reply));
31759 + memset(&msg, 0, sizeof(msg));
31760 + msg.msgId = FM_PCD_MASTER_IS_ENABLED;
31761 + replyLength = sizeof(uint32_t) + sizeof(enabled);
31762 + if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
31763 + (uint8_t*)&msg,
31764 + sizeof(msg.msgId),
31765 + (uint8_t*)&reply,
31766 + &replyLength,
31767 + NULL,
31768 + NULL)) != E_OK)
31769 + RETURN_ERROR(MAJOR, err, NO_MSG);
31770 + if (replyLength != sizeof(uint32_t) + sizeof(enabled))
31771 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
31772 + p_FmPcd->enabled = (bool)!!(*(uint8_t*)(reply.replyBody));
31773 + if (!p_FmPcd->enabled)
31774 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM-PCD master should be enabled first!"));
31775 +
31776 + return E_OK;
31777 + }
31778 + else if (p_FmPcd->guestId != NCSW_MASTER_ID)
31779 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
31780 + ("running in guest-mode without IPC!"));
31781 +
31782 + if (p_FmPcd->p_FmPcdKg)
31783 + KgEnable(p_FmPcd);
31784 +
31785 + if (p_FmPcd->p_FmPcdPlcr)
31786 + PlcrEnable(p_FmPcd);
31787 +
31788 + if (p_FmPcd->p_FmPcdPrs)
31789 + PrsEnable(p_FmPcd);
31790 +
31791 + p_FmPcd->enabled = TRUE;
31792 +
31793 + return E_OK;
31794 +}
31795 +
31796 +t_Error FM_PCD_Disable(t_Handle h_FmPcd)
31797 +{
31798 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
31799 + t_Error err = E_OK;
31800 +
31801 + SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
31802 +
31803 + if (!p_FmPcd->enabled)
31804 + return E_OK;
31805 +
31806 + if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
31807 + p_FmPcd->h_IpcSession)
31808 + {
31809 + t_FmPcdIpcMsg msg;
31810 + t_FmPcdIpcReply reply;
31811 + uint32_t replyLength;
31812 +
31813 + memset(&reply, 0, sizeof(reply));
31814 + memset(&msg, 0, sizeof(msg));
31815 + msg.msgId = FM_PCD_GUEST_DISABLE;
31816 + replyLength = sizeof(uint32_t);
31817 + if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
31818 + (uint8_t*)&msg,
31819 + sizeof(msg.msgId),
31820 + (uint8_t*)&reply,
31821 + &replyLength,
31822 + NULL,
31823 + NULL)) != E_OK)
31824 + RETURN_ERROR(MAJOR, err, NO_MSG);
31825 + if (replyLength != sizeof(uint32_t))
31826 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
31827 + if (reply.error == E_OK)
31828 + p_FmPcd->enabled = FALSE;
31829 +
31830 + return (t_Error)(reply.error);
31831 + }
31832 + else if (p_FmPcd->guestId != NCSW_MASTER_ID)
31833 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
31834 + ("running in guest-mode without IPC!"));
31835 +
31836 + if (p_FmPcd->numOfEnabledGuestPartitionsPcds != 0)
31837 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
31838 + ("Trying to disable a master partition PCD while"
31839 + "guest partitions are still enabled!"));
31840 +
31841 + if (p_FmPcd->p_FmPcdKg)
31842 + KgDisable(p_FmPcd);
31843 +
31844 + if (p_FmPcd->p_FmPcdPlcr)
31845 + PlcrDisable(p_FmPcd);
31846 +
31847 + if (p_FmPcd->p_FmPcdPrs)
31848 + PrsDisable(p_FmPcd);
31849 +
31850 + p_FmPcd->enabled = FALSE;
31851 +
31852 + return E_OK;
31853 +}
31854 +
31855 +t_Handle FM_PCD_NetEnvCharacteristicsSet(t_Handle h_FmPcd, t_FmPcdNetEnvParams *p_NetEnvParams)
31856 +{
31857 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
31858 + uint32_t intFlags, specialUnits = 0;
31859 + uint8_t bitId = 0;
31860 + uint8_t i, j, k;
31861 + uint8_t netEnvCurrId;
31862 + uint8_t ipsecAhUnit = 0,ipsecEspUnit = 0;
31863 + bool ipsecAhExists = FALSE, ipsecEspExists = FALSE, shim1Selected = FALSE;
31864 + uint8_t hdrNum;
31865 + t_FmPcdNetEnvParams *p_ModifiedNetEnvParams;
31866 +
31867 + SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_STATE, NULL);
31868 + SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE, NULL);
31869 + SANITY_CHECK_RETURN_VALUE(p_NetEnvParams, E_NULL_POINTER, NULL);
31870 +
31871 + intFlags = FmPcdLock(p_FmPcd);
31872 +
31873 + /* find a new netEnv */
31874 + for (i = 0; i < FM_MAX_NUM_OF_PORTS; i++)
31875 + if (!p_FmPcd->netEnvs[i].used)
31876 + break;
31877 +
31878 + if (i== FM_MAX_NUM_OF_PORTS)
31879 + {
31880 + REPORT_ERROR(MAJOR, E_FULL,("No more than %d netEnv's allowed.", FM_MAX_NUM_OF_PORTS));
31881 + FmPcdUnlock(p_FmPcd, intFlags);
31882 + return NULL;
31883 + }
31884 +
31885 + p_FmPcd->netEnvs[i].used = TRUE;
31886 + FmPcdUnlock(p_FmPcd, intFlags);
31887 +
31888 + /* As anyone doesn't have handle of this netEnv yet, no need
31889 + to protect it with spinlocks */
31890 +
31891 + p_ModifiedNetEnvParams = (t_FmPcdNetEnvParams *)XX_Malloc(sizeof(t_FmPcdNetEnvParams));
31892 + if (!p_ModifiedNetEnvParams)
31893 + {
31894 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FmPcdNetEnvParams"));
31895 + return NULL;
31896 + }
31897 +
31898 + memcpy(p_ModifiedNetEnvParams, p_NetEnvParams, sizeof(t_FmPcdNetEnvParams));
31899 + p_NetEnvParams = p_ModifiedNetEnvParams;
31900 +
31901 + netEnvCurrId = (uint8_t)i;
31902 +
31903 + /* clear from previous use */
31904 + memset(&p_FmPcd->netEnvs[netEnvCurrId].units, 0, FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS * sizeof(t_FmPcdIntDistinctionUnit));
31905 + memset(&p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs, 0, FM_PCD_MAX_NUM_OF_ALIAS_HDRS * sizeof(t_FmPcdNetEnvAliases));
31906 + memcpy(&p_FmPcd->netEnvs[netEnvCurrId].units, p_NetEnvParams->units, p_NetEnvParams->numOfDistinctionUnits*sizeof(t_FmPcdIntDistinctionUnit));
31907 +
31908 + p_FmPcd->netEnvs[netEnvCurrId].netEnvId = netEnvCurrId;
31909 + p_FmPcd->netEnvs[netEnvCurrId].h_FmPcd = p_FmPcd;
31910 +
31911 + p_FmPcd->netEnvs[netEnvCurrId].clsPlanGrpId = ILLEGAL_CLS_PLAN;
31912 +
31913 + /* check that header with opt is not interchanged with the same header */
31914 + for (i = 0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
31915 + && (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE); i++)
31916 + {
31917 + for (k = 0; (k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS)
31918 + && (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr != HEADER_TYPE_NONE); k++)
31919 + {
31920 + /* if an option exists, check that other headers are not the same header
31921 + without option */
31922 + if (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt)
31923 + {
31924 + for (j = 0; (j < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS)
31925 + && (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[j].hdr != HEADER_TYPE_NONE); j++)
31926 + {
31927 + if ((p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[j].hdr == p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr) &&
31928 + !p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[j].opt)
31929 + {
31930 + REPORT_ERROR(MINOR, E_FULL,
31931 + ("Illegal unit - header with opt may not be interchangeable with the same header without opt"));
31932 + XX_Free(p_ModifiedNetEnvParams);
31933 + return NULL;
31934 + }
31935 + }
31936 + }
31937 + }
31938 + }
31939 +
31940 + /* Specific headers checking */
31941 + for (i = 0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
31942 + && (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE); i++)
31943 + {
31944 + for (k = 0; (k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS)
31945 + && (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr != HEADER_TYPE_NONE); k++)
31946 + {
31947 + /* Some headers pairs may not be defined on different units as the parser
31948 + doesn't distinguish */
31949 + /* IPSEC_AH and IPSEC_SPI can't be 2 units, */
31950 + /* check that header with opt is not interchanged with the same header */
31951 + if (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_IPSEC_AH)
31952 + {
31953 + if (ipsecEspExists && (ipsecEspUnit != i))
31954 + {
31955 + REPORT_ERROR(MINOR, E_INVALID_STATE, ("HEADER_TYPE_IPSEC_AH and HEADER_TYPE_IPSEC_ESP may not be defined in separate units"));
31956 + XX_Free(p_ModifiedNetEnvParams);
31957 + return NULL;
31958 + }
31959 + else
31960 + {
31961 + ipsecAhUnit = i;
31962 + ipsecAhExists = TRUE;
31963 + }
31964 + }
31965 + if (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_IPSEC_ESP)
31966 + {
31967 + if (ipsecAhExists && (ipsecAhUnit != i))
31968 + {
31969 + REPORT_ERROR(MINOR, E_INVALID_STATE, ("HEADER_TYPE_IPSEC_AH and HEADER_TYPE_IPSEC_ESP may not be defined in separate units"));
31970 + XX_Free(p_ModifiedNetEnvParams);
31971 + return NULL;
31972 + }
31973 + else
31974 + {
31975 + ipsecEspUnit = i;
31976 + ipsecEspExists = TRUE;
31977 + }
31978 + }
31979 + /* ENCAP_ESP */
31980 + if (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_UDP_ENCAP_ESP)
31981 + {
31982 + /* IPSec UDP encapsulation is currently set to use SHIM1 */
31983 + p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].hdr = HEADER_TYPE_UDP_ENCAP_ESP;
31984 + p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits++].aliasHdr = HEADER_TYPE_USER_DEFINED_SHIM1;
31985 + p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr = HEADER_TYPE_USER_DEFINED_SHIM1;
31986 + p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt = 0;
31987 + }
31988 +#if (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
31989 + /* UDP_LITE */
31990 + if (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_UDP_LITE)
31991 + {
31992 + p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].hdr = HEADER_TYPE_UDP_LITE;
31993 + p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits++].aliasHdr = HEADER_TYPE_UDP;
31994 + p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr = HEADER_TYPE_UDP;
31995 + p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt = 0;
31996 + }
31997 +#endif /* (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
31998 +
31999 + /* IP FRAG */
32000 + if ((p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_IPv4) &&
32001 + (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt == IPV4_FRAG_1))
32002 + {
32003 + /* If IPv4+Frag, we need to set 2 units - SHIM 2 and IPv4. We first set SHIM2, and than check if
32004 + * IPv4 exists. If so we don't need to set an extra unit
32005 + * We consider as "having IPv4" any IPv4 without interchangable headers
32006 + * but including any options. */
32007 + p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].hdr = HEADER_TYPE_IPv4;
32008 + p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].opt = IPV4_FRAG_1;
32009 + p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits++].aliasHdr = HEADER_TYPE_USER_DEFINED_SHIM2;
32010 + p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr = HEADER_TYPE_USER_DEFINED_SHIM2;
32011 + p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt = 0;
32012 +
32013 + /* check if IPv4 header exists by itself */
32014 + if (FmPcdNetEnvGetUnitId(p_FmPcd, netEnvCurrId, HEADER_TYPE_IPv4, FALSE, 0) == FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
32015 + {
32016 + p_FmPcd->netEnvs[netEnvCurrId].units[p_NetEnvParams->numOfDistinctionUnits].hdrs[0].hdr = HEADER_TYPE_IPv4;
32017 + p_FmPcd->netEnvs[netEnvCurrId].units[p_NetEnvParams->numOfDistinctionUnits++].hdrs[0].opt = 0;
32018 + }
32019 + }
32020 + if ((p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_IPv6) &&
32021 + (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt == IPV6_FRAG_1))
32022 + {
32023 + /* If IPv6+Frag, we need to set 2 units - SHIM 2 and IPv6. We first set SHIM2, and than check if
32024 + * IPv4 exists. If so we don't need to set an extra unit
32025 + * We consider as "having IPv6" any IPv6 without interchangable headers
32026 + * but including any options. */
32027 + p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].hdr = HEADER_TYPE_IPv6;
32028 + p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].opt = IPV6_FRAG_1;
32029 + p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits++].aliasHdr = HEADER_TYPE_USER_DEFINED_SHIM2;
32030 + p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr = HEADER_TYPE_USER_DEFINED_SHIM2;
32031 + p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt = 0;
32032 +
32033 + /* check if IPv6 header exists by itself */
32034 + if (FmPcdNetEnvGetUnitId(p_FmPcd, netEnvCurrId, HEADER_TYPE_IPv6, FALSE, 0) == FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
32035 + {
32036 + p_FmPcd->netEnvs[netEnvCurrId].units[p_NetEnvParams->numOfDistinctionUnits].hdrs[0].hdr = HEADER_TYPE_IPv6;
32037 + p_FmPcd->netEnvs[netEnvCurrId].units[p_NetEnvParams->numOfDistinctionUnits++].hdrs[0].opt = 0;
32038 + }
32039 + }
32040 +#if (DPAA_VERSION >= 11)
32041 + /* CAPWAP FRAG */
32042 + if ((p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_CAPWAP) &&
32043 + (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt == CAPWAP_FRAG_1))
32044 + {
32045 + p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].hdr = HEADER_TYPE_CAPWAP;
32046 + p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].opt = CAPWAP_FRAG_1;
32047 + p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits++].aliasHdr = HEADER_TYPE_USER_DEFINED_SHIM2;
32048 + p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr = HEADER_TYPE_USER_DEFINED_SHIM2;
32049 + p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt = 0;
32050 + }
32051 +#endif /* (DPAA_VERSION >= 11) */
32052 + }
32053 + }
32054 +
32055 + /* if private header (shim), check that no other headers specified */
32056 + for (i = 0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
32057 + && (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE); i++)
32058 + {
32059 + if (IS_PRIVATE_HEADER(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr))
32060 + if (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[1].hdr != HEADER_TYPE_NONE)
32061 + {
32062 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("SHIM header may not be interchanged with other headers"));
32063 + XX_Free(p_ModifiedNetEnvParams);
32064 + return NULL;
32065 + }
32066 + }
32067 +
32068 + for (i = 0; i < p_NetEnvParams->numOfDistinctionUnits; i++)
32069 + {
32070 + if (IS_PRIVATE_HEADER(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr))
32071 + switch (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr)
32072 + {
32073 + case (HEADER_TYPE_USER_DEFINED_SHIM1):
32074 + if (shim1Selected)
32075 + {
32076 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("SHIM header cannot be selected with UDP_IPSEC_ESP"));
32077 + XX_Free(p_ModifiedNetEnvParams);
32078 + return NULL;
32079 + }
32080 + shim1Selected = TRUE;
32081 + p_FmPcd->netEnvs[netEnvCurrId].unitsVectors[i] = 0x00000001;
32082 + break;
32083 + case (HEADER_TYPE_USER_DEFINED_SHIM2):
32084 + p_FmPcd->netEnvs[netEnvCurrId].unitsVectors[i] = 0x00000002;
32085 + break;
32086 + default:
32087 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Requested SHIM not supported"));
32088 + }
32089 + else
32090 + {
32091 + p_FmPcd->netEnvs[netEnvCurrId].unitsVectors[i] = (uint32_t)(0x80000000 >> bitId++);
32092 +
32093 + if (IS_SPECIAL_HEADER(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr))
32094 + p_FmPcd->netEnvs[netEnvCurrId].macsecVector = p_FmPcd->netEnvs[netEnvCurrId].unitsVectors[i];
32095 + }
32096 + }
32097 +
32098 + /* define a set of hardware parser LCV's according to the defined netenv */
32099 +
32100 + /* set an array of LCV's for each header in the netEnv */
32101 + for (i = 0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
32102 + && (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE); i++)
32103 + {
32104 + /* private headers have no LCV in the hard parser */
32105 + if (!IS_PRIVATE_HEADER(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr))
32106 + {
32107 + for (k = 0; (k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS)
32108 + && (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr != HEADER_TYPE_NONE); k++)
32109 + {
32110 + hdrNum = GetPrsHdrNum(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr);
32111 + if ((hdrNum == ILLEGAL_HDR_NUM) || (hdrNum == NO_HDR_NUM))
32112 + {
32113 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, NO_MSG);
32114 + XX_Free(p_ModifiedNetEnvParams);
32115 + return NULL;
32116 + }
32117 + p_FmPcd->netEnvs[netEnvCurrId].lcvs[hdrNum] |= p_FmPcd->netEnvs[netEnvCurrId].unitsVectors[i];
32118 + }
32119 + }
32120 + }
32121 + XX_Free(p_ModifiedNetEnvParams);
32122 +
32123 + p_FmPcd->netEnvs[netEnvCurrId].h_Spinlock = XX_InitSpinlock();
32124 + if (!p_FmPcd->netEnvs[netEnvCurrId].h_Spinlock)
32125 + {
32126 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Pcd NetEnv spinlock"));
32127 + return NULL;
32128 + }
32129 + return &p_FmPcd->netEnvs[netEnvCurrId];
32130 +}
32131 +
32132 +t_Error FM_PCD_NetEnvCharacteristicsDelete(t_Handle h_NetEnv)
32133 +{
32134 + t_FmPcdNetEnv *p_NetEnv = (t_FmPcdNetEnv*)h_NetEnv;
32135 + t_FmPcd *p_FmPcd = p_NetEnv->h_FmPcd;
32136 + uint32_t intFlags;
32137 + uint8_t netEnvId = p_NetEnv->netEnvId;
32138 +
32139 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_STATE);
32140 + SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
32141 +
32142 + /* check that no port is bound to this netEnv */
32143 + if (p_FmPcd->netEnvs[netEnvId].owners)
32144 + {
32145 + RETURN_ERROR(MINOR, E_INVALID_STATE,
32146 + ("Trying to delete a netEnv that has ports/schemes/trees/clsPlanGrps bound to"));
32147 + }
32148 +
32149 + intFlags = FmPcdLock(p_FmPcd);
32150 +
32151 + p_FmPcd->netEnvs[netEnvId].used = FALSE;
32152 + p_FmPcd->netEnvs[netEnvId].clsPlanGrpId = ILLEGAL_CLS_PLAN;
32153 +
32154 + memset(p_FmPcd->netEnvs[netEnvId].units, 0, sizeof(t_FmPcdIntDistinctionUnit)*FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
32155 + memset(p_FmPcd->netEnvs[netEnvId].unitsVectors, 0, sizeof(uint32_t)*FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
32156 + memset(p_FmPcd->netEnvs[netEnvId].lcvs, 0, sizeof(uint32_t)*FM_PCD_PRS_NUM_OF_HDRS);
32157 +
32158 + if (p_FmPcd->netEnvs[netEnvId].h_Spinlock)
32159 + XX_FreeSpinlock(p_FmPcd->netEnvs[netEnvId].h_Spinlock);
32160 +
32161 + FmPcdUnlock(p_FmPcd, intFlags);
32162 + return E_OK;
32163 +}
32164 +
32165 +void FM_PCD_HcTxConf(t_Handle h_FmPcd, t_DpaaFD *p_Fd)
32166 +{
32167 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
32168 +
32169 + SANITY_CHECK_RETURN(h_FmPcd, E_INVALID_STATE);
32170 +
32171 + FmHcTxConf(p_FmPcd->h_Hc, p_Fd);
32172 +}
32173 +
32174 +t_Error FM_PCD_SetAdvancedOffloadSupport(t_Handle h_FmPcd)
32175 +{
32176 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
32177 + t_FmCtrlCodeRevisionInfo revInfo;
32178 + t_Error err;
32179 +
32180 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
32181 + SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
32182 + SANITY_CHECK_RETURN_ERROR(!p_FmPcd->enabled, E_INVALID_STATE);
32183 +
32184 + if ((err = FM_GetFmanCtrlCodeRevision(p_FmPcd->h_Fm, &revInfo)) != E_OK)
32185 + {
32186 + DBG(WARNING, ("FM in guest-mode without IPC, can't validate firmware revision."));
32187 + revInfo.packageRev = IP_OFFLOAD_PACKAGE_NUMBER;
32188 + }
32189 + if (!IS_OFFLOAD_PACKAGE(revInfo.packageRev))
32190 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Fman ctrl code package"));
32191 +
32192 + if (!p_FmPcd->h_Hc)
32193 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("HC must be initialized in this mode"));
32194 +
32195 + p_FmPcd->advancedOffloadSupport = TRUE;
32196 +
32197 + return E_OK;
32198 +}
32199 +
32200 +uint32_t FM_PCD_GetCounter(t_Handle h_FmPcd, e_FmPcdCounters counter)
32201 +{
32202 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
32203 + uint32_t outCounter = 0;
32204 + t_Error err;
32205 +
32206 + SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, 0);
32207 + SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE, 0);
32208 +
32209 + switch (counter)
32210 + {
32211 + case (e_FM_PCD_KG_COUNTERS_TOTAL):
32212 + if (!p_FmPcd->p_FmPcdKg)
32213 + {
32214 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("KeyGen is not activated"));
32215 + return 0;
32216 + }
32217 + if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
32218 + !p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs &&
32219 + !p_FmPcd->h_IpcSession)
32220 + {
32221 + REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
32222 + ("running in guest-mode without neither IPC nor mapped register!"));
32223 + return 0;
32224 + }
32225 + break;
32226 +
32227 + case (e_FM_PCD_PLCR_COUNTERS_YELLOW):
32228 + case (e_FM_PCD_PLCR_COUNTERS_RED):
32229 + case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED):
32230 + case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW):
32231 + case (e_FM_PCD_PLCR_COUNTERS_TOTAL):
32232 + case (e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH):
32233 + if (!p_FmPcd->p_FmPcdPlcr)
32234 + {
32235 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Policer is not activated"));
32236 + return 0;
32237 + }
32238 + if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
32239 + !p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs &&
32240 + !p_FmPcd->h_IpcSession)
32241 + {
32242 + REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
32243 + ("running in \"guest-mode\" without neither IPC nor mapped register!"));
32244 + return 0;
32245 + }
32246 +
32247 + /* check that counters are enabled */
32248 + if (p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs &&
32249 + !(GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_gcr) & FM_PCD_PLCR_GCR_STEN))
32250 + {
32251 + REPORT_ERROR(MINOR, E_INVALID_STATE, ("Requested counter was not enabled"));
32252 + return 0;
32253 + }
32254 + ASSERT_COND(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs ||
32255 + ((p_FmPcd->guestId != NCSW_MASTER_ID) && p_FmPcd->h_IpcSession));
32256 + break;
32257 +
32258 + case (e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH):
32259 + case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED):
32260 + case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED):
32261 + case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED):
32262 + case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED):
32263 + case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR):
32264 + case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR):
32265 + case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR):
32266 + case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR):
32267 + case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES):
32268 + case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES):
32269 + case (e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES):
32270 + case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES):
32271 + case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES):
32272 + case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES):
32273 + case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES):
32274 + case (e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES):
32275 + if (!p_FmPcd->p_FmPcdPrs)
32276 + {
32277 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Parser is not activated"));
32278 + return 0;
32279 + }
32280 + if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
32281 + !p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs &&
32282 + !p_FmPcd->h_IpcSession)
32283 + {
32284 + REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
32285 + ("running in guest-mode without neither IPC nor mapped register!"));
32286 + return 0;
32287 + }
32288 + break;
32289 + default:
32290 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Unsupported type of counter"));
32291 + return 0;
32292 + }
32293 +
32294 + if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
32295 + p_FmPcd->h_IpcSession)
32296 + {
32297 + t_FmPcdIpcMsg msg;
32298 + t_FmPcdIpcReply reply;
32299 + uint32_t replyLength;
32300 +
32301 + memset(&msg, 0, sizeof(msg));
32302 + memset(&reply, 0, sizeof(reply));
32303 + msg.msgId = FM_PCD_GET_COUNTER;
32304 + memcpy(msg.msgBody, (uint8_t *)&counter, sizeof(uint32_t));
32305 + replyLength = sizeof(uint32_t) + sizeof(uint32_t);
32306 + if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
32307 + (uint8_t*)&msg,
32308 + sizeof(msg.msgId) +sizeof(uint32_t),
32309 + (uint8_t*)&reply,
32310 + &replyLength,
32311 + NULL,
32312 + NULL)) != E_OK)
32313 + RETURN_ERROR(MAJOR, err, NO_MSG);
32314 + if (replyLength != sizeof(uint32_t) + sizeof(uint32_t))
32315 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
32316 +
32317 + memcpy((uint8_t*)&outCounter, reply.replyBody, sizeof(uint32_t));
32318 + return outCounter;
32319 + }
32320 +
32321 + switch (counter)
32322 + {
32323 + /* Parser statistics */
32324 + case (e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH):
32325 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_pds);
32326 + case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED):
32327 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l2rrs);
32328 + case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED):
32329 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l3rrs);
32330 + case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED):
32331 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l4rrs);
32332 + case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED):
32333 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_srrs);
32334 + case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR):
32335 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l2rres);
32336 + case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR):
32337 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l3rres);
32338 + case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR):
32339 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l4rres);
32340 + case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR):
32341 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_srres);
32342 + case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES):
32343 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_spcs);
32344 + case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES):
32345 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_spscs);
32346 + case (e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES):
32347 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_hxscs);
32348 + case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES):
32349 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mrcs);
32350 + case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES):
32351 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mrscs);
32352 + case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES):
32353 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mwcs);
32354 + case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES):
32355 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mwscs);
32356 + case (e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES):
32357 + return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_fcscs);
32358 + case (e_FM_PCD_KG_COUNTERS_TOTAL):
32359 + return GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_tpc);
32360 +
32361 + /* Policer statistics */
32362 + case (e_FM_PCD_PLCR_COUNTERS_YELLOW):
32363 + return GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ypcnt);
32364 + case (e_FM_PCD_PLCR_COUNTERS_RED):
32365 + return GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_rpcnt);
32366 + case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED):
32367 + return GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_rrpcnt);
32368 + case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW):
32369 + return GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_rypcnt);
32370 + case (e_FM_PCD_PLCR_COUNTERS_TOTAL):
32371 + return GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_tpcnt);
32372 + case (e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH):
32373 + return GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_flmcnt);
32374 + }
32375 + return 0;
32376 +}
32377 +
32378 +t_Error FM_PCD_SetException(t_Handle h_FmPcd, e_FmPcdExceptions exception, bool enable)
32379 +{
32380 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
32381 + uint32_t bitMask = 0, tmpReg;
32382 +
32383 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
32384 + SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
32385 +
32386 + if (p_FmPcd->guestId != NCSW_MASTER_ID)
32387 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_SetException - guest mode!"));
32388 +
32389 + GET_FM_PCD_EXCEPTION_FLAG(bitMask, exception);
32390 +
32391 + if (bitMask)
32392 + {
32393 + if (enable)
32394 + p_FmPcd->exceptions |= bitMask;
32395 + else
32396 + p_FmPcd->exceptions &= ~bitMask;
32397 +
32398 + switch (exception)
32399 + {
32400 + case (e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC):
32401 + case (e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW):
32402 + if (!p_FmPcd->p_FmPcdKg)
32403 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this interrupt - keygen is not working"));
32404 + break;
32405 + case (e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC):
32406 + case (e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR):
32407 + case (e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE):
32408 + case (e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE):
32409 + if (!p_FmPcd->p_FmPcdPlcr)
32410 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this interrupt - policer is not working"));
32411 + break;
32412 + case (e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC):
32413 + case (e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC):
32414 + if (!p_FmPcd->p_FmPcdPrs)
32415 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this interrupt - parser is not working"));
32416 + break;
32417 + }
32418 +
32419 + switch (exception)
32420 + {
32421 + case (e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC):
32422 + tmpReg = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_eeer);
32423 + if (enable)
32424 + tmpReg |= FM_EX_KG_DOUBLE_ECC;
32425 + else
32426 + tmpReg &= ~FM_EX_KG_DOUBLE_ECC;
32427 + WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_eeer, tmpReg);
32428 + break;
32429 + case (e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW):
32430 + tmpReg = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_eeer);
32431 + if (enable)
32432 + tmpReg |= FM_EX_KG_KEYSIZE_OVERFLOW;
32433 + else
32434 + tmpReg &= ~FM_EX_KG_KEYSIZE_OVERFLOW;
32435 + WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_eeer, tmpReg);
32436 + break;
32437 + case (e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC):
32438 + tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_perer);
32439 + if (enable)
32440 + tmpReg |= FM_PCD_PRS_DOUBLE_ECC;
32441 + else
32442 + tmpReg &= ~FM_PCD_PRS_DOUBLE_ECC;
32443 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_perer, tmpReg);
32444 + break;
32445 + case (e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC):
32446 + tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_pever);
32447 + if (enable)
32448 + tmpReg |= FM_PCD_PRS_SINGLE_ECC;
32449 + else
32450 + tmpReg &= ~FM_PCD_PRS_SINGLE_ECC;
32451 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_pever, tmpReg);
32452 + break;
32453 + case (e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC):
32454 + tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eier);
32455 + if (enable)
32456 + tmpReg |= FM_PCD_PLCR_DOUBLE_ECC;
32457 + else
32458 + tmpReg &= ~FM_PCD_PLCR_DOUBLE_ECC;
32459 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eier, tmpReg);
32460 + break;
32461 + case (e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR):
32462 + tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eier);
32463 + if (enable)
32464 + tmpReg |= FM_PCD_PLCR_INIT_ENTRY_ERROR;
32465 + else
32466 + tmpReg &= ~FM_PCD_PLCR_INIT_ENTRY_ERROR;
32467 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eier, tmpReg);
32468 + break;
32469 + case (e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE):
32470 + tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ier);
32471 + if (enable)
32472 + tmpReg |= FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE;
32473 + else
32474 + tmpReg &= ~FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE;
32475 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ier, tmpReg);
32476 + break;
32477 + case (e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE):
32478 + tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ier);
32479 + if (enable)
32480 + tmpReg |= FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE;
32481 + else
32482 + tmpReg &= ~FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE;
32483 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ier, tmpReg);
32484 + break;
32485 + }
32486 + /* for ECC exceptions driver automatically enables ECC mechanism, if disabled.
32487 + Driver may disable them automatically, depending on driver's status */
32488 + if (enable && ((exception == e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC) |
32489 + (exception == e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC) |
32490 + (exception == e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC) |
32491 + (exception == e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC)))
32492 + FmEnableRamsEcc(p_FmPcd->h_Fm);
32493 + if (!enable && ((exception == e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC) |
32494 + (exception == e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC) |
32495 + (exception == e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC) |
32496 + (exception == e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC)))
32497 + FmDisableRamsEcc(p_FmPcd->h_Fm);
32498 + }
32499 +
32500 + return E_OK;
32501 +}
32502 +
32503 +t_Error FM_PCD_ForceIntr (t_Handle h_FmPcd, e_FmPcdExceptions exception)
32504 +{
32505 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
32506 +
32507 + SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
32508 + SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
32509 +
32510 + if (p_FmPcd->guestId != NCSW_MASTER_ID)
32511 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_ForceIntr - guest mode!"));
32512 +
32513 + switch (exception)
32514 + {
32515 + case (e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC):
32516 + case (e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW):
32517 + if (!p_FmPcd->p_FmPcdKg)
32518 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this interrupt - keygen is not working"));
32519 + break;
32520 + case (e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC):
32521 + case (e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR):
32522 + case (e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE):
32523 + case (e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE):
32524 + if (!p_FmPcd->p_FmPcdPlcr)
32525 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this interrupt - policer is not working"));
32526 + break;
32527 + case (e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC):
32528 + case (e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC):
32529 + if (!p_FmPcd->p_FmPcdPrs)
32530 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this interrupt -parsrer is not working"));
32531 + break;
32532 + default:
32533 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid interrupt requested"));
32534 + }
32535 + switch (exception)
32536 + {
32537 + case e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC:
32538 + if (!(p_FmPcd->exceptions & FM_PCD_EX_PRS_DOUBLE_ECC))
32539 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
32540 + break;
32541 + case e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC:
32542 + if (!(p_FmPcd->exceptions & FM_PCD_EX_PRS_SINGLE_ECC))
32543 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
32544 + break;
32545 + case e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC:
32546 + if (!(p_FmPcd->exceptions & FM_EX_KG_DOUBLE_ECC))
32547 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
32548 + WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_feer, FM_EX_KG_DOUBLE_ECC);
32549 + break;
32550 + case e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW:
32551 + if (!(p_FmPcd->exceptions & FM_EX_KG_KEYSIZE_OVERFLOW))
32552 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
32553 + WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_feer, FM_EX_KG_KEYSIZE_OVERFLOW);
32554 + break;
32555 + case e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC:
32556 + if (!(p_FmPcd->exceptions & FM_PCD_EX_PLCR_DOUBLE_ECC))
32557 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
32558 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eifr, FM_PCD_PLCR_DOUBLE_ECC);
32559 + break;
32560 + case e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR:
32561 + if (!(p_FmPcd->exceptions & FM_PCD_EX_PLCR_INIT_ENTRY_ERROR))
32562 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
32563 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eifr, FM_PCD_PLCR_INIT_ENTRY_ERROR);
32564 + break;
32565 + case e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE:
32566 + if (!(p_FmPcd->exceptions & FM_PCD_EX_PLCR_PRAM_SELF_INIT_COMPLETE))
32567 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
32568 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ifr, FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE);
32569 + break;
32570 + case e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE:
32571 + if (!(p_FmPcd->exceptions & FM_PCD_EX_PLCR_ATOMIC_ACTION_COMPLETE))
32572 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
32573 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ifr, FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE);
32574 + break;
32575 + }
32576 +
32577 + return E_OK;
32578 +}
32579 +
32580 +
32581 +t_Error FM_PCD_ModifyCounter(t_Handle h_FmPcd, e_FmPcdCounters counter, uint32_t value)
32582 +{
32583 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
32584 +
32585 + SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
32586 + SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
32587 +
32588 + if (p_FmPcd->guestId != NCSW_MASTER_ID)
32589 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_ModifyCounter - guest mode!"));
32590 +
32591 + switch (counter)
32592 + {
32593 + case (e_FM_PCD_KG_COUNTERS_TOTAL):
32594 + if (!p_FmPcd->p_FmPcdKg)
32595 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Invalid counters - KeyGen is not working"));
32596 + break;
32597 + case (e_FM_PCD_PLCR_COUNTERS_YELLOW):
32598 + case (e_FM_PCD_PLCR_COUNTERS_RED):
32599 + case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED):
32600 + case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW):
32601 + case (e_FM_PCD_PLCR_COUNTERS_TOTAL):
32602 + case (e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH):
32603 + if (!p_FmPcd->p_FmPcdPlcr)
32604 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Invalid counters - Policer is not working"));
32605 + if (!(GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_gcr) & FM_PCD_PLCR_GCR_STEN))
32606 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter was not enabled"));
32607 + break;
32608 + case (e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH):
32609 + case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED):
32610 + case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED):
32611 + case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED):
32612 + case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED):
32613 + case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR):
32614 + case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR):
32615 + case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR):
32616 + case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR):
32617 + case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES):
32618 + case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES):
32619 + case (e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES):
32620 + case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES):
32621 + case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES):
32622 + case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES):
32623 + case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES):
32624 + case (e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES):
32625 + if (!p_FmPcd->p_FmPcdPrs)
32626 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Unsupported type of counter"));
32627 + break;
32628 + default:
32629 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Unsupported type of counter"));
32630 + }
32631 + switch (counter)
32632 + {
32633 + case (e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH):
32634 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_pds, value);
32635 + break;
32636 + case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED):
32637 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l2rrs, value);
32638 + break;
32639 + case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED):
32640 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l3rrs, value);
32641 + break;
32642 + case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED):
32643 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l4rrs, value);
32644 + break;
32645 + case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED):
32646 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_srrs, value);
32647 + break;
32648 + case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR):
32649 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l2rres, value);
32650 + break;
32651 + case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR):
32652 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l3rres, value);
32653 + break;
32654 + case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR):
32655 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l4rres, value);
32656 + break;
32657 + case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR):
32658 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_srres, value);
32659 + break;
32660 + case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES):
32661 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_spcs, value);
32662 + break;
32663 + case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES):
32664 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_spscs, value);
32665 + break;
32666 + case (e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES):
32667 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_hxscs, value);
32668 + break;
32669 + case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES):
32670 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mrcs, value);
32671 + break;
32672 + case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES):
32673 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mrscs, value);
32674 + break;
32675 + case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES):
32676 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mwcs, value);
32677 + break;
32678 + case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES):
32679 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mwscs, value);
32680 + break;
32681 + case (e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES):
32682 + WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_fcscs, value);
32683 + break;
32684 + case (e_FM_PCD_KG_COUNTERS_TOTAL):
32685 + WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_tpc,value);
32686 + break;
32687 +
32688 + /*Policer counters*/
32689 + case (e_FM_PCD_PLCR_COUNTERS_YELLOW):
32690 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ypcnt, value);
32691 + break;
32692 + case (e_FM_PCD_PLCR_COUNTERS_RED):
32693 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_rpcnt, value);
32694 + break;
32695 + case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED):
32696 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_rrpcnt, value);
32697 + break;
32698 + case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW):
32699 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_rypcnt, value);
32700 + break;
32701 + case (e_FM_PCD_PLCR_COUNTERS_TOTAL):
32702 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_tpcnt, value);
32703 + break;
32704 + case (e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH):
32705 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_flmcnt, value);
32706 + break;
32707 + }
32708 +
32709 + return E_OK;
32710 +}
32711 +
32712 +t_Handle FM_PCD_GetHcPort(t_Handle h_FmPcd)
32713 +{
32714 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
32715 + return FmHcGetPort(p_FmPcd->h_Hc);
32716 +}
32717 +
32718 --- /dev/null
32719 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_pcd.h
32720 @@ -0,0 +1,543 @@
32721 +/*
32722 + * Copyright 2008-2012 Freescale Semiconductor Inc.
32723 + *
32724 + * Redistribution and use in source and binary forms, with or without
32725 + * modification, are permitted provided that the following conditions are met:
32726 + * * Redistributions of source code must retain the above copyright
32727 + * notice, this list of conditions and the following disclaimer.
32728 + * * Redistributions in binary form must reproduce the above copyright
32729 + * notice, this list of conditions and the following disclaimer in the
32730 + * documentation and/or other materials provided with the distribution.
32731 + * * Neither the name of Freescale Semiconductor nor the
32732 + * names of its contributors may be used to endorse or promote products
32733 + * derived from this software without specific prior written permission.
32734 + *
32735 + *
32736 + * ALTERNATIVELY, this software may be distributed under the terms of the
32737 + * GNU General Public License ("GPL") as published by the Free Software
32738 + * Foundation, either version 2 of that License or (at your option) any
32739 + * later version.
32740 + *
32741 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
32742 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32743 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32744 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
32745 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32746 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32747 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32748 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32749 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32750 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32751 + */
32752 +
32753 +
32754 +/******************************************************************************
32755 + @File fm_pcd.h
32756 +
32757 + @Description FM PCD ...
32758 +*//***************************************************************************/
32759 +#ifndef __FM_PCD_H
32760 +#define __FM_PCD_H
32761 +
32762 +#include "std_ext.h"
32763 +#include "error_ext.h"
32764 +#include "list_ext.h"
32765 +#include "fm_pcd_ext.h"
32766 +#include "fm_common.h"
32767 +#include "fsl_fman_prs.h"
32768 +#include "fsl_fman_kg.h"
32769 +
32770 +#define __ERR_MODULE__ MODULE_FM_PCD
32771 +
32772 +
32773 +/****************************/
32774 +/* Defaults */
32775 +/****************************/
32776 +#define DEFAULT_plcrAutoRefresh FALSE
32777 +#define DEFAULT_fmPcdKgErrorExceptions (FM_EX_KG_DOUBLE_ECC | FM_EX_KG_KEYSIZE_OVERFLOW)
32778 +#define DEFAULT_fmPcdPlcrErrorExceptions (FM_PCD_EX_PLCR_DOUBLE_ECC | FM_PCD_EX_PLCR_INIT_ENTRY_ERROR)
32779 +#define DEFAULT_fmPcdPlcrExceptions 0
32780 +#define DEFAULT_fmPcdPrsErrorExceptions (FM_PCD_EX_PRS_DOUBLE_ECC)
32781 +
32782 +#define DEFAULT_fmPcdPrsExceptions FM_PCD_EX_PRS_SINGLE_ECC
32783 +#define DEFAULT_numOfUsedProfilesPerWindow 16
32784 +#define DEFAULT_numOfSharedPlcrProfiles 4
32785 +
32786 +/****************************/
32787 +/* Network defines */
32788 +/****************************/
32789 +#define UDP_HEADER_SIZE 8
32790 +
32791 +#define ESP_SPI_OFFSET 0
32792 +#define ESP_SPI_SIZE 4
32793 +#define ESP_SEQ_NUM_OFFSET ESP_SPI_SIZE
32794 +#define ESP_SEQ_NUM_SIZE 4
32795 +
32796 +/****************************/
32797 +/* General defines */
32798 +/****************************/
32799 +#define ILLEGAL_CLS_PLAN 0xff
32800 +#define ILLEGAL_NETENV 0xff
32801 +
32802 +#define FM_PCD_MAX_NUM_OF_ALIAS_HDRS 3
32803 +
32804 +/****************************/
32805 +/* Error defines */
32806 +/****************************/
32807 +
32808 +#define FM_PCD_EX_PLCR_DOUBLE_ECC 0x20000000
32809 +#define FM_PCD_EX_PLCR_INIT_ENTRY_ERROR 0x10000000
32810 +#define FM_PCD_EX_PLCR_PRAM_SELF_INIT_COMPLETE 0x08000000
32811 +#define FM_PCD_EX_PLCR_ATOMIC_ACTION_COMPLETE 0x04000000
32812 +
32813 +#define GET_FM_PCD_EXCEPTION_FLAG(bitMask, exception) \
32814 +switch (exception){ \
32815 + case e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC: \
32816 + bitMask = FM_EX_KG_DOUBLE_ECC; break; \
32817 + case e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC: \
32818 + bitMask = FM_PCD_EX_PLCR_DOUBLE_ECC; break; \
32819 + case e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW: \
32820 + bitMask = FM_EX_KG_KEYSIZE_OVERFLOW; break; \
32821 + case e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR: \
32822 + bitMask = FM_PCD_EX_PLCR_INIT_ENTRY_ERROR; break; \
32823 + case e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE: \
32824 + bitMask = FM_PCD_EX_PLCR_PRAM_SELF_INIT_COMPLETE; break; \
32825 + case e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE: \
32826 + bitMask = FM_PCD_EX_PLCR_ATOMIC_ACTION_COMPLETE; break; \
32827 + case e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC: \
32828 + bitMask = FM_PCD_EX_PRS_DOUBLE_ECC; break; \
32829 + case e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC: \
32830 + bitMask = FM_PCD_EX_PRS_SINGLE_ECC; break; \
32831 + default: bitMask = 0;break;}
32832 +
32833 +/***********************************************************************/
32834 +/* Policer defines */
32835 +/***********************************************************************/
32836 +#define FM_PCD_PLCR_GCR_STEN 0x40000000
32837 +#define FM_PCD_PLCR_DOUBLE_ECC 0x80000000
32838 +#define FM_PCD_PLCR_INIT_ENTRY_ERROR 0x40000000
32839 +#define FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE 0x80000000
32840 +#define FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE 0x40000000
32841 +
32842 +/***********************************************************************/
32843 +/* Memory map */
32844 +/***********************************************************************/
32845 +#if defined(__MWERKS__) && !defined(__GNUC__)
32846 +#pragma pack(push,1)
32847 +#endif /* defined(__MWERKS__) && ... */
32848 +
32849 +
32850 +typedef struct {
32851 +/* General Configuration and Status Registers */
32852 + volatile uint32_t fmpl_gcr; /* 0x000 FMPL_GCR - FM Policer General Configuration */
32853 + volatile uint32_t fmpl_gsr; /* 0x004 FMPL_GSR - FM Policer Global Status Register */
32854 + volatile uint32_t fmpl_evr; /* 0x008 FMPL_EVR - FM Policer Event Register */
32855 + volatile uint32_t fmpl_ier; /* 0x00C FMPL_IER - FM Policer Interrupt Enable Register */
32856 + volatile uint32_t fmpl_ifr; /* 0x010 FMPL_IFR - FM Policer Interrupt Force Register */
32857 + volatile uint32_t fmpl_eevr; /* 0x014 FMPL_EEVR - FM Policer Error Event Register */
32858 + volatile uint32_t fmpl_eier; /* 0x018 FMPL_EIER - FM Policer Error Interrupt Enable Register */
32859 + volatile uint32_t fmpl_eifr; /* 0x01C FMPL_EIFR - FM Policer Error Interrupt Force Register */
32860 +/* Global Statistic Counters */
32861 + volatile uint32_t fmpl_rpcnt; /* 0x020 FMPL_RPC - FM Policer RED Packets Counter */
32862 + volatile uint32_t fmpl_ypcnt; /* 0x024 FMPL_YPC - FM Policer YELLOW Packets Counter */
32863 + volatile uint32_t fmpl_rrpcnt; /* 0x028 FMPL_RRPC - FM Policer Recolored RED Packet Counter */
32864 + volatile uint32_t fmpl_rypcnt; /* 0x02C FMPL_RYPC - FM Policer Recolored YELLOW Packet Counter */
32865 + volatile uint32_t fmpl_tpcnt; /* 0x030 FMPL_TPC - FM Policer Total Packet Counter */
32866 + volatile uint32_t fmpl_flmcnt; /* 0x034 FMPL_FLMC - FM Policer Frame Length Mismatch Counter */
32867 + volatile uint32_t fmpl_res0[21]; /* 0x038 - 0x08B Reserved */
32868 +/* Profile RAM Access Registers */
32869 + volatile uint32_t fmpl_par; /* 0x08C FMPL_PAR - FM Policer Profile Action Register*/
32870 + t_FmPcdPlcrProfileRegs profileRegs;
32871 +/* Error Capture Registers */
32872 + volatile uint32_t fmpl_serc; /* 0x100 FMPL_SERC - FM Policer Soft Error Capture */
32873 + volatile uint32_t fmpl_upcr; /* 0x104 FMPL_UPCR - FM Policer Uninitialized Profile Capture Register */
32874 + volatile uint32_t fmpl_res2; /* 0x108 Reserved */
32875 +/* Debug Registers */
32876 + volatile uint32_t fmpl_res3[61]; /* 0x10C-0x200 Reserved Debug*/
32877 +/* Profile Selection Mapping Registers Per Port-ID (n=1-11, 16) */
32878 + volatile uint32_t fmpl_dpmr; /* 0x200 FMPL_DPMR - FM Policer Default Mapping Register */
32879 + volatile uint32_t fmpl_pmr[63]; /*+default 0x204-0x2FF FMPL_PMR1 - FMPL_PMR63, - FM Policer Profile Mapping Registers.
32880 + (for port-ID 1-11, only for supported Port-ID registers) */
32881 +} t_FmPcdPlcrRegs;
32882 +
32883 +#if defined(__MWERKS__) && !defined(__GNUC__)
32884 +#pragma pack(pop)
32885 +#endif /* defined(__MWERKS__) && ... */
32886 +
32887 +
32888 +/***********************************************************************/
32889 +/* Driver's internal structures */
32890 +/***********************************************************************/
32891 +
32892 +typedef struct {
32893 + bool known;
32894 + uint8_t id;
32895 +} t_FmPcdKgSchemesExtractsEntry;
32896 +
32897 +typedef struct {
32898 + t_FmPcdKgSchemesExtractsEntry extractsArray[FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY];
32899 +} t_FmPcdKgSchemesExtracts;
32900 +
32901 +typedef struct {
32902 + t_Handle h_Manip;
32903 + bool keepRes;
32904 + e_FmPcdEngine nextEngine;
32905 + uint8_t parseCode;
32906 +} t_FmPcdInfoForManip;
32907 +
32908 +/**************************************************************************//**
32909 + @Description A structure of parameters to communicate
32910 + between the port and PCD regarding the KG scheme.
32911 +*//***************************************************************************/
32912 +typedef struct {
32913 + uint8_t netEnvId; /* in */
32914 + uint8_t numOfDistinctionUnits; /* in */
32915 + uint8_t unitIds[FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS]; /* in */
32916 + uint32_t vector; /* out */
32917 +} t_NetEnvParams;
32918 +
32919 +typedef struct {
32920 + bool allocated;
32921 + uint8_t ownerId; /* guestId for KG in multi-partition only.
32922 + portId for PLCR in any environment */
32923 +} t_FmPcdAllocMng;
32924 +
32925 +typedef struct {
32926 + volatile bool lock;
32927 + bool used;
32928 + uint8_t owners;
32929 + uint8_t netEnvId;
32930 + uint8_t guestId;
32931 + uint8_t baseEntry;
32932 + uint16_t sizeOfGrp;
32933 + protocolOpt_t optArray[FM_PCD_MAX_NUM_OF_OPTIONS(FM_PCD_MAX_NUM_OF_CLS_PLANS)];
32934 +} t_FmPcdKgClsPlanGrp;
32935 +
32936 +typedef struct {
32937 + t_Handle h_FmPcd;
32938 + uint8_t schemeId;
32939 + t_FmPcdLock *p_Lock;
32940 + bool valid;
32941 + uint8_t netEnvId;
32942 + uint8_t owners;
32943 + uint32_t matchVector;
32944 + uint32_t ccUnits;
32945 + bool nextRelativePlcrProfile;
32946 + uint16_t relativeProfileId;
32947 + uint16_t numOfProfiles;
32948 + t_FmPcdKgKeyOrder orderedArray;
32949 + e_FmPcdEngine nextEngine;
32950 + e_FmPcdDoneAction doneAction;
32951 + bool requiredActionFlag;
32952 + uint32_t requiredAction;
32953 + bool extractedOrs;
32954 + uint8_t bitOffsetInPlcrProfile;
32955 + bool directPlcr;
32956 +#if (DPAA_VERSION >= 11)
32957 + bool vspe;
32958 +#endif
32959 +} t_FmPcdKgScheme;
32960 +
32961 +typedef union {
32962 + struct fman_kg_scheme_regs schemeRegs;
32963 + struct fman_kg_pe_regs portRegs;
32964 + struct fman_kg_cp_regs clsPlanRegs;
32965 +} u_FmPcdKgIndirectAccessRegs;
32966 +
32967 +typedef struct {
32968 + struct fman_kg_regs *p_FmPcdKgRegs;
32969 + uint32_t schemeExceptionsBitMask;
32970 + uint8_t numOfSchemes;
32971 + t_Handle h_HwSpinlock;
32972 + uint8_t schemesIds[FM_PCD_KG_NUM_OF_SCHEMES];
32973 + t_FmPcdKgScheme schemes[FM_PCD_KG_NUM_OF_SCHEMES];
32974 + t_FmPcdKgClsPlanGrp clsPlanGrps[FM_MAX_NUM_OF_PORTS];
32975 + uint8_t emptyClsPlanGrpId;
32976 + t_FmPcdAllocMng schemesMng[FM_PCD_KG_NUM_OF_SCHEMES]; /* only for MASTER ! */
32977 + t_FmPcdAllocMng clsPlanBlocksMng[FM_PCD_MAX_NUM_OF_CLS_PLANS/CLS_PLAN_NUM_PER_GRP];
32978 + u_FmPcdKgIndirectAccessRegs *p_IndirectAccessRegs;
32979 +} t_FmPcdKg;
32980 +
32981 +typedef struct {
32982 + uint16_t profilesBase;
32983 + uint16_t numOfProfiles;
32984 + t_Handle h_FmPort;
32985 +} t_FmPcdPlcrMapParam;
32986 +
32987 +typedef struct {
32988 + uint16_t absoluteProfileId;
32989 + t_Handle h_FmPcd;
32990 + bool valid;
32991 + t_FmPcdLock *p_Lock;
32992 + t_FmPcdAllocMng profilesMng;
32993 + bool requiredActionFlag;
32994 + uint32_t requiredAction;
32995 + e_FmPcdEngine nextEngineOnGreen; /**< Green next engine type */
32996 + u_FmPcdPlcrNextEngineParams paramsOnGreen; /**< Green next engine params */
32997 +
32998 + e_FmPcdEngine nextEngineOnYellow; /**< Yellow next engine type */
32999 + u_FmPcdPlcrNextEngineParams paramsOnYellow; /**< Yellow next engine params */
33000 +
33001 + e_FmPcdEngine nextEngineOnRed; /**< Red next engine type */
33002 + u_FmPcdPlcrNextEngineParams paramsOnRed; /**< Red next engine params */
33003 +} t_FmPcdPlcrProfile;
33004 +
33005 +typedef struct {
33006 + t_FmPcdPlcrRegs *p_FmPcdPlcrRegs;
33007 + uint16_t partPlcrProfilesBase;
33008 + uint16_t partNumOfPlcrProfiles;
33009 + t_FmPcdPlcrProfile profiles[FM_PCD_PLCR_NUM_ENTRIES];
33010 + uint16_t numOfSharedProfiles;
33011 + uint16_t sharedProfilesIds[FM_PCD_PLCR_NUM_ENTRIES];
33012 + t_FmPcdPlcrMapParam portsMapping[FM_MAX_NUM_OF_PORTS];
33013 + t_Handle h_HwSpinlock;
33014 + t_Handle h_SwSpinlock;
33015 +} t_FmPcdPlcr;
33016 +
33017 +typedef struct {
33018 + uint32_t *p_SwPrsCode;
33019 + uint32_t *p_CurrSwPrs;
33020 + uint8_t currLabel;
33021 + struct fman_prs_regs *p_FmPcdPrsRegs;
33022 + t_FmPcdPrsLabelParams labelsTable[FM_PCD_PRS_NUM_OF_LABELS];
33023 + uint32_t fmPcdPrsPortIdStatistics;
33024 +} t_FmPcdPrs;
33025 +
33026 +typedef struct {
33027 + struct {
33028 + e_NetHeaderType hdr;
33029 + protocolOpt_t opt; /* only one option !! */
33030 + } hdrs[FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS];
33031 +} t_FmPcdIntDistinctionUnit;
33032 +
33033 +typedef struct {
33034 + e_NetHeaderType hdr;
33035 + protocolOpt_t opt; /* only one option !! */
33036 + e_NetHeaderType aliasHdr;
33037 +} t_FmPcdNetEnvAliases;
33038 +
33039 +typedef struct {
33040 + uint8_t netEnvId;
33041 + t_Handle h_FmPcd;
33042 + t_Handle h_Spinlock;
33043 + bool used;
33044 + uint8_t owners;
33045 + uint8_t clsPlanGrpId;
33046 + t_FmPcdIntDistinctionUnit units[FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS];
33047 + uint32_t unitsVectors[FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS];
33048 + uint32_t lcvs[FM_PCD_PRS_NUM_OF_HDRS];
33049 + uint32_t macsecVector;
33050 + t_FmPcdNetEnvAliases aliasHdrs[FM_PCD_MAX_NUM_OF_ALIAS_HDRS];
33051 +} t_FmPcdNetEnv;
33052 +
33053 +typedef struct {
33054 + struct fman_prs_cfg dfltCfg;
33055 + bool plcrAutoRefresh;
33056 + uint16_t prsMaxParseCycleLimit;
33057 +} t_FmPcdDriverParam;
33058 +
33059 +typedef struct {
33060 + t_Handle h_Fm;
33061 + t_Handle h_FmMuram;
33062 + t_FmRevisionInfo fmRevInfo;
33063 +
33064 + uint64_t physicalMuramBase;
33065 +
33066 + t_Handle h_Spinlock;
33067 + t_List freeLocksLst;
33068 + t_List acquiredLocksLst;
33069 +
33070 + t_Handle h_IpcSession; /* relevant for guest only */
33071 + bool enabled;
33072 + uint8_t guestId; /**< Guest Partition Id */
33073 + uint8_t numOfEnabledGuestPartitionsPcds;
33074 + char fmPcdModuleName[MODULE_NAME_SIZE];
33075 + char fmPcdIpcHandlerModuleName[MODULE_NAME_SIZE]; /* relevant for guest only - this is the master's name */
33076 + t_FmPcdNetEnv netEnvs[FM_MAX_NUM_OF_PORTS];
33077 + t_FmPcdKg *p_FmPcdKg;
33078 + t_FmPcdPlcr *p_FmPcdPlcr;
33079 + t_FmPcdPrs *p_FmPcdPrs;
33080 +
33081 + void *p_CcShadow; /**< CC MURAM shadow */
33082 + uint32_t ccShadowSize;
33083 + uint32_t ccShadowAlign;
33084 + volatile bool shadowLock;
33085 + t_Handle h_ShadowSpinlock;
33086 +
33087 + t_Handle h_Hc;
33088 +
33089 + uint32_t exceptions;
33090 + t_FmPcdExceptionCallback *f_Exception;
33091 + t_FmPcdIdExceptionCallback *f_FmPcdIndexedException;
33092 + t_Handle h_App;
33093 + uintptr_t ipv6FrameIdAddr;
33094 + uintptr_t capwapFrameIdAddr;
33095 + bool advancedOffloadSupport;
33096 +
33097 + t_FmPcdDriverParam *p_FmPcdDriverParam;
33098 +} t_FmPcd;
33099 +
33100 +#if (DPAA_VERSION >= 11)
33101 +typedef uint8_t t_FmPcdFrmReplicUpdateType;
33102 +#define FRM_REPLIC_UPDATE_COUNTER 0x01
33103 +#define FRM_REPLIC_UPDATE_INFO 0x02
33104 +#endif /* (DPAA_VERSION >= 11) */
33105 +/***********************************************************************/
33106 +/* PCD internal routines */
33107 +/***********************************************************************/
33108 +
33109 +t_Error PcdGetVectorForOpt(t_FmPcd *p_FmPcd, uint8_t netEnvId, protocolOpt_t opt, uint32_t *p_Vector);
33110 +t_Error PcdGetUnitsVector(t_FmPcd *p_FmPcd, t_NetEnvParams *p_Params);
33111 +bool PcdNetEnvIsUnitWithoutOpts(t_FmPcd *p_FmPcd, uint8_t netEnvId, uint32_t unitVector);
33112 +t_Error PcdGetClsPlanGrpParams(t_FmPcd *p_FmPcd, t_FmPcdKgInterModuleClsPlanGrpParams *p_GrpParams);
33113 +void FmPcdSetClsPlanGrpId(t_FmPcd *p_FmPcd, uint8_t netEnvId, uint8_t clsPlanGrpId);
33114 +e_NetHeaderType FmPcdGetAliasHdr(t_FmPcd *p_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr);
33115 +uint8_t FmPcdNetEnvGetUnitIdForSingleHdr(t_FmPcd *p_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr);
33116 +uint8_t FmPcdNetEnvGetUnitId(t_FmPcd *p_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr, bool interchangeable, protocolOpt_t opt);
33117 +
33118 +t_Error FmPcdManipBuildIpReassmScheme(t_FmPcd *p_FmPcd, t_Handle h_NetEnv, t_Handle h_CcTree, t_Handle h_Manip, bool isIpv4, uint8_t groupId);
33119 +t_Error FmPcdManipDeleteIpReassmSchemes(t_Handle h_Manip);
33120 +t_Error FmPcdManipBuildCapwapReassmScheme(t_FmPcd *p_FmPcd, t_Handle h_NetEnv, t_Handle h_CcTree, t_Handle h_Manip, uint8_t groupId);
33121 +t_Error FmPcdManipDeleteCapwapReassmSchemes(t_Handle h_Manip);
33122 +bool FmPcdManipIpReassmIsIpv6Hdr(t_Handle h_Manip);
33123 +
33124 +t_Handle KgConfig( t_FmPcd *p_FmPcd, t_FmPcdParams *p_FmPcdParams);
33125 +t_Error KgInit(t_FmPcd *p_FmPcd);
33126 +t_Error KgFree(t_FmPcd *p_FmPcd);
33127 +void KgSetClsPlan(t_Handle h_FmPcd, t_FmPcdKgInterModuleClsPlanSet *p_Set);
33128 +bool KgIsSchemeAlwaysDirect(t_Handle h_FmPcd, uint8_t schemeId);
33129 +void KgEnable(t_FmPcd *p_FmPcd);
33130 +void KgDisable(t_FmPcd *p_FmPcd);
33131 +t_Error KgAllocClsPlanEntries(t_Handle h_FmPcd, uint16_t numOfClsPlanEntries, uint8_t guestId, uint8_t *p_First);
33132 +void KgFreeClsPlanEntries(t_Handle h_FmPcd, uint16_t numOfClsPlanEntries, uint8_t guestId, uint8_t base);
33133 +
33134 +/* only for MULTI partittion */
33135 +t_Error FmPcdKgAllocSchemes(t_Handle h_FmPcd, uint8_t numOfSchemes, uint8_t guestId, uint8_t *p_SchemesIds);
33136 +t_Error FmPcdKgFreeSchemes(t_Handle h_FmPcd, uint8_t numOfSchemes, uint8_t guestId, uint8_t *p_SchemesIds);
33137 +/* only for SINGLE partittion */
33138 +t_Error KgBindPortToSchemes(t_Handle h_FmPcd , uint8_t hardwarePortId, uint32_t spReg);
33139 +
33140 +t_FmPcdLock *FmPcdAcquireLock(t_Handle h_FmPcd);
33141 +void FmPcdReleaseLock(t_Handle h_FmPcd, t_FmPcdLock *p_Lock);
33142 +
33143 +t_Handle PlcrConfig(t_FmPcd *p_FmPcd, t_FmPcdParams *p_FmPcdParams);
33144 +t_Error PlcrInit(t_FmPcd *p_FmPcd);
33145 +t_Error PlcrFree(t_FmPcd *p_FmPcd);
33146 +void PlcrEnable(t_FmPcd *p_FmPcd);
33147 +void PlcrDisable(t_FmPcd *p_FmPcd);
33148 +uint16_t PlcrAllocProfilesForPartition(t_FmPcd *p_FmPcd, uint16_t base, uint16_t numOfProfiles, uint8_t guestId);
33149 +void PlcrFreeProfilesForPartition(t_FmPcd *p_FmPcd, uint16_t base, uint16_t numOfProfiles, uint8_t guestId);
33150 +t_Error PlcrSetPortProfiles(t_FmPcd *p_FmPcd,
33151 + uint8_t hardwarePortId,
33152 + uint16_t numOfProfiles,
33153 + uint16_t base);
33154 +t_Error PlcrClearPortProfiles(t_FmPcd *p_FmPcd, uint8_t hardwarePortId);
33155 +
33156 +t_Handle PrsConfig(t_FmPcd *p_FmPcd,t_FmPcdParams *p_FmPcdParams);
33157 +t_Error PrsInit(t_FmPcd *p_FmPcd);
33158 +void PrsEnable(t_FmPcd *p_FmPcd);
33159 +void PrsDisable(t_FmPcd *p_FmPcd);
33160 +void PrsFree(t_FmPcd *p_FmPcd );
33161 +t_Error PrsIncludePortInStatistics(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, bool include);
33162 +
33163 +t_Error FmPcdCcGetGrpParams(t_Handle treeId, uint8_t grpId, uint32_t *p_GrpBits, uint8_t *p_GrpBase);
33164 +uint8_t FmPcdCcGetOffset(t_Handle h_CcNode);
33165 +uint8_t FmPcdCcGetParseCode(t_Handle h_CcNode);
33166 +uint16_t FmPcdCcGetNumOfKeys(t_Handle h_CcNode);
33167 +t_Error ValidateNextEngineParams(t_Handle h_FmPcd, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams, e_FmPcdCcStatsMode supportedStatsMode);
33168 +
33169 +void FmPcdManipUpdateOwner(t_Handle h_Manip, bool add);
33170 +t_Error FmPcdManipCheckParamsForCcNextEngine(t_FmPcdCcNextEngineParams *p_InfoForManip, uint32_t *requiredAction);
33171 +void FmPcdManipUpdateAdResultForCc(t_Handle h_Manip,
33172 + t_FmPcdCcNextEngineParams *p_CcNextEngineParams,
33173 + t_Handle p_Ad,
33174 + t_Handle *p_AdNewPtr);
33175 +void FmPcdManipUpdateAdContLookupForCc(t_Handle h_Manip, t_Handle p_Ad, t_Handle *p_AdNew, uint32_t adTableOffset);
33176 +void FmPcdManipUpdateOwner(t_Handle h_Manip, bool add);
33177 +t_Error FmPcdManipCheckParamsWithCcNodeParams(t_Handle h_Manip, t_Handle h_FmPcdCcNode);
33178 +#ifdef FM_CAPWAP_SUPPORT
33179 +t_Handle FmPcdManipApplSpecificBuild(void);
33180 +bool FmPcdManipIsCapwapApplSpecific(t_Handle h_Manip);
33181 +#endif /* FM_CAPWAP_SUPPORT */
33182 +#if (DPAA_VERSION >= 11)
33183 +void * FrmReplicGroupGetSourceTableDescriptor(t_Handle h_ReplicGroup);
33184 +void FrmReplicGroupUpdateOwner(t_Handle h_ReplicGroup, bool add);
33185 +void FrmReplicGroupUpdateAd(t_Handle h_ReplicGroup, void *p_Ad, t_Handle *h_AdNew);
33186 +
33187 +void FmPcdCcGetAdTablesThatPointOnReplicGroup(t_Handle h_Node,
33188 + t_Handle h_ReplicGroup,
33189 + t_List *p_AdTables,
33190 + uint32_t *p_NumOfAdTables);
33191 +#endif /* (DPAA_VERSION >= 11) */
33192 +
33193 +void EnqueueNodeInfoToRelevantLst(t_List *p_List, t_CcNodeInformation *p_CcInfo, t_Handle h_Spinlock);
33194 +void DequeueNodeInfoFromRelevantLst(t_List *p_List, t_Handle h_Info, t_Handle h_Spinlock);
33195 +t_CcNodeInformation* FindNodeInfoInReleventLst(t_List *p_List, t_Handle h_Info, t_Handle h_Spinlock);
33196 +t_List *FmPcdManipGetSpinlock(t_Handle h_Manip);
33197 +t_List *FmPcdManipGetNodeLstPointedOnThisManip(t_Handle h_Manip);
33198 +
33199 +typedef struct
33200 +{
33201 + t_Handle h_StatsAd;
33202 + t_Handle h_StatsCounters;
33203 +#if (DPAA_VERSION >= 11)
33204 + t_Handle h_StatsFLRs;
33205 +#endif /* (DPAA_VERSION >= 11) */
33206 +} t_FmPcdCcStatsParams;
33207 +
33208 +void NextStepAd(t_Handle h_Ad,
33209 + t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,
33210 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,
33211 + t_FmPcd *p_FmPcd);
33212 +void ReleaseLst(t_List *p_List);
33213 +
33214 +static __inline__ t_Handle FmPcdGetMuramHandle(t_Handle h_FmPcd)
33215 +{
33216 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
33217 + ASSERT_COND(p_FmPcd);
33218 + return p_FmPcd->h_FmMuram;
33219 +}
33220 +
33221 +static __inline__ uint64_t FmPcdGetMuramPhysBase(t_Handle h_FmPcd)
33222 +{
33223 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
33224 + ASSERT_COND(p_FmPcd);
33225 + return p_FmPcd->physicalMuramBase;
33226 +}
33227 +
33228 +static __inline__ uint32_t FmPcdLockSpinlock(t_FmPcdLock *p_Lock)
33229 +{
33230 + ASSERT_COND(p_Lock);
33231 + return XX_LockIntrSpinlock(p_Lock->h_Spinlock);
33232 +}
33233 +
33234 +static __inline__ void FmPcdUnlockSpinlock(t_FmPcdLock *p_Lock, uint32_t flags)
33235 +{
33236 + ASSERT_COND(p_Lock);
33237 + XX_UnlockIntrSpinlock(p_Lock->h_Spinlock, flags);
33238 +}
33239 +
33240 +static __inline__ bool FmPcdLockTryLock(t_FmPcdLock *p_Lock)
33241 +{
33242 + uint32_t intFlags;
33243 +
33244 + ASSERT_COND(p_Lock);
33245 + intFlags = XX_LockIntrSpinlock(p_Lock->h_Spinlock);
33246 + if (p_Lock->flag)
33247 + {
33248 + XX_UnlockIntrSpinlock(p_Lock->h_Spinlock, intFlags);
33249 + return FALSE;
33250 + }
33251 + p_Lock->flag = TRUE;
33252 + XX_UnlockIntrSpinlock(p_Lock->h_Spinlock, intFlags);
33253 + return TRUE;
33254 +}
33255 +
33256 +static __inline__ void FmPcdLockUnlock(t_FmPcdLock *p_Lock)
33257 +{
33258 + ASSERT_COND(p_Lock);
33259 + p_Lock->flag = FALSE;
33260 +}
33261 +
33262 +
33263 +#endif /* __FM_PCD_H */
33264 --- /dev/null
33265 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_pcd_ipc.h
33266 @@ -0,0 +1,280 @@
33267 +/*
33268 + * Copyright 2008-2012 Freescale Semiconductor Inc.
33269 + *
33270 + * Redistribution and use in source and binary forms, with or without
33271 + * modification, are permitted provided that the following conditions are met:
33272 + * * Redistributions of source code must retain the above copyright
33273 + * notice, this list of conditions and the following disclaimer.
33274 + * * Redistributions in binary form must reproduce the above copyright
33275 + * notice, this list of conditions and the following disclaimer in the
33276 + * documentation and/or other materials provided with the distribution.
33277 + * * Neither the name of Freescale Semiconductor nor the
33278 + * names of its contributors may be used to endorse or promote products
33279 + * derived from this software without specific prior written permission.
33280 + *
33281 + *
33282 + * ALTERNATIVELY, this software may be distributed under the terms of the
33283 + * GNU General Public License ("GPL") as published by the Free Software
33284 + * Foundation, either version 2 of that License or (at your option) any
33285 + * later version.
33286 + *
33287 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
33288 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33289 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33290 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
33291 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33292 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33293 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33294 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33295 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33296 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33297 + */
33298 +
33299 +
33300 +/**************************************************************************//**
33301 + @File fm_pcd_ipc.h
33302 +
33303 + @Description FM PCD Inter-Partition prototypes, structures and definitions.
33304 +*//***************************************************************************/
33305 +#ifndef __FM_PCD_IPC_H
33306 +#define __FM_PCD_IPC_H
33307 +
33308 +#include "std_ext.h"
33309 +
33310 +
33311 +/**************************************************************************//**
33312 + @Group FM_grp Frame Manager API
33313 +
33314 + @Description FM API functions, definitions and enums
33315 +
33316 + @{
33317 +*//***************************************************************************/
33318 +
33319 +
33320 +#if defined(__MWERKS__) && !defined(__GNUC__)
33321 +#pragma pack(push,1)
33322 +#endif /* defined(__MWERKS__) && ... */
33323 +
33324 +/**************************************************************************//**
33325 + @Description Structure for getting a sw parser address according to a label
33326 + Fields commented 'IN' are passed by the port module to be used
33327 + by the FM module.
33328 + Fields commented 'OUT' will be filled by FM before returning to port.
33329 +*//***************************************************************************/
33330 +typedef _Packed struct t_FmPcdIpcSwPrsLable
33331 +{
33332 + uint32_t enumHdr; /**< IN. The existence of this header will invoke
33333 + the sw parser code. */
33334 + uint8_t indexPerHdr; /**< IN. Normally 0, if more than one sw parser
33335 + attachments for the same header, use this
33336 +
33337 + index to distinguish between them. */
33338 +} _PackedType t_FmPcdIpcSwPrsLable;
33339 +
33340 +/**************************************************************************//**
33341 + @Description Structure for port-PCD communication.
33342 + Fields commented 'IN' are passed by the port module to be used
33343 + by the FM module.
33344 + Fields commented 'OUT' will be filled by FM before returning to port.
33345 + Some fields are optional (depending on configuration) and
33346 + will be analized by the port and FM modules accordingly.
33347 +*//***************************************************************************/
33348 +
33349 +typedef struct t_FmPcdIpcKgSchemesParams
33350 +{
33351 + uint8_t guestId;
33352 + uint8_t numOfSchemes;
33353 + uint8_t schemesIds[FM_PCD_KG_NUM_OF_SCHEMES];
33354 +} _PackedType t_FmPcdIpcKgSchemesParams;
33355 +
33356 +typedef struct t_FmPcdIpcKgClsPlanParams
33357 +{
33358 + uint8_t guestId;
33359 + uint16_t numOfClsPlanEntries;
33360 + uint8_t clsPlanBase;
33361 +} _PackedType t_FmPcdIpcKgClsPlanParams;
33362 +
33363 +typedef _Packed struct t_FmPcdIpcPrsIncludePort
33364 +{
33365 + uint8_t hardwarePortId;
33366 + bool include;
33367 +} _PackedType t_FmPcdIpcPrsIncludePort;
33368 +
33369 +
33370 +#define FM_PCD_MAX_REPLY_SIZE 16
33371 +#define FM_PCD_MAX_MSG_SIZE 36
33372 +#define FM_PCD_MAX_REPLY_BODY_SIZE 36
33373 +
33374 +typedef _Packed struct {
33375 + uint32_t msgId;
33376 + uint8_t msgBody[FM_PCD_MAX_MSG_SIZE];
33377 +} _PackedType t_FmPcdIpcMsg;
33378 +
33379 +typedef _Packed struct t_FmPcdIpcReply {
33380 + uint32_t error;
33381 + uint8_t replyBody[FM_PCD_MAX_REPLY_BODY_SIZE];
33382 +} _PackedType t_FmPcdIpcReply;
33383 +
33384 +typedef _Packed struct t_FmIpcResourceAllocParams {
33385 + uint8_t guestId;
33386 + uint16_t base;
33387 + uint16_t num;
33388 +}_PackedType t_FmIpcResourceAllocParams;
33389 +
33390 +#if defined(__MWERKS__) && !defined(__GNUC__)
33391 +#pragma pack(pop)
33392 +#endif /* defined(__MWERKS__) && ... */
33393 +
33394 +
33395 +
33396 +/**************************************************************************//**
33397 + @Function FM_PCD_ALLOC_KG_SCHEMES
33398 +
33399 + @Description Used by FM PCD front-end in order to allocate KG resources
33400 +
33401 + @Param[in/out] t_FmPcdIpcKgAllocParams Pointer
33402 +*//***************************************************************************/
33403 +#define FM_PCD_ALLOC_KG_SCHEMES 3
33404 +
33405 +/**************************************************************************//**
33406 + @Function FM_PCD_FREE_KG_SCHEMES
33407 +
33408 + @Description Used by FM PCD front-end in order to Free KG resources
33409 +
33410 + @Param[in/out] t_FmPcdIpcKgSchemesParams Pointer
33411 +*//***************************************************************************/
33412 +#define FM_PCD_FREE_KG_SCHEMES 4
33413 +
33414 +/**************************************************************************//**
33415 + @Function FM_PCD_ALLOC_PROFILES
33416 +
33417 + @Description Used by FM PCD front-end in order to allocate Policer profiles
33418 +
33419 + @Param[in/out] t_FmIpcResourceAllocParams Pointer
33420 +*//***************************************************************************/
33421 +#define FM_PCD_ALLOC_PROFILES 5
33422 +
33423 +/**************************************************************************//**
33424 + @Function FM_PCD_FREE_PROFILES
33425 +
33426 + @Description Used by FM PCD front-end in order to Free Policer profiles
33427 +
33428 + @Param[in/out] t_FmIpcResourceAllocParams Pointer
33429 +*//***************************************************************************/
33430 +#define FM_PCD_FREE_PROFILES 6
33431 +
33432 +/**************************************************************************//**
33433 + @Function FM_PCD_SET_PORT_PROFILES
33434 +
33435 + @Description Used by FM PCD front-end in order to allocate Policer profiles
33436 + for specific port
33437 +
33438 + @Param[in/out] t_FmIpcResourceAllocParams Pointer
33439 +*//***************************************************************************/
33440 +#define FM_PCD_SET_PORT_PROFILES 7
33441 +
33442 +/**************************************************************************//**
33443 + @Function FM_PCD_CLEAR_PORT_PROFILES
33444 +
33445 + @Description Used by FM PCD front-end in order to allocate Policer profiles
33446 + for specific port
33447 +
33448 + @Param[in/out] t_FmIpcResourceAllocParams Pointer
33449 +*//***************************************************************************/
33450 +#define FM_PCD_CLEAR_PORT_PROFILES 8
33451 +
33452 +/**************************************************************************//**
33453 + @Function FM_PCD_GET_PHYS_MURAM_BASE
33454 +
33455 + @Description Used by FM PCD front-end in order to get MURAM base address
33456 +
33457 + @Param[in/out] t_FmPcdIcPhysAddr Pointer
33458 +*//***************************************************************************/
33459 +#define FM_PCD_GET_PHYS_MURAM_BASE 9
33460 +
33461 +/**************************************************************************//**
33462 + @Function FM_PCD_GET_SW_PRS_OFFSET
33463 +
33464 + @Description Used by FM front-end to get the SW parser offset of the start of
33465 + code relevant to a given label.
33466 +
33467 + @Param[in/out] t_FmPcdIpcSwPrsLable Pointer
33468 +*//***************************************************************************/
33469 +#define FM_PCD_GET_SW_PRS_OFFSET 10
33470 +
33471 +/**************************************************************************//**
33472 + @Function FM_PCD_MASTER_IS_ENABLED
33473 +
33474 + @Description Used by FM front-end in order to verify
33475 + PCD enablement.
33476 +
33477 + @Param[in] bool Pointer
33478 +*//***************************************************************************/
33479 +#define FM_PCD_MASTER_IS_ENABLED 15
33480 +
33481 +/**************************************************************************//**
33482 + @Function FM_PCD_GUEST_DISABLE
33483 +
33484 + @Description Used by FM front-end to inform back-end when
33485 + front-end PCD is disabled
33486 +
33487 + @Param[in] None
33488 +*//***************************************************************************/
33489 +#define FM_PCD_GUEST_DISABLE 16
33490 +
33491 +/**************************************************************************//**
33492 + @Function FM_PCD_FREE_KG_CLSPLAN
33493 +
33494 + @Description Used by FM PCD front-end in order to Free KG classification plan entries
33495 +
33496 + @Param[in/out] t_FmPcdIpcKgClsPlanParams Pointer
33497 +*//***************************************************************************/
33498 +#define FM_PCD_FREE_KG_CLSPLAN 22
33499 +
33500 +/**************************************************************************//**
33501 + @Function FM_PCD_ALLOC_KG_CLSPLAN
33502 +
33503 + @Description Used by FM PCD front-end in order to allocate KG classification plan entries
33504 +
33505 + @Param[in/out] t_FmPcdIpcKgClsPlanParams Pointer
33506 +*//***************************************************************************/
33507 +#define FM_PCD_ALLOC_KG_CLSPLAN 23
33508 +
33509 +/**************************************************************************//**
33510 + @Function FM_PCD_MASTER_IS_ALIVE
33511 +
33512 + @Description Used by FM front-end to check that back-end exists
33513 +
33514 + @Param[in] None
33515 +*//***************************************************************************/
33516 +#define FM_PCD_MASTER_IS_ALIVE 24
33517 +
33518 +/**************************************************************************//**
33519 + @Function FM_PCD_GET_COUNTER
33520 +
33521 + @Description Used by FM front-end to read PCD counters
33522 +
33523 + @Param[in/out] t_FmPcdIpcGetCounter Pointer
33524 +*//***************************************************************************/
33525 +#define FM_PCD_GET_COUNTER 25
33526 +
33527 +/**************************************************************************//**
33528 + @Function FM_PCD_PRS_INC_PORT_STATS
33529 +
33530 + @Description Used by FM front-end to set/clear statistics for port
33531 +
33532 + @Param[in/out] t_FmPcdIpcPrsIncludePort Pointer
33533 +*//***************************************************************************/
33534 +#define FM_PCD_PRS_INC_PORT_STATS 26
33535 +
33536 +#if (DPAA_VERSION >= 11)
33537 +/* TODO - doc */
33538 +#define FM_PCD_ALLOC_SP 27
33539 +#endif /* (DPAA_VERSION >= 11) */
33540 +
33541 +
33542 +/** @} */ /* end of FM_PCD_IPC_grp group */
33543 +/** @} */ /* end of FM_grp group */
33544 +
33545 +
33546 +#endif /* __FM_PCD_IPC_H */
33547 --- /dev/null
33548 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_plcr.c
33549 @@ -0,0 +1,1846 @@
33550 +/*
33551 + * Copyright 2008-2012 Freescale Semiconductor Inc.
33552 + *
33553 + * Redistribution and use in source and binary forms, with or without
33554 + * modification, are permitted provided that the following conditions are met:
33555 + * * Redistributions of source code must retain the above copyright
33556 + * notice, this list of conditions and the following disclaimer.
33557 + * * Redistributions in binary form must reproduce the above copyright
33558 + * notice, this list of conditions and the following disclaimer in the
33559 + * documentation and/or other materials provided with the distribution.
33560 + * * Neither the name of Freescale Semiconductor nor the
33561 + * names of its contributors may be used to endorse or promote products
33562 + * derived from this software without specific prior written permission.
33563 + *
33564 + *
33565 + * ALTERNATIVELY, this software may be distributed under the terms of the
33566 + * GNU General Public License ("GPL") as published by the Free Software
33567 + * Foundation, either version 2 of that License or (at your option) any
33568 + * later version.
33569 + *
33570 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
33571 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33572 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33573 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
33574 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33575 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33576 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33577 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33578 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33579 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33580 + */
33581 +
33582 +
33583 +/******************************************************************************
33584 + @File fm_plcr.c
33585 +
33586 + @Description FM PCD POLICER...
33587 +*//***************************************************************************/
33588 +#include "std_ext.h"
33589 +#include "error_ext.h"
33590 +#include "string_ext.h"
33591 +#include "debug_ext.h"
33592 +#include "net_ext.h"
33593 +#include "fm_ext.h"
33594 +
33595 +#include "fm_common.h"
33596 +#include "fm_pcd.h"
33597 +#include "fm_hc.h"
33598 +#include "fm_pcd_ipc.h"
33599 +#include "fm_plcr.h"
33600 +
33601 +
33602 +/****************************************/
33603 +/* static functions */
33604 +/****************************************/
33605 +
33606 +static uint32_t PlcrProfileLock(t_Handle h_Profile)
33607 +{
33608 + ASSERT_COND(h_Profile);
33609 + return FmPcdLockSpinlock(((t_FmPcdPlcrProfile *)h_Profile)->p_Lock);
33610 +}
33611 +
33612 +static void PlcrProfileUnlock(t_Handle h_Profile, uint32_t intFlags)
33613 +{
33614 + ASSERT_COND(h_Profile);
33615 + FmPcdUnlockSpinlock(((t_FmPcdPlcrProfile *)h_Profile)->p_Lock, intFlags);
33616 +}
33617 +
33618 +static bool PlcrProfileFlagTryLock(t_Handle h_Profile)
33619 +{
33620 + ASSERT_COND(h_Profile);
33621 + return FmPcdLockTryLock(((t_FmPcdPlcrProfile *)h_Profile)->p_Lock);
33622 +}
33623 +
33624 +static void PlcrProfileFlagUnlock(t_Handle h_Profile)
33625 +{
33626 + ASSERT_COND(h_Profile);
33627 + FmPcdLockUnlock(((t_FmPcdPlcrProfile *)h_Profile)->p_Lock);
33628 +}
33629 +
33630 +static uint32_t PlcrHwLock(t_Handle h_FmPcdPlcr)
33631 +{
33632 + ASSERT_COND(h_FmPcdPlcr);
33633 + return XX_LockIntrSpinlock(((t_FmPcdPlcr*)h_FmPcdPlcr)->h_HwSpinlock);
33634 +}
33635 +
33636 +static void PlcrHwUnlock(t_Handle h_FmPcdPlcr, uint32_t intFlags)
33637 +{
33638 + ASSERT_COND(h_FmPcdPlcr);
33639 + XX_UnlockIntrSpinlock(((t_FmPcdPlcr*)h_FmPcdPlcr)->h_HwSpinlock, intFlags);
33640 +}
33641 +
33642 +static uint32_t PlcrSwLock(t_Handle h_FmPcdPlcr)
33643 +{
33644 + ASSERT_COND(h_FmPcdPlcr);
33645 + return XX_LockIntrSpinlock(((t_FmPcdPlcr*)h_FmPcdPlcr)->h_SwSpinlock);
33646 +}
33647 +
33648 +static void PlcrSwUnlock(t_Handle h_FmPcdPlcr, uint32_t intFlags)
33649 +{
33650 + ASSERT_COND(h_FmPcdPlcr);
33651 + XX_UnlockIntrSpinlock(((t_FmPcdPlcr*)h_FmPcdPlcr)->h_SwSpinlock, intFlags);
33652 +}
33653 +
33654 +static bool IsProfileShared(t_Handle h_FmPcd, uint16_t absoluteProfileId)
33655 +{
33656 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
33657 + uint16_t i;
33658 +
33659 + SANITY_CHECK_RETURN_VALUE(p_FmPcd, E_INVALID_HANDLE, FALSE);
33660 +
33661 + for (i=0;i<p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles;i++)
33662 + if (p_FmPcd->p_FmPcdPlcr->sharedProfilesIds[i] == absoluteProfileId)
33663 + return TRUE;
33664 + return FALSE;
33665 +}
33666 +
33667 +static t_Error SetProfileNia(t_FmPcd *p_FmPcd, e_FmPcdEngine nextEngine, u_FmPcdPlcrNextEngineParams *p_NextEngineParams, uint32_t *nextAction)
33668 +{
33669 + uint32_t nia;
33670 + uint16_t absoluteProfileId;
33671 + uint8_t relativeSchemeId, physicalSchemeId;
33672 +
33673 + nia = FM_PCD_PLCR_NIA_VALID;
33674 +
33675 + switch (nextEngine)
33676 + {
33677 + case e_FM_PCD_DONE :
33678 + switch (p_NextEngineParams->action)
33679 + {
33680 + case e_FM_PCD_DROP_FRAME :
33681 + nia |= GET_NIA_BMI_AC_DISCARD_FRAME(p_FmPcd);
33682 + break;
33683 + case e_FM_PCD_ENQ_FRAME:
33684 + nia |= GET_NIA_BMI_AC_ENQ_FRAME(p_FmPcd);
33685 + break;
33686 + default:
33687 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
33688 + }
33689 + break;
33690 + case e_FM_PCD_KG:
33691 + physicalSchemeId = FmPcdKgGetSchemeId(p_NextEngineParams->h_DirectScheme);
33692 + relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, physicalSchemeId);
33693 + if (relativeSchemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
33694 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
33695 + if (!FmPcdKgIsSchemeValidSw(p_NextEngineParams->h_DirectScheme))
33696 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid direct scheme."));
33697 + if (!KgIsSchemeAlwaysDirect(p_FmPcd, relativeSchemeId))
33698 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Policer Profile may point only to a scheme that is always direct."));
33699 + nia |= NIA_ENG_KG | NIA_KG_DIRECT | physicalSchemeId;
33700 + break;
33701 + case e_FM_PCD_PLCR:
33702 + absoluteProfileId = ((t_FmPcdPlcrProfile *)p_NextEngineParams->h_Profile)->absoluteProfileId;
33703 + if (!IsProfileShared(p_FmPcd, absoluteProfileId))
33704 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next profile must be a shared profile"));
33705 + if (!FmPcdPlcrIsProfileValid(p_FmPcd, absoluteProfileId))
33706 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid profile "));
33707 + nia |= NIA_ENG_PLCR | NIA_PLCR_ABSOLUTE | absoluteProfileId;
33708 + break;
33709 + default:
33710 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
33711 + }
33712 +
33713 + *nextAction = nia;
33714 +
33715 + return E_OK;
33716 +}
33717 +
33718 +static uint32_t CalcFPP(uint32_t fpp)
33719 +{
33720 + if (fpp > 15)
33721 + return 15 - (0x1f - fpp);
33722 + else
33723 + return 16 + fpp;
33724 +}
33725 +
33726 +static void GetInfoRateReg(e_FmPcdPlcrRateMode rateMode,
33727 + uint32_t rate,
33728 + uint64_t tsuInTenthNano,
33729 + uint32_t fppShift,
33730 + uint64_t *p_Integer,
33731 + uint64_t *p_Fraction)
33732 +{
33733 + uint64_t tmp, div;
33734 +
33735 + if (rateMode == e_FM_PCD_PLCR_BYTE_MODE)
33736 + {
33737 + /* now we calculate the initial integer for the bigger rate */
33738 + /* from Kbps to Bytes/TSU */
33739 + tmp = (uint64_t)rate;
33740 + tmp *= 1000; /* kb --> b */
33741 + tmp *= tsuInTenthNano; /* bps --> bpTsu(in 10nano) */
33742 +
33743 + div = 1000000000; /* nano */
33744 + div *= 10; /* 10 nano */
33745 + div *= 8; /* bit to byte */
33746 + }
33747 + else
33748 + {
33749 + /* now we calculate the initial integer for the bigger rate */
33750 + /* from Kbps to Bytes/TSU */
33751 + tmp = (uint64_t)rate;
33752 + tmp *= tsuInTenthNano; /* bps --> bpTsu(in 10nano) */
33753 +
33754 + div = 1000000000; /* nano */
33755 + div *= 10; /* 10 nano */
33756 + }
33757 + *p_Integer = (tmp<<fppShift)/div;
33758 +
33759 + /* for calculating the fraction, we will recalculate cir and deduct the integer.
33760 + * For precision, we will multiply by 2^16. we do not divid back, since we write
33761 + * this value as fraction - see spec.
33762 + */
33763 + *p_Fraction = (((tmp<<fppShift)<<16) - ((*p_Integer<<16)*div))/div;
33764 +}
33765 +
33766 +/* .......... */
33767 +
33768 +static void CalcRates(uint32_t bitFor1Micro,
33769 + t_FmPcdPlcrNonPassthroughAlgParams *p_NonPassthroughAlgParam,
33770 + uint32_t *cir,
33771 + uint32_t *cbs,
33772 + uint32_t *pir_eir,
33773 + uint32_t *pbs_ebs,
33774 + uint32_t *fpp)
33775 +{
33776 + uint64_t integer, fraction;
33777 + uint32_t temp, tsuInTenthNanos;
33778 + uint8_t fppShift=0;
33779 +
33780 + /* we want the tsu to count 10 nano for better precision normally tsu is 3.9 nano, now we will get 39 */
33781 + tsuInTenthNanos = (uint32_t)(1000*10/(1 << bitFor1Micro));
33782 +
33783 + /* we choose the faster rate to calibrate fpp */
33784 + /* The meaning of this step:
33785 + * when fppShift is 0 it means all TS bits are treated as integer and TSU is the TS LSB count.
33786 + * In this configuration we calculate the integer and fraction that represent the higher infoRate
33787 + * When this is done, we can tell where we have "spare" unused bits and optimize the division of TS
33788 + * into "integer" and "fraction" where the logic is - as many bits as possible for integer at
33789 + * high rate, as many bits as possible for fraction at low rate.
33790 + */
33791 + if (p_NonPassthroughAlgParam->committedInfoRate > p_NonPassthroughAlgParam->peakOrExcessInfoRate)
33792 + GetInfoRateReg(p_NonPassthroughAlgParam->rateMode, p_NonPassthroughAlgParam->committedInfoRate, tsuInTenthNanos, 0, &integer, &fraction);
33793 + else
33794 + GetInfoRateReg(p_NonPassthroughAlgParam->rateMode, p_NonPassthroughAlgParam->peakOrExcessInfoRate, tsuInTenthNanos, 0, &integer, &fraction);
33795 +
33796 + /* we shift integer, as in cir/pir it is represented by the MSB 16 bits, and
33797 + * the LSB bits are for the fraction */
33798 + temp = (uint32_t)((integer<<16) & 0x00000000FFFFFFFF);
33799 + /* temp is effected by the rate. For low rates it may be as low as 0, and then we'll
33800 + * take max FP = 31.
33801 + * For high rates it will never exceed the 32 bit reg (after the 16 shift), as it is
33802 + * limited by the 10G physical port.
33803 + */
33804 + if (temp != 0)
33805 + {
33806 + /* In this case, the largest rate integer is non 0, if it does not occupy all (high) 16
33807 + * bits of the PIR_EIR we can use this fact and enlarge it to occupy all 16 bits.
33808 + * The logic is to have as many bits for integer in the higher rates, but if we have "0"s
33809 + * in the integer part of the cir/pir register, than these bits are wasted. So we want
33810 + * to use these bits for the fraction. in this way we will have for fraction - the number
33811 + * of "0" bits and the rest - for integer.
33812 + * In other words: For each bit we shift it in PIR_EIR, we move the FP in the TS
33813 + * one bit to the left - preserving the relationship and achieving more bits
33814 + * for integer in the TS.
33815 + */
33816 +
33817 + /* count zeroes left of the higher used bit (in order to shift the value such that
33818 + * unused bits may be used for fraction).
33819 + */
33820 + while ((temp & 0x80000000) == 0)
33821 + {
33822 + temp = temp << 1;
33823 + fppShift++;
33824 + }
33825 + if (fppShift > 15)
33826 + {
33827 + REPORT_ERROR(MAJOR, E_INVALID_SELECTION, ("timeStampPeriod to Information rate ratio is too small"));
33828 + return;
33829 + }
33830 + }
33831 + else
33832 + {
33833 + temp = (uint32_t)fraction; /* fraction will alyas be smaller than 2^16 */
33834 + if (!temp)
33835 + /* integer and fraction are 0, we set FP to its max val */
33836 + fppShift = 31;
33837 + else
33838 + {
33839 + /* integer was 0 but fraction is not. FP is 16 for the fraction,
33840 + * + all left zeroes of the fraction. */
33841 + fppShift=16;
33842 + /* count zeroes left of the higher used bit (in order to shift the value such that
33843 + * unused bits may be used for fraction).
33844 + */
33845 + while ((temp & 0x8000) == 0)
33846 + {
33847 + temp = temp << 1;
33848 + fppShift++;
33849 + }
33850 + }
33851 + }
33852 +
33853 + /*
33854 + * This means that the FM TS register will now be used so that 'fppShift' bits are for
33855 + * fraction and the rest for integer */
33856 + /* now we re-calculate cir and pir_eir with the calculated FP */
33857 + GetInfoRateReg(p_NonPassthroughAlgParam->rateMode, p_NonPassthroughAlgParam->committedInfoRate, tsuInTenthNanos, fppShift, &integer, &fraction);
33858 + *cir = (uint32_t)(integer << 16 | (fraction & 0xFFFF));
33859 + GetInfoRateReg(p_NonPassthroughAlgParam->rateMode, p_NonPassthroughAlgParam->peakOrExcessInfoRate, tsuInTenthNanos, fppShift, &integer, &fraction);
33860 + *pir_eir = (uint32_t)(integer << 16 | (fraction & 0xFFFF));
33861 +
33862 + *cbs = p_NonPassthroughAlgParam->committedBurstSize;
33863 + *pbs_ebs = p_NonPassthroughAlgParam->peakOrExcessBurstSize;
33864 +
33865 + /* convert FP as it should be written to reg.
33866 + * 0-15 --> 16-31
33867 + * 16-31 --> 0-15
33868 + */
33869 + *fpp = CalcFPP(fppShift);
33870 +}
33871 +
33872 +static void WritePar(t_FmPcd *p_FmPcd, uint32_t par)
33873 +{
33874 + t_FmPcdPlcrRegs *p_FmPcdPlcrRegs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
33875 +
33876 + ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
33877 + WRITE_UINT32(p_FmPcdPlcrRegs->fmpl_par, par);
33878 +
33879 + while (GET_UINT32(p_FmPcdPlcrRegs->fmpl_par) & FM_PCD_PLCR_PAR_GO) ;
33880 +}
33881 +
33882 +static t_Error BuildProfileRegs(t_FmPcd *p_FmPcd,
33883 + t_FmPcdPlcrProfileParams *p_ProfileParams,
33884 + t_FmPcdPlcrProfileRegs *p_PlcrRegs)
33885 +{
33886 + t_Error err = E_OK;
33887 + uint32_t pemode, gnia, ynia, rnia, bitFor1Micro;
33888 +
33889 + ASSERT_COND(p_FmPcd);
33890 +
33891 + bitFor1Micro = FmGetTimeStampScale(p_FmPcd->h_Fm);
33892 + if (bitFor1Micro == 0)
33893 + RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("Timestamp scale"));
33894 +
33895 +/* Set G, Y, R Nia */
33896 + err = SetProfileNia(p_FmPcd, p_ProfileParams->nextEngineOnGreen, &(p_ProfileParams->paramsOnGreen), &gnia);
33897 + if (err)
33898 + RETURN_ERROR(MAJOR, err, NO_MSG);
33899 + err = SetProfileNia(p_FmPcd, p_ProfileParams->nextEngineOnYellow, &(p_ProfileParams->paramsOnYellow), &ynia);
33900 + if (err)
33901 + RETURN_ERROR(MAJOR, err, NO_MSG);
33902 + err = SetProfileNia(p_FmPcd, p_ProfileParams->nextEngineOnRed, &(p_ProfileParams->paramsOnRed), &rnia);
33903 + if (err)
33904 + RETURN_ERROR(MAJOR, err, NO_MSG);
33905 +
33906 +/* Mode fmpl_pemode */
33907 + pemode = FM_PCD_PLCR_PEMODE_PI;
33908 +
33909 + switch (p_ProfileParams->algSelection)
33910 + {
33911 + case e_FM_PCD_PLCR_PASS_THROUGH:
33912 + p_PlcrRegs->fmpl_pecir = 0;
33913 + p_PlcrRegs->fmpl_pecbs = 0;
33914 + p_PlcrRegs->fmpl_pepepir_eir = 0;
33915 + p_PlcrRegs->fmpl_pepbs_ebs = 0;
33916 + p_PlcrRegs->fmpl_pelts = 0;
33917 + p_PlcrRegs->fmpl_pects = 0;
33918 + p_PlcrRegs->fmpl_pepts_ets = 0;
33919 + pemode &= ~FM_PCD_PLCR_PEMODE_ALG_MASK;
33920 + switch (p_ProfileParams->colorMode)
33921 + {
33922 + case e_FM_PCD_PLCR_COLOR_BLIND:
33923 + pemode |= FM_PCD_PLCR_PEMODE_CBLND;
33924 + switch (p_ProfileParams->color.dfltColor)
33925 + {
33926 + case e_FM_PCD_PLCR_GREEN:
33927 + pemode &= ~FM_PCD_PLCR_PEMODE_DEFC_MASK;
33928 + break;
33929 + case e_FM_PCD_PLCR_YELLOW:
33930 + pemode |= FM_PCD_PLCR_PEMODE_DEFC_Y;
33931 + break;
33932 + case e_FM_PCD_PLCR_RED:
33933 + pemode |= FM_PCD_PLCR_PEMODE_DEFC_R;
33934 + break;
33935 + case e_FM_PCD_PLCR_OVERRIDE:
33936 + pemode |= FM_PCD_PLCR_PEMODE_DEFC_OVERRIDE;
33937 + break;
33938 + default:
33939 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
33940 + }
33941 +
33942 + break;
33943 + case e_FM_PCD_PLCR_COLOR_AWARE:
33944 + pemode &= ~FM_PCD_PLCR_PEMODE_CBLND;
33945 + break;
33946 + default:
33947 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
33948 + }
33949 + break;
33950 +
33951 + case e_FM_PCD_PLCR_RFC_2698:
33952 + /* Select algorithm MODE[ALG] = "01" */
33953 + pemode |= FM_PCD_PLCR_PEMODE_ALG_RFC2698;
33954 + if (p_ProfileParams->nonPassthroughAlgParams.committedInfoRate > p_ProfileParams->nonPassthroughAlgParams.peakOrExcessInfoRate)
33955 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("in RFC2698 Peak rate must be equal or larger than committedInfoRate."));
33956 + goto cont_rfc;
33957 + case e_FM_PCD_PLCR_RFC_4115:
33958 + /* Select algorithm MODE[ALG] = "10" */
33959 + pemode |= FM_PCD_PLCR_PEMODE_ALG_RFC4115;
33960 +cont_rfc:
33961 + /* Select Color-Blind / Color-Aware operation (MODE[CBLND]) */
33962 + switch (p_ProfileParams->colorMode)
33963 + {
33964 + case e_FM_PCD_PLCR_COLOR_BLIND:
33965 + pemode |= FM_PCD_PLCR_PEMODE_CBLND;
33966 + break;
33967 + case e_FM_PCD_PLCR_COLOR_AWARE:
33968 + pemode &= ~FM_PCD_PLCR_PEMODE_CBLND;
33969 + /*In color aware more select override color interpretation (MODE[OVCLR]) */
33970 + switch (p_ProfileParams->color.override)
33971 + {
33972 + case e_FM_PCD_PLCR_GREEN:
33973 + pemode &= ~FM_PCD_PLCR_PEMODE_OVCLR_MASK;
33974 + break;
33975 + case e_FM_PCD_PLCR_YELLOW:
33976 + pemode |= FM_PCD_PLCR_PEMODE_OVCLR_Y;
33977 + break;
33978 + case e_FM_PCD_PLCR_RED:
33979 + pemode |= FM_PCD_PLCR_PEMODE_OVCLR_R;
33980 + break;
33981 + case e_FM_PCD_PLCR_OVERRIDE:
33982 + pemode |= FM_PCD_PLCR_PEMODE_OVCLR_G_NC;
33983 + break;
33984 + default:
33985 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
33986 + }
33987 + break;
33988 + default:
33989 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
33990 + }
33991 + /* Select Measurement Unit Mode to BYTE or PACKET (MODE[PKT]) */
33992 + switch (p_ProfileParams->nonPassthroughAlgParams.rateMode)
33993 + {
33994 + case e_FM_PCD_PLCR_BYTE_MODE :
33995 + pemode &= ~FM_PCD_PLCR_PEMODE_PKT;
33996 + switch (p_ProfileParams->nonPassthroughAlgParams.byteModeParams.frameLengthSelection)
33997 + {
33998 + case e_FM_PCD_PLCR_L2_FRM_LEN:
33999 + pemode |= FM_PCD_PLCR_PEMODE_FLS_L2;
34000 + break;
34001 + case e_FM_PCD_PLCR_L3_FRM_LEN:
34002 + pemode |= FM_PCD_PLCR_PEMODE_FLS_L3;
34003 + break;
34004 + case e_FM_PCD_PLCR_L4_FRM_LEN:
34005 + pemode |= FM_PCD_PLCR_PEMODE_FLS_L4;
34006 + break;
34007 + case e_FM_PCD_PLCR_FULL_FRM_LEN:
34008 + pemode |= FM_PCD_PLCR_PEMODE_FLS_FULL;
34009 + break;
34010 + default:
34011 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
34012 + }
34013 + switch (p_ProfileParams->nonPassthroughAlgParams.byteModeParams.rollBackFrameSelection)
34014 + {
34015 + case e_FM_PCD_PLCR_ROLLBACK_L2_FRM_LEN:
34016 + pemode &= ~FM_PCD_PLCR_PEMODE_RBFLS;
34017 + break;
34018 + case e_FM_PCD_PLCR_ROLLBACK_FULL_FRM_LEN:
34019 + pemode |= FM_PCD_PLCR_PEMODE_RBFLS;
34020 + break;
34021 + default:
34022 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
34023 + }
34024 + break;
34025 + case e_FM_PCD_PLCR_PACKET_MODE :
34026 + pemode |= FM_PCD_PLCR_PEMODE_PKT;
34027 + break;
34028 + default:
34029 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
34030 + }
34031 + /* Select timeStamp floating point position (MODE[FPP]) to fit the actual traffic rates. For PACKET
34032 + mode with low traffic rates move the fixed point to the left to increase fraction accuracy. For BYTE
34033 + mode with high traffic rates move the fixed point to the right to increase integer accuracy. */
34034 +
34035 + /* Configure Traffic Parameters*/
34036 + {
34037 + uint32_t cir=0, cbs=0, pir_eir=0, pbs_ebs=0, fpp=0;
34038 +
34039 + CalcRates(bitFor1Micro, &p_ProfileParams->nonPassthroughAlgParams, &cir, &cbs, &pir_eir, &pbs_ebs, &fpp);
34040 +
34041 + /* Set Committed Information Rate (CIR) */
34042 + p_PlcrRegs->fmpl_pecir = cir;
34043 + /* Set Committed Burst Size (CBS). */
34044 + p_PlcrRegs->fmpl_pecbs = cbs;
34045 + /* Set Peak Information Rate (PIR_EIR used as PIR) */
34046 + p_PlcrRegs->fmpl_pepepir_eir = pir_eir;
34047 + /* Set Peak Burst Size (PBS_EBS used as PBS) */
34048 + p_PlcrRegs->fmpl_pepbs_ebs = pbs_ebs;
34049 +
34050 + /* Initialize the Metering Buckets to be full (write them with 0xFFFFFFFF. */
34051 + /* Peak Rate Token Bucket Size (PTS_ETS used as PTS) */
34052 + p_PlcrRegs->fmpl_pepts_ets = 0xFFFFFFFF;
34053 + /* Committed Rate Token Bucket Size (CTS) */
34054 + p_PlcrRegs->fmpl_pects = 0xFFFFFFFF;
34055 +
34056 + /* Set the FPP based on calculation */
34057 + pemode |= (fpp << FM_PCD_PLCR_PEMODE_FPP_SHIFT);
34058 + }
34059 + break; /* FM_PCD_PLCR_PEMODE_ALG_RFC2698 , FM_PCD_PLCR_PEMODE_ALG_RFC4115 */
34060 + default:
34061 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
34062 + }
34063 +
34064 + p_PlcrRegs->fmpl_pemode = pemode;
34065 +
34066 + p_PlcrRegs->fmpl_pegnia = gnia;
34067 + p_PlcrRegs->fmpl_peynia = ynia;
34068 + p_PlcrRegs->fmpl_pernia = rnia;
34069 +
34070 + /* Zero Counters */
34071 + p_PlcrRegs->fmpl_pegpc = 0;
34072 + p_PlcrRegs->fmpl_peypc = 0;
34073 + p_PlcrRegs->fmpl_perpc = 0;
34074 + p_PlcrRegs->fmpl_perypc = 0;
34075 + p_PlcrRegs->fmpl_perrpc = 0;
34076 +
34077 + return E_OK;
34078 +}
34079 +
34080 +static t_Error AllocSharedProfiles(t_FmPcd *p_FmPcd, uint16_t numOfProfiles, uint16_t *profilesIds)
34081 +{
34082 + uint32_t profilesFound;
34083 + uint16_t i, k=0;
34084 + uint32_t intFlags;
34085 +
34086 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
34087 +
34088 + if (!numOfProfiles)
34089 + return E_OK;
34090 +
34091 + if (numOfProfiles>FM_PCD_PLCR_NUM_ENTRIES)
34092 + RETURN_ERROR(MINOR, E_INVALID_VALUE, ("numProfiles is too big."));
34093 +
34094 + intFlags = PlcrSwLock(p_FmPcd->p_FmPcdPlcr);
34095 + /* Find numOfProfiles free profiles (may be spread) */
34096 + profilesFound = 0;
34097 + for (i=0;i<FM_PCD_PLCR_NUM_ENTRIES; i++)
34098 + if (!p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated)
34099 + {
34100 + profilesFound++;
34101 + profilesIds[k] = i;
34102 + k++;
34103 + if (profilesFound == numOfProfiles)
34104 + break;
34105 + }
34106 +
34107 + if (profilesFound != numOfProfiles)
34108 + {
34109 + PlcrSwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
34110 + RETURN_ERROR(MAJOR, E_INVALID_STATE,NO_MSG);
34111 + }
34112 +
34113 + for (i = 0;i<k;i++)
34114 + {
34115 + p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.allocated = TRUE;
34116 + p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.ownerId = 0;
34117 + }
34118 + PlcrSwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
34119 +
34120 + return E_OK;
34121 +}
34122 +
34123 +static void FreeSharedProfiles(t_FmPcd *p_FmPcd, uint16_t numOfProfiles, uint16_t *profilesIds)
34124 +{
34125 + uint16_t i;
34126 +
34127 + SANITY_CHECK_RETURN(p_FmPcd, E_INVALID_HANDLE);
34128 +
34129 + ASSERT_COND(numOfProfiles);
34130 +
34131 + for (i=0; i < numOfProfiles; i++)
34132 + {
34133 + ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.allocated);
34134 + p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.allocated = FALSE;
34135 + p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.ownerId = p_FmPcd->guestId;
34136 + }
34137 +}
34138 +
34139 +static void UpdateRequiredActionFlag(t_Handle h_FmPcd, uint16_t absoluteProfileId, bool set)
34140 +{
34141 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
34142 +
34143 + /* this routine is protected by calling routine */
34144 +
34145 + ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
34146 +
34147 + if (set)
34148 + p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredActionFlag = TRUE;
34149 + else
34150 + {
34151 + p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredAction = 0;
34152 + p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredActionFlag = FALSE;
34153 + }
34154 +}
34155 +
34156 +/*********************************************/
34157 +/*............Policer Exception..............*/
34158 +/*********************************************/
34159 +static void EventsCB(t_Handle h_FmPcd)
34160 +{
34161 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
34162 + uint32_t event, mask, force;
34163 +
34164 + ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
34165 + event = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_evr);
34166 + mask = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ier);
34167 +
34168 + event &= mask;
34169 +
34170 + /* clear the forced events */
34171 + force = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ifr);
34172 + if (force & event)
34173 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ifr, force & ~event);
34174 +
34175 +
34176 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_evr, event);
34177 +
34178 + if (event & FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE)
34179 + p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE);
34180 + if (event & FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE)
34181 + p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE);
34182 +}
34183 +
34184 +/* ..... */
34185 +
34186 +static void ErrorExceptionsCB(t_Handle h_FmPcd)
34187 +{
34188 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
34189 + uint32_t event, force, captureReg, mask;
34190 +
34191 + ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
34192 + event = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eevr);
34193 + mask = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eier);
34194 +
34195 + event &= mask;
34196 +
34197 + /* clear the forced events */
34198 + force = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eifr);
34199 + if (force & event)
34200 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eifr, force & ~event);
34201 +
34202 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eevr, event);
34203 +
34204 + if (event & FM_PCD_PLCR_DOUBLE_ECC)
34205 + p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC);
34206 + if (event & FM_PCD_PLCR_INIT_ENTRY_ERROR)
34207 + {
34208 + captureReg = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_upcr);
34209 + /*ASSERT_COND(captureReg & PLCR_ERR_UNINIT_CAP);
34210 + p_UnInitCapt->profileNum = (uint8_t)(captureReg & PLCR_ERR_UNINIT_NUM_MASK);
34211 + p_UnInitCapt->portId = (uint8_t)((captureReg & PLCR_ERR_UNINIT_PID_MASK) >>PLCR_ERR_UNINIT_PID_SHIFT) ;
34212 + p_UnInitCapt->absolute = (bool)(captureReg & PLCR_ERR_UNINIT_ABSOLUTE_MASK);*/
34213 + p_FmPcd->f_FmPcdIndexedException(p_FmPcd->h_App,e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR,(uint16_t)(captureReg & PLCR_ERR_UNINIT_NUM_MASK));
34214 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_upcr, PLCR_ERR_UNINIT_CAP);
34215 + }
34216 +}
34217 +
34218 +
34219 +/*****************************************************************************/
34220 +/* Inter-module API routines */
34221 +/*****************************************************************************/
34222 +
34223 +t_Handle PlcrConfig(t_FmPcd *p_FmPcd, t_FmPcdParams *p_FmPcdParams)
34224 +{
34225 + t_FmPcdPlcr *p_FmPcdPlcr;
34226 + uint16_t i=0;
34227 +
34228 + UNUSED(p_FmPcd);
34229 + UNUSED(p_FmPcdParams);
34230 +
34231 + p_FmPcdPlcr = (t_FmPcdPlcr *) XX_Malloc(sizeof(t_FmPcdPlcr));
34232 + if (!p_FmPcdPlcr)
34233 + {
34234 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Policer structure allocation FAILED"));
34235 + return NULL;
34236 + }
34237 + memset(p_FmPcdPlcr, 0, sizeof(t_FmPcdPlcr));
34238 + if (p_FmPcd->guestId == NCSW_MASTER_ID)
34239 + {
34240 + p_FmPcdPlcr->p_FmPcdPlcrRegs = (t_FmPcdPlcrRegs *)UINT_TO_PTR(FmGetPcdPlcrBaseAddr(p_FmPcdParams->h_Fm));
34241 + p_FmPcd->p_FmPcdDriverParam->plcrAutoRefresh = DEFAULT_plcrAutoRefresh;
34242 + p_FmPcd->exceptions |= (DEFAULT_fmPcdPlcrExceptions | DEFAULT_fmPcdPlcrErrorExceptions);
34243 + }
34244 +
34245 + p_FmPcdPlcr->numOfSharedProfiles = DEFAULT_numOfSharedPlcrProfiles;
34246 +
34247 + p_FmPcdPlcr->partPlcrProfilesBase = p_FmPcdParams->partPlcrProfilesBase;
34248 + p_FmPcdPlcr->partNumOfPlcrProfiles = p_FmPcdParams->partNumOfPlcrProfiles;
34249 + /* for backward compatabilty. if no policer profile, will set automatically to the max */
34250 + if ((p_FmPcd->guestId == NCSW_MASTER_ID) &&
34251 + (p_FmPcdPlcr->partNumOfPlcrProfiles == 0))
34252 + p_FmPcdPlcr->partNumOfPlcrProfiles = FM_PCD_PLCR_NUM_ENTRIES;
34253 +
34254 + for (i=0; i<FM_PCD_PLCR_NUM_ENTRIES; i++)
34255 + p_FmPcdPlcr->profiles[i].profilesMng.ownerId = (uint8_t)ILLEGAL_BASE;
34256 +
34257 + return p_FmPcdPlcr;
34258 +}
34259 +
34260 +t_Error PlcrInit(t_FmPcd *p_FmPcd)
34261 +{
34262 + t_FmPcdDriverParam *p_Param = p_FmPcd->p_FmPcdDriverParam;
34263 + t_FmPcdPlcr *p_FmPcdPlcr = p_FmPcd->p_FmPcdPlcr;
34264 + t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
34265 + t_Error err = E_OK;
34266 + uint32_t tmpReg32 = 0;
34267 + uint16_t base;
34268 +
34269 + if ((p_FmPcdPlcr->partPlcrProfilesBase + p_FmPcdPlcr->partNumOfPlcrProfiles) > FM_PCD_PLCR_NUM_ENTRIES)
34270 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("partPlcrProfilesBase+partNumOfPlcrProfiles out of range!!!"));
34271 +
34272 + p_FmPcdPlcr->h_HwSpinlock = XX_InitSpinlock();
34273 + if (!p_FmPcdPlcr->h_HwSpinlock)
34274 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FM Policer HW spinlock"));
34275 +
34276 + p_FmPcdPlcr->h_SwSpinlock = XX_InitSpinlock();
34277 + if (!p_FmPcdPlcr->h_SwSpinlock)
34278 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FM Policer SW spinlock"));
34279 +
34280 + base = PlcrAllocProfilesForPartition(p_FmPcd,
34281 + p_FmPcdPlcr->partPlcrProfilesBase,
34282 + p_FmPcdPlcr->partNumOfPlcrProfiles,
34283 + p_FmPcd->guestId);
34284 + if (base == (uint16_t)ILLEGAL_BASE)
34285 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
34286 +
34287 + if (p_FmPcdPlcr->numOfSharedProfiles)
34288 + {
34289 + err = AllocSharedProfiles(p_FmPcd,
34290 + p_FmPcdPlcr->numOfSharedProfiles,
34291 + p_FmPcdPlcr->sharedProfilesIds);
34292 + if (err)
34293 + RETURN_ERROR(MAJOR, err,NO_MSG);
34294 + }
34295 +
34296 + if (p_FmPcd->guestId != NCSW_MASTER_ID)
34297 + return E_OK;
34298 +
34299 + /**********************FMPL_GCR******************/
34300 + tmpReg32 = 0;
34301 + tmpReg32 |= FM_PCD_PLCR_GCR_STEN;
34302 + if (p_Param->plcrAutoRefresh)
34303 + tmpReg32 |= FM_PCD_PLCR_GCR_DAR;
34304 + tmpReg32 |= GET_NIA_BMI_AC_ENQ_FRAME(p_FmPcd);
34305 +
34306 + WRITE_UINT32(p_Regs->fmpl_gcr, tmpReg32);
34307 + /**********************FMPL_GCR******************/
34308 +
34309 + /**********************FMPL_EEVR******************/
34310 + WRITE_UINT32(p_Regs->fmpl_eevr, (FM_PCD_PLCR_DOUBLE_ECC | FM_PCD_PLCR_INIT_ENTRY_ERROR));
34311 + /**********************FMPL_EEVR******************/
34312 + /**********************FMPL_EIER******************/
34313 + tmpReg32 = 0;
34314 + if (p_FmPcd->exceptions & FM_PCD_EX_PLCR_DOUBLE_ECC)
34315 + {
34316 + FmEnableRamsEcc(p_FmPcd->h_Fm);
34317 + tmpReg32 |= FM_PCD_PLCR_DOUBLE_ECC;
34318 + }
34319 + if (p_FmPcd->exceptions & FM_PCD_EX_PLCR_INIT_ENTRY_ERROR)
34320 + tmpReg32 |= FM_PCD_PLCR_INIT_ENTRY_ERROR;
34321 + WRITE_UINT32(p_Regs->fmpl_eier, tmpReg32);
34322 + /**********************FMPL_EIER******************/
34323 +
34324 + /**********************FMPL_EVR******************/
34325 + WRITE_UINT32(p_Regs->fmpl_evr, (FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE | FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE));
34326 + /**********************FMPL_EVR******************/
34327 + /**********************FMPL_IER******************/
34328 + tmpReg32 = 0;
34329 + if (p_FmPcd->exceptions & FM_PCD_EX_PLCR_PRAM_SELF_INIT_COMPLETE)
34330 + tmpReg32 |= FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE;
34331 + if (p_FmPcd->exceptions & FM_PCD_EX_PLCR_ATOMIC_ACTION_COMPLETE)
34332 + tmpReg32 |= FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE;
34333 + WRITE_UINT32(p_Regs->fmpl_ier, tmpReg32);
34334 + /**********************FMPL_IER******************/
34335 +
34336 + /* register even if no interrupts enabled, to allow future enablement */
34337 + FmRegisterIntr(p_FmPcd->h_Fm,
34338 + e_FM_MOD_PLCR,
34339 + 0,
34340 + e_FM_INTR_TYPE_ERR,
34341 + ErrorExceptionsCB,
34342 + p_FmPcd);
34343 + FmRegisterIntr(p_FmPcd->h_Fm,
34344 + e_FM_MOD_PLCR,
34345 + 0,
34346 + e_FM_INTR_TYPE_NORMAL,
34347 + EventsCB,
34348 + p_FmPcd);
34349 +
34350 + /* driver initializes one DFLT profile at the last entry*/
34351 + /**********************FMPL_DPMR******************/
34352 + tmpReg32 = 0;
34353 + WRITE_UINT32(p_Regs->fmpl_dpmr, tmpReg32);
34354 + p_FmPcd->p_FmPcdPlcr->profiles[0].profilesMng.allocated = TRUE;
34355 +
34356 + return E_OK;
34357 +}
34358 +
34359 +t_Error PlcrFree(t_FmPcd *p_FmPcd)
34360 +{
34361 + FmUnregisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PLCR, 0, e_FM_INTR_TYPE_ERR);
34362 + FmUnregisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PLCR, 0, e_FM_INTR_TYPE_NORMAL);
34363 +
34364 + if (p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles)
34365 + FreeSharedProfiles(p_FmPcd,
34366 + p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles,
34367 + p_FmPcd->p_FmPcdPlcr->sharedProfilesIds);
34368 +
34369 + if (p_FmPcd->p_FmPcdPlcr->partNumOfPlcrProfiles)
34370 + PlcrFreeProfilesForPartition(p_FmPcd,
34371 + p_FmPcd->p_FmPcdPlcr->partPlcrProfilesBase,
34372 + p_FmPcd->p_FmPcdPlcr->partNumOfPlcrProfiles,
34373 + p_FmPcd->guestId);
34374 +
34375 + if (p_FmPcd->p_FmPcdPlcr->h_SwSpinlock)
34376 + XX_FreeSpinlock(p_FmPcd->p_FmPcdPlcr->h_SwSpinlock);
34377 +
34378 + if (p_FmPcd->p_FmPcdPlcr->h_HwSpinlock)
34379 + XX_FreeSpinlock(p_FmPcd->p_FmPcdPlcr->h_HwSpinlock);
34380 +
34381 + return E_OK;
34382 +}
34383 +
34384 +void PlcrEnable(t_FmPcd *p_FmPcd)
34385 +{
34386 + t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
34387 +
34388 + WRITE_UINT32(p_Regs->fmpl_gcr, GET_UINT32(p_Regs->fmpl_gcr) | FM_PCD_PLCR_GCR_EN);
34389 +}
34390 +
34391 +void PlcrDisable(t_FmPcd *p_FmPcd)
34392 +{
34393 + t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
34394 +
34395 + WRITE_UINT32(p_Regs->fmpl_gcr, GET_UINT32(p_Regs->fmpl_gcr) & ~FM_PCD_PLCR_GCR_EN);
34396 +}
34397 +
34398 +uint16_t PlcrAllocProfilesForPartition(t_FmPcd *p_FmPcd, uint16_t base, uint16_t numOfProfiles, uint8_t guestId)
34399 +{
34400 + uint32_t intFlags;
34401 + uint16_t profilesFound = 0;
34402 + int i = 0;
34403 +
34404 + ASSERT_COND(p_FmPcd);
34405 + ASSERT_COND(p_FmPcd->p_FmPcdPlcr);
34406 +
34407 + if (!numOfProfiles)
34408 + return 0;
34409 +
34410 + if ((numOfProfiles > FM_PCD_PLCR_NUM_ENTRIES) ||
34411 + (base + numOfProfiles > FM_PCD_PLCR_NUM_ENTRIES))
34412 + return (uint16_t)ILLEGAL_BASE;
34413 +
34414 + if (p_FmPcd->h_IpcSession)
34415 + {
34416 + t_FmIpcResourceAllocParams ipcAllocParams;
34417 + t_FmPcdIpcMsg msg;
34418 + t_FmPcdIpcReply reply;
34419 + t_Error err;
34420 + uint32_t replyLength;
34421 +
34422 + memset(&msg, 0, sizeof(msg));
34423 + memset(&reply, 0, sizeof(reply));
34424 + memset(&ipcAllocParams, 0, sizeof(t_FmIpcResourceAllocParams));
34425 + ipcAllocParams.guestId = p_FmPcd->guestId;
34426 + ipcAllocParams.num = p_FmPcd->p_FmPcdPlcr->partNumOfPlcrProfiles;
34427 + ipcAllocParams.base = p_FmPcd->p_FmPcdPlcr->partPlcrProfilesBase;
34428 + msg.msgId = FM_PCD_ALLOC_PROFILES;
34429 + memcpy(msg.msgBody, &ipcAllocParams, sizeof(t_FmIpcResourceAllocParams));
34430 + replyLength = sizeof(uint32_t) + sizeof(uint16_t);
34431 + err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
34432 + (uint8_t*)&msg,
34433 + sizeof(msg.msgId) + sizeof(t_FmIpcResourceAllocParams),
34434 + (uint8_t*)&reply,
34435 + &replyLength,
34436 + NULL,
34437 + NULL);
34438 + if ((err != E_OK) ||
34439 + (replyLength != (sizeof(uint32_t) + sizeof(uint16_t))))
34440 + {
34441 + REPORT_ERROR(MAJOR, err, NO_MSG);
34442 + return (uint16_t)ILLEGAL_BASE;
34443 + }
34444 + else
34445 + memcpy((uint8_t*)&p_FmPcd->p_FmPcdPlcr->partPlcrProfilesBase, reply.replyBody, sizeof(uint16_t));
34446 + if (p_FmPcd->p_FmPcdPlcr->partPlcrProfilesBase == (uint16_t)ILLEGAL_BASE)
34447 + {
34448 + REPORT_ERROR(MAJOR, err, NO_MSG);
34449 + return (uint16_t)ILLEGAL_BASE;
34450 + }
34451 + }
34452 + else if (p_FmPcd->guestId != NCSW_MASTER_ID)
34453 + {
34454 + DBG(WARNING, ("FM Guest mode, without IPC - can't validate Policer-profiles range!"));
34455 + return (uint16_t)ILLEGAL_BASE;
34456 + }
34457 +
34458 + intFlags = XX_LockIntrSpinlock(p_FmPcd->h_Spinlock);
34459 + for (i=base; i<(base+numOfProfiles); i++)
34460 + if (p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId == (uint8_t)ILLEGAL_BASE)
34461 + profilesFound++;
34462 + else
34463 + break;
34464 +
34465 + if (profilesFound == numOfProfiles)
34466 + for (i=base; i<(base+numOfProfiles); i++)
34467 + p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId = guestId;
34468 + else
34469 + {
34470 + XX_UnlockIntrSpinlock(p_FmPcd->h_Spinlock, intFlags);
34471 + return (uint16_t)ILLEGAL_BASE;
34472 + }
34473 + XX_UnlockIntrSpinlock(p_FmPcd->h_Spinlock, intFlags);
34474 +
34475 + return base;
34476 +}
34477 +
34478 +void PlcrFreeProfilesForPartition(t_FmPcd *p_FmPcd, uint16_t base, uint16_t numOfProfiles, uint8_t guestId)
34479 +{
34480 + int i = 0;
34481 +
34482 + ASSERT_COND(p_FmPcd);
34483 + ASSERT_COND(p_FmPcd->p_FmPcdPlcr);
34484 +
34485 + if (p_FmPcd->h_IpcSession)
34486 + {
34487 + t_FmIpcResourceAllocParams ipcAllocParams;
34488 + t_FmPcdIpcMsg msg;
34489 + t_Error err;
34490 +
34491 + memset(&msg, 0, sizeof(msg));
34492 + memset(&ipcAllocParams, 0, sizeof(t_FmIpcResourceAllocParams));
34493 + ipcAllocParams.guestId = p_FmPcd->guestId;
34494 + ipcAllocParams.num = p_FmPcd->p_FmPcdPlcr->partNumOfPlcrProfiles;
34495 + ipcAllocParams.base = p_FmPcd->p_FmPcdPlcr->partPlcrProfilesBase;
34496 + msg.msgId = FM_PCD_FREE_PROFILES;
34497 + memcpy(msg.msgBody, &ipcAllocParams, sizeof(t_FmIpcResourceAllocParams));
34498 + err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
34499 + (uint8_t*)&msg,
34500 + sizeof(msg.msgId) + sizeof(t_FmIpcResourceAllocParams),
34501 + NULL,
34502 + NULL,
34503 + NULL,
34504 + NULL);
34505 + if (err != E_OK)
34506 + REPORT_ERROR(MAJOR, err, NO_MSG);
34507 + return;
34508 + }
34509 + else if (p_FmPcd->guestId != NCSW_MASTER_ID)
34510 + {
34511 + DBG(WARNING, ("FM Guest mode, without IPC - can't validate Policer-profiles range!"));
34512 + return;
34513 + }
34514 +
34515 + for (i=base; i<(base+numOfProfiles); i++)
34516 + {
34517 + if (p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId == guestId)
34518 + p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId = (uint8_t)ILLEGAL_BASE;
34519 + else
34520 + DBG(WARNING, ("Request for freeing storage profile window which wasn't allocated to this partition"));
34521 + }
34522 +}
34523 +
34524 +t_Error PlcrSetPortProfiles(t_FmPcd *p_FmPcd,
34525 + uint8_t hardwarePortId,
34526 + uint16_t numOfProfiles,
34527 + uint16_t base)
34528 +{
34529 + t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
34530 + uint32_t log2Num, tmpReg32;
34531 +
34532 + if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
34533 + !p_Regs &&
34534 + p_FmPcd->h_IpcSession)
34535 + {
34536 + t_FmIpcResourceAllocParams ipcAllocParams;
34537 + t_FmPcdIpcMsg msg;
34538 + t_Error err;
34539 +
34540 + memset(&msg, 0, sizeof(msg));
34541 + memset(&ipcAllocParams, 0, sizeof(t_FmIpcResourceAllocParams));
34542 + ipcAllocParams.guestId = hardwarePortId;
34543 + ipcAllocParams.num = numOfProfiles;
34544 + ipcAllocParams.base = base;
34545 + msg.msgId = FM_PCD_SET_PORT_PROFILES;
34546 + memcpy(msg.msgBody, &ipcAllocParams, sizeof(t_FmIpcResourceAllocParams));
34547 + err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
34548 + (uint8_t*)&msg,
34549 + sizeof(msg.msgId) + sizeof(t_FmIpcResourceAllocParams),
34550 + NULL,
34551 + NULL,
34552 + NULL,
34553 + NULL);
34554 + if (err != E_OK)
34555 + RETURN_ERROR(MAJOR, err, NO_MSG);
34556 + return E_OK;
34557 + }
34558 + else if (!p_Regs)
34559 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
34560 + ("Either IPC or 'baseAddress' is required!"));
34561 +
34562 + ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
34563 +
34564 + if (GET_UINT32(p_Regs->fmpl_pmr[hardwarePortId-1]) & FM_PCD_PLCR_PMR_V)
34565 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
34566 + ("The requesting port has already an allocated profiles window."));
34567 +
34568 + /**********************FMPL_PMRx******************/
34569 + LOG2((uint64_t)numOfProfiles, log2Num);
34570 + tmpReg32 = base;
34571 + tmpReg32 |= log2Num << 16;
34572 + tmpReg32 |= FM_PCD_PLCR_PMR_V;
34573 + WRITE_UINT32(p_Regs->fmpl_pmr[hardwarePortId-1], tmpReg32);
34574 +
34575 + return E_OK;
34576 +}
34577 +
34578 +t_Error PlcrClearPortProfiles(t_FmPcd *p_FmPcd, uint8_t hardwarePortId)
34579 +{
34580 + t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
34581 +
34582 + if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
34583 + !p_Regs &&
34584 + p_FmPcd->h_IpcSession)
34585 + {
34586 + t_FmIpcResourceAllocParams ipcAllocParams;
34587 + t_FmPcdIpcMsg msg;
34588 + t_Error err;
34589 +
34590 + memset(&msg, 0, sizeof(msg));
34591 + memset(&ipcAllocParams, 0, sizeof(t_FmIpcResourceAllocParams));
34592 + ipcAllocParams.guestId = hardwarePortId;
34593 + msg.msgId = FM_PCD_CLEAR_PORT_PROFILES;
34594 + memcpy(msg.msgBody, &ipcAllocParams, sizeof(t_FmIpcResourceAllocParams));
34595 + err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
34596 + (uint8_t*)&msg,
34597 + sizeof(msg.msgId) + sizeof(t_FmIpcResourceAllocParams),
34598 + NULL,
34599 + NULL,
34600 + NULL,
34601 + NULL);
34602 + if (err != E_OK)
34603 + RETURN_ERROR(MAJOR, err, NO_MSG);
34604 + return E_OK;
34605 + }
34606 + else if (!p_Regs)
34607 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
34608 + ("Either IPC or 'baseAddress' is required!"));
34609 +
34610 + ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
34611 + WRITE_UINT32(p_Regs->fmpl_pmr[hardwarePortId-1], 0);
34612 +
34613 + return E_OK;
34614 +}
34615 +
34616 +t_Error FmPcdPlcrAllocProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId, uint16_t numOfProfiles)
34617 +{
34618 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
34619 + t_Error err = E_OK;
34620 + uint32_t profilesFound;
34621 + uint32_t intFlags;
34622 + uint16_t i, first, swPortIndex = 0;
34623 +
34624 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
34625 +
34626 + if (!numOfProfiles)
34627 + return E_OK;
34628 +
34629 + ASSERT_COND(hardwarePortId);
34630 +
34631 + if (numOfProfiles>FM_PCD_PLCR_NUM_ENTRIES)
34632 + RETURN_ERROR(MINOR, E_INVALID_VALUE, ("numProfiles is too big."));
34633 +
34634 + if (!POWER_OF_2(numOfProfiles))
34635 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numProfiles must be a power of 2."));
34636 +
34637 + first = 0;
34638 + profilesFound = 0;
34639 + intFlags = PlcrSwLock(p_FmPcd->p_FmPcdPlcr);
34640 +
34641 + for (i=0; i<FM_PCD_PLCR_NUM_ENTRIES; )
34642 + {
34643 + if (!p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated)
34644 + {
34645 + profilesFound++;
34646 + i++;
34647 + if (profilesFound == numOfProfiles)
34648 + break;
34649 + }
34650 + else
34651 + {
34652 + profilesFound = 0;
34653 + /* advance i to the next aligned address */
34654 + i = first = (uint16_t)(first + numOfProfiles);
34655 + }
34656 + }
34657 +
34658 + if (profilesFound == numOfProfiles)
34659 + {
34660 + for (i=first; i<first + numOfProfiles; i++)
34661 + {
34662 + p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated = TRUE;
34663 + p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId = hardwarePortId;
34664 + }
34665 + }
34666 + else
34667 + {
34668 + PlcrSwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
34669 + RETURN_ERROR(MINOR, E_FULL, ("No profiles."));
34670 + }
34671 + PlcrSwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
34672 +
34673 + err = PlcrSetPortProfiles(p_FmPcd, hardwarePortId, numOfProfiles, first);
34674 + if (err)
34675 + {
34676 + RETURN_ERROR(MAJOR, err, NO_MSG);
34677 + }
34678 +
34679 + HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
34680 +
34681 + p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles = numOfProfiles;
34682 + p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase = first;
34683 +
34684 + return E_OK;
34685 +}
34686 +
34687 +t_Error FmPcdPlcrFreeProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId)
34688 +{
34689 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
34690 + t_Error err = E_OK;
34691 + uint32_t intFlags;
34692 + uint16_t i, swPortIndex = 0;
34693 +
34694 + ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
34695 +
34696 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
34697 + SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
34698 +
34699 + HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
34700 +
34701 + err = PlcrClearPortProfiles(p_FmPcd, hardwarePortId);
34702 + if (err)
34703 + RETURN_ERROR(MAJOR, err,NO_MSG);
34704 +
34705 + intFlags = PlcrSwLock(p_FmPcd->p_FmPcdPlcr);
34706 + for (i=p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase;
34707 + i<(p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase +
34708 + p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles);
34709 + i++)
34710 + {
34711 + ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId == hardwarePortId);
34712 + ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated);
34713 +
34714 + p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated = FALSE;
34715 + p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId = p_FmPcd->guestId;
34716 + }
34717 + PlcrSwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
34718 +
34719 + p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles = 0;
34720 + p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase = 0;
34721 +
34722 + return E_OK;
34723 +}
34724 +
34725 +t_Error FmPcdPlcrCcGetSetParams(t_Handle h_FmPcd, uint16_t profileIndx ,uint32_t requiredAction)
34726 +{
34727 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
34728 + t_FmPcdPlcr *p_FmPcdPlcr = p_FmPcd->p_FmPcdPlcr;
34729 + t_FmPcdPlcrRegs *p_FmPcdPlcrRegs = p_FmPcdPlcr->p_FmPcdPlcrRegs;
34730 + uint32_t tmpReg32, intFlags;
34731 + t_Error err;
34732 +
34733 + /* Calling function locked all PCD modules, so no need to lock here */
34734 +
34735 + if (profileIndx >= FM_PCD_PLCR_NUM_ENTRIES)
34736 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,("Policer profile out of range"));
34737 +
34738 + if (!FmPcdPlcrIsProfileValid(p_FmPcd, profileIndx))
34739 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,("Policer profile is not valid"));
34740 +
34741 + /*intFlags = PlcrProfileLock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx]);*/
34742 +
34743 + if (p_FmPcd->h_Hc)
34744 + {
34745 + err = FmHcPcdPlcrCcGetSetParams(p_FmPcd->h_Hc, profileIndx, requiredAction);
34746 +
34747 + UpdateRequiredActionFlag(p_FmPcd, profileIndx, TRUE);
34748 + FmPcdPlcrUpdateRequiredAction(p_FmPcd, profileIndx, requiredAction);
34749 +
34750 + /*PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx], intFlags);*/
34751 + return err;
34752 + }
34753 +
34754 + /* lock the HW because once we read the registers we don't want them to be changed
34755 + * by another access. (We can copy to a tmp location and release the lock!) */
34756 +
34757 + intFlags = PlcrHwLock(p_FmPcdPlcr);
34758 + WritePar(p_FmPcd, FmPcdPlcrBuildReadPlcrActionReg(profileIndx));
34759 +
34760 + if (!p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].requiredActionFlag ||
34761 + !(p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].requiredAction & requiredAction))
34762 + {
34763 + if (requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
34764 + {
34765 + if ((p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].nextEngineOnGreen!= e_FM_PCD_DONE) ||
34766 + (p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].nextEngineOnYellow!= e_FM_PCD_DONE) ||
34767 + (p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].nextEngineOnRed!= e_FM_PCD_DONE))
34768 + {
34769 + PlcrHwUnlock(p_FmPcdPlcr, intFlags);
34770 + /*PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx], intFlags);*/
34771 + RETURN_ERROR (MAJOR, E_OK, ("In this case the next engine can be e_FM_PCD_DONE"));
34772 + }
34773 +
34774 + if (p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].paramsOnGreen.action == e_FM_PCD_ENQ_FRAME)
34775 + {
34776 + tmpReg32 = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pegnia);
34777 + if (!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
34778 + {
34779 + PlcrHwUnlock(p_FmPcdPlcr, intFlags);
34780 + /*PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx], intFlags);*/
34781 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
34782 + }
34783 + tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
34784 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pegnia, tmpReg32);
34785 + tmpReg32 = FmPcdPlcrBuildWritePlcrActionReg(profileIndx);
34786 + tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PEGNIA;
34787 + WritePar(p_FmPcd, tmpReg32);
34788 + }
34789 +
34790 + if (p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].paramsOnYellow.action == e_FM_PCD_ENQ_FRAME)
34791 + {
34792 + tmpReg32 = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_peynia);
34793 + if (!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
34794 + {
34795 + PlcrHwUnlock(p_FmPcdPlcr, intFlags);
34796 + /*PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx], intFlags);*/
34797 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
34798 + }
34799 + tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
34800 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_peynia, tmpReg32);
34801 + tmpReg32 = FmPcdPlcrBuildWritePlcrActionReg(profileIndx);
34802 + tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PEYNIA;
34803 + WritePar(p_FmPcd, tmpReg32);
34804 + PlcrHwUnlock(p_FmPcdPlcr, intFlags);
34805 + }
34806 +
34807 + if (p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].paramsOnRed.action == e_FM_PCD_ENQ_FRAME)
34808 + {
34809 + tmpReg32 = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pernia);
34810 + if (!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
34811 + {
34812 + PlcrHwUnlock(p_FmPcdPlcr, intFlags);
34813 + /*PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx], intFlags);*/
34814 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
34815 + }
34816 + tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
34817 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pernia, tmpReg32);
34818 + tmpReg32 = FmPcdPlcrBuildWritePlcrActionReg(profileIndx);
34819 + tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PERNIA;
34820 + WritePar(p_FmPcd, tmpReg32);
34821 +
34822 + }
34823 + }
34824 + }
34825 + PlcrHwUnlock(p_FmPcdPlcr, intFlags);
34826 +
34827 + UpdateRequiredActionFlag(p_FmPcd, profileIndx, TRUE);
34828 + FmPcdPlcrUpdateRequiredAction(p_FmPcd, profileIndx, requiredAction);
34829 +
34830 + /*PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx], intFlags);*/
34831 +
34832 + return E_OK;
34833 +}
34834 +
34835 +uint32_t FmPcdPlcrGetRequiredActionFlag(t_Handle h_FmPcd, uint16_t absoluteProfileId)
34836 +{
34837 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
34838 +
34839 + ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
34840 +
34841 + return p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredActionFlag;
34842 +}
34843 +
34844 +uint32_t FmPcdPlcrGetRequiredAction(t_Handle h_FmPcd, uint16_t absoluteProfileId)
34845 +{
34846 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
34847 +
34848 + ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
34849 +
34850 + return p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredAction;
34851 +}
34852 +
34853 +bool FmPcdPlcrIsProfileValid(t_Handle h_FmPcd, uint16_t absoluteProfileId)
34854 +{
34855 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
34856 + t_FmPcdPlcr *p_FmPcdPlcr = p_FmPcd->p_FmPcdPlcr;
34857 +
34858 + ASSERT_COND(absoluteProfileId < FM_PCD_PLCR_NUM_ENTRIES);
34859 +
34860 + return p_FmPcdPlcr->profiles[absoluteProfileId].valid;
34861 +}
34862 +
34863 +void FmPcdPlcrValidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId)
34864 +{
34865 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
34866 + uint32_t intFlags;
34867 +
34868 + ASSERT_COND(!p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
34869 +
34870 + intFlags = PlcrProfileLock(&p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId]);
34871 + p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid = TRUE;
34872 + PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId], intFlags);
34873 +}
34874 +
34875 +void FmPcdPlcrInvalidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId)
34876 +{
34877 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
34878 + uint32_t intFlags;
34879 +
34880 + ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
34881 +
34882 + intFlags = PlcrProfileLock(&p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId]);
34883 + p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid = FALSE;
34884 + PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId], intFlags);
34885 +}
34886 +
34887 +uint16_t FmPcdPlcrProfileGetAbsoluteId(t_Handle h_Profile)
34888 +{
34889 + return ((t_FmPcdPlcrProfile*)h_Profile)->absoluteProfileId;
34890 +}
34891 +
34892 +t_Error FmPcdPlcrGetAbsoluteIdByProfileParams(t_Handle h_FmPcd,
34893 + e_FmPcdProfileTypeSelection profileType,
34894 + t_Handle h_FmPort,
34895 + uint16_t relativeProfile,
34896 + uint16_t *p_AbsoluteId)
34897 +{
34898 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
34899 + t_FmPcdPlcr *p_FmPcdPlcr = p_FmPcd->p_FmPcdPlcr;
34900 + uint8_t i;
34901 +
34902 + switch (profileType)
34903 + {
34904 + case e_FM_PCD_PLCR_PORT_PRIVATE:
34905 + /* get port PCD id from port handle */
34906 + for (i=0;i<FM_MAX_NUM_OF_PORTS;i++)
34907 + if (p_FmPcd->p_FmPcdPlcr->portsMapping[i].h_FmPort == h_FmPort)
34908 + break;
34909 + if (i == FM_MAX_NUM_OF_PORTS)
34910 + RETURN_ERROR(MAJOR, E_INVALID_STATE , ("Invalid port handle."));
34911 +
34912 + if (!p_FmPcd->p_FmPcdPlcr->portsMapping[i].numOfProfiles)
34913 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION , ("Port has no allocated profiles"));
34914 + if (relativeProfile >= p_FmPcd->p_FmPcdPlcr->portsMapping[i].numOfProfiles)
34915 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION , ("Profile id is out of range"));
34916 + *p_AbsoluteId = (uint16_t)(p_FmPcd->p_FmPcdPlcr->portsMapping[i].profilesBase + relativeProfile);
34917 + break;
34918 + case e_FM_PCD_PLCR_SHARED:
34919 + if (relativeProfile >= p_FmPcdPlcr->numOfSharedProfiles)
34920 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION , ("Profile id is out of range"));
34921 + *p_AbsoluteId = (uint16_t)(p_FmPcdPlcr->sharedProfilesIds[relativeProfile]);
34922 + break;
34923 + default:
34924 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Invalid policer profile type"));
34925 + }
34926 +
34927 + return E_OK;
34928 +}
34929 +
34930 +uint16_t FmPcdPlcrGetPortProfilesBase(t_Handle h_FmPcd, uint8_t hardwarePortId)
34931 +{
34932 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
34933 + uint16_t swPortIndex = 0;
34934 +
34935 + HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
34936 +
34937 + return p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase;
34938 +}
34939 +
34940 +uint16_t FmPcdPlcrGetPortNumOfProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId)
34941 +{
34942 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
34943 + uint16_t swPortIndex = 0;
34944 +
34945 + HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
34946 +
34947 + return p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles;
34948 +
34949 +}
34950 +uint32_t FmPcdPlcrBuildWritePlcrActionReg(uint16_t absoluteProfileId)
34951 +{
34952 + return (uint32_t)(FM_PCD_PLCR_PAR_GO |
34953 + ((uint32_t)absoluteProfileId << FM_PCD_PLCR_PAR_PNUM_SHIFT));
34954 +}
34955 +
34956 +uint32_t FmPcdPlcrBuildWritePlcrActionRegs(uint16_t absoluteProfileId)
34957 +{
34958 + return (uint32_t)(FM_PCD_PLCR_PAR_GO |
34959 + ((uint32_t)absoluteProfileId << FM_PCD_PLCR_PAR_PNUM_SHIFT) |
34960 + FM_PCD_PLCR_PAR_PWSEL_MASK);
34961 +}
34962 +
34963 +bool FmPcdPlcrHwProfileIsValid(uint32_t profileModeReg)
34964 +{
34965 +
34966 + if (profileModeReg & FM_PCD_PLCR_PEMODE_PI)
34967 + return TRUE;
34968 + else
34969 + return FALSE;
34970 +}
34971 +
34972 +uint32_t FmPcdPlcrBuildReadPlcrActionReg(uint16_t absoluteProfileId)
34973 +{
34974 + return (uint32_t)(FM_PCD_PLCR_PAR_GO |
34975 + FM_PCD_PLCR_PAR_R |
34976 + ((uint32_t)absoluteProfileId << FM_PCD_PLCR_PAR_PNUM_SHIFT) |
34977 + FM_PCD_PLCR_PAR_PWSEL_MASK);
34978 +}
34979 +
34980 +uint32_t FmPcdPlcrBuildCounterProfileReg(e_FmPcdPlcrProfileCounters counter)
34981 +{
34982 + switch (counter)
34983 + {
34984 + case (e_FM_PCD_PLCR_PROFILE_GREEN_PACKET_TOTAL_COUNTER):
34985 + return FM_PCD_PLCR_PAR_PWSEL_PEGPC;
34986 + case (e_FM_PCD_PLCR_PROFILE_YELLOW_PACKET_TOTAL_COUNTER):
34987 + return FM_PCD_PLCR_PAR_PWSEL_PEYPC;
34988 + case (e_FM_PCD_PLCR_PROFILE_RED_PACKET_TOTAL_COUNTER) :
34989 + return FM_PCD_PLCR_PAR_PWSEL_PERPC;
34990 + case (e_FM_PCD_PLCR_PROFILE_RECOLOURED_YELLOW_PACKET_TOTAL_COUNTER) :
34991 + return FM_PCD_PLCR_PAR_PWSEL_PERYPC;
34992 + case (e_FM_PCD_PLCR_PROFILE_RECOLOURED_RED_PACKET_TOTAL_COUNTER) :
34993 + return FM_PCD_PLCR_PAR_PWSEL_PERRPC;
34994 + default:
34995 + REPORT_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
34996 + return 0;
34997 + }
34998 +}
34999 +
35000 +uint32_t FmPcdPlcrBuildNiaProfileReg(bool green, bool yellow, bool red)
35001 +{
35002 +
35003 + uint32_t tmpReg32 = 0;
35004 +
35005 + if (green)
35006 + tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PEGNIA;
35007 + if (yellow)
35008 + tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PEYNIA;
35009 + if (red)
35010 + tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PERNIA;
35011 +
35012 + return tmpReg32;
35013 +}
35014 +
35015 +void FmPcdPlcrUpdateRequiredAction(t_Handle h_FmPcd, uint16_t absoluteProfileId, uint32_t requiredAction)
35016 +{
35017 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
35018 +
35019 + /* this routine is protected by calling routine */
35020 +
35021 + ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
35022 +
35023 + p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredAction |= requiredAction;
35024 +}
35025 +
35026 +/*********************** End of inter-module routines ************************/
35027 +
35028 +
35029 +/**************************************************/
35030 +/*............Policer API.........................*/
35031 +/**************************************************/
35032 +
35033 +t_Error FM_PCD_ConfigPlcrAutoRefreshMode(t_Handle h_FmPcd, bool enable)
35034 +{
35035 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
35036 +
35037 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
35038 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
35039 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE);
35040 +
35041 + if (!FmIsMaster(p_FmPcd->h_Fm))
35042 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_ConfigPlcrAutoRefreshMode - guest mode!"));
35043 +
35044 + p_FmPcd->p_FmPcdDriverParam->plcrAutoRefresh = enable;
35045 +
35046 + return E_OK;
35047 +}
35048 +
35049 +t_Error FM_PCD_ConfigPlcrNumOfSharedProfiles(t_Handle h_FmPcd, uint16_t numOfSharedPlcrProfiles)
35050 +{
35051 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
35052 +
35053 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
35054 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
35055 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE);
35056 +
35057 + p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles = numOfSharedPlcrProfiles;
35058 +
35059 + return E_OK;
35060 +}
35061 +
35062 +t_Error FM_PCD_SetPlcrStatistics(t_Handle h_FmPcd, bool enable)
35063 +{
35064 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
35065 + uint32_t tmpReg32;
35066 +
35067 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
35068 + SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
35069 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE);
35070 +
35071 + if (!FmIsMaster(p_FmPcd->h_Fm))
35072 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_SetPlcrStatistics - guest mode!"));
35073 +
35074 + tmpReg32 = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_gcr);
35075 + if (enable)
35076 + tmpReg32 |= FM_PCD_PLCR_GCR_STEN;
35077 + else
35078 + tmpReg32 &= ~FM_PCD_PLCR_GCR_STEN;
35079 +
35080 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_gcr, tmpReg32);
35081 + return E_OK;
35082 +}
35083 +
35084 +t_Handle FM_PCD_PlcrProfileSet(t_Handle h_FmPcd,
35085 + t_FmPcdPlcrProfileParams *p_ProfileParams)
35086 +{
35087 + t_FmPcd *p_FmPcd;
35088 + t_FmPcdPlcrRegs *p_FmPcdPlcrRegs;
35089 + t_FmPcdPlcrProfileRegs plcrProfileReg;
35090 + uint32_t intFlags;
35091 + uint16_t absoluteProfileId;
35092 + t_Error err = E_OK;
35093 + uint32_t tmpReg32;
35094 + t_FmPcdPlcrProfile *p_Profile;
35095 +
35096 + SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);
35097 +
35098 + if (p_ProfileParams->modify)
35099 + {
35100 + p_Profile = (t_FmPcdPlcrProfile *)p_ProfileParams->id.h_Profile;
35101 + p_FmPcd = p_Profile->h_FmPcd;
35102 + absoluteProfileId = p_Profile->absoluteProfileId;
35103 + if (absoluteProfileId >= FM_PCD_PLCR_NUM_ENTRIES)
35104 + {
35105 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("profileId too Big "));
35106 + return NULL;
35107 + }
35108 +
35109 + SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE, NULL);
35110 +
35111 + /* Try lock profile using flag */
35112 + if (!PlcrProfileFlagTryLock(p_Profile))
35113 + {
35114 + DBG(TRACE, ("Profile Try Lock - BUSY"));
35115 + /* Signal to caller BUSY condition */
35116 + p_ProfileParams->id.h_Profile = NULL;
35117 + return NULL;
35118 + }
35119 + }
35120 + else
35121 + {
35122 + p_FmPcd = (t_FmPcd*)h_FmPcd;
35123 +
35124 + SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE, NULL);
35125 +
35126 + /* SMP: needs to be protected only if another core now changes the windows */
35127 + err = FmPcdPlcrGetAbsoluteIdByProfileParams(h_FmPcd,
35128 + p_ProfileParams->id.newParams.profileType,
35129 + p_ProfileParams->id.newParams.h_FmPort,
35130 + p_ProfileParams->id.newParams.relativeProfileId,
35131 + &absoluteProfileId);
35132 + if (err)
35133 + {
35134 + REPORT_ERROR(MAJOR, err, NO_MSG);
35135 + return NULL;
35136 + }
35137 +
35138 + if (absoluteProfileId >= FM_PCD_PLCR_NUM_ENTRIES)
35139 + {
35140 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("profileId too Big "));
35141 + return NULL;
35142 + }
35143 +
35144 + if (FmPcdPlcrIsProfileValid(p_FmPcd, absoluteProfileId))
35145 + {
35146 + REPORT_ERROR(MAJOR, E_ALREADY_EXISTS, ("Policer Profile is already used"));
35147 + return NULL;
35148 + }
35149 +
35150 + /* initialize profile struct */
35151 + p_Profile = &p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId];
35152 +
35153 + p_Profile->h_FmPcd = p_FmPcd;
35154 + p_Profile->absoluteProfileId = absoluteProfileId;
35155 +
35156 + p_Profile->p_Lock = FmPcdAcquireLock(p_FmPcd);
35157 + if (!p_Profile->p_Lock)
35158 + REPORT_ERROR(MAJOR, E_NOT_AVAILABLE, ("FM Policer Profile lock obj!"));
35159 + }
35160 +
35161 + SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE, NULL);
35162 +
35163 + p_Profile->nextEngineOnGreen = p_ProfileParams->nextEngineOnGreen;
35164 + memcpy(&p_Profile->paramsOnGreen, &(p_ProfileParams->paramsOnGreen), sizeof(u_FmPcdPlcrNextEngineParams));
35165 +
35166 + p_Profile->nextEngineOnYellow = p_ProfileParams->nextEngineOnYellow;
35167 + memcpy(&p_Profile->paramsOnYellow, &(p_ProfileParams->paramsOnYellow), sizeof(u_FmPcdPlcrNextEngineParams));
35168 +
35169 + p_Profile->nextEngineOnRed = p_ProfileParams->nextEngineOnRed;
35170 + memcpy(&p_Profile->paramsOnRed, &(p_ProfileParams->paramsOnRed), sizeof(u_FmPcdPlcrNextEngineParams));
35171 +
35172 + memset(&plcrProfileReg, 0, sizeof(t_FmPcdPlcrProfileRegs));
35173 +
35174 + /* build the policer profile registers */
35175 + err = BuildProfileRegs(h_FmPcd, p_ProfileParams, &plcrProfileReg);
35176 + if (err)
35177 + {
35178 + REPORT_ERROR(MAJOR, err, NO_MSG);
35179 + if (p_ProfileParams->modify)
35180 + /* unlock */
35181 + PlcrProfileFlagUnlock(p_Profile);
35182 + if (!p_ProfileParams->modify &&
35183 + p_Profile->p_Lock)
35184 + /* release allocated Profile lock */
35185 + FmPcdReleaseLock(p_FmPcd, p_Profile->p_Lock);
35186 + return NULL;
35187 + }
35188 +
35189 + if (p_FmPcd->h_Hc)
35190 + {
35191 + err = FmHcPcdPlcrSetProfile(p_FmPcd->h_Hc, (t_Handle)p_Profile, &plcrProfileReg);
35192 + if (p_ProfileParams->modify)
35193 + PlcrProfileFlagUnlock(p_Profile);
35194 + if (err)
35195 + {
35196 + /* release the allocated scheme lock */
35197 + if (!p_ProfileParams->modify &&
35198 + p_Profile->p_Lock)
35199 + FmPcdReleaseLock(p_FmPcd, p_Profile->p_Lock);
35200 +
35201 + return NULL;
35202 + }
35203 + if (!p_ProfileParams->modify)
35204 + FmPcdPlcrValidateProfileSw(p_FmPcd,absoluteProfileId);
35205 + return (t_Handle)p_Profile;
35206 + }
35207 +
35208 + p_FmPcdPlcrRegs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
35209 + SANITY_CHECK_RETURN_VALUE(p_FmPcdPlcrRegs, E_INVALID_HANDLE, NULL);
35210 +
35211 + intFlags = PlcrHwLock(p_FmPcd->p_FmPcdPlcr);
35212 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pemode , plcrProfileReg.fmpl_pemode);
35213 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pegnia , plcrProfileReg.fmpl_pegnia);
35214 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_peynia , plcrProfileReg.fmpl_peynia);
35215 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pernia , plcrProfileReg.fmpl_pernia);
35216 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pecir , plcrProfileReg.fmpl_pecir);
35217 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pecbs , plcrProfileReg.fmpl_pecbs);
35218 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pepepir_eir,plcrProfileReg.fmpl_pepepir_eir);
35219 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pepbs_ebs,plcrProfileReg.fmpl_pepbs_ebs);
35220 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pelts , plcrProfileReg.fmpl_pelts);
35221 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pects , plcrProfileReg.fmpl_pects);
35222 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pepts_ets,plcrProfileReg.fmpl_pepts_ets);
35223 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pegpc , plcrProfileReg.fmpl_pegpc);
35224 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_peypc , plcrProfileReg.fmpl_peypc);
35225 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_perpc , plcrProfileReg.fmpl_perpc);
35226 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_perypc , plcrProfileReg.fmpl_perypc);
35227 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_perrpc , plcrProfileReg.fmpl_perrpc);
35228 +
35229 + tmpReg32 = FmPcdPlcrBuildWritePlcrActionRegs(absoluteProfileId);
35230 + WritePar(p_FmPcd, tmpReg32);
35231 +
35232 + PlcrHwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
35233 +
35234 + if (!p_ProfileParams->modify)
35235 + FmPcdPlcrValidateProfileSw(p_FmPcd,absoluteProfileId);
35236 + else
35237 + PlcrProfileFlagUnlock(p_Profile);
35238 +
35239 + return (t_Handle)p_Profile;
35240 +}
35241 +
35242 +t_Error FM_PCD_PlcrProfileDelete(t_Handle h_Profile)
35243 +{
35244 + t_FmPcdPlcrProfile *p_Profile = (t_FmPcdPlcrProfile*)h_Profile;
35245 + t_FmPcd *p_FmPcd;
35246 + uint16_t profileIndx;
35247 + uint32_t tmpReg32, intFlags;
35248 + t_Error err;
35249 +
35250 + SANITY_CHECK_RETURN_ERROR(p_Profile, E_INVALID_HANDLE);
35251 + p_FmPcd = p_Profile->h_FmPcd;
35252 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
35253 +
35254 + profileIndx = p_Profile->absoluteProfileId;
35255 +
35256 + UpdateRequiredActionFlag(p_FmPcd, profileIndx, FALSE);
35257 +
35258 + FmPcdPlcrInvalidateProfileSw(p_FmPcd,profileIndx);
35259 +
35260 + if (p_FmPcd->h_Hc)
35261 + {
35262 + err = FmHcPcdPlcrDeleteProfile(p_FmPcd->h_Hc, h_Profile);
35263 + if (p_Profile->p_Lock)
35264 + /* release allocated Profile lock */
35265 + FmPcdReleaseLock(p_FmPcd, p_Profile->p_Lock);
35266 +
35267 + return err;
35268 + }
35269 +
35270 + intFlags = PlcrHwLock(p_FmPcd->p_FmPcdPlcr);
35271 + WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->profileRegs.fmpl_pemode, ~FM_PCD_PLCR_PEMODE_PI);
35272 +
35273 + tmpReg32 = FmPcdPlcrBuildWritePlcrActionRegs(profileIndx);
35274 + WritePar(p_FmPcd, tmpReg32);
35275 + PlcrHwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
35276 +
35277 +
35278 + if (p_Profile->p_Lock)
35279 + /* release allocated Profile lock */
35280 + FmPcdReleaseLock(p_FmPcd, p_Profile->p_Lock);
35281 +
35282 + /* we do not memset profile as all its fields are being re-initialized at "set",
35283 + * plus its allocation information is still valid. */
35284 + return E_OK;
35285 +}
35286 +
35287 +/***************************************************/
35288 +/*............Policer Profile Counter..............*/
35289 +/***************************************************/
35290 +uint32_t FM_PCD_PlcrProfileGetCounter(t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter)
35291 +{
35292 + t_FmPcdPlcrProfile *p_Profile = (t_FmPcdPlcrProfile*)h_Profile;
35293 + t_FmPcd *p_FmPcd;
35294 + uint16_t profileIndx;
35295 + uint32_t intFlags, counterVal = 0;
35296 + t_FmPcdPlcrRegs *p_FmPcdPlcrRegs;
35297 +
35298 + SANITY_CHECK_RETURN_ERROR(p_Profile, E_INVALID_HANDLE);
35299 + p_FmPcd = p_Profile->h_FmPcd;
35300 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
35301 +
35302 + if (p_FmPcd->h_Hc)
35303 + return FmHcPcdPlcrGetProfileCounter(p_FmPcd->h_Hc, h_Profile, counter);
35304 +
35305 + p_FmPcdPlcrRegs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
35306 + SANITY_CHECK_RETURN_VALUE(p_FmPcdPlcrRegs, E_INVALID_HANDLE, 0);
35307 +
35308 + profileIndx = p_Profile->absoluteProfileId;
35309 +
35310 + if (profileIndx >= FM_PCD_PLCR_NUM_ENTRIES)
35311 + {
35312 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("profileId too Big "));
35313 + return 0;
35314 + }
35315 + intFlags = PlcrHwLock(p_FmPcd->p_FmPcdPlcr);
35316 + WritePar(p_FmPcd, FmPcdPlcrBuildReadPlcrActionReg(profileIndx));
35317 +
35318 + switch (counter)
35319 + {
35320 + case e_FM_PCD_PLCR_PROFILE_GREEN_PACKET_TOTAL_COUNTER:
35321 + counterVal = (GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pegpc));
35322 + break;
35323 + case e_FM_PCD_PLCR_PROFILE_YELLOW_PACKET_TOTAL_COUNTER:
35324 + counterVal = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_peypc);
35325 + break;
35326 + case e_FM_PCD_PLCR_PROFILE_RED_PACKET_TOTAL_COUNTER:
35327 + counterVal = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_perpc);
35328 + break;
35329 + case e_FM_PCD_PLCR_PROFILE_RECOLOURED_YELLOW_PACKET_TOTAL_COUNTER:
35330 + counterVal = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_perypc);
35331 + break;
35332 + case e_FM_PCD_PLCR_PROFILE_RECOLOURED_RED_PACKET_TOTAL_COUNTER:
35333 + counterVal = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_perrpc);
35334 + break;
35335 + default:
35336 + REPORT_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
35337 + break;
35338 + }
35339 + PlcrHwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
35340 +
35341 + return counterVal;
35342 +}
35343 +
35344 +t_Error FM_PCD_PlcrProfileSetCounter(t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter, uint32_t value)
35345 +{
35346 + t_FmPcdPlcrProfile *p_Profile = (t_FmPcdPlcrProfile*)h_Profile;
35347 + t_FmPcd *p_FmPcd;
35348 + uint16_t profileIndx;
35349 + uint32_t tmpReg32, intFlags;
35350 + t_FmPcdPlcrRegs *p_FmPcdPlcrRegs;
35351 +
35352 + SANITY_CHECK_RETURN_ERROR(p_Profile, E_INVALID_HANDLE);
35353 +
35354 + p_FmPcd = p_Profile->h_FmPcd;
35355 + profileIndx = p_Profile->absoluteProfileId;
35356 +
35357 + if (p_FmPcd->h_Hc)
35358 + return FmHcPcdPlcrSetProfileCounter(p_FmPcd->h_Hc, h_Profile, counter, value);
35359 +
35360 + p_FmPcdPlcrRegs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
35361 + SANITY_CHECK_RETURN_ERROR(p_FmPcdPlcrRegs, E_INVALID_HANDLE);
35362 +
35363 + intFlags = PlcrHwLock(p_FmPcd->p_FmPcdPlcr);
35364 + switch (counter)
35365 + {
35366 + case e_FM_PCD_PLCR_PROFILE_GREEN_PACKET_TOTAL_COUNTER:
35367 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pegpc, value);
35368 + break;
35369 + case e_FM_PCD_PLCR_PROFILE_YELLOW_PACKET_TOTAL_COUNTER:
35370 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_peypc, value);
35371 + break;
35372 + case e_FM_PCD_PLCR_PROFILE_RED_PACKET_TOTAL_COUNTER:
35373 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_perpc, value);
35374 + break;
35375 + case e_FM_PCD_PLCR_PROFILE_RECOLOURED_YELLOW_PACKET_TOTAL_COUNTER:
35376 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_perypc ,value);
35377 + break;
35378 + case e_FM_PCD_PLCR_PROFILE_RECOLOURED_RED_PACKET_TOTAL_COUNTER:
35379 + WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_perrpc ,value);
35380 + break;
35381 + default:
35382 + PlcrHwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
35383 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
35384 + }
35385 +
35386 + /* Activate the atomic write action by writing FMPL_PAR with: GO=1, RW=1, PSI=0, PNUM =
35387 + * Profile Number, PWSEL=0xFFFF (select all words).
35388 + */
35389 + tmpReg32 = FmPcdPlcrBuildWritePlcrActionReg(profileIndx);
35390 + tmpReg32 |= FmPcdPlcrBuildCounterProfileReg(counter);
35391 + WritePar(p_FmPcd, tmpReg32);
35392 + PlcrHwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
35393 +
35394 + return E_OK;
35395 +}
35396 --- /dev/null
35397 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_plcr.h
35398 @@ -0,0 +1,165 @@
35399 +/*
35400 + * Copyright 2008-2012 Freescale Semiconductor Inc.
35401 + *
35402 + * Redistribution and use in source and binary forms, with or without
35403 + * modification, are permitted provided that the following conditions are met:
35404 + * * Redistributions of source code must retain the above copyright
35405 + * notice, this list of conditions and the following disclaimer.
35406 + * * Redistributions in binary form must reproduce the above copyright
35407 + * notice, this list of conditions and the following disclaimer in the
35408 + * documentation and/or other materials provided with the distribution.
35409 + * * Neither the name of Freescale Semiconductor nor the
35410 + * names of its contributors may be used to endorse or promote products
35411 + * derived from this software without specific prior written permission.
35412 + *
35413 + *
35414 + * ALTERNATIVELY, this software may be distributed under the terms of the
35415 + * GNU General Public License ("GPL") as published by the Free Software
35416 + * Foundation, either version 2 of that License or (at your option) any
35417 + * later version.
35418 + *
35419 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
35420 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35421 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35422 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
35423 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35424 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35425 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35426 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35427 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35428 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35429 + */
35430 +
35431 +
35432 +/******************************************************************************
35433 + @File fm_plcr.h
35434 +
35435 + @Description FM Policer private header
35436 +*//***************************************************************************/
35437 +#ifndef __FM_PLCR_H
35438 +#define __FM_PLCR_H
35439 +
35440 +#include "std_ext.h"
35441 +
35442 +
35443 +/***********************************************************************/
35444 +/* Policer defines */
35445 +/***********************************************************************/
35446 +
35447 +#define FM_PCD_PLCR_PAR_GO 0x80000000
35448 +#define FM_PCD_PLCR_PAR_PWSEL_MASK 0x0000FFFF
35449 +#define FM_PCD_PLCR_PAR_R 0x40000000
35450 +
35451 +/* shifts */
35452 +#define FM_PCD_PLCR_PAR_PNUM_SHIFT 16
35453 +
35454 +/* masks */
35455 +#define FM_PCD_PLCR_PEMODE_PI 0x80000000
35456 +#define FM_PCD_PLCR_PEMODE_CBLND 0x40000000
35457 +#define FM_PCD_PLCR_PEMODE_ALG_MASK 0x30000000
35458 +#define FM_PCD_PLCR_PEMODE_ALG_RFC2698 0x10000000
35459 +#define FM_PCD_PLCR_PEMODE_ALG_RFC4115 0x20000000
35460 +#define FM_PCD_PLCR_PEMODE_DEFC_MASK 0x0C000000
35461 +#define FM_PCD_PLCR_PEMODE_DEFC_Y 0x04000000
35462 +#define FM_PCD_PLCR_PEMODE_DEFC_R 0x08000000
35463 +#define FM_PCD_PLCR_PEMODE_DEFC_OVERRIDE 0x0C000000
35464 +#define FM_PCD_PLCR_PEMODE_OVCLR_MASK 0x03000000
35465 +#define FM_PCD_PLCR_PEMODE_OVCLR_Y 0x01000000
35466 +#define FM_PCD_PLCR_PEMODE_OVCLR_R 0x02000000
35467 +#define FM_PCD_PLCR_PEMODE_OVCLR_G_NC 0x03000000
35468 +#define FM_PCD_PLCR_PEMODE_PKT 0x00800000
35469 +#define FM_PCD_PLCR_PEMODE_FPP_MASK 0x001F0000
35470 +#define FM_PCD_PLCR_PEMODE_FPP_SHIFT 16
35471 +#define FM_PCD_PLCR_PEMODE_FLS_MASK 0x0000F000
35472 +#define FM_PCD_PLCR_PEMODE_FLS_L2 0x00003000
35473 +#define FM_PCD_PLCR_PEMODE_FLS_L3 0x0000B000
35474 +#define FM_PCD_PLCR_PEMODE_FLS_L4 0x0000E000
35475 +#define FM_PCD_PLCR_PEMODE_FLS_FULL 0x0000F000
35476 +#define FM_PCD_PLCR_PEMODE_RBFLS 0x00000800
35477 +#define FM_PCD_PLCR_PEMODE_TRA 0x00000004
35478 +#define FM_PCD_PLCR_PEMODE_TRB 0x00000002
35479 +#define FM_PCD_PLCR_PEMODE_TRC 0x00000001
35480 +#define FM_PCD_PLCR_DOUBLE_ECC 0x80000000
35481 +#define FM_PCD_PLCR_INIT_ENTRY_ERROR 0x40000000
35482 +#define FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE 0x80000000
35483 +#define FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE 0x40000000
35484 +
35485 +#define FM_PCD_PLCR_NIA_VALID 0x80000000
35486 +
35487 +#define FM_PCD_PLCR_GCR_EN 0x80000000
35488 +#define FM_PCD_PLCR_GCR_STEN 0x40000000
35489 +#define FM_PCD_PLCR_GCR_DAR 0x20000000
35490 +#define FM_PCD_PLCR_GCR_DEFNIA 0x00FFFFFF
35491 +#define FM_PCD_PLCR_NIA_ABS 0x00000100
35492 +
35493 +#define FM_PCD_PLCR_GSR_BSY 0x80000000
35494 +#define FM_PCD_PLCR_GSR_DQS 0x60000000
35495 +#define FM_PCD_PLCR_GSR_RPB 0x20000000
35496 +#define FM_PCD_PLCR_GSR_FQS 0x0C000000
35497 +#define FM_PCD_PLCR_GSR_LPALG 0x0000C000
35498 +#define FM_PCD_PLCR_GSR_LPCA 0x00003000
35499 +#define FM_PCD_PLCR_GSR_LPNUM 0x000000FF
35500 +
35501 +#define FM_PCD_PLCR_EVR_PSIC 0x80000000
35502 +#define FM_PCD_PLCR_EVR_AAC 0x40000000
35503 +
35504 +#define FM_PCD_PLCR_PAR_PSI 0x20000000
35505 +#define FM_PCD_PLCR_PAR_PNUM 0x00FF0000
35506 +/* PWSEL Selctive select options */
35507 +#define FM_PCD_PLCR_PAR_PWSEL_PEMODE 0x00008000 /* 0 */
35508 +#define FM_PCD_PLCR_PAR_PWSEL_PEGNIA 0x00004000 /* 1 */
35509 +#define FM_PCD_PLCR_PAR_PWSEL_PEYNIA 0x00002000 /* 2 */
35510 +#define FM_PCD_PLCR_PAR_PWSEL_PERNIA 0x00001000 /* 3 */
35511 +#define FM_PCD_PLCR_PAR_PWSEL_PECIR 0x00000800 /* 4 */
35512 +#define FM_PCD_PLCR_PAR_PWSEL_PECBS 0x00000400 /* 5 */
35513 +#define FM_PCD_PLCR_PAR_PWSEL_PEPIR_EIR 0x00000200 /* 6 */
35514 +#define FM_PCD_PLCR_PAR_PWSEL_PEPBS_EBS 0x00000100 /* 7 */
35515 +#define FM_PCD_PLCR_PAR_PWSEL_PELTS 0x00000080 /* 8 */
35516 +#define FM_PCD_PLCR_PAR_PWSEL_PECTS 0x00000040 /* 9 */
35517 +#define FM_PCD_PLCR_PAR_PWSEL_PEPTS_ETS 0x00000020 /* 10 */
35518 +#define FM_PCD_PLCR_PAR_PWSEL_PEGPC 0x00000010 /* 11 */
35519 +#define FM_PCD_PLCR_PAR_PWSEL_PEYPC 0x00000008 /* 12 */
35520 +#define FM_PCD_PLCR_PAR_PWSEL_PERPC 0x00000004 /* 13 */
35521 +#define FM_PCD_PLCR_PAR_PWSEL_PERYPC 0x00000002 /* 14 */
35522 +#define FM_PCD_PLCR_PAR_PWSEL_PERRPC 0x00000001 /* 15 */
35523 +
35524 +#define FM_PCD_PLCR_PAR_PMR_BRN_1TO1 0x0000 /* - Full bit replacement. {PBNUM[0:N-1]
35525 + 1-> 2^N specific locations. */
35526 +#define FM_PCD_PLCR_PAR_PMR_BRN_2TO2 0x1 /* - {PBNUM[0:N-2],PNUM[N-1]}.
35527 + 2-> 2^(N-1) base locations. */
35528 +#define FM_PCD_PLCR_PAR_PMR_BRN_4TO4 0x2 /* - {PBNUM[0:N-3],PNUM[N-2:N-1]}.
35529 + 4-> 2^(N-2) base locations. */
35530 +#define FM_PCD_PLCR_PAR_PMR_BRN_8TO8 0x3 /* - {PBNUM[0:N-4],PNUM[N-3:N-1]}.
35531 + 8->2^(N-3) base locations. */
35532 +#define FM_PCD_PLCR_PAR_PMR_BRN_16TO16 0x4 /* - {PBNUM[0:N-5],PNUM[N-4:N-1]}.
35533 + 16-> 2^(N-4) base locations. */
35534 +#define FM_PCD_PLCR_PAR_PMR_BRN_32TO32 0x5 /* {PBNUM[0:N-6],PNUM[N-5:N-1]}.
35535 + 32-> 2^(N-5) base locations. */
35536 +#define FM_PCD_PLCR_PAR_PMR_BRN_64TO64 0x6 /* {PBNUM[0:N-7],PNUM[N-6:N-1]}.
35537 + 64-> 2^(N-6) base locations. */
35538 +#define FM_PCD_PLCR_PAR_PMR_BRN_128TO128 0x7 /* {PBNUM[0:N-8],PNUM[N-7:N-1]}.
35539 + 128-> 2^(N-7) base locations. */
35540 +#define FM_PCD_PLCR_PAR_PMR_BRN_256TO256 0x8 /* - No bit replacement for N=8. {PNUM[N-8:N-1]}.
35541 + When N=8 this option maps all 256 profiles by the DISPATCH bus into one group. */
35542 +
35543 +#define FM_PCD_PLCR_PMR_V 0x80000000
35544 +#define PLCR_ERR_ECC_CAP 0x80000000
35545 +#define PLCR_ERR_ECC_TYPE_DOUBLE 0x40000000
35546 +#define PLCR_ERR_ECC_PNUM_MASK 0x00000FF0
35547 +#define PLCR_ERR_ECC_OFFSET_MASK 0x0000000F
35548 +
35549 +#define PLCR_ERR_UNINIT_CAP 0x80000000
35550 +#define PLCR_ERR_UNINIT_NUM_MASK 0x000000FF
35551 +#define PLCR_ERR_UNINIT_PID_MASK 0x003f0000
35552 +#define PLCR_ERR_UNINIT_ABSOLUTE_MASK 0x00008000
35553 +
35554 +/* shifts */
35555 +#define PLCR_ERR_ECC_PNUM_SHIFT 4
35556 +#define PLCR_ERR_UNINIT_PID_SHIFT 16
35557 +
35558 +#define FM_PCD_PLCR_PMR_BRN_SHIFT 16
35559 +
35560 +#define PLCR_PORT_WINDOW_SIZE(hardwarePortId)
35561 +
35562 +
35563 +#endif /* __FM_PLCR_H */
35564 --- /dev/null
35565 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_prs.c
35566 @@ -0,0 +1,422 @@
35567 +/*
35568 + * Copyright 2008-2012 Freescale Semiconductor Inc.
35569 + *
35570 + * Redistribution and use in source and binary forms, with or without
35571 + * modification, are permitted provided that the following conditions are met:
35572 + * * Redistributions of source code must retain the above copyright
35573 + * notice, this list of conditions and the following disclaimer.
35574 + * * Redistributions in binary form must reproduce the above copyright
35575 + * notice, this list of conditions and the following disclaimer in the
35576 + * documentation and/or other materials provided with the distribution.
35577 + * * Neither the name of Freescale Semiconductor nor the
35578 + * names of its contributors may be used to endorse or promote products
35579 + * derived from this software without specific prior written permission.
35580 + *
35581 + *
35582 + * ALTERNATIVELY, this software may be distributed under the terms of the
35583 + * GNU General Public License ("GPL") as published by the Free Software
35584 + * Foundation, either version 2 of that License or (at your option) any
35585 + * later version.
35586 + *
35587 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
35588 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35589 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35590 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
35591 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35592 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35593 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35594 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35595 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35596 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35597 + */
35598 +
35599 +
35600 +/******************************************************************************
35601 + @File fm_pcd.c
35602 +
35603 + @Description FM PCD ...
35604 +*//***************************************************************************/
35605 +#include "std_ext.h"
35606 +#include "error_ext.h"
35607 +#include "string_ext.h"
35608 +#include "debug_ext.h"
35609 +#include "net_ext.h"
35610 +
35611 +#include "fm_common.h"
35612 +#include "fm_pcd.h"
35613 +#include "fm_pcd_ipc.h"
35614 +#include "fm_prs.h"
35615 +#include "fsl_fman_prs.h"
35616 +
35617 +
35618 +static void PcdPrsErrorException(t_Handle h_FmPcd)
35619 +{
35620 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
35621 + uint32_t event, ev_mask;
35622 + struct fman_prs_regs *PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
35623 +
35624 + ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
35625 + ev_mask = fman_prs_get_err_ev_mask(PrsRegs);
35626 +
35627 + event = fman_prs_get_err_event(PrsRegs, ev_mask);
35628 +
35629 + fman_prs_ack_err_event(PrsRegs, event);
35630 +
35631 + DBG(TRACE, ("parser error - 0x%08x\n",event));
35632 +
35633 + if(event & FM_PCD_PRS_DOUBLE_ECC)
35634 + p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC);
35635 +}
35636 +
35637 +static void PcdPrsException(t_Handle h_FmPcd)
35638 +{
35639 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
35640 + uint32_t event, ev_mask;
35641 + struct fman_prs_regs *PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
35642 +
35643 + ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
35644 + ev_mask = fman_prs_get_expt_ev_mask(PrsRegs);
35645 + event = fman_prs_get_expt_event(PrsRegs, ev_mask);
35646 +
35647 + ASSERT_COND(event & FM_PCD_PRS_SINGLE_ECC);
35648 +
35649 + DBG(TRACE, ("parser event - 0x%08x\n",event));
35650 +
35651 + fman_prs_ack_expt_event(PrsRegs, event);
35652 +
35653 + p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC);
35654 +}
35655 +
35656 +t_Handle PrsConfig(t_FmPcd *p_FmPcd,t_FmPcdParams *p_FmPcdParams)
35657 +{
35658 + t_FmPcdPrs *p_FmPcdPrs;
35659 + uintptr_t baseAddr;
35660 +
35661 + UNUSED(p_FmPcd);
35662 + UNUSED(p_FmPcdParams);
35663 +
35664 + p_FmPcdPrs = (t_FmPcdPrs *) XX_Malloc(sizeof(t_FmPcdPrs));
35665 + if (!p_FmPcdPrs)
35666 + {
35667 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Parser structure allocation FAILED"));
35668 + return NULL;
35669 + }
35670 + memset(p_FmPcdPrs, 0, sizeof(t_FmPcdPrs));
35671 + fman_prs_defconfig(&p_FmPcd->p_FmPcdDriverParam->dfltCfg);
35672 +
35673 + if (p_FmPcd->guestId == NCSW_MASTER_ID)
35674 + {
35675 + baseAddr = FmGetPcdPrsBaseAddr(p_FmPcdParams->h_Fm);
35676 + p_FmPcdPrs->p_SwPrsCode = (uint32_t *)UINT_TO_PTR(baseAddr);
35677 + p_FmPcdPrs->p_FmPcdPrsRegs = (struct fman_prs_regs *)UINT_TO_PTR(baseAddr + PRS_REGS_OFFSET);
35678 + }
35679 +
35680 + p_FmPcdPrs->fmPcdPrsPortIdStatistics = p_FmPcd->p_FmPcdDriverParam->dfltCfg.port_id_stat;
35681 + p_FmPcd->p_FmPcdDriverParam->prsMaxParseCycleLimit = p_FmPcd->p_FmPcdDriverParam->dfltCfg.max_prs_cyc_lim;
35682 + p_FmPcd->exceptions |= p_FmPcd->p_FmPcdDriverParam->dfltCfg.prs_exceptions;
35683 +
35684 + return p_FmPcdPrs;
35685 +}
35686 +
35687 +#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
35688 + static uint8_t swPrsPatch[] = SW_PRS_UDP_LITE_PATCH;
35689 +#else
35690 + static uint8_t swPrsPatch[] = SW_PRS_OFFLOAD_PATCH;
35691 +#endif /* FM_CAPWAP_SUPPORT */
35692 +
35693 +t_Error PrsInit(t_FmPcd *p_FmPcd)
35694 +{
35695 + t_FmPcdDriverParam *p_Param = p_FmPcd->p_FmPcdDriverParam;
35696 + uint32_t *p_TmpCode;
35697 + uint32_t *p_LoadTarget = (uint32_t *)PTR_MOVE(p_FmPcd->p_FmPcdPrs->p_SwPrsCode,
35698 + FM_PCD_SW_PRS_SIZE-FM_PCD_PRS_SW_PATCHES_SIZE);
35699 + struct fman_prs_regs *PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
35700 + uint32_t i;
35701 +
35702 + ASSERT_COND(sizeof(swPrsPatch) <= (FM_PCD_PRS_SW_PATCHES_SIZE-FM_PCD_PRS_SW_TAIL_SIZE));
35703 +
35704 + /* nothing to do in guest-partition */
35705 + if (p_FmPcd->guestId != NCSW_MASTER_ID)
35706 + return E_OK;
35707 +
35708 + p_TmpCode = (uint32_t *)XX_MallocSmart(ROUND_UP(sizeof(swPrsPatch),4), 0, sizeof(uint32_t));
35709 + if (!p_TmpCode)
35710 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Tmp Sw-Parser code allocation FAILED"));
35711 + memset((uint8_t *)p_TmpCode, 0, ROUND_UP(sizeof(swPrsPatch),4));
35712 + memcpy((uint8_t *)p_TmpCode, (uint8_t *)swPrsPatch, sizeof(swPrsPatch));
35713 +
35714 + fman_prs_init(PrsRegs, &p_Param->dfltCfg);
35715 +
35716 + /* register even if no interrupts enabled, to allow future enablement */
35717 + FmRegisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PRS, 0, e_FM_INTR_TYPE_ERR, PcdPrsErrorException, p_FmPcd);
35718 +
35719 + /* register even if no interrupts enabled, to allow future enablement */
35720 + FmRegisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PRS, 0, e_FM_INTR_TYPE_NORMAL, PcdPrsException, p_FmPcd);
35721 +
35722 + if(p_FmPcd->exceptions & FM_PCD_EX_PRS_SINGLE_ECC)
35723 + FmEnableRamsEcc(p_FmPcd->h_Fm);
35724 +
35725 + if(p_FmPcd->exceptions & FM_PCD_EX_PRS_DOUBLE_ECC)
35726 + FmEnableRamsEcc(p_FmPcd->h_Fm);
35727 +
35728 + /* load sw parser Ip-Frag patch */
35729 + for (i=0; i<DIV_CEIL(sizeof(swPrsPatch), 4); i++)
35730 + WRITE_UINT32(p_LoadTarget[i], GET_UINT32(p_TmpCode[i]));
35731 +
35732 + XX_FreeSmart(p_TmpCode);
35733 +
35734 + return E_OK;
35735 +}
35736 +
35737 +void PrsFree(t_FmPcd *p_FmPcd)
35738 +{
35739 + ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
35740 + FmUnregisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PRS, 0, e_FM_INTR_TYPE_ERR);
35741 + /* register even if no interrupts enabled, to allow future enablement */
35742 + FmUnregisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PRS, 0, e_FM_INTR_TYPE_NORMAL);
35743 +}
35744 +
35745 +void PrsEnable(t_FmPcd *p_FmPcd)
35746 +{
35747 + struct fman_prs_regs *PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
35748 +
35749 + ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
35750 + fman_prs_enable(PrsRegs);
35751 +}
35752 +
35753 +void PrsDisable(t_FmPcd *p_FmPcd)
35754 +{
35755 + struct fman_prs_regs *PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
35756 +
35757 + ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
35758 + fman_prs_disable(PrsRegs);
35759 +}
35760 +
35761 +int PrsIsEnabled(t_FmPcd *p_FmPcd)
35762 +{
35763 + struct fman_prs_regs *PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
35764 +
35765 + ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
35766 + return fman_prs_is_enabled(PrsRegs);
35767 +}
35768 +
35769 +t_Error PrsIncludePortInStatistics(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, bool include)
35770 +{
35771 + struct fman_prs_regs *PrsRegs;
35772 + uint32_t bitMask = 0;
35773 + uint8_t prsPortId;
35774 +
35775 + SANITY_CHECK_RETURN_ERROR((hardwarePortId >=1 && hardwarePortId <= 16), E_INVALID_VALUE);
35776 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
35777 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPrs, E_INVALID_HANDLE);
35778 +
35779 + PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
35780 +
35781 + GET_FM_PCD_PRS_PORT_ID(prsPortId, hardwarePortId);
35782 + GET_FM_PCD_INDEX_FLAG(bitMask, prsPortId);
35783 +
35784 + if (include)
35785 + p_FmPcd->p_FmPcdPrs->fmPcdPrsPortIdStatistics |= bitMask;
35786 + else
35787 + p_FmPcd->p_FmPcdPrs->fmPcdPrsPortIdStatistics &= ~bitMask;
35788 +
35789 + fman_prs_set_stst_port_msk(PrsRegs,
35790 + p_FmPcd->p_FmPcdPrs->fmPcdPrsPortIdStatistics);
35791 +
35792 + return E_OK;
35793 +}
35794 +
35795 +t_Error FmPcdPrsIncludePortInStatistics(t_Handle h_FmPcd, uint8_t hardwarePortId, bool include)
35796 +{
35797 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
35798 + t_Error err;
35799 +
35800 + SANITY_CHECK_RETURN_ERROR((hardwarePortId >=1 && hardwarePortId <= 16), E_INVALID_VALUE);
35801 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
35802 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPrs, E_INVALID_HANDLE);
35803 +
35804 + if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
35805 + p_FmPcd->h_IpcSession)
35806 + {
35807 + t_FmPcdIpcPrsIncludePort prsIncludePortParams;
35808 + t_FmPcdIpcMsg msg;
35809 +
35810 + prsIncludePortParams.hardwarePortId = hardwarePortId;
35811 + prsIncludePortParams.include = include;
35812 + memset(&msg, 0, sizeof(msg));
35813 + msg.msgId = FM_PCD_PRS_INC_PORT_STATS;
35814 + memcpy(msg.msgBody, &prsIncludePortParams, sizeof(prsIncludePortParams));
35815 + err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
35816 + (uint8_t*)&msg,
35817 + sizeof(msg.msgId) +sizeof(prsIncludePortParams),
35818 + NULL,
35819 + NULL,
35820 + NULL,
35821 + NULL);
35822 + if (err != E_OK)
35823 + RETURN_ERROR(MAJOR, err, NO_MSG);
35824 + return E_OK;
35825 + }
35826 + else if (p_FmPcd->guestId != NCSW_MASTER_ID)
35827 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
35828 + ("running in guest-mode without IPC!"));
35829 +
35830 + return PrsIncludePortInStatistics(p_FmPcd, hardwarePortId, include);
35831 +}
35832 +
35833 +uint32_t FmPcdGetSwPrsOffset(t_Handle h_FmPcd, e_NetHeaderType hdr, uint8_t indexPerHdr)
35834 +{
35835 + t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
35836 + t_FmPcdPrsLabelParams *p_Label;
35837 + int i;
35838 +
35839 + SANITY_CHECK_RETURN_VALUE(p_FmPcd, E_INVALID_HANDLE, 0);
35840 + SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE, 0);
35841 +
35842 + if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
35843 + p_FmPcd->h_IpcSession)
35844 + {
35845 + t_Error err = E_OK;
35846 + t_FmPcdIpcSwPrsLable labelParams;
35847 + t_FmPcdIpcMsg msg;
35848 + uint32_t prsOffset = 0;
35849 + t_FmPcdIpcReply reply;
35850 + uint32_t replyLength;
35851 +
35852 + memset(&reply, 0, sizeof(reply));
35853 + memset(&msg, 0, sizeof(msg));
35854 + labelParams.enumHdr = (uint32_t)hdr;
35855 + labelParams.indexPerHdr = indexPerHdr;
35856 + msg.msgId = FM_PCD_GET_SW_PRS_OFFSET;
35857 + memcpy(msg.msgBody, &labelParams, sizeof(labelParams));
35858 + replyLength = sizeof(uint32_t) + sizeof(uint32_t);
35859 + err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
35860 + (uint8_t*)&msg,
35861 + sizeof(msg.msgId) +sizeof(labelParams),
35862 + (uint8_t*)&reply,
35863 + &replyLength,
35864 + NULL,
35865 + NULL);
35866 + if (err != E_OK)
35867 + RETURN_ERROR(MAJOR, err, NO_MSG);
35868 + if (replyLength != sizeof(uint32_t) + sizeof(uint32_t))
35869 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
35870 +
35871 + memcpy((uint8_t*)&prsOffset, reply.replyBody, sizeof(uint32_t));
35872 + return prsOffset;
35873 + }
35874 + else if (p_FmPcd->guestId != NCSW_MASTER_ID)
35875 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
35876 + ("running in guest-mode without IPC!"));
35877 +
35878 + ASSERT_COND(p_FmPcd->p_FmPcdPrs->currLabel < FM_PCD_PRS_NUM_OF_LABELS);
35879 +
35880 + for (i=0; i<p_FmPcd->p_FmPcdPrs->currLabel; i++)
35881 + {
35882 + p_Label = &p_FmPcd->p_FmPcdPrs->labelsTable[i];
35883 +
35884 + if ((hdr == p_Label->hdr) && (indexPerHdr == p_Label->indexPerHdr))
35885 + return p_Label->instructionOffset;
35886 + }
35887 +
35888 + REPORT_ERROR(MAJOR, E_NOT_FOUND, ("Sw Parser attachment Not found"));
35889 + return (uint32_t)ILLEGAL_BASE;
35890 +}
35891 +
35892 +void FM_PCD_SetPrsStatistics(t_Handle h_FmPcd, bool enable)
35893 +{
35894 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
35895 + struct fman_prs_regs *PrsRegs;
35896 +
35897 + SANITY_CHECK_RETURN(p_FmPcd, E_INVALID_HANDLE);
35898 + SANITY_CHECK_RETURN(p_FmPcd->p_FmPcdPrs, E_INVALID_HANDLE);
35899 +
35900 + PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
35901 +
35902 +
35903 + if(p_FmPcd->guestId != NCSW_MASTER_ID)
35904 + {
35905 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_SetPrsStatistics - guest mode!"));
35906 + return;
35907 + }
35908 +
35909 + fman_prs_set_stst(PrsRegs, enable);
35910 +}
35911 +
35912 +t_Error FM_PCD_PrsLoadSw(t_Handle h_FmPcd, t_FmPcdPrsSwParams *p_SwPrs)
35913 +{
35914 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
35915 + uint32_t *p_LoadTarget;
35916 + uint32_t *p_TmpCode;
35917 + int i;
35918 +
35919 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
35920 + SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
35921 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPrs, E_INVALID_STATE);
35922 + SANITY_CHECK_RETURN_ERROR(p_SwPrs, E_INVALID_HANDLE);
35923 + SANITY_CHECK_RETURN_ERROR(!p_FmPcd->enabled, E_INVALID_HANDLE);
35924 +
35925 + if (p_FmPcd->guestId != NCSW_MASTER_ID)
35926 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM in guest-mode!"));
35927 +
35928 + if (!p_SwPrs->override)
35929 + {
35930 + if(p_FmPcd->p_FmPcdPrs->p_CurrSwPrs > p_FmPcd->p_FmPcdPrs->p_SwPrsCode + p_SwPrs->base*2/4)
35931 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("SW parser base must be larger than current loaded code"));
35932 + }
35933 + else
35934 + p_FmPcd->p_FmPcdPrs->currLabel = 0;
35935 +
35936 + if (p_SwPrs->size > FM_PCD_SW_PRS_SIZE - FM_PCD_PRS_SW_TAIL_SIZE - p_SwPrs->base*2)
35937 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("p_SwPrs->size may not be larger than MAX_SW_PRS_CODE_SIZE"));
35938 +
35939 + if (p_FmPcd->p_FmPcdPrs->currLabel + p_SwPrs->numOfLabels > FM_PCD_PRS_NUM_OF_LABELS)
35940 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exceeded number of labels allowed "));
35941 +
35942 + p_TmpCode = (uint32_t *)XX_MallocSmart(ROUND_UP(p_SwPrs->size,4), 0, sizeof(uint32_t));
35943 + if (!p_TmpCode)
35944 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Tmp Sw-Parser code allocation FAILED"));
35945 + memset((uint8_t *)p_TmpCode, 0, ROUND_UP(p_SwPrs->size,4));
35946 + memcpy((uint8_t *)p_TmpCode, p_SwPrs->p_Code, p_SwPrs->size);
35947 +
35948 + /* save sw parser labels */
35949 + memcpy(&p_FmPcd->p_FmPcdPrs->labelsTable[p_FmPcd->p_FmPcdPrs->currLabel],
35950 + p_SwPrs->labelsTable,
35951 + p_SwPrs->numOfLabels*sizeof(t_FmPcdPrsLabelParams));
35952 + p_FmPcd->p_FmPcdPrs->currLabel += p_SwPrs->numOfLabels;
35953 +
35954 + /* load sw parser code */
35955 + p_LoadTarget = p_FmPcd->p_FmPcdPrs->p_SwPrsCode + p_SwPrs->base*2/4;
35956 +
35957 + for(i=0; i<DIV_CEIL(p_SwPrs->size, 4); i++)
35958 + WRITE_UINT32(p_LoadTarget[i], GET_UINT32(p_TmpCode[i]));
35959 +
35960 + p_FmPcd->p_FmPcdPrs->p_CurrSwPrs =
35961 + p_FmPcd->p_FmPcdPrs->p_SwPrsCode + p_SwPrs->base*2/4 + ROUND_UP(p_SwPrs->size,4);
35962 +
35963 + /* copy data parameters */
35964 + for (i=0;i<FM_PCD_PRS_NUM_OF_HDRS;i++)
35965 + WRITE_UINT32(*(p_FmPcd->p_FmPcdPrs->p_SwPrsCode+PRS_SW_DATA/4+i), p_SwPrs->swPrsDataParams[i]);
35966 +
35967 + /* Clear last 4 bytes */
35968 + WRITE_UINT32(*(p_FmPcd->p_FmPcdPrs->p_SwPrsCode+(PRS_SW_DATA-FM_PCD_PRS_SW_TAIL_SIZE)/4), 0);
35969 +
35970 + XX_FreeSmart(p_TmpCode);
35971 +
35972 + return E_OK;
35973 +}
35974 +
35975 +t_Error FM_PCD_ConfigPrsMaxCycleLimit(t_Handle h_FmPcd,uint16_t value)
35976 +{
35977 + t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
35978 +
35979 + SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
35980 + SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
35981 +
35982 + if(p_FmPcd->guestId != NCSW_MASTER_ID)
35983 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_ConfigPrsMaxCycleLimit - guest mode!"));
35984 +
35985 + p_FmPcd->p_FmPcdDriverParam->prsMaxParseCycleLimit = value;
35986 +
35987 + return E_OK;
35988 +}
35989 --- /dev/null
35990 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_prs.h
35991 @@ -0,0 +1,316 @@
35992 +/*
35993 + * Copyright 2008-2012 Freescale Semiconductor Inc.
35994 + *
35995 + * Redistribution and use in source and binary forms, with or without
35996 + * modification, are permitted provided that the following conditions are met:
35997 + * * Redistributions of source code must retain the above copyright
35998 + * notice, this list of conditions and the following disclaimer.
35999 + * * Redistributions in binary form must reproduce the above copyright
36000 + * notice, this list of conditions and the following disclaimer in the
36001 + * documentation and/or other materials provided with the distribution.
36002 + * * Neither the name of Freescale Semiconductor nor the
36003 + * names of its contributors may be used to endorse or promote products
36004 + * derived from this software without specific prior written permission.
36005 + *
36006 + *
36007 + * ALTERNATIVELY, this software may be distributed under the terms of the
36008 + * GNU General Public License ("GPL") as published by the Free Software
36009 + * Foundation, either version 2 of that License or (at your option) any
36010 + * later version.
36011 + *
36012 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
36013 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36014 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36015 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
36016 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36017 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36018 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36019 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36020 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36021 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36022 + */
36023 +
36024 +
36025 +/******************************************************************************
36026 + @File fm_prs.h
36027 +
36028 + @Description FM Parser private header
36029 + *//***************************************************************************/
36030 +#ifndef __FM_PRS_H
36031 +#define __FM_PRS_H
36032 +
36033 +#include "std_ext.h"
36034 +
36035 +/***********************************************************************/
36036 +/* SW parser IP_FRAG patch */
36037 +/***********************************************************************/
36038 +
36039 +#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
36040 +#define SW_PRS_UDP_LITE_PATCH \
36041 +{\
36042 + 0x31,0x52,0x00,0xDA,0xFC,0x00,0x00,0x00,0x00,0x00, \
36043 + 0x00,0x00,0x50,0x2C,0x40,0x00,0x31,0x92,0x50,0x2C, \
36044 + 0x00,0x88,0x18,0x2F,0x00,0x01,0x1B,0xFE,0x18,0x71, \
36045 + 0x02,0x1F,0x00,0x08,0x00,0x83,0x02,0x1F,0x00,0x20, \
36046 + 0x28,0x1B,0x00,0x05,0x29,0x1F,0x30,0xD0,0x60,0x4F, \
36047 + 0x00,0x07,0x00,0x05,0x00,0x00,0xC3,0x8F,0x00,0x52, \
36048 + 0x00,0x01,0x07,0x01,0x60,0x3B,0x00,0x00,0x30,0xD0, \
36049 + 0x00,0xDA,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00, \
36050 + 0x40,0x4C,0x00,0x00,0x02,0x8F,0x00,0x00,0x30,0xF2, \
36051 + 0x00,0x06,0x18,0x5D,0x00,0x00,0x9F,0xFF,0x30,0xF2, \
36052 + 0x00,0x06,0x29,0x1E,0x07,0x08,0x30,0xD0,0x00,0x52, \
36053 + 0x00,0x08,0x28,0x1A,0x60,0x37,0x00,0x00,0x30,0xF2, \
36054 + 0x18,0x5D,0x06,0x00,0x29,0x1E,0x30,0xF2,0x2F,0x0E, \
36055 + 0x30,0x72,0x00,0x00,0x9B,0x8F,0x00,0x06,0x2F,0x0E, \
36056 + 0x32,0xF1,0x32,0xB0,0x00,0x4F,0x00,0x57,0x00,0x28, \
36057 + 0x00,0x00,0x97,0x9E,0x00,0x4E,0x30,0x72,0x00,0x06, \
36058 + 0x2F,0x0E,0x32,0xC1,0x32,0xF0,0x00,0x4A,0x00,0x80, \
36059 + 0x00,0x02,0x00,0x00,0x97,0x9E,0x40,0x7E,0x00,0x08, \
36060 + 0x08,0x16,0x00,0x54,0x00,0x01,0x1B,0xFE,0x00,0x00, \
36061 + 0x9F,0x9E,0x40,0xB3,0x00,0x00,0x02,0x1F,0x00,0x08, \
36062 + 0x28,0x1B,0x30,0x73,0x29,0x1F,0x30,0xD0,0x60,0x9F, \
36063 + 0x00,0x07,0x00,0x05,0x00,0x00,0xC3,0x8F,0x00,0x52, \
36064 + 0x00,0x01,0x07,0x01,0x60,0x8B,0x00,0x00,0x30,0xD0, \
36065 + 0x00,0xDA,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00, \
36066 + 0x40,0x9C,0x00,0x00,0x02,0x8F,0x00,0x00,0x30,0xF2, \
36067 + 0x00,0x06,0x18,0xAD,0x00,0x00,0x9F,0xFF,0x30,0xF2, \
36068 + 0x00,0x06,0x29,0x1E,0x07,0x08,0x30,0xD0,0x00,0x52, \
36069 + 0x00,0x08,0x28,0x1A,0x60,0x87,0x00,0x00,0x30,0xF2, \
36070 + 0x18,0xAD,0x06,0x00,0x29,0x1E,0x30,0xF2,0x50,0xB3, \
36071 + 0xFF,0xFF,0x18,0xB8,0x08,0x16,0x00,0x54,0x00,0x01, \
36072 + 0x1B,0xFE,0x18,0xC5,0x32,0xF1,0x28,0x5D,0x32,0xF1, \
36073 + 0x00,0x55,0x00,0x08,0x28,0x5F,0x00,0x00,0x8F,0x9F, \
36074 + 0x29,0x33,0x08,0x16,0x00,0x49,0x00,0x01,0x1B,0xFF, \
36075 + 0x00,0x01,0x1B,0xFF \
36076 +}
36077 +#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
36078 +
36079 +#if (DPAA_VERSION == 10)
36080 +/* Version: 106.1.9 */
36081 +#define SW_PRS_OFFLOAD_PATCH \
36082 +{ \
36083 + 0x31,0x52,0x00,0xDA,0x0A,0x00,0x00,0x00,0x00,0x00, \
36084 + 0x00,0x00,0x43,0x0A,0x00,0x00,0x00,0x01,0x1B,0xFE, \
36085 + 0x00,0x00,0x99,0x00,0x53,0x13,0x00,0x00,0x00,0x00, \
36086 + 0x9F,0x98,0x53,0x13,0x00,0x00,0x1B,0x23,0x33,0xF1, \
36087 + 0x00,0xF9,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00, \
36088 + 0x28,0x7F,0x00,0x03,0x00,0x02,0x00,0x00,0x00,0x01, \
36089 + 0x32,0xC1,0x32,0xF0,0x00,0x4A,0x00,0x80,0x1F,0xFF, \
36090 + 0x00,0x01,0x1B,0xFE,0x31,0x52,0x00,0xDA,0x06,0x00, \
36091 + 0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x2F,0x00,0x00, \
36092 + 0x00,0x01,0x1B,0xFE,0x31,0x52,0x00,0xDA,0x00,0x40, \
36093 + 0x00,0x00,0x00,0x00,0x00,0x00,0x53,0x95,0x00,0x00, \
36094 + 0x00,0x00,0x9B,0x8F,0x2F,0x0F,0x32,0xC1,0x00,0x55, \
36095 + 0x00,0x28,0x28,0x43,0x30,0x7E,0x43,0x45,0x00,0x00, \
36096 + 0x30,0x7E,0x43,0x45,0x00,0x3C,0x1B,0x5D,0x32,0x11, \
36097 + 0x32,0xC0,0x00,0x4F,0x00,0x81,0x00,0x00,0x83,0x8F, \
36098 + 0x2F,0x0F,0x06,0x00,0x32,0x11,0x32,0xC0,0x00,0x4F, \
36099 + 0x00,0x55,0x00,0x01,0x00,0x81,0x32,0x11,0x00,0x00, \
36100 + 0x83,0x8E,0x00,0x50,0x00,0x01,0x01,0x04,0x00,0x4D, \
36101 + 0x28,0x43,0x06,0x00,0x1B,0x3E,0x30,0x7E,0x53,0x79, \
36102 + 0x00,0x2B,0x32,0x11,0x32,0xC0,0x00,0x4F,0x00,0x81, \
36103 + 0x00,0x00,0x87,0x8F,0x28,0x23,0x06,0x00,0x32,0x11, \
36104 + 0x32,0xC0,0x00,0x4F,0x00,0x55,0x00,0x01,0x00,0x81, \
36105 + 0x32,0x11,0x00,0x00,0x83,0x8E,0x00,0x50,0x00,0x01, \
36106 + 0x01,0x04,0x00,0x4D,0x28,0x43,0x06,0x00,0x00,0x01, \
36107 + 0x1B,0xFE,0x00,0x00,0x9B,0x8E,0x53,0x90,0x00,0x00, \
36108 + 0x06,0x29,0x00,0x00,0x83,0x8F,0x28,0x23,0x06,0x00, \
36109 + 0x06,0x29,0x32,0xC1,0x00,0x55,0x00,0x28,0x00,0x00, \
36110 + 0x83,0x8E,0x00,0x50,0x00,0x01,0x01,0x04,0x00,0x4D, \
36111 + 0x28,0x43,0x06,0x00,0x00,0x01,0x1B,0xFE,0x32,0xC1, \
36112 + 0x00,0x55,0x00,0x28,0x28,0x43,0x1B,0xCF,0x00,0x00, \
36113 + 0x9B,0x8F,0x2F,0x0F,0x32,0xC1,0x00,0x55,0x00,0x28, \
36114 + 0x28,0x43,0x30,0x7E,0x43,0xBF,0x00,0x2C,0x32,0x11, \
36115 + 0x32,0xC0,0x00,0x4F,0x00,0x81,0x00,0x00,0x87,0x8F, \
36116 + 0x28,0x23,0x06,0x00,0x32,0x11,0x32,0xC0,0x00,0x4F, \
36117 + 0x00,0x81,0x00,0x00,0x83,0x8F,0x2F,0x0F,0x06,0x00, \
36118 + 0x32,0x11,0x32,0xC0,0x00,0x4F,0x00,0x55,0x00,0x01, \
36119 + 0x00,0x81,0x32,0x11,0x00,0x00,0x83,0x8E,0x00,0x50, \
36120 + 0x00,0x01,0x01,0x04,0x00,0x4D,0x28,0x43,0x06,0x00, \
36121 + 0x1B,0x9C,0x33,0xF1,0x00,0xF9,0x00,0x01,0x00,0x00, \
36122 + 0x00,0x00,0x00,0x00,0x28,0x7F,0x00,0x03,0x00,0x02, \
36123 + 0x00,0x00,0x00,0x01,0x32,0xC1,0x32,0xF0,0x00,0x4A, \
36124 + 0x00,0x80,0x1F,0xFF,0x00,0x01,0x1B,0xFE, \
36125 +}
36126 +
36127 +#else
36128 +#define SW_PRS_OFFLOAD_PATCH \
36129 +{ \
36130 + 0x31,0x52,0x00,0xDA,0x0E,0x4F,0x00,0x00,0x00,0x00, \
36131 + 0x00,0x00,0x51,0x16,0x08,0x4B,0x31,0x53,0x00,0xFB, \
36132 + 0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x29,0x2B, \
36133 + 0x33,0xF1,0x00,0xFB,0x00,0xDF,0x00,0x00,0x00,0x00, \
36134 + 0x00,0x00,0x28,0x7F,0x31,0x52,0x00,0xDA,0x0A,0x00, \
36135 + 0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x20,0x00,0x00, \
36136 + 0x00,0x01,0x1B,0xFE,0x00,0x00,0x99,0x00,0x51,0x29, \
36137 + 0x00,0x00,0x00,0x00,0x9F,0x98,0x51,0x29,0x00,0x00, \
36138 + 0x19,0x44,0x09,0x5F,0x00,0x20,0x00,0x00,0x09,0x4F, \
36139 + 0x00,0x20,0x00,0x00,0x34,0xB7,0x00,0xF9,0x00,0x00, \
36140 + 0x01,0x00,0x00,0x00,0x00,0x00,0x2B,0x97,0x31,0xB3, \
36141 + 0x29,0x8F,0x33,0xF1,0x00,0xF9,0x00,0x01,0x00,0x00, \
36142 + 0x00,0x00,0x00,0x00,0x28,0x7F,0x00,0x03,0x00,0x02, \
36143 + 0x00,0x00,0x00,0x01,0x1B,0xFE,0x00,0x01,0x1B,0xFE, \
36144 + 0x31,0x52,0x00,0xDA,0xFC,0x00,0x00,0x00,0x00,0x00, \
36145 + 0x00,0x00,0x51,0x52,0x40,0x00,0x31,0x92,0x51,0x52, \
36146 + 0x00,0x88,0x19,0x55,0x08,0x05,0x00,0x00,0x19,0x99, \
36147 + 0x02,0x1F,0x00,0x08,0x00,0x83,0x02,0x1F,0x00,0x20, \
36148 + 0x28,0x1B,0x00,0x05,0x29,0x1F,0x30,0xD0,0x61,0x75, \
36149 + 0x00,0x07,0x00,0x05,0x00,0x00,0xC3,0x8F,0x00,0x52, \
36150 + 0x00,0x01,0x07,0x01,0x61,0x61,0x00,0x00,0x30,0xD0, \
36151 + 0x00,0xDA,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00, \
36152 + 0x41,0x72,0x00,0x00,0x02,0x8F,0x00,0x00,0x30,0xF2, \
36153 + 0x00,0x06,0x19,0x83,0x00,0x00,0x9F,0xFF,0x30,0xF2, \
36154 + 0x00,0x06,0x29,0x1E,0x07,0x08,0x30,0xD0,0x00,0x52, \
36155 + 0x00,0x08,0x28,0x1A,0x61,0x5D,0x00,0x00,0x30,0xF2, \
36156 + 0x19,0x83,0x06,0x00,0x29,0x1E,0x30,0xF2,0x29,0x0E, \
36157 + 0x30,0x72,0x00,0x00,0x9B,0x8F,0x00,0x06,0x29,0x0E, \
36158 + 0x32,0xF1,0x32,0xB0,0x00,0x4F,0x00,0x57,0x00,0x28, \
36159 + 0x00,0x00,0x97,0x9E,0x00,0x4E,0x30,0x72,0x00,0x06, \
36160 + 0x29,0x0E,0x08,0x05,0x00,0x01,0x31,0x52,0x00,0xDA, \
36161 + 0x0E,0x4F,0x00,0x00,0x00,0x00,0x00,0x00,0x51,0xAF, \
36162 + 0x04,0x4B,0x31,0x53,0x00,0xFB,0xFF,0xF0,0x00,0x00, \
36163 + 0x00,0x00,0x00,0x00,0x29,0x2B,0x33,0xF1,0x00,0xFB, \
36164 + 0x00,0xDF,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x7F, \
36165 + 0x31,0x52,0x00,0xDA,0x06,0x00,0x00,0x00,0x00,0x00, \
36166 + 0x00,0x00,0x41,0xB9,0x00,0x00,0x00,0x01,0x1B,0xFE, \
36167 + 0x31,0x52,0x00,0xDA,0x00,0x40,0x00,0x00,0x00,0x00, \
36168 + 0x00,0x00,0x42,0x06,0x00,0x00,0x00,0x00,0x9B,0x8F, \
36169 + 0x28,0x01,0x32,0xC1,0x00,0x55,0x00,0x28,0x28,0x43, \
36170 + 0x30,0x00,0x41,0xEB,0x00,0x2C,0x32,0x11,0x32,0xC0, \
36171 + 0x00,0x4F,0x00,0x81,0x00,0x00,0x87,0x8F,0x28,0x23, \
36172 + 0x06,0x00,0x32,0x11,0x32,0xC0,0x00,0x4F,0x00,0x81, \
36173 + 0x00,0x00,0x83,0x8F,0x28,0x01,0x06,0x00,0x32,0x11, \
36174 + 0x32,0xC0,0x00,0x4F,0x00,0x55,0x00,0x01,0x00,0x81, \
36175 + 0x32,0x11,0x00,0x00,0x83,0x8E,0x00,0x50,0x00,0x01, \
36176 + 0x01,0x04,0x00,0x4D,0x28,0x43,0x06,0x00,0x19,0xC8, \
36177 + 0x09,0x5F,0x00,0x20,0x00,0x00,0x09,0x4F,0x00,0x20, \
36178 + 0x00,0x00,0x34,0xB7,0x00,0xF9,0x00,0x00,0x01,0x00, \
36179 + 0x00,0x00,0x00,0x00,0x2B,0x97,0x31,0xB3,0x29,0x8F, \
36180 + 0x33,0xF1,0x00,0xF9,0x00,0x01,0x00,0x00,0x00,0x00, \
36181 + 0x00,0x00,0x28,0x7F,0x00,0x03,0x00,0x02,0x00,0x00, \
36182 + 0x00,0x01,0x1B,0xFE,0x30,0x50,0x52,0x0B,0x00,0x00, \
36183 + 0x00,0x01,0x1B,0xFE,0x32,0xF1,0x32,0xC0,0x00,0x4F, \
36184 + 0x00,0x81,0x00,0x02,0x00,0x00,0x97,0x9E,0x42,0x18, \
36185 + 0x00,0x08,0x08,0x16,0x00,0x54,0x00,0x01,0x1B,0xFE, \
36186 + 0x00,0x00,0x9F,0x9E,0x42,0x4D,0x00,0x00,0x02,0x1F, \
36187 + 0x00,0x08,0x28,0x1B,0x30,0x73,0x29,0x1F,0x30,0xD0, \
36188 + 0x62,0x39,0x00,0x07,0x00,0x05,0x00,0x00,0xC3,0x8F, \
36189 + 0x00,0x52,0x00,0x01,0x07,0x01,0x62,0x25,0x00,0x00, \
36190 + 0x30,0xD0,0x00,0xDA,0x00,0x01,0x00,0x00,0x00,0x00, \
36191 + 0x00,0x00,0x42,0x36,0x00,0x00,0x02,0x8F,0x00,0x00, \
36192 + 0x30,0xF2,0x00,0x06,0x1A,0x47,0x00,0x00,0x9F,0xFF, \
36193 + 0x30,0xF2,0x00,0x06,0x29,0x1E,0x07,0x08,0x30,0xD0, \
36194 + 0x00,0x52,0x00,0x08,0x28,0x1A,0x62,0x21,0x00,0x00, \
36195 + 0x30,0xF2,0x1A,0x47,0x06,0x00,0x29,0x1E,0x30,0xF2, \
36196 + 0x52,0x4D,0xFF,0xFF,0x1A,0x52,0x08,0x16,0x00,0x54, \
36197 + 0x00,0x01,0x1B,0xFE,0x1A,0x5F,0x32,0xF1,0x28,0x5D, \
36198 + 0x32,0xF1,0x00,0x55,0x00,0x08,0x28,0x5F,0x00,0x00, \
36199 + 0x8F,0x9F,0x29,0x33,0x08,0x16,0x00,0x49,0x00,0x01, \
36200 + 0x1B,0xFF,0x00,0x01,0x1B,0xFF,0x31,0x52,0x00,0xDA, \
36201 + 0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x6D, \
36202 + 0x40,0x00,0x31,0x92,0x52,0x6D,0x00,0x88,0x1A,0x70, \
36203 + 0x08,0x05,0x00,0x00,0x1A,0xB4,0x02,0x1F,0x00,0x08, \
36204 + 0x00,0x83,0x02,0x1F,0x00,0x20,0x28,0x1B,0x00,0x05, \
36205 + 0x29,0x1F,0x30,0xD0,0x62,0x90,0x00,0x07,0x00,0x05, \
36206 + 0x00,0x00,0xC3,0x8F,0x00,0x52,0x00,0x01,0x07,0x01, \
36207 + 0x62,0x7C,0x00,0x00,0x30,0xD0,0x00,0xDA,0x00,0x01, \
36208 + 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x8D,0x00,0x00, \
36209 + 0x02,0x8F,0x00,0x00,0x30,0xF2,0x00,0x06,0x1A,0x9E, \
36210 + 0x00,0x00,0x9F,0xFF,0x30,0xF2,0x00,0x06,0x29,0x1E, \
36211 + 0x07,0x08,0x30,0xD0,0x00,0x52,0x00,0x08,0x28,0x1A, \
36212 + 0x62,0x78,0x00,0x00,0x30,0xF2,0x1A,0x9E,0x06,0x00, \
36213 + 0x29,0x1E,0x30,0xF2,0x29,0x0E,0x30,0x72,0x00,0x00, \
36214 + 0x9B,0x8F,0x00,0x06,0x29,0x0E,0x32,0xF1,0x32,0xB0, \
36215 + 0x00,0x4F,0x00,0x57,0x00,0x28,0x00,0x00,0x97,0x9E, \
36216 + 0x00,0x4E,0x30,0x72,0x00,0x06,0x29,0x0E,0x08,0x05, \
36217 + 0x00,0x01,0x31,0x52,0x00,0xDA,0x0E,0x4F,0x00,0x00, \
36218 + 0x00,0x00,0x00,0x00,0x52,0xCA,0x04,0x4B,0x31,0x53, \
36219 + 0x00,0xFB,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00, \
36220 + 0x29,0x2B,0x33,0xF1,0x00,0xFB,0x00,0xDF,0x00,0x00, \
36221 + 0x00,0x00,0x00,0x00,0x28,0x7F,0x31,0x52,0x00,0xDA, \
36222 + 0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x42,0xD4, \
36223 + 0x00,0x00,0x00,0x01,0x1B,0xFE,0x31,0x52,0x00,0xDA, \
36224 + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x53,0x37, \
36225 + 0x00,0x00,0x00,0x00,0x9B,0x8F,0x28,0x01,0x32,0xC1, \
36226 + 0x00,0x55,0x00,0x28,0x28,0x43,0x30,0x00,0x42,0xEA, \
36227 + 0x00,0x00,0x30,0x00,0x42,0xEA,0x00,0x3C,0x1B,0x02, \
36228 + 0x32,0x11,0x32,0xC0,0x00,0x4F,0x00,0x81,0x00,0x00, \
36229 + 0x83,0x8F,0x28,0x01,0x06,0x00,0x32,0x11,0x32,0xC0, \
36230 + 0x00,0x4F,0x00,0x55,0x00,0x01,0x00,0x81,0x32,0x11, \
36231 + 0x00,0x00,0x83,0x8E,0x00,0x50,0x00,0x01,0x01,0x04, \
36232 + 0x00,0x4D,0x28,0x43,0x06,0x00,0x1A,0xE3,0x30,0x00, \
36233 + 0x43,0x20,0x00,0x2B,0x00,0x00,0x9B,0x8E,0x43,0x0E, \
36234 + 0x00,0x00,0x32,0xC1,0x00,0x55,0x00,0x28,0x28,0x43, \
36235 + 0x1B,0x1F,0x06,0x29,0x00,0x00,0x83,0x8F,0x28,0x23, \
36236 + 0x06,0x00,0x06,0x29,0x32,0xC1,0x00,0x55,0x00,0x28, \
36237 + 0x00,0x00,0x83,0x8E,0x00,0x50,0x00,0x01,0x01,0x04, \
36238 + 0x00,0x4D,0x28,0x43,0x06,0x00,0x1B,0x37,0x32,0x11, \
36239 + 0x32,0xC0,0x00,0x4F,0x00,0x81,0x00,0x00,0x87,0x8F, \
36240 + 0x28,0x23,0x06,0x00,0x32,0x11,0x32,0xC0,0x00,0x4F, \
36241 + 0x00,0x55,0x00,0x01,0x00,0x81,0x32,0x11,0x00,0x00, \
36242 + 0x83,0x8E,0x00,0x50,0x00,0x01,0x01,0x04,0x00,0x4D, \
36243 + 0x28,0x43,0x06,0x00,0x30,0x50,0x53,0x3C,0x00,0x00, \
36244 + 0x00,0x01,0x1B,0xFE,0x32,0xF1,0x32,0xC0,0x00,0x4F, \
36245 + 0x00,0x81,0x00,0x02,0x00,0x00,0x97,0x9E,0x43,0x49, \
36246 + 0x00,0x08,0x08,0x16,0x00,0x54,0x00,0x01,0x1B,0xFE, \
36247 + 0x00,0x00,0x9F,0x9E,0x43,0x7E,0x00,0x00,0x02,0x1F, \
36248 + 0x00,0x08,0x28,0x1B,0x30,0x73,0x29,0x1F,0x30,0xD0, \
36249 + 0x63,0x6A,0x00,0x07,0x00,0x05,0x00,0x00,0xC3,0x8F, \
36250 + 0x00,0x52,0x00,0x01,0x07,0x01,0x63,0x56,0x00,0x00, \
36251 + 0x30,0xD0,0x00,0xDA,0x00,0x01,0x00,0x00,0x00,0x00, \
36252 + 0x00,0x00,0x43,0x67,0x00,0x00,0x02,0x8F,0x00,0x00, \
36253 + 0x30,0xF2,0x00,0x06,0x1B,0x78,0x00,0x00,0x9F,0xFF, \
36254 + 0x30,0xF2,0x00,0x06,0x29,0x1E,0x07,0x08,0x30,0xD0, \
36255 + 0x00,0x52,0x00,0x08,0x28,0x1A,0x63,0x52,0x00,0x00, \
36256 + 0x30,0xF2,0x1B,0x78,0x06,0x00,0x29,0x1E,0x30,0xF2, \
36257 + 0x53,0x7E,0xFF,0xFF,0x1B,0x83,0x08,0x16,0x00,0x54, \
36258 + 0x00,0x01,0x1B,0xFE,0x1B,0x90,0x32,0xF1,0x28,0x5D, \
36259 + 0x32,0xF1,0x00,0x55,0x00,0x08,0x28,0x5F,0x00,0x00, \
36260 + 0x8F,0x9F,0x29,0x33,0x08,0x16,0x00,0x49,0x00,0x01, \
36261 + 0x1B,0xFF,0x00,0x01,0x1B,0xFF,0x08,0x07,0x00,0x02, \
36262 + 0x00,0x00,0x8D,0x80,0x53,0x9C,0x00,0x01,0x30,0x71, \
36263 + 0x00,0x55,0x00,0x01,0x28,0x0F,0x00,0x00,0x8D,0x00, \
36264 + 0x53,0xA4,0x00,0x01,0x30,0x71,0x00,0x55,0x00,0x01, \
36265 + 0x28,0x0F,0x00,0x00,0x83,0x8E,0x53,0xB9,0x00,0x00, \
36266 + 0x00,0x00,0x86,0x08,0x30,0x71,0x00,0x7B,0x03,0xB9, \
36267 + 0x33,0xB4,0x00,0xDA,0xFF,0xFF,0x00,0x0F,0x00,0x00, \
36268 + 0x00,0x00,0x00,0x00,0x86,0x09,0x01,0x03,0x00,0x7D, \
36269 + 0x03,0xB9,0x1B,0xC8,0x33,0xD1,0x00,0xF9,0x00,0x10, \
36270 + 0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x7B,0x09,0x5F, \
36271 + 0x00,0x1A,0x00,0x00,0x09,0x4F,0x00,0x1A,0x00,0x00, \
36272 + 0x00,0x01,0x1B,0xFF,0x00,0x00,0x8C,0x00,0x53,0xF0, \
36273 + 0x00,0x01,0x34,0xF5,0x00,0xFB,0xFF,0xFF,0x00,0x7F, \
36274 + 0x00,0x00,0x00,0x00,0x2A,0x9F,0x00,0x00,0x93,0x8F, \
36275 + 0x28,0x49,0x00,0x00,0x97,0x8F,0x28,0x4B,0x34,0x61, \
36276 + 0x28,0x4D,0x34,0x71,0x28,0x4F,0x34,0xB7,0x00,0xF9, \
36277 + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x2B,0x97, \
36278 + 0x33,0xF1,0x00,0xF9,0x00,0x01,0x00,0x00,0x00,0x00, \
36279 + 0x00,0x00,0x28,0x7F,0x00,0x03,0x00,0x02,0x00,0x00, \
36280 + 0x00,0x01,0x1B,0xFF,0x00,0x01,0x1B,0xFF, \
36281 +}
36282 +#endif /* (DPAA_VERSION == 10) */
36283 +
36284 +/****************************/
36285 +/* Parser defines */
36286 +/****************************/
36287 +#define FM_PCD_PRS_SW_TAIL_SIZE 4 /**< Number of bytes that must be cleared at
36288 + the end of the SW parser area */
36289 +
36290 +/* masks */
36291 +#define PRS_ERR_CAP 0x80000000
36292 +#define PRS_ERR_TYPE_DOUBLE 0x40000000
36293 +#define PRS_ERR_SINGLE_ECC_CNT_MASK 0x00FF0000
36294 +#define PRS_ERR_ADDR_MASK 0x000001FF
36295 +
36296 +/* others */
36297 +#define PRS_MAX_CYCLE_LIMIT 8191
36298 +#define PRS_SW_DATA 0x00000800
36299 +#define PRS_REGS_OFFSET 0x00000840
36300 +
36301 +#define GET_FM_PCD_PRS_PORT_ID(prsPortId,hardwarePortId) \
36302 + prsPortId = (uint8_t)(hardwarePortId & 0x0f)
36303 +
36304 +#define GET_FM_PCD_INDEX_FLAG(bitMask, prsPortId) \
36305 + bitMask = 0x80000000>>prsPortId
36306 +
36307 +#endif /* __FM_PRS_H */
36308 --- /dev/null
36309 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_replic.c
36310 @@ -0,0 +1,984 @@
36311 +/*
36312 + * Copyright 2008-2012 Freescale Semiconductor Inc.
36313 + *
36314 + * Redistribution and use in source and binary forms, with or without
36315 + * modification, are permitted provided that the following conditions are met:
36316 + * * Redistributions of source code must retain the above copyright
36317 + * notice, this list of conditions and the following disclaimer.
36318 + * * Redistributions in binary form must reproduce the above copyright
36319 + * notice, this list of conditions and the following disclaimer in the
36320 + * documentation and/or other materials provided with the distribution.
36321 + * * Neither the name of Freescale Semiconductor nor the
36322 + * names of its contributors may be used to endorse or promote products
36323 + * derived from this software without specific prior written permission.
36324 + *
36325 + *
36326 + * ALTERNATIVELY, this software may be distributed under the terms of the
36327 + * GNU General Public License ("GPL") as published by the Free Software
36328 + * Foundation, either version 2 of that License or (at your option) any
36329 + * later version.
36330 + *
36331 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
36332 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36333 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36334 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
36335 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36336 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36337 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36338 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36339 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36340 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36341 + */
36342 +
36343 +
36344 +/******************************************************************************
36345 + @File fm_replic.c
36346 +
36347 + @Description FM frame replicator
36348 +*//***************************************************************************/
36349 +#include "std_ext.h"
36350 +#include "error_ext.h"
36351 +#include "string_ext.h"
36352 +#include "debug_ext.h"
36353 +#include "fm_pcd_ext.h"
36354 +#include "fm_muram_ext.h"
36355 +#include "fm_common.h"
36356 +#include "fm_hc.h"
36357 +#include "fm_replic.h"
36358 +#include "fm_cc.h"
36359 +#include "list_ext.h"
36360 +
36361 +
36362 +/****************************************/
36363 +/* static functions */
36364 +/****************************************/
36365 +static uint8_t GetMemberPosition(t_FmPcdFrmReplicGroup *p_ReplicGroup,
36366 + uint32_t memberIndex,
36367 + bool isAddOperation)
36368 +{
36369 + uint8_t memberPosition;
36370 + uint32_t lastMemberIndex;
36371 +
36372 + ASSERT_COND(p_ReplicGroup);
36373 +
36374 + /* the last member index is different between add and remove operation -
36375 + in case of remove - this is exactly the last member index
36376 + in case of add - this is the last member index + 1 - e.g.
36377 + if we have 4 members, the index of the actual last member is 3(because the
36378 + index starts from 0) therefore in order to add a new member as the last
36379 + member we shall use memberIndex = 4 and not 3
36380 + */
36381 + if (isAddOperation)
36382 + lastMemberIndex = p_ReplicGroup->numOfEntries;
36383 + else
36384 + lastMemberIndex = p_ReplicGroup->numOfEntries-1;
36385 +
36386 + /* last */
36387 + if (memberIndex == lastMemberIndex)
36388 + memberPosition = FRM_REPLIC_LAST_MEMBER_INDEX;
36389 + else
36390 + {
36391 + /* first */
36392 + if (memberIndex == 0)
36393 + memberPosition = FRM_REPLIC_FIRST_MEMBER_INDEX;
36394 + else
36395 + {
36396 + /* middle */
36397 + ASSERT_COND(memberIndex < lastMemberIndex);
36398 + memberPosition = FRM_REPLIC_MIDDLE_MEMBER_INDEX;
36399 + }
36400 + }
36401 + return memberPosition;
36402 +}
36403 +
36404 +static t_Error MemberCheckParams(t_Handle h_FmPcd,
36405 + t_FmPcdCcNextEngineParams *p_MemberParams)
36406 +{
36407 + t_Error err;
36408 +
36409 +
36410 + if ((p_MemberParams->nextEngine != e_FM_PCD_DONE) &&
36411 + (p_MemberParams->nextEngine != e_FM_PCD_KG) &&
36412 + (p_MemberParams->nextEngine != e_FM_PCD_PLCR))
36413 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Next engine of a member should be MatchTable(cc) or Done or Policer"));
36414 +
36415 + /* check the regular parameters of the next engine */
36416 + err = ValidateNextEngineParams(h_FmPcd, p_MemberParams, e_FM_PCD_CC_STATS_MODE_NONE);
36417 + if (err)
36418 + RETURN_ERROR(MAJOR, err, ("member next engine parameters"));
36419 +
36420 + return E_OK;
36421 +}
36422 +
36423 +static t_Error CheckParams(t_Handle h_FmPcd,
36424 + t_FmPcdFrmReplicGroupParams *p_ReplicGroupParam)
36425 +{
36426 + int i;
36427 + t_Error err;
36428 +
36429 + /* check that max num of entries is at least 2 */
36430 + if (!IN_RANGE(2, p_ReplicGroupParam->maxNumOfEntries, FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES))
36431 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, ("maxNumOfEntries in the frame replicator parameters should be 2-%d",FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES));
36432 +
36433 + /* check that number of entries is greater than zero */
36434 + if (!p_ReplicGroupParam->numOfEntries)
36435 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOFEntries in the frame replicator group should be greater than zero"));
36436 +
36437 + /* check that max num of entries is equal or greater than number of entries */
36438 + if (p_ReplicGroupParam->maxNumOfEntries < p_ReplicGroupParam->numOfEntries)
36439 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("maxNumOfEntries should be equal or greater than numOfEntries"));
36440 +
36441 + for (i=0; i<p_ReplicGroupParam->numOfEntries; i++)
36442 + {
36443 + err = MemberCheckParams(h_FmPcd, &p_ReplicGroupParam->nextEngineParams[i]);
36444 + if (err)
36445 + RETURN_ERROR(MAJOR, err, ("member check parameters"));
36446 + }
36447 + return E_OK;
36448 +}
36449 +
36450 +static t_FmPcdFrmReplicMember *GetAvailableMember(t_FmPcdFrmReplicGroup *p_ReplicGroup)
36451 +{
36452 + t_FmPcdFrmReplicMember *p_ReplicMember = NULL;
36453 + t_List *p_Next;
36454 +
36455 + if (!LIST_IsEmpty(&p_ReplicGroup->availableMembersList))
36456 + {
36457 + p_Next = LIST_FIRST(&p_ReplicGroup->availableMembersList);
36458 + p_ReplicMember = LIST_OBJECT(p_Next, t_FmPcdFrmReplicMember, node);
36459 + ASSERT_COND(p_ReplicMember);
36460 + LIST_DelAndInit(p_Next);
36461 + }
36462 + return p_ReplicMember;
36463 +}
36464 +
36465 +static void PutAvailableMember(t_FmPcdFrmReplicGroup *p_ReplicGroup,
36466 + t_FmPcdFrmReplicMember *p_ReplicMember)
36467 +{
36468 + LIST_AddToTail(&p_ReplicMember->node, &p_ReplicGroup->availableMembersList);
36469 +}
36470 +
36471 +static void AddMemberToList(t_FmPcdFrmReplicGroup *p_ReplicGroup,
36472 + t_FmPcdFrmReplicMember *p_CurrentMember,
36473 + t_List *p_ListHead)
36474 +{
36475 + LIST_Add(&p_CurrentMember->node, p_ListHead);
36476 +
36477 + p_ReplicGroup->numOfEntries++;
36478 +}
36479 +
36480 +static void RemoveMemberFromList(t_FmPcdFrmReplicGroup *p_ReplicGroup,
36481 + t_FmPcdFrmReplicMember *p_CurrentMember)
36482 +{
36483 + ASSERT_COND(p_ReplicGroup->numOfEntries);
36484 + LIST_DelAndInit(&p_CurrentMember->node);
36485 + p_ReplicGroup->numOfEntries--;
36486 +}
36487 +
36488 +static void LinkSourceToMember(t_FmPcdFrmReplicGroup *p_ReplicGroup,
36489 + t_AdOfTypeContLookup *p_SourceTd,
36490 + t_FmPcdFrmReplicMember *p_ReplicMember)
36491 +{
36492 + t_FmPcd *p_FmPcd;
36493 +
36494 + ASSERT_COND(p_SourceTd);
36495 + ASSERT_COND(p_ReplicMember);
36496 + ASSERT_COND(p_ReplicGroup);
36497 + ASSERT_COND(p_ReplicGroup->h_FmPcd);
36498 +
36499 + /* Link the first member in the group to the source TD */
36500 + p_FmPcd = p_ReplicGroup->h_FmPcd;
36501 +
36502 + WRITE_UINT32(p_SourceTd->matchTblPtr,
36503 + (uint32_t)(XX_VirtToPhys(p_ReplicMember->p_MemberAd) -
36504 + p_FmPcd->physicalMuramBase));
36505 +}
36506 +
36507 +static void LinkMemberToMember(t_FmPcdFrmReplicGroup *p_ReplicGroup,
36508 + t_FmPcdFrmReplicMember *p_CurrentMember,
36509 + t_FmPcdFrmReplicMember *p_NextMember)
36510 +{
36511 + t_AdOfTypeResult *p_CurrReplicAd = (t_AdOfTypeResult*)p_CurrentMember->p_MemberAd;
36512 + t_AdOfTypeResult *p_NextReplicAd = NULL;
36513 + t_FmPcd *p_FmPcd;
36514 + uint32_t offset = 0;
36515 +
36516 + /* Check if the next member exists or it's NULL (- means that this is the last member) */
36517 + if (p_NextMember)
36518 + {
36519 + p_NextReplicAd = (t_AdOfTypeResult*)p_NextMember->p_MemberAd;
36520 + p_FmPcd = p_ReplicGroup->h_FmPcd;
36521 + offset = (XX_VirtToPhys(p_NextReplicAd) - (p_FmPcd->physicalMuramBase));
36522 + offset = ((offset>>NEXT_FRM_REPLIC_ADDR_SHIFT)<< NEXT_FRM_REPLIC_MEMBER_INDEX_SHIFT);
36523 + }
36524 +
36525 + /* link the current AD to point to the AD of the next member */
36526 + WRITE_UINT32(p_CurrReplicAd->res, offset);
36527 +}
36528 +
36529 +static t_Error ModifyDescriptor(t_FmPcdFrmReplicGroup *p_ReplicGroup,
36530 + void *p_OldDescriptor,
36531 + void *p_NewDescriptor)
36532 +{
36533 + t_Handle h_Hc;
36534 + t_Error err;
36535 + t_FmPcd *p_FmPcd;
36536 +
36537 + ASSERT_COND(p_ReplicGroup);
36538 + ASSERT_COND(p_ReplicGroup->h_FmPcd);
36539 + ASSERT_COND(p_OldDescriptor);
36540 + ASSERT_COND(p_NewDescriptor);
36541 +
36542 + p_FmPcd = p_ReplicGroup->h_FmPcd;
36543 + h_Hc = FmPcdGetHcHandle(p_FmPcd);
36544 + if (!h_Hc)
36545 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("Host command"));
36546 +
36547 + err = FmHcPcdCcDoDynamicChange(h_Hc,
36548 + (uint32_t)(XX_VirtToPhys(p_OldDescriptor) - p_FmPcd->physicalMuramBase),
36549 + (uint32_t)(XX_VirtToPhys(p_NewDescriptor) - p_FmPcd->physicalMuramBase));
36550 + if (err)
36551 + RETURN_ERROR(MAJOR, err, ("Dynamic change host command"));
36552 +
36553 + return E_OK;
36554 +}
36555 +
36556 +static void FillReplicAdOfTypeResult(void *p_ReplicAd, bool last)
36557 +{
36558 + t_AdOfTypeResult *p_CurrReplicAd = (t_AdOfTypeResult*)p_ReplicAd;
36559 + uint32_t tmp;
36560 +
36561 + tmp = GET_UINT32(p_CurrReplicAd->plcrProfile);
36562 + if (last)
36563 + /* clear the NL bit in case it's the last member in the group*/
36564 + WRITE_UINT32(p_CurrReplicAd->plcrProfile,(tmp & ~FRM_REPLIC_NL_BIT));
36565 + else
36566 + /* set the NL bit in case it's not the last member in the group */
36567 + WRITE_UINT32(p_CurrReplicAd->plcrProfile, (tmp |FRM_REPLIC_NL_BIT));
36568 +
36569 + /* set FR bit in the action descriptor */
36570 + tmp = GET_UINT32(p_CurrReplicAd->nia);
36571 + WRITE_UINT32(p_CurrReplicAd->nia,
36572 + (tmp | FRM_REPLIC_FR_BIT | FM_PCD_AD_RESULT_EXTENDED_MODE ));
36573 +}
36574 +
36575 +static void BuildSourceTd(void *p_Ad)
36576 +{
36577 + t_AdOfTypeContLookup *p_SourceTd;
36578 +
36579 + ASSERT_COND(p_Ad);
36580 +
36581 + p_SourceTd = (t_AdOfTypeContLookup *)p_Ad;
36582 +
36583 + IOMemSet32((uint8_t*)p_SourceTd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
36584 +
36585 + /* initialize the source table descriptor */
36586 + WRITE_UINT32(p_SourceTd->ccAdBase, FM_PCD_AD_CONT_LOOKUP_TYPE);
36587 + WRITE_UINT32(p_SourceTd->pcAndOffsets, FRM_REPLIC_SOURCE_TD_OPCODE);
36588 +}
36589 +
36590 +static t_Error BuildShadowAndModifyDescriptor(t_FmPcdFrmReplicGroup *p_ReplicGroup,
36591 + t_FmPcdFrmReplicMember *p_NextMember,
36592 + t_FmPcdFrmReplicMember *p_CurrentMember,
36593 + bool sourceDescriptor,
36594 + bool last)
36595 +{
36596 + t_FmPcd *p_FmPcd;
36597 + t_FmPcdFrmReplicMember shadowMember;
36598 + t_Error err;
36599 +
36600 + ASSERT_COND(p_ReplicGroup);
36601 + ASSERT_COND(p_ReplicGroup->h_FmPcd);
36602 +
36603 + p_FmPcd = p_ReplicGroup->h_FmPcd;
36604 + ASSERT_COND(p_FmPcd->p_CcShadow);
36605 +
36606 + if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
36607 + return ERROR_CODE(E_BUSY);
36608 +
36609 + if (sourceDescriptor)
36610 + {
36611 + BuildSourceTd(p_FmPcd->p_CcShadow);
36612 + LinkSourceToMember(p_ReplicGroup, p_FmPcd->p_CcShadow, p_NextMember);
36613 +
36614 + /* Modify the source table descriptor according to the prepared shadow descriptor */
36615 + err = ModifyDescriptor(p_ReplicGroup,
36616 + p_ReplicGroup->p_SourceTd,
36617 + p_FmPcd->p_CcShadow/* new prepared source td */);
36618 +
36619 + RELEASE_LOCK(p_FmPcd->shadowLock);
36620 + if (err)
36621 + RETURN_ERROR(MAJOR, err, ("Modify source Descriptor in BuildShadowAndModifyDescriptor"));
36622 +
36623 + }
36624 + else
36625 + {
36626 + IO2IOCpy32(p_FmPcd->p_CcShadow,
36627 + p_CurrentMember->p_MemberAd,
36628 + FM_PCD_CC_AD_ENTRY_SIZE);
36629 +
36630 + /* update the last bit in the shadow ad */
36631 + FillReplicAdOfTypeResult(p_FmPcd->p_CcShadow, last);
36632 +
36633 + shadowMember.p_MemberAd = p_FmPcd->p_CcShadow;
36634 +
36635 + /* update the next FR member index */
36636 + LinkMemberToMember(p_ReplicGroup, &shadowMember, p_NextMember);
36637 +
36638 + /* Modify the next member according to the prepared shadow descriptor */
36639 + err = ModifyDescriptor(p_ReplicGroup,
36640 + p_CurrentMember->p_MemberAd,
36641 + p_FmPcd->p_CcShadow);
36642 +
36643 + RELEASE_LOCK(p_FmPcd->shadowLock);
36644 + if (err)
36645 + RETURN_ERROR(MAJOR, err, ("Modify Descriptor in BuildShadowAndModifyDescriptor"));
36646 + }
36647 +
36648 +
36649 + return E_OK;
36650 +}
36651 +
36652 +static t_FmPcdFrmReplicMember* GetMemberByIndex(t_FmPcdFrmReplicGroup *p_ReplicGroup,
36653 + uint16_t memberIndex)
36654 +{
36655 + int i=0;
36656 + t_List *p_Pos;
36657 + t_FmPcdFrmReplicMember *p_Member = NULL;
36658 +
36659 + LIST_FOR_EACH(p_Pos, &p_ReplicGroup->membersList)
36660 + {
36661 + if (i == memberIndex)
36662 + {
36663 + p_Member = LIST_OBJECT(p_Pos, t_FmPcdFrmReplicMember, node);
36664 + return p_Member;
36665 + }
36666 + i++;
36667 + }
36668 + return p_Member;
36669 +}
36670 +
36671 +static t_Error AllocMember(t_FmPcdFrmReplicGroup *p_ReplicGroup)
36672 +{
36673 + t_FmPcdFrmReplicMember *p_CurrentMember;
36674 + t_Handle h_Muram;
36675 +
36676 + ASSERT_COND(p_ReplicGroup);
36677 +
36678 + h_Muram = FmPcdGetMuramHandle(p_ReplicGroup->h_FmPcd);
36679 + ASSERT_COND(h_Muram);
36680 +
36681 + /* Initialize an internal structure of a member to add to the available members list */
36682 + p_CurrentMember = (t_FmPcdFrmReplicMember *)XX_Malloc(sizeof(t_FmPcdFrmReplicMember));
36683 + if (!p_CurrentMember)
36684 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Frame replicator member"));
36685 +
36686 + memset(p_CurrentMember, 0 ,sizeof(t_FmPcdFrmReplicMember));
36687 +
36688 + /* Allocate the member AD */
36689 + p_CurrentMember->p_MemberAd =
36690 + (t_AdOfTypeResult*)FM_MURAM_AllocMem(h_Muram,
36691 + FM_PCD_CC_AD_ENTRY_SIZE,
36692 + FM_PCD_CC_AD_TABLE_ALIGN);
36693 + if (!p_CurrentMember->p_MemberAd)
36694 + {
36695 + XX_Free(p_CurrentMember);
36696 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("member AD table"));
36697 + }
36698 + IOMemSet32((uint8_t*)p_CurrentMember->p_MemberAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
36699 +
36700 + /* Add the new member to the available members list */
36701 + LIST_AddToTail(&p_CurrentMember->node, &(p_ReplicGroup->availableMembersList));
36702 +
36703 + return E_OK;
36704 +}
36705 +
36706 +static t_FmPcdFrmReplicMember* InitMember(t_FmPcdFrmReplicGroup *p_ReplicGroup,
36707 + t_FmPcdCcNextEngineParams *p_MemberParams,
36708 + bool last)
36709 +{
36710 + t_FmPcdFrmReplicMember *p_CurrentMember = NULL;
36711 +
36712 + ASSERT_COND(p_ReplicGroup);
36713 +
36714 + /* Get an available member from the internal members list */
36715 + p_CurrentMember = GetAvailableMember(p_ReplicGroup);
36716 + if (!p_CurrentMember)
36717 + {
36718 + REPORT_ERROR(MAJOR, E_NOT_FOUND, ("Available member"));
36719 + return NULL;
36720 + }
36721 + p_CurrentMember->h_Manip = NULL;
36722 +
36723 + /* clear the Ad of the new member */
36724 + IOMemSet32((uint8_t*)p_CurrentMember->p_MemberAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
36725 +
36726 + INIT_LIST(&p_CurrentMember->node);
36727 +
36728 + /* Initialize the Ad of the member */
36729 + NextStepAd(p_CurrentMember->p_MemberAd,
36730 + NULL,
36731 + p_MemberParams,
36732 + p_ReplicGroup->h_FmPcd);
36733 +
36734 + /* save Manip handle (for free needs) */
36735 + if (p_MemberParams->h_Manip)
36736 + p_CurrentMember->h_Manip = p_MemberParams->h_Manip;
36737 +
36738 + /* Initialize the relevant frame replicator fields in the AD */
36739 + FillReplicAdOfTypeResult(p_CurrentMember->p_MemberAd, last);
36740 +
36741 + return p_CurrentMember;
36742 +}
36743 +
36744 +static void FreeMember(t_FmPcdFrmReplicGroup *p_ReplicGroup,
36745 + t_FmPcdFrmReplicMember *p_Member)
36746 +{
36747 + /* Note: Can't free the member AD just returns the member to the available
36748 + member list - therefore only memset the AD */
36749 +
36750 + /* zero the AD */
36751 + IOMemSet32(p_Member->p_MemberAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
36752 +
36753 +
36754 + /* return the member to the available members list */
36755 + PutAvailableMember(p_ReplicGroup, p_Member);
36756 +}
36757 +
36758 +static t_Error RemoveMember(t_FmPcdFrmReplicGroup *p_ReplicGroup,
36759 + uint16_t memberIndex)
36760 +{
36761 + t_FmPcd *p_FmPcd = NULL;
36762 + t_FmPcdFrmReplicMember *p_CurrentMember = NULL, *p_PreviousMember = NULL, *p_NextMember = NULL;
36763 + t_Error err;
36764 + uint8_t memberPosition;
36765 +
36766 + p_FmPcd = p_ReplicGroup->h_FmPcd;
36767 + ASSERT_COND(p_FmPcd);
36768 + UNUSED(p_FmPcd);
36769 +
36770 + p_CurrentMember = GetMemberByIndex(p_ReplicGroup, memberIndex);
36771 + ASSERT_COND(p_CurrentMember);
36772 +
36773 + /* determine the member position in the group */
36774 + memberPosition = GetMemberPosition(p_ReplicGroup,
36775 + memberIndex,
36776 + FALSE/*remove operation*/);
36777 +
36778 + switch (memberPosition)
36779 + {
36780 + case FRM_REPLIC_FIRST_MEMBER_INDEX:
36781 + p_NextMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)(memberIndex+1));
36782 + ASSERT_COND(p_NextMember);
36783 +
36784 + /* update the source td itself by using a host command */
36785 + err = BuildShadowAndModifyDescriptor(p_ReplicGroup,
36786 + p_NextMember,
36787 + NULL,
36788 + TRUE/*sourceDescriptor*/,
36789 + FALSE/*last*/);
36790 + break;
36791 +
36792 + case FRM_REPLIC_MIDDLE_MEMBER_INDEX:
36793 + p_PreviousMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)(memberIndex-1));
36794 + ASSERT_COND(p_PreviousMember);
36795 +
36796 + p_NextMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)(memberIndex+1));
36797 + ASSERT_COND(p_NextMember);
36798 +
36799 + err = BuildShadowAndModifyDescriptor(p_ReplicGroup,
36800 + p_NextMember,
36801 + p_PreviousMember,
36802 + FALSE/*sourceDescriptor*/,
36803 + FALSE/*last*/);
36804 +
36805 + break;
36806 +
36807 + case FRM_REPLIC_LAST_MEMBER_INDEX:
36808 + p_PreviousMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)(memberIndex-1));
36809 + ASSERT_COND(p_PreviousMember);
36810 +
36811 + err = BuildShadowAndModifyDescriptor(p_ReplicGroup,
36812 + NULL,
36813 + p_PreviousMember,
36814 + FALSE/*sourceDescriptor*/,
36815 + TRUE/*last*/);
36816 + break;
36817 +
36818 + default:
36819 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("member position in remove member"));
36820 + }
36821 +
36822 + if (err)
36823 + RETURN_ERROR(MAJOR, err, NO_MSG);
36824 +
36825 + if (p_CurrentMember->h_Manip)
36826 + {
36827 + FmPcdManipUpdateOwner(p_CurrentMember->h_Manip, FALSE);
36828 + p_CurrentMember->h_Manip = NULL;
36829 + }
36830 +
36831 + /* remove the member from the driver internal members list */
36832 + RemoveMemberFromList(p_ReplicGroup, p_CurrentMember);
36833 +
36834 + /* return the member to the available members list */
36835 + FreeMember(p_ReplicGroup, p_CurrentMember);
36836 +
36837 + return E_OK;
36838 +}
36839 +
36840 +static void DeleteGroup(t_FmPcdFrmReplicGroup *p_ReplicGroup)
36841 +{
36842 + int i, j;
36843 + t_Handle h_Muram;
36844 + t_FmPcdFrmReplicMember *p_Member, *p_CurrentMember;
36845 +
36846 + if (p_ReplicGroup)
36847 + {
36848 + ASSERT_COND(p_ReplicGroup->h_FmPcd);
36849 + h_Muram = FmPcdGetMuramHandle(p_ReplicGroup->h_FmPcd);
36850 + ASSERT_COND(h_Muram);
36851 +
36852 + /* free the source table descriptor */
36853 + if (p_ReplicGroup->p_SourceTd)
36854 + {
36855 + FM_MURAM_FreeMem(h_Muram, p_ReplicGroup->p_SourceTd);
36856 + p_ReplicGroup->p_SourceTd = NULL;
36857 + }
36858 +
36859 + /* Remove all members from the members linked list (hw and sw) and
36860 + return the members to the available members list */
36861 + if (p_ReplicGroup->numOfEntries)
36862 + {
36863 + j = p_ReplicGroup->numOfEntries-1;
36864 +
36865 + /* manually removal of the member because there are no owners of
36866 + this group */
36867 + for (i=j; i>=0; i--)
36868 + {
36869 + p_CurrentMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)i/*memberIndex*/);
36870 + ASSERT_COND(p_CurrentMember);
36871 +
36872 + if (p_CurrentMember->h_Manip)
36873 + {
36874 + FmPcdManipUpdateOwner(p_CurrentMember->h_Manip, FALSE);
36875 + p_CurrentMember->h_Manip = NULL;
36876 + }
36877 +
36878 + /* remove the member from the internal driver members list */
36879 + RemoveMemberFromList(p_ReplicGroup, p_CurrentMember);
36880 +
36881 + /* return the member to the available members list */
36882 + FreeMember(p_ReplicGroup, p_CurrentMember);
36883 + }
36884 + }
36885 +
36886 + /* Free members AD */
36887 + for (i=0; i<p_ReplicGroup->maxNumOfEntries; i++)
36888 + {
36889 + p_Member = GetAvailableMember(p_ReplicGroup);
36890 + ASSERT_COND(p_Member);
36891 + if (p_Member->p_MemberAd)
36892 + {
36893 + FM_MURAM_FreeMem(h_Muram, p_Member->p_MemberAd);
36894 + p_Member->p_MemberAd = NULL;
36895 + }
36896 + XX_Free(p_Member);
36897 + }
36898 +
36899 + /* release the group lock */
36900 + if (p_ReplicGroup->p_Lock)
36901 + FmPcdReleaseLock(p_ReplicGroup->h_FmPcd, p_ReplicGroup->p_Lock);
36902 +
36903 + /* free the replicator group */
36904 + XX_Free(p_ReplicGroup);
36905 + }
36906 +}
36907 +
36908 +
36909 +/*****************************************************************************/
36910 +/* Inter-module API routines */
36911 +/*****************************************************************************/
36912 +
36913 +/* NOTE: the inter-module routines are locked by cc in case of using them */
36914 +void * FrmReplicGroupGetSourceTableDescriptor(t_Handle h_ReplicGroup)
36915 +{
36916 + t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;
36917 + ASSERT_COND(p_ReplicGroup);
36918 +
36919 + return (p_ReplicGroup->p_SourceTd);
36920 +}
36921 +
36922 +void FrmReplicGroupUpdateAd(t_Handle h_ReplicGroup,
36923 + void *p_Ad,
36924 + t_Handle *h_AdNew)
36925 +{
36926 + t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;
36927 + t_AdOfTypeResult *p_AdResult = (t_AdOfTypeResult*)p_Ad;
36928 + t_FmPcd *p_FmPcd;
36929 +
36930 + ASSERT_COND(p_ReplicGroup);
36931 + p_FmPcd = p_ReplicGroup->h_FmPcd;
36932 +
36933 + /* build a bypass ad */
36934 + WRITE_UINT32(p_AdResult->fqid, FM_PCD_AD_BYPASS_TYPE |
36935 + (uint32_t)((XX_VirtToPhys(p_ReplicGroup->p_SourceTd)) - p_FmPcd->physicalMuramBase));
36936 +
36937 + *h_AdNew = NULL;
36938 +}
36939 +
36940 +void FrmReplicGroupUpdateOwner(t_Handle h_ReplicGroup,
36941 + bool add)
36942 +{
36943 + t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;
36944 + ASSERT_COND(p_ReplicGroup);
36945 +
36946 + /* update the group owner counter */
36947 + if (add)
36948 + p_ReplicGroup->owners++;
36949 + else
36950 + {
36951 + ASSERT_COND(p_ReplicGroup->owners);
36952 + p_ReplicGroup->owners--;
36953 + }
36954 +}
36955 +
36956 +t_Error FrmReplicGroupTryLock(t_Handle h_ReplicGroup)
36957 +{
36958 + t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;
36959 +
36960 + ASSERT_COND(h_ReplicGroup);
36961 +
36962 + if (FmPcdLockTryLock(p_ReplicGroup->p_Lock))
36963 + return E_OK;
36964 +
36965 + return ERROR_CODE(E_BUSY);
36966 +}
36967 +
36968 +void FrmReplicGroupUnlock(t_Handle h_ReplicGroup)
36969 +{
36970 + t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;
36971 +
36972 + ASSERT_COND(h_ReplicGroup);
36973 +
36974 + FmPcdLockUnlock(p_ReplicGroup->p_Lock);
36975 +}
36976 +/*********************** End of inter-module routines ************************/
36977 +
36978 +
36979 +/****************************************/
36980 +/* API Init unit functions */
36981 +/****************************************/
36982 +t_Handle FM_PCD_FrmReplicSetGroup(t_Handle h_FmPcd,
36983 + t_FmPcdFrmReplicGroupParams *p_ReplicGroupParam)
36984 +{
36985 + t_FmPcdFrmReplicGroup *p_ReplicGroup;
36986 + t_FmPcdFrmReplicMember *p_CurrentMember, *p_NextMember = NULL;
36987 + int i;
36988 + t_Error err;
36989 + bool last = FALSE;
36990 + t_Handle h_Muram;
36991 +
36992 + SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);
36993 + SANITY_CHECK_RETURN_VALUE(p_ReplicGroupParam, E_INVALID_HANDLE, NULL);
36994 +
36995 + if (!FmPcdIsAdvancedOffloadSupported(h_FmPcd))
36996 + {
36997 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Advanced-offload must be enabled"));
36998 + return NULL;
36999 + }
37000 +
37001 + err = CheckParams(h_FmPcd, p_ReplicGroupParam);
37002 + if (err)
37003 + {
37004 + REPORT_ERROR(MAJOR, err, (NO_MSG));
37005 + return NULL;
37006 + }
37007 +
37008 + p_ReplicGroup = (t_FmPcdFrmReplicGroup*)XX_Malloc(sizeof(t_FmPcdFrmReplicGroup));
37009 + if (!p_ReplicGroup)
37010 + {
37011 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));
37012 + return NULL;
37013 + }
37014 + memset(p_ReplicGroup, 0, sizeof(t_FmPcdFrmReplicGroup));
37015 +
37016 + /* initialize lists for internal driver use */
37017 + INIT_LIST(&p_ReplicGroup->availableMembersList);
37018 + INIT_LIST(&p_ReplicGroup->membersList);
37019 +
37020 + p_ReplicGroup->h_FmPcd = h_FmPcd;
37021 +
37022 + h_Muram = FmPcdGetMuramHandle(p_ReplicGroup->h_FmPcd);
37023 + ASSERT_COND(h_Muram);
37024 +
37025 + /* initialize the group lock */
37026 + p_ReplicGroup->p_Lock = FmPcdAcquireLock(p_ReplicGroup->h_FmPcd);
37027 + if (!p_ReplicGroup->p_Lock)
37028 + {
37029 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Replic group lock"));
37030 + DeleteGroup(p_ReplicGroup);
37031 + return NULL;
37032 + }
37033 +
37034 + /* Allocate the frame replicator source table descriptor */
37035 + p_ReplicGroup->p_SourceTd =
37036 + (t_Handle)FM_MURAM_AllocMem(h_Muram,
37037 + FM_PCD_CC_AD_ENTRY_SIZE,
37038 + FM_PCD_CC_AD_TABLE_ALIGN);
37039 + if (!p_ReplicGroup->p_SourceTd)
37040 + {
37041 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("frame replicator source table descriptor"));
37042 + DeleteGroup(p_ReplicGroup);
37043 + return NULL;
37044 + }
37045 +
37046 + /* update the shadow size - required for the host commands */
37047 + err = FmPcdUpdateCcShadow(p_ReplicGroup->h_FmPcd,
37048 + FM_PCD_CC_AD_ENTRY_SIZE,
37049 + FM_PCD_CC_AD_TABLE_ALIGN);
37050 + if (err)
37051 + {
37052 + REPORT_ERROR(MAJOR, err, ("Update CC shadow"));
37053 + DeleteGroup(p_ReplicGroup);
37054 + return NULL;
37055 + }
37056 +
37057 + p_ReplicGroup->maxNumOfEntries = p_ReplicGroupParam->maxNumOfEntries;
37058 +
37059 + /* Allocate the maximal number of members ADs and Statistics AD for the group
37060 + It prevents allocation of Muram in run-time */
37061 + for (i=0; i<p_ReplicGroup->maxNumOfEntries; i++)
37062 + {
37063 + err = AllocMember(p_ReplicGroup);
37064 + if (err)
37065 + {
37066 + REPORT_ERROR(MAJOR, err, ("allocate a new member"));
37067 + DeleteGroup(p_ReplicGroup);
37068 + return NULL;
37069 + }
37070 + }
37071 +
37072 + /* Initialize the members linked lists:
37073 + (hw - the one that is used by the FMan controller and
37074 + sw - the one that is managed by the driver internally) */
37075 + for (i=(p_ReplicGroupParam->numOfEntries-1); i>=0; i--)
37076 + {
37077 + /* check if this is the last member in the group */
37078 + if (i == (p_ReplicGroupParam->numOfEntries-1))
37079 + last = TRUE;
37080 + else
37081 + last = FALSE;
37082 +
37083 + /* Initialize a new member */
37084 + p_CurrentMember = InitMember(p_ReplicGroup,
37085 + &(p_ReplicGroupParam->nextEngineParams[i]),
37086 + last);
37087 + if (!p_CurrentMember)
37088 + {
37089 + REPORT_ERROR(MAJOR, E_INVALID_HANDLE, ("No available member"));
37090 + DeleteGroup(p_ReplicGroup);
37091 + return NULL;
37092 + }
37093 +
37094 + /* Build the members group - link two consecutive members in the hw linked list */
37095 + LinkMemberToMember(p_ReplicGroup, p_CurrentMember, p_NextMember);
37096 +
37097 + /* update the driver internal members list to be compatible to the hw members linked list */
37098 + AddMemberToList(p_ReplicGroup, p_CurrentMember, &p_ReplicGroup->membersList);
37099 +
37100 + p_NextMember = p_CurrentMember;
37101 + }
37102 +
37103 + /* initialize the source table descriptor */
37104 + BuildSourceTd(p_ReplicGroup->p_SourceTd);
37105 +
37106 + /* link the source table descriptor to point to the first member in the group */
37107 + LinkSourceToMember(p_ReplicGroup, p_ReplicGroup->p_SourceTd, p_NextMember);
37108 +
37109 + return p_ReplicGroup;
37110 +}
37111 +
37112 +t_Error FM_PCD_FrmReplicDeleteGroup(t_Handle h_ReplicGroup)
37113 +{
37114 + t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;
37115 +
37116 + SANITY_CHECK_RETURN_ERROR(p_ReplicGroup, E_INVALID_HANDLE);
37117 +
37118 + if (p_ReplicGroup->owners)
37119 + RETURN_ERROR(MAJOR,
37120 + E_INVALID_STATE,
37121 + ("the group has owners and can't be deleted"));
37122 +
37123 + DeleteGroup(p_ReplicGroup);
37124 +
37125 + return E_OK;
37126 +}
37127 +
37128 +
37129 +/*****************************************************************************/
37130 +/* API Run-time Frame replicator Control unit functions */
37131 +/*****************************************************************************/
37132 +t_Error FM_PCD_FrmReplicAddMember(t_Handle h_ReplicGroup,
37133 + uint16_t memberIndex,
37134 + t_FmPcdCcNextEngineParams *p_MemberParams)
37135 +{
37136 + t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup*) h_ReplicGroup;
37137 + t_FmPcdFrmReplicMember *p_NewMember, *p_CurrentMember = NULL, *p_PreviousMember = NULL;
37138 + t_Error err;
37139 + uint8_t memberPosition;
37140 +
37141 + SANITY_CHECK_RETURN_ERROR(p_ReplicGroup, E_INVALID_HANDLE);
37142 + SANITY_CHECK_RETURN_ERROR(p_MemberParams, E_INVALID_HANDLE);
37143 +
37144 + /* group lock */
37145 + err = FrmReplicGroupTryLock(p_ReplicGroup);
37146 + if (GET_ERROR_TYPE(err) == E_BUSY)
37147 + return ERROR_CODE(E_BUSY);
37148 +
37149 + if (memberIndex > p_ReplicGroup->numOfEntries)
37150 + {
37151 + /* unlock */
37152 + FrmReplicGroupUnlock(p_ReplicGroup);
37153 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
37154 + ("memberIndex is greater than the members in the list"));
37155 + }
37156 +
37157 + if (memberIndex >= p_ReplicGroup->maxNumOfEntries)
37158 + {
37159 + /* unlock */
37160 + FrmReplicGroupUnlock(p_ReplicGroup);
37161 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("memberIndex is greater than the allowed number of members in the group"));
37162 + }
37163 +
37164 + if ((p_ReplicGroup->numOfEntries + 1) > FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES)
37165 + {
37166 + /* unlock */
37167 + FrmReplicGroupUnlock(p_ReplicGroup);
37168 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
37169 + ("numOfEntries with new entry can not be larger than %d\n",
37170 + FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES));
37171 + }
37172 +
37173 + err = MemberCheckParams(p_ReplicGroup->h_FmPcd, p_MemberParams);
37174 + if (err)
37175 + {
37176 + /* unlock */
37177 + FrmReplicGroupUnlock(p_ReplicGroup);
37178 + RETURN_ERROR(MAJOR, err, ("member check parameters in add operation"));
37179 + }
37180 + /* determine the member position in the group */
37181 + memberPosition = GetMemberPosition(p_ReplicGroup,
37182 + memberIndex,
37183 + TRUE/* add operation */);
37184 +
37185 + /* Initialize a new member */
37186 + p_NewMember = InitMember(p_ReplicGroup,
37187 + p_MemberParams,
37188 + (memberPosition == FRM_REPLIC_LAST_MEMBER_INDEX ? TRUE : FALSE));
37189 + if (!p_NewMember)
37190 + {
37191 + /* unlock */
37192 + FrmReplicGroupUnlock(p_ReplicGroup);
37193 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("No available member"));
37194 + }
37195 +
37196 + switch (memberPosition)
37197 + {
37198 + case FRM_REPLIC_FIRST_MEMBER_INDEX:
37199 + p_CurrentMember = GetMemberByIndex(p_ReplicGroup, memberIndex);
37200 + ASSERT_COND(p_CurrentMember);
37201 +
37202 + LinkMemberToMember(p_ReplicGroup, p_NewMember, p_CurrentMember);
37203 +
37204 + /* update the internal group source TD */
37205 + LinkSourceToMember(p_ReplicGroup,
37206 + p_ReplicGroup->p_SourceTd,
37207 + p_NewMember);
37208 +
37209 + /* add member to the internal sw member list */
37210 + AddMemberToList(p_ReplicGroup,
37211 + p_NewMember,
37212 + &p_ReplicGroup->membersList);
37213 + break;
37214 +
37215 + case FRM_REPLIC_MIDDLE_MEMBER_INDEX:
37216 + p_CurrentMember = GetMemberByIndex(p_ReplicGroup, memberIndex);
37217 + ASSERT_COND(p_CurrentMember);
37218 +
37219 + p_PreviousMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)(memberIndex-1));
37220 + ASSERT_COND(p_PreviousMember);
37221 +
37222 + LinkMemberToMember(p_ReplicGroup, p_NewMember, p_CurrentMember);
37223 + LinkMemberToMember(p_ReplicGroup, p_PreviousMember, p_NewMember);
37224 +
37225 + AddMemberToList(p_ReplicGroup, p_NewMember, &p_PreviousMember->node);
37226 + break;
37227 +
37228 + case FRM_REPLIC_LAST_MEMBER_INDEX:
37229 + p_PreviousMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)(memberIndex-1));
37230 + ASSERT_COND(p_PreviousMember);
37231 +
37232 + LinkMemberToMember(p_ReplicGroup, p_PreviousMember, p_NewMember);
37233 + FillReplicAdOfTypeResult(p_PreviousMember->p_MemberAd, FALSE/*last*/);
37234 +
37235 + /* add the new member to the internal sw member list */
37236 + AddMemberToList(p_ReplicGroup, p_NewMember, &p_PreviousMember->node);
37237 + break;
37238 +
37239 + default:
37240 + /* unlock */
37241 + FrmReplicGroupUnlock(p_ReplicGroup);
37242 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("member position in add member"));
37243 +
37244 + }
37245 +
37246 + /* unlock */
37247 + FrmReplicGroupUnlock(p_ReplicGroup);
37248 +
37249 + return E_OK;
37250 +}
37251 +
37252 +t_Error FM_PCD_FrmReplicRemoveMember(t_Handle h_ReplicGroup,
37253 + uint16_t memberIndex)
37254 +{
37255 + t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup*) h_ReplicGroup;
37256 + t_Error err;
37257 +
37258 + SANITY_CHECK_RETURN_ERROR(p_ReplicGroup, E_INVALID_HANDLE);
37259 +
37260 + /* lock */
37261 + err = FrmReplicGroupTryLock(p_ReplicGroup);
37262 + if (GET_ERROR_TYPE(err) == E_BUSY)
37263 + return ERROR_CODE(E_BUSY);
37264 +
37265 + if (memberIndex >= p_ReplicGroup->numOfEntries)
37266 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("member index to remove"));
37267 +
37268 + /* Design decision: group must contain at least one member
37269 + No possibility to remove the last member from the group */
37270 + if (p_ReplicGroup->numOfEntries == 1)
37271 + RETURN_ERROR(MAJOR, E_CONFLICT, ("Can't remove the last member. At least one member should be related to a group."));
37272 +
37273 + err = RemoveMember(p_ReplicGroup, memberIndex);
37274 +
37275 + /* unlock */
37276 + FrmReplicGroupUnlock(p_ReplicGroup);
37277 +
37278 + switch (GET_ERROR_TYPE(err))
37279 + {
37280 + case E_OK:
37281 + return E_OK;
37282 +
37283 + case E_BUSY:
37284 + DBG(TRACE, ("E_BUSY error"));
37285 + return ERROR_CODE(E_BUSY);
37286 +
37287 + default:
37288 + RETURN_ERROR(MAJOR, err, NO_MSG);
37289 + }
37290 +}
37291 +
37292 +/*********************** End of API routines ************************/
37293 +
37294 +
37295 --- /dev/null
37296 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_replic.h
37297 @@ -0,0 +1,101 @@
37298 +/*
37299 + * Copyright 2008-2012 Freescale Semiconductor Inc.
37300 + *
37301 + * Redistribution and use in source and binary forms, with or without
37302 + * modification, are permitted provided that the following conditions are met:
37303 + * * Redistributions of source code must retain the above copyright
37304 + * notice, this list of conditions and the following disclaimer.
37305 + * * Redistributions in binary form must reproduce the above copyright
37306 + * notice, this list of conditions and the following disclaimer in the
37307 + * documentation and/or other materials provided with the distribution.
37308 + * * Neither the name of Freescale Semiconductor nor the
37309 + * names of its contributors may be used to endorse or promote products
37310 + * derived from this software without specific prior written permission.
37311 + *
37312 + *
37313 + * ALTERNATIVELY, this software may be distributed under the terms of the
37314 + * GNU General Public License ("GPL") as published by the Free Software
37315 + * Foundation, either version 2 of that License or (at your option) any
37316 + * later version.
37317 + *
37318 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
37319 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
37320 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37321 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
37322 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37323 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37324 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37325 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37326 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37327 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37328 + */
37329 +
37330 +
37331 +/******************************************************************************
37332 + @File fm_replic.h
37333 +
37334 + @Description FM frame replicator
37335 +*//***************************************************************************/
37336 +#ifndef __FM_REPLIC_H
37337 +#define __FM_REPLIC_H
37338 +
37339 +#include "std_ext.h"
37340 +#include "error_ext.h"
37341 +
37342 +
37343 +#define FRM_REPLIC_SOURCE_TD_OPCODE 0x75
37344 +#define NEXT_FRM_REPLIC_ADDR_SHIFT 4
37345 +#define NEXT_FRM_REPLIC_MEMBER_INDEX_SHIFT 16
37346 +#define FRM_REPLIC_FR_BIT 0x08000000
37347 +#define FRM_REPLIC_NL_BIT 0x10000000
37348 +#define FRM_REPLIC_INVALID_MEMBER_INDEX 0xffff
37349 +#define FRM_REPLIC_FIRST_MEMBER_INDEX 0
37350 +
37351 +#define FRM_REPLIC_MIDDLE_MEMBER_INDEX 1
37352 +#define FRM_REPLIC_LAST_MEMBER_INDEX 2
37353 +
37354 +#define SOURCE_TD_ITSELF_OPTION 0x01
37355 +#define SOURCE_TD_COPY_OPTION 0x02
37356 +#define SOURCE_TD_ITSELF_AND_COPY_OPTION SOURCE_TD_ITSELF_OPTION | SOURCE_TD_COPY_OPTION
37357 +#define SOURCE_TD_NONE 0x04
37358 +
37359 +/*typedef enum e_SourceTdOption
37360 +{
37361 + e_SOURCE_TD_NONE = 0,
37362 + e_SOURCE_TD_ITSELF_OPTION = 1,
37363 + e_SOURCE_TD_COPY_OPTION = 2,
37364 + e_SOURCE_TD_ITSELF_AND_COPY_OPTION = e_SOURCE_TD_ITSELF_OPTION | e_SOURCE_TD_COPY_OPTION
37365 +} e_SourceTdOption;
37366 +*/
37367 +
37368 +typedef struct
37369 +{
37370 + volatile uint32_t type;
37371 + volatile uint32_t frGroupPointer;
37372 + volatile uint32_t operationCode;
37373 + volatile uint32_t reserved;
37374 +} t_FrmReplicGroupSourceAd;
37375 +
37376 +typedef struct t_FmPcdFrmReplicMember
37377 +{
37378 + void *p_MemberAd; /**< pointer to the member AD */
37379 + void *p_StatisticsAd;/**< pointer to the statistics AD of the member */
37380 + t_Handle h_Manip; /**< manip handle - need for free routines */
37381 + t_List node;
37382 +} t_FmPcdFrmReplicMember;
37383 +
37384 +typedef struct t_FmPcdFrmReplicGroup
37385 +{
37386 + t_Handle h_FmPcd;
37387 +
37388 + uint8_t maxNumOfEntries;/**< maximal number of members in the group */
37389 + uint8_t numOfEntries; /**< actual number of members in the group */
37390 + uint16_t owners; /**< how many keys share this frame replicator group */
37391 + void *p_SourceTd; /**< pointer to the frame replicator source table descriptor */
37392 + t_List membersList; /**< the members list - should reflect the order of the members as in the hw linked list*/
37393 + t_List availableMembersList;/**< list of all the available members in the group */
37394 + t_FmPcdLock *p_Lock;
37395 +} t_FmPcdFrmReplicGroup;
37396 +
37397 +
37398 +#endif /* __FM_REPLIC_H */
37399 --- /dev/null
37400 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fman_kg.c
37401 @@ -0,0 +1,888 @@
37402 +/*
37403 + * Copyright 2008-2012 Freescale Semiconductor Inc.
37404 + *
37405 + * Redistribution and use in source and binary forms, with or without
37406 + * modification, are permitted provided that the following conditions are met:
37407 + * * Redistributions of source code must retain the above copyright
37408 + * notice, this list of conditions and the following disclaimer.
37409 + * * Redistributions in binary form must reproduce the above copyright
37410 + * notice, this list of conditions and the following disclaimer in the
37411 + * documentation and/or other materials provided with the distribution.
37412 + * * Neither the name of Freescale Semiconductor nor the
37413 + * names of its contributors may be used to endorse or promote products
37414 + * derived from this software without specific prior written permission.
37415 + *
37416 + *
37417 + * ALTERNATIVELY, this software may be distributed under the terms of the
37418 + * GNU General Public License ("GPL") as published by the Free Software
37419 + * Foundation, either version 2 of that License or (at your option) any
37420 + * later version.
37421 + *
37422 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
37423 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
37424 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37425 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
37426 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37427 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37428 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37429 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37430 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37431 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37432 + */
37433 +
37434 +#include "fsl_fman_kg.h"
37435 +
37436 +/****************************************/
37437 +/* static functions */
37438 +/****************************************/
37439 +
37440 +
37441 +static uint32_t build_ar_bind_scheme(uint8_t hwport_id, bool write)
37442 +{
37443 + uint32_t rw;
37444 +
37445 + rw = write ? (uint32_t)FM_KG_KGAR_WRITE : (uint32_t)FM_KG_KGAR_READ;
37446 +
37447 + return (uint32_t)(FM_KG_KGAR_GO |
37448 + rw |
37449 + FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
37450 + hwport_id |
37451 + FM_PCD_KG_KGAR_SEL_PORT_WSEL_SP);
37452 +}
37453 +
37454 +static void clear_pe_all_scheme(struct fman_kg_regs *regs, uint8_t hwport_id)
37455 +{
37456 + uint32_t ar;
37457 +
37458 + fman_kg_write_sp(regs, 0xffffffff, 0);
37459 +
37460 + ar = build_ar_bind_scheme(hwport_id, TRUE);
37461 + fman_kg_write_ar_wait(regs, ar);
37462 +}
37463 +
37464 +static uint32_t build_ar_bind_cls_plan(uint8_t hwport_id, bool write)
37465 +{
37466 + uint32_t rw;
37467 +
37468 + rw = write ? (uint32_t)FM_KG_KGAR_WRITE : (uint32_t)FM_KG_KGAR_READ;
37469 +
37470 + return (uint32_t)(FM_KG_KGAR_GO |
37471 + rw |
37472 + FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
37473 + hwport_id |
37474 + FM_PCD_KG_KGAR_SEL_PORT_WSEL_CPP);
37475 +}
37476 +
37477 +static void clear_pe_all_cls_plan(struct fman_kg_regs *regs, uint8_t hwport_id)
37478 +{
37479 + uint32_t ar;
37480 +
37481 + fman_kg_write_cpp(regs, 0);
37482 +
37483 + ar = build_ar_bind_cls_plan(hwport_id, TRUE);
37484 + fman_kg_write_ar_wait(regs, ar);
37485 +}
37486 +
37487 +static uint8_t get_gen_ht_code(enum fman_kg_gen_extract_src src,
37488 + bool no_validation,
37489 + uint8_t *offset)
37490 +{
37491 + int code;
37492 +
37493 + switch (src) {
37494 + case E_FMAN_KG_GEN_EXTRACT_ETH:
37495 + code = no_validation ? 0x73 : 0x3;
37496 + break;
37497 +
37498 + case E_FMAN_KG_GEN_EXTRACT_ETYPE:
37499 + code = no_validation ? 0x77 : 0x7;
37500 + break;
37501 +
37502 + case E_FMAN_KG_GEN_EXTRACT_SNAP:
37503 + code = no_validation ? 0x74 : 0x4;
37504 + break;
37505 +
37506 + case E_FMAN_KG_GEN_EXTRACT_VLAN_TCI_1:
37507 + code = no_validation ? 0x75 : 0x5;
37508 + break;
37509 +
37510 + case E_FMAN_KG_GEN_EXTRACT_VLAN_TCI_N:
37511 + code = no_validation ? 0x76 : 0x6;
37512 + break;
37513 +
37514 + case E_FMAN_KG_GEN_EXTRACT_PPPoE:
37515 + code = no_validation ? 0x78 : 0x8;
37516 + break;
37517 +
37518 + case E_FMAN_KG_GEN_EXTRACT_MPLS_1:
37519 + code = no_validation ? 0x79 : 0x9;
37520 + break;
37521 +
37522 + case E_FMAN_KG_GEN_EXTRACT_MPLS_2:
37523 + code = no_validation ? FM_KG_SCH_GEN_HT_INVALID : 0x19;
37524 + break;
37525 +
37526 + case E_FMAN_KG_GEN_EXTRACT_MPLS_3:
37527 + code = no_validation ? FM_KG_SCH_GEN_HT_INVALID : 0x29;
37528 + break;
37529 +
37530 + case E_FMAN_KG_GEN_EXTRACT_MPLS_N:
37531 + code = no_validation ? 0x7a : 0xa;
37532 + break;
37533 +
37534 + case E_FMAN_KG_GEN_EXTRACT_IPv4_1:
37535 + code = no_validation ? 0x7b : 0xb;
37536 + break;
37537 +
37538 + case E_FMAN_KG_GEN_EXTRACT_IPv6_1:
37539 + code = no_validation ? 0x7b : 0x1b;
37540 + break;
37541 +
37542 + case E_FMAN_KG_GEN_EXTRACT_IPv4_2:
37543 + code = no_validation ? 0x7c : 0xc;
37544 + break;
37545 +
37546 + case E_FMAN_KG_GEN_EXTRACT_IPv6_2:
37547 + code = no_validation ? 0x7c : 0x1c;
37548 + break;
37549 +
37550 + case E_FMAN_KG_GEN_EXTRACT_MINENCAP:
37551 + code = no_validation ? 0x7c : 0x2c;
37552 + break;
37553 +
37554 + case E_FMAN_KG_GEN_EXTRACT_IP_PID:
37555 + code = no_validation ? 0x72 : 0x2;
37556 + break;
37557 +
37558 + case E_FMAN_KG_GEN_EXTRACT_GRE:
37559 + code = no_validation ? 0x7d : 0xd;
37560 + break;
37561 +
37562 + case E_FMAN_KG_GEN_EXTRACT_TCP:
37563 + code = no_validation ? 0x7e : 0xe;
37564 + break;
37565 +
37566 + case E_FMAN_KG_GEN_EXTRACT_UDP:
37567 + code = no_validation ? 0x7e : 0x1e;
37568 + break;
37569 +
37570 + case E_FMAN_KG_GEN_EXTRACT_SCTP:
37571 + code = no_validation ? 0x7e : 0x3e;
37572 + break;
37573 +
37574 + case E_FMAN_KG_GEN_EXTRACT_DCCP:
37575 + code = no_validation ? 0x7e : 0x4e;
37576 + break;
37577 +
37578 + case E_FMAN_KG_GEN_EXTRACT_IPSEC_AH:
37579 + code = no_validation ? 0x7e : 0x2e;
37580 + break;
37581 +
37582 + case E_FMAN_KG_GEN_EXTRACT_IPSEC_ESP:
37583 + code = no_validation ? 0x7e : 0x6e;
37584 + break;
37585 +
37586 + case E_FMAN_KG_GEN_EXTRACT_SHIM_1:
37587 + code = 0x70;
37588 + break;
37589 +
37590 + case E_FMAN_KG_GEN_EXTRACT_SHIM_2:
37591 + code = 0x71;
37592 + break;
37593 +
37594 + case E_FMAN_KG_GEN_EXTRACT_FROM_DFLT:
37595 + code = 0x10;
37596 + break;
37597 +
37598 + case E_FMAN_KG_GEN_EXTRACT_FROM_FRAME_START:
37599 + code = 0x40;
37600 + break;
37601 +
37602 + case E_FMAN_KG_GEN_EXTRACT_FROM_PARSE_RESULT:
37603 + code = 0x20;
37604 + break;
37605 +
37606 + case E_FMAN_KG_GEN_EXTRACT_FROM_END_OF_PARSE:
37607 + code = 0x7f;
37608 + break;
37609 +
37610 + case E_FMAN_KG_GEN_EXTRACT_FROM_FQID:
37611 + code = 0x20;
37612 + *offset += 0x20;
37613 + break;
37614 +
37615 + default:
37616 + code = FM_KG_SCH_GEN_HT_INVALID;
37617 + }
37618 +
37619 + return (uint8_t)code;
37620 +}
37621 +
37622 +static uint32_t build_ar_scheme(uint8_t scheme,
37623 + uint8_t hwport_id,
37624 + bool update_counter,
37625 + bool write)
37626 +{
37627 + uint32_t rw;
37628 +
37629 + rw = (uint32_t)(write ? FM_KG_KGAR_WRITE : FM_KG_KGAR_READ);
37630 +
37631 + return (uint32_t)(FM_KG_KGAR_GO |
37632 + rw |
37633 + FM_KG_KGAR_SEL_SCHEME_ENTRY |
37634 + hwport_id |
37635 + ((uint32_t)scheme << FM_KG_KGAR_NUM_SHIFT) |
37636 + (update_counter ? FM_KG_KGAR_SCM_WSEL_UPDATE_CNT : 0));
37637 +}
37638 +
37639 +static uint32_t build_ar_cls_plan(uint8_t grp,
37640 + uint8_t entries_mask,
37641 + uint8_t hwport_id,
37642 + bool write)
37643 +{
37644 + uint32_t rw;
37645 +
37646 + rw = (uint32_t)(write ? FM_KG_KGAR_WRITE : FM_KG_KGAR_READ);
37647 +
37648 + return (uint32_t)(FM_KG_KGAR_GO |
37649 + rw |
37650 + FM_PCD_KG_KGAR_SEL_CLS_PLAN_ENTRY |
37651 + hwport_id |
37652 + ((uint32_t)grp << FM_KG_KGAR_NUM_SHIFT) |
37653 + ((uint32_t)entries_mask << FM_KG_KGAR_WSEL_SHIFT));
37654 +}
37655 +
37656 +int fman_kg_write_ar_wait(struct fman_kg_regs *regs, uint32_t fmkg_ar)
37657 +{
37658 + iowrite32be(fmkg_ar, &regs->fmkg_ar);
37659 + /* Wait for GO to be idle and read error */
37660 + while ((fmkg_ar = ioread32be(&regs->fmkg_ar)) & FM_KG_KGAR_GO) ;
37661 + if (fmkg_ar & FM_PCD_KG_KGAR_ERR)
37662 + return -EINVAL;
37663 + return 0;
37664 +}
37665 +
37666 +void fman_kg_write_sp(struct fman_kg_regs *regs, uint32_t sp, bool add)
37667 +{
37668 +
37669 + struct fman_kg_pe_regs *kgpe_regs;
37670 + uint32_t tmp;
37671 +
37672 + kgpe_regs = (struct fman_kg_pe_regs *)&(regs->fmkg_indirect[0]);
37673 + tmp = ioread32be(&kgpe_regs->fmkg_pe_sp);
37674 +
37675 + if (add)
37676 + tmp |= sp;
37677 + else /* clear */
37678 + tmp &= ~sp;
37679 +
37680 + iowrite32be(tmp, &kgpe_regs->fmkg_pe_sp);
37681 +
37682 +}
37683 +
37684 +void fman_kg_write_cpp(struct fman_kg_regs *regs, uint32_t cpp)
37685 +{
37686 + struct fman_kg_pe_regs *kgpe_regs;
37687 +
37688 + kgpe_regs = (struct fman_kg_pe_regs *)&(regs->fmkg_indirect[0]);
37689 +
37690 + iowrite32be(cpp, &kgpe_regs->fmkg_pe_cpp);
37691 +}
37692 +
37693 +void fman_kg_get_event(struct fman_kg_regs *regs,
37694 + uint32_t *event,
37695 + uint32_t *scheme_idx)
37696 +{
37697 + uint32_t mask, force;
37698 +
37699 + *event = ioread32be(&regs->fmkg_eer);
37700 + mask = ioread32be(&regs->fmkg_eeer);
37701 + *scheme_idx = ioread32be(&regs->fmkg_seer);
37702 + *scheme_idx &= ioread32be(&regs->fmkg_seeer);
37703 +
37704 + *event &= mask;
37705 +
37706 + /* clear the forced events */
37707 + force = ioread32be(&regs->fmkg_feer);
37708 + if (force & *event)
37709 + iowrite32be(force & ~*event ,&regs->fmkg_feer);
37710 +
37711 + iowrite32be(*event, &regs->fmkg_eer);
37712 + iowrite32be(*scheme_idx, &regs->fmkg_seer);
37713 +}
37714 +
37715 +
37716 +void fman_kg_init(struct fman_kg_regs *regs,
37717 + uint32_t exceptions,
37718 + uint32_t dflt_nia)
37719 +{
37720 + uint32_t tmp;
37721 + int i;
37722 +
37723 + iowrite32be(FM_EX_KG_DOUBLE_ECC | FM_EX_KG_KEYSIZE_OVERFLOW,
37724 + &regs->fmkg_eer);
37725 +
37726 + tmp = 0;
37727 + if (exceptions & FM_EX_KG_DOUBLE_ECC)
37728 + tmp |= FM_EX_KG_DOUBLE_ECC;
37729 +
37730 + if (exceptions & FM_EX_KG_KEYSIZE_OVERFLOW)
37731 + tmp |= FM_EX_KG_KEYSIZE_OVERFLOW;
37732 +
37733 + iowrite32be(tmp, &regs->fmkg_eeer);
37734 + iowrite32be(0, &regs->fmkg_fdor);
37735 + iowrite32be(0, &regs->fmkg_gdv0r);
37736 + iowrite32be(0, &regs->fmkg_gdv1r);
37737 + iowrite32be(dflt_nia, &regs->fmkg_gcr);
37738 +
37739 + /* Clear binding between ports to schemes and classification plans
37740 + * so that all ports are not bound to any scheme/classification plan */
37741 + for (i = 0; i < FMAN_MAX_NUM_OF_HW_PORTS; i++) {
37742 + clear_pe_all_scheme(regs, (uint8_t)i);
37743 + clear_pe_all_cls_plan(regs, (uint8_t)i);
37744 + }
37745 +}
37746 +
37747 +void fman_kg_enable_scheme_interrupts(struct fman_kg_regs *regs)
37748 +{
37749 + /* enable and enable all scheme interrupts */
37750 + iowrite32be(0xFFFFFFFF, &regs->fmkg_seer);
37751 + iowrite32be(0xFFFFFFFF, &regs->fmkg_seeer);
37752 +}
37753 +
37754 +void fman_kg_enable(struct fman_kg_regs *regs)
37755 +{
37756 + iowrite32be(ioread32be(&regs->fmkg_gcr) | FM_KG_KGGCR_EN,
37757 + &regs->fmkg_gcr);
37758 +}
37759 +
37760 +void fman_kg_disable(struct fman_kg_regs *regs)
37761 +{
37762 + iowrite32be(ioread32be(&regs->fmkg_gcr) & ~FM_KG_KGGCR_EN,
37763 + &regs->fmkg_gcr);
37764 +}
37765 +
37766 +void fman_kg_set_data_after_prs(struct fman_kg_regs *regs, uint8_t offset)
37767 +{
37768 + iowrite32be(offset, &regs->fmkg_fdor);
37769 +}
37770 +
37771 +void fman_kg_set_dflt_val(struct fman_kg_regs *regs,
37772 + uint8_t def_id,
37773 + uint32_t val)
37774 +{
37775 + if(def_id == 0)
37776 + iowrite32be(val, &regs->fmkg_gdv0r);
37777 + else
37778 + iowrite32be(val, &regs->fmkg_gdv1r);
37779 +}
37780 +
37781 +
37782 +void fman_kg_set_exception(struct fman_kg_regs *regs,
37783 + uint32_t exception,
37784 + bool enable)
37785 +{
37786 + uint32_t tmp;
37787 +
37788 + tmp = ioread32be(&regs->fmkg_eeer);
37789 +
37790 + if (enable) {
37791 + tmp |= exception;
37792 + } else {
37793 + tmp &= ~exception;
37794 + }
37795 +
37796 + iowrite32be(tmp, &regs->fmkg_eeer);
37797 +}
37798 +
37799 +void fman_kg_get_exception(struct fman_kg_regs *regs,
37800 + uint32_t *events,
37801 + uint32_t *scheme_ids,
37802 + bool clear)
37803 +{
37804 + uint32_t mask;
37805 +
37806 + *events = ioread32be(&regs->fmkg_eer);
37807 + mask = ioread32be(&regs->fmkg_eeer);
37808 + *events &= mask;
37809 +
37810 + *scheme_ids = 0;
37811 +
37812 + if (*events & FM_EX_KG_KEYSIZE_OVERFLOW) {
37813 + *scheme_ids = ioread32be(&regs->fmkg_seer);
37814 + mask = ioread32be(&regs->fmkg_seeer);
37815 + *scheme_ids &= mask;
37816 + }
37817 +
37818 + if (clear) {
37819 + iowrite32be(*scheme_ids, &regs->fmkg_seer);
37820 + iowrite32be(*events, &regs->fmkg_eer);
37821 + }
37822 +}
37823 +
37824 +void fman_kg_get_capture(struct fman_kg_regs *regs,
37825 + struct fman_kg_ex_ecc_attr *ecc_attr,
37826 + bool clear)
37827 +{
37828 + uint32_t tmp;
37829 +
37830 + tmp = ioread32be(&regs->fmkg_serc);
37831 +
37832 + if (tmp & KG_FMKG_SERC_CAP) {
37833 + /* Captured data is valid */
37834 + ecc_attr->valid = TRUE;
37835 + ecc_attr->double_ecc =
37836 + (bool)((tmp & KG_FMKG_SERC_CET) ? TRUE : FALSE);
37837 + ecc_attr->single_ecc_count =
37838 + (uint8_t)((tmp & KG_FMKG_SERC_CNT_MSK) >>
37839 + KG_FMKG_SERC_CNT_SHIFT);
37840 + ecc_attr->addr = (uint16_t)(tmp & KG_FMKG_SERC_ADDR_MSK);
37841 +
37842 + if (clear)
37843 + iowrite32be(KG_FMKG_SERC_CAP, &regs->fmkg_serc);
37844 + } else {
37845 + /* No ECC error is captured */
37846 + ecc_attr->valid = FALSE;
37847 + }
37848 +}
37849 +
37850 +int fman_kg_build_scheme(struct fman_kg_scheme_params *params,
37851 + struct fman_kg_scheme_regs *scheme_regs)
37852 +{
37853 + struct fman_kg_extract_params *extract_params;
37854 + struct fman_kg_gen_extract_params *gen_params;
37855 + uint32_t tmp_reg, i, select, mask, fqb;
37856 + uint8_t offset, shift, ht;
37857 +
37858 + /* Zero out all registers so no need to care about unused ones */
37859 + memset(scheme_regs, 0, sizeof(struct fman_kg_scheme_regs));
37860 +
37861 + /* Mode register */
37862 + tmp_reg = fm_kg_build_nia(params->next_engine,
37863 + params->next_engine_action);
37864 + if (tmp_reg == KG_NIA_INVALID) {
37865 + return -EINVAL;
37866 + }
37867 +
37868 + if (params->next_engine == E_FMAN_PCD_PLCR) {
37869 + tmp_reg |= FMAN_KG_SCH_MODE_NIA_PLCR;
37870 + }
37871 + else if (params->next_engine == E_FMAN_PCD_CC) {
37872 + tmp_reg |= (uint32_t)params->cc_params.base_offset <<
37873 + FMAN_KG_SCH_MODE_CCOBASE_SHIFT;
37874 + }
37875 +
37876 + tmp_reg |= FMAN_KG_SCH_MODE_EN;
37877 + scheme_regs->kgse_mode = tmp_reg;
37878 +
37879 + /* Match vector */
37880 + scheme_regs->kgse_mv = params->match_vector;
37881 +
37882 + extract_params = &params->extract_params;
37883 +
37884 + /* Scheme default values registers */
37885 + scheme_regs->kgse_dv0 = extract_params->def_scheme_0;
37886 + scheme_regs->kgse_dv1 = extract_params->def_scheme_1;
37887 +
37888 + /* Extract Known Fields Command register */
37889 + scheme_regs->kgse_ekfc = extract_params->known_fields;
37890 +
37891 + /* Entry Extract Known Default Value register */
37892 + tmp_reg = 0;
37893 + tmp_reg |= extract_params->known_fields_def.mac_addr <<
37894 + FMAN_KG_SCH_DEF_MAC_ADDR_SHIFT;
37895 + tmp_reg |= extract_params->known_fields_def.vlan_tci <<
37896 + FMAN_KG_SCH_DEF_VLAN_TCI_SHIFT;
37897 + tmp_reg |= extract_params->known_fields_def.etype <<
37898 + FMAN_KG_SCH_DEF_ETYPE_SHIFT;
37899 + tmp_reg |= extract_params->known_fields_def.ppp_sid <<
37900 + FMAN_KG_SCH_DEF_PPP_SID_SHIFT;
37901 + tmp_reg |= extract_params->known_fields_def.ppp_pid <<
37902 + FMAN_KG_SCH_DEF_PPP_PID_SHIFT;
37903 + tmp_reg |= extract_params->known_fields_def.mpls <<
37904 + FMAN_KG_SCH_DEF_MPLS_SHIFT;
37905 + tmp_reg |= extract_params->known_fields_def.ip_addr <<
37906 + FMAN_KG_SCH_DEF_IP_ADDR_SHIFT;
37907 + tmp_reg |= extract_params->known_fields_def.ptype <<
37908 + FMAN_KG_SCH_DEF_PTYPE_SHIFT;
37909 + tmp_reg |= extract_params->known_fields_def.ip_tos_tc <<
37910 + FMAN_KG_SCH_DEF_IP_TOS_TC_SHIFT;
37911 + tmp_reg |= extract_params->known_fields_def.ipv6_fl <<
37912 + FMAN_KG_SCH_DEF_IPv6_FL_SHIFT;
37913 + tmp_reg |= extract_params->known_fields_def.ipsec_spi <<
37914 + FMAN_KG_SCH_DEF_IPSEC_SPI_SHIFT;
37915 + tmp_reg |= extract_params->known_fields_def.l4_port <<
37916 + FMAN_KG_SCH_DEF_L4_PORT_SHIFT;
37917 + tmp_reg |= extract_params->known_fields_def.tcp_flg <<
37918 + FMAN_KG_SCH_DEF_TCP_FLG_SHIFT;
37919 +
37920 + scheme_regs->kgse_ekdv = tmp_reg;
37921 +
37922 + /* Generic extract registers */
37923 + if (extract_params->gen_extract_num > FM_KG_NUM_OF_GENERIC_REGS) {
37924 + return -EINVAL;
37925 + }
37926 +
37927 + for (i = 0; i < extract_params->gen_extract_num; i++) {
37928 + gen_params = extract_params->gen_extract + i;
37929 +
37930 + tmp_reg = FMAN_KG_SCH_GEN_VALID;
37931 + tmp_reg |= (uint32_t)gen_params->def_val <<
37932 + FMAN_KG_SCH_GEN_DEF_SHIFT;
37933 +
37934 + if (gen_params->type == E_FMAN_KG_HASH_EXTRACT) {
37935 + if ((gen_params->extract > FMAN_KG_SCH_GEN_SIZE_MAX) ||
37936 + (gen_params->extract == 0)) {
37937 + return -EINVAL;
37938 + }
37939 + } else {
37940 + tmp_reg |= FMAN_KG_SCH_GEN_OR;
37941 + }
37942 +
37943 + tmp_reg |= (uint32_t)gen_params->extract <<
37944 + FMAN_KG_SCH_GEN_SIZE_SHIFT;
37945 + tmp_reg |= (uint32_t)gen_params->mask <<
37946 + FMAN_KG_SCH_GEN_MASK_SHIFT;
37947 +
37948 + offset = gen_params->offset;
37949 + ht = get_gen_ht_code(gen_params->src,
37950 + gen_params->no_validation,
37951 + &offset);
37952 + tmp_reg |= (uint32_t)ht << FMAN_KG_SCH_GEN_HT_SHIFT;
37953 + tmp_reg |= offset;
37954 +
37955 + scheme_regs->kgse_gec[i] = tmp_reg;
37956 + }
37957 +
37958 + /* Masks registers */
37959 + if (extract_params->masks_num > FM_KG_EXTRACT_MASKS_NUM) {
37960 + return -EINVAL;
37961 + }
37962 +
37963 + select = 0;
37964 + mask = 0;
37965 + fqb = 0;
37966 + for (i = 0; i < extract_params->masks_num; i++) {
37967 + /* MCSx fields */
37968 + KG_GET_MASK_SEL_SHIFT(shift, i);
37969 + if (extract_params->masks[i].is_known) {
37970 + /* Mask known field */
37971 + select |= extract_params->masks[i].field_or_gen_idx <<
37972 + shift;
37973 + } else {
37974 + /* Mask generic extract */
37975 + select |= (extract_params->masks[i].field_or_gen_idx +
37976 + FM_KG_MASK_SEL_GEN_BASE) << shift;
37977 + }
37978 +
37979 + /* MOx fields - spread between se_bmch and se_fqb registers */
37980 + KG_GET_MASK_OFFSET_SHIFT(shift, i);
37981 + if (i < 2) {
37982 + select |= (uint32_t)extract_params->masks[i].offset <<
37983 + shift;
37984 + } else {
37985 + fqb |= (uint32_t)extract_params->masks[i].offset <<
37986 + shift;
37987 + }
37988 +
37989 + /* BMx fields */
37990 + KG_GET_MASK_SHIFT(shift, i);
37991 + mask |= (uint32_t)extract_params->masks[i].mask << shift;
37992 + }
37993 +
37994 + /* Finish with rest of BMx fileds -
37995 + * don't mask bits for unused masks by setting
37996 + * corresponding BMx field = 0xFF */
37997 + for (i = extract_params->masks_num; i < FM_KG_EXTRACT_MASKS_NUM; i++) {
37998 + KG_GET_MASK_SHIFT(shift, i);
37999 + mask |= 0xFF << shift;
38000 + }
38001 +
38002 + scheme_regs->kgse_bmch = select;
38003 + scheme_regs->kgse_bmcl = mask;
38004 +
38005 + /* Finish with FQB register initialization.
38006 + * Check fqid is 24-bit value. */
38007 + if (params->base_fqid & ~0x00FFFFFF) {
38008 + return -EINVAL;
38009 + }
38010 +
38011 + fqb |= params->base_fqid;
38012 + scheme_regs->kgse_fqb = fqb;
38013 +
38014 + /* Hash Configuration register */
38015 + tmp_reg = 0;
38016 + if (params->hash_params.use_hash) {
38017 + /* Check hash mask is 24-bit value */
38018 + if (params->hash_params.mask & ~0x00FFFFFF) {
38019 + return -EINVAL;
38020 + }
38021 +
38022 + /* Hash function produces 64-bit value, 24 bits of that
38023 + * are used to generate fq_id and policer profile.
38024 + * Thus, maximal shift is 40 bits to allow 24 bits out of 64.
38025 + */
38026 + if (params->hash_params.shift_r > FMAN_KG_SCH_HASH_HSHIFT_MAX) {
38027 + return -EINVAL;
38028 + }
38029 +
38030 + tmp_reg |= params->hash_params.mask;
38031 + tmp_reg |= (uint32_t)params->hash_params.shift_r <<
38032 + FMAN_KG_SCH_HASH_HSHIFT_SHIFT;
38033 +
38034 + if (params->hash_params.sym) {
38035 + tmp_reg |= FMAN_KG_SCH_HASH_SYM;
38036 + }
38037 +
38038 + }
38039 +
38040 + if (params->bypass_fqid_gen) {
38041 + tmp_reg |= FMAN_KG_SCH_HASH_NO_FQID_GEN;
38042 + }
38043 +
38044 + scheme_regs->kgse_hc = tmp_reg;
38045 +
38046 + /* Policer Profile register */
38047 + if (params->policer_params.bypass_pp_gen) {
38048 + tmp_reg = 0;
38049 + } else {
38050 + /* Lower 8 bits of 24-bits extracted from hash result
38051 + * are used for policer profile generation.
38052 + * That leaves maximum shift value = 23. */
38053 + if (params->policer_params.shift > FMAN_KG_SCH_PP_SHIFT_MAX) {
38054 + return -EINVAL;
38055 + }
38056 +
38057 + tmp_reg = params->policer_params.base;
38058 + tmp_reg |= ((uint32_t)params->policer_params.shift <<
38059 + FMAN_KG_SCH_PP_SH_SHIFT) &
38060 + FMAN_KG_SCH_PP_SH_MASK;
38061 + tmp_reg |= ((uint32_t)params->policer_params.shift <<
38062 + FMAN_KG_SCH_PP_SL_SHIFT) &
38063 + FMAN_KG_SCH_PP_SL_MASK;
38064 + tmp_reg |= (uint32_t)params->policer_params.mask <<
38065 + FMAN_KG_SCH_PP_MASK_SHIFT;
38066 + }
38067 +
38068 + scheme_regs->kgse_ppc = tmp_reg;
38069 +
38070 + /* Coarse Classification Bit Select register */
38071 + if (params->next_engine == E_FMAN_PCD_CC) {
38072 + scheme_regs->kgse_ccbs = params->cc_params.qlcv_bits_sel;
38073 + }
38074 +
38075 + /* Packets Counter register */
38076 + if (params->update_counter) {
38077 + scheme_regs->kgse_spc = params->counter_value;
38078 + }
38079 +
38080 + return 0;
38081 +}
38082 +
38083 +int fman_kg_write_scheme(struct fman_kg_regs *regs,
38084 + uint8_t scheme_id,
38085 + uint8_t hwport_id,
38086 + struct fman_kg_scheme_regs *scheme_regs,
38087 + bool update_counter)
38088 +{
38089 + struct fman_kg_scheme_regs *kgse_regs;
38090 + uint32_t tmp_reg;
38091 + int err, i;
38092 +
38093 + /* Write indirect scheme registers */
38094 + kgse_regs = (struct fman_kg_scheme_regs *)&(regs->fmkg_indirect[0]);
38095 +
38096 + iowrite32be(scheme_regs->kgse_mode, &kgse_regs->kgse_mode);
38097 + iowrite32be(scheme_regs->kgse_ekfc, &kgse_regs->kgse_ekfc);
38098 + iowrite32be(scheme_regs->kgse_ekdv, &kgse_regs->kgse_ekdv);
38099 + iowrite32be(scheme_regs->kgse_bmch, &kgse_regs->kgse_bmch);
38100 + iowrite32be(scheme_regs->kgse_bmcl, &kgse_regs->kgse_bmcl);
38101 + iowrite32be(scheme_regs->kgse_fqb, &kgse_regs->kgse_fqb);
38102 + iowrite32be(scheme_regs->kgse_hc, &kgse_regs->kgse_hc);
38103 + iowrite32be(scheme_regs->kgse_ppc, &kgse_regs->kgse_ppc);
38104 + iowrite32be(scheme_regs->kgse_spc, &kgse_regs->kgse_spc);
38105 + iowrite32be(scheme_regs->kgse_dv0, &kgse_regs->kgse_dv0);
38106 + iowrite32be(scheme_regs->kgse_dv1, &kgse_regs->kgse_dv1);
38107 + iowrite32be(scheme_regs->kgse_ccbs, &kgse_regs->kgse_ccbs);
38108 + iowrite32be(scheme_regs->kgse_mv, &kgse_regs->kgse_mv);
38109 +
38110 + for (i = 0 ; i < FM_KG_NUM_OF_GENERIC_REGS ; i++)
38111 + iowrite32be(scheme_regs->kgse_gec[i], &kgse_regs->kgse_gec[i]);
38112 +
38113 + /* Write AR (Action register) */
38114 + tmp_reg = build_ar_scheme(scheme_id, hwport_id, update_counter, TRUE);
38115 + err = fman_kg_write_ar_wait(regs, tmp_reg);
38116 + return err;
38117 +}
38118 +
38119 +int fman_kg_delete_scheme(struct fman_kg_regs *regs,
38120 + uint8_t scheme_id,
38121 + uint8_t hwport_id)
38122 +{
38123 + struct fman_kg_scheme_regs *kgse_regs;
38124 + uint32_t tmp_reg;
38125 + int err, i;
38126 +
38127 + kgse_regs = (struct fman_kg_scheme_regs *)&(regs->fmkg_indirect[0]);
38128 +
38129 + /* Clear all registers including enable bit in mode register */
38130 + for (i = 0; i < (sizeof(struct fman_kg_scheme_regs)) / 4; ++i) {
38131 + iowrite32be(0, ((uint32_t *)kgse_regs + i));
38132 + }
38133 +
38134 + /* Write AR (Action register) */
38135 + tmp_reg = build_ar_scheme(scheme_id, hwport_id, FALSE, TRUE);
38136 + err = fman_kg_write_ar_wait(regs, tmp_reg);
38137 + return err;
38138 +}
38139 +
38140 +int fman_kg_get_scheme_counter(struct fman_kg_regs *regs,
38141 + uint8_t scheme_id,
38142 + uint8_t hwport_id,
38143 + uint32_t *counter)
38144 +{
38145 + struct fman_kg_scheme_regs *kgse_regs;
38146 + uint32_t tmp_reg;
38147 + int err;
38148 +
38149 + kgse_regs = (struct fman_kg_scheme_regs *)&(regs->fmkg_indirect[0]);
38150 +
38151 + tmp_reg = build_ar_scheme(scheme_id, hwport_id, TRUE, FALSE);
38152 + err = fman_kg_write_ar_wait(regs, tmp_reg);
38153 +
38154 + if (err != 0)
38155 + return err;
38156 +
38157 + *counter = ioread32be(&kgse_regs->kgse_spc);
38158 +
38159 + return 0;
38160 +}
38161 +
38162 +int fman_kg_set_scheme_counter(struct fman_kg_regs *regs,
38163 + uint8_t scheme_id,
38164 + uint8_t hwport_id,
38165 + uint32_t counter)
38166 +{
38167 + struct fman_kg_scheme_regs *kgse_regs;
38168 + uint32_t tmp_reg;
38169 + int err;
38170 +
38171 + kgse_regs = (struct fman_kg_scheme_regs *)&(regs->fmkg_indirect[0]);
38172 +
38173 + tmp_reg = build_ar_scheme(scheme_id, hwport_id, TRUE, FALSE);
38174 +
38175 + err = fman_kg_write_ar_wait(regs, tmp_reg);
38176 + if (err != 0)
38177 + return err;
38178 +
38179 + /* Keygen indirect access memory contains all scheme_id registers
38180 + * by now. Change only counter value. */
38181 + iowrite32be(counter, &kgse_regs->kgse_spc);
38182 +
38183 + /* Write back scheme registers */
38184 + tmp_reg = build_ar_scheme(scheme_id, hwport_id, TRUE, TRUE);
38185 + err = fman_kg_write_ar_wait(regs, tmp_reg);
38186 +
38187 + return err;
38188 +}
38189 +
38190 +uint32_t fman_kg_get_schemes_total_counter(struct fman_kg_regs *regs)
38191 +{
38192 + return ioread32be(&regs->fmkg_tpc);
38193 +}
38194 +
38195 +int fman_kg_build_cls_plan(struct fman_kg_cls_plan_params *params,
38196 + struct fman_kg_cp_regs *cls_plan_regs)
38197 +{
38198 + uint8_t entries_set, entry_bit;
38199 + int i;
38200 +
38201 + /* Zero out all group's register */
38202 + memset(cls_plan_regs, 0, sizeof(struct fman_kg_cp_regs));
38203 +
38204 + /* Go over all classification entries in params->entries_mask and
38205 + * configure the corresponding cpe register */
38206 + entries_set = params->entries_mask;
38207 + for (i = 0; entries_set; i++) {
38208 + entry_bit = (uint8_t)(0x80 >> i);
38209 + if ((entry_bit & entries_set) == 0)
38210 + continue;
38211 + entries_set ^= entry_bit;
38212 + cls_plan_regs->kgcpe[i] = params->mask_vector[i];
38213 + }
38214 +
38215 + return 0;
38216 +}
38217 +
38218 +int fman_kg_write_cls_plan(struct fman_kg_regs *regs,
38219 + uint8_t grp_id,
38220 + uint8_t entries_mask,
38221 + uint8_t hwport_id,
38222 + struct fman_kg_cp_regs *cls_plan_regs)
38223 +{
38224 + struct fman_kg_cp_regs *kgcpe_regs;
38225 + uint32_t tmp_reg;
38226 + int i, err;
38227 +
38228 + /* Check group index is valid and the group isn't empty */
38229 + if (grp_id >= FM_KG_CLS_PLAN_GRPS_NUM)
38230 + return -EINVAL;
38231 +
38232 + /* Write indirect classification plan registers */
38233 + kgcpe_regs = (struct fman_kg_cp_regs *)&(regs->fmkg_indirect[0]);
38234 +
38235 + for (i = 0; i < FM_KG_NUM_CLS_PLAN_ENTR; i++) {
38236 + iowrite32be(cls_plan_regs->kgcpe[i], &kgcpe_regs->kgcpe[i]);
38237 + }
38238 +
38239 + tmp_reg = build_ar_cls_plan(grp_id, entries_mask, hwport_id, TRUE);
38240 + err = fman_kg_write_ar_wait(regs, tmp_reg);
38241 + return err;
38242 +}
38243 +
38244 +int fman_kg_write_bind_schemes(struct fman_kg_regs *regs,
38245 + uint8_t hwport_id,
38246 + uint32_t schemes)
38247 +{
38248 + struct fman_kg_pe_regs *kg_pe_regs;
38249 + uint32_t tmp_reg;
38250 + int err;
38251 +
38252 + kg_pe_regs = (struct fman_kg_pe_regs *)&(regs->fmkg_indirect[0]);
38253 +
38254 + iowrite32be(schemes, &kg_pe_regs->fmkg_pe_sp);
38255 +
38256 + tmp_reg = build_ar_bind_scheme(hwport_id, TRUE);
38257 + err = fman_kg_write_ar_wait(regs, tmp_reg);
38258 + return err;
38259 +}
38260 +
38261 +int fman_kg_build_bind_cls_plans(uint8_t grp_base,
38262 + uint8_t grp_mask,
38263 + uint32_t *bind_cls_plans)
38264 +{
38265 + /* Check grp_base and grp_mask are 5-bits values */
38266 + if ((grp_base & ~0x0000001F) || (grp_mask & ~0x0000001F))
38267 + return -EINVAL;
38268 +
38269 + *bind_cls_plans = (uint32_t) ((grp_mask << FMAN_KG_PE_CPP_MASK_SHIFT) | grp_base);
38270 + return 0;
38271 +}
38272 +
38273 +
38274 +int fman_kg_write_bind_cls_plans(struct fman_kg_regs *regs,
38275 + uint8_t hwport_id,
38276 + uint32_t bind_cls_plans)
38277 +{
38278 + struct fman_kg_pe_regs *kg_pe_regs;
38279 + uint32_t tmp_reg;
38280 + int err;
38281 +
38282 + kg_pe_regs = (struct fman_kg_pe_regs *)&(regs->fmkg_indirect[0]);
38283 +
38284 + iowrite32be(bind_cls_plans, &kg_pe_regs->fmkg_pe_cpp);
38285 +
38286 + tmp_reg = build_ar_bind_cls_plan(hwport_id, TRUE);
38287 + err = fman_kg_write_ar_wait(regs, tmp_reg);
38288 + return err;
38289 +}
38290 --- /dev/null
38291 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fman_prs.c
38292 @@ -0,0 +1,129 @@
38293 +/*
38294 + * Copyright 2012 Freescale Semiconductor Inc.
38295 + *
38296 + * Redistribution and use in source and binary forms, with or without
38297 + * modification, are permitted provided that the following conditions are met:
38298 + * * Redistributions of source code must retain the above copyright
38299 + * notice, this list of conditions and the following disclaimer.
38300 + * * Redistributions in binary form must reproduce the above copyright
38301 + * notice, this list of conditions and the following disclaimer in the
38302 + * documentation and/or other materials provided with the distribution.
38303 + * * Neither the name of Freescale Semiconductor nor the
38304 + * names of its contributors may be used to endorse or promote products
38305 + * derived from this software without specific prior written permission.
38306 + *
38307 + *
38308 + * ALTERNATIVELY, this software may be distributed under the terms of the
38309 + * GNU General Public License ("GPL") as published by the Free Software
38310 + * Foundation, either version 2 of that License or (at your option) any
38311 + * later version.
38312 + *
38313 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
38314 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38315 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38316 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
38317 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38318 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38319 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38320 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38321 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38322 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38323 + */
38324 +
38325 +#include "fsl_fman_prs.h"
38326 +
38327 +uint32_t fman_prs_get_err_event(struct fman_prs_regs *regs, uint32_t ev_mask)
38328 +{
38329 + return ioread32be(&regs->fmpr_perr) & ev_mask;
38330 +}
38331 +
38332 +uint32_t fman_prs_get_err_ev_mask(struct fman_prs_regs *regs)
38333 +{
38334 + return ioread32be(&regs->fmpr_perer);
38335 +}
38336 +
38337 +void fman_prs_ack_err_event(struct fman_prs_regs *regs, uint32_t event)
38338 +{
38339 + iowrite32be(event, &regs->fmpr_perr);
38340 +}
38341 +
38342 +uint32_t fman_prs_get_expt_event(struct fman_prs_regs *regs, uint32_t ev_mask)
38343 +{
38344 + return ioread32be(&regs->fmpr_pevr) & ev_mask;
38345 +}
38346 +
38347 +uint32_t fman_prs_get_expt_ev_mask(struct fman_prs_regs *regs)
38348 +{
38349 + return ioread32be(&regs->fmpr_pever);
38350 +}
38351 +
38352 +void fman_prs_ack_expt_event(struct fman_prs_regs *regs, uint32_t event)
38353 +{
38354 + iowrite32be(event, &regs->fmpr_pevr);
38355 +}
38356 +
38357 +void fman_prs_defconfig(struct fman_prs_cfg *cfg)
38358 +{
38359 + cfg->port_id_stat = 0;
38360 + cfg->max_prs_cyc_lim = DEFAULT_MAX_PRS_CYC_LIM;
38361 + cfg->prs_exceptions = 0x03000000;
38362 +}
38363 +
38364 +int fman_prs_init(struct fman_prs_regs *regs, struct fman_prs_cfg *cfg)
38365 +{
38366 + uint32_t tmp;
38367 +
38368 + iowrite32be(cfg->max_prs_cyc_lim, &regs->fmpr_rpclim);
38369 + iowrite32be((FM_PCD_PRS_SINGLE_ECC | FM_PCD_PRS_PORT_IDLE_STS),
38370 + &regs->fmpr_pevr);
38371 +
38372 + if (cfg->prs_exceptions & FM_PCD_EX_PRS_SINGLE_ECC)
38373 + iowrite32be(FM_PCD_PRS_SINGLE_ECC, &regs->fmpr_pever);
38374 + else
38375 + iowrite32be(0, &regs->fmpr_pever);
38376 +
38377 + iowrite32be(FM_PCD_PRS_DOUBLE_ECC, &regs->fmpr_perr);
38378 +
38379 + tmp = 0;
38380 + if (cfg->prs_exceptions & FM_PCD_EX_PRS_DOUBLE_ECC)
38381 + tmp |= FM_PCD_PRS_DOUBLE_ECC;
38382 + iowrite32be(tmp, &regs->fmpr_perer);
38383 +
38384 + iowrite32be(cfg->port_id_stat, &regs->fmpr_ppsc);
38385 +
38386 + return 0;
38387 +}
38388 +
38389 +void fman_prs_enable(struct fman_prs_regs *regs)
38390 +{
38391 + uint32_t tmp;
38392 +
38393 + tmp = ioread32be(&regs->fmpr_rpimac) | FM_PCD_PRS_RPIMAC_EN;
38394 + iowrite32be(tmp, &regs->fmpr_rpimac);
38395 +}
38396 +
38397 +void fman_prs_disable(struct fman_prs_regs *regs)
38398 +{
38399 + uint32_t tmp;
38400 +
38401 + tmp = ioread32be(&regs->fmpr_rpimac) & ~FM_PCD_PRS_RPIMAC_EN;
38402 + iowrite32be(tmp, &regs->fmpr_rpimac);
38403 +}
38404 +
38405 +int fman_prs_is_enabled(struct fman_prs_regs *regs)
38406 +{
38407 + return ioread32be(&regs->fmpr_rpimac) & FM_PCD_PRS_RPIMAC_EN;
38408 +}
38409 +
38410 +void fman_prs_set_stst_port_msk(struct fman_prs_regs *regs, uint32_t pid_msk)
38411 +{
38412 + iowrite32be(pid_msk, &regs->fmpr_ppsc);
38413 +}
38414 +
38415 +void fman_prs_set_stst(struct fman_prs_regs *regs, bool enable)
38416 +{
38417 + if (enable)
38418 + iowrite32be(FM_PCD_PRS_PPSC_ALL_PORTS, &regs->fmpr_ppsc);
38419 + else
38420 + iowrite32be(0, &regs->fmpr_ppsc);
38421 +}
38422 --- /dev/null
38423 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/Makefile
38424 @@ -0,0 +1,15 @@
38425 +#
38426 +# Makefile for the Freescale Ethernet controllers
38427 +#
38428 +ccflags-y += -DVERSION=\"\"
38429 +#
38430 +#Include netcomm SW specific definitions
38431 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
38432 +
38433 +NCSW_FM_INC = $(srctree)/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc
38434 +
38435 +ccflags-y += -I$(NCSW_FM_INC)
38436 +
38437 +obj-y += fsl-ncsw-Pcd.o
38438 +
38439 +fsl-ncsw-Pcd-objs := fm_port.o fm_port_im.o fman_port.o
38440 --- /dev/null
38441 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c
38442 @@ -0,0 +1,6436 @@
38443 +/*
38444 + * Copyright 2008-2012 Freescale Semiconductor Inc.
38445 + *
38446 + * Redistribution and use in source and binary forms, with or without
38447 + * modification, are permitted provided that the following conditions are met:
38448 + * * Redistributions of source code must retain the above copyright
38449 + * notice, this list of conditions and the following disclaimer.
38450 + * * Redistributions in binary form must reproduce the above copyright
38451 + * notice, this list of conditions and the following disclaimer in the
38452 + * documentation and/or other materials provided with the distribution.
38453 + * * Neither the name of Freescale Semiconductor nor the
38454 + * names of its contributors may be used to endorse or promote products
38455 + * derived from this software without specific prior written permission.
38456 + *
38457 + *
38458 + * ALTERNATIVELY, this software may be distributed under the terms of the
38459 + * GNU General Public License ("GPL") as published by the Free Software
38460 + * Foundation, either version 2 of that License or (at your option) any
38461 + * later version.
38462 + *
38463 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
38464 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38465 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38466 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
38467 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38468 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38469 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38470 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38471 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38472 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38473 + */
38474 +
38475 +
38476 +/******************************************************************************
38477 + @File fm_port.c
38478 +
38479 + @Description FM driver routines implementation.
38480 + *//***************************************************************************/
38481 +#include "error_ext.h"
38482 +#include "std_ext.h"
38483 +#include "string_ext.h"
38484 +#include "sprint_ext.h"
38485 +#include "debug_ext.h"
38486 +#include "fm_muram_ext.h"
38487 +
38488 +#include "fman_common.h"
38489 +#include "fm_port.h"
38490 +#include "fm_port_dsar.h"
38491 +#include "common/general.h"
38492 +
38493 +/****************************************/
38494 +/* static functions */
38495 +/****************************************/
38496 +static t_Error FmPortConfigAutoResForDeepSleepSupport1(t_FmPort *p_FmPort);
38497 +
38498 +static t_Error CheckInitParameters(t_FmPort *p_FmPort)
38499 +{
38500 + t_FmPortDriverParam *p_Params = p_FmPort->p_FmPortDriverParam;
38501 + struct fman_port_cfg *p_DfltConfig = &p_Params->dfltCfg;
38502 + t_Error ans = E_OK;
38503 + uint32_t unusedMask;
38504 +
38505 + if (p_FmPort->imEn)
38506 + {
38507 + if (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
38508 + if (p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth
38509 + > 2)
38510 + RETURN_ERROR(
38511 + MAJOR,
38512 + E_INVALID_VALUE,
38513 + ("fifoDeqPipelineDepth for IM 10G can't be larger than 2"));
38514 +
38515 + if ((ans = FmPortImCheckInitParameters(p_FmPort)) != E_OK)
38516 + return ERROR_CODE(ans);
38517 + }
38518 + else
38519 + {
38520 + /****************************************/
38521 + /* Rx only */
38522 + /****************************************/
38523 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
38524 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
38525 + {
38526 + /* external buffer pools */
38527 + if (!p_Params->extBufPools.numOfPoolsUsed)
38528 + RETURN_ERROR(
38529 + MAJOR,
38530 + E_INVALID_VALUE,
38531 + ("extBufPools.numOfPoolsUsed=0. At least one buffer pool must be defined"));
38532 +
38533 + if (FmSpCheckBufPoolsParams(&p_Params->extBufPools,
38534 + p_Params->p_BackupBmPools,
38535 + &p_Params->bufPoolDepletion) != E_OK)
38536 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
38537 +
38538 + /* Check that part of IC that needs copying is small enough to enter start margin */
38539 + if (p_Params->intContext.size
38540 + && (p_Params->intContext.size
38541 + + p_Params->intContext.extBufOffset
38542 + > p_Params->bufMargins.startMargins))
38543 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
38544 + ("intContext.size is larger than start margins"));
38545 +
38546 + if ((p_Params->liodnOffset != (uint16_t)DPAA_LIODN_DONT_OVERRIDE)
38547 + && (p_Params->liodnOffset & ~FM_LIODN_OFFSET_MASK))
38548 + RETURN_ERROR(
38549 + MAJOR,
38550 + E_INVALID_VALUE,
38551 + ("liodnOffset is larger than %d", FM_LIODN_OFFSET_MASK+1));
38552 +
38553 +#ifdef FM_NO_BACKUP_POOLS
38554 + if ((p_FmPort->fmRevInfo.majorRev != 4) && (p_FmPort->fmRevInfo.majorRev < 6))
38555 + if (p_FmPort->p_FmPortDriverParam->p_BackupBmPools)
38556 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("BackupBmPools"));
38557 +#endif /* FM_NO_BACKUP_POOLS */
38558 + }
38559 +
38560 + /****************************************/
38561 + /* Non Rx ports */
38562 + /****************************************/
38563 + else
38564 + {
38565 + if (p_Params->deqSubPortal >= FM_MAX_NUM_OF_SUB_PORTALS)
38566 + RETURN_ERROR(
38567 + MAJOR,
38568 + E_INVALID_VALUE,
38569 + (" deqSubPortal has to be in the range of 0 - %d", FM_MAX_NUM_OF_SUB_PORTALS));
38570 +
38571 + /* to protect HW internal-context from overwrite */
38572 + if ((p_Params->intContext.size)
38573 + && (p_Params->intContext.intContextOffset
38574 + < MIN_TX_INT_OFFSET))
38575 + RETURN_ERROR(
38576 + MAJOR,
38577 + E_INVALID_VALUE,
38578 + ("non-Rx intContext.intContextOffset can't be smaller than %d", MIN_TX_INT_OFFSET));
38579 +
38580 + if ((p_FmPort->portType == e_FM_PORT_TYPE_TX)
38581 + || (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)
38582 + /* in O/H DEFAULT_notSupported indicates that it is not supported and should not be checked */
38583 + || (p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth
38584 + != DEFAULT_notSupported))
38585 + {
38586 + /* Check that not larger than 8 */
38587 + if ((!p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth)
38588 + || (p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth
38589 + > MAX_FIFO_PIPELINE_DEPTH))
38590 + RETURN_ERROR(
38591 + MAJOR,
38592 + E_INVALID_VALUE,
38593 + ("fifoDeqPipelineDepth can't be larger than %d", MAX_FIFO_PIPELINE_DEPTH));
38594 + }
38595 + }
38596 +
38597 + /****************************************/
38598 + /* Rx Or Offline Parsing */
38599 + /****************************************/
38600 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
38601 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
38602 + || (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
38603 + {
38604 + if (!p_Params->dfltFqid)
38605 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
38606 + ("dfltFqid must be between 1 and 2^24-1"));
38607 +#if defined(FM_CAPWAP_SUPPORT) && defined(FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004)
38608 + if (p_FmPort->p_FmPortDriverParam->bufferPrefixContent.manipExtraSpace % 16)
38609 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufferPrefixContent.manipExtraSpace has to be devidable by 16"));
38610 +#endif /* defined(FM_CAPWAP_SUPPORT) && ... */
38611 + }
38612 +
38613 + /****************************************/
38614 + /* All ports */
38615 + /****************************************/
38616 + /* common BMI registers values */
38617 + /* Check that Queue Id is not larger than 2^24, and is not 0 */
38618 + if ((p_Params->errFqid & ~0x00FFFFFF) || !p_Params->errFqid)
38619 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
38620 + ("errFqid must be between 1 and 2^24-1"));
38621 + if (p_Params->dfltFqid & ~0x00FFFFFF)
38622 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
38623 + ("dfltFqid must be between 1 and 2^24-1"));
38624 + }
38625 +
38626 + /****************************************/
38627 + /* Rx only */
38628 + /****************************************/
38629 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
38630 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
38631 + {
38632 + if (p_DfltConfig->rx_pri_elevation % BMI_FIFO_UNITS)
38633 + RETURN_ERROR(
38634 + MAJOR,
38635 + E_INVALID_VALUE,
38636 + ("rxFifoPriElevationLevel has to be divisible by %d", BMI_FIFO_UNITS));
38637 + if ((p_DfltConfig->rx_pri_elevation < BMI_FIFO_UNITS)
38638 + || (p_DfltConfig->rx_pri_elevation > MAX_PORT_FIFO_SIZE))
38639 + RETURN_ERROR(
38640 + MAJOR,
38641 + E_INVALID_VALUE,
38642 + ("rxFifoPriElevationLevel has to be in the range of 256 - %d", MAX_PORT_FIFO_SIZE));
38643 + if (p_DfltConfig->rx_fifo_thr % BMI_FIFO_UNITS)
38644 + RETURN_ERROR(
38645 + MAJOR,
38646 + E_INVALID_VALUE,
38647 + ("rxFifoThreshold has to be divisible by %d", BMI_FIFO_UNITS));
38648 + if ((p_DfltConfig->rx_fifo_thr < BMI_FIFO_UNITS)
38649 + || (p_DfltConfig->rx_fifo_thr > MAX_PORT_FIFO_SIZE))
38650 + RETURN_ERROR(
38651 + MAJOR,
38652 + E_INVALID_VALUE,
38653 + ("rxFifoThreshold has to be in the range of 256 - %d", MAX_PORT_FIFO_SIZE));
38654 +
38655 + /* Check that not larger than 16 */
38656 + if (p_DfltConfig->rx_cut_end_bytes > FRAME_END_DATA_SIZE)
38657 + RETURN_ERROR(
38658 + MAJOR,
38659 + E_INVALID_VALUE,
38660 + ("cutBytesFromEnd can't be larger than %d", FRAME_END_DATA_SIZE));
38661 +
38662 + if (FmSpCheckBufMargins(&p_Params->bufMargins) != E_OK)
38663 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
38664 +
38665 + /* extra FIFO size (allowed only to Rx ports) */
38666 + if (p_Params->setSizeOfFifo
38667 + && (p_FmPort->fifoBufs.extra % BMI_FIFO_UNITS))
38668 + RETURN_ERROR(
38669 + MAJOR,
38670 + E_INVALID_VALUE,
38671 + ("fifoBufs.extra has to be divisible by %d", BMI_FIFO_UNITS));
38672 +
38673 + if (p_Params->bufPoolDepletion.poolsGrpModeEnable
38674 + && !p_Params->bufPoolDepletion.numOfPools)
38675 + RETURN_ERROR(
38676 + MAJOR,
38677 + E_INVALID_VALUE,
38678 + ("bufPoolDepletion.numOfPools can not be 0 when poolsGrpModeEnable=TRUE"));
38679 +#ifdef FM_CSI_CFED_LIMIT
38680 + if (p_FmPort->fmRevInfo.majorRev == 4)
38681 + {
38682 + /* Check that not larger than 16 */
38683 + if (p_DfltConfig->rx_cut_end_bytes + p_DfltConfig->checksum_bytes_ignore > FRAME_END_DATA_SIZE)
38684 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("cheksumLastBytesIgnore + cutBytesFromEnd can't be larger than %d", FRAME_END_DATA_SIZE));
38685 + }
38686 +#endif /* FM_CSI_CFED_LIMIT */
38687 + }
38688 +
38689 + /****************************************/
38690 + /* Non Rx ports */
38691 + /****************************************/
38692 + /* extra FIFO size (allowed only to Rx ports) */
38693 + else
38694 + if (p_FmPort->fifoBufs.extra)
38695 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
38696 + (" No fifoBufs.extra for non Rx ports"));
38697 +
38698 + /****************************************/
38699 + /* Tx only */
38700 + /****************************************/
38701 + if ((p_FmPort->portType == e_FM_PORT_TYPE_TX)
38702 + || (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G))
38703 + {
38704 + if (p_DfltConfig->tx_fifo_min_level % BMI_FIFO_UNITS)
38705 + RETURN_ERROR(
38706 + MAJOR,
38707 + E_INVALID_VALUE,
38708 + ("txFifoMinFillLevel has to be divisible by %d", BMI_FIFO_UNITS));
38709 + if (p_DfltConfig->tx_fifo_min_level > (MAX_PORT_FIFO_SIZE - 256))
38710 + RETURN_ERROR(
38711 + MAJOR,
38712 + E_INVALID_VALUE,
38713 + ("txFifoMinFillLevel has to be in the range of 0 - %d", (MAX_PORT_FIFO_SIZE - 256)));
38714 + if (p_DfltConfig->tx_fifo_low_comf_level % BMI_FIFO_UNITS)
38715 + RETURN_ERROR(
38716 + MAJOR,
38717 + E_INVALID_VALUE,
38718 + ("txFifoLowComfLevel has to be divisible by %d", BMI_FIFO_UNITS));
38719 + if ((p_DfltConfig->tx_fifo_low_comf_level < BMI_FIFO_UNITS)
38720 + || (p_DfltConfig->tx_fifo_low_comf_level > MAX_PORT_FIFO_SIZE))
38721 + RETURN_ERROR(
38722 + MAJOR,
38723 + E_INVALID_VALUE,
38724 + ("txFifoLowComfLevel has to be in the range of 256 - %d", MAX_PORT_FIFO_SIZE));
38725 +
38726 + if (p_FmPort->portType == e_FM_PORT_TYPE_TX)
38727 + if (p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth
38728 + > 2)
38729 + RETURN_ERROR(
38730 + MAJOR, E_INVALID_VALUE,
38731 + ("fifoDeqPipelineDepth for 1G can't be larger than 2"));
38732 + }
38733 +
38734 + /****************************************/
38735 + /* Non Tx Ports */
38736 + /****************************************/
38737 + /* If discard override was selected , no frames may be discarded. */
38738 + else
38739 + if (p_DfltConfig->discard_override && p_Params->errorsToDiscard)
38740 + RETURN_ERROR(
38741 + MAJOR,
38742 + E_CONFLICT,
38743 + ("errorsToDiscard is not empty, but frmDiscardOverride selected (all discarded frames to be enqueued to error queue)."));
38744 +
38745 + /****************************************/
38746 + /* Rx and Offline parsing */
38747 + /****************************************/
38748 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
38749 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
38750 + || (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
38751 + {
38752 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
38753 + unusedMask = BMI_STATUS_OP_MASK_UNUSED;
38754 + else
38755 + unusedMask = BMI_STATUS_RX_MASK_UNUSED;
38756 +
38757 + /* Check that no common bits with BMI_STATUS_MASK_UNUSED */
38758 + if (p_Params->errorsToDiscard & unusedMask)
38759 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
38760 + ("errorsToDiscard contains undefined bits"));
38761 + }
38762 +
38763 + /****************************************/
38764 + /* Offline Ports */
38765 + /****************************************/
38766 +#ifdef FM_OP_OPEN_DMA_MIN_LIMIT
38767 + if ((p_FmPort->fmRevInfo.majorRev >= 6)
38768 + && (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
38769 + && p_Params->setNumOfOpenDmas
38770 + && (p_FmPort->openDmas.num < MIN_NUM_OF_OP_DMAS))
38771 + RETURN_ERROR(
38772 + MAJOR,
38773 + E_INVALID_VALUE,
38774 + ("For Offline port, openDmas.num can't be smaller than %d", MIN_NUM_OF_OP_DMAS));
38775 +#endif /* FM_OP_OPEN_DMA_MIN_LIMIT */
38776 +
38777 + /****************************************/
38778 + /* Offline & HC Ports */
38779 + /****************************************/
38780 + if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
38781 + || (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
38782 + {
38783 +#ifndef FM_FRAME_END_PARAMS_FOR_OP
38784 + if ((p_FmPort->fmRevInfo.majorRev < 6) &&
38785 + (p_FmPort->p_FmPortDriverParam->cheksumLastBytesIgnore != DEFAULT_notSupported))
38786 + /* this is an indication that user called config for this mode which is not supported in this integration */
38787 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("cheksumLastBytesIgnore is available for Rx & Tx ports only"));
38788 +#endif /* !FM_FRAME_END_PARAMS_FOR_OP */
38789 +
38790 +#ifndef FM_DEQ_PIPELINE_PARAMS_FOR_OP
38791 + if ((!((p_FmPort->fmRevInfo.majorRev == 4) ||
38792 + (p_FmPort->fmRevInfo.majorRev >= 6))) &&
38793 + (p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth != DEFAULT_notSupported))
38794 + /* this is an indication that user called config for this mode which is not supported in this integration */
38795 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("fifoDeqPipelineDepth is available for Tx ports only"));
38796 +#endif /* !FM_DEQ_PIPELINE_PARAMS_FOR_OP */
38797 + }
38798 +
38799 + /****************************************/
38800 + /* All ports */
38801 + /****************************************/
38802 + /* Check that not larger than 16 */
38803 + if ((p_Params->cheksumLastBytesIgnore > FRAME_END_DATA_SIZE)
38804 + && ((p_Params->cheksumLastBytesIgnore != DEFAULT_notSupported)))
38805 + RETURN_ERROR(
38806 + MAJOR,
38807 + E_INVALID_VALUE,
38808 + ("cheksumLastBytesIgnore can't be larger than %d", FRAME_END_DATA_SIZE));
38809 +
38810 + if (FmSpCheckIntContextParams(&p_Params->intContext) != E_OK)
38811 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
38812 +
38813 + /* common BMI registers values */
38814 + if (p_Params->setNumOfTasks
38815 + && ((!p_FmPort->tasks.num)
38816 + || (p_FmPort->tasks.num > MAX_NUM_OF_TASKS)))
38817 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
38818 + ("tasks.num can't be larger than %d", MAX_NUM_OF_TASKS));
38819 + if (p_Params->setNumOfTasks
38820 + && (p_FmPort->tasks.extra > MAX_NUM_OF_EXTRA_TASKS))
38821 + RETURN_ERROR(
38822 + MAJOR,
38823 + E_INVALID_VALUE,
38824 + ("tasks.extra can't be larger than %d", MAX_NUM_OF_EXTRA_TASKS));
38825 + if (p_Params->setNumOfOpenDmas
38826 + && ((!p_FmPort->openDmas.num)
38827 + || (p_FmPort->openDmas.num > MAX_NUM_OF_DMAS)))
38828 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
38829 + ("openDmas.num can't be larger than %d", MAX_NUM_OF_DMAS));
38830 + if (p_Params->setNumOfOpenDmas
38831 + && (p_FmPort->openDmas.extra > MAX_NUM_OF_EXTRA_DMAS))
38832 + RETURN_ERROR(
38833 + MAJOR,
38834 + E_INVALID_VALUE,
38835 + ("openDmas.extra can't be larger than %d", MAX_NUM_OF_EXTRA_DMAS));
38836 + if (p_Params->setSizeOfFifo
38837 + && (!p_FmPort->fifoBufs.num
38838 + || (p_FmPort->fifoBufs.num > MAX_PORT_FIFO_SIZE)))
38839 + RETURN_ERROR(
38840 + MAJOR,
38841 + E_INVALID_VALUE,
38842 + ("fifoBufs.num has to be in the range of 256 - %d", MAX_PORT_FIFO_SIZE));
38843 + if (p_Params->setSizeOfFifo && (p_FmPort->fifoBufs.num % BMI_FIFO_UNITS))
38844 + RETURN_ERROR(
38845 + MAJOR, E_INVALID_VALUE,
38846 + ("fifoBufs.num has to be divisible by %d", BMI_FIFO_UNITS));
38847 +
38848 +#ifdef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
38849 + if (p_FmPort->fmRevInfo.majorRev == 4)
38850 + if (p_FmPort->p_FmPortDriverParam->deqPrefetchOption != DEFAULT_notSupported)
38851 + /* this is an indication that user called config for this mode which is not supported in this integration */
38852 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("deqPrefetchOption"));
38853 +#endif /* FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
38854 +
38855 + return E_OK;
38856 +}
38857 +
38858 +static t_Error VerifySizeOfFifo(t_FmPort *p_FmPort)
38859 +{
38860 + uint32_t minFifoSizeRequired = 0, optFifoSizeForB2B = 0;
38861 +
38862 + /*************************/
38863 + /* TX PORTS */
38864 + /*************************/
38865 + if ((p_FmPort->portType == e_FM_PORT_TYPE_TX)
38866 + || (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G))
38867 + {
38868 + minFifoSizeRequired =
38869 + (uint32_t)(ROUND_UP(p_FmPort->maxFrameLength, BMI_FIFO_UNITS)
38870 + + (3 * BMI_FIFO_UNITS));
38871 + if (!p_FmPort->imEn)
38872 + minFifoSizeRequired +=
38873 + p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth
38874 + * BMI_FIFO_UNITS;
38875 +
38876 + optFifoSizeForB2B = minFifoSizeRequired;
38877 +
38878 + /* Add some margin for back-to-back capability to improve performance,
38879 + allows the hardware to pipeline new frame dma while the previous
38880 + frame not yet transmitted. */
38881 + if (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)
38882 + optFifoSizeForB2B += 3 * BMI_FIFO_UNITS;
38883 + else
38884 + optFifoSizeForB2B += 2 * BMI_FIFO_UNITS;
38885 + }
38886 +
38887 + /*************************/
38888 + /* RX IM PORTS */
38889 + /*************************/
38890 + else
38891 + if (((p_FmPort->portType == e_FM_PORT_TYPE_RX)
38892 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
38893 + && p_FmPort->imEn)
38894 + {
38895 + optFifoSizeForB2B =
38896 + minFifoSizeRequired =
38897 + (uint32_t)(ROUND_UP(p_FmPort->maxFrameLength, BMI_FIFO_UNITS)
38898 + + (4 * BMI_FIFO_UNITS));
38899 + }
38900 +
38901 + /*************************/
38902 + /* RX non-IM PORTS */
38903 + /*************************/
38904 + else
38905 + if (((p_FmPort->portType == e_FM_PORT_TYPE_RX)
38906 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
38907 + && !p_FmPort->imEn)
38908 + {
38909 + if (p_FmPort->fmRevInfo.majorRev == 4)
38910 + {
38911 + if (p_FmPort->rxPoolsParams.numOfPools == 1)
38912 + minFifoSizeRequired = 8 * BMI_FIFO_UNITS;
38913 + else
38914 + minFifoSizeRequired =
38915 + (uint32_t)(ROUND_UP(p_FmPort->rxPoolsParams.secondLargestBufSize, BMI_FIFO_UNITS)
38916 + + (7 * BMI_FIFO_UNITS));
38917 + }
38918 + else
38919 + {
38920 +#if (DPAA_VERSION >= 11)
38921 + minFifoSizeRequired =
38922 + (uint32_t)(ROUND_UP(p_FmPort->maxFrameLength, BMI_FIFO_UNITS)
38923 + + (5 * BMI_FIFO_UNITS));
38924 + /* 4 according to spec + 1 for FOF>0 */
38925 +#else
38926 + minFifoSizeRequired = (uint32_t)
38927 + (ROUND_UP(MIN(p_FmPort->maxFrameLength, p_FmPort->rxPoolsParams.largestBufSize), BMI_FIFO_UNITS)
38928 + + (7*BMI_FIFO_UNITS));
38929 +#endif /* (DPAA_VERSION >= 11) */
38930 + }
38931 +
38932 + optFifoSizeForB2B = minFifoSizeRequired;
38933 +
38934 + /* Add some margin for back-to-back capability to improve performance,
38935 + allows the hardware to pipeline new frame dma while the previous
38936 + frame not yet transmitted. */
38937 + if (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
38938 + optFifoSizeForB2B += 8 * BMI_FIFO_UNITS;
38939 + else
38940 + optFifoSizeForB2B += 3 * BMI_FIFO_UNITS;
38941 + }
38942 +
38943 + /* For O/H ports, check fifo size and update if necessary */
38944 + else
38945 + if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
38946 + || (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
38947 + {
38948 +#if (DPAA_VERSION >= 11)
38949 + optFifoSizeForB2B =
38950 + minFifoSizeRequired =
38951 + (uint32_t)(ROUND_UP(p_FmPort->maxFrameLength, BMI_FIFO_UNITS)
38952 + + ((p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth
38953 + + 5) * BMI_FIFO_UNITS));
38954 + /* 4 according to spec + 1 for FOF>0 */
38955 +#else
38956 + optFifoSizeForB2B = minFifoSizeRequired = (uint32_t)((p_FmPort->tasks.num + 2) * BMI_FIFO_UNITS);
38957 +#endif /* (DPAA_VERSION >= 11) */
38958 + }
38959 +
38960 + ASSERT_COND(minFifoSizeRequired > 0);
38961 + ASSERT_COND(optFifoSizeForB2B >= minFifoSizeRequired);
38962 +
38963 + /* Verify the size */
38964 + if (p_FmPort->fifoBufs.num < minFifoSizeRequired)
38965 + DBG(INFO,
38966 + ("FIFO size is %d and should be enlarged to %d bytes",p_FmPort->fifoBufs.num, minFifoSizeRequired));
38967 + else if (p_FmPort->fifoBufs.num < optFifoSizeForB2B)
38968 + DBG(INFO,
38969 + ("For back-to-back frames processing, FIFO size is %d and needs to enlarge to %d bytes", p_FmPort->fifoBufs.num, optFifoSizeForB2B));
38970 +
38971 + return E_OK;
38972 +}
38973 +
38974 +static void FmPortDriverParamFree(t_FmPort *p_FmPort)
38975 +{
38976 + if (p_FmPort->p_FmPortDriverParam)
38977 + {
38978 + XX_Free(p_FmPort->p_FmPortDriverParam);
38979 + p_FmPort->p_FmPortDriverParam = NULL;
38980 + }
38981 +}
38982 +
38983 +static t_Error SetExtBufferPools(t_FmPort *p_FmPort)
38984 +{
38985 + t_FmExtPools *p_ExtBufPools = &p_FmPort->p_FmPortDriverParam->extBufPools;
38986 + t_FmBufPoolDepletion *p_BufPoolDepletion =
38987 + &p_FmPort->p_FmPortDriverParam->bufPoolDepletion;
38988 + uint8_t orderedArray[FM_PORT_MAX_NUM_OF_EXT_POOLS];
38989 + uint16_t sizesArray[BM_MAX_NUM_OF_POOLS];
38990 + int i = 0, j = 0, err;
38991 + struct fman_port_bpools bpools;
38992 +
38993 + memset(&orderedArray, 0, sizeof(uint8_t) * FM_PORT_MAX_NUM_OF_EXT_POOLS);
38994 + memset(&sizesArray, 0, sizeof(uint16_t) * BM_MAX_NUM_OF_POOLS);
38995 + memcpy(&p_FmPort->extBufPools, p_ExtBufPools, sizeof(t_FmExtPools));
38996 +
38997 + FmSpSetBufPoolsInAscOrderOfBufSizes(p_ExtBufPools, orderedArray,
38998 + sizesArray);
38999 +
39000 + /* Prepare flibs bpools structure */
39001 + memset(&bpools, 0, sizeof(struct fman_port_bpools));
39002 + bpools.count = p_ExtBufPools->numOfPoolsUsed;
39003 + bpools.counters_enable = TRUE;
39004 + for (i = 0; i < p_ExtBufPools->numOfPoolsUsed; i++)
39005 + {
39006 + bpools.bpool[i].bpid = orderedArray[i];
39007 + bpools.bpool[i].size = sizesArray[orderedArray[i]];
39008 + /* functionality available only for some derivatives (limited by config) */
39009 + if (p_FmPort->p_FmPortDriverParam->p_BackupBmPools)
39010 + for (j = 0;
39011 + j
39012 + < p_FmPort->p_FmPortDriverParam->p_BackupBmPools->numOfBackupPools;
39013 + j++)
39014 + if (orderedArray[i]
39015 + == p_FmPort->p_FmPortDriverParam->p_BackupBmPools->poolIds[j])
39016 + {
39017 + bpools.bpool[i].is_backup = TRUE;
39018 + break;
39019 + }
39020 + }
39021 +
39022 + /* save pools parameters for later use */
39023 + p_FmPort->rxPoolsParams.numOfPools = p_ExtBufPools->numOfPoolsUsed;
39024 + p_FmPort->rxPoolsParams.largestBufSize =
39025 + sizesArray[orderedArray[p_ExtBufPools->numOfPoolsUsed - 1]];
39026 + p_FmPort->rxPoolsParams.secondLargestBufSize =
39027 + sizesArray[orderedArray[p_ExtBufPools->numOfPoolsUsed - 2]];
39028 +
39029 + /* FMBM_RMPD reg. - pool depletion */
39030 + if (p_BufPoolDepletion->poolsGrpModeEnable)
39031 + {
39032 + bpools.grp_bp_depleted_num = p_BufPoolDepletion->numOfPools;
39033 + for (i = 0; i < BM_MAX_NUM_OF_POOLS; i++)
39034 + {
39035 + if (p_BufPoolDepletion->poolsToConsider[i])
39036 + {
39037 + for (j = 0; j < p_ExtBufPools->numOfPoolsUsed; j++)
39038 + {
39039 + if (i == orderedArray[j])
39040 + {
39041 + bpools.bpool[j].grp_bp_depleted = TRUE;
39042 + break;
39043 + }
39044 + }
39045 + }
39046 + }
39047 + }
39048 +
39049 + if (p_BufPoolDepletion->singlePoolModeEnable)
39050 + {
39051 + for (i = 0; i < BM_MAX_NUM_OF_POOLS; i++)
39052 + {
39053 + if (p_BufPoolDepletion->poolsToConsiderForSingleMode[i])
39054 + {
39055 + for (j = 0; j < p_ExtBufPools->numOfPoolsUsed; j++)
39056 + {
39057 + if (i == orderedArray[j])
39058 + {
39059 + bpools.bpool[j].single_bp_depleted = TRUE;
39060 + break;
39061 + }
39062 + }
39063 + }
39064 + }
39065 + }
39066 +
39067 +#if (DPAA_VERSION >= 11)
39068 + /* fill QbbPEV */
39069 + if (p_BufPoolDepletion->poolsGrpModeEnable
39070 + || p_BufPoolDepletion->singlePoolModeEnable)
39071 + {
39072 + for (i = 0; i < FM_MAX_NUM_OF_PFC_PRIORITIES; i++)
39073 + {
39074 + if (p_BufPoolDepletion->pfcPrioritiesEn[i] == TRUE)
39075 + {
39076 + bpools.bpool[i].pfc_priorities_en = TRUE;
39077 + }
39078 + }
39079 + }
39080 +#endif /* (DPAA_VERSION >= 11) */
39081 +
39082 + /* Issue flibs function */
39083 + err = fman_port_set_bpools(&p_FmPort->port, &bpools);
39084 + if (err != 0)
39085 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_bpools"));
39086 +
39087 + if (p_FmPort->p_FmPortDriverParam->p_BackupBmPools)
39088 + XX_Free(p_FmPort->p_FmPortDriverParam->p_BackupBmPools);
39089 +
39090 + return E_OK;
39091 +}
39092 +
39093 +static t_Error ClearPerfCnts(t_FmPort *p_FmPort)
39094 +{
39095 + if (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
39096 + FM_PORT_ModifyCounter(p_FmPort, e_FM_PORT_COUNTERS_QUEUE_UTIL, 0);
39097 + FM_PORT_ModifyCounter(p_FmPort, e_FM_PORT_COUNTERS_TASK_UTIL, 0);
39098 + FM_PORT_ModifyCounter(p_FmPort, e_FM_PORT_COUNTERS_DMA_UTIL, 0);
39099 + FM_PORT_ModifyCounter(p_FmPort, e_FM_PORT_COUNTERS_FIFO_UTIL, 0);
39100 + return E_OK;
39101 +}
39102 +
39103 +static t_Error InitLowLevelDriver(t_FmPort *p_FmPort)
39104 +{
39105 + t_FmPortDriverParam *p_DriverParams = p_FmPort->p_FmPortDriverParam;
39106 + struct fman_port_params portParams;
39107 + uint32_t tmpVal;
39108 + t_Error err;
39109 +
39110 + /* Set up flibs parameters and issue init function */
39111 +
39112 + memset(&portParams, 0, sizeof(struct fman_port_params));
39113 + portParams.discard_mask = p_DriverParams->errorsToDiscard;
39114 + portParams.dflt_fqid = p_DriverParams->dfltFqid;
39115 + portParams.err_fqid = p_DriverParams->errFqid;
39116 + portParams.deq_sp = p_DriverParams->deqSubPortal;
39117 + portParams.dont_release_buf = p_DriverParams->dontReleaseBuf;
39118 + switch (p_FmPort->portType)
39119 + {
39120 + case (e_FM_PORT_TYPE_RX_10G):
39121 + case (e_FM_PORT_TYPE_RX):
39122 + portParams.err_mask = (RX_ERRS_TO_ENQ & ~portParams.discard_mask);
39123 + if (!p_FmPort->imEn)
39124 + {
39125 + if (p_DriverParams->forwardReuseIntContext)
39126 + p_DriverParams->dfltCfg.rx_fd_bits =
39127 + (uint8_t)(BMI_PORT_RFNE_FRWD_RPD >> 24);
39128 + }
39129 + break;
39130 +
39131 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
39132 + portParams.err_mask = (OP_ERRS_TO_ENQ & ~portParams.discard_mask);
39133 + break;
39134 + break;
39135 +
39136 + default:
39137 + break;
39138 + }
39139 +
39140 + tmpVal =
39141 + (uint32_t)(
39142 + (p_FmPort->internalBufferOffset % OFFSET_UNITS) ? (p_FmPort->internalBufferOffset
39143 + / OFFSET_UNITS + 1) :
39144 + (p_FmPort->internalBufferOffset / OFFSET_UNITS));
39145 + p_FmPort->internalBufferOffset = (uint8_t)(tmpVal * OFFSET_UNITS);
39146 + p_DriverParams->dfltCfg.int_buf_start_margin =
39147 + p_FmPort->internalBufferOffset;
39148 +
39149 + p_DriverParams->dfltCfg.ext_buf_start_margin =
39150 + p_DriverParams->bufMargins.startMargins;
39151 + p_DriverParams->dfltCfg.ext_buf_end_margin =
39152 + p_DriverParams->bufMargins.endMargins;
39153 +
39154 + p_DriverParams->dfltCfg.ic_ext_offset =
39155 + p_DriverParams->intContext.extBufOffset;
39156 + p_DriverParams->dfltCfg.ic_int_offset =
39157 + p_DriverParams->intContext.intContextOffset;
39158 + p_DriverParams->dfltCfg.ic_size = p_DriverParams->intContext.size;
39159 +
39160 + p_DriverParams->dfltCfg.stats_counters_enable = TRUE;
39161 + p_DriverParams->dfltCfg.perf_counters_enable = TRUE;
39162 + p_DriverParams->dfltCfg.queue_counters_enable = TRUE;
39163 +
39164 + p_DriverParams->dfltCfg.perf_cnt_params.task_val =
39165 + (uint8_t)p_FmPort->tasks.num;
39166 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING ||
39167 + p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)p_DriverParams->dfltCfg.perf_cnt_params.queue_val = 0;
39168 + else
39169 + p_DriverParams->dfltCfg.perf_cnt_params.queue_val = 1;
39170 + p_DriverParams->dfltCfg.perf_cnt_params.dma_val =
39171 + (uint8_t)p_FmPort->openDmas.num;
39172 + p_DriverParams->dfltCfg.perf_cnt_params.fifo_val = p_FmPort->fifoBufs.num;
39173 +
39174 + if (0
39175 + != fman_port_init(&p_FmPort->port, &p_DriverParams->dfltCfg,
39176 + &portParams))
39177 + RETURN_ERROR(MAJOR, E_NO_DEVICE, ("fman_port_init"));
39178 +
39179 + if (p_FmPort->imEn && ((err = FmPortImInit(p_FmPort)) != E_OK))
39180 + RETURN_ERROR(MAJOR, err, NO_MSG);
39181 + else
39182 + {
39183 + // from QMIInit
39184 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
39185 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
39186 + {
39187 + if (p_DriverParams->deqPrefetchOption == e_FM_PORT_DEQ_NO_PREFETCH)
39188 + FmSetPortPreFetchConfiguration(p_FmPort->h_Fm, p_FmPort->portId,
39189 + FALSE);
39190 + else
39191 + FmSetPortPreFetchConfiguration(p_FmPort->h_Fm, p_FmPort->portId,
39192 + TRUE);
39193 + }
39194 + }
39195 + /* The code bellow is a trick so the FM will not release the buffer
39196 + to BM nor will try to enqueue the frame to QM */
39197 + if (((p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)
39198 + || (p_FmPort->portType == e_FM_PORT_TYPE_TX)) && (!p_FmPort->imEn))
39199 + {
39200 + if (!p_DriverParams->dfltFqid && p_DriverParams->dontReleaseBuf)
39201 + {
39202 + /* override fmbm_tcfqid 0 with a false non-0 value. This will force FM to
39203 + * act according to tfene. Otherwise, if fmbm_tcfqid is 0 the FM will release
39204 + * buffers to BM regardless of fmbm_tfene
39205 + */
39206 + WRITE_UINT32(p_FmPort->port.bmi_regs->tx.fmbm_tcfqid, 0xFFFFFF);
39207 + WRITE_UINT32(p_FmPort->port.bmi_regs->tx.fmbm_tfene,
39208 + NIA_ENG_BMI | NIA_BMI_AC_TX_RELEASE);
39209 + }
39210 + }
39211 +
39212 + return E_OK;
39213 +}
39214 +
39215 +static bool CheckRxBmiCounter(t_FmPort *p_FmPort, e_FmPortCounters counter)
39216 +{
39217 + UNUSED(p_FmPort);
39218 +
39219 + switch (counter)
39220 + {
39221 + case (e_FM_PORT_COUNTERS_CYCLE):
39222 + case (e_FM_PORT_COUNTERS_TASK_UTIL):
39223 + case (e_FM_PORT_COUNTERS_QUEUE_UTIL):
39224 + case (e_FM_PORT_COUNTERS_DMA_UTIL):
39225 + case (e_FM_PORT_COUNTERS_FIFO_UTIL):
39226 + case (e_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION):
39227 + case (e_FM_PORT_COUNTERS_FRAME):
39228 + case (e_FM_PORT_COUNTERS_DISCARD_FRAME):
39229 + case (e_FM_PORT_COUNTERS_RX_BAD_FRAME):
39230 + case (e_FM_PORT_COUNTERS_RX_LARGE_FRAME):
39231 + case (e_FM_PORT_COUNTERS_RX_FILTER_FRAME):
39232 + case (e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR):
39233 + case (e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD):
39234 + case (e_FM_PORT_COUNTERS_DEALLOC_BUF):
39235 + case (e_FM_PORT_COUNTERS_PREPARE_TO_ENQUEUE_COUNTER):
39236 + return TRUE;
39237 + default:
39238 + return FALSE;
39239 + }
39240 +}
39241 +
39242 +static bool CheckTxBmiCounter(t_FmPort *p_FmPort, e_FmPortCounters counter)
39243 +{
39244 + UNUSED(p_FmPort);
39245 +
39246 + switch (counter)
39247 + {
39248 + case (e_FM_PORT_COUNTERS_CYCLE):
39249 + case (e_FM_PORT_COUNTERS_TASK_UTIL):
39250 + case (e_FM_PORT_COUNTERS_QUEUE_UTIL):
39251 + case (e_FM_PORT_COUNTERS_DMA_UTIL):
39252 + case (e_FM_PORT_COUNTERS_FIFO_UTIL):
39253 + case (e_FM_PORT_COUNTERS_FRAME):
39254 + case (e_FM_PORT_COUNTERS_DISCARD_FRAME):
39255 + case (e_FM_PORT_COUNTERS_LENGTH_ERR):
39256 + case (e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT):
39257 + case (e_FM_PORT_COUNTERS_DEALLOC_BUF):
39258 + return TRUE;
39259 + default:
39260 + return FALSE;
39261 + }
39262 +}
39263 +
39264 +static bool CheckOhBmiCounter(t_FmPort *p_FmPort, e_FmPortCounters counter)
39265 +{
39266 + switch (counter)
39267 + {
39268 + case (e_FM_PORT_COUNTERS_CYCLE):
39269 + case (e_FM_PORT_COUNTERS_TASK_UTIL):
39270 + case (e_FM_PORT_COUNTERS_DMA_UTIL):
39271 + case (e_FM_PORT_COUNTERS_FIFO_UTIL):
39272 + case (e_FM_PORT_COUNTERS_FRAME):
39273 + case (e_FM_PORT_COUNTERS_DISCARD_FRAME):
39274 + case (e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR):
39275 + case (e_FM_PORT_COUNTERS_WRED_DISCARD):
39276 + case (e_FM_PORT_COUNTERS_LENGTH_ERR):
39277 + case (e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT):
39278 + case (e_FM_PORT_COUNTERS_DEALLOC_BUF):
39279 + return TRUE;
39280 + case (e_FM_PORT_COUNTERS_RX_FILTER_FRAME):
39281 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
39282 + return FALSE;
39283 + else
39284 + return TRUE;
39285 + default:
39286 + return FALSE;
39287 + }
39288 +}
39289 +
39290 +static t_Error BmiPortCheckAndGetCounterType(
39291 + t_FmPort *p_FmPort, e_FmPortCounters counter,
39292 + enum fman_port_stats_counters *p_StatsType,
39293 + enum fman_port_perf_counters *p_PerfType, bool *p_IsStats)
39294 +{
39295 + volatile uint32_t *p_Reg;
39296 + bool isValid;
39297 +
39298 + switch (p_FmPort->portType)
39299 + {
39300 + case (e_FM_PORT_TYPE_RX_10G):
39301 + case (e_FM_PORT_TYPE_RX):
39302 + p_Reg = &p_FmPort->port.bmi_regs->rx.fmbm_rstc;
39303 + isValid = CheckRxBmiCounter(p_FmPort, counter);
39304 + break;
39305 + case (e_FM_PORT_TYPE_TX_10G):
39306 + case (e_FM_PORT_TYPE_TX):
39307 + p_Reg = &p_FmPort->port.bmi_regs->tx.fmbm_tstc;
39308 + isValid = CheckTxBmiCounter(p_FmPort, counter);
39309 + break;
39310 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
39311 + case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
39312 + p_Reg = &p_FmPort->port.bmi_regs->oh.fmbm_ostc;
39313 + isValid = CheckOhBmiCounter(p_FmPort, counter);
39314 + break;
39315 + default:
39316 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Unsupported port type"));
39317 + }
39318 +
39319 + if (!isValid)
39320 + RETURN_ERROR(MINOR, E_INVALID_STATE,
39321 + ("Requested counter is not available for this port type"));
39322 +
39323 + /* check that counters are enabled */
39324 + switch (counter)
39325 + {
39326 + case (e_FM_PORT_COUNTERS_CYCLE):
39327 + case (e_FM_PORT_COUNTERS_TASK_UTIL):
39328 + case (e_FM_PORT_COUNTERS_QUEUE_UTIL):
39329 + case (e_FM_PORT_COUNTERS_DMA_UTIL):
39330 + case (e_FM_PORT_COUNTERS_FIFO_UTIL):
39331 + case (e_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION):
39332 + /* performance counters - may be read when disabled */
39333 + *p_IsStats = FALSE;
39334 + break;
39335 + case (e_FM_PORT_COUNTERS_FRAME):
39336 + case (e_FM_PORT_COUNTERS_DISCARD_FRAME):
39337 + case (e_FM_PORT_COUNTERS_DEALLOC_BUF):
39338 + case (e_FM_PORT_COUNTERS_RX_BAD_FRAME):
39339 + case (e_FM_PORT_COUNTERS_RX_LARGE_FRAME):
39340 + case (e_FM_PORT_COUNTERS_RX_FILTER_FRAME):
39341 + case (e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR):
39342 + case (e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD):
39343 + case (e_FM_PORT_COUNTERS_LENGTH_ERR):
39344 + case (e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT):
39345 + case (e_FM_PORT_COUNTERS_WRED_DISCARD):
39346 + *p_IsStats = TRUE;
39347 + if (!(GET_UINT32(*p_Reg) & BMI_COUNTERS_EN))
39348 + RETURN_ERROR(MINOR, E_INVALID_STATE,
39349 + ("Requested counter was not enabled"));
39350 + break;
39351 + default:
39352 + break;
39353 + }
39354 +
39355 + /* Set counter */
39356 + switch (counter)
39357 + {
39358 + case (e_FM_PORT_COUNTERS_CYCLE):
39359 + *p_PerfType = E_FMAN_PORT_PERF_CNT_CYCLE;
39360 + break;
39361 + case (e_FM_PORT_COUNTERS_TASK_UTIL):
39362 + *p_PerfType = E_FMAN_PORT_PERF_CNT_TASK_UTIL;
39363 + break;
39364 + case (e_FM_PORT_COUNTERS_QUEUE_UTIL):
39365 + *p_PerfType = E_FMAN_PORT_PERF_CNT_QUEUE_UTIL;
39366 + break;
39367 + case (e_FM_PORT_COUNTERS_DMA_UTIL):
39368 + *p_PerfType = E_FMAN_PORT_PERF_CNT_DMA_UTIL;
39369 + break;
39370 + case (e_FM_PORT_COUNTERS_FIFO_UTIL):
39371 + *p_PerfType = E_FMAN_PORT_PERF_CNT_FIFO_UTIL;
39372 + break;
39373 + case (e_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION):
39374 + *p_PerfType = E_FMAN_PORT_PERF_CNT_RX_PAUSE;
39375 + break;
39376 + case (e_FM_PORT_COUNTERS_FRAME):
39377 + *p_StatsType = E_FMAN_PORT_STATS_CNT_FRAME;
39378 + break;
39379 + case (e_FM_PORT_COUNTERS_DISCARD_FRAME):
39380 + *p_StatsType = E_FMAN_PORT_STATS_CNT_DISCARD;
39381 + break;
39382 + case (e_FM_PORT_COUNTERS_DEALLOC_BUF):
39383 + *p_StatsType = E_FMAN_PORT_STATS_CNT_DEALLOC_BUF;
39384 + break;
39385 + case (e_FM_PORT_COUNTERS_RX_BAD_FRAME):
39386 + *p_StatsType = E_FMAN_PORT_STATS_CNT_RX_BAD_FRAME;
39387 + break;
39388 + case (e_FM_PORT_COUNTERS_RX_LARGE_FRAME):
39389 + *p_StatsType = E_FMAN_PORT_STATS_CNT_RX_LARGE_FRAME;
39390 + break;
39391 + case (e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD):
39392 + *p_StatsType = E_FMAN_PORT_STATS_CNT_RX_OUT_OF_BUF;
39393 + break;
39394 + case (e_FM_PORT_COUNTERS_RX_FILTER_FRAME):
39395 + *p_StatsType = E_FMAN_PORT_STATS_CNT_FILTERED_FRAME;
39396 + break;
39397 + case (e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR):
39398 + *p_StatsType = E_FMAN_PORT_STATS_CNT_DMA_ERR;
39399 + break;
39400 + case (e_FM_PORT_COUNTERS_WRED_DISCARD):
39401 + *p_StatsType = E_FMAN_PORT_STATS_CNT_WRED_DISCARD;
39402 + break;
39403 + case (e_FM_PORT_COUNTERS_LENGTH_ERR):
39404 + *p_StatsType = E_FMAN_PORT_STATS_CNT_LEN_ERR;
39405 + break;
39406 + case (e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT):
39407 + *p_StatsType = E_FMAN_PORT_STATS_CNT_UNSUPPORTED_FORMAT;
39408 + break;
39409 + default:
39410 + break;
39411 + }
39412 +
39413 + return E_OK;
39414 +}
39415 +
39416 +static t_Error AdditionalPrsParams(t_FmPort *p_FmPort,
39417 + t_FmPcdPrsAdditionalHdrParams *p_HdrParams,
39418 + uint32_t *p_SoftSeqAttachReg)
39419 +{
39420 + uint8_t hdrNum, Ipv4HdrNum;
39421 + u_FmPcdHdrPrsOpts *p_prsOpts;
39422 + uint32_t tmpReg = *p_SoftSeqAttachReg, tmpPrsOffset;
39423 +
39424 + if (IS_PRIVATE_HEADER(p_HdrParams->hdr)
39425 + || IS_SPECIAL_HEADER(p_HdrParams->hdr))
39426 + RETURN_ERROR(
39427 + MAJOR, E_NOT_SUPPORTED,
39428 + ("No additional parameters for private or special headers."));
39429 +
39430 + if (p_HdrParams->errDisable)
39431 + tmpReg |= PRS_HDR_ERROR_DIS;
39432 +
39433 + /* Set parser options */
39434 + if (p_HdrParams->usePrsOpts)
39435 + {
39436 + p_prsOpts = &p_HdrParams->prsOpts;
39437 + switch (p_HdrParams->hdr)
39438 + {
39439 + case (HEADER_TYPE_MPLS):
39440 + if (p_prsOpts->mplsPrsOptions.labelInterpretationEnable)
39441 + tmpReg |= PRS_HDR_MPLS_LBL_INTER_EN;
39442 + hdrNum = GetPrsHdrNum(p_prsOpts->mplsPrsOptions.nextParse);
39443 + if (hdrNum == ILLEGAL_HDR_NUM)
39444 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
39445 + Ipv4HdrNum = GetPrsHdrNum(HEADER_TYPE_IPv4);
39446 + if (hdrNum < Ipv4HdrNum)
39447 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
39448 + ("Header must be equal or higher than IPv4"));
39449 + tmpReg |= ((uint32_t)hdrNum * PRS_HDR_ENTRY_SIZE)
39450 + << PRS_HDR_MPLS_NEXT_HDR_SHIFT;
39451 + break;
39452 + case (HEADER_TYPE_PPPoE):
39453 + if (p_prsOpts->pppoePrsOptions.enableMTUCheck)
39454 + tmpReg |= PRS_HDR_PPPOE_MTU_CHECK_EN;
39455 + break;
39456 + case (HEADER_TYPE_IPv6):
39457 + if (p_prsOpts->ipv6PrsOptions.routingHdrEnable)
39458 + tmpReg |= PRS_HDR_IPV6_ROUTE_HDR_EN;
39459 + break;
39460 + case (HEADER_TYPE_TCP):
39461 + if (p_prsOpts->tcpPrsOptions.padIgnoreChecksum)
39462 + tmpReg |= PRS_HDR_TCP_PAD_REMOVAL;
39463 + else
39464 + tmpReg &= ~PRS_HDR_TCP_PAD_REMOVAL;
39465 + break;
39466 + case (HEADER_TYPE_UDP):
39467 + if (p_prsOpts->udpPrsOptions.padIgnoreChecksum)
39468 + tmpReg |= PRS_HDR_UDP_PAD_REMOVAL;
39469 + else
39470 + tmpReg &= ~PRS_HDR_UDP_PAD_REMOVAL;
39471 + break;
39472 + default:
39473 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid header"));
39474 + }
39475 + }
39476 +
39477 + /* set software parsing (address is divided in 2 since parser uses 2 byte access. */
39478 + if (p_HdrParams->swPrsEnable)
39479 + {
39480 + tmpPrsOffset = FmPcdGetSwPrsOffset(p_FmPort->h_FmPcd, p_HdrParams->hdr,
39481 + p_HdrParams->indexPerHdr);
39482 + if (tmpPrsOffset == ILLEGAL_BASE)
39483 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
39484 + tmpReg |= (PRS_HDR_SW_PRS_EN | tmpPrsOffset);
39485 + }
39486 + *p_SoftSeqAttachReg = tmpReg;
39487 +
39488 + return E_OK;
39489 +}
39490 +
39491 +static uint32_t GetPortSchemeBindParams(
39492 + t_Handle h_FmPort, t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind)
39493 +{
39494 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
39495 + uint32_t walking1Mask = 0x80000000, tmp;
39496 + uint8_t idx = 0;
39497 +
39498 + p_SchemeBind->netEnvId = p_FmPort->netEnvId;
39499 + p_SchemeBind->hardwarePortId = p_FmPort->hardwarePortId;
39500 + p_SchemeBind->useClsPlan = p_FmPort->useClsPlan;
39501 + p_SchemeBind->numOfSchemes = 0;
39502 + tmp = p_FmPort->schemesPerPortVector;
39503 + if (tmp)
39504 + {
39505 + while (tmp)
39506 + {
39507 + if (tmp & walking1Mask)
39508 + {
39509 + p_SchemeBind->schemesIds[p_SchemeBind->numOfSchemes] = idx;
39510 + p_SchemeBind->numOfSchemes++;
39511 + tmp &= ~walking1Mask;
39512 + }
39513 + walking1Mask >>= 1;
39514 + idx++;
39515 + }
39516 + }
39517 +
39518 + return tmp;
39519 +}
39520 +
39521 +static void FmPortCheckNApplyMacsec(t_Handle h_FmPort)
39522 +{
39523 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
39524 + volatile uint32_t *p_BmiCfgReg = NULL;
39525 + uint32_t macsecEn = BMI_PORT_CFG_EN_MACSEC;
39526 + uint32_t lcv, walking1Mask = 0x80000000;
39527 + uint8_t cnt = 0;
39528 +
39529 + ASSERT_COND(p_FmPort);
39530 + ASSERT_COND(p_FmPort->h_FmPcd);
39531 + ASSERT_COND(!p_FmPort->p_FmPortDriverParam);
39532 +
39533 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
39534 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
39535 + return;
39536 +
39537 + p_BmiCfgReg = &p_FmPort->port.bmi_regs->rx.fmbm_rcfg;
39538 + /* get LCV for MACSEC */
39539 + if ((lcv = FmPcdGetMacsecLcv(p_FmPort->h_FmPcd, p_FmPort->netEnvId))
39540 + != 0)
39541 + {
39542 + while (!(lcv & walking1Mask))
39543 + {
39544 + cnt++;
39545 + walking1Mask >>= 1;
39546 + }
39547 +
39548 + macsecEn |= (uint32_t)cnt << BMI_PORT_CFG_MS_SEL_SHIFT;
39549 + WRITE_UINT32(*p_BmiCfgReg, GET_UINT32(*p_BmiCfgReg) | macsecEn);
39550 + }
39551 +}
39552 +
39553 +static t_Error SetPcd(t_FmPort *p_FmPort, t_FmPortPcdParams *p_PcdParams)
39554 +{
39555 + t_Error err = E_OK;
39556 + uint32_t tmpReg;
39557 + volatile uint32_t *p_BmiNia = NULL;
39558 + volatile uint32_t *p_BmiPrsNia = NULL;
39559 + volatile uint32_t *p_BmiPrsStartOffset = NULL;
39560 + volatile uint32_t *p_BmiInitPrsResult = NULL;
39561 + volatile uint32_t *p_BmiCcBase = NULL;
39562 + uint16_t hdrNum, L3HdrNum, greHdrNum;
39563 + int i;
39564 + bool isEmptyClsPlanGrp;
39565 + uint32_t tmpHxs[FM_PCD_PRS_NUM_OF_HDRS];
39566 + uint16_t absoluteProfileId;
39567 + uint8_t physicalSchemeId;
39568 + uint32_t ccTreePhysOffset;
39569 + t_FmPcdKgInterModuleBindPortToSchemes schemeBind;
39570 + uint32_t initialSwPrs = 0;
39571 +
39572 + ASSERT_COND(p_FmPort);
39573 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
39574 +
39575 + if (p_FmPort->imEn)
39576 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
39577 + ("available for non-independant mode ports only"));
39578 +
39579 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
39580 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
39581 + && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
39582 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
39583 + ("available for Rx and offline parsing ports only"));
39584 +
39585 + p_FmPort->netEnvId = FmPcdGetNetEnvId(p_PcdParams->h_NetEnv);
39586 +
39587 + p_FmPort->pcdEngines = 0;
39588 +
39589 + /* initialize p_FmPort->pcdEngines field in port's structure */
39590 + switch (p_PcdParams->pcdSupport)
39591 + {
39592 + case (e_FM_PORT_PCD_SUPPORT_NONE):
39593 + RETURN_ERROR(
39594 + MAJOR,
39595 + E_INVALID_STATE,
39596 + ("No PCD configuration required if e_FM_PORT_PCD_SUPPORT_NONE selected"));
39597 + case (e_FM_PORT_PCD_SUPPORT_PRS_ONLY):
39598 + p_FmPort->pcdEngines |= FM_PCD_PRS;
39599 + break;
39600 + case (e_FM_PORT_PCD_SUPPORT_PLCR_ONLY):
39601 + p_FmPort->pcdEngines |= FM_PCD_PLCR;
39602 + break;
39603 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR):
39604 + p_FmPort->pcdEngines |= FM_PCD_PRS;
39605 + p_FmPort->pcdEngines |= FM_PCD_PLCR;
39606 + break;
39607 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG):
39608 + p_FmPort->pcdEngines |= FM_PCD_PRS;
39609 + p_FmPort->pcdEngines |= FM_PCD_KG;
39610 + break;
39611 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC):
39612 + p_FmPort->pcdEngines |= FM_PCD_PRS;
39613 + p_FmPort->pcdEngines |= FM_PCD_CC;
39614 + p_FmPort->pcdEngines |= FM_PCD_KG;
39615 + break;
39616 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR):
39617 + p_FmPort->pcdEngines |= FM_PCD_PRS;
39618 + p_FmPort->pcdEngines |= FM_PCD_KG;
39619 + p_FmPort->pcdEngines |= FM_PCD_CC;
39620 + p_FmPort->pcdEngines |= FM_PCD_PLCR;
39621 + break;
39622 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_CC):
39623 + p_FmPort->pcdEngines |= FM_PCD_PRS;
39624 + p_FmPort->pcdEngines |= FM_PCD_CC;
39625 + break;
39626 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_CC_AND_PLCR):
39627 + p_FmPort->pcdEngines |= FM_PCD_PRS;
39628 + p_FmPort->pcdEngines |= FM_PCD_CC;
39629 + p_FmPort->pcdEngines |= FM_PCD_PLCR;
39630 + break;
39631 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR):
39632 + p_FmPort->pcdEngines |= FM_PCD_PRS;
39633 + p_FmPort->pcdEngines |= FM_PCD_KG;
39634 + p_FmPort->pcdEngines |= FM_PCD_PLCR;
39635 + break;
39636 + case (e_FM_PORT_PCD_SUPPORT_CC_ONLY):
39637 + p_FmPort->pcdEngines |= FM_PCD_CC;
39638 + break;
39639 +#ifdef FM_CAPWAP_SUPPORT
39640 + case (e_FM_PORT_PCD_SUPPORT_CC_AND_KG):
39641 + p_FmPort->pcdEngines |= FM_PCD_CC;
39642 + p_FmPort->pcdEngines |= FM_PCD_KG;
39643 + break;
39644 + case (e_FM_PORT_PCD_SUPPORT_CC_AND_KG_AND_PLCR):
39645 + p_FmPort->pcdEngines |= FM_PCD_CC;
39646 + p_FmPort->pcdEngines |= FM_PCD_KG;
39647 + p_FmPort->pcdEngines |= FM_PCD_PLCR;
39648 + break;
39649 +#endif /* FM_CAPWAP_SUPPORT */
39650 +
39651 + default:
39652 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("invalid pcdSupport"));
39653 + }
39654 +
39655 + if ((p_FmPort->pcdEngines & FM_PCD_PRS)
39656 + && (p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams
39657 + > FM_PCD_PRS_NUM_OF_HDRS))
39658 + RETURN_ERROR(
39659 + MAJOR,
39660 + E_INVALID_VALUE,
39661 + ("Port parser numOfHdrsWithAdditionalParams may not exceed %d", FM_PCD_PRS_NUM_OF_HDRS));
39662 +
39663 + /* check that parameters exist for each and only each defined engine */
39664 + if ((!!(p_FmPort->pcdEngines & FM_PCD_PRS) != !!p_PcdParams->p_PrsParams)
39665 + || (!!(p_FmPort->pcdEngines & FM_PCD_KG)
39666 + != !!p_PcdParams->p_KgParams)
39667 + || (!!(p_FmPort->pcdEngines & FM_PCD_CC)
39668 + != !!p_PcdParams->p_CcParams))
39669 + RETURN_ERROR(
39670 + MAJOR,
39671 + E_INVALID_STATE,
39672 + ("PCD initialization structure is not consistent with pcdSupport"));
39673 +
39674 + /* get PCD registers pointers */
39675 + switch (p_FmPort->portType)
39676 + {
39677 + case (e_FM_PORT_TYPE_RX_10G):
39678 + case (e_FM_PORT_TYPE_RX):
39679 + p_BmiNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfne;
39680 + p_BmiPrsNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfpne;
39681 + p_BmiPrsStartOffset = &p_FmPort->port.bmi_regs->rx.fmbm_rpso;
39682 + p_BmiInitPrsResult = &p_FmPort->port.bmi_regs->rx.fmbm_rprai[0];
39683 + p_BmiCcBase = &p_FmPort->port.bmi_regs->rx.fmbm_rccb;
39684 + break;
39685 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
39686 + p_BmiNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofne;
39687 + p_BmiPrsNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofpne;
39688 + p_BmiPrsStartOffset = &p_FmPort->port.bmi_regs->oh.fmbm_opso;
39689 + p_BmiInitPrsResult = &p_FmPort->port.bmi_regs->oh.fmbm_oprai[0];
39690 + p_BmiCcBase = &p_FmPort->port.bmi_regs->oh.fmbm_occb;
39691 + break;
39692 + default:
39693 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
39694 + }
39695 +
39696 + /* set PCD port parameter */
39697 + if (p_FmPort->pcdEngines & FM_PCD_CC)
39698 + {
39699 + err = FmPcdCcBindTree(p_FmPort->h_FmPcd, p_PcdParams,
39700 + p_PcdParams->p_CcParams->h_CcTree,
39701 + &ccTreePhysOffset, p_FmPort);
39702 + if (err)
39703 + RETURN_ERROR(MAJOR, err, NO_MSG);
39704 +
39705 + WRITE_UINT32(*p_BmiCcBase, ccTreePhysOffset);
39706 + p_FmPort->ccTreeId = p_PcdParams->p_CcParams->h_CcTree;
39707 + }
39708 +
39709 + if (p_FmPort->pcdEngines & FM_PCD_KG)
39710 + {
39711 + if (p_PcdParams->p_KgParams->numOfSchemes == 0)
39712 + RETURN_ERROR(
39713 + MAJOR,
39714 + E_INVALID_VALUE,
39715 + ("For ports using Keygen, at least one scheme must be bound. "));
39716 +
39717 + err = FmPcdKgSetOrBindToClsPlanGrp(p_FmPort->h_FmPcd,
39718 + p_FmPort->hardwarePortId,
39719 + p_FmPort->netEnvId,
39720 + p_FmPort->optArray,
39721 + &p_FmPort->clsPlanGrpId,
39722 + &isEmptyClsPlanGrp);
39723 + if (err)
39724 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
39725 + ("FmPcdKgSetOrBindToClsPlanGrp failed. "));
39726 +
39727 + p_FmPort->useClsPlan = !isEmptyClsPlanGrp;
39728 +
39729 + schemeBind.netEnvId = p_FmPort->netEnvId;
39730 + schemeBind.hardwarePortId = p_FmPort->hardwarePortId;
39731 + schemeBind.numOfSchemes = p_PcdParams->p_KgParams->numOfSchemes;
39732 + schemeBind.useClsPlan = p_FmPort->useClsPlan;
39733 +
39734 + /* for each scheme */
39735 + for (i = 0; i < p_PcdParams->p_KgParams->numOfSchemes; i++)
39736 + {
39737 + ASSERT_COND(p_PcdParams->p_KgParams->h_Schemes[i]);
39738 + physicalSchemeId = FmPcdKgGetSchemeId(
39739 + p_PcdParams->p_KgParams->h_Schemes[i]);
39740 + schemeBind.schemesIds[i] = physicalSchemeId;
39741 + /* build vector */
39742 + p_FmPort->schemesPerPortVector |= 1
39743 + << (31 - (uint32_t)physicalSchemeId);
39744 +#if (DPAA_VERSION >= 11)
39745 + /*because of the state that VSPE is defined per port - all PCD path should be according to this requirement
39746 + if !VSPE - in port, for relevant scheme VSPE can not be set*/
39747 + if (!p_FmPort->vspe
39748 + && FmPcdKgGetVspe((p_PcdParams->p_KgParams->h_Schemes[i])))
39749 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
39750 + ("VSPE is not at port level"));
39751 +#endif /* (DPAA_VERSION >= 11) */
39752 + }
39753 +
39754 + err = FmPcdKgBindPortToSchemes(p_FmPort->h_FmPcd, &schemeBind);
39755 + if (err)
39756 + RETURN_ERROR(MAJOR, err, NO_MSG);
39757 + }
39758 +
39759 + /***************************/
39760 + /* configure NIA after BMI */
39761 + /***************************/
39762 + /* rfne may contain FDCS bits, so first we read them. */
39763 + p_FmPort->savedBmiNia = GET_UINT32(*p_BmiNia) & BMI_RFNE_FDCS_MASK;
39764 +
39765 + /* If policer is used directly after BMI or PRS */
39766 + if ((p_FmPort->pcdEngines & FM_PCD_PLCR)
39767 + && ((p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_PLCR_ONLY)
39768 + || (p_PcdParams->pcdSupport
39769 + == e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR)))
39770 + {
39771 + if (!p_PcdParams->p_PlcrParams->h_Profile)
39772 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
39773 + ("Profile should be initialized"));
39774 +
39775 + absoluteProfileId = (uint16_t)FmPcdPlcrProfileGetAbsoluteId(
39776 + p_PcdParams->p_PlcrParams->h_Profile);
39777 +
39778 + if (!FmPcdPlcrIsProfileValid(p_FmPort->h_FmPcd, absoluteProfileId))
39779 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
39780 + ("Private port profile not valid."));
39781 +
39782 + tmpReg = (uint32_t)(absoluteProfileId | NIA_PLCR_ABSOLUTE);
39783 +
39784 + if (p_FmPort->pcdEngines & FM_PCD_PRS) /* e_FM_PCD_SUPPORT_PRS_AND_PLCR */
39785 + /* update BMI HPNIA */
39786 + WRITE_UINT32(*p_BmiPrsNia, (uint32_t)(NIA_ENG_PLCR | tmpReg));
39787 + else
39788 + /* e_FM_PCD_SUPPORT_PLCR_ONLY */
39789 + /* update BMI NIA */
39790 + p_FmPort->savedBmiNia |= (uint32_t)(NIA_ENG_PLCR);
39791 + }
39792 +
39793 + /* if CC is used directly after BMI */
39794 + if ((p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_CC_ONLY)
39795 +#ifdef FM_CAPWAP_SUPPORT
39796 + || (p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_CC_AND_KG)
39797 + || (p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_CC_AND_KG_AND_PLCR)
39798 +#endif /* FM_CAPWAP_SUPPORT */
39799 + )
39800 + {
39801 + if (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
39802 + RETURN_ERROR(
39803 + MAJOR,
39804 + E_INVALID_OPERATION,
39805 + ("e_FM_PORT_PCD_SUPPORT_CC_xx available for offline parsing ports only"));
39806 + p_FmPort->savedBmiNia |= (uint32_t)(NIA_ENG_FM_CTL | NIA_FM_CTL_AC_CC);
39807 + /* check that prs start offset == RIM[FOF] */
39808 + }
39809 +
39810 + if (p_FmPort->pcdEngines & FM_PCD_PRS)
39811 + {
39812 + ASSERT_COND(p_PcdParams->p_PrsParams);
39813 +#if (DPAA_VERSION >= 11)
39814 + if (p_PcdParams->p_PrsParams->firstPrsHdr == HEADER_TYPE_CAPWAP)
39815 + hdrNum = OFFLOAD_SW_PATCH_CAPWAP_LABEL;
39816 + else
39817 + {
39818 +#endif /* (DPAA_VERSION >= 11) */
39819 + /* if PRS is used it is always first */
39820 + hdrNum = GetPrsHdrNum(p_PcdParams->p_PrsParams->firstPrsHdr);
39821 + if (hdrNum == ILLEGAL_HDR_NUM)
39822 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unsupported header."));
39823 +#if (DPAA_VERSION >= 11)
39824 + }
39825 +#endif /* (DPAA_VERSION >= 11) */
39826 + p_FmPort->savedBmiNia |= (uint32_t)(NIA_ENG_PRS | (uint32_t)(hdrNum));
39827 + /* set after parser NIA */
39828 + tmpReg = 0;
39829 + switch (p_PcdParams->pcdSupport)
39830 + {
39831 + case (e_FM_PORT_PCD_SUPPORT_PRS_ONLY):
39832 + WRITE_UINT32(*p_BmiPrsNia,
39833 + GET_NIA_BMI_AC_ENQ_FRAME(p_FmPort->h_FmPcd));
39834 + break;
39835 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC):
39836 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR):
39837 + tmpReg = NIA_KG_CC_EN;
39838 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG):
39839 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR):
39840 + if (p_PcdParams->p_KgParams->directScheme)
39841 + {
39842 + physicalSchemeId = FmPcdKgGetSchemeId(
39843 + p_PcdParams->p_KgParams->h_DirectScheme);
39844 + /* check that this scheme was bound to this port */
39845 + for (i = 0; i < p_PcdParams->p_KgParams->numOfSchemes; i++)
39846 + if (p_PcdParams->p_KgParams->h_DirectScheme
39847 + == p_PcdParams->p_KgParams->h_Schemes[i])
39848 + break;
39849 + if (i == p_PcdParams->p_KgParams->numOfSchemes)
39850 + RETURN_ERROR(
39851 + MAJOR,
39852 + E_INVALID_VALUE,
39853 + ("Direct scheme is not one of the port selected schemes."));
39854 + tmpReg |= (uint32_t)(NIA_KG_DIRECT | physicalSchemeId);
39855 + }
39856 + WRITE_UINT32(*p_BmiPrsNia, NIA_ENG_KG | tmpReg);
39857 + break;
39858 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_CC):
39859 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_CC_AND_PLCR):
39860 + WRITE_UINT32(*p_BmiPrsNia,
39861 + (uint32_t)(NIA_ENG_FM_CTL | NIA_FM_CTL_AC_CC));
39862 + break;
39863 + case (e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR):
39864 + break;
39865 + default:
39866 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid PCD support"));
39867 + }
39868 +
39869 + /* set start parsing offset */
39870 + WRITE_UINT32(*p_BmiPrsStartOffset,
39871 + p_PcdParams->p_PrsParams->parsingOffset);
39872 +
39873 + /************************************/
39874 + /* Parser port parameters */
39875 + /************************************/
39876 + /* stop before configuring */
39877 + WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->pcac, PRS_CAC_STOP);
39878 + /* wait for parser to be in idle state */
39879 + while (GET_UINT32(p_FmPort->p_FmPortPrsRegs->pcac) & PRS_CAC_ACTIVE)
39880 + ;
39881 +
39882 + /* set soft seq attachment register */
39883 + memset(tmpHxs, 0, FM_PCD_PRS_NUM_OF_HDRS * sizeof(uint32_t));
39884 +
39885 + /* set protocol options */
39886 + for (i = 0; p_FmPort->optArray[i]; i++)
39887 + switch (p_FmPort->optArray[i])
39888 + {
39889 + case (ETH_BROADCAST):
39890 + hdrNum = GetPrsHdrNum(HEADER_TYPE_ETH);
39891 + tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_ETH_BC_SHIFT;
39892 + break;
39893 + case (ETH_MULTICAST):
39894 + hdrNum = GetPrsHdrNum(HEADER_TYPE_ETH);
39895 + tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_ETH_MC_SHIFT;
39896 + break;
39897 + case (VLAN_STACKED):
39898 + hdrNum = GetPrsHdrNum(HEADER_TYPE_VLAN);
39899 + tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_VLAN_STACKED_SHIFT;
39900 + break;
39901 + case (MPLS_STACKED):
39902 + hdrNum = GetPrsHdrNum(HEADER_TYPE_MPLS);
39903 + tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_MPLS_STACKED_SHIFT;
39904 + break;
39905 + case (IPV4_BROADCAST_1):
39906 + hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv4);
39907 + tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV4_1_BC_SHIFT;
39908 + break;
39909 + case (IPV4_MULTICAST_1):
39910 + hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv4);
39911 + tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV4_1_MC_SHIFT;
39912 + break;
39913 + case (IPV4_UNICAST_2):
39914 + hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv4);
39915 + tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV4_2_UC_SHIFT;
39916 + break;
39917 + case (IPV4_MULTICAST_BROADCAST_2):
39918 + hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv4);
39919 + tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV4_2_MC_BC_SHIFT;
39920 + break;
39921 + case (IPV6_MULTICAST_1):
39922 + hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
39923 + tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV6_1_MC_SHIFT;
39924 + break;
39925 + case (IPV6_UNICAST_2):
39926 + hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
39927 + tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV6_2_UC_SHIFT;
39928 + break;
39929 + case (IPV6_MULTICAST_2):
39930 + hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
39931 + tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV6_2_MC_SHIFT;
39932 + break;
39933 + }
39934 +
39935 + if (FmPcdNetEnvIsHdrExist(p_FmPort->h_FmPcd, p_FmPort->netEnvId,
39936 + HEADER_TYPE_UDP_ENCAP_ESP))
39937 + {
39938 + if (p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams == FM_PCD_PRS_NUM_OF_HDRS)
39939 + RETURN_ERROR(
39940 + MINOR, E_INVALID_VALUE,
39941 + ("If HEADER_TYPE_UDP_ENCAP_ESP is used, numOfHdrsWithAdditionalParams may be up to FM_PCD_PRS_NUM_OF_HDRS - 1"));
39942 +
39943 + p_PcdParams->p_PrsParams->additionalParams[p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams].hdr =
39944 + HEADER_TYPE_UDP;
39945 + p_PcdParams->p_PrsParams->additionalParams[p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams].swPrsEnable =
39946 + TRUE;
39947 + p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams++;
39948 + }
39949 +
39950 + /* set MPLS default next header - HW reset workaround */
39951 + hdrNum = GetPrsHdrNum(HEADER_TYPE_MPLS);
39952 + tmpHxs[hdrNum] |= PRS_HDR_MPLS_LBL_INTER_EN;
39953 + L3HdrNum = GetPrsHdrNum(HEADER_TYPE_USER_DEFINED_L3);
39954 + tmpHxs[hdrNum] |= (uint32_t)L3HdrNum << PRS_HDR_MPLS_NEXT_HDR_SHIFT;
39955 +
39956 + /* for GRE, disable errors */
39957 + greHdrNum = GetPrsHdrNum(HEADER_TYPE_GRE);
39958 + tmpHxs[greHdrNum] |= PRS_HDR_ERROR_DIS;
39959 +
39960 + /* For UDP remove PAD from L4 checksum calculation */
39961 + hdrNum = GetPrsHdrNum(HEADER_TYPE_UDP);
39962 + tmpHxs[hdrNum] |= PRS_HDR_UDP_PAD_REMOVAL;
39963 + /* For TCP remove PAD from L4 checksum calculation */
39964 + hdrNum = GetPrsHdrNum(HEADER_TYPE_TCP);
39965 + tmpHxs[hdrNum] |= PRS_HDR_TCP_PAD_REMOVAL;
39966 +
39967 + /* config additional params for specific headers */
39968 + for (i = 0; i < p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams;
39969 + i++)
39970 + {
39971 + /* case for using sw parser as the initial NIA address, before
39972 + * HW parsing
39973 + */
39974 + if ((p_PcdParams->p_PrsParams->additionalParams[i].hdr == HEADER_TYPE_NONE) &&
39975 + p_PcdParams->p_PrsParams->additionalParams[i].swPrsEnable)
39976 + {
39977 + initialSwPrs = FmPcdGetSwPrsOffset(p_FmPort->h_FmPcd, HEADER_TYPE_NONE,
39978 + p_PcdParams->p_PrsParams->additionalParams[i].indexPerHdr);
39979 + if (initialSwPrs == ILLEGAL_BASE)
39980 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
39981 +
39982 + /* clear parser first HXS */
39983 + p_FmPort->savedBmiNia &= ~BMI_RFNE_HXS_MASK; /* 0x000000FF */
39984 + /* rewrite with soft parser start */
39985 + p_FmPort->savedBmiNia |= initialSwPrs;
39986 + continue;
39987 + }
39988 +
39989 + hdrNum =
39990 + GetPrsHdrNum(p_PcdParams->p_PrsParams->additionalParams[i].hdr);
39991 + if (hdrNum == ILLEGAL_HDR_NUM)
39992 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
39993 + if (hdrNum == NO_HDR_NUM)
39994 + RETURN_ERROR(
39995 + MAJOR, E_INVALID_VALUE,
39996 + ("Private headers may not use additional parameters"));
39997 +
39998 + err = AdditionalPrsParams(
39999 + p_FmPort, &p_PcdParams->p_PrsParams->additionalParams[i],
40000 + &tmpHxs[hdrNum]);
40001 + if (err)
40002 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
40003 + }
40004 +
40005 + /* Check if ip-reassembly port - need to link sw-parser code */
40006 + if (p_FmPort->h_IpReassemblyManip)
40007 + {
40008 + /* link to sw parser code for IP Frag - only if no other code is applied. */
40009 + hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv4);
40010 + if (!(tmpHxs[hdrNum] & PRS_HDR_SW_PRS_EN))
40011 + tmpHxs[hdrNum] |= (PRS_HDR_SW_PRS_EN | OFFLOAD_SW_PATCH_IPv4_IPR_LABEL);
40012 + hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
40013 + if (!(tmpHxs[hdrNum] & PRS_HDR_SW_PRS_EN))
40014 + tmpHxs[hdrNum] |= (PRS_HDR_SW_PRS_EN | OFFLOAD_SW_PATCH_IPv6_IPR_LABEL);
40015 + } else {
40016 + if (FmPcdNetEnvIsHdrExist(p_FmPort->h_FmPcd, p_FmPort->netEnvId, HEADER_TYPE_UDP_LITE))
40017 + {
40018 + hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
40019 + if (!(tmpHxs[hdrNum] & PRS_HDR_SW_PRS_EN))
40020 + tmpHxs[hdrNum] |= (PRS_HDR_SW_PRS_EN | OFFLOAD_SW_PATCH_IPv6_IPF_LABEL);
40021 + } else if ((FmPcdIsAdvancedOffloadSupported(p_FmPort->h_FmPcd)
40022 + && (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)))
40023 + {
40024 + hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
40025 + if (!(tmpHxs[hdrNum] & PRS_HDR_SW_PRS_EN))
40026 + tmpHxs[hdrNum] |= (PRS_HDR_SW_PRS_EN | OFFLOAD_SW_PATCH_IPv6_IPF_LABEL);
40027 + }
40028 + }
40029 +
40030 +#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
40031 + if (FmPcdNetEnvIsHdrExist(p_FmPort->h_FmPcd, p_FmPort->netEnvId,
40032 + HEADER_TYPE_UDP_LITE))
40033 + {
40034 + /* link to sw parser code for udp lite - only if no other code is applied. */
40035 + hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
40036 + if (!(tmpHxs[hdrNum] & PRS_HDR_SW_PRS_EN))
40037 + tmpHxs[hdrNum] |= (PRS_HDR_SW_PRS_EN | UDP_LITE_SW_PATCH_LABEL);
40038 + }
40039 +#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
40040 + for (i = 0; i < FM_PCD_PRS_NUM_OF_HDRS; i++)
40041 + {
40042 + /* For all header set LCV as taken from netEnv*/
40043 + WRITE_UINT32(
40044 + p_FmPort->p_FmPortPrsRegs->hdrs[i].lcv,
40045 + FmPcdGetLcv(p_FmPort->h_FmPcd, p_FmPort->netEnvId, (uint8_t)i));
40046 + /* set HXS register according to default+Additional params+protocol options */
40047 + WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->hdrs[i].softSeqAttach,
40048 + tmpHxs[i]);
40049 + }
40050 +
40051 + /* set tpid. */
40052 + tmpReg = PRS_TPID_DFLT;
40053 + if (p_PcdParams->p_PrsParams->setVlanTpid1)
40054 + {
40055 + tmpReg &= PRS_TPID2_MASK;
40056 + tmpReg |= (uint32_t)p_PcdParams->p_PrsParams->vlanTpid1
40057 + << PRS_PCTPID_SHIFT;
40058 + }
40059 + if (p_PcdParams->p_PrsParams->setVlanTpid2)
40060 + {
40061 + tmpReg &= PRS_TPID1_MASK;
40062 + tmpReg |= (uint32_t)p_PcdParams->p_PrsParams->vlanTpid2;
40063 + }WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->pctpid, tmpReg);
40064 +
40065 + /* enable parser */
40066 + WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->pcac, 0);
40067 +
40068 + if (p_PcdParams->p_PrsParams->prsResultPrivateInfo)
40069 + p_FmPort->privateInfo =
40070 + p_PcdParams->p_PrsParams->prsResultPrivateInfo;
40071 +
40072 + } /* end parser */
40073 + else {
40074 + if (FmPcdIsAdvancedOffloadSupported(p_FmPort->h_FmPcd)
40075 + && (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
40076 + {
40077 + hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
40078 + WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->hdrs[hdrNum].softSeqAttach,
40079 + (PRS_HDR_SW_PRS_EN | OFFLOAD_SW_PATCH_IPv6_IPF_LABEL));
40080 + }
40081 +
40082 + WRITE_UINT32(*p_BmiPrsStartOffset, 0);
40083 +
40084 + p_FmPort->privateInfo = 0;
40085 + }
40086 +
40087 + FmPortCheckNApplyMacsec(p_FmPort);
40088 +
40089 + WRITE_UINT32(
40090 + *p_BmiPrsStartOffset,
40091 + GET_UINT32(*p_BmiPrsStartOffset) + p_FmPort->internalBufferOffset);
40092 +
40093 + /* set initial parser result - used for all engines */
40094 + for (i = 0; i < FM_PORT_PRS_RESULT_NUM_OF_WORDS; i++)
40095 + {
40096 + if (!i)
40097 + WRITE_UINT32(
40098 + *(p_BmiInitPrsResult),
40099 + (uint32_t)(((uint32_t)p_FmPort->privateInfo << BMI_PR_PORTID_SHIFT) | BMI_PRS_RESULT_HIGH));
40100 + else
40101 + {
40102 + if (i < FM_PORT_PRS_RESULT_NUM_OF_WORDS / 2)
40103 + WRITE_UINT32(*(p_BmiInitPrsResult+i), BMI_PRS_RESULT_HIGH);
40104 + else
40105 + WRITE_UINT32(*(p_BmiInitPrsResult+i), BMI_PRS_RESULT_LOW);
40106 + }
40107 + }
40108 +
40109 + return E_OK;
40110 +}
40111 +
40112 +static t_Error DeletePcd(t_FmPort *p_FmPort)
40113 +{
40114 + t_Error err = E_OK;
40115 + volatile uint32_t *p_BmiNia = NULL;
40116 + volatile uint32_t *p_BmiPrsStartOffset = NULL;
40117 +
40118 + ASSERT_COND(p_FmPort);
40119 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
40120 +
40121 + if (p_FmPort->imEn)
40122 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
40123 + ("available for non-independant mode ports only"));
40124 +
40125 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
40126 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
40127 + && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
40128 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
40129 + ("available for Rx and offline parsing ports only"));
40130 +
40131 + if (!p_FmPort->pcdEngines)
40132 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("called for non PCD port"));
40133 +
40134 + /* get PCD registers pointers */
40135 + switch (p_FmPort->portType)
40136 + {
40137 + case (e_FM_PORT_TYPE_RX_10G):
40138 + case (e_FM_PORT_TYPE_RX):
40139 + p_BmiNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfne;
40140 + p_BmiPrsStartOffset = &p_FmPort->port.bmi_regs->rx.fmbm_rpso;
40141 + break;
40142 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
40143 + p_BmiNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofne;
40144 + p_BmiPrsStartOffset = &p_FmPort->port.bmi_regs->oh.fmbm_opso;
40145 + break;
40146 + default:
40147 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
40148 + }
40149 +
40150 + if ((GET_UINT32(*p_BmiNia) & GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME())
40151 + != GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME())
40152 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
40153 + ("port has to be detached previousely"));
40154 +
40155 + WRITE_UINT32(*p_BmiPrsStartOffset, 0);
40156 +
40157 + /* "cut" PCD out of the port's flow - go to BMI */
40158 + /* WRITE_UINT32(*p_BmiNia, (p_FmPort->savedBmiNia & BMI_RFNE_FDCS_MASK) | (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)); */
40159 +
40160 + if (p_FmPort->pcdEngines & FM_PCD_PRS)
40161 + {
40162 + /* stop parser */
40163 + WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->pcac, PRS_CAC_STOP);
40164 + /* wait for parser to be in idle state */
40165 + while (GET_UINT32(p_FmPort->p_FmPortPrsRegs->pcac) & PRS_CAC_ACTIVE)
40166 + ;
40167 + }
40168 +
40169 + if (p_FmPort->pcdEngines & FM_PCD_KG)
40170 + {
40171 + t_FmPcdKgInterModuleBindPortToSchemes schemeBind;
40172 +
40173 + /* unbind all schemes */
40174 + p_FmPort->schemesPerPortVector = GetPortSchemeBindParams(p_FmPort,
40175 + &schemeBind);
40176 +
40177 + err = FmPcdKgUnbindPortToSchemes(p_FmPort->h_FmPcd, &schemeBind);
40178 + if (err)
40179 + RETURN_ERROR(MAJOR, err, NO_MSG);
40180 +
40181 + err = FmPcdKgDeleteOrUnbindPortToClsPlanGrp(p_FmPort->h_FmPcd,
40182 + p_FmPort->hardwarePortId,
40183 + p_FmPort->clsPlanGrpId);
40184 + if (err)
40185 + RETURN_ERROR(MAJOR, err, NO_MSG);
40186 + p_FmPort->useClsPlan = FALSE;
40187 + }
40188 +
40189 + if (p_FmPort->pcdEngines & FM_PCD_CC)
40190 + {
40191 + /* unbind - we need to get the treeId too */
40192 + err = FmPcdCcUnbindTree(p_FmPort->h_FmPcd, p_FmPort->ccTreeId);
40193 + if (err)
40194 + RETURN_ERROR(MAJOR, err, NO_MSG);
40195 + }
40196 +
40197 + p_FmPort->pcdEngines = 0;
40198 +
40199 + return E_OK;
40200 +}
40201 +
40202 +static t_Error AttachPCD(t_FmPort *p_FmPort)
40203 +{
40204 + volatile uint32_t *p_BmiNia = NULL;
40205 +
40206 + ASSERT_COND(p_FmPort);
40207 +
40208 + /* get PCD registers pointers */
40209 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
40210 + p_BmiNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofne;
40211 + else
40212 + p_BmiNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfne;
40213 +
40214 + /* check that current NIA is BMI to BMI */
40215 + if ((GET_UINT32(*p_BmiNia) & ~BMI_RFNE_FDCS_MASK)
40216 + != GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME())
40217 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
40218 + ("may be called only for ports in BMI-to-BMI state."));
40219 +
40220 + if (p_FmPort->requiredAction & UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY)
40221 + if (FmSetNumOfRiscsPerPort(p_FmPort->h_Fm, p_FmPort->hardwarePortId, 1,
40222 + p_FmPort->orFmanCtrl) != E_OK)
40223 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
40224 +
40225 + if (p_FmPort->requiredAction & UPDATE_NIA_CMNE)
40226 + {
40227 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
40228 + WRITE_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ocmne,
40229 + p_FmPort->savedBmiCmne);
40230 + else
40231 + WRITE_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rcmne,
40232 + p_FmPort->savedBmiCmne);
40233 + }
40234 +
40235 + if (p_FmPort->requiredAction & UPDATE_NIA_PNEN)
40236 + WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnen,
40237 + p_FmPort->savedQmiPnen);
40238 +
40239 + if (p_FmPort->requiredAction & UPDATE_NIA_FENE)
40240 + {
40241 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
40242 + WRITE_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ofene,
40243 + p_FmPort->savedBmiFene);
40244 + else
40245 + WRITE_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rfene,
40246 + p_FmPort->savedBmiFene);
40247 + }
40248 +
40249 + if (p_FmPort->requiredAction & UPDATE_NIA_FPNE)
40250 + {
40251 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
40252 + WRITE_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ofpne,
40253 + p_FmPort->savedBmiFpne);
40254 + else
40255 + WRITE_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rfpne,
40256 + p_FmPort->savedBmiFpne);
40257 + }
40258 +
40259 + if (p_FmPort->requiredAction & UPDATE_OFP_DPTE)
40260 + {
40261 + ASSERT_COND(p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING);
40262 +
40263 + WRITE_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ofp,
40264 + p_FmPort->savedBmiOfp);
40265 + }
40266 +
40267 + WRITE_UINT32(*p_BmiNia, p_FmPort->savedBmiNia);
40268 +
40269 + if (p_FmPort->requiredAction & UPDATE_NIA_PNDN)
40270 + {
40271 + p_FmPort->origNonRxQmiRegsPndn =
40272 + GET_UINT32(p_FmPort->port.qmi_regs->fmqm_pndn);
40273 + WRITE_UINT32(p_FmPort->port.qmi_regs->fmqm_pndn,
40274 + p_FmPort->savedNonRxQmiRegsPndn);
40275 + }
40276 +
40277 + return E_OK;
40278 +}
40279 +
40280 +static t_Error DetachPCD(t_FmPort *p_FmPort)
40281 +{
40282 + volatile uint32_t *p_BmiNia = NULL;
40283 +
40284 + ASSERT_COND(p_FmPort);
40285 +
40286 + /* get PCD registers pointers */
40287 + if (p_FmPort->requiredAction & UPDATE_NIA_PNDN)
40288 + WRITE_UINT32(p_FmPort->port.qmi_regs->fmqm_pndn,
40289 + p_FmPort->origNonRxQmiRegsPndn);
40290 +
40291 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
40292 + p_BmiNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofne;
40293 + else
40294 + p_BmiNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfne;
40295 +
40296 + WRITE_UINT32(
40297 + *p_BmiNia,
40298 + (p_FmPort->savedBmiNia & BMI_RFNE_FDCS_MASK) | GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME());
40299 +
40300 + if (FmPcdGetHcHandle(p_FmPort->h_FmPcd))
40301 + FmPcdHcSync(p_FmPort->h_FmPcd);
40302 +
40303 + if (p_FmPort->requiredAction & UPDATE_NIA_FENE)
40304 + {
40305 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
40306 + WRITE_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ofene,
40307 + NIA_ENG_QMI_ENQ | NIA_ORDER_RESTOR);
40308 + else
40309 + WRITE_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rfene,
40310 + NIA_ENG_QMI_ENQ | NIA_ORDER_RESTOR);
40311 + }
40312 +
40313 + if (p_FmPort->requiredAction & UPDATE_NIA_PNEN)
40314 + WRITE_UINT32(p_FmPort->port.qmi_regs->fmqm_pnen,
40315 + NIA_ENG_BMI | NIA_BMI_AC_RELEASE);
40316 +
40317 + if (p_FmPort->requiredAction & UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY)
40318 + if (FmSetNumOfRiscsPerPort(p_FmPort->h_Fm, p_FmPort->hardwarePortId, 2,
40319 + p_FmPort->orFmanCtrl) != E_OK)
40320 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
40321 +
40322 + p_FmPort->requiredAction = 0;
40323 +
40324 + return E_OK;
40325 +}
40326 +
40327 +/*****************************************************************************/
40328 +/* Inter-module API routines */
40329 +/*****************************************************************************/
40330 +void FmPortSetMacsecCmd(t_Handle h_FmPort, uint8_t dfltSci)
40331 +{
40332 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
40333 + volatile uint32_t *p_BmiCfgReg = NULL;
40334 + uint32_t tmpReg;
40335 +
40336 + SANITY_CHECK_RETURN(p_FmPort, E_INVALID_HANDLE);
40337 + SANITY_CHECK_RETURN(p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
40338 +
40339 + if ((p_FmPort->portType != e_FM_PORT_TYPE_TX_10G)
40340 + && (p_FmPort->portType != e_FM_PORT_TYPE_TX))
40341 + {
40342 + REPORT_ERROR(MAJOR, E_INVALID_OPERATION, ("The routine is relevant for Tx ports only"));
40343 + return;
40344 + }
40345 +
40346 + p_BmiCfgReg = &p_FmPort->port.bmi_regs->tx.fmbm_tfca;
40347 + tmpReg = GET_UINT32(*p_BmiCfgReg) & ~BMI_CMD_ATTR_MACCMD_MASK;
40348 + tmpReg |= BMI_CMD_ATTR_MACCMD_SECURED;
40349 + tmpReg |= (((uint32_t)dfltSci << BMI_CMD_ATTR_MACCMD_SC_SHIFT)
40350 + & BMI_CMD_ATTR_MACCMD_SC_MASK);
40351 +
40352 + WRITE_UINT32(*p_BmiCfgReg, tmpReg);
40353 +}
40354 +
40355 +uint8_t FmPortGetNetEnvId(t_Handle h_FmPort)
40356 +{
40357 + return ((t_FmPort*)h_FmPort)->netEnvId;
40358 +}
40359 +
40360 +uint8_t FmPortGetHardwarePortId(t_Handle h_FmPort)
40361 +{
40362 + return ((t_FmPort*)h_FmPort)->hardwarePortId;
40363 +}
40364 +
40365 +uint32_t FmPortGetPcdEngines(t_Handle h_FmPort)
40366 +{
40367 + return ((t_FmPort*)h_FmPort)->pcdEngines;
40368 +}
40369 +
40370 +#if (DPAA_VERSION >= 11)
40371 +t_Error FmPortSetGprFunc(t_Handle h_FmPort, e_FmPortGprFuncType gprFunc,
40372 + void **p_Value)
40373 +{
40374 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
40375 + uint32_t muramPageOffset;
40376 +
40377 + ASSERT_COND(p_FmPort);
40378 + ASSERT_COND(p_Value);
40379 +
40380 + if (p_FmPort->gprFunc != e_FM_PORT_GPR_EMPTY)
40381 + {
40382 + if (p_FmPort->gprFunc != gprFunc)
40383 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
40384 + ("gpr was assigned with different func"));
40385 + }
40386 + else
40387 + {
40388 + switch (gprFunc)
40389 + {
40390 + case (e_FM_PORT_GPR_MURAM_PAGE):
40391 + p_FmPort->p_ParamsPage = FM_MURAM_AllocMem(p_FmPort->h_FmMuram,
40392 + 256, 8);
40393 + if (!p_FmPort->p_ParamsPage)
40394 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for page"));
40395 +
40396 + IOMemSet32(p_FmPort->p_ParamsPage, 0, 256);
40397 + muramPageOffset =
40398 + (uint32_t)(XX_VirtToPhys(p_FmPort->p_ParamsPage)
40399 + - p_FmPort->fmMuramPhysBaseAddr);
40400 + switch (p_FmPort->portType)
40401 + {
40402 + case (e_FM_PORT_TYPE_RX_10G):
40403 + case (e_FM_PORT_TYPE_RX):
40404 + WRITE_UINT32(
40405 + p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rgpr,
40406 + muramPageOffset);
40407 + break;
40408 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
40409 + WRITE_UINT32(
40410 + p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ogpr,
40411 + muramPageOffset);
40412 + break;
40413 + default:
40414 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
40415 + ("Invalid port type"));
40416 + }
40417 + break;
40418 + default:
40419 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
40420 + }
40421 + p_FmPort->gprFunc = gprFunc;
40422 + }
40423 +
40424 + switch (p_FmPort->gprFunc)
40425 + {
40426 + case (e_FM_PORT_GPR_MURAM_PAGE):
40427 + *p_Value = p_FmPort->p_ParamsPage;
40428 + break;
40429 + default:
40430 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
40431 + }
40432 +
40433 + return E_OK;
40434 +}
40435 +#endif /* (DPAA_VERSION >= 11) */
40436 +
40437 +t_Error FmPortGetSetCcParams(t_Handle h_FmPort,
40438 + t_FmPortGetSetCcParams *p_CcParams)
40439 +{
40440 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
40441 + int tmpInt;
40442 + volatile uint32_t *p_BmiPrsStartOffset = NULL;
40443 +
40444 + /* this function called from Cc for pass and receive parameters port params between CC and PORT*/
40445 +
40446 + if ((p_CcParams->getCcParams.type & OFFSET_OF_PR)
40447 + && (p_FmPort->bufferOffsets.prsResultOffset != ILLEGAL_BASE))
40448 + {
40449 + p_CcParams->getCcParams.prOffset =
40450 + (uint8_t)p_FmPort->bufferOffsets.prsResultOffset;
40451 + p_CcParams->getCcParams.type &= ~OFFSET_OF_PR;
40452 + }
40453 + if (p_CcParams->getCcParams.type & HW_PORT_ID)
40454 + {
40455 + p_CcParams->getCcParams.hardwarePortId =
40456 + (uint8_t)p_FmPort->hardwarePortId;
40457 + p_CcParams->getCcParams.type &= ~HW_PORT_ID;
40458 + }
40459 + if ((p_CcParams->getCcParams.type & OFFSET_OF_DATA)
40460 + && (p_FmPort->bufferOffsets.dataOffset != ILLEGAL_BASE))
40461 + {
40462 + p_CcParams->getCcParams.dataOffset =
40463 + (uint16_t)p_FmPort->bufferOffsets.dataOffset;
40464 + p_CcParams->getCcParams.type &= ~OFFSET_OF_DATA;
40465 + }
40466 + if (p_CcParams->getCcParams.type & NUM_OF_TASKS)
40467 + {
40468 + p_CcParams->getCcParams.numOfTasks = (uint8_t)p_FmPort->tasks.num;
40469 + p_CcParams->getCcParams.type &= ~NUM_OF_TASKS;
40470 + }
40471 + if (p_CcParams->getCcParams.type & NUM_OF_EXTRA_TASKS)
40472 + {
40473 + p_CcParams->getCcParams.numOfExtraTasks =
40474 + (uint8_t)p_FmPort->tasks.extra;
40475 + p_CcParams->getCcParams.type &= ~NUM_OF_EXTRA_TASKS;
40476 + }
40477 + if (p_CcParams->getCcParams.type & FM_REV)
40478 + {
40479 + p_CcParams->getCcParams.revInfo.majorRev = p_FmPort->fmRevInfo.majorRev;
40480 + p_CcParams->getCcParams.revInfo.minorRev = p_FmPort->fmRevInfo.minorRev;
40481 + p_CcParams->getCcParams.type &= ~FM_REV;
40482 + }
40483 + if (p_CcParams->getCcParams.type & DISCARD_MASK)
40484 + {
40485 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
40486 + p_CcParams->getCcParams.discardMask =
40487 + GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsdm);
40488 + else
40489 + p_CcParams->getCcParams.discardMask =
40490 + GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfsdm);
40491 + p_CcParams->getCcParams.type &= ~DISCARD_MASK;
40492 + }
40493 + if (p_CcParams->getCcParams.type & MANIP_EXTRA_SPACE)
40494 + {
40495 + p_CcParams->getCcParams.internalBufferOffset =
40496 + p_FmPort->internalBufferOffset;
40497 + p_CcParams->getCcParams.type &= ~MANIP_EXTRA_SPACE;
40498 + }
40499 + if (p_CcParams->getCcParams.type & GET_NIA_FPNE)
40500 + {
40501 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
40502 + p_CcParams->getCcParams.nia =
40503 + GET_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ofpne);
40504 + else
40505 + p_CcParams->getCcParams.nia =
40506 + GET_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rfpne);
40507 + p_CcParams->getCcParams.type &= ~GET_NIA_FPNE;
40508 + }
40509 + if (p_CcParams->getCcParams.type & GET_NIA_PNDN)
40510 + {
40511 + if (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
40512 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
40513 + p_CcParams->getCcParams.nia =
40514 + GET_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndn);
40515 + p_CcParams->getCcParams.type &= ~GET_NIA_PNDN;
40516 + }
40517 +
40518 + if ((p_CcParams->setCcParams.type & UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY)
40519 + && !(p_FmPort->requiredAction & UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY))
40520 + {
40521 + p_FmPort->requiredAction |= UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY;
40522 + p_FmPort->orFmanCtrl = p_CcParams->setCcParams.orFmanCtrl;
40523 + }
40524 +
40525 + if ((p_CcParams->setCcParams.type & UPDATE_NIA_PNEN)
40526 + && !(p_FmPort->requiredAction & UPDATE_NIA_PNEN))
40527 + {
40528 + p_FmPort->savedQmiPnen = p_CcParams->setCcParams.nia;
40529 + p_FmPort->requiredAction |= UPDATE_NIA_PNEN;
40530 + }
40531 + else
40532 + if (p_CcParams->setCcParams.type & UPDATE_NIA_PNEN)
40533 + {
40534 + if (p_FmPort->savedQmiPnen != p_CcParams->setCcParams.nia)
40535 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
40536 + ("PNEN was defined previously different"));
40537 + }
40538 +
40539 + if ((p_CcParams->setCcParams.type & UPDATE_NIA_PNDN)
40540 + && !(p_FmPort->requiredAction & UPDATE_NIA_PNDN))
40541 + {
40542 + p_FmPort->savedNonRxQmiRegsPndn = p_CcParams->setCcParams.nia;
40543 + p_FmPort->requiredAction |= UPDATE_NIA_PNDN;
40544 + }
40545 + else
40546 + if (p_CcParams->setCcParams.type & UPDATE_NIA_PNDN)
40547 + {
40548 + if (p_FmPort->savedNonRxQmiRegsPndn != p_CcParams->setCcParams.nia)
40549 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
40550 + ("PNDN was defined previously different"));
40551 + }
40552 +
40553 + if ((p_CcParams->setCcParams.type & UPDATE_NIA_FENE)
40554 + && (p_CcParams->setCcParams.overwrite
40555 + || !(p_FmPort->requiredAction & UPDATE_NIA_FENE)))
40556 + {
40557 + p_FmPort->savedBmiFene = p_CcParams->setCcParams.nia;
40558 + p_FmPort->requiredAction |= UPDATE_NIA_FENE;
40559 + }
40560 + else
40561 + if (p_CcParams->setCcParams.type & UPDATE_NIA_FENE)
40562 + {
40563 + if (p_FmPort->savedBmiFene != p_CcParams->setCcParams.nia)
40564 + RETURN_ERROR( MAJOR, E_INVALID_STATE,
40565 + ("xFENE was defined previously different"));
40566 + }
40567 +
40568 + if ((p_CcParams->setCcParams.type & UPDATE_NIA_FPNE)
40569 + && !(p_FmPort->requiredAction & UPDATE_NIA_FPNE))
40570 + {
40571 + p_FmPort->savedBmiFpne = p_CcParams->setCcParams.nia;
40572 + p_FmPort->requiredAction |= UPDATE_NIA_FPNE;
40573 + }
40574 + else
40575 + if (p_CcParams->setCcParams.type & UPDATE_NIA_FPNE)
40576 + {
40577 + if (p_FmPort->savedBmiFpne != p_CcParams->setCcParams.nia)
40578 + RETURN_ERROR( MAJOR, E_INVALID_STATE,
40579 + ("xFPNE was defined previously different"));
40580 + }
40581 +
40582 + if ((p_CcParams->setCcParams.type & UPDATE_NIA_CMNE)
40583 + && !(p_FmPort->requiredAction & UPDATE_NIA_CMNE))
40584 + {
40585 + p_FmPort->savedBmiCmne = p_CcParams->setCcParams.nia;
40586 + p_FmPort->requiredAction |= UPDATE_NIA_CMNE;
40587 + }
40588 + else
40589 + if (p_CcParams->setCcParams.type & UPDATE_NIA_CMNE)
40590 + {
40591 + if (p_FmPort->savedBmiCmne != p_CcParams->setCcParams.nia)
40592 + RETURN_ERROR( MAJOR, E_INVALID_STATE,
40593 + ("xCMNE was defined previously different"));
40594 + }
40595 +
40596 + if ((p_CcParams->setCcParams.type & UPDATE_PSO)
40597 + && !(p_FmPort->requiredAction & UPDATE_PSO))
40598 + {
40599 + /* get PCD registers pointers */
40600 + switch (p_FmPort->portType)
40601 + {
40602 + case (e_FM_PORT_TYPE_RX_10G):
40603 + case (e_FM_PORT_TYPE_RX):
40604 + p_BmiPrsStartOffset = &p_FmPort->port.bmi_regs->rx.fmbm_rpso;
40605 + break;
40606 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
40607 + p_BmiPrsStartOffset = &p_FmPort->port.bmi_regs->oh.fmbm_opso;
40608 + break;
40609 + default:
40610 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
40611 + }
40612 +
40613 + /* set start parsing offset */
40614 + tmpInt = (int)GET_UINT32(*p_BmiPrsStartOffset)
40615 + + p_CcParams->setCcParams.psoSize;
40616 + if (tmpInt > 0)
40617 + WRITE_UINT32(*p_BmiPrsStartOffset, (uint32_t)tmpInt);
40618 +
40619 + p_FmPort->requiredAction |= UPDATE_PSO;
40620 + p_FmPort->savedPrsStartOffset = p_CcParams->setCcParams.psoSize;
40621 + }
40622 + else
40623 + if (p_CcParams->setCcParams.type & UPDATE_PSO)
40624 + {
40625 + if (p_FmPort->savedPrsStartOffset
40626 + != p_CcParams->setCcParams.psoSize)
40627 + RETURN_ERROR(
40628 + MAJOR,
40629 + E_INVALID_STATE,
40630 + ("parser start offset was defoned previousley different"));
40631 + }
40632 +
40633 + if ((p_CcParams->setCcParams.type & UPDATE_OFP_DPTE)
40634 + && !(p_FmPort->requiredAction & UPDATE_OFP_DPTE))
40635 + {
40636 + if (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
40637 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
40638 + p_FmPort->savedBmiOfp = GET_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ofp);
40639 + p_FmPort->savedBmiOfp &= ~BMI_FIFO_PIPELINE_DEPTH_MASK;
40640 + p_FmPort->savedBmiOfp |= p_CcParams->setCcParams.ofpDpde
40641 + << BMI_FIFO_PIPELINE_DEPTH_SHIFT;
40642 + p_FmPort->requiredAction |= UPDATE_OFP_DPTE;
40643 + }
40644 +
40645 + return E_OK;
40646 +}
40647 +/*********************** End of inter-module routines ************************/
40648 +
40649 +/****************************************/
40650 +/* API Init unit functions */
40651 +/****************************************/
40652 +
40653 +t_Handle FM_PORT_Config(t_FmPortParams *p_FmPortParams)
40654 +{
40655 + t_FmPort *p_FmPort;
40656 + uintptr_t baseAddr = p_FmPortParams->baseAddr;
40657 + uint32_t tmpReg;
40658 +
40659 + /* Allocate FM structure */
40660 + p_FmPort = (t_FmPort *)XX_Malloc(sizeof(t_FmPort));
40661 + if (!p_FmPort)
40662 + {
40663 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Port driver structure"));
40664 + return NULL;
40665 + }
40666 + memset(p_FmPort, 0, sizeof(t_FmPort));
40667 +
40668 + /* Allocate the FM driver's parameters structure */
40669 + p_FmPort->p_FmPortDriverParam = (t_FmPortDriverParam *)XX_Malloc(
40670 + sizeof(t_FmPortDriverParam));
40671 + if (!p_FmPort->p_FmPortDriverParam)
40672 + {
40673 + XX_Free(p_FmPort);
40674 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Port driver parameters"));
40675 + return NULL;
40676 + }
40677 + memset(p_FmPort->p_FmPortDriverParam, 0, sizeof(t_FmPortDriverParam));
40678 +
40679 + /* Initialize FM port parameters which will be kept by the driver */
40680 + p_FmPort->portType = p_FmPortParams->portType;
40681 + p_FmPort->portId = p_FmPortParams->portId;
40682 + p_FmPort->pcdEngines = FM_PCD_NONE;
40683 + p_FmPort->f_Exception = p_FmPortParams->f_Exception;
40684 + p_FmPort->h_App = p_FmPortParams->h_App;
40685 + p_FmPort->h_Fm = p_FmPortParams->h_Fm;
40686 +
40687 + /* get FM revision */
40688 + FM_GetRevision(p_FmPort->h_Fm, &p_FmPort->fmRevInfo);
40689 +
40690 + /* calculate global portId number */
40691 + p_FmPort->hardwarePortId = SwPortIdToHwPortId(p_FmPort->portType,
40692 + p_FmPortParams->portId,
40693 + p_FmPort->fmRevInfo.majorRev,
40694 + p_FmPort->fmRevInfo.minorRev);
40695 +
40696 + if (p_FmPort->fmRevInfo.majorRev >= 6)
40697 + {
40698 + if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
40699 + && (p_FmPortParams->portId != FM_OH_PORT_ID))
40700 + DBG(WARNING,
40701 + ("Port ID %d is recommended for HC port. Overwriting HW defaults to be suitable for HC.",
40702 + FM_OH_PORT_ID));
40703 +
40704 + if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
40705 + && (p_FmPortParams->portId == FM_OH_PORT_ID))
40706 + DBG(WARNING, ("Use non-zero portId for OP port due to insufficient resources on portId 0."));
40707 + }
40708 +
40709 + /* Set up FM port parameters for initialization phase only */
40710 +
40711 + /* First, fill in flibs struct */
40712 + fman_port_defconfig(&p_FmPort->p_FmPortDriverParam->dfltCfg,
40713 + (enum fman_port_type)p_FmPort->portType);
40714 + /* Overwrite some integration specific parameters */
40715 + p_FmPort->p_FmPortDriverParam->dfltCfg.rx_pri_elevation =
40716 + DEFAULT_PORT_rxFifoPriElevationLevel;
40717 + p_FmPort->p_FmPortDriverParam->dfltCfg.rx_fifo_thr =
40718 + DEFAULT_PORT_rxFifoThreshold;
40719 +
40720 +#if defined(FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675) || defined(FM_ERROR_VSP_NO_MATCH_SW006)
40721 + p_FmPort->p_FmPortDriverParam->dfltCfg.errata_A006675 = TRUE;
40722 +#else
40723 + p_FmPort->p_FmPortDriverParam->dfltCfg.errata_A006675 = FALSE;
40724 +#endif
40725 + if ((p_FmPort->fmRevInfo.majorRev == 6)
40726 + && (p_FmPort->fmRevInfo.minorRev == 0))
40727 + p_FmPort->p_FmPortDriverParam->dfltCfg.errata_A006320 = TRUE;
40728 + else
40729 + p_FmPort->p_FmPortDriverParam->dfltCfg.errata_A006320 = FALSE;
40730 +
40731 + /* Excessive Threshold register - exists for pre-FMv3 chips only */
40732 + if (p_FmPort->fmRevInfo.majorRev < 6)
40733 + {
40734 +#ifdef FM_NO_RESTRICT_ON_ACCESS_RSRC
40735 + p_FmPort->p_FmPortDriverParam->dfltCfg.excessive_threshold_register =
40736 + TRUE;
40737 +#endif
40738 + p_FmPort->p_FmPortDriverParam->dfltCfg.fmbm_rebm_has_sgd = FALSE;
40739 + p_FmPort->p_FmPortDriverParam->dfltCfg.fmbm_tfne_has_features = FALSE;
40740 + }
40741 + else
40742 + {
40743 + p_FmPort->p_FmPortDriverParam->dfltCfg.excessive_threshold_register =
40744 + FALSE;
40745 + p_FmPort->p_FmPortDriverParam->dfltCfg.fmbm_rebm_has_sgd = TRUE;
40746 + p_FmPort->p_FmPortDriverParam->dfltCfg.fmbm_tfne_has_features = TRUE;
40747 + }
40748 + if (p_FmPort->fmRevInfo.majorRev == 4)
40749 + p_FmPort->p_FmPortDriverParam->dfltCfg.qmi_deq_options_support = FALSE;
40750 + else
40751 + p_FmPort->p_FmPortDriverParam->dfltCfg.qmi_deq_options_support = TRUE;
40752 +
40753 + /* Continue with other parameters */
40754 + p_FmPort->p_FmPortDriverParam->baseAddr = baseAddr;
40755 + /* set memory map pointers */
40756 + p_FmPort->p_FmPortQmiRegs =
40757 + (t_FmPortQmiRegs *)UINT_TO_PTR(baseAddr + QMI_PORT_REGS_OFFSET);
40758 + p_FmPort->p_FmPortBmiRegs =
40759 + (u_FmPortBmiRegs *)UINT_TO_PTR(baseAddr + BMI_PORT_REGS_OFFSET);
40760 + p_FmPort->p_FmPortPrsRegs =
40761 + (t_FmPortPrsRegs *)UINT_TO_PTR(baseAddr + PRS_PORT_REGS_OFFSET);
40762 +
40763 + p_FmPort->p_FmPortDriverParam->bufferPrefixContent.privDataSize =
40764 + DEFAULT_PORT_bufferPrefixContent_privDataSize;
40765 + p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passPrsResult =
40766 + DEFAULT_PORT_bufferPrefixContent_passPrsResult;
40767 + p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passTimeStamp =
40768 + DEFAULT_PORT_bufferPrefixContent_passTimeStamp;
40769 + p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passAllOtherPCDInfo =
40770 + DEFAULT_PORT_bufferPrefixContent_passTimeStamp;
40771 + p_FmPort->p_FmPortDriverParam->bufferPrefixContent.dataAlign =
40772 + DEFAULT_PORT_bufferPrefixContent_dataAlign;
40773 + /* p_FmPort->p_FmPortDriverParam->dmaSwapData = (e_FmDmaSwapOption)DEFAULT_PORT_dmaSwapData;
40774 + p_FmPort->p_FmPortDriverParam->dmaIntContextCacheAttr = (e_FmDmaCacheOption)DEFAULT_PORT_dmaIntContextCacheAttr;
40775 + p_FmPort->p_FmPortDriverParam->dmaHeaderCacheAttr = (e_FmDmaCacheOption)DEFAULT_PORT_dmaHeaderCacheAttr;
40776 + p_FmPort->p_FmPortDriverParam->dmaScatterGatherCacheAttr = (e_FmDmaCacheOption)DEFAULT_PORT_dmaScatterGatherCacheAttr;
40777 + p_FmPort->p_FmPortDriverParam->dmaWriteOptimize = DEFAULT_PORT_dmaWriteOptimize;
40778 + */
40779 + p_FmPort->p_FmPortDriverParam->liodnBase = p_FmPortParams->liodnBase;
40780 + p_FmPort->p_FmPortDriverParam->cheksumLastBytesIgnore =
40781 + DEFAULT_PORT_cheksumLastBytesIgnore;
40782 +
40783 + p_FmPort->maxFrameLength = DEFAULT_PORT_maxFrameLength;
40784 + /* resource distribution. */
40785 + p_FmPort->fifoBufs.num = DEFAULT_PORT_numOfFifoBufs(p_FmPort->portType)
40786 + * BMI_FIFO_UNITS;
40787 + p_FmPort->fifoBufs.extra = DEFAULT_PORT_extraNumOfFifoBufs
40788 + * BMI_FIFO_UNITS;
40789 + p_FmPort->openDmas.num = DEFAULT_PORT_numOfOpenDmas(p_FmPort->portType);
40790 + p_FmPort->openDmas.extra =
40791 + DEFAULT_PORT_extraNumOfOpenDmas(p_FmPort->portType);
40792 + p_FmPort->tasks.num = DEFAULT_PORT_numOfTasks(p_FmPort->portType);
40793 + p_FmPort->tasks.extra = DEFAULT_PORT_extraNumOfTasks(p_FmPort->portType);
40794 +
40795 +
40796 +#ifdef FM_HEAVY_TRAFFIC_SEQUENCER_HANG_ERRATA_FMAN_A006981
40797 + if ((p_FmPort->fmRevInfo.majorRev == 6)
40798 + && (p_FmPort->fmRevInfo.minorRev == 0)
40799 + && ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
40800 + || (p_FmPort->portType == e_FM_PORT_TYPE_TX)))
40801 + {
40802 + p_FmPort->openDmas.num = 16;
40803 + p_FmPort->openDmas.extra = 0;
40804 + }
40805 +#endif /* FM_HEAVY_TRAFFIC_SEQUENCER_HANG_ERRATA_FMAN_A006981 */
40806 +
40807 + /* Port type specific initialization: */
40808 + switch (p_FmPort->portType)
40809 + {
40810 + case (e_FM_PORT_TYPE_RX):
40811 + case (e_FM_PORT_TYPE_RX_10G):
40812 + /* Initialize FM port parameters for initialization phase only */
40813 + p_FmPort->p_FmPortDriverParam->cutBytesFromEnd =
40814 + DEFAULT_PORT_cutBytesFromEnd;
40815 + p_FmPort->p_FmPortDriverParam->enBufPoolDepletion = FALSE;
40816 + p_FmPort->p_FmPortDriverParam->frmDiscardOverride =
40817 + DEFAULT_PORT_frmDiscardOverride;
40818 +
40819 + tmpReg =
40820 + GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfp);
40821 + p_FmPort->p_FmPortDriverParam->rxFifoPriElevationLevel =
40822 + (((tmpReg & BMI_RX_FIFO_PRI_ELEVATION_MASK)
40823 + >> BMI_RX_FIFO_PRI_ELEVATION_SHIFT) + 1)
40824 + * BMI_FIFO_UNITS;
40825 + p_FmPort->p_FmPortDriverParam->rxFifoThreshold = (((tmpReg
40826 + & BMI_RX_FIFO_THRESHOLD_MASK)
40827 + >> BMI_RX_FIFO_THRESHOLD_SHIFT) + 1) * BMI_FIFO_UNITS;
40828 +
40829 + p_FmPort->p_FmPortDriverParam->bufMargins.endMargins =
40830 + DEFAULT_PORT_BufMargins_endMargins;
40831 + p_FmPort->p_FmPortDriverParam->errorsToDiscard =
40832 + DEFAULT_PORT_errorsToDiscard;
40833 + p_FmPort->p_FmPortDriverParam->forwardReuseIntContext =
40834 + DEFAULT_PORT_forwardIntContextReuse;
40835 +#if (DPAA_VERSION >= 11)
40836 + p_FmPort->p_FmPortDriverParam->noScatherGather =
40837 + DEFAULT_PORT_noScatherGather;
40838 +#endif /* (DPAA_VERSION >= 11) */
40839 + break;
40840 +
40841 + case (e_FM_PORT_TYPE_TX):
40842 + p_FmPort->p_FmPortDriverParam->dontReleaseBuf = FALSE;
40843 +#ifdef FM_WRONG_RESET_VALUES_ERRATA_FMAN_A005127
40844 + tmpReg = 0x00001013;
40845 + WRITE_UINT32( p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tfp,
40846 + tmpReg);
40847 +#endif /* FM_WRONG_RESET_VALUES_ERRATA_FMAN_A005127 */
40848 + case (e_FM_PORT_TYPE_TX_10G):
40849 + tmpReg =
40850 + GET_UINT32(p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tfp);
40851 + p_FmPort->p_FmPortDriverParam->txFifoMinFillLevel = ((tmpReg
40852 + & BMI_TX_FIFO_MIN_FILL_MASK)
40853 + >> BMI_TX_FIFO_MIN_FILL_SHIFT) * BMI_FIFO_UNITS;
40854 + p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth =
40855 + (uint8_t)(((tmpReg & BMI_FIFO_PIPELINE_DEPTH_MASK)
40856 + >> BMI_FIFO_PIPELINE_DEPTH_SHIFT) + 1);
40857 + p_FmPort->p_FmPortDriverParam->txFifoLowComfLevel = (((tmpReg
40858 + & BMI_TX_LOW_COMF_MASK) >> BMI_TX_LOW_COMF_SHIFT) + 1)
40859 + * BMI_FIFO_UNITS;
40860 +
40861 + p_FmPort->p_FmPortDriverParam->deqType = DEFAULT_PORT_deqType;
40862 + p_FmPort->p_FmPortDriverParam->deqPrefetchOption =
40863 + DEFAULT_PORT_deqPrefetchOption;
40864 + p_FmPort->p_FmPortDriverParam->deqHighPriority =
40865 + (bool)((p_FmPort->portType == e_FM_PORT_TYPE_TX) ? DEFAULT_PORT_deqHighPriority_1G :
40866 + DEFAULT_PORT_deqHighPriority_10G);
40867 + p_FmPort->p_FmPortDriverParam->deqByteCnt =
40868 + (uint16_t)(
40869 + (p_FmPort->portType == e_FM_PORT_TYPE_TX) ? DEFAULT_PORT_deqByteCnt_1G :
40870 + DEFAULT_PORT_deqByteCnt_10G);
40871 + break;
40872 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
40873 + p_FmPort->p_FmPortDriverParam->errorsToDiscard =
40874 + DEFAULT_PORT_errorsToDiscard;
40875 +#if (DPAA_VERSION >= 11)
40876 + p_FmPort->p_FmPortDriverParam->noScatherGather =
40877 + DEFAULT_PORT_noScatherGather;
40878 +#endif /* (DPAA_VERSION >= 11) */
40879 + case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
40880 + p_FmPort->p_FmPortDriverParam->deqPrefetchOption =
40881 + DEFAULT_PORT_deqPrefetchOption_HC;
40882 + p_FmPort->p_FmPortDriverParam->deqHighPriority =
40883 + DEFAULT_PORT_deqHighPriority_1G;
40884 + p_FmPort->p_FmPortDriverParam->deqType = DEFAULT_PORT_deqType;
40885 + p_FmPort->p_FmPortDriverParam->deqByteCnt =
40886 + DEFAULT_PORT_deqByteCnt_1G;
40887 +
40888 + tmpReg =
40889 + GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofp);
40890 + p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth =
40891 + (uint8_t)(((tmpReg & BMI_FIFO_PIPELINE_DEPTH_MASK)
40892 + >> BMI_FIFO_PIPELINE_DEPTH_SHIFT) + 1);
40893 + if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
40894 + && (p_FmPortParams->portId != FM_OH_PORT_ID))
40895 + {
40896 + /* Overwrite HC defaults */
40897 + p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth =
40898 + DEFAULT_PORT_fifoDeqPipelineDepth_OH;
40899 + }
40900 +
40901 +#ifndef FM_FRAME_END_PARAMS_FOR_OP
40902 + if (p_FmPort->fmRevInfo.majorRev < 6)
40903 + p_FmPort->p_FmPortDriverParam->cheksumLastBytesIgnore = DEFAULT_notSupported;
40904 +#endif /* !FM_FRAME_END_PARAMS_FOR_OP */
40905 +
40906 +#ifndef FM_DEQ_PIPELINE_PARAMS_FOR_OP
40907 + if (!((p_FmPort->fmRevInfo.majorRev == 4) ||
40908 + (p_FmPort->fmRevInfo.majorRev >= 6)))
40909 + p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth = DEFAULT_notSupported;
40910 +#endif /* !FM_DEQ_PIPELINE_PARAMS_FOR_OP */
40911 + break;
40912 +
40913 + default:
40914 + XX_Free(p_FmPort->p_FmPortDriverParam);
40915 + XX_Free(p_FmPort);
40916 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
40917 + return NULL;
40918 + }
40919 +#ifdef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
40920 + if (p_FmPort->fmRevInfo.majorRev == 4)
40921 + p_FmPort->p_FmPortDriverParam->deqPrefetchOption = (e_FmPortDeqPrefetchOption)DEFAULT_notSupported;
40922 +#endif /* FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
40923 +
40924 + p_FmPort->imEn = p_FmPortParams->independentModeEnable;
40925 +
40926 + if (p_FmPort->imEn)
40927 + {
40928 + if ((p_FmPort->portType == e_FM_PORT_TYPE_TX)
40929 + || (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G))
40930 + p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth =
40931 + DEFAULT_PORT_fifoDeqPipelineDepth_IM;
40932 + FmPortConfigIM(p_FmPort, p_FmPortParams);
40933 + }
40934 + else
40935 + {
40936 + switch (p_FmPort->portType)
40937 + {
40938 + case (e_FM_PORT_TYPE_RX):
40939 + case (e_FM_PORT_TYPE_RX_10G):
40940 + /* Initialize FM port parameters for initialization phase only */
40941 + memcpy(&p_FmPort->p_FmPortDriverParam->extBufPools,
40942 + &p_FmPortParams->specificParams.rxParams.extBufPools,
40943 + sizeof(t_FmExtPools));
40944 + p_FmPort->p_FmPortDriverParam->errFqid =
40945 + p_FmPortParams->specificParams.rxParams.errFqid;
40946 + p_FmPort->p_FmPortDriverParam->dfltFqid =
40947 + p_FmPortParams->specificParams.rxParams.dfltFqid;
40948 + p_FmPort->p_FmPortDriverParam->liodnOffset =
40949 + p_FmPortParams->specificParams.rxParams.liodnOffset;
40950 + break;
40951 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
40952 + case (e_FM_PORT_TYPE_TX):
40953 + case (e_FM_PORT_TYPE_TX_10G):
40954 + case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
40955 + p_FmPort->p_FmPortDriverParam->errFqid =
40956 + p_FmPortParams->specificParams.nonRxParams.errFqid;
40957 + p_FmPort->p_FmPortDriverParam->deqSubPortal =
40958 + (uint8_t)(p_FmPortParams->specificParams.nonRxParams.qmChannel
40959 + & QMI_DEQ_CFG_SUBPORTAL_MASK);
40960 + p_FmPort->p_FmPortDriverParam->dfltFqid =
40961 + p_FmPortParams->specificParams.nonRxParams.dfltFqid;
40962 + break;
40963 + default:
40964 + XX_Free(p_FmPort->p_FmPortDriverParam);
40965 + XX_Free(p_FmPort);
40966 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
40967 + return NULL;
40968 + }
40969 + }
40970 +
40971 + memset(p_FmPort->name, 0, (sizeof(char)) * MODULE_NAME_SIZE);
40972 + if (Sprint(
40973 + p_FmPort->name,
40974 + "FM-%d-port-%s-%d",
40975 + FmGetId(p_FmPort->h_Fm),
40976 + ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING
40977 + || (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)) ? "OH" :
40978 + (p_FmPort->portType == e_FM_PORT_TYPE_RX ? "1g-RX" :
40979 + (p_FmPort->portType == e_FM_PORT_TYPE_TX ? "1g-TX" :
40980 + (p_FmPort->portType
40981 + == e_FM_PORT_TYPE_RX_10G ? "10g-RX" :
40982 + "10g-TX")))),
40983 + p_FmPort->portId) == 0)
40984 + {
40985 + XX_Free(p_FmPort->p_FmPortDriverParam);
40986 + XX_Free(p_FmPort);
40987 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
40988 + return NULL;
40989 + }
40990 +
40991 + p_FmPort->h_Spinlock = XX_InitSpinlock();
40992 + if (!p_FmPort->h_Spinlock)
40993 + {
40994 + XX_Free(p_FmPort->p_FmPortDriverParam);
40995 + XX_Free(p_FmPort);
40996 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
40997 + return NULL;
40998 + }
40999 +
41000 + return p_FmPort;
41001 +}
41002 +
41003 +t_FmPort *rx_port = 0;
41004 +t_FmPort *tx_port = 0;
41005 +
41006 +/**************************************************************************//**
41007 + @Function FM_PORT_Init
41008 +
41009 + @Description Initializes the FM module
41010 +
41011 + @Param[in] h_FmPort - FM module descriptor
41012 +
41013 + @Return E_OK on success; Error code otherwise.
41014 + *//***************************************************************************/
41015 +t_Error FM_PORT_Init(t_Handle h_FmPort)
41016 +{
41017 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41018 + t_FmPortDriverParam *p_DriverParams;
41019 + t_Error errCode;
41020 + t_FmInterModulePortInitParams fmParams;
41021 + t_FmRevisionInfo revInfo;
41022 +
41023 + SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
41024 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41025 +
41026 + errCode = FmSpBuildBufferStructure(
41027 + &p_FmPort->p_FmPortDriverParam->intContext,
41028 + &p_FmPort->p_FmPortDriverParam->bufferPrefixContent,
41029 + &p_FmPort->p_FmPortDriverParam->bufMargins,
41030 + &p_FmPort->bufferOffsets, &p_FmPort->internalBufferOffset);
41031 + if (errCode != E_OK)
41032 + RETURN_ERROR(MAJOR, errCode, NO_MSG);
41033 +#ifdef FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669
41034 + if ((p_FmPort->p_FmPortDriverParam->bcbWorkaround) &&
41035 + (p_FmPort->portType == e_FM_PORT_TYPE_RX))
41036 + {
41037 + p_FmPort->p_FmPortDriverParam->errorsToDiscard |= FM_PORT_FRM_ERR_PHYSICAL;
41038 + if (!p_FmPort->fifoBufs.num)
41039 + p_FmPort->fifoBufs.num = DEFAULT_PORT_numOfFifoBufs(p_FmPort->portType)*BMI_FIFO_UNITS;
41040 + p_FmPort->fifoBufs.num += 4*KILOBYTE;
41041 + }
41042 +#endif /* FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669 */
41043 +
41044 + CHECK_INIT_PARAMETERS(p_FmPort, CheckInitParameters);
41045 +
41046 + p_DriverParams = p_FmPort->p_FmPortDriverParam;
41047 +
41048 + /* Set up flibs port structure */
41049 + memset(&p_FmPort->port, 0, sizeof(struct fman_port));
41050 + p_FmPort->port.type = (enum fman_port_type)p_FmPort->portType;
41051 + FM_GetRevision(p_FmPort->h_Fm, &revInfo);
41052 + p_FmPort->port.fm_rev_maj = revInfo.majorRev;
41053 + p_FmPort->port.fm_rev_min = revInfo.minorRev;
41054 + p_FmPort->port.bmi_regs =
41055 + (union fman_port_bmi_regs *)UINT_TO_PTR(p_DriverParams->baseAddr + BMI_PORT_REGS_OFFSET);
41056 + p_FmPort->port.qmi_regs =
41057 + (struct fman_port_qmi_regs *)UINT_TO_PTR(p_DriverParams->baseAddr + QMI_PORT_REGS_OFFSET);
41058 + p_FmPort->port.ext_pools_num = (uint8_t)((revInfo.majorRev == 4) ? 4 : 8);
41059 + p_FmPort->port.im_en = p_FmPort->imEn;
41060 + p_FmPort->p_FmPortPrsRegs =
41061 + (t_FmPortPrsRegs *)UINT_TO_PTR(p_DriverParams->baseAddr + PRS_PORT_REGS_OFFSET);
41062 +
41063 + if (((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
41064 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX)) && !p_FmPort->imEn)
41065 + {
41066 + /* Call the external Buffer routine which also checks fifo
41067 + size and updates it if necessary */
41068 + /* define external buffer pools and pool depletion*/
41069 + errCode = SetExtBufferPools(p_FmPort);
41070 + if (errCode)
41071 + RETURN_ERROR(MAJOR, errCode, NO_MSG);
41072 + /* check if the largest external buffer pool is large enough */
41073 + if (p_DriverParams->bufMargins.startMargins + MIN_EXT_BUF_SIZE
41074 + + p_DriverParams->bufMargins.endMargins
41075 + > p_FmPort->rxPoolsParams.largestBufSize)
41076 + RETURN_ERROR(
41077 + MAJOR,
41078 + E_INVALID_VALUE,
41079 + ("bufMargins.startMargins (%d) + minimum buf size (64) + bufMargins.endMargins (%d) is larger than maximum external buffer size (%d)", p_DriverParams->bufMargins.startMargins, p_DriverParams->bufMargins.endMargins, p_FmPort->rxPoolsParams.largestBufSize));
41080 + }
41081 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
41082 + {
41083 + {
41084 +#ifdef FM_NO_OP_OBSERVED_POOLS
41085 + t_FmRevisionInfo revInfo;
41086 +
41087 + FM_GetRevision(p_FmPort->h_Fm, &revInfo);
41088 + if ((revInfo.majorRev == 4) && (p_DriverParams->enBufPoolDepletion))
41089 +#endif /* FM_NO_OP_OBSERVED_POOLS */
41090 + {
41091 + /* define external buffer pools */
41092 + errCode = SetExtBufferPools(p_FmPort);
41093 + if (errCode)
41094 + RETURN_ERROR(MAJOR, errCode, NO_MSG);
41095 + }
41096 + }
41097 + }
41098 +
41099 + /************************************************************/
41100 + /* Call FM module routine for communicating parameters */
41101 + /************************************************************/
41102 + memset(&fmParams, 0, sizeof(fmParams));
41103 + fmParams.hardwarePortId = p_FmPort->hardwarePortId;
41104 + fmParams.portType = (e_FmPortType)p_FmPort->portType;
41105 + fmParams.numOfTasks = (uint8_t)p_FmPort->tasks.num;
41106 + fmParams.numOfExtraTasks = (uint8_t)p_FmPort->tasks.extra;
41107 + fmParams.numOfOpenDmas = (uint8_t)p_FmPort->openDmas.num;
41108 + fmParams.numOfExtraOpenDmas = (uint8_t)p_FmPort->openDmas.extra;
41109 +
41110 + if (p_FmPort->fifoBufs.num)
41111 + {
41112 + errCode = VerifySizeOfFifo(p_FmPort);
41113 + if (errCode != E_OK)
41114 + RETURN_ERROR(MAJOR, errCode, NO_MSG);
41115 + }
41116 + fmParams.sizeOfFifo = p_FmPort->fifoBufs.num;
41117 + fmParams.extraSizeOfFifo = p_FmPort->fifoBufs.extra;
41118 + fmParams.independentMode = p_FmPort->imEn;
41119 + fmParams.liodnOffset = p_DriverParams->liodnOffset;
41120 + fmParams.liodnBase = p_DriverParams->liodnBase;
41121 + fmParams.deqPipelineDepth =
41122 + p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth;
41123 + fmParams.maxFrameLength = p_FmPort->maxFrameLength;
41124 +#ifndef FM_DEQ_PIPELINE_PARAMS_FOR_OP
41125 + if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) ||
41126 + (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
41127 + {
41128 + if (!((p_FmPort->fmRevInfo.majorRev == 4) ||
41129 + (p_FmPort->fmRevInfo.majorRev >= 6)))
41130 + /* HC ports do not have fifoDeqPipelineDepth, but it is needed only
41131 + * for deq threshold calculation.
41132 + */
41133 + fmParams.deqPipelineDepth = 2;
41134 + }
41135 +#endif /* !FM_DEQ_PIPELINE_PARAMS_FOR_OP */
41136 +
41137 + errCode = FmGetSetPortParams(p_FmPort->h_Fm, &fmParams);
41138 + if (errCode)
41139 + RETURN_ERROR(MAJOR, errCode, NO_MSG);
41140 +
41141 + /* get params for use in init */
41142 + p_FmPort->fmMuramPhysBaseAddr =
41143 + (uint64_t)((uint64_t)(fmParams.fmMuramPhysBaseAddr.low)
41144 + | ((uint64_t)(fmParams.fmMuramPhysBaseAddr.high) << 32));
41145 + p_FmPort->h_FmMuram = FmGetMuramHandle(p_FmPort->h_Fm);
41146 +
41147 + errCode = InitLowLevelDriver(p_FmPort);
41148 + if (errCode != E_OK)
41149 + RETURN_ERROR(MAJOR, errCode, NO_MSG);
41150 +
41151 + FmPortDriverParamFree(p_FmPort);
41152 +
41153 +#if (DPAA_VERSION >= 11)
41154 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
41155 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX)
41156 + || (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
41157 + {
41158 + t_FmPcdCtrlParamsPage *p_ParamsPage;
41159 +
41160 + FmPortSetGprFunc(p_FmPort, e_FM_PORT_GPR_MURAM_PAGE,
41161 + (void**)&p_ParamsPage);
41162 + ASSERT_COND(p_ParamsPage);
41163 +
41164 + WRITE_UINT32(p_ParamsPage->misc, FM_CTL_PARAMS_PAGE_ALWAYS_ON);
41165 +#ifdef FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675
41166 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
41167 + {
41168 + WRITE_UINT32(
41169 + p_ParamsPage->misc,
41170 + (GET_UINT32(p_ParamsPage->misc) | FM_CTL_PARAMS_PAGE_OP_FIX_EN));
41171 + WRITE_UINT32(
41172 + p_ParamsPage->discardMask,
41173 + GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsdm));
41174 + }
41175 +#endif /* FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675 */
41176 +#ifdef FM_ERROR_VSP_NO_MATCH_SW006
41177 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
41178 + WRITE_UINT32(
41179 + p_ParamsPage->errorsDiscardMask,
41180 + (GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsdm) | GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsem)));
41181 + else
41182 + WRITE_UINT32(
41183 + p_ParamsPage->errorsDiscardMask,
41184 + (GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfsdm) | GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfsem)));
41185 +#endif /* FM_ERROR_VSP_NO_MATCH_SW006 */
41186 + }
41187 +#endif /* (DPAA_VERSION >= 11) */
41188 +
41189 + if (p_FmPort->deepSleepVars.autoResMaxSizes)
41190 + FmPortConfigAutoResForDeepSleepSupport1(p_FmPort);
41191 + return E_OK;
41192 +}
41193 +
41194 +/**************************************************************************//**
41195 + @Function FM_PORT_Free
41196 +
41197 + @Description Frees all resources that were assigned to FM module.
41198 +
41199 + Calling this routine invalidates the descriptor.
41200 +
41201 + @Param[in] h_FmPort - FM module descriptor
41202 +
41203 + @Return E_OK on success; Error code otherwise.
41204 + *//***************************************************************************/
41205 +t_Error FM_PORT_Free(t_Handle h_FmPort)
41206 +{
41207 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41208 + t_FmInterModulePortFreeParams fmParams;
41209 +
41210 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41211 +
41212 + if (p_FmPort->pcdEngines)
41213 + RETURN_ERROR(
41214 + MAJOR,
41215 + E_INVALID_STATE,
41216 + ("Trying to free a port with PCD. FM_PORT_DeletePCD must be called first."));
41217 +
41218 + if (p_FmPort->enabled)
41219 + {
41220 + if (FM_PORT_Disable(p_FmPort) != E_OK)
41221 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM_PORT_Disable FAILED"));
41222 + }
41223 +
41224 + if (p_FmPort->imEn)
41225 + FmPortImFree(p_FmPort);
41226 +
41227 + FmPortDriverParamFree(p_FmPort);
41228 +
41229 + memset(&fmParams, 0, sizeof(fmParams));
41230 + fmParams.hardwarePortId = p_FmPort->hardwarePortId;
41231 + fmParams.portType = (e_FmPortType)p_FmPort->portType;
41232 + fmParams.deqPipelineDepth =
41233 + p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth;
41234 +
41235 + FmFreePortParams(p_FmPort->h_Fm, &fmParams);
41236 +
41237 +#if (DPAA_VERSION >= 11)
41238 + if (FmVSPFreeForPort(p_FmPort->h_Fm, p_FmPort->portType, p_FmPort->portId)
41239 + != E_OK)
41240 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("VSP free of port FAILED"));
41241 +
41242 + if (p_FmPort->p_ParamsPage)
41243 + FM_MURAM_FreeMem(p_FmPort->h_FmMuram, p_FmPort->p_ParamsPage);
41244 +#endif /* (DPAA_VERSION >= 11) */
41245 +
41246 + if (p_FmPort->h_Spinlock)
41247 + XX_FreeSpinlock(p_FmPort->h_Spinlock);
41248 +
41249 + XX_Free(p_FmPort);
41250 +
41251 + return E_OK;
41252 +}
41253 +
41254 +/*************************************************/
41255 +/* API Advanced Init unit functions */
41256 +/*************************************************/
41257 +
41258 +t_Error FM_PORT_ConfigNumOfOpenDmas(t_Handle h_FmPort, t_FmPortRsrc *p_OpenDmas)
41259 +{
41260 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41261 +
41262 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41263 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41264 +
41265 + p_FmPort->p_FmPortDriverParam->setNumOfOpenDmas = TRUE;
41266 + memcpy(&p_FmPort->openDmas, p_OpenDmas, sizeof(t_FmPortRsrc));
41267 +
41268 + return E_OK;
41269 +}
41270 +
41271 +t_Error FM_PORT_ConfigNumOfTasks(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfTasks)
41272 +{
41273 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41274 +
41275 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41276 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41277 +
41278 + memcpy(&p_FmPort->tasks, p_NumOfTasks, sizeof(t_FmPortRsrc));
41279 + p_FmPort->p_FmPortDriverParam->setNumOfTasks = TRUE;
41280 + return E_OK;
41281 +}
41282 +
41283 +t_Error FM_PORT_ConfigSizeOfFifo(t_Handle h_FmPort, t_FmPortRsrc *p_SizeOfFifo)
41284 +{
41285 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41286 +
41287 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41288 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41289 +
41290 + p_FmPort->p_FmPortDriverParam->setSizeOfFifo = TRUE;
41291 + memcpy(&p_FmPort->fifoBufs, p_SizeOfFifo, sizeof(t_FmPortRsrc));
41292 +
41293 + return E_OK;
41294 +}
41295 +
41296 +t_Error FM_PORT_ConfigDeqHighPriority(t_Handle h_FmPort, bool highPri)
41297 +{
41298 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41299 +
41300 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41301 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41302 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
41303 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
41304 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("not available for Rx ports"));
41305 +
41306 + p_FmPort->p_FmPortDriverParam->dfltCfg.deq_high_pri = highPri;
41307 +
41308 + return E_OK;
41309 +}
41310 +
41311 +t_Error FM_PORT_ConfigDeqType(t_Handle h_FmPort, e_FmPortDeqType deqType)
41312 +{
41313 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41314 +
41315 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41316 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41317 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
41318 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
41319 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41320 + ("not available for Rx ports"));
41321 +
41322 + p_FmPort->p_FmPortDriverParam->dfltCfg.deq_type =
41323 + (enum fman_port_deq_type)deqType;
41324 +
41325 + return E_OK;
41326 +}
41327 +
41328 +t_Error FM_PORT_ConfigDeqPrefetchOption(
41329 + t_Handle h_FmPort, e_FmPortDeqPrefetchOption deqPrefetchOption)
41330 +{
41331 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41332 +
41333 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41334 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41335 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
41336 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
41337 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41338 + ("not available for Rx ports"));
41339 + p_FmPort->p_FmPortDriverParam->dfltCfg.deq_prefetch_opt =
41340 + (enum fman_port_deq_prefetch)deqPrefetchOption;
41341 +
41342 + return E_OK;
41343 +}
41344 +
41345 +t_Error FM_PORT_ConfigBackupPools(t_Handle h_FmPort,
41346 + t_FmBackupBmPools *p_BackupBmPools)
41347 +{
41348 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41349 +
41350 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41351 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41352 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
41353 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
41354 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41355 + ("available for Rx ports only"));
41356 +
41357 + p_FmPort->p_FmPortDriverParam->p_BackupBmPools =
41358 + (t_FmBackupBmPools *)XX_Malloc(sizeof(t_FmBackupBmPools));
41359 + if (!p_FmPort->p_FmPortDriverParam->p_BackupBmPools)
41360 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("p_BackupBmPools allocation failed"));
41361 + memcpy(p_FmPort->p_FmPortDriverParam->p_BackupBmPools, p_BackupBmPools,
41362 + sizeof(t_FmBackupBmPools));
41363 +
41364 + return E_OK;
41365 +}
41366 +
41367 +t_Error FM_PORT_ConfigDeqByteCnt(t_Handle h_FmPort, uint16_t deqByteCnt)
41368 +{
41369 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41370 +
41371 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41372 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41373 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
41374 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
41375 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41376 + ("not available for Rx ports"));
41377 +
41378 + p_FmPort->p_FmPortDriverParam->dfltCfg.deq_byte_cnt = deqByteCnt;
41379 +
41380 + return E_OK;
41381 +}
41382 +
41383 +t_Error FM_PORT_ConfigBufferPrefixContent(
41384 + t_Handle h_FmPort, t_FmBufferPrefixContent *p_FmBufferPrefixContent)
41385 +{
41386 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41387 +
41388 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41389 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41390 +
41391 + memcpy(&p_FmPort->p_FmPortDriverParam->bufferPrefixContent,
41392 + p_FmBufferPrefixContent, sizeof(t_FmBufferPrefixContent));
41393 + /* if dataAlign was not initialized by user, we return to driver's default */
41394 + if (!p_FmPort->p_FmPortDriverParam->bufferPrefixContent.dataAlign)
41395 + p_FmPort->p_FmPortDriverParam->bufferPrefixContent.dataAlign =
41396 + DEFAULT_PORT_bufferPrefixContent_dataAlign;
41397 +
41398 + return E_OK;
41399 +}
41400 +
41401 +t_Error FM_PORT_ConfigCheksumLastBytesIgnore(t_Handle h_FmPort,
41402 + uint8_t checksumLastBytesIgnore)
41403 +{
41404 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41405 +
41406 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41407 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41408 +
41409 + p_FmPort->p_FmPortDriverParam->dfltCfg.checksum_bytes_ignore =
41410 + checksumLastBytesIgnore;
41411 +
41412 + return E_OK;
41413 +}
41414 +
41415 +t_Error FM_PORT_ConfigCutBytesFromEnd(t_Handle h_FmPort,
41416 + uint8_t cutBytesFromEnd)
41417 +{
41418 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41419 +
41420 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41421 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41422 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
41423 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
41424 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41425 + ("available for Rx ports only"));
41426 +
41427 + p_FmPort->p_FmPortDriverParam->dfltCfg.rx_cut_end_bytes = cutBytesFromEnd;
41428 +
41429 + return E_OK;
41430 +}
41431 +
41432 +t_Error FM_PORT_ConfigPoolDepletion(t_Handle h_FmPort,
41433 + t_FmBufPoolDepletion *p_BufPoolDepletion)
41434 +{
41435 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41436 +
41437 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41438 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41439 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
41440 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
41441 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41442 + ("available for Rx ports only"));
41443 +
41444 + p_FmPort->p_FmPortDriverParam->enBufPoolDepletion = TRUE;
41445 + memcpy(&p_FmPort->p_FmPortDriverParam->bufPoolDepletion, p_BufPoolDepletion,
41446 + sizeof(t_FmBufPoolDepletion));
41447 +
41448 + return E_OK;
41449 +}
41450 +
41451 +t_Error FM_PORT_ConfigObservedPoolDepletion(
41452 + t_Handle h_FmPort,
41453 + t_FmPortObservedBufPoolDepletion *p_FmPortObservedBufPoolDepletion)
41454 +{
41455 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41456 +
41457 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41458 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41459 + if (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
41460 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41461 + ("available for OP ports only"));
41462 +
41463 + p_FmPort->p_FmPortDriverParam->enBufPoolDepletion = TRUE;
41464 + memcpy(&p_FmPort->p_FmPortDriverParam->bufPoolDepletion,
41465 + &p_FmPortObservedBufPoolDepletion->poolDepletionParams,
41466 + sizeof(t_FmBufPoolDepletion));
41467 + memcpy(&p_FmPort->p_FmPortDriverParam->extBufPools,
41468 + &p_FmPortObservedBufPoolDepletion->poolsParams,
41469 + sizeof(t_FmExtPools));
41470 +
41471 + return E_OK;
41472 +}
41473 +
41474 +t_Error FM_PORT_ConfigExtBufPools(t_Handle h_FmPort, t_FmExtPools *p_FmExtPools)
41475 +{
41476 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41477 +
41478 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41479 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41480 +
41481 + if (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
41482 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41483 + ("available for OP ports only"));
41484 +
41485 + memcpy(&p_FmPort->p_FmPortDriverParam->extBufPools, p_FmExtPools,
41486 + sizeof(t_FmExtPools));
41487 +
41488 + return E_OK;
41489 +}
41490 +
41491 +t_Error FM_PORT_ConfigDontReleaseTxBufToBM(t_Handle h_FmPort)
41492 +{
41493 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41494 +
41495 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41496 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41497 + if ((p_FmPort->portType != e_FM_PORT_TYPE_TX_10G)
41498 + && (p_FmPort->portType != e_FM_PORT_TYPE_TX))
41499 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41500 + ("available for Tx ports only"));
41501 +
41502 + p_FmPort->p_FmPortDriverParam->dontReleaseBuf = TRUE;
41503 +
41504 + return E_OK;
41505 +}
41506 +
41507 +t_Error FM_PORT_ConfigDfltColor(t_Handle h_FmPort, e_FmPortColor color)
41508 +{
41509 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41510 +
41511 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41512 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41513 + p_FmPort->p_FmPortDriverParam->dfltCfg.color = (enum fman_port_color)color;
41514 +
41515 + return E_OK;
41516 +}
41517 +
41518 +t_Error FM_PORT_ConfigSyncReq(t_Handle h_FmPort, bool syncReq)
41519 +{
41520 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41521 +
41522 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41523 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41524 +
41525 + if ((p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)
41526 + || (p_FmPort->portType == e_FM_PORT_TYPE_TX))
41527 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41528 + ("Not available for Tx ports"));
41529 +
41530 + p_FmPort->p_FmPortDriverParam->dfltCfg.sync_req = syncReq;
41531 +
41532 + return E_OK;
41533 +}
41534 +
41535 +t_Error FM_PORT_ConfigFrmDiscardOverride(t_Handle h_FmPort, bool override)
41536 +{
41537 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41538 +
41539 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41540 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41541 + if ((p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)
41542 + || (p_FmPort->portType == e_FM_PORT_TYPE_TX))
41543 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41544 + ("Not available for Tx ports"));
41545 +
41546 + p_FmPort->p_FmPortDriverParam->dfltCfg.discard_override = override;
41547 +
41548 + return E_OK;
41549 +}
41550 +
41551 +t_Error FM_PORT_ConfigErrorsToDiscard(t_Handle h_FmPort,
41552 + fmPortFrameErrSelect_t errs)
41553 +{
41554 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41555 +
41556 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41557 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41558 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
41559 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
41560 + && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
41561 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
41562 + ("available for Rx and offline parsing ports only"));
41563 +
41564 + p_FmPort->p_FmPortDriverParam->errorsToDiscard = errs;
41565 +
41566 + return E_OK;
41567 +}
41568 +
41569 +t_Error FM_PORT_ConfigDmaSwapData(t_Handle h_FmPort, e_FmDmaSwapOption swapData)
41570 +{
41571 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41572 +
41573 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41574 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41575 +
41576 + p_FmPort->p_FmPortDriverParam->dfltCfg.dma_swap_data =
41577 + (enum fman_port_dma_swap)swapData;
41578 +
41579 + return E_OK;
41580 +}
41581 +
41582 +t_Error FM_PORT_ConfigDmaIcCacheAttr(t_Handle h_FmPort,
41583 + e_FmDmaCacheOption intContextCacheAttr)
41584 +{
41585 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41586 +
41587 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41588 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41589 +
41590 + p_FmPort->p_FmPortDriverParam->dfltCfg.dma_ic_stash_on =
41591 + (bool)(intContextCacheAttr == e_FM_DMA_STASH);
41592 +
41593 + return E_OK;
41594 +}
41595 +
41596 +t_Error FM_PORT_ConfigDmaHdrAttr(t_Handle h_FmPort,
41597 + e_FmDmaCacheOption headerCacheAttr)
41598 +{
41599 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41600 +
41601 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41602 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41603 +
41604 + p_FmPort->p_FmPortDriverParam->dfltCfg.dma_header_stash_on =
41605 + (bool)(headerCacheAttr == e_FM_DMA_STASH);
41606 +
41607 + return E_OK;
41608 +}
41609 +
41610 +t_Error FM_PORT_ConfigDmaScatterGatherAttr(
41611 + t_Handle h_FmPort, e_FmDmaCacheOption scatterGatherCacheAttr)
41612 +{
41613 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41614 +
41615 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41616 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41617 +
41618 + p_FmPort->p_FmPortDriverParam->dfltCfg.dma_sg_stash_on =
41619 + (bool)(scatterGatherCacheAttr == e_FM_DMA_STASH);
41620 +
41621 + return E_OK;
41622 +}
41623 +
41624 +t_Error FM_PORT_ConfigDmaWriteOptimize(t_Handle h_FmPort, bool optimize)
41625 +{
41626 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41627 +
41628 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41629 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41630 +
41631 + if ((p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)
41632 + || (p_FmPort->portType == e_FM_PORT_TYPE_TX))
41633 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41634 + ("Not available for Tx ports"));
41635 +
41636 + p_FmPort->p_FmPortDriverParam->dfltCfg.dma_write_optimize = optimize;
41637 +
41638 + return E_OK;
41639 +}
41640 +
41641 +#if (DPAA_VERSION >= 11)
41642 +t_Error FM_PORT_ConfigNoScatherGather(t_Handle h_FmPort, bool noScatherGather)
41643 +{
41644 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41645 +
41646 + UNUSED(noScatherGather);
41647 + UNUSED(p_FmPort);
41648 +
41649 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41650 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41651 +
41652 + p_FmPort->p_FmPortDriverParam->noScatherGather = noScatherGather;
41653 +
41654 + return E_OK;
41655 +}
41656 +#endif /* (DPAA_VERSION >= 11) */
41657 +
41658 +t_Error FM_PORT_ConfigForwardReuseIntContext(t_Handle h_FmPort,
41659 + bool forwardReuse)
41660 +{
41661 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41662 +
41663 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41664 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41665 +
41666 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
41667 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
41668 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41669 + ("available for Rx ports only"));
41670 +
41671 + p_FmPort->p_FmPortDriverParam->forwardReuseIntContext = forwardReuse;
41672 +
41673 + return E_OK;
41674 +}
41675 +
41676 +t_Error FM_PORT_ConfigMaxFrameLength(t_Handle h_FmPort, uint16_t length)
41677 +{
41678 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41679 +
41680 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41681 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41682 +
41683 + p_FmPort->maxFrameLength = length;
41684 +
41685 + return E_OK;
41686 +}
41687 +
41688 +#ifdef FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669
41689 +t_Error FM_PORT_ConfigBCBWorkaround(t_Handle h_FmPort)
41690 +{
41691 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41692 +
41693 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41694 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41695 +
41696 + p_FmPort->p_FmPortDriverParam->bcbWorkaround = TRUE;
41697 +
41698 + return E_OK;
41699 +}
41700 +#endif /* FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669 */
41701 +
41702 +/****************************************************/
41703 +/* Hidden-DEBUG Only API */
41704 +/****************************************************/
41705 +
41706 +t_Error FM_PORT_ConfigTxFifoMinFillLevel(t_Handle h_FmPort,
41707 + uint32_t minFillLevel)
41708 +{
41709 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41710 +
41711 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41712 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41713 + if ((p_FmPort->portType != e_FM_PORT_TYPE_TX_10G)
41714 + && (p_FmPort->portType != e_FM_PORT_TYPE_TX))
41715 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41716 + ("available for Tx ports only"));
41717 +
41718 + p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_min_level = minFillLevel;
41719 +
41720 + return E_OK;
41721 +}
41722 +
41723 +t_Error FM_PORT_ConfigFifoDeqPipelineDepth(t_Handle h_FmPort,
41724 + uint8_t deqPipelineDepth)
41725 +{
41726 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41727 +
41728 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41729 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41730 +
41731 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
41732 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
41733 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41734 + ("Not available for Rx ports"));
41735 +
41736 + if (p_FmPort->imEn)
41737 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41738 + ("Not available for IM ports!"));
41739 +
41740 + p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth =
41741 + deqPipelineDepth;
41742 +
41743 + return E_OK;
41744 +}
41745 +
41746 +t_Error FM_PORT_ConfigTxFifoLowComfLevel(t_Handle h_FmPort,
41747 + uint32_t fifoLowComfLevel)
41748 +{
41749 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41750 +
41751 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41752 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41753 + if ((p_FmPort->portType != e_FM_PORT_TYPE_TX_10G)
41754 + && (p_FmPort->portType != e_FM_PORT_TYPE_TX))
41755 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41756 + ("available for Tx ports only"));
41757 +
41758 + p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_low_comf_level =
41759 + fifoLowComfLevel;
41760 +
41761 + return E_OK;
41762 +}
41763 +
41764 +t_Error FM_PORT_ConfigRxFifoThreshold(t_Handle h_FmPort, uint32_t fifoThreshold)
41765 +{
41766 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41767 +
41768 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41769 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41770 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
41771 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
41772 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41773 + ("available for Rx ports only"));
41774 +
41775 + p_FmPort->p_FmPortDriverParam->dfltCfg.rx_fifo_thr = fifoThreshold;
41776 +
41777 + return E_OK;
41778 +}
41779 +
41780 +t_Error FM_PORT_ConfigRxFifoPriElevationLevel(t_Handle h_FmPort,
41781 + uint32_t priElevationLevel)
41782 +{
41783 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41784 +
41785 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41786 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41787 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
41788 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
41789 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
41790 + ("available for Rx ports only"));
41791 +
41792 + p_FmPort->p_FmPortDriverParam->dfltCfg.rx_pri_elevation = priElevationLevel;
41793 +
41794 + return E_OK;
41795 +}
41796 +/****************************************************/
41797 +/* API Run-time Control unit functions */
41798 +/****************************************************/
41799 +
41800 +t_Error FM_PORT_SetNumOfOpenDmas(t_Handle h_FmPort,
41801 + t_FmPortRsrc *p_NumOfOpenDmas)
41802 +{
41803 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41804 + t_Error err;
41805 +
41806 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41807 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41808 +
41809 + if ((!p_NumOfOpenDmas->num) || (p_NumOfOpenDmas->num > MAX_NUM_OF_DMAS))
41810 + RETURN_ERROR( MAJOR, E_INVALID_VALUE,
41811 + ("openDmas-num can't be larger than %d", MAX_NUM_OF_DMAS));
41812 + if (p_NumOfOpenDmas->extra > MAX_NUM_OF_EXTRA_DMAS)
41813 + RETURN_ERROR(
41814 + MAJOR,
41815 + E_INVALID_VALUE,
41816 + ("openDmas-extra can't be larger than %d", MAX_NUM_OF_EXTRA_DMAS));
41817 + err = FmSetNumOfOpenDmas(p_FmPort->h_Fm, p_FmPort->hardwarePortId,
41818 + (uint8_t*)&p_NumOfOpenDmas->num,
41819 + (uint8_t*)&p_NumOfOpenDmas->extra, FALSE);
41820 + if (err)
41821 + RETURN_ERROR(MAJOR, err, NO_MSG);
41822 +
41823 + memcpy(&p_FmPort->openDmas, p_NumOfOpenDmas, sizeof(t_FmPortRsrc));
41824 +
41825 + return E_OK;
41826 +}
41827 +
41828 +t_Error FM_PORT_SetNumOfTasks(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfTasks)
41829 +{
41830 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41831 + t_Error err;
41832 +
41833 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41834 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41835 +
41836 + /* only driver uses host command port, so ASSERT rather than RETURN_ERROR */
41837 + ASSERT_COND(p_FmPort->portType != e_FM_PORT_TYPE_OH_HOST_COMMAND);
41838 +
41839 + if ((!p_NumOfTasks->num) || (p_NumOfTasks->num > MAX_NUM_OF_TASKS))
41840 + RETURN_ERROR(
41841 + MAJOR, E_INVALID_VALUE,
41842 + ("NumOfTasks-num can't be larger than %d", MAX_NUM_OF_TASKS));
41843 + if (p_NumOfTasks->extra > MAX_NUM_OF_EXTRA_TASKS)
41844 + RETURN_ERROR(
41845 + MAJOR,
41846 + E_INVALID_VALUE,
41847 + ("NumOfTasks-extra can't be larger than %d", MAX_NUM_OF_EXTRA_TASKS));
41848 +
41849 + err = FmSetNumOfTasks(p_FmPort->h_Fm, p_FmPort->hardwarePortId,
41850 + (uint8_t*)&p_NumOfTasks->num,
41851 + (uint8_t*)&p_NumOfTasks->extra, FALSE);
41852 + if (err)
41853 + RETURN_ERROR(MAJOR, err, NO_MSG);
41854 +
41855 + /* update driver's struct */
41856 + memcpy(&p_FmPort->tasks, p_NumOfTasks, sizeof(t_FmPortRsrc));
41857 + return E_OK;
41858 +}
41859 +
41860 +t_Error FM_PORT_SetSizeOfFifo(t_Handle h_FmPort, t_FmPortRsrc *p_SizeOfFifo)
41861 +{
41862 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41863 + t_Error err;
41864 +
41865 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41866 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
41867 +
41868 + if (!p_SizeOfFifo->num || (p_SizeOfFifo->num > MAX_PORT_FIFO_SIZE))
41869 + RETURN_ERROR(
41870 + MAJOR,
41871 + E_INVALID_VALUE,
41872 + ("SizeOfFifo-num has to be in the range of 256 - %d", MAX_PORT_FIFO_SIZE));
41873 + if (p_SizeOfFifo->num % BMI_FIFO_UNITS)
41874 + RETURN_ERROR(
41875 + MAJOR, E_INVALID_VALUE,
41876 + ("SizeOfFifo-num has to be divisible by %d", BMI_FIFO_UNITS));
41877 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
41878 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
41879 + {
41880 + /* extra FIFO size (allowed only to Rx ports) */
41881 + if (p_SizeOfFifo->extra % BMI_FIFO_UNITS)
41882 + RETURN_ERROR(
41883 + MAJOR,
41884 + E_INVALID_VALUE,
41885 + ("SizeOfFifo-extra has to be divisible by %d", BMI_FIFO_UNITS));
41886 + }
41887 + else
41888 + if (p_SizeOfFifo->extra)
41889 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
41890 + (" No SizeOfFifo-extra for non Rx ports"));
41891 +
41892 + memcpy(&p_FmPort->fifoBufs, p_SizeOfFifo, sizeof(t_FmPortRsrc));
41893 +
41894 + /* we do not change user's parameter */
41895 + err = VerifySizeOfFifo(p_FmPort);
41896 + if (err)
41897 + RETURN_ERROR(MAJOR, err, NO_MSG);
41898 +
41899 + err = FmSetSizeOfFifo(p_FmPort->h_Fm, p_FmPort->hardwarePortId,
41900 + &p_SizeOfFifo->num, &p_SizeOfFifo->extra, FALSE);
41901 + if (err)
41902 + RETURN_ERROR(MAJOR, err, NO_MSG);
41903 +
41904 + return E_OK;
41905 +}
41906 +
41907 +uint32_t FM_PORT_GetBufferDataOffset(t_Handle h_FmPort)
41908 +{
41909 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41910 +
41911 + SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, 0);
41912 + SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE,
41913 + 0);
41914 +
41915 + return p_FmPort->bufferOffsets.dataOffset;
41916 +}
41917 +
41918 +uint8_t * FM_PORT_GetBufferICInfo(t_Handle h_FmPort, char *p_Data)
41919 +{
41920 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41921 +
41922 + SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, NULL);
41923 + SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE,
41924 + NULL);
41925 +
41926 + if (p_FmPort->bufferOffsets.pcdInfoOffset == ILLEGAL_BASE)
41927 + return NULL;
41928 +
41929 + return (uint8_t *)PTR_MOVE(p_Data, p_FmPort->bufferOffsets.pcdInfoOffset);
41930 +}
41931 +
41932 +t_FmPrsResult * FM_PORT_GetBufferPrsResult(t_Handle h_FmPort, char *p_Data)
41933 +{
41934 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41935 +
41936 + SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, NULL);
41937 + SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE,
41938 + NULL);
41939 +
41940 + if (p_FmPort->bufferOffsets.prsResultOffset == ILLEGAL_BASE)
41941 + return NULL;
41942 +
41943 + return (t_FmPrsResult *)PTR_MOVE(p_Data, p_FmPort->bufferOffsets.prsResultOffset);
41944 +}
41945 +
41946 +uint64_t * FM_PORT_GetBufferTimeStamp(t_Handle h_FmPort, char *p_Data)
41947 +{
41948 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41949 +
41950 + SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, NULL);
41951 + SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE,
41952 + NULL);
41953 +
41954 + if (p_FmPort->bufferOffsets.timeStampOffset == ILLEGAL_BASE)
41955 + return NULL;
41956 +
41957 + return (uint64_t *)PTR_MOVE(p_Data, p_FmPort->bufferOffsets.timeStampOffset);
41958 +}
41959 +
41960 +uint8_t * FM_PORT_GetBufferHashResult(t_Handle h_FmPort, char *p_Data)
41961 +{
41962 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41963 +
41964 + SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, NULL);
41965 + SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE,
41966 + NULL);
41967 +
41968 + if (p_FmPort->bufferOffsets.hashResultOffset == ILLEGAL_BASE)
41969 + return NULL;
41970 +
41971 + return (uint8_t *)PTR_MOVE(p_Data, p_FmPort->bufferOffsets.hashResultOffset);
41972 +}
41973 +
41974 +t_Error FM_PORT_Disable(t_Handle h_FmPort)
41975 +{
41976 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
41977 + int err;
41978 +
41979 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
41980 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
41981 +
41982 + if (p_FmPort->imEn)
41983 + FmPortImDisable(p_FmPort);
41984 +
41985 + err = fman_port_disable(&p_FmPort->port);
41986 + if (err == -EBUSY)
41987 + {
41988 + DBG(WARNING, ("%s: BMI or QMI is Busy. Port forced down",
41989 + p_FmPort->name));
41990 + }
41991 + else
41992 + if (err != 0)
41993 + {
41994 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_disable"));
41995 + }
41996 +
41997 + p_FmPort->enabled = FALSE;
41998 +
41999 + return E_OK;
42000 +}
42001 +
42002 +t_Error FM_PORT_Enable(t_Handle h_FmPort)
42003 +{
42004 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42005 + int err;
42006 +
42007 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42008 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
42009 +
42010 + /* Used by FM_PORT_Free routine as indication
42011 + if to disable port. Thus set it to TRUE prior
42012 + to enabling itself. This way if part of enable
42013 + process fails there will be still things
42014 + to disable during Free. For example, if BMI
42015 + enable succeeded but QMI failed, still BMI
42016 + needs to be disabled by Free. */
42017 + p_FmPort->enabled = TRUE;
42018 +
42019 + if (p_FmPort->imEn)
42020 + FmPortImEnable(p_FmPort);
42021 +
42022 + err = fman_port_enable(&p_FmPort->port);
42023 + if (err != 0)
42024 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_enable"));
42025 +
42026 + return E_OK;
42027 +}
42028 +
42029 +t_Error FM_PORT_SetRateLimit(t_Handle h_FmPort, t_FmPortRateLimit *p_RateLimit)
42030 +{
42031 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42032 + uint8_t factor, countUnitBit;
42033 + uint16_t baseGran;
42034 + struct fman_port_rate_limiter params;
42035 + int err;
42036 +
42037 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42038 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
42039 +
42040 + switch (p_FmPort->portType)
42041 + {
42042 + case (e_FM_PORT_TYPE_TX_10G):
42043 + case (e_FM_PORT_TYPE_TX):
42044 + baseGran = BMI_RATE_LIMIT_GRAN_TX;
42045 + break;
42046 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
42047 + baseGran = BMI_RATE_LIMIT_GRAN_OP;
42048 + break;
42049 + default:
42050 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
42051 + ("available for Tx and Offline parsing ports only"));
42052 + }
42053 +
42054 + countUnitBit = (uint8_t)FmGetTimeStampScale(p_FmPort->h_Fm); /* TimeStamp per nano seconds units */
42055 + /* normally, we use 1 usec as the reference count */
42056 + factor = 1;
42057 + /* if ratelimit is too small for a 1usec factor, multiply the factor */
42058 + while (p_RateLimit->rateLimit < baseGran / factor)
42059 + {
42060 + if (countUnitBit == 31)
42061 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Rate limit is too small"));
42062 +
42063 + countUnitBit++;
42064 + factor <<= 1;
42065 + }
42066 + /* if ratelimit is too large for a 1usec factor, it is also larger than max rate*/
42067 + if (p_RateLimit->rateLimit
42068 + > ((uint32_t)baseGran * (1 << 10) * (uint32_t)factor))
42069 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Rate limit is too large"));
42070 +
42071 + if (!p_RateLimit->maxBurstSize
42072 + || (p_RateLimit->maxBurstSize > BMI_RATE_LIMIT_MAX_BURST_SIZE))
42073 + RETURN_ERROR(
42074 + MAJOR,
42075 + E_INVALID_VALUE,
42076 + ("maxBurstSize must be between 1K and %dk", BMI_RATE_LIMIT_MAX_BURST_SIZE));
42077 +
42078 + params.count_1micro_bit = (uint8_t)FmGetTimeStampScale(p_FmPort->h_Fm);
42079 + params.high_burst_size_gran = FALSE;
42080 + params.burst_size = p_RateLimit->maxBurstSize;
42081 + params.rate = p_RateLimit->rateLimit;
42082 + params.rate_factor = E_FMAN_PORT_RATE_DOWN_NONE;
42083 +
42084 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
42085 + {
42086 +#ifndef FM_NO_ADVANCED_RATE_LIMITER
42087 +
42088 + if ((p_FmPort->fmRevInfo.majorRev == 4)
42089 + || (p_FmPort->fmRevInfo.majorRev >= 6))
42090 + {
42091 + params.high_burst_size_gran = TRUE;
42092 + }
42093 + else
42094 +#endif /* ! FM_NO_ADVANCED_RATE_LIMITER */
42095 + {
42096 + if (p_RateLimit->rateLimitDivider
42097 + != e_FM_PORT_DUAL_RATE_LIMITER_NONE)
42098 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
42099 + ("FM_PORT_ConfigDualRateLimitScaleDown"));
42100 +
42101 + if (p_RateLimit->maxBurstSize % 1000)
42102 + {
42103 + p_RateLimit->maxBurstSize =
42104 + (uint16_t)((p_RateLimit->maxBurstSize / 1000) + 1);
42105 + DBG(WARNING, ("rateLimit.maxBurstSize rounded up to %d", (p_RateLimit->maxBurstSize/1000+1)*1000));
42106 + }
42107 + else
42108 + p_RateLimit->maxBurstSize = (uint16_t)(p_RateLimit->maxBurstSize
42109 + / 1000);
42110 + }
42111 + params.rate_factor =
42112 + (enum fman_port_rate_limiter_scale_down)p_RateLimit->rateLimitDivider;
42113 + params.burst_size = p_RateLimit->maxBurstSize;
42114 + }
42115 +
42116 + err = fman_port_set_rate_limiter(&p_FmPort->port, &params);
42117 + if (err != 0)
42118 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_rate_limiter"));
42119 +
42120 + return E_OK;
42121 +}
42122 +
42123 +t_Error FM_PORT_DeleteRateLimit(t_Handle h_FmPort)
42124 +{
42125 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42126 + int err;
42127 +
42128 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42129 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
42130 +
42131 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
42132 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX)
42133 + || (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
42134 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
42135 + ("available for Tx and Offline parsing ports only"));
42136 +
42137 + err = fman_port_delete_rate_limiter(&p_FmPort->port);
42138 + if (err != 0)
42139 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_rate_limiter"));
42140 + return E_OK;
42141 +}
42142 +
42143 +t_Error FM_PORT_SetPfcPrioritiesMappingToQmanWQ(t_Handle h_FmPort, uint8_t prio,
42144 + uint8_t wq)
42145 +{
42146 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42147 + uint32_t tmpReg;
42148 + uint32_t wqTmpReg;
42149 +
42150 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42151 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
42152 +
42153 + if ((p_FmPort->portType != e_FM_PORT_TYPE_TX)
42154 + && (p_FmPort->portType != e_FM_PORT_TYPE_TX_10G))
42155 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
42156 + ("PFC mapping is available for Tx ports only"));
42157 +
42158 + if (prio > 7)
42159 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE,
42160 + ("PFC priority (%d) is out of range (0-7)", prio));
42161 + if (wq > 7)
42162 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE,
42163 + ("WQ (%d) is out of range (0-7)", wq));
42164 +
42165 + tmpReg = GET_UINT32(p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tpfcm[0]);
42166 + tmpReg &= ~(0xf << ((7 - prio) * 4));
42167 + wqTmpReg = ((uint32_t)wq << ((7 - prio) * 4));
42168 + tmpReg |= wqTmpReg;
42169 +
42170 + WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tpfcm[0],
42171 + tmpReg);
42172 +
42173 + return E_OK;
42174 +}
42175 +
42176 +t_Error FM_PORT_SetFrameQueueCounters(t_Handle h_FmPort, bool enable)
42177 +{
42178 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42179 +
42180 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42181 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
42182 +
42183 + fman_port_set_queue_cnt_mode(&p_FmPort->port, enable);
42184 +
42185 + return E_OK;
42186 +}
42187 +
42188 +t_Error FM_PORT_SetPerformanceCounters(t_Handle h_FmPort, bool enable)
42189 +{
42190 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42191 + int err;
42192 +
42193 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42194 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
42195 +
42196 + err = fman_port_set_perf_cnt_mode(&p_FmPort->port, enable);
42197 + if (err != 0)
42198 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_perf_cnt_mode"));
42199 + return E_OK;
42200 +}
42201 +
42202 +t_Error FM_PORT_SetPerformanceCountersParams(
42203 + t_Handle h_FmPort, t_FmPortPerformanceCnt *p_FmPortPerformanceCnt)
42204 +{
42205 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42206 + struct fman_port_perf_cnt_params params;
42207 + int err;
42208 +
42209 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42210 +
42211 + /* check parameters */
42212 + if (!p_FmPortPerformanceCnt->taskCompVal
42213 + || (p_FmPortPerformanceCnt->taskCompVal > p_FmPort->tasks.num))
42214 + RETURN_ERROR(
42215 + MAJOR,
42216 + E_INVALID_VALUE,
42217 + ("taskCompVal (%d) has to be in the range of 1 - %d (current value)!", p_FmPortPerformanceCnt->taskCompVal, p_FmPort->tasks.num));
42218 + if (!p_FmPortPerformanceCnt->dmaCompVal
42219 + || (p_FmPortPerformanceCnt->dmaCompVal > p_FmPort->openDmas.num))
42220 + RETURN_ERROR(
42221 + MAJOR,
42222 + E_INVALID_VALUE,
42223 + ("dmaCompVal (%d) has to be in the range of 1 - %d (current value)!", p_FmPortPerformanceCnt->dmaCompVal, p_FmPort->openDmas.num));
42224 + if (!p_FmPortPerformanceCnt->fifoCompVal
42225 + || (p_FmPortPerformanceCnt->fifoCompVal > p_FmPort->fifoBufs.num))
42226 + RETURN_ERROR(
42227 + MAJOR,
42228 + E_INVALID_VALUE,
42229 + ("fifoCompVal (%d) has to be in the range of 256 - %d (current value)!", p_FmPortPerformanceCnt->fifoCompVal, p_FmPort->fifoBufs.num));
42230 + if (p_FmPortPerformanceCnt->fifoCompVal % BMI_FIFO_UNITS)
42231 + RETURN_ERROR(
42232 + MAJOR,
42233 + E_INVALID_VALUE,
42234 + ("fifoCompVal (%d) has to be divisible by %d", p_FmPortPerformanceCnt->fifoCompVal, BMI_FIFO_UNITS));
42235 +
42236 + switch (p_FmPort->portType)
42237 + {
42238 + case (e_FM_PORT_TYPE_RX_10G):
42239 + case (e_FM_PORT_TYPE_RX):
42240 + if (!p_FmPortPerformanceCnt->queueCompVal
42241 + || (p_FmPortPerformanceCnt->queueCompVal
42242 + > MAX_PERFORMANCE_RX_QUEUE_COMP))
42243 + RETURN_ERROR(
42244 + MAJOR,
42245 + E_INVALID_VALUE,
42246 + ("performanceCnt.queueCompVal for Rx has to be in the range of 1 - %d", MAX_PERFORMANCE_RX_QUEUE_COMP));
42247 + break;
42248 + case (e_FM_PORT_TYPE_TX_10G):
42249 + case (e_FM_PORT_TYPE_TX):
42250 + if (!p_FmPortPerformanceCnt->queueCompVal
42251 + || (p_FmPortPerformanceCnt->queueCompVal
42252 + > MAX_PERFORMANCE_TX_QUEUE_COMP))
42253 + RETURN_ERROR(
42254 + MAJOR,
42255 + E_INVALID_VALUE,
42256 + ("performanceCnt.queueCompVal for Tx has to be in the range of 1 - %d", MAX_PERFORMANCE_TX_QUEUE_COMP));
42257 + break;
42258 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
42259 + case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
42260 + if (p_FmPortPerformanceCnt->queueCompVal)
42261 + RETURN_ERROR(
42262 + MAJOR,
42263 + E_INVALID_VALUE,
42264 + ("performanceCnt.queueCompVal is not relevant for H/O ports."));
42265 + break;
42266 + default:
42267 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
42268 + }
42269 +
42270 + params.task_val = p_FmPortPerformanceCnt->taskCompVal;
42271 + params.queue_val = p_FmPortPerformanceCnt->queueCompVal;
42272 + params.dma_val = p_FmPortPerformanceCnt->dmaCompVal;
42273 + params.fifo_val = p_FmPortPerformanceCnt->fifoCompVal;
42274 +
42275 + err = fman_port_set_perf_cnt_params(&p_FmPort->port, &params);
42276 + if (err != 0)
42277 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_perf_cnt_params"));
42278 +
42279 + return E_OK;
42280 +}
42281 +
42282 +t_Error FM_PORT_AnalyzePerformanceParams(t_Handle h_FmPort)
42283 +{
42284 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42285 + t_FmPortPerformanceCnt currParams, savedParams;
42286 + t_Error err;
42287 + bool underTest, failed = FALSE;
42288 +
42289 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42290 +
42291 + XX_Print("Analyzing Performance parameters for port (type %d, id%d)\n",
42292 + p_FmPort->portType, p_FmPort->portId);
42293 +
42294 + currParams.taskCompVal = (uint8_t)p_FmPort->tasks.num;
42295 + if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
42296 + || (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
42297 + currParams.queueCompVal = 0;
42298 + else
42299 + currParams.queueCompVal = 1;
42300 + currParams.dmaCompVal = (uint8_t)p_FmPort->openDmas.num;
42301 + currParams.fifoCompVal = p_FmPort->fifoBufs.num;
42302 +
42303 + FM_PORT_SetPerformanceCounters(p_FmPort, FALSE);
42304 + ClearPerfCnts(p_FmPort);
42305 + if ((err = FM_PORT_SetPerformanceCountersParams(p_FmPort, &currParams))
42306 + != E_OK)
42307 + RETURN_ERROR(MAJOR, err, NO_MSG);
42308 + FM_PORT_SetPerformanceCounters(p_FmPort, TRUE);
42309 + XX_UDelay(1000000);
42310 + FM_PORT_SetPerformanceCounters(p_FmPort, FALSE);
42311 + if (FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_TASK_UTIL))
42312 + {
42313 + XX_Print(
42314 + "Max num of defined port tasks (%d) utilized - Please enlarge\n",
42315 + p_FmPort->tasks.num);
42316 + failed = TRUE;
42317 + }
42318 + if (FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_DMA_UTIL))
42319 + {
42320 + XX_Print(
42321 + "Max num of defined port openDmas (%d) utilized - Please enlarge\n",
42322 + p_FmPort->openDmas.num);
42323 + failed = TRUE;
42324 + }
42325 + if (FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_FIFO_UTIL))
42326 + {
42327 + XX_Print(
42328 + "Max size of defined port fifo (%d) utilized - Please enlarge\n",
42329 + p_FmPort->fifoBufs.num);
42330 + failed = TRUE;
42331 + }
42332 + if (failed)
42333 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
42334 +
42335 + memset(&savedParams, 0, sizeof(savedParams));
42336 + while (TRUE)
42337 + {
42338 + underTest = FALSE;
42339 + if ((currParams.taskCompVal != 1) && !savedParams.taskCompVal)
42340 + {
42341 + currParams.taskCompVal--;
42342 + underTest = TRUE;
42343 + }
42344 + if ((currParams.dmaCompVal != 1) && !savedParams.dmaCompVal)
42345 + {
42346 + currParams.dmaCompVal--;
42347 + underTest = TRUE;
42348 + }
42349 + if ((currParams.fifoCompVal != BMI_FIFO_UNITS)
42350 + && !savedParams.fifoCompVal)
42351 + {
42352 + currParams.fifoCompVal -= BMI_FIFO_UNITS;
42353 + underTest = TRUE;
42354 + }
42355 + if (!underTest)
42356 + break;
42357 +
42358 + ClearPerfCnts(p_FmPort);
42359 + if ((err = FM_PORT_SetPerformanceCountersParams(p_FmPort, &currParams))
42360 + != E_OK)
42361 + RETURN_ERROR(MAJOR, err, NO_MSG);
42362 + FM_PORT_SetPerformanceCounters(p_FmPort, TRUE);
42363 + XX_UDelay(1000000);
42364 + FM_PORT_SetPerformanceCounters(p_FmPort, FALSE);
42365 +
42366 + if (!savedParams.taskCompVal
42367 + && FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_TASK_UTIL))
42368 + savedParams.taskCompVal = (uint8_t)(currParams.taskCompVal + 2);
42369 + if (!savedParams.dmaCompVal
42370 + && FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_DMA_UTIL))
42371 + savedParams.dmaCompVal = (uint8_t)(currParams.dmaCompVal + 2);
42372 + if (!savedParams.fifoCompVal
42373 + && FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_FIFO_UTIL))
42374 + savedParams.fifoCompVal = currParams.fifoCompVal
42375 + + (2 * BMI_FIFO_UNITS);
42376 + }
42377 +
42378 + XX_Print("best vals: tasks %d, dmas %d, fifos %d\n",
42379 + savedParams.taskCompVal, savedParams.dmaCompVal,
42380 + savedParams.fifoCompVal);
42381 + return E_OK;
42382 +}
42383 +
42384 +t_Error FM_PORT_SetStatisticsCounters(t_Handle h_FmPort, bool enable)
42385 +{
42386 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42387 + int err;
42388 +
42389 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42390 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
42391 +
42392 + err = fman_port_set_stats_cnt_mode(&p_FmPort->port, enable);
42393 + if (err != 0)
42394 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_stats_cnt_mode"));
42395 + return E_OK;
42396 +}
42397 +
42398 +t_Error FM_PORT_SetErrorsRoute(t_Handle h_FmPort, fmPortFrameErrSelect_t errs)
42399 +{
42400 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42401 + volatile uint32_t *p_ErrDiscard = NULL;
42402 + int err;
42403 +
42404 + UNUSED(p_ErrDiscard);
42405 + err = fman_port_set_err_mask(&p_FmPort->port, (uint32_t)errs);
42406 + if (err != 0)
42407 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_err_mask"));
42408 +
42409 +#ifdef FM_ERROR_VSP_NO_MATCH_SW006
42410 + if (p_FmPort->fmRevInfo.majorRev >= 6)
42411 + {
42412 + t_FmPcdCtrlParamsPage *p_ParamsPage;
42413 +
42414 + FmPortSetGprFunc(p_FmPort, e_FM_PORT_GPR_MURAM_PAGE,
42415 + (void**)&p_ParamsPage);
42416 + ASSERT_COND(p_ParamsPage);
42417 + switch (p_FmPort->portType)
42418 + {
42419 + case (e_FM_PORT_TYPE_RX_10G):
42420 + case (e_FM_PORT_TYPE_RX):
42421 + p_ErrDiscard =
42422 + &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfsdm;
42423 + break;
42424 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
42425 + p_ErrDiscard =
42426 + &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsdm;
42427 + break;
42428 + default:
42429 + RETURN_ERROR(
42430 + MAJOR, E_INVALID_OPERATION,
42431 + ("available for Rx and offline parsing ports only"));
42432 + }
42433 + WRITE_UINT32(p_ParamsPage->errorsDiscardMask,
42434 + GET_UINT32(*p_ErrDiscard) | errs);
42435 + }
42436 +#endif /* FM_ERROR_VSP_NO_MATCH_SW006 */
42437 +
42438 + return E_OK;
42439 +}
42440 +
42441 +t_Error FM_PORT_SetAllocBufCounter(t_Handle h_FmPort, uint8_t poolId,
42442 + bool enable)
42443 +{
42444 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42445 + int err;
42446 +
42447 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42448 + SANITY_CHECK_RETURN_ERROR(poolId<BM_MAX_NUM_OF_POOLS, E_INVALID_HANDLE);
42449 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
42450 +
42451 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
42452 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
42453 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
42454 + ("available for Rx ports only"));
42455 +
42456 + err = fman_port_set_bpool_cnt_mode(&p_FmPort->port, poolId, enable);
42457 + if (err != 0)
42458 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_bpool_cnt_mode"));
42459 + return E_OK;
42460 +}
42461 +
42462 +t_Error FM_PORT_GetBmiCounters(t_Handle h_FmPort, t_FmPortBmiStats *p_BmiStats)
42463 +{
42464 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42465 +
42466 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
42467 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)){
42468 + p_BmiStats->cntCycle =
42469 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_CYCLE);
42470 + /* fmbm_rccn */
42471 + p_BmiStats->cntTaskUtil =
42472 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_TASK_UTIL);
42473 + /* fmbm_rtuc */
42474 + p_BmiStats->cntQueueUtil =
42475 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_QUEUE_UTIL);
42476 + /* fmbm_rrquc */
42477 + p_BmiStats->cntDmaUtil =
42478 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DMA_UTIL);
42479 + /* fmbm_rduc */
42480 + p_BmiStats->cntFifoUtil =
42481 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_FIFO_UTIL);
42482 + /* fmbm_rfuc */
42483 + p_BmiStats->cntRxPauseActivation =
42484 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION);
42485 + /* fmbm_rpac */
42486 + p_BmiStats->cntFrame =
42487 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_FRAME);
42488 + /* fmbm_rfrc */
42489 + p_BmiStats->cntDiscardFrame =
42490 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DISCARD_FRAME);
42491 + /* fmbm_rfdc */
42492 + p_BmiStats->cntDeallocBuf =
42493 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DEALLOC_BUF);
42494 + /* fmbm_rbdc */
42495 + p_BmiStats->cntRxBadFrame =
42496 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_BAD_FRAME);
42497 + /* fmbm_rfbc */
42498 + p_BmiStats->cntRxLargeFrame =
42499 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_LARGE_FRAME);
42500 + /* fmbm_rlfc */
42501 + p_BmiStats->cntRxFilterFrame =
42502 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_FILTER_FRAME);
42503 + /* fmbm_rffc */
42504 + p_BmiStats->cntRxListDmaErr =
42505 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR);
42506 + /* fmbm_rfldec */
42507 + p_BmiStats->cntRxOutOfBuffersDiscard =
42508 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD);
42509 + /* fmbm_rodc */
42510 + p_BmiStats->cntWredDiscard = 0;
42511 + p_BmiStats->cntLengthErr = 0;
42512 + p_BmiStats->cntUnsupportedFormat = 0;
42513 + }
42514 + else if ((p_FmPort->portType == e_FM_PORT_TYPE_TX)
42515 + || (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)){
42516 + p_BmiStats->cntCycle =
42517 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_CYCLE);
42518 + /* fmbm_tccn */
42519 + p_BmiStats->cntTaskUtil =
42520 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_TASK_UTIL);
42521 + /* fmbm_ttuc */
42522 + p_BmiStats->cntQueueUtil =
42523 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_QUEUE_UTIL);
42524 + /* fmbm_ttcquc */
42525 + p_BmiStats->cntDmaUtil =
42526 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DMA_UTIL);
42527 + /* fmbm_tduc */
42528 + p_BmiStats->cntFifoUtil =
42529 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_FIFO_UTIL);
42530 + /* fmbm_tfuc */
42531 + p_BmiStats->cntRxPauseActivation = 0;
42532 + p_BmiStats->cntFrame =
42533 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_FRAME);
42534 + /* fmbm_tfrc */
42535 + p_BmiStats->cntDiscardFrame =
42536 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DISCARD_FRAME);
42537 + /* fmbm_tfdc */
42538 + p_BmiStats->cntDeallocBuf =
42539 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DEALLOC_BUF);
42540 + /* fmbm_tbdc */
42541 + p_BmiStats->cntRxBadFrame = 0;
42542 + p_BmiStats->cntRxLargeFrame = 0;
42543 + p_BmiStats->cntRxFilterFrame = 0;
42544 + p_BmiStats->cntRxListDmaErr = 0;
42545 + p_BmiStats->cntRxOutOfBuffersDiscard = 0;
42546 + p_BmiStats->cntWredDiscard = 0;
42547 + p_BmiStats->cntLengthErr =
42548 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_LENGTH_ERR);
42549 + /* fmbm_tfledc */
42550 + p_BmiStats->cntUnsupportedFormat =
42551 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT);
42552 + /* fmbm_tfufdc */
42553 + }
42554 + else if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) {
42555 + p_BmiStats->cntCycle =
42556 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_CYCLE);
42557 + /* fmbm_occn */
42558 + p_BmiStats->cntTaskUtil =
42559 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_TASK_UTIL);
42560 + /* fmbm_otuc */
42561 + p_BmiStats->cntQueueUtil = 0;
42562 + p_BmiStats->cntDmaUtil =
42563 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DMA_UTIL);
42564 + /* fmbm_oduc */
42565 + p_BmiStats->cntFifoUtil =
42566 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_FIFO_UTIL);
42567 + /* fmbm_ofuc*/
42568 + p_BmiStats->cntRxPauseActivation = 0;
42569 + p_BmiStats->cntFrame =
42570 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_FRAME);
42571 + /* fmbm_ofrc */
42572 + p_BmiStats->cntDiscardFrame =
42573 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DISCARD_FRAME);
42574 + /* fmbm_ofdc */
42575 + p_BmiStats->cntDeallocBuf =
42576 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DEALLOC_BUF);
42577 + /* fmbm_obdc*/
42578 + p_BmiStats->cntRxBadFrame = 0;
42579 + p_BmiStats->cntRxLargeFrame = 0;
42580 + p_BmiStats->cntRxFilterFrame =
42581 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_FILTER_FRAME);
42582 + /* fmbm_offc */
42583 + p_BmiStats->cntRxListDmaErr =
42584 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR);
42585 + /* fmbm_ofldec */
42586 + p_BmiStats->cntRxOutOfBuffersDiscard =
42587 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD);
42588 + /* fmbm_rodc */
42589 + p_BmiStats->cntWredDiscard =
42590 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_WRED_DISCARD);
42591 + /* fmbm_ofwdc */
42592 + p_BmiStats->cntLengthErr =
42593 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_LENGTH_ERR);
42594 + /* fmbm_ofledc */
42595 + p_BmiStats->cntUnsupportedFormat =
42596 + FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT);
42597 + /* fmbm_ofufdc */
42598 + }
42599 + return E_OK;
42600 +}
42601 +
42602 +uint32_t FM_PORT_GetCounter(t_Handle h_FmPort, e_FmPortCounters counter)
42603 +{
42604 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42605 + bool bmiCounter = FALSE;
42606 + enum fman_port_stats_counters statsType;
42607 + enum fman_port_perf_counters perfType;
42608 + enum fman_port_qmi_counters queueType;
42609 + bool isStats;
42610 + t_Error errCode;
42611 +
42612 + SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, 0);
42613 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
42614 +
42615 + switch (counter)
42616 + {
42617 + case (e_FM_PORT_COUNTERS_DEQ_TOTAL):
42618 + case (e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT):
42619 + case (e_FM_PORT_COUNTERS_DEQ_CONFIRM):
42620 + /* check that counter is available for the port type */
42621 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
42622 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
42623 + {
42624 + REPORT_ERROR(MINOR, E_INVALID_STATE,
42625 + ("Requested counter is not available for Rx ports"));
42626 + return 0;
42627 + }
42628 + bmiCounter = FALSE;
42629 + break;
42630 + case (e_FM_PORT_COUNTERS_ENQ_TOTAL):
42631 + bmiCounter = FALSE;
42632 + break;
42633 + default: /* BMI counters (or error - will be checked in BMI routine )*/
42634 + bmiCounter = TRUE;
42635 + break;
42636 + }
42637 +
42638 + if (bmiCounter)
42639 + {
42640 + errCode = BmiPortCheckAndGetCounterType(p_FmPort, counter, &statsType,
42641 + &perfType, &isStats);
42642 + if (errCode != E_OK)
42643 + {
42644 + REPORT_ERROR(MINOR, errCode, NO_MSG);
42645 + return 0;
42646 + }
42647 + if (isStats)
42648 + return fman_port_get_stats_counter(&p_FmPort->port, statsType);
42649 + else
42650 + return fman_port_get_perf_counter(&p_FmPort->port, perfType);
42651 + }
42652 + else /* QMI counter */
42653 + {
42654 + /* check that counters are enabled */
42655 + if (!(GET_UINT32(p_FmPort->port.qmi_regs->fmqm_pnc)
42656 + & QMI_PORT_CFG_EN_COUNTERS))
42657 +
42658 + {
42659 + REPORT_ERROR(MINOR, E_INVALID_STATE, ("Requested counter was not enabled"));
42660 + return 0;
42661 + }
42662 +
42663 + /* Set counter */
42664 + switch (counter)
42665 + {
42666 + case (e_FM_PORT_COUNTERS_ENQ_TOTAL):
42667 + queueType = E_FMAN_PORT_ENQ_TOTAL;
42668 + break;
42669 + case (e_FM_PORT_COUNTERS_DEQ_TOTAL):
42670 + queueType = E_FMAN_PORT_DEQ_TOTAL;
42671 + break;
42672 + case (e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT):
42673 + queueType = E_FMAN_PORT_DEQ_FROM_DFLT;
42674 + break;
42675 + case (e_FM_PORT_COUNTERS_DEQ_CONFIRM):
42676 + queueType = E_FMAN_PORT_DEQ_CONFIRM;
42677 + break;
42678 + default:
42679 + REPORT_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available"));
42680 + return 0;
42681 + }
42682 +
42683 + return fman_port_get_qmi_counter(&p_FmPort->port, queueType);
42684 + }
42685 +
42686 + return 0;
42687 +}
42688 +
42689 +t_Error FM_PORT_ModifyCounter(t_Handle h_FmPort, e_FmPortCounters counter,
42690 + uint32_t value)
42691 +{
42692 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42693 + bool bmiCounter = FALSE;
42694 + enum fman_port_stats_counters statsType;
42695 + enum fman_port_perf_counters perfType;
42696 + enum fman_port_qmi_counters queueType;
42697 + bool isStats;
42698 + t_Error errCode;
42699 +
42700 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42701 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
42702 +
42703 + switch (counter)
42704 + {
42705 + case (e_FM_PORT_COUNTERS_DEQ_TOTAL):
42706 + case (e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT):
42707 + case (e_FM_PORT_COUNTERS_DEQ_CONFIRM):
42708 + /* check that counter is available for the port type */
42709 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
42710 + || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
42711 + RETURN_ERROR(
42712 + MINOR, E_INVALID_STATE,
42713 + ("Requested counter is not available for Rx ports"));
42714 + case (e_FM_PORT_COUNTERS_ENQ_TOTAL):
42715 + bmiCounter = FALSE;
42716 + break;
42717 + default: /* BMI counters (or error - will be checked in BMI routine )*/
42718 + bmiCounter = TRUE;
42719 + break;
42720 + }
42721 +
42722 + if (bmiCounter)
42723 + {
42724 + errCode = BmiPortCheckAndGetCounterType(p_FmPort, counter, &statsType,
42725 + &perfType, &isStats);
42726 + if (errCode != E_OK)
42727 + {
42728 + RETURN_ERROR(MINOR, errCode, NO_MSG);
42729 + }
42730 + if (isStats)
42731 + fman_port_set_stats_counter(&p_FmPort->port, statsType, value);
42732 + else
42733 + fman_port_set_perf_counter(&p_FmPort->port, perfType, value);
42734 + }
42735 + else /* QMI counter */
42736 + {
42737 + /* check that counters are enabled */
42738 + if (!(GET_UINT32(p_FmPort->port.qmi_regs->fmqm_pnc)
42739 + & QMI_PORT_CFG_EN_COUNTERS))
42740 + {
42741 + RETURN_ERROR(MINOR, E_INVALID_STATE,
42742 + ("Requested counter was not enabled"));
42743 + }
42744 +
42745 + /* Set counter */
42746 + switch (counter)
42747 + {
42748 + case (e_FM_PORT_COUNTERS_ENQ_TOTAL):
42749 + queueType = E_FMAN_PORT_ENQ_TOTAL;
42750 + break;
42751 + case (e_FM_PORT_COUNTERS_DEQ_TOTAL):
42752 + queueType = E_FMAN_PORT_DEQ_TOTAL;
42753 + break;
42754 + case (e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT):
42755 + queueType = E_FMAN_PORT_DEQ_FROM_DFLT;
42756 + break;
42757 + case (e_FM_PORT_COUNTERS_DEQ_CONFIRM):
42758 + queueType = E_FMAN_PORT_DEQ_CONFIRM;
42759 + break;
42760 + default:
42761 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
42762 + ("Requested counter is not available"));
42763 + }
42764 +
42765 + fman_port_set_qmi_counter(&p_FmPort->port, queueType, value);
42766 + }
42767 +
42768 + return E_OK;
42769 +}
42770 +
42771 +uint32_t FM_PORT_GetAllocBufCounter(t_Handle h_FmPort, uint8_t poolId)
42772 +{
42773 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42774 +
42775 + SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, 0);
42776 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
42777 +
42778 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX)
42779 + && (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
42780 + {
42781 + REPORT_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available for non-Rx ports"));
42782 + return 0;
42783 + }
42784 + return fman_port_get_bpool_counter(&p_FmPort->port, poolId);
42785 +}
42786 +
42787 +t_Error FM_PORT_ModifyAllocBufCounter(t_Handle h_FmPort, uint8_t poolId,
42788 + uint32_t value)
42789 +{
42790 + t_FmPort *p_FmPort = (t_FmPort *)h_FmPort;
42791 +
42792 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42793 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
42794 +
42795 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX)
42796 + && (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
42797 + RETURN_ERROR( MINOR, E_INVALID_STATE,
42798 + ("Requested counter is not available for non-Rx ports"));
42799 +
42800 + fman_port_set_bpool_counter(&p_FmPort->port, poolId, value);
42801 + return E_OK;
42802 +}
42803 +bool FM_PORT_IsStalled(t_Handle h_FmPort)
42804 +{
42805 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42806 + t_Error err;
42807 + bool isStalled;
42808 +
42809 + SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, FALSE);
42810 + SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE,
42811 + FALSE);
42812 +
42813 + err = FmIsPortStalled(p_FmPort->h_Fm, p_FmPort->hardwarePortId, &isStalled);
42814 + if (err != E_OK)
42815 + {
42816 + REPORT_ERROR(MAJOR, err, NO_MSG);
42817 + return TRUE;
42818 + }
42819 + return isStalled;
42820 +}
42821 +
42822 +t_Error FM_PORT_ReleaseStalled(t_Handle h_FmPort)
42823 +{
42824 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42825 +
42826 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42827 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
42828 +
42829 + return FmResumeStalledPort(p_FmPort->h_Fm, p_FmPort->hardwarePortId);
42830 +}
42831 +
42832 +t_Error FM_PORT_SetRxL4ChecksumVerify(t_Handle h_FmPort, bool l4Checksum)
42833 +{
42834 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42835 + int err;
42836 +
42837 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42838 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
42839 +
42840 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
42841 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
42842 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
42843 + ("available for Rx ports only"));
42844 +
42845 + if (l4Checksum)
42846 + err = fman_port_modify_rx_fd_bits(
42847 + &p_FmPort->port, (uint8_t)(BMI_PORT_RFNE_FRWD_DCL4C >> 24),
42848 + TRUE);
42849 + else
42850 + err = fman_port_modify_rx_fd_bits(
42851 + &p_FmPort->port, (uint8_t)(BMI_PORT_RFNE_FRWD_DCL4C >> 24),
42852 + FALSE);
42853 + if (err != 0)
42854 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_modify_rx_fd_bits"));
42855 +
42856 + return E_OK;
42857 +}
42858 +
42859 +/*****************************************************************************/
42860 +/* API Run-time PCD Control unit functions */
42861 +/*****************************************************************************/
42862 +
42863 +#if (DPAA_VERSION >= 11)
42864 +t_Error FM_PORT_VSPAlloc(t_Handle h_FmPort, t_FmPortVSPAllocParams *p_VSPParams)
42865 +{
42866 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42867 + t_Error err = E_OK;
42868 + volatile uint32_t *p_BmiStorageProfileId = NULL, *p_BmiVspe = NULL;
42869 + uint32_t tmpReg = 0, tmp = 0;
42870 + uint16_t hwStoragePrflId;
42871 +
42872 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
42873 + SANITY_CHECK_RETURN_ERROR(p_FmPort->h_Fm, E_INVALID_HANDLE);
42874 + /*for numOfProfiles = 0 don't call this function*/
42875 + SANITY_CHECK_RETURN_ERROR(p_VSPParams->numOfProfiles, E_INVALID_VALUE);
42876 + /*dfltRelativeId should be in the range of numOfProfiles*/
42877 + SANITY_CHECK_RETURN_ERROR(
42878 + p_VSPParams->dfltRelativeId < p_VSPParams->numOfProfiles,
42879 + E_INVALID_VALUE);
42880 + /*p_FmPort should be from Rx type or OP*/
42881 + SANITY_CHECK_RETURN_ERROR(
42882 + ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G) || (p_FmPort->portType == e_FM_PORT_TYPE_RX) || (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)),
42883 + E_INVALID_VALUE);
42884 + /*port should be disabled*/
42885 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->enabled, E_INVALID_STATE);
42886 + /*if its called for Rx port relevant Tx Port should be passed (initialized) too and it should be disabled*/
42887 + SANITY_CHECK_RETURN_ERROR(
42888 + ((p_VSPParams->h_FmTxPort && !((t_FmPort *)(p_VSPParams->h_FmTxPort))->enabled) || (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)),
42889 + E_INVALID_VALUE);
42890 + /*should be called before SetPCD - this port should be without PCD*/
42891 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->pcdEngines, E_INVALID_STATE);
42892 +
42893 + /*alloc window of VSPs for this port*/
42894 + err = FmVSPAllocForPort(p_FmPort->h_Fm, p_FmPort->portType,
42895 + p_FmPort->portId, p_VSPParams->numOfProfiles);
42896 + if (err != E_OK)
42897 + RETURN_ERROR(MAJOR, err, NO_MSG);
42898 +
42899 + /*get absolute VSP ID for dfltRelative*/
42900 + err = FmVSPGetAbsoluteProfileId(p_FmPort->h_Fm, p_FmPort->portType,
42901 + p_FmPort->portId,
42902 + p_VSPParams->dfltRelativeId,
42903 + &hwStoragePrflId);
42904 + if (err != E_OK)
42905 + RETURN_ERROR(MAJOR, err, NO_MSG);
42906 +
42907 + /*fill relevant registers for p_FmPort and relative TxPort in the case p_FmPort from Rx type*/
42908 + switch (p_FmPort->portType)
42909 + {
42910 + case (e_FM_PORT_TYPE_RX_10G):
42911 + case (e_FM_PORT_TYPE_RX):
42912 + p_BmiStorageProfileId =
42913 + &(((t_FmPort *)(p_VSPParams->h_FmTxPort))->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfqid);
42914 + p_BmiVspe =
42915 + &(((t_FmPort *)(p_VSPParams->h_FmTxPort))->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tfne);
42916 +
42917 + tmpReg = GET_UINT32(*p_BmiStorageProfileId) & ~BMI_SP_ID_MASK;
42918 + tmpReg |= (uint32_t)hwStoragePrflId << BMI_SP_ID_SHIFT;
42919 + WRITE_UINT32(*p_BmiStorageProfileId, tmpReg);
42920 +
42921 + tmpReg = GET_UINT32(*p_BmiVspe);
42922 + WRITE_UINT32(*p_BmiVspe, tmpReg | BMI_SP_EN);
42923 +
42924 + p_BmiStorageProfileId =
42925 + &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfqid;
42926 + p_BmiVspe = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rpp;
42927 + hwStoragePrflId = p_VSPParams->dfltRelativeId;
42928 + break;
42929 +
42930 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
42931 + tmpReg = NIA_ENG_BMI | NIA_BMI_AC_FETCH_ALL_FRAME;
42932 + WRITE_UINT32( p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndn,
42933 + tmpReg);
42934 +
42935 + p_BmiStorageProfileId =
42936 + &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofqid;
42937 + p_BmiVspe = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_opp;
42938 + tmp |= BMI_EBD_EN;
42939 + break;
42940 +
42941 + default:
42942 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
42943 + ("available for Rx and offline parsing ports only"));
42944 + }
42945 +
42946 + p_FmPort->vspe = TRUE;
42947 + p_FmPort->dfltRelativeId = p_VSPParams->dfltRelativeId;
42948 +
42949 + tmpReg = GET_UINT32(*p_BmiStorageProfileId) & ~BMI_SP_ID_MASK;
42950 + tmpReg |= (uint32_t)hwStoragePrflId << BMI_SP_ID_SHIFT;
42951 + WRITE_UINT32(*p_BmiStorageProfileId, tmpReg);
42952 +
42953 + tmpReg = GET_UINT32(*p_BmiVspe);
42954 + WRITE_UINT32(*p_BmiVspe, tmpReg | BMI_SP_EN | tmp);
42955 + return E_OK;
42956 +}
42957 +#endif /* (DPAA_VERSION >= 11) */
42958 +
42959 +t_Error FM_PORT_PcdPlcrAllocProfiles(t_Handle h_FmPort, uint16_t numOfProfiles)
42960 +{
42961 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42962 + t_Error err = E_OK;
42963 +
42964 + p_FmPort->h_FmPcd = FmGetPcdHandle(p_FmPort->h_Fm);
42965 + ASSERT_COND(p_FmPort->h_FmPcd);
42966 +
42967 + if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
42968 + {
42969 + DBG(TRACE, ("FM Port Try Lock - BUSY"));
42970 + return ERROR_CODE(E_BUSY);
42971 + }
42972 +
42973 + if (numOfProfiles)
42974 + {
42975 + err = FmPcdPlcrAllocProfiles(p_FmPort->h_FmPcd,
42976 + p_FmPort->hardwarePortId, numOfProfiles);
42977 + if (err)
42978 + RETURN_ERROR(MAJOR, err, NO_MSG);
42979 + }
42980 + /* set the port handle within the PCD policer, even if no profiles defined */
42981 + FmPcdPortRegister(p_FmPort->h_FmPcd, h_FmPort, p_FmPort->hardwarePortId);
42982 +
42983 + RELEASE_LOCK(p_FmPort->lock);
42984 +
42985 + return E_OK;
42986 +}
42987 +
42988 +t_Error FM_PORT_PcdPlcrFreeProfiles(t_Handle h_FmPort)
42989 +{
42990 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
42991 + t_Error err = E_OK;
42992 +
42993 + if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
42994 + {
42995 + DBG(TRACE, ("FM Port Try Lock - BUSY"));
42996 + return ERROR_CODE(E_BUSY);
42997 + }
42998 +
42999 + err = FmPcdPlcrFreeProfiles(p_FmPort->h_FmPcd, p_FmPort->hardwarePortId);
43000 +
43001 + RELEASE_LOCK(p_FmPort->lock);
43002 +
43003 + if (err)
43004 + RETURN_ERROR(MAJOR, err, NO_MSG);
43005 +
43006 + return E_OK;
43007 +}
43008 +
43009 +t_Error FM_PORT_PcdKgModifyInitialScheme(t_Handle h_FmPort,
43010 + t_FmPcdKgSchemeSelect *p_FmPcdKgScheme)
43011 +{
43012 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
43013 + volatile uint32_t *p_BmiHpnia = NULL;
43014 + uint32_t tmpReg;
43015 + uint8_t relativeSchemeId;
43016 + uint8_t physicalSchemeId;
43017 +
43018 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
43019 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
43020 + SANITY_CHECK_RETURN_ERROR(p_FmPort->pcdEngines & FM_PCD_KG,
43021 + E_INVALID_STATE);
43022 +
43023 + tmpReg = (uint32_t)((p_FmPort->pcdEngines & FM_PCD_CC) ? NIA_KG_CC_EN : 0);
43024 + switch (p_FmPort->portType)
43025 + {
43026 + case (e_FM_PORT_TYPE_RX_10G):
43027 + case (e_FM_PORT_TYPE_RX):
43028 + p_BmiHpnia = &p_FmPort->port.bmi_regs->rx.fmbm_rfpne;
43029 + break;
43030 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
43031 + p_BmiHpnia = &p_FmPort->port.bmi_regs->oh.fmbm_ofpne;
43032 + break;
43033 + default:
43034 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
43035 + ("available for Rx and offline parsing ports only"));
43036 + }
43037 +
43038 + if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
43039 + {
43040 + DBG(TRACE, ("FM Port Try Lock - BUSY"));
43041 + return ERROR_CODE(E_BUSY);
43042 + }
43043 +
43044 + /* if we want to change to direct scheme, we need to check that this scheme is valid */
43045 + if (p_FmPcdKgScheme->direct)
43046 + {
43047 + physicalSchemeId = FmPcdKgGetSchemeId(p_FmPcdKgScheme->h_DirectScheme);
43048 + /* check that this scheme is bound to this port */
43049 + if (!(p_FmPort->schemesPerPortVector
43050 + & (uint32_t)(1 << (31 - (uint32_t)physicalSchemeId))))
43051 + {
43052 + RELEASE_LOCK(p_FmPort->lock);
43053 + RETURN_ERROR(
43054 + MAJOR, E_INVALID_STATE,
43055 + ("called with a scheme that is not bound to this port"));
43056 + }
43057 +
43058 + relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPort->h_FmPcd,
43059 + physicalSchemeId);
43060 + if (relativeSchemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
43061 + {
43062 + RELEASE_LOCK(p_FmPort->lock);
43063 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE,
43064 + ("called with invalid Scheme "));
43065 + }
43066 +
43067 + if (!FmPcdKgIsSchemeValidSw(p_FmPcdKgScheme->h_DirectScheme))
43068 + {
43069 + RELEASE_LOCK(p_FmPort->lock);
43070 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
43071 + ("called with uninitialized Scheme "));
43072 + }
43073 +
43074 + WRITE_UINT32(
43075 + *p_BmiHpnia,
43076 + NIA_ENG_KG | tmpReg | NIA_KG_DIRECT | (uint32_t)physicalSchemeId);
43077 + }
43078 + else
43079 + /* change to indirect scheme */
43080 + WRITE_UINT32(*p_BmiHpnia, NIA_ENG_KG | tmpReg);
43081 + RELEASE_LOCK(p_FmPort->lock);
43082 +
43083 + return E_OK;
43084 +}
43085 +
43086 +t_Error FM_PORT_PcdPlcrModifyInitialProfile(t_Handle h_FmPort,
43087 + t_Handle h_Profile)
43088 +{
43089 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
43090 + volatile uint32_t *p_BmiNia;
43091 + volatile uint32_t *p_BmiHpnia;
43092 + uint32_t tmpReg;
43093 + uint16_t absoluteProfileId = FmPcdPlcrProfileGetAbsoluteId(h_Profile);
43094 +
43095 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
43096 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
43097 + SANITY_CHECK_RETURN_ERROR(p_FmPort->pcdEngines & FM_PCD_PLCR,
43098 + E_INVALID_STATE);
43099 +
43100 + /* check relevance of this routine - only when policer is used
43101 + directly after BMI or Parser */
43102 + if ((p_FmPort->pcdEngines & FM_PCD_KG)
43103 + || (p_FmPort->pcdEngines & FM_PCD_CC))
43104 + RETURN_ERROR(
43105 + MAJOR,
43106 + E_INVALID_STATE,
43107 + ("relevant only when PCD support mode is e_FM_PCD_SUPPORT_PLCR_ONLY or e_FM_PCD_SUPPORT_PRS_AND_PLCR"));
43108 +
43109 + switch (p_FmPort->portType)
43110 + {
43111 + case (e_FM_PORT_TYPE_RX_10G):
43112 + case (e_FM_PORT_TYPE_RX):
43113 + p_BmiNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfne;
43114 + p_BmiHpnia = &p_FmPort->port.bmi_regs->rx.fmbm_rfpne;
43115 + tmpReg = GET_UINT32(*p_BmiNia) & BMI_RFNE_FDCS_MASK;
43116 + break;
43117 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
43118 + p_BmiNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofne;
43119 + p_BmiHpnia = &p_FmPort->port.bmi_regs->oh.fmbm_ofpne;
43120 + tmpReg = 0;
43121 + break;
43122 + default:
43123 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
43124 + ("available for Rx and offline parsing ports only"));
43125 + }
43126 +
43127 + if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
43128 + {
43129 + DBG(TRACE, ("FM Port Try Lock - BUSY"));
43130 + return ERROR_CODE(E_BUSY);
43131 + }
43132 +
43133 + if (!FmPcdPlcrIsProfileValid(p_FmPort->h_FmPcd, absoluteProfileId))
43134 + {
43135 + RELEASE_LOCK(p_FmPort->lock);
43136 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("Invalid profile"));
43137 + }
43138 +
43139 + tmpReg |= (uint32_t)(NIA_ENG_PLCR | NIA_PLCR_ABSOLUTE | absoluteProfileId);
43140 +
43141 + if (p_FmPort->pcdEngines & FM_PCD_PRS) /* e_FM_PCD_SUPPORT_PRS_AND_PLCR */
43142 + {
43143 + /* update BMI HPNIA */
43144 + WRITE_UINT32(*p_BmiHpnia, tmpReg);
43145 + }
43146 + else /* e_FM_PCD_SUPPORT_PLCR_ONLY */
43147 + {
43148 + /* rfne may contain FDCS bits, so first we read them. */
43149 + tmpReg |= (GET_UINT32(*p_BmiNia) & BMI_RFNE_FDCS_MASK);
43150 + /* update BMI NIA */
43151 + WRITE_UINT32(*p_BmiNia, tmpReg);
43152 + }RELEASE_LOCK(p_FmPort->lock);
43153 +
43154 + return E_OK;
43155 +}
43156 +
43157 +t_Error FM_PORT_PcdCcModifyTree(t_Handle h_FmPort, t_Handle h_CcTree)
43158 +{
43159 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
43160 + t_Error err = E_OK;
43161 + volatile uint32_t *p_BmiCcBase = NULL;
43162 + volatile uint32_t *p_BmiNia = NULL;
43163 + uint32_t ccTreePhysOffset;
43164 +
43165 + SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
43166 + SANITY_CHECK_RETURN_ERROR(h_CcTree, E_INVALID_HANDLE);
43167 +
43168 + if (p_FmPort->imEn)
43169 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
43170 + ("available for non-independent mode ports only"));
43171 +
43172 + /* get PCD registers pointers */
43173 + switch (p_FmPort->portType)
43174 + {
43175 + case (e_FM_PORT_TYPE_RX_10G):
43176 + case (e_FM_PORT_TYPE_RX):
43177 + p_BmiNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfne;
43178 + break;
43179 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
43180 + p_BmiNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofne;
43181 + break;
43182 + default:
43183 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
43184 + ("available for Rx and offline parsing ports only"));
43185 + }
43186 +
43187 + /* check that current NIA is BMI to BMI */
43188 + if ((GET_UINT32(*p_BmiNia) & ~BMI_RFNE_FDCS_MASK)
43189 + != GET_NIA_BMI_AC_ENQ_FRAME(p_FmPort->h_FmPcd))
43190 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
43191 + ("may be called only for ports in BMI-to-BMI state."));
43192 +
43193 + if (p_FmPort->pcdEngines & FM_PCD_CC)
43194 + {
43195 + if (p_FmPort->h_IpReassemblyManip)
43196 + {
43197 + err = FmPcdCcTreeAddIPR(p_FmPort->h_FmPcd, h_CcTree, NULL,
43198 + p_FmPort->h_IpReassemblyManip, FALSE);
43199 + if (err != E_OK)
43200 + {
43201 + RETURN_ERROR(MAJOR, err, NO_MSG);
43202 + }
43203 + }
43204 + else
43205 + if (p_FmPort->h_CapwapReassemblyManip)
43206 + {
43207 + err = FmPcdCcTreeAddCPR(p_FmPort->h_FmPcd, h_CcTree, NULL,
43208 + p_FmPort->h_CapwapReassemblyManip,
43209 + FALSE);
43210 + if (err != E_OK)
43211 + {
43212 + RETURN_ERROR(MAJOR, err, NO_MSG);
43213 + }
43214 + }
43215 + switch (p_FmPort->portType)
43216 + {
43217 + case (e_FM_PORT_TYPE_RX_10G):
43218 + case (e_FM_PORT_TYPE_RX):
43219 + p_BmiCcBase = &p_FmPort->port.bmi_regs->rx.fmbm_rccb;
43220 + break;
43221 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
43222 + p_BmiCcBase = &p_FmPort->port.bmi_regs->oh.fmbm_occb;
43223 + break;
43224 + default:
43225 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
43226 + }
43227 +
43228 + if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
43229 + {
43230 + DBG(TRACE, ("FM Port Try Lock - BUSY"));
43231 + return ERROR_CODE(E_BUSY);
43232 + }
43233 + err = FmPcdCcBindTree(p_FmPort->h_FmPcd, NULL, h_CcTree,
43234 + &ccTreePhysOffset, h_FmPort);
43235 + if (err)
43236 + {
43237 + RELEASE_LOCK(p_FmPort->lock);
43238 + RETURN_ERROR(MAJOR, err, NO_MSG);
43239 + }WRITE_UINT32(*p_BmiCcBase, ccTreePhysOffset);
43240 +
43241 + p_FmPort->ccTreeId = h_CcTree;
43242 + RELEASE_LOCK(p_FmPort->lock);
43243 + }
43244 + else
43245 + RETURN_ERROR( MAJOR, E_INVALID_STATE,
43246 + ("Coarse Classification not defined for this port."));
43247 +
43248 + return E_OK;
43249 +}
43250 +
43251 +t_Error FM_PORT_AttachPCD(t_Handle h_FmPort)
43252 +{
43253 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
43254 + t_Error err = E_OK;
43255 +
43256 + SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
43257 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
43258 +
43259 + if (p_FmPort->imEn)
43260 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
43261 + ("available for non-independent mode ports only"));
43262 +
43263 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
43264 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
43265 + && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
43266 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
43267 + ("available for Rx and offline parsing ports only"));
43268 +
43269 + if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
43270 + {
43271 + DBG(TRACE, ("FM Port Try Lock - BUSY"));
43272 + return ERROR_CODE(E_BUSY);
43273 + }
43274 +
43275 + if (p_FmPort->h_ReassemblyTree)
43276 + p_FmPort->pcdEngines |= FM_PCD_CC;
43277 +
43278 + err = AttachPCD(h_FmPort);
43279 + RELEASE_LOCK(p_FmPort->lock);
43280 +
43281 + return err;
43282 +}
43283 +
43284 +t_Error FM_PORT_DetachPCD(t_Handle h_FmPort)
43285 +{
43286 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
43287 + t_Error err = E_OK;
43288 +
43289 + SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
43290 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
43291 +
43292 + if (p_FmPort->imEn)
43293 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
43294 + ("available for non-independent mode ports only"));
43295 +
43296 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
43297 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
43298 + && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
43299 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
43300 + ("available for Rx and offline parsing ports only"));
43301 +
43302 + if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
43303 + {
43304 + DBG(TRACE, ("FM Port Try Lock - BUSY"));
43305 + return ERROR_CODE(E_BUSY);
43306 + }
43307 +
43308 + err = DetachPCD(h_FmPort);
43309 + if (err != E_OK)
43310 + {
43311 + RELEASE_LOCK(p_FmPort->lock);
43312 + RETURN_ERROR(MAJOR, err, NO_MSG);
43313 + }
43314 +
43315 + if (p_FmPort->h_ReassemblyTree)
43316 + p_FmPort->pcdEngines &= ~FM_PCD_CC;
43317 + RELEASE_LOCK(p_FmPort->lock);
43318 +
43319 + return E_OK;
43320 +}
43321 +
43322 +t_Error FM_PORT_SetPCD(t_Handle h_FmPort, t_FmPortPcdParams *p_PcdParam)
43323 +{
43324 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
43325 + t_Error err = E_OK;
43326 + t_FmPortPcdParams modifiedPcdParams, *p_PcdParams;
43327 + t_FmPcdCcTreeParams *p_FmPcdCcTreeParams;
43328 + t_FmPortPcdCcParams fmPortPcdCcParams;
43329 + t_FmPortGetSetCcParams fmPortGetSetCcParams;
43330 +
43331 + SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
43332 + SANITY_CHECK_RETURN_ERROR(p_PcdParam, E_NULL_POINTER);
43333 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
43334 +
43335 + if (p_FmPort->imEn)
43336 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
43337 + ("available for non-independent mode ports only"));
43338 +
43339 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
43340 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
43341 + && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
43342 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
43343 + ("available for Rx and offline parsing ports only"));
43344 +
43345 + if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
43346 + {
43347 + DBG(TRACE, ("FM Port Try Lock - BUSY"));
43348 + return ERROR_CODE(E_BUSY);
43349 + }
43350 +
43351 + p_FmPort->h_FmPcd = FmGetPcdHandle(p_FmPort->h_Fm);
43352 + ASSERT_COND(p_FmPort->h_FmPcd);
43353 +
43354 + if (p_PcdParam->p_CcParams && !p_PcdParam->p_CcParams->h_CcTree)
43355 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE,
43356 + ("Tree handle must be given if CC is required"));
43357 +
43358 + memcpy(&modifiedPcdParams, p_PcdParam, sizeof(t_FmPortPcdParams));
43359 + p_PcdParams = &modifiedPcdParams;
43360 + if ((p_PcdParams->h_IpReassemblyManip)
43361 +#if (DPAA_VERSION >= 11)
43362 + || (p_PcdParams->h_CapwapReassemblyManip)
43363 +#endif /* (DPAA_VERSION >= 11) */
43364 + )
43365 + {
43366 + if ((p_PcdParams->pcdSupport != e_FM_PORT_PCD_SUPPORT_PRS_AND_KG)
43367 + && (p_PcdParams->pcdSupport
43368 + != e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC)
43369 + && (p_PcdParams->pcdSupport
43370 + != e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR)
43371 + && (p_PcdParams->pcdSupport
43372 + != e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR))
43373 + {
43374 + RELEASE_LOCK(p_FmPort->lock);
43375 + RETURN_ERROR( MAJOR, E_INVALID_STATE,
43376 + ("pcdSupport must have KG for supporting Reassembly"));
43377 + }
43378 + p_FmPort->h_IpReassemblyManip = p_PcdParams->h_IpReassemblyManip;
43379 +#if (DPAA_VERSION >= 11)
43380 + if ((p_PcdParams->h_IpReassemblyManip)
43381 + && (p_PcdParams->h_CapwapReassemblyManip))
43382 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
43383 + ("Either IP-R or CAPWAP-R is allowed"));
43384 + if ((p_PcdParams->h_CapwapReassemblyManip)
43385 + && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
43386 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
43387 + ("CAPWAP-R is allowed only on offline-port"));
43388 + if (p_PcdParams->h_CapwapReassemblyManip)
43389 + p_FmPort->h_CapwapReassemblyManip =
43390 + p_PcdParams->h_CapwapReassemblyManip;
43391 +#endif /* (DPAA_VERSION >= 11) */
43392 +
43393 + if (!p_PcdParams->p_CcParams)
43394 + {
43395 + if (!((p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_PRS_AND_KG)
43396 + || (p_PcdParams->pcdSupport
43397 + == e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR)))
43398 + {
43399 + RELEASE_LOCK(p_FmPort->lock);
43400 + RETURN_ERROR(
43401 + MAJOR,
43402 + E_INVALID_STATE,
43403 + ("PCD initialization structure is not consistent with pcdSupport"));
43404 + }
43405 +
43406 + /* No user-tree, need to build internal tree */
43407 + p_FmPcdCcTreeParams = (t_FmPcdCcTreeParams*)XX_Malloc(
43408 + sizeof(t_FmPcdCcTreeParams));
43409 + if (!p_FmPcdCcTreeParams)
43410 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("p_FmPcdCcTreeParams"));
43411 + memset(p_FmPcdCcTreeParams, 0, sizeof(t_FmPcdCcTreeParams));
43412 + p_FmPcdCcTreeParams->h_NetEnv = p_PcdParams->h_NetEnv;
43413 + p_FmPort->h_ReassemblyTree = FM_PCD_CcRootBuild(
43414 + p_FmPort->h_FmPcd, p_FmPcdCcTreeParams);
43415 +
43416 + if (!p_FmPort->h_ReassemblyTree)
43417 + {
43418 + RELEASE_LOCK(p_FmPort->lock);
43419 + XX_Free(p_FmPcdCcTreeParams);
43420 + RETURN_ERROR( MAJOR, E_INVALID_HANDLE,
43421 + ("FM_PCD_CcBuildTree for Reassembly failed"));
43422 + }
43423 + if (p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_PRS_AND_KG)
43424 + p_PcdParams->pcdSupport =
43425 + e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC;
43426 + else
43427 + p_PcdParams->pcdSupport =
43428 + e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR;
43429 +
43430 + memset(&fmPortPcdCcParams, 0, sizeof(t_FmPortPcdCcParams));
43431 + fmPortPcdCcParams.h_CcTree = p_FmPort->h_ReassemblyTree;
43432 + p_PcdParams->p_CcParams = &fmPortPcdCcParams;
43433 + XX_Free(p_FmPcdCcTreeParams);
43434 + }
43435 +
43436 + if (p_FmPort->h_IpReassemblyManip)
43437 + err = FmPcdCcTreeAddIPR(p_FmPort->h_FmPcd,
43438 + p_PcdParams->p_CcParams->h_CcTree,
43439 + p_PcdParams->h_NetEnv,
43440 + p_FmPort->h_IpReassemblyManip, TRUE);
43441 +#if (DPAA_VERSION >= 11)
43442 + else
43443 + if (p_FmPort->h_CapwapReassemblyManip)
43444 + err = FmPcdCcTreeAddCPR(p_FmPort->h_FmPcd,
43445 + p_PcdParams->p_CcParams->h_CcTree,
43446 + p_PcdParams->h_NetEnv,
43447 + p_FmPort->h_CapwapReassemblyManip,
43448 + TRUE);
43449 +#endif /* (DPAA_VERSION >= 11) */
43450 +
43451 + if (err != E_OK)
43452 + {
43453 + if (p_FmPort->h_ReassemblyTree)
43454 + {
43455 + FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
43456 + p_FmPort->h_ReassemblyTree = NULL;
43457 + }RELEASE_LOCK(p_FmPort->lock);
43458 + RETURN_ERROR(MAJOR, err, NO_MSG);
43459 + }
43460 + }
43461 +
43462 + if (!FmPcdLockTryLockAll(p_FmPort->h_FmPcd))
43463 + {
43464 + if (p_FmPort->h_ReassemblyTree)
43465 + {
43466 + FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
43467 + p_FmPort->h_ReassemblyTree = NULL;
43468 + }RELEASE_LOCK(p_FmPort->lock);
43469 + DBG(TRACE, ("Try LockAll - BUSY"));
43470 + return ERROR_CODE(E_BUSY);
43471 + }
43472 +
43473 + err = SetPcd(h_FmPort, p_PcdParams);
43474 + if (err)
43475 + {
43476 + if (p_FmPort->h_ReassemblyTree)
43477 + {
43478 + FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
43479 + p_FmPort->h_ReassemblyTree = NULL;
43480 + }
43481 + FmPcdLockUnlockAll(p_FmPort->h_FmPcd);
43482 + RELEASE_LOCK(p_FmPort->lock);
43483 + RETURN_ERROR(MAJOR, err, NO_MSG);
43484 + }
43485 +
43486 + if ((p_FmPort->pcdEngines & FM_PCD_PRS)
43487 + && (p_PcdParams->p_PrsParams->includeInPrsStatistics))
43488 + {
43489 + err = FmPcdPrsIncludePortInStatistics(p_FmPort->h_FmPcd,
43490 + p_FmPort->hardwarePortId, TRUE);
43491 + if (err)
43492 + {
43493 + DeletePcd(p_FmPort);
43494 + if (p_FmPort->h_ReassemblyTree)
43495 + {
43496 + FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
43497 + p_FmPort->h_ReassemblyTree = NULL;
43498 + }
43499 + FmPcdLockUnlockAll(p_FmPort->h_FmPcd);
43500 + RELEASE_LOCK(p_FmPort->lock);
43501 + RETURN_ERROR(MAJOR, err, NO_MSG);
43502 + }
43503 + p_FmPort->includeInPrsStatistics = TRUE;
43504 + }
43505 +
43506 + FmPcdIncNetEnvOwners(p_FmPort->h_FmPcd, p_FmPort->netEnvId);
43507 +
43508 + if (FmPcdIsAdvancedOffloadSupported(p_FmPort->h_FmPcd))
43509 + {
43510 + memset(&fmPortGetSetCcParams, 0, sizeof(t_FmPortGetSetCcParams));
43511 +
43512 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
43513 + {
43514 +#ifdef FM_KG_ERASE_FLOW_ID_ERRATA_FMAN_SW004
43515 + if ((p_FmPort->fmRevInfo.majorRev < 6) &&
43516 + (p_FmPort->pcdEngines & FM_PCD_KG))
43517 + {
43518 + int i;
43519 + for (i = 0; i<p_PcdParams->p_KgParams->numOfSchemes; i++)
43520 + /* The following function must be locked */
43521 + FmPcdKgCcGetSetParams(p_FmPort->h_FmPcd,
43522 + p_PcdParams->p_KgParams->h_Schemes[i],
43523 + UPDATE_KG_NIA_CC_WA,
43524 + 0);
43525 + }
43526 +#endif /* FM_KG_ERASE_FLOW_ID_ERRATA_FMAN_SW004 */
43527 +
43528 +#if (DPAA_VERSION >= 11)
43529 + {
43530 + t_FmPcdCtrlParamsPage *p_ParamsPage;
43531 +
43532 + FmPortSetGprFunc(p_FmPort, e_FM_PORT_GPR_MURAM_PAGE,
43533 + (void**)&p_ParamsPage);
43534 + ASSERT_COND(p_ParamsPage);
43535 + WRITE_UINT32(p_ParamsPage->postBmiFetchNia,
43536 + p_FmPort->savedBmiNia);
43537 + }
43538 +#endif /* (DPAA_VERSION >= 11) */
43539 +
43540 + /* Set post-bmi-fetch nia */
43541 + p_FmPort->savedBmiNia &= BMI_RFNE_FDCS_MASK;
43542 + p_FmPort->savedBmiNia |= (NIA_FM_CTL_AC_POST_BMI_FETCH
43543 + | NIA_ENG_FM_CTL);
43544 +
43545 + /* Set pre-bmi-fetch nia */
43546 + fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNDN;
43547 +#if (DPAA_VERSION >= 11)
43548 + fmPortGetSetCcParams.setCcParams.nia =
43549 + (NIA_FM_CTL_AC_PRE_BMI_FETCH_FULL_FRAME | NIA_ENG_FM_CTL);
43550 +#else
43551 + fmPortGetSetCcParams.setCcParams.nia = (NIA_FM_CTL_AC_PRE_BMI_FETCH_HEADER | NIA_ENG_FM_CTL);
43552 +#endif /* (DPAA_VERSION >= 11) */
43553 + if ((err = FmPortGetSetCcParams(p_FmPort, &fmPortGetSetCcParams))
43554 + != E_OK)
43555 + {
43556 + DeletePcd(p_FmPort);
43557 + if (p_FmPort->h_ReassemblyTree)
43558 + {
43559 + FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
43560 + p_FmPort->h_ReassemblyTree = NULL;
43561 + }
43562 + FmPcdLockUnlockAll(p_FmPort->h_FmPcd);
43563 + RELEASE_LOCK(p_FmPort->lock);
43564 + RETURN_ERROR(MAJOR, err, NO_MSG);
43565 + }
43566 + }
43567 +
43568 + FmPcdLockUnlockAll(p_FmPort->h_FmPcd);
43569 +
43570 + /* Set pop-to-next-step nia */
43571 +#if (DPAA_VERSION == 10)
43572 + if (p_FmPort->fmRevInfo.majorRev < 6)
43573 + {
43574 + fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNEN;
43575 + fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_POP_TO_N_STEP | NIA_ENG_FM_CTL;
43576 + }
43577 + else
43578 + {
43579 +#endif /* (DPAA_VERSION == 10) */
43580 + fmPortGetSetCcParams.getCcParams.type = GET_NIA_FPNE;
43581 +#if (DPAA_VERSION == 10)
43582 + }
43583 +#endif /* (DPAA_VERSION == 10) */
43584 + if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams))
43585 + != E_OK)
43586 + {
43587 + DeletePcd(p_FmPort);
43588 + if (p_FmPort->h_ReassemblyTree)
43589 + {
43590 + FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
43591 + p_FmPort->h_ReassemblyTree = NULL;
43592 + }RELEASE_LOCK(p_FmPort->lock);
43593 + RETURN_ERROR(MAJOR, err, NO_MSG);
43594 + }
43595 +
43596 + /* Set post-bmi-prepare-to-enq nia */
43597 + fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_FENE;
43598 + fmPortGetSetCcParams.setCcParams.nia = (NIA_FM_CTL_AC_POST_BMI_ENQ
43599 + | NIA_ENG_FM_CTL);
43600 + if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams))
43601 + != E_OK)
43602 + {
43603 + DeletePcd(p_FmPort);
43604 + if (p_FmPort->h_ReassemblyTree)
43605 + {
43606 + FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
43607 + p_FmPort->h_ReassemblyTree = NULL;
43608 + }RELEASE_LOCK(p_FmPort->lock);
43609 + RETURN_ERROR(MAJOR, err, NO_MSG);
43610 + }
43611 +
43612 + if ((p_FmPort->h_IpReassemblyManip)
43613 + || (p_FmPort->h_CapwapReassemblyManip))
43614 + {
43615 +#if (DPAA_VERSION == 10)
43616 + if (p_FmPort->fmRevInfo.majorRev < 6)
43617 + {
43618 + /* Overwrite post-bmi-prepare-to-enq nia */
43619 + fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_FENE;
43620 + fmPortGetSetCcParams.setCcParams.nia = (NIA_FM_CTL_AC_POST_BMI_ENQ_ORR | NIA_ENG_FM_CTL | NIA_ORDER_RESTOR);
43621 + fmPortGetSetCcParams.setCcParams.overwrite = TRUE;
43622 + }
43623 + else
43624 + {
43625 +#endif /* (DPAA_VERSION == 10) */
43626 + /* Set the ORR bit (for order-restoration) */
43627 + fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_FPNE;
43628 + fmPortGetSetCcParams.setCcParams.nia =
43629 + fmPortGetSetCcParams.getCcParams.nia | NIA_ORDER_RESTOR;
43630 +#if (DPAA_VERSION == 10)
43631 + }
43632 +#endif /* (DPAA_VERSION == 10) */
43633 + if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams))
43634 + != E_OK)
43635 + {
43636 + DeletePcd(p_FmPort);
43637 + if (p_FmPort->h_ReassemblyTree)
43638 + {
43639 + FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
43640 + p_FmPort->h_ReassemblyTree = NULL;
43641 + }RELEASE_LOCK(p_FmPort->lock);
43642 + RETURN_ERROR(MAJOR, err, NO_MSG);
43643 + }
43644 + }
43645 + }
43646 + else
43647 + FmPcdLockUnlockAll(p_FmPort->h_FmPcd);
43648 +
43649 +#if (DPAA_VERSION >= 11)
43650 + {
43651 + t_FmPcdCtrlParamsPage *p_ParamsPage;
43652 +
43653 + memset(&fmPortGetSetCcParams, 0, sizeof(t_FmPortGetSetCcParams));
43654 +
43655 + fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_CMNE;
43656 + if (FmPcdIsAdvancedOffloadSupported(p_FmPort->h_FmPcd))
43657 + fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_POP_TO_N_STEP
43658 + | NIA_ENG_FM_CTL;
43659 + else
43660 + fmPortGetSetCcParams.setCcParams.nia =
43661 + NIA_FM_CTL_AC_NO_IPACC_POP_TO_N_STEP | NIA_ENG_FM_CTL;
43662 + if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams))
43663 + != E_OK)
43664 + {
43665 + DeletePcd(p_FmPort);
43666 + if (p_FmPort->h_ReassemblyTree)
43667 + {
43668 + FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
43669 + p_FmPort->h_ReassemblyTree = NULL;
43670 + }RELEASE_LOCK(p_FmPort->lock);
43671 + RETURN_ERROR(MAJOR, err, NO_MSG);
43672 + }
43673 +
43674 + FmPortSetGprFunc(p_FmPort, e_FM_PORT_GPR_MURAM_PAGE,
43675 + (void**)&p_ParamsPage);
43676 + ASSERT_COND(p_ParamsPage);
43677 +
43678 + if (FmPcdIsAdvancedOffloadSupported(p_FmPort->h_FmPcd))
43679 + WRITE_UINT32(
43680 + p_ParamsPage->misc,
43681 + GET_UINT32(p_ParamsPage->misc) | FM_CTL_PARAMS_PAGE_OFFLOAD_SUPPORT_EN);
43682 +
43683 + if ((p_FmPort->h_IpReassemblyManip)
43684 + || (p_FmPort->h_CapwapReassemblyManip))
43685 + {
43686 + if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
43687 + WRITE_UINT32(
43688 + p_ParamsPage->discardMask,
43689 + GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsdm));
43690 + else
43691 + WRITE_UINT32(
43692 + p_ParamsPage->discardMask,
43693 + GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfsdm));
43694 + }
43695 +#ifdef FM_ERROR_VSP_NO_MATCH_SW006
43696 + if (p_FmPort->vspe)
43697 + WRITE_UINT32(
43698 + p_ParamsPage->misc,
43699 + GET_UINT32(p_ParamsPage->misc) | (p_FmPort->dfltRelativeId & FM_CTL_PARAMS_PAGE_ERROR_VSP_MASK));
43700 +#endif /* FM_ERROR_VSP_NO_MATCH_SW006 */
43701 + }
43702 +#endif /* (DPAA_VERSION >= 11) */
43703 +
43704 + err = AttachPCD(h_FmPort);
43705 + if (err)
43706 + {
43707 + DeletePcd(p_FmPort);
43708 + if (p_FmPort->h_ReassemblyTree)
43709 + {
43710 + FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
43711 + p_FmPort->h_ReassemblyTree = NULL;
43712 + }RELEASE_LOCK(p_FmPort->lock);
43713 + RETURN_ERROR(MAJOR, err, NO_MSG);
43714 + }
43715 +
43716 + RELEASE_LOCK(p_FmPort->lock);
43717 +
43718 + return err;
43719 +}
43720 +
43721 +t_Error FM_PORT_DeletePCD(t_Handle h_FmPort)
43722 +{
43723 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
43724 + t_Error err = E_OK;
43725 +
43726 + SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
43727 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
43728 +
43729 + if (p_FmPort->imEn)
43730 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
43731 + ("available for non-independant mode ports only"));
43732 +
43733 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
43734 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
43735 + && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
43736 + RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
43737 + ("available for Rx and offline parsing ports only"));
43738 +
43739 + if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
43740 + {
43741 + DBG(TRACE, ("FM Port Try Lock - BUSY"));
43742 + return ERROR_CODE(E_BUSY);
43743 + }
43744 +
43745 + err = DetachPCD(h_FmPort);
43746 + if (err)
43747 + {
43748 + RELEASE_LOCK(p_FmPort->lock);
43749 + RETURN_ERROR(MAJOR, err, NO_MSG);
43750 + }
43751 +
43752 + FmPcdDecNetEnvOwners(p_FmPort->h_FmPcd, p_FmPort->netEnvId);
43753 +
43754 + /* we do it anyway, instead of checking if included */
43755 + if ((p_FmPort->pcdEngines & FM_PCD_PRS) && p_FmPort->includeInPrsStatistics)
43756 + {
43757 + FmPcdPrsIncludePortInStatistics(p_FmPort->h_FmPcd,
43758 + p_FmPort->hardwarePortId, FALSE);
43759 + p_FmPort->includeInPrsStatistics = FALSE;
43760 + }
43761 +
43762 + if (!FmPcdLockTryLockAll(p_FmPort->h_FmPcd))
43763 + {
43764 + RELEASE_LOCK(p_FmPort->lock);
43765 + DBG(TRACE, ("Try LockAll - BUSY"));
43766 + return ERROR_CODE(E_BUSY);
43767 + }
43768 +
43769 + err = DeletePcd(h_FmPort);
43770 + FmPcdLockUnlockAll(p_FmPort->h_FmPcd);
43771 + if (err)
43772 + {
43773 + RELEASE_LOCK(p_FmPort->lock);
43774 + RETURN_ERROR(MAJOR, err, NO_MSG);
43775 + }
43776 +
43777 + if (p_FmPort->h_ReassemblyTree)
43778 + {
43779 + err = FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
43780 + if (err)
43781 + {
43782 + RELEASE_LOCK(p_FmPort->lock);
43783 + RETURN_ERROR(MAJOR, err, NO_MSG);
43784 + }
43785 + p_FmPort->h_ReassemblyTree = NULL;
43786 + }RELEASE_LOCK(p_FmPort->lock);
43787 +
43788 + return err;
43789 +}
43790 +
43791 +t_Error FM_PORT_PcdKgBindSchemes(t_Handle h_FmPort,
43792 + t_FmPcdPortSchemesParams *p_PortScheme)
43793 +{
43794 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
43795 + t_FmPcdKgInterModuleBindPortToSchemes schemeBind;
43796 + t_Error err = E_OK;
43797 + uint32_t tmpScmVec = 0;
43798 + int i;
43799 +
43800 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
43801 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
43802 + SANITY_CHECK_RETURN_ERROR(p_FmPort->pcdEngines & FM_PCD_KG,
43803 + E_INVALID_STATE);
43804 +
43805 + schemeBind.netEnvId = p_FmPort->netEnvId;
43806 + schemeBind.hardwarePortId = p_FmPort->hardwarePortId;
43807 + schemeBind.numOfSchemes = p_PortScheme->numOfSchemes;
43808 + schemeBind.useClsPlan = p_FmPort->useClsPlan;
43809 + for (i = 0; i < schemeBind.numOfSchemes; i++)
43810 + {
43811 + schemeBind.schemesIds[i] = FmPcdKgGetSchemeId(
43812 + p_PortScheme->h_Schemes[i]);
43813 + /* build vector */
43814 + tmpScmVec |= 1 << (31 - (uint32_t)schemeBind.schemesIds[i]);
43815 + }
43816 +
43817 + if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
43818 + {
43819 + DBG(TRACE, ("FM Port Try Lock - BUSY"));
43820 + return ERROR_CODE(E_BUSY);
43821 + }
43822 +
43823 + err = FmPcdKgBindPortToSchemes(p_FmPort->h_FmPcd, &schemeBind);
43824 + if (err == E_OK)
43825 + p_FmPort->schemesPerPortVector |= tmpScmVec;
43826 +
43827 +#ifdef FM_KG_ERASE_FLOW_ID_ERRATA_FMAN_SW004
43828 + if ((FmPcdIsAdvancedOffloadSupported(p_FmPort->h_FmPcd)) &&
43829 + (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) &&
43830 + (p_FmPort->fmRevInfo.majorRev < 6))
43831 + {
43832 + for (i=0; i<p_PortScheme->numOfSchemes; i++)
43833 + FmPcdKgCcGetSetParams(p_FmPort->h_FmPcd, p_PortScheme->h_Schemes[i], UPDATE_KG_NIA_CC_WA, 0);
43834 + }
43835 +#endif /* FM_KG_ERASE_FLOW_ID_ERRATA_FMAN_SW004 */
43836 +
43837 + RELEASE_LOCK(p_FmPort->lock);
43838 +
43839 + return err;
43840 +}
43841 +
43842 +t_Error FM_PORT_PcdKgUnbindSchemes(t_Handle h_FmPort,
43843 + t_FmPcdPortSchemesParams *p_PortScheme)
43844 +{
43845 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
43846 + t_FmPcdKgInterModuleBindPortToSchemes schemeBind;
43847 + t_Error err = E_OK;
43848 + uint32_t tmpScmVec = 0;
43849 + int i;
43850 +
43851 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
43852 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
43853 + SANITY_CHECK_RETURN_ERROR(p_FmPort->pcdEngines & FM_PCD_KG,
43854 + E_INVALID_STATE);
43855 +
43856 + schemeBind.netEnvId = p_FmPort->netEnvId;
43857 + schemeBind.hardwarePortId = p_FmPort->hardwarePortId;
43858 + schemeBind.numOfSchemes = p_PortScheme->numOfSchemes;
43859 + for (i = 0; i < schemeBind.numOfSchemes; i++)
43860 + {
43861 + schemeBind.schemesIds[i] = FmPcdKgGetSchemeId(
43862 + p_PortScheme->h_Schemes[i]);
43863 + /* build vector */
43864 + tmpScmVec |= 1 << (31 - (uint32_t)schemeBind.schemesIds[i]);
43865 + }
43866 +
43867 + if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
43868 + {
43869 + DBG(TRACE, ("FM Port Try Lock - BUSY"));
43870 + return ERROR_CODE(E_BUSY);
43871 + }
43872 +
43873 + err = FmPcdKgUnbindPortToSchemes(p_FmPort->h_FmPcd, &schemeBind);
43874 + if (err == E_OK)
43875 + p_FmPort->schemesPerPortVector &= ~tmpScmVec;
43876 + RELEASE_LOCK(p_FmPort->lock);
43877 +
43878 + return err;
43879 +}
43880 +
43881 +t_Error FM_PORT_AddCongestionGrps(t_Handle h_FmPort,
43882 + t_FmPortCongestionGrps *p_CongestionGrps)
43883 +{
43884 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
43885 + uint8_t priorityTmpArray[FM_PORT_NUM_OF_CONGESTION_GRPS];
43886 + uint8_t mod, index;
43887 + uint32_t i, grpsMap[FMAN_PORT_CG_MAP_NUM];
43888 + int err;
43889 +#if (DPAA_VERSION >= 11)
43890 + int j;
43891 +#endif /* (DPAA_VERSION >= 11) */
43892 +
43893 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
43894 +
43895 + /* un-necessary check of the indexes; probably will be needed in the future when there
43896 + will be more CGs available ....
43897 + for (i=0; i<p_CongestionGrps->numOfCongestionGrpsToConsider; i++)
43898 + if (p_CongestionGrps->congestionGrpsToConsider[i] >= FM_PORT_NUM_OF_CONGESTION_GRPS)
43899 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("CG id!"));
43900 + */
43901 +
43902 +#ifdef FM_NO_OP_OBSERVED_CGS
43903 + if ((p_FmPort->fmRevInfo.majorRev != 4) &&
43904 + (p_FmPort->fmRevInfo.majorRev < 6))
43905 + {
43906 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
43907 + (p_FmPort->portType != e_FM_PORT_TYPE_RX))
43908 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Available for Rx ports only"));
43909 + }
43910 + else
43911 +#endif /* FM_NO_OP_OBSERVED_CGS */
43912 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
43913 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
43914 + && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
43915 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
43916 + ("Available for Rx & OP ports only"));
43917 +
43918 + /* Prepare groups map array */
43919 + memset(grpsMap, 0, FMAN_PORT_CG_MAP_NUM * sizeof(uint32_t));
43920 + for (i = 0; i < p_CongestionGrps->numOfCongestionGrpsToConsider; i++)
43921 + {
43922 + index = (uint8_t)(p_CongestionGrps->congestionGrpsToConsider[i] / 32);
43923 + mod = (uint8_t)(p_CongestionGrps->congestionGrpsToConsider[i] % 32);
43924 + if (p_FmPort->fmRevInfo.majorRev != 4)
43925 + grpsMap[7 - index] |= (uint32_t)(1 << mod);
43926 + else
43927 + grpsMap[0] |= (uint32_t)(1 << mod);
43928 + }
43929 +
43930 + memset(&priorityTmpArray, 0,
43931 + FM_PORT_NUM_OF_CONGESTION_GRPS * sizeof(uint8_t));
43932 +
43933 + for (i = 0; i < p_CongestionGrps->numOfCongestionGrpsToConsider; i++)
43934 + {
43935 +#if (DPAA_VERSION >= 11)
43936 + for (j = 0; j < FM_MAX_NUM_OF_PFC_PRIORITIES; j++)
43937 + if (p_CongestionGrps->pfcPrioritiesEn[i][j])
43938 + priorityTmpArray[p_CongestionGrps->congestionGrpsToConsider[i]] |=
43939 + (0x01 << (FM_MAX_NUM_OF_PFC_PRIORITIES - j - 1));
43940 +#endif /* (DPAA_VERSION >= 11) */
43941 + }
43942 +
43943 +#if (DPAA_VERSION >= 11)
43944 + for (i = 0; i < FM_PORT_NUM_OF_CONGESTION_GRPS; i++)
43945 + {
43946 + err = FmSetCongestionGroupPFCpriority(p_FmPort->h_Fm, i,
43947 + priorityTmpArray[i]);
43948 + if (err)
43949 + return err;
43950 + }
43951 +#endif /* (DPAA_VERSION >= 11) */
43952 +
43953 + err = fman_port_add_congestion_grps(&p_FmPort->port, grpsMap);
43954 + if (err != 0)
43955 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_add_congestion_grps"));
43956 +
43957 + return E_OK;
43958 +}
43959 +
43960 +t_Error FM_PORT_RemoveCongestionGrps(t_Handle h_FmPort,
43961 + t_FmPortCongestionGrps *p_CongestionGrps)
43962 +{
43963 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
43964 + uint8_t mod, index;
43965 + uint32_t i, grpsMap[FMAN_PORT_CG_MAP_NUM];
43966 + int err;
43967 +
43968 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
43969 +
43970 + {
43971 +#ifdef FM_NO_OP_OBSERVED_CGS
43972 + t_FmRevisionInfo revInfo;
43973 +
43974 + FM_GetRevision(p_FmPort->h_Fm, &revInfo);
43975 + if (revInfo.majorRev != 4)
43976 + {
43977 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
43978 + (p_FmPort->portType != e_FM_PORT_TYPE_RX))
43979 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Available for Rx ports only"));
43980 + }
43981 + else
43982 +#endif /* FM_NO_OP_OBSERVED_CGS */
43983 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
43984 + && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
43985 + && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
43986 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
43987 + ("Available for Rx & OP ports only"));
43988 + }
43989 +
43990 + /* Prepare groups map array */
43991 + memset(grpsMap, 0, FMAN_PORT_CG_MAP_NUM * sizeof(uint32_t));
43992 + for (i = 0; i < p_CongestionGrps->numOfCongestionGrpsToConsider; i++)
43993 + {
43994 + index = (uint8_t)(p_CongestionGrps->congestionGrpsToConsider[i] / 32);
43995 + mod = (uint8_t)(p_CongestionGrps->congestionGrpsToConsider[i] % 32);
43996 + if (p_FmPort->fmRevInfo.majorRev != 4)
43997 + grpsMap[7 - index] |= (uint32_t)(1 << mod);
43998 + else
43999 + grpsMap[0] |= (uint32_t)(1 << mod);
44000 + }
44001 +
44002 +#if (DPAA_VERSION >= 11)
44003 + for (i = 0; i < p_CongestionGrps->numOfCongestionGrpsToConsider; i++)
44004 + {
44005 + t_Error err = FmSetCongestionGroupPFCpriority(
44006 + p_FmPort->h_Fm, p_CongestionGrps->congestionGrpsToConsider[i],
44007 + 0);
44008 + if (err)
44009 + return err;
44010 + }
44011 +#endif /* (DPAA_VERSION >= 11) */
44012 +
44013 + err = fman_port_remove_congestion_grps(&p_FmPort->port, grpsMap);
44014 + if (err != 0)
44015 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
44016 + ("fman_port_remove_congestion_grps"));
44017 + return E_OK;
44018 +}
44019 +
44020 +#if (DPAA_VERSION >= 11)
44021 +t_Error FM_PORT_GetIPv4OptionsCount(t_Handle h_FmPort,
44022 + uint32_t *p_Ipv4OptionsCount)
44023 +{
44024 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
44025 +
44026 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
44027 + SANITY_CHECK_RETURN_ERROR(
44028 + (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING),
44029 + E_INVALID_VALUE);
44030 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_ParamsPage, E_INVALID_STATE);
44031 + SANITY_CHECK_RETURN_ERROR(p_Ipv4OptionsCount, E_NULL_POINTER);
44032 +
44033 + *p_Ipv4OptionsCount = GET_UINT32(p_FmPort->p_ParamsPage->ipfOptionsCounter);
44034 +
44035 + return E_OK;
44036 +}
44037 +#endif /* (DPAA_VERSION >= 11) */
44038 +
44039 +t_Error FM_PORT_ConfigDsarSupport(t_Handle h_FmPortRx,
44040 + t_FmPortDsarTablesSizes *params)
44041 +{
44042 + t_FmPort *p_FmPort = (t_FmPort *)h_FmPortRx;
44043 + p_FmPort->deepSleepVars.autoResMaxSizes = XX_Malloc(
44044 + sizeof(struct t_FmPortDsarTablesSizes));
44045 + memcpy(p_FmPort->deepSleepVars.autoResMaxSizes, params,
44046 + sizeof(struct t_FmPortDsarTablesSizes));
44047 + return E_OK;
44048 +}
44049 +
44050 +static t_Error FmPortConfigAutoResForDeepSleepSupport1(t_FmPort *p_FmPort)
44051 +{
44052 + uint32_t *param_page;
44053 + t_FmPortDsarTablesSizes *params = p_FmPort->deepSleepVars.autoResMaxSizes;
44054 + t_ArCommonDesc *ArCommonDescPtr;
44055 + uint32_t size = sizeof(t_ArCommonDesc);
44056 + // ARP
44057 + // should put here if (params->max_num_of_arp_entries)?
44058 + size = ROUND_UP(size,4);
44059 + size += sizeof(t_DsarArpDescriptor);
44060 + size += sizeof(t_DsarArpBindingEntry) * params->maxNumOfArpEntries;
44061 + size += sizeof(t_DsarArpStatistics);
44062 + //ICMPV4
44063 + size = ROUND_UP(size,4);
44064 + size += sizeof(t_DsarIcmpV4Descriptor);
44065 + size += sizeof(t_DsarIcmpV4BindingEntry) * params->maxNumOfEchoIpv4Entries;
44066 + size += sizeof(t_DsarIcmpV4Statistics);
44067 + //ICMPV6
44068 + size = ROUND_UP(size,4);
44069 + size += sizeof(t_DsarIcmpV6Descriptor);
44070 + size += sizeof(t_DsarIcmpV6BindingEntry) * params->maxNumOfEchoIpv6Entries;
44071 + size += sizeof(t_DsarIcmpV6Statistics);
44072 + //ND
44073 + size = ROUND_UP(size,4);
44074 + size += sizeof(t_DsarNdDescriptor);
44075 + size += sizeof(t_DsarIcmpV6BindingEntry) * params->maxNumOfNdpEntries;
44076 + size += sizeof(t_DsarIcmpV6Statistics);
44077 + //SNMP
44078 + size = ROUND_UP(size,4);
44079 + size += sizeof(t_DsarSnmpDescriptor);
44080 + size += sizeof(t_DsarSnmpIpv4AddrTblEntry)
44081 + * params->maxNumOfSnmpIPV4Entries;
44082 + size += sizeof(t_DsarSnmpIpv6AddrTblEntry)
44083 + * params->maxNumOfSnmpIPV6Entries;
44084 + size += sizeof(t_OidsTblEntry) * params->maxNumOfSnmpOidEntries;
44085 + size += params->maxNumOfSnmpOidChar;
44086 + size += sizeof(t_DsarIcmpV6Statistics);
44087 + //filters
44088 + size = ROUND_UP(size,4);
44089 + size += params->maxNumOfIpProtFiltering;
44090 + size = ROUND_UP(size,4);
44091 + size += params->maxNumOfUdpPortFiltering * sizeof(t_PortTblEntry);
44092 + size = ROUND_UP(size,4);
44093 + size += params->maxNumOfTcpPortFiltering * sizeof(t_PortTblEntry);
44094 +
44095 + // add here for more protocols
44096 +
44097 + // statistics
44098 + size = ROUND_UP(size,4);
44099 + size += sizeof(t_ArStatistics);
44100 +
44101 + ArCommonDescPtr = FM_MURAM_AllocMem(p_FmPort->h_FmMuram, size, 0x10);
44102 +
44103 + param_page =
44104 + XX_PhysToVirt(
44105 + p_FmPort->fmMuramPhysBaseAddr
44106 + + GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rgpr));
44107 + WRITE_UINT32(
44108 + *param_page,
44109 + (uint32_t)(XX_VirtToPhys(ArCommonDescPtr) - p_FmPort->fmMuramPhysBaseAddr));
44110 + return E_OK;
44111 +}
44112 +
44113 +t_FmPortDsarTablesSizes* FM_PORT_GetDsarTablesMaxSizes(t_Handle h_FmPortRx)
44114 +{
44115 + t_FmPort *p_FmPort = (t_FmPort *)h_FmPortRx;
44116 + return p_FmPort->deepSleepVars.autoResMaxSizes;
44117 +}
44118 +
44119 +struct arOffsets
44120 +{
44121 + uint32_t arp;
44122 + uint32_t nd;
44123 + uint32_t icmpv4;
44124 + uint32_t icmpv6;
44125 + uint32_t snmp;
44126 + uint32_t stats;
44127 + uint32_t filtIp;
44128 + uint32_t filtUdp;
44129 + uint32_t filtTcp;
44130 +};
44131 +
44132 +static uint32_t AR_ComputeOffsets(struct arOffsets* of,
44133 + struct t_FmPortDsarParams *params,
44134 + t_FmPort *p_FmPort)
44135 +{
44136 + uint32_t size = sizeof(t_ArCommonDesc);
44137 + // ARP
44138 + if (params->p_AutoResArpInfo)
44139 + {
44140 + size = ROUND_UP(size,4);
44141 + of->arp = size;
44142 + size += sizeof(t_DsarArpDescriptor);
44143 + size += sizeof(t_DsarArpBindingEntry)
44144 + * params->p_AutoResArpInfo->tableSize;
44145 + size += sizeof(t_DsarArpStatistics);
44146 + }
44147 + // ICMPV4
44148 + if (params->p_AutoResEchoIpv4Info)
44149 + {
44150 + size = ROUND_UP(size,4);
44151 + of->icmpv4 = size;
44152 + size += sizeof(t_DsarIcmpV4Descriptor);
44153 + size += sizeof(t_DsarIcmpV4BindingEntry)
44154 + * params->p_AutoResEchoIpv4Info->tableSize;
44155 + size += sizeof(t_DsarIcmpV4Statistics);
44156 + }
44157 + // ICMPV6
44158 + if (params->p_AutoResEchoIpv6Info)
44159 + {
44160 + size = ROUND_UP(size,4);
44161 + of->icmpv6 = size;
44162 + size += sizeof(t_DsarIcmpV6Descriptor);
44163 + size += sizeof(t_DsarIcmpV6BindingEntry)
44164 + * params->p_AutoResEchoIpv6Info->tableSize;
44165 + size += sizeof(t_DsarIcmpV6Statistics);
44166 + }
44167 + // ND
44168 + if (params->p_AutoResNdpInfo)
44169 + {
44170 + size = ROUND_UP(size,4);
44171 + of->nd = size;
44172 + size += sizeof(t_DsarNdDescriptor);
44173 + size += sizeof(t_DsarIcmpV6BindingEntry)
44174 + * (params->p_AutoResNdpInfo->tableSizeAssigned
44175 + + params->p_AutoResNdpInfo->tableSizeTmp);
44176 + size += sizeof(t_DsarIcmpV6Statistics);
44177 + }
44178 + // SNMP
44179 + if (params->p_AutoResSnmpInfo)
44180 + {
44181 + size = ROUND_UP(size,4);
44182 + of->snmp = size;
44183 + size += sizeof(t_DsarSnmpDescriptor);
44184 + size += sizeof(t_DsarSnmpIpv4AddrTblEntry)
44185 + * params->p_AutoResSnmpInfo->numOfIpv4Addresses;
44186 + size += sizeof(t_DsarSnmpIpv6AddrTblEntry)
44187 + * params->p_AutoResSnmpInfo->numOfIpv6Addresses;
44188 + size += sizeof(t_OidsTblEntry) * params->p_AutoResSnmpInfo->oidsTblSize;
44189 + size += p_FmPort->deepSleepVars.autoResMaxSizes->maxNumOfSnmpOidChar;
44190 + size += sizeof(t_DsarIcmpV6Statistics);
44191 + }
44192 + //filters
44193 + size = ROUND_UP(size,4);
44194 + if (params->p_AutoResFilteringInfo)
44195 + {
44196 + of->filtIp = size;
44197 + size += params->p_AutoResFilteringInfo->ipProtTableSize;
44198 + size = ROUND_UP(size,4);
44199 + of->filtUdp = size;
44200 + size += params->p_AutoResFilteringInfo->udpPortsTableSize
44201 + * sizeof(t_PortTblEntry);
44202 + size = ROUND_UP(size,4);
44203 + of->filtTcp = size;
44204 + size += params->p_AutoResFilteringInfo->tcpPortsTableSize
44205 + * sizeof(t_PortTblEntry);
44206 + }
44207 + // add here for more protocols
44208 + // statistics
44209 + size = ROUND_UP(size,4);
44210 + of->stats = size;
44211 + size += sizeof(t_ArStatistics);
44212 + return size;
44213 +}
44214 +
44215 +uint32_t* ARDesc;
44216 +void PrsEnable(t_Handle p_FmPcd);
44217 +void PrsDisable(t_Handle p_FmPcd);
44218 +int PrsIsEnabled(t_Handle p_FmPcd);
44219 +t_Handle FM_PCD_GetHcPort(t_Handle h_FmPcd);
44220 +
44221 +static t_Error DsarCheckParams(t_FmPortDsarParams *params,
44222 + t_FmPortDsarTablesSizes *sizes)
44223 +{
44224 + bool macInit = FALSE;
44225 + uint8_t mac[6];
44226 + int i = 0;
44227 +
44228 + // check table sizes
44229 + if (params->p_AutoResArpInfo
44230 + && sizes->maxNumOfArpEntries < params->p_AutoResArpInfo->tableSize)
44231 + RETURN_ERROR(
44232 + MAJOR, E_INVALID_VALUE,
44233 + ("DSAR: Arp table size exceeds the configured maximum size."));
44234 + if (params->p_AutoResEchoIpv4Info
44235 + && sizes->maxNumOfEchoIpv4Entries
44236 + < params->p_AutoResEchoIpv4Info->tableSize)
44237 + RETURN_ERROR(
44238 + MAJOR,
44239 + E_INVALID_VALUE,
44240 + ("DSAR: EchoIpv4 table size exceeds the configured maximum size."));
44241 + if (params->p_AutoResNdpInfo
44242 + && sizes->maxNumOfNdpEntries
44243 + < params->p_AutoResNdpInfo->tableSizeAssigned
44244 + + params->p_AutoResNdpInfo->tableSizeTmp)
44245 + RETURN_ERROR(
44246 + MAJOR, E_INVALID_VALUE,
44247 + ("DSAR: NDP table size exceeds the configured maximum size."));
44248 + if (params->p_AutoResEchoIpv6Info
44249 + && sizes->maxNumOfEchoIpv6Entries
44250 + < params->p_AutoResEchoIpv6Info->tableSize)
44251 + RETURN_ERROR(
44252 + MAJOR,
44253 + E_INVALID_VALUE,
44254 + ("DSAR: EchoIpv6 table size exceeds the configured maximum size."));
44255 + if (params->p_AutoResSnmpInfo
44256 + && sizes->maxNumOfSnmpOidEntries
44257 + < params->p_AutoResSnmpInfo->oidsTblSize)
44258 + RETURN_ERROR(
44259 + MAJOR,
44260 + E_INVALID_VALUE,
44261 + ("DSAR: Snmp Oid table size exceeds the configured maximum size."));
44262 + if (params->p_AutoResSnmpInfo
44263 + && sizes->maxNumOfSnmpIPV4Entries
44264 + < params->p_AutoResSnmpInfo->numOfIpv4Addresses)
44265 + RETURN_ERROR(
44266 + MAJOR,
44267 + E_INVALID_VALUE,
44268 + ("DSAR: Snmp ipv4 table size exceeds the configured maximum size."));
44269 + if (params->p_AutoResSnmpInfo
44270 + && sizes->maxNumOfSnmpIPV6Entries
44271 + < params->p_AutoResSnmpInfo->numOfIpv6Addresses)
44272 + RETURN_ERROR(
44273 + MAJOR,
44274 + E_INVALID_VALUE,
44275 + ("DSAR: Snmp ipv6 table size exceeds the configured maximum size."));
44276 + if (params->p_AutoResFilteringInfo)
44277 + {
44278 + if (sizes->maxNumOfIpProtFiltering
44279 + < params->p_AutoResFilteringInfo->ipProtTableSize)
44280 + RETURN_ERROR(
44281 + MAJOR,
44282 + E_INVALID_VALUE,
44283 + ("DSAR: ip filter table size exceeds the configured maximum size."));
44284 + if (sizes->maxNumOfTcpPortFiltering
44285 + < params->p_AutoResFilteringInfo->udpPortsTableSize)
44286 + RETURN_ERROR(
44287 + MAJOR,
44288 + E_INVALID_VALUE,
44289 + ("DSAR: udp filter table size exceeds the configured maximum size."));
44290 + if (sizes->maxNumOfUdpPortFiltering
44291 + < params->p_AutoResFilteringInfo->tcpPortsTableSize)
44292 + RETURN_ERROR(
44293 + MAJOR,
44294 + E_INVALID_VALUE,
44295 + ("DSAR: tcp filter table size exceeds the configured maximum size."));
44296 + }
44297 + /* check only 1 MAC address is configured (this is what ucode currently supports) */
44298 + if (params->p_AutoResArpInfo && params->p_AutoResArpInfo->tableSize)
44299 + {
44300 + memcpy(mac, params->p_AutoResArpInfo->p_AutoResTable[0].mac, 6);
44301 + i = 1;
44302 + macInit = TRUE;
44303 +
44304 + for (; i < params->p_AutoResArpInfo->tableSize; i++)
44305 + if (memcmp(mac, params->p_AutoResArpInfo->p_AutoResTable[i].mac, 6))
44306 + RETURN_ERROR(
44307 + MAJOR, E_INVALID_VALUE,
44308 + ("DSAR: Only 1 mac address is currently supported."));
44309 + }
44310 + if (params->p_AutoResEchoIpv4Info
44311 + && params->p_AutoResEchoIpv4Info->tableSize)
44312 + {
44313 + i = 0;
44314 + if (!macInit)
44315 + {
44316 + memcpy(mac, params->p_AutoResEchoIpv4Info->p_AutoResTable[0].mac,
44317 + 6);
44318 + i = 1;
44319 + macInit = TRUE;
44320 + }
44321 + for (; i < params->p_AutoResEchoIpv4Info->tableSize; i++)
44322 + if (memcmp(mac,
44323 + params->p_AutoResEchoIpv4Info->p_AutoResTable[i].mac, 6))
44324 + RETURN_ERROR(
44325 + MAJOR, E_INVALID_VALUE,
44326 + ("DSAR: Only 1 mac address is currently supported."));
44327 + }
44328 + if (params->p_AutoResEchoIpv6Info
44329 + && params->p_AutoResEchoIpv6Info->tableSize)
44330 + {
44331 + i = 0;
44332 + if (!macInit)
44333 + {
44334 + memcpy(mac, params->p_AutoResEchoIpv6Info->p_AutoResTable[0].mac,
44335 + 6);
44336 + i = 1;
44337 + macInit = TRUE;
44338 + }
44339 + for (; i < params->p_AutoResEchoIpv6Info->tableSize; i++)
44340 + if (memcmp(mac,
44341 + params->p_AutoResEchoIpv6Info->p_AutoResTable[i].mac, 6))
44342 + RETURN_ERROR(
44343 + MAJOR, E_INVALID_VALUE,
44344 + ("DSAR: Only 1 mac address is currently supported."));
44345 + }
44346 + if (params->p_AutoResNdpInfo && params->p_AutoResNdpInfo->tableSizeAssigned)
44347 + {
44348 + i = 0;
44349 + if (!macInit)
44350 + {
44351 + memcpy(mac, params->p_AutoResNdpInfo->p_AutoResTableAssigned[0].mac,
44352 + 6);
44353 + i = 1;
44354 + macInit = TRUE;
44355 + }
44356 + for (; i < params->p_AutoResNdpInfo->tableSizeAssigned; i++)
44357 + if (memcmp(mac,
44358 + params->p_AutoResNdpInfo->p_AutoResTableAssigned[i].mac,
44359 + 6))
44360 + RETURN_ERROR(
44361 + MAJOR, E_INVALID_VALUE,
44362 + ("DSAR: Only 1 mac address is currently supported."));
44363 + }
44364 + if (params->p_AutoResNdpInfo && params->p_AutoResNdpInfo->tableSizeTmp)
44365 + {
44366 + i = 0;
44367 + if (!macInit)
44368 + {
44369 + memcpy(mac, params->p_AutoResNdpInfo->p_AutoResTableTmp[0].mac, 6);
44370 + i = 1;
44371 + }
44372 + for (; i < params->p_AutoResNdpInfo->tableSizeTmp; i++)
44373 + if (memcmp(mac, params->p_AutoResNdpInfo->p_AutoResTableTmp[i].mac,
44374 + 6))
44375 + RETURN_ERROR(
44376 + MAJOR, E_INVALID_VALUE,
44377 + ("DSAR: Only 1 mac address is currently supported."));
44378 + }
44379 + return E_OK;
44380 +}
44381 +
44382 +static int GetBERLen(uint8_t* buf)
44383 +{
44384 + if (*buf & 0x80)
44385 + {
44386 + if ((*buf & 0x7F) == 1)
44387 + return buf[1];
44388 + else
44389 + return *(uint16_t*)&buf[1]; // assuming max len is 2
44390 + }
44391 + else
44392 + return buf[0];
44393 +}
44394 +#define TOTAL_BER_LEN(len) (len < 128) ? len + 2 : len + 3
44395 +
44396 +#define SCFG_FMCLKDPSLPCR_ADDR 0xFFE0FC00C
44397 +#define SCFG_FMCLKDPSLPCR_DS_VAL 0x08402000
44398 +#define SCFG_FMCLKDPSLPCR_NORMAL_VAL 0x00402000
44399 +static int fm_soc_suspend(void)
44400 +{
44401 + uint32_t *fmclk, tmp32;
44402 + fmclk = ioremap(SCFG_FMCLKDPSLPCR_ADDR, 4);
44403 + tmp32 = GET_UINT32(*fmclk);
44404 + WRITE_UINT32(*fmclk, SCFG_FMCLKDPSLPCR_DS_VAL);
44405 + tmp32 = GET_UINT32(*fmclk);
44406 + iounmap(fmclk);
44407 + return 0;
44408 +}
44409 +
44410 +void fm_clk_down(void)
44411 +{
44412 + uint32_t *fmclk, tmp32;
44413 + fmclk = ioremap(SCFG_FMCLKDPSLPCR_ADDR, 4);
44414 + tmp32 = GET_UINT32(*fmclk);
44415 + WRITE_UINT32(*fmclk, SCFG_FMCLKDPSLPCR_DS_VAL | 0x40000000);
44416 + tmp32 = GET_UINT32(*fmclk);
44417 + iounmap(fmclk);
44418 +}
44419 +
44420 +t_Error FM_PORT_EnterDsar(t_Handle h_FmPortRx, t_FmPortDsarParams *params)
44421 +{
44422 + int i, j;
44423 + t_Error err;
44424 + uint32_t nia;
44425 + t_FmPort *p_FmPort = (t_FmPort *)h_FmPortRx;
44426 + t_FmPort *p_FmPortTx = (t_FmPort *)params->h_FmPortTx;
44427 + t_DsarArpDescriptor *ArpDescriptor;
44428 + t_DsarIcmpV4Descriptor* ICMPV4Descriptor;
44429 + t_DsarIcmpV6Descriptor* ICMPV6Descriptor;
44430 + t_DsarNdDescriptor* NDDescriptor;
44431 +
44432 + uint64_t fmMuramVirtBaseAddr = (uint64_t)PTR_TO_UINT(XX_PhysToVirt(p_FmPort->fmMuramPhysBaseAddr));
44433 + uint32_t *param_page = XX_PhysToVirt(p_FmPort->fmMuramPhysBaseAddr + GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rgpr));
44434 + t_ArCommonDesc *ArCommonDescPtr = (t_ArCommonDesc*)(XX_PhysToVirt(p_FmPort->fmMuramPhysBaseAddr + GET_UINT32(*param_page)));
44435 + struct arOffsets* of;
44436 + uint8_t tmp = 0;
44437 + t_FmGetSetParams fmGetSetParams;
44438 + memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
44439 + fmGetSetParams.setParams.type = UPDATE_FPM_BRKC_SLP;
44440 + fmGetSetParams.setParams.sleep = 1;
44441 +
44442 + err = DsarCheckParams(params, p_FmPort->deepSleepVars.autoResMaxSizes);
44443 + if (err != E_OK)
44444 + return err;
44445 +
44446 + p_FmPort->deepSleepVars.autoResOffsets = XX_Malloc(sizeof(struct arOffsets));
44447 + of = (struct arOffsets *)p_FmPort->deepSleepVars.autoResOffsets;
44448 + IOMemSet32(ArCommonDescPtr, 0, AR_ComputeOffsets(of, params, p_FmPort));
44449 +
44450 + // common
44451 + WRITE_UINT8(ArCommonDescPtr->arTxPort, p_FmPortTx->hardwarePortId);
44452 + nia = GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne); // bmi nia
44453 + if ((nia & 0x007C0000) == 0x00440000) // bmi nia is parser
44454 + WRITE_UINT32(ArCommonDescPtr->activeHPNIA, GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfpne));
44455 + else
44456 + WRITE_UINT32(ArCommonDescPtr->activeHPNIA, nia);
44457 + WRITE_UINT16(ArCommonDescPtr->snmpPort, 161);
44458 +
44459 + // ARP
44460 + if (params->p_AutoResArpInfo)
44461 + {
44462 + t_DsarArpBindingEntry* arp_bindings;
44463 + ArpDescriptor = (t_DsarArpDescriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->arp);
44464 + WRITE_UINT32(ArCommonDescPtr->p_ArpDescriptor, PTR_TO_UINT(ArpDescriptor) - fmMuramVirtBaseAddr);
44465 + arp_bindings = (t_DsarArpBindingEntry*)(PTR_TO_UINT(ArpDescriptor) + sizeof(t_DsarArpDescriptor));
44466 + if (params->p_AutoResArpInfo->enableConflictDetection)
44467 + WRITE_UINT16(ArpDescriptor->control, 1);
44468 + else
44469 + WRITE_UINT16(ArpDescriptor->control, 0);
44470 + if (params->p_AutoResArpInfo->tableSize)
44471 + {
44472 + t_FmPortDsarArpEntry* arp_entry = params->p_AutoResArpInfo->p_AutoResTable;
44473 + WRITE_UINT16(*(uint16_t*)&ArCommonDescPtr->macStationAddr[0], *(uint16_t*)&arp_entry[0].mac[0]);
44474 + WRITE_UINT32(*(uint32_t*)&ArCommonDescPtr->macStationAddr[2], *(uint32_t*)&arp_entry[0].mac[2]);
44475 + WRITE_UINT16(ArpDescriptor->numOfBindings, params->p_AutoResArpInfo->tableSize);
44476 +
44477 + for (i = 0; i < params->p_AutoResArpInfo->tableSize; i++)
44478 + {
44479 + WRITE_UINT32(arp_bindings[i].ipv4Addr, arp_entry[i].ipAddress);
44480 + if (arp_entry[i].isVlan)
44481 + WRITE_UINT16(arp_bindings[i].vlanId, arp_entry[i].vid & 0xFFF);
44482 + }
44483 + WRITE_UINT32(ArpDescriptor->p_Bindings, PTR_TO_UINT(arp_bindings) - fmMuramVirtBaseAddr);
44484 + }
44485 + WRITE_UINT32(ArpDescriptor->p_Statistics, PTR_TO_UINT(arp_bindings) +
44486 + sizeof(t_DsarArpBindingEntry) * params->p_AutoResArpInfo->tableSize - fmMuramVirtBaseAddr);
44487 + }
44488 +
44489 + // ICMPV4
44490 + if (params->p_AutoResEchoIpv4Info)
44491 + {
44492 + t_DsarIcmpV4BindingEntry* icmpv4_bindings;
44493 + ICMPV4Descriptor = (t_DsarIcmpV4Descriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->icmpv4);
44494 + WRITE_UINT32(ArCommonDescPtr->p_IcmpV4Descriptor, PTR_TO_UINT(ICMPV4Descriptor) - fmMuramVirtBaseAddr);
44495 + icmpv4_bindings = (t_DsarIcmpV4BindingEntry*)(PTR_TO_UINT(ICMPV4Descriptor) + sizeof(t_DsarIcmpV4Descriptor));
44496 + WRITE_UINT16(ICMPV4Descriptor->control, 0);
44497 + if (params->p_AutoResEchoIpv4Info->tableSize)
44498 + {
44499 + t_FmPortDsarArpEntry* arp_entry = params->p_AutoResEchoIpv4Info->p_AutoResTable;
44500 + WRITE_UINT16(*(uint16_t*)&ArCommonDescPtr->macStationAddr[0], *(uint16_t*)&arp_entry[0].mac[0]);
44501 + WRITE_UINT32(*(uint32_t*)&ArCommonDescPtr->macStationAddr[2], *(uint32_t*)&arp_entry[0].mac[2]);
44502 + WRITE_UINT16(ICMPV4Descriptor->numOfBindings, params->p_AutoResEchoIpv4Info->tableSize);
44503 +
44504 + for (i = 0; i < params->p_AutoResEchoIpv4Info->tableSize; i++)
44505 + {
44506 + WRITE_UINT32(icmpv4_bindings[i].ipv4Addr, arp_entry[i].ipAddress);
44507 + if (arp_entry[i].isVlan)
44508 + WRITE_UINT16(icmpv4_bindings[i].vlanId, arp_entry[i].vid & 0xFFF);
44509 + }
44510 + WRITE_UINT32(ICMPV4Descriptor->p_Bindings, PTR_TO_UINT(icmpv4_bindings) - fmMuramVirtBaseAddr);
44511 + }
44512 + WRITE_UINT32(ICMPV4Descriptor->p_Statistics, PTR_TO_UINT(icmpv4_bindings) +
44513 + sizeof(t_DsarIcmpV4BindingEntry) * params->p_AutoResEchoIpv4Info->tableSize - fmMuramVirtBaseAddr);
44514 + }
44515 +
44516 + // ICMPV6
44517 + if (params->p_AutoResEchoIpv6Info)
44518 + {
44519 + t_DsarIcmpV6BindingEntry* icmpv6_bindings;
44520 + ICMPV6Descriptor = (t_DsarIcmpV6Descriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->icmpv6);
44521 + WRITE_UINT32(ArCommonDescPtr->p_IcmpV6Descriptor, PTR_TO_UINT(ICMPV6Descriptor) - fmMuramVirtBaseAddr);
44522 + icmpv6_bindings = (t_DsarIcmpV6BindingEntry*)(PTR_TO_UINT(ICMPV6Descriptor) + sizeof(t_DsarIcmpV6Descriptor));
44523 + WRITE_UINT16(ICMPV6Descriptor->control, 0);
44524 + if (params->p_AutoResEchoIpv6Info->tableSize)
44525 + {
44526 + t_FmPortDsarNdpEntry* ndp_entry = params->p_AutoResEchoIpv6Info->p_AutoResTable;
44527 + WRITE_UINT16(*(uint16_t*)&ArCommonDescPtr->macStationAddr[0], *(uint16_t*)&ndp_entry[0].mac[0]);
44528 + WRITE_UINT32(*(uint32_t*)&ArCommonDescPtr->macStationAddr[2], *(uint32_t*)&ndp_entry[0].mac[2]);
44529 + WRITE_UINT16(ICMPV6Descriptor->numOfBindings, params->p_AutoResEchoIpv6Info->tableSize);
44530 +
44531 + for (i = 0; i < params->p_AutoResEchoIpv6Info->tableSize; i++)
44532 + {
44533 + for (j = 0; j < 4; j++)
44534 + WRITE_UINT32(icmpv6_bindings[i].ipv6Addr[j], ndp_entry[i].ipAddress[j]);
44535 + if (ndp_entry[i].isVlan)
44536 + WRITE_UINT16(*(uint16_t*)&icmpv6_bindings[i].ipv6Addr[4], ndp_entry[i].vid & 0xFFF); // writing vlan
44537 + }
44538 + WRITE_UINT32(ICMPV6Descriptor->p_Bindings, PTR_TO_UINT(icmpv6_bindings) - fmMuramVirtBaseAddr);
44539 + }
44540 + WRITE_UINT32(ICMPV6Descriptor->p_Statistics, PTR_TO_UINT(icmpv6_bindings) +
44541 + sizeof(t_DsarIcmpV6BindingEntry) * params->p_AutoResEchoIpv6Info->tableSize - fmMuramVirtBaseAddr);
44542 + }
44543 +
44544 + // ND
44545 + if (params->p_AutoResNdpInfo)
44546 + {
44547 + t_DsarIcmpV6BindingEntry* icmpv6_bindings;
44548 + NDDescriptor = (t_DsarNdDescriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->nd);
44549 + WRITE_UINT32(ArCommonDescPtr->p_NdDescriptor, PTR_TO_UINT(NDDescriptor) - fmMuramVirtBaseAddr);
44550 + icmpv6_bindings = (t_DsarIcmpV6BindingEntry*)(PTR_TO_UINT(NDDescriptor) + sizeof(t_DsarNdDescriptor));
44551 + if (params->p_AutoResNdpInfo->enableConflictDetection)
44552 + WRITE_UINT16(NDDescriptor->control, 1);
44553 + else
44554 + WRITE_UINT16(NDDescriptor->control, 0);
44555 + if (params->p_AutoResNdpInfo->tableSizeAssigned + params->p_AutoResNdpInfo->tableSizeTmp)
44556 + {
44557 + t_FmPortDsarNdpEntry* ndp_entry = params->p_AutoResNdpInfo->p_AutoResTableAssigned;
44558 + WRITE_UINT16(*(uint16_t*)&ArCommonDescPtr->macStationAddr[0], *(uint16_t*)&ndp_entry[0].mac[0]);
44559 + WRITE_UINT32(*(uint32_t*)&ArCommonDescPtr->macStationAddr[2], *(uint32_t*)&ndp_entry[0].mac[2]);
44560 + WRITE_UINT16(NDDescriptor->numOfBindings, params->p_AutoResNdpInfo->tableSizeAssigned
44561 + + params->p_AutoResNdpInfo->tableSizeTmp);
44562 +
44563 + for (i = 0; i < params->p_AutoResNdpInfo->tableSizeAssigned; i++)
44564 + {
44565 + for (j = 0; j < 4; j++)
44566 + WRITE_UINT32(icmpv6_bindings[i].ipv6Addr[j], ndp_entry[i].ipAddress[j]);
44567 + if (ndp_entry[i].isVlan)
44568 + WRITE_UINT16(*(uint16_t*)&icmpv6_bindings[i].ipv6Addr[4], ndp_entry[i].vid & 0xFFF); // writing vlan
44569 + }
44570 + ndp_entry = params->p_AutoResNdpInfo->p_AutoResTableTmp;
44571 + for (i = 0; i < params->p_AutoResNdpInfo->tableSizeTmp; i++)
44572 + {
44573 + for (j = 0; j < 4; j++)
44574 + WRITE_UINT32(icmpv6_bindings[i + params->p_AutoResNdpInfo->tableSizeAssigned].ipv6Addr[j], ndp_entry[i].ipAddress[j]);
44575 + if (ndp_entry[i].isVlan)
44576 + WRITE_UINT16(*(uint16_t*)&icmpv6_bindings[i + params->p_AutoResNdpInfo->tableSizeAssigned].ipv6Addr[4], ndp_entry[i].vid & 0xFFF); // writing vlan
44577 + }
44578 + WRITE_UINT32(NDDescriptor->p_Bindings, PTR_TO_UINT(icmpv6_bindings) - fmMuramVirtBaseAddr);
44579 + }
44580 + WRITE_UINT32(NDDescriptor->p_Statistics, PTR_TO_UINT(icmpv6_bindings) + sizeof(t_DsarIcmpV6BindingEntry)
44581 + * (params->p_AutoResNdpInfo->tableSizeAssigned + params->p_AutoResNdpInfo->tableSizeTmp)
44582 + - fmMuramVirtBaseAddr);
44583 + WRITE_UINT32(NDDescriptor->solicitedAddr, 0xFFFFFFFF);
44584 + }
44585 +
44586 + // SNMP
44587 + if (params->p_AutoResSnmpInfo)
44588 + {
44589 + t_FmPortDsarSnmpInfo *snmpSrc = params->p_AutoResSnmpInfo;
44590 + t_DsarSnmpIpv4AddrTblEntry* snmpIpv4Addr;
44591 + t_DsarSnmpIpv6AddrTblEntry* snmpIpv6Addr;
44592 + t_OidsTblEntry* snmpOid;
44593 + uint8_t *charPointer;
44594 + int len;
44595 + t_DsarSnmpDescriptor* SnmpDescriptor = (t_DsarSnmpDescriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->snmp);
44596 + WRITE_UINT32(ArCommonDescPtr->p_SnmpDescriptor, PTR_TO_UINT(SnmpDescriptor) - fmMuramVirtBaseAddr);
44597 + WRITE_UINT16(SnmpDescriptor->control, snmpSrc->control);
44598 + WRITE_UINT16(SnmpDescriptor->maxSnmpMsgLength, snmpSrc->maxSnmpMsgLength);
44599 + snmpIpv4Addr = (t_DsarSnmpIpv4AddrTblEntry*)(PTR_TO_UINT(SnmpDescriptor) + sizeof(t_DsarSnmpDescriptor));
44600 + if (snmpSrc->numOfIpv4Addresses)
44601 + {
44602 + t_FmPortDsarSnmpIpv4AddrTblEntry* snmpIpv4AddrSrc = snmpSrc->p_Ipv4AddrTbl;
44603 + WRITE_UINT16(SnmpDescriptor->numOfIpv4Addresses, snmpSrc->numOfIpv4Addresses);
44604 + for (i = 0; i < snmpSrc->numOfIpv4Addresses; i++)
44605 + {
44606 + WRITE_UINT32(snmpIpv4Addr[i].ipv4Addr, snmpIpv4AddrSrc[i].ipv4Addr);
44607 + if (snmpIpv4AddrSrc[i].isVlan)
44608 + WRITE_UINT16(snmpIpv4Addr[i].vlanId, snmpIpv4AddrSrc[i].vid & 0xFFF);
44609 + }
44610 + WRITE_UINT32(SnmpDescriptor->p_Ipv4AddrTbl, PTR_TO_UINT(snmpIpv4Addr) - fmMuramVirtBaseAddr);
44611 + }
44612 + snmpIpv6Addr = (t_DsarSnmpIpv6AddrTblEntry*)(PTR_TO_UINT(snmpIpv4Addr)
44613 + + sizeof(t_DsarSnmpIpv4AddrTblEntry) * snmpSrc->numOfIpv4Addresses);
44614 + if (snmpSrc->numOfIpv6Addresses)
44615 + {
44616 + t_FmPortDsarSnmpIpv6AddrTblEntry* snmpIpv6AddrSrc = snmpSrc->p_Ipv6AddrTbl;
44617 + WRITE_UINT16(SnmpDescriptor->numOfIpv6Addresses, snmpSrc->numOfIpv6Addresses);
44618 + for (i = 0; i < snmpSrc->numOfIpv6Addresses; i++)
44619 + {
44620 + for (j = 0; j < 4; j++)
44621 + WRITE_UINT32(snmpIpv6Addr[i].ipv6Addr[j], snmpIpv6AddrSrc[i].ipv6Addr[j]);
44622 + if (snmpIpv6AddrSrc[i].isVlan)
44623 + WRITE_UINT16(snmpIpv6Addr[i].vlanId, snmpIpv6AddrSrc[i].vid & 0xFFF);
44624 + }
44625 + WRITE_UINT32(SnmpDescriptor->p_Ipv6AddrTbl, PTR_TO_UINT(snmpIpv6Addr) - fmMuramVirtBaseAddr);
44626 + }
44627 + snmpOid = (t_OidsTblEntry*)(PTR_TO_UINT(snmpIpv6Addr)
44628 + + sizeof(t_DsarSnmpIpv6AddrTblEntry) * snmpSrc->numOfIpv6Addresses);
44629 + charPointer = (uint8_t*)(PTR_TO_UINT(snmpOid)
44630 + + sizeof(t_OidsTblEntry) * snmpSrc->oidsTblSize);
44631 + len = TOTAL_BER_LEN(GetBERLen(&snmpSrc->p_RdOnlyCommunityStr[1]));
44632 + Mem2IOCpy32(charPointer, snmpSrc->p_RdOnlyCommunityStr, len);
44633 + WRITE_UINT32(SnmpDescriptor->p_RdOnlyCommunityStr, PTR_TO_UINT(charPointer) - fmMuramVirtBaseAddr);
44634 + charPointer += len;
44635 + len = TOTAL_BER_LEN(GetBERLen(&snmpSrc->p_RdWrCommunityStr[1]));
44636 + Mem2IOCpy32(charPointer, snmpSrc->p_RdWrCommunityStr, len);
44637 + WRITE_UINT32(SnmpDescriptor->p_RdWrCommunityStr, PTR_TO_UINT(charPointer) - fmMuramVirtBaseAddr);
44638 + charPointer += len;
44639 + WRITE_UINT32(SnmpDescriptor->oidsTblSize, snmpSrc->oidsTblSize);
44640 + WRITE_UINT32(SnmpDescriptor->p_OidsTbl, PTR_TO_UINT(snmpOid) - fmMuramVirtBaseAddr);
44641 + for (i = 0; i < snmpSrc->oidsTblSize; i++)
44642 + {
44643 + WRITE_UINT16(snmpOid->oidSize, snmpSrc->p_OidsTbl[i].oidSize);
44644 + WRITE_UINT16(snmpOid->resSize, snmpSrc->p_OidsTbl[i].resSize);
44645 + Mem2IOCpy32(charPointer, snmpSrc->p_OidsTbl[i].oidVal, snmpSrc->p_OidsTbl[i].oidSize);
44646 + WRITE_UINT32(snmpOid->p_Oid, PTR_TO_UINT(charPointer) - fmMuramVirtBaseAddr);
44647 + charPointer += snmpSrc->p_OidsTbl[i].oidSize;
44648 + if (snmpSrc->p_OidsTbl[i].resSize <= 4)
44649 + WRITE_UINT32(snmpOid->resValOrPtr, *snmpSrc->p_OidsTbl[i].resVal);
44650 + else
44651 + {
44652 + Mem2IOCpy32(charPointer, snmpSrc->p_OidsTbl[i].resVal, snmpSrc->p_OidsTbl[i].resSize);
44653 + WRITE_UINT32(snmpOid->resValOrPtr, PTR_TO_UINT(charPointer) - fmMuramVirtBaseAddr);
44654 + charPointer += snmpSrc->p_OidsTbl[i].resSize;
44655 + }
44656 + snmpOid++;
44657 + }
44658 + charPointer = UINT_TO_PTR(ROUND_UP(PTR_TO_UINT(charPointer),4));
44659 + WRITE_UINT32(SnmpDescriptor->p_Statistics, PTR_TO_UINT(charPointer) - fmMuramVirtBaseAddr);
44660 + }
44661 +
44662 + // filtering
44663 + if (params->p_AutoResFilteringInfo)
44664 + {
44665 + if (params->p_AutoResFilteringInfo->ipProtPassOnHit)
44666 + tmp |= IP_PROT_TBL_PASS_MASK;
44667 + if (params->p_AutoResFilteringInfo->udpPortPassOnHit)
44668 + tmp |= UDP_PORT_TBL_PASS_MASK;
44669 + if (params->p_AutoResFilteringInfo->tcpPortPassOnHit)
44670 + tmp |= TCP_PORT_TBL_PASS_MASK;
44671 + WRITE_UINT8(ArCommonDescPtr->filterControl, tmp);
44672 + WRITE_UINT16(ArCommonDescPtr->tcpControlPass, params->p_AutoResFilteringInfo->tcpFlagsMask);
44673 +
44674 + // ip filtering
44675 + if (params->p_AutoResFilteringInfo->ipProtTableSize)
44676 + {
44677 + uint8_t* ip_tbl = (uint8_t*)(PTR_TO_UINT(ArCommonDescPtr) + of->filtIp);
44678 + WRITE_UINT8(ArCommonDescPtr->ipProtocolTblSize, params->p_AutoResFilteringInfo->ipProtTableSize);
44679 + for (i = 0; i < params->p_AutoResFilteringInfo->ipProtTableSize; i++)
44680 + WRITE_UINT8(ip_tbl[i], params->p_AutoResFilteringInfo->p_IpProtTablePtr[i]);
44681 + WRITE_UINT32(ArCommonDescPtr->p_IpProtocolFiltTbl, PTR_TO_UINT(ip_tbl) - fmMuramVirtBaseAddr);
44682 + }
44683 +
44684 + // udp filtering
44685 + if (params->p_AutoResFilteringInfo->udpPortsTableSize)
44686 + {
44687 + t_PortTblEntry* udp_tbl = (t_PortTblEntry*)(PTR_TO_UINT(ArCommonDescPtr) + of->filtUdp);
44688 + WRITE_UINT8(ArCommonDescPtr->udpPortTblSize, params->p_AutoResFilteringInfo->udpPortsTableSize);
44689 + for (i = 0; i < params->p_AutoResFilteringInfo->udpPortsTableSize; i++)
44690 + {
44691 + WRITE_UINT32(udp_tbl[i].Ports,
44692 + (params->p_AutoResFilteringInfo->p_UdpPortsTablePtr[i].srcPort << 16) +
44693 + params->p_AutoResFilteringInfo->p_UdpPortsTablePtr[i].dstPort);
44694 + WRITE_UINT32(udp_tbl[i].PortsMask,
44695 + (params->p_AutoResFilteringInfo->p_UdpPortsTablePtr[i].srcPortMask << 16) +
44696 + params->p_AutoResFilteringInfo->p_UdpPortsTablePtr[i].dstPortMask);
44697 + }
44698 + WRITE_UINT32(ArCommonDescPtr->p_UdpPortFiltTbl, PTR_TO_UINT(udp_tbl) - fmMuramVirtBaseAddr);
44699 + }
44700 +
44701 + // tcp filtering
44702 + if (params->p_AutoResFilteringInfo->tcpPortsTableSize)
44703 + {
44704 + t_PortTblEntry* tcp_tbl = (t_PortTblEntry*)(PTR_TO_UINT(ArCommonDescPtr) + of->filtTcp);
44705 + WRITE_UINT8(ArCommonDescPtr->tcpPortTblSize, params->p_AutoResFilteringInfo->tcpPortsTableSize);
44706 + for (i = 0; i < params->p_AutoResFilteringInfo->tcpPortsTableSize; i++)
44707 + {
44708 + WRITE_UINT32(tcp_tbl[i].Ports,
44709 + (params->p_AutoResFilteringInfo->p_TcpPortsTablePtr[i].srcPort << 16) +
44710 + params->p_AutoResFilteringInfo->p_TcpPortsTablePtr[i].dstPort);
44711 + WRITE_UINT32(tcp_tbl[i].PortsMask,
44712 + (params->p_AutoResFilteringInfo->p_TcpPortsTablePtr[i].srcPortMask << 16) +
44713 + params->p_AutoResFilteringInfo->p_TcpPortsTablePtr[i].dstPortMask);
44714 + }
44715 + WRITE_UINT32(ArCommonDescPtr->p_TcpPortFiltTbl, PTR_TO_UINT(tcp_tbl) - fmMuramVirtBaseAddr);
44716 + }
44717 + }
44718 + // common stats
44719 + WRITE_UINT32(ArCommonDescPtr->p_ArStats, PTR_TO_UINT(ArCommonDescPtr) + of->stats - fmMuramVirtBaseAddr);
44720 +
44721 + // get into Deep Sleep sequence:
44722 +
44723 + // Ensures that FMan do not enter the idle state. This is done by programing
44724 + // FMDPSLPCR[FM_STOP] to one.
44725 + fm_soc_suspend();
44726 +
44727 + ARDesc = UINT_TO_PTR(XX_VirtToPhys(ArCommonDescPtr));
44728 + return E_OK;
44729 +
44730 +}
44731 +
44732 +void FM_ChangeClock(t_Handle h_Fm, int hardwarePortId);
44733 +t_Error FM_PORT_EnterDsarFinal(t_Handle h_DsarRxPort, t_Handle h_DsarTxPort)
44734 +{
44735 + t_FmGetSetParams fmGetSetParams;
44736 + t_FmPort *p_FmPort = (t_FmPort *)h_DsarRxPort;
44737 + t_FmPort *p_FmPortTx = (t_FmPort *)h_DsarTxPort;
44738 + t_Handle *h_FmPcd = FmGetPcd(p_FmPort->h_Fm);
44739 + t_FmPort *p_FmPortHc = FM_PCD_GetHcPort(h_FmPcd);
44740 + memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
44741 + fmGetSetParams.setParams.type = UPDATE_FM_CLD;
44742 + FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
44743 +
44744 + /* Issue graceful stop to HC port */
44745 + FM_PORT_Disable(p_FmPortHc);
44746 +
44747 + // config tx port
44748 + p_FmPort->deepSleepVars.fmbm_tcfg = GET_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfg);
44749 + WRITE_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfg, GET_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfg) | BMI_PORT_CFG_IM | BMI_PORT_CFG_EN);
44750 + // ????
44751 + p_FmPort->deepSleepVars.fmbm_tcmne = GET_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcmne);
44752 + WRITE_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcmne, 0xE);
44753 + // Stage 7:echo
44754 + p_FmPort->deepSleepVars.fmbm_rfpne = GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfpne);
44755 + WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfpne, 0x2E);
44756 + if (!PrsIsEnabled(h_FmPcd))
44757 + {
44758 + p_FmPort->deepSleepVars.dsarEnabledParser = TRUE;
44759 + PrsEnable(h_FmPcd);
44760 + }
44761 + else
44762 + p_FmPort->deepSleepVars.dsarEnabledParser = FALSE;
44763 +
44764 + p_FmPort->deepSleepVars.fmbm_rfne = GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne);
44765 + WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne, 0x440000);
44766 +
44767 + // save rcfg for restoring: accumulate mode is changed by ucode
44768 + p_FmPort->deepSleepVars.fmbm_rcfg = GET_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rcfg);
44769 + WRITE_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rcfg, p_FmPort->deepSleepVars.fmbm_rcfg | BMI_PORT_CFG_AM);
44770 + memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
44771 + fmGetSetParams.setParams.type = UPDATE_FPM_BRKC_SLP;
44772 + fmGetSetParams.setParams.sleep = 1;
44773 + FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
44774 +
44775 +// ***** issue external request sync command
44776 + memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
44777 + fmGetSetParams.setParams.type = UPDATE_FPM_EXTC;
44778 + FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
44779 + // get
44780 + memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
44781 + fmGetSetParams.getParams.type = GET_FMFP_EXTC;
44782 + FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
44783 + if (fmGetSetParams.getParams.fmfp_extc != 0)
44784 + {
44785 + // clear
44786 + memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
44787 + fmGetSetParams.setParams.type = UPDATE_FPM_EXTC_CLEAR;
44788 + FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
44789 +}
44790 +
44791 + memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
44792 + fmGetSetParams.getParams.type = GET_FMFP_EXTC | GET_FM_NPI;
44793 + do
44794 + {
44795 + FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
44796 + } while (fmGetSetParams.getParams.fmfp_extc != 0 && fmGetSetParams.getParams.fm_npi == 0);
44797 + if (fmGetSetParams.getParams.fm_npi != 0)
44798 + XX_Print("FM: Sync did not finish\n");
44799 +
44800 + // check that all stoped
44801 + memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
44802 + fmGetSetParams.getParams.type = GET_FMQM_GS | GET_FM_NPI;
44803 + FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
44804 + while (fmGetSetParams.getParams.fmqm_gs & 0xF0000000)
44805 + FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
44806 + if (fmGetSetParams.getParams.fmqm_gs == 0 && fmGetSetParams.getParams.fm_npi == 0)
44807 + XX_Print("FM: Sleeping\n");
44808 +// FM_ChangeClock(p_FmPort->h_Fm, p_FmPort->hardwarePortId);
44809 +
44810 + return E_OK;
44811 +}
44812 +
44813 +EXPORT_SYMBOL(FM_PORT_EnterDsarFinal);
44814 +
44815 +void FM_PORT_Dsar_DumpRegs()
44816 +{
44817 + uint32_t* hh = XX_PhysToVirt(PTR_TO_UINT(ARDesc));
44818 + DUMP_MEMORY(hh, 0x220);
44819 +}
44820 +
44821 +void FM_PORT_ExitDsar(t_Handle h_FmPortRx, t_Handle h_FmPortTx)
44822 +{
44823 + t_FmPort *p_FmPort = (t_FmPort *)h_FmPortRx;
44824 + t_FmPort *p_FmPortTx = (t_FmPort *)h_FmPortTx;
44825 + t_Handle *h_FmPcd = FmGetPcd(p_FmPort->h_Fm);
44826 + t_FmPort *p_FmPortHc = FM_PCD_GetHcPort(h_FmPcd);
44827 + t_FmGetSetParams fmGetSetParams;
44828 + memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
44829 + fmGetSetParams.setParams.type = UPDATE_FPM_BRKC_SLP;
44830 + fmGetSetParams.setParams.sleep = 0;
44831 + if (p_FmPort->deepSleepVars.autoResOffsets)
44832 + {
44833 + XX_Free(p_FmPort->deepSleepVars.autoResOffsets);
44834 + p_FmPort->deepSleepVars.autoResOffsets = 0;
44835 + }
44836 +
44837 + if (p_FmPort->deepSleepVars.dsarEnabledParser)
44838 + PrsDisable(FmGetPcd(p_FmPort->h_Fm));
44839 + WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfpne, p_FmPort->deepSleepVars.fmbm_rfpne);
44840 + WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne, p_FmPort->deepSleepVars.fmbm_rfne);
44841 + WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rcfg, p_FmPort->deepSleepVars.fmbm_rcfg);
44842 + FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
44843 + WRITE_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcmne, p_FmPort->deepSleepVars.fmbm_tcmne);
44844 + WRITE_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfg, p_FmPort->deepSleepVars.fmbm_tcfg);
44845 + FM_PORT_Enable(p_FmPortHc);
44846 +}
44847 +
44848 +bool FM_PORT_IsInDsar(t_Handle h_FmPort)
44849 +{
44850 + t_FmPort *p_FmPort = (t_FmPort *)h_FmPort;
44851 + return PTR_TO_UINT(p_FmPort->deepSleepVars.autoResOffsets);
44852 +}
44853 +
44854 +t_Error FM_PORT_GetDsarStats(t_Handle h_FmPortRx, t_FmPortDsarStats *stats)
44855 +{
44856 + t_FmPort *p_FmPort = (t_FmPort *)h_FmPortRx;
44857 + struct arOffsets *of = (struct arOffsets*)p_FmPort->deepSleepVars.autoResOffsets;
44858 + uint8_t* fmMuramVirtBaseAddr = XX_PhysToVirt(p_FmPort->fmMuramPhysBaseAddr);
44859 + uint32_t *param_page = XX_PhysToVirt(p_FmPort->fmMuramPhysBaseAddr + GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rgpr));
44860 + t_ArCommonDesc *ArCommonDescPtr = (t_ArCommonDesc*)(XX_PhysToVirt(p_FmPort->fmMuramPhysBaseAddr + GET_UINT32(*param_page)));
44861 + t_DsarArpDescriptor *ArpDescriptor = (t_DsarArpDescriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->arp);
44862 + t_DsarArpStatistics* arp_stats = (t_DsarArpStatistics*)(PTR_TO_UINT(ArpDescriptor->p_Statistics) + fmMuramVirtBaseAddr);
44863 + t_DsarIcmpV4Descriptor* ICMPV4Descriptor = (t_DsarIcmpV4Descriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->icmpv4);
44864 + t_DsarIcmpV4Statistics* icmpv4_stats = (t_DsarIcmpV4Statistics*)(PTR_TO_UINT(ICMPV4Descriptor->p_Statistics) + fmMuramVirtBaseAddr);
44865 + t_DsarNdDescriptor* NDDescriptor = (t_DsarNdDescriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->nd);
44866 + t_NdStatistics* nd_stats = (t_NdStatistics*)(PTR_TO_UINT(NDDescriptor->p_Statistics) + fmMuramVirtBaseAddr);
44867 + t_DsarIcmpV6Descriptor* ICMPV6Descriptor = (t_DsarIcmpV6Descriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->icmpv6);
44868 + t_DsarIcmpV6Statistics* icmpv6_stats = (t_DsarIcmpV6Statistics*)(PTR_TO_UINT(ICMPV6Descriptor->p_Statistics) + fmMuramVirtBaseAddr);
44869 + t_DsarSnmpDescriptor* SnmpDescriptor = (t_DsarSnmpDescriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->snmp);
44870 + t_DsarSnmpStatistics* snmp_stats = (t_DsarSnmpStatistics*)(PTR_TO_UINT(SnmpDescriptor->p_Statistics) + fmMuramVirtBaseAddr);
44871 + stats->arpArCnt = arp_stats->arCnt;
44872 + stats->echoIcmpv4ArCnt = icmpv4_stats->arCnt;
44873 + stats->ndpArCnt = nd_stats->arCnt;
44874 + stats->echoIcmpv6ArCnt = icmpv6_stats->arCnt;
44875 + stats->snmpGetCnt = snmp_stats->snmpGetReqCnt;
44876 + stats->snmpGetNextCnt = snmp_stats->snmpGetNextReqCnt;
44877 + return E_OK;
44878 +}
44879 --- /dev/null
44880 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.h
44881 @@ -0,0 +1,999 @@
44882 +/*
44883 + * Copyright 2008-2012 Freescale Semiconductor Inc.
44884 + *
44885 + * Redistribution and use in source and binary forms, with or without
44886 + * modification, are permitted provided that the following conditions are met:
44887 + * * Redistributions of source code must retain the above copyright
44888 + * notice, this list of conditions and the following disclaimer.
44889 + * * Redistributions in binary form must reproduce the above copyright
44890 + * notice, this list of conditions and the following disclaimer in the
44891 + * documentation and/or other materials provided with the distribution.
44892 + * * Neither the name of Freescale Semiconductor nor the
44893 + * names of its contributors may be used to endorse or promote products
44894 + * derived from this software without specific prior written permission.
44895 + *
44896 + *
44897 + * ALTERNATIVELY, this software may be distributed under the terms of the
44898 + * GNU General Public License ("GPL") as published by the Free Software
44899 + * Foundation, either version 2 of that License or (at your option) any
44900 + * later version.
44901 + *
44902 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
44903 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
44904 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44905 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
44906 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
44907 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44908 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44909 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44910 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
44911 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44912 + */
44913 +
44914 +
44915 +/******************************************************************************
44916 + @File fm_port.h
44917 +
44918 + @Description FM Port internal structures and definitions.
44919 +*//***************************************************************************/
44920 +#ifndef __FM_PORT_H
44921 +#define __FM_PORT_H
44922 +
44923 +#include "error_ext.h"
44924 +#include "std_ext.h"
44925 +#include "fm_port_ext.h"
44926 +
44927 +#include "fm_common.h"
44928 +#include "fm_sp_common.h"
44929 +#include "fsl_fman_sp.h"
44930 +#include "fm_port_ext.h"
44931 +#include "fsl_fman_port.h"
44932 +
44933 +#define __ERR_MODULE__ MODULE_FM_PORT
44934 +
44935 +
44936 +#define MIN_EXT_BUF_SIZE 64
44937 +#define DATA_ALIGNMENT 64
44938 +#define MAX_LIODN_OFFSET 64
44939 +#define MAX_PORT_FIFO_SIZE MIN(BMI_MAX_FIFO_SIZE, 1024*BMI_FIFO_UNITS)
44940 +
44941 +/**************************************************************************//**
44942 + @Description Memory Map defines
44943 +*//***************************************************************************/
44944 +#define BMI_PORT_REGS_OFFSET 0
44945 +#define QMI_PORT_REGS_OFFSET 0x400
44946 +#define PRS_PORT_REGS_OFFSET 0x800
44947 +
44948 +/**************************************************************************//**
44949 + @Description defaults
44950 +*//***************************************************************************/
44951 +#define DEFAULT_PORT_deqHighPriority_1G FALSE
44952 +#define DEFAULT_PORT_deqHighPriority_10G TRUE
44953 +#define DEFAULT_PORT_deqType e_FM_PORT_DEQ_TYPE1
44954 +#define DEFAULT_PORT_deqPrefetchOption e_FM_PORT_DEQ_FULL_PREFETCH
44955 +#define DEFAULT_PORT_deqPrefetchOption_HC e_FM_PORT_DEQ_NO_PREFETCH
44956 +#define DEFAULT_PORT_deqByteCnt_10G 0x1400
44957 +#define DEFAULT_PORT_deqByteCnt_1G 0x400
44958 +#define DEFAULT_PORT_bufferPrefixContent_privDataSize DEFAULT_FM_SP_bufferPrefixContent_privDataSize
44959 +#define DEFAULT_PORT_bufferPrefixContent_passPrsResult DEFAULT_FM_SP_bufferPrefixContent_passPrsResult
44960 +#define DEFAULT_PORT_bufferPrefixContent_passTimeStamp DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp
44961 +#define DEFAULT_PORT_bufferPrefixContent_allOtherPCDInfo DEFAULT_FM_SP_bufferPrefixContent_allOtherPCDInfo
44962 +#define DEFAULT_PORT_bufferPrefixContent_dataAlign DEFAULT_FM_SP_bufferPrefixContent_dataAlign
44963 +#define DEFAULT_PORT_cheksumLastBytesIgnore 0
44964 +#define DEFAULT_PORT_cutBytesFromEnd 4
44965 +#define DEFAULT_PORT_fifoDeqPipelineDepth_IM 2
44966 +
44967 +#define DEFAULT_PORT_frmDiscardOverride FALSE
44968 +
44969 +#define DEFAULT_PORT_dmaSwapData (e_FmDmaSwapOption)DEFAULT_FMAN_SP_DMA_SWAP_DATA
44970 +#define DEFAULT_PORT_dmaIntContextCacheAttr (e_FmDmaCacheOption)DEFAULT_FMAN_SP_DMA_INT_CONTEXT_CACHE_ATTR
44971 +#define DEFAULT_PORT_dmaHeaderCacheAttr (e_FmDmaCacheOption)DEFAULT_FMAN_SP_DMA_HEADER_CACHE_ATTR
44972 +#define DEFAULT_PORT_dmaScatterGatherCacheAttr (e_FmDmaCacheOption)DEFAULT_FMAN_SP_DMA_SCATTER_GATHER_CACHE_ATTR
44973 +#define DEFAULT_PORT_dmaWriteOptimize DEFAULT_FMAN_SP_DMA_WRITE_OPTIMIZE
44974 +
44975 +#define DEFAULT_PORT_noScatherGather DEFAULT_FMAN_SP_NO_SCATTER_GATHER
44976 +#define DEFAULT_PORT_forwardIntContextReuse FALSE
44977 +#define DEFAULT_PORT_BufMargins_startMargins 32
44978 +#define DEFAULT_PORT_BufMargins_endMargins 0
44979 +#define DEFAULT_PORT_syncReq TRUE
44980 +#define DEFAULT_PORT_syncReqForHc FALSE
44981 +#define DEFAULT_PORT_color e_FM_PORT_COLOR_GREEN
44982 +#define DEFAULT_PORT_errorsToDiscard FM_PORT_FRM_ERR_CLS_DISCARD
44983 +/* #define DEFAULT_PORT_dualRateLimitScaleDown e_FM_PORT_DUAL_RATE_LIMITER_NONE */
44984 +/* #define DEFAULT_PORT_rateLimitBurstSizeHighGranularity FALSE */
44985 +#define DEFAULT_PORT_exception IM_EV_BSY
44986 +#define DEFAULT_PORT_maxFrameLength 9600
44987 +
44988 +#define DEFAULT_notSupported 0xff
44989 +
44990 +#if (DPAA_VERSION < 11)
44991 +#define DEFAULT_PORT_rxFifoPriElevationLevel MAX_PORT_FIFO_SIZE
44992 +#define DEFAULT_PORT_rxFifoThreshold (MAX_PORT_FIFO_SIZE*3/4)
44993 +
44994 +#define DEFAULT_PORT_txFifoMinFillLevel 0
44995 +#define DEFAULT_PORT_txFifoLowComfLevel (5*KILOBYTE)
44996 +#define DEFAULT_PORT_fifoDeqPipelineDepth_1G 1
44997 +#define DEFAULT_PORT_fifoDeqPipelineDepth_10G 4
44998 +
44999 +#define DEFAULT_PORT_fifoDeqPipelineDepth_OH 2
45000 +
45001 +/* Host command port MUST NOT be changed to more than 1 !!! */
45002 +#define DEFAULT_PORT_numOfTasks(type) \
45003 + (uint32_t)((((type) == e_FM_PORT_TYPE_RX_10G) || \
45004 + ((type) == e_FM_PORT_TYPE_TX_10G)) ? 16 : \
45005 + ((((type) == e_FM_PORT_TYPE_RX) || \
45006 + ((type) == e_FM_PORT_TYPE_TX) || \
45007 + ((type) == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)) ? 3 : 1))
45008 +
45009 +#define DEFAULT_PORT_extraNumOfTasks(type) \
45010 + (uint32_t)(((type) == e_FM_PORT_TYPE_RX_10G) ? 8 : \
45011 + (((type) == e_FM_PORT_TYPE_RX) ? 2 : 0))
45012 +
45013 +#define DEFAULT_PORT_numOfOpenDmas(type) \
45014 + (uint32_t)((((type) == e_FM_PORT_TYPE_TX_10G) || \
45015 + ((type) == e_FM_PORT_TYPE_RX_10G)) ? 8 : 1 )
45016 +
45017 +#define DEFAULT_PORT_extraNumOfOpenDmas(type) \
45018 + (uint32_t)(((type) == e_FM_PORT_TYPE_RX_10G) ? 8 : \
45019 + (((type) == e_FM_PORT_TYPE_RX) ? 1 : 0))
45020 +
45021 +#define DEFAULT_PORT_numOfFifoBufs(type) \
45022 + (uint32_t)((((type) == e_FM_PORT_TYPE_RX_10G) || \
45023 + ((type) == e_FM_PORT_TYPE_TX_10G)) ? 48 : \
45024 + ((type) == e_FM_PORT_TYPE_RX) ? 45 : \
45025 + ((type) == e_FM_PORT_TYPE_TX) ? 44 : 8)
45026 +
45027 +#define DEFAULT_PORT_extraNumOfFifoBufs 0
45028 +
45029 +#else /* (DPAA_VERSION < 11) */
45030 +/* Defaults are registers' reset values */
45031 +#define DEFAULT_PORT_rxFifoPriElevationLevel MAX_PORT_FIFO_SIZE
45032 +#define DEFAULT_PORT_rxFifoThreshold MAX_PORT_FIFO_SIZE
45033 +
45034 +#define DEFAULT_PORT_txFifoMinFillLevel 0
45035 +#define DEFAULT_PORT_txFifoLowComfLevel (5 * KILOBYTE)
45036 +#define DEFAULT_PORT_fifoDeqPipelineDepth_1G 2
45037 +#define DEFAULT_PORT_fifoDeqPipelineDepth_10G 4
45038 +
45039 +#define DEFAULT_PORT_fifoDeqPipelineDepth_OH 2
45040 +
45041 +#define DEFAULT_PORT_numOfTasks(type) \
45042 + (uint32_t)((((type) == e_FM_PORT_TYPE_RX_10G) || \
45043 + ((type) == e_FM_PORT_TYPE_TX_10G)) ? 14 : \
45044 + (((type) == e_FM_PORT_TYPE_RX) || \
45045 + ((type) == e_FM_PORT_TYPE_TX)) ? 4 : \
45046 + ((type) == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) ? 6 : 1)
45047 +
45048 +#define DEFAULT_PORT_extraNumOfTasks(type) 0
45049 +
45050 +#define DEFAULT_PORT_numOfOpenDmas(type) \
45051 + (uint32_t)(((type) == e_FM_PORT_TYPE_RX_10G) ? 8 : \
45052 + ((type) == e_FM_PORT_TYPE_TX_10G) ? 12 : \
45053 + ((type) == e_FM_PORT_TYPE_RX) ? 2 : \
45054 + ((type) == e_FM_PORT_TYPE_TX) ? 3 : \
45055 + ((type) == e_FM_PORT_TYPE_OH_HOST_COMMAND) ? 2 : 4)
45056 +
45057 +#define DEFAULT_PORT_extraNumOfOpenDmas(type) 0
45058 +
45059 +#define DEFAULT_PORT_numOfFifoBufs(type) \
45060 + (uint32_t) (((type) == e_FM_PORT_TYPE_RX_10G) ? 96 : \
45061 + ((type) == e_FM_PORT_TYPE_TX_10G) ? 64 : \
45062 + ((type) == e_FM_PORT_TYPE_OH_HOST_COMMAND) ? 10 : 50)
45063 +
45064 +#define DEFAULT_PORT_extraNumOfFifoBufs 0
45065 +
45066 +#endif /* (DPAA_VERSION < 11) */
45067 +
45068 +#define DEFAULT_PORT_txBdRingLength 16
45069 +#define DEFAULT_PORT_rxBdRingLength 128
45070 +#define DEFAULT_PORT_ImfwExtStructsMemId 0
45071 +#define DEFAULT_PORT_ImfwExtStructsMemAttr MEMORY_ATTR_CACHEABLE
45072 +
45073 +#define FM_PORT_CG_REG_NUM(_cgId) (((FM_PORT_NUM_OF_CONGESTION_GRPS/32)-1)-_cgId/32)
45074 +
45075 +/**************************************************************************//**
45076 + @Collection PCD Engines
45077 +*//***************************************************************************/
45078 +typedef uint32_t fmPcdEngines_t; /**< options as defined below: */
45079 +
45080 +#define FM_PCD_NONE 0 /**< No PCD Engine indicated */
45081 +#define FM_PCD_PRS 0x80000000 /**< Parser indicated */
45082 +#define FM_PCD_KG 0x40000000 /**< Keygen indicated */
45083 +#define FM_PCD_CC 0x20000000 /**< Coarse classification indicated */
45084 +#define FM_PCD_PLCR 0x10000000 /**< Policer indicated */
45085 +#define FM_PCD_MANIP 0x08000000 /**< Manipulation indicated */
45086 +/* @} */
45087 +
45088 +#define FM_PORT_MAX_NUM_OF_EXT_POOLS_ALL_INTEGRATIONS 8
45089 +#define FM_PORT_MAX_NUM_OF_CONGESTION_GRPS_ALL_INTEGRATIONS 256
45090 +#define FM_PORT_CG_REG_NUM(_cgId) (((FM_PORT_NUM_OF_CONGESTION_GRPS/32)-1)-_cgId/32)
45091 +
45092 +#define FM_OH_PORT_ID 0
45093 +
45094 +/***********************************************************************/
45095 +/* SW parser OFFLOAD labels (offsets) */
45096 +/***********************************************************************/
45097 +#if (DPAA_VERSION == 10)
45098 +#define OFFLOAD_SW_PATCH_IPv4_IPR_LABEL 0x300
45099 +#define OFFLOAD_SW_PATCH_IPv6_IPR_LABEL 0x325
45100 +#define OFFLOAD_SW_PATCH_IPv6_IPF_LABEL 0x325
45101 +#else
45102 +#define OFFLOAD_SW_PATCH_IPv4_IPR_LABEL 0x100
45103 +/* Will be used for:
45104 + * 1. identify fragments
45105 + * 2. udp-lite
45106 + */
45107 +#define OFFLOAD_SW_PATCH_IPv6_IPR_LABEL 0x146
45108 +/* Will be used for:
45109 + * 1. will identify the fragmentable area
45110 + * 2. udp-lite
45111 + */
45112 +#define OFFLOAD_SW_PATCH_IPv6_IPF_LABEL 0x261
45113 +#define OFFLOAD_SW_PATCH_CAPWAP_LABEL 0x38d
45114 +#endif /* (DPAA_VERSION == 10) */
45115 +
45116 +#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
45117 +#define UDP_LITE_SW_PATCH_LABEL 0x2E0
45118 +#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
45119 +
45120 +
45121 +/**************************************************************************//**
45122 + @Description Memory Mapped Registers
45123 +*//***************************************************************************/
45124 +
45125 +#if defined(__MWERKS__) && !defined(__GNUC__)
45126 +#pragma pack(push,1)
45127 +#endif /* defined(__MWERKS__) && ... */
45128 +
45129 +typedef struct
45130 +{
45131 + volatile uint32_t fmbm_rcfg; /**< Rx Configuration */
45132 + volatile uint32_t fmbm_rst; /**< Rx Status */
45133 + volatile uint32_t fmbm_rda; /**< Rx DMA attributes*/
45134 + volatile uint32_t fmbm_rfp; /**< Rx FIFO Parameters*/
45135 + volatile uint32_t fmbm_rfed; /**< Rx Frame End Data*/
45136 + volatile uint32_t fmbm_ricp; /**< Rx Internal Context Parameters*/
45137 + volatile uint32_t fmbm_rim; /**< Rx Internal Buffer Margins*/
45138 + volatile uint32_t fmbm_rebm; /**< Rx External Buffer Margins*/
45139 + volatile uint32_t fmbm_rfne; /**< Rx Frame Next Engine*/
45140 + volatile uint32_t fmbm_rfca; /**< Rx Frame Command Attributes.*/
45141 + volatile uint32_t fmbm_rfpne; /**< Rx Frame Parser Next Engine*/
45142 + volatile uint32_t fmbm_rpso; /**< Rx Parse Start Offset*/
45143 + volatile uint32_t fmbm_rpp; /**< Rx Policer Profile */
45144 + volatile uint32_t fmbm_rccb; /**< Rx Coarse Classification Base */
45145 + volatile uint32_t fmbm_reth; /**< Rx Excessive Threshold */
45146 + volatile uint32_t reserved1[0x01];/**< (0x03C) */
45147 + volatile uint32_t fmbm_rprai[FM_PORT_PRS_RESULT_NUM_OF_WORDS];
45148 + /**< Rx Parse Results Array Initialization*/
45149 + volatile uint32_t fmbm_rfqid; /**< Rx Frame Queue ID*/
45150 + volatile uint32_t fmbm_refqid; /**< Rx Error Frame Queue ID*/
45151 + volatile uint32_t fmbm_rfsdm; /**< Rx Frame Status Discard Mask*/
45152 + volatile uint32_t fmbm_rfsem; /**< Rx Frame Status Error Mask*/
45153 + volatile uint32_t fmbm_rfene; /**< Rx Frame Enqueue Next Engine */
45154 + volatile uint32_t reserved2[0x02];/**< (0x074-0x078) */
45155 + volatile uint32_t fmbm_rcmne; /**< Rx Frame Continuous Mode Next Engine */
45156 + volatile uint32_t reserved3[0x20];/**< (0x080 0x0FF) */
45157 + volatile uint32_t fmbm_ebmpi[FM_PORT_MAX_NUM_OF_EXT_POOLS_ALL_INTEGRATIONS];
45158 + /**< Buffer Manager pool Information-*/
45159 + volatile uint32_t fmbm_acnt[FM_PORT_MAX_NUM_OF_EXT_POOLS_ALL_INTEGRATIONS];
45160 + /**< Allocate Counter-*/
45161 + volatile uint32_t reserved4[0x08];
45162 + /**< 0x130/0x140 - 0x15F reserved -*/
45163 + volatile uint32_t fmbm_rcgm[FM_PORT_MAX_NUM_OF_CONGESTION_GRPS_ALL_INTEGRATIONS/32];
45164 + /**< Congestion Group Map*/
45165 + volatile uint32_t fmbm_rmpd; /**< BM Pool Depletion */
45166 + volatile uint32_t reserved5[0x1F];/**< (0x184 0x1FF) */
45167 + volatile uint32_t fmbm_rstc; /**< Rx Statistics Counters*/
45168 + volatile uint32_t fmbm_rfrc; /**< Rx Frame Counter*/
45169 + volatile uint32_t fmbm_rfbc; /**< Rx Bad Frames Counter*/
45170 + volatile uint32_t fmbm_rlfc; /**< Rx Large Frames Counter*/
45171 + volatile uint32_t fmbm_rffc; /**< Rx Filter Frames Counter*/
45172 + volatile uint32_t fmbm_rfcd; /**< Rx Frame Discard Counter*/
45173 + volatile uint32_t fmbm_rfldec; /**< Rx Frames List DMA Error Counter*/
45174 + volatile uint32_t fmbm_rodc; /**< Rx Out of Buffers Discard Counter-*/
45175 + volatile uint32_t fmbm_rbdc; /**< Rx Buffers Deallocate Counter-*/
45176 + volatile uint32_t fmbm_rpec; /**< Rx RX Prepare to enqueue Counter-*/
45177 + volatile uint32_t reserved6[0x16];/**< (0x228 0x27F) */
45178 + volatile uint32_t fmbm_rpc; /**< Rx Performance Counters*/
45179 + volatile uint32_t fmbm_rpcp; /**< Rx Performance Count Parameters*/
45180 + volatile uint32_t fmbm_rccn; /**< Rx Cycle Counter*/
45181 + volatile uint32_t fmbm_rtuc; /**< Rx Tasks Utilization Counter*/
45182 + volatile uint32_t fmbm_rrquc; /**< Rx Receive Queue Utilization Counter*/
45183 + volatile uint32_t fmbm_rduc; /**< Rx DMA Utilization Counter*/
45184 + volatile uint32_t fmbm_rfuc; /**< Rx FIFO Utilization Counter*/
45185 + volatile uint32_t fmbm_rpac; /**< Rx Pause Activation Counter*/
45186 + volatile uint32_t reserved7[0x18];/**< (0x2A0-0x2FF) */
45187 + volatile uint32_t fmbm_rdcfg[0x3];/**< Rx Debug-*/
45188 + volatile uint32_t fmbm_rgpr; /**< Rx General Purpose Register. */
45189 + volatile uint32_t reserved8[0x3a];/**< (0x310-0x3FF) */
45190 +} t_FmPortRxBmiRegs;
45191 +
45192 +typedef struct
45193 +{
45194 + volatile uint32_t fmbm_tcfg; /**< Tx Configuration */
45195 + volatile uint32_t fmbm_tst; /**< Tx Status */
45196 + volatile uint32_t fmbm_tda; /**< Tx DMA attributes */
45197 + volatile uint32_t fmbm_tfp; /**< Tx FIFO Parameters */
45198 + volatile uint32_t fmbm_tfed; /**< Tx Frame End Data */
45199 + volatile uint32_t fmbm_ticp; /**< Tx Internal Context Parameters */
45200 + volatile uint32_t fmbm_tfdne; /**< Tx Frame Dequeue Next Engine. */
45201 + volatile uint32_t fmbm_tfca; /**< Tx Frame Command attribute. */
45202 + volatile uint32_t fmbm_tcfqid; /**< Tx Confirmation Frame Queue ID. */
45203 + volatile uint32_t fmbm_tfeqid; /**< Tx Frame Error Queue ID */
45204 + volatile uint32_t fmbm_tfene; /**< Tx Frame Enqueue Next Engine */
45205 + volatile uint32_t fmbm_trlmts; /**< Tx Rate Limiter Scale */
45206 + volatile uint32_t fmbm_trlmt; /**< Tx Rate Limiter */
45207 + volatile uint32_t fmbm_tccb; /**< Tx Coarse Classification Base */
45208 + volatile uint32_t reserved0[0x0e];/**< (0x038-0x070) */
45209 + volatile uint32_t fmbm_tfne; /**< Tx Frame Next Engine */
45210 + volatile uint32_t fmbm_tpfcm[0x02];/**< Tx Priority based Flow Control (PFC) Mapping */
45211 + volatile uint32_t fmbm_tcmne; /**< Tx Frame Continuous Mode Next Engine */
45212 + volatile uint32_t reserved2[0x60];/**< (0x080-0x200) */
45213 + volatile uint32_t fmbm_tstc; /**< Tx Statistics Counters */
45214 + volatile uint32_t fmbm_tfrc; /**< Tx Frame Counter */
45215 + volatile uint32_t fmbm_tfdc; /**< Tx Frames Discard Counter */
45216 + volatile uint32_t fmbm_tfledc; /**< Tx Frame Length error discard counter */
45217 + volatile uint32_t fmbm_tfufdc; /**< Tx Frame unsupported format discard Counter */
45218 + volatile uint32_t fmbm_tbdc; /**< Tx Buffers Deallocate Counter */
45219 + volatile uint32_t reserved3[0x1A];/**< (0x218-0x280) */
45220 + volatile uint32_t fmbm_tpc; /**< Tx Performance Counters*/
45221 + volatile uint32_t fmbm_tpcp; /**< Tx Performance Count Parameters*/
45222 + volatile uint32_t fmbm_tccn; /**< Tx Cycle Counter*/
45223 + volatile uint32_t fmbm_ttuc; /**< Tx Tasks Utilization Counter*/
45224 + volatile uint32_t fmbm_ttcquc; /**< Tx Transmit Confirm Queue Utilization Counter*/
45225 + volatile uint32_t fmbm_tduc; /**< Tx DMA Utilization Counter*/
45226 + volatile uint32_t fmbm_tfuc; /**< Tx FIFO Utilization Counter*/
45227 + volatile uint32_t reserved4[16]; /**< (0x29C-0x2FF) */
45228 + volatile uint32_t fmbm_tdcfg[0x3];/**< Tx Debug-*/
45229 + volatile uint32_t fmbm_tgpr; /**< O/H General Purpose Register */
45230 + volatile uint32_t reserved5[0x3a];/**< (0x310-0x3FF) */
45231 +} t_FmPortTxBmiRegs;
45232 +
45233 +typedef struct
45234 +{
45235 + volatile uint32_t fmbm_ocfg; /**< O/H Configuration */
45236 + volatile uint32_t fmbm_ost; /**< O/H Status */
45237 + volatile uint32_t fmbm_oda; /**< O/H DMA attributes */
45238 + volatile uint32_t fmbm_oicp; /**< O/H Internal Context Parameters */
45239 + volatile uint32_t fmbm_ofdne; /**< O/H Frame Dequeue Next Engine */
45240 + volatile uint32_t fmbm_ofne; /**< O/H Frame Next Engine */
45241 + volatile uint32_t fmbm_ofca; /**< O/H Frame Command Attributes. */
45242 + volatile uint32_t fmbm_ofpne; /**< O/H Frame Parser Next Engine */
45243 + volatile uint32_t fmbm_opso; /**< O/H Parse Start Offset */
45244 + volatile uint32_t fmbm_opp; /**< O/H Policer Profile */
45245 + volatile uint32_t fmbm_occb; /**< O/H Coarse Classification base */
45246 + volatile uint32_t fmbm_oim; /**< O/H Internal margins*/
45247 + volatile uint32_t fmbm_ofp; /**< O/H Fifo Parameters*/
45248 + volatile uint32_t fmbm_ofed; /**< O/H Frame End Data*/
45249 + volatile uint32_t reserved0[2]; /**< (0x038 - 0x03F) */
45250 + volatile uint32_t fmbm_oprai[FM_PORT_PRS_RESULT_NUM_OF_WORDS];
45251 + /**< O/H Parse Results Array Initialization */
45252 + volatile uint32_t fmbm_ofqid; /**< O/H Frame Queue ID */
45253 + volatile uint32_t fmbm_oefqid; /**< O/H Error Frame Queue ID */
45254 + volatile uint32_t fmbm_ofsdm; /**< O/H Frame Status Discard Mask */
45255 + volatile uint32_t fmbm_ofsem; /**< O/H Frame Status Error Mask */
45256 + volatile uint32_t fmbm_ofene; /**< O/H Frame Enqueue Next Engine */
45257 + volatile uint32_t fmbm_orlmts; /**< O/H Rate Limiter Scale */
45258 + volatile uint32_t fmbm_orlmt; /**< O/H Rate Limiter */
45259 + volatile uint32_t fmbm_ocmne; /**< O/H Continuous Mode Next Engine */
45260 + volatile uint32_t reserved1[0x20];/**< (0x080 - 0x0FF) */
45261 + volatile uint32_t fmbm_oebmpi[2]; /**< Buffer Manager Observed Pool Information */
45262 + volatile uint32_t reserved2[0x16];/**< (0x108 - 0x15F) */
45263 + volatile uint32_t fmbm_ocgm; /**< Observed Congestion Group Map */
45264 + volatile uint32_t reserved3[0x7]; /**< (0x164 - 0x17F) */
45265 + volatile uint32_t fmbm_ompd; /**< Observed BMan Pool Depletion */
45266 + volatile uint32_t reserved4[0x1F];/**< (0x184 - 0x1FF) */
45267 + volatile uint32_t fmbm_ostc; /**< O/H Statistics Counters */
45268 + volatile uint32_t fmbm_ofrc; /**< O/H Frame Counter */
45269 + volatile uint32_t fmbm_ofdc; /**< O/H Frames Discard Counter */
45270 + volatile uint32_t fmbm_ofledc; /**< O/H Frames Length Error Discard Counter */
45271 + volatile uint32_t fmbm_ofufdc; /**< O/H Frames Unsupported Format Discard Counter */
45272 + volatile uint32_t fmbm_offc; /**< O/H Filter Frames Counter */
45273 + volatile uint32_t fmbm_ofwdc; /**< - Rx Frames WRED Discard Counter */
45274 + volatile uint32_t fmbm_ofldec; /**< O/H Frames List DMA Error Counter */
45275 + volatile uint32_t fmbm_obdc; /**< O/H Buffers Deallocate Counter */
45276 + volatile uint32_t fmbm_oodc; /**< O/H Out of Buffers Discard Counter */
45277 + volatile uint32_t fmbm_opec; /**< O/H Prepare to enqueue Counter */
45278 + volatile uint32_t reserved5[0x15];/**< ( - 0x27F) */
45279 + volatile uint32_t fmbm_opc; /**< O/H Performance Counters */
45280 + volatile uint32_t fmbm_opcp; /**< O/H Performance Count Parameters */
45281 + volatile uint32_t fmbm_occn; /**< O/H Cycle Counter */
45282 + volatile uint32_t fmbm_otuc; /**< O/H Tasks Utilization Counter */
45283 + volatile uint32_t fmbm_oduc; /**< O/H DMA Utilization Counter */
45284 + volatile uint32_t fmbm_ofuc; /**< O/H FIFO Utilization Counter */
45285 + volatile uint32_t reserved6[26]; /**< (0x298-0x2FF) */
45286 + volatile uint32_t fmbm_odcfg[0x3];/**< O/H Debug (only 1 in P1023) */
45287 + volatile uint32_t fmbm_ogpr; /**< O/H General Purpose Register. */
45288 + volatile uint32_t reserved7[0x3a];/**< (0x310 0x3FF) */
45289 +} t_FmPortOhBmiRegs;
45290 +
45291 +typedef union
45292 +{
45293 + t_FmPortRxBmiRegs rxPortBmiRegs;
45294 + t_FmPortTxBmiRegs txPortBmiRegs;
45295 + t_FmPortOhBmiRegs ohPortBmiRegs;
45296 +} u_FmPortBmiRegs;
45297 +
45298 +typedef struct
45299 +{
45300 + volatile uint32_t reserved1[2]; /**< 0xn024 - 0x02B */
45301 + volatile uint32_t fmqm_pndn; /**< PortID n Dequeue NIA Register */
45302 + volatile uint32_t fmqm_pndc; /**< PortID n Dequeue Config Register */
45303 + volatile uint32_t fmqm_pndtfc; /**< PortID n Dequeue Total Frame Counter */
45304 + volatile uint32_t fmqm_pndfdc; /**< PortID n Dequeue FQID from Default Counter */
45305 + volatile uint32_t fmqm_pndcc; /**< PortID n Dequeue Confirm Counter */
45306 +} t_FmPortNonRxQmiRegs;
45307 +
45308 +typedef struct
45309 +{
45310 + volatile uint32_t fmqm_pnc; /**< PortID n Configuration Register */
45311 + volatile uint32_t fmqm_pns; /**< PortID n Status Register */
45312 + volatile uint32_t fmqm_pnts; /**< PortID n Task Status Register */
45313 + volatile uint32_t reserved0[4]; /**< 0xn00C - 0xn01B */
45314 + volatile uint32_t fmqm_pnen; /**< PortID n Enqueue NIA Register */
45315 + volatile uint32_t fmqm_pnetfc; /**< PortID n Enqueue Total Frame Counter */
45316 + t_FmPortNonRxQmiRegs nonRxQmiRegs; /**< Registers for Tx Hc & Op ports */
45317 +} t_FmPortQmiRegs;
45318 +
45319 +typedef struct
45320 +{
45321 + struct
45322 + {
45323 + volatile uint32_t softSeqAttach; /**< Soft Sequence Attachment */
45324 + volatile uint32_t lcv; /**< Line-up Enable Confirmation Mask */
45325 + } hdrs[FM_PCD_PRS_NUM_OF_HDRS];
45326 + volatile uint32_t reserved0[0xde];
45327 + volatile uint32_t pcac; /**< Parse Internal Memory Configuration Access Control Register */
45328 + volatile uint32_t pctpid; /**< Parse Internal Memory Configured TPID Register */
45329 +} t_FmPortPrsRegs;
45330 +
45331 +/**************************************************************************//*
45332 + @Description Basic buffer descriptor (BD) structure
45333 +*//***************************************************************************/
45334 +typedef _Packed struct
45335 +{
45336 + volatile uint16_t status;
45337 + volatile uint16_t length;
45338 + volatile uint8_t reserved0[0x6];
45339 + volatile uint8_t reserved1[0x1];
45340 + volatile t_FmPhysAddr buff;
45341 +} _PackedType t_FmImBd;
45342 +
45343 +typedef _Packed struct
45344 +{
45345 + volatile uint16_t gen; /**< tbd */
45346 + volatile uint8_t reserved0[0x1];
45347 + volatile t_FmPhysAddr bdRingBase; /**< tbd */
45348 + volatile uint16_t bdRingSize; /**< tbd */
45349 + volatile uint16_t offsetIn; /**< tbd */
45350 + volatile uint16_t offsetOut; /**< tbd */
45351 + volatile uint8_t reserved1[0x12]; /**< 0x0e - 0x1f */
45352 +} _PackedType t_FmPortImQd;
45353 +
45354 +typedef _Packed struct
45355 +{
45356 + volatile uint32_t mode; /**< Mode register */
45357 + volatile uint32_t rxQdPtr; /**< tbd */
45358 + volatile uint32_t txQdPtr; /**< tbd */
45359 + volatile uint16_t mrblr; /**< tbd */
45360 + volatile uint16_t rxQdBsyCnt; /**< tbd */
45361 + volatile uint8_t reserved0[0x10]; /**< 0x10 - 0x1f */
45362 + t_FmPortImQd rxQd;
45363 + t_FmPortImQd txQd;
45364 + volatile uint8_t reserved1[0xa0]; /**< 0x60 - 0xff */
45365 +} _PackedType t_FmPortImPram;
45366 +
45367 +#if defined(__MWERKS__) && !defined(__GNUC__)
45368 +#pragma pack(pop)
45369 +#endif /* defined(__MWERKS__) && ... */
45370 +
45371 +
45372 +/**************************************************************************//**
45373 + @Description Registers bit fields
45374 +*//***************************************************************************/
45375 +
45376 +/**************************************************************************//**
45377 + @Description BMI defines
45378 +*//***************************************************************************/
45379 +#if (DPAA_VERSION >= 11)
45380 +#define BMI_SP_ID_MASK 0xff000000
45381 +#define BMI_SP_ID_SHIFT 24
45382 +#define BMI_SP_EN 0x01000000
45383 +#endif /* (DPAA_VERSION >= 11) */
45384 +
45385 +#define BMI_PORT_CFG_EN 0x80000000
45386 +#define BMI_PORT_CFG_EN_MACSEC 0x00800000
45387 +#define BMI_PORT_CFG_FDOVR 0x02000000
45388 +#define BMI_PORT_CFG_IM 0x01000000
45389 +#define BMI_PORT_CFG_AM 0x00000040
45390 +#define BMI_PORT_STATUS_BSY 0x80000000
45391 +#define BMI_COUNTERS_EN 0x80000000
45392 +
45393 +#define BMI_PORT_RFNE_FRWD_DCL4C 0x10000000
45394 +#define BMI_PORT_RFNE_FRWD_RPD 0x40000000
45395 +#define BMI_RFNE_FDCS_MASK 0xFF000000
45396 +#define BMI_RFNE_HXS_MASK 0x000000FF
45397 +
45398 +#define BMI_CMD_MR_LEAC 0x00200000
45399 +#define BMI_CMD_MR_SLEAC 0x00100000
45400 +#define BMI_CMD_MR_MA 0x00080000
45401 +#define BMI_CMD_MR_DEAS 0x00040000
45402 +#define BMI_CMD_RX_MR_DEF (BMI_CMD_MR_LEAC | \
45403 + BMI_CMD_MR_SLEAC | \
45404 + BMI_CMD_MR_MA | \
45405 + BMI_CMD_MR_DEAS)
45406 +#define BMI_CMD_ATTR_ORDER 0x80000000
45407 +#define BMI_CMD_ATTR_SYNC 0x02000000
45408 +#define BMI_CMD_ATTR_MODE_MISS_ALLIGN_ADDR_EN 0x00080000
45409 +#define BMI_CMD_ATTR_MACCMD_MASK 0x0000ff00
45410 +#define BMI_CMD_ATTR_MACCMD_OVERRIDE 0x00008000
45411 +#define BMI_CMD_ATTR_MACCMD_SECURED 0x00001000
45412 +#define BMI_CMD_ATTR_MACCMD_SC_MASK 0x00000f00
45413 +
45414 +#define BMI_EXT_BUF_POOL_ID_MASK 0x003F0000
45415 +#define BMI_STATUS_RX_MASK_UNUSED (uint32_t)(~(FM_PORT_FRM_ERR_DMA | \
45416 + FM_PORT_FRM_ERR_PHYSICAL | \
45417 + FM_PORT_FRM_ERR_SIZE | \
45418 + FM_PORT_FRM_ERR_CLS_DISCARD | \
45419 + FM_PORT_FRM_ERR_EXTRACTION | \
45420 + FM_PORT_FRM_ERR_NO_SCHEME | \
45421 + FM_PORT_FRM_ERR_COLOR_RED | \
45422 + FM_PORT_FRM_ERR_COLOR_YELLOW | \
45423 + FM_PORT_FRM_ERR_ILL_PLCR | \
45424 + FM_PORT_FRM_ERR_PLCR_FRAME_LEN | \
45425 + FM_PORT_FRM_ERR_PRS_TIMEOUT | \
45426 + FM_PORT_FRM_ERR_PRS_ILL_INSTRUCT | \
45427 + FM_PORT_FRM_ERR_BLOCK_LIMIT_EXCEEDED | \
45428 + FM_PORT_FRM_ERR_PRS_HDR_ERR | \
45429 + FM_PORT_FRM_ERR_IPRE | \
45430 + FM_PORT_FRM_ERR_IPR_NCSP | \
45431 + FM_PORT_FRM_ERR_KEYSIZE_OVERFLOW))
45432 +
45433 +#define BMI_STATUS_OP_MASK_UNUSED (uint32_t)(BMI_STATUS_RX_MASK_UNUSED & \
45434 + ~(FM_PORT_FRM_ERR_LENGTH | \
45435 + FM_PORT_FRM_ERR_NON_FM | \
45436 + FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT))
45437 +
45438 +#define BMI_RATE_LIMIT_EN 0x80000000
45439 +#define BMI_RATE_LIMIT_BURST_SIZE_GRAN 0x80000000
45440 +#define BMI_RATE_LIMIT_SCALE_BY_2 0x00000001
45441 +#define BMI_RATE_LIMIT_SCALE_BY_4 0x00000002
45442 +#define BMI_RATE_LIMIT_SCALE_BY_8 0x00000003
45443 +
45444 +#define BMI_RX_FIFO_THRESHOLD_BC 0x80000000
45445 +
45446 +#define BMI_PRS_RESULT_HIGH 0x00000000
45447 +#define BMI_PRS_RESULT_LOW 0xFFFFFFFF
45448 +
45449 +
45450 +#define RX_ERRS_TO_ENQ (FM_PORT_FRM_ERR_DMA | \
45451 + FM_PORT_FRM_ERR_PHYSICAL | \
45452 + FM_PORT_FRM_ERR_SIZE | \
45453 + FM_PORT_FRM_ERR_EXTRACTION | \
45454 + FM_PORT_FRM_ERR_NO_SCHEME | \
45455 + FM_PORT_FRM_ERR_ILL_PLCR | \
45456 + FM_PORT_FRM_ERR_PLCR_FRAME_LEN | \
45457 + FM_PORT_FRM_ERR_PRS_TIMEOUT | \
45458 + FM_PORT_FRM_ERR_PRS_ILL_INSTRUCT | \
45459 + FM_PORT_FRM_ERR_BLOCK_LIMIT_EXCEEDED | \
45460 + FM_PORT_FRM_ERR_PRS_HDR_ERR | \
45461 + FM_PORT_FRM_ERR_KEYSIZE_OVERFLOW | \
45462 + FM_PORT_FRM_ERR_IPRE)
45463 +
45464 +#define OP_ERRS_TO_ENQ (RX_ERRS_TO_ENQ | \
45465 + FM_PORT_FRM_ERR_LENGTH | \
45466 + FM_PORT_FRM_ERR_NON_FM | \
45467 + FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT)
45468 +
45469 +
45470 +#define BMI_RX_FIFO_PRI_ELEVATION_MASK 0x03FF0000
45471 +#define BMI_RX_FIFO_THRESHOLD_MASK 0x000003FF
45472 +#define BMI_TX_FIFO_MIN_FILL_MASK 0x03FF0000
45473 +#define BMI_FIFO_PIPELINE_DEPTH_MASK 0x0000F000
45474 +#define BMI_TX_LOW_COMF_MASK 0x000003FF
45475 +
45476 +/* shifts */
45477 +#define BMI_PORT_CFG_MS_SEL_SHIFT 16
45478 +#define BMI_DMA_ATTR_IC_CACHE_SHIFT FMAN_SP_DMA_ATTR_IC_CACHE_SHIFT
45479 +#define BMI_DMA_ATTR_HDR_CACHE_SHIFT FMAN_SP_DMA_ATTR_HDR_CACHE_SHIFT
45480 +#define BMI_DMA_ATTR_SG_CACHE_SHIFT FMAN_SP_DMA_ATTR_SG_CACHE_SHIFT
45481 +
45482 +#define BMI_IM_FOF_SHIFT 28
45483 +#define BMI_PR_PORTID_SHIFT 24
45484 +
45485 +#define BMI_RX_FIFO_PRI_ELEVATION_SHIFT 16
45486 +#define BMI_RX_FIFO_THRESHOLD_SHIFT 0
45487 +
45488 +#define BMI_RX_FRAME_END_CS_IGNORE_SHIFT 24
45489 +#define BMI_RX_FRAME_END_CUT_SHIFT 16
45490 +
45491 +#define BMI_IC_SIZE_SHIFT FMAN_SP_IC_SIZE_SHIFT
45492 +
45493 +#define BMI_INT_BUF_MARG_SHIFT 28
45494 +
45495 +#define BMI_EXT_BUF_MARG_END_SHIFT FMAN_SP_EXT_BUF_MARG_END_SHIFT
45496 +
45497 +#define BMI_CMD_ATTR_COLOR_SHIFT 26
45498 +#define BMI_CMD_ATTR_COM_MODE_SHIFT 16
45499 +#define BMI_CMD_ATTR_MACCMD_SHIFT 8
45500 +#define BMI_CMD_ATTR_MACCMD_OVERRIDE_SHIFT 15
45501 +#define BMI_CMD_ATTR_MACCMD_SECURED_SHIFT 12
45502 +#define BMI_CMD_ATTR_MACCMD_SC_SHIFT 8
45503 +
45504 +#define BMI_POOL_DEP_NUM_OF_POOLS_VECTOR_SHIFT 24
45505 +
45506 +#define BMI_TX_FIFO_MIN_FILL_SHIFT 16
45507 +#define BMI_TX_LOW_COMF_SHIFT 0
45508 +
45509 +#define BMI_PERFORMANCE_TASK_COMP_SHIFT 24
45510 +#define BMI_PERFORMANCE_PORT_COMP_SHIFT 16
45511 +#define BMI_PERFORMANCE_DMA_COMP_SHIFT 12
45512 +#define BMI_PERFORMANCE_FIFO_COMP_SHIFT 0
45513 +
45514 +#define BMI_MAX_BURST_SHIFT 16
45515 +#define BMI_COUNT_RATE_UNIT_SHIFT 16
45516 +
45517 +/* sizes */
45518 +#define FRAME_END_DATA_SIZE 16
45519 +#define FRAME_OFFSET_UNITS 16
45520 +#define MIN_TX_INT_OFFSET 16
45521 +#define MAX_FRAME_OFFSET 64
45522 +#define MAX_FIFO_PIPELINE_DEPTH 8
45523 +#define MAX_PERFORMANCE_TASK_COMP 64
45524 +#define MAX_PERFORMANCE_TX_QUEUE_COMP 8
45525 +#define MAX_PERFORMANCE_RX_QUEUE_COMP 64
45526 +#define MAX_PERFORMANCE_DMA_COMP 16
45527 +#define MAX_NUM_OF_TASKS 64
45528 +#define MAX_NUM_OF_EXTRA_TASKS 8
45529 +#define MAX_NUM_OF_DMAS 16
45530 +#define MAX_NUM_OF_EXTRA_DMAS 8
45531 +#define MAX_BURST_SIZE 1024
45532 +#define MIN_NUM_OF_OP_DMAS 2
45533 +
45534 +
45535 +/**************************************************************************//**
45536 + @Description QMI defines
45537 +*//***************************************************************************/
45538 +/* masks */
45539 +#define QMI_PORT_CFG_EN 0x80000000
45540 +#define QMI_PORT_CFG_EN_COUNTERS 0x10000000
45541 +#define QMI_PORT_STATUS_DEQ_TNUM_BSY 0x80000000
45542 +#define QMI_PORT_STATUS_DEQ_FD_BSY 0x20000000
45543 +
45544 +#define QMI_DEQ_CFG_PREFETCH_NO_TNUM 0x02000000
45545 +#define QMI_DEQ_CFG_PREFETCH_WAITING_TNUM 0
45546 +#define QMI_DEQ_CFG_PREFETCH_1_FRAME 0
45547 +#define QMI_DEQ_CFG_PREFETCH_3_FRAMES 0x01000000
45548 +
45549 +#define QMI_DEQ_CFG_PRI 0x80000000
45550 +#define QMI_DEQ_CFG_TYPE1 0x10000000
45551 +#define QMI_DEQ_CFG_TYPE2 0x20000000
45552 +#define QMI_DEQ_CFG_TYPE3 0x30000000
45553 +
45554 +#define QMI_DEQ_CFG_SUBPORTAL_MASK 0x1f
45555 +#define QMI_DEQ_CFG_SUBPORTAL_SHIFT 20
45556 +
45557 +/**************************************************************************//**
45558 + @Description PARSER defines
45559 +*//***************************************************************************/
45560 +/* masks */
45561 +#define PRS_HDR_ERROR_DIS 0x00000800
45562 +#define PRS_HDR_SW_PRS_EN 0x00000400
45563 +#define PRS_CP_OFFSET_MASK 0x0000000F
45564 +#define PRS_TPID1_MASK 0xFFFF0000
45565 +#define PRS_TPID2_MASK 0x0000FFFF
45566 +#define PRS_TPID_DFLT 0x91009100
45567 +
45568 +#define PRS_HDR_MPLS_LBL_INTER_EN 0x00200000
45569 +#define PRS_HDR_IPV6_ROUTE_HDR_EN 0x00008000
45570 +#define PRS_HDR_PPPOE_MTU_CHECK_EN 0x80000000
45571 +#define PRS_HDR_UDP_PAD_REMOVAL 0x80000000
45572 +#define PRS_HDR_TCP_PAD_REMOVAL 0x80000000
45573 +#define PRS_CAC_STOP 0x00000001
45574 +#define PRS_CAC_ACTIVE 0x00000100
45575 +
45576 +/* shifts */
45577 +#define PRS_PCTPID_SHIFT 16
45578 +#define PRS_HDR_MPLS_NEXT_HDR_SHIFT 22
45579 +#define PRS_HDR_ETH_BC_SHIFT 28
45580 +#define PRS_HDR_ETH_MC_SHIFT 24
45581 +#define PRS_HDR_VLAN_STACKED_SHIFT 16
45582 +#define PRS_HDR_MPLS_STACKED_SHIFT 16
45583 +#define PRS_HDR_IPV4_1_BC_SHIFT 28
45584 +#define PRS_HDR_IPV4_1_MC_SHIFT 24
45585 +#define PRS_HDR_IPV4_2_UC_SHIFT 20
45586 +#define PRS_HDR_IPV4_2_MC_BC_SHIFT 16
45587 +#define PRS_HDR_IPV6_1_MC_SHIFT 24
45588 +#define PRS_HDR_IPV6_2_UC_SHIFT 20
45589 +#define PRS_HDR_IPV6_2_MC_SHIFT 16
45590 +
45591 +#define PRS_HDR_ETH_BC_MASK 0x0fffffff
45592 +#define PRS_HDR_ETH_MC_MASK 0xf0ffffff
45593 +#define PRS_HDR_VLAN_STACKED_MASK 0xfff0ffff
45594 +#define PRS_HDR_MPLS_STACKED_MASK 0xfff0ffff
45595 +#define PRS_HDR_IPV4_1_BC_MASK 0x0fffffff
45596 +#define PRS_HDR_IPV4_1_MC_MASK 0xf0ffffff
45597 +#define PRS_HDR_IPV4_2_UC_MASK 0xff0fffff
45598 +#define PRS_HDR_IPV4_2_MC_BC_MASK 0xfff0ffff
45599 +#define PRS_HDR_IPV6_1_MC_MASK 0xf0ffffff
45600 +#define PRS_HDR_IPV6_2_UC_MASK 0xff0fffff
45601 +#define PRS_HDR_IPV6_2_MC_MASK 0xfff0ffff
45602 +
45603 +/* others */
45604 +#define PRS_HDR_ENTRY_SIZE 8
45605 +#define DEFAULT_CLS_PLAN_VECTOR 0xFFFFFFFF
45606 +
45607 +#define IPSEC_SW_PATCH_START 0x20
45608 +#define SCTP_SW_PATCH_START 0x4D
45609 +#define DCCP_SW_PATCH_START 0x41
45610 +
45611 +/**************************************************************************//**
45612 + @Description IM defines
45613 +*//***************************************************************************/
45614 +#define BD_R_E 0x80000000
45615 +#define BD_L 0x08000000
45616 +
45617 +#define BD_RX_CRE 0x00080000
45618 +#define BD_RX_FTL 0x00040000
45619 +#define BD_RX_FTS 0x00020000
45620 +#define BD_RX_OV 0x00010000
45621 +
45622 +#define BD_RX_ERRORS (BD_RX_CRE | BD_RX_FTL | BD_RX_FTS | BD_RX_OV)
45623 +
45624 +#define FM_IM_SIZEOF_BD sizeof(t_FmImBd)
45625 +
45626 +#define BD_STATUS_MASK 0xffff0000
45627 +#define BD_LENGTH_MASK 0x0000ffff
45628 +
45629 +#define BD_STATUS_AND_LENGTH_SET(bd, val) WRITE_UINT32(*(volatile uint32_t*)(bd), (val))
45630 +
45631 +#define BD_STATUS_AND_LENGTH(bd) GET_UINT32(*(volatile uint32_t*)(bd))
45632 +
45633 +#define BD_GET(id) &p_FmPort->im.p_BdRing[id]
45634 +
45635 +#define IM_ILEGAL_BD_ID 0xffff
45636 +
45637 +/* others */
45638 +#define IM_PRAM_ALIGN 0x100
45639 +
45640 +/* masks */
45641 +#define IM_MODE_GBL 0x20000000
45642 +#define IM_MODE_BO_MASK 0x18000000
45643 +#define IM_MODE_BO_SHIFT 3
45644 +#define IM_MODE_GRC_STP 0x00800000
45645 +
45646 +#define IM_MODE_SET_BO(val) (uint32_t)((val << (31-IM_MODE_BO_SHIFT)) & IM_MODE_BO_MASK)
45647 +
45648 +#define IM_RXQD_BSYINTM 0x0008
45649 +#define IM_RXQD_RXFINTM 0x0010
45650 +#define IM_RXQD_FPMEVT_SEL_MASK 0x0003
45651 +
45652 +#define IM_EV_BSY 0x40000000
45653 +#define IM_EV_RX 0x80000000
45654 +
45655 +
45656 +/**************************************************************************//**
45657 + @Description Additional defines
45658 +*//***************************************************************************/
45659 +
45660 +typedef struct {
45661 + t_Handle h_FmMuram;
45662 + t_FmPortImPram *p_FmPortImPram;
45663 + uint8_t fwExtStructsMemId;
45664 + uint32_t fwExtStructsMemAttr;
45665 + uint16_t bdRingSize;
45666 + t_FmImBd *p_BdRing;
45667 + t_Handle *p_BdShadow;
45668 + uint16_t currBdId;
45669 + uint16_t firstBdOfFrameId;
45670 +
45671 + /* Rx port parameters */
45672 + uint8_t dataMemId; /**< Memory partition ID for data buffers */
45673 + uint32_t dataMemAttributes; /**< Memory attributes for data buffers */
45674 + t_BufferPoolInfo rxPool;
45675 + uint16_t mrblr;
45676 + uint16_t rxFrameAccumLength;
45677 + t_FmPortImRxStoreCallback *f_RxStore;
45678 +
45679 + /* Tx port parameters */
45680 + uint32_t txFirstBdStatus;
45681 + t_FmPortImTxConfCallback *f_TxConf;
45682 +} t_FmMacIm;
45683 +
45684 +
45685 +typedef struct {
45686 + struct fman_port_cfg dfltCfg;
45687 + uint32_t dfltFqid;
45688 + uint32_t confFqid;
45689 + uint32_t errFqid;
45690 + uintptr_t baseAddr;
45691 + uint8_t deqSubPortal;
45692 + bool deqHighPriority;
45693 + e_FmPortDeqType deqType;
45694 + e_FmPortDeqPrefetchOption deqPrefetchOption;
45695 + uint16_t deqByteCnt;
45696 + uint8_t cheksumLastBytesIgnore;
45697 + uint8_t cutBytesFromEnd;
45698 + t_FmBufPoolDepletion bufPoolDepletion;
45699 + uint8_t pipelineDepth;
45700 + uint16_t fifoLowComfLevel;
45701 + bool frmDiscardOverride;
45702 + bool enRateLimit;
45703 + t_FmPortRateLimit rateLimit;
45704 + e_FmPortDualRateLimiterScaleDown rateLimitDivider;
45705 + bool enBufPoolDepletion;
45706 + uint16_t liodnOffset;
45707 + uint16_t liodnBase;
45708 + t_FmExtPools extBufPools;
45709 + e_FmDmaSwapOption dmaSwapData;
45710 + e_FmDmaCacheOption dmaIntContextCacheAttr;
45711 + e_FmDmaCacheOption dmaHeaderCacheAttr;
45712 + e_FmDmaCacheOption dmaScatterGatherCacheAttr;
45713 + bool dmaReadOptimize;
45714 + bool dmaWriteOptimize;
45715 + uint32_t txFifoMinFillLevel;
45716 + uint32_t txFifoLowComfLevel;
45717 + uint32_t rxFifoPriElevationLevel;
45718 + uint32_t rxFifoThreshold;
45719 + t_FmSpBufMargins bufMargins;
45720 + t_FmSpIntContextDataCopy intContext;
45721 + bool syncReq;
45722 + e_FmPortColor color;
45723 + fmPortFrameErrSelect_t errorsToDiscard;
45724 + fmPortFrameErrSelect_t errorsToEnq;
45725 + bool forwardReuseIntContext;
45726 + t_FmBufferPrefixContent bufferPrefixContent;
45727 + t_FmBackupBmPools *p_BackupBmPools;
45728 + bool dontReleaseBuf;
45729 + bool setNumOfTasks;
45730 + bool setNumOfOpenDmas;
45731 + bool setSizeOfFifo;
45732 +#if (DPAA_VERSION >= 11)
45733 + bool noScatherGather;
45734 +#endif /* (DPAA_VERSION >= 11) */
45735 +
45736 +#ifdef FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669
45737 + bool bcbWorkaround;
45738 +#endif /* FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669 */
45739 +} t_FmPortDriverParam;
45740 +
45741 +
45742 +typedef struct t_FmPortRxPoolsParams
45743 +{
45744 + uint8_t numOfPools;
45745 + uint16_t secondLargestBufSize;
45746 + uint16_t largestBufSize;
45747 +} t_FmPortRxPoolsParams;
45748 +
45749 +typedef struct t_FmPortDsarVars {
45750 + t_Handle *autoResOffsets;
45751 + t_FmPortDsarTablesSizes *autoResMaxSizes;
45752 + uint32_t fmbm_tcfg;
45753 + uint32_t fmbm_tcmne;
45754 + uint32_t fmbm_rfne;
45755 + uint32_t fmbm_rfpne;
45756 + uint32_t fmbm_rcfg;
45757 + bool dsarEnabledParser;
45758 +} t_FmPortDsarVars;
45759 +typedef struct {
45760 + struct fman_port port;
45761 + t_Handle h_Fm;
45762 + t_Handle h_FmPcd;
45763 + t_Handle h_FmMuram;
45764 + t_FmRevisionInfo fmRevInfo;
45765 + uint8_t portId;
45766 + e_FmPortType portType;
45767 + int enabled;
45768 + char name[MODULE_NAME_SIZE];
45769 + uint8_t hardwarePortId;
45770 + uint16_t fmClkFreq;
45771 + t_FmPortQmiRegs *p_FmPortQmiRegs;
45772 + u_FmPortBmiRegs *p_FmPortBmiRegs;
45773 + t_FmPortPrsRegs *p_FmPortPrsRegs;
45774 + fmPcdEngines_t pcdEngines;
45775 + uint32_t savedBmiNia;
45776 + uint8_t netEnvId;
45777 + uint32_t optArray[FM_PCD_MAX_NUM_OF_OPTIONS(FM_PCD_MAX_NUM_OF_CLS_PLANS)];
45778 + uint32_t lcvs[FM_PCD_PRS_NUM_OF_HDRS];
45779 + uint8_t privateInfo;
45780 + uint32_t schemesPerPortVector;
45781 + bool useClsPlan;
45782 + uint8_t clsPlanGrpId;
45783 + t_Handle ccTreeId;
45784 + t_Handle completeArg;
45785 + void (*f_Complete)(t_Handle arg);
45786 + t_FmSpBufferOffsets bufferOffsets;
45787 + /* Independent-Mode parameters support */
45788 + bool imEn;
45789 + t_FmMacIm im;
45790 + volatile bool lock;
45791 + t_Handle h_Spinlock;
45792 + t_FmPortExceptionCallback *f_Exception;
45793 + t_Handle h_App;
45794 + uint8_t internalBufferOffset;
45795 + uint8_t fmanCtrlEventId;
45796 + uint32_t exceptions;
45797 + bool polling;
45798 + t_FmExtPools extBufPools;
45799 + uint32_t requiredAction;
45800 + uint32_t savedQmiPnen;
45801 + uint32_t savedBmiFene;
45802 + uint32_t savedBmiFpne;
45803 + uint32_t savedBmiCmne;
45804 + uint32_t savedBmiOfp;
45805 + uint32_t savedNonRxQmiRegsPndn;
45806 + uint32_t origNonRxQmiRegsPndn;
45807 + int savedPrsStartOffset;
45808 + bool includeInPrsStatistics;
45809 + uint16_t maxFrameLength;
45810 + t_FmFmanCtrl orFmanCtrl;
45811 + t_FmPortRsrc openDmas;
45812 + t_FmPortRsrc tasks;
45813 + t_FmPortRsrc fifoBufs;
45814 + t_FmPortRxPoolsParams rxPoolsParams;
45815 +// bool explicitUserSizeOfFifo;
45816 + t_Handle h_IpReassemblyManip;
45817 + t_Handle h_CapwapReassemblyManip;
45818 + t_Handle h_ReassemblyTree;
45819 + uint64_t fmMuramPhysBaseAddr;
45820 +#if (DPAA_VERSION >= 11)
45821 + bool vspe;
45822 + uint8_t dfltRelativeId;
45823 + e_FmPortGprFuncType gprFunc;
45824 + t_FmPcdCtrlParamsPage *p_ParamsPage;
45825 +#endif /* (DPAA_VERSION >= 11) */
45826 + t_FmPortDsarVars deepSleepVars;
45827 + t_FmPortDriverParam *p_FmPortDriverParam;
45828 +} t_FmPort;
45829 +
45830 +
45831 +void FmPortConfigIM (t_FmPort *p_FmPort, t_FmPortParams *p_FmPortParams);
45832 +t_Error FmPortImCheckInitParameters(t_FmPort *p_FmPort);
45833 +
45834 +t_Error FmPortImInit(t_FmPort *p_FmPort);
45835 +void FmPortImFree(t_FmPort *p_FmPort);
45836 +
45837 +t_Error FmPortImEnable (t_FmPort *p_FmPort);
45838 +t_Error FmPortImDisable (t_FmPort *p_FmPort);
45839 +t_Error FmPortImRx (t_FmPort *p_FmPort);
45840 +
45841 +void FmPortSetMacsecLcv(t_Handle h_FmPort);
45842 +void FmPortSetMacsecCmd(t_Handle h_FmPort, uint8_t dfltSci);
45843 +
45844 +
45845 +t_Error FM_PORT_SetNumOfOpenDmas(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfOpenDmas);
45846 +t_Error FM_PORT_SetNumOfTasks(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfTasks);
45847 +t_Error FM_PORT_SetSizeOfFifo(t_Handle h_FmPort, t_FmPortRsrc *p_SizeOfFifo);
45848 +
45849 +static __inline__ uint8_t * BdBufferGet (t_PhysToVirt *f_PhysToVirt, t_FmImBd *p_Bd)
45850 +{
45851 + uint64_t physAddr = (uint64_t)((uint64_t)GET_UINT8(p_Bd->buff.high) << 32);
45852 + physAddr |= GET_UINT32(p_Bd->buff.low);
45853 +
45854 + return (uint8_t *)f_PhysToVirt((physAddress_t)(physAddr));
45855 +}
45856 +
45857 +static __inline__ void SET_ADDR(volatile t_FmPhysAddr *fmPhysAddr, uint64_t value)
45858 +{
45859 + WRITE_UINT8(fmPhysAddr->high,(uint8_t)((value & 0x000000ff00000000LL) >> 32));
45860 + WRITE_UINT32(fmPhysAddr->low,(uint32_t)value);
45861 +}
45862 +
45863 +static __inline__ void BdBufferSet(t_VirtToPhys *f_VirtToPhys, t_FmImBd *p_Bd, uint8_t *p_Buffer)
45864 +{
45865 + uint64_t physAddr = (uint64_t)(f_VirtToPhys(p_Buffer));
45866 + SET_ADDR(&p_Bd->buff, physAddr);
45867 +}
45868 +
45869 +static __inline__ uint16_t GetNextBdId(t_FmPort *p_FmPort, uint16_t id)
45870 +{
45871 + if (id < p_FmPort->im.bdRingSize-1)
45872 + return (uint16_t)(id+1);
45873 + else
45874 + return 0;
45875 +}
45876 +
45877 +void FM_PORT_Dsar_DumpRegs(void);
45878 +
45879 +
45880 +#endif /* __FM_PORT_H */
45881 --- /dev/null
45882 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port_dsar.h
45883 @@ -0,0 +1,494 @@
45884 +/*
45885 + * Copyright 2008-2012 Freescale Semiconductor Inc.
45886 + *
45887 + * Redistribution and use in source and binary forms, with or without
45888 + * modification, are permitted provided that the following conditions are met:
45889 + * * Redistributions of source code must retain the above copyright
45890 + * notice, this list of conditions and the following disclaimer.
45891 + * * Redistributions in binary form must reproduce the above copyright
45892 + * notice, this list of conditions and the following disclaimer in the
45893 + * documentation and/or other materials provided with the distribution.
45894 + * * Neither the name of Freescale Semiconductor nor the
45895 + * names of its contributors may be used to endorse or promote products
45896 + * derived from this software without specific prior written permission.
45897 + *
45898 + *
45899 + * ALTERNATIVELY, this software may be distributed under the terms of the
45900 + * GNU General Public License ("GPL") as published by the Free Software
45901 + * Foundation, either version 2 of that License or (at your option) any
45902 + * later version.
45903 + *
45904 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
45905 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
45906 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
45907 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
45908 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
45909 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45910 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45911 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
45912 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45913 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45914 + */
45915 +
45916 +/**************************************************************************//**
45917 + @File fm_port_dsar.h
45918 +
45919 + @Description Deep Sleep Auto Response project - common module header file.
45920 +
45921 + Author - Eyal Harari
45922 +
45923 + @Cautions See the FMan Controller spec and design document for more information.
45924 +*//***************************************************************************/
45925 +
45926 +#ifndef __FM_PORT_DSAR_H_
45927 +#define __FM_PORT_DSAR_H_
45928 +
45929 +#define DSAR_GETSER_MASK 0xFF0000FF
45930 +
45931 +#if defined(__MWERKS__) && !defined(__GNUC__)
45932 +#pragma pack(push,1)
45933 +#endif /* defined(__MWERKS__) && ... */
45934 +
45935 +/**************************************************************************//**
45936 + @Description Deep Sleep Auto Response VLAN-IPv4 Binding Table (for ARP/ICMPv4)
45937 + Refer to the FMan Controller spec for more details.
45938 +*//***************************************************************************/
45939 +typedef _Packed struct
45940 +{
45941 + uint32_t ipv4Addr; /*!< 32 bit IPv4 Address. */
45942 + uint16_t vlanId; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
45943 + /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
45944 + uint16_t reserved;
45945 +} _PackedType t_DsarArpBindingEntry;
45946 +
45947 +/**************************************************************************//**
45948 + @Description Deep Sleep Auto Response Address Resolution Protocol Statistics Descriptor
45949 + Refer to the FMan Controller spec for more details.
45950 + 0x00 INVAL_CNT Invalid ARP IPv4-Ethernet counter
45951 + 0x04 ECHO_CNT Echo counter
45952 + 0x08 CD_CNT Conflict Detection counter
45953 + 0x0C AR_CNT Auto-Response counter
45954 + 0x10 RATM_CNT Replies Addressed To Me counter
45955 + 0x14 UKOP_CNT Unknown Operation counter
45956 + 0x18 NMTP_CNT Not my TPA counter
45957 + 0x1C NMVLAN_CNT Not My VLAN counter
45958 +*//***************************************************************************/
45959 +typedef _Packed struct
45960 +{
45961 + uint32_t invalCnt; /**< Invalid ARP IPv4-Ethernet counter. */
45962 + uint32_t echoCnt; /**< Echo counter. */
45963 + uint32_t cdCnt; /**< Conflict Detection counter. */
45964 + uint32_t arCnt; /**< Auto-Response counter. */
45965 + uint32_t ratmCnt; /**< Replies Addressed To Me counter. */
45966 + uint32_t ukopCnt; /**< Unknown Operation counter. */
45967 + uint32_t nmtpCnt; /**< Not my TPA counter. */
45968 + uint32_t nmVlanCnt; /**< Not My VLAN counter */
45969 +} _PackedType t_DsarArpStatistics;
45970 +
45971 +
45972 +/**************************************************************************//**
45973 + @Description Deep Sleep Auto Response Address Resolution Protocol Descriptor
45974 + 0x0 0-15 Control bits [0-15]. Bit 15 = CDEN.
45975 + 0x2 0-15 NumOfBindings Number of entries in the binding list.
45976 + 0x4 0-15 BindingsPointer Bindings Pointer. This points to an IPv4-MAC Addresses Bindings list.
45977 + 0x6 0-15
45978 + 0x8 0-15 StatisticsPointer Statistics Pointer. This field points to the ARP Descriptors statistics data structure.
45979 + 0xA 0-15
45980 + 0xC 0-15 Reserved Reserved. Must be cleared.
45981 + 0xE 015
45982 +
45983 +*//***************************************************************************/
45984 +typedef _Packed struct
45985 +{
45986 + uint16_t control; /** Control bits [0-15]. Bit 15 = CDEN */
45987 + uint16_t numOfBindings; /**< Number of VLAN-IPv4 */
45988 + uint32_t p_Bindings; /**< VLAN-IPv4 Bindings table pointer. */
45989 + uint32_t p_Statistics; /**< Statistics Data Structure pointer. */
45990 + uint32_t reserved1; /**< Reserved. */
45991 +} _PackedType t_DsarArpDescriptor;
45992 +
45993 +
45994 +/**************************************************************************//**
45995 + @Description Deep Sleep Auto Response VLAN-IPv4 Binding Table (for ARP/ICMPv4)
45996 + Refer to the FMan Controller spec for more details.
45997 +*//***************************************************************************/
45998 +typedef _Packed struct
45999 +{
46000 + uint32_t ipv4Addr; /*!< 32 bit IPv4 Address. */
46001 + uint16_t vlanId; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
46002 + /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
46003 + uint16_t reserved;
46004 +} _PackedType t_DsarIcmpV4BindingEntry;
46005 +
46006 +/**************************************************************************//**
46007 + @Description Deep Sleep Auto Response ICMPv4 Statistics Descriptor
46008 + Refer to the FMan Controller spec for more details.
46009 + 0x00 INVAL_CNT Invalid ICMPv4 header counter
46010 + 0x04 NMVLAN_CNT Not My VLAN counter
46011 + 0x08 NMIP_CNT Not My IP counter
46012 + 0x0C AR_CNT Auto-Response counter
46013 + 0x10 CSERR_CNT Checksum Error counter
46014 + 0x14 Reserved Reserved
46015 + 0x18 Reserved Reserved
46016 + 0x1C Reserved Reserved
46017 +
46018 +*//***************************************************************************/
46019 +typedef _Packed struct
46020 +{
46021 + uint32_t invalCnt; /**< Invalid ICMPv4 Echo counter. */
46022 + uint32_t nmVlanCnt; /**< Not My VLAN counter */
46023 + uint32_t nmIpCnt; /**< Not My IP counter */
46024 + uint32_t arCnt; /**< Auto-Response counter */
46025 + uint32_t cserrCnt; /**< Checksum Error counter */
46026 + uint32_t reserved0; /**< Reserved */
46027 + uint32_t reserved1; /**< Reserved */
46028 + uint32_t reserved2; /**< Reserved */
46029 +} _PackedType t_DsarIcmpV4Statistics;
46030 +
46031 +
46032 +
46033 +/**************************************************************************//**
46034 + @Description Deep Sleep Auto Response ICMPv4 Descriptor
46035 + 0x0 0-15 Control bits [0-15]
46036 + 0x2 0-15 NumOfBindings Number of entries in the binding list.
46037 + 0x4 0-15 BindingsPointer Bindings Pointer. This points to an VLAN-IPv4 Addresses Bindings list.
46038 + 0x6 0-15
46039 + 0x8 0-15 StatisticsPointer Statistics Pointer. This field points to the ICMPv4 statistics data structure.
46040 + 0xA 0-15
46041 + 0xC 0-15 Reserved Reserved. Must be cleared.
46042 + 0xE 015
46043 +
46044 +*//***************************************************************************/
46045 +typedef _Packed struct
46046 +{
46047 + uint16_t control; /** Control bits [0-15]. */
46048 + uint16_t numOfBindings; /**< Number of VLAN-IPv4 */
46049 + uint32_t p_Bindings; /**< VLAN-IPv4 Bindings table pointer. */
46050 + uint32_t p_Statistics; /**< Statistics Data Structure pointer. */
46051 + uint32_t reserved1; /**< Reserved. */
46052 +} _PackedType t_DsarIcmpV4Descriptor;
46053 +
46054 +/**************************************************************************//**
46055 + @Description Deep Sleep Auto Response VLAN-IPv4 Binding Table (for ARP/ICMPv4)
46056 + The 4 left-most bits (15:12) of the VlanId parameter are control flags.
46057 + Flags[3:1] (VlanId[15:13]): Reserved, should be cleared.
46058 + Flags[0] (VlanId[12]): Temporary address.
46059 + ? 0 - Assigned IP address.
46060 + ? 1- Temporary (tentative) IP address.
46061 + Refer to the FMan Controller spec for more details.
46062 +*//***************************************************************************/
46063 +typedef _Packed struct
46064 +{
46065 + uint32_t ipv6Addr[4]; /*!< 3 * 32 bit IPv4 Address. */
46066 + uint16_t resFlags:4; /*!< reserved flags. should be cleared */
46067 + uint16_t vlanId:12; /*!< 12 bits VLAN ID. */
46068 + /*!< This field should be 0x000 for an entry with no VLAN tag or a null VLAN ID. */
46069 + uint16_t reserved;
46070 +} _PackedType t_DsarIcmpV6BindingEntry;
46071 +
46072 +/**************************************************************************//**
46073 + @Description Deep Sleep Auto Response ICMPv4 Statistics Descriptor
46074 + Refer to the FMan Controller spec for more details.
46075 + 0x00 INVAL_CNT Invalid ICMPv4 header counter
46076 + 0x04 NMVLAN_CNT Not My VLAN counter
46077 + 0x08 NMIP_CNT Not My IP counter
46078 + 0x0C AR_CNT Auto-Response counter
46079 + 0x10 CSERR_CNT Checksum Error counter
46080 + 0x14 MCAST_CNT Multicast counter
46081 + 0x18 Reserved Reserved
46082 + 0x1C Reserved Reserved
46083 +
46084 +*//***************************************************************************/
46085 +typedef _Packed struct
46086 +{
46087 + uint32_t invalCnt; /**< Invalid ICMPv4 Echo counter. */
46088 + uint32_t nmVlanCnt; /**< Not My VLAN counter */
46089 + uint32_t nmIpCnt; /**< Not My IP counter */
46090 + uint32_t arCnt; /**< Auto-Response counter */
46091 + uint32_t reserved1; /**< Reserved */
46092 + uint32_t reserved2; /**< Reserved */
46093 + uint32_t reserved3; /**< Reserved */
46094 + uint32_t reserved4; /**< Reserved */
46095 +} _PackedType t_DsarIcmpV6Statistics;
46096 +
46097 +/**************************************************************************//**
46098 + @Description Deep Sleep Auto Response Neighbor Discovery Statistics Descriptor
46099 + 0x00 INVAL_CNT Invalid Neighbor Discovery message counter
46100 + 0x04 NMVLAN_CNT Not My VLAN counter
46101 + 0x08 NMIP_CNT Not My IP counter
46102 + 0x0C AR_CNT Auto-Response counter
46103 + 0x10 CSERR_CNT Checksum Error counter
46104 + 0x14 USADVERT_CNT Unsolicited Neighbor Advertisements counter
46105 + 0x18 NMMCAST_CNT Not My Multicast group counter
46106 + 0x1C NSLLA_CNT No Source Link-Layer Address counter. Indicates that there was a match on a Target
46107 + Address of a packet that its source IP address is a unicast address, but the ICMPv6
46108 + Source Link-layer Address option is omitted
46109 +*//***************************************************************************/
46110 +typedef _Packed struct
46111 +{
46112 + uint32_t invalCnt; /**< Invalid ICMPv4 Echo counter. */
46113 + uint32_t nmVlanCnt; /**< Not My VLAN counter */
46114 + uint32_t nmIpCnt; /**< Not My IP counter */
46115 + uint32_t arCnt; /**< Auto-Response counter */
46116 + uint32_t reserved1; /**< Reserved */
46117 + uint32_t usadvertCnt; /**< Unsolicited Neighbor Advertisements counter */
46118 + uint32_t nmmcastCnt; /**< Not My Multicast group counter */
46119 + uint32_t nsllaCnt; /**< No Source Link-Layer Address counter */
46120 +} _PackedType t_NdStatistics;
46121 +
46122 +/**************************************************************************//**
46123 + @Description Deep Sleep Auto Response ICMPv6 Descriptor
46124 + 0x0 0-15 Control bits [0-15]
46125 + 0x2 0-15 NumOfBindings Number of entries in the binding list.
46126 + 0x4 0-15 BindingsPointer Bindings Pointer. This points to an VLAN-IPv4 Addresses Bindings list.
46127 + 0x6 0-15
46128 + 0x8 0-15 StatisticsPointer Statistics Pointer. This field points to the ICMPv4 statistics data structure.
46129 + 0xA 0-15
46130 + 0xC 0-15 Reserved Reserved. Must be cleared.
46131 + 0xE 015
46132 +
46133 +*//***************************************************************************/
46134 +typedef _Packed struct
46135 +{
46136 + uint16_t control; /** Control bits [0-15]. */
46137 + uint16_t numOfBindings; /**< Number of VLAN-IPv6 */
46138 + uint32_t p_Bindings; /**< VLAN-IPv4 Bindings table pointer. */
46139 + uint32_t p_Statistics; /**< Statistics Data Structure pointer. */
46140 + uint32_t reserved1; /**< Reserved. */
46141 +} _PackedType t_DsarIcmpV6Descriptor;
46142 +
46143 +
46144 +/**************************************************************************//**
46145 + @Description Internet Control Message Protocol (ICMPv6) Echo message header
46146 + The fields names are taken from RFC 4443.
46147 +*//***************************************************************************/
46148 +/* 0 1 2 3 */
46149 +/* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 */
46150 +/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
46151 +/* | Type | Code | Checksum | */
46152 +/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
46153 +/* | Identifier | Sequence Number | */
46154 +/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
46155 +/* | Data ... */
46156 +/* +-+-+-+-+- */
46157 +typedef _Packed struct
46158 +{
46159 + uint8_t type;
46160 + uint8_t code;
46161 + uint16_t checksum;
46162 + uint16_t identifier;
46163 + uint16_t sequenceNumber;
46164 +} _PackedType t_IcmpV6EchoHdr;
46165 +
46166 +/**************************************************************************//**
46167 + @Description Internet Control Message Protocol (ICMPv6)
46168 + Neighbor Solicitation/Advertisement header
46169 + The fields names are taken from RFC 4861.
46170 + The R/S/O fields are valid for Neighbor Advertisement only
46171 +*//***************************************************************************/
46172 +/* 0 1 2 3
46173 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
46174 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46175 + * | Type | Code | Checksum |
46176 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46177 + * |R|S|O| Reserved |
46178 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46179 + * | |
46180 + * + +
46181 + * | |
46182 + * + Target Address +
46183 + * | |
46184 + * + +
46185 + * | |
46186 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46187 + * | Options ...
46188 + * +-+-+-+-+-+-+-+-+-+-+-+-
46189 + *
46190 + * Options Format:
46191 + * 0 1 2 3
46192 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
46193 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46194 + * | Type | Length | Link-Layer Address ... |
46195 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46196 + * | Link-Layer Address |
46197 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46198 +*/
46199 +typedef _Packed struct
46200 +{
46201 + uint8_t type;
46202 + uint8_t code;
46203 + uint16_t checksum;
46204 + uint32_t router:1;
46205 + uint32_t solicited:1;
46206 + uint32_t override:1;
46207 + uint32_t reserved:29;
46208 + uint32_t targetAddr[4];
46209 + uint8_t optionType;
46210 + uint8_t optionLength;
46211 + uint8_t linkLayerAddr[6];
46212 +} _PackedType t_IcmpV6NdHdr;
46213 +
46214 +/**************************************************************************//**
46215 + @Description Deep Sleep Auto Response ICMPv6 Descriptor
46216 + 0x0 0-15 Control bits [0-15]
46217 + 0x2 0-15 NumOfBindings Number of entries in the binding list.
46218 + 0x4 0-15 BindingsPointer Bindings Pointer. This points to an VLAN-IPv4 Addresses Bindings list.
46219 + 0x6 0-15
46220 + 0x8 0-15 StatisticsPointer Statistics Pointer. This field points to the ICMPv4 statistics data structure.
46221 + 0xA 0-15
46222 + 0xC 0-15 Reserved Reserved. Must be cleared.
46223 + 0xE 015
46224 +
46225 +*//***************************************************************************/
46226 +typedef _Packed struct
46227 +{
46228 + uint16_t control; /** Control bits [0-15]. */
46229 + uint16_t numOfBindings; /**< Number of VLAN-IPv6 */
46230 + uint32_t p_Bindings; /**< VLAN-IPv4 Bindings table pointer. */
46231 + uint32_t p_Statistics; /**< Statistics Data Structure pointer. */
46232 + uint32_t solicitedAddr; /**< Solicited Node Multicast Group Address */
46233 +} _PackedType t_DsarNdDescriptor;
46234 +
46235 +/**************************************************************************//**
46236 +@Description Deep Sleep Auto Response SNMP OIDs table entry
46237 +
46238 +*//***************************************************************************/
46239 +typedef struct {
46240 + uint16_t oidSize; /**< Size in octets of the OID. */
46241 + uint16_t resSize; /**< Size in octets of the value that is attached to the OID. */
46242 + uint32_t p_Oid; /**< Pointer to the OID. OID is encoded in BER but type and length are excluded. */
46243 + uint32_t resValOrPtr; /**< Value (for up to 4 octets) or pointer to the Value. Encoded in BER. */
46244 + uint32_t reserved;
46245 +} t_OidsTblEntry;
46246 +
46247 +/**************************************************************************//**
46248 + @Description Deep Sleep Auto Response SNMP IPv4 Addresses Table Entry
46249 + Refer to the FMan Controller spec for more details.
46250 +*//***************************************************************************/
46251 +typedef struct
46252 +{
46253 + uint32_t ipv4Addr; /*!< 32 bit IPv4 Address. */
46254 + uint16_t vlanId; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
46255 + /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
46256 + uint16_t reserved;
46257 +} t_DsarSnmpIpv4AddrTblEntry;
46258 +
46259 +/**************************************************************************//**
46260 + @Description Deep Sleep Auto Response SNMP IPv6 Addresses Table Entry
46261 + Refer to the FMan Controller spec for more details.
46262 +*//***************************************************************************/
46263 +#pragma pack(push,1)
46264 +typedef struct
46265 +{
46266 + uint32_t ipv6Addr[4]; /*!< 4 * 32 bit IPv6 Address. */
46267 + uint16_t vlanId; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
46268 + /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
46269 + uint16_t reserved;
46270 +} t_DsarSnmpIpv6AddrTblEntry;
46271 +#pragma pack(pop)
46272 +
46273 +/**************************************************************************//**
46274 +@Description Deep Sleep Auto Response SNMP statistics table
46275 +
46276 +*//***************************************************************************/
46277 +typedef struct {
46278 + uint32_t snmpErrCnt; /**< Counts SNMP errors (wrong version, BER encoding, format). */
46279 + uint32_t snmpCommunityErrCnt; /**< Counts messages that were dropped due to insufficient permission. */
46280 + uint32_t snmpTotalDiscardCnt; /**< Counts any message that was dropped. */
46281 + uint32_t snmpGetReqCnt; /**< Counts the number of get-request messages */
46282 + uint32_t snmpGetNextReqCnt; /**< Counts the number of get-next-request messages */
46283 +} t_DsarSnmpStatistics;
46284 +
46285 +/**************************************************************************//**
46286 + @Description Deep Sleep Auto Response SNMP Descriptor
46287 +
46288 +*//***************************************************************************/
46289 +typedef struct
46290 +{
46291 + uint16_t control; /**< Control bits [0-15]. */
46292 + uint16_t maxSnmpMsgLength; /**< Maximal allowed SNMP message length. */
46293 + uint16_t numOfIpv4Addresses; /**< Number of entries in IPv4 addresses table. */
46294 + uint16_t numOfIpv6Addresses; /**< Number of entries in IPv6 addresses table. */
46295 + uint32_t p_Ipv4AddrTbl; /**< Pointer to IPv4 addresses table. */
46296 + uint32_t p_Ipv6AddrTbl; /**< Pointer to IPv6 addresses table. */
46297 + uint32_t p_RdOnlyCommunityStr; /**< Pointer to the Read Only Community String. */
46298 + uint32_t p_RdWrCommunityStr; /**< Pointer to the Read Write Community String. */
46299 + uint32_t p_OidsTbl; /**< Pointer to OIDs table. */
46300 + uint32_t oidsTblSize; /**< Number of entries in OIDs table. */
46301 + uint32_t p_Statistics; /**< Pointer to SNMP statistics table. */
46302 +} t_DsarSnmpDescriptor;
46303 +
46304 +/**************************************************************************//**
46305 +@Description Deep Sleep Auto Response (Common) Statistics
46306 +
46307 +*//***************************************************************************/
46308 +typedef _Packed struct {
46309 + uint32_t dsarDiscarded;
46310 + uint32_t dsarErrDiscarded;
46311 + uint32_t dsarFragDiscarded;
46312 + uint32_t dsarTunnelDiscarded;
46313 + uint32_t dsarArpDiscarded;
46314 + uint32_t dsarIpDiscarded;
46315 + uint32_t dsarTcpDiscarded;
46316 + uint32_t dsarUdpDiscarded;
46317 + uint32_t dsarIcmpV6ChecksumErr; /* ICMPv6 Checksum Error counter */
46318 + uint32_t dsarIcmpV6OtherType; /* ICMPv6 'Other' type (not Echo or Neighbor Solicitaion/Advertisement counter */
46319 + uint32_t dsarIcmpV4OtherType; /* ICMPv4 'Other' type (not Echo) counter */
46320 +} _PackedType t_ArStatistics;
46321 +
46322 +
46323 +/**************************************************************************//**
46324 +@Description Deep Sleep Auto Response TCP/UDP port filter table entry
46325 +
46326 +*//***************************************************************************/
46327 +typedef _Packed struct {
46328 + uint32_t Ports;
46329 + uint32_t PortsMask;
46330 +} _PackedType t_PortTblEntry;
46331 +
46332 +
46333 +
46334 +/**************************************************************************//**
46335 +@Description Deep Sleep Auto Response Common Parameters Descriptor
46336 +
46337 +*//***************************************************************************/
46338 +typedef _Packed struct {
46339 + uint8_t arTxPort; /* 0x00 0-7 Auto Response Transmit Port number */
46340 + uint8_t controlBits; /* 0x00 8-15 Auto Response control bits */
46341 + uint16_t res1; /* 0x00 16-31 Reserved */
46342 + uint32_t activeHPNIA; /* 0x04 0-31 Active mode Hardware Parser NIA */
46343 + uint16_t snmpPort; /* 0x08 0-15 SNMP Port. */
46344 + uint8_t macStationAddr[6]; /* 0x08 16-31 and 0x0C 0-31 MAC Station Address */
46345 + uint8_t res2; /* 0x10 0-7 Reserved */
46346 + uint8_t filterControl; /* 0x10 8-15 Filtering Control Bits. */
46347 + uint16_t tcpControlPass; /* 0x10 16-31 TCP control pass flags */
46348 + uint8_t ipProtocolTblSize; /* 0x14 0-7 IP Protocol Table Size. */
46349 + uint8_t udpPortTblSize; /* 0x14 8-15 UDP Port Table Size. */
46350 + uint8_t tcpPortTblSize; /* 0x14 16-23 TCP Port Table Size. */
46351 + uint8_t res3; /* 0x14 24-31 Reserved */
46352 + uint32_t p_IpProtocolFiltTbl; /* 0x18 0-31 Pointer to IP Protocol Filter Table */
46353 + uint32_t p_UdpPortFiltTbl; /* 0x1C 0-31 Pointer to UDP Port Filter Table */
46354 + uint32_t p_TcpPortFiltTbl; /* 0x20 0-31 Pointer to TCP Port Filter Table */
46355 + uint32_t res4; /* 0x24 Reserved */
46356 + uint32_t p_ArpDescriptor; /* 0x28 0-31 ARP Descriptor Pointer. */
46357 + uint32_t p_NdDescriptor; /* 0x2C 0-31 Neighbor Discovery Descriptor. */
46358 + uint32_t p_IcmpV4Descriptor; /* 0x30 0-31 ICMPv4 Descriptor pointer. */
46359 + uint32_t p_IcmpV6Descriptor; /* 0x34 0-31 ICMPv6 Descriptor pointer. */
46360 + uint32_t p_SnmpDescriptor; /* 0x38 0-31 SNMP Descriptor pointer. */
46361 + uint32_t p_ArStats; /* 0x3C 0-31 Pointer to Auto Response Statistics */
46362 +} _PackedType t_ArCommonDesc;
46363 +
46364 +#if defined(__MWERKS__) && !defined(__GNUC__)
46365 +#pragma pack(pop)
46366 +#endif /* defined(__MWERKS__) && ... */
46367 +
46368 +/* t_ArCommonDesc.filterControl bits */
46369 +#define IP_PROT_TBL_PASS_MASK 0x08
46370 +#define UDP_PORT_TBL_PASS_MASK 0x04
46371 +#define TCP_PORT_TBL_PASS_MASK 0x02
46372 +
46373 +/* Offset of TCF flags within TCP packet */
46374 +#define TCP_FLAGS_OFFSET 12
46375 +
46376 +
46377 +#endif /* __FM_PORT_DSAR_H_ */
46378 --- /dev/null
46379 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port_im.c
46380 @@ -0,0 +1,753 @@
46381 +/*
46382 + * Copyright 2008-2012 Freescale Semiconductor Inc.
46383 + *
46384 + * Redistribution and use in source and binary forms, with or without
46385 + * modification, are permitted provided that the following conditions are met:
46386 + * * Redistributions of source code must retain the above copyright
46387 + * notice, this list of conditions and the following disclaimer.
46388 + * * Redistributions in binary form must reproduce the above copyright
46389 + * notice, this list of conditions and the following disclaimer in the
46390 + * documentation and/or other materials provided with the distribution.
46391 + * * Neither the name of Freescale Semiconductor nor the
46392 + * names of its contributors may be used to endorse or promote products
46393 + * derived from this software without specific prior written permission.
46394 + *
46395 + *
46396 + * ALTERNATIVELY, this software may be distributed under the terms of the
46397 + * GNU General Public License ("GPL") as published by the Free Software
46398 + * Foundation, either version 2 of that License or (at your option) any
46399 + * later version.
46400 + *
46401 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
46402 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
46403 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
46404 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
46405 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
46406 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46407 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46408 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46409 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
46410 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46411 + */
46412 +
46413 +
46414 +/******************************************************************************
46415 + @File fm_port_im.c
46416 +
46417 + @Description FM Port Independent-Mode ...
46418 +*//***************************************************************************/
46419 +#include "std_ext.h"
46420 +#include "string_ext.h"
46421 +#include "error_ext.h"
46422 +#include "memcpy_ext.h"
46423 +#include "fm_muram_ext.h"
46424 +
46425 +#include "fm_port.h"
46426 +
46427 +
46428 +#define TX_CONF_STATUS_UNSENT 0x1
46429 +
46430 +
46431 +typedef enum e_TxConfType
46432 +{
46433 + e_TX_CONF_TYPE_CHECK = 0 /**< check if all the buffers were touched by the muxator, no confirmation callback */
46434 + ,e_TX_CONF_TYPE_CALLBACK = 1 /**< confirm to user all the available sent buffers */
46435 + ,e_TX_CONF_TYPE_FLUSH = 3 /**< confirm all buffers plus the unsent one with an appropriate status */
46436 +} e_TxConfType;
46437 +
46438 +
46439 +static void ImException(t_Handle h_FmPort, uint32_t event)
46440 +{
46441 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
46442 +
46443 + ASSERT_COND(((event & (IM_EV_RX | IM_EV_BSY)) && FmIsMaster(p_FmPort->h_Fm)) ||
46444 + !FmIsMaster(p_FmPort->h_Fm));
46445 +
46446 + if (event & IM_EV_RX)
46447 + FmPortImRx(p_FmPort);
46448 + if ((event & IM_EV_BSY) && p_FmPort->f_Exception)
46449 + p_FmPort->f_Exception(p_FmPort->h_App, e_FM_PORT_EXCEPTION_IM_BUSY);
46450 +}
46451 +
46452 +
46453 +static t_Error TxConf(t_FmPort *p_FmPort, e_TxConfType confType)
46454 +{
46455 + t_Error retVal = E_BUSY;
46456 + uint32_t bdStatus;
46457 + uint16_t savedStartBdId, confBdId;
46458 +
46459 + ASSERT_COND(p_FmPort);
46460 +
46461 + /*
46462 + if (confType==e_TX_CONF_TYPE_CHECK)
46463 + return (WfqEntryIsQueueEmpty(p_FmPort->im.h_WfqEntry) ? E_OK : E_BUSY);
46464 + */
46465 +
46466 + confBdId = savedStartBdId = p_FmPort->im.currBdId;
46467 + bdStatus = BD_STATUS_AND_LENGTH(BD_GET(confBdId));
46468 +
46469 + /* If R bit is set, we don't enter, or we break.
46470 + we run till we get to R, or complete the loop */
46471 + while ((!(bdStatus & BD_R_E) || (confType == e_TX_CONF_TYPE_FLUSH)) && (retVal != E_OK))
46472 + {
46473 + if (confType & e_TX_CONF_TYPE_CALLBACK) /* if it is confirmation with user callbacks */
46474 + BD_STATUS_AND_LENGTH_SET(BD_GET(confBdId), 0);
46475 +
46476 + /* case 1: R bit is 0 and Length is set -> confirm! */
46477 + if ((confType & e_TX_CONF_TYPE_CALLBACK) && (bdStatus & BD_LENGTH_MASK))
46478 + {
46479 + if (p_FmPort->im.f_TxConf)
46480 + {
46481 + if ((confType == e_TX_CONF_TYPE_FLUSH) && (bdStatus & BD_R_E))
46482 + p_FmPort->im.f_TxConf(p_FmPort->h_App,
46483 + BdBufferGet(XX_PhysToVirt, BD_GET(confBdId)),
46484 + TX_CONF_STATUS_UNSENT,
46485 + p_FmPort->im.p_BdShadow[confBdId]);
46486 + else
46487 + p_FmPort->im.f_TxConf(p_FmPort->h_App,
46488 + BdBufferGet(XX_PhysToVirt, BD_GET(confBdId)),
46489 + 0,
46490 + p_FmPort->im.p_BdShadow[confBdId]);
46491 + }
46492 + }
46493 + /* case 2: R bit is 0 and Length is 0 -> not used yet, nop! */
46494 +
46495 + confBdId = GetNextBdId(p_FmPort, confBdId);
46496 + if (confBdId == savedStartBdId)
46497 + retVal = E_OK;
46498 + bdStatus = BD_STATUS_AND_LENGTH(BD_GET(confBdId));
46499 + }
46500 +
46501 + return retVal;
46502 +}
46503 +
46504 +t_Error FmPortImEnable(t_FmPort *p_FmPort)
46505 +{
46506 + uint32_t tmpReg = GET_UINT32(p_FmPort->im.p_FmPortImPram->mode);
46507 + WRITE_UINT32(p_FmPort->im.p_FmPortImPram->mode, (uint32_t)(tmpReg & ~IM_MODE_GRC_STP));
46508 + return E_OK;
46509 +}
46510 +
46511 +t_Error FmPortImDisable(t_FmPort *p_FmPort)
46512 +{
46513 + uint32_t tmpReg = GET_UINT32(p_FmPort->im.p_FmPortImPram->mode);
46514 + WRITE_UINT32(p_FmPort->im.p_FmPortImPram->mode, (uint32_t)(tmpReg | IM_MODE_GRC_STP));
46515 + return E_OK;
46516 +}
46517 +
46518 +t_Error FmPortImRx(t_FmPort *p_FmPort)
46519 +{
46520 + t_Handle h_CurrUserPriv, h_NewUserPriv;
46521 + uint32_t bdStatus;
46522 + volatile uint8_t buffPos;
46523 + uint16_t length;
46524 + uint16_t errors;
46525 + uint8_t *p_CurData, *p_Data;
46526 + uint32_t flags;
46527 +
46528 + ASSERT_COND(p_FmPort);
46529 +
46530 + flags = XX_LockIntrSpinlock(p_FmPort->h_Spinlock);
46531 + if (p_FmPort->lock)
46532 + {
46533 + XX_UnlockIntrSpinlock(p_FmPort->h_Spinlock, flags);
46534 + return E_OK;
46535 + }
46536 + p_FmPort->lock = TRUE;
46537 + XX_UnlockIntrSpinlock(p_FmPort->h_Spinlock, flags);
46538 +
46539 + bdStatus = BD_STATUS_AND_LENGTH(BD_GET(p_FmPort->im.currBdId));
46540 +
46541 + while (!(bdStatus & BD_R_E)) /* while there is data in the Rx BD */
46542 + {
46543 + if ((p_Data = p_FmPort->im.rxPool.f_GetBuf(p_FmPort->im.rxPool.h_BufferPool, &h_NewUserPriv)) == NULL)
46544 + {
46545 + p_FmPort->lock = FALSE;
46546 + RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("Data buffer"));
46547 + }
46548 +
46549 + if (p_FmPort->im.firstBdOfFrameId == IM_ILEGAL_BD_ID)
46550 + p_FmPort->im.firstBdOfFrameId = p_FmPort->im.currBdId;
46551 +
46552 + p_CurData = BdBufferGet(p_FmPort->im.rxPool.f_PhysToVirt, BD_GET(p_FmPort->im.currBdId));
46553 + h_CurrUserPriv = p_FmPort->im.p_BdShadow[p_FmPort->im.currBdId];
46554 + length = (uint16_t)((bdStatus & BD_L) ?
46555 + ((bdStatus & BD_LENGTH_MASK) - p_FmPort->im.rxFrameAccumLength):
46556 + (bdStatus & BD_LENGTH_MASK));
46557 + p_FmPort->im.rxFrameAccumLength += length;
46558 +
46559 + /* determine whether buffer is first, last, first and last (single */
46560 + /* buffer frame) or middle (not first and not last) */
46561 + buffPos = (uint8_t)((p_FmPort->im.currBdId == p_FmPort->im.firstBdOfFrameId) ?
46562 + ((bdStatus & BD_L) ? SINGLE_BUF : FIRST_BUF) :
46563 + ((bdStatus & BD_L) ? LAST_BUF : MIDDLE_BUF));
46564 +
46565 + if (bdStatus & BD_L)
46566 + {
46567 + p_FmPort->im.rxFrameAccumLength = 0;
46568 + p_FmPort->im.firstBdOfFrameId = IM_ILEGAL_BD_ID;
46569 + }
46570 +
46571 + BdBufferSet(p_FmPort->im.rxPool.f_VirtToPhys, BD_GET(p_FmPort->im.currBdId), p_Data);
46572 +
46573 + BD_STATUS_AND_LENGTH_SET(BD_GET(p_FmPort->im.currBdId), BD_R_E);
46574 +
46575 + errors = (uint16_t)((bdStatus & BD_RX_ERRORS) >> 16);
46576 + p_FmPort->im.p_BdShadow[p_FmPort->im.currBdId] = h_NewUserPriv;
46577 +
46578 + p_FmPort->im.currBdId = GetNextBdId(p_FmPort, p_FmPort->im.currBdId);
46579 + WRITE_UINT16(p_FmPort->im.p_FmPortImPram->rxQd.offsetOut, (uint16_t)(p_FmPort->im.currBdId<<4));
46580 + /* Pass the buffer if one of the conditions is true:
46581 + - There are no errors
46582 + - This is a part of a larger frame ( the application has already received some buffers ) */
46583 + if ((buffPos != SINGLE_BUF) || !errors)
46584 + {
46585 + if (p_FmPort->im.f_RxStore(p_FmPort->h_App,
46586 + p_CurData,
46587 + length,
46588 + errors,
46589 + buffPos,
46590 + h_CurrUserPriv) == e_RX_STORE_RESPONSE_PAUSE)
46591 + break;
46592 + }
46593 + else if (p_FmPort->im.rxPool.f_PutBuf(p_FmPort->im.rxPool.h_BufferPool,
46594 + p_CurData,
46595 + h_CurrUserPriv))
46596 + {
46597 + p_FmPort->lock = FALSE;
46598 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Failed freeing data buffer"));
46599 + }
46600 +
46601 + bdStatus = BD_STATUS_AND_LENGTH(BD_GET(p_FmPort->im.currBdId));
46602 + }
46603 + p_FmPort->lock = FALSE;
46604 + return E_OK;
46605 +}
46606 +
46607 +void FmPortConfigIM (t_FmPort *p_FmPort, t_FmPortParams *p_FmPortParams)
46608 +{
46609 + ASSERT_COND(p_FmPort);
46610 +
46611 + SANITY_CHECK_RETURN(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
46612 +
46613 + p_FmPort->im.h_FmMuram = p_FmPortParams->specificParams.imRxTxParams.h_FmMuram;
46614 + p_FmPort->p_FmPortDriverParam->liodnOffset = p_FmPortParams->specificParams.imRxTxParams.liodnOffset;
46615 + p_FmPort->im.dataMemId = p_FmPortParams->specificParams.imRxTxParams.dataMemId;
46616 + p_FmPort->im.dataMemAttributes = p_FmPortParams->specificParams.imRxTxParams.dataMemAttributes;
46617 +
46618 + p_FmPort->im.fwExtStructsMemId = DEFAULT_PORT_ImfwExtStructsMemId;
46619 + p_FmPort->im.fwExtStructsMemAttr = DEFAULT_PORT_ImfwExtStructsMemAttr;
46620 +
46621 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX) ||
46622 + (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
46623 + {
46624 + p_FmPort->im.rxPool.h_BufferPool = p_FmPortParams->specificParams.imRxTxParams.rxPoolParams.h_BufferPool;
46625 + p_FmPort->im.rxPool.f_GetBuf = p_FmPortParams->specificParams.imRxTxParams.rxPoolParams.f_GetBuf;
46626 + p_FmPort->im.rxPool.f_PutBuf = p_FmPortParams->specificParams.imRxTxParams.rxPoolParams.f_PutBuf;
46627 + p_FmPort->im.rxPool.bufferSize = p_FmPortParams->specificParams.imRxTxParams.rxPoolParams.bufferSize;
46628 + p_FmPort->im.rxPool.f_PhysToVirt = p_FmPortParams->specificParams.imRxTxParams.rxPoolParams.f_PhysToVirt;
46629 + if (!p_FmPort->im.rxPool.f_PhysToVirt)
46630 + p_FmPort->im.rxPool.f_PhysToVirt = XX_PhysToVirt;
46631 + p_FmPort->im.rxPool.f_VirtToPhys = p_FmPortParams->specificParams.imRxTxParams.rxPoolParams.f_VirtToPhys;
46632 + if (!p_FmPort->im.rxPool.f_VirtToPhys)
46633 + p_FmPort->im.rxPool.f_VirtToPhys = XX_VirtToPhys;
46634 + p_FmPort->im.f_RxStore = p_FmPortParams->specificParams.imRxTxParams.f_RxStore;
46635 +
46636 + p_FmPort->im.mrblr = 0x8000;
46637 + while (p_FmPort->im.mrblr)
46638 + {
46639 + if (p_FmPort->im.rxPool.bufferSize & p_FmPort->im.mrblr)
46640 + break;
46641 + p_FmPort->im.mrblr >>= 1;
46642 + }
46643 + if (p_FmPort->im.mrblr != p_FmPort->im.rxPool.bufferSize)
46644 + DBG(WARNING, ("Max-Rx-Buffer-Length set to %d", p_FmPort->im.mrblr));
46645 + p_FmPort->im.bdRingSize = DEFAULT_PORT_rxBdRingLength;
46646 + p_FmPort->exceptions = DEFAULT_PORT_exception;
46647 + if (FmIsMaster(p_FmPort->h_Fm))
46648 + p_FmPort->polling = FALSE;
46649 + else
46650 + p_FmPort->polling = TRUE;
46651 + p_FmPort->fmanCtrlEventId = (uint8_t)NO_IRQ;
46652 + }
46653 + else
46654 + {
46655 + p_FmPort->im.f_TxConf = p_FmPortParams->specificParams.imRxTxParams.f_TxConf;
46656 +
46657 + p_FmPort->im.bdRingSize = DEFAULT_PORT_txBdRingLength;
46658 + }
46659 +}
46660 +
46661 +t_Error FmPortImCheckInitParameters(t_FmPort *p_FmPort)
46662 +{
46663 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX) &&
46664 + (p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
46665 + (p_FmPort->portType != e_FM_PORT_TYPE_TX) &&
46666 + (p_FmPort->portType != e_FM_PORT_TYPE_TX_10G))
46667 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
46668 +
46669 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX) ||
46670 + (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
46671 + {
46672 + if (!POWER_OF_2(p_FmPort->im.mrblr))
46673 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("max Rx buffer length must be power of 2!!!"));
46674 + if (p_FmPort->im.mrblr < 256)
46675 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("max Rx buffer length must at least 256!!!"));
46676 + if (p_FmPort->p_FmPortDriverParam->liodnOffset & ~FM_LIODN_OFFSET_MASK)
46677 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("liodnOffset is larger than %d", FM_LIODN_OFFSET_MASK+1));
46678 + }
46679 +
46680 + return E_OK;
46681 +}
46682 +
46683 +t_Error FmPortImInit(t_FmPort *p_FmPort)
46684 +{
46685 + t_FmImBd *p_Bd=NULL;
46686 + t_Handle h_BufContext;
46687 + uint64_t tmpPhysBase;
46688 + uint16_t log2Num;
46689 + uint8_t *p_Data/*, *p_Tmp*/;
46690 + int i;
46691 + t_Error err;
46692 + uint16_t tmpReg16;
46693 + uint32_t tmpReg32;
46694 +
46695 + ASSERT_COND(p_FmPort);
46696 +
46697 + p_FmPort->im.p_FmPortImPram =
46698 + (t_FmPortImPram *)FM_MURAM_AllocMem(p_FmPort->im.h_FmMuram, sizeof(t_FmPortImPram), IM_PRAM_ALIGN);
46699 + if (!p_FmPort->im.p_FmPortImPram)
46700 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Independent-Mode Parameter-RAM!!!"));
46701 + WRITE_BLOCK(p_FmPort->im.p_FmPortImPram, 0, sizeof(t_FmPortImPram));
46702 +
46703 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX) ||
46704 + (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
46705 + {
46706 + p_FmPort->im.p_BdRing =
46707 + (t_FmImBd *)XX_MallocSmart((uint32_t)(sizeof(t_FmImBd)*p_FmPort->im.bdRingSize),
46708 + p_FmPort->im.fwExtStructsMemId,
46709 + 4);
46710 + if (!p_FmPort->im.p_BdRing)
46711 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Independent-Mode Rx BD ring!!!"));
46712 + IOMemSet32(p_FmPort->im.p_BdRing, 0, (uint32_t)(sizeof(t_FmImBd)*p_FmPort->im.bdRingSize));
46713 +
46714 + p_FmPort->im.p_BdShadow = (t_Handle *)XX_Malloc((uint32_t)(sizeof(t_Handle)*p_FmPort->im.bdRingSize));
46715 + if (!p_FmPort->im.p_BdShadow)
46716 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Independent-Mode Rx BD shadow!!!"));
46717 + memset(p_FmPort->im.p_BdShadow, 0, (uint32_t)(sizeof(t_Handle)*p_FmPort->im.bdRingSize));
46718 +
46719 + /* Initialize the Rx-BD ring */
46720 + for (i=0; i<p_FmPort->im.bdRingSize; i++)
46721 + {
46722 + p_Bd = BD_GET(i);
46723 + BD_STATUS_AND_LENGTH_SET (p_Bd, BD_R_E);
46724 +
46725 + if ((p_Data = p_FmPort->im.rxPool.f_GetBuf(p_FmPort->im.rxPool.h_BufferPool, &h_BufContext)) == NULL)
46726 + RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("Data buffer"));
46727 + BdBufferSet(p_FmPort->im.rxPool.f_VirtToPhys, p_Bd, p_Data);
46728 + p_FmPort->im.p_BdShadow[i] = h_BufContext;
46729 + }
46730 +
46731 + if ((p_FmPort->im.dataMemAttributes & MEMORY_ATTR_CACHEABLE) ||
46732 + (p_FmPort->im.fwExtStructsMemAttr & MEMORY_ATTR_CACHEABLE))
46733 + WRITE_UINT32(p_FmPort->im.p_FmPortImPram->mode, IM_MODE_GBL | IM_MODE_SET_BO(2));
46734 + else
46735 + WRITE_UINT32(p_FmPort->im.p_FmPortImPram->mode, IM_MODE_SET_BO(2));
46736 +
46737 + WRITE_UINT32(p_FmPort->im.p_FmPortImPram->rxQdPtr,
46738 + (uint32_t)((uint64_t)(XX_VirtToPhys(p_FmPort->im.p_FmPortImPram)) -
46739 + p_FmPort->fmMuramPhysBaseAddr + 0x20));
46740 +
46741 + LOG2((uint64_t)p_FmPort->im.mrblr, log2Num);
46742 + WRITE_UINT16(p_FmPort->im.p_FmPortImPram->mrblr, log2Num);
46743 +
46744 + /* Initialize Rx QD */
46745 + tmpPhysBase = (uint64_t)(XX_VirtToPhys(p_FmPort->im.p_BdRing));
46746 + SET_ADDR(&p_FmPort->im.p_FmPortImPram->rxQd.bdRingBase, tmpPhysBase);
46747 + WRITE_UINT16(p_FmPort->im.p_FmPortImPram->rxQd.bdRingSize, (uint16_t)(sizeof(t_FmImBd)*p_FmPort->im.bdRingSize));
46748 +
46749 + /* Update the IM PRAM address in the BMI */
46750 + WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfqid,
46751 + (uint32_t)((uint64_t)(XX_VirtToPhys(p_FmPort->im.p_FmPortImPram)) -
46752 + p_FmPort->fmMuramPhysBaseAddr));
46753 + if (!p_FmPort->polling || p_FmPort->exceptions)
46754 + {
46755 + /* Allocate, configure and register interrupts */
46756 + err = FmAllocFmanCtrlEventReg(p_FmPort->h_Fm, &p_FmPort->fmanCtrlEventId);
46757 + if (err)
46758 + RETURN_ERROR(MAJOR, err, NO_MSG);
46759 +
46760 + ASSERT_COND(!(p_FmPort->fmanCtrlEventId & ~IM_RXQD_FPMEVT_SEL_MASK));
46761 + tmpReg16 = (uint16_t)(p_FmPort->fmanCtrlEventId & IM_RXQD_FPMEVT_SEL_MASK);
46762 + tmpReg32 = 0;
46763 +
46764 + if (p_FmPort->exceptions & IM_EV_BSY)
46765 + {
46766 + tmpReg16 |= IM_RXQD_BSYINTM;
46767 + tmpReg32 |= IM_EV_BSY;
46768 + }
46769 + if (!p_FmPort->polling)
46770 + {
46771 + tmpReg16 |= IM_RXQD_RXFINTM;
46772 + tmpReg32 |= IM_EV_RX;
46773 + }
46774 + WRITE_UINT16(p_FmPort->im.p_FmPortImPram->rxQd.gen, tmpReg16);
46775 +
46776 + FmRegisterFmanCtrlIntr(p_FmPort->h_Fm, p_FmPort->fmanCtrlEventId, ImException , (t_Handle)p_FmPort);
46777 +
46778 + FmSetFmanCtrlIntr(p_FmPort->h_Fm, p_FmPort->fmanCtrlEventId, tmpReg32);
46779 + }
46780 + else
46781 + p_FmPort->fmanCtrlEventId = (uint8_t)NO_IRQ;
46782 + }
46783 + else
46784 + {
46785 + p_FmPort->im.p_BdRing = (t_FmImBd *)XX_MallocSmart((uint32_t)(sizeof(t_FmImBd)*p_FmPort->im.bdRingSize), p_FmPort->im.fwExtStructsMemId, 4);
46786 + if (!p_FmPort->im.p_BdRing)
46787 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Independent-Mode Tx BD ring!!!"));
46788 + IOMemSet32(p_FmPort->im.p_BdRing, 0, (uint32_t)(sizeof(t_FmImBd)*p_FmPort->im.bdRingSize));
46789 +
46790 + p_FmPort->im.p_BdShadow = (t_Handle *)XX_Malloc((uint32_t)(sizeof(t_Handle)*p_FmPort->im.bdRingSize));
46791 + if (!p_FmPort->im.p_BdShadow)
46792 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Independent-Mode Rx BD shadow!!!"));
46793 + memset(p_FmPort->im.p_BdShadow, 0, (uint32_t)(sizeof(t_Handle)*p_FmPort->im.bdRingSize));
46794 + p_FmPort->im.firstBdOfFrameId = IM_ILEGAL_BD_ID;
46795 +
46796 + if ((p_FmPort->im.dataMemAttributes & MEMORY_ATTR_CACHEABLE) ||
46797 + (p_FmPort->im.fwExtStructsMemAttr & MEMORY_ATTR_CACHEABLE))
46798 + WRITE_UINT32(p_FmPort->im.p_FmPortImPram->mode, IM_MODE_GBL | IM_MODE_SET_BO(2));
46799 + else
46800 + WRITE_UINT32(p_FmPort->im.p_FmPortImPram->mode, IM_MODE_SET_BO(2));
46801 +
46802 + WRITE_UINT32(p_FmPort->im.p_FmPortImPram->txQdPtr,
46803 + (uint32_t)((uint64_t)(XX_VirtToPhys(p_FmPort->im.p_FmPortImPram)) -
46804 + p_FmPort->fmMuramPhysBaseAddr + 0x40));
46805 +
46806 + /* Initialize Tx QD */
46807 + tmpPhysBase = (uint64_t)(XX_VirtToPhys(p_FmPort->im.p_BdRing));
46808 + SET_ADDR(&p_FmPort->im.p_FmPortImPram->txQd.bdRingBase, tmpPhysBase);
46809 + WRITE_UINT16(p_FmPort->im.p_FmPortImPram->txQd.bdRingSize, (uint16_t)(sizeof(t_FmImBd)*p_FmPort->im.bdRingSize));
46810 +
46811 + /* Update the IM PRAM address in the BMI */
46812 + WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfqid,
46813 + (uint32_t)((uint64_t)(XX_VirtToPhys(p_FmPort->im.p_FmPortImPram)) -
46814 + p_FmPort->fmMuramPhysBaseAddr));
46815 + }
46816 +
46817 +
46818 + return E_OK;
46819 +}
46820 +
46821 +void FmPortImFree(t_FmPort *p_FmPort)
46822 +{
46823 + uint32_t bdStatus;
46824 + uint8_t *p_CurData;
46825 +
46826 + ASSERT_COND(p_FmPort);
46827 + ASSERT_COND(p_FmPort->im.p_FmPortImPram);
46828 +
46829 + if ((p_FmPort->portType == e_FM_PORT_TYPE_RX) ||
46830 + (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
46831 + {
46832 + if (!p_FmPort->polling || p_FmPort->exceptions)
46833 + {
46834 + /* Deallocate and unregister interrupts */
46835 + FmSetFmanCtrlIntr(p_FmPort->h_Fm, p_FmPort->fmanCtrlEventId, 0);
46836 +
46837 + FmFreeFmanCtrlEventReg(p_FmPort->h_Fm, p_FmPort->fmanCtrlEventId);
46838 +
46839 + WRITE_UINT16(p_FmPort->im.p_FmPortImPram->rxQd.gen, 0);
46840 +
46841 + FmUnregisterFmanCtrlIntr(p_FmPort->h_Fm, p_FmPort->fmanCtrlEventId);
46842 + }
46843 + /* Try first clean what has received */
46844 + FmPortImRx(p_FmPort);
46845 +
46846 + /* Now, get rid of the the empty buffer! */
46847 + bdStatus = BD_STATUS_AND_LENGTH(BD_GET(p_FmPort->im.currBdId));
46848 +
46849 + while (bdStatus & BD_R_E) /* while there is data in the Rx BD */
46850 + {
46851 + p_CurData = BdBufferGet(p_FmPort->im.rxPool.f_PhysToVirt, BD_GET(p_FmPort->im.currBdId));
46852 +
46853 + BdBufferSet(p_FmPort->im.rxPool.f_VirtToPhys, BD_GET(p_FmPort->im.currBdId), NULL);
46854 + BD_STATUS_AND_LENGTH_SET(BD_GET(p_FmPort->im.currBdId), 0);
46855 +
46856 + p_FmPort->im.rxPool.f_PutBuf(p_FmPort->im.rxPool.h_BufferPool,
46857 + p_CurData,
46858 + p_FmPort->im.p_BdShadow[p_FmPort->im.currBdId]);
46859 +
46860 + p_FmPort->im.currBdId = GetNextBdId(p_FmPort, p_FmPort->im.currBdId);
46861 + bdStatus = BD_STATUS_AND_LENGTH(BD_GET(p_FmPort->im.currBdId));
46862 + }
46863 + }
46864 + else
46865 + TxConf(p_FmPort, e_TX_CONF_TYPE_FLUSH);
46866 +
46867 + FM_MURAM_FreeMem(p_FmPort->im.h_FmMuram, p_FmPort->im.p_FmPortImPram);
46868 +
46869 + if (p_FmPort->im.p_BdShadow)
46870 + XX_Free(p_FmPort->im.p_BdShadow);
46871 +
46872 + if (p_FmPort->im.p_BdRing)
46873 + XX_FreeSmart(p_FmPort->im.p_BdRing);
46874 +}
46875 +
46876 +
46877 +t_Error FM_PORT_ConfigIMMaxRxBufLength(t_Handle h_FmPort, uint16_t newVal)
46878 +{
46879 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
46880 +
46881 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
46882 + SANITY_CHECK_RETURN_ERROR(p_FmPort->imEn, E_INVALID_STATE);
46883 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
46884 +
46885 + p_FmPort->im.mrblr = newVal;
46886 +
46887 + return E_OK;
46888 +}
46889 +
46890 +t_Error FM_PORT_ConfigIMRxBdRingLength(t_Handle h_FmPort, uint16_t newVal)
46891 +{
46892 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
46893 +
46894 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
46895 + SANITY_CHECK_RETURN_ERROR(p_FmPort->imEn, E_INVALID_STATE);
46896 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
46897 +
46898 + p_FmPort->im.bdRingSize = newVal;
46899 +
46900 + return E_OK;
46901 +}
46902 +
46903 +t_Error FM_PORT_ConfigIMTxBdRingLength(t_Handle h_FmPort, uint16_t newVal)
46904 +{
46905 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
46906 +
46907 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
46908 + SANITY_CHECK_RETURN_ERROR(p_FmPort->imEn, E_INVALID_STATE);
46909 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
46910 +
46911 + p_FmPort->im.bdRingSize = newVal;
46912 +
46913 + return E_OK;
46914 +}
46915 +
46916 +t_Error FM_PORT_ConfigIMFmanCtrlExternalStructsMemory(t_Handle h_FmPort,
46917 + uint8_t memId,
46918 + uint32_t memAttributes)
46919 +{
46920 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
46921 +
46922 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
46923 + SANITY_CHECK_RETURN_ERROR(p_FmPort->imEn, E_INVALID_STATE);
46924 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
46925 +
46926 + p_FmPort->im.fwExtStructsMemId = memId;
46927 + p_FmPort->im.fwExtStructsMemAttr = memAttributes;
46928 +
46929 + return E_OK;
46930 +}
46931 +
46932 +t_Error FM_PORT_ConfigIMPolling(t_Handle h_FmPort)
46933 +{
46934 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
46935 +
46936 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
46937 + SANITY_CHECK_RETURN_ERROR(p_FmPort->imEn, E_INVALID_STATE);
46938 + SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
46939 +
46940 + if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
46941 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("Available for Rx ports only"));
46942 +
46943 + if (!FmIsMaster(p_FmPort->h_Fm))
46944 + RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("Available on master-partition only;"
46945 + "in guest-partitions, IM is always in polling!"));
46946 +
46947 + p_FmPort->polling = TRUE;
46948 +
46949 + return E_OK;
46950 +}
46951 +
46952 +t_Error FM_PORT_SetIMExceptions(t_Handle h_FmPort, e_FmPortExceptions exception, bool enable)
46953 +{
46954 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
46955 + t_Error err;
46956 + uint16_t tmpReg16;
46957 + uint32_t tmpReg32;
46958 +
46959 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
46960 + SANITY_CHECK_RETURN_ERROR(p_FmPort->imEn, E_INVALID_STATE);
46961 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
46962 +
46963 + if (exception == e_FM_PORT_EXCEPTION_IM_BUSY)
46964 + {
46965 + if (enable)
46966 + {
46967 + p_FmPort->exceptions |= IM_EV_BSY;
46968 + if (p_FmPort->fmanCtrlEventId == (uint8_t)NO_IRQ)
46969 + {
46970 + /* Allocate, configure and register interrupts */
46971 + err = FmAllocFmanCtrlEventReg(p_FmPort->h_Fm, &p_FmPort->fmanCtrlEventId);
46972 + if (err)
46973 + RETURN_ERROR(MAJOR, err, NO_MSG);
46974 + ASSERT_COND(!(p_FmPort->fmanCtrlEventId & ~IM_RXQD_FPMEVT_SEL_MASK));
46975 +
46976 + FmRegisterFmanCtrlIntr(p_FmPort->h_Fm, p_FmPort->fmanCtrlEventId, ImException, (t_Handle)p_FmPort);
46977 + tmpReg16 = (uint16_t)((p_FmPort->fmanCtrlEventId & IM_RXQD_FPMEVT_SEL_MASK) | IM_RXQD_BSYINTM);
46978 + tmpReg32 = IM_EV_BSY;
46979 + }
46980 + else
46981 + {
46982 + tmpReg16 = (uint16_t)(GET_UINT16(p_FmPort->im.p_FmPortImPram->rxQd.gen) | IM_RXQD_BSYINTM);
46983 + tmpReg32 = FmGetFmanCtrlIntr(p_FmPort->h_Fm, p_FmPort->fmanCtrlEventId) | IM_EV_BSY;
46984 + }
46985 +
46986 + WRITE_UINT16(p_FmPort->im.p_FmPortImPram->rxQd.gen, tmpReg16);
46987 + FmSetFmanCtrlIntr(p_FmPort->h_Fm, p_FmPort->fmanCtrlEventId, tmpReg32);
46988 + }
46989 + else
46990 + {
46991 + p_FmPort->exceptions &= ~IM_EV_BSY;
46992 + if (!p_FmPort->exceptions && p_FmPort->polling)
46993 + {
46994 + FmFreeFmanCtrlEventReg(p_FmPort->h_Fm, p_FmPort->fmanCtrlEventId);
46995 + FmUnregisterFmanCtrlIntr(p_FmPort->h_Fm, p_FmPort->fmanCtrlEventId);
46996 + FmSetFmanCtrlIntr(p_FmPort->h_Fm, p_FmPort->fmanCtrlEventId, 0);
46997 + WRITE_UINT16(p_FmPort->im.p_FmPortImPram->rxQd.gen, 0);
46998 + p_FmPort->fmanCtrlEventId = (uint8_t)NO_IRQ;
46999 + }
47000 + else
47001 + {
47002 + tmpReg16 = (uint16_t)(GET_UINT16(p_FmPort->im.p_FmPortImPram->rxQd.gen) & ~IM_RXQD_BSYINTM);
47003 + WRITE_UINT16(p_FmPort->im.p_FmPortImPram->rxQd.gen, tmpReg16);
47004 + tmpReg32 = FmGetFmanCtrlIntr(p_FmPort->h_Fm, p_FmPort->fmanCtrlEventId) & ~IM_EV_BSY;
47005 + FmSetFmanCtrlIntr(p_FmPort->h_Fm, p_FmPort->fmanCtrlEventId, tmpReg32);
47006 + }
47007 + }
47008 + }
47009 + else
47010 + RETURN_ERROR(MINOR, E_INVALID_SELECTION, ("Invalid exception."));
47011 +
47012 + return E_OK;
47013 +}
47014 +
47015 +t_Error FM_PORT_ImTx( t_Handle h_FmPort,
47016 + uint8_t *p_Data,
47017 + uint16_t length,
47018 + bool lastBuffer,
47019 + t_Handle h_BufContext)
47020 +{
47021 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
47022 + uint16_t nextBdId;
47023 + uint32_t bdStatus, nextBdStatus;
47024 + bool firstBuffer;
47025 +
47026 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
47027 + SANITY_CHECK_RETURN_ERROR(p_FmPort->imEn, E_INVALID_STATE);
47028 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
47029 +
47030 + bdStatus = BD_STATUS_AND_LENGTH(BD_GET(p_FmPort->im.currBdId));
47031 + nextBdId = GetNextBdId(p_FmPort, p_FmPort->im.currBdId);
47032 + nextBdStatus = BD_STATUS_AND_LENGTH(BD_GET(nextBdId));
47033 +
47034 + if (!(bdStatus & BD_R_E) && !(nextBdStatus & BD_R_E))
47035 + {
47036 + /* Confirm the current BD - BD is available */
47037 + if ((bdStatus & BD_LENGTH_MASK) && (p_FmPort->im.f_TxConf))
47038 + p_FmPort->im.f_TxConf (p_FmPort->h_App,
47039 + BdBufferGet(XX_PhysToVirt, BD_GET(p_FmPort->im.currBdId)),
47040 + 0,
47041 + p_FmPort->im.p_BdShadow[p_FmPort->im.currBdId]);
47042 +
47043 + bdStatus = length;
47044 +
47045 + /* if this is the first BD of a frame */
47046 + if (p_FmPort->im.firstBdOfFrameId == IM_ILEGAL_BD_ID)
47047 + {
47048 + firstBuffer = TRUE;
47049 + p_FmPort->im.txFirstBdStatus = (bdStatus | BD_R_E);
47050 +
47051 + if (!lastBuffer)
47052 + p_FmPort->im.firstBdOfFrameId = p_FmPort->im.currBdId;
47053 + }
47054 + else
47055 + firstBuffer = FALSE;
47056 +
47057 + BdBufferSet(XX_VirtToPhys, BD_GET(p_FmPort->im.currBdId), p_Data);
47058 + p_FmPort->im.p_BdShadow[p_FmPort->im.currBdId] = h_BufContext;
47059 +
47060 + /* deal with last */
47061 + if (lastBuffer)
47062 + {
47063 + /* if single buffer frame */
47064 + if (firstBuffer)
47065 + BD_STATUS_AND_LENGTH_SET(BD_GET(p_FmPort->im.currBdId), p_FmPort->im.txFirstBdStatus | BD_L);
47066 + else
47067 + {
47068 + /* Set the last BD of the frame */
47069 + BD_STATUS_AND_LENGTH_SET (BD_GET(p_FmPort->im.currBdId), (bdStatus | BD_R_E | BD_L));
47070 + /* Set the first BD of the frame */
47071 + BD_STATUS_AND_LENGTH_SET(BD_GET(p_FmPort->im.firstBdOfFrameId), p_FmPort->im.txFirstBdStatus);
47072 + p_FmPort->im.firstBdOfFrameId = IM_ILEGAL_BD_ID;
47073 + }
47074 + WRITE_UINT16(p_FmPort->im.p_FmPortImPram->txQd.offsetIn, (uint16_t)(GetNextBdId(p_FmPort, p_FmPort->im.currBdId)<<4));
47075 + }
47076 + else if (!firstBuffer) /* mid frame buffer */
47077 + BD_STATUS_AND_LENGTH_SET (BD_GET(p_FmPort->im.currBdId), bdStatus | BD_R_E);
47078 +
47079 + p_FmPort->im.currBdId = GetNextBdId(p_FmPort, p_FmPort->im.currBdId);
47080 + }
47081 + else
47082 + {
47083 + /* Discard current frame. Return error. */
47084 + if (p_FmPort->im.firstBdOfFrameId != IM_ILEGAL_BD_ID)
47085 + {
47086 + /* Error: No free BD */
47087 + /* Response: Discard current frame. Return error. */
47088 + uint16_t cleanBdId = p_FmPort->im.firstBdOfFrameId;
47089 +
47090 + ASSERT_COND(p_FmPort->im.firstBdOfFrameId != p_FmPort->im.currBdId);
47091 +
47092 + /* Since firstInFrame is not NULL, one buffer at least has already been
47093 + inserted into the BD ring. Using do-while covers the situation of a
47094 + frame spanned throughout the whole Tx BD ring (p_CleanBd is incremented
47095 + prior to testing whether or not it's equal to TxBd). */
47096 + do
47097 + {
47098 + BD_STATUS_AND_LENGTH_SET(BD_GET(cleanBdId), 0);
47099 + /* Advance BD pointer */
47100 + cleanBdId = GetNextBdId(p_FmPort, cleanBdId);
47101 + } while (cleanBdId != p_FmPort->im.currBdId);
47102 +
47103 + p_FmPort->im.currBdId = cleanBdId;
47104 + p_FmPort->im.firstBdOfFrameId = IM_ILEGAL_BD_ID;
47105 + }
47106 +
47107 + return ERROR_CODE(E_FULL);
47108 + }
47109 +
47110 + return E_OK;
47111 +}
47112 +
47113 +void FM_PORT_ImTxConf(t_Handle h_FmPort)
47114 +{
47115 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
47116 +
47117 + SANITY_CHECK_RETURN(p_FmPort, E_INVALID_HANDLE);
47118 + SANITY_CHECK_RETURN(p_FmPort->imEn, E_INVALID_STATE);
47119 + SANITY_CHECK_RETURN(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
47120 +
47121 + TxConf(p_FmPort, e_TX_CONF_TYPE_CALLBACK);
47122 +}
47123 +
47124 +t_Error FM_PORT_ImRx(t_Handle h_FmPort)
47125 +{
47126 + t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
47127 +
47128 + SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
47129 + SANITY_CHECK_RETURN_ERROR(p_FmPort->imEn, E_INVALID_STATE);
47130 + SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
47131 +
47132 + return FmPortImRx(p_FmPort);
47133 +}
47134 --- /dev/null
47135 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fman_port.c
47136 @@ -0,0 +1,1568 @@
47137 +/*
47138 + * Copyright 2008-2012 Freescale Semiconductor Inc.
47139 + *
47140 + * Redistribution and use in source and binary forms, with or without
47141 + * modification, are permitted provided that the following conditions are met:
47142 + * * Redistributions of source code must retain the above copyright
47143 + * notice, this list of conditions and the following disclaimer.
47144 + * * Redistributions in binary form must reproduce the above copyright
47145 + * notice, this list of conditions and the following disclaimer in the
47146 + * documentation and/or other materials provided with the distribution.
47147 + * * Neither the name of Freescale Semiconductor nor the
47148 + * names of its contributors may be used to endorse or promote products
47149 + * derived from this software without specific prior written permission.
47150 + *
47151 + *
47152 + * ALTERNATIVELY, this software may be distributed under the terms of the
47153 + * GNU General Public License ("GPL") as published by the Free Software
47154 + * Foundation, either version 2 of that License or (at your option) any
47155 + * later version.
47156 + *
47157 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
47158 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47159 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
47160 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
47161 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
47162 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47163 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
47164 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
47165 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
47166 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47167 + */
47168 +
47169 +
47170 +#include "common/general.h"
47171 +
47172 +#include "fman_common.h"
47173 +#include "fsl_fman_port.h"
47174 +
47175 +
47176 +/* problem Eyal: the following should not be here*/
47177 +#define NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME 0x00000028
47178 +
47179 +static uint32_t get_no_pcd_nia_bmi_ac_enc_frame(struct fman_port_cfg *cfg)
47180 +{
47181 + if (cfg->errata_A006675)
47182 + return NIA_ENG_FM_CTL |
47183 + NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME;
47184 + else
47185 + return NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME;
47186 +}
47187 +
47188 +static int init_bmi_rx(struct fman_port *port,
47189 + struct fman_port_cfg *cfg,
47190 + struct fman_port_params *params)
47191 +{
47192 + struct fman_port_rx_bmi_regs *regs = &port->bmi_regs->rx;
47193 + uint32_t tmp;
47194 +
47195 + /* Rx Configuration register */
47196 + tmp = 0;
47197 + if (port->im_en)
47198 + tmp |= BMI_PORT_CFG_IM;
47199 + else if (cfg->discard_override)
47200 + tmp |= BMI_PORT_CFG_FDOVR;
47201 + iowrite32be(tmp, &regs->fmbm_rcfg);
47202 +
47203 + /* DMA attributes */
47204 + tmp = (uint32_t)cfg->dma_swap_data << BMI_DMA_ATTR_SWP_SHIFT;
47205 + if (cfg->dma_ic_stash_on)
47206 + tmp |= BMI_DMA_ATTR_IC_STASH_ON;
47207 + if (cfg->dma_header_stash_on)
47208 + tmp |= BMI_DMA_ATTR_HDR_STASH_ON;
47209 + if (cfg->dma_sg_stash_on)
47210 + tmp |= BMI_DMA_ATTR_SG_STASH_ON;
47211 + if (cfg->dma_write_optimize)
47212 + tmp |= BMI_DMA_ATTR_WRITE_OPTIMIZE;
47213 + iowrite32be(tmp, &regs->fmbm_rda);
47214 +
47215 + /* Rx FIFO parameters */
47216 + tmp = (cfg->rx_pri_elevation / FMAN_PORT_BMI_FIFO_UNITS - 1) <<
47217 + BMI_RX_FIFO_PRI_ELEVATION_SHIFT;
47218 + tmp |= cfg->rx_fifo_thr / FMAN_PORT_BMI_FIFO_UNITS - 1;
47219 + iowrite32be(tmp, &regs->fmbm_rfp);
47220 +
47221 + if (cfg->excessive_threshold_register)
47222 + /* always allow access to the extra resources */
47223 + iowrite32be(BMI_RX_FIFO_THRESHOLD_ETHE, &regs->fmbm_reth);
47224 +
47225 + /* Frame end data */
47226 + tmp = (uint32_t)cfg->checksum_bytes_ignore <<
47227 + BMI_RX_FRAME_END_CS_IGNORE_SHIFT;
47228 + tmp |= (uint32_t)cfg->rx_cut_end_bytes <<
47229 + BMI_RX_FRAME_END_CUT_SHIFT;
47230 + if (cfg->errata_A006320)
47231 + tmp &= 0xffe0ffff;
47232 + iowrite32be(tmp, &regs->fmbm_rfed);
47233 +
47234 + /* Internal context parameters */
47235 + tmp = ((uint32_t)cfg->ic_ext_offset / FMAN_PORT_IC_OFFSET_UNITS) <<
47236 + BMI_IC_TO_EXT_SHIFT;
47237 + tmp |= ((uint32_t)cfg->ic_int_offset / FMAN_PORT_IC_OFFSET_UNITS) <<
47238 + BMI_IC_FROM_INT_SHIFT;
47239 + tmp |= cfg->ic_size / FMAN_PORT_IC_OFFSET_UNITS;
47240 + iowrite32be(tmp, &regs->fmbm_ricp);
47241 +
47242 + /* Internal buffer offset */
47243 + tmp = ((uint32_t)cfg->int_buf_start_margin / FMAN_PORT_IC_OFFSET_UNITS)
47244 + << BMI_INT_BUF_MARG_SHIFT;
47245 + iowrite32be(tmp, &regs->fmbm_rim);
47246 +
47247 + /* External buffer margins */
47248 + if (!port->im_en)
47249 + {
47250 + tmp = (uint32_t)cfg->ext_buf_start_margin <<
47251 + BMI_EXT_BUF_MARG_START_SHIFT;
47252 + tmp |= (uint32_t)cfg->ext_buf_end_margin;
47253 + if (cfg->fmbm_rebm_has_sgd && cfg->no_scatter_gather)
47254 + tmp |= BMI_SG_DISABLE;
47255 + iowrite32be(tmp, &regs->fmbm_rebm);
47256 + }
47257 +
47258 + /* Frame attributes */
47259 + tmp = BMI_CMD_RX_MR_DEF;
47260 + if (!port->im_en)
47261 + {
47262 + tmp |= BMI_CMD_ATTR_ORDER;
47263 + tmp |= (uint32_t)cfg->color << BMI_CMD_ATTR_COLOR_SHIFT;
47264 + if (cfg->sync_req)
47265 + tmp |= BMI_CMD_ATTR_SYNC;
47266 + }
47267 + iowrite32be(tmp, &regs->fmbm_rfca);
47268 +
47269 + /* NIA */
47270 + if (port->im_en)
47271 + tmp = NIA_ENG_FM_CTL | NIA_FM_CTL_AC_IND_MODE_RX;
47272 + else
47273 + {
47274 + tmp = (uint32_t)cfg->rx_fd_bits << BMI_NEXT_ENG_FD_BITS_SHIFT;
47275 + tmp |= get_no_pcd_nia_bmi_ac_enc_frame(cfg);
47276 + }
47277 + iowrite32be(tmp, &regs->fmbm_rfne);
47278 +
47279 + /* Enqueue NIA */
47280 + iowrite32be(NIA_ENG_QMI_ENQ | NIA_ORDER_RESTOR, &regs->fmbm_rfene);
47281 +
47282 + /* Default/error queues */
47283 + if (!port->im_en)
47284 + {
47285 + iowrite32be((params->dflt_fqid & 0x00FFFFFF), &regs->fmbm_rfqid);
47286 + iowrite32be((params->err_fqid & 0x00FFFFFF), &regs->fmbm_refqid);
47287 + }
47288 +
47289 + /* Discard/error masks */
47290 + iowrite32be(params->discard_mask, &regs->fmbm_rfsdm);
47291 + iowrite32be(params->err_mask, &regs->fmbm_rfsem);
47292 +
47293 + /* Statistics counters */
47294 + tmp = 0;
47295 + if (cfg->stats_counters_enable)
47296 + tmp = BMI_COUNTERS_EN;
47297 + iowrite32be(tmp, &regs->fmbm_rstc);
47298 +
47299 + /* Performance counters */
47300 + fman_port_set_perf_cnt_params(port, &cfg->perf_cnt_params);
47301 + tmp = 0;
47302 + if (cfg->perf_counters_enable)
47303 + tmp = BMI_COUNTERS_EN;
47304 + iowrite32be(tmp, &regs->fmbm_rpc);
47305 +
47306 + return 0;
47307 +}
47308 +
47309 +static int init_bmi_tx(struct fman_port *port,
47310 + struct fman_port_cfg *cfg,
47311 + struct fman_port_params *params)
47312 +{
47313 + struct fman_port_tx_bmi_regs *regs = &port->bmi_regs->tx;
47314 + uint32_t tmp;
47315 +
47316 + /* Tx Configuration register */
47317 + tmp = 0;
47318 + if (port->im_en)
47319 + tmp |= BMI_PORT_CFG_IM;
47320 + iowrite32be(tmp, &regs->fmbm_tcfg);
47321 +
47322 + /* DMA attributes */
47323 + tmp = (uint32_t)cfg->dma_swap_data << BMI_DMA_ATTR_SWP_SHIFT;
47324 + if (cfg->dma_ic_stash_on)
47325 + tmp |= BMI_DMA_ATTR_IC_STASH_ON;
47326 + if (cfg->dma_header_stash_on)
47327 + tmp |= BMI_DMA_ATTR_HDR_STASH_ON;
47328 + if (cfg->dma_sg_stash_on)
47329 + tmp |= BMI_DMA_ATTR_SG_STASH_ON;
47330 + iowrite32be(tmp, &regs->fmbm_tda);
47331 +
47332 + /* Tx FIFO parameters */
47333 + tmp = (cfg->tx_fifo_min_level / FMAN_PORT_BMI_FIFO_UNITS) <<
47334 + BMI_TX_FIFO_MIN_FILL_SHIFT;
47335 + tmp |= ((uint32_t)cfg->tx_fifo_deq_pipeline_depth - 1) <<
47336 + BMI_FIFO_PIPELINE_DEPTH_SHIFT;
47337 + tmp |= (uint32_t)(cfg->tx_fifo_low_comf_level /
47338 + FMAN_PORT_BMI_FIFO_UNITS - 1);
47339 + iowrite32be(tmp, &regs->fmbm_tfp);
47340 +
47341 + /* Frame end data */
47342 + tmp = (uint32_t)cfg->checksum_bytes_ignore <<
47343 + BMI_FRAME_END_CS_IGNORE_SHIFT;
47344 + iowrite32be(tmp, &regs->fmbm_tfed);
47345 +
47346 + /* Internal context parameters */
47347 + if (!port->im_en)
47348 + {
47349 + tmp = ((uint32_t)cfg->ic_ext_offset / FMAN_PORT_IC_OFFSET_UNITS) <<
47350 + BMI_IC_TO_EXT_SHIFT;
47351 + tmp |= ((uint32_t)cfg->ic_int_offset / FMAN_PORT_IC_OFFSET_UNITS) <<
47352 + BMI_IC_FROM_INT_SHIFT;
47353 + tmp |= cfg->ic_size / FMAN_PORT_IC_OFFSET_UNITS;
47354 + iowrite32be(tmp, &regs->fmbm_ticp);
47355 + }
47356 + /* Frame attributes */
47357 + tmp = BMI_CMD_TX_MR_DEF;
47358 + if (port->im_en)
47359 + tmp |= BMI_CMD_MR_DEAS;
47360 + else
47361 + {
47362 + tmp |= BMI_CMD_ATTR_ORDER;
47363 + tmp |= (uint32_t)cfg->color << BMI_CMD_ATTR_COLOR_SHIFT;
47364 + }
47365 + iowrite32be(tmp, &regs->fmbm_tfca);
47366 +
47367 + /* Dequeue NIA + enqueue NIA */
47368 + if (port->im_en)
47369 + {
47370 + iowrite32be(NIA_ENG_FM_CTL | NIA_FM_CTL_AC_IND_MODE_TX, &regs->fmbm_tfdne);
47371 + iowrite32be(NIA_ENG_FM_CTL | NIA_FM_CTL_AC_IND_MODE_TX, &regs->fmbm_tfene);
47372 + }
47373 + else
47374 + {
47375 + iowrite32be(NIA_ENG_QMI_DEQ, &regs->fmbm_tfdne);
47376 + iowrite32be(NIA_ENG_QMI_ENQ | NIA_ORDER_RESTOR, &regs->fmbm_tfene);
47377 + if (cfg->fmbm_tfne_has_features)
47378 + iowrite32be(!params->dflt_fqid ?
47379 + BMI_EBD_EN | NIA_BMI_AC_FETCH_ALL_FRAME :
47380 + NIA_BMI_AC_FETCH_ALL_FRAME, &regs->fmbm_tfne);
47381 + if (!params->dflt_fqid && params->dont_release_buf)
47382 + {
47383 + iowrite32be(0x00FFFFFF, &regs->fmbm_tcfqid);
47384 + iowrite32be(NIA_ENG_BMI | NIA_BMI_AC_TX_RELEASE, &regs->fmbm_tfene);
47385 + if (cfg->fmbm_tfne_has_features)
47386 + iowrite32be(ioread32be(&regs->fmbm_tfne) & ~BMI_EBD_EN, &regs->fmbm_tfne);
47387 + }
47388 + }
47389 +
47390 + /* Confirmation/error queues */
47391 + if (!port->im_en)
47392 + {
47393 + if (params->dflt_fqid || !params->dont_release_buf)
47394 + iowrite32be(params->dflt_fqid & 0x00FFFFFF, &regs->fmbm_tcfqid);
47395 + iowrite32be((params->err_fqid & 0x00FFFFFF), &regs->fmbm_tefqid);
47396 + }
47397 + /* Statistics counters */
47398 + tmp = 0;
47399 + if (cfg->stats_counters_enable)
47400 + tmp = BMI_COUNTERS_EN;
47401 + iowrite32be(tmp, &regs->fmbm_tstc);
47402 +
47403 + /* Performance counters */
47404 + fman_port_set_perf_cnt_params(port, &cfg->perf_cnt_params);
47405 + tmp = 0;
47406 + if (cfg->perf_counters_enable)
47407 + tmp = BMI_COUNTERS_EN;
47408 + iowrite32be(tmp, &regs->fmbm_tpc);
47409 +
47410 + return 0;
47411 +}
47412 +
47413 +static int init_bmi_oh(struct fman_port *port,
47414 + struct fman_port_cfg *cfg,
47415 + struct fman_port_params *params)
47416 +{
47417 + struct fman_port_oh_bmi_regs *regs = &port->bmi_regs->oh;
47418 + uint32_t tmp;
47419 +
47420 + /* OP Configuration register */
47421 + tmp = 0;
47422 + if (cfg->discard_override)
47423 + tmp |= BMI_PORT_CFG_FDOVR;
47424 + iowrite32be(tmp, &regs->fmbm_ocfg);
47425 +
47426 + /* DMA attributes */
47427 + tmp = (uint32_t)cfg->dma_swap_data << BMI_DMA_ATTR_SWP_SHIFT;
47428 + if (cfg->dma_ic_stash_on)
47429 + tmp |= BMI_DMA_ATTR_IC_STASH_ON;
47430 + if (cfg->dma_header_stash_on)
47431 + tmp |= BMI_DMA_ATTR_HDR_STASH_ON;
47432 + if (cfg->dma_sg_stash_on)
47433 + tmp |= BMI_DMA_ATTR_SG_STASH_ON;
47434 + if (cfg->dma_write_optimize)
47435 + tmp |= BMI_DMA_ATTR_WRITE_OPTIMIZE;
47436 + iowrite32be(tmp, &regs->fmbm_oda);
47437 +
47438 + /* Tx FIFO parameters */
47439 + tmp = ((uint32_t)cfg->tx_fifo_deq_pipeline_depth - 1) <<
47440 + BMI_FIFO_PIPELINE_DEPTH_SHIFT;
47441 + iowrite32be(tmp, &regs->fmbm_ofp);
47442 +
47443 + /* Internal context parameters */
47444 + tmp = ((uint32_t)cfg->ic_ext_offset / FMAN_PORT_IC_OFFSET_UNITS) <<
47445 + BMI_IC_TO_EXT_SHIFT;
47446 + tmp |= ((uint32_t)cfg->ic_int_offset / FMAN_PORT_IC_OFFSET_UNITS) <<
47447 + BMI_IC_FROM_INT_SHIFT;
47448 + tmp |= cfg->ic_size / FMAN_PORT_IC_OFFSET_UNITS;
47449 + iowrite32be(tmp, &regs->fmbm_oicp);
47450 +
47451 + /* Frame attributes */
47452 + tmp = BMI_CMD_OP_MR_DEF;
47453 + tmp |= (uint32_t)cfg->color << BMI_CMD_ATTR_COLOR_SHIFT;
47454 + if (cfg->sync_req)
47455 + tmp |= BMI_CMD_ATTR_SYNC;
47456 + if (port->type == E_FMAN_PORT_TYPE_OP)
47457 + tmp |= BMI_CMD_ATTR_ORDER;
47458 + iowrite32be(tmp, &regs->fmbm_ofca);
47459 +
47460 + /* Internal buffer offset */
47461 + tmp = ((uint32_t)cfg->int_buf_start_margin / FMAN_PORT_IC_OFFSET_UNITS)
47462 + << BMI_INT_BUF_MARG_SHIFT;
47463 + iowrite32be(tmp, &regs->fmbm_oim);
47464 +
47465 + /* Dequeue NIA */
47466 + iowrite32be(NIA_ENG_QMI_DEQ, &regs->fmbm_ofdne);
47467 +
47468 + /* NIA and Enqueue NIA */
47469 + if (port->type == E_FMAN_PORT_TYPE_HC) {
47470 + iowrite32be(NIA_ENG_FM_CTL | NIA_FM_CTL_AC_HC,
47471 + &regs->fmbm_ofne);
47472 + iowrite32be(NIA_ENG_QMI_ENQ, &regs->fmbm_ofene);
47473 + } else {
47474 + iowrite32be(get_no_pcd_nia_bmi_ac_enc_frame(cfg),
47475 + &regs->fmbm_ofne);
47476 + iowrite32be(NIA_ENG_QMI_ENQ | NIA_ORDER_RESTOR,
47477 + &regs->fmbm_ofene);
47478 + }
47479 +
47480 + /* Default/error queues */
47481 + iowrite32be((params->dflt_fqid & 0x00FFFFFF), &regs->fmbm_ofqid);
47482 + iowrite32be((params->err_fqid & 0x00FFFFFF), &regs->fmbm_oefqid);
47483 +
47484 + /* Discard/error masks */
47485 + if (port->type == E_FMAN_PORT_TYPE_OP) {
47486 + iowrite32be(params->discard_mask, &regs->fmbm_ofsdm);
47487 + iowrite32be(params->err_mask, &regs->fmbm_ofsem);
47488 + }
47489 +
47490 + /* Statistics counters */
47491 + tmp = 0;
47492 + if (cfg->stats_counters_enable)
47493 + tmp = BMI_COUNTERS_EN;
47494 + iowrite32be(tmp, &regs->fmbm_ostc);
47495 +
47496 + /* Performance counters */
47497 + fman_port_set_perf_cnt_params(port, &cfg->perf_cnt_params);
47498 + tmp = 0;
47499 + if (cfg->perf_counters_enable)
47500 + tmp = BMI_COUNTERS_EN;
47501 + iowrite32be(tmp, &regs->fmbm_opc);
47502 +
47503 + return 0;
47504 +}
47505 +
47506 +static int init_qmi(struct fman_port *port,
47507 + struct fman_port_cfg *cfg,
47508 + struct fman_port_params *params)
47509 +{
47510 + struct fman_port_qmi_regs *regs = port->qmi_regs;
47511 + uint32_t tmp;
47512 +
47513 + tmp = 0;
47514 + if (cfg->queue_counters_enable)
47515 + tmp |= QMI_PORT_CFG_EN_COUNTERS;
47516 + iowrite32be(tmp, &regs->fmqm_pnc);
47517 +
47518 + /* Rx port configuration */
47519 + if ((port->type == E_FMAN_PORT_TYPE_RX) ||
47520 + (port->type == E_FMAN_PORT_TYPE_RX_10G)) {
47521 + /* Enqueue NIA */
47522 + iowrite32be(NIA_ENG_BMI | NIA_BMI_AC_RELEASE, &regs->fmqm_pnen);
47523 + return 0;
47524 + }
47525 +
47526 + /* Continue with Tx and O/H port configuration */
47527 + if ((port->type == E_FMAN_PORT_TYPE_TX) ||
47528 + (port->type == E_FMAN_PORT_TYPE_TX_10G)) {
47529 + /* Enqueue NIA */
47530 + iowrite32be(NIA_ENG_BMI | NIA_BMI_AC_TX_RELEASE,
47531 + &regs->fmqm_pnen);
47532 + /* Dequeue NIA */
47533 + iowrite32be(NIA_ENG_BMI | NIA_BMI_AC_TX, &regs->fmqm_pndn);
47534 + } else {
47535 + /* Enqueue NIA */
47536 + iowrite32be(NIA_ENG_BMI | NIA_BMI_AC_RELEASE, &regs->fmqm_pnen);
47537 + /* Dequeue NIA */
47538 + iowrite32be(NIA_ENG_BMI | NIA_BMI_AC_FETCH, &regs->fmqm_pndn);
47539 + }
47540 +
47541 + /* Dequeue Configuration register */
47542 + tmp = 0;
47543 + if (cfg->deq_high_pri)
47544 + tmp |= QMI_DEQ_CFG_PRI;
47545 +
47546 + switch (cfg->deq_type) {
47547 + case E_FMAN_PORT_DEQ_BY_PRI:
47548 + tmp |= QMI_DEQ_CFG_TYPE1;
47549 + break;
47550 + case E_FMAN_PORT_DEQ_ACTIVE_FQ:
47551 + tmp |= QMI_DEQ_CFG_TYPE2;
47552 + break;
47553 + case E_FMAN_PORT_DEQ_ACTIVE_FQ_NO_ICS:
47554 + tmp |= QMI_DEQ_CFG_TYPE3;
47555 + break;
47556 + default:
47557 + return -EINVAL;
47558 + }
47559 +
47560 + if (cfg->qmi_deq_options_support) {
47561 + if ((port->type == E_FMAN_PORT_TYPE_HC) &&
47562 + (cfg->deq_prefetch_opt != E_FMAN_PORT_DEQ_NO_PREFETCH))
47563 + return -EINVAL;
47564 +
47565 + switch (cfg->deq_prefetch_opt) {
47566 + case E_FMAN_PORT_DEQ_NO_PREFETCH:
47567 + break;
47568 + case E_FMAN_PORT_DEQ_PART_PREFETCH:
47569 + tmp |= QMI_DEQ_CFG_PREFETCH_PARTIAL;
47570 + break;
47571 + case E_FMAN_PORT_DEQ_FULL_PREFETCH:
47572 + tmp |= QMI_DEQ_CFG_PREFETCH_FULL;
47573 + break;
47574 + default:
47575 + return -EINVAL;
47576 + }
47577 + }
47578 + tmp |= (uint32_t)(params->deq_sp & QMI_DEQ_CFG_SP_MASK) <<
47579 + QMI_DEQ_CFG_SP_SHIFT;
47580 + tmp |= cfg->deq_byte_cnt;
47581 + iowrite32be(tmp, &regs->fmqm_pndc);
47582 +
47583 + return 0;
47584 +}
47585 +
47586 +static void get_rx_stats_reg(struct fman_port *port,
47587 + enum fman_port_stats_counters counter,
47588 + uint32_t **stats_reg)
47589 +{
47590 + struct fman_port_rx_bmi_regs *regs = &port->bmi_regs->rx;
47591 +
47592 + switch (counter) {
47593 + case E_FMAN_PORT_STATS_CNT_FRAME:
47594 + *stats_reg = &regs->fmbm_rfrc;
47595 + break;
47596 + case E_FMAN_PORT_STATS_CNT_DISCARD:
47597 + *stats_reg = &regs->fmbm_rfdc;
47598 + break;
47599 + case E_FMAN_PORT_STATS_CNT_DEALLOC_BUF:
47600 + *stats_reg = &regs->fmbm_rbdc;
47601 + break;
47602 + case E_FMAN_PORT_STATS_CNT_RX_BAD_FRAME:
47603 + *stats_reg = &regs->fmbm_rfbc;
47604 + break;
47605 + case E_FMAN_PORT_STATS_CNT_RX_LARGE_FRAME:
47606 + *stats_reg = &regs->fmbm_rlfc;
47607 + break;
47608 + case E_FMAN_PORT_STATS_CNT_RX_OUT_OF_BUF:
47609 + *stats_reg = &regs->fmbm_rodc;
47610 + break;
47611 + case E_FMAN_PORT_STATS_CNT_FILTERED_FRAME:
47612 + *stats_reg = &regs->fmbm_rffc;
47613 + break;
47614 + case E_FMAN_PORT_STATS_CNT_DMA_ERR:
47615 + *stats_reg = &regs->fmbm_rfldec;
47616 + break;
47617 + default:
47618 + *stats_reg = NULL;
47619 + }
47620 +}
47621 +
47622 +static void get_tx_stats_reg(struct fman_port *port,
47623 + enum fman_port_stats_counters counter,
47624 + uint32_t **stats_reg)
47625 +{
47626 + struct fman_port_tx_bmi_regs *regs = &port->bmi_regs->tx;
47627 +
47628 + switch (counter) {
47629 + case E_FMAN_PORT_STATS_CNT_FRAME:
47630 + *stats_reg = &regs->fmbm_tfrc;
47631 + break;
47632 + case E_FMAN_PORT_STATS_CNT_DISCARD:
47633 + *stats_reg = &regs->fmbm_tfdc;
47634 + break;
47635 + case E_FMAN_PORT_STATS_CNT_DEALLOC_BUF:
47636 + *stats_reg = &regs->fmbm_tbdc;
47637 + break;
47638 + case E_FMAN_PORT_STATS_CNT_LEN_ERR:
47639 + *stats_reg = &regs->fmbm_tfledc;
47640 + break;
47641 + case E_FMAN_PORT_STATS_CNT_UNSUPPORTED_FORMAT:
47642 + *stats_reg = &regs->fmbm_tfufdc;
47643 + break;
47644 + default:
47645 + *stats_reg = NULL;
47646 + }
47647 +}
47648 +
47649 +static void get_oh_stats_reg(struct fman_port *port,
47650 + enum fman_port_stats_counters counter,
47651 + uint32_t **stats_reg)
47652 +{
47653 + struct fman_port_oh_bmi_regs *regs = &port->bmi_regs->oh;
47654 +
47655 + switch (counter) {
47656 + case E_FMAN_PORT_STATS_CNT_FRAME:
47657 + *stats_reg = &regs->fmbm_ofrc;
47658 + break;
47659 + case E_FMAN_PORT_STATS_CNT_DISCARD:
47660 + *stats_reg = &regs->fmbm_ofdc;
47661 + break;
47662 + case E_FMAN_PORT_STATS_CNT_DEALLOC_BUF:
47663 + *stats_reg = &regs->fmbm_obdc;
47664 + break;
47665 + case E_FMAN_PORT_STATS_CNT_FILTERED_FRAME:
47666 + *stats_reg = &regs->fmbm_offc;
47667 + break;
47668 + case E_FMAN_PORT_STATS_CNT_DMA_ERR:
47669 + *stats_reg = &regs->fmbm_ofldec;
47670 + break;
47671 + case E_FMAN_PORT_STATS_CNT_LEN_ERR:
47672 + *stats_reg = &regs->fmbm_ofledc;
47673 + break;
47674 + case E_FMAN_PORT_STATS_CNT_UNSUPPORTED_FORMAT:
47675 + *stats_reg = &regs->fmbm_ofufdc;
47676 + break;
47677 + case E_FMAN_PORT_STATS_CNT_WRED_DISCARD:
47678 + *stats_reg = &regs->fmbm_ofwdc;
47679 + break;
47680 + default:
47681 + *stats_reg = NULL;
47682 + }
47683 +}
47684 +
47685 +static void get_rx_perf_reg(struct fman_port *port,
47686 + enum fman_port_perf_counters counter,
47687 + uint32_t **perf_reg)
47688 +{
47689 + struct fman_port_rx_bmi_regs *regs = &port->bmi_regs->rx;
47690 +
47691 + switch (counter) {
47692 + case E_FMAN_PORT_PERF_CNT_CYCLE:
47693 + *perf_reg = &regs->fmbm_rccn;
47694 + break;
47695 + case E_FMAN_PORT_PERF_CNT_TASK_UTIL:
47696 + *perf_reg = &regs->fmbm_rtuc;
47697 + break;
47698 + case E_FMAN_PORT_PERF_CNT_QUEUE_UTIL:
47699 + *perf_reg = &regs->fmbm_rrquc;
47700 + break;
47701 + case E_FMAN_PORT_PERF_CNT_DMA_UTIL:
47702 + *perf_reg = &regs->fmbm_rduc;
47703 + break;
47704 + case E_FMAN_PORT_PERF_CNT_FIFO_UTIL:
47705 + *perf_reg = &regs->fmbm_rfuc;
47706 + break;
47707 + case E_FMAN_PORT_PERF_CNT_RX_PAUSE:
47708 + *perf_reg = &regs->fmbm_rpac;
47709 + break;
47710 + default:
47711 + *perf_reg = NULL;
47712 + }
47713 +}
47714 +
47715 +static void get_tx_perf_reg(struct fman_port *port,
47716 + enum fman_port_perf_counters counter,
47717 + uint32_t **perf_reg)
47718 +{
47719 + struct fman_port_tx_bmi_regs *regs = &port->bmi_regs->tx;
47720 +
47721 + switch (counter) {
47722 + case E_FMAN_PORT_PERF_CNT_CYCLE:
47723 + *perf_reg = &regs->fmbm_tccn;
47724 + break;
47725 + case E_FMAN_PORT_PERF_CNT_TASK_UTIL:
47726 + *perf_reg = &regs->fmbm_ttuc;
47727 + break;
47728 + case E_FMAN_PORT_PERF_CNT_QUEUE_UTIL:
47729 + *perf_reg = &regs->fmbm_ttcquc;
47730 + break;
47731 + case E_FMAN_PORT_PERF_CNT_DMA_UTIL:
47732 + *perf_reg = &regs->fmbm_tduc;
47733 + break;
47734 + case E_FMAN_PORT_PERF_CNT_FIFO_UTIL:
47735 + *perf_reg = &regs->fmbm_tfuc;
47736 + break;
47737 + default:
47738 + *perf_reg = NULL;
47739 + }
47740 +}
47741 +
47742 +static void get_oh_perf_reg(struct fman_port *port,
47743 + enum fman_port_perf_counters counter,
47744 + uint32_t **perf_reg)
47745 +{
47746 + struct fman_port_oh_bmi_regs *regs = &port->bmi_regs->oh;
47747 +
47748 + switch (counter) {
47749 + case E_FMAN_PORT_PERF_CNT_CYCLE:
47750 + *perf_reg = &regs->fmbm_occn;
47751 + break;
47752 + case E_FMAN_PORT_PERF_CNT_TASK_UTIL:
47753 + *perf_reg = &regs->fmbm_otuc;
47754 + break;
47755 + case E_FMAN_PORT_PERF_CNT_DMA_UTIL:
47756 + *perf_reg = &regs->fmbm_oduc;
47757 + break;
47758 + case E_FMAN_PORT_PERF_CNT_FIFO_UTIL:
47759 + *perf_reg = &regs->fmbm_ofuc;
47760 + break;
47761 + default:
47762 + *perf_reg = NULL;
47763 + }
47764 +}
47765 +
47766 +static void get_qmi_counter_reg(struct fman_port *port,
47767 + enum fman_port_qmi_counters counter,
47768 + uint32_t **queue_reg)
47769 +{
47770 + struct fman_port_qmi_regs *regs = port->qmi_regs;
47771 +
47772 + switch (counter) {
47773 + case E_FMAN_PORT_ENQ_TOTAL:
47774 + *queue_reg = &regs->fmqm_pnetfc;
47775 + break;
47776 + case E_FMAN_PORT_DEQ_TOTAL:
47777 + if ((port->type == E_FMAN_PORT_TYPE_RX) ||
47778 + (port->type == E_FMAN_PORT_TYPE_RX_10G))
47779 + /* Counter not available for Rx ports */
47780 + *queue_reg = NULL;
47781 + else
47782 + *queue_reg = &regs->fmqm_pndtfc;
47783 + break;
47784 + case E_FMAN_PORT_DEQ_FROM_DFLT:
47785 + if ((port->type == E_FMAN_PORT_TYPE_RX) ||
47786 + (port->type == E_FMAN_PORT_TYPE_RX_10G))
47787 + /* Counter not available for Rx ports */
47788 + *queue_reg = NULL;
47789 + else
47790 + *queue_reg = &regs->fmqm_pndfdc;
47791 + break;
47792 + case E_FMAN_PORT_DEQ_CONFIRM:
47793 + if ((port->type == E_FMAN_PORT_TYPE_RX) ||
47794 + (port->type == E_FMAN_PORT_TYPE_RX_10G))
47795 + /* Counter not available for Rx ports */
47796 + *queue_reg = NULL;
47797 + else
47798 + *queue_reg = &regs->fmqm_pndcc;
47799 + break;
47800 + default:
47801 + *queue_reg = NULL;
47802 + }
47803 +}
47804 +
47805 +void fman_port_defconfig(struct fman_port_cfg *cfg, enum fman_port_type type)
47806 +{
47807 + cfg->dma_swap_data = E_FMAN_PORT_DMA_NO_SWAP;
47808 + cfg->dma_ic_stash_on = FALSE;
47809 + cfg->dma_header_stash_on = FALSE;
47810 + cfg->dma_sg_stash_on = FALSE;
47811 + cfg->dma_write_optimize = TRUE;
47812 + cfg->color = E_FMAN_PORT_COLOR_GREEN;
47813 + cfg->discard_override = FALSE;
47814 + cfg->checksum_bytes_ignore = 0;
47815 + cfg->rx_cut_end_bytes = 4;
47816 + cfg->rx_pri_elevation = ((0x3FF + 1) * FMAN_PORT_BMI_FIFO_UNITS);
47817 + cfg->rx_fifo_thr = ((0x3FF + 1) * FMAN_PORT_BMI_FIFO_UNITS);
47818 + cfg->rx_fd_bits = 0;
47819 + cfg->ic_ext_offset = 0;
47820 + cfg->ic_int_offset = 0;
47821 + cfg->ic_size = 0;
47822 + cfg->int_buf_start_margin = 0;
47823 + cfg->ext_buf_start_margin = 0;
47824 + cfg->ext_buf_end_margin = 0;
47825 + cfg->tx_fifo_min_level = 0;
47826 + cfg->tx_fifo_low_comf_level = (5 * KILOBYTE);
47827 + cfg->stats_counters_enable = TRUE;
47828 + cfg->perf_counters_enable = TRUE;
47829 + cfg->deq_type = E_FMAN_PORT_DEQ_BY_PRI;
47830 +
47831 + if (type == E_FMAN_PORT_TYPE_HC) {
47832 + cfg->sync_req = FALSE;
47833 + cfg->deq_prefetch_opt = E_FMAN_PORT_DEQ_NO_PREFETCH;
47834 + } else {
47835 + cfg->sync_req = TRUE;
47836 + cfg->deq_prefetch_opt = E_FMAN_PORT_DEQ_FULL_PREFETCH;
47837 + }
47838 +
47839 + if (type == E_FMAN_PORT_TYPE_TX_10G) {
47840 + cfg->tx_fifo_deq_pipeline_depth = 4;
47841 + cfg->deq_high_pri = TRUE;
47842 + cfg->deq_byte_cnt = 0x1400;
47843 + } else {
47844 + if ((type == E_FMAN_PORT_TYPE_HC) ||
47845 + (type == E_FMAN_PORT_TYPE_OP))
47846 + cfg->tx_fifo_deq_pipeline_depth = 2;
47847 + else
47848 + cfg->tx_fifo_deq_pipeline_depth = 1;
47849 +
47850 + cfg->deq_high_pri = FALSE;
47851 + cfg->deq_byte_cnt = 0x400;
47852 + }
47853 + cfg->no_scatter_gather = DEFAULT_FMAN_SP_NO_SCATTER_GATHER;
47854 +}
47855 +
47856 +static uint8_t fman_port_find_bpool(struct fman_port *port, uint8_t bpid)
47857 +{
47858 + uint32_t *bp_reg, tmp;
47859 + uint8_t i, id;
47860 +
47861 + /* Find the pool */
47862 + bp_reg = port->bmi_regs->rx.fmbm_ebmpi;
47863 + for (i = 0;
47864 + (i < port->ext_pools_num && (i < FMAN_PORT_MAX_EXT_POOLS_NUM));
47865 + i++) {
47866 + tmp = ioread32be(&bp_reg[i]);
47867 + id = (uint8_t)((tmp & BMI_EXT_BUF_POOL_ID_MASK) >>
47868 + BMI_EXT_BUF_POOL_ID_SHIFT);
47869 +
47870 + if (id == bpid)
47871 + break;
47872 + }
47873 +
47874 + return i;
47875 +}
47876 +
47877 +int fman_port_init(struct fman_port *port,
47878 + struct fman_port_cfg *cfg,
47879 + struct fman_port_params *params)
47880 +{
47881 + int err;
47882 +
47883 + /* Init BMI registers */
47884 + switch (port->type) {
47885 + case E_FMAN_PORT_TYPE_RX:
47886 + case E_FMAN_PORT_TYPE_RX_10G:
47887 + err = init_bmi_rx(port, cfg, params);
47888 + break;
47889 + case E_FMAN_PORT_TYPE_TX:
47890 + case E_FMAN_PORT_TYPE_TX_10G:
47891 + err = init_bmi_tx(port, cfg, params);
47892 + break;
47893 + case E_FMAN_PORT_TYPE_OP:
47894 + case E_FMAN_PORT_TYPE_HC:
47895 + err = init_bmi_oh(port, cfg, params);
47896 + break;
47897 + default:
47898 + return -EINVAL;
47899 + }
47900 +
47901 + if (err)
47902 + return err;
47903 +
47904 + /* Init QMI registers */
47905 + if (!port->im_en)
47906 + {
47907 + err = init_qmi(port, cfg, params);
47908 + return err;
47909 + }
47910 + return 0;
47911 +}
47912 +
47913 +int fman_port_enable(struct fman_port *port)
47914 +{
47915 + uint32_t *bmi_cfg_reg, tmp;
47916 + bool rx_port;
47917 +
47918 + switch (port->type) {
47919 + case E_FMAN_PORT_TYPE_RX:
47920 + case E_FMAN_PORT_TYPE_RX_10G:
47921 + bmi_cfg_reg = &port->bmi_regs->rx.fmbm_rcfg;
47922 + rx_port = TRUE;
47923 + break;
47924 + case E_FMAN_PORT_TYPE_TX:
47925 + case E_FMAN_PORT_TYPE_TX_10G:
47926 + bmi_cfg_reg = &port->bmi_regs->tx.fmbm_tcfg;
47927 + rx_port = FALSE;
47928 + break;
47929 + case E_FMAN_PORT_TYPE_OP:
47930 + case E_FMAN_PORT_TYPE_HC:
47931 + bmi_cfg_reg = &port->bmi_regs->oh.fmbm_ocfg;
47932 + rx_port = FALSE;
47933 + break;
47934 + default:
47935 + return -EINVAL;
47936 + }
47937 +
47938 + /* Enable QMI */
47939 + if (!rx_port) {
47940 + tmp = ioread32be(&port->qmi_regs->fmqm_pnc) | QMI_PORT_CFG_EN;
47941 + iowrite32be(tmp, &port->qmi_regs->fmqm_pnc);
47942 + }
47943 +
47944 + /* Enable BMI */
47945 + tmp = ioread32be(bmi_cfg_reg) | BMI_PORT_CFG_EN;
47946 + iowrite32be(tmp, bmi_cfg_reg);
47947 +
47948 + return 0;
47949 +}
47950 +
47951 +int fman_port_disable(const struct fman_port *port)
47952 +{
47953 + uint32_t *bmi_cfg_reg, *bmi_status_reg, tmp;
47954 + bool rx_port, failure = FALSE;
47955 + int count;
47956 +
47957 + switch (port->type) {
47958 + case E_FMAN_PORT_TYPE_RX:
47959 + case E_FMAN_PORT_TYPE_RX_10G:
47960 + bmi_cfg_reg = &port->bmi_regs->rx.fmbm_rcfg;
47961 + bmi_status_reg = &port->bmi_regs->rx.fmbm_rst;
47962 + rx_port = TRUE;
47963 + break;
47964 + case E_FMAN_PORT_TYPE_TX:
47965 + case E_FMAN_PORT_TYPE_TX_10G:
47966 + bmi_cfg_reg = &port->bmi_regs->tx.fmbm_tcfg;
47967 + bmi_status_reg = &port->bmi_regs->tx.fmbm_tst;
47968 + rx_port = FALSE;
47969 + break;
47970 + case E_FMAN_PORT_TYPE_OP:
47971 + case E_FMAN_PORT_TYPE_HC:
47972 + bmi_cfg_reg = &port->bmi_regs->oh.fmbm_ocfg;
47973 + bmi_status_reg = &port->bmi_regs->oh.fmbm_ost;
47974 + rx_port = FALSE;
47975 + break;
47976 + default:
47977 + return -EINVAL;
47978 + }
47979 +
47980 + /* Disable QMI */
47981 + if (!rx_port) {
47982 + tmp = ioread32be(&port->qmi_regs->fmqm_pnc) & ~QMI_PORT_CFG_EN;
47983 + iowrite32be(tmp, &port->qmi_regs->fmqm_pnc);
47984 +
47985 + /* Wait for QMI to finish FD handling */
47986 + count = 100;
47987 + do {
47988 + udelay(10);
47989 + tmp = ioread32be(&port->qmi_regs->fmqm_pns);
47990 + } while ((tmp & QMI_PORT_STATUS_DEQ_FD_BSY) && --count);
47991 +
47992 + if (count == 0)
47993 + {
47994 + /* Timeout */
47995 + failure = TRUE;
47996 + }
47997 + }
47998 +
47999 + /* Disable BMI */
48000 + tmp = ioread32be(bmi_cfg_reg) & ~BMI_PORT_CFG_EN;
48001 + iowrite32be(tmp, bmi_cfg_reg);
48002 +
48003 + /* Wait for graceful stop end */
48004 + count = 500;
48005 + do {
48006 + udelay(10);
48007 + tmp = ioread32be(bmi_status_reg);
48008 + } while ((tmp & BMI_PORT_STATUS_BSY) && --count);
48009 +
48010 + if (count == 0)
48011 + {
48012 + /* Timeout */
48013 + failure = TRUE;
48014 + }
48015 +
48016 + if (failure)
48017 + return -EBUSY;
48018 +
48019 + return 0;
48020 +}
48021 +
48022 +int fman_port_set_bpools(const struct fman_port *port,
48023 + const struct fman_port_bpools *bp)
48024 +{
48025 + uint32_t tmp, *bp_reg, *bp_depl_reg;
48026 + uint8_t i, max_bp_num;
48027 + bool grp_depl_used = FALSE, rx_port;
48028 +
48029 + switch (port->type) {
48030 + case E_FMAN_PORT_TYPE_RX:
48031 + case E_FMAN_PORT_TYPE_RX_10G:
48032 + max_bp_num = port->ext_pools_num;
48033 + rx_port = TRUE;
48034 + bp_reg = port->bmi_regs->rx.fmbm_ebmpi;
48035 + bp_depl_reg = &port->bmi_regs->rx.fmbm_mpd;
48036 + break;
48037 + case E_FMAN_PORT_TYPE_OP:
48038 + if (port->fm_rev_maj != 4)
48039 + return -EINVAL;
48040 + max_bp_num = FMAN_PORT_OBS_EXT_POOLS_NUM;
48041 + rx_port = FALSE;
48042 + bp_reg = port->bmi_regs->oh.fmbm_oebmpi;
48043 + bp_depl_reg = &port->bmi_regs->oh.fmbm_ompd;
48044 + break;
48045 + default:
48046 + return -EINVAL;
48047 + }
48048 +
48049 + if (rx_port) {
48050 + /* Check buffers are provided in ascending order */
48051 + for (i = 0;
48052 + (i < (bp->count-1) && (i < FMAN_PORT_MAX_EXT_POOLS_NUM - 1));
48053 + i++) {
48054 + if (bp->bpool[i].size > bp->bpool[i+1].size)
48055 + return -EINVAL;
48056 + }
48057 + }
48058 +
48059 + /* Set up external buffers pools */
48060 + for (i = 0; i < bp->count; i++) {
48061 + tmp = BMI_EXT_BUF_POOL_VALID;
48062 + tmp |= ((uint32_t)bp->bpool[i].bpid <<
48063 + BMI_EXT_BUF_POOL_ID_SHIFT) & BMI_EXT_BUF_POOL_ID_MASK;
48064 +
48065 + if (rx_port) {
48066 + if (bp->counters_enable)
48067 + tmp |= BMI_EXT_BUF_POOL_EN_COUNTER;
48068 +
48069 + if (bp->bpool[i].is_backup)
48070 + tmp |= BMI_EXT_BUF_POOL_BACKUP;
48071 +
48072 + tmp |= (uint32_t)bp->bpool[i].size;
48073 + }
48074 +
48075 + iowrite32be(tmp, &bp_reg[i]);
48076 + }
48077 +
48078 + /* Clear unused pools */
48079 + for (i = bp->count; i < max_bp_num; i++)
48080 + iowrite32be(0, &bp_reg[i]);
48081 +
48082 + /* Pools depletion */
48083 + tmp = 0;
48084 + for (i = 0; i < FMAN_PORT_MAX_EXT_POOLS_NUM; i++) {
48085 + if (bp->bpool[i].grp_bp_depleted) {
48086 + grp_depl_used = TRUE;
48087 + tmp |= 0x80000000 >> i;
48088 + }
48089 +
48090 + if (bp->bpool[i].single_bp_depleted)
48091 + tmp |= 0x80 >> i;
48092 +
48093 + if (bp->bpool[i].pfc_priorities_en)
48094 + tmp |= 0x0100 << i;
48095 + }
48096 +
48097 + if (grp_depl_used)
48098 + tmp |= ((uint32_t)bp->grp_bp_depleted_num - 1) <<
48099 + BMI_POOL_DEP_NUM_OF_POOLS_SHIFT;
48100 +
48101 + iowrite32be(tmp, bp_depl_reg);
48102 + return 0;
48103 +}
48104 +
48105 +int fman_port_set_rate_limiter(struct fman_port *port,
48106 + struct fman_port_rate_limiter *rate_limiter)
48107 +{
48108 + uint32_t *rate_limit_reg, *rate_limit_scale_reg;
48109 + uint32_t granularity, tmp;
48110 + uint8_t usec_bit, factor;
48111 +
48112 + switch (port->type) {
48113 + case E_FMAN_PORT_TYPE_TX:
48114 + case E_FMAN_PORT_TYPE_TX_10G:
48115 + rate_limit_reg = &port->bmi_regs->tx.fmbm_trlmt;
48116 + rate_limit_scale_reg = &port->bmi_regs->tx.fmbm_trlmts;
48117 + granularity = BMI_RATE_LIMIT_GRAN_TX;
48118 + break;
48119 + case E_FMAN_PORT_TYPE_OP:
48120 + rate_limit_reg = &port->bmi_regs->oh.fmbm_orlmt;
48121 + rate_limit_scale_reg = &port->bmi_regs->oh.fmbm_orlmts;
48122 + granularity = BMI_RATE_LIMIT_GRAN_OP;
48123 + break;
48124 + default:
48125 + return -EINVAL;
48126 + }
48127 +
48128 + /* Factor is per 1 usec count */
48129 + factor = 1;
48130 + usec_bit = rate_limiter->count_1micro_bit;
48131 +
48132 + /* If rate limit is too small for an 1usec factor, adjust timestamp
48133 + * scale and multiply the factor */
48134 + while (rate_limiter->rate < (granularity / factor)) {
48135 + if (usec_bit == 31)
48136 + /* Can't configure rate limiter - rate is too small */
48137 + return -EINVAL;
48138 +
48139 + usec_bit++;
48140 + factor <<= 1;
48141 + }
48142 +
48143 + /* Figure out register value. The "while" above quarantees that
48144 + * (rate_limiter->rate * factor / granularity) >= 1 */
48145 + tmp = (uint32_t)(rate_limiter->rate * factor / granularity - 1);
48146 +
48147 + /* Check rate limit isn't too large */
48148 + if (tmp >= BMI_RATE_LIMIT_MAX_RATE_IN_GRAN_UNITS)
48149 + return -EINVAL;
48150 +
48151 + /* Check burst size is in allowed range */
48152 + if ((rate_limiter->burst_size == 0) ||
48153 + (rate_limiter->burst_size >
48154 + BMI_RATE_LIMIT_MAX_BURST_SIZE))
48155 + return -EINVAL;
48156 +
48157 + tmp |= (uint32_t)(rate_limiter->burst_size - 1) <<
48158 + BMI_RATE_LIMIT_MAX_BURST_SHIFT;
48159 +
48160 + if ((port->type == E_FMAN_PORT_TYPE_OP) &&
48161 + (port->fm_rev_maj == 4)) {
48162 + if (rate_limiter->high_burst_size_gran)
48163 + tmp |= BMI_RATE_LIMIT_HIGH_BURST_SIZE_GRAN;
48164 + }
48165 +
48166 + iowrite32be(tmp, rate_limit_reg);
48167 +
48168 + /* Set up rate limiter scale register */
48169 + tmp = BMI_RATE_LIMIT_SCALE_EN;
48170 + tmp |= (31 - (uint32_t)usec_bit) << BMI_RATE_LIMIT_SCALE_TSBS_SHIFT;
48171 +
48172 + if ((port->type == E_FMAN_PORT_TYPE_OP) &&
48173 + (port->fm_rev_maj == 4))
48174 + tmp |= rate_limiter->rate_factor;
48175 +
48176 + iowrite32be(tmp, rate_limit_scale_reg);
48177 +
48178 + return 0;
48179 +}
48180 +
48181 +int fman_port_delete_rate_limiter(struct fman_port *port)
48182 +{
48183 + uint32_t *rate_limit_scale_reg;
48184 +
48185 + switch (port->type) {
48186 + case E_FMAN_PORT_TYPE_TX:
48187 + case E_FMAN_PORT_TYPE_TX_10G:
48188 + rate_limit_scale_reg = &port->bmi_regs->tx.fmbm_trlmts;
48189 + break;
48190 + case E_FMAN_PORT_TYPE_OP:
48191 + rate_limit_scale_reg = &port->bmi_regs->oh.fmbm_orlmts;
48192 + break;
48193 + default:
48194 + return -EINVAL;
48195 + }
48196 +
48197 + iowrite32be(0, rate_limit_scale_reg);
48198 + return 0;
48199 +}
48200 +
48201 +int fman_port_set_err_mask(struct fman_port *port, uint32_t err_mask)
48202 +{
48203 + uint32_t *err_mask_reg;
48204 +
48205 + /* Obtain register address */
48206 + switch (port->type) {
48207 + case E_FMAN_PORT_TYPE_RX:
48208 + case E_FMAN_PORT_TYPE_RX_10G:
48209 + err_mask_reg = &port->bmi_regs->rx.fmbm_rfsem;
48210 + break;
48211 + case E_FMAN_PORT_TYPE_OP:
48212 + err_mask_reg = &port->bmi_regs->oh.fmbm_ofsem;
48213 + break;
48214 + default:
48215 + return -EINVAL;
48216 + }
48217 +
48218 + iowrite32be(err_mask, err_mask_reg);
48219 + return 0;
48220 +}
48221 +
48222 +int fman_port_set_discard_mask(struct fman_port *port, uint32_t discard_mask)
48223 +{
48224 + uint32_t *discard_mask_reg;
48225 +
48226 + /* Obtain register address */
48227 + switch (port->type) {
48228 + case E_FMAN_PORT_TYPE_RX:
48229 + case E_FMAN_PORT_TYPE_RX_10G:
48230 + discard_mask_reg = &port->bmi_regs->rx.fmbm_rfsdm;
48231 + break;
48232 + case E_FMAN_PORT_TYPE_OP:
48233 + discard_mask_reg = &port->bmi_regs->oh.fmbm_ofsdm;
48234 + break;
48235 + default:
48236 + return -EINVAL;
48237 + }
48238 +
48239 + iowrite32be(discard_mask, discard_mask_reg);
48240 + return 0;
48241 +}
48242 +
48243 +int fman_port_modify_rx_fd_bits(struct fman_port *port,
48244 + uint8_t rx_fd_bits,
48245 + bool add)
48246 +{
48247 + uint32_t tmp;
48248 +
48249 + switch (port->type) {
48250 + case E_FMAN_PORT_TYPE_RX:
48251 + case E_FMAN_PORT_TYPE_RX_10G:
48252 + break;
48253 + default:
48254 + return -EINVAL;
48255 + }
48256 +
48257 + tmp = ioread32be(&port->bmi_regs->rx.fmbm_rfne);
48258 +
48259 + if (add)
48260 + tmp |= (uint32_t)rx_fd_bits << BMI_NEXT_ENG_FD_BITS_SHIFT;
48261 + else
48262 + tmp &= ~((uint32_t)rx_fd_bits << BMI_NEXT_ENG_FD_BITS_SHIFT);
48263 +
48264 + iowrite32be(tmp, &port->bmi_regs->rx.fmbm_rfne);
48265 + return 0;
48266 +}
48267 +
48268 +int fman_port_set_perf_cnt_params(struct fman_port *port,
48269 + struct fman_port_perf_cnt_params *params)
48270 +{
48271 + uint32_t *pcp_reg, tmp;
48272 +
48273 + /* Obtain register address and check parameters are in range */
48274 + switch (port->type) {
48275 + case E_FMAN_PORT_TYPE_RX:
48276 + case E_FMAN_PORT_TYPE_RX_10G:
48277 + pcp_reg = &port->bmi_regs->rx.fmbm_rpcp;
48278 + if ((params->queue_val == 0) ||
48279 + (params->queue_val > MAX_PERFORMANCE_RX_QUEUE_COMP))
48280 + return -EINVAL;
48281 + break;
48282 + case E_FMAN_PORT_TYPE_TX:
48283 + case E_FMAN_PORT_TYPE_TX_10G:
48284 + pcp_reg = &port->bmi_regs->tx.fmbm_tpcp;
48285 + if ((params->queue_val == 0) ||
48286 + (params->queue_val > MAX_PERFORMANCE_TX_QUEUE_COMP))
48287 + return -EINVAL;
48288 + break;
48289 + case E_FMAN_PORT_TYPE_OP:
48290 + case E_FMAN_PORT_TYPE_HC:
48291 + pcp_reg = &port->bmi_regs->oh.fmbm_opcp;
48292 + if (params->queue_val != 0)
48293 + return -EINVAL;
48294 + break;
48295 + default:
48296 + return -EINVAL;
48297 + }
48298 +
48299 + if ((params->task_val == 0) ||
48300 + (params->task_val > MAX_PERFORMANCE_TASK_COMP))
48301 + return -EINVAL;
48302 + if ((params->dma_val == 0) ||
48303 + (params->dma_val > MAX_PERFORMANCE_DMA_COMP))
48304 + return -EINVAL;
48305 + if ((params->fifo_val == 0) ||
48306 + ((params->fifo_val / FMAN_PORT_BMI_FIFO_UNITS) >
48307 + MAX_PERFORMANCE_FIFO_COMP))
48308 + return -EINVAL;
48309 + tmp = (uint32_t)(params->task_val - 1) <<
48310 + BMI_PERFORMANCE_TASK_COMP_SHIFT;
48311 + tmp |= (uint32_t)(params->dma_val - 1) <<
48312 + BMI_PERFORMANCE_DMA_COMP_SHIFT;
48313 + tmp |= (uint32_t)(params->fifo_val / FMAN_PORT_BMI_FIFO_UNITS - 1);
48314 +
48315 + switch (port->type) {
48316 + case E_FMAN_PORT_TYPE_RX:
48317 + case E_FMAN_PORT_TYPE_RX_10G:
48318 + case E_FMAN_PORT_TYPE_TX:
48319 + case E_FMAN_PORT_TYPE_TX_10G:
48320 + tmp |= (uint32_t)(params->queue_val - 1) <<
48321 + BMI_PERFORMANCE_QUEUE_COMP_SHIFT;
48322 + break;
48323 + default:
48324 + break;
48325 + }
48326 +
48327 +
48328 + iowrite32be(tmp, pcp_reg);
48329 + return 0;
48330 +}
48331 +
48332 +int fman_port_set_stats_cnt_mode(struct fman_port *port, bool enable)
48333 +{
48334 + uint32_t *stats_reg, tmp;
48335 +
48336 + switch (port->type) {
48337 + case E_FMAN_PORT_TYPE_RX:
48338 + case E_FMAN_PORT_TYPE_RX_10G:
48339 + stats_reg = &port->bmi_regs->rx.fmbm_rstc;
48340 + break;
48341 + case E_FMAN_PORT_TYPE_TX:
48342 + case E_FMAN_PORT_TYPE_TX_10G:
48343 + stats_reg = &port->bmi_regs->tx.fmbm_tstc;
48344 + break;
48345 + case E_FMAN_PORT_TYPE_OP:
48346 + case E_FMAN_PORT_TYPE_HC:
48347 + stats_reg = &port->bmi_regs->oh.fmbm_ostc;
48348 + break;
48349 + default:
48350 + return -EINVAL;
48351 + }
48352 +
48353 + tmp = ioread32be(stats_reg);
48354 +
48355 + if (enable)
48356 + tmp |= BMI_COUNTERS_EN;
48357 + else
48358 + tmp &= ~BMI_COUNTERS_EN;
48359 +
48360 + iowrite32be(tmp, stats_reg);
48361 + return 0;
48362 +}
48363 +
48364 +int fman_port_set_perf_cnt_mode(struct fman_port *port, bool enable)
48365 +{
48366 + uint32_t *stats_reg, tmp;
48367 +
48368 + switch (port->type) {
48369 + case E_FMAN_PORT_TYPE_RX:
48370 + case E_FMAN_PORT_TYPE_RX_10G:
48371 + stats_reg = &port->bmi_regs->rx.fmbm_rpc;
48372 + break;
48373 + case E_FMAN_PORT_TYPE_TX:
48374 + case E_FMAN_PORT_TYPE_TX_10G:
48375 + stats_reg = &port->bmi_regs->tx.fmbm_tpc;
48376 + break;
48377 + case E_FMAN_PORT_TYPE_OP:
48378 + case E_FMAN_PORT_TYPE_HC:
48379 + stats_reg = &port->bmi_regs->oh.fmbm_opc;
48380 + break;
48381 + default:
48382 + return -EINVAL;
48383 + }
48384 +
48385 + tmp = ioread32be(stats_reg);
48386 +
48387 + if (enable)
48388 + tmp |= BMI_COUNTERS_EN;
48389 + else
48390 + tmp &= ~BMI_COUNTERS_EN;
48391 +
48392 + iowrite32be(tmp, stats_reg);
48393 + return 0;
48394 +}
48395 +
48396 +int fman_port_set_queue_cnt_mode(struct fman_port *port, bool enable)
48397 +{
48398 + uint32_t tmp;
48399 +
48400 + tmp = ioread32be(&port->qmi_regs->fmqm_pnc);
48401 +
48402 + if (enable)
48403 + tmp |= QMI_PORT_CFG_EN_COUNTERS;
48404 + else
48405 + tmp &= ~QMI_PORT_CFG_EN_COUNTERS;
48406 +
48407 + iowrite32be(tmp, &port->qmi_regs->fmqm_pnc);
48408 + return 0;
48409 +}
48410 +
48411 +int fman_port_set_bpool_cnt_mode(struct fman_port *port,
48412 + uint8_t bpid,
48413 + bool enable)
48414 +{
48415 + uint8_t index;
48416 + uint32_t tmp;
48417 +
48418 + switch (port->type) {
48419 + case E_FMAN_PORT_TYPE_RX:
48420 + case E_FMAN_PORT_TYPE_RX_10G:
48421 + break;
48422 + default:
48423 + return -EINVAL;
48424 + }
48425 +
48426 + /* Find the pool */
48427 + index = fman_port_find_bpool(port, bpid);
48428 + if (index == port->ext_pools_num || index == FMAN_PORT_MAX_EXT_POOLS_NUM)
48429 + /* Not found */
48430 + return -EINVAL;
48431 +
48432 + tmp = ioread32be(&port->bmi_regs->rx.fmbm_ebmpi[index]);
48433 +
48434 + if (enable)
48435 + tmp |= BMI_EXT_BUF_POOL_EN_COUNTER;
48436 + else
48437 + tmp &= ~BMI_EXT_BUF_POOL_EN_COUNTER;
48438 +
48439 + iowrite32be(tmp, &port->bmi_regs->rx.fmbm_ebmpi[index]);
48440 + return 0;
48441 +}
48442 +
48443 +uint32_t fman_port_get_stats_counter(struct fman_port *port,
48444 + enum fman_port_stats_counters counter)
48445 +{
48446 + uint32_t *stats_reg, ret_val;
48447 +
48448 + switch (port->type) {
48449 + case E_FMAN_PORT_TYPE_RX:
48450 + case E_FMAN_PORT_TYPE_RX_10G:
48451 + get_rx_stats_reg(port, counter, &stats_reg);
48452 + break;
48453 + case E_FMAN_PORT_TYPE_TX:
48454 + case E_FMAN_PORT_TYPE_TX_10G:
48455 + get_tx_stats_reg(port, counter, &stats_reg);
48456 + break;
48457 + case E_FMAN_PORT_TYPE_OP:
48458 + case E_FMAN_PORT_TYPE_HC:
48459 + get_oh_stats_reg(port, counter, &stats_reg);
48460 + break;
48461 + default:
48462 + stats_reg = NULL;
48463 + }
48464 +
48465 + if (stats_reg == NULL)
48466 + return 0;
48467 +
48468 + ret_val = ioread32be(stats_reg);
48469 + return ret_val;
48470 +}
48471 +
48472 +void fman_port_set_stats_counter(struct fman_port *port,
48473 + enum fman_port_stats_counters counter,
48474 + uint32_t value)
48475 +{
48476 + uint32_t *stats_reg;
48477 +
48478 + switch (port->type) {
48479 + case E_FMAN_PORT_TYPE_RX:
48480 + case E_FMAN_PORT_TYPE_RX_10G:
48481 + get_rx_stats_reg(port, counter, &stats_reg);
48482 + break;
48483 + case E_FMAN_PORT_TYPE_TX:
48484 + case E_FMAN_PORT_TYPE_TX_10G:
48485 + get_tx_stats_reg(port, counter, &stats_reg);
48486 + break;
48487 + case E_FMAN_PORT_TYPE_OP:
48488 + case E_FMAN_PORT_TYPE_HC:
48489 + get_oh_stats_reg(port, counter, &stats_reg);
48490 + break;
48491 + default:
48492 + stats_reg = NULL;
48493 + }
48494 +
48495 + if (stats_reg == NULL)
48496 + return;
48497 +
48498 + iowrite32be(value, stats_reg);
48499 +}
48500 +
48501 +uint32_t fman_port_get_perf_counter(struct fman_port *port,
48502 + enum fman_port_perf_counters counter)
48503 +{
48504 + uint32_t *perf_reg, ret_val;
48505 +
48506 + switch (port->type) {
48507 + case E_FMAN_PORT_TYPE_RX:
48508 + case E_FMAN_PORT_TYPE_RX_10G:
48509 + get_rx_perf_reg(port, counter, &perf_reg);
48510 + break;
48511 + case E_FMAN_PORT_TYPE_TX:
48512 + case E_FMAN_PORT_TYPE_TX_10G:
48513 + get_tx_perf_reg(port, counter, &perf_reg);
48514 + break;
48515 + case E_FMAN_PORT_TYPE_OP:
48516 + case E_FMAN_PORT_TYPE_HC:
48517 + get_oh_perf_reg(port, counter, &perf_reg);
48518 + break;
48519 + default:
48520 + perf_reg = NULL;
48521 + }
48522 +
48523 + if (perf_reg == NULL)
48524 + return 0;
48525 +
48526 + ret_val = ioread32be(perf_reg);
48527 + return ret_val;
48528 +}
48529 +
48530 +void fman_port_set_perf_counter(struct fman_port *port,
48531 + enum fman_port_perf_counters counter,
48532 + uint32_t value)
48533 +{
48534 + uint32_t *perf_reg;
48535 +
48536 + switch (port->type) {
48537 + case E_FMAN_PORT_TYPE_RX:
48538 + case E_FMAN_PORT_TYPE_RX_10G:
48539 + get_rx_perf_reg(port, counter, &perf_reg);
48540 + break;
48541 + case E_FMAN_PORT_TYPE_TX:
48542 + case E_FMAN_PORT_TYPE_TX_10G:
48543 + get_tx_perf_reg(port, counter, &perf_reg);
48544 + break;
48545 + case E_FMAN_PORT_TYPE_OP:
48546 + case E_FMAN_PORT_TYPE_HC:
48547 + get_oh_perf_reg(port, counter, &perf_reg);
48548 + break;
48549 + default:
48550 + perf_reg = NULL;
48551 + }
48552 +
48553 + if (perf_reg == NULL)
48554 + return;
48555 +
48556 + iowrite32be(value, perf_reg);
48557 +}
48558 +
48559 +uint32_t fman_port_get_qmi_counter(struct fman_port *port,
48560 + enum fman_port_qmi_counters counter)
48561 +{
48562 + uint32_t *queue_reg, ret_val;
48563 +
48564 + get_qmi_counter_reg(port, counter, &queue_reg);
48565 +
48566 + if (queue_reg == NULL)
48567 + return 0;
48568 +
48569 + ret_val = ioread32be(queue_reg);
48570 + return ret_val;
48571 +}
48572 +
48573 +void fman_port_set_qmi_counter(struct fman_port *port,
48574 + enum fman_port_qmi_counters counter,
48575 + uint32_t value)
48576 +{
48577 + uint32_t *queue_reg;
48578 +
48579 + get_qmi_counter_reg(port, counter, &queue_reg);
48580 +
48581 + if (queue_reg == NULL)
48582 + return;
48583 +
48584 + iowrite32be(value, queue_reg);
48585 +}
48586 +
48587 +uint32_t fman_port_get_bpool_counter(struct fman_port *port, uint8_t bpid)
48588 +{
48589 + uint8_t index;
48590 + uint32_t ret_val;
48591 +
48592 + switch (port->type) {
48593 + case E_FMAN_PORT_TYPE_RX:
48594 + case E_FMAN_PORT_TYPE_RX_10G:
48595 + break;
48596 + default:
48597 + return 0;
48598 + }
48599 +
48600 + /* Find the pool */
48601 + index = fman_port_find_bpool(port, bpid);
48602 + if (index == port->ext_pools_num || index == FMAN_PORT_MAX_EXT_POOLS_NUM)
48603 + /* Not found */
48604 + return 0;
48605 +
48606 + ret_val = ioread32be(&port->bmi_regs->rx.fmbm_acnt[index]);
48607 + return ret_val;
48608 +}
48609 +
48610 +void fman_port_set_bpool_counter(struct fman_port *port,
48611 + uint8_t bpid,
48612 + uint32_t value)
48613 +{
48614 + uint8_t index;
48615 +
48616 + switch (port->type) {
48617 + case E_FMAN_PORT_TYPE_RX:
48618 + case E_FMAN_PORT_TYPE_RX_10G:
48619 + break;
48620 + default:
48621 + return;
48622 + }
48623 +
48624 + /* Find the pool */
48625 + index = fman_port_find_bpool(port, bpid);
48626 + if (index == port->ext_pools_num || index == FMAN_PORT_MAX_EXT_POOLS_NUM)
48627 + /* Not found */
48628 + return;
48629 +
48630 + iowrite32be(value, &port->bmi_regs->rx.fmbm_acnt[index]);
48631 +}
48632 +
48633 +int fman_port_add_congestion_grps(struct fman_port *port,
48634 + uint32_t grps_map[FMAN_PORT_CG_MAP_NUM])
48635 +{
48636 + int i;
48637 + uint32_t tmp, *grp_map_reg;
48638 + uint8_t max_grp_map_num;
48639 +
48640 + switch (port->type) {
48641 + case E_FMAN_PORT_TYPE_RX:
48642 + case E_FMAN_PORT_TYPE_RX_10G:
48643 + if (port->fm_rev_maj == 4)
48644 + max_grp_map_num = 1;
48645 + else
48646 + max_grp_map_num = FMAN_PORT_CG_MAP_NUM;
48647 + grp_map_reg = port->bmi_regs->rx.fmbm_rcgm;
48648 + break;
48649 + case E_FMAN_PORT_TYPE_OP:
48650 + max_grp_map_num = 1;
48651 + if (port->fm_rev_maj != 4)
48652 + return -EINVAL;
48653 + grp_map_reg = port->bmi_regs->oh.fmbm_ocgm;
48654 + break;
48655 + default:
48656 + return -EINVAL;
48657 + }
48658 +
48659 + for (i = (max_grp_map_num - 1); i >= 0; i--) {
48660 + if (grps_map[i] == 0)
48661 + continue;
48662 + tmp = ioread32be(&grp_map_reg[i]);
48663 + tmp |= grps_map[i];
48664 + iowrite32be(tmp, &grp_map_reg[i]);
48665 + }
48666 +
48667 + return 0;
48668 +}
48669 +
48670 +int fman_port_remove_congestion_grps(struct fman_port *port,
48671 + uint32_t grps_map[FMAN_PORT_CG_MAP_NUM])
48672 +{
48673 + int i;
48674 + uint32_t tmp, *grp_map_reg;
48675 + uint8_t max_grp_map_num;
48676 +
48677 + switch (port->type) {
48678 + case E_FMAN_PORT_TYPE_RX:
48679 + case E_FMAN_PORT_TYPE_RX_10G:
48680 + if (port->fm_rev_maj == 4)
48681 + max_grp_map_num = 1;
48682 + else
48683 + max_grp_map_num = FMAN_PORT_CG_MAP_NUM;
48684 + grp_map_reg = port->bmi_regs->rx.fmbm_rcgm;
48685 + break;
48686 + case E_FMAN_PORT_TYPE_OP:
48687 + max_grp_map_num = 1;
48688 + if (port->fm_rev_maj != 4)
48689 + return -EINVAL;
48690 + grp_map_reg = port->bmi_regs->oh.fmbm_ocgm;
48691 + break;
48692 + default:
48693 + return -EINVAL;
48694 + }
48695 +
48696 + for (i = (max_grp_map_num - 1); i >= 0; i--) {
48697 + if (grps_map[i] == 0)
48698 + continue;
48699 + tmp = ioread32be(&grp_map_reg[i]);
48700 + tmp &= ~grps_map[i];
48701 + iowrite32be(tmp, &grp_map_reg[i]);
48702 + }
48703 + return 0;
48704 +}
48705 --- /dev/null
48706 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Rtc/Makefile
48707 @@ -0,0 +1,15 @@
48708 +#
48709 +# Makefile for the Freescale Ethernet controllers
48710 +#
48711 +ccflags-y += -DVERSION=\"\"
48712 +#
48713 +#Include netcomm SW specific definitions
48714 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
48715 +
48716 +NCSW_FM_INC = $(srctree)/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc
48717 +
48718 +ccflags-y += -I$(NCSW_FM_INC)
48719 +
48720 +obj-y += fsl-ncsw-RTC.o
48721 +
48722 +fsl-ncsw-RTC-objs := fm_rtc.o fman_rtc.o
48723 --- /dev/null
48724 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Rtc/fm_rtc.c
48725 @@ -0,0 +1,692 @@
48726 +/*
48727 + * Copyright 2008-2012 Freescale Semiconductor Inc.
48728 + *
48729 + * Redistribution and use in source and binary forms, with or without
48730 + * modification, are permitted provided that the following conditions are met:
48731 + * * Redistributions of source code must retain the above copyright
48732 + * notice, this list of conditions and the following disclaimer.
48733 + * * Redistributions in binary form must reproduce the above copyright
48734 + * notice, this list of conditions and the following disclaimer in the
48735 + * documentation and/or other materials provided with the distribution.
48736 + * * Neither the name of Freescale Semiconductor nor the
48737 + * names of its contributors may be used to endorse or promote products
48738 + * derived from this software without specific prior written permission.
48739 + *
48740 + *
48741 + * ALTERNATIVELY, this software may be distributed under the terms of the
48742 + * GNU General Public License ("GPL") as published by the Free Software
48743 + * Foundation, either version 2 of that License or (at your option) any
48744 + * later version.
48745 + *
48746 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
48747 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
48748 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48749 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
48750 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
48751 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48752 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48753 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
48754 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
48755 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48756 + */
48757 +
48758 +
48759 +/******************************************************************************
48760 + @File fm_rtc.c
48761 +
48762 + @Description FM RTC driver implementation.
48763 +
48764 + @Cautions None
48765 +*//***************************************************************************/
48766 +
48767 +#include "error_ext.h"
48768 +#include "debug_ext.h"
48769 +#include "string_ext.h"
48770 +#include "part_ext.h"
48771 +#include "xx_ext.h"
48772 +#include "ncsw_ext.h"
48773 +
48774 +#include "fm_rtc.h"
48775 +#include "fm_common.h"
48776 +
48777 +
48778 +
48779 +/*****************************************************************************/
48780 +static t_Error CheckInitParameters(t_FmRtc *p_Rtc)
48781 +{
48782 + struct rtc_cfg *p_RtcDriverParam = p_Rtc->p_RtcDriverParam;
48783 + int i;
48784 +
48785 + if ((p_RtcDriverParam->src_clk != E_FMAN_RTC_SOURCE_CLOCK_EXTERNAL) &&
48786 + (p_RtcDriverParam->src_clk != E_FMAN_RTC_SOURCE_CLOCK_SYSTEM) &&
48787 + (p_RtcDriverParam->src_clk != E_FMAN_RTC_SOURCE_CLOCK_OSCILATOR))
48788 + RETURN_ERROR(MAJOR, E_INVALID_CLOCK, ("Source clock undefined"));
48789 +
48790 + if (p_Rtc->outputClockDivisor == 0)
48791 + {
48792 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
48793 + ("Divisor for output clock (should be positive)"));
48794 + }
48795 +
48796 + for (i=0; i < FM_RTC_NUM_OF_ALARMS; i++)
48797 + {
48798 + if ((p_RtcDriverParam->alarm_polarity[i] != E_FMAN_RTC_ALARM_POLARITY_ACTIVE_LOW) &&
48799 + (p_RtcDriverParam->alarm_polarity[i] != E_FMAN_RTC_ALARM_POLARITY_ACTIVE_HIGH))
48800 + {
48801 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Alarm %d signal polarity", i));
48802 + }
48803 + }
48804 + for (i=0; i < FM_RTC_NUM_OF_EXT_TRIGGERS; i++)
48805 + {
48806 + if ((p_RtcDriverParam->trigger_polarity[i] != E_FMAN_RTC_TRIGGER_ON_FALLING_EDGE) &&
48807 + (p_RtcDriverParam->trigger_polarity[i] != E_FMAN_RTC_TRIGGER_ON_RISING_EDGE))
48808 + {
48809 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Trigger %d signal polarity", i));
48810 + }
48811 + }
48812 +
48813 + return E_OK;
48814 +}
48815 +
48816 +/*****************************************************************************/
48817 +static void RtcExceptions(t_Handle h_FmRtc)
48818 +{
48819 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
48820 + struct rtc_regs *p_MemMap;
48821 + register uint32_t events;
48822 +
48823 + ASSERT_COND(p_Rtc);
48824 + p_MemMap = p_Rtc->p_MemMap;
48825 +
48826 + events = fman_rtc_check_and_clear_event(p_MemMap);
48827 + if (events & FMAN_RTC_TMR_TEVENT_ALM1)
48828 + {
48829 + if (p_Rtc->alarmParams[0].clearOnExpiration)
48830 + {
48831 + fman_rtc_set_timer_alarm_l(p_MemMap, 0, 0);
48832 + fman_rtc_disable_interupt(p_MemMap, FMAN_RTC_TMR_TEVENT_ALM1);
48833 + }
48834 + ASSERT_COND(p_Rtc->alarmParams[0].f_AlarmCallback);
48835 + p_Rtc->alarmParams[0].f_AlarmCallback(p_Rtc->h_App, 0);
48836 + }
48837 + if (events & FMAN_RTC_TMR_TEVENT_ALM2)
48838 + {
48839 + if (p_Rtc->alarmParams[1].clearOnExpiration)
48840 + {
48841 + fman_rtc_set_timer_alarm_l(p_MemMap, 1, 0);
48842 + fman_rtc_disable_interupt(p_MemMap, FMAN_RTC_TMR_TEVENT_ALM2);
48843 + }
48844 + ASSERT_COND(p_Rtc->alarmParams[1].f_AlarmCallback);
48845 + p_Rtc->alarmParams[1].f_AlarmCallback(p_Rtc->h_App, 1);
48846 + }
48847 + if (events & FMAN_RTC_TMR_TEVENT_PP1)
48848 + {
48849 + ASSERT_COND(p_Rtc->periodicPulseParams[0].f_PeriodicPulseCallback);
48850 + p_Rtc->periodicPulseParams[0].f_PeriodicPulseCallback(p_Rtc->h_App, 0);
48851 + }
48852 + if (events & FMAN_RTC_TMR_TEVENT_PP2)
48853 + {
48854 + ASSERT_COND(p_Rtc->periodicPulseParams[1].f_PeriodicPulseCallback);
48855 + p_Rtc->periodicPulseParams[1].f_PeriodicPulseCallback(p_Rtc->h_App, 1);
48856 + }
48857 + if (events & FMAN_RTC_TMR_TEVENT_ETS1)
48858 + {
48859 + ASSERT_COND(p_Rtc->externalTriggerParams[0].f_ExternalTriggerCallback);
48860 + p_Rtc->externalTriggerParams[0].f_ExternalTriggerCallback(p_Rtc->h_App, 0);
48861 + }
48862 + if (events & FMAN_RTC_TMR_TEVENT_ETS2)
48863 + {
48864 + ASSERT_COND(p_Rtc->externalTriggerParams[1].f_ExternalTriggerCallback);
48865 + p_Rtc->externalTriggerParams[1].f_ExternalTriggerCallback(p_Rtc->h_App, 1);
48866 + }
48867 +}
48868 +
48869 +
48870 +/*****************************************************************************/
48871 +t_Handle FM_RTC_Config(t_FmRtcParams *p_FmRtcParam)
48872 +{
48873 + t_FmRtc *p_Rtc;
48874 +
48875 + SANITY_CHECK_RETURN_VALUE(p_FmRtcParam, E_NULL_POINTER, NULL);
48876 +
48877 + /* Allocate memory for the FM RTC driver parameters */
48878 + p_Rtc = (t_FmRtc *)XX_Malloc(sizeof(t_FmRtc));
48879 + if (!p_Rtc)
48880 + {
48881 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM RTC driver structure"));
48882 + return NULL;
48883 + }
48884 +
48885 + memset(p_Rtc, 0, sizeof(t_FmRtc));
48886 +
48887 + /* Allocate memory for the FM RTC driver parameters */
48888 + p_Rtc->p_RtcDriverParam = (struct rtc_cfg *)XX_Malloc(sizeof(struct rtc_cfg));
48889 + if (!p_Rtc->p_RtcDriverParam)
48890 + {
48891 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM RTC driver parameters"));
48892 + XX_Free(p_Rtc);
48893 + return NULL;
48894 + }
48895 +
48896 + memset(p_Rtc->p_RtcDriverParam, 0, sizeof(struct rtc_cfg));
48897 +
48898 + /* Store RTC configuration parameters */
48899 + p_Rtc->h_Fm = p_FmRtcParam->h_Fm;
48900 +
48901 + /* Set default RTC configuration parameters */
48902 + fman_rtc_defconfig(p_Rtc->p_RtcDriverParam);
48903 +
48904 + p_Rtc->outputClockDivisor = DEFAULT_OUTPUT_CLOCK_DIVISOR;
48905 + p_Rtc->p_RtcDriverParam->bypass = DEFAULT_BYPASS;
48906 + p_Rtc->clockPeriodNanoSec = DEFAULT_CLOCK_PERIOD; /* 1 usec */
48907 +
48908 +
48909 + /* Store RTC parameters in the RTC control structure */
48910 + p_Rtc->p_MemMap = (struct rtc_regs *)UINT_TO_PTR(p_FmRtcParam->baseAddress);
48911 + p_Rtc->h_App = p_FmRtcParam->h_App;
48912 +
48913 + return p_Rtc;
48914 +}
48915 +
48916 +/*****************************************************************************/
48917 +t_Error FM_RTC_Init(t_Handle h_FmRtc)
48918 +{
48919 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
48920 + struct rtc_cfg *p_RtcDriverParam;
48921 + struct rtc_regs *p_MemMap;
48922 + uint32_t freqCompensation = 0;
48923 + uint64_t tmpDouble;
48924 + bool init_freq_comp = FALSE;
48925 +
48926 + p_RtcDriverParam = p_Rtc->p_RtcDriverParam;
48927 + p_MemMap = p_Rtc->p_MemMap;
48928 +
48929 + if (CheckInitParameters(p_Rtc)!=E_OK)
48930 + RETURN_ERROR(MAJOR, E_CONFLICT,
48931 + ("Init Parameters are not Valid"));
48932 +
48933 + /* TODO check that no timestamping MACs are working in this stage. */
48934 +
48935 + /* find source clock frequency in Mhz */
48936 + if (p_Rtc->p_RtcDriverParam->src_clk != E_FMAN_RTC_SOURCE_CLOCK_SYSTEM)
48937 + p_Rtc->srcClkFreqMhz = p_Rtc->p_RtcDriverParam->ext_src_clk_freq;
48938 + else
48939 + p_Rtc->srcClkFreqMhz = (uint32_t)(FmGetMacClockFreq(p_Rtc->h_Fm));
48940 +
48941 + /* if timer in Master mode Initialize TMR_CTRL */
48942 + /* We want the counter (TMR_CNT) to count in nano-seconds */
48943 + if (!p_RtcDriverParam->timer_slave_mode && p_Rtc->p_RtcDriverParam->bypass)
48944 + p_Rtc->clockPeriodNanoSec = (1000 / p_Rtc->srcClkFreqMhz);
48945 + else
48946 + {
48947 + /* Initialize TMR_ADD with the initial frequency compensation value:
48948 + freqCompensation = (2^32 / frequency ratio) */
48949 + /* frequency ratio = sorce clock/rtc clock =
48950 + * (p_Rtc->srcClkFreqMhz*1000000))/ 1/(p_Rtc->clockPeriodNanoSec * 1000000000) */
48951 + init_freq_comp = TRUE;
48952 + freqCompensation = (uint32_t)DIV_CEIL(ACCUMULATOR_OVERFLOW * 1000,
48953 + p_Rtc->clockPeriodNanoSec * p_Rtc->srcClkFreqMhz);
48954 + }
48955 +
48956 + /* check the legality of the relation between source and destination clocks */
48957 + /* should be larger than 1.0001 */
48958 + tmpDouble = 10000 * (uint64_t)p_Rtc->clockPeriodNanoSec * (uint64_t)p_Rtc->srcClkFreqMhz;
48959 + if ((tmpDouble) <= 10001)
48960 + RETURN_ERROR(MAJOR, E_CONFLICT,
48961 + ("Invalid relation between source and destination clocks. Should be larger than 1.0001"));
48962 +
48963 + fman_rtc_init(p_RtcDriverParam,
48964 + p_MemMap,
48965 + FM_RTC_NUM_OF_ALARMS,
48966 + FM_RTC_NUM_OF_PERIODIC_PULSES,
48967 + FM_RTC_NUM_OF_EXT_TRIGGERS,
48968 + init_freq_comp,
48969 + freqCompensation,
48970 + p_Rtc->outputClockDivisor);
48971 +
48972 + /* Register the FM RTC interrupt */
48973 + FmRegisterIntr(p_Rtc->h_Fm, e_FM_MOD_TMR, 0, e_FM_INTR_TYPE_NORMAL, RtcExceptions , p_Rtc);
48974 +
48975 + /* Free parameters structures */
48976 + XX_Free(p_Rtc->p_RtcDriverParam);
48977 + p_Rtc->p_RtcDriverParam = NULL;
48978 +
48979 + return E_OK;
48980 +}
48981 +
48982 +/*****************************************************************************/
48983 +t_Error FM_RTC_Free(t_Handle h_FmRtc)
48984 +{
48985 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
48986 +
48987 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
48988 +
48989 + if (p_Rtc->p_RtcDriverParam)
48990 + {
48991 + XX_Free(p_Rtc->p_RtcDriverParam);
48992 + }
48993 + else
48994 + {
48995 + FM_RTC_Disable(h_FmRtc);
48996 + }
48997 +
48998 + /* Unregister FM RTC interrupt */
48999 + FmUnregisterIntr(p_Rtc->h_Fm, e_FM_MOD_TMR, 0, e_FM_INTR_TYPE_NORMAL);
49000 + XX_Free(p_Rtc);
49001 +
49002 + return E_OK;
49003 +}
49004 +
49005 +/*****************************************************************************/
49006 +t_Error FM_RTC_ConfigSourceClock(t_Handle h_FmRtc,
49007 + e_FmSrcClk srcClk,
49008 + uint32_t freqInMhz)
49009 +{
49010 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49011 +
49012 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49013 + SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49014 +
49015 + p_Rtc->p_RtcDriverParam->src_clk = (enum fman_src_clock)srcClk;
49016 + if (srcClk != e_FM_RTC_SOURCE_CLOCK_SYSTEM)
49017 + p_Rtc->p_RtcDriverParam->ext_src_clk_freq = freqInMhz;
49018 +
49019 + return E_OK;
49020 +}
49021 +
49022 +/*****************************************************************************/
49023 +t_Error FM_RTC_ConfigPeriod(t_Handle h_FmRtc, uint32_t period)
49024 +{
49025 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49026 +
49027 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49028 + SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49029 +
49030 + p_Rtc->clockPeriodNanoSec = period;
49031 +
49032 + return E_OK;
49033 +}
49034 +
49035 +/*****************************************************************************/
49036 +t_Error FM_RTC_ConfigFrequencyBypass(t_Handle h_FmRtc, bool enabled)
49037 +{
49038 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49039 +
49040 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49041 + SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49042 +
49043 + p_Rtc->p_RtcDriverParam->bypass = enabled;
49044 +
49045 + return E_OK;
49046 +}
49047 +
49048 +/*****************************************************************************/
49049 +t_Error FM_RTC_ConfigInvertedInputClockPhase(t_Handle h_FmRtc, bool inverted)
49050 +{
49051 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49052 +
49053 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49054 + SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49055 +
49056 + p_Rtc->p_RtcDriverParam->invert_input_clk_phase = inverted;
49057 +
49058 + return E_OK;
49059 +}
49060 +
49061 +/*****************************************************************************/
49062 +t_Error FM_RTC_ConfigInvertedOutputClockPhase(t_Handle h_FmRtc, bool inverted)
49063 +{
49064 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49065 +
49066 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49067 + SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49068 +
49069 + p_Rtc->p_RtcDriverParam->invert_output_clk_phase = inverted;
49070 +
49071 + return E_OK;
49072 +}
49073 +
49074 +/*****************************************************************************/
49075 +t_Error FM_RTC_ConfigOutputClockDivisor(t_Handle h_FmRtc, uint16_t divisor)
49076 +{
49077 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49078 +
49079 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49080 + SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49081 +
49082 + p_Rtc->outputClockDivisor = divisor;
49083 +
49084 + return E_OK;
49085 +}
49086 +
49087 +/*****************************************************************************/
49088 +t_Error FM_RTC_ConfigPulseRealignment(t_Handle h_FmRtc, bool enable)
49089 +{
49090 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49091 +
49092 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49093 + SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49094 +
49095 + p_Rtc->p_RtcDriverParam->pulse_realign = enable;
49096 +
49097 + return E_OK;
49098 +}
49099 +
49100 +/*****************************************************************************/
49101 +t_Error FM_RTC_ConfigAlarmPolarity(t_Handle h_FmRtc,
49102 + uint8_t alarmId,
49103 + e_FmRtcAlarmPolarity alarmPolarity)
49104 +{
49105 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49106 +
49107 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49108 + SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49109 +
49110 + if (alarmId >= FM_RTC_NUM_OF_ALARMS)
49111 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Alarm ID"));
49112 +
49113 + p_Rtc->p_RtcDriverParam->alarm_polarity[alarmId] =
49114 + (enum fman_rtc_alarm_polarity)alarmPolarity;
49115 +
49116 + return E_OK;
49117 +}
49118 +
49119 +/*****************************************************************************/
49120 +t_Error FM_RTC_ConfigExternalTriggerPolarity(t_Handle h_FmRtc,
49121 + uint8_t triggerId,
49122 + e_FmRtcTriggerPolarity triggerPolarity)
49123 +{
49124 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49125 +
49126 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49127 + SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49128 +
49129 + if (triggerId >= FM_RTC_NUM_OF_EXT_TRIGGERS)
49130 + {
49131 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("External trigger ID"));
49132 + }
49133 +
49134 + p_Rtc->p_RtcDriverParam->trigger_polarity[triggerId] =
49135 + (enum fman_rtc_trigger_polarity)triggerPolarity;
49136 +
49137 + return E_OK;
49138 +}
49139 +
49140 +/*****************************************************************************/
49141 +t_Error FM_RTC_Enable(t_Handle h_FmRtc, bool resetClock)
49142 +{
49143 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49144 +
49145 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49146 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49147 +
49148 + fman_rtc_enable(p_Rtc->p_MemMap, resetClock);
49149 + return E_OK;
49150 +}
49151 +
49152 +/*****************************************************************************/
49153 +t_Error FM_RTC_Disable(t_Handle h_FmRtc)
49154 +{
49155 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49156 +
49157 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49158 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49159 +
49160 + /* TODO A check must be added here, that no timestamping MAC's
49161 + * are working in this stage. */
49162 + fman_rtc_disable(p_Rtc->p_MemMap);
49163 +
49164 + return E_OK;
49165 +}
49166 +
49167 +/*****************************************************************************/
49168 +t_Error FM_RTC_SetClockOffset(t_Handle h_FmRtc, int64_t offset)
49169 +{
49170 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49171 +
49172 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49173 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49174 +
49175 + fman_rtc_set_timer_offset(p_Rtc->p_MemMap, offset);
49176 + return E_OK;
49177 +}
49178 +
49179 +/*****************************************************************************/
49180 +t_Error FM_RTC_SetAlarm(t_Handle h_FmRtc, t_FmRtcAlarmParams *p_FmRtcAlarmParams)
49181 +{
49182 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49183 + uint64_t tmpAlarm;
49184 + bool enable = FALSE;
49185 +
49186 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49187 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49188 +
49189 + if (p_FmRtcAlarmParams->alarmId >= FM_RTC_NUM_OF_ALARMS)
49190 + {
49191 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Alarm ID"));
49192 + }
49193 +
49194 + if (p_FmRtcAlarmParams->alarmTime < p_Rtc->clockPeriodNanoSec)
49195 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
49196 + ("Alarm time must be equal or larger than RTC period - %d nanoseconds",
49197 + p_Rtc->clockPeriodNanoSec));
49198 + if (p_FmRtcAlarmParams->alarmTime % (uint64_t)p_Rtc->clockPeriodNanoSec)
49199 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
49200 + ("Alarm time must be a multiple of RTC period - %d nanoseconds",
49201 + p_Rtc->clockPeriodNanoSec));
49202 + tmpAlarm = p_FmRtcAlarmParams->alarmTime/(uint64_t)p_Rtc->clockPeriodNanoSec;
49203 +
49204 + if (p_FmRtcAlarmParams->f_AlarmCallback)
49205 + {
49206 + p_Rtc->alarmParams[p_FmRtcAlarmParams->alarmId].f_AlarmCallback = p_FmRtcAlarmParams->f_AlarmCallback;
49207 + p_Rtc->alarmParams[p_FmRtcAlarmParams->alarmId].clearOnExpiration = p_FmRtcAlarmParams->clearOnExpiration;
49208 + enable = TRUE;
49209 + }
49210 +
49211 + fman_rtc_set_alarm(p_Rtc->p_MemMap, p_FmRtcAlarmParams->alarmId, (unsigned long)tmpAlarm, enable);
49212 +
49213 + return E_OK;
49214 +}
49215 +
49216 +/*****************************************************************************/
49217 +t_Error FM_RTC_SetPeriodicPulse(t_Handle h_FmRtc, t_FmRtcPeriodicPulseParams *p_FmRtcPeriodicPulseParams)
49218 +{
49219 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49220 + bool enable = FALSE;
49221 + uint64_t tmpFiper;
49222 +
49223 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49224 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49225 +
49226 + if (p_FmRtcPeriodicPulseParams->periodicPulseId >= FM_RTC_NUM_OF_PERIODIC_PULSES)
49227 + {
49228 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Periodic pulse ID"));
49229 + }
49230 + if (fman_rtc_is_enabled(p_Rtc->p_MemMap))
49231 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Can't set Periodic pulse when RTC is enabled."));
49232 + if (p_FmRtcPeriodicPulseParams->periodicPulsePeriod < p_Rtc->clockPeriodNanoSec)
49233 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
49234 + ("Periodic pulse must be equal or larger than RTC period - %d nanoseconds",
49235 + p_Rtc->clockPeriodNanoSec));
49236 + if (p_FmRtcPeriodicPulseParams->periodicPulsePeriod % (uint64_t)p_Rtc->clockPeriodNanoSec)
49237 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
49238 + ("Periodic pulse must be a multiple of RTC period - %d nanoseconds",
49239 + p_Rtc->clockPeriodNanoSec));
49240 + tmpFiper = p_FmRtcPeriodicPulseParams->periodicPulsePeriod/(uint64_t)p_Rtc->clockPeriodNanoSec;
49241 + if (tmpFiper & 0xffffffff00000000LL)
49242 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
49243 + ("Periodic pulse/RTC Period must be smaller than 4294967296",
49244 + p_Rtc->clockPeriodNanoSec));
49245 +
49246 + if (p_FmRtcPeriodicPulseParams->f_PeriodicPulseCallback)
49247 + {
49248 + p_Rtc->periodicPulseParams[p_FmRtcPeriodicPulseParams->periodicPulseId].f_PeriodicPulseCallback =
49249 + p_FmRtcPeriodicPulseParams->f_PeriodicPulseCallback;
49250 + enable = TRUE;
49251 + }
49252 + fman_rtc_set_periodic_pulse(p_Rtc->p_MemMap, p_FmRtcPeriodicPulseParams->periodicPulseId, (uint32_t)tmpFiper, enable);
49253 + return E_OK;
49254 +}
49255 +
49256 +/*****************************************************************************/
49257 +t_Error FM_RTC_ClearPeriodicPulse(t_Handle h_FmRtc, uint8_t periodicPulseId)
49258 +{
49259 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49260 +
49261 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49262 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49263 +
49264 + if (periodicPulseId >= FM_RTC_NUM_OF_PERIODIC_PULSES)
49265 + {
49266 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Periodic pulse ID"));
49267 + }
49268 +
49269 + p_Rtc->periodicPulseParams[periodicPulseId].f_PeriodicPulseCallback = NULL;
49270 + fman_rtc_clear_periodic_pulse(p_Rtc->p_MemMap, periodicPulseId);
49271 +
49272 + return E_OK;
49273 +}
49274 +
49275 +/*****************************************************************************/
49276 +t_Error FM_RTC_SetExternalTrigger(t_Handle h_FmRtc, t_FmRtcExternalTriggerParams *p_FmRtcExternalTriggerParams)
49277 +{
49278 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49279 + bool enable = FALSE;
49280 +
49281 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49282 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49283 +
49284 + if (p_FmRtcExternalTriggerParams->externalTriggerId >= FM_RTC_NUM_OF_EXT_TRIGGERS)
49285 + {
49286 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("External Trigger ID"));
49287 + }
49288 +
49289 + if (p_FmRtcExternalTriggerParams->f_ExternalTriggerCallback)
49290 + {
49291 + p_Rtc->externalTriggerParams[p_FmRtcExternalTriggerParams->externalTriggerId].f_ExternalTriggerCallback = p_FmRtcExternalTriggerParams->f_ExternalTriggerCallback;
49292 + enable = TRUE;
49293 + }
49294 +
49295 + fman_rtc_set_ext_trigger(p_Rtc->p_MemMap, p_FmRtcExternalTriggerParams->externalTriggerId, enable, p_FmRtcExternalTriggerParams->usePulseAsInput);
49296 + return E_OK;
49297 +}
49298 +
49299 +/*****************************************************************************/
49300 +t_Error FM_RTC_ClearExternalTrigger(t_Handle h_FmRtc, uint8_t externalTriggerId)
49301 +{
49302 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49303 +
49304 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49305 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49306 +
49307 + if (externalTriggerId >= FM_RTC_NUM_OF_EXT_TRIGGERS)
49308 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("External Trigger ID"));
49309 +
49310 + p_Rtc->externalTriggerParams[externalTriggerId].f_ExternalTriggerCallback = NULL;
49311 +
49312 + fman_rtc_clear_external_trigger(p_Rtc->p_MemMap, externalTriggerId);
49313 +
49314 + return E_OK;
49315 +}
49316 +
49317 +/*****************************************************************************/
49318 +t_Error FM_RTC_GetExternalTriggerTimeStamp(t_Handle h_FmRtc,
49319 + uint8_t triggerId,
49320 + uint64_t *p_TimeStamp)
49321 +{
49322 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49323 +
49324 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49325 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49326 +
49327 + if (triggerId >= FM_RTC_NUM_OF_EXT_TRIGGERS)
49328 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("External trigger ID"));
49329 +
49330 + *p_TimeStamp = fman_rtc_get_trigger_stamp(p_Rtc->p_MemMap, triggerId)*p_Rtc->clockPeriodNanoSec;
49331 +
49332 + return E_OK;
49333 +}
49334 +
49335 +/*****************************************************************************/
49336 +t_Error FM_RTC_GetCurrentTime(t_Handle h_FmRtc, uint64_t *p_Ts)
49337 +{
49338 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49339 +
49340 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49341 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49342 +
49343 + *p_Ts = fman_rtc_get_timer(p_Rtc->p_MemMap)*p_Rtc->clockPeriodNanoSec;
49344 +
49345 + return E_OK;
49346 +}
49347 +
49348 +/*****************************************************************************/
49349 +t_Error FM_RTC_SetCurrentTime(t_Handle h_FmRtc, uint64_t ts)
49350 +{
49351 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49352 +
49353 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49354 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49355 +
49356 + ts = ts/p_Rtc->clockPeriodNanoSec;
49357 + fman_rtc_set_timer(p_Rtc->p_MemMap, (int64_t)ts);
49358 +
49359 + return E_OK;
49360 +}
49361 +
49362 +/*****************************************************************************/
49363 +t_Error FM_RTC_GetFreqCompensation(t_Handle h_FmRtc, uint32_t *p_Compensation)
49364 +{
49365 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49366 +
49367 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49368 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49369 +
49370 + *p_Compensation = fman_rtc_get_frequency_compensation(p_Rtc->p_MemMap);
49371 +
49372 + return E_OK;
49373 +}
49374 +
49375 +/*****************************************************************************/
49376 +t_Error FM_RTC_SetFreqCompensation(t_Handle h_FmRtc, uint32_t freqCompensation)
49377 +{
49378 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49379 +
49380 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49381 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49382 +
49383 + /* set the new freqCompensation */
49384 + fman_rtc_set_frequency_compensation(p_Rtc->p_MemMap, freqCompensation);
49385 +
49386 + return E_OK;
49387 +}
49388 +
49389 +#ifdef CONFIG_PTP_1588_CLOCK_DPAA
49390 +/*****************************************************************************/
49391 +t_Error FM_RTC_EnableInterrupt(t_Handle h_FmRtc, uint32_t events)
49392 +{
49393 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49394 +
49395 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49396 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49397 +
49398 + /* enable interrupt */
49399 + fman_rtc_enable_interupt(p_Rtc->p_MemMap, events);
49400 +
49401 + return E_OK;
49402 +}
49403 +
49404 +/*****************************************************************************/
49405 +t_Error FM_RTC_DisableInterrupt(t_Handle h_FmRtc, uint32_t events)
49406 +{
49407 + t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
49408 +
49409 + SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
49410 + SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
49411 +
49412 + /* disable interrupt */
49413 + fman_rtc_disable_interupt(p_Rtc->p_MemMap, events);
49414 +
49415 + return E_OK;
49416 +}
49417 +#endif
49418 --- /dev/null
49419 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Rtc/fm_rtc.h
49420 @@ -0,0 +1,96 @@
49421 +/*
49422 + * Copyright 2008-2012 Freescale Semiconductor Inc.
49423 + *
49424 + * Redistribution and use in source and binary forms, with or without
49425 + * modification, are permitted provided that the following conditions are met:
49426 + * * Redistributions of source code must retain the above copyright
49427 + * notice, this list of conditions and the following disclaimer.
49428 + * * Redistributions in binary form must reproduce the above copyright
49429 + * notice, this list of conditions and the following disclaimer in the
49430 + * documentation and/or other materials provided with the distribution.
49431 + * * Neither the name of Freescale Semiconductor nor the
49432 + * names of its contributors may be used to endorse or promote products
49433 + * derived from this software without specific prior written permission.
49434 + *
49435 + *
49436 + * ALTERNATIVELY, this software may be distributed under the terms of the
49437 + * GNU General Public License ("GPL") as published by the Free Software
49438 + * Foundation, either version 2 of that License or (at your option) any
49439 + * later version.
49440 + *
49441 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
49442 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
49443 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
49444 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
49445 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
49446 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49447 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49448 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49449 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
49450 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49451 + */
49452 +
49453 +
49454 +/******************************************************************************
49455 + @File fm_rtc.h
49456 +
49457 + @Description Memory map and internal definitions for FM RTC IEEE1588 Timer driver.
49458 +
49459 + @Cautions None
49460 +*//***************************************************************************/
49461 +
49462 +#ifndef __FM_RTC_H__
49463 +#define __FM_RTC_H__
49464 +
49465 +#include "std_ext.h"
49466 +#include "fm_rtc_ext.h"
49467 +
49468 +
49469 +#define __ERR_MODULE__ MODULE_FM_RTC
49470 +
49471 +/* General definitions */
49472 +
49473 +#define ACCUMULATOR_OVERFLOW ((uint64_t)(1LL << 32))
49474 +#define DEFAULT_OUTPUT_CLOCK_DIVISOR 0x00000002
49475 +#define DEFAULT_BYPASS FALSE
49476 +#define DEFAULT_CLOCK_PERIOD 1000
49477 +
49478 +
49479 +
49480 +typedef struct t_FmRtcAlarm
49481 +{
49482 + t_FmRtcExceptionsCallback *f_AlarmCallback;
49483 + bool clearOnExpiration;
49484 +} t_FmRtcAlarm;
49485 +
49486 +typedef struct t_FmRtcPeriodicPulse
49487 +{
49488 + t_FmRtcExceptionsCallback *f_PeriodicPulseCallback;
49489 +} t_FmRtcPeriodicPulse;
49490 +
49491 +typedef struct t_FmRtcExternalTrigger
49492 +{
49493 + t_FmRtcExceptionsCallback *f_ExternalTriggerCallback;
49494 +} t_FmRtcExternalTrigger;
49495 +
49496 +
49497 +/**************************************************************************//**
49498 + @Description RTC FM driver control structure.
49499 +*//***************************************************************************/
49500 +typedef struct t_FmRtc
49501 +{
49502 + t_Part *p_Part; /**< Pointer to the integration device */
49503 + t_Handle h_Fm;
49504 + t_Handle h_App; /**< Application handle */
49505 + struct rtc_regs *p_MemMap;
49506 + uint32_t clockPeriodNanoSec; /**< RTC clock period in nano-seconds (for FS mode) */
49507 + uint32_t srcClkFreqMhz;
49508 + uint16_t outputClockDivisor; /**< Output clock divisor (for FS mode) */
49509 + t_FmRtcAlarm alarmParams[FM_RTC_NUM_OF_ALARMS];
49510 + t_FmRtcPeriodicPulse periodicPulseParams[FM_RTC_NUM_OF_PERIODIC_PULSES];
49511 + t_FmRtcExternalTrigger externalTriggerParams[FM_RTC_NUM_OF_EXT_TRIGGERS];
49512 + struct rtc_cfg *p_RtcDriverParam; /**< RTC Driver parameters (for Init phase) */
49513 +} t_FmRtc;
49514 +
49515 +
49516 +#endif /* __FM_RTC_H__ */
49517 --- /dev/null
49518 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Rtc/fman_rtc.c
49519 @@ -0,0 +1,334 @@
49520 +/*
49521 + * Copyright 2008-2013 Freescale Semiconductor Inc.
49522 + *
49523 + * Redistribution and use in source and binary forms, with or without
49524 + * modification, are permitted provided that the following conditions are met:
49525 + * * Redistributions of source code must retain the above copyright
49526 + * notice, this list of conditions and the following disclaimer.
49527 + * * Redistributions in binary form must reproduce the above copyright
49528 + * notice, this list of conditions and the following disclaimer in the
49529 + * documentation and/or other materials provided with the distribution.
49530 + * * Neither the name of Freescale Semiconductor nor the
49531 + * names of its contributors may be used to endorse or promote products
49532 + * derived from this software without specific prior written permission.
49533 + *
49534 + *
49535 + * ALTERNATIVELY, this software may be distributed under the terms of the
49536 + * GNU General Public License ("GPL") as published by the Free Software
49537 + * Foundation, either version 2 of that License or (at your option) any
49538 + * later version.
49539 + *
49540 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
49541 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
49542 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
49543 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
49544 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
49545 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49546 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49547 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49548 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
49549 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49550 + */
49551 +
49552 +#include "fsl_fman_rtc.h"
49553 +
49554 +void fman_rtc_defconfig(struct rtc_cfg *cfg)
49555 +{
49556 + int i;
49557 + cfg->src_clk = DEFAULT_SRC_CLOCK;
49558 + cfg->invert_input_clk_phase = DEFAULT_INVERT_INPUT_CLK_PHASE;
49559 + cfg->invert_output_clk_phase = DEFAULT_INVERT_OUTPUT_CLK_PHASE;
49560 + cfg->pulse_realign = DEFAULT_PULSE_REALIGN;
49561 + for (i = 0; i < FMAN_RTC_MAX_NUM_OF_ALARMS; i++)
49562 + cfg->alarm_polarity[i] = DEFAULT_ALARM_POLARITY;
49563 + for (i = 0; i < FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS; i++)
49564 + cfg->trigger_polarity[i] = DEFAULT_TRIGGER_POLARITY;
49565 +}
49566 +
49567 +uint32_t fman_rtc_get_events(struct rtc_regs *regs)
49568 +{
49569 + return ioread32be(&regs->tmr_tevent);
49570 +}
49571 +
49572 +uint32_t fman_rtc_get_event(struct rtc_regs *regs, uint32_t ev_mask)
49573 +{
49574 + return ioread32be(&regs->tmr_tevent) & ev_mask;
49575 +}
49576 +
49577 +uint32_t fman_rtc_get_interrupt_mask(struct rtc_regs *regs)
49578 +{
49579 + return ioread32be(&regs->tmr_temask);
49580 +}
49581 +
49582 +void fman_rtc_set_interrupt_mask(struct rtc_regs *regs, uint32_t mask)
49583 +{
49584 + iowrite32be(mask, &regs->tmr_temask);
49585 +}
49586 +
49587 +void fman_rtc_ack_event(struct rtc_regs *regs, uint32_t events)
49588 +{
49589 + iowrite32be(events, &regs->tmr_tevent);
49590 +}
49591 +
49592 +uint32_t fman_rtc_check_and_clear_event(struct rtc_regs *regs)
49593 +{
49594 + uint32_t event;
49595 +
49596 + event = ioread32be(&regs->tmr_tevent);
49597 + event &= ioread32be(&regs->tmr_temask);
49598 +
49599 + if (event)
49600 + iowrite32be(event, &regs->tmr_tevent);
49601 + return event;
49602 +}
49603 +
49604 +uint32_t fman_rtc_get_frequency_compensation(struct rtc_regs *regs)
49605 +{
49606 + return ioread32be(&regs->tmr_add);
49607 +}
49608 +
49609 +void fman_rtc_set_frequency_compensation(struct rtc_regs *regs, uint32_t val)
49610 +{
49611 + iowrite32be(val, &regs->tmr_add);
49612 +}
49613 +
49614 +void fman_rtc_enable_interupt(struct rtc_regs *regs, uint32_t events)
49615 +{
49616 + fman_rtc_set_interrupt_mask(regs, fman_rtc_get_interrupt_mask(regs) | events);
49617 +}
49618 +
49619 +void fman_rtc_disable_interupt(struct rtc_regs *regs, uint32_t events)
49620 +{
49621 + fman_rtc_set_interrupt_mask(regs, fman_rtc_get_interrupt_mask(regs) & ~events);
49622 +}
49623 +
49624 +void fman_rtc_set_timer_alarm_l(struct rtc_regs *regs, int index, uint32_t val)
49625 +{
49626 + iowrite32be(val, &regs->tmr_alarm[index].tmr_alarm_l);
49627 +}
49628 +
49629 +void fman_rtc_set_timer_fiper(struct rtc_regs *regs, int index, uint32_t val)
49630 +{
49631 + iowrite32be(val, &regs->tmr_fiper[index]);
49632 +}
49633 +
49634 +void fman_rtc_set_timer_alarm(struct rtc_regs *regs, int index, int64_t val)
49635 +{
49636 + iowrite32be((uint32_t)val, &regs->tmr_alarm[index].tmr_alarm_l);
49637 + iowrite32be((uint32_t)(val >> 32), &regs->tmr_alarm[index].tmr_alarm_h);
49638 +}
49639 +
49640 +void fman_rtc_set_timer_offset(struct rtc_regs *regs, int64_t val)
49641 +{
49642 + iowrite32be((uint32_t)val, &regs->tmr_off_l);
49643 + iowrite32be((uint32_t)(val >> 32), &regs->tmr_off_h);
49644 +}
49645 +
49646 +uint64_t fman_rtc_get_trigger_stamp(struct rtc_regs *regs, int id)
49647 +{
49648 + uint64_t time;
49649 + /* TMR_CNT_L must be read first to get an accurate value */
49650 + time = (uint64_t)ioread32be(&regs->tmr_etts[id].tmr_etts_l);
49651 + time |= ((uint64_t)ioread32be(&regs->tmr_etts[id].tmr_etts_h)
49652 + << 32);
49653 +
49654 + return time;
49655 +}
49656 +
49657 +uint32_t fman_rtc_get_timer_ctrl(struct rtc_regs *regs)
49658 +{
49659 + return ioread32be(&regs->tmr_ctrl);
49660 +}
49661 +
49662 +void fman_rtc_set_timer_ctrl(struct rtc_regs *regs, uint32_t val)
49663 +{
49664 + iowrite32be(val, &regs->tmr_ctrl);
49665 +}
49666 +
49667 +void fman_rtc_timers_soft_reset(struct rtc_regs *regs)
49668 +{
49669 + fman_rtc_set_timer_ctrl(regs, FMAN_RTC_TMR_CTRL_TMSR);
49670 + udelay(10);
49671 + fman_rtc_set_timer_ctrl(regs, 0);
49672 +}
49673 +
49674 +void fman_rtc_init(struct rtc_cfg *cfg, struct rtc_regs *regs, int num_alarms,
49675 + int num_fipers, int num_ext_triggers, bool init_freq_comp,
49676 + uint32_t freq_compensation, uint32_t output_clock_divisor)
49677 +{
49678 + uint32_t tmr_ctrl;
49679 + int i;
49680 +
49681 + fman_rtc_timers_soft_reset(regs);
49682 +
49683 + /* Set the source clock */
49684 + switch (cfg->src_clk) {
49685 + case E_FMAN_RTC_SOURCE_CLOCK_SYSTEM:
49686 + tmr_ctrl = FMAN_RTC_TMR_CTRL_CKSEL_MAC_CLK;
49687 + break;
49688 + case E_FMAN_RTC_SOURCE_CLOCK_OSCILATOR:
49689 + tmr_ctrl = FMAN_RTC_TMR_CTRL_CKSEL_OSC_CLK;
49690 + break;
49691 + default:
49692 + /* Use a clock from the External TMR reference clock.*/
49693 + tmr_ctrl = FMAN_RTC_TMR_CTRL_CKSEL_EXT_CLK;
49694 + break;
49695 + }
49696 +
49697 + /* whatever period the user picked, the timestamp will advance in '1'
49698 + * every time the period passed. */
49699 + tmr_ctrl |= ((1 << FMAN_RTC_TMR_CTRL_TCLK_PERIOD_SHIFT) &
49700 + FMAN_RTC_TMR_CTRL_TCLK_PERIOD_MASK);
49701 +
49702 + if (cfg->invert_input_clk_phase)
49703 + tmr_ctrl |= FMAN_RTC_TMR_CTRL_CIPH;
49704 + if (cfg->invert_output_clk_phase)
49705 + tmr_ctrl |= FMAN_RTC_TMR_CTRL_COPH;
49706 +
49707 + for (i = 0; i < num_alarms; i++) {
49708 + if (cfg->alarm_polarity[i] ==
49709 + E_FMAN_RTC_ALARM_POLARITY_ACTIVE_LOW)
49710 + tmr_ctrl |= (FMAN_RTC_TMR_CTRL_ALMP1 >> i);
49711 + }
49712 +
49713 + for (i = 0; i < num_ext_triggers; i++)
49714 + if (cfg->trigger_polarity[i] ==
49715 + E_FMAN_RTC_TRIGGER_ON_FALLING_EDGE)
49716 + tmr_ctrl |= (FMAN_RTC_TMR_CTRL_ETEP1 << i);
49717 +
49718 + if (!cfg->timer_slave_mode && cfg->bypass)
49719 + tmr_ctrl |= FMAN_RTC_TMR_CTRL_BYP;
49720 +
49721 + fman_rtc_set_timer_ctrl(regs, tmr_ctrl);
49722 + if (init_freq_comp)
49723 + fman_rtc_set_frequency_compensation(regs, freq_compensation);
49724 +
49725 + /* Clear TMR_ALARM registers */
49726 + for (i = 0; i < num_alarms; i++)
49727 + fman_rtc_set_timer_alarm(regs, i, 0xFFFFFFFFFFFFFFFFLL);
49728 +
49729 + /* Clear TMR_TEVENT */
49730 + fman_rtc_ack_event(regs, FMAN_RTC_TMR_TEVENT_ALL);
49731 +
49732 + /* Initialize TMR_TEMASK */
49733 + fman_rtc_set_interrupt_mask(regs, 0);
49734 +
49735 + /* Clear TMR_FIPER registers */
49736 + for (i = 0; i < num_fipers; i++)
49737 + fman_rtc_set_timer_fiper(regs, i, 0xFFFFFFFF);
49738 +
49739 + /* Initialize TMR_PRSC */
49740 + iowrite32be(output_clock_divisor, &regs->tmr_prsc);
49741 +
49742 + /* Clear TMR_OFF */
49743 + fman_rtc_set_timer_offset(regs, 0);
49744 +}
49745 +
49746 +bool fman_rtc_is_enabled(struct rtc_regs *regs)
49747 +{
49748 + return (bool)(fman_rtc_get_timer_ctrl(regs) & FMAN_RTC_TMR_CTRL_TE);
49749 +}
49750 +
49751 +void fman_rtc_enable(struct rtc_regs *regs, bool reset_clock)
49752 +{
49753 + uint32_t tmr_ctrl = fman_rtc_get_timer_ctrl(regs);
49754 +
49755 + /* TODO check that no timestamping MACs are working in this stage. */
49756 + if (reset_clock) {
49757 + fman_rtc_set_timer_ctrl(regs, (tmr_ctrl | FMAN_RTC_TMR_CTRL_TMSR));
49758 +
49759 + udelay(10);
49760 + /* Clear TMR_OFF */
49761 + fman_rtc_set_timer_offset(regs, 0);
49762 + }
49763 +
49764 + fman_rtc_set_timer_ctrl(regs, (tmr_ctrl | FMAN_RTC_TMR_CTRL_TE));
49765 +}
49766 +
49767 +void fman_rtc_disable(struct rtc_regs *regs)
49768 +{
49769 + fman_rtc_set_timer_ctrl(regs, (fman_rtc_get_timer_ctrl(regs)
49770 + & ~(FMAN_RTC_TMR_CTRL_TE)));
49771 +}
49772 +
49773 +void fman_rtc_clear_periodic_pulse(struct rtc_regs *regs, int id)
49774 +{
49775 + uint32_t tmp_reg;
49776 + if (id == 0)
49777 + tmp_reg = FMAN_RTC_TMR_TEVENT_PP1;
49778 + else
49779 + tmp_reg = FMAN_RTC_TMR_TEVENT_PP2;
49780 + fman_rtc_disable_interupt(regs, tmp_reg);
49781 +
49782 + tmp_reg = fman_rtc_get_timer_ctrl(regs);
49783 + if (tmp_reg & FMAN_RTC_TMR_CTRL_FS)
49784 + fman_rtc_set_timer_ctrl(regs, tmp_reg & ~FMAN_RTC_TMR_CTRL_FS);
49785 +
49786 + fman_rtc_set_timer_fiper(regs, id, 0xFFFFFFFF);
49787 +}
49788 +
49789 +void fman_rtc_clear_external_trigger(struct rtc_regs *regs, int id)
49790 +{
49791 + uint32_t tmpReg, tmp_ctrl;
49792 +
49793 + if (id == 0)
49794 + tmpReg = FMAN_RTC_TMR_TEVENT_ETS1;
49795 + else
49796 + tmpReg = FMAN_RTC_TMR_TEVENT_ETS2;
49797 + fman_rtc_disable_interupt(regs, tmpReg);
49798 +
49799 + if (id == 0)
49800 + tmpReg = FMAN_RTC_TMR_CTRL_PP1L;
49801 + else
49802 + tmpReg = FMAN_RTC_TMR_CTRL_PP2L;
49803 + tmp_ctrl = fman_rtc_get_timer_ctrl(regs);
49804 + if (tmp_ctrl & tmpReg)
49805 + fman_rtc_set_timer_ctrl(regs, tmp_ctrl & ~tmpReg);
49806 +}
49807 +
49808 +void fman_rtc_set_alarm(struct rtc_regs *regs, int id, uint32_t val, bool enable)
49809 +{
49810 + uint32_t tmpReg;
49811 + fman_rtc_set_timer_alarm(regs, id, val);
49812 + if (enable) {
49813 + if (id == 0)
49814 + tmpReg = FMAN_RTC_TMR_TEVENT_ALM1;
49815 + else
49816 + tmpReg = FMAN_RTC_TMR_TEVENT_ALM2;
49817 + fman_rtc_enable_interupt(regs, tmpReg);
49818 + }
49819 +}
49820 +
49821 +void fman_rtc_set_periodic_pulse(struct rtc_regs *regs, int id, uint32_t val,
49822 + bool enable)
49823 +{
49824 + uint32_t tmpReg;
49825 + fman_rtc_set_timer_fiper(regs, id, val);
49826 + if (enable) {
49827 + if (id == 0)
49828 + tmpReg = FMAN_RTC_TMR_TEVENT_PP1;
49829 + else
49830 + tmpReg = FMAN_RTC_TMR_TEVENT_PP2;
49831 + fman_rtc_enable_interupt(regs, tmpReg);
49832 + }
49833 +}
49834 +
49835 +void fman_rtc_set_ext_trigger(struct rtc_regs *regs, int id, bool enable,
49836 + bool use_pulse_as_input)
49837 +{
49838 + uint32_t tmpReg;
49839 + if (enable) {
49840 + if (id == 0)
49841 + tmpReg = FMAN_RTC_TMR_TEVENT_ETS1;
49842 + else
49843 + tmpReg = FMAN_RTC_TMR_TEVENT_ETS2;
49844 + fman_rtc_enable_interupt(regs, tmpReg);
49845 + }
49846 + if (use_pulse_as_input) {
49847 + if (id == 0)
49848 + tmpReg = FMAN_RTC_TMR_CTRL_PP1L;
49849 + else
49850 + tmpReg = FMAN_RTC_TMR_CTRL_PP2L;
49851 + fman_rtc_set_timer_ctrl(regs, fman_rtc_get_timer_ctrl(regs) | tmpReg);
49852 + }
49853 +}
49854 --- /dev/null
49855 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/SP/Makefile
49856 @@ -0,0 +1,15 @@
49857 +#
49858 +# Makefile for the Freescale Ethernet controllers
49859 +#
49860 +ccflags-y += -DVERSION=\"\"
49861 +#
49862 +#Include netcomm SW specific definitions
49863 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
49864 +
49865 +NCSW_FM_INC = $(srctree)/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc
49866 +
49867 +ccflags-y += -I$(NCSW_FM_INC)
49868 +
49869 +obj-y += fsl-ncsw-sp.o
49870 +
49871 +fsl-ncsw-sp-objs := fm_sp.o fman_sp.o
49872 --- /dev/null
49873 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/SP/fm_sp.c
49874 @@ -0,0 +1,757 @@
49875 +/*
49876 + * Copyright 2008-2012 Freescale Semiconductor Inc.
49877 + *
49878 + * Redistribution and use in source and binary forms, with or without
49879 + * modification, are permitted provided that the following conditions are met:
49880 + * * Redistributions of source code must retain the above copyright
49881 + * notice, this list of conditions and the following disclaimer.
49882 + * * Redistributions in binary form must reproduce the above copyright
49883 + * notice, this list of conditions and the following disclaimer in the
49884 + * documentation and/or other materials provided with the distribution.
49885 + * * Neither the name of Freescale Semiconductor nor the
49886 + * names of its contributors may be used to endorse or promote products
49887 + * derived from this software without specific prior written permission.
49888 + *
49889 + *
49890 + * ALTERNATIVELY, this software may be distributed under the terms of the
49891 + * GNU General Public License ("GPL") as published by the Free Software
49892 + * Foundation, either version 2 of that License or (at your option) any
49893 + * later version.
49894 + *
49895 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
49896 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
49897 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
49898 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
49899 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
49900 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49901 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49902 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49903 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
49904 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49905 + */
49906 +
49907 +
49908 +/******************************************************************************
49909 + @File fm_sp.c
49910 +
49911 + @Description FM PCD Storage profile ...
49912 +*//***************************************************************************/
49913 +
49914 +#include "std_ext.h"
49915 +#include "error_ext.h"
49916 +#include "string_ext.h"
49917 +#include "debug_ext.h"
49918 +#include "net_ext.h"
49919 +
49920 +#include "fm_vsp_ext.h"
49921 +#include "fm_sp.h"
49922 +#include "fm_common.h"
49923 +#include "fsl_fman_sp.h"
49924 +
49925 +
49926 +#if (DPAA_VERSION >= 11)
49927 +static t_Error CheckParamsGeneratedInternally(t_FmVspEntry *p_FmVspEntry)
49928 +{
49929 + t_Error err = E_OK;
49930 +
49931 + if ((err = FmSpCheckIntContextParams(&p_FmVspEntry->intContext))!= E_OK)
49932 + RETURN_ERROR(MAJOR, err, NO_MSG);
49933 + if ((err = FmSpCheckBufMargins(&p_FmVspEntry->bufMargins)) != E_OK)
49934 + RETURN_ERROR(MAJOR, err, NO_MSG);
49935 + return err;
49936 +
49937 +}
49938 +
49939 +static t_Error CheckParams(t_FmVspEntry *p_FmVspEntry)
49940 +{
49941 + t_Error err = E_OK;
49942 +
49943 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
49944 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
49945 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->h_Fm, E_INVALID_HANDLE);
49946 +
49947 + if ((err = FmSpCheckBufPoolsParams(&p_FmVspEntry->p_FmVspEntryDriverParams->extBufPools,
49948 + p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools,
49949 + p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion)) != E_OK)
49950 +
49951 + RETURN_ERROR(MAJOR, err, NO_MSG);
49952 +
49953 + if (p_FmVspEntry->p_FmVspEntryDriverParams->liodnOffset & ~FM_LIODN_OFFSET_MASK)
49954 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("liodnOffset is larger than %d", FM_LIODN_OFFSET_MASK+1));
49955 +
49956 + err = FmVSPCheckRelativeProfile(p_FmVspEntry->h_Fm,
49957 + p_FmVspEntry->portType,
49958 + p_FmVspEntry->portId,
49959 + p_FmVspEntry->relativeProfileId);
49960 +
49961 + return err;
49962 +}
49963 +#endif /* (DPAA_VERSION >= 11) */
49964 +
49965 +
49966 +/*****************************************************************************/
49967 +/* Inter-module API routines */
49968 +/*****************************************************************************/
49969 +void FmSpSetBufPoolsInAscOrderOfBufSizes(t_FmExtPools *p_FmExtPools,
49970 + uint8_t *orderedArray,
49971 + uint16_t *sizesArray)
49972 +{
49973 + uint16_t bufSize = 0;
49974 + int i=0, j=0, k=0;
49975 +
49976 + /* First we copy the external buffers pools information to an ordered local array */
49977 + for (i=0;i<p_FmExtPools->numOfPoolsUsed;i++)
49978 + {
49979 + /* get pool size */
49980 + bufSize = p_FmExtPools->extBufPool[i].size;
49981 +
49982 + /* keep sizes in an array according to poolId for direct access */
49983 + sizesArray[p_FmExtPools->extBufPool[i].id] = bufSize;
49984 +
49985 + /* save poolId in an ordered array according to size */
49986 + for (j=0;j<=i;j++)
49987 + {
49988 + /* this is the next free place in the array */
49989 + if (j==i)
49990 + orderedArray[i] = p_FmExtPools->extBufPool[i].id;
49991 + else
49992 + {
49993 + /* find the right place for this poolId */
49994 + if (bufSize < sizesArray[orderedArray[j]])
49995 + {
49996 + /* move the poolIds one place ahead to make room for this poolId */
49997 + for (k=i;k>j;k--)
49998 + orderedArray[k] = orderedArray[k-1];
49999 +
50000 + /* now k==j, this is the place for the new size */
50001 + orderedArray[k] = p_FmExtPools->extBufPool[i].id;
50002 + break;
50003 + }
50004 + }
50005 + }
50006 + }
50007 +}
50008 +
50009 +t_Error FmSpCheckBufPoolsParams(t_FmExtPools *p_FmExtPools,
50010 + t_FmBackupBmPools *p_FmBackupBmPools,
50011 + t_FmBufPoolDepletion *p_FmBufPoolDepletion)
50012 +{
50013 +
50014 + int i = 0, j = 0;
50015 + bool found;
50016 + uint8_t count = 0;
50017 +
50018 + if (p_FmExtPools)
50019 + {
50020 + if (p_FmExtPools->numOfPoolsUsed > FM_PORT_MAX_NUM_OF_EXT_POOLS)
50021 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfPoolsUsed can't be larger than %d", FM_PORT_MAX_NUM_OF_EXT_POOLS));
50022 +
50023 + for (i=0;i<p_FmExtPools->numOfPoolsUsed;i++)
50024 + {
50025 + if (p_FmExtPools->extBufPool[i].id >= BM_MAX_NUM_OF_POOLS)
50026 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("extBufPools.extBufPool[%d].id can't be larger than %d", i, BM_MAX_NUM_OF_POOLS));
50027 + if (!p_FmExtPools->extBufPool[i].size)
50028 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("extBufPools.extBufPool[%d].size is 0", i));
50029 + }
50030 + }
50031 + if (!p_FmExtPools && (p_FmBackupBmPools || p_FmBufPoolDepletion))
50032 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("backupBmPools ot bufPoolDepletion can not be defined without external pools"));
50033 +
50034 + /* backup BM pools indication is valid only for some chip derivatives
50035 + (limited by the config routine) */
50036 + if (p_FmBackupBmPools)
50037 + {
50038 + if (p_FmBackupBmPools->numOfBackupPools >= p_FmExtPools->numOfPoolsUsed)
50039 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("p_BackupBmPools must be smaller than extBufPools.numOfPoolsUsed"));
50040 + found = FALSE;
50041 + for (i = 0;i<p_FmBackupBmPools->numOfBackupPools;i++)
50042 + {
50043 +
50044 + for (j=0;j<p_FmExtPools->numOfPoolsUsed;j++)
50045 + {
50046 + if (p_FmBackupBmPools->poolIds[i] == p_FmExtPools->extBufPool[j].id)
50047 + {
50048 + found = TRUE;
50049 + break;
50050 + }
50051 + }
50052 + if (!found)
50053 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("All p_BackupBmPools.poolIds must be included in extBufPools.extBufPool[n].id"));
50054 + else
50055 + found = FALSE;
50056 + }
50057 + }
50058 +
50059 + /* up to extBufPools.numOfPoolsUsed pools may be defined */
50060 + if (p_FmBufPoolDepletion && p_FmBufPoolDepletion->poolsGrpModeEnable)
50061 + {
50062 + if ((p_FmBufPoolDepletion->numOfPools > p_FmExtPools->numOfPoolsUsed))
50063 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufPoolDepletion.numOfPools can't be larger than %d and can't be larger than numOfPoolsUsed", FM_PORT_MAX_NUM_OF_EXT_POOLS));
50064 +
50065 + if (!p_FmBufPoolDepletion->numOfPools)
50066 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufPoolDepletion.numOfPoolsToConsider can not be 0 when poolsGrpModeEnable=TRUE"));
50067 +
50068 + found = FALSE;
50069 + count = 0;
50070 + /* for each pool that is in poolsToConsider, check if it is defined
50071 + in extBufPool */
50072 + for (i=0;i<BM_MAX_NUM_OF_POOLS;i++)
50073 + {
50074 + if (p_FmBufPoolDepletion->poolsToConsider[i])
50075 + {
50076 + for (j=0;j<p_FmExtPools->numOfPoolsUsed;j++)
50077 + {
50078 + if (i == p_FmExtPools->extBufPool[j].id)
50079 + {
50080 + found = TRUE;
50081 + count++;
50082 + break;
50083 + }
50084 + }
50085 + if (!found)
50086 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Pools selected for depletion are not used."));
50087 + else
50088 + found = FALSE;
50089 + }
50090 + }
50091 + /* check that the number of pools that we have checked is equal to the number announced by the user */
50092 + if (count != p_FmBufPoolDepletion->numOfPools)
50093 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufPoolDepletion.numOfPools is larger than the number of pools defined."));
50094 + }
50095 +
50096 + if (p_FmBufPoolDepletion && p_FmBufPoolDepletion->singlePoolModeEnable)
50097 + {
50098 + /* calculate vector for number of pools depletion */
50099 + found = FALSE;
50100 + count = 0;
50101 + for (i=0;i<BM_MAX_NUM_OF_POOLS;i++)
50102 + {
50103 + if (p_FmBufPoolDepletion->poolsToConsiderForSingleMode[i])
50104 + {
50105 + for (j=0;j<p_FmExtPools->numOfPoolsUsed;j++)
50106 + {
50107 + if (i == p_FmExtPools->extBufPool[j].id)
50108 + {
50109 + found = TRUE;
50110 + count++;
50111 + break;
50112 + }
50113 + }
50114 + if (!found)
50115 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Pools selected for depletion are not used."));
50116 + else
50117 + found = FALSE;
50118 + }
50119 + }
50120 + if (!count)
50121 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("No pools defined for single buffer mode pool depletion."));
50122 + }
50123 +
50124 + return E_OK;
50125 +}
50126 +
50127 +t_Error FmSpCheckIntContextParams(t_FmSpIntContextDataCopy *p_FmSpIntContextDataCopy)
50128 +{
50129 + /* Check that divisible by 16 and not larger than 240 */
50130 + if (p_FmSpIntContextDataCopy->intContextOffset >MAX_INT_OFFSET)
50131 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.intContextOffset can't be larger than %d", MAX_INT_OFFSET));
50132 + if (p_FmSpIntContextDataCopy->intContextOffset % OFFSET_UNITS)
50133 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.intContextOffset has to be divisible by %d", OFFSET_UNITS));
50134 +
50135 + /* check that ic size+ic internal offset, does not exceed ic block size */
50136 + if (p_FmSpIntContextDataCopy->size + p_FmSpIntContextDataCopy->intContextOffset > MAX_IC_SIZE)
50137 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.size + intContext.intContextOffset has to be smaller than %d", MAX_IC_SIZE));
50138 + /* Check that divisible by 16 and not larger than 256 */
50139 + if (p_FmSpIntContextDataCopy->size % OFFSET_UNITS)
50140 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.size has to be divisible by %d", OFFSET_UNITS));
50141 +
50142 + /* Check that divisible by 16 and not larger than 4K */
50143 + if (p_FmSpIntContextDataCopy->extBufOffset > MAX_EXT_OFFSET)
50144 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.extBufOffset can't be larger than %d", MAX_EXT_OFFSET));
50145 + if (p_FmSpIntContextDataCopy->extBufOffset % OFFSET_UNITS)
50146 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.extBufOffset has to be divisible by %d", OFFSET_UNITS));
50147 +
50148 + return E_OK;
50149 +}
50150 +
50151 +t_Error FmSpCheckBufMargins(t_FmSpBufMargins *p_FmSpBufMargins)
50152 +{
50153 + /* Check the margin definition */
50154 + if (p_FmSpBufMargins->startMargins > MAX_EXT_BUFFER_OFFSET)
50155 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufMargins.startMargins can't be larger than %d", MAX_EXT_BUFFER_OFFSET));
50156 + if (p_FmSpBufMargins->endMargins > MAX_EXT_BUFFER_OFFSET)
50157 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufMargins.endMargins can't be larger than %d", MAX_EXT_BUFFER_OFFSET));
50158 +
50159 + return E_OK;
50160 +}
50161 +
50162 +t_Error FmSpBuildBufferStructure(t_FmSpIntContextDataCopy *p_FmSpIntContextDataCopy,
50163 + t_FmBufferPrefixContent *p_BufferPrefixContent,
50164 + t_FmSpBufMargins *p_FmSpBufMargins,
50165 + t_FmSpBufferOffsets *p_FmSpBufferOffsets,
50166 + uint8_t *internalBufferOffset)
50167 +{
50168 + uint32_t tmp;
50169 +
50170 + SANITY_CHECK_RETURN_ERROR(p_FmSpIntContextDataCopy, E_INVALID_VALUE);
50171 + ASSERT_COND(p_FmSpIntContextDataCopy);
50172 + ASSERT_COND(p_BufferPrefixContent);
50173 + ASSERT_COND(p_FmSpBufMargins);
50174 + ASSERT_COND(p_FmSpBufferOffsets);
50175 +
50176 + /* Align start of internal context data to 16 byte */
50177 + p_FmSpIntContextDataCopy->extBufOffset =
50178 + (uint16_t)((p_BufferPrefixContent->privDataSize & (OFFSET_UNITS-1)) ?
50179 + ((p_BufferPrefixContent->privDataSize + OFFSET_UNITS) & ~(uint16_t)(OFFSET_UNITS-1)) :
50180 + p_BufferPrefixContent->privDataSize);
50181 +
50182 + /* Translate margin and intContext params to FM parameters */
50183 + /* Initialize with illegal value. Later we'll set legal values. */
50184 + p_FmSpBufferOffsets->prsResultOffset = (uint32_t)ILLEGAL_BASE;
50185 + p_FmSpBufferOffsets->timeStampOffset = (uint32_t)ILLEGAL_BASE;
50186 + p_FmSpBufferOffsets->hashResultOffset= (uint32_t)ILLEGAL_BASE;
50187 + p_FmSpBufferOffsets->pcdInfoOffset = (uint32_t)ILLEGAL_BASE;
50188 +
50189 + /* Internally the driver supports 4 options
50190 + 1. prsResult/timestamp/hashResult selection (in fact 8 options, but for simplicity we'll
50191 + relate to it as 1).
50192 + 2. All IC context (from AD) not including debug.*/
50193 +
50194 + /* This 'if' covers option 2. We copy from beginning of context. */
50195 + if (p_BufferPrefixContent->passAllOtherPCDInfo)
50196 + {
50197 + p_FmSpIntContextDataCopy->size = 128; /* must be aligned to 16 */
50198 + /* Start copying data after 16 bytes (FD) from the beginning of the internal context */
50199 + p_FmSpIntContextDataCopy->intContextOffset = 16;
50200 +
50201 + if (p_BufferPrefixContent->passAllOtherPCDInfo)
50202 + p_FmSpBufferOffsets->pcdInfoOffset = p_FmSpIntContextDataCopy->extBufOffset;
50203 + if (p_BufferPrefixContent->passPrsResult)
50204 + p_FmSpBufferOffsets->prsResultOffset =
50205 + (uint32_t)(p_FmSpIntContextDataCopy->extBufOffset + 16);
50206 + if (p_BufferPrefixContent->passTimeStamp)
50207 + p_FmSpBufferOffsets->timeStampOffset =
50208 + (uint32_t)(p_FmSpIntContextDataCopy->extBufOffset + 48);
50209 + if (p_BufferPrefixContent->passHashResult)
50210 + p_FmSpBufferOffsets->hashResultOffset =
50211 + (uint32_t)(p_FmSpIntContextDataCopy->extBufOffset + 56);
50212 + }
50213 + else
50214 + {
50215 + /* This case covers the options under 1 */
50216 + /* Copy size must be in 16-byte granularity. */
50217 + p_FmSpIntContextDataCopy->size =
50218 + (uint16_t)((p_BufferPrefixContent->passPrsResult ? 32 : 0) +
50219 + ((p_BufferPrefixContent->passTimeStamp ||
50220 + p_BufferPrefixContent->passHashResult) ? 16 : 0));
50221 +
50222 + /* Align start of internal context data to 16 byte */
50223 + p_FmSpIntContextDataCopy->intContextOffset =
50224 + (uint8_t)(p_BufferPrefixContent->passPrsResult ? 32 :
50225 + ((p_BufferPrefixContent->passTimeStamp ||
50226 + p_BufferPrefixContent->passHashResult) ? 64 : 0));
50227 +
50228 + if (p_BufferPrefixContent->passPrsResult)
50229 + p_FmSpBufferOffsets->prsResultOffset = p_FmSpIntContextDataCopy->extBufOffset;
50230 + if (p_BufferPrefixContent->passTimeStamp)
50231 + p_FmSpBufferOffsets->timeStampOffset = p_BufferPrefixContent->passPrsResult ?
50232 + (p_FmSpIntContextDataCopy->extBufOffset + sizeof(t_FmPrsResult)) :
50233 + p_FmSpIntContextDataCopy->extBufOffset;
50234 + if (p_BufferPrefixContent->passHashResult)
50235 + /* If PR is not requested, whether TS is requested or not, IC will be copied from TS */
50236 + p_FmSpBufferOffsets->hashResultOffset = p_BufferPrefixContent->passPrsResult ?
50237 + (p_FmSpIntContextDataCopy->extBufOffset + sizeof(t_FmPrsResult) + 8) :
50238 + p_FmSpIntContextDataCopy->extBufOffset + 8;
50239 + }
50240 +
50241 + if (p_FmSpIntContextDataCopy->size)
50242 + p_FmSpBufMargins->startMargins =
50243 + (uint16_t)(p_FmSpIntContextDataCopy->extBufOffset +
50244 + p_FmSpIntContextDataCopy->size);
50245 + else
50246 + /* No Internal Context passing, STartMargin is immediately after privateInfo */
50247 + p_FmSpBufMargins->startMargins = p_BufferPrefixContent->privDataSize;
50248 +
50249 + /* save extra space for manip in both external and internal buffers */
50250 + if (p_BufferPrefixContent->manipExtraSpace)
50251 + {
50252 + uint8_t extraSpace;
50253 +#ifdef FM_CAPWAP_SUPPORT
50254 + if ((p_BufferPrefixContent->manipExtraSpace + CAPWAP_FRAG_EXTRA_SPACE) >= 256)
50255 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
50256 + ("p_BufferPrefixContent->manipExtraSpace should be less than %d",
50257 + 256-CAPWAP_FRAG_EXTRA_SPACE));
50258 + extraSpace = (uint8_t)(p_BufferPrefixContent->manipExtraSpace + CAPWAP_FRAG_EXTRA_SPACE);
50259 +#else
50260 + extraSpace = p_BufferPrefixContent->manipExtraSpace;
50261 +#endif /* FM_CAPWAP_SUPPORT */
50262 + p_FmSpBufferOffsets->manipOffset = p_FmSpBufMargins->startMargins;
50263 + p_FmSpBufMargins->startMargins += extraSpace;
50264 + *internalBufferOffset = extraSpace;
50265 + }
50266 +
50267 + /* align data start */
50268 + tmp = (uint32_t)(p_FmSpBufMargins->startMargins % p_BufferPrefixContent->dataAlign);
50269 + if (tmp)
50270 + p_FmSpBufMargins->startMargins += (p_BufferPrefixContent->dataAlign-tmp);
50271 + p_FmSpBufferOffsets->dataOffset = p_FmSpBufMargins->startMargins;
50272 +
50273 + return E_OK;
50274 +}
50275 +/*********************** End of inter-module routines ************************/
50276 +
50277 +
50278 +#if (DPAA_VERSION >= 11)
50279 +/*****************************************************************************/
50280 +/* API routines */
50281 +/*****************************************************************************/
50282 +t_Handle FM_VSP_Config(t_FmVspParams *p_FmVspParams)
50283 +{
50284 + t_FmVspEntry *p_FmVspEntry = NULL;
50285 + struct fm_storage_profile_params fm_vsp_params;
50286 +
50287 + p_FmVspEntry = (t_FmVspEntry *)XX_Malloc(sizeof(t_FmVspEntry));
50288 + if (!p_FmVspEntry)
50289 + {
50290 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_StorageProfile allocation failed"));
50291 + return NULL;
50292 + }
50293 + memset(p_FmVspEntry, 0, sizeof(t_FmVspEntry));
50294 +
50295 + p_FmVspEntry->p_FmVspEntryDriverParams = (t_FmVspEntryDriverParams *)XX_Malloc(sizeof(t_FmVspEntryDriverParams));
50296 + if (!p_FmVspEntry->p_FmVspEntryDriverParams)
50297 + {
50298 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_StorageProfile allocation failed"));
50299 + XX_Free(p_FmVspEntry);
50300 + return NULL;
50301 + }
50302 + memset(p_FmVspEntry->p_FmVspEntryDriverParams, 0, sizeof(t_FmVspEntryDriverParams));
50303 + fman_vsp_defconfig(&fm_vsp_params);
50304 + p_FmVspEntry->p_FmVspEntryDriverParams->dmaHeaderCacheAttr = fm_vsp_params.header_cache_attr;
50305 + p_FmVspEntry->p_FmVspEntryDriverParams->dmaIntContextCacheAttr = fm_vsp_params.int_context_cache_attr;
50306 + p_FmVspEntry->p_FmVspEntryDriverParams->dmaScatterGatherCacheAttr = fm_vsp_params.scatter_gather_cache_attr;
50307 + p_FmVspEntry->p_FmVspEntryDriverParams->dmaSwapData = fm_vsp_params.dma_swap_data;
50308 + p_FmVspEntry->p_FmVspEntryDriverParams->dmaWriteOptimize = fm_vsp_params.dma_write_optimize;
50309 + p_FmVspEntry->p_FmVspEntryDriverParams->noScatherGather = fm_vsp_params.no_scather_gather;
50310 + p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.privDataSize = DEFAULT_FM_SP_bufferPrefixContent_privDataSize;
50311 + p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.passPrsResult= DEFAULT_FM_SP_bufferPrefixContent_passPrsResult;
50312 + p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.passTimeStamp= DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp;
50313 + p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.passAllOtherPCDInfo
50314 + = DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp;
50315 + p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.dataAlign = DEFAULT_FM_SP_bufferPrefixContent_dataAlign;
50316 + p_FmVspEntry->p_FmVspEntryDriverParams->liodnOffset = p_FmVspParams->liodnOffset;
50317 +
50318 + memcpy(&p_FmVspEntry->p_FmVspEntryDriverParams->extBufPools, &p_FmVspParams->extBufPools, sizeof(t_FmExtPools));
50319 + p_FmVspEntry->h_Fm = p_FmVspParams->h_Fm;
50320 + p_FmVspEntry->portType = p_FmVspParams->portParams.portType;
50321 + p_FmVspEntry->portId = p_FmVspParams->portParams.portId;
50322 +
50323 + p_FmVspEntry->relativeProfileId = p_FmVspParams->relativeProfileId;
50324 +
50325 + return p_FmVspEntry;
50326 +}
50327 +
50328 +t_Error FM_VSP_Init(t_Handle h_FmVsp)
50329 +{
50330 +
50331 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry *)h_FmVsp;
50332 + struct fm_storage_profile_params fm_vsp_params;
50333 + uint8_t orderedArray[FM_PORT_MAX_NUM_OF_EXT_POOLS];
50334 + uint16_t sizesArray[BM_MAX_NUM_OF_POOLS];
50335 + t_Error err;
50336 + uint16_t absoluteProfileId = 0;
50337 + int i = 0;
50338 +
50339 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
50340 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams,E_INVALID_HANDLE);
50341 +
50342 + CHECK_INIT_PARAMETERS(p_FmVspEntry, CheckParams);
50343 +
50344 + memset(&orderedArray, 0, sizeof(uint8_t) * FM_PORT_MAX_NUM_OF_EXT_POOLS);
50345 + memset(&sizesArray, 0, sizeof(uint16_t) * BM_MAX_NUM_OF_POOLS);
50346 +
50347 + err = FmSpBuildBufferStructure(&p_FmVspEntry->intContext,
50348 + &p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent,
50349 + &p_FmVspEntry->bufMargins,
50350 + &p_FmVspEntry->bufferOffsets,
50351 + &p_FmVspEntry->internalBufferOffset);
50352 + if (err != E_OK)
50353 + RETURN_ERROR(MAJOR, err, NO_MSG);
50354 +
50355 +
50356 + err = CheckParamsGeneratedInternally(p_FmVspEntry);
50357 + if (err != E_OK)
50358 + RETURN_ERROR(MAJOR, err, NO_MSG);
50359 +
50360 +
50361 + p_FmVspEntry->p_FmSpRegsBase =
50362 + (struct fm_pcd_storage_profile_regs *)FmGetVSPBaseAddr(p_FmVspEntry->h_Fm);
50363 + if (!p_FmVspEntry->p_FmSpRegsBase)
50364 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("impossible to initialize SpRegsBase"));
50365 +
50366 + /* order external buffer pools in ascending order of buffer pools sizes */
50367 + FmSpSetBufPoolsInAscOrderOfBufSizes(&(p_FmVspEntry->p_FmVspEntryDriverParams)->extBufPools,
50368 + orderedArray,
50369 + sizesArray);
50370 +
50371 + p_FmVspEntry->extBufPools.numOfPoolsUsed =
50372 + p_FmVspEntry->p_FmVspEntryDriverParams->extBufPools.numOfPoolsUsed;
50373 + for (i = 0; i < p_FmVspEntry->extBufPools.numOfPoolsUsed; i++)
50374 + {
50375 + p_FmVspEntry->extBufPools.extBufPool[i].id = orderedArray[i];
50376 + p_FmVspEntry->extBufPools.extBufPool[i].size = sizesArray[orderedArray[i]];
50377 + }
50378 +
50379 + /* on user responsibility to fill it according requirement */
50380 + memset(&fm_vsp_params, 0, sizeof(struct fm_storage_profile_params));
50381 + fm_vsp_params.dma_swap_data = p_FmVspEntry->p_FmVspEntryDriverParams->dmaSwapData;
50382 + fm_vsp_params.int_context_cache_attr = p_FmVspEntry->p_FmVspEntryDriverParams->dmaIntContextCacheAttr;
50383 + fm_vsp_params.header_cache_attr = p_FmVspEntry->p_FmVspEntryDriverParams->dmaHeaderCacheAttr;
50384 + fm_vsp_params.scatter_gather_cache_attr = p_FmVspEntry->p_FmVspEntryDriverParams->dmaScatterGatherCacheAttr;
50385 + fm_vsp_params.dma_write_optimize = p_FmVspEntry->p_FmVspEntryDriverParams->dmaWriteOptimize;
50386 + fm_vsp_params.liodn_offset = p_FmVspEntry->p_FmVspEntryDriverParams->liodnOffset;
50387 + fm_vsp_params.no_scather_gather = p_FmVspEntry->p_FmVspEntryDriverParams->noScatherGather;
50388 +
50389 + if (p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion)
50390 + {
50391 + fm_vsp_params.buf_pool_depletion.buf_pool_depletion_enabled = TRUE;
50392 + fm_vsp_params.buf_pool_depletion.pools_grp_mode_enable = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->poolsGrpModeEnable;
50393 + fm_vsp_params.buf_pool_depletion.num_pools = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->numOfPools;
50394 + fm_vsp_params.buf_pool_depletion.pools_to_consider = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->poolsToConsider;
50395 + fm_vsp_params.buf_pool_depletion.single_pool_mode_enable = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->singlePoolModeEnable;
50396 + fm_vsp_params.buf_pool_depletion.pools_to_consider_for_single_mode = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->poolsToConsiderForSingleMode;
50397 + fm_vsp_params.buf_pool_depletion.has_pfc_priorities = TRUE;
50398 + fm_vsp_params.buf_pool_depletion.pfc_priorities_en = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->pfcPrioritiesEn;
50399 + }
50400 + else
50401 + fm_vsp_params.buf_pool_depletion.buf_pool_depletion_enabled = FALSE;
50402 +
50403 + if (p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools)
50404 + {
50405 + fm_vsp_params.backup_pools.num_backup_pools = p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools->numOfBackupPools;
50406 + fm_vsp_params.backup_pools.pool_ids = p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools->poolIds;
50407 + }
50408 + else
50409 + fm_vsp_params.backup_pools.num_backup_pools = 0;
50410 +
50411 + fm_vsp_params.fm_ext_pools.num_pools_used = p_FmVspEntry->extBufPools.numOfPoolsUsed;
50412 + fm_vsp_params.fm_ext_pools.ext_buf_pool = (struct fman_ext_pool_params*)&p_FmVspEntry->extBufPools.extBufPool;
50413 + fm_vsp_params.buf_margins = (struct fman_sp_buf_margins*)&p_FmVspEntry->bufMargins;
50414 + fm_vsp_params.int_context = (struct fman_sp_int_context_data_copy*)&p_FmVspEntry->intContext;
50415 +
50416 + /* no check on err - it was checked earlier */
50417 + FmVSPGetAbsoluteProfileId(p_FmVspEntry->h_Fm,
50418 + p_FmVspEntry->portType,
50419 + p_FmVspEntry->portId,
50420 + p_FmVspEntry->relativeProfileId,
50421 + &absoluteProfileId);
50422 +
50423 + ASSERT_COND(p_FmVspEntry->p_FmSpRegsBase);
50424 + ASSERT_COND(fm_vsp_params.int_context);
50425 + ASSERT_COND(fm_vsp_params.buf_margins);
50426 + ASSERT_COND((absoluteProfileId <= FM_VSP_MAX_NUM_OF_ENTRIES));
50427 +
50428 + /* Set all registers related to VSP */
50429 + fman_vsp_init(p_FmVspEntry->p_FmSpRegsBase, absoluteProfileId, &fm_vsp_params,FM_PORT_MAX_NUM_OF_EXT_POOLS, BM_MAX_NUM_OF_POOLS, FM_MAX_NUM_OF_PFC_PRIORITIES);
50430 +
50431 + p_FmVspEntry->absoluteSpId = absoluteProfileId;
50432 +
50433 + if (p_FmVspEntry->p_FmVspEntryDriverParams)
50434 + XX_Free(p_FmVspEntry->p_FmVspEntryDriverParams);
50435 + p_FmVspEntry->p_FmVspEntryDriverParams = NULL;
50436 +
50437 + return E_OK;
50438 +}
50439 +
50440 +t_Error FM_VSP_Free(t_Handle h_FmVsp)
50441 +{
50442 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry *)h_FmVsp;
50443 + SANITY_CHECK_RETURN_ERROR(h_FmVsp, E_INVALID_HANDLE);
50444 + XX_Free(p_FmVspEntry);
50445 + return E_OK;
50446 +}
50447 +
50448 +t_Error FM_VSP_ConfigBufferPrefixContent(t_Handle h_FmVsp, t_FmBufferPrefixContent *p_FmBufferPrefixContent)
50449 +{
50450 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50451 +
50452 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
50453 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
50454 +
50455 + memcpy(&p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent, p_FmBufferPrefixContent, sizeof(t_FmBufferPrefixContent));
50456 + /* if dataAlign was not initialized by user, we return to driver's default */
50457 + if (!p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.dataAlign)
50458 + p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.dataAlign = DEFAULT_FM_SP_bufferPrefixContent_dataAlign;
50459 +
50460 + return E_OK;
50461 +}
50462 +
50463 +t_Error FM_VSP_ConfigDmaSwapData(t_Handle h_FmVsp, e_FmDmaSwapOption swapData)
50464 +{
50465 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50466 +
50467 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
50468 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
50469 +
50470 + p_FmVspEntry->p_FmVspEntryDriverParams->dmaSwapData = swapData;
50471 +
50472 + return E_OK;
50473 +}
50474 +
50475 +t_Error FM_VSP_ConfigDmaIcCacheAttr(t_Handle h_FmVsp, e_FmDmaCacheOption intContextCacheAttr)
50476 +{
50477 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50478 +
50479 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
50480 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
50481 +
50482 + p_FmVspEntry->p_FmVspEntryDriverParams->dmaIntContextCacheAttr = intContextCacheAttr;
50483 +
50484 + return E_OK;
50485 +}
50486 +
50487 +t_Error FM_VSP_ConfigDmaHdrAttr(t_Handle h_FmVsp, e_FmDmaCacheOption headerCacheAttr)
50488 +{
50489 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50490 +
50491 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
50492 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
50493 +
50494 + p_FmVspEntry->p_FmVspEntryDriverParams->dmaHeaderCacheAttr = headerCacheAttr;
50495 +
50496 + return E_OK;
50497 +}
50498 +
50499 +t_Error FM_VSP_ConfigDmaScatterGatherAttr(t_Handle h_FmVsp, e_FmDmaCacheOption scatterGatherCacheAttr)
50500 +{
50501 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50502 +
50503 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
50504 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
50505 +
50506 + p_FmVspEntry->p_FmVspEntryDriverParams->dmaScatterGatherCacheAttr = scatterGatherCacheAttr;
50507 +
50508 + return E_OK;
50509 +}
50510 +
50511 +t_Error FM_VSP_ConfigDmaWriteOptimize(t_Handle h_FmVsp, bool optimize)
50512 +{
50513 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50514 +
50515 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
50516 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
50517 +
50518 +
50519 + p_FmVspEntry->p_FmVspEntryDriverParams->dmaWriteOptimize = optimize;
50520 +
50521 + return E_OK;
50522 +}
50523 +
50524 +t_Error FM_VSP_ConfigNoScatherGather(t_Handle h_FmVsp, bool noScatherGather)
50525 +{
50526 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50527 +
50528 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
50529 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
50530 +
50531 +
50532 + p_FmVspEntry->p_FmVspEntryDriverParams->noScatherGather = noScatherGather;
50533 +
50534 + return E_OK;
50535 +}
50536 +
50537 +t_Error FM_VSP_ConfigPoolDepletion(t_Handle h_FmVsp, t_FmBufPoolDepletion *p_BufPoolDepletion)
50538 +{
50539 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50540 +
50541 + SANITY_CHECK_RETURN_ERROR(h_FmVsp, E_INVALID_HANDLE);
50542 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
50543 + SANITY_CHECK_RETURN_ERROR(p_BufPoolDepletion, E_INVALID_HANDLE);
50544 +
50545 + p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion = (t_FmBufPoolDepletion *)XX_Malloc(sizeof(t_FmBufPoolDepletion));
50546 + if (!p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion)
50547 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("p_BufPoolDepletion allocation failed"));
50548 + memcpy(p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion, p_BufPoolDepletion, sizeof(t_FmBufPoolDepletion));
50549 +
50550 + return E_OK;
50551 +}
50552 +
50553 +t_Error FM_VSP_ConfigBackupPools(t_Handle h_FmVsp, t_FmBackupBmPools *p_BackupBmPools)
50554 +{
50555 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50556 +
50557 + SANITY_CHECK_RETURN_ERROR(h_FmVsp, E_INVALID_HANDLE);
50558 + SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
50559 + SANITY_CHECK_RETURN_ERROR(p_BackupBmPools, E_INVALID_HANDLE);
50560 +
50561 + p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools = (t_FmBackupBmPools *)XX_Malloc(sizeof(t_FmBackupBmPools));
50562 + if (!p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools)
50563 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("p_BackupBmPools allocation failed"));
50564 + memcpy(p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools, p_BackupBmPools, sizeof(t_FmBackupBmPools));
50565 +
50566 + return E_OK;
50567 +}
50568 +
50569 +uint32_t FM_VSP_GetBufferDataOffset(t_Handle h_FmVsp)
50570 +{
50571 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50572 +
50573 + SANITY_CHECK_RETURN_VALUE(p_FmVspEntry, E_INVALID_HANDLE, 0);
50574 + SANITY_CHECK_RETURN_VALUE(!p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_STATE, 0);
50575 +
50576 + return p_FmVspEntry->bufferOffsets.dataOffset;
50577 +}
50578 +
50579 +uint8_t * FM_VSP_GetBufferICInfo(t_Handle h_FmVsp, char *p_Data)
50580 +{
50581 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50582 +
50583 + SANITY_CHECK_RETURN_VALUE(p_FmVspEntry, E_INVALID_HANDLE, NULL);
50584 + SANITY_CHECK_RETURN_VALUE(!p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_STATE, NULL);
50585 +
50586 + if (p_FmVspEntry->bufferOffsets.pcdInfoOffset == ILLEGAL_BASE)
50587 + return NULL;
50588 +
50589 + return (uint8_t *)PTR_MOVE(p_Data, p_FmVspEntry->bufferOffsets.pcdInfoOffset);
50590 +}
50591 +
50592 +t_FmPrsResult * FM_VSP_GetBufferPrsResult(t_Handle h_FmVsp, char *p_Data)
50593 +{
50594 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50595 +
50596 + SANITY_CHECK_RETURN_VALUE(p_FmVspEntry, E_INVALID_HANDLE, NULL);
50597 + SANITY_CHECK_RETURN_VALUE(!p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_STATE, NULL);
50598 +
50599 + if (p_FmVspEntry->bufferOffsets.prsResultOffset == ILLEGAL_BASE)
50600 + return NULL;
50601 +
50602 + return (t_FmPrsResult *)PTR_MOVE(p_Data, p_FmVspEntry->bufferOffsets.prsResultOffset);
50603 +}
50604 +
50605 +uint64_t * FM_VSP_GetBufferTimeStamp(t_Handle h_FmVsp, char *p_Data)
50606 +{
50607 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50608 +
50609 + SANITY_CHECK_RETURN_VALUE(p_FmVspEntry, E_INVALID_HANDLE, NULL);
50610 + SANITY_CHECK_RETURN_VALUE(!p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_STATE, NULL);
50611 +
50612 + if (p_FmVspEntry->bufferOffsets.timeStampOffset == ILLEGAL_BASE)
50613 + return NULL;
50614 +
50615 + return (uint64_t *)PTR_MOVE(p_Data, p_FmVspEntry->bufferOffsets.timeStampOffset);
50616 +}
50617 +
50618 +uint8_t * FM_VSP_GetBufferHashResult(t_Handle h_FmVsp, char *p_Data)
50619 +{
50620 + t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
50621 +
50622 + SANITY_CHECK_RETURN_VALUE(p_FmVspEntry, E_INVALID_HANDLE, NULL);
50623 + SANITY_CHECK_RETURN_VALUE(!p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_STATE, NULL);
50624 +
50625 + if (p_FmVspEntry->bufferOffsets.hashResultOffset == ILLEGAL_BASE)
50626 + return NULL;
50627 +
50628 + return (uint8_t *)PTR_MOVE(p_Data, p_FmVspEntry->bufferOffsets.hashResultOffset);
50629 +}
50630 +
50631 +#endif /* (DPAA_VERSION >= 11) */
50632 --- /dev/null
50633 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/SP/fm_sp.h
50634 @@ -0,0 +1,85 @@
50635 +/*
50636 + * Copyright 2008-2012 Freescale Semiconductor Inc.
50637 + *
50638 + * Redistribution and use in source and binary forms, with or without
50639 + * modification, are permitted provided that the following conditions are met:
50640 + * * Redistributions of source code must retain the above copyright
50641 + * notice, this list of conditions and the following disclaimer.
50642 + * * Redistributions in binary form must reproduce the above copyright
50643 + * notice, this list of conditions and the following disclaimer in the
50644 + * documentation and/or other materials provided with the distribution.
50645 + * * Neither the name of Freescale Semiconductor nor the
50646 + * names of its contributors may be used to endorse or promote products
50647 + * derived from this software without specific prior written permission.
50648 + *
50649 + *
50650 + * ALTERNATIVELY, this software may be distributed under the terms of the
50651 + * GNU General Public License ("GPL") as published by the Free Software
50652 + * Foundation, either version 2 of that License or (at your option) any
50653 + * later version.
50654 + *
50655 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
50656 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
50657 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50658 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
50659 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
50660 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50661 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50662 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50663 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50664 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50665 + */
50666 +
50667 +
50668 +/******************************************************************************
50669 + @File fm_sp.h
50670 +
50671 + @Description FM SP ...
50672 +*//***************************************************************************/
50673 +#ifndef __FM_SP_H
50674 +#define __FM_SP_H
50675 +
50676 +#include "std_ext.h"
50677 +#include "error_ext.h"
50678 +#include "list_ext.h"
50679 +
50680 +#include "fm_sp_common.h"
50681 +#include "fm_common.h"
50682 +
50683 +
50684 +#define __ERR_MODULE__ MODULE_FM_SP
50685 +
50686 +typedef struct {
50687 + t_FmBufferPrefixContent bufferPrefixContent;
50688 + e_FmDmaSwapOption dmaSwapData;
50689 + e_FmDmaCacheOption dmaIntContextCacheAttr;
50690 + e_FmDmaCacheOption dmaHeaderCacheAttr;
50691 + e_FmDmaCacheOption dmaScatterGatherCacheAttr;
50692 + bool dmaWriteOptimize;
50693 + uint16_t liodnOffset;
50694 + bool noScatherGather;
50695 + t_FmBufPoolDepletion *p_BufPoolDepletion;
50696 + t_FmBackupBmPools *p_BackupBmPools;
50697 + t_FmExtPools extBufPools;
50698 +} t_FmVspEntryDriverParams;
50699 +
50700 +typedef struct {
50701 + bool valid;
50702 + volatile bool lock;
50703 + uint8_t pointedOwners;
50704 + uint16_t absoluteSpId;
50705 + uint8_t internalBufferOffset;
50706 + t_FmSpBufMargins bufMargins;
50707 + t_FmSpIntContextDataCopy intContext;
50708 + t_FmSpBufferOffsets bufferOffsets;
50709 + t_Handle h_Fm;
50710 + e_FmPortType portType; /**< Port type */
50711 + uint8_t portId; /**< Port Id - relative to type */
50712 + uint8_t relativeProfileId;
50713 + struct fm_pcd_storage_profile_regs *p_FmSpRegsBase;
50714 + t_FmExtPools extBufPools;
50715 + t_FmVspEntryDriverParams *p_FmVspEntryDriverParams;
50716 +} t_FmVspEntry;
50717 +
50718 +
50719 +#endif /* __FM_SP_H */
50720 --- /dev/null
50721 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/SP/fman_sp.c
50722 @@ -0,0 +1,197 @@
50723 +/*
50724 + * Copyright 2013 Freescale Semiconductor Inc.
50725 + *
50726 + * Redistribution and use in source and binary forms, with or without
50727 + * modification, are permitted provided that the following conditions are met:
50728 + * * Redistributions of source code must retain the above copyright
50729 + * notice, this list of conditions and the following disclaimer.
50730 + * * Redistributions in binary form must reproduce the above copyright
50731 + * notice, this list of conditions and the following disclaimer in the
50732 + * documentation and/or other materials provided with the distribution.
50733 + * * Neither the name of Freescale Semiconductor nor the
50734 + * names of its contributors may be used to endorse or promote products
50735 + * derived from this software without specific prior written permission.
50736 + *
50737 + *
50738 + * ALTERNATIVELY, this software may be distributed under the terms of the
50739 + * GNU General Public License ("GPL") as published by the Free Software
50740 + * Foundation, either version 2 of that License or (at your option) any
50741 + * later version.
50742 + *
50743 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
50744 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
50745 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50746 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
50747 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
50748 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50749 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50750 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50751 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50752 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50753 + */
50754 +
50755 +#include "fsl_fman_sp.h"
50756 +
50757 +
50758 +uint32_t fman_vsp_get_statistics(struct fm_pcd_storage_profile_regs *regs,
50759 + uint16_t index)
50760 +{
50761 + struct fm_pcd_storage_profile_regs *sp_regs;
50762 + sp_regs = &regs[index];
50763 + return ioread32be(&sp_regs->fm_sp_acnt);
50764 +}
50765 +
50766 +void fman_vsp_set_statistics(struct fm_pcd_storage_profile_regs *regs,
50767 + uint16_t index, uint32_t value)
50768 +{
50769 + struct fm_pcd_storage_profile_regs *sp_regs;
50770 + sp_regs = &regs[index];
50771 + iowrite32be(value, &sp_regs->fm_sp_acnt);
50772 +}
50773 +
50774 +void fman_vsp_defconfig(struct fm_storage_profile_params *cfg)
50775 +{
50776 + cfg->dma_swap_data =
50777 + DEFAULT_FMAN_SP_DMA_SWAP_DATA;
50778 + cfg->int_context_cache_attr =
50779 + DEFAULT_FMAN_SP_DMA_INT_CONTEXT_CACHE_ATTR;
50780 + cfg->header_cache_attr =
50781 + DEFAULT_FMAN_SP_DMA_HEADER_CACHE_ATTR;
50782 + cfg->scatter_gather_cache_attr =
50783 + DEFAULT_FMAN_SP_DMA_SCATTER_GATHER_CACHE_ATTR;
50784 + cfg->dma_write_optimize =
50785 + DEFAULT_FMAN_SP_DMA_WRITE_OPTIMIZE;
50786 + cfg->no_scather_gather =
50787 + DEFAULT_FMAN_SP_NO_SCATTER_GATHER;
50788 +}
50789 +
50790 +static inline uint32_t calc_vec_dep(int max_pools, bool *pools,
50791 + struct fman_ext_pools *ext_buf_pools, uint32_t mask)
50792 +{
50793 + int i, j;
50794 + uint32_t vector = 0;
50795 + for (i = 0; i < max_pools; i++)
50796 + if (pools[i])
50797 + for (j = 0; j < ext_buf_pools->num_pools_used; j++)
50798 + if (i == ext_buf_pools->ext_buf_pool[j].id) {
50799 + vector |= mask >> j;
50800 + break;
50801 + }
50802 + return vector;
50803 +}
50804 +
50805 +void fman_vsp_init(struct fm_pcd_storage_profile_regs *regs,
50806 + uint16_t index, struct fm_storage_profile_params *fm_vsp_params,
50807 + int port_max_num_of_ext_pools, int bm_max_num_of_pools,
50808 + int max_num_of_pfc_priorities)
50809 +{
50810 + int i = 0, j = 0;
50811 + struct fm_pcd_storage_profile_regs *sp_regs;
50812 + uint32_t tmp_reg, vector;
50813 + struct fman_ext_pools *ext_buf_pools = &fm_vsp_params->fm_ext_pools;
50814 + struct fman_buf_pool_depletion *buf_pool_depletion =
50815 + &fm_vsp_params->buf_pool_depletion;
50816 + struct fman_backup_bm_pools *backup_pools =
50817 + &fm_vsp_params->backup_pools;
50818 + struct fman_sp_int_context_data_copy *int_context_data_copy =
50819 + fm_vsp_params->int_context;
50820 + struct fman_sp_buf_margins *external_buffer_margins =
50821 + fm_vsp_params->buf_margins;
50822 + bool no_scather_gather = fm_vsp_params->no_scather_gather;
50823 + uint16_t liodn_offset = fm_vsp_params->liodn_offset;
50824 +
50825 + sp_regs = &regs[index];
50826 +
50827 + /* fill external buffers manager pool information register*/
50828 + for (i = 0; i < ext_buf_pools->num_pools_used; i++) {
50829 + tmp_reg = FMAN_SP_EXT_BUF_POOL_VALID |
50830 + FMAN_SP_EXT_BUF_POOL_EN_COUNTER;
50831 + tmp_reg |= ((uint32_t)ext_buf_pools->ext_buf_pool[i].id <<
50832 + FMAN_SP_EXT_BUF_POOL_ID_SHIFT);
50833 + tmp_reg |= ext_buf_pools->ext_buf_pool[i].size;
50834 + /* functionality available only for some deriviatives
50835 + (limited by config) */
50836 + for (j = 0; j < backup_pools->num_backup_pools; j++)
50837 + if (ext_buf_pools->ext_buf_pool[i].id ==
50838 + backup_pools->pool_ids[j]) {
50839 + tmp_reg |= FMAN_SP_EXT_BUF_POOL_BACKUP;
50840 + break;
50841 + }
50842 + iowrite32be(tmp_reg, &sp_regs->fm_sp_ebmpi[i]);
50843 + }
50844 +
50845 + /* clear unused pools */
50846 + for (i = ext_buf_pools->num_pools_used;
50847 + i < port_max_num_of_ext_pools; i++)
50848 + iowrite32be(0, &sp_regs->fm_sp_ebmpi[i]);
50849 +
50850 + /* fill pool depletion register*/
50851 + tmp_reg = 0;
50852 + if (buf_pool_depletion->buf_pool_depletion_enabled && buf_pool_depletion->pools_grp_mode_enable) {
50853 + /* calculate vector for number of pools depletion */
50854 + vector = calc_vec_dep(bm_max_num_of_pools, buf_pool_depletion->
50855 + pools_to_consider, ext_buf_pools, 0x80000000);
50856 +
50857 + /* configure num of pools and vector for number of pools mode */
50858 + tmp_reg |= (((uint32_t)buf_pool_depletion->num_pools - 1) <<
50859 + FMAN_SP_POOL_DEP_NUM_OF_POOLS_SHIFT);
50860 + tmp_reg |= vector;
50861 + }
50862 +
50863 + if (buf_pool_depletion->buf_pool_depletion_enabled && buf_pool_depletion->single_pool_mode_enable) {
50864 + /* calculate vector for number of pools depletion */
50865 + vector = calc_vec_dep(bm_max_num_of_pools, buf_pool_depletion->
50866 + pools_to_consider_for_single_mode,
50867 + ext_buf_pools, 0x00000080);
50868 +
50869 + /* configure num of pools and vector for number of pools mode */
50870 + tmp_reg |= vector;
50871 + }
50872 +
50873 + /* fill QbbPEV */
50874 + if (buf_pool_depletion->buf_pool_depletion_enabled) {
50875 + vector = 0;
50876 + for (i = 0; i < max_num_of_pfc_priorities; i++)
50877 + if (buf_pool_depletion->pfc_priorities_en[i] == TRUE)
50878 + vector |= 0x00000100 << i;
50879 + tmp_reg |= vector;
50880 + }
50881 + iowrite32be(tmp_reg, &sp_regs->fm_sp_mpd);
50882 +
50883 + /* fill dma attributes register */
50884 + tmp_reg = 0;
50885 + tmp_reg |= (uint32_t)fm_vsp_params->dma_swap_data <<
50886 + FMAN_SP_DMA_ATTR_SWP_SHIFT;
50887 + tmp_reg |= (uint32_t)fm_vsp_params->int_context_cache_attr <<
50888 + FMAN_SP_DMA_ATTR_IC_CACHE_SHIFT;
50889 + tmp_reg |= (uint32_t)fm_vsp_params->header_cache_attr <<
50890 + FMAN_SP_DMA_ATTR_HDR_CACHE_SHIFT;
50891 + tmp_reg |= (uint32_t)fm_vsp_params->scatter_gather_cache_attr <<
50892 + FMAN_SP_DMA_ATTR_SG_CACHE_SHIFT;
50893 + if (fm_vsp_params->dma_write_optimize)
50894 + tmp_reg |= FMAN_SP_DMA_ATTR_WRITE_OPTIMIZE;
50895 + iowrite32be(tmp_reg, &sp_regs->fm_sp_da);
50896 +
50897 + /* IC parameters - fill internal context parameters register */
50898 + tmp_reg = 0;
50899 + tmp_reg |= (((uint32_t)int_context_data_copy->ext_buf_offset/
50900 + OFFSET_UNITS) << FMAN_SP_IC_TO_EXT_SHIFT);
50901 + tmp_reg |= (((uint32_t)int_context_data_copy->int_context_offset/
50902 + OFFSET_UNITS) << FMAN_SP_IC_FROM_INT_SHIFT);
50903 + tmp_reg |= (((uint32_t)int_context_data_copy->size/OFFSET_UNITS) <<
50904 + FMAN_SP_IC_SIZE_SHIFT);
50905 + iowrite32be(tmp_reg, &sp_regs->fm_sp_icp);
50906 +
50907 + /* buffer margins - fill external buffer margins register */
50908 + tmp_reg = 0;
50909 + tmp_reg |= (((uint32_t)external_buffer_margins->start_margins) <<
50910 + FMAN_SP_EXT_BUF_MARG_START_SHIFT);
50911 + tmp_reg |= (((uint32_t)external_buffer_margins->end_margins) <<
50912 + FMAN_SP_EXT_BUF_MARG_END_SHIFT);
50913 + if (no_scather_gather)
50914 + tmp_reg |= FMAN_SP_SG_DISABLE;
50915 + iowrite32be(tmp_reg, &sp_regs->fm_sp_ebm);
50916 +
50917 + /* buffer margins - fill spliodn register */
50918 + iowrite32be(liodn_offset, &sp_regs->fm_sp_spliodn);
50919 +}
50920 --- /dev/null
50921 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.c
50922 @@ -0,0 +1,5195 @@
50923 +/*
50924 + * Copyright 2008-2012 Freescale Semiconductor Inc.
50925 + *
50926 + * Redistribution and use in source and binary forms, with or without
50927 + * modification, are permitted provided that the following conditions are met:
50928 + * * Redistributions of source code must retain the above copyright
50929 + * notice, this list of conditions and the following disclaimer.
50930 + * * Redistributions in binary form must reproduce the above copyright
50931 + * notice, this list of conditions and the following disclaimer in the
50932 + * documentation and/or other materials provided with the distribution.
50933 + * * Neither the name of Freescale Semiconductor nor the
50934 + * names of its contributors may be used to endorse or promote products
50935 + * derived from this software without specific prior written permission.
50936 + *
50937 + *
50938 + * ALTERNATIVELY, this software may be distributed under the terms of the
50939 + * GNU General Public License ("GPL") as published by the Free Software
50940 + * Foundation, either version 2 of that License or (at your option) any
50941 + * later version.
50942 + *
50943 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
50944 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
50945 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50946 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
50947 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
50948 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50949 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50950 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50951 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50952 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50953 + */
50954 +
50955 +
50956 +/******************************************************************************
50957 + @File fm.c
50958 +
50959 + @Description FM driver routines implementation.
50960 +*//***************************************************************************/
50961 +#include "std_ext.h"
50962 +#include "error_ext.h"
50963 +#include "xx_ext.h"
50964 +#include "string_ext.h"
50965 +#include "sprint_ext.h"
50966 +#include "debug_ext.h"
50967 +#include "fm_muram_ext.h"
50968 +
50969 +#include "fm_common.h"
50970 +#include "fm_ipc.h"
50971 +#include "fm.h"
50972 +#ifndef CONFIG_FMAN_ARM
50973 +#include <linux/fsl/svr.h>
50974 +#endif
50975 +#include "fsl_fman.h"
50976 +
50977 +
50978 +/****************************************/
50979 +/* static functions */
50980 +/****************************************/
50981 +
50982 +static volatile bool blockingFlag = FALSE;
50983 +static void IpcMsgCompletionCB(t_Handle h_Fm,
50984 + uint8_t *p_Msg,
50985 + uint8_t *p_Reply,
50986 + uint32_t replyLength,
50987 + t_Error status)
50988 +{
50989 + UNUSED(h_Fm);UNUSED(p_Msg);UNUSED(p_Reply);UNUSED(replyLength);UNUSED(status);
50990 + blockingFlag = FALSE;
50991 +}
50992 +
50993 +static void FreeInitResources(t_Fm *p_Fm)
50994 +{
50995 + if (p_Fm->camBaseAddr)
50996 + FM_MURAM_FreeMem(p_Fm->h_FmMuram, UINT_TO_PTR(p_Fm->camBaseAddr));
50997 + if (p_Fm->fifoBaseAddr)
50998 + FM_MURAM_FreeMem(p_Fm->h_FmMuram, UINT_TO_PTR(p_Fm->fifoBaseAddr));
50999 + if (p_Fm->resAddr)
51000 + FM_MURAM_FreeMem(p_Fm->h_FmMuram, UINT_TO_PTR(p_Fm->resAddr));
51001 +}
51002 +
51003 +static bool IsFmanCtrlCodeLoaded(t_Fm *p_Fm)
51004 +{
51005 + t_FMIramRegs *p_Iram;
51006 +
51007 + ASSERT_COND(p_Fm);
51008 + p_Iram = (t_FMIramRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_IMEM);
51009 +
51010 + return (bool)!!(GET_UINT32(p_Iram->iready) & IRAM_READY);
51011 +}
51012 +
51013 +static t_Error CheckFmParameters(t_Fm *p_Fm)
51014 +{
51015 + if (IsFmanCtrlCodeLoaded(p_Fm) && !p_Fm->resetOnInit)
51016 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Old FMan CTRL code is loaded; FM must be reset!"));
51017 +#if (DPAA_VERSION < 11)
51018 + if (!p_Fm->p_FmDriverParam->dma_axi_dbg_num_of_beats ||
51019 + (p_Fm->p_FmDriverParam->dma_axi_dbg_num_of_beats > DMA_MODE_MAX_AXI_DBG_NUM_OF_BEATS))
51020 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
51021 + ("axiDbgNumOfBeats has to be in the range 1 - %d", DMA_MODE_MAX_AXI_DBG_NUM_OF_BEATS));
51022 +#endif /* (DPAA_VERSION < 11) */
51023 + if (p_Fm->p_FmDriverParam->dma_cam_num_of_entries % DMA_CAM_UNITS)
51024 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_cam_num_of_entries has to be divisble by %d", DMA_CAM_UNITS));
51025 +// if (!p_Fm->p_FmDriverParam->dma_cam_num_of_entries || (p_Fm->p_FmDriverParam->dma_cam_num_of_entries > DMA_MODE_MAX_CAM_NUM_OF_ENTRIES))
51026 +// RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_cam_num_of_entries has to be in the range 1 - %d", DMA_MODE_MAX_CAM_NUM_OF_ENTRIES));
51027 + if (p_Fm->p_FmDriverParam->dma_comm_qtsh_asrt_emer > DMA_THRESH_MAX_COMMQ)
51028 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_comm_qtsh_asrt_emer can not be larger than %d", DMA_THRESH_MAX_COMMQ));
51029 + if (p_Fm->p_FmDriverParam->dma_comm_qtsh_clr_emer > DMA_THRESH_MAX_COMMQ)
51030 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_comm_qtsh_clr_emer can not be larger than %d", DMA_THRESH_MAX_COMMQ));
51031 + if (p_Fm->p_FmDriverParam->dma_comm_qtsh_clr_emer >= p_Fm->p_FmDriverParam->dma_comm_qtsh_asrt_emer)
51032 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_comm_qtsh_clr_emer must be smaller than dma_comm_qtsh_asrt_emer"));
51033 +#if (DPAA_VERSION < 11)
51034 + if (p_Fm->p_FmDriverParam->dma_read_buf_tsh_asrt_emer > DMA_THRESH_MAX_BUF)
51035 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_read_buf_tsh_asrt_emer can not be larger than %d", DMA_THRESH_MAX_BUF));
51036 + if (p_Fm->p_FmDriverParam->dma_read_buf_tsh_clr_emer > DMA_THRESH_MAX_BUF)
51037 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_read_buf_tsh_clr_emer can not be larger than %d", DMA_THRESH_MAX_BUF));
51038 + if (p_Fm->p_FmDriverParam->dma_read_buf_tsh_clr_emer >= p_Fm->p_FmDriverParam->dma_read_buf_tsh_asrt_emer)
51039 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_read_buf_tsh_clr_emer must be smaller than dma_read_buf_tsh_asrt_emer"));
51040 + if (p_Fm->p_FmDriverParam->dma_write_buf_tsh_asrt_emer > DMA_THRESH_MAX_BUF)
51041 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_write_buf_tsh_asrt_emer can not be larger than %d", DMA_THRESH_MAX_BUF));
51042 + if (p_Fm->p_FmDriverParam->dma_write_buf_tsh_clr_emer > DMA_THRESH_MAX_BUF)
51043 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_write_buf_tsh_clr_emer can not be larger than %d", DMA_THRESH_MAX_BUF));
51044 + if (p_Fm->p_FmDriverParam->dma_write_buf_tsh_clr_emer >= p_Fm->p_FmDriverParam->dma_write_buf_tsh_asrt_emer)
51045 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_write_buf_tsh_clr_emer must be smaller than dma_write_buf_tsh_asrt_emer"));
51046 +#else /* (DPAA_VERSION >= 11) */
51047 + if ((p_Fm->p_FmDriverParam->dma_dbg_cnt_mode == E_FMAN_DMA_DBG_CNT_INT_READ_EM)||
51048 + (p_Fm->p_FmDriverParam->dma_dbg_cnt_mode == E_FMAN_DMA_DBG_CNT_INT_WRITE_EM) ||
51049 + (p_Fm->p_FmDriverParam->dma_dbg_cnt_mode == E_FMAN_DMA_DBG_CNT_RAW_WAR_PROT))
51050 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_dbg_cnt_mode value not supported by this integration."));
51051 + if ((p_Fm->p_FmDriverParam->dma_emergency_bus_select == FM_DMA_MURAM_READ_EMERGENCY)||
51052 + (p_Fm->p_FmDriverParam->dma_emergency_bus_select == FM_DMA_MURAM_WRITE_EMERGENCY))
51053 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("emergencyBusSelect value not supported by this integration."));
51054 + if (p_Fm->p_FmDriverParam->dma_stop_on_bus_error)
51055 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_stop_on_bus_error not supported by this integration."));
51056 +#ifdef FM_AID_MODE_NO_TNUM_SW005
51057 + if (p_Fm->p_FmDriverParam->dma_aid_mode != E_FMAN_DMA_AID_OUT_PORT_ID)
51058 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_aid_mode not supported by this integration."));
51059 +#endif /* FM_AID_MODE_NO_TNUM_SW005 */
51060 + if (p_Fm->p_FmDriverParam->dma_axi_dbg_num_of_beats)
51061 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_axi_dbg_num_of_beats not supported by this integration."));
51062 +#endif /* (DPAA_VERSION < 11) */
51063 +
51064 + if (!p_Fm->p_FmStateStruct->fmClkFreq)
51065 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fmClkFreq must be set."));
51066 + if (USEC_TO_CLK(p_Fm->p_FmDriverParam->dma_watchdog, p_Fm->p_FmStateStruct->fmClkFreq) > DMA_MAX_WATCHDOG)
51067 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
51068 + ("dma_watchdog depends on FM clock. dma_watchdog(in microseconds) * clk (in Mhz), may not exceed 0x08x", DMA_MAX_WATCHDOG));
51069 +
51070 +#if (DPAA_VERSION >= 11)
51071 + if ((p_Fm->partVSPBase + p_Fm->partNumOfVSPs) > FM_VSP_MAX_NUM_OF_ENTRIES)
51072 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("partVSPBase+partNumOfVSPs out of range!!!"));
51073 +#endif /* (DPAA_VERSION >= 11) */
51074 +
51075 + if (p_Fm->p_FmStateStruct->totalFifoSize % BMI_FIFO_UNITS)
51076 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("totalFifoSize number has to be divisible by %d", BMI_FIFO_UNITS));
51077 + if (!p_Fm->p_FmStateStruct->totalFifoSize ||
51078 + (p_Fm->p_FmStateStruct->totalFifoSize > BMI_MAX_FIFO_SIZE))
51079 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
51080 + ("totalFifoSize (currently defined as %d) has to be in the range of 256 to %d",
51081 + p_Fm->p_FmStateStruct->totalFifoSize,
51082 + BMI_MAX_FIFO_SIZE));
51083 + if (!p_Fm->p_FmStateStruct->totalNumOfTasks ||
51084 + (p_Fm->p_FmStateStruct->totalNumOfTasks > BMI_MAX_NUM_OF_TASKS))
51085 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("totalNumOfTasks number has to be in the range 1 - %d", BMI_MAX_NUM_OF_TASKS));
51086 +
51087 +#ifdef FM_HAS_TOTAL_DMAS
51088 + if (!p_Fm->p_FmStateStruct->maxNumOfOpenDmas ||
51089 + (p_Fm->p_FmStateStruct->maxNumOfOpenDmas > BMI_MAX_NUM_OF_DMAS))
51090 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("maxNumOfOpenDmas number has to be in the range 1 - %d", BMI_MAX_NUM_OF_DMAS));
51091 +#endif /* FM_HAS_TOTAL_DMAS */
51092 +
51093 + if (p_Fm->p_FmDriverParam->disp_limit_tsh > FPM_MAX_DISP_LIMIT)
51094 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("disp_limit_tsh can't be greater than %d", FPM_MAX_DISP_LIMIT));
51095 +
51096 + if (!p_Fm->f_Exception)
51097 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exceptions callback not provided"));
51098 + if (!p_Fm->f_BusError)
51099 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exceptions callback not provided"));
51100 +
51101 +#ifdef FM_NO_WATCHDOG
51102 + if ((p_Fm->p_FmStateStruct->revInfo.majorRev == 2) &&
51103 + (p_Fm->p_FmDriverParam->dma_watchdog))
51104 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("watchdog!"));
51105 +#endif /* FM_NO_WATCHDOG */
51106 +
51107 +#ifdef FM_ECC_HALT_NO_SYNC_ERRATA_10GMAC_A008
51108 + if ((p_Fm->p_FmStateStruct->revInfo.majorRev < 6) &&
51109 + (p_Fm->p_FmDriverParam->halt_on_unrecov_ecc_err))
51110 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("HaltOnEccError!"));
51111 +#endif /* FM_ECC_HALT_NO_SYNC_ERRATA_10GMAC_A008 */
51112 +
51113 +#ifdef FM_NO_TNUM_AGING
51114 + if ((p_Fm->p_FmStateStruct->revInfo.majorRev != 4) &&
51115 + (p_Fm->p_FmStateStruct->revInfo.majorRev < 6))
51116 + if (p_Fm->p_FmDriverParam->tnum_aging_period)
51117 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Tnum aging!"));
51118 +#endif /* FM_NO_TNUM_AGING */
51119 +
51120 + /* check that user did not set revision-dependent exceptions */
51121 +#ifdef FM_NO_DISPATCH_RAM_ECC
51122 + if ((p_Fm->p_FmStateStruct->revInfo.majorRev != 4) &&
51123 + (p_Fm->p_FmStateStruct->revInfo.majorRev < 6))
51124 + if (p_Fm->userSetExceptions & FM_EX_BMI_DISPATCH_RAM_ECC)
51125 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("exception e_FM_EX_BMI_DISPATCH_RAM_ECC!"));
51126 +#endif /* FM_NO_DISPATCH_RAM_ECC */
51127 +
51128 +#ifdef FM_QMI_NO_ECC_EXCEPTIONS
51129 + if (p_Fm->p_FmStateStruct->revInfo.majorRev == 4)
51130 + if (p_Fm->userSetExceptions & (FM_EX_QMI_SINGLE_ECC | FM_EX_QMI_DOUBLE_ECC))
51131 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("exception e_FM_EX_QMI_SINGLE_ECC/e_FM_EX_QMI_DOUBLE_ECC!"));
51132 +#endif /* FM_QMI_NO_ECC_EXCEPTIONS */
51133 +
51134 +#ifdef FM_QMI_NO_SINGLE_ECC_EXCEPTION
51135 + if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
51136 + if (p_Fm->userSetExceptions & FM_EX_QMI_SINGLE_ECC)
51137 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("exception e_FM_EX_QMI_SINGLE_ECC!"));
51138 +#endif /* FM_QMI_NO_SINGLE_ECC_EXCEPTION */
51139 +
51140 + return E_OK;
51141 +}
51142 +
51143 +
51144 +static void SendIpcIsr(t_Fm *p_Fm, uint32_t macEvent, uint32_t pendingReg)
51145 +{
51146 + ASSERT_COND(p_Fm->guestId == NCSW_MASTER_ID);
51147 +
51148 + if (p_Fm->intrMng[macEvent].guestId == NCSW_MASTER_ID)
51149 + p_Fm->intrMng[macEvent].f_Isr(p_Fm->intrMng[macEvent].h_SrcHandle);
51150 +
51151 + /* If the MAC is running on guest-partition and we have IPC session with it,
51152 + we inform him about the event through IPC; otherwise, we ignore the event. */
51153 + else if (p_Fm->h_IpcSessions[p_Fm->intrMng[macEvent].guestId])
51154 + {
51155 + t_Error err;
51156 + t_FmIpcIsr fmIpcIsr;
51157 + t_FmIpcMsg msg;
51158 +
51159 + memset(&msg, 0, sizeof(msg));
51160 + msg.msgId = FM_GUEST_ISR;
51161 + fmIpcIsr.pendingReg = pendingReg;
51162 + fmIpcIsr.boolErr = FALSE;
51163 + memcpy(msg.msgBody, &fmIpcIsr, sizeof(fmIpcIsr));
51164 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[p_Fm->intrMng[macEvent].guestId],
51165 + (uint8_t*)&msg,
51166 + sizeof(msg.msgId) + sizeof(fmIpcIsr),
51167 + NULL,
51168 + NULL,
51169 + NULL,
51170 + NULL);
51171 + if (err != E_OK)
51172 + REPORT_ERROR(MINOR, err, NO_MSG);
51173 + }
51174 + else
51175 + DBG(TRACE, ("FM Guest mode, without IPC - can't call ISR!"));
51176 +}
51177 +
51178 +static void BmiErrEvent(t_Fm *p_Fm)
51179 +{
51180 + uint32_t event;
51181 + struct fman_bmi_regs *bmi_rg = p_Fm->p_FmBmiRegs;
51182 +
51183 +
51184 + event = fman_get_bmi_err_event(bmi_rg);
51185 +
51186 + if (event & BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC)
51187 + p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_BMI_STORAGE_PROFILE_ECC);
51188 + if (event & BMI_ERR_INTR_EN_LIST_RAM_ECC)
51189 + p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_BMI_LIST_RAM_ECC);
51190 + if (event & BMI_ERR_INTR_EN_STATISTICS_RAM_ECC)
51191 + p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_BMI_STATISTICS_RAM_ECC);
51192 + if (event & BMI_ERR_INTR_EN_DISPATCH_RAM_ECC)
51193 + p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_BMI_DISPATCH_RAM_ECC);
51194 +}
51195 +
51196 +static void QmiErrEvent(t_Fm *p_Fm)
51197 +{
51198 + uint32_t event;
51199 + struct fman_qmi_regs *qmi_rg = p_Fm->p_FmQmiRegs;
51200 +
51201 + event = fman_get_qmi_err_event(qmi_rg);
51202 +
51203 + if (event & QMI_ERR_INTR_EN_DOUBLE_ECC)
51204 + p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_QMI_DOUBLE_ECC);
51205 + if (event & QMI_ERR_INTR_EN_DEQ_FROM_DEF)
51206 + p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID);
51207 +}
51208 +
51209 +static void DmaErrEvent(t_Fm *p_Fm)
51210 +{
51211 + uint32_t status, com_id;
51212 + uint8_t tnum;
51213 + uint8_t hardwarePortId;
51214 + uint8_t relativePortId;
51215 + uint16_t liodn;
51216 + struct fman_dma_regs *dma_rg = p_Fm->p_FmDmaRegs;
51217 +
51218 + status = fman_get_dma_err_event(dma_rg);
51219 +
51220 + if (status & DMA_STATUS_BUS_ERR)
51221 + {
51222 + com_id = fman_get_dma_com_id(dma_rg);
51223 + hardwarePortId = (uint8_t)(((com_id & DMA_TRANSFER_PORTID_MASK) >> DMA_TRANSFER_PORTID_SHIFT));
51224 + ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
51225 + HW_PORT_ID_TO_SW_PORT_ID(relativePortId, hardwarePortId);
51226 + tnum = (uint8_t)((com_id & DMA_TRANSFER_TNUM_MASK) >> DMA_TRANSFER_TNUM_SHIFT);
51227 + liodn = (uint16_t)(com_id & DMA_TRANSFER_LIODN_MASK);
51228 + ASSERT_COND(p_Fm->p_FmStateStruct->portsTypes[hardwarePortId] != e_FM_PORT_TYPE_DUMMY);
51229 + p_Fm->f_BusError(p_Fm->h_App,
51230 + p_Fm->p_FmStateStruct->portsTypes[hardwarePortId],
51231 + relativePortId,
51232 + fman_get_dma_addr(dma_rg),
51233 + tnum,
51234 + liodn);
51235 + }
51236 + if (status & DMA_STATUS_FM_SPDAT_ECC)
51237 + p_Fm->f_Exception(p_Fm->h_App, e_FM_EX_DMA_SINGLE_PORT_ECC);
51238 + if (status & DMA_STATUS_READ_ECC)
51239 + p_Fm->f_Exception(p_Fm->h_App, e_FM_EX_DMA_READ_ECC);
51240 + if (status & DMA_STATUS_SYSTEM_WRITE_ECC)
51241 + p_Fm->f_Exception(p_Fm->h_App, e_FM_EX_DMA_SYSTEM_WRITE_ECC);
51242 + if (status & DMA_STATUS_FM_WRITE_ECC)
51243 + p_Fm->f_Exception(p_Fm->h_App, e_FM_EX_DMA_FM_WRITE_ECC);
51244 + }
51245 +
51246 +static void FpmErrEvent(t_Fm *p_Fm)
51247 +{
51248 + uint32_t event;
51249 + struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
51250 +
51251 + event = fman_get_fpm_err_event(fpm_rg);
51252 +
51253 + if ((event & FPM_EV_MASK_DOUBLE_ECC) && (event & FPM_EV_MASK_DOUBLE_ECC_EN))
51254 + p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_FPM_DOUBLE_ECC);
51255 + if ((event & FPM_EV_MASK_STALL) && (event & FPM_EV_MASK_STALL_EN))
51256 + p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_FPM_STALL_ON_TASKS);
51257 + if ((event & FPM_EV_MASK_SINGLE_ECC) && (event & FPM_EV_MASK_SINGLE_ECC_EN))
51258 + p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_FPM_SINGLE_ECC);
51259 +}
51260 +
51261 +static void MuramErrIntr(t_Fm *p_Fm)
51262 +{
51263 + uint32_t event;
51264 + struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
51265 +
51266 + event = fman_get_muram_err_event(fpm_rg);
51267 +
51268 + if (event & FPM_RAM_MURAM_ECC)
51269 + p_Fm->f_Exception(p_Fm->h_App, e_FM_EX_MURAM_ECC);
51270 +}
51271 +
51272 +static void IramErrIntr(t_Fm *p_Fm)
51273 +{
51274 + uint32_t event;
51275 + struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
51276 +
51277 + event = fman_get_iram_err_event(fpm_rg);
51278 +
51279 + if (event & FPM_RAM_IRAM_ECC)
51280 + p_Fm->f_Exception(p_Fm->h_App, e_FM_EX_IRAM_ECC);
51281 +}
51282 +
51283 +static void QmiEvent(t_Fm *p_Fm)
51284 +{
51285 + uint32_t event;
51286 + struct fman_qmi_regs *qmi_rg = p_Fm->p_FmQmiRegs;
51287 +
51288 + event = fman_get_qmi_event(qmi_rg);
51289 +
51290 + if (event & QMI_INTR_EN_SINGLE_ECC)
51291 + p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_QMI_SINGLE_ECC);
51292 +}
51293 +
51294 +static void UnimplementedIsr(t_Handle h_Arg)
51295 +{
51296 + UNUSED(h_Arg);
51297 +
51298 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unimplemented ISR!"));
51299 +}
51300 +
51301 +static void UnimplementedFmanCtrlIsr(t_Handle h_Arg, uint32_t event)
51302 +{
51303 + UNUSED(h_Arg); UNUSED(event);
51304 +
51305 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unimplemented FmCtl ISR!"));
51306 +}
51307 +
51308 +static void EnableTimeStamp(t_Fm *p_Fm)
51309 +{
51310 + struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
51311 +
51312 + ASSERT_COND(p_Fm->p_FmStateStruct);
51313 + ASSERT_COND(p_Fm->p_FmStateStruct->count1MicroBit);
51314 +
51315 + fman_enable_time_stamp(fpm_rg, p_Fm->p_FmStateStruct->count1MicroBit, p_Fm->p_FmStateStruct->fmClkFreq);
51316 +
51317 + p_Fm->p_FmStateStruct->enabledTimeStamp = TRUE;
51318 +}
51319 +
51320 +static t_Error ClearIRam(t_Fm *p_Fm)
51321 +{
51322 + t_FMIramRegs *p_Iram;
51323 + int i;
51324 + int iram_size;
51325 +
51326 + ASSERT_COND(p_Fm);
51327 + p_Iram = (t_FMIramRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_IMEM);
51328 + iram_size = FM_IRAM_SIZE(p_Fm->p_FmStateStruct->revInfo.majorRev,p_Fm->p_FmStateStruct->revInfo.minorRev);
51329 +
51330 + /* Enable the auto-increment */
51331 + WRITE_UINT32(p_Iram->iadd, IRAM_IADD_AIE);
51332 + while (GET_UINT32(p_Iram->iadd) != IRAM_IADD_AIE) ;
51333 +
51334 + for (i=0; i < (iram_size/4); i++)
51335 + WRITE_UINT32(p_Iram->idata, 0xffffffff);
51336 +
51337 + WRITE_UINT32(p_Iram->iadd, iram_size - 4);
51338 + CORE_MemoryBarrier();
51339 + while (GET_UINT32(p_Iram->idata) != 0xffffffff) ;
51340 +
51341 + return E_OK;
51342 +}
51343 +
51344 +static t_Error LoadFmanCtrlCode(t_Fm *p_Fm)
51345 +{
51346 + t_FMIramRegs *p_Iram;
51347 + int i;
51348 + uint32_t tmp;
51349 + uint8_t compTo16;
51350 +
51351 + ASSERT_COND(p_Fm);
51352 + p_Iram = (t_FMIramRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_IMEM);
51353 +
51354 + /* Enable the auto-increment */
51355 + WRITE_UINT32(p_Iram->iadd, IRAM_IADD_AIE);
51356 + while (GET_UINT32(p_Iram->iadd) != IRAM_IADD_AIE) ;
51357 +
51358 + for (i=0; i < (p_Fm->firmware.size / 4); i++)
51359 + WRITE_UINT32(p_Iram->idata, p_Fm->firmware.p_Code[i]);
51360 +
51361 + compTo16 = (uint8_t)(p_Fm->firmware.size % 16);
51362 + if (compTo16)
51363 + for (i=0; i < ((16-compTo16) / 4); i++)
51364 + WRITE_UINT32(p_Iram->idata, 0xffffffff);
51365 +
51366 + WRITE_UINT32(p_Iram->iadd,p_Fm->firmware.size-4);
51367 + while (GET_UINT32(p_Iram->iadd) != (p_Fm->firmware.size-4)) ;
51368 +
51369 + /* verify that writing has completed */
51370 + while (GET_UINT32(p_Iram->idata) != p_Fm->firmware.p_Code[(p_Fm->firmware.size / 4)-1]) ;
51371 +
51372 + if (p_Fm->fwVerify)
51373 + {
51374 + WRITE_UINT32(p_Iram->iadd, IRAM_IADD_AIE);
51375 + while (GET_UINT32(p_Iram->iadd) != IRAM_IADD_AIE) ;
51376 + for (i=0; i < (p_Fm->firmware.size / 4); i++)
51377 + {
51378 + tmp = GET_UINT32(p_Iram->idata);
51379 + if (tmp != p_Fm->firmware.p_Code[i])
51380 + RETURN_ERROR(MAJOR, E_WRITE_FAILED,
51381 + ("UCode write error : write 0x%x, read 0x%x",
51382 + p_Fm->firmware.p_Code[i],tmp));
51383 + }
51384 + WRITE_UINT32(p_Iram->iadd, 0x0);
51385 + }
51386 +
51387 + /* Enable patch from IRAM */
51388 + WRITE_UINT32(p_Iram->iready, IRAM_READY);
51389 + XX_UDelay(1000);
51390 +
51391 + DBG(INFO, ("FMan-Controller code (ver %d.%d.%d) loaded to IRAM.",
51392 + ((uint16_t *)p_Fm->firmware.p_Code)[2],
51393 + ((uint8_t *)p_Fm->firmware.p_Code)[6],
51394 + ((uint8_t *)p_Fm->firmware.p_Code)[7]));
51395 +
51396 + return E_OK;
51397 +}
51398 +
51399 +#ifdef FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173
51400 +static t_Error FwNotResetErratumBugzilla6173WA(t_Fm *p_Fm)
51401 +{
51402 + t_FMIramRegs *p_Iram = (t_FMIramRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_IMEM);
51403 + uint32_t tmpReg;
51404 + uint32_t savedSpliodn[63];
51405 +
51406 + /* write to IRAM first location the debug instruction */
51407 + WRITE_UINT32(p_Iram->iadd, 0);
51408 + while (GET_UINT32(p_Iram->iadd) != 0) ;
51409 + WRITE_UINT32(p_Iram->idata, FM_FW_DEBUG_INSTRUCTION);
51410 +
51411 + WRITE_UINT32(p_Iram->iadd, 0);
51412 + while (GET_UINT32(p_Iram->iadd) != 0) ;
51413 + while (GET_UINT32(p_Iram->idata) != FM_FW_DEBUG_INSTRUCTION) ;
51414 +
51415 + /* Enable patch from IRAM */
51416 + WRITE_UINT32(p_Iram->iready, IRAM_READY);
51417 + CORE_MemoryBarrier();
51418 + XX_UDelay(100);
51419 + IO2MemCpy32((uint8_t *)savedSpliodn,
51420 + (uint8_t *)p_Fm->p_FmBmiRegs->fmbm_spliodn,
51421 + 63*sizeof(uint32_t));
51422 +
51423 + /* reset FMAN */
51424 + WRITE_UINT32(p_Fm->p_FmFpmRegs->fm_rstc, FPM_RSTC_FM_RESET);
51425 + CORE_MemoryBarrier();
51426 + XX_UDelay(100);
51427 +
51428 + /* verify breakpoint debug status register */
51429 + tmpReg = GET_UINT32(*(uint32_t *)UINT_TO_PTR(p_Fm->baseAddr + FM_DEBUG_STATUS_REGISTER_OFFSET));
51430 + if (!tmpReg)
51431 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Invalid debug status register value is '0'"));
51432 +
51433 + /*************************************/
51434 + /* Load FMan-Controller code to IRAM */
51435 + /*************************************/
51436 + ClearIRam(p_Fm);
51437 + if (p_Fm->firmware.p_Code &&
51438 + (LoadFmanCtrlCode(p_Fm) != E_OK))
51439 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
51440 + XX_UDelay(100);
51441 +
51442 + /* reset FMAN again to start the microcode */
51443 + WRITE_UINT32(p_Fm->p_FmFpmRegs->fm_rstc, FPM_RSTC_FM_RESET);
51444 + CORE_MemoryBarrier();
51445 + XX_UDelay(100);
51446 + Mem2IOCpy32((uint8_t *)p_Fm->p_FmBmiRegs->fmbm_spliodn,
51447 + (uint8_t *)savedSpliodn,
51448 + 63*sizeof(uint32_t));
51449 +
51450 + if (fman_is_qmi_halt_not_busy_state(p_Fm->p_FmQmiRegs))
51451 + {
51452 + fman_resume(p_Fm->p_FmFpmRegs);
51453 + CORE_MemoryBarrier();
51454 + XX_UDelay(100);
51455 + }
51456 +
51457 + return E_OK;
51458 +}
51459 +#endif /* FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173 */
51460 +
51461 +static void GuestErrorIsr(t_Fm *p_Fm, uint32_t pending)
51462 +{
51463 +#define FM_G_CALL_1G_MAC_ERR_ISR(_id) \
51464 +do { \
51465 + p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id)].h_SrcHandle);\
51466 +} while (0)
51467 +#define FM_G_CALL_10G_MAC_ERR_ISR(_id) \
51468 +do { \
51469 + p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_10G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_10G_MAC0+_id)].h_SrcHandle);\
51470 +} while (0)
51471 +
51472 + /* error interrupts */
51473 + if (pending & ERR_INTR_EN_1G_MAC0)
51474 + FM_G_CALL_1G_MAC_ERR_ISR(0);
51475 + if (pending & ERR_INTR_EN_1G_MAC1)
51476 + FM_G_CALL_1G_MAC_ERR_ISR(1);
51477 + if (pending & ERR_INTR_EN_1G_MAC2)
51478 + FM_G_CALL_1G_MAC_ERR_ISR(2);
51479 + if (pending & ERR_INTR_EN_1G_MAC3)
51480 + FM_G_CALL_1G_MAC_ERR_ISR(3);
51481 + if (pending & ERR_INTR_EN_1G_MAC4)
51482 + FM_G_CALL_1G_MAC_ERR_ISR(4);
51483 + if (pending & ERR_INTR_EN_1G_MAC5)
51484 + FM_G_CALL_1G_MAC_ERR_ISR(5);
51485 + if (pending & ERR_INTR_EN_1G_MAC6)
51486 + FM_G_CALL_1G_MAC_ERR_ISR(6);
51487 + if (pending & ERR_INTR_EN_1G_MAC7)
51488 + FM_G_CALL_1G_MAC_ERR_ISR(7);
51489 + if (pending & ERR_INTR_EN_10G_MAC0)
51490 + FM_G_CALL_10G_MAC_ERR_ISR(0);
51491 + if (pending & ERR_INTR_EN_10G_MAC1)
51492 + FM_G_CALL_10G_MAC_ERR_ISR(1);
51493 +}
51494 +
51495 +static void GuestEventIsr(t_Fm *p_Fm, uint32_t pending)
51496 +{
51497 +#define FM_G_CALL_1G_MAC_ISR(_id) \
51498 +do { \
51499 + p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0+_id)].h_SrcHandle);\
51500 +} while (0)
51501 +#define FM_G_CALL_10G_MAC_ISR(_id) \
51502 +do { \
51503 + p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_10G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_10G_MAC0+_id)].h_SrcHandle);\
51504 +} while (0)
51505 +
51506 + if (pending & INTR_EN_1G_MAC0)
51507 + FM_G_CALL_1G_MAC_ISR(0);
51508 + if (pending & INTR_EN_1G_MAC1)
51509 + FM_G_CALL_1G_MAC_ISR(1);
51510 + if (pending & INTR_EN_1G_MAC2)
51511 + FM_G_CALL_1G_MAC_ISR(2);
51512 + if (pending & INTR_EN_1G_MAC3)
51513 + FM_G_CALL_1G_MAC_ISR(3);
51514 + if (pending & INTR_EN_1G_MAC4)
51515 + FM_G_CALL_1G_MAC_ISR(4);
51516 + if (pending & INTR_EN_1G_MAC5)
51517 + FM_G_CALL_1G_MAC_ISR(5);
51518 + if (pending & INTR_EN_1G_MAC6)
51519 + FM_G_CALL_1G_MAC_ISR(6);
51520 + if (pending & INTR_EN_1G_MAC7)
51521 + FM_G_CALL_1G_MAC_ISR(7);
51522 + if (pending & INTR_EN_10G_MAC0)
51523 + FM_G_CALL_10G_MAC_ISR(0);
51524 + if (pending & INTR_EN_10G_MAC1)
51525 + FM_G_CALL_10G_MAC_ISR(1);
51526 + if (pending & INTR_EN_TMR)
51527 + p_Fm->intrMng[e_FM_EV_TMR].f_Isr(p_Fm->intrMng[e_FM_EV_TMR].h_SrcHandle);
51528 +}
51529 +
51530 +#if (DPAA_VERSION >= 11)
51531 +static t_Error SetVSPWindow(t_Handle h_Fm,
51532 + uint8_t hardwarePortId,
51533 + uint8_t baseStorageProfile,
51534 + uint8_t log2NumOfProfiles)
51535 +{
51536 + t_Fm *p_Fm = (t_Fm *)h_Fm;
51537 +
51538 + ASSERT_COND(h_Fm);
51539 + ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
51540 +
51541 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
51542 + !p_Fm->p_FmBmiRegs &&
51543 + p_Fm->h_IpcSessions[0])
51544 + {
51545 + t_FmIpcVspSetPortWindow fmIpcVspSetPortWindow;
51546 + t_FmIpcMsg msg;
51547 + t_Error err = E_OK;
51548 +
51549 + memset(&msg, 0, sizeof(msg));
51550 + memset(&fmIpcVspSetPortWindow, 0, sizeof(t_FmIpcVspSetPortWindow));
51551 + fmIpcVspSetPortWindow.hardwarePortId = hardwarePortId;
51552 + fmIpcVspSetPortWindow.baseStorageProfile = baseStorageProfile;
51553 + fmIpcVspSetPortWindow.log2NumOfProfiles = log2NumOfProfiles;
51554 + msg.msgId = FM_VSP_SET_PORT_WINDOW;
51555 + memcpy(msg.msgBody, &fmIpcVspSetPortWindow, sizeof(t_FmIpcVspSetPortWindow));
51556 +
51557 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
51558 + (uint8_t*)&msg,
51559 + sizeof(msg.msgId),
51560 + NULL,
51561 + NULL,
51562 + NULL,
51563 + NULL);
51564 + if (err != E_OK)
51565 + RETURN_ERROR(MINOR, err, NO_MSG);
51566 + return E_OK;
51567 + }
51568 + else if (!p_Fm->p_FmBmiRegs)
51569 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
51570 + ("Either IPC or 'baseAddress' is required!"));
51571 +
51572 + fman_set_vsp_window(p_Fm->p_FmBmiRegs,
51573 + hardwarePortId,
51574 + baseStorageProfile,
51575 + log2NumOfProfiles);
51576 +
51577 + return E_OK;
51578 +}
51579 +
51580 +static uint8_t AllocVSPsForPartition(t_Handle h_Fm, uint8_t base, uint8_t numOfProfiles, uint8_t guestId)
51581 +{
51582 + t_Fm *p_Fm = (t_Fm *)h_Fm;
51583 + uint8_t profilesFound = 0;
51584 + int i = 0;
51585 + uint32_t intFlags;
51586 +
51587 + if (!numOfProfiles)
51588 + return E_OK;
51589 +
51590 + if ((numOfProfiles > FM_VSP_MAX_NUM_OF_ENTRIES) ||
51591 + (base + numOfProfiles > FM_VSP_MAX_NUM_OF_ENTRIES))
51592 + return (uint8_t)ILLEGAL_BASE;
51593 +
51594 + if (p_Fm->h_IpcSessions[0])
51595 + {
51596 + t_FmIpcResourceAllocParams ipcAllocParams;
51597 + t_FmIpcMsg msg;
51598 + t_FmIpcReply reply;
51599 + t_Error err;
51600 + uint32_t replyLength;
51601 +
51602 + memset(&msg, 0, sizeof(msg));
51603 + memset(&reply, 0, sizeof(reply));
51604 + memset(&ipcAllocParams, 0, sizeof(t_FmIpcResourceAllocParams));
51605 + ipcAllocParams.guestId = p_Fm->guestId;
51606 + ipcAllocParams.num = p_Fm->partNumOfVSPs;
51607 + ipcAllocParams.base = p_Fm->partVSPBase;
51608 + msg.msgId = FM_VSP_ALLOC;
51609 + memcpy(msg.msgBody, &ipcAllocParams, sizeof(t_FmIpcResourceAllocParams));
51610 + replyLength = sizeof(uint32_t) + sizeof(uint8_t);
51611 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
51612 + (uint8_t*)&msg,
51613 + sizeof(msg.msgId) + sizeof(t_FmIpcResourceAllocParams),
51614 + (uint8_t*)&reply,
51615 + &replyLength,
51616 + NULL,
51617 + NULL);
51618 + if ((err != E_OK) ||
51619 + (replyLength != (sizeof(uint32_t) + sizeof(uint8_t))))
51620 + RETURN_ERROR(MAJOR, err, NO_MSG);
51621 + else
51622 + memcpy((uint8_t*)&p_Fm->partVSPBase, reply.replyBody, sizeof(uint8_t));
51623 + if (p_Fm->partVSPBase == (uint8_t)(ILLEGAL_BASE))
51624 + RETURN_ERROR(MAJOR, err, NO_MSG);
51625 + }
51626 + if (p_Fm->guestId != NCSW_MASTER_ID)
51627 + {
51628 + DBG(WARNING, ("FM Guest mode, without IPC - can't validate VSP range!"));
51629 + return (uint8_t)ILLEGAL_BASE;
51630 + }
51631 +
51632 + intFlags = XX_LockIntrSpinlock(p_Fm->h_Spinlock);
51633 + for (i = base; i < base + numOfProfiles; i++)
51634 + if (p_Fm->p_FmSp->profiles[i].profilesMng.ownerId == (uint8_t)ILLEGAL_BASE)
51635 + profilesFound++;
51636 + else
51637 + break;
51638 +
51639 + if (profilesFound == numOfProfiles)
51640 + for (i = base; i<base + numOfProfiles; i++)
51641 + p_Fm->p_FmSp->profiles[i].profilesMng.ownerId = guestId;
51642 + else
51643 + {
51644 + XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
51645 + return (uint8_t)ILLEGAL_BASE;
51646 + }
51647 + XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
51648 +
51649 + return base;
51650 +}
51651 +
51652 +static void FreeVSPsForPartition(t_Handle h_Fm, uint8_t base, uint8_t numOfProfiles, uint8_t guestId)
51653 +{
51654 + t_Fm *p_Fm = (t_Fm *)h_Fm;
51655 + int i = 0;
51656 +
51657 + ASSERT_COND(p_Fm);
51658 +
51659 + if (p_Fm->h_IpcSessions[0])
51660 + {
51661 + t_FmIpcResourceAllocParams ipcAllocParams;
51662 + t_FmIpcMsg msg;
51663 + t_FmIpcReply reply;
51664 + uint32_t replyLength;
51665 + t_Error err;
51666 +
51667 + memset(&msg, 0, sizeof(msg));
51668 + memset(&reply, 0, sizeof(reply));
51669 + memset(&ipcAllocParams, 0, sizeof(t_FmIpcResourceAllocParams));
51670 + ipcAllocParams.guestId = p_Fm->guestId;
51671 + ipcAllocParams.num = p_Fm->partNumOfVSPs;
51672 + ipcAllocParams.base = p_Fm->partVSPBase;
51673 + msg.msgId = FM_VSP_FREE;
51674 + memcpy(msg.msgBody, &ipcAllocParams, sizeof(t_FmIpcResourceAllocParams));
51675 + replyLength = sizeof(uint32_t) + sizeof(uint8_t);
51676 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
51677 + (uint8_t*)&msg,
51678 + sizeof(msg.msgId) + sizeof(t_FmIpcResourceAllocParams),
51679 + (uint8_t*)&reply,
51680 + &replyLength,
51681 + NULL,
51682 + NULL);
51683 + if (err != E_OK)
51684 + REPORT_ERROR(MAJOR, err, NO_MSG);
51685 + return;
51686 + }
51687 + if (p_Fm->guestId != NCSW_MASTER_ID)
51688 + {
51689 + DBG(WARNING, ("FM Guest mode, without IPC - can't validate VSP range!"));
51690 + return;
51691 + }
51692 +
51693 + ASSERT_COND(p_Fm->p_FmSp);
51694 +
51695 + for (i=base; i<numOfProfiles; i++)
51696 + {
51697 + if (p_Fm->p_FmSp->profiles[i].profilesMng.ownerId == guestId)
51698 + p_Fm->p_FmSp->profiles[i].profilesMng.ownerId = (uint8_t)ILLEGAL_BASE;
51699 + else
51700 + DBG(WARNING, ("Request for freeing storage profile window which wasn't allocated to this partition"));
51701 + }
51702 +}
51703 +#endif /* (DPAA_VERSION >= 11) */
51704 +
51705 +static t_Error FmGuestHandleIpcMsgCB(t_Handle h_Fm,
51706 + uint8_t *p_Msg,
51707 + uint32_t msgLength,
51708 + uint8_t *p_Reply,
51709 + uint32_t *p_ReplyLength)
51710 +{
51711 + t_Fm *p_Fm = (t_Fm*)h_Fm;
51712 + t_FmIpcMsg *p_IpcMsg = (t_FmIpcMsg*)p_Msg;
51713 +
51714 + UNUSED(p_Reply);
51715 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
51716 + SANITY_CHECK_RETURN_ERROR((msgLength > sizeof(uint32_t)), E_INVALID_VALUE);
51717 +
51718 +#ifdef DISABLE_SANITY_CHECKS
51719 + UNUSED(msgLength);
51720 +#endif /* DISABLE_SANITY_CHECKS */
51721 +
51722 + ASSERT_COND(p_Msg);
51723 +
51724 + *p_ReplyLength = 0;
51725 +
51726 + switch (p_IpcMsg->msgId)
51727 + {
51728 + case (FM_GUEST_ISR):
51729 + {
51730 + t_FmIpcIsr ipcIsr;
51731 +
51732 + memcpy((uint8_t*)&ipcIsr, p_IpcMsg->msgBody, sizeof(t_FmIpcIsr));
51733 + if (ipcIsr.boolErr)
51734 + GuestErrorIsr(p_Fm, ipcIsr.pendingReg);
51735 + else
51736 + GuestEventIsr(p_Fm, ipcIsr.pendingReg);
51737 + break;
51738 + }
51739 + default:
51740 + *p_ReplyLength = 0;
51741 + RETURN_ERROR(MINOR, E_INVALID_SELECTION, ("command not found!!!"));
51742 + }
51743 + return E_OK;
51744 +}
51745 +
51746 +static t_Error FmHandleIpcMsgCB(t_Handle h_Fm,
51747 + uint8_t *p_Msg,
51748 + uint32_t msgLength,
51749 + uint8_t *p_Reply,
51750 + uint32_t *p_ReplyLength)
51751 +{
51752 + t_Error err;
51753 + t_Fm *p_Fm = (t_Fm*)h_Fm;
51754 + t_FmIpcMsg *p_IpcMsg = (t_FmIpcMsg*)p_Msg;
51755 + t_FmIpcReply *p_IpcReply = (t_FmIpcReply*)p_Reply;
51756 +
51757 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
51758 + SANITY_CHECK_RETURN_ERROR((msgLength >= sizeof(uint32_t)), E_INVALID_VALUE);
51759 +
51760 +#ifdef DISABLE_SANITY_CHECKS
51761 + UNUSED(msgLength);
51762 +#endif /* DISABLE_SANITY_CHECKS */
51763 +
51764 + ASSERT_COND(p_IpcMsg);
51765 +
51766 + memset(p_IpcReply, 0, (sizeof(uint8_t) * FM_IPC_MAX_REPLY_SIZE));
51767 + *p_ReplyLength = 0;
51768 +
51769 + switch (p_IpcMsg->msgId)
51770 + {
51771 + case (FM_GET_SET_PORT_PARAMS):
51772 + {
51773 + t_FmIpcPortInInitParams ipcInitParams;
51774 + t_FmInterModulePortInitParams initParams;
51775 + t_FmIpcPortOutInitParams ipcOutInitParams;
51776 +
51777 + memcpy((uint8_t*)&ipcInitParams, p_IpcMsg->msgBody, sizeof(t_FmIpcPortInInitParams));
51778 + initParams.hardwarePortId = ipcInitParams.hardwarePortId;
51779 + initParams.portType = (e_FmPortType)ipcInitParams.enumPortType;
51780 + initParams.independentMode = (bool)(ipcInitParams.boolIndependentMode);
51781 + initParams.liodnOffset = ipcInitParams.liodnOffset;
51782 + initParams.numOfTasks = ipcInitParams.numOfTasks;
51783 + initParams.numOfExtraTasks = ipcInitParams.numOfExtraTasks;
51784 + initParams.numOfOpenDmas = ipcInitParams.numOfOpenDmas;
51785 + initParams.numOfExtraOpenDmas = ipcInitParams.numOfExtraOpenDmas;
51786 + initParams.sizeOfFifo = ipcInitParams.sizeOfFifo;
51787 + initParams.extraSizeOfFifo = ipcInitParams.extraSizeOfFifo;
51788 + initParams.deqPipelineDepth = ipcInitParams.deqPipelineDepth;
51789 + initParams.maxFrameLength = ipcInitParams.maxFrameLength;
51790 + initParams.liodnBase = ipcInitParams.liodnBase;
51791 +
51792 + p_IpcReply->error = (uint32_t)FmGetSetPortParams(h_Fm, &initParams);
51793 +
51794 + ipcOutInitParams.ipcPhysAddr.high = initParams.fmMuramPhysBaseAddr.high;
51795 + ipcOutInitParams.ipcPhysAddr.low = initParams.fmMuramPhysBaseAddr.low;
51796 + ipcOutInitParams.sizeOfFifo = initParams.sizeOfFifo;
51797 + ipcOutInitParams.extraSizeOfFifo = initParams.extraSizeOfFifo;
51798 + ipcOutInitParams.numOfTasks = initParams.numOfTasks;
51799 + ipcOutInitParams.numOfExtraTasks = initParams.numOfExtraTasks;
51800 + ipcOutInitParams.numOfOpenDmas = initParams.numOfOpenDmas;
51801 + ipcOutInitParams.numOfExtraOpenDmas = initParams.numOfExtraOpenDmas;
51802 + memcpy(p_IpcReply->replyBody, (uint8_t*)&ipcOutInitParams, sizeof(ipcOutInitParams));
51803 + *p_ReplyLength = sizeof(uint32_t) + sizeof(t_FmIpcPortOutInitParams);
51804 + break;
51805 + }
51806 + case (FM_SET_SIZE_OF_FIFO):
51807 + {
51808 + t_FmIpcPortRsrcParams ipcPortRsrcParams;
51809 +
51810 + memcpy((uint8_t*)&ipcPortRsrcParams, p_IpcMsg->msgBody, sizeof(t_FmIpcPortRsrcParams));
51811 + p_IpcReply->error = (uint32_t)FmSetSizeOfFifo(h_Fm,
51812 + ipcPortRsrcParams.hardwarePortId,
51813 + &ipcPortRsrcParams.val,
51814 + &ipcPortRsrcParams.extra,
51815 + (bool)ipcPortRsrcParams.boolInitialConfig);
51816 + *p_ReplyLength = sizeof(uint32_t);
51817 + break;
51818 + }
51819 + case (FM_SET_NUM_OF_TASKS):
51820 + {
51821 + t_FmIpcPortRsrcParams ipcPortRsrcParams;
51822 +
51823 + memcpy((uint8_t*)&ipcPortRsrcParams, p_IpcMsg->msgBody, sizeof(t_FmIpcPortRsrcParams));
51824 + p_IpcReply->error = (uint32_t)FmSetNumOfTasks(h_Fm, ipcPortRsrcParams.hardwarePortId,
51825 + (uint8_t*)&ipcPortRsrcParams.val,
51826 + (uint8_t*)&ipcPortRsrcParams.extra,
51827 + (bool)ipcPortRsrcParams.boolInitialConfig);
51828 + *p_ReplyLength = sizeof(uint32_t);
51829 + break;
51830 + }
51831 + case (FM_SET_NUM_OF_OPEN_DMAS):
51832 + {
51833 + t_FmIpcPortRsrcParams ipcPortRsrcParams;
51834 +
51835 + memcpy((uint8_t*)&ipcPortRsrcParams, p_IpcMsg->msgBody, sizeof(t_FmIpcPortRsrcParams));
51836 + p_IpcReply->error = (uint32_t)FmSetNumOfOpenDmas(h_Fm, ipcPortRsrcParams.hardwarePortId,
51837 + (uint8_t*)&ipcPortRsrcParams.val,
51838 + (uint8_t*)&ipcPortRsrcParams.extra,
51839 + (bool)ipcPortRsrcParams.boolInitialConfig);
51840 + *p_ReplyLength = sizeof(uint32_t);
51841 + break;
51842 + }
51843 + case (FM_RESUME_STALLED_PORT):
51844 + *p_ReplyLength = sizeof(uint32_t);
51845 + p_IpcReply->error = (uint32_t)FmResumeStalledPort(h_Fm, p_IpcMsg->msgBody[0]);
51846 + break;
51847 + case (FM_MASTER_IS_ALIVE):
51848 + {
51849 + uint8_t guestId = p_IpcMsg->msgBody[0];
51850 + /* build the FM master partition IPC address */
51851 + memset(p_Fm->fmIpcHandlerModuleName[guestId], 0, (sizeof(char)) * MODULE_NAME_SIZE);
51852 + if (Sprint (p_Fm->fmIpcHandlerModuleName[guestId], "FM_%d_%d",p_Fm->p_FmStateStruct->fmId, guestId) != (guestId<10 ? 6:7))
51853 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
51854 + p_Fm->h_IpcSessions[guestId] = XX_IpcInitSession(p_Fm->fmIpcHandlerModuleName[guestId], p_Fm->fmModuleName);
51855 + if (p_Fm->h_IpcSessions[guestId] == NULL)
51856 + RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("FM Master IPC session for guest %d", guestId));
51857 + *(uint8_t*)(p_IpcReply->replyBody) = 1;
51858 + *p_ReplyLength = sizeof(uint32_t) + sizeof(uint8_t);
51859 + break;
51860 + }
51861 + case (FM_IS_PORT_STALLED):
51862 + {
51863 + bool tmp;
51864 +
51865 + p_IpcReply->error = (uint32_t)FmIsPortStalled(h_Fm, p_IpcMsg->msgBody[0], &tmp);
51866 + *(uint8_t*)(p_IpcReply->replyBody) = (uint8_t)tmp;
51867 + *p_ReplyLength = sizeof(uint32_t) + sizeof(uint8_t);
51868 + break;
51869 + }
51870 + case (FM_RESET_MAC):
51871 + {
51872 + t_FmIpcMacParams ipcMacParams;
51873 +
51874 + memcpy((uint8_t*)&ipcMacParams, p_IpcMsg->msgBody, sizeof(t_FmIpcMacParams));
51875 + p_IpcReply->error = (uint32_t)FmResetMac(p_Fm,
51876 + (e_FmMacType)(ipcMacParams.enumType),
51877 + ipcMacParams.id);
51878 + *p_ReplyLength = sizeof(uint32_t);
51879 + break;
51880 + }
51881 + case (FM_SET_MAC_MAX_FRAME):
51882 + {
51883 + t_FmIpcMacMaxFrameParams ipcMacMaxFrameParams;
51884 +
51885 + memcpy((uint8_t*)&ipcMacMaxFrameParams, p_IpcMsg->msgBody, sizeof(t_FmIpcMacMaxFrameParams));
51886 + err = FmSetMacMaxFrame(p_Fm,
51887 + (e_FmMacType)(ipcMacMaxFrameParams.macParams.enumType),
51888 + ipcMacMaxFrameParams.macParams.id,
51889 + ipcMacMaxFrameParams.maxFrameLength);
51890 + if (err != E_OK)
51891 + REPORT_ERROR(MINOR, err, NO_MSG);
51892 + break;
51893 + }
51894 +#if (DPAA_VERSION >= 11)
51895 + case (FM_VSP_ALLOC) :
51896 + {
51897 + t_FmIpcResourceAllocParams ipcAllocParams;
51898 + uint8_t vspBase;
51899 + memcpy(&ipcAllocParams, p_IpcMsg->msgBody, sizeof(t_FmIpcResourceAllocParams));
51900 + vspBase = AllocVSPsForPartition(h_Fm, (uint8_t)ipcAllocParams.base, (uint8_t)ipcAllocParams.num, ipcAllocParams.guestId);
51901 + memcpy(p_IpcReply->replyBody, (uint8_t*)&vspBase, sizeof(uint8_t));
51902 + *p_ReplyLength = sizeof(uint32_t) + sizeof(uint8_t);
51903 + break;
51904 + }
51905 + case (FM_VSP_FREE) :
51906 + {
51907 + t_FmIpcResourceAllocParams ipcAllocParams;
51908 + memcpy(&ipcAllocParams, p_IpcMsg->msgBody, sizeof(t_FmIpcResourceAllocParams));
51909 + FreeVSPsForPartition(h_Fm, (uint8_t)ipcAllocParams.base, (uint8_t)ipcAllocParams.num, ipcAllocParams.guestId);
51910 + break;
51911 + }
51912 + case (FM_VSP_SET_PORT_WINDOW) :
51913 + {
51914 + t_FmIpcVspSetPortWindow ipcVspSetPortWindow;
51915 + memcpy(&ipcVspSetPortWindow, p_IpcMsg->msgBody, sizeof(t_FmIpcVspSetPortWindow));
51916 + err = SetVSPWindow(h_Fm,
51917 + ipcVspSetPortWindow.hardwarePortId,
51918 + ipcVspSetPortWindow.baseStorageProfile,
51919 + ipcVspSetPortWindow.log2NumOfProfiles);
51920 + return err;
51921 + }
51922 + case (FM_SET_CONG_GRP_PFC_PRIO) :
51923 + {
51924 + t_FmIpcSetCongestionGroupPfcPriority fmIpcSetCongestionGroupPfcPriority;
51925 + memcpy(&fmIpcSetCongestionGroupPfcPriority, p_IpcMsg->msgBody, sizeof(t_FmIpcSetCongestionGroupPfcPriority));
51926 + err = FmSetCongestionGroupPFCpriority(h_Fm,
51927 + fmIpcSetCongestionGroupPfcPriority.congestionGroupId,
51928 + fmIpcSetCongestionGroupPfcPriority.priorityBitMap);
51929 + return err;
51930 + }
51931 +#endif /* (DPAA_VERSION >= 11) */
51932 +
51933 + case (FM_FREE_PORT):
51934 + {
51935 + t_FmInterModulePortFreeParams portParams;
51936 + t_FmIpcPortFreeParams ipcPortParams;
51937 +
51938 + memcpy((uint8_t*)&ipcPortParams, p_IpcMsg->msgBody, sizeof(t_FmIpcPortFreeParams));
51939 + portParams.hardwarePortId = ipcPortParams.hardwarePortId;
51940 + portParams.portType = (e_FmPortType)(ipcPortParams.enumPortType);
51941 + portParams.deqPipelineDepth = ipcPortParams.deqPipelineDepth;
51942 + FmFreePortParams(h_Fm, &portParams);
51943 + break;
51944 + }
51945 + case (FM_REGISTER_INTR):
51946 + {
51947 + t_FmIpcRegisterIntr ipcRegIntr;
51948 +
51949 + memcpy((uint8_t*)&ipcRegIntr, p_IpcMsg->msgBody, sizeof(ipcRegIntr));
51950 + p_Fm->intrMng[ipcRegIntr.event].guestId = ipcRegIntr.guestId;
51951 + break;
51952 + }
51953 + case (FM_GET_PARAMS):
51954 + {
51955 + t_FmIpcParams ipcParams;
51956 +
51957 + /* Get clock frequency */
51958 + ipcParams.fmClkFreq = p_Fm->p_FmStateStruct->fmClkFreq;
51959 + ipcParams.fmMacClkFreq = p_Fm->p_FmStateStruct->fmMacClkFreq;
51960 +
51961 + fman_get_revision(p_Fm->p_FmFpmRegs,&ipcParams.majorRev,&ipcParams.minorRev);
51962 +
51963 + memcpy(p_IpcReply->replyBody, (uint8_t*)&ipcParams, sizeof(t_FmIpcParams));
51964 + *p_ReplyLength = sizeof(uint32_t) + sizeof(t_FmIpcParams);
51965 + break;
51966 + }
51967 + case (FM_GET_FMAN_CTRL_CODE_REV):
51968 + {
51969 + t_FmCtrlCodeRevisionInfo fmanCtrlRevInfo;
51970 + t_FmIpcFmanCtrlCodeRevisionInfo ipcRevInfo;
51971 +
51972 + p_IpcReply->error = (uint32_t)FM_GetFmanCtrlCodeRevision(h_Fm, &fmanCtrlRevInfo);
51973 + ipcRevInfo.packageRev = fmanCtrlRevInfo.packageRev;
51974 + ipcRevInfo.majorRev = fmanCtrlRevInfo.majorRev;
51975 + ipcRevInfo.minorRev = fmanCtrlRevInfo.minorRev;
51976 + memcpy(p_IpcReply->replyBody, (uint8_t*)&ipcRevInfo, sizeof(t_FmIpcFmanCtrlCodeRevisionInfo));
51977 + *p_ReplyLength = sizeof(uint32_t) + sizeof(t_FmIpcFmanCtrlCodeRevisionInfo);
51978 + break;
51979 + }
51980 +
51981 + case (FM_DMA_STAT):
51982 + {
51983 + t_FmDmaStatus dmaStatus;
51984 + t_FmIpcDmaStatus ipcDmaStatus;
51985 +
51986 + FM_GetDmaStatus(h_Fm, &dmaStatus);
51987 + ipcDmaStatus.boolCmqNotEmpty = (uint8_t)dmaStatus.cmqNotEmpty;
51988 + ipcDmaStatus.boolBusError = (uint8_t)dmaStatus.busError;
51989 + ipcDmaStatus.boolReadBufEccError = (uint8_t)dmaStatus.readBufEccError;
51990 + ipcDmaStatus.boolWriteBufEccSysError = (uint8_t)dmaStatus.writeBufEccSysError;
51991 + ipcDmaStatus.boolWriteBufEccFmError = (uint8_t)dmaStatus.writeBufEccFmError;
51992 + ipcDmaStatus.boolSinglePortEccError = (uint8_t)dmaStatus.singlePortEccError;
51993 + memcpy(p_IpcReply->replyBody, (uint8_t*)&ipcDmaStatus, sizeof(t_FmIpcDmaStatus));
51994 + *p_ReplyLength = sizeof(uint32_t) + sizeof(t_FmIpcDmaStatus);
51995 + break;
51996 + }
51997 + case (FM_ALLOC_FMAN_CTRL_EVENT_REG):
51998 + p_IpcReply->error = (uint32_t)FmAllocFmanCtrlEventReg(h_Fm, (uint8_t*)p_IpcReply->replyBody);
51999 + *p_ReplyLength = sizeof(uint32_t) + sizeof(uint8_t);
52000 + break;
52001 + case (FM_FREE_FMAN_CTRL_EVENT_REG):
52002 + FmFreeFmanCtrlEventReg(h_Fm, p_IpcMsg->msgBody[0]);
52003 + break;
52004 + case (FM_GET_TIMESTAMP_SCALE):
52005 + {
52006 + uint32_t timeStamp = FmGetTimeStampScale(h_Fm);
52007 +
52008 + memcpy(p_IpcReply->replyBody, (uint8_t*)&timeStamp, sizeof(uint32_t));
52009 + *p_ReplyLength = sizeof(uint32_t) + sizeof(uint32_t);
52010 + break;
52011 + }
52012 + case (FM_GET_COUNTER):
52013 + {
52014 + e_FmCounters inCounter;
52015 + uint32_t outCounter;
52016 +
52017 + memcpy((uint8_t*)&inCounter, p_IpcMsg->msgBody, sizeof(uint32_t));
52018 + outCounter = FM_GetCounter(h_Fm, inCounter);
52019 + memcpy(p_IpcReply->replyBody, (uint8_t*)&outCounter, sizeof(uint32_t));
52020 + *p_ReplyLength = sizeof(uint32_t) + sizeof(uint32_t);
52021 + break;
52022 + }
52023 + case (FM_SET_FMAN_CTRL_EVENTS_ENABLE):
52024 + {
52025 + t_FmIpcFmanEvents ipcFmanEvents;
52026 +
52027 + memcpy((uint8_t*)&ipcFmanEvents, p_IpcMsg->msgBody, sizeof(t_FmIpcFmanEvents));
52028 + FmSetFmanCtrlIntr(h_Fm,
52029 + ipcFmanEvents.eventRegId,
52030 + ipcFmanEvents.enableEvents);
52031 + break;
52032 + }
52033 + case (FM_GET_FMAN_CTRL_EVENTS_ENABLE):
52034 + {
52035 + uint32_t tmp = FmGetFmanCtrlIntr(h_Fm, p_IpcMsg->msgBody[0]);
52036 +
52037 + memcpy(p_IpcReply->replyBody, (uint8_t*)&tmp, sizeof(uint32_t));
52038 + *p_ReplyLength = sizeof(uint32_t) + sizeof(uint32_t);
52039 + break;
52040 + }
52041 + case (FM_GET_PHYS_MURAM_BASE):
52042 + {
52043 + t_FmPhysAddr physAddr;
52044 + t_FmIpcPhysAddr ipcPhysAddr;
52045 +
52046 + FmGetPhysicalMuramBase(h_Fm, &physAddr);
52047 + ipcPhysAddr.high = physAddr.high;
52048 + ipcPhysAddr.low = physAddr.low;
52049 + memcpy(p_IpcReply->replyBody, (uint8_t*)&ipcPhysAddr, sizeof(t_FmIpcPhysAddr));
52050 + *p_ReplyLength = sizeof(uint32_t) + sizeof(t_FmIpcPhysAddr);
52051 + break;
52052 + }
52053 + case (FM_ENABLE_RAM_ECC):
52054 + {
52055 + if (((err = FM_EnableRamsEcc(h_Fm)) != E_OK) ||
52056 + ((err = FM_SetException(h_Fm, e_FM_EX_IRAM_ECC, TRUE)) != E_OK) ||
52057 + ((err = FM_SetException(h_Fm, e_FM_EX_MURAM_ECC, TRUE)) != E_OK))
52058 +#if (!(defined(DEBUG_ERRORS)) || (DEBUG_ERRORS == 0))
52059 + UNUSED(err);
52060 +#else
52061 + REPORT_ERROR(MINOR, err, NO_MSG);
52062 +#endif /* (!(defined(DEBUG_ERRORS)) || (DEBUG_ERRORS == 0)) */
52063 + break;
52064 + }
52065 + case (FM_DISABLE_RAM_ECC):
52066 + {
52067 +
52068 + if (((err = FM_SetException(h_Fm, e_FM_EX_IRAM_ECC, FALSE)) != E_OK) ||
52069 + ((err = FM_SetException(h_Fm, e_FM_EX_MURAM_ECC, FALSE)) != E_OK) ||
52070 + ((err = FM_DisableRamsEcc(h_Fm)) != E_OK))
52071 +#if (!(defined(DEBUG_ERRORS)) || (DEBUG_ERRORS == 0))
52072 + UNUSED(err);
52073 +#else
52074 + REPORT_ERROR(MINOR, err, NO_MSG);
52075 +#endif /* (!(defined(DEBUG_ERRORS)) || (DEBUG_ERRORS == 0)) */
52076 + break;
52077 + }
52078 + case (FM_SET_NUM_OF_FMAN_CTRL):
52079 + {
52080 + t_FmIpcPortNumOfFmanCtrls ipcPortNumOfFmanCtrls;
52081 +
52082 + memcpy((uint8_t*)&ipcPortNumOfFmanCtrls, p_IpcMsg->msgBody, sizeof(t_FmIpcPortNumOfFmanCtrls));
52083 + err = FmSetNumOfRiscsPerPort(h_Fm,
52084 + ipcPortNumOfFmanCtrls.hardwarePortId,
52085 + ipcPortNumOfFmanCtrls.numOfFmanCtrls,
52086 + ipcPortNumOfFmanCtrls.orFmanCtrl);
52087 + if (err != E_OK)
52088 + REPORT_ERROR(MINOR, err, NO_MSG);
52089 + break;
52090 + }
52091 +#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
52092 + case (FM_10G_TX_ECC_WA):
52093 + p_IpcReply->error = (uint32_t)Fm10GTxEccWorkaround(h_Fm, p_IpcMsg->msgBody[0]);
52094 + *p_ReplyLength = sizeof(uint32_t);
52095 + break;
52096 +#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
52097 + default:
52098 + *p_ReplyLength = 0;
52099 + RETURN_ERROR(MINOR, E_INVALID_SELECTION, ("command not found!!!"));
52100 + }
52101 + return E_OK;
52102 +}
52103 +
52104 +
52105 +/****************************************/
52106 +/* Inter-Module functions */
52107 +/****************************************/
52108 +#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
52109 +t_Error Fm10GTxEccWorkaround(t_Handle h_Fm, uint8_t macId)
52110 +{
52111 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52112 + t_Error err = E_OK;
52113 + t_FmIpcMsg msg;
52114 + t_FmIpcReply reply;
52115 + uint32_t replyLength;
52116 + uint8_t rxHardwarePortId, txHardwarePortId;
52117 + struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
52118 +
52119 + if (p_Fm->guestId != NCSW_MASTER_ID)
52120 + {
52121 + memset(&msg, 0, sizeof(msg));
52122 + memset(&reply, 0, sizeof(reply));
52123 + msg.msgId = FM_10G_TX_ECC_WA;
52124 + msg.msgBody[0] = macId;
52125 + replyLength = sizeof(uint32_t);
52126 + if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
52127 + (uint8_t*)&msg,
52128 + sizeof(msg.msgId)+sizeof(macId),
52129 + (uint8_t*)&reply,
52130 + &replyLength,
52131 + NULL,
52132 + NULL)) != E_OK)
52133 + RETURN_ERROR(MINOR, err, NO_MSG);
52134 + if (replyLength != sizeof(uint32_t))
52135 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
52136 + return (t_Error)(reply.error);
52137 + }
52138 +
52139 + SANITY_CHECK_RETURN_ERROR((macId == 0), E_NOT_SUPPORTED);
52140 + SANITY_CHECK_RETURN_ERROR(IsFmanCtrlCodeLoaded(p_Fm), E_INVALID_STATE);
52141 +
52142 + rxHardwarePortId = SwPortIdToHwPortId(e_FM_PORT_TYPE_RX_10G,
52143 + macId,
52144 + p_Fm->p_FmStateStruct->revInfo.majorRev,
52145 + p_Fm->p_FmStateStruct->revInfo.minorRev);
52146 + txHardwarePortId = SwPortIdToHwPortId(e_FM_PORT_TYPE_TX_10G,
52147 + macId,
52148 + p_Fm->p_FmStateStruct->revInfo.majorRev,
52149 + p_Fm->p_FmStateStruct->revInfo.minorRev);
52150 + if ((p_Fm->p_FmStateStruct->portsTypes[rxHardwarePortId] != e_FM_PORT_TYPE_DUMMY) ||
52151 + (p_Fm->p_FmStateStruct->portsTypes[txHardwarePortId] != e_FM_PORT_TYPE_DUMMY))
52152 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
52153 + ("MAC should be initialized prior to Rx and Tx ports!"));
52154 +
52155 + return fman_set_erratum_10gmac_a004_wa(fpm_rg);
52156 +}
52157 +#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
52158 +
52159 +uint16_t FmGetTnumAgingPeriod(t_Handle h_Fm)
52160 +{
52161 + t_Fm *p_Fm = (t_Fm *)h_Fm;
52162 +
52163 + SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, 0);
52164 + SANITY_CHECK_RETURN_VALUE(!p_Fm->p_FmDriverParam, E_INVALID_STATE, 0);
52165 +
52166 + return p_Fm->tnumAgingPeriod;
52167 +}
52168 +
52169 +t_Error FmSetPortPreFetchConfiguration(t_Handle h_Fm,
52170 + uint8_t portNum,
52171 + bool preFetchConfigured)
52172 +{
52173 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52174 +
52175 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
52176 + SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
52177 +
52178 + p_Fm->portsPreFetchConfigured[portNum] = TRUE;
52179 + p_Fm->portsPreFetchValue[portNum] = preFetchConfigured;
52180 +
52181 + return E_OK;
52182 +}
52183 +
52184 +t_Error FmGetPortPreFetchConfiguration(t_Handle h_Fm,
52185 + uint8_t portNum,
52186 + bool *p_PortConfigured,
52187 + bool *p_PreFetchConfigured)
52188 +{
52189 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52190 +
52191 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
52192 + SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
52193 +
52194 + /* If the prefetch wasn't configured yet (not enable or disabled)
52195 + we return the value TRUE as it was already configured */
52196 + if (!p_Fm->portsPreFetchConfigured[portNum])
52197 + {
52198 + *p_PortConfigured = FALSE;
52199 + *p_PreFetchConfigured = FALSE;
52200 + }
52201 + else
52202 + {
52203 + *p_PortConfigured = TRUE;
52204 + *p_PreFetchConfigured = (p_Fm->portsPreFetchConfigured[portNum]);
52205 + }
52206 +
52207 + return E_OK;
52208 +}
52209 +
52210 +t_Error FmSetCongestionGroupPFCpriority(t_Handle h_Fm,
52211 + uint32_t congestionGroupId,
52212 + uint8_t priorityBitMap)
52213 +{
52214 + t_Fm *p_Fm = (t_Fm *)h_Fm;
52215 + uint32_t regNum;
52216 +
52217 + ASSERT_COND(h_Fm);
52218 +
52219 + if (congestionGroupId > FM_PORT_NUM_OF_CONGESTION_GRPS)
52220 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
52221 + ("Congestion group ID bigger than %d",
52222 + FM_PORT_NUM_OF_CONGESTION_GRPS));
52223 +
52224 + if (p_Fm->guestId == NCSW_MASTER_ID)
52225 + {
52226 + ASSERT_COND(p_Fm->baseAddr);
52227 + regNum = (FM_PORT_NUM_OF_CONGESTION_GRPS - 1 - congestionGroupId) / 4;
52228 + fman_set_congestion_group_pfc_priority((uint32_t *)((p_Fm->baseAddr+FM_MM_CGP)),
52229 + congestionGroupId,
52230 + priorityBitMap,
52231 + regNum);
52232 + }
52233 + else if (p_Fm->h_IpcSessions[0])
52234 + {
52235 + t_Error err;
52236 + t_FmIpcMsg msg;
52237 + t_FmIpcSetCongestionGroupPfcPriority fmIpcSetCongestionGroupPfcPriority;
52238 +
52239 + memset(&msg, 0, sizeof(msg));
52240 + memset(&fmIpcSetCongestionGroupPfcPriority, 0, sizeof(t_FmIpcSetCongestionGroupPfcPriority));
52241 + fmIpcSetCongestionGroupPfcPriority.congestionGroupId = congestionGroupId;
52242 + fmIpcSetCongestionGroupPfcPriority.priorityBitMap = priorityBitMap;
52243 +
52244 + msg.msgId = FM_SET_CONG_GRP_PFC_PRIO;
52245 + memcpy(msg.msgBody, &fmIpcSetCongestionGroupPfcPriority, sizeof(t_FmIpcSetCongestionGroupPfcPriority));
52246 +
52247 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
52248 + (uint8_t*)&msg,
52249 + sizeof(msg.msgId),
52250 + NULL,
52251 + NULL,
52252 + NULL,
52253 + NULL);
52254 + if (err != E_OK)
52255 + RETURN_ERROR(MINOR, err, NO_MSG);
52256 + }
52257 + else
52258 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("guest without IPC!"));
52259 +
52260 + return E_OK;
52261 +}
52262 +
52263 +uintptr_t FmGetPcdPrsBaseAddr(t_Handle h_Fm)
52264 +{
52265 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52266 +
52267 + SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, 0);
52268 +
52269 + if (!p_Fm->baseAddr)
52270 + {
52271 + REPORT_ERROR(MAJOR, E_INVALID_STATE,
52272 + ("No base-addr; probably Guest with IPC!"));
52273 + return 0;
52274 + }
52275 +
52276 + return (p_Fm->baseAddr + FM_MM_PRS);
52277 +}
52278 +
52279 +uintptr_t FmGetPcdKgBaseAddr(t_Handle h_Fm)
52280 +{
52281 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52282 +
52283 + SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, 0);
52284 +
52285 + if (!p_Fm->baseAddr)
52286 + {
52287 + REPORT_ERROR(MAJOR, E_INVALID_STATE,
52288 + ("No base-addr; probably Guest with IPC!"));
52289 + return 0;
52290 + }
52291 +
52292 + return (p_Fm->baseAddr + FM_MM_KG);
52293 +}
52294 +
52295 +uintptr_t FmGetPcdPlcrBaseAddr(t_Handle h_Fm)
52296 +{
52297 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52298 +
52299 + SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, 0);
52300 +
52301 + if (!p_Fm->baseAddr)
52302 + {
52303 + REPORT_ERROR(MAJOR, E_INVALID_STATE,
52304 + ("No base-addr; probably Guest with IPC!"));
52305 + return 0;
52306 + }
52307 +
52308 + return (p_Fm->baseAddr + FM_MM_PLCR);
52309 +}
52310 +
52311 +#if (DPAA_VERSION >= 11)
52312 +uintptr_t FmGetVSPBaseAddr(t_Handle h_Fm)
52313 +{
52314 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52315 +
52316 + SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, 0);
52317 +
52318 + return p_Fm->vspBaseAddr;
52319 +}
52320 +#endif /* (DPAA_VERSION >= 11) */
52321 +
52322 +t_Handle FmGetMuramHandle(t_Handle h_Fm)
52323 +{
52324 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52325 +
52326 + SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, NULL);
52327 +
52328 + return (p_Fm->h_FmMuram);
52329 +}
52330 +
52331 +void FmGetPhysicalMuramBase(t_Handle h_Fm, t_FmPhysAddr *p_FmPhysAddr)
52332 +{
52333 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52334 +
52335 + if (p_Fm->fmMuramPhysBaseAddr)
52336 + {
52337 + /* General FM driver initialization */
52338 + p_FmPhysAddr->low = (uint32_t)p_Fm->fmMuramPhysBaseAddr;
52339 + p_FmPhysAddr->high = (uint8_t)((p_Fm->fmMuramPhysBaseAddr & 0x000000ff00000000LL) >> 32);
52340 + return;
52341 + }
52342 +
52343 + ASSERT_COND(p_Fm->guestId != NCSW_MASTER_ID);
52344 +
52345 + if (p_Fm->h_IpcSessions[0])
52346 + {
52347 + t_Error err;
52348 + t_FmIpcMsg msg;
52349 + t_FmIpcReply reply;
52350 + uint32_t replyLength;
52351 + t_FmIpcPhysAddr ipcPhysAddr;
52352 +
52353 + memset(&msg, 0, sizeof(msg));
52354 + memset(&reply, 0, sizeof(reply));
52355 + msg.msgId = FM_GET_PHYS_MURAM_BASE;
52356 + replyLength = sizeof(uint32_t) + sizeof(t_FmPhysAddr);
52357 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
52358 + (uint8_t*)&msg,
52359 + sizeof(msg.msgId),
52360 + (uint8_t*)&reply,
52361 + &replyLength,
52362 + NULL,
52363 + NULL);
52364 + if (err != E_OK)
52365 + {
52366 + REPORT_ERROR(MINOR, err, NO_MSG);
52367 + return;
52368 + }
52369 + if (replyLength != (sizeof(uint32_t) + sizeof(t_FmPhysAddr)))
52370 + {
52371 + REPORT_ERROR(MINOR, E_INVALID_VALUE,("IPC reply length mismatch"));
52372 + return;
52373 + }
52374 + memcpy((uint8_t*)&ipcPhysAddr, reply.replyBody, sizeof(t_FmIpcPhysAddr));
52375 + p_FmPhysAddr->high = ipcPhysAddr.high;
52376 + p_FmPhysAddr->low = ipcPhysAddr.low;
52377 + }
52378 + else
52379 + REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
52380 + ("running in guest-mode without neither IPC nor mapped register!"));
52381 +}
52382 +
52383 +#if (DPAA_VERSION >= 11)
52384 +t_Error FmVSPAllocForPort (t_Handle h_Fm,
52385 + e_FmPortType portType,
52386 + uint8_t portId,
52387 + uint8_t numOfVSPs)
52388 +{
52389 + t_Fm *p_Fm = (t_Fm *)h_Fm;
52390 + t_Error err = E_OK;
52391 + uint32_t profilesFound, intFlags;
52392 + uint8_t first, i;
52393 + uint8_t log2Num;
52394 + uint8_t swPortIndex=0, hardwarePortId;
52395 +
52396 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
52397 +
52398 + if (!numOfVSPs)
52399 + return E_OK;
52400 +
52401 + if (numOfVSPs > FM_VSP_MAX_NUM_OF_ENTRIES)
52402 + RETURN_ERROR(MINOR, E_INVALID_VALUE, ("numProfiles can not be bigger than %d.",FM_VSP_MAX_NUM_OF_ENTRIES));
52403 +
52404 + if (!POWER_OF_2(numOfVSPs))
52405 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numProfiles must be a power of 2."));
52406 +
52407 + LOG2((uint64_t)numOfVSPs, log2Num);
52408 +
52409 + if ((log2Num == 0) || (p_Fm->partVSPBase == 0))
52410 + first = 0;
52411 + else
52412 + first = 1<<log2Num;
52413 +
52414 + if (first > (p_Fm->partVSPBase + p_Fm->partNumOfVSPs))
52415 + RETURN_ERROR(MINOR, E_INVALID_VALUE, ("can not allocate storage profile port window"));
52416 +
52417 + if (first < p_Fm->partVSPBase)
52418 + while (first < p_Fm->partVSPBase)
52419 + first = first + numOfVSPs;
52420 +
52421 + if ((first + numOfVSPs) > (p_Fm->partVSPBase + p_Fm->partNumOfVSPs))
52422 + RETURN_ERROR(MINOR, E_INVALID_VALUE, ("can not allocate storage profile port window"));
52423 +
52424 + intFlags = XX_LockIntrSpinlock(p_Fm->h_Spinlock);
52425 + profilesFound = 0;
52426 + for (i=first; i < p_Fm->partVSPBase + p_Fm->partNumOfVSPs; )
52427 + {
52428 + if (!p_Fm->p_FmSp->profiles[i].profilesMng.allocated)
52429 + {
52430 + profilesFound++;
52431 + i++;
52432 + if (profilesFound == numOfVSPs)
52433 + break;
52434 + }
52435 + else
52436 + {
52437 + profilesFound = 0;
52438 + /* advance i to the next aligned address */
52439 + first = i = (uint8_t)(first + numOfVSPs);
52440 + }
52441 + }
52442 + if (profilesFound == numOfVSPs)
52443 + for (i = first; i<first + numOfVSPs; i++)
52444 + p_Fm->p_FmSp->profiles[i].profilesMng.allocated = TRUE;
52445 + else
52446 + {
52447 + XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
52448 + RETURN_ERROR(MINOR, E_FULL, ("No profiles."));
52449 + }
52450 +
52451 + hardwarePortId = SwPortIdToHwPortId(portType,
52452 + portId,
52453 + p_Fm->p_FmStateStruct->revInfo.majorRev,
52454 + p_Fm->p_FmStateStruct->revInfo.minorRev);
52455 + HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
52456 +
52457 + p_Fm->p_FmSp->portsMapping[swPortIndex].numOfProfiles = numOfVSPs;
52458 + p_Fm->p_FmSp->portsMapping[swPortIndex].profilesBase = first;
52459 +
52460 + if ((err = SetVSPWindow(h_Fm,hardwarePortId, first,log2Num)) != E_OK)
52461 + for (i = first; i < first + numOfVSPs; i++)
52462 + p_Fm->p_FmSp->profiles[i].profilesMng.allocated = FALSE;
52463 +
52464 + XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
52465 +
52466 + return err;
52467 +}
52468 +
52469 +t_Error FmVSPFreeForPort(t_Handle h_Fm,
52470 + e_FmPortType portType,
52471 + uint8_t portId)
52472 +{
52473 + t_Fm *p_Fm = (t_Fm *)h_Fm;
52474 + uint8_t swPortIndex=0, hardwarePortId, first, numOfVSPs, i;
52475 + uint32_t intFlags;
52476 +
52477 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
52478 +
52479 + hardwarePortId = SwPortIdToHwPortId(portType,
52480 + portId,
52481 + p_Fm->p_FmStateStruct->revInfo.majorRev,
52482 + p_Fm->p_FmStateStruct->revInfo.minorRev);
52483 + HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
52484 +
52485 + numOfVSPs = (uint8_t)p_Fm->p_FmSp->portsMapping[swPortIndex].numOfProfiles;
52486 + first = (uint8_t)p_Fm->p_FmSp->portsMapping[swPortIndex].profilesBase;
52487 +
52488 + intFlags = XX_LockIntrSpinlock(p_Fm->h_Spinlock);
52489 + for (i = first; i < first + numOfVSPs; i++)
52490 + p_Fm->p_FmSp->profiles[i].profilesMng.allocated = FALSE;
52491 + XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
52492 +
52493 + p_Fm->p_FmSp->portsMapping[swPortIndex].numOfProfiles = 0;
52494 + p_Fm->p_FmSp->portsMapping[swPortIndex].profilesBase = 0;
52495 +
52496 + return E_OK;
52497 +}
52498 +#endif /* (DPAA_VERSION >= 11) */
52499 +
52500 +t_Error FmAllocFmanCtrlEventReg(t_Handle h_Fm, uint8_t *p_EventId)
52501 +{
52502 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52503 + uint8_t i;
52504 +
52505 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
52506 +
52507 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
52508 + p_Fm->h_IpcSessions[0])
52509 + {
52510 + t_Error err;
52511 + t_FmIpcMsg msg;
52512 + t_FmIpcReply reply;
52513 + uint32_t replyLength;
52514 +
52515 + memset(&msg, 0, sizeof(msg));
52516 + memset(&reply, 0, sizeof(reply));
52517 + msg.msgId = FM_ALLOC_FMAN_CTRL_EVENT_REG;
52518 + replyLength = sizeof(uint32_t) + sizeof(uint8_t);
52519 + if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
52520 + (uint8_t*)&msg,
52521 + sizeof(msg.msgId),
52522 + (uint8_t*)&reply,
52523 + &replyLength,
52524 + NULL,
52525 + NULL)) != E_OK)
52526 + RETURN_ERROR(MAJOR, err, NO_MSG);
52527 +
52528 + if (replyLength != (sizeof(uint32_t) + sizeof(uint8_t)))
52529 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
52530 +
52531 + *p_EventId = *(uint8_t*)(reply.replyBody);
52532 +
52533 + return (t_Error)(reply.error);
52534 + }
52535 + else if (p_Fm->guestId != NCSW_MASTER_ID)
52536 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
52537 + ("running in guest-mode without IPC!"));
52538 +
52539 + for (i=0;i<FM_NUM_OF_FMAN_CTRL_EVENT_REGS;i++)
52540 + if (!p_Fm->usedEventRegs[i])
52541 + {
52542 + p_Fm->usedEventRegs[i] = TRUE;
52543 + *p_EventId = i;
52544 + break;
52545 + }
52546 +
52547 + if (i==FM_NUM_OF_FMAN_CTRL_EVENT_REGS)
52548 + RETURN_ERROR(MAJOR, E_BUSY, ("No resource - FMan controller event register."));
52549 +
52550 + return E_OK;
52551 +}
52552 +
52553 +void FmFreeFmanCtrlEventReg(t_Handle h_Fm, uint8_t eventId)
52554 +{
52555 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52556 +
52557 + SANITY_CHECK_RETURN(p_Fm, E_INVALID_HANDLE);
52558 +
52559 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
52560 + p_Fm->h_IpcSessions[0])
52561 + {
52562 + t_Error err;
52563 + t_FmIpcMsg msg;
52564 +
52565 + memset(&msg, 0, sizeof(msg));
52566 + msg.msgId = FM_FREE_FMAN_CTRL_EVENT_REG;
52567 + msg.msgBody[0] = eventId;
52568 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
52569 + (uint8_t*)&msg,
52570 + sizeof(msg.msgId)+sizeof(eventId),
52571 + NULL,
52572 + NULL,
52573 + NULL,
52574 + NULL);
52575 + if (err != E_OK)
52576 + REPORT_ERROR(MINOR, err, NO_MSG);
52577 + return;
52578 + }
52579 + else if (p_Fm->guestId != NCSW_MASTER_ID)
52580 + {
52581 + REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
52582 + ("running in guest-mode without IPC!"));
52583 + return;
52584 + }
52585 +
52586 + ((t_Fm*)h_Fm)->usedEventRegs[eventId] = FALSE;
52587 +}
52588 +
52589 +void FmSetFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId, uint32_t enableEvents)
52590 +{
52591 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52592 + struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
52593 +
52594 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
52595 + !p_Fm->p_FmFpmRegs &&
52596 + p_Fm->h_IpcSessions[0])
52597 + {
52598 + t_FmIpcFmanEvents fmanCtrl;
52599 + t_Error err;
52600 + t_FmIpcMsg msg;
52601 +
52602 + fmanCtrl.eventRegId = eventRegId;
52603 + fmanCtrl.enableEvents = enableEvents;
52604 + memset(&msg, 0, sizeof(msg));
52605 + msg.msgId = FM_SET_FMAN_CTRL_EVENTS_ENABLE;
52606 + memcpy(msg.msgBody, &fmanCtrl, sizeof(fmanCtrl));
52607 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
52608 + (uint8_t*)&msg,
52609 + sizeof(msg.msgId)+sizeof(fmanCtrl),
52610 + NULL,
52611 + NULL,
52612 + NULL,
52613 + NULL);
52614 + if (err != E_OK)
52615 + REPORT_ERROR(MINOR, err, NO_MSG);
52616 + return;
52617 + }
52618 + else if (!p_Fm->p_FmFpmRegs)
52619 + {
52620 + REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
52621 + ("Either IPC or 'baseAddress' is required!"));
52622 + return;
52623 + }
52624 +
52625 + ASSERT_COND(eventRegId < FM_NUM_OF_FMAN_CTRL_EVENT_REGS);
52626 + fman_set_ctrl_intr(fpm_rg, eventRegId, enableEvents);
52627 +}
52628 +
52629 +uint32_t FmGetFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId)
52630 +{
52631 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52632 + struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
52633 +
52634 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
52635 + !p_Fm->p_FmFpmRegs &&
52636 + p_Fm->h_IpcSessions[0])
52637 + {
52638 + t_Error err;
52639 + t_FmIpcMsg msg;
52640 + t_FmIpcReply reply;
52641 + uint32_t replyLength, ctrlIntr;
52642 +
52643 + memset(&msg, 0, sizeof(msg));
52644 + memset(&reply, 0, sizeof(reply));
52645 + msg.msgId = FM_GET_FMAN_CTRL_EVENTS_ENABLE;
52646 + msg.msgBody[0] = eventRegId;
52647 + replyLength = sizeof(uint32_t) + sizeof(uint32_t);
52648 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
52649 + (uint8_t*)&msg,
52650 + sizeof(msg.msgId)+sizeof(eventRegId),
52651 + (uint8_t*)&reply,
52652 + &replyLength,
52653 + NULL,
52654 + NULL);
52655 + if (err != E_OK)
52656 + {
52657 + REPORT_ERROR(MINOR, err, NO_MSG);
52658 + return 0;
52659 + }
52660 + if (replyLength != (sizeof(uint32_t) + sizeof(uint32_t)))
52661 + {
52662 + REPORT_ERROR(MINOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
52663 + return 0;
52664 + }
52665 + memcpy((uint8_t*)&ctrlIntr, reply.replyBody, sizeof(uint32_t));
52666 + return ctrlIntr;
52667 + }
52668 + else if (!p_Fm->p_FmFpmRegs)
52669 + {
52670 + REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
52671 + ("Either IPC or 'baseAddress' is required!"));
52672 + return 0;
52673 + }
52674 +
52675 + return fman_get_ctrl_intr(fpm_rg, eventRegId);
52676 +}
52677 +
52678 +void FmRegisterIntr(t_Handle h_Fm,
52679 + e_FmEventModules module,
52680 + uint8_t modId,
52681 + e_FmIntrType intrType,
52682 + void (*f_Isr) (t_Handle h_Arg),
52683 + t_Handle h_Arg)
52684 +{
52685 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52686 + int event = 0;
52687 +
52688 + ASSERT_COND(h_Fm);
52689 +
52690 + GET_FM_MODULE_EVENT(module, modId, intrType, event);
52691 + ASSERT_COND(event < e_FM_EV_DUMMY_LAST);
52692 +
52693 + /* register in local FM structure */
52694 + p_Fm->intrMng[event].f_Isr = f_Isr;
52695 + p_Fm->intrMng[event].h_SrcHandle = h_Arg;
52696 +
52697 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
52698 + p_Fm->h_IpcSessions[0])
52699 + {
52700 + t_FmIpcRegisterIntr fmIpcRegisterIntr;
52701 + t_Error err;
52702 + t_FmIpcMsg msg;
52703 +
52704 + /* register in Master FM structure */
52705 + fmIpcRegisterIntr.event = (uint32_t)event;
52706 + fmIpcRegisterIntr.guestId = p_Fm->guestId;
52707 + memset(&msg, 0, sizeof(msg));
52708 + msg.msgId = FM_REGISTER_INTR;
52709 + memcpy(msg.msgBody, &fmIpcRegisterIntr, sizeof(fmIpcRegisterIntr));
52710 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
52711 + (uint8_t*)&msg,
52712 + sizeof(msg.msgId) + sizeof(fmIpcRegisterIntr),
52713 + NULL,
52714 + NULL,
52715 + NULL,
52716 + NULL);
52717 + if (err != E_OK)
52718 + REPORT_ERROR(MINOR, err, NO_MSG);
52719 + }
52720 + else if (p_Fm->guestId != NCSW_MASTER_ID)
52721 + REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
52722 + ("running in guest-mode without IPC!"));
52723 +}
52724 +
52725 +void FmUnregisterIntr(t_Handle h_Fm,
52726 + e_FmEventModules module,
52727 + uint8_t modId,
52728 + e_FmIntrType intrType)
52729 +{
52730 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52731 + int event = 0;
52732 +
52733 + ASSERT_COND(h_Fm);
52734 +
52735 + GET_FM_MODULE_EVENT(module, modId,intrType, event);
52736 + ASSERT_COND(event < e_FM_EV_DUMMY_LAST);
52737 +
52738 + p_Fm->intrMng[event].f_Isr = UnimplementedIsr;
52739 + p_Fm->intrMng[event].h_SrcHandle = NULL;
52740 +}
52741 +
52742 +void FmRegisterFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId, void (*f_Isr) (t_Handle h_Arg, uint32_t event), t_Handle h_Arg)
52743 +{
52744 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52745 +
52746 + ASSERT_COND(eventRegId<FM_NUM_OF_FMAN_CTRL_EVENT_REGS);
52747 +
52748 + if (p_Fm->guestId != NCSW_MASTER_ID)
52749 + {
52750 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM in guest-mode"));
52751 + return;
52752 + }
52753 +
52754 + p_Fm->fmanCtrlIntr[eventRegId].f_Isr = f_Isr;
52755 + p_Fm->fmanCtrlIntr[eventRegId].h_SrcHandle = h_Arg;
52756 +}
52757 +
52758 +void FmUnregisterFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId)
52759 +{
52760 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52761 +
52762 + ASSERT_COND(eventRegId<FM_NUM_OF_FMAN_CTRL_EVENT_REGS);
52763 +
52764 + if (p_Fm->guestId != NCSW_MASTER_ID)
52765 + {
52766 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM in guest-mode"));
52767 + return;
52768 + }
52769 +
52770 + p_Fm->fmanCtrlIntr[eventRegId].f_Isr = UnimplementedFmanCtrlIsr;
52771 + p_Fm->fmanCtrlIntr[eventRegId].h_SrcHandle = NULL;
52772 +}
52773 +
52774 +void FmRegisterPcd(t_Handle h_Fm, t_Handle h_FmPcd)
52775 +{
52776 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52777 +
52778 + if (p_Fm->h_Pcd)
52779 + REPORT_ERROR(MAJOR, E_ALREADY_EXISTS, ("PCD already set"));
52780 +
52781 + p_Fm->h_Pcd = h_FmPcd;
52782 +}
52783 +
52784 +void FmUnregisterPcd(t_Handle h_Fm)
52785 +{
52786 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52787 +
52788 + if (!p_Fm->h_Pcd)
52789 + REPORT_ERROR(MAJOR, E_NOT_FOUND, ("PCD handle!"));
52790 +
52791 + p_Fm->h_Pcd = NULL;
52792 +}
52793 +
52794 +t_Handle FmGetPcdHandle(t_Handle h_Fm)
52795 +{
52796 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52797 +
52798 + return p_Fm->h_Pcd;
52799 +}
52800 +
52801 +uint8_t FmGetId(t_Handle h_Fm)
52802 +{
52803 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52804 +
52805 + SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, 0xff);
52806 +
52807 + return p_Fm->p_FmStateStruct->fmId;
52808 +}
52809 +
52810 +t_Error FmSetNumOfRiscsPerPort(t_Handle h_Fm,
52811 + uint8_t hardwarePortId,
52812 + uint8_t numOfFmanCtrls,
52813 + t_FmFmanCtrl orFmanCtrl)
52814 +{
52815 +
52816 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52817 + struct fman_fpm_regs *fpm_rg;
52818 +
52819 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
52820 + SANITY_CHECK_RETURN_ERROR(((numOfFmanCtrls > 0) && (numOfFmanCtrls < 3)) , E_INVALID_HANDLE);
52821 +
52822 + fpm_rg = p_Fm->p_FmFpmRegs;
52823 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
52824 + !p_Fm->p_FmFpmRegs &&
52825 + p_Fm->h_IpcSessions[0])
52826 + {
52827 + t_Error err;
52828 + t_FmIpcPortNumOfFmanCtrls params;
52829 + t_FmIpcMsg msg;
52830 +
52831 + memset(&msg, 0, sizeof(msg));
52832 + params.hardwarePortId = hardwarePortId;
52833 + params.numOfFmanCtrls = numOfFmanCtrls;
52834 + params.orFmanCtrl = orFmanCtrl;
52835 + msg.msgId = FM_SET_NUM_OF_FMAN_CTRL;
52836 + memcpy(msg.msgBody, &params, sizeof(params));
52837 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
52838 + (uint8_t*)&msg,
52839 + sizeof(msg.msgId) +sizeof(params),
52840 + NULL,
52841 + NULL,
52842 + NULL,
52843 + NULL);
52844 + if (err != E_OK)
52845 + RETURN_ERROR(MINOR, err, NO_MSG);
52846 + return E_OK;
52847 + }
52848 + else if (!p_Fm->p_FmFpmRegs)
52849 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
52850 + ("Either IPC or 'baseAddress' is required!"));
52851 +
52852 + fman_set_num_of_riscs_per_port(fpm_rg, hardwarePortId, numOfFmanCtrls, orFmanCtrl);
52853 +
52854 + return E_OK;
52855 +}
52856 +
52857 +t_Error FmGetSetPortParams(t_Handle h_Fm, t_FmInterModulePortInitParams *p_PortParams)
52858 +{
52859 + t_Fm *p_Fm = (t_Fm*)h_Fm;
52860 + t_Error err;
52861 + uint32_t intFlags;
52862 + uint8_t hardwarePortId = p_PortParams->hardwarePortId, macId;
52863 + struct fman_rg fman_rg;
52864 +
52865 + fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
52866 + fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
52867 + fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
52868 + fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
52869 +
52870 + if (p_Fm->guestId != NCSW_MASTER_ID)
52871 + {
52872 + t_FmIpcPortInInitParams portInParams;
52873 + t_FmIpcPortOutInitParams portOutParams;
52874 + t_FmIpcMsg msg;
52875 + t_FmIpcReply reply;
52876 + uint32_t replyLength;
52877 +
52878 + portInParams.hardwarePortId = p_PortParams->hardwarePortId;
52879 + portInParams.enumPortType = (uint32_t)p_PortParams->portType;
52880 + portInParams.boolIndependentMode= (uint8_t)p_PortParams->independentMode;
52881 + portInParams.liodnOffset = p_PortParams->liodnOffset;
52882 + portInParams.numOfTasks = p_PortParams->numOfTasks;
52883 + portInParams.numOfExtraTasks = p_PortParams->numOfExtraTasks;
52884 + portInParams.numOfOpenDmas = p_PortParams->numOfOpenDmas;
52885 + portInParams.numOfExtraOpenDmas = p_PortParams->numOfExtraOpenDmas;
52886 + portInParams.sizeOfFifo = p_PortParams->sizeOfFifo;
52887 + portInParams.extraSizeOfFifo = p_PortParams->extraSizeOfFifo;
52888 + portInParams.deqPipelineDepth = p_PortParams->deqPipelineDepth;
52889 + portInParams.maxFrameLength = p_PortParams->maxFrameLength;
52890 + portInParams.liodnBase = p_PortParams->liodnBase;
52891 +
52892 + memset(&msg, 0, sizeof(msg));
52893 + memset(&reply, 0, sizeof(reply));
52894 + msg.msgId = FM_GET_SET_PORT_PARAMS;
52895 + memcpy(msg.msgBody, &portInParams, sizeof(portInParams));
52896 + replyLength = (sizeof(uint32_t) + sizeof(t_FmIpcPortOutInitParams));
52897 + if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
52898 + (uint8_t*)&msg,
52899 + sizeof(msg.msgId) +sizeof(portInParams),
52900 + (uint8_t*)&reply,
52901 + &replyLength,
52902 + NULL,
52903 + NULL)) != E_OK)
52904 + RETURN_ERROR(MINOR, err, NO_MSG);
52905 + if (replyLength != (sizeof(uint32_t) + sizeof(t_FmIpcPortOutInitParams)))
52906 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
52907 + memcpy((uint8_t*)&portOutParams, reply.replyBody, sizeof(t_FmIpcPortOutInitParams));
52908 +
52909 + p_PortParams->fmMuramPhysBaseAddr.high = portOutParams.ipcPhysAddr.high;
52910 + p_PortParams->fmMuramPhysBaseAddr.low = portOutParams.ipcPhysAddr.low;
52911 + p_PortParams->numOfTasks = portOutParams.numOfTasks;
52912 + p_PortParams->numOfExtraTasks = portOutParams.numOfExtraTasks;
52913 + p_PortParams->numOfOpenDmas = portOutParams.numOfOpenDmas;
52914 + p_PortParams->numOfExtraOpenDmas = portOutParams.numOfExtraOpenDmas;
52915 + p_PortParams->sizeOfFifo = portOutParams.sizeOfFifo;
52916 + p_PortParams->extraSizeOfFifo = portOutParams.extraSizeOfFifo;
52917 +
52918 + return (t_Error)(reply.error);
52919 + }
52920 +
52921 + ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
52922 +
52923 + intFlags = XX_LockIntrSpinlock(p_Fm->h_Spinlock);
52924 + if (p_PortParams->independentMode)
52925 + {
52926 + /* set port parameters */
52927 + p_Fm->independentMode = p_PortParams->independentMode;
52928 + /* disable dispatch limit */
52929 + fman_qmi_disable_dispatch_limit(fman_rg.fpm_rg);
52930 + }
52931 +
52932 + if (p_PortParams->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
52933 + {
52934 + if (p_Fm->hcPortInitialized)
52935 + {
52936 + XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
52937 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Only one host command port is allowed."));
52938 + }
52939 + else
52940 + p_Fm->hcPortInitialized = TRUE;
52941 + }
52942 + p_Fm->p_FmStateStruct->portsTypes[hardwarePortId] = p_PortParams->portType;
52943 +
52944 + err = FmSetNumOfTasks(p_Fm, hardwarePortId, &p_PortParams->numOfTasks, &p_PortParams->numOfExtraTasks, TRUE);
52945 + if (err)
52946 + {
52947 + XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
52948 + RETURN_ERROR(MAJOR, err, NO_MSG);
52949 + }
52950 +
52951 +#ifdef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
52952 + if (p_Fm->p_FmStateStruct->revInfo.majorRev != 4)
52953 +#endif /* FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
52954 + if ((p_PortParams->portType != e_FM_PORT_TYPE_RX) &&
52955 + (p_PortParams->portType != e_FM_PORT_TYPE_RX_10G))
52956 + /* for transmit & O/H ports */
52957 + {
52958 + uint8_t enqTh;
52959 + uint8_t deqTh;
52960 +
52961 + /* update qmi ENQ/DEQ threshold */
52962 + p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums += p_PortParams->deqPipelineDepth;
52963 + enqTh = fman_get_qmi_enq_th(fman_rg.qmi_rg);
52964 + /* if enqTh is too big, we reduce it to the max value that is still OK */
52965 + if (enqTh >= (QMI_MAX_NUM_OF_TNUMS - p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums))
52966 + {
52967 + enqTh = (uint8_t)(QMI_MAX_NUM_OF_TNUMS - p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums - 1);
52968 + fman_set_qmi_enq_th(fman_rg.qmi_rg, enqTh);
52969 + }
52970 +
52971 + deqTh = fman_get_qmi_deq_th(fman_rg.qmi_rg);
52972 + /* if deqTh is too small, we enlarge it to the min value that is still OK.
52973 + deqTh may not be larger than 63 (QMI_MAX_NUM_OF_TNUMS-1). */
52974 + if ((deqTh <= p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums) && (deqTh < QMI_MAX_NUM_OF_TNUMS-1))
52975 + {
52976 + deqTh = (uint8_t)(p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums + 1);
52977 + fman_set_qmi_deq_th(fman_rg.qmi_rg, deqTh);
52978 + }
52979 + }
52980 +
52981 +#ifdef FM_LOW_END_RESTRICTION
52982 + if ((hardwarePortId==0x1) || (hardwarePortId==0x29))
52983 + {
52984 + if (p_Fm->p_FmStateStruct->lowEndRestriction)
52985 + {
52986 + XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
52987 + RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("OP #0 cannot work with Tx Port #1."));
52988 + }
52989 + else
52990 + p_Fm->p_FmStateStruct->lowEndRestriction = TRUE;
52991 + }
52992 +#endif /* FM_LOW_END_RESTRICTION */
52993 +
52994 + err = FmSetSizeOfFifo(p_Fm,
52995 + hardwarePortId,
52996 + &p_PortParams->sizeOfFifo,
52997 + &p_PortParams->extraSizeOfFifo,
52998 + TRUE);
52999 + if (err)
53000 + {
53001 + XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
53002 + RETURN_ERROR(MAJOR, err, NO_MSG);
53003 + }
53004 +
53005 + err = FmSetNumOfOpenDmas(p_Fm,
53006 + hardwarePortId,
53007 + &p_PortParams->numOfOpenDmas,
53008 + &p_PortParams->numOfExtraOpenDmas,
53009 + TRUE);
53010 + if (err)
53011 + {
53012 + XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
53013 + RETURN_ERROR(MAJOR, err, NO_MSG);
53014 + }
53015 +
53016 + fman_set_liodn_per_port(&fman_rg,
53017 + hardwarePortId,
53018 + p_PortParams->liodnBase,
53019 + p_PortParams->liodnOffset);
53020 +
53021 + if (p_Fm->p_FmStateStruct->revInfo.majorRev < 6)
53022 + fman_set_order_restoration_per_port(fman_rg.fpm_rg,
53023 + hardwarePortId,
53024 + p_PortParams->independentMode,
53025 + !!((p_PortParams->portType==e_FM_PORT_TYPE_RX) || (p_PortParams->portType==e_FM_PORT_TYPE_RX_10G)));
53026 +
53027 + HW_PORT_ID_TO_SW_PORT_ID(macId, hardwarePortId);
53028 +
53029 +#if defined(FM_MAX_NUM_OF_10G_MACS) && (FM_MAX_NUM_OF_10G_MACS)
53030 + if ((p_PortParams->portType == e_FM_PORT_TYPE_TX_10G) ||
53031 + (p_PortParams->portType == e_FM_PORT_TYPE_RX_10G))
53032 + {
53033 + ASSERT_COND(macId < FM_MAX_NUM_OF_10G_MACS);
53034 + if (p_PortParams->maxFrameLength >= p_Fm->p_FmStateStruct->macMaxFrameLengths10G[macId])
53035 + p_Fm->p_FmStateStruct->portMaxFrameLengths10G[macId] = p_PortParams->maxFrameLength;
53036 + else
53037 + RETURN_ERROR(MINOR, E_INVALID_VALUE, ("Port maxFrameLength is smaller than MAC current MTU"));
53038 + }
53039 + else
53040 +#endif /* defined(FM_MAX_NUM_OF_10G_MACS) && ... */
53041 + if ((p_PortParams->portType == e_FM_PORT_TYPE_TX) ||
53042 + (p_PortParams->portType == e_FM_PORT_TYPE_RX))
53043 + {
53044 + ASSERT_COND(macId < FM_MAX_NUM_OF_1G_MACS);
53045 + if (p_PortParams->maxFrameLength >= p_Fm->p_FmStateStruct->macMaxFrameLengths1G[macId])
53046 + p_Fm->p_FmStateStruct->portMaxFrameLengths1G[macId] = p_PortParams->maxFrameLength;
53047 + else
53048 + RETURN_ERROR(MINOR, E_INVALID_VALUE, ("Port maxFrameLength is smaller than MAC current MTU"));
53049 + }
53050 +
53051 + FmGetPhysicalMuramBase(p_Fm, &p_PortParams->fmMuramPhysBaseAddr);
53052 + XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
53053 +
53054 + return E_OK;
53055 +}
53056 +
53057 +void FmFreePortParams(t_Handle h_Fm,t_FmInterModulePortFreeParams *p_PortParams)
53058 +{
53059 + t_Fm *p_Fm = (t_Fm*)h_Fm;
53060 + uint32_t intFlags;
53061 + uint8_t hardwarePortId = p_PortParams->hardwarePortId;
53062 + uint8_t numOfTasks, numOfDmas, macId;
53063 + uint16_t sizeOfFifo;
53064 + t_Error err;
53065 + t_FmIpcPortFreeParams portParams;
53066 + t_FmIpcMsg msg;
53067 + struct fman_qmi_regs *qmi_rg = p_Fm->p_FmQmiRegs;
53068 + struct fman_bmi_regs *bmi_rg = p_Fm->p_FmBmiRegs;
53069 +
53070 + if (p_Fm->guestId != NCSW_MASTER_ID)
53071 + {
53072 + portParams.hardwarePortId = p_PortParams->hardwarePortId;
53073 + portParams.enumPortType = (uint32_t)p_PortParams->portType;
53074 + portParams.deqPipelineDepth = p_PortParams->deqPipelineDepth;
53075 + memset(&msg, 0, sizeof(msg));
53076 + msg.msgId = FM_FREE_PORT;
53077 + memcpy(msg.msgBody, &portParams, sizeof(portParams));
53078 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
53079 + (uint8_t*)&msg,
53080 + sizeof(msg.msgId)+sizeof(portParams),
53081 + NULL,
53082 + NULL,
53083 + NULL,
53084 + NULL);
53085 + if (err != E_OK)
53086 + REPORT_ERROR(MINOR, err, NO_MSG);
53087 + return;
53088 + }
53089 +
53090 + ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
53091 +
53092 + intFlags = XX_LockIntrSpinlock(p_Fm->h_Spinlock);
53093 +
53094 + if (p_PortParams->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
53095 + {
53096 + ASSERT_COND(p_Fm->hcPortInitialized);
53097 + p_Fm->hcPortInitialized = FALSE;
53098 + }
53099 +
53100 + p_Fm->p_FmStateStruct->portsTypes[hardwarePortId] = e_FM_PORT_TYPE_DUMMY;
53101 +
53102 + /* free numOfTasks */
53103 + numOfTasks = fman_get_num_of_tasks(bmi_rg, hardwarePortId);
53104 + ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedNumOfTasks >= numOfTasks);
53105 + p_Fm->p_FmStateStruct->accumulatedNumOfTasks -= numOfTasks;
53106 +
53107 + /* free numOfOpenDmas */
53108 + numOfDmas = fman_get_num_of_dmas(bmi_rg, hardwarePortId);
53109 + ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas >= numOfDmas);
53110 + p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas -= numOfDmas;
53111 +
53112 +#ifdef FM_HAS_TOTAL_DMAS
53113 + if (p_Fm->p_FmStateStruct->revInfo.majorRev < 6)
53114 + {
53115 + /* update total num of DMA's with committed number of open DMAS, and max uncommitted pool. */
53116 + fman_set_num_of_open_dmas(bmi_rg,
53117 + hardwarePortId,
53118 + 1,
53119 + 0,
53120 + (uint8_t)(p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas + p_Fm->p_FmStateStruct->extraOpenDmasPoolSize));
53121 + }
53122 +#endif /* FM_HAS_TOTAL_DMAS */
53123 +
53124 + /* free sizeOfFifo */
53125 + sizeOfFifo = fman_get_size_of_fifo(bmi_rg, hardwarePortId);
53126 + ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedFifoSize >= (sizeOfFifo * BMI_FIFO_UNITS));
53127 + p_Fm->p_FmStateStruct->accumulatedFifoSize -= (sizeOfFifo * BMI_FIFO_UNITS);
53128 +
53129 +#ifdef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
53130 + if (p_Fm->p_FmStateStruct->revInfo.majorRev != 4)
53131 +#endif /* FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
53132 + if ((p_PortParams->portType != e_FM_PORT_TYPE_RX) &&
53133 + (p_PortParams->portType != e_FM_PORT_TYPE_RX_10G))
53134 + /* for transmit & O/H ports */
53135 + {
53136 + uint8_t enqTh;
53137 + uint8_t deqTh;
53138 +
53139 + /* update qmi ENQ/DEQ threshold */
53140 + p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums -= p_PortParams->deqPipelineDepth;
53141 +
53142 + /* p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums is now smaller,
53143 + so we can enlarge enqTh */
53144 + enqTh = (uint8_t)(QMI_MAX_NUM_OF_TNUMS - p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums - 1);
53145 +
53146 + /* p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums is now smaller,
53147 + so we can reduce deqTh */
53148 + deqTh = (uint8_t)(p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums + 1);
53149 +
53150 + fman_set_qmi_enq_th(qmi_rg, enqTh);
53151 + fman_set_qmi_deq_th(qmi_rg, deqTh);
53152 + }
53153 +
53154 + HW_PORT_ID_TO_SW_PORT_ID(macId, hardwarePortId);
53155 +
53156 +#if defined(FM_MAX_NUM_OF_10G_MACS) && (FM_MAX_NUM_OF_10G_MACS)
53157 + if ((p_PortParams->portType == e_FM_PORT_TYPE_TX_10G) ||
53158 + (p_PortParams->portType == e_FM_PORT_TYPE_RX_10G))
53159 + {
53160 + ASSERT_COND(macId < FM_MAX_NUM_OF_10G_MACS);
53161 + p_Fm->p_FmStateStruct->portMaxFrameLengths10G[macId] = 0;
53162 + }
53163 + else
53164 +#endif /* defined(FM_MAX_NUM_OF_10G_MACS) && ... */
53165 + if ((p_PortParams->portType == e_FM_PORT_TYPE_TX) ||
53166 + (p_PortParams->portType == e_FM_PORT_TYPE_RX))
53167 + {
53168 + ASSERT_COND(macId < FM_MAX_NUM_OF_1G_MACS);
53169 + p_Fm->p_FmStateStruct->portMaxFrameLengths1G[macId] = 0;
53170 + }
53171 +
53172 +#ifdef FM_LOW_END_RESTRICTION
53173 + if ((hardwarePortId==0x1) || (hardwarePortId==0x29))
53174 + p_Fm->p_FmStateStruct->lowEndRestriction = FALSE;
53175 +#endif /* FM_LOW_END_RESTRICTION */
53176 + XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
53177 +}
53178 +
53179 +t_Error FmIsPortStalled(t_Handle h_Fm, uint8_t hardwarePortId, bool *p_IsStalled)
53180 +{
53181 + t_Fm *p_Fm = (t_Fm*)h_Fm;
53182 + t_Error err;
53183 + t_FmIpcMsg msg;
53184 + t_FmIpcReply reply;
53185 + uint32_t replyLength;
53186 + struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
53187 +
53188 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
53189 + !p_Fm->baseAddr &&
53190 + p_Fm->h_IpcSessions[0])
53191 + {
53192 + memset(&msg, 0, sizeof(msg));
53193 + memset(&reply, 0, sizeof(reply));
53194 + msg.msgId = FM_IS_PORT_STALLED;
53195 + msg.msgBody[0] = hardwarePortId;
53196 + replyLength = sizeof(uint32_t) + sizeof(uint8_t);
53197 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
53198 + (uint8_t*)&msg,
53199 + sizeof(msg.msgId)+sizeof(hardwarePortId),
53200 + (uint8_t*)&reply,
53201 + &replyLength,
53202 + NULL,
53203 + NULL);
53204 + if (err != E_OK)
53205 + RETURN_ERROR(MINOR, err, NO_MSG);
53206 + if (replyLength != (sizeof(uint32_t) + sizeof(uint8_t)))
53207 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
53208 +
53209 + *p_IsStalled = (bool)!!(*(uint8_t*)(reply.replyBody));
53210 +
53211 + return (t_Error)(reply.error);
53212 + }
53213 + else if (!p_Fm->baseAddr)
53214 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
53215 + ("Either IPC or 'baseAddress' is required!"));
53216 +
53217 + *p_IsStalled = fman_is_port_stalled(fpm_rg, hardwarePortId);
53218 +
53219 + return E_OK;
53220 +}
53221 +
53222 +t_Error FmResumeStalledPort(t_Handle h_Fm, uint8_t hardwarePortId)
53223 +{
53224 + t_Fm *p_Fm = (t_Fm*)h_Fm;
53225 + t_Error err;
53226 + bool isStalled;
53227 + struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
53228 +
53229 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
53230 + !p_Fm->baseAddr &&
53231 + p_Fm->h_IpcSessions[0])
53232 + {
53233 + t_FmIpcMsg msg;
53234 + t_FmIpcReply reply;
53235 + uint32_t replyLength;
53236 +
53237 + memset(&msg, 0, sizeof(msg));
53238 + memset(&reply, 0, sizeof(reply));
53239 + msg.msgId = FM_RESUME_STALLED_PORT;
53240 + msg.msgBody[0] = hardwarePortId;
53241 + replyLength = sizeof(uint32_t);
53242 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
53243 + (uint8_t*)&msg,
53244 + sizeof(msg.msgId) + sizeof(hardwarePortId),
53245 + (uint8_t*)&reply,
53246 + &replyLength,
53247 + NULL,
53248 + NULL);
53249 + if (err != E_OK)
53250 + RETURN_ERROR(MINOR, err, NO_MSG);
53251 + if (replyLength != sizeof(uint32_t))
53252 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
53253 + return (t_Error)(reply.error);
53254 + }
53255 + else if (!p_Fm->baseAddr)
53256 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
53257 + ("Either IPC or 'baseAddress' is required!"));
53258 +
53259 + if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
53260 + RETURN_ERROR(MINOR, E_NOT_AVAILABLE, ("Not available for this FM revision!"));
53261 +
53262 + /* Get port status */
53263 + err = FmIsPortStalled(h_Fm, hardwarePortId, &isStalled);
53264 + if (err)
53265 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Can't get port status"));
53266 + if (!isStalled)
53267 + return E_OK;
53268 +
53269 + fman_resume_stalled_port(fpm_rg, hardwarePortId);
53270 +
53271 + return E_OK;
53272 +}
53273 +
53274 +t_Error FmResetMac(t_Handle h_Fm, e_FmMacType type, uint8_t macId)
53275 +{
53276 + t_Fm *p_Fm = (t_Fm*)h_Fm;
53277 + t_Error err;
53278 + struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
53279 +
53280 +#if (DPAA_VERSION >= 11)
53281 + if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
53282 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
53283 + ("FMan MAC reset!"));
53284 +#endif /*(DPAA_VERSION >= 11)*/
53285 +
53286 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
53287 + !p_Fm->baseAddr &&
53288 + p_Fm->h_IpcSessions[0])
53289 + {
53290 + t_FmIpcMacParams macParams;
53291 + t_FmIpcMsg msg;
53292 + t_FmIpcReply reply;
53293 + uint32_t replyLength;
53294 +
53295 + memset(&msg, 0, sizeof(msg));
53296 + memset(&reply, 0, sizeof(reply));
53297 + macParams.id = macId;
53298 + macParams.enumType = (uint32_t)type;
53299 + msg.msgId = FM_RESET_MAC;
53300 + memcpy(msg.msgBody, &macParams, sizeof(macParams));
53301 + replyLength = sizeof(uint32_t);
53302 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
53303 + (uint8_t*)&msg,
53304 + sizeof(msg.msgId)+sizeof(macParams),
53305 + (uint8_t*)&reply,
53306 + &replyLength,
53307 + NULL,
53308 + NULL);
53309 + if (err != E_OK)
53310 + RETURN_ERROR(MINOR, err, NO_MSG);
53311 + if (replyLength != sizeof(uint32_t))
53312 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
53313 + return (t_Error)(reply.error);
53314 + }
53315 + else if (!p_Fm->baseAddr)
53316 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
53317 + ("Either IPC or 'baseAddress' is required!"));
53318 +
53319 + err = (t_Error)fman_reset_mac(fpm_rg, macId, !!(type == e_FM_MAC_10G));
53320 +
53321 + if (err == -EBUSY)
53322 + return ERROR_CODE(E_TIMEOUT);
53323 + else if (err)
53324 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal MAC ID"));
53325 +
53326 + return E_OK;
53327 +}
53328 +
53329 +t_Error FmSetMacMaxFrame(t_Handle h_Fm, e_FmMacType type, uint8_t macId, uint16_t mtu)
53330 +{
53331 + t_Fm *p_Fm = (t_Fm*)h_Fm;
53332 +
53333 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
53334 + p_Fm->h_IpcSessions[0])
53335 + {
53336 + t_FmIpcMacMaxFrameParams macMaxFrameLengthParams;
53337 + t_Error err;
53338 + t_FmIpcMsg msg;
53339 +
53340 + memset(&msg, 0, sizeof(msg));
53341 + macMaxFrameLengthParams.macParams.id = macId;
53342 + macMaxFrameLengthParams.macParams.enumType = (uint32_t)type;
53343 + macMaxFrameLengthParams.maxFrameLength = (uint16_t)mtu;
53344 + msg.msgId = FM_SET_MAC_MAX_FRAME;
53345 + memcpy(msg.msgBody, &macMaxFrameLengthParams, sizeof(macMaxFrameLengthParams));
53346 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
53347 + (uint8_t*)&msg,
53348 + sizeof(msg.msgId)+sizeof(macMaxFrameLengthParams),
53349 + NULL,
53350 + NULL,
53351 + NULL,
53352 + NULL);
53353 + if (err != E_OK)
53354 + RETURN_ERROR(MINOR, err, NO_MSG);
53355 + return E_OK;
53356 + }
53357 + else if (p_Fm->guestId != NCSW_MASTER_ID)
53358 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
53359 + ("running in guest-mode without IPC!"));
53360 +
53361 + /* if port is already initialized, check that MaxFrameLength is smaller
53362 + * or equal to the port's max */
53363 +#if (defined(FM_MAX_NUM_OF_10G_MACS) && (FM_MAX_NUM_OF_10G_MACS))
53364 + if (type == e_FM_MAC_10G)
53365 + {
53366 + if ((!p_Fm->p_FmStateStruct->portMaxFrameLengths10G[macId])
53367 + || (p_Fm->p_FmStateStruct->portMaxFrameLengths10G[macId] &&
53368 + (mtu <= p_Fm->p_FmStateStruct->portMaxFrameLengths10G[macId])))
53369 + p_Fm->p_FmStateStruct->macMaxFrameLengths10G[macId] = mtu;
53370 + else
53371 + RETURN_ERROR(MINOR, E_INVALID_VALUE, ("MAC maxFrameLength is larger than Port maxFrameLength"));
53372 +
53373 + }
53374 + else
53375 +#else
53376 + UNUSED(type);
53377 +#endif /* (defined(FM_MAX_NUM_OF_10G_MACS) && ... */
53378 + if ((!p_Fm->p_FmStateStruct->portMaxFrameLengths1G[macId])
53379 + || (p_Fm->p_FmStateStruct->portMaxFrameLengths1G[macId] &&
53380 + (mtu <= p_Fm->p_FmStateStruct->portMaxFrameLengths1G[macId])))
53381 + p_Fm->p_FmStateStruct->macMaxFrameLengths1G[macId] = mtu;
53382 + else
53383 + RETURN_ERROR(MINOR, E_INVALID_VALUE, ("MAC maxFrameLength is larger than Port maxFrameLength"));
53384 +
53385 + return E_OK;
53386 +}
53387 +
53388 +uint16_t FmGetClockFreq(t_Handle h_Fm)
53389 +{
53390 + t_Fm *p_Fm = (t_Fm*)h_Fm;
53391 +
53392 + /* for multicore environment: this depends on the
53393 + * fact that fmClkFreq was properly initialized at "init". */
53394 + return p_Fm->p_FmStateStruct->fmClkFreq;
53395 +}
53396 +
53397 +uint16_t FmGetMacClockFreq(t_Handle h_Fm)
53398 +{
53399 + t_Fm *p_Fm = (t_Fm*)h_Fm;
53400 +
53401 + return p_Fm->p_FmStateStruct->fmMacClkFreq;
53402 +}
53403 +
53404 +uint32_t FmGetTimeStampScale(t_Handle h_Fm)
53405 +{
53406 + t_Fm *p_Fm = (t_Fm*)h_Fm;
53407 +
53408 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
53409 + !p_Fm->baseAddr &&
53410 + p_Fm->h_IpcSessions[0])
53411 + {
53412 + t_Error err;
53413 + t_FmIpcMsg msg;
53414 + t_FmIpcReply reply;
53415 + uint32_t replyLength, timeStamp;
53416 +
53417 + memset(&msg, 0, sizeof(msg));
53418 + memset(&reply, 0, sizeof(reply));
53419 + msg.msgId = FM_GET_TIMESTAMP_SCALE;
53420 + replyLength = sizeof(uint32_t) + sizeof(uint32_t);
53421 + if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
53422 + (uint8_t*)&msg,
53423 + sizeof(msg.msgId),
53424 + (uint8_t*)&reply,
53425 + &replyLength,
53426 + NULL,
53427 + NULL)) != E_OK)
53428 + {
53429 + REPORT_ERROR(MAJOR, err, NO_MSG);
53430 + return 0;
53431 + }
53432 + if (replyLength != (sizeof(uint32_t) + sizeof(uint32_t)))
53433 + {
53434 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
53435 + return 0;
53436 + }
53437 +
53438 + memcpy((uint8_t*)&timeStamp, reply.replyBody, sizeof(uint32_t));
53439 + return timeStamp;
53440 + }
53441 + else if ((p_Fm->guestId != NCSW_MASTER_ID) &&
53442 + p_Fm->baseAddr)
53443 + {
53444 + if (!(GET_UINT32(p_Fm->p_FmFpmRegs->fmfp_tsc1) & FPM_TS_CTL_EN))
53445 + {
53446 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("timestamp is not enabled!"));
53447 + return 0;
53448 + }
53449 + }
53450 + else if (p_Fm->guestId != NCSW_MASTER_ID)
53451 + DBG(WARNING, ("No IPC - can't validate FM if timestamp enabled."));
53452 +
53453 + return p_Fm->p_FmStateStruct->count1MicroBit;
53454 +}
53455 +
53456 +t_Error FmEnableRamsEcc(t_Handle h_Fm)
53457 +{
53458 + t_Fm *p_Fm = (t_Fm*)h_Fm;
53459 +
53460 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
53461 +
53462 + p_Fm->p_FmStateStruct->ramsEccOwners++;
53463 + p_Fm->p_FmStateStruct->internalCall = TRUE;
53464 +
53465 + return FM_EnableRamsEcc(p_Fm);
53466 +}
53467 +
53468 +t_Error FmDisableRamsEcc(t_Handle h_Fm)
53469 +{
53470 + t_Fm *p_Fm = (t_Fm*)h_Fm;
53471 +
53472 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
53473 +
53474 + ASSERT_COND(p_Fm->p_FmStateStruct->ramsEccOwners);
53475 + p_Fm->p_FmStateStruct->ramsEccOwners--;
53476 +
53477 + if (p_Fm->p_FmStateStruct->ramsEccOwners==0)
53478 + {
53479 + p_Fm->p_FmStateStruct->internalCall = TRUE;
53480 + return FM_DisableRamsEcc(p_Fm);
53481 + }
53482 +
53483 + return E_OK;
53484 +}
53485 +
53486 +uint8_t FmGetGuestId(t_Handle h_Fm)
53487 +{
53488 + t_Fm *p_Fm = (t_Fm*)h_Fm;
53489 +
53490 + return p_Fm->guestId;
53491 +}
53492 +
53493 +bool FmIsMaster(t_Handle h_Fm)
53494 +{
53495 + t_Fm *p_Fm = (t_Fm*)h_Fm;
53496 +
53497 + return (p_Fm->guestId == NCSW_MASTER_ID);
53498 +}
53499 +
53500 +t_Error FmSetSizeOfFifo(t_Handle h_Fm,
53501 + uint8_t hardwarePortId,
53502 + uint32_t *p_SizeOfFifo,
53503 + uint32_t *p_ExtraSizeOfFifo,
53504 + bool initialConfig)
53505 +{
53506 + t_Fm *p_Fm = (t_Fm*)h_Fm;
53507 + t_FmIpcPortRsrcParams rsrcParams;
53508 + t_Error err;
53509 + struct fman_bmi_regs *bmi_rg = p_Fm->p_FmBmiRegs;
53510 + uint32_t sizeOfFifo = *p_SizeOfFifo, extraSizeOfFifo = *p_ExtraSizeOfFifo;
53511 + uint16_t currentVal = 0, currentExtraVal = 0;
53512 +
53513 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
53514 + !p_Fm->baseAddr &&
53515 + p_Fm->h_IpcSessions[0])
53516 + {
53517 + t_FmIpcMsg msg;
53518 + t_FmIpcReply reply;
53519 + uint32_t replyLength;
53520 +
53521 + rsrcParams.hardwarePortId = hardwarePortId;
53522 + rsrcParams.val = sizeOfFifo;
53523 + rsrcParams.extra = extraSizeOfFifo;
53524 + rsrcParams.boolInitialConfig = (uint8_t)initialConfig;
53525 +
53526 + memset(&msg, 0, sizeof(msg));
53527 + memset(&reply, 0, sizeof(reply));
53528 + msg.msgId = FM_SET_SIZE_OF_FIFO;
53529 + memcpy(msg.msgBody, &rsrcParams, sizeof(rsrcParams));
53530 + replyLength = sizeof(uint32_t);
53531 + if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
53532 + (uint8_t*)&msg,
53533 + sizeof(msg.msgId) + sizeof(rsrcParams),
53534 + (uint8_t*)&reply,
53535 + &replyLength,
53536 + NULL,
53537 + NULL)) != E_OK)
53538 + RETURN_ERROR(MINOR, err, NO_MSG);
53539 + if (replyLength != sizeof(uint32_t))
53540 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
53541 + return (t_Error)(reply.error);
53542 + }
53543 + else if ((p_Fm->guestId != NCSW_MASTER_ID) &&
53544 + p_Fm->baseAddr)
53545 + {
53546 + DBG(WARNING, ("No IPC - can't validate FM total-fifo size."));
53547 + fman_set_size_of_fifo(bmi_rg, hardwarePortId, sizeOfFifo, extraSizeOfFifo);
53548 + }
53549 + else if (p_Fm->guestId != NCSW_MASTER_ID)
53550 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
53551 + ("running in guest-mode without neither IPC nor mapped register!"));
53552 +
53553 + if (!initialConfig)
53554 + {
53555 + /* !initialConfig - runtime change of existing value.
53556 + * - read the current FIFO and extra FIFO size */
53557 + currentExtraVal = fman_get_size_of_extra_fifo(bmi_rg, hardwarePortId);
53558 + currentVal = fman_get_size_of_fifo(bmi_rg, hardwarePortId);
53559 + }
53560 +
53561 + if (extraSizeOfFifo > currentExtraVal)
53562 + {
53563 + if (extraSizeOfFifo && !p_Fm->p_FmStateStruct->extraFifoPoolSize)
53564 + /* if this is the first time a port requires extraFifoPoolSize, the total extraFifoPoolSize
53565 + * must be initialized to 1 buffer per port
53566 + */
53567 + p_Fm->p_FmStateStruct->extraFifoPoolSize = FM_MAX_NUM_OF_RX_PORTS*BMI_FIFO_UNITS;
53568 +
53569 + p_Fm->p_FmStateStruct->extraFifoPoolSize = MAX(p_Fm->p_FmStateStruct->extraFifoPoolSize, extraSizeOfFifo);
53570 + }
53571 +
53572 + /* check that there are enough uncommitted fifo size */
53573 + if ((p_Fm->p_FmStateStruct->accumulatedFifoSize - currentVal + sizeOfFifo) >
53574 + (p_Fm->p_FmStateStruct->totalFifoSize - p_Fm->p_FmStateStruct->extraFifoPoolSize)){
53575 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
53576 + ("Port request fifo size + accumulated size > total FIFO size:"));
53577 + RETURN_ERROR(MAJOR, E_INVALID_VALUE,
53578 + ("port 0x%x requested %d bytes, extra size = %d, accumulated size = %d total size = %d",
53579 + hardwarePortId, sizeOfFifo, p_Fm->p_FmStateStruct->extraFifoPoolSize,
53580 + p_Fm->p_FmStateStruct->accumulatedFifoSize,
53581 + p_Fm->p_FmStateStruct->totalFifoSize));
53582 + }
53583 + else
53584 + {
53585 + /* update accumulated */
53586 + ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedFifoSize >= currentVal);
53587 + p_Fm->p_FmStateStruct->accumulatedFifoSize -= currentVal;
53588 + p_Fm->p_FmStateStruct->accumulatedFifoSize += sizeOfFifo;
53589 + fman_set_size_of_fifo(bmi_rg, hardwarePortId, sizeOfFifo, extraSizeOfFifo);
53590 + }
53591 +
53592 + return E_OK;
53593 +}
53594 +
53595 +t_Error FmSetNumOfTasks(t_Handle h_Fm,
53596 + uint8_t hardwarePortId,
53597 + uint8_t *p_NumOfTasks,
53598 + uint8_t *p_NumOfExtraTasks,
53599 + bool initialConfig)
53600 +{
53601 + t_Fm *p_Fm = (t_Fm *)h_Fm;
53602 + t_Error err;
53603 + struct fman_bmi_regs *bmi_rg = p_Fm->p_FmBmiRegs;
53604 + uint8_t currentVal = 0, currentExtraVal = 0, numOfTasks = *p_NumOfTasks, numOfExtraTasks = *p_NumOfExtraTasks;
53605 +
53606 + ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
53607 +
53608 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
53609 + !p_Fm->baseAddr &&
53610 + p_Fm->h_IpcSessions[0])
53611 + {
53612 + t_FmIpcPortRsrcParams rsrcParams;
53613 + t_FmIpcMsg msg;
53614 + t_FmIpcReply reply;
53615 + uint32_t replyLength;
53616 +
53617 + rsrcParams.hardwarePortId = hardwarePortId;
53618 + rsrcParams.val = numOfTasks;
53619 + rsrcParams.extra = numOfExtraTasks;
53620 + rsrcParams.boolInitialConfig = (uint8_t)initialConfig;
53621 +
53622 + memset(&msg, 0, sizeof(msg));
53623 + memset(&reply, 0, sizeof(reply));
53624 + msg.msgId = FM_SET_NUM_OF_TASKS;
53625 + memcpy(msg.msgBody, &rsrcParams, sizeof(rsrcParams));
53626 + replyLength = sizeof(uint32_t);
53627 + if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
53628 + (uint8_t*)&msg,
53629 + sizeof(msg.msgId) + sizeof(rsrcParams),
53630 + (uint8_t*)&reply,
53631 + &replyLength,
53632 + NULL,
53633 + NULL)) != E_OK)
53634 + RETURN_ERROR(MINOR, err, NO_MSG);
53635 + if (replyLength != sizeof(uint32_t))
53636 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
53637 + return (t_Error)(reply.error);
53638 + }
53639 + else if ((p_Fm->guestId != NCSW_MASTER_ID) &&
53640 + p_Fm->baseAddr)
53641 + {
53642 + DBG(WARNING, ("No IPC - can't validate FM total-num-of-tasks."));
53643 + fman_set_num_of_tasks(bmi_rg, hardwarePortId, numOfTasks, numOfExtraTasks);
53644 + }
53645 + else if (p_Fm->guestId != NCSW_MASTER_ID)
53646 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
53647 + ("running in guest-mode without neither IPC nor mapped register!"));
53648 +
53649 + if (!initialConfig)
53650 + {
53651 + /* !initialConfig - runtime change of existing value.
53652 + * - read the current number of tasks */
53653 + currentVal = fman_get_num_of_tasks(bmi_rg, hardwarePortId);
53654 + currentExtraVal = fman_get_num_extra_tasks(bmi_rg, hardwarePortId);
53655 + }
53656 +
53657 + if (numOfExtraTasks > currentExtraVal)
53658 + p_Fm->p_FmStateStruct->extraTasksPoolSize =
53659 + (uint8_t)MAX(p_Fm->p_FmStateStruct->extraTasksPoolSize, numOfExtraTasks);
53660 +
53661 + /* check that there are enough uncommitted tasks */
53662 + if ((p_Fm->p_FmStateStruct->accumulatedNumOfTasks - currentVal + numOfTasks) >
53663 + (p_Fm->p_FmStateStruct->totalNumOfTasks - p_Fm->p_FmStateStruct->extraTasksPoolSize))
53664 + RETURN_ERROR(MAJOR, E_NOT_AVAILABLE,
53665 + ("Requested numOfTasks and extra tasks pool for fm%d exceed total numOfTasks.",
53666 + p_Fm->p_FmStateStruct->fmId));
53667 + else
53668 + {
53669 + ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedNumOfTasks >= currentVal);
53670 + /* update accumulated */
53671 + p_Fm->p_FmStateStruct->accumulatedNumOfTasks -= currentVal;
53672 + p_Fm->p_FmStateStruct->accumulatedNumOfTasks += numOfTasks;
53673 + fman_set_num_of_tasks(bmi_rg, hardwarePortId, numOfTasks, numOfExtraTasks);
53674 + }
53675 +
53676 + return E_OK;
53677 +}
53678 +
53679 +t_Error FmSetNumOfOpenDmas(t_Handle h_Fm,
53680 + uint8_t hardwarePortId,
53681 + uint8_t *p_NumOfOpenDmas,
53682 + uint8_t *p_NumOfExtraOpenDmas,
53683 + bool initialConfig)
53684 +
53685 +{
53686 + t_Fm *p_Fm = (t_Fm *)h_Fm;
53687 + t_Error err;
53688 + struct fman_bmi_regs *bmi_rg = p_Fm->p_FmBmiRegs;
53689 + uint8_t numOfOpenDmas = *p_NumOfOpenDmas, numOfExtraOpenDmas = *p_NumOfExtraOpenDmas;
53690 + uint8_t totalNumDmas = 0, currentVal = 0, currentExtraVal = 0;
53691 +
53692 + ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
53693 +
53694 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
53695 + !p_Fm->baseAddr &&
53696 + p_Fm->h_IpcSessions[0])
53697 + {
53698 + t_FmIpcPortRsrcParams rsrcParams;
53699 + t_FmIpcMsg msg;
53700 + t_FmIpcReply reply;
53701 + uint32_t replyLength;
53702 +
53703 + rsrcParams.hardwarePortId = hardwarePortId;
53704 + rsrcParams.val = numOfOpenDmas;
53705 + rsrcParams.extra = numOfExtraOpenDmas;
53706 + rsrcParams.boolInitialConfig = (uint8_t)initialConfig;
53707 +
53708 + memset(&msg, 0, sizeof(msg));
53709 + memset(&reply, 0, sizeof(reply));
53710 + msg.msgId = FM_SET_NUM_OF_OPEN_DMAS;
53711 + memcpy(msg.msgBody, &rsrcParams, sizeof(rsrcParams));
53712 + replyLength = sizeof(uint32_t);
53713 + if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
53714 + (uint8_t*)&msg,
53715 + sizeof(msg.msgId) + sizeof(rsrcParams),
53716 + (uint8_t*)&reply,
53717 + &replyLength,
53718 + NULL,
53719 + NULL)) != E_OK)
53720 + RETURN_ERROR(MINOR, err, NO_MSG);
53721 + if (replyLength != sizeof(uint32_t))
53722 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
53723 + return (t_Error)(reply.error);
53724 + }
53725 +#ifdef FM_HAS_TOTAL_DMAS
53726 + else if (p_Fm->guestId != NCSW_MASTER_ID)
53727 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("running in guest-mode without IPC!"));
53728 +#else
53729 + else if ((p_Fm->guestId != NCSW_MASTER_ID) &&
53730 + p_Fm->baseAddr &&
53731 + (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6))
53732 + {
53733 + /*DBG(WARNING, ("No IPC - can't validate FM total-num-of-dmas."));*/
53734 +
53735 + if (!numOfOpenDmas)
53736 + {
53737 + /* first config without explic it value: Do Nothing - reset value shouldn't be
53738 + changed, read register for port save */
53739 + *p_NumOfOpenDmas = fman_get_num_of_dmas(bmi_rg, hardwarePortId);
53740 + *p_NumOfExtraOpenDmas = fman_get_num_extra_dmas(bmi_rg, hardwarePortId);
53741 + }
53742 + else
53743 + /* whether it is the first time with explicit value, or runtime "set" - write register */
53744 + fman_set_num_of_open_dmas(bmi_rg,
53745 + hardwarePortId,
53746 + numOfOpenDmas,
53747 + numOfExtraOpenDmas,
53748 + p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas + p_Fm->p_FmStateStruct->extraOpenDmasPoolSize);
53749 + }
53750 + else if (p_Fm->guestId != NCSW_MASTER_ID)
53751 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
53752 + ("running in guest-mode without neither IPC nor mapped register!"));
53753 +#endif /* FM_HAS_TOTAL_DMAS */
53754 +
53755 + if (!initialConfig)
53756 + {
53757 + /* !initialConfig - runtime change of existing value.
53758 + * - read the current number of open Dma's */
53759 + currentExtraVal = fman_get_num_extra_dmas(bmi_rg, hardwarePortId);
53760 + currentVal = fman_get_num_of_dmas(bmi_rg, hardwarePortId);
53761 + }
53762 +
53763 +#ifdef FM_NO_GUARANTEED_RESET_VALUES
53764 + /* it's illegal to be in a state where this is not the first set and no value is specified */
53765 + ASSERT_COND(initialConfig || numOfOpenDmas);
53766 + if (!numOfOpenDmas)
53767 + {
53768 + /* !numOfOpenDmas - first configuration according to values in regs.
53769 + * - read the current number of open Dma's */
53770 + currentExtraVal = fman_get_num_extra_dmas(bmi_rg, hardwarePortId);
53771 + currentVal = fman_get_num_of_dmas(bmi_rg, hardwarePortId);
53772 + /* This is the first configuration and user did not specify value (!numOfOpenDmas),
53773 + * reset values will be used and we just save these values for resource management */
53774 + p_Fm->p_FmStateStruct->extraOpenDmasPoolSize =
53775 + (uint8_t)MAX(p_Fm->p_FmStateStruct->extraOpenDmasPoolSize, currentExtraVal);
53776 + p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas += currentVal;
53777 + *p_NumOfOpenDmas = currentVal;
53778 + *p_NumOfExtraOpenDmas = currentExtraVal;
53779 + return E_OK;
53780 + }
53781 +#endif /* FM_NO_GUARANTEED_RESET_VALUES */
53782 +
53783 + if (numOfExtraOpenDmas > currentExtraVal)
53784 + p_Fm->p_FmStateStruct->extraOpenDmasPoolSize =
53785 + (uint8_t)MAX(p_Fm->p_FmStateStruct->extraOpenDmasPoolSize, numOfExtraOpenDmas);
53786 +
53787 +#ifdef FM_HAS_TOTAL_DMAS
53788 + if ((p_Fm->p_FmStateStruct->revInfo.majorRev < 6) &&
53789 + (p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas - currentVal + numOfOpenDmas >
53790 + p_Fm->p_FmStateStruct->maxNumOfOpenDmas))
53791 + RETURN_ERROR(MAJOR, E_NOT_AVAILABLE,
53792 + ("Requested numOfOpenDmas for fm%d exceeds total numOfOpenDmas.",
53793 + p_Fm->p_FmStateStruct->fmId));
53794 +#else
53795 + if ((p_Fm->p_FmStateStruct->revInfo.majorRev >= 6) &&
53796 +#ifdef FM_HEAVY_TRAFFIC_SEQUENCER_HANG_ERRATA_FMAN_A006981
53797 + !((p_Fm->p_FmStateStruct->revInfo.majorRev == 6) &&
53798 + (p_Fm->p_FmStateStruct->revInfo.minorRev == 0)) &&
53799 +#endif /* FM_HEAVY_TRAFFIC_SEQUENCER_HANG_ERRATA_FMAN_A006981 */
53800 + (p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas - currentVal + numOfOpenDmas > DMA_THRESH_MAX_COMMQ + 1))
53801 + RETURN_ERROR(MAJOR, E_NOT_AVAILABLE,
53802 + ("Requested numOfOpenDmas for fm%d exceeds DMA Command queue (%d)",
53803 + p_Fm->p_FmStateStruct->fmId, DMA_THRESH_MAX_COMMQ+1));
53804 +#endif /* FM_HAS_TOTAL_DMAS */
53805 + else
53806 + {
53807 + ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas >= currentVal);
53808 + /* update acummulated */
53809 + p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas -= currentVal;
53810 + p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas += numOfOpenDmas;
53811 +
53812 +#ifdef FM_HAS_TOTAL_DMAS
53813 + if (p_Fm->p_FmStateStruct->revInfo.majorRev < 6)
53814 + totalNumDmas = (uint8_t)(p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas + p_Fm->p_FmStateStruct->extraOpenDmasPoolSize);
53815 +#endif /* FM_HAS_TOTAL_DMAS */
53816 + fman_set_num_of_open_dmas(bmi_rg,
53817 + hardwarePortId,
53818 + numOfOpenDmas,
53819 + numOfExtraOpenDmas,
53820 + totalNumDmas);
53821 + }
53822 +
53823 + return E_OK;
53824 +}
53825 +
53826 +#if (DPAA_VERSION >= 11)
53827 +t_Error FmVSPCheckRelativeProfile(t_Handle h_Fm,
53828 + e_FmPortType portType,
53829 + uint8_t portId,
53830 + uint16_t relativeProfile)
53831 +{
53832 + t_Fm *p_Fm;
53833 + t_FmSp *p_FmPcdSp;
53834 + uint8_t swPortIndex=0, hardwarePortId;
53835 +
53836 + ASSERT_COND(h_Fm);
53837 + p_Fm = (t_Fm*)h_Fm;
53838 +
53839 + hardwarePortId = SwPortIdToHwPortId(portType,
53840 + portId,
53841 + p_Fm->p_FmStateStruct->revInfo.majorRev,
53842 + p_Fm->p_FmStateStruct->revInfo.minorRev);
53843 + ASSERT_COND(hardwarePortId);
53844 + HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
53845 +
53846 + p_FmPcdSp = p_Fm->p_FmSp;
53847 + ASSERT_COND(p_FmPcdSp);
53848 +
53849 + if (!p_FmPcdSp->portsMapping[swPortIndex].numOfProfiles)
53850 + RETURN_ERROR(MAJOR, E_INVALID_STATE , ("Port has no allocated profiles"));
53851 + if (relativeProfile >= p_FmPcdSp->portsMapping[swPortIndex].numOfProfiles)
53852 + RETURN_ERROR(MAJOR, E_NOT_IN_RANGE , ("Profile id is out of range"));
53853 +
53854 + return E_OK;
53855 +}
53856 +
53857 +t_Error FmVSPGetAbsoluteProfileId(t_Handle h_Fm,
53858 + e_FmPortType portType,
53859 + uint8_t portId,
53860 + uint16_t relativeProfile,
53861 + uint16_t *p_AbsoluteId)
53862 +{
53863 + t_Fm *p_Fm;
53864 + t_FmSp *p_FmPcdSp;
53865 + uint8_t swPortIndex=0, hardwarePortId;
53866 + t_Error err;
53867 +
53868 + ASSERT_COND(h_Fm);
53869 + p_Fm = (t_Fm*)h_Fm;
53870 +
53871 + err = FmVSPCheckRelativeProfile(h_Fm, portType, portId, relativeProfile);
53872 + if (err != E_OK)
53873 + return err;
53874 +
53875 + hardwarePortId = SwPortIdToHwPortId(portType,
53876 + portId,
53877 + p_Fm->p_FmStateStruct->revInfo.majorRev,
53878 + p_Fm->p_FmStateStruct->revInfo.minorRev);
53879 + ASSERT_COND(hardwarePortId);
53880 + HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
53881 +
53882 + p_FmPcdSp = p_Fm->p_FmSp;
53883 + ASSERT_COND(p_FmPcdSp);
53884 +
53885 + *p_AbsoluteId = (uint16_t)(p_FmPcdSp->portsMapping[swPortIndex].profilesBase + relativeProfile);
53886 +
53887 + return E_OK;
53888 +}
53889 +#endif /* (DPAA_VERSION >= 11) */
53890 +
53891 +static t_Error InitFmDma(t_Fm *p_Fm)
53892 +{
53893 + t_Error err;
53894 +
53895 + err = (t_Error)fman_dma_init(p_Fm->p_FmDmaRegs, p_Fm->p_FmDriverParam);
53896 + if (err != E_OK)
53897 + return err;
53898 +
53899 + /* Allocate MURAM for CAM */
53900 + p_Fm->camBaseAddr = PTR_TO_UINT(FM_MURAM_AllocMem(p_Fm->h_FmMuram,
53901 + (uint32_t)(p_Fm->p_FmDriverParam->dma_cam_num_of_entries*DMA_CAM_SIZEOF_ENTRY),
53902 + DMA_CAM_ALIGN));
53903 + if (!p_Fm->camBaseAddr)
53904 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for DMA CAM failed"));
53905 +
53906 + WRITE_BLOCK(UINT_TO_PTR(p_Fm->camBaseAddr),
53907 + 0,
53908 + (uint32_t)(p_Fm->p_FmDriverParam->dma_cam_num_of_entries*DMA_CAM_SIZEOF_ENTRY));
53909 +
53910 + if (p_Fm->p_FmStateStruct->revInfo.majorRev == 2)
53911 + {
53912 + FM_MURAM_FreeMem(p_Fm->h_FmMuram, UINT_TO_PTR(p_Fm->camBaseAddr));
53913 +
53914 + p_Fm->camBaseAddr = PTR_TO_UINT(FM_MURAM_AllocMem(p_Fm->h_FmMuram,
53915 + (uint32_t)(p_Fm->p_FmDriverParam->dma_cam_num_of_entries*72 + 128),
53916 + 64));
53917 + if (!p_Fm->camBaseAddr)
53918 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for DMA CAM failed"));
53919 +
53920 + WRITE_BLOCK(UINT_TO_PTR(p_Fm->camBaseAddr),
53921 + 0,
53922 + (uint32_t)(p_Fm->p_FmDriverParam->dma_cam_num_of_entries*72 + 128));
53923 +
53924 + switch(p_Fm->p_FmDriverParam->dma_cam_num_of_entries)
53925 + {
53926 + case (8):
53927 + WRITE_UINT32(*(uint32_t*)p_Fm->camBaseAddr, 0xff000000);
53928 + break;
53929 + case (16):
53930 + WRITE_UINT32(*(uint32_t*)p_Fm->camBaseAddr, 0xffff0000);
53931 + break;
53932 + case (24):
53933 + WRITE_UINT32(*(uint32_t*)p_Fm->camBaseAddr, 0xffffff00);
53934 + break;
53935 + case (32):
53936 + WRITE_UINT32(*(uint32_t*)p_Fm->camBaseAddr, 0xffffffff);
53937 + break;
53938 + default:
53939 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("wrong dma_cam_num_of_entries"));
53940 + }
53941 + }
53942 +
53943 + p_Fm->p_FmDriverParam->cam_base_addr =
53944 + (uint32_t)(XX_VirtToPhys(UINT_TO_PTR(p_Fm->camBaseAddr)) - p_Fm->fmMuramPhysBaseAddr);
53945 +
53946 + return E_OK;
53947 +}
53948 +
53949 +static t_Error InitFmFpm(t_Fm *p_Fm)
53950 +{
53951 + return (t_Error)fman_fpm_init(p_Fm->p_FmFpmRegs, p_Fm->p_FmDriverParam);
53952 +}
53953 +
53954 +static t_Error InitFmBmi(t_Fm *p_Fm)
53955 +{
53956 + return (t_Error)fman_bmi_init(p_Fm->p_FmBmiRegs, p_Fm->p_FmDriverParam);
53957 +}
53958 +
53959 +static t_Error InitFmQmi(t_Fm *p_Fm)
53960 +{
53961 + return (t_Error)fman_qmi_init(p_Fm->p_FmQmiRegs, p_Fm->p_FmDriverParam);
53962 +}
53963 +
53964 +static t_Error InitGuestMode(t_Fm *p_Fm)
53965 +{
53966 + t_Error err = E_OK;
53967 + int i;
53968 + t_FmIpcMsg msg;
53969 + t_FmIpcReply reply;
53970 + uint32_t replyLength;
53971 +
53972 + ASSERT_COND(p_Fm);
53973 + ASSERT_COND(p_Fm->guestId != NCSW_MASTER_ID);
53974 +
53975 + /* build the FM guest partition IPC address */
53976 + if (Sprint (p_Fm->fmModuleName, "FM_%d_%d",p_Fm->p_FmStateStruct->fmId, p_Fm->guestId) != (p_Fm->guestId<10 ? 6:7))
53977 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
53978 +
53979 + /* build the FM master partition IPC address */
53980 + memset(p_Fm->fmIpcHandlerModuleName, 0, (sizeof(char)) * MODULE_NAME_SIZE);
53981 + if (Sprint (p_Fm->fmIpcHandlerModuleName[0], "FM_%d_%d",p_Fm->p_FmStateStruct->fmId, NCSW_MASTER_ID) != 6)
53982 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
53983 +
53984 + for (i=0;i<e_FM_EV_DUMMY_LAST;i++)
53985 + p_Fm->intrMng[i].f_Isr = UnimplementedIsr;
53986 +
53987 + p_Fm->h_IpcSessions[0] = XX_IpcInitSession(p_Fm->fmIpcHandlerModuleName[0], p_Fm->fmModuleName);
53988 + if (p_Fm->h_IpcSessions[0])
53989 + {
53990 + uint8_t isMasterAlive;
53991 + t_FmIpcParams ipcParams;
53992 +
53993 + err = XX_IpcRegisterMsgHandler(p_Fm->fmModuleName, FmGuestHandleIpcMsgCB, p_Fm, FM_IPC_MAX_REPLY_SIZE);
53994 + if (err)
53995 + RETURN_ERROR(MAJOR, err, NO_MSG);
53996 +
53997 + memset(&msg, 0, sizeof(msg));
53998 + memset(&reply, 0, sizeof(reply));
53999 + msg.msgId = FM_MASTER_IS_ALIVE;
54000 + msg.msgBody[0] = p_Fm->guestId;
54001 + replyLength = sizeof(uint32_t) + sizeof(uint8_t);
54002 + do
54003 + {
54004 + blockingFlag = TRUE;
54005 + if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
54006 + (uint8_t*)&msg,
54007 + sizeof(msg.msgId)+sizeof(p_Fm->guestId),
54008 + (uint8_t*)&reply,
54009 + &replyLength,
54010 + IpcMsgCompletionCB,
54011 + p_Fm)) != E_OK)
54012 + REPORT_ERROR(MINOR, err, NO_MSG);
54013 + while (blockingFlag) ;
54014 + if (replyLength != (sizeof(uint32_t) + sizeof(uint8_t)))
54015 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
54016 + isMasterAlive = *(uint8_t*)(reply.replyBody);
54017 + } while (!isMasterAlive);
54018 +
54019 + /* read FM parameters and save */
54020 + memset(&msg, 0, sizeof(msg));
54021 + memset(&reply, 0, sizeof(reply));
54022 + msg.msgId = FM_GET_PARAMS;
54023 + replyLength = sizeof(uint32_t) + sizeof(t_FmIpcParams);
54024 + if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
54025 + (uint8_t*)&msg,
54026 + sizeof(msg.msgId),
54027 + (uint8_t*)&reply,
54028 + &replyLength,
54029 + NULL,
54030 + NULL)) != E_OK)
54031 + RETURN_ERROR(MAJOR, err, NO_MSG);
54032 + if (replyLength != (sizeof(uint32_t) + sizeof(t_FmIpcParams)))
54033 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
54034 + memcpy((uint8_t*)&ipcParams, reply.replyBody, sizeof(t_FmIpcParams));
54035 +
54036 + p_Fm->p_FmStateStruct->fmClkFreq = ipcParams.fmClkFreq;
54037 + p_Fm->p_FmStateStruct->fmMacClkFreq = ipcParams.fmMacClkFreq;
54038 + p_Fm->p_FmStateStruct->revInfo.majorRev = ipcParams.majorRev;
54039 + p_Fm->p_FmStateStruct->revInfo.minorRev = ipcParams.minorRev;
54040 + }
54041 + else
54042 + {
54043 + DBG(WARNING, ("FM Guest mode - without IPC"));
54044 + if (!p_Fm->p_FmStateStruct->fmClkFreq)
54045 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("No fmClkFreq configured for guest without IPC"));
54046 + if (p_Fm->baseAddr)
54047 + {
54048 + fman_get_revision(p_Fm->p_FmFpmRegs,
54049 + &p_Fm->p_FmStateStruct->revInfo.majorRev,
54050 + &p_Fm->p_FmStateStruct->revInfo.minorRev);
54051 +
54052 + }
54053 + }
54054 +
54055 +#if (DPAA_VERSION >= 11)
54056 + p_Fm->partVSPBase = AllocVSPsForPartition(p_Fm, p_Fm->partVSPBase, p_Fm->partNumOfVSPs, p_Fm->guestId);
54057 + if (p_Fm->partVSPBase == (uint8_t)(ILLEGAL_BASE))
54058 + DBG(WARNING, ("partition VSPs allocation is FAILED"));
54059 +#endif /* (DPAA_VERSION >= 11) */
54060 +
54061 + /* General FM driver initialization */
54062 + if (p_Fm->baseAddr)
54063 + p_Fm->fmMuramPhysBaseAddr =
54064 + (uint64_t)(XX_VirtToPhys(UINT_TO_PTR(p_Fm->baseAddr + FM_MM_MURAM)));
54065 +
54066 + XX_Free(p_Fm->p_FmDriverParam);
54067 + p_Fm->p_FmDriverParam = NULL;
54068 +
54069 + if ((p_Fm->guestId == NCSW_MASTER_ID) ||
54070 + (p_Fm->h_IpcSessions[0]))
54071 + {
54072 + FM_DisableRamsEcc(p_Fm);
54073 + FmMuramClear(p_Fm->h_FmMuram);
54074 + FM_EnableRamsEcc(p_Fm);
54075 + }
54076 +
54077 + return E_OK;
54078 +}
54079 +
54080 +static __inline__ enum fman_exceptions FmanExceptionTrans(e_FmExceptions exception)
54081 +{
54082 + switch (exception) {
54083 + case e_FM_EX_DMA_BUS_ERROR:
54084 + return E_FMAN_EX_DMA_BUS_ERROR;
54085 + case e_FM_EX_DMA_READ_ECC:
54086 + return E_FMAN_EX_DMA_READ_ECC;
54087 + case e_FM_EX_DMA_SYSTEM_WRITE_ECC:
54088 + return E_FMAN_EX_DMA_SYSTEM_WRITE_ECC;
54089 + case e_FM_EX_DMA_FM_WRITE_ECC:
54090 + return E_FMAN_EX_DMA_FM_WRITE_ECC;
54091 + case e_FM_EX_FPM_STALL_ON_TASKS:
54092 + return E_FMAN_EX_FPM_STALL_ON_TASKS;
54093 + case e_FM_EX_FPM_SINGLE_ECC:
54094 + return E_FMAN_EX_FPM_SINGLE_ECC;
54095 + case e_FM_EX_FPM_DOUBLE_ECC:
54096 + return E_FMAN_EX_FPM_DOUBLE_ECC;
54097 + case e_FM_EX_QMI_SINGLE_ECC:
54098 + return E_FMAN_EX_QMI_SINGLE_ECC;
54099 + case e_FM_EX_QMI_DOUBLE_ECC:
54100 + return E_FMAN_EX_QMI_DOUBLE_ECC;
54101 + case e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID:
54102 + return E_FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID;
54103 + case e_FM_EX_BMI_LIST_RAM_ECC:
54104 + return E_FMAN_EX_BMI_LIST_RAM_ECC;
54105 + case e_FM_EX_BMI_STORAGE_PROFILE_ECC:
54106 + return E_FMAN_EX_BMI_STORAGE_PROFILE_ECC;
54107 + case e_FM_EX_BMI_STATISTICS_RAM_ECC:
54108 + return E_FMAN_EX_BMI_STATISTICS_RAM_ECC;
54109 + case e_FM_EX_BMI_DISPATCH_RAM_ECC:
54110 + return E_FMAN_EX_BMI_DISPATCH_RAM_ECC;
54111 + case e_FM_EX_IRAM_ECC:
54112 + return E_FMAN_EX_IRAM_ECC;
54113 + case e_FM_EX_MURAM_ECC:
54114 + return E_FMAN_EX_MURAM_ECC;
54115 + default:
54116 + return E_FMAN_EX_DMA_BUS_ERROR;
54117 + }
54118 +}
54119 +
54120 +uint8_t SwPortIdToHwPortId(e_FmPortType type, uint8_t relativePortId, uint8_t majorRev, uint8_t minorRev)
54121 +{
54122 + switch (type)
54123 + {
54124 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
54125 + case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
54126 + CHECK_PORT_ID_OH_PORTS(relativePortId);
54127 + return (uint8_t)(BASE_OH_PORTID + (relativePortId));
54128 + case (e_FM_PORT_TYPE_RX):
54129 + CHECK_PORT_ID_1G_RX_PORTS(relativePortId);
54130 + return (uint8_t)(BASE_1G_RX_PORTID + (relativePortId));
54131 + case (e_FM_PORT_TYPE_RX_10G):
54132 + /* The 10G port in T1024 (FMan Version 6.4) is the first port.
54133 + * This is the reason why the 1G port offset is used.
54134 + */
54135 + if (majorRev == 6 && minorRev == 4)
54136 + {
54137 + CHECK_PORT_ID_1G_RX_PORTS(relativePortId);
54138 + return (uint8_t)(BASE_1G_RX_PORTID + (relativePortId));
54139 + }
54140 + else
54141 + {
54142 + CHECK_PORT_ID_10G_RX_PORTS(relativePortId);
54143 + return (uint8_t)(BASE_10G_RX_PORTID + (relativePortId));
54144 + }
54145 + case (e_FM_PORT_TYPE_TX):
54146 + CHECK_PORT_ID_1G_TX_PORTS(relativePortId);
54147 + return (uint8_t)(BASE_1G_TX_PORTID + (relativePortId));
54148 + case (e_FM_PORT_TYPE_TX_10G):
54149 + /* The 10G port in T1024 (FMan Version 6.4) is the first port.
54150 + * This is the reason why the 1G port offset is used.
54151 + */
54152 + if (majorRev == 6 && minorRev == 4)
54153 + {
54154 + CHECK_PORT_ID_1G_TX_PORTS(relativePortId);
54155 + return (uint8_t)(BASE_1G_TX_PORTID + (relativePortId));
54156 + }
54157 + else
54158 + {
54159 + CHECK_PORT_ID_10G_TX_PORTS(relativePortId);
54160 + return (uint8_t)(BASE_10G_TX_PORTID + (relativePortId));
54161 + }
54162 + default:
54163 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal port type"));
54164 + return 0;
54165 + }
54166 +}
54167 +
54168 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
54169 +t_Error FmDumpPortRegs (t_Handle h_Fm, uint8_t hardwarePortId)
54170 +{
54171 + t_Fm *p_Fm = (t_Fm *)h_Fm;
54172 +
54173 + DECLARE_DUMP;
54174 +
54175 + ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
54176 +
54177 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54178 + SANITY_CHECK_RETURN_ERROR(((p_Fm->guestId == NCSW_MASTER_ID) ||
54179 + p_Fm->baseAddr), E_INVALID_OPERATION);
54180 +
54181 + DUMP_TITLE(&p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId-1], ("fmbm_pp for port %u", (hardwarePortId)));
54182 + DUMP_MEMORY(&p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId-1], sizeof(uint32_t));
54183 +
54184 + DUMP_TITLE(&p_Fm->p_FmBmiRegs->fmbm_pfs[hardwarePortId-1], ("fmbm_pfs for port %u", (hardwarePortId )));
54185 + DUMP_MEMORY(&p_Fm->p_FmBmiRegs->fmbm_pfs[hardwarePortId-1], sizeof(uint32_t));
54186 +
54187 + DUMP_TITLE(&p_Fm->p_FmBmiRegs->fmbm_spliodn[hardwarePortId-1], ("fmbm_spliodn for port %u", (hardwarePortId)));
54188 + DUMP_MEMORY(&p_Fm->p_FmBmiRegs->fmbm_spliodn[hardwarePortId-1], sizeof(uint32_t));
54189 +
54190 + DUMP_TITLE(&p_Fm->p_FmFpmRegs->fmfp_ps[hardwarePortId], ("fmfp_ps for port %u", (hardwarePortId)));
54191 + DUMP_MEMORY(&p_Fm->p_FmFpmRegs->fmfp_ps[hardwarePortId], sizeof(uint32_t));
54192 +
54193 + DUMP_TITLE(&p_Fm->p_FmDmaRegs->fmdmplr[hardwarePortId/2], ("fmdmplr for port %u", (hardwarePortId)));
54194 + DUMP_MEMORY(&p_Fm->p_FmDmaRegs->fmdmplr[hardwarePortId/2], sizeof(uint32_t));
54195 +
54196 + return E_OK;
54197 +}
54198 +#endif /* (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)) */
54199 +
54200 +
54201 +/*****************************************************************************/
54202 +/* API Init unit functions */
54203 +/*****************************************************************************/
54204 +t_Handle FM_Config(t_FmParams *p_FmParam)
54205 +{
54206 + t_Fm *p_Fm;
54207 + uint8_t i;
54208 + uintptr_t baseAddr;
54209 +
54210 + SANITY_CHECK_RETURN_VALUE(p_FmParam, E_NULL_POINTER, NULL);
54211 + SANITY_CHECK_RETURN_VALUE(((p_FmParam->firmware.p_Code && p_FmParam->firmware.size) ||
54212 + (!p_FmParam->firmware.p_Code && !p_FmParam->firmware.size)),
54213 + E_INVALID_VALUE, NULL);
54214 +
54215 + baseAddr = p_FmParam->baseAddr;
54216 +
54217 + /* Allocate FM structure */
54218 + p_Fm = (t_Fm *) XX_Malloc(sizeof(t_Fm));
54219 + if (!p_Fm)
54220 + {
54221 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM driver structure"));
54222 + return NULL;
54223 + }
54224 + memset(p_Fm, 0, sizeof(t_Fm));
54225 +
54226 + p_Fm->p_FmStateStruct = (t_FmStateStruct *) XX_Malloc(sizeof(t_FmStateStruct));
54227 + if (!p_Fm->p_FmStateStruct)
54228 + {
54229 + XX_Free(p_Fm);
54230 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Status structure"));
54231 + return NULL;
54232 + }
54233 + memset(p_Fm->p_FmStateStruct, 0, sizeof(t_FmStateStruct));
54234 +
54235 + /* Initialize FM parameters which will be kept by the driver */
54236 + p_Fm->p_FmStateStruct->fmId = p_FmParam->fmId;
54237 + p_Fm->guestId = p_FmParam->guestId;
54238 +
54239 + for (i=0; i<FM_MAX_NUM_OF_HW_PORT_IDS; i++)
54240 + p_Fm->p_FmStateStruct->portsTypes[i] = e_FM_PORT_TYPE_DUMMY;
54241 +
54242 + /* Allocate the FM driver's parameters structure */
54243 + p_Fm->p_FmDriverParam = (struct fman_cfg *)XX_Malloc(sizeof(struct fman_cfg));
54244 + if (!p_Fm->p_FmDriverParam)
54245 + {
54246 + XX_Free(p_Fm->p_FmStateStruct);
54247 + XX_Free(p_Fm);
54248 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM driver parameters"));
54249 + return NULL;
54250 + }
54251 + memset(p_Fm->p_FmDriverParam, 0, sizeof(struct fman_cfg));
54252 +
54253 +#if (DPAA_VERSION >= 11)
54254 + p_Fm->p_FmSp = (t_FmSp *)XX_Malloc(sizeof(t_FmSp));
54255 + if (!p_Fm->p_FmSp)
54256 + {
54257 + XX_Free(p_Fm->p_FmDriverParam);
54258 + XX_Free(p_Fm->p_FmStateStruct);
54259 + XX_Free(p_Fm);
54260 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("allocation for internal data structure failed"));
54261 + return NULL;
54262 + }
54263 + memset(p_Fm->p_FmSp, 0, sizeof(t_FmSp));
54264 +
54265 + for (i=0; i<FM_VSP_MAX_NUM_OF_ENTRIES; i++)
54266 + p_Fm->p_FmSp->profiles[i].profilesMng.ownerId = (uint8_t)ILLEGAL_BASE;
54267 +#endif /* (DPAA_VERSION >= 11) */
54268 +
54269 + /* Initialize FM parameters which will be kept by the driver */
54270 + p_Fm->p_FmStateStruct->fmId = p_FmParam->fmId;
54271 + p_Fm->h_FmMuram = p_FmParam->h_FmMuram;
54272 + p_Fm->h_App = p_FmParam->h_App;
54273 + p_Fm->p_FmStateStruct->fmClkFreq = p_FmParam->fmClkFreq;
54274 + p_Fm->p_FmStateStruct->fmMacClkFreq = p_FmParam->fmClkFreq / ((!p_FmParam->fmMacClkRatio)? 2: p_FmParam->fmMacClkRatio);
54275 + p_Fm->f_Exception = p_FmParam->f_Exception;
54276 + p_Fm->f_BusError = p_FmParam->f_BusError;
54277 + p_Fm->p_FmFpmRegs = (struct fman_fpm_regs *)UINT_TO_PTR(baseAddr + FM_MM_FPM);
54278 + p_Fm->p_FmBmiRegs = (struct fman_bmi_regs *)UINT_TO_PTR(baseAddr + FM_MM_BMI);
54279 + p_Fm->p_FmQmiRegs = (struct fman_qmi_regs *)UINT_TO_PTR(baseAddr + FM_MM_QMI);
54280 + p_Fm->p_FmDmaRegs = (struct fman_dma_regs *)UINT_TO_PTR(baseAddr + FM_MM_DMA);
54281 + p_Fm->p_FmRegs = (struct fman_regs *)UINT_TO_PTR(baseAddr + FM_MM_BMI);
54282 + p_Fm->baseAddr = baseAddr;
54283 + p_Fm->p_FmStateStruct->irq = p_FmParam->irq;
54284 + p_Fm->p_FmStateStruct->errIrq = p_FmParam->errIrq;
54285 + p_Fm->hcPortInitialized = FALSE;
54286 + p_Fm->independentMode = FALSE;
54287 +
54288 + p_Fm->h_Spinlock = XX_InitSpinlock();
54289 + if (!p_Fm->h_Spinlock)
54290 + {
54291 + XX_Free(p_Fm->p_FmDriverParam);
54292 + XX_Free(p_Fm->p_FmStateStruct);
54293 + XX_Free(p_Fm);
54294 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("can't allocate spinlock!"));
54295 + return NULL;
54296 + }
54297 +
54298 +#if (DPAA_VERSION >= 11)
54299 + p_Fm->partVSPBase = p_FmParam->partVSPBase;
54300 + p_Fm->partNumOfVSPs = p_FmParam->partNumOfVSPs;
54301 + p_Fm->vspBaseAddr = p_FmParam->vspBaseAddr;
54302 +#endif /* (DPAA_VERSION >= 11) */
54303 +
54304 + fman_defconfig(p_Fm->p_FmDriverParam,
54305 + !!(p_Fm->guestId == NCSW_MASTER_ID));
54306 +/* overide macros dependent parameters */
54307 +#ifdef FM_PEDANTIC_DMA
54308 + p_Fm->p_FmDriverParam->pedantic_dma = TRUE;
54309 + p_Fm->p_FmDriverParam->dma_aid_override = TRUE;
54310 +#endif /* FM_PEDANTIC_DMA */
54311 +#ifndef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
54312 + p_Fm->p_FmDriverParam->qmi_deq_option_support = TRUE;
54313 +#endif /* !FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
54314 +
54315 + p_Fm->p_FmStateStruct->ramsEccEnable = FALSE;
54316 + p_Fm->p_FmStateStruct->extraFifoPoolSize = 0;
54317 + p_Fm->p_FmStateStruct->exceptions = DEFAULT_exceptions;
54318 + p_Fm->resetOnInit = DEFAULT_resetOnInit;
54319 + p_Fm->fwVerify = DEFAULT_VerifyUcode;
54320 + p_Fm->firmware.size = p_FmParam->firmware.size;
54321 + if (p_Fm->firmware.size)
54322 + {
54323 + p_Fm->firmware.p_Code = (uint32_t *)XX_Malloc(p_Fm->firmware.size);
54324 + if (!p_Fm->firmware.p_Code)
54325 + {
54326 + XX_FreeSpinlock(p_Fm->h_Spinlock);
54327 + XX_Free(p_Fm->p_FmStateStruct);
54328 + XX_Free(p_Fm->p_FmDriverParam);
54329 + XX_Free(p_Fm);
54330 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM firmware code"));
54331 + return NULL;
54332 + }
54333 + memcpy(p_Fm->firmware.p_Code, p_FmParam->firmware.p_Code ,p_Fm->firmware.size);
54334 + }
54335 +
54336 + if (p_Fm->guestId != NCSW_MASTER_ID)
54337 + return p_Fm;
54338 +
54339 + /* read revision */
54340 + /* Chip dependent, will be configured in Init */
54341 + fman_get_revision(p_Fm->p_FmFpmRegs,
54342 + &p_Fm->p_FmStateStruct->revInfo.majorRev,
54343 + &p_Fm->p_FmStateStruct->revInfo.minorRev);
54344 +
54345 +#ifdef FM_AID_MODE_NO_TNUM_SW005
54346 + if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
54347 + p_Fm->p_FmDriverParam->dma_aid_mode = e_FM_DMA_AID_OUT_PORT_ID;
54348 +#endif /* FM_AID_MODE_NO_TNUM_SW005 */
54349 +#ifndef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
54350 + if (p_Fm->p_FmStateStruct->revInfo.majorRev != 4)
54351 + p_Fm->p_FmDriverParam->qmi_def_tnums_thresh = QMI_DEF_TNUMS_THRESH;
54352 +#endif /* FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
54353 +
54354 + p_Fm->p_FmStateStruct->totalFifoSize = 0;
54355 + p_Fm->p_FmStateStruct->totalNumOfTasks =
54356 + DEFAULT_totalNumOfTasks(p_Fm->p_FmStateStruct->revInfo.majorRev,
54357 + p_Fm->p_FmStateStruct->revInfo.minorRev);
54358 +
54359 +#ifdef FM_HAS_TOTAL_DMAS
54360 + p_Fm->p_FmStateStruct->maxNumOfOpenDmas = BMI_MAX_NUM_OF_DMAS;
54361 +#endif /* FM_HAS_TOTAL_DMAS */
54362 +#if (DPAA_VERSION < 11)
54363 + p_Fm->p_FmDriverParam->dma_comm_qtsh_clr_emer = DEFAULT_dmaCommQLow;
54364 + p_Fm->p_FmDriverParam->dma_comm_qtsh_asrt_emer = DEFAULT_dmaCommQHigh;
54365 + p_Fm->p_FmDriverParam->dma_cam_num_of_entries = DEFAULT_dmaCamNumOfEntries;
54366 + p_Fm->p_FmDriverParam->dma_read_buf_tsh_clr_emer = DEFAULT_dmaReadIntBufLow;
54367 + p_Fm->p_FmDriverParam->dma_read_buf_tsh_asrt_emer = DEFAULT_dmaReadIntBufHigh;
54368 + p_Fm->p_FmDriverParam->dma_write_buf_tsh_clr_emer = DEFAULT_dmaWriteIntBufLow;
54369 + p_Fm->p_FmDriverParam->dma_write_buf_tsh_asrt_emer = DEFAULT_dmaWriteIntBufHigh;
54370 + p_Fm->p_FmDriverParam->dma_axi_dbg_num_of_beats = DEFAULT_axiDbgNumOfBeats;
54371 +#endif /* (DPAA_VERSION < 11) */
54372 +#ifdef FM_NO_TNUM_AGING
54373 + p_Fm->p_FmDriverParam->tnum_aging_period = 0;
54374 +#endif
54375 + p_Fm->tnumAgingPeriod = p_Fm->p_FmDriverParam->tnum_aging_period;
54376 +
54377 + return p_Fm;
54378 +}
54379 +
54380 +/**************************************************************************//**
54381 + @Function FM_Init
54382 +
54383 + @Description Initializes the FM module
54384 +
54385 + @Param[in] h_Fm - FM module descriptor
54386 +
54387 + @Return E_OK on success; Error code otherwise.
54388 +*//***************************************************************************/
54389 +t_Error FM_Init(t_Handle h_Fm)
54390 +{
54391 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54392 + struct fman_cfg *p_FmDriverParam = NULL;
54393 + t_Error err = E_OK;
54394 + int i;
54395 + t_FmRevisionInfo revInfo;
54396 + struct fman_rg fman_rg;
54397 +
54398 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54399 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54400 +
54401 + fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
54402 + fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
54403 + fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
54404 + fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
54405 +
54406 + p_Fm->p_FmStateStruct->count1MicroBit = FM_TIMESTAMP_1_USEC_BIT;
54407 + p_Fm->p_FmDriverParam->num_of_fman_ctrl_evnt_regs = FM_NUM_OF_FMAN_CTRL_EVENT_REGS;
54408 +
54409 + if (p_Fm->guestId != NCSW_MASTER_ID)
54410 + return InitGuestMode(p_Fm);
54411 +
54412 + /* if user didn't configured totalFifoSize - (totalFifoSize=0) we configure default
54413 + * according to chip. otherwise, we use user's configuration.
54414 + */
54415 + if (p_Fm->p_FmStateStruct->totalFifoSize == 0)
54416 + p_Fm->p_FmStateStruct->totalFifoSize = DEFAULT_totalFifoSize(p_Fm->p_FmStateStruct->revInfo.majorRev,
54417 + p_Fm->p_FmStateStruct->revInfo.minorRev);
54418 +
54419 + CHECK_INIT_PARAMETERS(p_Fm, CheckFmParameters);
54420 +
54421 + p_FmDriverParam = p_Fm->p_FmDriverParam;
54422 +
54423 + FM_GetRevision(p_Fm, &revInfo);
54424 +
54425 + /* clear revision-dependent non existing exception */
54426 +#ifdef FM_NO_DISPATCH_RAM_ECC
54427 + if ((revInfo.majorRev != 4) &&
54428 + (revInfo.majorRev < 6))
54429 + p_Fm->p_FmStateStruct->exceptions &= ~FM_EX_BMI_DISPATCH_RAM_ECC;
54430 +#endif /* FM_NO_DISPATCH_RAM_ECC */
54431 +
54432 +#ifdef FM_QMI_NO_ECC_EXCEPTIONS
54433 + if (revInfo.majorRev == 4)
54434 + p_Fm->p_FmStateStruct->exceptions &= ~(FM_EX_QMI_SINGLE_ECC | FM_EX_QMI_DOUBLE_ECC);
54435 +#endif /* FM_QMI_NO_ECC_EXCEPTIONS */
54436 +
54437 +#ifdef FM_QMI_NO_SINGLE_ECC_EXCEPTION
54438 + if (revInfo.majorRev >= 6)
54439 + p_Fm->p_FmStateStruct->exceptions &= ~FM_EX_QMI_SINGLE_ECC;
54440 +#endif /* FM_QMI_NO_SINGLE_ECC_EXCEPTION */
54441 +
54442 + FmMuramClear(p_Fm->h_FmMuram);
54443 +
54444 + /* clear CPG */
54445 + IOMemSet32(UINT_TO_PTR(p_Fm->baseAddr + FM_MM_CGP), 0, FM_PORT_NUM_OF_CONGESTION_GRPS);
54446 +
54447 + /* add to the default exceptions the user's definitions */
54448 + p_Fm->p_FmStateStruct->exceptions |= p_Fm->userSetExceptions;
54449 +
54450 + /* Reset the FM if required */
54451 + if (p_Fm->resetOnInit)
54452 + {
54453 +#ifdef FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173
54454 + if ((err = FwNotResetErratumBugzilla6173WA(p_Fm)) != E_OK)
54455 + RETURN_ERROR(MAJOR, err, NO_MSG);
54456 +#else /* not FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173 */
54457 +#ifndef CONFIG_FMAN_ARM
54458 + {
54459 + u32 svr = mfspr(SPRN_SVR);
54460 +
54461 + if (((SVR_SOC_VER(svr) == SVR_T4240 && SVR_REV(svr) > 0x10)) ||
54462 + ((SVR_SOC_VER(svr) == SVR_T4160 && SVR_REV(svr) > 0x10)) ||
54463 + ((SVR_SOC_VER(svr) == SVR_T4080 && SVR_REV(svr) > 0x10)) ||
54464 + (SVR_SOC_VER(svr) == SVR_T1024) ||
54465 + (SVR_SOC_VER(svr) == SVR_T1023) ||
54466 + (SVR_SOC_VER(svr) == SVR_T2080) ||
54467 + (SVR_SOC_VER(svr) == SVR_T2081)) {
54468 + DBG(WARNING, ("Hack: No FM reset!\n"));
54469 + } else {
54470 + WRITE_UINT32(p_Fm->p_FmFpmRegs->fm_rstc, FPM_RSTC_FM_RESET);
54471 + CORE_MemoryBarrier();
54472 + XX_UDelay(100);
54473 + }
54474 + }
54475 +#endif
54476 + if (fman_is_qmi_halt_not_busy_state(p_Fm->p_FmQmiRegs))
54477 + {
54478 + fman_resume(p_Fm->p_FmFpmRegs);
54479 + XX_UDelay(100);
54480 + }
54481 +#endif /* not FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173 */
54482 + }
54483 +
54484 +#ifdef FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173
54485 + if (!p_Fm->resetOnInit) /* Skip operations done in errata workaround */
54486 + {
54487 +#endif /* FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173 */
54488 + /* Load FMan-Controller code to IRAM */
54489 +
54490 + ClearIRam(p_Fm);
54491 +
54492 + if (p_Fm->firmware.p_Code && (LoadFmanCtrlCode(p_Fm) != E_OK))
54493 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
54494 +#ifdef FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173
54495 + }
54496 +#endif /* FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173 */
54497 +
54498 +#ifdef FM_CAPWAP_SUPPORT
54499 + /* save first 256 byte in MURAM */
54500 + p_Fm->resAddr = PTR_TO_UINT(FM_MURAM_AllocMem(p_Fm->h_FmMuram, 256, 0));
54501 + if (!p_Fm->resAddr)
54502 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for reserved Area failed"));
54503 +
54504 + WRITE_BLOCK(UINT_TO_PTR(p_Fm->resAddr), 0, 256);
54505 +#endif /* FM_CAPWAP_SUPPORT */
54506 +
54507 +#if (DPAA_VERSION >= 11)
54508 + p_Fm->partVSPBase = AllocVSPsForPartition(h_Fm, p_Fm->partVSPBase, p_Fm->partNumOfVSPs, p_Fm->guestId);
54509 + if (p_Fm->partVSPBase == (uint8_t)(ILLEGAL_BASE))
54510 + DBG(WARNING, ("partition VSPs allocation is FAILED"));
54511 +#endif /* (DPAA_VERSION >= 11) */
54512 +
54513 + /* General FM driver initialization */
54514 + p_Fm->fmMuramPhysBaseAddr =
54515 + (uint64_t)(XX_VirtToPhys(UINT_TO_PTR(p_Fm->baseAddr + FM_MM_MURAM)));
54516 +
54517 + for (i=0;i<e_FM_EV_DUMMY_LAST;i++)
54518 + p_Fm->intrMng[i].f_Isr = UnimplementedIsr;
54519 + for (i=0;i<FM_NUM_OF_FMAN_CTRL_EVENT_REGS;i++)
54520 + p_Fm->fmanCtrlIntr[i].f_Isr = UnimplementedFmanCtrlIsr;
54521 +
54522 + p_FmDriverParam->exceptions = p_Fm->p_FmStateStruct->exceptions;
54523 +
54524 + /**********************/
54525 + /* Init DMA Registers */
54526 + /**********************/
54527 + err = InitFmDma(p_Fm);
54528 + if (err != E_OK)
54529 + {
54530 + FreeInitResources(p_Fm);
54531 + RETURN_ERROR(MAJOR, err, NO_MSG);
54532 + }
54533 +
54534 + /**********************/
54535 + /* Init FPM Registers */
54536 + /**********************/
54537 + err = InitFmFpm(p_Fm);
54538 + if (err != E_OK)
54539 + {
54540 + FreeInitResources(p_Fm);
54541 + RETURN_ERROR(MAJOR, err, NO_MSG);
54542 + }
54543 +
54544 + /* define common resources */
54545 + /* allocate MURAM for FIFO according to total size */
54546 + p_Fm->fifoBaseAddr = PTR_TO_UINT(FM_MURAM_AllocMem(p_Fm->h_FmMuram,
54547 + p_Fm->p_FmStateStruct->totalFifoSize,
54548 + BMI_FIFO_ALIGN));
54549 + if (!p_Fm->fifoBaseAddr)
54550 + {
54551 + FreeInitResources(p_Fm);
54552 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for BMI FIFO failed"));
54553 + }
54554 +
54555 + p_FmDriverParam->fifo_base_addr = (uint32_t)(XX_VirtToPhys(UINT_TO_PTR(p_Fm->fifoBaseAddr)) - p_Fm->fmMuramPhysBaseAddr);
54556 + p_FmDriverParam->total_fifo_size = p_Fm->p_FmStateStruct->totalFifoSize;
54557 + p_FmDriverParam->total_num_of_tasks = p_Fm->p_FmStateStruct->totalNumOfTasks;
54558 + p_FmDriverParam->clk_freq = p_Fm->p_FmStateStruct->fmClkFreq;
54559 +
54560 + /**********************/
54561 + /* Init BMI Registers */
54562 + /**********************/
54563 + err = InitFmBmi(p_Fm);
54564 + if (err != E_OK)
54565 + {
54566 + FreeInitResources(p_Fm);
54567 + RETURN_ERROR(MAJOR, err, NO_MSG);
54568 + }
54569 +
54570 + /**********************/
54571 + /* Init QMI Registers */
54572 + /**********************/
54573 + err = InitFmQmi(p_Fm);
54574 + if (err != E_OK)
54575 + {
54576 + FreeInitResources(p_Fm);
54577 + RETURN_ERROR(MAJOR, err, NO_MSG);
54578 + }
54579 +
54580 + /* build the FM master partition IPC address */
54581 + if (Sprint (p_Fm->fmModuleName, "FM_%d_%d",p_Fm->p_FmStateStruct->fmId, NCSW_MASTER_ID) != 6)
54582 + {
54583 + FreeInitResources(p_Fm);
54584 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
54585 + }
54586 +
54587 + err = XX_IpcRegisterMsgHandler(p_Fm->fmModuleName, FmHandleIpcMsgCB, p_Fm, FM_IPC_MAX_REPLY_SIZE);
54588 + if (err)
54589 + {
54590 + FreeInitResources(p_Fm);
54591 + RETURN_ERROR(MAJOR, err, NO_MSG);
54592 + }
54593 +
54594 + /* Register the FM interrupts handlers */
54595 + if (p_Fm->p_FmStateStruct->irq != NO_IRQ)
54596 + {
54597 + XX_SetIntr(p_Fm->p_FmStateStruct->irq, FM_EventIsr, p_Fm);
54598 + XX_EnableIntr(p_Fm->p_FmStateStruct->irq);
54599 + }
54600 +
54601 + if (p_Fm->p_FmStateStruct->errIrq != NO_IRQ)
54602 + {
54603 + XX_SetIntr(p_Fm->p_FmStateStruct->errIrq, (void (*) (t_Handle))FM_ErrorIsr, p_Fm);
54604 + XX_EnableIntr(p_Fm->p_FmStateStruct->errIrq);
54605 + }
54606 +
54607 + err = (t_Error)fman_enable(&fman_rg , p_FmDriverParam);
54608 + if (err != E_OK)
54609 + return err; /* FIXME */
54610 +
54611 + EnableTimeStamp(p_Fm);
54612 +
54613 + if (p_Fm->firmware.p_Code)
54614 + {
54615 + XX_Free(p_Fm->firmware.p_Code);
54616 + p_Fm->firmware.p_Code = NULL;
54617 + }
54618 +
54619 + XX_Free(p_Fm->p_FmDriverParam);
54620 + p_Fm->p_FmDriverParam = NULL;
54621 +
54622 + return E_OK;
54623 +}
54624 +
54625 +/**************************************************************************//**
54626 + @Function FM_Free
54627 +
54628 + @Description Frees all resources that were assigned to FM module.
54629 +
54630 + Calling this routine invalidates the descriptor.
54631 +
54632 + @Param[in] h_Fm - FM module descriptor
54633 +
54634 + @Return E_OK on success; Error code otherwise.
54635 +*//***************************************************************************/
54636 +t_Error FM_Free(t_Handle h_Fm)
54637 +{
54638 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54639 + struct fman_rg fman_rg;
54640 +
54641 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54642 +
54643 + fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
54644 + fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
54645 + fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
54646 + fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
54647 +
54648 + if (p_Fm->guestId != NCSW_MASTER_ID)
54649 + {
54650 +#if (DPAA_VERSION >= 11)
54651 + FreeVSPsForPartition(h_Fm, p_Fm->partVSPBase, p_Fm->partNumOfVSPs, p_Fm->guestId);
54652 +
54653 + if (p_Fm->p_FmSp)
54654 + {
54655 + XX_Free(p_Fm->p_FmSp);
54656 + p_Fm->p_FmSp = NULL;
54657 + }
54658 +#endif /* (DPAA_VERSION >= 11) */
54659 +
54660 + if (p_Fm->fmModuleName[0] != 0)
54661 + XX_IpcUnregisterMsgHandler(p_Fm->fmModuleName);
54662 +
54663 + if (!p_Fm->recoveryMode)
54664 + XX_Free(p_Fm->p_FmStateStruct);
54665 +
54666 + XX_Free(p_Fm);
54667 +
54668 + return E_OK;
54669 + }
54670 +
54671 + fman_free_resources(&fman_rg);
54672 +
54673 + if ((p_Fm->guestId == NCSW_MASTER_ID) && (p_Fm->fmModuleName[0] != 0))
54674 + XX_IpcUnregisterMsgHandler(p_Fm->fmModuleName);
54675 +
54676 + if (p_Fm->p_FmStateStruct)
54677 + {
54678 + if (p_Fm->p_FmStateStruct->irq != NO_IRQ)
54679 + {
54680 + XX_DisableIntr(p_Fm->p_FmStateStruct->irq);
54681 + XX_FreeIntr(p_Fm->p_FmStateStruct->irq);
54682 + }
54683 + if (p_Fm->p_FmStateStruct->errIrq != NO_IRQ)
54684 + {
54685 + XX_DisableIntr(p_Fm->p_FmStateStruct->errIrq);
54686 + XX_FreeIntr(p_Fm->p_FmStateStruct->errIrq);
54687 + }
54688 + }
54689 +
54690 +#if (DPAA_VERSION >= 11)
54691 + FreeVSPsForPartition(h_Fm, p_Fm->partVSPBase, p_Fm->partNumOfVSPs, p_Fm->guestId);
54692 +
54693 + if (p_Fm->p_FmSp)
54694 + {
54695 + XX_Free(p_Fm->p_FmSp);
54696 + p_Fm->p_FmSp = NULL;
54697 + }
54698 +#endif /* (DPAA_VERSION >= 11) */
54699 +
54700 + if (p_Fm->h_Spinlock)
54701 + XX_FreeSpinlock(p_Fm->h_Spinlock);
54702 +
54703 + if (p_Fm->p_FmDriverParam)
54704 + {
54705 + if (p_Fm->firmware.p_Code)
54706 + XX_Free(p_Fm->firmware.p_Code);
54707 + XX_Free(p_Fm->p_FmDriverParam);
54708 + p_Fm->p_FmDriverParam = NULL;
54709 + }
54710 +
54711 + FreeInitResources(p_Fm);
54712 +
54713 + if (!p_Fm->recoveryMode && p_Fm->p_FmStateStruct)
54714 + XX_Free(p_Fm->p_FmStateStruct);
54715 +
54716 + XX_Free(p_Fm);
54717 +
54718 + return E_OK;
54719 +}
54720 +
54721 +/*************************************************/
54722 +/* API Advanced Init unit functions */
54723 +/*************************************************/
54724 +
54725 +t_Error FM_ConfigResetOnInit(t_Handle h_Fm, bool enable)
54726 +{
54727 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54728 +
54729 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54730 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54731 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54732 +
54733 + p_Fm->resetOnInit = enable;
54734 +
54735 + return E_OK;
54736 +}
54737 +
54738 +t_Error FM_ConfigTotalFifoSize(t_Handle h_Fm, uint32_t totalFifoSize)
54739 +{
54740 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54741 +
54742 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54743 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54744 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54745 +
54746 + p_Fm->p_FmStateStruct->totalFifoSize = totalFifoSize;
54747 +
54748 + return E_OK;
54749 +}
54750 +
54751 +t_Error FM_ConfigDmaCacheOverride(t_Handle h_Fm, e_FmDmaCacheOverride cacheOverride)
54752 +{
54753 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54754 + enum fman_dma_cache_override fsl_cache_override;
54755 +
54756 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54757 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54758 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54759 +
54760 + FMAN_CACHE_OVERRIDE_TRANS(fsl_cache_override, cacheOverride)
54761 + p_Fm->p_FmDriverParam->dma_cache_override = fsl_cache_override;
54762 +
54763 + return E_OK;
54764 +}
54765 +
54766 +t_Error FM_ConfigDmaAidOverride(t_Handle h_Fm, bool aidOverride)
54767 +{
54768 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54769 +
54770 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54771 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54772 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54773 +
54774 + p_Fm->p_FmDriverParam->dma_aid_override = aidOverride;
54775 +
54776 + return E_OK;
54777 +}
54778 +
54779 +t_Error FM_ConfigDmaAidMode(t_Handle h_Fm, e_FmDmaAidMode aidMode)
54780 +{
54781 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54782 + enum fman_dma_aid_mode fsl_aid_mode;
54783 +
54784 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54785 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54786 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54787 +
54788 + FMAN_AID_MODE_TRANS(fsl_aid_mode, aidMode);
54789 + p_Fm->p_FmDriverParam->dma_aid_mode = fsl_aid_mode;
54790 +
54791 + return E_OK;
54792 +}
54793 +
54794 +t_Error FM_ConfigDmaAxiDbgNumOfBeats(t_Handle h_Fm, uint8_t axiDbgNumOfBeats)
54795 +{
54796 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54797 +
54798 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54799 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54800 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54801 +
54802 +#if (DPAA_VERSION >= 11)
54803 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Not available for this FM revision!"));
54804 +#else
54805 + p_Fm->p_FmDriverParam->dma_axi_dbg_num_of_beats = axiDbgNumOfBeats;
54806 +
54807 + return E_OK;
54808 +#endif /* (DPAA_VERSION >= 11) */
54809 +}
54810 +
54811 +t_Error FM_ConfigDmaCamNumOfEntries(t_Handle h_Fm, uint8_t numOfEntries)
54812 +{
54813 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54814 +
54815 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54816 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54817 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54818 +
54819 + p_Fm->p_FmDriverParam->dma_cam_num_of_entries = numOfEntries;
54820 +
54821 + return E_OK;
54822 +}
54823 +
54824 +t_Error FM_ConfigDmaDbgCounter(t_Handle h_Fm, e_FmDmaDbgCntMode fmDmaDbgCntMode)
54825 +{
54826 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54827 + enum fman_dma_dbg_cnt_mode fsl_dma_dbg_cnt;
54828 +
54829 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54830 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54831 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54832 +
54833 + FMAN_DMA_DBG_CNT_TRANS(fsl_dma_dbg_cnt, fmDmaDbgCntMode);
54834 + p_Fm->p_FmDriverParam->dma_dbg_cnt_mode = fsl_dma_dbg_cnt;
54835 +
54836 + return E_OK;
54837 +}
54838 +
54839 +t_Error FM_ConfigDmaStopOnBusErr(t_Handle h_Fm, bool stop)
54840 +{
54841 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54842 +
54843 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54844 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54845 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54846 +
54847 + p_Fm->p_FmDriverParam->dma_stop_on_bus_error = stop;
54848 +
54849 + return E_OK;
54850 +}
54851 +
54852 +t_Error FM_ConfigDmaEmergency(t_Handle h_Fm, t_FmDmaEmergency *p_Emergency)
54853 +{
54854 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54855 + enum fman_dma_emergency_level fsl_dma_emer;
54856 +
54857 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54858 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54859 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54860 +
54861 + FMAN_DMA_EMER_TRANS(fsl_dma_emer, p_Emergency->emergencyLevel);
54862 + p_Fm->p_FmDriverParam->dma_en_emergency = TRUE;
54863 + p_Fm->p_FmDriverParam->dma_emergency_bus_select = (uint32_t)p_Emergency->emergencyBusSelect;
54864 + p_Fm->p_FmDriverParam->dma_emergency_level = fsl_dma_emer;
54865 +
54866 + return E_OK;
54867 +}
54868 +
54869 +t_Error FM_ConfigDmaEmergencySmoother(t_Handle h_Fm, uint32_t emergencyCnt)
54870 +{
54871 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54872 +
54873 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54874 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54875 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54876 +
54877 + p_Fm->p_FmDriverParam->dma_en_emergency_smoother = TRUE;
54878 + p_Fm->p_FmDriverParam->dma_emergency_switch_counter = emergencyCnt;
54879 +
54880 + return E_OK;
54881 +}
54882 +
54883 +t_Error FM_ConfigDmaErr(t_Handle h_Fm, e_FmDmaErr dmaErr)
54884 +{
54885 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54886 + enum fman_dma_err fsl_dma_err;
54887 +
54888 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54889 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54890 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54891 +
54892 + FMAN_DMA_ERR_TRANS(fsl_dma_err, dmaErr);
54893 + p_Fm->p_FmDriverParam->dma_err = fsl_dma_err;
54894 +
54895 + return E_OK;
54896 +}
54897 +
54898 +t_Error FM_ConfigCatastrophicErr(t_Handle h_Fm, e_FmCatastrophicErr catastrophicErr)
54899 +{
54900 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54901 + enum fman_catastrophic_err fsl_catastrophic_err;
54902 +
54903 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54904 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54905 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54906 +
54907 + FMAN_CATASTROPHIC_ERR_TRANS(fsl_catastrophic_err, catastrophicErr);
54908 + p_Fm->p_FmDriverParam->catastrophic_err = fsl_catastrophic_err;
54909 +
54910 + return E_OK;
54911 +}
54912 +
54913 +t_Error FM_ConfigEnableMuramTestMode(t_Handle h_Fm)
54914 +{
54915 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54916 +
54917 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54918 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54919 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54920 +
54921 + if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
54922 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Not available for this FM revision!"));
54923 +
54924 + p_Fm->p_FmDriverParam->en_muram_test_mode = TRUE;
54925 +
54926 + return E_OK;
54927 +}
54928 +
54929 +t_Error FM_ConfigEnableIramTestMode(t_Handle h_Fm)
54930 +{
54931 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54932 +
54933 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE );
54934 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54935 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54936 +
54937 + if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
54938 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Not available for this FM revision!"));
54939 +
54940 + p_Fm->p_FmDriverParam->en_iram_test_mode = TRUE;
54941 +
54942 + return E_OK;
54943 +}
54944 +
54945 +t_Error FM_ConfigHaltOnExternalActivation(t_Handle h_Fm, bool enable)
54946 +{
54947 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54948 +
54949 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54950 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54951 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54952 +
54953 + p_Fm->p_FmDriverParam->halt_on_external_activ = enable;
54954 +
54955 + return E_OK;
54956 +}
54957 +
54958 +t_Error FM_ConfigHaltOnUnrecoverableEccError(t_Handle h_Fm, bool enable)
54959 +{
54960 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54961 +
54962 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54963 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54964 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54965 +
54966 + if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
54967 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Not available for this FM revision!"));
54968 +
54969 + p_Fm->p_FmDriverParam->halt_on_unrecov_ecc_err = enable;
54970 +
54971 + return E_OK;
54972 +}
54973 +
54974 +t_Error FM_ConfigException(t_Handle h_Fm, e_FmExceptions exception, bool enable)
54975 +{
54976 + t_Fm *p_Fm = (t_Fm*)h_Fm;
54977 + uint32_t bitMask = 0;
54978 +
54979 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
54980 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
54981 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
54982 +
54983 + GET_EXCEPTION_FLAG(bitMask, exception);
54984 + if (bitMask)
54985 + {
54986 + if (enable)
54987 + p_Fm->userSetExceptions |= bitMask;
54988 + else
54989 + p_Fm->p_FmStateStruct->exceptions &= ~bitMask;
54990 + }
54991 + else
54992 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
54993 +
54994 + return E_OK;
54995 +}
54996 +
54997 +t_Error FM_ConfigExternalEccRamsEnable(t_Handle h_Fm, bool enable)
54998 +{
54999 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55000 +
55001 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55002 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
55003 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55004 +
55005 + p_Fm->p_FmDriverParam->external_ecc_rams_enable = enable;
55006 +
55007 + return E_OK;
55008 +}
55009 +
55010 +t_Error FM_ConfigTnumAgingPeriod(t_Handle h_Fm, uint16_t tnumAgingPeriod)
55011 +{
55012 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55013 +
55014 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55015 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
55016 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55017 +
55018 + p_Fm->p_FmDriverParam->tnum_aging_period = tnumAgingPeriod;
55019 + p_Fm->tnumAgingPeriod = p_Fm->p_FmDriverParam->tnum_aging_period;
55020 +
55021 + return E_OK;
55022 +}
55023 +
55024 +/****************************************************/
55025 +/* Hidden-DEBUG Only API */
55026 +/****************************************************/
55027 +
55028 +t_Error FM_ConfigThresholds(t_Handle h_Fm, t_FmThresholds *p_FmThresholds)
55029 +{
55030 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55031 +
55032 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55033 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
55034 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55035 +
55036 + p_Fm->p_FmDriverParam->disp_limit_tsh = p_FmThresholds->dispLimit;
55037 + p_Fm->p_FmDriverParam->prs_disp_tsh = p_FmThresholds->prsDispTh;
55038 + p_Fm->p_FmDriverParam->plcr_disp_tsh = p_FmThresholds->plcrDispTh;
55039 + p_Fm->p_FmDriverParam->kg_disp_tsh = p_FmThresholds->kgDispTh;
55040 + p_Fm->p_FmDriverParam->bmi_disp_tsh = p_FmThresholds->bmiDispTh;
55041 + p_Fm->p_FmDriverParam->qmi_enq_disp_tsh = p_FmThresholds->qmiEnqDispTh;
55042 + p_Fm->p_FmDriverParam->qmi_deq_disp_tsh = p_FmThresholds->qmiDeqDispTh;
55043 + p_Fm->p_FmDriverParam->fm_ctl1_disp_tsh = p_FmThresholds->fmCtl1DispTh;
55044 + p_Fm->p_FmDriverParam->fm_ctl2_disp_tsh = p_FmThresholds->fmCtl2DispTh;
55045 +
55046 + return E_OK;
55047 +}
55048 +
55049 +t_Error FM_ConfigDmaSosEmergencyThreshold(t_Handle h_Fm, uint32_t dmaSosEmergency)
55050 +{
55051 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55052 +
55053 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55054 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
55055 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55056 +
55057 + p_Fm->p_FmDriverParam->dma_sos_emergency = dmaSosEmergency;
55058 +
55059 + return E_OK;
55060 +}
55061 +
55062 +t_Error FM_ConfigDmaWriteBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds)
55063 +
55064 +{
55065 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55066 +
55067 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55068 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
55069 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55070 +
55071 +#if (DPAA_VERSION >= 11)
55072 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Not available for this FM revision!"));
55073 +#else
55074 + p_Fm->p_FmDriverParam->dma_write_buf_tsh_asrt_emer = p_FmDmaThresholds->assertEmergency;
55075 + p_Fm->p_FmDriverParam->dma_write_buf_tsh_clr_emer = p_FmDmaThresholds->clearEmergency;
55076 +
55077 + return E_OK;
55078 +#endif
55079 +}
55080 +
55081 +t_Error FM_ConfigDmaCommQThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds)
55082 +{
55083 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55084 +
55085 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55086 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
55087 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55088 +
55089 + p_Fm->p_FmDriverParam->dma_comm_qtsh_asrt_emer = p_FmDmaThresholds->assertEmergency;
55090 + p_Fm->p_FmDriverParam->dma_comm_qtsh_clr_emer = p_FmDmaThresholds->clearEmergency;
55091 +
55092 + return E_OK;
55093 +}
55094 +
55095 +t_Error FM_ConfigDmaReadBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds)
55096 +{
55097 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55098 +
55099 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55100 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
55101 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55102 +
55103 +#if (DPAA_VERSION >= 11)
55104 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Not available for this FM revision!"));
55105 +#else
55106 + p_Fm->p_FmDriverParam->dma_read_buf_tsh_clr_emer = p_FmDmaThresholds->clearEmergency;
55107 + p_Fm->p_FmDriverParam->dma_read_buf_tsh_asrt_emer = p_FmDmaThresholds->assertEmergency;
55108 +
55109 + return E_OK;
55110 +#endif
55111 +}
55112 +
55113 +t_Error FM_ConfigDmaWatchdog(t_Handle h_Fm, uint32_t watchdogValue)
55114 +{
55115 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55116 +
55117 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55118 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
55119 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55120 +
55121 + p_Fm->p_FmDriverParam->dma_watchdog = watchdogValue;
55122 +
55123 + return E_OK;
55124 +}
55125 +
55126 +t_Error FM_ConfigEnableCounters(t_Handle h_Fm)
55127 +{
55128 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55129 +
55130 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55131 + SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
55132 +UNUSED(p_Fm);
55133 +
55134 + return E_OK;
55135 +}
55136 +
55137 +t_Error FmGetSetParams(t_Handle h_Fm, t_FmGetSetParams *p_Params)
55138 +{
55139 + t_Fm* p_Fm = (t_Fm*)h_Fm;
55140 + if (p_Params->setParams.type & UPDATE_FM_CLD)
55141 + {
55142 + WRITE_UINT32(p_Fm->p_FmFpmRegs->fm_cld, GET_UINT32(
55143 + p_Fm->p_FmFpmRegs->fm_cld) | 0x00000800);
55144 + }
55145 + if (p_Params->setParams.type & CLEAR_IRAM_READY)
55146 + {
55147 + t_FMIramRegs *p_Iram = (t_FMIramRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_IMEM);
55148 + WRITE_UINT32(p_Iram->iready,GET_UINT32(p_Iram->iready) & ~IRAM_READY);
55149 + }
55150 + if (p_Params->setParams.type & UPDATE_FPM_EXTC)
55151 + WRITE_UINT32(p_Fm->p_FmFpmRegs->fmfp_extc,0x80000000);
55152 + if (p_Params->setParams.type & UPDATE_FPM_EXTC_CLEAR)
55153 + WRITE_UINT32(p_Fm->p_FmFpmRegs->fmfp_extc,0x00800000);
55154 + if (p_Params->setParams.type & UPDATE_FPM_BRKC_SLP)
55155 + {
55156 + if (p_Params->setParams.sleep)
55157 + WRITE_UINT32(p_Fm->p_FmFpmRegs->fmfp_brkc, GET_UINT32(
55158 + p_Fm->p_FmFpmRegs->fmfp_brkc) | FPM_BRKC_SLP);
55159 + else
55160 + WRITE_UINT32(p_Fm->p_FmFpmRegs->fmfp_brkc, GET_UINT32(
55161 + p_Fm->p_FmFpmRegs->fmfp_brkc) & ~FPM_BRKC_SLP);
55162 + }
55163 + if (p_Params->getParams.type & GET_FM_CLD)
55164 + p_Params->getParams.fm_cld = GET_UINT32(p_Fm->p_FmFpmRegs->fm_cld);
55165 + if (p_Params->getParams.type & GET_FMQM_GS)
55166 + p_Params->getParams.fmqm_gs = GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_gs);
55167 + if (p_Params->getParams.type & GET_FM_NPI)
55168 + p_Params->getParams.fm_npi = GET_UINT32(p_Fm->p_FmFpmRegs->fm_npi);
55169 + if (p_Params->getParams.type & GET_FMFP_EXTC)
55170 + p_Params->getParams.fmfp_extc = GET_UINT32(p_Fm->p_FmFpmRegs->fmfp_extc);
55171 + return E_OK;
55172 +}
55173 +
55174 +
55175 +/****************************************************/
55176 +/* API Run-time Control uint functions */
55177 +/****************************************************/
55178 +void FM_EventIsr(t_Handle h_Fm)
55179 +{
55180 +#define FM_M_CALL_1G_MAC_ISR(_id) \
55181 + { \
55182 + if (p_Fm->guestId != p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0+_id)].guestId) \
55183 + SendIpcIsr(p_Fm, (e_FmInterModuleEvent)(e_FM_EV_1G_MAC0+_id), pending); \
55184 + else \
55185 + p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0+_id)].h_SrcHandle);\
55186 + }
55187 +#define FM_M_CALL_10G_MAC_ISR(_id) \
55188 + { \
55189 + if (p_Fm->guestId != p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_10G_MAC0+_id)].guestId) \
55190 + SendIpcIsr(p_Fm, (e_FmInterModuleEvent)(e_FM_EV_10G_MAC0+_id), pending); \
55191 + else \
55192 + p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_10G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_10G_MAC0+_id)].h_SrcHandle);\
55193 + }
55194 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55195 + uint32_t pending, event;
55196 + struct fman_fpm_regs *fpm_rg;
55197 +
55198 + SANITY_CHECK_RETURN(p_Fm, E_INVALID_HANDLE);
55199 + SANITY_CHECK_RETURN(!p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
55200 + SANITY_CHECK_RETURN((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55201 +
55202 + fpm_rg = p_Fm->p_FmFpmRegs;
55203 +
55204 + /* normal interrupts */
55205 + pending = fman_get_normal_pending(fpm_rg);
55206 + if (!pending)
55207 + return;
55208 + if (pending & INTR_EN_WAKEUP) // this is a wake up from sleep interrupt
55209 + {
55210 + t_FmGetSetParams fmGetSetParams;
55211 + memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
55212 + fmGetSetParams.setParams.type = UPDATE_FPM_BRKC_SLP;
55213 + fmGetSetParams.setParams.sleep = 0;
55214 + FmGetSetParams(h_Fm, &fmGetSetParams);
55215 + }
55216 + if (pending & INTR_EN_QMI)
55217 + QmiEvent(p_Fm);
55218 + if (pending & INTR_EN_PRS)
55219 + p_Fm->intrMng[e_FM_EV_PRS].f_Isr(p_Fm->intrMng[e_FM_EV_PRS].h_SrcHandle);
55220 + if (pending & INTR_EN_PLCR)
55221 + p_Fm->intrMng[e_FM_EV_PLCR].f_Isr(p_Fm->intrMng[e_FM_EV_PLCR].h_SrcHandle);
55222 + if (pending & INTR_EN_TMR)
55223 + p_Fm->intrMng[e_FM_EV_TMR].f_Isr(p_Fm->intrMng[e_FM_EV_TMR].h_SrcHandle);
55224 +
55225 + /* MAC events may belong to different partitions */
55226 + if (pending & INTR_EN_1G_MAC0)
55227 + FM_M_CALL_1G_MAC_ISR(0);
55228 + if (pending & INTR_EN_1G_MAC1)
55229 + FM_M_CALL_1G_MAC_ISR(1);
55230 + if (pending & INTR_EN_1G_MAC2)
55231 + FM_M_CALL_1G_MAC_ISR(2);
55232 + if (pending & INTR_EN_1G_MAC3)
55233 + FM_M_CALL_1G_MAC_ISR(3);
55234 + if (pending & INTR_EN_1G_MAC4)
55235 + FM_M_CALL_1G_MAC_ISR(4);
55236 + if (pending & INTR_EN_1G_MAC5)
55237 + FM_M_CALL_1G_MAC_ISR(5);
55238 + if (pending & INTR_EN_1G_MAC6)
55239 + FM_M_CALL_1G_MAC_ISR(6);
55240 + if (pending & INTR_EN_1G_MAC7)
55241 + FM_M_CALL_1G_MAC_ISR(7);
55242 + if (pending & INTR_EN_10G_MAC0)
55243 + FM_M_CALL_10G_MAC_ISR(0);
55244 + if (pending & INTR_EN_10G_MAC1)
55245 + FM_M_CALL_10G_MAC_ISR(1);
55246 +
55247 + /* IM port events may belong to different partitions */
55248 + if (pending & INTR_EN_REV0)
55249 + {
55250 + event = fman_get_controller_event(fpm_rg, 0);
55251 + if (p_Fm->guestId != p_Fm->intrMng[e_FM_EV_FMAN_CTRL_0].guestId)
55252 + /*TODO IPC ISR For Fman Ctrl */
55253 + ASSERT_COND(0);
55254 + /* SendIpcIsr(p_Fm, e_FM_EV_FMAN_CTRL_0, pending); */
55255 + else
55256 + p_Fm->fmanCtrlIntr[0].f_Isr(p_Fm->fmanCtrlIntr[0].h_SrcHandle, event);
55257 +
55258 + }
55259 + if (pending & INTR_EN_REV1)
55260 + {
55261 + event = fman_get_controller_event(fpm_rg, 1);
55262 + if (p_Fm->guestId != p_Fm->intrMng[e_FM_EV_FMAN_CTRL_1].guestId)
55263 + /*TODO IPC ISR For Fman Ctrl */
55264 + ASSERT_COND(0);
55265 + /* SendIpcIsr(p_Fm, e_FM_EV_FMAN_CTRL_1, pending); */
55266 + else
55267 + p_Fm->fmanCtrlIntr[1].f_Isr(p_Fm->fmanCtrlIntr[1].h_SrcHandle, event);
55268 + }
55269 + if (pending & INTR_EN_REV2)
55270 + {
55271 + event = fman_get_controller_event(fpm_rg, 2);
55272 + if (p_Fm->guestId != p_Fm->intrMng[e_FM_EV_FMAN_CTRL_2].guestId)
55273 + /*TODO IPC ISR For Fman Ctrl */
55274 + ASSERT_COND(0);
55275 + /* SendIpcIsr(p_Fm, e_FM_EV_FMAN_CTRL_2, pending); */
55276 + else
55277 + p_Fm->fmanCtrlIntr[2].f_Isr(p_Fm->fmanCtrlIntr[2].h_SrcHandle, event);
55278 + }
55279 + if (pending & INTR_EN_REV3)
55280 + {
55281 + event = fman_get_controller_event(fpm_rg, 3);
55282 + if (p_Fm->guestId != p_Fm->intrMng[e_FM_EV_FMAN_CTRL_3].guestId)
55283 + /*TODO IPC ISR For Fman Ctrl */
55284 + ASSERT_COND(0);
55285 + /* SendIpcIsr(p_Fm, e_FM_EV_FMAN_CTRL_2, pendin3); */
55286 + else
55287 + p_Fm->fmanCtrlIntr[3].f_Isr(p_Fm->fmanCtrlIntr[3].h_SrcHandle, event);
55288 + }
55289 +#ifdef FM_MACSEC_SUPPORT
55290 + if (pending & INTR_EN_MACSEC_MAC0)
55291 + {
55292 + if (p_Fm->guestId != p_Fm->intrMng[e_FM_EV_MACSEC_MAC0].guestId)
55293 + SendIpcIsr(p_Fm, e_FM_EV_MACSEC_MAC0, pending);
55294 + else
55295 + p_Fm->intrMng[e_FM_EV_MACSEC_MAC0].f_Isr(p_Fm->intrMng[e_FM_EV_MACSEC_MAC0].h_SrcHandle);
55296 + }
55297 +#endif /* FM_MACSEC_SUPPORT */
55298 +}
55299 +
55300 +t_Error FM_ErrorIsr(t_Handle h_Fm)
55301 +{
55302 +#define FM_M_CALL_1G_MAC_ERR_ISR(_id) \
55303 + { \
55304 + if (p_Fm->guestId != p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id)].guestId) \
55305 + SendIpcIsr(p_Fm, (e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id), pending); \
55306 + else \
55307 + p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id)].h_SrcHandle);\
55308 + }
55309 +#define FM_M_CALL_10G_MAC_ERR_ISR(_id) \
55310 + { \
55311 + if (p_Fm->guestId != p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_10G_MAC0+_id)].guestId) \
55312 + SendIpcIsr(p_Fm, (e_FmInterModuleEvent)(e_FM_EV_ERR_10G_MAC0+_id), pending); \
55313 + else \
55314 + p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_10G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_10G_MAC0+_id)].h_SrcHandle);\
55315 + }
55316 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55317 + uint32_t pending;
55318 + struct fman_fpm_regs *fpm_rg;
55319 +
55320 + SANITY_CHECK_RETURN_ERROR(h_Fm, E_INVALID_HANDLE);
55321 + SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
55322 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55323 +
55324 + fpm_rg = p_Fm->p_FmFpmRegs;
55325 +
55326 + /* error interrupts */
55327 + pending = fman_get_fpm_error_interrupts(fpm_rg);
55328 + if (!pending)
55329 + return ERROR_CODE(E_EMPTY);
55330 +
55331 + if (pending & ERR_INTR_EN_BMI)
55332 + BmiErrEvent(p_Fm);
55333 + if (pending & ERR_INTR_EN_QMI)
55334 + QmiErrEvent(p_Fm);
55335 + if (pending & ERR_INTR_EN_FPM)
55336 + FpmErrEvent(p_Fm);
55337 + if (pending & ERR_INTR_EN_DMA)
55338 + DmaErrEvent(p_Fm);
55339 + if (pending & ERR_INTR_EN_IRAM)
55340 + IramErrIntr(p_Fm);
55341 + if (pending & ERR_INTR_EN_MURAM)
55342 + MuramErrIntr(p_Fm);
55343 + if (pending & ERR_INTR_EN_PRS)
55344 + p_Fm->intrMng[e_FM_EV_ERR_PRS].f_Isr(p_Fm->intrMng[e_FM_EV_ERR_PRS].h_SrcHandle);
55345 + if (pending & ERR_INTR_EN_PLCR)
55346 + p_Fm->intrMng[e_FM_EV_ERR_PLCR].f_Isr(p_Fm->intrMng[e_FM_EV_ERR_PLCR].h_SrcHandle);
55347 + if (pending & ERR_INTR_EN_KG)
55348 + p_Fm->intrMng[e_FM_EV_ERR_KG].f_Isr(p_Fm->intrMng[e_FM_EV_ERR_KG].h_SrcHandle);
55349 +
55350 + /* MAC events may belong to different partitions */
55351 + if (pending & ERR_INTR_EN_1G_MAC0)
55352 + FM_M_CALL_1G_MAC_ERR_ISR(0);
55353 + if (pending & ERR_INTR_EN_1G_MAC1)
55354 + FM_M_CALL_1G_MAC_ERR_ISR(1);
55355 + if (pending & ERR_INTR_EN_1G_MAC2)
55356 + FM_M_CALL_1G_MAC_ERR_ISR(2);
55357 + if (pending & ERR_INTR_EN_1G_MAC3)
55358 + FM_M_CALL_1G_MAC_ERR_ISR(3);
55359 + if (pending & ERR_INTR_EN_1G_MAC4)
55360 + FM_M_CALL_1G_MAC_ERR_ISR(4);
55361 + if (pending & ERR_INTR_EN_1G_MAC5)
55362 + FM_M_CALL_1G_MAC_ERR_ISR(5);
55363 + if (pending & ERR_INTR_EN_1G_MAC6)
55364 + FM_M_CALL_1G_MAC_ERR_ISR(6);
55365 + if (pending & ERR_INTR_EN_1G_MAC7)
55366 + FM_M_CALL_1G_MAC_ERR_ISR(7);
55367 + if (pending & ERR_INTR_EN_10G_MAC0)
55368 + FM_M_CALL_10G_MAC_ERR_ISR(0);
55369 + if (pending & ERR_INTR_EN_10G_MAC1)
55370 + FM_M_CALL_10G_MAC_ERR_ISR(1);
55371 +
55372 +#ifdef FM_MACSEC_SUPPORT
55373 + if (pending & ERR_INTR_EN_MACSEC_MAC0)
55374 + {
55375 + if (p_Fm->guestId != p_Fm->intrMng[e_FM_EV_ERR_MACSEC_MAC0].guestId)
55376 + SendIpcIsr(p_Fm, e_FM_EV_ERR_MACSEC_MAC0, pending);
55377 + else
55378 + p_Fm->intrMng[e_FM_EV_ERR_MACSEC_MAC0].f_Isr(p_Fm->intrMng[e_FM_EV_ERR_MACSEC_MAC0].h_SrcHandle);
55379 + }
55380 +#endif /* FM_MACSEC_SUPPORT */
55381 +
55382 + return E_OK;
55383 +}
55384 +
55385 +t_Error FM_SetPortsBandwidth(t_Handle h_Fm, t_FmPortsBandwidthParams *p_PortsBandwidth)
55386 +{
55387 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55388 + int i;
55389 + uint8_t sum;
55390 + uint8_t hardwarePortId;
55391 + uint8_t weights[64];
55392 + uint8_t weight, maxPercent = 0;
55393 + struct fman_bmi_regs *bmi_rg;
55394 +
55395 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55396 + SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
55397 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55398 +
55399 + bmi_rg = p_Fm->p_FmBmiRegs;
55400 +
55401 + memset(weights, 0, (sizeof(uint8_t) * 64));
55402 +
55403 + /* check that all ports add up to 100% */
55404 + sum = 0;
55405 + for (i=0; i < p_PortsBandwidth->numOfPorts; i++)
55406 + sum +=p_PortsBandwidth->portsBandwidths[i].bandwidth;
55407 + if (sum != 100)
55408 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Sum of ports bandwidth differ from 100%"));
55409 +
55410 + /* find highest percent */
55411 + for (i=0; i < p_PortsBandwidth->numOfPorts; i++)
55412 + {
55413 + if (p_PortsBandwidth->portsBandwidths[i].bandwidth > maxPercent)
55414 + maxPercent = p_PortsBandwidth->portsBandwidths[i].bandwidth;
55415 + }
55416 +
55417 + ASSERT_COND(maxPercent > 0); /* guaranteed by sum = 100 */
55418 +
55419 + /* calculate weight for each port */
55420 + for (i=0; i < p_PortsBandwidth->numOfPorts; i++)
55421 + {
55422 + weight = (uint8_t)((p_PortsBandwidth->portsBandwidths[i].bandwidth * PORT_MAX_WEIGHT ) / maxPercent);
55423 + /* we want even division between 1-to-PORT_MAX_WEIGHT. so if exact division
55424 + is not reached, we round up so that:
55425 + 0 until maxPercent/PORT_MAX_WEIGHT get "1"
55426 + maxPercent/PORT_MAX_WEIGHT+1 until (maxPercent/PORT_MAX_WEIGHT)*2 get "2"
55427 + ...
55428 + maxPercent - maxPercent/PORT_MAX_WEIGHT until maxPercent get "PORT_MAX_WEIGHT: */
55429 + if ((uint8_t)((p_PortsBandwidth->portsBandwidths[i].bandwidth * PORT_MAX_WEIGHT ) % maxPercent))
55430 + weight++;
55431 +
55432 + /* find the location of this port within the register */
55433 + hardwarePortId =
55434 + SwPortIdToHwPortId(p_PortsBandwidth->portsBandwidths[i].type,
55435 + p_PortsBandwidth->portsBandwidths[i].relativePortId,
55436 + p_Fm->p_FmStateStruct->revInfo.majorRev,
55437 + p_Fm->p_FmStateStruct->revInfo.minorRev);
55438 +
55439 + ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
55440 + weights[hardwarePortId] = weight;
55441 + }
55442 +
55443 + fman_set_ports_bandwidth(bmi_rg, weights);
55444 +
55445 + return E_OK;
55446 +}
55447 +
55448 +t_Error FM_EnableRamsEcc(t_Handle h_Fm)
55449 +{
55450 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55451 + struct fman_fpm_regs *fpm_rg;
55452 +
55453 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55454 +
55455 + fpm_rg = p_Fm->p_FmFpmRegs;
55456 +
55457 + if (p_Fm->guestId != NCSW_MASTER_ID)
55458 + {
55459 + t_FmIpcMsg msg;
55460 + t_Error err;
55461 +
55462 + memset(&msg, 0, sizeof(msg));
55463 + msg.msgId = FM_ENABLE_RAM_ECC;
55464 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
55465 + (uint8_t*)&msg,
55466 + sizeof(msg.msgId),
55467 + NULL,
55468 + NULL,
55469 + NULL,
55470 + NULL);
55471 + if (err != E_OK)
55472 + RETURN_ERROR(MINOR, err, NO_MSG);
55473 + return E_OK;
55474 + }
55475 +
55476 + if (!p_Fm->p_FmStateStruct->internalCall)
55477 + p_Fm->p_FmStateStruct->explicitEnable = TRUE;
55478 + p_Fm->p_FmStateStruct->internalCall = FALSE;
55479 +
55480 + if (p_Fm->p_FmStateStruct->ramsEccEnable)
55481 + return E_OK;
55482 + else
55483 + {
55484 + fman_enable_rams_ecc(fpm_rg);
55485 + p_Fm->p_FmStateStruct->ramsEccEnable = TRUE;
55486 + }
55487 +
55488 + return E_OK;
55489 +}
55490 +
55491 +t_Error FM_DisableRamsEcc(t_Handle h_Fm)
55492 +{
55493 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55494 + bool explicitDisable = FALSE;
55495 + struct fman_fpm_regs *fpm_rg;
55496 +
55497 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55498 + SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
55499 +
55500 + fpm_rg = p_Fm->p_FmFpmRegs;
55501 +
55502 + if (p_Fm->guestId != NCSW_MASTER_ID)
55503 + {
55504 + t_Error err;
55505 + t_FmIpcMsg msg;
55506 +
55507 + memset(&msg, 0, sizeof(msg));
55508 + msg.msgId = FM_DISABLE_RAM_ECC;
55509 + if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
55510 + (uint8_t*)&msg,
55511 + sizeof(msg.msgId),
55512 + NULL,
55513 + NULL,
55514 + NULL,
55515 + NULL)) != E_OK)
55516 + RETURN_ERROR(MINOR, err, NO_MSG);
55517 + return E_OK;
55518 + }
55519 +
55520 + if (!p_Fm->p_FmStateStruct->internalCall)
55521 + explicitDisable = TRUE;
55522 + p_Fm->p_FmStateStruct->internalCall = FALSE;
55523 +
55524 + /* if rams are already disabled, or if rams were explicitly enabled and are
55525 + currently called indirectly (not explicitly), ignore this call. */
55526 + if (!p_Fm->p_FmStateStruct->ramsEccEnable ||
55527 + (p_Fm->p_FmStateStruct->explicitEnable && !explicitDisable))
55528 + return E_OK;
55529 + else
55530 + {
55531 + if (p_Fm->p_FmStateStruct->explicitEnable)
55532 + /* This is the case were both explicit are TRUE.
55533 + Turn off this flag for cases were following ramsEnable
55534 + routines are called */
55535 + p_Fm->p_FmStateStruct->explicitEnable = FALSE;
55536 +
55537 + fman_enable_rams_ecc(fpm_rg);
55538 + p_Fm->p_FmStateStruct->ramsEccEnable = FALSE;
55539 + }
55540 +
55541 + return E_OK;
55542 +}
55543 +
55544 +t_Error FM_SetException(t_Handle h_Fm, e_FmExceptions exception, bool enable)
55545 +{
55546 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55547 + uint32_t bitMask = 0;
55548 + enum fman_exceptions fslException;
55549 + struct fman_rg fman_rg;
55550 +
55551 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55552 + SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
55553 +
55554 + fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
55555 + fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
55556 + fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
55557 + fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
55558 +
55559 + GET_EXCEPTION_FLAG(bitMask, exception);
55560 + if (bitMask)
55561 + {
55562 + if (enable)
55563 + p_Fm->p_FmStateStruct->exceptions |= bitMask;
55564 + else
55565 + p_Fm->p_FmStateStruct->exceptions &= ~bitMask;
55566 +
55567 + fslException = FmanExceptionTrans(exception);
55568 +
55569 + return (t_Error)fman_set_exception(&fman_rg,
55570 + fslException,
55571 + enable);
55572 + }
55573 + else
55574 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
55575 +
55576 + return E_OK;
55577 +}
55578 +
55579 +t_Error FM_GetRevision(t_Handle h_Fm, t_FmRevisionInfo *p_FmRevisionInfo)
55580 +{
55581 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55582 +
55583 + p_FmRevisionInfo->majorRev = p_Fm->p_FmStateStruct->revInfo.majorRev;
55584 + p_FmRevisionInfo->minorRev = p_Fm->p_FmStateStruct->revInfo.minorRev;
55585 +
55586 + return E_OK;
55587 +}
55588 +
55589 +t_Error FM_GetFmanCtrlCodeRevision(t_Handle h_Fm, t_FmCtrlCodeRevisionInfo *p_RevisionInfo)
55590 +{
55591 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55592 + t_FMIramRegs *p_Iram;
55593 + uint32_t revInfo;
55594 +
55595 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55596 + SANITY_CHECK_RETURN_ERROR(p_RevisionInfo, E_NULL_POINTER);
55597 +
55598 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
55599 + p_Fm->h_IpcSessions[0])
55600 + {
55601 + t_Error err;
55602 + t_FmIpcMsg msg;
55603 + t_FmIpcReply reply;
55604 + uint32_t replyLength;
55605 + t_FmIpcFmanCtrlCodeRevisionInfo ipcRevInfo;
55606 +
55607 + memset(&msg, 0, sizeof(msg));
55608 + memset(&reply, 0, sizeof(reply));
55609 + msg.msgId = FM_GET_FMAN_CTRL_CODE_REV;
55610 + replyLength = sizeof(uint32_t) + sizeof(t_FmCtrlCodeRevisionInfo);
55611 + if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
55612 + (uint8_t*)&msg,
55613 + sizeof(msg.msgId),
55614 + (uint8_t*)&reply,
55615 + &replyLength,
55616 + NULL,
55617 + NULL)) != E_OK)
55618 + RETURN_ERROR(MINOR, err, NO_MSG);
55619 + if (replyLength != (sizeof(uint32_t) + sizeof(t_FmCtrlCodeRevisionInfo)))
55620 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
55621 + memcpy((uint8_t*)&ipcRevInfo, reply.replyBody, sizeof(t_FmCtrlCodeRevisionInfo));
55622 + p_RevisionInfo->packageRev = ipcRevInfo.packageRev;
55623 + p_RevisionInfo->majorRev = ipcRevInfo.majorRev;
55624 + p_RevisionInfo->minorRev = ipcRevInfo.minorRev;
55625 + return (t_Error)(reply.error);
55626 + }
55627 + else if (p_Fm->guestId != NCSW_MASTER_ID)
55628 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
55629 + ("running in guest-mode without IPC!"));
55630 +
55631 + p_Iram = (t_FMIramRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_IMEM);
55632 + WRITE_UINT32(p_Iram->iadd, 0x4);
55633 + while (GET_UINT32(p_Iram->iadd) != 0x4) ;
55634 + revInfo = GET_UINT32(p_Iram->idata);
55635 + p_RevisionInfo->packageRev = (uint16_t)((revInfo & 0xFFFF0000) >> 16);
55636 + p_RevisionInfo->majorRev = (uint8_t)((revInfo & 0x0000FF00) >> 8);
55637 + p_RevisionInfo->minorRev = (uint8_t)(revInfo & 0x000000FF);
55638 +
55639 + return E_OK;
55640 +}
55641 +
55642 +uint32_t FM_GetCounter(t_Handle h_Fm, e_FmCounters counter)
55643 +{
55644 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55645 + t_Error err;
55646 + uint32_t counterValue;
55647 + struct fman_rg fman_rg;
55648 + enum fman_counters fsl_counter;
55649 +
55650 + SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, 0);
55651 + SANITY_CHECK_RETURN_VALUE(!p_Fm->p_FmDriverParam, E_INVALID_STATE, 0);
55652 +
55653 + fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
55654 + fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
55655 + fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
55656 + fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
55657 +
55658 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
55659 + !p_Fm->baseAddr &&
55660 + p_Fm->h_IpcSessions[0])
55661 + {
55662 + t_FmIpcMsg msg;
55663 + t_FmIpcReply reply;
55664 + uint32_t replyLength, outCounter;
55665 +
55666 + memset(&msg, 0, sizeof(msg));
55667 + memset(&reply, 0, sizeof(reply));
55668 + msg.msgId = FM_GET_COUNTER;
55669 + memcpy(msg.msgBody, (uint8_t *)&counter, sizeof(uint32_t));
55670 + replyLength = sizeof(uint32_t) + sizeof(uint32_t);
55671 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
55672 + (uint8_t*)&msg,
55673 + sizeof(msg.msgId) +sizeof(counterValue),
55674 + (uint8_t*)&reply,
55675 + &replyLength,
55676 + NULL,
55677 + NULL);
55678 + if (err != E_OK)
55679 + {
55680 + REPORT_ERROR(MAJOR, err, NO_MSG);
55681 + return 0;
55682 + }
55683 + if (replyLength != (sizeof(uint32_t) + sizeof(uint32_t)))
55684 + {
55685 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
55686 + return 0;
55687 + }
55688 +
55689 + memcpy((uint8_t*)&outCounter, reply.replyBody, sizeof(uint32_t));
55690 + return outCounter;
55691 + }
55692 + else if (!p_Fm->baseAddr)
55693 + {
55694 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Either IPC or 'baseAddress' is required!"));
55695 + return 0;
55696 + }
55697 +
55698 + /* When applicable (when there is an 'enable counters' bit,
55699 + check that counters are enabled */
55700 + switch (counter)
55701 + {
55702 + case (e_FM_COUNTERS_DEQ_1):
55703 + case (e_FM_COUNTERS_DEQ_2):
55704 + case (e_FM_COUNTERS_DEQ_3):
55705 + if ((p_Fm->p_FmStateStruct->revInfo.majorRev == 4) ||
55706 + (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6))
55707 + {
55708 + REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Requested counter not supported"));
55709 + return 0;
55710 + }
55711 + case (e_FM_COUNTERS_ENQ_TOTAL_FRAME):
55712 + case (e_FM_COUNTERS_DEQ_TOTAL_FRAME):
55713 + case (e_FM_COUNTERS_DEQ_0):
55714 + case (e_FM_COUNTERS_DEQ_FROM_DEFAULT):
55715 + case (e_FM_COUNTERS_DEQ_FROM_CONTEXT):
55716 + case (e_FM_COUNTERS_DEQ_FROM_FD):
55717 + case (e_FM_COUNTERS_DEQ_CONFIRM):
55718 + if (!(GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_gc) & QMI_CFG_EN_COUNTERS))
55719 + {
55720 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Requested counter was not enabled"));
55721 + return 0;
55722 + }
55723 + break;
55724 + default:
55725 + break;
55726 + }
55727 +
55728 + FMAN_COUNTERS_TRANS(fsl_counter, counter);
55729 + return fman_get_counter(&fman_rg, fsl_counter);
55730 +}
55731 +
55732 +t_Error FM_ModifyCounter(t_Handle h_Fm, e_FmCounters counter, uint32_t val)
55733 +{
55734 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55735 + struct fman_rg fman_rg;
55736 + enum fman_counters fsl_counter;
55737 +
55738 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55739 + SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
55740 +
55741 + fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
55742 + fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
55743 + fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
55744 + fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
55745 +
55746 + FMAN_COUNTERS_TRANS(fsl_counter, counter);
55747 + return (t_Error)fman_modify_counter(&fman_rg, fsl_counter, val);
55748 +}
55749 +
55750 +void FM_SetDmaEmergency(t_Handle h_Fm, e_FmDmaMuramPort muramPort, bool enable)
55751 +{
55752 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55753 + struct fman_dma_regs *dma_rg;
55754 +
55755 + SANITY_CHECK_RETURN(p_Fm, E_INVALID_HANDLE);
55756 + SANITY_CHECK_RETURN(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
55757 +
55758 + dma_rg = p_Fm->p_FmDmaRegs;
55759 +
55760 + fman_set_dma_emergency(dma_rg, !!(muramPort==e_FM_DMA_MURAM_PORT_WRITE), enable);
55761 +}
55762 +
55763 +void FM_SetDmaExtBusPri(t_Handle h_Fm, e_FmDmaExtBusPri pri)
55764 +{
55765 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55766 + struct fman_dma_regs *dma_rg;
55767 +
55768 + SANITY_CHECK_RETURN(p_Fm, E_INVALID_HANDLE);
55769 + SANITY_CHECK_RETURN(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
55770 +
55771 + dma_rg = p_Fm->p_FmDmaRegs;
55772 +
55773 + fman_set_dma_ext_bus_pri(dma_rg, pri);
55774 +}
55775 +
55776 +void FM_GetDmaStatus(t_Handle h_Fm, t_FmDmaStatus *p_FmDmaStatus)
55777 +{
55778 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55779 + uint32_t dmaStatus;
55780 + struct fman_dma_regs *dma_rg;
55781 +
55782 + SANITY_CHECK_RETURN(p_Fm, E_INVALID_HANDLE);
55783 + SANITY_CHECK_RETURN(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
55784 +
55785 + dma_rg = p_Fm->p_FmDmaRegs;
55786 +
55787 + if ((p_Fm->guestId != NCSW_MASTER_ID) &&
55788 + !p_Fm->baseAddr &&
55789 + p_Fm->h_IpcSessions[0])
55790 + {
55791 + t_FmIpcDmaStatus ipcDmaStatus;
55792 + t_FmIpcMsg msg;
55793 + t_FmIpcReply reply;
55794 + t_Error err;
55795 + uint32_t replyLength;
55796 +
55797 + memset(&msg, 0, sizeof(msg));
55798 + memset(&reply, 0, sizeof(reply));
55799 + msg.msgId = FM_DMA_STAT;
55800 + replyLength = sizeof(uint32_t) + sizeof(t_FmIpcDmaStatus);
55801 + err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
55802 + (uint8_t*)&msg,
55803 + sizeof(msg.msgId),
55804 + (uint8_t*)&reply,
55805 + &replyLength,
55806 + NULL,
55807 + NULL);
55808 + if (err != E_OK)
55809 + {
55810 + REPORT_ERROR(MINOR, err, NO_MSG);
55811 + return;
55812 + }
55813 + if (replyLength != (sizeof(uint32_t) + sizeof(t_FmIpcDmaStatus)))
55814 + {
55815 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
55816 + return;
55817 + }
55818 + memcpy((uint8_t*)&ipcDmaStatus, reply.replyBody, sizeof(t_FmIpcDmaStatus));
55819 +
55820 + p_FmDmaStatus->cmqNotEmpty = (bool)ipcDmaStatus.boolCmqNotEmpty; /**< Command queue is not empty */
55821 + p_FmDmaStatus->busError = (bool)ipcDmaStatus.boolBusError; /**< Bus error occurred */
55822 + p_FmDmaStatus->readBufEccError = (bool)ipcDmaStatus.boolReadBufEccError; /**< Double ECC error on buffer Read */
55823 + p_FmDmaStatus->writeBufEccSysError =(bool)ipcDmaStatus.boolWriteBufEccSysError; /**< Double ECC error on buffer write from system side */
55824 + p_FmDmaStatus->writeBufEccFmError = (bool)ipcDmaStatus.boolWriteBufEccFmError; /**< Double ECC error on buffer write from FM side */
55825 + p_FmDmaStatus->singlePortEccError = (bool)ipcDmaStatus.boolSinglePortEccError; /**< Double ECC error on buffer write from FM side */
55826 + return;
55827 + }
55828 + else if (!p_Fm->baseAddr)
55829 + {
55830 + REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
55831 + ("Either IPC or 'baseAddress' is required!"));
55832 + return;
55833 + }
55834 +
55835 + dmaStatus = fman_get_dma_status(dma_rg);
55836 +
55837 + p_FmDmaStatus->cmqNotEmpty = (bool)(dmaStatus & DMA_STATUS_CMD_QUEUE_NOT_EMPTY);
55838 + p_FmDmaStatus->busError = (bool)(dmaStatus & DMA_STATUS_BUS_ERR);
55839 + if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
55840 + p_FmDmaStatus->singlePortEccError = (bool)(dmaStatus & DMA_STATUS_FM_SPDAT_ECC);
55841 + else
55842 + {
55843 + p_FmDmaStatus->readBufEccError = (bool)(dmaStatus & DMA_STATUS_READ_ECC);
55844 + p_FmDmaStatus->writeBufEccSysError = (bool)(dmaStatus & DMA_STATUS_SYSTEM_WRITE_ECC);
55845 + p_FmDmaStatus->writeBufEccFmError = (bool)(dmaStatus & DMA_STATUS_FM_WRITE_ECC);
55846 + }
55847 +}
55848 +
55849 +void FM_Resume(t_Handle h_Fm)
55850 +{
55851 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55852 + struct fman_fpm_regs *fpm_rg;
55853 +
55854 + SANITY_CHECK_RETURN(p_Fm, E_INVALID_HANDLE);
55855 + SANITY_CHECK_RETURN(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
55856 + SANITY_CHECK_RETURN((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55857 +
55858 + fpm_rg = p_Fm->p_FmFpmRegs;
55859 +
55860 + fman_resume(fpm_rg);
55861 +}
55862 +
55863 +t_Error FM_GetSpecialOperationCoding(t_Handle h_Fm,
55864 + fmSpecialOperations_t spOper,
55865 + uint8_t *p_SpOperCoding)
55866 +{
55867 + t_Fm *p_Fm = (t_Fm*)h_Fm;
55868 + t_FmCtrlCodeRevisionInfo revInfo;
55869 + t_Error err;
55870 +
55871 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55872 + SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
55873 + SANITY_CHECK_RETURN_ERROR(p_SpOperCoding, E_NULL_POINTER);
55874 +
55875 + if (!spOper)
55876 + {
55877 + *p_SpOperCoding = 0;
55878 + return E_OK;
55879 + }
55880 +
55881 + if ((err = FM_GetFmanCtrlCodeRevision(p_Fm, &revInfo)) != E_OK)
55882 + {
55883 + DBG(WARNING, ("FM in guest-mode without IPC, can't validate firmware revision."));
55884 + revInfo.packageRev = IP_OFFLOAD_PACKAGE_NUMBER;
55885 + }
55886 + else if (!IS_OFFLOAD_PACKAGE(revInfo.packageRev))
55887 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Fman ctrl code package"));
55888 +
55889 + switch (spOper)
55890 + {
55891 + case (FM_SP_OP_CAPWAP_DTLS_DEC):
55892 + *p_SpOperCoding = 9;
55893 + break;
55894 + case (FM_SP_OP_CAPWAP_DTLS_ENC):
55895 + *p_SpOperCoding = 10;
55896 + break;
55897 + case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_UPDATE_UDP_LEN|FM_SP_OP_IPSEC_MANIP):
55898 + case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_UPDATE_UDP_LEN|FM_SP_OP_IPSEC_MANIP|FM_SP_OP_RPD):
55899 + *p_SpOperCoding = 5;
55900 + break;
55901 + case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_MANIP):
55902 + case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_MANIP|FM_SP_OP_RPD):
55903 + *p_SpOperCoding = 6;
55904 + break;
55905 + case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_UPDATE_UDP_LEN|FM_SP_OP_RPD):
55906 + *p_SpOperCoding = 3;
55907 + break;
55908 + case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_UPDATE_UDP_LEN):
55909 + *p_SpOperCoding = 1;
55910 + break;
55911 + case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_UPDATE_UDP_LEN|FM_SP_OP_IPSEC_NO_ETH_HDR):
55912 + *p_SpOperCoding = 12;
55913 + break;
55914 + case (FM_SP_OP_IPSEC|FM_SP_OP_RPD):
55915 + *p_SpOperCoding = 4;
55916 + break;
55917 + case (FM_SP_OP_IPSEC):
55918 + *p_SpOperCoding = 2;
55919 + break;
55920 + case (FM_SP_OP_DCL4C):
55921 + *p_SpOperCoding = 7;
55922 + break;
55923 + case (FM_SP_OP_CLEAR_RPD):
55924 + *p_SpOperCoding = 8;
55925 + break;
55926 + default:
55927 + RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
55928 + }
55929 +
55930 + return E_OK;
55931 +}
55932 +
55933 +t_Error FM_CtrlMonStart(t_Handle h_Fm)
55934 +{
55935 + t_Fm *p_Fm = (t_Fm *)h_Fm;
55936 + t_FmTrbRegs *p_MonRegs;
55937 + uint8_t i;
55938 +
55939 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55940 + SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
55941 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55942 +
55943 + WRITE_UINT32(p_Fm->p_FmFpmRegs->fmfp_brkc,
55944 + GET_UINT32(p_Fm->p_FmFpmRegs->fmfp_brkc) | FPM_BRKC_RDBG);
55945 +
55946 + for (i = 0; i < FM_NUM_OF_CTRL; i++)
55947 + {
55948 + p_MonRegs = (t_FmTrbRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_TRB(i));
55949 +
55950 + /* Reset control registers */
55951 + WRITE_UINT32(p_MonRegs->tcrh, TRB_TCRH_RESET);
55952 + WRITE_UINT32(p_MonRegs->tcrl, TRB_TCRL_RESET);
55953 +
55954 + /* Configure: counter #1 counts all stalls in risc - ldsched stall
55955 + counter #2 counts all stalls in risc - other stall*/
55956 + WRITE_UINT32(p_MonRegs->tcrl, TRB_TCRL_RESET | TRB_TCRL_UTIL);
55957 +
55958 + /* Enable monitoring */
55959 + WRITE_UINT32(p_MonRegs->tcrh, TRB_TCRH_ENABLE_COUNTERS);
55960 + }
55961 +
55962 + return E_OK;
55963 +}
55964 +
55965 +t_Error FM_CtrlMonStop(t_Handle h_Fm)
55966 +{
55967 + t_Fm *p_Fm = (t_Fm *)h_Fm;
55968 + t_FmTrbRegs *p_MonRegs;
55969 + uint8_t i;
55970 +
55971 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55972 + SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
55973 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55974 +
55975 + for (i = 0; i < FM_NUM_OF_CTRL; i++)
55976 + {
55977 + p_MonRegs = (t_FmTrbRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_TRB(i));
55978 + WRITE_UINT32(p_MonRegs->tcrh, TRB_TCRH_DISABLE_COUNTERS);
55979 + }
55980 +
55981 + WRITE_UINT32(p_Fm->p_FmFpmRegs->fmfp_brkc,
55982 + GET_UINT32(p_Fm->p_FmFpmRegs->fmfp_brkc) & ~FPM_BRKC_RDBG);
55983 +
55984 + return E_OK;
55985 +}
55986 +
55987 +t_Error FM_CtrlMonGetCounters(t_Handle h_Fm, uint8_t fmCtrlIndex, t_FmCtrlMon *p_Mon)
55988 +{
55989 + t_Fm *p_Fm = (t_Fm *)h_Fm;
55990 + t_FmTrbRegs *p_MonRegs;
55991 + uint64_t clkCnt, utilValue, effValue;
55992 +
55993 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
55994 + SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
55995 + SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
55996 + SANITY_CHECK_RETURN_ERROR(p_Mon, E_NULL_POINTER);
55997 +
55998 + if (fmCtrlIndex >= FM_NUM_OF_CTRL)
55999 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("FM Controller index"));
56000 +
56001 + p_MonRegs = (t_FmTrbRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_TRB(fmCtrlIndex));
56002 +
56003 + clkCnt = (uint64_t)
56004 + ((uint64_t)GET_UINT32(p_MonRegs->tpcch) << 32 | GET_UINT32(p_MonRegs->tpccl));
56005 +
56006 + utilValue = (uint64_t)
56007 + ((uint64_t)GET_UINT32(p_MonRegs->tpc1h) << 32 | GET_UINT32(p_MonRegs->tpc1l));
56008 +
56009 + effValue = (uint64_t)
56010 + ((uint64_t)GET_UINT32(p_MonRegs->tpc2h) << 32 | GET_UINT32(p_MonRegs->tpc2l));
56011 +
56012 + p_Mon->percentCnt[0] = (uint8_t)((clkCnt - utilValue) * 100 / clkCnt);
56013 + if (clkCnt != utilValue)
56014 + p_Mon->percentCnt[1] = (uint8_t)(((clkCnt - utilValue) - effValue) * 100 / (clkCnt - utilValue));
56015 + else
56016 + p_Mon->percentCnt[1] = 0;
56017 +
56018 + return E_OK;
56019 +}
56020 +
56021 +t_Handle FM_GetMuramHandle(t_Handle h_Fm)
56022 +{
56023 + t_Fm *p_Fm = (t_Fm*)h_Fm;
56024 +
56025 + SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, NULL);
56026 +
56027 + return (p_Fm->h_FmMuram);
56028 +}
56029 +
56030 +/****************************************************/
56031 +/* Hidden-DEBUG Only API */
56032 +/****************************************************/
56033 +t_Error FM_ForceIntr (t_Handle h_Fm, e_FmExceptions exception)
56034 +{
56035 + t_Fm *p_Fm = (t_Fm*)h_Fm;
56036 + enum fman_exceptions fslException;
56037 + struct fman_rg fman_rg;
56038 +
56039 + SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
56040 + SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
56041 +
56042 + fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
56043 + fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
56044 + fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
56045 + fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
56046 +
56047 + switch (exception)
56048 + {
56049 + case e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID:
56050 + if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID))
56051 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
56052 + break;
56053 + case e_FM_EX_QMI_SINGLE_ECC:
56054 + if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
56055 + RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("e_FM_EX_QMI_SINGLE_ECC not supported on this integration."));
56056 +
56057 + if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_QMI_SINGLE_ECC))
56058 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
56059 + break;
56060 + case e_FM_EX_QMI_DOUBLE_ECC:
56061 + if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_QMI_DOUBLE_ECC))
56062 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
56063 + break;
56064 + case e_FM_EX_BMI_LIST_RAM_ECC:
56065 + if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_LIST_RAM_ECC))
56066 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
56067 + break;
56068 + case e_FM_EX_BMI_STORAGE_PROFILE_ECC:
56069 + if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_STORAGE_PROFILE_ECC))
56070 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
56071 + break;
56072 + case e_FM_EX_BMI_STATISTICS_RAM_ECC:
56073 + if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_STATISTICS_RAM_ECC))
56074 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
56075 + break;
56076 + case e_FM_EX_BMI_DISPATCH_RAM_ECC:
56077 + if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_DISPATCH_RAM_ECC))
56078 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
56079 + break;
56080 + default:
56081 + RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception may not be forced"));
56082 + }
56083 +
56084 + fslException = FmanExceptionTrans(exception);
56085 + fman_force_intr (&fman_rg, fslException);
56086 +
56087 + return E_OK;
56088 +}
56089 +
56090 +t_Handle FmGetPcd(t_Handle h_Fm)
56091 +{
56092 + return ((t_Fm*)h_Fm)->h_Pcd;
56093 +}
56094 +#if (DPAA_VERSION >= 11)
56095 +extern void *g_MemacRegs;
56096 +void fm_clk_down(void);
56097 +uint32_t fman_memac_get_event(void *regs, uint32_t ev_mask);
56098 +void FM_ChangeClock(t_Handle h_Fm, int hardwarePortId)
56099 +{
56100 + int macId;
56101 + uint32_t event, rcr;
56102 + t_Fm *p_Fm = (t_Fm*)h_Fm;
56103 + rcr = GET_UINT32(p_Fm->p_FmFpmRegs->fm_rcr);
56104 + rcr |= 0x04000000;
56105 + WRITE_UINT32(p_Fm->p_FmFpmRegs->fm_rcr, rcr);
56106 +
56107 + HW_PORT_ID_TO_SW_PORT_ID(macId, hardwarePortId);
56108 + do
56109 + {
56110 + event = fman_memac_get_event(g_MemacRegs, 0xFFFFFFFF);
56111 + } while ((event & 0x00000020) == 0);
56112 + fm_clk_down();
56113 + rcr = GET_UINT32(p_Fm->p_FmFpmRegs->fm_rcr);
56114 + rcr &= ~0x04000000;
56115 + WRITE_UINT32(p_Fm->p_FmFpmRegs->fm_rcr, rcr);
56116 +}
56117 +#endif
56118 --- /dev/null
56119 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.h
56120 @@ -0,0 +1,646 @@
56121 +/*
56122 + * Copyright 2008-2012 Freescale Semiconductor Inc.
56123 + *
56124 + * Redistribution and use in source and binary forms, with or without
56125 + * modification, are permitted provided that the following conditions are met:
56126 + * * Redistributions of source code must retain the above copyright
56127 + * notice, this list of conditions and the following disclaimer.
56128 + * * Redistributions in binary form must reproduce the above copyright
56129 + * notice, this list of conditions and the following disclaimer in the
56130 + * documentation and/or other materials provided with the distribution.
56131 + * * Neither the name of Freescale Semiconductor nor the
56132 + * names of its contributors may be used to endorse or promote products
56133 + * derived from this software without specific prior written permission.
56134 + *
56135 + *
56136 + * ALTERNATIVELY, this software may be distributed under the terms of the
56137 + * GNU General Public License ("GPL") as published by the Free Software
56138 + * Foundation, either version 2 of that License or (at your option) any
56139 + * later version.
56140 + *
56141 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
56142 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
56143 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
56144 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
56145 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
56146 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
56147 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
56148 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56149 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
56150 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56151 + */
56152 +
56153 +
56154 +/******************************************************************************
56155 + @File fm.h
56156 +
56157 + @Description FM internal structures and definitions.
56158 +*//***************************************************************************/
56159 +#ifndef __FM_H
56160 +#define __FM_H
56161 +
56162 +#include "error_ext.h"
56163 +#include "std_ext.h"
56164 +#include "fm_ext.h"
56165 +#include "fm_ipc.h"
56166 +
56167 +#include "fsl_fman.h"
56168 +
56169 +#define __ERR_MODULE__ MODULE_FM
56170 +
56171 +#define FM_MAX_NUM_OF_HW_PORT_IDS 64
56172 +#define FM_MAX_NUM_OF_GUESTS 100
56173 +
56174 +/**************************************************************************//**
56175 + @Description Exceptions
56176 +*//***************************************************************************/
56177 +#define FM_EX_DMA_BUS_ERROR 0x80000000 /**< DMA bus error. */
56178 +#define FM_EX_DMA_READ_ECC 0x40000000
56179 +#define FM_EX_DMA_SYSTEM_WRITE_ECC 0x20000000
56180 +#define FM_EX_DMA_FM_WRITE_ECC 0x10000000
56181 +#define FM_EX_FPM_STALL_ON_TASKS 0x08000000 /**< Stall of tasks on FPM */
56182 +#define FM_EX_FPM_SINGLE_ECC 0x04000000 /**< Single ECC on FPM */
56183 +#define FM_EX_FPM_DOUBLE_ECC 0x02000000
56184 +#define FM_EX_QMI_SINGLE_ECC 0x01000000 /**< Single ECC on FPM */
56185 +#define FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID 0x00800000 /**< Dequeu from default queue id */
56186 +#define FM_EX_QMI_DOUBLE_ECC 0x00400000
56187 +#define FM_EX_BMI_LIST_RAM_ECC 0x00200000
56188 +#define FM_EX_BMI_STORAGE_PROFILE_ECC 0x00100000
56189 +#define FM_EX_BMI_STATISTICS_RAM_ECC 0x00080000
56190 +#define FM_EX_IRAM_ECC 0x00040000
56191 +#define FM_EX_MURAM_ECC 0x00020000
56192 +#define FM_EX_BMI_DISPATCH_RAM_ECC 0x00010000
56193 +#define FM_EX_DMA_SINGLE_PORT_ECC 0x00008000
56194 +
56195 +#define DMA_EMSR_EMSTR_MASK 0x0000FFFF
56196 +
56197 +#define DMA_THRESH_COMMQ_MASK 0xFF000000
56198 +#define DMA_THRESH_READ_INT_BUF_MASK 0x007F0000
56199 +#define DMA_THRESH_WRITE_INT_BUF_MASK 0x0000007F
56200 +
56201 +#define GET_EXCEPTION_FLAG(bitMask, exception) \
56202 +switch (exception){ \
56203 + case e_FM_EX_DMA_BUS_ERROR: \
56204 + bitMask = FM_EX_DMA_BUS_ERROR; break; \
56205 + case e_FM_EX_DMA_SINGLE_PORT_ECC: \
56206 + bitMask = FM_EX_DMA_SINGLE_PORT_ECC; break; \
56207 + case e_FM_EX_DMA_READ_ECC: \
56208 + bitMask = FM_EX_DMA_READ_ECC; break; \
56209 + case e_FM_EX_DMA_SYSTEM_WRITE_ECC: \
56210 + bitMask = FM_EX_DMA_SYSTEM_WRITE_ECC; break; \
56211 + case e_FM_EX_DMA_FM_WRITE_ECC: \
56212 + bitMask = FM_EX_DMA_FM_WRITE_ECC; break; \
56213 + case e_FM_EX_FPM_STALL_ON_TASKS: \
56214 + bitMask = FM_EX_FPM_STALL_ON_TASKS; break; \
56215 + case e_FM_EX_FPM_SINGLE_ECC: \
56216 + bitMask = FM_EX_FPM_SINGLE_ECC; break; \
56217 + case e_FM_EX_FPM_DOUBLE_ECC: \
56218 + bitMask = FM_EX_FPM_DOUBLE_ECC; break; \
56219 + case e_FM_EX_QMI_SINGLE_ECC: \
56220 + bitMask = FM_EX_QMI_SINGLE_ECC; break; \
56221 + case e_FM_EX_QMI_DOUBLE_ECC: \
56222 + bitMask = FM_EX_QMI_DOUBLE_ECC; break; \
56223 + case e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID: \
56224 + bitMask = FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID; break; \
56225 + case e_FM_EX_BMI_LIST_RAM_ECC: \
56226 + bitMask = FM_EX_BMI_LIST_RAM_ECC; break; \
56227 + case e_FM_EX_BMI_STORAGE_PROFILE_ECC: \
56228 + bitMask = FM_EX_BMI_STORAGE_PROFILE_ECC; break; \
56229 + case e_FM_EX_BMI_STATISTICS_RAM_ECC: \
56230 + bitMask = FM_EX_BMI_STATISTICS_RAM_ECC; break; \
56231 + case e_FM_EX_BMI_DISPATCH_RAM_ECC: \
56232 + bitMask = FM_EX_BMI_DISPATCH_RAM_ECC; break; \
56233 + case e_FM_EX_IRAM_ECC: \
56234 + bitMask = FM_EX_IRAM_ECC; break; \
56235 + case e_FM_EX_MURAM_ECC: \
56236 + bitMask = FM_EX_MURAM_ECC; break; \
56237 + default: bitMask = 0;break; \
56238 +}
56239 +
56240 +#define GET_FM_MODULE_EVENT(_mod, _id, _intrType, _event) \
56241 + switch (_mod) { \
56242 + case e_FM_MOD_PRS: \
56243 + if (_id) _event = e_FM_EV_DUMMY_LAST; \
56244 + else _event = (_intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_PRS : e_FM_EV_PRS; \
56245 + break; \
56246 + case e_FM_MOD_KG: \
56247 + if (_id) _event = e_FM_EV_DUMMY_LAST; \
56248 + else _event = (_intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_KG : e_FM_EV_DUMMY_LAST; \
56249 + break; \
56250 + case e_FM_MOD_PLCR: \
56251 + if (_id) _event = e_FM_EV_DUMMY_LAST; \
56252 + else _event = (_intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_PLCR : e_FM_EV_PLCR; \
56253 + break; \
56254 + case e_FM_MOD_TMR: \
56255 + if (_id) _event = e_FM_EV_DUMMY_LAST; \
56256 + else _event = (_intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_DUMMY_LAST : e_FM_EV_TMR; \
56257 + break; \
56258 + case e_FM_MOD_10G_MAC: \
56259 + if (_id >= FM_MAX_NUM_OF_10G_MACS) _event = e_FM_EV_DUMMY_LAST; \
56260 + else _event = (_intrType == e_FM_INTR_TYPE_ERR) ? (e_FM_EV_ERR_10G_MAC0 + _id) : (e_FM_EV_10G_MAC0 + _id); \
56261 + break; \
56262 + case e_FM_MOD_1G_MAC: \
56263 + if (_id >= FM_MAX_NUM_OF_1G_MACS) _event = e_FM_EV_DUMMY_LAST; \
56264 + else _event = (_intrType == e_FM_INTR_TYPE_ERR) ? (e_FM_EV_ERR_1G_MAC0 + _id) : (e_FM_EV_1G_MAC0 + _id); \
56265 + break; \
56266 + case e_FM_MOD_MACSEC: \
56267 + switch (_id){ \
56268 + case (0): _event = (_intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_MACSEC_MAC0:e_FM_EV_MACSEC_MAC0; \
56269 + break; \
56270 + } \
56271 + break; \
56272 + case e_FM_MOD_FMAN_CTRL: \
56273 + if (_intrType == e_FM_INTR_TYPE_ERR) _event = e_FM_EV_DUMMY_LAST; \
56274 + else _event = (e_FM_EV_FMAN_CTRL_0 + _id); \
56275 + break; \
56276 + default: _event = e_FM_EV_DUMMY_LAST; \
56277 + break; \
56278 + }
56279 +
56280 +#define FMAN_CACHE_OVERRIDE_TRANS(fsl_cache_override, _cache_override) \
56281 + switch (_cache_override){ \
56282 + case e_FM_DMA_NO_CACHE_OR: \
56283 + fsl_cache_override = E_FMAN_DMA_NO_CACHE_OR; break; \
56284 + case e_FM_DMA_NO_STASH_DATA: \
56285 + fsl_cache_override = E_FMAN_DMA_NO_STASH_DATA; break; \
56286 + case e_FM_DMA_MAY_STASH_DATA: \
56287 + fsl_cache_override = E_FMAN_DMA_MAY_STASH_DATA; break; \
56288 + case e_FM_DMA_STASH_DATA: \
56289 + fsl_cache_override = E_FMAN_DMA_STASH_DATA; break; \
56290 + default: \
56291 + fsl_cache_override = E_FMAN_DMA_NO_CACHE_OR; break; \
56292 + }
56293 +
56294 +#define FMAN_AID_MODE_TRANS(fsl_aid_mode, _aid_mode) \
56295 + switch (_aid_mode){ \
56296 + case e_FM_DMA_AID_OUT_PORT_ID: \
56297 + fsl_aid_mode = E_FMAN_DMA_AID_OUT_PORT_ID; break; \
56298 + case e_FM_DMA_AID_OUT_TNUM: \
56299 + fsl_aid_mode = E_FMAN_DMA_AID_OUT_TNUM; break; \
56300 + default: \
56301 + fsl_aid_mode = E_FMAN_DMA_AID_OUT_PORT_ID; break; \
56302 + }
56303 +
56304 +#define FMAN_DMA_DBG_CNT_TRANS(fsl_dma_dbg_cnt, _dma_dbg_cnt) \
56305 + switch (_dma_dbg_cnt){ \
56306 + case e_FM_DMA_DBG_NO_CNT: \
56307 + fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_NO_CNT; break; \
56308 + case e_FM_DMA_DBG_CNT_DONE: \
56309 + fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_DONE; break; \
56310 + case e_FM_DMA_DBG_CNT_COMM_Q_EM: \
56311 + fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_COMM_Q_EM; break; \
56312 + case e_FM_DMA_DBG_CNT_INT_READ_EM: \
56313 + fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_INT_READ_EM; break; \
56314 + case e_FM_DMA_DBG_CNT_INT_WRITE_EM: \
56315 + fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_INT_WRITE_EM ; break; \
56316 + case e_FM_DMA_DBG_CNT_FPM_WAIT: \
56317 + fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_FPM_WAIT ; break; \
56318 + case e_FM_DMA_DBG_CNT_SIGLE_BIT_ECC: \
56319 + fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_SIGLE_BIT_ECC ; break; \
56320 + case e_FM_DMA_DBG_CNT_RAW_WAR_PROT: \
56321 + fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_RAW_WAR_PROT ; break; \
56322 + default: \
56323 + fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_NO_CNT; break; \
56324 + }
56325 +
56326 +#define FMAN_DMA_EMER_TRANS(fsl_dma_emer, _dma_emer) \
56327 + switch (_dma_emer){ \
56328 + case e_FM_DMA_EM_EBS: \
56329 + fsl_dma_emer = E_FMAN_DMA_EM_EBS; break; \
56330 + case e_FM_DMA_EM_SOS: \
56331 + fsl_dma_emer = E_FMAN_DMA_EM_SOS; break; \
56332 + default: \
56333 + fsl_dma_emer = E_FMAN_DMA_EM_EBS; break; \
56334 + }
56335 +
56336 +#define FMAN_DMA_ERR_TRANS(fsl_dma_err, _dma_err) \
56337 + switch (_dma_err){ \
56338 + case e_FM_DMA_ERR_CATASTROPHIC: \
56339 + fsl_dma_err = E_FMAN_DMA_ERR_CATASTROPHIC; break; \
56340 + case e_FM_DMA_ERR_REPORT: \
56341 + fsl_dma_err = E_FMAN_DMA_ERR_REPORT; break; \
56342 + default: \
56343 + fsl_dma_err = E_FMAN_DMA_ERR_CATASTROPHIC; break; \
56344 + }
56345 +
56346 +#define FMAN_CATASTROPHIC_ERR_TRANS(fsl_catastrophic_err, _catastrophic_err) \
56347 + switch (_catastrophic_err){ \
56348 + case e_FM_CATASTROPHIC_ERR_STALL_PORT: \
56349 + fsl_catastrophic_err = E_FMAN_CATAST_ERR_STALL_PORT; break; \
56350 + case e_FM_CATASTROPHIC_ERR_STALL_TASK: \
56351 + fsl_catastrophic_err = E_FMAN_CATAST_ERR_STALL_TASK; break; \
56352 + default: \
56353 + fsl_catastrophic_err = E_FMAN_CATAST_ERR_STALL_PORT; break; \
56354 + }
56355 +
56356 +#define FMAN_COUNTERS_TRANS(fsl_counters, _counters) \
56357 + switch (_counters){ \
56358 + case e_FM_COUNTERS_ENQ_TOTAL_FRAME: \
56359 + fsl_counters = E_FMAN_COUNTERS_ENQ_TOTAL_FRAME; break; \
56360 + case e_FM_COUNTERS_DEQ_TOTAL_FRAME: \
56361 + fsl_counters = E_FMAN_COUNTERS_DEQ_TOTAL_FRAME; break; \
56362 + case e_FM_COUNTERS_DEQ_0: \
56363 + fsl_counters = E_FMAN_COUNTERS_DEQ_0; break; \
56364 + case e_FM_COUNTERS_DEQ_1: \
56365 + fsl_counters = E_FMAN_COUNTERS_DEQ_1; break; \
56366 + case e_FM_COUNTERS_DEQ_2: \
56367 + fsl_counters = E_FMAN_COUNTERS_DEQ_2; break; \
56368 + case e_FM_COUNTERS_DEQ_3: \
56369 + fsl_counters = E_FMAN_COUNTERS_DEQ_3; break; \
56370 + case e_FM_COUNTERS_DEQ_FROM_DEFAULT: \
56371 + fsl_counters = E_FMAN_COUNTERS_DEQ_FROM_DEFAULT; break; \
56372 + case e_FM_COUNTERS_DEQ_FROM_CONTEXT: \
56373 + fsl_counters = E_FMAN_COUNTERS_DEQ_FROM_CONTEXT; break; \
56374 + case e_FM_COUNTERS_DEQ_FROM_FD: \
56375 + fsl_counters = E_FMAN_COUNTERS_DEQ_FROM_FD; break; \
56376 + case e_FM_COUNTERS_DEQ_CONFIRM: \
56377 + fsl_counters = E_FMAN_COUNTERS_DEQ_CONFIRM; break; \
56378 + default: \
56379 + fsl_counters = E_FMAN_COUNTERS_ENQ_TOTAL_FRAME; break; \
56380 + }
56381 +
56382 +/**************************************************************************//**
56383 + @Description defaults
56384 +*//***************************************************************************/
56385 +#define DEFAULT_exceptions (FM_EX_DMA_BUS_ERROR |\
56386 + FM_EX_DMA_READ_ECC |\
56387 + FM_EX_DMA_SYSTEM_WRITE_ECC |\
56388 + FM_EX_DMA_FM_WRITE_ECC |\
56389 + FM_EX_FPM_STALL_ON_TASKS |\
56390 + FM_EX_FPM_SINGLE_ECC |\
56391 + FM_EX_FPM_DOUBLE_ECC |\
56392 + FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID|\
56393 + FM_EX_BMI_LIST_RAM_ECC |\
56394 + FM_EX_BMI_STORAGE_PROFILE_ECC |\
56395 + FM_EX_BMI_STATISTICS_RAM_ECC |\
56396 + FM_EX_IRAM_ECC |\
56397 + FM_EX_MURAM_ECC |\
56398 + FM_EX_BMI_DISPATCH_RAM_ECC |\
56399 + FM_EX_QMI_DOUBLE_ECC |\
56400 + FM_EX_QMI_SINGLE_ECC)
56401 +
56402 +#define DEFAULT_eccEnable FALSE
56403 +#ifdef FM_PEDANTIC_DMA
56404 +#define DEFAULT_aidOverride TRUE
56405 +#else
56406 +#define DEFAULT_aidOverride FALSE
56407 +#endif /* FM_PEDANTIC_DMA */
56408 +#define DEFAULT_aidMode e_FM_DMA_AID_OUT_TNUM
56409 +#define DEFAULT_dmaStopOnBusError FALSE
56410 +#define DEFAULT_stopAtBusError FALSE
56411 +#define DEFAULT_axiDbgNumOfBeats 1
56412 +#define DEFAULT_dmaReadIntBufLow ((DMA_THRESH_MAX_BUF+1)/2)
56413 +#define DEFAULT_dmaReadIntBufHigh ((DMA_THRESH_MAX_BUF+1)*3/4)
56414 +#define DEFAULT_dmaWriteIntBufLow ((DMA_THRESH_MAX_BUF+1)/2)
56415 +#define DEFAULT_dmaWriteIntBufHigh ((DMA_THRESH_MAX_BUF+1)*3/4)
56416 +#define DEFAULT_catastrophicErr e_FM_CATASTROPHIC_ERR_STALL_PORT
56417 +#define DEFAULT_dmaErr e_FM_DMA_ERR_CATASTROPHIC
56418 +#define DEFAULT_resetOnInit FALSE
56419 +#define DEFAULT_haltOnExternalActivation FALSE /* do not change! if changed, must be disabled for rev1 ! */
56420 +#define DEFAULT_haltOnUnrecoverableEccError FALSE /* do not change! if changed, must be disabled for rev1 ! */
56421 +#define DEFAULT_externalEccRamsEnable FALSE
56422 +#define DEFAULT_VerifyUcode FALSE
56423 +
56424 +#if (DPAA_VERSION < 11)
56425 +#define DEFAULT_totalFifoSize(major, minor) \
56426 + (((major == 2) || (major == 5)) ? \
56427 + (100*KILOBYTE) : ((major == 4) ? \
56428 + (49*KILOBYTE) : (122*KILOBYTE)))
56429 +#define DEFAULT_totalNumOfTasks(major, minor) \
56430 + BMI_MAX_NUM_OF_TASKS
56431 +
56432 +#define DEFAULT_dmaCommQLow ((DMA_THRESH_MAX_COMMQ+1)/2)
56433 +#define DEFAULT_dmaCommQHigh ((DMA_THRESH_MAX_COMMQ+1)*3/4)
56434 +#define DEFAULT_cacheOverride e_FM_DMA_NO_CACHE_OR
56435 +#define DEFAULT_dmaCamNumOfEntries 32
56436 +#define DEFAULT_dmaDbgCntMode e_FM_DMA_DBG_NO_CNT
56437 +#define DEFAULT_dmaEnEmergency FALSE
56438 +#define DEFAULT_dmaSosEmergency 0
56439 +#define DEFAULT_dmaWatchdog 0 /* disabled */
56440 +#define DEFAULT_dmaEnEmergencySmoother FALSE
56441 +#define DEFAULT_dmaEmergencySwitchCounter 0
56442 +
56443 +#define DEFAULT_dispLimit 0
56444 +#define DEFAULT_prsDispTh 16
56445 +#define DEFAULT_plcrDispTh 16
56446 +#define DEFAULT_kgDispTh 16
56447 +#define DEFAULT_bmiDispTh 16
56448 +#define DEFAULT_qmiEnqDispTh 16
56449 +#define DEFAULT_qmiDeqDispTh 16
56450 +#define DEFAULT_fmCtl1DispTh 16
56451 +#define DEFAULT_fmCtl2DispTh 16
56452 +
56453 +#else /* (DPAA_VERSION < 11) */
56454 +/* Defaults are registers' reset values */
56455 +#define DEFAULT_totalFifoSize(major, minor) \
56456 + (((major == 6) && ((minor == 1) || (minor == 4))) ? \
56457 + (156*KILOBYTE) : (295*KILOBYTE))
56458 +
56459 +/* According to the default value of FMBM_CFG2[TNTSKS] */
56460 +#define DEFAULT_totalNumOfTasks(major, minor) \
56461 + (((major == 6) && ((minor == 1) || (minor == 4))) ? 59 : 124)
56462 +
56463 +#define DEFAULT_dmaCommQLow 0x2A
56464 +#define DEFAULT_dmaCommQHigh 0x3F
56465 +#define DEFAULT_cacheOverride e_FM_DMA_NO_CACHE_OR
56466 +#define DEFAULT_dmaCamNumOfEntries 64
56467 +#define DEFAULT_dmaDbgCntMode e_FM_DMA_DBG_NO_CNT
56468 +#define DEFAULT_dmaEnEmergency FALSE
56469 +#define DEFAULT_dmaSosEmergency 0
56470 +#define DEFAULT_dmaWatchdog 0 /* disabled */
56471 +#define DEFAULT_dmaEnEmergencySmoother FALSE
56472 +#define DEFAULT_dmaEmergencySwitchCounter 0
56473 +
56474 +#define DEFAULT_dispLimit 0
56475 +#define DEFAULT_prsDispTh 16
56476 +#define DEFAULT_plcrDispTh 16
56477 +#define DEFAULT_kgDispTh 16
56478 +#define DEFAULT_bmiDispTh 16
56479 +#define DEFAULT_qmiEnqDispTh 16
56480 +#define DEFAULT_qmiDeqDispTh 16
56481 +#define DEFAULT_fmCtl1DispTh 16
56482 +#define DEFAULT_fmCtl2DispTh 16
56483 +#endif /* (DPAA_VERSION < 11) */
56484 +
56485 +#define FM_TIMESTAMP_1_USEC_BIT 8
56486 +
56487 +/**************************************************************************//**
56488 + @Collection Defines used for enabling/disabling FM interrupts
56489 + @{
56490 +*//***************************************************************************/
56491 +#define ERR_INTR_EN_DMA 0x00010000
56492 +#define ERR_INTR_EN_FPM 0x80000000
56493 +#define ERR_INTR_EN_BMI 0x00800000
56494 +#define ERR_INTR_EN_QMI 0x00400000
56495 +#define ERR_INTR_EN_PRS 0x00200000
56496 +#define ERR_INTR_EN_KG 0x00100000
56497 +#define ERR_INTR_EN_PLCR 0x00080000
56498 +#define ERR_INTR_EN_MURAM 0x00040000
56499 +#define ERR_INTR_EN_IRAM 0x00020000
56500 +#define ERR_INTR_EN_10G_MAC0 0x00008000
56501 +#define ERR_INTR_EN_10G_MAC1 0x00000040
56502 +#define ERR_INTR_EN_1G_MAC0 0x00004000
56503 +#define ERR_INTR_EN_1G_MAC1 0x00002000
56504 +#define ERR_INTR_EN_1G_MAC2 0x00001000
56505 +#define ERR_INTR_EN_1G_MAC3 0x00000800
56506 +#define ERR_INTR_EN_1G_MAC4 0x00000400
56507 +#define ERR_INTR_EN_1G_MAC5 0x00000200
56508 +#define ERR_INTR_EN_1G_MAC6 0x00000100
56509 +#define ERR_INTR_EN_1G_MAC7 0x00000080
56510 +#define ERR_INTR_EN_MACSEC_MAC0 0x00000001
56511 +
56512 +#define INTR_EN_QMI 0x40000000
56513 +#define INTR_EN_PRS 0x20000000
56514 +#define INTR_EN_WAKEUP 0x10000000
56515 +#define INTR_EN_PLCR 0x08000000
56516 +#define INTR_EN_1G_MAC0 0x00080000
56517 +#define INTR_EN_1G_MAC1 0x00040000
56518 +#define INTR_EN_1G_MAC2 0x00020000
56519 +#define INTR_EN_1G_MAC3 0x00010000
56520 +#define INTR_EN_1G_MAC4 0x00000040
56521 +#define INTR_EN_1G_MAC5 0x00000020
56522 +#define INTR_EN_1G_MAC6 0x00000008
56523 +#define INTR_EN_1G_MAC7 0x00000002
56524 +#define INTR_EN_10G_MAC0 0x00200000
56525 +#define INTR_EN_10G_MAC1 0x00100000
56526 +#define INTR_EN_REV0 0x00008000
56527 +#define INTR_EN_REV1 0x00004000
56528 +#define INTR_EN_REV2 0x00002000
56529 +#define INTR_EN_REV3 0x00001000
56530 +#define INTR_EN_BRK 0x00000080
56531 +#define INTR_EN_TMR 0x01000000
56532 +#define INTR_EN_MACSEC_MAC0 0x00000001
56533 +/* @} */
56534 +
56535 +/**************************************************************************//**
56536 + @Description Memory Mapped Registers
56537 +*//***************************************************************************/
56538 +
56539 +#if defined(__MWERKS__) && !defined(__GNUC__)
56540 +#pragma pack(push,1)
56541 +#endif /* defined(__MWERKS__) && ... */
56542 +
56543 +typedef struct
56544 +{
56545 + volatile uint32_t iadd; /**< FM IRAM instruction address register */
56546 + volatile uint32_t idata; /**< FM IRAM instruction data register */
56547 + volatile uint32_t itcfg; /**< FM IRAM timing config register */
56548 + volatile uint32_t iready; /**< FM IRAM ready register */
56549 + volatile uint32_t res[0x1FFFC];
56550 +} t_FMIramRegs;
56551 +
56552 +/* Trace buffer registers -
56553 + each FM Controller has its own trace buffer residing at FM_MM_TRB(fmCtrlIndex) offset */
56554 +typedef struct t_FmTrbRegs
56555 +{
56556 + volatile uint32_t tcrh;
56557 + volatile uint32_t tcrl;
56558 + volatile uint32_t tesr;
56559 + volatile uint32_t tecr0h;
56560 + volatile uint32_t tecr0l;
56561 + volatile uint32_t terf0h;
56562 + volatile uint32_t terf0l;
56563 + volatile uint32_t tecr1h;
56564 + volatile uint32_t tecr1l;
56565 + volatile uint32_t terf1h;
56566 + volatile uint32_t terf1l;
56567 + volatile uint32_t tpcch;
56568 + volatile uint32_t tpccl;
56569 + volatile uint32_t tpc1h;
56570 + volatile uint32_t tpc1l;
56571 + volatile uint32_t tpc2h;
56572 + volatile uint32_t tpc2l;
56573 + volatile uint32_t twdimr;
56574 + volatile uint32_t twicvr;
56575 + volatile uint32_t tar;
56576 + volatile uint32_t tdr;
56577 + volatile uint32_t tsnum1;
56578 + volatile uint32_t tsnum2;
56579 + volatile uint32_t tsnum3;
56580 + volatile uint32_t tsnum4;
56581 +} t_FmTrbRegs;
56582 +
56583 +#if defined(__MWERKS__) && !defined(__GNUC__)
56584 +#pragma pack(pop)
56585 +#endif /* defined(__MWERKS__) && ... */
56586 +
56587 +/**************************************************************************//**
56588 + @Description General defines
56589 +*//***************************************************************************/
56590 +#define FM_DEBUG_STATUS_REGISTER_OFFSET 0x000d1084UL
56591 +#define FM_FW_DEBUG_INSTRUCTION 0x6ffff805UL
56592 +
56593 +/**************************************************************************//**
56594 + @Description FPM defines
56595 +*//***************************************************************************/
56596 +/* masks */
56597 +#define FPM_BRKC_RDBG 0x00000200
56598 +#define FPM_BRKC_SLP 0x00000800
56599 +/**************************************************************************//**
56600 + @Description BMI defines
56601 +*//***************************************************************************/
56602 +/* masks */
56603 +#define BMI_INIT_START 0x80000000
56604 +#define BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC 0x80000000
56605 +#define BMI_ERR_INTR_EN_LIST_RAM_ECC 0x40000000
56606 +#define BMI_ERR_INTR_EN_STATISTICS_RAM_ECC 0x20000000
56607 +#define BMI_ERR_INTR_EN_DISPATCH_RAM_ECC 0x10000000
56608 +/**************************************************************************//**
56609 + @Description QMI defines
56610 +*//***************************************************************************/
56611 +/* masks */
56612 +#define QMI_ERR_INTR_EN_DOUBLE_ECC 0x80000000
56613 +#define QMI_ERR_INTR_EN_DEQ_FROM_DEF 0x40000000
56614 +#define QMI_INTR_EN_SINGLE_ECC 0x80000000
56615 +
56616 +/**************************************************************************//**
56617 + @Description IRAM defines
56618 +*//***************************************************************************/
56619 +/* masks */
56620 +#define IRAM_IADD_AIE 0x80000000
56621 +#define IRAM_READY 0x80000000
56622 +
56623 +/**************************************************************************//**
56624 + @Description TRB defines
56625 +*//***************************************************************************/
56626 +/* masks */
56627 +#define TRB_TCRH_RESET 0x04000000
56628 +#define TRB_TCRH_ENABLE_COUNTERS 0x84008000
56629 +#define TRB_TCRH_DISABLE_COUNTERS 0x8400C000
56630 +#define TRB_TCRL_RESET 0x20000000
56631 +#define TRB_TCRL_UTIL 0x00000460
56632 +typedef struct {
56633 + void (*f_Isr) (t_Handle h_Arg, uint32_t event);
56634 + t_Handle h_SrcHandle;
56635 +} t_FmanCtrlIntrSrc;
56636 +
56637 +
56638 +typedef void (t_FmanCtrlIsr)( t_Handle h_Fm, uint32_t event);
56639 +
56640 +typedef struct
56641 +{
56642 +/***************************/
56643 +/* Master/Guest parameters */
56644 +/***************************/
56645 + uint8_t fmId;
56646 + e_FmPortType portsTypes[FM_MAX_NUM_OF_HW_PORT_IDS];
56647 + uint16_t fmClkFreq;
56648 + uint16_t fmMacClkFreq;
56649 + t_FmRevisionInfo revInfo;
56650 +/**************************/
56651 +/* Master Only parameters */
56652 +/**************************/
56653 + bool enabledTimeStamp;
56654 + uint8_t count1MicroBit;
56655 + uint8_t totalNumOfTasks;
56656 + uint32_t totalFifoSize;
56657 + uint8_t maxNumOfOpenDmas;
56658 + uint8_t accumulatedNumOfTasks;
56659 + uint32_t accumulatedFifoSize;
56660 + uint8_t accumulatedNumOfOpenDmas;
56661 + uint8_t accumulatedNumOfDeqTnums;
56662 +#ifdef FM_LOW_END_RESTRICTION
56663 + bool lowEndRestriction;
56664 +#endif /* FM_LOW_END_RESTRICTION */
56665 + uint32_t exceptions;
56666 + int irq;
56667 + int errIrq;
56668 + bool ramsEccEnable;
56669 + bool explicitEnable;
56670 + bool internalCall;
56671 + uint8_t ramsEccOwners;
56672 + uint32_t extraFifoPoolSize;
56673 + uint8_t extraTasksPoolSize;
56674 + uint8_t extraOpenDmasPoolSize;
56675 +#if defined(FM_MAX_NUM_OF_10G_MACS) && (FM_MAX_NUM_OF_10G_MACS)
56676 + uint16_t portMaxFrameLengths10G[FM_MAX_NUM_OF_10G_MACS];
56677 + uint16_t macMaxFrameLengths10G[FM_MAX_NUM_OF_10G_MACS];
56678 +#endif /* defined(FM_MAX_NUM_OF_10G_MACS) && ... */
56679 + uint16_t portMaxFrameLengths1G[FM_MAX_NUM_OF_1G_MACS];
56680 + uint16_t macMaxFrameLengths1G[FM_MAX_NUM_OF_1G_MACS];
56681 +} t_FmStateStruct;
56682 +
56683 +#if (DPAA_VERSION >= 11)
56684 +typedef struct t_FmMapParam {
56685 + uint16_t profilesBase;
56686 + uint16_t numOfProfiles;
56687 + t_Handle h_FmPort;
56688 +} t_FmMapParam;
56689 +
56690 +typedef struct t_FmAllocMng {
56691 + bool allocated;
56692 + uint8_t ownerId; /* guestId for KG in multi-partition only,
56693 + portId for PLCR in any environment */
56694 +} t_FmAllocMng;
56695 +
56696 +typedef struct t_FmPcdSpEntry {
56697 + bool valid;
56698 + t_FmAllocMng profilesMng;
56699 +} t_FmPcdSpEntry;
56700 +
56701 +typedef struct t_FmSp {
56702 + void *p_FmPcdStoragePrflRegs;
56703 + t_FmPcdSpEntry profiles[FM_VSP_MAX_NUM_OF_ENTRIES];
56704 + t_FmMapParam portsMapping[FM_MAX_NUM_OF_PORTS];
56705 +} t_FmSp;
56706 +#endif /* (DPAA_VERSION >= 11) */
56707 +
56708 +typedef struct t_Fm
56709 +{
56710 +/***************************/
56711 +/* Master/Guest parameters */
56712 +/***************************/
56713 +/* locals for recovery */
56714 + uintptr_t baseAddr;
56715 +
56716 +/* un-needed for recovery */
56717 + t_Handle h_Pcd;
56718 + char fmModuleName[MODULE_NAME_SIZE];
56719 + char fmIpcHandlerModuleName[FM_MAX_NUM_OF_GUESTS][MODULE_NAME_SIZE];
56720 + t_Handle h_IpcSessions[FM_MAX_NUM_OF_GUESTS];
56721 + t_FmIntrSrc intrMng[e_FM_EV_DUMMY_LAST]; /* FM exceptions user callback */
56722 + uint8_t guestId;
56723 +/**************************/
56724 +/* Master Only parameters */
56725 +/**************************/
56726 +/* locals for recovery */
56727 + struct fman_fpm_regs *p_FmFpmRegs;
56728 + struct fman_bmi_regs *p_FmBmiRegs;
56729 + struct fman_qmi_regs *p_FmQmiRegs;
56730 + struct fman_dma_regs *p_FmDmaRegs;
56731 + struct fman_regs *p_FmRegs;
56732 + t_FmExceptionsCallback *f_Exception;
56733 + t_FmBusErrorCallback *f_BusError;
56734 + t_Handle h_App; /* Application handle */
56735 + t_Handle h_Spinlock;
56736 + bool recoveryMode;
56737 + t_FmStateStruct *p_FmStateStruct;
56738 + uint16_t tnumAgingPeriod;
56739 +#if (DPAA_VERSION >= 11)
56740 + t_FmSp *p_FmSp;
56741 + uint8_t partNumOfVSPs;
56742 + uint8_t partVSPBase;
56743 + uintptr_t vspBaseAddr;
56744 +#endif /* (DPAA_VERSION >= 11) */
56745 + bool portsPreFetchConfigured[FM_MAX_NUM_OF_HW_PORT_IDS]; /* Prefetch configration per Tx-port */
56746 + bool portsPreFetchValue[FM_MAX_NUM_OF_HW_PORT_IDS]; /* Prefetch configration per Tx-port */
56747 +
56748 +/* un-needed for recovery */
56749 + struct fman_cfg *p_FmDriverParam;
56750 + t_Handle h_FmMuram;
56751 + uint64_t fmMuramPhysBaseAddr;
56752 + bool independentMode;
56753 + bool hcPortInitialized;
56754 + uintptr_t camBaseAddr; /* save for freeing */
56755 + uintptr_t resAddr;
56756 + uintptr_t fifoBaseAddr; /* save for freeing */
56757 + t_FmanCtrlIntrSrc fmanCtrlIntr[FM_NUM_OF_FMAN_CTRL_EVENT_REGS]; /* FM exceptions user callback */
56758 + bool usedEventRegs[FM_NUM_OF_FMAN_CTRL_EVENT_REGS];
56759 + t_FmFirmwareParams firmware;
56760 + bool fwVerify;
56761 + bool resetOnInit;
56762 + uint32_t userSetExceptions;
56763 +} t_Fm;
56764 +
56765 +
56766 +#endif /* __FM_H */
56767 --- /dev/null
56768 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm_ipc.h
56769 @@ -0,0 +1,465 @@
56770 +/*
56771 + * Copyright 2008-2012 Freescale Semiconductor Inc.
56772 + *
56773 + * Redistribution and use in source and binary forms, with or without
56774 + * modification, are permitted provided that the following conditions are met:
56775 + * * Redistributions of source code must retain the above copyright
56776 + * notice, this list of conditions and the following disclaimer.
56777 + * * Redistributions in binary form must reproduce the above copyright
56778 + * notice, this list of conditions and the following disclaimer in the
56779 + * documentation and/or other materials provided with the distribution.
56780 + * * Neither the name of Freescale Semiconductor nor the
56781 + * names of its contributors may be used to endorse or promote products
56782 + * derived from this software without specific prior written permission.
56783 + *
56784 + *
56785 + * ALTERNATIVELY, this software may be distributed under the terms of the
56786 + * GNU General Public License ("GPL") as published by the Free Software
56787 + * Foundation, either version 2 of that License or (at your option) any
56788 + * later version.
56789 + *
56790 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
56791 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
56792 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
56793 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
56794 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
56795 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
56796 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
56797 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56798 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
56799 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56800 + */
56801 +
56802 +
56803 +/**************************************************************************//**
56804 + @File fm_ipc.h
56805 +
56806 + @Description FM Inter-Partition prototypes, structures and definitions.
56807 +*//***************************************************************************/
56808 +#ifndef __FM_IPC_H
56809 +#define __FM_IPC_H
56810 +
56811 +#include "error_ext.h"
56812 +#include "std_ext.h"
56813 +
56814 +
56815 +/**************************************************************************//**
56816 + @Group FM_grp Frame Manager API
56817 +
56818 + @Description FM API functions, definitions and enums
56819 +
56820 + @{
56821 +*//***************************************************************************/
56822 +
56823 +/**************************************************************************//**
56824 + @Group FM_IPC_grp FM Inter-Partition messaging Unit
56825 +
56826 + @Description FM Inter-Partition messaging unit API definitions and enums.
56827 +
56828 + @{
56829 +*//***************************************************************************/
56830 +
56831 +#if defined(__MWERKS__) && !defined(__GNUC__)
56832 +#pragma pack(push,1)
56833 +#endif /* defined(__MWERKS__) && ... */
56834 +
56835 +/**************************************************************************//**
56836 + @Description enum for defining MAC types
56837 +*//***************************************************************************/
56838 +
56839 +/**************************************************************************//**
56840 + @Description A structure of parameters for specifying a MAC.
56841 +*//***************************************************************************/
56842 +typedef _Packed struct
56843 +{
56844 + uint8_t id;
56845 + uint32_t enumType;
56846 +} _PackedType t_FmIpcMacParams;
56847 +
56848 +/**************************************************************************//**
56849 + @Description A structure of parameters for specifying a MAC.
56850 +*//***************************************************************************/
56851 +typedef _Packed struct
56852 +{
56853 + t_FmIpcMacParams macParams;
56854 + uint16_t maxFrameLength;
56855 +} _PackedType t_FmIpcMacMaxFrameParams;
56856 +
56857 +/**************************************************************************//**
56858 + @Description FM physical Address
56859 +*//***************************************************************************/
56860 +typedef _Packed struct t_FmIpcPhysAddr
56861 +{
56862 + volatile uint8_t high;
56863 + volatile uint32_t low;
56864 +} _PackedType t_FmIpcPhysAddr;
56865 +
56866 +
56867 +typedef _Packed struct t_FmIpcPortOutInitParams {
56868 + uint8_t numOfTasks; /**< OUT */
56869 + uint8_t numOfExtraTasks; /**< OUT */
56870 + uint8_t numOfOpenDmas; /**< OUT */
56871 + uint8_t numOfExtraOpenDmas; /**< OUT */
56872 + uint32_t sizeOfFifo; /**< OUT */
56873 + uint32_t extraSizeOfFifo; /**< OUT */
56874 + t_FmIpcPhysAddr ipcPhysAddr; /**< OUT */
56875 +} _PackedType t_FmIpcPortOutInitParams;
56876 +
56877 +/**************************************************************************//**
56878 + @Description Structure for IPC communication during FM_PORT_Init.
56879 +*//***************************************************************************/
56880 +typedef _Packed struct t_FmIpcPortInInitParams {
56881 + uint8_t hardwarePortId; /**< IN. port Id */
56882 + uint32_t enumPortType; /**< IN. Port type */
56883 + uint8_t boolIndependentMode;/**< IN. TRUE if FM Port operates in independent mode */
56884 + uint16_t liodnOffset; /**< IN. Port's requested resource */
56885 + uint8_t numOfTasks; /**< IN. Port's requested resource */
56886 + uint8_t numOfExtraTasks; /**< IN. Port's requested resource */
56887 + uint8_t numOfOpenDmas; /**< IN. Port's requested resource */
56888 + uint8_t numOfExtraOpenDmas; /**< IN. Port's requested resource */
56889 + uint32_t sizeOfFifo; /**< IN. Port's requested resource */
56890 + uint32_t extraSizeOfFifo; /**< IN. Port's requested resource */
56891 + uint8_t deqPipelineDepth; /**< IN. Port's requested resource */
56892 + uint16_t maxFrameLength; /**< IN. Port's max frame length. */
56893 + uint16_t liodnBase; /**< IN. Irrelevant for P4080 rev 1.
56894 + LIODN base for this port, to be
56895 + used together with LIODN offset. */
56896 +} _PackedType t_FmIpcPortInInitParams;
56897 +
56898 +
56899 +/**************************************************************************//**
56900 + @Description Structure for IPC communication between port and FM
56901 + regarding tasks and open DMA resources management.
56902 +*//***************************************************************************/
56903 +typedef _Packed struct t_FmIpcPortRsrcParams {
56904 + uint8_t hardwarePortId; /**< IN. port Id */
56905 + uint32_t val; /**< IN. Port's requested resource */
56906 + uint32_t extra; /**< IN. Port's requested resource */
56907 + uint8_t boolInitialConfig;
56908 +} _PackedType t_FmIpcPortRsrcParams;
56909 +
56910 +
56911 +/**************************************************************************//**
56912 + @Description Structure for IPC communication between port and FM
56913 + regarding tasks and open DMA resources management.
56914 +*//***************************************************************************/
56915 +typedef _Packed struct t_FmIpcPortFifoParams {
56916 + t_FmIpcPortRsrcParams rsrcParams;
56917 + uint32_t enumPortType;
56918 + uint8_t boolIndependentMode;
56919 + uint8_t deqPipelineDepth;
56920 + uint8_t numOfPools;
56921 + uint16_t secondLargestBufSize;
56922 + uint16_t largestBufSize;
56923 + uint8_t boolInitialConfig;
56924 +} _PackedType t_FmIpcPortFifoParams;
56925 +
56926 +/**************************************************************************//**
56927 + @Description Structure for port-FM communication during FM_PORT_Free.
56928 +*//***************************************************************************/
56929 +typedef _Packed struct t_FmIpcPortFreeParams {
56930 + uint8_t hardwarePortId; /**< IN. port Id */
56931 + uint32_t enumPortType; /**< IN. Port type */
56932 + uint8_t deqPipelineDepth; /**< IN. Port's requested resource */
56933 +} _PackedType t_FmIpcPortFreeParams;
56934 +
56935 +/**************************************************************************//**
56936 + @Description Structure for defining DMA status
56937 +*//***************************************************************************/
56938 +typedef _Packed struct t_FmIpcDmaStatus {
56939 + uint8_t boolCmqNotEmpty; /**< Command queue is not empty */
56940 + uint8_t boolBusError; /**< Bus error occurred */
56941 + uint8_t boolReadBufEccError; /**< Double ECC error on buffer Read */
56942 + uint8_t boolWriteBufEccSysError; /**< Double ECC error on buffer write from system side */
56943 + uint8_t boolWriteBufEccFmError; /**< Double ECC error on buffer write from FM side */
56944 + uint8_t boolSinglePortEccError; /**< Single port ECC error from FM side */
56945 +} _PackedType t_FmIpcDmaStatus;
56946 +
56947 +typedef _Packed struct t_FmIpcRegisterIntr
56948 +{
56949 + uint8_t guestId; /* IN */
56950 + uint32_t event; /* IN */
56951 +} _PackedType t_FmIpcRegisterIntr;
56952 +
56953 +typedef _Packed struct t_FmIpcIsr
56954 +{
56955 + uint8_t boolErr; /* IN */
56956 + uint32_t pendingReg; /* IN */
56957 +} _PackedType t_FmIpcIsr;
56958 +
56959 +/**************************************************************************//**
56960 + @Description structure for returning FM parameters
56961 +*//***************************************************************************/
56962 +typedef _Packed struct t_FmIpcParams {
56963 + uint16_t fmClkFreq; /**< OUT: FM Clock frequency */
56964 + uint16_t fmMacClkFreq; /**< OUT: FM MAC clock frequence */
56965 + uint8_t majorRev; /**< OUT: FM Major revision */
56966 + uint8_t minorRev; /**< OUT: FM Minor revision */
56967 +} _PackedType t_FmIpcParams;
56968 +
56969 +
56970 +/**************************************************************************//**
56971 + @Description structure for returning Fman Ctrl Code revision information
56972 +*//***************************************************************************/
56973 +typedef _Packed struct t_FmIpcFmanCtrlCodeRevisionInfo {
56974 + uint16_t packageRev; /**< OUT: Package revision */
56975 + uint8_t majorRev; /**< OUT: Major revision */
56976 + uint8_t minorRev; /**< OUT: Minor revision */
56977 +} _PackedType t_FmIpcFmanCtrlCodeRevisionInfo;
56978 +
56979 +/**************************************************************************//**
56980 + @Description Structure for defining Fm number of Fman controlers
56981 +*//***************************************************************************/
56982 +typedef _Packed struct t_FmIpcPortNumOfFmanCtrls {
56983 + uint8_t hardwarePortId; /**< IN. port Id */
56984 + uint8_t numOfFmanCtrls; /**< IN. Port type */
56985 + t_FmFmanCtrl orFmanCtrl; /**< IN. fman controller for order restoration*/
56986 +} t_FmIpcPortNumOfFmanCtrls;
56987 +
56988 +/**************************************************************************//**
56989 + @Description structure for setting Fman contriller events
56990 +*//***************************************************************************/
56991 +typedef _Packed struct t_FmIpcFmanEvents {
56992 + uint8_t eventRegId; /**< IN: Fman controller event register id */
56993 + uint32_t enableEvents; /**< IN/OUT: required enabled events mask */
56994 +} _PackedType t_FmIpcFmanEvents;
56995 +
56996 +typedef _Packed struct t_FmIpcResourceAllocParams {
56997 + uint8_t guestId;
56998 + uint16_t base;
56999 + uint16_t num;
57000 +}_PackedType t_FmIpcResourceAllocParams;
57001 +
57002 +typedef _Packed struct t_FmIpcVspSetPortWindow {
57003 + uint8_t hardwarePortId;
57004 + uint8_t baseStorageProfile;
57005 + uint8_t log2NumOfProfiles;
57006 +}_PackedType t_FmIpcVspSetPortWindow;
57007 +
57008 +typedef _Packed struct t_FmIpcSetCongestionGroupPfcPriority {
57009 + uint32_t congestionGroupId;
57010 + uint8_t priorityBitMap;
57011 +}_PackedType t_FmIpcSetCongestionGroupPfcPriority;
57012 +
57013 +#define FM_IPC_MAX_REPLY_BODY_SIZE 20
57014 +#define FM_IPC_MAX_REPLY_SIZE (FM_IPC_MAX_REPLY_BODY_SIZE + sizeof(uint32_t))
57015 +#define FM_IPC_MAX_MSG_SIZE 30
57016 +
57017 +typedef _Packed struct t_FmIpcMsg
57018 +{
57019 + uint32_t msgId;
57020 + uint8_t msgBody[FM_IPC_MAX_MSG_SIZE];
57021 +} _PackedType t_FmIpcMsg;
57022 +
57023 +typedef _Packed struct t_FmIpcReply
57024 +{
57025 + uint32_t error;
57026 + uint8_t replyBody[FM_IPC_MAX_REPLY_BODY_SIZE];
57027 +} _PackedType t_FmIpcReply;
57028 +
57029 +#if defined(__MWERKS__) && !defined(__GNUC__)
57030 +#pragma pack(pop)
57031 +#endif /* defined(__MWERKS__) && ... */
57032 +
57033 +
57034 +/***************************************************************************/
57035 +/************************ FRONT-END-TO-BACK-END*****************************/
57036 +/***************************************************************************/
57037 +
57038 +/**************************************************************************//**
57039 + @Function FM_GET_TIMESTAMP_SCALE
57040 +
57041 + @Description Used by FM front-end.
57042 +
57043 + @Param[out] uint32_t Pointer
57044 +*//***************************************************************************/
57045 +#define FM_GET_TIMESTAMP_SCALE 1
57046 +
57047 +/**************************************************************************//**
57048 + @Function FM_GET_COUNTER
57049 +
57050 + @Description Used by FM front-end.
57051 +
57052 + @Param[in/out] t_FmIpcGetCounter Pointer
57053 +*//***************************************************************************/
57054 +#define FM_GET_COUNTER 2
57055 +
57056 +/**************************************************************************//**
57057 + @Function FM_GET_SET_PORT_PARAMS
57058 +
57059 + @Description Used by FM front-end for the PORT module in order to set and get
57060 + parameters in/from master FM module on FM PORT initialization time.
57061 +
57062 + @Param[in/out] t_FmIcPortInitParams Pointer
57063 +*//***************************************************************************/
57064 +#define FM_GET_SET_PORT_PARAMS 4
57065 +
57066 +/**************************************************************************//**
57067 + @Function FM_FREE_PORT
57068 +
57069 + @Description Used by FM front-end for the PORT module when a port is freed
57070 + to free all FM PORT resources.
57071 +
57072 + @Param[in] uint8_t Pointer
57073 +*//***************************************************************************/
57074 +#define FM_FREE_PORT 5
57075 +
57076 +/**************************************************************************//**
57077 + @Function FM_RESET_MAC
57078 +
57079 + @Description Used by front-end for the MAC module to reset the MAC registers
57080 +
57081 + @Param[in] t_FmIpcMacParams Pointer .
57082 +*//***************************************************************************/
57083 +#define FM_RESET_MAC 6
57084 +
57085 +/**************************************************************************//**
57086 + @Function FM_RESUME_STALLED_PORT
57087 +
57088 + @Description Used by FM front-end for the PORT module in order to
57089 + release a stalled FM Port.
57090 +
57091 + @Param[in] uint8_t Pointer
57092 +*//***************************************************************************/
57093 +#define FM_RESUME_STALLED_PORT 7
57094 +
57095 +/**************************************************************************//**
57096 + @Function FM_IS_PORT_STALLED
57097 +
57098 + @Description Used by FM front-end for the PORT module in order to check whether
57099 + an FM port is stalled.
57100 +
57101 + @Param[in/out] t_FmIcPortIsStalled Pointer
57102 +*//***************************************************************************/
57103 +#define FM_IS_PORT_STALLED 8
57104 +
57105 +/**************************************************************************//**
57106 + @Function FM_GET_PARAMS
57107 +
57108 + @Description Used by FM front-end for the PORT module in order to dump
57109 + return FM parameters.
57110 +
57111 + @Param[in] uint8_t Pointer
57112 +*//***************************************************************************/
57113 +#define FM_GET_PARAMS 10
57114 +
57115 +/**************************************************************************//**
57116 + @Function FM_REGISTER_INTR
57117 +
57118 + @Description Used by FM front-end to register an interrupt handler to
57119 + be called upon interrupt for guest.
57120 +
57121 + @Param[out] t_FmIpcRegisterIntr Pointer
57122 +*//***************************************************************************/
57123 +#define FM_REGISTER_INTR 11
57124 +
57125 +/**************************************************************************//**
57126 + @Function FM_DMA_STAT
57127 +
57128 + @Description Used by FM front-end to read the FM DMA status.
57129 +
57130 + @Param[out] t_FmIpcDmaStatus Pointer
57131 +*//***************************************************************************/
57132 +#define FM_DMA_STAT 13
57133 +
57134 +/**************************************************************************//**
57135 + @Function FM_ALLOC_FMAN_CTRL_EVENT_REG
57136 +
57137 + @Description Used by FM front-end to allocate event register.
57138 +
57139 + @Param[out] Event register id Pointer
57140 +*//***************************************************************************/
57141 +#define FM_ALLOC_FMAN_CTRL_EVENT_REG 14
57142 +
57143 +/**************************************************************************//**
57144 + @Function FM_FREE_FMAN_CTRL_EVENT_REG
57145 +
57146 + @Description Used by FM front-end to free locate event register.
57147 +
57148 + @Param[in] uint8_t Pointer - Event register id
57149 +*//***************************************************************************/
57150 +#define FM_FREE_FMAN_CTRL_EVENT_REG 15
57151 +
57152 +/**************************************************************************//**
57153 + @Function FM_SET_FMAN_CTRL_EVENTS_ENABLE
57154 +
57155 + @Description Used by FM front-end to enable events in the FPM
57156 + Fman controller event register.
57157 +
57158 + @Param[in] t_FmIpcFmanEvents Pointer
57159 +*//***************************************************************************/
57160 +#define FM_SET_FMAN_CTRL_EVENTS_ENABLE 16
57161 +
57162 +/**************************************************************************//**
57163 + @Function FM_SET_FMAN_CTRL_EVENTS_ENABLE
57164 +
57165 + @Description Used by FM front-end to enable events in the FPM
57166 + Fman controller event register.
57167 +
57168 + @Param[in/out] t_FmIpcFmanEvents Pointer
57169 +*//***************************************************************************/
57170 +#define FM_GET_FMAN_CTRL_EVENTS_ENABLE 17
57171 +
57172 +/**************************************************************************//**
57173 + @Function FM_SET_MAC_MAX_FRAME
57174 +
57175 + @Description Used by FM front-end to set MAC's MTU/RTU's in
57176 + back-end.
57177 +
57178 + @Param[in/out] t_FmIpcMacMaxFrameParams Pointer
57179 +*//***************************************************************************/
57180 +#define FM_SET_MAC_MAX_FRAME 18
57181 +
57182 +/**************************************************************************//**
57183 + @Function FM_GET_PHYS_MURAM_BASE
57184 +
57185 + @Description Used by FM front-end in order to get MURAM base address
57186 +
57187 + @Param[in/out] t_FmIpcPhysAddr Pointer
57188 +*//***************************************************************************/
57189 +#define FM_GET_PHYS_MURAM_BASE 19
57190 +
57191 +/**************************************************************************//**
57192 + @Function FM_MASTER_IS_ALIVE
57193 +
57194 + @Description Used by FM front-end in order to verify Master is up
57195 +
57196 + @Param[in/out] bool
57197 +*//***************************************************************************/
57198 +#define FM_MASTER_IS_ALIVE 20
57199 +
57200 +#define FM_ENABLE_RAM_ECC 21
57201 +#define FM_DISABLE_RAM_ECC 22
57202 +#define FM_SET_NUM_OF_FMAN_CTRL 23
57203 +#define FM_SET_SIZE_OF_FIFO 24
57204 +#define FM_SET_NUM_OF_TASKS 25
57205 +#define FM_SET_NUM_OF_OPEN_DMAS 26
57206 +#define FM_VSP_ALLOC 27
57207 +#define FM_VSP_FREE 28
57208 +#define FM_VSP_SET_PORT_WINDOW 29
57209 +#define FM_GET_FMAN_CTRL_CODE_REV 30
57210 +#define FM_SET_CONG_GRP_PFC_PRIO 31
57211 +#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
57212 +#define FM_10G_TX_ECC_WA 100
57213 +#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
57214 +
57215 +/***************************************************************************/
57216 +/************************ BACK-END-TO-FRONT-END*****************************/
57217 +/***************************************************************************/
57218 +
57219 +/**************************************************************************//**
57220 + @Function FM_GUEST_ISR
57221 +
57222 + @Description Used by FM back-end to report an interrupt to the front-end.
57223 +
57224 + @Param[out] t_FmIpcIsr Pointer
57225 +*//***************************************************************************/
57226 +#define FM_GUEST_ISR 1
57227 +
57228 +
57229 +
57230 +/** @} */ /* end of FM_IPC_grp group */
57231 +/** @} */ /* end of FM_grp group */
57232 +
57233 +
57234 +#endif /* __FM_IPC_H */
57235 --- /dev/null
57236 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm_muram.c
57237 @@ -0,0 +1,174 @@
57238 +/*
57239 + * Copyright 2008-2012 Freescale Semiconductor Inc.
57240 + *
57241 + * Redistribution and use in source and binary forms, with or without
57242 + * modification, are permitted provided that the following conditions are met:
57243 + * * Redistributions of source code must retain the above copyright
57244 + * notice, this list of conditions and the following disclaimer.
57245 + * * Redistributions in binary form must reproduce the above copyright
57246 + * notice, this list of conditions and the following disclaimer in the
57247 + * documentation and/or other materials provided with the distribution.
57248 + * * Neither the name of Freescale Semiconductor nor the
57249 + * names of its contributors may be used to endorse or promote products
57250 + * derived from this software without specific prior written permission.
57251 + *
57252 + *
57253 + * ALTERNATIVELY, this software may be distributed under the terms of the
57254 + * GNU General Public License ("GPL") as published by the Free Software
57255 + * Foundation, either version 2 of that License or (at your option) any
57256 + * later version.
57257 + *
57258 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
57259 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
57260 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
57261 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
57262 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
57263 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
57264 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
57265 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57266 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
57267 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57268 + */
57269 +
57270 +
57271 +/******************************************************************************
57272 + @File FM_muram.c
57273 +
57274 + @Description FM MURAM ...
57275 +*//***************************************************************************/
57276 +#include "error_ext.h"
57277 +#include "std_ext.h"
57278 +#include "mm_ext.h"
57279 +#include "string_ext.h"
57280 +#include "sprint_ext.h"
57281 +#include "fm_muram_ext.h"
57282 +#include "fm_common.h"
57283 +
57284 +#define __ERR_MODULE__ MODULE_FM_MURAM
57285 +
57286 +
57287 +typedef struct
57288 +{
57289 + t_Handle h_Mem;
57290 + uintptr_t baseAddr;
57291 + uint32_t size;
57292 +} t_FmMuram;
57293 +
57294 +
57295 +void FmMuramClear(t_Handle h_FmMuram)
57296 +{
57297 + t_FmMuram *p_FmMuram = ( t_FmMuram *)h_FmMuram;
57298 +
57299 + SANITY_CHECK_RETURN(h_FmMuram, E_INVALID_HANDLE);
57300 + IOMemSet32(UINT_TO_PTR(p_FmMuram->baseAddr), 0, p_FmMuram->size);
57301 +}
57302 +
57303 +
57304 +t_Handle FM_MURAM_ConfigAndInit(uintptr_t baseAddress, uint32_t size)
57305 +{
57306 + t_Handle h_Mem;
57307 + t_FmMuram *p_FmMuram;
57308 +
57309 + if (!baseAddress)
57310 + {
57311 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("baseAddress 0 is not supported"));
57312 + return NULL;
57313 + }
57314 +
57315 + if (baseAddress%4)
57316 + {
57317 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("baseAddress not 4 bytes aligned!"));
57318 + return NULL;
57319 + }
57320 +
57321 + /* Allocate FM MURAM structure */
57322 + p_FmMuram = (t_FmMuram *) XX_Malloc(sizeof(t_FmMuram));
57323 + if (!p_FmMuram)
57324 + {
57325 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM MURAM driver structure"));
57326 + return NULL;
57327 + }
57328 + memset(p_FmMuram, 0, sizeof(t_FmMuram));
57329 +
57330 +
57331 + if ((MM_Init(&h_Mem, baseAddress, size) != E_OK) || (!h_Mem))
57332 + {
57333 + XX_Free(p_FmMuram);
57334 + REPORT_ERROR(MAJOR, E_INVALID_HANDLE, ("FM-MURAM partition!!!"));
57335 + return NULL;
57336 + }
57337 +
57338 + /* Initialize FM MURAM parameters which will be kept by the driver */
57339 + p_FmMuram->baseAddr = baseAddress;
57340 + p_FmMuram->size = size;
57341 + p_FmMuram->h_Mem = h_Mem;
57342 +
57343 + return p_FmMuram;
57344 +}
57345 +
57346 +t_Error FM_MURAM_Free(t_Handle h_FmMuram)
57347 +{
57348 + t_FmMuram *p_FmMuram = ( t_FmMuram *)h_FmMuram;
57349 +
57350 + if (p_FmMuram->h_Mem)
57351 + MM_Free(p_FmMuram->h_Mem);
57352 +
57353 + XX_Free(h_FmMuram);
57354 +
57355 + return E_OK;
57356 +}
57357 +
57358 +void * FM_MURAM_AllocMem(t_Handle h_FmMuram, uint32_t size, uint32_t align)
57359 +{
57360 + t_FmMuram *p_FmMuram = ( t_FmMuram *)h_FmMuram;
57361 + uintptr_t addr;
57362 +
57363 + SANITY_CHECK_RETURN_VALUE(h_FmMuram, E_INVALID_HANDLE, NULL);
57364 + SANITY_CHECK_RETURN_VALUE(p_FmMuram->h_Mem, E_INVALID_HANDLE, NULL);
57365 +
57366 + addr = (uintptr_t)MM_Get(p_FmMuram->h_Mem, size, align ,"FM MURAM");
57367 +
57368 + if (addr == ILLEGAL_BASE)
57369 + return NULL;
57370 +
57371 + return UINT_TO_PTR(addr);
57372 +}
57373 +
57374 +void * FM_MURAM_AllocMemForce(t_Handle h_FmMuram, uint64_t base, uint32_t size)
57375 +{
57376 + t_FmMuram *p_FmMuram = ( t_FmMuram *)h_FmMuram;
57377 + uintptr_t addr;
57378 +
57379 + SANITY_CHECK_RETURN_VALUE(h_FmMuram, E_INVALID_HANDLE, NULL);
57380 + SANITY_CHECK_RETURN_VALUE(p_FmMuram->h_Mem, E_INVALID_HANDLE, NULL);
57381 +
57382 + addr = (uintptr_t)MM_GetForce(p_FmMuram->h_Mem, base, size, "FM MURAM");
57383 +
57384 + if (addr == ILLEGAL_BASE)
57385 + return NULL;
57386 +
57387 + return UINT_TO_PTR(addr);
57388 +}
57389 +
57390 +t_Error FM_MURAM_FreeMem(t_Handle h_FmMuram, void *ptr)
57391 +{
57392 + t_FmMuram *p_FmMuram = ( t_FmMuram *)h_FmMuram;
57393 +
57394 + SANITY_CHECK_RETURN_ERROR(h_FmMuram, E_INVALID_HANDLE);
57395 + SANITY_CHECK_RETURN_ERROR(p_FmMuram->h_Mem, E_INVALID_HANDLE);
57396 +
57397 + if (MM_Put(p_FmMuram->h_Mem, PTR_TO_UINT(ptr)) == 0)
57398 + RETURN_ERROR(MINOR, E_INVALID_ADDRESS, ("memory pointer!!!"));
57399 +
57400 + return E_OK;
57401 +}
57402 +
57403 +uint64_t FM_MURAM_GetFreeMemSize(t_Handle h_FmMuram)
57404 +{
57405 + t_FmMuram *p_FmMuram = ( t_FmMuram *)h_FmMuram;
57406 +
57407 + SANITY_CHECK_RETURN_VALUE(h_FmMuram, E_INVALID_HANDLE, 0);
57408 + SANITY_CHECK_RETURN_VALUE(p_FmMuram->h_Mem, E_INVALID_HANDLE, 0);
57409 +
57410 + return MM_GetFreeMemSize(p_FmMuram->h_Mem);
57411 +}
57412 --- /dev/null
57413 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fman.c
57414 @@ -0,0 +1,1399 @@
57415 +/*
57416 + * Copyright 2008-2012 Freescale Semiconductor Inc.
57417 + *
57418 + * Redistribution and use in source and binary forms, with or without
57419 + * modification, are permitted provided that the following conditions are met:
57420 + * * Redistributions of source code must retain the above copyright
57421 + * notice, this list of conditions and the following disclaimer.
57422 + * * Redistributions in binary form must reproduce the above copyright
57423 + * notice, this list of conditions and the following disclaimer in the
57424 + * documentation and/or other materials provided with the distribution.
57425 + * * Neither the name of Freescale Semiconductor nor the
57426 + * names of its contributors may be used to endorse or promote products
57427 + * derived from this software without specific prior written permission.
57428 + *
57429 + *
57430 + * ALTERNATIVELY, this software may be distributed under the terms of the
57431 + * GNU General Public License ("GPL") as published by the Free Software
57432 + * Foundation, either version 2 of that License or (at your option) any
57433 + * later version.
57434 + *
57435 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
57436 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
57437 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
57438 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
57439 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
57440 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
57441 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
57442 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57443 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
57444 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57445 + */
57446 +
57447 +
57448 +
57449 +#include "fsl_fman.h"
57450 +#include "dpaa_integration_ext.h"
57451 +
57452 +uint32_t fman_get_bmi_err_event(struct fman_bmi_regs *bmi_rg)
57453 +{
57454 + uint32_t event, mask, force;
57455 +
57456 + event = ioread32be(&bmi_rg->fmbm_ievr);
57457 + mask = ioread32be(&bmi_rg->fmbm_ier);
57458 + event &= mask;
57459 + /* clear the forced events */
57460 + force = ioread32be(&bmi_rg->fmbm_ifr);
57461 + if (force & event)
57462 + iowrite32be(force & ~event, &bmi_rg->fmbm_ifr);
57463 + /* clear the acknowledged events */
57464 + iowrite32be(event, &bmi_rg->fmbm_ievr);
57465 + return event;
57466 +}
57467 +
57468 +uint32_t fman_get_qmi_err_event(struct fman_qmi_regs *qmi_rg)
57469 +{
57470 + uint32_t event, mask, force;
57471 +
57472 + event = ioread32be(&qmi_rg->fmqm_eie);
57473 + mask = ioread32be(&qmi_rg->fmqm_eien);
57474 + event &= mask;
57475 +
57476 + /* clear the forced events */
57477 + force = ioread32be(&qmi_rg->fmqm_eif);
57478 + if (force & event)
57479 + iowrite32be(force & ~event, &qmi_rg->fmqm_eif);
57480 + /* clear the acknowledged events */
57481 + iowrite32be(event, &qmi_rg->fmqm_eie);
57482 + return event;
57483 +}
57484 +
57485 +uint32_t fman_get_dma_com_id(struct fman_dma_regs *dma_rg)
57486 +{
57487 + return ioread32be(&dma_rg->fmdmtcid);
57488 +}
57489 +
57490 +uint64_t fman_get_dma_addr(struct fman_dma_regs *dma_rg)
57491 +{
57492 + uint64_t addr;
57493 +
57494 + addr = (uint64_t)ioread32be(&dma_rg->fmdmtal);
57495 + addr |= ((uint64_t)(ioread32be(&dma_rg->fmdmtah)) << 32);
57496 +
57497 + return addr;
57498 +}
57499 +
57500 +uint32_t fman_get_dma_err_event(struct fman_dma_regs *dma_rg)
57501 +{
57502 + uint32_t status, mask;
57503 +
57504 + status = ioread32be(&dma_rg->fmdmsr);
57505 + mask = ioread32be(&dma_rg->fmdmmr);
57506 +
57507 + /* clear DMA_STATUS_BUS_ERR if mask has no DMA_MODE_BER */
57508 + if ((mask & DMA_MODE_BER) != DMA_MODE_BER)
57509 + status &= ~DMA_STATUS_BUS_ERR;
57510 +
57511 + /* clear relevant bits if mask has no DMA_MODE_ECC */
57512 + if ((mask & DMA_MODE_ECC) != DMA_MODE_ECC)
57513 + status &= ~(DMA_STATUS_FM_SPDAT_ECC |
57514 + DMA_STATUS_READ_ECC |
57515 + DMA_STATUS_SYSTEM_WRITE_ECC |
57516 + DMA_STATUS_FM_WRITE_ECC);
57517 +
57518 + /* clear set events */
57519 + iowrite32be(status, &dma_rg->fmdmsr);
57520 +
57521 + return status;
57522 +}
57523 +
57524 +uint32_t fman_get_fpm_err_event(struct fman_fpm_regs *fpm_rg)
57525 +{
57526 + uint32_t event;
57527 +
57528 + event = ioread32be(&fpm_rg->fmfp_ee);
57529 + /* clear the all occurred events */
57530 + iowrite32be(event, &fpm_rg->fmfp_ee);
57531 + return event;
57532 +}
57533 +
57534 +uint32_t fman_get_muram_err_event(struct fman_fpm_regs *fpm_rg)
57535 +{
57536 + uint32_t event, mask;
57537 +
57538 + event = ioread32be(&fpm_rg->fm_rcr);
57539 + mask = ioread32be(&fpm_rg->fm_rie);
57540 +
57541 + /* clear MURAM event bit (do not clear IRAM event) */
57542 + iowrite32be(event & ~FPM_RAM_IRAM_ECC, &fpm_rg->fm_rcr);
57543 +
57544 + if ((mask & FPM_MURAM_ECC_ERR_EX_EN))
57545 + return event;
57546 + else
57547 + return 0;
57548 +}
57549 +
57550 +uint32_t fman_get_iram_err_event(struct fman_fpm_regs *fpm_rg)
57551 +{
57552 + uint32_t event, mask;
57553 +
57554 + event = ioread32be(&fpm_rg->fm_rcr) ;
57555 + mask = ioread32be(&fpm_rg->fm_rie);
57556 + /* clear IRAM event bit (do not clear MURAM event) */
57557 + iowrite32be(event & ~FPM_RAM_MURAM_ECC,
57558 + &fpm_rg->fm_rcr);
57559 +
57560 + if ((mask & FPM_IRAM_ECC_ERR_EX_EN))
57561 + return event;
57562 + else
57563 + return 0;
57564 +}
57565 +
57566 +uint32_t fman_get_qmi_event(struct fman_qmi_regs *qmi_rg)
57567 +{
57568 + uint32_t event, mask, force;
57569 +
57570 + event = ioread32be(&qmi_rg->fmqm_ie);
57571 + mask = ioread32be(&qmi_rg->fmqm_ien);
57572 + event &= mask;
57573 + /* clear the forced events */
57574 + force = ioread32be(&qmi_rg->fmqm_if);
57575 + if (force & event)
57576 + iowrite32be(force & ~event, &qmi_rg->fmqm_if);
57577 + /* clear the acknowledged events */
57578 + iowrite32be(event, &qmi_rg->fmqm_ie);
57579 + return event;
57580 +}
57581 +
57582 +void fman_enable_time_stamp(struct fman_fpm_regs *fpm_rg,
57583 + uint8_t count1ubit,
57584 + uint16_t fm_clk_freq)
57585 +{
57586 + uint32_t tmp;
57587 + uint64_t frac;
57588 + uint32_t intgr;
57589 + uint32_t ts_freq = (uint32_t)(1 << count1ubit); /* in Mhz */
57590 +
57591 + /* configure timestamp so that bit 8 will count 1 microsecond
57592 + * Find effective count rate at TIMESTAMP least significant bits:
57593 + * Effective_Count_Rate = 1MHz x 2^8 = 256MHz
57594 + * Find frequency ratio between effective count rate and the clock:
57595 + * Effective_Count_Rate / CLK e.g. for 600 MHz clock:
57596 + * 256/600 = 0.4266666... */
57597 +
57598 + intgr = ts_freq / fm_clk_freq;
57599 + /* we multiply by 2^16 to keep the fraction of the division
57600 + * we do not div back, since we write this value as a fraction
57601 + * see spec */
57602 +
57603 + frac = (((uint64_t)ts_freq << 16) - ((uint64_t)intgr << 16) * fm_clk_freq)
57604 + / fm_clk_freq;
57605 + /* we check remainder of the division in order to round up if not int */
57606 + if (((ts_freq << 16) - (intgr << 16)*fm_clk_freq) % fm_clk_freq)
57607 + frac++;
57608 +
57609 + tmp = (intgr << FPM_TS_INT_SHIFT) | (uint16_t)frac;
57610 + iowrite32be(tmp, &fpm_rg->fmfp_tsc2);
57611 +
57612 + /* enable timestamp with original clock */
57613 + iowrite32be(FPM_TS_CTL_EN, &fpm_rg->fmfp_tsc1);
57614 +}
57615 +
57616 +uint32_t fman_get_fpm_error_interrupts(struct fman_fpm_regs *fpm_rg)
57617 +{
57618 + return ioread32be(&fpm_rg->fm_epi);
57619 +}
57620 +
57621 +
57622 +int fman_set_erratum_10gmac_a004_wa(struct fman_fpm_regs *fpm_rg)
57623 +{
57624 + int timeout = 100;
57625 +
57626 + iowrite32be(0x40000000, &fpm_rg->fmfp_extc);
57627 +
57628 + while ((ioread32be(&fpm_rg->fmfp_extc) & 0x40000000) && --timeout)
57629 + udelay(10);
57630 +
57631 + if (!timeout)
57632 + return -EBUSY;
57633 + return 0;
57634 +}
57635 +
57636 +void fman_set_ctrl_intr(struct fman_fpm_regs *fpm_rg,
57637 + uint8_t event_reg_id,
57638 + uint32_t enable_events)
57639 +{
57640 + iowrite32be(enable_events, &fpm_rg->fmfp_cee[event_reg_id]);
57641 +}
57642 +
57643 +uint32_t fman_get_ctrl_intr(struct fman_fpm_regs *fpm_rg, uint8_t event_reg_id)
57644 +{
57645 + return ioread32be(&fpm_rg->fmfp_cee[event_reg_id]);
57646 +}
57647 +
57648 +void fman_set_num_of_riscs_per_port(struct fman_fpm_regs *fpm_rg,
57649 + uint8_t port_id,
57650 + uint8_t num_fman_ctrls,
57651 + uint32_t or_fman_ctrl)
57652 +{
57653 + uint32_t tmp = 0;
57654 +
57655 + tmp = (uint32_t)(port_id << FPM_PORT_FM_CTL_PORTID_SHIFT);
57656 + /*TODO - maybe to put CTL# according to another criteria*/
57657 + if (num_fman_ctrls == 2)
57658 + tmp = FPM_PRT_FM_CTL2 | FPM_PRT_FM_CTL1;
57659 + /* order restoration */
57660 + tmp |= (or_fman_ctrl << FPM_PRC_ORA_FM_CTL_SEL_SHIFT) | or_fman_ctrl;
57661 +
57662 + iowrite32be(tmp, &fpm_rg->fmfp_prc);
57663 +}
57664 +
57665 +void fman_set_order_restoration_per_port(struct fman_fpm_regs *fpm_rg,
57666 + uint8_t port_id,
57667 + bool independent_mode,
57668 + bool is_rx_port)
57669 +{
57670 + uint32_t tmp = 0;
57671 +
57672 + tmp = (uint32_t)(port_id << FPM_PORT_FM_CTL_PORTID_SHIFT);
57673 + if (independent_mode) {
57674 + if (is_rx_port)
57675 + tmp |= (FPM_PRT_FM_CTL1 <<
57676 + FPM_PRC_ORA_FM_CTL_SEL_SHIFT) | FPM_PRT_FM_CTL1;
57677 + else
57678 + tmp |= (FPM_PRT_FM_CTL2 <<
57679 + FPM_PRC_ORA_FM_CTL_SEL_SHIFT) | FPM_PRT_FM_CTL2;
57680 + } else {
57681 + tmp |= (FPM_PRT_FM_CTL2|FPM_PRT_FM_CTL1);
57682 +
57683 + /* order restoration */
57684 + if (port_id % 2)
57685 + tmp |= (FPM_PRT_FM_CTL1 <<
57686 + FPM_PRC_ORA_FM_CTL_SEL_SHIFT);
57687 + else
57688 + tmp |= (FPM_PRT_FM_CTL2 <<
57689 + FPM_PRC_ORA_FM_CTL_SEL_SHIFT);
57690 + }
57691 + iowrite32be(tmp, &fpm_rg->fmfp_prc);
57692 +}
57693 +
57694 +uint8_t fman_get_qmi_deq_th(struct fman_qmi_regs *qmi_rg)
57695 +{
57696 + return (uint8_t)ioread32be(&qmi_rg->fmqm_gc);
57697 +}
57698 +
57699 +uint8_t fman_get_qmi_enq_th(struct fman_qmi_regs *qmi_rg)
57700 +{
57701 + return (uint8_t)(ioread32be(&qmi_rg->fmqm_gc) >> 8);
57702 +}
57703 +
57704 +void fman_set_qmi_enq_th(struct fman_qmi_regs *qmi_rg, uint8_t val)
57705 +{
57706 + uint32_t tmp_reg;
57707 +
57708 + tmp_reg = ioread32be(&qmi_rg->fmqm_gc);
57709 + tmp_reg &= ~QMI_CFG_ENQ_MASK;
57710 + tmp_reg |= ((uint32_t)val << 8);
57711 + iowrite32be(tmp_reg, &qmi_rg->fmqm_gc);
57712 +}
57713 +
57714 +void fman_set_qmi_deq_th(struct fman_qmi_regs *qmi_rg, uint8_t val)
57715 +{
57716 + uint32_t tmp_reg;
57717 +
57718 + tmp_reg = ioread32be(&qmi_rg->fmqm_gc);
57719 + tmp_reg &= ~QMI_CFG_DEQ_MASK;
57720 + tmp_reg |= (uint32_t)val;
57721 + iowrite32be(tmp_reg, &qmi_rg->fmqm_gc);
57722 +}
57723 +
57724 +void fman_qmi_disable_dispatch_limit(struct fman_fpm_regs *fpm_rg)
57725 +{
57726 + iowrite32be(0, &fpm_rg->fmfp_mxd);
57727 +}
57728 +
57729 +void fman_set_liodn_per_port(struct fman_rg *fman_rg, uint8_t port_id,
57730 + uint16_t liodn_base,
57731 + uint16_t liodn_ofst)
57732 +{
57733 + uint32_t tmp;
57734 +
57735 + if ((port_id > 63) || (port_id < 1))
57736 + return;
57737 +
57738 + /* set LIODN base for this port */
57739 + tmp = ioread32be(&fman_rg->dma_rg->fmdmplr[port_id / 2]);
57740 + if (port_id % 2) {
57741 + tmp &= ~FM_LIODN_BASE_MASK;
57742 + tmp |= (uint32_t)liodn_base;
57743 + } else {
57744 + tmp &= ~(FM_LIODN_BASE_MASK << DMA_LIODN_SHIFT);
57745 + tmp |= (uint32_t)liodn_base << DMA_LIODN_SHIFT;
57746 + }
57747 + iowrite32be(tmp, &fman_rg->dma_rg->fmdmplr[port_id / 2]);
57748 + iowrite32be((uint32_t)liodn_ofst,
57749 + &fman_rg->bmi_rg->fmbm_spliodn[port_id - 1]);
57750 +}
57751 +
57752 +bool fman_is_port_stalled(struct fman_fpm_regs *fpm_rg, uint8_t port_id)
57753 +{
57754 + return (bool)!!(ioread32be(&fpm_rg->fmfp_ps[port_id]) & FPM_PS_STALLED);
57755 +}
57756 +
57757 +void fman_resume_stalled_port(struct fman_fpm_regs *fpm_rg, uint8_t port_id)
57758 +{
57759 + uint32_t tmp;
57760 +
57761 + tmp = (uint32_t)((port_id << FPM_PORT_FM_CTL_PORTID_SHIFT) |
57762 + FPM_PRC_REALSE_STALLED);
57763 + iowrite32be(tmp, &fpm_rg->fmfp_prc);
57764 +}
57765 +
57766 +int fman_reset_mac(struct fman_fpm_regs *fpm_rg, uint8_t mac_id, bool is_10g)
57767 +{
57768 + uint32_t msk, timeout = 100;
57769 +
57770 + /* Get the relevant bit mask */
57771 + if (is_10g) {
57772 + switch (mac_id) {
57773 + case(0):
57774 + msk = FPM_RSTC_10G0_RESET;
57775 + break;
57776 + case(1):
57777 + msk = FPM_RSTC_10G1_RESET;
57778 + break;
57779 + default:
57780 + return -EINVAL;
57781 + }
57782 + } else {
57783 + switch (mac_id) {
57784 + case(0):
57785 + msk = FPM_RSTC_1G0_RESET;
57786 + break;
57787 + case(1):
57788 + msk = FPM_RSTC_1G1_RESET;
57789 + break;
57790 + case(2):
57791 + msk = FPM_RSTC_1G2_RESET;
57792 + break;
57793 + case(3):
57794 + msk = FPM_RSTC_1G3_RESET;
57795 + break;
57796 + case(4):
57797 + msk = FPM_RSTC_1G4_RESET;
57798 + break;
57799 + case (5):
57800 + msk = FPM_RSTC_1G5_RESET;
57801 + break;
57802 + case (6):
57803 + msk = FPM_RSTC_1G6_RESET;
57804 + break;
57805 + case (7):
57806 + msk = FPM_RSTC_1G7_RESET;
57807 + break;
57808 + default:
57809 + return -EINVAL;
57810 + }
57811 + }
57812 + /* reset */
57813 + iowrite32be(msk, &fpm_rg->fm_rstc);
57814 + while ((ioread32be(&fpm_rg->fm_rstc) & msk) && --timeout)
57815 + udelay(10);
57816 +
57817 + if (!timeout)
57818 + return -EBUSY;
57819 + return 0;
57820 +}
57821 +
57822 +uint16_t fman_get_size_of_fifo(struct fman_bmi_regs *bmi_rg, uint8_t port_id)
57823 +{
57824 + uint32_t tmp_reg;
57825 +
57826 + if ((port_id > 63) || (port_id < 1))
57827 + return 0;
57828 +
57829 + tmp_reg = ioread32be(&bmi_rg->fmbm_pfs[port_id - 1]);
57830 + return (uint16_t)((tmp_reg & BMI_FIFO_SIZE_MASK) + 1);
57831 +}
57832 +
57833 +uint32_t fman_get_total_fifo_size(struct fman_bmi_regs *bmi_rg)
57834 +{
57835 + uint32_t reg, res;
57836 +
57837 + reg = ioread32be(&bmi_rg->fmbm_cfg1);
57838 + res = (reg >> BMI_CFG1_FIFO_SIZE_SHIFT) & 0x3ff;
57839 + return res * FMAN_BMI_FIFO_UNITS;
57840 +}
57841 +
57842 +uint16_t fman_get_size_of_extra_fifo(struct fman_bmi_regs *bmi_rg,
57843 + uint8_t port_id)
57844 +{
57845 + uint32_t tmp_reg;
57846 +
57847 + if ((port_id > 63) || (port_id < 1))
57848 + return 0;
57849 +
57850 + tmp_reg = ioread32be(&bmi_rg->fmbm_pfs[port_id-1]);
57851 + return (uint16_t)((tmp_reg & BMI_EXTRA_FIFO_SIZE_MASK) >>
57852 + BMI_EXTRA_FIFO_SIZE_SHIFT);
57853 +}
57854 +
57855 +void fman_set_size_of_fifo(struct fman_bmi_regs *bmi_rg,
57856 + uint8_t port_id,
57857 + uint32_t sz_fifo,
57858 + uint32_t extra_sz_fifo)
57859 +{
57860 + uint32_t tmp;
57861 +
57862 + if ((port_id > 63) || (port_id < 1))
57863 + return;
57864 +
57865 + /* calculate reg */
57866 + tmp = (uint32_t)((sz_fifo / FMAN_BMI_FIFO_UNITS - 1) |
57867 + ((extra_sz_fifo / FMAN_BMI_FIFO_UNITS) <<
57868 + BMI_EXTRA_FIFO_SIZE_SHIFT));
57869 + iowrite32be(tmp, &bmi_rg->fmbm_pfs[port_id - 1]);
57870 +}
57871 +
57872 +uint8_t fman_get_num_of_tasks(struct fman_bmi_regs *bmi_rg, uint8_t port_id)
57873 +{
57874 + uint32_t tmp;
57875 +
57876 + if ((port_id > 63) || (port_id < 1))
57877 + return 0;
57878 +
57879 + tmp = ioread32be(&bmi_rg->fmbm_pp[port_id - 1]);
57880 + return (uint8_t)(((tmp & BMI_NUM_OF_TASKS_MASK) >>
57881 + BMI_NUM_OF_TASKS_SHIFT) + 1);
57882 +}
57883 +
57884 +uint8_t fman_get_num_extra_tasks(struct fman_bmi_regs *bmi_rg, uint8_t port_id)
57885 +{
57886 + uint32_t tmp;
57887 +
57888 + if ((port_id > 63) || (port_id < 1))
57889 + return 0;
57890 +
57891 + tmp = ioread32be(&bmi_rg->fmbm_pp[port_id - 1]);
57892 + return (uint8_t)((tmp & BMI_NUM_OF_EXTRA_TASKS_MASK) >>
57893 + BMI_EXTRA_NUM_OF_TASKS_SHIFT);
57894 +}
57895 +
57896 +void fman_set_num_of_tasks(struct fman_bmi_regs *bmi_rg,
57897 + uint8_t port_id,
57898 + uint8_t num_tasks,
57899 + uint8_t num_extra_tasks)
57900 +{
57901 + uint32_t tmp;
57902 +
57903 + if ((port_id > 63) || (port_id < 1))
57904 + return;
57905 +
57906 + /* calculate reg */
57907 + tmp = ioread32be(&bmi_rg->fmbm_pp[port_id - 1]) &
57908 + ~(BMI_NUM_OF_TASKS_MASK | BMI_NUM_OF_EXTRA_TASKS_MASK);
57909 + tmp |= (uint32_t)(((num_tasks - 1) << BMI_NUM_OF_TASKS_SHIFT) |
57910 + (num_extra_tasks << BMI_EXTRA_NUM_OF_TASKS_SHIFT));
57911 + iowrite32be(tmp, &bmi_rg->fmbm_pp[port_id - 1]);
57912 +}
57913 +
57914 +uint8_t fman_get_num_of_dmas(struct fman_bmi_regs *bmi_rg, uint8_t port_id)
57915 +{
57916 + uint32_t tmp;
57917 +
57918 + if ((port_id > 63) || (port_id < 1))
57919 + return 0;
57920 +
57921 + tmp = ioread32be(&bmi_rg->fmbm_pp[port_id - 1]);
57922 + return (uint8_t)(((tmp & BMI_NUM_OF_DMAS_MASK) >>
57923 + BMI_NUM_OF_DMAS_SHIFT) + 1);
57924 +}
57925 +
57926 +uint8_t fman_get_num_extra_dmas(struct fman_bmi_regs *bmi_rg, uint8_t port_id)
57927 +{
57928 + uint32_t tmp;
57929 +
57930 + if ((port_id > 63) || (port_id < 1))
57931 + return 0;
57932 +
57933 + tmp = ioread32be(&bmi_rg->fmbm_pp[port_id - 1]);
57934 + return (uint8_t)((tmp & BMI_NUM_OF_EXTRA_DMAS_MASK) >>
57935 + BMI_EXTRA_NUM_OF_DMAS_SHIFT);
57936 +}
57937 +
57938 +void fman_set_num_of_open_dmas(struct fman_bmi_regs *bmi_rg,
57939 + uint8_t port_id,
57940 + uint8_t num_open_dmas,
57941 + uint8_t num_extra_open_dmas,
57942 + uint8_t total_num_dmas)
57943 +{
57944 + uint32_t tmp = 0;
57945 +
57946 + if ((port_id > 63) || (port_id < 1))
57947 + return;
57948 +
57949 + /* calculate reg */
57950 + tmp = ioread32be(&bmi_rg->fmbm_pp[port_id - 1]) &
57951 + ~(BMI_NUM_OF_DMAS_MASK | BMI_NUM_OF_EXTRA_DMAS_MASK);
57952 + tmp |= (uint32_t)(((num_open_dmas-1) << BMI_NUM_OF_DMAS_SHIFT) |
57953 + (num_extra_open_dmas << BMI_EXTRA_NUM_OF_DMAS_SHIFT));
57954 + iowrite32be(tmp, &bmi_rg->fmbm_pp[port_id - 1]);
57955 +
57956 + /* update total num of DMA's with committed number of open DMAS,
57957 + * and max uncommitted pool. */
57958 + if (total_num_dmas)
57959 + {
57960 + tmp = ioread32be(&bmi_rg->fmbm_cfg2) & ~BMI_CFG2_DMAS_MASK;
57961 + tmp |= (uint32_t)(total_num_dmas - 1) << BMI_CFG2_DMAS_SHIFT;
57962 + iowrite32be(tmp, &bmi_rg->fmbm_cfg2);
57963 + }
57964 +}
57965 +
57966 +void fman_set_vsp_window(struct fman_bmi_regs *bmi_rg,
57967 + uint8_t port_id,
57968 + uint8_t base_storage_profile,
57969 + uint8_t log2_num_of_profiles)
57970 +{
57971 + uint32_t tmp = 0;
57972 + if ((port_id > 63) || (port_id < 1))
57973 + return;
57974 +
57975 + tmp = ioread32be(&bmi_rg->fmbm_spliodn[port_id-1]);
57976 + tmp |= (uint32_t)((uint32_t)base_storage_profile & 0x3f) << 16;
57977 + tmp |= (uint32_t)log2_num_of_profiles << 28;
57978 + iowrite32be(tmp, &bmi_rg->fmbm_spliodn[port_id-1]);
57979 +}
57980 +
57981 +void fman_set_congestion_group_pfc_priority(uint32_t *cpg_rg,
57982 + uint32_t congestion_group_id,
57983 + uint8_t priority_bit_map,
57984 + uint32_t reg_num)
57985 +{
57986 + uint32_t offset, tmp = 0;
57987 +
57988 + offset = (congestion_group_id%4)*8;
57989 +
57990 + tmp = ioread32be(&cpg_rg[reg_num]);
57991 + tmp &= ~(0xFF<<offset);
57992 + tmp |= (uint32_t)priority_bit_map << offset;
57993 +
57994 + iowrite32be(tmp,&cpg_rg[reg_num]);
57995 +}
57996 +
57997 +/*****************************************************************************/
57998 +/* API Init unit functions */
57999 +/*****************************************************************************/
58000 +void fman_defconfig(struct fman_cfg *cfg, bool is_master)
58001 +{
58002 + memset(cfg, 0, sizeof(struct fman_cfg));
58003 +
58004 + cfg->catastrophic_err = DEFAULT_CATASTROPHIC_ERR;
58005 + cfg->dma_err = DEFAULT_DMA_ERR;
58006 + cfg->halt_on_external_activ = DEFAULT_HALT_ON_EXTERNAL_ACTIVATION;
58007 + cfg->halt_on_unrecov_ecc_err = DEFAULT_HALT_ON_UNRECOVERABLE_ECC_ERROR;
58008 + cfg->en_iram_test_mode = FALSE;
58009 + cfg->en_muram_test_mode = FALSE;
58010 + cfg->external_ecc_rams_enable = DEFAULT_EXTERNAL_ECC_RAMS_ENABLE;
58011 +
58012 + if (!is_master)
58013 + return;
58014 +
58015 + cfg->dma_aid_override = DEFAULT_AID_OVERRIDE;
58016 + cfg->dma_aid_mode = DEFAULT_AID_MODE;
58017 + cfg->dma_comm_qtsh_clr_emer = DEFAULT_DMA_COMM_Q_LOW;
58018 + cfg->dma_comm_qtsh_asrt_emer = DEFAULT_DMA_COMM_Q_HIGH;
58019 + cfg->dma_cache_override = DEFAULT_CACHE_OVERRIDE;
58020 + cfg->dma_cam_num_of_entries = DEFAULT_DMA_CAM_NUM_OF_ENTRIES;
58021 + cfg->dma_dbg_cnt_mode = DEFAULT_DMA_DBG_CNT_MODE;
58022 + cfg->dma_en_emergency = DEFAULT_DMA_EN_EMERGENCY;
58023 + cfg->dma_sos_emergency = DEFAULT_DMA_SOS_EMERGENCY;
58024 + cfg->dma_watchdog = DEFAULT_DMA_WATCHDOG;
58025 + cfg->dma_en_emergency_smoother = DEFAULT_DMA_EN_EMERGENCY_SMOOTHER;
58026 + cfg->dma_emergency_switch_counter = DEFAULT_DMA_EMERGENCY_SWITCH_COUNTER;
58027 + cfg->disp_limit_tsh = DEFAULT_DISP_LIMIT;
58028 + cfg->prs_disp_tsh = DEFAULT_PRS_DISP_TH;
58029 + cfg->plcr_disp_tsh = DEFAULT_PLCR_DISP_TH;
58030 + cfg->kg_disp_tsh = DEFAULT_KG_DISP_TH;
58031 + cfg->bmi_disp_tsh = DEFAULT_BMI_DISP_TH;
58032 + cfg->qmi_enq_disp_tsh = DEFAULT_QMI_ENQ_DISP_TH;
58033 + cfg->qmi_deq_disp_tsh = DEFAULT_QMI_DEQ_DISP_TH;
58034 + cfg->fm_ctl1_disp_tsh = DEFAULT_FM_CTL1_DISP_TH;
58035 + cfg->fm_ctl2_disp_tsh = DEFAULT_FM_CTL2_DISP_TH;
58036 +
58037 + cfg->pedantic_dma = FALSE;
58038 + cfg->tnum_aging_period = DEFAULT_TNUM_AGING_PERIOD;
58039 + cfg->dma_stop_on_bus_error = FALSE;
58040 + cfg->qmi_deq_option_support = FALSE;
58041 +}
58042 +
58043 +void fman_regconfig(struct fman_rg *fman_rg, struct fman_cfg *cfg)
58044 +{
58045 + uint32_t tmp_reg;
58046 +
58047 + /* read the values from the registers as they are initialized by the HW with
58048 + * the required values.
58049 + */
58050 + tmp_reg = ioread32be(&fman_rg->bmi_rg->fmbm_cfg1);
58051 + cfg->total_fifo_size =
58052 + (((tmp_reg & BMI_TOTAL_FIFO_SIZE_MASK) >> BMI_CFG1_FIFO_SIZE_SHIFT) + 1) * FMAN_BMI_FIFO_UNITS;
58053 +
58054 + tmp_reg = ioread32be(&fman_rg->bmi_rg->fmbm_cfg2);
58055 + cfg->total_num_of_tasks =
58056 + (uint8_t)(((tmp_reg & BMI_TOTAL_NUM_OF_TASKS_MASK) >> BMI_CFG2_TASKS_SHIFT) + 1);
58057 +
58058 + tmp_reg = ioread32be(&fman_rg->dma_rg->fmdmtr);
58059 + cfg->dma_comm_qtsh_asrt_emer = (uint8_t)(tmp_reg >> DMA_THRESH_COMMQ_SHIFT);
58060 +
58061 + tmp_reg = ioread32be(&fman_rg->dma_rg->fmdmhy);
58062 + cfg->dma_comm_qtsh_clr_emer = (uint8_t)(tmp_reg >> DMA_THRESH_COMMQ_SHIFT);
58063 +
58064 + tmp_reg = ioread32be(&fman_rg->dma_rg->fmdmmr);
58065 + cfg->dma_cache_override = (enum fman_dma_cache_override)((tmp_reg & DMA_MODE_CACHE_OR_MASK) >> DMA_MODE_CACHE_OR_SHIFT);
58066 + cfg->dma_cam_num_of_entries = (uint8_t)((((tmp_reg & DMA_MODE_CEN_MASK) >> DMA_MODE_CEN_SHIFT) +1)*DMA_CAM_UNITS);
58067 + cfg->dma_aid_override = (bool)((tmp_reg & DMA_MODE_AID_OR)? TRUE:FALSE);
58068 + cfg->dma_dbg_cnt_mode = (enum fman_dma_dbg_cnt_mode)((tmp_reg & DMA_MODE_DBG_MASK) >> DMA_MODE_DBG_SHIFT);
58069 + cfg->dma_en_emergency = (bool)((tmp_reg & DMA_MODE_EB)? TRUE : FALSE);
58070 +
58071 + tmp_reg = ioread32be(&fman_rg->fpm_rg->fmfp_mxd);
58072 + cfg->disp_limit_tsh = (uint8_t)((tmp_reg & FPM_DISP_LIMIT_MASK) >> FPM_DISP_LIMIT_SHIFT);
58073 +
58074 + tmp_reg = ioread32be(&fman_rg->fpm_rg->fmfp_dist1);
58075 + cfg->prs_disp_tsh = (uint8_t)((tmp_reg & FPM_THR1_PRS_MASK ) >> FPM_THR1_PRS_SHIFT);
58076 + cfg->plcr_disp_tsh = (uint8_t)((tmp_reg & FPM_THR1_KG_MASK ) >> FPM_THR1_KG_SHIFT);
58077 + cfg->kg_disp_tsh = (uint8_t)((tmp_reg & FPM_THR1_PLCR_MASK ) >> FPM_THR1_PLCR_SHIFT);
58078 + cfg->bmi_disp_tsh = (uint8_t)((tmp_reg & FPM_THR1_BMI_MASK ) >> FPM_THR1_BMI_SHIFT);
58079 +
58080 + tmp_reg = ioread32be(&fman_rg->fpm_rg->fmfp_dist2);
58081 + cfg->qmi_enq_disp_tsh = (uint8_t)((tmp_reg & FPM_THR2_QMI_ENQ_MASK ) >> FPM_THR2_QMI_ENQ_SHIFT);
58082 + cfg->qmi_deq_disp_tsh = (uint8_t)((tmp_reg & FPM_THR2_QMI_DEQ_MASK ) >> FPM_THR2_QMI_DEQ_SHIFT);
58083 + cfg->fm_ctl1_disp_tsh = (uint8_t)((tmp_reg & FPM_THR2_FM_CTL1_MASK ) >> FPM_THR2_FM_CTL1_SHIFT);
58084 + cfg->fm_ctl2_disp_tsh = (uint8_t)((tmp_reg & FPM_THR2_FM_CTL2_MASK ) >> FPM_THR2_FM_CTL2_SHIFT);
58085 +
58086 + tmp_reg = ioread32be(&fman_rg->dma_rg->fmdmsetr);
58087 + cfg->dma_sos_emergency = tmp_reg;
58088 +
58089 + tmp_reg = ioread32be(&fman_rg->dma_rg->fmdmwcr);
58090 + cfg->dma_watchdog = tmp_reg/cfg->clk_freq;
58091 +
58092 + tmp_reg = ioread32be(&fman_rg->dma_rg->fmdmemsr);
58093 + cfg->dma_en_emergency_smoother = (bool)((tmp_reg & DMA_EMSR_EMSTR_MASK)? TRUE : FALSE);
58094 + cfg->dma_emergency_switch_counter = (tmp_reg & DMA_EMSR_EMSTR_MASK);
58095 +}
58096 +
58097 +void fman_reset(struct fman_fpm_regs *fpm_rg)
58098 +{
58099 + iowrite32be(FPM_RSTC_FM_RESET, &fpm_rg->fm_rstc);
58100 +}
58101 +
58102 +/**************************************************************************//**
58103 + @Function FM_Init
58104 +
58105 + @Description Initializes the FM module
58106 +
58107 + @Param[in] h_Fm - FM module descriptor
58108 +
58109 + @Return E_OK on success; Error code otherwise.
58110 +*//***************************************************************************/
58111 +int fman_dma_init(struct fman_dma_regs *dma_rg, struct fman_cfg *cfg)
58112 +{
58113 + uint32_t tmp_reg;
58114 +
58115 + /**********************/
58116 + /* Init DMA Registers */
58117 + /**********************/
58118 + /* clear status reg events */
58119 + /* oren - check!!! */
58120 + tmp_reg = (DMA_STATUS_BUS_ERR | DMA_STATUS_READ_ECC |
58121 + DMA_STATUS_SYSTEM_WRITE_ECC | DMA_STATUS_FM_WRITE_ECC);
58122 + iowrite32be(ioread32be(&dma_rg->fmdmsr) | tmp_reg,
58123 + &dma_rg->fmdmsr);
58124 +
58125 + /* configure mode register */
58126 + tmp_reg = 0;
58127 + tmp_reg |= cfg->dma_cache_override << DMA_MODE_CACHE_OR_SHIFT;
58128 + if (cfg->dma_aid_override)
58129 + tmp_reg |= DMA_MODE_AID_OR;
58130 + if (cfg->exceptions & FMAN_EX_DMA_BUS_ERROR)
58131 + tmp_reg |= DMA_MODE_BER;
58132 + if ((cfg->exceptions & FMAN_EX_DMA_SYSTEM_WRITE_ECC) |
58133 + (cfg->exceptions & FMAN_EX_DMA_READ_ECC) |
58134 + (cfg->exceptions & FMAN_EX_DMA_FM_WRITE_ECC))
58135 + tmp_reg |= DMA_MODE_ECC;
58136 + if (cfg->dma_stop_on_bus_error)
58137 + tmp_reg |= DMA_MODE_SBER;
58138 + if(cfg->dma_axi_dbg_num_of_beats)
58139 + tmp_reg |= (uint32_t)(DMA_MODE_AXI_DBG_MASK &
58140 + ((cfg->dma_axi_dbg_num_of_beats - 1) << DMA_MODE_AXI_DBG_SHIFT));
58141 +
58142 + if (cfg->dma_en_emergency) {
58143 + tmp_reg |= cfg->dma_emergency_bus_select;
58144 + tmp_reg |= cfg->dma_emergency_level << DMA_MODE_EMER_LVL_SHIFT;
58145 + if (cfg->dma_en_emergency_smoother)
58146 + iowrite32be(cfg->dma_emergency_switch_counter,
58147 + &dma_rg->fmdmemsr);
58148 + }
58149 + tmp_reg |= ((cfg->dma_cam_num_of_entries / DMA_CAM_UNITS) - 1) <<
58150 + DMA_MODE_CEN_SHIFT;
58151 + tmp_reg |= DMA_MODE_SECURE_PROT;
58152 + tmp_reg |= cfg->dma_dbg_cnt_mode << DMA_MODE_DBG_SHIFT;
58153 + tmp_reg |= cfg->dma_aid_mode << DMA_MODE_AID_MODE_SHIFT;
58154 +
58155 + if (cfg->pedantic_dma)
58156 + tmp_reg |= DMA_MODE_EMER_READ;
58157 +
58158 + iowrite32be(tmp_reg, &dma_rg->fmdmmr);
58159 +
58160 + /* configure thresholds register */
58161 + tmp_reg = ((uint32_t)cfg->dma_comm_qtsh_asrt_emer <<
58162 + DMA_THRESH_COMMQ_SHIFT) |
58163 + ((uint32_t)cfg->dma_read_buf_tsh_asrt_emer <<
58164 + DMA_THRESH_READ_INT_BUF_SHIFT) |
58165 + ((uint32_t)cfg->dma_write_buf_tsh_asrt_emer);
58166 +
58167 + iowrite32be(tmp_reg, &dma_rg->fmdmtr);
58168 +
58169 + /* configure hysteresis register */
58170 + tmp_reg = ((uint32_t)cfg->dma_comm_qtsh_clr_emer <<
58171 + DMA_THRESH_COMMQ_SHIFT) |
58172 + ((uint32_t)cfg->dma_read_buf_tsh_clr_emer <<
58173 + DMA_THRESH_READ_INT_BUF_SHIFT) |
58174 + ((uint32_t)cfg->dma_write_buf_tsh_clr_emer);
58175 +
58176 + iowrite32be(tmp_reg, &dma_rg->fmdmhy);
58177 +
58178 + /* configure emergency threshold */
58179 + iowrite32be(cfg->dma_sos_emergency, &dma_rg->fmdmsetr);
58180 +
58181 + /* configure Watchdog */
58182 + iowrite32be((cfg->dma_watchdog * cfg->clk_freq),
58183 + &dma_rg->fmdmwcr);
58184 +
58185 + iowrite32be(cfg->cam_base_addr, &dma_rg->fmdmebcr);
58186 +
58187 + return 0;
58188 +}
58189 +
58190 +int fman_fpm_init(struct fman_fpm_regs *fpm_rg, struct fman_cfg *cfg)
58191 +{
58192 + uint32_t tmp_reg;
58193 + int i;
58194 +
58195 + /**********************/
58196 + /* Init FPM Registers */
58197 + /**********************/
58198 + tmp_reg = (uint32_t)(cfg->disp_limit_tsh << FPM_DISP_LIMIT_SHIFT);
58199 + iowrite32be(tmp_reg, &fpm_rg->fmfp_mxd);
58200 +
58201 + tmp_reg = (((uint32_t)cfg->prs_disp_tsh << FPM_THR1_PRS_SHIFT) |
58202 + ((uint32_t)cfg->kg_disp_tsh << FPM_THR1_KG_SHIFT) |
58203 + ((uint32_t)cfg->plcr_disp_tsh << FPM_THR1_PLCR_SHIFT) |
58204 + ((uint32_t)cfg->bmi_disp_tsh << FPM_THR1_BMI_SHIFT));
58205 + iowrite32be(tmp_reg, &fpm_rg->fmfp_dist1);
58206 +
58207 + tmp_reg = (((uint32_t)cfg->qmi_enq_disp_tsh << FPM_THR2_QMI_ENQ_SHIFT) |
58208 + ((uint32_t)cfg->qmi_deq_disp_tsh << FPM_THR2_QMI_DEQ_SHIFT) |
58209 + ((uint32_t)cfg->fm_ctl1_disp_tsh << FPM_THR2_FM_CTL1_SHIFT) |
58210 + ((uint32_t)cfg->fm_ctl2_disp_tsh << FPM_THR2_FM_CTL2_SHIFT));
58211 + iowrite32be(tmp_reg, &fpm_rg->fmfp_dist2);
58212 +
58213 + /* define exceptions and error behavior */
58214 + tmp_reg = 0;
58215 + /* Clear events */
58216 + tmp_reg |= (FPM_EV_MASK_STALL | FPM_EV_MASK_DOUBLE_ECC |
58217 + FPM_EV_MASK_SINGLE_ECC);
58218 + /* enable interrupts */
58219 + if (cfg->exceptions & FMAN_EX_FPM_STALL_ON_TASKS)
58220 + tmp_reg |= FPM_EV_MASK_STALL_EN;
58221 + if (cfg->exceptions & FMAN_EX_FPM_SINGLE_ECC)
58222 + tmp_reg |= FPM_EV_MASK_SINGLE_ECC_EN;
58223 + if (cfg->exceptions & FMAN_EX_FPM_DOUBLE_ECC)
58224 + tmp_reg |= FPM_EV_MASK_DOUBLE_ECC_EN;
58225 + tmp_reg |= (cfg->catastrophic_err << FPM_EV_MASK_CAT_ERR_SHIFT);
58226 + tmp_reg |= (cfg->dma_err << FPM_EV_MASK_DMA_ERR_SHIFT);
58227 + if (!cfg->halt_on_external_activ)
58228 + tmp_reg |= FPM_EV_MASK_EXTERNAL_HALT;
58229 + if (!cfg->halt_on_unrecov_ecc_err)
58230 + tmp_reg |= FPM_EV_MASK_ECC_ERR_HALT;
58231 + iowrite32be(tmp_reg, &fpm_rg->fmfp_ee);
58232 +
58233 + /* clear all fmCtls event registers */
58234 + for (i = 0; i < cfg->num_of_fman_ctrl_evnt_regs; i++)
58235 + iowrite32be(0xFFFFFFFF, &fpm_rg->fmfp_cev[i]);
58236 +
58237 + /* RAM ECC - enable and clear events*/
58238 + /* first we need to clear all parser memory,
58239 + * as it is uninitialized and may cause ECC errors */
58240 + /* event bits */
58241 + tmp_reg = (FPM_RAM_MURAM_ECC | FPM_RAM_IRAM_ECC);
58242 + /* Rams enable not effected by RCR bit, but by a COP configuration */
58243 + if (cfg->external_ecc_rams_enable)
58244 + tmp_reg |= FPM_RAM_RAMS_ECC_EN_SRC_SEL;
58245 +
58246 + /* enable test mode */
58247 + if (cfg->en_muram_test_mode)
58248 + tmp_reg |= FPM_RAM_MURAM_TEST_ECC;
58249 + if (cfg->en_iram_test_mode)
58250 + tmp_reg |= FPM_RAM_IRAM_TEST_ECC;
58251 + iowrite32be(tmp_reg, &fpm_rg->fm_rcr);
58252 +
58253 + tmp_reg = 0;
58254 + if (cfg->exceptions & FMAN_EX_IRAM_ECC) {
58255 + tmp_reg |= FPM_IRAM_ECC_ERR_EX_EN;
58256 + fman_enable_rams_ecc(fpm_rg);
58257 + }
58258 + if (cfg->exceptions & FMAN_EX_NURAM_ECC) {
58259 + tmp_reg |= FPM_MURAM_ECC_ERR_EX_EN;
58260 + fman_enable_rams_ecc(fpm_rg);
58261 + }
58262 + iowrite32be(tmp_reg, &fpm_rg->fm_rie);
58263 +
58264 + return 0;
58265 +}
58266 +
58267 +int fman_bmi_init(struct fman_bmi_regs *bmi_rg, struct fman_cfg *cfg)
58268 +{
58269 + uint32_t tmp_reg;
58270 +
58271 + /**********************/
58272 + /* Init BMI Registers */
58273 + /**********************/
58274 +
58275 + /* define common resources */
58276 + tmp_reg = cfg->fifo_base_addr;
58277 + tmp_reg = tmp_reg / BMI_FIFO_ALIGN;
58278 +
58279 + tmp_reg |= ((cfg->total_fifo_size / FMAN_BMI_FIFO_UNITS - 1) <<
58280 + BMI_CFG1_FIFO_SIZE_SHIFT);
58281 + iowrite32be(tmp_reg, &bmi_rg->fmbm_cfg1);
58282 +
58283 + tmp_reg = ((uint32_t)(cfg->total_num_of_tasks - 1) <<
58284 + BMI_CFG2_TASKS_SHIFT);
58285 + /* num of DMA's will be dynamically updated when each port is set */
58286 + iowrite32be(tmp_reg, &bmi_rg->fmbm_cfg2);
58287 +
58288 + /* define unmaskable exceptions, enable and clear events */
58289 + tmp_reg = 0;
58290 + iowrite32be(BMI_ERR_INTR_EN_LIST_RAM_ECC |
58291 + BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC |
58292 + BMI_ERR_INTR_EN_STATISTICS_RAM_ECC |
58293 + BMI_ERR_INTR_EN_DISPATCH_RAM_ECC,
58294 + &bmi_rg->fmbm_ievr);
58295 +
58296 + if (cfg->exceptions & FMAN_EX_BMI_LIST_RAM_ECC)
58297 + tmp_reg |= BMI_ERR_INTR_EN_LIST_RAM_ECC;
58298 + if (cfg->exceptions & FMAN_EX_BMI_PIPELINE_ECC)
58299 + tmp_reg |= BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC;
58300 + if (cfg->exceptions & FMAN_EX_BMI_STATISTICS_RAM_ECC)
58301 + tmp_reg |= BMI_ERR_INTR_EN_STATISTICS_RAM_ECC;
58302 + if (cfg->exceptions & FMAN_EX_BMI_DISPATCH_RAM_ECC)
58303 + tmp_reg |= BMI_ERR_INTR_EN_DISPATCH_RAM_ECC;
58304 + iowrite32be(tmp_reg, &bmi_rg->fmbm_ier);
58305 +
58306 + return 0;
58307 +}
58308 +
58309 +int fman_qmi_init(struct fman_qmi_regs *qmi_rg, struct fman_cfg *cfg)
58310 +{
58311 + uint32_t tmp_reg;
58312 + uint16_t period_in_fm_clocks;
58313 + uint8_t remainder;
58314 + /**********************/
58315 + /* Init QMI Registers */
58316 + /**********************/
58317 + /* Clear error interrupt events */
58318 +
58319 + iowrite32be(QMI_ERR_INTR_EN_DOUBLE_ECC | QMI_ERR_INTR_EN_DEQ_FROM_DEF,
58320 + &qmi_rg->fmqm_eie);
58321 + tmp_reg = 0;
58322 + if (cfg->exceptions & FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID)
58323 + tmp_reg |= QMI_ERR_INTR_EN_DEQ_FROM_DEF;
58324 + if (cfg->exceptions & FMAN_EX_QMI_DOUBLE_ECC)
58325 + tmp_reg |= QMI_ERR_INTR_EN_DOUBLE_ECC;
58326 + /* enable events */
58327 + iowrite32be(tmp_reg, &qmi_rg->fmqm_eien);
58328 +
58329 + if (cfg->tnum_aging_period) {
58330 + /* tnum_aging_period is in units of usec, p_FmClockFreq in Mhz */
58331 + period_in_fm_clocks = (uint16_t)
58332 + (cfg->tnum_aging_period * cfg->clk_freq);
58333 + /* period_in_fm_clocks must be a 64 multiply */
58334 + remainder = (uint8_t)(period_in_fm_clocks % 64);
58335 + if (remainder)
58336 + tmp_reg = (uint32_t)((period_in_fm_clocks / 64) + 1);
58337 + else{
58338 + tmp_reg = (uint32_t)(period_in_fm_clocks / 64);
58339 + if (!tmp_reg)
58340 + tmp_reg = 1;
58341 + }
58342 + tmp_reg <<= QMI_TAPC_TAP;
58343 + iowrite32be(tmp_reg, &qmi_rg->fmqm_tapc);
58344 + }
58345 + tmp_reg = 0;
58346 + /* Clear interrupt events */
58347 + iowrite32be(QMI_INTR_EN_SINGLE_ECC, &qmi_rg->fmqm_ie);
58348 + if (cfg->exceptions & FMAN_EX_QMI_SINGLE_ECC)
58349 + tmp_reg |= QMI_INTR_EN_SINGLE_ECC;
58350 + /* enable events */
58351 + iowrite32be(tmp_reg, &qmi_rg->fmqm_ien);
58352 +
58353 + return 0;
58354 +}
58355 +
58356 +int fman_enable(struct fman_rg *fman_rg, struct fman_cfg *cfg)
58357 +{
58358 + uint32_t cfg_reg = 0;
58359 +
58360 + /**********************/
58361 + /* Enable all modules */
58362 + /**********************/
58363 + /* clear & enable global counters - calculate reg and save for later,
58364 + because it's the same reg for QMI enable */
58365 + cfg_reg = QMI_CFG_EN_COUNTERS;
58366 + if (cfg->qmi_deq_option_support)
58367 + cfg_reg |= (uint32_t)(((cfg->qmi_def_tnums_thresh) << 8) |
58368 + (uint32_t)cfg->qmi_def_tnums_thresh);
58369 +
58370 + iowrite32be(BMI_INIT_START, &fman_rg->bmi_rg->fmbm_init);
58371 + iowrite32be(cfg_reg | QMI_CFG_ENQ_EN | QMI_CFG_DEQ_EN,
58372 + &fman_rg->qmi_rg->fmqm_gc);
58373 +
58374 + return 0;
58375 +}
58376 +
58377 +void fman_free_resources(struct fman_rg *fman_rg)
58378 +{
58379 + /* disable BMI and QMI */
58380 + iowrite32be(0, &fman_rg->bmi_rg->fmbm_init);
58381 + iowrite32be(0, &fman_rg->qmi_rg->fmqm_gc);
58382 +
58383 + /* release BMI resources */
58384 + iowrite32be(0, &fman_rg->bmi_rg->fmbm_cfg2);
58385 + iowrite32be(0, &fman_rg->bmi_rg->fmbm_cfg1);
58386 +
58387 + /* disable ECC */
58388 + iowrite32be(0, &fman_rg->fpm_rg->fm_rcr);
58389 +}
58390 +
58391 +/****************************************************/
58392 +/* API Run-time Control uint functions */
58393 +/****************************************************/
58394 +uint32_t fman_get_normal_pending(struct fman_fpm_regs *fpm_rg)
58395 +{
58396 + return ioread32be(&fpm_rg->fm_npi);
58397 +}
58398 +
58399 +uint32_t fman_get_controller_event(struct fman_fpm_regs *fpm_rg, uint8_t reg_id)
58400 +{
58401 + uint32_t event;
58402 +
58403 + event = ioread32be(&fpm_rg->fmfp_fcev[reg_id]) &
58404 + ioread32be(&fpm_rg->fmfp_cee[reg_id]);
58405 + iowrite32be(event, &fpm_rg->fmfp_cev[reg_id]);
58406 +
58407 + return event;
58408 +}
58409 +
58410 +uint32_t fman_get_error_pending(struct fman_fpm_regs *fpm_rg)
58411 +{
58412 + return ioread32be(&fpm_rg->fm_epi);
58413 +}
58414 +
58415 +void fman_set_ports_bandwidth(struct fman_bmi_regs *bmi_rg, uint8_t *weights)
58416 +{
58417 + int i;
58418 + uint8_t shift;
58419 + uint32_t tmp = 0;
58420 +
58421 + for (i = 0; i < 64; i++) {
58422 + if (weights[i] > 1) { /* no need to write 1 since it is 0 */
58423 + /* Add this port to tmp_reg */
58424 + /* (each 8 ports result in one register)*/
58425 + shift = (uint8_t)(32 - 4 * ((i % 8) + 1));
58426 + tmp |= ((weights[i] - 1) << shift);
58427 + }
58428 + if (i % 8 == 7) { /* last in this set */
58429 + iowrite32be(tmp, &bmi_rg->fmbm_arb[i / 8]);
58430 + tmp = 0;
58431 + }
58432 + }
58433 +}
58434 +
58435 +void fman_enable_rams_ecc(struct fman_fpm_regs *fpm_rg)
58436 +{
58437 + uint32_t tmp;
58438 +
58439 + tmp = ioread32be(&fpm_rg->fm_rcr);
58440 + if (tmp & FPM_RAM_RAMS_ECC_EN_SRC_SEL)
58441 + iowrite32be(tmp | FPM_RAM_IRAM_ECC_EN,
58442 + &fpm_rg->fm_rcr);
58443 + else
58444 + iowrite32be(tmp | FPM_RAM_RAMS_ECC_EN |
58445 + FPM_RAM_IRAM_ECC_EN,
58446 + &fpm_rg->fm_rcr);
58447 +}
58448 +
58449 +void fman_disable_rams_ecc(struct fman_fpm_regs *fpm_rg)
58450 +{
58451 + uint32_t tmp;
58452 +
58453 + tmp = ioread32be(&fpm_rg->fm_rcr);
58454 + if (tmp & FPM_RAM_RAMS_ECC_EN_SRC_SEL)
58455 + iowrite32be(tmp & ~FPM_RAM_IRAM_ECC_EN,
58456 + &fpm_rg->fm_rcr);
58457 + else
58458 + iowrite32be(tmp & ~(FPM_RAM_RAMS_ECC_EN | FPM_RAM_IRAM_ECC_EN),
58459 + &fpm_rg->fm_rcr);
58460 +}
58461 +
58462 +int fman_set_exception(struct fman_rg *fman_rg,
58463 + enum fman_exceptions exception,
58464 + bool enable)
58465 +{
58466 + uint32_t tmp;
58467 +
58468 + switch (exception) {
58469 + case(E_FMAN_EX_DMA_BUS_ERROR):
58470 + tmp = ioread32be(&fman_rg->dma_rg->fmdmmr);
58471 + if (enable)
58472 + tmp |= DMA_MODE_BER;
58473 + else
58474 + tmp &= ~DMA_MODE_BER;
58475 + /* disable bus error */
58476 + iowrite32be(tmp, &fman_rg->dma_rg->fmdmmr);
58477 + break;
58478 + case(E_FMAN_EX_DMA_READ_ECC):
58479 + case(E_FMAN_EX_DMA_SYSTEM_WRITE_ECC):
58480 + case(E_FMAN_EX_DMA_FM_WRITE_ECC):
58481 + tmp = ioread32be(&fman_rg->dma_rg->fmdmmr);
58482 + if (enable)
58483 + tmp |= DMA_MODE_ECC;
58484 + else
58485 + tmp &= ~DMA_MODE_ECC;
58486 + iowrite32be(tmp, &fman_rg->dma_rg->fmdmmr);
58487 + break;
58488 + case(E_FMAN_EX_FPM_STALL_ON_TASKS):
58489 + tmp = ioread32be(&fman_rg->fpm_rg->fmfp_ee);
58490 + if (enable)
58491 + tmp |= FPM_EV_MASK_STALL_EN;
58492 + else
58493 + tmp &= ~FPM_EV_MASK_STALL_EN;
58494 + iowrite32be(tmp, &fman_rg->fpm_rg->fmfp_ee);
58495 + break;
58496 + case(E_FMAN_EX_FPM_SINGLE_ECC):
58497 + tmp = ioread32be(&fman_rg->fpm_rg->fmfp_ee);
58498 + if (enable)
58499 + tmp |= FPM_EV_MASK_SINGLE_ECC_EN;
58500 + else
58501 + tmp &= ~FPM_EV_MASK_SINGLE_ECC_EN;
58502 + iowrite32be(tmp, &fman_rg->fpm_rg->fmfp_ee);
58503 + break;
58504 + case(E_FMAN_EX_FPM_DOUBLE_ECC):
58505 + tmp = ioread32be(&fman_rg->fpm_rg->fmfp_ee);
58506 + if (enable)
58507 + tmp |= FPM_EV_MASK_DOUBLE_ECC_EN;
58508 + else
58509 + tmp &= ~FPM_EV_MASK_DOUBLE_ECC_EN;
58510 + iowrite32be(tmp, &fman_rg->fpm_rg->fmfp_ee);
58511 + break;
58512 + case(E_FMAN_EX_QMI_SINGLE_ECC):
58513 + tmp = ioread32be(&fman_rg->qmi_rg->fmqm_ien);
58514 + if (enable)
58515 + tmp |= QMI_INTR_EN_SINGLE_ECC;
58516 + else
58517 + tmp &= ~QMI_INTR_EN_SINGLE_ECC;
58518 + iowrite32be(tmp, &fman_rg->qmi_rg->fmqm_ien);
58519 + break;
58520 + case(E_FMAN_EX_QMI_DOUBLE_ECC):
58521 + tmp = ioread32be(&fman_rg->qmi_rg->fmqm_eien);
58522 + if (enable)
58523 + tmp |= QMI_ERR_INTR_EN_DOUBLE_ECC;
58524 + else
58525 + tmp &= ~QMI_ERR_INTR_EN_DOUBLE_ECC;
58526 + iowrite32be(tmp, &fman_rg->qmi_rg->fmqm_eien);
58527 + break;
58528 + case(E_FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID):
58529 + tmp = ioread32be(&fman_rg->qmi_rg->fmqm_eien);
58530 + if (enable)
58531 + tmp |= QMI_ERR_INTR_EN_DEQ_FROM_DEF;
58532 + else
58533 + tmp &= ~QMI_ERR_INTR_EN_DEQ_FROM_DEF;
58534 + iowrite32be(tmp, &fman_rg->qmi_rg->fmqm_eien);
58535 + break;
58536 + case(E_FMAN_EX_BMI_LIST_RAM_ECC):
58537 + tmp = ioread32be(&fman_rg->bmi_rg->fmbm_ier);
58538 + if (enable)
58539 + tmp |= BMI_ERR_INTR_EN_LIST_RAM_ECC;
58540 + else
58541 + tmp &= ~BMI_ERR_INTR_EN_LIST_RAM_ECC;
58542 + iowrite32be(tmp, &fman_rg->bmi_rg->fmbm_ier);
58543 + break;
58544 + case(E_FMAN_EX_BMI_STORAGE_PROFILE_ECC):
58545 + tmp = ioread32be(&fman_rg->bmi_rg->fmbm_ier);
58546 + if (enable)
58547 + tmp |= BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC;
58548 + else
58549 + tmp &= ~BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC;
58550 + iowrite32be(tmp, &fman_rg->bmi_rg->fmbm_ier);
58551 + break;
58552 + case(E_FMAN_EX_BMI_STATISTICS_RAM_ECC):
58553 + tmp = ioread32be(&fman_rg->bmi_rg->fmbm_ier);
58554 + if (enable)
58555 + tmp |= BMI_ERR_INTR_EN_STATISTICS_RAM_ECC;
58556 + else
58557 + tmp &= ~BMI_ERR_INTR_EN_STATISTICS_RAM_ECC;
58558 + iowrite32be(tmp, &fman_rg->bmi_rg->fmbm_ier);
58559 + break;
58560 + case(E_FMAN_EX_BMI_DISPATCH_RAM_ECC):
58561 + tmp = ioread32be(&fman_rg->bmi_rg->fmbm_ier);
58562 + if (enable)
58563 + tmp |= BMI_ERR_INTR_EN_DISPATCH_RAM_ECC;
58564 + else
58565 + tmp &= ~BMI_ERR_INTR_EN_DISPATCH_RAM_ECC;
58566 + iowrite32be(tmp, &fman_rg->bmi_rg->fmbm_ier);
58567 + break;
58568 + case(E_FMAN_EX_IRAM_ECC):
58569 + tmp = ioread32be(&fman_rg->fpm_rg->fm_rie);
58570 + if (enable) {
58571 + /* enable ECC if not enabled */
58572 + fman_enable_rams_ecc(fman_rg->fpm_rg);
58573 + /* enable ECC interrupts */
58574 + tmp |= FPM_IRAM_ECC_ERR_EX_EN;
58575 + } else {
58576 + /* ECC mechanism may be disabled,
58577 + * depending on driver status */
58578 + fman_disable_rams_ecc(fman_rg->fpm_rg);
58579 + tmp &= ~FPM_IRAM_ECC_ERR_EX_EN;
58580 + }
58581 + iowrite32be(tmp, &fman_rg->fpm_rg->fm_rie);
58582 + break;
58583 + case(E_FMAN_EX_MURAM_ECC):
58584 + tmp = ioread32be(&fman_rg->fpm_rg->fm_rie);
58585 + if (enable) {
58586 + /* enable ECC if not enabled */
58587 + fman_enable_rams_ecc(fman_rg->fpm_rg);
58588 + /* enable ECC interrupts */
58589 + tmp |= FPM_MURAM_ECC_ERR_EX_EN;
58590 + } else {
58591 + /* ECC mechanism may be disabled,
58592 + * depending on driver status */
58593 + fman_disable_rams_ecc(fman_rg->fpm_rg);
58594 + tmp &= ~FPM_MURAM_ECC_ERR_EX_EN;
58595 + }
58596 + iowrite32be(tmp, &fman_rg->fpm_rg->fm_rie);
58597 + break;
58598 + default:
58599 + return -EINVAL;
58600 + }
58601 + return 0;
58602 +}
58603 +
58604 +void fman_get_revision(struct fman_fpm_regs *fpm_rg,
58605 + uint8_t *major,
58606 + uint8_t *minor)
58607 +{
58608 + uint32_t tmp;
58609 +
58610 + tmp = ioread32be(&fpm_rg->fm_ip_rev_1);
58611 + *major = (uint8_t)((tmp & FPM_REV1_MAJOR_MASK) >> FPM_REV1_MAJOR_SHIFT);
58612 + *minor = (uint8_t)((tmp & FPM_REV1_MINOR_MASK) >> FPM_REV1_MINOR_SHIFT);
58613 +
58614 +}
58615 +
58616 +uint32_t fman_get_counter(struct fman_rg *fman_rg,
58617 + enum fman_counters reg_name)
58618 +{
58619 + uint32_t ret_val;
58620 +
58621 + switch (reg_name) {
58622 + case(E_FMAN_COUNTERS_ENQ_TOTAL_FRAME):
58623 + ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_etfc);
58624 + break;
58625 + case(E_FMAN_COUNTERS_DEQ_TOTAL_FRAME):
58626 + ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dtfc);
58627 + break;
58628 + case(E_FMAN_COUNTERS_DEQ_0):
58629 + ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dc0);
58630 + break;
58631 + case(E_FMAN_COUNTERS_DEQ_1):
58632 + ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dc1);
58633 + break;
58634 + case(E_FMAN_COUNTERS_DEQ_2):
58635 + ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dc2);
58636 + break;
58637 + case(E_FMAN_COUNTERS_DEQ_3):
58638 + ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dc3);
58639 + break;
58640 + case(E_FMAN_COUNTERS_DEQ_FROM_DEFAULT):
58641 + ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dfdc);
58642 + break;
58643 + case(E_FMAN_COUNTERS_DEQ_FROM_CONTEXT):
58644 + ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dfcc);
58645 + break;
58646 + case(E_FMAN_COUNTERS_DEQ_FROM_FD):
58647 + ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dffc);
58648 + break;
58649 + case(E_FMAN_COUNTERS_DEQ_CONFIRM):
58650 + ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dcc);
58651 + break;
58652 + default:
58653 + ret_val = 0;
58654 + }
58655 + return ret_val;
58656 +}
58657 +
58658 +int fman_modify_counter(struct fman_rg *fman_rg,
58659 + enum fman_counters reg_name,
58660 + uint32_t val)
58661 +{
58662 + /* When applicable (when there is an 'enable counters' bit,
58663 + * check that counters are enabled */
58664 + switch (reg_name) {
58665 + case(E_FMAN_COUNTERS_ENQ_TOTAL_FRAME):
58666 + case(E_FMAN_COUNTERS_DEQ_TOTAL_FRAME):
58667 + case(E_FMAN_COUNTERS_DEQ_0):
58668 + case(E_FMAN_COUNTERS_DEQ_1):
58669 + case(E_FMAN_COUNTERS_DEQ_2):
58670 + case(E_FMAN_COUNTERS_DEQ_3):
58671 + case(E_FMAN_COUNTERS_DEQ_FROM_DEFAULT):
58672 + case(E_FMAN_COUNTERS_DEQ_FROM_CONTEXT):
58673 + case(E_FMAN_COUNTERS_DEQ_FROM_FD):
58674 + case(E_FMAN_COUNTERS_DEQ_CONFIRM):
58675 + if (!(ioread32be(&fman_rg->qmi_rg->fmqm_gc) &
58676 + QMI_CFG_EN_COUNTERS))
58677 + return -EINVAL;
58678 + break;
58679 + default:
58680 + break;
58681 + }
58682 + /* Set counter */
58683 + switch (reg_name) {
58684 + case(E_FMAN_COUNTERS_ENQ_TOTAL_FRAME):
58685 + iowrite32be(val, &fman_rg->qmi_rg->fmqm_etfc);
58686 + break;
58687 + case(E_FMAN_COUNTERS_DEQ_TOTAL_FRAME):
58688 + iowrite32be(val, &fman_rg->qmi_rg->fmqm_dtfc);
58689 + break;
58690 + case(E_FMAN_COUNTERS_DEQ_0):
58691 + iowrite32be(val, &fman_rg->qmi_rg->fmqm_dc0);
58692 + break;
58693 + case(E_FMAN_COUNTERS_DEQ_1):
58694 + iowrite32be(val, &fman_rg->qmi_rg->fmqm_dc1);
58695 + break;
58696 + case(E_FMAN_COUNTERS_DEQ_2):
58697 + iowrite32be(val, &fman_rg->qmi_rg->fmqm_dc2);
58698 + break;
58699 + case(E_FMAN_COUNTERS_DEQ_3):
58700 + iowrite32be(val, &fman_rg->qmi_rg->fmqm_dc3);
58701 + break;
58702 + case(E_FMAN_COUNTERS_DEQ_FROM_DEFAULT):
58703 + iowrite32be(val, &fman_rg->qmi_rg->fmqm_dfdc);
58704 + break;
58705 + case(E_FMAN_COUNTERS_DEQ_FROM_CONTEXT):
58706 + iowrite32be(val, &fman_rg->qmi_rg->fmqm_dfcc);
58707 + break;
58708 + case(E_FMAN_COUNTERS_DEQ_FROM_FD):
58709 + iowrite32be(val, &fman_rg->qmi_rg->fmqm_dffc);
58710 + break;
58711 + case(E_FMAN_COUNTERS_DEQ_CONFIRM):
58712 + iowrite32be(val, &fman_rg->qmi_rg->fmqm_dcc);
58713 + break;
58714 + case(E_FMAN_COUNTERS_SEMAPHOR_ENTRY_FULL_REJECT):
58715 + iowrite32be(val, &fman_rg->dma_rg->fmdmsefrc);
58716 + break;
58717 + case(E_FMAN_COUNTERS_SEMAPHOR_QUEUE_FULL_REJECT):
58718 + iowrite32be(val, &fman_rg->dma_rg->fmdmsqfrc);
58719 + break;
58720 + case(E_FMAN_COUNTERS_SEMAPHOR_SYNC_REJECT):
58721 + iowrite32be(val, &fman_rg->dma_rg->fmdmssrc);
58722 + break;
58723 + default:
58724 + break;
58725 + }
58726 + return 0;
58727 +}
58728 +
58729 +void fman_set_dma_emergency(struct fman_dma_regs *dma_rg,
58730 + bool is_write,
58731 + bool enable)
58732 +{
58733 + uint32_t msk;
58734 +
58735 + msk = (uint32_t)(is_write ? DMA_MODE_EMER_WRITE : DMA_MODE_EMER_READ);
58736 +
58737 + if (enable)
58738 + iowrite32be(ioread32be(&dma_rg->fmdmmr) | msk,
58739 + &dma_rg->fmdmmr);
58740 + else /* disable */
58741 + iowrite32be(ioread32be(&dma_rg->fmdmmr) & ~msk,
58742 + &dma_rg->fmdmmr);
58743 +}
58744 +
58745 +void fman_set_dma_ext_bus_pri(struct fman_dma_regs *dma_rg, uint32_t pri)
58746 +{
58747 + uint32_t tmp;
58748 +
58749 + tmp = ioread32be(&dma_rg->fmdmmr) |
58750 + (pri << DMA_MODE_BUS_PRI_SHIFT);
58751 +
58752 + iowrite32be(tmp, &dma_rg->fmdmmr);
58753 +}
58754 +
58755 +uint32_t fman_get_dma_status(struct fman_dma_regs *dma_rg)
58756 +{
58757 + return ioread32be(&dma_rg->fmdmsr);
58758 +}
58759 +
58760 +void fman_force_intr(struct fman_rg *fman_rg,
58761 + enum fman_exceptions exception)
58762 +{
58763 + switch (exception) {
58764 + case E_FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID:
58765 + iowrite32be(QMI_ERR_INTR_EN_DEQ_FROM_DEF,
58766 + &fman_rg->qmi_rg->fmqm_eif);
58767 + break;
58768 + case E_FMAN_EX_QMI_SINGLE_ECC:
58769 + iowrite32be(QMI_INTR_EN_SINGLE_ECC,
58770 + &fman_rg->qmi_rg->fmqm_if);
58771 + break;
58772 + case E_FMAN_EX_QMI_DOUBLE_ECC:
58773 + iowrite32be(QMI_ERR_INTR_EN_DOUBLE_ECC,
58774 + &fman_rg->qmi_rg->fmqm_eif);
58775 + break;
58776 + case E_FMAN_EX_BMI_LIST_RAM_ECC:
58777 + iowrite32be(BMI_ERR_INTR_EN_LIST_RAM_ECC,
58778 + &fman_rg->bmi_rg->fmbm_ifr);
58779 + break;
58780 + case E_FMAN_EX_BMI_STORAGE_PROFILE_ECC:
58781 + iowrite32be(BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC,
58782 + &fman_rg->bmi_rg->fmbm_ifr);
58783 + break;
58784 + case E_FMAN_EX_BMI_STATISTICS_RAM_ECC:
58785 + iowrite32be(BMI_ERR_INTR_EN_STATISTICS_RAM_ECC,
58786 + &fman_rg->bmi_rg->fmbm_ifr);
58787 + break;
58788 + case E_FMAN_EX_BMI_DISPATCH_RAM_ECC:
58789 + iowrite32be(BMI_ERR_INTR_EN_DISPATCH_RAM_ECC,
58790 + &fman_rg->bmi_rg->fmbm_ifr);
58791 + break;
58792 + default:
58793 + break;
58794 + }
58795 +}
58796 +
58797 +bool fman_is_qmi_halt_not_busy_state(struct fman_qmi_regs *qmi_rg)
58798 +{
58799 + return (bool)!!(ioread32be(&qmi_rg->fmqm_gs) & QMI_GS_HALT_NOT_BUSY);
58800 +}
58801 +void fman_resume(struct fman_fpm_regs *fpm_rg)
58802 +{
58803 + uint32_t tmp;
58804 +
58805 + tmp = ioread32be(&fpm_rg->fmfp_ee);
58806 + /* clear tmp_reg event bits in order not to clear standing events */
58807 + tmp &= ~(FPM_EV_MASK_DOUBLE_ECC |
58808 + FPM_EV_MASK_STALL |
58809 + FPM_EV_MASK_SINGLE_ECC);
58810 + tmp |= FPM_EV_MASK_RELEASE_FM;
58811 +
58812 + iowrite32be(tmp, &fpm_rg->fmfp_ee);
58813 +}
58814 --- /dev/null
58815 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc/fm_common.h
58816 @@ -0,0 +1,1203 @@
58817 +/*
58818 + * Copyright 2008-2012 Freescale Semiconductor Inc.
58819 + *
58820 + * Redistribution and use in source and binary forms, with or without
58821 + * modification, are permitted provided that the following conditions are met:
58822 + * * Redistributions of source code must retain the above copyright
58823 + * notice, this list of conditions and the following disclaimer.
58824 + * * Redistributions in binary form must reproduce the above copyright
58825 + * notice, this list of conditions and the following disclaimer in the
58826 + * documentation and/or other materials provided with the distribution.
58827 + * * Neither the name of Freescale Semiconductor nor the
58828 + * names of its contributors may be used to endorse or promote products
58829 + * derived from this software without specific prior written permission.
58830 + *
58831 + *
58832 + * ALTERNATIVELY, this software may be distributed under the terms of the
58833 + * GNU General Public License ("GPL") as published by the Free Software
58834 + * Foundation, either version 2 of that License or (at your option) any
58835 + * later version.
58836 + *
58837 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
58838 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
58839 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
58840 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
58841 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
58842 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
58843 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
58844 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
58845 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
58846 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58847 + */
58848 +
58849 +
58850 +/******************************************************************************
58851 + @File fm_common.h
58852 +
58853 + @Description FM internal structures and definitions.
58854 +*//***************************************************************************/
58855 +#ifndef __FM_COMMON_H
58856 +#define __FM_COMMON_H
58857 +
58858 +#include "error_ext.h"
58859 +#include "std_ext.h"
58860 +#include "fm_pcd_ext.h"
58861 +#include "fm_ext.h"
58862 +#include "fm_port_ext.h"
58863 +
58864 +
58865 +#define e_FM_PORT_TYPE_OH_HOST_COMMAND e_FM_PORT_TYPE_DUMMY
58866 +
58867 +#define CLS_PLAN_NUM_PER_GRP 8
58868 +
58869 +#define IP_OFFLOAD_PACKAGE_NUMBER 106
58870 +#define CAPWAP_OFFLOAD_PACKAGE_NUMBER 108
58871 +#define IS_OFFLOAD_PACKAGE(num) ((num == IP_OFFLOAD_PACKAGE_NUMBER) || (num == CAPWAP_OFFLOAD_PACKAGE_NUMBER))
58872 +
58873 +
58874 +
58875 +/**************************************************************************//**
58876 + @Description Modules registers offsets
58877 +*//***************************************************************************/
58878 +#define FM_MM_MURAM 0x00000000
58879 +#define FM_MM_BMI 0x00080000
58880 +#define FM_MM_QMI 0x00080400
58881 +#define FM_MM_PRS 0x000c7000
58882 +#define FM_MM_KG 0x000C1000
58883 +#define FM_MM_DMA 0x000C2000
58884 +#define FM_MM_FPM 0x000C3000
58885 +#define FM_MM_PLCR 0x000C0000
58886 +#define FM_MM_IMEM 0x000C4000
58887 +#define FM_MM_CGP 0x000DB000
58888 +#define FM_MM_TRB(i) (0x000D0200 + 0x400 * (i))
58889 +#if (DPAA_VERSION >= 11)
58890 +#define FM_MM_SP 0x000dc000
58891 +#endif /* (DPAA_VERSION >= 11) */
58892 +
58893 +
58894 +/**************************************************************************//**
58895 + @Description Enum for inter-module interrupts registration
58896 +*//***************************************************************************/
58897 +typedef enum e_FmEventModules{
58898 + e_FM_MOD_PRS, /**< Parser event */
58899 + e_FM_MOD_KG, /**< Keygen event */
58900 + e_FM_MOD_PLCR, /**< Policer event */
58901 + e_FM_MOD_10G_MAC, /**< 10G MAC event */
58902 + e_FM_MOD_1G_MAC, /**< 1G MAC event */
58903 + e_FM_MOD_TMR, /**< Timer event */
58904 + e_FM_MOD_FMAN_CTRL, /**< FMAN Controller Timer event */
58905 + e_FM_MOD_MACSEC,
58906 + e_FM_MOD_DUMMY_LAST
58907 +} e_FmEventModules;
58908 +
58909 +/**************************************************************************//**
58910 + @Description Enum for interrupts types
58911 +*//***************************************************************************/
58912 +typedef enum e_FmIntrType {
58913 + e_FM_INTR_TYPE_ERR,
58914 + e_FM_INTR_TYPE_NORMAL
58915 +} e_FmIntrType;
58916 +
58917 +/**************************************************************************//**
58918 + @Description Enum for inter-module interrupts registration
58919 +*//***************************************************************************/
58920 +typedef enum e_FmInterModuleEvent
58921 +{
58922 + e_FM_EV_PRS = 0, /**< Parser event */
58923 + e_FM_EV_ERR_PRS, /**< Parser error event */
58924 + e_FM_EV_KG, /**< Keygen event */
58925 + e_FM_EV_ERR_KG, /**< Keygen error event */
58926 + e_FM_EV_PLCR, /**< Policer event */
58927 + e_FM_EV_ERR_PLCR, /**< Policer error event */
58928 + e_FM_EV_ERR_10G_MAC0, /**< 10G MAC 0 error event */
58929 + e_FM_EV_ERR_10G_MAC1, /**< 10G MAC 1 error event */
58930 + e_FM_EV_ERR_1G_MAC0, /**< 1G MAC 0 error event */
58931 + e_FM_EV_ERR_1G_MAC1, /**< 1G MAC 1 error event */
58932 + e_FM_EV_ERR_1G_MAC2, /**< 1G MAC 2 error event */
58933 + e_FM_EV_ERR_1G_MAC3, /**< 1G MAC 3 error event */
58934 + e_FM_EV_ERR_1G_MAC4, /**< 1G MAC 4 error event */
58935 + e_FM_EV_ERR_1G_MAC5, /**< 1G MAC 5 error event */
58936 + e_FM_EV_ERR_1G_MAC6, /**< 1G MAC 6 error event */
58937 + e_FM_EV_ERR_1G_MAC7, /**< 1G MAC 7 error event */
58938 + e_FM_EV_ERR_MACSEC_MAC0,
58939 + e_FM_EV_TMR, /**< Timer event */
58940 + e_FM_EV_10G_MAC0, /**< 10G MAC 0 event (Magic packet detection)*/
58941 + e_FM_EV_10G_MAC1, /**< 10G MAC 1 event (Magic packet detection)*/
58942 + e_FM_EV_1G_MAC0, /**< 1G MAC 0 event (Magic packet detection)*/
58943 + e_FM_EV_1G_MAC1, /**< 1G MAC 1 event (Magic packet detection)*/
58944 + e_FM_EV_1G_MAC2, /**< 1G MAC 2 (Magic packet detection)*/
58945 + e_FM_EV_1G_MAC3, /**< 1G MAC 3 (Magic packet detection)*/
58946 + e_FM_EV_1G_MAC4, /**< 1G MAC 4 (Magic packet detection)*/
58947 + e_FM_EV_1G_MAC5, /**< 1G MAC 5 (Magic packet detection)*/
58948 + e_FM_EV_1G_MAC6, /**< 1G MAC 6 (Magic packet detection)*/
58949 + e_FM_EV_1G_MAC7, /**< 1G MAC 7 (Magic packet detection)*/
58950 + e_FM_EV_MACSEC_MAC0, /**< MACSEC MAC 0 event */
58951 + e_FM_EV_FMAN_CTRL_0, /**< Fman controller event 0 */
58952 + e_FM_EV_FMAN_CTRL_1, /**< Fman controller event 1 */
58953 + e_FM_EV_FMAN_CTRL_2, /**< Fman controller event 2 */
58954 + e_FM_EV_FMAN_CTRL_3, /**< Fman controller event 3 */
58955 + e_FM_EV_DUMMY_LAST
58956 +} e_FmInterModuleEvent;
58957 +
58958 +
58959 +#if defined(__MWERKS__) && !defined(__GNUC__)
58960 +#pragma pack(push,1)
58961 +#endif /* defined(__MWERKS__) && ... */
58962 +
58963 +/**************************************************************************//**
58964 + @Description PCD KG scheme registers
58965 +*//***************************************************************************/
58966 +typedef _Packed struct t_FmPcdPlcrProfileRegs {
58967 + volatile uint32_t fmpl_pemode; /* 0x090 FMPL_PEMODE - FM Policer Profile Entry Mode*/
58968 + volatile uint32_t fmpl_pegnia; /* 0x094 FMPL_PEGNIA - FM Policer Profile Entry GREEN Next Invoked Action*/
58969 + volatile uint32_t fmpl_peynia; /* 0x098 FMPL_PEYNIA - FM Policer Profile Entry YELLOW Next Invoked Action*/
58970 + volatile uint32_t fmpl_pernia; /* 0x09C FMPL_PERNIA - FM Policer Profile Entry RED Next Invoked Action*/
58971 + volatile uint32_t fmpl_pecir; /* 0x0A0 FMPL_PECIR - FM Policer Profile Entry Committed Information Rate*/
58972 + volatile uint32_t fmpl_pecbs; /* 0x0A4 FMPL_PECBS - FM Policer Profile Entry Committed Burst Size*/
58973 + volatile uint32_t fmpl_pepepir_eir; /* 0x0A8 FMPL_PEPIR_EIR - FM Policer Profile Entry Peak/Excess Information Rate*/
58974 + volatile uint32_t fmpl_pepbs_ebs; /* 0x0AC FMPL_PEPBS_EBS - FM Policer Profile Entry Peak/Excess Information Rate*/
58975 + volatile uint32_t fmpl_pelts; /* 0x0B0 FMPL_PELTS - FM Policer Profile Entry Last TimeStamp*/
58976 + volatile uint32_t fmpl_pects; /* 0x0B4 FMPL_PECTS - FM Policer Profile Entry Committed Token Status*/
58977 + volatile uint32_t fmpl_pepts_ets; /* 0x0B8 FMPL_PEPTS_ETS - FM Policer Profile Entry Peak/Excess Token Status*/
58978 + volatile uint32_t fmpl_pegpc; /* 0x0BC FMPL_PEGPC - FM Policer Profile Entry GREEN Packet Counter*/
58979 + volatile uint32_t fmpl_peypc; /* 0x0C0 FMPL_PEYPC - FM Policer Profile Entry YELLOW Packet Counter*/
58980 + volatile uint32_t fmpl_perpc; /* 0x0C4 FMPL_PERPC - FM Policer Profile Entry RED Packet Counter */
58981 + volatile uint32_t fmpl_perypc; /* 0x0C8 FMPL_PERYPC - FM Policer Profile Entry Recolored YELLOW Packet Counter*/
58982 + volatile uint32_t fmpl_perrpc; /* 0x0CC FMPL_PERRPC - FM Policer Profile Entry Recolored RED Packet Counter*/
58983 + volatile uint32_t fmpl_res1[12]; /* 0x0D0-0x0FF Reserved */
58984 +} _PackedType t_FmPcdPlcrProfileRegs;
58985 +
58986 +
58987 +typedef _Packed struct t_FmPcdCcCapwapReassmTimeoutParams {
58988 + volatile uint32_t portIdAndCapwapReassmTbl;
58989 + volatile uint32_t fqidForTimeOutFrames;
58990 + volatile uint32_t timeoutRequestTime;
58991 +}_PackedType t_FmPcdCcCapwapReassmTimeoutParams;
58992 +
58993 +/**************************************************************************//**
58994 + @Description PCD CTRL Parameters Page
58995 +*//***************************************************************************/
58996 +typedef _Packed struct t_FmPcdCtrlParamsPage {
58997 + volatile uint8_t reserved0[16];
58998 + volatile uint32_t iprIpv4Nia;
58999 + volatile uint32_t iprIpv6Nia;
59000 + volatile uint8_t reserved1[24];
59001 + volatile uint32_t ipfOptionsCounter;
59002 + volatile uint8_t reserved2[12];
59003 + volatile uint32_t misc;
59004 + volatile uint32_t errorsDiscardMask;
59005 + volatile uint32_t discardMask;
59006 + volatile uint8_t reserved3[4];
59007 + volatile uint32_t postBmiFetchNia;
59008 + volatile uint8_t reserved4[172];
59009 +} _PackedType t_FmPcdCtrlParamsPage;
59010 +
59011 +
59012 +
59013 +#if defined(__MWERKS__) && !defined(__GNUC__)
59014 +#pragma pack(pop)
59015 +#endif /* defined(__MWERKS__) && ... */
59016 +
59017 +
59018 +/*for UNDER_CONSTRUCTION_FM_RMU_USE_SEC its defined in fm_ext.h*/
59019 +typedef uint32_t t_FmFmanCtrl;
59020 +
59021 +#define FPM_PORT_FM_CTL1 0x00000001
59022 +#define FPM_PORT_FM_CTL2 0x00000002
59023 +
59024 +
59025 +
59026 +typedef struct t_FmPcdCcFragScratchPoolCmdParams {
59027 + uint32_t numOfBuffers;
59028 + uint8_t bufferPoolId;
59029 +} t_FmPcdCcFragScratchPoolCmdParams;
59030 +
59031 +typedef struct t_FmPcdCcReassmTimeoutParams {
59032 + bool activate;
59033 + uint8_t tsbs;
59034 + uint32_t iprcpt;
59035 +} t_FmPcdCcReassmTimeoutParams;
59036 +
59037 +typedef struct {
59038 + uint8_t baseEntry;
59039 + uint16_t numOfClsPlanEntries;
59040 + uint32_t vectors[FM_PCD_MAX_NUM_OF_CLS_PLANS];
59041 +} t_FmPcdKgInterModuleClsPlanSet;
59042 +
59043 +/**************************************************************************//**
59044 + @Description Structure for binding a port to keygen schemes.
59045 +*//***************************************************************************/
59046 +typedef struct t_FmPcdKgInterModuleBindPortToSchemes {
59047 + uint8_t hardwarePortId;
59048 + uint8_t netEnvId;
59049 + bool useClsPlan; /**< TRUE if this port uses the clsPlan mechanism */
59050 + uint8_t numOfSchemes;
59051 + uint8_t schemesIds[FM_PCD_KG_NUM_OF_SCHEMES];
59052 +} t_FmPcdKgInterModuleBindPortToSchemes;
59053 +
59054 +typedef struct {
59055 + uint32_t nextCcNodeInfo;
59056 + t_List node;
59057 +} t_CcNodeInfo;
59058 +
59059 +typedef struct
59060 +{
59061 + t_Handle h_CcNode;
59062 + uint16_t index;
59063 + t_List node;
59064 +}t_CcNodeInformation;
59065 +#define CC_NODE_F_OBJECT(ptr) LIST_OBJECT(ptr, t_CcNodeInformation, node)
59066 +
59067 +typedef enum e_ModifyState
59068 +{
59069 + e_MODIFY_STATE_ADD = 0,
59070 + e_MODIFY_STATE_REMOVE,
59071 + e_MODIFY_STATE_CHANGE
59072 +} e_ModifyState;
59073 +
59074 +typedef struct
59075 +{
59076 + t_Handle h_Manip;
59077 + t_List node;
59078 +}t_ManipInfo;
59079 +#define CC_NEXT_NODE_F_OBJECT(ptr) LIST_OBJECT(ptr, t_CcNodeInfo, node)
59080 +
59081 +typedef struct {
59082 + uint32_t type;
59083 + uint8_t prOffset;
59084 + uint16_t dataOffset;
59085 + uint8_t internalBufferOffset;
59086 + uint8_t numOfTasks;
59087 + uint8_t numOfExtraTasks;
59088 + uint8_t hardwarePortId;
59089 + t_FmRevisionInfo revInfo;
59090 + uint32_t nia;
59091 + uint32_t discardMask;
59092 +} t_GetCcParams;
59093 +
59094 +typedef struct {
59095 + uint32_t type;
59096 + int psoSize;
59097 + uint32_t nia;
59098 + t_FmFmanCtrl orFmanCtrl;
59099 + bool overwrite;
59100 + uint8_t ofpDpde;
59101 +} t_SetCcParams;
59102 +
59103 +typedef struct {
59104 + t_GetCcParams getCcParams;
59105 + t_SetCcParams setCcParams;
59106 +} t_FmPortGetSetCcParams;
59107 +
59108 +typedef struct {
59109 + uint32_t type;
59110 + bool sleep;
59111 +} t_FmSetParams;
59112 +
59113 +typedef struct {
59114 + uint32_t type;
59115 + uint32_t fmqm_gs;
59116 + uint32_t fm_npi;
59117 + uint32_t fm_cld;
59118 + uint32_t fmfp_extc;
59119 +} t_FmGetParams;
59120 +
59121 +typedef struct {
59122 + t_FmSetParams setParams;
59123 + t_FmGetParams getParams;
59124 +} t_FmGetSetParams;
59125 +
59126 +t_Error FmGetSetParams(t_Handle h_Fm, t_FmGetSetParams *p_Params);
59127 +
59128 +static __inline__ bool TRY_LOCK(t_Handle h_Spinlock, volatile bool *p_Flag)
59129 +{
59130 + uint32_t intFlags;
59131 + if (h_Spinlock)
59132 + intFlags = XX_LockIntrSpinlock(h_Spinlock);
59133 + else
59134 + intFlags = XX_DisableAllIntr();
59135 +
59136 + if (*p_Flag)
59137 + {
59138 + if (h_Spinlock)
59139 + XX_UnlockIntrSpinlock(h_Spinlock, intFlags);
59140 + else
59141 + XX_RestoreAllIntr(intFlags);
59142 + return FALSE;
59143 + }
59144 + *p_Flag = TRUE;
59145 +
59146 + if (h_Spinlock)
59147 + XX_UnlockIntrSpinlock(h_Spinlock, intFlags);
59148 + else
59149 + XX_RestoreAllIntr(intFlags);
59150 +
59151 + return TRUE;
59152 +}
59153 +
59154 +#define RELEASE_LOCK(_flag) _flag = FALSE;
59155 +
59156 +/**************************************************************************//**
59157 + @Collection Defines used for manipulation CC and BMI
59158 + @{
59159 +*//***************************************************************************/
59160 +#define INTERNAL_CONTEXT_OFFSET 0x80000000
59161 +#define OFFSET_OF_PR 0x40000000
59162 +#define MANIP_EXTRA_SPACE 0x20000000
59163 +#define NUM_OF_TASKS 0x10000000
59164 +#define OFFSET_OF_DATA 0x08000000
59165 +#define HW_PORT_ID 0x04000000
59166 +#define FM_REV 0x02000000
59167 +#define GET_NIA_FPNE 0x01000000
59168 +#define GET_NIA_PNDN 0x00800000
59169 +#define NUM_OF_EXTRA_TASKS 0x00400000
59170 +#define DISCARD_MASK 0x00200000
59171 +
59172 +#define UPDATE_NIA_PNEN 0x80000000
59173 +#define UPDATE_PSO 0x40000000
59174 +#define UPDATE_NIA_PNDN 0x20000000
59175 +#define UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY 0x10000000
59176 +#define UPDATE_OFP_DPTE 0x08000000
59177 +#define UPDATE_NIA_FENE 0x04000000
59178 +#define UPDATE_NIA_CMNE 0x02000000
59179 +#define UPDATE_NIA_FPNE 0x01000000
59180 +/* @} */
59181 +
59182 +/**************************************************************************//**
59183 + @Collection Defines used for manipulation CC and CC
59184 + @{
59185 +*//***************************************************************************/
59186 +#define UPDATE_NIA_ENQ_WITHOUT_DMA 0x80000000
59187 +#define UPDATE_CC_WITH_TREE 0x40000000
59188 +#define UPDATE_CC_WITH_DELETE_TREE 0x20000000
59189 +#define UPDATE_KG_NIA_CC_WA 0x10000000
59190 +#define UPDATE_KG_OPT_MODE 0x08000000
59191 +#define UPDATE_KG_NIA 0x04000000
59192 +#define UPDATE_CC_SHADOW_CLEAR 0x02000000
59193 +/* @} */
59194 +
59195 +#define UPDATE_FPM_BRKC_SLP 0x80000000
59196 +#define UPDATE_FPM_EXTC 0x40000000
59197 +#define UPDATE_FPM_EXTC_CLEAR 0x20000000
59198 +#define GET_FMQM_GS 0x10000000
59199 +#define GET_FM_NPI 0x08000000
59200 +#define GET_FMFP_EXTC 0x04000000
59201 +#define CLEAR_IRAM_READY 0x02000000
59202 +#define UPDATE_FM_CLD 0x01000000
59203 +#define GET_FM_CLD 0x00800000
59204 +#define FM_MAX_NUM_OF_PORTS (FM_MAX_NUM_OF_OH_PORTS + \
59205 + FM_MAX_NUM_OF_1G_RX_PORTS + \
59206 + FM_MAX_NUM_OF_10G_RX_PORTS + \
59207 + FM_MAX_NUM_OF_1G_TX_PORTS + \
59208 + FM_MAX_NUM_OF_10G_TX_PORTS)
59209 +
59210 +#define MODULE_NAME_SIZE 30
59211 +#define DUMMY_PORT_ID 0
59212 +
59213 +#define FM_LIODN_OFFSET_MASK 0x3FF
59214 +
59215 +/**************************************************************************//**
59216 + @Description NIA Description
59217 +*//***************************************************************************/
59218 +#define NIA_ENG_MASK 0x007C0000
59219 +#define NIA_AC_MASK 0x0003ffff
59220 +
59221 +#define NIA_ORDER_RESTOR 0x00800000
59222 +#define NIA_ENG_FM_CTL 0x00000000
59223 +#define NIA_ENG_PRS 0x00440000
59224 +#define NIA_ENG_KG 0x00480000
59225 +#define NIA_ENG_PLCR 0x004C0000
59226 +#define NIA_ENG_BMI 0x00500000
59227 +#define NIA_ENG_QMI_ENQ 0x00540000
59228 +#define NIA_ENG_QMI_DEQ 0x00580000
59229 +
59230 +#define NIA_FM_CTL_AC_CC 0x00000006
59231 +#define NIA_FM_CTL_AC_HC 0x0000000C
59232 +#define NIA_FM_CTL_AC_IND_MODE_TX 0x00000008
59233 +#define NIA_FM_CTL_AC_IND_MODE_RX 0x0000000A
59234 +#define NIA_FM_CTL_AC_POP_TO_N_STEP 0x0000000e
59235 +#define NIA_FM_CTL_AC_PRE_BMI_FETCH_HEADER 0x00000010
59236 +#define NIA_FM_CTL_AC_PRE_BMI_FETCH_FULL_FRAME 0x00000018
59237 +#define NIA_FM_CTL_AC_POST_BMI_FETCH 0x00000012
59238 +#define NIA_FM_CTL_AC_PRE_BMI_ENQ_FRAME 0x0000001A
59239 +#define NIA_FM_CTL_AC_PRE_BMI_DISCARD_FRAME 0x0000001E
59240 +#define NIA_FM_CTL_AC_POST_BMI_ENQ_ORR 0x00000014
59241 +#define NIA_FM_CTL_AC_POST_BMI_ENQ 0x00000022
59242 +#define NIA_FM_CTL_AC_PRE_CC 0x00000020
59243 +#define NIA_FM_CTL_AC_POST_TX 0x00000024
59244 +/* V3 only */
59245 +#define NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME 0x00000028
59246 +#define NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_DISCARD_FRAME 0x0000002A
59247 +#define NIA_FM_CTL_AC_NO_IPACC_POP_TO_N_STEP 0x0000002C
59248 +
59249 +#define NIA_BMI_AC_ENQ_FRAME 0x00000002
59250 +#define NIA_BMI_AC_TX_RELEASE 0x000002C0
59251 +#define NIA_BMI_AC_RELEASE 0x000000C0
59252 +#define NIA_BMI_AC_DISCARD 0x000000C1
59253 +#define NIA_BMI_AC_TX 0x00000274
59254 +#define NIA_BMI_AC_FETCH 0x00000208
59255 +#define NIA_BMI_AC_MASK 0x000003FF
59256 +
59257 +#define NIA_KG_DIRECT 0x00000100
59258 +#define NIA_KG_CC_EN 0x00000200
59259 +#define NIA_PLCR_ABSOLUTE 0x00008000
59260 +
59261 +#define NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA 0x00000202
59262 +
59263 +#if defined(FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675) || defined(FM_ERROR_VSP_NO_MATCH_SW006)
59264 +#define GET_NIA_BMI_AC_ENQ_FRAME(h_FmPcd) \
59265 + (uint32_t)((FmPcdIsAdvancedOffloadSupported(h_FmPcd)) ? \
59266 + (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_PRE_BMI_ENQ_FRAME) : \
59267 + (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME))
59268 +#define GET_NIA_BMI_AC_DISCARD_FRAME(h_FmPcd) \
59269 + (uint32_t)((FmPcdIsAdvancedOffloadSupported(h_FmPcd)) ? \
59270 + (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_PRE_BMI_DISCARD_FRAME) : \
59271 + (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_DISCARD_FRAME))
59272 +#define GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME() \
59273 + (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME)
59274 +#else
59275 +#define GET_NIA_BMI_AC_ENQ_FRAME(h_FmPcd) \
59276 + (uint32_t)((FmPcdIsAdvancedOffloadSupported(h_FmPcd)) ? \
59277 + (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_PRE_BMI_ENQ_FRAME) : \
59278 + (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME))
59279 +#define GET_NIA_BMI_AC_DISCARD_FRAME(h_FmPcd) \
59280 + (uint32_t)((FmPcdIsAdvancedOffloadSupported(h_FmPcd)) ? \
59281 + (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_PRE_BMI_DISCARD_FRAME) : \
59282 + (NIA_ENG_BMI | NIA_BMI_AC_DISCARD))
59283 +#define GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME() \
59284 + (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)
59285 +#endif /* defined(FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675) || ... */
59286 +
59287 +/**************************************************************************//**
59288 + @Description CTRL Parameters Page defines
59289 +*//***************************************************************************/
59290 +#define FM_CTL_PARAMS_PAGE_OP_FIX_EN 0x80000000
59291 +#define FM_CTL_PARAMS_PAGE_OFFLOAD_SUPPORT_EN 0x40000000
59292 +#define FM_CTL_PARAMS_PAGE_ALWAYS_ON 0x00000100
59293 +
59294 +#define FM_CTL_PARAMS_PAGE_ERROR_VSP_MASK 0x0000003f
59295 +
59296 +/**************************************************************************//**
59297 + @Description Port Id defines
59298 +*//***************************************************************************/
59299 +#if (DPAA_VERSION == 10)
59300 +#define BASE_OH_PORTID 1
59301 +#else
59302 +#define BASE_OH_PORTID 2
59303 +#endif /* (DPAA_VERSION == 10) */
59304 +#define BASE_1G_RX_PORTID 8
59305 +#define BASE_10G_RX_PORTID 0x10
59306 +#define BASE_1G_TX_PORTID 0x28
59307 +#define BASE_10G_TX_PORTID 0x30
59308 +
59309 +#define FM_PCD_PORT_OH_BASE_INDX 0
59310 +#define FM_PCD_PORT_1G_RX_BASE_INDX (FM_PCD_PORT_OH_BASE_INDX+FM_MAX_NUM_OF_OH_PORTS)
59311 +#define FM_PCD_PORT_10G_RX_BASE_INDX (FM_PCD_PORT_1G_RX_BASE_INDX+FM_MAX_NUM_OF_1G_RX_PORTS)
59312 +#define FM_PCD_PORT_1G_TX_BASE_INDX (FM_PCD_PORT_10G_RX_BASE_INDX+FM_MAX_NUM_OF_10G_RX_PORTS)
59313 +#define FM_PCD_PORT_10G_TX_BASE_INDX (FM_PCD_PORT_1G_TX_BASE_INDX+FM_MAX_NUM_OF_1G_TX_PORTS)
59314 +
59315 +#if (FM_MAX_NUM_OF_OH_PORTS > 0)
59316 +#define CHECK_PORT_ID_OH_PORTS(_relativePortId) \
59317 + if ((_relativePortId) >= FM_MAX_NUM_OF_OH_PORTS) \
59318 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal OH_PORT port id"))
59319 +#else
59320 +#define CHECK_PORT_ID_OH_PORTS(_relativePortId) \
59321 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal OH_PORT port id"))
59322 +#endif
59323 +#if (FM_MAX_NUM_OF_1G_RX_PORTS > 0)
59324 +#define CHECK_PORT_ID_1G_RX_PORTS(_relativePortId) \
59325 + if ((_relativePortId) >= FM_MAX_NUM_OF_1G_RX_PORTS) \
59326 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 1G_RX_PORT port id"))
59327 +#else
59328 +#define CHECK_PORT_ID_1G_RX_PORTS(_relativePortId) \
59329 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 1G_RX_PORT port id"))
59330 +#endif
59331 +#if (FM_MAX_NUM_OF_10G_RX_PORTS > 0)
59332 +#define CHECK_PORT_ID_10G_RX_PORTS(_relativePortId) \
59333 + if ((_relativePortId) >= FM_MAX_NUM_OF_10G_RX_PORTS) \
59334 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 10G_RX_PORT port id"))
59335 +#else
59336 +#define CHECK_PORT_ID_10G_RX_PORTS(_relativePortId) \
59337 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 10G_RX_PORT port id"))
59338 +#endif
59339 +#if (FM_MAX_NUM_OF_1G_TX_PORTS > 0)
59340 +#define CHECK_PORT_ID_1G_TX_PORTS(_relativePortId) \
59341 + if ((_relativePortId) >= FM_MAX_NUM_OF_1G_TX_PORTS) \
59342 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 1G_TX_PORT port id"))
59343 +#else
59344 +#define CHECK_PORT_ID_1G_TX_PORTS(_relativePortId) \
59345 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 1G_TX_PORT port id"))
59346 +#endif
59347 +#if (FM_MAX_NUM_OF_10G_TX_PORTS > 0)
59348 +#define CHECK_PORT_ID_10G_TX_PORTS(_relativePortId) \
59349 + if ((_relativePortId) >= FM_MAX_NUM_OF_10G_TX_PORTS) \
59350 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 10G_TX_PORT port id"))
59351 +#else
59352 +#define CHECK_PORT_ID_10G_TX_PORTS(_relativePortId) \
59353 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 10G_TX_PORT port id"))
59354 +#endif
59355 +
59356 +uint8_t SwPortIdToHwPortId(e_FmPortType type, uint8_t relativePortId, uint8_t majorRev, uint8_t minorRev);
59357 +
59358 +#define HW_PORT_ID_TO_SW_PORT_ID(_relativePortId, hardwarePortId) \
59359 +{ if (((hardwarePortId) >= BASE_OH_PORTID) && \
59360 + ((hardwarePortId) < BASE_OH_PORTID+FM_MAX_NUM_OF_OH_PORTS)) \
59361 + _relativePortId = (uint8_t)((hardwarePortId)-BASE_OH_PORTID); \
59362 + else if (((hardwarePortId) >= BASE_10G_TX_PORTID) && \
59363 + ((hardwarePortId) < BASE_10G_TX_PORTID+FM_MAX_NUM_OF_10G_TX_PORTS)) \
59364 + _relativePortId = (uint8_t)((hardwarePortId)-BASE_10G_TX_PORTID); \
59365 + else if (((hardwarePortId) >= BASE_1G_TX_PORTID) && \
59366 + ((hardwarePortId) < BASE_1G_TX_PORTID+FM_MAX_NUM_OF_1G_TX_PORTS)) \
59367 + _relativePortId = (uint8_t)((hardwarePortId)-BASE_1G_TX_PORTID); \
59368 + else if (((hardwarePortId) >= BASE_10G_RX_PORTID) && \
59369 + ((hardwarePortId) < BASE_10G_RX_PORTID+FM_MAX_NUM_OF_10G_RX_PORTS)) \
59370 + _relativePortId = (uint8_t)((hardwarePortId)-BASE_10G_RX_PORTID); \
59371 + else if (((hardwarePortId) >= BASE_1G_RX_PORTID) && \
59372 + ((hardwarePortId) < BASE_1G_RX_PORTID+FM_MAX_NUM_OF_1G_RX_PORTS)) \
59373 + _relativePortId = (uint8_t)((hardwarePortId)-BASE_1G_RX_PORTID); \
59374 + else { \
59375 + _relativePortId = (uint8_t)DUMMY_PORT_ID; \
59376 + ASSERT_COND(TRUE); \
59377 + } \
59378 +}
59379 +
59380 +#define HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId) \
59381 +do { \
59382 + if (((hardwarePortId) >= BASE_OH_PORTID) && ((hardwarePortId) < BASE_OH_PORTID+FM_MAX_NUM_OF_OH_PORTS)) \
59383 + swPortIndex = (uint8_t)((hardwarePortId)-BASE_OH_PORTID+FM_PCD_PORT_OH_BASE_INDX); \
59384 + else if (((hardwarePortId) >= BASE_1G_RX_PORTID) && \
59385 + ((hardwarePortId) < BASE_1G_RX_PORTID+FM_MAX_NUM_OF_1G_RX_PORTS)) \
59386 + swPortIndex = (uint8_t)((hardwarePortId)-BASE_1G_RX_PORTID+FM_PCD_PORT_1G_RX_BASE_INDX); \
59387 + else if (((hardwarePortId) >= BASE_10G_RX_PORTID) && \
59388 + ((hardwarePortId) < BASE_10G_RX_PORTID+FM_MAX_NUM_OF_10G_RX_PORTS)) \
59389 + swPortIndex = (uint8_t)((hardwarePortId)-BASE_10G_RX_PORTID+FM_PCD_PORT_10G_RX_BASE_INDX); \
59390 + else if (((hardwarePortId) >= BASE_1G_TX_PORTID) && \
59391 + ((hardwarePortId) < BASE_1G_TX_PORTID+FM_MAX_NUM_OF_1G_TX_PORTS)) \
59392 + swPortIndex = (uint8_t)((hardwarePortId)-BASE_1G_TX_PORTID+FM_PCD_PORT_1G_TX_BASE_INDX); \
59393 + else if (((hardwarePortId) >= BASE_10G_TX_PORTID) && \
59394 + ((hardwarePortId) < BASE_10G_TX_PORTID+FM_MAX_NUM_OF_10G_TX_PORTS)) \
59395 + swPortIndex = (uint8_t)((hardwarePortId)-BASE_10G_TX_PORTID+FM_PCD_PORT_10G_TX_BASE_INDX); \
59396 + else ASSERT_COND(FALSE); \
59397 +} while (0)
59398 +
59399 +#define SW_PORT_INDX_TO_HW_PORT_ID(hardwarePortId, swPortIndex) \
59400 +do { \
59401 + if (((swPortIndex) >= FM_PCD_PORT_OH_BASE_INDX) && ((swPortIndex) < FM_PCD_PORT_1G_RX_BASE_INDX)) \
59402 + hardwarePortId = (uint8_t)((swPortIndex)-FM_PCD_PORT_OH_BASE_INDX+BASE_OH_PORTID); \
59403 + else if (((swPortIndex) >= FM_PCD_PORT_1G_RX_BASE_INDX) && ((swPortIndex) < FM_PCD_PORT_10G_RX_BASE_INDX)) \
59404 + hardwarePortId = (uint8_t)((swPortIndex)-FM_PCD_PORT_1G_RX_BASE_INDX+BASE_1G_RX_PORTID); \
59405 + else if (((swPortIndex) >= FM_PCD_PORT_10G_RX_BASE_INDX) && ((swPortIndex) < FM_MAX_NUM_OF_PORTS)) \
59406 + hardwarePortId = (uint8_t)((swPortIndex)-FM_PCD_PORT_10G_RX_BASE_INDX+BASE_10G_RX_PORTID); \
59407 + else if (((swPortIndex) >= FM_PCD_PORT_1G_TX_BASE_INDX) && ((swPortIndex) < FM_PCD_PORT_10G_TX_BASE_INDX)) \
59408 + hardwarePortId = (uint8_t)((swPortIndex)-FM_PCD_PORT_1G_TX_BASE_INDX+BASE_1G_TX_PORTID); \
59409 + else if (((swPortIndex) >= FM_PCD_PORT_10G_TX_BASE_INDX) && ((swPortIndex) < FM_MAX_NUM_OF_PORTS)) \
59410 + hardwarePortId = (uint8_t)((swPortIndex)-FM_PCD_PORT_10G_TX_BASE_INDX+BASE_10G_TX_PORTID); \
59411 + else ASSERT_COND(FALSE); \
59412 +} while (0)
59413 +
59414 +#define BMI_MAX_FIFO_SIZE (FM_MURAM_SIZE)
59415 +#define BMI_FIFO_UNITS 0x100
59416 +
59417 +typedef struct {
59418 + void (*f_Isr) (t_Handle h_Arg);
59419 + t_Handle h_SrcHandle;
59420 + uint8_t guestId;
59421 +} t_FmIntrSrc;
59422 +
59423 +#define ILLEGAL_HDR_NUM 0xFF
59424 +#define NO_HDR_NUM FM_PCD_PRS_NUM_OF_HDRS
59425 +
59426 +#define IS_PRIVATE_HEADER(hdr) (((hdr) == HEADER_TYPE_USER_DEFINED_SHIM1) || \
59427 + ((hdr) == HEADER_TYPE_USER_DEFINED_SHIM2))
59428 +#define IS_SPECIAL_HEADER(hdr) ((hdr) == HEADER_TYPE_MACSEC)
59429 +
59430 +static __inline__ uint8_t GetPrsHdrNum(e_NetHeaderType hdr)
59431 +{
59432 + switch (hdr)
59433 + { case (HEADER_TYPE_ETH): return 0;
59434 + case (HEADER_TYPE_LLC_SNAP): return 1;
59435 + case (HEADER_TYPE_VLAN): return 2;
59436 + case (HEADER_TYPE_PPPoE): return 3;
59437 + case (HEADER_TYPE_PPP): return 3;
59438 + case (HEADER_TYPE_MPLS): return 4;
59439 + case (HEADER_TYPE_IPv4): return 5;
59440 + case (HEADER_TYPE_IPv6): return 6;
59441 + case (HEADER_TYPE_GRE): return 7;
59442 + case (HEADER_TYPE_MINENCAP): return 8;
59443 + case (HEADER_TYPE_USER_DEFINED_L3): return 9;
59444 + case (HEADER_TYPE_TCP): return 10;
59445 + case (HEADER_TYPE_UDP): return 11;
59446 + case (HEADER_TYPE_IPSEC_AH):
59447 + case (HEADER_TYPE_IPSEC_ESP): return 12;
59448 + case (HEADER_TYPE_SCTP): return 13;
59449 + case (HEADER_TYPE_DCCP): return 14;
59450 + case (HEADER_TYPE_USER_DEFINED_L4): return 15;
59451 + case (HEADER_TYPE_USER_DEFINED_SHIM1):
59452 + case (HEADER_TYPE_USER_DEFINED_SHIM2):
59453 + case (HEADER_TYPE_MACSEC): return NO_HDR_NUM;
59454 + default:
59455 + return ILLEGAL_HDR_NUM;
59456 + }
59457 +}
59458 +
59459 +#define FM_PCD_MAX_NUM_OF_OPTIONS(clsPlanEntries) ((clsPlanEntries==256)? 8:((clsPlanEntries==128)? 7: ((clsPlanEntries==64)? 6: ((clsPlanEntries==32)? 5:0))))
59460 +
59461 +
59462 +/**************************************************************************//**
59463 + @Description A structure for initializing a keygen classification plan group
59464 +*//***************************************************************************/
59465 +typedef struct t_FmPcdKgInterModuleClsPlanGrpParams {
59466 + uint8_t netEnvId; /* IN */
59467 + bool grpExists; /* OUT (unused in FmPcdKgBuildClsPlanGrp)*/
59468 + uint8_t clsPlanGrpId; /* OUT */
59469 + bool emptyClsPlanGrp; /* OUT */
59470 + uint8_t numOfOptions; /* OUT in FmPcdGetSetClsPlanGrpParams IN in FmPcdKgBuildClsPlanGrp*/
59471 + protocolOpt_t options[FM_PCD_MAX_NUM_OF_OPTIONS(FM_PCD_MAX_NUM_OF_CLS_PLANS)];
59472 + /* OUT in FmPcdGetSetClsPlanGrpParams IN in FmPcdKgBuildClsPlanGrp*/
59473 + uint32_t optVectors[FM_PCD_MAX_NUM_OF_OPTIONS(FM_PCD_MAX_NUM_OF_CLS_PLANS)];
59474 + /* OUT in FmPcdGetSetClsPlanGrpParams IN in FmPcdKgBuildClsPlanGrp*/
59475 +} t_FmPcdKgInterModuleClsPlanGrpParams;
59476 +
59477 +typedef struct t_FmPcdLock {
59478 + t_Handle h_Spinlock;
59479 + volatile bool flag;
59480 + t_List node;
59481 +} t_FmPcdLock;
59482 +#define FM_PCD_LOCK_OBJ(ptr) LIST_OBJECT(ptr, t_FmPcdLock, node)
59483 +
59484 +
59485 +typedef t_Error (t_FmPortGetSetCcParamsCallback) (t_Handle h_FmPort,
59486 + t_FmPortGetSetCcParams *p_FmPortGetSetCcParams);
59487 +
59488 +
59489 +/***********************************************************************/
59490 +/* Common API for FM-PCD module */
59491 +/***********************************************************************/
59492 +t_Handle FmPcdGetHcHandle(t_Handle h_FmPcd);
59493 +uint32_t FmPcdGetSwPrsOffset(t_Handle h_FmPcd, e_NetHeaderType hdr, uint8_t indexPerHdr);
59494 +uint32_t FmPcdGetLcv(t_Handle h_FmPcd, uint32_t netEnvId, uint8_t hdrNum);
59495 +uint32_t FmPcdGetMacsecLcv(t_Handle h_FmPcd, uint32_t netEnvId);
59496 +void FmPcdIncNetEnvOwners(t_Handle h_FmPcd, uint8_t netEnvId);
59497 +void FmPcdDecNetEnvOwners(t_Handle h_FmPcd, uint8_t netEnvId);
59498 +uint8_t FmPcdGetNetEnvId(t_Handle h_NetEnv);
59499 +void FmPcdPortRegister(t_Handle h_FmPcd, t_Handle h_FmPort, uint8_t hardwarePortId);
59500 +uint32_t FmPcdLock(t_Handle h_FmPcd);
59501 +void FmPcdUnlock(t_Handle h_FmPcd, uint32_t intFlags);
59502 +bool FmPcdNetEnvIsHdrExist(t_Handle h_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr);
59503 +t_Error FmPcdFragHcScratchPoolInit(t_Handle h_FmPcd, uint8_t scratchBpid);
59504 +t_Error FmPcdRegisterReassmPort(t_Handle h_FmPcd, t_Handle h_IpReasmCommonPramTbl);
59505 +t_Error FmPcdUnregisterReassmPort(t_Handle h_FmPcd, t_Handle h_IpReasmCommonPramTbl);
59506 +bool FmPcdIsAdvancedOffloadSupported(t_Handle h_FmPcd);
59507 +bool FmPcdLockTryLockAll(t_Handle h_FmPcd);
59508 +void FmPcdLockUnlockAll(t_Handle h_FmPcd);
59509 +t_Error FmPcdHcSync(t_Handle h_FmPcd);
59510 +t_Handle FmGetPcd(t_Handle h_Fm);
59511 +/***********************************************************************/
59512 +/* Common API for FM-PCD KG module */
59513 +/***********************************************************************/
59514 +uint8_t FmPcdKgGetClsPlanGrpBase(t_Handle h_FmPcd, uint8_t clsPlanGrp);
59515 +uint16_t FmPcdKgGetClsPlanGrpSize(t_Handle h_FmPcd, uint8_t clsPlanGrp);
59516 +t_Error FmPcdKgBuildClsPlanGrp(t_Handle h_FmPcd, t_FmPcdKgInterModuleClsPlanGrpParams *p_Grp, t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet);
59517 +
59518 +uint8_t FmPcdKgGetSchemeId(t_Handle h_Scheme);
59519 +#if (DPAA_VERSION >= 11)
59520 +bool FmPcdKgGetVspe(t_Handle h_Scheme);
59521 +#endif /* (DPAA_VERSION >= 11) */
59522 +uint8_t FmPcdKgGetRelativeSchemeId(t_Handle h_FmPcd, uint8_t schemeId);
59523 +void FmPcdKgDestroyClsPlanGrp(t_Handle h_FmPcd, uint8_t grpId);
59524 +t_Error FmPcdKgCheckInvalidateSchemeSw(t_Handle h_Scheme);
59525 +t_Error FmPcdKgBuildBindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_BindPortToSchemes, uint32_t *p_SpReg, bool add);
59526 +bool FmPcdKgHwSchemeIsValid(uint32_t schemeModeReg);
59527 +uint32_t FmPcdKgBuildWriteSchemeActionReg(uint8_t schemeId, bool updateCounter);
59528 +uint32_t FmPcdKgBuildReadSchemeActionReg(uint8_t schemeId);
59529 +uint32_t FmPcdKgBuildWriteClsPlanBlockActionReg(uint8_t grpId);
59530 +uint32_t FmPcdKgBuildWritePortSchemeBindActionReg(uint8_t hardwarePortId);
59531 +uint32_t FmPcdKgBuildReadPortSchemeBindActionReg(uint8_t hardwarePortId);
59532 +uint32_t FmPcdKgBuildWritePortClsPlanBindActionReg(uint8_t hardwarePortId);
59533 +bool FmPcdKgIsSchemeValidSw(t_Handle h_Scheme);
59534 +
59535 +t_Error FmPcdKgBindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind);
59536 +t_Error FmPcdKgUnbindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind);
59537 +uint32_t FmPcdKgGetRequiredAction(t_Handle h_FmPcd, uint8_t schemeId);
59538 +uint32_t FmPcdKgGetRequiredActionFlag(t_Handle h_FmPcd, uint8_t schemeId);
59539 +e_FmPcdDoneAction FmPcdKgGetDoneAction(t_Handle h_FmPcd, uint8_t schemeId);
59540 +e_FmPcdEngine FmPcdKgGetNextEngine(t_Handle h_FmPcd, uint8_t schemeId);
59541 +void FmPcdKgUpdateRequiredAction(t_Handle h_Scheme, uint32_t requiredAction);
59542 +bool FmPcdKgIsDirectPlcr(t_Handle h_FmPcd, uint8_t schemeId);
59543 +bool FmPcdKgIsDistrOnPlcrProfile(t_Handle h_FmPcd, uint8_t schemeId);
59544 +uint16_t FmPcdKgGetRelativeProfileId(t_Handle h_FmPcd, uint8_t schemeId);
59545 +t_Handle FmPcdKgGetSchemeHandle(t_Handle h_FmPcd, uint8_t relativeSchemeId);
59546 +bool FmPcdKgIsSchemeHasOwners(t_Handle h_Scheme);
59547 +t_Error FmPcdKgCcGetSetParams(t_Handle h_FmPcd, t_Handle h_Scheme, uint32_t requiredAction, uint32_t value);
59548 +t_Error FmPcdKgSetOrBindToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t netEnvId, protocolOpt_t *p_OptArray, uint8_t *p_ClsPlanGrpId, bool *p_IsEmptyClsPlanGrp);
59549 +t_Error FmPcdKgDeleteOrUnbindPortToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t clsPlanGrpId);
59550 +
59551 +/***********************************************************************/
59552 +/* Common API for FM-PCD parser module */
59553 +/***********************************************************************/
59554 +t_Error FmPcdPrsIncludePortInStatistics(t_Handle p_FmPcd, uint8_t hardwarePortId, bool include);
59555 +
59556 +/***********************************************************************/
59557 +/* Common API for FM-PCD policer module */
59558 +/***********************************************************************/
59559 +t_Error FmPcdPlcrAllocProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId, uint16_t numOfProfiles);
59560 +t_Error FmPcdPlcrFreeProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId);
59561 +bool FmPcdPlcrIsProfileValid(t_Handle h_FmPcd, uint16_t absoluteProfileId);
59562 +uint16_t FmPcdPlcrGetPortProfilesBase(t_Handle h_FmPcd, uint8_t hardwarePortId);
59563 +uint16_t FmPcdPlcrGetPortNumOfProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId);
59564 +uint32_t FmPcdPlcrBuildWritePlcrActionRegs(uint16_t absoluteProfileId);
59565 +uint32_t FmPcdPlcrBuildCounterProfileReg(e_FmPcdPlcrProfileCounters counter);
59566 +uint32_t FmPcdPlcrBuildWritePlcrActionReg(uint16_t absoluteProfileId);
59567 +uint32_t FmPcdPlcrBuildReadPlcrActionReg(uint16_t absoluteProfileId);
59568 +uint16_t FmPcdPlcrProfileGetAbsoluteId(t_Handle h_Profile);
59569 +t_Error FmPcdPlcrGetAbsoluteIdByProfileParams(t_Handle h_FmPcd,
59570 + e_FmPcdProfileTypeSelection profileType,
59571 + t_Handle h_FmPort,
59572 + uint16_t relativeProfile,
59573 + uint16_t *p_AbsoluteId);
59574 +void FmPcdPlcrInvalidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId);
59575 +void FmPcdPlcrValidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId);
59576 +bool FmPcdPlcrHwProfileIsValid(uint32_t profileModeReg);
59577 +uint32_t FmPcdPlcrGetRequiredAction(t_Handle h_FmPcd, uint16_t absoluteProfileId);
59578 +uint32_t FmPcdPlcrGetRequiredActionFlag(t_Handle h_FmPcd, uint16_t absoluteProfileId);
59579 +uint32_t FmPcdPlcrBuildNiaProfileReg(bool green, bool yellow, bool red);
59580 +void FmPcdPlcrUpdateRequiredAction(t_Handle h_FmPcd, uint16_t absoluteProfileId, uint32_t requiredAction);
59581 +t_Error FmPcdPlcrCcGetSetParams(t_Handle h_FmPcd, uint16_t profileIndx,uint32_t requiredAction);
59582 +
59583 +/***********************************************************************/
59584 +/* Common API for FM-PCD CC module */
59585 +/***********************************************************************/
59586 +uint8_t FmPcdCcGetParseCode(t_Handle h_CcNode);
59587 +uint8_t FmPcdCcGetOffset(t_Handle h_CcNode);
59588 +t_Error FmPcdCcRemoveKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint16_t keyIndex);
59589 +t_Error FmPcdCcAddKey(t_Handle h_FmPcd, t_Handle h_CcNode, uint16_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_FmPCdCcKeyParams);
59590 +t_Error FmPcdCcModifyKey(t_Handle h_FmPcd, t_Handle h_CcNode, uint16_t keyIndex, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask);
59591 +t_Error FmPcdCcModifyKeyAndNextEngine(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint16_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_FmPcdCcKeyParams);
59592 +t_Error FmPcdCcModifyMissNextEngineParamNode(t_Handle h_FmPcd,t_Handle h_FmPcdCcNode, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
59593 +t_Error FmPcdCcModifyNextEngineParamTree(t_Handle h_FmPcd, t_Handle h_FmPcdCcTree, uint8_t grpId, uint8_t index, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
59594 +uint32_t FmPcdCcGetNodeAddrOffsetFromNodeInfo(t_Handle h_FmPcd, t_Handle h_Pointer);
59595 +t_Handle FmPcdCcTreeGetSavedManipParams(t_Handle h_FmTree);
59596 +void FmPcdCcTreeSetSavedManipParams(t_Handle h_FmTree, t_Handle h_SavedManipParams);
59597 +t_Error FmPcdCcTreeAddIPR(t_Handle h_FmPcd, t_Handle h_FmTree, t_Handle h_NetEnv, t_Handle h_ReassemblyManip, bool schemes);
59598 +t_Error FmPcdCcTreeAddCPR(t_Handle h_FmPcd, t_Handle h_FmTree, t_Handle h_NetEnv, t_Handle h_ReassemblyManip, bool schemes);
59599 +t_Error FmPcdCcBindTree(t_Handle h_FmPcd, t_Handle h_PcdParams, t_Handle h_CcTree, uint32_t *p_Offset,t_Handle h_FmPort);
59600 +t_Error FmPcdCcUnbindTree(t_Handle h_FmPcd, t_Handle h_CcTree);
59601 +
59602 +/***********************************************************************/
59603 +/* Common API for FM-PCD Manip module */
59604 +/***********************************************************************/
59605 +t_Error FmPcdManipUpdate(t_Handle h_FmPcd, t_Handle h_PcdParams, t_Handle h_FmPort, t_Handle h_Manip, t_Handle h_Ad, bool validate, int level, t_Handle h_FmTree, bool modify);
59606 +
59607 +/***********************************************************************/
59608 +/* Common API for FM-Port module */
59609 +/***********************************************************************/
59610 +#if (DPAA_VERSION >= 11)
59611 +typedef enum e_FmPortGprFuncType
59612 +{
59613 + e_FM_PORT_GPR_EMPTY = 0,
59614 + e_FM_PORT_GPR_MURAM_PAGE
59615 +} e_FmPortGprFuncType;
59616 +
59617 +t_Error FmPortSetGprFunc(t_Handle h_FmPort, e_FmPortGprFuncType gprFunc, void **p_Value);
59618 +#endif /* DPAA_VERSION >= 11) */
59619 +t_Error FmGetSetParams(t_Handle h_Fm, t_FmGetSetParams *p_FmGetSetParams);
59620 +t_Error FmPortGetSetCcParams(t_Handle h_FmPort, t_FmPortGetSetCcParams *p_FmPortGetSetCcParams);
59621 +uint8_t FmPortGetNetEnvId(t_Handle h_FmPort);
59622 +uint8_t FmPortGetHardwarePortId(t_Handle h_FmPort);
59623 +uint32_t FmPortGetPcdEngines(t_Handle h_FmPort);
59624 +void FmPortPcdKgSwUnbindClsPlanGrp (t_Handle h_FmPort);
59625 +
59626 +
59627 +#if (DPAA_VERSION >= 11)
59628 +t_Error FmPcdFrmReplicUpdate(t_Handle h_FmPcd, t_Handle h_FmPort, t_Handle h_FrmReplic);
59629 +#endif /* (DPAA_VERSION >= 11) */
59630 +
59631 +/**************************************************************************//**
59632 + @Function FmRegisterIntr
59633 +
59634 + @Description Used to register an inter-module event handler to be processed by FM
59635 +
59636 + @Param[in] h_Fm A handle to an FM Module.
59637 + @Param[in] mod The module that causes the event
59638 + @Param[in] modId Module id - if more than 1 instansiation of this
59639 + mode exists,0 otherwise.
59640 + @Param[in] intrType Interrupt type (error/normal) selection.
59641 + @Param[in] f_Isr The interrupt service routine.
59642 + @Param[in] h_Arg Argument to be passed to f_Isr.
59643 +
59644 + @Return None.
59645 +*//***************************************************************************/
59646 +void FmRegisterIntr(t_Handle h_Fm,
59647 + e_FmEventModules mod,
59648 + uint8_t modId,
59649 + e_FmIntrType intrType,
59650 + void (*f_Isr) (t_Handle h_Arg),
59651 + t_Handle h_Arg);
59652 +
59653 +/**************************************************************************//**
59654 + @Function FmUnregisterIntr
59655 +
59656 + @Description Used to un-register an inter-module event handler that was processed by FM
59657 +
59658 + @Param[in] h_Fm A handle to an FM Module.
59659 + @Param[in] mod The module that causes the event
59660 + @Param[in] modId Module id - if more than 1 instansiation of this
59661 + mode exists,0 otherwise.
59662 + @Param[in] intrType Interrupt type (error/normal) selection.
59663 +
59664 + @Return None.
59665 +*//***************************************************************************/
59666 +void FmUnregisterIntr(t_Handle h_Fm,
59667 + e_FmEventModules mod,
59668 + uint8_t modId,
59669 + e_FmIntrType intrType);
59670 +
59671 +/**************************************************************************//**
59672 + @Function FmRegisterFmCtlIntr
59673 +
59674 + @Description Used to register to one of the fmCtl events in the FM module
59675 +
59676 + @Param[in] h_Fm A handle to an FM Module.
59677 + @Param[in] eventRegId FmCtl event id (0-7).
59678 + @Param[in] f_Isr The interrupt service routine.
59679 +
59680 + @Return E_OK on success; Error code otherwise.
59681 +
59682 + @Cautions Allowed only following FM_Init().
59683 +*//***************************************************************************/
59684 +void FmRegisterFmCtlIntr(t_Handle h_Fm, uint8_t eventRegId, void (*f_Isr) (t_Handle h_Fm, uint32_t event));
59685 +
59686 +
59687 +/**************************************************************************//**
59688 + @Description enum for defining MAC types
59689 +*//***************************************************************************/
59690 +typedef enum e_FmMacType {
59691 + e_FM_MAC_10G = 0, /**< 10G MAC */
59692 + e_FM_MAC_1G /**< 1G MAC */
59693 +} e_FmMacType;
59694 +
59695 +/**************************************************************************//**
59696 + @Description Structure for port-FM communication during FM_PORT_Init.
59697 + Fields commented 'IN' are passed by the port module to be used
59698 + by the FM module.
59699 + Fields commented 'OUT' will be filled by FM before returning to port.
59700 + Some fields are optional (depending on configuration) and
59701 + will be analized by the port and FM modules accordingly.
59702 +*//***************************************************************************/
59703 +typedef struct t_FmInterModulePortInitParams {
59704 + uint8_t hardwarePortId; /**< IN. port Id */
59705 + e_FmPortType portType; /**< IN. Port type */
59706 + bool independentMode; /**< IN. TRUE if FM Port operates in independent mode */
59707 + uint16_t liodnOffset; /**< IN. Port's requested resource */
59708 + uint8_t numOfTasks; /**< IN. Port's requested resource */
59709 + uint8_t numOfExtraTasks; /**< IN. Port's requested resource */
59710 + uint8_t numOfOpenDmas; /**< IN. Port's requested resource */
59711 + uint8_t numOfExtraOpenDmas; /**< IN. Port's requested resource */
59712 + uint32_t sizeOfFifo; /**< IN. Port's requested resource */
59713 + uint32_t extraSizeOfFifo; /**< IN. Port's requested resource */
59714 + uint8_t deqPipelineDepth; /**< IN. Port's requested resource */
59715 + uint16_t maxFrameLength; /**< IN. Port's max frame length. */
59716 + uint16_t liodnBase; /**< IN. Irrelevant for P4080 rev 1.
59717 + LIODN base for this port, to be
59718 + used together with LIODN offset. */
59719 + t_FmPhysAddr fmMuramPhysBaseAddr;/**< OUT. FM-MURAM physical address*/
59720 +} t_FmInterModulePortInitParams;
59721 +
59722 +/**************************************************************************//**
59723 + @Description Structure for port-FM communication during FM_PORT_Free.
59724 +*//***************************************************************************/
59725 +typedef struct t_FmInterModulePortFreeParams {
59726 + uint8_t hardwarePortId; /**< IN. port Id */
59727 + e_FmPortType portType; /**< IN. Port type */
59728 + uint8_t deqPipelineDepth; /**< IN. Port's requested resource */
59729 +} t_FmInterModulePortFreeParams;
59730 +
59731 +/**************************************************************************//**
59732 + @Function FmGetPcdPrsBaseAddr
59733 +
59734 + @Description Get the base address of the Parser from the FM module
59735 +
59736 + @Param[in] h_Fm A handle to an FM Module.
59737 +
59738 + @Return Base address.
59739 +*//***************************************************************************/
59740 +uintptr_t FmGetPcdPrsBaseAddr(t_Handle h_Fm);
59741 +
59742 +/**************************************************************************//**
59743 + @Function FmGetPcdKgBaseAddr
59744 +
59745 + @Description Get the base address of the Keygen from the FM module
59746 +
59747 + @Param[in] h_Fm A handle to an FM Module.
59748 +
59749 + @Return Base address.
59750 +*//***************************************************************************/
59751 +uintptr_t FmGetPcdKgBaseAddr(t_Handle h_Fm);
59752 +
59753 +/**************************************************************************//**
59754 + @Function FmGetPcdPlcrBaseAddr
59755 +
59756 + @Description Get the base address of the Policer from the FM module
59757 +
59758 + @Param[in] h_Fm A handle to an FM Module.
59759 +
59760 + @Return Base address.
59761 +*//***************************************************************************/
59762 +uintptr_t FmGetPcdPlcrBaseAddr(t_Handle h_Fm);
59763 +
59764 +/**************************************************************************//**
59765 + @Function FmGetMuramHandle
59766 +
59767 + @Description Get the handle of the MURAM from the FM module
59768 +
59769 + @Param[in] h_Fm A handle to an FM Module.
59770 +
59771 + @Return MURAM module handle.
59772 +*//***************************************************************************/
59773 +t_Handle FmGetMuramHandle(t_Handle h_Fm);
59774 +
59775 +/**************************************************************************//**
59776 + @Function FmGetPhysicalMuramBase
59777 +
59778 + @Description Get the physical base address of the MURAM from the FM module
59779 +
59780 + @Param[in] h_Fm A handle to an FM Module.
59781 + @Param[in] fmPhysAddr Physical MURAM base
59782 +
59783 + @Return Physical base address.
59784 +*//***************************************************************************/
59785 +void FmGetPhysicalMuramBase(t_Handle h_Fm, t_FmPhysAddr *fmPhysAddr);
59786 +
59787 +/**************************************************************************//**
59788 + @Function FmGetTimeStampScale
59789 +
59790 + @Description Used internally by other modules in order to get the timeStamp
59791 + period as requested by the application.
59792 +
59793 + This function returns bit number that is incremented every 1 usec.
59794 + To calculate timestamp period in nsec, use
59795 + 1000 / (1 << FmGetTimeStampScale()).
59796 +
59797 + @Param[in] h_Fm A handle to an FM Module.
59798 +
59799 + @Return Bit that counts 1 usec.
59800 +
59801 + @Cautions Allowed only following FM_Init().
59802 +*//***************************************************************************/
59803 +uint32_t FmGetTimeStampScale(t_Handle h_Fm);
59804 +
59805 +/**************************************************************************//**
59806 + @Function FmResumeStalledPort
59807 +
59808 + @Description Used internally by FM port to release a stalled port.
59809 +
59810 + @Param[in] h_Fm A handle to an FM Module.
59811 + @Param[in] hardwarePortId HW port id.
59812 +
59813 + @Return E_OK on success; Error code otherwise.
59814 +
59815 + @Cautions Allowed only following FM_Init().
59816 +*//***************************************************************************/
59817 +t_Error FmResumeStalledPort(t_Handle h_Fm, uint8_t hardwarePortId);
59818 +
59819 +/**************************************************************************//**
59820 + @Function FmIsPortStalled
59821 +
59822 + @Description Used internally by FM port to read the port's status.
59823 +
59824 + @Param[in] h_Fm A handle to an FM Module.
59825 + @Param[in] hardwarePortId HW port id.
59826 + @Param[in] p_IsStalled A pointer to the boolean port stalled state
59827 +
59828 + @Return E_OK on success; Error code otherwise.
59829 +
59830 + @Cautions Allowed only following FM_Init().
59831 +*//***************************************************************************/
59832 +t_Error FmIsPortStalled(t_Handle h_Fm, uint8_t hardwarePortId, bool *p_IsStalled);
59833 +
59834 +/**************************************************************************//**
59835 + @Function FmResetMac
59836 +
59837 + @Description Used by MAC driver to reset the MAC registers
59838 +
59839 + @Param[in] h_Fm A handle to an FM Module.
59840 + @Param[in] type MAC type.
59841 + @Param[in] macId MAC id - according to type.
59842 +
59843 + @Return E_OK on success; Error code otherwise.
59844 +
59845 + @Cautions Allowed only following FM_Init().
59846 +*//***************************************************************************/
59847 +t_Error FmResetMac(t_Handle h_Fm, e_FmMacType type, uint8_t macId);
59848 +
59849 +/**************************************************************************//**
59850 + @Function FmGetClockFreq
59851 +
59852 + @Description Used by MAC driver to get the FM clock frequency
59853 +
59854 + @Param[in] h_Fm A handle to an FM Module.
59855 +
59856 + @Return clock-freq on success; 0 otherwise.
59857 +
59858 + @Cautions Allowed only following FM_Init().
59859 +*//***************************************************************************/
59860 +uint16_t FmGetClockFreq(t_Handle h_Fm);
59861 +
59862 +/**************************************************************************//**
59863 + @Function FmGetMacClockFreq
59864 +
59865 + @Description Used by MAC driver to get the MAC clock frequency
59866 +
59867 + @Param[in] h_Fm A handle to an FM Module.
59868 +
59869 + @Return clock-freq on success; 0 otherwise.
59870 +
59871 + @Cautions Allowed only following FM_Init().
59872 +*//***************************************************************************/
59873 +uint16_t FmGetMacClockFreq(t_Handle h_Fm);
59874 +
59875 +/**************************************************************************//**
59876 + @Function FmGetId
59877 +
59878 + @Description Used by PCD driver to read rhe FM id
59879 +
59880 + @Param[in] h_Fm A handle to an FM Module.
59881 +
59882 + @Return E_OK on success; Error code otherwise.
59883 +
59884 + @Cautions Allowed only following FM_Init().
59885 +*//***************************************************************************/
59886 +uint8_t FmGetId(t_Handle h_Fm);
59887 +
59888 +/**************************************************************************//**
59889 + @Function FmGetSetPortParams
59890 +
59891 + @Description Used by FM-PORT driver to pass and receive parameters between
59892 + PORT and FM modules.
59893 +
59894 + @Param[in] h_Fm A handle to an FM Module.
59895 + @Param[in,out] p_PortParams A structure of FM Port parameters.
59896 +
59897 + @Return E_OK on success; Error code otherwise.
59898 +
59899 + @Cautions Allowed only following FM_Init().
59900 +*//***************************************************************************/
59901 +t_Error FmGetSetPortParams(t_Handle h_Fm,t_FmInterModulePortInitParams *p_PortParams);
59902 +
59903 +/**************************************************************************//**
59904 + @Function FmFreePortParams
59905 +
59906 + @Description Used by FM-PORT driver to free port's resources within the FM.
59907 +
59908 + @Param[in] h_Fm A handle to an FM Module.
59909 + @Param[in,out] p_PortParams A structure of FM Port parameters.
59910 +
59911 + @Return None.
59912 +
59913 + @Cautions Allowed only following FM_Init().
59914 +*//***************************************************************************/
59915 +void FmFreePortParams(t_Handle h_Fm,t_FmInterModulePortFreeParams *p_PortParams);
59916 +
59917 +/**************************************************************************//**
59918 + @Function FmSetNumOfRiscsPerPort
59919 +
59920 + @Description Used by FM-PORT driver to pass parameter between
59921 + PORT and FM modules for working with number of RISC..
59922 +
59923 + @Param[in] h_Fm A handle to an FM Module.
59924 + @Param[in] hardwarePortId hardware port Id.
59925 + @Param[in] numOfFmanCtrls number of Fman Controllers.
59926 + @Param[in] orFmanCtrl Fman Controller for order restoration.
59927 +
59928 + @Return None.
59929 +
59930 + @Cautions Allowed only following FM_Init().
59931 +*//***************************************************************************/
59932 +t_Error FmSetNumOfRiscsPerPort(t_Handle h_Fm, uint8_t hardwarePortId, uint8_t numOfFmanCtrls, t_FmFmanCtrl orFmanCtrl);
59933 +
59934 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
59935 +/**************************************************************************//*
59936 + @Function FmDumpPortRegs
59937 +
59938 + @Description Dumps FM port registers which are part of FM common registers
59939 +
59940 + @Param[in] h_Fm A handle to an FM Module.
59941 + @Param[in] hardwarePortId HW port id.
59942 +
59943 + @Return E_OK on success; Error code otherwise.
59944 +
59945 + @Cautions Allowed only FM_Init().
59946 +*//***************************************************************************/
59947 +t_Error FmDumpPortRegs(t_Handle h_Fm,uint8_t hardwarePortId);
59948 +#endif /* (defined(DEBUG_ERRORS) && ... */
59949 +
59950 +void FmRegisterPcd(t_Handle h_Fm, t_Handle h_FmPcd);
59951 +void FmUnregisterPcd(t_Handle h_Fm);
59952 +t_Handle FmGetPcdHandle(t_Handle h_Fm);
59953 +t_Error FmEnableRamsEcc(t_Handle h_Fm);
59954 +t_Error FmDisableRamsEcc(t_Handle h_Fm);
59955 +void FmGetRevision(t_Handle h_Fm, t_FmRevisionInfo *p_FmRevisionInfo);
59956 +t_Error FmAllocFmanCtrlEventReg(t_Handle h_Fm, uint8_t *p_EventId);
59957 +void FmFreeFmanCtrlEventReg(t_Handle h_Fm, uint8_t eventId);
59958 +void FmSetFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId, uint32_t enableEvents);
59959 +uint32_t FmGetFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId);
59960 +void FmRegisterFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId, void (*f_Isr) (t_Handle h_Fm, uint32_t event), t_Handle h_Arg);
59961 +void FmUnregisterFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId);
59962 +t_Error FmSetMacMaxFrame(t_Handle h_Fm, e_FmMacType type, uint8_t macId, uint16_t mtu);
59963 +bool FmIsMaster(t_Handle h_Fm);
59964 +uint8_t FmGetGuestId(t_Handle h_Fm);
59965 +uint16_t FmGetTnumAgingPeriod(t_Handle h_Fm);
59966 +t_Error FmSetPortPreFetchConfiguration(t_Handle h_Fm, uint8_t portNum, bool preFetchConfigured);
59967 +t_Error FmGetPortPreFetchConfiguration(t_Handle h_Fm, uint8_t portNum, bool *p_PortConfigured, bool *p_PreFetchConfigured);
59968 +
59969 +
59970 +#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
59971 +t_Error Fm10GTxEccWorkaround(t_Handle h_Fm, uint8_t macId);
59972 +#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
59973 +
59974 +void FmMuramClear(t_Handle h_FmMuram);
59975 +t_Error FmSetNumOfOpenDmas(t_Handle h_Fm,
59976 + uint8_t hardwarePortId,
59977 + uint8_t *p_NumOfOpenDmas,
59978 + uint8_t *p_NumOfExtraOpenDmas,
59979 + bool initialConfig);
59980 +t_Error FmSetNumOfTasks(t_Handle h_Fm,
59981 + uint8_t hardwarePortId,
59982 + uint8_t *p_NumOfTasks,
59983 + uint8_t *p_NumOfExtraTasks,
59984 + bool initialConfig);
59985 +t_Error FmSetSizeOfFifo(t_Handle h_Fm,
59986 + uint8_t hardwarePortId,
59987 + uint32_t *p_SizeOfFifo,
59988 + uint32_t *p_ExtraSizeOfFifo,
59989 + bool initialConfig);
59990 +
59991 +t_Error FmSetCongestionGroupPFCpriority(t_Handle h_Fm,
59992 + uint32_t congestionGroupId,
59993 + uint8_t priorityBitMap);
59994 +
59995 +#if (DPAA_VERSION >= 11)
59996 +t_Error FmVSPAllocForPort(t_Handle h_Fm,
59997 + e_FmPortType portType,
59998 + uint8_t portId,
59999 + uint8_t numOfStorageProfiles);
60000 +
60001 +t_Error FmVSPFreeForPort(t_Handle h_Fm,
60002 + e_FmPortType portType,
60003 + uint8_t portId);
60004 +
60005 +t_Error FmVSPGetAbsoluteProfileId(t_Handle h_Fm,
60006 + e_FmPortType portType,
60007 + uint8_t portId,
60008 + uint16_t relativeProfile,
60009 + uint16_t *p_AbsoluteId);
60010 +t_Error FmVSPCheckRelativeProfile(t_Handle h_Fm,
60011 + e_FmPortType portType,
60012 + uint8_t portId,
60013 + uint16_t relativeProfile);
60014 +
60015 +uintptr_t FmGetVSPBaseAddr(t_Handle h_Fm);
60016 +#endif /* (DPAA_VERSION >= 11) */
60017 +
60018 +
60019 +#endif /* __FM_COMMON_H */
60020 --- /dev/null
60021 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc/fm_hc.h
60022 @@ -0,0 +1,93 @@
60023 +/*
60024 + * Copyright 2008-2012 Freescale Semiconductor Inc.
60025 + *
60026 + * Redistribution and use in source and binary forms, with or without
60027 + * modification, are permitted provided that the following conditions are met:
60028 + * * Redistributions of source code must retain the above copyright
60029 + * notice, this list of conditions and the following disclaimer.
60030 + * * Redistributions in binary form must reproduce the above copyright
60031 + * notice, this list of conditions and the following disclaimer in the
60032 + * documentation and/or other materials provided with the distribution.
60033 + * * Neither the name of Freescale Semiconductor nor the
60034 + * names of its contributors may be used to endorse or promote products
60035 + * derived from this software without specific prior written permission.
60036 + *
60037 + *
60038 + * ALTERNATIVELY, this software may be distributed under the terms of the
60039 + * GNU General Public License ("GPL") as published by the Free Software
60040 + * Foundation, either version 2 of that License or (at your option) any
60041 + * later version.
60042 + *
60043 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
60044 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
60045 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
60046 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
60047 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
60048 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
60049 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
60050 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60051 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
60052 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60053 + */
60054 +
60055 +
60056 +#ifndef __FM_HC_H
60057 +#define __FM_HC_H
60058 +
60059 +#include "std_ext.h"
60060 +#include "error_ext.h"
60061 +#include "fsl_fman_kg.h"
60062 +
60063 +#define __ERR_MODULE__ MODULE_FM_PCD
60064 +
60065 +
60066 +typedef struct t_FmHcParams {
60067 + t_Handle h_Fm;
60068 + t_Handle h_FmPcd;
60069 + t_FmPcdHcParams params;
60070 +} t_FmHcParams;
60071 +
60072 +
60073 +t_Handle FmHcConfigAndInit(t_FmHcParams *p_FmHcParams);
60074 +void FmHcFree(t_Handle h_FmHc);
60075 +t_Error FmHcSetFramesDataMemory(t_Handle h_FmHc,
60076 + uint8_t memId);
60077 +t_Error FmHcDumpRegs(t_Handle h_FmHc);
60078 +
60079 +void FmHcTxConf(t_Handle h_FmHc, t_DpaaFD *p_Fd);
60080 +
60081 +t_Error FmHcPcdKgSetScheme(t_Handle h_FmHc,
60082 + t_Handle h_Scheme,
60083 + struct fman_kg_scheme_regs *p_SchemeRegs,
60084 + bool updateCounter);
60085 +t_Error FmHcPcdKgDeleteScheme(t_Handle h_FmHc, t_Handle h_Scheme);
60086 +t_Error FmHcPcdCcCapwapTimeoutReassm(t_Handle h_FmHc, t_FmPcdCcCapwapReassmTimeoutParams *p_CcCapwapReassmTimeoutParams );
60087 +t_Error FmHcPcdCcIpFragScratchPollCmd(t_Handle h_FmHc, bool fill, t_FmPcdCcFragScratchPoolCmdParams *p_FmPcdCcFragScratchPoolCmdParams);
60088 +t_Error FmHcPcdCcTimeoutReassm(t_Handle h_FmHc, t_FmPcdCcReassmTimeoutParams *p_CcReassmTimeoutParams, uint8_t *p_Result);
60089 +t_Error FmHcPcdKgSetClsPlan(t_Handle h_FmHc, t_FmPcdKgInterModuleClsPlanSet *p_Set);
60090 +t_Error FmHcPcdKgDeleteClsPlan(t_Handle h_FmHc, uint8_t clsPlanGrpId);
60091 +
60092 +t_Error FmHcPcdKgSetSchemeCounter(t_Handle h_FmHc, t_Handle h_Scheme, uint32_t value);
60093 +uint32_t FmHcPcdKgGetSchemeCounter(t_Handle h_FmHc, t_Handle h_Scheme);
60094 +
60095 +t_Error FmHcPcdCcDoDynamicChange(t_Handle h_FmHc, uint32_t oldAdAddrOffset, uint32_t newAdAddrOffset);
60096 +
60097 +t_Error FmHcPcdPlcrSetProfile(t_Handle h_FmHc, t_Handle h_Profile, t_FmPcdPlcrProfileRegs *p_PlcrRegs);
60098 +t_Error FmHcPcdPlcrDeleteProfile(t_Handle h_FmHc, t_Handle h_Profile);
60099 +
60100 +t_Error FmHcPcdPlcrSetProfileCounter(t_Handle h_FmHc, t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter, uint32_t value);
60101 +uint32_t FmHcPcdPlcrGetProfileCounter(t_Handle h_FmHc, t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter);
60102 +
60103 +t_Error FmHcKgWriteSp(t_Handle h_FmHc, uint8_t hardwarePortId, uint32_t spReg, bool add);
60104 +t_Error FmHcKgWriteCpp(t_Handle h_FmHc, uint8_t hardwarePortId, uint32_t cppReg);
60105 +
60106 +t_Error FmHcPcdKgCcGetSetParams(t_Handle h_FmHc, t_Handle h_Scheme, uint32_t requiredAction, uint32_t value);
60107 +t_Error FmHcPcdPlcrCcGetSetParams(t_Handle h_FmHc,uint16_t absoluteProfileId, uint32_t requiredAction);
60108 +
60109 +t_Error FmHcPcdSync(t_Handle h_FmHc);
60110 +t_Handle FmHcGetPort(t_Handle h_FmHc);
60111 +
60112 +
60113 +
60114 +
60115 +#endif /* __FM_HC_H */
60116 --- /dev/null
60117 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc/fm_sp_common.h
60118 @@ -0,0 +1,117 @@
60119 +/*
60120 + * Copyright 2008-2012 Freescale Semiconductor Inc.
60121 + *
60122 + * Redistribution and use in source and binary forms, with or without
60123 + * modification, are permitted provided that the following conditions are met:
60124 + * * Redistributions of source code must retain the above copyright
60125 + * notice, this list of conditions and the following disclaimer.
60126 + * * Redistributions in binary form must reproduce the above copyright
60127 + * notice, this list of conditions and the following disclaimer in the
60128 + * documentation and/or other materials provided with the distribution.
60129 + * * Neither the name of Freescale Semiconductor nor the
60130 + * names of its contributors may be used to endorse or promote products
60131 + * derived from this software without specific prior written permission.
60132 + *
60133 + *
60134 + * ALTERNATIVELY, this software may be distributed under the terms of the
60135 + * GNU General Public License ("GPL") as published by the Free Software
60136 + * Foundation, either version 2 of that License or (at your option) any
60137 + * later version.
60138 + *
60139 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
60140 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
60141 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
60142 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
60143 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
60144 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
60145 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
60146 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60147 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
60148 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60149 + */
60150 +
60151 +
60152 +/******************************************************************************
60153 + @File fm_sp_common.h
60154 +
60155 + @Description FM SP ...
60156 +*//***************************************************************************/
60157 +#ifndef __FM_SP_COMMON_H
60158 +#define __FM_SP_COMMON_H
60159 +
60160 +#include "std_ext.h"
60161 +#include "error_ext.h"
60162 +#include "list_ext.h"
60163 +
60164 +#include "fm_ext.h"
60165 +#include "fm_pcd_ext.h"
60166 +#include "fsl_fman.h"
60167 +
60168 +/**************************************************************************//**
60169 + @Description defaults
60170 +*//***************************************************************************/
60171 +#define DEFAULT_FM_SP_bufferPrefixContent_privDataSize 0
60172 +#define DEFAULT_FM_SP_bufferPrefixContent_passPrsResult FALSE
60173 +#define DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp FALSE
60174 +#define DEFAULT_FM_SP_bufferPrefixContent_allOtherPCDInfo FALSE
60175 +#define DEFAULT_FM_SP_bufferPrefixContent_dataAlign 64
60176 +
60177 +/**************************************************************************//**
60178 + @Description structure for defining internal context copying
60179 +*//***************************************************************************/
60180 +typedef struct
60181 +{
60182 + uint16_t extBufOffset; /**< Offset in External buffer to which internal
60183 + context is copied to (Rx) or taken from (Tx, Op). */
60184 + uint8_t intContextOffset; /**< Offset within internal context to copy from
60185 + (Rx) or to copy to (Tx, Op). */
60186 + uint16_t size; /**< Internal offset size to be copied */
60187 +} t_FmSpIntContextDataCopy;
60188 +
60189 +/**************************************************************************//**
60190 + @Description struct for defining external buffer margins
60191 +*//***************************************************************************/
60192 +typedef struct {
60193 + uint16_t startMargins; /**< Number of bytes to be left at the beginning
60194 + of the external buffer (must be divisible by 16) */
60195 + uint16_t endMargins; /**< number of bytes to be left at the end
60196 + of the external buffer(must be divisible by 16) */
60197 +} t_FmSpBufMargins;
60198 +
60199 +typedef struct {
60200 + uint32_t dataOffset;
60201 + uint32_t prsResultOffset;
60202 + uint32_t timeStampOffset;
60203 + uint32_t hashResultOffset;
60204 + uint32_t pcdInfoOffset;
60205 + uint32_t manipOffset;
60206 +} t_FmSpBufferOffsets;
60207 +
60208 +
60209 +t_Error FmSpBuildBufferStructure(t_FmSpIntContextDataCopy *p_FmPortIntContextDataCopy,
60210 + t_FmBufferPrefixContent *p_BufferPrefixContent,
60211 + t_FmSpBufMargins *p_FmPortBufMargins,
60212 + t_FmSpBufferOffsets *p_FmPortBufferOffsets,
60213 + uint8_t *internalBufferOffset);
60214 +
60215 +t_Error FmSpCheckIntContextParams(t_FmSpIntContextDataCopy *p_FmSpIntContextDataCopy);
60216 +t_Error FmSpCheckBufPoolsParams(t_FmExtPools *p_FmExtPools,
60217 + t_FmBackupBmPools *p_FmBackupBmPools,
60218 + t_FmBufPoolDepletion *p_FmBufPoolDepletion);
60219 +t_Error FmSpCheckBufMargins(t_FmSpBufMargins *p_FmSpBufMargins);
60220 +void FmSpSetBufPoolsInAscOrderOfBufSizes(t_FmExtPools *p_FmExtPools, uint8_t *orderedArray, uint16_t *sizesArray);
60221 +
60222 +t_Error FmPcdSpAllocProfiles(t_Handle h_FmPcd,
60223 + uint8_t hardwarePortId,
60224 + uint16_t numOfStorageProfiles,
60225 + uint16_t *base,
60226 + uint8_t *log2Num);
60227 +t_Error FmPcdSpGetAbsoluteProfileId(t_Handle h_FmPcd,
60228 + t_Handle h_FmPort,
60229 + uint16_t relativeProfile,
60230 + uint16_t *p_AbsoluteId);
60231 +void SpInvalidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId);
60232 +void SpValidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId);
60233 +
60234 +
60235 +#endif /* __FM_SP_COMMON_H */
60236 --- /dev/null
60237 +++ b/drivers/net/ethernet/freescale/sdk_fman/etc/Makefile
60238 @@ -0,0 +1,12 @@
60239 +#
60240 +# Makefile for the Freescale Ethernet controllers
60241 +#
60242 +ccflags-y += -DVERSION=\"\"
60243 +#
60244 +#Include netcomm SW specific definitions
60245 +
60246 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
60247 +
60248 +obj-y += fsl-ncsw-etc.o
60249 +
60250 +fsl-ncsw-etc-objs := mm.o memcpy.o sprint.o list.o error.o
60251 --- /dev/null
60252 +++ b/drivers/net/ethernet/freescale/sdk_fman/etc/error.c
60253 @@ -0,0 +1,95 @@
60254 +/*
60255 + * Copyright 2008-2012 Freescale Semiconductor Inc.
60256 + *
60257 + * Redistribution and use in source and binary forms, with or without
60258 + * modification, are permitted provided that the following conditions are met:
60259 + * * Redistributions of source code must retain the above copyright
60260 + * notice, this list of conditions and the following disclaimer.
60261 + * * Redistributions in binary form must reproduce the above copyright
60262 + * notice, this list of conditions and the following disclaimer in the
60263 + * documentation and/or other materials provided with the distribution.
60264 + * * Neither the name of Freescale Semiconductor nor the
60265 + * names of its contributors may be used to endorse or promote products
60266 + * derived from this software without specific prior written permission.
60267 + *
60268 + *
60269 + * ALTERNATIVELY, this software may be distributed under the terms of the
60270 + * GNU General Public License ("GPL") as published by the Free Software
60271 + * Foundation, either version 2 of that License or (at your option) any
60272 + * later version.
60273 + *
60274 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
60275 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
60276 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
60277 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
60278 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
60279 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
60280 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
60281 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60282 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
60283 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60284 + */
60285 +
60286 +
60287 +/*
60288 +
60289 + @File error.c
60290 +
60291 + @Description General errors and events reporting utilities.
60292 +*//***************************************************************************/
60293 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
60294 +#include "error_ext.h"
60295 +
60296 +
60297 +const char *dbgLevelStrings[] =
60298 +{
60299 + "CRITICAL"
60300 + ,"MAJOR"
60301 + ,"MINOR"
60302 + ,"WARNING"
60303 + ,"INFO"
60304 + ,"TRACE"
60305 +};
60306 +
60307 +
60308 +char * ErrTypeStrings (e_ErrorType err)
60309 +{
60310 + switch (err)
60311 + {
60312 + case (E_OK): return "OK";
60313 + case (E_WRITE_FAILED): return "Write Access Failed";
60314 + case (E_NO_DEVICE): return "No Device";
60315 + case (E_NOT_AVAILABLE): return "Resource Is Unavailable";
60316 + case (E_NO_MEMORY): return "Memory Allocation Failed";
60317 + case (E_INVALID_ADDRESS): return "Invalid Address";
60318 + case (E_BUSY): return "Resource Is Busy";
60319 + case (E_ALREADY_EXISTS): return "Resource Already Exists";
60320 + case (E_INVALID_OPERATION): return "Invalid Operation";
60321 + case (E_INVALID_VALUE): return "Invalid Value";
60322 + case (E_NOT_IN_RANGE): return "Value Out Of Range";
60323 + case (E_NOT_SUPPORTED): return "Unsupported Operation";
60324 + case (E_INVALID_STATE): return "Invalid State";
60325 + case (E_INVALID_HANDLE): return "Invalid Handle";
60326 + case (E_INVALID_ID): return "Invalid ID";
60327 + case (E_NULL_POINTER): return "Unexpected NULL Pointer";
60328 + case (E_INVALID_SELECTION): return "Invalid Selection";
60329 + case (E_INVALID_COMM_MODE): return "Invalid Communication Mode";
60330 + case (E_INVALID_MEMORY_TYPE): return "Invalid Memory Type";
60331 + case (E_INVALID_CLOCK): return "Invalid Clock";
60332 + case (E_CONFLICT): return "Conflict In Settings";
60333 + case (E_NOT_ALIGNED): return "Incorrect Alignment";
60334 + case (E_NOT_FOUND): return "Resource Not Found";
60335 + case (E_FULL): return "Resource Is Full";
60336 + case (E_EMPTY): return "Resource Is Empty";
60337 + case (E_ALREADY_FREE): return "Resource Already Free";
60338 + case (E_READ_FAILED): return "Read Access Failed";
60339 + case (E_INVALID_FRAME): return "Invalid Frame";
60340 + case (E_SEND_FAILED): return "Send Operation Failed";
60341 + case (E_RECEIVE_FAILED): return "Receive Operation Failed";
60342 + case (E_TIMEOUT): return "Operation Timed Out";
60343 + default:
60344 + break;
60345 + }
60346 + return NULL;
60347 +}
60348 +#endif /* (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)) */
60349 --- /dev/null
60350 +++ b/drivers/net/ethernet/freescale/sdk_fman/etc/list.c
60351 @@ -0,0 +1,71 @@
60352 +/*
60353 + * Copyright 2008-2012 Freescale Semiconductor Inc.
60354 + *
60355 + * Redistribution and use in source and binary forms, with or without
60356 + * modification, are permitted provided that the following conditions are met:
60357 + * * Redistributions of source code must retain the above copyright
60358 + * notice, this list of conditions and the following disclaimer.
60359 + * * Redistributions in binary form must reproduce the above copyright
60360 + * notice, this list of conditions and the following disclaimer in the
60361 + * documentation and/or other materials provided with the distribution.
60362 + * * Neither the name of Freescale Semiconductor nor the
60363 + * names of its contributors may be used to endorse or promote products
60364 + * derived from this software without specific prior written permission.
60365 + *
60366 + *
60367 + * ALTERNATIVELY, this software may be distributed under the terms of the
60368 + * GNU General Public License ("GPL") as published by the Free Software
60369 + * Foundation, either version 2 of that License or (at your option) any
60370 + * later version.
60371 + *
60372 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
60373 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
60374 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
60375 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
60376 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
60377 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
60378 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
60379 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60380 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
60381 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60382 + */
60383 +
60384 +
60385 +/**************************************************************************//**
60386 +
60387 + @File list.c
60388 +
60389 + @Description Implementation of list.
60390 +*//***************************************************************************/
60391 +#include "std_ext.h"
60392 +#include "list_ext.h"
60393 +
60394 +
60395 +void LIST_Append(t_List *p_NewList, t_List *p_Head)
60396 +{
60397 + t_List *p_First = LIST_FIRST(p_NewList);
60398 +
60399 + if (p_First != p_NewList)
60400 + {
60401 + t_List *p_Last = LIST_LAST(p_NewList);
60402 + t_List *p_Cur = LIST_NEXT(p_Head);
60403 +
60404 + LIST_PREV(p_First) = p_Head;
60405 + LIST_FIRST(p_Head) = p_First;
60406 + LIST_NEXT(p_Last) = p_Cur;
60407 + LIST_LAST(p_Cur) = p_Last;
60408 + }
60409 +}
60410 +
60411 +
60412 +int LIST_NumOfObjs(t_List *p_List)
60413 +{
60414 + t_List *p_Tmp;
60415 + int numOfObjs = 0;
60416 +
60417 + if (!LIST_IsEmpty(p_List))
60418 + LIST_FOR_EACH(p_Tmp, p_List)
60419 + numOfObjs++;
60420 +
60421 + return numOfObjs;
60422 +}
60423 --- /dev/null
60424 +++ b/drivers/net/ethernet/freescale/sdk_fman/etc/memcpy.c
60425 @@ -0,0 +1,620 @@
60426 +/*
60427 + * Copyright 2008-2012 Freescale Semiconductor Inc.
60428 + *
60429 + * Redistribution and use in source and binary forms, with or without
60430 + * modification, are permitted provided that the following conditions are met:
60431 + * * Redistributions of source code must retain the above copyright
60432 + * notice, this list of conditions and the following disclaimer.
60433 + * * Redistributions in binary form must reproduce the above copyright
60434 + * notice, this list of conditions and the following disclaimer in the
60435 + * documentation and/or other materials provided with the distribution.
60436 + * * Neither the name of Freescale Semiconductor nor the
60437 + * names of its contributors may be used to endorse or promote products
60438 + * derived from this software without specific prior written permission.
60439 + *
60440 + *
60441 + * ALTERNATIVELY, this software may be distributed under the terms of the
60442 + * GNU General Public License ("GPL") as published by the Free Software
60443 + * Foundation, either version 2 of that License or (at your option) any
60444 + * later version.
60445 + *
60446 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
60447 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
60448 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
60449 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
60450 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
60451 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
60452 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
60453 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60454 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
60455 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60456 + */
60457 +
60458 +
60459 +
60460 +#include "std_ext.h"
60461 +#include "xx_ext.h"
60462 +#include "memcpy_ext.h"
60463 +
60464 +void * MemCpy8(void* pDst, void* pSrc, uint32_t size)
60465 +{
60466 + int i;
60467 +
60468 + for(i = 0; i < size; ++i)
60469 + *(((uint8_t*)(pDst)) + i) = *(((uint8_t*)(pSrc)) + i);
60470 +
60471 + return pDst;
60472 +}
60473 +
60474 +void * MemSet8(void* pDst, int c, uint32_t size)
60475 +{
60476 + int i;
60477 +
60478 + for(i = 0; i < size; ++i)
60479 + *(((uint8_t*)(pDst)) + i) = (uint8_t)(c);
60480 +
60481 + return pDst;
60482 +}
60483 +
60484 +void * MemCpy32(void* pDst,void* pSrc, uint32_t size)
60485 +{
60486 + uint32_t leftAlign;
60487 + uint32_t rightAlign;
60488 + uint32_t lastWord;
60489 + uint32_t currWord;
60490 + uint32_t *p_Src32;
60491 + uint32_t *p_Dst32;
60492 + uint8_t *p_Src8;
60493 + uint8_t *p_Dst8;
60494 +
60495 + p_Src8 = (uint8_t*)(pSrc);
60496 + p_Dst8 = (uint8_t*)(pDst);
60497 + /* first copy byte by byte till the source first alignment
60498 + * this step is necessary to ensure we do not even try to access
60499 + * data which is before the source buffer, hence it is not ours.
60500 + */
60501 + while((PTR_TO_UINT(p_Src8) & 3) && size) /* (pSrc mod 4) > 0 and size > 0 */
60502 + {
60503 + *p_Dst8++ = *p_Src8++;
60504 + size--;
60505 + }
60506 +
60507 + /* align destination (possibly disaligning source)*/
60508 + while((PTR_TO_UINT(p_Dst8) & 3) && size) /* (pDst mod 4) > 0 and size > 0 */
60509 + {
60510 + *p_Dst8++ = *p_Src8++;
60511 + size--;
60512 + }
60513 +
60514 + /* dest is aligned and source is not necessarily aligned */
60515 + leftAlign = (uint32_t)((PTR_TO_UINT(p_Src8) & 3) << 3); /* leftAlign = (pSrc mod 4)*8 */
60516 + rightAlign = 32 - leftAlign;
60517 +
60518 +
60519 + if (leftAlign == 0)
60520 + {
60521 + /* source is also aligned */
60522 + p_Src32 = (uint32_t*)(p_Src8);
60523 + p_Dst32 = (uint32_t*)(p_Dst8);
60524 + while (size >> 2) /* size >= 4 */
60525 + {
60526 + *p_Dst32++ = *p_Src32++;
60527 + size -= 4;
60528 + }
60529 + p_Src8 = (uint8_t*)(p_Src32);
60530 + p_Dst8 = (uint8_t*)(p_Dst32);
60531 + }
60532 + else
60533 + {
60534 + /* source is not aligned (destination is aligned)*/
60535 + p_Src32 = (uint32_t*)(p_Src8 - (leftAlign >> 3));
60536 + p_Dst32 = (uint32_t*)(p_Dst8);
60537 + lastWord = *p_Src32++;
60538 + while(size >> 3) /* size >= 8 */
60539 + {
60540 + currWord = *p_Src32;
60541 + *p_Dst32 = (lastWord << leftAlign) | (currWord >> rightAlign);
60542 + lastWord = currWord;
60543 + p_Src32++;
60544 + p_Dst32++;
60545 + size -= 4;
60546 + }
60547 + p_Dst8 = (uint8_t*)(p_Dst32);
60548 + p_Src8 = (uint8_t*)(p_Src32) - 4 + (leftAlign >> 3);
60549 + }
60550 +
60551 + /* complete the left overs */
60552 + while (size--)
60553 + *p_Dst8++ = *p_Src8++;
60554 +
60555 + return pDst;
60556 +}
60557 +
60558 +void * IO2IOCpy32(void* pDst,void* pSrc, uint32_t size)
60559 +{
60560 + uint32_t leftAlign;
60561 + uint32_t rightAlign;
60562 + uint32_t lastWord;
60563 + uint32_t currWord;
60564 + uint32_t *p_Src32;
60565 + uint32_t *p_Dst32;
60566 + uint8_t *p_Src8;
60567 + uint8_t *p_Dst8;
60568 +
60569 + p_Src8 = (uint8_t*)(pSrc);
60570 + p_Dst8 = (uint8_t*)(pDst);
60571 + /* first copy byte by byte till the source first alignment
60572 + * this step is necessary to ensure we do not even try to access
60573 + * data which is before the source buffer, hence it is not ours.
60574 + */
60575 + while((PTR_TO_UINT(p_Src8) & 3) && size) /* (pSrc mod 4) > 0 and size > 0 */
60576 + {
60577 + WRITE_UINT8(*p_Dst8, GET_UINT8(*p_Src8));
60578 + p_Dst8++;p_Src8++;
60579 + size--;
60580 + }
60581 +
60582 + /* align destination (possibly disaligning source)*/
60583 + while((PTR_TO_UINT(p_Dst8) & 3) && size) /* (pDst mod 4) > 0 and size > 0 */
60584 + {
60585 + WRITE_UINT8(*p_Dst8, GET_UINT8(*p_Src8));
60586 + p_Dst8++;p_Src8++;
60587 + size--;
60588 + }
60589 +
60590 + /* dest is aligned and source is not necessarily aligned */
60591 + leftAlign = (uint32_t)((PTR_TO_UINT(p_Src8) & 3) << 3); /* leftAlign = (pSrc mod 4)*8 */
60592 + rightAlign = 32 - leftAlign;
60593 +
60594 + if (leftAlign == 0)
60595 + {
60596 + /* source is also aligned */
60597 + p_Src32 = (uint32_t*)(p_Src8);
60598 + p_Dst32 = (uint32_t*)(p_Dst8);
60599 + while (size >> 2) /* size >= 4 */
60600 + {
60601 + WRITE_UINT32(*p_Dst32, GET_UINT32(*p_Src32));
60602 + p_Dst32++;p_Src32++;
60603 + size -= 4;
60604 + }
60605 + p_Src8 = (uint8_t*)(p_Src32);
60606 + p_Dst8 = (uint8_t*)(p_Dst32);
60607 + }
60608 + else
60609 + {
60610 + /* source is not aligned (destination is aligned)*/
60611 + p_Src32 = (uint32_t*)(p_Src8 - (leftAlign >> 3));
60612 + p_Dst32 = (uint32_t*)(p_Dst8);
60613 + lastWord = GET_UINT32(*p_Src32);
60614 + p_Src32++;
60615 + while(size >> 3) /* size >= 8 */
60616 + {
60617 + currWord = GET_UINT32(*p_Src32);
60618 + WRITE_UINT32(*p_Dst32, (lastWord << leftAlign) | (currWord >> rightAlign));
60619 + lastWord = currWord;
60620 + p_Src32++;p_Dst32++;
60621 + size -= 4;
60622 + }
60623 + p_Dst8 = (uint8_t*)(p_Dst32);
60624 + p_Src8 = (uint8_t*)(p_Src32) - 4 + (leftAlign >> 3);
60625 + }
60626 +
60627 + /* complete the left overs */
60628 + while (size--)
60629 + {
60630 + WRITE_UINT8(*p_Dst8, GET_UINT8(*p_Src8));
60631 + p_Dst8++;p_Src8++;
60632 + }
60633 +
60634 + return pDst;
60635 +}
60636 +
60637 +void * Mem2IOCpy32(void* pDst,void* pSrc, uint32_t size)
60638 +{
60639 + uint32_t leftAlign;
60640 + uint32_t rightAlign;
60641 + uint32_t lastWord;
60642 + uint32_t currWord;
60643 + uint32_t *p_Src32;
60644 + uint32_t *p_Dst32;
60645 + uint8_t *p_Src8;
60646 + uint8_t *p_Dst8;
60647 +
60648 + p_Src8 = (uint8_t*)(pSrc);
60649 + p_Dst8 = (uint8_t*)(pDst);
60650 + /* first copy byte by byte till the source first alignment
60651 + * this step is necessary to ensure we do not even try to access
60652 + * data which is before the source buffer, hence it is not ours.
60653 + */
60654 + while((PTR_TO_UINT(p_Src8) & 3) && size) /* (pSrc mod 4) > 0 and size > 0 */
60655 + {
60656 + WRITE_UINT8(*p_Dst8, *p_Src8);
60657 + p_Dst8++;p_Src8++;
60658 + size--;
60659 + }
60660 +
60661 + /* align destination (possibly disaligning source)*/
60662 + while((PTR_TO_UINT(p_Dst8) & 3) && size) /* (pDst mod 4) > 0 and size > 0 */
60663 + {
60664 + WRITE_UINT8(*p_Dst8, *p_Src8);
60665 + p_Dst8++;p_Src8++;
60666 + size--;
60667 + }
60668 +
60669 + /* dest is aligned and source is not necessarily aligned */
60670 + leftAlign = (uint32_t)((PTR_TO_UINT(p_Src8) & 3) << 3); /* leftAlign = (pSrc mod 4)*8 */
60671 + rightAlign = 32 - leftAlign;
60672 +
60673 + if (leftAlign == 0)
60674 + {
60675 + /* source is also aligned */
60676 + p_Src32 = (uint32_t*)(p_Src8);
60677 + p_Dst32 = (uint32_t*)(p_Dst8);
60678 + while (size >> 2) /* size >= 4 */
60679 + {
60680 + WRITE_UINT32(*p_Dst32, *p_Src32);
60681 + p_Dst32++;p_Src32++;
60682 + size -= 4;
60683 + }
60684 + p_Src8 = (uint8_t*)(p_Src32);
60685 + p_Dst8 = (uint8_t*)(p_Dst32);
60686 + }
60687 + else
60688 + {
60689 + /* source is not aligned (destination is aligned)*/
60690 + p_Src32 = (uint32_t*)(p_Src8 - (leftAlign >> 3));
60691 + p_Dst32 = (uint32_t*)(p_Dst8);
60692 + lastWord = *p_Src32++;
60693 + while(size >> 3) /* size >= 8 */
60694 + {
60695 + currWord = *p_Src32;
60696 + WRITE_UINT32(*p_Dst32, (lastWord << leftAlign) | (currWord >> rightAlign));
60697 + lastWord = currWord;
60698 + p_Src32++;p_Dst32++;
60699 + size -= 4;
60700 + }
60701 + p_Dst8 = (uint8_t*)(p_Dst32);
60702 + p_Src8 = (uint8_t*)(p_Src32) - 4 + (leftAlign >> 3);
60703 + }
60704 +
60705 + /* complete the left overs */
60706 + while (size--)
60707 + {
60708 + WRITE_UINT8(*p_Dst8, *p_Src8);
60709 + p_Dst8++;p_Src8++;
60710 + }
60711 +
60712 + return pDst;
60713 +}
60714 +
60715 +void * IO2MemCpy32(void* pDst,void* pSrc, uint32_t size)
60716 +{
60717 + uint32_t leftAlign;
60718 + uint32_t rightAlign;
60719 + uint32_t lastWord;
60720 + uint32_t currWord;
60721 + uint32_t *p_Src32;
60722 + uint32_t *p_Dst32;
60723 + uint8_t *p_Src8;
60724 + uint8_t *p_Dst8;
60725 +
60726 + p_Src8 = (uint8_t*)(pSrc);
60727 + p_Dst8 = (uint8_t*)(pDst);
60728 + /* first copy byte by byte till the source first alignment
60729 + * this step is necessary to ensure we do not even try to access
60730 + * data which is before the source buffer, hence it is not ours.
60731 + */
60732 + while((PTR_TO_UINT(p_Src8) & 3) && size) /* (pSrc mod 4) > 0 and size > 0 */
60733 + {
60734 + *p_Dst8 = GET_UINT8(*p_Src8);
60735 + p_Dst8++;p_Src8++;
60736 + size--;
60737 + }
60738 +
60739 + /* align destination (possibly disaligning source)*/
60740 + while((PTR_TO_UINT(p_Dst8) & 3) && size) /* (pDst mod 4) > 0 and size > 0 */
60741 + {
60742 + *p_Dst8 = GET_UINT8(*p_Src8);
60743 + p_Dst8++;p_Src8++;
60744 + size--;
60745 + }
60746 +
60747 + /* dest is aligned and source is not necessarily aligned */
60748 + leftAlign = (uint32_t)((PTR_TO_UINT(p_Src8) & 3) << 3); /* leftAlign = (pSrc mod 4)*8 */
60749 + rightAlign = 32 - leftAlign;
60750 +
60751 + if (leftAlign == 0)
60752 + {
60753 + /* source is also aligned */
60754 + p_Src32 = (uint32_t*)(p_Src8);
60755 + p_Dst32 = (uint32_t*)(p_Dst8);
60756 + while (size >> 2) /* size >= 4 */
60757 + {
60758 + *p_Dst32 = GET_UINT32(*p_Src32);
60759 + p_Dst32++;p_Src32++;
60760 + size -= 4;
60761 + }
60762 + p_Src8 = (uint8_t*)(p_Src32);
60763 + p_Dst8 = (uint8_t*)(p_Dst32);
60764 + }
60765 + else
60766 + {
60767 + /* source is not aligned (destination is aligned)*/
60768 + p_Src32 = (uint32_t*)(p_Src8 - (leftAlign >> 3));
60769 + p_Dst32 = (uint32_t*)(p_Dst8);
60770 + lastWord = GET_UINT32(*p_Src32);
60771 + p_Src32++;
60772 + while(size >> 3) /* size >= 8 */
60773 + {
60774 + currWord = GET_UINT32(*p_Src32);
60775 + *p_Dst32 = (lastWord << leftAlign) | (currWord >> rightAlign);
60776 + lastWord = currWord;
60777 + p_Src32++;p_Dst32++;
60778 + size -= 4;
60779 + }
60780 + p_Dst8 = (uint8_t*)(p_Dst32);
60781 + p_Src8 = (uint8_t*)(p_Src32) - 4 + (leftAlign >> 3);
60782 + }
60783 +
60784 + /* complete the left overs */
60785 + while (size--)
60786 + {
60787 + *p_Dst8 = GET_UINT8(*p_Src8);
60788 + p_Dst8++;p_Src8++;
60789 + }
60790 +
60791 + return pDst;
60792 +}
60793 +
60794 +void * MemCpy64(void* pDst,void* pSrc, uint32_t size)
60795 +{
60796 + uint32_t leftAlign;
60797 + uint32_t rightAlign;
60798 + uint64_t lastWord;
60799 + uint64_t currWord;
60800 + uint64_t *pSrc64;
60801 + uint64_t *pDst64;
60802 + uint8_t *p_Src8;
60803 + uint8_t *p_Dst8;
60804 +
60805 + p_Src8 = (uint8_t*)(pSrc);
60806 + p_Dst8 = (uint8_t*)(pDst);
60807 + /* first copy byte by byte till the source first alignment
60808 + * this step is necessarily to ensure we do not even try to access
60809 + * data which is before the source buffer, hence it is not ours.
60810 + */
60811 + while((PTR_TO_UINT(p_Src8) & 7) && size) /* (pSrc mod 8) > 0 and size > 0 */
60812 + {
60813 + *p_Dst8++ = *p_Src8++;
60814 + size--;
60815 + }
60816 +
60817 + /* align destination (possibly disaligning source)*/
60818 + while((PTR_TO_UINT(p_Dst8) & 7) && size) /* (pDst mod 8) > 0 and size > 0 */
60819 + {
60820 + *p_Dst8++ = *p_Src8++;
60821 + size--;
60822 + }
60823 +
60824 + /* dest is aligned and source is not necessarily aligned */
60825 + leftAlign = (uint32_t)((PTR_TO_UINT(p_Src8) & 7) << 3); /* leftAlign = (pSrc mod 8)*8 */
60826 + rightAlign = 64 - leftAlign;
60827 +
60828 +
60829 + if (leftAlign == 0)
60830 + {
60831 + /* source is also aligned */
60832 + pSrc64 = (uint64_t*)(p_Src8);
60833 + pDst64 = (uint64_t*)(p_Dst8);
60834 + while (size >> 3) /* size >= 8 */
60835 + {
60836 + *pDst64++ = *pSrc64++;
60837 + size -= 8;
60838 + }
60839 + p_Src8 = (uint8_t*)(pSrc64);
60840 + p_Dst8 = (uint8_t*)(pDst64);
60841 + }
60842 + else
60843 + {
60844 + /* source is not aligned (destination is aligned)*/
60845 + pSrc64 = (uint64_t*)(p_Src8 - (leftAlign >> 3));
60846 + pDst64 = (uint64_t*)(p_Dst8);
60847 + lastWord = *pSrc64++;
60848 + while(size >> 4) /* size >= 16 */
60849 + {
60850 + currWord = *pSrc64;
60851 + *pDst64 = (lastWord << leftAlign) | (currWord >> rightAlign);
60852 + lastWord = currWord;
60853 + pSrc64++;
60854 + pDst64++;
60855 + size -= 8;
60856 + }
60857 + p_Dst8 = (uint8_t*)(pDst64);
60858 + p_Src8 = (uint8_t*)(pSrc64) - 8 + (leftAlign >> 3);
60859 + }
60860 +
60861 + /* complete the left overs */
60862 + while (size--)
60863 + *p_Dst8++ = *p_Src8++;
60864 +
60865 + return pDst;
60866 +}
60867 +
60868 +void * MemSet32(void* pDst, uint8_t val, uint32_t size)
60869 +{
60870 + uint32_t val32;
60871 + uint32_t *p_Dst32;
60872 + uint8_t *p_Dst8;
60873 +
60874 + p_Dst8 = (uint8_t*)(pDst);
60875 +
60876 + /* generate four 8-bit val's in 32-bit container */
60877 + val32 = (uint32_t) val;
60878 + val32 |= (val32 << 8);
60879 + val32 |= (val32 << 16);
60880 +
60881 + /* align destination to 32 */
60882 + while((PTR_TO_UINT(p_Dst8) & 3) && size) /* (pDst mod 4) > 0 and size > 0 */
60883 + {
60884 + *p_Dst8++ = val;
60885 + size--;
60886 + }
60887 +
60888 + /* 32-bit chunks */
60889 + p_Dst32 = (uint32_t*)(p_Dst8);
60890 + while (size >> 2) /* size >= 4 */
60891 + {
60892 + *p_Dst32++ = val32;
60893 + size -= 4;
60894 + }
60895 +
60896 + /* complete the leftovers */
60897 + p_Dst8 = (uint8_t*)(p_Dst32);
60898 + while (size--)
60899 + *p_Dst8++ = val;
60900 +
60901 + return pDst;
60902 +}
60903 +
60904 +void * IOMemSet32(void* pDst, uint8_t val, uint32_t size)
60905 +{
60906 + uint32_t val32;
60907 + uint32_t *p_Dst32;
60908 + uint8_t *p_Dst8;
60909 +
60910 + p_Dst8 = (uint8_t*)(pDst);
60911 +
60912 + /* generate four 8-bit val's in 32-bit container */
60913 + val32 = (uint32_t) val;
60914 + val32 |= (val32 << 8);
60915 + val32 |= (val32 << 16);
60916 +
60917 + /* align destination to 32 */
60918 + while((PTR_TO_UINT(p_Dst8) & 3) && size) /* (pDst mod 4) > 0 and size > 0 */
60919 + {
60920 + WRITE_UINT8(*p_Dst8, val);
60921 + p_Dst8++;
60922 + size--;
60923 + }
60924 +
60925 + /* 32-bit chunks */
60926 + p_Dst32 = (uint32_t*)(p_Dst8);
60927 + while (size >> 2) /* size >= 4 */
60928 + {
60929 + WRITE_UINT32(*p_Dst32, val32);
60930 + p_Dst32++;
60931 + size -= 4;
60932 + }
60933 +
60934 + /* complete the leftovers */
60935 + p_Dst8 = (uint8_t*)(p_Dst32);
60936 + while (size--)
60937 + {
60938 + WRITE_UINT8(*p_Dst8, val);
60939 + p_Dst8++;
60940 + }
60941 +
60942 + return pDst;
60943 +}
60944 +
60945 +void * MemSet64(void* pDst, uint8_t val, uint32_t size)
60946 +{
60947 + uint64_t val64;
60948 + uint64_t *pDst64;
60949 + uint8_t *p_Dst8;
60950 +
60951 + p_Dst8 = (uint8_t*)(pDst);
60952 +
60953 + /* generate four 8-bit val's in 32-bit container */
60954 + val64 = (uint64_t) val;
60955 + val64 |= (val64 << 8);
60956 + val64 |= (val64 << 16);
60957 + val64 |= (val64 << 24);
60958 + val64 |= (val64 << 32);
60959 +
60960 + /* align destination to 64 */
60961 + while((PTR_TO_UINT(p_Dst8) & 7) && size) /* (pDst mod 8) > 0 and size > 0 */
60962 + {
60963 + *p_Dst8++ = val;
60964 + size--;
60965 + }
60966 +
60967 + /* 64-bit chunks */
60968 + pDst64 = (uint64_t*)(p_Dst8);
60969 + while (size >> 4) /* size >= 8 */
60970 + {
60971 + *pDst64++ = val64;
60972 + size -= 8;
60973 + }
60974 +
60975 + /* complete the leftovers */
60976 + p_Dst8 = (uint8_t*)(pDst64);
60977 + while (size--)
60978 + *p_Dst8++ = val;
60979 +
60980 + return pDst;
60981 +}
60982 +
60983 +void MemDisp(uint8_t *p, int size)
60984 +{
60985 + uint32_t space = (uint32_t)(PTR_TO_UINT(p) & 0x3);
60986 + uint8_t *p_Limit;
60987 +
60988 + if (space)
60989 + {
60990 + p_Limit = (p - space + 4);
60991 +
60992 + XX_Print("0x%08X: ", (p - space));
60993 +
60994 + while (space--)
60995 + {
60996 + XX_Print("--");
60997 + }
60998 + while (size && (p < p_Limit))
60999 + {
61000 + XX_Print("%02x", *(uint8_t*)p);
61001 + size--;
61002 + p++;
61003 + }
61004 +
61005 + XX_Print(" ");
61006 + p_Limit += 12;
61007 +
61008 + while ((size > 3) && (p < p_Limit))
61009 + {
61010 + XX_Print("%08x ", *(uint32_t*)p);
61011 + size -= 4;
61012 + p += 4;
61013 + }
61014 + XX_Print("\r\n");
61015 + }
61016 +
61017 + while (size > 15)
61018 + {
61019 + XX_Print("0x%08X: %08x %08x %08x %08x\r\n",
61020 + p, *(uint32_t *)p, *(uint32_t *)(p + 4),
61021 + *(uint32_t *)(p + 8), *(uint32_t *)(p + 12));
61022 + size -= 16;
61023 + p += 16;
61024 + }
61025 +
61026 + if (size)
61027 + {
61028 + XX_Print("0x%08X: ", p);
61029 +
61030 + while (size > 3)
61031 + {
61032 + XX_Print("%08x ", *(uint32_t *)p);
61033 + size -= 4;
61034 + p += 4;
61035 + }
61036 + while (size)
61037 + {
61038 + XX_Print("%02x", *(uint8_t *)p);
61039 + size--;
61040 + p++;
61041 + }
61042 +
61043 + XX_Print("\r\n");
61044 + }
61045 +}
61046 --- /dev/null
61047 +++ b/drivers/net/ethernet/freescale/sdk_fman/etc/mm.c
61048 @@ -0,0 +1,1155 @@
61049 +/*
61050 + * Copyright 2008-2012 Freescale Semiconductor Inc.
61051 + *
61052 + * Redistribution and use in source and binary forms, with or without
61053 + * modification, are permitted provided that the following conditions are met:
61054 + * * Redistributions of source code must retain the above copyright
61055 + * notice, this list of conditions and the following disclaimer.
61056 + * * Redistributions in binary form must reproduce the above copyright
61057 + * notice, this list of conditions and the following disclaimer in the
61058 + * documentation and/or other materials provided with the distribution.
61059 + * * Neither the name of Freescale Semiconductor nor the
61060 + * names of its contributors may be used to endorse or promote products
61061 + * derived from this software without specific prior written permission.
61062 + *
61063 + *
61064 + * ALTERNATIVELY, this software may be distributed under the terms of the
61065 + * GNU General Public License ("GPL") as published by the Free Software
61066 + * Foundation, either version 2 of that License or (at your option) any
61067 + * later version.
61068 + *
61069 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
61070 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
61071 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
61072 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
61073 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
61074 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
61075 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
61076 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61077 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
61078 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61079 + */
61080 +
61081 +
61082 +#include "string_ext.h"
61083 +#include "error_ext.h"
61084 +#include "std_ext.h"
61085 +#include "part_ext.h"
61086 +#include "xx_ext.h"
61087 +
61088 +#include "mm.h"
61089 +
61090 +
61091 +
61092 +
61093 +/**********************************************************************
61094 + * MM internal routines set *
61095 + **********************************************************************/
61096 +
61097 +/****************************************************************
61098 + * Routine: CreateBusyBlock
61099 + *
61100 + * Description:
61101 + * Initializes a new busy block of "size" bytes and started
61102 + * rom "base" address. Each busy block has a name that
61103 + * specified the purpose of the memory allocation.
61104 + *
61105 + * Arguments:
61106 + * base - base address of the busy block
61107 + * size - size of the busy block
61108 + * name - name that specified the busy block
61109 + *
61110 + * Return value:
61111 + * A pointer to new created structure returned on success;
61112 + * Otherwise, NULL.
61113 + ****************************************************************/
61114 +static t_BusyBlock * CreateBusyBlock(uint64_t base, uint64_t size, char *name)
61115 +{
61116 + t_BusyBlock *p_BusyBlock;
61117 + uint32_t n;
61118 +
61119 + p_BusyBlock = (t_BusyBlock *)XX_Malloc(sizeof(t_BusyBlock));
61120 + if ( !p_BusyBlock )
61121 + {
61122 + REPORT_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
61123 + return NULL;
61124 + }
61125 +
61126 + p_BusyBlock->base = base;
61127 + p_BusyBlock->end = base + size;
61128 +
61129 + n = strlen(name);
61130 + if (n >= MM_MAX_NAME_LEN)
61131 + n = MM_MAX_NAME_LEN - 1;
61132 + strncpy(p_BusyBlock->name, name, MM_MAX_NAME_LEN-1);
61133 + p_BusyBlock->name[n] = '\0';
61134 + p_BusyBlock->p_Next = 0;
61135 +
61136 + return p_BusyBlock;
61137 +}
61138 +
61139 +/****************************************************************
61140 + * Routine: CreateNewBlock
61141 + *
61142 + * Description:
61143 + * Initializes a new memory block of "size" bytes and started
61144 + * from "base" address.
61145 + *
61146 + * Arguments:
61147 + * base - base address of the memory block
61148 + * size - size of the memory block
61149 + *
61150 + * Return value:
61151 + * A pointer to new created structure returned on success;
61152 + * Otherwise, NULL.
61153 + ****************************************************************/
61154 +static t_MemBlock * CreateNewBlock(uint64_t base, uint64_t size)
61155 +{
61156 + t_MemBlock *p_MemBlock;
61157 +
61158 + p_MemBlock = (t_MemBlock *)XX_Malloc(sizeof(t_MemBlock));
61159 + if ( !p_MemBlock )
61160 + {
61161 + REPORT_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
61162 + return NULL;
61163 + }
61164 +
61165 + p_MemBlock->base = base;
61166 + p_MemBlock->end = base+size;
61167 + p_MemBlock->p_Next = 0;
61168 +
61169 + return p_MemBlock;
61170 +}
61171 +
61172 +/****************************************************************
61173 + * Routine: CreateFreeBlock
61174 + *
61175 + * Description:
61176 + * Initializes a new free block of of "size" bytes and
61177 + * started from "base" address.
61178 + *
61179 + * Arguments:
61180 + * base - base address of the free block
61181 + * size - size of the free block
61182 + *
61183 + * Return value:
61184 + * A pointer to new created structure returned on success;
61185 + * Otherwise, NULL.
61186 + ****************************************************************/
61187 +static t_FreeBlock * CreateFreeBlock(uint64_t base, uint64_t size)
61188 +{
61189 + t_FreeBlock *p_FreeBlock;
61190 +
61191 + p_FreeBlock = (t_FreeBlock *)XX_Malloc(sizeof(t_FreeBlock));
61192 + if ( !p_FreeBlock )
61193 + {
61194 + REPORT_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
61195 + return NULL;
61196 + }
61197 +
61198 + p_FreeBlock->base = base;
61199 + p_FreeBlock->end = base + size;
61200 + p_FreeBlock->p_Next = 0;
61201 +
61202 + return p_FreeBlock;
61203 +}
61204 +
61205 +/****************************************************************
61206 + * Routine: AddFree
61207 + *
61208 + * Description:
61209 + * Adds a new free block to the free lists. It updates each
61210 + * free list to include a new free block.
61211 + * Note, that all free block in each free list are ordered
61212 + * by their base address.
61213 + *
61214 + * Arguments:
61215 + * p_MM - pointer to the MM object
61216 + * base - base address of a given free block
61217 + * end - end address of a given free block
61218 + *
61219 + * Return value:
61220 + *
61221 + *
61222 + ****************************************************************/
61223 +static t_Error AddFree(t_MM *p_MM, uint64_t base, uint64_t end)
61224 +{
61225 + t_FreeBlock *p_PrevB, *p_CurrB, *p_NewB;
61226 + uint64_t alignment;
61227 + uint64_t alignBase;
61228 + int i;
61229 +
61230 + /* Updates free lists to include a just released block */
61231 + for (i=0; i <= MM_MAX_ALIGNMENT; i++)
61232 + {
61233 + p_PrevB = p_NewB = 0;
61234 + p_CurrB = p_MM->freeBlocks[i];
61235 +
61236 + alignment = (uint64_t)(0x1 << i);
61237 + alignBase = MAKE_ALIGNED(base, alignment);
61238 +
61239 + /* Goes to the next free list if there is no block to free */
61240 + if (alignBase >= end)
61241 + continue;
61242 +
61243 + /* Looks for a free block that should be updated */
61244 + while ( p_CurrB )
61245 + {
61246 + if ( alignBase <= p_CurrB->end )
61247 + {
61248 + if ( end > p_CurrB->end )
61249 + {
61250 + t_FreeBlock *p_NextB;
61251 + while ( p_CurrB->p_Next && end > p_CurrB->p_Next->end )
61252 + {
61253 + p_NextB = p_CurrB->p_Next;
61254 + p_CurrB->p_Next = p_CurrB->p_Next->p_Next;
61255 + XX_Free(p_NextB);
61256 + }
61257 +
61258 + p_NextB = p_CurrB->p_Next;
61259 + if ( !p_NextB || (p_NextB && end < p_NextB->base) )
61260 + {
61261 + p_CurrB->end = end;
61262 + }
61263 + else
61264 + {
61265 + p_CurrB->end = p_NextB->end;
61266 + p_CurrB->p_Next = p_NextB->p_Next;
61267 + XX_Free(p_NextB);
61268 + }
61269 + }
61270 + else if ( (end < p_CurrB->base) && ((end-alignBase) >= alignment) )
61271 + {
61272 + if ((p_NewB = CreateFreeBlock(alignBase, end-alignBase)) == NULL)
61273 + RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
61274 +
61275 + p_NewB->p_Next = p_CurrB;
61276 + if (p_PrevB)
61277 + p_PrevB->p_Next = p_NewB;
61278 + else
61279 + p_MM->freeBlocks[i] = p_NewB;
61280 + break;
61281 + }
61282 +
61283 + if ((alignBase < p_CurrB->base) && (end >= p_CurrB->base))
61284 + {
61285 + p_CurrB->base = alignBase;
61286 + }
61287 +
61288 + /* if size of the free block is less then alignment
61289 + * deletes that free block from the free list. */
61290 + if ( (p_CurrB->end - p_CurrB->base) < alignment)
61291 + {
61292 + if ( p_PrevB )
61293 + p_PrevB->p_Next = p_CurrB->p_Next;
61294 + else
61295 + p_MM->freeBlocks[i] = p_CurrB->p_Next;
61296 + XX_Free(p_CurrB);
61297 + p_CurrB = NULL;
61298 + }
61299 + break;
61300 + }
61301 + else
61302 + {
61303 + p_PrevB = p_CurrB;
61304 + p_CurrB = p_CurrB->p_Next;
61305 + }
61306 + }
61307 +
61308 + /* If no free block found to be updated, insert a new free block
61309 + * to the end of the free list.
61310 + */
61311 + if ( !p_CurrB && ((((uint64_t)(end-base)) & ((uint64_t)(alignment-1))) == 0) )
61312 + {
61313 + if ((p_NewB = CreateFreeBlock(alignBase, end-base)) == NULL)
61314 + RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
61315 +
61316 + if (p_PrevB)
61317 + p_PrevB->p_Next = p_NewB;
61318 + else
61319 + p_MM->freeBlocks[i] = p_NewB;
61320 + }
61321 +
61322 + /* Update boundaries of the new free block */
61323 + if ((alignment == 1) && !p_NewB)
61324 + {
61325 + if ( p_CurrB && base > p_CurrB->base )
61326 + base = p_CurrB->base;
61327 + if ( p_CurrB && end < p_CurrB->end )
61328 + end = p_CurrB->end;
61329 + }
61330 + }
61331 +
61332 + return (E_OK);
61333 +}
61334 +
61335 +/****************************************************************
61336 + * Routine: CutFree
61337 + *
61338 + * Description:
61339 + * Cuts a free block from holdBase to holdEnd from the free lists.
61340 + * That is, it updates all free lists of the MM object do
61341 + * not include a block of memory from holdBase to holdEnd.
61342 + * For each free lists it seek for a free block that holds
61343 + * either holdBase or holdEnd. If such block is found it updates it.
61344 + *
61345 + * Arguments:
61346 + * p_MM - pointer to the MM object
61347 + * holdBase - base address of the allocated block
61348 + * holdEnd - end address of the allocated block
61349 + *
61350 + * Return value:
61351 + * E_OK is returned on success,
61352 + * otherwise returns an error code.
61353 + *
61354 + ****************************************************************/
61355 +static t_Error CutFree(t_MM *p_MM, uint64_t holdBase, uint64_t holdEnd)
61356 +{
61357 + t_FreeBlock *p_PrevB, *p_CurrB, *p_NewB;
61358 + uint64_t alignBase, base, end;
61359 + uint64_t alignment;
61360 + int i;
61361 +
61362 + for (i=0; i <= MM_MAX_ALIGNMENT; i++)
61363 + {
61364 + p_PrevB = p_NewB = 0;
61365 + p_CurrB = p_MM->freeBlocks[i];
61366 +
61367 + alignment = (uint64_t)(0x1 << i);
61368 + alignBase = MAKE_ALIGNED(holdEnd, alignment);
61369 +
61370 + while ( p_CurrB )
61371 + {
61372 + base = p_CurrB->base;
61373 + end = p_CurrB->end;
61374 +
61375 + if ( (holdBase <= base) && (holdEnd <= end) && (holdEnd > base) )
61376 + {
61377 + if ( alignBase >= end ||
61378 + (alignBase < end && ((end-alignBase) < alignment)) )
61379 + {
61380 + if (p_PrevB)
61381 + p_PrevB->p_Next = p_CurrB->p_Next;
61382 + else
61383 + p_MM->freeBlocks[i] = p_CurrB->p_Next;
61384 + XX_Free(p_CurrB);
61385 + }
61386 + else
61387 + {
61388 + p_CurrB->base = alignBase;
61389 + }
61390 + break;
61391 + }
61392 + else if ( (holdBase > base) && (holdEnd <= end) )
61393 + {
61394 + if ( (holdBase-base) >= alignment )
61395 + {
61396 + if ( (alignBase < end) && ((end-alignBase) >= alignment) )
61397 + {
61398 + if ((p_NewB = CreateFreeBlock(alignBase, end-alignBase)) == NULL)
61399 + RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
61400 + p_NewB->p_Next = p_CurrB->p_Next;
61401 + p_CurrB->p_Next = p_NewB;
61402 + }
61403 + p_CurrB->end = holdBase;
61404 + }
61405 + else if ( (alignBase < end) && ((end-alignBase) >= alignment) )
61406 + {
61407 + p_CurrB->base = alignBase;
61408 + }
61409 + else
61410 + {
61411 + if (p_PrevB)
61412 + p_PrevB->p_Next = p_CurrB->p_Next;
61413 + else
61414 + p_MM->freeBlocks[i] = p_CurrB->p_Next;
61415 + XX_Free(p_CurrB);
61416 + }
61417 + break;
61418 + }
61419 + else
61420 + {
61421 + p_PrevB = p_CurrB;
61422 + p_CurrB = p_CurrB->p_Next;
61423 + }
61424 + }
61425 + }
61426 +
61427 + return (E_OK);
61428 +}
61429 +
61430 +/****************************************************************
61431 + * Routine: AddBusy
61432 + *
61433 + * Description:
61434 + * Adds a new busy block to the list of busy blocks. Note,
61435 + * that all busy blocks are ordered by their base address in
61436 + * the busy list.
61437 + *
61438 + * Arguments:
61439 + * MM - handler to the MM object
61440 + * p_NewBusyB - pointer to the a busy block
61441 + *
61442 + * Return value:
61443 + * None.
61444 + *
61445 + ****************************************************************/
61446 +static void AddBusy(t_MM *p_MM, t_BusyBlock *p_NewBusyB)
61447 +{
61448 + t_BusyBlock *p_CurrBusyB, *p_PrevBusyB;
61449 +
61450 + /* finds a place of a new busy block in the list of busy blocks */
61451 + p_PrevBusyB = 0;
61452 + p_CurrBusyB = p_MM->busyBlocks;
61453 +
61454 + while ( p_CurrBusyB && p_NewBusyB->base > p_CurrBusyB->base )
61455 + {
61456 + p_PrevBusyB = p_CurrBusyB;
61457 + p_CurrBusyB = p_CurrBusyB->p_Next;
61458 + }
61459 +
61460 + /* insert the new busy block into the list of busy blocks */
61461 + if ( p_CurrBusyB )
61462 + p_NewBusyB->p_Next = p_CurrBusyB;
61463 + if ( p_PrevBusyB )
61464 + p_PrevBusyB->p_Next = p_NewBusyB;
61465 + else
61466 + p_MM->busyBlocks = p_NewBusyB;
61467 +}
61468 +
61469 +/****************************************************************
61470 + * Routine: CutBusy
61471 + *
61472 + * Description:
61473 + * Cuts a block from base to end from the list of busy blocks.
61474 + * This is done by updating the list of busy blocks do not
61475 + * include a given block, that block is going to be free. If a
61476 + * given block is a part of some other busy block, so that
61477 + * busy block is updated. If there are number of busy blocks
61478 + * included in the given block, so all that blocks are removed
61479 + * from the busy list and the end blocks are updated.
61480 + * If the given block devides some block into two parts, a new
61481 + * busy block is added to the busy list.
61482 + *
61483 + * Arguments:
61484 + * p_MM - pointer to the MM object
61485 + * base - base address of a given busy block
61486 + * end - end address of a given busy block
61487 + *
61488 + * Return value:
61489 + * E_OK on success, E_NOMEMORY otherwise.
61490 + *
61491 + ****************************************************************/
61492 +static t_Error CutBusy(t_MM *p_MM, uint64_t base, uint64_t end)
61493 +{
61494 + t_BusyBlock *p_CurrB, *p_PrevB, *p_NewB;
61495 +
61496 + p_CurrB = p_MM->busyBlocks;
61497 + p_PrevB = p_NewB = 0;
61498 +
61499 + while ( p_CurrB )
61500 + {
61501 + if ( base < p_CurrB->end )
61502 + {
61503 + if ( end > p_CurrB->end )
61504 + {
61505 + t_BusyBlock *p_NextB;
61506 + while ( p_CurrB->p_Next && end >= p_CurrB->p_Next->end )
61507 + {
61508 + p_NextB = p_CurrB->p_Next;
61509 + p_CurrB->p_Next = p_CurrB->p_Next->p_Next;
61510 + XX_Free(p_NextB);
61511 + }
61512 +
61513 + p_NextB = p_CurrB->p_Next;
61514 + if ( p_NextB && end > p_NextB->base )
61515 + {
61516 + p_NextB->base = end;
61517 + }
61518 + }
61519 +
61520 + if ( base <= p_CurrB->base )
61521 + {
61522 + if ( end < p_CurrB->end && end > p_CurrB->base )
61523 + {
61524 + p_CurrB->base = end;
61525 + }
61526 + else if ( end >= p_CurrB->end )
61527 + {
61528 + if ( p_PrevB )
61529 + p_PrevB->p_Next = p_CurrB->p_Next;
61530 + else
61531 + p_MM->busyBlocks = p_CurrB->p_Next;
61532 + XX_Free(p_CurrB);
61533 + }
61534 + }
61535 + else
61536 + {
61537 + if ( end < p_CurrB->end && end > p_CurrB->base )
61538 + {
61539 + if ((p_NewB = CreateBusyBlock(end,
61540 + p_CurrB->end-end,
61541 + p_CurrB->name)) == NULL)
61542 + RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
61543 + p_NewB->p_Next = p_CurrB->p_Next;
61544 + p_CurrB->p_Next = p_NewB;
61545 + }
61546 + p_CurrB->end = base;
61547 + }
61548 + break;
61549 + }
61550 + else
61551 + {
61552 + p_PrevB = p_CurrB;
61553 + p_CurrB = p_CurrB->p_Next;
61554 + }
61555 + }
61556 +
61557 + return (E_OK);
61558 +}
61559 +
61560 +/****************************************************************
61561 + * Routine: MmGetGreaterAlignment
61562 + *
61563 + * Description:
61564 + * Allocates a block of memory according to the given size
61565 + * and the alignment. That routine is called from the MM_Get
61566 + * routine if the required alignment is greater then MM_MAX_ALIGNMENT.
61567 + * In that case, it goes over free blocks of 64 byte align list
61568 + * and checks if it has the required size of bytes of the required
61569 + * alignment. If no blocks found returns ILLEGAL_BASE.
61570 + * After the block is found and data is allocated, it calls
61571 + * the internal CutFree routine to update all free lists
61572 + * do not include a just allocated block. Of course, each
61573 + * free list contains a free blocks with the same alignment.
61574 + * It is also creates a busy block that holds
61575 + * information about an allocated block.
61576 + *
61577 + * Arguments:
61578 + * MM - handle to the MM object
61579 + * size - size of the MM
61580 + * alignment - index as a power of two defines
61581 + * a required alignment that is greater then 64.
61582 + * name - the name that specifies an allocated block.
61583 + *
61584 + * Return value:
61585 + * base address of an allocated block.
61586 + * ILLEGAL_BASE if can't allocate a block
61587 + *
61588 + ****************************************************************/
61589 +static uint64_t MmGetGreaterAlignment(t_MM *p_MM, uint64_t size, uint64_t alignment, char* name)
61590 +{
61591 + t_FreeBlock *p_FreeB;
61592 + t_BusyBlock *p_NewBusyB;
61593 + uint64_t holdBase, holdEnd, alignBase = 0;
61594 +
61595 + /* goes over free blocks of the 64 byte alignment list
61596 + and look for a block of the suitable size and
61597 + base address according to the alignment. */
61598 + p_FreeB = p_MM->freeBlocks[MM_MAX_ALIGNMENT];
61599 +
61600 + while ( p_FreeB )
61601 + {
61602 + alignBase = MAKE_ALIGNED(p_FreeB->base, alignment);
61603 +
61604 + /* the block is found if the aligned base inside the block
61605 + * and has the anough size. */
61606 + if ( alignBase >= p_FreeB->base &&
61607 + alignBase < p_FreeB->end &&
61608 + size <= (p_FreeB->end - alignBase) )
61609 + break;
61610 + else
61611 + p_FreeB = p_FreeB->p_Next;
61612 + }
61613 +
61614 + /* If such block isn't found */
61615 + if ( !p_FreeB )
61616 + return (uint64_t)(ILLEGAL_BASE);
61617 +
61618 + holdBase = alignBase;
61619 + holdEnd = alignBase + size;
61620 +
61621 + /* init a new busy block */
61622 + if ((p_NewBusyB = CreateBusyBlock(holdBase, size, name)) == NULL)
61623 + return (uint64_t)(ILLEGAL_BASE);
61624 +
61625 + /* calls Update routine to update a lists of free blocks */
61626 + if ( CutFree ( p_MM, holdBase, holdEnd ) != E_OK )
61627 + {
61628 + XX_Free(p_NewBusyB);
61629 + return (uint64_t)(ILLEGAL_BASE);
61630 + }
61631 +
61632 + /* insert the new busy block into the list of busy blocks */
61633 + AddBusy ( p_MM, p_NewBusyB );
61634 +
61635 + return (holdBase);
61636 +}
61637 +
61638 +
61639 +/**********************************************************************
61640 + * MM API routines set *
61641 + **********************************************************************/
61642 +
61643 +/*****************************************************************************/
61644 +t_Error MM_Init(t_Handle *h_MM, uint64_t base, uint64_t size)
61645 +{
61646 + t_MM *p_MM;
61647 + uint64_t newBase, newSize;
61648 + int i;
61649 +
61650 + if (!size)
61651 + {
61652 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Size (should be positive)"));
61653 + }
61654 +
61655 + /* Initializes a new MM object */
61656 + p_MM = (t_MM *)XX_Malloc(sizeof(t_MM));
61657 + if (!p_MM)
61658 + {
61659 + RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
61660 + }
61661 +
61662 + p_MM->h_Spinlock = XX_InitSpinlock();
61663 + if (!p_MM->h_Spinlock)
61664 + {
61665 + XX_Free(p_MM);
61666 + RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MM spinlock!"));
61667 + }
61668 +
61669 + /* Initializes counter of free memory to total size */
61670 + p_MM->freeMemSize = size;
61671 +
61672 + /* A busy list is empty */
61673 + p_MM->busyBlocks = 0;
61674 +
61675 + /* Initializes a new memory block */
61676 + if ((p_MM->memBlocks = CreateNewBlock(base, size)) == NULL)
61677 + {
61678 + MM_Free(p_MM);
61679 + RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
61680 + }
61681 +
61682 + /* Initializes a new free block for each free list*/
61683 + for (i=0; i <= MM_MAX_ALIGNMENT; i++)
61684 + {
61685 + newBase = MAKE_ALIGNED( base, (0x1 << i) );
61686 + newSize = size - (newBase - base);
61687 +
61688 + if ((p_MM->freeBlocks[i] = CreateFreeBlock(newBase, newSize)) == NULL)
61689 + {
61690 + MM_Free(p_MM);
61691 + RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
61692 + }
61693 + }
61694 +
61695 + *h_MM = p_MM;
61696 +
61697 + return (E_OK);
61698 +}
61699 +
61700 +/*****************************************************************************/
61701 +void MM_Free(t_Handle h_MM)
61702 +{
61703 + t_MM *p_MM = (t_MM *)h_MM;
61704 + t_MemBlock *p_MemBlock;
61705 + t_BusyBlock *p_BusyBlock;
61706 + t_FreeBlock *p_FreeBlock;
61707 + void *p_Block;
61708 + int i;
61709 +
61710 + ASSERT_COND(p_MM);
61711 +
61712 + /* release memory allocated for busy blocks */
61713 + p_BusyBlock = p_MM->busyBlocks;
61714 + while ( p_BusyBlock )
61715 + {
61716 + p_Block = p_BusyBlock;
61717 + p_BusyBlock = p_BusyBlock->p_Next;
61718 + XX_Free(p_Block);
61719 + }
61720 +
61721 + /* release memory allocated for free blocks */
61722 + for (i=0; i <= MM_MAX_ALIGNMENT; i++)
61723 + {
61724 + p_FreeBlock = p_MM->freeBlocks[i];
61725 + while ( p_FreeBlock )
61726 + {
61727 + p_Block = p_FreeBlock;
61728 + p_FreeBlock = p_FreeBlock->p_Next;
61729 + XX_Free(p_Block);
61730 + }
61731 + }
61732 +
61733 + /* release memory allocated for memory blocks */
61734 + p_MemBlock = p_MM->memBlocks;
61735 + while ( p_MemBlock )
61736 + {
61737 + p_Block = p_MemBlock;
61738 + p_MemBlock = p_MemBlock->p_Next;
61739 + XX_Free(p_Block);
61740 + }
61741 +
61742 + if (p_MM->h_Spinlock)
61743 + XX_FreeSpinlock(p_MM->h_Spinlock);
61744 +
61745 + /* release memory allocated for MM object itself */
61746 + XX_Free(p_MM);
61747 +}
61748 +
61749 +/*****************************************************************************/
61750 +uint64_t MM_Get(t_Handle h_MM, uint64_t size, uint64_t alignment, char* name)
61751 +{
61752 + t_MM *p_MM = (t_MM *)h_MM;
61753 + t_FreeBlock *p_FreeB;
61754 + t_BusyBlock *p_NewBusyB;
61755 + uint64_t holdBase, holdEnd, j, i = 0;
61756 + uint32_t intFlags;
61757 +
61758 + SANITY_CHECK_RETURN_VALUE(p_MM, E_INVALID_HANDLE, (uint64_t)ILLEGAL_BASE);
61759 +
61760 + /* checks that alignment value is greater then zero */
61761 + if (alignment == 0)
61762 + {
61763 + alignment = 1;
61764 + }
61765 +
61766 + j = alignment;
61767 +
61768 + /* checks if alignment is a power of two, if it correct and if the
61769 + required size is multiple of the given alignment. */
61770 + while ((j & 0x1) == 0)
61771 + {
61772 + i++;
61773 + j = j >> 1;
61774 + }
61775 +
61776 + /* if the given alignment isn't power of two, returns an error */
61777 + if (j != 1)
61778 + {
61779 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("alignment (should be power of 2)"));
61780 + return (uint64_t)ILLEGAL_BASE;
61781 + }
61782 +
61783 + if (i > MM_MAX_ALIGNMENT)
61784 + {
61785 + return (MmGetGreaterAlignment(p_MM, size, alignment, name));
61786 + }
61787 +
61788 + intFlags = XX_LockIntrSpinlock(p_MM->h_Spinlock);
61789 + /* look for a block of the size greater or equal to the required size. */
61790 + p_FreeB = p_MM->freeBlocks[i];
61791 + while ( p_FreeB && (p_FreeB->end - p_FreeB->base) < size )
61792 + p_FreeB = p_FreeB->p_Next;
61793 +
61794 + /* If such block is found */
61795 + if ( !p_FreeB )
61796 + {
61797 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
61798 + return (uint64_t)(ILLEGAL_BASE);
61799 + }
61800 +
61801 + holdBase = p_FreeB->base;
61802 + holdEnd = holdBase + size;
61803 +
61804 + /* init a new busy block */
61805 + if ((p_NewBusyB = CreateBusyBlock(holdBase, size, name)) == NULL)
61806 + {
61807 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
61808 + return (uint64_t)(ILLEGAL_BASE);
61809 + }
61810 +
61811 + /* calls Update routine to update a lists of free blocks */
61812 + if ( CutFree ( p_MM, holdBase, holdEnd ) != E_OK )
61813 + {
61814 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
61815 + XX_Free(p_NewBusyB);
61816 + return (uint64_t)(ILLEGAL_BASE);
61817 + }
61818 +
61819 + /* Decreasing the allocated memory size from free memory size */
61820 + p_MM->freeMemSize -= size;
61821 +
61822 + /* insert the new busy block into the list of busy blocks */
61823 + AddBusy ( p_MM, p_NewBusyB );
61824 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
61825 +
61826 + return (holdBase);
61827 +}
61828 +
61829 +/*****************************************************************************/
61830 +uint64_t MM_GetForce(t_Handle h_MM, uint64_t base, uint64_t size, char* name)
61831 +{
61832 + t_MM *p_MM = (t_MM *)h_MM;
61833 + t_FreeBlock *p_FreeB;
61834 + t_BusyBlock *p_NewBusyB;
61835 + uint32_t intFlags;
61836 + bool blockIsFree = FALSE;
61837 +
61838 + ASSERT_COND(p_MM);
61839 +
61840 + intFlags = XX_LockIntrSpinlock(p_MM->h_Spinlock);
61841 + p_FreeB = p_MM->freeBlocks[0]; /* The biggest free blocks are in the
61842 + free list with alignment 1 */
61843 +
61844 + while ( p_FreeB )
61845 + {
61846 + if ( base >= p_FreeB->base && (base+size) <= p_FreeB->end )
61847 + {
61848 + blockIsFree = TRUE;
61849 + break;
61850 + }
61851 + else
61852 + p_FreeB = p_FreeB->p_Next;
61853 + }
61854 +
61855 + if ( !blockIsFree )
61856 + {
61857 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
61858 + return (uint64_t)(ILLEGAL_BASE);
61859 + }
61860 +
61861 + /* init a new busy block */
61862 + if ((p_NewBusyB = CreateBusyBlock(base, size, name)) == NULL)
61863 + {
61864 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
61865 + return (uint64_t)(ILLEGAL_BASE);
61866 + }
61867 +
61868 + /* calls Update routine to update a lists of free blocks */
61869 + if ( CutFree ( p_MM, base, base+size ) != E_OK )
61870 + {
61871 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
61872 + XX_Free(p_NewBusyB);
61873 + return (uint64_t)(ILLEGAL_BASE);
61874 + }
61875 +
61876 + /* Decreasing the allocated memory size from free memory size */
61877 + p_MM->freeMemSize -= size;
61878 +
61879 + /* insert the new busy block into the list of busy blocks */
61880 + AddBusy ( p_MM, p_NewBusyB );
61881 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
61882 +
61883 + return (base);
61884 +}
61885 +
61886 +/*****************************************************************************/
61887 +uint64_t MM_GetForceMin(t_Handle h_MM, uint64_t size, uint64_t alignment, uint64_t min, char* name)
61888 +{
61889 + t_MM *p_MM = (t_MM *)h_MM;
61890 + t_FreeBlock *p_FreeB;
61891 + t_BusyBlock *p_NewBusyB;
61892 + uint64_t holdBase, holdEnd, j = alignment, i=0;
61893 + uint32_t intFlags;
61894 +
61895 + ASSERT_COND(p_MM);
61896 +
61897 + /* checks if alignment is a power of two, if it correct and if the
61898 + required size is multiple of the given alignment. */
61899 + while ((j & 0x1) == 0)
61900 + {
61901 + i++;
61902 + j = j >> 1;
61903 + }
61904 +
61905 + if ( (j != 1) || (i > MM_MAX_ALIGNMENT) )
61906 + {
61907 + return (uint64_t)(ILLEGAL_BASE);
61908 + }
61909 +
61910 + intFlags = XX_LockIntrSpinlock(p_MM->h_Spinlock);
61911 + p_FreeB = p_MM->freeBlocks[i];
61912 +
61913 + /* look for the first block that contains the minimum
61914 + base address. If the whole required size may be fit
61915 + into it, use that block, otherwise look for the next
61916 + block of size greater or equal to the required size. */
61917 + while ( p_FreeB && (min >= p_FreeB->end))
61918 + p_FreeB = p_FreeB->p_Next;
61919 +
61920 + /* If such block is found */
61921 + if ( !p_FreeB )
61922 + {
61923 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
61924 + return (uint64_t)(ILLEGAL_BASE);
61925 + }
61926 +
61927 + /* if this block is large enough, use this block */
61928 + holdBase = ( min <= p_FreeB->base ) ? p_FreeB->base : min;
61929 + if ((holdBase + size) <= p_FreeB->end )
61930 + {
61931 + holdEnd = holdBase + size;
61932 + }
61933 + else
61934 + {
61935 + p_FreeB = p_FreeB->p_Next;
61936 + while ( p_FreeB && ((p_FreeB->end - p_FreeB->base) < size) )
61937 + p_FreeB = p_FreeB->p_Next;
61938 +
61939 + /* If such block is found */
61940 + if ( !p_FreeB )
61941 + {
61942 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
61943 + return (uint64_t)(ILLEGAL_BASE);
61944 + }
61945 +
61946 + holdBase = p_FreeB->base;
61947 + holdEnd = holdBase + size;
61948 + }
61949 +
61950 + /* init a new busy block */
61951 + if ((p_NewBusyB = CreateBusyBlock(holdBase, size, name)) == NULL)
61952 + {
61953 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
61954 + return (uint64_t)(ILLEGAL_BASE);
61955 + }
61956 +
61957 + /* calls Update routine to update a lists of free blocks */
61958 + if ( CutFree( p_MM, holdBase, holdEnd ) != E_OK )
61959 + {
61960 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
61961 + XX_Free(p_NewBusyB);
61962 + return (uint64_t)(ILLEGAL_BASE);
61963 + }
61964 +
61965 + /* Decreasing the allocated memory size from free memory size */
61966 + p_MM->freeMemSize -= size;
61967 +
61968 + /* insert the new busy block into the list of busy blocks */
61969 + AddBusy( p_MM, p_NewBusyB );
61970 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
61971 +
61972 + return (holdBase);
61973 +}
61974 +
61975 +/*****************************************************************************/
61976 +uint64_t MM_Put(t_Handle h_MM, uint64_t base)
61977 +{
61978 + t_MM *p_MM = (t_MM *)h_MM;
61979 + t_BusyBlock *p_BusyB, *p_PrevBusyB;
61980 + uint64_t size;
61981 + uint32_t intFlags;
61982 +
61983 + ASSERT_COND(p_MM);
61984 +
61985 + /* Look for a busy block that have the given base value.
61986 + * That block will be returned back to the memory.
61987 + */
61988 + p_PrevBusyB = 0;
61989 +
61990 + intFlags = XX_LockIntrSpinlock(p_MM->h_Spinlock);
61991 + p_BusyB = p_MM->busyBlocks;
61992 + while ( p_BusyB && base != p_BusyB->base )
61993 + {
61994 + p_PrevBusyB = p_BusyB;
61995 + p_BusyB = p_BusyB->p_Next;
61996 + }
61997 +
61998 + if ( !p_BusyB )
61999 + {
62000 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
62001 + return (uint64_t)(0);
62002 + }
62003 +
62004 + if ( AddFree( p_MM, p_BusyB->base, p_BusyB->end ) != E_OK )
62005 + {
62006 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
62007 + return (uint64_t)(0);
62008 + }
62009 +
62010 + /* removes a busy block form the list of busy blocks */
62011 + if ( p_PrevBusyB )
62012 + p_PrevBusyB->p_Next = p_BusyB->p_Next;
62013 + else
62014 + p_MM->busyBlocks = p_BusyB->p_Next;
62015 +
62016 + size = p_BusyB->end - p_BusyB->base;
62017 +
62018 + /* Adding the deallocated memory size to free memory size */
62019 + p_MM->freeMemSize += size;
62020 +
62021 + XX_Free(p_BusyB);
62022 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
62023 +
62024 + return (size);
62025 +}
62026 +
62027 +/*****************************************************************************/
62028 +uint64_t MM_PutForce(t_Handle h_MM, uint64_t base, uint64_t size)
62029 +{
62030 + t_MM *p_MM = (t_MM *)h_MM;
62031 + uint64_t end = base + size;
62032 + uint32_t intFlags;
62033 +
62034 + ASSERT_COND(p_MM);
62035 +
62036 + intFlags = XX_LockIntrSpinlock(p_MM->h_Spinlock);
62037 +
62038 + if ( CutBusy( p_MM, base, end ) != E_OK )
62039 + {
62040 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
62041 + return (uint64_t)(0);
62042 + }
62043 +
62044 + if ( AddFree ( p_MM, base, end ) != E_OK )
62045 + {
62046 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
62047 + return (uint64_t)(0);
62048 + }
62049 +
62050 + /* Adding the deallocated memory size to free memory size */
62051 + p_MM->freeMemSize += size;
62052 +
62053 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
62054 +
62055 + return (size);
62056 +}
62057 +
62058 +/*****************************************************************************/
62059 +t_Error MM_Add(t_Handle h_MM, uint64_t base, uint64_t size)
62060 +{
62061 + t_MM *p_MM = (t_MM *)h_MM;
62062 + t_MemBlock *p_MemB, *p_NewMemB;
62063 + t_Error errCode;
62064 + uint32_t intFlags;
62065 +
62066 + ASSERT_COND(p_MM);
62067 +
62068 + /* find a last block in the list of memory blocks to insert a new
62069 + * memory block
62070 + */
62071 + intFlags = XX_LockIntrSpinlock(p_MM->h_Spinlock);
62072 +
62073 + p_MemB = p_MM->memBlocks;
62074 + while ( p_MemB->p_Next )
62075 + {
62076 + if ( base >= p_MemB->base && base < p_MemB->end )
62077 + {
62078 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
62079 + RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, NO_MSG);
62080 + }
62081 + p_MemB = p_MemB->p_Next;
62082 + }
62083 + /* check for a last memory block */
62084 + if ( base >= p_MemB->base && base < p_MemB->end )
62085 + {
62086 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
62087 + RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, NO_MSG);
62088 + }
62089 +
62090 + /* create a new memory block */
62091 + if ((p_NewMemB = CreateNewBlock(base, size)) == NULL)
62092 + {
62093 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
62094 + RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
62095 + }
62096 +
62097 + /* append a new memory block to the end of the list of memory blocks */
62098 + p_MemB->p_Next = p_NewMemB;
62099 +
62100 + /* add a new free block to the free lists */
62101 + errCode = AddFree(p_MM, base, base+size);
62102 + if (errCode)
62103 + {
62104 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
62105 + p_MemB->p_Next = 0;
62106 + XX_Free(p_NewMemB);
62107 + return ((t_Error)errCode);
62108 + }
62109 +
62110 + /* Adding the new block size to free memory size */
62111 + p_MM->freeMemSize += size;
62112 +
62113 + XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
62114 +
62115 + return (E_OK);
62116 +}
62117 +
62118 +/*****************************************************************************/
62119 +uint64_t MM_GetMemBlock(t_Handle h_MM, int index)
62120 +{
62121 + t_MM *p_MM = (t_MM*)h_MM;
62122 + t_MemBlock *p_MemBlock;
62123 + int i;
62124 +
62125 + ASSERT_COND(p_MM);
62126 +
62127 + p_MemBlock = p_MM->memBlocks;
62128 + for (i=0; i < index; i++)
62129 + p_MemBlock = p_MemBlock->p_Next;
62130 +
62131 + if ( p_MemBlock )
62132 + return (p_MemBlock->base);
62133 + else
62134 + return (uint64_t)ILLEGAL_BASE;
62135 +}
62136 +
62137 +/*****************************************************************************/
62138 +uint64_t MM_GetBase(t_Handle h_MM)
62139 +{
62140 + t_MM *p_MM = (t_MM*)h_MM;
62141 + t_MemBlock *p_MemBlock;
62142 +
62143 + ASSERT_COND(p_MM);
62144 +
62145 + p_MemBlock = p_MM->memBlocks;
62146 + return p_MemBlock->base;
62147 +}
62148 +
62149 +/*****************************************************************************/
62150 +bool MM_InRange(t_Handle h_MM, uint64_t addr)
62151 +{
62152 + t_MM *p_MM = (t_MM*)h_MM;
62153 + t_MemBlock *p_MemBlock;
62154 +
62155 + ASSERT_COND(p_MM);
62156 +
62157 + p_MemBlock = p_MM->memBlocks;
62158 +
62159 + if ((addr >= p_MemBlock->base) && (addr < p_MemBlock->end))
62160 + return TRUE;
62161 + else
62162 + return FALSE;
62163 +}
62164 +
62165 +/*****************************************************************************/
62166 +uint64_t MM_GetFreeMemSize(t_Handle h_MM)
62167 +{
62168 + t_MM *p_MM = (t_MM*)h_MM;
62169 +
62170 + ASSERT_COND(p_MM);
62171 +
62172 + return p_MM->freeMemSize;
62173 +}
62174 +
62175 +/*****************************************************************************/
62176 +void MM_Dump(t_Handle h_MM)
62177 +{
62178 + t_MM *p_MM = (t_MM *)h_MM;
62179 + t_FreeBlock *p_FreeB;
62180 + t_BusyBlock *p_BusyB;
62181 + int i;
62182 +
62183 + p_BusyB = p_MM->busyBlocks;
62184 + XX_Print("List of busy blocks:\n");
62185 + while (p_BusyB)
62186 + {
62187 + XX_Print("\t0x%p: (%s: b=0x%llx, e=0x%llx)\n", p_BusyB, p_BusyB->name, p_BusyB->base, p_BusyB->end );
62188 + p_BusyB = p_BusyB->p_Next;
62189 + }
62190 +
62191 + XX_Print("\nLists of free blocks according to alignment:\n");
62192 + for (i=0; i <= MM_MAX_ALIGNMENT; i++)
62193 + {
62194 + XX_Print("%d alignment:\n", (0x1 << i));
62195 + p_FreeB = p_MM->freeBlocks[i];
62196 + while (p_FreeB)
62197 + {
62198 + XX_Print("\t0x%p: (b=0x%llx, e=0x%llx)\n", p_FreeB, p_FreeB->base, p_FreeB->end);
62199 + p_FreeB = p_FreeB->p_Next;
62200 + }
62201 + XX_Print("\n");
62202 + }
62203 +}
62204 --- /dev/null
62205 +++ b/drivers/net/ethernet/freescale/sdk_fman/etc/mm.h
62206 @@ -0,0 +1,105 @@
62207 +/*
62208 + * Copyright 2008-2012 Freescale Semiconductor Inc.
62209 + *
62210 + * Redistribution and use in source and binary forms, with or without
62211 + * modification, are permitted provided that the following conditions are met:
62212 + * * Redistributions of source code must retain the above copyright
62213 + * notice, this list of conditions and the following disclaimer.
62214 + * * Redistributions in binary form must reproduce the above copyright
62215 + * notice, this list of conditions and the following disclaimer in the
62216 + * documentation and/or other materials provided with the distribution.
62217 + * * Neither the name of Freescale Semiconductor nor the
62218 + * names of its contributors may be used to endorse or promote products
62219 + * derived from this software without specific prior written permission.
62220 + *
62221 + *
62222 + * ALTERNATIVELY, this software may be distributed under the terms of the
62223 + * GNU General Public License ("GPL") as published by the Free Software
62224 + * Foundation, either version 2 of that License or (at your option) any
62225 + * later version.
62226 + *
62227 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
62228 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
62229 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
62230 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
62231 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
62232 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62233 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
62234 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62235 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
62236 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62237 + */
62238 +
62239 +
62240 +/****************************************************************
62241 + *
62242 + * File: mm.h
62243 + *
62244 + *
62245 + * Description:
62246 + * MM (Memory Management) object definitions.
62247 + * It also includes definitions of the Free Block, Busy Block
62248 + * and Memory Block structures used by the MM object.
62249 + *
62250 + ****************************************************************/
62251 +
62252 +#ifndef __MM_H
62253 +#define __MM_H
62254 +
62255 +
62256 +#include "mm_ext.h"
62257 +
62258 +#define __ERR_MODULE__ MODULE_MM
62259 +
62260 +
62261 +#define MAKE_ALIGNED(addr, align) \
62262 + (((uint64_t)(addr) + ((align) - 1)) & (~(((uint64_t)align) - 1)))
62263 +
62264 +
62265 +/* t_MemBlock data structure defines parameters of the Memory Block */
62266 +typedef struct t_MemBlock
62267 +{
62268 + struct t_MemBlock *p_Next; /* Pointer to the next memory block */
62269 +
62270 + uint64_t base; /* Base address of the memory block */
62271 + uint64_t end; /* End address of the memory block */
62272 +} t_MemBlock;
62273 +
62274 +
62275 +/* t_FreeBlock data structure defines parameters of the Free Block */
62276 +typedef struct t_FreeBlock
62277 +{
62278 + struct t_FreeBlock *p_Next; /* Pointer to the next free block */
62279 +
62280 + uint64_t base; /* Base address of the block */
62281 + uint64_t end; /* End address of the block */
62282 +} t_FreeBlock;
62283 +
62284 +
62285 +/* t_BusyBlock data structure defines parameters of the Busy Block */
62286 +typedef struct t_BusyBlock
62287 +{
62288 + struct t_BusyBlock *p_Next; /* Pointer to the next free block */
62289 +
62290 + uint64_t base; /* Base address of the block */
62291 + uint64_t end; /* End address of the block */
62292 + char name[MM_MAX_NAME_LEN]; /* That block of memory was allocated for
62293 + something specified by the Name */
62294 +} t_BusyBlock;
62295 +
62296 +
62297 +/* t_MM data structure defines parameters of the MM object */
62298 +typedef struct t_MM
62299 +{
62300 + t_Handle h_Spinlock;
62301 +
62302 + t_MemBlock *memBlocks; /* List of memory blocks (Memory list) */
62303 + t_BusyBlock *busyBlocks; /* List of busy blocks (Busy list) */
62304 + t_FreeBlock *freeBlocks[MM_MAX_ALIGNMENT + 1];
62305 + /* Alignment lists of free blocks (Free lists) */
62306 +
62307 + uint64_t freeMemSize; /* Total size of free memory (in bytes) */
62308 +} t_MM;
62309 +
62310 +
62311 +#endif /* __MM_H */
62312 --- /dev/null
62313 +++ b/drivers/net/ethernet/freescale/sdk_fman/etc/sprint.c
62314 @@ -0,0 +1,81 @@
62315 +/*
62316 + * Copyright 2008-2012 Freescale Semiconductor Inc.
62317 + *
62318 + * Redistribution and use in source and binary forms, with or without
62319 + * modification, are permitted provided that the following conditions are met:
62320 + * * Redistributions of source code must retain the above copyright
62321 + * notice, this list of conditions and the following disclaimer.
62322 + * * Redistributions in binary form must reproduce the above copyright
62323 + * notice, this list of conditions and the following disclaimer in the
62324 + * documentation and/or other materials provided with the distribution.
62325 + * * Neither the name of Freescale Semiconductor nor the
62326 + * names of its contributors may be used to endorse or promote products
62327 + * derived from this software without specific prior written permission.
62328 + *
62329 + *
62330 + * ALTERNATIVELY, this software may be distributed under the terms of the
62331 + * GNU General Public License ("GPL") as published by the Free Software
62332 + * Foundation, either version 2 of that License or (at your option) any
62333 + * later version.
62334 + *
62335 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
62336 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
62337 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
62338 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
62339 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
62340 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62341 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
62342 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62343 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
62344 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62345 + */
62346 +
62347 +
62348 +/*------------------------------------------------------*/
62349 +/* File: sprint.c */
62350 +/* */
62351 +/* Description: */
62352 +/* Debug routines (externals) */
62353 +/*------------------------------------------------------*/
62354 +#include "string_ext.h"
62355 +#include "stdlib_ext.h"
62356 +#include "stdarg_ext.h"
62357 +#include "sprint_ext.h"
62358 +#include "std_ext.h"
62359 +#include "xx_ext.h"
62360 +
62361 +
62362 +int Sprint(char * buf, const char *fmt, ...)
62363 +{
62364 + va_list args;
62365 + int i;
62366 +
62367 + va_start(args, fmt);
62368 + i=vsprintf(buf,fmt,args);
62369 + va_end(args);
62370 + return i;
62371 +}
62372 +
62373 +int Snprint(char * buf, uint32_t size, const char *fmt, ...)
62374 +{
62375 + va_list args;
62376 + int i;
62377 +
62378 + va_start(args, fmt);
62379 + i=vsnprintf(buf,size,fmt,args);
62380 + va_end(args);
62381 + return i;
62382 +}
62383 +
62384 +#ifndef NCSW_VXWORKS
62385 +int Sscan(const char * buf, const char * fmt, ...)
62386 +{
62387 + va_list args;
62388 + int i;
62389 +
62390 + va_start(args,fmt);
62391 + i = vsscanf(buf,fmt,args);
62392 + va_end(args);
62393 + return i;
62394 +}
62395 +#endif /* NCSW_VXWORKS */
62396 --- /dev/null
62397 +++ b/drivers/net/ethernet/freescale/sdk_fman/fmanv3h_dflags.h
62398 @@ -0,0 +1,57 @@
62399 +/*
62400 + * Copyright 2012 Freescale Semiconductor Inc.
62401 + *
62402 + * Redistribution and use in source and binary forms, with or without
62403 + * modification, are permitted provided that the following conditions are met:
62404 + * * Redistributions of source code must retain the above copyright
62405 + * notice, this list of conditions and the following disclaimer.
62406 + * * Redistributions in binary form must reproduce the above copyright
62407 + * notice, this list of conditions and the following disclaimer in the
62408 + * documentation and/or other materials provided with the distribution.
62409 + * * Neither the name of Freescale Semiconductor nor the
62410 + * names of its contributors may be used to endorse or promote products
62411 + * derived from this software without specific prior written permission.
62412 + *
62413 + *
62414 + * ALTERNATIVELY, this software may be distributed under the terms of the
62415 + * GNU General Public License ("GPL") as published by the Free Software
62416 + * Foundation, either version 2 of that License or (at your option) any
62417 + * later version.
62418 + *
62419 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
62420 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
62421 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
62422 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
62423 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
62424 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62425 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
62426 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62427 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
62428 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62429 + */
62430 +
62431 +#ifndef __dflags_h
62432 +#define __dflags_h
62433 +
62434 +
62435 +#define NCSW_LINUX
62436 +
62437 +#define T4240
62438 +#define NCSW_PPC_CORE
62439 +
62440 +#define DEBUG_ERRORS 1
62441 +
62442 +#if defined(DEBUG)
62443 +#define DEBUG_GLOBAL_LEVEL REPORT_LEVEL_INFO
62444 +
62445 +#define DEBUG_XX_MALLOC
62446 +#define DEBUG_MEM_LEAKS
62447 +
62448 +#else
62449 +#define DEBUG_GLOBAL_LEVEL REPORT_LEVEL_WARNING
62450 +#endif /* (DEBUG) */
62451 +
62452 +#define REPORT_EVENTS 1
62453 +#define EVENT_GLOBAL_LEVEL REPORT_LEVEL_MINOR
62454 +
62455 +#endif /* __dflags_h */
62456 --- /dev/null
62457 +++ b/drivers/net/ethernet/freescale/sdk_fman/fmanv3l_dflags.h
62458 @@ -0,0 +1,56 @@
62459 +/*
62460 + * Copyright 2012 Freescale Semiconductor Inc.
62461 + *
62462 + * Redistribution and use in source and binary forms, with or without
62463 + * modification, are permitted provided that the following conditions are met:
62464 + * * Redistributions of source code must retain the above copyright
62465 + * notice, this list of conditions and the following disclaimer.
62466 + * * Redistributions in binary form must reproduce the above copyright
62467 + * notice, this list of conditions and the following disclaimer in the
62468 + * documentation and/or other materials provided with the distribution.
62469 + * * Neither the name of Freescale Semiconductor nor the
62470 + * names of its contributors may be used to endorse or promote products
62471 + * derived from this software without specific prior written permission.
62472 + *
62473 + *
62474 + * ALTERNATIVELY, this software may be distributed under the terms of the
62475 + * GNU General Public License ("GPL") as published by the Free Software
62476 + * Foundation, either version 2 of that License or (at your option) any
62477 + * later version.
62478 + *
62479 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
62480 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
62481 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
62482 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
62483 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
62484 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62485 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
62486 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62487 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
62488 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62489 + */
62490 +
62491 +#ifndef __dflags_h
62492 +#define __dflags_h
62493 +
62494 +
62495 +#define NCSW_LINUX
62496 +
62497 +#define NCSW_PPC_CORE
62498 +
62499 +#define DEBUG_ERRORS 1
62500 +
62501 +#if defined(DEBUG)
62502 +#define DEBUG_GLOBAL_LEVEL REPORT_LEVEL_INFO
62503 +
62504 +#define DEBUG_XX_MALLOC
62505 +#define DEBUG_MEM_LEAKS
62506 +
62507 +#else
62508 +#define DEBUG_GLOBAL_LEVEL REPORT_LEVEL_WARNING
62509 +#endif /* (DEBUG) */
62510 +
62511 +#define REPORT_EVENTS 1
62512 +#define EVENT_GLOBAL_LEVEL REPORT_LEVEL_MINOR
62513 +
62514 +#endif /* __dflags_h */
62515 --- /dev/null
62516 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/crc_mac_addr_ext.h
62517 @@ -0,0 +1,364 @@
62518 +/*
62519 + * Copyright 2008-2012 Freescale Semiconductor Inc.
62520 + *
62521 + * Redistribution and use in source and binary forms, with or without
62522 + * modification, are permitted provided that the following conditions are met:
62523 + * * Redistributions of source code must retain the above copyright
62524 + * notice, this list of conditions and the following disclaimer.
62525 + * * Redistributions in binary form must reproduce the above copyright
62526 + * notice, this list of conditions and the following disclaimer in the
62527 + * documentation and/or other materials provided with the distribution.
62528 + * * Neither the name of Freescale Semiconductor nor the
62529 + * names of its contributors may be used to endorse or promote products
62530 + * derived from this software without specific prior written permission.
62531 + *
62532 + *
62533 + * ALTERNATIVELY, this software may be distributed under the terms of the
62534 + * GNU General Public License ("GPL") as published by the Free Software
62535 + * Foundation, either version 2 of that License or (at your option) any
62536 + * later version.
62537 + *
62538 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
62539 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
62540 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
62541 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
62542 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
62543 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62544 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
62545 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62546 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
62547 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62548 + */
62549 +
62550 +
62551 +/*------------------------------------------------------*/
62552 +/* */
62553 +/* File: crc_mac_addr_ext.h */
62554 +/* */
62555 +/* Description: */
62556 +/* Define a macro that calculate the crc value of */
62557 +/* an Ethernet MAC address (48 bitd address */
62558 +/*------------------------------------------------------*/
62559 +
62560 +#ifndef __crc_mac_addr_ext_h
62561 +#define __crc_mac_addr_ext_h
62562 +
62563 +#include "std_ext.h"
62564 +
62565 +
62566 +static uint32_t crc_table[256] =
62567 +{
62568 + 0x00000000,
62569 + 0x77073096,
62570 + 0xee0e612c,
62571 + 0x990951ba,
62572 + 0x076dc419,
62573 + 0x706af48f,
62574 + 0xe963a535,
62575 + 0x9e6495a3,
62576 + 0x0edb8832,
62577 + 0x79dcb8a4,
62578 + 0xe0d5e91e,
62579 + 0x97d2d988,
62580 + 0x09b64c2b,
62581 + 0x7eb17cbd,
62582 + 0xe7b82d07,
62583 + 0x90bf1d91,
62584 + 0x1db71064,
62585 + 0x6ab020f2,
62586 + 0xf3b97148,
62587 + 0x84be41de,
62588 + 0x1adad47d,
62589 + 0x6ddde4eb,
62590 + 0xf4d4b551,
62591 + 0x83d385c7,
62592 + 0x136c9856,
62593 + 0x646ba8c0,
62594 + 0xfd62f97a,
62595 + 0x8a65c9ec,
62596 + 0x14015c4f,
62597 + 0x63066cd9,
62598 + 0xfa0f3d63,
62599 + 0x8d080df5,
62600 + 0x3b6e20c8,
62601 + 0x4c69105e,
62602 + 0xd56041e4,
62603 + 0xa2677172,
62604 + 0x3c03e4d1,
62605 + 0x4b04d447,
62606 + 0xd20d85fd,
62607 + 0xa50ab56b,
62608 + 0x35b5a8fa,
62609 + 0x42b2986c,
62610 + 0xdbbbc9d6,
62611 + 0xacbcf940,
62612 + 0x32d86ce3,
62613 + 0x45df5c75,
62614 + 0xdcd60dcf,
62615 + 0xabd13d59,
62616 + 0x26d930ac,
62617 + 0x51de003a,
62618 + 0xc8d75180,
62619 + 0xbfd06116,
62620 + 0x21b4f4b5,
62621 + 0x56b3c423,
62622 + 0xcfba9599,
62623 + 0xb8bda50f,
62624 + 0x2802b89e,
62625 + 0x5f058808,
62626 + 0xc60cd9b2,
62627 + 0xb10be924,
62628 + 0x2f6f7c87,
62629 + 0x58684c11,
62630 + 0xc1611dab,
62631 + 0xb6662d3d,
62632 + 0x76dc4190,
62633 + 0x01db7106,
62634 + 0x98d220bc,
62635 + 0xefd5102a,
62636 + 0x71b18589,
62637 + 0x06b6b51f,
62638 + 0x9fbfe4a5,
62639 + 0xe8b8d433,
62640 + 0x7807c9a2,
62641 + 0x0f00f934,
62642 + 0x9609a88e,
62643 + 0xe10e9818,
62644 + 0x7f6a0dbb,
62645 + 0x086d3d2d,
62646 + 0x91646c97,
62647 + 0xe6635c01,
62648 + 0x6b6b51f4,
62649 + 0x1c6c6162,
62650 + 0x856530d8,
62651 + 0xf262004e,
62652 + 0x6c0695ed,
62653 + 0x1b01a57b,
62654 + 0x8208f4c1,
62655 + 0xf50fc457,
62656 + 0x65b0d9c6,
62657 + 0x12b7e950,
62658 + 0x8bbeb8ea,
62659 + 0xfcb9887c,
62660 + 0x62dd1ddf,
62661 + 0x15da2d49,
62662 + 0x8cd37cf3,
62663 + 0xfbd44c65,
62664 + 0x4db26158,
62665 + 0x3ab551ce,
62666 + 0xa3bc0074,
62667 + 0xd4bb30e2,
62668 + 0x4adfa541,
62669 + 0x3dd895d7,
62670 + 0xa4d1c46d,
62671 + 0xd3d6f4fb,
62672 + 0x4369e96a,
62673 + 0x346ed9fc,
62674 + 0xad678846,
62675 + 0xda60b8d0,
62676 + 0x44042d73,
62677 + 0x33031de5,
62678 + 0xaa0a4c5f,
62679 + 0xdd0d7cc9,
62680 + 0x5005713c,
62681 + 0x270241aa,
62682 + 0xbe0b1010,
62683 + 0xc90c2086,
62684 + 0x5768b525,
62685 + 0x206f85b3,
62686 + 0xb966d409,
62687 + 0xce61e49f,
62688 + 0x5edef90e,
62689 + 0x29d9c998,
62690 + 0xb0d09822,
62691 + 0xc7d7a8b4,
62692 + 0x59b33d17,
62693 + 0x2eb40d81,
62694 + 0xb7bd5c3b,
62695 + 0xc0ba6cad,
62696 + 0xedb88320,
62697 + 0x9abfb3b6,
62698 + 0x03b6e20c,
62699 + 0x74b1d29a,
62700 + 0xead54739,
62701 + 0x9dd277af,
62702 + 0x04db2615,
62703 + 0x73dc1683,
62704 + 0xe3630b12,
62705 + 0x94643b84,
62706 + 0x0d6d6a3e,
62707 + 0x7a6a5aa8,
62708 + 0xe40ecf0b,
62709 + 0x9309ff9d,
62710 + 0x0a00ae27,
62711 + 0x7d079eb1,
62712 + 0xf00f9344,
62713 + 0x8708a3d2,
62714 + 0x1e01f268,
62715 + 0x6906c2fe,
62716 + 0xf762575d,
62717 + 0x806567cb,
62718 + 0x196c3671,
62719 + 0x6e6b06e7,
62720 + 0xfed41b76,
62721 + 0x89d32be0,
62722 + 0x10da7a5a,
62723 + 0x67dd4acc,
62724 + 0xf9b9df6f,
62725 + 0x8ebeeff9,
62726 + 0x17b7be43,
62727 + 0x60b08ed5,
62728 + 0xd6d6a3e8,
62729 + 0xa1d1937e,
62730 + 0x38d8c2c4,
62731 + 0x4fdff252,
62732 + 0xd1bb67f1,
62733 + 0xa6bc5767,
62734 + 0x3fb506dd,
62735 + 0x48b2364b,
62736 + 0xd80d2bda,
62737 + 0xaf0a1b4c,
62738 + 0x36034af6,
62739 + 0x41047a60,
62740 + 0xdf60efc3,
62741 + 0xa867df55,
62742 + 0x316e8eef,
62743 + 0x4669be79,
62744 + 0xcb61b38c,
62745 + 0xbc66831a,
62746 + 0x256fd2a0,
62747 + 0x5268e236,
62748 + 0xcc0c7795,
62749 + 0xbb0b4703,
62750 + 0x220216b9,
62751 + 0x5505262f,
62752 + 0xc5ba3bbe,
62753 + 0xb2bd0b28,
62754 + 0x2bb45a92,
62755 + 0x5cb36a04,
62756 + 0xc2d7ffa7,
62757 + 0xb5d0cf31,
62758 + 0x2cd99e8b,
62759 + 0x5bdeae1d,
62760 + 0x9b64c2b0,
62761 + 0xec63f226,
62762 + 0x756aa39c,
62763 + 0x026d930a,
62764 + 0x9c0906a9,
62765 + 0xeb0e363f,
62766 + 0x72076785,
62767 + 0x05005713,
62768 + 0x95bf4a82,
62769 + 0xe2b87a14,
62770 + 0x7bb12bae,
62771 + 0x0cb61b38,
62772 + 0x92d28e9b,
62773 + 0xe5d5be0d,
62774 + 0x7cdcefb7,
62775 + 0x0bdbdf21,
62776 + 0x86d3d2d4,
62777 + 0xf1d4e242,
62778 + 0x68ddb3f8,
62779 + 0x1fda836e,
62780 + 0x81be16cd,
62781 + 0xf6b9265b,
62782 + 0x6fb077e1,
62783 + 0x18b74777,
62784 + 0x88085ae6,
62785 + 0xff0f6a70,
62786 + 0x66063bca,
62787 + 0x11010b5c,
62788 + 0x8f659eff,
62789 + 0xf862ae69,
62790 + 0x616bffd3,
62791 + 0x166ccf45,
62792 + 0xa00ae278,
62793 + 0xd70dd2ee,
62794 + 0x4e048354,
62795 + 0x3903b3c2,
62796 + 0xa7672661,
62797 + 0xd06016f7,
62798 + 0x4969474d,
62799 + 0x3e6e77db,
62800 + 0xaed16a4a,
62801 + 0xd9d65adc,
62802 + 0x40df0b66,
62803 + 0x37d83bf0,
62804 + 0xa9bcae53,
62805 + 0xdebb9ec5,
62806 + 0x47b2cf7f,
62807 + 0x30b5ffe9,
62808 + 0xbdbdf21c,
62809 + 0xcabac28a,
62810 + 0x53b39330,
62811 + 0x24b4a3a6,
62812 + 0xbad03605,
62813 + 0xcdd70693,
62814 + 0x54de5729,
62815 + 0x23d967bf,
62816 + 0xb3667a2e,
62817 + 0xc4614ab8,
62818 + 0x5d681b02,
62819 + 0x2a6f2b94,
62820 + 0xb40bbe37,
62821 + 0xc30c8ea1,
62822 + 0x5a05df1b,
62823 + 0x2d02ef8d
62824 +};
62825 +
62826 +
62827 +#define GET_MAC_ADDR_CRC(addr, crc) \
62828 +{ \
62829 + uint32_t i; \
62830 + uint8_t data; \
62831 + \
62832 + /* CRC calculation */ \
62833 + crc = 0xffffffff; \
62834 + for (i=0; i < 6; i++) \
62835 + { \
62836 + data = (uint8_t)(addr >> ((5-i)*8)); \
62837 + crc = crc^data; \
62838 + crc = crc_table[crc&0xff] ^ (crc>>8); \
62839 + } \
62840 +} \
62841 +
62842 +/* Define a macro for getting the mirrored value of */
62843 +/* a byte size number. (0x11010011 --> 0x11001011) */
62844 +/* Sometimes the mirrored value of the CRC is required */
62845 +static __inline__ uint8_t GetMirror(uint8_t n)
62846 +{
62847 + uint8_t mirror[16] =
62848 + {
62849 + 0x00,
62850 + 0x08,
62851 + 0x04,
62852 + 0x0c,
62853 + 0x02,
62854 + 0x0a,
62855 + 0x06,
62856 + 0x0e,
62857 + 0x01,
62858 + 0x09,
62859 + 0x05,
62860 + 0x0d,
62861 + 0x03,
62862 + 0x0b,
62863 + 0x07,
62864 + 0x0f
62865 + };
62866 + return ((uint8_t)(((mirror[n & 0x0f] << 4) | (mirror[n >> 4]))));
62867 +}
62868 +
62869 +static __inline__ uint32_t GetMirror32(uint32_t n)
62870 +{
62871 + return (((uint32_t)GetMirror((uint8_t)(n))<<24) |
62872 + ((uint32_t)GetMirror((uint8_t)(n>>8))<<16) |
62873 + ((uint32_t)GetMirror((uint8_t)(n>>16))<<8) |
62874 + ((uint32_t)GetMirror((uint8_t)(n>>24))));
62875 +}
62876 +
62877 +#define MIRROR GetMirror
62878 +#define MIRROR_32 GetMirror32
62879 +
62880 +
62881 +#endif /* __crc_mac_addr_ext_h */
62882 --- /dev/null
62883 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/dpaa_ext.h
62884 @@ -0,0 +1,207 @@
62885 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
62886 + * All rights reserved.
62887 + *
62888 + * Redistribution and use in source and binary forms, with or without
62889 + * modification, are permitted provided that the following conditions are met:
62890 + * * Redistributions of source code must retain the above copyright
62891 + * notice, this list of conditions and the following disclaimer.
62892 + * * Redistributions in binary form must reproduce the above copyright
62893 + * notice, this list of conditions and the following disclaimer in the
62894 + * documentation and/or other materials provided with the distribution.
62895 + * * Neither the name of Freescale Semiconductor nor the
62896 + * names of its contributors may be used to endorse or promote products
62897 + * derived from this software without specific prior written permission.
62898 + *
62899 + *
62900 + * ALTERNATIVELY, this software may be distributed under the terms of the
62901 + * GNU General Public License ("GPL") as published by the Free Software
62902 + * Foundation, either version 2 of that License or (at your option) any
62903 + * later version.
62904 + *
62905 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
62906 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
62907 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
62908 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
62909 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
62910 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62911 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
62912 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62913 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
62914 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62915 + */
62916 +
62917 +
62918 +/**************************************************************************//**
62919 + @File dpaa_ext.h
62920 +
62921 + @Description DPAA Application Programming Interface.
62922 +*//***************************************************************************/
62923 +#ifndef __DPAA_EXT_H
62924 +#define __DPAA_EXT_H
62925 +
62926 +#include "std_ext.h"
62927 +#include "error_ext.h"
62928 +
62929 +
62930 +/**************************************************************************//**
62931 + @Group DPAA_grp Data Path Acceleration Architecture API
62932 +
62933 + @Description DPAA API functions, definitions and enums.
62934 +
62935 + @{
62936 +*//***************************************************************************/
62937 +
62938 +#if defined(__MWERKS__) && !defined(__GNUC__)
62939 +#pragma pack(push,1)
62940 +#endif /* defined(__MWERKS__) && ... */
62941 +
62942 +/**************************************************************************//**
62943 + @Description Frame descriptor
62944 +*//***************************************************************************/
62945 +typedef _Packed struct t_DpaaFD {
62946 + volatile uint32_t id; /**< FD id */
62947 + volatile uint32_t addrl; /**< Data Address */
62948 + volatile uint32_t length; /**< Frame length */
62949 + volatile uint32_t status; /**< FD status */
62950 +} _PackedType t_DpaaFD;
62951 +
62952 +/**************************************************************************//**
62953 + @Description enum for defining frame format
62954 +*//***************************************************************************/
62955 +typedef enum e_DpaaFDFormatType {
62956 + e_DPAA_FD_FORMAT_TYPE_SHORT_SBSF = 0x0, /**< Simple frame Single buffer; Offset and
62957 + small length (9b OFFSET, 20b LENGTH) */
62958 + e_DPAA_FD_FORMAT_TYPE_LONG_SBSF = 0x2, /**< Simple frame, single buffer; big length
62959 + (29b LENGTH ,No OFFSET) */
62960 + e_DPAA_FD_FORMAT_TYPE_SHORT_MBSF = 0x4, /**< Simple frame, Scatter Gather table; Offset
62961 + and small length (9b OFFSET, 20b LENGTH) */
62962 + e_DPAA_FD_FORMAT_TYPE_LONG_MBSF = 0x6, /**< Simple frame, Scatter Gather table;
62963 + big length (29b LENGTH ,No OFFSET) */
62964 + e_DPAA_FD_FORMAT_TYPE_COMPOUND = 0x1, /**< Compound Frame (29b CONGESTION-WEIGHT
62965 + No LENGTH or OFFSET) */
62966 + e_DPAA_FD_FORMAT_TYPE_DUMMY
62967 +} e_DpaaFDFormatType;
62968 +
62969 +/**************************************************************************//**
62970 + @Collection Frame descriptor macros
62971 +*//***************************************************************************/
62972 +#define DPAA_FD_DD_MASK 0xc0000000 /**< FD DD field mask */
62973 +#define DPAA_FD_PID_MASK 0x3f000000 /**< FD PID field mask */
62974 +#define DPAA_FD_ELIODN_MASK 0x0000f000 /**< FD ELIODN field mask */
62975 +#define DPAA_FD_BPID_MASK 0x00ff0000 /**< FD BPID field mask */
62976 +#define DPAA_FD_ADDRH_MASK 0x000000ff /**< FD ADDRH field mask */
62977 +#define DPAA_FD_ADDRL_MASK 0xffffffff /**< FD ADDRL field mask */
62978 +#define DPAA_FD_FORMAT_MASK 0xe0000000 /**< FD FORMAT field mask */
62979 +#define DPAA_FD_OFFSET_MASK 0x1ff00000 /**< FD OFFSET field mask */
62980 +#define DPAA_FD_LENGTH_MASK 0x000fffff /**< FD LENGTH field mask */
62981 +
62982 +#define DPAA_FD_GET_DD(fd) ((((t_DpaaFD *)fd)->id & DPAA_FD_DD_MASK) >> (31-1)) /**< Macro to get FD DD field */
62983 +#define DPAA_FD_GET_PID(fd) (((((t_DpaaFD *)fd)->id & DPAA_FD_PID_MASK) >> (31-7)) | \
62984 + ((((t_DpaaFD *)fd)->id & DPAA_FD_ELIODN_MASK) >> (31-19-6))) /**< Macro to get FD PID field */
62985 +#define DPAA_FD_GET_BPID(fd) ((((t_DpaaFD *)fd)->id & DPAA_FD_BPID_MASK) >> (31-15)) /**< Macro to get FD BPID field */
62986 +#define DPAA_FD_GET_ADDRH(fd) (((t_DpaaFD *)fd)->id & DPAA_FD_ADDRH_MASK) /**< Macro to get FD ADDRH field */
62987 +#define DPAA_FD_GET_ADDRL(fd) ((t_DpaaFD *)fd)->addrl /**< Macro to get FD ADDRL field */
62988 +#define DPAA_FD_GET_PHYS_ADDR(fd) ((physAddress_t)(((uint64_t)DPAA_FD_GET_ADDRH(fd) << 32) | (uint64_t)DPAA_FD_GET_ADDRL(fd))) /**< Macro to get FD ADDR field */
62989 +#define DPAA_FD_GET_FORMAT(fd) ((((t_DpaaFD *)fd)->length & DPAA_FD_FORMAT_MASK) >> (31-2)) /**< Macro to get FD FORMAT field */
62990 +#define DPAA_FD_GET_OFFSET(fd) ((((t_DpaaFD *)fd)->length & DPAA_FD_OFFSET_MASK) >> (31-11)) /**< Macro to get FD OFFSET field */
62991 +#define DPAA_FD_GET_LENGTH(fd) (((t_DpaaFD *)fd)->length & DPAA_FD_LENGTH_MASK) /**< Macro to get FD LENGTH field */
62992 +#define DPAA_FD_GET_STATUS(fd) ((t_DpaaFD *)fd)->status /**< Macro to get FD STATUS field */
62993 +#define DPAA_FD_GET_ADDR(fd) XX_PhysToVirt(DPAA_FD_GET_PHYS_ADDR(fd)) /**< Macro to get FD ADDR (virtual) */
62994 +
62995 +#define DPAA_FD_SET_DD(fd,val) (((t_DpaaFD *)fd)->id = ((((t_DpaaFD *)fd)->id & ~DPAA_FD_DD_MASK) | (((val) << (31-1)) & DPAA_FD_DD_MASK ))) /**< Macro to set FD DD field */
62996 + /**< Macro to set FD PID field or LIODN offset*/
62997 +#define DPAA_FD_SET_PID(fd,val) (((t_DpaaFD *)fd)->id = ((((t_DpaaFD *)fd)->id & ~(DPAA_FD_PID_MASK|DPAA_FD_ELIODN_MASK)) | ((((val) << (31-7)) & DPAA_FD_PID_MASK) | ((((val)>>6) << (31-19)) & DPAA_FD_ELIODN_MASK))))
62998 +#define DPAA_FD_SET_BPID(fd,val) (((t_DpaaFD *)fd)->id = ((((t_DpaaFD *)fd)->id & ~DPAA_FD_BPID_MASK) | (((val) << (31-15)) & DPAA_FD_BPID_MASK))) /**< Macro to set FD BPID field */
62999 +#define DPAA_FD_SET_ADDRH(fd,val) (((t_DpaaFD *)fd)->id = ((((t_DpaaFD *)fd)->id & ~DPAA_FD_ADDRH_MASK) | ((val) & DPAA_FD_ADDRH_MASK))) /**< Macro to set FD ADDRH field */
63000 +#define DPAA_FD_SET_ADDRL(fd,val) ((t_DpaaFD *)fd)->addrl = (val) /**< Macro to set FD ADDRL field */
63001 +#define DPAA_FD_SET_ADDR(fd,val) \
63002 +do { \
63003 + uint64_t physAddr = (uint64_t)(XX_VirtToPhys(val)); \
63004 + DPAA_FD_SET_ADDRH(fd, ((uint32_t)(physAddr >> 32))); \
63005 + DPAA_FD_SET_ADDRL(fd, (uint32_t)physAddr); \
63006 +} while (0) /**< Macro to set FD ADDR field */
63007 +#define DPAA_FD_SET_FORMAT(fd,val) (((t_DpaaFD *)fd)->length = ((((t_DpaaFD *)fd)->length & ~DPAA_FD_FORMAT_MASK) | (((val) << (31-2))& DPAA_FD_FORMAT_MASK))) /**< Macro to set FD FORMAT field */
63008 +#define DPAA_FD_SET_OFFSET(fd,val) (((t_DpaaFD *)fd)->length = ((((t_DpaaFD *)fd)->length & ~DPAA_FD_OFFSET_MASK) | (((val) << (31-11))& DPAA_FD_OFFSET_MASK) )) /**< Macro to set FD OFFSET field */
63009 +#define DPAA_FD_SET_LENGTH(fd,val) (((t_DpaaFD *)fd)->length = (((t_DpaaFD *)fd)->length & ~DPAA_FD_LENGTH_MASK) | ((val) & DPAA_FD_LENGTH_MASK)) /**< Macro to set FD LENGTH field */
63010 +#define DPAA_FD_SET_STATUS(fd,val) ((t_DpaaFD *)fd)->status = (val) /**< Macro to set FD STATUS field */
63011 +/* @} */
63012 +
63013 +/**************************************************************************//**
63014 + @Description Frame Scatter/Gather Table Entry
63015 +*//***************************************************************************/
63016 +typedef _Packed struct t_DpaaSGTE {
63017 + volatile uint32_t addrh; /**< Buffer Address high */
63018 + volatile uint32_t addrl; /**< Buffer Address low */
63019 + volatile uint32_t length; /**< Buffer length */
63020 + volatile uint32_t offset; /**< SGTE offset */
63021 +} _PackedType t_DpaaSGTE;
63022 +
63023 +#define DPAA_NUM_OF_SG_TABLE_ENTRY 16
63024 +
63025 +/**************************************************************************//**
63026 + @Description Frame Scatter/Gather Table
63027 +*//***************************************************************************/
63028 +typedef _Packed struct t_DpaaSGT {
63029 + t_DpaaSGTE tableEntry[DPAA_NUM_OF_SG_TABLE_ENTRY];
63030 + /**< Structure that holds information about
63031 + a single S/G entry. */
63032 +} _PackedType t_DpaaSGT;
63033 +
63034 +/**************************************************************************//**
63035 + @Description Compound Frame Table
63036 +*//***************************************************************************/
63037 +typedef _Packed struct t_DpaaCompTbl {
63038 + t_DpaaSGTE outputBuffInfo; /**< Structure that holds information about
63039 + the compound-frame output buffer;
63040 + NOTE: this may point to a S/G table */
63041 + t_DpaaSGTE inputBuffInfo; /**< Structure that holds information about
63042 + the compound-frame input buffer;
63043 + NOTE: this may point to a S/G table */
63044 +} _PackedType t_DpaaCompTbl;
63045 +
63046 +/**************************************************************************//**
63047 + @Collection Frame Scatter/Gather Table Entry macros
63048 +*//***************************************************************************/
63049 +#define DPAA_SGTE_ADDRH_MASK 0x000000ff /**< SGTE ADDRH field mask */
63050 +#define DPAA_SGTE_ADDRL_MASK 0xffffffff /**< SGTE ADDRL field mask */
63051 +#define DPAA_SGTE_E_MASK 0x80000000 /**< SGTE Extension field mask */
63052 +#define DPAA_SGTE_F_MASK 0x40000000 /**< SGTE Final field mask */
63053 +#define DPAA_SGTE_LENGTH_MASK 0x3fffffff /**< SGTE LENGTH field mask */
63054 +#define DPAA_SGTE_BPID_MASK 0x00ff0000 /**< SGTE BPID field mask */
63055 +#define DPAA_SGTE_OFFSET_MASK 0x00001fff /**< SGTE OFFSET field mask */
63056 +
63057 +#define DPAA_SGTE_GET_ADDRH(sgte) (((t_DpaaSGTE *)sgte)->addrh & DPAA_SGTE_ADDRH_MASK) /**< Macro to get SGTE ADDRH field */
63058 +#define DPAA_SGTE_GET_ADDRL(sgte) ((t_DpaaSGTE *)sgte)->addrl /**< Macro to get SGTE ADDRL field */
63059 +#define DPAA_SGTE_GET_PHYS_ADDR(sgte) ((physAddress_t)(((uint64_t)DPAA_SGTE_GET_ADDRH(sgte) << 32) | (uint64_t)DPAA_SGTE_GET_ADDRL(sgte))) /**< Macro to get FD ADDR field */
63060 +#define DPAA_SGTE_GET_EXTENSION(sgte) ((((t_DpaaSGTE *)sgte)->length & DPAA_SGTE_E_MASK) >> (31-0)) /**< Macro to get SGTE EXTENSION field */
63061 +#define DPAA_SGTE_GET_FINAL(sgte) ((((t_DpaaSGTE *)sgte)->length & DPAA_SGTE_F_MASK) >> (31-1)) /**< Macro to get SGTE FINAL field */
63062 +#define DPAA_SGTE_GET_LENGTH(sgte) (((t_DpaaSGTE *)sgte)->length & DPAA_SGTE_LENGTH_MASK) /**< Macro to get SGTE LENGTH field */
63063 +#define DPAA_SGTE_GET_BPID(sgte) ((((t_DpaaSGTE *)sgte)->offset & DPAA_SGTE_BPID_MASK) >> (31-15)) /**< Macro to get SGTE BPID field */
63064 +#define DPAA_SGTE_GET_OFFSET(sgte) (((t_DpaaSGTE *)sgte)->offset & DPAA_SGTE_OFFSET_MASK) /**< Macro to get SGTE OFFSET field */
63065 +#define DPAA_SGTE_GET_ADDR(sgte) XX_PhysToVirt(DPAA_SGTE_GET_PHYS_ADDR(sgte))
63066 +
63067 +#define DPAA_SGTE_SET_ADDRH(sgte,val) (((t_DpaaSGTE *)sgte)->addrh = ((((t_DpaaSGTE *)sgte)->addrh & ~DPAA_SGTE_ADDRH_MASK) | ((val) & DPAA_SGTE_ADDRH_MASK))) /**< Macro to set SGTE ADDRH field */
63068 +#define DPAA_SGTE_SET_ADDRL(sgte,val) ((t_DpaaSGTE *)sgte)->addrl = (val) /**< Macro to set SGTE ADDRL field */
63069 +#define DPAA_SGTE_SET_ADDR(sgte,val) \
63070 +do { \
63071 + uint64_t physAddr = (uint64_t)(XX_VirtToPhys(val)); \
63072 + DPAA_SGTE_SET_ADDRH(sgte, ((uint32_t)(physAddr >> 32))); \
63073 + DPAA_SGTE_SET_ADDRL(sgte, (uint32_t)physAddr); \
63074 +} while (0) /**< Macro to set SGTE ADDR field */
63075 +#define DPAA_SGTE_SET_EXTENSION(sgte,val) (((t_DpaaSGTE *)sgte)->length = ((((t_DpaaSGTE *)sgte)->length & ~DPAA_SGTE_E_MASK) | (((val) << (31-0))& DPAA_SGTE_E_MASK))) /**< Macro to set SGTE EXTENSION field */
63076 +#define DPAA_SGTE_SET_FINAL(sgte,val) (((t_DpaaSGTE *)sgte)->length = ((((t_DpaaSGTE *)sgte)->length & ~DPAA_SGTE_F_MASK) | (((val) << (31-1))& DPAA_SGTE_F_MASK))) /**< Macro to set SGTE FINAL field */
63077 +#define DPAA_SGTE_SET_LENGTH(sgte,val) (((t_DpaaSGTE *)sgte)->length = (((t_DpaaSGTE *)sgte)->length & ~DPAA_SGTE_LENGTH_MASK) | ((val) & DPAA_SGTE_LENGTH_MASK)) /**< Macro to set SGTE LENGTH field */
63078 +#define DPAA_SGTE_SET_BPID(sgte,val) (((t_DpaaSGTE *)sgte)->offset = ((((t_DpaaSGTE *)sgte)->offset & ~DPAA_SGTE_BPID_MASK) | (((val) << (31-15))& DPAA_SGTE_BPID_MASK))) /**< Macro to set SGTE BPID field */
63079 +#define DPAA_SGTE_SET_OFFSET(sgte,val) (((t_DpaaSGTE *)sgte)->offset = ((((t_DpaaSGTE *)sgte)->offset & ~DPAA_SGTE_OFFSET_MASK) | (((val) << (31-31))& DPAA_SGTE_OFFSET_MASK) )) /**< Macro to set SGTE OFFSET field */
63080 +/* @} */
63081 +
63082 +#if defined(__MWERKS__) && !defined(__GNUC__)
63083 +#pragma pack(pop)
63084 +#endif /* defined(__MWERKS__) && ... */
63085 +
63086 +#define DPAA_LIODN_DONT_OVERRIDE (-1)
63087 +
63088 +/** @} */ /* end of DPAA_grp group */
63089 +
63090 +
63091 +#endif /* __DPAA_EXT_H */
63092 --- /dev/null
63093 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_ext.h
63094 @@ -0,0 +1,1705 @@
63095 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
63096 + * All rights reserved.
63097 + *
63098 + * Redistribution and use in source and binary forms, with or without
63099 + * modification, are permitted provided that the following conditions are met:
63100 + * * Redistributions of source code must retain the above copyright
63101 + * notice, this list of conditions and the following disclaimer.
63102 + * * Redistributions in binary form must reproduce the above copyright
63103 + * notice, this list of conditions and the following disclaimer in the
63104 + * documentation and/or other materials provided with the distribution.
63105 + * * Neither the name of Freescale Semiconductor nor the
63106 + * names of its contributors may be used to endorse or promote products
63107 + * derived from this software without specific prior written permission.
63108 + *
63109 + *
63110 + * ALTERNATIVELY, this software may be distributed under the terms of the
63111 + * GNU General Public License ("GPL") as published by the Free Software
63112 + * Foundation, either version 2 of that License or (at your option) any
63113 + * later version.
63114 + *
63115 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
63116 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
63117 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
63118 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
63119 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
63120 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63121 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
63122 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
63123 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
63124 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63125 + */
63126 +
63127 +
63128 +/**************************************************************************//**
63129 + @File fm_ext.h
63130 +
63131 + @Description FM Application Programming Interface.
63132 +*//***************************************************************************/
63133 +#ifndef __FM_EXT
63134 +#define __FM_EXT
63135 +
63136 +#include "error_ext.h"
63137 +#include "std_ext.h"
63138 +#include "dpaa_ext.h"
63139 +#include "fsl_fman_sp.h"
63140 +
63141 +/**************************************************************************//**
63142 + @Group FM_grp Frame Manager API
63143 +
63144 + @Description FM API functions, definitions and enums.
63145 +
63146 + @{
63147 +*//***************************************************************************/
63148 +
63149 +/**************************************************************************//**
63150 + @Group FM_lib_grp FM library
63151 +
63152 + @Description FM API functions, definitions and enums.
63153 +
63154 + The FM module is the main driver module and is a mandatory module
63155 + for FM driver users. This module must be initialized first prior
63156 + to any other drivers modules.
63157 + The FM is a "singleton" module. It is responsible of the common
63158 + HW modules: FPM, DMA, common QMI and common BMI initializations and
63159 + run-time control routines. This module must be initialized always
63160 + when working with any of the FM modules.
63161 + NOTE - We assume that the FM library will be initialized only by core No. 0!
63162 +
63163 + @{
63164 +*//***************************************************************************/
63165 +
63166 +/**************************************************************************//**
63167 + @Description Enum for defining port types
63168 +*//***************************************************************************/
63169 +typedef enum e_FmPortType {
63170 + e_FM_PORT_TYPE_OH_OFFLINE_PARSING = 0, /**< Offline parsing port */
63171 + e_FM_PORT_TYPE_RX, /**< 1G Rx port */
63172 + e_FM_PORT_TYPE_RX_10G, /**< 10G Rx port */
63173 + e_FM_PORT_TYPE_TX, /**< 1G Tx port */
63174 + e_FM_PORT_TYPE_TX_10G, /**< 10G Tx port */
63175 + e_FM_PORT_TYPE_DUMMY
63176 +} e_FmPortType;
63177 +
63178 +/**************************************************************************//**
63179 + @Collection General FM defines
63180 +*//***************************************************************************/
63181 +#define FM_MAX_NUM_OF_PARTITIONS 64 /**< Maximum number of partitions */
63182 +#define FM_PHYS_ADDRESS_SIZE 6 /**< FM Physical address size */
63183 +/* @} */
63184 +
63185 +
63186 +#if defined(__MWERKS__) && !defined(__GNUC__)
63187 +#pragma pack(push,1)
63188 +#endif /* defined(__MWERKS__) && ... */
63189 +
63190 +/**************************************************************************//**
63191 + @Description FM physical Address
63192 +*//***************************************************************************/
63193 +typedef _Packed struct t_FmPhysAddr {
63194 + volatile uint8_t high; /**< High part of the physical address */
63195 + volatile uint32_t low; /**< Low part of the physical address */
63196 +} _PackedType t_FmPhysAddr;
63197 +
63198 +/**************************************************************************//**
63199 + @Description Parse results memory layout
63200 +*//***************************************************************************/
63201 +typedef _Packed struct t_FmPrsResult {
63202 + volatile uint8_t lpid; /**< Logical port id */
63203 + volatile uint8_t shimr; /**< Shim header result */
63204 + volatile uint16_t l2r; /**< Layer 2 result */
63205 + volatile uint16_t l3r; /**< Layer 3 result */
63206 + volatile uint8_t l4r; /**< Layer 4 result */
63207 + volatile uint8_t cplan; /**< Classification plan id */
63208 + volatile uint16_t nxthdr; /**< Next Header */
63209 + volatile uint16_t cksum; /**< Running-sum */
63210 + volatile uint16_t flags_frag_off; /**< Flags & fragment-offset field of the last IP-header */
63211 + volatile uint8_t route_type; /**< Routing type field of a IPv6 routing extension header */
63212 + volatile uint8_t rhp_ip_valid; /**< Routing Extension Header Present; last bit is IP valid */
63213 + volatile uint8_t shim_off[2]; /**< Shim offset */
63214 + volatile uint8_t ip_pid_off; /**< IP PID (last IP-proto) offset */
63215 + volatile uint8_t eth_off; /**< ETH offset */
63216 + volatile uint8_t llc_snap_off; /**< LLC_SNAP offset */
63217 + volatile uint8_t vlan_off[2]; /**< VLAN offset */
63218 + volatile uint8_t etype_off; /**< ETYPE offset */
63219 + volatile uint8_t pppoe_off; /**< PPP offset */
63220 + volatile uint8_t mpls_off[2]; /**< MPLS offset */
63221 + volatile uint8_t ip_off[2]; /**< IP offset */
63222 + volatile uint8_t gre_off; /**< GRE offset */
63223 + volatile uint8_t l4_off; /**< Layer 4 offset */
63224 + volatile uint8_t nxthdr_off; /**< Parser end point */
63225 +} _PackedType t_FmPrsResult;
63226 +
63227 +/**************************************************************************//**
63228 + @Collection FM Parser results
63229 +*//***************************************************************************/
63230 +#define FM_PR_L2_VLAN_STACK 0x00000100 /**< Parse Result: VLAN stack */
63231 +#define FM_PR_L2_ETHERNET 0x00008000 /**< Parse Result: Ethernet*/
63232 +#define FM_PR_L2_VLAN 0x00004000 /**< Parse Result: VLAN */
63233 +#define FM_PR_L2_LLC_SNAP 0x00002000 /**< Parse Result: LLC_SNAP */
63234 +#define FM_PR_L2_MPLS 0x00001000 /**< Parse Result: MPLS */
63235 +#define FM_PR_L2_PPPoE 0x00000800 /**< Parse Result: PPPoE */
63236 +/* @} */
63237 +
63238 +/**************************************************************************//**
63239 + @Collection FM Frame descriptor macros
63240 +*//***************************************************************************/
63241 +#define FM_FD_CMD_FCO 0x80000000 /**< Frame queue Context Override */
63242 +#define FM_FD_CMD_RPD 0x40000000 /**< Read Prepended Data */
63243 +#define FM_FD_CMD_UPD 0x20000000 /**< Update Prepended Data */
63244 +#define FM_FD_CMD_DTC 0x10000000 /**< Do L4 Checksum */
63245 +#define FM_FD_CMD_DCL4C 0x10000000 /**< Didn't calculate L4 Checksum */
63246 +#define FM_FD_CMD_CFQ 0x00ffffff /**< Confirmation Frame Queue */
63247 +
63248 +#define FM_FD_ERR_UNSUPPORTED_FORMAT 0x04000000 /**< Not for Rx-Port! Unsupported Format */
63249 +#define FM_FD_ERR_LENGTH 0x02000000 /**< Not for Rx-Port! Length Error */
63250 +#define FM_FD_ERR_DMA 0x01000000 /**< DMA Data error */
63251 +
63252 +#define FM_FD_IPR 0x00000001 /**< IPR frame (not error) */
63253 +
63254 +#define FM_FD_ERR_IPR_NCSP (0x00100000 | FM_FD_IPR) /**< IPR non-consistent-sp */
63255 +#define FM_FD_ERR_IPR (0x00200000 | FM_FD_IPR) /**< IPR error */
63256 +#define FM_FD_ERR_IPR_TO (0x00300000 | FM_FD_IPR) /**< IPR timeout */
63257 +
63258 +#ifdef FM_CAPWAP_SUPPORT
63259 +#define FM_FD_ERR_CRE 0x00200000
63260 +#define FM_FD_ERR_CHE 0x00100000
63261 +#endif /* FM_CAPWAP_SUPPORT */
63262 +
63263 +#define FM_FD_ERR_PHYSICAL 0x00080000 /**< Rx FIFO overflow, FCS error, code error, running disparity
63264 + error (SGMII and TBI modes), FIFO parity error. PHY
63265 + Sequence error, PHY error control character detected. */
63266 +#define FM_FD_ERR_SIZE 0x00040000 /**< Frame too long OR Frame size exceeds max_length_frame */
63267 +#define FM_FD_ERR_CLS_DISCARD 0x00020000 /**< classification discard */
63268 +#define FM_FD_ERR_EXTRACTION 0x00008000 /**< Extract Out of Frame */
63269 +#define FM_FD_ERR_NO_SCHEME 0x00004000 /**< No Scheme Selected */
63270 +#define FM_FD_ERR_KEYSIZE_OVERFLOW 0x00002000 /**< Keysize Overflow */
63271 +#define FM_FD_ERR_COLOR_RED 0x00000800 /**< Frame color is red */
63272 +#define FM_FD_ERR_COLOR_YELLOW 0x00000400 /**< Frame color is yellow */
63273 +#define FM_FD_ERR_ILL_PLCR 0x00000200 /**< Illegal Policer Profile selected */
63274 +#define FM_FD_ERR_PLCR_FRAME_LEN 0x00000100 /**< Policer frame length error */
63275 +#define FM_FD_ERR_PRS_TIMEOUT 0x00000080 /**< Parser Time out Exceed */
63276 +#define FM_FD_ERR_PRS_ILL_INSTRUCT 0x00000040 /**< Invalid Soft Parser instruction */
63277 +#define FM_FD_ERR_PRS_HDR_ERR 0x00000020 /**< Header error was identified during parsing */
63278 +#define FM_FD_ERR_BLOCK_LIMIT_EXCEEDED 0x00000008 /**< Frame parsed beyind 256 first bytes */
63279 +
63280 +#define FM_FD_TX_STATUS_ERR_MASK (FM_FD_ERR_UNSUPPORTED_FORMAT | \
63281 + FM_FD_ERR_LENGTH | \
63282 + FM_FD_ERR_DMA) /**< TX Error FD bits */
63283 +
63284 +#define FM_FD_RX_STATUS_ERR_MASK (FM_FD_ERR_UNSUPPORTED_FORMAT | \
63285 + FM_FD_ERR_LENGTH | \
63286 + FM_FD_ERR_DMA | \
63287 + FM_FD_ERR_IPR | \
63288 + FM_FD_ERR_IPR_TO | \
63289 + FM_FD_ERR_IPR_NCSP | \
63290 + FM_FD_ERR_PHYSICAL | \
63291 + FM_FD_ERR_SIZE | \
63292 + FM_FD_ERR_CLS_DISCARD | \
63293 + FM_FD_ERR_COLOR_RED | \
63294 + FM_FD_ERR_COLOR_YELLOW | \
63295 + FM_FD_ERR_ILL_PLCR | \
63296 + FM_FD_ERR_PLCR_FRAME_LEN | \
63297 + FM_FD_ERR_EXTRACTION | \
63298 + FM_FD_ERR_NO_SCHEME | \
63299 + FM_FD_ERR_KEYSIZE_OVERFLOW | \
63300 + FM_FD_ERR_PRS_TIMEOUT | \
63301 + FM_FD_ERR_PRS_ILL_INSTRUCT | \
63302 + FM_FD_ERR_PRS_HDR_ERR | \
63303 + FM_FD_ERR_BLOCK_LIMIT_EXCEEDED) /**< RX Error FD bits */
63304 +
63305 +#define FM_FD_RX_STATUS_ERR_NON_FM 0x00400000 /**< non Frame-Manager error */
63306 +/* @} */
63307 +
63308 +/**************************************************************************//**
63309 + @Description Context A
63310 +*//***************************************************************************/
63311 +typedef _Packed struct t_FmContextA {
63312 + volatile uint32_t command; /**< ContextA Command */
63313 + volatile uint8_t res0[4]; /**< ContextA Reserved bits */
63314 +} _PackedType t_FmContextA;
63315 +
63316 +/**************************************************************************//**
63317 + @Description Context B
63318 +*//***************************************************************************/
63319 +typedef uint32_t t_FmContextB;
63320 +
63321 +/**************************************************************************//**
63322 + @Collection Special Operation options
63323 +*//***************************************************************************/
63324 +typedef uint32_t fmSpecialOperations_t; /**< typedef for defining Special Operation options */
63325 +
63326 +#define FM_SP_OP_IPSEC 0x80000000 /**< activate features that related to IPSec (e.g fix Eth-type) */
63327 +#define FM_SP_OP_IPSEC_UPDATE_UDP_LEN 0x40000000 /**< update the UDP-Len after Encryption */
63328 +#define FM_SP_OP_IPSEC_MANIP 0x20000000 /**< handle the IPSec-manip options */
63329 +#define FM_SP_OP_RPD 0x10000000 /**< Set the RPD bit */
63330 +#define FM_SP_OP_DCL4C 0x08000000 /**< Set the DCL4C bit */
63331 +#define FM_SP_OP_CHECK_SEC_ERRORS 0x04000000 /**< Check SEC errors */
63332 +#define FM_SP_OP_CLEAR_RPD 0x02000000 /**< Clear the RPD bit */
63333 +#define FM_SP_OP_CAPWAP_DTLS_ENC 0x01000000 /**< activate features that related to CAPWAP-DTLS post Encryption */
63334 +#define FM_SP_OP_CAPWAP_DTLS_DEC 0x00800000 /**< activate features that related to CAPWAP-DTLS post Decryption */
63335 +#define FM_SP_OP_IPSEC_NO_ETH_HDR 0x00400000 /**< activate features that related to IPSec without Eth hdr */
63336 +/* @} */
63337 +
63338 +/**************************************************************************//**
63339 + @Collection Context A macros
63340 +*//***************************************************************************/
63341 +#define FM_CONTEXTA_OVERRIDE_MASK 0x80000000
63342 +#define FM_CONTEXTA_ICMD_MASK 0x40000000
63343 +#define FM_CONTEXTA_A1_VALID_MASK 0x20000000
63344 +#define FM_CONTEXTA_MACCMD_MASK 0x00ff0000
63345 +#define FM_CONTEXTA_MACCMD_VALID_MASK 0x00800000
63346 +#define FM_CONTEXTA_MACCMD_SECURED_MASK 0x00100000
63347 +#define FM_CONTEXTA_MACCMD_SC_MASK 0x000f0000
63348 +#define FM_CONTEXTA_A1_MASK 0x0000ffff
63349 +
63350 +#define FM_CONTEXTA_GET_OVERRIDE(contextA) ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_OVERRIDE_MASK) >> (31-0))
63351 +#define FM_CONTEXTA_GET_ICMD(contextA) ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_ICMD_MASK) >> (31-1))
63352 +#define FM_CONTEXTA_GET_A1_VALID(contextA) ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_A1_VALID_MASK) >> (31-2))
63353 +#define FM_CONTEXTA_GET_A1(contextA) ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_A1_MASK) >> (31-31))
63354 +#define FM_CONTEXTA_GET_MACCMD(contextA) ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_MACCMD_MASK) >> (31-15))
63355 +#define FM_CONTEXTA_GET_MACCMD_VALID(contextA) ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_MACCMD_VALID_MASK) >> (31-8))
63356 +#define FM_CONTEXTA_GET_MACCMD_SECURED(contextA) ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_MACCMD_SECURED_MASK) >> (31-11))
63357 +#define FM_CONTEXTA_GET_MACCMD_SECURE_CHANNEL(contextA) ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_MACCMD_SC_MASK) >> (31-15))
63358 +
63359 +#define FM_CONTEXTA_SET_OVERRIDE(contextA,val) (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_OVERRIDE_MASK) | (((uint32_t)(val) << (31-0)) & FM_CONTEXTA_OVERRIDE_MASK) ))
63360 +#define FM_CONTEXTA_SET_ICMD(contextA,val) (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_ICMD_MASK) | (((val) << (31-1)) & FM_CONTEXTA_ICMD_MASK) ))
63361 +#define FM_CONTEXTA_SET_A1_VALID(contextA,val) (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_A1_VALID_MASK) | (((val) << (31-2)) & FM_CONTEXTA_A1_VALID_MASK) ))
63362 +#define FM_CONTEXTA_SET_A1(contextA,val) (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_A1_MASK) | (((val) << (31-31)) & FM_CONTEXTA_A1_MASK) ))
63363 +#define FM_CONTEXTA_SET_MACCMD(contextA,val) (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_MACCMD_MASK) | (((val) << (31-15)) & FM_CONTEXTA_MACCMD_MASK) ))
63364 +#define FM_CONTEXTA_SET_MACCMD_VALID(contextA,val) (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_MACCMD_VALID_MASK) | (((val) << (31-8)) & FM_CONTEXTA_MACCMD_VALID_MASK) ))
63365 +#define FM_CONTEXTA_SET_MACCMD_SECURED(contextA,val) (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_MACCMD_SECURED_MASK) | (((val) << (31-11)) & FM_CONTEXTA_MACCMD_SECURED_MASK) ))
63366 +#define FM_CONTEXTA_SET_MACCMD_SECURE_CHANNEL(contextA,val) (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_MACCMD_SC_MASK) | (((val) << (31-15)) & FM_CONTEXTA_MACCMD_SC_MASK) ))
63367 +/* @} */
63368 +
63369 +/**************************************************************************//**
63370 + @Collection Context B macros
63371 +*//***************************************************************************/
63372 +#define FM_CONTEXTB_FQID_MASK 0x00ffffff
63373 +
63374 +#define FM_CONTEXTB_GET_FQID(contextB) (*((t_FmContextB *)contextB) & FM_CONTEXTB_FQID_MASK)
63375 +#define FM_CONTEXTB_SET_FQID(contextB,val) (*((t_FmContextB *)contextB) = ((*((t_FmContextB *)contextB) & ~FM_CONTEXTB_FQID_MASK) | ((val) & FM_CONTEXTB_FQID_MASK)))
63376 +/* @} */
63377 +
63378 +#if defined(__MWERKS__) && !defined(__GNUC__)
63379 +#pragma pack(pop)
63380 +#endif /* defined(__MWERKS__) && ... */
63381 +
63382 +
63383 +/**************************************************************************//**
63384 + @Description FM Exceptions
63385 +*//***************************************************************************/
63386 +typedef enum e_FmExceptions {
63387 + e_FM_EX_DMA_BUS_ERROR = 0, /**< DMA bus error. */
63388 + e_FM_EX_DMA_READ_ECC, /**< Read Buffer ECC error (Valid for FM rev < 6)*/
63389 + e_FM_EX_DMA_SYSTEM_WRITE_ECC, /**< Write Buffer ECC error on system side (Valid for FM rev < 6)*/
63390 + e_FM_EX_DMA_FM_WRITE_ECC, /**< Write Buffer ECC error on FM side (Valid for FM rev < 6)*/
63391 + e_FM_EX_DMA_SINGLE_PORT_ECC, /**< Single Port ECC error on FM side (Valid for FM rev > 6)*/
63392 + e_FM_EX_FPM_STALL_ON_TASKS, /**< Stall of tasks on FPM */
63393 + e_FM_EX_FPM_SINGLE_ECC, /**< Single ECC on FPM. */
63394 + e_FM_EX_FPM_DOUBLE_ECC, /**< Double ECC error on FPM ram access */
63395 + e_FM_EX_QMI_SINGLE_ECC, /**< Single ECC on QMI. */
63396 + e_FM_EX_QMI_DOUBLE_ECC, /**< Double bit ECC occurred on QMI */
63397 + e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,/**< Dequeue from unknown port id */
63398 + e_FM_EX_BMI_LIST_RAM_ECC, /**< Linked List RAM ECC error */
63399 + e_FM_EX_BMI_STORAGE_PROFILE_ECC, /**< Storage Profile ECC Error */
63400 + e_FM_EX_BMI_STATISTICS_RAM_ECC, /**< Statistics Count RAM ECC Error Enable */
63401 + e_FM_EX_BMI_DISPATCH_RAM_ECC, /**< Dispatch RAM ECC Error Enable */
63402 + e_FM_EX_IRAM_ECC, /**< Double bit ECC occurred on IRAM*/
63403 + e_FM_EX_MURAM_ECC /**< Double bit ECC occurred on MURAM*/
63404 +} e_FmExceptions;
63405 +
63406 +/**************************************************************************//**
63407 + @Description Enum for defining port DMA swap mode
63408 +*//***************************************************************************/
63409 +typedef enum e_FmDmaSwapOption {
63410 + e_FM_DMA_NO_SWP = FMAN_DMA_NO_SWP, /**< No swap, transfer data as is.*/
63411 + e_FM_DMA_SWP_PPC_LE = FMAN_DMA_SWP_PPC_LE, /**< The transferred data should be swapped
63412 + in PowerPc Little Endian mode. */
63413 + e_FM_DMA_SWP_BE = FMAN_DMA_SWP_BE /**< The transferred data should be swapped
63414 + in Big Endian mode */
63415 +} e_FmDmaSwapOption;
63416 +
63417 +/**************************************************************************//**
63418 + @Description Enum for defining port DMA cache attributes
63419 +*//***************************************************************************/
63420 +typedef enum e_FmDmaCacheOption {
63421 + e_FM_DMA_NO_STASH = FMAN_DMA_NO_STASH, /**< Cacheable, no Allocate (No Stashing) */
63422 + e_FM_DMA_STASH = FMAN_DMA_STASH /**< Cacheable and Allocate (Stashing on) */
63423 +} e_FmDmaCacheOption;
63424 +
63425 +
63426 +/**************************************************************************//**
63427 + @Group FM_init_grp FM Initialization Unit
63428 +
63429 + @Description FM Initialization Unit
63430 +
63431 + Initialization Flow
63432 + Initialization of the FM Module will be carried out by the application
63433 + according to the following sequence:
63434 + - Calling the configuration routine with basic parameters.
63435 + - Calling the advance initialization routines to change driver's defaults.
63436 + - Calling the initialization routine.
63437 +
63438 + @{
63439 +*//***************************************************************************/
63440 +
63441 +/**************************************************************************//**
63442 + @Function t_FmExceptionsCallback
63443 +
63444 + @Description Exceptions user callback routine, will be called upon an
63445 + exception passing the exception identification.
63446 +
63447 + @Param[in] h_App - User's application descriptor.
63448 + @Param[in] exception - The exception.
63449 +*//***************************************************************************/
63450 +typedef void (t_FmExceptionsCallback)(t_Handle h_App,
63451 + e_FmExceptions exception);
63452 +
63453 +
63454 +/**************************************************************************//**
63455 + @Function t_FmBusErrorCallback
63456 +
63457 + @Description Bus error user callback routine, will be called upon a
63458 + bus error, passing parameters describing the errors and the owner.
63459 +
63460 + @Param[in] h_App - User's application descriptor.
63461 + @Param[in] portType - Port type (e_FmPortType)
63462 + @Param[in] portId - Port id - relative to type.
63463 + @Param[in] addr - Address that caused the error
63464 + @Param[in] tnum - Owner of error
63465 + @Param[in] liodn - Logical IO device number
63466 +*//***************************************************************************/
63467 +typedef void (t_FmBusErrorCallback) (t_Handle h_App,
63468 + e_FmPortType portType,
63469 + uint8_t portId,
63470 + uint64_t addr,
63471 + uint8_t tnum,
63472 + uint16_t liodn);
63473 +
63474 +/**************************************************************************//**
63475 + @Description A structure for defining buffer prefix area content.
63476 +*//***************************************************************************/
63477 +typedef struct t_FmBufferPrefixContent {
63478 + uint16_t privDataSize; /**< Number of bytes to be left at the beginning
63479 + of the external buffer; Note that the private-area will
63480 + start from the base of the buffer address. */
63481 + bool passPrsResult; /**< TRUE to pass the parse result to/from the FM;
63482 + User may use FM_PORT_GetBufferPrsResult() in order to
63483 + get the parser-result from a buffer. */
63484 + bool passTimeStamp; /**< TRUE to pass the timeStamp to/from the FM
63485 + User may use FM_PORT_GetBufferTimeStamp() in order to
63486 + get the parser-result from a buffer. */
63487 + bool passHashResult; /**< TRUE to pass the KG hash result to/from the FM
63488 + User may use FM_PORT_GetBufferHashResult() in order to
63489 + get the parser-result from a buffer. */
63490 + bool passAllOtherPCDInfo;/**< Add all other Internal-Context information:
63491 + AD, hash-result, key, etc. */
63492 + uint16_t dataAlign; /**< 0 to use driver's default alignment [DEFAULT_FM_SP_bufferPrefixContent_dataAlign],
63493 + other value for selecting a data alignment (must be a power of 2);
63494 + if write optimization is used, must be >= 16. */
63495 + uint8_t manipExtraSpace; /**< Maximum extra size needed (insertion-size minus removal-size);
63496 + Note that this field impacts the size of the buffer-prefix
63497 + (i.e. it pushes the data offset);
63498 + This field is irrelevant if DPAA_VERSION==10 */
63499 +} t_FmBufferPrefixContent;
63500 +
63501 +/**************************************************************************//**
63502 + @Description A structure of information about each of the external
63503 + buffer pools used by a port or storage-profile.
63504 +*//***************************************************************************/
63505 +typedef struct t_FmExtPoolParams {
63506 + uint8_t id; /**< External buffer pool id */
63507 + uint16_t size; /**< External buffer pool buffer size */
63508 +} t_FmExtPoolParams;
63509 +
63510 +/**************************************************************************//**
63511 + @Description A structure for informing the driver about the external
63512 + buffer pools allocated in the BM and used by a port or a
63513 + storage-profile.
63514 +*//***************************************************************************/
63515 +typedef struct t_FmExtPools {
63516 + uint8_t numOfPoolsUsed; /**< Number of pools use by this port */
63517 + t_FmExtPoolParams extBufPool[FM_PORT_MAX_NUM_OF_EXT_POOLS];
63518 + /**< Parameters for each port */
63519 +} t_FmExtPools;
63520 +
63521 +/**************************************************************************//**
63522 + @Description A structure for defining backup BM Pools.
63523 +*//***************************************************************************/
63524 +typedef struct t_FmBackupBmPools {
63525 + uint8_t numOfBackupPools; /**< Number of BM backup pools -
63526 + must be smaller than the total number of
63527 + pools defined for the specified port.*/
63528 + uint8_t poolIds[FM_PORT_MAX_NUM_OF_EXT_POOLS];
63529 + /**< numOfBackupPools pool id's, specifying which
63530 + pools should be used only as backup. Pool
63531 + id's specified here must be a subset of the
63532 + pools used by the specified port.*/
63533 +} t_FmBackupBmPools;
63534 +
63535 +/**************************************************************************//**
63536 + @Description A structure for defining BM pool depletion criteria
63537 +*//***************************************************************************/
63538 +typedef struct t_FmBufPoolDepletion {
63539 + bool poolsGrpModeEnable; /**< select mode in which pause frames will be sent after
63540 + a number of pools (all together!) are depleted */
63541 + uint8_t numOfPools; /**< the number of depleted pools that will invoke
63542 + pause frames transmission. */
63543 + bool poolsToConsider[BM_MAX_NUM_OF_POOLS];
63544 + /**< For each pool, TRUE if it should be considered for
63545 + depletion (Note - this pool must be used by this port!). */
63546 + bool singlePoolModeEnable; /**< select mode in which pause frames will be sent after
63547 + a single-pool is depleted; */
63548 + bool poolsToConsiderForSingleMode[BM_MAX_NUM_OF_POOLS];
63549 + /**< For each pool, TRUE if it should be considered for
63550 + depletion (Note - this pool must be used by this port!) */
63551 +#if (DPAA_VERSION >= 11)
63552 + bool pfcPrioritiesEn[FM_MAX_NUM_OF_PFC_PRIORITIES];
63553 + /**< This field is used by the MAC as the Priority Enable Vector in the PFC frame which is transmitted */
63554 +#endif /* (DPAA_VERSION >= 11) */
63555 +} t_FmBufPoolDepletion;
63556 +
63557 +/**************************************************************************//**
63558 + @Description A Structure for defining Ucode patch for loading.
63559 +*//***************************************************************************/
63560 +typedef struct t_FmFirmwareParams {
63561 + uint32_t size; /**< Size of uCode */
63562 + uint32_t *p_Code; /**< A pointer to the uCode */
63563 +} t_FmFirmwareParams;
63564 +
63565 +/**************************************************************************//**
63566 + @Description A Structure for defining FM initialization parameters
63567 +*//***************************************************************************/
63568 +typedef struct t_FmParams {
63569 + uint8_t fmId; /**< Index of the FM */
63570 + uint8_t guestId; /**< FM Partition Id */
63571 + uintptr_t baseAddr; /**< A pointer to base of memory mapped FM registers (virtual);
63572 + this field is optional when the FM runs in "guest-mode"
63573 + (i.e. guestId != NCSW_MASTER_ID); in that case, the driver will
63574 + use the memory-map instead of calling the IPC where possible;
63575 + NOTE that this should include ALL common registers of the FM including
63576 + the PCD registers area (i.e. until the VSP pages - 880KB). */
63577 + t_Handle h_FmMuram; /**< A handle of an initialized MURAM object,
63578 + to be used by the FM. */
63579 + uint16_t fmClkFreq; /**< In Mhz;
63580 + Relevant when FM not runs in "guest-mode". */
63581 + uint16_t fmMacClkRatio; /**< FM MAC Clock ratio, for backward comparability:
63582 + when fmMacClkRatio = 0, ratio is 2:1
63583 + when fmMacClkRatio = 1, ratio is 1:1 */
63584 + t_FmExceptionsCallback *f_Exception; /**< An application callback routine to handle exceptions;
63585 + Relevant when FM not runs in "guest-mode". */
63586 + t_FmBusErrorCallback *f_BusError; /**< An application callback routine to handle exceptions;
63587 + Relevant when FM not runs in "guest-mode". */
63588 + t_Handle h_App; /**< A handle to an application layer object; This handle will
63589 + be passed by the driver upon calling the above callbacks;
63590 + Relevant when FM not runs in "guest-mode". */
63591 + int irq; /**< FM interrupt source for normal events;
63592 + Relevant when FM not runs in "guest-mode". */
63593 + int errIrq; /**< FM interrupt source for errors;
63594 + Relevant when FM not runs in "guest-mode". */
63595 + t_FmFirmwareParams firmware; /**< The firmware parameters structure;
63596 + Relevant when FM not runs in "guest-mode". */
63597 +
63598 +#if (DPAA_VERSION >= 11)
63599 + uintptr_t vspBaseAddr; /**< A pointer to base of memory mapped FM VSP registers (virtual);
63600 + i.e. up to 24KB, depending on the specific chip. */
63601 + uint8_t partVSPBase; /**< The first Virtual-Storage-Profile-id dedicated to this partition.
63602 + NOTE: this parameter relevant only when working with multiple partitions. */
63603 + uint8_t partNumOfVSPs; /**< Number of VSPs dedicated to this partition.
63604 + NOTE: this parameter relevant only when working with multiple partitions. */
63605 +#endif /* (DPAA_VERSION >= 11) */
63606 +} t_FmParams;
63607 +
63608 +
63609 +/**************************************************************************//**
63610 + @Function FM_Config
63611 +
63612 + @Description Creates the FM module and returns its handle (descriptor).
63613 + This descriptor must be passed as first parameter to all other
63614 + FM function calls.
63615 +
63616 + No actual initialization or configuration of FM hardware is
63617 + done by this routine. All FM parameters get default values that
63618 + may be changed by calling one or more of the advance config routines.
63619 +
63620 + @Param[in] p_FmParams - A pointer to a data structure of mandatory FM parameters
63621 +
63622 + @Return A handle to the FM object, or NULL for Failure.
63623 +*//***************************************************************************/
63624 +t_Handle FM_Config(t_FmParams *p_FmParams);
63625 +
63626 +/**************************************************************************//**
63627 + @Function FM_Init
63628 +
63629 + @Description Initializes the FM module by defining the software structure
63630 + and configuring the hardware registers.
63631 +
63632 + @Param[in] h_Fm - FM module descriptor
63633 +
63634 + @Return E_OK on success; Error code otherwise.
63635 +*//***************************************************************************/
63636 +t_Error FM_Init(t_Handle h_Fm);
63637 +
63638 +/**************************************************************************//**
63639 + @Function FM_Free
63640 +
63641 + @Description Frees all resources that were assigned to FM module.
63642 +
63643 + Calling this routine invalidates the descriptor.
63644 +
63645 + @Param[in] h_Fm - FM module descriptor
63646 +
63647 + @Return E_OK on success; Error code otherwise.
63648 +*//***************************************************************************/
63649 +t_Error FM_Free(t_Handle h_Fm);
63650 +
63651 +
63652 +/**************************************************************************//**
63653 + @Group FM_advanced_init_grp FM Advanced Configuration Unit
63654 +
63655 + @Description Advanced configuration routines are optional routines that may
63656 + be called in order to change the default driver settings.
63657 +
63658 + Note: Advanced configuration routines are not available for guest partition.
63659 + @{
63660 +*//***************************************************************************/
63661 +
63662 +/**************************************************************************//**
63663 + @Description Enum for selecting DMA debug mode
63664 +*//***************************************************************************/
63665 +typedef enum e_FmDmaDbgCntMode {
63666 + e_FM_DMA_DBG_NO_CNT = 0, /**< No counting */
63667 + e_FM_DMA_DBG_CNT_DONE, /**< Count DONE commands */
63668 + e_FM_DMA_DBG_CNT_COMM_Q_EM, /**< count command queue emergency signals */
63669 + e_FM_DMA_DBG_CNT_INT_READ_EM, /**< Count Internal Read buffer emergency signal */
63670 + e_FM_DMA_DBG_CNT_INT_WRITE_EM, /**< Count Internal Write buffer emergency signal */
63671 + e_FM_DMA_DBG_CNT_FPM_WAIT, /**< Count FPM WAIT signal */
63672 + e_FM_DMA_DBG_CNT_SIGLE_BIT_ECC, /**< Single bit ECC errors. */
63673 + e_FM_DMA_DBG_CNT_RAW_WAR_PROT /**< Number of times there was a need for RAW & WAR protection. */
63674 +} e_FmDmaDbgCntMode;
63675 +
63676 +/**************************************************************************//**
63677 + @Description Enum for selecting DMA Cache Override
63678 +*//***************************************************************************/
63679 +typedef enum e_FmDmaCacheOverride {
63680 + e_FM_DMA_NO_CACHE_OR = 0, /**< No override of the Cache field */
63681 + e_FM_DMA_NO_STASH_DATA, /**< Data should not be stashed in system level cache */
63682 + e_FM_DMA_MAY_STASH_DATA, /**< Data may be stashed in system level cache */
63683 + e_FM_DMA_STASH_DATA /**< Data should be stashed in system level cache */
63684 +} e_FmDmaCacheOverride;
63685 +
63686 +/**************************************************************************//**
63687 + @Description Enum for selecting DMA External Bus Priority
63688 +*//***************************************************************************/
63689 +typedef enum e_FmDmaExtBusPri {
63690 + e_FM_DMA_EXT_BUS_NORMAL = 0, /**< Normal priority */
63691 + e_FM_DMA_EXT_BUS_EBS, /**< AXI extended bus service priority */
63692 + e_FM_DMA_EXT_BUS_SOS, /**< AXI sos priority */
63693 + e_FM_DMA_EXT_BUS_EBS_AND_SOS /**< AXI ebs + sos priority */
63694 +} e_FmDmaExtBusPri;
63695 +
63696 +/**************************************************************************//**
63697 + @Description Enum for choosing the field that will be output on AID
63698 +*//***************************************************************************/
63699 +typedef enum e_FmDmaAidMode {
63700 + e_FM_DMA_AID_OUT_PORT_ID = 0, /**< 4 LSB of PORT_ID */
63701 + e_FM_DMA_AID_OUT_TNUM /**< 4 LSB of TNUM */
63702 +} e_FmDmaAidMode;
63703 +
63704 +/**************************************************************************//**
63705 + @Description Enum for selecting FPM Catastrophic error behavior
63706 +*//***************************************************************************/
63707 +typedef enum e_FmCatastrophicErr {
63708 + e_FM_CATASTROPHIC_ERR_STALL_PORT = 0, /**< Port_ID is stalled (only reset can release it) */
63709 + e_FM_CATASTROPHIC_ERR_STALL_TASK /**< Only erroneous task is stalled */
63710 +} e_FmCatastrophicErr;
63711 +
63712 +/**************************************************************************//**
63713 + @Description Enum for selecting FPM DMA Error behavior
63714 +*//***************************************************************************/
63715 +typedef enum e_FmDmaErr {
63716 + e_FM_DMA_ERR_CATASTROPHIC = 0, /**< Dma error is treated as a catastrophic
63717 + error (e_FmCatastrophicErr)*/
63718 + e_FM_DMA_ERR_REPORT /**< Dma error is just reported */
63719 +} e_FmDmaErr;
63720 +
63721 +/**************************************************************************//**
63722 + @Description Enum for selecting DMA Emergency level by BMI emergency signal
63723 +*//***************************************************************************/
63724 +typedef enum e_FmDmaEmergencyLevel {
63725 + e_FM_DMA_EM_EBS = 0, /**< EBS emergency */
63726 + e_FM_DMA_EM_SOS /**< SOS emergency */
63727 +} e_FmDmaEmergencyLevel;
63728 +
63729 +/**************************************************************************//**
63730 + @Collection Enum for selecting DMA Emergency options
63731 +*//***************************************************************************/
63732 +typedef uint32_t fmEmergencyBus_t; /**< DMA emergency options */
63733 +
63734 +#define FM_DMA_MURAM_READ_EMERGENCY 0x00800000 /**< Enable emergency for MURAM1 */
63735 +#define FM_DMA_MURAM_WRITE_EMERGENCY 0x00400000 /**< Enable emergency for MURAM2 */
63736 +#define FM_DMA_EXT_BUS_EMERGENCY 0x00100000 /**< Enable emergency for external bus */
63737 +/* @} */
63738 +
63739 +/**************************************************************************//**
63740 + @Description A structure for defining DMA emergency level
63741 +*//***************************************************************************/
63742 +typedef struct t_FmDmaEmergency {
63743 + fmEmergencyBus_t emergencyBusSelect; /**< An OR of the busses where emergency
63744 + should be enabled */
63745 + e_FmDmaEmergencyLevel emergencyLevel; /**< EBS/SOS */
63746 +} t_FmDmaEmergency;
63747 +
63748 +/**************************************************************************//*
63749 + @Description structure for defining FM threshold
63750 +*//***************************************************************************/
63751 +typedef struct t_FmThresholds {
63752 + uint8_t dispLimit; /**< The number of times a frames may
63753 + be passed in the FM before assumed to
63754 + be looping. */
63755 + uint8_t prsDispTh; /**< This is the number pf packets that may be
63756 + queued in the parser dispatch queue*/
63757 + uint8_t plcrDispTh; /**< This is the number pf packets that may be
63758 + queued in the policer dispatch queue*/
63759 + uint8_t kgDispTh; /**< This is the number pf packets that may be
63760 + queued in the keygen dispatch queue*/
63761 + uint8_t bmiDispTh; /**< This is the number pf packets that may be
63762 + queued in the BMI dispatch queue*/
63763 + uint8_t qmiEnqDispTh; /**< This is the number pf packets that may be
63764 + queued in the QMI enqueue dispatch queue*/
63765 + uint8_t qmiDeqDispTh; /**< This is the number pf packets that may be
63766 + queued in the QMI dequeue dispatch queue*/
63767 + uint8_t fmCtl1DispTh; /**< This is the number pf packets that may be
63768 + queued in fmCtl1 dispatch queue*/
63769 + uint8_t fmCtl2DispTh; /**< This is the number pf packets that may be
63770 + queued in fmCtl2 dispatch queue*/
63771 +} t_FmThresholds;
63772 +
63773 +/**************************************************************************//*
63774 + @Description structure for defining DMA thresholds
63775 +*//***************************************************************************/
63776 +typedef struct t_FmDmaThresholds {
63777 + uint8_t assertEmergency; /**< When this value is reached,
63778 + assert emergency (Threshold)*/
63779 + uint8_t clearEmergency; /**< After emergency is asserted, it is held
63780 + until this value is reached (Hystheresis) */
63781 +} t_FmDmaThresholds;
63782 +
63783 +
63784 +/**************************************************************************//**
63785 + @Function FM_ConfigResetOnInit
63786 +
63787 + @Description Define whether to reset the FM before initialization.
63788 + Change the default configuration [DEFAULT_resetOnInit].
63789 +
63790 + @Param[in] h_Fm A handle to an FM Module.
63791 + @Param[in] enable When TRUE, FM will be reset before any initialization.
63792 +
63793 + @Return E_OK on success; Error code otherwise.
63794 +
63795 + @Cautions Allowed only following FM_Config() and before FM_Init().
63796 + This routine should NOT be called from guest-partition
63797 + (i.e. guestId != NCSW_MASTER_ID)
63798 +*//***************************************************************************/
63799 +t_Error FM_ConfigResetOnInit(t_Handle h_Fm, bool enable);
63800 +
63801 +/**************************************************************************//**
63802 + @Function FM_ConfigTotalFifoSize
63803 +
63804 + @Description Define Total FIFO size for the whole FM.
63805 + Calling this routine changes the total Fifo size in the internal driver
63806 + data base from its default configuration [DEFAULT_totalFifoSize]
63807 +
63808 + @Param[in] h_Fm A handle to an FM Module.
63809 + @Param[in] totalFifoSize The selected new value.
63810 +
63811 + @Return E_OK on success; Error code otherwise.
63812 +
63813 + @Cautions Allowed only following FM_Config() and before FM_Init().
63814 + This routine should NOT be called from guest-partition
63815 + (i.e. guestId != NCSW_MASTER_ID)
63816 +*//***************************************************************************/
63817 +t_Error FM_ConfigTotalFifoSize(t_Handle h_Fm, uint32_t totalFifoSize);
63818 +
63819 + /**************************************************************************//**
63820 + @Function FM_ConfigDmaCacheOverride
63821 +
63822 + @Description Define cache override mode.
63823 + Calling this routine changes the cache override mode
63824 + in the internal driver data base from its default configuration [DEFAULT_cacheOverride]
63825 +
63826 + @Param[in] h_Fm A handle to an FM Module.
63827 + @Param[in] cacheOverride The selected new value.
63828 +
63829 + @Return E_OK on success; Error code otherwise.
63830 +
63831 + @Cautions Allowed only following FM_Config() and before FM_Init().
63832 + This routine should NOT be called from guest-partition
63833 + (i.e. guestId != NCSW_MASTER_ID)
63834 +*//***************************************************************************/
63835 +t_Error FM_ConfigDmaCacheOverride(t_Handle h_Fm, e_FmDmaCacheOverride cacheOverride);
63836 +
63837 +/**************************************************************************//**
63838 + @Function FM_ConfigDmaAidOverride
63839 +
63840 + @Description Define DMA AID override mode.
63841 + Calling this routine changes the AID override mode
63842 + in the internal driver data base from its default configuration [DEFAULT_aidOverride]
63843 +
63844 + @Param[in] h_Fm A handle to an FM Module.
63845 + @Param[in] aidOverride The selected new value.
63846 +
63847 + @Return E_OK on success; Error code otherwise.
63848 +
63849 + @Cautions Allowed only following FM_Config() and before FM_Init().
63850 + This routine should NOT be called from guest-partition
63851 + (i.e. guestId != NCSW_MASTER_ID)
63852 +*//***************************************************************************/
63853 +t_Error FM_ConfigDmaAidOverride(t_Handle h_Fm, bool aidOverride);
63854 +
63855 +/**************************************************************************//**
63856 + @Function FM_ConfigDmaAidMode
63857 +
63858 + @Description Define DMA AID mode.
63859 + Calling this routine changes the AID mode in the internal
63860 + driver data base from its default configuration [DEFAULT_aidMode]
63861 +
63862 + @Param[in] h_Fm A handle to an FM Module.
63863 + @Param[in] aidMode The selected new value.
63864 +
63865 + @Return E_OK on success; Error code otherwise.
63866 +
63867 + @Cautions Allowed only following FM_Config() and before FM_Init().
63868 + This routine should NOT be called from guest-partition
63869 + (i.e. guestId != NCSW_MASTER_ID)
63870 +*//***************************************************************************/
63871 +t_Error FM_ConfigDmaAidMode(t_Handle h_Fm, e_FmDmaAidMode aidMode);
63872 +
63873 +/**************************************************************************//**
63874 + @Function FM_ConfigDmaAxiDbgNumOfBeats
63875 +
63876 + @Description Define DMA AXI number of beats.
63877 + Calling this routine changes the AXI number of beats in the internal
63878 + driver data base from its default configuration [DEFAULT_axiDbgNumOfBeats]
63879 +
63880 + @Param[in] h_Fm A handle to an FM Module.
63881 + @Param[in] axiDbgNumOfBeats The selected new value.
63882 +
63883 + @Return E_OK on success; Error code otherwise.
63884 +
63885 + @Cautions Allowed only following FM_Config() and before FM_Init().
63886 + This routine should NOT be called from guest-partition
63887 + (i.e. guestId != NCSW_MASTER_ID)
63888 +*//***************************************************************************/
63889 +t_Error FM_ConfigDmaAxiDbgNumOfBeats(t_Handle h_Fm, uint8_t axiDbgNumOfBeats);
63890 +
63891 +/**************************************************************************//**
63892 + @Function FM_ConfigDmaCamNumOfEntries
63893 +
63894 + @Description Define number of CAM entries.
63895 + Calling this routine changes the number of CAM entries in the internal
63896 + driver data base from its default configuration [DEFAULT_dmaCamNumOfEntries].
63897 +
63898 + @Param[in] h_Fm A handle to an FM Module.
63899 + @Param[in] numOfEntries The selected new value.
63900 +
63901 + @Return E_OK on success; Error code otherwise.
63902 +
63903 + @Cautions Allowed only following FM_Config() and before FM_Init().
63904 + This routine should NOT be called from guest-partition
63905 + (i.e. guestId != NCSW_MASTER_ID)
63906 +*//***************************************************************************/
63907 +t_Error FM_ConfigDmaCamNumOfEntries(t_Handle h_Fm, uint8_t numOfEntries);
63908 +
63909 +/**************************************************************************//**
63910 + @Function FM_ConfigEnableCounters
63911 +
63912 + @Description Obsolete, always return E_OK.
63913 +
63914 + @Param[in] h_Fm A handle to an FM Module.
63915 +
63916 + @Return E_OK on success; Error code otherwise.
63917 +*//***************************************************************************/
63918 +t_Error FM_ConfigEnableCounters(t_Handle h_Fm);
63919 +
63920 +/**************************************************************************//**
63921 + @Function FM_ConfigDmaDbgCounter
63922 +
63923 + @Description Define DMA debug counter.
63924 + Calling this routine changes the number of the DMA debug counter in the internal
63925 + driver data base from its default configuration [DEFAULT_dmaDbgCntMode].
63926 +
63927 + @Param[in] h_Fm A handle to an FM Module.
63928 + @Param[in] fmDmaDbgCntMode An enum selecting the debug counter mode.
63929 +
63930 + @Return E_OK on success; Error code otherwise.
63931 +
63932 + @Cautions Allowed only following FM_Config() and before FM_Init().
63933 + This routine should NOT be called from guest-partition
63934 + (i.e. guestId != NCSW_MASTER_ID)
63935 +*//***************************************************************************/
63936 +t_Error FM_ConfigDmaDbgCounter(t_Handle h_Fm, e_FmDmaDbgCntMode fmDmaDbgCntMode);
63937 +
63938 +/**************************************************************************//**
63939 + @Function FM_ConfigDmaStopOnBusErr
63940 +
63941 + @Description Define bus error behavior.
63942 + Calling this routine changes the bus error behavior definition
63943 + in the internal driver data base from its default
63944 + configuration [DEFAULT_dmaStopOnBusError].
63945 +
63946 + @Param[in] h_Fm A handle to an FM Module.
63947 + @Param[in] stop TRUE to stop on bus error, FALSE to continue.
63948 +
63949 + @Return E_OK on success; Error code otherwise.
63950 +
63951 + @Cautions Allowed only following FM_Config() and before FM_Init().
63952 + Only if bus error is enabled.
63953 + This routine should NOT be called from guest-partition
63954 + (i.e. guestId != NCSW_MASTER_ID)
63955 +*//***************************************************************************/
63956 +t_Error FM_ConfigDmaStopOnBusErr(t_Handle h_Fm, bool stop);
63957 +
63958 +/**************************************************************************//**
63959 + @Function FM_ConfigDmaEmergency
63960 +
63961 + @Description Define DMA emergency.
63962 + Calling this routine changes the DMA emergency definition
63963 + in the internal driver data base from its default
63964 + configuration where's it's disabled.
63965 +
63966 + @Param[in] h_Fm A handle to an FM Module.
63967 + @Param[in] p_Emergency An OR mask of all required options.
63968 +
63969 + @Return E_OK on success; Error code otherwise.
63970 +
63971 + @Cautions Allowed only following FM_Config() and before FM_Init().
63972 + This routine should NOT be called from guest-partition
63973 + (i.e. guestId != NCSW_MASTER_ID)
63974 +*//***************************************************************************/
63975 +t_Error FM_ConfigDmaEmergency(t_Handle h_Fm, t_FmDmaEmergency *p_Emergency);
63976 +
63977 +/**************************************************************************//**
63978 + @Function FM_ConfigDmaErr
63979 +
63980 + @Description DMA error treatment.
63981 + Calling this routine changes the DMA error treatment
63982 + in the internal driver data base from its default
63983 + configuration [DEFAULT_dmaErr].
63984 +
63985 + @Param[in] h_Fm A handle to an FM Module.
63986 + @Param[in] dmaErr The selected new choice.
63987 +
63988 + @Return E_OK on success; Error code otherwise.
63989 +
63990 + @Cautions Allowed only following FM_Config() and before FM_Init().
63991 + This routine should NOT be called from guest-partition
63992 + (i.e. guestId != NCSW_MASTER_ID)
63993 +*//***************************************************************************/
63994 +t_Error FM_ConfigDmaErr(t_Handle h_Fm, e_FmDmaErr dmaErr);
63995 +
63996 +/**************************************************************************//**
63997 + @Function FM_ConfigCatastrophicErr
63998 +
63999 + @Description Define FM behavior on catastrophic error.
64000 + Calling this routine changes the FM behavior on catastrophic
64001 + error in the internal driver data base from its default
64002 + [DEFAULT_catastrophicErr].
64003 +
64004 + @Param[in] h_Fm A handle to an FM Module.
64005 + @Param[in] catastrophicErr The selected new choice.
64006 +
64007 + @Return E_OK on success; Error code otherwise.
64008 +
64009 + @Cautions Allowed only following FM_Config() and before FM_Init().
64010 + This routine should NOT be called from guest-partition
64011 + (i.e. guestId != NCSW_MASTER_ID)
64012 +*//***************************************************************************/
64013 +t_Error FM_ConfigCatastrophicErr(t_Handle h_Fm, e_FmCatastrophicErr catastrophicErr);
64014 +
64015 +/**************************************************************************//**
64016 + @Function FM_ConfigEnableMuramTestMode
64017 +
64018 + @Description Enable MURAM test mode.
64019 + Calling this routine changes the internal driver data base
64020 + from its default selection of test mode where it's disabled.
64021 + This routine is only avaiable on old FM revisions (FMan v2).
64022 +
64023 + @Param[in] h_Fm A handle to an FM Module.
64024 +
64025 + @Return E_OK on success; Error code otherwise.
64026 +
64027 + @Cautions Allowed only following FM_Config() and before FM_Init().
64028 + This routine should NOT be called from guest-partition
64029 + (i.e. guestId != NCSW_MASTER_ID)
64030 +*//***************************************************************************/
64031 +t_Error FM_ConfigEnableMuramTestMode(t_Handle h_Fm);
64032 +
64033 +/**************************************************************************//**
64034 + @Function FM_ConfigEnableIramTestMode
64035 +
64036 + @Description Enable IRAM test mode.
64037 + Calling this routine changes the internal driver data base
64038 + from its default selection of test mode where it's disabled.
64039 + This routine is only avaiable on old FM revisions (FMan v2).
64040 +
64041 + @Param[in] h_Fm A handle to an FM Module.
64042 +
64043 + @Return E_OK on success; Error code otherwise.
64044 +
64045 + @Cautions Allowed only following FM_Config() and before FM_Init().
64046 + This routine should NOT be called from guest-partition
64047 + (i.e. guestId != NCSW_MASTER_ID)
64048 +*//***************************************************************************/
64049 +t_Error FM_ConfigEnableIramTestMode(t_Handle h_Fm);
64050 +
64051 +/**************************************************************************//**
64052 + @Function FM_ConfigHaltOnExternalActivation
64053 +
64054 + @Description Define FM behavior on external halt activation.
64055 + Calling this routine changes the FM behavior on external halt
64056 + activation in the internal driver data base from its default
64057 + [DEFAULT_haltOnExternalActivation].
64058 +
64059 + @Param[in] h_Fm A handle to an FM Module.
64060 + @Param[in] enable TRUE to enable halt on external halt
64061 + activation.
64062 +
64063 + @Return E_OK on success; Error code otherwise.
64064 +
64065 + @Cautions Allowed only following FM_Config() and before FM_Init().
64066 + This routine should NOT be called from guest-partition
64067 + (i.e. guestId != NCSW_MASTER_ID)
64068 +*//***************************************************************************/
64069 +t_Error FM_ConfigHaltOnExternalActivation(t_Handle h_Fm, bool enable);
64070 +
64071 +/**************************************************************************//**
64072 + @Function FM_ConfigHaltOnUnrecoverableEccError
64073 +
64074 + @Description Define FM behavior on external halt activation.
64075 + Calling this routine changes the FM behavior on unrecoverable
64076 + ECC error in the internal driver data base from its default
64077 + [DEFAULT_haltOnUnrecoverableEccError].
64078 + This routine is only avaiable on old FM revisions (FMan v2).
64079 +
64080 + @Param[in] h_Fm A handle to an FM Module.
64081 + @Param[in] enable TRUE to enable halt on unrecoverable Ecc error
64082 +
64083 + @Return E_OK on success; Error code otherwise.
64084 +
64085 + @Cautions Allowed only following FM_Config() and before FM_Init().
64086 + This routine should NOT be called from guest-partition
64087 + (i.e. guestId != NCSW_MASTER_ID)
64088 +*//***************************************************************************/
64089 +t_Error FM_ConfigHaltOnUnrecoverableEccError(t_Handle h_Fm, bool enable);
64090 +
64091 +/**************************************************************************//**
64092 + @Function FM_ConfigException
64093 +
64094 + @Description Define FM exceptions.
64095 + Calling this routine changes the exceptions defaults in the
64096 + internal driver data base where all exceptions are enabled.
64097 +
64098 + @Param[in] h_Fm A handle to an FM Module.
64099 + @Param[in] exception The exception to be selected.
64100 + @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
64101 +
64102 + @Return E_OK on success; Error code otherwise.
64103 +
64104 + @Cautions Allowed only following FM_Config() and before FM_Init().
64105 + This routine should NOT be called from guest-partition
64106 + (i.e. guestId != NCSW_MASTER_ID)
64107 +*//***************************************************************************/
64108 +t_Error FM_ConfigException(t_Handle h_Fm, e_FmExceptions exception, bool enable);
64109 +
64110 +/**************************************************************************//**
64111 + @Function FM_ConfigExternalEccRamsEnable
64112 +
64113 + @Description Select external ECC enabling.
64114 + Calling this routine changes the ECC enabling control in the internal
64115 + driver data base from its default [DEFAULT_externalEccRamsEnable].
64116 + When this option is enabled Rams ECC enabling is not effected
64117 + by FM_EnableRamsEcc/FM_DisableRamsEcc, but by a JTAG.
64118 +
64119 + @Param[in] h_Fm A handle to an FM Module.
64120 + @Param[in] enable TRUE to enable this option.
64121 +
64122 + @Return E_OK on success; Error code otherwise.
64123 +
64124 + @Cautions Allowed only following FM_Config() and before FM_Init().
64125 + This routine should NOT be called from guest-partition
64126 + (i.e. guestId != NCSW_MASTER_ID)
64127 +*//***************************************************************************/
64128 +t_Error FM_ConfigExternalEccRamsEnable(t_Handle h_Fm, bool enable);
64129 +
64130 +/**************************************************************************//**
64131 + @Function FM_ConfigTnumAgingPeriod
64132 +
64133 + @Description Define Tnum aging period.
64134 + Calling this routine changes the Tnum aging of dequeue TNUMs
64135 + in the QMI in the internal driver data base from its default
64136 + [DEFAULT_tnumAgingPeriod].
64137 +
64138 + @Param[in] h_Fm A handle to an FM Module.
64139 + @Param[in] tnumAgingPeriod Tnum Aging Period in microseconds.
64140 + Note that period is recalculated in units of
64141 + 64 FM clocks. Driver will pick the closest
64142 + possible period.
64143 +
64144 + @Return E_OK on success; Error code otherwise.
64145 +
64146 + @Cautions Allowed only following FM_Config() and before FM_Init().
64147 + This routine should NOT be called from guest-partition
64148 + (i.e. guestId != NCSW_MASTER_ID)
64149 + NOTE that if some MAC is configured for PFC, '0' value is NOT
64150 + allowed.
64151 +*//***************************************************************************/
64152 +t_Error FM_ConfigTnumAgingPeriod(t_Handle h_Fm, uint16_t tnumAgingPeriod);
64153 +
64154 +/**************************************************************************//*
64155 + @Function FM_ConfigDmaEmergencySmoother
64156 +
64157 + @Description Define DMA emergency smoother.
64158 + Calling this routine changes the definition of the minimum
64159 + amount of DATA beats transferred on the AXI READ and WRITE
64160 + ports before lowering the emergency level.
64161 + By default smoother is disabled.
64162 +
64163 + @Param[in] h_Fm A handle to an FM Module.
64164 + @Param[in] emergencyCnt emergency switching counter.
64165 +
64166 + @Return E_OK on success; Error code otherwise.
64167 +
64168 + @Cautions Allowed only following FM_Config() and before FM_Init().
64169 + This routine should NOT be called from guest-partition
64170 + (i.e. guestId != NCSW_MASTER_ID)
64171 +*//***************************************************************************/
64172 +t_Error FM_ConfigDmaEmergencySmoother(t_Handle h_Fm, uint32_t emergencyCnt);
64173 +
64174 +/**************************************************************************//*
64175 + @Function FM_ConfigThresholds
64176 +
64177 + @Description Calling this routine changes the internal driver data base
64178 + from its default FM threshold configuration:
64179 + dispLimit: [DEFAULT_dispLimit]
64180 + prsDispTh: [DEFAULT_prsDispTh]
64181 + plcrDispTh: [DEFAULT_plcrDispTh]
64182 + kgDispTh: [DEFAULT_kgDispTh]
64183 + bmiDispTh: [DEFAULT_bmiDispTh]
64184 + qmiEnqDispTh: [DEFAULT_qmiEnqDispTh]
64185 + qmiDeqDispTh: [DEFAULT_qmiDeqDispTh]
64186 + fmCtl1DispTh: [DEFAULT_fmCtl1DispTh]
64187 + fmCtl2DispTh: [DEFAULT_fmCtl2DispTh]
64188 +
64189 +
64190 + @Param[in] h_Fm A handle to an FM Module.
64191 + @Param[in] p_FmThresholds A structure of threshold parameters.
64192 +
64193 + @Return E_OK on success; Error code otherwise.
64194 +
64195 + @Cautions Allowed only following FM_Config() and before FM_Init().
64196 + This routine should NOT be called from guest-partition
64197 + (i.e. guestId != NCSW_MASTER_ID)
64198 +*//***************************************************************************/
64199 +t_Error FM_ConfigThresholds(t_Handle h_Fm, t_FmThresholds *p_FmThresholds);
64200 +
64201 +/**************************************************************************//*
64202 + @Function FM_ConfigDmaSosEmergencyThreshold
64203 +
64204 + @Description Calling this routine changes the internal driver data base
64205 + from its default dma SOS emergency configuration [DEFAULT_dmaSosEmergency]
64206 +
64207 + @Param[in] h_Fm A handle to an FM Module.
64208 + @Param[in] dmaSosEmergency The selected new value.
64209 +
64210 + @Return E_OK on success; Error code otherwise.
64211 +
64212 + @Cautions Allowed only following FM_Config() and before FM_Init().
64213 + This routine should NOT be called from guest-partition
64214 + (i.e. guestId != NCSW_MASTER_ID)
64215 +*//***************************************************************************/
64216 +t_Error FM_ConfigDmaSosEmergencyThreshold(t_Handle h_Fm, uint32_t dmaSosEmergency);
64217 +
64218 +/**************************************************************************//*
64219 + @Function FM_ConfigDmaWriteBufThresholds
64220 +
64221 + @Description Calling this routine changes the internal driver data base
64222 + from its default configuration of DMA write buffer threshold
64223 + assertEmergency: [DEFAULT_dmaWriteIntBufLow]
64224 + clearEmergency: [DEFAULT_dmaWriteIntBufHigh]
64225 + This routine is only avaiable on old FM revisions (FMan v2).
64226 +
64227 + @Param[in] h_Fm A handle to an FM Module.
64228 + @Param[in] p_FmDmaThresholds A structure of thresholds to define emergency behavior -
64229 + When 'assertEmergency' value is reached, emergency is asserted,
64230 + then it is held until 'clearEmergency' value is reached.
64231 +
64232 + @Return E_OK on success; Error code otherwise.
64233 +
64234 + @Cautions Allowed only following FM_Config() and before FM_Init().
64235 + This routine should NOT be called from guest-partition
64236 + (i.e. guestId != NCSW_MASTER_ID)
64237 +*//***************************************************************************/
64238 +t_Error FM_ConfigDmaWriteBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);
64239 +
64240 + /**************************************************************************//*
64241 + @Function FM_ConfigDmaCommQThresholds
64242 +
64243 + @Description Calling this routine changes the internal driver data base
64244 + from its default configuration of DMA command queue threshold
64245 + assertEmergency: [DEFAULT_dmaCommQLow]
64246 + clearEmergency: [DEFAULT_dmaCommQHigh]
64247 +
64248 + @Param[in] h_Fm A handle to an FM Module.
64249 + @Param[in] p_FmDmaThresholds A structure of thresholds to define emergency behavior -
64250 + When 'assertEmergency' value is reached, emergency is asserted,
64251 + then it is held until 'clearEmergency' value is reached..
64252 +
64253 + @Return E_OK on success; Error code otherwise.
64254 +
64255 + @Cautions Allowed only following FM_Config() and before FM_Init().
64256 + This routine should NOT be called from guest-partition
64257 + (i.e. guestId != NCSW_MASTER_ID)
64258 +*//***************************************************************************/
64259 +t_Error FM_ConfigDmaCommQThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);
64260 +
64261 +/**************************************************************************//*
64262 + @Function FM_ConfigDmaReadBufThresholds
64263 +
64264 + @Description Calling this routine changes the internal driver data base
64265 + from its default configuration of DMA read buffer threshold
64266 + assertEmergency: [DEFAULT_dmaReadIntBufLow]
64267 + clearEmergency: [DEFAULT_dmaReadIntBufHigh]
64268 + This routine is only avaiable on old FM revisions (FMan v2).
64269 +
64270 + @Param[in] h_Fm A handle to an FM Module.
64271 + @Param[in] p_FmDmaThresholds A structure of thresholds to define emergency behavior -
64272 + When 'assertEmergency' value is reached, emergency is asserted,
64273 + then it is held until 'clearEmergency' value is reached..
64274 +
64275 + @Return E_OK on success; Error code otherwise.
64276 +
64277 + @Cautions Allowed only following FM_Config() and before FM_Init().
64278 + This routine should NOT be called from guest-partition
64279 + (i.e. guestId != NCSW_MASTER_ID)
64280 +*//***************************************************************************/
64281 +t_Error FM_ConfigDmaReadBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);
64282 +
64283 +/**************************************************************************//*
64284 + @Function FM_ConfigDmaWatchdog
64285 +
64286 + @Description Calling this routine changes the internal driver data base
64287 + from its default watchdog configuration, which is disabled
64288 + [DEFAULT_dmaWatchdog].
64289 +
64290 + @Param[in] h_Fm A handle to an FM Module.
64291 + @Param[in] watchDogValue The selected new value - in microseconds.
64292 +
64293 + @Return E_OK on success; Error code otherwise.
64294 +
64295 + @Cautions Allowed only following FM_Config() and before FM_Init().
64296 + This routine should NOT be called from guest-partition
64297 + (i.e. guestId != NCSW_MASTER_ID)
64298 +*//***************************************************************************/
64299 +t_Error FM_ConfigDmaWatchdog(t_Handle h_Fm, uint32_t watchDogValue);
64300 +
64301 +/** @} */ /* end of FM_advanced_init_grp group */
64302 +/** @} */ /* end of FM_init_grp group */
64303 +
64304 +
64305 +/**************************************************************************//**
64306 + @Group FM_runtime_control_grp FM Runtime Control Unit
64307 +
64308 + @Description FM Runtime control unit API functions, definitions and enums.
64309 + The FM driver provides a set of control routines.
64310 + These routines may only be called after the module was fully
64311 + initialized (both configuration and initialization routines were
64312 + called). They are typically used to get information from hardware
64313 + (status, counters/statistics, revision etc.), to modify a current
64314 + state or to force/enable a required action. Run-time control may
64315 + be called whenever necessary and as many times as needed.
64316 + @{
64317 +*//***************************************************************************/
64318 +
64319 +/**************************************************************************//**
64320 + @Collection General FM defines.
64321 +*//***************************************************************************/
64322 +#define FM_MAX_NUM_OF_VALID_PORTS (FM_MAX_NUM_OF_OH_PORTS + \
64323 + FM_MAX_NUM_OF_1G_RX_PORTS + \
64324 + FM_MAX_NUM_OF_10G_RX_PORTS + \
64325 + FM_MAX_NUM_OF_1G_TX_PORTS + \
64326 + FM_MAX_NUM_OF_10G_TX_PORTS) /**< Number of available FM ports */
64327 +/* @} */
64328 +
64329 +/**************************************************************************//*
64330 + @Description A Structure for Port bandwidth requirement. Port is identified
64331 + by type and relative id.
64332 +*//***************************************************************************/
64333 +typedef struct t_FmPortBandwidth {
64334 + e_FmPortType type; /**< FM port type */
64335 + uint8_t relativePortId; /**< Type relative port id */
64336 + uint8_t bandwidth; /**< bandwidth - (in term of percents) */
64337 +} t_FmPortBandwidth;
64338 +
64339 +/**************************************************************************//*
64340 + @Description A Structure containing an array of Port bandwidth requirements.
64341 + The user should state the ports requiring bandwidth in terms of
64342 + percentage - i.e. all port's bandwidths in the array must add
64343 + up to 100.
64344 +*//***************************************************************************/
64345 +typedef struct t_FmPortsBandwidthParams {
64346 + uint8_t numOfPorts; /**< The number of relevant ports, which is the
64347 + number of valid entries in the array below */
64348 + t_FmPortBandwidth portsBandwidths[FM_MAX_NUM_OF_VALID_PORTS];
64349 + /**< for each port, it's bandwidth (all port's
64350 + bandwidths must add up to 100.*/
64351 +} t_FmPortsBandwidthParams;
64352 +
64353 +/**************************************************************************//**
64354 + @Description DMA Emergency control on MURAM
64355 +*//***************************************************************************/
64356 +typedef enum e_FmDmaMuramPort {
64357 + e_FM_DMA_MURAM_PORT_WRITE, /**< MURAM write port */
64358 + e_FM_DMA_MURAM_PORT_READ /**< MURAM read port */
64359 +} e_FmDmaMuramPort;
64360 +
64361 +/**************************************************************************//**
64362 + @Description Enum for defining FM counters
64363 +*//***************************************************************************/
64364 +typedef enum e_FmCounters {
64365 + e_FM_COUNTERS_ENQ_TOTAL_FRAME = 0, /**< QMI total enqueued frames counter */
64366 + e_FM_COUNTERS_DEQ_TOTAL_FRAME, /**< QMI total dequeued frames counter */
64367 + e_FM_COUNTERS_DEQ_0, /**< QMI 0 frames from QMan counter */
64368 + e_FM_COUNTERS_DEQ_1, /**< QMI 1 frames from QMan counter */
64369 + e_FM_COUNTERS_DEQ_2, /**< QMI 2 frames from QMan counter */
64370 + e_FM_COUNTERS_DEQ_3, /**< QMI 3 frames from QMan counter */
64371 + e_FM_COUNTERS_DEQ_FROM_DEFAULT, /**< QMI dequeue from default queue counter */
64372 + e_FM_COUNTERS_DEQ_FROM_CONTEXT, /**< QMI dequeue from FQ context counter */
64373 + e_FM_COUNTERS_DEQ_FROM_FD, /**< QMI dequeue from FD command field counter */
64374 + e_FM_COUNTERS_DEQ_CONFIRM /**< QMI dequeue confirm counter */
64375 +} e_FmCounters;
64376 +
64377 +/**************************************************************************//**
64378 + @Description A Structure for returning FM revision information
64379 +*//***************************************************************************/
64380 +typedef struct t_FmRevisionInfo {
64381 + uint8_t majorRev; /**< Major revision */
64382 + uint8_t minorRev; /**< Minor revision */
64383 +} t_FmRevisionInfo;
64384 +
64385 +/**************************************************************************//**
64386 + @Description A Structure for returning FM ctrl code revision information
64387 +*//***************************************************************************/
64388 +typedef struct t_FmCtrlCodeRevisionInfo {
64389 + uint16_t packageRev; /**< Package revision */
64390 + uint8_t majorRev; /**< Major revision */
64391 + uint8_t minorRev; /**< Minor revision */
64392 +} t_FmCtrlCodeRevisionInfo;
64393 +
64394 +/**************************************************************************//**
64395 + @Description A Structure for defining DMA status
64396 +*//***************************************************************************/
64397 +typedef struct t_FmDmaStatus {
64398 + bool cmqNotEmpty; /**< Command queue is not empty */
64399 + bool busError; /**< Bus error occurred */
64400 + bool readBufEccError; /**< Double ECC error on buffer Read (Valid for FM rev < 6)*/
64401 + bool writeBufEccSysError; /**< Double ECC error on buffer write from system side (Valid for FM rev < 6)*/
64402 + bool writeBufEccFmError; /**< Double ECC error on buffer write from FM side (Valid for FM rev < 6) */
64403 + bool singlePortEccError; /**< Single Port ECC error from FM side (Valid for FM rev >= 6)*/
64404 +} t_FmDmaStatus;
64405 +
64406 +/**************************************************************************//**
64407 + @Description A Structure for obtaining FM controller monitor values
64408 +*//***************************************************************************/
64409 +typedef struct t_FmCtrlMon {
64410 + uint8_t percentCnt[2]; /**< Percentage value */
64411 +} t_FmCtrlMon;
64412 +
64413 +
64414 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
64415 +/**************************************************************************//**
64416 + @Function FM_DumpRegs
64417 +
64418 + @Description Dumps all FM registers
64419 +
64420 + @Param[in] h_Fm A handle to an FM Module.
64421 +
64422 + @Return E_OK on success;
64423 +
64424 + @Cautions Allowed only following FM_Init().
64425 +*//***************************************************************************/
64426 +t_Error FM_DumpRegs(t_Handle h_Fm);
64427 +#endif /* (defined(DEBUG_ERRORS) && ... */
64428 +
64429 +/**************************************************************************//**
64430 + @Function FM_SetException
64431 +
64432 + @Description Calling this routine enables/disables the specified exception.
64433 +
64434 + @Param[in] h_Fm A handle to an FM Module.
64435 + @Param[in] exception The exception to be selected.
64436 + @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
64437 +
64438 + @Return E_OK on success; Error code otherwise.
64439 +
64440 + @Cautions Allowed only following FM_Init().
64441 + This routine should NOT be called from guest-partition
64442 + (i.e. guestId != NCSW_MASTER_ID)
64443 +*//***************************************************************************/
64444 +t_Error FM_SetException(t_Handle h_Fm, e_FmExceptions exception, bool enable);
64445 +
64446 +/**************************************************************************//**
64447 + @Function FM_EnableRamsEcc
64448 +
64449 + @Description Enables ECC mechanism for all the different FM RAM's; E.g. IRAM,
64450 + MURAM, Parser, Keygen, Policer, etc.
64451 + Note:
64452 + If FM_ConfigExternalEccRamsEnable was called to enable external
64453 + setting of ECC, this routine effects IRAM ECC only.
64454 + This routine is also called by the driver if an ECC exception is
64455 + enabled.
64456 +
64457 + @Param[in] h_Fm A handle to an FM Module.
64458 +
64459 + @Return E_OK on success; Error code otherwise.
64460 +
64461 + @Cautions Allowed only following FM_Config() and before FM_Init().
64462 + This routine should NOT be called from guest-partition
64463 + (i.e. guestId != NCSW_MASTER_ID)
64464 +*//***************************************************************************/
64465 +t_Error FM_EnableRamsEcc(t_Handle h_Fm);
64466 +
64467 +/**************************************************************************//**
64468 + @Function FM_DisableRamsEcc
64469 +
64470 + @Description Disables ECC mechanism for all the different FM RAM's; E.g. IRAM,
64471 + MURAM, Parser, Keygen, Policer, etc.
64472 + Note:
64473 + If FM_ConfigExternalEccRamsEnable was called to enable external
64474 + setting of ECC, this routine effects IRAM ECC only.
64475 + In opposed to FM_EnableRamsEcc, this routine must be called
64476 + explicitly to disable all Rams ECC.
64477 +
64478 + @Param[in] h_Fm A handle to an FM Module.
64479 +
64480 + @Return E_OK on success; Error code otherwise.
64481 +
64482 + @Cautions Allowed only following FM_Config() and before FM_Init().
64483 + This routine should NOT be called from guest-partition
64484 + (i.e. guestId != NCSW_MASTER_ID)
64485 +*//***************************************************************************/
64486 +t_Error FM_DisableRamsEcc(t_Handle h_Fm);
64487 +
64488 +/**************************************************************************//**
64489 + @Function FM_GetRevision
64490 +
64491 + @Description Returns the FM revision
64492 +
64493 + @Param[in] h_Fm A handle to an FM Module.
64494 + @Param[out] p_FmRevisionInfo A structure of revision information parameters.
64495 +
64496 + @Return E_OK on success; Error code otherwise.
64497 +
64498 + @Cautions Allowed only following FM_Init().
64499 +*//***************************************************************************/
64500 +t_Error FM_GetRevision(t_Handle h_Fm, t_FmRevisionInfo *p_FmRevisionInfo);
64501 +
64502 +/**************************************************************************//**
64503 + @Function FM_GetFmanCtrlCodeRevision
64504 +
64505 + @Description Returns the Fman controller code revision
64506 +
64507 + @Param[in] h_Fm A handle to an FM Module.
64508 + @Param[out] p_RevisionInfo A structure of revision information parameters.
64509 +
64510 + @Return E_OK on success; Error code otherwise.
64511 +
64512 + @Cautions Allowed only following FM_Init().
64513 +*//***************************************************************************/
64514 +t_Error FM_GetFmanCtrlCodeRevision(t_Handle h_Fm, t_FmCtrlCodeRevisionInfo *p_RevisionInfo);
64515 +
64516 +/**************************************************************************//**
64517 + @Function FM_GetCounter
64518 +
64519 + @Description Reads one of the FM counters.
64520 +
64521 + @Param[in] h_Fm A handle to an FM Module.
64522 + @Param[in] counter The requested counter.
64523 +
64524 + @Return Counter's current value.
64525 +
64526 + @Cautions Allowed only following FM_Init().
64527 + Note that it is user's responsibility to call this routine only
64528 + for enabled counters, and there will be no indication if a
64529 + disabled counter is accessed.
64530 +*//***************************************************************************/
64531 +uint32_t FM_GetCounter(t_Handle h_Fm, e_FmCounters counter);
64532 +
64533 +/**************************************************************************//**
64534 + @Function FM_ModifyCounter
64535 +
64536 + @Description Sets a value to an enabled counter. Use "0" to reset the counter.
64537 +
64538 + @Param[in] h_Fm A handle to an FM Module.
64539 + @Param[in] counter The requested counter.
64540 + @Param[in] val The requested value to be written into the counter.
64541 +
64542 + @Return E_OK on success; Error code otherwise.
64543 +
64544 + @Cautions Allowed only following FM_Init().
64545 + This routine should NOT be called from guest-partition
64546 + (i.e. guestId != NCSW_MASTER_ID)
64547 +*//***************************************************************************/
64548 +t_Error FM_ModifyCounter(t_Handle h_Fm, e_FmCounters counter, uint32_t val);
64549 +
64550 +/**************************************************************************//**
64551 + @Function FM_Resume
64552 +
64553 + @Description Release FM after halt FM command or after unrecoverable ECC error.
64554 +
64555 + @Param[in] h_Fm A handle to an FM Module.
64556 +
64557 + @Return E_OK on success; Error code otherwise.
64558 +
64559 + @Cautions Allowed only following FM_Init().
64560 + This routine should NOT be called from guest-partition
64561 + (i.e. guestId != NCSW_MASTER_ID)
64562 +*//***************************************************************************/
64563 +void FM_Resume(t_Handle h_Fm);
64564 +
64565 +/**************************************************************************//**
64566 + @Function FM_SetDmaEmergency
64567 +
64568 + @Description Manual emergency set
64569 +
64570 + @Param[in] h_Fm A handle to an FM Module.
64571 + @Param[in] muramPort MURAM direction select.
64572 + @Param[in] enable TRUE to manually enable emergency, FALSE to disable.
64573 +
64574 + @Return None.
64575 +
64576 + @Cautions Allowed only following FM_Init().
64577 + This routine should NOT be called from guest-partition
64578 + (i.e. guestId != NCSW_MASTER_ID)
64579 +*//***************************************************************************/
64580 +void FM_SetDmaEmergency(t_Handle h_Fm, e_FmDmaMuramPort muramPort, bool enable);
64581 +
64582 +/**************************************************************************//**
64583 + @Function FM_SetDmaExtBusPri
64584 +
64585 + @Description Set the DMA external bus priority
64586 +
64587 + @Param[in] h_Fm A handle to an FM Module.
64588 + @Param[in] pri External bus priority select
64589 +
64590 + @Return None.
64591 +
64592 + @Cautions Allowed only following FM_Init().
64593 + This routine should NOT be called from guest-partition
64594 + (i.e. guestId != NCSW_MASTER_ID)
64595 +*//***************************************************************************/
64596 +void FM_SetDmaExtBusPri(t_Handle h_Fm, e_FmDmaExtBusPri pri);
64597 +
64598 +/**************************************************************************//**
64599 + @Function FM_GetDmaStatus
64600 +
64601 + @Description Reads the DMA current status
64602 +
64603 + @Param[in] h_Fm A handle to an FM Module.
64604 + @Param[out] p_FmDmaStatus A structure of DMA status parameters.
64605 +
64606 + @Cautions Allowed only following FM_Init().
64607 +*//***************************************************************************/
64608 +void FM_GetDmaStatus(t_Handle h_Fm, t_FmDmaStatus *p_FmDmaStatus);
64609 +
64610 +/**************************************************************************//**
64611 + @Function FM_ErrorIsr
64612 +
64613 + @Description FM interrupt-service-routine for errors.
64614 +
64615 + @Param[in] h_Fm A handle to an FM Module.
64616 +
64617 + @Return E_OK on success; E_EMPTY if no errors found in register, other
64618 + error code otherwise.
64619 +
64620 + @Cautions Allowed only following FM_Init().
64621 + This routine should NOT be called from guest-partition
64622 + (i.e. guestId != NCSW_MASTER_ID)
64623 +*//***************************************************************************/
64624 +t_Error FM_ErrorIsr(t_Handle h_Fm);
64625 +
64626 +/**************************************************************************//**
64627 + @Function FM_EventIsr
64628 +
64629 + @Description FM interrupt-service-routine for normal events.
64630 +
64631 + @Param[in] h_Fm A handle to an FM Module.
64632 +
64633 + @Cautions Allowed only following FM_Init().
64634 + This routine should NOT be called from guest-partition
64635 + (i.e. guestId != NCSW_MASTER_ID)
64636 +*//***************************************************************************/
64637 +void FM_EventIsr(t_Handle h_Fm);
64638 +
64639 +/**************************************************************************//**
64640 + @Function FM_GetSpecialOperationCoding
64641 +
64642 + @Description Return a specific coding according to the input mask.
64643 +
64644 + @Param[in] h_Fm A handle to an FM Module.
64645 + @Param[in] spOper special operation mask.
64646 + @Param[out] p_SpOperCoding special operation code.
64647 +
64648 + @Return E_OK on success; Error code otherwise.
64649 +
64650 + @Cautions Allowed only following FM_Init().
64651 +*//***************************************************************************/
64652 +t_Error FM_GetSpecialOperationCoding(t_Handle h_Fm,
64653 + fmSpecialOperations_t spOper,
64654 + uint8_t *p_SpOperCoding);
64655 +
64656 +/**************************************************************************//**
64657 + @Function FM_CtrlMonStart
64658 +
64659 + @Description Start monitoring utilization of all available FM controllers.
64660 +
64661 + In order to obtain FM controllers utilization the following sequence
64662 + should be used:
64663 + -# FM_CtrlMonStart()
64664 + -# FM_CtrlMonStop()
64665 + -# FM_CtrlMonGetCounters() - issued for each FM controller
64666 +
64667 + @Param[in] h_Fm A handle to an FM Module.
64668 +
64669 + @Return E_OK on success; Error code otherwise.
64670 +
64671 + @Cautions Allowed only following FM_Init().
64672 + This routine should NOT be called from guest-partition
64673 + (i.e. guestId != NCSW_MASTER_ID).
64674 +*//***************************************************************************/
64675 +t_Error FM_CtrlMonStart(t_Handle h_Fm);
64676 +
64677 +/**************************************************************************//**
64678 + @Function FM_CtrlMonStop
64679 +
64680 + @Description Stop monitoring utilization of all available FM controllers.
64681 +
64682 + In order to obtain FM controllers utilization the following sequence
64683 + should be used:
64684 + -# FM_CtrlMonStart()
64685 + -# FM_CtrlMonStop()
64686 + -# FM_CtrlMonGetCounters() - issued for each FM controller
64687 +
64688 + @Param[in] h_Fm A handle to an FM Module.
64689 +
64690 + @Return E_OK on success; Error code otherwise.
64691 +
64692 + @Cautions Allowed only following FM_Init().
64693 + This routine should NOT be called from guest-partition
64694 + (i.e. guestId != NCSW_MASTER_ID).
64695 +*//***************************************************************************/
64696 +t_Error FM_CtrlMonStop(t_Handle h_Fm);
64697 +
64698 +/**************************************************************************//**
64699 + @Function FM_CtrlMonGetCounters
64700 +
64701 + @Description Obtain FM controller utilization parameters.
64702 +
64703 + In order to obtain FM controllers utilization the following sequence
64704 + should be used:
64705 + -# FM_CtrlMonStart()
64706 + -# FM_CtrlMonStop()
64707 + -# FM_CtrlMonGetCounters() - issued for each FM controller
64708 +
64709 + @Param[in] h_Fm A handle to an FM Module.
64710 + @Param[in] fmCtrlIndex FM Controller index for that utilization results
64711 + are requested.
64712 + @Param[in] p_Mon Pointer to utilization results structure.
64713 +
64714 + @Return E_OK on success; Error code otherwise.
64715 +
64716 + @Cautions Allowed only following FM_Init().
64717 + This routine should NOT be called from guest-partition
64718 + (i.e. guestId != NCSW_MASTER_ID).
64719 +*//***************************************************************************/
64720 +t_Error FM_CtrlMonGetCounters(t_Handle h_Fm, uint8_t fmCtrlIndex, t_FmCtrlMon *p_Mon);
64721 +
64722 +
64723 +/**************************************************************************//*
64724 + @Function FM_ForceIntr
64725 +
64726 + @Description Causes an interrupt event on the requested source.
64727 +
64728 + @Param[in] h_Fm A handle to an FM Module.
64729 + @Param[in] exception An exception to be forced.
64730 +
64731 + @Return E_OK on success; Error code if the exception is not enabled,
64732 + or is not able to create interrupt.
64733 +
64734 + @Cautions Allowed only following FM_Init().
64735 + This routine should NOT be called from guest-partition
64736 + (i.e. guestId != NCSW_MASTER_ID)
64737 +*//***************************************************************************/
64738 +t_Error FM_ForceIntr (t_Handle h_Fm, e_FmExceptions exception);
64739 +
64740 +/**************************************************************************//*
64741 + @Function FM_SetPortsBandwidth
64742 +
64743 + @Description Sets relative weights between ports when accessing common resources.
64744 +
64745 + @Param[in] h_Fm A handle to an FM Module.
64746 + @Param[in] p_PortsBandwidth A structure of ports bandwidths in percentage, i.e.
64747 + total must equal 100.
64748 +
64749 + @Return E_OK on success; Error code otherwise.
64750 +
64751 + @Cautions Allowed only following FM_Init().
64752 + This routine should NOT be called from guest-partition
64753 + (i.e. guestId != NCSW_MASTER_ID)
64754 +*//***************************************************************************/
64755 +t_Error FM_SetPortsBandwidth(t_Handle h_Fm, t_FmPortsBandwidthParams *p_PortsBandwidth);
64756 +
64757 +/**************************************************************************//*
64758 + @Function FM_GetMuramHandle
64759 +
64760 + @Description Gets the corresponding MURAM handle
64761 +
64762 + @Param[in] h_Fm A handle to an FM Module.
64763 +
64764 + @Return MURAM handle; NULL otherwise.
64765 +
64766 + @Cautions Allowed only following FM_Init().
64767 + This routine should NOT be called from guest-partition
64768 + (i.e. guestId != NCSW_MASTER_ID)
64769 +*//***************************************************************************/
64770 +t_Handle FM_GetMuramHandle(t_Handle h_Fm);
64771 +
64772 +/** @} */ /* end of FM_runtime_control_grp group */
64773 +/** @} */ /* end of FM_lib_grp group */
64774 +/** @} */ /* end of FM_grp group */
64775 +
64776 +
64777 +#ifdef NCSW_BACKWARD_COMPATIBLE_API
64778 +typedef t_FmFirmwareParams t_FmPcdFirmwareParams;
64779 +typedef t_FmBufferPrefixContent t_FmPortBufferPrefixContent;
64780 +typedef t_FmExtPoolParams t_FmPortExtPoolParams;
64781 +typedef t_FmExtPools t_FmPortExtPools;
64782 +typedef t_FmBackupBmPools t_FmPortBackupBmPools;
64783 +typedef t_FmBufPoolDepletion t_FmPortBufPoolDepletion;
64784 +typedef e_FmDmaSwapOption e_FmPortDmaSwapOption;
64785 +typedef e_FmDmaCacheOption e_FmPortDmaCacheOption;
64786 +
64787 +#define FM_CONTEXTA_GET_OVVERIDE FM_CONTEXTA_GET_OVERRIDE
64788 +#define FM_CONTEXTA_SET_OVVERIDE FM_CONTEXTA_SET_OVERRIDE
64789 +
64790 +#define e_FM_EX_BMI_PIPELINE_ECC e_FM_EX_BMI_STORAGE_PROFILE_ECC
64791 +#define e_FM_PORT_DMA_NO_SWP e_FM_DMA_NO_SWP
64792 +#define e_FM_PORT_DMA_SWP_PPC_LE e_FM_DMA_SWP_PPC_LE
64793 +#define e_FM_PORT_DMA_SWP_BE e_FM_DMA_SWP_BE
64794 +#define e_FM_PORT_DMA_NO_STASH e_FM_DMA_NO_STASH
64795 +#define e_FM_PORT_DMA_STASH e_FM_DMA_STASH
64796 +#endif /* NCSW_BACKWARD_COMPATIBLE_API */
64797 +
64798 +
64799 +#endif /* __FM_EXT */
64800 --- /dev/null
64801 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_mac_ext.h
64802 @@ -0,0 +1,846 @@
64803 +/*
64804 + * Copyright 2008-2012 Freescale Semiconductor Inc.
64805 + *
64806 + * Redistribution and use in source and binary forms, with or without
64807 + * modification, are permitted provided that the following conditions are met:
64808 + * * Redistributions of source code must retain the above copyright
64809 + * notice, this list of conditions and the following disclaimer.
64810 + * * Redistributions in binary form must reproduce the above copyright
64811 + * notice, this list of conditions and the following disclaimer in the
64812 + * documentation and/or other materials provided with the distribution.
64813 + * * Neither the name of Freescale Semiconductor nor the
64814 + * names of its contributors may be used to endorse or promote products
64815 + * derived from this software without specific prior written permission.
64816 + *
64817 + *
64818 + * ALTERNATIVELY, this software may be distributed under the terms of the
64819 + * GNU General Public License ("GPL") as published by the Free Software
64820 + * Foundation, either version 2 of that License or (at your option) any
64821 + * later version.
64822 + *
64823 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
64824 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
64825 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
64826 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
64827 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
64828 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64829 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
64830 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
64831 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
64832 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64833 + */
64834 +
64835 +
64836 +/**************************************************************************//**
64837 + @File fm_mac_ext.h
64838 +
64839 + @Description FM MAC ...
64840 +*//***************************************************************************/
64841 +#ifndef __FM_MAC_EXT_H
64842 +#define __FM_MAC_EXT_H
64843 +
64844 +#include "std_ext.h"
64845 +#include "enet_ext.h"
64846 +
64847 +
64848 +/**************************************************************************//**
64849 +
64850 + @Group FM_grp Frame Manager API
64851 +
64852 + @Description FM API functions, definitions and enums
64853 +
64854 + @{
64855 +*//***************************************************************************/
64856 +
64857 +/**************************************************************************//**
64858 + @Group FM_mac_grp FM MAC
64859 +
64860 + @Description FM MAC API functions, definitions and enums
64861 +
64862 + @{
64863 +*//***************************************************************************/
64864 +
64865 +#define FM_MAC_NO_PFC 0xff
64866 +
64867 +
64868 +/**************************************************************************//**
64869 + @Description FM MAC Exceptions
64870 +*//***************************************************************************/
64871 +typedef enum e_FmMacExceptions {
64872 + e_FM_MAC_EX_10G_MDIO_SCAN_EVENTMDIO = 0 /**< 10GEC MDIO scan event interrupt */
64873 + ,e_FM_MAC_EX_10G_MDIO_CMD_CMPL /**< 10GEC MDIO command completion interrupt */
64874 + ,e_FM_MAC_EX_10G_REM_FAULT /**< 10GEC, mEMAC Remote fault interrupt */
64875 + ,e_FM_MAC_EX_10G_LOC_FAULT /**< 10GEC, mEMAC Local fault interrupt */
64876 + ,e_FM_MAC_EX_10G_1TX_ECC_ER /**< 10GEC, mEMAC Transmit frame ECC error interrupt */
64877 + ,e_FM_MAC_EX_10G_TX_FIFO_UNFL /**< 10GEC, mEMAC Transmit FIFO underflow interrupt */
64878 + ,e_FM_MAC_EX_10G_TX_FIFO_OVFL /**< 10GEC, mEMAC Transmit FIFO overflow interrupt */
64879 + ,e_FM_MAC_EX_10G_TX_ER /**< 10GEC Transmit frame error interrupt */
64880 + ,e_FM_MAC_EX_10G_RX_FIFO_OVFL /**< 10GEC, mEMAC Receive FIFO overflow interrupt */
64881 + ,e_FM_MAC_EX_10G_RX_ECC_ER /**< 10GEC, mEMAC Receive frame ECC error interrupt */
64882 + ,e_FM_MAC_EX_10G_RX_JAB_FRM /**< 10GEC Receive jabber frame interrupt */
64883 + ,e_FM_MAC_EX_10G_RX_OVRSZ_FRM /**< 10GEC Receive oversized frame interrupt */
64884 + ,e_FM_MAC_EX_10G_RX_RUNT_FRM /**< 10GEC Receive runt frame interrupt */
64885 + ,e_FM_MAC_EX_10G_RX_FRAG_FRM /**< 10GEC Receive fragment frame interrupt */
64886 + ,e_FM_MAC_EX_10G_RX_LEN_ER /**< 10GEC Receive payload length error interrupt */
64887 + ,e_FM_MAC_EX_10G_RX_CRC_ER /**< 10GEC Receive CRC error interrupt */
64888 + ,e_FM_MAC_EX_10G_RX_ALIGN_ER /**< 10GEC Receive alignment error interrupt */
64889 + ,e_FM_MAC_EX_1G_BAB_RX /**< dTSEC Babbling receive error */
64890 + ,e_FM_MAC_EX_1G_RX_CTL /**< dTSEC Receive control (pause frame) interrupt */
64891 + ,e_FM_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET /**< dTSEC Graceful transmit stop complete */
64892 + ,e_FM_MAC_EX_1G_BAB_TX /**< dTSEC Babbling transmit error */
64893 + ,e_FM_MAC_EX_1G_TX_CTL /**< dTSEC Transmit control (pause frame) interrupt */
64894 + ,e_FM_MAC_EX_1G_TX_ERR /**< dTSEC Transmit error */
64895 + ,e_FM_MAC_EX_1G_LATE_COL /**< dTSEC Late collision */
64896 + ,e_FM_MAC_EX_1G_COL_RET_LMT /**< dTSEC Collision retry limit */
64897 + ,e_FM_MAC_EX_1G_TX_FIFO_UNDRN /**< dTSEC Transmit FIFO underrun */
64898 + ,e_FM_MAC_EX_1G_MAG_PCKT /**< dTSEC Magic Packet detection */
64899 + ,e_FM_MAC_EX_1G_MII_MNG_RD_COMPLET /**< dTSEC MII management read completion */
64900 + ,e_FM_MAC_EX_1G_MII_MNG_WR_COMPLET /**< dTSEC MII management write completion */
64901 + ,e_FM_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET /**< dTSEC Graceful receive stop complete */
64902 + ,e_FM_MAC_EX_1G_TX_DATA_ERR /**< dTSEC Internal data error on transmit */
64903 + ,e_FM_MAC_EX_1G_RX_DATA_ERR /**< dTSEC Internal data error on receive */
64904 + ,e_FM_MAC_EX_1G_1588_TS_RX_ERR /**< dTSEC Time-Stamp Receive Error */
64905 + ,e_FM_MAC_EX_1G_RX_MIB_CNT_OVFL /**< dTSEC MIB counter overflow */
64906 + ,e_FM_MAC_EX_TS_FIFO_ECC_ERR /**< mEMAC Time-stamp FIFO ECC error interrupt;
64907 + not supported on T4240/B4860 rev1 chips */
64908 + ,e_FM_MAC_EX_MAGIC_PACKET_INDICATION = e_FM_MAC_EX_1G_MAG_PCKT
64909 + /**< mEMAC Magic Packet Indication Interrupt */
64910 +} e_FmMacExceptions;
64911 +
64912 +/**************************************************************************//**
64913 + @Description TM MAC statistics level
64914 +*//***************************************************************************/
64915 +typedef enum e_FmMacStatisticsLevel {
64916 + e_FM_MAC_NONE_STATISTICS = 0, /**< No statistics */
64917 + e_FM_MAC_PARTIAL_STATISTICS, /**< Only error counters are available; Optimized for performance */
64918 + e_FM_MAC_FULL_STATISTICS /**< All counters available; Not optimized for performance */
64919 +} e_FmMacStatisticsLevel;
64920 +
64921 +
64922 +#if (DPAA_VERSION >= 11)
64923 +/**************************************************************************//**
64924 + @Description Priority Flow Control Parameters
64925 +*//***************************************************************************/
64926 +typedef struct t_FmMacPfcParams {
64927 + bool pfcEnable; /**< Enable/Disable PFC */
64928 +
64929 + uint16_t pauseQuanta[FM_MAX_NUM_OF_PFC_PRIORITIES]; /**< Pause Quanta per priority to be sent in a pause frame. Each quanta represents a 512 bit-times*/
64930 +
64931 + uint16_t pauseThresholdQuanta[FM_MAX_NUM_OF_PFC_PRIORITIES];/**< Pause threshold per priority, when timer passes this threshold time a PFC frames is sent again if the port is still congested or BM pool in depletion*/
64932 +
64933 +
64934 +} t_FmMacPfcParams;
64935 +#endif /* (DPAA_VERSION >= 11) */
64936 +
64937 +/**************************************************************************//**
64938 + @Function t_FmMacExceptionCallback
64939 +
64940 + @Description Fm Mac Exception Callback from FM MAC to the user
64941 +
64942 + @Param[in] h_App - Handle to the upper layer handler
64943 +
64944 + @Param[in] exceptions - The exception that occurred
64945 +
64946 + @Return void.
64947 +*//***************************************************************************/
64948 +typedef void (t_FmMacExceptionCallback)(t_Handle h_App, e_FmMacExceptions exceptions);
64949 +
64950 +
64951 +/**************************************************************************//**
64952 + @Description TM MAC statistics rfc3635
64953 +*//***************************************************************************/
64954 +typedef struct t_FmMacStatistics {
64955 +/* RMON */
64956 + uint64_t eStatPkts64; /**< r-10G tr-DT 64 byte frame counter */
64957 + uint64_t eStatPkts65to127; /**< r-10G 65 to 127 byte frame counter */
64958 + uint64_t eStatPkts128to255; /**< r-10G 128 to 255 byte frame counter */
64959 + uint64_t eStatPkts256to511; /**< r-10G 256 to 511 byte frame counter */
64960 + uint64_t eStatPkts512to1023; /**< r-10G 512 to 1023 byte frame counter */
64961 + uint64_t eStatPkts1024to1518; /**< r-10G 1024 to 1518 byte frame counter */
64962 + uint64_t eStatPkts1519to1522; /**< r-10G 1519 to 1522 byte good frame count */
64963 +/* */
64964 + uint64_t eStatFragments; /**< Total number of packets that were less than 64 octets long with a wrong CRC.*/
64965 + uint64_t eStatJabbers; /**< Total number of packets longer than valid maximum length octets */
64966 + uint64_t eStatsDropEvents; /**< number of dropped packets due to internal errors of the MAC Client (during receive). */
64967 + uint64_t eStatCRCAlignErrors; /**< Incremented when frames of correct length but with CRC error are received.*/
64968 + uint64_t eStatUndersizePkts; /**< Incremented for frames under 64 bytes with a valid FCS and otherwise well formed;
64969 + This count does not include range length errors */
64970 + uint64_t eStatOversizePkts; /**< Incremented for frames which exceed 1518 (non VLAN) or 1522 (VLAN) and contains
64971 + a valid FCS and otherwise well formed */
64972 +/* Pause */
64973 + uint64_t teStatPause; /**< Pause MAC Control received */
64974 + uint64_t reStatPause; /**< Pause MAC Control sent */
64975 +/* MIB II */
64976 + uint64_t ifInOctets; /**< Total number of byte received. */
64977 + uint64_t ifInPkts; /**< Total number of packets received.*/
64978 + uint64_t ifInUcastPkts; /**< Total number of unicast frame received;
64979 + NOTE: this counter is not supported on dTSEC MAC */
64980 + uint64_t ifInMcastPkts; /**< Total number of multicast frame received*/
64981 + uint64_t ifInBcastPkts; /**< Total number of broadcast frame received */
64982 + uint64_t ifInDiscards; /**< Frames received, but discarded due to problems within the MAC RX. */
64983 + uint64_t ifInErrors; /**< Number of frames received with error:
64984 + - FIFO Overflow Error
64985 + - CRC Error
64986 + - Frame Too Long Error
64987 + - Alignment Error
64988 + - The dedicated Error Code (0xfe, not a code error) was received */
64989 + uint64_t ifOutOctets; /**< Total number of byte sent. */
64990 + uint64_t ifOutPkts; /**< Total number of packets sent .*/
64991 + uint64_t ifOutUcastPkts; /**< Total number of unicast frame sent;
64992 + NOTE: this counter is not supported on dTSEC MAC */
64993 + uint64_t ifOutMcastPkts; /**< Total number of multicast frame sent */
64994 + uint64_t ifOutBcastPkts; /**< Total number of multicast frame sent */
64995 + uint64_t ifOutDiscards; /**< Frames received, but discarded due to problems within the MAC TX N/A!.*/
64996 + uint64_t ifOutErrors; /**< Number of frames transmitted with error:
64997 + - FIFO Overflow Error
64998 + - FIFO Underflow Error
64999 + - Other */
65000 +} t_FmMacStatistics;
65001 +
65002 +
65003 +/**************************************************************************//**
65004 + @Group FM_mac_init_grp FM MAC Initialization Unit
65005 +
65006 + @Description FM MAC Initialization Unit
65007 +
65008 + @{
65009 +*//***************************************************************************/
65010 +
65011 +/**************************************************************************//**
65012 + @Description FM MAC config input
65013 +*//***************************************************************************/
65014 +typedef struct t_FmMacParams {
65015 + uintptr_t baseAddr; /**< Base of memory mapped FM MAC registers */
65016 + t_EnetAddr addr; /**< MAC address of device; First octet is sent first */
65017 + uint8_t macId; /**< MAC ID;
65018 + numbering of dTSEC and 1G-mEMAC:
65019 + 0 - FM_MAX_NUM_OF_1G_MACS;
65020 + numbering of 10G-MAC (TGEC) and 10G-mEMAC:
65021 + 0 - FM_MAX_NUM_OF_10G_MACS */
65022 + e_EnetMode enetMode; /**< Ethernet operation mode (MAC-PHY interface and speed);
65023 + Note that the speed should indicate the maximum rate that
65024 + this MAC should support rather than the actual speed;
65025 + i.e. user should use the FM_MAC_AdjustLink() routine to
65026 + provide accurate speed;
65027 + In case of mEMAC RGMII mode, the MAC is configured to RGMII
65028 + automatic mode, where actual speed/duplex mode information
65029 + is provided by PHY automatically in-band; FM_MAC_AdjustLink()
65030 + function should be used to switch to manual RGMII speed/duplex mode
65031 + configuration if RGMII PHY doesn't support in-band status signaling;
65032 + In addition, in mEMAC, in case where user is using the higher MACs
65033 + (i.e. the MACs that should support 10G), user should pass here
65034 + speed=10000 even if the interface is not allowing that (e.g. SGMII). */
65035 + t_Handle h_Fm; /**< A handle to the FM object this port related to */
65036 + int mdioIrq; /**< MDIO exceptions interrupt source - not valid for all
65037 + MACs; MUST be set to 'NO_IRQ' for MACs that don't have
65038 + mdio-irq, or for polling */
65039 + t_FmMacExceptionCallback *f_Event; /**< MDIO Events Callback Routine */
65040 + t_FmMacExceptionCallback *f_Exception; /**< Exception Callback Routine */
65041 + t_Handle h_App; /**< A handle to an application layer object; This handle will
65042 + be passed by the driver upon calling the above callbacks */
65043 +} t_FmMacParams;
65044 +
65045 +
65046 +/**************************************************************************//**
65047 + @Function FM_MAC_Config
65048 +
65049 + @Description Creates descriptor for the FM MAC module.
65050 +
65051 + The routine returns a handle (descriptor) to the FM MAC object.
65052 + This descriptor must be passed as first parameter to all other
65053 + FM MAC function calls.
65054 +
65055 + No actual initialization or configuration of FM MAC hardware is
65056 + done by this routine.
65057 +
65058 + @Param[in] p_FmMacParam - Pointer to data structure of parameters
65059 +
65060 + @Retval Handle to FM MAC object, or NULL for Failure.
65061 +*//***************************************************************************/
65062 +t_Handle FM_MAC_Config(t_FmMacParams *p_FmMacParam);
65063 +
65064 +/**************************************************************************//**
65065 + @Function FM_MAC_Init
65066 +
65067 + @Description Initializes the FM MAC module
65068 +
65069 + @Param[in] h_FmMac - FM module descriptor
65070 +
65071 + @Return E_OK on success; Error code otherwise.
65072 +*//***************************************************************************/
65073 +t_Error FM_MAC_Init(t_Handle h_FmMac);
65074 +
65075 +/**************************************************************************//**
65076 + @Function FM_Free
65077 +
65078 + @Description Frees all resources that were assigned to FM MAC module.
65079 +
65080 + Calling this routine invalidates the descriptor.
65081 +
65082 + @Param[in] h_FmMac - FM module descriptor
65083 +
65084 + @Return E_OK on success; Error code otherwise.
65085 +*//***************************************************************************/
65086 +t_Error FM_MAC_Free(t_Handle h_FmMac);
65087 +
65088 +
65089 +/**************************************************************************//**
65090 + @Group FM_mac_advanced_init_grp FM MAC Advanced Configuration Unit
65091 +
65092 + @Description Configuration functions used to change default values.
65093 +
65094 + @{
65095 +*//***************************************************************************/
65096 +
65097 +/**************************************************************************//**
65098 + @Function FM_MAC_ConfigResetOnInit
65099 +
65100 + @Description Tell the driver whether to reset the FM MAC before initialization or
65101 + not. It changes the default configuration [DEFAULT_resetOnInit].
65102 +
65103 + @Param[in] h_FmMac A handle to a FM MAC Module.
65104 + @Param[in] enable When TRUE, FM will be reset before any initialization.
65105 +
65106 + @Return E_OK on success; Error code otherwise.
65107 +
65108 + @Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
65109 +*//***************************************************************************/
65110 +t_Error FM_MAC_ConfigResetOnInit(t_Handle h_FmMac, bool enable);
65111 +
65112 +/**************************************************************************//**
65113 + @Function FM_MAC_ConfigLoopback
65114 +
65115 + @Description Enable/Disable internal loopback mode
65116 +
65117 + @Param[in] h_FmMac A handle to a FM MAC Module.
65118 + @Param[in] enable TRUE to enable or FALSE to disable.
65119 +
65120 + @Return E_OK on success; Error code otherwise.
65121 +
65122 + @Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
65123 +*//***************************************************************************/
65124 +t_Error FM_MAC_ConfigLoopback(t_Handle h_FmMac, bool enable);
65125 +
65126 +/**************************************************************************//**
65127 + @Function FM_MAC_ConfigMaxFrameLength
65128 +
65129 + @Description Setup maximum Rx Frame Length (in 1G MAC, effects also Tx)
65130 +
65131 + @Param[in] h_FmMac A handle to a FM MAC Module.
65132 + @Param[in] newVal MAX Frame length
65133 +
65134 + @Return E_OK on success; Error code otherwise.
65135 +
65136 + @Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
65137 +*//***************************************************************************/
65138 +t_Error FM_MAC_ConfigMaxFrameLength(t_Handle h_FmMac, uint16_t newVal);
65139 +
65140 +/**************************************************************************//**
65141 + @Function FM_MAC_ConfigWan
65142 +
65143 + @Description ENABLE WAN mode in 10G-MAC
65144 +
65145 + @Param[in] h_FmMac A handle to a FM MAC Module.
65146 + @Param[in] enable TRUE to enable or FALSE to disable.
65147 +
65148 + @Return E_OK on success; Error code otherwise.
65149 +
65150 + @Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
65151 +*//***************************************************************************/
65152 +t_Error FM_MAC_ConfigWan(t_Handle h_FmMac, bool enable);
65153 +
65154 +/**************************************************************************//**
65155 + @Function FM_MAC_ConfigPadAndCrc
65156 +
65157 + @Description Config PAD and CRC mode
65158 +
65159 + @Param[in] h_FmMac A handle to a FM MAC Module.
65160 + @Param[in] enable TRUE to enable or FALSE to disable.
65161 +
65162 + @Return E_OK on success; Error code otherwise.
65163 +
65164 + @Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
65165 + Not supported on 10G-MAC (i.e. CRC & PAD are added automatically
65166 + by HW); on mEMAC, this routine supports only PAD (i.e. CRC is
65167 + added automatically by HW).
65168 +*//***************************************************************************/
65169 +t_Error FM_MAC_ConfigPadAndCrc(t_Handle h_FmMac, bool enable);
65170 +
65171 +/**************************************************************************//**
65172 + @Function FM_MAC_ConfigHalfDuplex
65173 +
65174 + @Description Config Half Duplex Mode
65175 +
65176 + @Param[in] h_FmMac A handle to a FM MAC Module.
65177 + @Param[in] enable TRUE to enable or FALSE to disable.
65178 +
65179 + @Return E_OK on success; Error code otherwise.
65180 +
65181 + @Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
65182 +*//***************************************************************************/
65183 +t_Error FM_MAC_ConfigHalfDuplex(t_Handle h_FmMac, bool enable);
65184 +
65185 +/**************************************************************************//**
65186 + @Function FM_MAC_ConfigTbiPhyAddr
65187 +
65188 + @Description Configures the address of internal TBI PHY.
65189 +
65190 + @Param[in] h_FmMac A handle to a FM MAC Module.
65191 + @Param[in] newVal TBI PHY address (1-31).
65192 +
65193 + @Return E_OK on success; Error code otherwise.
65194 +
65195 + @Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
65196 +*//***************************************************************************/
65197 +t_Error FM_MAC_ConfigTbiPhyAddr(t_Handle h_FmMac, uint8_t newVal);
65198 +
65199 +/**************************************************************************//**
65200 + @Function FM_MAC_ConfigLengthCheck
65201 +
65202 + @Description Configure the frame length checking.
65203 +
65204 + @Param[in] h_FmMac A handle to a FM MAC Module.
65205 + @Param[in] enable TRUE to enable or FALSE to disable.
65206 +
65207 + @Return E_OK on success; Error code otherwise.
65208 +
65209 + @Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
65210 +*//***************************************************************************/
65211 +t_Error FM_MAC_ConfigLengthCheck(t_Handle h_FmMac, bool enable);
65212 +
65213 +/**************************************************************************//**
65214 + @Function FM_MAC_ConfigException
65215 +
65216 + @Description Change Exception selection from default
65217 +
65218 + @Param[in] h_FmMac A handle to a FM MAC Module.
65219 + @Param[in] ex Type of the desired exceptions
65220 + @Param[in] enable TRUE to enable the specified exception, FALSE to disable it.
65221 +
65222 + @Return E_OK on success; Error code otherwise.
65223 +
65224 + @Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
65225 +*//***************************************************************************/
65226 +t_Error FM_MAC_ConfigException(t_Handle h_FmMac, e_FmMacExceptions ex, bool enable);
65227 +
65228 +#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
65229 +t_Error FM_MAC_ConfigSkipFman11Workaround (t_Handle h_FmMac);
65230 +#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
65231 +/** @} */ /* end of FM_mac_advanced_init_grp group */
65232 +/** @} */ /* end of FM_mac_init_grp group */
65233 +
65234 +
65235 +/**************************************************************************//**
65236 + @Group FM_mac_runtime_control_grp FM MAC Runtime Control Unit
65237 +
65238 + @Description FM MAC Runtime control unit API functions, definitions and enums.
65239 +
65240 + @{
65241 +*//***************************************************************************/
65242 +
65243 +/**************************************************************************//**
65244 + @Function FM_MAC_Enable
65245 +
65246 + @Description Enable the MAC
65247 +
65248 + @Param[in] h_FmMac A handle to a FM MAC Module.
65249 + @Param[in] mode Mode of operation (RX, TX, Both)
65250 +
65251 + @Return E_OK on success; Error code otherwise.
65252 +
65253 + @Cautions Allowed only following FM_MAC_Init().
65254 +*//***************************************************************************/
65255 +t_Error FM_MAC_Enable(t_Handle h_FmMac, e_CommMode mode);
65256 +
65257 +/**************************************************************************//**
65258 + @Function FM_MAC_Disable
65259 +
65260 + @Description DISABLE the MAC
65261 +
65262 + @Param[in] h_FmMac A handle to a FM MAC Module.
65263 + @Param[in] mode Define what part to Disable (RX, TX or BOTH)
65264 +
65265 + @Return E_OK on success; Error code otherwise.
65266 +
65267 + @Cautions Allowed only following FM_MAC_Init().
65268 +*//***************************************************************************/
65269 +t_Error FM_MAC_Disable(t_Handle h_FmMac, e_CommMode mode);
65270 +
65271 +/**************************************************************************//**
65272 + @Function FM_MAC_Enable1588TimeStamp
65273 +
65274 + @Description Enables the TSU operation.
65275 +
65276 + @Param[in] h_Fm - Handle to the PTP as returned from the FM_MAC_PtpConfig.
65277 +
65278 + @Return E_OK on success; Error code otherwise.
65279 +
65280 + @Cautions Allowed only following FM_MAC_Init().
65281 +*//***************************************************************************/
65282 +t_Error FM_MAC_Enable1588TimeStamp(t_Handle h_Fm);
65283 +
65284 +/**************************************************************************//**
65285 + @Function FM_MAC_Disable1588TimeStamp
65286 +
65287 + @Description Disables the TSU operation.
65288 +
65289 + @Param[in] h_Fm - Handle to the PTP as returned from the FM_MAC_PtpConfig.
65290 +
65291 + @Return E_OK on success; Error code otherwise.
65292 +
65293 + @Cautions Allowed only following FM_MAC_Init().
65294 +*//***************************************************************************/
65295 +t_Error FM_MAC_Disable1588TimeStamp(t_Handle h_Fm);
65296 +
65297 +/**************************************************************************//**
65298 + @Function FM_MAC_SetTxAutoPauseFrames
65299 +
65300 + @Description Enable/Disable transmission of Pause-Frames.
65301 + The routine changes the default configuration [DEFAULT_TX_PAUSE_TIME].
65302 +
65303 + @Param[in] h_FmMac - A handle to a FM MAC Module.
65304 + @Param[in] pauseTime - Pause quanta value used with transmitted pause frames.
65305 + Each quanta represents a 512 bit-times; Note that '0'
65306 + as an input here will be used as disabling the
65307 + transmission of the pause-frames.
65308 +
65309 + @Return E_OK on success; Error code otherwise.
65310 +
65311 + @Cautions Allowed only following FM_MAC_Init().
65312 +*//***************************************************************************/
65313 +t_Error FM_MAC_SetTxAutoPauseFrames(t_Handle h_FmMac,
65314 + uint16_t pauseTime);
65315 +
65316 + /**************************************************************************//**
65317 + @Function FM_MAC_SetTxPauseFrames
65318 +
65319 + @Description Enable/Disable transmission of Pause-Frames.
65320 + The routine changes the default configuration:
65321 + pause-time - [DEFAULT_TX_PAUSE_TIME]
65322 + threshold-time - [0]
65323 +
65324 + @Param[in] h_FmMac - A handle to a FM MAC Module.
65325 + @Param[in] priority - the PFC class of service; use 'FM_MAC_NO_PFC'
65326 + to indicate legacy pause support (i.e. no PFC).
65327 + @Param[in] pauseTime - Pause quanta value used with transmitted pause frames.
65328 + Each quanta represents a 512 bit-times;
65329 + Note that '0' as an input here will be used as disabling the
65330 + transmission of the pause-frames.
65331 + @Param[in] threshTime - Pause Threshold equanta value used by the MAC to retransmit pause frame.
65332 + if the situation causing a pause frame to be sent didn't finish when the timer
65333 + reached the threshold quanta, the MAC will retransmit the pause frame.
65334 + Each quanta represents a 512 bit-times.
65335 +
65336 + @Return E_OK on success; Error code otherwise.
65337 +
65338 + @Cautions Allowed only following FM_MAC_Init().
65339 + In order for PFC to work properly the user must configure
65340 + TNUM-aging in the tx-port it is recommended that pre-fetch and
65341 + rate limit in the tx port should be disabled;
65342 + PFC is supported only on new mEMAC; i.e. in MACs that don't have
65343 + PFC support (10G-MAC and dTSEC), user should use 'FM_MAC_NO_PFC'
65344 + in the 'priority' field.
65345 +*//***************************************************************************/
65346 +t_Error FM_MAC_SetTxPauseFrames(t_Handle h_FmMac,
65347 + uint8_t priority,
65348 + uint16_t pauseTime,
65349 + uint16_t threshTime);
65350 +
65351 +/**************************************************************************//**
65352 + @Function FM_MAC_SetRxIgnorePauseFrames
65353 +
65354 + @Description Enable/Disable ignoring of Pause-Frames.
65355 +
65356 + @Param[in] h_FmMac - A handle to a FM MAC Module.
65357 + @Param[in] en - boolean indicates whether to ignore the incoming pause
65358 + frames or not.
65359 +
65360 + @Return E_OK on success; Error code otherwise.
65361 +
65362 + @Cautions Allowed only following FM_MAC_Init().
65363 +*//***************************************************************************/
65364 +t_Error FM_MAC_SetRxIgnorePauseFrames(t_Handle h_FmMac, bool en);
65365 +
65366 +/**************************************************************************//**
65367 + @Function FM_MAC_SetWakeOnLan
65368 +
65369 + @Description Enable/Disable Wake On Lan support
65370 +
65371 + @Param[in] h_FmMac - A handle to a FM MAC Module.
65372 + @Param[in] en - boolean indicates whether to enable Wake On Lan
65373 + support or not.
65374 +
65375 + @Return E_OK on success; Error code otherwise.
65376 +
65377 + @Cautions Allowed only following FM_MAC_Init().
65378 +*//***************************************************************************/
65379 +t_Error FM_MAC_SetWakeOnLan(t_Handle h_FmMac, bool en);
65380 +
65381 +/**************************************************************************//**
65382 + @Function FM_MAC_ResetCounters
65383 +
65384 + @Description reset all statistics counters
65385 +
65386 + @Param[in] h_FmMac - A handle to a FM MAC Module.
65387 +
65388 + @Return E_OK on success; Error code otherwise.
65389 +
65390 + @Cautions Allowed only following FM_MAC_Init().
65391 +*//***************************************************************************/
65392 +t_Error FM_MAC_ResetCounters(t_Handle h_FmMac);
65393 +
65394 +/**************************************************************************//**
65395 + @Function FM_MAC_SetException
65396 +
65397 + @Description Enable/Disable a specific Exception
65398 +
65399 + @Param[in] h_FmMac - A handle to a FM MAC Module.
65400 + @Param[in] ex - Type of the desired exceptions
65401 + @Param[in] enable - TRUE to enable the specified exception, FALSE to disable it.
65402 +
65403 +
65404 + @Return E_OK on success; Error code otherwise.
65405 +
65406 + @Cautions Allowed only following FM_MAC_Init().
65407 +*//***************************************************************************/
65408 +t_Error FM_MAC_SetException(t_Handle h_FmMac, e_FmMacExceptions ex, bool enable);
65409 +
65410 +/**************************************************************************//**
65411 + @Function FM_MAC_SetStatistics
65412 +
65413 + @Description Define Statistics level.
65414 + Where applicable, the routine also enables the MIB counters
65415 + overflow interrupt in order to keep counters accurate
65416 + and account for overflows.
65417 + This routine is relevant only for dTSEC.
65418 +
65419 + @Param[in] h_FmMac - A handle to a FM MAC Module.
65420 + @Param[in] statisticsLevel - Full statistics level provides all standard counters but may
65421 + reduce performance. Partial statistics provides only special
65422 + event counters (errors etc.). If selected, regular counters (such as
65423 + byte/packet) will be invalid and will return -1.
65424 +
65425 + @Return E_OK on success; Error code otherwise.
65426 +
65427 + @Cautions Allowed only following FM_MAC_Init().
65428 +*//***************************************************************************/
65429 +t_Error FM_MAC_SetStatistics(t_Handle h_FmMac, e_FmMacStatisticsLevel statisticsLevel);
65430 +
65431 +/**************************************************************************//**
65432 + @Function FM_MAC_GetStatistics
65433 +
65434 + @Description get all statistics counters
65435 +
65436 + @Param[in] h_FmMac - A handle to a FM MAC Module.
65437 + @Param[in] p_Statistics - Structure with statistics
65438 +
65439 + @Return E_OK on success; Error code otherwise.
65440 +
65441 + @Cautions Allowed only following FM_Init().
65442 +*//***************************************************************************/
65443 +t_Error FM_MAC_GetStatistics(t_Handle h_FmMac, t_FmMacStatistics *p_Statistics);
65444 +
65445 +/**************************************************************************//**
65446 + @Function FM_MAC_ModifyMacAddr
65447 +
65448 + @Description Replace the main MAC Address
65449 +
65450 + @Param[in] h_FmMac - A handle to a FM Module.
65451 + @Param[in] p_EnetAddr - Ethernet Mac address
65452 +
65453 + @Return E_OK on success; Error code otherwise.
65454 +
65455 + @Cautions Allowed only after FM_MAC_Init().
65456 +*//***************************************************************************/
65457 +t_Error FM_MAC_ModifyMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
65458 +
65459 +/**************************************************************************//**
65460 + @Function FM_MAC_AddHashMacAddr
65461 +
65462 + @Description Add an Address to the hash table. This is for filter purpose only.
65463 +
65464 + @Param[in] h_FmMac - A handle to a FM Module.
65465 + @Param[in] p_EnetAddr - Ethernet Mac address
65466 +
65467 + @Return E_OK on success; Error code otherwise.
65468 +
65469 + @Cautions Allowed only following FM_MAC_Init(). It is a filter only address.
65470 + @Cautions Some address need to be filterd out in upper FM blocks.
65471 +*//***************************************************************************/
65472 +t_Error FM_MAC_AddHashMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
65473 +
65474 +/**************************************************************************//**
65475 + @Function FM_MAC_RemoveHashMacAddr
65476 +
65477 + @Description Delete an Address to the hash table. This is for filter purpose only.
65478 +
65479 + @Param[in] h_FmMac - A handle to a FM Module.
65480 + @Param[in] p_EnetAddr - Ethernet Mac address
65481 +
65482 + @Return E_OK on success; Error code otherwise.
65483 +
65484 + @Cautions Allowed only following FM_MAC_Init().
65485 +*//***************************************************************************/
65486 +t_Error FM_MAC_RemoveHashMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
65487 +
65488 +/**************************************************************************//**
65489 + @Function FM_MAC_AddExactMatchMacAddr
65490 +
65491 + @Description Add a unicast or multicast mac address for exact-match filtering
65492 + (8 on dTSEC, 2 for 10G-MAC)
65493 +
65494 + @Param[in] h_FmMac - A handle to a FM Module.
65495 + @Param[in] p_EnetAddr - MAC Address to ADD
65496 +
65497 + @Return E_OK on success; Error code otherwise.
65498 +
65499 + @Cautions Allowed only after FM_MAC_Init().
65500 +*//***************************************************************************/
65501 +t_Error FM_MAC_AddExactMatchMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
65502 +
65503 +/**************************************************************************//**
65504 + @Function FM_MAC_RemovelExactMatchMacAddr
65505 +
65506 + @Description Remove a uni cast or multi cast mac address.
65507 +
65508 + @Param[in] h_FmMac - A handle to a FM Module.
65509 + @Param[in] p_EnetAddr - MAC Address to remove
65510 +
65511 + @Return E_OK on success; Error code otherwise..
65512 +
65513 + @Cautions Allowed only after FM_MAC_Init().
65514 +*//***************************************************************************/
65515 +t_Error FM_MAC_RemovelExactMatchMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
65516 +
65517 +/**************************************************************************//**
65518 + @Function FM_MAC_SetPromiscuous
65519 +
65520 + @Description Enable/Disable MAC Promiscuous mode for ALL mac addresses.
65521 +
65522 + @Param[in] h_FmMac - A handle to a FM MAC Module.
65523 + @Param[in] enable - TRUE to enable or FALSE to disable.
65524 +
65525 + @Return E_OK on success; Error code otherwise.
65526 +
65527 + @Cautions Allowed only after FM_MAC_Init().
65528 +*//***************************************************************************/
65529 +t_Error FM_MAC_SetPromiscuous(t_Handle h_FmMac, bool enable);
65530 +
65531 +/**************************************************************************//**
65532 + @Function FM_MAC_AdjustLink
65533 +
65534 + @Description Adjusts the Ethernet link with new speed/duplex setup.
65535 + This routine is relevant for dTSEC and mEMAC.
65536 + In case of mEMAC, this routine is also used for manual
65537 + re-configuration of RGMII speed and duplex mode for
65538 + RGMII PHYs not supporting in-band status information
65539 + to MAC.
65540 +
65541 + @Param[in] h_FmMac - A handle to a FM Module.
65542 + @Param[in] speed - Ethernet speed.
65543 + @Param[in] fullDuplex - TRUE for full-duplex mode;
65544 + FALSE for half-duplex mode.
65545 +
65546 + @Return E_OK on success; Error code otherwise.
65547 +*//***************************************************************************/
65548 +t_Error FM_MAC_AdjustLink(t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex);
65549 +
65550 +/**************************************************************************//**
65551 + @Function FM_MAC_RestartAutoneg
65552 +
65553 + @Description Restarts the auto-negotiation process.
65554 + When auto-negotiation process is invoked under traffic the
65555 + auto-negotiation process between the internal SGMII PHY and the
65556 + external PHY does not always complete successfully. Calling this
65557 + function will restart the auto-negotiation process that will end
65558 + successfully. It is recommended to call this function after issuing
65559 + auto-negotiation restart command to the Eth Phy.
65560 + This routine is relevant only for dTSEC.
65561 +
65562 + @Param[in] h_FmMac - A handle to a FM Module.
65563 +
65564 + @Return E_OK on success; Error code otherwise.
65565 +*//***************************************************************************/
65566 +t_Error FM_MAC_RestartAutoneg(t_Handle h_FmMac);
65567 +
65568 +/**************************************************************************//**
65569 + @Function FM_MAC_GetId
65570 +
65571 + @Description Return the MAC ID
65572 +
65573 + @Param[in] h_FmMac - A handle to a FM Module.
65574 + @Param[out] p_MacId - MAC ID of device
65575 +
65576 + @Return E_OK on success; Error code otherwise.
65577 +
65578 + @Cautions Allowed only after FM_MAC_Init().
65579 +*//***************************************************************************/
65580 +t_Error FM_MAC_GetId(t_Handle h_FmMac, uint32_t *p_MacId);
65581 +
65582 +/**************************************************************************//**
65583 + @Function FM_MAC_GetVesrion
65584 +
65585 + @Description Return Mac HW chip version
65586 +
65587 + @Param[in] h_FmMac - A handle to a FM Module.
65588 + @Param[out] p_MacVresion - Mac version as defined by the chip
65589 +
65590 + @Return E_OK on success; Error code otherwise.
65591 +
65592 + @Cautions Allowed only after FM_MAC_Init().
65593 +*//***************************************************************************/
65594 +t_Error FM_MAC_GetVesrion(t_Handle h_FmMac, uint32_t *p_MacVresion);
65595 +
65596 +/**************************************************************************//**
65597 + @Function FM_MAC_MII_WritePhyReg
65598 +
65599 + @Description Write data into Phy Register
65600 +
65601 + @Param[in] h_FmMac - A handle to a FM Module.
65602 + @Param[in] phyAddr - Phy Address on the MII bus
65603 + @Param[in] reg - Register Number.
65604 + @Param[in] data - Data to write.
65605 +
65606 + @Return E_OK on success; Error code otherwise.
65607 +
65608 + @Cautions Allowed only after FM_MAC_Init().
65609 +*//***************************************************************************/
65610 +t_Error FM_MAC_MII_WritePhyReg(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t data);
65611 +
65612 +/**************************************************************************//**
65613 + @Function FM_MAC_MII_ReadPhyReg
65614 +
65615 + @Description Read data from Phy Register
65616 +
65617 + @Param[in] h_FmMac - A handle to a FM Module.
65618 + @Param[in] phyAddr - Phy Address on the MII bus
65619 + @Param[in] reg - Register Number.
65620 + @Param[out] p_Data - Data from PHY.
65621 +
65622 + @Return E_OK on success; Error code otherwise.
65623 +
65624 + @Cautions Allowed only after FM_MAC_Init().
65625 +*//***************************************************************************/
65626 +t_Error FM_MAC_MII_ReadPhyReg(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);
65627 +
65628 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
65629 +/**************************************************************************//**
65630 + @Function FM_MAC_DumpRegs
65631 +
65632 + @Description Dump internal registers
65633 +
65634 + @Param[in] h_FmMac - A handle to a FM Module.
65635 +
65636 + @Return E_OK on success; Error code otherwise.
65637 +
65638 + @Cautions Allowed only after FM_MAC_Init().
65639 +*//***************************************************************************/
65640 +t_Error FM_MAC_DumpRegs(t_Handle h_FmMac);
65641 +#endif /* (defined(DEBUG_ERRORS) && ... */
65642 +
65643 +/** @} */ /* end of FM_mac_runtime_control_grp group */
65644 +/** @} */ /* end of FM_mac_grp group */
65645 +/** @} */ /* end of FM_grp group */
65646 +
65647 +
65648 +#endif /* __FM_MAC_EXT_H */
65649 --- /dev/null
65650 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_macsec_ext.h
65651 @@ -0,0 +1,1271 @@
65652 +/*
65653 + * Copyright 2008-2015 Freescale Semiconductor Inc.
65654 + *
65655 + * Redistribution and use in source and binary forms, with or without
65656 + * modification, are permitted provided that the following conditions are met:
65657 + * * Redistributions of source code must retain the above copyright
65658 + * notice, this list of conditions and the following disclaimer.
65659 + * * Redistributions in binary form must reproduce the above copyright
65660 + * notice, this list of conditions and the following disclaimer in the
65661 + * documentation and/or other materials provided with the distribution.
65662 + * * Neither the name of Freescale Semiconductor nor the
65663 + * names of its contributors may be used to endorse or promote products
65664 + * derived from this software without specific prior written permission.
65665 + *
65666 + *
65667 + * ALTERNATIVELY, this software may be distributed under the terms of the
65668 + * GNU General Public License ("GPL") as published by the Free Software
65669 + * Foundation, either version 2 of that License or (at your option) any
65670 + * later version.
65671 + *
65672 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
65673 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
65674 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
65675 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
65676 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
65677 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
65678 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
65679 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65680 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
65681 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65682 + */
65683 +
65684 +/**************************************************************************//**
65685 + @File fm_macsec_ext.h
65686 +
65687 + @Description FM MACSEC ...
65688 +*//***************************************************************************/
65689 +#ifndef __FM_MACSEC_EXT_H
65690 +#define __FM_MACSEC_EXT_H
65691 +
65692 +#include "std_ext.h"
65693 +
65694 +
65695 +/**************************************************************************//**
65696 + @Group FM_grp Frame Manager API
65697 +
65698 + @Description FM API functions, definitions and enums
65699 +
65700 + @{
65701 +*//***************************************************************************/
65702 +
65703 +/**************************************************************************//**
65704 + @Group FM_MACSEC_grp FM MACSEC
65705 +
65706 + @Description FM MACSEC API functions, definitions and enums
65707 +
65708 + @{
65709 +*//***************************************************************************/
65710 +
65711 +/**************************************************************************//**
65712 + @Description MACSEC Exceptions
65713 +*//***************************************************************************/
65714 +typedef enum e_FmMacsecExceptions {
65715 + e_FM_MACSEC_EX_SINGLE_BIT_ECC, /**< Single bit ECC error */
65716 + e_FM_MACSEC_EX_MULTI_BIT_ECC /**< Multi bit ECC error */
65717 +} e_FmMacsecExceptions;
65718 +
65719 +
65720 +/**************************************************************************//**
65721 + @Group FM_MACSEC_init_grp FM-MACSEC Initialization Unit
65722 +
65723 + @Description FM MACSEC Initialization Unit
65724 +
65725 + @{
65726 +*//***************************************************************************/
65727 +
65728 +/**************************************************************************//**
65729 + @Function t_FmMacsecExceptionsCallback
65730 +
65731 + @Description Exceptions user callback routine, will be called upon an
65732 + exception passing the exception identification.
65733 +
65734 + @Param[in] h_App A handle to an application layer object; This handle
65735 + will be passed by the driver upon calling this callback.
65736 + @Param[in] exception The exception.
65737 +*//***************************************************************************/
65738 +typedef void (t_FmMacsecExceptionsCallback) ( t_Handle h_App,
65739 + e_FmMacsecExceptions exception);
65740 +
65741 +
65742 +/**************************************************************************//**
65743 + @Description FM MACSEC config input
65744 +*//***************************************************************************/
65745 +typedef struct t_FmMacsecParams {
65746 + t_Handle h_Fm; /**< A handle to the FM object related to */
65747 + bool guestMode; /**< Partition-id */
65748 + union {
65749 + struct {
65750 + uint8_t fmMacId; /**< FM MAC id */
65751 + } guestParams;
65752 +
65753 + struct {
65754 + uintptr_t baseAddr; /**< Base of memory mapped FM MACSEC registers */
65755 + t_Handle h_FmMac; /**< A handle to the FM MAC object related to */
65756 + t_FmMacsecExceptionsCallback *f_Exception; /**< Exception Callback Routine */
65757 + t_Handle h_App; /**< A handle to an application layer object; This handle will
65758 + be passed by the driver upon calling the above callbacks */
65759 + } nonGuestParams;
65760 + };
65761 +} t_FmMacsecParams;
65762 +
65763 +/**************************************************************************//**
65764 + @Function FM_MACSEC_Config
65765 +
65766 + @Description Creates descriptor for the FM MACSEC module;
65767 +
65768 + The routine returns a handle (descriptor) to the FM MACSEC object;
65769 + This descriptor must be passed as first parameter to all other
65770 + FM MACSEC function calls;
65771 +
65772 + No actual initialization or configuration of FM MACSEC hardware is
65773 + done by this routine.
65774 +
65775 + @Param[in] p_FmMacsecParam Pointer to data structure of parameters.
65776 +
65777 + @Retval Handle to FM MACSEC object, or NULL for Failure.
65778 +*//***************************************************************************/
65779 +t_Handle FM_MACSEC_Config(t_FmMacsecParams *p_FmMacsecParam);
65780 +
65781 +/**************************************************************************//**
65782 + @Function FM_MACSEC_Init
65783 +
65784 + @Description Initializes the FM MACSEC module.
65785 +
65786 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
65787 +
65788 + @Return E_OK on success; Error code otherwise.
65789 +*//***************************************************************************/
65790 +t_Error FM_MACSEC_Init(t_Handle h_FmMacsec);
65791 +
65792 +/**************************************************************************//**
65793 + @Function FM_MACSEC_Free
65794 +
65795 + @Description Frees all resources that were assigned to FM MACSEC module;
65796 +
65797 + Calling this routine invalidates the descriptor.
65798 +
65799 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
65800 +
65801 + @Return E_OK on success; Error code otherwise.
65802 +*//***************************************************************************/
65803 +t_Error FM_MACSEC_Free(t_Handle h_FmMacsec);
65804 +
65805 +
65806 +/**************************************************************************//**
65807 + @Group FM_MACSEC_advanced_init_grp FM-MACSEC Advanced Configuration Unit
65808 +
65809 + @Description Configuration functions used to change default values.
65810 +
65811 + @{
65812 +*//***************************************************************************/
65813 +
65814 +/**************************************************************************//**
65815 + @Description enum for unknown sci frame treatment
65816 +*//***************************************************************************/
65817 +typedef enum e_FmMacsecUnknownSciFrameTreatment {
65818 + e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DISCARD_BOTH = 0, /**< Controlled port - Strict mode */
65819 + e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DISCARD_UNCONTROLLED_DELIVER_OR_DISCARD_CONTROLLED, /**< If C bit clear deliver on controlled port, else discard
65820 + Controlled port - Check or Disable mode */
65821 + e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DELIVER_UNCONTROLLED_DISCARD_CONTROLLED, /**< Controlled port - Strict mode */
65822 + e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DELIVER_OR_DISCARD_UNCONTROLLED_DELIVER_OR_DISCARD_CONTROLLED /**< If C bit set deliver on uncontrolled port and discard on controlled port,
65823 + else discard on uncontrolled port and deliver on controlled port
65824 + Controlled port - Check or Disable mode */
65825 +} e_FmMacsecUnknownSciFrameTreatment;
65826 +
65827 +/**************************************************************************//**
65828 + @Description enum for untag frame treatment
65829 +*//***************************************************************************/
65830 +typedef enum e_FmMacsecUntagFrameTreatment {
65831 + e_FM_MACSEC_UNTAG_FRAME_TREATMENT_DELIVER_UNCONTROLLED_DISCARD_CONTROLLED = 0, /**< Controlled port - Strict mode */
65832 + e_FM_MACSEC_UNTAG_FRAME_TREATMENT_DISCARD_BOTH, /**< Controlled port - Strict mode */
65833 + e_FM_MACSEC_UNTAG_FRAME_TREATMENT_DISCARD_UNCONTROLLED_DELIVER_CONTROLLED_UNMODIFIED /**< Controlled port - Strict mode */
65834 +} e_FmMacsecUntagFrameTreatment;
65835 +
65836 +/**************************************************************************//**
65837 + @Function FM_MACSEC_ConfigUnknownSciFrameTreatment
65838 +
65839 + @Description Change the treatment for received frames with unknown sci from its default
65840 + configuration [DEFAULT_unknownSciFrameTreatment].
65841 +
65842 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
65843 + @Param[in] treatMode The selected mode.
65844 +
65845 + @Return E_OK on success; Error code otherwise.
65846 +
65847 + @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
65848 +*//***************************************************************************/
65849 +t_Error FM_MACSEC_ConfigUnknownSciFrameTreatment(t_Handle h_FmMacsec, e_FmMacsecUnknownSciFrameTreatment treatMode);
65850 +
65851 +/**************************************************************************//**
65852 + @Function FM_MACSEC_ConfigInvalidTagsFrameTreatment
65853 +
65854 + @Description Change the treatment for received frames with invalid tags or
65855 + a zero value PN or an invalid ICV from its default configuration
65856 + [DEFAULT_invalidTagsFrameTreatment].
65857 +
65858 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
65859 + @Param[in] deliverUncontrolled If True deliver on the uncontrolled port, else discard;
65860 + In both cases discard on the controlled port;
65861 + this provide Strict, Check or Disable mode.
65862 +
65863 + @Return E_OK on success; Error code otherwise.
65864 +
65865 + @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
65866 +*//***************************************************************************/
65867 +t_Error FM_MACSEC_ConfigInvalidTagsFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled);
65868 +
65869 +/**************************************************************************//**
65870 + @Function FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment
65871 +
65872 + @Description Change the treatment for received frames with the Encryption bit
65873 + set and the Changed Text bit clear from its default configuration
65874 + [DEFAULT_encryptWithNoChangedTextFrameTreatment].
65875 +
65876 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
65877 + @Param[in] discardUncontrolled If True discard on the uncontrolled port, else deliver;
65878 + In both cases discard on the controlled port;
65879 + this provide Strict, Check or Disable mode.
65880 +
65881 + @Return E_OK on success; Error code otherwise.
65882 +
65883 + @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
65884 +*//***************************************************************************/
65885 +t_Error FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment(t_Handle h_FmMacsec, bool discardUncontrolled);
65886 +
65887 +/**************************************************************************//**
65888 + @Function FM_MACSEC_ConfigChangedTextWithNoEncryptFrameTreatment
65889 +
65890 + @Description Change the treatment for received frames with the Encryption bit
65891 + clear and the Changed Text bit set from its default configuration
65892 + [DEFAULT_changedTextWithNoEncryptFrameTreatment].
65893 +
65894 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
65895 + @Param[in] deliverUncontrolled If True deliver on the uncontrolled port, else discard;
65896 + In both cases discard on the controlled port;
65897 + this provide Strict, Check or Disable mode.
65898 +
65899 + @Return E_OK on success; Error code otherwise.
65900 +
65901 + @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
65902 +*//***************************************************************************/
65903 +t_Error FM_MACSEC_ConfigChangedTextWithNoEncryptFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled);
65904 +
65905 +/**************************************************************************//**
65906 + @Function FM_MACSEC_ConfigUntagFrameTreatment
65907 +
65908 + @Description Change the treatment for received frames without the MAC security tag (SecTAG)
65909 + from its default configuration [DEFAULT_untagFrameTreatment].
65910 +
65911 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
65912 + @Param[in] treatMode The selected mode.
65913 +
65914 + @Return E_OK on success; Error code otherwise.
65915 +
65916 + @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
65917 +*//***************************************************************************/
65918 +t_Error FM_MACSEC_ConfigUntagFrameTreatment(t_Handle h_FmMacsec, e_FmMacsecUntagFrameTreatment treatMode);
65919 +
65920 +/**************************************************************************//**
65921 + @Function FM_MACSEC_ConfigOnlyScbIsSetFrameTreatment
65922 +
65923 + @Description Change the treatment for received frames with only SCB bit set
65924 + from its default configuration [DEFAULT_onlyScbIsSetFrameTreatment].
65925 +
65926 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
65927 + @Param[in] deliverUncontrolled If True deliver on the uncontrolled port, else discard;
65928 + In both cases discard on the controlled port;
65929 + this provide Strict, Check or Disable mode.
65930 +
65931 + @Return E_OK on success; Error code otherwise.
65932 +
65933 + @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
65934 +*//***************************************************************************/
65935 +t_Error FM_MACSEC_ConfigOnlyScbIsSetFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled);
65936 +
65937 +/**************************************************************************//**
65938 + @Function FM_MACSEC_ConfigPnExhaustionThreshold
65939 +
65940 + @Description It's provide the ability to configure a PN exhaustion threshold;
65941 + When the NextPn crosses this value an interrupt event
65942 + is asserted to warn that the active SA should re-key.
65943 +
65944 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
65945 + @Param[in] pnExhThr If the threshold is reached, an interrupt event
65946 + is asserted to re-key.
65947 +
65948 + @Return E_OK on success; Error code otherwise.
65949 +
65950 + @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
65951 +*//***************************************************************************/
65952 +t_Error FM_MACSEC_ConfigPnExhaustionThreshold(t_Handle h_FmMacsec, uint32_t pnExhThr);
65953 +
65954 +/**************************************************************************//**
65955 + @Function FM_MACSEC_ConfigKeysUnreadable
65956 +
65957 + @Description Turn on privacy mode; All the keys and their hash values can't be read any more;
65958 + Can not be cleared unless hard reset.
65959 +
65960 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
65961 +
65962 + @Return E_OK on success; Error code otherwise.
65963 +
65964 + @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
65965 +*//***************************************************************************/
65966 +t_Error FM_MACSEC_ConfigKeysUnreadable(t_Handle h_FmMacsec);
65967 +
65968 +/**************************************************************************//**
65969 + @Function FM_MACSEC_ConfigSectagWithoutSCI
65970 +
65971 + @Description Promise that all generated Sectag will be without SCI included.
65972 +
65973 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
65974 +
65975 + @Return E_OK on success; Error code otherwise.
65976 +
65977 + @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
65978 +*//***************************************************************************/
65979 +t_Error FM_MACSEC_ConfigSectagWithoutSCI(t_Handle h_FmMacsec);
65980 +
65981 +/**************************************************************************//**
65982 + @Function FM_MACSEC_ConfigException
65983 +
65984 + @Description Calling this routine changes the internal driver data base
65985 + from its default selection of exceptions enablement;
65986 + By default all exceptions are enabled.
65987 +
65988 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
65989 + @Param[in] exception The exception to be selected.
65990 + @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
65991 +
65992 + @Return E_OK on success; Error code otherwise.
65993 +
65994 + @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
65995 +*//***************************************************************************/
65996 +t_Error FM_MACSEC_ConfigException(t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable);
65997 +
65998 +/** @} */ /* end of FM_MACSEC_advanced_init_grp group */
65999 +/** @} */ /* end of FM_MACSEC_init_grp group */
66000 +
66001 +
66002 +/**************************************************************************//**
66003 + @Group FM_MACSEC_runtime_control_grp FM-MACSEC Runtime Control Data Unit
66004 +
66005 + @Description FM MACSEC runtime control data unit API functions, definitions and enums.
66006 +
66007 + @{
66008 +*//***************************************************************************/
66009 +
66010 +/**************************************************************************//**
66011 + @Function FM_MACSEC_GetRevision
66012 +
66013 + @Description Return MACSEC HW chip revision
66014 +
66015 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
66016 + @Param[out] p_MacsecRevision MACSEC revision as defined by the chip.
66017 +
66018 + @Return E_OK on success; Error code otherwise.
66019 +
66020 + @Cautions Allowed only after FM_MACSEC_Init().
66021 +*//***************************************************************************/
66022 +t_Error FM_MACSEC_GetRevision(t_Handle h_FmMacsec, uint32_t *p_MacsecRevision);
66023 +
66024 +/**************************************************************************//**
66025 + @Function FM_MACSEC_Enable
66026 +
66027 + @Description This routine should be called after MACSEC is initialized for enabling all
66028 + MACSEC engines according to their existing configuration.
66029 +
66030 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
66031 +
66032 + @Return E_OK on success; Error code otherwise.
66033 +
66034 + @Cautions Allowed only following FM_MACSEC_Init() and when MACSEC is disabled.
66035 +*//***************************************************************************/
66036 +t_Error FM_MACSEC_Enable(t_Handle h_FmMacsec);
66037 +
66038 +/**************************************************************************//**
66039 + @Function FM_MACSEC_Disable
66040 +
66041 + @Description This routine may be called when MACSEC is enabled in order to
66042 + disable all MACSEC engines; The MACSEC is working in bypass mode.
66043 +
66044 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
66045 +
66046 + @Return E_OK on success; Error code otherwise.
66047 +
66048 + @Cautions Allowed only following FM_MACSEC_Init() and when MACSEC is enabled.
66049 +*//***************************************************************************/
66050 +t_Error FM_MACSEC_Disable(t_Handle h_FmMacsec);
66051 +
66052 +/**************************************************************************//**
66053 + @Function FM_MACSEC_SetException
66054 +
66055 + @Description Calling this routine enables/disables the specified exception.
66056 +
66057 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
66058 + @Param[in] exception The exception to be selected.
66059 + @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
66060 +
66061 + @Return E_OK on success; Error code otherwise.
66062 +
66063 + @Cautions Allowed only following FM_MACSEC_Init().
66064 +*//***************************************************************************/
66065 +t_Error FM_MACSEC_SetException(t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable);
66066 +
66067 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
66068 +/**************************************************************************//**
66069 + @Function FM_MACSEC_DumpRegs
66070 +
66071 + @Description Dump internal registers.
66072 +
66073 + @Param[in] h_FmMacsec - FM MACSEC module descriptor.
66074 +
66075 + @Return E_OK on success; Error code otherwise.
66076 +
66077 + @Cautions Allowed only after FM_MACSEC_Init().
66078 +*//***************************************************************************/
66079 +t_Error FM_MACSEC_DumpRegs(t_Handle h_FmMacsec);
66080 +#endif /* (defined(DEBUG_ERRORS) && ... */
66081 +
66082 +#ifdef VERIFICATION_SUPPORT
66083 +/********************* VERIFICATION ONLY ********************************/
66084 +/**************************************************************************//**
66085 + @Function FM_MACSEC_BackdoorSet
66086 +
66087 + @Description Set register of the MACSEC memory map
66088 +
66089 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
66090 + @Param[out] offset Register offset.
66091 + @Param[out] value Value to write.
66092 +
66093 +
66094 + @Return None
66095 +
66096 + @Cautions Allowed only following FM_MACSEC_Init().
66097 +*//***************************************************************************/
66098 +t_Error FM_MACSEC_BackdoorSet(t_Handle h_FmMacsec, uint32_t offset, uint32_t value);
66099 +
66100 +/**************************************************************************//**
66101 + @Function FM_MACSEC_BackdoorGet
66102 +
66103 + @Description Read from register of the MACSEC memory map.
66104 +
66105 + @Param[in] h_FmMacsec FM MACSEC module descriptor.
66106 + @Param[out] offset Register offset.
66107 +
66108 + @Return Value read
66109 +
66110 + @Cautions Allowed only following FM_MACSEC_Init().
66111 +*//***************************************************************************/
66112 +uint32_t FM_MACSEC_BackdoorGet(t_Handle h_FmMacsec, uint32_t offset);
66113 +#endif /* VERIFICATION_SUPPORT */
66114 +
66115 +/** @} */ /* end of FM_MACSEC_runtime_control_grp group */
66116 +
66117 +
66118 +/**************************************************************************//**
66119 + @Group FM_MACSEC_SECY_grp FM-MACSEC SecY
66120 +
66121 + @Description FM-MACSEC SecY API functions, definitions and enums
66122 +
66123 + @{
66124 +*//***************************************************************************/
66125 +
66126 +typedef uint8_t macsecSAKey_t[32];
66127 +typedef uint64_t macsecSCI_t;
66128 +typedef uint8_t macsecAN_t;
66129 +
66130 +/**************************************************************************//**
66131 +@Description MACSEC SECY Cipher Suite
66132 +*//***************************************************************************/
66133 +typedef enum e_FmMacsecSecYCipherSuite {
66134 + e_FM_MACSEC_SECY_GCM_AES_128 = 0, /**< GCM-AES-128 */
66135 +#if (DPAA_VERSION >= 11)
66136 + e_FM_MACSEC_SECY_GCM_AES_256 /**< GCM-AES-256 */
66137 +#endif /* (DPAA_VERSION >= 11) */
66138 +} e_FmMacsecSecYCipherSuite;
66139 +
66140 +/**************************************************************************//**
66141 + @Description MACSEC SECY Exceptions
66142 +*//***************************************************************************/
66143 +typedef enum e_FmMacsecSecYExceptions {
66144 + e_FM_MACSEC_SECY_EX_FRAME_DISCARDED /**< Frame Discarded */
66145 +} e_FmMacsecSecYExceptions;
66146 +
66147 +/**************************************************************************//**
66148 + @Description MACSEC SECY Events
66149 +*//***************************************************************************/
66150 +typedef enum e_FmMacsecSecYEvents {
66151 + e_FM_MACSEC_SECY_EV_NEXT_PN /**< Next Packet Number exhaustion threshold reached */
66152 +} e_FmMacsecSecYEvents;
66153 +
66154 +/**************************************************************************//**
66155 + @Collection MACSEC SECY Frame Discarded Descriptor error
66156 +*//***************************************************************************/
66157 +typedef uint8_t macsecTxScFrameDiscardedErrSelect_t; /**< typedef for defining Frame Discarded Descriptor errors */
66158 +
66159 +#define FM_MACSEC_SECY_TX_SC_FRM_DISCAR_ERR_NEXT_PN_ZERO 0x8000 /**< NextPn == 0 */
66160 +#define FM_MACSEC_SECY_TX_SC_FRM_DISCAR_ERR_SC_DISBALE 0x4000 /**< SC is disable */
66161 +/* @} */
66162 +
66163 +/**************************************************************************//**
66164 + @Function t_FmMacsecSecYExceptionsCallback
66165 +
66166 + @Description Exceptions user callback routine, will be called upon an
66167 + exception passing the exception identification.
66168 +
66169 + @Param[in] h_App A handle to an application layer object; This handle
66170 + will be passed by the driver upon calling this callback.
66171 + @Param[in] exception The exception.
66172 +*//***************************************************************************/
66173 +typedef void (t_FmMacsecSecYExceptionsCallback) ( t_Handle h_App,
66174 + e_FmMacsecSecYExceptions exception);
66175 +
66176 +/**************************************************************************//**
66177 + @Function t_FmMacsecSecYEventsCallback
66178 +
66179 + @Description Events user callback routine, will be called upon an
66180 + event passing the event identification.
66181 +
66182 + @Param[in] h_App A handle to an application layer object; This handle
66183 + will be passed by the driver upon calling this callback.
66184 + @Param[in] event The event.
66185 +*//***************************************************************************/
66186 +typedef void (t_FmMacsecSecYEventsCallback) ( t_Handle h_App,
66187 + e_FmMacsecSecYEvents event);
66188 +
66189 +/**************************************************************************//**
66190 + @Description RFC2863 MIB
66191 +*//***************************************************************************/
66192 +typedef struct t_MIBStatistics {
66193 + uint64_t ifInOctets; /**< Total number of byte received */
66194 + uint64_t ifInPkts; /**< Total number of packets received */
66195 + uint64_t ifInMcastPkts; /**< Total number of multicast frame received */
66196 + uint64_t ifInBcastPkts; /**< Total number of broadcast frame received */
66197 + uint64_t ifInDiscards; /**< Frames received, but discarded due to problems within the MAC RX :
66198 + - InPktsNoTag,
66199 + - InPktsLate,
66200 + - InPktsOverrun */
66201 + uint64_t ifInErrors; /**< Number of frames received with error:
66202 + - InPktsBadTag,
66203 + - InPktsNoSCI,
66204 + - InPktsNotUsingSA
66205 + - InPktsNotValid */
66206 + uint64_t ifOutOctets; /**< Total number of byte sent */
66207 + uint64_t ifOutPkts; /**< Total number of packets sent */
66208 + uint64_t ifOutMcastPkts; /**< Total number of multicast frame sent */
66209 + uint64_t ifOutBcastPkts; /**< Total number of multicast frame sent */
66210 + uint64_t ifOutDiscards; /**< Frames received, but discarded due to problems within the MAC TX N/A! */
66211 + uint64_t ifOutErrors; /**< Number of frames transmitted with error:
66212 + - FIFO Overflow Error
66213 + - FIFO Underflow Error
66214 + - Other */
66215 +} t_MIBStatistics;
66216 +
66217 +/**************************************************************************//**
66218 + @Description MACSEC SecY Rx SA Statistics
66219 +*//***************************************************************************/
66220 +typedef struct t_FmMacsecSecYRxSaStatistics {
66221 + uint32_t inPktsOK; /**< The number of frames with resolved SCI, have passed all
66222 + frame validation frame validation with the validateFrame not set to disable */
66223 + uint32_t inPktsInvalid; /**< The number of frames with resolved SCI, that have failed frame
66224 + validation with the validateFrame set to check */
66225 + uint32_t inPktsNotValid; /**< The number of frames with resolved SCI, discarded on the controlled port,
66226 + that have failed frame validation with the validateFrame set to strict or the c bit is set */
66227 + uint32_t inPktsNotUsingSA; /**< The number of frames received with resolved SCI and discarded on disabled or
66228 + not provisioned SA with validateFrame in the strict mode or the C bit is set */
66229 + uint32_t inPktsUnusedSA; /**< The number of frames received with resolved SCI on disabled or not provisioned SA
66230 + with validateFrame not in the strict mode and the C bit is cleared */
66231 +} t_FmMacsecSecYRxSaStatistics;
66232 +
66233 +/**************************************************************************//**
66234 + @Description MACSEC SecY Tx SA Statistics
66235 +*//***************************************************************************/
66236 +typedef struct t_FmMacsecSecYTxSaStatistics {
66237 + uint64_t outPktsProtected; /**< The number of frames, that the user of the controlled port requested to
66238 + be transmitted, which were integrity protected */
66239 + uint64_t outPktsEncrypted; /**< The number of frames, that the user of the controlled port requested to
66240 + be transmitted, which were confidentiality protected */
66241 +} t_FmMacsecSecYTxSaStatistics;
66242 +
66243 +/**************************************************************************//**
66244 + @Description MACSEC SecY Rx SC Statistics
66245 +*//***************************************************************************/
66246 +typedef struct t_FmMacsecSecYRxScStatistics {
66247 + uint64_t inPktsUnchecked; /**< The number of frames with resolved SCI, delivered to the user of a controlled port,
66248 + that are not validated with the validateFrame set to disable */
66249 + uint64_t inPktsDelayed; /**< The number of frames with resolved SCI, delivered to the user of a controlled port,
66250 + that have their PN smaller than the lowest_PN with the validateFrame set to
66251 + disable or replayProtect disabled */
66252 + uint64_t inPktsLate; /**< The number of frames with resolved SCI, discarded on the controlled port,
66253 + that have their PN smaller than the lowest_PN with the validateFrame set to
66254 + Check or Strict and replayProtect enabled */
66255 + uint64_t inPktsOK; /**< The number of frames with resolved SCI, have passed all
66256 + frame validation frame validation with the validateFrame not set to disable */
66257 + uint64_t inPktsInvalid; /**< The number of frames with resolved SCI, that have failed frame
66258 + validation with the validateFrame set to check */
66259 + uint64_t inPktsNotValid; /**< The number of frames with resolved SCI, discarded on the controlled port,
66260 + that have failed frame validation with the validateFrame set to strict or the c bit is set */
66261 + uint64_t inPktsNotUsingSA; /**< The number of frames received with resolved SCI and discarded on disabled or
66262 + not provisioned SA with validateFrame in the strict mode or the C bit is set */
66263 + uint64_t inPktsUnusedSA; /**< The number of frames received with resolved SCI on disabled or not provisioned SA
66264 + with validateFrame not in the strict mode and the C bit is cleared */
66265 +} t_FmMacsecSecYRxScStatistics;
66266 +
66267 +/**************************************************************************//**
66268 + @Description MACSEC SecY Tx SC Statistics
66269 +*//***************************************************************************/
66270 +typedef struct t_FmMacsecSecYTxScStatistics {
66271 + uint64_t outPktsProtected; /**< The number of frames, that the user of the controlled port requested to
66272 + be transmitted, which were integrity protected */
66273 + uint64_t outPktsEncrypted; /**< The number of frames, that the user of the controlled port requested to
66274 + be transmitted, which were confidentiality protected */
66275 +} t_FmMacsecSecYTxScStatistics;
66276 +
66277 +/**************************************************************************//**
66278 + @Description MACSEC SecY Statistics
66279 +*//***************************************************************************/
66280 +typedef struct t_FmMacsecSecYStatistics {
66281 + t_MIBStatistics mibCtrlStatistics; /**< Controlled port MIB statistics */
66282 + t_MIBStatistics mibNonCtrlStatistics; /**< Uncontrolled port MIB statistics */
66283 +/* Frame verification statistics */
66284 + uint64_t inPktsUntagged; /**< The number of received packets without the MAC security tag
66285 + (SecTAG) with validateFrames which is not in the strict mode */
66286 + uint64_t inPktsNoTag; /**< The number of received packets discarded without the
66287 + MAC security tag (SecTAG) with validateFrames which is in the strict mode */
66288 + uint64_t inPktsBadTag; /**< The number of received packets discarded with an invalid
66289 + SecTAG or a zero value PN or an invalid ICV */
66290 + uint64_t inPktsUnknownSCI; /**< The number of received packets with unknown SCI with the
66291 + condition : validateFrames is not in the strict mode and the
66292 + C bit in the SecTAG is not set */
66293 + uint64_t inPktsNoSCI; /**< The number of received packets discarded with unknown SCI
66294 + information with the condition : validateFrames is in the strict mode
66295 + or the C bit in the SecTAG is set */
66296 + uint64_t inPktsOverrun; /**< The number of packets discarded because the number of
66297 + received packets exceeded the cryptographic performance capabilities */
66298 +/* Frame validation statistics */
66299 + uint64_t inOctetsValidated; /**< The number of octets of plaintext recovered from received frames with
66300 + resolved SCI that were integrity protected but not encrypted */
66301 + uint64_t inOctetsDecrypted; /**< The number of octets of plaintext recovered from received frames with
66302 + resolved SCI that were integrity protected and encrypted */
66303 +/* Frame generation statistics */
66304 + uint64_t outPktsUntagged; /**< The number of frames, that the user of the controlled port requested to
66305 + be transmitted, with protectFrame false */
66306 + uint64_t outPktsTooLong; /**< The number of frames, that the user of the controlled port requested to
66307 + be transmitted, discarded due to length being larger than Maximum Frame Length (MACSEC_MFL) */
66308 +/* Frame protection statistics */
66309 + uint64_t outOctetsProtected; /**< The number of octets of User Data in transmitted frames that were
66310 + integrity protected but not encrypted */
66311 + uint64_t outOctetsEncrypted; /**< The number of octets of User Data in transmitted frames that were
66312 + both integrity protected and encrypted */
66313 +} t_FmMacsecSecYStatistics;
66314 +
66315 +
66316 +/**************************************************************************//**
66317 + @Description MACSEC SecY SC Params
66318 +*//***************************************************************************/
66319 +typedef struct t_FmMacsecSecYSCParams {
66320 + macsecSCI_t sci; /**< The secure channel identification of the SC */
66321 + e_FmMacsecSecYCipherSuite cipherSuite; /**< Cipher suite to be used for the SC */
66322 +} t_FmMacsecSecYSCParams;
66323 +
66324 +/**************************************************************************//**
66325 + @Group FM_MACSEC_SECY_init_grp FM-MACSEC SecY Initialization Unit
66326 +
66327 + @Description FM-MACSEC SecY Initialization Unit
66328 +
66329 + @{
66330 +*//***************************************************************************/
66331 +
66332 +/**************************************************************************//**
66333 + @Description enum for validate frames
66334 +*//***************************************************************************/
66335 +typedef enum e_FmMacsecValidFrameBehavior {
66336 + e_FM_MACSEC_VALID_FRAME_BEHAVIOR_DISABLE = 0, /**< disable the validation function */
66337 + e_FM_MACSEC_VALID_FRAME_BEHAVIOR_CHECK, /**< enable the validation function but only for checking
66338 + without filtering out invalid frames */
66339 + e_FM_MACSEC_VALID_FRAME_BEHAVIOR_STRICT /**< enable the validation function and also strictly filter
66340 + out those invalid frames */
66341 +} e_FmMacsecValidFrameBehavior;
66342 +
66343 +/**************************************************************************//**
66344 + @Description enum for sci insertion
66345 +*//***************************************************************************/
66346 +typedef enum e_FmMacsecSciInsertionMode {
66347 + e_FM_MACSEC_SCI_INSERTION_MODE_EXPLICIT_SECTAG = 0, /**< explicit sci in the sectag */
66348 + e_FM_MACSEC_SCI_INSERTION_MODE_EXPLICIT_MAC_SA, /**< mac sa is overwritten with the sci*/
66349 + e_FM_MACSEC_SCI_INSERTION_MODE_IMPLICT_PTP /**< implicit point-to-point sci (pre-shared) */
66350 +} e_FmMacsecSciInsertionMode;
66351 +
66352 +/**************************************************************************//**
66353 + @Description FM MACSEC SecY config input
66354 +*//***************************************************************************/
66355 +typedef struct t_FmMacsecSecYParams {
66356 + t_Handle h_FmMacsec; /**< A handle to the FM MACSEC object */
66357 + t_FmMacsecSecYSCParams txScParams; /**< Tx SC Params */
66358 + uint32_t numReceiveChannels; /**< Number of receive channels dedicated to this SecY */
66359 + t_FmMacsecSecYExceptionsCallback *f_Exception; /**< Callback routine to be called by the driver upon SecY exception */
66360 + t_FmMacsecSecYEventsCallback *f_Event; /**< Callback routine to be called by the driver upon SecY event */
66361 + t_Handle h_App; /**< A handle to an application layer object; This handle will
66362 + be passed by the driver upon calling the above callbacks */
66363 +} t_FmMacsecSecYParams;
66364 +
66365 +/**************************************************************************//**
66366 + @Function FM_MACSEC_SECY_Config
66367 +
66368 + @Description Creates descriptor for the FM MACSEC SECY module;
66369 +
66370 + The routine returns a handle (descriptor) to the FM MACSEC SECY object;
66371 + This descriptor must be passed as first parameter to all other
66372 + FM MACSEC SECY function calls;
66373 + No actual initialization or configuration of FM MACSEC SecY hardware is
66374 + done by this routine.
66375 +
66376 + @Param[in] p_FmMacsecSecYParam Pointer to data structure of parameters.
66377 +
66378 + @Return Handle to FM MACSEC SECY object, or NULL for Failure.
66379 +*//***************************************************************************/
66380 +t_Handle FM_MACSEC_SECY_Config(t_FmMacsecSecYParams *p_FmMacsecSecYParam);
66381 +
66382 +/**************************************************************************//**
66383 + @Function FM_MACSEC_SECY_Init
66384 +
66385 + @Description Initializes the FM MACSEC SECY module.
66386 +
66387 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66388 +
66389 + @Return E_OK on success; Error code otherwise.
66390 +*//***************************************************************************/
66391 +t_Error FM_MACSEC_SECY_Init(t_Handle h_FmMacsecSecY);
66392 +
66393 +/**************************************************************************//**
66394 + @Function FM_MACSEC_SECY_Free
66395 +
66396 + @Description Frees all resources that were assigned to FM MACSEC SECY module.
66397 +
66398 + Calling this routine invalidates the descriptor.
66399 +
66400 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66401 +
66402 + @Return E_OK on success; Error code otherwise.
66403 +*//***************************************************************************/
66404 +t_Error FM_MACSEC_SECY_Free(t_Handle h_FmMacsecSecY);
66405 +
66406 +/**************************************************************************//**
66407 + @Group FM_MACSEC_SECY_advanced_init_grp FM-MACSEC SecY Advanced Configuration Unit
66408 +
66409 + @Description Configuration functions used to change default values.
66410 +
66411 + @{
66412 +*//***************************************************************************/
66413 +
66414 +/**************************************************************************//**
66415 + @Function FM_MACSEC_SECY_ConfigSciInsertionMode
66416 +
66417 + @Description Calling this routine changes the SCI-insertion-mode in the
66418 + internal driver data base from its default configuration
66419 + [DEFAULT_sciInsertionMode]
66420 +
66421 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66422 + @Param[in] sciInsertionMode Sci insertion mode
66423 +
66424 + @Return E_OK on success; Error code otherwise.
66425 +
66426 + @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init();
66427 +
66428 +*//***************************************************************************/
66429 +t_Error FM_MACSEC_SECY_ConfigSciInsertionMode(t_Handle h_FmMacsecSecY, e_FmMacsecSciInsertionMode sciInsertionMode);
66430 +
66431 +/**************************************************************************//**
66432 + @Function FM_MACSEC_SECY_ConfigProtectFrames
66433 +
66434 + @Description Calling this routine changes the protect-frame mode in the
66435 + internal driver data base from its default configuration
66436 + [DEFAULT_protectFrames]
66437 +
66438 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66439 + @Param[in] protectFrames If FALSE, frames are transmitted without modification
66440 +
66441 + @Return E_OK on success; Error code otherwise.
66442 +
66443 + @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init();
66444 +
66445 +*//***************************************************************************/
66446 +t_Error FM_MACSEC_SECY_ConfigProtectFrames(t_Handle h_FmMacsecSecY, bool protectFrames);
66447 +
66448 +/**************************************************************************//**
66449 + @Function FM_MACSEC_SECY_ConfigReplayWindow
66450 +
66451 + @Description Calling this routine changes the replay-window settings in the
66452 + internal driver data base from its default configuration
66453 + [DEFAULT_replayEnable], [DEFAULT_replayWindow]
66454 +
66455 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66456 + @Param[in] replayProtect; Replay protection function mode
66457 + @Param[in] replayWindow; The size of the replay window
66458 +
66459 + @Return E_OK on success; Error code otherwise.
66460 +
66461 + @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init();
66462 +
66463 +*//***************************************************************************/
66464 +t_Error FM_MACSEC_SECY_ConfigReplayWindow(t_Handle h_FmMacsecSecY, bool replayProtect, uint32_t replayWindow);
66465 +
66466 +/**************************************************************************//**
66467 + @Function FM_MACSEC_SECY_ConfigValidationMode
66468 +
66469 + @Description Calling this routine changes the frame-validation-behavior mode
66470 + in the internal driver data base from its default configuration
66471 + [DEFAULT_validateFrames]
66472 +
66473 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66474 + @Param[in] validateFrames Validation function mode
66475 +
66476 + @Return E_OK on success; Error code otherwise.
66477 +
66478 + @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init();
66479 +
66480 +*//***************************************************************************/
66481 +t_Error FM_MACSEC_SECY_ConfigValidationMode(t_Handle h_FmMacsecSecY, e_FmMacsecValidFrameBehavior validateFrames);
66482 +
66483 +/**************************************************************************//**
66484 + @Function FM_MACSEC_SECY_ConfigConfidentiality
66485 +
66486 + @Description Calling this routine changes the confidentiality settings in the
66487 + internal driver data base from its default configuration
66488 + [DEFAULT_confidentialityEnable], [DEFAULT_confidentialityOffset]
66489 +
66490 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66491 + @Param[in] confidentialityEnable TRUE - confidentiality protection and integrity protection
66492 + FALSE - no confidentiality protection, only integrity protection
66493 + @Param[in] confidentialityOffset The number of initial octets of each MSDU without confidentiality protection
66494 + common values are 0, 30, and 50
66495 +
66496 + @Return E_OK on success; Error code otherwise.
66497 +
66498 + @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init();
66499 +
66500 +*//***************************************************************************/
66501 +t_Error FM_MACSEC_SECY_ConfigConfidentiality(t_Handle h_FmMacsecSecY, bool confidentialityEnable, uint16_t confidentialityOffset);
66502 +
66503 +/**************************************************************************//**
66504 + @Function FM_MACSEC_SECY_ConfigPointToPoint
66505 +
66506 + @Description configure this SecY to work in point-to-point mode, means that
66507 + it will have only one rx sc;
66508 +
66509 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66510 +
66511 + @Return E_OK on success; Error code otherwise.
66512 +
66513 + @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init();
66514 + Can be called only once in a system; only the first secY that will call this
66515 + routine will be able to operate in Point-To-Point mode.
66516 +*//***************************************************************************/
66517 +t_Error FM_MACSEC_SECY_ConfigPointToPoint(t_Handle h_FmMacsecSecY);
66518 +
66519 +/**************************************************************************//**
66520 + @Function FM_MACSEC_SECY_ConfigException
66521 +
66522 + @Description Calling this routine changes the internal driver data base
66523 + from its default selection of exceptions enablement;
66524 + By default all exceptions are enabled.
66525 +
66526 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66527 + @Param[in] exception The exception to be selected.
66528 + @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
66529 +
66530 + @Return E_OK on success; Error code otherwise.
66531 +
66532 + @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init().
66533 +*//***************************************************************************/
66534 +t_Error FM_MACSEC_SECY_ConfigException(t_Handle h_FmMacsecSecY, e_FmMacsecSecYExceptions exception, bool enable);
66535 +
66536 +/**************************************************************************//**
66537 + @Function FM_MACSEC_SECY_ConfigEvent
66538 +
66539 + @Description Calling this routine changes the internal driver data base
66540 + from its default selection of events enablement;
66541 + By default all events are enabled.
66542 +
66543 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66544 + @Param[in] event The event to be selected.
66545 + @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
66546 +
66547 + @Return E_OK on success; Error code otherwise.
66548 +
66549 + @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init().
66550 +*//***************************************************************************/
66551 +t_Error FM_MACSEC_SECY_ConfigEvent(t_Handle h_FmMacsecSecY, e_FmMacsecSecYEvents event, bool enable);
66552 +
66553 +/** @} */ /* end of FM_MACSEC_SECY_advanced_init_grp group */
66554 +/** @} */ /* end of FM_MACSEC_SECY_init_grp group */
66555 +
66556 +
66557 +/**************************************************************************//**
66558 + @Group FM_MACSEC_SECY_runtime_control_grp FM-MACSEC SecY Runtime Control Unit
66559 +
66560 + @Description FM MACSEC SECY Runtime control unit API functions, definitions and enums.
66561 +
66562 + @{
66563 +*//***************************************************************************/
66564 +
66565 +/**************************************************************************//**
66566 + @Function FM_MACSEC_SECY_CreateRxSc
66567 +
66568 + @Description Create a receive secure channel.
66569 +
66570 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66571 + @Param[in] scParams secure channel params.
66572 +
66573 + @Return E_OK on success; Error code otherwise.
66574 +
66575 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66576 +*//***************************************************************************/
66577 +t_Handle FM_MACSEC_SECY_CreateRxSc(t_Handle h_FmMacsecSecY, t_FmMacsecSecYSCParams *p_ScParams);
66578 +
66579 +/**************************************************************************//**
66580 + @Function FM_MACSEC_SECY_DeleteRxSc
66581 +
66582 + @Description Deleting an initialized secure channel.
66583 +
66584 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66585 + @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
66586 +
66587 + @Return E_OK on success; Error code otherwise.
66588 +
66589 + @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSc().
66590 +*//***************************************************************************/
66591 +t_Error FM_MACSEC_SECY_DeleteRxSc(t_Handle h_FmMacsecSecY, t_Handle h_Sc);
66592 +
66593 +/**************************************************************************//**
66594 + @Function FM_MACSEC_SECY_CreateRxSa
66595 +
66596 + @Description Create a receive secure association for the secure channel;
66597 + the SA cannot be used to receive frames until FM_MACSEC_SECY_RxSaEnableReceive is called.
66598 +
66599 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66600 + @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
66601 + @Param[in] an association number represent the SA.
66602 + @Param[in] lowestPn the lowest acceptable PN value for a received frame.
66603 + @Param[in] key the desired key for this SA.
66604 +
66605 + @Return E_OK on success; Error code otherwise.
66606 +
66607 + @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSc().
66608 +*//***************************************************************************/
66609 +t_Error FM_MACSEC_SECY_CreateRxSa(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, uint32_t lowestPn, macsecSAKey_t key);
66610 +
66611 +/**************************************************************************//**
66612 + @Function FM_MACSEC_SECY_DeleteRxSa
66613 +
66614 + @Description Deleting an initialized secure association.
66615 +
66616 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66617 + @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
66618 + @Param[in] an association number represent the SA.
66619 +
66620 + @Return E_OK on success; Error code otherwise.
66621 +
66622 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66623 +*//***************************************************************************/
66624 +t_Error FM_MACSEC_SECY_DeleteRxSa(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an);
66625 +
66626 +/**************************************************************************//**
66627 + @Function FM_MACSEC_SECY_RxSaEnableReceive
66628 +
66629 + @Description Enabling the SA to receive frames.
66630 +
66631 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66632 + @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
66633 + @Param[in] an association number represent the SA.
66634 +
66635 + @Return E_OK on success; Error code otherwise.
66636 +
66637 + @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSa().
66638 +*//***************************************************************************/
66639 +t_Error FM_MACSEC_SECY_RxSaEnableReceive(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an);
66640 +
66641 +/**************************************************************************//**
66642 + @Function FM_MACSEC_SECY_RxSaDisableReceive
66643 +
66644 + @Description Disabling the SA from receive frames.
66645 +
66646 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66647 + @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
66648 + @Param[in] an association number represent the SA.
66649 +
66650 + @Return E_OK on success; Error code otherwise.
66651 +
66652 + @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSa().
66653 +*//***************************************************************************/
66654 +t_Error FM_MACSEC_SECY_RxSaDisableReceive(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an);
66655 +
66656 +/**************************************************************************//**
66657 + @Function FM_MACSEC_SECY_RxSaUpdateNextPn
66658 +
66659 + @Description Update the next packet number expected on RX;
66660 + The value of nextPN shall be set to the greater of its existing value and the
66661 + supplied of updtNextPN (802.1AE-2006 10.7.15).
66662 +
66663 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66664 + @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
66665 + @Param[in] an association number represent the SA.
66666 + @Param[in] updtNextPN the next PN value for a received frame.
66667 +
66668 + @Return E_OK on success; Error code otherwise.
66669 +
66670 + @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSa().
66671 +*//***************************************************************************/
66672 +t_Error FM_MACSEC_SECY_RxSaUpdateNextPn(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, uint32_t updtNextPN);
66673 +
66674 +/**************************************************************************//**
66675 + @Function FM_MACSEC_SECY_RxSaUpdateLowestPn
66676 +
66677 + @Description Update the lowest packet number expected on RX;
66678 + The value of lowestPN shall be set to the greater of its existing value and the
66679 + supplied of updtLowestPN (802.1AE-2006 10.7.15).
66680 +
66681 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66682 + @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
66683 + @Param[in] an association number represent the SA.
66684 + @Param[in] updtLowestPN the lowest PN acceptable value for a received frame.
66685 +
66686 + @Return E_OK on success; Error code otherwise.
66687 +
66688 + @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSa().
66689 +*//***************************************************************************/
66690 +t_Error FM_MACSEC_SECY_RxSaUpdateLowestPn(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, uint32_t updtLowestPN);
66691 +
66692 +/**************************************************************************//**
66693 + @Function FM_MACSEC_SECY_RxSaModifyKey
66694 +
66695 + @Description Modify the current key of the SA with a new one.
66696 +
66697 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66698 + @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
66699 + @Param[in] an association number represent the SA.
66700 + @Param[in] key new key to replace the current key.
66701 +
66702 + @Return E_OK on success; Error code otherwise.
66703 +
66704 + @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSa().
66705 +*//***************************************************************************/
66706 +t_Error FM_MACSEC_SECY_RxSaModifyKey(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, macsecSAKey_t key);
66707 +
66708 +/**************************************************************************//**
66709 + @Function FM_MACSEC_SECY_CreateTxSa
66710 +
66711 + @Description Create a transmit secure association for the secure channel;
66712 + the SA cannot be used to transmit frames until FM_MACSEC_SECY_TxSaSetActivate is called;
66713 + Only one SA can be active at a time.
66714 +
66715 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66716 + @Param[in] an association number represent the SA.
66717 + @Param[in] key the desired key for this SA.
66718 +
66719 + @Return E_OK on success; Error code otherwise.
66720 +
66721 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66722 +*//***************************************************************************/
66723 +t_Error FM_MACSEC_SECY_CreateTxSa(t_Handle h_FmMacsecSecY, macsecAN_t an, macsecSAKey_t key);
66724 +
66725 +/**************************************************************************//**
66726 + @Function FM_MACSEC_SECY_DeleteTxSa
66727 +
66728 + @Description Deleting an initialized secure association.
66729 +
66730 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66731 + @Param[in] an association number represent the SA.
66732 +
66733 + @Return E_OK on success; Error code otherwise.
66734 +
66735 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66736 +*//***************************************************************************/
66737 +t_Error FM_MACSEC_SECY_DeleteTxSa(t_Handle h_FmMacsecSecY, macsecAN_t an);
66738 +
66739 +/**************************************************************************//**
66740 + @Function FM_MACSEC_SECY_TxSaModifyKey
66741 +
66742 + @Description Modify the key of the inactive SA with a new one.
66743 +
66744 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66745 + @Param[in] nextActiveAn association number represent the next SA to be activated.
66746 + @Param[in] key new key to replace the current key.
66747 +
66748 + @Return E_OK on success; Error code otherwise.
66749 +
66750 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66751 +*//***************************************************************************/
66752 +t_Error FM_MACSEC_SECY_TxSaModifyKey(t_Handle h_FmMacsecSecY, macsecAN_t nextActiveAn, macsecSAKey_t key);
66753 +
66754 +/**************************************************************************//**
66755 + @Function FM_MACSEC_SECY_TxSaSetActive
66756 +
66757 + @Description Set this SA to the active SA to be used on TX for SC;
66758 + only one SA can be active at a time.
66759 +
66760 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66761 + @Param[in] an association number represent the SA.
66762 +
66763 + @Return E_OK on success; Error code otherwise.
66764 +
66765 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66766 +*//***************************************************************************/
66767 +t_Error FM_MACSEC_SECY_TxSaSetActive(t_Handle h_FmMacsecSecY, macsecAN_t an);
66768 +
66769 +/**************************************************************************//**
66770 + @Function FM_MACSEC_SECY_TxSaGetActive
66771 +
66772 + @Description Get the active SA that being used for TX.
66773 +
66774 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66775 + @Param[out] p_An the active an.
66776 +
66777 + @Return E_OK on success; Error code otherwise.
66778 +
66779 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66780 +*//***************************************************************************/
66781 +t_Error FM_MACSEC_SECY_TxSaGetActive(t_Handle h_FmMacsecSecY, macsecAN_t *p_An);
66782 +
66783 +/**************************************************************************//**
66784 + @Function FM_MACSEC_SECY_GetStatistics
66785 +
66786 + @Description get all statistics counters.
66787 +
66788 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66789 + @Param[in] p_Statistics Structure with statistics.
66790 +
66791 + @Return E_OK on success; Error code otherwise.
66792 +
66793 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66794 +*//***************************************************************************/
66795 +t_Error FM_MACSEC_SECY_GetStatistics(t_Handle h_FmMacsecSecY, t_FmMacsecSecYStatistics *p_Statistics);
66796 +
66797 +/**************************************************************************//**
66798 + @Function FM_MACSEC_SECY_RxScGetStatistics
66799 +
66800 + @Description get all statistics counters.
66801 +
66802 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66803 + @Param[in] h_Sc Rx Sc handle.
66804 + @Param[in] p_Statistics Structure with statistics.
66805 +
66806 + @Return E_OK on success; Error code otherwise.
66807 +
66808 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66809 +*//***************************************************************************/
66810 +t_Error FM_MACSEC_SECY_RxScGetStatistics(t_Handle h_FmMacsecSecY, t_Handle h_Sc, t_FmMacsecSecYRxScStatistics *p_Statistics);
66811 +
66812 +/**************************************************************************//**
66813 + @Function FM_MACSEC_SECY_RxSaGetStatistics
66814 +
66815 + @Description get all statistics counters
66816 +
66817 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66818 + @Param[in] h_Sc Rx Sc handle.
66819 + @Param[in] an association number represent the SA.
66820 + @Param[in] p_Statistics Structure with statistics.
66821 +
66822 + @Return E_OK on success; Error code otherwise.
66823 +
66824 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66825 +*//***************************************************************************/
66826 +t_Error FM_MACSEC_SECY_RxSaGetStatistics(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, t_FmMacsecSecYRxSaStatistics *p_Statistics);
66827 +
66828 +/**************************************************************************//**
66829 + @Function FM_MACSEC_SECY_TxScGetStatistics
66830 +
66831 + @Description get all statistics counters.
66832 +
66833 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66834 + @Param[in] p_Statistics Structure with statistics.
66835 +
66836 + @Return E_OK on success; Error code otherwise.
66837 +
66838 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66839 +*//***************************************************************************/
66840 +t_Error FM_MACSEC_SECY_TxScGetStatistics(t_Handle h_FmMacsecSecY, t_FmMacsecSecYTxScStatistics *p_Statistics);
66841 +
66842 +/**************************************************************************//**
66843 + @Function FM_MACSEC_SECY_TxSaGetStatistics
66844 +
66845 + @Description get all statistics counters.
66846 +
66847 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66848 + @Param[in] an association number represent the SA.
66849 + @Param[in] p_Statistics Structure with statistics.
66850 +
66851 + @Return E_OK on success; Error code otherwise.
66852 +
66853 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66854 +*//***************************************************************************/
66855 +t_Error FM_MACSEC_SECY_TxSaGetStatistics(t_Handle h_FmMacsecSecY, macsecAN_t an, t_FmMacsecSecYTxSaStatistics *p_Statistics);
66856 +
66857 +/**************************************************************************//**
66858 + @Function FM_MACSEC_SECY_SetException
66859 +
66860 + @Description Calling this routine enables/disables the specified exception.
66861 +
66862 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66863 + @Param[in] exception The exception to be selected.
66864 + @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
66865 +
66866 + @Return E_OK on success; Error code otherwise.
66867 +
66868 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66869 +*//***************************************************************************/
66870 +t_Error FM_MACSEC_SECY_SetException(t_Handle h_FmMacsecSecY, e_FmMacsecExceptions exception, bool enable);
66871 +
66872 +/**************************************************************************//**
66873 + @Function FM_MACSEC_SECY_SetEvent
66874 +
66875 + @Description Calling this routine enables/disables the specified event.
66876 +
66877 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66878 + @Param[in] event The event to be selected.
66879 + @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
66880 +
66881 + @Return E_OK on success; Error code otherwise.
66882 +
66883 + @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init().
66884 +*//***************************************************************************/
66885 +t_Error FM_MACSEC_SECY_SetEvent(t_Handle h_FmMacsecSecY, e_FmMacsecSecYEvents event, bool enable);
66886 +
66887 +/**************************************************************************//**
66888 + @Function FM_MACSEC_SECY_GetRxScPhysId
66889 +
66890 + @Description return the physical id of the Secure Channel.
66891 +
66892 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66893 + @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
66894 + @Param[out] p_ScPhysId the SC physical id.
66895 +
66896 + @Return E_OK on success; Error code otherwise.
66897 +
66898 + @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSc().
66899 +*//***************************************************************************/
66900 +t_Error FM_MACSEC_SECY_GetRxScPhysId(t_Handle h_FmMacsecSecY, t_Handle h_Sc, uint32_t *p_ScPhysId);
66901 +
66902 +/**************************************************************************//**
66903 + @Function FM_MACSEC_SECY_GetTxScPhysId
66904 +
66905 + @Description return the physical id of the Secure Channel.
66906 +
66907 + @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
66908 + @Param[out] p_ScPhysId the SC physical id.
66909 +
66910 + @Return E_OK on success; Error code otherwise.
66911 +
66912 + @Cautions Allowed only following FM_MACSEC_SECY_Init().
66913 +*//***************************************************************************/
66914 +t_Error FM_MACSEC_SECY_GetTxScPhysId(t_Handle h_FmMacsecSecY, uint32_t *p_ScPhysId);
66915 +
66916 +/** @} */ /* end of FM_MACSEC_SECY_runtime_control_grp group */
66917 +/** @} */ /* end of FM_MACSEC_SECY_grp group */
66918 +/** @} */ /* end of FM_MACSEC_grp group */
66919 +/** @} */ /* end of FM_grp group */
66920 +
66921 +
66922 +#endif /* __FM_MACSEC_EXT_H */
66923 --- /dev/null
66924 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_muram_ext.h
66925 @@ -0,0 +1,170 @@
66926 +/*
66927 + * Copyright 2008-2012 Freescale Semiconductor Inc.
66928 + *
66929 + * Redistribution and use in source and binary forms, with or without
66930 + * modification, are permitted provided that the following conditions are met:
66931 + * * Redistributions of source code must retain the above copyright
66932 + * notice, this list of conditions and the following disclaimer.
66933 + * * Redistributions in binary form must reproduce the above copyright
66934 + * notice, this list of conditions and the following disclaimer in the
66935 + * documentation and/or other materials provided with the distribution.
66936 + * * Neither the name of Freescale Semiconductor nor the
66937 + * names of its contributors may be used to endorse or promote products
66938 + * derived from this software without specific prior written permission.
66939 + *
66940 + *
66941 + * ALTERNATIVELY, this software may be distributed under the terms of the
66942 + * GNU General Public License ("GPL") as published by the Free Software
66943 + * Foundation, either version 2 of that License or (at your option) any
66944 + * later version.
66945 + *
66946 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
66947 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
66948 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
66949 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
66950 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
66951 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
66952 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
66953 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
66954 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
66955 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66956 + */
66957 +
66958 +
66959 +/**************************************************************************//**
66960 + @File fm_muram_ext.h
66961 +
66962 + @Description FM MURAM Application Programming Interface.
66963 +*//***************************************************************************/
66964 +#ifndef __FM_MURAM_EXT
66965 +#define __FM_MURAM_EXT
66966 +
66967 +#include "error_ext.h"
66968 +#include "std_ext.h"
66969 +
66970 +
66971 +/**************************************************************************//**
66972 +
66973 + @Group FM_grp Frame Manager API
66974 +
66975 + @Description FM API functions, definitions and enums
66976 +
66977 + @{
66978 +*//***************************************************************************/
66979 +
66980 +/**************************************************************************//**
66981 + @Group FM_muram_grp FM MURAM
66982 +
66983 + @Description FM MURAM API functions, definitions and enums
66984 +
66985 + @{
66986 +*//***************************************************************************/
66987 +
66988 +/**************************************************************************//**
66989 + @Group FM_muram_init_grp FM MURAM Initialization Unit
66990 +
66991 + @Description FM MURAM initialization API functions, definitions and enums
66992 +
66993 + @{
66994 +*//***************************************************************************/
66995 +
66996 +/**************************************************************************//**
66997 + @Function FM_MURAM_ConfigAndInit
66998 +
66999 + @Description Creates partition in the MURAM.
67000 +
67001 + The routine returns a handle (descriptor) to the MURAM partition.
67002 + This descriptor must be passed as first parameter to all other
67003 + FM-MURAM function calls.
67004 +
67005 + No actual initialization or configuration of FM_MURAM hardware is
67006 + done by this routine.
67007 +
67008 + @Param[in] baseAddress - Pointer to base of memory mapped FM-MURAM.
67009 + @Param[in] size - Size of the FM-MURAM partition.
67010 +
67011 + @Return Handle to FM-MURAM object, or NULL for Failure.
67012 +*//***************************************************************************/
67013 +t_Handle FM_MURAM_ConfigAndInit(uintptr_t baseAddress, uint32_t size);
67014 +
67015 +/**************************************************************************//**
67016 + @Function FM_MURAM_Free
67017 +
67018 + @Description Frees all resources that were assigned to FM-MURAM module.
67019 +
67020 + Calling this routine invalidates the descriptor.
67021 +
67022 + @Param[in] h_FmMuram - FM-MURAM module descriptor.
67023 +
67024 + @Return E_OK on success; Error code otherwise.
67025 +*//***************************************************************************/
67026 +t_Error FM_MURAM_Free(t_Handle h_FmMuram);
67027 +
67028 +/** @} */ /* end of FM_muram_init_grp group */
67029 +
67030 +
67031 +/**************************************************************************//**
67032 + @Group FM_muram_ctrl_grp FM MURAM Control Unit
67033 +
67034 + @Description FM MURAM control API functions, definitions and enums
67035 +
67036 + @{
67037 +*//***************************************************************************/
67038 +
67039 +/**************************************************************************//**
67040 + @Function FM_MURAM_AllocMem
67041 +
67042 + @Description Allocate some memory from FM-MURAM partition.
67043 +
67044 + @Param[in] h_FmMuram - FM-MURAM module descriptor.
67045 + @Param[in] size - size of the memory to be allocated.
67046 + @Param[in] align - Alignment of the memory.
67047 +
67048 + @Return address of the allocated memory; NULL otherwise.
67049 +*//***************************************************************************/
67050 +void * FM_MURAM_AllocMem(t_Handle h_FmMuram, uint32_t size, uint32_t align);
67051 +
67052 +/**************************************************************************//**
67053 + @Function FM_MURAM_AllocMemForce
67054 +
67055 + @Description Allocate some specific memory from FM-MURAM partition (according
67056 + to base).
67057 +
67058 + @Param[in] h_FmMuram - FM-MURAM module descriptor.
67059 + @Param[in] base - the desired base-address to be allocated.
67060 + @Param[in] size - size of the memory to be allocated.
67061 +
67062 + @Return address of the allocated memory; NULL otherwise.
67063 +*//***************************************************************************/
67064 +void * FM_MURAM_AllocMemForce(t_Handle h_FmMuram, uint64_t base, uint32_t size);
67065 +
67066 +/**************************************************************************//**
67067 + @Function FM_MURAM_FreeMem
67068 +
67069 + @Description Free an allocated memory from FM-MURAM partition.
67070 +
67071 + @Param[in] h_FmMuram - FM-MURAM module descriptor.
67072 + @Param[in] ptr - A pointer to an allocated memory.
67073 +
67074 + @Return E_OK on success; Error code otherwise.
67075 +*//***************************************************************************/
67076 +t_Error FM_MURAM_FreeMem(t_Handle h_FmMuram, void *ptr);
67077 +
67078 +/**************************************************************************//**
67079 + @Function FM_MURAM_GetFreeMemSize
67080 +
67081 + @Description Returns the size (in bytes) of free MURAM memory.
67082 +
67083 + @Param[in] h_FmMuram - FM-MURAM module descriptor.
67084 +
67085 + @Return Free MURAM memory size in bytes.
67086 +*//***************************************************************************/
67087 +uint64_t FM_MURAM_GetFreeMemSize(t_Handle h_FmMuram);
67088 +
67089 +/** @} */ /* end of FM_muram_ctrl_grp group */
67090 +/** @} */ /* end of FM_muram_grp group */
67091 +/** @} */ /* end of FM_grp group */
67092 +
67093 +
67094 +
67095 +#endif /* __FM_MURAM_EXT */
67096 --- /dev/null
67097 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_pcd_ext.h
67098 @@ -0,0 +1,3974 @@
67099 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
67100 + * All rights reserved.
67101 + *
67102 + * Redistribution and use in source and binary forms, with or without
67103 + * modification, are permitted provided that the following conditions are met:
67104 + * * Redistributions of source code must retain the above copyright
67105 + * notice, this list of conditions and the following disclaimer.
67106 + * * Redistributions in binary form must reproduce the above copyright
67107 + * notice, this list of conditions and the following disclaimer in the
67108 + * documentation and/or other materials provided with the distribution.
67109 + * * Neither the name of Freescale Semiconductor nor the
67110 + * names of its contributors may be used to endorse or promote products
67111 + * derived from this software without specific prior written permission.
67112 + *
67113 + *
67114 + * ALTERNATIVELY, this software may be distributed under the terms of the
67115 + * GNU General Public License ("GPL") as published by the Free Software
67116 + * Foundation, either version 2 of that License or (at your option) any
67117 + * later version.
67118 + *
67119 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
67120 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
67121 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
67122 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
67123 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
67124 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
67125 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
67126 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
67127 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
67128 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67129 + */
67130 +
67131 +
67132 +/**************************************************************************//**
67133 + @File fm_pcd_ext.h
67134 +
67135 + @Description FM PCD API definitions
67136 +*//***************************************************************************/
67137 +#ifndef __FM_PCD_EXT
67138 +#define __FM_PCD_EXT
67139 +
67140 +#include "std_ext.h"
67141 +#include "net_ext.h"
67142 +#include "list_ext.h"
67143 +#include "fm_ext.h"
67144 +#include "fsl_fman_kg.h"
67145 +
67146 +
67147 +/**************************************************************************//**
67148 + @Group FM_grp Frame Manager API
67149 +
67150 + @Description Frame Manager Application Programming Interface
67151 +
67152 + @{
67153 +*//***************************************************************************/
67154 +
67155 +/**************************************************************************//**
67156 + @Group FM_PCD_grp FM PCD
67157 +
67158 + @Description Frame Manager PCD (Parse-Classify-Distribute) API.
67159 +
67160 + The FM PCD module is responsible for the initialization of all
67161 + global classifying FM modules. This includes the parser general and
67162 + common registers, the key generator global and common registers,
67163 + and the policer global and common registers.
67164 + In addition, the FM PCD SW module will initialize all required
67165 + key generator schemes, coarse classification flows, and policer
67166 + profiles. When FM module is configured to work with one of these
67167 + entities, it will register to it using the FM PORT API. The PCD
67168 + module will manage the PCD resources - i.e. resource management of
67169 + KeyGen schemes, etc.
67170 +
67171 + @{
67172 +*//***************************************************************************/
67173 +
67174 +/**************************************************************************//**
67175 + @Collection General PCD defines
67176 +*//***************************************************************************/
67177 +#define FM_PCD_MAX_NUM_OF_PRIVATE_HDRS 2 /**< Number of units/headers saved for user */
67178 +
67179 +#define FM_PCD_PRS_NUM_OF_HDRS 16 /**< Number of headers supported by HW parser */
67180 +#define FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS (32 - FM_PCD_MAX_NUM_OF_PRIVATE_HDRS)
67181 + /**< Number of distinction units is limited by
67182 + register size (32 bits) minus reserved bits
67183 + for private headers. */
67184 +#define FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS 4 /**< Maximum number of interchangeable headers
67185 + in a distinction unit */
67186 +#define FM_PCD_KG_NUM_OF_GENERIC_REGS FM_KG_NUM_OF_GENERIC_REGS /**< Total number of generic KeyGen registers */
67187 +#define FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY 35 /**< Max number allowed on any configuration;
67188 + For HW implementation reasons, in most
67189 + cases less than this will be allowed; The
67190 + driver will return an initialization error
67191 + if resource is unavailable. */
67192 +#define FM_PCD_KG_NUM_OF_EXTRACT_MASKS 4 /**< Total number of masks allowed on KeyGen extractions. */
67193 +#define FM_PCD_KG_NUM_OF_DEFAULT_GROUPS 16 /**< Number of default value logical groups */
67194 +
67195 +#define FM_PCD_PRS_NUM_OF_LABELS 32 /**< Maximum number of SW parser labels */
67196 +#define FM_SW_PRS_MAX_IMAGE_SIZE (FM_PCD_SW_PRS_SIZE /*- FM_PCD_PRS_SW_OFFSET -FM_PCD_PRS_SW_TAIL_SIZE*/-FM_PCD_PRS_SW_PATCHES_SIZE)
67197 + /**< Maximum size of SW parser code */
67198 +
67199 +#define FM_PCD_MAX_MANIP_INSRT_TEMPLATE_SIZE 128 /**< Maximum size of insertion template for
67200 + insert manipulation */
67201 +
67202 +#if (DPAA_VERSION >= 11)
67203 +#define FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES 64 /**< Maximum possible entries for frame replicator group */
67204 +#endif /* (DPAA_VERSION >= 11) */
67205 +/* @} */
67206 +
67207 +
67208 +/**************************************************************************//**
67209 + @Group FM_PCD_init_grp FM PCD Initialization Unit
67210 +
67211 + @Description Frame Manager PCD Initialization Unit API
67212 +
67213 + @{
67214 +*//***************************************************************************/
67215 +
67216 +/**************************************************************************//**
67217 + @Description PCD counters
67218 +*//***************************************************************************/
67219 +typedef enum e_FmPcdCounters {
67220 + e_FM_PCD_KG_COUNTERS_TOTAL, /**< KeyGen counter */
67221 + e_FM_PCD_PLCR_COUNTERS_RED, /**< Policer counter - counts the total number of RED packets that exit the Policer. */
67222 + e_FM_PCD_PLCR_COUNTERS_YELLOW, /**< Policer counter - counts the total number of YELLOW packets that exit the Policer. */
67223 + e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED, /**< Policer counter - counts the number of packets that changed color to RED by the Policer;
67224 + This is a subset of e_FM_PCD_PLCR_COUNTERS_RED packet count, indicating active color changes. */
67225 + e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW, /**< Policer counter - counts the number of packets that changed color to YELLOW by the Policer;
67226 + This is a subset of e_FM_PCD_PLCR_COUNTERS_YELLOW packet count, indicating active color changes. */
67227 + e_FM_PCD_PLCR_COUNTERS_TOTAL, /**< Policer counter - counts the total number of packets passed in the Policer. */
67228 + e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH, /**< Policer counter - counts the number of packets with length mismatch. */
67229 + e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH, /**< Parser counter - counts the number of times the parser block is dispatched. */
67230 + e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED, /**< Parser counter - counts the number of times L2 parse result is returned (including errors). */
67231 + e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED, /**< Parser counter - counts the number of times L3 parse result is returned (including errors). */
67232 + e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED, /**< Parser counter - counts the number of times L4 parse result is returned (including errors). */
67233 + e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED, /**< Parser counter - counts the number of times SHIM parse result is returned (including errors). */
67234 + e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter - counts the number of times L2 parse result is returned with errors. */
67235 + e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter - counts the number of times L3 parse result is returned with errors. */
67236 + e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter - counts the number of times L4 parse result is returned with errors. */
67237 + e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter - counts the number of times SHIM parse result is returned with errors. */
67238 + e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES, /**< Parser counter - counts the number of cycles spent executing soft parser instruction (including stall cycles). */
67239 + e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES, /**< Parser counter - counts the number of cycles stalled waiting for parser internal memory reads while executing soft parser instruction. */
67240 + e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES, /**< Parser counter - counts the number of cycles spent executing hard parser (including stall cycles). */
67241 + e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES, /**< MURAM counter - counts the number of cycles while performing FMan Memory read. */
67242 + e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES, /**< MURAM counter - counts the number of cycles stalled while performing FMan Memory read. */
67243 + e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES, /**< MURAM counter - counts the number of cycles while performing FMan Memory write. */
67244 + e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES, /**< MURAM counter - counts the number of cycles stalled while performing FMan Memory write. */
67245 + e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES /**< FPM counter - counts the number of cycles stalled while performing a FPM Command. */
67246 +} e_FmPcdCounters;
67247 +
67248 +/**************************************************************************//**
67249 + @Description PCD interrupts
67250 +*//***************************************************************************/
67251 +typedef enum e_FmPcdExceptions {
67252 + e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC, /**< KeyGen double-bit ECC error is detected on internal memory read access. */
67253 + e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW, /**< KeyGen scheme configuration error indicating a key size larger than 56 bytes. */
67254 + e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC, /**< Policer double-bit ECC error has been detected on PRAM read access. */
67255 + e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR, /**< Policer access to a non-initialized profile has been detected. */
67256 + e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE, /**< Policer RAM self-initialization complete */
67257 + e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE, /**< Policer atomic action complete */
67258 + e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC, /**< Parser double-bit ECC error */
67259 + e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC /**< Parser single-bit ECC error */
67260 +} e_FmPcdExceptions;
67261 +
67262 +
67263 +/**************************************************************************//**
67264 + @Description Exceptions user callback routine, will be called upon an
67265 + exception passing the exception identification.
67266 +
67267 + @Param[in] h_App - User's application descriptor.
67268 + @Param[in] exception - The exception.
67269 + *//***************************************************************************/
67270 +typedef void (t_FmPcdExceptionCallback) (t_Handle h_App, e_FmPcdExceptions exception);
67271 +
67272 +/**************************************************************************//**
67273 + @Description Exceptions user callback routine, will be called upon an exception
67274 + passing the exception identification.
67275 +
67276 + @Param[in] h_App - User's application descriptor.
67277 + @Param[in] exception - The exception.
67278 + @Param[in] index - id of the relevant source (may be scheme or profile id).
67279 + *//***************************************************************************/
67280 +typedef void (t_FmPcdIdExceptionCallback) ( t_Handle h_App,
67281 + e_FmPcdExceptions exception,
67282 + uint16_t index);
67283 +
67284 +/**************************************************************************//**
67285 + @Description A callback for enqueuing frame onto a QM queue.
67286 +
67287 + @Param[in] h_QmArg - Application's handle passed to QM module on enqueue.
67288 + @Param[in] p_Fd - Frame descriptor for the frame.
67289 +
67290 + @Return E_OK on success; Error code otherwise.
67291 + *//***************************************************************************/
67292 +typedef t_Error (t_FmPcdQmEnqueueCallback) (t_Handle h_QmArg, void *p_Fd);
67293 +
67294 +/**************************************************************************//**
67295 + @Description Host-Command parameters structure.
67296 +
67297 + When using Host command for PCD functionalities, a dedicated port
67298 + must be used. If this routine is called for a PCD in a single partition
67299 + environment, or it is the Master partition in a Multi-partition
67300 + environment, The port will be initialized by the PCD driver
67301 + initialization routine.
67302 + *//***************************************************************************/
67303 +typedef struct t_FmPcdHcParams {
67304 + uintptr_t portBaseAddr; /**< Virtual Address of Host-Command Port memory mapped registers.*/
67305 + uint8_t portId; /**< Port Id (0-6 relative to Host-Command/Offline-Parsing ports);
67306 + NOTE: When configuring Host Command port for
67307 + FMANv3 devices (DPAA_VERSION 11 and higher),
67308 + portId=0 MUST be used. */
67309 + uint16_t liodnBase; /**< LIODN base for this port, to be used together with LIODN offset
67310 + (irrelevant for P4080 revision 1.0) */
67311 + uint32_t errFqid; /**< Host-Command Port error queue Id. */
67312 + uint32_t confFqid; /**< Host-Command Port confirmation queue Id. */
67313 + uint32_t qmChannel; /**< QM channel dedicated to this Host-Command port;
67314 + will be used by the FM for dequeue. */
67315 + t_FmPcdQmEnqueueCallback *f_QmEnqueue; /**< Callback routine for enqueuing a frame to the QM */
67316 + t_Handle h_QmArg; /**< Application's handle passed to QM module on enqueue */
67317 +} t_FmPcdHcParams;
67318 +
67319 +/**************************************************************************//**
67320 + @Description The main structure for PCD initialization
67321 + *//***************************************************************************/
67322 +typedef struct t_FmPcdParams {
67323 + bool prsSupport; /**< TRUE if Parser will be used for any of the FM ports. */
67324 + bool ccSupport; /**< TRUE if Coarse Classification will be used for any
67325 + of the FM ports. */
67326 + bool kgSupport; /**< TRUE if KeyGen will be used for any of the FM ports. */
67327 + bool plcrSupport; /**< TRUE if Policer will be used for any of the FM ports. */
67328 + t_Handle h_Fm; /**< A handle to the FM module. */
67329 + uint8_t numOfSchemes; /**< Number of schemes dedicated to this partition.
67330 + this parameter is relevant if 'kgSupport'=TRUE. */
67331 + bool useHostCommand; /**< Optional for single partition, Mandatory for Multi partition */
67332 + t_FmPcdHcParams hc; /**< Host Command parameters, relevant only if 'useHostCommand'=TRUE;
67333 + Relevant when FM not runs in "guest-mode". */
67334 +
67335 + t_FmPcdExceptionCallback *f_Exception; /**< Callback routine for general PCD exceptions;
67336 + Relevant when FM not runs in "guest-mode". */
67337 + t_FmPcdIdExceptionCallback *f_ExceptionId; /**< Callback routine for specific KeyGen scheme or
67338 + Policer profile exceptions;
67339 + Relevant when FM not runs in "guest-mode". */
67340 + t_Handle h_App; /**< A handle to an application layer object; This handle will
67341 + be passed by the driver upon calling the above callbacks;
67342 + Relevant when FM not runs in "guest-mode". */
67343 + uint8_t partPlcrProfilesBase; /**< The first policer-profile-id dedicated to this partition.
67344 + this parameter is relevant if 'plcrSupport'=TRUE.
67345 + NOTE: this parameter relevant only when working with multiple partitions. */
67346 + uint16_t partNumOfPlcrProfiles; /**< Number of policer-profiles dedicated to this partition.
67347 + this parameter is relevant if 'plcrSupport'=TRUE.
67348 + NOTE: this parameter relevant only when working with multiple partitions. */
67349 +} t_FmPcdParams;
67350 +
67351 +
67352 +/**************************************************************************//**
67353 + @Function FM_PCD_Config
67354 +
67355 + @Description Basic configuration of the PCD module.
67356 + Creates descriptor for the FM PCD module.
67357 +
67358 + @Param[in] p_FmPcdParams A structure of parameters for the initialization of PCD.
67359 +
67360 + @Return A handle to the initialized module.
67361 +*//***************************************************************************/
67362 +t_Handle FM_PCD_Config(t_FmPcdParams *p_FmPcdParams);
67363 +
67364 +/**************************************************************************//**
67365 + @Function FM_PCD_Init
67366 +
67367 + @Description Initialization of the PCD module.
67368 +
67369 + @Param[in] h_FmPcd - FM PCD module descriptor.
67370 +
67371 + @Return E_OK on success; Error code otherwise.
67372 +*//***************************************************************************/
67373 +t_Error FM_PCD_Init(t_Handle h_FmPcd);
67374 +
67375 +/**************************************************************************//**
67376 + @Function FM_PCD_Free
67377 +
67378 + @Description Frees all resources that were assigned to FM module.
67379 +
67380 + Calling this routine invalidates the descriptor.
67381 +
67382 + @Param[in] h_FmPcd - FM PCD module descriptor.
67383 +
67384 + @Return E_OK on success; Error code otherwise.
67385 +*//***************************************************************************/
67386 +t_Error FM_PCD_Free(t_Handle h_FmPcd);
67387 +
67388 +/**************************************************************************//**
67389 + @Group FM_PCD_advanced_cfg_grp FM PCD Advanced Configuration Unit
67390 +
67391 + @Description Frame Manager PCD Advanced Configuration API.
67392 +
67393 + @{
67394 +*//***************************************************************************/
67395 +
67396 +/**************************************************************************//**
67397 + @Function FM_PCD_ConfigException
67398 +
67399 + @Description Calling this routine changes the internal driver data base
67400 + from its default selection of exceptions enabling.
67401 + [DEFAULT_numOfSharedPlcrProfiles].
67402 +
67403 + @Param[in] h_FmPcd FM PCD module descriptor.
67404 + @Param[in] exception The exception to be selected.
67405 + @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
67406 +
67407 + @Return E_OK on success; Error code otherwise.
67408 +
67409 + @Cautions This routine should NOT be called from guest-partition
67410 + (i.e. guestId != NCSW_MASTER_ID)
67411 +*//***************************************************************************/
67412 +t_Error FM_PCD_ConfigException(t_Handle h_FmPcd, e_FmPcdExceptions exception, bool enable);
67413 +
67414 +/**************************************************************************//**
67415 + @Function FM_PCD_ConfigHcFramesDataMemory
67416 +
67417 + @Description Configures memory-partition-id for FMan-Controller Host-Command
67418 + frames. Calling this routine changes the internal driver data
67419 + base from its default configuration [0].
67420 +
67421 + @Param[in] h_FmPcd FM PCD module descriptor.
67422 + @Param[in] memId Memory partition ID.
67423 +
67424 + @Return E_OK on success; Error code otherwise.
67425 +
67426 + @Cautions This routine may be called only if 'useHostCommand' was TRUE
67427 + when FM_PCD_Config() routine was called.
67428 +*//***************************************************************************/
67429 +t_Error FM_PCD_ConfigHcFramesDataMemory(t_Handle h_FmPcd, uint8_t memId);
67430 +
67431 +/**************************************************************************//**
67432 + @Function FM_PCD_ConfigPlcrNumOfSharedProfiles
67433 +
67434 + @Description Calling this routine changes the internal driver data base
67435 + from its default selection of exceptions enablement.
67436 + [DEFAULT_numOfSharedPlcrProfiles].
67437 +
67438 + @Param[in] h_FmPcd FM PCD module descriptor.
67439 + @Param[in] numOfSharedPlcrProfiles Number of profiles to
67440 + be shared between ports on this partition
67441 +
67442 + @Return E_OK on success; Error code otherwise.
67443 +*//***************************************************************************/
67444 +t_Error FM_PCD_ConfigPlcrNumOfSharedProfiles(t_Handle h_FmPcd, uint16_t numOfSharedPlcrProfiles);
67445 +
67446 +/**************************************************************************//**
67447 + @Function FM_PCD_ConfigPlcrAutoRefreshMode
67448 +
67449 + @Description Calling this routine changes the internal driver data base
67450 + from its default selection of exceptions enablement.
67451 + By default auto-refresh is [DEFAULT_plcrAutoRefresh].
67452 +
67453 + @Param[in] h_FmPcd FM PCD module descriptor.
67454 + @Param[in] enable TRUE to enable, FALSE to disable
67455 +
67456 + @Return E_OK on success; Error code otherwise.
67457 +
67458 + @Cautions This routine should NOT be called from guest-partition
67459 + (i.e. guestId != NCSW_MASTER_ID)
67460 +*//***************************************************************************/
67461 +t_Error FM_PCD_ConfigPlcrAutoRefreshMode(t_Handle h_FmPcd, bool enable);
67462 +
67463 +/**************************************************************************//**
67464 + @Function FM_PCD_ConfigPrsMaxCycleLimit
67465 +
67466 + @Description Calling this routine changes the internal data structure for
67467 + the maximum parsing time from its default value
67468 + [DEFAULT_MAX_PRS_CYC_LIM].
67469 +
67470 + @Param[in] h_FmPcd FM PCD module descriptor.
67471 + @Param[in] value 0 to disable the mechanism, or new
67472 + maximum parsing time.
67473 +
67474 + @Return E_OK on success; Error code otherwise.
67475 +
67476 + @Cautions This routine should NOT be called from guest-partition
67477 + (i.e. guestId != NCSW_MASTER_ID)
67478 +*//***************************************************************************/
67479 +t_Error FM_PCD_ConfigPrsMaxCycleLimit(t_Handle h_FmPcd,uint16_t value);
67480 +
67481 +/** @} */ /* end of FM_PCD_advanced_cfg_grp group */
67482 +/** @} */ /* end of FM_PCD_init_grp group */
67483 +
67484 +
67485 +/**************************************************************************//**
67486 + @Group FM_PCD_Runtime_grp FM PCD Runtime Unit
67487 +
67488 + @Description Frame Manager PCD Runtime Unit API
67489 +
67490 + The runtime control allows creation of PCD infrastructure modules
67491 + such as Network Environment Characteristics, Classification Plan
67492 + Groups and Coarse Classification Trees.
67493 + It also allows on-the-fly initialization, modification and removal
67494 + of PCD modules such as KeyGen schemes, coarse classification nodes
67495 + and Policer profiles.
67496 +
67497 + In order to explain the programming model of the PCD driver interface
67498 + a few terms should be explained, and will be used below.
67499 + - Distinction Header - One of the 16 protocols supported by the FM parser,
67500 + or one of the SHIM headers (1 or 2). May be a header with a special
67501 + option (see below).
67502 + - Interchangeable Headers Group - This is a group of Headers recognized
67503 + by either one of them. For example, if in a specific context the user
67504 + chooses to treat IPv4 and IPV6 in the same way, they may create an
67505 + interchangeable Headers Unit consisting of these 2 headers.
67506 + - A Distinction Unit - a Distinction Header or an Interchangeable Headers
67507 + Group.
67508 + - Header with special option - applies to Ethernet, MPLS, VLAN, IPv4 and
67509 + IPv6, includes multicast, broadcast and other protocol specific options.
67510 + In terms of hardware it relates to the options available in the classification
67511 + plan.
67512 + - Network Environment Characteristics - a set of Distinction Units that define
67513 + the total recognizable header selection for a certain environment. This is
67514 + NOT the list of all headers that will ever appear in a flow, but rather
67515 + everything that needs distinction in a flow, where distinction is made by KeyGen
67516 + schemes and coarse classification action descriptors.
67517 +
67518 + The PCD runtime modules initialization is done in stages. The first stage after
67519 + initializing the PCD module itself is to establish a Network Flows Environment
67520 + Definition. The application may choose to establish one or more such environments.
67521 + Later, when needed, the application will have to state, for some of its modules,
67522 + to which single environment it belongs.
67523 +
67524 + @{
67525 +*//***************************************************************************/
67526 +
67527 +/**************************************************************************//**
67528 + @Description A structure for SW parser labels
67529 + *//***************************************************************************/
67530 +typedef struct t_FmPcdPrsLabelParams {
67531 + uint32_t instructionOffset; /**< SW parser label instruction offset (2 bytes
67532 + resolution), relative to Parser RAM. */
67533 + e_NetHeaderType hdr; /**< The existence of this header will invoke
67534 + the SW parser code; Use HEADER_TYPE_NONE
67535 + to indicate that sw parser is to run
67536 + independent of the existence of any protocol
67537 + (run before HW parser). */
67538 + uint8_t indexPerHdr; /**< Normally 0, if more than one SW parser
67539 + attachments for the same header, use this
67540 + index to distinguish between them. */
67541 +} t_FmPcdPrsLabelParams;
67542 +
67543 +/**************************************************************************//**
67544 + @Description A structure for SW parser
67545 + *//***************************************************************************/
67546 +typedef struct t_FmPcdPrsSwParams {
67547 + bool override; /**< FALSE to invoke a check that nothing else
67548 + was loaded to this address, including
67549 + internal patches.
67550 + TRUE to override any existing code.*/
67551 + uint32_t size; /**< SW parser code size */
67552 + uint16_t base; /**< SW parser base (in instruction counts!
67553 + must be larger than 0x20)*/
67554 + uint8_t *p_Code; /**< SW parser code */
67555 + uint32_t swPrsDataParams[FM_PCD_PRS_NUM_OF_HDRS];
67556 + /**< SW parser data (parameters) */
67557 + uint8_t numOfLabels; /**< Number of labels for SW parser. */
67558 + t_FmPcdPrsLabelParams labelsTable[FM_PCD_PRS_NUM_OF_LABELS];
67559 + /**< SW parser labels table, containing
67560 + numOfLabels entries */
67561 +} t_FmPcdPrsSwParams;
67562 +
67563 +
67564 +/**************************************************************************//**
67565 + @Function FM_PCD_Enable
67566 +
67567 + @Description This routine should be called after PCD is initialized for enabling all
67568 + PCD engines according to their existing configuration.
67569 +
67570 + @Param[in] h_FmPcd FM PCD module descriptor.
67571 +
67572 + @Return E_OK on success; Error code otherwise.
67573 +
67574 + @Cautions Allowed only following FM_PCD_Init() and when PCD is disabled.
67575 +*//***************************************************************************/
67576 +t_Error FM_PCD_Enable(t_Handle h_FmPcd);
67577 +
67578 +/**************************************************************************//**
67579 + @Function FM_PCD_Disable
67580 +
67581 + @Description This routine may be called when PCD is enabled in order to
67582 + disable all PCD engines. It may be called
67583 + only when none of the ports in the system are using the PCD.
67584 +
67585 + @Param[in] h_FmPcd FM PCD module descriptor.
67586 +
67587 + @Return E_OK on success; Error code otherwise.
67588 +
67589 + @Cautions Allowed only following FM_PCD_Init() and when PCD is enabled.
67590 +*//***************************************************************************/
67591 +t_Error FM_PCD_Disable(t_Handle h_FmPcd);
67592 +
67593 +/**************************************************************************//**
67594 + @Function FM_PCD_GetCounter
67595 +
67596 + @Description Reads one of the FM PCD counters.
67597 +
67598 + @Param[in] h_FmPcd FM PCD module descriptor.
67599 + @Param[in] counter The requested counter.
67600 +
67601 + @Return Counter's current value.
67602 +
67603 + @Cautions Allowed only following FM_PCD_Init().
67604 + Note that it is user's responsibility to call this routine only
67605 + for enabled counters, and there will be no indication if a
67606 + disabled counter is accessed.
67607 +*//***************************************************************************/
67608 +uint32_t FM_PCD_GetCounter(t_Handle h_FmPcd, e_FmPcdCounters counter);
67609 +
67610 +/**************************************************************************//**
67611 +@Function FM_PCD_PrsLoadSw
67612 +
67613 +@Description This routine may be called in order to load software parsing code.
67614 +
67615 +
67616 +@Param[in] h_FmPcd FM PCD module descriptor.
67617 +@Param[in] p_SwPrs A pointer to a structure of software
67618 + parser parameters, including the software
67619 + parser image.
67620 +
67621 +@Return E_OK on success; Error code otherwise.
67622 +
67623 +@Cautions Allowed only following FM_PCD_Init() and when PCD is disabled.
67624 + This routine should NOT be called from guest-partition
67625 + (i.e. guestId != NCSW_MASTER_ID)
67626 +*//***************************************************************************/
67627 +t_Error FM_PCD_PrsLoadSw(t_Handle h_FmPcd, t_FmPcdPrsSwParams *p_SwPrs);
67628 +
67629 +/**************************************************************************//**
67630 +@Function FM_PCD_SetAdvancedOffloadSupport
67631 +
67632 +@Description This routine must be called in order to support the following features:
67633 + IP-fragmentation, IP-reassembly, IPsec, Header-manipulation, frame-replicator.
67634 +
67635 +@Param[in] h_FmPcd FM PCD module descriptor.
67636 +
67637 +@Return E_OK on success; Error code otherwise.
67638 +
67639 +@Cautions Allowed only following FM_PCD_Init() and when PCD is disabled.
67640 + This routine should NOT be called from guest-partition
67641 + (i.e. guestId != NCSW_MASTER_ID)
67642 +*//***************************************************************************/
67643 +t_Error FM_PCD_SetAdvancedOffloadSupport(t_Handle h_FmPcd);
67644 +
67645 +/**************************************************************************//**
67646 + @Function FM_PCD_KgSetDfltValue
67647 +
67648 + @Description Calling this routine sets a global default value to be used
67649 + by the KeyGen when parser does not recognize a required
67650 + field/header.
67651 + By default default values are 0.
67652 +
67653 + @Param[in] h_FmPcd FM PCD module descriptor.
67654 + @Param[in] valueId 0,1 - one of 2 global default values.
67655 + @Param[in] value The requested default value.
67656 +
67657 + @Return E_OK on success; Error code otherwise.
67658 +
67659 + @Cautions Allowed only following FM_PCD_Init() and when PCD is disabled.
67660 + This routine should NOT be called from guest-partition
67661 + (i.e. guestId != NCSW_MASTER_ID)
67662 +*//***************************************************************************/
67663 +t_Error FM_PCD_KgSetDfltValue(t_Handle h_FmPcd, uint8_t valueId, uint32_t value);
67664 +
67665 +/**************************************************************************//**
67666 + @Function FM_PCD_KgSetAdditionalDataAfterParsing
67667 +
67668 + @Description Calling this routine allows the KeyGen to access data past
67669 + the parser finishing point.
67670 +
67671 + @Param[in] h_FmPcd FM PCD module descriptor.
67672 + @Param[in] payloadOffset the number of bytes beyond the parser location.
67673 +
67674 + @Return E_OK on success; Error code otherwise.
67675 +
67676 + @Cautions Allowed only following FM_PCD_Init() and when PCD is disabled.
67677 + This routine should NOT be called from guest-partition
67678 + (i.e. guestId != NCSW_MASTER_ID)
67679 +*//***************************************************************************/
67680 +t_Error FM_PCD_KgSetAdditionalDataAfterParsing(t_Handle h_FmPcd, uint8_t payloadOffset);
67681 +
67682 +/**************************************************************************//**
67683 + @Function FM_PCD_SetException
67684 +
67685 + @Description Calling this routine enables/disables PCD interrupts.
67686 +
67687 + @Param[in] h_FmPcd FM PCD module descriptor.
67688 + @Param[in] exception The exception to be selected.
67689 + @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
67690 +
67691 + @Return E_OK on success; Error code otherwise.
67692 +
67693 + @Cautions Allowed only following FM_PCD_Init().
67694 + This routine should NOT be called from guest-partition
67695 + (i.e. guestId != NCSW_MASTER_ID)
67696 +*//***************************************************************************/
67697 +t_Error FM_PCD_SetException(t_Handle h_FmPcd, e_FmPcdExceptions exception, bool enable);
67698 +
67699 +/**************************************************************************//**
67700 + @Function FM_PCD_ModifyCounter
67701 +
67702 + @Description Sets a value to an enabled counter. Use "0" to reset the counter.
67703 +
67704 + @Param[in] h_FmPcd FM PCD module descriptor.
67705 + @Param[in] counter The requested counter.
67706 + @Param[in] value The requested value to be written into the counter.
67707 +
67708 + @Return E_OK on success; Error code otherwise.
67709 +
67710 + @Cautions Allowed only following FM_PCD_Init().
67711 + This routine should NOT be called from guest-partition
67712 + (i.e. guestId != NCSW_MASTER_ID)
67713 +*//***************************************************************************/
67714 +t_Error FM_PCD_ModifyCounter(t_Handle h_FmPcd, e_FmPcdCounters counter, uint32_t value);
67715 +
67716 +/**************************************************************************//**
67717 + @Function FM_PCD_SetPlcrStatistics
67718 +
67719 + @Description This routine may be used to enable/disable policer statistics
67720 + counter. By default the statistics is enabled.
67721 +
67722 + @Param[in] h_FmPcd FM PCD module descriptor
67723 + @Param[in] enable TRUE to enable, FALSE to disable.
67724 +
67725 + @Return E_OK on success; Error code otherwise.
67726 +
67727 + @Cautions Allowed only following FM_PCD_Init().
67728 + This routine should NOT be called from guest-partition
67729 + (i.e. guestId != NCSW_MASTER_ID)
67730 +*//***************************************************************************/
67731 +t_Error FM_PCD_SetPlcrStatistics(t_Handle h_FmPcd, bool enable);
67732 +
67733 +/**************************************************************************//**
67734 + @Function FM_PCD_SetPrsStatistics
67735 +
67736 + @Description Defines whether to gather parser statistics including all ports.
67737 +
67738 + @Param[in] h_FmPcd FM PCD module descriptor.
67739 + @Param[in] enable TRUE to enable, FALSE to disable.
67740 +
67741 + @Return None
67742 +
67743 + @Cautions Allowed only following FM_PCD_Init().
67744 + This routine should NOT be called from guest-partition
67745 + (i.e. guestId != NCSW_MASTER_ID)
67746 +*//***************************************************************************/
67747 +void FM_PCD_SetPrsStatistics(t_Handle h_FmPcd, bool enable);
67748 +
67749 +/**************************************************************************//**
67750 + @Function FM_PCD_HcTxConf
67751 +
67752 + @Description This routine should be called to confirm frames that were
67753 + received on the HC confirmation queue.
67754 +
67755 + @Param[in] h_FmPcd A handle to an FM PCD Module.
67756 + @Param[in] p_Fd Frame descriptor of the received frame.
67757 +
67758 + @Cautions Allowed only following FM_PCD_Init(). Allowed only if 'useHostCommand'
67759 + option was selected in the initialization.
67760 +*//***************************************************************************/
67761 +void FM_PCD_HcTxConf(t_Handle h_FmPcd, t_DpaaFD *p_Fd);
67762 +
67763 +/**************************************************************************//*
67764 + @Function FM_PCD_ForceIntr
67765 +
67766 + @Description Causes an interrupt event on the requested source.
67767 +
67768 + @Param[in] h_FmPcd FM PCD module descriptor.
67769 + @Param[in] exception An exception to be forced.
67770 +
67771 + @Return E_OK on success; Error code if the exception is not enabled,
67772 + or is not able to create interrupt.
67773 +
67774 + @Cautions Allowed only following FM_PCD_Init().
67775 + This routine should NOT be called from guest-partition
67776 + (i.e. guestId != NCSW_MASTER_ID)
67777 +*//***************************************************************************/
67778 +t_Error FM_PCD_ForceIntr (t_Handle h_FmPcd, e_FmPcdExceptions exception);
67779 +
67780 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
67781 +/**************************************************************************//**
67782 + @Function FM_PCD_DumpRegs
67783 +
67784 + @Description Dumps all PCD registers
67785 +
67786 + @Param[in] h_FmPcd A handle to an FM PCD Module.
67787 +
67788 + @Return E_OK on success; Error code otherwise.
67789 +
67790 + @Cautions Allowed only following FM_PCD_Init().
67791 + NOTE: this routine may be called only for FM in master mode
67792 + (i.e. 'guestId'=NCSW_MASTER_ID) or in a case that the registers
67793 + are mapped.
67794 +*//***************************************************************************/
67795 +t_Error FM_PCD_DumpRegs(t_Handle h_FmPcd);
67796 +
67797 +/**************************************************************************//**
67798 + @Function FM_PCD_KgDumpRegs
67799 +
67800 + @Description Dumps all PCD KG registers
67801 +
67802 + @Param[in] h_FmPcd A handle to an FM PCD Module.
67803 +
67804 + @Return E_OK on success; Error code otherwise.
67805 +
67806 + @Cautions Allowed only following FM_PCD_Init().
67807 + NOTE: this routine may be called only for FM in master mode
67808 + (i.e. 'guestId'=NCSW_MASTER_ID) or in a case that the registers
67809 + are mapped.
67810 +*//***************************************************************************/
67811 +t_Error FM_PCD_KgDumpRegs(t_Handle h_FmPcd);
67812 +
67813 +/**************************************************************************//**
67814 + @Function FM_PCD_PlcrDumpRegs
67815 +
67816 + @Description Dumps all PCD Policer registers
67817 +
67818 + @Param[in] h_FmPcd A handle to an FM PCD Module.
67819 +
67820 + @Return E_OK on success; Error code otherwise.
67821 +
67822 + @Cautions Allowed only following FM_PCD_Init().
67823 + NOTE: this routine may be called only for FM in master mode
67824 + (i.e. 'guestId'=NCSW_MASTER_ID) or in a case that the registers
67825 + are mapped.
67826 +*//***************************************************************************/
67827 +t_Error FM_PCD_PlcrDumpRegs(t_Handle h_FmPcd);
67828 +
67829 +/**************************************************************************//**
67830 + @Function FM_PCD_PlcrProfileDumpRegs
67831 +
67832 + @Description Dumps all PCD Policer profile registers
67833 +
67834 + @Param[in] h_Profile A handle to a Policer profile.
67835 +
67836 + @Return E_OK on success; Error code otherwise.
67837 +
67838 + @Cautions Allowed only following FM_PCD_Init().
67839 + NOTE: this routine may be called only for FM in master mode
67840 + (i.e. 'guestId'=NCSW_MASTER_ID) or in a case that the registers
67841 + are mapped.
67842 +*//***************************************************************************/
67843 +t_Error FM_PCD_PlcrProfileDumpRegs(t_Handle h_Profile);
67844 +
67845 +/**************************************************************************//**
67846 + @Function FM_PCD_PrsDumpRegs
67847 +
67848 + @Description Dumps all PCD Parser registers
67849 +
67850 + @Param[in] h_FmPcd A handle to an FM PCD Module.
67851 +
67852 + @Return E_OK on success; Error code otherwise.
67853 +
67854 + @Cautions Allowed only following FM_PCD_Init().
67855 + NOTE: this routine may be called only for FM in master mode
67856 + (i.e. 'guestId'=NCSW_MASTER_ID) or in a case that the registers
67857 + are mapped.
67858 +*//***************************************************************************/
67859 +t_Error FM_PCD_PrsDumpRegs(t_Handle h_FmPcd);
67860 +
67861 +/**************************************************************************//**
67862 + @Function FM_PCD_HcDumpRegs
67863 +
67864 + @Description Dumps HC Port registers
67865 +
67866 + @Param[in] h_FmPcd A handle to an FM PCD Module.
67867 +
67868 + @Return E_OK on success; Error code otherwise.
67869 +
67870 + @Cautions Allowed only following FM_PCD_Init().
67871 + NOTE: this routine may be called only for FM in master mode
67872 + (i.e. 'guestId'=NCSW_MASTER_ID).
67873 +*//***************************************************************************/
67874 +t_Error FM_PCD_HcDumpRegs(t_Handle h_FmPcd);
67875 +#endif /* (defined(DEBUG_ERRORS) && ... */
67876 +
67877 +
67878 +
67879 +/**************************************************************************//**
67880 + KeyGen FM_PCD_Runtime_build_grp FM PCD Runtime Building Unit
67881 +
67882 + @Description Frame Manager PCD Runtime Building API
67883 +
67884 + This group contains routines for setting, deleting and modifying
67885 + PCD resources, for defining the total PCD tree.
67886 + @{
67887 +*//***************************************************************************/
67888 +
67889 +/**************************************************************************//**
67890 + @Collection Definitions of coarse classification
67891 + parameters as required by KeyGen (when coarse classification
67892 + is the next engine after this scheme).
67893 +*//***************************************************************************/
67894 +#define FM_PCD_MAX_NUM_OF_CC_TREES 8
67895 +#define FM_PCD_MAX_NUM_OF_CC_GROUPS 16
67896 +#define FM_PCD_MAX_NUM_OF_CC_UNITS 4
67897 +#define FM_PCD_MAX_NUM_OF_KEYS 256
67898 +#define FM_PCD_MAX_NUM_OF_FLOWS (4*KILOBYTE)
67899 +#define FM_PCD_MAX_SIZE_OF_KEY 56
67900 +#define FM_PCD_MAX_NUM_OF_CC_ENTRIES_IN_GRP 16
67901 +#define FM_PCD_LAST_KEY_INDEX 0xffff
67902 +
67903 +#define FM_PCD_MAX_NUM_OF_CC_NODES 255 /* Obsolete, not used - will be removed in the future */
67904 +/* @} */
67905 +
67906 +/**************************************************************************//**
67907 + @Collection A set of definitions to allow protocol
67908 + special option description.
67909 +*//***************************************************************************/
67910 +typedef uint32_t protocolOpt_t; /**< A general type to define a protocol option. */
67911 +
67912 +typedef protocolOpt_t ethProtocolOpt_t; /**< Ethernet protocol options. */
67913 +#define ETH_BROADCAST 0x80000000 /**< Ethernet Broadcast. */
67914 +#define ETH_MULTICAST 0x40000000 /**< Ethernet Multicast. */
67915 +
67916 +typedef protocolOpt_t vlanProtocolOpt_t; /**< VLAN protocol options. */
67917 +#define VLAN_STACKED 0x20000000 /**< Stacked VLAN. */
67918 +
67919 +typedef protocolOpt_t mplsProtocolOpt_t; /**< MPLS protocol options. */
67920 +#define MPLS_STACKED 0x10000000 /**< Stacked MPLS. */
67921 +
67922 +typedef protocolOpt_t ipv4ProtocolOpt_t; /**< IPv4 protocol options. */
67923 +#define IPV4_BROADCAST_1 0x08000000 /**< IPv4 Broadcast. */
67924 +#define IPV4_MULTICAST_1 0x04000000 /**< IPv4 Multicast. */
67925 +#define IPV4_UNICAST_2 0x02000000 /**< Tunneled IPv4 - Unicast. */
67926 +#define IPV4_MULTICAST_BROADCAST_2 0x01000000 /**< Tunneled IPv4 - Broadcast/Multicast. */
67927 +
67928 +#define IPV4_FRAG_1 0x00000008 /**< IPV4 reassembly option.
67929 + IPV4 Reassembly manipulation requires network
67930 + environment with IPV4 header and IPV4_FRAG_1 option */
67931 +
67932 +typedef protocolOpt_t ipv6ProtocolOpt_t; /**< IPv6 protocol options. */
67933 +#define IPV6_MULTICAST_1 0x00800000 /**< IPv6 Multicast. */
67934 +#define IPV6_UNICAST_2 0x00400000 /**< Tunneled IPv6 - Unicast. */
67935 +#define IPV6_MULTICAST_2 0x00200000 /**< Tunneled IPv6 - Multicast. */
67936 +
67937 +#define IPV6_FRAG_1 0x00000004 /**< IPV6 reassembly option.
67938 + IPV6 Reassembly manipulation requires network
67939 + environment with IPV6 header and IPV6_FRAG_1 option;
67940 + in case where fragment found, the fragment-extension offset
67941 + may be found at 'shim2' (in parser-result). */
67942 +#if (DPAA_VERSION >= 11)
67943 +typedef protocolOpt_t capwapProtocolOpt_t; /**< CAPWAP protocol options. */
67944 +#define CAPWAP_FRAG_1 0x00000008 /**< CAPWAP reassembly option.
67945 + CAPWAP Reassembly manipulation requires network
67946 + environment with CAPWAP header and CAPWAP_FRAG_1 option;
67947 + in case where fragment found, the fragment-extension offset
67948 + may be found at 'shim2' (in parser-result). */
67949 +#endif /* (DPAA_VERSION >= 11) */
67950 +
67951 +
67952 +/* @} */
67953 +
67954 +#define FM_PCD_MANIP_MAX_HDR_SIZE 256
67955 +#define FM_PCD_MANIP_DSCP_TO_VLAN_TRANS 64
67956 +
67957 +/**************************************************************************//**
67958 + @Collection A set of definitions to support Header Manipulation selection.
67959 +*//***************************************************************************/
67960 +typedef uint32_t hdrManipFlags_t; /**< A general type to define a HMan update command flags. */
67961 +
67962 +typedef hdrManipFlags_t ipv4HdrManipUpdateFlags_t; /**< IPv4 protocol HMan update command flags. */
67963 +
67964 +#define HDR_MANIP_IPV4_TOS 0x80000000 /**< update TOS with the given value ('tos' field
67965 + of t_FmPcdManipHdrFieldUpdateIpv4) */
67966 +#define HDR_MANIP_IPV4_ID 0x40000000 /**< update IP ID with the given value ('id' field
67967 + of t_FmPcdManipHdrFieldUpdateIpv4) */
67968 +#define HDR_MANIP_IPV4_TTL 0x20000000 /**< Decrement TTL by 1 */
67969 +#define HDR_MANIP_IPV4_SRC 0x10000000 /**< update IP source address with the given value
67970 + ('src' field of t_FmPcdManipHdrFieldUpdateIpv4) */
67971 +#define HDR_MANIP_IPV4_DST 0x08000000 /**< update IP destination address with the given value
67972 + ('dst' field of t_FmPcdManipHdrFieldUpdateIpv4) */
67973 +
67974 +typedef hdrManipFlags_t ipv6HdrManipUpdateFlags_t; /**< IPv6 protocol HMan update command flags. */
67975 +
67976 +#define HDR_MANIP_IPV6_TC 0x80000000 /**< update Traffic Class address with the given value
67977 + ('trafficClass' field of t_FmPcdManipHdrFieldUpdateIpv6) */
67978 +#define HDR_MANIP_IPV6_HL 0x40000000 /**< Decrement Hop Limit by 1 */
67979 +#define HDR_MANIP_IPV6_SRC 0x20000000 /**< update IP source address with the given value
67980 + ('src' field of t_FmPcdManipHdrFieldUpdateIpv6) */
67981 +#define HDR_MANIP_IPV6_DST 0x10000000 /**< update IP destination address with the given value
67982 + ('dst' field of t_FmPcdManipHdrFieldUpdateIpv6) */
67983 +
67984 +typedef hdrManipFlags_t tcpUdpHdrManipUpdateFlags_t;/**< TCP/UDP protocol HMan update command flags. */
67985 +
67986 +#define HDR_MANIP_TCP_UDP_SRC 0x80000000 /**< update TCP/UDP source address with the given value
67987 + ('src' field of t_FmPcdManipHdrFieldUpdateTcpUdp) */
67988 +#define HDR_MANIP_TCP_UDP_DST 0x40000000 /**< update TCP/UDP destination address with the given value
67989 + ('dst' field of t_FmPcdManipHdrFieldUpdateTcpUdp) */
67990 +#define HDR_MANIP_TCP_UDP_CHECKSUM 0x20000000 /**< update TCP/UDP checksum */
67991 +
67992 +/* @} */
67993 +
67994 +/**************************************************************************//**
67995 + @Description A type used for returning the order of the key extraction.
67996 + each value in this array represents the index of the extraction
67997 + command as defined by the user in the initialization extraction array.
67998 + The valid size of this array is the user define number of extractions
67999 + required (also marked by the second '0' in this array).
68000 +*//***************************************************************************/
68001 +typedef uint8_t t_FmPcdKgKeyOrder [FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY];
68002 +
68003 +/**************************************************************************//**
68004 + @Description All PCD engines
68005 +*//***************************************************************************/
68006 +typedef enum e_FmPcdEngine {
68007 + e_FM_PCD_INVALID = 0, /**< Invalid PCD engine */
68008 + e_FM_PCD_DONE, /**< No PCD Engine indicated */
68009 + e_FM_PCD_KG, /**< KeyGen */
68010 + e_FM_PCD_CC, /**< Coarse classifier */
68011 + e_FM_PCD_PLCR, /**< Policer */
68012 + e_FM_PCD_PRS, /**< Parser */
68013 +#if (DPAA_VERSION >= 11)
68014 + e_FM_PCD_FR, /**< Frame-Replicator */
68015 +#endif /* (DPAA_VERSION >= 11) */
68016 + e_FM_PCD_HASH /**< Hash table */
68017 +} e_FmPcdEngine;
68018 +
68019 +/**************************************************************************//**
68020 + @Description Enumeration type for selecting extraction by header types
68021 +*//***************************************************************************/
68022 +typedef enum e_FmPcdExtractByHdrType {
68023 + e_FM_PCD_EXTRACT_FROM_HDR, /**< Extract bytes from header */
68024 + e_FM_PCD_EXTRACT_FROM_FIELD, /**< Extract bytes from header field */
68025 + e_FM_PCD_EXTRACT_FULL_FIELD /**< Extract a full field */
68026 +} e_FmPcdExtractByHdrType;
68027 +
68028 +/**************************************************************************//**
68029 + @Description Enumeration type for selecting extraction source
68030 + (when it is not the header)
68031 +*//***************************************************************************/
68032 +typedef enum e_FmPcdExtractFrom {
68033 + e_FM_PCD_EXTRACT_FROM_FRAME_START, /**< KG & CC: Extract from beginning of frame */
68034 + e_FM_PCD_EXTRACT_FROM_DFLT_VALUE, /**< KG only: Extract from a default value */
68035 + e_FM_PCD_EXTRACT_FROM_CURR_END_OF_PARSE, /**< KG & CC: Extract from the point where parsing had finished */
68036 + e_FM_PCD_EXTRACT_FROM_KEY, /**< CC only: Field where saved KEY */
68037 + e_FM_PCD_EXTRACT_FROM_HASH, /**< CC only: Field where saved HASH */
68038 + e_FM_PCD_EXTRACT_FROM_PARSE_RESULT, /**< KG only: Extract from the parser result */
68039 + e_FM_PCD_EXTRACT_FROM_ENQ_FQID, /**< KG & CC: Extract from enqueue FQID */
68040 + e_FM_PCD_EXTRACT_FROM_FLOW_ID /**< CC only: Field where saved Dequeue FQID */
68041 +} e_FmPcdExtractFrom;
68042 +
68043 +/**************************************************************************//**
68044 + @Description Enumeration type for selecting extraction type
68045 +*//***************************************************************************/
68046 +typedef enum e_FmPcdExtractType {
68047 + e_FM_PCD_EXTRACT_BY_HDR, /**< Extract according to header */
68048 + e_FM_PCD_EXTRACT_NON_HDR, /**< Extract from data that is not the header */
68049 + e_FM_PCD_KG_EXTRACT_PORT_PRIVATE_INFO /**< Extract private info as specified by user */
68050 +} e_FmPcdExtractType;
68051 +
68052 +/**************************************************************************//**
68053 + @Description Enumeration type for selecting default extraction value
68054 +*//***************************************************************************/
68055 +typedef enum e_FmPcdKgExtractDfltSelect {
68056 + e_FM_PCD_KG_DFLT_GBL_0, /**< Default selection is KG register 0 */
68057 + e_FM_PCD_KG_DFLT_GBL_1, /**< Default selection is KG register 1 */
68058 + e_FM_PCD_KG_DFLT_PRIVATE_0, /**< Default selection is a per scheme register 0 */
68059 + e_FM_PCD_KG_DFLT_PRIVATE_1, /**< Default selection is a per scheme register 1 */
68060 + e_FM_PCD_KG_DFLT_ILLEGAL /**< Illegal selection */
68061 +} e_FmPcdKgExtractDfltSelect;
68062 +
68063 +/**************************************************************************//**
68064 + @Description Enumeration type defining all default groups - each group shares
68065 + a default value, one of four user-initialized values.
68066 +*//***************************************************************************/
68067 +typedef enum e_FmPcdKgKnownFieldsDfltTypes {
68068 + e_FM_PCD_KG_MAC_ADDR, /**< MAC Address */
68069 + e_FM_PCD_KG_TCI, /**< TCI field */
68070 + e_FM_PCD_KG_ENET_TYPE, /**< ENET Type */
68071 + e_FM_PCD_KG_PPP_SESSION_ID, /**< PPP Session id */
68072 + e_FM_PCD_KG_PPP_PROTOCOL_ID, /**< PPP Protocol id */
68073 + e_FM_PCD_KG_MPLS_LABEL, /**< MPLS label */
68074 + e_FM_PCD_KG_IP_ADDR, /**< IP address */
68075 + e_FM_PCD_KG_PROTOCOL_TYPE, /**< Protocol type */
68076 + e_FM_PCD_KG_IP_TOS_TC, /**< TOS or TC */
68077 + e_FM_PCD_KG_IPV6_FLOW_LABEL, /**< IPV6 flow label */
68078 + e_FM_PCD_KG_IPSEC_SPI, /**< IPSEC SPI */
68079 + e_FM_PCD_KG_L4_PORT, /**< L4 Port */
68080 + e_FM_PCD_KG_TCP_FLAG, /**< TCP Flag */
68081 + e_FM_PCD_KG_GENERIC_FROM_DATA, /**< grouping implemented by SW,
68082 + any data extraction that is not the full
68083 + field described above */
68084 + e_FM_PCD_KG_GENERIC_FROM_DATA_NO_V, /**< grouping implemented by SW,
68085 + any data extraction without validation */
68086 + e_FM_PCD_KG_GENERIC_NOT_FROM_DATA /**< grouping implemented by SW,
68087 + extraction from parser result or
68088 + direct use of default value */
68089 +} e_FmPcdKgKnownFieldsDfltTypes;
68090 +
68091 +/**************************************************************************//**
68092 + @Description Enumeration type for defining header index for scenarios with
68093 + multiple (tunneled) headers
68094 +*//***************************************************************************/
68095 +typedef enum e_FmPcdHdrIndex {
68096 + e_FM_PCD_HDR_INDEX_NONE = 0, /**< used when multiple headers not used, also
68097 + to specify regular IP (not tunneled). */
68098 + e_FM_PCD_HDR_INDEX_1, /**< may be used for VLAN, MPLS, tunneled IP */
68099 + e_FM_PCD_HDR_INDEX_2, /**< may be used for MPLS, tunneled IP */
68100 + e_FM_PCD_HDR_INDEX_3, /**< may be used for MPLS */
68101 + e_FM_PCD_HDR_INDEX_LAST = 0xFF /**< may be used for VLAN, MPLS */
68102 +} e_FmPcdHdrIndex;
68103 +
68104 +/**************************************************************************//**
68105 + @Description Enumeration type for selecting the policer profile functional type
68106 +*//***************************************************************************/
68107 +typedef enum e_FmPcdProfileTypeSelection {
68108 + e_FM_PCD_PLCR_PORT_PRIVATE, /**< Port dedicated profile */
68109 + e_FM_PCD_PLCR_SHARED /**< Shared profile (shared within partition) */
68110 +} e_FmPcdProfileTypeSelection;
68111 +
68112 +/**************************************************************************//**
68113 + @Description Enumeration type for selecting the policer profile algorithm
68114 +*//***************************************************************************/
68115 +typedef enum e_FmPcdPlcrAlgorithmSelection {
68116 + e_FM_PCD_PLCR_PASS_THROUGH, /**< Policer pass through */
68117 + e_FM_PCD_PLCR_RFC_2698, /**< Policer algorithm RFC 2698 */
68118 + e_FM_PCD_PLCR_RFC_4115 /**< Policer algorithm RFC 4115 */
68119 +} e_FmPcdPlcrAlgorithmSelection;
68120 +
68121 +/**************************************************************************//**
68122 + @Description Enumeration type for selecting a policer profile color mode
68123 +*//***************************************************************************/
68124 +typedef enum e_FmPcdPlcrColorMode {
68125 + e_FM_PCD_PLCR_COLOR_BLIND, /**< Color blind */
68126 + e_FM_PCD_PLCR_COLOR_AWARE /**< Color aware */
68127 +} e_FmPcdPlcrColorMode;
68128 +
68129 +/**************************************************************************//**
68130 + @Description Enumeration type for selecting a policer profile color
68131 +*//***************************************************************************/
68132 +typedef enum e_FmPcdPlcrColor {
68133 + e_FM_PCD_PLCR_GREEN, /**< Green color code */
68134 + e_FM_PCD_PLCR_YELLOW, /**< Yellow color code */
68135 + e_FM_PCD_PLCR_RED, /**< Red color code */
68136 + e_FM_PCD_PLCR_OVERRIDE /**< Color override code */
68137 +} e_FmPcdPlcrColor;
68138 +
68139 +/**************************************************************************//**
68140 + @Description Enumeration type for selecting the policer profile packet frame length selector
68141 +*//***************************************************************************/
68142 +typedef enum e_FmPcdPlcrFrameLengthSelect {
68143 + e_FM_PCD_PLCR_L2_FRM_LEN, /**< L2 frame length */
68144 + e_FM_PCD_PLCR_L3_FRM_LEN, /**< L3 frame length */
68145 + e_FM_PCD_PLCR_L4_FRM_LEN, /**< L4 frame length */
68146 + e_FM_PCD_PLCR_FULL_FRM_LEN /**< Full frame length */
68147 +} e_FmPcdPlcrFrameLengthSelect;
68148 +
68149 +/**************************************************************************//**
68150 + @Description Enumeration type for selecting roll-back frame
68151 +*//***************************************************************************/
68152 +typedef enum e_FmPcdPlcrRollBackFrameSelect {
68153 + e_FM_PCD_PLCR_ROLLBACK_L2_FRM_LEN, /**< Roll-back L2 frame length */
68154 + e_FM_PCD_PLCR_ROLLBACK_FULL_FRM_LEN /**< Roll-back Full frame length */
68155 +} e_FmPcdPlcrRollBackFrameSelect;
68156 +
68157 +/**************************************************************************//**
68158 + @Description Enumeration type for selecting the policer profile packet or byte mode
68159 +*//***************************************************************************/
68160 +typedef enum e_FmPcdPlcrRateMode {
68161 + e_FM_PCD_PLCR_BYTE_MODE, /**< Byte mode */
68162 + e_FM_PCD_PLCR_PACKET_MODE /**< Packet mode */
68163 +} e_FmPcdPlcrRateMode;
68164 +
68165 +/**************************************************************************//**
68166 + @Description Enumeration type for defining action of frame
68167 +*//***************************************************************************/
68168 +typedef enum e_FmPcdDoneAction {
68169 + e_FM_PCD_ENQ_FRAME = 0, /**< Enqueue frame */
68170 + e_FM_PCD_DROP_FRAME /**< Mark this frame as error frame and continue
68171 + to error flow; 'FM_PORT_FRM_ERR_CLS_DISCARD'
68172 + flag will be set for this frame. */
68173 +} e_FmPcdDoneAction;
68174 +
68175 +/**************************************************************************//**
68176 + @Description Enumeration type for selecting the policer counter
68177 +*//***************************************************************************/
68178 +typedef enum e_FmPcdPlcrProfileCounters {
68179 + e_FM_PCD_PLCR_PROFILE_GREEN_PACKET_TOTAL_COUNTER, /**< Green packets counter */
68180 + e_FM_PCD_PLCR_PROFILE_YELLOW_PACKET_TOTAL_COUNTER, /**< Yellow packets counter */
68181 + e_FM_PCD_PLCR_PROFILE_RED_PACKET_TOTAL_COUNTER, /**< Red packets counter */
68182 + e_FM_PCD_PLCR_PROFILE_RECOLOURED_YELLOW_PACKET_TOTAL_COUNTER, /**< Recolored yellow packets counter */
68183 + e_FM_PCD_PLCR_PROFILE_RECOLOURED_RED_PACKET_TOTAL_COUNTER /**< Recolored red packets counter */
68184 +} e_FmPcdPlcrProfileCounters;
68185 +
68186 +/**************************************************************************//**
68187 + @Description Enumeration type for selecting the PCD action after extraction
68188 +*//***************************************************************************/
68189 +typedef enum e_FmPcdAction {
68190 + e_FM_PCD_ACTION_NONE, /**< NONE */
68191 + e_FM_PCD_ACTION_EXACT_MATCH, /**< Exact match on the selected extraction */
68192 + e_FM_PCD_ACTION_INDEXED_LOOKUP /**< Indexed lookup on the selected extraction */
68193 +} e_FmPcdAction;
68194 +
68195 +/**************************************************************************//**
68196 + @Description Enumeration type for selecting type of insert manipulation
68197 +*//***************************************************************************/
68198 +typedef enum e_FmPcdManipHdrInsrtType {
68199 + e_FM_PCD_MANIP_INSRT_GENERIC, /**< Insert according to offset & size */
68200 + e_FM_PCD_MANIP_INSRT_BY_HDR, /**< Insert according to protocol */
68201 +#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
68202 + e_FM_PCD_MANIP_INSRT_BY_TEMPLATE /**< Insert template to start of frame */
68203 +#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
68204 +} e_FmPcdManipHdrInsrtType;
68205 +
68206 +/**************************************************************************//**
68207 + @Description Enumeration type for selecting type of remove manipulation
68208 +*//***************************************************************************/
68209 +typedef enum e_FmPcdManipHdrRmvType {
68210 + e_FM_PCD_MANIP_RMV_GENERIC, /**< Remove according to offset & size */
68211 + e_FM_PCD_MANIP_RMV_BY_HDR /**< Remove according to offset & size */
68212 +} e_FmPcdManipHdrRmvType;
68213 +
68214 +/**************************************************************************//**
68215 + @Description Enumeration type for selecting specific L2 fields removal
68216 +*//***************************************************************************/
68217 +typedef enum e_FmPcdManipHdrRmvSpecificL2 {
68218 + e_FM_PCD_MANIP_HDR_RMV_ETHERNET, /**< Ethernet/802.3 MAC */
68219 + e_FM_PCD_MANIP_HDR_RMV_STACKED_QTAGS, /**< stacked QTags */
68220 + e_FM_PCD_MANIP_HDR_RMV_ETHERNET_AND_MPLS, /**< MPLS and Ethernet/802.3 MAC header until
68221 + the header which follows the MPLS header */
68222 + e_FM_PCD_MANIP_HDR_RMV_MPLS, /**< Remove MPLS header (Unlimited MPLS labels) */
68223 + e_FM_PCD_MANIP_HDR_RMV_PPPOE /**< Remove the PPPoE header and PPP protocol field. */
68224 +} e_FmPcdManipHdrRmvSpecificL2;
68225 +
68226 +/**************************************************************************//**
68227 + @Description Enumeration type for selecting specific fields updates
68228 +*//***************************************************************************/
68229 +typedef enum e_FmPcdManipHdrFieldUpdateType {
68230 + e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN, /**< VLAN updates */
68231 + e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV4, /**< IPV4 updates */
68232 + e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV6, /**< IPV6 updates */
68233 + e_FM_PCD_MANIP_HDR_FIELD_UPDATE_TCP_UDP, /**< TCP_UDP updates */
68234 +} e_FmPcdManipHdrFieldUpdateType;
68235 +
68236 +/**************************************************************************//**
68237 + @Description Enumeration type for selecting VLAN updates
68238 +*//***************************************************************************/
68239 +typedef enum e_FmPcdManipHdrFieldUpdateVlan {
68240 + e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN_VPRI, /**< Replace VPri of outer most VLAN tag. */
68241 + e_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN /**< DSCP to VLAN priority bits translation */
68242 +} e_FmPcdManipHdrFieldUpdateVlan;
68243 +
68244 +/**************************************************************************//**
68245 + @Description Enumeration type for selecting specific L2 header insertion
68246 +*//***************************************************************************/
68247 +typedef enum e_FmPcdManipHdrInsrtSpecificL2 {
68248 + e_FM_PCD_MANIP_HDR_INSRT_MPLS, /**< Insert MPLS header (Unlimited MPLS labels) */
68249 + e_FM_PCD_MANIP_HDR_INSRT_PPPOE /**< Insert PPPOE */
68250 +} e_FmPcdManipHdrInsrtSpecificL2;
68251 +
68252 +#if (DPAA_VERSION >= 11)
68253 +/**************************************************************************//**
68254 + @Description Enumeration type for selecting QoS mapping mode
68255 +
68256 + Note: In all cases except 'e_FM_PCD_MANIP_HDR_QOS_MAPPING_NONE'
68257 + User should instruct the port to read the hash-result
68258 +*//***************************************************************************/
68259 +typedef enum e_FmPcdManipHdrQosMappingMode {
68260 + e_FM_PCD_MANIP_HDR_QOS_MAPPING_NONE = 0, /**< No mapping, QoS field will not be changed */
68261 + e_FM_PCD_MANIP_HDR_QOS_MAPPING_AS_IS, /**< QoS field will be overwritten by the last byte in the hash-result. */
68262 +} e_FmPcdManipHdrQosMappingMode;
68263 +
68264 +/**************************************************************************//**
68265 + @Description Enumeration type for selecting QoS source
68266 +
68267 + Note: In all cases except 'e_FM_PCD_MANIP_HDR_QOS_SRC_NONE'
68268 + User should left room for the hash-result on input/output buffer
68269 + and instruct the port to read/write the hash-result to the buffer (RPD should be set)
68270 +*//***************************************************************************/
68271 +typedef enum e_FmPcdManipHdrQosSrc {
68272 + e_FM_PCD_MANIP_HDR_QOS_SRC_NONE = 0, /**< TODO */
68273 + e_FM_PCD_MANIP_HDR_QOS_SRC_USER_DEFINED, /**< QoS will be taken from the last byte in the hash-result. */
68274 +} e_FmPcdManipHdrQosSrc;
68275 +#endif /* (DPAA_VERSION >= 11) */
68276 +
68277 +/**************************************************************************//**
68278 + @Description Enumeration type for selecting type of header insertion
68279 +*//***************************************************************************/
68280 +typedef enum e_FmPcdManipHdrInsrtByHdrType {
68281 + e_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2, /**< Specific L2 fields insertion */
68282 +#if (DPAA_VERSION >= 11)
68283 + e_FM_PCD_MANIP_INSRT_BY_HDR_IP, /**< IP insertion */
68284 + e_FM_PCD_MANIP_INSRT_BY_HDR_UDP, /**< UDP insertion */
68285 + e_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE, /**< UDP lite insertion */
68286 + e_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP /**< CAPWAP insertion */
68287 +#endif /* (DPAA_VERSION >= 11) */
68288 +} e_FmPcdManipHdrInsrtByHdrType;
68289 +
68290 +/**************************************************************************//**
68291 + @Description Enumeration type for selecting specific customCommand
68292 +*//***************************************************************************/
68293 +typedef enum e_FmPcdManipHdrCustomType {
68294 + e_FM_PCD_MANIP_HDR_CUSTOM_IP_REPLACE, /**< Replace IPv4/IPv6 */
68295 + e_FM_PCD_MANIP_HDR_CUSTOM_GEN_FIELD_REPLACE, /**< Replace IPv4/IPv6 */
68296 +} e_FmPcdManipHdrCustomType;
68297 +
68298 +/**************************************************************************//**
68299 + @Description Enumeration type for selecting specific customCommand
68300 +*//***************************************************************************/
68301 +typedef enum e_FmPcdManipHdrCustomIpReplace {
68302 + e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV4_BY_IPV6, /**< Replace IPv4 by IPv6 */
68303 + e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4 /**< Replace IPv6 by IPv4 */
68304 +} e_FmPcdManipHdrCustomIpReplace;
68305 +
68306 +/**************************************************************************//**
68307 + @Description Enumeration type for selecting type of header removal
68308 +*//***************************************************************************/
68309 +typedef enum e_FmPcdManipHdrRmvByHdrType {
68310 + e_FM_PCD_MANIP_RMV_BY_HDR_SPECIFIC_L2 = 0, /**< Specific L2 fields removal */
68311 +#if (DPAA_VERSION >= 11)
68312 + e_FM_PCD_MANIP_RMV_BY_HDR_CAPWAP, /**< CAPWAP removal */
68313 +#endif /* (DPAA_VERSION >= 11) */
68314 +#if (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
68315 + e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START, /**< Locate from data that is not the header */
68316 +#endif /* (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
68317 +} e_FmPcdManipHdrRmvByHdrType;
68318 +
68319 +/**************************************************************************//**
68320 + @Description Enumeration type for selecting type of timeout mode
68321 +*//***************************************************************************/
68322 +typedef enum e_FmPcdManipReassemTimeOutMode {
68323 + e_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAMES, /**< Limits the time of the reassembly process
68324 + from the first fragment to the last */
68325 + e_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAG /**< Limits the time of receiving the fragment */
68326 +} e_FmPcdManipReassemTimeOutMode;
68327 +
68328 +/**************************************************************************//**
68329 + @Description Enumeration type for selecting type of WaysNumber mode
68330 +*//***************************************************************************/
68331 +typedef enum e_FmPcdManipReassemWaysNumber {
68332 + e_FM_PCD_MANIP_ONE_WAY_HASH = 1, /**< One way hash */
68333 + e_FM_PCD_MANIP_TWO_WAYS_HASH, /**< Two ways hash */
68334 + e_FM_PCD_MANIP_THREE_WAYS_HASH, /**< Three ways hash */
68335 + e_FM_PCD_MANIP_FOUR_WAYS_HASH, /**< Four ways hash */
68336 + e_FM_PCD_MANIP_FIVE_WAYS_HASH, /**< Five ways hash */
68337 + e_FM_PCD_MANIP_SIX_WAYS_HASH, /**< Six ways hash */
68338 + e_FM_PCD_MANIP_SEVEN_WAYS_HASH, /**< Seven ways hash */
68339 + e_FM_PCD_MANIP_EIGHT_WAYS_HASH /**< Eight ways hash */
68340 +} e_FmPcdManipReassemWaysNumber;
68341 +
68342 +#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
68343 +/**************************************************************************//**
68344 + @Description Enumeration type for selecting type of statistics mode
68345 +*//***************************************************************************/
68346 +typedef enum e_FmPcdStatsType {
68347 + e_FM_PCD_STATS_PER_FLOWID = 0 /**< Flow ID is used as index for getting statistics */
68348 +} e_FmPcdStatsType;
68349 +#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
68350 +
68351 +/**************************************************************************//**
68352 + @Description Enumeration type for selecting manipulation type
68353 +*//***************************************************************************/
68354 +typedef enum e_FmPcdManipType {
68355 + e_FM_PCD_MANIP_HDR = 0, /**< Header manipulation */
68356 + e_FM_PCD_MANIP_REASSEM, /**< Reassembly */
68357 + e_FM_PCD_MANIP_FRAG, /**< Fragmentation */
68358 + e_FM_PCD_MANIP_SPECIAL_OFFLOAD /**< Special Offloading */
68359 +} e_FmPcdManipType;
68360 +
68361 +/**************************************************************************//**
68362 + @Description Enumeration type for selecting type of statistics mode
68363 +*//***************************************************************************/
68364 +typedef enum e_FmPcdCcStatsMode {
68365 + e_FM_PCD_CC_STATS_MODE_NONE = 0, /**< No statistics support */
68366 + e_FM_PCD_CC_STATS_MODE_FRAME, /**< Frame count statistics */
68367 + e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME, /**< Byte and frame count statistics */
68368 +#if (DPAA_VERSION >= 11)
68369 + e_FM_PCD_CC_STATS_MODE_RMON, /**< Byte and frame length range count statistics;
68370 + This mode is supported only on B4860 device */
68371 +#endif /* (DPAA_VERSION >= 11) */
68372 +} e_FmPcdCcStatsMode;
68373 +
68374 +/**************************************************************************//**
68375 + @Description Enumeration type for determining the action in case an IP packet
68376 + is larger than MTU but its DF (Don't Fragment) bit is set.
68377 +*//***************************************************************************/
68378 +typedef enum e_FmPcdManipDontFragAction {
68379 + e_FM_PCD_MANIP_DISCARD_PACKET = 0, /**< Discard packet */
68380 + e_FM_PCD_MANIP_ENQ_TO_ERR_Q_OR_DISCARD_PACKET = e_FM_PCD_MANIP_DISCARD_PACKET,
68381 + /**< Obsolete, cannot enqueue to error queue;
68382 + In practice, selects to discard packets;
68383 + Will be removed in the future */
68384 + e_FM_PCD_MANIP_FRAGMENT_PACKET, /**< Fragment packet and continue normal processing */
68385 + e_FM_PCD_MANIP_CONTINUE_WITHOUT_FRAG /**< Continue normal processing without fragmenting the packet */
68386 +} e_FmPcdManipDontFragAction;
68387 +
68388 +/**************************************************************************//**
68389 + @Description Enumeration type for selecting type of special offload manipulation
68390 +*//***************************************************************************/
68391 +typedef enum e_FmPcdManipSpecialOffloadType {
68392 + e_FM_PCD_MANIP_SPECIAL_OFFLOAD_IPSEC, /**< IPSec offload manipulation */
68393 +#if (DPAA_VERSION >= 11)
68394 + e_FM_PCD_MANIP_SPECIAL_OFFLOAD_CAPWAP /**< CAPWAP offload manipulation */
68395 +#endif /* (DPAA_VERSION >= 11) */
68396 +} e_FmPcdManipSpecialOffloadType;
68397 +
68398 +
68399 +/**************************************************************************//**
68400 + @Description A Union of protocol dependent special options
68401 +*//***************************************************************************/
68402 +typedef union u_FmPcdHdrProtocolOpt {
68403 + ethProtocolOpt_t ethOpt; /**< Ethernet options */
68404 + vlanProtocolOpt_t vlanOpt; /**< VLAN options */
68405 + mplsProtocolOpt_t mplsOpt; /**< MPLS options */
68406 + ipv4ProtocolOpt_t ipv4Opt; /**< IPv4 options */
68407 + ipv6ProtocolOpt_t ipv6Opt; /**< IPv6 options */
68408 +#if (DPAA_VERSION >= 11)
68409 + capwapProtocolOpt_t capwapOpt; /**< CAPWAP options */
68410 +#endif /* (DPAA_VERSION >= 11) */
68411 +} u_FmPcdHdrProtocolOpt;
68412 +
68413 +/**************************************************************************//**
68414 + @Description A union holding protocol fields
68415 +
68416 +
68417 + Fields supported as "full fields":
68418 + HEADER_TYPE_ETH:
68419 + NET_HEADER_FIELD_ETH_DA
68420 + NET_HEADER_FIELD_ETH_SA
68421 + NET_HEADER_FIELD_ETH_TYPE
68422 +
68423 + HEADER_TYPE_LLC_SNAP:
68424 + NET_HEADER_FIELD_LLC_SNAP_TYPE
68425 +
68426 + HEADER_TYPE_VLAN:
68427 + NET_HEADER_FIELD_VLAN_TCI
68428 + (index may apply:
68429 + e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
68430 + e_FM_PCD_HDR_INDEX_LAST)
68431 +
68432 + HEADER_TYPE_MPLS:
68433 + NET_HEADER_FIELD_MPLS_LABEL_STACK
68434 + (index may apply:
68435 + e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
68436 + e_FM_PCD_HDR_INDEX_2,
68437 + e_FM_PCD_HDR_INDEX_LAST)
68438 +
68439 + HEADER_TYPE_IPv4:
68440 + NET_HEADER_FIELD_IPv4_SRC_IP
68441 + NET_HEADER_FIELD_IPv4_DST_IP
68442 + NET_HEADER_FIELD_IPv4_PROTO
68443 + NET_HEADER_FIELD_IPv4_TOS
68444 + (index may apply:
68445 + e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
68446 + e_FM_PCD_HDR_INDEX_2/e_FM_PCD_HDR_INDEX_LAST)
68447 +
68448 + HEADER_TYPE_IPv6:
68449 + NET_HEADER_FIELD_IPv6_SRC_IP
68450 + NET_HEADER_FIELD_IPv6_DST_IP
68451 + NET_HEADER_FIELD_IPv6_NEXT_HDR
68452 + NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_FL | NET_HEADER_FIELD_IPv6_TC (must come together!)
68453 + (index may apply:
68454 + e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
68455 + e_FM_PCD_HDR_INDEX_2/e_FM_PCD_HDR_INDEX_LAST)
68456 +
68457 + (Note that starting from DPAA 1-1, NET_HEADER_FIELD_IPv6_NEXT_HDR applies to
68458 + the last next header indication, meaning the next L4, which may be
68459 + present at the Ipv6 last extension. On earlier revisions this field
68460 + applies to the Next-Header field of the main IPv6 header)
68461 +
68462 + HEADER_TYPE_IP:
68463 + NET_HEADER_FIELD_IP_PROTO
68464 + (index may apply:
68465 + e_FM_PCD_HDR_INDEX_LAST)
68466 + NET_HEADER_FIELD_IP_DSCP
68467 + (index may apply:
68468 + e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1)
68469 + HEADER_TYPE_GRE:
68470 + NET_HEADER_FIELD_GRE_TYPE
68471 +
68472 + HEADER_TYPE_MINENCAP
68473 + NET_HEADER_FIELD_MINENCAP_SRC_IP
68474 + NET_HEADER_FIELD_MINENCAP_DST_IP
68475 + NET_HEADER_FIELD_MINENCAP_TYPE
68476 +
68477 + HEADER_TYPE_TCP:
68478 + NET_HEADER_FIELD_TCP_PORT_SRC
68479 + NET_HEADER_FIELD_TCP_PORT_DST
68480 + NET_HEADER_FIELD_TCP_FLAGS
68481 +
68482 + HEADER_TYPE_UDP:
68483 + NET_HEADER_FIELD_UDP_PORT_SRC
68484 + NET_HEADER_FIELD_UDP_PORT_DST
68485 +
68486 + HEADER_TYPE_UDP_LITE:
68487 + NET_HEADER_FIELD_UDP_LITE_PORT_SRC
68488 + NET_HEADER_FIELD_UDP_LITE_PORT_DST
68489 +
68490 + HEADER_TYPE_IPSEC_AH:
68491 + NET_HEADER_FIELD_IPSEC_AH_SPI
68492 + NET_HEADER_FIELD_IPSEC_AH_NH
68493 +
68494 + HEADER_TYPE_IPSEC_ESP:
68495 + NET_HEADER_FIELD_IPSEC_ESP_SPI
68496 +
68497 + HEADER_TYPE_SCTP:
68498 + NET_HEADER_FIELD_SCTP_PORT_SRC
68499 + NET_HEADER_FIELD_SCTP_PORT_DST
68500 +
68501 + HEADER_TYPE_DCCP:
68502 + NET_HEADER_FIELD_DCCP_PORT_SRC
68503 + NET_HEADER_FIELD_DCCP_PORT_DST
68504 +
68505 + HEADER_TYPE_PPPoE:
68506 + NET_HEADER_FIELD_PPPoE_PID
68507 + NET_HEADER_FIELD_PPPoE_SID
68508 +
68509 + *****************************************************************
68510 + Fields supported as "from fields":
68511 + HEADER_TYPE_ETH (with or without validation):
68512 + NET_HEADER_FIELD_ETH_TYPE
68513 +
68514 + HEADER_TYPE_VLAN (with or without validation):
68515 + NET_HEADER_FIELD_VLAN_TCI
68516 + (index may apply:
68517 + e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
68518 + e_FM_PCD_HDR_INDEX_LAST)
68519 +
68520 + HEADER_TYPE_IPv4 (without validation):
68521 + NET_HEADER_FIELD_IPv4_PROTO
68522 + (index may apply:
68523 + e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
68524 + e_FM_PCD_HDR_INDEX_2/e_FM_PCD_HDR_INDEX_LAST)
68525 +
68526 + HEADER_TYPE_IPv6 (without validation):
68527 + NET_HEADER_FIELD_IPv6_NEXT_HDR
68528 + (index may apply:
68529 + e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
68530 + e_FM_PCD_HDR_INDEX_2/e_FM_PCD_HDR_INDEX_LAST)
68531 +
68532 +*//***************************************************************************/
68533 +typedef union t_FmPcdFields {
68534 + headerFieldEth_t eth; /**< Ethernet */
68535 + headerFieldVlan_t vlan; /**< VLAN */
68536 + headerFieldLlcSnap_t llcSnap; /**< LLC SNAP */
68537 + headerFieldPppoe_t pppoe; /**< PPPoE */
68538 + headerFieldMpls_t mpls; /**< MPLS */
68539 + headerFieldIp_t ip; /**< IP */
68540 + headerFieldIpv4_t ipv4; /**< IPv4 */
68541 + headerFieldIpv6_t ipv6; /**< IPv6 */
68542 + headerFieldUdp_t udp; /**< UDP */
68543 + headerFieldUdpLite_t udpLite; /**< UDP Lite */
68544 + headerFieldTcp_t tcp; /**< TCP */
68545 + headerFieldSctp_t sctp; /**< SCTP */
68546 + headerFieldDccp_t dccp; /**< DCCP */
68547 + headerFieldGre_t gre; /**< GRE */
68548 + headerFieldMinencap_t minencap; /**< Minimal Encapsulation */
68549 + headerFieldIpsecAh_t ipsecAh; /**< IPSec AH */
68550 + headerFieldIpsecEsp_t ipsecEsp; /**< IPSec ESP */
68551 + headerFieldUdpEncapEsp_t udpEncapEsp; /**< UDP Encapsulation ESP */
68552 +} t_FmPcdFields;
68553 +
68554 +/**************************************************************************//**
68555 + @Description Parameters for defining header extraction for key generation
68556 +*//***************************************************************************/
68557 +typedef struct t_FmPcdFromHdr {
68558 + uint8_t size; /**< Size in byte */
68559 + uint8_t offset; /**< Byte offset */
68560 +} t_FmPcdFromHdr;
68561 +
68562 +/**************************************************************************//**
68563 + @Description Parameters for defining field extraction for key generation
68564 +*//***************************************************************************/
68565 +typedef struct t_FmPcdFromField {
68566 + t_FmPcdFields field; /**< Field selection */
68567 + uint8_t size; /**< Size in byte */
68568 + uint8_t offset; /**< Byte offset */
68569 +} t_FmPcdFromField;
68570 +
68571 +/**************************************************************************//**
68572 + @Description Parameters for defining a single network environment unit
68573 +
68574 + A distinction unit should be defined if it will later be used
68575 + by one or more PCD engines to distinguish between flows.
68576 +*//***************************************************************************/
68577 +typedef struct t_FmPcdDistinctionUnit {
68578 + struct {
68579 + e_NetHeaderType hdr; /**< One of the headers supported by the FM */
68580 + u_FmPcdHdrProtocolOpt opt; /**< Select only one option ! */
68581 + } hdrs[FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS];
68582 +} t_FmPcdDistinctionUnit;
68583 +
68584 +/**************************************************************************//**
68585 + @Description Parameters for defining all different distinction units supported
68586 + by a specific PCD Network Environment Characteristics module.
68587 +
68588 + Each unit represent a protocol or a group of protocols that may
68589 + be used later by the different PCD engines to distinguish
68590 + between flows.
68591 +*//***************************************************************************/
68592 +typedef struct t_FmPcdNetEnvParams {
68593 + uint8_t numOfDistinctionUnits; /**< Number of different units to be identified */
68594 + t_FmPcdDistinctionUnit units[FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS]; /**< An array of numOfDistinctionUnits of the
68595 + different units to be identified */
68596 +} t_FmPcdNetEnvParams;
68597 +
68598 +/**************************************************************************//**
68599 + @Description Parameters for defining a single extraction action when
68600 + creating a key
68601 +*//***************************************************************************/
68602 +typedef struct t_FmPcdExtractEntry {
68603 + e_FmPcdExtractType type; /**< Extraction type select */
68604 + union {
68605 + struct {
68606 + e_NetHeaderType hdr; /**< Header selection */
68607 + bool ignoreProtocolValidation;
68608 + /**< Ignore protocol validation */
68609 + e_FmPcdHdrIndex hdrIndex; /**< Relevant only for MPLS, VLAN and tunneled
68610 + IP. Otherwise should be cleared. */
68611 + e_FmPcdExtractByHdrType type; /**< Header extraction type select */
68612 + union {
68613 + t_FmPcdFromHdr fromHdr; /**< Extract bytes from header parameters */
68614 + t_FmPcdFromField fromField; /**< Extract bytes from field parameters */
68615 + t_FmPcdFields fullField; /**< Extract full filed parameters */
68616 + } extractByHdrType;
68617 + } extractByHdr; /**< used when type = e_FM_PCD_KG_EXTRACT_BY_HDR */
68618 + struct {
68619 + e_FmPcdExtractFrom src; /**< Non-header extraction source */
68620 + e_FmPcdAction action; /**< Relevant for CC Only */
68621 + uint16_t icIndxMask; /**< Relevant only for CC when
68622 + action = e_FM_PCD_ACTION_INDEXED_LOOKUP;
68623 + Note that the number of bits that are set within
68624 + this mask must be log2 of the CC-node 'numOfKeys'.
68625 + Note that the mask cannot be set on the lower bits. */
68626 + uint8_t offset; /**< Byte offset */
68627 + uint8_t size; /**< Size in byte */
68628 + } extractNonHdr; /**< used when type = e_FM_PCD_KG_EXTRACT_NON_HDR */
68629 + };
68630 +} t_FmPcdExtractEntry;
68631 +
68632 +/**************************************************************************//**
68633 + @Description Parameters for defining masks for each extracted field in the key.
68634 +*//***************************************************************************/
68635 +typedef struct t_FmPcdKgExtractMask {
68636 + uint8_t extractArrayIndex; /**< Index in the extraction array, as initialized by user */
68637 + uint8_t offset; /**< Byte offset */
68638 + uint8_t mask; /**< A byte mask (selected bits will be used) */
68639 +} t_FmPcdKgExtractMask;
68640 +
68641 +/**************************************************************************//**
68642 + @Description Parameters for defining default selection per groups of fields
68643 +*//***************************************************************************/
68644 +typedef struct t_FmPcdKgExtractDflt {
68645 + e_FmPcdKgKnownFieldsDfltTypes type; /**< Default type select */
68646 + e_FmPcdKgExtractDfltSelect dfltSelect; /**< Default register select */
68647 +} t_FmPcdKgExtractDflt;
68648 +
68649 +/**************************************************************************//**
68650 + @Description Parameters for defining key extraction and hashing
68651 +*//***************************************************************************/
68652 +typedef struct t_FmPcdKgKeyExtractAndHashParams {
68653 + uint32_t privateDflt0; /**< Scheme default register 0 */
68654 + uint32_t privateDflt1; /**< Scheme default register 1 */
68655 + uint8_t numOfUsedExtracts; /**< defines the valid size of the following array */
68656 + t_FmPcdExtractEntry extractArray [FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY]; /**< An array of extractions definition. */
68657 + uint8_t numOfUsedDflts; /**< defines the valid size of the following array */
68658 + t_FmPcdKgExtractDflt dflts[FM_PCD_KG_NUM_OF_DEFAULT_GROUPS];
68659 + /**< For each extraction used in this scheme, specify the required
68660 + default register to be used when header is not found.
68661 + types not specified in this array will get undefined value. */
68662 + uint8_t numOfUsedMasks; /**< defines the valid size of the following array */
68663 + t_FmPcdKgExtractMask masks[FM_PCD_KG_NUM_OF_EXTRACT_MASKS];
68664 + uint8_t hashShift; /**< hash result right shift. Select the 24 bits out of the 64 hash
68665 + result. 0 means using the 24 LSB's, otherwise use the
68666 + 24 LSB's after shifting right.*/
68667 + uint32_t hashDistributionNumOfFqids; /**< must be > 1 and a power of 2. Represents the range
68668 + of queues for the key and hash functionality */
68669 + uint8_t hashDistributionFqidsShift; /**< selects the FQID bits that will be effected by the hash */
68670 + bool symmetricHash; /**< TRUE to generate the same hash for frames with swapped source and
68671 + destination fields on all layers; If TRUE, driver will check that for
68672 + all layers, if SRC extraction is selected, DST extraction must also be
68673 + selected, and vice versa. */
68674 +} t_FmPcdKgKeyExtractAndHashParams;
68675 +
68676 +/**************************************************************************//**
68677 + @Description Parameters for defining a single FQID mask (extracted OR).
68678 +*//***************************************************************************/
68679 +typedef struct t_FmPcdKgExtractedOrParams {
68680 + e_FmPcdExtractType type; /**< Extraction type select */
68681 + union {
68682 + struct { /**< used when type = e_FM_PCD_KG_EXTRACT_BY_HDR */
68683 + e_NetHeaderType hdr;
68684 + e_FmPcdHdrIndex hdrIndex; /**< Relevant only for MPLS, VLAN and tunneled
68685 + IP. Otherwise should be cleared.*/
68686 + bool ignoreProtocolValidation;
68687 + /**< continue extraction even if protocol is not recognized */
68688 + } extractByHdr; /**< Header to extract by */
68689 + e_FmPcdExtractFrom src; /**< used when type = e_FM_PCD_KG_EXTRACT_NON_HDR */
68690 + };
68691 + uint8_t extractionOffset; /**< Offset for extraction (in bytes). */
68692 + e_FmPcdKgExtractDfltSelect dfltValue; /**< Select register from which extraction is taken if
68693 + field not found */
68694 + uint8_t mask; /**< Extraction mask (specified bits are used) */
68695 + uint8_t bitOffsetInFqid; /**< 0-31, Selects which bits of the 24 FQID bits to effect using
68696 + the extracted byte; Assume byte is placed as the 8 MSB's in
68697 + a 32 bit word where the lower bits
68698 + are the FQID; i.e if bitOffsetInFqid=1 than its LSB
68699 + will effect the FQID MSB, if bitOffsetInFqid=24 than the
68700 + extracted byte will effect the 8 LSB's of the FQID,
68701 + if bitOffsetInFqid=31 than the byte's MSB will effect
68702 + the FQID's LSB; 0 means - no effect on FQID;
68703 + Note that one, and only one of
68704 + bitOffsetInFqid or bitOffsetInPlcrProfile must be set (i.e,
68705 + extracted byte must effect either FQID or Policer profile).*/
68706 + uint8_t bitOffsetInPlcrProfile;
68707 + /**< 0-15, Selects which bits of the 8 policer profile id bits to
68708 + effect using the extracted byte; Assume byte is placed
68709 + as the 8 MSB's in a 16 bit word where the lower bits
68710 + are the policer profile id; i.e if bitOffsetInPlcrProfile=1
68711 + than its LSB will effect the profile MSB, if bitOffsetInFqid=8
68712 + than the extracted byte will effect the whole policer profile id,
68713 + if bitOffsetInFqid=15 than the byte's MSB will effect
68714 + the Policer Profile id's LSB;
68715 + 0 means - no effect on policer profile; Note that one, and only one of
68716 + bitOffsetInFqid or bitOffsetInPlcrProfile must be set (i.e,
68717 + extracted byte must effect either FQID or Policer profile).*/
68718 +} t_FmPcdKgExtractedOrParams;
68719 +
68720 +/**************************************************************************//**
68721 + @Description Parameters for configuring a scheme counter
68722 +*//***************************************************************************/
68723 +typedef struct t_FmPcdKgSchemeCounter {
68724 + bool update; /**< FALSE to keep the current counter state
68725 + and continue from that point, TRUE to update/reset
68726 + the counter when the scheme is written. */
68727 + uint32_t value; /**< If update=TRUE, this value will be written into the
68728 + counter. clear this field to reset the counter. */
68729 +} t_FmPcdKgSchemeCounter;
68730 +
68731 +/**************************************************************************//**
68732 + @Description Parameters for configuring a policer profile for a KeyGen scheme
68733 + (when policer is the next engine after this scheme).
68734 +*//***************************************************************************/
68735 +typedef struct t_FmPcdKgPlcrProfile {
68736 + bool sharedProfile; /**< TRUE if this profile is shared between ports
68737 + (managed by master partition); Must not be TRUE
68738 + if profile is after Coarse Classification*/
68739 + bool direct; /**< if TRUE, directRelativeProfileId only selects the profile
68740 + id, if FALSE fqidOffsetRelativeProfileIdBase is used
68741 + together with fqidOffsetShift and numOfProfiles
68742 + parameters, to define a range of profiles from
68743 + which the KeyGen result will determine the
68744 + destination policer profile. */
68745 + union {
68746 + uint16_t directRelativeProfileId; /**< Used if 'direct' is TRUE, to select policer profile.
68747 + should indicate the policer profile offset within the
68748 + port's policer profiles or shared window. */
68749 + struct {
68750 + uint8_t fqidOffsetShift; /**< Shift on the KeyGen create FQID offset (i.e. not the
68751 + final FQID - without the FQID base). */
68752 + uint8_t fqidOffsetRelativeProfileIdBase;
68753 + /**< The base of the FMan Port's relative Storage-Profile ID;
68754 + this value will be "OR'ed" with the KeyGen create FQID
68755 + offset (i.e. not the final FQID - without the FQID base);
68756 + the final result should indicate the Storage-Profile offset
68757 + within the FMan Port's relative Storage-Profiles window/
68758 + (or the SHARED window depends on 'sharedProfile'). */
68759 + uint8_t numOfProfiles; /**< Range of profiles starting at base */
68760 + } indirectProfile; /**< Indirect profile parameters */
68761 + } profileSelect; /**< Direct/indirect profile selection and parameters */
68762 +} t_FmPcdKgPlcrProfile;
68763 +
68764 +#if (DPAA_VERSION >= 11)
68765 +/**************************************************************************//**
68766 + @Description Parameters for configuring a storage profile for a KeyGen scheme.
68767 +*//***************************************************************************/
68768 +typedef struct t_FmPcdKgStorageProfile {
68769 + bool direct; /**< If TRUE, directRelativeProfileId only selects the
68770 + profile id;
68771 + If FALSE, fqidOffsetRelativeProfileIdBase is used
68772 + together with fqidOffsetShift and numOfProfiles
68773 + parameters to define a range of profiles from which
68774 + the KeyGen result will determine the destination
68775 + storage profile. */
68776 + union {
68777 + uint16_t directRelativeProfileId; /**< Used when 'direct' is TRUE, to select a storage profile;
68778 + should indicate the storage profile offset within the
68779 + port's storage profiles window. */
68780 + struct {
68781 + uint8_t fqidOffsetShift; /**< Shift on the KeyGen create FQID offset (i.e. not the
68782 + final FQID - without the FQID base). */
68783 + uint8_t fqidOffsetRelativeProfileIdBase;
68784 + /**< The base of the FMan Port's relative Storage-Profile ID;
68785 + this value will be "OR'ed" with the KeyGen create FQID
68786 + offset (i.e. not the final FQID - without the FQID base);
68787 + the final result should indicate the Storage-Profile offset
68788 + within the FMan Port's relative Storage-Profiles window. */
68789 + uint8_t numOfProfiles; /**< Range of profiles starting at base. */
68790 + } indirectProfile; /**< Indirect profile parameters. */
68791 + } profileSelect; /**< Direct/indirect profile selection and parameters. */
68792 +} t_FmPcdKgStorageProfile;
68793 +#endif /* (DPAA_VERSION >= 11) */
68794 +
68795 +/**************************************************************************//**
68796 + @Description Parameters for defining CC as the next engine after KeyGen
68797 +*//***************************************************************************/
68798 +typedef struct t_FmPcdKgCc {
68799 + t_Handle h_CcTree; /**< A handle to a CC Tree */
68800 + uint8_t grpId; /**< CC group id within the CC tree */
68801 + bool plcrNext; /**< TRUE if after CC, in case of data frame,
68802 + policing is required. */
68803 + bool bypassPlcrProfileGeneration; /**< TRUE to bypass KeyGen policer profile generation;
68804 + selected profile is the one set at port initialization. */
68805 + t_FmPcdKgPlcrProfile plcrProfile; /**< Valid only if plcrNext = TRUE and
68806 + bypassPlcrProfileGeneration = FALSE */
68807 +} t_FmPcdKgCc;
68808 +
68809 +/**************************************************************************//**
68810 + @Description Parameters for defining initializing a KeyGen scheme
68811 +*//***************************************************************************/
68812 +typedef struct t_FmPcdKgSchemeParams {
68813 + bool modify; /**< TRUE to change an existing scheme */
68814 + union
68815 + {
68816 + uint8_t relativeSchemeId; /**< if modify=FALSE:Partition relative scheme id */
68817 + t_Handle h_Scheme; /**< if modify=TRUE: a handle of the existing scheme */
68818 + } id;
68819 + bool alwaysDirect; /**< This scheme is reached only directly, i.e. no need
68820 + for match vector; KeyGen will ignore it when matching */
68821 + struct { /**< HL Relevant only if alwaysDirect = FALSE */
68822 + t_Handle h_NetEnv; /**< A handle to the Network environment as returned
68823 + by FM_PCD_NetEnvCharacteristicsSet() */
68824 + uint8_t numOfDistinctionUnits; /**< Number of NetEnv units listed in unitIds array */
68825 + uint8_t unitIds[FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS];
68826 + /**< Indexes as passed to SetNetEnvCharacteristics array*/
68827 + } netEnvParams;
68828 + bool useHash; /**< use the KeyGen Hash functionality */
68829 + t_FmPcdKgKeyExtractAndHashParams keyExtractAndHashParams;
68830 + /**< used only if useHash = TRUE */
68831 + bool bypassFqidGeneration; /**< Normally - FALSE, TRUE to avoid FQID update in the IC;
68832 + In such a case FQID after KeyGen will be the default FQID
68833 + defined for the relevant port, or the FQID defined by CC
68834 + in cases where CC was the previous engine. */
68835 + uint32_t baseFqid; /**< Base FQID; Relevant only if bypassFqidGeneration = FALSE;
68836 + If hash is used and an even distribution is expected
68837 + according to hashDistributionNumOfFqids, baseFqid must be aligned to
68838 + hashDistributionNumOfFqids. */
68839 + uint8_t numOfUsedExtractedOrs; /**< Number of FQID masks listed in extractedOrs array */
68840 + t_FmPcdKgExtractedOrParams extractedOrs[FM_PCD_KG_NUM_OF_GENERIC_REGS];
68841 + /**< FM_PCD_KG_NUM_OF_GENERIC_REGS
68842 + registers are shared between qidMasks
68843 + functionality and some of the extraction
68844 + actions; Normally only some will be used
68845 + for qidMask. Driver will return error if
68846 + resource is full at initialization time. */
68847 +
68848 +#if (DPAA_VERSION >= 11)
68849 + bool overrideStorageProfile; /**< TRUE if KeyGen override previously decided storage profile */
68850 + t_FmPcdKgStorageProfile storageProfile; /**< Used when overrideStorageProfile TRUE */
68851 +#endif /* (DPAA_VERSION >= 11) */
68852 +
68853 + e_FmPcdEngine nextEngine; /**< may be BMI, PLCR or CC */
68854 + union { /**< depends on nextEngine */
68855 + e_FmPcdDoneAction doneAction; /**< Used when next engine is BMI (done) */
68856 + t_FmPcdKgPlcrProfile plcrProfile; /**< Used when next engine is PLCR */
68857 + t_FmPcdKgCc cc; /**< Used when next engine is CC */
68858 + } kgNextEngineParams;
68859 + t_FmPcdKgSchemeCounter schemeCounter; /**< A structure of parameters for updating
68860 + the scheme counter */
68861 +} t_FmPcdKgSchemeParams;
68862 +
68863 +/**************************************************************************//**
68864 + @Collection Definitions for CC statistics
68865 +*//***************************************************************************/
68866 +#if (DPAA_VERSION >= 11)
68867 +#define FM_PCD_CC_STATS_MAX_NUM_OF_FLR 10 /* Maximal supported number of frame length ranges */
68868 +#define FM_PCD_CC_STATS_FLR_SIZE 2 /* Size in bytes of a frame length range limit */
68869 +#endif /* (DPAA_VERSION >= 11) */
68870 +#define FM_PCD_CC_STATS_COUNTER_SIZE 4 /* Size in bytes of a frame length range counter */
68871 +/* @} */
68872 +
68873 +/**************************************************************************//**
68874 + @Description Parameters for defining CC as the next engine after a CC node.
68875 +*//***************************************************************************/
68876 +typedef struct t_FmPcdCcNextCcParams {
68877 + t_Handle h_CcNode; /**< A handle of the next CC node */
68878 +} t_FmPcdCcNextCcParams;
68879 +
68880 +#if (DPAA_VERSION >= 11)
68881 +/**************************************************************************//**
68882 + @Description Parameters for defining Frame replicator as the next engine after a CC node.
68883 +*//***************************************************************************/
68884 +typedef struct t_FmPcdCcNextFrParams {
68885 + t_Handle h_FrmReplic; /**< A handle of the next frame replicator group */
68886 +} t_FmPcdCcNextFrParams;
68887 +#endif /* (DPAA_VERSION >= 11) */
68888 +
68889 +/**************************************************************************//**
68890 + @Description Parameters for defining Policer as the next engine after a CC node.
68891 +*//***************************************************************************/
68892 +typedef struct t_FmPcdCcNextPlcrParams {
68893 + bool overrideParams; /**< TRUE if CC override previously decided parameters*/
68894 + bool sharedProfile; /**< Relevant only if overrideParams=TRUE:
68895 + TRUE if this profile is shared between ports */
68896 + uint16_t newRelativeProfileId; /**< Relevant only if overrideParams=TRUE:
68897 + (otherwise profile id is taken from KeyGen);
68898 + This parameter should indicate the policer
68899 + profile offset within the port's
68900 + policer profiles or from SHARED window.*/
68901 + uint32_t newFqid; /**< Relevant only if overrideParams=TRUE:
68902 + FQID for enqueuing the frame;
68903 + In earlier chips if policer next engine is KEYGEN,
68904 + this parameter can be 0, because the KEYGEN
68905 + always decides the enqueue FQID.*/
68906 +#if (DPAA_VERSION >= 11)
68907 + uint8_t newRelativeStorageProfileId;
68908 + /**< Indicates the relative storage profile offset within
68909 + the port's storage profiles window;
68910 + Relevant only if the port was configured with VSP. */
68911 +#endif /* (DPAA_VERSION >= 11) */
68912 +} t_FmPcdCcNextPlcrParams;
68913 +
68914 +/**************************************************************************//**
68915 + @Description Parameters for defining enqueue as the next action after a CC node.
68916 +*//***************************************************************************/
68917 +typedef struct t_FmPcdCcNextEnqueueParams {
68918 + e_FmPcdDoneAction action; /**< Action - when next engine is BMI (done) */
68919 + bool overrideFqid; /**< TRUE if CC override previously decided fqid and vspid,
68920 + relevant if action = e_FM_PCD_ENQ_FRAME */
68921 + uint32_t newFqid; /**< Valid if overrideFqid=TRUE, FQID for enqueuing the frame
68922 + (otherwise FQID is taken from KeyGen),
68923 + relevant if action = e_FM_PCD_ENQ_FRAME */
68924 +#if (DPAA_VERSION >= 11)
68925 + uint8_t newRelativeStorageProfileId;
68926 + /**< Valid if overrideFqid=TRUE, Indicates the relative virtual
68927 + storage profile offset within the port's storage profiles
68928 + window; Relevant only if the port was configured with VSP. */
68929 +#endif /* (DPAA_VERSION >= 11) */
68930 +} t_FmPcdCcNextEnqueueParams;
68931 +
68932 +/**************************************************************************//**
68933 + @Description Parameters for defining KeyGen as the next engine after a CC node.
68934 +*//***************************************************************************/
68935 +typedef struct t_FmPcdCcNextKgParams {
68936 + bool overrideFqid; /**< TRUE if CC override previously decided fqid and vspid,
68937 + Note - this parameters irrelevant for earlier chips */
68938 + uint32_t newFqid; /**< Valid if overrideFqid=TRUE, FQID for enqueuing the frame
68939 + (otherwise FQID is taken from KeyGen),
68940 + Note - this parameters irrelevant for earlier chips */
68941 +#if (DPAA_VERSION >= 11)
68942 + uint8_t newRelativeStorageProfileId;
68943 + /**< Valid if overrideFqid=TRUE, Indicates the relative virtual
68944 + storage profile offset within the port's storage profiles
68945 + window; Relevant only if the port was configured with VSP. */
68946 +#endif /* (DPAA_VERSION >= 11) */
68947 +
68948 + t_Handle h_DirectScheme; /**< Direct scheme handle to go to. */
68949 +} t_FmPcdCcNextKgParams;
68950 +
68951 +/**************************************************************************//**
68952 + @Description Parameters for defining the next engine after a CC node.
68953 +*//***************************************************************************/
68954 +typedef struct t_FmPcdCcNextEngineParams {
68955 + e_FmPcdEngine nextEngine; /**< User has to initialize parameters
68956 + according to nextEngine definition */
68957 + union {
68958 + t_FmPcdCcNextCcParams ccParams; /**< Parameters in case next engine is CC */
68959 + t_FmPcdCcNextPlcrParams plcrParams; /**< Parameters in case next engine is PLCR */
68960 + t_FmPcdCcNextEnqueueParams enqueueParams; /**< Parameters in case next engine is BMI */
68961 + t_FmPcdCcNextKgParams kgParams; /**< Parameters in case next engine is KG */
68962 +#if (DPAA_VERSION >= 11)
68963 + t_FmPcdCcNextFrParams frParams; /**< Parameters in case next engine is FR */
68964 +#endif /* (DPAA_VERSION >= 11) */
68965 + } params; /**< union used for all the next-engine parameters options */
68966 +
68967 + t_Handle h_Manip; /**< Handle to Manipulation object.
68968 + Relevant if next engine is of type result
68969 + (e_FM_PCD_PLCR, e_FM_PCD_KG, e_FM_PCD_DONE) */
68970 +
68971 + bool statisticsEn; /**< If TRUE, statistics counters are incremented
68972 + for each frame passing through this
68973 + Coarse Classification entry. */
68974 +} t_FmPcdCcNextEngineParams;
68975 +
68976 +/**************************************************************************//**
68977 + @Description Parameters for defining a single CC key
68978 +*//***************************************************************************/
68979 +typedef struct t_FmPcdCcKeyParams {
68980 + uint8_t *p_Key; /**< Relevant only if 'action' = e_FM_PCD_ACTION_EXACT_MATCH;
68981 + pointer to the key of the size defined in keySize */
68982 + uint8_t *p_Mask; /**< Relevant only if 'action' = e_FM_PCD_ACTION_EXACT_MATCH;
68983 + pointer to the Mask per key of the size defined
68984 + in keySize. p_Key and p_Mask (if defined) has to be
68985 + of the same size defined in the keySize;
68986 + NOTE that if this value is equal for all entries whithin
68987 + this table, the driver will automatically use global-mask
68988 + (i.e. one common mask for all entries) instead of private
68989 + one; that is done in order to spare some memory and for
68990 + better performance. */
68991 + t_FmPcdCcNextEngineParams ccNextEngineParams;
68992 + /**< parameters for the next for the defined Key in
68993 + the p_Key */
68994 +} t_FmPcdCcKeyParams;
68995 +
68996 +/**************************************************************************//**
68997 + @Description Parameters for defining CC keys parameters
68998 + The driver supports two methods for CC node allocation: dynamic and static.
68999 + Static mode was created in order to prevent runtime alloc/free
69000 + of FMan memory (MURAM), which may cause fragmentation; in this mode,
69001 + the driver automatically allocates the memory according to
69002 + 'maxNumOfKeys' parameter. The driver calculates the maximal memory
69003 + size that may be used for this CC-Node taking into consideration
69004 + 'maskSupport' and 'statisticsMode' parameters.
69005 + When 'action' = e_FM_PCD_ACTION_INDEXED_LOOKUP in the extraction
69006 + parameters of this node, 'maxNumOfKeys' must be equal to 'numOfKeys'.
69007 + In dynamic mode, 'maxNumOfKeys' must be zero. At initialization,
69008 + all required structures are allocated according to 'numOfKeys'
69009 + parameter. During runtime modification, these structures are
69010 + re-allocated according to the updated number of keys.
69011 +
69012 + Please note that 'action' and 'icIndxMask' mentioned in the
69013 + specific parameter explanations are passed in the extraction
69014 + parameters of the node (fields of extractCcParams.extractNonHdr).
69015 +*//***************************************************************************/
69016 +typedef struct t_KeysParams {
69017 + uint16_t maxNumOfKeys; /**< Maximum number of keys that will (ever) be used in this CC-Node;
69018 + A value of zero may be used for dynamic memory allocation. */
69019 + bool maskSupport; /**< This parameter is relevant only if a node is initialized with
69020 + 'action' = e_FM_PCD_ACTION_EXACT_MATCH and maxNumOfKeys > 0;
69021 + Should be TRUE to reserve table memory for key masks, even if
69022 + initial keys do not contain masks, or if the node was initialized
69023 + as 'empty' (without keys); this will allow user to add keys with
69024 + masks at runtime.
69025 + NOTE that if user want to use only global-masks (i.e. one common mask
69026 + for all the entries within this table, this parameter should set to 'FALSE'. */
69027 + e_FmPcdCcStatsMode statisticsMode; /**< Determines the supported statistics mode for all node's keys.
69028 + To enable statistics gathering, statistics should be enabled per
69029 + every key, using 'statisticsEn' in next engine parameters structure
69030 + of that key;
69031 + If 'maxNumOfKeys' is set, all required structures will be
69032 + preallocated for all keys. */
69033 +#if (DPAA_VERSION >= 11)
69034 + uint16_t frameLengthRanges[FM_PCD_CC_STATS_MAX_NUM_OF_FLR];
69035 + /**< Relevant only for 'RMON' statistics mode
69036 + (this feature is supported only on B4860 device);
69037 + Holds a list of programmable thresholds - for each received frame,
69038 + its length in bytes is examined against these range thresholds and
69039 + the appropriate counter is incremented by 1 - for example, to belong
69040 + to range i, the following should hold:
69041 + range i-1 threshold < frame length <= range i threshold
69042 + Each range threshold must be larger then its preceding range
69043 + threshold, and last range threshold must be 0xFFFF. */
69044 +#endif /* (DPAA_VERSION >= 11) */
69045 + uint16_t numOfKeys; /**< Number of initial keys;
69046 + Note that in case of 'action' = e_FM_PCD_ACTION_INDEXED_LOOKUP,
69047 + this field should be power-of-2 of the number of bits that are
69048 + set in 'icIndxMask'. */
69049 + uint8_t keySize; /**< Size of key - for extraction of type FULL_FIELD, 'keySize' has
69050 + to be the standard size of the selected key; For other extraction
69051 + types, 'keySize' has to be as size of extraction; When 'action' =
69052 + e_FM_PCD_ACTION_INDEXED_LOOKUP, 'keySize' must be 2. */
69053 + t_FmPcdCcKeyParams keyParams[FM_PCD_MAX_NUM_OF_KEYS];
69054 + /**< An array with 'numOfKeys' entries, each entry specifies the
69055 + corresponding key parameters;
69056 + When 'action' = e_FM_PCD_ACTION_EXACT_MATCH, this value must not
69057 + exceed 255 (FM_PCD_MAX_NUM_OF_KEYS-1) as the last entry is saved
69058 + for the 'miss' entry. */
69059 + t_FmPcdCcNextEngineParams ccNextEngineParamsForMiss;
69060 + /**< Parameters for defining the next engine when a key is not matched;
69061 + Not relevant if action = e_FM_PCD_ACTION_INDEXED_LOOKUP. */
69062 +} t_KeysParams;
69063 +
69064 +
69065 +/**************************************************************************//**
69066 + @Description Parameters for defining a CC node
69067 +*//***************************************************************************/
69068 +typedef struct t_FmPcdCcNodeParams {
69069 + t_FmPcdExtractEntry extractCcParams; /**< Extraction parameters */
69070 + t_KeysParams keysParams; /**< Keys definition matching the selected extraction */
69071 +} t_FmPcdCcNodeParams;
69072 +
69073 +/**************************************************************************//**
69074 + @Description Parameters for defining a hash table
69075 +*//***************************************************************************/
69076 +typedef struct t_FmPcdHashTableParams {
69077 + uint16_t maxNumOfKeys; /**< Maximum Number Of Keys that will (ever) be used in this Hash-table */
69078 + e_FmPcdCcStatsMode statisticsMode; /**< If not e_FM_PCD_CC_STATS_MODE_NONE, the required structures for the
69079 + requested statistics mode will be allocated according to maxNumOfKeys. */
69080 + uint8_t kgHashShift; /**< KG-Hash-shift as it was configured in the KG-scheme
69081 + that leads to this hash-table. */
69082 + uint16_t hashResMask; /**< Mask that will be used on the hash-result;
69083 + The number-of-sets for this hash will be calculated
69084 + as (2^(number of bits set in 'hashResMask'));
69085 + The 4 lower bits must be cleared. */
69086 + uint8_t hashShift; /**< Byte offset from the beginning of the KeyGen hash result to the
69087 + 2-bytes to be used as hash index. */
69088 + uint8_t matchKeySize; /**< Size of the exact match keys held by the hash buckets */
69089 +
69090 + t_FmPcdCcNextEngineParams ccNextEngineParamsForMiss; /**< Parameters for defining the next engine when a key is not matched */
69091 +
69092 +} t_FmPcdHashTableParams;
69093 +
69094 +/**************************************************************************//**
69095 + @Description Parameters for defining a CC tree group.
69096 +
69097 + This structure defines a CC group in terms of NetEnv units
69098 + and the action to be taken in each case. The unitIds list must
69099 + be given in order from low to high indices.
69100 +
69101 + t_FmPcdCcNextEngineParams is a list of 2^numOfDistinctionUnits
69102 + structures where each defines the next action to be taken for
69103 + each units combination. for example:
69104 + numOfDistinctionUnits = 2
69105 + unitIds = {1,3}
69106 + p_NextEnginePerEntriesInGrp[0] = t_FmPcdCcNextEngineParams for the case that
69107 + unit 1 - not found; unit 3 - not found;
69108 + p_NextEnginePerEntriesInGrp[1] = t_FmPcdCcNextEngineParams for the case that
69109 + unit 1 - not found; unit 3 - found;
69110 + p_NextEnginePerEntriesInGrp[2] = t_FmPcdCcNextEngineParams for the case that
69111 + unit 1 - found; unit 3 - not found;
69112 + p_NextEnginePerEntriesInGrp[3] = t_FmPcdCcNextEngineParams for the case that
69113 + unit 1 - found; unit 3 - found;
69114 +*//***************************************************************************/
69115 +typedef struct t_FmPcdCcGrpParams {
69116 + uint8_t numOfDistinctionUnits; /**< Up to 4 */
69117 + uint8_t unitIds[FM_PCD_MAX_NUM_OF_CC_UNITS];
69118 + /**< Indices of the units as defined in
69119 + FM_PCD_NetEnvCharacteristicsSet() */
69120 + t_FmPcdCcNextEngineParams nextEnginePerEntriesInGrp[FM_PCD_MAX_NUM_OF_CC_ENTRIES_IN_GRP];
69121 + /**< Maximum entries per group is 16 */
69122 +} t_FmPcdCcGrpParams;
69123 +
69124 +/**************************************************************************//**
69125 + @Description Parameters for defining CC tree groups
69126 +*//***************************************************************************/
69127 +typedef struct t_FmPcdCcTreeParams {
69128 + t_Handle h_NetEnv; /**< A handle to the Network environment as returned
69129 + by FM_PCD_NetEnvCharacteristicsSet() */
69130 + uint8_t numOfGrps; /**< Number of CC groups within the CC tree */
69131 + t_FmPcdCcGrpParams ccGrpParams[FM_PCD_MAX_NUM_OF_CC_GROUPS];
69132 + /**< Parameters for each group. */
69133 +} t_FmPcdCcTreeParams;
69134 +
69135 +
69136 +/**************************************************************************//**
69137 + @Description CC key statistics structure
69138 +*//***************************************************************************/
69139 +typedef struct t_FmPcdCcKeyStatistics {
69140 + uint32_t byteCount; /**< This counter reflects byte count of frames that
69141 + were matched by this key. */
69142 + uint32_t frameCount; /**< This counter reflects count of frames that
69143 + were matched by this key. */
69144 +#if (DPAA_VERSION >= 11)
69145 + uint32_t frameLengthRangeCount[FM_PCD_CC_STATS_MAX_NUM_OF_FLR];
69146 + /**< These counters reflect how many frames matched
69147 + this key in 'RMON' statistics mode:
69148 + Each counter holds the number of frames of a
69149 + specific frames length range, according to the
69150 + ranges provided at initialization. */
69151 +#endif /* (DPAA_VERSION >= 11) */
69152 +} t_FmPcdCcKeyStatistics;
69153 +
69154 +/**************************************************************************//**
69155 + @Description Parameters for defining policer byte rate
69156 +*//***************************************************************************/
69157 +typedef struct t_FmPcdPlcrByteRateModeParams {
69158 + e_FmPcdPlcrFrameLengthSelect frameLengthSelection; /**< Frame length selection */
69159 + e_FmPcdPlcrRollBackFrameSelect rollBackFrameSelection; /**< relevant option only e_FM_PCD_PLCR_L2_FRM_LEN,
69160 + e_FM_PCD_PLCR_FULL_FRM_LEN */
69161 +} t_FmPcdPlcrByteRateModeParams;
69162 +
69163 +/**************************************************************************//**
69164 + @Description Parameters for defining the policer profile (based on
69165 + RFC-2698 or RFC-4115 attributes).
69166 +*//***************************************************************************/
69167 +typedef struct t_FmPcdPlcrNonPassthroughAlgParams {
69168 + e_FmPcdPlcrRateMode rateMode; /**< Byte mode or Packet mode */
69169 + t_FmPcdPlcrByteRateModeParams byteModeParams; /**< Valid for Byte NULL for Packet */
69170 + uint32_t committedInfoRate; /**< KBits/Second or Packets/Second */
69171 + uint32_t committedBurstSize; /**< Bytes/Packets */
69172 + uint32_t peakOrExcessInfoRate; /**< KBits/Second or Packets/Second */
69173 + uint32_t peakOrExcessBurstSize; /**< Bytes/Packets */
69174 +} t_FmPcdPlcrNonPassthroughAlgParams;
69175 +
69176 +/**************************************************************************//**
69177 + @Description Parameters for defining the next engine after policer
69178 +*//***************************************************************************/
69179 +typedef union u_FmPcdPlcrNextEngineParams {
69180 + e_FmPcdDoneAction action; /**< Action - when next engine is BMI (done) */
69181 + t_Handle h_Profile; /**< Policer profile handle - used when next engine
69182 + is Policer, must be a SHARED profile */
69183 + t_Handle h_DirectScheme; /**< Direct scheme select - when next engine is KeyGen */
69184 +} u_FmPcdPlcrNextEngineParams;
69185 +
69186 +/**************************************************************************//**
69187 + @Description Parameters for defining the policer profile entry
69188 +*//***************************************************************************/
69189 +typedef struct t_FmPcdPlcrProfileParams {
69190 + bool modify; /**< TRUE to change an existing profile */
69191 + union {
69192 + struct {
69193 + e_FmPcdProfileTypeSelection profileType; /**< Type of policer profile */
69194 + t_Handle h_FmPort; /**< Relevant for per-port profiles only */
69195 + uint16_t relativeProfileId; /**< Profile id - relative to shared group or to port */
69196 + } newParams; /**< use it when modify = FALSE */
69197 + t_Handle h_Profile; /**< A handle to a profile - use it when modify=TRUE */
69198 + } id;
69199 + e_FmPcdPlcrAlgorithmSelection algSelection; /**< Profile Algorithm PASS_THROUGH, RFC_2698, RFC_4115 */
69200 + e_FmPcdPlcrColorMode colorMode; /**< COLOR_BLIND, COLOR_AWARE */
69201 +
69202 + union {
69203 + e_FmPcdPlcrColor dfltColor; /**< For Color-Blind Pass-Through mode; the policer will re-color
69204 + any incoming packet with the default value. */
69205 + e_FmPcdPlcrColor override; /**< For Color-Aware modes; the profile response to a
69206 + pre-color value of 2'b11. */
69207 + } color;
69208 +
69209 + t_FmPcdPlcrNonPassthroughAlgParams nonPassthroughAlgParams; /**< RFC2698 or RFC4115 parameters */
69210 +
69211 + e_FmPcdEngine nextEngineOnGreen; /**< Next engine for green-colored frames */
69212 + u_FmPcdPlcrNextEngineParams paramsOnGreen; /**< Next engine parameters for green-colored frames */
69213 +
69214 + e_FmPcdEngine nextEngineOnYellow; /**< Next engine for yellow-colored frames */
69215 + u_FmPcdPlcrNextEngineParams paramsOnYellow; /**< Next engine parameters for yellow-colored frames */
69216 +
69217 + e_FmPcdEngine nextEngineOnRed; /**< Next engine for red-colored frames */
69218 + u_FmPcdPlcrNextEngineParams paramsOnRed; /**< Next engine parameters for red-colored frames */
69219 +
69220 + bool trapProfileOnFlowA; /**< Obsolete - do not use */
69221 + bool trapProfileOnFlowB; /**< Obsolete - do not use */
69222 + bool trapProfileOnFlowC; /**< Obsolete - do not use */
69223 +} t_FmPcdPlcrProfileParams;
69224 +
69225 +/**************************************************************************//**
69226 + @Description Parameters for selecting a location for requested manipulation
69227 +*//***************************************************************************/
69228 +typedef struct t_FmManipHdrInfo {
69229 + e_NetHeaderType hdr; /**< Header selection */
69230 + e_FmPcdHdrIndex hdrIndex; /**< Relevant only for MPLS, VLAN and tunneled IP. Otherwise should be cleared. */
69231 + bool byField; /**< TRUE if the location of manipulation is according to some field in the specific header*/
69232 + t_FmPcdFields fullField; /**< Relevant only when byField = TRUE: Extract field */
69233 +} t_FmManipHdrInfo;
69234 +
69235 +#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
69236 +/**************************************************************************//**
69237 + @Description Parameters for defining an insertion manipulation
69238 + of type e_FM_PCD_MANIP_INSRT_TO_START_OF_FRAME_TEMPLATE
69239 +*//***************************************************************************/
69240 +typedef struct t_FmPcdManipHdrInsrtByTemplateParams {
69241 + uint8_t size; /**< Size of insert template to the start of the frame. */
69242 + uint8_t hdrTemplate[FM_PCD_MAX_MANIP_INSRT_TEMPLATE_SIZE];
69243 + /**< Array of the insertion template. */
69244 +
69245 + bool modifyOuterIp; /**< TRUE if user want to modify some fields in outer IP. */
69246 + struct {
69247 + uint16_t ipOuterOffset; /**< Offset of outer IP in the insert template, relevant if modifyOuterIp = TRUE.*/
69248 + uint16_t dscpEcn; /**< value of dscpEcn in IP outer, relevant if modifyOuterIp = TRUE.
69249 + in IPV4 dscpEcn only byte - it has to be adjusted to the right*/
69250 + bool udpPresent; /**< TRUE if UDP is present in the insert template, relevant if modifyOuterIp = TRUE.*/
69251 + uint8_t udpOffset; /**< Offset in the insert template of UDP, relevant if modifyOuterIp = TRUE and udpPresent=TRUE.*/
69252 + uint8_t ipIdentGenId; /**< Used by FMan-CTRL to calculate IP-identification field,relevant if modifyOuterIp = TRUE.*/
69253 + bool recalculateLength; /**< TRUE if recalculate length has to be performed due to the engines in the path which can change the frame later, relevant if modifyOuterIp = TRUE.*/
69254 + struct {
69255 + uint8_t blockSize; /**< The CAAM block-size; Used by FMan-CTRL to calculate the IP Total Length field.*/
69256 + uint8_t extraBytesAddedAlignedToBlockSize; /**< Used by FMan-CTRL to calculate the IP Total Length field and UDP length*/
69257 + uint8_t extraBytesAddedNotAlignedToBlockSize;/**< Used by FMan-CTRL to calculate the IP Total Length field and UDP length.*/
69258 + } recalculateLengthParams; /**< Recalculate length parameters - relevant if modifyOuterIp = TRUE and recalculateLength = TRUE */
69259 + } modifyOuterIpParams; /**< Outer IP modification parameters - ignored if modifyOuterIp is FALSE */
69260 +
69261 + bool modifyOuterVlan; /**< TRUE if user wants to modify VPri field in the outer VLAN header*/
69262 + struct {
69263 + uint8_t vpri; /**< Value of VPri, relevant if modifyOuterVlan = TRUE
69264 + VPri only 3 bits, it has to be adjusted to the right*/
69265 + } modifyOuterVlanParams;
69266 +} t_FmPcdManipHdrInsrtByTemplateParams;
69267 +
69268 +/**************************************************************************//**
69269 + @Description Parameters for defining CAPWAP fragmentation
69270 +*//***************************************************************************/
69271 +typedef struct t_CapwapFragmentationParams {
69272 + uint16_t sizeForFragmentation; /**< if length of the frame is greater than this value, CAPWAP fragmentation will be executed.*/
69273 + bool headerOptionsCompr; /**< TRUE - first fragment include the CAPWAP header options field,
69274 + and all other fragments exclude the CAPWAP options field,
69275 + FALSE - all fragments include CAPWAP header options field. */
69276 +} t_CapwapFragmentationParams;
69277 +
69278 +/**************************************************************************//**
69279 + @Description Parameters for defining CAPWAP reassembly
69280 +*//***************************************************************************/
69281 +typedef struct t_CapwapReassemblyParams {
69282 + uint16_t maxNumFramesInProcess; /**< Number of frames which can be reassembled concurrently; must be power of 2.
69283 + In case numOfFramesPerHashEntry == e_FM_PCD_MANIP_FOUR_WAYS_HASH,
69284 + maxNumFramesInProcess has to be in the range of 4 - 512,
69285 + In case numOfFramesPerHashEntry == e_FM_PCD_MANIP_EIGHT_WAYS_HASH,
69286 + maxNumFramesInProcess has to be in the range of 8 - 2048 */
69287 + bool haltOnDuplicationFrag; /**< If TRUE, reassembly process will be halted due to duplicated fragment,
69288 + and all processed fragments will be enqueued with error indication;
69289 + If FALSE, only duplicated fragments will be enqueued with error indication. */
69290 +
69291 + e_FmPcdManipReassemTimeOutMode timeOutMode; /**< Expiration delay initialized by the reassembly process */
69292 + uint32_t fqidForTimeOutFrames; /**< FQID in which time out frames will enqueue during Time Out Process */
69293 + uint32_t timeoutRoutineRequestTime;
69294 + /**< Represents the time interval in microseconds between consecutive
69295 + timeout routine requests It has to be power of 2. */
69296 + uint32_t timeoutThresholdForReassmProcess;
69297 + /**< Time interval (microseconds) for marking frames in process as too old;
69298 + Frames in process are those for which at least one fragment was received
69299 + but not all fragments. */
69300 +
69301 + e_FmPcdManipReassemWaysNumber numOfFramesPerHashEntry;/**< Number of frames per hash entry (needed for the reassembly process) */
69302 +} t_CapwapReassemblyParams;
69303 +
69304 +/**************************************************************************//**
69305 + @Description Parameters for defining fragmentation/reassembly manipulation
69306 +*//***************************************************************************/
69307 +typedef struct t_FmPcdManipFragOrReasmParams {
69308 + bool frag; /**< TRUE if using the structure for fragmentation,
69309 + otherwise this structure is used for reassembly */
69310 + uint8_t sgBpid; /**< Scatter/Gather buffer pool id;
69311 + Same LIODN number is used for these buffers as for
69312 + the received frames buffers, so buffers of this pool
69313 + need to be allocated in the same memory area as the
69314 + received buffers. If the received buffers arrive
69315 + from different sources, the Scatter/Gather BP id
69316 + should be mutual to all these sources. */
69317 + e_NetHeaderType hdr; /**< Header selection */
69318 + union {
69319 + t_CapwapFragmentationParams capwapFragParams; /**< Structure for CAPWAP fragmentation,
69320 + relevant if 'frag' = TRUE, 'hdr' = HEADER_TYPE_CAPWAP */
69321 + t_CapwapReassemblyParams capwapReasmParams; /**< Structure for CAPWAP reassembly,
69322 + relevant if 'frag' = FALSE, 'hdr' = HEADER_TYPE_CAPWAP */
69323 + } u;
69324 +} t_FmPcdManipFragOrReasmParams;
69325 +#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
69326 +
69327 +
69328 +/**************************************************************************//**
69329 + @Description Parameters for defining header removal by header type
69330 +*//***************************************************************************/
69331 +typedef struct t_FmPcdManipHdrRmvByHdrParams {
69332 + e_FmPcdManipHdrRmvByHdrType type; /**< Selection of header removal location */
69333 + union {
69334 +#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
69335 + struct {
69336 + bool include; /**< If FALSE, remove until the specified header (not including the header);
69337 + If TRUE, remove also the specified header. */
69338 + t_FmManipHdrInfo hdrInfo;
69339 + } fromStartByHdr; /**< Relevant when type = e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START */
69340 +#endif /* (DPAA_VERSION >= 11) || ... */
69341 +#if (DPAA_VERSION >= 11)
69342 + t_FmManipHdrInfo hdrInfo; /**< Relevant when type = e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START */
69343 +#endif /* (DPAA_VERSION >= 11) */
69344 + e_FmPcdManipHdrRmvSpecificL2 specificL2; /**< Relevant when type = e_FM_PCD_MANIP_BY_HDR_SPECIFIC_L2;
69345 + Defines which L2 headers to remove. */
69346 + } u;
69347 +} t_FmPcdManipHdrRmvByHdrParams;
69348 +
69349 +/**************************************************************************//**
69350 + @Description Parameters for configuring IP fragmentation manipulation
69351 +
69352 + Restrictions:
69353 + - IP Fragmentation output fragments must not be forwarded to application directly.
69354 + - Maximum number of fragments per frame is 16.
69355 + - Fragmentation of IP fragments is not supported.
69356 + - IPv4 packets containing header Option fields are fragmented by copying all option
69357 + fields to each fragment, regardless of the copy bit value.
69358 + - Transmit confirmation is not supported.
69359 + - Fragmentation after SEC can't handle S/G frames.
69360 + - Fragmentation nodes must be set as the last PCD action (i.e. the
69361 + corresponding CC node key must have next engine set to e_FM_PCD_DONE).
69362 + - Only BMan buffers shall be used for frames to be fragmented.
69363 + - IPF does not support VSP. Therefore, on the same port where we have IPF
69364 + we cannot support VSP.
69365 + - NOTE: The following comment is relevant only for FMAN v3 devices: IPF
69366 + does not support VSP. Therefore, on the same port where we have IPF we
69367 + cannot support VSP.
69368 +*//***************************************************************************/
69369 +typedef struct t_FmPcdManipFragIpParams {
69370 + uint16_t sizeForFragmentation; /**< If length of the frame is greater than this value,
69371 + IP fragmentation will be executed.*/
69372 +#if (DPAA_VERSION == 10)
69373 + uint8_t scratchBpid; /**< Absolute buffer pool id according to BM configuration.*/
69374 +#endif /* (DPAA_VERSION == 10) */
69375 + bool sgBpidEn; /**< Enable a dedicated buffer pool id for the Scatter/Gather buffer allocation;
69376 + If disabled, the Scatter/Gather buffer will be allocated from the same pool as the
69377 + received frame's buffer. */
69378 + uint8_t sgBpid; /**< Scatter/Gather buffer pool id;
69379 + This parameters is relevant when 'sgBpidEn=TRUE';
69380 + Same LIODN number is used for these buffers as for the received frames buffers, so buffers
69381 + of this pool need to be allocated in the same memory area as the received buffers.
69382 + If the received buffers arrive from different sources, the Scatter/Gather BP id should be
69383 + mutual to all these sources. */
69384 + e_FmPcdManipDontFragAction dontFragAction; /**< Don't Fragment Action - If an IP packet is larger
69385 + than MTU and its DF bit is set, then this field will
69386 + determine the action to be taken.*/
69387 +} t_FmPcdManipFragIpParams;
69388 +
69389 +/**************************************************************************//**
69390 + @Description Parameters for configuring IP reassembly manipulation.
69391 +
69392 + This is a common structure for both IPv4 and IPv6 reassembly
69393 + manipulation. For reassembly of both IPv4 and IPv6, make sure to
69394 + set the 'hdr' field in t_FmPcdManipReassemParams to HEADER_TYPE_IPv6.
69395 +
69396 + Restrictions:
69397 + - Application must define at least one scheme to catch the reassembled frames.
69398 + - Maximum number of fragments per frame is 16.
69399 + - Reassembly of IPv4 fragments containing Option fields is supported.
69400 +
69401 +*//***************************************************************************/
69402 +typedef struct t_FmPcdManipReassemIpParams {
69403 + uint8_t relativeSchemeId[2]; /**< Partition relative scheme id:
69404 + relativeSchemeId[0] - Relative scheme ID for IPV4 Reassembly manipulation;
69405 + relativeSchemeId[1] - Relative scheme ID for IPV6 Reassembly manipulation;
69406 + NOTE: The following comment is relevant only for FMAN v2 devices:
69407 + Relative scheme ID for IPv4/IPv6 Reassembly manipulation must be smaller than
69408 + the user schemes id to ensure that the reassembly schemes will be first match;
69409 + Rest schemes, if defined, should have higher relative scheme ID. */
69410 +#if (DPAA_VERSION >= 11)
69411 + uint32_t nonConsistentSpFqid; /**< In case that other fragments of the frame corresponds to different storage
69412 + profile than the opening fragment (Non-Consistent-SP state)
69413 + then one of two possible scenarios occurs:
69414 + if 'nonConsistentSpFqid != 0', the reassembled frame will be enqueued to
69415 + this fqid, otherwise a 'Non Consistent SP' bit will be set in the FD[status].*/
69416 +#else
69417 + uint8_t sgBpid; /**< Buffer pool id for the S/G frame created by the reassembly process */
69418 +#endif /* (DPAA_VERSION >= 11) */
69419 + uint8_t dataMemId; /**< Memory partition ID for the IPR's external tables structure */
69420 + uint16_t dataLiodnOffset; /**< LIODN offset for access the IPR's external tables structure. */
69421 + uint16_t minFragSize[2]; /**< Minimum fragment size:
69422 + minFragSize[0] - for ipv4, minFragSize[1] - for ipv6 */
69423 + e_FmPcdManipReassemWaysNumber numOfFramesPerHashEntry[2];
69424 + /**< Number of frames per hash entry needed for reassembly process:
69425 + numOfFramesPerHashEntry[0] - for ipv4 (max value is e_FM_PCD_MANIP_EIGHT_WAYS_HASH);
69426 + numOfFramesPerHashEntry[1] - for ipv6 (max value is e_FM_PCD_MANIP_SIX_WAYS_HASH). */
69427 + uint16_t maxNumFramesInProcess; /**< Number of frames which can be processed by Reassembly in the same time;
69428 + Must be power of 2;
69429 + In the case numOfFramesPerHashEntry == e_FM_PCD_MANIP_FOUR_WAYS_HASH,
69430 + maxNumFramesInProcess has to be in the range of 4 - 512;
69431 + In the case numOfFramesPerHashEntry == e_FM_PCD_MANIP_EIGHT_WAYS_HASH,
69432 + maxNumFramesInProcess has to be in the range of 8 - 2048. */
69433 + e_FmPcdManipReassemTimeOutMode timeOutMode; /**< Expiration delay initialized by Reassembly process */
69434 + uint32_t fqidForTimeOutFrames; /**< FQID in which time out frames will enqueue during Time Out Process;
69435 + Recommended value for this field is 0; in this way timed-out frames will be discarded */
69436 + uint32_t timeoutThresholdForReassmProcess;
69437 + /**< Represents the time interval in microseconds which defines
69438 + if opened frame (at least one fragment was processed but not all the fragments)is found as too old*/
69439 +} t_FmPcdManipReassemIpParams;
69440 +
69441 +/**************************************************************************//**
69442 + @Description structure for defining IPSEC manipulation
69443 +*//***************************************************************************/
69444 +typedef struct t_FmPcdManipSpecialOffloadIPSecParams {
69445 + bool decryption; /**< TRUE if being used in decryption direction;
69446 + FALSE if being used in encryption direction. */
69447 + bool ecnCopy; /**< TRUE to copy the ECN bits from inner/outer to outer/inner
69448 + (direction depends on the 'decryption' field). */
69449 + bool dscpCopy; /**< TRUE to copy the DSCP bits from inner/outer to outer/inner
69450 + (direction depends on the 'decryption' field). */
69451 + bool variableIpHdrLen; /**< TRUE for supporting variable IP header length in decryption. */
69452 + bool variableIpVersion; /**< TRUE for supporting both IP version on the same SA in encryption */
69453 + uint8_t outerIPHdrLen; /**< if 'variableIpVersion == TRUE' then this field must be set to non-zero value;
69454 + It is specifies the length of the outer IP header that was configured in the
69455 + corresponding SA. */
69456 + uint16_t arwSize; /**< if <> '0' then will perform ARW check for this SA;
69457 + The value must be a multiplication of 16 */
69458 + uintptr_t arwAddr; /**< if arwSize <> '0' then this field must be set to non-zero value;
69459 + MUST be allocated from FMAN's MURAM that the post-sec op-port belongs to;
69460 + Must be 4B aligned. Required MURAM size is 'NEXT_POWER_OF_2(arwSize+32))/8+4' Bytes */
69461 +} t_FmPcdManipSpecialOffloadIPSecParams;
69462 +
69463 +#if (DPAA_VERSION >= 11)
69464 +/**************************************************************************//**
69465 + @Description Parameters for configuring CAPWAP fragmentation manipulation
69466 +
69467 + Restrictions:
69468 + - Maximum number of fragments per frame is 16.
69469 + - Transmit confirmation is not supported.
69470 + - Fragmentation nodes must be set as the last PCD action (i.e. the
69471 + corresponding CC node key must have next engine set to e_FM_PCD_DONE).
69472 + - Only BMan buffers shall be used for frames to be fragmented.
69473 + - NOTE: The following comment is relevant only for FMAN v3 devices: IPF
69474 + does not support VSP. Therefore, on the same port where we have IPF we
69475 + cannot support VSP.
69476 +*//***************************************************************************/
69477 +typedef struct t_FmPcdManipFragCapwapParams {
69478 + uint16_t sizeForFragmentation; /**< If length of the frame is greater than this value,
69479 + CAPWAP fragmentation will be executed.*/
69480 + bool sgBpidEn; /**< Enable a dedicated buffer pool id for the Scatter/Gather buffer allocation;
69481 + If disabled, the Scatter/Gather buffer will be allocated from the same pool as the
69482 + received frame's buffer. */
69483 + uint8_t sgBpid; /**< Scatter/Gather buffer pool id;
69484 + This parameters is relevant when 'sgBpidEn=TRUE';
69485 + Same LIODN number is used for these buffers as for the received frames buffers, so buffers
69486 + of this pool need to be allocated in the same memory area as the received buffers.
69487 + If the received buffers arrive from different sources, the Scatter/Gather BP id should be
69488 + mutual to all these sources. */
69489 + bool compressModeEn; /**< CAPWAP Header Options Compress Enable mode;
69490 + When this mode is enabled then only the first fragment include the CAPWAP header options
69491 + field (if user provides it in the input frame) and all other fragments exclude the CAPWAP
69492 + options field (CAPWAP header is updated accordingly).*/
69493 +} t_FmPcdManipFragCapwapParams;
69494 +
69495 +/**************************************************************************//**
69496 + @Description Parameters for configuring CAPWAP reassembly manipulation.
69497 +
69498 + Restrictions:
69499 + - Application must define one scheme to catch the reassembled frames.
69500 + - Maximum number of fragments per frame is 16.
69501 +
69502 +*//***************************************************************************/
69503 +typedef struct t_FmPcdManipReassemCapwapParams {
69504 + uint8_t relativeSchemeId; /**< Partition relative scheme id;
69505 + NOTE: this id must be smaller than the user schemes id to ensure that the reassembly scheme will be first match;
69506 + Rest schemes, if defined, should have higher relative scheme ID. */
69507 + uint8_t dataMemId; /**< Memory partition ID for the IPR's external tables structure */
69508 + uint16_t dataLiodnOffset; /**< LIODN offset for access the IPR's external tables structure. */
69509 + uint16_t maxReassembledFrameLength;/**< The maximum CAPWAP reassembled frame length in bytes;
69510 + If maxReassembledFrameLength == 0, any successful reassembled frame length is
69511 + considered as a valid length;
69512 + if maxReassembledFrameLength > 0, a successful reassembled frame which its length
69513 + exceeds this value is considered as an error frame (FD status[CRE] bit is set). */
69514 + e_FmPcdManipReassemWaysNumber numOfFramesPerHashEntry;
69515 + /**< Number of frames per hash entry needed for reassembly process */
69516 + uint16_t maxNumFramesInProcess; /**< Number of frames which can be processed by reassembly in the same time;
69517 + Must be power of 2;
69518 + In the case numOfFramesPerHashEntry == e_FM_PCD_MANIP_FOUR_WAYS_HASH,
69519 + maxNumFramesInProcess has to be in the range of 4 - 512;
69520 + In the case numOfFramesPerHashEntry == e_FM_PCD_MANIP_EIGHT_WAYS_HASH,
69521 + maxNumFramesInProcess has to be in the range of 8 - 2048. */
69522 + e_FmPcdManipReassemTimeOutMode timeOutMode; /**< Expiration delay initialized by Reassembly process */
69523 + uint32_t fqidForTimeOutFrames; /**< FQID in which time out frames will enqueue during Time Out Process;
69524 + Recommended value for this field is 0; in this way timed-out frames will be discarded */
69525 + uint32_t timeoutThresholdForReassmProcess;
69526 + /**< Represents the time interval in microseconds which defines
69527 + if opened frame (at least one fragment was processed but not all the fragments)is found as too old*/
69528 +} t_FmPcdManipReassemCapwapParams;
69529 +
69530 +/**************************************************************************//**
69531 + @Description structure for defining CAPWAP manipulation
69532 +*//***************************************************************************/
69533 +typedef struct t_FmPcdManipSpecialOffloadCapwapParams {
69534 + bool dtls; /**< TRUE if continue to SEC DTLS encryption */
69535 + e_FmPcdManipHdrQosSrc qosSrc; /**< TODO */
69536 +} t_FmPcdManipSpecialOffloadCapwapParams;
69537 +
69538 +#endif /* (DPAA_VERSION >= 11) */
69539 +
69540 +
69541 +/**************************************************************************//**
69542 + @Description Parameters for defining special offload manipulation
69543 +*//***************************************************************************/
69544 +typedef struct t_FmPcdManipSpecialOffloadParams {
69545 + e_FmPcdManipSpecialOffloadType type; /**< Type of special offload manipulation */
69546 + union
69547 + {
69548 + t_FmPcdManipSpecialOffloadIPSecParams ipsec; /**< Parameters for IPSec; Relevant when
69549 + type = e_FM_PCD_MANIP_SPECIAL_OFFLOAD_IPSEC */
69550 +#if (DPAA_VERSION >= 11)
69551 + t_FmPcdManipSpecialOffloadCapwapParams capwap; /**< Parameters for CAPWAP; Relevant when
69552 + type = e_FM_PCD_MANIP_SPECIAL_OFFLOAD_CAPWAP */
69553 +#endif /* (DPAA_VERSION >= 11) */
69554 + } u;
69555 +} t_FmPcdManipSpecialOffloadParams;
69556 +
69557 +/**************************************************************************//**
69558 + @Description Parameters for defining insertion manipulation
69559 +*//***************************************************************************/
69560 +typedef struct t_FmPcdManipHdrInsrt {
69561 + uint8_t size; /**< size of inserted section */
69562 + uint8_t *p_Data; /**< data to be inserted */
69563 +} t_FmPcdManipHdrInsrt;
69564 +
69565 +
69566 +/**************************************************************************//**
69567 + @Description Parameters for defining generic removal manipulation
69568 +*//***************************************************************************/
69569 +typedef struct t_FmPcdManipHdrRmvGenericParams {
69570 + uint8_t offset; /**< Offset from beginning of header to the start
69571 + location of the removal */
69572 + uint8_t size; /**< Size of removed section */
69573 +} t_FmPcdManipHdrRmvGenericParams;
69574 +
69575 +/**************************************************************************//**
69576 + @Description Parameters for defining generic insertion manipulation
69577 +*//***************************************************************************/
69578 +typedef struct t_FmPcdManipHdrInsrtGenericParams {
69579 + uint8_t offset; /**< Offset from beginning of header to the start
69580 + location of the insertion */
69581 + uint8_t size; /**< Size of inserted section */
69582 + bool replace; /**< TRUE to override (replace) existing data at
69583 + 'offset', FALSE to insert */
69584 + uint8_t *p_Data; /**< Pointer to data to be inserted */
69585 +} t_FmPcdManipHdrInsrtGenericParams;
69586 +
69587 +/**************************************************************************//**
69588 + @Description Parameters for defining header manipulation VLAN DSCP To Vpri translation
69589 +*//***************************************************************************/
69590 +typedef struct t_FmPcdManipHdrFieldUpdateVlanDscpToVpri {
69591 + uint8_t dscpToVpriTable[FM_PCD_MANIP_DSCP_TO_VLAN_TRANS];
69592 + /**< A table of VPri values for each DSCP value;
69593 + The index is the DSCP value (0-0x3F) and the
69594 + value is the corresponding VPRI (0-15). */
69595 + uint8_t vpriDefVal; /**< 0-7, Relevant only if if updateType =
69596 + e_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN,
69597 + this field is the Q Tag default value if the
69598 + IP header is not found. */
69599 +} t_FmPcdManipHdrFieldUpdateVlanDscpToVpri;
69600 +
69601 +/**************************************************************************//**
69602 + @Description Parameters for defining header manipulation VLAN fields updates
69603 +*//***************************************************************************/
69604 +typedef struct t_FmPcdManipHdrFieldUpdateVlan {
69605 + e_FmPcdManipHdrFieldUpdateVlan updateType; /**< Selects VLAN update type */
69606 + union {
69607 + uint8_t vpri; /**< 0-7, Relevant only if If updateType =
69608 + e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN_PRI, this
69609 + is the new VLAN pri. */
69610 + t_FmPcdManipHdrFieldUpdateVlanDscpToVpri dscpToVpri; /**< Parameters structure, Relevant only if updateType
69611 + = e_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN. */
69612 + } u;
69613 +} t_FmPcdManipHdrFieldUpdateVlan;
69614 +
69615 +/**************************************************************************//**
69616 + @Description Parameters for defining header manipulation IPV4 fields updates
69617 +*//***************************************************************************/
69618 +typedef struct t_FmPcdManipHdrFieldUpdateIpv4 {
69619 + ipv4HdrManipUpdateFlags_t validUpdates; /**< ORed flag, selecting the required updates */
69620 + uint8_t tos; /**< 8 bit New TOS; Relevant if validUpdates contains
69621 + HDR_MANIP_IPV4_TOS */
69622 + uint16_t id; /**< 16 bit New IP ID; Relevant only if validUpdates
69623 + contains HDR_MANIP_IPV4_ID */
69624 + uint32_t src; /**< 32 bit New IP SRC; Relevant only if validUpdates
69625 + contains HDR_MANIP_IPV4_SRC */
69626 + uint32_t dst; /**< 32 bit New IP DST; Relevant only if validUpdates
69627 + contains HDR_MANIP_IPV4_DST */
69628 +} t_FmPcdManipHdrFieldUpdateIpv4;
69629 +
69630 +/**************************************************************************//**
69631 + @Description Parameters for defining header manipulation IPV6 fields updates
69632 +*//***************************************************************************/
69633 +typedef struct t_FmPcdManipHdrFieldUpdateIpv6 {
69634 + ipv6HdrManipUpdateFlags_t validUpdates; /**< ORed flag, selecting the required updates */
69635 + uint8_t trafficClass; /**< 8 bit New Traffic Class; Relevant if validUpdates contains
69636 + HDR_MANIP_IPV6_TC */
69637 + uint8_t src[NET_HEADER_FIELD_IPv6_ADDR_SIZE];
69638 + /**< 16 byte new IP SRC; Relevant only if validUpdates
69639 + contains HDR_MANIP_IPV6_SRC */
69640 + uint8_t dst[NET_HEADER_FIELD_IPv6_ADDR_SIZE];
69641 + /**< 16 byte new IP DST; Relevant only if validUpdates
69642 + contains HDR_MANIP_IPV6_DST */
69643 +} t_FmPcdManipHdrFieldUpdateIpv6;
69644 +
69645 +/**************************************************************************//**
69646 + @Description Parameters for defining header manipulation TCP/UDP fields updates
69647 +*//***************************************************************************/
69648 +typedef struct t_FmPcdManipHdrFieldUpdateTcpUdp {
69649 + tcpUdpHdrManipUpdateFlags_t validUpdates; /**< ORed flag, selecting the required updates */
69650 + uint16_t src; /**< 16 bit New TCP/UDP SRC; Relevant only if validUpdates
69651 + contains HDR_MANIP_TCP_UDP_SRC */
69652 + uint16_t dst; /**< 16 bit New TCP/UDP DST; Relevant only if validUpdates
69653 + contains HDR_MANIP_TCP_UDP_DST */
69654 +} t_FmPcdManipHdrFieldUpdateTcpUdp;
69655 +
69656 +/**************************************************************************//**
69657 + @Description Parameters for defining header manipulation fields updates
69658 +*//***************************************************************************/
69659 +typedef struct t_FmPcdManipHdrFieldUpdateParams {
69660 + e_FmPcdManipHdrFieldUpdateType type; /**< Type of header field update manipulation */
69661 + union {
69662 + t_FmPcdManipHdrFieldUpdateVlan vlan; /**< Parameters for VLAN update. Relevant when
69663 + type = e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN */
69664 + t_FmPcdManipHdrFieldUpdateIpv4 ipv4; /**< Parameters for IPv4 update. Relevant when
69665 + type = e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV4 */
69666 + t_FmPcdManipHdrFieldUpdateIpv6 ipv6; /**< Parameters for IPv6 update. Relevant when
69667 + type = e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV6 */
69668 + t_FmPcdManipHdrFieldUpdateTcpUdp tcpUdp; /**< Parameters for TCP/UDP update. Relevant when
69669 + type = e_FM_PCD_MANIP_HDR_FIELD_UPDATE_TCP_UDP */
69670 + } u;
69671 +} t_FmPcdManipHdrFieldUpdateParams;
69672 +
69673 +
69674 +
69675 +/**************************************************************************//**
69676 + @Description Parameters for defining custom header manipulation for generic field replacement
69677 +*//***************************************************************************/
69678 +typedef struct t_FmPcdManipHdrCustomGenFieldReplace {
69679 + uint8_t srcOffset; /**< Location of new data - Offset from
69680 + Parse Result (>= 16, srcOffset+size <= 32, ) */
69681 + uint8_t dstOffset; /**< Location of data to be overwritten - Offset from
69682 + start of frame (dstOffset + size <= 256). */
69683 + uint8_t size; /**< The number of bytes (<=16) to be replaced */
69684 + uint8_t mask; /**< Optional 1 byte mask. Set to select bits for
69685 + replacement (1 - bit will be replaced);
69686 + Clear to use field as is. */
69687 + uint8_t maskOffset; /**< Relevant if mask != 0;
69688 + Mask offset within the replaces "size" */
69689 +} t_FmPcdManipHdrCustomGenFieldReplace;
69690 +
69691 +/**************************************************************************//**
69692 + @Description Parameters for defining custom header manipulation for IP replacement
69693 +*//***************************************************************************/
69694 +typedef struct t_FmPcdManipHdrCustomIpHdrReplace {
69695 + e_FmPcdManipHdrCustomIpReplace replaceType; /**< Selects replace update type */
69696 + bool decTtlHl; /**< Decrement TTL (IPV4) or Hop limit (IPV6) by 1 */
69697 + bool updateIpv4Id; /**< Relevant when replaceType =
69698 + e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4 */
69699 + uint16_t id; /**< 16 bit New IP ID; Relevant only if
69700 + updateIpv4Id = TRUE */
69701 + uint8_t hdrSize; /**< The size of the new IP header */
69702 + uint8_t hdr[FM_PCD_MANIP_MAX_HDR_SIZE];
69703 + /**< The new IP header */
69704 +} t_FmPcdManipHdrCustomIpHdrReplace;
69705 +
69706 +/**************************************************************************//**
69707 + @Description Parameters for defining custom header manipulation
69708 +*//***************************************************************************/
69709 +typedef struct t_FmPcdManipHdrCustomParams {
69710 + e_FmPcdManipHdrCustomType type; /**< Type of header field update manipulation */
69711 + union {
69712 + t_FmPcdManipHdrCustomIpHdrReplace ipHdrReplace; /**< Parameters IP header replacement */
69713 + t_FmPcdManipHdrCustomGenFieldReplace genFieldReplace; /**< Parameters IP header replacement */
69714 + } u;
69715 +} t_FmPcdManipHdrCustomParams;
69716 +
69717 +/**************************************************************************//**
69718 + @Description Parameters for defining specific L2 insertion manipulation
69719 +*//***************************************************************************/
69720 +typedef struct t_FmPcdManipHdrInsrtSpecificL2Params {
69721 + e_FmPcdManipHdrInsrtSpecificL2 specificL2; /**< Selects which L2 headers to insert */
69722 + bool update; /**< TRUE to update MPLS header */
69723 + uint8_t size; /**< size of inserted section */
69724 + uint8_t *p_Data; /**< data to be inserted */
69725 +} t_FmPcdManipHdrInsrtSpecificL2Params;
69726 +
69727 +#if (DPAA_VERSION >= 11)
69728 +/**************************************************************************//**
69729 + @Description Parameters for defining IP insertion manipulation
69730 +*//***************************************************************************/
69731 +typedef struct t_FmPcdManipHdrInsrtIpParams {
69732 + bool calcL4Checksum; /**< Calculate L4 checksum. */
69733 + e_FmPcdManipHdrQosMappingMode mappingMode; /**< TODO */
69734 + uint8_t lastPidOffset; /**< the offset of the last Protocol within
69735 + the inserted header */
69736 + uint16_t id; /**< 16 bit New IP ID */
69737 + bool dontFragOverwrite;
69738 + /**< IPv4 only. DF is overwritten with the hash-result next-to-last byte.
69739 + * This byte is configured to be overwritten when RPD is set. */
69740 + uint8_t lastDstOffset;
69741 + /**< IPv6 only. if routing extension exist, user should set the offset of the destination address
69742 + * in order to calculate UDP checksum pseudo header;
69743 + * Otherwise set it to '0'. */
69744 + t_FmPcdManipHdrInsrt insrt; /**< size and data to be inserted. */
69745 +} t_FmPcdManipHdrInsrtIpParams;
69746 +#endif /* (DPAA_VERSION >= 11) */
69747 +
69748 +/**************************************************************************//**
69749 + @Description Parameters for defining header insertion manipulation by header type
69750 +*//***************************************************************************/
69751 +typedef struct t_FmPcdManipHdrInsrtByHdrParams {
69752 + e_FmPcdManipHdrInsrtByHdrType type; /**< Selects manipulation type */
69753 + union {
69754 +
69755 + t_FmPcdManipHdrInsrtSpecificL2Params specificL2Params;
69756 + /**< Used when type = e_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2:
69757 + Selects which L2 headers to insert */
69758 +#if (DPAA_VERSION >= 11)
69759 + t_FmPcdManipHdrInsrtIpParams ipParams; /**< Used when type = e_FM_PCD_MANIP_INSRT_BY_HDR_IP */
69760 + t_FmPcdManipHdrInsrt insrt; /**< Used when type is one of e_FM_PCD_MANIP_INSRT_BY_HDR_UDP,
69761 + e_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE, or
69762 + e_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP */
69763 +#endif /* (DPAA_VERSION >= 11) */
69764 + } u;
69765 +} t_FmPcdManipHdrInsrtByHdrParams;
69766 +
69767 +/**************************************************************************//**
69768 + @Description Parameters for defining header insertion manipulation
69769 +*//***************************************************************************/
69770 +typedef struct t_FmPcdManipHdrInsrtParams {
69771 + e_FmPcdManipHdrInsrtType type; /**< Type of insertion manipulation */
69772 + union {
69773 + t_FmPcdManipHdrInsrtByHdrParams byHdr; /**< Parameters for defining header insertion manipulation by header type,
69774 + relevant if 'type' = e_FM_PCD_MANIP_INSRT_BY_HDR */
69775 + t_FmPcdManipHdrInsrtGenericParams generic; /**< Parameters for defining generic header insertion manipulation,
69776 + relevant if 'type' = e_FM_PCD_MANIP_INSRT_GENERIC */
69777 +#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
69778 + t_FmPcdManipHdrInsrtByTemplateParams byTemplate; /**< Parameters for defining header insertion manipulation by template,
69779 + relevant if 'type' = e_FM_PCD_MANIP_INSRT_BY_TEMPLATE */
69780 +#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
69781 + } u;
69782 +} t_FmPcdManipHdrInsrtParams;
69783 +
69784 +/**************************************************************************//**
69785 + @Description Parameters for defining header removal manipulation
69786 +*//***************************************************************************/
69787 +typedef struct t_FmPcdManipHdrRmvParams {
69788 + e_FmPcdManipHdrRmvType type; /**< Type of header removal manipulation */
69789 + union {
69790 + t_FmPcdManipHdrRmvByHdrParams byHdr; /**< Parameters for defining header removal manipulation by header type,
69791 + relevant if type = e_FM_PCD_MANIP_RMV_BY_HDR */
69792 + t_FmPcdManipHdrRmvGenericParams generic; /**< Parameters for defining generic header removal manipulation,
69793 + relevant if type = e_FM_PCD_MANIP_RMV_GENERIC */
69794 + } u;
69795 +} t_FmPcdManipHdrRmvParams;
69796 +
69797 +/**************************************************************************//**
69798 + @Description Parameters for defining header manipulation node
69799 +*//***************************************************************************/
69800 +typedef struct t_FmPcdManipHdrParams {
69801 + bool rmv; /**< TRUE, to define removal manipulation */
69802 + t_FmPcdManipHdrRmvParams rmvParams; /**< Parameters for removal manipulation, relevant if 'rmv' = TRUE */
69803 +
69804 + bool insrt; /**< TRUE, to define insertion manipulation */
69805 + t_FmPcdManipHdrInsrtParams insrtParams; /**< Parameters for insertion manipulation, relevant if 'insrt' = TRUE */
69806 +
69807 + bool fieldUpdate; /**< TRUE, to define field update manipulation */
69808 + t_FmPcdManipHdrFieldUpdateParams fieldUpdateParams; /**< Parameters for field update manipulation, relevant if 'fieldUpdate' = TRUE */
69809 +
69810 + bool custom; /**< TRUE, to define custom manipulation */
69811 + t_FmPcdManipHdrCustomParams customParams; /**< Parameters for custom manipulation, relevant if 'custom' = TRUE */
69812 +
69813 + bool dontParseAfterManip;/**< TRUE to de-activate the parser after the manipulation defined in this node.
69814 + Restrictions:
69815 + 1. MUST be set if the next engine after the CC is not another CC node
69816 + (but rather Policer or Keygen), and this is the last (no h_NextManip) in a chain
69817 + of manipulation nodes. This includes single nodes (i.e. no h_NextManip and
69818 + also never pointed as h_NextManip of other manipulation nodes)
69819 + 2. MUST be set if the next engine after the CC is another CC node, and
69820 + this is NOT the last manipulation node (i.e. it has h_NextManip).*/
69821 +} t_FmPcdManipHdrParams;
69822 +
69823 +/**************************************************************************//**
69824 + @Description Parameters for defining fragmentation manipulation
69825 +*//***************************************************************************/
69826 +typedef struct t_FmPcdManipFragParams {
69827 + e_NetHeaderType hdr; /**< Header selection */
69828 + union {
69829 +#if (DPAA_VERSION >= 11)
69830 + t_FmPcdManipFragCapwapParams capwapFrag; /**< Parameters for defining CAPWAP fragmentation,
69831 + relevant if 'hdr' = HEADER_TYPE_CAPWAP */
69832 +#endif /* (DPAA_VERSION >= 11) */
69833 + t_FmPcdManipFragIpParams ipFrag; /**< Parameters for defining IP fragmentation,
69834 + relevant if 'hdr' = HEADER_TYPE_Ipv4 or HEADER_TYPE_Ipv6 */
69835 + } u;
69836 +} t_FmPcdManipFragParams;
69837 +
69838 +/**************************************************************************//**
69839 + @Description Parameters for defining reassembly manipulation
69840 +*//***************************************************************************/
69841 +typedef struct t_FmPcdManipReassemParams {
69842 + e_NetHeaderType hdr; /**< Header selection */
69843 + union {
69844 +#if (DPAA_VERSION >= 11)
69845 + t_FmPcdManipReassemCapwapParams capwapReassem; /**< Parameters for defining CAPWAP reassembly,
69846 + relevant if 'hdr' = HEADER_TYPE_CAPWAP */
69847 +#endif /* (DPAA_VERSION >= 11) */
69848 +
69849 + t_FmPcdManipReassemIpParams ipReassem; /**< Parameters for defining IP reassembly,
69850 + relevant if 'hdr' = HEADER_TYPE_Ipv4 or HEADER_TYPE_Ipv6 */
69851 + } u;
69852 +} t_FmPcdManipReassemParams;
69853 +
69854 +/**************************************************************************//**
69855 + @Description Parameters for defining a manipulation node
69856 +*//***************************************************************************/
69857 +typedef struct t_FmPcdManipParams {
69858 + e_FmPcdManipType type; /**< Selects type of manipulation node */
69859 + union{
69860 + t_FmPcdManipHdrParams hdr; /**< Parameters for defining header manipulation node */
69861 + t_FmPcdManipReassemParams reassem; /**< Parameters for defining reassembly manipulation node */
69862 + t_FmPcdManipFragParams frag; /**< Parameters for defining fragmentation manipulation node */
69863 + t_FmPcdManipSpecialOffloadParams specialOffload; /**< Parameters for defining special offload manipulation node */
69864 + } u;
69865 +
69866 + t_Handle h_NextManip; /**< Supported for Header Manipulation only;
69867 + Handle to another (previously defined) manipulation node;
69868 + Allows concatenation of manipulation actions;
69869 + This parameter is optional and may be NULL. */
69870 +#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
69871 + bool fragOrReasm; /**< TRUE, if defined fragmentation/reassembly manipulation */
69872 + t_FmPcdManipFragOrReasmParams fragOrReasmParams; /**< Parameters for fragmentation/reassembly manipulation,
69873 + relevant if fragOrReasm = TRUE */
69874 +#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
69875 +} t_FmPcdManipParams;
69876 +
69877 +/**************************************************************************//**
69878 + @Description Structure for retrieving IP reassembly statistics
69879 +*//***************************************************************************/
69880 +typedef struct t_FmPcdManipReassemIpStats {
69881 + /* common counters for both IPv4 and IPv6 */
69882 + uint32_t timeout; /**< Counts the number of timeout occurrences */
69883 + uint32_t rfdPoolBusy; /**< Counts the number of failed attempts to allocate
69884 + a Reassembly Frame Descriptor */
69885 + uint32_t internalBufferBusy; /**< Counts the number of times an internal buffer busy occurred */
69886 + uint32_t externalBufferBusy; /**< Counts the number of times external buffer busy occurred */
69887 + uint32_t sgFragments; /**< Counts the number of Scatter/Gather fragments */
69888 + uint32_t dmaSemaphoreDepletion; /**< Counts the number of failed attempts to allocate a DMA semaphore */
69889 +#if (DPAA_VERSION >= 11)
69890 + uint32_t nonConsistentSp; /**< Counts the number of Non Consistent Storage Profile events for
69891 + successfully reassembled frames */
69892 +#endif /* (DPAA_VERSION >= 11) */
69893 + struct {
69894 + uint32_t successfullyReassembled; /**< Counts the number of successfully reassembled frames */
69895 + uint32_t validFragments; /**< Counts the total number of valid fragments that
69896 + have been processed for all frames */
69897 + uint32_t processedFragments; /**< Counts the number of processed fragments
69898 + (valid and error fragments) for all frames */
69899 + uint32_t malformedFragments; /**< Counts the number of malformed fragments processed for all frames */
69900 + uint32_t discardedFragments; /**< Counts the number of fragments discarded by the reassembly process */
69901 + uint32_t autoLearnBusy; /**< Counts the number of times a busy condition occurs when attempting
69902 + to access an IP-Reassembly Automatic Learning Hash set */
69903 + uint32_t moreThan16Fragments; /**< Counts the fragment occurrences in which the number of fragments-per-frame
69904 + exceeds 16 */
69905 + } specificHdrStatistics[2]; /**< slot '0' is for IPv4, slot '1' is for IPv6 */
69906 +} t_FmPcdManipReassemIpStats;
69907 +
69908 +/**************************************************************************//**
69909 + @Description Structure for retrieving IP fragmentation statistics
69910 +*//***************************************************************************/
69911 +typedef struct t_FmPcdManipFragIpStats {
69912 + uint32_t totalFrames; /**< Number of frames that passed through the manipulation node */
69913 + uint32_t fragmentedFrames; /**< Number of frames that were fragmented */
69914 + uint32_t generatedFragments; /**< Number of fragments that were generated */
69915 +} t_FmPcdManipFragIpStats;
69916 +
69917 +#if (DPAA_VERSION >= 11)
69918 +/**************************************************************************//**
69919 + @Description Structure for retrieving CAPWAP reassembly statistics
69920 +*//***************************************************************************/
69921 +typedef struct t_FmPcdManipReassemCapwapStats {
69922 + uint32_t timeout; /**< Counts the number of timeout occurrences */
69923 + uint32_t rfdPoolBusy; /**< Counts the number of failed attempts to allocate
69924 + a Reassembly Frame Descriptor */
69925 + uint32_t internalBufferBusy; /**< Counts the number of times an internal buffer busy occurred */
69926 + uint32_t externalBufferBusy; /**< Counts the number of times external buffer busy occurred */
69927 + uint32_t sgFragments; /**< Counts the number of Scatter/Gather fragments */
69928 + uint32_t dmaSemaphoreDepletion; /**< Counts the number of failed attempts to allocate a DMA semaphore */
69929 + uint32_t successfullyReassembled; /**< Counts the number of successfully reassembled frames */
69930 + uint32_t validFragments; /**< Counts the total number of valid fragments that
69931 + have been processed for all frames */
69932 + uint32_t processedFragments; /**< Counts the number of processed fragments
69933 + (valid and error fragments) for all frames */
69934 + uint32_t malformedFragments; /**< Counts the number of malformed fragments processed for all frames */
69935 + uint32_t autoLearnBusy; /**< Counts the number of times a busy condition occurs when attempting
69936 + to access an Reassembly Automatic Learning Hash set */
69937 + uint32_t discardedFragments; /**< Counts the number of fragments discarded by the reassembly process */
69938 + uint32_t moreThan16Fragments; /**< Counts the fragment occurrences in which the number of fragments-per-frame
69939 + exceeds 16 */
69940 + uint32_t exceedMaxReassemblyFrameLen;/**< ounts the number of times that a successful reassembled frame
69941 + length exceeds MaxReassembledFrameLength value */
69942 +} t_FmPcdManipReassemCapwapStats;
69943 +
69944 +/**************************************************************************//**
69945 + @Description Structure for retrieving CAPWAP fragmentation statistics
69946 +*//***************************************************************************/
69947 +typedef struct t_FmPcdManipFragCapwapStats {
69948 + uint32_t totalFrames; /**< Number of frames that passed through the manipulation node */
69949 + uint32_t fragmentedFrames; /**< Number of frames that were fragmented */
69950 + uint32_t generatedFragments; /**< Number of fragments that were generated */
69951 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
69952 + uint8_t sgAllocationFailure; /**< Number of allocation failure of s/g buffers */
69953 +#endif /* (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)) */
69954 +} t_FmPcdManipFragCapwapStats;
69955 +#endif /* (DPAA_VERSION >= 11) */
69956 +
69957 +/**************************************************************************//**
69958 + @Description Structure for retrieving reassembly statistics
69959 +*//***************************************************************************/
69960 +typedef struct t_FmPcdManipReassemStats {
69961 + union {
69962 + t_FmPcdManipReassemIpStats ipReassem; /**< Structure for IP reassembly statistics */
69963 +#if (DPAA_VERSION >= 11)
69964 + t_FmPcdManipReassemCapwapStats capwapReassem; /**< Structure for CAPWAP reassembly statistics */
69965 +#endif /* (DPAA_VERSION >= 11) */
69966 + } u;
69967 +} t_FmPcdManipReassemStats;
69968 +
69969 +/**************************************************************************//**
69970 + @Description Structure for retrieving fragmentation statistics
69971 +*//***************************************************************************/
69972 +typedef struct t_FmPcdManipFragStats {
69973 + union {
69974 + t_FmPcdManipFragIpStats ipFrag; /**< Structure for IP fragmentation statistics */
69975 +#if (DPAA_VERSION >= 11)
69976 + t_FmPcdManipFragCapwapStats capwapFrag; /**< Structure for CAPWAP fragmentation statistics */
69977 +#endif /* (DPAA_VERSION >= 11) */
69978 + } u;
69979 +} t_FmPcdManipFragStats;
69980 +
69981 +/**************************************************************************//**
69982 + @Description Structure for selecting manipulation statistics
69983 +*//***************************************************************************/
69984 +typedef struct t_FmPcdManipStats {
69985 + union {
69986 + t_FmPcdManipReassemStats reassem; /**< Structure for reassembly statistics */
69987 + t_FmPcdManipFragStats frag; /**< Structure for fragmentation statistics */
69988 + } u;
69989 +} t_FmPcdManipStats;
69990 +
69991 +#if (DPAA_VERSION >= 11)
69992 +/**************************************************************************//**
69993 + @Description Parameters for defining frame replicator group and its members
69994 +*//***************************************************************************/
69995 +typedef struct t_FmPcdFrmReplicGroupParams {
69996 + uint8_t maxNumOfEntries; /**< Maximal number of members in the group;
69997 + Must be at least 2. */
69998 + uint8_t numOfEntries; /**< Number of members in the group;
69999 + Must be at least 1. */
70000 + t_FmPcdCcNextEngineParams nextEngineParams[FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES];
70001 + /**< Array of members' parameters */
70002 +} t_FmPcdFrmReplicGroupParams;
70003 +#endif /* (DPAA_VERSION >= 11) */
70004 +
70005 +#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
70006 +/**************************************************************************//**
70007 + @Description structure for defining statistics node
70008 +*//***************************************************************************/
70009 +typedef struct t_FmPcdStatsParams {
70010 + e_FmPcdStatsType type; /**< type of statistics node */
70011 +} t_FmPcdStatsParams;
70012 +#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
70013 +
70014 +/**************************************************************************//**
70015 + @Function FM_PCD_NetEnvCharacteristicsSet
70016 +
70017 + @Description Define a set of Network Environment Characteristics.
70018 +
70019 + When setting an environment it is important to understand its
70020 + application. It is not meant to describe the flows that will run
70021 + on the ports using this environment, but what the user means TO DO
70022 + with the PCD mechanisms in order to parse-classify-distribute those
70023 + frames.
70024 + By specifying a distinction unit, the user means it would use that option
70025 + for distinction between frames at either a KeyGen scheme or a coarse
70026 + classification action descriptor. Using interchangeable headers to define a
70027 + unit means that the user is indifferent to which of the interchangeable
70028 + headers is present in the frame, and wants the distinction to be based
70029 + on the presence of either one of them.
70030 +
70031 + Depending on context, there are limitations to the use of environments. A
70032 + port using the PCD functionality is bound to an environment. Some or even
70033 + all ports may share an environment but also an environment per port is
70034 + possible. When initializing a scheme, a classification plan group (see below),
70035 + or a coarse classification tree, one of the initialized environments must be
70036 + stated and related to. When a port is bound to a scheme, a classification
70037 + plan group, or a coarse classification tree, it MUST be bound to the same
70038 + environment.
70039 +
70040 + The different PCD modules, may relate (for flows definition) ONLY on
70041 + distinction units as defined by their environment. When initializing a
70042 + scheme for example, it may not choose to select IPV4 as a match for
70043 + recognizing flows unless it was defined in the relating environment. In
70044 + fact, to guide the user through the configuration of the PCD, each module's
70045 + characterization in terms of flows is not done using protocol names, but using
70046 + environment indexes.
70047 +
70048 + In terms of HW implementation, the list of distinction units sets the LCV vectors
70049 + and later used for match vector, classification plan vectors and coarse classification
70050 + indexing.
70051 +
70052 + @Param[in] h_FmPcd FM PCD module descriptor.
70053 + @Param[in] p_NetEnvParams A structure of parameters for the initialization of
70054 + the network environment.
70055 +
70056 + @Return A handle to the initialized object on success; NULL code otherwise.
70057 +
70058 + @Cautions Allowed only following FM_PCD_Init().
70059 +*//***************************************************************************/
70060 +t_Handle FM_PCD_NetEnvCharacteristicsSet(t_Handle h_FmPcd, t_FmPcdNetEnvParams *p_NetEnvParams);
70061 +
70062 +/**************************************************************************//**
70063 + @Function FM_PCD_NetEnvCharacteristicsDelete
70064 +
70065 + @Description Deletes a set of Network Environment Characteristics.
70066 +
70067 + @Param[in] h_NetEnv A handle to the Network environment.
70068 +
70069 + @Return E_OK on success; Error code otherwise.
70070 +*//***************************************************************************/
70071 +t_Error FM_PCD_NetEnvCharacteristicsDelete(t_Handle h_NetEnv);
70072 +
70073 +/**************************************************************************//**
70074 + @Function FM_PCD_KgSchemeSet
70075 +
70076 + @Description Initializing or modifying and enabling a scheme for the KeyGen.
70077 + This routine should be called for adding or modifying a scheme.
70078 + When a scheme needs modifying, the API requires that it will be
70079 + rewritten. In such a case 'modify' should be TRUE. If the
70080 + routine is called for a valid scheme and 'modify' is FALSE,
70081 + it will return error.
70082 +
70083 + @Param[in] h_FmPcd If this is a new scheme - A handle to an FM PCD Module.
70084 + Otherwise NULL (ignored by driver).
70085 + @Param[in,out] p_SchemeParams A structure of parameters for defining the scheme
70086 +
70087 + @Return A handle to the initialized scheme on success; NULL code otherwise.
70088 + When used as "modify" (rather than for setting a new scheme),
70089 + p_SchemeParams->id.h_Scheme will return NULL if action fails due to scheme
70090 + BUSY state.
70091 +
70092 + @Cautions Allowed only following FM_PCD_Init().
70093 +*//***************************************************************************/
70094 +t_Handle FM_PCD_KgSchemeSet(t_Handle h_FmPcd,
70095 + t_FmPcdKgSchemeParams *p_SchemeParams);
70096 +
70097 +/**************************************************************************//**
70098 + @Function FM_PCD_KgSchemeDelete
70099 +
70100 + @Description Deleting an initialized scheme.
70101 +
70102 + @Param[in] h_Scheme scheme handle as returned by FM_PCD_KgSchemeSet()
70103 +
70104 + @Return E_OK on success; Error code otherwise.
70105 +
70106 + @Cautions Allowed only following FM_PCD_Init() & FM_PCD_KgSchemeSet().
70107 +*//***************************************************************************/
70108 +t_Error FM_PCD_KgSchemeDelete(t_Handle h_Scheme);
70109 +
70110 +/**************************************************************************//**
70111 + @Function FM_PCD_KgSchemeGetCounter
70112 +
70113 + @Description Reads scheme packet counter.
70114 +
70115 + @Param[in] h_Scheme scheme handle as returned by FM_PCD_KgSchemeSet().
70116 +
70117 + @Return Counter's current value.
70118 +
70119 + @Cautions Allowed only following FM_PCD_Init() & FM_PCD_KgSchemeSet().
70120 +*//***************************************************************************/
70121 +uint32_t FM_PCD_KgSchemeGetCounter(t_Handle h_Scheme);
70122 +
70123 +/**************************************************************************//**
70124 + @Function FM_PCD_KgSchemeSetCounter
70125 +
70126 + @Description Writes scheme packet counter.
70127 +
70128 + @Param[in] h_Scheme scheme handle as returned by FM_PCD_KgSchemeSet().
70129 + @Param[in] value New scheme counter value - typically '0' for
70130 + resetting the counter.
70131 +
70132 + @Return E_OK on success; Error code otherwise.
70133 +
70134 + @Cautions Allowed only following FM_PCD_Init() & FM_PCD_KgSchemeSet().
70135 +*//***************************************************************************/
70136 +t_Error FM_PCD_KgSchemeSetCounter(t_Handle h_Scheme, uint32_t value);
70137 +
70138 +/**************************************************************************//**
70139 + @Function FM_PCD_PlcrProfileSet
70140 +
70141 + @Description Sets a profile entry in the policer profile table.
70142 + The routine overrides any existing value.
70143 +
70144 + @Param[in] h_FmPcd A handle to an FM PCD Module.
70145 + @Param[in] p_Profile A structure of parameters for defining a
70146 + policer profile entry.
70147 +
70148 + @Return A handle to the initialized object on success; NULL code otherwise.
70149 + When used as "modify" (rather than for setting a new profile),
70150 + p_Profile->id.h_Profile will return NULL if action fails due to profile
70151 + BUSY state.
70152 + @Cautions Allowed only following FM_PCD_Init().
70153 +*//***************************************************************************/
70154 +t_Handle FM_PCD_PlcrProfileSet(t_Handle h_FmPcd,
70155 + t_FmPcdPlcrProfileParams *p_Profile);
70156 +
70157 +/**************************************************************************//**
70158 + @Function FM_PCD_PlcrProfileDelete
70159 +
70160 + @Description Delete a profile entry in the policer profile table.
70161 + The routine set entry to invalid.
70162 +
70163 + @Param[in] h_Profile A handle to the profile.
70164 +
70165 + @Return E_OK on success; Error code otherwise.
70166 +
70167 + @Cautions Allowed only following FM_PCD_Init().
70168 +*//***************************************************************************/
70169 +t_Error FM_PCD_PlcrProfileDelete(t_Handle h_Profile);
70170 +
70171 +/**************************************************************************//**
70172 + @Function FM_PCD_PlcrProfileGetCounter
70173 +
70174 + @Description Sets an entry in the classification plan.
70175 + The routine overrides any existing value.
70176 +
70177 + @Param[in] h_Profile A handle to the profile.
70178 + @Param[in] counter Counter selector.
70179 +
70180 + @Return specific counter value.
70181 +
70182 + @Cautions Allowed only following FM_PCD_Init().
70183 +*//***************************************************************************/
70184 +uint32_t FM_PCD_PlcrProfileGetCounter(t_Handle h_Profile,
70185 + e_FmPcdPlcrProfileCounters counter);
70186 +
70187 +/**************************************************************************//**
70188 + @Function FM_PCD_PlcrProfileSetCounter
70189 +
70190 + @Description Sets an entry in the classification plan.
70191 + The routine overrides any existing value.
70192 +
70193 + @Param[in] h_Profile A handle to the profile.
70194 + @Param[in] counter Counter selector.
70195 + @Param[in] value value to set counter with.
70196 +
70197 + @Return E_OK on success; Error code otherwise.
70198 +
70199 + @Cautions Allowed only following FM_PCD_Init().
70200 +*//***************************************************************************/
70201 +t_Error FM_PCD_PlcrProfileSetCounter(t_Handle h_Profile,
70202 + e_FmPcdPlcrProfileCounters counter,
70203 + uint32_t value);
70204 +
70205 +/**************************************************************************//**
70206 + @Function FM_PCD_CcRootBuild
70207 +
70208 + @Description This routine must be called to define a complete coarse
70209 + classification tree. This is the way to define coarse
70210 + classification to a certain flow - the KeyGen schemes
70211 + may point only to trees defined in this way.
70212 +
70213 + @Param[in] h_FmPcd FM PCD module descriptor.
70214 + @Param[in] p_Params A structure of parameters to define the tree.
70215 +
70216 + @Return A handle to the initialized object on success; NULL code otherwise.
70217 +
70218 + @Cautions Allowed only following FM_PCD_Init().
70219 +*//***************************************************************************/
70220 +t_Handle FM_PCD_CcRootBuild (t_Handle h_FmPcd,
70221 + t_FmPcdCcTreeParams *p_Params);
70222 +
70223 +/**************************************************************************//**
70224 + @Function FM_PCD_CcRootDelete
70225 +
70226 + @Description Deleting an built tree.
70227 +
70228 + @Param[in] h_CcTree A handle to a CC tree.
70229 +
70230 + @Return E_OK on success; Error code otherwise.
70231 +
70232 + @Cautions Allowed only following FM_PCD_Init().
70233 +*//***************************************************************************/
70234 +t_Error FM_PCD_CcRootDelete(t_Handle h_CcTree);
70235 +
70236 +/**************************************************************************//**
70237 + @Function FM_PCD_CcRootModifyNextEngine
70238 +
70239 + @Description Modify the Next Engine Parameters in the entry of the tree.
70240 +
70241 + @Param[in] h_CcTree A handle to the tree
70242 + @Param[in] grpId A Group index in the tree
70243 + @Param[in] index Entry index in the group defined by grpId
70244 + @Param[in] p_FmPcdCcNextEngineParams Pointer to new next engine parameters
70245 +
70246 + @Return E_OK on success; Error code otherwise.
70247 +
70248 + @Cautions Allowed only following FM_PCD_CcBuildTree().
70249 +*//***************************************************************************/
70250 +t_Error FM_PCD_CcRootModifyNextEngine(t_Handle h_CcTree,
70251 + uint8_t grpId,
70252 + uint8_t index,
70253 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
70254 +
70255 +/**************************************************************************//**
70256 + @Function FM_PCD_MatchTableSet
70257 +
70258 + @Description This routine should be called for each CC (coarse classification)
70259 + node. The whole CC tree should be built bottom up so that each
70260 + node points to already defined nodes.
70261 +
70262 + @Param[in] h_FmPcd FM PCD module descriptor.
70263 + @Param[in] p_Param A structure of parameters defining the CC node
70264 +
70265 + @Return A handle to the initialized object on success; NULL code otherwise.
70266 +
70267 + @Cautions Allowed only following FM_PCD_Init().
70268 +*//***************************************************************************/
70269 +t_Handle FM_PCD_MatchTableSet(t_Handle h_FmPcd, t_FmPcdCcNodeParams *p_Param);
70270 +
70271 +/**************************************************************************//**
70272 + @Function FM_PCD_MatchTableDelete
70273 +
70274 + @Description Deleting an built node.
70275 +
70276 + @Param[in] h_CcNode A handle to a CC node.
70277 +
70278 + @Return E_OK on success; Error code otherwise.
70279 +
70280 + @Cautions Allowed only following FM_PCD_Init().
70281 +*//***************************************************************************/
70282 +t_Error FM_PCD_MatchTableDelete(t_Handle h_CcNode);
70283 +
70284 +/**************************************************************************//**
70285 + @Function FM_PCD_MatchTableModifyMissNextEngine
70286 +
70287 + @Description Modify the Next Engine Parameters of the Miss key case of the node.
70288 +
70289 + @Param[in] h_CcNode A handle to the node
70290 + @Param[in] p_FmPcdCcNextEngineParams Parameters for defining next engine
70291 +
70292 + @Return E_OK on success; Error code otherwise.
70293 +
70294 + @Cautions Allowed only following FM_PCD_MatchTableSet();
70295 + Not relevant in the case the node is of type 'INDEXED_LOOKUP'.
70296 + When configuring nextEngine = e_FM_PCD_CC, note that
70297 + p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
70298 + from the currently changed table.
70299 +
70300 +*//***************************************************************************/
70301 +t_Error FM_PCD_MatchTableModifyMissNextEngine(t_Handle h_CcNode,
70302 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
70303 +
70304 +/**************************************************************************//**
70305 + @Function FM_PCD_MatchTableRemoveKey
70306 +
70307 + @Description Remove the key (including next engine parameters of this key)
70308 + defined by the index of the relevant node.
70309 +
70310 + @Param[in] h_CcNode A handle to the node
70311 + @Param[in] keyIndex Key index for removing
70312 +
70313 + @Return E_OK on success; Error code otherwise.
70314 +
70315 + @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
70316 + node and the nodes that lead to it.
70317 +*//***************************************************************************/
70318 +t_Error FM_PCD_MatchTableRemoveKey(t_Handle h_CcNode, uint16_t keyIndex);
70319 +
70320 +/**************************************************************************//**
70321 + @Function FM_PCD_MatchTableAddKey
70322 +
70323 + @Description Add the key (including next engine parameters of this key in the
70324 + index defined by the keyIndex. Note that 'FM_PCD_LAST_KEY_INDEX'
70325 + may be used by user that don't care about the position of the
70326 + key in the table - in that case, the key will be automatically
70327 + added by the driver in the last available entry.
70328 +
70329 + @Param[in] h_CcNode A handle to the node
70330 + @Param[in] keyIndex Key index for adding.
70331 + @Param[in] keySize Key size of added key
70332 + @Param[in] p_KeyParams A pointer to the parameters includes
70333 + new key with Next Engine Parameters
70334 +
70335 + @Return E_OK on success; Error code otherwise.
70336 +
70337 + @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
70338 + node and the nodes that lead to it.
70339 +*//***************************************************************************/
70340 +t_Error FM_PCD_MatchTableAddKey(t_Handle h_CcNode,
70341 + uint16_t keyIndex,
70342 + uint8_t keySize,
70343 + t_FmPcdCcKeyParams *p_KeyParams);
70344 +
70345 +/**************************************************************************//**
70346 + @Function FM_PCD_MatchTableModifyNextEngine
70347 +
70348 + @Description Modify the Next Engine Parameters in the relevant key entry of the node.
70349 +
70350 + @Param[in] h_CcNode A handle to the node
70351 + @Param[in] keyIndex Key index for Next Engine modifications
70352 + @Param[in] p_FmPcdCcNextEngineParams Parameters for defining next engine
70353 +
70354 + @Return E_OK on success; Error code otherwise.
70355 +
70356 + @Cautions Allowed only following FM_PCD_MatchTableSet().
70357 + When configuring nextEngine = e_FM_PCD_CC, note that
70358 + p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
70359 + from the currently changed table.
70360 +
70361 +*//***************************************************************************/
70362 +t_Error FM_PCD_MatchTableModifyNextEngine(t_Handle h_CcNode,
70363 + uint16_t keyIndex,
70364 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
70365 +
70366 +/**************************************************************************//**
70367 + @Function FM_PCD_MatchTableModifyKeyAndNextEngine
70368 +
70369 + @Description Modify the key and Next Engine Parameters of this key in the
70370 + index defined by the keyIndex.
70371 +
70372 + @Param[in] h_CcNode A handle to the node
70373 + @Param[in] keyIndex Key index for adding
70374 + @Param[in] keySize Key size of added key
70375 + @Param[in] p_KeyParams A pointer to the parameters includes
70376 + modified key and modified Next Engine Parameters
70377 +
70378 + @Return E_OK on success; Error code otherwise.
70379 +
70380 + @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
70381 + node and the nodes that lead to it.
70382 + When configuring nextEngine = e_FM_PCD_CC, note that
70383 + p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
70384 + from the currently changed table.
70385 +*//***************************************************************************/
70386 +t_Error FM_PCD_MatchTableModifyKeyAndNextEngine(t_Handle h_CcNode,
70387 + uint16_t keyIndex,
70388 + uint8_t keySize,
70389 + t_FmPcdCcKeyParams *p_KeyParams);
70390 +
70391 +/**************************************************************************//**
70392 + @Function FM_PCD_MatchTableModifyKey
70393 +
70394 + @Description Modify the key in the index defined by the keyIndex.
70395 +
70396 + @Param[in] h_CcNode A handle to the node
70397 + @Param[in] keyIndex Key index for adding
70398 + @Param[in] keySize Key size of added key
70399 + @Param[in] p_Key A pointer to the new key
70400 + @Param[in] p_Mask A pointer to the new mask if relevant,
70401 + otherwise pointer to NULL
70402 +
70403 + @Return E_OK on success; Error code otherwise.
70404 +
70405 + @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
70406 + node and the nodes that lead to it.
70407 +*//***************************************************************************/
70408 +t_Error FM_PCD_MatchTableModifyKey(t_Handle h_CcNode,
70409 + uint16_t keyIndex,
70410 + uint8_t keySize,
70411 + uint8_t *p_Key,
70412 + uint8_t *p_Mask);
70413 +
70414 +/**************************************************************************//**
70415 + @Function FM_PCD_MatchTableFindNRemoveKey
70416 +
70417 + @Description Remove the key (including next engine parameters of this key)
70418 + defined by the key and mask. Note that this routine will search
70419 + the node to locate the index of the required key (& mask) to remove.
70420 +
70421 + @Param[in] h_CcNode A handle to the node
70422 + @Param[in] keySize Key size of the one to remove.
70423 + @Param[in] p_Key A pointer to the requested key to remove.
70424 + @Param[in] p_Mask A pointer to the mask if relevant,
70425 + otherwise pointer to NULL
70426 +
70427 + @Return E_OK on success; Error code otherwise.
70428 +
70429 + @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
70430 + node and the nodes that lead to it.
70431 +*//***************************************************************************/
70432 +t_Error FM_PCD_MatchTableFindNRemoveKey(t_Handle h_CcNode,
70433 + uint8_t keySize,
70434 + uint8_t *p_Key,
70435 + uint8_t *p_Mask);
70436 +
70437 +/**************************************************************************//**
70438 + @Function FM_PCD_MatchTableFindNModifyNextEngine
70439 +
70440 + @Description Modify the Next Engine Parameters in the relevant key entry of
70441 + the node. Note that this routine will search the node to locate
70442 + the index of the required key (& mask) to modify.
70443 +
70444 + @Param[in] h_CcNode A handle to the node
70445 + @Param[in] keySize Key size of the one to modify.
70446 + @Param[in] p_Key A pointer to the requested key to modify.
70447 + @Param[in] p_Mask A pointer to the mask if relevant,
70448 + otherwise pointer to NULL
70449 + @Param[in] p_FmPcdCcNextEngineParams Parameters for defining next engine
70450 +
70451 + @Return E_OK on success; Error code otherwise.
70452 +
70453 + @Cautions Allowed only following FM_PCD_MatchTableSet().
70454 + When configuring nextEngine = e_FM_PCD_CC, note that
70455 + p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
70456 + from the currently changed table.
70457 +*//***************************************************************************/
70458 +t_Error FM_PCD_MatchTableFindNModifyNextEngine(t_Handle h_CcNode,
70459 + uint8_t keySize,
70460 + uint8_t *p_Key,
70461 + uint8_t *p_Mask,
70462 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
70463 +
70464 +/**************************************************************************//**
70465 + @Function FM_PCD_MatchTableFindNModifyKeyAndNextEngine
70466 +
70467 + @Description Modify the key and Next Engine Parameters of this key in the
70468 + index defined by the keyIndex. Note that this routine will search
70469 + the node to locate the index of the required key (& mask) to modify.
70470 +
70471 + @Param[in] h_CcNode A handle to the node
70472 + @Param[in] keySize Key size of the one to modify.
70473 + @Param[in] p_Key A pointer to the requested key to modify.
70474 + @Param[in] p_Mask A pointer to the mask if relevant,
70475 + otherwise pointer to NULL
70476 + @Param[in] p_KeyParams A pointer to the parameters includes
70477 + modified key and modified Next Engine Parameters
70478 +
70479 + @Return E_OK on success; Error code otherwise.
70480 +
70481 + @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
70482 + node and the nodes that lead to it.
70483 + When configuring nextEngine = e_FM_PCD_CC, note that
70484 + p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
70485 + from the currently changed table.
70486 +*//***************************************************************************/
70487 +t_Error FM_PCD_MatchTableFindNModifyKeyAndNextEngine(t_Handle h_CcNode,
70488 + uint8_t keySize,
70489 + uint8_t *p_Key,
70490 + uint8_t *p_Mask,
70491 + t_FmPcdCcKeyParams *p_KeyParams);
70492 +
70493 +/**************************************************************************//**
70494 + @Function FM_PCD_MatchTableFindNModifyKey
70495 +
70496 + @Description Modify the key in the index defined by the keyIndex. Note that
70497 + this routine will search the node to locate the index of the
70498 + required key (& mask) to modify.
70499 +
70500 + @Param[in] h_CcNode A handle to the node
70501 + @Param[in] keySize Key size of the one to modify.
70502 + @Param[in] p_Key A pointer to the requested key to modify.
70503 + @Param[in] p_Mask A pointer to the mask if relevant,
70504 + otherwise pointer to NULL
70505 + @Param[in] p_NewKey A pointer to the new key
70506 + @Param[in] p_NewMask A pointer to the new mask if relevant,
70507 + otherwise pointer to NULL
70508 +
70509 + @Return E_OK on success; Error code otherwise.
70510 +
70511 + @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
70512 + node and the nodes that lead to it.
70513 +*//***************************************************************************/
70514 +t_Error FM_PCD_MatchTableFindNModifyKey(t_Handle h_CcNode,
70515 + uint8_t keySize,
70516 + uint8_t *p_Key,
70517 + uint8_t *p_Mask,
70518 + uint8_t *p_NewKey,
70519 + uint8_t *p_NewMask);
70520 +
70521 +/**************************************************************************//**
70522 + @Function FM_PCD_MatchTableGetKeyCounter
70523 +
70524 + @Description This routine may be used to get a counter of specific key in a CC
70525 + Node; This counter reflects how many frames passed that were matched
70526 + this key.
70527 +
70528 + @Param[in] h_CcNode A handle to the node
70529 + @Param[in] keyIndex Key index for adding
70530 +
70531 + @Return The specific key counter.
70532 +
70533 + @Cautions Allowed only following FM_PCD_MatchTableSet().
70534 +*//***************************************************************************/
70535 +uint32_t FM_PCD_MatchTableGetKeyCounter(t_Handle h_CcNode, uint16_t keyIndex);
70536 +
70537 +/**************************************************************************//**
70538 + @Function FM_PCD_MatchTableGetKeyStatistics
70539 +
70540 + @Description This routine may be used to get statistics counters of specific key
70541 + in a CC Node.
70542 +
70543 + If 'e_FM_PCD_CC_STATS_MODE_FRAME' and
70544 + 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node,
70545 + these counters reflect how many frames passed that were matched
70546 + this key; The total frames count will be returned in the counter
70547 + of the first range (as only one frame length range was defined).
70548 + If 'e_FM_PCD_CC_STATS_MODE_RMON' was set for this node, the total
70549 + frame count will be separated to frame length counters, based on
70550 + provided frame length ranges.
70551 +
70552 + @Param[in] h_CcNode A handle to the node
70553 + @Param[in] keyIndex Key index for adding
70554 + @Param[out] p_KeyStatistics Key statistics counters
70555 +
70556 + @Return The specific key statistics.
70557 +
70558 + @Cautions Allowed only following FM_PCD_MatchTableSet().
70559 +*//***************************************************************************/
70560 +t_Error FM_PCD_MatchTableGetKeyStatistics(t_Handle h_CcNode,
70561 + uint16_t keyIndex,
70562 + t_FmPcdCcKeyStatistics *p_KeyStatistics);
70563 +
70564 +/**************************************************************************//**
70565 + @Function FM_PCD_MatchTableGetMissStatistics
70566 +
70567 + @Description This routine may be used to get statistics counters of miss entry
70568 + in a CC Node.
70569 +
70570 + If 'e_FM_PCD_CC_STATS_MODE_FRAME' and
70571 + 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node,
70572 + these counters reflect how many frames were not matched to any
70573 + existing key and therefore passed through the miss entry; The
70574 + total frames count will be returned in the counter of the
70575 + first range (as only one frame length range was defined).
70576 +
70577 + @Param[in] h_CcNode A handle to the node
70578 + @Param[out] p_MissStatistics Statistics counters for 'miss'
70579 +
70580 + @Return The statistics for 'miss'.
70581 +
70582 + @Cautions Allowed only following FM_PCD_MatchTableSet().
70583 +*//***************************************************************************/
70584 +t_Error FM_PCD_MatchTableGetMissStatistics(t_Handle h_CcNode,
70585 + t_FmPcdCcKeyStatistics *p_MissStatistics);
70586 +
70587 +/**************************************************************************//**
70588 + @Function FM_PCD_MatchTableFindNGetKeyStatistics
70589 +
70590 + @Description This routine may be used to get statistics counters of specific key
70591 + in a CC Node.
70592 +
70593 + If 'e_FM_PCD_CC_STATS_MODE_FRAME' and
70594 + 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node,
70595 + these counters reflect how many frames passed that were matched
70596 + this key; The total frames count will be returned in the counter
70597 + of the first range (as only one frame length range was defined).
70598 + If 'e_FM_PCD_CC_STATS_MODE_RMON' was set for this node, the total
70599 + frame count will be separated to frame length counters, based on
70600 + provided frame length ranges.
70601 + Note that this routine will search the node to locate the index
70602 + of the required key based on received key parameters.
70603 +
70604 + @Param[in] h_CcNode A handle to the node
70605 + @Param[in] keySize Size of the requested key
70606 + @Param[in] p_Key A pointer to the requested key
70607 + @Param[in] p_Mask A pointer to the mask if relevant,
70608 + otherwise pointer to NULL
70609 + @Param[out] p_KeyStatistics Key statistics counters
70610 +
70611 + @Return The specific key statistics.
70612 +
70613 + @Cautions Allowed only following FM_PCD_MatchTableSet().
70614 +*//***************************************************************************/
70615 +t_Error FM_PCD_MatchTableFindNGetKeyStatistics(t_Handle h_CcNode,
70616 + uint8_t keySize,
70617 + uint8_t *p_Key,
70618 + uint8_t *p_Mask,
70619 + t_FmPcdCcKeyStatistics *p_KeyStatistics);
70620 +
70621 +/**************************************************************************//*
70622 + @Function FM_PCD_MatchTableGetNextEngine
70623 +
70624 + @Description Gets NextEngine of the relevant keyIndex.
70625 +
70626 + @Param[in] h_CcNode A handle to the node.
70627 + @Param[in] keyIndex keyIndex in the relevant node.
70628 + @Param[out] p_FmPcdCcNextEngineParams here updated nextEngine parameters for
70629 + the relevant keyIndex of the CC Node
70630 + received as parameter to this function
70631 +
70632 + @Return E_OK on success; Error code otherwise.
70633 +
70634 + @Cautions Allowed only following FM_PCD_Init().
70635 +*//***************************************************************************/
70636 +t_Error FM_PCD_MatchTableGetNextEngine(t_Handle h_CcNode,
70637 + uint16_t keyIndex,
70638 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
70639 +
70640 +/**************************************************************************//*
70641 + @Function FM_PCD_MatchTableGetIndexedHashBucket
70642 +
70643 + @Description This routine simulates KeyGen operation on the provided key and
70644 + calculates to which hash bucket it will be mapped.
70645 +
70646 + @Param[in] h_CcNode A handle to the node.
70647 + @Param[in] kgKeySize Key size as it was configured in the KG
70648 + scheme that leads to this hash.
70649 + @Param[in] p_KgKey Pointer to the key; must be like the key
70650 + that the KG is generated, i.e. the same
70651 + extraction and with mask if exist.
70652 + @Param[in] kgHashShift Hash-shift as it was configured in the KG
70653 + scheme that leads to this hash.
70654 + @Param[out] p_CcNodeBucketHandle Pointer to the bucket of the provided key.
70655 + @Param[out] p_BucketIndex Index to the bucket of the provided key
70656 + @Param[out] p_LastIndex Pointer to last index in the bucket of the
70657 + provided key.
70658 +
70659 + @Return E_OK on success; Error code otherwise.
70660 +
70661 + @Cautions Allowed only following FM_PCD_HashTableSet()
70662 +*//***************************************************************************/
70663 +t_Error FM_PCD_MatchTableGetIndexedHashBucket(t_Handle h_CcNode,
70664 + uint8_t kgKeySize,
70665 + uint8_t *p_KgKey,
70666 + uint8_t kgHashShift,
70667 + t_Handle *p_CcNodeBucketHandle,
70668 + uint8_t *p_BucketIndex,
70669 + uint16_t *p_LastIndex);
70670 +
70671 +/**************************************************************************//**
70672 + @Function FM_PCD_HashTableSet
70673 +
70674 + @Description This routine initializes a hash table structure.
70675 + KeyGen hash result determines the hash bucket.
70676 + Next, KeyGen key is compared against all keys of this
70677 + bucket (exact match).
70678 + Number of sets (number of buckets) of the hash equals to the
70679 + number of 1-s in 'hashResMask' in the provided parameters.
70680 + Number of hash table ways is then calculated by dividing
70681 + 'maxNumOfKeys' equally between the hash sets. This is the maximal
70682 + number of keys that a hash bucket may hold.
70683 + The hash table is initialized empty and keys may be
70684 + added to it following the initialization. Keys masks are not
70685 + supported in current hash table implementation.
70686 + The initialized hash table can be integrated as a node in a
70687 + CC tree.
70688 +
70689 + @Param[in] h_FmPcd FM PCD module descriptor.
70690 + @Param[in] p_Param A structure of parameters defining the hash table
70691 +
70692 + @Return A handle to the initialized object on success; NULL code otherwise.
70693 +
70694 + @Cautions Allowed only following FM_PCD_Init().
70695 +*//***************************************************************************/
70696 +t_Handle FM_PCD_HashTableSet(t_Handle h_FmPcd, t_FmPcdHashTableParams *p_Param);
70697 +
70698 +/**************************************************************************//**
70699 + @Function FM_PCD_HashTableDelete
70700 +
70701 + @Description This routine deletes the provided hash table and released all
70702 + its allocated resources.
70703 +
70704 + @Param[in] h_HashTbl A handle to a hash table
70705 +
70706 + @Return E_OK on success; Error code otherwise.
70707 +
70708 + @Cautions Allowed only following FM_PCD_HashTableSet().
70709 +*//***************************************************************************/
70710 +t_Error FM_PCD_HashTableDelete(t_Handle h_HashTbl);
70711 +
70712 +/**************************************************************************//**
70713 + @Function FM_PCD_HashTableAddKey
70714 +
70715 + @Description This routine adds the provided key (including next engine
70716 + parameters of this key) to the hash table.
70717 + The key is added as the last key of the bucket that it is
70718 + mapped to.
70719 +
70720 + @Param[in] h_HashTbl A handle to a hash table
70721 + @Param[in] keySize Key size of added key
70722 + @Param[in] p_KeyParams A pointer to the parameters includes
70723 + new key with next engine parameters; The pointer
70724 + to the key mask must be NULL, as masks are not
70725 + supported in hash table implementation.
70726 +
70727 + @Return E_OK on success; Error code otherwise.
70728 +
70729 + @Cautions Allowed only following FM_PCD_HashTableSet().
70730 +*//***************************************************************************/
70731 +t_Error FM_PCD_HashTableAddKey(t_Handle h_HashTbl,
70732 + uint8_t keySize,
70733 + t_FmPcdCcKeyParams *p_KeyParams);
70734 +
70735 +/**************************************************************************//**
70736 + @Function FM_PCD_HashTableRemoveKey
70737 +
70738 + @Description This routine removes the requested key (including next engine
70739 + parameters of this key) from the hash table.
70740 +
70741 + @Param[in] h_HashTbl A handle to a hash table
70742 + @Param[in] keySize Key size of the one to remove.
70743 + @Param[in] p_Key A pointer to the requested key to remove.
70744 +
70745 + @Return E_OK on success; Error code otherwise.
70746 +
70747 + @Cautions Allowed only following FM_PCD_HashTableSet().
70748 +*//***************************************************************************/
70749 +t_Error FM_PCD_HashTableRemoveKey(t_Handle h_HashTbl,
70750 + uint8_t keySize,
70751 + uint8_t *p_Key);
70752 +
70753 +/**************************************************************************//**
70754 + @Function FM_PCD_HashTableModifyNextEngine
70755 +
70756 + @Description This routine modifies the next engine for the provided key. The
70757 + key should be previously added to the hash table.
70758 +
70759 + @Param[in] h_HashTbl A handle to a hash table
70760 + @Param[in] keySize Key size of the key to modify.
70761 + @Param[in] p_Key A pointer to the requested key to modify.
70762 + @Param[in] p_FmPcdCcNextEngineParams A structure for defining new next engine
70763 + parameters.
70764 +
70765 + @Return E_OK on success; Error code otherwise.
70766 +
70767 + @Cautions Allowed only following FM_PCD_HashTableSet().
70768 + When configuring nextEngine = e_FM_PCD_CC, note that
70769 + p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
70770 + from the currently changed table.
70771 +*//***************************************************************************/
70772 +t_Error FM_PCD_HashTableModifyNextEngine(t_Handle h_HashTbl,
70773 + uint8_t keySize,
70774 + uint8_t *p_Key,
70775 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
70776 +
70777 +/**************************************************************************//**
70778 + @Function FM_PCD_HashTableModifyMissNextEngine
70779 +
70780 + @Description This routine modifies the next engine on key match miss.
70781 +
70782 + @Param[in] h_HashTbl A handle to a hash table
70783 + @Param[in] p_FmPcdCcNextEngineParams A structure for defining new next engine
70784 + parameters.
70785 +
70786 + @Return E_OK on success; Error code otherwise.
70787 +
70788 + @Cautions Allowed only following FM_PCD_HashTableSet().
70789 + When configuring nextEngine = e_FM_PCD_CC, note that
70790 + p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
70791 + from the currently changed table.
70792 +*//***************************************************************************/
70793 +t_Error FM_PCD_HashTableModifyMissNextEngine(t_Handle h_HashTbl,
70794 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
70795 +
70796 +/**************************************************************************//*
70797 + @Function FM_PCD_HashTableGetMissNextEngine
70798 +
70799 + @Description Gets NextEngine in case of key match miss.
70800 +
70801 + @Param[in] h_HashTbl A handle to a hash table
70802 + @Param[out] p_FmPcdCcNextEngineParams Next engine parameters for the specified
70803 + hash table.
70804 +
70805 + @Return E_OK on success; Error code otherwise.
70806 +
70807 + @Cautions Allowed only following FM_PCD_HashTableSet().
70808 +*//***************************************************************************/
70809 +t_Error FM_PCD_HashTableGetMissNextEngine(t_Handle h_HashTbl,
70810 + t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
70811 +
70812 +/**************************************************************************//**
70813 + @Function FM_PCD_HashTableFindNGetKeyStatistics
70814 +
70815 + @Description This routine may be used to get statistics counters of specific key
70816 + in a hash table.
70817 +
70818 + If 'e_FM_PCD_CC_STATS_MODE_FRAME' and
70819 + 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node,
70820 + these counters reflect how many frames passed that were matched
70821 + this key; The total frames count will be returned in the counter
70822 + of the first range (as only one frame length range was defined).
70823 + If 'e_FM_PCD_CC_STATS_MODE_RMON' was set for this node, the total
70824 + frame count will be separated to frame length counters, based on
70825 + provided frame length ranges.
70826 + Note that this routine will identify the bucket of this key in
70827 + the hash table and will search the bucket to locate the index
70828 + of the required key based on received key parameters.
70829 +
70830 + @Param[in] h_HashTbl A handle to a hash table
70831 + @Param[in] keySize Size of the requested key
70832 + @Param[in] p_Key A pointer to the requested key
70833 + @Param[out] p_KeyStatistics Key statistics counters
70834 +
70835 + @Return The specific key statistics.
70836 +
70837 + @Cautions Allowed only following FM_PCD_HashTableSet().
70838 +*//***************************************************************************/
70839 +t_Error FM_PCD_HashTableFindNGetKeyStatistics(t_Handle h_HashTbl,
70840 + uint8_t keySize,
70841 + uint8_t *p_Key,
70842 + t_FmPcdCcKeyStatistics *p_KeyStatistics);
70843 +
70844 +/**************************************************************************//**
70845 + @Function FM_PCD_HashTableGetMissStatistics
70846 +
70847 + @Description This routine may be used to get statistics counters of 'miss'
70848 + entry of the a hash table.
70849 +
70850 + If 'e_FM_PCD_CC_STATS_MODE_FRAME' and
70851 + 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node,
70852 + these counters reflect how many frames were not matched to any
70853 + existing key and therefore passed through the miss entry;
70854 +
70855 + @Param[in] h_HashTbl A handle to a hash table
70856 + @Param[out] p_MissStatistics Statistics counters for 'miss'
70857 +
70858 + @Return The statistics for 'miss'.
70859 +
70860 + @Cautions Allowed only following FM_PCD_HashTableSet().
70861 +*//***************************************************************************/
70862 +t_Error FM_PCD_HashTableGetMissStatistics(t_Handle h_HashTbl,
70863 + t_FmPcdCcKeyStatistics *p_MissStatistics);
70864 +
70865 +/**************************************************************************//**
70866 + @Function FM_PCD_ManipNodeSet
70867 +
70868 + @Description This routine should be called for defining a manipulation
70869 + node. A manipulation node must be defined before the CC node
70870 + that precedes it.
70871 +
70872 + @Param[in] h_FmPcd FM PCD module descriptor.
70873 + @Param[in] p_FmPcdManipParams A structure of parameters defining the manipulation
70874 +
70875 + @Return A handle to the initialized object on success; NULL code otherwise.
70876 +
70877 + @Cautions Allowed only following FM_PCD_Init().
70878 +*//***************************************************************************/
70879 +t_Handle FM_PCD_ManipNodeSet(t_Handle h_FmPcd, t_FmPcdManipParams *p_FmPcdManipParams);
70880 +
70881 +/**************************************************************************//**
70882 + @Function FM_PCD_ManipNodeDelete
70883 +
70884 + @Description Delete an existing manipulation node.
70885 +
70886 + @Param[in] h_ManipNode A handle to a manipulation node.
70887 +
70888 + @Return E_OK on success; Error code otherwise.
70889 +
70890 + @Cautions Allowed only following FM_PCD_ManipNodeSet().
70891 +*//***************************************************************************/
70892 +t_Error FM_PCD_ManipNodeDelete(t_Handle h_ManipNode);
70893 +
70894 +/**************************************************************************//**
70895 + @Function FM_PCD_ManipGetStatistics
70896 +
70897 + @Description Retrieve the manipulation statistics.
70898 +
70899 + @Param[in] h_ManipNode A handle to a manipulation node.
70900 + @Param[out] p_FmPcdManipStats A structure for retrieving the manipulation statistics
70901 +
70902 + @Return E_OK on success; Error code otherwise.
70903 +
70904 + @Cautions Allowed only following FM_PCD_ManipNodeSet().
70905 +*//***************************************************************************/
70906 +t_Error FM_PCD_ManipGetStatistics(t_Handle h_ManipNode, t_FmPcdManipStats *p_FmPcdManipStats);
70907 +
70908 +/**************************************************************************//**
70909 + @Function FM_PCD_ManipNodeReplace
70910 +
70911 + @Description Change existing manipulation node to be according to new requirement.
70912 +
70913 + @Param[in] h_ManipNode A handle to a manipulation node.
70914 + @Param[out] p_ManipParams A structure of parameters defining the change requirement
70915 +
70916 + @Return E_OK on success; Error code otherwise.
70917 +
70918 + @Cautions Allowed only following FM_PCD_ManipNodeSet().
70919 +*//***************************************************************************/
70920 +t_Error FM_PCD_ManipNodeReplace(t_Handle h_ManipNode, t_FmPcdManipParams *p_ManipParams);
70921 +
70922 +#if (DPAA_VERSION >= 11)
70923 +/**************************************************************************//**
70924 + @Function FM_PCD_FrmReplicSetGroup
70925 +
70926 + @Description Initialize a Frame Replicator group.
70927 +
70928 + @Param[in] h_FmPcd FM PCD module descriptor.
70929 + @Param[in] p_FrmReplicGroupParam A structure of parameters for the initialization of
70930 + the frame replicator group.
70931 +
70932 + @Return A handle to the initialized object on success; NULL code otherwise.
70933 +
70934 + @Cautions Allowed only following FM_PCD_Init().
70935 +*//***************************************************************************/
70936 +t_Handle FM_PCD_FrmReplicSetGroup(t_Handle h_FmPcd, t_FmPcdFrmReplicGroupParams *p_FrmReplicGroupParam);
70937 +
70938 +/**************************************************************************//**
70939 + @Function FM_PCD_FrmReplicDeleteGroup
70940 +
70941 + @Description Delete a Frame Replicator group.
70942 +
70943 + @Param[in] h_FrmReplicGroup A handle to the frame replicator group.
70944 +
70945 + @Return E_OK on success; Error code otherwise.
70946 +
70947 + @Cautions Allowed only following FM_PCD_FrmReplicSetGroup().
70948 +*//***************************************************************************/
70949 +t_Error FM_PCD_FrmReplicDeleteGroup(t_Handle h_FrmReplicGroup);
70950 +
70951 +/**************************************************************************//**
70952 + @Function FM_PCD_FrmReplicAddMember
70953 +
70954 + @Description Add the member in the index defined by the memberIndex.
70955 +
70956 + @Param[in] h_FrmReplicGroup A handle to the frame replicator group.
70957 + @Param[in] memberIndex member index for adding.
70958 + @Param[in] p_MemberParams A pointer to the new member parameters.
70959 +
70960 + @Return E_OK on success; Error code otherwise.
70961 +
70962 + @Cautions Allowed only following FM_PCD_FrmReplicSetGroup() of this group.
70963 +*//***************************************************************************/
70964 +t_Error FM_PCD_FrmReplicAddMember(t_Handle h_FrmReplicGroup,
70965 + uint16_t memberIndex,
70966 + t_FmPcdCcNextEngineParams *p_MemberParams);
70967 +
70968 +/**************************************************************************//**
70969 + @Function FM_PCD_FrmReplicRemoveMember
70970 +
70971 + @Description Remove the member defined by the index from the relevant group.
70972 +
70973 + @Param[in] h_FrmReplicGroup A handle to the frame replicator group.
70974 + @Param[in] memberIndex member index for removing.
70975 +
70976 + @Return E_OK on success; Error code otherwise.
70977 +
70978 + @Cautions Allowed only following FM_PCD_FrmReplicSetGroup() of this group.
70979 +*//***************************************************************************/
70980 +t_Error FM_PCD_FrmReplicRemoveMember(t_Handle h_FrmReplicGroup,
70981 + uint16_t memberIndex);
70982 +#endif /* (DPAA_VERSION >= 11) */
70983 +
70984 +#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
70985 +/**************************************************************************//**
70986 + @Function FM_PCD_StatisticsSetNode
70987 +
70988 + @Description This routine should be called for defining a statistics node.
70989 +
70990 + @Param[in] h_FmPcd FM PCD module descriptor.
70991 + @Param[in] p_FmPcdstatsParams A structure of parameters defining the statistics
70992 +
70993 + @Return A handle to the initialized object on success; NULL code otherwise.
70994 +
70995 + @Cautions Allowed only following FM_PCD_Init().
70996 +*//***************************************************************************/
70997 +t_Handle FM_PCD_StatisticsSetNode(t_Handle h_FmPcd, t_FmPcdStatsParams *p_FmPcdstatsParams);
70998 +#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
70999 +
71000 +/** @} */ /* end of FM_PCD_Runtime_build_grp group */
71001 +/** @} */ /* end of FM_PCD_Runtime_grp group */
71002 +/** @} */ /* end of FM_PCD_grp group */
71003 +/** @} */ /* end of FM_grp group */
71004 +
71005 +
71006 +#ifdef NCSW_BACKWARD_COMPATIBLE_API
71007 +#define FM_PCD_MAX_NUM_OF_INTERCHANGABLE_HDRS FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS
71008 +#define e_FM_PCD_MANIP_ONE_WAYS_HASH e_FM_PCD_MANIP_ONE_WAY_HASH
71009 +#define e_FM_PCD_MANIP_TOW_WAYS_HASH e_FM_PCD_MANIP_TWO_WAYS_HASH
71010 +
71011 +#define e_FM_PCD_MANIP_FRAGMENT_PACKECT e_FM_PCD_MANIP_FRAGMENT_PACKET /* Feb13 */
71012 +
71013 +#define FM_PCD_SetNetEnvCharacteristics(_pcd, _params) \
71014 + FM_PCD_NetEnvCharacteristicsSet(_pcd, _params)
71015 +#define FM_PCD_KgSetScheme(_pcd, _params) FM_PCD_KgSchemeSet(_pcd, _params)
71016 +#define FM_PCD_CcBuildTree(_pcd, _params) FM_PCD_CcRootBuild(_pcd, _params)
71017 +#define FM_PCD_CcSetNode(_pcd, _params) FM_PCD_MatchTableSet(_pcd, _params)
71018 +#define FM_PCD_PlcrSetProfile(_pcd, _params) FM_PCD_PlcrProfileSet(_pcd, _params)
71019 +#define FM_PCD_ManipSetNode(_pcd, _params) FM_PCD_ManipNodeSet(_pcd, _params)
71020 +
71021 +#define FM_PCD_DeleteNetEnvCharacteristics(_pcd, ...) \
71022 + FM_PCD_NetEnvCharacteristicsDelete(__VA_ARGS__)
71023 +#define FM_PCD_KgDeleteScheme(_pcd, ...) \
71024 + FM_PCD_KgSchemeDelete(__VA_ARGS__)
71025 +#define FM_PCD_KgGetSchemeCounter(_pcd, ...) \
71026 + FM_PCD_KgSchemeGetCounter(__VA_ARGS__)
71027 +#define FM_PCD_KgSetSchemeCounter(_pcd, ...) \
71028 + FM_PCD_KgSchemeSetCounter(__VA_ARGS__)
71029 +#define FM_PCD_PlcrDeleteProfile(_pcd, ...) \
71030 + FM_PCD_PlcrProfileDelete(__VA_ARGS__)
71031 +#define FM_PCD_PlcrGetProfileCounter(_pcd, ...) \
71032 + FM_PCD_PlcrProfileGetCounter(__VA_ARGS__)
71033 +#define FM_PCD_PlcrSetProfileCounter(_pcd, ...) \
71034 + FM_PCD_PlcrProfileSetCounter(__VA_ARGS__)
71035 +#define FM_PCD_CcDeleteTree(_pcd, ...) \
71036 + FM_PCD_CcRootDelete(__VA_ARGS__)
71037 +#define FM_PCD_CcTreeModifyNextEngine(_pcd, ...) \
71038 + FM_PCD_CcRootModifyNextEngine(__VA_ARGS__)
71039 +#define FM_PCD_CcDeleteNode(_pcd, ...) \
71040 + FM_PCD_MatchTableDelete(__VA_ARGS__)
71041 +#define FM_PCD_CcNodeModifyMissNextEngine(_pcd, ...) \
71042 + FM_PCD_MatchTableModifyMissNextEngine(__VA_ARGS__)
71043 +#define FM_PCD_CcNodeRemoveKey(_pcd, ...) \
71044 + FM_PCD_MatchTableRemoveKey(__VA_ARGS__)
71045 +#define FM_PCD_CcNodeAddKey(_pcd, ...) \
71046 + FM_PCD_MatchTableAddKey(__VA_ARGS__)
71047 +#define FM_PCD_CcNodeModifyNextEngine(_pcd, ...) \
71048 + FM_PCD_MatchTableModifyNextEngine(__VA_ARGS__)
71049 +#define FM_PCD_CcNodeModifyKeyAndNextEngine(_pcd, ...) \
71050 + FM_PCD_MatchTableModifyKeyAndNextEngine(__VA_ARGS__)
71051 +#define FM_PCD_CcNodeModifyKey(_pcd, ...) \
71052 + FM_PCD_MatchTableModifyKey(__VA_ARGS__)
71053 +#define FM_PCD_CcNodeFindNRemoveKey(_pcd, ...) \
71054 + FM_PCD_MatchTableFindNRemoveKey(__VA_ARGS__)
71055 +#define FM_PCD_CcNodeFindNModifyNextEngine(_pcd, ...) \
71056 + FM_PCD_MatchTableFindNModifyNextEngine(__VA_ARGS__)
71057 +#define FM_PCD_CcNodeFindNModifyKeyAndNextEngine(_pcd, ...) \
71058 + FM_PCD_MatchTableFindNModifyKeyAndNextEngine(__VA_ARGS__)
71059 +#define FM_PCD_CcNodeFindNModifyKey(_pcd, ...) \
71060 + FM_PCD_MatchTableFindNModifyKey(__VA_ARGS__)
71061 +#define FM_PCD_CcIndexedHashNodeGetBucket(_pcd, ...) \
71062 + FM_PCD_MatchTableGetIndexedHashBucket(__VA_ARGS__)
71063 +#define FM_PCD_CcNodeGetNextEngine(_pcd, ...) \
71064 + FM_PCD_MatchTableGetNextEngine(__VA_ARGS__)
71065 +#define FM_PCD_CcNodeGetKeyCounter(_pcd, ...) \
71066 + FM_PCD_MatchTableGetKeyCounter(__VA_ARGS__)
71067 +#define FM_PCD_ManipDeleteNode(_pcd, ...) \
71068 + FM_PCD_ManipNodeDelete(__VA_ARGS__)
71069 +#endif /* NCSW_BACKWARD_COMPATIBLE_API */
71070 +
71071 +
71072 +#endif /* __FM_PCD_EXT */
71073 --- /dev/null
71074 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_port_ext.h
71075 @@ -0,0 +1,2608 @@
71076 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc.
71077 + * All rights reserved.
71078 + *
71079 + * Redistribution and use in source and binary forms, with or without
71080 + * modification, are permitted provided that the following conditions are met:
71081 + * * Redistributions of source code must retain the above copyright
71082 + * notice, this list of conditions and the following disclaimer.
71083 + * * Redistributions in binary form must reproduce the above copyright
71084 + * notice, this list of conditions and the following disclaimer in the
71085 + * documentation and/or other materials provided with the distribution.
71086 + * * Neither the name of Freescale Semiconductor nor the
71087 + * names of its contributors may be used to endorse or promote products
71088 + * derived from this software without specific prior written permission.
71089 + *
71090 + *
71091 + * ALTERNATIVELY, this software may be distributed under the terms of the
71092 + * GNU General Public License ("GPL") as published by the Free Software
71093 + * Foundation, either version 2 of that License or (at your option) any
71094 + * later version.
71095 + *
71096 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
71097 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
71098 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
71099 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
71100 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
71101 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
71102 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
71103 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
71104 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
71105 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
71106 + */
71107 +
71108 +
71109 +/**************************************************************************//**
71110 + @File fm_port_ext.h
71111 +
71112 + @Description FM-Port Application Programming Interface.
71113 +*//***************************************************************************/
71114 +#ifndef __FM_PORT_EXT
71115 +#define __FM_PORT_EXT
71116 +
71117 +#include "error_ext.h"
71118 +#include "std_ext.h"
71119 +#include "fm_pcd_ext.h"
71120 +#include "fm_ext.h"
71121 +#include "net_ext.h"
71122 +
71123 +
71124 +/**************************************************************************//**
71125 +
71126 + @Group FM_grp Frame Manager API
71127 +
71128 + @Description FM API functions, definitions and enums
71129 +
71130 + @{
71131 +*//***************************************************************************/
71132 +
71133 +/**************************************************************************//**
71134 + @Group FM_PORT_grp FM Port
71135 +
71136 + @Description FM Port API
71137 +
71138 + The FM uses a general module called "port" to represent a Tx port
71139 + (MAC), an Rx port (MAC) or Offline Parsing port.
71140 + The number of ports in an FM varies between SOCs.
71141 + The SW driver manages these ports as sub-modules of the FM, i.e.
71142 + after an FM is initialized, its ports may be initialized and
71143 + operated upon.
71144 +
71145 + The port is initialized aware of its type, but other functions on
71146 + a port may be indifferent to its type. When necessary, the driver
71147 + verifies coherence and returns error if applicable.
71148 +
71149 + On initialization, user specifies the port type and it's index
71150 + (relative to the port's type) - always starting at 0.
71151 +
71152 + @{
71153 +*//***************************************************************************/
71154 +
71155 +/**************************************************************************//**
71156 + @Description An enum for defining port PCD modes.
71157 + This enum defines the superset of PCD engines support - i.e. not
71158 + all engines have to be used, but all have to be enabled. The real
71159 + flow of a specific frame depends on the PCD configuration and the
71160 + frame headers and payload.
71161 + Note: the first engine and the first engine after the parser (if
71162 + exists) should be in order, the order is important as it will
71163 + define the flow of the port. However, as for the rest engines
71164 + (the ones that follows), the order is not important anymore as
71165 + it is defined by the PCD graph itself.
71166 +*//***************************************************************************/
71167 +typedef enum e_FmPortPcdSupport {
71168 + e_FM_PORT_PCD_SUPPORT_NONE = 0 /**< BMI to BMI, PCD is not used */
71169 + , e_FM_PORT_PCD_SUPPORT_PRS_ONLY /**< Use only Parser */
71170 + , e_FM_PORT_PCD_SUPPORT_PLCR_ONLY /**< Use only Policer */
71171 + , e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR /**< Use Parser and Policer */
71172 + , e_FM_PORT_PCD_SUPPORT_PRS_AND_KG /**< Use Parser and Keygen */
71173 + , e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC /**< Use Parser, Keygen and Coarse Classification */
71174 + , e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR
71175 + /**< Use all PCD engines */
71176 + , e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR /**< Use Parser, Keygen and Policer */
71177 + , e_FM_PORT_PCD_SUPPORT_PRS_AND_CC /**< Use Parser and Coarse Classification */
71178 + , e_FM_PORT_PCD_SUPPORT_PRS_AND_CC_AND_PLCR /**< Use Parser and Coarse Classification and Policer */
71179 + , e_FM_PORT_PCD_SUPPORT_CC_ONLY /**< Use only Coarse Classification */
71180 +#ifdef FM_CAPWAP_SUPPORT
71181 + , e_FM_PORT_PCD_SUPPORT_CC_AND_KG /**< Use Coarse Classification,and Keygen */
71182 + , e_FM_PORT_PCD_SUPPORT_CC_AND_KG_AND_PLCR /**< Use Coarse Classification, Keygen and Policer */
71183 +#endif /* FM_CAPWAP_SUPPORT */
71184 +} e_FmPortPcdSupport;
71185 +
71186 +/**************************************************************************//**
71187 + @Description Port interrupts
71188 +*//***************************************************************************/
71189 +typedef enum e_FmPortExceptions {
71190 + e_FM_PORT_EXCEPTION_IM_BUSY /**< Independent-Mode Rx-BUSY */
71191 +} e_FmPortExceptions;
71192 +
71193 +
71194 +/**************************************************************************//**
71195 + @Collection General FM Port defines
71196 +*//***************************************************************************/
71197 +#define FM_PORT_PRS_RESULT_NUM_OF_WORDS 8 /**< Number of 4 bytes words in parser result */
71198 +/* @} */
71199 +
71200 +/**************************************************************************//**
71201 + @Collection FM Frame error
71202 +*//***************************************************************************/
71203 +typedef uint32_t fmPortFrameErrSelect_t; /**< typedef for defining Frame Descriptor errors */
71204 +
71205 +#define FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT FM_FD_ERR_UNSUPPORTED_FORMAT /**< Not for Rx-Port! Unsupported Format */
71206 +#define FM_PORT_FRM_ERR_LENGTH FM_FD_ERR_LENGTH /**< Not for Rx-Port! Length Error */
71207 +#define FM_PORT_FRM_ERR_DMA FM_FD_ERR_DMA /**< DMA Data error */
71208 +#define FM_PORT_FRM_ERR_NON_FM FM_FD_RX_STATUS_ERR_NON_FM /**< non Frame-Manager error; probably come from SEC that
71209 + was chained to FM */
71210 +
71211 +#define FM_PORT_FRM_ERR_IPRE (FM_FD_ERR_IPR & ~FM_FD_IPR) /**< IPR error */
71212 +#define FM_PORT_FRM_ERR_IPR_NCSP (FM_FD_ERR_IPR_NCSP & ~FM_FD_IPR) /**< IPR non-consistent-sp */
71213 +
71214 +#define FM_PORT_FRM_ERR_IPFE 0 /**< Obsolete; will be removed in the future */
71215 +
71216 +#ifdef FM_CAPWAP_SUPPORT
71217 +#define FM_PORT_FRM_ERR_CRE FM_FD_ERR_CRE
71218 +#define FM_PORT_FRM_ERR_CHE FM_FD_ERR_CHE
71219 +#endif /* FM_CAPWAP_SUPPORT */
71220 +
71221 +#define FM_PORT_FRM_ERR_PHYSICAL FM_FD_ERR_PHYSICAL /**< Rx FIFO overflow, FCS error, code error, running disparity
71222 + error (SGMII and TBI modes), FIFO parity error. PHY
71223 + Sequence error, PHY error control character detected. */
71224 +#define FM_PORT_FRM_ERR_SIZE FM_FD_ERR_SIZE /**< Frame too long OR Frame size exceeds max_length_frame */
71225 +#define FM_PORT_FRM_ERR_CLS_DISCARD FM_FD_ERR_CLS_DISCARD /**< indicates a classifier "drop" operation */
71226 +#define FM_PORT_FRM_ERR_EXTRACTION FM_FD_ERR_EXTRACTION /**< Extract Out of Frame */
71227 +#define FM_PORT_FRM_ERR_NO_SCHEME FM_FD_ERR_NO_SCHEME /**< No Scheme Selected */
71228 +#define FM_PORT_FRM_ERR_KEYSIZE_OVERFLOW FM_FD_ERR_KEYSIZE_OVERFLOW /**< Keysize Overflow */
71229 +#define FM_PORT_FRM_ERR_COLOR_RED FM_FD_ERR_COLOR_RED /**< Frame color is red */
71230 +#define FM_PORT_FRM_ERR_COLOR_YELLOW FM_FD_ERR_COLOR_YELLOW /**< Frame color is yellow */
71231 +#define FM_PORT_FRM_ERR_ILL_PLCR FM_FD_ERR_ILL_PLCR /**< Illegal Policer Profile selected */
71232 +#define FM_PORT_FRM_ERR_PLCR_FRAME_LEN FM_FD_ERR_PLCR_FRAME_LEN /**< Policer frame length error */
71233 +#define FM_PORT_FRM_ERR_PRS_TIMEOUT FM_FD_ERR_PRS_TIMEOUT /**< Parser Time out Exceed */
71234 +#define FM_PORT_FRM_ERR_PRS_ILL_INSTRUCT FM_FD_ERR_PRS_ILL_INSTRUCT /**< Invalid Soft Parser instruction */
71235 +#define FM_PORT_FRM_ERR_PRS_HDR_ERR FM_FD_ERR_PRS_HDR_ERR /**< Header error was identified during parsing */
71236 +#define FM_PORT_FRM_ERR_BLOCK_LIMIT_EXCEEDED FM_FD_ERR_BLOCK_LIMIT_EXCEEDED /**< Frame parsed beyind 256 first bytes */
71237 +#define FM_PORT_FRM_ERR_PROCESS_TIMEOUT 0x00000001 /**< FPM Frame Processing Timeout Exceeded */
71238 +/* @} */
71239 +
71240 +
71241 +
71242 +/**************************************************************************//**
71243 + @Group FM_PORT_init_grp FM Port Initialization Unit
71244 +
71245 + @Description FM Port Initialization Unit
71246 +
71247 + @{
71248 +*//***************************************************************************/
71249 +
71250 +/**************************************************************************//**
71251 + @Description Exceptions user callback routine, will be called upon an
71252 + exception passing the exception identification.
71253 +
71254 + @Param[in] h_App - User's application descriptor.
71255 + @Param[in] exception - The exception.
71256 + *//***************************************************************************/
71257 +typedef void (t_FmPortExceptionCallback) (t_Handle h_App, e_FmPortExceptions exception);
71258 +
71259 +/**************************************************************************//**
71260 + @Description User callback function called by driver with received data.
71261 +
71262 + User provides this function. Driver invokes it.
71263 +
71264 + @Param[in] h_App Application's handle originally specified to
71265 + the API Config function
71266 + @Param[in] p_Data A pointer to data received
71267 + @Param[in] length length of received data
71268 + @Param[in] status receive status and errors
71269 + @Param[in] position position of buffer in frame
71270 + @Param[in] h_BufContext A handle of the user acossiated with this buffer
71271 +
71272 + @Retval e_RX_STORE_RESPONSE_CONTINUE - order the driver to continue Rx
71273 + operation for all ready data.
71274 + @Retval e_RX_STORE_RESPONSE_PAUSE - order the driver to stop Rx operation.
71275 +*//***************************************************************************/
71276 +typedef e_RxStoreResponse (t_FmPortImRxStoreCallback) (t_Handle h_App,
71277 + uint8_t *p_Data,
71278 + uint16_t length,
71279 + uint16_t status,
71280 + uint8_t position,
71281 + t_Handle h_BufContext);
71282 +
71283 +/**************************************************************************//**
71284 + @Description User callback function called by driver when transmit completed.
71285 +
71286 + User provides this function. Driver invokes it.
71287 +
71288 + @Param[in] h_App Application's handle originally specified to
71289 + the API Config function
71290 + @Param[in] p_Data A pointer to data received
71291 + @Param[in] status transmit status and errors
71292 + @Param[in] lastBuffer is last buffer in frame
71293 + @Param[in] h_BufContext A handle of the user acossiated with this buffer
71294 + *//***************************************************************************/
71295 +typedef void (t_FmPortImTxConfCallback) (t_Handle h_App,
71296 + uint8_t *p_Data,
71297 + uint16_t status,
71298 + t_Handle h_BufContext);
71299 +
71300 +/**************************************************************************//**
71301 + @Description A structure for additional Rx port parameters
71302 +*//***************************************************************************/
71303 +typedef struct t_FmPortRxParams {
71304 + uint32_t errFqid; /**< Error Queue Id. */
71305 + uint32_t dfltFqid; /**< Default Queue Id. */
71306 + uint16_t liodnOffset; /**< Port's LIODN offset. */
71307 + t_FmExtPools extBufPools; /**< Which external buffer pools are used
71308 + (up to FM_PORT_MAX_NUM_OF_EXT_POOLS), and their sizes. */
71309 +} t_FmPortRxParams;
71310 +
71311 +/**************************************************************************//**
71312 + @Description A structure for additional non-Rx port parameters
71313 +*//***************************************************************************/
71314 +typedef struct t_FmPortNonRxParams {
71315 + uint32_t errFqid; /**< Error Queue Id. */
71316 + uint32_t dfltFqid; /**< For Tx - Default Confirmation queue,
71317 + 0 means no Tx confirmation for processed
71318 + frames. For OP port - default Rx queue. */
71319 + uint32_t qmChannel; /**< QM-channel dedicated to this port; will be used
71320 + by the FM for dequeue. */
71321 +} t_FmPortNonRxParams;
71322 +
71323 +/**************************************************************************//**
71324 + @Description A structure for additional Rx port parameters
71325 +*//***************************************************************************/
71326 +typedef struct t_FmPortImRxTxParams {
71327 + t_Handle h_FmMuram; /**< A handle of the FM-MURAM partition */
71328 + uint16_t liodnOffset; /**< For Rx ports only. Port's LIODN Offset. */
71329 + uint8_t dataMemId; /**< Memory partition ID for data buffers */
71330 + uint32_t dataMemAttributes; /**< Memory attributes for data buffers */
71331 + t_BufferPoolInfo rxPoolParams; /**< For Rx ports only. */
71332 + t_FmPortImRxStoreCallback *f_RxStore; /**< For Rx ports only. */
71333 + t_FmPortImTxConfCallback *f_TxConf; /**< For Tx ports only. */
71334 +} t_FmPortImRxTxParams;
71335 +
71336 +/**************************************************************************//**
71337 + @Description A union for additional parameters depending on port type
71338 +*//***************************************************************************/
71339 +typedef union u_FmPortSpecificParams {
71340 + t_FmPortImRxTxParams imRxTxParams; /**< Rx/Tx Independent-Mode port parameter structure */
71341 + t_FmPortRxParams rxParams; /**< Rx port parameters structure */
71342 + t_FmPortNonRxParams nonRxParams; /**< Non-Rx port parameters structure */
71343 +} u_FmPortSpecificParams;
71344 +
71345 +/**************************************************************************//**
71346 + @Description A structure representing FM initialization parameters
71347 +*//***************************************************************************/
71348 +typedef struct t_FmPortParams {
71349 + uintptr_t baseAddr; /**< Virtual Address of memory mapped FM Port registers.*/
71350 + t_Handle h_Fm; /**< A handle to the FM object this port related to */
71351 + e_FmPortType portType; /**< Port type */
71352 + uint8_t portId; /**< Port Id - relative to type;
71353 + NOTE: When configuring Offline Parsing port for
71354 + FMANv3 devices (DPAA_VERSION 11 and higher),
71355 + it is highly recommended NOT to use portId=0 due to lack
71356 + of HW resources on portId=0. */
71357 + bool independentModeEnable;
71358 + /**< This port is Independent-Mode - Used for Rx/Tx ports only! */
71359 + uint16_t liodnBase; /**< Irrelevant for P4080 rev 1. LIODN base for this port, to be
71360 + used together with LIODN offset. */
71361 + u_FmPortSpecificParams specificParams; /**< Additional parameters depending on port
71362 + type. */
71363 +
71364 + t_FmPortExceptionCallback *f_Exception; /**< Relevant for IM only Callback routine to be called on BUSY exception */
71365 + t_Handle h_App; /**< A handle to an application layer object; This handle will
71366 + be passed by the driver upon calling the above callbacks */
71367 +} t_FmPortParams;
71368 +
71369 +
71370 +/**************************************************************************//**
71371 + @Function FM_PORT_Config
71372 +
71373 + @Description Creates a descriptor for the FM PORT module.
71374 +
71375 + The routine returns a handle (descriptor) to the FM PORT object.
71376 + This descriptor must be passed as first parameter to all other
71377 + FM PORT function calls.
71378 +
71379 + No actual initialization or configuration of FM hardware is
71380 + done by this routine.
71381 +
71382 + @Param[in] p_FmPortParams - Pointer to data structure of parameters
71383 +
71384 + @Retval Handle to FM object, or NULL for Failure.
71385 +*//***************************************************************************/
71386 +t_Handle FM_PORT_Config(t_FmPortParams *p_FmPortParams);
71387 +
71388 +/**************************************************************************//**
71389 + @Function FM_PORT_Init
71390 +
71391 + @Description Initializes the FM PORT module by defining the software structure
71392 + and configuring the hardware registers.
71393 +
71394 + @Param[in] h_FmPort - FM PORT module descriptor
71395 +
71396 + @Return E_OK on success; Error code otherwise.
71397 +*//***************************************************************************/
71398 +t_Error FM_PORT_Init(t_Handle h_FmPort);
71399 +
71400 +/**************************************************************************//**
71401 + @Function FM_PORT_Free
71402 +
71403 + @Description Frees all resources that were assigned to FM PORT module.
71404 +
71405 + Calling this routine invalidates the descriptor.
71406 +
71407 + @Param[in] h_FmPort - FM PORT module descriptor
71408 +
71409 + @Return E_OK on success; Error code otherwise.
71410 +*//***************************************************************************/
71411 +t_Error FM_PORT_Free(t_Handle h_FmPort);
71412 +
71413 +
71414 +/**************************************************************************//**
71415 + @Group FM_PORT_advanced_init_grp FM Port Advanced Configuration Unit
71416 +
71417 + @Description Configuration functions used to change default values.
71418 +
71419 + @{
71420 +*//***************************************************************************/
71421 +
71422 +/**************************************************************************//**
71423 + @Description enum for defining QM frame dequeue
71424 +*//***************************************************************************/
71425 +typedef enum e_FmPortDeqType {
71426 + e_FM_PORT_DEQ_TYPE1, /**< Dequeue from the SP channel - with priority precedence,
71427 + and Intra-Class Scheduling respected. */
71428 + e_FM_PORT_DEQ_TYPE2, /**< Dequeue from the SP channel - with active FQ precedence,
71429 + and Intra-Class Scheduling respected. */
71430 + e_FM_PORT_DEQ_TYPE3 /**< Dequeue from the SP channel - with active FQ precedence,
71431 + and override Intra-Class Scheduling */
71432 +} e_FmPortDeqType;
71433 +
71434 +/**************************************************************************//**
71435 + @Description enum for defining QM frame dequeue
71436 +*//***************************************************************************/
71437 +typedef enum e_FmPortDeqPrefetchOption {
71438 + e_FM_PORT_DEQ_NO_PREFETCH, /**< QMI preforms a dequeue action for a single frame
71439 + only when a dedicated portID Tnum is waiting. */
71440 + e_FM_PORT_DEQ_PARTIAL_PREFETCH, /**< QMI preforms a dequeue action for 3 frames when
71441 + one dedicated portId tnum is waiting. */
71442 + e_FM_PORT_DEQ_FULL_PREFETCH /**< QMI preforms a dequeue action for 3 frames when
71443 + no dedicated portId tnums are waiting. */
71444 +
71445 +} e_FmPortDeqPrefetchOption;
71446 +
71447 +/**************************************************************************//**
71448 + @Description enum for defining port default color
71449 +*//***************************************************************************/
71450 +typedef enum e_FmPortColor {
71451 + e_FM_PORT_COLOR_GREEN, /**< Default port color is green */
71452 + e_FM_PORT_COLOR_YELLOW, /**< Default port color is yellow */
71453 + e_FM_PORT_COLOR_RED, /**< Default port color is red */
71454 + e_FM_PORT_COLOR_OVERRIDE /**< Ignore color */
71455 +} e_FmPortColor;
71456 +
71457 +/**************************************************************************//**
71458 + @Description A structure for defining Dual Tx rate limiting scale
71459 +*//***************************************************************************/
71460 +typedef enum e_FmPortDualRateLimiterScaleDown {
71461 + e_FM_PORT_DUAL_RATE_LIMITER_NONE = 0, /**< Use only single rate limiter */
71462 + e_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_2, /**< Divide high rate limiter by 2 */
71463 + e_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_4, /**< Divide high rate limiter by 4 */
71464 + e_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_8 /**< Divide high rate limiter by 8 */
71465 +} e_FmPortDualRateLimiterScaleDown;
71466 +
71467 +
71468 +/**************************************************************************//**
71469 + @Description A structure for defining FM port resources
71470 +*//***************************************************************************/
71471 +typedef struct t_FmPortRsrc {
71472 + uint32_t num; /**< Committed required resource */
71473 + uint32_t extra; /**< Extra (not committed) required resource */
71474 +} t_FmPortRsrc;
71475 +
71476 +/**************************************************************************//**
71477 + @Description A structure for defining observed pool depletion
71478 +*//***************************************************************************/
71479 +typedef struct t_FmPortObservedBufPoolDepletion {
71480 + t_FmBufPoolDepletion poolDepletionParams;/**< parameters to define pool depletion */
71481 + t_FmExtPools poolsParams; /**< Which external buffer pools are observed
71482 + (up to FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS),
71483 + and their sizes. */
71484 +} t_FmPortObservedBufPoolDepletion;
71485 +
71486 +/**************************************************************************//**
71487 + @Description A structure for defining Tx rate limiting
71488 +*//***************************************************************************/
71489 +typedef struct t_FmPortRateLimit {
71490 + uint16_t maxBurstSize; /**< in KBytes for Tx ports, in frames
71491 + for OP ports. (note that
71492 + for early chips burst size is
71493 + rounded up to a multiply of 1000 frames).*/
71494 + uint32_t rateLimit; /**< in Kb/sec for Tx ports, in frame/sec for
71495 + OP ports. Rate limit refers to
71496 + data rate (rather than line rate). */
71497 + e_FmPortDualRateLimiterScaleDown rateLimitDivider; /**< For OP ports only. Not-valid
71498 + for some earlier chip revisions */
71499 +} t_FmPortRateLimit;
71500 +
71501 +/**************************************************************************//**
71502 + @Description A structure for defining the parameters of
71503 + the Rx port performance counters
71504 +*//***************************************************************************/
71505 +typedef struct t_FmPortPerformanceCnt {
71506 + uint8_t taskCompVal; /**< Task compare value */
71507 + uint8_t queueCompVal; /**< Rx queue/Tx confirm queue compare
71508 + value (unused for H/O) */
71509 + uint8_t dmaCompVal; /**< Dma compare value */
71510 + uint32_t fifoCompVal; /**< Fifo compare value (in bytes) */
71511 +} t_FmPortPerformanceCnt;
71512 +
71513 +
71514 +/**************************************************************************//**
71515 + @Description A structure for defining the sizes of the Deep Sleep
71516 + the Auto Response tables
71517 +*//***************************************************************************/
71518 +typedef struct t_FmPortDsarTablesSizes
71519 +{
71520 + uint16_t maxNumOfArpEntries;
71521 + uint16_t maxNumOfEchoIpv4Entries;
71522 + uint16_t maxNumOfNdpEntries;
71523 + uint16_t maxNumOfEchoIpv6Entries;
71524 + uint16_t maxNumOfSnmpIPV4Entries;
71525 + uint16_t maxNumOfSnmpIPV6Entries;
71526 + uint16_t maxNumOfSnmpOidEntries;
71527 + uint16_t maxNumOfSnmpOidChar; /* total amount of character needed for the snmp table */
71528 +
71529 + uint16_t maxNumOfIpProtFiltering;
71530 + uint16_t maxNumOfTcpPortFiltering;
71531 + uint16_t maxNumOfUdpPortFiltering;
71532 +} t_FmPortDsarTablesSizes;
71533 +
71534 +
71535 +/**************************************************************************//**
71536 + @Function FM_PORT_ConfigDsarSupport
71537 +
71538 + @Description This function will allocate the amount of MURAM needed for
71539 + this max number of entries for Deep Sleep Auto Response.
71540 + it will calculate all needed MURAM for autoresponse including
71541 + necesary common stuff.
71542 +
71543 +
71544 + @Param[in] h_FmPort A handle to a FM Port module.
71545 + @Param[in] params A pointer to a structure containing the maximum
71546 + sizes of the auto response tables
71547 +
71548 + @Return E_OK on success; Error code otherwise.
71549 +
71550 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71551 +*//***************************************************************************/
71552 +t_Error FM_PORT_ConfigDsarSupport(t_Handle h_FmPortRx, t_FmPortDsarTablesSizes *params);
71553 +
71554 +/**************************************************************************//**
71555 + @Function FM_PORT_ConfigNumOfOpenDmas
71556 +
71557 + @Description Calling this routine changes the max number of open DMA's
71558 + available for this port. It changes this parameter in the
71559 + internal driver data base from its default configuration
71560 + [OP: 1]
71561 + [1G-RX, 1G-TX: 1 (+1)]
71562 + [10G-RX, 10G-TX: 8 (+8)]
71563 +
71564 + @Param[in] h_FmPort A handle to a FM Port module.
71565 + @Param[in] p_OpenDmas A pointer to a structure of parameters defining
71566 + the open DMA allocation.
71567 +
71568 + @Return E_OK on success; Error code otherwise.
71569 +
71570 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71571 +*//***************************************************************************/
71572 +t_Error FM_PORT_ConfigNumOfOpenDmas(t_Handle h_FmPort, t_FmPortRsrc *p_OpenDmas);
71573 +
71574 +/**************************************************************************//**
71575 + @Function FM_PORT_ConfigNumOfTasks
71576 +
71577 + @Description Calling this routine changes the max number of tasks
71578 + available for this port. It changes this parameter in the
71579 + internal driver data base from its default configuration
71580 + [OP: 1]
71581 + [1G-RX, 1G-TX: 3 (+2)]
71582 + [10G-RX, 10G-TX: 16 (+8)]
71583 +
71584 + @Param[in] h_FmPort A handle to a FM Port module.
71585 + @Param[in] p_NumOfTasks A pointer to a structure of parameters defining
71586 + the tasks allocation.
71587 +
71588 + @Return E_OK on success; Error code otherwise.
71589 +
71590 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71591 +*//***************************************************************************/
71592 +t_Error FM_PORT_ConfigNumOfTasks(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfTasks);
71593 +
71594 +/**************************************************************************//**
71595 + @Function FM_PORT_ConfigSizeOfFifo
71596 +
71597 + @Description Calling this routine changes the max FIFO size configured for this port.
71598 +
71599 + This function changes the internal driver data base from its
71600 + default configuration. Please refer to the driver's User Guide for
71601 + information on default FIFO sizes in the various devices.
71602 + [OP: 2KB]
71603 + [1G-RX, 1G-TX: 11KB]
71604 + [10G-RX, 10G-TX: 12KB]
71605 +
71606 + @Param[in] h_FmPort A handle to a FM Port module.
71607 + @Param[in] p_SizeOfFifo A pointer to a structure of parameters defining
71608 + the FIFO allocation.
71609 +
71610 + @Return E_OK on success; Error code otherwise.
71611 +
71612 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71613 +*//***************************************************************************/
71614 +t_Error FM_PORT_ConfigSizeOfFifo(t_Handle h_FmPort, t_FmPortRsrc *p_SizeOfFifo);
71615 +
71616 +/**************************************************************************//**
71617 + @Function FM_PORT_ConfigDeqHighPriority
71618 +
71619 + @Description Calling this routine changes the dequeue priority in the
71620 + internal driver data base from its default configuration
71621 + 1G: [DEFAULT_PORT_deqHighPriority_1G]
71622 + 10G: [DEFAULT_PORT_deqHighPriority_10G]
71623 +
71624 + May be used for Non-Rx ports only
71625 +
71626 + @Param[in] h_FmPort A handle to a FM Port module.
71627 + @Param[in] highPri TRUE to select high priority, FALSE for normal operation.
71628 +
71629 + @Return E_OK on success; Error code otherwise.
71630 +
71631 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71632 +*//***************************************************************************/
71633 +t_Error FM_PORT_ConfigDeqHighPriority(t_Handle h_FmPort, bool highPri);
71634 +
71635 +/**************************************************************************//**
71636 + @Function FM_PORT_ConfigDeqType
71637 +
71638 + @Description Calling this routine changes the dequeue type parameter in the
71639 + internal driver data base from its default configuration
71640 + [DEFAULT_PORT_deqType].
71641 +
71642 + May be used for Non-Rx ports only
71643 +
71644 + @Param[in] h_FmPort A handle to a FM Port module.
71645 + @Param[in] deqType According to QM definition.
71646 +
71647 + @Return E_OK on success; Error code otherwise.
71648 +
71649 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71650 +*//***************************************************************************/
71651 +t_Error FM_PORT_ConfigDeqType(t_Handle h_FmPort, e_FmPortDeqType deqType);
71652 +
71653 +/**************************************************************************//**
71654 + @Function FM_PORT_ConfigDeqPrefetchOption
71655 +
71656 + @Description Calling this routine changes the dequeue prefetch option parameter in the
71657 + internal driver data base from its default configuration
71658 + [DEFAULT_PORT_deqPrefetchOption]
71659 + Note: Available for some chips only
71660 +
71661 + May be used for Non-Rx ports only
71662 +
71663 + @Param[in] h_FmPort A handle to a FM Port module.
71664 + @Param[in] deqPrefetchOption New option
71665 +
71666 + @Return E_OK on success; Error code otherwise.
71667 +
71668 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71669 +*//***************************************************************************/
71670 +t_Error FM_PORT_ConfigDeqPrefetchOption(t_Handle h_FmPort, e_FmPortDeqPrefetchOption deqPrefetchOption);
71671 +
71672 +/**************************************************************************//**
71673 + @Function FM_PORT_ConfigDeqByteCnt
71674 +
71675 + @Description Calling this routine changes the dequeue byte count parameter in
71676 + the internal driver data base from its default configuration
71677 + 1G:[DEFAULT_PORT_deqByteCnt_1G].
71678 + 10G:[DEFAULT_PORT_deqByteCnt_10G].
71679 +
71680 + May be used for Non-Rx ports only
71681 +
71682 + @Param[in] h_FmPort A handle to a FM Port module.
71683 + @Param[in] deqByteCnt New byte count
71684 +
71685 + @Return E_OK on success; Error code otherwise.
71686 +
71687 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71688 +*//***************************************************************************/
71689 +t_Error FM_PORT_ConfigDeqByteCnt(t_Handle h_FmPort, uint16_t deqByteCnt);
71690 +
71691 +/**************************************************************************//**
71692 + @Function FM_PORT_ConfigBufferPrefixContent
71693 +
71694 + @Description Defines the structure, size and content of the application buffer.
71695 + The prefix will
71696 + In Tx ports, if 'passPrsResult', the application
71697 + should set a value to their offsets in the prefix of
71698 + the FM will save the first 'privDataSize', than,
71699 + depending on 'passPrsResult' and 'passTimeStamp', copy parse result
71700 + and timeStamp, and the packet itself (in this order), to the
71701 + application buffer, and to offset.
71702 + Calling this routine changes the buffer margins definitions
71703 + in the internal driver data base from its default
71704 + configuration: Data size: [DEFAULT_PORT_bufferPrefixContent_privDataSize]
71705 + Pass Parser result: [DEFAULT_PORT_bufferPrefixContent_passPrsResult].
71706 + Pass timestamp: [DEFAULT_PORT_bufferPrefixContent_passTimeStamp].
71707 +
71708 + May be used for all ports
71709 +
71710 + @Param[in] h_FmPort A handle to a FM Port module.
71711 + @Param[in,out] p_FmBufferPrefixContent A structure of parameters describing the
71712 + structure of the buffer.
71713 + Out parameter: Start margin - offset
71714 + of data from start of external buffer.
71715 +
71716 + @Return E_OK on success; Error code otherwise.
71717 +
71718 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71719 +*//***************************************************************************/
71720 +t_Error FM_PORT_ConfigBufferPrefixContent(t_Handle h_FmPort,
71721 + t_FmBufferPrefixContent *p_FmBufferPrefixContent);
71722 +
71723 +/**************************************************************************//**
71724 + @Function FM_PORT_ConfigCheksumLastBytesIgnore
71725 +
71726 + @Description Calling this routine changes the number of checksum bytes to ignore
71727 + parameter in the internal driver data base from its default configuration
71728 + [DEFAULT_PORT_cheksumLastBytesIgnore]
71729 +
71730 + May be used by Tx & Rx ports only
71731 +
71732 + @Param[in] h_FmPort A handle to a FM Port module.
71733 + @Param[in] cheksumLastBytesIgnore New value
71734 +
71735 + @Return E_OK on success; Error code otherwise.
71736 +
71737 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71738 +*//***************************************************************************/
71739 +t_Error FM_PORT_ConfigCheksumLastBytesIgnore(t_Handle h_FmPort, uint8_t cheksumLastBytesIgnore);
71740 +
71741 +/**************************************************************************//**
71742 + @Function FM_PORT_ConfigCutBytesFromEnd
71743 +
71744 + @Description Calling this routine changes the number of bytes to cut from a
71745 + frame's end parameter in the internal driver data base
71746 + from its default configuration [DEFAULT_PORT_cutBytesFromEnd]
71747 + Note that if the result of (frame length before chop - cutBytesFromEnd) is
71748 + less than 14 bytes, the chop operation is not executed.
71749 +
71750 + May be used for Rx ports only
71751 +
71752 + @Param[in] h_FmPort A handle to a FM Port module.
71753 + @Param[in] cutBytesFromEnd New value
71754 +
71755 + @Return E_OK on success; Error code otherwise.
71756 +
71757 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71758 +*//***************************************************************************/
71759 +t_Error FM_PORT_ConfigCutBytesFromEnd(t_Handle h_FmPort, uint8_t cutBytesFromEnd);
71760 +
71761 +/**************************************************************************//**
71762 + @Function FM_PORT_ConfigPoolDepletion
71763 +
71764 + @Description Calling this routine enables pause frame generation depending on the
71765 + depletion status of BM pools. It also defines the conditions to activate
71766 + this functionality. By default, this functionality is disabled.
71767 +
71768 + May be used for Rx ports only
71769 +
71770 + @Param[in] h_FmPort A handle to a FM Port module.
71771 + @Param[in] p_BufPoolDepletion A structure of pool depletion parameters
71772 +
71773 + @Return E_OK on success; Error code otherwise.
71774 +
71775 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71776 +*//***************************************************************************/
71777 +t_Error FM_PORT_ConfigPoolDepletion(t_Handle h_FmPort, t_FmBufPoolDepletion *p_BufPoolDepletion);
71778 +
71779 +/**************************************************************************//**
71780 + @Function FM_PORT_ConfigObservedPoolDepletion
71781 +
71782 + @Description Calling this routine enables a mechanism to stop port enqueue
71783 + depending on the depletion status of selected BM pools.
71784 + It also defines the conditions to activate
71785 + this functionality. By default, this functionality is disabled.
71786 +
71787 + Note: Available for some chips only
71788 +
71789 + May be used for OP ports only
71790 +
71791 + @Param[in] h_FmPort A handle to a FM Port module.
71792 + @Param[in] p_FmPortObservedBufPoolDepletion A structure of parameters for pool depletion.
71793 +
71794 + @Return E_OK on success; Error code otherwise.
71795 +
71796 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71797 +*//***************************************************************************/
71798 +t_Error FM_PORT_ConfigObservedPoolDepletion(t_Handle h_FmPort,
71799 + t_FmPortObservedBufPoolDepletion *p_FmPortObservedBufPoolDepletion);
71800 +
71801 +/**************************************************************************//**
71802 + @Function FM_PORT_ConfigExtBufPools
71803 +
71804 + @Description This routine should be called for OP ports
71805 + that internally use BM buffer pools. In such cases, e.g. for fragmentation and
71806 + re-assembly, the FM needs new BM buffers. By calling this routine the user
71807 + specifies the BM buffer pools that should be used.
71808 +
71809 + Note: Available for some chips only
71810 +
71811 + May be used for OP ports only
71812 +
71813 + @Param[in] h_FmPort A handle to a FM Port module.
71814 + @Param[in] p_FmExtPools A structure of parameters for the external pools.
71815 +
71816 + @Return E_OK on success; Error code otherwise.
71817 +
71818 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71819 +*//***************************************************************************/
71820 +t_Error FM_PORT_ConfigExtBufPools(t_Handle h_FmPort, t_FmExtPools *p_FmExtPools);
71821 +
71822 +/**************************************************************************//**
71823 + @Function FM_PORT_ConfigBackupPools
71824 +
71825 + @Description Calling this routine allows the configuration of some of the BM pools
71826 + defined for this port as backup pools.
71827 + A pool configured to be a backup pool will be used only if all other
71828 + enabled non-backup pools are depleted.
71829 +
71830 + May be used for Rx ports only
71831 +
71832 + @Param[in] h_FmPort A handle to a FM Port module.
71833 + @Param[in] p_FmPortBackupBmPools An array of pool id's. All pools specified here will
71834 + be defined as backup pools.
71835 +
71836 + @Return E_OK on success; Error code otherwise.
71837 +
71838 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71839 +*//***************************************************************************/
71840 +t_Error FM_PORT_ConfigBackupPools(t_Handle h_FmPort, t_FmBackupBmPools *p_FmPortBackupBmPools);
71841 +
71842 +/**************************************************************************//**
71843 + @Function FM_PORT_ConfigFrmDiscardOverride
71844 +
71845 + @Description Calling this routine changes the error frames destination parameter
71846 + in the internal driver data base from its default configuration:
71847 + override = [DEFAULT_PORT_frmDiscardOverride]
71848 +
71849 + May be used for Rx and OP ports only
71850 +
71851 + @Param[in] h_FmPort A handle to a FM Port module.
71852 + @Param[in] override TRUE to override discarding of error frames and
71853 + enqueueing them to error queue.
71854 +
71855 + @Return E_OK on success; Error code otherwise.
71856 +
71857 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71858 +*//***************************************************************************/
71859 +t_Error FM_PORT_ConfigFrmDiscardOverride(t_Handle h_FmPort, bool override);
71860 +
71861 +/**************************************************************************//**
71862 + @Function FM_PORT_ConfigErrorsToDiscard
71863 +
71864 + @Description Calling this routine changes the behaviour on error parameter
71865 + in the internal driver data base from its default configuration:
71866 + [DEFAULT_PORT_errorsToDiscard].
71867 + If a requested error was previously defined as "ErrorsToEnqueue" it's
71868 + definition will change and the frame will be discarded.
71869 + Errors that were not defined either as "ErrorsToEnqueue" nor as
71870 + "ErrorsToDiscard", will be forwarded to CPU.
71871 +
71872 + May be used for Rx and OP ports only
71873 +
71874 + @Param[in] h_FmPort A handle to a FM Port module.
71875 + @Param[in] errs A list of errors to discard
71876 +
71877 + @Return E_OK on success; Error code otherwise.
71878 +
71879 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71880 +*//***************************************************************************/
71881 +t_Error FM_PORT_ConfigErrorsToDiscard(t_Handle h_FmPort, fmPortFrameErrSelect_t errs);
71882 +
71883 +/**************************************************************************//**
71884 + @Function FM_PORT_ConfigDmaSwapData
71885 +
71886 + @Description Calling this routine changes the DMA swap data aparameter
71887 + in the internal driver data base from its default
71888 + configuration [DEFAULT_PORT_dmaSwapData]
71889 +
71890 + May be used for all port types
71891 +
71892 + @Param[in] h_FmPort A handle to a FM Port module.
71893 + @Param[in] swapData New selection
71894 +
71895 + @Return E_OK on success; Error code otherwise.
71896 +
71897 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71898 +*//***************************************************************************/
71899 +t_Error FM_PORT_ConfigDmaSwapData(t_Handle h_FmPort, e_FmDmaSwapOption swapData);
71900 +
71901 +/**************************************************************************//**
71902 + @Function FM_PORT_ConfigDmaIcCacheAttr
71903 +
71904 + @Description Calling this routine changes the internal context cache
71905 + attribute parameter in the internal driver data base
71906 + from its default configuration [DEFAULT_PORT_dmaIntContextCacheAttr]
71907 +
71908 + May be used for all port types
71909 +
71910 + @Param[in] h_FmPort A handle to a FM Port module.
71911 + @Param[in] intContextCacheAttr New selection
71912 +
71913 + @Return E_OK on success; Error code otherwise.
71914 +
71915 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71916 +*//***************************************************************************/
71917 +t_Error FM_PORT_ConfigDmaIcCacheAttr(t_Handle h_FmPort, e_FmDmaCacheOption intContextCacheAttr);
71918 +
71919 +/**************************************************************************//**
71920 + @Function FM_PORT_ConfigDmaHdrAttr
71921 +
71922 + @Description Calling this routine changes the header cache
71923 + attribute parameter in the internal driver data base
71924 + from its default configuration [DEFAULT_PORT_dmaHeaderCacheAttr]
71925 +
71926 + May be used for all port types
71927 +
71928 + @Param[in] h_FmPort A handle to a FM Port module.
71929 + @Param[in] headerCacheAttr New selection
71930 +
71931 + @Return E_OK on success; Error code otherwise.
71932 +
71933 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71934 +*//***************************************************************************/
71935 +t_Error FM_PORT_ConfigDmaHdrAttr(t_Handle h_FmPort, e_FmDmaCacheOption headerCacheAttr);
71936 +
71937 +/**************************************************************************//**
71938 + @Function FM_PORT_ConfigDmaScatterGatherAttr
71939 +
71940 + @Description Calling this routine changes the scatter gather cache
71941 + attribute parameter in the internal driver data base
71942 + from its default configuration [DEFAULT_PORT_dmaScatterGatherCacheAttr]
71943 +
71944 + May be used for all port types
71945 +
71946 + @Param[in] h_FmPort A handle to a FM Port module.
71947 + @Param[in] scatterGatherCacheAttr New selection
71948 +
71949 + @Return E_OK on success; Error code otherwise.
71950 +
71951 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71952 +*//***************************************************************************/
71953 +t_Error FM_PORT_ConfigDmaScatterGatherAttr(t_Handle h_FmPort, e_FmDmaCacheOption scatterGatherCacheAttr);
71954 +
71955 +/**************************************************************************//**
71956 + @Function FM_PORT_ConfigDmaWriteOptimize
71957 +
71958 + @Description Calling this routine changes the write optimization
71959 + parameter in the internal driver data base
71960 + from its default configuration: By default optimize = [DEFAULT_PORT_dmaWriteOptimize].
71961 + Note:
71962 +
71963 + 1. For head optimization, data alignment must be >= 16 (supported by default).
71964 +
71965 + 3. For tail optimization, note that the optimization is performed by extending the write transaction
71966 + of the frame payload at the tail as needed to achieve optimal bus transfers, so that the last write
71967 + is extended to be on 16/64 bytes aligned block (chip dependent).
71968 +
71969 + Relevant for non-Tx port types
71970 +
71971 + @Param[in] h_FmPort A handle to a FM Port module.
71972 + @Param[in] optimize TRUE to enable optimization, FALSE for normal operation
71973 +
71974 + @Return E_OK on success; Error code otherwise.
71975 +
71976 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71977 +*//***************************************************************************/
71978 +t_Error FM_PORT_ConfigDmaWriteOptimize(t_Handle h_FmPort, bool optimize);
71979 +
71980 +/**************************************************************************//**
71981 + @Function FM_PORT_ConfigNoScatherGather
71982 +
71983 + @Description Calling this routine changes the noScatherGather parameter in internal driver data base
71984 + from its default configuration.
71985 +
71986 + @Param[in] h_FmPort A handle to a FM Port module.
71987 + @Param[in] noScatherGather (TRUE - frame is discarded if can not be stored in single buffer,
71988 + FALSE - frame can be stored in scatter gather (S/G) format).
71989 +
71990 + @Return E_OK on success; Error code otherwise.
71991 +
71992 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
71993 +*//***************************************************************************/
71994 +t_Error FM_PORT_ConfigNoScatherGather(t_Handle h_FmPort, bool noScatherGather);
71995 +
71996 +/**************************************************************************//**
71997 + @Function FM_PORT_ConfigDfltColor
71998 +
71999 + @Description Calling this routine changes the internal default color parameter
72000 + in the internal driver data base
72001 + from its default configuration [DEFAULT_PORT_color]
72002 +
72003 + May be used for all port types
72004 +
72005 + @Param[in] h_FmPort A handle to a FM Port module.
72006 + @Param[in] color New selection
72007 +
72008 + @Return E_OK on success; Error code otherwise.
72009 +
72010 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72011 +*//***************************************************************************/
72012 +t_Error FM_PORT_ConfigDfltColor(t_Handle h_FmPort, e_FmPortColor color);
72013 +
72014 +/**************************************************************************//**
72015 + @Function FM_PORT_ConfigSyncReq
72016 +
72017 + @Description Calling this routine changes the synchronization attribute parameter
72018 + in the internal driver data base from its default configuration:
72019 + syncReq = [DEFAULT_PORT_syncReq]
72020 +
72021 + May be used for all port types
72022 +
72023 + @Param[in] h_FmPort A handle to a FM Port module.
72024 + @Param[in] syncReq TRUE to request synchronization, FALSE otherwize.
72025 +
72026 + @Return E_OK on success; Error code otherwise.
72027 +
72028 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72029 +*//***************************************************************************/
72030 +t_Error FM_PORT_ConfigSyncReq(t_Handle h_FmPort, bool syncReq);
72031 +
72032 +/**************************************************************************//**
72033 + @Function FM_PORT_ConfigForwardReuseIntContext
72034 +
72035 + @Description This routine is relevant for Rx ports that are routed to OP port.
72036 + It changes the internal context reuse option in the internal
72037 + driver data base from its default configuration:
72038 + reuse = [DEFAULT_PORT_forwardIntContextReuse]
72039 +
72040 + May be used for Rx ports only
72041 +
72042 + @Param[in] h_FmPort A handle to a FM Port module.
72043 + @Param[in] reuse TRUE to reuse internal context on frames
72044 + forwarded to OP port.
72045 +
72046 + @Return E_OK on success; Error code otherwise.
72047 +
72048 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72049 +*//***************************************************************************/
72050 +t_Error FM_PORT_ConfigForwardReuseIntContext(t_Handle h_FmPort, bool reuse);
72051 +
72052 +/**************************************************************************//**
72053 + @Function FM_PORT_ConfigDontReleaseTxBufToBM
72054 +
72055 + @Description This routine should be called if no Tx confirmation
72056 + is done, and yet buffers should not be released to the BM.
72057 + Normally, buffers are returned using the Tx confirmation
72058 + process. When Tx confirmation is not used (defFqid=0),
72059 + buffers are typically released to the BM. This routine
72060 + may be called to avoid this behavior and not release the
72061 + buffers.
72062 +
72063 + May be used for Tx ports only
72064 +
72065 + @Param[in] h_FmPort A handle to a FM Port module.
72066 +
72067 + @Return E_OK on success; Error code otherwise.
72068 +
72069 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72070 +*//***************************************************************************/
72071 +t_Error FM_PORT_ConfigDontReleaseTxBufToBM(t_Handle h_FmPort);
72072 +
72073 +/**************************************************************************//**
72074 + @Function FM_PORT_ConfigIMMaxRxBufLength
72075 +
72076 + @Description Changes the maximum receive buffer length from its default
72077 + configuration: Closest rounded down power of 2 value of the
72078 + data buffer size.
72079 +
72080 + The maximum receive buffer length directly affects the structure
72081 + of received frames (single- or multi-buffered) and the performance
72082 + of both the FM and the driver.
72083 +
72084 + The selection between single- or multi-buffered frames should be
72085 + done according to the characteristics of the specific application.
72086 + The recommended mode is to use a single data buffer per packet,
72087 + as this mode provides the best performance. However, the user can
72088 + select to use multiple data buffers per packet.
72089 +
72090 + @Param[in] h_FmPort A handle to a FM Port module.
72091 + @Param[in] newVal Maximum receive buffer length (in bytes).
72092 +
72093 + @Return E_OK on success; Error code otherwise.
72094 +
72095 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72096 + This routine is to be used only if Independent-Mode is enabled.
72097 +*//***************************************************************************/
72098 +t_Error FM_PORT_ConfigIMMaxRxBufLength(t_Handle h_FmPort, uint16_t newVal);
72099 +
72100 +/**************************************************************************//**
72101 + @Function FM_PORT_ConfigIMRxBdRingLength
72102 +
72103 + @Description Changes the receive BD ring length from its default
72104 + configuration:[DEFAULT_PORT_rxBdRingLength]
72105 +
72106 + @Param[in] h_FmPort A handle to a FM Port module.
72107 + @Param[in] newVal The desired BD ring length.
72108 +
72109 + @Return E_OK on success; Error code otherwise.
72110 +
72111 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72112 + This routine is to be used only if Independent-Mode is enabled.
72113 +*//***************************************************************************/
72114 +t_Error FM_PORT_ConfigIMRxBdRingLength(t_Handle h_FmPort, uint16_t newVal);
72115 +
72116 +/**************************************************************************//**
72117 + @Function FM_PORT_ConfigIMTxBdRingLength
72118 +
72119 + @Description Changes the transmit BD ring length from its default
72120 + configuration:[DEFAULT_PORT_txBdRingLength]
72121 +
72122 + @Param[in] h_FmPort A handle to a FM Port module.
72123 + @Param[in] newVal The desired BD ring length.
72124 +
72125 + @Return E_OK on success; Error code otherwise.
72126 +
72127 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72128 + This routine is to be used only if Independent-Mode is enabled.
72129 +*//***************************************************************************/
72130 +t_Error FM_PORT_ConfigIMTxBdRingLength(t_Handle h_FmPort, uint16_t newVal);
72131 +
72132 +/**************************************************************************//**
72133 + @Function FM_PORT_ConfigIMFmanCtrlExternalStructsMemory
72134 +
72135 + @Description Configures memory partition and attributes for FMan-Controller
72136 + data structures (e.g. BD rings).
72137 + Calling this routine changes the internal driver data base
72138 + from its default configuration
72139 + [DEFAULT_PORT_ImfwExtStructsMemId, DEFAULT_PORT_ImfwExtStructsMemAttr].
72140 +
72141 + @Param[in] h_FmPort A handle to a FM Port module.
72142 + @Param[in] memId Memory partition ID.
72143 + @Param[in] memAttributes Memory attributes mask (a combination of MEMORY_ATTR_x flags).
72144 +
72145 + @Return E_OK on success; Error code otherwise.
72146 +*//***************************************************************************/
72147 +t_Error FM_PORT_ConfigIMFmanCtrlExternalStructsMemory(t_Handle h_FmPort,
72148 + uint8_t memId,
72149 + uint32_t memAttributes);
72150 +
72151 +/**************************************************************************//**
72152 + @Function FM_PORT_ConfigIMPolling
72153 +
72154 + @Description Changes the Rx flow from interrupt driven (default) to polling.
72155 +
72156 + @Param[in] h_FmPort A handle to a FM Port module.
72157 +
72158 + @Return E_OK on success; Error code otherwise.
72159 +
72160 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72161 + This routine is to be used only if Independent-Mode is enabled.
72162 +*//***************************************************************************/
72163 +t_Error FM_PORT_ConfigIMPolling(t_Handle h_FmPort);
72164 +
72165 +/**************************************************************************//**
72166 + @Function FM_PORT_ConfigMaxFrameLength
72167 +
72168 + @Description Changes the definition of the max size of frame that should be
72169 + transmitted/received on this port from its default value [DEFAULT_PORT_maxFrameLength].
72170 + This parameter is used for confirmation of the minimum Fifo
72171 + size calculations and only for Tx ports or ports working in
72172 + independent mode. This should be larger than the maximum possible
72173 + MTU that will be used for this port (i.e. its MAC).
72174 +
72175 + @Param[in] h_FmPort A handle to a FM Port module.
72176 + @Param[in] length Max size of frame
72177 +
72178 + @Return E_OK on success; Error code otherwise.
72179 +
72180 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72181 + This routine is to be used only if Independent-Mode is enabled.
72182 +*//***************************************************************************/
72183 +t_Error FM_PORT_ConfigMaxFrameLength(t_Handle h_FmPort, uint16_t length);
72184 +
72185 +/**************************************************************************//*
72186 + @Function FM_PORT_ConfigTxFifoMinFillLevel
72187 +
72188 + @Description Calling this routine changes the fifo minimum
72189 + fill level parameter in the internal driver data base
72190 + from its default configuration [DEFAULT_PORT_txFifoMinFillLevel]
72191 +
72192 + May be used for Tx ports only
72193 +
72194 + @Param[in] h_FmPort A handle to a FM Port module.
72195 + @Param[in] minFillLevel New value
72196 +
72197 + @Return E_OK on success; Error code otherwise.
72198 +
72199 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72200 +*//***************************************************************************/
72201 +t_Error FM_PORT_ConfigTxFifoMinFillLevel(t_Handle h_FmPort, uint32_t minFillLevel);
72202 +
72203 +/**************************************************************************//*
72204 + @Function FM_PORT_ConfigFifoDeqPipelineDepth
72205 +
72206 + @Description Calling this routine changes the fifo dequeue
72207 + pipeline depth parameter in the internal driver data base
72208 +
72209 + from its default configuration: 1G ports: [DEFAULT_PORT_fifoDeqPipelineDepth_1G],
72210 + 10G port: [DEFAULT_PORT_fifoDeqPipelineDepth_10G],
72211 + OP port: [DEFAULT_PORT_fifoDeqPipelineDepth_OH]
72212 +
72213 + May be used for Tx/OP ports only
72214 +
72215 + @Param[in] h_FmPort A handle to a FM Port module.
72216 + @Param[in] deqPipelineDepth New value
72217 +
72218 + @Return E_OK on success; Error code otherwise.
72219 +
72220 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72221 +*//***************************************************************************/
72222 +t_Error FM_PORT_ConfigFifoDeqPipelineDepth(t_Handle h_FmPort, uint8_t deqPipelineDepth);
72223 +
72224 +/**************************************************************************//*
72225 + @Function FM_PORT_ConfigTxFifoLowComfLevel
72226 +
72227 + @Description Calling this routine changes the fifo low comfort level
72228 + parameter in internal driver data base
72229 + from its default configuration [DEFAULT_PORT_txFifoLowComfLevel]
72230 +
72231 + May be used for Tx ports only
72232 +
72233 + @Param[in] h_FmPort A handle to a FM Port module.
72234 + @Param[in] fifoLowComfLevel New value
72235 +
72236 + @Return E_OK on success; Error code otherwise.
72237 +
72238 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72239 +*//***************************************************************************/
72240 +t_Error FM_PORT_ConfigTxFifoLowComfLevel(t_Handle h_FmPort, uint32_t fifoLowComfLevel);
72241 +
72242 +/**************************************************************************//*
72243 + @Function FM_PORT_ConfigRxFifoThreshold
72244 +
72245 + @Description Calling this routine changes the threshold of the FIFO
72246 + fill level parameter in the internal driver data base
72247 + from its default configuration [DEFAULT_PORT_rxFifoThreshold]
72248 +
72249 + If the total number of buffers which are
72250 + currently in use and associated with the
72251 + specific RX port exceed this threshold, the
72252 + BMI will signal the MAC to send a pause frame
72253 + over the link.
72254 +
72255 + May be used for Rx ports only
72256 +
72257 + @Param[in] h_FmPort A handle to a FM Port module.
72258 + @Param[in] fifoThreshold New value
72259 +
72260 + @Return E_OK on success; Error code otherwise.
72261 +
72262 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72263 +*//***************************************************************************/
72264 +t_Error FM_PORT_ConfigRxFifoThreshold(t_Handle h_FmPort, uint32_t fifoThreshold);
72265 +
72266 +/**************************************************************************//*
72267 + @Function FM_PORT_ConfigRxFifoPriElevationLevel
72268 +
72269 + @Description Calling this routine changes the priority elevation level
72270 + parameter in the internal driver data base from its default
72271 + configuration [DEFAULT_PORT_rxFifoPriElevationLevel]
72272 +
72273 + If the total number of buffers which are currently in use and
72274 + associated with the specific RX port exceed the amount specified
72275 + in priElevationLevel, BMI will signal the main FM's DMA to
72276 + elevate the FM priority on the system bus.
72277 +
72278 + May be used for Rx ports only
72279 +
72280 + @Param[in] h_FmPort A handle to a FM Port module.
72281 + @Param[in] priElevationLevel New value
72282 +
72283 + @Return E_OK on success; Error code otherwise.
72284 +
72285 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72286 +*//***************************************************************************/
72287 +t_Error FM_PORT_ConfigRxFifoPriElevationLevel(t_Handle h_FmPort, uint32_t priElevationLevel);
72288 +
72289 +#ifdef FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669
72290 +/**************************************************************************//*
72291 + @Function FM_PORT_ConfigBCBWorkaround
72292 +
72293 + @Description Configures BCB errata workaround.
72294 +
72295 + When BCB errata is applicable, the workaround is always
72296 + performed by FM Controller. Thus, this functions doesn't
72297 + actually enable errata workaround but rather allows driver
72298 + to perform adjustments required due to errata workaround
72299 + execution in FM controller.
72300 +
72301 + Applying BCB workaround also configures FM_PORT_FRM_ERR_PHYSICAL
72302 + errors to be discarded. Thus FM_PORT_FRM_ERR_PHYSICAL can't be
72303 + set by FM_PORT_SetErrorsRoute() function.
72304 +
72305 + @Param[in] h_FmPort A handle to a FM Port module.
72306 +
72307 + @Return E_OK on success; Error code otherwise.
72308 +
72309 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72310 +*//***************************************************************************/
72311 +t_Error FM_PORT_ConfigBCBWorkaround(t_Handle h_FmPort);
72312 +#endif /* FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669 */
72313 +
72314 +#if (DPAA_VERSION >= 11)
72315 +/**************************************************************************//*
72316 + @Function FM_PORT_ConfigInternalBuffOffset
72317 +
72318 + @Description Configures internal buffer offset.
72319 +
72320 + May be used for Rx and OP ports only
72321 +
72322 + @Param[in] h_FmPort A handle to a FM Port module.
72323 + @Param[in] val New value
72324 +
72325 + @Return E_OK on success; Error code otherwise.
72326 +
72327 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
72328 +*//***************************************************************************/
72329 +t_Error FM_PORT_ConfigInternalBuffOffset(t_Handle h_FmPort, uint8_t val);
72330 +#endif /* (DPAA_VERSION >= 11) */
72331 +
72332 +/** @} */ /* end of FM_PORT_advanced_init_grp group */
72333 +/** @} */ /* end of FM_PORT_init_grp group */
72334 +
72335 +
72336 +/**************************************************************************//**
72337 + @Group FM_PORT_runtime_control_grp FM Port Runtime Control Unit
72338 +
72339 + @Description FM Port Runtime control unit API functions, definitions and enums.
72340 +
72341 + @{
72342 +*//***************************************************************************/
72343 +
72344 +/**************************************************************************//**
72345 + @Description enum for defining FM Port counters
72346 +*//***************************************************************************/
72347 +typedef enum e_FmPortCounters {
72348 + e_FM_PORT_COUNTERS_CYCLE, /**< BMI performance counter */
72349 + e_FM_PORT_COUNTERS_TASK_UTIL, /**< BMI performance counter */
72350 + e_FM_PORT_COUNTERS_QUEUE_UTIL, /**< BMI performance counter */
72351 + e_FM_PORT_COUNTERS_DMA_UTIL, /**< BMI performance counter */
72352 + e_FM_PORT_COUNTERS_FIFO_UTIL, /**< BMI performance counter */
72353 + e_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION, /**< BMI Rx only performance counter */
72354 + e_FM_PORT_COUNTERS_FRAME, /**< BMI statistics counter */
72355 + e_FM_PORT_COUNTERS_DISCARD_FRAME, /**< BMI statistics counter */
72356 + e_FM_PORT_COUNTERS_DEALLOC_BUF, /**< BMI deallocate buffer statistics counter */
72357 + e_FM_PORT_COUNTERS_RX_BAD_FRAME, /**< BMI Rx only statistics counter */
72358 + e_FM_PORT_COUNTERS_RX_LARGE_FRAME, /**< BMI Rx only statistics counter */
72359 + e_FM_PORT_COUNTERS_RX_FILTER_FRAME, /**< BMI Rx & OP only statistics counter */
72360 + e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR, /**< BMI Rx, OP & HC only statistics counter */
72361 + e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD, /**< BMI Rx, OP & HC statistics counter */
72362 + e_FM_PORT_COUNTERS_PREPARE_TO_ENQUEUE_COUNTER, /**< BMI Rx, OP & HC only statistics counter */
72363 + e_FM_PORT_COUNTERS_WRED_DISCARD, /**< BMI OP & HC only statistics counter */
72364 + e_FM_PORT_COUNTERS_LENGTH_ERR, /**< BMI non-Rx statistics counter */
72365 + e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT, /**< BMI non-Rx statistics counter */
72366 + e_FM_PORT_COUNTERS_DEQ_TOTAL, /**< QMI total QM dequeues counter */
72367 + e_FM_PORT_COUNTERS_ENQ_TOTAL, /**< QMI total QM enqueues counter */
72368 + e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT, /**< QMI counter */
72369 + e_FM_PORT_COUNTERS_DEQ_CONFIRM /**< QMI counter */
72370 +} e_FmPortCounters;
72371 +
72372 +typedef struct t_FmPortBmiStats {
72373 + uint32_t cntCycle;
72374 + uint32_t cntTaskUtil;
72375 + uint32_t cntQueueUtil;
72376 + uint32_t cntDmaUtil;
72377 + uint32_t cntFifoUtil;
72378 + uint32_t cntRxPauseActivation;
72379 + uint32_t cntFrame;
72380 + uint32_t cntDiscardFrame;
72381 + uint32_t cntDeallocBuf;
72382 + uint32_t cntRxBadFrame;
72383 + uint32_t cntRxLargeFrame;
72384 + uint32_t cntRxFilterFrame;
72385 + uint32_t cntRxListDmaErr;
72386 + uint32_t cntRxOutOfBuffersDiscard;
72387 + uint32_t cntWredDiscard;
72388 + uint32_t cntLengthErr;
72389 + uint32_t cntUnsupportedFormat;
72390 +} t_FmPortBmiStats;
72391 +
72392 +/**************************************************************************//**
72393 + @Description Structure for Port id parameters.
72394 + Fields commented 'IN' are passed by the port module to be used
72395 + by the FM module.
72396 + Fields commented 'OUT' will be filled by FM before returning to port.
72397 +*//***************************************************************************/
72398 +typedef struct t_FmPortCongestionGrps {
72399 + uint16_t numOfCongestionGrpsToConsider; /**< The number of required CGs
72400 + to define the size of the following array */
72401 + uint8_t congestionGrpsToConsider[FM_PORT_NUM_OF_CONGESTION_GRPS];
72402 + /**< An array of CG indexes;
72403 + Note that the size of the array should be
72404 + 'numOfCongestionGrpsToConsider'. */
72405 +#if (DPAA_VERSION >= 11)
72406 + bool pfcPrioritiesEn[FM_PORT_NUM_OF_CONGESTION_GRPS][FM_MAX_NUM_OF_PFC_PRIORITIES];
72407 + /**< a matrix that represents the map between the CG ids
72408 + defined in 'congestionGrpsToConsider' to the priorties
72409 + mapping array. */
72410 +#endif /* (DPAA_VERSION >= 11) */
72411 +} t_FmPortCongestionGrps;
72412 +
72413 +/**************************************************************************//**
72414 + @Description Structure for Deep Sleep Auto Response ARP Entry
72415 +*//***************************************************************************/
72416 +typedef struct t_FmPortDsarArpEntry
72417 +{
72418 + uint32_t ipAddress;
72419 + uint8_t mac[6];
72420 + bool isVlan;
72421 + uint16_t vid;
72422 +} t_FmPortDsarArpEntry;
72423 +
72424 +/**************************************************************************//**
72425 + @Description Structure for Deep Sleep Auto Response ARP info
72426 +*//***************************************************************************/
72427 +typedef struct t_FmPortDsarArpInfo
72428 +{
72429 + uint8_t tableSize;
72430 + t_FmPortDsarArpEntry *p_AutoResTable;
72431 + bool enableConflictDetection; /* when TRUE Conflict Detection will be checked and wake the host if needed */
72432 +} t_FmPortDsarArpInfo;
72433 +
72434 +/**************************************************************************//**
72435 + @Description Structure for Deep Sleep Auto Response NDP Entry
72436 +*//***************************************************************************/
72437 +typedef struct t_FmPortDsarNdpEntry
72438 +{
72439 + uint32_t ipAddress[4];
72440 + uint8_t mac[6];
72441 + bool isVlan;
72442 + uint16_t vid;
72443 +} t_FmPortDsarNdpEntry;
72444 +
72445 +/**************************************************************************//**
72446 + @Description Structure for Deep Sleep Auto Response NDP info
72447 +*//***************************************************************************/
72448 +typedef struct t_FmPortDsarNdpInfo
72449 +{
72450 + uint32_t multicastGroup;
72451 +
72452 + uint8_t tableSizeAssigned;
72453 + t_FmPortDsarNdpEntry *p_AutoResTableAssigned; /* This list refer to solicitation IP addresses.
72454 + Note that all IP adresses must be from the same multicast group.
72455 + This will be checked and if not operation will fail. */
72456 + uint8_t tableSizeTmp;
72457 + t_FmPortDsarNdpEntry *p_AutoResTableTmp; /* This list refer to temp IP addresses.
72458 + Note that all temp IP adresses must be from the same multicast group.
72459 + This will be checked and if not operation will fail. */
72460 +
72461 + bool enableConflictDetection; /* when TRUE Conflict Detection will be checked and wake the host if needed */
72462 +
72463 +} t_FmPortDsarNdpInfo;
72464 +
72465 +/**************************************************************************//**
72466 + @Description Structure for Deep Sleep Auto Response ICMPV4 info
72467 +*//***************************************************************************/
72468 +typedef struct t_FmPortDsarEchoIpv4Info
72469 +{
72470 + uint8_t tableSize;
72471 + t_FmPortDsarArpEntry *p_AutoResTable;
72472 +} t_FmPortDsarEchoIpv4Info;
72473 +
72474 +/**************************************************************************//**
72475 + @Description Structure for Deep Sleep Auto Response ICMPV6 info
72476 +*//***************************************************************************/
72477 +typedef struct t_FmPortDsarEchoIpv6Info
72478 +{
72479 + uint8_t tableSize;
72480 + t_FmPortDsarNdpEntry *p_AutoResTable;
72481 +} t_FmPortDsarEchoIpv6Info;
72482 +
72483 +/**************************************************************************//**
72484 +@Description Deep Sleep Auto Response SNMP OIDs table entry
72485 +
72486 +*//***************************************************************************/
72487 +typedef struct {
72488 + uint16_t oidSize;
72489 + uint8_t *oidVal; /* only the oid string */
72490 + uint16_t resSize;
72491 + uint8_t *resVal; /* resVal will be the entire reply,
72492 + i.e. "Type|Length|Value" */
72493 +} t_FmPortDsarOidsEntry;
72494 +
72495 +/**************************************************************************//**
72496 + @Description Deep Sleep Auto Response SNMP IPv4 Addresses Table Entry
72497 + Refer to the FMan Controller spec for more details.
72498 +*//***************************************************************************/
72499 +typedef struct
72500 +{
72501 + uint32_t ipv4Addr; /*!< 32 bit IPv4 Address. */
72502 + bool isVlan;
72503 + uint16_t vid; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
72504 + /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
72505 +} t_FmPortDsarSnmpIpv4AddrTblEntry;
72506 +
72507 +/**************************************************************************//**
72508 + @Description Deep Sleep Auto Response SNMP IPv6 Addresses Table Entry
72509 + Refer to the FMan Controller spec for more details.
72510 +*//***************************************************************************/
72511 +typedef struct
72512 +{
72513 + uint32_t ipv6Addr[4]; /*!< 4 * 32 bit IPv6 Address. */
72514 + bool isVlan;
72515 + uint16_t vid; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
72516 + /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
72517 +} t_FmPortDsarSnmpIpv6AddrTblEntry;
72518 +
72519 +/**************************************************************************//**
72520 + @Description Deep Sleep Auto Response SNMP Descriptor
72521 +
72522 +*//***************************************************************************/
72523 +typedef struct
72524 +{
72525 + uint16_t control; /**< Control bits [0-15]. */
72526 + uint16_t maxSnmpMsgLength; /**< Maximal allowed SNMP message length. */
72527 + uint16_t numOfIpv4Addresses; /**< Number of entries in IPv4 addresses table. */
72528 + uint16_t numOfIpv6Addresses; /**< Number of entries in IPv6 addresses table. */
72529 + t_FmPortDsarSnmpIpv4AddrTblEntry *p_Ipv4AddrTbl; /**< Pointer to IPv4 addresses table. */
72530 + t_FmPortDsarSnmpIpv6AddrTblEntry *p_Ipv6AddrTbl; /**< Pointer to IPv6 addresses table. */
72531 + uint8_t *p_RdOnlyCommunityStr; /**< Pointer to the Read Only Community String. */
72532 + uint8_t *p_RdWrCommunityStr; /**< Pointer to the Read Write Community String. */
72533 + t_FmPortDsarOidsEntry *p_OidsTbl; /**< Pointer to OIDs table. */
72534 + uint32_t oidsTblSize; /**< Number of entries in OIDs table. */
72535 +} t_FmPortDsarSnmpInfo;
72536 +
72537 +/**************************************************************************//**
72538 + @Description Structure for Deep Sleep Auto Response filtering Entry
72539 +*//***************************************************************************/
72540 +typedef struct t_FmPortDsarFilteringEntry
72541 +{
72542 + uint16_t srcPort;
72543 + uint16_t dstPort;
72544 + uint16_t srcPortMask;
72545 + uint16_t dstPortMask;
72546 +} t_FmPortDsarFilteringEntry;
72547 +
72548 +/**************************************************************************//**
72549 + @Description Structure for Deep Sleep Auto Response filtering info
72550 +*//***************************************************************************/
72551 +typedef struct t_FmPortDsarFilteringInfo
72552 +{
72553 + /* IP protocol filtering parameters */
72554 + uint8_t ipProtTableSize;
72555 + uint8_t *p_IpProtTablePtr;
72556 + bool ipProtPassOnHit; /* when TRUE, miss in the table will cause the packet to be droped,
72557 + hit will pass the packet to UDP/TCP filters if needed and if not
72558 + to the classification tree. If the classification tree will pass
72559 + the packet to a queue it will cause a wake interupt.
72560 + When FALSE it the other way around. */
72561 + /* UDP port filtering parameters */
72562 + uint8_t udpPortsTableSize;
72563 + t_FmPortDsarFilteringEntry *p_UdpPortsTablePtr;
72564 + bool udpPortPassOnHit; /* when TRUE, miss in the table will cause the packet to be droped,
72565 + hit will pass the packet to classification tree.
72566 + If the classification tree will pass the packet to a queue it
72567 + will cause a wake interupt.
72568 + When FALSE it the other way around. */
72569 + /* TCP port filtering parameters */
72570 + uint16_t tcpFlagsMask;
72571 + uint8_t tcpPortsTableSize;
72572 + t_FmPortDsarFilteringEntry *p_TcpPortsTablePtr;
72573 + bool tcpPortPassOnHit; /* when TRUE, miss in the table will cause the packet to be droped,
72574 + hit will pass the packet to classification tree.
72575 + If the classification tree will pass the packet to a queue it
72576 + will cause a wake interupt.
72577 + When FALSE it the other way around. */
72578 +} t_FmPortDsarFilteringInfo;
72579 +
72580 +/**************************************************************************//**
72581 + @Description Structure for Deep Sleep Auto Response parameters
72582 +*//***************************************************************************/
72583 +typedef struct t_FmPortDsarParams
72584 +{
72585 + t_Handle h_FmPortTx;
72586 + t_FmPortDsarArpInfo *p_AutoResArpInfo;
72587 + t_FmPortDsarEchoIpv4Info *p_AutoResEchoIpv4Info;
72588 + t_FmPortDsarNdpInfo *p_AutoResNdpInfo;
72589 + t_FmPortDsarEchoIpv6Info *p_AutoResEchoIpv6Info;
72590 + t_FmPortDsarSnmpInfo *p_AutoResSnmpInfo;
72591 + t_FmPortDsarFilteringInfo *p_AutoResFilteringInfo;
72592 +} t_FmPortDsarParams;
72593 +
72594 +/**************************************************************************//**
72595 + @Function FM_PORT_EnterDsar
72596 +
72597 + @Description Enter Deep Sleep Auto Response mode.
72598 + This function write the apropriate values to in the relevant
72599 + tables in the MURAM.
72600 +
72601 + @Param[in] h_FmPortRx - FM PORT module descriptor
72602 + @Param[in] params - Auto Response parameters
72603 +
72604 + @Return E_OK on success; Error code otherwise.
72605 +
72606 + @Cautions Allowed only following FM_PORT_Init().
72607 +*//***************************************************************************/
72608 +t_Error FM_PORT_EnterDsar(t_Handle h_FmPortRx, t_FmPortDsarParams *params);
72609 +
72610 +/**************************************************************************//**
72611 + @Function FM_PORT_EnterDsarFinal
72612 +
72613 + @Description Enter Deep Sleep Auto Response mode.
72614 + This function sets the Tx port in independent mode as needed
72615 + and redirect the receive flow to go through the
72616 + Dsar Fman-ctrl code
72617 +
72618 + @Param[in] h_DsarRxPort - FM Rx PORT module descriptor
72619 + @Param[in] h_DsarTxPort - FM Tx PORT module descriptor
72620 +
72621 + @Return E_OK on success; Error code otherwise.
72622 +
72623 + @Cautions Allowed only following FM_PORT_Init().
72624 +*//***************************************************************************/
72625 +t_Error FM_PORT_EnterDsarFinal(t_Handle h_DsarRxPort, t_Handle h_DsarTxPort);
72626 +
72627 +/**************************************************************************//**
72628 + @Function FM_PORT_ExitDsar
72629 +
72630 + @Description Exit Deep Sleep Auto Response mode.
72631 + This function reverse the AR mode and put the ports back into
72632 + their original wake mode
72633 +
72634 + @Param[in] h_FmPortRx - FM PORT Rx module descriptor
72635 + @Param[in] h_FmPortTx - FM PORT Tx module descriptor
72636 +
72637 + @Return E_OK on success; Error code otherwise.
72638 +
72639 + @Cautions Allowed only following FM_PORT_EnterDsar().
72640 +*//***************************************************************************/
72641 +void FM_PORT_ExitDsar(t_Handle h_FmPortRx, t_Handle h_FmPortTx);
72642 +
72643 +/**************************************************************************//**
72644 + @Function FM_PORT_IsInDsar
72645 +
72646 + @Description This function returns TRUE if the port was set as Auto Response
72647 + and FALSE if not. Once Exit AR mode it will return FALSE as well
72648 + until re-enabled once more.
72649 +
72650 + @Param[in] h_FmPort - FM PORT module descriptor
72651 +
72652 + @Return E_OK on success; Error code otherwise.
72653 +*//***************************************************************************/
72654 +bool FM_PORT_IsInDsar(t_Handle h_FmPort);
72655 +
72656 +typedef struct t_FmPortDsarStats
72657 +{
72658 + uint32_t arpArCnt;
72659 + uint32_t echoIcmpv4ArCnt;
72660 + uint32_t ndpArCnt;
72661 + uint32_t echoIcmpv6ArCnt;
72662 + uint32_t snmpGetCnt;
72663 + uint32_t snmpGetNextCnt;
72664 +} t_FmPortDsarStats;
72665 +
72666 +/**************************************************************************//**
72667 + @Function FM_PORT_GetDsarStats
72668 +
72669 + @Description Return statistics for Deep Sleep Auto Response
72670 +
72671 + @Param[in] h_FmPortRx - FM PORT module descriptor
72672 + @Param[out] stats - structure containing the statistics counters
72673 +
72674 + @Return E_OK on success; Error code otherwise.
72675 +*//***************************************************************************/
72676 +t_Error FM_PORT_GetDsarStats(t_Handle h_FmPortRx, t_FmPortDsarStats *stats);
72677 +
72678 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
72679 +/**************************************************************************//**
72680 + @Function FM_PORT_DumpRegs
72681 +
72682 + @Description Dump all regs.
72683 +
72684 + Calling this routine invalidates the descriptor.
72685 +
72686 + @Param[in] h_FmPort - FM PORT module descriptor
72687 +
72688 + @Return E_OK on success; Error code otherwise.
72689 +
72690 + @Cautions Allowed only following FM_PORT_Init().
72691 +*//***************************************************************************/
72692 +t_Error FM_PORT_DumpRegs(t_Handle h_FmPort);
72693 +#endif /* (defined(DEBUG_ERRORS) && ... */
72694 +
72695 +/**************************************************************************//**
72696 + @Function FM_PORT_GetBufferDataOffset
72697 +
72698 + @Description Relevant for Rx ports.
72699 + Returns the data offset from the beginning of the data buffer
72700 +
72701 + @Param[in] h_FmPort - FM PORT module descriptor
72702 +
72703 + @Return data offset.
72704 +
72705 + @Cautions Allowed only following FM_PORT_Init().
72706 +*//***************************************************************************/
72707 +uint32_t FM_PORT_GetBufferDataOffset(t_Handle h_FmPort);
72708 +
72709 +/**************************************************************************//**
72710 + @Function FM_PORT_GetBufferICInfo
72711 +
72712 + @Description Returns the Internal Context offset from the beginning of the data buffer
72713 +
72714 + @Param[in] h_FmPort - FM PORT module descriptor
72715 + @Param[in] p_Data - A pointer to the data buffer.
72716 +
72717 + @Return Internal context info pointer on success, NULL if 'allOtherInfo' was not
72718 + configured for this port.
72719 +
72720 + @Cautions Allowed only following FM_PORT_Init().
72721 +*//***************************************************************************/
72722 +uint8_t * FM_PORT_GetBufferICInfo(t_Handle h_FmPort, char *p_Data);
72723 +
72724 +/**************************************************************************//**
72725 + @Function FM_PORT_GetBufferPrsResult
72726 +
72727 + @Description Returns the pointer to the parse result in the data buffer.
72728 + In Rx ports this is relevant after reception, if parse
72729 + result is configured to be part of the data passed to the
72730 + application. For non Rx ports it may be used to get the pointer
72731 + of the area in the buffer where parse result should be
72732 + initialized - if so configured.
72733 + See FM_PORT_ConfigBufferPrefixContent for data buffer prefix
72734 + configuration.
72735 +
72736 + @Param[in] h_FmPort - FM PORT module descriptor
72737 + @Param[in] p_Data - A pointer to the data buffer.
72738 +
72739 + @Return Parse result pointer on success, NULL if parse result was not
72740 + configured for this port.
72741 +
72742 + @Cautions Allowed only following FM_PORT_Init().
72743 +*//***************************************************************************/
72744 +t_FmPrsResult * FM_PORT_GetBufferPrsResult(t_Handle h_FmPort, char *p_Data);
72745 +
72746 +/**************************************************************************//**
72747 + @Function FM_PORT_GetBufferTimeStamp
72748 +
72749 + @Description Returns the time stamp in the data buffer.
72750 + Relevant for Rx ports for getting the buffer time stamp.
72751 + See FM_PORT_ConfigBufferPrefixContent for data buffer prefix
72752 + configuration.
72753 +
72754 + @Param[in] h_FmPort - FM PORT module descriptor
72755 + @Param[in] p_Data - A pointer to the data buffer.
72756 +
72757 + @Return A pointer to the hash result on success, NULL otherwise.
72758 +
72759 + @Cautions Allowed only following FM_PORT_Init().
72760 +*//***************************************************************************/
72761 +uint64_t * FM_PORT_GetBufferTimeStamp(t_Handle h_FmPort, char *p_Data);
72762 +
72763 +/**************************************************************************//**
72764 + @Function FM_PORT_GetBufferHashResult
72765 +
72766 + @Description Given a data buffer, on the condition that hash result was defined
72767 + as a part of the buffer content (see FM_PORT_ConfigBufferPrefixContent)
72768 + this routine will return the pointer to the hash result location in the
72769 + buffer prefix.
72770 +
72771 + @Param[in] h_FmPort - FM PORT module descriptor
72772 + @Param[in] p_Data - A pointer to the data buffer.
72773 +
72774 + @Return A pointer to the hash result on success, NULL otherwise.
72775 +
72776 + @Cautions Allowed only following FM_PORT_Init().
72777 +*//***************************************************************************/
72778 +uint8_t * FM_PORT_GetBufferHashResult(t_Handle h_FmPort, char *p_Data);
72779 +
72780 +/**************************************************************************//**
72781 + @Function FM_PORT_Disable
72782 +
72783 + @Description Gracefully disable an FM port. The port will not start new tasks after all
72784 + tasks associated with the port are terminated.
72785 +
72786 + @Param[in] h_FmPort A handle to a FM Port module.
72787 +
72788 + @Return E_OK on success; Error code otherwise.
72789 +
72790 + @Cautions Allowed only following FM_PORT_Init().
72791 + This is a blocking routine, it returns after port is
72792 + gracefully stopped, i.e. the port will not except new frames,
72793 + but it will finish all frames or tasks which were already began
72794 +*//***************************************************************************/
72795 +t_Error FM_PORT_Disable(t_Handle h_FmPort);
72796 +
72797 +/**************************************************************************//**
72798 + @Function FM_PORT_Enable
72799 +
72800 + @Description A runtime routine provided to allow disable/enable of port.
72801 +
72802 + @Param[in] h_FmPort A handle to a FM Port module.
72803 +
72804 + @Return E_OK on success; Error code otherwise.
72805 +
72806 + @Cautions Allowed only following FM_PORT_Init().
72807 +*//***************************************************************************/
72808 +t_Error FM_PORT_Enable(t_Handle h_FmPort);
72809 +
72810 +/**************************************************************************//**
72811 + @Function FM_PORT_SetRateLimit
72812 +
72813 + @Description Calling this routine enables rate limit algorithm.
72814 + By default, this functionality is disabled.
72815 + Note that rate-limit mechanism uses the FM time stamp.
72816 + The selected rate limit specified here would be
72817 + rounded DOWN to the nearest 16M.
72818 +
72819 + May be used for Tx and OP ports only
72820 +
72821 + @Param[in] h_FmPort A handle to a FM Port module.
72822 + @Param[in] p_RateLimit A structure of rate limit parameters
72823 +
72824 + @Return E_OK on success; Error code otherwise.
72825 +
72826 + @Cautions Allowed only following FM_PORT_Init().
72827 + If rate limit is set on a port that need to send PFC frames,
72828 + it might violate the stop transmit timing.
72829 +*//***************************************************************************/
72830 +t_Error FM_PORT_SetRateLimit(t_Handle h_FmPort, t_FmPortRateLimit *p_RateLimit);
72831 +
72832 +/**************************************************************************//**
72833 + @Function FM_PORT_DeleteRateLimit
72834 +
72835 + @Description Calling this routine disables and clears rate limit
72836 + initialization.
72837 +
72838 + May be used for Tx and OP ports only
72839 +
72840 + @Param[in] h_FmPort A handle to a FM Port module.
72841 +
72842 + @Return E_OK on success; Error code otherwise.
72843 +
72844 + @Cautions Allowed only following FM_PORT_Init().
72845 +*//***************************************************************************/
72846 +t_Error FM_PORT_DeleteRateLimit(t_Handle h_FmPort);
72847 +
72848 +/**************************************************************************//**
72849 + @Function FM_PORT_SetPfcPrioritiesMappingToQmanWQ
72850 +
72851 + @Description Calling this routine maps each PFC received priority to the transmit WQ.
72852 + This WQ will be blocked upon receiving a PFC frame with this priority.
72853 +
72854 + May be used for Tx ports only.
72855 +
72856 + @Param[in] h_FmPort A handle to a FM Port module.
72857 + @Param[in] prio PFC priority (0-7).
72858 + @Param[in] wq Work Queue (0-7).
72859 +
72860 + @Return E_OK on success; Error code otherwise.
72861 +
72862 + @Cautions Allowed only following FM_PORT_Init().
72863 +*//***************************************************************************/
72864 +t_Error FM_PORT_SetPfcPrioritiesMappingToQmanWQ(t_Handle h_FmPort, uint8_t prio, uint8_t wq);
72865 +
72866 +/**************************************************************************//**
72867 + @Function FM_PORT_SetStatisticsCounters
72868 +
72869 + @Description Calling this routine enables/disables port's statistics counters.
72870 + By default, counters are enabled.
72871 +
72872 + May be used for all port types
72873 +
72874 + @Param[in] h_FmPort A handle to a FM Port module.
72875 + @Param[in] enable TRUE to enable, FALSE to disable.
72876 +
72877 + @Return E_OK on success; Error code otherwise.
72878 +
72879 + @Cautions Allowed only following FM_PORT_Init().
72880 +*//***************************************************************************/
72881 +t_Error FM_PORT_SetStatisticsCounters(t_Handle h_FmPort, bool enable);
72882 +
72883 +/**************************************************************************//**
72884 + @Function FM_PORT_SetFrameQueueCounters
72885 +
72886 + @Description Calling this routine enables/disables port's enqueue/dequeue counters.
72887 + By default, counters are enabled.
72888 +
72889 + May be used for all ports
72890 +
72891 + @Param[in] h_FmPort A handle to a FM Port module.
72892 + @Param[in] enable TRUE to enable, FALSE to disable.
72893 +
72894 + @Return E_OK on success; Error code otherwise.
72895 +
72896 + @Cautions Allowed only following FM_PORT_Init().
72897 +*//***************************************************************************/
72898 +t_Error FM_PORT_SetFrameQueueCounters(t_Handle h_FmPort, bool enable);
72899 +
72900 +/**************************************************************************//**
72901 + @Function FM_PORT_AnalyzePerformanceParams
72902 +
72903 + @Description User may call this routine to so the driver will analyze if the
72904 + basic performance parameters are correct and also the driver may
72905 + suggest of improvements; The basic parameters are FIFO sizes, number
72906 + of DMAs and number of TNUMs for the port.
72907 +
72908 + May be used for all port types
72909 +
72910 + @Param[in] h_FmPort A handle to a FM Port module.
72911 +
72912 + @Return E_OK on success; Error code otherwise.
72913 +
72914 + @Cautions Allowed only following FM_PORT_Init().
72915 +*//***************************************************************************/
72916 +t_Error FM_PORT_AnalyzePerformanceParams(t_Handle h_FmPort);
72917 +
72918 +
72919 +/**************************************************************************//**
72920 + @Function FM_PORT_SetAllocBufCounter
72921 +
72922 + @Description Calling this routine enables/disables BM pool allocate
72923 + buffer counters.
72924 + By default, counters are enabled.
72925 +
72926 + May be used for Rx ports only
72927 +
72928 + @Param[in] h_FmPort A handle to a FM Port module.
72929 + @Param[in] poolId BM pool id.
72930 + @Param[in] enable TRUE to enable, FALSE to disable.
72931 +
72932 + @Return E_OK on success; Error code otherwise.
72933 +
72934 + @Cautions Allowed only following FM_PORT_Init().
72935 +*//***************************************************************************/
72936 +t_Error FM_PORT_SetAllocBufCounter(t_Handle h_FmPort, uint8_t poolId, bool enable);
72937 +
72938 +/**************************************************************************//**
72939 + @Function FM_PORT_GetBmiCounters
72940 +
72941 + @Description Read port's BMI stat counters and place them into
72942 + a designated structure of counters.
72943 +
72944 + @Param[in] h_FmPort A handle to a FM Port module.
72945 + @Param[out] p_BmiStats counters structure
72946 +
72947 + @Return E_OK on success; Error code otherwise.
72948 +
72949 + @Cautions Allowed only following FM_PORT_Init().
72950 +*//***************************************************************************/
72951 +t_Error FM_PORT_GetBmiCounters(t_Handle h_FmPort, t_FmPortBmiStats *p_BmiStats);
72952 +
72953 +/**************************************************************************//**
72954 + @Function FM_PORT_GetCounter
72955 +
72956 + @Description Reads one of the FM PORT counters.
72957 +
72958 + @Param[in] h_FmPort A handle to a FM Port module.
72959 + @Param[in] fmPortCounter The requested counter.
72960 +
72961 + @Return Counter's current value.
72962 +
72963 + @Cautions Allowed only following FM_PORT_Init().
72964 + Note that it is user's responsibility to call this routine only
72965 + for enabled counters, and there will be no indication if a
72966 + disabled counter is accessed.
72967 +*//***************************************************************************/
72968 +uint32_t FM_PORT_GetCounter(t_Handle h_FmPort, e_FmPortCounters fmPortCounter);
72969 +
72970 +/**************************************************************************//**
72971 + @Function FM_PORT_ModifyCounter
72972 +
72973 + @Description Sets a value to an enabled counter. Use "0" to reset the counter.
72974 +
72975 + @Param[in] h_FmPort A handle to a FM Port module.
72976 + @Param[in] fmPortCounter The requested counter.
72977 + @Param[in] value The requested value to be written into the counter.
72978 +
72979 + @Return E_OK on success; Error code otherwise.
72980 +
72981 + @Cautions Allowed only following FM_PORT_Init().
72982 +*//***************************************************************************/
72983 +t_Error FM_PORT_ModifyCounter(t_Handle h_FmPort, e_FmPortCounters fmPortCounter, uint32_t value);
72984 +
72985 +/**************************************************************************//**
72986 + @Function FM_PORT_GetAllocBufCounter
72987 +
72988 + @Description Reads one of the FM PORT buffer counters.
72989 +
72990 + @Param[in] h_FmPort A handle to a FM Port module.
72991 + @Param[in] poolId The requested pool.
72992 +
72993 + @Return Counter's current value.
72994 +
72995 + @Cautions Allowed only following FM_PORT_Init().
72996 + Note that it is user's responsibility to call this routine only
72997 + for enabled counters, and there will be no indication if a
72998 + disabled counter is accessed.
72999 +*//***************************************************************************/
73000 +uint32_t FM_PORT_GetAllocBufCounter(t_Handle h_FmPort, uint8_t poolId);
73001 +
73002 +/**************************************************************************//**
73003 + @Function FM_PORT_ModifyAllocBufCounter
73004 +
73005 + @Description Sets a value to an enabled counter. Use "0" to reset the counter.
73006 +
73007 + @Param[in] h_FmPort A handle to a FM Port module.
73008 + @Param[in] poolId The requested pool.
73009 + @Param[in] value The requested value to be written into the counter.
73010 +
73011 + @Return E_OK on success; Error code otherwise.
73012 +
73013 + @Cautions Allowed only following FM_PORT_Init().
73014 +*//***************************************************************************/
73015 +t_Error FM_PORT_ModifyAllocBufCounter(t_Handle h_FmPort, uint8_t poolId, uint32_t value);
73016 +
73017 +/**************************************************************************//**
73018 + @Function FM_PORT_AddCongestionGrps
73019 +
73020 + @Description This routine effects the corresponding Tx port.
73021 + It should be called in order to enable pause
73022 + frame transmission in case of congestion in one or more
73023 + of the congestion groups relevant to this port.
73024 + Each call to this routine may add one or more congestion
73025 + groups to be considered relevant to this port.
73026 +
73027 + May be used for Rx, or RX+OP ports only (depending on chip)
73028 +
73029 + @Param[in] h_FmPort A handle to a FM Port module.
73030 + @Param[in] p_CongestionGrps A pointer to an array of congestion groups
73031 + id's to consider.
73032 +
73033 + @Return E_OK on success; Error code otherwise.
73034 +
73035 + @Cautions Allowed only following FM_PORT_Init().
73036 +*//***************************************************************************/
73037 +t_Error FM_PORT_AddCongestionGrps(t_Handle h_FmPort, t_FmPortCongestionGrps *p_CongestionGrps);
73038 +
73039 +/**************************************************************************//**
73040 + @Function FM_PORT_RemoveCongestionGrps
73041 +
73042 + @Description This routine effects the corresponding Tx port. It should be
73043 + called when congestion groups were
73044 + defined for this port and are no longer relevant, or pause
73045 + frames transmitting is not required on their behalf.
73046 + Each call to this routine may remove one or more congestion
73047 + groups to be considered relevant to this port.
73048 +
73049 + May be used for Rx, or RX+OP ports only (depending on chip)
73050 +
73051 + @Param[in] h_FmPort A handle to a FM Port module.
73052 + @Param[in] p_CongestionGrps A pointer to an array of congestion groups
73053 + id's to consider.
73054 +
73055 + @Return E_OK on success; Error code otherwise.
73056 +
73057 + @Cautions Allowed only following FM_PORT_Init().
73058 +*//***************************************************************************/
73059 +t_Error FM_PORT_RemoveCongestionGrps(t_Handle h_FmPort, t_FmPortCongestionGrps *p_CongestionGrps);
73060 +
73061 +/**************************************************************************//**
73062 + @Function FM_PORT_IsStalled
73063 +
73064 + @Description A routine for checking whether the specified port is stalled.
73065 +
73066 + @Param[in] h_FmPort A handle to a FM Port module.
73067 +
73068 + @Return TRUE if port is stalled, FALSE otherwize
73069 +
73070 + @Cautions Allowed only following FM_PORT_Init().
73071 +*//***************************************************************************/
73072 +bool FM_PORT_IsStalled(t_Handle h_FmPort);
73073 +
73074 +/**************************************************************************//**
73075 + @Function FM_PORT_ReleaseStalled
73076 +
73077 + @Description This routine may be called in case the port was stalled and may
73078 + now be released.
73079 + Note that this routine is available only on older FMan revisions
73080 + (FMan v2, DPAA v1.0 only).
73081 +
73082 + @Param[in] h_FmPort A handle to a FM Port module.
73083 +
73084 + @Return E_OK on success; Error code otherwise.
73085 +
73086 + @Cautions Allowed only following FM_PORT_Init().
73087 +*//***************************************************************************/
73088 +t_Error FM_PORT_ReleaseStalled(t_Handle h_FmPort);
73089 +
73090 +/**************************************************************************//**
73091 + @Function FM_PORT_SetRxL4ChecksumVerify
73092 +
73093 + @Description This routine is relevant for Rx ports (1G and 10G). The routine
73094 + set/clear the L3/L4 checksum verification (on RX side).
73095 + Note that this takes affect only if hw-parser is enabled!
73096 +
73097 + @Param[in] h_FmPort A handle to a FM Port module.
73098 + @Param[in] l4Checksum boolean indicates whether to do L3/L4 checksum
73099 + on frames or not.
73100 +
73101 + @Return E_OK on success; Error code otherwise.
73102 +
73103 + @Cautions Allowed only following FM_PORT_Init().
73104 +*//***************************************************************************/
73105 +t_Error FM_PORT_SetRxL4ChecksumVerify(t_Handle h_FmPort, bool l4Checksum);
73106 +
73107 +/**************************************************************************//**
73108 + @Function FM_PORT_SetErrorsRoute
73109 +
73110 + @Description Errors selected for this routine will cause a frame with that error
73111 + to be enqueued to error queue.
73112 + Errors not selected for this routine will cause a frame with that error
73113 + to be enqueued to the one of the other port queues.
73114 + By default all errors are defined to be enqueued to error queue.
73115 + Errors that were configured to be discarded (at initialization)
73116 + may not be selected here.
73117 +
73118 + May be used for Rx and OP ports only
73119 +
73120 + @Param[in] h_FmPort A handle to a FM Port module.
73121 + @Param[in] errs A list of errors to enqueue to error queue
73122 +
73123 + @Return E_OK on success; Error code otherwise.
73124 +
73125 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
73126 +*//***************************************************************************/
73127 +t_Error FM_PORT_SetErrorsRoute(t_Handle h_FmPort, fmPortFrameErrSelect_t errs);
73128 +
73129 +/**************************************************************************//**
73130 + @Function FM_PORT_SetIMExceptions
73131 +
73132 + @Description Calling this routine enables/disables FM PORT interrupts.
73133 +
73134 + @Param[in] h_FmPort FM PORT module descriptor.
73135 + @Param[in] exception The exception to be selected.
73136 + @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
73137 +
73138 + @Return E_OK on success; Error code otherwise.
73139 +
73140 + @Cautions Allowed only following FM_PORT_Init().
73141 + This routine should NOT be called from guest-partition
73142 + (i.e. guestId != NCSW_MASTER_ID)
73143 +*//***************************************************************************/
73144 +t_Error FM_PORT_SetIMExceptions(t_Handle h_FmPort, e_FmPortExceptions exception, bool enable);
73145 +
73146 +/**************************************************************************//*
73147 + @Function FM_PORT_SetPerformanceCounters
73148 +
73149 + @Description Calling this routine enables/disables port's performance counters.
73150 + By default, counters are enabled.
73151 +
73152 + May be used for all port types
73153 +
73154 + @Param[in] h_FmPort A handle to a FM Port module.
73155 + @Param[in] enable TRUE to enable, FALSE to disable.
73156 +
73157 + @Return E_OK on success; Error code otherwise.
73158 +
73159 + @Cautions Allowed only following FM_PORT_Init().
73160 +*//***************************************************************************/
73161 +t_Error FM_PORT_SetPerformanceCounters(t_Handle h_FmPort, bool enable);
73162 +
73163 +/**************************************************************************//*
73164 + @Function FM_PORT_SetPerformanceCountersParams
73165 +
73166 + @Description Calling this routine defines port's performance
73167 + counters parameters.
73168 +
73169 + May be used for all port types
73170 +
73171 + @Param[in] h_FmPort A handle to a FM Port module.
73172 + @Param[in] p_FmPortPerformanceCnt A pointer to a structure of performance
73173 + counters parameters.
73174 +
73175 + @Return E_OK on success; Error code otherwise.
73176 +
73177 + @Cautions Allowed only following FM_PORT_Init().
73178 +*//***************************************************************************/
73179 +t_Error FM_PORT_SetPerformanceCountersParams(t_Handle h_FmPort, t_FmPortPerformanceCnt *p_FmPortPerformanceCnt);
73180 +
73181 +/**************************************************************************//**
73182 + @Group FM_PORT_pcd_runtime_control_grp FM Port PCD Runtime Control Unit
73183 +
73184 + @Description FM Port PCD Runtime control unit API functions, definitions and enums.
73185 +
73186 + @{
73187 +*//***************************************************************************/
73188 +
73189 +/**************************************************************************//**
73190 + @Description A structure defining the KG scheme after the parser.
73191 + This is relevant only to change scheme selection mode - from
73192 + direct to indirect and vice versa, or when the scheme is selected directly,
73193 + to select the scheme id.
73194 +
73195 +*//***************************************************************************/
73196 +typedef struct t_FmPcdKgSchemeSelect {
73197 + bool direct; /**< TRUE to use 'h_Scheme' directly, FALSE to use LCV. */
73198 + t_Handle h_DirectScheme; /**< Scheme handle, selects the scheme after parser;
73199 + Relevant only when 'direct' is TRUE. */
73200 +} t_FmPcdKgSchemeSelect;
73201 +
73202 +/**************************************************************************//**
73203 + @Description A structure of scheme parameters
73204 +*//***************************************************************************/
73205 +typedef struct t_FmPcdPortSchemesParams {
73206 + uint8_t numOfSchemes; /**< Number of schemes for port to be bound to. */
73207 + t_Handle h_Schemes[FM_PCD_KG_NUM_OF_SCHEMES]; /**< Array of 'numOfSchemes' schemes for the
73208 + port to be bound to */
73209 +} t_FmPcdPortSchemesParams;
73210 +
73211 +/**************************************************************************//**
73212 + @Description Union for defining port protocol parameters for parser
73213 +*//***************************************************************************/
73214 +typedef union u_FmPcdHdrPrsOpts {
73215 + /* MPLS */
73216 + struct {
73217 + bool labelInterpretationEnable; /**< When this bit is set, the last MPLS label will be
73218 + interpreted as described in HW spec table. When the bit
73219 + is cleared, the parser will advance to MPLS next parse */
73220 + e_NetHeaderType nextParse; /**< must be equal or higher than IPv4 */
73221 + } mplsPrsOptions;
73222 + /* VLAN */
73223 + struct {
73224 + uint16_t tagProtocolId1; /**< User defined Tag Protocol Identifier, to be recognized
73225 + on VLAN TAG on top of 0x8100 and 0x88A8 */
73226 + uint16_t tagProtocolId2; /**< User defined Tag Protocol Identifier, to be recognized
73227 + on VLAN TAG on top of 0x8100 and 0x88A8 */
73228 + } vlanPrsOptions;
73229 + /* PPP */
73230 + struct{
73231 + bool enableMTUCheck; /**< Check validity of MTU according to RFC2516 */
73232 + } pppoePrsOptions;
73233 +
73234 + /* IPV6 */
73235 + struct{
73236 + bool routingHdrEnable; /**< TRUE to enable routing header, otherwise ignore */
73237 + } ipv6PrsOptions;
73238 +
73239 + /* UDP */
73240 + struct{
73241 + bool padIgnoreChecksum; /**< TRUE to ignore pad in checksum */
73242 + } udpPrsOptions;
73243 +
73244 + /* TCP */
73245 + struct {
73246 + bool padIgnoreChecksum; /**< TRUE to ignore pad in checksum */
73247 + } tcpPrsOptions;
73248 +} u_FmPcdHdrPrsOpts;
73249 +
73250 +/**************************************************************************//**
73251 + @Description A structure for defining each header for the parser
73252 +*//***************************************************************************/
73253 +typedef struct t_FmPcdPrsAdditionalHdrParams {
73254 + e_NetHeaderType hdr; /**< Selected header; use HEADER_TYPE_NONE
73255 + to indicate that sw parser is to run first
73256 + (before HW parser, and independent of the
73257 + existence of any protocol), in this case,
73258 + swPrsEnable must be set, and all other
73259 + parameters are irrelevant. */
73260 + bool errDisable; /**< TRUE to disable error indication */
73261 + bool swPrsEnable; /**< Enable jump to SW parser when this
73262 + header is recognized by the HW parser. */
73263 + uint8_t indexPerHdr; /**< Normally 0, if more than one sw parser
73264 + attachments exists for the same header,
73265 + (in the main sw parser code) use this
73266 + index to distinguish between them. */
73267 + bool usePrsOpts; /**< TRUE to use parser options. */
73268 + u_FmPcdHdrPrsOpts prsOpts; /**< A union according to header type,
73269 + defining the parser options selected.*/
73270 +} t_FmPcdPrsAdditionalHdrParams;
73271 +
73272 +/**************************************************************************//**
73273 + @Description struct for defining port PCD parameters
73274 +*//***************************************************************************/
73275 +typedef struct t_FmPortPcdPrsParams {
73276 + uint8_t prsResultPrivateInfo; /**< The private info provides a method of inserting
73277 + port information into the parser result. This information
73278 + may be extracted by Keygen and be used for frames
73279 + distribution when a per-port distinction is required,
73280 + it may also be used as a port logical id for analyzing
73281 + incoming frames. */
73282 + uint8_t parsingOffset; /**< Number of bytes from beginning of packet to start parsing */
73283 + e_NetHeaderType firstPrsHdr; /**< The type of the first header expected at 'parsingOffset' */
73284 + bool includeInPrsStatistics; /**< TRUE to include this port in the parser statistics;
73285 + NOTE: this field is not valid when the FM is in "guest" mode
73286 + and IPC is not available. */
73287 + uint8_t numOfHdrsWithAdditionalParams; /**< Normally 0, some headers may get
73288 + special parameters */
73289 + t_FmPcdPrsAdditionalHdrParams additionalParams[FM_PCD_PRS_NUM_OF_HDRS];
73290 + /**< 'numOfHdrsWithAdditionalParams' structures
73291 + of additional parameters
73292 + for each header that requires them */
73293 + bool setVlanTpid1; /**< TRUE to configure user selection of Ethertype to
73294 + indicate a VLAN tag (in addition to the TPID values
73295 + 0x8100 and 0x88A8). */
73296 + uint16_t vlanTpid1; /**< extra tag to use if setVlanTpid1=TRUE. */
73297 + bool setVlanTpid2; /**< TRUE to configure user selection of Ethertype to
73298 + indicate a VLAN tag (in addition to the TPID values
73299 + 0x8100 and 0x88A8). */
73300 + uint16_t vlanTpid2; /**< extra tag to use if setVlanTpid1=TRUE. */
73301 +} t_FmPortPcdPrsParams;
73302 +
73303 +/**************************************************************************//**
73304 + @Description struct for defining coarse alassification parameters
73305 +*//***************************************************************************/
73306 +typedef struct t_FmPortPcdCcParams {
73307 + t_Handle h_CcTree; /**< A handle to a CC tree */
73308 +} t_FmPortPcdCcParams;
73309 +
73310 +/**************************************************************************//**
73311 + @Description struct for defining keygen parameters
73312 +*//***************************************************************************/
73313 +typedef struct t_FmPortPcdKgParams {
73314 + uint8_t numOfSchemes; /**< Number of schemes for port to be bound to. */
73315 + t_Handle h_Schemes[FM_PCD_KG_NUM_OF_SCHEMES];
73316 + /**< Array of 'numOfSchemes' schemes handles for the
73317 + port to be bound to */
73318 + bool directScheme; /**< TRUE for going from parser to a specific scheme,
73319 + regardless of parser result */
73320 + t_Handle h_DirectScheme; /**< relevant only if direct == TRUE, Scheme handle,
73321 + as returned by FM_PCD_KgSetScheme */
73322 +} t_FmPortPcdKgParams;
73323 +
73324 +/**************************************************************************//**
73325 + @Description struct for defining policer parameters
73326 +*//***************************************************************************/
73327 +typedef struct t_FmPortPcdPlcrParams {
73328 + t_Handle h_Profile; /**< Selected profile handle */
73329 +} t_FmPortPcdPlcrParams;
73330 +
73331 +/**************************************************************************//**
73332 + @Description struct for defining port PCD parameters
73333 +*//***************************************************************************/
73334 +typedef struct t_FmPortPcdParams {
73335 + e_FmPortPcdSupport pcdSupport; /**< Relevant for Rx and offline ports only.
73336 + Describes the active PCD engines for this port. */
73337 + t_Handle h_NetEnv; /**< HL Unused in PLCR only mode */
73338 + t_FmPortPcdPrsParams *p_PrsParams; /**< Parser parameters for this port */
73339 + t_FmPortPcdCcParams *p_CcParams; /**< Coarse classification parameters for this port */
73340 + t_FmPortPcdKgParams *p_KgParams; /**< Keygen parameters for this port */
73341 + t_FmPortPcdPlcrParams *p_PlcrParams; /**< Policer parameters for this port; Relevant for one of
73342 + following cases:
73343 + e_FM_PORT_PCD_SUPPORT_PLCR_ONLY or
73344 + e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR were selected,
73345 + or if any flow uses a KG scheme were policer
73346 + profile is not generated
73347 + ('bypassPlcrProfileGeneration selected'). */
73348 + t_Handle h_IpReassemblyManip; /**< IP Reassembly manipulation */
73349 +#if (DPAA_VERSION >= 11)
73350 + t_Handle h_CapwapReassemblyManip;/**< CAPWAP Reassembly manipulation */
73351 +#endif /* (DPAA_VERSION >= 11) */
73352 +} t_FmPortPcdParams;
73353 +
73354 +/**************************************************************************//**
73355 + @Description A structure for defining the Parser starting point
73356 +*//***************************************************************************/
73357 +typedef struct t_FmPcdPrsStart {
73358 + uint8_t parsingOffset; /**< Number of bytes from beginning of packet to
73359 + start parsing */
73360 + e_NetHeaderType firstPrsHdr; /**< The type of the first header axpected at
73361 + 'parsingOffset' */
73362 +} t_FmPcdPrsStart;
73363 +
73364 +#if (DPAA_VERSION >= 11)
73365 +/**************************************************************************//**
73366 + @Description struct for defining external buffer margins
73367 +*//***************************************************************************/
73368 +typedef struct t_FmPortVSPAllocParams {
73369 + uint8_t numOfProfiles; /**< Number of Virtual Storage Profiles; must be a power of 2 */
73370 + uint8_t dfltRelativeId; /**< The default Virtual-Storage-Profile-id dedicated to Rx/OP port
73371 + The same default Virtual-Storage-Profile-id will be for coupled Tx port
73372 + if relevant function called for Rx port */
73373 + t_Handle h_FmTxPort; /**< Handle to coupled Tx Port; not relevant for OP port. */
73374 +} t_FmPortVSPAllocParams;
73375 +#endif /* (DPAA_VERSION >= 11) */
73376 +
73377 +
73378 +/**************************************************************************//**
73379 + @Function FM_PORT_SetPCD
73380 +
73381 + @Description Calling this routine defines the port's PCD configuration.
73382 + It changes it from its default configuration which is PCD
73383 + disabled (BMI to BMI) and configures it according to the passed
73384 + parameters.
73385 +
73386 + May be used for Rx and OP ports only
73387 +
73388 + @Param[in] h_FmPort A handle to a FM Port module.
73389 + @Param[in] p_FmPortPcd A Structure of parameters defining the port's PCD
73390 + configuration.
73391 +
73392 + @Return E_OK on success; Error code otherwise.
73393 +
73394 + @Cautions Allowed only following FM_PORT_Init().
73395 +*//***************************************************************************/
73396 +t_Error FM_PORT_SetPCD(t_Handle h_FmPort, t_FmPortPcdParams *p_FmPortPcd);
73397 +
73398 +/**************************************************************************//**
73399 + @Function FM_PORT_DeletePCD
73400 +
73401 + @Description Calling this routine releases the port's PCD configuration.
73402 + The port returns to its default configuration which is PCD
73403 + disabled (BMI to BMI) and all PCD configuration is removed.
73404 +
73405 + May be used for Rx and OP ports which are
73406 + in PCD mode only
73407 +
73408 + @Param[in] h_FmPort A handle to a FM Port module.
73409 +
73410 + @Return E_OK on success; Error code otherwise.
73411 +
73412 + @Cautions Allowed only following FM_PORT_Init().
73413 +*//***************************************************************************/
73414 +t_Error FM_PORT_DeletePCD(t_Handle h_FmPort);
73415 +
73416 +/**************************************************************************//**
73417 + @Function FM_PORT_AttachPCD
73418 +
73419 + @Description This routine may be called after FM_PORT_DetachPCD was called,
73420 + to return to the originally configured PCD support flow.
73421 + The couple of routines are used to allow PCD configuration changes
73422 + that demand that PCD will not be used while changes take place.
73423 +
73424 + May be used for Rx and OP ports which are
73425 + in PCD mode only
73426 +
73427 + @Param[in] h_FmPort A handle to a FM Port module.
73428 +
73429 + @Return E_OK on success; Error code otherwise.
73430 +
73431 + @Cautions Allowed only following FM_PORT_Init().
73432 +*//***************************************************************************/
73433 +t_Error FM_PORT_AttachPCD(t_Handle h_FmPort);
73434 +
73435 +/**************************************************************************//**
73436 + @Function FM_PORT_DetachPCD
73437 +
73438 + @Description Calling this routine detaches the port from its PCD functionality.
73439 + The port returns to its default flow which is BMI to BMI.
73440 +
73441 + May be used for Rx and OP ports which are
73442 + in PCD mode only
73443 +
73444 + @Param[in] h_FmPort A handle to a FM Port module.
73445 +
73446 + @Return E_OK on success; Error code otherwise.
73447 +
73448 + @Cautions Allowed only following FM_PORT_AttachPCD().
73449 +*//***************************************************************************/
73450 +t_Error FM_PORT_DetachPCD(t_Handle h_FmPort);
73451 +
73452 +/**************************************************************************//**
73453 + @Function FM_PORT_PcdPlcrAllocProfiles
73454 +
73455 + @Description This routine may be called only for ports that use the Policer in
73456 + order to allocate private policer profiles.
73457 +
73458 + @Param[in] h_FmPort A handle to a FM Port module.
73459 + @Param[in] numOfProfiles The number of required policer profiles
73460 +
73461 + @Return E_OK on success; Error code otherwise.
73462 +
73463 + @Cautions Allowed only following FM_PORT_Init() and FM_PCD_Init(),
73464 + and before FM_PORT_SetPCD().
73465 +*//***************************************************************************/
73466 +t_Error FM_PORT_PcdPlcrAllocProfiles(t_Handle h_FmPort, uint16_t numOfProfiles);
73467 +
73468 +/**************************************************************************//**
73469 + @Function FM_PORT_PcdPlcrFreeProfiles
73470 +
73471 + @Description This routine should be called for freeing private policer profiles.
73472 +
73473 + @Param[in] h_FmPort A handle to a FM Port module.
73474 +
73475 + @Return E_OK on success; Error code otherwise.
73476 +
73477 + @Cautions Allowed only following FM_PORT_Init() and FM_PCD_Init(),
73478 + and before FM_PORT_SetPCD().
73479 +*//***************************************************************************/
73480 +t_Error FM_PORT_PcdPlcrFreeProfiles(t_Handle h_FmPort);
73481 +
73482 +#if (DPAA_VERSION >= 11)
73483 +/**************************************************************************//**
73484 + @Function FM_PORT_VSPAlloc
73485 +
73486 + @Description This routine allocated VSPs per port and forces the port to work
73487 + in VSP mode. Note that the port is initialized by default with the
73488 + physical-storage-profile only.
73489 +
73490 + @Param[in] h_FmPort A handle to a FM Port module.
73491 + @Param[in] p_Params A structure of parameters for allocation VSP's per port
73492 +
73493 + @Return E_OK on success; Error code otherwise.
73494 +
73495 + @Cautions Allowed only following FM_PORT_Init(), and before FM_PORT_SetPCD()
73496 + and also before FM_PORT_Enable(); i.e. the port should be disabled.
73497 +*//***************************************************************************/
73498 +t_Error FM_PORT_VSPAlloc(t_Handle h_FmPort, t_FmPortVSPAllocParams *p_Params);
73499 +#endif /* (DPAA_VERSION >= 11) */
73500 +
73501 +/**************************************************************************//**
73502 + @Function FM_PORT_PcdKgModifyInitialScheme
73503 +
73504 + @Description This routine may be called only for ports that use the keygen in
73505 + order to change the initial scheme frame should be routed to.
73506 + The change may be of a scheme id (in case of direct mode),
73507 + from direct to indirect, or from indirect to direct - specifying the scheme id.
73508 +
73509 + @Param[in] h_FmPort A handle to a FM Port module.
73510 + @Param[in] p_FmPcdKgScheme A structure of parameters for defining whether
73511 + a scheme is direct/indirect, and if direct - scheme id.
73512 +
73513 + @Return E_OK on success; Error code otherwise.
73514 +
73515 + @Cautions Allowed only following FM_PORT_Init() and FM_PORT_SetPCD().
73516 +*//***************************************************************************/
73517 +t_Error FM_PORT_PcdKgModifyInitialScheme (t_Handle h_FmPort, t_FmPcdKgSchemeSelect *p_FmPcdKgScheme);
73518 +
73519 +/**************************************************************************//**
73520 + @Function FM_PORT_PcdPlcrModifyInitialProfile
73521 +
73522 + @Description This routine may be called for ports with flows
73523 + e_FM_PORT_PCD_SUPPORT_PLCR_ONLY or e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR
73524 + only, to change the initial Policer profile frame should be
73525 + routed to. The change may be of a profile and/or absolute/direct
73526 + mode selection.
73527 +
73528 + @Param[in] h_FmPort A handle to a FM Port module.
73529 + @Param[in] h_Profile Policer profile handle
73530 +
73531 + @Return E_OK on success; Error code otherwise.
73532 +
73533 + @Cautions Allowed only following FM_PORT_Init() and FM_PORT_SetPCD().
73534 +*//***************************************************************************/
73535 +t_Error FM_PORT_PcdPlcrModifyInitialProfile (t_Handle h_FmPort, t_Handle h_Profile);
73536 +
73537 +/**************************************************************************//**
73538 + @Function FM_PORT_PcdCcModifyTree
73539 +
73540 + @Description This routine may be called for ports that use coarse classification tree
73541 + if the user wishes to replace the tree. The routine may not be called while port
73542 + receives packets using the PCD functionalities, therefor port must be first detached
73543 + from the PCD, only than the routine may be called, and than port be attached to PCD again.
73544 +
73545 + @Param[in] h_FmPort A handle to a FM Port module.
73546 + @Param[in] h_CcTree A CC tree that was already built. The tree id as returned from
73547 + the BuildTree routine.
73548 +
73549 + @Return E_OK on success; Error code otherwise.
73550 +
73551 + @Cautions Allowed only following FM_PORT_Init(), FM_PORT_SetPCD() and FM_PORT_DetachPCD()
73552 +*//***************************************************************************/
73553 +t_Error FM_PORT_PcdCcModifyTree (t_Handle h_FmPort, t_Handle h_CcTree);
73554 +
73555 +/**************************************************************************//**
73556 + @Function FM_PORT_PcdKgBindSchemes
73557 +
73558 + @Description These routines may be called for adding more schemes for the
73559 + port to be bound to. The selected schemes are not added,
73560 + just this specific port starts using them.
73561 +
73562 + @Param[in] h_FmPort A handle to a FM Port module.
73563 + @Param[in] p_PortScheme A structure defining the list of schemes to be added.
73564 +
73565 + @Return E_OK on success; Error code otherwise.
73566 +
73567 + @Cautions Allowed only following FM_PORT_Init() and FM_PORT_SetPCD().
73568 +*//***************************************************************************/
73569 +t_Error FM_PORT_PcdKgBindSchemes (t_Handle h_FmPort, t_FmPcdPortSchemesParams *p_PortScheme);
73570 +
73571 +/**************************************************************************//**
73572 + @Function FM_PORT_PcdKgUnbindSchemes
73573 +
73574 + @Description These routines may be called for adding more schemes for the
73575 + port to be bound to. The selected schemes are not removed or invalidated,
73576 + just this specific port stops using them.
73577 +
73578 + @Param[in] h_FmPort A handle to a FM Port module.
73579 + @Param[in] p_PortScheme A structure defining the list of schemes to be added.
73580 +
73581 + @Return E_OK on success; Error code otherwise.
73582 +
73583 + @Cautions Allowed only following FM_PORT_Init() and FM_PORT_SetPCD().
73584 +*//***************************************************************************/
73585 +t_Error FM_PORT_PcdKgUnbindSchemes (t_Handle h_FmPort, t_FmPcdPortSchemesParams *p_PortScheme);
73586 +
73587 +/**************************************************************************//**
73588 + @Function FM_PORT_GetIPv4OptionsCount
73589 +
73590 + @Description TODO
73591 +
73592 + @Param[in] h_FmPort A handle to a FM Port module.
73593 + @Param[out] p_Ipv4OptionsCount will hold the counter value
73594 +
73595 + @Return E_OK on success; Error code otherwise.
73596 +
73597 + @Cautions Allowed only following FM_PORT_Init()
73598 +*//***************************************************************************/
73599 +t_Error FM_PORT_GetIPv4OptionsCount(t_Handle h_FmPort, uint32_t *p_Ipv4OptionsCount);
73600 +
73601 +/** @} */ /* end of FM_PORT_pcd_runtime_control_grp group */
73602 +/** @} */ /* end of FM_PORT_runtime_control_grp group */
73603 +
73604 +
73605 +/**************************************************************************//**
73606 + @Group FM_PORT_runtime_data_grp FM Port Runtime Data-path Unit
73607 +
73608 + @Description FM Port Runtime data unit API functions, definitions and enums.
73609 + This API is valid only if working in Independent-Mode.
73610 +
73611 + @{
73612 +*//***************************************************************************/
73613 +
73614 +/**************************************************************************//**
73615 + @Function FM_PORT_ImTx
73616 +
73617 + @Description Tx function, called to transmit a data buffer on the port.
73618 +
73619 + @Param[in] h_FmPort A handle to a FM Port module.
73620 + @Param[in] p_Data A pointer to an LCP data buffer.
73621 + @Param[in] length Size of data for transmission.
73622 + @Param[in] lastBuffer Buffer position - TRUE for the last buffer
73623 + of a frame, including a single buffer frame
73624 + @Param[in] h_BufContext A handle of the user acossiated with this buffer
73625 +
73626 + @Return E_OK on success; Error code otherwise.
73627 +
73628 + @Cautions Allowed only following FM_PORT_Init().
73629 + NOTE - This routine can be used only when working in
73630 + Independent-Mode mode.
73631 +*//***************************************************************************/
73632 +t_Error FM_PORT_ImTx( t_Handle h_FmPort,
73633 + uint8_t *p_Data,
73634 + uint16_t length,
73635 + bool lastBuffer,
73636 + t_Handle h_BufContext);
73637 +
73638 +/**************************************************************************//**
73639 + @Function FM_PORT_ImTxConf
73640 +
73641 + @Description Tx port confirmation routine, optional, may be called to verify
73642 + transmission of all frames. The procedure performed by this
73643 + routine will be performed automatically on next buffer transmission,
73644 + but if desired, calling this routine will invoke this action on
73645 + demand.
73646 +
73647 + @Param[in] h_FmPort A handle to a FM Port module.
73648 +
73649 + @Cautions Allowed only following FM_PORT_Init().
73650 + NOTE - This routine can be used only when working in
73651 + Independent-Mode mode.
73652 +*//***************************************************************************/
73653 +void FM_PORT_ImTxConf(t_Handle h_FmPort);
73654 +
73655 +/**************************************************************************//**
73656 + @Function FM_PORT_ImRx
73657 +
73658 + @Description Rx function, may be called to poll for received buffers.
73659 + Normally, Rx process is invoked by the driver on Rx interrupt.
73660 + Alternatively, this routine may be called on demand.
73661 +
73662 + @Param[in] h_FmPort A handle to a FM Port module.
73663 +
73664 + @Return E_OK on success; Error code otherwise.
73665 +
73666 + @Cautions Allowed only following FM_PORT_Init().
73667 + NOTE - This routine can be used only when working in
73668 + Independent-Mode mode.
73669 +*//***************************************************************************/
73670 +t_Error FM_PORT_ImRx(t_Handle h_FmPort);
73671 +
73672 +/** @} */ /* end of FM_PORT_runtime_data_grp group */
73673 +/** @} */ /* end of FM_PORT_grp group */
73674 +/** @} */ /* end of FM_grp group */
73675 +
73676 +
73677 +
73678 +#ifdef NCSW_BACKWARD_COMPATIBLE_API
73679 +#define FM_PORT_ConfigTxFifoDeqPipelineDepth FM_PORT_ConfigFifoDeqPipelineDepth
73680 +#endif /* NCSW_BACKWARD_COMPATIBLE_API */
73681 +
73682 +
73683 +#endif /* __FM_PORT_EXT */
73684 --- /dev/null
73685 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_rtc_ext.h
73686 @@ -0,0 +1,619 @@
73687 +/*
73688 + * Copyright 2008-2012 Freescale Semiconductor Inc.
73689 + *
73690 + * Redistribution and use in source and binary forms, with or without
73691 + * modification, are permitted provided that the following conditions are met:
73692 + * * Redistributions of source code must retain the above copyright
73693 + * notice, this list of conditions and the following disclaimer.
73694 + * * Redistributions in binary form must reproduce the above copyright
73695 + * notice, this list of conditions and the following disclaimer in the
73696 + * documentation and/or other materials provided with the distribution.
73697 + * * Neither the name of Freescale Semiconductor nor the
73698 + * names of its contributors may be used to endorse or promote products
73699 + * derived from this software without specific prior written permission.
73700 + *
73701 + *
73702 + * ALTERNATIVELY, this software may be distributed under the terms of the
73703 + * GNU General Public License ("GPL") as published by the Free Software
73704 + * Foundation, either version 2 of that License or (at your option) any
73705 + * later version.
73706 + *
73707 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
73708 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
73709 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
73710 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
73711 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
73712 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
73713 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
73714 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
73715 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
73716 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
73717 + */
73718 +
73719 +
73720 +/**************************************************************************//**
73721 + @File fm_rtc_ext.h
73722 +
73723 + @Description External definitions and API for FM RTC IEEE1588 Timer Module.
73724 +
73725 + @Cautions None.
73726 +*//***************************************************************************/
73727 +
73728 +#ifndef __FM_RTC_EXT_H__
73729 +#define __FM_RTC_EXT_H__
73730 +
73731 +
73732 +#include "error_ext.h"
73733 +#include "std_ext.h"
73734 +#include "fsl_fman_rtc.h"
73735 +
73736 +/**************************************************************************//**
73737 +
73738 + @Group FM_grp Frame Manager API
73739 +
73740 + @Description FM API functions, definitions and enums
73741 +
73742 + @{
73743 +*//***************************************************************************/
73744 +
73745 +/**************************************************************************//**
73746 + @Group fm_rtc_grp FM RTC
73747 +
73748 + @Description FM RTC functions, definitions and enums.
73749 +
73750 + @{
73751 +*//***************************************************************************/
73752 +
73753 +/**************************************************************************//**
73754 + @Group fm_rtc_init_grp FM RTC Initialization Unit
73755 +
73756 + @Description FM RTC initialization API.
73757 +
73758 + @{
73759 +*//***************************************************************************/
73760 +
73761 +/**************************************************************************//**
73762 + @Description FM RTC Alarm Polarity Options.
73763 +*//***************************************************************************/
73764 +typedef enum e_FmRtcAlarmPolarity
73765 +{
73766 + e_FM_RTC_ALARM_POLARITY_ACTIVE_HIGH = E_FMAN_RTC_ALARM_POLARITY_ACTIVE_HIGH, /**< Active-high output polarity */
73767 + e_FM_RTC_ALARM_POLARITY_ACTIVE_LOW = E_FMAN_RTC_ALARM_POLARITY_ACTIVE_LOW /**< Active-low output polarity */
73768 +} e_FmRtcAlarmPolarity;
73769 +
73770 +/**************************************************************************//**
73771 + @Description FM RTC Trigger Polarity Options.
73772 +*//***************************************************************************/
73773 +typedef enum e_FmRtcTriggerPolarity
73774 +{
73775 + e_FM_RTC_TRIGGER_ON_RISING_EDGE = E_FMAN_RTC_TRIGGER_ON_RISING_EDGE, /**< Trigger on rising edge */
73776 + e_FM_RTC_TRIGGER_ON_FALLING_EDGE = E_FMAN_RTC_TRIGGER_ON_FALLING_EDGE /**< Trigger on falling edge */
73777 +} e_FmRtcTriggerPolarity;
73778 +
73779 +/**************************************************************************//**
73780 + @Description IEEE1588 Timer Module FM RTC Optional Clock Sources.
73781 +*//***************************************************************************/
73782 +typedef enum e_FmSrcClock
73783 +{
73784 + e_FM_RTC_SOURCE_CLOCK_EXTERNAL = E_FMAN_RTC_SOURCE_CLOCK_EXTERNAL, /**< external high precision timer reference clock */
73785 + e_FM_RTC_SOURCE_CLOCK_SYSTEM = E_FMAN_RTC_SOURCE_CLOCK_SYSTEM, /**< MAC system clock */
73786 + e_FM_RTC_SOURCE_CLOCK_OSCILATOR = E_FMAN_RTC_SOURCE_CLOCK_OSCILATOR /**< RTC clock oscilator */
73787 +}e_FmSrcClk;
73788 +
73789 +/**************************************************************************//**
73790 + @Description FM RTC configuration parameters structure.
73791 +
73792 + This structure should be passed to FM_RTC_Config().
73793 +*//***************************************************************************/
73794 +typedef struct t_FmRtcParams
73795 +{
73796 + t_Handle h_Fm; /**< FM Handle*/
73797 + uintptr_t baseAddress; /**< Base address of FM RTC registers */
73798 + t_Handle h_App; /**< A handle to an application layer object; This handle will
73799 + be passed by the driver upon calling the above callbacks */
73800 +} t_FmRtcParams;
73801 +
73802 +
73803 +/**************************************************************************//**
73804 + @Function FM_RTC_Config
73805 +
73806 + @Description Configures the FM RTC module according to user's parameters.
73807 +
73808 + The driver assigns default values to some FM RTC parameters.
73809 + These parameters can be overwritten using the advanced
73810 + configuration routines.
73811 +
73812 + @Param[in] p_FmRtcParam - FM RTC configuration parameters.
73813 +
73814 + @Return Handle to the new FM RTC object; NULL pointer on failure.
73815 +
73816 + @Cautions None
73817 +*//***************************************************************************/
73818 +t_Handle FM_RTC_Config(t_FmRtcParams *p_FmRtcParam);
73819 +
73820 +/**************************************************************************//**
73821 + @Function FM_RTC_Init
73822 +
73823 + @Description Initializes the FM RTC driver and hardware.
73824 +
73825 + @Param[in] h_FmRtc - Handle to FM RTC object.
73826 +
73827 + @Return E_OK on success; Error code otherwise.
73828 +
73829 + @Cautions h_FmRtc must have been previously created using FM_RTC_Config().
73830 +*//***************************************************************************/
73831 +t_Error FM_RTC_Init(t_Handle h_FmRtc);
73832 +
73833 +/**************************************************************************//**
73834 + @Function FM_RTC_Free
73835 +
73836 + @Description Frees the FM RTC object and all allocated resources.
73837 +
73838 + @Param[in] h_FmRtc - Handle to FM RTC object.
73839 +
73840 + @Return E_OK on success; Error code otherwise.
73841 +
73842 + @Cautions h_FmRtc must have been previously created using FM_RTC_Config().
73843 +*//***************************************************************************/
73844 +t_Error FM_RTC_Free(t_Handle h_FmRtc);
73845 +
73846 +
73847 +/**************************************************************************//**
73848 + @Group fm_rtc_adv_config_grp FM RTC Advanced Configuration Unit
73849 +
73850 + @Description FM RTC advanced configuration functions.
73851 +
73852 + @{
73853 +*//***************************************************************************/
73854 +
73855 +/**************************************************************************//**
73856 + @Function FM_RTC_ConfigPeriod
73857 +
73858 + @Description Configures the period of the timestamp if different than
73859 + default [DEFAULT_clockPeriod].
73860 +
73861 + @Param[in] h_FmRtc - Handle to FM RTC object.
73862 + @Param[in] period - Period in nano-seconds.
73863 +
73864 + @Return E_OK on success; Error code otherwise.
73865 +
73866 + @Cautions h_FmRtc must have been previously created using FM_RTC_Config().
73867 +*//***************************************************************************/
73868 +t_Error FM_RTC_ConfigPeriod(t_Handle h_FmRtc, uint32_t period);
73869 +
73870 +/**************************************************************************//**
73871 + @Function FM_RTC_ConfigSourceClock
73872 +
73873 + @Description Configures the source clock of the RTC.
73874 +
73875 + @Param[in] h_FmRtc - Handle to FM RTC object.
73876 + @Param[in] srcClk - Source clock selection.
73877 + @Param[in] freqInMhz - the source-clock frequency (in MHz).
73878 +
73879 + @Return E_OK on success; Error code otherwise.
73880 +
73881 + @Cautions h_FmRtc must have been previously created using FM_RTC_Config().
73882 +*//***************************************************************************/
73883 +t_Error FM_RTC_ConfigSourceClock(t_Handle h_FmRtc,
73884 + e_FmSrcClk srcClk,
73885 + uint32_t freqInMhz);
73886 +
73887 +/**************************************************************************//**
73888 + @Function FM_RTC_ConfigPulseRealignment
73889 +
73890 + @Description Configures the RTC to automatic FIPER pulse realignment in
73891 + response to timer adjustments [DEFAULT_pulseRealign]
73892 +
73893 + In this mode, the RTC clock is identical to the source clock.
73894 + This feature can be useful when the system contains an external
73895 + RTC with inherent frequency compensation.
73896 +
73897 + @Param[in] h_FmRtc - Handle to FM RTC object.
73898 + @Param[in] enable - TRUE to enable automatic realignment.
73899 +
73900 + @Return E_OK on success; Error code otherwise.
73901 +
73902 + @Cautions h_FmRtc must have been previously created using FM_RTC_Config().
73903 +*//***************************************************************************/
73904 +t_Error FM_RTC_ConfigPulseRealignment(t_Handle h_FmRtc, bool enable);
73905 +
73906 +/**************************************************************************//**
73907 + @Function FM_RTC_ConfigFrequencyBypass
73908 +
73909 + @Description Configures the RTC to bypass the frequency compensation
73910 + mechanism. [DEFAULT_bypass]
73911 +
73912 + In this mode, the RTC clock is identical to the source clock.
73913 + This feature can be useful when the system contains an external
73914 + RTC with inherent frequency compensation.
73915 +
73916 + @Param[in] h_FmRtc - Handle to FM RTC object.
73917 + @Param[in] enabled - TRUE to bypass frequency compensation;
73918 + FALSE otherwise.
73919 +
73920 + @Return E_OK on success; Error code otherwise.
73921 +
73922 + @Cautions h_FmRtc must have been previously created using FM_RTC_Config().
73923 +*//***************************************************************************/
73924 +t_Error FM_RTC_ConfigFrequencyBypass(t_Handle h_FmRtc, bool enabled);
73925 +
73926 +/**************************************************************************//**
73927 + @Function FM_RTC_ConfigInvertedInputClockPhase
73928 +
73929 + @Description Configures the RTC to invert the source clock phase on input.
73930 + [DEFAULT_invertInputClkPhase]
73931 +
73932 + @Param[in] h_FmRtc - Handle to FM RTC object.
73933 + @Param[in] inverted - TRUE to invert the source clock phase on input.
73934 + FALSE otherwise.
73935 +
73936 + @Return E_OK on success; Error code otherwise.
73937 +
73938 + @Cautions h_FmRtc must have been previously created using FM_RTC_Config().
73939 +*//***************************************************************************/
73940 +t_Error FM_RTC_ConfigInvertedInputClockPhase(t_Handle h_FmRtc, bool inverted);
73941 +
73942 +/**************************************************************************//**
73943 + @Function FM_RTC_ConfigInvertedOutputClockPhase
73944 +
73945 + @Description Configures the RTC to invert the output clock phase.
73946 + [DEFAULT_invertOutputClkPhase]
73947 +
73948 + @Param[in] h_FmRtc - Handle to FM RTC object.
73949 + @Param[in] inverted - TRUE to invert the output clock phase.
73950 + FALSE otherwise.
73951 +
73952 + @Return E_OK on success; Error code otherwise.
73953 +
73954 + @Cautions h_FmRtc must have been previously created using FM_RTC_Config().
73955 +*//***************************************************************************/
73956 +t_Error FM_RTC_ConfigInvertedOutputClockPhase(t_Handle h_FmRtc, bool inverted);
73957 +
73958 +/**************************************************************************//**
73959 + @Function FM_RTC_ConfigOutputClockDivisor
73960 +
73961 + @Description Configures the divisor for generating the output clock from
73962 + the RTC clock. [DEFAULT_outputClockDivisor]
73963 +
73964 + @Param[in] h_FmRtc - Handle to FM RTC object.
73965 + @Param[in] divisor - Divisor for generation of the output clock.
73966 +
73967 + @Return E_OK on success; Error code otherwise.
73968 +
73969 + @Cautions h_FmRtc must have been previously created using FM_RTC_Config().
73970 +*//***************************************************************************/
73971 +t_Error FM_RTC_ConfigOutputClockDivisor(t_Handle h_FmRtc, uint16_t divisor);
73972 +
73973 +/**************************************************************************//**
73974 + @Function FM_RTC_ConfigAlarmPolarity
73975 +
73976 + @Description Configures the polarity (active-high/active-low) of a specific
73977 + alarm signal. [DEFAULT_alarmPolarity]
73978 +
73979 + @Param[in] h_FmRtc - Handle to FM RTC object.
73980 + @Param[in] alarmId - Alarm ID.
73981 + @Param[in] alarmPolarity - Alarm polarity.
73982 +
73983 + @Return E_OK on success; Error code otherwise.
73984 +
73985 + @Cautions h_FmRtc must have been previously created using FM_RTC_Config().
73986 +*//***************************************************************************/
73987 +t_Error FM_RTC_ConfigAlarmPolarity(t_Handle h_FmRtc,
73988 + uint8_t alarmId,
73989 + e_FmRtcAlarmPolarity alarmPolarity);
73990 +
73991 +/**************************************************************************//**
73992 + @Function FM_RTC_ConfigExternalTriggerPolarity
73993 +
73994 + @Description Configures the polarity (rising/falling edge) of a specific
73995 + external trigger signal. [DEFAULT_triggerPolarity]
73996 +
73997 + @Param[in] h_FmRtc - Handle to FM RTC object.
73998 + @Param[in] triggerId - Trigger ID.
73999 + @Param[in] triggerPolarity - Trigger polarity.
74000 +
74001 + @Return E_OK on success; Error code otherwise.
74002 +
74003 + @Cautions h_FmRtc must have been previously created using FM_RTC_Config().
74004 +*//***************************************************************************/
74005 +t_Error FM_RTC_ConfigExternalTriggerPolarity(t_Handle h_FmRtc,
74006 + uint8_t triggerId,
74007 + e_FmRtcTriggerPolarity triggerPolarity);
74008 +
74009 +/** @} */ /* end of fm_rtc_adv_config_grp */
74010 +/** @} */ /* end of fm_rtc_init_grp */
74011 +
74012 +
74013 +/**************************************************************************//**
74014 + @Group fm_rtc_control_grp FM RTC Control Unit
74015 +
74016 + @Description FM RTC runtime control API.
74017 +
74018 + @{
74019 +*//***************************************************************************/
74020 +
74021 +/**************************************************************************//**
74022 + @Function t_FmRtcExceptionsCallback
74023 +
74024 + @Description Exceptions user callback routine, used for RTC different mechanisms.
74025 +
74026 + @Param[in] h_App - User's application descriptor.
74027 + @Param[in] id - source id.
74028 +*//***************************************************************************/
74029 +typedef void (t_FmRtcExceptionsCallback) ( t_Handle h_App, uint8_t id);
74030 +
74031 +/**************************************************************************//**
74032 + @Description FM RTC alarm parameters.
74033 +*//***************************************************************************/
74034 +typedef struct t_FmRtcAlarmParams {
74035 + uint8_t alarmId; /**< 0 or 1 */
74036 + uint64_t alarmTime; /**< In nanoseconds, the time when the alarm
74037 + should go off - must be a multiple of
74038 + the RTC period */
74039 + t_FmRtcExceptionsCallback *f_AlarmCallback; /**< This routine will be called when RTC
74040 + reaches alarmTime */
74041 + bool clearOnExpiration; /**< TRUE to turn off the alarm once expired. */
74042 +} t_FmRtcAlarmParams;
74043 +
74044 +/**************************************************************************//**
74045 + @Description FM RTC Periodic Pulse parameters.
74046 +*//***************************************************************************/
74047 +typedef struct t_FmRtcPeriodicPulseParams {
74048 + uint8_t periodicPulseId; /**< 0 or 1 */
74049 + uint64_t periodicPulsePeriod; /**< In Nanoseconds. Must be
74050 + a multiple of the RTC period */
74051 + t_FmRtcExceptionsCallback *f_PeriodicPulseCallback; /**< This routine will be called every
74052 + periodicPulsePeriod. */
74053 +} t_FmRtcPeriodicPulseParams;
74054 +
74055 +/**************************************************************************//**
74056 + @Description FM RTC Periodic Pulse parameters.
74057 +*//***************************************************************************/
74058 +typedef struct t_FmRtcExternalTriggerParams {
74059 + uint8_t externalTriggerId; /**< 0 or 1 */
74060 + bool usePulseAsInput; /**< Use the pulse interrupt instead of
74061 + an external signal */
74062 + t_FmRtcExceptionsCallback *f_ExternalTriggerCallback; /**< This routine will be called every
74063 + periodicPulsePeriod. */
74064 +} t_FmRtcExternalTriggerParams;
74065 +
74066 +
74067 +/**************************************************************************//**
74068 + @Function FM_RTC_Enable
74069 +
74070 + @Description Enable the RTC (time count is started).
74071 +
74072 + The user can select to resume the time count from previous
74073 + point, or to restart the time count.
74074 +
74075 + @Param[in] h_FmRtc - Handle to FM RTC object.
74076 + @Param[in] resetClock - Restart the time count from zero.
74077 +
74078 + @Return E_OK on success; Error code otherwise.
74079 +
74080 + @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
74081 +*//***************************************************************************/
74082 +t_Error FM_RTC_Enable(t_Handle h_FmRtc, bool resetClock);
74083 +
74084 +/**************************************************************************//**
74085 + @Function FM_RTC_Disable
74086 +
74087 + @Description Disables the RTC (time count is stopped).
74088 +
74089 + @Param[in] h_FmRtc - Handle to FM RTC object.
74090 +
74091 + @Return E_OK on success; Error code otherwise.
74092 +
74093 + @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
74094 +*//***************************************************************************/
74095 +t_Error FM_RTC_Disable(t_Handle h_FmRtc);
74096 +
74097 +/**************************************************************************//**
74098 + @Function FM_RTC_SetClockOffset
74099 +
74100 + @Description Sets the clock offset (usually relative to another clock).
74101 +
74102 + The user can pass a negative offset value.
74103 +
74104 + @Param[in] h_FmRtc - Handle to FM RTC object.
74105 + @Param[in] offset - New clock offset (in nanoseconds).
74106 +
74107 + @Return E_OK on success; Error code otherwise.
74108 +
74109 + @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
74110 +*//***************************************************************************/
74111 +t_Error FM_RTC_SetClockOffset(t_Handle h_FmRtc, int64_t offset);
74112 +
74113 +/**************************************************************************//**
74114 + @Function FM_RTC_SetAlarm
74115 +
74116 + @Description Schedules an alarm event to a given RTC time.
74117 +
74118 + @Param[in] h_FmRtc - Handle to FM RTC object.
74119 + @Param[in] p_FmRtcAlarmParams - Alarm parameters.
74120 +
74121 + @Return E_OK on success; Error code otherwise.
74122 +
74123 + @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
74124 + Must be called only prior to FM_RTC_Enable().
74125 +*//***************************************************************************/
74126 +t_Error FM_RTC_SetAlarm(t_Handle h_FmRtc, t_FmRtcAlarmParams *p_FmRtcAlarmParams);
74127 +
74128 +/**************************************************************************//**
74129 + @Function FM_RTC_SetPeriodicPulse
74130 +
74131 + @Description Sets a periodic pulse.
74132 +
74133 + @Param[in] h_FmRtc - Handle to FM RTC object.
74134 + @Param[in] p_FmRtcPeriodicPulseParams - Periodic pulse parameters.
74135 +
74136 + @Return E_OK on success; Error code otherwise.
74137 +
74138 + @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
74139 + Must be called only prior to FM_RTC_Enable().
74140 +*//***************************************************************************/
74141 +t_Error FM_RTC_SetPeriodicPulse(t_Handle h_FmRtc, t_FmRtcPeriodicPulseParams *p_FmRtcPeriodicPulseParams);
74142 +
74143 +/**************************************************************************//**
74144 + @Function FM_RTC_ClearPeriodicPulse
74145 +
74146 + @Description Clears a periodic pulse.
74147 +
74148 + @Param[in] h_FmRtc - Handle to FM RTC object.
74149 + @Param[in] periodicPulseId - Periodic pulse id.
74150 +
74151 + @Return E_OK on success; Error code otherwise.
74152 +
74153 + @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
74154 +*//***************************************************************************/
74155 +t_Error FM_RTC_ClearPeriodicPulse(t_Handle h_FmRtc, uint8_t periodicPulseId);
74156 +
74157 +/**************************************************************************//**
74158 + @Function FM_RTC_SetExternalTrigger
74159 +
74160 + @Description Sets an external trigger indication and define a callback
74161 + routine to be called on such event.
74162 +
74163 + @Param[in] h_FmRtc - Handle to FM RTC object.
74164 + @Param[in] p_FmRtcExternalTriggerParams - External Trigger parameters.
74165 +
74166 + @Return E_OK on success; Error code otherwise.
74167 +
74168 + @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
74169 +*//***************************************************************************/
74170 +t_Error FM_RTC_SetExternalTrigger(t_Handle h_FmRtc, t_FmRtcExternalTriggerParams *p_FmRtcExternalTriggerParams);
74171 +
74172 +/**************************************************************************//**
74173 + @Function FM_RTC_ClearExternalTrigger
74174 +
74175 + @Description Clears external trigger indication.
74176 +
74177 + @Param[in] h_FmRtc - Handle to FM RTC object.
74178 + @Param[in] id - External Trigger id.
74179 +
74180 + @Return E_OK on success; Error code otherwise.
74181 +
74182 + @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
74183 +*//***************************************************************************/
74184 +t_Error FM_RTC_ClearExternalTrigger(t_Handle h_FmRtc, uint8_t id);
74185 +
74186 +/**************************************************************************//**
74187 + @Function FM_RTC_GetExternalTriggerTimeStamp
74188 +
74189 + @Description Reads the External Trigger TimeStamp.
74190 +
74191 + @Param[in] h_FmRtc - Handle to FM RTC object.
74192 + @Param[in] triggerId - External Trigger id.
74193 + @Param[out] p_TimeStamp - External Trigger timestamp (in nanoseconds).
74194 +
74195 + @Return E_OK on success; Error code otherwise.
74196 +
74197 + @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
74198 +*//***************************************************************************/
74199 +t_Error FM_RTC_GetExternalTriggerTimeStamp(t_Handle h_FmRtc,
74200 + uint8_t triggerId,
74201 + uint64_t *p_TimeStamp);
74202 +
74203 +/**************************************************************************//**
74204 + @Function FM_RTC_GetCurrentTime
74205 +
74206 + @Description Returns the current RTC time.
74207 +
74208 + @Param[in] h_FmRtc - Handle to FM RTC object.
74209 + @Param[out] p_Ts - returned time stamp (in nanoseconds).
74210 +
74211 + @Return E_OK on success; Error code otherwise.
74212 +
74213 + @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
74214 +*//***************************************************************************/
74215 +t_Error FM_RTC_GetCurrentTime(t_Handle h_FmRtc, uint64_t *p_Ts);
74216 +
74217 +/**************************************************************************//**
74218 + @Function FM_RTC_SetCurrentTime
74219 +
74220 + @Description Sets the current RTC time.
74221 +
74222 + @Param[in] h_FmRtc - Handle to FM RTC object.
74223 + @Param[in] ts - The new time stamp (in nanoseconds).
74224 +
74225 + @Return E_OK on success; Error code otherwise.
74226 +
74227 + @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
74228 +*//***************************************************************************/
74229 +t_Error FM_RTC_SetCurrentTime(t_Handle h_FmRtc, uint64_t ts);
74230 +
74231 +/**************************************************************************//**
74232 + @Function FM_RTC_GetFreqCompensation
74233 +
74234 + @Description Retrieves the frequency compensation value
74235 +
74236 + @Param[in] h_FmRtc - Handle to FM RTC object.
74237 + @Param[out] p_Compensation - A pointer to the returned value of compensation.
74238 +
74239 + @Return E_OK on success; Error code otherwise.
74240 +
74241 + @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
74242 +*//***************************************************************************/
74243 +t_Error FM_RTC_GetFreqCompensation(t_Handle h_FmRtc, uint32_t *p_Compensation);
74244 +
74245 +/**************************************************************************//**
74246 + @Function FM_RTC_SetFreqCompensation
74247 +
74248 + @Description Sets a new frequency compensation value.
74249 +
74250 + @Param[in] h_FmRtc - Handle to FM RTC object.
74251 + @Param[in] freqCompensation - The new frequency compensation value to set.
74252 +
74253 + @Return E_OK on success; Error code otherwise.
74254 +
74255 + @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
74256 +*//***************************************************************************/
74257 +t_Error FM_RTC_SetFreqCompensation(t_Handle h_FmRtc, uint32_t freqCompensation);
74258 +
74259 +#ifdef CONFIG_PTP_1588_CLOCK_DPAA
74260 +/**************************************************************************//**
74261 +*@Function FM_RTC_EnableInterrupt
74262 +*
74263 +*@Description Enable interrupt of FM RTC.
74264 +*
74265 +*@Param[in] h_FmRtc - Handle to FM RTC object.
74266 +*@Param[in] events - Interrupt events.
74267 +*
74268 +*@Return E_OK on success; Error code otherwise.
74269 +*//***************************************************************************/
74270 +t_Error FM_RTC_EnableInterrupt(t_Handle h_FmRtc, uint32_t events);
74271 +
74272 +/**************************************************************************//**
74273 +*@Function FM_RTC_DisableInterrupt
74274 +*
74275 +*@Description Disable interrupt of FM RTC.
74276 +*
74277 +*@Param[in] h_FmRtc - Handle to FM RTC object.
74278 +*@Param[in] events - Interrupt events.
74279 +*
74280 +*@Return E_OK on success; Error code otherwise.
74281 +*//***************************************************************************/
74282 +t_Error FM_RTC_DisableInterrupt(t_Handle h_FmRtc, uint32_t events);
74283 +#endif
74284 +
74285 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
74286 +/**************************************************************************//**
74287 + @Function FM_RTC_DumpRegs
74288 +
74289 + @Description Dumps all FM registers
74290 +
74291 + @Param[in] h_FmRtc A handle to an FM RTC Module.
74292 +
74293 + @Return E_OK on success;
74294 +
74295 + @Cautions Allowed only FM_Init().
74296 +*//***************************************************************************/
74297 +t_Error FM_RTC_DumpRegs(t_Handle h_FmRtc);
74298 +#endif /* (defined(DEBUG_ERRORS) && ... */
74299 +
74300 +/** @} */ /* end of fm_rtc_control_grp */
74301 +/** @} */ /* end of fm_rtc_grp */
74302 +/** @} */ /* end of FM_grp group */
74303 +
74304 +
74305 +#endif /* __FM_RTC_EXT_H__ */
74306 --- /dev/null
74307 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_vsp_ext.h
74308 @@ -0,0 +1,411 @@
74309 +/*
74310 + * Copyright 2008-2012 Freescale Semiconductor Inc.
74311 + *
74312 + * Redistribution and use in source and binary forms, with or without
74313 + * modification, are permitted provided that the following conditions are met:
74314 + * * Redistributions of source code must retain the above copyright
74315 + * notice, this list of conditions and the following disclaimer.
74316 + * * Redistributions in binary form must reproduce the above copyright
74317 + * notice, this list of conditions and the following disclaimer in the
74318 + * documentation and/or other materials provided with the distribution.
74319 + * * Neither the name of Freescale Semiconductor nor the
74320 + * names of its contributors may be used to endorse or promote products
74321 + * derived from this software without specific prior written permission.
74322 + *
74323 + *
74324 + * ALTERNATIVELY, this software may be distributed under the terms of the
74325 + * GNU General Public License ("GPL") as published by the Free Software
74326 + * Foundation, either version 2 of that License or (at your option) any
74327 + * later version.
74328 + *
74329 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
74330 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
74331 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
74332 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
74333 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
74334 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
74335 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
74336 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
74337 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
74338 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74339 + */
74340 +
74341 +
74342 +/**************************************************************************//**
74343 + @File fm_vsp_ext.h
74344 +
74345 + @Description FM Virtual Storage-Profile ...
74346 +*//***************************************************************************/
74347 +#ifndef __FM_VSP_EXT_H
74348 +#define __FM_VSP_EXT_H
74349 +
74350 +#include "std_ext.h"
74351 +#include "error_ext.h"
74352 +#include "string_ext.h"
74353 +#include "debug_ext.h"
74354 +
74355 +#include "fm_ext.h"
74356 +
74357 +
74358 +/**************************************************************************//**
74359 +
74360 + @Group FM_grp Frame Manager API
74361 +
74362 + @Description FM API functions, definitions and enums
74363 +
74364 + @{
74365 +*//***************************************************************************/
74366 +
74367 +/**************************************************************************//**
74368 + @Group FM_VSP_grp FM Virtual-Storage-Profile
74369 +
74370 + @Description FM Virtual-Storage-Profile API
74371 +
74372 + @{
74373 +*//***************************************************************************/
74374 +
74375 +/**************************************************************************//**
74376 + @Group FM_VSP_init_grp FM VSP Initialization Unit
74377 +
74378 + @Description FM VSP initialization API.
74379 +
74380 + @{
74381 +*//***************************************************************************/
74382 +
74383 +/**************************************************************************//**
74384 + @Description Virtual Storage Profile
74385 +*//***************************************************************************/
74386 +typedef struct t_FmVspParams {
74387 + t_Handle h_Fm; /**< A handle to the FM object this VSP related to */
74388 + t_FmExtPools extBufPools; /**< Which external buffer pools are used
74389 + (up to FM_PORT_MAX_NUM_OF_EXT_POOLS), and their sizes.
74390 + parameter associated with Rx / OP port */
74391 + uint16_t liodnOffset; /**< VSP's LIODN offset */
74392 + struct {
74393 + e_FmPortType portType; /**< Port type */
74394 + uint8_t portId; /**< Port Id - relative to type */
74395 + } portParams;
74396 + uint8_t relativeProfileId; /**< VSP Id - relative to VSP's range
74397 + defined in relevant FM object */
74398 +} t_FmVspParams;
74399 +
74400 +
74401 +/**************************************************************************//**
74402 + @Function FM_VSP_Config
74403 +
74404 + @Description Creates descriptor for the FM VSP module.
74405 +
74406 + The routine returns a handle (descriptor) to the FM VSP object.
74407 + This descriptor must be passed as first parameter to all other
74408 + FM VSP function calls.
74409 +
74410 + No actual initialization or configuration of FM hardware is
74411 + done by this routine.
74412 +
74413 +@Param[in] p_FmVspParams Pointer to data structure of parameters
74414 +
74415 + @Retval Handle to FM VSP object, or NULL for Failure.
74416 +*//***************************************************************************/
74417 +t_Handle FM_VSP_Config(t_FmVspParams *p_FmVspParams);
74418 +
74419 +/**************************************************************************//**
74420 + @Function FM_VSP_Init
74421 +
74422 + @Description Initializes the FM VSP module
74423 +
74424 + @Param[in] h_FmVsp - FM VSP module descriptor
74425 +
74426 + @Return E_OK on success; Error code otherwise.
74427 +*//***************************************************************************/
74428 +t_Error FM_VSP_Init(t_Handle h_FmVsp);
74429 +
74430 +/**************************************************************************//**
74431 + @Function FM_VSP_Free
74432 +
74433 + @Description Frees all resources that were assigned to FM VSP module.
74434 +
74435 + Calling this routine invalidates the descriptor.
74436 +
74437 + @Param[in] h_FmVsp - FM VSP module descriptor
74438 +
74439 + @Return E_OK on success; Error code otherwise.
74440 +*//***************************************************************************/
74441 +t_Error FM_VSP_Free(t_Handle h_FmVsp);
74442 +
74443 +
74444 +/**************************************************************************//**
74445 + @Group FM_VSP_adv_config_grp FM VSP Advanced Configuration Unit
74446 +
74447 + @Description FM VSP advanced configuration functions.
74448 +
74449 + @{
74450 +*//***************************************************************************/
74451 +
74452 +/**************************************************************************//**
74453 + @Function FM_VSP_ConfigBufferPrefixContent
74454 +
74455 + @Description Defines the structure, size and content of the application buffer.
74456 +
74457 + The prefix will
74458 + In VSPs defined for Tx ports, if 'passPrsResult', the application
74459 + should set a value to their offsets in the prefix of
74460 + the FM will save the first 'privDataSize', than,
74461 + depending on 'passPrsResult' and 'passTimeStamp', copy parse result
74462 + and timeStamp, and the packet itself (in this order), to the
74463 + application buffer, and to offset.
74464 +
74465 + Calling this routine changes the buffer margins definitions
74466 + in the internal driver data base from its default
74467 + configuration: Data size: [DEFAULT_FM_SP_bufferPrefixContent_privDataSize]
74468 + Pass Parser result: [DEFAULT_FM_SP_bufferPrefixContent_passPrsResult].
74469 + Pass timestamp: [DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp].
74470 +
74471 + @Param[in] h_FmVsp A handle to a FM VSP module.
74472 + @Param[in,out] p_FmBufferPrefixContent A structure of parameters describing the
74473 + structure of the buffer.
74474 + Out parameter: Start margin - offset
74475 + of data from start of external buffer.
74476 +
74477 + @Return E_OK on success; Error code otherwise.
74478 +
74479 + @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
74480 +*//***************************************************************************/
74481 +t_Error FM_VSP_ConfigBufferPrefixContent(t_Handle h_FmVsp,
74482 + t_FmBufferPrefixContent *p_FmBufferPrefixContent);
74483 +
74484 +/**************************************************************************//**
74485 + @Function FM_VSP_ConfigDmaSwapData
74486 +
74487 + @Description Calling this routine changes the DMA swap data parameter
74488 + in the internal driver data base from its default
74489 + configuration [DEFAULT_FM_SP_dmaSwapData]
74490 +
74491 + @Param[in] h_FmVsp A handle to a FM VSP module.
74492 + @Param[in] swapData New selection
74493 +
74494 + @Return E_OK on success; Error code otherwise.
74495 +
74496 + @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
74497 +*//***************************************************************************/
74498 +t_Error FM_VSP_ConfigDmaSwapData(t_Handle h_FmVsp, e_FmDmaSwapOption swapData);
74499 +
74500 +/**************************************************************************//**
74501 + @Function FM_VSP_ConfigDmaIcCacheAttr
74502 +
74503 + @Description Calling this routine changes the internal context cache
74504 + attribute parameter in the internal driver data base
74505 + from its default configuration [DEFAULT_FM_SP_dmaIntContextCacheAttr]
74506 +
74507 + @Param[in] h_FmVsp A handle to a FM VSP module.
74508 + @Param[in] intContextCacheAttr New selection
74509 +
74510 + @Return E_OK on success; Error code otherwise.
74511 +
74512 + @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
74513 +*//***************************************************************************/
74514 +t_Error FM_VSP_ConfigDmaIcCacheAttr(t_Handle h_FmVsp,
74515 + e_FmDmaCacheOption intContextCacheAttr);
74516 +
74517 +/**************************************************************************//**
74518 + @Function FM_VSP_ConfigDmaHdrAttr
74519 +
74520 + @Description Calling this routine changes the header cache
74521 + attribute parameter in the internal driver data base
74522 + from its default configuration [DEFAULT_FM_SP_dmaHeaderCacheAttr]
74523 +
74524 + @Param[in] h_FmVsp A handle to a FM VSP module.
74525 + @Param[in] headerCacheAttr New selection
74526 +
74527 + @Return E_OK on success; Error code otherwise.
74528 +
74529 + @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
74530 +*//***************************************************************************/
74531 +t_Error FM_VSP_ConfigDmaHdrAttr(t_Handle h_FmVsp, e_FmDmaCacheOption headerCacheAttr);
74532 +
74533 +/**************************************************************************//**
74534 + @Function FM_VSP_ConfigDmaScatterGatherAttr
74535 +
74536 + @Description Calling this routine changes the scatter gather cache
74537 + attribute parameter in the internal driver data base
74538 + from its default configuration [DEFAULT_FM_SP_dmaScatterGatherCacheAttr]
74539 +
74540 + @Param[in] h_FmVsp A handle to a FM VSP module.
74541 + @Param[in] scatterGatherCacheAttr New selection
74542 +
74543 + @Return E_OK on success; Error code otherwise.
74544 +
74545 + @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
74546 +*//***************************************************************************/
74547 +t_Error FM_VSP_ConfigDmaScatterGatherAttr(t_Handle h_FmVsp,
74548 + e_FmDmaCacheOption scatterGatherCacheAttr);
74549 +
74550 +/**************************************************************************//**
74551 + @Function FM_VSP_ConfigDmaWriteOptimize
74552 +
74553 + @Description Calling this routine changes the write optimization
74554 + parameter in the internal driver data base
74555 + from its default configuration: optimize = [DEFAULT_FM_SP_dmaWriteOptimize]
74556 +
74557 + @Param[in] h_FmVsp A handle to a FM VSP module.
74558 + @Param[in] optimize TRUE to enable optimization, FALSE for normal operation
74559 +
74560 + @Return E_OK on success; Error code otherwise.
74561 +
74562 + @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
74563 +*//***************************************************************************/
74564 +t_Error FM_VSP_ConfigDmaWriteOptimize(t_Handle h_FmVsp, bool optimize);
74565 +
74566 +/**************************************************************************//**
74567 + @Function FM_VSP_ConfigNoScatherGather
74568 +
74569 + @Description Calling this routine changes the possibility to receive S/G frame
74570 + in the internal driver data base
74571 + from its default configuration: optimize = [DEFAULT_FM_SP_noScatherGather]
74572 +
74573 + @Param[in] h_FmVsp A handle to a FM VSP module.
74574 + @Param[in] noScatherGather TRUE to operate without scatter/gather capability.
74575 +
74576 + @Return E_OK on success; Error code otherwise.
74577 +
74578 + @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
74579 +*//***************************************************************************/
74580 +t_Error FM_VSP_ConfigNoScatherGather(t_Handle h_FmVsp, bool noScatherGather);
74581 +
74582 +/**************************************************************************//**
74583 + @Function FM_VSP_ConfigPoolDepletion
74584 +
74585 + @Description Calling this routine enables pause frame generation depending on the
74586 + depletion status of BM pools. It also defines the conditions to activate
74587 + this functionality. By default, this functionality is disabled.
74588 +
74589 + @Param[in] h_FmVsp A handle to a FM VSP module.
74590 + @Param[in] p_BufPoolDepletion A structure of pool depletion parameters
74591 +
74592 + @Return E_OK on success; Error code otherwise.
74593 +
74594 + @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
74595 +*//***************************************************************************/
74596 +t_Error FM_VSP_ConfigPoolDepletion(t_Handle h_FmVsp, t_FmBufPoolDepletion *p_BufPoolDepletion);
74597 +
74598 +/**************************************************************************//**
74599 + @Function FM_VSP_ConfigBackupPools
74600 +
74601 + @Description Calling this routine allows the configuration of some of the BM pools
74602 + defined for this port as backup pools.
74603 + A pool configured to be a backup pool will be used only if all other
74604 + enabled non-backup pools are depleted.
74605 +
74606 + @Param[in] h_FmVsp A handle to a FM VSP module.
74607 + @Param[in] p_BackupBmPools An array of pool id's. All pools specified here will
74608 + be defined as backup pools.
74609 +
74610 + @Return E_OK on success; Error code otherwise.
74611 +
74612 + @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
74613 +*//***************************************************************************/
74614 +t_Error FM_VSP_ConfigBackupPools(t_Handle h_FmVsp, t_FmBackupBmPools *p_BackupBmPools);
74615 +
74616 +/** @} */ /* end of FM_VSP_adv_config_grp group */
74617 +/** @} */ /* end of FM_VSP_init_grp group */
74618 +
74619 +
74620 +/**************************************************************************//**
74621 + @Group FM_VSP_control_grp FM VSP Control Unit
74622 +
74623 + @Description FM VSP runtime control API.
74624 +
74625 + @{
74626 +*//***************************************************************************/
74627 +
74628 +/**************************************************************************//**
74629 + @Function FM_VSP_GetBufferDataOffset
74630 +
74631 + @Description Relevant for Rx ports.
74632 + Returns the data offset from the beginning of the data buffer
74633 +
74634 + @Param[in] h_FmVsp - FM PORT module descriptor
74635 +
74636 + @Return data offset.
74637 +
74638 + @Cautions Allowed only following FM_VSP_Init().
74639 +*//***************************************************************************/
74640 +uint32_t FM_VSP_GetBufferDataOffset(t_Handle h_FmVsp);
74641 +
74642 +/**************************************************************************//**
74643 + @Function FM_VSP_GetBufferICInfo
74644 +
74645 + @Description Returns the Internal Context offset from the beginning of the data buffer
74646 +
74647 + @Param[in] h_FmVsp - FM PORT module descriptor
74648 + @Param[in] p_Data - A pointer to the data buffer.
74649 +
74650 + @Return Internal context info pointer on success, NULL if 'allOtherInfo' was not
74651 + configured for this port.
74652 +
74653 + @Cautions Allowed only following FM_VSP_Init().
74654 +*//***************************************************************************/
74655 +uint8_t * FM_VSP_GetBufferICInfo(t_Handle h_FmVsp, char *p_Data);
74656 +
74657 +/**************************************************************************//**
74658 + @Function FM_VSP_GetBufferPrsResult
74659 +
74660 + @Description Returns the pointer to the parse result in the data buffer.
74661 + In Rx ports this is relevant after reception, if parse
74662 + result is configured to be part of the data passed to the
74663 + application. For non Rx ports it may be used to get the pointer
74664 + of the area in the buffer where parse result should be
74665 + initialized - if so configured.
74666 + See FM_VSP_ConfigBufferPrefixContent for data buffer prefix
74667 + configuration.
74668 +
74669 + @Param[in] h_FmVsp - FM PORT module descriptor
74670 + @Param[in] p_Data - A pointer to the data buffer.
74671 +
74672 + @Return Parse result pointer on success, NULL if parse result was not
74673 + configured for this port.
74674 +
74675 + @Cautions Allowed only following FM_VSP_Init().
74676 +*//***************************************************************************/
74677 +t_FmPrsResult * FM_VSP_GetBufferPrsResult(t_Handle h_FmVsp, char *p_Data);
74678 +
74679 +/**************************************************************************//**
74680 + @Function FM_VSP_GetBufferTimeStamp
74681 +
74682 + @Description Returns the time stamp in the data buffer.
74683 + Relevant for Rx ports for getting the buffer time stamp.
74684 + See FM_VSP_ConfigBufferPrefixContent for data buffer prefix
74685 + configuration.
74686 +
74687 + @Param[in] h_FmVsp - FM PORT module descriptor
74688 + @Param[in] p_Data - A pointer to the data buffer.
74689 +
74690 + @Return A pointer to the hash result on success, NULL otherwise.
74691 +
74692 + @Cautions Allowed only following FM_VSP_Init().
74693 +*//***************************************************************************/
74694 +uint64_t * FM_VSP_GetBufferTimeStamp(t_Handle h_FmVsp, char *p_Data);
74695 +
74696 +/**************************************************************************//**
74697 + @Function FM_VSP_GetBufferHashResult
74698 +
74699 + @Description Given a data buffer, on the condition that hash result was defined
74700 + as a part of the buffer content (see FM_VSP_ConfigBufferPrefixContent)
74701 + this routine will return the pointer to the hash result location in the
74702 + buffer prefix.
74703 +
74704 + @Param[in] h_FmVsp - FM PORT module descriptor
74705 + @Param[in] p_Data - A pointer to the data buffer.
74706 +
74707 + @Return A pointer to the hash result on success, NULL otherwise.
74708 +
74709 + @Cautions Allowed only following FM_VSP_Init().
74710 +*//***************************************************************************/
74711 +uint8_t * FM_VSP_GetBufferHashResult(t_Handle h_FmVsp, char *p_Data);
74712 +
74713 +
74714 +/** @} */ /* end of FM_VSP_control_grp group */
74715 +/** @} */ /* end of FM_VSP_grp group */
74716 +/** @} */ /* end of FM_grp group */
74717 +
74718 +
74719 +#endif /* __FM_VSP_EXT_H */
74720 --- /dev/null
74721 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/mii_acc_ext.h
74722 @@ -0,0 +1,76 @@
74723 +/*
74724 + * Copyright 2008-2012 Freescale Semiconductor Inc.
74725 + *
74726 + * Redistribution and use in source and binary forms, with or without
74727 + * modification, are permitted provided that the following conditions are met:
74728 + * * Redistributions of source code must retain the above copyright
74729 + * notice, this list of conditions and the following disclaimer.
74730 + * * Redistributions in binary form must reproduce the above copyright
74731 + * notice, this list of conditions and the following disclaimer in the
74732 + * documentation and/or other materials provided with the distribution.
74733 + * * Neither the name of Freescale Semiconductor nor the
74734 + * names of its contributors may be used to endorse or promote products
74735 + * derived from this software without specific prior written permission.
74736 + *
74737 + *
74738 + * ALTERNATIVELY, this software may be distributed under the terms of the
74739 + * GNU General Public License ("GPL") as published by the Free Software
74740 + * Foundation, either version 2 of that License or (at your option) any
74741 + * later version.
74742 + *
74743 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
74744 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
74745 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
74746 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
74747 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
74748 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
74749 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
74750 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
74751 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
74752 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74753 + */
74754 +
74755 +
74756 +
74757 +#ifndef __MII_ACC_EXT_H
74758 +#define __MII_ACC_EXT_H
74759 +
74760 +
74761 +/**************************************************************************//**
74762 + @Function MII_ReadPhyReg
74763 +
74764 + @Description This routine is called to read a specified PHY
74765 + register value.
74766 +
74767 + @Param[in] h_MiiAccess - Handle to MII configuration access registers
74768 + @Param[in] phyAddr - PHY address (0-31).
74769 + @Param[in] reg - PHY register to read
74770 + @Param[out] p_Data - Gets the register value.
74771 +
74772 + @Return Always zero (success).
74773 +*//***************************************************************************/
74774 +int MII_ReadPhyReg(t_Handle h_MiiAccess,
74775 + uint8_t phyAddr,
74776 + uint8_t reg,
74777 + uint16_t *p_Data);
74778 +
74779 +/**************************************************************************//**
74780 + @Function MII_WritePhyReg
74781 +
74782 + @Description This routine is called to write data to a specified PHY
74783 + register.
74784 +
74785 + @Param[in] h_MiiAccess - Handle to MII configuration access registers
74786 + @Param[in] phyAddr - PHY address (0-31).
74787 + @Param[in] reg - PHY register to write
74788 + @Param[in] data - Data to write in register.
74789 +
74790 + @Return Always zero (success).
74791 +*//***************************************************************************/
74792 +int MII_WritePhyReg(t_Handle h_MiiAccess,
74793 + uint8_t phyAddr,
74794 + uint8_t reg,
74795 + uint16_t data);
74796 +
74797 +
74798 +#endif /* __MII_ACC_EXT_H */
74799 --- /dev/null
74800 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/core_ext.h
74801 @@ -0,0 +1,90 @@
74802 +/*
74803 + * Copyright 2008-2012 Freescale Semiconductor Inc.
74804 + *
74805 + * Redistribution and use in source and binary forms, with or without
74806 + * modification, are permitted provided that the following conditions are met:
74807 + * * Redistributions of source code must retain the above copyright
74808 + * notice, this list of conditions and the following disclaimer.
74809 + * * Redistributions in binary form must reproduce the above copyright
74810 + * notice, this list of conditions and the following disclaimer in the
74811 + * documentation and/or other materials provided with the distribution.
74812 + * * Neither the name of Freescale Semiconductor nor the
74813 + * names of its contributors may be used to endorse or promote products
74814 + * derived from this software without specific prior written permission.
74815 + *
74816 + *
74817 + * ALTERNATIVELY, this software may be distributed under the terms of the
74818 + * GNU General Public License ("GPL") as published by the Free Software
74819 + * Foundation, either version 2 of that License or (at your option) any
74820 + * later version.
74821 + *
74822 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
74823 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
74824 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
74825 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
74826 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
74827 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
74828 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
74829 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
74830 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
74831 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74832 + */
74833 +
74834 +
74835 +/**************************************************************************//**
74836 + @File core_ext.h
74837 +
74838 + @Description Generic interface to basic core operations.
74839 +
74840 + The system integrator must ensure that this interface is
74841 + mapped to a specific core implementation, by including the
74842 + appropriate header file.
74843 +*//***************************************************************************/
74844 +#ifndef __CORE_EXT_H
74845 +#define __CORE_EXT_H
74846 +
74847 +#ifdef CONFIG_FMAN_ARM
74848 +#include "arm_ext.h"
74849 +#include <linux/smp.h>
74850 +#else
74851 +#ifdef NCSW_PPC_CORE
74852 +#include "ppc_ext.h"
74853 +#elif defined(NCSW_VXWORKS)
74854 +#include "core_vxw_ext.h"
74855 +#else
74856 +#error "Core is not defined!"
74857 +#endif /* NCSW_CORE */
74858 +
74859 +#if (!defined(CORE_IS_LITTLE_ENDIAN) && !defined(CORE_IS_BIG_ENDIAN))
74860 +#error "Must define core as little-endian or big-endian!"
74861 +#endif /* (!defined(CORE_IS_LITTLE_ENDIAN) && ... */
74862 +
74863 +#ifndef CORE_CACHELINE_SIZE
74864 +#error "Must define the core cache-line size!"
74865 +#endif /* !CORE_CACHELINE_SIZE */
74866 +
74867 +#endif /* CONFIG_FMAN_ARM */
74868 +
74869 +
74870 +/**************************************************************************//**
74871 + @Function CORE_GetId
74872 +
74873 + @Description Returns the core ID in the system.
74874 +
74875 + @Return Core ID.
74876 +*//***************************************************************************/
74877 +uint32_t CORE_GetId(void);
74878 +
74879 +/**************************************************************************//**
74880 + @Function CORE_MemoryBarrier
74881 +
74882 + @Description This routine will cause the core to stop executing any commands
74883 + until all previous memory read/write commands are completely out
74884 + of the core's pipeline.
74885 +
74886 + @Return None.
74887 +*//***************************************************************************/
74888 +void CORE_MemoryBarrier(void);
74889 +#define fsl_mem_core_barrier() CORE_MemoryBarrier()
74890 +
74891 +#endif /* __CORE_EXT_H */
74892 --- /dev/null
74893 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/cores/arm_ext.h
74894 @@ -0,0 +1,55 @@
74895 +/*
74896 + * Copyright 2008-2012 Freescale Semiconductor Inc.
74897 + *
74898 + * Redistribution and use in source and binary forms, with or without
74899 + * modification, are permitted provided that the following conditions are met:
74900 + * * Redistributions of source code must retain the above copyright
74901 + * notice, this list of conditions and the following disclaimer.
74902 + * * Redistributions in binary form must reproduce the above copyright
74903 + * notice, this list of conditions and the following disclaimer in the
74904 + * documentation and/or other materials provided with the distribution.
74905 + * * Neither the name of Freescale Semiconductor nor the
74906 + * names of its contributors may be used to endorse or promote products
74907 + * derived from this software without specific prior written permission.
74908 + *
74909 + *
74910 + * ALTERNATIVELY, this software may be distributed under the terms of the
74911 + * GNU General Public License ("GPL") as published by the Free Software
74912 + * Foundation, either version 2 of that License or (at your option) any
74913 + * later version.
74914 + *
74915 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
74916 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
74917 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
74918 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
74919 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
74920 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
74921 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
74922 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
74923 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
74924 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74925 + */
74926 +
74927 +
74928 +/**************************************************************************//**
74929 + @File arm_ext.h
74930 +
74931 + @Description Core API for ARM cores
74932 +
74933 + These routines must be implemented by each specific PowerPC
74934 + core driver.
74935 +*//***************************************************************************/
74936 +#ifndef __ARM_EXT_H
74937 +#define __ARM_EXT_H
74938 +
74939 +#include "part_ext.h"
74940 +
74941 +
74942 +#define CORE_IS_LITTLE_ENDIAN
74943 +
74944 +static __inline__ void CORE_MemoryBarrier(void)
74945 +{
74946 + mb();
74947 +}
74948 +
74949 +#endif /* __PPC_EXT_H */
74950 --- /dev/null
74951 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/cores/e500v2_ext.h
74952 @@ -0,0 +1,476 @@
74953 +/*
74954 + * Copyright 2008-2012 Freescale Semiconductor Inc.
74955 + *
74956 + * Redistribution and use in source and binary forms, with or without
74957 + * modification, are permitted provided that the following conditions are met:
74958 + * * Redistributions of source code must retain the above copyright
74959 + * notice, this list of conditions and the following disclaimer.
74960 + * * Redistributions in binary form must reproduce the above copyright
74961 + * notice, this list of conditions and the following disclaimer in the
74962 + * documentation and/or other materials provided with the distribution.
74963 + * * Neither the name of Freescale Semiconductor nor the
74964 + * names of its contributors may be used to endorse or promote products
74965 + * derived from this software without specific prior written permission.
74966 + *
74967 + *
74968 + * ALTERNATIVELY, this software may be distributed under the terms of the
74969 + * GNU General Public License ("GPL") as published by the Free Software
74970 + * Foundation, either version 2 of that License or (at your option) any
74971 + * later version.
74972 + *
74973 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
74974 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
74975 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
74976 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
74977 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
74978 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
74979 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
74980 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
74981 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
74982 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74983 + */
74984 +
74985 +
74986 +/**************************************************************************//**
74987 + @File e500v2_ext.h
74988 +
74989 + @Description E500 external definitions prototypes
74990 + This file is not included by the E500
74991 + source file as it is an assembly file. It is used
74992 + only for prototypes exposure, for inclusion
74993 + by user and other modules.
74994 +*//***************************************************************************/
74995 +
74996 +#ifndef __E500V2_EXT_H
74997 +#define __E500V2_EXT_H
74998 +
74999 +#include "std_ext.h"
75000 +
75001 +
75002 +/* Layer 1 Cache Manipulations
75003 + *==============================
75004 + * Should not be called directly by the user.
75005 + */
75006 +void L1DCache_Invalidate (void);
75007 +void L1ICache_Invalidate(void);
75008 +void L1DCache_Enable(void);
75009 +void L1ICache_Enable(void);
75010 +void L1DCache_Disable(void);
75011 +void L1ICache_Disable(void);
75012 +void L1DCache_Flush(void);
75013 +void L1ICache_Flush(void);
75014 +uint32_t L1ICache_IsEnabled(void);
75015 +uint32_t L1DCache_IsEnabled(void);
75016 +/*
75017 + *
75018 + */
75019 +uint32_t L1DCache_LineLock(uint32_t addr);
75020 +uint32_t L1ICache_LineLock(uint32_t addr);
75021 +void L1Cache_BroadCastEnable(void);
75022 +void L1Cache_BroadCastDisable(void);
75023 +
75024 +
75025 +#define CORE_DCacheEnable E500_DCacheEnable
75026 +#define CORE_ICacheEnable E500_ICacheEnable
75027 +#define CORE_DCacheDisable E500_DCacheDisable
75028 +#define CORE_ICacheDisable E500_ICacheDisable
75029 +#define CORE_GetId E500_GetId
75030 +#define CORE_TestAndSet E500_TestAndSet
75031 +#define CORE_MemoryBarrier E500_MemoryBarrier
75032 +#define CORE_InstructionSync E500_InstructionSync
75033 +
75034 +#define CORE_SetDozeMode E500_SetDozeMode
75035 +#define CORE_SetNapMode E500_SetNapMode
75036 +#define CORE_SetSleepMode E500_SetSleepMode
75037 +#define CORE_SetJogMode E500_SetJogMode
75038 +#define CORE_SetDeepSleepMode E500_SetDeepSleepMode
75039 +
75040 +#define CORE_RecoverDozeMode E500_RecoverDozeMode
75041 +#define CORE_RecoverNapMode E500_RecoverNapMode
75042 +#define CORE_RecoverSleepMode E500_RecoverSleepMode
75043 +#define CORE_RecoverJogMode E500_RecoverJogMode
75044 +
75045 +void E500_SetDozeMode(void);
75046 +void E500_SetNapMode(void);
75047 +void E500_SetSleepMode(void);
75048 +void E500_SetJogMode(void);
75049 +t_Error E500_SetDeepSleepMode(uint32_t bptrAddress);
75050 +
75051 +void E500_RecoverDozeMode(void);
75052 +void E500_RecoverNapMode(void);
75053 +void E500_RecoverSleepMode(void);
75054 +void E500_RecoverJogMode(void);
75055 +
75056 +
75057 +/**************************************************************************//**
75058 + @Group E500_id E500 Application Programming Interface
75059 +
75060 + @Description E500 API functions, definitions and enums
75061 +
75062 + @{
75063 +*//***************************************************************************/
75064 +
75065 +/**************************************************************************//**
75066 + @Group E500_init_grp E500 Initialization Unit
75067 +
75068 + @Description E500 initialization unit API functions, definitions and enums
75069 +
75070 + @{
75071 +*//***************************************************************************/
75072 +
75073 +
75074 +/**************************************************************************//**
75075 + @Function E500_DCacheEnable
75076 +
75077 + @Description Enables the data cache for memory pages that are
75078 + not cache inhibited.
75079 +
75080 + @Return None.
75081 +*//***************************************************************************/
75082 +void E500_DCacheEnable(void);
75083 +
75084 +/**************************************************************************//**
75085 + @Function E500_ICacheEnable
75086 +
75087 + @Description Enables the instruction cache for memory pages that are
75088 + not cache inhibited.
75089 +
75090 + @Return None.
75091 +*//***************************************************************************/
75092 +void E500_ICacheEnable(void);
75093 +
75094 +/**************************************************************************//**
75095 + @Function E500_DCacheDisable
75096 +
75097 + @Description Disables the data cache.
75098 +
75099 + @Return None.
75100 +*//***************************************************************************/
75101 +void E500_DCacheDisable(void);
75102 +
75103 +/**************************************************************************//**
75104 + @Function E500_ICacheDisable
75105 +
75106 + @Description Disables the instruction cache.
75107 +
75108 + @Return None.
75109 +*//***************************************************************************/
75110 +void E500_ICacheDisable(void);
75111 +
75112 +/**************************************************************************//**
75113 + @Function E500_DCacheFlush
75114 +
75115 + @Description Flushes the data cache
75116 +
75117 + @Return None.
75118 +*//***************************************************************************/
75119 +void E500_DCacheFlush(void);
75120 +
75121 +/**************************************************************************//**
75122 + @Function E500_ICacheFlush
75123 +
75124 + @Description Flushes the instruction cache.
75125 +
75126 + @Return None.
75127 +*//***************************************************************************/
75128 +void E500_ICacheFlush(void);
75129 +
75130 +/**************************************************************************//**
75131 + @Function E500_DCacheSetStashId
75132 +
75133 + @Description Set Stash Id for data cache
75134 +
75135 + @Param[in] stashId the stash id to be set.
75136 +
75137 + @Return None.
75138 +*//***************************************************************************/
75139 +void E500_DCacheSetStashId(uint8_t stashId);
75140 +
75141 +/**************************************************************************//**
75142 + @Description E500mc L2 Cache Operation Mode
75143 +*//***************************************************************************/
75144 +typedef enum e_E500mcL2CacheMode
75145 +{
75146 + e_L2_CACHE_MODE_DATA_ONLY = 0x00000001, /**< Cache data only */
75147 + e_L2_CACHE_MODE_INST_ONLY = 0x00000002, /**< Cache instructions only */
75148 + e_L2_CACHE_MODE_DATA_AND_INST = 0x00000003 /**< Cache data and instructions */
75149 +} e_E500mcL2CacheMode;
75150 +
75151 +#if defined(CORE_E500MC) || defined(CORE_E5500)
75152 +/**************************************************************************//**
75153 + @Function E500_L2CacheEnable
75154 +
75155 + @Description Enables the cache for memory pages that are not cache inhibited.
75156 +
75157 + @param[in] mode - L2 cache mode: data only, instruction only or instruction and data.
75158 +
75159 + @Return None.
75160 +
75161 + @Cautions This routine must be call only ONCE for both caches. I.e. it is
75162 + not possible to call this routine for i-cache and than to call
75163 + again for d-cache; The second call will override the first one.
75164 +*//***************************************************************************/
75165 +void E500_L2CacheEnable(e_E500mcL2CacheMode mode);
75166 +
75167 +/**************************************************************************//**
75168 + @Function E500_L2CacheDisable
75169 +
75170 + @Description Disables the cache (data instruction or both).
75171 +
75172 + @Return None.
75173 +
75174 +*//***************************************************************************/
75175 +void E500_L2CacheDisable(void);
75176 +
75177 +/**************************************************************************//**
75178 + @Function E500_L2CacheFlush
75179 +
75180 + @Description Flushes the cache.
75181 +
75182 + @Return None.
75183 +*//***************************************************************************/
75184 +void E500_L2CacheFlush(void);
75185 +
75186 +/**************************************************************************//**
75187 + @Function E500_L2SetStashId
75188 +
75189 + @Description Set Stash Id
75190 +
75191 + @Param[in] stashId the stash id to be set.
75192 +
75193 + @Return None.
75194 +*//***************************************************************************/
75195 +void E500_L2SetStashId(uint8_t stashId);
75196 +#endif /* defined(CORE_E500MC) || defined(CORE_E5500) */
75197 +
75198 +#ifdef CORE_E6500
75199 +/**************************************************************************//**
75200 + @Function E6500_L2CacheEnable
75201 +
75202 + @Description Enables the cache for memory pages that are not cache inhibited.
75203 +
75204 + @param[in] mode - L2 cache mode: support data & instruction only.
75205 +
75206 + @Return None.
75207 +
75208 + @Cautions This routine must be call only ONCE for both caches. I.e. it is
75209 + not possible to call this routine for i-cache and than to call
75210 + again for d-cache; The second call will override the first one.
75211 +*//***************************************************************************/
75212 +void E6500_L2CacheEnable(uintptr_t clusterBase);
75213 +
75214 +/**************************************************************************//**
75215 + @Function E6500_L2CacheDisable
75216 +
75217 + @Description Disables the cache (data instruction or both).
75218 +
75219 + @Return None.
75220 +
75221 +*//***************************************************************************/
75222 +void E6500_L2CacheDisable(uintptr_t clusterBase);
75223 +
75224 +/**************************************************************************//**
75225 + @Function E6500_L2CacheFlush
75226 +
75227 + @Description Flushes the cache.
75228 +
75229 + @Return None.
75230 +*//***************************************************************************/
75231 +void E6500_L2CacheFlush(uintptr_t clusterBase);
75232 +
75233 +/**************************************************************************//**
75234 + @Function E6500_L2SetStashId
75235 +
75236 + @Description Set Stash Id
75237 +
75238 + @Param[in] stashId the stash id to be set.
75239 +
75240 + @Return None.
75241 +*//***************************************************************************/
75242 +void E6500_L2SetStashId(uintptr_t clusterBase, uint8_t stashId);
75243 +
75244 +/**************************************************************************//**
75245 + @Function E6500_GetCcsrBase
75246 +
75247 + @Description Obtain SoC CCSR base address
75248 +
75249 + @Param[in] None.
75250 +
75251 + @Return Physical CCSR base address.
75252 +*//***************************************************************************/
75253 +physAddress_t E6500_GetCcsrBase(void);
75254 +#endif /* CORE_E6500 */
75255 +
75256 +/**************************************************************************//**
75257 + @Function E500_AddressBusStreamingEnable
75258 +
75259 + @Description Enables address bus streaming on the CCB.
75260 +
75261 + This setting, along with the ECM streaming configuration
75262 + parameters, enables address bus streaming on the CCB.
75263 +
75264 + @Return None.
75265 +*//***************************************************************************/
75266 +void E500_AddressBusStreamingEnable(void);
75267 +
75268 +/**************************************************************************//**
75269 + @Function E500_AddressBusStreamingDisable
75270 +
75271 + @Description Disables address bus streaming on the CCB.
75272 +
75273 + @Return None.
75274 +*//***************************************************************************/
75275 +void E500_AddressBusStreamingDisable(void);
75276 +
75277 +/**************************************************************************//**
75278 + @Function E500_AddressBroadcastEnable
75279 +
75280 + @Description Enables address broadcast.
75281 +
75282 + The e500 broadcasts cache management instructions (dcbst, dcblc
75283 + (CT = 1), icblc (CT = 1), dcbf, dcbi, mbar, msync, tlbsync, icbi)
75284 + based on ABE. ABE must be set to allow management of external
75285 + L2 caches.
75286 +
75287 + @Return None.
75288 +*//***************************************************************************/
75289 +void E500_AddressBroadcastEnable(void);
75290 +
75291 +/**************************************************************************//**
75292 + @Function E500_AddressBroadcastDisable
75293 +
75294 + @Description Disables address broadcast.
75295 +
75296 + The e500 broadcasts cache management instructions (dcbst, dcblc
75297 + (CT = 1), icblc (CT = 1), dcbf, dcbi, mbar, msync, tlbsync, icbi)
75298 + based on ABE. ABE must be set to allow management of external
75299 + L2 caches.
75300 +
75301 + @Return None.
75302 +*//***************************************************************************/
75303 +void E500_AddressBroadcastDisable(void);
75304 +
75305 +/**************************************************************************//**
75306 + @Function E500_IsTaskletSupported
75307 +
75308 + @Description Checks if tasklets are supported by the e500 interrupt handler.
75309 +
75310 + @Retval TRUE - Tasklets are supported.
75311 + @Retval FALSE - Tasklets are not supported.
75312 +*//***************************************************************************/
75313 +bool E500_IsTaskletSupported(void);
75314 +
75315 +void E500_EnableTimeBase(void);
75316 +void E500_DisableTimeBase(void);
75317 +
75318 +uint64_t E500_GetTimeBaseTime(void);
75319 +
75320 +void E500_GenericIntrInit(void);
75321 +
75322 +t_Error E500_SetIntr(int ppcIntrSrc,
75323 + void (* Isr)(t_Handle handle),
75324 + t_Handle handle);
75325 +
75326 +t_Error E500_ClearIntr(int ppcIntrSrc);
75327 +
75328 +/**************************************************************************//**
75329 + @Function E500_GenericIntrHandler
75330 +
75331 + @Description This is the general e500 interrupt handler.
75332 +
75333 + It is called by the main assembly interrupt handler
75334 + when an exception occurs and no other function has been
75335 + assigned to this exception.
75336 +
75337 + @Param intrEntry - (In) The exception interrupt vector entry.
75338 +*//***************************************************************************/
75339 +void E500_GenericIntrHandler(uint32_t intrEntry);
75340 +
75341 +/**************************************************************************//**
75342 + @Function CriticalIntr
75343 +
75344 + @Description This is the specific critical e500 interrupt handler.
75345 +
75346 + It is called by the main assembly interrupt handler
75347 + when an critical interrupt.
75348 +
75349 + @Param intrEntry - (In) The exception interrupt vector entry.
75350 +*//***************************************************************************/
75351 +void CriticalIntr(uint32_t intrEntry);
75352 +
75353 +
75354 +/**************************************************************************//**
75355 + @Function E500_GetId
75356 +
75357 + @Description Returns the core ID in the system.
75358 +
75359 + @Return Core ID.
75360 +*//***************************************************************************/
75361 +uint32_t E500_GetId(void);
75362 +
75363 +/**************************************************************************//**
75364 + @Function E500_TestAndSet
75365 +
75366 + @Description This routine tries to atomically test-and-set an integer
75367 + in memory to a non-zero value.
75368 +
75369 + The memory will be set only if it is tested as zero, in which
75370 + case the routine returns the new non-zero value; otherwise the
75371 + routine returns zero.
75372 +
75373 + @Param[in] p - pointer to a volatile int in memory, on which test-and-set
75374 + operation should be made.
75375 +
75376 + @Retval Zero - Operation failed - memory was already set.
75377 + @Retval Non-zero - Operation succeeded - memory has been set.
75378 +*//***************************************************************************/
75379 +int E500_TestAndSet(volatile int *p);
75380 +
75381 +/**************************************************************************//**
75382 + @Function E500_MemoryBarrier
75383 +
75384 + @Description This routine will cause the core to stop executing any commands
75385 + until all previous memory read/write commands are completely out
75386 + of the core's pipeline.
75387 +
75388 + @Return None.
75389 +*//***************************************************************************/
75390 +static __inline__ void E500_MemoryBarrier(void)
75391 +{
75392 +#ifndef CORE_E500V2
75393 + __asm__ ("mbar 1");
75394 +#else /* CORE_E500V2 */
75395 + /**** ERRATA WORK AROUND START ****/
75396 + /* ERRATA num: CPU1 */
75397 + /* Description: "mbar MO = 1" instruction fails to order caching-inhibited
75398 + guarded loads and stores. */
75399 +
75400 + /* "msync" instruction is used instead */
75401 +
75402 + __asm__ ("msync");
75403 +
75404 + /**** ERRATA WORK AROUND END ****/
75405 +#endif /* CORE_E500V2 */
75406 +}
75407 +
75408 +/**************************************************************************//**
75409 + @Function E500_InstructionSync
75410 +
75411 + @Description This routine will cause the core to wait for previous instructions
75412 + (including any interrupts they generate) to complete before the
75413 + synchronization command executes, which purges all instructions
75414 + from the processor's pipeline and refetches the next instruction.
75415 +
75416 + @Return None.
75417 +*//***************************************************************************/
75418 +static __inline__ void E500_InstructionSync(void)
75419 +{
75420 + __asm__ ("isync");
75421 +}
75422 +
75423 +
75424 +/** @} */ /* end of E500_init_grp group */
75425 +/** @} */ /* end of E500_grp group */
75426 +
75427 +
75428 +#endif /* __E500V2_EXT_H */
75429 --- /dev/null
75430 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/cores/ppc_ext.h
75431 @@ -0,0 +1,141 @@
75432 +/*
75433 + * Copyright 2008-2012 Freescale Semiconductor Inc.
75434 + *
75435 + * Redistribution and use in source and binary forms, with or without
75436 + * modification, are permitted provided that the following conditions are met:
75437 + * * Redistributions of source code must retain the above copyright
75438 + * notice, this list of conditions and the following disclaimer.
75439 + * * Redistributions in binary form must reproduce the above copyright
75440 + * notice, this list of conditions and the following disclaimer in the
75441 + * documentation and/or other materials provided with the distribution.
75442 + * * Neither the name of Freescale Semiconductor nor the
75443 + * names of its contributors may be used to endorse or promote products
75444 + * derived from this software without specific prior written permission.
75445 + *
75446 + *
75447 + * ALTERNATIVELY, this software may be distributed under the terms of the
75448 + * GNU General Public License ("GPL") as published by the Free Software
75449 + * Foundation, either version 2 of that License or (at your option) any
75450 + * later version.
75451 + *
75452 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
75453 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
75454 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
75455 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
75456 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
75457 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
75458 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
75459 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
75460 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
75461 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
75462 + */
75463 +
75464 +
75465 +/**************************************************************************//**
75466 + @File ppc_ext.h
75467 +
75468 + @Description Core API for PowerPC cores
75469 +
75470 + These routines must be implemented by each specific PowerPC
75471 + core driver.
75472 +*//***************************************************************************/
75473 +#ifndef __PPC_EXT_H
75474 +#define __PPC_EXT_H
75475 +
75476 +#include "part_ext.h"
75477 +
75478 +
75479 +#define CORE_IS_BIG_ENDIAN
75480 +
75481 +#if defined(CORE_E300) || defined(CORE_E500V2)
75482 +#define CORE_CACHELINE_SIZE 32
75483 +#elif defined(CORE_E500MC) || defined(CORE_E5500) || defined(CORE_E6500)
75484 +#define CORE_CACHELINE_SIZE 64
75485 +#else
75486 +#error "Core not defined!"
75487 +#endif /* defined(CORE_E300) || ... */
75488 +
75489 +
75490 +/**************************************************************************//**
75491 + @Function CORE_TestAndSet
75492 +
75493 + @Description This routine tries to atomically test-and-set an integer
75494 + in memory to a non-zero value.
75495 +
75496 + The memory will be set only if it is tested as zero, in which
75497 + case the routine returns the new non-zero value; otherwise the
75498 + routine returns zero.
75499 +
75500 + @Param[in] p - pointer to a volatile int in memory, on which test-and-set
75501 + operation should be made.
75502 +
75503 + @Retval Zero - Operation failed - memory was already set.
75504 + @Retval Non-zero - Operation succeeded - memory has been set.
75505 +*//***************************************************************************/
75506 +int CORE_TestAndSet(volatile int *p);
75507 +
75508 +/**************************************************************************//**
75509 + @Function CORE_InstructionSync
75510 +
75511 + @Description This routine will cause the core to wait for previous instructions
75512 + (including any interrupts they generate) to complete before the
75513 + synchronization command executes, which purges all instructions
75514 + from the processor's pipeline and refetches the next instruction.
75515 +
75516 + @Return None.
75517 +*//***************************************************************************/
75518 +void CORE_InstructionSync(void);
75519 +
75520 +/**************************************************************************//**
75521 + @Function CORE_DCacheEnable
75522 +
75523 + @Description Enables the data cache for memory pages that are
75524 + not cache inhibited.
75525 +
75526 + @Return None.
75527 +*//***************************************************************************/
75528 +void CORE_DCacheEnable(void);
75529 +
75530 +/**************************************************************************//**
75531 + @Function CORE_ICacheEnable
75532 +
75533 + @Description Enables the instruction cache for memory pages that are
75534 + not cache inhibited.
75535 +
75536 + @Return None.
75537 +*//***************************************************************************/
75538 +void CORE_ICacheEnable(void);
75539 +
75540 +/**************************************************************************//**
75541 + @Function CORE_DCacheDisable
75542 +
75543 + @Description Disables the data cache.
75544 +
75545 + @Return None.
75546 +*//***************************************************************************/
75547 +void CORE_DCacheDisable(void);
75548 +
75549 +/**************************************************************************//**
75550 + @Function CORE_ICacheDisable
75551 +
75552 + @Description Disables the instruction cache.
75553 +
75554 + @Return None.
75555 +*//***************************************************************************/
75556 +void CORE_ICacheDisable(void);
75557 +
75558 +
75559 +
75560 +#if defined(CORE_E300)
75561 +#include "e300_ext.h"
75562 +#elif defined(CORE_E500V2) || defined(CORE_E500MC) || defined(CORE_E5500) || defined(CORE_E6500)
75563 +#include "e500v2_ext.h"
75564 +#if !defined(NCSW_LINUX)
75565 +#include "e500v2_asm_ext.h"
75566 +#endif
75567 +#else
75568 +#error "Core not defined!"
75569 +#endif
75570 +
75571 +
75572 +#endif /* __PPC_EXT_H */
75573 --- /dev/null
75574 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/ddr_std_ext.h
75575 @@ -0,0 +1,77 @@
75576 +/*
75577 + * Copyright 2008-2012 Freescale Semiconductor Inc.
75578 + *
75579 + * Redistribution and use in source and binary forms, with or without
75580 + * modification, are permitted provided that the following conditions are met:
75581 + * * Redistributions of source code must retain the above copyright
75582 + * notice, this list of conditions and the following disclaimer.
75583 + * * Redistributions in binary form must reproduce the above copyright
75584 + * notice, this list of conditions and the following disclaimer in the
75585 + * documentation and/or other materials provided with the distribution.
75586 + * * Neither the name of Freescale Semiconductor nor the
75587 + * names of its contributors may be used to endorse or promote products
75588 + * derived from this software without specific prior written permission.
75589 + *
75590 + *
75591 + * ALTERNATIVELY, this software may be distributed under the terms of the
75592 + * GNU General Public License ("GPL") as published by the Free Software
75593 + * Foundation, either version 2 of that License or (at your option) any
75594 + * later version.
75595 + *
75596 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
75597 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
75598 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
75599 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
75600 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
75601 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
75602 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
75603 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
75604 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
75605 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
75606 + */
75607 +
75608 +#ifndef __DDR_SDT_EXT_H
75609 +#define __DDR_SDT_EXT_H
75610 +
75611 +
75612 +/**************************************************************************//**
75613 + @Group ddr_Generic_Resources
75614 +
75615 + @Description ddr generic functions, definitions and enums.
75616 +
75617 + @{
75618 +*//***************************************************************************/
75619 +
75620 +
75621 +/**************************************************************************//**
75622 + @Description SPD maximum size
75623 +*//***************************************************************************/
75624 +#define SPD_MAX_SIZE 256
75625 +
75626 +/**************************************************************************//**
75627 + @Description DDR types select
75628 +*//***************************************************************************/
75629 +typedef enum e_DdrType
75630 +{
75631 + e_DDR_DDR1,
75632 + e_DDR_DDR2,
75633 + e_DDR_DDR3,
75634 + e_DDR_DDR3L,
75635 + e_DDR_DDR4
75636 +} e_DdrType;
75637 +
75638 +/**************************************************************************//**
75639 + @Description DDR Mode.
75640 +*//***************************************************************************/
75641 +typedef enum e_DdrMode
75642 +{
75643 + e_DDR_BUS_WIDTH_32BIT,
75644 + e_DDR_BUS_WIDTH_64BIT
75645 +} e_DdrMode;
75646 +
75647 +/** @} */ /* end of ddr_Generic_Resources group */
75648 +
75649 +
75650 +
75651 +#endif /* __DDR_SDT_EXT_H */
75652 +
75653 --- /dev/null
75654 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/debug_ext.h
75655 @@ -0,0 +1,233 @@
75656 +/*
75657 + * Copyright 2008-2012 Freescale Semiconductor Inc.
75658 + *
75659 + * Redistribution and use in source and binary forms, with or without
75660 + * modification, are permitted provided that the following conditions are met:
75661 + * * Redistributions of source code must retain the above copyright
75662 + * notice, this list of conditions and the following disclaimer.
75663 + * * Redistributions in binary form must reproduce the above copyright
75664 + * notice, this list of conditions and the following disclaimer in the
75665 + * documentation and/or other materials provided with the distribution.
75666 + * * Neither the name of Freescale Semiconductor nor the
75667 + * names of its contributors may be used to endorse or promote products
75668 + * derived from this software without specific prior written permission.
75669 + *
75670 + *
75671 + * ALTERNATIVELY, this software may be distributed under the terms of the
75672 + * GNU General Public License ("GPL") as published by the Free Software
75673 + * Foundation, either version 2 of that License or (at your option) any
75674 + * later version.
75675 + *
75676 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
75677 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
75678 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
75679 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
75680 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
75681 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
75682 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
75683 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
75684 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
75685 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
75686 + */
75687 +
75688 +
75689 +/**************************************************************************//**
75690 + @File debug_ext.h
75691 +
75692 + @Description Debug mode definitions.
75693 +*//***************************************************************************/
75694 +
75695 +#ifndef __DEBUG_EXT_H
75696 +#define __DEBUG_EXT_H
75697 +
75698 +#include "std_ext.h"
75699 +#include "xx_ext.h"
75700 +#include "memcpy_ext.h"
75701 +#if (DEBUG_ERRORS > 0)
75702 +#include "sprint_ext.h"
75703 +#include "string_ext.h"
75704 +#endif /* DEBUG_ERRORS > 0 */
75705 +
75706 +
75707 +#if (DEBUG_ERRORS > 0)
75708 +
75709 +/* Internally used macros */
75710 +
75711 +#define DUMP_Print XX_Print
75712 +#define DUMP_MAX_LEVELS 6
75713 +#define DUMP_IDX_LEN 6
75714 +#define DUMP_MAX_STR 64
75715 +
75716 +
75717 +#define _CREATE_DUMP_SUBSTR(phrase) \
75718 + dumpTmpLevel = 0; dumpSubStr[0] = '\0'; \
75719 + snprintf(dumpTmpStr, DUMP_MAX_STR, "%s", #phrase); \
75720 + p_DumpToken = strtok(dumpTmpStr, (dumpIsArr[0] ? "[" : ".")); \
75721 + while ((p_DumpToken != NULL) && (dumpTmpLevel < DUMP_MAX_LEVELS)) \
75722 + { \
75723 + strlcat(dumpSubStr, p_DumpToken, DUMP_MAX_STR); \
75724 + if (dumpIsArr[dumpTmpLevel]) \
75725 + { \
75726 + strlcat(dumpSubStr, dumpIdxStr[dumpTmpLevel], DUMP_MAX_STR); \
75727 + p_DumpToken = strtok(NULL, "."); \
75728 + } \
75729 + if ((p_DumpToken != NULL) && \
75730 + ((p_DumpToken = strtok(NULL, (dumpIsArr[++dumpTmpLevel] ? "[" : "."))) != NULL)) \
75731 + strlcat(dumpSubStr, ".", DUMP_MAX_STR); \
75732 + }
75733 +
75734 +
75735 +/**************************************************************************//**
75736 + @Group gen_id General Drivers Utilities
75737 +
75738 + @Description External routines.
75739 +
75740 + @{
75741 +*//***************************************************************************/
75742 +
75743 +/**************************************************************************//**
75744 + @Group dump_id Memory and Registers Dump Mechanism
75745 +
75746 + @Description Macros for dumping memory mapped structures.
75747 +
75748 + @{
75749 +*//***************************************************************************/
75750 +
75751 +/**************************************************************************//**
75752 + @Description Declaration of dump mechanism variables.
75753 +
75754 + This macro must be declared at the beginning of each routine
75755 + which uses the dump mechanism macros, before the routine's code
75756 + starts.
75757 +*//***************************************************************************/
75758 +#define DECLARE_DUMP \
75759 + char dumpIdxStr[DUMP_MAX_LEVELS + 1][DUMP_IDX_LEN] = { "", }; \
75760 + char dumpSubStr[DUMP_MAX_STR] = ""; \
75761 + char dumpTmpStr[DUMP_MAX_STR] = ""; \
75762 + char *p_DumpToken = NULL; \
75763 + int dumpArrIdx = 0, dumpArrSize = 0, dumpLevel = 0, dumpTmpLevel = 0; \
75764 + uint8_t dumpIsArr[DUMP_MAX_LEVELS + 1] = { 0 }; \
75765 + /* Prevent warnings if not all used */ \
75766 + UNUSED(dumpIdxStr[0][0]); \
75767 + UNUSED(dumpSubStr[0]); \
75768 + UNUSED(dumpTmpStr[0]); \
75769 + UNUSED(p_DumpToken); \
75770 + UNUSED(dumpArrIdx); \
75771 + UNUSED(dumpArrSize); \
75772 + UNUSED(dumpLevel); \
75773 + UNUSED(dumpTmpLevel); \
75774 + UNUSED(dumpIsArr[0]);
75775 +
75776 +
75777 +/**************************************************************************//**
75778 + @Description Prints a title for a subsequent dumped structure or memory.
75779 +
75780 + The inputs for this macro are the structure/memory title and
75781 + its base addresses.
75782 +*//***************************************************************************/
75783 +#define DUMP_TITLE(addr, msg) \
75784 + DUMP_Print("\r\n"); DUMP_Print msg; \
75785 + if (addr) \
75786 + DUMP_Print(" (%p)", (addr)); \
75787 + DUMP_Print("\r\n---------------------------------------------------------\r\n");
75788 +
75789 +/**************************************************************************//**
75790 + @Description Prints a subtitle for a subsequent dumped sub-structure (optional).
75791 +
75792 + The inputs for this macro are the sub-structure subtitle.
75793 + A separating line with this subtitle will be printed.
75794 +*//***************************************************************************/
75795 +#define DUMP_SUBTITLE(subtitle) \
75796 + DUMP_Print("----------- "); DUMP_Print subtitle; DUMP_Print("\r\n")
75797 +
75798 +
75799 +/**************************************************************************//**
75800 + @Description Dumps a memory region in 4-bytes aligned format.
75801 +
75802 + The inputs for this macro are the base addresses and size
75803 + (in bytes) of the memory region.
75804 +*//***************************************************************************/
75805 +#define DUMP_MEMORY(addr, size) \
75806 + MemDisp((uint8_t *)(addr), (int)(size))
75807 +
75808 +
75809 +/**************************************************************************//**
75810 + @Description Declares a dump loop, for dumping a sub-structure array.
75811 +
75812 + The inputs for this macro are:
75813 + - idx: an index variable, for indexing the sub-structure items
75814 + inside the loop. This variable must be declared separately
75815 + in the beginning of the routine.
75816 + - cnt: the number of times to repeat the loop. This number should
75817 + equal the number of items in the sub-structures array.
75818 +
75819 + Note, that the body of the loop must be written inside brackets.
75820 +*//***************************************************************************/
75821 +#define DUMP_SUBSTRUCT_ARRAY(idx, cnt) \
75822 + for (idx=0, dumpIsArr[dumpLevel++] = 1; \
75823 + (idx < cnt) && (dumpLevel > 0) && snprintf(dumpIdxStr[dumpLevel-1], DUMP_IDX_LEN, "[%d]", idx); \
75824 + idx++, ((idx < cnt) || (dumpIsArr[--dumpLevel] = 0)))
75825 +
75826 +
75827 +/**************************************************************************//**
75828 + @Description Dumps a structure's member variable.
75829 +
75830 + The input for this macro is the full reference for the member
75831 + variable, where the structure is referenced using a pointer.
75832 +
75833 + Note, that a members array must be dumped using DUMP_ARR macro,
75834 + rather than using this macro.
75835 +
75836 + If the member variable is part of a sub-structure hierarchy,
75837 + the full hierarchy (including array indexing) must be specified.
75838 +
75839 + Examples: p_Struct->member
75840 + p_Struct->sub.member
75841 + p_Struct->sub[i].member
75842 +*//***************************************************************************/
75843 +#define DUMP_VAR(st, phrase) \
75844 + do { \
75845 + void *addr = (void *)&((st)->phrase); \
75846 + physAddress_t physAddr = XX_VirtToPhys(addr); \
75847 + _CREATE_DUMP_SUBSTR(phrase); \
75848 + DUMP_Print("0x%010llX: 0x%08x%8s\t%s\r\n", \
75849 + physAddr, GET_UINT32(*(uint32_t*)addr), "", dumpSubStr); \
75850 + } while (0)
75851 +
75852 +
75853 +/**************************************************************************//**
75854 + @Description Dumps a structure's members array.
75855 +
75856 + The input for this macro is the full reference for the members
75857 + array, where the structure is referenced using a pointer.
75858 +
75859 + If the members array is part of a sub-structure hierarchy,
75860 + the full hierarchy (including array indexing) must be specified.
75861 +
75862 + Examples: p_Struct->array
75863 + p_Struct->sub.array
75864 + p_Struct->sub[i].array
75865 +*//***************************************************************************/
75866 +#define DUMP_ARR(st, phrase) \
75867 + do { \
75868 + physAddress_t physAddr; \
75869 + _CREATE_DUMP_SUBSTR(phrase); \
75870 + dumpArrSize = ARRAY_SIZE((st)->phrase); \
75871 + for (dumpArrIdx=0; dumpArrIdx < dumpArrSize; dumpArrIdx++) { \
75872 + physAddr = XX_VirtToPhys((void *)&((st)->phrase[dumpArrIdx])); \
75873 + DUMP_Print("0x%010llX: 0x%08x%8s\t%s[%d]\r\n", \
75874 + physAddr, GET_UINT32((st)->phrase[dumpArrIdx]), "", dumpSubStr, dumpArrIdx); \
75875 + } \
75876 + } while (0)
75877 +
75878 +
75879 +
75880 +#endif /* DEBUG_ERRORS > 0 */
75881 +
75882 +
75883 +/** @} */ /* end of dump_id group */
75884 +/** @} */ /* end of gen_id group */
75885 +
75886 +
75887 +#endif /* __DEBUG_EXT_H */
75888 +
75889 --- /dev/null
75890 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/endian_ext.h
75891 @@ -0,0 +1,447 @@
75892 +/*
75893 + * Copyright 2008-2012 Freescale Semiconductor Inc.
75894 + *
75895 + * Redistribution and use in source and binary forms, with or without
75896 + * modification, are permitted provided that the following conditions are met:
75897 + * * Redistributions of source code must retain the above copyright
75898 + * notice, this list of conditions and the following disclaimer.
75899 + * * Redistributions in binary form must reproduce the above copyright
75900 + * notice, this list of conditions and the following disclaimer in the
75901 + * documentation and/or other materials provided with the distribution.
75902 + * * Neither the name of Freescale Semiconductor nor the
75903 + * names of its contributors may be used to endorse or promote products
75904 + * derived from this software without specific prior written permission.
75905 + *
75906 + *
75907 + * ALTERNATIVELY, this software may be distributed under the terms of the
75908 + * GNU General Public License ("GPL") as published by the Free Software
75909 + * Foundation, either version 2 of that License or (at your option) any
75910 + * later version.
75911 + *
75912 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
75913 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
75914 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
75915 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
75916 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
75917 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
75918 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
75919 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
75920 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
75921 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
75922 + */
75923 +
75924 +
75925 +/**************************************************************************//**
75926 +
75927 + @File endian_ext.h
75928 +
75929 + @Description Big/little endian swapping routines.
75930 +*//***************************************************************************/
75931 +
75932 +#ifndef __ENDIAN_EXT_H
75933 +#define __ENDIAN_EXT_H
75934 +
75935 +#include "std_ext.h"
75936 +
75937 +
75938 +/**************************************************************************//**
75939 + @Group gen_id General Drivers Utilities
75940 +
75941 + @Description General usage API. This API is intended for usage by both the
75942 + internal modules and the user's application.
75943 +
75944 + @{
75945 +*//***************************************************************************/
75946 +
75947 +/**************************************************************************//**
75948 + @Group endian_id Big/Little-Endian Conversion
75949 +
75950 + @Description Routines and macros for Big/Little-Endian conversion and
75951 + general byte swapping.
75952 +
75953 + All routines and macros are expecting unsigned values as
75954 + parameters, but will generate the correct result also for
75955 + signed values. Therefore, signed/unsigned casting is allowed.
75956 + @{
75957 +*//***************************************************************************/
75958 +
75959 +/**************************************************************************//**
75960 + @Collection Byte-Swap Macros
75961 +
75962 + Macros for swapping byte order.
75963 +
75964 + @Cautions The parameters of these macros are evaluated multiple times.
75965 + For calculated expressions or expressions that contain function
75966 + calls it is recommended to use the byte-swap routines.
75967 +
75968 + @{
75969 +*//***************************************************************************/
75970 +
75971 +/**************************************************************************//**
75972 + @Description Swaps the byte order of a given 16-bit value.
75973 +
75974 + @Param[in] val - The 16-bit value to swap.
75975 +
75976 + @Return The byte-swapped value..
75977 +
75978 + @Cautions The given value is evaluated multiple times by this macro.
75979 + For calculated expressions or expressions that contain function
75980 + calls it is recommended to use the SwapUint16() routine.
75981 +
75982 + @hideinitializer
75983 +*//***************************************************************************/
75984 +#define SWAP_UINT16(val) \
75985 + ((uint16_t)((((val) & 0x00FF) << 8) | (((val) & 0xFF00) >> 8)))
75986 +
75987 +/**************************************************************************//**
75988 + @Description Swaps the byte order of a given 32-bit value.
75989 +
75990 + @Param[in] val - The 32-bit value to swap.
75991 +
75992 + @Return The byte-swapped value..
75993 +
75994 + @Cautions The given value is evaluated multiple times by this macro.
75995 + For calculated expressions or expressions that contain function
75996 + calls it is recommended to use the SwapUint32() routine.
75997 +
75998 + @hideinitializer
75999 +*//***************************************************************************/
76000 +#define SWAP_UINT32(val) \
76001 + ((uint32_t)((((val) & 0x000000FF) << 24) | \
76002 + (((val) & 0x0000FF00) << 8) | \
76003 + (((val) & 0x00FF0000) >> 8) | \
76004 + (((val) & 0xFF000000) >> 24)))
76005 +
76006 +/**************************************************************************//**
76007 + @Description Swaps the byte order of a given 64-bit value.
76008 +
76009 + @Param[in] val - The 64-bit value to swap.
76010 +
76011 + @Return The byte-swapped value..
76012 +
76013 + @Cautions The given value is evaluated multiple times by this macro.
76014 + For calculated expressions or expressions that contain function
76015 + calls it is recommended to use the SwapUint64() routine.
76016 +
76017 + @hideinitializer
76018 +*//***************************************************************************/
76019 +#define SWAP_UINT64(val) \
76020 + ((uint64_t)((((val) & 0x00000000000000FFULL) << 56) | \
76021 + (((val) & 0x000000000000FF00ULL) << 40) | \
76022 + (((val) & 0x0000000000FF0000ULL) << 24) | \
76023 + (((val) & 0x00000000FF000000ULL) << 8) | \
76024 + (((val) & 0x000000FF00000000ULL) >> 8) | \
76025 + (((val) & 0x0000FF0000000000ULL) >> 24) | \
76026 + (((val) & 0x00FF000000000000ULL) >> 40) | \
76027 + (((val) & 0xFF00000000000000ULL) >> 56)))
76028 +
76029 +/* @} */
76030 +
76031 +/**************************************************************************//**
76032 + @Collection Byte-Swap Routines
76033 +
76034 + Routines for swapping the byte order of a given parameter and
76035 + returning the swapped value.
76036 +
76037 + These inline routines are safer than the byte-swap macros,
76038 + because they evaluate the parameter expression only once.
76039 + @{
76040 +*//***************************************************************************/
76041 +
76042 +/**************************************************************************//**
76043 + @Function SwapUint16
76044 +
76045 + @Description Returns the byte-swapped value of a given 16-bit value.
76046 +
76047 + @Param[in] val - The 16-bit value.
76048 +
76049 + @Return The byte-swapped value of the parameter.
76050 +*//***************************************************************************/
76051 +static __inline__ uint16_t SwapUint16(uint16_t val)
76052 +{
76053 + return (uint16_t)(((val & 0x00FF) << 8) |
76054 + ((val & 0xFF00) >> 8));
76055 +}
76056 +
76057 +/**************************************************************************//**
76058 + @Function SwapUint32
76059 +
76060 + @Description Returns the byte-swapped value of a given 32-bit value.
76061 +
76062 + @Param[in] val - The 32-bit value.
76063 +
76064 + @Return The byte-swapped value of the parameter.
76065 +*//***************************************************************************/
76066 +static __inline__ uint32_t SwapUint32(uint32_t val)
76067 +{
76068 + return (uint32_t)(((val & 0x000000FF) << 24) |
76069 + ((val & 0x0000FF00) << 8) |
76070 + ((val & 0x00FF0000) >> 8) |
76071 + ((val & 0xFF000000) >> 24));
76072 +}
76073 +
76074 +/**************************************************************************//**
76075 + @Function SwapUint64
76076 +
76077 + @Description Returns the byte-swapped value of a given 64-bit value.
76078 +
76079 + @Param[in] val - The 64-bit value.
76080 +
76081 + @Return The byte-swapped value of the parameter.
76082 +*//***************************************************************************/
76083 +static __inline__ uint64_t SwapUint64(uint64_t val)
76084 +{
76085 + return (uint64_t)(((val & 0x00000000000000FFULL) << 56) |
76086 + ((val & 0x000000000000FF00ULL) << 40) |
76087 + ((val & 0x0000000000FF0000ULL) << 24) |
76088 + ((val & 0x00000000FF000000ULL) << 8) |
76089 + ((val & 0x000000FF00000000ULL) >> 8) |
76090 + ((val & 0x0000FF0000000000ULL) >> 24) |
76091 + ((val & 0x00FF000000000000ULL) >> 40) |
76092 + ((val & 0xFF00000000000000ULL) >> 56));
76093 +}
76094 +
76095 +/* @} */
76096 +
76097 +/**************************************************************************//**
76098 + @Collection In-place Byte-Swap-And-Set Routines
76099 +
76100 + Routines for swapping the byte order of a given variable and
76101 + setting the swapped value back to the same variable.
76102 + @{
76103 +*//***************************************************************************/
76104 +
76105 +/**************************************************************************//**
76106 + @Function SwapUint16P
76107 +
76108 + @Description Swaps the byte order of a given 16-bit variable.
76109 +
76110 + @Param[in] p_Val - Pointer to the 16-bit variable.
76111 +
76112 + @Return None.
76113 +*//***************************************************************************/
76114 +static __inline__ void SwapUint16P(uint16_t *p_Val)
76115 +{
76116 + *p_Val = SwapUint16(*p_Val);
76117 +}
76118 +
76119 +/**************************************************************************//**
76120 + @Function SwapUint32P
76121 +
76122 + @Description Swaps the byte order of a given 32-bit variable.
76123 +
76124 + @Param[in] p_Val - Pointer to the 32-bit variable.
76125 +
76126 + @Return None.
76127 +*//***************************************************************************/
76128 +static __inline__ void SwapUint32P(uint32_t *p_Val)
76129 +{
76130 + *p_Val = SwapUint32(*p_Val);
76131 +}
76132 +
76133 +/**************************************************************************//**
76134 + @Function SwapUint64P
76135 +
76136 + @Description Swaps the byte order of a given 64-bit variable.
76137 +
76138 + @Param[in] p_Val - Pointer to the 64-bit variable.
76139 +
76140 + @Return None.
76141 +*//***************************************************************************/
76142 +static __inline__ void SwapUint64P(uint64_t *p_Val)
76143 +{
76144 + *p_Val = SwapUint64(*p_Val);
76145 +}
76146 +
76147 +/* @} */
76148 +
76149 +
76150 +/**************************************************************************//**
76151 + @Collection Little-Endian Conversion Macros
76152 +
76153 + These macros convert given parameters to or from Little-Endian
76154 + format. Use these macros when you want to read or write a specific
76155 + Little-Endian value in memory, without a-priori knowing the CPU
76156 + byte order.
76157 +
76158 + These macros use the byte-swap routines. For conversion of
76159 + constants in initialization structures, you may use the CONST
76160 + versions of these macros (see below), which are using the
76161 + byte-swap macros instead.
76162 + @{
76163 +*//***************************************************************************/
76164 +
76165 +/**************************************************************************//**
76166 + @Description Converts a given 16-bit value from CPU byte order to
76167 + Little-Endian byte order.
76168 +
76169 + @Param[in] val - The 16-bit value to convert.
76170 +
76171 + @Return The converted value.
76172 +
76173 + @hideinitializer
76174 +*//***************************************************************************/
76175 +#define CPU_TO_LE16(val) SwapUint16(val)
76176 +
76177 +/**************************************************************************//**
76178 + @Description Converts a given 32-bit value from CPU byte order to
76179 + Little-Endian byte order.
76180 +
76181 + @Param[in] val - The 32-bit value to convert.
76182 +
76183 + @Return The converted value.
76184 +
76185 + @hideinitializer
76186 +*//***************************************************************************/
76187 +#define CPU_TO_LE32(val) SwapUint32(val)
76188 +
76189 +/**************************************************************************//**
76190 + @Description Converts a given 64-bit value from CPU byte order to
76191 + Little-Endian byte order.
76192 +
76193 + @Param[in] val - The 64-bit value to convert.
76194 +
76195 + @Return The converted value.
76196 +
76197 + @hideinitializer
76198 +*//***************************************************************************/
76199 +#define CPU_TO_LE64(val) SwapUint64(val)
76200 +
76201 +
76202 +/**************************************************************************//**
76203 + @Description Converts a given 16-bit value from Little-Endian byte order to
76204 + CPU byte order.
76205 +
76206 + @Param[in] val - The 16-bit value to convert.
76207 +
76208 + @Return The converted value.
76209 +
76210 + @hideinitializer
76211 +*//***************************************************************************/
76212 +#define LE16_TO_CPU(val) CPU_TO_LE16(val)
76213 +
76214 +/**************************************************************************//**
76215 + @Description Converts a given 32-bit value from Little-Endian byte order to
76216 + CPU byte order.
76217 +
76218 + @Param[in] val - The 32-bit value to convert.
76219 +
76220 + @Return The converted value.
76221 +
76222 + @hideinitializer
76223 +*//***************************************************************************/
76224 +#define LE32_TO_CPU(val) CPU_TO_LE32(val)
76225 +
76226 +/**************************************************************************//**
76227 + @Description Converts a given 64-bit value from Little-Endian byte order to
76228 + CPU byte order.
76229 +
76230 + @Param[in] val - The 64-bit value to convert.
76231 +
76232 + @Return The converted value.
76233 +
76234 + @hideinitializer
76235 +*//***************************************************************************/
76236 +#define LE64_TO_CPU(val) CPU_TO_LE64(val)
76237 +
76238 +/* @} */
76239 +
76240 +/**************************************************************************//**
76241 + @Collection Little-Endian Constant Conversion Macros
76242 +
76243 + These macros convert given constants to or from Little-Endian
76244 + format. Use these macros when you want to read or write a specific
76245 + Little-Endian constant in memory, without a-priori knowing the
76246 + CPU byte order.
76247 +
76248 + These macros use the byte-swap macros, therefore can be used for
76249 + conversion of constants in initialization structures.
76250 +
76251 + @Cautions The parameters of these macros are evaluated multiple times.
76252 + For non-constant expressions, use the non-CONST macro versions.
76253 +
76254 + @{
76255 +*//***************************************************************************/
76256 +
76257 +/**************************************************************************//**
76258 + @Description Converts a given 16-bit constant from CPU byte order to
76259 + Little-Endian byte order.
76260 +
76261 + @Param[in] val - The 16-bit value to convert.
76262 +
76263 + @Return The converted value.
76264 +
76265 + @hideinitializer
76266 +*//***************************************************************************/
76267 +#define CONST_CPU_TO_LE16(val) SWAP_UINT16(val)
76268 +
76269 +/**************************************************************************//**
76270 + @Description Converts a given 32-bit constant from CPU byte order to
76271 + Little-Endian byte order.
76272 +
76273 + @Param[in] val - The 32-bit value to convert.
76274 +
76275 + @Return The converted value.
76276 +
76277 + @hideinitializer
76278 +*//***************************************************************************/
76279 +#define CONST_CPU_TO_LE32(val) SWAP_UINT32(val)
76280 +
76281 +/**************************************************************************//**
76282 + @Description Converts a given 64-bit constant from CPU byte order to
76283 + Little-Endian byte order.
76284 +
76285 + @Param[in] val - The 64-bit value to convert.
76286 +
76287 + @Return The converted value.
76288 +
76289 + @hideinitializer
76290 +*//***************************************************************************/
76291 +#define CONST_CPU_TO_LE64(val) SWAP_UINT64(val)
76292 +
76293 +
76294 +/**************************************************************************//**
76295 + @Description Converts a given 16-bit constant from Little-Endian byte order
76296 + to CPU byte order.
76297 +
76298 + @Param[in] val - The 16-bit value to convert.
76299 +
76300 + @Return The converted value.
76301 +
76302 + @hideinitializer
76303 +*//***************************************************************************/
76304 +#define CONST_LE16_TO_CPU(val) CONST_CPU_TO_LE16(val)
76305 +
76306 +/**************************************************************************//**
76307 + @Description Converts a given 32-bit constant from Little-Endian byte order
76308 + to CPU byte order.
76309 +
76310 + @Param[in] val - The 32-bit value to convert.
76311 +
76312 + @Return The converted value.
76313 +
76314 + @hideinitializer
76315 +*//***************************************************************************/
76316 +#define CONST_LE32_TO_CPU(val) CONST_CPU_TO_LE32(val)
76317 +
76318 +/**************************************************************************//**
76319 + @Description Converts a given 64-bit constant from Little-Endian byte order
76320 + to CPU byte order.
76321 +
76322 + @Param[in] val - The 64-bit value to convert.
76323 +
76324 + @Return The converted value.
76325 +
76326 + @hideinitializer
76327 +*//***************************************************************************/
76328 +#define CONST_LE64_TO_CPU(val) CONST_CPU_TO_LE64(val)
76329 +
76330 +/* @} */
76331 +
76332 +
76333 +/** @} */ /* end of endian_id group */
76334 +/** @} */ /* end of gen_id group */
76335 +
76336 +
76337 +#endif /* __ENDIAN_EXT_H */
76338 +
76339 --- /dev/null
76340 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/enet_ext.h
76341 @@ -0,0 +1,205 @@
76342 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
76343 + * All rights reserved.
76344 + *
76345 + * Redistribution and use in source and binary forms, with or without
76346 + * modification, are permitted provided that the following conditions are met:
76347 + * * Redistributions of source code must retain the above copyright
76348 + * notice, this list of conditions and the following disclaimer.
76349 + * * Redistributions in binary form must reproduce the above copyright
76350 + * notice, this list of conditions and the following disclaimer in the
76351 + * documentation and/or other materials provided with the distribution.
76352 + * * Neither the name of Freescale Semiconductor nor the
76353 + * names of its contributors may be used to endorse or promote products
76354 + * derived from this software without specific prior written permission.
76355 + *
76356 + *
76357 + * ALTERNATIVELY, this software may be distributed under the terms of the
76358 + * GNU General Public License ("GPL") as published by the Free Software
76359 + * Foundation, either version 2 of that License or (at your option) any
76360 + * later version.
76361 + *
76362 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
76363 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
76364 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
76365 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
76366 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
76367 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
76368 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
76369 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
76370 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
76371 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
76372 + */
76373 +
76374 +
76375 +/**************************************************************************//**
76376 + @File enet_ext.h
76377 +
76378 + @Description Ethernet generic definitions and enums.
76379 +*//***************************************************************************/
76380 +
76381 +#ifndef __ENET_EXT_H
76382 +#define __ENET_EXT_H
76383 +
76384 +#include "fsl_enet.h"
76385 +
76386 +#define ENET_NUM_OCTETS_PER_ADDRESS 6 /**< Number of octets (8-bit bytes) in an ethernet address */
76387 +#define ENET_GROUP_ADDR 0x01 /**< Group address mask for ethernet addresses */
76388 +
76389 +
76390 +/**************************************************************************//**
76391 + @Description Ethernet Address
76392 +*//***************************************************************************/
76393 +typedef uint8_t t_EnetAddr[ENET_NUM_OCTETS_PER_ADDRESS];
76394 +
76395 +/**************************************************************************//**
76396 + @Description Ethernet Address Type.
76397 +*//***************************************************************************/
76398 +typedef enum e_EnetAddrType
76399 +{
76400 + e_ENET_ADDR_TYPE_INDIVIDUAL, /**< Individual (unicast) address */
76401 + e_ENET_ADDR_TYPE_GROUP, /**< Group (multicast) address */
76402 + e_ENET_ADDR_TYPE_BROADCAST /**< Broadcast address */
76403 +} e_EnetAddrType;
76404 +
76405 +/**************************************************************************//**
76406 + @Description Ethernet MAC-PHY Interface
76407 +*//***************************************************************************/
76408 +typedef enum e_EnetInterface
76409 +{
76410 + e_ENET_IF_MII = E_ENET_IF_MII, /**< MII interface */
76411 + e_ENET_IF_RMII = E_ENET_IF_RMII, /**< RMII interface */
76412 + e_ENET_IF_SMII = E_ENET_IF_SMII, /**< SMII interface */
76413 + e_ENET_IF_GMII = E_ENET_IF_GMII, /**< GMII interface */
76414 + e_ENET_IF_RGMII = E_ENET_IF_RGMII, /**< RGMII interface */
76415 + e_ENET_IF_TBI = E_ENET_IF_TBI, /**< TBI interface */
76416 + e_ENET_IF_RTBI = E_ENET_IF_RTBI, /**< RTBI interface */
76417 + e_ENET_IF_SGMII = E_ENET_IF_SGMII, /**< SGMII interface */
76418 + e_ENET_IF_XGMII = E_ENET_IF_XGMII, /**< XGMII interface */
76419 + e_ENET_IF_QSGMII= E_ENET_IF_QSGMII, /**< QSGMII interface */
76420 + e_ENET_IF_XFI = E_ENET_IF_XFI /**< XFI interface */
76421 +} e_EnetInterface;
76422 +
76423 +#define ENET_IF_SGMII_BASEX 0x80000000 /**< SGMII/QSGII interface with 1000BaseX
76424 + auto-negotiation between MAC and phy
76425 + or backplane;
76426 + Note: 1000BaseX auto-negotiation relates
76427 + only to interface between MAC and phy/backplane,
76428 + SGMII phy can still synchronize with far-end phy
76429 + at 10Mbps, 100Mbps or 1000Mbps */
76430 +
76431 +/**************************************************************************//**
76432 + @Description Ethernet Duplex Mode
76433 +*//***************************************************************************/
76434 +typedef enum e_EnetDuplexMode
76435 +{
76436 + e_ENET_HALF_DUPLEX, /**< Half-Duplex mode */
76437 + e_ENET_FULL_DUPLEX /**< Full-Duplex mode */
76438 +} e_EnetDuplexMode;
76439 +
76440 +/**************************************************************************//**
76441 + @Description Ethernet Speed (nominal data rate)
76442 +*//***************************************************************************/
76443 +typedef enum e_EnetSpeed
76444 +{
76445 + e_ENET_SPEED_10 = E_ENET_SPEED_10, /**< 10 Mbps */
76446 + e_ENET_SPEED_100 = E_ENET_SPEED_100, /**< 100 Mbps */
76447 + e_ENET_SPEED_1000 = E_ENET_SPEED_1000, /**< 1000 Mbps = 1 Gbps */
76448 + e_ENET_SPEED_2500 = E_ENET_SPEED_2500, /**< 2500 Mbps = 2.5 Gbps */
76449 + e_ENET_SPEED_10000 = E_ENET_SPEED_10000 /**< 10000 Mbps = 10 Gbps */
76450 +} e_EnetSpeed;
76451 +
76452 +/**************************************************************************//**
76453 + @Description Ethernet mode (combination of MAC-PHY interface and speed)
76454 +*//***************************************************************************/
76455 +typedef enum e_EnetMode
76456 +{
76457 + e_ENET_MODE_INVALID = 0, /**< Invalid Ethernet mode */
76458 + e_ENET_MODE_MII_10 = (e_ENET_IF_MII | e_ENET_SPEED_10), /**< 10 Mbps MII */
76459 + e_ENET_MODE_MII_100 = (e_ENET_IF_MII | e_ENET_SPEED_100), /**< 100 Mbps MII */
76460 + e_ENET_MODE_RMII_10 = (e_ENET_IF_RMII | e_ENET_SPEED_10), /**< 10 Mbps RMII */
76461 + e_ENET_MODE_RMII_100 = (e_ENET_IF_RMII | e_ENET_SPEED_100), /**< 100 Mbps RMII */
76462 + e_ENET_MODE_SMII_10 = (e_ENET_IF_SMII | e_ENET_SPEED_10), /**< 10 Mbps SMII */
76463 + e_ENET_MODE_SMII_100 = (e_ENET_IF_SMII | e_ENET_SPEED_100), /**< 100 Mbps SMII */
76464 + e_ENET_MODE_GMII_1000 = (e_ENET_IF_GMII | e_ENET_SPEED_1000), /**< 1000 Mbps GMII */
76465 + e_ENET_MODE_RGMII_10 = (e_ENET_IF_RGMII | e_ENET_SPEED_10), /**< 10 Mbps RGMII */
76466 + e_ENET_MODE_RGMII_100 = (e_ENET_IF_RGMII | e_ENET_SPEED_100), /**< 100 Mbps RGMII */
76467 + e_ENET_MODE_RGMII_1000 = (e_ENET_IF_RGMII | e_ENET_SPEED_1000), /**< 1000 Mbps RGMII */
76468 + e_ENET_MODE_TBI_1000 = (e_ENET_IF_TBI | e_ENET_SPEED_1000), /**< 1000 Mbps TBI */
76469 + e_ENET_MODE_RTBI_1000 = (e_ENET_IF_RTBI | e_ENET_SPEED_1000), /**< 1000 Mbps RTBI */
76470 + e_ENET_MODE_SGMII_10 = (e_ENET_IF_SGMII | e_ENET_SPEED_10),
76471 + /**< 10 Mbps SGMII with auto-negotiation between MAC and
76472 + SGMII phy according to Cisco SGMII specification */
76473 + e_ENET_MODE_SGMII_100 = (e_ENET_IF_SGMII | e_ENET_SPEED_100),
76474 + /**< 100 Mbps SGMII with auto-negotiation between MAC and
76475 + SGMII phy according to Cisco SGMII specification */
76476 + e_ENET_MODE_SGMII_1000 = (e_ENET_IF_SGMII | e_ENET_SPEED_1000),
76477 + /**< 1000 Mbps SGMII with auto-negotiation between MAC and
76478 + SGMII phy according to Cisco SGMII specification */
76479 + e_ENET_MODE_SGMII_2500 = (e_ENET_IF_SGMII | e_ENET_SPEED_2500),
76480 + e_ENET_MODE_SGMII_BASEX_10 = (ENET_IF_SGMII_BASEX | e_ENET_IF_SGMII | e_ENET_SPEED_10),
76481 + /**< 10 Mbps SGMII with 1000BaseX auto-negotiation between
76482 + MAC and SGMII phy or backplane */
76483 + e_ENET_MODE_SGMII_BASEX_100 = (ENET_IF_SGMII_BASEX | e_ENET_IF_SGMII | e_ENET_SPEED_100),
76484 + /**< 100 Mbps SGMII with 1000BaseX auto-negotiation between
76485 + MAC and SGMII phy or backplane */
76486 + e_ENET_MODE_SGMII_BASEX_1000 = (ENET_IF_SGMII_BASEX | e_ENET_IF_SGMII | e_ENET_SPEED_1000),
76487 + /**< 1000 Mbps SGMII with 1000BaseX auto-negotiation between
76488 + MAC and SGMII phy or backplane */
76489 + e_ENET_MODE_QSGMII_1000 = (e_ENET_IF_QSGMII| e_ENET_SPEED_1000),
76490 + /**< 1000 Mbps QSGMII with auto-negotiation between MAC and
76491 + QSGMII phy according to Cisco QSGMII specification */
76492 + e_ENET_MODE_QSGMII_BASEX_1000 = (ENET_IF_SGMII_BASEX | e_ENET_IF_QSGMII| e_ENET_SPEED_1000),
76493 + /**< 1000 Mbps QSGMII with 1000BaseX auto-negotiation between
76494 + MAC and QSGMII phy or backplane */
76495 + e_ENET_MODE_XGMII_10000 = (e_ENET_IF_XGMII | e_ENET_SPEED_10000), /**< 10000 Mbps XGMII */
76496 + e_ENET_MODE_XFI_10000 = (e_ENET_IF_XFI | e_ENET_SPEED_10000) /**< 10000 Mbps XFI */
76497 +} e_EnetMode;
76498 +
76499 +
76500 +#define IS_ENET_MODE_VALID(mode) \
76501 + (((mode) == e_ENET_MODE_MII_10 ) || \
76502 + ((mode) == e_ENET_MODE_MII_100 ) || \
76503 + ((mode) == e_ENET_MODE_RMII_10 ) || \
76504 + ((mode) == e_ENET_MODE_RMII_100 ) || \
76505 + ((mode) == e_ENET_MODE_SMII_10 ) || \
76506 + ((mode) == e_ENET_MODE_SMII_100 ) || \
76507 + ((mode) == e_ENET_MODE_GMII_1000 ) || \
76508 + ((mode) == e_ENET_MODE_RGMII_10 ) || \
76509 + ((mode) == e_ENET_MODE_RGMII_100 ) || \
76510 + ((mode) == e_ENET_MODE_RGMII_1000 ) || \
76511 + ((mode) == e_ENET_MODE_TBI_1000 ) || \
76512 + ((mode) == e_ENET_MODE_RTBI_1000 ) || \
76513 + ((mode) == e_ENET_MODE_SGMII_10 ) || \
76514 + ((mode) == e_ENET_MODE_SGMII_100 ) || \
76515 + ((mode) == e_ENET_MODE_SGMII_1000 ) || \
76516 + ((mode) == e_ENET_MODE_SGMII_BASEX_10 ) || \
76517 + ((mode) == e_ENET_MODE_SGMII_BASEX_100 ) || \
76518 + ((mode) == e_ENET_MODE_SGMII_BASEX_1000 ) || \
76519 + ((mode) == e_ENET_MODE_XGMII_10000) || \
76520 + ((mode) == e_ENET_MODE_QSGMII_1000) || \
76521 + ((mode) == e_ENET_MODE_QSGMII_BASEX_1000) || \
76522 + ((mode) == e_ENET_MODE_XFI_10000))
76523 +
76524 +
76525 +#define MAKE_ENET_MODE(_interface, _speed) (e_EnetMode)((_interface) | (_speed))
76526 +
76527 +#define ENET_INTERFACE_FROM_MODE(mode) (e_EnetInterface)((mode) & 0x0FFF0000)
76528 +#define ENET_SPEED_FROM_MODE(mode) (e_EnetSpeed)((mode) & 0x0000FFFF)
76529 +
76530 +#define ENET_ADDR_TO_UINT64(_enetAddr) \
76531 + (uint64_t)(((uint64_t)(_enetAddr)[0] << 40) | \
76532 + ((uint64_t)(_enetAddr)[1] << 32) | \
76533 + ((uint64_t)(_enetAddr)[2] << 24) | \
76534 + ((uint64_t)(_enetAddr)[3] << 16) | \
76535 + ((uint64_t)(_enetAddr)[4] << 8) | \
76536 + ((uint64_t)(_enetAddr)[5]))
76537 +
76538 +#define MAKE_ENET_ADDR_FROM_UINT64(_addr64, _enetAddr) \
76539 + do { \
76540 + int i; \
76541 + for (i=0; i < ENET_NUM_OCTETS_PER_ADDRESS; i++) \
76542 + (_enetAddr)[i] = (uint8_t)((_addr64) >> ((5-i)*8)); \
76543 + } while (0)
76544 +
76545 +
76546 +#endif /* __ENET_EXT_H */
76547 --- /dev/null
76548 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/error_ext.h
76549 @@ -0,0 +1,529 @@
76550 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
76551 + * All rights reserved.
76552 + *
76553 + * Redistribution and use in source and binary forms, with or without
76554 + * modification, are permitted provided that the following conditions are met:
76555 + * * Redistributions of source code must retain the above copyright
76556 + * notice, this list of conditions and the following disclaimer.
76557 + * * Redistributions in binary form must reproduce the above copyright
76558 + * notice, this list of conditions and the following disclaimer in the
76559 + * documentation and/or other materials provided with the distribution.
76560 + * * Neither the name of Freescale Semiconductor nor the
76561 + * names of its contributors may be used to endorse or promote products
76562 + * derived from this software without specific prior written permission.
76563 + *
76564 + *
76565 + * ALTERNATIVELY, this software may be distributed under the terms of the
76566 + * GNU General Public License ("GPL") as published by the Free Software
76567 + * Foundation, either version 2 of that License or (at your option) any
76568 + * later version.
76569 + *
76570 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
76571 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
76572 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
76573 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
76574 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
76575 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
76576 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
76577 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
76578 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
76579 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
76580 + */
76581 +
76582 +
76583 +/**************************************************************************//**
76584 + @File error_ext.h
76585 +
76586 + @Description Error definitions.
76587 +*//***************************************************************************/
76588 +
76589 +#ifndef __ERROR_EXT_H
76590 +#define __ERROR_EXT_H
76591 +
76592 +#if !defined(NCSW_LINUX)
76593 +#include <errno.h>
76594 +#endif
76595 +
76596 +#include "std_ext.h"
76597 +#include "xx_ext.h"
76598 +#include "core_ext.h"
76599 +
76600 +
76601 +
76602 +
76603 +/**************************************************************************//**
76604 + @Group gen_id General Drivers Utilities
76605 +
76606 + @Description External routines.
76607 +
76608 + @{
76609 +*//***************************************************************************/
76610 +
76611 +/**************************************************************************//**
76612 + @Group gen_error_id Errors, Events and Debug
76613 +
76614 + @Description External routines.
76615 +
76616 + @{
76617 +*//***************************************************************************/
76618 +
76619 +/******************************************************************************
76620 +The scheme below provides the bits description for error codes:
76621 +
76622 + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
76623 +| Reserved (should be zero) | Module ID |
76624 +
76625 + 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
76626 +| Error Type |
76627 +******************************************************************************/
76628 +
76629 +#define ERROR_CODE(_err) ((((uint32_t)_err) & 0x0000FFFF) | __ERR_MODULE__)
76630 +
76631 +#define GET_ERROR_TYPE(_errcode) ((_errcode) & 0x0000FFFF)
76632 + /**< Extract module code from error code (#t_Error) */
76633 +
76634 +#define GET_ERROR_MODULE(_errcode) ((_errcode) & 0x00FF0000)
76635 + /**< Extract error type (#e_ErrorType) from
76636 + error code (#t_Error) */
76637 +
76638 +
76639 +/**************************************************************************//**
76640 + @Description Error Type Enumeration
76641 +*//***************************************************************************/
76642 +typedef enum e_ErrorType /* Comments / Associated Message Strings */
76643 +{ /* ------------------------------------------------------------ */
76644 + E_OK = 0 /* Never use "RETURN_ERROR" with E_OK; Use "return E_OK;" */
76645 + ,E_WRITE_FAILED = EIO /**< Write access failed on memory/device. */
76646 + /* String: none, or device name. */
76647 + ,E_NO_DEVICE = ENXIO /**< The associated device is not initialized. */
76648 + /* String: none. */
76649 + ,E_NOT_AVAILABLE = EAGAIN
76650 + /**< Resource is unavailable. */
76651 + /* String: none, unless the operation is not the main goal
76652 + of the function (in this case add resource description). */
76653 + ,E_NO_MEMORY = ENOMEM /**< External memory allocation failed. */
76654 + /* String: description of item for which allocation failed. */
76655 + ,E_INVALID_ADDRESS = EFAULT
76656 + /**< Invalid address. */
76657 + /* String: description of the specific violation. */
76658 + ,E_BUSY = EBUSY /**< Resource or module is busy. */
76659 + /* String: none, unless the operation is not the main goal
76660 + of the function (in this case add resource description). */
76661 + ,E_ALREADY_EXISTS = EEXIST
76662 + /**< Requested resource or item already exists. */
76663 + /* Use when resource duplication or sharing are not allowed.
76664 + String: none, unless the operation is not the main goal
76665 + of the function (in this case add item description). */
76666 + ,E_INVALID_OPERATION = ENODEV
76667 + /**< The operation/command is invalid (unrecognized). */
76668 + /* String: none. */
76669 + ,E_INVALID_VALUE = EDOM /**< Invalid value. */
76670 + /* Use for non-enumeration parameters, and
76671 + only when other error types are not suitable.
76672 + String: parameter description + "(should be <attribute>)",
76673 + e.g: "Maximum Rx buffer length (should be divisible by 8)",
76674 + "Channel number (should be even)". */
76675 + ,E_NOT_IN_RANGE = ERANGE/**< Parameter value is out of range. */
76676 + /* Don't use this error for enumeration parameters.
76677 + String: parameter description + "(should be %d-%d)",
76678 + e.g: "Number of pad characters (should be 0-15)". */
76679 + ,E_NOT_SUPPORTED = ENOSYS
76680 + /**< The function is not supported or not implemented. */
76681 + /* String: none. */
76682 + ,E_INVALID_STATE /**< The operation is not allowed in current module state. */
76683 + /* String: none. */
76684 + ,E_INVALID_HANDLE /**< Invalid handle of module or object. */
76685 + /* String: none, unless the function takes in more than one
76686 + handle (in this case add the handle description) */
76687 + ,E_INVALID_ID /**< Invalid module ID (usually enumeration or index). */
76688 + /* String: none, unless the function takes in more than one
76689 + ID (in this case add the ID description) */
76690 + ,E_NULL_POINTER /**< Unexpected NULL pointer. */
76691 + /* String: pointer description. */
76692 + ,E_INVALID_SELECTION /**< Invalid selection or mode. */
76693 + /* Use for enumeration values, only when other error types
76694 + are not suitable.
76695 + String: parameter description. */
76696 + ,E_INVALID_COMM_MODE /**< Invalid communication mode. */
76697 + /* String: none, unless the function takes in more than one
76698 + communication mode indications (in this case add
76699 + parameter description). */
76700 + ,E_INVALID_MEMORY_TYPE /**< Invalid memory type. */
76701 + /* String: none, unless the function takes in more than one
76702 + memory types (in this case add memory description,
76703 + e.g: "Data memory", "Buffer descriptors memory"). */
76704 + ,E_INVALID_CLOCK /**< Invalid clock. */
76705 + /* String: none, unless the function takes in more than one
76706 + clocks (in this case add clock description,
76707 + e.g: "Rx clock", "Tx clock"). */
76708 + ,E_CONFLICT /**< Some setting conflicts with another setting. */
76709 + /* String: description of the conflicting settings. */
76710 + ,E_NOT_ALIGNED /**< Non-aligned address. */
76711 + /* String: parameter description + "(should be %d-bytes aligned)",
76712 + e.g: "Rx data buffer (should be 32-bytes aligned)". */
76713 + ,E_NOT_FOUND /**< Requested resource or item was not found. */
76714 + /* Use only when the resource/item is uniquely identified.
76715 + String: none, unless the operation is not the main goal
76716 + of the function (in this case add item description). */
76717 + ,E_FULL /**< Resource is full. */
76718 + /* String: none, unless the operation is not the main goal
76719 + of the function (in this case add resource description). */
76720 + ,E_EMPTY /**< Resource is empty. */
76721 + /* String: none, unless the operation is not the main goal
76722 + of the function (in this case add resource description). */
76723 + ,E_ALREADY_FREE /**< Specified resource or item is already free or deleted. */
76724 + /* String: none, unless the operation is not the main goal
76725 + of the function (in this case add item description). */
76726 + ,E_READ_FAILED /**< Read access failed on memory/device. */
76727 + /* String: none, or device name. */
76728 + ,E_INVALID_FRAME /**< Invalid frame object (NULL handle or missing buffers). */
76729 + /* String: none. */
76730 + ,E_SEND_FAILED /**< Send operation failed on device. */
76731 + /* String: none, or device name. */
76732 + ,E_RECEIVE_FAILED /**< Receive operation failed on device. */
76733 + /* String: none, or device name. */
76734 + ,E_TIMEOUT/* = ETIMEDOUT*/ /**< The operation timed out. */
76735 + /* String: none. */
76736 +
76737 + ,E_DUMMY_LAST /* NEVER USED */
76738 +
76739 +} e_ErrorType;
76740 +
76741 +/**************************************************************************//**
76742 + @Description Event Type Enumeration
76743 +*//***************************************************************************/
76744 +typedef enum e_Event /* Comments / Associated Flags and Message Strings */
76745 +{ /* ------------------------------------------------------------ */
76746 + EV_NO_EVENT = 0 /**< No event; Never used. */
76747 +
76748 + ,EV_RX_DISCARD /**< Received packet discarded (by the driver, and only for
76749 + complete packets);
76750 + Flags: error flags in case of error, zero otherwise. */
76751 + /* String: reason for discard, e.g: "Error in frame",
76752 + "Disordered frame", "Incomplete frame", "No frame object". */
76753 + ,EV_RX_ERROR /**< Receive error (by hardware/firmware);
76754 + Flags: usually status flags from the buffer descriptor. */
76755 + /* String: none. */
76756 + ,EV_TX_ERROR /**< Transmit error (by hardware/firmware);
76757 + Flags: usually status flags from the buffer descriptor. */
76758 + /* String: none. */
76759 + ,EV_NO_BUFFERS /**< System ran out of buffer objects;
76760 + Flags: zero. */
76761 + /* String: none. */
76762 + ,EV_NO_MB_FRAMES /**< System ran out of multi-buffer frame objects;
76763 + Flags: zero. */
76764 + /* String: none. */
76765 + ,EV_NO_SB_FRAMES /**< System ran out of single-buffer frame objects;
76766 + Flags: zero. */
76767 + /* String: none. */
76768 + ,EV_TX_QUEUE_FULL /**< Transmit queue is full;
76769 + Flags: zero. */
76770 + /* String: none. */
76771 + ,EV_RX_QUEUE_FULL /**< Receive queue is full;
76772 + Flags: zero. */
76773 + /* String: none. */
76774 + ,EV_INTR_QUEUE_FULL /**< Interrupt queue overflow;
76775 + Flags: zero. */
76776 + /* String: none. */
76777 + ,EV_NO_DATA_BUFFER /**< Data buffer allocation (from higher layer) failed;
76778 + Flags: zero. */
76779 + /* String: none. */
76780 + ,EV_OBJ_POOL_EMPTY /**< Objects pool is empty;
76781 + Flags: zero. */
76782 + /* String: object description (name). */
76783 + ,EV_BUS_ERROR /**< Illegal access on bus;
76784 + Flags: the address (if available) or bus identifier */
76785 + /* String: bus/address/module description. */
76786 + ,EV_PTP_TXTS_QUEUE_FULL /**< PTP Tx timestamps queue is full;
76787 + Flags: zero. */
76788 + /* String: none. */
76789 + ,EV_PTP_RXTS_QUEUE_FULL /**< PTP Rx timestamps queue is full;
76790 + Flags: zero. */
76791 + /* String: none. */
76792 + ,EV_DUMMY_LAST
76793 +
76794 +} e_Event;
76795 +
76796 +
76797 +/**************************************************************************//**
76798 + @Collection Debug Levels for Errors and Events
76799 +
76800 + The level description refers to errors only.
76801 + For events, classification is done by the user.
76802 +
76803 + The TRACE, INFO and WARNING levels are allowed only when using
76804 + the DBG macro, and are not allowed when using the error macros
76805 + (RETURN_ERROR or REPORT_ERROR).
76806 + @{
76807 +*//***************************************************************************/
76808 +#define REPORT_LEVEL_CRITICAL 1 /**< Crasher: Incorrect flow, NULL pointers/handles. */
76809 +#define REPORT_LEVEL_MAJOR 2 /**< Cannot proceed: Invalid operation, parameters or
76810 + configuration. */
76811 +#define REPORT_LEVEL_MINOR 3 /**< Recoverable problem: a repeating call with the same
76812 + parameters may be successful. */
76813 +#define REPORT_LEVEL_WARNING 4 /**< Something is not exactly right, yet it is not an error. */
76814 +#define REPORT_LEVEL_INFO 5 /**< Messages which may be of interest to user/programmer. */
76815 +#define REPORT_LEVEL_TRACE 6 /**< Program flow messages. */
76816 +
76817 +#define EVENT_DISABLED 0xFF /**< Disabled event (not reported at all) */
76818 +
76819 +/* @} */
76820 +
76821 +
76822 +
76823 +#define NO_MSG ("")
76824 +
76825 +#ifndef DEBUG_GLOBAL_LEVEL
76826 +#define DEBUG_GLOBAL_LEVEL REPORT_LEVEL_WARNING
76827 +#endif /* DEBUG_GLOBAL_LEVEL */
76828 +
76829 +#ifndef ERROR_GLOBAL_LEVEL
76830 +#define ERROR_GLOBAL_LEVEL DEBUG_GLOBAL_LEVEL
76831 +#endif /* ERROR_GLOBAL_LEVEL */
76832 +
76833 +#ifndef EVENT_GLOBAL_LEVEL
76834 +#define EVENT_GLOBAL_LEVEL REPORT_LEVEL_MINOR
76835 +#endif /* EVENT_GLOBAL_LEVEL */
76836 +
76837 +#ifdef EVENT_LOCAL_LEVEL
76838 +#define EVENT_DYNAMIC_LEVEL EVENT_LOCAL_LEVEL
76839 +#else
76840 +#define EVENT_DYNAMIC_LEVEL EVENT_GLOBAL_LEVEL
76841 +#endif /* EVENT_LOCAL_LEVEL */
76842 +
76843 +
76844 +#ifndef DEBUG_DYNAMIC_LEVEL
76845 +#define DEBUG_USING_STATIC_LEVEL
76846 +
76847 +#ifdef DEBUG_STATIC_LEVEL
76848 +#define DEBUG_DYNAMIC_LEVEL DEBUG_STATIC_LEVEL
76849 +#else
76850 +#define DEBUG_DYNAMIC_LEVEL DEBUG_GLOBAL_LEVEL
76851 +#endif /* DEBUG_STATIC_LEVEL */
76852 +
76853 +#else /* DEBUG_DYNAMIC_LEVEL */
76854 +#ifdef DEBUG_STATIC_LEVEL
76855 +#error "Please use either DEBUG_STATIC_LEVEL or DEBUG_DYNAMIC_LEVEL (not both)"
76856 +#else
76857 +int DEBUG_DYNAMIC_LEVEL = DEBUG_GLOBAL_LEVEL;
76858 +#endif /* DEBUG_STATIC_LEVEL */
76859 +#endif /* !DEBUG_DYNAMIC_LEVEL */
76860 +
76861 +
76862 +#ifndef ERROR_DYNAMIC_LEVEL
76863 +
76864 +#ifdef ERROR_STATIC_LEVEL
76865 +#define ERROR_DYNAMIC_LEVEL ERROR_STATIC_LEVEL
76866 +#else
76867 +#define ERROR_DYNAMIC_LEVEL ERROR_GLOBAL_LEVEL
76868 +#endif /* ERROR_STATIC_LEVEL */
76869 +
76870 +#else /* ERROR_DYNAMIC_LEVEL */
76871 +#ifdef ERROR_STATIC_LEVEL
76872 +#error "Please use either ERROR_STATIC_LEVEL or ERROR_DYNAMIC_LEVEL (not both)"
76873 +#else
76874 +int ERROR_DYNAMIC_LEVEL = ERROR_GLOBAL_LEVEL;
76875 +#endif /* ERROR_STATIC_LEVEL */
76876 +#endif /* !ERROR_DYNAMIC_LEVEL */
76877 +
76878 +#define PRINT_FORMAT "[CPU%02d, %s:%d %s]"
76879 +#define PRINT_FMT_PARAMS raw_smp_processor_id(), __FILE__, __LINE__, __FUNCTION__
76880 +
76881 +#if (!(defined(DEBUG_ERRORS)) || (DEBUG_ERRORS == 0))
76882 +/* No debug/error/event messages at all */
76883 +#define DBG(_level, _vmsg)
76884 +
76885 +#define REPORT_ERROR(_level, _err, _vmsg)
76886 +
76887 +#define RETURN_ERROR(_level, _err, _vmsg) \
76888 + return ERROR_CODE(_err)
76889 +
76890 +#if (REPORT_EVENTS > 0)
76891 +
76892 +#define REPORT_EVENT(_ev, _appId, _flg, _vmsg) \
76893 + do { \
76894 + if (_ev##_LEVEL <= EVENT_DYNAMIC_LEVEL) { \
76895 + XX_EventById((uint32_t)(_ev), (t_Handle)(_appId), (uint16_t)(_flg), NO_MSG); \
76896 + } \
76897 + } while (0)
76898 +
76899 +#else
76900 +
76901 +#define REPORT_EVENT(_ev, _appId, _flg, _vmsg)
76902 +
76903 +#endif /* (REPORT_EVENTS > 0) */
76904 +
76905 +
76906 +#else /* DEBUG_ERRORS > 0 */
76907 +
76908 +extern const char *dbgLevelStrings[];
76909 +extern const char *moduleStrings[];
76910 +#if (REPORT_EVENTS > 0)
76911 +extern const char *eventStrings[];
76912 +#endif /* (REPORT_EVENTS > 0) */
76913 +
76914 +char * ErrTypeStrings (e_ErrorType err);
76915 +
76916 +
76917 +#if ((defined(DEBUG_USING_STATIC_LEVEL)) && (DEBUG_DYNAMIC_LEVEL < REPORT_LEVEL_WARNING))
76918 +/* No need for DBG macro - debug level is higher anyway */
76919 +#define DBG(_level, _vmsg)
76920 +#else
76921 +#define DBG(_level, _vmsg) \
76922 + do { \
76923 + if (REPORT_LEVEL_##_level <= DEBUG_DYNAMIC_LEVEL) { \
76924 + XX_Print("> %s (%s) " PRINT_FORMAT ": ", \
76925 + dbgLevelStrings[REPORT_LEVEL_##_level - 1], \
76926 + moduleStrings[__ERR_MODULE__ >> 16], \
76927 + PRINT_FMT_PARAMS); \
76928 + XX_Print _vmsg; \
76929 + XX_Print("\r\n"); \
76930 + } \
76931 + } while (0)
76932 +#endif /* (defined(DEBUG_USING_STATIC_LEVEL) && (DEBUG_DYNAMIC_LEVEL < WARNING)) */
76933 +
76934 +
76935 +#define REPORT_ERROR(_level, _err, _vmsg) \
76936 + do { \
76937 + if (REPORT_LEVEL_##_level <= ERROR_DYNAMIC_LEVEL) { \
76938 + XX_Print("! %s %s Error " PRINT_FORMAT ": %s; ", \
76939 + dbgLevelStrings[REPORT_LEVEL_##_level - 1], \
76940 + moduleStrings[__ERR_MODULE__ >> 16], \
76941 + PRINT_FMT_PARAMS, \
76942 + ErrTypeStrings((e_ErrorType)GET_ERROR_TYPE(_err))); \
76943 + XX_Print _vmsg; \
76944 + XX_Print("\r\n"); \
76945 + } \
76946 + } while (0)
76947 +
76948 +
76949 +#define RETURN_ERROR(_level, _err, _vmsg) \
76950 + do { \
76951 + REPORT_ERROR(_level, (_err), _vmsg); \
76952 + return ERROR_CODE(_err); \
76953 + } while (0)
76954 +
76955 +
76956 +#if (REPORT_EVENTS > 0)
76957 +
76958 +#define REPORT_EVENT(_ev, _appId, _flg, _vmsg) \
76959 + do { \
76960 + if (_ev##_LEVEL <= EVENT_DYNAMIC_LEVEL) { \
76961 + XX_Print("~ %s %s Event " PRINT_FORMAT ": %s (flags: 0x%04x); ", \
76962 + dbgLevelStrings[_ev##_LEVEL - 1], \
76963 + moduleStrings[__ERR_MODULE__ >> 16], \
76964 + PRINT_FMT_PARAMS, \
76965 + eventStrings[((_ev) - EV_NO_EVENT - 1)], \
76966 + (uint16_t)(_flg)); \
76967 + XX_Print _vmsg; \
76968 + XX_Print("\r\n"); \
76969 + XX_EventById((uint32_t)(_ev), (t_Handle)(_appId), (uint16_t)(_flg), NO_MSG); \
76970 + } \
76971 + } while (0)
76972 +
76973 +#else /* not REPORT_EVENTS */
76974 +
76975 +#define REPORT_EVENT(_ev, _appId, _flg, _vmsg)
76976 +
76977 +#endif /* (REPORT_EVENTS > 0) */
76978 +
76979 +#endif /* (DEBUG_ERRORS > 0) */
76980 +
76981 +
76982 +/**************************************************************************//**
76983 + @Function ASSERT_COND
76984 +
76985 + @Description Assertion macro.
76986 +
76987 + @Param[in] _cond - The condition being checked, in positive form;
76988 + Failure of the condition triggers the assert.
76989 +*//***************************************************************************/
76990 +#ifdef DISABLE_ASSERTIONS
76991 +#define ASSERT_COND(_cond)
76992 +#else
76993 +#define ASSERT_COND(_cond) \
76994 + do { \
76995 + if (!(_cond)) { \
76996 + XX_Print("*** ASSERT_COND failed " PRINT_FORMAT "\r\n", \
76997 + PRINT_FMT_PARAMS); \
76998 + XX_Exit(1); \
76999 + } \
77000 + } while (0)
77001 +#endif /* DISABLE_ASSERTIONS */
77002 +
77003 +
77004 +#ifdef DISABLE_INIT_PARAMETERS_CHECK
77005 +
77006 +#define CHECK_INIT_PARAMETERS(handle, f_check)
77007 +#define CHECK_INIT_PARAMETERS_RETURN_VALUE(handle, f_check, retval)
77008 +
77009 +#else
77010 +
77011 +#define CHECK_INIT_PARAMETERS(handle, f_check) \
77012 + do { \
77013 + t_Error err = f_check(handle); \
77014 + if (err != E_OK) { \
77015 + RETURN_ERROR(MAJOR, err, NO_MSG); \
77016 + } \
77017 + } while (0)
77018 +
77019 +#define CHECK_INIT_PARAMETERS_RETURN_VALUE(handle, f_check, retval) \
77020 + do { \
77021 + t_Error err = f_check(handle); \
77022 + if (err != E_OK) { \
77023 + REPORT_ERROR(MAJOR, err, NO_MSG); \
77024 + return (retval); \
77025 + } \
77026 + } while (0)
77027 +
77028 +#endif /* DISABLE_INIT_PARAMETERS_CHECK */
77029 +
77030 +#ifdef DISABLE_SANITY_CHECKS
77031 +
77032 +#define SANITY_CHECK_RETURN_ERROR(_cond, _err)
77033 +#define SANITY_CHECK_RETURN_VALUE(_cond, _err, retval)
77034 +#define SANITY_CHECK_RETURN(_cond, _err)
77035 +#define SANITY_CHECK_EXIT(_cond, _err)
77036 +
77037 +#else /* DISABLE_SANITY_CHECKS */
77038 +
77039 +#define SANITY_CHECK_RETURN_ERROR(_cond, _err) \
77040 + do { \
77041 + if (!(_cond)) { \
77042 + RETURN_ERROR(CRITICAL, (_err), NO_MSG); \
77043 + } \
77044 + } while (0)
77045 +
77046 +#define SANITY_CHECK_RETURN_VALUE(_cond, _err, retval) \
77047 + do { \
77048 + if (!(_cond)) { \
77049 + REPORT_ERROR(CRITICAL, (_err), NO_MSG); \
77050 + return (retval); \
77051 + } \
77052 + } while (0)
77053 +
77054 +#define SANITY_CHECK_RETURN(_cond, _err) \
77055 + do { \
77056 + if (!(_cond)) { \
77057 + REPORT_ERROR(CRITICAL, (_err), NO_MSG); \
77058 + return; \
77059 + } \
77060 + } while (0)
77061 +
77062 +#define SANITY_CHECK_EXIT(_cond, _err) \
77063 + do { \
77064 + if (!(_cond)) { \
77065 + REPORT_ERROR(CRITICAL, (_err), NO_MSG); \
77066 + XX_Exit(1); \
77067 + } \
77068 + } while (0)
77069 +
77070 +#endif /* DISABLE_SANITY_CHECKS */
77071 +
77072 +/** @} */ /* end of Debug/error Utils group */
77073 +
77074 +/** @} */ /* end of General Utils group */
77075 +
77076 +#endif /* __ERROR_EXT_H */
77077 +
77078 +
77079 --- /dev/null
77080 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/etc/list_ext.h
77081 @@ -0,0 +1,358 @@
77082 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
77083 + * All rights reserved.
77084 + *
77085 + * Redistribution and use in source and binary forms, with or without
77086 + * modification, are permitted provided that the following conditions are met:
77087 + * * Redistributions of source code must retain the above copyright
77088 + * notice, this list of conditions and the following disclaimer.
77089 + * * Redistributions in binary form must reproduce the above copyright
77090 + * notice, this list of conditions and the following disclaimer in the
77091 + * documentation and/or other materials provided with the distribution.
77092 + * * Neither the name of Freescale Semiconductor nor the
77093 + * names of its contributors may be used to endorse or promote products
77094 + * derived from this software without specific prior written permission.
77095 + *
77096 + *
77097 + * ALTERNATIVELY, this software may be distributed under the terms of the
77098 + * GNU General Public License ("GPL") as published by the Free Software
77099 + * Foundation, either version 2 of that License or (at your option) any
77100 + * later version.
77101 + *
77102 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
77103 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
77104 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
77105 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
77106 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
77107 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
77108 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
77109 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
77110 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
77111 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
77112 + */
77113 +
77114 +
77115 +/**************************************************************************//**
77116 +
77117 + @File list_ext.h
77118 +
77119 + @Description External prototypes for list.c
77120 +*//***************************************************************************/
77121 +
77122 +#ifndef __LIST_EXT_H
77123 +#define __LIST_EXT_H
77124 +
77125 +
77126 +#include "std_ext.h"
77127 +
77128 +
77129 +/**************************************************************************//**
77130 + @Group etc_id Utility Library Application Programming Interface
77131 +
77132 + @Description External routines.
77133 +
77134 + @{
77135 +*//***************************************************************************/
77136 +
77137 +/**************************************************************************//**
77138 + @Group list_id List
77139 +
77140 + @Description List module functions,definitions and enums.
77141 +
77142 + @{
77143 +*//***************************************************************************/
77144 +
77145 +/**************************************************************************//**
77146 + @Description List structure.
77147 +*//***************************************************************************/
77148 +typedef struct List
77149 +{
77150 + struct List *p_Next; /**< A pointer to the next list object */
77151 + struct List *p_Prev; /**< A pointer to the previous list object */
77152 +} t_List;
77153 +
77154 +
77155 +/**************************************************************************//**
77156 + @Function LIST_FIRST/LIST_LAST/LIST_NEXT/LIST_PREV
77157 +
77158 + @Description Macro to get first/last/next/previous entry in a list.
77159 +
77160 + @Param[in] p_List - A pointer to a list.
77161 +*//***************************************************************************/
77162 +#define LIST_FIRST(p_List) (p_List)->p_Next
77163 +#define LIST_LAST(p_List) (p_List)->p_Prev
77164 +#define LIST_NEXT LIST_FIRST
77165 +#define LIST_PREV LIST_LAST
77166 +
77167 +
77168 +/**************************************************************************//**
77169 + @Function LIST_INIT
77170 +
77171 + @Description Macro for initialization of a list struct.
77172 +
77173 + @Param[in] lst - The t_List object to initialize.
77174 +*//***************************************************************************/
77175 +#define LIST_INIT(lst) {&(lst), &(lst)}
77176 +
77177 +
77178 +/**************************************************************************//**
77179 + @Function LIST
77180 +
77181 + @Description Macro to declare of a list.
77182 +
77183 + @Param[in] listName - The list object name.
77184 +*//***************************************************************************/
77185 +#define LIST(listName) t_List listName = LIST_INIT(listName)
77186 +
77187 +
77188 +/**************************************************************************//**
77189 + @Function INIT_LIST
77190 +
77191 + @Description Macro to initialize a list pointer.
77192 +
77193 + @Param[in] p_List - The list pointer.
77194 +*//***************************************************************************/
77195 +#define INIT_LIST(p_List) LIST_FIRST(p_List) = LIST_LAST(p_List) = (p_List)
77196 +
77197 +
77198 +/**************************************************************************//**
77199 + @Function LIST_OBJECT
77200 +
77201 + @Description Macro to get the struct (object) for this entry.
77202 +
77203 + @Param[in] type - The type of the struct (object) this list is embedded in.
77204 + @Param[in] member - The name of the t_List object within the struct.
77205 +
77206 + @Return The structure pointer for this entry.
77207 +*//***************************************************************************/
77208 +#define MEMBER_OFFSET(type, member) (PTR_TO_UINT(&((type *)0)->member))
77209 +#define LIST_OBJECT(p_List, type, member) \
77210 + ((type *)((char *)(p_List)-MEMBER_OFFSET(type, member)))
77211 +
77212 +
77213 +/**************************************************************************//**
77214 + @Function LIST_FOR_EACH
77215 +
77216 + @Description Macro to iterate over a list.
77217 +
77218 + @Param[in] p_Pos - A pointer to a list to use as a loop counter.
77219 + @Param[in] p_Head - A pointer to the head for your list pointer.
77220 +
77221 + @Cautions You can't delete items with this routine.
77222 + For deletion use LIST_FOR_EACH_SAFE().
77223 +*//***************************************************************************/
77224 +#define LIST_FOR_EACH(p_Pos, p_Head) \
77225 + for (p_Pos = LIST_FIRST(p_Head); p_Pos != (p_Head); p_Pos = LIST_NEXT(p_Pos))
77226 +
77227 +
77228 +/**************************************************************************//**
77229 + @Function LIST_FOR_EACH_SAFE
77230 +
77231 + @Description Macro to iterate over a list safe against removal of list entry.
77232 +
77233 + @Param[in] p_Pos - A pointer to a list to use as a loop counter.
77234 + @Param[in] p_Tmp - Another pointer to a list to use as temporary storage.
77235 + @Param[in] p_Head - A pointer to the head for your list pointer.
77236 +*//***************************************************************************/
77237 +#define LIST_FOR_EACH_SAFE(p_Pos, p_Tmp, p_Head) \
77238 + for (p_Pos = LIST_FIRST(p_Head), p_Tmp = LIST_FIRST(p_Pos); \
77239 + p_Pos != (p_Head); \
77240 + p_Pos = p_Tmp, p_Tmp = LIST_NEXT(p_Pos))
77241 +
77242 +
77243 +/**************************************************************************//**
77244 + @Function LIST_FOR_EACH_OBJECT_SAFE
77245 +
77246 + @Description Macro to iterate over list of given type safely.
77247 +
77248 + @Param[in] p_Pos - A pointer to a list to use as a loop counter.
77249 + @Param[in] p_Tmp - Another pointer to a list to use as temporary storage.
77250 + @Param[in] type - The type of the struct this is embedded in.
77251 + @Param[in] p_Head - A pointer to the head for your list pointer.
77252 + @Param[in] member - The name of the list_struct within the struct.
77253 +
77254 + @Cautions You can't delete items with this routine.
77255 + For deletion use LIST_FOR_EACH_SAFE().
77256 +*//***************************************************************************/
77257 +#define LIST_FOR_EACH_OBJECT_SAFE(p_Pos, p_Tmp, p_Head, type, member) \
77258 + for (p_Pos = LIST_OBJECT(LIST_FIRST(p_Head), type, member), \
77259 + p_Tmp = LIST_OBJECT(LIST_FIRST(&p_Pos->member), type, member); \
77260 + &p_Pos->member != (p_Head); \
77261 + p_Pos = p_Tmp, \
77262 + p_Tmp = LIST_OBJECT(LIST_FIRST(&p_Pos->member), type, member))
77263 +
77264 +/**************************************************************************//**
77265 + @Function LIST_FOR_EACH_OBJECT
77266 +
77267 + @Description Macro to iterate over list of given type.
77268 +
77269 + @Param[in] p_Pos - A pointer to a list to use as a loop counter.
77270 + @Param[in] type - The type of the struct this is embedded in.
77271 + @Param[in] p_Head - A pointer to the head for your list pointer.
77272 + @Param[in] member - The name of the list_struct within the struct.
77273 +
77274 + @Cautions You can't delete items with this routine.
77275 + For deletion use LIST_FOR_EACH_SAFE().
77276 +*//***************************************************************************/
77277 +#define LIST_FOR_EACH_OBJECT(p_Pos, type, p_Head, member) \
77278 + for (p_Pos = LIST_OBJECT(LIST_FIRST(p_Head), type, member); \
77279 + &p_Pos->member != (p_Head); \
77280 + p_Pos = LIST_OBJECT(LIST_FIRST(&(p_Pos->member)), type, member))
77281 +
77282 +
77283 +/**************************************************************************//**
77284 + @Function LIST_Add
77285 +
77286 + @Description Add a new entry to a list.
77287 +
77288 + Insert a new entry after the specified head.
77289 + This is good for implementing stacks.
77290 +
77291 + @Param[in] p_New - A pointer to a new list entry to be added.
77292 + @Param[in] p_Head - A pointer to a list head to add it after.
77293 +
77294 + @Return none.
77295 +*//***************************************************************************/
77296 +static __inline__ void LIST_Add(t_List *p_New, t_List *p_Head)
77297 +{
77298 + LIST_PREV(LIST_NEXT(p_Head)) = p_New;
77299 + LIST_NEXT(p_New) = LIST_NEXT(p_Head);
77300 + LIST_PREV(p_New) = p_Head;
77301 + LIST_NEXT(p_Head) = p_New;
77302 +}
77303 +
77304 +
77305 +/**************************************************************************//**
77306 + @Function LIST_AddToTail
77307 +
77308 + @Description Add a new entry to a list.
77309 +
77310 + Insert a new entry before the specified head.
77311 + This is useful for implementing queues.
77312 +
77313 + @Param[in] p_New - A pointer to a new list entry to be added.
77314 + @Param[in] p_Head - A pointer to a list head to add it before.
77315 +
77316 + @Return none.
77317 +*//***************************************************************************/
77318 +static __inline__ void LIST_AddToTail(t_List *p_New, t_List *p_Head)
77319 +{
77320 + LIST_NEXT(LIST_PREV(p_Head)) = p_New;
77321 + LIST_PREV(p_New) = LIST_PREV(p_Head);
77322 + LIST_NEXT(p_New) = p_Head;
77323 + LIST_PREV(p_Head) = p_New;
77324 +}
77325 +
77326 +
77327 +/**************************************************************************//**
77328 + @Function LIST_Del
77329 +
77330 + @Description Deletes entry from a list.
77331 +
77332 + @Param[in] p_Entry - A pointer to the element to delete from the list.
77333 +
77334 + @Return none.
77335 +
77336 + @Cautions LIST_IsEmpty() on entry does not return true after this,
77337 + the entry is in an undefined state.
77338 +*//***************************************************************************/
77339 +static __inline__ void LIST_Del(t_List *p_Entry)
77340 +{
77341 + LIST_PREV(LIST_NEXT(p_Entry)) = LIST_PREV(p_Entry);
77342 + LIST_NEXT(LIST_PREV(p_Entry)) = LIST_NEXT(p_Entry);
77343 +}
77344 +
77345 +
77346 +/**************************************************************************//**
77347 + @Function LIST_DelAndInit
77348 +
77349 + @Description Deletes entry from list and reinitialize it.
77350 +
77351 + @Param[in] p_Entry - A pointer to the element to delete from the list.
77352 +
77353 + @Return none.
77354 +*//***************************************************************************/
77355 +static __inline__ void LIST_DelAndInit(t_List *p_Entry)
77356 +{
77357 + LIST_Del(p_Entry);
77358 + INIT_LIST(p_Entry);
77359 +}
77360 +
77361 +
77362 +/**************************************************************************//**
77363 + @Function LIST_Move
77364 +
77365 + @Description Delete from one list and add as another's head.
77366 +
77367 + @Param[in] p_Entry - A pointer to the list entry to move.
77368 + @Param[in] p_Head - A pointer to the list head that will precede our entry.
77369 +
77370 + @Return none.
77371 +*//***************************************************************************/
77372 +static __inline__ void LIST_Move(t_List *p_Entry, t_List *p_Head)
77373 +{
77374 + LIST_Del(p_Entry);
77375 + LIST_Add(p_Entry, p_Head);
77376 +}
77377 +
77378 +
77379 +/**************************************************************************//**
77380 + @Function LIST_MoveToTail
77381 +
77382 + @Description Delete from one list and add as another's tail.
77383 +
77384 + @Param[in] p_Entry - A pointer to the entry to move.
77385 + @Param[in] p_Head - A pointer to the list head that will follow our entry.
77386 +
77387 + @Return none.
77388 +*//***************************************************************************/
77389 +static __inline__ void LIST_MoveToTail(t_List *p_Entry, t_List *p_Head)
77390 +{
77391 + LIST_Del(p_Entry);
77392 + LIST_AddToTail(p_Entry, p_Head);
77393 +}
77394 +
77395 +
77396 +/**************************************************************************//**
77397 + @Function LIST_IsEmpty
77398 +
77399 + @Description Tests whether a list is empty.
77400 +
77401 + @Param[in] p_List - A pointer to the list to test.
77402 +
77403 + @Return 1 if the list is empty, 0 otherwise.
77404 +*//***************************************************************************/
77405 +static __inline__ int LIST_IsEmpty(t_List *p_List)
77406 +{
77407 + return (LIST_FIRST(p_List) == p_List);
77408 +}
77409 +
77410 +
77411 +/**************************************************************************//**
77412 + @Function LIST_Append
77413 +
77414 + @Description Join two lists.
77415 +
77416 + @Param[in] p_NewList - A pointer to the new list to add.
77417 + @Param[in] p_Head - A pointer to the place to add it in the first list.
77418 +
77419 + @Return none.
77420 +*//***************************************************************************/
77421 +void LIST_Append(t_List *p_NewList, t_List *p_Head);
77422 +
77423 +
77424 +/**************************************************************************//**
77425 + @Function LIST_NumOfObjs
77426 +
77427 + @Description Counts number of objects in the list
77428 +
77429 + @Param[in] p_List - A pointer to the list which objects are to be counted.
77430 +
77431 + @Return Number of objects in the list.
77432 +*//***************************************************************************/
77433 +int LIST_NumOfObjs(t_List *p_List);
77434 +
77435 +/** @} */ /* end of list_id group */
77436 +/** @} */ /* end of etc_id group */
77437 +
77438 +
77439 +#endif /* __LIST_EXT_H */
77440 --- /dev/null
77441 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/etc/mem_ext.h
77442 @@ -0,0 +1,318 @@
77443 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
77444 + * All rights reserved.
77445 + *
77446 + * Redistribution and use in source and binary forms, with or without
77447 + * modification, are permitted provided that the following conditions are met:
77448 + * * Redistributions of source code must retain the above copyright
77449 + * notice, this list of conditions and the following disclaimer.
77450 + * * Redistributions in binary form must reproduce the above copyright
77451 + * notice, this list of conditions and the following disclaimer in the
77452 + * documentation and/or other materials provided with the distribution.
77453 + * * Neither the name of Freescale Semiconductor nor the
77454 + * names of its contributors may be used to endorse or promote products
77455 + * derived from this software without specific prior written permission.
77456 + *
77457 + *
77458 + * ALTERNATIVELY, this software may be distributed under the terms of the
77459 + * GNU General Public License ("GPL") as published by the Free Software
77460 + * Foundation, either version 2 of that License or (at your option) any
77461 + * later version.
77462 + *
77463 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
77464 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
77465 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
77466 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
77467 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
77468 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
77469 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
77470 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
77471 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
77472 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
77473 + */
77474 +
77475 +
77476 +/**************************************************************************//**
77477 +
77478 + @File mem_ext.h
77479 +
77480 + @Description External prototypes for the memory manager object
77481 +*//***************************************************************************/
77482 +
77483 +#ifndef __MEM_EXT_H
77484 +#define __MEM_EXT_H
77485 +
77486 +#include "std_ext.h"
77487 +#include "part_ext.h"
77488 +
77489 +
77490 +/**************************************************************************//**
77491 + @Group etc_id Utility Library Application Programming Interface
77492 +
77493 + @Description External routines.
77494 +
77495 + @{
77496 +*//***************************************************************************/
77497 +
77498 +/**************************************************************************//**
77499 + @Group mem_id Slab Memory Manager
77500 +
77501 + @Description Slab Memory Manager module functions, definitions and enums.
77502 +
77503 + @{
77504 +*//***************************************************************************/
77505 +
77506 +/* Each block is of the following structure:
77507 + *
77508 + *
77509 + * +-----------+----------+---------------------------+-----------+-----------+
77510 + * | Alignment | Prefix | Data | Postfix | Alignment |
77511 + * | field | field | field | field | Padding |
77512 + * | | | | | |
77513 + * +-----------+----------+---------------------------+-----------+-----------+
77514 + * and at the beginning of all bytes, an additional optional padding might reside
77515 + * to ensure that the first blocks data field is aligned as requested.
77516 + */
77517 +
77518 +
77519 +#define MEM_MAX_NAME_LENGTH 8
77520 +
77521 +/**************************************************************************//*
77522 + @Description Memory Segment structure
77523 +*//***************************************************************************/
77524 +
77525 +typedef struct
77526 +{
77527 + char name[MEM_MAX_NAME_LENGTH];
77528 + /* The segment's name */
77529 + uint8_t **p_Bases; /* Base addresses of the segments */
77530 + uint8_t **p_BlocksStack; /* Array of pointers to blocks */
77531 + t_Handle h_Spinlock;
77532 + uint16_t dataSize; /* Size of each data block */
77533 + uint16_t prefixSize; /* How many bytes to reserve before the data */
77534 + uint16_t postfixSize; /* How many bytes to reserve after the data */
77535 + uint16_t alignment; /* Requested alignment for the data field */
77536 + int allocOwner; /* Memory allocation owner */
77537 + uint32_t getFailures; /* Number of times get failed */
77538 + uint32_t num; /* Number of blocks in segment */
77539 + uint32_t current; /* Current block */
77540 + bool consecutiveMem; /* Allocate consecutive data blocks memory */
77541 +#ifdef DEBUG_MEM_LEAKS
77542 + void *p_MemDbg; /* MEM debug database (MEM leaks detection) */
77543 + uint32_t blockOffset;
77544 + uint32_t blockSize;
77545 +#endif /* DEBUG_MEM_LEAKS */
77546 +} t_MemorySegment;
77547 +
77548 +
77549 +
77550 +/**************************************************************************//**
77551 + @Function MEM_Init
77552 +
77553 + @Description Create a new memory segment.
77554 +
77555 + @Param[in] name - Name of memory partition.
77556 + @Param[in] p_Handle - Handle to new segment is returned through here.
77557 + @Param[in] num - Number of blocks in new segment.
77558 + @Param[in] dataSize - Size of blocks in segment.
77559 + @Param[in] prefixSize - How many bytes to allocate before the data.
77560 + @Param[in] postfixSize - How many bytes to allocate after the data.
77561 + @Param[in] alignment - Requested alignment for data field (in bytes).
77562 +
77563 + @Return E_OK - success, E_NO_MEMORY - out of memory.
77564 +*//***************************************************************************/
77565 +t_Error MEM_Init(char name[],
77566 + t_Handle *p_Handle,
77567 + uint32_t num,
77568 + uint16_t dataSize,
77569 + uint16_t prefixSize,
77570 + uint16_t postfixSize,
77571 + uint16_t alignment);
77572 +
77573 +/**************************************************************************//**
77574 + @Function MEM_InitSmart
77575 +
77576 + @Description Create a new memory segment.
77577 +
77578 + @Param[in] name - Name of memory partition.
77579 + @Param[in] p_Handle - Handle to new segment is returned through here.
77580 + @Param[in] num - Number of blocks in new segment.
77581 + @Param[in] dataSize - Size of blocks in segment.
77582 + @Param[in] prefixSize - How many bytes to allocate before the data.
77583 + @Param[in] postfixSize - How many bytes to allocate after the data.
77584 + @Param[in] alignment - Requested alignment for data field (in bytes).
77585 + @Param[in] memPartitionId - Memory partition ID for allocation.
77586 + @Param[in] consecutiveMem - Whether to allocate the memory blocks
77587 + continuously or not.
77588 +
77589 + @Return E_OK - success, E_NO_MEMORY - out of memory.
77590 +*//***************************************************************************/
77591 +t_Error MEM_InitSmart(char name[],
77592 + t_Handle *p_Handle,
77593 + uint32_t num,
77594 + uint16_t dataSize,
77595 + uint16_t prefixSize,
77596 + uint16_t postfixSize,
77597 + uint16_t alignment,
77598 + uint8_t memPartitionId,
77599 + bool consecutiveMem);
77600 +
77601 +/**************************************************************************//**
77602 + @Function MEM_InitByAddress
77603 +
77604 + @Description Create a new memory segment with a specified base address.
77605 +
77606 + @Param[in] name - Name of memory partition.
77607 + @Param[in] p_Handle - Handle to new segment is returned through here.
77608 + @Param[in] num - Number of blocks in new segment.
77609 + @Param[in] dataSize - Size of blocks in segment.
77610 + @Param[in] prefixSize - How many bytes to allocate before the data.
77611 + @Param[in] postfixSize - How many bytes to allocate after the data.
77612 + @Param[in] alignment - Requested alignment for data field (in bytes).
77613 + @Param[in] address - The required base address.
77614 +
77615 + @Return E_OK - success, E_NO_MEMORY - out of memory.
77616 + *//***************************************************************************/
77617 +t_Error MEM_InitByAddress(char name[],
77618 + t_Handle *p_Handle,
77619 + uint32_t num,
77620 + uint16_t dataSize,
77621 + uint16_t prefixSize,
77622 + uint16_t postfixSize,
77623 + uint16_t alignment,
77624 + uint8_t *address);
77625 +
77626 +/**************************************************************************//**
77627 + @Function MEM_Free
77628 +
77629 + @Description Free a specific memory segment.
77630 +
77631 + @Param[in] h_Mem - Handle to memory segment.
77632 +
77633 + @Return None.
77634 +*//***************************************************************************/
77635 +void MEM_Free(t_Handle h_Mem);
77636 +
77637 +/**************************************************************************//**
77638 + @Function MEM_Get
77639 +
77640 + @Description Get a block of memory from a segment.
77641 +
77642 + @Param[in] h_Mem - Handle to memory segment.
77643 +
77644 + @Return Pointer to new memory block on success,0 otherwise.
77645 +*//***************************************************************************/
77646 +void * MEM_Get(t_Handle h_Mem);
77647 +
77648 +/**************************************************************************//**
77649 + @Function MEM_GetN
77650 +
77651 + @Description Get up to N blocks of memory from a segment.
77652 +
77653 + The blocks are assumed to be of a fixed size (one size per segment).
77654 +
77655 + @Param[in] h_Mem - Handle to memory segment.
77656 + @Param[in] num - Number of blocks to allocate.
77657 + @Param[out] array - Array of at least num pointers to which the addresses
77658 + of the allocated blocks are written.
77659 +
77660 + @Return The number of blocks actually allocated.
77661 +
77662 + @Cautions Interrupts are disabled for all of the allocation loop.
77663 + Although this loop is very short for each block (several machine
77664 + instructions), you should not allocate a very large number
77665 + of blocks via this routine.
77666 +*//***************************************************************************/
77667 +uint16_t MEM_GetN(t_Handle h_Mem, uint32_t num, void *array[]);
77668 +
77669 +/**************************************************************************//**
77670 + @Function MEM_Put
77671 +
77672 + @Description Put a block of memory back to a segment.
77673 +
77674 + @Param[in] h_Mem - Handle to memory segment.
77675 + @Param[in] p_Block - The block to return.
77676 +
77677 + @Return Pointer to new memory block on success,0 otherwise.
77678 +*//***************************************************************************/
77679 +t_Error MEM_Put(t_Handle h_Mem, void *p_Block);
77680 +
77681 +/**************************************************************************//**
77682 + @Function MEM_ComputePartitionSize
77683 +
77684 + @Description calculate a tight upper boundary of the size of a partition with
77685 + given attributes.
77686 +
77687 + The returned value is suitable if one wants to use MEM_InitByAddress().
77688 +
77689 + @Param[in] num - The number of blocks in the segment.
77690 + @Param[in] dataSize - Size of block to get.
77691 + @Param[in] prefixSize - The prefix size
77692 + @Param postfixSize - The postfix size
77693 + @Param[in] alignment - The requested alignment value (in bytes)
77694 +
77695 + @Return The memory block size a segment with the given attributes needs.
77696 +*//***************************************************************************/
77697 +uint32_t MEM_ComputePartitionSize(uint32_t num,
77698 + uint16_t dataSize,
77699 + uint16_t prefixSize,
77700 + uint16_t postfixSize,
77701 + uint16_t alignment);
77702 +
77703 +#ifdef DEBUG_MEM_LEAKS
77704 +#if !((defined(__MWERKS__) || defined(__GNUC__)) && (__dest_os == __ppc_eabi))
77705 +#error "Memory-Leaks-Debug option is supported only for freescale CodeWarrior"
77706 +#endif /* !(defined(__MWERKS__) && ... */
77707 +
77708 +/**************************************************************************//**
77709 + @Function MEM_CheckLeaks
77710 +
77711 + @Description Report MEM object leaks.
77712 +
77713 + This routine is automatically called by the MEM_Free() routine,
77714 + but it can also be invoked while the MEM object is alive.
77715 +
77716 + @Param[in] h_Mem - Handle to memory segment.
77717 +
77718 + @Return None.
77719 +*//***************************************************************************/
77720 +void MEM_CheckLeaks(t_Handle h_Mem);
77721 +
77722 +#else /* not DEBUG_MEM_LEAKS */
77723 +#define MEM_CheckLeaks(h_Mem)
77724 +#endif /* not DEBUG_MEM_LEAKS */
77725 +
77726 +/**************************************************************************//**
77727 + @Description Get base of MEM
77728 +*//***************************************************************************/
77729 +#define MEM_GetBase(h_Mem) ((t_MemorySegment *)(h_Mem))->p_Bases[0]
77730 +
77731 +/**************************************************************************//**
77732 + @Description Get size of MEM block
77733 +*//***************************************************************************/
77734 +#define MEM_GetSize(h_Mem) ((t_MemorySegment *)(h_Mem))->dataSize
77735 +
77736 +/**************************************************************************//**
77737 + @Description Get prefix size of MEM block
77738 +*//***************************************************************************/
77739 +#define MEM_GetPrefixSize(h_Mem) ((t_MemorySegment *)(h_Mem))->prefixSize
77740 +
77741 +/**************************************************************************//**
77742 + @Description Get postfix size of MEM block
77743 +*//***************************************************************************/
77744 +#define MEM_GetPostfixSize(h_Mem) ((t_MemorySegment *)(h_Mem))->postfixSize
77745 +
77746 +/**************************************************************************//**
77747 + @Description Get alignment of MEM block (in bytes)
77748 +*//***************************************************************************/
77749 +#define MEM_GetAlignment(h_Mem) ((t_MemorySegment *)(h_Mem))->alignment
77750 +
77751 +/**************************************************************************//**
77752 + @Description Get the number of blocks in the segment
77753 +*//***************************************************************************/
77754 +#define MEM_GetNumOfBlocks(h_Mem) ((t_MemorySegment *)(h_Mem))->num
77755 +
77756 +/** @} */ /* end of MEM group */
77757 +/** @} */ /* end of etc_id group */
77758 +
77759 +
77760 +#endif /* __MEM_EXT_H */
77761 --- /dev/null
77762 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/etc/memcpy_ext.h
77763 @@ -0,0 +1,208 @@
77764 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
77765 + * All rights reserved.
77766 + *
77767 + * Redistribution and use in source and binary forms, with or without
77768 + * modification, are permitted provided that the following conditions are met:
77769 + * * Redistributions of source code must retain the above copyright
77770 + * notice, this list of conditions and the following disclaimer.
77771 + * * Redistributions in binary form must reproduce the above copyright
77772 + * notice, this list of conditions and the following disclaimer in the
77773 + * documentation and/or other materials provided with the distribution.
77774 + * * Neither the name of Freescale Semiconductor nor the
77775 + * names of its contributors may be used to endorse or promote products
77776 + * derived from this software without specific prior written permission.
77777 + *
77778 + *
77779 + * ALTERNATIVELY, this software may be distributed under the terms of the
77780 + * GNU General Public License ("GPL") as published by the Free Software
77781 + * Foundation, either version 2 of that License or (at your option) any
77782 + * later version.
77783 + *
77784 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
77785 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
77786 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
77787 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
77788 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
77789 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
77790 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
77791 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
77792 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
77793 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
77794 + */
77795 +
77796 +
77797 +/**************************************************************************//**
77798 +
77799 + @File memcpy_ext.h
77800 +
77801 + @Description Efficient functions for copying and setting blocks of memory.
77802 +*//***************************************************************************/
77803 +
77804 +#ifndef __MEMCPY_EXT_H
77805 +#define __MEMCPY_EXT_H
77806 +
77807 +#include "std_ext.h"
77808 +
77809 +
77810 +/**************************************************************************//**
77811 + @Group etc_id Utility Library Application Programming Interface
77812 +
77813 + @Description External routines.
77814 +
77815 + @{
77816 +*//***************************************************************************/
77817 +
77818 +/**************************************************************************//**
77819 + @Group mem_cpy Memory Copy
77820 +
77821 + @Description Memory Copy module functions,definitions and enums.
77822 +
77823 + @{
77824 +*//***************************************************************************/
77825 +
77826 +/**************************************************************************//**
77827 + @Function MemCpy32
77828 +
77829 + @Description Copies one memory buffer into another one in 4-byte chunks!
77830 + Which should be more efficient than byte by byte.
77831 +
77832 + For large buffers (over 60 bytes) this function is about 4 times
77833 + more efficient than the trivial memory copy. For short buffers
77834 + it is reduced to the trivial copy and may be a bit worse.
77835 +
77836 + @Param[in] pDst - The address of the destination buffer.
77837 + @Param[in] pSrc - The address of the source buffer.
77838 + @Param[in] size - The number of bytes that will be copied from pSrc to pDst.
77839 +
77840 + @Return pDst (the address of the destination buffer).
77841 +
77842 + @Cautions There is no parameter or boundary checking! It is up to the user
77843 + to supply non-null parameters as source & destination and size
77844 + that actually fits into the destination buffer.
77845 +*//***************************************************************************/
77846 +void * MemCpy32(void* pDst,void* pSrc, uint32_t size);
77847 +void * IO2IOCpy32(void* pDst,void* pSrc, uint32_t size);
77848 +void * IO2MemCpy32(void* pDst,void* pSrc, uint32_t size);
77849 +void * Mem2IOCpy32(void* pDst,void* pSrc, uint32_t size);
77850 +
77851 +/**************************************************************************//**
77852 + @Function MemCpy64
77853 +
77854 + @Description Copies one memory buffer into another one in 8-byte chunks!
77855 + Which should be more efficient than byte by byte.
77856 +
77857 + For large buffers (over 60 bytes) this function is about 8 times
77858 + more efficient than the trivial memory copy. For short buffers
77859 + it is reduced to the trivial copy and may be a bit worse.
77860 +
77861 + Some testing suggests that MemCpy32() preforms better than
77862 + MemCpy64() over small buffers. On average they break even at
77863 + 100 byte buffers. For buffers larger than that MemCpy64 is
77864 + superior.
77865 +
77866 + @Param[in] pDst - The address of the destination buffer.
77867 + @Param[in] pSrc - The address of the source buffer.
77868 + @Param[in] size - The number of bytes that will be copied from pSrc to pDst.
77869 +
77870 + @Return pDst (the address of the destination buffer).
77871 +
77872 + @Cautions There is no parameter or boundary checking! It is up to the user
77873 + to supply non null parameters as source & destination and size
77874 + that actually fits into their buffer.
77875 +
77876 + Do not use under Linux.
77877 +*//***************************************************************************/
77878 +void * MemCpy64(void* pDst,void* pSrc, uint32_t size);
77879 +
77880 +/**************************************************************************//**
77881 + @Function MemSet32
77882 +
77883 + @Description Sets all bytes of a memory buffer to a specific value, in
77884 + 4-byte chunks.
77885 +
77886 + @Param[in] pDst - The address of the destination buffer.
77887 + @Param[in] val - Value to set destination bytes to.
77888 + @Param[in] size - The number of bytes that will be set to val.
77889 +
77890 + @Return pDst (the address of the destination buffer).
77891 +
77892 + @Cautions There is no parameter or boundary checking! It is up to the user
77893 + to supply non null parameter as destination and size
77894 + that actually fits into the destination buffer.
77895 +*//***************************************************************************/
77896 +void * MemSet32(void* pDst, uint8_t val, uint32_t size);
77897 +void * IOMemSet32(void* pDst, uint8_t val, uint32_t size);
77898 +
77899 +/**************************************************************************//**
77900 + @Function MemSet64
77901 +
77902 + @Description Sets all bytes of a memory buffer to a specific value, in
77903 + 8-byte chunks.
77904 +
77905 + @Param[in] pDst - The address of the destination buffer.
77906 + @Param[in] val - Value to set destination bytes to.
77907 + @Param[in] size - The number of bytes that will be set to val.
77908 +
77909 + @Return pDst (the address of the destination buffer).
77910 +
77911 + @Cautions There is no parameter or boundary checking! It is up to the user
77912 + to supply non null parameter as destination and size
77913 + that actually fits into the destination buffer.
77914 +*//***************************************************************************/
77915 +void * MemSet64(void* pDst, uint8_t val, uint32_t size);
77916 +
77917 +/**************************************************************************//**
77918 + @Function MemDisp
77919 +
77920 + @Description Displays a block of memory in chunks of 32 bits.
77921 +
77922 + @Param[in] addr - The address of the memory to display.
77923 + @Param[in] size - The number of bytes that will be displayed.
77924 +
77925 + @Return None.
77926 +
77927 + @Cautions There is no parameter or boundary checking! It is up to the user
77928 + to supply non null parameter as destination and size
77929 + that actually fits into the destination buffer.
77930 +*//***************************************************************************/
77931 +void MemDisp(uint8_t *addr, int size);
77932 +
77933 +/**************************************************************************//**
77934 + @Function MemCpy8
77935 +
77936 + @Description Trivial copy one memory buffer into another byte by byte
77937 +
77938 + @Param[in] pDst - The address of the destination buffer.
77939 + @Param[in] pSrc - The address of the source buffer.
77940 + @Param[in] size - The number of bytes that will be copied from pSrc to pDst.
77941 +
77942 + @Return pDst (the address of the destination buffer).
77943 +
77944 + @Cautions There is no parameter or boundary checking! It is up to the user
77945 + to supply non-null parameters as source & destination and size
77946 + that actually fits into the destination buffer.
77947 +*//***************************************************************************/
77948 +void * MemCpy8(void* pDst,void* pSrc, uint32_t size);
77949 +
77950 +/**************************************************************************//**
77951 + @Function MemSet8
77952 +
77953 + @Description Sets all bytes of a memory buffer to a specific value byte by byte.
77954 +
77955 + @Param[in] pDst - The address of the destination buffer.
77956 + @Param[in] c - Value to set destination bytes to.
77957 + @Param[in] size - The number of bytes that will be set to val.
77958 +
77959 + @Return pDst (the address of the destination buffer).
77960 +
77961 + @Cautions There is no parameter or boundary checking! It is up to the user
77962 + to supply non null parameter as destination and size
77963 + that actually fits into the destination buffer.
77964 +*//***************************************************************************/
77965 +void * MemSet8(void* pDst, int c, uint32_t size);
77966 +
77967 +/** @} */ /* end of mem_cpy group */
77968 +/** @} */ /* end of etc_id group */
77969 +
77970 +
77971 +#endif /* __MEMCPY_EXT_H */
77972 --- /dev/null
77973 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/etc/mm_ext.h
77974 @@ -0,0 +1,310 @@
77975 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
77976 + * All rights reserved.
77977 + *
77978 + * Redistribution and use in source and binary forms, with or without
77979 + * modification, are permitted provided that the following conditions are met:
77980 + * * Redistributions of source code must retain the above copyright
77981 + * notice, this list of conditions and the following disclaimer.
77982 + * * Redistributions in binary form must reproduce the above copyright
77983 + * notice, this list of conditions and the following disclaimer in the
77984 + * documentation and/or other materials provided with the distribution.
77985 + * * Neither the name of Freescale Semiconductor nor the
77986 + * names of its contributors may be used to endorse or promote products
77987 + * derived from this software without specific prior written permission.
77988 + *
77989 + *
77990 + * ALTERNATIVELY, this software may be distributed under the terms of the
77991 + * GNU General Public License ("GPL") as published by the Free Software
77992 + * Foundation, either version 2 of that License or (at your option) any
77993 + * later version.
77994 + *
77995 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
77996 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
77997 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
77998 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
77999 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
78000 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
78001 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
78002 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
78003 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
78004 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78005 + */
78006 +
78007 +
78008 +/**************************************************************************//**
78009 + @File mm_ext.h
78010 +
78011 + @Description Memory Manager Application Programming Interface
78012 +*//***************************************************************************/
78013 +#ifndef __MM_EXT
78014 +#define __MM_EXT
78015 +
78016 +#include "std_ext.h"
78017 +
78018 +#define MM_MAX_ALIGNMENT 20 /* Alignments from 2 to 128 are available
78019 + where maximum alignment defined as
78020 + MM_MAX_ALIGNMENT power of 2 */
78021 +
78022 +#define MM_MAX_NAME_LEN 32
78023 +
78024 +/**************************************************************************//**
78025 + @Group etc_id Utility Library Application Programming Interface
78026 +
78027 + @Description External routines.
78028 +
78029 + @{
78030 +*//***************************************************************************/
78031 +
78032 +/**************************************************************************//**
78033 + @Group mm_grp Flexible Memory Manager
78034 +
78035 + @Description Flexible Memory Manager module functions,definitions and enums.
78036 + (All of the following functions,definitions and enums can be found in mm_ext.h)
78037 +
78038 + @{
78039 +*//***************************************************************************/
78040 +
78041 +
78042 +/**************************************************************************//**
78043 + @Function MM_Init
78044 +
78045 + @Description Initializes a new MM object.
78046 +
78047 + It initializes a new memory block consisting of base address
78048 + and size of the available memory by calling to MemBlock_Init
78049 + routine. It is also initializes a new free block for each
78050 + by calling FreeBlock_Init routine, which is pointed to
78051 + the almost all memory started from the required alignment
78052 + from the base address and to the end of the memory.
78053 + The handle to the new MM object is returned via "MM"
78054 + argument (passed by reference).
78055 +
78056 + @Param[in] h_MM - Handle to the MM object.
78057 + @Param[in] base - Base address of the MM.
78058 + @Param[in] size - Size of the MM.
78059 +
78060 + @Return E_OK is returned on success. E_NOMEMORY is returned if the new MM object or a new free block can not be initialized.
78061 +*//***************************************************************************/
78062 +t_Error MM_Init(t_Handle *h_MM, uint64_t base, uint64_t size);
78063 +
78064 +/**************************************************************************//**
78065 + @Function MM_Get
78066 +
78067 + @Description Allocates a block of memory according to the given size and the alignment.
78068 +
78069 + The Alignment argument tells from which
78070 + free list allocate a block of memory. 2^alignment indicates
78071 + the alignment that the base address of the allocated block
78072 + should have. So, the only values 1, 2, 4, 8, 16, 32 and 64
78073 + are available for the alignment argument.
78074 + The routine passes through the specific free list of free
78075 + blocks and seeks for a first block that have anough memory
78076 + that is required (best fit).
78077 + After the block is found and data is allocated, it calls
78078 + the internal MM_CutFree routine to update all free lists
78079 + do not include a just allocated block. Of course, each
78080 + free list contains a free blocks with the same alignment.
78081 + It is also creates a busy block that holds
78082 + information about an allocated block.
78083 +
78084 + @Param[in] h_MM - Handle to the MM object.
78085 + @Param[in] size - Size of the MM.
78086 + @Param[in] alignment - Index as a power of two defines a required
78087 + alignment (in bytes); Should be 1, 2, 4, 8, 16, 32 or 64
78088 + @Param[in] name - The name that specifies an allocated block.
78089 +
78090 + @Return base address of an allocated block ILLEGAL_BASE if can't allocate a block
78091 +*//***************************************************************************/
78092 +uint64_t MM_Get(t_Handle h_MM, uint64_t size, uint64_t alignment, char *name);
78093 +
78094 +/**************************************************************************//**
78095 + @Function MM_GetBase
78096 +
78097 + @Description Gets the base address of the required MM objects.
78098 +
78099 + @Param[in] h_MM - Handle to the MM object.
78100 +
78101 + @Return base address of the block.
78102 +*//***************************************************************************/
78103 +uint64_t MM_GetBase(t_Handle h_MM);
78104 +
78105 +/**************************************************************************//**
78106 + @Function MM_GetForce
78107 +
78108 + @Description Force memory allocation.
78109 +
78110 + It means to allocate a block of memory of the given
78111 + size from the given base address.
78112 + The routine checks if the required block can be allocated
78113 + (that is it is free) and then, calls the internal MM_CutFree
78114 + routine to update all free lists do not include that block.
78115 +
78116 + @Param[in] h_MM - Handle to the MM object.
78117 + @Param[in] base - Base address of the MM.
78118 + @Param[in] size - Size of the MM.
78119 + @Param[in] name - Name that specifies an allocated block.
78120 +
78121 + @Return base address of an allocated block, ILLEGAL_BASE if can't allocate a block.
78122 +*//***************************************************************************/
78123 +uint64_t MM_GetForce(t_Handle h_MM, uint64_t base, uint64_t size, char *name);
78124 +
78125 +/**************************************************************************//**
78126 + @Function MM_GetForceMin
78127 +
78128 + @Description Allocates a block of memory according to the given size, the alignment and minimum base address.
78129 +
78130 + The Alignment argument tells from which
78131 + free list allocate a block of memory. 2^alignment indicates
78132 + the alignment that the base address of the allocated block
78133 + should have. So, the only values 1, 2, 4, 8, 16, 32 and 64
78134 + are available for the alignment argument.
78135 + The minimum baser address forces the location of the block
78136 + to be from a given address onward.
78137 + The routine passes through the specific free list of free
78138 + blocks and seeks for the first base address equal or smaller
78139 + than the required minimum address and end address larger than
78140 + than the required base + its size - i.e. that may contain
78141 + the required block.
78142 + After the block is found and data is allocated, it calls
78143 + the internal MM_CutFree routine to update all free lists
78144 + do not include a just allocated block. Of course, each
78145 + free list contains a free blocks with the same alignment.
78146 + It is also creates a busy block that holds
78147 + information about an allocated block.
78148 +
78149 + @Param[in] h_MM - Handle to the MM object.
78150 + @Param[in] size - Size of the MM.
78151 + @Param[in] alignment - Index as a power of two defines a required
78152 + alignment (in bytes); Should be 1, 2, 4, 8, 16, 32 or 64
78153 + @Param[in] min - The minimum base address of the block.
78154 + @Param[in] name - Name that specifies an allocated block.
78155 +
78156 + @Return base address of an allocated block,ILLEGAL_BASE if can't allocate a block.
78157 +*//***************************************************************************/
78158 +uint64_t MM_GetForceMin(t_Handle h_MM,
78159 + uint64_t size,
78160 + uint64_t alignment,
78161 + uint64_t min,
78162 + char *name);
78163 +
78164 +/**************************************************************************//**
78165 + @Function MM_Put
78166 +
78167 + @Description Puts a block of memory of the given base address back to the memory.
78168 +
78169 + It checks if there is a busy block with the
78170 + given base address. If not, it returns 0, that
78171 + means can't free a block. Otherwise, it gets parameters of
78172 + the busy block and after it updates lists of free blocks,
78173 + removes that busy block from the list by calling to MM_CutBusy
78174 + routine.
78175 + After that it calls to MM_AddFree routine to add a new free
78176 + block to the free lists.
78177 +
78178 + @Param[in] h_MM - Handle to the MM object.
78179 + @Param[in] base - Base address of the MM.
78180 +
78181 + @Return The size of bytes released, 0 if failed.
78182 +*//***************************************************************************/
78183 +uint64_t MM_Put(t_Handle h_MM, uint64_t base);
78184 +
78185 +/**************************************************************************//**
78186 + @Function MM_PutForce
78187 +
78188 + @Description Releases a block of memory of the required size from the required base address.
78189 +
78190 + First, it calls to MM_CutBusy routine
78191 + to cut a free block from the busy list. And then, calls to
78192 + MM_AddFree routine to add the free block to the free lists.
78193 +
78194 + @Param[in] h_MM - Handle to the MM object.
78195 + @Param[in] base - Base address of of a block to free.
78196 + @Param[in] size - Size of a block to free.
78197 +
78198 + @Return The number of bytes released, 0 on failure.
78199 +*//***************************************************************************/
78200 +uint64_t MM_PutForce(t_Handle h_MM, uint64_t base, uint64_t size);
78201 +
78202 +/**************************************************************************//**
78203 + @Function MM_Add
78204 +
78205 + @Description Adds a new memory block for memory allocation.
78206 +
78207 + When a new memory block is initialized and added to the
78208 + memory list, it calls to MM_AddFree routine to add the
78209 + new free block to the free lists.
78210 +
78211 + @Param[in] h_MM - Handle to the MM object.
78212 + @Param[in] base - Base address of the memory block.
78213 + @Param[in] size - Size of the memory block.
78214 +
78215 + @Return E_OK on success, otherwise returns an error code.
78216 +*//***************************************************************************/
78217 +t_Error MM_Add(t_Handle h_MM, uint64_t base, uint64_t size);
78218 +
78219 +/**************************************************************************//**
78220 + @Function MM_Dump
78221 +
78222 + @Description Prints results of free and busy lists.
78223 +
78224 + @Param[in] h_MM - Handle to the MM object.
78225 +*//***************************************************************************/
78226 +void MM_Dump(t_Handle h_MM);
78227 +
78228 +/**************************************************************************//**
78229 + @Function MM_Free
78230 +
78231 + @Description Releases memory allocated for MM object.
78232 +
78233 + @Param[in] h_MM - Handle of the MM object.
78234 +*//***************************************************************************/
78235 +void MM_Free(t_Handle h_MM);
78236 +
78237 +/**************************************************************************//**
78238 + @Function MM_GetMemBlock
78239 +
78240 + @Description Returns base address of the memory block specified by the index.
78241 +
78242 + If index is 0, returns base address
78243 + of the first memory block, 1 - returns base address
78244 + of the second memory block, etc.
78245 + Note, those memory blocks are allocated by the
78246 + application before MM_Init or MM_Add and have to
78247 + be released by the application before or after invoking
78248 + the MM_Free routine.
78249 +
78250 + @Param[in] h_MM - Handle to the MM object.
78251 + @Param[in] index - Index of the memory block.
78252 +
78253 + @Return valid base address or ILLEGAL_BASE if no memory block specified by the index.
78254 +*//***************************************************************************/
78255 +uint64_t MM_GetMemBlock(t_Handle h_MM, int index);
78256 +
78257 +/**************************************************************************//**
78258 + @Function MM_InRange
78259 +
78260 + @Description Checks if a specific address is in the memory range of the passed MM object.
78261 +
78262 + @Param[in] h_MM - Handle to the MM object.
78263 + @Param[in] addr - The address to be checked.
78264 +
78265 + @Return TRUE if the address is in the address range of the block, FALSE otherwise.
78266 +*//***************************************************************************/
78267 +bool MM_InRange(t_Handle h_MM, uint64_t addr);
78268 +
78269 +/**************************************************************************//**
78270 + @Function MM_GetFreeMemSize
78271 +
78272 + @Description Returns the size (in bytes) of free memory.
78273 +
78274 + @Param[in] h_MM - Handle to the MM object.
78275 +
78276 + @Return Free memory size in bytes.
78277 +*//***************************************************************************/
78278 +uint64_t MM_GetFreeMemSize(t_Handle h_MM);
78279 +
78280 +
78281 +/** @} */ /* end of mm_grp group */
78282 +/** @} */ /* end of etc_id group */
78283 +
78284 +#endif /* __MM_EXT_H */
78285 --- /dev/null
78286 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/etc/sprint_ext.h
78287 @@ -0,0 +1,118 @@
78288 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
78289 + * All rights reserved.
78290 + *
78291 + * Redistribution and use in source and binary forms, with or without
78292 + * modification, are permitted provided that the following conditions are met:
78293 + * * Redistributions of source code must retain the above copyright
78294 + * notice, this list of conditions and the following disclaimer.
78295 + * * Redistributions in binary form must reproduce the above copyright
78296 + * notice, this list of conditions and the following disclaimer in the
78297 + * documentation and/or other materials provided with the distribution.
78298 + * * Neither the name of Freescale Semiconductor nor the
78299 + * names of its contributors may be used to endorse or promote products
78300 + * derived from this software without specific prior written permission.
78301 + *
78302 + *
78303 + * ALTERNATIVELY, this software may be distributed under the terms of the
78304 + * GNU General Public License ("GPL") as published by the Free Software
78305 + * Foundation, either version 2 of that License or (at your option) any
78306 + * later version.
78307 + *
78308 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
78309 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
78310 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
78311 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
78312 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
78313 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
78314 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
78315 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
78316 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
78317 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78318 + */
78319 +
78320 +
78321 +/**************************************************************************//**
78322 + @File sprint_ext.h
78323 +
78324 + @Description Debug routines (externals).
78325 +
78326 +*//***************************************************************************/
78327 +
78328 +#ifndef __SPRINT_EXT_H
78329 +#define __SPRINT_EXT_H
78330 +
78331 +
78332 +#if defined(NCSW_LINUX) && defined(__KERNEL__)
78333 +#include <linux/kernel.h>
78334 +
78335 +#elif defined(NCSW_VXWORKS)
78336 +#include "private/stdioP.h"
78337 +
78338 +#else
78339 +#include <stdio.h>
78340 +#endif /* defined(NCSW_LINUX) && defined(__KERNEL__) */
78341 +
78342 +#include "std_ext.h"
78343 +
78344 +
78345 +/**************************************************************************//**
78346 + @Group etc_id Utility Library Application Programming Interface
78347 +
78348 + @Description External routines.
78349 +
78350 + @{
78351 +*//***************************************************************************/
78352 +
78353 +/**************************************************************************//**
78354 + @Group sprint_id Sprint
78355 +
78356 + @Description Sprint & Sscan module functions,definitions and enums.
78357 +
78358 + @{
78359 +*//***************************************************************************/
78360 +
78361 +/**************************************************************************//**
78362 + @Function Sprint
78363 +
78364 + @Description Format a string and place it in a buffer.
78365 +
78366 + @Param[in] buff - The buffer to place the result into.
78367 + @Param[in] str - The format string to use.
78368 + @Param[in] ... - Arguments for the format string.
78369 +
78370 + @Return Number of bytes formatted.
78371 +*//***************************************************************************/
78372 +int Sprint(char *buff, const char *str, ...);
78373 +
78374 +/**************************************************************************//**
78375 + @Function Snprint
78376 +
78377 + @Description Format a string and place it in a buffer.
78378 +
78379 + @Param[in] buf - The buffer to place the result into.
78380 + @Param[in] size - The size of the buffer, including the trailing null space.
78381 + @Param[in] fmt - The format string to use.
78382 + @Param[in] ... - Arguments for the format string.
78383 +
78384 + @Return Number of bytes formatted.
78385 +*//***************************************************************************/
78386 +int Snprint(char * buf, uint32_t size, const char *fmt, ...);
78387 +
78388 +/**************************************************************************//**
78389 + @Function Sscan
78390 +
78391 + @Description Unformat a buffer into a list of arguments.
78392 +
78393 + @Param[in] buf - input buffer.
78394 + @Param[in] fmt - formatting of buffer.
78395 + @Param[out] ... - resulting arguments.
78396 +
78397 + @Return Number of bytes unformatted.
78398 +*//***************************************************************************/
78399 +int Sscan(const char * buf, const char * fmt, ...);
78400 +
78401 +/** @} */ /* end of sprint_id group */
78402 +/** @} */ /* end of etc_id group */
78403 +
78404 +
78405 +#endif /* __SPRINT_EXT_H */
78406 --- /dev/null
78407 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/common/arch/ppc_access.h
78408 @@ -0,0 +1,37 @@
78409 +/*
78410 + * Copyright 2008-2012 Freescale Semiconductor Inc.
78411 + *
78412 + * Redistribution and use in source and binary forms, with or without
78413 + * modification, are permitted provided that the following conditions are met:
78414 + * * Redistributions of source code must retain the above copyright
78415 + * notice, this list of conditions and the following disclaimer.
78416 + * * Redistributions in binary form must reproduce the above copyright
78417 + * notice, this list of conditions and the following disclaimer in the
78418 + * documentation and/or other materials provided with the distribution.
78419 + * * Neither the name of Freescale Semiconductor nor the
78420 + * names of its contributors may be used to endorse or promote products
78421 + * derived from this software without specific prior written permission.
78422 + *
78423 + *
78424 + * ALTERNATIVELY, this software may be distributed under the terms of the
78425 + * GNU General Public License ("GPL") as published by the Free Software
78426 + * Foundation, either version 2 of that License or (at your option) any
78427 + * later version.
78428 + *
78429 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
78430 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
78431 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
78432 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
78433 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
78434 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
78435 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
78436 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
78437 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
78438 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78439 + */
78440 +
78441 +#ifndef FL_E500_MACROS_H
78442 +#define FL_E500_MACROS_H
78443 +
78444 +#endif /* FL_E500_MACROS_H */
78445 +
78446 --- /dev/null
78447 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/common/general.h
78448 @@ -0,0 +1,52 @@
78449 +/*
78450 + * Copyright 2008-2012 Freescale Semiconductor Inc.
78451 + *
78452 + * Redistribution and use in source and binary forms, with or without
78453 + * modification, are permitted provided that the following conditions are met:
78454 + * * Redistributions of source code must retain the above copyright
78455 + * notice, this list of conditions and the following disclaimer.
78456 + * * Redistributions in binary form must reproduce the above copyright
78457 + * notice, this list of conditions and the following disclaimer in the
78458 + * documentation and/or other materials provided with the distribution.
78459 + * * Neither the name of Freescale Semiconductor nor the
78460 + * names of its contributors may be used to endorse or promote products
78461 + * derived from this software without specific prior written permission.
78462 + *
78463 + *
78464 + * ALTERNATIVELY, this software may be distributed under the terms of the
78465 + * GNU General Public License ("GPL") as published by the Free Software
78466 + * Foundation, either version 2 of that License or (at your option) any
78467 + * later version.
78468 + *
78469 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
78470 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
78471 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
78472 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
78473 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
78474 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
78475 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
78476 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
78477 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
78478 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78479 + */
78480 +
78481 +#ifndef __GENERAL_H
78482 +#define __GENERAL_H
78483 +
78484 +#include "std_ext.h"
78485 +#if !defined(NCSW_LINUX)
78486 +#include "errno.h"
78487 +#endif
78488 +
78489 +
78490 +extern uint32_t get_mac_addr_crc(uint64_t _addr);
78491 +
78492 +#ifndef CONFIG_FMAN_ARM
78493 +#define iowrite32be(val, addr) WRITE_UINT32(*addr, val)
78494 +#define ioread32be(addr) GET_UINT32(*addr)
78495 +#endif
78496 +
78497 +#define ether_crc(len, addr) get_mac_addr_crc(*(uint64_t *)(addr)>>16)
78498 +
78499 +
78500 +#endif /* __GENERAL_H */
78501 --- /dev/null
78502 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fman_common.h
78503 @@ -0,0 +1,78 @@
78504 +/*
78505 + * Copyright 2008-2013 Freescale Semiconductor Inc.
78506 + *
78507 + * Redistribution and use in source and binary forms, with or without
78508 + * modification, are permitted provided that the following conditions are met:
78509 + * * Redistributions of source code must retain the above copyright
78510 + * notice, this list of conditions and the following disclaimer.
78511 + * * Redistributions in binary form must reproduce the above copyright
78512 + * notice, this list of conditions and the following disclaimer in the
78513 + * documentation and/or other materials provided with the distribution.
78514 + * * Neither the name of Freescale Semiconductor nor the
78515 + * names of its contributors may be used to endorse or promote products
78516 + * derived from this software without specific prior written permission.
78517 + *
78518 + *
78519 + * ALTERNATIVELY, this software may be distributed under the terms of the
78520 + * GNU General Public License ("GPL") as published by the Free Software
78521 + * Foundation, either version 2 of that License or (at your option) any
78522 + * later version.
78523 + *
78524 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
78525 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
78526 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
78527 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
78528 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
78529 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
78530 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
78531 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
78532 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
78533 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78534 + */
78535 +
78536 +
78537 +#ifndef __FMAN_COMMON_H
78538 +#define __FMAN_COMMON_H
78539 +
78540 +/**************************************************************************//**
78541 + @Description NIA Description
78542 +*//***************************************************************************/
78543 +#define NIA_ORDER_RESTOR 0x00800000
78544 +#define NIA_ENG_FM_CTL 0x00000000
78545 +#define NIA_ENG_PRS 0x00440000
78546 +#define NIA_ENG_KG 0x00480000
78547 +#define NIA_ENG_PLCR 0x004C0000
78548 +#define NIA_ENG_BMI 0x00500000
78549 +#define NIA_ENG_QMI_ENQ 0x00540000
78550 +#define NIA_ENG_QMI_DEQ 0x00580000
78551 +#define NIA_ENG_MASK 0x007C0000
78552 +
78553 +#define NIA_FM_CTL_AC_CC 0x00000006
78554 +#define NIA_FM_CTL_AC_HC 0x0000000C
78555 +#define NIA_FM_CTL_AC_IND_MODE_TX 0x00000008
78556 +#define NIA_FM_CTL_AC_IND_MODE_RX 0x0000000A
78557 +#define NIA_FM_CTL_AC_FRAG 0x0000000e
78558 +#define NIA_FM_CTL_AC_PRE_FETCH 0x00000010
78559 +#define NIA_FM_CTL_AC_POST_FETCH_PCD 0x00000012
78560 +#define NIA_FM_CTL_AC_POST_FETCH_PCD_UDP_LEN 0x00000018
78561 +#define NIA_FM_CTL_AC_POST_FETCH_NO_PCD 0x00000012
78562 +#define NIA_FM_CTL_AC_FRAG_CHECK 0x00000014
78563 +#define NIA_FM_CTL_AC_PRE_CC 0x00000020
78564 +
78565 +
78566 +#define NIA_BMI_AC_ENQ_FRAME 0x00000002
78567 +#define NIA_BMI_AC_TX_RELEASE 0x000002C0
78568 +#define NIA_BMI_AC_RELEASE 0x000000C0
78569 +#define NIA_BMI_AC_DISCARD 0x000000C1
78570 +#define NIA_BMI_AC_TX 0x00000274
78571 +#define NIA_BMI_AC_FETCH 0x00000208
78572 +#define NIA_BMI_AC_MASK 0x000003FF
78573 +
78574 +#define NIA_KG_DIRECT 0x00000100
78575 +#define NIA_KG_CC_EN 0x00000200
78576 +#define NIA_PLCR_ABSOLUTE 0x00008000
78577 +
78578 +#define NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA 0x00000202
78579 +#define NIA_BMI_AC_FETCH_ALL_FRAME 0x0000020c
78580 +
78581 +#endif /* __FMAN_COMMON_H */
78582 --- /dev/null
78583 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_enet.h
78584 @@ -0,0 +1,273 @@
78585 +/*
78586 + * Copyright 2008-2012 Freescale Semiconductor Inc.
78587 + *
78588 + * Redistribution and use in source and binary forms, with or without
78589 + * modification, are permitted provided that the following conditions are met:
78590 + * * Redistributions of source code must retain the above copyright
78591 + * notice, this list of conditions and the following disclaimer.
78592 + * * Redistributions in binary form must reproduce the above copyright
78593 + * notice, this list of conditions and the following disclaimer in the
78594 + * documentation and/or other materials provided with the distribution.
78595 + * * Neither the name of Freescale Semiconductor nor the
78596 + * names of its contributors may be used to endorse or promote products
78597 + * derived from this software without specific prior written permission.
78598 + *
78599 + *
78600 + * ALTERNATIVELY, this software may be distributed under the terms of the
78601 + * GNU General Public License ("GPL") as published by the Free Software
78602 + * Foundation, either version 2 of that License or (at your option) any
78603 + * later version.
78604 + *
78605 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
78606 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
78607 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
78608 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
78609 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
78610 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
78611 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
78612 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
78613 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
78614 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78615 + */
78616 +
78617 +#ifndef __FSL_ENET_H
78618 +#define __FSL_ENET_H
78619 +
78620 +/**
78621 + @Description Ethernet MAC-PHY Interface
78622 +*/
78623 +
78624 +enum enet_interface {
78625 + E_ENET_IF_MII = 0x00010000, /**< MII interface */
78626 + E_ENET_IF_RMII = 0x00020000, /**< RMII interface */
78627 + E_ENET_IF_SMII = 0x00030000, /**< SMII interface */
78628 + E_ENET_IF_GMII = 0x00040000, /**< GMII interface */
78629 + E_ENET_IF_RGMII = 0x00050000, /**< RGMII interface */
78630 + E_ENET_IF_TBI = 0x00060000, /**< TBI interface */
78631 + E_ENET_IF_RTBI = 0x00070000, /**< RTBI interface */
78632 + E_ENET_IF_SGMII = 0x00080000, /**< SGMII interface */
78633 + E_ENET_IF_XGMII = 0x00090000, /**< XGMII interface */
78634 + E_ENET_IF_QSGMII = 0x000a0000, /**< QSGMII interface */
78635 + E_ENET_IF_XFI = 0x000b0000 /**< XFI interface */
78636 +};
78637 +
78638 +/**
78639 + @Description Ethernet Speed (nominal data rate)
78640 +*/
78641 +enum enet_speed {
78642 + E_ENET_SPEED_10 = 10, /**< 10 Mbps */
78643 + E_ENET_SPEED_100 = 100, /**< 100 Mbps */
78644 + E_ENET_SPEED_1000 = 1000, /**< 1000 Mbps = 1 Gbps */
78645 + E_ENET_SPEED_2500 = 2500, /**< 2500 Mbps = 2.5 Gbps */
78646 + E_ENET_SPEED_10000 = 10000 /**< 10000 Mbps = 10 Gbps */
78647 +};
78648 +
78649 +enum mac_type {
78650 + E_MAC_DTSEC,
78651 + E_MAC_TGEC,
78652 + E_MAC_MEMAC
78653 +};
78654 +
78655 +/**************************************************************************//**
78656 + @Description Enum for inter-module interrupts registration
78657 +*//***************************************************************************/
78658 +enum fman_event_modules {
78659 + E_FMAN_MOD_PRS, /**< Parser event */
78660 + E_FMAN_MOD_KG, /**< Keygen event */
78661 + E_FMAN_MOD_PLCR, /**< Policer event */
78662 + E_FMAN_MOD_10G_MAC, /**< 10G MAC event */
78663 + E_FMAN_MOD_1G_MAC, /**< 1G MAC event */
78664 + E_FMAN_MOD_TMR, /**< Timer event */
78665 + E_FMAN_MOD_FMAN_CTRL, /**< FMAN Controller Timer event */
78666 + E_FMAN_MOD_MACSEC,
78667 + E_FMAN_MOD_DUMMY_LAST
78668 +};
78669 +
78670 +/**************************************************************************//**
78671 + @Description Enum for interrupts types
78672 +*//***************************************************************************/
78673 +enum fman_intr_type {
78674 + E_FMAN_INTR_TYPE_ERR,
78675 + E_FMAN_INTR_TYPE_NORMAL
78676 +};
78677 +
78678 +/**************************************************************************//**
78679 + @Description enum for defining MAC types
78680 +*//***************************************************************************/
78681 +enum fman_mac_type {
78682 + E_FMAN_MAC_10G = 0, /**< 10G MAC */
78683 + E_FMAN_MAC_1G /**< 1G MAC */
78684 +};
78685 +
78686 +enum fman_mac_exceptions {
78687 + E_FMAN_MAC_EX_10G_MDIO_SCAN_EVENTMDIO = 0,
78688 + /**< 10GEC MDIO scan event interrupt */
78689 + E_FMAN_MAC_EX_10G_MDIO_CMD_CMPL,
78690 + /**< 10GEC MDIO command completion interrupt */
78691 + E_FMAN_MAC_EX_10G_REM_FAULT,
78692 + /**< 10GEC, mEMAC Remote fault interrupt */
78693 + E_FMAN_MAC_EX_10G_LOC_FAULT,
78694 + /**< 10GEC, mEMAC Local fault interrupt */
78695 + E_FMAN_MAC_EX_10G_1TX_ECC_ER,
78696 + /**< 10GEC, mEMAC Transmit frame ECC error interrupt */
78697 + E_FMAN_MAC_EX_10G_TX_FIFO_UNFL,
78698 + /**< 10GEC, mEMAC Transmit FIFO underflow interrupt */
78699 + E_FMAN_MAC_EX_10G_TX_FIFO_OVFL,
78700 + /**< 10GEC, mEMAC Transmit FIFO overflow interrupt */
78701 + E_FMAN_MAC_EX_10G_TX_ER,
78702 + /**< 10GEC Transmit frame error interrupt */
78703 + E_FMAN_MAC_EX_10G_RX_FIFO_OVFL,
78704 + /**< 10GEC, mEMAC Receive FIFO overflow interrupt */
78705 + E_FMAN_MAC_EX_10G_RX_ECC_ER,
78706 + /**< 10GEC, mEMAC Receive frame ECC error interrupt */
78707 + E_FMAN_MAC_EX_10G_RX_JAB_FRM,
78708 + /**< 10GEC Receive jabber frame interrupt */
78709 + E_FMAN_MAC_EX_10G_RX_OVRSZ_FRM,
78710 + /**< 10GEC Receive oversized frame interrupt */
78711 + E_FMAN_MAC_EX_10G_RX_RUNT_FRM,
78712 + /**< 10GEC Receive runt frame interrupt */
78713 + E_FMAN_MAC_EX_10G_RX_FRAG_FRM,
78714 + /**< 10GEC Receive fragment frame interrupt */
78715 + E_FMAN_MAC_EX_10G_RX_LEN_ER,
78716 + /**< 10GEC Receive payload length error interrupt */
78717 + E_FMAN_MAC_EX_10G_RX_CRC_ER,
78718 + /**< 10GEC Receive CRC error interrupt */
78719 + E_FMAN_MAC_EX_10G_RX_ALIGN_ER,
78720 + /**< 10GEC Receive alignment error interrupt */
78721 + E_FMAN_MAC_EX_1G_BAB_RX,
78722 + /**< dTSEC Babbling receive error */
78723 + E_FMAN_MAC_EX_1G_RX_CTL,
78724 + /**< dTSEC Receive control (pause frame) interrupt */
78725 + E_FMAN_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET,
78726 + /**< dTSEC Graceful transmit stop complete */
78727 + E_FMAN_MAC_EX_1G_BAB_TX,
78728 + /**< dTSEC Babbling transmit error */
78729 + E_FMAN_MAC_EX_1G_TX_CTL,
78730 + /**< dTSEC Transmit control (pause frame) interrupt */
78731 + E_FMAN_MAC_EX_1G_TX_ERR,
78732 + /**< dTSEC Transmit error */
78733 + E_FMAN_MAC_EX_1G_LATE_COL,
78734 + /**< dTSEC Late collision */
78735 + E_FMAN_MAC_EX_1G_COL_RET_LMT,
78736 + /**< dTSEC Collision retry limit */
78737 + E_FMAN_MAC_EX_1G_TX_FIFO_UNDRN,
78738 + /**< dTSEC Transmit FIFO underrun */
78739 + E_FMAN_MAC_EX_1G_MAG_PCKT,
78740 + /**< dTSEC Magic Packet detection */
78741 + E_FMAN_MAC_EX_1G_MII_MNG_RD_COMPLET,
78742 + /**< dTSEC MII management read completion */
78743 + E_FMAN_MAC_EX_1G_MII_MNG_WR_COMPLET,
78744 + /**< dTSEC MII management write completion */
78745 + E_FMAN_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET,
78746 + /**< dTSEC Graceful receive stop complete */
78747 + E_FMAN_MAC_EX_1G_TX_DATA_ERR,
78748 + /**< dTSEC Internal data error on transmit */
78749 + E_FMAN_MAC_EX_1G_RX_DATA_ERR,
78750 + /**< dTSEC Internal data error on receive */
78751 + E_FMAN_MAC_EX_1G_1588_TS_RX_ERR,
78752 + /**< dTSEC Time-Stamp Receive Error */
78753 + E_FMAN_MAC_EX_1G_RX_MIB_CNT_OVFL,
78754 + /**< dTSEC MIB counter overflow */
78755 + E_FMAN_MAC_EX_TS_FIFO_ECC_ERR,
78756 + /**< mEMAC Time-stamp FIFO ECC error interrupt;
78757 + not supported on T4240/B4860 rev1 chips */
78758 +};
78759 +
78760 +#define ENET_IF_SGMII_BASEX 0x80000000
78761 + /**< SGMII/QSGII interface with 1000BaseX auto-negotiation between MAC
78762 + and phy or backplane;
78763 + Note: 1000BaseX auto-negotiation relates only to interface between MAC
78764 + and phy/backplane, SGMII phy can still synchronize with far-end phy at
78765 + 10Mbps, 100Mbps or 1000Mbps */
78766 +
78767 +enum enet_mode {
78768 + E_ENET_MODE_INVALID = 0,
78769 + /**< Invalid Ethernet mode */
78770 + E_ENET_MODE_MII_10 = (E_ENET_IF_MII | E_ENET_SPEED_10),
78771 + /**< 10 Mbps MII */
78772 + E_ENET_MODE_MII_100 = (E_ENET_IF_MII | E_ENET_SPEED_100),
78773 + /**< 100 Mbps MII */
78774 + E_ENET_MODE_RMII_10 = (E_ENET_IF_RMII | E_ENET_SPEED_10),
78775 + /**< 10 Mbps RMII */
78776 + E_ENET_MODE_RMII_100 = (E_ENET_IF_RMII | E_ENET_SPEED_100),
78777 + /**< 100 Mbps RMII */
78778 + E_ENET_MODE_SMII_10 = (E_ENET_IF_SMII | E_ENET_SPEED_10),
78779 + /**< 10 Mbps SMII */
78780 + E_ENET_MODE_SMII_100 = (E_ENET_IF_SMII | E_ENET_SPEED_100),
78781 + /**< 100 Mbps SMII */
78782 + E_ENET_MODE_GMII_1000 = (E_ENET_IF_GMII | E_ENET_SPEED_1000),
78783 + /**< 1000 Mbps GMII */
78784 + E_ENET_MODE_RGMII_10 = (E_ENET_IF_RGMII | E_ENET_SPEED_10),
78785 + /**< 10 Mbps RGMII */
78786 + E_ENET_MODE_RGMII_100 = (E_ENET_IF_RGMII | E_ENET_SPEED_100),
78787 + /**< 100 Mbps RGMII */
78788 + E_ENET_MODE_RGMII_1000 = (E_ENET_IF_RGMII | E_ENET_SPEED_1000),
78789 + /**< 1000 Mbps RGMII */
78790 + E_ENET_MODE_TBI_1000 = (E_ENET_IF_TBI | E_ENET_SPEED_1000),
78791 + /**< 1000 Mbps TBI */
78792 + E_ENET_MODE_RTBI_1000 = (E_ENET_IF_RTBI | E_ENET_SPEED_1000),
78793 + /**< 1000 Mbps RTBI */
78794 + E_ENET_MODE_SGMII_10 = (E_ENET_IF_SGMII | E_ENET_SPEED_10),
78795 + /**< 10 Mbps SGMII with auto-negotiation between MAC and
78796 + SGMII phy according to Cisco SGMII specification */
78797 + E_ENET_MODE_SGMII_100 = (E_ENET_IF_SGMII | E_ENET_SPEED_100),
78798 + /**< 100 Mbps SGMII with auto-negotiation between MAC and
78799 + SGMII phy according to Cisco SGMII specification */
78800 + E_ENET_MODE_SGMII_1000 = (E_ENET_IF_SGMII | E_ENET_SPEED_1000),
78801 + /**< 1000 Mbps SGMII with auto-negotiation between MAC and
78802 + SGMII phy according to Cisco SGMII specification */
78803 + E_ENET_MODE_SGMII_BASEX_10 = (ENET_IF_SGMII_BASEX | E_ENET_IF_SGMII
78804 + | E_ENET_SPEED_10),
78805 + /**< 10 Mbps SGMII with 1000BaseX auto-negotiation between
78806 + MAC and SGMII phy or backplane */
78807 + E_ENET_MODE_SGMII_BASEX_100 = (ENET_IF_SGMII_BASEX | E_ENET_IF_SGMII
78808 + | E_ENET_SPEED_100),
78809 + /**< 100 Mbps SGMII with 1000BaseX auto-negotiation between
78810 + MAC and SGMII phy or backplane */
78811 + E_ENET_MODE_SGMII_BASEX_1000 = (ENET_IF_SGMII_BASEX | E_ENET_IF_SGMII
78812 + | E_ENET_SPEED_1000),
78813 + /**< 1000 Mbps SGMII with 1000BaseX auto-negotiation between
78814 + MAC and SGMII phy or backplane */
78815 + E_ENET_MODE_QSGMII_1000 = (E_ENET_IF_QSGMII | E_ENET_SPEED_1000),
78816 + /**< 1000 Mbps QSGMII with auto-negotiation between MAC and
78817 + QSGMII phy according to Cisco QSGMII specification */
78818 + E_ENET_MODE_QSGMII_BASEX_1000 = (ENET_IF_SGMII_BASEX | E_ENET_IF_QSGMII
78819 + | E_ENET_SPEED_1000),
78820 + /**< 1000 Mbps QSGMII with 1000BaseX auto-negotiation between
78821 + MAC and QSGMII phy or backplane */
78822 + E_ENET_MODE_XGMII_10000 = (E_ENET_IF_XGMII | E_ENET_SPEED_10000),
78823 + /**< 10000 Mbps XGMII */
78824 + E_ENET_MODE_XFI_10000 = (E_ENET_IF_XFI | E_ENET_SPEED_10000)
78825 + /**< 10000 Mbps XFI */
78826 +};
78827 +
78828 +enum fmam_mac_statistics_level {
78829 + E_FMAN_MAC_NONE_STATISTICS, /**< No statistics */
78830 + E_FMAN_MAC_PARTIAL_STATISTICS, /**< Only error counters are available;
78831 + Optimized for performance */
78832 + E_FMAN_MAC_FULL_STATISTICS /**< All counters available; Not
78833 + optimized for performance */
78834 +};
78835 +
78836 +#define _MAKE_ENET_MODE(_interface, _speed) (enum enet_mode)((_interface) \
78837 + | (_speed))
78838 +
78839 +#define _ENET_INTERFACE_FROM_MODE(mode) (enum enet_interface) \
78840 + ((mode) & 0x0FFF0000)
78841 +#define _ENET_SPEED_FROM_MODE(mode) (enum enet_speed)((mode) & 0x0000FFFF)
78842 +#define _ENET_ADDR_TO_UINT64(_enet_addr) \
78843 + (uint64_t)(((uint64_t)(_enet_addr)[0] << 40) | \
78844 + ((uint64_t)(_enet_addr)[1] << 32) | \
78845 + ((uint64_t)(_enet_addr)[2] << 24) | \
78846 + ((uint64_t)(_enet_addr)[3] << 16) | \
78847 + ((uint64_t)(_enet_addr)[4] << 8) | \
78848 + ((uint64_t)(_enet_addr)[5]))
78849 +
78850 +#define _MAKE_ENET_ADDR_FROM_UINT64(_addr64, _enet_addr) \
78851 + do { \
78852 + int i; \
78853 + for (i = 0; i < ENET_NUM_OCTETS_PER_ADDRESS; i++) \
78854 + (_enet_addr)[i] = (uint8_t)((_addr64) >> ((5-i)*8));\
78855 + } while (0)
78856 +
78857 +#endif /* __FSL_ENET_H */
78858 --- /dev/null
78859 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman.h
78860 @@ -0,0 +1,825 @@
78861 +/*
78862 + * Copyright 2013 Freescale Semiconductor Inc.
78863 + *
78864 + * Redistribution and use in source and binary forms, with or without
78865 + * modification, are permitted provided that the following conditions are met:
78866 + * * Redistributions of source code must retain the above copyright
78867 + * notice, this list of conditions and the following disclaimer.
78868 + * * Redistributions in binary form must reproduce the above copyright
78869 + * notice, this list of conditions and the following disclaimer in the
78870 + * documentation and/or other materials provided with the distribution.
78871 + * * Neither the name of Freescale Semiconductor nor the
78872 + * names of its contributors may be used to endorse or promote products
78873 + * derived from this software without specific prior written permission.
78874 + *
78875 + *
78876 + * ALTERNATIVELY, this software may be distributed under the terms of the
78877 + * GNU General Public License ("GPL") as published by the Free Software
78878 + * Foundation, either version 2 of that License or (at your option) any
78879 + * later version.
78880 + *
78881 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
78882 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
78883 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
78884 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
78885 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
78886 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
78887 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
78888 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
78889 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
78890 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78891 + */
78892 +
78893 +#ifndef __FSL_FMAN_H
78894 +#define __FSL_FMAN_H
78895 +
78896 +#include "common/general.h"
78897 +
78898 +struct fman_ext_pool_params {
78899 + uint8_t id; /**< External buffer pool id */
78900 + uint16_t size; /**< External buffer pool buffer size */
78901 +};
78902 +
78903 +struct fman_ext_pools {
78904 + uint8_t num_pools_used; /**< Number of pools use by this port */
78905 + struct fman_ext_pool_params *ext_buf_pool;
78906 + /**< Parameters for each port */
78907 +};
78908 +
78909 +struct fman_backup_bm_pools {
78910 + uint8_t num_backup_pools; /**< Number of BM backup pools -
78911 + must be smaller than the total number
78912 + of pools defined for the specified
78913 + port.*/
78914 + uint8_t *pool_ids; /**< numOfBackupPools pool id's,
78915 + specifying which pools should be used
78916 + only as backup. Pool id's specified
78917 + here must be a subset of the pools
78918 + used by the specified port.*/
78919 +};
78920 +
78921 +/**************************************************************************//**
78922 + @Description A structure for defining BM pool depletion criteria
78923 +*//***************************************************************************/
78924 +struct fman_buf_pool_depletion {
78925 + bool buf_pool_depletion_enabled;
78926 + bool pools_grp_mode_enable; /**< select mode in which pause frames
78927 + will be sent after a number of pools
78928 + (all together!) are depleted */
78929 + uint8_t num_pools; /**< the number of depleted pools that
78930 + will invoke pause frames transmission.
78931 + */
78932 + bool *pools_to_consider; /**< For each pool, TRUE if it should be
78933 + considered for depletion (Note - this
78934 + pool must be used by this port!). */
78935 + bool single_pool_mode_enable; /**< select mode in which pause frames
78936 + will be sent after a single-pool
78937 + is depleted; */
78938 + bool *pools_to_consider_for_single_mode;
78939 + /**< For each pool, TRUE if it should be
78940 + considered for depletion (Note - this
78941 + pool must be used by this port!) */
78942 + bool has_pfc_priorities;
78943 + bool *pfc_priorities_en; /**< This field is used by the MAC as
78944 + the Priority Enable Vector in the PFC
78945 + frame which is transmitted */
78946 +};
78947 +
78948 +/**************************************************************************//**
78949 + @Description Enum for defining port DMA swap mode
78950 +*//***************************************************************************/
78951 +enum fman_dma_swap_option {
78952 + FMAN_DMA_NO_SWP, /**< No swap, transfer data as is.*/
78953 + FMAN_DMA_SWP_PPC_LE, /**< The transferred data should be swapped
78954 + in PowerPc Little Endian mode. */
78955 + FMAN_DMA_SWP_BE /**< The transferred data should be swapped
78956 + in Big Endian mode */
78957 +};
78958 +
78959 +/**************************************************************************//**
78960 + @Description Enum for defining port DMA cache attributes
78961 +*//***************************************************************************/
78962 +enum fman_dma_cache_option {
78963 + FMAN_DMA_NO_STASH = 0, /**< Cacheable, no Allocate (No Stashing) */
78964 + FMAN_DMA_STASH = 1 /**< Cacheable and Allocate (Stashing on) */
78965 +};
78966 +
78967 +typedef struct t_FmPrsResult fm_prs_result_t;
78968 +typedef enum e_EnetMode enet_mode_t;
78969 +typedef t_Handle handle_t;
78970 +
78971 +struct fman_revision_info {
78972 + uint8_t majorRev; /**< Major revision */
78973 + uint8_t minorRev; /**< Minor revision */
78974 +};
78975 +
78976 +/* sizes */
78977 +#define CAPWAP_FRAG_EXTRA_SPACE 32
78978 +#define OFFSET_UNITS 16
78979 +#define MAX_INT_OFFSET 240
78980 +#define MAX_IC_SIZE 256
78981 +#define MAX_EXT_OFFSET 496
78982 +#define MAX_EXT_BUFFER_OFFSET 511
78983 +
78984 +/**************************************************************************
78985 + @Description Memory Mapped Registers
78986 +***************************************************************************/
78987 +#define FMAN_LIODN_TBL 64 /* size of LIODN table */
78988 +
78989 +struct fman_fpm_regs {
78990 + uint32_t fmfp_tnc; /**< FPM TNUM Control 0x00 */
78991 + uint32_t fmfp_prc; /**< FPM Port_ID FmCtl Association 0x04 */
78992 + uint32_t fmfp_brkc; /**< FPM Breakpoint Control 0x08 */
78993 + uint32_t fmfp_mxd; /**< FPM Flush Control 0x0c */
78994 + uint32_t fmfp_dist1; /**< FPM Dispatch Thresholds1 0x10 */
78995 + uint32_t fmfp_dist2; /**< FPM Dispatch Thresholds2 0x14 */
78996 + uint32_t fm_epi; /**< FM Error Pending Interrupts 0x18 */
78997 + uint32_t fm_rie; /**< FM Error Interrupt Enable 0x1c */
78998 + uint32_t fmfp_fcev[4]; /**< FPM FMan-Controller Event 1-4 0x20-0x2f */
78999 + uint32_t res0030[4]; /**< res 0x30 - 0x3f */
79000 + uint32_t fmfp_cee[4]; /**< PM FMan-Controller Event 1-4 0x40-0x4f */
79001 + uint32_t res0050[4]; /**< res 0x50-0x5f */
79002 + uint32_t fmfp_tsc1; /**< FPM TimeStamp Control1 0x60 */
79003 + uint32_t fmfp_tsc2; /**< FPM TimeStamp Control2 0x64 */
79004 + uint32_t fmfp_tsp; /**< FPM Time Stamp 0x68 */
79005 + uint32_t fmfp_tsf; /**< FPM Time Stamp Fraction 0x6c */
79006 + uint32_t fm_rcr; /**< FM Rams Control 0x70 */
79007 + uint32_t fmfp_extc; /**< FPM External Requests Control 0x74 */
79008 + uint32_t fmfp_ext1; /**< FPM External Requests Config1 0x78 */
79009 + uint32_t fmfp_ext2; /**< FPM External Requests Config2 0x7c */
79010 + uint32_t fmfp_drd[16]; /**< FPM Data_Ram Data 0-15 0x80 - 0xbf */
79011 + uint32_t fmfp_dra; /**< FPM Data Ram Access 0xc0 */
79012 + uint32_t fm_ip_rev_1; /**< FM IP Block Revision 1 0xc4 */
79013 + uint32_t fm_ip_rev_2; /**< FM IP Block Revision 2 0xc8 */
79014 + uint32_t fm_rstc; /**< FM Reset Command 0xcc */
79015 + uint32_t fm_cld; /**< FM Classifier Debug 0xd0 */
79016 + uint32_t fm_npi; /**< FM Normal Pending Interrupts 0xd4 */
79017 + uint32_t fmfp_exte; /**< FPM External Requests Enable 0xd8 */
79018 + uint32_t fmfp_ee; /**< FPM Event & Mask 0xdc */
79019 + uint32_t fmfp_cev[4]; /**< FPM CPU Event 1-4 0xe0-0xef */
79020 + uint32_t res00f0[4]; /**< res 0xf0-0xff */
79021 + uint32_t fmfp_ps[64]; /**< FPM Port Status 0x100-0x1ff */
79022 + uint32_t fmfp_clfabc; /**< FPM CLFABC 0x200 */
79023 + uint32_t fmfp_clfcc; /**< FPM CLFCC 0x204 */
79024 + uint32_t fmfp_clfaval; /**< FPM CLFAVAL 0x208 */
79025 + uint32_t fmfp_clfbval; /**< FPM CLFBVAL 0x20c */
79026 + uint32_t fmfp_clfcval; /**< FPM CLFCVAL 0x210 */
79027 + uint32_t fmfp_clfamsk; /**< FPM CLFAMSK 0x214 */
79028 + uint32_t fmfp_clfbmsk; /**< FPM CLFBMSK 0x218 */
79029 + uint32_t fmfp_clfcmsk; /**< FPM CLFCMSK 0x21c */
79030 + uint32_t fmfp_clfamc; /**< FPM CLFAMC 0x220 */
79031 + uint32_t fmfp_clfbmc; /**< FPM CLFBMC 0x224 */
79032 + uint32_t fmfp_clfcmc; /**< FPM CLFCMC 0x228 */
79033 + uint32_t fmfp_decceh; /**< FPM DECCEH 0x22c */
79034 + uint32_t res0230[116]; /**< res 0x230 - 0x3ff */
79035 + uint32_t fmfp_ts[128]; /**< 0x400: FPM Task Status 0x400 - 0x5ff */
79036 + uint32_t res0600[0x400 - 384];
79037 +};
79038 +
79039 +struct fman_bmi_regs {
79040 + uint32_t fmbm_init; /**< BMI Initialization 0x00 */
79041 + uint32_t fmbm_cfg1; /**< BMI Configuration 1 0x04 */
79042 + uint32_t fmbm_cfg2; /**< BMI Configuration 2 0x08 */
79043 + uint32_t res000c[5]; /**< 0x0c - 0x1f */
79044 + uint32_t fmbm_ievr; /**< Interrupt Event Register 0x20 */
79045 + uint32_t fmbm_ier; /**< Interrupt Enable Register 0x24 */
79046 + uint32_t fmbm_ifr; /**< Interrupt Force Register 0x28 */
79047 + uint32_t res002c[5]; /**< 0x2c - 0x3f */
79048 + uint32_t fmbm_arb[8]; /**< BMI Arbitration 0x40 - 0x5f */
79049 + uint32_t res0060[12]; /**<0x60 - 0x8f */
79050 + uint32_t fmbm_dtc[3]; /**< Debug Trap Counter 0x90 - 0x9b */
79051 + uint32_t res009c; /**< 0x9c */
79052 + uint32_t fmbm_dcv[3][4]; /**< Debug Compare val 0xa0-0xcf */
79053 + uint32_t fmbm_dcm[3][4]; /**< Debug Compare Mask 0xd0-0xff */
79054 + uint32_t fmbm_gde; /**< BMI Global Debug Enable 0x100 */
79055 + uint32_t fmbm_pp[63]; /**< BMI Port Parameters 0x104 - 0x1ff */
79056 + uint32_t res0200; /**< 0x200 */
79057 + uint32_t fmbm_pfs[63]; /**< BMI Port FIFO Size 0x204 - 0x2ff */
79058 + uint32_t res0300; /**< 0x300 */
79059 + uint32_t fmbm_spliodn[63]; /**< Port Partition ID 0x304 - 0x3ff */
79060 +};
79061 +
79062 +struct fman_qmi_regs {
79063 + uint32_t fmqm_gc; /**< General Configuration Register 0x00 */
79064 + uint32_t res0004; /**< 0x04 */
79065 + uint32_t fmqm_eie; /**< Error Interrupt Event Register 0x08 */
79066 + uint32_t fmqm_eien; /**< Error Interrupt Enable Register 0x0c */
79067 + uint32_t fmqm_eif; /**< Error Interrupt Force Register 0x10 */
79068 + uint32_t fmqm_ie; /**< Interrupt Event Register 0x14 */
79069 + uint32_t fmqm_ien; /**< Interrupt Enable Register 0x18 */
79070 + uint32_t fmqm_if; /**< Interrupt Force Register 0x1c */
79071 + uint32_t fmqm_gs; /**< Global Status Register 0x20 */
79072 + uint32_t fmqm_ts; /**< Task Status Register 0x24 */
79073 + uint32_t fmqm_etfc; /**< Enqueue Total Frame Counter 0x28 */
79074 + uint32_t fmqm_dtfc; /**< Dequeue Total Frame Counter 0x2c */
79075 + uint32_t fmqm_dc0; /**< Dequeue Counter 0 0x30 */
79076 + uint32_t fmqm_dc1; /**< Dequeue Counter 1 0x34 */
79077 + uint32_t fmqm_dc2; /**< Dequeue Counter 2 0x38 */
79078 + uint32_t fmqm_dc3; /**< Dequeue Counter 3 0x3c */
79079 + uint32_t fmqm_dfdc; /**< Dequeue FQID from Default Counter 0x40 */
79080 + uint32_t fmqm_dfcc; /**< Dequeue FQID from Context Counter 0x44 */
79081 + uint32_t fmqm_dffc; /**< Dequeue FQID from FD Counter 0x48 */
79082 + uint32_t fmqm_dcc; /**< Dequeue Confirm Counter 0x4c */
79083 + uint32_t res0050[7]; /**< 0x50 - 0x6b */
79084 + uint32_t fmqm_tapc; /**< Tnum Aging Period Control 0x6c */
79085 + uint32_t fmqm_dmcvc; /**< Dequeue MAC Command Valid Counter 0x70 */
79086 + uint32_t fmqm_difdcc; /**< Dequeue Invalid FD Command Counter 0x74 */
79087 + uint32_t fmqm_da1v; /**< Dequeue A1 Valid Counter 0x78 */
79088 + uint32_t res007c; /**< 0x7c */
79089 + uint32_t fmqm_dtc; /**< 0x80 Debug Trap Counter 0x80 */
79090 + uint32_t fmqm_efddd; /**< 0x84 Enqueue Frame desc Dynamic dbg 0x84 */
79091 + uint32_t res0088[2]; /**< 0x88 - 0x8f */
79092 + struct {
79093 + uint32_t fmqm_dtcfg1; /**< 0x90 dbg trap cfg 1 Register 0x00 */
79094 + uint32_t fmqm_dtval1; /**< Debug Trap Value 1 Register 0x04 */
79095 + uint32_t fmqm_dtm1; /**< Debug Trap Mask 1 Register 0x08 */
79096 + uint32_t fmqm_dtc1; /**< Debug Trap Counter 1 Register 0x0c */
79097 + uint32_t fmqm_dtcfg2; /**< dbg Trap cfg 2 Register 0x10 */
79098 + uint32_t fmqm_dtval2; /**< Debug Trap Value 2 Register 0x14 */
79099 + uint32_t fmqm_dtm2; /**< Debug Trap Mask 2 Register 0x18 */
79100 + uint32_t res001c; /**< 0x1c */
79101 + } dbg_traps[3]; /**< 0x90 - 0xef */
79102 + uint8_t res00f0[0x400 - 0xf0]; /**< 0xf0 - 0x3ff */
79103 +};
79104 +
79105 +struct fman_dma_regs {
79106 + uint32_t fmdmsr; /**< FM DMA status register 0x00 */
79107 + uint32_t fmdmmr; /**< FM DMA mode register 0x04 */
79108 + uint32_t fmdmtr; /**< FM DMA bus threshold register 0x08 */
79109 + uint32_t fmdmhy; /**< FM DMA bus hysteresis register 0x0c */
79110 + uint32_t fmdmsetr; /**< FM DMA SOS emergency Threshold Register 0x10 */
79111 + uint32_t fmdmtah; /**< FM DMA transfer bus address high reg 0x14 */
79112 + uint32_t fmdmtal; /**< FM DMA transfer bus address low reg 0x18 */
79113 + uint32_t fmdmtcid; /**< FM DMA transfer bus communication ID reg 0x1c */
79114 + uint32_t fmdmra; /**< FM DMA bus internal ram address register 0x20 */
79115 + uint32_t fmdmrd; /**< FM DMA bus internal ram data register 0x24 */
79116 + uint32_t fmdmwcr; /**< FM DMA CAM watchdog counter value 0x28 */
79117 + uint32_t fmdmebcr; /**< FM DMA CAM base in MURAM register 0x2c */
79118 + uint32_t fmdmccqdr; /**< FM DMA CAM and CMD Queue Debug reg 0x30 */
79119 + uint32_t fmdmccqvr1; /**< FM DMA CAM and CMD Queue Value reg #1 0x34 */
79120 + uint32_t fmdmccqvr2; /**< FM DMA CAM and CMD Queue Value reg #2 0x38 */
79121 + uint32_t fmdmcqvr3; /**< FM DMA CMD Queue Value register #3 0x3c */
79122 + uint32_t fmdmcqvr4; /**< FM DMA CMD Queue Value register #4 0x40 */
79123 + uint32_t fmdmcqvr5; /**< FM DMA CMD Queue Value register #5 0x44 */
79124 + uint32_t fmdmsefrc; /**< FM DMA Semaphore Entry Full Reject Cntr 0x48 */
79125 + uint32_t fmdmsqfrc; /**< FM DMA Semaphore Queue Full Reject Cntr 0x4c */
79126 + uint32_t fmdmssrc; /**< FM DMA Semaphore SYNC Reject Counter 0x50 */
79127 + uint32_t fmdmdcr; /**< FM DMA Debug Counter 0x54 */
79128 + uint32_t fmdmemsr; /**< FM DMA Emergency Smoother Register 0x58 */
79129 + uint32_t res005c; /**< 0x5c */
79130 + uint32_t fmdmplr[FMAN_LIODN_TBL / 2]; /**< DMA LIODN regs 0x60-0xdf */
79131 + uint32_t res00e0[0x400 - 56];
79132 +};
79133 +
79134 +struct fman_rg {
79135 + struct fman_fpm_regs *fpm_rg;
79136 + struct fman_dma_regs *dma_rg;
79137 + struct fman_bmi_regs *bmi_rg;
79138 + struct fman_qmi_regs *qmi_rg;
79139 +};
79140 +
79141 +enum fman_dma_cache_override {
79142 + E_FMAN_DMA_NO_CACHE_OR = 0, /**< No override of the Cache field */
79143 + E_FMAN_DMA_NO_STASH_DATA, /**< No data stashing in system level cache */
79144 + E_FMAN_DMA_MAY_STASH_DATA, /**< Stashing allowed in sys level cache */
79145 + E_FMAN_DMA_STASH_DATA /**< Stashing performed in system level cache */
79146 +};
79147 +
79148 +enum fman_dma_aid_mode {
79149 + E_FMAN_DMA_AID_OUT_PORT_ID = 0, /**< 4 LSB of PORT_ID */
79150 + E_FMAN_DMA_AID_OUT_TNUM /**< 4 LSB of TNUM */
79151 +};
79152 +
79153 +enum fman_dma_dbg_cnt_mode {
79154 + E_FMAN_DMA_DBG_NO_CNT = 0, /**< No counting */
79155 + E_FMAN_DMA_DBG_CNT_DONE, /**< Count DONE commands */
79156 + E_FMAN_DMA_DBG_CNT_COMM_Q_EM, /**< command Q emergency signal */
79157 + E_FMAN_DMA_DBG_CNT_INT_READ_EM, /**< Read buf emergency signal */
79158 + E_FMAN_DMA_DBG_CNT_INT_WRITE_EM, /**< Write buf emergency signal */
79159 + E_FMAN_DMA_DBG_CNT_FPM_WAIT, /**< FPM WAIT signal */
79160 + E_FMAN_DMA_DBG_CNT_SIGLE_BIT_ECC, /**< Single bit ECC errors */
79161 + E_FMAN_DMA_DBG_CNT_RAW_WAR_PROT /**< RAW & WAR protection counter */
79162 +};
79163 +
79164 +enum fman_dma_emergency_level {
79165 + E_FMAN_DMA_EM_EBS = 0, /**< EBS emergency */
79166 + E_FMAN_DMA_EM_SOS /**< SOS emergency */
79167 +};
79168 +
79169 +enum fman_catastrophic_err {
79170 + E_FMAN_CATAST_ERR_STALL_PORT = 0, /**< Port_ID stalled reset required */
79171 + E_FMAN_CATAST_ERR_STALL_TASK /**< Only erroneous task is stalled */
79172 +};
79173 +
79174 +enum fman_dma_err {
79175 + E_FMAN_DMA_ERR_CATASTROPHIC = 0, /**< Catastrophic DMA error */
79176 + E_FMAN_DMA_ERR_REPORT /**< Reported DMA error */
79177 +};
79178 +
79179 +struct fman_cfg {
79180 + uint16_t liodn_bs_pr_port[FMAN_LIODN_TBL];/* base per port */
79181 + bool en_counters;
79182 + uint8_t disp_limit_tsh;
79183 + uint8_t prs_disp_tsh;
79184 + uint8_t plcr_disp_tsh;
79185 + uint8_t kg_disp_tsh;
79186 + uint8_t bmi_disp_tsh;
79187 + uint8_t qmi_enq_disp_tsh;
79188 + uint8_t qmi_deq_disp_tsh;
79189 + uint8_t fm_ctl1_disp_tsh;
79190 + uint8_t fm_ctl2_disp_tsh;
79191 + enum fman_dma_cache_override dma_cache_override;
79192 + enum fman_dma_aid_mode dma_aid_mode;
79193 + bool dma_aid_override;
79194 + uint8_t dma_axi_dbg_num_of_beats;
79195 + uint8_t dma_cam_num_of_entries;
79196 + uint32_t dma_watchdog;
79197 + uint8_t dma_comm_qtsh_asrt_emer;
79198 + uint8_t dma_write_buf_tsh_asrt_emer;
79199 + uint8_t dma_read_buf_tsh_asrt_emer;
79200 + uint8_t dma_comm_qtsh_clr_emer;
79201 + uint8_t dma_write_buf_tsh_clr_emer;
79202 + uint8_t dma_read_buf_tsh_clr_emer;
79203 + uint32_t dma_sos_emergency;
79204 + enum fman_dma_dbg_cnt_mode dma_dbg_cnt_mode;
79205 + bool dma_stop_on_bus_error;
79206 + bool dma_en_emergency;
79207 + uint32_t dma_emergency_bus_select;
79208 + enum fman_dma_emergency_level dma_emergency_level;
79209 + bool dma_en_emergency_smoother;
79210 + uint32_t dma_emergency_switch_counter;
79211 + bool halt_on_external_activ;
79212 + bool halt_on_unrecov_ecc_err;
79213 + enum fman_catastrophic_err catastrophic_err;
79214 + enum fman_dma_err dma_err;
79215 + bool en_muram_test_mode;
79216 + bool en_iram_test_mode;
79217 + bool external_ecc_rams_enable;
79218 + uint16_t tnum_aging_period;
79219 + uint32_t exceptions;
79220 + uint16_t clk_freq;
79221 + bool pedantic_dma;
79222 + uint32_t cam_base_addr;
79223 + uint32_t fifo_base_addr;
79224 + uint32_t total_fifo_size;
79225 + uint8_t total_num_of_tasks;
79226 + bool qmi_deq_option_support;
79227 + uint32_t qmi_def_tnums_thresh;
79228 + bool fman_partition_array;
79229 + uint8_t num_of_fman_ctrl_evnt_regs;
79230 +};
79231 +
79232 +/**************************************************************************//**
79233 + @Description Exceptions
79234 +*//***************************************************************************/
79235 +#define FMAN_EX_DMA_BUS_ERROR 0x80000000
79236 +#define FMAN_EX_DMA_READ_ECC 0x40000000
79237 +#define FMAN_EX_DMA_SYSTEM_WRITE_ECC 0x20000000
79238 +#define FMAN_EX_DMA_FM_WRITE_ECC 0x10000000
79239 +#define FMAN_EX_FPM_STALL_ON_TASKS 0x08000000
79240 +#define FMAN_EX_FPM_SINGLE_ECC 0x04000000
79241 +#define FMAN_EX_FPM_DOUBLE_ECC 0x02000000
79242 +#define FMAN_EX_QMI_SINGLE_ECC 0x01000000
79243 +#define FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID 0x00800000
79244 +#define FMAN_EX_QMI_DOUBLE_ECC 0x00400000
79245 +#define FMAN_EX_BMI_LIST_RAM_ECC 0x00200000
79246 +#define FMAN_EX_BMI_PIPELINE_ECC 0x00100000
79247 +#define FMAN_EX_BMI_STATISTICS_RAM_ECC 0x00080000
79248 +#define FMAN_EX_IRAM_ECC 0x00040000
79249 +#define FMAN_EX_NURAM_ECC 0x00020000
79250 +#define FMAN_EX_BMI_DISPATCH_RAM_ECC 0x00010000
79251 +
79252 +enum fman_exceptions {
79253 + E_FMAN_EX_DMA_BUS_ERROR = 0, /**< DMA bus error. */
79254 + E_FMAN_EX_DMA_READ_ECC, /**< Read Buffer ECC error */
79255 + E_FMAN_EX_DMA_SYSTEM_WRITE_ECC, /**< Write Buffer ECC err on sys side */
79256 + E_FMAN_EX_DMA_FM_WRITE_ECC, /**< Write Buffer ECC error on FM side */
79257 + E_FMAN_EX_FPM_STALL_ON_TASKS, /**< Stall of tasks on FPM */
79258 + E_FMAN_EX_FPM_SINGLE_ECC, /**< Single ECC on FPM. */
79259 + E_FMAN_EX_FPM_DOUBLE_ECC, /**< Double ECC error on FPM ram access */
79260 + E_FMAN_EX_QMI_SINGLE_ECC, /**< Single ECC on QMI. */
79261 + E_FMAN_EX_QMI_DOUBLE_ECC, /**< Double bit ECC occurred on QMI */
79262 + E_FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,/**< DeQ from unknown port id */
79263 + E_FMAN_EX_BMI_LIST_RAM_ECC, /**< Linked List RAM ECC error */
79264 + E_FMAN_EX_BMI_STORAGE_PROFILE_ECC, /**< storage profile */
79265 + E_FMAN_EX_BMI_STATISTICS_RAM_ECC, /**< Statistics RAM ECC Err Enable */
79266 + E_FMAN_EX_BMI_DISPATCH_RAM_ECC, /**< Dispatch RAM ECC Error Enable */
79267 + E_FMAN_EX_IRAM_ECC, /**< Double bit ECC occurred on IRAM*/
79268 + E_FMAN_EX_MURAM_ECC /**< Double bit ECC occurred on MURAM*/
79269 +};
79270 +
79271 +enum fman_counters {
79272 + E_FMAN_COUNTERS_ENQ_TOTAL_FRAME = 0, /**< QMI tot enQ frames counter */
79273 + E_FMAN_COUNTERS_DEQ_TOTAL_FRAME, /**< QMI tot deQ frames counter */
79274 + E_FMAN_COUNTERS_DEQ_0, /**< QMI 0 frames from QMan counter */
79275 + E_FMAN_COUNTERS_DEQ_1, /**< QMI 1 frames from QMan counter */
79276 + E_FMAN_COUNTERS_DEQ_2, /**< QMI 2 frames from QMan counter */
79277 + E_FMAN_COUNTERS_DEQ_3, /**< QMI 3 frames from QMan counter */
79278 + E_FMAN_COUNTERS_DEQ_FROM_DEFAULT, /**< QMI deQ from dflt queue cntr */
79279 + E_FMAN_COUNTERS_DEQ_FROM_CONTEXT, /**< QMI deQ from FQ context cntr */
79280 + E_FMAN_COUNTERS_DEQ_FROM_FD, /**< QMI deQ from FD command field cntr */
79281 + E_FMAN_COUNTERS_DEQ_CONFIRM, /**< QMI dequeue confirm counter */
79282 + E_FMAN_COUNTERS_SEMAPHOR_ENTRY_FULL_REJECT, /**< DMA full entry cntr */
79283 + E_FMAN_COUNTERS_SEMAPHOR_QUEUE_FULL_REJECT, /**< DMA full CAM Q cntr */
79284 + E_FMAN_COUNTERS_SEMAPHOR_SYNC_REJECT /**< DMA sync counter */
79285 +};
79286 +
79287 +#define FPM_PRT_FM_CTL1 0x00000001
79288 +#define FPM_PRT_FM_CTL2 0x00000002
79289 +
79290 +/**************************************************************************//**
79291 + @Description DMA definitions
79292 +*//***************************************************************************/
79293 +
79294 +/* masks */
79295 +#define DMA_MODE_AID_OR 0x20000000
79296 +#define DMA_MODE_SBER 0x10000000
79297 +#define DMA_MODE_BER 0x00200000
79298 +#define DMA_MODE_EB 0x00100000
79299 +#define DMA_MODE_ECC 0x00000020
79300 +#define DMA_MODE_PRIVILEGE_PROT 0x00001000
79301 +#define DMA_MODE_SECURE_PROT 0x00000800
79302 +#define DMA_MODE_EMER_READ 0x00080000
79303 +#define DMA_MODE_EMER_WRITE 0x00040000
79304 +#define DMA_MODE_CACHE_OR_MASK 0xC0000000
79305 +#define DMA_MODE_CEN_MASK 0x0000E000
79306 +#define DMA_MODE_DBG_MASK 0x00000380
79307 +#define DMA_MODE_AXI_DBG_MASK 0x0F000000
79308 +
79309 +#define DMA_EMSR_EMSTR_MASK 0x0000FFFF
79310 +
79311 +#define DMA_TRANSFER_PORTID_MASK 0xFF000000
79312 +#define DMA_TRANSFER_TNUM_MASK 0x00FF0000
79313 +#define DMA_TRANSFER_LIODN_MASK 0x00000FFF
79314 +
79315 +#define DMA_HIGH_LIODN_MASK 0x0FFF0000
79316 +#define DMA_LOW_LIODN_MASK 0x00000FFF
79317 +
79318 +#define DMA_STATUS_CMD_QUEUE_NOT_EMPTY 0x10000000
79319 +#define DMA_STATUS_BUS_ERR 0x08000000
79320 +#define DMA_STATUS_READ_ECC 0x04000000
79321 +#define DMA_STATUS_SYSTEM_WRITE_ECC 0x02000000
79322 +#define DMA_STATUS_FM_WRITE_ECC 0x01000000
79323 +#define DMA_STATUS_SYSTEM_DPEXT_ECC 0x00800000
79324 +#define DMA_STATUS_FM_DPEXT_ECC 0x00400000
79325 +#define DMA_STATUS_SYSTEM_DPDAT_ECC 0x00200000
79326 +#define DMA_STATUS_FM_DPDAT_ECC 0x00100000
79327 +#define DMA_STATUS_FM_SPDAT_ECC 0x00080000
79328 +
79329 +#define FM_LIODN_BASE_MASK 0x00000FFF
79330 +
79331 +/* shifts */
79332 +#define DMA_MODE_CACHE_OR_SHIFT 30
79333 +#define DMA_MODE_BUS_PRI_SHIFT 16
79334 +#define DMA_MODE_AXI_DBG_SHIFT 24
79335 +#define DMA_MODE_CEN_SHIFT 13
79336 +#define DMA_MODE_BUS_PROT_SHIFT 10
79337 +#define DMA_MODE_DBG_SHIFT 7
79338 +#define DMA_MODE_EMER_LVL_SHIFT 6
79339 +#define DMA_MODE_AID_MODE_SHIFT 4
79340 +#define DMA_MODE_MAX_AXI_DBG_NUM_OF_BEATS 16
79341 +#define DMA_MODE_MAX_CAM_NUM_OF_ENTRIES 32
79342 +
79343 +#define DMA_THRESH_COMMQ_SHIFT 24
79344 +#define DMA_THRESH_READ_INT_BUF_SHIFT 16
79345 +
79346 +#define DMA_LIODN_SHIFT 16
79347 +
79348 +#define DMA_TRANSFER_PORTID_SHIFT 24
79349 +#define DMA_TRANSFER_TNUM_SHIFT 16
79350 +
79351 +/* sizes */
79352 +#define DMA_MAX_WATCHDOG 0xffffffff
79353 +
79354 +/* others */
79355 +#define DMA_CAM_SIZEOF_ENTRY 0x40
79356 +#define DMA_CAM_ALIGN 0x1000
79357 +#define DMA_CAM_UNITS 8
79358 +
79359 +/**************************************************************************//**
79360 + @Description General defines
79361 +*//***************************************************************************/
79362 +
79363 +#define FM_DEBUG_STATUS_REGISTER_OFFSET 0x000d1084UL
79364 +#define FM_UCODE_DEBUG_INSTRUCTION 0x6ffff805UL
79365 +
79366 +/**************************************************************************//**
79367 + @Description FPM defines
79368 +*//***************************************************************************/
79369 +
79370 +/* masks */
79371 +#define FPM_EV_MASK_DOUBLE_ECC 0x80000000
79372 +#define FPM_EV_MASK_STALL 0x40000000
79373 +#define FPM_EV_MASK_SINGLE_ECC 0x20000000
79374 +#define FPM_EV_MASK_RELEASE_FM 0x00010000
79375 +#define FPM_EV_MASK_DOUBLE_ECC_EN 0x00008000
79376 +#define FPM_EV_MASK_STALL_EN 0x00004000
79377 +#define FPM_EV_MASK_SINGLE_ECC_EN 0x00002000
79378 +#define FPM_EV_MASK_EXTERNAL_HALT 0x00000008
79379 +#define FPM_EV_MASK_ECC_ERR_HALT 0x00000004
79380 +
79381 +#define FPM_RAM_RAMS_ECC_EN 0x80000000
79382 +#define FPM_RAM_IRAM_ECC_EN 0x40000000
79383 +#define FPM_RAM_MURAM_ECC 0x00008000
79384 +#define FPM_RAM_IRAM_ECC 0x00004000
79385 +#define FPM_RAM_MURAM_TEST_ECC 0x20000000
79386 +#define FPM_RAM_IRAM_TEST_ECC 0x10000000
79387 +#define FPM_RAM_RAMS_ECC_EN_SRC_SEL 0x08000000
79388 +
79389 +#define FPM_IRAM_ECC_ERR_EX_EN 0x00020000
79390 +#define FPM_MURAM_ECC_ERR_EX_EN 0x00040000
79391 +
79392 +#define FPM_REV1_MAJOR_MASK 0x0000FF00
79393 +#define FPM_REV1_MINOR_MASK 0x000000FF
79394 +
79395 +#define FPM_REV2_INTEG_MASK 0x00FF0000
79396 +#define FPM_REV2_ERR_MASK 0x0000FF00
79397 +#define FPM_REV2_CFG_MASK 0x000000FF
79398 +
79399 +#define FPM_TS_FRACTION_MASK 0x0000FFFF
79400 +#define FPM_TS_CTL_EN 0x80000000
79401 +
79402 +#define FPM_PRC_REALSE_STALLED 0x00800000
79403 +
79404 +#define FPM_PS_STALLED 0x00800000
79405 +#define FPM_PS_FM_CTL1_SEL 0x80000000
79406 +#define FPM_PS_FM_CTL2_SEL 0x40000000
79407 +#define FPM_PS_FM_CTL_SEL_MASK (FPM_PS_FM_CTL1_SEL | FPM_PS_FM_CTL2_SEL)
79408 +
79409 +#define FPM_RSTC_FM_RESET 0x80000000
79410 +#define FPM_RSTC_10G0_RESET 0x04000000
79411 +#define FPM_RSTC_1G0_RESET 0x40000000
79412 +#define FPM_RSTC_1G1_RESET 0x20000000
79413 +#define FPM_RSTC_1G2_RESET 0x10000000
79414 +#define FPM_RSTC_1G3_RESET 0x08000000
79415 +#define FPM_RSTC_1G4_RESET 0x02000000
79416 +
79417 +
79418 +#define FPM_DISP_LIMIT_MASK 0x1F000000
79419 +#define FPM_THR1_PRS_MASK 0xFF000000
79420 +#define FPM_THR1_KG_MASK 0x00FF0000
79421 +#define FPM_THR1_PLCR_MASK 0x0000FF00
79422 +#define FPM_THR1_BMI_MASK 0x000000FF
79423 +
79424 +#define FPM_THR2_QMI_ENQ_MASK 0xFF000000
79425 +#define FPM_THR2_QMI_DEQ_MASK 0x000000FF
79426 +#define FPM_THR2_FM_CTL1_MASK 0x00FF0000
79427 +#define FPM_THR2_FM_CTL2_MASK 0x0000FF00
79428 +
79429 +/* shifts */
79430 +#define FPM_DISP_LIMIT_SHIFT 24
79431 +
79432 +#define FPM_THR1_PRS_SHIFT 24
79433 +#define FPM_THR1_KG_SHIFT 16
79434 +#define FPM_THR1_PLCR_SHIFT 8
79435 +#define FPM_THR1_BMI_SHIFT 0
79436 +
79437 +#define FPM_THR2_QMI_ENQ_SHIFT 24
79438 +#define FPM_THR2_QMI_DEQ_SHIFT 0
79439 +#define FPM_THR2_FM_CTL1_SHIFT 16
79440 +#define FPM_THR2_FM_CTL2_SHIFT 8
79441 +
79442 +#define FPM_EV_MASK_CAT_ERR_SHIFT 1
79443 +#define FPM_EV_MASK_DMA_ERR_SHIFT 0
79444 +
79445 +#define FPM_REV1_MAJOR_SHIFT 8
79446 +#define FPM_REV1_MINOR_SHIFT 0
79447 +
79448 +#define FPM_REV2_INTEG_SHIFT 16
79449 +#define FPM_REV2_ERR_SHIFT 8
79450 +#define FPM_REV2_CFG_SHIFT 0
79451 +
79452 +#define FPM_TS_INT_SHIFT 16
79453 +
79454 +#define FPM_PORT_FM_CTL_PORTID_SHIFT 24
79455 +
79456 +#define FPM_PS_FM_CTL_SEL_SHIFT 30
79457 +#define FPM_PRC_ORA_FM_CTL_SEL_SHIFT 16
79458 +
79459 +#define FPM_DISP_LIMIT_SHIFT 24
79460 +
79461 +/* Interrupts defines */
79462 +#define FPM_EVENT_FM_CTL_0 0x00008000
79463 +#define FPM_EVENT_FM_CTL 0x0000FF00
79464 +#define FPM_EVENT_FM_CTL_BRK 0x00000080
79465 +
79466 +/* others */
79467 +#define FPM_MAX_DISP_LIMIT 31
79468 +#define FPM_RSTC_FM_RESET 0x80000000
79469 +#define FPM_RSTC_1G0_RESET 0x40000000
79470 +#define FPM_RSTC_1G1_RESET 0x20000000
79471 +#define FPM_RSTC_1G2_RESET 0x10000000
79472 +#define FPM_RSTC_1G3_RESET 0x08000000
79473 +#define FPM_RSTC_10G0_RESET 0x04000000
79474 +#define FPM_RSTC_1G4_RESET 0x02000000
79475 +#define FPM_RSTC_1G5_RESET 0x01000000
79476 +#define FPM_RSTC_1G6_RESET 0x00800000
79477 +#define FPM_RSTC_1G7_RESET 0x00400000
79478 +#define FPM_RSTC_10G1_RESET 0x00200000
79479 +/**************************************************************************//**
79480 + @Description BMI defines
79481 +*//***************************************************************************/
79482 +/* masks */
79483 +#define BMI_INIT_START 0x80000000
79484 +#define BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC 0x80000000
79485 +#define BMI_ERR_INTR_EN_LIST_RAM_ECC 0x40000000
79486 +#define BMI_ERR_INTR_EN_STATISTICS_RAM_ECC 0x20000000
79487 +#define BMI_ERR_INTR_EN_DISPATCH_RAM_ECC 0x10000000
79488 +#define BMI_NUM_OF_TASKS_MASK 0x3F000000
79489 +#define BMI_NUM_OF_EXTRA_TASKS_MASK 0x000F0000
79490 +#define BMI_NUM_OF_DMAS_MASK 0x00000F00
79491 +#define BMI_NUM_OF_EXTRA_DMAS_MASK 0x0000000F
79492 +#define BMI_FIFO_SIZE_MASK 0x000003FF
79493 +#define BMI_EXTRA_FIFO_SIZE_MASK 0x03FF0000
79494 +#define BMI_CFG2_DMAS_MASK 0x0000003F
79495 +#define BMI_TOTAL_FIFO_SIZE_MASK 0x07FF0000
79496 +#define BMI_TOTAL_NUM_OF_TASKS_MASK 0x007F0000
79497 +
79498 +/* shifts */
79499 +#define BMI_CFG2_TASKS_SHIFT 16
79500 +#define BMI_CFG2_DMAS_SHIFT 0
79501 +#define BMI_CFG1_FIFO_SIZE_SHIFT 16
79502 +#define BMI_FIFO_SIZE_SHIFT 0
79503 +#define BMI_EXTRA_FIFO_SIZE_SHIFT 16
79504 +#define BMI_NUM_OF_TASKS_SHIFT 24
79505 +#define BMI_EXTRA_NUM_OF_TASKS_SHIFT 16
79506 +#define BMI_NUM_OF_DMAS_SHIFT 8
79507 +#define BMI_EXTRA_NUM_OF_DMAS_SHIFT 0
79508 +
79509 +/* others */
79510 +#define BMI_FIFO_ALIGN 0x100
79511 +#define FMAN_BMI_FIFO_UNITS 0x100
79512 +
79513 +
79514 +/**************************************************************************//**
79515 + @Description QMI defines
79516 +*//***************************************************************************/
79517 +/* masks */
79518 +#define QMI_CFG_ENQ_EN 0x80000000
79519 +#define QMI_CFG_DEQ_EN 0x40000000
79520 +#define QMI_CFG_EN_COUNTERS 0x10000000
79521 +#define QMI_CFG_SOFT_RESET 0x01000000
79522 +#define QMI_CFG_DEQ_MASK 0x0000003F
79523 +#define QMI_CFG_ENQ_MASK 0x00003F00
79524 +
79525 +#define QMI_ERR_INTR_EN_DOUBLE_ECC 0x80000000
79526 +#define QMI_ERR_INTR_EN_DEQ_FROM_DEF 0x40000000
79527 +#define QMI_INTR_EN_SINGLE_ECC 0x80000000
79528 +
79529 +/* shifts */
79530 +#define QMI_CFG_ENQ_SHIFT 8
79531 +#define QMI_TAPC_TAP 22
79532 +
79533 +#define QMI_GS_HALT_NOT_BUSY 0x00000002
79534 +
79535 +/**************************************************************************//**
79536 + @Description IRAM defines
79537 +*//***************************************************************************/
79538 +/* masks */
79539 +#define IRAM_IADD_AIE 0x80000000
79540 +#define IRAM_READY 0x80000000
79541 +
79542 +uint32_t fman_get_bmi_err_event(struct fman_bmi_regs *bmi_rg);
79543 +uint32_t fman_get_qmi_err_event(struct fman_qmi_regs *qmi_rg);
79544 +uint32_t fman_get_dma_com_id(struct fman_dma_regs *dma_rg);
79545 +uint64_t fman_get_dma_addr(struct fman_dma_regs *dma_rg);
79546 +uint32_t fman_get_dma_err_event(struct fman_dma_regs *dma_rg);
79547 +uint32_t fman_get_fpm_err_event(struct fman_fpm_regs *fpm_rg);
79548 +uint32_t fman_get_muram_err_event(struct fman_fpm_regs *fpm_rg);
79549 +uint32_t fman_get_iram_err_event(struct fman_fpm_regs *fpm_rg);
79550 +uint32_t fman_get_qmi_event(struct fman_qmi_regs *qmi_rg);
79551 +uint32_t fman_get_fpm_error_interrupts(struct fman_fpm_regs *fpm_rg);
79552 +uint32_t fman_get_ctrl_intr(struct fman_fpm_regs *fpm_rg,
79553 + uint8_t event_reg_id);
79554 +uint8_t fman_get_qmi_deq_th(struct fman_qmi_regs *qmi_rg);
79555 +uint8_t fman_get_qmi_enq_th(struct fman_qmi_regs *qmi_rg);
79556 +uint16_t fman_get_size_of_fifo(struct fman_bmi_regs *bmi_rg, uint8_t port_id);
79557 +uint32_t fman_get_total_fifo_size(struct fman_bmi_regs *bmi_rg);
79558 +uint16_t fman_get_size_of_extra_fifo(struct fman_bmi_regs *bmi_rg,
79559 + uint8_t port_id);
79560 +uint8_t fman_get_num_of_tasks(struct fman_bmi_regs *bmi_rg, uint8_t port_id);
79561 +uint8_t fman_get_num_extra_tasks(struct fman_bmi_regs *bmi_rg,
79562 + uint8_t port_id);
79563 +uint8_t fman_get_num_of_dmas(struct fman_bmi_regs *bmi_rg, uint8_t port_id);
79564 +uint8_t fman_get_num_extra_dmas(struct fman_bmi_regs *bmi_rg,
79565 + uint8_t port_id);
79566 +uint32_t fman_get_normal_pending(struct fman_fpm_regs *fpm_rg);
79567 +uint32_t fman_get_controller_event(struct fman_fpm_regs *fpm_rg,
79568 + uint8_t reg_id);
79569 +uint32_t fman_get_error_pending(struct fman_fpm_regs *fpm_rg);
79570 +void fman_get_revision(struct fman_fpm_regs *fpm_rg, uint8_t *major,
79571 + uint8_t *minor);
79572 +uint32_t fman_get_counter(struct fman_rg *fman_rg,
79573 + enum fman_counters reg_name);
79574 +uint32_t fman_get_dma_status(struct fman_dma_regs *dma_rg);
79575 +
79576 +
79577 +int fman_set_erratum_10gmac_a004_wa(struct fman_fpm_regs *fpm_rg);
79578 +void fman_set_ctrl_intr(struct fman_fpm_regs *fpm_rg, uint8_t event_reg_id,
79579 + uint32_t enable_events);
79580 +void fman_set_num_of_riscs_per_port(struct fman_fpm_regs *fpm_rg,
79581 + uint8_t port_id,
79582 + uint8_t num_fman_ctrls,
79583 + uint32_t or_fman_ctrl);
79584 +void fman_set_order_restoration_per_port(struct fman_fpm_regs *fpm_rg,
79585 + uint8_t port_id,
79586 + bool independent_mode,
79587 + bool is_rx_port);
79588 +void fman_set_qmi_enq_th(struct fman_qmi_regs *qmi_rg, uint8_t val);
79589 +void fman_set_qmi_deq_th(struct fman_qmi_regs *qmi_rg, uint8_t val);
79590 +void fman_set_liodn_per_port(struct fman_rg *fman_rg,
79591 + uint8_t port_id,
79592 + uint16_t liodn_base,
79593 + uint16_t liodn_offset);
79594 +void fman_set_size_of_fifo(struct fman_bmi_regs *bmi_rg,
79595 + uint8_t port_id,
79596 + uint32_t size_of_fifo,
79597 + uint32_t extra_size_of_fifo);
79598 +void fman_set_num_of_tasks(struct fman_bmi_regs *bmi_rg,
79599 + uint8_t port_id,
79600 + uint8_t num_of_tasks,
79601 + uint8_t num_of_extra_tasks);
79602 +void fman_set_num_of_open_dmas(struct fman_bmi_regs *bmi_rg,
79603 + uint8_t port_id,
79604 + uint8_t num_of_open_dmas,
79605 + uint8_t num_of_extra_open_dmas,
79606 + uint8_t total_num_of_dmas);
79607 +void fman_set_ports_bandwidth(struct fman_bmi_regs *bmi_rg, uint8_t *weights);
79608 +int fman_set_exception(struct fman_rg *fman_rg,
79609 + enum fman_exceptions exception,
79610 + bool enable);
79611 +void fman_set_dma_emergency(struct fman_dma_regs *dma_rg, bool is_write,
79612 + bool enable);
79613 +void fman_set_dma_ext_bus_pri(struct fman_dma_regs *dma_rg, uint32_t pri);
79614 +void fman_set_congestion_group_pfc_priority(uint32_t *cpg_rg,
79615 + uint32_t congestion_group_id,
79616 + uint8_t piority_bit_map,
79617 + uint32_t reg_num);
79618 +
79619 +
79620 +void fman_defconfig(struct fman_cfg *cfg, bool is_master);
79621 +void fman_regconfig(struct fman_rg *fman_rg, struct fman_cfg *cfg);
79622 +int fman_fpm_init(struct fman_fpm_regs *fpm_rg, struct fman_cfg *cfg);
79623 +int fman_bmi_init(struct fman_bmi_regs *bmi_rg, struct fman_cfg *cfg);
79624 +int fman_qmi_init(struct fman_qmi_regs *qmi_rg, struct fman_cfg *cfg);
79625 +int fman_dma_init(struct fman_dma_regs *dma_rg, struct fman_cfg *cfg);
79626 +void fman_free_resources(struct fman_rg *fman_rg);
79627 +int fman_enable(struct fman_rg *fman_rg, struct fman_cfg *cfg);
79628 +void fman_reset(struct fman_fpm_regs *fpm_rg);
79629 +void fman_resume(struct fman_fpm_regs *fpm_rg);
79630 +
79631 +
79632 +void fman_enable_time_stamp(struct fman_fpm_regs *fpm_rg,
79633 + uint8_t count1ubit,
79634 + uint16_t fm_clk_freq);
79635 +void fman_enable_rams_ecc(struct fman_fpm_regs *fpm_rg);
79636 +void fman_qmi_disable_dispatch_limit(struct fman_fpm_regs *fpm_rg);
79637 +void fman_disable_rams_ecc(struct fman_fpm_regs *fpm_rg);
79638 +void fman_resume_stalled_port(struct fman_fpm_regs *fpm_rg, uint8_t port_id);
79639 +int fman_reset_mac(struct fman_fpm_regs *fpm_rg, uint8_t macId, bool is_10g);
79640 +bool fman_is_port_stalled(struct fman_fpm_regs *fpm_rg, uint8_t port_id);
79641 +bool fman_rams_ecc_is_external_ctl(struct fman_fpm_regs *fpm_rg);
79642 +bool fman_is_qmi_halt_not_busy_state(struct fman_qmi_regs *qmi_rg);
79643 +int fman_modify_counter(struct fman_rg *fman_rg,
79644 + enum fman_counters reg_name,
79645 + uint32_t val);
79646 +void fman_force_intr(struct fman_rg *fman_rg,
79647 + enum fman_exceptions exception);
79648 +void fman_set_vsp_window(struct fman_bmi_regs *bmi_rg,
79649 + uint8_t port_id,
79650 + uint8_t base_storage_profile,
79651 + uint8_t log2_num_of_profiles);
79652 +
79653 +/**************************************************************************//**
79654 + @Description default values
79655 +*//***************************************************************************/
79656 +#define DEFAULT_CATASTROPHIC_ERR E_FMAN_CATAST_ERR_STALL_PORT
79657 +#define DEFAULT_DMA_ERR E_FMAN_DMA_ERR_CATASTROPHIC
79658 +#define DEFAULT_HALT_ON_EXTERNAL_ACTIVATION FALSE /* do not change! if changed, must be disabled for rev1 ! */
79659 +#define DEFAULT_HALT_ON_UNRECOVERABLE_ECC_ERROR FALSE /* do not change! if changed, must be disabled for rev1 ! */
79660 +#define DEFAULT_EXTERNAL_ECC_RAMS_ENABLE FALSE
79661 +#define DEFAULT_AID_OVERRIDE FALSE
79662 +#define DEFAULT_AID_MODE E_FMAN_DMA_AID_OUT_TNUM
79663 +#define DEFAULT_DMA_COMM_Q_LOW 0x2A
79664 +#define DEFAULT_DMA_COMM_Q_HIGH 0x3F
79665 +#define DEFAULT_CACHE_OVERRIDE E_FMAN_DMA_NO_CACHE_OR
79666 +#define DEFAULT_DMA_CAM_NUM_OF_ENTRIES 64
79667 +#define DEFAULT_DMA_DBG_CNT_MODE E_FMAN_DMA_DBG_NO_CNT
79668 +#define DEFAULT_DMA_EN_EMERGENCY FALSE
79669 +#define DEFAULT_DMA_SOS_EMERGENCY 0
79670 +#define DEFAULT_DMA_WATCHDOG 0 /* disabled */
79671 +#define DEFAULT_DMA_EN_EMERGENCY_SMOOTHER FALSE
79672 +#define DEFAULT_DMA_EMERGENCY_SWITCH_COUNTER 0
79673 +#define DEFAULT_DISP_LIMIT 0
79674 +#define DEFAULT_PRS_DISP_TH 16
79675 +#define DEFAULT_PLCR_DISP_TH 16
79676 +#define DEFAULT_KG_DISP_TH 16
79677 +#define DEFAULT_BMI_DISP_TH 16
79678 +#define DEFAULT_QMI_ENQ_DISP_TH 16
79679 +#define DEFAULT_QMI_DEQ_DISP_TH 16
79680 +#define DEFAULT_FM_CTL1_DISP_TH 16
79681 +#define DEFAULT_FM_CTL2_DISP_TH 16
79682 +#define DEFAULT_TNUM_AGING_PERIOD 4
79683 +
79684 +
79685 +#endif /* __FSL_FMAN_H */
79686 --- /dev/null
79687 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_dtsec.h
79688 @@ -0,0 +1,1096 @@
79689 +/*
79690 + * Copyright 2008-2012 Freescale Semiconductor Inc.
79691 + *
79692 + * Redistribution and use in source and binary forms, with or without
79693 + * modification, are permitted provided that the following conditions are met:
79694 + * * Redistributions of source code must retain the above copyright
79695 + * notice, this list of conditions and the following disclaimer.
79696 + * * Redistributions in binary form must reproduce the above copyright
79697 + * notice, this list of conditions and the following disclaimer in the
79698 + * documentation and/or other materials provided with the distribution.
79699 + * * Neither the name of Freescale Semiconductor nor the
79700 + * names of its contributors may be used to endorse or promote products
79701 + * derived from this software without specific prior written permission.
79702 + *
79703 + *
79704 + * ALTERNATIVELY, this software may be distributed under the terms of the
79705 + * GNU General Public License ("GPL") as published by the Free Software
79706 + * Foundation, either version 2 of that License or (at your option) any
79707 + * later version.
79708 + *
79709 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
79710 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
79711 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
79712 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
79713 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
79714 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
79715 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
79716 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
79717 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
79718 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
79719 + */
79720 +
79721 +#ifndef __FSL_FMAN_DTSEC_H
79722 +#define __FSL_FMAN_DTSEC_H
79723 +
79724 +#include "common/general.h"
79725 +#include "fsl_enet.h"
79726 +
79727 +/**
79728 + * DOC: dTSEC Init sequence
79729 + *
79730 + * To prepare dTSEC block for transfer use the following call sequence:
79731 + *
79732 + * - fman_dtsec_defconfig() - This step is optional and yet recommended. Its
79733 + * use is to obtain the default dTSEC configuration parameters.
79734 + *
79735 + * - Change dtsec configuration in &dtsec_cfg. This structure will be used
79736 + * to customize the dTSEC behavior.
79737 + *
79738 + * - fman_dtsec_init() - Applies the configuration on dTSEC hardware. Note that
79739 + * dTSEC is initialized while both Tx and Rx are disabled.
79740 + *
79741 + * - fman_dtsec_set_mac_address() - Set the station address (mac address).
79742 + * This is used by dTSEC to match against received packets.
79743 + *
79744 + * - fman_dtsec_adjust_link() - Set the link speed and duplex parameters
79745 + * after the PHY establishes the link.
79746 + *
79747 + * - dtsec_enable_tx() and dtsec_enable_rx() to enable transmission and
79748 + * reception.
79749 + */
79750 +
79751 +/**
79752 + * DOC: dTSEC Graceful stop
79753 + *
79754 + * To temporary stop dTSEC activity use fman_dtsec_stop_tx() and
79755 + * fman_dtsec_stop_rx(). Note that these functions request dTSEC graceful stop
79756 + * but return before this stop is complete. To query for graceful stop
79757 + * completion use fman_dtsec_get_event() and check DTSEC_IEVENT_GTSC and
79758 + * DTSEC_IEVENT_GRSC bits. Alternatively the dTSEC interrupt mask can be set to
79759 + * enable graceful stop interrupts.
79760 + *
79761 + * To resume operation after graceful stop use fman_dtsec_start_tx() and
79762 + * fman_dtsec_start_rx().
79763 + */
79764 +
79765 +/**
79766 + * DOC: dTSEC interrupt handling
79767 + *
79768 + * This code does not provide an interrupt handler for dTSEC. Instead this
79769 + * handler should be implemented and registered to the operating system by the
79770 + * caller. Some primitives for accessing the event status and mask registers
79771 + * are provided.
79772 + *
79773 + * See "dTSEC Events" section for a list of events that dTSEC can generate.
79774 + */
79775 +
79776 +/**
79777 + * DOC: dTSEC Events
79778 + *
79779 + * Interrupt events cause dTSEC event bits to be set. Software may poll the
79780 + * event register at any time to check for pending interrupts. If an event
79781 + * occurs and its corresponding enable bit is set in the interrupt mask
79782 + * register, the event also causes a hardware interrupt at the PIC.
79783 + *
79784 + * To poll for event status use the fman_dtsec_get_event() function.
79785 + * To configure the interrupt mask use fman_dtsec_enable_interrupt() and
79786 + * fman_dtsec_disable_interrupt() functions.
79787 + * After servicing a dTSEC interrupt use fman_dtsec_ack_event to reset the
79788 + * serviced event bit.
79789 + *
79790 + * The following events may be signaled by dTSEC hardware:
79791 + *
79792 + * %DTSEC_IEVENT_BABR - Babbling receive error. This bit indicates that
79793 + * a frame was received with length in excess of the MAC's maximum frame length
79794 + * register.
79795 + *
79796 + * %DTSEC_IEVENT_RXC - Receive control (pause frame) interrupt. A pause
79797 + * control frame was received while Rx pause frame handling is enabled.
79798 + * Also see fman_dtsec_handle_rx_pause().
79799 + *
79800 + * %DTSEC_IEVENT_MSRO - MIB counter overflow. The count for one of the MIB
79801 + * counters has exceeded the size of its register.
79802 + *
79803 + * %DTSEC_IEVENT_GTSC - Graceful transmit stop complete. Graceful stop is now
79804 + * complete. The transmitter is in a stopped state, in which only pause frames
79805 + * can be transmitted.
79806 + * Also see fman_dtsec_stop_tx().
79807 + *
79808 + * %DTSEC_IEVENT_BABT - Babbling transmit error. The transmitted frame length
79809 + * has exceeded the value in the MAC's Maximum Frame Length register.
79810 + *
79811 + * %DTSEC_IEVENT_TXC - Transmit control (pause frame) interrupt. his bit
79812 + * indicates that a control frame was transmitted.
79813 + *
79814 + * %DTSEC_IEVENT_TXE - Transmit error. This bit indicates that an error
79815 + * occurred on the transmitted channel. This bit is set whenever any transmit
79816 + * error occurs which causes the dTSEC to discard all or part of a frame
79817 + * (LC, CRL, XFUN).
79818 + *
79819 + * %DTSEC_IEVENT_LC - Late collision. This bit indicates that a collision
79820 + * occurred beyond the collision window (slot time) in half-duplex mode.
79821 + * The frame is truncated with a bad CRC and the remainder of the frame
79822 + * is discarded.
79823 + *
79824 + * %DTSEC_IEVENT_CRL - Collision retry limit. is bit indicates that the number
79825 + * of successive transmission collisions has exceeded the MAC's half-duplex
79826 + * register's retransmission maximum count. The frame is discarded without
79827 + * being transmitted and transmission of the next frame commences. This only
79828 + * occurs while in half-duplex mode.
79829 + * The number of retransmit attempts can be set in
79830 + * &dtsec_halfdup_cfg.@retransmit before calling fman_dtsec_init().
79831 + *
79832 + * %DTSEC_IEVENT_XFUN - Transmit FIFO underrun. This bit indicates that the
79833 + * transmit FIFO became empty before the complete frame was transmitted.
79834 + * The frame is truncated with a bad CRC and the remainder of the frame is
79835 + * discarded.
79836 + *
79837 + * %DTSEC_IEVENT_MAG - TBD
79838 + *
79839 + * %DTSEC_IEVENT_MMRD - MII management read completion.
79840 + *
79841 + * %DTSEC_IEVENT_MMWR - MII management write completion.
79842 + *
79843 + * %DTSEC_IEVENT_GRSC - Graceful receive stop complete. It allows the user to
79844 + * know if the system has completed the stop and it is safe to write to receive
79845 + * registers (status, control or configuration registers) that are used by the
79846 + * system during normal operation.
79847 + *
79848 + * %DTSEC_IEVENT_TDPE - Internal data error on transmit. This bit indicates
79849 + * that the dTSEC has detected a parity error on its stored transmit data, which
79850 + * is likely to compromise the validity of recently transferred frames.
79851 + *
79852 + * %DTSEC_IEVENT_RDPE - Internal data error on receive. This bit indicates that
79853 + * the dTSEC has detected a parity error on its stored receive data, which is
79854 + * likely to compromise the validity of recently transferred frames.
79855 + */
79856 +/* Interrupt Mask Register (IMASK) */
79857 +#define DTSEC_IMASK_BREN 0x80000000
79858 +#define DTSEC_IMASK_RXCEN 0x40000000
79859 +#define DTSEC_IMASK_MSROEN 0x04000000
79860 +#define DTSEC_IMASK_GTSCEN 0x02000000
79861 +#define DTSEC_IMASK_BTEN 0x01000000
79862 +#define DTSEC_IMASK_TXCEN 0x00800000
79863 +#define DTSEC_IMASK_TXEEN 0x00400000
79864 +#define DTSEC_IMASK_LCEN 0x00040000
79865 +#define DTSEC_IMASK_CRLEN 0x00020000
79866 +#define DTSEC_IMASK_XFUNEN 0x00010000
79867 +#define DTSEC_IMASK_ABRTEN 0x00008000
79868 +#define DTSEC_IMASK_IFERREN 0x00004000
79869 +#define DTSEC_IMASK_MAGEN 0x00000800
79870 +#define DTSEC_IMASK_MMRDEN 0x00000400
79871 +#define DTSEC_IMASK_MMWREN 0x00000200
79872 +#define DTSEC_IMASK_GRSCEN 0x00000100
79873 +#define DTSEC_IMASK_TDPEEN 0x00000002
79874 +#define DTSEC_IMASK_RDPEEN 0x00000001
79875 +
79876 +#define DTSEC_EVENTS_MASK \
79877 + ((uint32_t)(DTSEC_IMASK_BREN | \
79878 + DTSEC_IMASK_RXCEN | \
79879 + DTSEC_IMASK_BTEN | \
79880 + DTSEC_IMASK_TXCEN | \
79881 + DTSEC_IMASK_TXEEN | \
79882 + DTSEC_IMASK_ABRTEN | \
79883 + DTSEC_IMASK_LCEN | \
79884 + DTSEC_IMASK_CRLEN | \
79885 + DTSEC_IMASK_XFUNEN | \
79886 + DTSEC_IMASK_IFERREN | \
79887 + DTSEC_IMASK_MAGEN | \
79888 + DTSEC_IMASK_TDPEEN | \
79889 + DTSEC_IMASK_RDPEEN))
79890 +
79891 +/* dtsec timestamp event bits */
79892 +#define TMR_PEMASK_TSREEN 0x00010000
79893 +#define TMR_PEVENT_TSRE 0x00010000
79894 +
79895 +/* Group address bit indication */
79896 +#define MAC_GROUP_ADDRESS 0x0000010000000000ULL
79897 +/* size in bytes of L2 address */
79898 +#define MAC_ADDRLEN 6
79899 +
79900 +#define DEFAULT_HALFDUP_ON FALSE
79901 +#define DEFAULT_HALFDUP_RETRANSMIT 0xf
79902 +#define DEFAULT_HALFDUP_COLL_WINDOW 0x37
79903 +#define DEFAULT_HALFDUP_EXCESS_DEFER TRUE
79904 +#define DEFAULT_HALFDUP_NO_BACKOFF FALSE
79905 +#define DEFAULT_HALFDUP_BP_NO_BACKOFF FALSE
79906 +#define DEFAULT_HALFDUP_ALT_BACKOFF_VAL 0x0A
79907 +#define DEFAULT_HALFDUP_ALT_BACKOFF_EN FALSE
79908 +#define DEFAULT_RX_DROP_BCAST FALSE
79909 +#define DEFAULT_RX_SHORT_FRM TRUE
79910 +#define DEFAULT_RX_LEN_CHECK FALSE
79911 +#define DEFAULT_TX_PAD_CRC TRUE
79912 +#define DEFAULT_TX_CRC FALSE
79913 +#define DEFAULT_RX_CTRL_ACC FALSE
79914 +#define DEFAULT_TX_PAUSE_TIME 0xf000
79915 +#define DEFAULT_TBIPA 5
79916 +#define DEFAULT_RX_PREPEND 0
79917 +#define DEFAULT_PTP_TSU_EN TRUE
79918 +#define DEFAULT_PTP_EXCEPTION_EN TRUE
79919 +#define DEFAULT_PREAMBLE_LEN 7
79920 +#define DEFAULT_RX_PREAMBLE FALSE
79921 +#define DEFAULT_TX_PREAMBLE FALSE
79922 +#define DEFAULT_LOOPBACK FALSE
79923 +#define DEFAULT_RX_TIME_STAMP_EN FALSE
79924 +#define DEFAULT_TX_TIME_STAMP_EN FALSE
79925 +#define DEFAULT_RX_FLOW TRUE
79926 +#define DEFAULT_TX_FLOW TRUE
79927 +#define DEFAULT_RX_GROUP_HASH_EXD FALSE
79928 +#define DEFAULT_TX_PAUSE_TIME_EXTD 0
79929 +#define DEFAULT_RX_PROMISC FALSE
79930 +#define DEFAULT_NON_BACK_TO_BACK_IPG1 0x40
79931 +#define DEFAULT_NON_BACK_TO_BACK_IPG2 0x60
79932 +#define DEFAULT_MIN_IFG_ENFORCEMENT 0x50
79933 +#define DEFAULT_BACK_TO_BACK_IPG 0x60
79934 +#define DEFAULT_MAXIMUM_FRAME 0x600
79935 +#define DEFAULT_TBI_PHY_ADDR 5
79936 +#define DEFAULT_WAKE_ON_LAN FALSE
79937 +
79938 +/* register related defines (bits, field offsets..) */
79939 +#define DTSEC_ID1_ID 0xffff0000
79940 +#define DTSEC_ID1_REV_MJ 0x0000FF00
79941 +#define DTSEC_ID1_REV_MN 0x000000ff
79942 +
79943 +#define DTSEC_ID2_INT_REDUCED_OFF 0x00010000
79944 +#define DTSEC_ID2_INT_NORMAL_OFF 0x00020000
79945 +
79946 +#define DTSEC_ECNTRL_CLRCNT 0x00004000
79947 +#define DTSEC_ECNTRL_AUTOZ 0x00002000
79948 +#define DTSEC_ECNTRL_STEN 0x00001000
79949 +#define DTSEC_ECNTRL_CFG_RO 0x80000000
79950 +#define DTSEC_ECNTRL_GMIIM 0x00000040
79951 +#define DTSEC_ECNTRL_TBIM 0x00000020
79952 +#define DTSEC_ECNTRL_SGMIIM 0x00000002
79953 +#define DTSEC_ECNTRL_RPM 0x00000010
79954 +#define DTSEC_ECNTRL_R100M 0x00000008
79955 +#define DTSEC_ECNTRL_RMM 0x00000004
79956 +#define DTSEC_ECNTRL_QSGMIIM 0x00000001
79957 +
79958 +#define DTSEC_TCTRL_THDF 0x00000800
79959 +#define DTSEC_TCTRL_TTSE 0x00000040
79960 +#define DTSEC_TCTRL_GTS 0x00000020
79961 +#define DTSEC_TCTRL_TFC_PAUSE 0x00000010
79962 +
79963 +/* PTV offsets */
79964 +#define PTV_PTE_OFST 16
79965 +
79966 +#define RCTRL_CFA 0x00008000
79967 +#define RCTRL_GHTX 0x00000400
79968 +#define RCTRL_RTSE 0x00000040
79969 +#define RCTRL_GRS 0x00000020
79970 +#define RCTRL_BC_REJ 0x00000010
79971 +#define RCTRL_MPROM 0x00000008
79972 +#define RCTRL_RSF 0x00000004
79973 +#define RCTRL_UPROM 0x00000001
79974 +#define RCTRL_PROM (RCTRL_UPROM | RCTRL_MPROM)
79975 +
79976 +#define TMR_CTL_ESFDP 0x00000800
79977 +#define TMR_CTL_ESFDE 0x00000400
79978 +
79979 +#define MACCFG1_SOFT_RESET 0x80000000
79980 +#define MACCFG1_LOOPBACK 0x00000100
79981 +#define MACCFG1_RX_FLOW 0x00000020
79982 +#define MACCFG1_TX_FLOW 0x00000010
79983 +#define MACCFG1_TX_EN 0x00000001
79984 +#define MACCFG1_RX_EN 0x00000004
79985 +#define MACCFG1_RESET_RxMC 0x00080000
79986 +#define MACCFG1_RESET_TxMC 0x00040000
79987 +#define MACCFG1_RESET_RxFUN 0x00020000
79988 +#define MACCFG1_RESET_TxFUN 0x00010000
79989 +
79990 +#define MACCFG2_NIBBLE_MODE 0x00000100
79991 +#define MACCFG2_BYTE_MODE 0x00000200
79992 +#define MACCFG2_PRE_AM_Rx_EN 0x00000080
79993 +#define MACCFG2_PRE_AM_Tx_EN 0x00000040
79994 +#define MACCFG2_LENGTH_CHECK 0x00000010
79995 +#define MACCFG2_MAGIC_PACKET_EN 0x00000008
79996 +#define MACCFG2_PAD_CRC_EN 0x00000004
79997 +#define MACCFG2_CRC_EN 0x00000002
79998 +#define MACCFG2_FULL_DUPLEX 0x00000001
79999 +
80000 +#define PREAMBLE_LENGTH_SHIFT 12
80001 +
80002 +#define IPGIFG_NON_BACK_TO_BACK_IPG_1_SHIFT 24
80003 +#define IPGIFG_NON_BACK_TO_BACK_IPG_2_SHIFT 16
80004 +#define IPGIFG_MIN_IFG_ENFORCEMENT_SHIFT 8
80005 +
80006 +#define IPGIFG_NON_BACK_TO_BACK_IPG_1 0x7F000000
80007 +#define IPGIFG_NON_BACK_TO_BACK_IPG_2 0x007F0000
80008 +#define IPGIFG_MIN_IFG_ENFORCEMENT 0x0000FF00
80009 +#define IPGIFG_BACK_TO_BACK_IPG 0x0000007F
80010 +
80011 +#define HAFDUP_ALT_BEB 0x00080000
80012 +#define HAFDUP_BP_NO_BACKOFF 0x00040000
80013 +#define HAFDUP_NO_BACKOFF 0x00020000
80014 +#define HAFDUP_EXCESS_DEFER 0x00010000
80015 +#define HAFDUP_COLLISION_WINDOW 0x000003ff
80016 +
80017 +#define HAFDUP_ALTERNATE_BEB_TRUNCATION_SHIFT 20
80018 +#define HAFDUP_RETRANSMISSION_MAX_SHIFT 12
80019 +#define HAFDUP_RETRANSMISSION_MAX 0x0000f000
80020 +
80021 +#define NUM_OF_HASH_REGS 8 /* Number of hash table registers */
80022 +
80023 +/* CAR1/2 bits */
80024 +#define DTSEC_CAR1_TR64 0x80000000
80025 +#define DTSEC_CAR1_TR127 0x40000000
80026 +#define DTSEC_CAR1_TR255 0x20000000
80027 +#define DTSEC_CAR1_TR511 0x10000000
80028 +#define DTSEC_CAR1_TRK1 0x08000000
80029 +#define DTSEC_CAR1_TRMAX 0x04000000
80030 +#define DTSEC_CAR1_TRMGV 0x02000000
80031 +
80032 +#define DTSEC_CAR1_RBYT 0x00010000
80033 +#define DTSEC_CAR1_RPKT 0x00008000
80034 +#define DTSEC_CAR1_RFCS 0x00004000
80035 +#define DTSEC_CAR1_RMCA 0x00002000
80036 +#define DTSEC_CAR1_RBCA 0x00001000
80037 +#define DTSEC_CAR1_RXCF 0x00000800
80038 +#define DTSEC_CAR1_RXPF 0x00000400
80039 +#define DTSEC_CAR1_RXUO 0x00000200
80040 +#define DTSEC_CAR1_RALN 0x00000100
80041 +#define DTSEC_CAR1_RFLR 0x00000080
80042 +#define DTSEC_CAR1_RCDE 0x00000040
80043 +#define DTSEC_CAR1_RCSE 0x00000020
80044 +#define DTSEC_CAR1_RUND 0x00000010
80045 +#define DTSEC_CAR1_ROVR 0x00000008
80046 +#define DTSEC_CAR1_RFRG 0x00000004
80047 +#define DTSEC_CAR1_RJBR 0x00000002
80048 +#define DTSEC_CAR1_RDRP 0x00000001
80049 +
80050 +#define DTSEC_CAR2_TJBR 0x00080000
80051 +#define DTSEC_CAR2_TFCS 0x00040000
80052 +#define DTSEC_CAR2_TXCF 0x00020000
80053 +#define DTSEC_CAR2_TOVR 0x00010000
80054 +#define DTSEC_CAR2_TUND 0x00008000
80055 +#define DTSEC_CAR2_TFRG 0x00004000
80056 +#define DTSEC_CAR2_TBYT 0x00002000
80057 +#define DTSEC_CAR2_TPKT 0x00001000
80058 +#define DTSEC_CAR2_TMCA 0x00000800
80059 +#define DTSEC_CAR2_TBCA 0x00000400
80060 +#define DTSEC_CAR2_TXPF 0x00000200
80061 +#define DTSEC_CAR2_TDFR 0x00000100
80062 +#define DTSEC_CAR2_TEDF 0x00000080
80063 +#define DTSEC_CAR2_TSCL 0x00000040
80064 +#define DTSEC_CAR2_TMCL 0x00000020
80065 +#define DTSEC_CAR2_TLCL 0x00000010
80066 +#define DTSEC_CAR2_TXCL 0x00000008
80067 +#define DTSEC_CAR2_TNCL 0x00000004
80068 +#define DTSEC_CAR2_TDRP 0x00000001
80069 +
80070 +#define CAM1_ERRORS_ONLY \
80071 + (DTSEC_CAR1_RXPF | DTSEC_CAR1_RALN | DTSEC_CAR1_RFLR \
80072 + | DTSEC_CAR1_RCDE | DTSEC_CAR1_RCSE | DTSEC_CAR1_RUND \
80073 + | DTSEC_CAR1_ROVR | DTSEC_CAR1_RFRG | DTSEC_CAR1_RJBR \
80074 + | DTSEC_CAR1_RDRP)
80075 +
80076 +#define CAM2_ERRORS_ONLY (DTSEC_CAR2_TFCS | DTSEC_CAR2_TXPF | DTSEC_CAR2_TDRP)
80077 +
80078 +/*
80079 + * Group of dTSEC specific counters relating to the standard RMON MIB Group 1
80080 + * (or Ethernet) statistics.
80081 + */
80082 +#define CAM1_MIB_GRP_1 \
80083 + (DTSEC_CAR1_RDRP | DTSEC_CAR1_RBYT | DTSEC_CAR1_RPKT | DTSEC_CAR1_RMCA\
80084 + | DTSEC_CAR1_RBCA | DTSEC_CAR1_RALN | DTSEC_CAR1_RUND | DTSEC_CAR1_ROVR\
80085 + | DTSEC_CAR1_RFRG | DTSEC_CAR1_RJBR \
80086 + | DTSEC_CAR1_TR64 | DTSEC_CAR1_TR127 | DTSEC_CAR1_TR255 \
80087 + | DTSEC_CAR1_TR511 | DTSEC_CAR1_TRMAX)
80088 +
80089 +#define CAM2_MIB_GRP_1 (DTSEC_CAR2_TNCL | DTSEC_CAR2_TDRP)
80090 +
80091 +/* memory map */
80092 +
80093 +struct dtsec_regs {
80094 + /* dTSEC General Control and Status Registers */
80095 + uint32_t tsec_id; /* 0x000 ETSEC_ID register */
80096 + uint32_t tsec_id2; /* 0x004 ETSEC_ID2 register */
80097 + uint32_t ievent; /* 0x008 Interrupt event register */
80098 + uint32_t imask; /* 0x00C Interrupt mask register */
80099 + uint32_t reserved0010[1];
80100 + uint32_t ecntrl; /* 0x014 E control register */
80101 + uint32_t ptv; /* 0x018 Pause time value register */
80102 + uint32_t tbipa; /* 0x01C TBI PHY address register */
80103 + uint32_t tmr_ctrl; /* 0x020 Time-stamp Control register */
80104 + uint32_t tmr_pevent; /* 0x024 Time-stamp event register */
80105 + uint32_t tmr_pemask; /* 0x028 Timer event mask register */
80106 + uint32_t reserved002c[5];
80107 + uint32_t tctrl; /* 0x040 Transmit control register */
80108 + uint32_t reserved0044[3];
80109 + uint32_t rctrl; /* 0x050 Receive control register */
80110 + uint32_t reserved0054[11];
80111 + uint32_t igaddr[8]; /* 0x080-0x09C Individual/group address */
80112 + uint32_t gaddr[8]; /* 0x0A0-0x0BC Group address registers 0-7 */
80113 + uint32_t reserved00c0[16];
80114 + uint32_t maccfg1; /* 0x100 MAC configuration #1 */
80115 + uint32_t maccfg2; /* 0x104 MAC configuration #2 */
80116 + uint32_t ipgifg; /* 0x108 IPG/IFG */
80117 + uint32_t hafdup; /* 0x10C Half-duplex */
80118 + uint32_t maxfrm; /* 0x110 Maximum frame */
80119 + uint32_t reserved0114[10];
80120 + uint32_t ifstat; /* 0x13C Interface status */
80121 + uint32_t macstnaddr1; /* 0x140 Station Address,part 1 */
80122 + uint32_t macstnaddr2; /* 0x144 Station Address,part 2 */
80123 + struct {
80124 + uint32_t exact_match1; /* octets 1-4 */
80125 + uint32_t exact_match2; /* octets 5-6 */
80126 + } macaddr[15]; /* 0x148-0x1BC mac exact match addresses 1-15 */
80127 + uint32_t reserved01c0[16];
80128 + uint32_t tr64; /* 0x200 transmit and receive 64 byte frame counter */
80129 + uint32_t tr127; /* 0x204 transmit and receive 65 to 127 byte frame
80130 + * counter */
80131 + uint32_t tr255; /* 0x208 transmit and receive 128 to 255 byte frame
80132 + * counter */
80133 + uint32_t tr511; /* 0x20C transmit and receive 256 to 511 byte frame
80134 + * counter */
80135 + uint32_t tr1k; /* 0x210 transmit and receive 512 to 1023 byte frame
80136 + * counter */
80137 + uint32_t trmax; /* 0x214 transmit and receive 1024 to 1518 byte frame
80138 + * counter */
80139 + uint32_t trmgv; /* 0x218 transmit and receive 1519 to 1522 byte good
80140 + * VLAN frame count */
80141 + uint32_t rbyt; /* 0x21C receive byte counter */
80142 + uint32_t rpkt; /* 0x220 receive packet counter */
80143 + uint32_t rfcs; /* 0x224 receive FCS error counter */
80144 + uint32_t rmca; /* 0x228 RMCA receive multicast packet counter */
80145 + uint32_t rbca; /* 0x22C receive broadcast packet counter */
80146 + uint32_t rxcf; /* 0x230 receive control frame packet counter */
80147 + uint32_t rxpf; /* 0x234 receive pause frame packet counter */
80148 + uint32_t rxuo; /* 0x238 receive unknown OP code counter */
80149 + uint32_t raln; /* 0x23C receive alignment error counter */
80150 + uint32_t rflr; /* 0x240 receive frame length error counter */
80151 + uint32_t rcde; /* 0x244 receive code error counter */
80152 + uint32_t rcse; /* 0x248 receive carrier sense error counter */
80153 + uint32_t rund; /* 0x24C receive undersize packet counter */
80154 + uint32_t rovr; /* 0x250 receive oversize packet counter */
80155 + uint32_t rfrg; /* 0x254 receive fragments counter */
80156 + uint32_t rjbr; /* 0x258 receive jabber counter */
80157 + uint32_t rdrp; /* 0x25C receive drop */
80158 + uint32_t tbyt; /* 0x260 transmit byte counter */
80159 + uint32_t tpkt; /* 0x264 transmit packet counter */
80160 + uint32_t tmca; /* 0x268 transmit multicast packet counter */
80161 + uint32_t tbca; /* 0x26C transmit broadcast packet counter */
80162 + uint32_t txpf; /* 0x270 transmit pause control frame counter */
80163 + uint32_t tdfr; /* 0x274 transmit deferral packet counter */
80164 + uint32_t tedf; /* 0x278 transmit excessive deferral packet counter */
80165 + uint32_t tscl; /* 0x27C transmit single collision packet counter */
80166 + uint32_t tmcl; /* 0x280 transmit multiple collision packet counter */
80167 + uint32_t tlcl; /* 0x284 transmit late collision packet counter */
80168 + uint32_t txcl; /* 0x288 transmit excessive collision packet counter */
80169 + uint32_t tncl; /* 0x28C transmit total collision counter */
80170 + uint32_t reserved0290[1];
80171 + uint32_t tdrp; /* 0x294 transmit drop frame counter */
80172 + uint32_t tjbr; /* 0x298 transmit jabber frame counter */
80173 + uint32_t tfcs; /* 0x29C transmit FCS error counter */
80174 + uint32_t txcf; /* 0x2A0 transmit control frame counter */
80175 + uint32_t tovr; /* 0x2A4 transmit oversize frame counter */
80176 + uint32_t tund; /* 0x2A8 transmit undersize frame counter */
80177 + uint32_t tfrg; /* 0x2AC transmit fragments frame counter */
80178 + uint32_t car1; /* 0x2B0 carry register one register* */
80179 + uint32_t car2; /* 0x2B4 carry register two register* */
80180 + uint32_t cam1; /* 0x2B8 carry register one mask register */
80181 + uint32_t cam2; /* 0x2BC carry register two mask register */
80182 + uint32_t reserved02c0[848];
80183 +};
80184 +
80185 +/**
80186 + * struct dtsec_mib_grp_1_counters - MIB counter overflows
80187 + *
80188 + * @tr64: Transmit and Receive 64 byte frame count. Increment for each
80189 + * good or bad frame, of any type, transmitted or received, which
80190 + * is 64 bytes in length.
80191 + * @tr127: Transmit and Receive 65 to 127 byte frame count. Increments for
80192 + * each good or bad frame of any type, transmitted or received,
80193 + * which is 65-127 bytes in length.
80194 + * @tr255: Transmit and Receive 128 to 255 byte frame count. Increments
80195 + * for each good or bad frame, of any type, transmitted or
80196 + * received, which is 128-255 bytes in length.
80197 + * @tr511: Transmit and Receive 256 to 511 byte frame count. Increments
80198 + * for each good or bad frame, of any type, transmitted or
80199 + * received, which is 256-511 bytes in length.
80200 + * @tr1k: Transmit and Receive 512 to 1023 byte frame count. Increments
80201 + * for each good or bad frame, of any type, transmitted or
80202 + * received, which is 512-1023 bytes in length.
80203 + * @trmax: Transmit and Receive 1024 to 1518 byte frame count. Increments
80204 + * for each good or bad frame, of any type, transmitted or
80205 + * received, which is 1024-1518 bytes in length.
80206 + * @rfrg: Receive fragments count. Increments for each received frame
80207 + * which is less than 64 bytes in length and contains an invalid
80208 + * FCS. This includes integral and non-integral lengths.
80209 + * @rjbr: Receive jabber count. Increments for received frames which
80210 + * exceed 1518 (non VLAN) or 1522 (VLAN) bytes and contain an
80211 + * invalid FCS. This includes alignment errors.
80212 + * @rdrp: Receive dropped packets count. Increments for received frames
80213 + * which are streamed to system but are later dropped due to lack
80214 + * of system resources. Does not increment for frames rejected due
80215 + * to address filtering.
80216 + * @raln: Receive alignment error count. Increments for each received
80217 + * frame from 64 to 1518 (non VLAN) or 1522 (VLAN) which contains
80218 + * an invalid FCS and is not an integral number of bytes.
80219 + * @rund: Receive undersize packet count. Increments each time a frame is
80220 + * received which is less than 64 bytes in length and contains a
80221 + * valid FCS and is otherwise well formed. This count does not
80222 + * include range length errors.
80223 + * @rovr: Receive oversize packet count. Increments each time a frame is
80224 + * received which exceeded 1518 (non VLAN) or 1522 (VLAN) and
80225 + * contains a valid FCS and is otherwise well formed.
80226 + * @rbyt: Receive byte count. Increments by the byte count of frames
80227 + * received, including those in bad packets, excluding preamble and
80228 + * SFD but including FCS bytes.
80229 + * @rpkt: Receive packet count. Increments for each received frame
80230 + * (including bad packets, all unicast, broadcast, and multicast
80231 + * packets).
80232 + * @rmca: Receive multicast packet count. Increments for each multicast
80233 + * frame with valid CRC and of lengths 64 to 1518 (non VLAN) or
80234 + * 1522 (VLAN), excluding broadcast frames. This count does not
80235 + * include range/length errors.
80236 + * @rbca: Receive broadcast packet count. Increments for each broadcast
80237 + * frame with valid CRC and of lengths 64 to 1518 (non VLAN) or
80238 + * 1522 (VLAN), excluding multicast frames. Does not include
80239 + * range/length errors.
80240 + * @tdrp: Transmit drop frame count. Increments each time a memory error
80241 + * or an underrun has occurred.
80242 + * @tncl: Transmit total collision counter. Increments by the number of
80243 + * collisions experienced during the transmission of a frame. Does
80244 + * not increment for aborted frames.
80245 + *
80246 + * The structure contains a group of dTSEC HW specific counters relating to the
80247 + * standard RMON MIB Group 1 (or Ethernet statistics) counters. This structure
80248 + * is counting only the carry events of the corresponding HW counters.
80249 + *
80250 + * tr64 to trmax notes: Frame sizes specified are considered excluding preamble
80251 + * and SFD but including FCS bytes.
80252 + */
80253 +struct dtsec_mib_grp_1_counters {
80254 + uint64_t rdrp;
80255 + uint64_t tdrp;
80256 + uint64_t rbyt;
80257 + uint64_t rpkt;
80258 + uint64_t rbca;
80259 + uint64_t rmca;
80260 + uint64_t raln;
80261 + uint64_t rund;
80262 + uint64_t rovr;
80263 + uint64_t rfrg;
80264 + uint64_t rjbr;
80265 + uint64_t tncl;
80266 + uint64_t tr64;
80267 + uint64_t tr127;
80268 + uint64_t tr255;
80269 + uint64_t tr511;
80270 + uint64_t tr1k;
80271 + uint64_t trmax;
80272 +};
80273 +
80274 +enum dtsec_stat_counters {
80275 + E_DTSEC_STAT_TR64,
80276 + E_DTSEC_STAT_TR127,
80277 + E_DTSEC_STAT_TR255,
80278 + E_DTSEC_STAT_TR511,
80279 + E_DTSEC_STAT_TR1K,
80280 + E_DTSEC_STAT_TRMAX,
80281 + E_DTSEC_STAT_TRMGV,
80282 + E_DTSEC_STAT_RBYT,
80283 + E_DTSEC_STAT_RPKT,
80284 + E_DTSEC_STAT_RMCA,
80285 + E_DTSEC_STAT_RBCA,
80286 + E_DTSEC_STAT_RXPF,
80287 + E_DTSEC_STAT_RALN,
80288 + E_DTSEC_STAT_RFLR,
80289 + E_DTSEC_STAT_RCDE,
80290 + E_DTSEC_STAT_RCSE,
80291 + E_DTSEC_STAT_RUND,
80292 + E_DTSEC_STAT_ROVR,
80293 + E_DTSEC_STAT_RFRG,
80294 + E_DTSEC_STAT_RJBR,
80295 + E_DTSEC_STAT_RDRP,
80296 + E_DTSEC_STAT_TFCS,
80297 + E_DTSEC_STAT_TBYT,
80298 + E_DTSEC_STAT_TPKT,
80299 + E_DTSEC_STAT_TMCA,
80300 + E_DTSEC_STAT_TBCA,
80301 + E_DTSEC_STAT_TXPF,
80302 + E_DTSEC_STAT_TNCL,
80303 + E_DTSEC_STAT_TDRP
80304 +};
80305 +
80306 +enum dtsec_stat_level {
80307 + /* No statistics */
80308 + E_MAC_STAT_NONE = 0,
80309 + /* Only RMON MIB group 1 (ether stats). Optimized for performance */
80310 + E_MAC_STAT_MIB_GRP1,
80311 + /* Only error counters are available. Optimized for performance */
80312 + E_MAC_STAT_PARTIAL,
80313 + /* All counters available. Not optimized for performance */
80314 + E_MAC_STAT_FULL
80315 +};
80316 +
80317 +
80318 +/**
80319 + * struct dtsec_cfg - dTSEC configuration
80320 + *
80321 + * @halfdup_on: Transmit half-duplex flow control, under software
80322 + * control for 10/100-Mbps half-duplex media. If set,
80323 + * back pressure is applied to media by raising carrier.
80324 + * @halfdup_retransmit: Number of retransmission attempts following a collision.
80325 + * If this is exceeded dTSEC aborts transmission due to
80326 + * excessive collisions. The standard specifies the
80327 + * attempt limit to be 15.
80328 + * @halfdup_coll_window:The number of bytes of the frame during which
80329 + * collisions may occur. The default value of 55
80330 + * corresponds to the frame byte at the end of the
80331 + * standard 512-bit slot time window. If collisions are
80332 + * detected after this byte, the late collision event is
80333 + * asserted and transmission of current frame is aborted.
80334 + * @rx_drop_bcast: Discard broadcast frames. If set, all broadcast frames
80335 + * will be discarded by dTSEC.
80336 + * @rx_short_frm: Accept short frames. If set, dTSEC will accept frames
80337 + * of length 14..63 bytes.
80338 + * @rx_len_check: Length check for received frames. If set, the MAC
80339 + * checks the frame's length field on receive to ensure it
80340 + * matches the actual data field length. This only works
80341 + * for received frames with length field less than 1500.
80342 + * No check is performed for larger frames.
80343 + * @tx_pad_crc: Pad and append CRC. If set, the MAC pads all
80344 + * transmitted short frames and appends a CRC to every
80345 + * frame regardless of padding requirement.
80346 + * @tx_crc: Transmission CRC enable. If set, the MAC appends a CRC
80347 + * to all frames. If frames presented to the MAC have a
80348 + * valid length and contain a valid CRC, @tx_crc should be
80349 + * reset.
80350 + * This field is ignored if @tx_pad_crc is set.
80351 + * @rx_ctrl_acc: Control frame accept. If set, this overrides 802.3
80352 + * standard control frame behavior, and all Ethernet frames
80353 + * that have an ethertype of 0x8808 are treated as normal
80354 + * Ethernet frames and passed up to the packet interface on
80355 + * a DA match. Received pause control frames are passed to
80356 + * the packet interface only if Rx flow control is also
80357 + * disabled. See fman_dtsec_handle_rx_pause() function.
80358 + * @tx_pause_time: Transmit pause time value. This pause value is used as
80359 + * part of the pause frame to be sent when a transmit pause
80360 + * frame is initiated. If set to 0 this disables
80361 + * transmission of pause frames.
80362 + * @rx_preamble: Receive preamble enable. If set, the MAC recovers the
80363 + * received Ethernet 7-byte preamble and passes it to the
80364 + * packet interface at the start of each received frame.
80365 + * This field should be reset for internal MAC loop-back
80366 + * mode.
80367 + * @tx_preamble: User defined preamble enable for transmitted frames.
80368 + * If set, a user-defined preamble must passed to the MAC
80369 + * and it is transmitted instead of the standard preamble.
80370 + * @preamble_len: Length, in bytes, of the preamble field preceding each
80371 + * Ethernet start-of-frame delimiter byte. The default
80372 + * value of 0x7 should be used in order to guarantee
80373 + * reliable operation with IEEE 802.3 compliant hardware.
80374 + * @rx_prepend: Packet alignment padding length. The specified number
80375 + * of bytes (1-31) of zero padding are inserted before the
80376 + * start of each received frame. For Ethernet, where
80377 + * optional preamble extraction is enabled, the padding
80378 + * appears before the preamble, otherwise the padding
80379 + * precedes the layer 2 header.
80380 + *
80381 + * This structure contains basic dTSEC configuration and must be passed to
80382 + * fman_dtsec_init() function. A default set of configuration values can be
80383 + * obtained by calling fman_dtsec_defconfig().
80384 + */
80385 +struct dtsec_cfg {
80386 + bool halfdup_on;
80387 + bool halfdup_alt_backoff_en;
80388 + bool halfdup_excess_defer;
80389 + bool halfdup_no_backoff;
80390 + bool halfdup_bp_no_backoff;
80391 + uint8_t halfdup_alt_backoff_val;
80392 + uint16_t halfdup_retransmit;
80393 + uint16_t halfdup_coll_window;
80394 + bool rx_drop_bcast;
80395 + bool rx_short_frm;
80396 + bool rx_len_check;
80397 + bool tx_pad_crc;
80398 + bool tx_crc;
80399 + bool rx_ctrl_acc;
80400 + unsigned short tx_pause_time;
80401 + unsigned short tbipa;
80402 + bool ptp_tsu_en;
80403 + bool ptp_exception_en;
80404 + bool rx_preamble;
80405 + bool tx_preamble;
80406 + unsigned char preamble_len;
80407 + unsigned char rx_prepend;
80408 + bool loopback;
80409 + bool rx_time_stamp_en;
80410 + bool tx_time_stamp_en;
80411 + bool rx_flow;
80412 + bool tx_flow;
80413 + bool rx_group_hash_exd;
80414 + bool rx_promisc;
80415 + uint8_t tbi_phy_addr;
80416 + uint16_t tx_pause_time_extd;
80417 + uint16_t maximum_frame;
80418 + uint32_t non_back_to_back_ipg1;
80419 + uint32_t non_back_to_back_ipg2;
80420 + uint32_t min_ifg_enforcement;
80421 + uint32_t back_to_back_ipg;
80422 + bool wake_on_lan;
80423 +};
80424 +
80425 +
80426 +/**
80427 + * fman_dtsec_defconfig() - Get default dTSEC configuration
80428 + * @cfg: pointer to configuration structure.
80429 + *
80430 + * Call this function to obtain a default set of configuration values for
80431 + * initializing dTSEC. The user can overwrite any of the values before calling
80432 + * fman_dtsec_init(), if specific configuration needs to be applied.
80433 + */
80434 +void fman_dtsec_defconfig(struct dtsec_cfg *cfg);
80435 +
80436 +/**
80437 + * fman_dtsec_init() - Init dTSEC hardware block
80438 + * @regs: Pointer to dTSEC register block
80439 + * @cfg: dTSEC configuration data
80440 + * @iface_mode: dTSEC interface mode, the type of MAC - PHY interface.
80441 + * @iface_speed: 1G or 10G
80442 + * @macaddr: MAC station address to be assigned to the device
80443 + * @fm_rev_maj: major rev number
80444 + * @fm_rev_min: minor rev number
80445 + * @exceptions_mask: initial exceptions mask
80446 + *
80447 + * This function initializes dTSEC and applies basic configuration.
80448 + *
80449 + * dTSEC initialization sequence:
80450 + * Before enabling Rx/Tx call dtsec_set_address() to set MAC address,
80451 + * fman_dtsec_adjust_link() to configure interface speed and duplex and finally
80452 + * dtsec_enable_tx()/dtsec_enable_rx() to start transmission and reception.
80453 + *
80454 + * Returns: 0 if successful, an error code otherwise.
80455 + */
80456 +int fman_dtsec_init(struct dtsec_regs *regs, struct dtsec_cfg *cfg,
80457 + enum enet_interface iface_mode,
80458 + enum enet_speed iface_speed,
80459 + uint8_t *macaddr, uint8_t fm_rev_maj,
80460 + uint8_t fm_rev_min,
80461 + uint32_t exception_mask);
80462 +
80463 +/**
80464 + * fman_dtsec_enable() - Enable dTSEC Tx and Tx
80465 + * @regs: Pointer to dTSEC register block
80466 + * @apply_rx: enable rx side
80467 + * @apply_tx: enable tx side
80468 + *
80469 + * This function resets Tx and Rx graceful stop bit and enables dTSEC Tx and Rx.
80470 + */
80471 +void fman_dtsec_enable(struct dtsec_regs *regs, bool apply_rx, bool apply_tx);
80472 +
80473 +/**
80474 + * fman_dtsec_disable() - Disable dTSEC Tx and Rx
80475 + * @regs: Pointer to dTSEC register block
80476 + * @apply_rx: disable rx side
80477 + * @apply_tx: disable tx side
80478 + *
80479 + * This function disables Tx and Rx in dTSEC.
80480 + */
80481 +void fman_dtsec_disable(struct dtsec_regs *regs, bool apply_rx, bool apply_tx);
80482 +
80483 +/**
80484 + * fman_dtsec_get_revision() - Get dTSEC hardware revision
80485 + * @regs: Pointer to dTSEC register block
80486 + *
80487 + * Returns dtsec_id content
80488 + *
80489 + * Call this function to obtain the dTSEC hardware version.
80490 + */
80491 +uint32_t fman_dtsec_get_revision(struct dtsec_regs *regs);
80492 +
80493 +/**
80494 + * fman_dtsec_set_mac_address() - Set MAC station address
80495 + * @regs: Pointer to dTSEC register block
80496 + * @macaddr: MAC address array
80497 + *
80498 + * This function sets MAC station address. To enable unicast reception call
80499 + * this after fman_dtsec_init(). While promiscuous mode is disabled dTSEC will
80500 + * match the destination address of received unicast frames against this
80501 + * address.
80502 + */
80503 +void fman_dtsec_set_mac_address(struct dtsec_regs *regs, uint8_t *macaddr);
80504 +
80505 +/**
80506 + * fman_dtsec_get_mac_address() - Query MAC station address
80507 + * @regs: Pointer to dTSEC register block
80508 + * @macaddr: MAC address array
80509 + */
80510 +void fman_dtsec_get_mac_address(struct dtsec_regs *regs, uint8_t *macaddr);
80511 +
80512 +/**
80513 + * fman_dtsec_set_uc_promisc() - Sets unicast promiscuous mode
80514 + * @regs: Pointer to dTSEC register block
80515 + * @enable: Enable unicast promiscuous mode
80516 + *
80517 + * Use this function to enable/disable dTSEC L2 address filtering. If the
80518 + * address filtering is disabled all unicast packets are accepted.
80519 + * To set dTSEC in promiscuous mode call both fman_dtsec_set_uc_promisc() and
80520 + * fman_dtsec_set_mc_promisc() to disable filtering for both unicast and
80521 + * multicast addresses.
80522 + */
80523 +void fman_dtsec_set_uc_promisc(struct dtsec_regs *regs, bool enable);
80524 +
80525 +/**
80526 + * fman_dtsec_set_wol() - Enable/Disable wake on lan
80527 + * (magic packet support)
80528 + * @regs: Pointer to dTSEC register block
80529 + * @en: Enable Wake On Lan support in dTSEC
80530 + *
80531 + */
80532 +void fman_dtsec_set_wol(struct dtsec_regs *regs, bool en);
80533 +
80534 +/**
80535 + * fman_dtsec_adjust_link() - Adjust dTSEC speed/duplex settings
80536 + * @regs: Pointer to dTSEC register block
80537 + * @iface_mode: dTSEC interface mode
80538 + * @speed: Link speed
80539 + * @full_dx: True for full-duplex, false for half-duplex.
80540 + *
80541 + * This function configures the MAC to function and the desired rates. Use it
80542 + * to configure dTSEC after fman_dtsec_init() and whenever the link speed
80543 + * changes (for instance following PHY auto-negociation).
80544 + *
80545 + * Returns: 0 if successful, an error code otherwise.
80546 + */
80547 +int fman_dtsec_adjust_link(struct dtsec_regs *regs,
80548 + enum enet_interface iface_mode,
80549 + enum enet_speed speed, bool full_dx);
80550 +
80551 +/**
80552 + * fman_dtsec_set_tbi_phy_addr() - Updates TBI address field
80553 + * @regs: Pointer to dTSEC register block
80554 + * @address: Valid PHY address in the range of 1 to 31. 0 is reserved.
80555 + *
80556 + * In SGMII mode, the dTSEC's TBIPA field must contain a valid TBI PHY address
80557 + * so that the associated TBI PHY (i.e. the link) may be initialized.
80558 + *
80559 + * Returns: 0 if successful, an error code otherwise.
80560 + */
80561 +int fman_dtsec_set_tbi_phy_addr(struct dtsec_regs *regs,
80562 + uint8_t addr);
80563 +
80564 +/**
80565 + * fman_dtsec_set_max_frame_len() - Set max frame length
80566 + * @regs: Pointer to dTSEC register block
80567 + * @length: Max frame length.
80568 + *
80569 + * Sets maximum frame length for received and transmitted frames. Frames that
80570 + * exceeds this length are truncated.
80571 + */
80572 +void fman_dtsec_set_max_frame_len(struct dtsec_regs *regs, uint16_t length);
80573 +
80574 +/**
80575 + * fman_dtsec_get_max_frame_len() - Query max frame length
80576 + * @regs: Pointer to dTSEC register block
80577 + *
80578 + * Returns: the current value of the maximum frame length.
80579 + */
80580 +uint16_t fman_dtsec_get_max_frame_len(struct dtsec_regs *regs);
80581 +
80582 +/**
80583 + * fman_dtsec_handle_rx_pause() - Configure pause frame handling
80584 + * @regs: Pointer to dTSEC register block
80585 + * @en: Enable pause frame handling in dTSEC
80586 + *
80587 + * If enabled, dTSEC will handle pause frames internally. This must be disabled
80588 + * if dTSEC is set in half-duplex mode.
80589 + * If pause frame handling is disabled and &dtsec_cfg.rx_ctrl_acc is set, pause
80590 + * frames will be transferred to the packet interface just like regular Ethernet
80591 + * frames.
80592 + */
80593 +void fman_dtsec_handle_rx_pause(struct dtsec_regs *regs, bool en);
80594 +
80595 +/**
80596 + * fman_dtsec_set_tx_pause_frames() - Configure Tx pause time
80597 + * @regs: Pointer to dTSEC register block
80598 + * @time: Time value included in pause frames
80599 + *
80600 + * Call this function to set the time value used in transmitted pause frames.
80601 + * If time is 0, transmission of pause frames is disabled
80602 + */
80603 +void fman_dtsec_set_tx_pause_frames(struct dtsec_regs *regs, uint16_t time);
80604 +
80605 +/**
80606 + * fman_dtsec_ack_event() - Acknowledge handled events
80607 + * @regs: Pointer to dTSEC register block
80608 + * @ev_mask: Events to acknowledge
80609 + *
80610 + * After handling events signaled by dTSEC in either polling or interrupt mode,
80611 + * call this function to reset the associated status bits in dTSEC event
80612 + * register.
80613 + */
80614 +void fman_dtsec_ack_event(struct dtsec_regs *regs, uint32_t ev_mask);
80615 +
80616 +/**
80617 + * fman_dtsec_get_event() - Returns currently asserted events
80618 + * @regs: Pointer to dTSEC register block
80619 + * @ev_mask: Mask of relevant events
80620 + *
80621 + * Call this function to obtain a bit-mask of events that are currently asserted
80622 + * in dTSEC, taken from IEVENT register.
80623 + *
80624 + * Returns: a bit-mask of events asserted in dTSEC.
80625 + */
80626 +uint32_t fman_dtsec_get_event(struct dtsec_regs *regs, uint32_t ev_mask);
80627 +
80628 +/**
80629 + * fman_dtsec_get_interrupt_mask() - Returns a bit-mask of enabled interrupts
80630 + * @regs: Pointer to dTSEC register block
80631 + *
80632 + * Call this function to obtain a bit-mask of enabled interrupts
80633 + * in dTSEC, taken from IMASK register.
80634 + *
80635 + * Returns: a bit-mask of enabled interrupts in dTSEC.
80636 + */
80637 +uint32_t fman_dtsec_get_interrupt_mask(struct dtsec_regs *regs);
80638 +
80639 +void fman_dtsec_clear_addr_in_paddr(struct dtsec_regs *regs,
80640 + uint8_t paddr_num);
80641 +
80642 +void fman_dtsec_add_addr_in_paddr(struct dtsec_regs *regs,
80643 + uint64_t addr,
80644 + uint8_t paddr_num);
80645 +
80646 +void fman_dtsec_enable_tmr_interrupt (struct dtsec_regs *regs);
80647 +
80648 +void fman_dtsec_disable_tmr_interrupt(struct dtsec_regs *regs);
80649 +
80650 +/**
80651 + * fman_dtsec_disable_interrupt() - Disables interrupts for the specified events
80652 + * @regs: Pointer to dTSEC register block
80653 + * @ev_mask: Mask of relevant events
80654 + *
80655 + * Call this function to disable interrupts in dTSEC for the specified events.
80656 + * To enable interrupts use fman_dtsec_enable_interrupt().
80657 + */
80658 +void fman_dtsec_disable_interrupt(struct dtsec_regs *regs, uint32_t ev_mask);
80659 +
80660 +/**
80661 + * fman_dtsec_enable_interrupt() - Enable interrupts for the specified events
80662 + * @regs: Pointer to dTSEC register block
80663 + * @ev_mask: Mask of relevant events
80664 + *
80665 + * Call this function to enable interrupts in dTSEC for the specified events.
80666 + * To disable interrupts use fman_dtsec_disable_interrupt().
80667 + */
80668 +void fman_dtsec_enable_interrupt(struct dtsec_regs *regs, uint32_t ev_mask);
80669 +
80670 +/**
80671 + * fman_dtsec_set_ts() - Enables dTSEC timestamps
80672 + * @regs: Pointer to dTSEC register block
80673 + * @en: true to enable timestamps, false to disable them
80674 + *
80675 + * Call this function to enable/disable dTSEC timestamps. This affects both
80676 + * Tx and Rx.
80677 + */
80678 +void fman_dtsec_set_ts(struct dtsec_regs *regs, bool en);
80679 +
80680 +/**
80681 + * fman_dtsec_set_bucket() - Enables/disables a filter bucket
80682 + * @regs: Pointer to dTSEC register block
80683 + * @bucket: Bucket index
80684 + * @enable: true/false to enable/disable this bucket
80685 + *
80686 + * This function enables or disables the specified bucket. Enabling a bucket
80687 + * associated with an address configures dTSEC to accept received packets
80688 + * with that destination address.
80689 + * Multiple addresses may be associated with the same bucket. Disabling a
80690 + * bucket will affect all addresses associated with that bucket. A bucket that
80691 + * is enabled requires further filtering and verification in the upper layers
80692 + *
80693 + */
80694 +void fman_dtsec_set_bucket(struct dtsec_regs *regs, int bucket, bool enable);
80695 +
80696 +/**
80697 + * dtsec_set_hash_table() - insert a crc code into thr filter table
80698 + * @regs: Pointer to dTSEC register block
80699 + * @crc: crc to insert
80700 + * @mcast: true is this is a multicast address
80701 + * @ghtx: true if we are in ghtx mode
80702 + *
80703 + * This function inserts a crc code into the filter table.
80704 + */
80705 +void fman_dtsec_set_hash_table(struct dtsec_regs *regs, uint32_t crc,
80706 + bool mcast, bool ghtx);
80707 +
80708 +/**
80709 + * fman_dtsec_reset_filter_table() - Resets the address filtering table
80710 + * @regs: Pointer to dTSEC register block
80711 + * @mcast: Reset multicast entries
80712 + * @ucast: Reset unicast entries
80713 + *
80714 + * Resets all entries in L2 address filter table. After calling this function
80715 + * all buckets enabled using fman_dtsec_set_bucket() will be disabled.
80716 + * If dtsec_init_filter_table() was called with @unicast_hash set to false,
80717 + * @ucast argument is ignored.
80718 + * This does not affect the primary nor the 15 additional addresses configured
80719 + * using dtsec_set_address() or dtsec_set_match_address().
80720 + */
80721 +void fman_dtsec_reset_filter_table(struct dtsec_regs *regs, bool mcast,
80722 + bool ucast);
80723 +
80724 +/**
80725 + * fman_dtsec_set_mc_promisc() - Set multicast promiscuous mode
80726 + * @regs: Pointer to dTSEC register block
80727 + * @enable: Enable multicast promiscuous mode
80728 + *
80729 + * Call this to enable/disable L2 address filtering for multicast packets.
80730 + */
80731 +void fman_dtsec_set_mc_promisc(struct dtsec_regs *regs, bool enable);
80732 +
80733 +/* statistics APIs */
80734 +
80735 +/**
80736 + * fman_dtsec_set_stat_level() - Enable a group of MIB statistics counters
80737 + * @regs: Pointer to dTSEC register block
80738 + * @level: Specifies a certain group of dTSEC MIB HW counters or _all_,
80739 + * to specify all the existing counters.
80740 + * If set to _none_, it disables all the counters.
80741 + *
80742 + * Enables the MIB statistics hw counters and sets up the carry interrupt
80743 + * masks for the counters corresponding to the @level input parameter.
80744 + *
80745 + * Returns: error if invalid @level value given.
80746 + */
80747 +int fman_dtsec_set_stat_level(struct dtsec_regs *regs,
80748 + enum dtsec_stat_level level);
80749 +
80750 +/**
80751 + * fman_dtsec_reset_stat() - Completely resets all dTSEC HW counters
80752 + * @regs: Pointer to dTSEC register block
80753 + */
80754 +void fman_dtsec_reset_stat(struct dtsec_regs *regs);
80755 +
80756 +/**
80757 + * fman_dtsec_get_clear_carry_regs() - Read and clear carry bits (CAR1-2 registers)
80758 + * @regs: Pointer to dTSEC register block
80759 + * @car1: car1 register value
80760 + * @car2: car2 register value
80761 + *
80762 + * When set, the carry bits signal that an overflow occurred on the
80763 + * corresponding counters.
80764 + * Note that the carry bits (CAR1-2 registers) will assert the
80765 + * %DTSEC_IEVENT_MSRO interrupt if unmasked (via CAM1-2 regs).
80766 + *
80767 + * Returns: true if overflow occurred, otherwise - false
80768 + */
80769 +bool fman_dtsec_get_clear_carry_regs(struct dtsec_regs *regs,
80770 + uint32_t *car1, uint32_t *car2);
80771 +
80772 +uint32_t fman_dtsec_check_and_clear_tmr_event(struct dtsec_regs *regs);
80773 +
80774 +uint32_t fman_dtsec_get_stat_counter(struct dtsec_regs *regs,
80775 + enum dtsec_stat_counters reg_name);
80776 +
80777 +void fman_dtsec_start_tx(struct dtsec_regs *regs);
80778 +void fman_dtsec_start_rx(struct dtsec_regs *regs);
80779 +void fman_dtsec_stop_tx(struct dtsec_regs *regs);
80780 +void fman_dtsec_stop_rx(struct dtsec_regs *regs);
80781 +uint32_t fman_dtsec_get_rctrl(struct dtsec_regs *regs);
80782 +
80783 +
80784 +#endif /* __FSL_FMAN_DTSEC_H */
80785 --- /dev/null
80786 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_dtsec_mii_acc.h
80787 @@ -0,0 +1,107 @@
80788 +/*
80789 + * Copyright 2008-2013 Freescale Semiconductor Inc.
80790 + *
80791 + * Redistribution and use in source and binary forms, with or without
80792 + * modification, are permitted provided that the following conditions are met:
80793 + * * Redistributions of source code must retain the above copyright
80794 + * notice, this list of conditions and the following disclaimer.
80795 + * * Redistributions in binary form must reproduce the above copyright
80796 + * notice, this list of conditions and the following disclaimer in the
80797 + * documentation and/or other materials provided with the distribution.
80798 + * * Neither the name of Freescale Semiconductor nor the
80799 + * names of its contributors may be used to endorse or promote products
80800 + * derived from this software without specific prior written permission.
80801 + *
80802 + *
80803 + * ALTERNATIVELY, this software may be distributed under the terms of the
80804 + * GNU General Public License ("GPL") as published by the Free Software
80805 + * Foundation, either version 2 of that License or (at your option) any
80806 + * later version.
80807 + *
80808 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
80809 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
80810 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
80811 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
80812 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
80813 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
80814 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
80815 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
80816 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
80817 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
80818 + */
80819 +
80820 +#ifndef __FSL_FMAN_DTSEC_MII_ACC_H
80821 +#define __FSL_FMAN_DTSEC_MII_ACC_H
80822 +
80823 +#include "common/general.h"
80824 +
80825 +
80826 +/* MII Management Configuration Register */
80827 +#define MIIMCFG_RESET_MGMT 0x80000000
80828 +#define MIIMCFG_MGNTCLK_MASK 0x00000007
80829 +#define MIIMCFG_MGNTCLK_SHIFT 0
80830 +
80831 +/* MII Management Command Register */
80832 +#define MIIMCOM_SCAN_CYCLE 0x00000002
80833 +#define MIIMCOM_READ_CYCLE 0x00000001
80834 +
80835 +/* MII Management Address Register */
80836 +#define MIIMADD_PHY_ADDR_SHIFT 8
80837 +#define MIIMADD_PHY_ADDR_MASK 0x00001f00
80838 +
80839 +#define MIIMADD_REG_ADDR_SHIFT 0
80840 +#define MIIMADD_REG_ADDR_MASK 0x0000001f
80841 +
80842 +/* MII Management Indicator Register */
80843 +#define MIIMIND_BUSY 0x00000001
80844 +
80845 +
80846 +/* PHY Control Register */
80847 +#define PHY_CR_PHY_RESET 0x8000
80848 +#define PHY_CR_LOOPBACK 0x4000
80849 +#define PHY_CR_SPEED0 0x2000
80850 +#define PHY_CR_ANE 0x1000
80851 +#define PHY_CR_RESET_AN 0x0200
80852 +#define PHY_CR_FULLDUPLEX 0x0100
80853 +#define PHY_CR_SPEED1 0x0040
80854 +
80855 +#define PHY_TBICON_SRESET 0x8000
80856 +#define PHY_TBICON_SPEED2 0x0020
80857 +#define PHY_TBICON_CLK_SEL 0x0020
80858 +#define PHY_TBIANA_SGMII 0x4001
80859 +#define PHY_TBIANA_1000X 0x01a0
80860 +/* register map */
80861 +
80862 +/* MII Configuration Control Memory Map Registers */
80863 +struct dtsec_mii_reg {
80864 + uint32_t reserved1[72];
80865 + uint32_t miimcfg; /* MII Mgmt:configuration */
80866 + uint32_t miimcom; /* MII Mgmt:command */
80867 + uint32_t miimadd; /* MII Mgmt:address */
80868 + uint32_t miimcon; /* MII Mgmt:control 3 */
80869 + uint32_t miimstat; /* MII Mgmt:status */
80870 + uint32_t miimind; /* MII Mgmt:indicators */
80871 +};
80872 +
80873 +/* dTSEC MII API */
80874 +
80875 +/* functions to access the mii registers for phy configuration.
80876 + * this functionality may not be available for all dtsecs in the system.
80877 + * consult the reference manual for details */
80878 +void fman_dtsec_mii_reset(struct dtsec_mii_reg *regs);
80879 +/* frequency is in MHz.
80880 + * note that dtsec clock is 1/2 of fman clock */
80881 +void fman_dtsec_mii_init(struct dtsec_mii_reg *regs, uint16_t dtsec_freq);
80882 +int fman_dtsec_mii_write_reg(struct dtsec_mii_reg *regs,
80883 + uint8_t addr,
80884 + uint8_t reg,
80885 + uint16_t data,
80886 + uint16_t dtsec_freq);
80887 +
80888 +int fman_dtsec_mii_read_reg(struct dtsec_mii_reg *regs,
80889 + uint8_t addr,
80890 + uint8_t reg,
80891 + uint16_t *data,
80892 + uint16_t dtsec_freq);
80893 +
80894 +#endif /* __FSL_FMAN_DTSEC_MII_ACC_H */
80895 --- /dev/null
80896 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_kg.h
80897 @@ -0,0 +1,514 @@
80898 +/*
80899 + * Copyright 2008-2012 Freescale Semiconductor Inc.
80900 + *
80901 + * Redistribution and use in source and binary forms, with or without
80902 + * modification, are permitted provided that the following conditions are met:
80903 + * * Redistributions of source code must retain the above copyright
80904 + * notice, this list of conditions and the following disclaimer.
80905 + * * Redistributions in binary form must reproduce the above copyright
80906 + * notice, this list of conditions and the following disclaimer in the
80907 + * documentation and/or other materials provided with the distribution.
80908 + * * Neither the name of Freescale Semiconductor nor the
80909 + * names of its contributors may be used to endorse or promote products
80910 + * derived from this software without specific prior written permission.
80911 + *
80912 + *
80913 + * ALTERNATIVELY, this software may be distributed under the terms of the
80914 + * GNU General Public License ("GPL") as published by the Free Software
80915 + * Foundation, either version 2 of that License or (at your option) any
80916 + * later version.
80917 + *
80918 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
80919 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
80920 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
80921 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
80922 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
80923 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
80924 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
80925 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
80926 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
80927 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
80928 + */
80929 +
80930 +#ifndef __FSL_FMAN_KG_H
80931 +#define __FSL_FMAN_KG_H
80932 +
80933 +#include "common/general.h"
80934 +
80935 +#define FM_KG_NUM_OF_GENERIC_REGS 8 /**< Num of generic KeyGen regs */
80936 +#define FMAN_MAX_NUM_OF_HW_PORTS 64
80937 +/**< Total num of masks allowed on KG extractions */
80938 +#define FM_KG_EXTRACT_MASKS_NUM 4
80939 +#define FM_KG_NUM_CLS_PLAN_ENTR 8 /**< Num of class. plan regs */
80940 +#define FM_KG_CLS_PLAN_GRPS_NUM 32 /**< Max num of class. groups */
80941 +
80942 +struct fman_kg_regs {
80943 + uint32_t fmkg_gcr;
80944 + uint32_t res004;
80945 + uint32_t res008;
80946 + uint32_t fmkg_eer;
80947 + uint32_t fmkg_eeer;
80948 + uint32_t res014;
80949 + uint32_t res018;
80950 + uint32_t fmkg_seer;
80951 + uint32_t fmkg_seeer;
80952 + uint32_t fmkg_gsr;
80953 + uint32_t fmkg_tpc;
80954 + uint32_t fmkg_serc;
80955 + uint32_t res030[4];
80956 + uint32_t fmkg_fdor;
80957 + uint32_t fmkg_gdv0r;
80958 + uint32_t fmkg_gdv1r;
80959 + uint32_t res04c[6];
80960 + uint32_t fmkg_feer;
80961 + uint32_t res068[38];
80962 + uint32_t fmkg_indirect[63];
80963 + uint32_t fmkg_ar;
80964 +};
80965 +
80966 +struct fman_kg_scheme_regs {
80967 + uint32_t kgse_mode; /**< MODE */
80968 + uint32_t kgse_ekfc; /**< Extract Known Fields Command */
80969 + uint32_t kgse_ekdv; /**< Extract Known Default Value */
80970 + uint32_t kgse_bmch; /**< Bit Mask Command High */
80971 + uint32_t kgse_bmcl; /**< Bit Mask Command Low */
80972 + uint32_t kgse_fqb; /**< Frame Queue Base */
80973 + uint32_t kgse_hc; /**< Hash Command */
80974 + uint32_t kgse_ppc; /**< Policer Profile Command */
80975 + uint32_t kgse_gec[FM_KG_NUM_OF_GENERIC_REGS];
80976 + /**< Generic Extract Command */
80977 + uint32_t kgse_spc; /**< KeyGen Scheme Entry Statistic Packet Counter */
80978 + uint32_t kgse_dv0; /**< KeyGen Scheme Entry Default Value 0 */
80979 + uint32_t kgse_dv1; /**< KeyGen Scheme Entry Default Value 1 */
80980 + uint32_t kgse_ccbs; /**< KeyGen Scheme Entry Coarse Classification Bit*/
80981 + uint32_t kgse_mv; /**< KeyGen Scheme Entry Match vector */
80982 + uint32_t kgse_om; /**< KeyGen Scheme Entry Operation Mode bits */
80983 + uint32_t kgse_vsp; /**< KeyGen Scheme Entry Virtual Storage Profile */
80984 +};
80985 +
80986 +struct fman_kg_pe_regs{
80987 + uint32_t fmkg_pe_sp;
80988 + uint32_t fmkg_pe_cpp;
80989 +};
80990 +
80991 +struct fman_kg_cp_regs {
80992 + uint32_t kgcpe[FM_KG_NUM_CLS_PLAN_ENTR];
80993 +};
80994 +
80995 +
80996 +#define FM_KG_KGAR_GO 0x80000000
80997 +#define FM_KG_KGAR_READ 0x40000000
80998 +#define FM_KG_KGAR_WRITE 0x00000000
80999 +#define FM_KG_KGAR_SEL_SCHEME_ENTRY 0x00000000
81000 +#define FM_KG_KGAR_SCM_WSEL_UPDATE_CNT 0x00008000
81001 +
81002 +#define KG_SCH_PP_SHIFT_HIGH 0x80000000
81003 +#define KG_SCH_PP_NO_GEN 0x10000000
81004 +#define KG_SCH_PP_SHIFT_LOW 0x0000F000
81005 +#define KG_SCH_MODE_NIA_PLCR 0x40000000
81006 +#define KG_SCH_GEN_EXTRACT_TYPE 0x00008000
81007 +#define KG_SCH_BITMASK_MASK 0x000000FF
81008 +#define KG_SCH_GEN_VALID 0x80000000
81009 +#define KG_SCH_GEN_MASK 0x00FF0000
81010 +#define FM_PCD_KG_KGAR_ERR 0x20000000
81011 +#define FM_PCD_KG_KGAR_SEL_CLS_PLAN_ENTRY 0x01000000
81012 +#define FM_PCD_KG_KGAR_SEL_PORT_ENTRY 0x02000000
81013 +#define FM_PCD_KG_KGAR_SEL_PORT_WSEL_SP 0x00008000
81014 +#define FM_PCD_KG_KGAR_SEL_PORT_WSEL_CPP 0x00004000
81015 +#define FM_PCD_KG_KGAR_WSEL_MASK 0x0000FF00
81016 +#define KG_SCH_HASH_CONFIG_NO_FQID 0x80000000
81017 +#define KG_SCH_HASH_CONFIG_SYM 0x40000000
81018 +
81019 +#define FM_EX_KG_DOUBLE_ECC 0x80000000
81020 +#define FM_EX_KG_KEYSIZE_OVERFLOW 0x40000000
81021 +
81022 +/* ECC capture register */
81023 +#define KG_FMKG_SERC_CAP 0x80000000
81024 +#define KG_FMKG_SERC_CET 0x40000000
81025 +#define KG_FMKG_SERC_CNT_MSK 0x00FF0000
81026 +#define KG_FMKG_SERC_CNT_SHIFT 16
81027 +#define KG_FMKG_SERC_ADDR_MSK 0x000003FF
81028 +
81029 +/* Masks */
81030 +#define FM_KG_KGGCR_EN 0x80000000
81031 +#define KG_SCH_GEN_VALID 0x80000000
81032 +#define KG_SCH_GEN_EXTRACT_TYPE 0x00008000
81033 +#define KG_ERR_TYPE_DOUBLE 0x40000000
81034 +#define KG_ERR_ADDR_MASK 0x00000FFF
81035 +#define KG_SCH_MODE_EN 0x80000000
81036 +
81037 +/* shifts */
81038 +#define FM_KG_KGAR_NUM_SHIFT 16
81039 +#define FM_KG_PE_CPP_MASK_SHIFT 16
81040 +#define FM_KG_KGAR_WSEL_SHIFT 8
81041 +
81042 +#define FM_KG_SCH_GEN_HT_INVALID 0
81043 +
81044 +#define FM_KG_MASK_SEL_GEN_BASE 0x20
81045 +
81046 +#define KG_GET_MASK_SEL_SHIFT(shift, i) \
81047 +switch (i) \
81048 +{ \
81049 + case 0: (shift) = 26; break; \
81050 + case 1: (shift) = 20; break; \
81051 + case 2: (shift) = 10; break; \
81052 + case 3: (shift) = 4; break; \
81053 + default: (shift) = 0; \
81054 +}
81055 +
81056 +#define KG_GET_MASK_OFFSET_SHIFT(shift, i) \
81057 +switch (i) \
81058 +{ \
81059 + case 0: (shift) = 16; break; \
81060 + case 1: (shift) = 0; break; \
81061 + case 2: (shift) = 28; break; \
81062 + case 3: (shift) = 24; break; \
81063 + default: (shift) = 0; \
81064 +}
81065 +
81066 +#define KG_GET_MASK_SHIFT(shift, i) \
81067 +switch (i) \
81068 +{ \
81069 + case 0: shift = 24; break; \
81070 + case 1: shift = 16; break; \
81071 + case 2: shift = 8; break; \
81072 + case 3: shift = 0; break; \
81073 + default: shift = 0; \
81074 +}
81075 +
81076 +/* Port entry CPP register */
81077 +#define FMAN_KG_PE_CPP_MASK_SHIFT 16
81078 +
81079 +/* Scheme registers */
81080 +#define FMAN_KG_SCH_MODE_EN 0x80000000
81081 +#define FMAN_KG_SCH_MODE_NIA_PLCR 0x40000000
81082 +#define FMAN_KG_SCH_MODE_CCOBASE_SHIFT 24
81083 +
81084 +#define FMAN_KG_SCH_DEF_MAC_ADDR_SHIFT 30
81085 +#define FMAN_KG_SCH_DEF_VLAN_TCI_SHIFT 28
81086 +#define FMAN_KG_SCH_DEF_ETYPE_SHIFT 26
81087 +#define FMAN_KG_SCH_DEF_PPP_SID_SHIFT 24
81088 +#define FMAN_KG_SCH_DEF_PPP_PID_SHIFT 22
81089 +#define FMAN_KG_SCH_DEF_MPLS_SHIFT 20
81090 +#define FMAN_KG_SCH_DEF_IP_ADDR_SHIFT 18
81091 +#define FMAN_KG_SCH_DEF_PTYPE_SHIFT 16
81092 +#define FMAN_KG_SCH_DEF_IP_TOS_TC_SHIFT 14
81093 +#define FMAN_KG_SCH_DEF_IPv6_FL_SHIFT 12
81094 +#define FMAN_KG_SCH_DEF_IPSEC_SPI_SHIFT 10
81095 +#define FMAN_KG_SCH_DEF_L4_PORT_SHIFT 8
81096 +#define FMAN_KG_SCH_DEF_TCP_FLG_SHIFT 6
81097 +
81098 +#define FMAN_KG_SCH_GEN_VALID 0x80000000
81099 +#define FMAN_KG_SCH_GEN_SIZE_MAX 16
81100 +#define FMAN_KG_SCH_GEN_OR 0x00008000
81101 +
81102 +#define FMAN_KG_SCH_GEN_DEF_SHIFT 29
81103 +#define FMAN_KG_SCH_GEN_SIZE_SHIFT 24
81104 +#define FMAN_KG_SCH_GEN_MASK_SHIFT 16
81105 +#define FMAN_KG_SCH_GEN_HT_SHIFT 8
81106 +
81107 +#define FMAN_KG_SCH_HASH_HSHIFT_SHIFT 24
81108 +#define FMAN_KG_SCH_HASH_HSHIFT_MAX 0x28
81109 +#define FMAN_KG_SCH_HASH_SYM 0x40000000
81110 +#define FMAN_KG_SCH_HASH_NO_FQID_GEN 0x80000000
81111 +
81112 +#define FMAN_KG_SCH_PP_SH_SHIFT 27
81113 +#define FMAN_KG_SCH_PP_SL_SHIFT 12
81114 +#define FMAN_KG_SCH_PP_SH_MASK 0x80000000
81115 +#define FMAN_KG_SCH_PP_SL_MASK 0x0000F000
81116 +#define FMAN_KG_SCH_PP_SHIFT_MAX 0x17
81117 +#define FMAN_KG_SCH_PP_MASK_SHIFT 16
81118 +#define FMAN_KG_SCH_PP_NO_GEN 0x10000000
81119 +
81120 +enum fman_kg_gen_extract_src {
81121 + E_FMAN_KG_GEN_EXTRACT_ETH,
81122 + E_FMAN_KG_GEN_EXTRACT_ETYPE,
81123 + E_FMAN_KG_GEN_EXTRACT_SNAP,
81124 + E_FMAN_KG_GEN_EXTRACT_VLAN_TCI_1,
81125 + E_FMAN_KG_GEN_EXTRACT_VLAN_TCI_N,
81126 + E_FMAN_KG_GEN_EXTRACT_PPPoE,
81127 + E_FMAN_KG_GEN_EXTRACT_MPLS_1,
81128 + E_FMAN_KG_GEN_EXTRACT_MPLS_2,
81129 + E_FMAN_KG_GEN_EXTRACT_MPLS_3,
81130 + E_FMAN_KG_GEN_EXTRACT_MPLS_N,
81131 + E_FMAN_KG_GEN_EXTRACT_IPv4_1,
81132 + E_FMAN_KG_GEN_EXTRACT_IPv6_1,
81133 + E_FMAN_KG_GEN_EXTRACT_IPv4_2,
81134 + E_FMAN_KG_GEN_EXTRACT_IPv6_2,
81135 + E_FMAN_KG_GEN_EXTRACT_MINENCAP,
81136 + E_FMAN_KG_GEN_EXTRACT_IP_PID,
81137 + E_FMAN_KG_GEN_EXTRACT_GRE,
81138 + E_FMAN_KG_GEN_EXTRACT_TCP,
81139 + E_FMAN_KG_GEN_EXTRACT_UDP,
81140 + E_FMAN_KG_GEN_EXTRACT_SCTP,
81141 + E_FMAN_KG_GEN_EXTRACT_DCCP,
81142 + E_FMAN_KG_GEN_EXTRACT_IPSEC_AH,
81143 + E_FMAN_KG_GEN_EXTRACT_IPSEC_ESP,
81144 + E_FMAN_KG_GEN_EXTRACT_SHIM_1,
81145 + E_FMAN_KG_GEN_EXTRACT_SHIM_2,
81146 + E_FMAN_KG_GEN_EXTRACT_FROM_DFLT,
81147 + E_FMAN_KG_GEN_EXTRACT_FROM_FRAME_START,
81148 + E_FMAN_KG_GEN_EXTRACT_FROM_PARSE_RESULT,
81149 + E_FMAN_KG_GEN_EXTRACT_FROM_END_OF_PARSE,
81150 + E_FMAN_KG_GEN_EXTRACT_FROM_FQID
81151 +};
81152 +
81153 +struct fman_kg_ex_ecc_attr
81154 +{
81155 + bool valid;
81156 + bool double_ecc;
81157 + uint16_t addr;
81158 + uint8_t single_ecc_count;
81159 +};
81160 +
81161 +enum fman_kg_def_select
81162 +{
81163 + E_FMAN_KG_DEF_GLOBAL_0,
81164 + E_FMAN_KG_DEF_GLOBAL_1,
81165 + E_FMAN_KG_DEF_SCHEME_0,
81166 + E_FMAN_KG_DEF_SCHEME_1
81167 +};
81168 +
81169 +struct fman_kg_extract_def
81170 +{
81171 + enum fman_kg_def_select mac_addr;
81172 + enum fman_kg_def_select vlan_tci;
81173 + enum fman_kg_def_select etype;
81174 + enum fman_kg_def_select ppp_sid;
81175 + enum fman_kg_def_select ppp_pid;
81176 + enum fman_kg_def_select mpls;
81177 + enum fman_kg_def_select ip_addr;
81178 + enum fman_kg_def_select ptype;
81179 + enum fman_kg_def_select ip_tos_tc;
81180 + enum fman_kg_def_select ipv6_fl;
81181 + enum fman_kg_def_select ipsec_spi;
81182 + enum fman_kg_def_select l4_port;
81183 + enum fman_kg_def_select tcp_flg;
81184 +};
81185 +
81186 +enum fman_kg_gen_extract_type
81187 +{
81188 + E_FMAN_KG_HASH_EXTRACT,
81189 + E_FMAN_KG_OR_EXTRACT
81190 +};
81191 +
81192 +struct fman_kg_gen_extract_params
81193 +{
81194 + /* Hash or Or-ed extract */
81195 + enum fman_kg_gen_extract_type type;
81196 + enum fman_kg_gen_extract_src src;
81197 + bool no_validation;
81198 + /* Extraction offset from the header location specified above */
81199 + uint8_t offset;
81200 + /* Size of extraction for FMAN_KG_HASH_EXTRACT,
81201 + * hash result shift for FMAN_KG_OR_EXTRACT */
81202 + uint8_t extract;
81203 + uint8_t mask;
81204 + /* Default value to use when header specified
81205 + * by fman_kg_gen_extract_src doesn't present */
81206 + enum fman_kg_def_select def_val;
81207 +};
81208 +
81209 +struct fman_kg_extract_mask
81210 +{
81211 + /**< Indication if mask is on known field extraction or
81212 + * on general extraction; TRUE for known field */
81213 + bool is_known;
81214 + /**< One of FMAN_KG_EXTRACT_xxx defines for known fields mask and
81215 + * generic register index for generic extracts mask */
81216 + uint32_t field_or_gen_idx;
81217 + /**< Byte offset from start of the extracted data specified
81218 + * by field_or_gen_idx */
81219 + uint8_t offset;
81220 + /**< Byte mask (selected bits will be used) */
81221 + uint8_t mask;
81222 +};
81223 +
81224 +struct fman_kg_extract_params
81225 +{
81226 + /* Or-ed mask of FMAN_KG_EXTRACT_xxx defines */
81227 + uint32_t known_fields;
81228 + struct fman_kg_extract_def known_fields_def;
81229 + /* Number of entries in gen_extract */
81230 + uint8_t gen_extract_num;
81231 + struct fman_kg_gen_extract_params gen_extract[FM_KG_NUM_OF_GENERIC_REGS];
81232 + /* Number of entries in masks */
81233 + uint8_t masks_num;
81234 + struct fman_kg_extract_mask masks[FM_KG_EXTRACT_MASKS_NUM];
81235 + uint32_t def_scheme_0;
81236 + uint32_t def_scheme_1;
81237 +};
81238 +
81239 +struct fman_kg_hash_params
81240 +{
81241 + bool use_hash;
81242 + uint8_t shift_r;
81243 + uint32_t mask; /**< 24-bit mask */
81244 + bool sym; /**< Symmetric hash for src and dest pairs */
81245 +};
81246 +
81247 +struct fman_kg_pp_params
81248 +{
81249 + uint8_t base;
81250 + uint8_t shift;
81251 + uint8_t mask;
81252 + bool bypass_pp_gen;
81253 +};
81254 +
81255 +struct fman_kg_cc_params
81256 +{
81257 + uint8_t base_offset;
81258 + uint32_t qlcv_bits_sel;
81259 +};
81260 +
81261 +enum fman_pcd_engine
81262 +{
81263 + E_FMAN_PCD_INVALID = 0, /**< Invalid PCD engine indicated*/
81264 + E_FMAN_PCD_DONE, /**< No PCD Engine indicated */
81265 + E_FMAN_PCD_KG, /**< Keygen indicated */
81266 + E_FMAN_PCD_CC, /**< Coarse classification indicated */
81267 + E_FMAN_PCD_PLCR, /**< Policer indicated */
81268 + E_FMAN_PCD_PRS /**< Parser indicated */
81269 +};
81270 +
81271 +struct fman_kg_cls_plan_params
81272 +{
81273 + uint8_t entries_mask;
81274 + uint32_t mask_vector[FM_KG_NUM_CLS_PLAN_ENTR];
81275 +};
81276 +
81277 +struct fman_kg_scheme_params
81278 +{
81279 + uint32_t match_vector;
81280 + struct fman_kg_extract_params extract_params;
81281 + struct fman_kg_hash_params hash_params;
81282 + uint32_t base_fqid;
81283 + /* What we do w/features supported per FM version ?? */
81284 + bool bypass_fqid_gen;
81285 + struct fman_kg_pp_params policer_params;
81286 + struct fman_kg_cc_params cc_params;
81287 + bool update_counter;
81288 + /**< counter_value: Set scheme counter to the specified value;
81289 + * relevant only when update_counter = TRUE. */
81290 + uint32_t counter_value;
81291 + enum fman_pcd_engine next_engine;
81292 + /**< Next engine action code */
81293 + uint32_t next_engine_action;
81294 +};
81295 +
81296 +
81297 +
81298 +int fman_kg_write_ar_wait(struct fman_kg_regs *regs, uint32_t fmkg_ar);
81299 +void fman_kg_write_sp(struct fman_kg_regs *regs, uint32_t sp, bool add);
81300 +void fman_kg_write_cpp(struct fman_kg_regs *regs, uint32_t cpp);
81301 +void fman_kg_get_event(struct fman_kg_regs *regs,
81302 + uint32_t *event,
81303 + uint32_t *scheme_idx);
81304 +void fman_kg_init(struct fman_kg_regs *regs,
81305 + uint32_t exceptions,
81306 + uint32_t dflt_nia);
81307 +void fman_kg_enable_scheme_interrupts(struct fman_kg_regs *regs);
81308 +void fman_kg_enable(struct fman_kg_regs *regs);
81309 +void fman_kg_disable(struct fman_kg_regs *regs);
81310 +int fman_kg_write_bind_cls_plans(struct fman_kg_regs *regs,
81311 + uint8_t hwport_id,
81312 + uint32_t bind_cls_plans);
81313 +int fman_kg_build_bind_cls_plans(uint8_t grp_base,
81314 + uint8_t grp_mask,
81315 + uint32_t *bind_cls_plans);
81316 +int fman_kg_write_bind_schemes(struct fman_kg_regs *regs,
81317 + uint8_t hwport_id,
81318 + uint32_t schemes);
81319 +int fman_kg_write_cls_plan(struct fman_kg_regs *regs,
81320 + uint8_t grp_id,
81321 + uint8_t entries_mask,
81322 + uint8_t hwport_id,
81323 + struct fman_kg_cp_regs *cls_plan_regs);
81324 +int fman_kg_build_cls_plan(struct fman_kg_cls_plan_params *params,
81325 + struct fman_kg_cp_regs *cls_plan_regs);
81326 +uint32_t fman_kg_get_schemes_total_counter(struct fman_kg_regs *regs);
81327 +int fman_kg_set_scheme_counter(struct fman_kg_regs *regs,
81328 + uint8_t scheme_id,
81329 + uint8_t hwport_id,
81330 + uint32_t counter);
81331 +int fman_kg_get_scheme_counter(struct fman_kg_regs *regs,
81332 + uint8_t scheme_id,
81333 + uint8_t hwport_id,
81334 + uint32_t *counter);
81335 +int fman_kg_delete_scheme(struct fman_kg_regs *regs,
81336 + uint8_t scheme_id,
81337 + uint8_t hwport_id);
81338 +int fman_kg_write_scheme(struct fman_kg_regs *regs,
81339 + uint8_t scheme_id,
81340 + uint8_t hwport_id,
81341 + struct fman_kg_scheme_regs *scheme_regs,
81342 + bool update_counter);
81343 +int fman_kg_build_scheme(struct fman_kg_scheme_params *params,
81344 + struct fman_kg_scheme_regs *scheme_regs);
81345 +void fman_kg_get_capture(struct fman_kg_regs *regs,
81346 + struct fman_kg_ex_ecc_attr *ecc_attr,
81347 + bool clear);
81348 +void fman_kg_get_exception(struct fman_kg_regs *regs,
81349 + uint32_t *events,
81350 + uint32_t *scheme_ids,
81351 + bool clear);
81352 +void fman_kg_set_exception(struct fman_kg_regs *regs,
81353 + uint32_t exception,
81354 + bool enable);
81355 +void fman_kg_set_dflt_val(struct fman_kg_regs *regs,
81356 + uint8_t def_id,
81357 + uint32_t val);
81358 +void fman_kg_set_data_after_prs(struct fman_kg_regs *regs, uint8_t offset);
81359 +
81360 +
81361 +
81362 +/**************************************************************************//**
81363 + @Description NIA Description
81364 +*//***************************************************************************/
81365 +#define KG_NIA_ORDER_RESTOR 0x00800000
81366 +#define KG_NIA_ENG_FM_CTL 0x00000000
81367 +#define KG_NIA_ENG_PRS 0x00440000
81368 +#define KG_NIA_ENG_KG 0x00480000
81369 +#define KG_NIA_ENG_PLCR 0x004C0000
81370 +#define KG_NIA_ENG_BMI 0x00500000
81371 +#define KG_NIA_ENG_QMI_ENQ 0x00540000
81372 +#define KG_NIA_ENG_QMI_DEQ 0x00580000
81373 +#define KG_NIA_ENG_MASK 0x007C0000
81374 +
81375 +#define KG_NIA_AC_MASK 0x0003FFFF
81376 +
81377 +#define KG_NIA_INVALID 0xFFFFFFFF
81378 +
81379 +static __inline__ uint32_t fm_kg_build_nia(enum fman_pcd_engine next_engine,
81380 + uint32_t next_engine_action)
81381 +{
81382 + uint32_t nia;
81383 +
81384 + if (next_engine_action & ~KG_NIA_AC_MASK)
81385 + return KG_NIA_INVALID;
81386 +
81387 + switch (next_engine) {
81388 + case E_FMAN_PCD_DONE:
81389 + nia = KG_NIA_ENG_BMI | next_engine_action;
81390 + break;
81391 +
81392 + case E_FMAN_PCD_KG:
81393 + nia = KG_NIA_ENG_KG | next_engine_action;
81394 + break;
81395 +
81396 + case E_FMAN_PCD_CC:
81397 + nia = KG_NIA_ENG_FM_CTL | next_engine_action;
81398 + break;
81399 +
81400 + case E_FMAN_PCD_PLCR:
81401 + nia = KG_NIA_ENG_PLCR | next_engine_action;
81402 + break;
81403 +
81404 + default:
81405 + nia = KG_NIA_INVALID;
81406 + }
81407 +
81408 + return nia;
81409 +}
81410 +
81411 +#endif /* __FSL_FMAN_KG_H */
81412 --- /dev/null
81413 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_memac.h
81414 @@ -0,0 +1,427 @@
81415 +/*
81416 + * Copyright 2008-2012 Freescale Semiconductor Inc.
81417 + *
81418 + * Redistribution and use in source and binary forms, with or without
81419 + * modification, are permitted provided that the following conditions are met:
81420 + * * Redistributions of source code must retain the above copyright
81421 + * notice, this list of conditions and the following disclaimer.
81422 + * * Redistributions in binary form must reproduce the above copyright
81423 + * notice, this list of conditions and the following disclaimer in the
81424 + * documentation and/or other materials provided with the distribution.
81425 + * * Neither the name of Freescale Semiconductor nor the
81426 + * names of its contributors may be used to endorse or promote products
81427 + * derived from this software without specific prior written permission.
81428 + *
81429 + *
81430 + * ALTERNATIVELY, this software may be distributed under the terms of the
81431 + * GNU General Public License ("GPL") as published by the Free Software
81432 + * Foundation, either version 2 of that License or (at your option) any
81433 + * later version.
81434 + *
81435 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
81436 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
81437 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
81438 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
81439 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
81440 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
81441 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
81442 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
81443 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
81444 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81445 + */
81446 +
81447 +
81448 +#ifndef __FSL_FMAN_MEMAC_H
81449 +#define __FSL_FMAN_MEMAC_H
81450 +
81451 +#include "common/general.h"
81452 +#include "fsl_enet.h"
81453 +
81454 +
81455 +#define MEMAC_NUM_OF_PADDRS 7 /* Num of additional exact match MAC adr regs */
81456 +
81457 +/* Control and Configuration Register (COMMAND_CONFIG) */
81458 +#define CMD_CFG_MG 0x80000000 /* 00 Magic Packet detection */
81459 +#define CMD_CFG_REG_LOWP_RXETY 0x01000000 /* 07 Rx low power indication */
81460 +#define CMD_CFG_TX_LOWP_ENA 0x00800000 /* 08 Tx Low Power Idle Enable */
81461 +#define CMD_CFG_SFD_ANY 0x00200000 /* 10 Disable SFD check */
81462 +#define CMD_CFG_PFC_MODE 0x00080000 /* 12 Enable PFC */
81463 +#define CMD_CFG_NO_LEN_CHK 0x00020000 /* 14 Payload length check disable */
81464 +#define CMD_CFG_SEND_IDLE 0x00010000 /* 15 Force idle generation */
81465 +#define CMD_CFG_CNT_FRM_EN 0x00002000 /* 18 Control frame rx enable */
81466 +#define CMD_CFG_SW_RESET 0x00001000 /* 19 S/W Reset, self clearing bit */
81467 +#define CMD_CFG_TX_PAD_EN 0x00000800 /* 20 Enable Tx padding of frames */
81468 +#define CMD_CFG_LOOPBACK_EN 0x00000400 /* 21 XGMII/GMII loopback enable */
81469 +#define CMD_CFG_TX_ADDR_INS 0x00000200 /* 22 Tx source MAC addr insertion */
81470 +#define CMD_CFG_PAUSE_IGNORE 0x00000100 /* 23 Ignore Pause frame quanta */
81471 +#define CMD_CFG_PAUSE_FWD 0x00000080 /* 24 Terminate/frwd Pause frames */
81472 +#define CMD_CFG_CRC_FWD 0x00000040 /* 25 Terminate/frwd CRC of frames */
81473 +#define CMD_CFG_PAD_EN 0x00000020 /* 26 Frame padding removal */
81474 +#define CMD_CFG_PROMIS_EN 0x00000010 /* 27 Promiscuous operation enable */
81475 +#define CMD_CFG_WAN_MODE 0x00000008 /* 28 WAN mode enable */
81476 +#define CMD_CFG_RX_EN 0x00000002 /* 30 MAC receive path enable */
81477 +#define CMD_CFG_TX_EN 0x00000001 /* 31 MAC transmit path enable */
81478 +
81479 +/* Transmit FIFO Sections Register (TX_FIFO_SECTIONS) */
81480 +#define TX_FIFO_SECTIONS_TX_EMPTY_MASK 0xFFFF0000
81481 +#define TX_FIFO_SECTIONS_TX_AVAIL_MASK 0x0000FFFF
81482 +#define TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_10G 0x00400000
81483 +#define TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_1G 0x00100000
81484 +#define TX_FIFO_SECTIONS_TX_EMPTY_PFC_10G 0x00360000
81485 +#define TX_FIFO_SECTIONS_TX_EMPTY_PFC_1G 0x00040000
81486 +#define TX_FIFO_SECTIONS_TX_AVAIL_10G 0x00000019
81487 +#define TX_FIFO_SECTIONS_TX_AVAIL_1G 0x00000020
81488 +#define TX_FIFO_SECTIONS_TX_AVAIL_SLOW_10G 0x00000060
81489 +
81490 +#define GET_TX_EMPTY_DEFAULT_VALUE(_val) \
81491 +_val &= ~TX_FIFO_SECTIONS_TX_EMPTY_MASK; \
81492 +((_val == TX_FIFO_SECTIONS_TX_AVAIL_10G) ? \
81493 + (_val |= TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_10G) : \
81494 + (_val |= TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_1G));
81495 +
81496 +#define GET_TX_EMPTY_PFC_VALUE(_val) \
81497 +_val &= ~TX_FIFO_SECTIONS_TX_EMPTY_MASK; \
81498 +((_val == TX_FIFO_SECTIONS_TX_AVAIL_10G) ? \
81499 + (_val |= TX_FIFO_SECTIONS_TX_EMPTY_PFC_10G) : \
81500 + (_val |= TX_FIFO_SECTIONS_TX_EMPTY_PFC_1G));
81501 +
81502 +/* Interface Mode Register (IF_MODE) */
81503 +#define IF_MODE_MASK 0x00000003 /* 30-31 Mask on i/f mode bits */
81504 +#define IF_MODE_XGMII 0x00000000 /* 30-31 XGMII (10G) interface */
81505 +#define IF_MODE_GMII 0x00000002 /* 30-31 GMII (1G) interface */
81506 +#define IF_MODE_RGMII 0x00000004
81507 +#define IF_MODE_RGMII_AUTO 0x00008000
81508 +#define IF_MODE_RGMII_1000 0x00004000 /* 10 - 1000Mbps RGMII */
81509 +#define IF_MODE_RGMII_100 0x00000000 /* 00 - 100Mbps RGMII */
81510 +#define IF_MODE_RGMII_10 0x00002000 /* 01 - 10Mbps RGMII */
81511 +#define IF_MODE_RGMII_SP_MASK 0x00006000 /* Setsp mask bits */
81512 +#define IF_MODE_RGMII_FD 0x00001000 /* Full duplex RGMII */
81513 +#define IF_MODE_HD 0x00000040 /* Half duplex operation */
81514 +
81515 +/* Hash table Control Register (HASHTABLE_CTRL) */
81516 +#define HASH_CTRL_MCAST_SHIFT 26
81517 +#define HASH_CTRL_MCAST_EN 0x00000100 /* 23 Mcast frame rx for hash */
81518 +#define HASH_CTRL_ADDR_MASK 0x0000003F /* 26-31 Hash table address code */
81519 +
81520 +#define GROUP_ADDRESS 0x0000010000000000LL /* MAC mcast indication */
81521 +#define HASH_TABLE_SIZE 64 /* Hash tbl size */
81522 +
81523 +/* Transmit Inter-Packet Gap Length Register (TX_IPG_LENGTH) */
81524 +#define MEMAC_TX_IPG_LENGTH_MASK 0x0000003F
81525 +
81526 +/* Statistics Configuration Register (STATN_CONFIG) */
81527 +#define STATS_CFG_CLR 0x00000004 /* 29 Reset all counters */
81528 +#define STATS_CFG_CLR_ON_RD 0x00000002 /* 30 Clear on read */
81529 +#define STATS_CFG_SATURATE 0x00000001 /* 31 Saturate at the maximum val */
81530 +
81531 +/* Interrupt Mask Register (IMASK) */
81532 +#define MEMAC_IMASK_MGI 0x40000000 /* 1 Magic pkt detect indication */
81533 +#define MEMAC_IMASK_TSECC_ER 0x20000000 /* 2 Timestamp FIFO ECC error evnt */
81534 +#define MEMAC_IMASK_TECC_ER 0x02000000 /* 6 Transmit frame ECC error evnt */
81535 +#define MEMAC_IMASK_RECC_ER 0x01000000 /* 7 Receive frame ECC error evnt */
81536 +
81537 +#define MEMAC_ALL_ERRS_IMASK \
81538 + ((uint32_t)(MEMAC_IMASK_TSECC_ER | \
81539 + MEMAC_IMASK_TECC_ER | \
81540 + MEMAC_IMASK_RECC_ER | \
81541 + MEMAC_IMASK_MGI))
81542 +
81543 +#define MEMAC_IEVNT_PCS 0x80000000 /* PCS (XG). Link sync (G) */
81544 +#define MEMAC_IEVNT_AN 0x40000000 /* Auto-negotiation */
81545 +#define MEMAC_IEVNT_LT 0x20000000 /* Link Training/New page */
81546 +#define MEMAC_IEVNT_MGI 0x00004000 /* Magic pkt detection */
81547 +#define MEMAC_IEVNT_TS_ECC_ER 0x00002000 /* Timestamp FIFO ECC error */
81548 +#define MEMAC_IEVNT_RX_FIFO_OVFL 0x00001000 /* Rx FIFO overflow */
81549 +#define MEMAC_IEVNT_TX_FIFO_UNFL 0x00000800 /* Tx FIFO underflow */
81550 +#define MEMAC_IEVNT_TX_FIFO_OVFL 0x00000400 /* Tx FIFO overflow */
81551 +#define MEMAC_IEVNT_TX_ECC_ER 0x00000200 /* Tx frame ECC error */
81552 +#define MEMAC_IEVNT_RX_ECC_ER 0x00000100 /* Rx frame ECC error */
81553 +#define MEMAC_IEVNT_LI_FAULT 0x00000080 /* Link Interruption flt */
81554 +#define MEMAC_IEVNT_RX_EMPTY 0x00000040 /* Rx FIFO empty */
81555 +#define MEMAC_IEVNT_TX_EMPTY 0x00000020 /* Tx FIFO empty */
81556 +#define MEMAC_IEVNT_RX_LOWP 0x00000010 /* Low Power Idle */
81557 +#define MEMAC_IEVNT_PHY_LOS 0x00000004 /* Phy loss of signal */
81558 +#define MEMAC_IEVNT_REM_FAULT 0x00000002 /* Remote fault (XGMII) */
81559 +#define MEMAC_IEVNT_LOC_FAULT 0x00000001 /* Local fault (XGMII) */
81560 +
81561 +enum memac_counters {
81562 + E_MEMAC_COUNTER_R64,
81563 + E_MEMAC_COUNTER_R127,
81564 + E_MEMAC_COUNTER_R255,
81565 + E_MEMAC_COUNTER_R511,
81566 + E_MEMAC_COUNTER_R1023,
81567 + E_MEMAC_COUNTER_R1518,
81568 + E_MEMAC_COUNTER_R1519X,
81569 + E_MEMAC_COUNTER_RFRG,
81570 + E_MEMAC_COUNTER_RJBR,
81571 + E_MEMAC_COUNTER_RDRP,
81572 + E_MEMAC_COUNTER_RALN,
81573 + E_MEMAC_COUNTER_TUND,
81574 + E_MEMAC_COUNTER_ROVR,
81575 + E_MEMAC_COUNTER_RXPF,
81576 + E_MEMAC_COUNTER_TXPF,
81577 + E_MEMAC_COUNTER_ROCT,
81578 + E_MEMAC_COUNTER_RMCA,
81579 + E_MEMAC_COUNTER_RBCA,
81580 + E_MEMAC_COUNTER_RPKT,
81581 + E_MEMAC_COUNTER_RUCA,
81582 + E_MEMAC_COUNTER_RERR,
81583 + E_MEMAC_COUNTER_TOCT,
81584 + E_MEMAC_COUNTER_TMCA,
81585 + E_MEMAC_COUNTER_TBCA,
81586 + E_MEMAC_COUNTER_TUCA,
81587 + E_MEMAC_COUNTER_TERR
81588 +};
81589 +
81590 +#define DEFAULT_PAUSE_QUANTA 0xf000
81591 +#define DEFAULT_FRAME_LENGTH 0x600
81592 +#define DEFAULT_TX_IPG_LENGTH 12
81593 +
81594 +/*
81595 + * memory map
81596 + */
81597 +
81598 +struct mac_addr {
81599 + uint32_t mac_addr_l; /* Lower 32 bits of 48-bit MAC address */
81600 + uint32_t mac_addr_u; /* Upper 16 bits of 48-bit MAC address */
81601 +};
81602 +
81603 +struct memac_regs {
81604 + /* General Control and Status */
81605 + uint32_t res0000[2];
81606 + uint32_t command_config; /* 0x008 Ctrl and cfg */
81607 + struct mac_addr mac_addr0; /* 0x00C-0x010 MAC_ADDR_0...1 */
81608 + uint32_t maxfrm; /* 0x014 Max frame length */
81609 + uint32_t res0018[1];
81610 + uint32_t rx_fifo_sections; /* Receive FIFO configuration reg */
81611 + uint32_t tx_fifo_sections; /* Transmit FIFO configuration reg */
81612 + uint32_t res0024[2];
81613 + uint32_t hashtable_ctrl; /* 0x02C Hash table control */
81614 + uint32_t res0030[4];
81615 + uint32_t ievent; /* 0x040 Interrupt event */
81616 + uint32_t tx_ipg_length; /* 0x044 Transmitter inter-packet-gap */
81617 + uint32_t res0048;
81618 + uint32_t imask; /* 0x04C Interrupt mask */
81619 + uint32_t res0050;
81620 + uint32_t pause_quanta[4]; /* 0x054 Pause quanta */
81621 + uint32_t pause_thresh[4]; /* 0x064 Pause quanta threshold */
81622 + uint32_t rx_pause_status; /* 0x074 Receive pause status */
81623 + uint32_t res0078[2];
81624 + struct mac_addr mac_addr[MEMAC_NUM_OF_PADDRS]; /* 0x80-0x0B4 mac padr */
81625 + uint32_t lpwake_timer; /* 0x0B8 Low Power Wakeup Timer */
81626 + uint32_t sleep_timer; /* 0x0BC Transmit EEE Low Power Timer */
81627 + uint32_t res00c0[8];
81628 + uint32_t statn_config; /* 0x0E0 Statistics configuration */
81629 + uint32_t res00e4[7];
81630 + /* Rx Statistics Counter */
81631 + uint32_t reoct_l;
81632 + uint32_t reoct_u;
81633 + uint32_t roct_l;
81634 + uint32_t roct_u;
81635 + uint32_t raln_l;
81636 + uint32_t raln_u;
81637 + uint32_t rxpf_l;
81638 + uint32_t rxpf_u;
81639 + uint32_t rfrm_l;
81640 + uint32_t rfrm_u;
81641 + uint32_t rfcs_l;
81642 + uint32_t rfcs_u;
81643 + uint32_t rvlan_l;
81644 + uint32_t rvlan_u;
81645 + uint32_t rerr_l;
81646 + uint32_t rerr_u;
81647 + uint32_t ruca_l;
81648 + uint32_t ruca_u;
81649 + uint32_t rmca_l;
81650 + uint32_t rmca_u;
81651 + uint32_t rbca_l;
81652 + uint32_t rbca_u;
81653 + uint32_t rdrp_l;
81654 + uint32_t rdrp_u;
81655 + uint32_t rpkt_l;
81656 + uint32_t rpkt_u;
81657 + uint32_t rund_l;
81658 + uint32_t rund_u;
81659 + uint32_t r64_l;
81660 + uint32_t r64_u;
81661 + uint32_t r127_l;
81662 + uint32_t r127_u;
81663 + uint32_t r255_l;
81664 + uint32_t r255_u;
81665 + uint32_t r511_l;
81666 + uint32_t r511_u;
81667 + uint32_t r1023_l;
81668 + uint32_t r1023_u;
81669 + uint32_t r1518_l;
81670 + uint32_t r1518_u;
81671 + uint32_t r1519x_l;
81672 + uint32_t r1519x_u;
81673 + uint32_t rovr_l;
81674 + uint32_t rovr_u;
81675 + uint32_t rjbr_l;
81676 + uint32_t rjbr_u;
81677 + uint32_t rfrg_l;
81678 + uint32_t rfrg_u;
81679 + uint32_t rcnp_l;
81680 + uint32_t rcnp_u;
81681 + uint32_t rdrntp_l;
81682 + uint32_t rdrntp_u;
81683 + uint32_t res01d0[12];
81684 + /* Tx Statistics Counter */
81685 + uint32_t teoct_l;
81686 + uint32_t teoct_u;
81687 + uint32_t toct_l;
81688 + uint32_t toct_u;
81689 + uint32_t res0210[2];
81690 + uint32_t txpf_l;
81691 + uint32_t txpf_u;
81692 + uint32_t tfrm_l;
81693 + uint32_t tfrm_u;
81694 + uint32_t tfcs_l;
81695 + uint32_t tfcs_u;
81696 + uint32_t tvlan_l;
81697 + uint32_t tvlan_u;
81698 + uint32_t terr_l;
81699 + uint32_t terr_u;
81700 + uint32_t tuca_l;
81701 + uint32_t tuca_u;
81702 + uint32_t tmca_l;
81703 + uint32_t tmca_u;
81704 + uint32_t tbca_l;
81705 + uint32_t tbca_u;
81706 + uint32_t res0258[2];
81707 + uint32_t tpkt_l;
81708 + uint32_t tpkt_u;
81709 + uint32_t tund_l;
81710 + uint32_t tund_u;
81711 + uint32_t t64_l;
81712 + uint32_t t64_u;
81713 + uint32_t t127_l;
81714 + uint32_t t127_u;
81715 + uint32_t t255_l;
81716 + uint32_t t255_u;
81717 + uint32_t t511_l;
81718 + uint32_t t511_u;
81719 + uint32_t t1023_l;
81720 + uint32_t t1023_u;
81721 + uint32_t t1518_l;
81722 + uint32_t t1518_u;
81723 + uint32_t t1519x_l;
81724 + uint32_t t1519x_u;
81725 + uint32_t res02a8[6];
81726 + uint32_t tcnp_l;
81727 + uint32_t tcnp_u;
81728 + uint32_t res02c8[14];
81729 + /* Line Interface Control */
81730 + uint32_t if_mode; /* 0x300 Interface Mode Control */
81731 + uint32_t if_status; /* 0x304 Interface Status */
81732 + uint32_t res0308[14];
81733 + /* HiGig/2 */
81734 + uint32_t hg_config; /* 0x340 Control and cfg */
81735 + uint32_t res0344[3];
81736 + uint32_t hg_pause_quanta; /* 0x350 Pause quanta */
81737 + uint32_t res0354[3];
81738 + uint32_t hg_pause_thresh; /* 0x360 Pause quanta threshold */
81739 + uint32_t res0364[3];
81740 + uint32_t hgrx_pause_status; /* 0x370 Receive pause status */
81741 + uint32_t hg_fifos_status; /* 0x374 fifos status */
81742 + uint32_t rhm; /* 0x378 rx messages counter */
81743 + uint32_t thm; /* 0x37C tx messages counter */
81744 +};
81745 +
81746 +struct memac_cfg {
81747 + bool reset_on_init;
81748 + bool rx_error_discard;
81749 + bool pause_ignore;
81750 + bool pause_forward_enable;
81751 + bool no_length_check_enable;
81752 + bool cmd_frame_enable;
81753 + bool send_idle_enable;
81754 + bool wan_mode_enable;
81755 + bool promiscuous_mode_enable;
81756 + bool tx_addr_ins_enable;
81757 + bool loopback_enable;
81758 + bool lgth_check_nostdr;
81759 + bool time_stamp_enable;
81760 + bool pad_enable;
81761 + bool phy_tx_ena_on;
81762 + bool rx_sfd_any;
81763 + bool rx_pbl_fwd;
81764 + bool tx_pbl_fwd;
81765 + bool debug_mode;
81766 + bool wake_on_lan;
81767 + uint16_t max_frame_length;
81768 + uint16_t pause_quanta;
81769 + uint32_t tx_ipg_length;
81770 +};
81771 +
81772 +
81773 +/**
81774 + * fman_memac_defconfig() - Get default MEMAC configuration
81775 + * @cfg: pointer to configuration structure.
81776 + *
81777 + * Call this function to obtain a default set of configuration values for
81778 + * initializing MEMAC. The user can overwrite any of the values before calling
81779 + * fman_memac_init(), if specific configuration needs to be applied.
81780 + */
81781 +void fman_memac_defconfig(struct memac_cfg *cfg);
81782 +
81783 +int fman_memac_init(struct memac_regs *regs,
81784 + struct memac_cfg *cfg,
81785 + enum enet_interface enet_interface,
81786 + enum enet_speed enet_speed,
81787 + bool slow_10g_if,
81788 + uint32_t exceptions);
81789 +
81790 +void fman_memac_enable(struct memac_regs *regs, bool apply_rx, bool apply_tx);
81791 +
81792 +void fman_memac_disable(struct memac_regs *regs, bool apply_rx, bool apply_tx);
81793 +
81794 +void fman_memac_set_promiscuous(struct memac_regs *regs, bool val);
81795 +
81796 +void fman_memac_add_addr_in_paddr(struct memac_regs *regs,
81797 + uint8_t *adr,
81798 + uint8_t paddr_num);
81799 +
81800 +void fman_memac_clear_addr_in_paddr(struct memac_regs *regs,
81801 + uint8_t paddr_num);
81802 +
81803 +uint64_t fman_memac_get_counter(struct memac_regs *regs,
81804 + enum memac_counters reg_name);
81805 +
81806 +void fman_memac_set_tx_pause_frames(struct memac_regs *regs,
81807 + uint8_t priority, uint16_t pauseTime, uint16_t threshTime);
81808 +
81809 +uint16_t fman_memac_get_max_frame_len(struct memac_regs *regs);
81810 +
81811 +void fman_memac_set_exception(struct memac_regs *regs, uint32_t val,
81812 + bool enable);
81813 +
81814 +void fman_memac_reset_stat(struct memac_regs *regs);
81815 +
81816 +void fman_memac_reset(struct memac_regs *regs);
81817 +
81818 +void fman_memac_reset_filter_table(struct memac_regs *regs);
81819 +
81820 +void fman_memac_set_hash_table_entry(struct memac_regs *regs, uint32_t crc);
81821 +
81822 +void fman_memac_set_hash_table(struct memac_regs *regs, uint32_t val);
81823 +
81824 +void fman_memac_set_rx_ignore_pause_frames(struct memac_regs *regs,
81825 + bool enable);
81826 +
81827 +void fman_memac_set_wol(struct memac_regs *regs, bool enable);
81828 +
81829 +uint32_t fman_memac_get_event(struct memac_regs *regs, uint32_t ev_mask);
81830 +
81831 +void fman_memac_ack_event(struct memac_regs *regs, uint32_t ev_mask);
81832 +
81833 +uint32_t fman_memac_get_interrupt_mask(struct memac_regs *regs);
81834 +
81835 +void fman_memac_adjust_link(struct memac_regs *regs,
81836 + enum enet_interface iface_mode,
81837 + enum enet_speed speed, bool full_dx);
81838 +
81839 +
81840 +
81841 +#endif /*__FSL_FMAN_MEMAC_H*/
81842 --- /dev/null
81843 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_memac_mii_acc.h
81844 @@ -0,0 +1,78 @@
81845 +/*
81846 + * Copyright 2008-2013 Freescale Semiconductor Inc.
81847 + *
81848 + * Redistribution and use in source and binary forms, with or without
81849 + * modification, are permitted provided that the following conditions are met:
81850 + * * Redistributions of source code must retain the above copyright
81851 + * notice, this list of conditions and the following disclaimer.
81852 + * * Redistributions in binary form must reproduce the above copyright
81853 + * notice, this list of conditions and the following disclaimer in the
81854 + * documentation and/or other materials provided with the distribution.
81855 + * * Neither the name of Freescale Semiconductor nor the
81856 + * names of its contributors may be used to endorse or promote products
81857 + * derived from this software without specific prior written permission.
81858 + *
81859 + *
81860 + * ALTERNATIVELY, this software may be distributed under the terms of the
81861 + * GNU General Public License ("GPL") as published by the Free Software
81862 + * Foundation, either version 2 of that License or (at your option) any
81863 + * later version.
81864 + *
81865 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
81866 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
81867 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
81868 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
81869 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
81870 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
81871 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
81872 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
81873 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
81874 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81875 + */
81876 +
81877 +#ifndef __FSL_FMAN_MEMAC_MII_ACC_H
81878 +#define __FSL_FMAN_MEMAC_MII_ACC_H
81879 +
81880 +#include "common/general.h"
81881 +#include "fsl_enet.h"
81882 +/* MII Management Registers */
81883 +#define MDIO_CFG_CLK_DIV_MASK 0x0080ff80
81884 +#define MDIO_CFG_CLK_DIV_SHIFT 7
81885 +#define MDIO_CFG_HOLD_MASK 0x0000001c
81886 +#define MDIO_CFG_ENC45 0x00000040
81887 +#define MDIO_CFG_READ_ERR 0x00000002
81888 +#define MDIO_CFG_BSY 0x00000001
81889 +
81890 +#define MDIO_CTL_PHY_ADDR_SHIFT 5
81891 +#define MDIO_CTL_READ 0x00008000
81892 +
81893 +#define MDIO_DATA_BSY 0x80000000
81894 +
81895 +/*MEMAC Internal PHY Registers - SGMII */
81896 +#define PHY_SGMII_CR_PHY_RESET 0x8000
81897 +#define PHY_SGMII_CR_RESET_AN 0x0200
81898 +#define PHY_SGMII_CR_DEF_VAL 0x1140
81899 +#define PHY_SGMII_DEV_ABILITY_SGMII 0x4001
81900 +#define PHY_SGMII_DEV_ABILITY_1000X 0x01A0
81901 +#define PHY_SGMII_IF_MODE_AN 0x0002
81902 +#define PHY_SGMII_IF_MODE_SGMII 0x0001
81903 +#define PHY_SGMII_IF_MODE_1000X 0x0000
81904 +
81905 +/*----------------------------------------------------*/
81906 +/* MII Configuration Control Memory Map Registers */
81907 +/*----------------------------------------------------*/
81908 +struct memac_mii_access_mem_map {
81909 + uint32_t mdio_cfg; /* 0x030 */
81910 + uint32_t mdio_ctrl; /* 0x034 */
81911 + uint32_t mdio_data; /* 0x038 */
81912 + uint32_t mdio_addr; /* 0x03c */
81913 +};
81914 +
81915 +int fman_memac_mii_read_phy_reg(struct memac_mii_access_mem_map *mii_regs,
81916 + uint8_t phy_addr, uint8_t reg, uint16_t *data,
81917 + enum enet_speed enet_speed);
81918 +int fman_memac_mii_write_phy_reg(struct memac_mii_access_mem_map *mii_regs,
81919 + uint8_t phy_addr, uint8_t reg, uint16_t data,
81920 + enum enet_speed enet_speed);
81921 +
81922 +#endif /* __MAC_API_MEMAC_MII_ACC_H */
81923 --- /dev/null
81924 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_port.h
81925 @@ -0,0 +1,593 @@
81926 +/*
81927 + * Copyright 2008-2013 Freescale Semiconductor Inc.
81928 + *
81929 + * Redistribution and use in source and binary forms, with or without
81930 + * modification, are permitted provided that the following conditions are met:
81931 + * * Redistributions of source code must retain the above copyright
81932 + * notice, this list of conditions and the following disclaimer.
81933 + * * Redistributions in binary form must reproduce the above copyright
81934 + * notice, this list of conditions and the following disclaimer in the
81935 + * documentation and/or other materials provided with the distribution.
81936 + * * Neither the name of Freescale Semiconductor nor the
81937 + * names of its contributors may be used to endorse or promote products
81938 + * derived from this software without specific prior written permission.
81939 + *
81940 + *
81941 + * ALTERNATIVELY, this software may be distributed under the terms of the
81942 + * GNU General Public License ("GPL") as published by the Free Software
81943 + * Foundation, either version 2 of that License or (at your option) any
81944 + * later version.
81945 + *
81946 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
81947 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
81948 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
81949 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
81950 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
81951 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
81952 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
81953 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
81954 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
81955 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81956 + */
81957 +
81958 +#ifndef __FSL_FMAN_PORT_H
81959 +#define __FSL_FMAN_PORT_H
81960 +
81961 +#include "fsl_fman_sp.h"
81962 +
81963 +/** @Collection Registers bit fields */
81964 +
81965 +/** @Description BMI defines */
81966 +#define BMI_EBD_EN 0x80000000
81967 +
81968 +#define BMI_PORT_CFG_EN 0x80000000
81969 +#define BMI_PORT_CFG_FDOVR 0x02000000
81970 +#define BMI_PORT_CFG_IM 0x01000000
81971 +
81972 +#define BMI_PORT_STATUS_BSY 0x80000000
81973 +
81974 +#define BMI_DMA_ATTR_SWP_SHIFT FMAN_SP_DMA_ATTR_SWP_SHIFT
81975 +#define BMI_DMA_ATTR_IC_STASH_ON 0x10000000
81976 +#define BMI_DMA_ATTR_HDR_STASH_ON 0x04000000
81977 +#define BMI_DMA_ATTR_SG_STASH_ON 0x01000000
81978 +#define BMI_DMA_ATTR_WRITE_OPTIMIZE FMAN_SP_DMA_ATTR_WRITE_OPTIMIZE
81979 +
81980 +#define BMI_RX_FIFO_PRI_ELEVATION_SHIFT 16
81981 +#define BMI_RX_FIFO_THRESHOLD_ETHE 0x80000000
81982 +
81983 +#define BMI_TX_FRAME_END_CS_IGNORE_SHIFT 24
81984 +#define BMI_RX_FRAME_END_CS_IGNORE_SHIFT 24
81985 +#define BMI_RX_FRAME_END_CUT_SHIFT 16
81986 +
81987 +#define BMI_IC_TO_EXT_SHIFT FMAN_SP_IC_TO_EXT_SHIFT
81988 +#define BMI_IC_FROM_INT_SHIFT FMAN_SP_IC_FROM_INT_SHIFT
81989 +
81990 +#define BMI_INT_BUF_MARG_SHIFT 28
81991 +#define BMI_EXT_BUF_MARG_START_SHIFT FMAN_SP_EXT_BUF_MARG_START_SHIFT
81992 +
81993 +#define BMI_CMD_MR_LEAC 0x00200000
81994 +#define BMI_CMD_MR_SLEAC 0x00100000
81995 +#define BMI_CMD_MR_MA 0x00080000
81996 +#define BMI_CMD_MR_DEAS 0x00040000
81997 +#define BMI_CMD_RX_MR_DEF (BMI_CMD_MR_LEAC | \
81998 + BMI_CMD_MR_SLEAC | \
81999 + BMI_CMD_MR_MA | \
82000 + BMI_CMD_MR_DEAS)
82001 +#define BMI_CMD_TX_MR_DEF 0
82002 +#define BMI_CMD_OP_MR_DEF (BMI_CMD_MR_DEAS | \
82003 + BMI_CMD_MR_MA)
82004 +
82005 +#define BMI_CMD_ATTR_ORDER 0x80000000
82006 +#define BMI_CMD_ATTR_SYNC 0x02000000
82007 +#define BMI_CMD_ATTR_COLOR_SHIFT 26
82008 +
82009 +#define BMI_FIFO_PIPELINE_DEPTH_SHIFT 12
82010 +#define BMI_NEXT_ENG_FD_BITS_SHIFT 24
82011 +#define BMI_FRAME_END_CS_IGNORE_SHIFT 24
82012 +
82013 +#define BMI_COUNTERS_EN 0x80000000
82014 +
82015 +#define BMI_EXT_BUF_POOL_VALID FMAN_SP_EXT_BUF_POOL_VALID
82016 +#define BMI_EXT_BUF_POOL_EN_COUNTER FMAN_SP_EXT_BUF_POOL_EN_COUNTER
82017 +#define BMI_EXT_BUF_POOL_BACKUP FMAN_SP_EXT_BUF_POOL_BACKUP
82018 +#define BMI_EXT_BUF_POOL_ID_SHIFT 16
82019 +#define BMI_EXT_BUF_POOL_ID_MASK 0x003F0000
82020 +#define BMI_POOL_DEP_NUM_OF_POOLS_SHIFT 16
82021 +
82022 +#define BMI_TX_FIFO_MIN_FILL_SHIFT 16
82023 +#define BMI_TX_FIFO_PIPELINE_DEPTH_SHIFT 12
82024 +
82025 +#define MAX_PERFORMANCE_TASK_COMP 64
82026 +#define MAX_PERFORMANCE_RX_QUEUE_COMP 64
82027 +#define MAX_PERFORMANCE_TX_QUEUE_COMP 8
82028 +#define MAX_PERFORMANCE_DMA_COMP 16
82029 +#define MAX_PERFORMANCE_FIFO_COMP 1024
82030 +
82031 +#define BMI_PERFORMANCE_TASK_COMP_SHIFT 24
82032 +#define BMI_PERFORMANCE_QUEUE_COMP_SHIFT 16
82033 +#define BMI_PERFORMANCE_DMA_COMP_SHIFT 12
82034 +
82035 +#define BMI_RATE_LIMIT_GRAN_TX 16000 /* In Kbps */
82036 +#define BMI_RATE_LIMIT_GRAN_OP 10000 /* In frames */
82037 +#define BMI_RATE_LIMIT_MAX_RATE_IN_GRAN_UNITS 1024
82038 +#define BMI_RATE_LIMIT_MAX_BURST_SIZE 1024 /* In KBytes */
82039 +#define BMI_RATE_LIMIT_MAX_BURST_SHIFT 16
82040 +#define BMI_RATE_LIMIT_HIGH_BURST_SIZE_GRAN 0x80000000
82041 +#define BMI_RATE_LIMIT_SCALE_TSBS_SHIFT 16
82042 +#define BMI_RATE_LIMIT_SCALE_EN 0x80000000
82043 +#define BMI_SG_DISABLE FMAN_SP_SG_DISABLE
82044 +
82045 +/** @Description QMI defines */
82046 +#define QMI_PORT_CFG_EN 0x80000000
82047 +#define QMI_PORT_CFG_EN_COUNTERS 0x10000000
82048 +
82049 +#define QMI_PORT_STATUS_DEQ_TNUM_BSY 0x80000000
82050 +#define QMI_PORT_STATUS_DEQ_FD_BSY 0x20000000
82051 +
82052 +#define QMI_DEQ_CFG_PRI 0x80000000
82053 +#define QMI_DEQ_CFG_TYPE1 0x10000000
82054 +#define QMI_DEQ_CFG_TYPE2 0x20000000
82055 +#define QMI_DEQ_CFG_TYPE3 0x30000000
82056 +#define QMI_DEQ_CFG_PREFETCH_PARTIAL 0x01000000
82057 +#define QMI_DEQ_CFG_PREFETCH_FULL 0x03000000
82058 +#define QMI_DEQ_CFG_SP_MASK 0xf
82059 +#define QMI_DEQ_CFG_SP_SHIFT 20
82060 +
82061 +
82062 +/** @Description General port defines */
82063 +#define FMAN_PORT_EXT_POOLS_NUM(fm_rev_maj) \
82064 + (((fm_rev_maj) == 4) ? 4 : 8)
82065 +#define FMAN_PORT_MAX_EXT_POOLS_NUM 8
82066 +#define FMAN_PORT_OBS_EXT_POOLS_NUM 2
82067 +#define FMAN_PORT_CG_MAP_NUM 8
82068 +#define FMAN_PORT_PRS_RESULT_WORDS_NUM 8
82069 +#define FMAN_PORT_BMI_FIFO_UNITS 0x100
82070 +#define FMAN_PORT_IC_OFFSET_UNITS 0x10
82071 +
82072 +
82073 +/** @Collection FM Port Register Map */
82074 +
82075 +/** @Description BMI Rx port register map */
82076 +struct fman_port_rx_bmi_regs {
82077 + uint32_t fmbm_rcfg; /**< Rx Configuration */
82078 + uint32_t fmbm_rst; /**< Rx Status */
82079 + uint32_t fmbm_rda; /**< Rx DMA attributes*/
82080 + uint32_t fmbm_rfp; /**< Rx FIFO Parameters*/
82081 + uint32_t fmbm_rfed; /**< Rx Frame End Data*/
82082 + uint32_t fmbm_ricp; /**< Rx Internal Context Parameters*/
82083 + uint32_t fmbm_rim; /**< Rx Internal Buffer Margins*/
82084 + uint32_t fmbm_rebm; /**< Rx External Buffer Margins*/
82085 + uint32_t fmbm_rfne; /**< Rx Frame Next Engine*/
82086 + uint32_t fmbm_rfca; /**< Rx Frame Command Attributes.*/
82087 + uint32_t fmbm_rfpne; /**< Rx Frame Parser Next Engine*/
82088 + uint32_t fmbm_rpso; /**< Rx Parse Start Offset*/
82089 + uint32_t fmbm_rpp; /**< Rx Policer Profile */
82090 + uint32_t fmbm_rccb; /**< Rx Coarse Classification Base */
82091 + uint32_t fmbm_reth; /**< Rx Excessive Threshold */
82092 + uint32_t reserved003c[1]; /**< (0x03C 0x03F) */
82093 + uint32_t fmbm_rprai[FMAN_PORT_PRS_RESULT_WORDS_NUM];
82094 + /**< Rx Parse Results Array Init*/
82095 + uint32_t fmbm_rfqid; /**< Rx Frame Queue ID*/
82096 + uint32_t fmbm_refqid; /**< Rx Error Frame Queue ID*/
82097 + uint32_t fmbm_rfsdm; /**< Rx Frame Status Discard Mask*/
82098 + uint32_t fmbm_rfsem; /**< Rx Frame Status Error Mask*/
82099 + uint32_t fmbm_rfene; /**< Rx Frame Enqueue Next Engine */
82100 + uint32_t reserved0074[0x2]; /**< (0x074-0x07C) */
82101 + uint32_t fmbm_rcmne; /**< Rx Frame Continuous Mode Next Engine */
82102 + uint32_t reserved0080[0x20];/**< (0x080 0x0FF) */
82103 + uint32_t fmbm_ebmpi[FMAN_PORT_MAX_EXT_POOLS_NUM];
82104 + /**< Buffer Manager pool Information-*/
82105 + uint32_t fmbm_acnt[FMAN_PORT_MAX_EXT_POOLS_NUM];
82106 + /**< Allocate Counter-*/
82107 + uint32_t reserved0130[8];
82108 + /**< 0x130/0x140 - 0x15F reserved -*/
82109 + uint32_t fmbm_rcgm[FMAN_PORT_CG_MAP_NUM];
82110 + /**< Congestion Group Map*/
82111 + uint32_t fmbm_mpd; /**< BM Pool Depletion */
82112 + uint32_t reserved0184[0x1F]; /**< (0x184 0x1FF) */
82113 + uint32_t fmbm_rstc; /**< Rx Statistics Counters*/
82114 + uint32_t fmbm_rfrc; /**< Rx Frame Counter*/
82115 + uint32_t fmbm_rfbc; /**< Rx Bad Frames Counter*/
82116 + uint32_t fmbm_rlfc; /**< Rx Large Frames Counter*/
82117 + uint32_t fmbm_rffc; /**< Rx Filter Frames Counter*/
82118 + uint32_t fmbm_rfdc; /**< Rx Frame Discard Counter*/
82119 + uint32_t fmbm_rfldec; /**< Rx Frames List DMA Error Counter*/
82120 + uint32_t fmbm_rodc; /**< Rx Out of Buffers Discard nntr*/
82121 + uint32_t fmbm_rbdc; /**< Rx Buffers Deallocate Counter*/
82122 + uint32_t reserved0224[0x17]; /**< (0x224 0x27F) */
82123 + uint32_t fmbm_rpc; /**< Rx Performance Counters*/
82124 + uint32_t fmbm_rpcp; /**< Rx Performance Count Parameters*/
82125 + uint32_t fmbm_rccn; /**< Rx Cycle Counter*/
82126 + uint32_t fmbm_rtuc; /**< Rx Tasks Utilization Counter*/
82127 + uint32_t fmbm_rrquc; /**< Rx Receive Queue Utilization cntr*/
82128 + uint32_t fmbm_rduc; /**< Rx DMA Utilization Counter*/
82129 + uint32_t fmbm_rfuc; /**< Rx FIFO Utilization Counter*/
82130 + uint32_t fmbm_rpac; /**< Rx Pause Activation Counter*/
82131 + uint32_t reserved02a0[0x18]; /**< (0x2A0 0x2FF) */
82132 + uint32_t fmbm_rdbg; /**< Rx Debug-*/
82133 +};
82134 +
82135 +/** @Description BMI Tx port register map */
82136 +struct fman_port_tx_bmi_regs {
82137 + uint32_t fmbm_tcfg; /**< Tx Configuration */
82138 + uint32_t fmbm_tst; /**< Tx Status */
82139 + uint32_t fmbm_tda; /**< Tx DMA attributes */
82140 + uint32_t fmbm_tfp; /**< Tx FIFO Parameters */
82141 + uint32_t fmbm_tfed; /**< Tx Frame End Data */
82142 + uint32_t fmbm_ticp; /**< Tx Internal Context Parameters */
82143 + uint32_t fmbm_tfdne; /**< Tx Frame Dequeue Next Engine. */
82144 + uint32_t fmbm_tfca; /**< Tx Frame Command attribute. */
82145 + uint32_t fmbm_tcfqid; /**< Tx Confirmation Frame Queue ID. */
82146 + uint32_t fmbm_tefqid; /**< Tx Frame Error Queue ID */
82147 + uint32_t fmbm_tfene; /**< Tx Frame Enqueue Next Engine */
82148 + uint32_t fmbm_trlmts; /**< Tx Rate Limiter Scale */
82149 + uint32_t fmbm_trlmt; /**< Tx Rate Limiter */
82150 + uint32_t reserved0034[0x0e]; /**< (0x034-0x6c) */
82151 + uint32_t fmbm_tccb; /**< Tx Coarse Classification base */
82152 + uint32_t fmbm_tfne; /**< Tx Frame Next Engine */
82153 + uint32_t fmbm_tpfcm[0x02]; /**< Tx Priority based Flow Control (PFC) Mapping */
82154 + uint32_t fmbm_tcmne; /**< Tx Frame Continuous Mode Next Engine */
82155 + uint32_t reserved0080[0x60]; /**< (0x080-0x200) */
82156 + uint32_t fmbm_tstc; /**< Tx Statistics Counters */
82157 + uint32_t fmbm_tfrc; /**< Tx Frame Counter */
82158 + uint32_t fmbm_tfdc; /**< Tx Frames Discard Counter */
82159 + uint32_t fmbm_tfledc; /**< Tx Frame len error discard cntr */
82160 + uint32_t fmbm_tfufdc; /**< Tx Frame unsprt frmt discard cntr*/
82161 + uint32_t fmbm_tbdc; /**< Tx Buffers Deallocate Counter */
82162 + uint32_t reserved0218[0x1A]; /**< (0x218-0x280) */
82163 + uint32_t fmbm_tpc; /**< Tx Performance Counters*/
82164 + uint32_t fmbm_tpcp; /**< Tx Performance Count Parameters*/
82165 + uint32_t fmbm_tccn; /**< Tx Cycle Counter*/
82166 + uint32_t fmbm_ttuc; /**< Tx Tasks Utilization Counter*/
82167 + uint32_t fmbm_ttcquc; /**< Tx Transmit conf Q util Counter*/
82168 + uint32_t fmbm_tduc; /**< Tx DMA Utilization Counter*/
82169 + uint32_t fmbm_tfuc; /**< Tx FIFO Utilization Counter*/
82170 +};
82171 +
82172 +/** @Description BMI O/H port register map */
82173 +struct fman_port_oh_bmi_regs {
82174 + uint32_t fmbm_ocfg; /**< O/H Configuration */
82175 + uint32_t fmbm_ost; /**< O/H Status */
82176 + uint32_t fmbm_oda; /**< O/H DMA attributes */
82177 + uint32_t fmbm_oicp; /**< O/H Internal Context Parameters */
82178 + uint32_t fmbm_ofdne; /**< O/H Frame Dequeue Next Engine */
82179 + uint32_t fmbm_ofne; /**< O/H Frame Next Engine */
82180 + uint32_t fmbm_ofca; /**< O/H Frame Command Attributes. */
82181 + uint32_t fmbm_ofpne; /**< O/H Frame Parser Next Engine */
82182 + uint32_t fmbm_opso; /**< O/H Parse Start Offset */
82183 + uint32_t fmbm_opp; /**< O/H Policer Profile */
82184 + uint32_t fmbm_occb; /**< O/H Coarse Classification base */
82185 + uint32_t fmbm_oim; /**< O/H Internal margins*/
82186 + uint32_t fmbm_ofp; /**< O/H Fifo Parameters*/
82187 + uint32_t fmbm_ofed; /**< O/H Frame End Data*/
82188 + uint32_t reserved0030[2]; /**< (0x038 - 0x03F) */
82189 + uint32_t fmbm_oprai[FMAN_PORT_PRS_RESULT_WORDS_NUM];
82190 + /**< O/H Parse Results Array Initialization */
82191 + uint32_t fmbm_ofqid; /**< O/H Frame Queue ID */
82192 + uint32_t fmbm_oefqid; /**< O/H Error Frame Queue ID */
82193 + uint32_t fmbm_ofsdm; /**< O/H Frame Status Discard Mask */
82194 + uint32_t fmbm_ofsem; /**< O/H Frame Status Error Mask */
82195 + uint32_t fmbm_ofene; /**< O/H Frame Enqueue Next Engine */
82196 + uint32_t fmbm_orlmts; /**< O/H Rate Limiter Scale */
82197 + uint32_t fmbm_orlmt; /**< O/H Rate Limiter */
82198 + uint32_t fmbm_ocmne; /**< O/H Continuous Mode Next Engine */
82199 + uint32_t reserved0080[0x20]; /**< 0x080 - 0x0FF Reserved */
82200 + uint32_t fmbm_oebmpi[2]; /**< Buf Mngr Observed Pool Info */
82201 + uint32_t reserved0108[0x16]; /**< 0x108 - 0x15F Reserved */
82202 + uint32_t fmbm_ocgm[FMAN_PORT_CG_MAP_NUM]; /**< Observed Congestion Group Map */
82203 + uint32_t fmbm_ompd; /**< Observed BMan Pool Depletion */
82204 + uint32_t reserved0184[0x1F]; /**< 0x184 - 0x1FF Reserved */
82205 + uint32_t fmbm_ostc; /**< O/H Statistics Counters */
82206 + uint32_t fmbm_ofrc; /**< O/H Frame Counter */
82207 + uint32_t fmbm_ofdc; /**< O/H Frames Discard Counter */
82208 + uint32_t fmbm_ofledc; /**< O/H Frames Len Err Discard Cntr */
82209 + uint32_t fmbm_ofufdc; /**< O/H Frames Unsprtd Discard Cutr */
82210 + uint32_t fmbm_offc; /**< O/H Filter Frames Counter */
82211 + uint32_t fmbm_ofwdc; /**< Rx Frames WRED Discard Counter */
82212 + uint32_t fmbm_ofldec; /**< O/H Frames List DMA Error Cntr */
82213 + uint32_t fmbm_obdc; /**< O/H Buffers Deallocate Counter */
82214 + uint32_t reserved0218[0x17]; /**< (0x218 - 0x27F) */
82215 + uint32_t fmbm_opc; /**< O/H Performance Counters */
82216 + uint32_t fmbm_opcp; /**< O/H Performance Count Parameters */
82217 + uint32_t fmbm_occn; /**< O/H Cycle Counter */
82218 + uint32_t fmbm_otuc; /**< O/H Tasks Utilization Counter */
82219 + uint32_t fmbm_oduc; /**< O/H DMA Utilization Counter */
82220 + uint32_t fmbm_ofuc; /**< O/H FIFO Utilization Counter */
82221 +};
82222 +
82223 +/** @Description BMI port register map */
82224 +union fman_port_bmi_regs {
82225 + struct fman_port_rx_bmi_regs rx;
82226 + struct fman_port_tx_bmi_regs tx;
82227 + struct fman_port_oh_bmi_regs oh;
82228 +};
82229 +
82230 +/** @Description QMI port register map */
82231 +struct fman_port_qmi_regs {
82232 + uint32_t fmqm_pnc; /**< PortID n Configuration Register */
82233 + uint32_t fmqm_pns; /**< PortID n Status Register */
82234 + uint32_t fmqm_pnts; /**< PortID n Task Status Register */
82235 + uint32_t reserved00c[4]; /**< 0xn00C - 0xn01B */
82236 + uint32_t fmqm_pnen; /**< PortID n Enqueue NIA Register */
82237 + uint32_t fmqm_pnetfc; /**< PortID n Enq Total Frame Counter */
82238 + uint32_t reserved024[2]; /**< 0xn024 - 0x02B */
82239 + uint32_t fmqm_pndn; /**< PortID n Dequeue NIA Register */
82240 + uint32_t fmqm_pndc; /**< PortID n Dequeue Config Register */
82241 + uint32_t fmqm_pndtfc; /**< PortID n Dequeue tot Frame cntr */
82242 + uint32_t fmqm_pndfdc; /**< PortID n Dequeue FQID Dflt Cntr */
82243 + uint32_t fmqm_pndcc; /**< PortID n Dequeue Confirm Counter */
82244 +};
82245 +
82246 +
82247 +enum fman_port_dma_swap {
82248 + E_FMAN_PORT_DMA_NO_SWAP, /**< No swap, transfer data as is */
82249 + E_FMAN_PORT_DMA_SWAP_LE,
82250 + /**< The transferred data should be swapped in PPC Little Endian mode */
82251 + E_FMAN_PORT_DMA_SWAP_BE
82252 + /**< The transferred data should be swapped in Big Endian mode */
82253 +};
82254 +
82255 +/* Default port color */
82256 +enum fman_port_color {
82257 + E_FMAN_PORT_COLOR_GREEN, /**< Default port color is green */
82258 + E_FMAN_PORT_COLOR_YELLOW, /**< Default port color is yellow */
82259 + E_FMAN_PORT_COLOR_RED, /**< Default port color is red */
82260 + E_FMAN_PORT_COLOR_OVERRIDE /**< Ignore color */
82261 +};
82262 +
82263 +/* QMI dequeue from the SP channel - types */
82264 +enum fman_port_deq_type {
82265 + E_FMAN_PORT_DEQ_BY_PRI,
82266 + /**< Priority precedence and Intra-Class scheduling */
82267 + E_FMAN_PORT_DEQ_ACTIVE_FQ,
82268 + /**< Active FQ precedence and Intra-Class scheduling */
82269 + E_FMAN_PORT_DEQ_ACTIVE_FQ_NO_ICS
82270 + /**< Active FQ precedence and override Intra-Class scheduling */
82271 +};
82272 +
82273 +/* QMI dequeue prefetch modes */
82274 +enum fman_port_deq_prefetch {
82275 + E_FMAN_PORT_DEQ_NO_PREFETCH, /**< No prefetch mode */
82276 + E_FMAN_PORT_DEQ_PART_PREFETCH, /**< Partial prefetch mode */
82277 + E_FMAN_PORT_DEQ_FULL_PREFETCH /**< Full prefetch mode */
82278 +};
82279 +
82280 +/* Parameters for defining performance counters behavior */
82281 +struct fman_port_perf_cnt_params {
82282 + uint8_t task_val; /**< Task compare value */
82283 + uint8_t queue_val;
82284 + /**< Rx or Tx conf queue compare value (unused for O/H ports) */
82285 + uint8_t dma_val; /**< Dma compare value */
82286 + uint32_t fifo_val; /**< Fifo compare value (in bytes) */
82287 +};
82288 +
82289 +/** @Description FM Port configuration structure, used at init */
82290 +struct fman_port_cfg {
82291 + struct fman_port_perf_cnt_params perf_cnt_params;
82292 + /* BMI parameters */
82293 + enum fman_port_dma_swap dma_swap_data;
82294 + bool dma_ic_stash_on;
82295 + bool dma_header_stash_on;
82296 + bool dma_sg_stash_on;
82297 + bool dma_write_optimize;
82298 + uint16_t ic_ext_offset;
82299 + uint8_t ic_int_offset;
82300 + uint16_t ic_size;
82301 + enum fman_port_color color;
82302 + bool sync_req;
82303 + bool discard_override;
82304 + uint8_t checksum_bytes_ignore;
82305 + uint8_t rx_cut_end_bytes;
82306 + uint32_t rx_pri_elevation;
82307 + uint32_t rx_fifo_thr;
82308 + uint8_t rx_fd_bits;
82309 + uint8_t int_buf_start_margin;
82310 + uint16_t ext_buf_start_margin;
82311 + uint16_t ext_buf_end_margin;
82312 + uint32_t tx_fifo_min_level;
82313 + uint32_t tx_fifo_low_comf_level;
82314 + uint8_t tx_fifo_deq_pipeline_depth;
82315 + bool stats_counters_enable;
82316 + bool perf_counters_enable;
82317 + /* QMI parameters */
82318 + bool deq_high_pri;
82319 + enum fman_port_deq_type deq_type;
82320 + enum fman_port_deq_prefetch deq_prefetch_opt;
82321 + uint16_t deq_byte_cnt;
82322 + bool queue_counters_enable;
82323 + bool no_scatter_gather;
82324 + int errata_A006675;
82325 + int errata_A006320;
82326 + int excessive_threshold_register;
82327 + int fmbm_rebm_has_sgd;
82328 + int fmbm_tfne_has_features;
82329 + int qmi_deq_options_support;
82330 +};
82331 +
82332 +enum fman_port_type {
82333 + E_FMAN_PORT_TYPE_OP = 0,
82334 + /**< Offline parsing port, shares id-s with
82335 + * host command, so must have exclusive id-s */
82336 + E_FMAN_PORT_TYPE_RX, /**< 1G Rx port */
82337 + E_FMAN_PORT_TYPE_RX_10G, /**< 10G Rx port */
82338 + E_FMAN_PORT_TYPE_TX, /**< 1G Tx port */
82339 + E_FMAN_PORT_TYPE_TX_10G, /**< 10G Tx port */
82340 + E_FMAN_PORT_TYPE_DUMMY,
82341 + E_FMAN_PORT_TYPE_HC = E_FMAN_PORT_TYPE_DUMMY
82342 + /**< Host command port, shares id-s with
82343 + * offline parsing ports, so must have exclusive id-s */
82344 +};
82345 +
82346 +struct fman_port_params {
82347 + uint32_t discard_mask;
82348 + uint32_t err_mask;
82349 + uint32_t dflt_fqid;
82350 + uint32_t err_fqid;
82351 + uint8_t deq_sp;
82352 + bool dont_release_buf;
82353 +};
82354 +
82355 +/* Port context - used by most API functions */
82356 +struct fman_port {
82357 + enum fman_port_type type;
82358 + uint8_t fm_rev_maj;
82359 + uint8_t fm_rev_min;
82360 + union fman_port_bmi_regs *bmi_regs;
82361 + struct fman_port_qmi_regs *qmi_regs;
82362 + bool im_en;
82363 + uint8_t ext_pools_num;
82364 +};
82365 +
82366 +/** @Description External buffer pools configuration */
82367 +struct fman_port_bpools {
82368 + uint8_t count; /**< Num of pools to set up */
82369 + bool counters_enable; /**< Enable allocate counters */
82370 + uint8_t grp_bp_depleted_num;
82371 + /**< Number of depleted pools - if reached the BMI indicates
82372 + * the MAC to send a pause frame */
82373 + struct {
82374 + uint8_t bpid; /**< BM pool ID */
82375 + uint16_t size;
82376 + /**< Pool's size - must be in ascending order */
82377 + bool is_backup;
82378 + /**< If this is a backup pool */
82379 + bool grp_bp_depleted;
82380 + /**< Consider this buffer in multiple pools depletion criteria*/
82381 + bool single_bp_depleted;
82382 + /**< Consider this buffer in single pool depletion criteria */
82383 + bool pfc_priorities_en;
82384 + } bpool[FMAN_PORT_MAX_EXT_POOLS_NUM];
82385 +};
82386 +
82387 +enum fman_port_rate_limiter_scale_down {
82388 + E_FMAN_PORT_RATE_DOWN_NONE,
82389 + E_FMAN_PORT_RATE_DOWN_BY_2,
82390 + E_FMAN_PORT_RATE_DOWN_BY_4,
82391 + E_FMAN_PORT_RATE_DOWN_BY_8
82392 +};
82393 +
82394 +/* Rate limiter configuration */
82395 +struct fman_port_rate_limiter {
82396 + uint8_t count_1micro_bit;
82397 + bool high_burst_size_gran;
82398 + /**< Defines burst_size granularity for OP ports; when TRUE,
82399 + * burst_size below counts in frames, otherwise in 10^3 frames */
82400 + uint16_t burst_size;
82401 + /**< Max burst size, in KBytes for Tx port, according to
82402 + * high_burst_size_gran definition for OP port */
82403 + uint32_t rate;
82404 + /**< In Kbps for Tx port, in frames/sec for OP port */
82405 + enum fman_port_rate_limiter_scale_down rate_factor;
82406 +};
82407 +
82408 +/* BMI statistics counters */
82409 +enum fman_port_stats_counters {
82410 + E_FMAN_PORT_STATS_CNT_FRAME,
82411 + /**< Number of processed frames; valid for all ports */
82412 + E_FMAN_PORT_STATS_CNT_DISCARD,
82413 + /**< For Rx ports - frames discarded by QMAN, for Tx or O/H ports -
82414 + * frames discarded due to DMA error; valid for all ports */
82415 + E_FMAN_PORT_STATS_CNT_DEALLOC_BUF,
82416 + /**< Number of buffer deallocate operations; valid for all ports */
82417 + E_FMAN_PORT_STATS_CNT_RX_BAD_FRAME,
82418 + /**< Number of bad Rx frames, like CRC error, Rx FIFO overflow etc;
82419 + * valid for Rx ports only */
82420 + E_FMAN_PORT_STATS_CNT_RX_LARGE_FRAME,
82421 + /**< Number of Rx oversized frames, that is frames exceeding max frame
82422 + * size configured for the corresponding ETH controller;
82423 + * valid for Rx ports only */
82424 + E_FMAN_PORT_STATS_CNT_RX_OUT_OF_BUF,
82425 + /**< Frames discarded due to lack of external buffers; valid for
82426 + * Rx ports only */
82427 + E_FMAN_PORT_STATS_CNT_LEN_ERR,
82428 + /**< Frames discarded due to frame length error; valid for Tx and
82429 + * O/H ports only */
82430 + E_FMAN_PORT_STATS_CNT_UNSUPPORTED_FORMAT,
82431 + /**< Frames discarded due to unsupported FD format; valid for Tx
82432 + * and O/H ports only */
82433 + E_FMAN_PORT_STATS_CNT_FILTERED_FRAME,
82434 + /**< Number of frames filtered out by PCD module; valid for
82435 + * Rx and OP ports only */
82436 + E_FMAN_PORT_STATS_CNT_DMA_ERR,
82437 + /**< Frames rejected by QMAN that were not able to release their
82438 + * buffers due to DMA error; valid for Rx and O/H ports only */
82439 + E_FMAN_PORT_STATS_CNT_WRED_DISCARD
82440 + /**< Frames going through O/H port that were not able to to enter the
82441 + * return queue due to WRED algorithm; valid for O/H ports only */
82442 +};
82443 +
82444 +/* BMI performance counters */
82445 +enum fman_port_perf_counters {
82446 + E_FMAN_PORT_PERF_CNT_CYCLE, /**< Cycle counter */
82447 + E_FMAN_PORT_PERF_CNT_TASK_UTIL, /**< Tasks utilization counter */
82448 + E_FMAN_PORT_PERF_CNT_QUEUE_UTIL,
82449 + /**< For Rx ports - Rx queue utilization, for Tx ports - Tx conf queue
82450 + * utilization; not valid for O/H ports */
82451 + E_FMAN_PORT_PERF_CNT_DMA_UTIL, /**< DMA utilization counter */
82452 + E_FMAN_PORT_PERF_CNT_FIFO_UTIL, /**< FIFO utilization counter */
82453 + E_FMAN_PORT_PERF_CNT_RX_PAUSE
82454 + /**< Number of cycles in which Rx pause activation control is on;
82455 + * valid for Rx ports only */
82456 +};
82457 +
82458 +/* QMI counters */
82459 +enum fman_port_qmi_counters {
82460 + E_FMAN_PORT_ENQ_TOTAL, /**< EnQ tot frame cntr */
82461 + E_FMAN_PORT_DEQ_TOTAL, /**< DeQ tot frame cntr; invalid for Rx ports */
82462 + E_FMAN_PORT_DEQ_FROM_DFLT,
82463 + /**< Dequeue from default FQID counter not valid for Rx ports */
82464 + E_FMAN_PORT_DEQ_CONFIRM /**< DeQ confirm cntr invalid for Rx ports */
82465 +};
82466 +
82467 +
82468 +/** @Collection FM Port API */
82469 +void fman_port_defconfig(struct fman_port_cfg *cfg, enum fman_port_type type);
82470 +int fman_port_init(struct fman_port *port,
82471 + struct fman_port_cfg *cfg,
82472 + struct fman_port_params *params);
82473 +int fman_port_enable(struct fman_port *port);
82474 +int fman_port_disable(const struct fman_port *port);
82475 +int fman_port_set_bpools(const struct fman_port *port,
82476 + const struct fman_port_bpools *bp);
82477 +int fman_port_set_rate_limiter(struct fman_port *port,
82478 + struct fman_port_rate_limiter *rate_limiter);
82479 +int fman_port_delete_rate_limiter(struct fman_port *port);
82480 +int fman_port_set_err_mask(struct fman_port *port, uint32_t err_mask);
82481 +int fman_port_set_discard_mask(struct fman_port *port, uint32_t discard_mask);
82482 +int fman_port_modify_rx_fd_bits(struct fman_port *port,
82483 + uint8_t rx_fd_bits,
82484 + bool add);
82485 +int fman_port_set_perf_cnt_params(struct fman_port *port,
82486 + struct fman_port_perf_cnt_params *params);
82487 +int fman_port_set_stats_cnt_mode(struct fman_port *port, bool enable);
82488 +int fman_port_set_perf_cnt_mode(struct fman_port *port, bool enable);
82489 +int fman_port_set_queue_cnt_mode(struct fman_port *port, bool enable);
82490 +int fman_port_set_bpool_cnt_mode(struct fman_port *port,
82491 + uint8_t bpid,
82492 + bool enable);
82493 +uint32_t fman_port_get_stats_counter(struct fman_port *port,
82494 + enum fman_port_stats_counters counter);
82495 +void fman_port_set_stats_counter(struct fman_port *port,
82496 + enum fman_port_stats_counters counter,
82497 + uint32_t value);
82498 +uint32_t fman_port_get_perf_counter(struct fman_port *port,
82499 + enum fman_port_perf_counters counter);
82500 +void fman_port_set_perf_counter(struct fman_port *port,
82501 + enum fman_port_perf_counters counter,
82502 + uint32_t value);
82503 +uint32_t fman_port_get_qmi_counter(struct fman_port *port,
82504 + enum fman_port_qmi_counters counter);
82505 +void fman_port_set_qmi_counter(struct fman_port *port,
82506 + enum fman_port_qmi_counters counter,
82507 + uint32_t value);
82508 +uint32_t fman_port_get_bpool_counter(struct fman_port *port, uint8_t bpid);
82509 +void fman_port_set_bpool_counter(struct fman_port *port,
82510 + uint8_t bpid,
82511 + uint32_t value);
82512 +int fman_port_add_congestion_grps(struct fman_port *port,
82513 + uint32_t grps_map[FMAN_PORT_CG_MAP_NUM]);
82514 +int fman_port_remove_congestion_grps(struct fman_port *port,
82515 + uint32_t grps_map[FMAN_PORT_CG_MAP_NUM]);
82516 +
82517 +
82518 +#endif /* __FSL_FMAN_PORT_H */
82519 --- /dev/null
82520 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_prs.h
82521 @@ -0,0 +1,102 @@
82522 +/*
82523 + * Copyright 2008-2012 Freescale Semiconductor Inc.
82524 + *
82525 + * Redistribution and use in source and binary forms, with or without
82526 + * modification, are permitted provided that the following conditions are met:
82527 + * * Redistributions of source code must retain the above copyright
82528 + * notice, this list of conditions and the following disclaimer.
82529 + * * Redistributions in binary form must reproduce the above copyright
82530 + * notice, this list of conditions and the following disclaimer in the
82531 + * documentation and/or other materials provided with the distribution.
82532 + * * Neither the name of Freescale Semiconductor nor the
82533 + * names of its contributors may be used to endorse or promote products
82534 + * derived from this software without specific prior written permission.
82535 + *
82536 + *
82537 + * ALTERNATIVELY, this software may be distributed under the terms of the
82538 + * GNU General Public License ("GPL") as published by the Free Software
82539 + * Foundation, either version 2 of that License or (at your option) any
82540 + * later version.
82541 + *
82542 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
82543 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
82544 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
82545 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
82546 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
82547 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
82548 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
82549 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
82550 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
82551 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
82552 + */
82553 +
82554 +#ifndef __FSL_FMAN_PRS_H
82555 +#define __FSL_FMAN_PRS_H
82556 +
82557 +#include "common/general.h"
82558 +
82559 +#define FM_PCD_EX_PRS_DOUBLE_ECC 0x02000000
82560 +#define FM_PCD_EX_PRS_SINGLE_ECC 0x01000000
82561 +
82562 +#define FM_PCD_PRS_PPSC_ALL_PORTS 0xffff0000
82563 +#define FM_PCD_PRS_RPIMAC_EN 0x00000001
82564 +#define FM_PCD_PRS_PORT_IDLE_STS 0xffff0000
82565 +#define FM_PCD_PRS_SINGLE_ECC 0x00004000
82566 +#define FM_PCD_PRS_DOUBLE_ECC 0x00004000
82567 +#define PRS_MAX_CYCLE_LIMIT 8191
82568 +
82569 +#define DEFAULT_MAX_PRS_CYC_LIM 0
82570 +
82571 +struct fman_prs_regs {
82572 + uint32_t fmpr_rpclim;
82573 + uint32_t fmpr_rpimac;
82574 + uint32_t pmeec;
82575 + uint32_t res00c[5];
82576 + uint32_t fmpr_pevr;
82577 + uint32_t fmpr_pever;
82578 + uint32_t res028;
82579 + uint32_t fmpr_perr;
82580 + uint32_t fmpr_perer;
82581 + uint32_t res034;
82582 + uint32_t res038[10];
82583 + uint32_t fmpr_ppsc;
82584 + uint32_t res064;
82585 + uint32_t fmpr_pds;
82586 + uint32_t fmpr_l2rrs;
82587 + uint32_t fmpr_l3rrs;
82588 + uint32_t fmpr_l4rrs;
82589 + uint32_t fmpr_srrs;
82590 + uint32_t fmpr_l2rres;
82591 + uint32_t fmpr_l3rres;
82592 + uint32_t fmpr_l4rres;
82593 + uint32_t fmpr_srres;
82594 + uint32_t fmpr_spcs;
82595 + uint32_t fmpr_spscs;
82596 + uint32_t fmpr_hxscs;
82597 + uint32_t fmpr_mrcs;
82598 + uint32_t fmpr_mwcs;
82599 + uint32_t fmpr_mrscs;
82600 + uint32_t fmpr_mwscs;
82601 + uint32_t fmpr_fcscs;
82602 +};
82603 +
82604 +struct fman_prs_cfg {
82605 + uint32_t port_id_stat;
82606 + uint16_t max_prs_cyc_lim;
82607 + uint32_t prs_exceptions;
82608 +};
82609 +
82610 +uint32_t fman_prs_get_err_event(struct fman_prs_regs *regs, uint32_t ev_mask);
82611 +uint32_t fman_prs_get_err_ev_mask(struct fman_prs_regs *regs);
82612 +void fman_prs_ack_err_event(struct fman_prs_regs *regs, uint32_t event);
82613 +uint32_t fman_prs_get_expt_event(struct fman_prs_regs *regs, uint32_t ev_mask);
82614 +uint32_t fman_prs_get_expt_ev_mask(struct fman_prs_regs *regs);
82615 +void fman_prs_ack_expt_event(struct fman_prs_regs *regs, uint32_t event);
82616 +void fman_prs_defconfig(struct fman_prs_cfg *cfg);
82617 +int fman_prs_init(struct fman_prs_regs *regs, struct fman_prs_cfg *cfg);
82618 +void fman_prs_enable(struct fman_prs_regs *regs);
82619 +void fman_prs_disable(struct fman_prs_regs *regs);
82620 +int fman_prs_is_enabled(struct fman_prs_regs *regs);
82621 +void fman_prs_set_stst_port_msk(struct fman_prs_regs *regs, uint32_t pid_msk);
82622 +void fman_prs_set_stst(struct fman_prs_regs *regs, bool enable);
82623 +#endif /* __FSL_FMAN_PRS_H */
82624 --- /dev/null
82625 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_rtc.h
82626 @@ -0,0 +1,449 @@
82627 +/*
82628 + * Copyright 2013 Freescale Semiconductor Inc.
82629 + *
82630 + * Redistribution and use in source and binary forms, with or without
82631 + * modification, are permitted provided that the following conditions are met:
82632 + * * Redistributions of source code must retain the above copyright
82633 + * notice, this list of conditions and the following disclaimer.
82634 + * * Redistributions in binary form must reproduce the above copyright
82635 + * notice, this list of conditions and the following disclaimer in the
82636 + * documentation and/or other materials provided with the distribution.
82637 + * * Neither the name of Freescale Semiconductor nor the
82638 + * names of its contributors may be used to endorse or promote products
82639 + * derived from this software without specific prior written permission.
82640 + *
82641 + *
82642 + * ALTERNATIVELY, this software may be distributed under the terms of the
82643 + * GNU General Public License ("GPL") as published by the Free Software
82644 + * Foundation, either version 2 of that License or (at your option) any
82645 + * later version.
82646 + *
82647 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
82648 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
82649 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
82650 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
82651 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
82652 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
82653 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
82654 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
82655 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
82656 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
82657 + */
82658 +
82659 +#ifndef __FSL_FMAN_RTC_H
82660 +#define __FSL_FMAN_RTC_H
82661 +
82662 +#include "common/general.h"
82663 +
82664 +/* FM RTC Registers definitions */
82665 +#define FMAN_RTC_TMR_CTRL_ALMP1 0x80000000
82666 +#define FMAN_RTC_TMR_CTRL_ALMP2 0x40000000
82667 +#define FMAN_RTC_TMR_CTRL_FS 0x10000000
82668 +#define FMAN_RTC_TMR_CTRL_PP1L 0x08000000
82669 +#define FMAN_RTC_TMR_CTRL_PP2L 0x04000000
82670 +#define FMAN_RTC_TMR_CTRL_TCLK_PERIOD_MASK 0x03FF0000
82671 +#define FMAN_RTC_TMR_CTRL_FRD 0x00004000
82672 +#define FMAN_RTC_TMR_CTRL_SLV 0x00002000
82673 +#define FMAN_RTC_TMR_CTRL_ETEP1 0x00000100
82674 +#define FMAN_RTC_TMR_CTRL_COPH 0x00000080
82675 +#define FMAN_RTC_TMR_CTRL_CIPH 0x00000040
82676 +#define FMAN_RTC_TMR_CTRL_TMSR 0x00000020
82677 +#define FMAN_RTC_TMR_CTRL_DBG 0x00000010
82678 +#define FMAN_RTC_TMR_CTRL_BYP 0x00000008
82679 +#define FMAN_RTC_TMR_CTRL_TE 0x00000004
82680 +#define FMAN_RTC_TMR_CTRL_CKSEL_OSC_CLK 0x00000003
82681 +#define FMAN_RTC_TMR_CTRL_CKSEL_MAC_CLK 0x00000001
82682 +#define FMAN_RTC_TMR_CTRL_CKSEL_EXT_CLK 0x00000000
82683 +#define FMAN_RTC_TMR_CTRL_TCLK_PERIOD_SHIFT 16
82684 +
82685 +#define FMAN_RTC_TMR_TEVENT_ETS2 0x02000000
82686 +#define FMAN_RTC_TMR_TEVENT_ETS1 0x01000000
82687 +#define FMAN_RTC_TMR_TEVENT_ALM2 0x00020000
82688 +#define FMAN_RTC_TMR_TEVENT_ALM1 0x00010000
82689 +#define FMAN_RTC_TMR_TEVENT_PP1 0x00000080
82690 +#define FMAN_RTC_TMR_TEVENT_PP2 0x00000040
82691 +#define FMAN_RTC_TMR_TEVENT_PP3 0x00000020
82692 +#define FMAN_RTC_TMR_TEVENT_ALL (FMAN_RTC_TMR_TEVENT_ETS2 |\
82693 + FMAN_RTC_TMR_TEVENT_ETS1 |\
82694 + FMAN_RTC_TMR_TEVENT_ALM2 |\
82695 + FMAN_RTC_TMR_TEVENT_ALM1 |\
82696 + FMAN_RTC_TMR_TEVENT_PP1 |\
82697 + FMAN_RTC_TMR_TEVENT_PP2 |\
82698 + FMAN_RTC_TMR_TEVENT_PP3)
82699 +
82700 +#define FMAN_RTC_TMR_PRSC_OCK_MASK 0x0000FFFF
82701 +
82702 +/**************************************************************************//**
82703 + @Description FM RTC Alarm Polarity Options.
82704 +*//***************************************************************************/
82705 +enum fman_rtc_alarm_polarity {
82706 + E_FMAN_RTC_ALARM_POLARITY_ACTIVE_HIGH, /**< Active-high output polarity */
82707 + E_FMAN_RTC_ALARM_POLARITY_ACTIVE_LOW /**< Active-low output polarity */
82708 +};
82709 +
82710 +/**************************************************************************//**
82711 + @Description FM RTC Trigger Polarity Options.
82712 +*//***************************************************************************/
82713 +enum fman_rtc_trigger_polarity {
82714 + E_FMAN_RTC_TRIGGER_ON_RISING_EDGE, /**< Trigger on rising edge */
82715 + E_FMAN_RTC_TRIGGER_ON_FALLING_EDGE /**< Trigger on falling edge */
82716 +};
82717 +
82718 +/**************************************************************************//**
82719 + @Description IEEE1588 Timer Module FM RTC Optional Clock Sources.
82720 +*//***************************************************************************/
82721 +enum fman_src_clock {
82722 + E_FMAN_RTC_SOURCE_CLOCK_EXTERNAL, /**< external high precision timer
82723 + reference clock */
82724 + E_FMAN_RTC_SOURCE_CLOCK_SYSTEM, /**< MAC system clock */
82725 + E_FMAN_RTC_SOURCE_CLOCK_OSCILATOR /**< RTC clock oscilator */
82726 +};
82727 +
82728 +/* RTC default values */
82729 +#define DEFAULT_SRC_CLOCK E_FMAN_RTC_SOURCE_CLOCK_SYSTEM
82730 +#define DEFAULT_INVERT_INPUT_CLK_PHASE FALSE
82731 +#define DEFAULT_INVERT_OUTPUT_CLK_PHASE FALSE
82732 +#define DEFAULT_ALARM_POLARITY E_FMAN_RTC_ALARM_POLARITY_ACTIVE_HIGH
82733 +#define DEFAULT_TRIGGER_POLARITY E_FMAN_RTC_TRIGGER_ON_FALLING_EDGE
82734 +#define DEFAULT_PULSE_REALIGN FALSE
82735 +
82736 +#define FMAN_RTC_MAX_NUM_OF_ALARMS 3
82737 +#define FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES 4
82738 +#define FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS 3
82739 +
82740 +/**************************************************************************//**
82741 + @Description FM RTC timer alarm
82742 +*//***************************************************************************/
82743 +struct t_tmr_alarm{
82744 + uint32_t tmr_alarm_h; /**< */
82745 + uint32_t tmr_alarm_l; /**< */
82746 +};
82747 +
82748 +/**************************************************************************//**
82749 + @Description FM RTC timer Ex trigger
82750 +*//***************************************************************************/
82751 +struct t_tmr_ext_trigger{
82752 + uint32_t tmr_etts_h; /**< */
82753 + uint32_t tmr_etts_l; /**< */
82754 +};
82755 +
82756 +struct rtc_regs {
82757 + uint32_t tmr_id; /* 0x000 Module ID register */
82758 + uint32_t tmr_id2; /* 0x004 Controller ID register */
82759 + uint32_t reserved0008[30];
82760 + uint32_t tmr_ctrl; /* 0x0080 timer control register */
82761 + uint32_t tmr_tevent; /* 0x0084 timer event register */
82762 + uint32_t tmr_temask; /* 0x0088 timer event mask register */
82763 + uint32_t reserved008c[3];
82764 + uint32_t tmr_cnt_h; /* 0x0098 timer counter high register */
82765 + uint32_t tmr_cnt_l; /* 0x009c timer counter low register */
82766 + uint32_t tmr_add; /* 0x00a0 timer drift compensation addend register */
82767 + uint32_t tmr_acc; /* 0x00a4 timer accumulator register */
82768 + uint32_t tmr_prsc; /* 0x00a8 timer prescale */
82769 + uint32_t reserved00ac;
82770 + uint32_t tmr_off_h; /* 0x00b0 timer offset high */
82771 + uint32_t tmr_off_l; /* 0x00b4 timer offset low */
82772 + struct t_tmr_alarm tmr_alarm[FMAN_RTC_MAX_NUM_OF_ALARMS]; /* 0x00b8 timer
82773 + alarm */
82774 + uint32_t tmr_fiper[FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES]; /* 0x00d0 timer
82775 + fixed period interval */
82776 + struct t_tmr_ext_trigger tmr_etts[FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS];
82777 + /* 0x00e0 time stamp general purpose external */
82778 + uint32_t reserved00f0[4];
82779 +};
82780 +
82781 +struct rtc_cfg {
82782 + enum fman_src_clock src_clk;
82783 + uint32_t ext_src_clk_freq;
82784 + uint32_t rtc_freq_hz;
82785 + bool timer_slave_mode;
82786 + bool invert_input_clk_phase;
82787 + bool invert_output_clk_phase;
82788 + uint32_t events_mask;
82789 + bool bypass; /**< Indicates if frequency compensation
82790 + is bypassed */
82791 + bool pulse_realign;
82792 + enum fman_rtc_alarm_polarity alarm_polarity[FMAN_RTC_MAX_NUM_OF_ALARMS];
82793 + enum fman_rtc_trigger_polarity trigger_polarity
82794 + [FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS];
82795 +};
82796 +
82797 +/**
82798 + * fman_rtc_defconfig() - Get default RTC configuration
82799 + * @cfg: pointer to configuration structure.
82800 + *
82801 + * Call this function to obtain a default set of configuration values for
82802 + * initializing RTC. The user can overwrite any of the values before calling
82803 + * fman_rtc_init(), if specific configuration needs to be applied.
82804 + */
82805 +void fman_rtc_defconfig(struct rtc_cfg *cfg);
82806 +
82807 +/**
82808 + * fman_rtc_get_events() - Get the events
82809 + * @regs: Pointer to RTC register block
82810 + *
82811 + * Returns: The events
82812 + */
82813 +uint32_t fman_rtc_get_events(struct rtc_regs *regs);
82814 +
82815 +/**
82816 + * fman_rtc_get_interrupt_mask() - Get the events mask
82817 + * @regs: Pointer to RTC register block
82818 + *
82819 + * Returns: The events mask
82820 + */
82821 +uint32_t fman_rtc_get_interrupt_mask(struct rtc_regs *regs);
82822 +
82823 +
82824 +/**
82825 + * fman_rtc_set_interrupt_mask() - Set the events mask
82826 + * @regs: Pointer to RTC register block
82827 + * @mask: The mask to set
82828 + */
82829 +void fman_rtc_set_interrupt_mask(struct rtc_regs *regs, uint32_t mask);
82830 +
82831 +/**
82832 + * fman_rtc_get_event() - Check if specific events occurred
82833 + * @regs: Pointer to RTC register block
82834 + * @ev_mask: a mask of the events to check
82835 + *
82836 + * Returns: 0 if the events did not occur. Non zero if one of the events occurred
82837 + */
82838 +uint32_t fman_rtc_get_event(struct rtc_regs *regs, uint32_t ev_mask);
82839 +
82840 +/**
82841 + * fman_rtc_check_and_clear_event() - Clear events which are on
82842 + * @regs: Pointer to RTC register block
82843 + *
82844 + * Returns: A mask of the events which were cleared
82845 + */
82846 +uint32_t fman_rtc_check_and_clear_event(struct rtc_regs *regs);
82847 +
82848 +/**
82849 + * fman_rtc_ack_event() - Clear events
82850 + * @regs: Pointer to RTC register block
82851 + * @events: The events to disable
82852 + */
82853 +void fman_rtc_ack_event(struct rtc_regs *regs, uint32_t events);
82854 +
82855 +/**
82856 + * fman_rtc_enable_interupt() - Enable events interrupts
82857 + * @regs: Pointer to RTC register block
82858 + * @mask: The events to disable
82859 + */
82860 +void fman_rtc_enable_interupt(struct rtc_regs *regs, uint32_t mask);
82861 +
82862 +/**
82863 + * fman_rtc_disable_interupt() - Disable events interrupts
82864 + * @regs: Pointer to RTC register block
82865 + * @mask: The events to disable
82866 + */
82867 +void fman_rtc_disable_interupt(struct rtc_regs *regs, uint32_t mask);
82868 +
82869 +/**
82870 + * fman_rtc_get_timer_ctrl() - Get the control register
82871 + * @regs: Pointer to RTC register block
82872 + *
82873 + * Returns: The control register value
82874 + */
82875 +uint32_t fman_rtc_get_timer_ctrl(struct rtc_regs *regs);
82876 +
82877 +/**
82878 + * fman_rtc_set_timer_ctrl() - Set timer control register
82879 + * @regs: Pointer to RTC register block
82880 + * @val: The value to set
82881 + */
82882 +void fman_rtc_set_timer_ctrl(struct rtc_regs *regs, uint32_t val);
82883 +
82884 +/**
82885 + * fman_rtc_get_frequency_compensation() - Get the frequency compensation
82886 + * @regs: Pointer to RTC register block
82887 + *
82888 + * Returns: The timer counter
82889 + */
82890 +uint32_t fman_rtc_get_frequency_compensation(struct rtc_regs *regs);
82891 +
82892 +/**
82893 + * fman_rtc_set_frequency_compensation() - Set frequency compensation
82894 + * @regs: Pointer to RTC register block
82895 + * @val: The value to set
82896 + */
82897 +void fman_rtc_set_frequency_compensation(struct rtc_regs *regs, uint32_t val);
82898 +
82899 +/**
82900 + * fman_rtc_get_trigger_stamp() - Get a trigger stamp
82901 + * @regs: Pointer to RTC register block
82902 + * @id: The id of the trigger stamp
82903 + *
82904 + * Returns: The time stamp
82905 + */
82906 +uint64_t fman_rtc_get_trigger_stamp(struct rtc_regs *regs, int id);
82907 +
82908 +/**
82909 + * fman_rtc_set_timer_alarm_l() - Set timer alarm low register
82910 + * @regs: Pointer to RTC register block
82911 + * @index: The index of alarm to set
82912 + * @val: The value to set
82913 + */
82914 +void fman_rtc_set_timer_alarm_l(struct rtc_regs *regs, int index,
82915 + uint32_t val);
82916 +
82917 +/**
82918 + * fman_rtc_set_timer_alarm() - Set timer alarm
82919 + * @regs: Pointer to RTC register block
82920 + * @index: The index of alarm to set
82921 + * @val: The value to set
82922 + */
82923 +void fman_rtc_set_timer_alarm(struct rtc_regs *regs, int index, int64_t val);
82924 +
82925 +/**
82926 + * fman_rtc_set_timer_fiper() - Set timer fiper
82927 + * @regs: Pointer to RTC register block
82928 + * @index: The index of fiper to set
82929 + * @val: The value to set
82930 + */
82931 +void fman_rtc_set_timer_fiper(struct rtc_regs *regs, int index, uint32_t val);
82932 +
82933 +/**
82934 + * fman_rtc_set_timer_offset() - Set timer offset
82935 + * @regs: Pointer to RTC register block
82936 + * @val: The value to set
82937 + */
82938 +void fman_rtc_set_timer_offset(struct rtc_regs *regs, int64_t val);
82939 +
82940 +/**
82941 + * fman_rtc_get_timer() - Get the timer counter
82942 + * @regs: Pointer to RTC register block
82943 + *
82944 + * Returns: The timer counter
82945 + */
82946 +static inline uint64_t fman_rtc_get_timer(struct rtc_regs *regs)
82947 +{
82948 + uint64_t time;
82949 + /* TMR_CNT_L must be read first to get an accurate value */
82950 + time = (uint64_t)ioread32be(&regs->tmr_cnt_l);
82951 + time |= ((uint64_t)ioread32be(&regs->tmr_cnt_h) << 32);
82952 +
82953 + return time;
82954 +}
82955 +
82956 +/**
82957 + * fman_rtc_set_timer() - Set timer counter
82958 + * @regs: Pointer to RTC register block
82959 + * @val: The value to set
82960 + */
82961 +static inline void fman_rtc_set_timer(struct rtc_regs *regs, int64_t val)
82962 +{
82963 + iowrite32be((uint32_t)val, &regs->tmr_cnt_l);
82964 + iowrite32be((uint32_t)(val >> 32), &regs->tmr_cnt_h);
82965 +}
82966 +
82967 +/**
82968 + * fman_rtc_timers_soft_reset() - Soft reset
82969 + * @regs: Pointer to RTC register block
82970 + *
82971 + * Resets all the timer registers and state machines for the 1588 IP and
82972 + * the attached client 1588
82973 + */
82974 +void fman_rtc_timers_soft_reset(struct rtc_regs *regs);
82975 +
82976 +/**
82977 + * fman_rtc_clear_external_trigger() - Clear an external trigger
82978 + * @regs: Pointer to RTC register block
82979 + * @id: The id of the trigger to clear
82980 + */
82981 +void fman_rtc_clear_external_trigger(struct rtc_regs *regs, int id);
82982 +
82983 +/**
82984 + * fman_rtc_clear_periodic_pulse() - Clear periodic pulse
82985 + * @regs: Pointer to RTC register block
82986 + * @id: The id of the fiper to clear
82987 + */
82988 +void fman_rtc_clear_periodic_pulse(struct rtc_regs *regs, int id);
82989 +
82990 +/**
82991 + * fman_rtc_enable() - Enable RTC hardware block
82992 + * @regs: Pointer to RTC register block
82993 + */
82994 +void fman_rtc_enable(struct rtc_regs *regs, bool reset_clock);
82995 +
82996 +/**
82997 + * fman_rtc_is_enabled() - Is RTC hardware block enabled
82998 + * @regs: Pointer to RTC register block
82999 + *
83000 + * Return: TRUE if enabled
83001 + */
83002 +bool fman_rtc_is_enabled(struct rtc_regs *regs);
83003 +
83004 +/**
83005 + * fman_rtc_disable() - Disable RTC hardware block
83006 + * @regs: Pointer to RTC register block
83007 + */
83008 +void fman_rtc_disable(struct rtc_regs *regs);
83009 +
83010 +/**
83011 + * fman_rtc_init() - Init RTC hardware block
83012 + * @cfg: RTC configuration data
83013 + * @regs: Pointer to RTC register block
83014 + * @num_alarms: Number of alarms in RTC
83015 + * @num_fipers: Number of fipers in RTC
83016 + * @num_ext_triggers: Number of external triggers in RTC
83017 + * @freq_compensation: Frequency compensation
83018 + * @output_clock_divisor: Output clock divisor
83019 + *
83020 + * This function initializes RTC and applies basic configuration.
83021 + */
83022 +void fman_rtc_init(struct rtc_cfg *cfg, struct rtc_regs *regs, int num_alarms,
83023 + int num_fipers, int num_ext_triggers, bool init_freq_comp,
83024 + uint32_t freq_compensation, uint32_t output_clock_divisor);
83025 +
83026 +/**
83027 + * fman_rtc_set_alarm() - Set an alarm
83028 + * @regs: Pointer to RTC register block
83029 + * @id: id of alarm
83030 + * @val: value to write
83031 + * @enable: should interrupt be enabled
83032 + */
83033 +void fman_rtc_set_alarm(struct rtc_regs *regs, int id, uint32_t val, bool enable);
83034 +
83035 +/**
83036 + * fman_rtc_set_periodic_pulse() - Set an alarm
83037 + * @regs: Pointer to RTC register block
83038 + * @id: id of fiper
83039 + * @val: value to write
83040 + * @enable: should interrupt be enabled
83041 + */
83042 +void fman_rtc_set_periodic_pulse(struct rtc_regs *regs, int id, uint32_t val,
83043 + bool enable);
83044 +
83045 +/**
83046 + * fman_rtc_set_ext_trigger() - Set an external trigger
83047 + * @regs: Pointer to RTC register block
83048 + * @id: id of trigger
83049 + * @enable: should interrupt be enabled
83050 + * @use_pulse_as_input: use the pulse as input
83051 + */
83052 +void fman_rtc_set_ext_trigger(struct rtc_regs *regs, int id, bool enable,
83053 + bool use_pulse_as_input);
83054 +
83055 +struct fm_rtc_alarm_params {
83056 + uint8_t alarm_id; /**< 0 or 1 */
83057 + uint64_t alarm_time; /**< In nanoseconds, the time when the
83058 + alarm should go off - must be a
83059 + multiple of the RTC period */
83060 + void (*f_alarm_callback)(void* app, uint8_t id); /**< This routine will
83061 + be called when RTC reaches alarmTime */
83062 + bool clear_on_expiration; /**< TRUE to turn off the alarm once
83063 + expired.*/
83064 +};
83065 +
83066 +struct fm_rtc_periodic_pulse_params {
83067 + uint8_t periodic_pulse_id; /**< 0 or 1 */
83068 + uint64_t periodic_pulse_period; /**< In Nanoseconds. Must be a multiple
83069 + of the RTC period */
83070 + void (*f_periodic_pulse_callback)(void* app, uint8_t id); /**< This
83071 + routine will be called every
83072 + periodicPulsePeriod. */
83073 +};
83074 +
83075 +#endif /* __FSL_FMAN_RTC_H */
83076 --- /dev/null
83077 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_sp.h
83078 @@ -0,0 +1,138 @@
83079 +/*
83080 + * Copyright 2013 Freescale Semiconductor Inc.
83081 + *
83082 + * Redistribution and use in source and binary forms, with or without
83083 + * modification, are permitted provided that the following conditions are met:
83084 + * * Redistributions of source code must retain the above copyright
83085 + * notice, this list of conditions and the following disclaimer.
83086 + * * Redistributions in binary form must reproduce the above copyright
83087 + * notice, this list of conditions and the following disclaimer in the
83088 + * documentation and/or other materials provided with the distribution.
83089 + * * Neither the name of Freescale Semiconductor nor the
83090 + * names of its contributors may be used to endorse or promote products
83091 + * derived from this software without specific prior written permission.
83092 + *
83093 + *
83094 + * ALTERNATIVELY, this software may be distributed under the terms of the
83095 + * GNU General Public License ("GPL") as published by the Free Software
83096 + * Foundation, either version 2 of that License or (at your option) any
83097 + * later version.
83098 + *
83099 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
83100 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
83101 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
83102 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
83103 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
83104 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
83105 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
83106 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
83107 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
83108 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
83109 + */
83110 +
83111 +#ifndef __FSL_FMAN_SP_H
83112 +#define __FSL_FMAN_SP_H
83113 +
83114 +#include "common/general.h"
83115 +#include "fsl_fman.h"
83116 +
83117 +
83118 +struct fm_pcd_storage_profile_regs{
83119 + uint32_t fm_sp_ebmpi[8];
83120 + /*offset 0 - 0xc*/
83121 + /**< Buffer Manager pool Information */
83122 +
83123 + uint32_t fm_sp_acnt; /*offset 0x20*/
83124 + uint32_t fm_sp_ebm; /*offset 0x24*/
83125 + uint32_t fm_sp_da; /*offset 0x28*/
83126 + uint32_t fm_sp_icp; /*offset 0x2c*/
83127 + uint32_t fm_sp_mpd; /*offset 0x30*/
83128 + uint32_t res1[2]; /*offset 0x34 - 0x38*/
83129 + uint32_t fm_sp_spliodn; /*offset 0x3c*/
83130 +};
83131 +
83132 +/**************************************************************************//**
83133 + @Description structure for defining internal context copying
83134 +*//***************************************************************************/
83135 +struct fman_sp_int_context_data_copy{
83136 + uint16_t ext_buf_offset; /**< Offset in External buffer to which
83137 + internal context is copied to (Rx)
83138 + or taken from (Tx, Op). */
83139 + uint8_t int_context_offset; /**< Offset within internal context to copy
83140 + from (Rx) or to copy to (Tx, Op).*/
83141 + uint16_t size; /**< Internal offset size to be copied */
83142 +};
83143 +
83144 +/**************************************************************************//**
83145 + @Description struct for defining external buffer margins
83146 +*//***************************************************************************/
83147 +struct fman_sp_buf_margins{
83148 + uint16_t start_margins; /**< Number of bytes to be left at the
83149 + beginning of the external buffer (must be
83150 + divisible by 16) */
83151 + uint16_t end_margins; /**< number of bytes to be left at the end of
83152 + the external buffer(must be divisible by 16)*/
83153 +};
83154 +
83155 +struct fm_storage_profile_params {
83156 + struct fman_ext_pools fm_ext_pools;
83157 + struct fman_backup_bm_pools backup_pools;
83158 + struct fman_sp_int_context_data_copy *int_context;
83159 + struct fman_sp_buf_margins *buf_margins;
83160 + enum fman_dma_swap_option dma_swap_data;
83161 + enum fman_dma_cache_option int_context_cache_attr;
83162 + enum fman_dma_cache_option header_cache_attr;
83163 + enum fman_dma_cache_option scatter_gather_cache_attr;
83164 + bool dma_write_optimize;
83165 + uint16_t liodn_offset;
83166 + bool no_scather_gather;
83167 + struct fman_buf_pool_depletion buf_pool_depletion;
83168 +};
83169 +
83170 +/**************************************************************************//**
83171 + @Description Registers bit fields
83172 +*//***************************************************************************/
83173 +#define FMAN_SP_EXT_BUF_POOL_EN_COUNTER 0x40000000
83174 +#define FMAN_SP_EXT_BUF_POOL_VALID 0x80000000
83175 +#define FMAN_SP_EXT_BUF_POOL_BACKUP 0x20000000
83176 +#define FMAN_SP_DMA_ATTR_WRITE_OPTIMIZE 0x00100000
83177 +#define FMAN_SP_SG_DISABLE 0x80000000
83178 +
83179 +/* shifts */
83180 +#define FMAN_SP_EXT_BUF_POOL_ID_SHIFT 16
83181 +#define FMAN_SP_POOL_DEP_NUM_OF_POOLS_SHIFT 16
83182 +#define FMAN_SP_EXT_BUF_MARG_START_SHIFT 16
83183 +#define FMAN_SP_EXT_BUF_MARG_END_SHIFT 0
83184 +#define FMAN_SP_DMA_ATTR_SWP_SHIFT 30
83185 +#define FMAN_SP_DMA_ATTR_IC_CACHE_SHIFT 28
83186 +#define FMAN_SP_DMA_ATTR_HDR_CACHE_SHIFT 26
83187 +#define FMAN_SP_DMA_ATTR_SG_CACHE_SHIFT 24
83188 +#define FMAN_SP_IC_TO_EXT_SHIFT 16
83189 +#define FMAN_SP_IC_FROM_INT_SHIFT 8
83190 +#define FMAN_SP_IC_SIZE_SHIFT 0
83191 +
83192 +/**************************************************************************//**
83193 + @Description defaults
83194 +*//***************************************************************************/
83195 +#define DEFAULT_FMAN_SP_DMA_SWAP_DATA FMAN_DMA_NO_SWP
83196 +#define DEFAULT_FMAN_SP_DMA_INT_CONTEXT_CACHE_ATTR FMAN_DMA_NO_STASH
83197 +#define DEFAULT_FMAN_SP_DMA_HEADER_CACHE_ATTR FMAN_DMA_NO_STASH
83198 +#define DEFAULT_FMAN_SP_DMA_SCATTER_GATHER_CACHE_ATTR FMAN_DMA_NO_STASH
83199 +#define DEFAULT_FMAN_SP_DMA_WRITE_OPTIMIZE TRUE
83200 +#define DEFAULT_FMAN_SP_NO_SCATTER_GATHER FALSE
83201 +
83202 +void fman_vsp_defconfig(struct fm_storage_profile_params *cfg);
83203 +
83204 +void fman_vsp_init(struct fm_pcd_storage_profile_regs *regs,
83205 + uint16_t index, struct fm_storage_profile_params *fm_vsp_params,
83206 + int port_max_num_of_ext_pools, int bm_max_num_of_pools,
83207 + int max_num_of_pfc_priorities);
83208 +
83209 +uint32_t fman_vsp_get_statistics(struct fm_pcd_storage_profile_regs *regs,
83210 + uint16_t index);
83211 +
83212 +void fman_vsp_set_statistics(struct fm_pcd_storage_profile_regs *regs,
83213 + uint16_t index, uint32_t value);
83214 +
83215 +
83216 +#endif /* __FSL_FMAN_SP_H */
83217 --- /dev/null
83218 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_tgec.h
83219 @@ -0,0 +1,479 @@
83220 +/*
83221 + * Copyright 2008-2012 Freescale Semiconductor Inc.
83222 + *
83223 + * Redistribution and use in source and binary forms, with or without
83224 + * modification, are permitted provided that the following conditions are met:
83225 + * * Redistributions of source code must retain the above copyright
83226 + * notice, this list of conditions and the following disclaimer.
83227 + * * Redistributions in binary form must reproduce the above copyright
83228 + * notice, this list of conditions and the following disclaimer in the
83229 + * documentation and/or other materials provided with the distribution.
83230 + * * Neither the name of Freescale Semiconductor nor the
83231 + * names of its contributors may be used to endorse or promote products
83232 + * derived from this software without specific prior written permission.
83233 + *
83234 + *
83235 + * ALTERNATIVELY, this software may be distributed under the terms of the
83236 + * GNU General Public License ("GPL") as published by the Free Software
83237 + * Foundation, either version 2 of that License or (at your option) any
83238 + * later version.
83239 + *
83240 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
83241 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
83242 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
83243 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
83244 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
83245 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
83246 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
83247 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
83248 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
83249 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
83250 + */
83251 +
83252 +#ifndef __FSL_FMAN_TGEC_H
83253 +#define __FSL_FMAN_TGEC_H
83254 +
83255 +#include "common/general.h"
83256 +#include "fsl_enet.h"
83257 +
83258 +
83259 +/* Transmit Inter-Packet Gap Length Register (TX_IPG_LENGTH) */
83260 +#define TGEC_TX_IPG_LENGTH_MASK 0x000003ff
83261 +
83262 +enum tgec_counters {
83263 + E_TGEC_COUNTER_R64,
83264 + E_TGEC_COUNTER_R127,
83265 + E_TGEC_COUNTER_R255,
83266 + E_TGEC_COUNTER_R511,
83267 + E_TGEC_COUNTER_R1023,
83268 + E_TGEC_COUNTER_R1518,
83269 + E_TGEC_COUNTER_R1519X,
83270 + E_TGEC_COUNTER_TRFRG,
83271 + E_TGEC_COUNTER_TRJBR,
83272 + E_TGEC_COUNTER_RDRP,
83273 + E_TGEC_COUNTER_RALN,
83274 + E_TGEC_COUNTER_TRUND,
83275 + E_TGEC_COUNTER_TROVR,
83276 + E_TGEC_COUNTER_RXPF,
83277 + E_TGEC_COUNTER_TXPF,
83278 + E_TGEC_COUNTER_ROCT,
83279 + E_TGEC_COUNTER_RMCA,
83280 + E_TGEC_COUNTER_RBCA,
83281 + E_TGEC_COUNTER_RPKT,
83282 + E_TGEC_COUNTER_RUCA,
83283 + E_TGEC_COUNTER_RERR,
83284 + E_TGEC_COUNTER_TOCT,
83285 + E_TGEC_COUNTER_TMCA,
83286 + E_TGEC_COUNTER_TBCA,
83287 + E_TGEC_COUNTER_TUCA,
83288 + E_TGEC_COUNTER_TERR
83289 +};
83290 +
83291 +/* Command and Configuration Register (COMMAND_CONFIG) */
83292 +#define CMD_CFG_EN_TIMESTAMP 0x00100000
83293 +#define CMD_CFG_TX_ADDR_INS_SEL 0x00080000
83294 +#define CMD_CFG_NO_LEN_CHK 0x00020000
83295 +#define CMD_CFG_SEND_IDLE 0x00010000
83296 +#define CMD_CFG_RX_ER_DISC 0x00004000
83297 +#define CMD_CFG_CMD_FRM_EN 0x00002000
83298 +#define CMD_CFG_STAT_CLR 0x00001000
83299 +#define CMD_CFG_LOOPBACK_EN 0x00000400
83300 +#define CMD_CFG_TX_ADDR_INS 0x00000200
83301 +#define CMD_CFG_PAUSE_IGNORE 0x00000100
83302 +#define CMD_CFG_PAUSE_FWD 0x00000080
83303 +#define CMD_CFG_PROMIS_EN 0x00000010
83304 +#define CMD_CFG_WAN_MODE 0x00000008
83305 +#define CMD_CFG_RX_EN 0x00000002
83306 +#define CMD_CFG_TX_EN 0x00000001
83307 +
83308 +/* Interrupt Mask Register (IMASK) */
83309 +#define TGEC_IMASK_MDIO_SCAN_EVENT 0x00010000
83310 +#define TGEC_IMASK_MDIO_CMD_CMPL 0x00008000
83311 +#define TGEC_IMASK_REM_FAULT 0x00004000
83312 +#define TGEC_IMASK_LOC_FAULT 0x00002000
83313 +#define TGEC_IMASK_TX_ECC_ER 0x00001000
83314 +#define TGEC_IMASK_TX_FIFO_UNFL 0x00000800
83315 +#define TGEC_IMASK_TX_FIFO_OVFL 0x00000400
83316 +#define TGEC_IMASK_TX_ER 0x00000200
83317 +#define TGEC_IMASK_RX_FIFO_OVFL 0x00000100
83318 +#define TGEC_IMASK_RX_ECC_ER 0x00000080
83319 +#define TGEC_IMASK_RX_JAB_FRM 0x00000040
83320 +#define TGEC_IMASK_RX_OVRSZ_FRM 0x00000020
83321 +#define TGEC_IMASK_RX_RUNT_FRM 0x00000010
83322 +#define TGEC_IMASK_RX_FRAG_FRM 0x00000008
83323 +#define TGEC_IMASK_RX_LEN_ER 0x00000004
83324 +#define TGEC_IMASK_RX_CRC_ER 0x00000002
83325 +#define TGEC_IMASK_RX_ALIGN_ER 0x00000001
83326 +
83327 +#define TGEC_EVENTS_MASK \
83328 + ((uint32_t)(TGEC_IMASK_MDIO_SCAN_EVENT | \
83329 + TGEC_IMASK_MDIO_CMD_CMPL | \
83330 + TGEC_IMASK_REM_FAULT | \
83331 + TGEC_IMASK_LOC_FAULT | \
83332 + TGEC_IMASK_TX_ECC_ER | \
83333 + TGEC_IMASK_TX_FIFO_UNFL | \
83334 + TGEC_IMASK_TX_FIFO_OVFL | \
83335 + TGEC_IMASK_TX_ER | \
83336 + TGEC_IMASK_RX_FIFO_OVFL | \
83337 + TGEC_IMASK_RX_ECC_ER | \
83338 + TGEC_IMASK_RX_JAB_FRM | \
83339 + TGEC_IMASK_RX_OVRSZ_FRM | \
83340 + TGEC_IMASK_RX_RUNT_FRM | \
83341 + TGEC_IMASK_RX_FRAG_FRM | \
83342 + TGEC_IMASK_RX_LEN_ER | \
83343 + TGEC_IMASK_RX_CRC_ER | \
83344 + TGEC_IMASK_RX_ALIGN_ER))
83345 +
83346 +/* Hashtable Control Register (HASHTABLE_CTRL) */
83347 +#define TGEC_HASH_MCAST_SHIFT 23
83348 +#define TGEC_HASH_MCAST_EN 0x00000200
83349 +#define TGEC_HASH_ADR_MSK 0x000001ff
83350 +
83351 +#define DEFAULT_WAN_MODE_ENABLE FALSE
83352 +#define DEFAULT_PROMISCUOUS_MODE_ENABLE FALSE
83353 +#define DEFAULT_PAUSE_FORWARD_ENABLE FALSE
83354 +#define DEFAULT_PAUSE_IGNORE FALSE
83355 +#define DEFAULT_TX_ADDR_INS_ENABLE FALSE
83356 +#define DEFAULT_LOOPBACK_ENABLE FALSE
83357 +#define DEFAULT_CMD_FRAME_ENABLE FALSE
83358 +#define DEFAULT_RX_ERROR_DISCARD FALSE
83359 +#define DEFAULT_SEND_IDLE_ENABLE FALSE
83360 +#define DEFAULT_NO_LENGTH_CHECK_ENABLE TRUE
83361 +#define DEFAULT_LGTH_CHECK_NOSTDR FALSE
83362 +#define DEFAULT_TIME_STAMP_ENABLE FALSE
83363 +#define DEFAULT_TX_IPG_LENGTH 12
83364 +#define DEFAULT_MAX_FRAME_LENGTH 0x600
83365 +#define DEFAULT_PAUSE_QUANT 0xf000
83366 +
83367 +/*
83368 + * 10G memory map
83369 + */
83370 +struct tgec_regs {
83371 + uint32_t tgec_id; /* 0x000 Controller ID */
83372 + uint32_t reserved001[1]; /* 0x004 */
83373 + uint32_t command_config; /* 0x008 Control and configuration */
83374 + uint32_t mac_addr_0; /* 0x00c Lower 32 bits of the MAC adr */
83375 + uint32_t mac_addr_1; /* 0x010 Upper 16 bits of the MAC adr */
83376 + uint32_t maxfrm; /* 0x014 Maximum frame length */
83377 + uint32_t pause_quant; /* 0x018 Pause quanta */
83378 + uint32_t rx_fifo_sections; /* 0x01c */
83379 + uint32_t tx_fifo_sections; /* 0x020 */
83380 + uint32_t rx_fifo_almost_f_e; /* 0x024 */
83381 + uint32_t tx_fifo_almost_f_e; /* 0x028 */
83382 + uint32_t hashtable_ctrl; /* 0x02c Hash table control*/
83383 + uint32_t mdio_cfg_status; /* 0x030 */
83384 + uint32_t mdio_command; /* 0x034 */
83385 + uint32_t mdio_data; /* 0x038 */
83386 + uint32_t mdio_regaddr; /* 0x03c */
83387 + uint32_t status; /* 0x040 */
83388 + uint32_t tx_ipg_len; /* 0x044 Transmitter inter-packet-gap */
83389 + uint32_t mac_addr_2; /* 0x048 Lower 32 bits of 2nd MAC adr */
83390 + uint32_t mac_addr_3; /* 0x04c Upper 16 bits of 2nd MAC adr */
83391 + uint32_t rx_fifo_ptr_rd; /* 0x050 */
83392 + uint32_t rx_fifo_ptr_wr; /* 0x054 */
83393 + uint32_t tx_fifo_ptr_rd; /* 0x058 */
83394 + uint32_t tx_fifo_ptr_wr; /* 0x05c */
83395 + uint32_t imask; /* 0x060 Interrupt mask */
83396 + uint32_t ievent; /* 0x064 Interrupt event */
83397 + uint32_t udp_port; /* 0x068 Defines a UDP Port number */
83398 + uint32_t type_1588v2; /* 0x06c Type field for 1588v2 */
83399 + uint32_t reserved070[4]; /* 0x070 */
83400 + /*10Ge Statistics Counter */
83401 + uint32_t tfrm_u; /* 80 aFramesTransmittedOK */
83402 + uint32_t tfrm_l; /* 84 aFramesTransmittedOK */
83403 + uint32_t rfrm_u; /* 88 aFramesReceivedOK */
83404 + uint32_t rfrm_l; /* 8c aFramesReceivedOK */
83405 + uint32_t rfcs_u; /* 90 aFrameCheckSequenceErrors */
83406 + uint32_t rfcs_l; /* 94 aFrameCheckSequenceErrors */
83407 + uint32_t raln_u; /* 98 aAlignmentErrors */
83408 + uint32_t raln_l; /* 9c aAlignmentErrors */
83409 + uint32_t txpf_u; /* A0 aPAUSEMACCtrlFramesTransmitted */
83410 + uint32_t txpf_l; /* A4 aPAUSEMACCtrlFramesTransmitted */
83411 + uint32_t rxpf_u; /* A8 aPAUSEMACCtrlFramesReceived */
83412 + uint32_t rxpf_l; /* Ac aPAUSEMACCtrlFramesReceived */
83413 + uint32_t rlong_u; /* B0 aFrameTooLongErrors */
83414 + uint32_t rlong_l; /* B4 aFrameTooLongErrors */
83415 + uint32_t rflr_u; /* B8 aInRangeLengthErrors */
83416 + uint32_t rflr_l; /* Bc aInRangeLengthErrors */
83417 + uint32_t tvlan_u; /* C0 VLANTransmittedOK */
83418 + uint32_t tvlan_l; /* C4 VLANTransmittedOK */
83419 + uint32_t rvlan_u; /* C8 VLANReceivedOK */
83420 + uint32_t rvlan_l; /* Cc VLANReceivedOK */
83421 + uint32_t toct_u; /* D0 ifOutOctets */
83422 + uint32_t toct_l; /* D4 ifOutOctets */
83423 + uint32_t roct_u; /* D8 ifInOctets */
83424 + uint32_t roct_l; /* Dc ifInOctets */
83425 + uint32_t ruca_u; /* E0 ifInUcastPkts */
83426 + uint32_t ruca_l; /* E4 ifInUcastPkts */
83427 + uint32_t rmca_u; /* E8 ifInMulticastPkts */
83428 + uint32_t rmca_l; /* Ec ifInMulticastPkts */
83429 + uint32_t rbca_u; /* F0 ifInBroadcastPkts */
83430 + uint32_t rbca_l; /* F4 ifInBroadcastPkts */
83431 + uint32_t terr_u; /* F8 ifOutErrors */
83432 + uint32_t terr_l; /* Fc ifOutErrors */
83433 + uint32_t reserved100[2]; /* 100-108*/
83434 + uint32_t tuca_u; /* 108 ifOutUcastPkts */
83435 + uint32_t tuca_l; /* 10c ifOutUcastPkts */
83436 + uint32_t tmca_u; /* 110 ifOutMulticastPkts */
83437 + uint32_t tmca_l; /* 114 ifOutMulticastPkts */
83438 + uint32_t tbca_u; /* 118 ifOutBroadcastPkts */
83439 + uint32_t tbca_l; /* 11c ifOutBroadcastPkts */
83440 + uint32_t rdrp_u; /* 120 etherStatsDropEvents */
83441 + uint32_t rdrp_l; /* 124 etherStatsDropEvents */
83442 + uint32_t reoct_u; /* 128 etherStatsOctets */
83443 + uint32_t reoct_l; /* 12c etherStatsOctets */
83444 + uint32_t rpkt_u; /* 130 etherStatsPkts */
83445 + uint32_t rpkt_l; /* 134 etherStatsPkts */
83446 + uint32_t trund_u; /* 138 etherStatsUndersizePkts */
83447 + uint32_t trund_l; /* 13c etherStatsUndersizePkts */
83448 + uint32_t r64_u; /* 140 etherStatsPkts64Octets */
83449 + uint32_t r64_l; /* 144 etherStatsPkts64Octets */
83450 + uint32_t r127_u; /* 148 etherStatsPkts65to127Octets */
83451 + uint32_t r127_l; /* 14c etherStatsPkts65to127Octets */
83452 + uint32_t r255_u; /* 150 etherStatsPkts128to255Octets */
83453 + uint32_t r255_l; /* 154 etherStatsPkts128to255Octets */
83454 + uint32_t r511_u; /* 158 etherStatsPkts256to511Octets */
83455 + uint32_t r511_l; /* 15c etherStatsPkts256to511Octets */
83456 + uint32_t r1023_u; /* 160 etherStatsPkts512to1023Octets */
83457 + uint32_t r1023_l; /* 164 etherStatsPkts512to1023Octets */
83458 + uint32_t r1518_u; /* 168 etherStatsPkts1024to1518Octets */
83459 + uint32_t r1518_l; /* 16c etherStatsPkts1024to1518Octets */
83460 + uint32_t r1519x_u; /* 170 etherStatsPkts1519toX */
83461 + uint32_t r1519x_l; /* 174 etherStatsPkts1519toX */
83462 + uint32_t trovr_u; /* 178 etherStatsOversizePkts */
83463 + uint32_t trovr_l; /* 17c etherStatsOversizePkts */
83464 + uint32_t trjbr_u; /* 180 etherStatsJabbers */
83465 + uint32_t trjbr_l; /* 184 etherStatsJabbers */
83466 + uint32_t trfrg_u; /* 188 etherStatsFragments */
83467 + uint32_t trfrg_l; /* 18C etherStatsFragments */
83468 + uint32_t rerr_u; /* 190 ifInErrors */
83469 + uint32_t rerr_l; /* 194 ifInErrors */
83470 +};
83471 +
83472 +/**
83473 + * struct tgec_cfg - TGEC configuration
83474 + *
83475 + * @rx_error_discard: Receive Erroneous Frame Discard Enable. When set to 1
83476 + * any frame received with an error is discarded in the
83477 + * Core and not forwarded to the Client interface.
83478 + * When set to 0 (Reset value), erroneous Frames are
83479 + * forwarded to the Client interface with ff_rx_err
83480 + * asserted.
83481 + * @pause_ignore: Ignore Pause Frame Quanta. If set to 1 received pause
83482 + * frames are ignored by the MAC. When set to 0
83483 + * (Reset value) the transmit process is stopped for the
83484 + * amount of time specified in the pause quanta received
83485 + * within a pause frame.
83486 + * @pause_forward_enable:
83487 + * Terminate / Forward Pause Frames. If set to 1 pause
83488 + * frames are forwarded to the user application. When set
83489 + * to 0 (Reset value) pause frames are terminated and
83490 + * discarded within the MAC.
83491 + * @no_length_check_enable:
83492 + * Payload Length Check Disable. When set to 0
83493 + * (Reset value), the Core checks the frame's payload
83494 + * length with the Frame Length/Type field, when set to 1
83495 + * the payload length check is disabled.
83496 + * @cmd_frame_enable: Enables reception of all command frames. When set to 1
83497 + * all Command Frames are accepted, when set to 0
83498 + * (Reset Value) only Pause Frames are accepted and all
83499 + * other Command Frames are rejected.
83500 + * @send_idle_enable: Force Idle Generation. When set to 1, the MAC
83501 + * permanently sends XGMII Idle sequences even when faults
83502 + * are received.
83503 + * @wan_mode_enable: WAN Mode Enable. Sets WAN mode (1) or LAN mode
83504 + * (0, default) of operation.
83505 + * @promiscuous_mode_enable:
83506 + * Enables MAC promiscuous operation. When set to 1, all
83507 + * frames are received without any MAC address filtering,
83508 + * when set to 0 (Reset value) Unicast Frames with a
83509 + * destination address not matching the Core MAC Address
83510 + * (MAC Address programmed in Registers MAC_ADDR_0 and
83511 + * MAC_ADDR_1 or the MAC address programmed in Registers
83512 + * MAC_ADDR_2 and MAC_ADDR_3) are rejected.
83513 + * @tx_addr_ins_enable: Set Source MAC Address on Transmit. If set to 1 the
83514 + * MAC overwrites the source MAC address received from the
83515 + * Client Interface with one of the MAC addresses. If set
83516 + * to 0 (Reset value), the source MAC address from the
83517 + * Client Interface is transmitted unmodified to the line.
83518 + * @loopback_enable: PHY Interface Loopback. When set to 1, the signal
83519 + * loop_ena is set to '1', when set to 0 (Reset value)
83520 + * the signal loop_ena is set to 0.
83521 + * @lgth_check_nostdr: The Core interprets the Length/Type field differently
83522 + * depending on the value of this Bit
83523 + * @time_stamp_enable: This bit selects between enabling and disabling the
83524 + * IEEE 1588 functionality. 1: IEEE 1588 is enabled
83525 + * 0: IEEE 1588 is disabled
83526 + * @max_frame_length: Maximum supported received frame length.
83527 + * The 10GEC MAC supports reception of any frame size up
83528 + * to 16,352 bytes (0x3FE0). Typical settings are
83529 + * 0x05EE (1,518 bytes) for standard frames.
83530 + * Default setting is 0x0600 (1,536 bytes).
83531 + * Received frames that exceed this stated maximum
83532 + * are truncated.
83533 + * @pause_quant: Pause quanta value used with transmitted pause frames.
83534 + * Each quanta represents a 512 bit-times.
83535 + * @tx_ipg_length: Transmit Inter-Packet-Gap (IPG) value. A 6-bit value:
83536 + * Depending on LAN or WAN mode of operation the value has
83537 + * the following meaning: - LAN Mode: Number of octets in
83538 + * steps of 4. Valid values are 8, 12, 16, ... 100. DIC is
83539 + * fully supported (see 10.6.1 page 49) for any setting. A
83540 + * default of 12 (reset value) must be set to conform to
83541 + * IEEE802.3ae. Warning: When set to 8, PCS layers may not
83542 + * be able to perform clock rate compensation. - WAN Mode:
83543 + * Stretch factor. Valid values are 4..15. The stretch
83544 + * factor is calculated as (value+1)*8. A default of 12
83545 + * (reset value) must be set to conform to IEEE 802.3ae
83546 + * (i.e. 13*8=104). A larger value shrinks the IPG
83547 + * (increasing bandwidth).
83548 + *
83549 + * This structure contains basic TGEC configuration and must be passed to
83550 + * fman_tgec_init() function. A default set of configuration values can be
83551 + * obtained by calling fman_tgec_defconfig().
83552 + */
83553 +struct tgec_cfg {
83554 + bool rx_error_discard;
83555 + bool pause_ignore;
83556 + bool pause_forward_enable;
83557 + bool no_length_check_enable;
83558 + bool cmd_frame_enable;
83559 + bool send_idle_enable;
83560 + bool wan_mode_enable;
83561 + bool promiscuous_mode_enable;
83562 + bool tx_addr_ins_enable;
83563 + bool loopback_enable;
83564 + bool lgth_check_nostdr;
83565 + bool time_stamp_enable;
83566 + uint16_t max_frame_length;
83567 + uint16_t pause_quant;
83568 + uint32_t tx_ipg_length;
83569 + bool skip_fman11_workaround;
83570 +};
83571 +
83572 +
83573 +void fman_tgec_defconfig(struct tgec_cfg *cfg);
83574 +
83575 +/**
83576 + * fman_tgec_init() - Init tgec hardware block
83577 + * @regs: Pointer to tgec register block
83578 + * @cfg: tgec configuration data
83579 + * @exceptions_mask: initial exceptions mask
83580 + *
83581 + * This function initializes the tgec controller and applies its
83582 + * basic configuration.
83583 + *
83584 + * Returns: 0 if successful, an error code otherwise.
83585 + */
83586 +
83587 +int fman_tgec_init(struct tgec_regs *regs, struct tgec_cfg *cfg,
83588 + uint32_t exception_mask);
83589 +
83590 +void fman_tgec_enable(struct tgec_regs *regs, bool apply_rx, bool apply_tx);
83591 +
83592 +void fman_tgec_disable(struct tgec_regs *regs, bool apply_rx, bool apply_tx);
83593 +
83594 +uint32_t fman_tgec_get_revision(struct tgec_regs *regs);
83595 +
83596 +void fman_tgec_set_mac_address(struct tgec_regs *regs, uint8_t *macaddr);
83597 +
83598 +void fman_tgec_set_promiscuous(struct tgec_regs *regs, bool val);
83599 +
83600 +/**
83601 + * fman_tgec_reset_stat() - Completely resets all TGEC HW counters
83602 + * @regs: Pointer to TGEC register block
83603 + */
83604 +void fman_tgec_reset_stat(struct tgec_regs *regs);
83605 +
83606 +/**
83607 + * fman_tgec_get_counter() - Reads TGEC HW counters
83608 + * @regs: Pointer to TGEC register block
83609 + * @reg_name: Counter name according to the appropriate enum
83610 + *
83611 + * Returns: Required counter value
83612 + */
83613 +uint64_t fman_tgec_get_counter(struct tgec_regs *regs,
83614 + enum tgec_counters reg_name);
83615 +
83616 +/**
83617 + * fman_tgec_set_hash_table() - Sets the Hashtable Control Register
83618 + * @regs: Pointer to TGEC register block
83619 + * @value: Value to be written in Hashtable Control Register
83620 + */
83621 +void fman_tgec_set_hash_table(struct tgec_regs *regs, uint32_t value);
83622 +
83623 +/**
83624 + * fman_tgec_set_tx_pause_frames() - Sets the Pause Quanta Register
83625 + * @regs: Pointer to TGEC register block
83626 + * @pause_time: Pause quanta value used with transmitted pause frames.
83627 + * Each quanta represents a 512 bit-times
83628 + */
83629 +void fman_tgec_set_tx_pause_frames(struct tgec_regs *regs, uint16_t pause_time);
83630 +
83631 +/**
83632 + * fman_tgec_set_rx_ignore_pause_frames() - Changes the policy WRT pause frames
83633 + * @regs: Pointer to TGEC register block
83634 + * @en: Ignore/Respond to pause frame quanta
83635 + *
83636 + * Sets the value of PAUSE_IGNORE field in the COMMAND_CONFIG Register
83637 + * 0 - MAC stops transmit process for the duration specified
83638 + * in the Pause frame quanta of a received Pause frame.
83639 + * 1 - MAC ignores received Pause frames.
83640 + */
83641 +void fman_tgec_set_rx_ignore_pause_frames(struct tgec_regs *regs, bool en);
83642 +
83643 +/**
83644 + * fman_tgec_enable_1588_time_stamp() - change timestamp functionality
83645 + * @regs: Pointer to TGEC register block
83646 + * @en: enable/disable timestamp functionality
83647 + *
83648 + * Sets the value of EN_TIMESTAMP field in the COMMAND_CONFIG Register
83649 + * IEEE 1588 timestamp functionality control:
83650 + * 0 disabled, 1 enabled
83651 + */
83652 +
83653 +void fman_tgec_enable_1588_time_stamp(struct tgec_regs *regs, bool en);
83654 +
83655 +uint32_t fman_tgec_get_event(struct tgec_regs *regs, uint32_t ev_mask);
83656 +
83657 +void fman_tgec_ack_event(struct tgec_regs *regs, uint32_t ev_mask);
83658 +
83659 +uint32_t fman_tgec_get_interrupt_mask(struct tgec_regs *regs);
83660 +
83661 +/**
83662 + * fman_tgec_add_addr_in_paddr() - Sets additional exact match MAC address
83663 + * @regs: Pointer to TGEC register block
83664 + * @addr_ptr: Pointer to 6-byte array containing the MAC address
83665 + *
83666 + * Sets the additional station MAC address
83667 + */
83668 +void fman_tgec_add_addr_in_paddr(struct tgec_regs *regs, uint8_t *addr_ptr);
83669 +
83670 +void fman_tgec_clear_addr_in_paddr(struct tgec_regs *regs);
83671 +
83672 +void fman_tgec_enable_interrupt(struct tgec_regs *regs, uint32_t ev_mask);
83673 +
83674 +void fman_tgec_disable_interrupt(struct tgec_regs *regs, uint32_t ev_mask);
83675 +
83676 +void fman_tgec_reset_filter_table(struct tgec_regs *regs);
83677 +
83678 +void fman_tgec_set_hash_table_entry(struct tgec_regs *regs, uint32_t crc);
83679 +
83680 +
83681 +/**
83682 + * fman_tgec_get_max_frame_len() - Returns the maximum frame length value
83683 + * @regs: Pointer to TGEC register block
83684 + */
83685 +uint16_t fman_tgec_get_max_frame_len(struct tgec_regs *regs);
83686 +
83687 +/**
83688 + * fman_tgec_set_erratum_tx_fifo_corruption_10gmac_a007() - Initialize the
83689 + * main tgec configuration parameters
83690 + * @regs: Pointer to TGEC register block
83691 + *
83692 + * TODO
83693 + */
83694 +void fman_tgec_set_erratum_tx_fifo_corruption_10gmac_a007(struct tgec_regs
83695 + *regs);
83696 +
83697 +
83698 +#endif /* __FSL_FMAN_TGEC_H */
83699 --- /dev/null
83700 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3H/dpaa_integration_ext.h
83701 @@ -0,0 +1,290 @@
83702 +/*
83703 + * Copyright 2012 Freescale Semiconductor Inc.
83704 + *
83705 + * Redistribution and use in source and binary forms, with or without
83706 + * modification, are permitted provided that the following conditions are met:
83707 + * * Redistributions of source code must retain the above copyright
83708 + * notice, this list of conditions and the following disclaimer.
83709 + * * Redistributions in binary form must reproduce the above copyright
83710 + * notice, this list of conditions and the following disclaimer in the
83711 + * documentation and/or other materials provided with the distribution.
83712 + * * Neither the name of Freescale Semiconductor nor the
83713 + * names of its contributors may be used to endorse or promote products
83714 + * derived from this software without specific prior written permission.
83715 + *
83716 + *
83717 + * ALTERNATIVELY, this software may be distributed under the terms of the
83718 + * GNU General Public License ("GPL") as published by the Free Software
83719 + * Foundation, either version 2 of that License or (at your option) any
83720 + * later version.
83721 + *
83722 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
83723 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
83724 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
83725 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
83726 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
83727 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
83728 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
83729 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
83730 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
83731 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
83732 + */
83733 +
83734 +/**
83735 +
83736 + @File dpaa_integration_ext.h
83737 +
83738 + @Description T4240 FM external definitions and structures.
83739 +*//***************************************************************************/
83740 +#ifndef __DPAA_INTEGRATION_EXT_H
83741 +#define __DPAA_INTEGRATION_EXT_H
83742 +
83743 +#include "std_ext.h"
83744 +
83745 +
83746 +#define DPAA_VERSION 11
83747 +
83748 +/**************************************************************************//**
83749 + @Description DPAA SW Portals Enumeration.
83750 +*//***************************************************************************/
83751 +typedef enum
83752 +{
83753 + e_DPAA_SWPORTAL0 = 0,
83754 + e_DPAA_SWPORTAL1,
83755 + e_DPAA_SWPORTAL2,
83756 + e_DPAA_SWPORTAL3,
83757 + e_DPAA_SWPORTAL4,
83758 + e_DPAA_SWPORTAL5,
83759 + e_DPAA_SWPORTAL6,
83760 + e_DPAA_SWPORTAL7,
83761 + e_DPAA_SWPORTAL8,
83762 + e_DPAA_SWPORTAL9,
83763 + e_DPAA_SWPORTAL10,
83764 + e_DPAA_SWPORTAL11,
83765 + e_DPAA_SWPORTAL12,
83766 + e_DPAA_SWPORTAL13,
83767 + e_DPAA_SWPORTAL14,
83768 + e_DPAA_SWPORTAL15,
83769 + e_DPAA_SWPORTAL16,
83770 + e_DPAA_SWPORTAL17,
83771 + e_DPAA_SWPORTAL18,
83772 + e_DPAA_SWPORTAL19,
83773 + e_DPAA_SWPORTAL20,
83774 + e_DPAA_SWPORTAL21,
83775 + e_DPAA_SWPORTAL22,
83776 + e_DPAA_SWPORTAL23,
83777 + e_DPAA_SWPORTAL24,
83778 + e_DPAA_SWPORTAL_DUMMY_LAST
83779 +} e_DpaaSwPortal;
83780 +
83781 +/**************************************************************************//**
83782 + @Description DPAA Direct Connect Portals Enumeration.
83783 +*//***************************************************************************/
83784 +typedef enum
83785 +{
83786 + e_DPAA_DCPORTAL0 = 0,
83787 + e_DPAA_DCPORTAL1,
83788 + e_DPAA_DCPORTAL2,
83789 + e_DPAA_DCPORTAL_DUMMY_LAST
83790 +} e_DpaaDcPortal;
83791 +
83792 +#define DPAA_MAX_NUM_OF_SW_PORTALS e_DPAA_SWPORTAL_DUMMY_LAST
83793 +#define DPAA_MAX_NUM_OF_DC_PORTALS e_DPAA_DCPORTAL_DUMMY_LAST
83794 +
83795 +/*****************************************************************************
83796 + QMan INTEGRATION-SPECIFIC DEFINITIONS
83797 +******************************************************************************/
83798 +#define QM_MAX_NUM_OF_POOL_CHANNELS 15 /**< Total number of channels, dedicated and pool */
83799 +#define QM_MAX_NUM_OF_WQ 8 /**< Number of work queues per channel */
83800 +#define QM_MAX_NUM_OF_CGS 256 /**< Congestion groups number */
83801 +#define QM_MAX_NUM_OF_FQIDS (16 * MEGABYTE)
83802 + /**< FQIDs range - 24 bits */
83803 +
83804 +/**************************************************************************//**
83805 + @Description Work Queue Channel assignments in QMan.
83806 +*//***************************************************************************/
83807 +typedef enum
83808 +{
83809 + e_QM_FQ_CHANNEL_SWPORTAL0 = 0x0, /**< Dedicated channels serviced by software portals 0 to 24 */
83810 + e_QM_FQ_CHANNEL_SWPORTAL1,
83811 + e_QM_FQ_CHANNEL_SWPORTAL2,
83812 + e_QM_FQ_CHANNEL_SWPORTAL3,
83813 + e_QM_FQ_CHANNEL_SWPORTAL4,
83814 + e_QM_FQ_CHANNEL_SWPORTAL5,
83815 + e_QM_FQ_CHANNEL_SWPORTAL6,
83816 + e_QM_FQ_CHANNEL_SWPORTAL7,
83817 + e_QM_FQ_CHANNEL_SWPORTAL8,
83818 + e_QM_FQ_CHANNEL_SWPORTAL9,
83819 + e_QM_FQ_CHANNEL_SWPORTAL10,
83820 + e_QM_FQ_CHANNEL_SWPORTAL11,
83821 + e_QM_FQ_CHANNEL_SWPORTAL12,
83822 + e_QM_FQ_CHANNEL_SWPORTAL13,
83823 + e_QM_FQ_CHANNEL_SWPORTAL14,
83824 + e_QM_FQ_CHANNEL_SWPORTAL15,
83825 + e_QM_FQ_CHANNEL_SWPORTAL16,
83826 + e_QM_FQ_CHANNEL_SWPORTAL17,
83827 + e_QM_FQ_CHANNEL_SWPORTAL18,
83828 + e_QM_FQ_CHANNEL_SWPORTAL19,
83829 + e_QM_FQ_CHANNEL_SWPORTAL20,
83830 + e_QM_FQ_CHANNEL_SWPORTAL21,
83831 + e_QM_FQ_CHANNEL_SWPORTAL22,
83832 + e_QM_FQ_CHANNEL_SWPORTAL23,
83833 + e_QM_FQ_CHANNEL_SWPORTAL24,
83834 +
83835 + e_QM_FQ_CHANNEL_POOL1 = 0x401, /**< Pool channels that can be serviced by any of the software portals */
83836 + e_QM_FQ_CHANNEL_POOL2,
83837 + e_QM_FQ_CHANNEL_POOL3,
83838 + e_QM_FQ_CHANNEL_POOL4,
83839 + e_QM_FQ_CHANNEL_POOL5,
83840 + e_QM_FQ_CHANNEL_POOL6,
83841 + e_QM_FQ_CHANNEL_POOL7,
83842 + e_QM_FQ_CHANNEL_POOL8,
83843 + e_QM_FQ_CHANNEL_POOL9,
83844 + e_QM_FQ_CHANNEL_POOL10,
83845 + e_QM_FQ_CHANNEL_POOL11,
83846 + e_QM_FQ_CHANNEL_POOL12,
83847 + e_QM_FQ_CHANNEL_POOL13,
83848 + e_QM_FQ_CHANNEL_POOL14,
83849 + e_QM_FQ_CHANNEL_POOL15,
83850 +
83851 + e_QM_FQ_CHANNEL_FMAN0_SP0 = 0x800, /**< Dedicated channels serviced by Direct Connect Portal 0:
83852 + connected to FMan 0; assigned in incrementing order to
83853 + each sub-portal (SP) in the portal */
83854 + e_QM_FQ_CHANNEL_FMAN0_SP1,
83855 + e_QM_FQ_CHANNEL_FMAN0_SP2,
83856 + e_QM_FQ_CHANNEL_FMAN0_SP3,
83857 + e_QM_FQ_CHANNEL_FMAN0_SP4,
83858 + e_QM_FQ_CHANNEL_FMAN0_SP5,
83859 + e_QM_FQ_CHANNEL_FMAN0_SP6,
83860 + e_QM_FQ_CHANNEL_FMAN0_SP7,
83861 + e_QM_FQ_CHANNEL_FMAN0_SP8,
83862 + e_QM_FQ_CHANNEL_FMAN0_SP9,
83863 + e_QM_FQ_CHANNEL_FMAN0_SP10,
83864 + e_QM_FQ_CHANNEL_FMAN0_SP11,
83865 + e_QM_FQ_CHANNEL_FMAN0_SP12,
83866 + e_QM_FQ_CHANNEL_FMAN0_SP13,
83867 + e_QM_FQ_CHANNEL_FMAN0_SP14,
83868 + e_QM_FQ_CHANNEL_FMAN0_SP15,
83869 +
83870 + e_QM_FQ_CHANNEL_RMAN_SP0 = 0x820, /**< Dedicated channels serviced by Direct Connect Portal 1: connected to RMan */
83871 + e_QM_FQ_CHANNEL_RMAN_SP1,
83872 +
83873 + e_QM_FQ_CHANNEL_CAAM = 0x840 /**< Dedicated channel serviced by Direct Connect Portal 2:
83874 + connected to SEC */
83875 +} e_QmFQChannel;
83876 +
83877 +/*****************************************************************************
83878 + BMan INTEGRATION-SPECIFIC DEFINITIONS
83879 +******************************************************************************/
83880 +#define BM_MAX_NUM_OF_POOLS 64 /**< Number of buffers pools */
83881 +
83882 +/*****************************************************************************
83883 + SEC INTEGRATION-SPECIFIC DEFINITIONS
83884 +******************************************************************************/
83885 +#define SEC_NUM_OF_DECOS 3
83886 +#define SEC_ALL_DECOS_MASK 0x00000003
83887 +
83888 +
83889 +/*****************************************************************************
83890 + FM INTEGRATION-SPECIFIC DEFINITIONS
83891 +******************************************************************************/
83892 +#define INTG_MAX_NUM_OF_FM 2
83893 +/* Ports defines */
83894 +#define FM_MAX_NUM_OF_1G_MACS 6
83895 +#define FM_MAX_NUM_OF_10G_MACS 2
83896 +#define FM_MAX_NUM_OF_MACS (FM_MAX_NUM_OF_1G_MACS + FM_MAX_NUM_OF_10G_MACS)
83897 +#define FM_MAX_NUM_OF_OH_PORTS 6
83898 +
83899 +#define FM_MAX_NUM_OF_1G_RX_PORTS FM_MAX_NUM_OF_1G_MACS
83900 +#define FM_MAX_NUM_OF_10G_RX_PORTS FM_MAX_NUM_OF_10G_MACS
83901 +#define FM_MAX_NUM_OF_RX_PORTS (FM_MAX_NUM_OF_10G_RX_PORTS + FM_MAX_NUM_OF_1G_RX_PORTS)
83902 +
83903 +#define FM_MAX_NUM_OF_1G_TX_PORTS FM_MAX_NUM_OF_1G_MACS
83904 +#define FM_MAX_NUM_OF_10G_TX_PORTS FM_MAX_NUM_OF_10G_MACS
83905 +#define FM_MAX_NUM_OF_TX_PORTS (FM_MAX_NUM_OF_10G_TX_PORTS + FM_MAX_NUM_OF_1G_TX_PORTS)
83906 +
83907 +#define FM_PORT_MAX_NUM_OF_EXT_POOLS 4 /**< Number of external BM pools per Rx port */
83908 +#define FM_PORT_NUM_OF_CONGESTION_GRPS 256 /**< Total number of congestion groups in QM */
83909 +#define FM_MAX_NUM_OF_SUB_PORTALS 16
83910 +#define FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS 0
83911 +
83912 +#define FM_VSP_MAX_NUM_OF_ENTRIES 64
83913 +#define FM_MAX_NUM_OF_PFC_PRIORITIES 8
83914 +
83915 +/* RAMs defines */
83916 +#define FM_MURAM_SIZE (384 * KILOBYTE)
83917 +#define FM_IRAM_SIZE(major, minor) (64 * KILOBYTE)
83918 +#define FM_NUM_OF_CTRL 4
83919 +
83920 +/* PCD defines */
83921 +#define FM_PCD_PLCR_NUM_ENTRIES 256 /**< Total number of policer profiles */
83922 +#define FM_PCD_KG_NUM_OF_SCHEMES 32 /**< Total number of KG schemes */
83923 +#define FM_PCD_MAX_NUM_OF_CLS_PLANS 256 /**< Number of classification plan entries. */
83924 +#define FM_PCD_PRS_SW_PATCHES_SIZE 0x00000600 /**< Number of bytes saved for patches */
83925 +#define FM_PCD_SW_PRS_SIZE 0x00000800 /**< Total size of SW parser area */
83926 +
83927 +/* RTC defines */
83928 +#define FM_RTC_NUM_OF_ALARMS 2 /**< RTC number of alarms */
83929 +#define FM_RTC_NUM_OF_PERIODIC_PULSES 3 /**< RTC number of periodic pulses */
83930 +#define FM_RTC_NUM_OF_EXT_TRIGGERS 2 /**< RTC number of external triggers */
83931 +
83932 +/* QMI defines */
83933 +#define QMI_MAX_NUM_OF_TNUMS 64
83934 +#define QMI_DEF_TNUMS_THRESH 32
83935 +/* FPM defines */
83936 +#define FM_NUM_OF_FMAN_CTRL_EVENT_REGS 4
83937 +
83938 +/* DMA defines */
83939 +#define DMA_THRESH_MAX_COMMQ 83
83940 +#define DMA_THRESH_MAX_BUF 127
83941 +
83942 +/* BMI defines */
83943 +#define BMI_MAX_NUM_OF_TASKS 128
83944 +#define BMI_MAX_NUM_OF_DMAS 84
83945 +
83946 +#define BMI_MAX_FIFO_SIZE (FM_MURAM_SIZE)
83947 +#define PORT_MAX_WEIGHT 16
83948 +
83949 +#define FM_CHECK_PORT_RESTRICTIONS(__validPorts, __newPortIndx) TRUE
83950 +
83951 +/* Unique T4240 */
83952 +#define FM_OP_OPEN_DMA_MIN_LIMIT
83953 +#define FM_NO_RESTRICT_ON_ACCESS_RSRC
83954 +#define FM_NO_OP_OBSERVED_POOLS
83955 +#define FM_FRAME_END_PARAMS_FOR_OP
83956 +#define FM_DEQ_PIPELINE_PARAMS_FOR_OP
83957 +#define FM_QMI_NO_SINGLE_ECC_EXCEPTION
83958 +
83959 +#define FM_NO_GUARANTEED_RESET_VALUES
83960 +
83961 +/* FM errata */
83962 +#define FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669
83963 +#define FM_WRONG_RESET_VALUES_ERRATA_FMAN_A005127
83964 +#define FM_RX_FIFO_CORRUPT_ERRATA_10GMAC_A006320
83965 +#define FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675
83966 +#define FM_HEAVY_TRAFFIC_SEQUENCER_HANG_ERRATA_FMAN_A006981
83967 +
83968 +#define FM_BCB_ERRATA_BMI_SW001
83969 +#define FM_LEN_CHECK_ERRATA_FMAN_SW002
83970 +#define FM_AID_MODE_NO_TNUM_SW005 /* refer to pdm TKT068794 - only support of port_id on aid */
83971 +#define FM_ERROR_VSP_NO_MATCH_SW006 /* refer to pdm TKT174304 - no match between errorQ and VSP */
83972 +
83973 +/*****************************************************************************
83974 + RMan INTEGRATION-SPECIFIC DEFINITIONS
83975 +******************************************************************************/
83976 +#define RM_MAX_NUM_OF_IB 4 /**< Number of inbound blocks */
83977 +#define RM_NUM_OF_IBCU 8 /**< NUmber of classification units in an inbound block */
83978 +
83979 +/* RMan erratas */
83980 +#define RM_ERRONEOUS_ACK_ERRATA_RMAN_A006756
83981 +
83982 +/*****************************************************************************
83983 + FM MACSEC INTEGRATION-SPECIFIC DEFINITIONS
83984 +******************************************************************************/
83985 +#define NUM_OF_RX_SC 16
83986 +#define NUM_OF_TX_SC 16
83987 +
83988 +#define NUM_OF_SA_PER_RX_SC 2
83989 +#define NUM_OF_SA_PER_TX_SC 2
83990 +
83991 +#endif /* __DPAA_INTEGRATION_EXT_H */
83992 --- /dev/null
83993 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3H/part_ext.h
83994 @@ -0,0 +1,71 @@
83995 +/*
83996 + * Copyright 2012 Freescale Semiconductor Inc.
83997 + *
83998 + * Redistribution and use in source and binary forms, with or without
83999 + * modification, are permitted provided that the following conditions are met:
84000 + * * Redistributions of source code must retain the above copyright
84001 + * notice, this list of conditions and the following disclaimer.
84002 + * * Redistributions in binary form must reproduce the above copyright
84003 + * notice, this list of conditions and the following disclaimer in the
84004 + * documentation and/or other materials provided with the distribution.
84005 + * * Neither the name of Freescale Semiconductor nor the
84006 + * names of its contributors may be used to endorse or promote products
84007 + * derived from this software without specific prior written permission.
84008 + *
84009 + *
84010 + * ALTERNATIVELY, this software may be distributed under the terms of the
84011 + * GNU General Public License ("GPL") as published by the Free Software
84012 + * Foundation, either version 2 of that License or (at your option) any
84013 + * later version.
84014 + *
84015 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
84016 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
84017 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
84018 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
84019 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
84020 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
84021 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
84022 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
84023 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
84024 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84025 + */
84026 +
84027 +/**************************************************************************//**
84028 +
84029 + @File part_ext.h
84030 +
84031 + @Description Definitions for the part (integration) module.
84032 +*//***************************************************************************/
84033 +
84034 +#ifndef __PART_EXT_H
84035 +#define __PART_EXT_H
84036 +
84037 +#include "std_ext.h"
84038 +#include "part_integration_ext.h"
84039 +
84040 +#if !(defined(P1023) || \
84041 + defined(P2041) || \
84042 + defined(P3041) || \
84043 + defined(P4080) || \
84044 + defined(P5020) || \
84045 + defined(P5040) || \
84046 + defined(B4860) || \
84047 + defined(T4240))
84048 +#error "unable to proceed without chip-definition"
84049 +#endif
84050 +
84051 +
84052 +/**************************************************************************//*
84053 + @Description Part data structure - must be contained in any integration
84054 + data structure.
84055 +*//***************************************************************************/
84056 +typedef struct t_Part
84057 +{
84058 + uintptr_t (* f_GetModuleBase)(t_Handle h_Part, e_ModuleId moduleId);
84059 + /**< Returns the address of the module's memory map base. */
84060 + e_ModuleId (* f_GetModuleIdByBase)(t_Handle h_Part, uintptr_t baseAddress);
84061 + /**< Returns the module's ID according to its memory map base. */
84062 +} t_Part;
84063 +
84064 +
84065 +#endif /* __PART_EXT_H */
84066 --- /dev/null
84067 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3H/part_integration_ext.h
84068 @@ -0,0 +1,304 @@
84069 +/*
84070 + * Copyright 2008-2012 Freescale Semiconductor Inc.
84071 + *
84072 + * Redistribution and use in source and binary forms, with or without
84073 + * modification, are permitted provided that the following conditions are met:
84074 + * * Redistributions of source code must retain the above copyright
84075 + * notice, this list of conditions and the following disclaimer.
84076 + * * Redistributions in binary form must reproduce the above copyright
84077 + * notice, this list of conditions and the following disclaimer in the
84078 + * documentation and/or other materials provided with the distribution.
84079 + * * Neither the name of Freescale Semiconductor nor the
84080 + * names of its contributors may be used to endorse or promote products
84081 + * derived from this software without specific prior written permission.
84082 + *
84083 + *
84084 + * ALTERNATIVELY, this software may be distributed under the terms of the
84085 + * GNU General Public License ("GPL") as published by the Free Software
84086 + * Foundation, either version 2 of that License or (at your option) any
84087 + * later version.
84088 + *
84089 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
84090 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
84091 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
84092 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
84093 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
84094 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
84095 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
84096 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
84097 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
84098 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84099 + */
84100 +
84101 +/**
84102 +
84103 + @File part_integration_ext.h
84104 +
84105 + @Description T4240 external definitions and structures.
84106 +*//***************************************************************************/
84107 +#ifndef __PART_INTEGRATION_EXT_H
84108 +#define __PART_INTEGRATION_EXT_H
84109 +
84110 +#include "std_ext.h"
84111 +#include "ddr_std_ext.h"
84112 +#include "enet_ext.h"
84113 +#include "dpaa_integration_ext.h"
84114 +
84115 +
84116 +/**************************************************************************//**
84117 + @Group T4240_chip_id T4240 Application Programming Interface
84118 +
84119 + @Description T4240 Chip functions,definitions and enums.
84120 +
84121 + @{
84122 +*//***************************************************************************/
84123 +
84124 +#define CORE_E6500
84125 +
84126 +#define INTG_MAX_NUM_OF_CORES 24
84127 +
84128 +
84129 +/**************************************************************************//**
84130 + @Description Module types.
84131 +*//***************************************************************************/
84132 +typedef enum e_ModuleId
84133 +{
84134 + e_MODULE_ID_DUART_1 = 0,
84135 + e_MODULE_ID_DUART_2,
84136 + e_MODULE_ID_DUART_3,
84137 + e_MODULE_ID_DUART_4,
84138 + e_MODULE_ID_LAW,
84139 + e_MODULE_ID_IFC,
84140 + e_MODULE_ID_PAMU,
84141 + e_MODULE_ID_QM, /**< Queue manager module */
84142 + e_MODULE_ID_BM, /**< Buffer manager module */
84143 + e_MODULE_ID_QM_CE_PORTAL_0,
84144 + e_MODULE_ID_QM_CI_PORTAL_0,
84145 + e_MODULE_ID_QM_CE_PORTAL_1,
84146 + e_MODULE_ID_QM_CI_PORTAL_1,
84147 + e_MODULE_ID_QM_CE_PORTAL_2,
84148 + e_MODULE_ID_QM_CI_PORTAL_2,
84149 + e_MODULE_ID_QM_CE_PORTAL_3,
84150 + e_MODULE_ID_QM_CI_PORTAL_3,
84151 + e_MODULE_ID_QM_CE_PORTAL_4,
84152 + e_MODULE_ID_QM_CI_PORTAL_4,
84153 + e_MODULE_ID_QM_CE_PORTAL_5,
84154 + e_MODULE_ID_QM_CI_PORTAL_5,
84155 + e_MODULE_ID_QM_CE_PORTAL_6,
84156 + e_MODULE_ID_QM_CI_PORTAL_6,
84157 + e_MODULE_ID_QM_CE_PORTAL_7,
84158 + e_MODULE_ID_QM_CI_PORTAL_7,
84159 + e_MODULE_ID_QM_CE_PORTAL_8,
84160 + e_MODULE_ID_QM_CI_PORTAL_8,
84161 + e_MODULE_ID_QM_CE_PORTAL_9,
84162 + e_MODULE_ID_QM_CI_PORTAL_9,
84163 + e_MODULE_ID_BM_CE_PORTAL_0,
84164 + e_MODULE_ID_BM_CI_PORTAL_0,
84165 + e_MODULE_ID_BM_CE_PORTAL_1,
84166 + e_MODULE_ID_BM_CI_PORTAL_1,
84167 + e_MODULE_ID_BM_CE_PORTAL_2,
84168 + e_MODULE_ID_BM_CI_PORTAL_2,
84169 + e_MODULE_ID_BM_CE_PORTAL_3,
84170 + e_MODULE_ID_BM_CI_PORTAL_3,
84171 + e_MODULE_ID_BM_CE_PORTAL_4,
84172 + e_MODULE_ID_BM_CI_PORTAL_4,
84173 + e_MODULE_ID_BM_CE_PORTAL_5,
84174 + e_MODULE_ID_BM_CI_PORTAL_5,
84175 + e_MODULE_ID_BM_CE_PORTAL_6,
84176 + e_MODULE_ID_BM_CI_PORTAL_6,
84177 + e_MODULE_ID_BM_CE_PORTAL_7,
84178 + e_MODULE_ID_BM_CI_PORTAL_7,
84179 + e_MODULE_ID_BM_CE_PORTAL_8,
84180 + e_MODULE_ID_BM_CI_PORTAL_8,
84181 + e_MODULE_ID_BM_CE_PORTAL_9,
84182 + e_MODULE_ID_BM_CI_PORTAL_9,
84183 + e_MODULE_ID_FM, /**< Frame manager module */
84184 + e_MODULE_ID_FM_RTC, /**< FM Real-Time-Clock */
84185 + e_MODULE_ID_FM_MURAM, /**< FM Multi-User-RAM */
84186 + e_MODULE_ID_FM_BMI, /**< FM BMI block */
84187 + e_MODULE_ID_FM_QMI, /**< FM QMI block */
84188 + e_MODULE_ID_FM_PARSER, /**< FM parser block */
84189 + e_MODULE_ID_FM_PORT_HO1, /**< FM Host-command/offline-parsing port block */
84190 + e_MODULE_ID_FM_PORT_HO2, /**< FM Host-command/offline-parsing port block */
84191 + e_MODULE_ID_FM_PORT_HO3, /**< FM Host-command/offline-parsing port block */
84192 + e_MODULE_ID_FM_PORT_HO4, /**< FM Host-command/offline-parsing port block */
84193 + e_MODULE_ID_FM_PORT_HO5, /**< FM Host-command/offline-parsing port block */
84194 + e_MODULE_ID_FM_PORT_HO6, /**< FM Host-command/offline-parsing port block */
84195 + e_MODULE_ID_FM_PORT_HO7, /**< FM Host-command/offline-parsing port block */
84196 + e_MODULE_ID_FM_PORT_1GRx1, /**< FM Rx 1G MAC port block */
84197 + e_MODULE_ID_FM_PORT_1GRx2, /**< FM Rx 1G MAC port block */
84198 + e_MODULE_ID_FM_PORT_1GRx3, /**< FM Rx 1G MAC port block */
84199 + e_MODULE_ID_FM_PORT_1GRx4, /**< FM Rx 1G MAC port block */
84200 + e_MODULE_ID_FM_PORT_1GRx5, /**< FM Rx 1G MAC port block */
84201 + e_MODULE_ID_FM_PORT_1GRx6, /**< FM Rx 1G MAC port block */
84202 + e_MODULE_ID_FM_PORT_10GRx1, /**< FM Rx 10G MAC port block */
84203 + e_MODULE_ID_FM_PORT_10GRx2, /**< FM Rx 10G MAC port block */
84204 + e_MODULE_ID_FM_PORT_1GTx1, /**< FM Tx 1G MAC port block */
84205 + e_MODULE_ID_FM_PORT_1GTx2, /**< FM Tx 1G MAC port block */
84206 + e_MODULE_ID_FM_PORT_1GTx3, /**< FM Tx 1G MAC port block */
84207 + e_MODULE_ID_FM_PORT_1GTx4, /**< FM Tx 1G MAC port block */
84208 + e_MODULE_ID_FM_PORT_1GTx5, /**< FM Tx 1G MAC port block */
84209 + e_MODULE_ID_FM_PORT_1GTx6, /**< FM Tx 1G MAC port block */
84210 + e_MODULE_ID_FM_PORT_10GTx1, /**< FM Tx 10G MAC port block */
84211 + e_MODULE_ID_FM_PORT_10GTx2, /**< FM Tx 10G MAC port block */
84212 + e_MODULE_ID_FM_PLCR, /**< FM Policer */
84213 + e_MODULE_ID_FM_KG, /**< FM Keygen */
84214 + e_MODULE_ID_FM_DMA, /**< FM DMA */
84215 + e_MODULE_ID_FM_FPM, /**< FM FPM */
84216 + e_MODULE_ID_FM_IRAM, /**< FM Instruction-RAM */
84217 + e_MODULE_ID_FM_1GMDIO, /**< FM 1G MDIO MAC */
84218 + e_MODULE_ID_FM_10GMDIO, /**< FM 10G MDIO */
84219 + e_MODULE_ID_FM_PRS_IRAM, /**< FM SW-parser Instruction-RAM */
84220 + e_MODULE_ID_FM_1GMAC1, /**< FM 1G MAC #1 */
84221 + e_MODULE_ID_FM_1GMAC2, /**< FM 1G MAC #2 */
84222 + e_MODULE_ID_FM_1GMAC3, /**< FM 1G MAC #3 */
84223 + e_MODULE_ID_FM_1GMAC4, /**< FM 1G MAC #4 */
84224 + e_MODULE_ID_FM_1GMAC5, /**< FM 1G MAC #5 */
84225 + e_MODULE_ID_FM_1GMAC6, /**< FM 1G MAC #6 */
84226 + e_MODULE_ID_FM_10GMAC1, /**< FM 10G MAC */
84227 + e_MODULE_ID_FM_10GMAC2, /**< FM 10G MAC */
84228 +
84229 + e_MODULE_ID_SEC_GEN, /**< SEC 4.0 General registers */
84230 + e_MODULE_ID_SEC_QI, /**< SEC 4.0 QI registers */
84231 + e_MODULE_ID_SEC_JQ0, /**< SEC 4.0 JQ-0 registers */
84232 + e_MODULE_ID_SEC_JQ1, /**< SEC 4.0 JQ-1 registers */
84233 + e_MODULE_ID_SEC_JQ2, /**< SEC 4.0 JQ-2 registers */
84234 + e_MODULE_ID_SEC_JQ3, /**< SEC 4.0 JQ-3 registers */
84235 + e_MODULE_ID_SEC_RTIC, /**< SEC 4.0 RTIC registers */
84236 + e_MODULE_ID_SEC_DECO0_CCB0, /**< SEC 4.0 DECO-0/CCB-0 registers */
84237 + e_MODULE_ID_SEC_DECO1_CCB1, /**< SEC 4.0 DECO-1/CCB-1 registers */
84238 + e_MODULE_ID_SEC_DECO2_CCB2, /**< SEC 4.0 DECO-2/CCB-2 registers */
84239 + e_MODULE_ID_SEC_DECO3_CCB3, /**< SEC 4.0 DECO-3/CCB-3 registers */
84240 + e_MODULE_ID_SEC_DECO4_CCB4, /**< SEC 4.0 DECO-4/CCB-4 registers */
84241 +
84242 + e_MODULE_ID_PIC, /**< PIC */
84243 + e_MODULE_ID_GPIO, /**< GPIO */
84244 + e_MODULE_ID_SERDES, /**< SERDES */
84245 + e_MODULE_ID_CPC_1, /**< CoreNet-Platform-Cache 1 */
84246 + e_MODULE_ID_CPC_2, /**< CoreNet-Platform-Cache 2 */
84247 +
84248 + e_MODULE_ID_SRIO_PORTS, /**< RapidIO controller */
84249 +
84250 + e_MODULE_ID_DUMMY_LAST
84251 +} e_ModuleId;
84252 +
84253 +#define NUM_OF_MODULES e_MODULE_ID_DUMMY_LAST
84254 +
84255 +#if 0 /* using unified values */
84256 +/*****************************************************************************
84257 + INTEGRATION-SPECIFIC MODULE CODES
84258 +******************************************************************************/
84259 +#define MODULE_UNKNOWN 0x00000000
84260 +#define MODULE_MEM 0x00010000
84261 +#define MODULE_MM 0x00020000
84262 +#define MODULE_CORE 0x00030000
84263 +#define MODULE_T4240 0x00040000
84264 +#define MODULE_T4240_PLATFORM 0x00050000
84265 +#define MODULE_PM 0x00060000
84266 +#define MODULE_MMU 0x00070000
84267 +#define MODULE_PIC 0x00080000
84268 +#define MODULE_CPC 0x00090000
84269 +#define MODULE_DUART 0x000a0000
84270 +#define MODULE_SERDES 0x000b0000
84271 +#define MODULE_PIO 0x000c0000
84272 +#define MODULE_QM 0x000d0000
84273 +#define MODULE_BM 0x000e0000
84274 +#define MODULE_SEC 0x000f0000
84275 +#define MODULE_LAW 0x00100000
84276 +#define MODULE_LBC 0x00110000
84277 +#define MODULE_PAMU 0x00120000
84278 +#define MODULE_FM 0x00130000
84279 +#define MODULE_FM_MURAM 0x00140000
84280 +#define MODULE_FM_PCD 0x00150000
84281 +#define MODULE_FM_RTC 0x00160000
84282 +#define MODULE_FM_MAC 0x00170000
84283 +#define MODULE_FM_PORT 0x00180000
84284 +#define MODULE_FM_SP 0x00190000
84285 +#define MODULE_DPA_PORT 0x001a0000
84286 +#define MODULE_MII 0x001b0000
84287 +#define MODULE_I2C 0x001c0000
84288 +#define MODULE_DMA 0x001d0000
84289 +#define MODULE_DDR 0x001e0000
84290 +#define MODULE_ESPI 0x001f0000
84291 +#define MODULE_DPAA_IPSEC 0x00200000
84292 +#endif /* using unified values */
84293 +
84294 +/*****************************************************************************
84295 + PAMU INTEGRATION-SPECIFIC DEFINITIONS
84296 +******************************************************************************/
84297 +#define PAMU_NUM_OF_PARTITIONS 4
84298 +
84299 +/*****************************************************************************
84300 + LAW INTEGRATION-SPECIFIC DEFINITIONS
84301 +******************************************************************************/
84302 +#define LAW_NUM_OF_WINDOWS 32
84303 +#define LAW_MIN_WINDOW_SIZE 0x0000000000001000LL /**< 4 Kbytes */
84304 +#define LAW_MAX_WINDOW_SIZE 0x0000010000000000LL /**< 1 Tbytes for 40-bit address space */
84305 +
84306 +
84307 +/*****************************************************************************
84308 + LBC INTEGRATION-SPECIFIC DEFINITIONS
84309 +******************************************************************************/
84310 +/**************************************************************************//**
84311 + @Group lbc_exception_grp LBC Exception Unit
84312 +
84313 + @Description LBC Exception unit API functions, definitions and enums
84314 +
84315 + @{
84316 +*//***************************************************************************/
84317 +
84318 +/**************************************************************************//**
84319 + @Anchor lbc_exbm
84320 +
84321 + @Collection LBC Errors Bit Mask
84322 +
84323 + These errors are reported through the exceptions callback..
84324 + The values can be or'ed in any combination in the errors mask
84325 + parameter of the errors report structure.
84326 +
84327 + These errors can also be passed as a bit-mask to
84328 + LBC_EnableErrorChecking() or LBC_DisableErrorChecking(),
84329 + for enabling or disabling error checking.
84330 + @{
84331 +*//***************************************************************************/
84332 +#define LBC_ERR_BUS_MONITOR 0x80000000 /**< Bus monitor error */
84333 +#define LBC_ERR_PARITY_ECC 0x20000000 /**< Parity error for GPCM/UPM */
84334 +#define LBC_ERR_WRITE_PROTECT 0x04000000 /**< Write protection error */
84335 +#define LBC_ERR_CHIP_SELECT 0x00080000 /**< Unrecognized chip select */
84336 +
84337 +#define LBC_ERR_ALL (LBC_ERR_BUS_MONITOR | LBC_ERR_PARITY_ECC | \
84338 + LBC_ERR_WRITE_PROTECT | LBC_ERR_CHIP_SELECT)
84339 + /**< All possible errors */
84340 +/* @} */
84341 +/** @} */ /* end of lbc_exception_grp group */
84342 +
84343 +#define LBC_INCORRECT_ERROR_REPORT_ERRATA
84344 +
84345 +#define LBC_NUM_OF_BANKS 8
84346 +#define LBC_MAX_CS_SIZE 0x0000000100000000LL /* Up to 4G memory block size */
84347 +#define LBC_PARITY_SUPPORT
84348 +#define LBC_ADDRESS_HOLD_TIME_CTRL
84349 +#define LBC_HIGH_CLK_DIVIDERS
84350 +#define LBC_FCM_AVAILABLE
84351 +
84352 +/*****************************************************************************
84353 + GPIO INTEGRATION-SPECIFIC DEFINITIONS
84354 +******************************************************************************/
84355 +#define GPIO_PORT_OFFSET_0x1000
84356 +
84357 +#define GPIO_NUM_OF_PORTS 3 /**< Number of ports in GPIO module;
84358 + Each port contains up to 32 I/O pins. */
84359 +
84360 +#define GPIO_VALID_PIN_MASKS \
84361 + { /* Port A */ 0xFFFFFFFF, \
84362 + /* Port B */ 0xFFFFFFFF, \
84363 + /* Port C */ 0xFFFFFFFF }
84364 +
84365 +#define GPIO_VALID_INTR_MASKS \
84366 + { /* Port A */ 0xFFFFFFFF, \
84367 + /* Port B */ 0xFFFFFFFF, \
84368 + /* Port C */ 0xFFFFFFFF }
84369 +
84370 +
84371 +
84372 +#endif /* __PART_INTEGRATION_EXT_H */
84373 --- /dev/null
84374 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3L/dpaa_integration_ext.h
84375 @@ -0,0 +1,292 @@
84376 +/*
84377 + * Copyright 2012 Freescale Semiconductor Inc.
84378 + *
84379 + * Redistribution and use in source and binary forms, with or without
84380 + * modification, are permitted provided that the following conditions are met:
84381 + * * Redistributions of source code must retain the above copyright
84382 + * notice, this list of conditions and the following disclaimer.
84383 + * * Redistributions in binary form must reproduce the above copyright
84384 + * notice, this list of conditions and the following disclaimer in the
84385 + * documentation and/or other materials provided with the distribution.
84386 + * * Neither the name of Freescale Semiconductor nor the
84387 + * names of its contributors may be used to endorse or promote products
84388 + * derived from this software without specific prior written permission.
84389 + *
84390 + *
84391 + * ALTERNATIVELY, this software may be distributed under the terms of the
84392 + * GNU General Public License ("GPL") as published by the Free Software
84393 + * Foundation, either version 2 of that License or (at your option) any
84394 + * later version.
84395 + *
84396 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
84397 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
84398 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
84399 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
84400 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
84401 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
84402 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
84403 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
84404 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
84405 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84406 + */
84407 +
84408 +/**
84409 +
84410 + @File dpaa_integration_ext.h
84411 +
84412 + @Description T4240 FM external definitions and structures.
84413 +*//***************************************************************************/
84414 +#ifndef __DPAA_INTEGRATION_EXT_H
84415 +#define __DPAA_INTEGRATION_EXT_H
84416 +
84417 +#include "std_ext.h"
84418 +
84419 +
84420 +#define DPAA_VERSION 11
84421 +
84422 +/**************************************************************************//**
84423 + @Description DPAA SW Portals Enumeration.
84424 +*//***************************************************************************/
84425 +typedef enum
84426 +{
84427 + e_DPAA_SWPORTAL0 = 0,
84428 + e_DPAA_SWPORTAL1,
84429 + e_DPAA_SWPORTAL2,
84430 + e_DPAA_SWPORTAL3,
84431 + e_DPAA_SWPORTAL4,
84432 + e_DPAA_SWPORTAL5,
84433 + e_DPAA_SWPORTAL6,
84434 + e_DPAA_SWPORTAL7,
84435 + e_DPAA_SWPORTAL8,
84436 + e_DPAA_SWPORTAL9,
84437 + e_DPAA_SWPORTAL10,
84438 + e_DPAA_SWPORTAL11,
84439 + e_DPAA_SWPORTAL12,
84440 + e_DPAA_SWPORTAL13,
84441 + e_DPAA_SWPORTAL14,
84442 + e_DPAA_SWPORTAL15,
84443 + e_DPAA_SWPORTAL16,
84444 + e_DPAA_SWPORTAL17,
84445 + e_DPAA_SWPORTAL18,
84446 + e_DPAA_SWPORTAL19,
84447 + e_DPAA_SWPORTAL20,
84448 + e_DPAA_SWPORTAL21,
84449 + e_DPAA_SWPORTAL22,
84450 + e_DPAA_SWPORTAL23,
84451 + e_DPAA_SWPORTAL24,
84452 + e_DPAA_SWPORTAL_DUMMY_LAST
84453 +} e_DpaaSwPortal;
84454 +
84455 +/**************************************************************************//**
84456 + @Description DPAA Direct Connect Portals Enumeration.
84457 +*//***************************************************************************/
84458 +typedef enum
84459 +{
84460 + e_DPAA_DCPORTAL0 = 0,
84461 + e_DPAA_DCPORTAL1,
84462 + e_DPAA_DCPORTAL2,
84463 + e_DPAA_DCPORTAL_DUMMY_LAST
84464 +} e_DpaaDcPortal;
84465 +
84466 +#define DPAA_MAX_NUM_OF_SW_PORTALS e_DPAA_SWPORTAL_DUMMY_LAST
84467 +#define DPAA_MAX_NUM_OF_DC_PORTALS e_DPAA_DCPORTAL_DUMMY_LAST
84468 +
84469 +/*****************************************************************************
84470 + QMan INTEGRATION-SPECIFIC DEFINITIONS
84471 +******************************************************************************/
84472 +#define QM_MAX_NUM_OF_POOL_CHANNELS 15 /**< Total number of channels, dedicated and pool */
84473 +#define QM_MAX_NUM_OF_WQ 8 /**< Number of work queues per channel */
84474 +#define QM_MAX_NUM_OF_CGS 256 /**< Congestion groups number */
84475 +#define QM_MAX_NUM_OF_FQIDS (16 * MEGABYTE)
84476 + /**< FQIDs range - 24 bits */
84477 +
84478 +/**************************************************************************//**
84479 + @Description Work Queue Channel assignments in QMan.
84480 +*//***************************************************************************/
84481 +typedef enum
84482 +{
84483 + e_QM_FQ_CHANNEL_SWPORTAL0 = 0x0, /**< Dedicated channels serviced by software portals 0 to 24 */
84484 + e_QM_FQ_CHANNEL_SWPORTAL1,
84485 + e_QM_FQ_CHANNEL_SWPORTAL2,
84486 + e_QM_FQ_CHANNEL_SWPORTAL3,
84487 + e_QM_FQ_CHANNEL_SWPORTAL4,
84488 + e_QM_FQ_CHANNEL_SWPORTAL5,
84489 + e_QM_FQ_CHANNEL_SWPORTAL6,
84490 + e_QM_FQ_CHANNEL_SWPORTAL7,
84491 + e_QM_FQ_CHANNEL_SWPORTAL8,
84492 + e_QM_FQ_CHANNEL_SWPORTAL9,
84493 + e_QM_FQ_CHANNEL_SWPORTAL10,
84494 + e_QM_FQ_CHANNEL_SWPORTAL11,
84495 + e_QM_FQ_CHANNEL_SWPORTAL12,
84496 + e_QM_FQ_CHANNEL_SWPORTAL13,
84497 + e_QM_FQ_CHANNEL_SWPORTAL14,
84498 + e_QM_FQ_CHANNEL_SWPORTAL15,
84499 + e_QM_FQ_CHANNEL_SWPORTAL16,
84500 + e_QM_FQ_CHANNEL_SWPORTAL17,
84501 + e_QM_FQ_CHANNEL_SWPORTAL18,
84502 + e_QM_FQ_CHANNEL_SWPORTAL19,
84503 + e_QM_FQ_CHANNEL_SWPORTAL20,
84504 + e_QM_FQ_CHANNEL_SWPORTAL21,
84505 + e_QM_FQ_CHANNEL_SWPORTAL22,
84506 + e_QM_FQ_CHANNEL_SWPORTAL23,
84507 + e_QM_FQ_CHANNEL_SWPORTAL24,
84508 +
84509 + e_QM_FQ_CHANNEL_POOL1 = 0x401, /**< Pool channels that can be serviced by any of the software portals */
84510 + e_QM_FQ_CHANNEL_POOL2,
84511 + e_QM_FQ_CHANNEL_POOL3,
84512 + e_QM_FQ_CHANNEL_POOL4,
84513 + e_QM_FQ_CHANNEL_POOL5,
84514 + e_QM_FQ_CHANNEL_POOL6,
84515 + e_QM_FQ_CHANNEL_POOL7,
84516 + e_QM_FQ_CHANNEL_POOL8,
84517 + e_QM_FQ_CHANNEL_POOL9,
84518 + e_QM_FQ_CHANNEL_POOL10,
84519 + e_QM_FQ_CHANNEL_POOL11,
84520 + e_QM_FQ_CHANNEL_POOL12,
84521 + e_QM_FQ_CHANNEL_POOL13,
84522 + e_QM_FQ_CHANNEL_POOL14,
84523 + e_QM_FQ_CHANNEL_POOL15,
84524 +
84525 + e_QM_FQ_CHANNEL_FMAN0_SP0 = 0x800, /**< Dedicated channels serviced by Direct Connect Portal 0:
84526 + connected to FMan 0; assigned in incrementing order to
84527 + each sub-portal (SP) in the portal */
84528 + e_QM_FQ_CHANNEL_FMAN0_SP1,
84529 + e_QM_FQ_CHANNEL_FMAN0_SP2,
84530 + e_QM_FQ_CHANNEL_FMAN0_SP3,
84531 + e_QM_FQ_CHANNEL_FMAN0_SP4,
84532 + e_QM_FQ_CHANNEL_FMAN0_SP5,
84533 + e_QM_FQ_CHANNEL_FMAN0_SP6,
84534 + e_QM_FQ_CHANNEL_FMAN0_SP7,
84535 + e_QM_FQ_CHANNEL_FMAN0_SP8,
84536 + e_QM_FQ_CHANNEL_FMAN0_SP9,
84537 + e_QM_FQ_CHANNEL_FMAN0_SP10,
84538 + e_QM_FQ_CHANNEL_FMAN0_SP11,
84539 + e_QM_FQ_CHANNEL_FMAN0_SP12,
84540 + e_QM_FQ_CHANNEL_FMAN0_SP13,
84541 + e_QM_FQ_CHANNEL_FMAN0_SP14,
84542 + e_QM_FQ_CHANNEL_FMAN0_SP15,
84543 +
84544 + e_QM_FQ_CHANNEL_RMAN_SP0 = 0x820, /**< Dedicated channels serviced by Direct Connect Portal 1: connected to RMan */
84545 + e_QM_FQ_CHANNEL_RMAN_SP1,
84546 +
84547 + e_QM_FQ_CHANNEL_CAAM = 0x840 /**< Dedicated channel serviced by Direct Connect Portal 2:
84548 + connected to SEC */
84549 +} e_QmFQChannel;
84550 +
84551 +/*****************************************************************************
84552 + BMan INTEGRATION-SPECIFIC DEFINITIONS
84553 +******************************************************************************/
84554 +#define BM_MAX_NUM_OF_POOLS 64 /**< Number of buffers pools */
84555 +
84556 +/*****************************************************************************
84557 + SEC INTEGRATION-SPECIFIC DEFINITIONS
84558 +******************************************************************************/
84559 +#define SEC_NUM_OF_DECOS 3
84560 +#define SEC_ALL_DECOS_MASK 0x00000003
84561 +
84562 +
84563 +/*****************************************************************************
84564 + FM INTEGRATION-SPECIFIC DEFINITIONS
84565 +******************************************************************************/
84566 +#define INTG_MAX_NUM_OF_FM 1
84567 +/* Ports defines */
84568 +#define FM_MAX_NUM_OF_1G_MACS 5
84569 +#define FM_MAX_NUM_OF_10G_MACS 1
84570 +#define FM_MAX_NUM_OF_MACS (FM_MAX_NUM_OF_1G_MACS + FM_MAX_NUM_OF_10G_MACS)
84571 +#define FM_MAX_NUM_OF_OH_PORTS 4
84572 +
84573 +#define FM_MAX_NUM_OF_1G_RX_PORTS FM_MAX_NUM_OF_1G_MACS
84574 +#define FM_MAX_NUM_OF_10G_RX_PORTS FM_MAX_NUM_OF_10G_MACS
84575 +#define FM_MAX_NUM_OF_RX_PORTS (FM_MAX_NUM_OF_10G_RX_PORTS + FM_MAX_NUM_OF_1G_RX_PORTS)
84576 +
84577 +#define FM_MAX_NUM_OF_1G_TX_PORTS FM_MAX_NUM_OF_1G_MACS
84578 +#define FM_MAX_NUM_OF_10G_TX_PORTS FM_MAX_NUM_OF_10G_MACS
84579 +#define FM_MAX_NUM_OF_TX_PORTS (FM_MAX_NUM_OF_10G_TX_PORTS + FM_MAX_NUM_OF_1G_TX_PORTS)
84580 +
84581 +#define FM_MAX_NUM_OF_MACSECS 1 /* Should be updated */
84582 +
84583 +#define FM_PORT_MAX_NUM_OF_EXT_POOLS 4 /**< Number of external BM pools per Rx port */
84584 +#define FM_PORT_NUM_OF_CONGESTION_GRPS 256 /**< Total number of congestion groups in QM */
84585 +#define FM_MAX_NUM_OF_SUB_PORTALS 16
84586 +#define FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS 0
84587 +
84588 +#define FM_VSP_MAX_NUM_OF_ENTRIES 32
84589 +#define FM_MAX_NUM_OF_PFC_PRIORITIES 8
84590 +
84591 +/* RAMs defines */
84592 +#define FM_MURAM_SIZE (192 * KILOBYTE)
84593 +#define FM_IRAM_SIZE(major, minor) \
84594 + (((major == 6) && ((minor == 4) )) ? (64 * KILOBYTE) : (32 * KILOBYTE))
84595 +#define FM_NUM_OF_CTRL 2
84596 +
84597 +/* PCD defines */
84598 +#define FM_PCD_PLCR_NUM_ENTRIES 256 /**< Total number of policer profiles */
84599 +#define FM_PCD_KG_NUM_OF_SCHEMES 32 /**< Total number of KG schemes */
84600 +#define FM_PCD_MAX_NUM_OF_CLS_PLANS 256 /**< Number of classification plan entries. */
84601 +#define FM_PCD_PRS_SW_PATCHES_SIZE 0x00000600 /**< Number of bytes saved for patches */
84602 +#define FM_PCD_SW_PRS_SIZE 0x00000800 /**< Total size of SW parser area */
84603 +
84604 +/* RTC defines */
84605 +#define FM_RTC_NUM_OF_ALARMS 2 /**< RTC number of alarms */
84606 +#define FM_RTC_NUM_OF_PERIODIC_PULSES 3 /**< RTC number of periodic pulses */
84607 +#define FM_RTC_NUM_OF_EXT_TRIGGERS 2 /**< RTC number of external triggers */
84608 +
84609 +/* QMI defines */
84610 +#define QMI_MAX_NUM_OF_TNUMS 64
84611 +#define QMI_DEF_TNUMS_THRESH 32
84612 +/* FPM defines */
84613 +#define FM_NUM_OF_FMAN_CTRL_EVENT_REGS 4
84614 +
84615 +/* DMA defines */
84616 +#define DMA_THRESH_MAX_COMMQ 83
84617 +#define DMA_THRESH_MAX_BUF 127
84618 +
84619 +/* BMI defines */
84620 +#define BMI_MAX_NUM_OF_TASKS 64
84621 +#define BMI_MAX_NUM_OF_DMAS 32
84622 +
84623 +#define BMI_MAX_FIFO_SIZE (FM_MURAM_SIZE)
84624 +#define PORT_MAX_WEIGHT 16
84625 +
84626 +#define FM_CHECK_PORT_RESTRICTIONS(__validPorts, __newPortIndx) TRUE
84627 +
84628 +/* Unique T4240 */
84629 +#define FM_OP_OPEN_DMA_MIN_LIMIT
84630 +#define FM_NO_RESTRICT_ON_ACCESS_RSRC
84631 +#define FM_NO_OP_OBSERVED_POOLS
84632 +#define FM_FRAME_END_PARAMS_FOR_OP
84633 +#define FM_DEQ_PIPELINE_PARAMS_FOR_OP
84634 +#define FM_QMI_NO_SINGLE_ECC_EXCEPTION
84635 +
84636 +#define FM_NO_GUARANTEED_RESET_VALUES
84637 +
84638 +/* FM errata */
84639 +#define FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669
84640 +#define FM_RX_FIFO_CORRUPT_ERRATA_10GMAC_A006320
84641 +#define FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675
84642 +#define FM_HEAVY_TRAFFIC_SEQUENCER_HANG_ERRATA_FMAN_A006981
84643 +
84644 +#define FM_BCB_ERRATA_BMI_SW001
84645 +#define FM_LEN_CHECK_ERRATA_FMAN_SW002
84646 +#define FM_AID_MODE_NO_TNUM_SW005 /* refer to pdm TKT068794 - only support of port_id on aid */
84647 +#define FM_ERROR_VSP_NO_MATCH_SW006 /* refer to pdm TKT174304 - no match between errorQ and VSP */
84648 +
84649 +/*****************************************************************************
84650 + RMan INTEGRATION-SPECIFIC DEFINITIONS
84651 +******************************************************************************/
84652 +#define RM_MAX_NUM_OF_IB 4 /**< Number of inbound blocks */
84653 +#define RM_NUM_OF_IBCU 8 /**< NUmber of classification units in an inbound block */
84654 +
84655 +/* RMan erratas */
84656 +#define RM_ERRONEOUS_ACK_ERRATA_RMAN_A006756
84657 +
84658 +/*****************************************************************************
84659 + FM MACSEC INTEGRATION-SPECIFIC DEFINITIONS
84660 +******************************************************************************/
84661 +#define NUM_OF_RX_SC 16
84662 +#define NUM_OF_TX_SC 16
84663 +
84664 +#define NUM_OF_SA_PER_RX_SC 2
84665 +#define NUM_OF_SA_PER_TX_SC 2
84666 +
84667 +#endif /* __DPAA_INTEGRATION_EXT_H */
84668 --- /dev/null
84669 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3L/part_ext.h
84670 @@ -0,0 +1,59 @@
84671 +/*
84672 + * Copyright 2012 Freescale Semiconductor Inc.
84673 + *
84674 + * Redistribution and use in source and binary forms, with or without
84675 + * modification, are permitted provided that the following conditions are met:
84676 + * * Redistributions of source code must retain the above copyright
84677 + * notice, this list of conditions and the following disclaimer.
84678 + * * Redistributions in binary form must reproduce the above copyright
84679 + * notice, this list of conditions and the following disclaimer in the
84680 + * documentation and/or other materials provided with the distribution.
84681 + * * Neither the name of Freescale Semiconductor nor the
84682 + * names of its contributors may be used to endorse or promote products
84683 + * derived from this software without specific prior written permission.
84684 + *
84685 + *
84686 + * ALTERNATIVELY, this software may be distributed under the terms of the
84687 + * GNU General Public License ("GPL") as published by the Free Software
84688 + * Foundation, either version 2 of that License or (at your option) any
84689 + * later version.
84690 + *
84691 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
84692 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
84693 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
84694 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
84695 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
84696 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
84697 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
84698 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
84699 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
84700 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84701 + */
84702 +
84703 +/**************************************************************************//**
84704 +
84705 + @File part_ext.h
84706 +
84707 + @Description Definitions for the part (integration) module.
84708 +*//***************************************************************************/
84709 +
84710 +#ifndef __PART_EXT_H
84711 +#define __PART_EXT_H
84712 +
84713 +#include "std_ext.h"
84714 +#include "part_integration_ext.h"
84715 +
84716 +/**************************************************************************//*
84717 + @Description Part data structure - must be contained in any integration
84718 + data structure.
84719 +*//***************************************************************************/
84720 +typedef struct t_Part
84721 +{
84722 + uintptr_t (* f_GetModuleBase)(t_Handle h_Part, e_ModuleId moduleId);
84723 + /**< Returns the address of the module's memory map base. */
84724 + e_ModuleId (* f_GetModuleIdByBase)(t_Handle h_Part, uintptr_t baseAddress);
84725 + /**< Returns the module's ID according to its memory map base. */
84726 +} t_Part;
84727 +
84728 +
84729 +#endif /* __PART_EXT_H */
84730 --- /dev/null
84731 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3L/part_integration_ext.h
84732 @@ -0,0 +1,304 @@
84733 +/*
84734 + * Copyright 2008-2012 Freescale Semiconductor Inc.
84735 + *
84736 + * Redistribution and use in source and binary forms, with or without
84737 + * modification, are permitted provided that the following conditions are met:
84738 + * * Redistributions of source code must retain the above copyright
84739 + * notice, this list of conditions and the following disclaimer.
84740 + * * Redistributions in binary form must reproduce the above copyright
84741 + * notice, this list of conditions and the following disclaimer in the
84742 + * documentation and/or other materials provided with the distribution.
84743 + * * Neither the name of Freescale Semiconductor nor the
84744 + * names of its contributors may be used to endorse or promote products
84745 + * derived from this software without specific prior written permission.
84746 + *
84747 + *
84748 + * ALTERNATIVELY, this software may be distributed under the terms of the
84749 + * GNU General Public License ("GPL") as published by the Free Software
84750 + * Foundation, either version 2 of that License or (at your option) any
84751 + * later version.
84752 + *
84753 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
84754 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
84755 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
84756 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
84757 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
84758 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
84759 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
84760 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
84761 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
84762 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84763 + */
84764 +
84765 +/**
84766 +
84767 + @File part_integration_ext.h
84768 +
84769 + @Description T4240 external definitions and structures.
84770 +*//***************************************************************************/
84771 +#ifndef __PART_INTEGRATION_EXT_H
84772 +#define __PART_INTEGRATION_EXT_H
84773 +
84774 +#include "std_ext.h"
84775 +#include "ddr_std_ext.h"
84776 +#include "enet_ext.h"
84777 +#include "dpaa_integration_ext.h"
84778 +
84779 +
84780 +/**************************************************************************//**
84781 + @Group T4240_chip_id T4240 Application Programming Interface
84782 +
84783 + @Description T4240 Chip functions,definitions and enums.
84784 +
84785 + @{
84786 +*//***************************************************************************/
84787 +
84788 +#define CORE_E6500
84789 +
84790 +#define INTG_MAX_NUM_OF_CORES 24
84791 +
84792 +
84793 +/**************************************************************************//**
84794 + @Description Module types.
84795 +*//***************************************************************************/
84796 +typedef enum e_ModuleId
84797 +{
84798 + e_MODULE_ID_DUART_1 = 0,
84799 + e_MODULE_ID_DUART_2,
84800 + e_MODULE_ID_DUART_3,
84801 + e_MODULE_ID_DUART_4,
84802 + e_MODULE_ID_LAW,
84803 + e_MODULE_ID_IFC,
84804 + e_MODULE_ID_PAMU,
84805 + e_MODULE_ID_QM, /**< Queue manager module */
84806 + e_MODULE_ID_BM, /**< Buffer manager module */
84807 + e_MODULE_ID_QM_CE_PORTAL_0,
84808 + e_MODULE_ID_QM_CI_PORTAL_0,
84809 + e_MODULE_ID_QM_CE_PORTAL_1,
84810 + e_MODULE_ID_QM_CI_PORTAL_1,
84811 + e_MODULE_ID_QM_CE_PORTAL_2,
84812 + e_MODULE_ID_QM_CI_PORTAL_2,
84813 + e_MODULE_ID_QM_CE_PORTAL_3,
84814 + e_MODULE_ID_QM_CI_PORTAL_3,
84815 + e_MODULE_ID_QM_CE_PORTAL_4,
84816 + e_MODULE_ID_QM_CI_PORTAL_4,
84817 + e_MODULE_ID_QM_CE_PORTAL_5,
84818 + e_MODULE_ID_QM_CI_PORTAL_5,
84819 + e_MODULE_ID_QM_CE_PORTAL_6,
84820 + e_MODULE_ID_QM_CI_PORTAL_6,
84821 + e_MODULE_ID_QM_CE_PORTAL_7,
84822 + e_MODULE_ID_QM_CI_PORTAL_7,
84823 + e_MODULE_ID_QM_CE_PORTAL_8,
84824 + e_MODULE_ID_QM_CI_PORTAL_8,
84825 + e_MODULE_ID_QM_CE_PORTAL_9,
84826 + e_MODULE_ID_QM_CI_PORTAL_9,
84827 + e_MODULE_ID_BM_CE_PORTAL_0,
84828 + e_MODULE_ID_BM_CI_PORTAL_0,
84829 + e_MODULE_ID_BM_CE_PORTAL_1,
84830 + e_MODULE_ID_BM_CI_PORTAL_1,
84831 + e_MODULE_ID_BM_CE_PORTAL_2,
84832 + e_MODULE_ID_BM_CI_PORTAL_2,
84833 + e_MODULE_ID_BM_CE_PORTAL_3,
84834 + e_MODULE_ID_BM_CI_PORTAL_3,
84835 + e_MODULE_ID_BM_CE_PORTAL_4,
84836 + e_MODULE_ID_BM_CI_PORTAL_4,
84837 + e_MODULE_ID_BM_CE_PORTAL_5,
84838 + e_MODULE_ID_BM_CI_PORTAL_5,
84839 + e_MODULE_ID_BM_CE_PORTAL_6,
84840 + e_MODULE_ID_BM_CI_PORTAL_6,
84841 + e_MODULE_ID_BM_CE_PORTAL_7,
84842 + e_MODULE_ID_BM_CI_PORTAL_7,
84843 + e_MODULE_ID_BM_CE_PORTAL_8,
84844 + e_MODULE_ID_BM_CI_PORTAL_8,
84845 + e_MODULE_ID_BM_CE_PORTAL_9,
84846 + e_MODULE_ID_BM_CI_PORTAL_9,
84847 + e_MODULE_ID_FM, /**< Frame manager module */
84848 + e_MODULE_ID_FM_RTC, /**< FM Real-Time-Clock */
84849 + e_MODULE_ID_FM_MURAM, /**< FM Multi-User-RAM */
84850 + e_MODULE_ID_FM_BMI, /**< FM BMI block */
84851 + e_MODULE_ID_FM_QMI, /**< FM QMI block */
84852 + e_MODULE_ID_FM_PARSER, /**< FM parser block */
84853 + e_MODULE_ID_FM_PORT_HO1, /**< FM Host-command/offline-parsing port block */
84854 + e_MODULE_ID_FM_PORT_HO2, /**< FM Host-command/offline-parsing port block */
84855 + e_MODULE_ID_FM_PORT_HO3, /**< FM Host-command/offline-parsing port block */
84856 + e_MODULE_ID_FM_PORT_HO4, /**< FM Host-command/offline-parsing port block */
84857 + e_MODULE_ID_FM_PORT_HO5, /**< FM Host-command/offline-parsing port block */
84858 + e_MODULE_ID_FM_PORT_HO6, /**< FM Host-command/offline-parsing port block */
84859 + e_MODULE_ID_FM_PORT_HO7, /**< FM Host-command/offline-parsing port block */
84860 + e_MODULE_ID_FM_PORT_1GRx1, /**< FM Rx 1G MAC port block */
84861 + e_MODULE_ID_FM_PORT_1GRx2, /**< FM Rx 1G MAC port block */
84862 + e_MODULE_ID_FM_PORT_1GRx3, /**< FM Rx 1G MAC port block */
84863 + e_MODULE_ID_FM_PORT_1GRx4, /**< FM Rx 1G MAC port block */
84864 + e_MODULE_ID_FM_PORT_1GRx5, /**< FM Rx 1G MAC port block */
84865 + e_MODULE_ID_FM_PORT_1GRx6, /**< FM Rx 1G MAC port block */
84866 + e_MODULE_ID_FM_PORT_10GRx1, /**< FM Rx 10G MAC port block */
84867 + e_MODULE_ID_FM_PORT_10GRx2, /**< FM Rx 10G MAC port block */
84868 + e_MODULE_ID_FM_PORT_1GTx1, /**< FM Tx 1G MAC port block */
84869 + e_MODULE_ID_FM_PORT_1GTx2, /**< FM Tx 1G MAC port block */
84870 + e_MODULE_ID_FM_PORT_1GTx3, /**< FM Tx 1G MAC port block */
84871 + e_MODULE_ID_FM_PORT_1GTx4, /**< FM Tx 1G MAC port block */
84872 + e_MODULE_ID_FM_PORT_1GTx5, /**< FM Tx 1G MAC port block */
84873 + e_MODULE_ID_FM_PORT_1GTx6, /**< FM Tx 1G MAC port block */
84874 + e_MODULE_ID_FM_PORT_10GTx1, /**< FM Tx 10G MAC port block */
84875 + e_MODULE_ID_FM_PORT_10GTx2, /**< FM Tx 10G MAC port block */
84876 + e_MODULE_ID_FM_PLCR, /**< FM Policer */
84877 + e_MODULE_ID_FM_KG, /**< FM Keygen */
84878 + e_MODULE_ID_FM_DMA, /**< FM DMA */
84879 + e_MODULE_ID_FM_FPM, /**< FM FPM */
84880 + e_MODULE_ID_FM_IRAM, /**< FM Instruction-RAM */
84881 + e_MODULE_ID_FM_1GMDIO, /**< FM 1G MDIO MAC */
84882 + e_MODULE_ID_FM_10GMDIO, /**< FM 10G MDIO */
84883 + e_MODULE_ID_FM_PRS_IRAM, /**< FM SW-parser Instruction-RAM */
84884 + e_MODULE_ID_FM_1GMAC1, /**< FM 1G MAC #1 */
84885 + e_MODULE_ID_FM_1GMAC2, /**< FM 1G MAC #2 */
84886 + e_MODULE_ID_FM_1GMAC3, /**< FM 1G MAC #3 */
84887 + e_MODULE_ID_FM_1GMAC4, /**< FM 1G MAC #4 */
84888 + e_MODULE_ID_FM_1GMAC5, /**< FM 1G MAC #5 */
84889 + e_MODULE_ID_FM_1GMAC6, /**< FM 1G MAC #6 */
84890 + e_MODULE_ID_FM_10GMAC1, /**< FM 10G MAC */
84891 + e_MODULE_ID_FM_10GMAC2, /**< FM 10G MAC */
84892 +
84893 + e_MODULE_ID_SEC_GEN, /**< SEC 4.0 General registers */
84894 + e_MODULE_ID_SEC_QI, /**< SEC 4.0 QI registers */
84895 + e_MODULE_ID_SEC_JQ0, /**< SEC 4.0 JQ-0 registers */
84896 + e_MODULE_ID_SEC_JQ1, /**< SEC 4.0 JQ-1 registers */
84897 + e_MODULE_ID_SEC_JQ2, /**< SEC 4.0 JQ-2 registers */
84898 + e_MODULE_ID_SEC_JQ3, /**< SEC 4.0 JQ-3 registers */
84899 + e_MODULE_ID_SEC_RTIC, /**< SEC 4.0 RTIC registers */
84900 + e_MODULE_ID_SEC_DECO0_CCB0, /**< SEC 4.0 DECO-0/CCB-0 registers */
84901 + e_MODULE_ID_SEC_DECO1_CCB1, /**< SEC 4.0 DECO-1/CCB-1 registers */
84902 + e_MODULE_ID_SEC_DECO2_CCB2, /**< SEC 4.0 DECO-2/CCB-2 registers */
84903 + e_MODULE_ID_SEC_DECO3_CCB3, /**< SEC 4.0 DECO-3/CCB-3 registers */
84904 + e_MODULE_ID_SEC_DECO4_CCB4, /**< SEC 4.0 DECO-4/CCB-4 registers */
84905 +
84906 + e_MODULE_ID_PIC, /**< PIC */
84907 + e_MODULE_ID_GPIO, /**< GPIO */
84908 + e_MODULE_ID_SERDES, /**< SERDES */
84909 + e_MODULE_ID_CPC_1, /**< CoreNet-Platform-Cache 1 */
84910 + e_MODULE_ID_CPC_2, /**< CoreNet-Platform-Cache 2 */
84911 +
84912 + e_MODULE_ID_SRIO_PORTS, /**< RapidIO controller */
84913 +
84914 + e_MODULE_ID_DUMMY_LAST
84915 +} e_ModuleId;
84916 +
84917 +#define NUM_OF_MODULES e_MODULE_ID_DUMMY_LAST
84918 +
84919 +#if 0 /* using unified values */
84920 +/*****************************************************************************
84921 + INTEGRATION-SPECIFIC MODULE CODES
84922 +******************************************************************************/
84923 +#define MODULE_UNKNOWN 0x00000000
84924 +#define MODULE_MEM 0x00010000
84925 +#define MODULE_MM 0x00020000
84926 +#define MODULE_CORE 0x00030000
84927 +#define MODULE_T4240 0x00040000
84928 +#define MODULE_T4240_PLATFORM 0x00050000
84929 +#define MODULE_PM 0x00060000
84930 +#define MODULE_MMU 0x00070000
84931 +#define MODULE_PIC 0x00080000
84932 +#define MODULE_CPC 0x00090000
84933 +#define MODULE_DUART 0x000a0000
84934 +#define MODULE_SERDES 0x000b0000
84935 +#define MODULE_PIO 0x000c0000
84936 +#define MODULE_QM 0x000d0000
84937 +#define MODULE_BM 0x000e0000
84938 +#define MODULE_SEC 0x000f0000
84939 +#define MODULE_LAW 0x00100000
84940 +#define MODULE_LBC 0x00110000
84941 +#define MODULE_PAMU 0x00120000
84942 +#define MODULE_FM 0x00130000
84943 +#define MODULE_FM_MURAM 0x00140000
84944 +#define MODULE_FM_PCD 0x00150000
84945 +#define MODULE_FM_RTC 0x00160000
84946 +#define MODULE_FM_MAC 0x00170000
84947 +#define MODULE_FM_PORT 0x00180000
84948 +#define MODULE_FM_SP 0x00190000
84949 +#define MODULE_DPA_PORT 0x001a0000
84950 +#define MODULE_MII 0x001b0000
84951 +#define MODULE_I2C 0x001c0000
84952 +#define MODULE_DMA 0x001d0000
84953 +#define MODULE_DDR 0x001e0000
84954 +#define MODULE_ESPI 0x001f0000
84955 +#define MODULE_DPAA_IPSEC 0x00200000
84956 +#endif /* using unified values */
84957 +
84958 +/*****************************************************************************
84959 + PAMU INTEGRATION-SPECIFIC DEFINITIONS
84960 +******************************************************************************/
84961 +#define PAMU_NUM_OF_PARTITIONS 4
84962 +
84963 +/*****************************************************************************
84964 + LAW INTEGRATION-SPECIFIC DEFINITIONS
84965 +******************************************************************************/
84966 +#define LAW_NUM_OF_WINDOWS 32
84967 +#define LAW_MIN_WINDOW_SIZE 0x0000000000001000LL /**< 4 Kbytes */
84968 +#define LAW_MAX_WINDOW_SIZE 0x0000010000000000LL /**< 1 Tbytes for 40-bit address space */
84969 +
84970 +
84971 +/*****************************************************************************
84972 + LBC INTEGRATION-SPECIFIC DEFINITIONS
84973 +******************************************************************************/
84974 +/**************************************************************************//**
84975 + @Group lbc_exception_grp LBC Exception Unit
84976 +
84977 + @Description LBC Exception unit API functions, definitions and enums
84978 +
84979 + @{
84980 +*//***************************************************************************/
84981 +
84982 +/**************************************************************************//**
84983 + @Anchor lbc_exbm
84984 +
84985 + @Collection LBC Errors Bit Mask
84986 +
84987 + These errors are reported through the exceptions callback..
84988 + The values can be or'ed in any combination in the errors mask
84989 + parameter of the errors report structure.
84990 +
84991 + These errors can also be passed as a bit-mask to
84992 + LBC_EnableErrorChecking() or LBC_DisableErrorChecking(),
84993 + for enabling or disabling error checking.
84994 + @{
84995 +*//***************************************************************************/
84996 +#define LBC_ERR_BUS_MONITOR 0x80000000 /**< Bus monitor error */
84997 +#define LBC_ERR_PARITY_ECC 0x20000000 /**< Parity error for GPCM/UPM */
84998 +#define LBC_ERR_WRITE_PROTECT 0x04000000 /**< Write protection error */
84999 +#define LBC_ERR_CHIP_SELECT 0x00080000 /**< Unrecognized chip select */
85000 +
85001 +#define LBC_ERR_ALL (LBC_ERR_BUS_MONITOR | LBC_ERR_PARITY_ECC | \
85002 + LBC_ERR_WRITE_PROTECT | LBC_ERR_CHIP_SELECT)
85003 + /**< All possible errors */
85004 +/* @} */
85005 +/** @} */ /* end of lbc_exception_grp group */
85006 +
85007 +#define LBC_INCORRECT_ERROR_REPORT_ERRATA
85008 +
85009 +#define LBC_NUM_OF_BANKS 8
85010 +#define LBC_MAX_CS_SIZE 0x0000000100000000LL /* Up to 4G memory block size */
85011 +#define LBC_PARITY_SUPPORT
85012 +#define LBC_ADDRESS_HOLD_TIME_CTRL
85013 +#define LBC_HIGH_CLK_DIVIDERS
85014 +#define LBC_FCM_AVAILABLE
85015 +
85016 +/*****************************************************************************
85017 + GPIO INTEGRATION-SPECIFIC DEFINITIONS
85018 +******************************************************************************/
85019 +#define GPIO_PORT_OFFSET_0x1000
85020 +
85021 +#define GPIO_NUM_OF_PORTS 3 /**< Number of ports in GPIO module;
85022 + Each port contains up to 32 I/O pins. */
85023 +
85024 +#define GPIO_VALID_PIN_MASKS \
85025 + { /* Port A */ 0xFFFFFFFF, \
85026 + /* Port B */ 0xFFFFFFFF, \
85027 + /* Port C */ 0xFFFFFFFF }
85028 +
85029 +#define GPIO_VALID_INTR_MASKS \
85030 + { /* Port A */ 0xFFFFFFFF, \
85031 + /* Port B */ 0xFFFFFFFF, \
85032 + /* Port C */ 0xFFFFFFFF }
85033 +
85034 +
85035 +
85036 +#endif /* __PART_INTEGRATION_EXT_H */
85037 --- /dev/null
85038 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/dpaa_integration_ext.h
85039 @@ -0,0 +1,291 @@
85040 +/*
85041 + * Copyright 2012 Freescale Semiconductor Inc.
85042 + *
85043 + * Redistribution and use in source and binary forms, with or without
85044 + * modification, are permitted provided that the following conditions are met:
85045 + * * Redistributions of source code must retain the above copyright
85046 + * notice, this list of conditions and the following disclaimer.
85047 + * * Redistributions in binary form must reproduce the above copyright
85048 + * notice, this list of conditions and the following disclaimer in the
85049 + * documentation and/or other materials provided with the distribution.
85050 + * * Neither the name of Freescale Semiconductor nor the
85051 + * names of its contributors may be used to endorse or promote products
85052 + * derived from this software without specific prior written permission.
85053 + *
85054 + *
85055 + * ALTERNATIVELY, this software may be distributed under the terms of the
85056 + * GNU General Public License ("GPL") as published by the Free Software
85057 + * Foundation, either version 2 of that License or (at your option) any
85058 + * later version.
85059 + *
85060 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
85061 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
85062 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
85063 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
85064 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
85065 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
85066 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
85067 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
85068 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
85069 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
85070 + */
85071 +
85072 +/**
85073 +
85074 + @File dpaa_integration_ext.h
85075 +
85076 + @Description T4240 FM external definitions and structures.
85077 +*//***************************************************************************/
85078 +#ifndef __DPAA_INTEGRATION_EXT_H
85079 +#define __DPAA_INTEGRATION_EXT_H
85080 +
85081 +#include "std_ext.h"
85082 +
85083 +
85084 +#define DPAA_VERSION 11
85085 +
85086 +/**************************************************************************//**
85087 + @Description DPAA SW Portals Enumeration.
85088 +*//***************************************************************************/
85089 +typedef enum
85090 +{
85091 + e_DPAA_SWPORTAL0 = 0,
85092 + e_DPAA_SWPORTAL1,
85093 + e_DPAA_SWPORTAL2,
85094 + e_DPAA_SWPORTAL3,
85095 + e_DPAA_SWPORTAL4,
85096 + e_DPAA_SWPORTAL5,
85097 + e_DPAA_SWPORTAL6,
85098 + e_DPAA_SWPORTAL7,
85099 + e_DPAA_SWPORTAL8,
85100 + e_DPAA_SWPORTAL9,
85101 + e_DPAA_SWPORTAL10,
85102 + e_DPAA_SWPORTAL11,
85103 + e_DPAA_SWPORTAL12,
85104 + e_DPAA_SWPORTAL13,
85105 + e_DPAA_SWPORTAL14,
85106 + e_DPAA_SWPORTAL15,
85107 + e_DPAA_SWPORTAL16,
85108 + e_DPAA_SWPORTAL17,
85109 + e_DPAA_SWPORTAL18,
85110 + e_DPAA_SWPORTAL19,
85111 + e_DPAA_SWPORTAL20,
85112 + e_DPAA_SWPORTAL21,
85113 + e_DPAA_SWPORTAL22,
85114 + e_DPAA_SWPORTAL23,
85115 + e_DPAA_SWPORTAL24,
85116 + e_DPAA_SWPORTAL_DUMMY_LAST
85117 +} e_DpaaSwPortal;
85118 +
85119 +/**************************************************************************//**
85120 + @Description DPAA Direct Connect Portals Enumeration.
85121 +*//***************************************************************************/
85122 +typedef enum
85123 +{
85124 + e_DPAA_DCPORTAL0 = 0,
85125 + e_DPAA_DCPORTAL1,
85126 + e_DPAA_DCPORTAL2,
85127 + e_DPAA_DCPORTAL_DUMMY_LAST
85128 +} e_DpaaDcPortal;
85129 +
85130 +#define DPAA_MAX_NUM_OF_SW_PORTALS e_DPAA_SWPORTAL_DUMMY_LAST
85131 +#define DPAA_MAX_NUM_OF_DC_PORTALS e_DPAA_DCPORTAL_DUMMY_LAST
85132 +
85133 +/*****************************************************************************
85134 + QMan INTEGRATION-SPECIFIC DEFINITIONS
85135 +******************************************************************************/
85136 +#define QM_MAX_NUM_OF_POOL_CHANNELS 15 /**< Total number of channels, dedicated and pool */
85137 +#define QM_MAX_NUM_OF_WQ 8 /**< Number of work queues per channel */
85138 +#define QM_MAX_NUM_OF_CGS 256 /**< Congestion groups number */
85139 +#define QM_MAX_NUM_OF_FQIDS (16 * MEGABYTE)
85140 + /**< FQIDs range - 24 bits */
85141 +
85142 +/**************************************************************************//**
85143 + @Description Work Queue Channel assignments in QMan.
85144 +*//***************************************************************************/
85145 +typedef enum
85146 +{
85147 + e_QM_FQ_CHANNEL_SWPORTAL0 = 0x0, /**< Dedicated channels serviced by software portals 0 to 24 */
85148 + e_QM_FQ_CHANNEL_SWPORTAL1,
85149 + e_QM_FQ_CHANNEL_SWPORTAL2,
85150 + e_QM_FQ_CHANNEL_SWPORTAL3,
85151 + e_QM_FQ_CHANNEL_SWPORTAL4,
85152 + e_QM_FQ_CHANNEL_SWPORTAL5,
85153 + e_QM_FQ_CHANNEL_SWPORTAL6,
85154 + e_QM_FQ_CHANNEL_SWPORTAL7,
85155 + e_QM_FQ_CHANNEL_SWPORTAL8,
85156 + e_QM_FQ_CHANNEL_SWPORTAL9,
85157 + e_QM_FQ_CHANNEL_SWPORTAL10,
85158 + e_QM_FQ_CHANNEL_SWPORTAL11,
85159 + e_QM_FQ_CHANNEL_SWPORTAL12,
85160 + e_QM_FQ_CHANNEL_SWPORTAL13,
85161 + e_QM_FQ_CHANNEL_SWPORTAL14,
85162 + e_QM_FQ_CHANNEL_SWPORTAL15,
85163 + e_QM_FQ_CHANNEL_SWPORTAL16,
85164 + e_QM_FQ_CHANNEL_SWPORTAL17,
85165 + e_QM_FQ_CHANNEL_SWPORTAL18,
85166 + e_QM_FQ_CHANNEL_SWPORTAL19,
85167 + e_QM_FQ_CHANNEL_SWPORTAL20,
85168 + e_QM_FQ_CHANNEL_SWPORTAL21,
85169 + e_QM_FQ_CHANNEL_SWPORTAL22,
85170 + e_QM_FQ_CHANNEL_SWPORTAL23,
85171 + e_QM_FQ_CHANNEL_SWPORTAL24,
85172 +
85173 + e_QM_FQ_CHANNEL_POOL1 = 0x401, /**< Pool channels that can be serviced by any of the software portals */
85174 + e_QM_FQ_CHANNEL_POOL2,
85175 + e_QM_FQ_CHANNEL_POOL3,
85176 + e_QM_FQ_CHANNEL_POOL4,
85177 + e_QM_FQ_CHANNEL_POOL5,
85178 + e_QM_FQ_CHANNEL_POOL6,
85179 + e_QM_FQ_CHANNEL_POOL7,
85180 + e_QM_FQ_CHANNEL_POOL8,
85181 + e_QM_FQ_CHANNEL_POOL9,
85182 + e_QM_FQ_CHANNEL_POOL10,
85183 + e_QM_FQ_CHANNEL_POOL11,
85184 + e_QM_FQ_CHANNEL_POOL12,
85185 + e_QM_FQ_CHANNEL_POOL13,
85186 + e_QM_FQ_CHANNEL_POOL14,
85187 + e_QM_FQ_CHANNEL_POOL15,
85188 +
85189 + e_QM_FQ_CHANNEL_FMAN0_SP0 = 0x800, /**< Dedicated channels serviced by Direct Connect Portal 0:
85190 + connected to FMan 0; assigned in incrementing order to
85191 + each sub-portal (SP) in the portal */
85192 + e_QM_FQ_CHANNEL_FMAN0_SP1,
85193 + e_QM_FQ_CHANNEL_FMAN0_SP2,
85194 + e_QM_FQ_CHANNEL_FMAN0_SP3,
85195 + e_QM_FQ_CHANNEL_FMAN0_SP4,
85196 + e_QM_FQ_CHANNEL_FMAN0_SP5,
85197 + e_QM_FQ_CHANNEL_FMAN0_SP6,
85198 + e_QM_FQ_CHANNEL_FMAN0_SP7,
85199 + e_QM_FQ_CHANNEL_FMAN0_SP8,
85200 + e_QM_FQ_CHANNEL_FMAN0_SP9,
85201 + e_QM_FQ_CHANNEL_FMAN0_SP10,
85202 + e_QM_FQ_CHANNEL_FMAN0_SP11,
85203 + e_QM_FQ_CHANNEL_FMAN0_SP12,
85204 + e_QM_FQ_CHANNEL_FMAN0_SP13,
85205 + e_QM_FQ_CHANNEL_FMAN0_SP14,
85206 + e_QM_FQ_CHANNEL_FMAN0_SP15,
85207 +
85208 + e_QM_FQ_CHANNEL_RMAN_SP0 = 0x820, /**< Dedicated channels serviced by Direct Connect Portal 1: connected to RMan */
85209 + e_QM_FQ_CHANNEL_RMAN_SP1,
85210 +
85211 + e_QM_FQ_CHANNEL_CAAM = 0x840 /**< Dedicated channel serviced by Direct Connect Portal 2:
85212 + connected to SEC */
85213 +} e_QmFQChannel;
85214 +
85215 +/*****************************************************************************
85216 + BMan INTEGRATION-SPECIFIC DEFINITIONS
85217 +******************************************************************************/
85218 +#define BM_MAX_NUM_OF_POOLS 64 /**< Number of buffers pools */
85219 +
85220 +/*****************************************************************************
85221 + SEC INTEGRATION-SPECIFIC DEFINITIONS
85222 +******************************************************************************/
85223 +#define SEC_NUM_OF_DECOS 3
85224 +#define SEC_ALL_DECOS_MASK 0x00000003
85225 +
85226 +
85227 +/*****************************************************************************
85228 + FM INTEGRATION-SPECIFIC DEFINITIONS
85229 +******************************************************************************/
85230 +#define INTG_MAX_NUM_OF_FM 2
85231 +
85232 +/* Ports defines */
85233 +#define FM_MAX_NUM_OF_1G_MACS 6
85234 +#define FM_MAX_NUM_OF_10G_MACS 2
85235 +#define FM_MAX_NUM_OF_MACS (FM_MAX_NUM_OF_1G_MACS + FM_MAX_NUM_OF_10G_MACS)
85236 +#define FM_MAX_NUM_OF_OH_PORTS 6
85237 +
85238 +#define FM_MAX_NUM_OF_1G_RX_PORTS FM_MAX_NUM_OF_1G_MACS
85239 +#define FM_MAX_NUM_OF_10G_RX_PORTS FM_MAX_NUM_OF_10G_MACS
85240 +#define FM_MAX_NUM_OF_RX_PORTS (FM_MAX_NUM_OF_10G_RX_PORTS + FM_MAX_NUM_OF_1G_RX_PORTS)
85241 +
85242 +#define FM_MAX_NUM_OF_1G_TX_PORTS FM_MAX_NUM_OF_1G_MACS
85243 +#define FM_MAX_NUM_OF_10G_TX_PORTS FM_MAX_NUM_OF_10G_MACS
85244 +#define FM_MAX_NUM_OF_TX_PORTS (FM_MAX_NUM_OF_10G_TX_PORTS + FM_MAX_NUM_OF_1G_TX_PORTS)
85245 +
85246 +#define FM_PORT_MAX_NUM_OF_EXT_POOLS 4 /**< Number of external BM pools per Rx port */
85247 +#define FM_PORT_NUM_OF_CONGESTION_GRPS 256 /**< Total number of congestion groups in QM */
85248 +#define FM_MAX_NUM_OF_SUB_PORTALS 16
85249 +#define FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS 0
85250 +
85251 +#define FM_VSP_MAX_NUM_OF_ENTRIES 64
85252 +#define FM_MAX_NUM_OF_PFC_PRIORITIES 8
85253 +
85254 +/* RAMs defines */
85255 +#define FM_MURAM_SIZE (384 * KILOBYTE)
85256 +#define FM_IRAM_SIZE(major, minor) (64 * KILOBYTE)
85257 +#define FM_NUM_OF_CTRL 4
85258 +
85259 +/* PCD defines */
85260 +#define FM_PCD_PLCR_NUM_ENTRIES 256 /**< Total number of policer profiles */
85261 +#define FM_PCD_KG_NUM_OF_SCHEMES 32 /**< Total number of KG schemes */
85262 +#define FM_PCD_MAX_NUM_OF_CLS_PLANS 256 /**< Number of classification plan entries. */
85263 +#define FM_PCD_PRS_SW_PATCHES_SIZE 0x00000600 /**< Number of bytes saved for patches */
85264 +#define FM_PCD_SW_PRS_SIZE 0x00000800 /**< Total size of SW parser area */
85265 +
85266 +/* RTC defines */
85267 +#define FM_RTC_NUM_OF_ALARMS 2 /**< RTC number of alarms */
85268 +#define FM_RTC_NUM_OF_PERIODIC_PULSES 3 /**< RTC number of periodic pulses */
85269 +#define FM_RTC_NUM_OF_EXT_TRIGGERS 2 /**< RTC number of external triggers */
85270 +
85271 +/* QMI defines */
85272 +#define QMI_MAX_NUM_OF_TNUMS 64
85273 +#define QMI_DEF_TNUMS_THRESH 32
85274 +/* FPM defines */
85275 +#define FM_NUM_OF_FMAN_CTRL_EVENT_REGS 4
85276 +
85277 +/* DMA defines */
85278 +#define DMA_THRESH_MAX_COMMQ 83
85279 +#define DMA_THRESH_MAX_BUF 127
85280 +
85281 +/* BMI defines */
85282 +#define BMI_MAX_NUM_OF_TASKS 128
85283 +#define BMI_MAX_NUM_OF_DMAS 84
85284 +
85285 +#define BMI_MAX_FIFO_SIZE (FM_MURAM_SIZE)
85286 +#define PORT_MAX_WEIGHT 16
85287 +
85288 +#define FM_CHECK_PORT_RESTRICTIONS(__validPorts, __newPortIndx) TRUE
85289 +
85290 +/* Unique T4240 */
85291 +#define FM_OP_OPEN_DMA_MIN_LIMIT
85292 +#define FM_NO_RESTRICT_ON_ACCESS_RSRC
85293 +#define FM_NO_OP_OBSERVED_POOLS
85294 +#define FM_FRAME_END_PARAMS_FOR_OP
85295 +#define FM_DEQ_PIPELINE_PARAMS_FOR_OP
85296 +#define FM_QMI_NO_SINGLE_ECC_EXCEPTION
85297 +
85298 +#define FM_NO_GUARANTEED_RESET_VALUES
85299 +
85300 +/* FM errata */
85301 +#define FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669
85302 +#define FM_WRONG_RESET_VALUES_ERRATA_FMAN_A005127
85303 +#define FM_RX_FIFO_CORRUPT_ERRATA_10GMAC_A006320
85304 +#define FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675
85305 +#define FM_HEAVY_TRAFFIC_SEQUENCER_HANG_ERRATA_FMAN_A006981
85306 +
85307 +#define FM_BCB_ERRATA_BMI_SW001
85308 +#define FM_LEN_CHECK_ERRATA_FMAN_SW002
85309 +#define FM_AID_MODE_NO_TNUM_SW005 /* refer to pdm TKT068794 - only support of port_id on aid */
85310 +#define FM_ERROR_VSP_NO_MATCH_SW006 /* refer to pdm TKT174304 - no match between errorQ and VSP */
85311 +
85312 +/*****************************************************************************
85313 + RMan INTEGRATION-SPECIFIC DEFINITIONS
85314 +******************************************************************************/
85315 +#define RM_MAX_NUM_OF_IB 4 /**< Number of inbound blocks */
85316 +#define RM_NUM_OF_IBCU 8 /**< NUmber of classification units in an inbound block */
85317 +
85318 +/* RMan erratas */
85319 +#define RM_ERRONEOUS_ACK_ERRATA_RMAN_A006756
85320 +
85321 +/*****************************************************************************
85322 + FM MACSEC INTEGRATION-SPECIFIC DEFINITIONS
85323 +******************************************************************************/
85324 +#define NUM_OF_RX_SC 16
85325 +#define NUM_OF_TX_SC 16
85326 +
85327 +#define NUM_OF_SA_PER_RX_SC 2
85328 +#define NUM_OF_SA_PER_TX_SC 2
85329 +
85330 +#endif /* __DPAA_INTEGRATION_EXT_H */
85331 --- /dev/null
85332 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/part_ext.h
85333 @@ -0,0 +1,64 @@
85334 +/*
85335 + * Copyright 2012 Freescale Semiconductor Inc.
85336 + *
85337 + * Redistribution and use in source and binary forms, with or without
85338 + * modification, are permitted provided that the following conditions are met:
85339 + * * Redistributions of source code must retain the above copyright
85340 + * notice, this list of conditions and the following disclaimer.
85341 + * * Redistributions in binary form must reproduce the above copyright
85342 + * notice, this list of conditions and the following disclaimer in the
85343 + * documentation and/or other materials provided with the distribution.
85344 + * * Neither the name of Freescale Semiconductor nor the
85345 + * names of its contributors may be used to endorse or promote products
85346 + * derived from this software without specific prior written permission.
85347 + *
85348 + *
85349 + * ALTERNATIVELY, this software may be distributed under the terms of the
85350 + * GNU General Public License ("GPL") as published by the Free Software
85351 + * Foundation, either version 2 of that License or (at your option) any
85352 + * later version.
85353 + *
85354 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
85355 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
85356 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
85357 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
85358 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
85359 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
85360 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
85361 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
85362 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
85363 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
85364 + */
85365 +
85366 +/**************************************************************************//**
85367 +
85368 + @File part_ext.h
85369 +
85370 + @Description Definitions for the part (integration) module.
85371 +*//***************************************************************************/
85372 +
85373 +#ifndef __PART_EXT_H
85374 +#define __PART_EXT_H
85375 +
85376 +#include "std_ext.h"
85377 +#include "part_integration_ext.h"
85378 +
85379 +#if !(defined(LS1043))
85380 +#error "unable to proceed without chip-definition"
85381 +#endif
85382 +
85383 +
85384 +/**************************************************************************//*
85385 + @Description Part data structure - must be contained in any integration
85386 + data structure.
85387 +*//***************************************************************************/
85388 +typedef struct t_Part
85389 +{
85390 + uintptr_t (* f_GetModuleBase)(t_Handle h_Part, e_ModuleId moduleId);
85391 + /**< Returns the address of the module's memory map base. */
85392 + e_ModuleId (* f_GetModuleIdByBase)(t_Handle h_Part, uintptr_t baseAddress);
85393 + /**< Returns the module's ID according to its memory map base. */
85394 +} t_Part;
85395 +
85396 +
85397 +#endif /* __PART_EXT_H */
85398 --- /dev/null
85399 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/part_integration_ext.h
85400 @@ -0,0 +1,185 @@
85401 +/*
85402 + * Copyright 2008-2012 Freescale Semiconductor Inc.
85403 + *
85404 + * Redistribution and use in source and binary forms, with or without
85405 + * modification, are permitted provided that the following conditions are met:
85406 + * * Redistributions of source code must retain the above copyright
85407 + * notice, this list of conditions and the following disclaimer.
85408 + * * Redistributions in binary form must reproduce the above copyright
85409 + * notice, this list of conditions and the following disclaimer in the
85410 + * documentation and/or other materials provided with the distribution.
85411 + * * Neither the name of Freescale Semiconductor nor the
85412 + * names of its contributors may be used to endorse or promote products
85413 + * derived from this software without specific prior written permission.
85414 + *
85415 + *
85416 + * ALTERNATIVELY, this software may be distributed under the terms of the
85417 + * GNU General Public License ("GPL") as published by the Free Software
85418 + * Foundation, either version 2 of that License or (at your option) any
85419 + * later version.
85420 + *
85421 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
85422 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
85423 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
85424 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
85425 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
85426 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
85427 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
85428 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
85429 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
85430 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
85431 + */
85432 +
85433 +/**
85434 +
85435 + @File part_integration_ext.h
85436 +
85437 + @Description T4240 external definitions and structures.
85438 +*//***************************************************************************/
85439 +#ifndef __PART_INTEGRATION_EXT_H
85440 +#define __PART_INTEGRATION_EXT_H
85441 +
85442 +#include "std_ext.h"
85443 +#include "ddr_std_ext.h"
85444 +#include "enet_ext.h"
85445 +#include "dpaa_integration_ext.h"
85446 +
85447 +
85448 +/**************************************************************************//**
85449 + @Group T4240_chip_id T4240 Application Programming Interface
85450 +
85451 + @Description T4240 Chip functions,definitions and enums.
85452 +
85453 + @{
85454 +*//***************************************************************************/
85455 +
85456 +#define INTG_MAX_NUM_OF_CORES 4
85457 +
85458 +/**************************************************************************//**
85459 + @Description Module types.
85460 +*//***************************************************************************/
85461 +typedef enum e_ModuleId
85462 +{
85463 + e_MODULE_ID_DUART_1 = 0,
85464 + e_MODULE_ID_DUART_2,
85465 + e_MODULE_ID_DUART_3,
85466 + e_MODULE_ID_DUART_4,
85467 + e_MODULE_ID_LAW,
85468 + e_MODULE_ID_IFC,
85469 + e_MODULE_ID_PAMU,
85470 + e_MODULE_ID_QM, /**< Queue manager module */
85471 + e_MODULE_ID_BM, /**< Buffer manager module */
85472 + e_MODULE_ID_QM_CE_PORTAL_0,
85473 + e_MODULE_ID_QM_CI_PORTAL_0,
85474 + e_MODULE_ID_QM_CE_PORTAL_1,
85475 + e_MODULE_ID_QM_CI_PORTAL_1,
85476 + e_MODULE_ID_QM_CE_PORTAL_2,
85477 + e_MODULE_ID_QM_CI_PORTAL_2,
85478 + e_MODULE_ID_QM_CE_PORTAL_3,
85479 + e_MODULE_ID_QM_CI_PORTAL_3,
85480 + e_MODULE_ID_QM_CE_PORTAL_4,
85481 + e_MODULE_ID_QM_CI_PORTAL_4,
85482 + e_MODULE_ID_QM_CE_PORTAL_5,
85483 + e_MODULE_ID_QM_CI_PORTAL_5,
85484 + e_MODULE_ID_QM_CE_PORTAL_6,
85485 + e_MODULE_ID_QM_CI_PORTAL_6,
85486 + e_MODULE_ID_QM_CE_PORTAL_7,
85487 + e_MODULE_ID_QM_CI_PORTAL_7,
85488 + e_MODULE_ID_QM_CE_PORTAL_8,
85489 + e_MODULE_ID_QM_CI_PORTAL_8,
85490 + e_MODULE_ID_QM_CE_PORTAL_9,
85491 + e_MODULE_ID_QM_CI_PORTAL_9,
85492 + e_MODULE_ID_BM_CE_PORTAL_0,
85493 + e_MODULE_ID_BM_CI_PORTAL_0,
85494 + e_MODULE_ID_BM_CE_PORTAL_1,
85495 + e_MODULE_ID_BM_CI_PORTAL_1,
85496 + e_MODULE_ID_BM_CE_PORTAL_2,
85497 + e_MODULE_ID_BM_CI_PORTAL_2,
85498 + e_MODULE_ID_BM_CE_PORTAL_3,
85499 + e_MODULE_ID_BM_CI_PORTAL_3,
85500 + e_MODULE_ID_BM_CE_PORTAL_4,
85501 + e_MODULE_ID_BM_CI_PORTAL_4,
85502 + e_MODULE_ID_BM_CE_PORTAL_5,
85503 + e_MODULE_ID_BM_CI_PORTAL_5,
85504 + e_MODULE_ID_BM_CE_PORTAL_6,
85505 + e_MODULE_ID_BM_CI_PORTAL_6,
85506 + e_MODULE_ID_BM_CE_PORTAL_7,
85507 + e_MODULE_ID_BM_CI_PORTAL_7,
85508 + e_MODULE_ID_BM_CE_PORTAL_8,
85509 + e_MODULE_ID_BM_CI_PORTAL_8,
85510 + e_MODULE_ID_BM_CE_PORTAL_9,
85511 + e_MODULE_ID_BM_CI_PORTAL_9,
85512 + e_MODULE_ID_FM, /**< Frame manager module */
85513 + e_MODULE_ID_FM_RTC, /**< FM Real-Time-Clock */
85514 + e_MODULE_ID_FM_MURAM, /**< FM Multi-User-RAM */
85515 + e_MODULE_ID_FM_BMI, /**< FM BMI block */
85516 + e_MODULE_ID_FM_QMI, /**< FM QMI block */
85517 + e_MODULE_ID_FM_PARSER, /**< FM parser block */
85518 + e_MODULE_ID_FM_PORT_HO1, /**< FM Host-command/offline-parsing port block */
85519 + e_MODULE_ID_FM_PORT_HO2, /**< FM Host-command/offline-parsing port block */
85520 + e_MODULE_ID_FM_PORT_HO3, /**< FM Host-command/offline-parsing port block */
85521 + e_MODULE_ID_FM_PORT_HO4, /**< FM Host-command/offline-parsing port block */
85522 + e_MODULE_ID_FM_PORT_HO5, /**< FM Host-command/offline-parsing port block */
85523 + e_MODULE_ID_FM_PORT_HO6, /**< FM Host-command/offline-parsing port block */
85524 + e_MODULE_ID_FM_PORT_HO7, /**< FM Host-command/offline-parsing port block */
85525 + e_MODULE_ID_FM_PORT_1GRx1, /**< FM Rx 1G MAC port block */
85526 + e_MODULE_ID_FM_PORT_1GRx2, /**< FM Rx 1G MAC port block */
85527 + e_MODULE_ID_FM_PORT_1GRx3, /**< FM Rx 1G MAC port block */
85528 + e_MODULE_ID_FM_PORT_1GRx4, /**< FM Rx 1G MAC port block */
85529 + e_MODULE_ID_FM_PORT_1GRx5, /**< FM Rx 1G MAC port block */
85530 + e_MODULE_ID_FM_PORT_1GRx6, /**< FM Rx 1G MAC port block */
85531 + e_MODULE_ID_FM_PORT_10GRx1, /**< FM Rx 10G MAC port block */
85532 + e_MODULE_ID_FM_PORT_10GRx2, /**< FM Rx 10G MAC port block */
85533 + e_MODULE_ID_FM_PORT_1GTx1, /**< FM Tx 1G MAC port block */
85534 + e_MODULE_ID_FM_PORT_1GTx2, /**< FM Tx 1G MAC port block */
85535 + e_MODULE_ID_FM_PORT_1GTx3, /**< FM Tx 1G MAC port block */
85536 + e_MODULE_ID_FM_PORT_1GTx4, /**< FM Tx 1G MAC port block */
85537 + e_MODULE_ID_FM_PORT_1GTx5, /**< FM Tx 1G MAC port block */
85538 + e_MODULE_ID_FM_PORT_1GTx6, /**< FM Tx 1G MAC port block */
85539 + e_MODULE_ID_FM_PORT_10GTx1, /**< FM Tx 10G MAC port block */
85540 + e_MODULE_ID_FM_PORT_10GTx2, /**< FM Tx 10G MAC port block */
85541 + e_MODULE_ID_FM_PLCR, /**< FM Policer */
85542 + e_MODULE_ID_FM_KG, /**< FM Keygen */
85543 + e_MODULE_ID_FM_DMA, /**< FM DMA */
85544 + e_MODULE_ID_FM_FPM, /**< FM FPM */
85545 + e_MODULE_ID_FM_IRAM, /**< FM Instruction-RAM */
85546 + e_MODULE_ID_FM_1GMDIO, /**< FM 1G MDIO MAC */
85547 + e_MODULE_ID_FM_10GMDIO, /**< FM 10G MDIO */
85548 + e_MODULE_ID_FM_PRS_IRAM, /**< FM SW-parser Instruction-RAM */
85549 + e_MODULE_ID_FM_1GMAC1, /**< FM 1G MAC #1 */
85550 + e_MODULE_ID_FM_1GMAC2, /**< FM 1G MAC #2 */
85551 + e_MODULE_ID_FM_1GMAC3, /**< FM 1G MAC #3 */
85552 + e_MODULE_ID_FM_1GMAC4, /**< FM 1G MAC #4 */
85553 + e_MODULE_ID_FM_1GMAC5, /**< FM 1G MAC #5 */
85554 + e_MODULE_ID_FM_1GMAC6, /**< FM 1G MAC #6 */
85555 + e_MODULE_ID_FM_10GMAC1, /**< FM 10G MAC */
85556 + e_MODULE_ID_FM_10GMAC2, /**< FM 10G MAC */
85557 +
85558 + e_MODULE_ID_SEC_GEN, /**< SEC 4.0 General registers */
85559 + e_MODULE_ID_SEC_QI, /**< SEC 4.0 QI registers */
85560 + e_MODULE_ID_SEC_JQ0, /**< SEC 4.0 JQ-0 registers */
85561 + e_MODULE_ID_SEC_JQ1, /**< SEC 4.0 JQ-1 registers */
85562 + e_MODULE_ID_SEC_JQ2, /**< SEC 4.0 JQ-2 registers */
85563 + e_MODULE_ID_SEC_JQ3, /**< SEC 4.0 JQ-3 registers */
85564 + e_MODULE_ID_SEC_RTIC, /**< SEC 4.0 RTIC registers */
85565 + e_MODULE_ID_SEC_DECO0_CCB0, /**< SEC 4.0 DECO-0/CCB-0 registers */
85566 + e_MODULE_ID_SEC_DECO1_CCB1, /**< SEC 4.0 DECO-1/CCB-1 registers */
85567 + e_MODULE_ID_SEC_DECO2_CCB2, /**< SEC 4.0 DECO-2/CCB-2 registers */
85568 + e_MODULE_ID_SEC_DECO3_CCB3, /**< SEC 4.0 DECO-3/CCB-3 registers */
85569 + e_MODULE_ID_SEC_DECO4_CCB4, /**< SEC 4.0 DECO-4/CCB-4 registers */
85570 +
85571 + e_MODULE_ID_PIC, /**< PIC */
85572 + e_MODULE_ID_GPIO, /**< GPIO */
85573 + e_MODULE_ID_SERDES, /**< SERDES */
85574 + e_MODULE_ID_CPC_1, /**< CoreNet-Platform-Cache 1 */
85575 + e_MODULE_ID_CPC_2, /**< CoreNet-Platform-Cache 2 */
85576 +
85577 + e_MODULE_ID_SRIO_PORTS, /**< RapidIO controller */
85578 +
85579 + e_MODULE_ID_DUMMY_LAST
85580 +} e_ModuleId;
85581 +
85582 +#define NUM_OF_MODULES e_MODULE_ID_DUMMY_LAST
85583 +
85584 +
85585 +#endif /* __PART_INTEGRATION_EXT_H */
85586 --- /dev/null
85587 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P1023/dpaa_integration_ext.h
85588 @@ -0,0 +1,213 @@
85589 +/*
85590 + * Copyright 2008-2012 Freescale Semiconductor Inc.
85591 + *
85592 + * Redistribution and use in source and binary forms, with or without
85593 + * modification, are permitted provided that the following conditions are met:
85594 + * * Redistributions of source code must retain the above copyright
85595 + * notice, this list of conditions and the following disclaimer.
85596 + * * Redistributions in binary form must reproduce the above copyright
85597 + * notice, this list of conditions and the following disclaimer in the
85598 + * documentation and/or other materials provided with the distribution.
85599 + * * Neither the name of Freescale Semiconductor nor the
85600 + * names of its contributors may be used to endorse or promote products
85601 + * derived from this software without specific prior written permission.
85602 + *
85603 + *
85604 + * ALTERNATIVELY, this software may be distributed under the terms of the
85605 + * GNU General Public License ("GPL") as published by the Free Software
85606 + * Foundation, either version 2 of that License or (at your option) any
85607 + * later version.
85608 + *
85609 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
85610 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
85611 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
85612 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
85613 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
85614 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
85615 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
85616 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
85617 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
85618 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
85619 + */
85620 +
85621 +
85622 +/**
85623 +
85624 + @File dpaa_integration_ext.h
85625 +
85626 + @Description P1023 FM external definitions and structures.
85627 +*//***************************************************************************/
85628 +#ifndef __DPAA_INTEGRATION_EXT_H
85629 +#define __DPAA_INTEGRATION_EXT_H
85630 +
85631 +#include "std_ext.h"
85632 +
85633 +
85634 +#define DPAA_VERSION 10
85635 +
85636 +typedef enum e_DpaaSwPortal {
85637 + e_DPAA_SWPORTAL0 = 0,
85638 + e_DPAA_SWPORTAL1,
85639 + e_DPAA_SWPORTAL2,
85640 + e_DPAA_SWPORTAL_DUMMY_LAST
85641 +} e_DpaaSwPortal;
85642 +
85643 +typedef enum {
85644 + e_DPAA_DCPORTAL0 = 0,
85645 + e_DPAA_DCPORTAL2,
85646 + e_DPAA_DCPORTAL_DUMMY_LAST
85647 +} e_DpaaDcPortal;
85648 +
85649 +#define DPAA_MAX_NUM_OF_SW_PORTALS e_DPAA_SWPORTAL_DUMMY_LAST
85650 +#define DPAA_MAX_NUM_OF_DC_PORTALS e_DPAA_DCPORTAL_DUMMY_LAST
85651 +
85652 +/*****************************************************************************
85653 + QMAN INTEGRATION-SPECIFIC DEFINITIONS
85654 +******************************************************************************/
85655 +#define QM_MAX_NUM_OF_POOL_CHANNELS 3
85656 +#define QM_MAX_NUM_OF_WQ 8
85657 +#define QM_MAX_NUM_OF_SWP_AS 2
85658 +#define QM_MAX_NUM_OF_CGS 64
85659 +#define QM_MAX_NUM_OF_FQIDS (16*MEGABYTE)
85660 +
85661 +typedef enum {
85662 + e_QM_FQ_CHANNEL_SWPORTAL0 = 0,
85663 + e_QM_FQ_CHANNEL_SWPORTAL1,
85664 + e_QM_FQ_CHANNEL_SWPORTAL2,
85665 +
85666 + e_QM_FQ_CHANNEL_POOL1 = 0x21,
85667 + e_QM_FQ_CHANNEL_POOL2,
85668 + e_QM_FQ_CHANNEL_POOL3,
85669 +
85670 + e_QM_FQ_CHANNEL_FMAN0_SP0 = 0x40,
85671 + e_QM_FQ_CHANNEL_FMAN0_SP1,
85672 + e_QM_FQ_CHANNEL_FMAN0_SP2,
85673 + e_QM_FQ_CHANNEL_FMAN0_SP3,
85674 + e_QM_FQ_CHANNEL_FMAN0_SP4,
85675 + e_QM_FQ_CHANNEL_FMAN0_SP5,
85676 + e_QM_FQ_CHANNEL_FMAN0_SP6,
85677 +
85678 +
85679 + e_QM_FQ_CHANNEL_CAAM = 0x80
85680 +} e_QmFQChannel;
85681 +
85682 +/*****************************************************************************
85683 + BMAN INTEGRATION-SPECIFIC DEFINITIONS
85684 +******************************************************************************/
85685 +#define BM_MAX_NUM_OF_POOLS 8
85686 +
85687 +/*****************************************************************************
85688 + SEC INTEGRATION-SPECIFIC DEFINITIONS
85689 +******************************************************************************/
85690 +#define SEC_NUM_OF_DECOS 2
85691 +#define SEC_ALL_DECOS_MASK 0x00000003
85692 +#define SEC_RNGB
85693 +#define SEC_NO_ESP_TRAILER_REMOVAL
85694 +
85695 +/*****************************************************************************
85696 + FM INTEGRATION-SPECIFIC DEFINITIONS
85697 +******************************************************************************/
85698 +#define INTG_MAX_NUM_OF_FM 1
85699 +
85700 +/* Ports defines */
85701 +#define FM_MAX_NUM_OF_1G_MACS 2
85702 +#define FM_MAX_NUM_OF_10G_MACS 0
85703 +#define FM_MAX_NUM_OF_MACS (FM_MAX_NUM_OF_1G_MACS + FM_MAX_NUM_OF_10G_MACS)
85704 +#define FM_MAX_NUM_OF_OH_PORTS 5
85705 +
85706 +#define FM_MAX_NUM_OF_1G_RX_PORTS FM_MAX_NUM_OF_1G_MACS
85707 +#define FM_MAX_NUM_OF_10G_RX_PORTS FM_MAX_NUM_OF_10G_MACS
85708 +#define FM_MAX_NUM_OF_RX_PORTS (FM_MAX_NUM_OF_10G_RX_PORTS + FM_MAX_NUM_OF_1G_RX_PORTS)
85709 +
85710 +#define FM_MAX_NUM_OF_1G_TX_PORTS FM_MAX_NUM_OF_1G_MACS
85711 +#define FM_MAX_NUM_OF_10G_TX_PORTS FM_MAX_NUM_OF_10G_MACS
85712 +#define FM_MAX_NUM_OF_TX_PORTS (FM_MAX_NUM_OF_10G_TX_PORTS + FM_MAX_NUM_OF_1G_TX_PORTS)
85713 +
85714 +#define FM_MAX_NUM_OF_MACSECS 1
85715 +
85716 +#define FM_MACSEC_SUPPORT
85717 +
85718 +#define FM_LOW_END_RESTRICTION /* prevents the use of TX port 1 with OP port 0 */
85719 +
85720 +#define FM_PORT_MAX_NUM_OF_EXT_POOLS 4 /**< Number of external BM pools per Rx port */
85721 +#define FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS 2 /**< Number of Offline parsing port external BM pools per Rx port */
85722 +#define FM_PORT_NUM_OF_CONGESTION_GRPS 32 /**< Total number of congestion groups in QM */
85723 +#define FM_MAX_NUM_OF_SUB_PORTALS 7
85724 +
85725 +/* Rams defines */
85726 +#define FM_MURAM_SIZE (64*KILOBYTE)
85727 +#define FM_IRAM_SIZE(major, minor) (32 * KILOBYTE)
85728 +#define FM_NUM_OF_CTRL 2
85729 +
85730 +/* PCD defines */
85731 +#define FM_PCD_PLCR_NUM_ENTRIES 32 /**< Total number of policer profiles */
85732 +#define FM_PCD_KG_NUM_OF_SCHEMES 16 /**< Total number of KG schemes */
85733 +#define FM_PCD_MAX_NUM_OF_CLS_PLANS 128 /**< Number of classification plan entries. */
85734 +#define FM_PCD_PRS_SW_PATCHES_SIZE 0x00000240 /**< Number of bytes saved for patches */
85735 +#define FM_PCD_SW_PRS_SIZE 0x00000800 /**< Total size of SW parser area */
85736 +
85737 +/* RTC defines */
85738 +#define FM_RTC_NUM_OF_ALARMS 2
85739 +#define FM_RTC_NUM_OF_PERIODIC_PULSES 2
85740 +#define FM_RTC_NUM_OF_EXT_TRIGGERS 2
85741 +
85742 +/* QMI defines */
85743 +#define QMI_MAX_NUM_OF_TNUMS 15
85744 +
85745 +/* FPM defines */
85746 +#define FM_NUM_OF_FMAN_CTRL_EVENT_REGS 4
85747 +
85748 +/* DMA defines */
85749 +#define DMA_THRESH_MAX_COMMQ 15
85750 +#define DMA_THRESH_MAX_BUF 7
85751 +
85752 +/* BMI defines */
85753 +#define BMI_MAX_NUM_OF_TASKS 64
85754 +#define BMI_MAX_NUM_OF_DMAS 16
85755 +#define BMI_MAX_FIFO_SIZE (FM_MURAM_SIZE)
85756 +#define PORT_MAX_WEIGHT 4
85757 +
85758 +/*****************************************************************************
85759 + FM MACSEC INTEGRATION-SPECIFIC DEFINITIONS
85760 +******************************************************************************/
85761 +#define NUM_OF_RX_SC 16
85762 +#define NUM_OF_TX_SC 16
85763 +
85764 +#define NUM_OF_SA_PER_RX_SC 2
85765 +#define NUM_OF_SA_PER_TX_SC 2
85766 +
85767 +/**************************************************************************//**
85768 + @Description Enum for inter-module interrupts registration
85769 +*//***************************************************************************/
85770 +
85771 +/* 1023 unique features */
85772 +#define FM_QMI_NO_ECC_EXCEPTIONS
85773 +#define FM_CSI_CFED_LIMIT
85774 +#define FM_PEDANTIC_DMA
85775 +#define FM_QMI_NO_DEQ_OPTIONS_SUPPORT
85776 +#define FM_FIFO_ALLOCATION_ALG
85777 +#define FM_DEQ_PIPELINE_PARAMS_FOR_OP
85778 +#define FM_HAS_TOTAL_DMAS
85779 +#define FM_KG_NO_IPPID_SUPPORT
85780 +#define FM_NO_GUARANTEED_RESET_VALUES
85781 +#define FM_MAC_RESET
85782 +
85783 +/* FM erratas */
85784 +#define FM_RX_PREAM_4_ERRATA_DTSEC_A001
85785 +#define FM_MAGIC_PACKET_UNRECOGNIZED_ERRATA_DTSEC2 /* No implementation, Out of LLD scope */
85786 +
85787 +#define FM_DEBUG_TRACE_FMAN_A004 /* No implementation, Out of LLD scope */
85788 +#define FM_INT_BUF_LEAK_FMAN_A005 /* No implementation, Out of LLD scope. App must avoid S/G */
85789 +
85790 +#define FM_GTS_AFTER_DROPPED_FRAME_ERRATA_DTSEC_A004839
85791 +
85792 +/* #define FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173 */
85793 +
85794 +/*
85795 +TKT056919 - axi12axi0 can hang if read request follows the single byte write on the very next cycle
85796 +TKT038900 - FM dma lockup occur due to AXI slave protocol violation
85797 +*/
85798 +#define FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004
85799 +
85800 +
85801 +#endif /* __DPAA_INTEGRATION_EXT_H */
85802 --- /dev/null
85803 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P1023/part_ext.h
85804 @@ -0,0 +1,82 @@
85805 +/*
85806 + * Copyright 2008-2012 Freescale Semiconductor Inc.
85807 + *
85808 + * Redistribution and use in source and binary forms, with or without
85809 + * modification, are permitted provided that the following conditions are met:
85810 + * * Redistributions of source code must retain the above copyright
85811 + * notice, this list of conditions and the following disclaimer.
85812 + * * Redistributions in binary form must reproduce the above copyright
85813 + * notice, this list of conditions and the following disclaimer in the
85814 + * documentation and/or other materials provided with the distribution.
85815 + * * Neither the name of Freescale Semiconductor nor the
85816 + * names of its contributors may be used to endorse or promote products
85817 + * derived from this software without specific prior written permission.
85818 + *
85819 + *
85820 + * ALTERNATIVELY, this software may be distributed under the terms of the
85821 + * GNU General Public License ("GPL") as published by the Free Software
85822 + * Foundation, either version 2 of that License or (at your option) any
85823 + * later version.
85824 + *
85825 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
85826 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
85827 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
85828 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
85829 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
85830 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
85831 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
85832 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
85833 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
85834 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
85835 + */
85836 +
85837 +
85838 +/**************************************************************************//**
85839 +
85840 + @File part_ext.h
85841 +
85842 + @Description Definitions for the part (integration) module.
85843 +*//***************************************************************************/
85844 +
85845 +#ifndef __PART_EXT_H
85846 +#define __PART_EXT_H
85847 +
85848 +#include "std_ext.h"
85849 +#include "part_integration_ext.h"
85850 +
85851 +
85852 +#if !(defined(MPC8306) || \
85853 + defined(MPC8309) || \
85854 + defined(MPC834x) || \
85855 + defined(MPC836x) || \
85856 + defined(MPC832x) || \
85857 + defined(MPC837x) || \
85858 + defined(MPC8568) || \
85859 + defined(MPC8569) || \
85860 + defined(P1020) || \
85861 + defined(P1021) || \
85862 + defined(P1022) || \
85863 + defined(P1023) || \
85864 + defined(P2020) || \
85865 + defined(P3041) || \
85866 + defined(P4080) || \
85867 + defined(P5020) || \
85868 + defined(MSC814x))
85869 +#error "unable to proceed without chip-definition"
85870 +#endif
85871 +
85872 +
85873 +/**************************************************************************//*
85874 + @Description Part data structure - must be contained in any integration
85875 + data structure.
85876 +*//***************************************************************************/
85877 +typedef struct t_Part
85878 +{
85879 + uint64_t (* f_GetModuleBase)(t_Handle h_Part, e_ModuleId moduleId);
85880 + /**< Returns the address of the module's memory map base. */
85881 + e_ModuleId (* f_GetModuleIdByBase)(t_Handle h_Part, uint64_t baseAddress);
85882 + /**< Returns the module's ID according to its memory map base. */
85883 +} t_Part;
85884 +
85885 +
85886 +#endif /* __PART_EXT_H */
85887 --- /dev/null
85888 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P1023/part_integration_ext.h
85889 @@ -0,0 +1,635 @@
85890 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
85891 + * All rights reserved.
85892 + *
85893 + * Redistribution and use in source and binary forms, with or without
85894 + * modification, are permitted provided that the following conditions are met:
85895 + * * Redistributions of source code must retain the above copyright
85896 + * notice, this list of conditions and the following disclaimer.
85897 + * * Redistributions in binary form must reproduce the above copyright
85898 + * notice, this list of conditions and the following disclaimer in the
85899 + * documentation and/or other materials provided with the distribution.
85900 + * * Neither the name of Freescale Semiconductor nor the
85901 + * names of its contributors may be used to endorse or promote products
85902 + * derived from this software without specific prior written permission.
85903 + *
85904 + *
85905 + * ALTERNATIVELY, this software may be distributed under the terms of the
85906 + * GNU General Public License ("GPL") as published by the Free Software
85907 + * Foundation, either version 2 of that License or (at your option) any
85908 + * later version.
85909 + *
85910 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
85911 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
85912 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
85913 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
85914 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
85915 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
85916 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
85917 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
85918 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
85919 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
85920 + */
85921 +
85922 +/**************************************************************************//**
85923 + @File part_integration_ext.h
85924 +
85925 + @Description P1023 external definitions and structures.
85926 +*//***************************************************************************/
85927 +#ifndef __PART_INTEGRATION_EXT_H
85928 +#define __PART_INTEGRATION_EXT_H
85929 +
85930 +#include "std_ext.h"
85931 +#include "dpaa_integration_ext.h"
85932 +
85933 +
85934 +/**************************************************************************//**
85935 + @Group 1023_chip_id P1023 Application Programming Interface
85936 +
85937 + @Description P1023 Chip functions,definitions and enums.
85938 +
85939 + @{
85940 +*//***************************************************************************/
85941 +
85942 +#define INTG_MAX_NUM_OF_CORES 2
85943 +
85944 +
85945 +/**************************************************************************//**
85946 + @Description Module types.
85947 +*//***************************************************************************/
85948 +typedef enum e_ModuleId
85949 +{
85950 + e_MODULE_ID_LAW, /**< Local Access module */
85951 + e_MODULE_ID_ECM, /**< e500 Coherency Module */
85952 + e_MODULE_ID_DDR, /**< DDR memory controller */
85953 + e_MODULE_ID_I2C_1, /**< I2C 1 */
85954 + e_MODULE_ID_I2C_2, /**< I2C 1 */
85955 + e_MODULE_ID_DUART_1, /**< DUART module 1 */
85956 + e_MODULE_ID_DUART_2, /**< DUART module 2 */
85957 + e_MODULE_ID_LBC, /**< Local bus memory controller module */
85958 + e_MODULE_ID_PCIE_1, /**< PCI Express 1 controller module */
85959 + e_MODULE_ID_PCIE_ATMU_1, /**< PCI 1 ATMU Window */
85960 + e_MODULE_ID_PCIE_2, /**< PCI Express 2 controller module */
85961 + e_MODULE_ID_PCIE_ATMU_2, /**< PCI 2 ATMU Window */
85962 + e_MODULE_ID_PCIE_3, /**< PCI Express 3 controller module */
85963 + e_MODULE_ID_PCIE_ATMU_3, /**< PCI 3 ATMU Window */
85964 + e_MODULE_ID_MSI, /**< MSI registers */
85965 + e_MODULE_ID_L2_SRAM, /**< L2/SRAM Memory-Mapped controller module */
85966 + e_MODULE_ID_DMA_1, /**< DMA controller 1 */
85967 + e_MODULE_ID_DMA_2, /**< DMA controller 2 */
85968 + e_MODULE_ID_EPIC, /**< Programmable interrupt controller */
85969 + e_MODULE_ID_ESPI, /**< ESPI module */
85970 + e_MODULE_ID_GPIO, /**< General Purpose I/O */
85971 + e_MODULE_ID_SEC_GEN, /**< SEC 4.0 General registers */
85972 + e_MODULE_ID_SEC_QI, /**< SEC 4.0 QI registers */
85973 + e_MODULE_ID_SEC_JQ0, /**< SEC 4.0 JQ-0 registers */
85974 + e_MODULE_ID_SEC_JQ1, /**< SEC 4.0 JQ-1 registers */
85975 + e_MODULE_ID_SEC_JQ2, /**< SEC 4.0 JQ-2 registers */
85976 + e_MODULE_ID_SEC_JQ3, /**< SEC 4.0 JQ-3 registers */
85977 + e_MODULE_ID_SEC_RTIC, /**< SEC 4.0 RTIC registers */
85978 + e_MODULE_ID_SEC_DECO0_CCB0, /**< SEC 4.0 DECO-0/CCB-0 registers */
85979 + e_MODULE_ID_SEC_DECO1_CCB1, /**< SEC 4.0 DECO-1/CCB-1 registers */
85980 + e_MODULE_ID_SEC_DECO2_CCB2, /**< SEC 4.0 DECO-2/CCB-2 registers */
85981 + e_MODULE_ID_SEC_DECO3_CCB3, /**< SEC 4.0 DECO-3/CCB-3 registers */
85982 + e_MODULE_ID_SEC_DECO4_CCB4, /**< SEC 4.0 DECO-4/CCB-4 registers */
85983 + e_MODULE_ID_USB_DR_1, /**< USB 2.0 module 1 */
85984 + e_MODULE_ID_USB_DR_2, /**< USB 2.0 module 2 */
85985 + e_MODULE_ID_ETSEC_MII_MNG, /**< MII MNG registers */
85986 + e_MODULE_ID_ETSEC_1, /**< ETSEC module 1 */
85987 + e_MODULE_ID_ETSEC_2, /**< ETSEC module 2 */
85988 + e_MODULE_ID_GUTS, /**< Serial DMA */
85989 + e_MODULE_ID_PM, /**< Performance Monitor module */
85990 + e_MODULE_ID_QM, /**< Queue manager module */
85991 + e_MODULE_ID_BM, /**< Buffer manager module */
85992 + e_MODULE_ID_QM_CE_PORTAL,
85993 + e_MODULE_ID_QM_CI_PORTAL,
85994 + e_MODULE_ID_BM_CE_PORTAL,
85995 + e_MODULE_ID_BM_CI_PORTAL,
85996 + e_MODULE_ID_FM, /**< Frame manager #1 module */
85997 + e_MODULE_ID_FM_RTC, /**< FM Real-Time-Clock */
85998 + e_MODULE_ID_FM_MURAM, /**< FM Multi-User-RAM */
85999 + e_MODULE_ID_FM_BMI, /**< FM BMI block */
86000 + e_MODULE_ID_FM_QMI, /**< FM QMI block */
86001 + e_MODULE_ID_FM_PRS, /**< FM parser block */
86002 + e_MODULE_ID_FM_PORT_HO0, /**< FM Host-command/offline-parsing port block */
86003 + e_MODULE_ID_FM_PORT_HO1, /**< FM Host-command/offline-parsing port block */
86004 + e_MODULE_ID_FM_PORT_HO2, /**< FM Host-command/offline-parsing port block */
86005 + e_MODULE_ID_FM_PORT_HO3, /**< FM Host-command/offline-parsing port block */
86006 + e_MODULE_ID_FM_PORT_HO4, /**< FM Host-command/offline-parsing port block */
86007 + e_MODULE_ID_FM_PORT_1GRx0, /**< FM Rx 1G MAC port block */
86008 + e_MODULE_ID_FM_PORT_1GRx1, /**< FM Rx 1G MAC port block */
86009 + e_MODULE_ID_FM_PORT_1GTx0, /**< FM Tx 1G MAC port block */
86010 + e_MODULE_ID_FM_PORT_1GTx1, /**< FM Tx 1G MAC port block */
86011 + e_MODULE_ID_FM_PLCR, /**< FM Policer */
86012 + e_MODULE_ID_FM_KG, /**< FM Keygen */
86013 + e_MODULE_ID_FM_DMA, /**< FM DMA */
86014 + e_MODULE_ID_FM_FPM, /**< FM FPM */
86015 + e_MODULE_ID_FM_IRAM, /**< FM Instruction-RAM */
86016 + e_MODULE_ID_FM_1GMDIO0, /**< FM 1G MDIO MAC 0*/
86017 + e_MODULE_ID_FM_1GMDIO1, /**< FM 1G MDIO MAC 1*/
86018 + e_MODULE_ID_FM_PRS_IRAM, /**< FM SW-parser Instruction-RAM */
86019 + e_MODULE_ID_FM_RISC0, /**< FM risc #0 */
86020 + e_MODULE_ID_FM_RISC1, /**< FM risc #1 */
86021 + e_MODULE_ID_FM_1GMAC0, /**< FM 1G MAC #0 */
86022 + e_MODULE_ID_FM_1GMAC1, /**< FM 1G MAC #1 */
86023 + e_MODULE_ID_FM_MACSEC, /**< FM MACSEC */
86024 +
86025 + e_MODULE_ID_DUMMY_LAST
86026 +} e_ModuleId;
86027 +
86028 +#define NUM_OF_MODULES e_MODULE_ID_DUMMY_LAST
86029 +
86030 +
86031 +#define P1023_OFFSET_LAW 0x00000C08
86032 +#define P1023_OFFSET_ECM 0x00001000
86033 +#define P1023_OFFSET_DDR 0x00002000
86034 +#define P1023_OFFSET_I2C1 0x00003000
86035 +#define P1023_OFFSET_I2C2 0x00003100
86036 +#define P1023_OFFSET_DUART1 0x00004500
86037 +#define P1023_OFFSET_DUART2 0x00004600
86038 +#define P1023_OFFSET_LBC 0x00005000
86039 +#define P1023_OFFSET_ESPI 0x00007000
86040 +#define P1023_OFFSET_PCIE2 0x00009000
86041 +#define P1023_OFFSET_PCIE2_ATMU 0x00009C00
86042 +#define P1023_OFFSET_PCIE1 0x0000A000
86043 +#define P1023_OFFSET_PCIE1_ATMU 0x0000AC00
86044 +#define P1023_OFFSET_PCIE3 0x0000B000
86045 +#define P1023_OFFSET_PCIE3_ATMU 0x0000BC00
86046 +#define P1023_OFFSET_DMA2 0x0000C100
86047 +#define P1023_OFFSET_GPIO 0x0000F000
86048 +#define P1023_OFFSET_L2_SRAM 0x00020000
86049 +#define P1023_OFFSET_DMA1 0x00021100
86050 +#define P1023_OFFSET_USB1 0x00022000
86051 +#define P1023_OFFSET_SEC_GEN 0x00030000
86052 +#define P1023_OFFSET_SEC_JQ0 0x00031000
86053 +#define P1023_OFFSET_SEC_JQ1 0x00032000
86054 +#define P1023_OFFSET_SEC_JQ2 0x00033000
86055 +#define P1023_OFFSET_SEC_JQ3 0x00034000
86056 +#define P1023_OFFSET_SEC_RTIC 0x00036000
86057 +#define P1023_OFFSET_SEC_QI 0x00037000
86058 +#define P1023_OFFSET_SEC_DECO0_CCB0 0x00038000
86059 +#define P1023_OFFSET_SEC_DECO1_CCB1 0x00039000
86060 +#define P1023_OFFSET_SEC_DECO2_CCB2 0x0003a000
86061 +#define P1023_OFFSET_SEC_DECO3_CCB3 0x0003b000
86062 +#define P1023_OFFSET_SEC_DECO4_CCB4 0x0003c000
86063 +#define P1023_OFFSET_PIC 0x00040000
86064 +#define P1023_OFFSET_MSI 0x00041600
86065 +#define P1023_OFFSET_AXI 0x00081000
86066 +#define P1023_OFFSET_QM 0x00088000
86067 +#define P1023_OFFSET_BM 0x0008A000
86068 +#define P1022_OFFSET_PM 0x000E1000
86069 +
86070 +#define P1023_OFFSET_GUTIL 0x000E0000
86071 +#define P1023_OFFSET_PM 0x000E1000
86072 +#define P1023_OFFSET_DEBUG 0x000E2000
86073 +#define P1023_OFFSET_SERDES 0x000E3000
86074 +#define P1023_OFFSET_ROM 0x000F0000
86075 +#define P1023_OFFSET_FM 0x00100000
86076 +
86077 +#define P1023_OFFSET_FM_MURAM (P1023_OFFSET_FM + 0x00000000)
86078 +#define P1023_OFFSET_FM_BMI (P1023_OFFSET_FM + 0x00080000)
86079 +#define P1023_OFFSET_FM_QMI (P1023_OFFSET_FM + 0x00080400)
86080 +#define P1023_OFFSET_FM_PRS (P1023_OFFSET_FM + 0x00080800)
86081 +#define P1023_OFFSET_FM_PORT_HO0 (P1023_OFFSET_FM + 0x00081000)
86082 +#define P1023_OFFSET_FM_PORT_HO1 (P1023_OFFSET_FM + 0x00082000)
86083 +#define P1023_OFFSET_FM_PORT_HO2 (P1023_OFFSET_FM + 0x00083000)
86084 +#define P1023_OFFSET_FM_PORT_HO3 (P1023_OFFSET_FM + 0x00084000)
86085 +#define P1023_OFFSET_FM_PORT_HO4 (P1023_OFFSET_FM + 0x00085000)
86086 +#define P1023_OFFSET_FM_PORT_1GRX0 (P1023_OFFSET_FM + 0x00088000)
86087 +#define P1023_OFFSET_FM_PORT_1GRX1 (P1023_OFFSET_FM + 0x00089000)
86088 +#define P1023_OFFSET_FM_PORT_1GTX0 (P1023_OFFSET_FM + 0x000A8000)
86089 +#define P1023_OFFSET_FM_PORT_1GTX1 (P1023_OFFSET_FM + 0x000A9000)
86090 +#define P1023_OFFSET_FM_PLCR (P1023_OFFSET_FM + 0x000C0000)
86091 +#define P1023_OFFSET_FM_KG (P1023_OFFSET_FM + 0x000C1000)
86092 +#define P1023_OFFSET_FM_DMA (P1023_OFFSET_FM + 0x000C2000)
86093 +#define P1023_OFFSET_FM_FPM (P1023_OFFSET_FM + 0x000C3000)
86094 +#define P1023_OFFSET_FM_IRAM (P1023_OFFSET_FM + 0x000C4000)
86095 +#define P1023_OFFSET_FM_PRS_IRAM (P1023_OFFSET_FM + 0x000C7000)
86096 +#define P1023_OFFSET_FM_RISC0 (P1023_OFFSET_FM + 0x000D0000)
86097 +#define P1023_OFFSET_FM_RISC1 (P1023_OFFSET_FM + 0x000D0400)
86098 +#define P1023_OFFSET_FM_MACSEC (P1023_OFFSET_FM + 0x000D8000)
86099 +#define P1023_OFFSET_FM_1GMAC0 (P1023_OFFSET_FM + 0x000E0000)
86100 +#define P1023_OFFSET_FM_1GMDIO0 (P1023_OFFSET_FM + 0x000E1120)
86101 +#define P1023_OFFSET_FM_1GMAC1 (P1023_OFFSET_FM + 0x000E2000)
86102 +#define P1023_OFFSET_FM_1GMDIO1 (P1023_OFFSET_FM + 0x000E3000)
86103 +#define P1023_OFFSET_FM_RTC (P1023_OFFSET_FM + 0x000FE000)
86104 +
86105 +/* Offsets relative to QM or BM portals base */
86106 +#define P1023_OFFSET_PORTALS_CE_AREA 0x00000000 /* cache enabled area */
86107 +#define P1023_OFFSET_PORTALS_CI_AREA 0x00100000 /* cache inhibited area */
86108 +
86109 +#define P1023_OFFSET_PORTALS_CE(portal) (P1023_OFFSET_PORTALS_CE_AREA + 0x4000 * (portal))
86110 +#define P1023_OFFSET_PORTALS_CI(portal) (P1023_OFFSET_PORTALS_CI_AREA + 0x1000 * (portal))
86111 +
86112 +/**************************************************************************//**
86113 + @Description Transaction source ID (for memory controllers error reporting).
86114 +*//***************************************************************************/
86115 +typedef enum e_TransSrc
86116 +{
86117 + e_TRANS_SRC_PCIE_2 = 0x01, /**< PCIe port 2 */
86118 + e_TRANS_SRC_PCIE_1 = 0x02, /**< PCIe port 1 */
86119 + e_TRANS_SRC_PCIE_3 = 0x03, /**< PCIe port 3 */
86120 + e_TRANS_SRC_LBC = 0x04, /**< Enhanced local bus */
86121 + e_TRANS_SRC_DPAA_SW_PORTALS = 0x0E, /**< DPAA software portals or SRAM */
86122 + e_TRANS_SRC_DDR = 0x0F, /**< DDR controller */
86123 + e_TRANS_SRC_CORE_INS_FETCH = 0x10, /**< Processor (instruction) */
86124 + e_TRANS_SRC_CORE_DATA = 0x11, /**< Processor (data) */
86125 + e_TRANS_SRC_DMA = 0x15 /**< DMA */
86126 +} e_TransSrc;
86127 +
86128 +/**************************************************************************//**
86129 + @Description Local Access Window Target interface ID
86130 +*//***************************************************************************/
86131 +typedef enum e_P1023LawTargetId
86132 +{
86133 + e_P1023_LAW_TARGET_PCIE_2 = 0x01, /**< PCI Express 2 target interface */
86134 + e_P1023_LAW_TARGET_PCIE_1 = 0x02, /**< PCI Express 1 target interface */
86135 + e_P1023_LAW_TARGET_PCIE_3 = 0x03, /**< PCI Express 3 target interface */
86136 + e_P1023_LAW_TARGET_LBC = 0x04, /**< Local bus target interface */
86137 + e_P1023_LAW_TARGET_QM_PORTALS = 0x0E, /**< Queue Manager Portals */
86138 + e_P1023_LAW_TARGET_BM_PORTALS = 0x0E, /**< Buffer Manager Portals */
86139 + e_P1023_LAW_TARGET_SRAM = 0x0E, /**< SRAM scratchpad */
86140 + e_P1023_LAW_TARGET_DDR = 0x0F, /**< DDR target interface */
86141 + e_P1023_LAW_TARGET_NONE = 0xFF /**< Invalid target interface */
86142 +} e_P1023LawTargetId;
86143 +
86144 +
86145 +/**************************************************************************//**
86146 + @Group 1023_init_grp P1023 Initialization Unit
86147 +
86148 + @Description P1023 initialization unit API functions, definitions and enums
86149 +
86150 + @{
86151 +*//***************************************************************************/
86152 +
86153 +/**************************************************************************//**
86154 + @Description Part ID and revision number
86155 +*//***************************************************************************/
86156 +typedef enum e_P1023DeviceName
86157 +{
86158 + e_P1023_REV_INVALID = 0x00000000, /**< Invalid revision */
86159 + e_SC1023_REV_1_0 = (int)0x80FC0010, /**< SC1023 rev 1.0 */
86160 + e_SC1023_REV_1_1 = (int)0x80FC0011, /**< SC1023 rev 1.1 */
86161 + e_P1023_REV_1_0 = (int)0x80FE0010, /**< P1023 rev 1.0 with security */
86162 + e_P1023_REV_1_1 = (int)0x80FE0011, /**< P1023 rev 1.1 with security */
86163 + e_P1017_REV_1_1 = (int)0x80FF0011, /**< P1017 rev 1.1 with security */
86164 + e_P1023_REV_1_0_NO_SEC = (int)0x80F60010, /**< P1023 rev 1.0 without security */
86165 + e_P1023_REV_1_1_NO_SEC = (int)0x80F60011, /**< P1023 rev 1.1 without security */
86166 + e_P1017_REV_1_1_NO_SEC = (int)0x80F70011 /**< P1017 rev 1.1 without security */
86167 +} e_P1023DeviceName;
86168 +
86169 +/**************************************************************************//**
86170 + @Description structure representing P1023 initialization parameters
86171 +*//***************************************************************************/
86172 +typedef struct t_P1023Params
86173 +{
86174 + uintptr_t ccsrBaseAddress; /**< CCSR base address (virtual) */
86175 + uintptr_t bmPortalsBaseAddress; /**< Portals base address (virtual) */
86176 + uintptr_t qmPortalsBaseAddress; /**< Portals base address (virtual) */
86177 +} t_P1023Params;
86178 +
86179 +/**************************************************************************//**
86180 + @Function P1023_ConfigAndInit
86181 +
86182 + @Description General initiation of the chip registers.
86183 +
86184 + @Param[in] p_P1023Params - A pointer to data structure of parameters
86185 +
86186 + @Return A handle to the P1023 data structure.
86187 +*//***************************************************************************/
86188 +t_Handle P1023_ConfigAndInit(t_P1023Params *p_P1023Params);
86189 +
86190 +/**************************************************************************//**
86191 + @Function P1023_Free
86192 +
86193 + @Description Free all resources.
86194 +
86195 + @Param h_P1023 - (In) The handle of the initialized P1023 object.
86196 +
86197 + @Return E_OK on success; Other value otherwise.
86198 +*//***************************************************************************/
86199 +t_Error P1023_Free(t_Handle h_P1023);
86200 +
86201 +/**************************************************************************//**
86202 + @Function P1023_GetRevInfo
86203 +
86204 + @Description This routine enables access to chip and revision information.
86205 +
86206 + @Param[in] gutilBase - Base address of P1023 GUTIL registers.
86207 +
86208 + @Return Part ID and revision.
86209 +*//***************************************************************************/
86210 +e_P1023DeviceName P1023_GetRevInfo(uintptr_t gutilBase);
86211 +
86212 +/**************************************************************************//**
86213 + @Function P1023_GetE500Factor
86214 +
86215 + @Description Returns E500 core clock multiplication factor.
86216 +
86217 + @Param[in] gutilBase - Base address of P1023 GUTIL registers.
86218 + @Param[in] coreId - Id of the requested core.
86219 + @Param[out] p_E500MulFactor - Returns E500 to CCB multification factor.
86220 + @Param[out] p_E500DivFactor - Returns E500 to CCB division factor.
86221 +
86222 + @Return E_OK on success; Other value otherwise.
86223 +*
86224 +*//***************************************************************************/
86225 +t_Error P1023_GetE500Factor(uintptr_t gutilBase,
86226 + uint32_t coreId,
86227 + uint32_t *p_E500MulFactor,
86228 + uint32_t *p_E500DivFactor);
86229 +
86230 +/**************************************************************************//**
86231 + @Function P1023_GetFmFactor
86232 +
86233 + @Description returns FM multiplication factors. (This value is returned using
86234 + two parameters to avoid using float parameter).
86235 +
86236 + @Param[in] gutilBase - Base address of P1023 GUTIL registers.
86237 + @Param[out] p_FmMulFactor - returns E500 to CCB multification factor.
86238 + @Param[out] p_FmDivFactor - returns E500 to CCB division factor.
86239 +
86240 + @Return E_OK on success; Other value otherwise.
86241 +*//***************************************************************************/
86242 +t_Error P1023_GetFmFactor(uintptr_t gutilBase, uint32_t *p_FmMulFactor, uint32_t *p_FmDivFactor);
86243 +
86244 +/**************************************************************************//**
86245 + @Function P1023_GetCcbFactor
86246 +
86247 + @Description returns system multiplication factor.
86248 +
86249 + @Param[in] gutilBase - Base address of P1023 GUTIL registers.
86250 +
86251 + @Return System multiplication factor.
86252 +*//***************************************************************************/
86253 +uint32_t P1023_GetCcbFactor(uintptr_t gutilBase);
86254 +
86255 +#if 0
86256 +/**************************************************************************//**
86257 + @Function P1023_GetDdrFactor
86258 +
86259 + @Description returns the multiplication factor of the clock in for the DDR clock .
86260 + Note: assumes the ddr_in_clk is identical to the sys_in_clk
86261 +
86262 + @Param[in] gutilBase - Base address of P1023 GUTIL registers.
86263 + @Param p_DdrMulFactor - returns DDR in clk multification factor.
86264 + @Param p_DdrDivFactor - returns DDR division factor.
86265 +
86266 + @Return E_OK on success; Other value otherwise..
86267 +*//***************************************************************************/
86268 +t_Error P1023_GetDdrFactor( uintptr_t gutilBase,
86269 + uint32_t *p_DdrMulFactor,
86270 + uint32_t *p_DdrDivFactor);
86271 +
86272 +/**************************************************************************//**
86273 + @Function P1023_GetDdrType
86274 +
86275 + @Description returns the multiplication factor of the clock in for the DDR clock .
86276 +
86277 + @Param[in] gutilBase - Base address of P1023 GUTIL registers.
86278 + @Param p_DdrType - (Out) returns DDR type DDR1/DDR2/DDR3.
86279 +
86280 + @Return E_OK on success; Other value otherwise.
86281 +*//***************************************************************************/
86282 +t_Error P1023_GetDdrType(uintptr_t gutilBase, e_DdrType *p_DdrType );
86283 +#endif
86284 +
86285 +/** @} */ /* end of 1023_init_grp group */
86286 +/** @} */ /* end of 1023_grp group */
86287 +
86288 +#define CORE_E500V2
86289 +
86290 +#if 0 /* using unified values */
86291 +/*****************************************************************************
86292 + INTEGRATION-SPECIFIC MODULE CODES
86293 +******************************************************************************/
86294 +#define MODULE_UNKNOWN 0x00000000
86295 +#define MODULE_MEM 0x00010000
86296 +#define MODULE_MM 0x00020000
86297 +#define MODULE_CORE 0x00030000
86298 +#define MODULE_P1023 0x00040000
86299 +#define MODULE_MII 0x00050000
86300 +#define MODULE_PM 0x00060000
86301 +#define MODULE_MMU 0x00070000
86302 +#define MODULE_PIC 0x00080000
86303 +#define MODULE_L2_CACHE 0x00090000
86304 +#define MODULE_DUART 0x000a0000
86305 +#define MODULE_SERDES 0x000b0000
86306 +#define MODULE_PIO 0x000c0000
86307 +#define MODULE_QM 0x000d0000
86308 +#define MODULE_BM 0x000e0000
86309 +#define MODULE_SEC 0x000f0000
86310 +#define MODULE_FM 0x00100000
86311 +#define MODULE_FM_MURAM 0x00110000
86312 +#define MODULE_FM_PCD 0x00120000
86313 +#define MODULE_FM_RTC 0x00130000
86314 +#define MODULE_FM_MAC 0x00140000
86315 +#define MODULE_FM_PORT 0x00150000
86316 +#define MODULE_FM_MACSEC 0x00160000
86317 +#define MODULE_FM_MACSEC_SECY 0x00170000
86318 +#define MODULE_FM_SP 0x00280000
86319 +#define MODULE_ECM 0x00190000
86320 +#define MODULE_DMA 0x001a0000
86321 +#define MODULE_DDR 0x001b0000
86322 +#define MODULE_LAW 0x001c0000
86323 +#define MODULE_LBC 0x001d0000
86324 +#define MODULE_I2C 0x001e0000
86325 +#define MODULE_ESPI 0x001f0000
86326 +#define MODULE_PCI 0x00200000
86327 +#define MODULE_DPA_PORT 0x00210000
86328 +#define MODULE_USB 0x00220000
86329 +#endif /* using unified values */
86330 +
86331 +/*****************************************************************************
86332 + LBC INTEGRATION-SPECIFIC DEFINITIONS
86333 +******************************************************************************/
86334 +/**************************************************************************//**
86335 + @Group lbc_exception_grp LBC Exception Unit
86336 +
86337 + @Description LBC Exception unit API functions, definitions and enums
86338 +
86339 + @{
86340 +*//***************************************************************************/
86341 +
86342 +/**************************************************************************//**
86343 + @Anchor lbc_exbm
86344 +
86345 + @Collection LBC Errors Bit Mask
86346 +
86347 + These errors are reported through the exceptions callback..
86348 + The values can be or'ed in any combination in the errors mask
86349 + parameter of the errors report structure.
86350 +
86351 + These errors can also be passed as a bit-mask to
86352 + LBC_EnableErrorChecking() or LBC_DisableErrorChecking(),
86353 + for enabling or disabling error checking.
86354 + @{
86355 +*//***************************************************************************/
86356 +#define LBC_ERR_BUS_MONITOR 0x80000000 /**< Bus monitor error */
86357 +#define LBC_ERR_PARITY_ECC 0x20000000 /**< Parity error for GPCM/UPM */
86358 +#define LBC_ERR_WRITE_PROTECT 0x04000000 /**< Write protection error */
86359 +#define LBC_ERR_CHIP_SELECT 0x00080000 /**< Unrecognized chip select */
86360 +
86361 +#define LBC_ERR_ALL (LBC_ERR_BUS_MONITOR | LBC_ERR_PARITY_ECC | \
86362 + LBC_ERR_WRITE_PROTECT | LBC_ERR_CHIP_SELECT)
86363 + /**< All possible errors */
86364 +/* @} */
86365 +/** @} */ /* end of lbc_exception_grp group */
86366 +
86367 +#define LBC_NUM_OF_BANKS 2
86368 +#define LBC_MAX_CS_SIZE 0x0000000100000000LL
86369 +#define LBC_ATOMIC_OPERATION_SUPPORT
86370 +#define LBC_PARITY_SUPPORT
86371 +#define LBC_ADDRESS_SHIFT_SUPPORT
86372 +#define LBC_ADDRESS_HOLD_TIME_CTRL
86373 +#define LBC_HIGH_CLK_DIVIDERS
86374 +#define LBC_FCM_AVAILABLE
86375 +
86376 +
86377 +/*****************************************************************************
86378 + LAW INTEGRATION-SPECIFIC DEFINITIONS
86379 +******************************************************************************/
86380 +#define LAW_ARCH_CCB
86381 +#define LAW_NUM_OF_WINDOWS 12
86382 +#define LAW_MIN_WINDOW_SIZE 0x0000000000001000LL /**< 4KB */
86383 +#define LAW_MAX_WINDOW_SIZE 0x0000001000000000LL /**< 32GB */
86384 +
86385 +
86386 +/*****************************************************************************
86387 + SPI INTEGRATION-SPECIFIC DEFINITIONS
86388 +******************************************************************************/
86389 +#define SPI_NUM_OF_CONTROLLERS 1
86390 +
86391 +/*****************************************************************************
86392 + PCI/PCIe INTEGRATION-SPECIFIC DEFINITIONS
86393 +******************************************************************************/
86394 +
86395 +#define PCI_MAX_INBOUND_WINDOWS_NUM 4
86396 +#define PCI_MAX_OUTBOUND_WINDOWS_NUM 5
86397 +
86398 +/**************************************************************************//**
86399 + @Description Target interface of an inbound window
86400 +*//***************************************************************************/
86401 +typedef enum e_PciTargetInterface
86402 +{
86403 + e_PCI_TARGET_PCIE_2 = 0x1, /**< PCI Express target interface 2 */
86404 + e_PCI_TARGET_PCIE_1 = 0x2, /**< PCI Express target interface 1 */
86405 + e_PCI_TARGET_PCIE_3 = 0x3, /**< PCI Express target interface 3 */
86406 + e_PCI_TARGET_LOCAL_MEMORY = 0xF /**< Local Memory (DDR SDRAM, Local Bus, SRAM) target interface */
86407 +
86408 +} e_PciTargetInterface;
86409 +
86410 +/*****************************************************************************
86411 + DDR INTEGRATION-SPECIFIC DEFINITIONS
86412 +******************************************************************************/
86413 +#define DDR_NUM_OF_VALID_CS 2
86414 +
86415 +/*****************************************************************************
86416 + SEC INTEGRATION-SPECIFIC DEFINITIONS
86417 +******************************************************************************/
86418 +#define SEC_ERRATA_STAT_REGS_UNUSABLE
86419 +
86420 +/*****************************************************************************
86421 + DMA INTEGRATION-SPECIFIC DEFINITIONS
86422 +******************************************************************************/
86423 +#define DMA_NUM_OF_CONTROLLERS 2
86424 +
86425 +
86426 +
86427 +
86428 +/*****************************************************************************
86429 + 1588 INTEGRATION-SPECIFIC DEFINITIONS
86430 +******************************************************************************/
86431 +#define PTP_V2
86432 +
86433 +/**************************************************************************//**
86434 + @Function P1023_GetMuxControlReg
86435 +
86436 + @Description Returns the value of PMUXCR (Alternate Function Signal Multiplex
86437 + Control Register)
86438 +
86439 + @Param[in] gutilBase - Base address of P1023 GUTIL registers.
86440 +
86441 + @Return Value of PMUXCR
86442 +*//***************************************************************************/
86443 +uint32_t P1023_GetMuxControlReg(uintptr_t gutilBase);
86444 +
86445 +/**************************************************************************//**
86446 + @Function P1023_SetMuxControlReg
86447 +
86448 + @Description Sets the value of PMUXCR (Alternate Function Signal Multiplex
86449 + Control Register)
86450 +
86451 + @Param[in] gutilBase - Base address of P1023 GUTIL registers.
86452 + @Param[in] val - the new value for PMUXCR.
86453 +
86454 + @Return None
86455 +*//***************************************************************************/
86456 +void P1023_SetMuxControlReg(uintptr_t gutilBase, uint32_t val);
86457 +
86458 +/**************************************************************************//**
86459 + @Function P1023_GetDeviceDisableStatusRegister
86460 +
86461 + @Description Returns the value of DEVDISR (Device Disable Register)
86462 +
86463 + @Param[in] gutilBase - Base address of P1023 GUTIL registers.
86464 +
86465 + @Return Value of DEVDISR
86466 +*//***************************************************************************/
86467 +uint32_t P1023_GetDeviceDisableStatusRegister(uintptr_t gutilBase);
86468 +
86469 +/**************************************************************************//**
86470 + @Function P1023_GetPorDeviceStatusRegister
86471 +
86472 + @Description Returns the value of POR Device Status Register
86473 +
86474 + @Param[in] gutilBase - Base address of P1023 GUTIL registers.
86475 +
86476 + @Return POR Device Status Register
86477 +*//***************************************************************************/
86478 +uint32_t P1023_GetPorDeviceStatusRegister(uintptr_t gutilBase);
86479 +
86480 +/**************************************************************************//**
86481 + @Function P1023_GetPorBootModeStatusRegister
86482 +
86483 + @Description Returns the value of POR Boot Mode Status Register
86484 +
86485 + @Param[in] gutilBase - Base address of P1023 GUTIL registers.
86486 +
86487 + @Return POR Boot Mode Status Register value
86488 +*//***************************************************************************/
86489 +uint32_t P1023_GetPorBootModeStatusRegister(uintptr_t gutilBase);
86490 +
86491 +
86492 +#define PORDEVSR_SGMII1_DIS 0x10000000
86493 +#define PORDEVSR_SGMII2_DIS 0x08000000
86494 +#define PORDEVSR_ECP1 0x02000000
86495 +#define PORDEVSR_IO_SEL 0x00780000
86496 +#define PORDEVSR_IO_SEL_SHIFT 19
86497 +#define PORBMSR_HA 0x00070000
86498 +#define PORBMSR_HA_SHIFT 16
86499 +
86500 +#define DEVDISR_QM_BM 0x80000000
86501 +#define DEVDISR_FM 0x40000000
86502 +#define DEVDISR_PCIE1 0x20000000
86503 +#define DEVDISR_MAC_SEC 0x10000000
86504 +#define DEVDISR_ELBC 0x08000000
86505 +#define DEVDISR_PCIE2 0x04000000
86506 +#define DEVDISR_PCIE3 0x02000000
86507 +#define DEVDISR_CAAM 0x01000000
86508 +#define DEVDISR_USB0 0x00800000
86509 +#define DEVDISR_1588 0x00020000
86510 +#define DEVDISR_CORE0 0x00008000
86511 +#define DEVDISR_TB0 0x00004000
86512 +#define DEVDISR_CORE1 0x00002000
86513 +#define DEVDISR_TB1 0x00001000
86514 +#define DEVDISR_DMA1 0x00000400
86515 +#define DEVDISR_DMA2 0x00000200
86516 +#define DEVDISR_DDR 0x00000010
86517 +#define DEVDISR_TSEC1 0x00000080
86518 +#define DEVDISR_TSEC2 0x00000040
86519 +#define DEVDISR_SPI 0x00000008
86520 +#define DEVDISR_I2C 0x00000004
86521 +#define DEVDISR_DUART 0x00000002
86522 +
86523 +
86524 +#endif /* __PART_INTEGRATION_EXT_H */
86525 --- /dev/null
86526 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P3040_P4080_P5020/dpaa_integration_ext.h
86527 @@ -0,0 +1,276 @@
86528 +/* Copyright (c) 2009-2012 Freescale Semiconductor, Inc
86529 + * All rights reserved.
86530 + *
86531 + * Redistribution and use in source and binary forms, with or without
86532 + * modification, are permitted provided that the following conditions are met:
86533 + * * Redistributions of source code must retain the above copyright
86534 + * notice, this list of conditions and the following disclaimer.
86535 + * * Redistributions in binary form must reproduce the above copyright
86536 + * notice, this list of conditions and the following disclaimer in the
86537 + * documentation and/or other materials provided with the distribution.
86538 + * * Neither the name of Freescale Semiconductor nor the
86539 + * names of its contributors may be used to endorse or promote products
86540 + * derived from this software without specific prior written permission.
86541 + *
86542 + *
86543 + * ALTERNATIVELY, this software may be distributed under the terms of the
86544 + * GNU General Public License ("GPL") as published by the Free Software
86545 + * Foundation, either version 2 of that License or (at your option) any
86546 + * later version.
86547 + *
86548 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
86549 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
86550 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
86551 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
86552 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
86553 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
86554 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
86555 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
86556 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
86557 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86558 + */
86559 +
86560 +/**************************************************************************//**
86561 + @File dpaa_integration_ext.h
86562 +
86563 + @Description P3040/P4080/P5020 FM external definitions and structures.
86564 +*//***************************************************************************/
86565 +#ifndef __DPAA_INTEGRATION_EXT_H
86566 +#define __DPAA_INTEGRATION_EXT_H
86567 +
86568 +#include "std_ext.h"
86569 +
86570 +
86571 +#define DPAA_VERSION 10
86572 +
86573 +typedef enum {
86574 + e_DPAA_SWPORTAL0 = 0,
86575 + e_DPAA_SWPORTAL1,
86576 + e_DPAA_SWPORTAL2,
86577 + e_DPAA_SWPORTAL3,
86578 + e_DPAA_SWPORTAL4,
86579 + e_DPAA_SWPORTAL5,
86580 + e_DPAA_SWPORTAL6,
86581 + e_DPAA_SWPORTAL7,
86582 + e_DPAA_SWPORTAL8,
86583 + e_DPAA_SWPORTAL9,
86584 + e_DPAA_SWPORTAL_DUMMY_LAST
86585 +} e_DpaaSwPortal;
86586 +
86587 +typedef enum {
86588 + e_DPAA_DCPORTAL0 = 0,
86589 + e_DPAA_DCPORTAL1,
86590 + e_DPAA_DCPORTAL2,
86591 + e_DPAA_DCPORTAL3,
86592 + e_DPAA_DCPORTAL4,
86593 + e_DPAA_DCPORTAL_DUMMY_LAST
86594 +} e_DpaaDcPortal;
86595 +
86596 +#define DPAA_MAX_NUM_OF_SW_PORTALS e_DPAA_SWPORTAL_DUMMY_LAST
86597 +#define DPAA_MAX_NUM_OF_DC_PORTALS e_DPAA_DCPORTAL_DUMMY_LAST
86598 +
86599 +/*****************************************************************************
86600 + QMan INTEGRATION-SPECIFIC DEFINITIONS
86601 +******************************************************************************/
86602 +#define QM_MAX_NUM_OF_POOL_CHANNELS 15 /**< Total number of channels, dedicated and pool */
86603 +#define QM_MAX_NUM_OF_WQ 8 /**< Number of work queues per channel */
86604 +#define QM_MAX_NUM_OF_SWP_AS 4
86605 +#define QM_MAX_NUM_OF_CGS 256 /**< Number of congestion groups */
86606 +#define QM_MAX_NUM_OF_FQIDS (16 * MEGABYTE) /**< FQIDs range - 24 bits */
86607 +
86608 +/**************************************************************************//**
86609 + @Description Work Queue Channel assignments in QMan.
86610 +*//***************************************************************************/
86611 +typedef enum
86612 +{
86613 + e_QM_FQ_CHANNEL_SWPORTAL0 = 0, /**< Dedicated channels serviced by software portals 0 to 9 */
86614 + e_QM_FQ_CHANNEL_SWPORTAL1,
86615 + e_QM_FQ_CHANNEL_SWPORTAL2,
86616 + e_QM_FQ_CHANNEL_SWPORTAL3,
86617 + e_QM_FQ_CHANNEL_SWPORTAL4,
86618 + e_QM_FQ_CHANNEL_SWPORTAL5,
86619 + e_QM_FQ_CHANNEL_SWPORTAL6,
86620 + e_QM_FQ_CHANNEL_SWPORTAL7,
86621 + e_QM_FQ_CHANNEL_SWPORTAL8,
86622 + e_QM_FQ_CHANNEL_SWPORTAL9,
86623 +
86624 + e_QM_FQ_CHANNEL_POOL1 = 0x21, /**< Pool channels that can be serviced by any of the software portals */
86625 + e_QM_FQ_CHANNEL_POOL2,
86626 + e_QM_FQ_CHANNEL_POOL3,
86627 + e_QM_FQ_CHANNEL_POOL4,
86628 + e_QM_FQ_CHANNEL_POOL5,
86629 + e_QM_FQ_CHANNEL_POOL6,
86630 + e_QM_FQ_CHANNEL_POOL7,
86631 + e_QM_FQ_CHANNEL_POOL8,
86632 + e_QM_FQ_CHANNEL_POOL9,
86633 + e_QM_FQ_CHANNEL_POOL10,
86634 + e_QM_FQ_CHANNEL_POOL11,
86635 + e_QM_FQ_CHANNEL_POOL12,
86636 + e_QM_FQ_CHANNEL_POOL13,
86637 + e_QM_FQ_CHANNEL_POOL14,
86638 + e_QM_FQ_CHANNEL_POOL15,
86639 +
86640 + e_QM_FQ_CHANNEL_FMAN0_SP0 = 0x40, /**< Dedicated channels serviced by Direct Connect Portal 0:
86641 + connected to FMan 0; assigned in incrementing order to
86642 + each sub-portal (SP) in the portal */
86643 + e_QM_FQ_CHANNEL_FMAN0_SP1,
86644 + e_QM_FQ_CHANNEL_FMAN0_SP2,
86645 + e_QM_FQ_CHANNEL_FMAN0_SP3,
86646 + e_QM_FQ_CHANNEL_FMAN0_SP4,
86647 + e_QM_FQ_CHANNEL_FMAN0_SP5,
86648 + e_QM_FQ_CHANNEL_FMAN0_SP6,
86649 + e_QM_FQ_CHANNEL_FMAN0_SP7,
86650 + e_QM_FQ_CHANNEL_FMAN0_SP8,
86651 + e_QM_FQ_CHANNEL_FMAN0_SP9,
86652 + e_QM_FQ_CHANNEL_FMAN0_SP10,
86653 + e_QM_FQ_CHANNEL_FMAN0_SP11,
86654 +/* difference between 5020 and 4080 :) */
86655 + e_QM_FQ_CHANNEL_FMAN1_SP0 = 0x60,
86656 + e_QM_FQ_CHANNEL_FMAN1_SP1,
86657 + e_QM_FQ_CHANNEL_FMAN1_SP2,
86658 + e_QM_FQ_CHANNEL_FMAN1_SP3,
86659 + e_QM_FQ_CHANNEL_FMAN1_SP4,
86660 + e_QM_FQ_CHANNEL_FMAN1_SP5,
86661 + e_QM_FQ_CHANNEL_FMAN1_SP6,
86662 + e_QM_FQ_CHANNEL_FMAN1_SP7,
86663 + e_QM_FQ_CHANNEL_FMAN1_SP8,
86664 + e_QM_FQ_CHANNEL_FMAN1_SP9,
86665 + e_QM_FQ_CHANNEL_FMAN1_SP10,
86666 + e_QM_FQ_CHANNEL_FMAN1_SP11,
86667 +
86668 + e_QM_FQ_CHANNEL_CAAM = 0x80, /**< Dedicated channel serviced by Direct Connect Portal 2:
86669 + connected to SEC 4.x */
86670 +
86671 + e_QM_FQ_CHANNEL_PME = 0xA0, /**< Dedicated channel serviced by Direct Connect Portal 3:
86672 + connected to PME */
86673 + e_QM_FQ_CHANNEL_RAID = 0xC0 /**< Dedicated channel serviced by Direct Connect Portal 4:
86674 + connected to RAID */
86675 +} e_QmFQChannel;
86676 +
86677 +/*****************************************************************************
86678 + BMan INTEGRATION-SPECIFIC DEFINITIONS
86679 +******************************************************************************/
86680 +#define BM_MAX_NUM_OF_POOLS 64 /**< Number of buffers pools */
86681 +
86682 +
86683 +/*****************************************************************************
86684 + FM INTEGRATION-SPECIFIC DEFINITIONS
86685 +******************************************************************************/
86686 +#define INTG_MAX_NUM_OF_FM 2
86687 +
86688 +/* Ports defines */
86689 +#define FM_MAX_NUM_OF_1G_MACS 5
86690 +#define FM_MAX_NUM_OF_10G_MACS 1
86691 +#define FM_MAX_NUM_OF_MACS (FM_MAX_NUM_OF_1G_MACS + FM_MAX_NUM_OF_10G_MACS)
86692 +#define FM_MAX_NUM_OF_OH_PORTS 7
86693 +
86694 +#define FM_MAX_NUM_OF_1G_RX_PORTS FM_MAX_NUM_OF_1G_MACS
86695 +#define FM_MAX_NUM_OF_10G_RX_PORTS FM_MAX_NUM_OF_10G_MACS
86696 +#define FM_MAX_NUM_OF_RX_PORTS (FM_MAX_NUM_OF_10G_RX_PORTS + FM_MAX_NUM_OF_1G_RX_PORTS)
86697 +
86698 +#define FM_MAX_NUM_OF_1G_TX_PORTS FM_MAX_NUM_OF_1G_MACS
86699 +#define FM_MAX_NUM_OF_10G_TX_PORTS FM_MAX_NUM_OF_10G_MACS
86700 +#define FM_MAX_NUM_OF_TX_PORTS (FM_MAX_NUM_OF_10G_TX_PORTS + FM_MAX_NUM_OF_1G_TX_PORTS)
86701 +
86702 +#define FM_PORT_MAX_NUM_OF_EXT_POOLS 8 /**< Number of external BM pools per Rx port */
86703 +#define FM_PORT_NUM_OF_CONGESTION_GRPS 256 /**< Total number of congestion groups in QM */
86704 +#define FM_MAX_NUM_OF_SUB_PORTALS 12
86705 +#define FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS 0
86706 +
86707 +/* Rams defines */
86708 +#define FM_MURAM_SIZE (160*KILOBYTE)
86709 +#define FM_IRAM_SIZE(major, minor) (64 * KILOBYTE)
86710 +#define FM_NUM_OF_CTRL 2
86711 +
86712 +/* PCD defines */
86713 +#define FM_PCD_PLCR_NUM_ENTRIES 256 /**< Total number of policer profiles */
86714 +#define FM_PCD_KG_NUM_OF_SCHEMES 32 /**< Total number of KG schemes */
86715 +#define FM_PCD_MAX_NUM_OF_CLS_PLANS 256 /**< Number of classification plan entries. */
86716 +#define FM_PCD_PRS_SW_PATCHES_SIZE 0x00000200 /**< Number of bytes saved for patches */
86717 +#define FM_PCD_SW_PRS_SIZE 0x00000800 /**< Total size of SW parser area */
86718 +
86719 +/* RTC defines */
86720 +#define FM_RTC_NUM_OF_ALARMS 2 /**< RTC number of alarms */
86721 +#define FM_RTC_NUM_OF_PERIODIC_PULSES 2 /**< RTC number of periodic pulses */
86722 +#define FM_RTC_NUM_OF_EXT_TRIGGERS 2 /**< RTC number of external triggers */
86723 +
86724 +/* QMI defines */
86725 +#define QMI_MAX_NUM_OF_TNUMS 64
86726 +#define QMI_DEF_TNUMS_THRESH 48
86727 +
86728 +/* FPM defines */
86729 +#define FM_NUM_OF_FMAN_CTRL_EVENT_REGS 4
86730 +
86731 +/* DMA defines */
86732 +#define DMA_THRESH_MAX_COMMQ 31
86733 +#define DMA_THRESH_MAX_BUF 127
86734 +
86735 +/* BMI defines */
86736 +#define BMI_MAX_NUM_OF_TASKS 128
86737 +#define BMI_MAX_NUM_OF_DMAS 32
86738 +#define BMI_MAX_FIFO_SIZE (FM_MURAM_SIZE)
86739 +#define PORT_MAX_WEIGHT 16
86740 +
86741 +
86742 +#define FM_CHECK_PORT_RESTRICTIONS(__validPorts, __newPortIndx) TRUE
86743 +
86744 +/* p4080-rev1 unique features */
86745 +#define QM_CGS_NO_FRAME_MODE
86746 +
86747 +/* p4080 unique features */
86748 +#define FM_NO_DISPATCH_RAM_ECC
86749 +#define FM_NO_WATCHDOG
86750 +#define FM_NO_TNUM_AGING
86751 +#define FM_KG_NO_BYPASS_FQID_GEN
86752 +#define FM_KG_NO_BYPASS_PLCR_PROFILE_GEN
86753 +#define FM_NO_BACKUP_POOLS
86754 +#define FM_NO_OP_OBSERVED_POOLS
86755 +#define FM_NO_ADVANCED_RATE_LIMITER
86756 +#define FM_NO_OP_OBSERVED_CGS
86757 +#define FM_HAS_TOTAL_DMAS
86758 +#define FM_KG_NO_IPPID_SUPPORT
86759 +#define FM_NO_GUARANTEED_RESET_VALUES
86760 +#define FM_MAC_RESET
86761 +
86762 +/* FM erratas */
86763 +#define FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
86764 +#define FM_TX_SHORT_FRAME_BAD_TS_ERRATA_10GMAC_A006 /* No implementation, Out of LLD scope */
86765 +#define FM_TX_FIFO_CORRUPTION_ERRATA_10GMAC_A007
86766 +#define FM_ECC_HALT_NO_SYNC_ERRATA_10GMAC_A008
86767 +#define FM_TX_INVALID_ECC_ERRATA_10GMAC_A009 /* Out of LLD scope, user may disable ECC exceptions using FM_DisableRamsEcc */
86768 +#define FM_BAD_VLAN_DETECT_ERRATA_10GMAC_A010
86769 +
86770 +#define FM_RX_PREAM_4_ERRATA_DTSEC_A001
86771 +#define FM_GRS_ERRATA_DTSEC_A002
86772 +#define FM_BAD_TX_TS_IN_B_2_B_ERRATA_DTSEC_A003
86773 +#define FM_GTS_ERRATA_DTSEC_A004
86774 +#define FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012
86775 +#define FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014
86776 +#define FM_GTS_AFTER_DROPPED_FRAME_ERRATA_DTSEC_A004839
86777 +
86778 +#define FM_MAGIC_PACKET_UNRECOGNIZED_ERRATA_DTSEC2 /* No implementation, Out of LLD scope */
86779 +#define FM_TX_LOCKUP_ERRATA_DTSEC6
86780 +
86781 +#define FM_HC_DEF_FQID_ONLY_ERRATA_FMAN_A003 /* Implemented by ucode */
86782 +#define FM_DEBUG_TRACE_FMAN_A004 /* No implementation, Out of LLD scope */
86783 +
86784 +#define FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173
86785 +
86786 +#define FM_10G_REM_N_LCL_FLT_EX_10GMAC_ERRATA_SW005
86787 +
86788 +#define FM_LEN_CHECK_ERRATA_FMAN_SW002
86789 +
86790 +#define FM_NO_CTXA_COPY_ERRATA_FMAN_SW001
86791 +#define FM_KG_ERASE_FLOW_ID_ERRATA_FMAN_SW004
86792 +
86793 +/*****************************************************************************
86794 + FM MACSEC INTEGRATION-SPECIFIC DEFINITIONS
86795 +******************************************************************************/
86796 +#define NUM_OF_RX_SC 16
86797 +#define NUM_OF_TX_SC 16
86798 +
86799 +#define NUM_OF_SA_PER_RX_SC 2
86800 +#define NUM_OF_SA_PER_TX_SC 2
86801 +
86802 +
86803 +#endif /* __DPAA_INTEGRATION_EXT_H */
86804 --- /dev/null
86805 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P3040_P4080_P5020/part_ext.h
86806 @@ -0,0 +1,83 @@
86807 +/*
86808 + * Copyright 2008-2012 Freescale Semiconductor Inc.
86809 + *
86810 + * Redistribution and use in source and binary forms, with or without
86811 + * modification, are permitted provided that the following conditions are met:
86812 + * * Redistributions of source code must retain the above copyright
86813 + * notice, this list of conditions and the following disclaimer.
86814 + * * Redistributions in binary form must reproduce the above copyright
86815 + * notice, this list of conditions and the following disclaimer in the
86816 + * documentation and/or other materials provided with the distribution.
86817 + * * Neither the name of Freescale Semiconductor nor the
86818 + * names of its contributors may be used to endorse or promote products
86819 + * derived from this software without specific prior written permission.
86820 + *
86821 + *
86822 + * ALTERNATIVELY, this software may be distributed under the terms of the
86823 + * GNU General Public License ("GPL") as published by the Free Software
86824 + * Foundation, either version 2 of that License or (at your option) any
86825 + * later version.
86826 + *
86827 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
86828 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
86829 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
86830 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
86831 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
86832 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
86833 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
86834 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
86835 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
86836 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86837 + */
86838 +
86839 +/**************************************************************************//**
86840 +
86841 + @File part_ext.h
86842 +
86843 + @Description Definitions for the part (integration) module.
86844 +*//***************************************************************************/
86845 +
86846 +#ifndef __PART_EXT_H
86847 +#define __PART_EXT_H
86848 +
86849 +#include "std_ext.h"
86850 +#include "part_integration_ext.h"
86851 +
86852 +
86853 +#if !(defined(MPC8306) || \
86854 + defined(MPC8309) || \
86855 + defined(MPC834x) || \
86856 + defined(MPC836x) || \
86857 + defined(MPC832x) || \
86858 + defined(MPC837x) || \
86859 + defined(MPC8568) || \
86860 + defined(MPC8569) || \
86861 + defined(P1020) || \
86862 + defined(P1021) || \
86863 + defined(P1022) || \
86864 + defined(P1023) || \
86865 + defined(P2020) || \
86866 + defined(P2040) || \
86867 + defined(P3041) || \
86868 + defined(P4080) || \
86869 + defined(SC4080) || \
86870 + defined(P5020) || \
86871 + defined(MSC814x))
86872 +#error "unable to proceed without chip-definition"
86873 +#endif /* !(defined(MPC834x) || ... */
86874 +
86875 +
86876 +/**************************************************************************//*
86877 + @Description Part data structure - must be contained in any integration
86878 + data structure.
86879 +*//***************************************************************************/
86880 +typedef struct t_Part
86881 +{
86882 + uintptr_t (* f_GetModuleBase)(t_Handle h_Part, e_ModuleId moduleId);
86883 + /**< Returns the address of the module's memory map base. */
86884 + e_ModuleId (* f_GetModuleIdByBase)(t_Handle h_Part, uintptr_t baseAddress);
86885 + /**< Returns the module's ID according to its memory map base. */
86886 +} t_Part;
86887 +
86888 +
86889 +#endif /* __PART_EXT_H */
86890 --- /dev/null
86891 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P3040_P4080_P5020/part_integration_ext.h
86892 @@ -0,0 +1,336 @@
86893 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
86894 + * All rights reserved.
86895 + *
86896 + * Redistribution and use in source and binary forms, with or without
86897 + * modification, are permitted provided that the following conditions are met:
86898 + * * Redistributions of source code must retain the above copyright
86899 + * notice, this list of conditions and the following disclaimer.
86900 + * * Redistributions in binary form must reproduce the above copyright
86901 + * notice, this list of conditions and the following disclaimer in the
86902 + * documentation and/or other materials provided with the distribution.
86903 + * * Neither the name of Freescale Semiconductor nor the
86904 + * names of its contributors may be used to endorse or promote products
86905 + * derived from this software without specific prior written permission.
86906 + *
86907 + *
86908 + * ALTERNATIVELY, this software may be distributed under the terms of the
86909 + * GNU General Public License ("GPL") as published by the Free Software
86910 + * Foundation, either version 2 of that License or (at your option) any
86911 + * later version.
86912 + *
86913 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
86914 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
86915 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
86916 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
86917 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
86918 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
86919 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
86920 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
86921 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
86922 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86923 + */
86924 +
86925 +/**************************************************************************//**
86926 + @File part_integration_ext.h
86927 +
86928 + @Description P3040/P4080/P5020 external definitions and structures.
86929 +*//***************************************************************************/
86930 +#ifndef __PART_INTEGRATION_EXT_H
86931 +#define __PART_INTEGRATION_EXT_H
86932 +
86933 +#include "std_ext.h"
86934 +#include "dpaa_integration_ext.h"
86935 +
86936 +
86937 +/**************************************************************************//**
86938 + @Group P3040/P4080/P5020_chip_id P5020 Application Programming Interface
86939 +
86940 + @Description P3040/P4080/P5020 Chip functions,definitions and enums.
86941 +
86942 + @{
86943 +*//***************************************************************************/
86944 +
86945 +#define CORE_E500MC
86946 +
86947 +#define INTG_MAX_NUM_OF_CORES 1
86948 +
86949 +
86950 +/**************************************************************************//**
86951 + @Description Module types.
86952 +*//***************************************************************************/
86953 +typedef enum e_ModuleId
86954 +{
86955 + e_MODULE_ID_DUART_1 = 0,
86956 + e_MODULE_ID_DUART_2,
86957 + e_MODULE_ID_DUART_3,
86958 + e_MODULE_ID_DUART_4,
86959 + e_MODULE_ID_LAW,
86960 + e_MODULE_ID_LBC,
86961 + e_MODULE_ID_PAMU,
86962 + e_MODULE_ID_QM, /**< Queue manager module */
86963 + e_MODULE_ID_BM, /**< Buffer manager module */
86964 + e_MODULE_ID_QM_CE_PORTAL_0,
86965 + e_MODULE_ID_QM_CI_PORTAL_0,
86966 + e_MODULE_ID_QM_CE_PORTAL_1,
86967 + e_MODULE_ID_QM_CI_PORTAL_1,
86968 + e_MODULE_ID_QM_CE_PORTAL_2,
86969 + e_MODULE_ID_QM_CI_PORTAL_2,
86970 + e_MODULE_ID_QM_CE_PORTAL_3,
86971 + e_MODULE_ID_QM_CI_PORTAL_3,
86972 + e_MODULE_ID_QM_CE_PORTAL_4,
86973 + e_MODULE_ID_QM_CI_PORTAL_4,
86974 + e_MODULE_ID_QM_CE_PORTAL_5,
86975 + e_MODULE_ID_QM_CI_PORTAL_5,
86976 + e_MODULE_ID_QM_CE_PORTAL_6,
86977 + e_MODULE_ID_QM_CI_PORTAL_6,
86978 + e_MODULE_ID_QM_CE_PORTAL_7,
86979 + e_MODULE_ID_QM_CI_PORTAL_7,
86980 + e_MODULE_ID_QM_CE_PORTAL_8,
86981 + e_MODULE_ID_QM_CI_PORTAL_8,
86982 + e_MODULE_ID_QM_CE_PORTAL_9,
86983 + e_MODULE_ID_QM_CI_PORTAL_9,
86984 + e_MODULE_ID_BM_CE_PORTAL_0,
86985 + e_MODULE_ID_BM_CI_PORTAL_0,
86986 + e_MODULE_ID_BM_CE_PORTAL_1,
86987 + e_MODULE_ID_BM_CI_PORTAL_1,
86988 + e_MODULE_ID_BM_CE_PORTAL_2,
86989 + e_MODULE_ID_BM_CI_PORTAL_2,
86990 + e_MODULE_ID_BM_CE_PORTAL_3,
86991 + e_MODULE_ID_BM_CI_PORTAL_3,
86992 + e_MODULE_ID_BM_CE_PORTAL_4,
86993 + e_MODULE_ID_BM_CI_PORTAL_4,
86994 + e_MODULE_ID_BM_CE_PORTAL_5,
86995 + e_MODULE_ID_BM_CI_PORTAL_5,
86996 + e_MODULE_ID_BM_CE_PORTAL_6,
86997 + e_MODULE_ID_BM_CI_PORTAL_6,
86998 + e_MODULE_ID_BM_CE_PORTAL_7,
86999 + e_MODULE_ID_BM_CI_PORTAL_7,
87000 + e_MODULE_ID_BM_CE_PORTAL_8,
87001 + e_MODULE_ID_BM_CI_PORTAL_8,
87002 + e_MODULE_ID_BM_CE_PORTAL_9,
87003 + e_MODULE_ID_BM_CI_PORTAL_9,
87004 + e_MODULE_ID_FM1, /**< Frame manager #1 module */
87005 + e_MODULE_ID_FM1_RTC, /**< FM Real-Time-Clock */
87006 + e_MODULE_ID_FM1_MURAM, /**< FM Multi-User-RAM */
87007 + e_MODULE_ID_FM1_BMI, /**< FM BMI block */
87008 + e_MODULE_ID_FM1_QMI, /**< FM QMI block */
87009 + e_MODULE_ID_FM1_PRS, /**< FM parser block */
87010 + e_MODULE_ID_FM1_PORT_HO0, /**< FM Host-command/offline-parsing port block */
87011 + e_MODULE_ID_FM1_PORT_HO1, /**< FM Host-command/offline-parsing port block */
87012 + e_MODULE_ID_FM1_PORT_HO2, /**< FM Host-command/offline-parsing port block */
87013 + e_MODULE_ID_FM1_PORT_HO3, /**< FM Host-command/offline-parsing port block */
87014 + e_MODULE_ID_FM1_PORT_HO4, /**< FM Host-command/offline-parsing port block */
87015 + e_MODULE_ID_FM1_PORT_HO5, /**< FM Host-command/offline-parsing port block */
87016 + e_MODULE_ID_FM1_PORT_HO6, /**< FM Host-command/offline-parsing port block */
87017 + e_MODULE_ID_FM1_PORT_1GRx0, /**< FM Rx 1G MAC port block */
87018 + e_MODULE_ID_FM1_PORT_1GRx1, /**< FM Rx 1G MAC port block */
87019 + e_MODULE_ID_FM1_PORT_1GRx2, /**< FM Rx 1G MAC port block */
87020 + e_MODULE_ID_FM1_PORT_1GRx3, /**< FM Rx 1G MAC port block */
87021 + e_MODULE_ID_FM1_PORT_1GRx4, /**< FM Rx 1G MAC port block */
87022 + e_MODULE_ID_FM1_PORT_10GRx0, /**< FM Rx 10G MAC port block */
87023 + e_MODULE_ID_FM1_PORT_1GTx0, /**< FM Tx 1G MAC port block */
87024 + e_MODULE_ID_FM1_PORT_1GTx1, /**< FM Tx 1G MAC port block */
87025 + e_MODULE_ID_FM1_PORT_1GTx2, /**< FM Tx 1G MAC port block */
87026 + e_MODULE_ID_FM1_PORT_1GTx3, /**< FM Tx 1G MAC port block */
87027 + e_MODULE_ID_FM1_PORT_1GTx4, /**< FM Tx 1G MAC port block */
87028 + e_MODULE_ID_FM1_PORT_10GTx0, /**< FM Tx 10G MAC port block */
87029 + e_MODULE_ID_FM1_PLCR, /**< FM Policer */
87030 + e_MODULE_ID_FM1_KG, /**< FM Keygen */
87031 + e_MODULE_ID_FM1_DMA, /**< FM DMA */
87032 + e_MODULE_ID_FM1_FPM, /**< FM FPM */
87033 + e_MODULE_ID_FM1_IRAM, /**< FM Instruction-RAM */
87034 + e_MODULE_ID_FM1_1GMDIO0, /**< FM 1G MDIO MAC 0*/
87035 + e_MODULE_ID_FM1_1GMDIO1, /**< FM 1G MDIO MAC 1*/
87036 + e_MODULE_ID_FM1_1GMDIO2, /**< FM 1G MDIO MAC 2*/
87037 + e_MODULE_ID_FM1_1GMDIO3, /**< FM 1G MDIO MAC 3*/
87038 + e_MODULE_ID_FM1_10GMDIO, /**< FM 10G MDIO */
87039 + e_MODULE_ID_FM1_PRS_IRAM, /**< FM SW-parser Instruction-RAM */
87040 + e_MODULE_ID_FM1_1GMAC0, /**< FM 1G MAC #0 */
87041 + e_MODULE_ID_FM1_1GMAC1, /**< FM 1G MAC #1 */
87042 + e_MODULE_ID_FM1_1GMAC2, /**< FM 1G MAC #2 */
87043 + e_MODULE_ID_FM1_1GMAC3, /**< FM 1G MAC #3 */
87044 + e_MODULE_ID_FM1_10GMAC0, /**< FM 10G MAC #0 */
87045 +
87046 + e_MODULE_ID_FM2, /**< Frame manager #2 module */
87047 + e_MODULE_ID_FM2_RTC, /**< FM Real-Time-Clock */
87048 + e_MODULE_ID_FM2_MURAM, /**< FM Multi-User-RAM */
87049 + e_MODULE_ID_FM2_BMI, /**< FM BMI block */
87050 + e_MODULE_ID_FM2_QMI, /**< FM QMI block */
87051 + e_MODULE_ID_FM2_PRS, /**< FM parser block */
87052 + e_MODULE_ID_FM2_PORT_HO0, /**< FM Host-command/offline-parsing port block */
87053 + e_MODULE_ID_FM2_PORT_HO1, /**< FM Host-command/offline-parsing port block */
87054 + e_MODULE_ID_FM2_PORT_HO2, /**< FM Host-command/offline-parsing port block */
87055 + e_MODULE_ID_FM2_PORT_HO3, /**< FM Host-command/offline-parsing port block */
87056 + e_MODULE_ID_FM2_PORT_HO4, /**< FM Host-command/offline-parsing port block */
87057 + e_MODULE_ID_FM2_PORT_HO5, /**< FM Host-command/offline-parsing port block */
87058 + e_MODULE_ID_FM2_PORT_HO6, /**< FM Host-command/offline-parsing port block */
87059 + e_MODULE_ID_FM2_PORT_1GRx0, /**< FM Rx 1G MAC port block */
87060 + e_MODULE_ID_FM2_PORT_1GRx1, /**< FM Rx 1G MAC port block */
87061 + e_MODULE_ID_FM2_PORT_1GRx2, /**< FM Rx 1G MAC port block */
87062 + e_MODULE_ID_FM2_PORT_1GRx3, /**< FM Rx 1G MAC port block */
87063 + e_MODULE_ID_FM2_PORT_10GRx0, /**< FM Rx 10G MAC port block */
87064 + e_MODULE_ID_FM2_PORT_1GTx0, /**< FM Tx 1G MAC port block */
87065 + e_MODULE_ID_FM2_PORT_1GTx1, /**< FM Tx 1G MAC port block */
87066 + e_MODULE_ID_FM2_PORT_1GTx2, /**< FM Tx 1G MAC port block */
87067 + e_MODULE_ID_FM2_PORT_1GTx3, /**< FM Tx 1G MAC port block */
87068 + e_MODULE_ID_FM2_PORT_10GTx0, /**< FM Tx 10G MAC port block */
87069 + e_MODULE_ID_FM2_PLCR, /**< FM Policer */
87070 + e_MODULE_ID_FM2_KG, /**< FM Keygen */
87071 + e_MODULE_ID_FM2_DMA, /**< FM DMA */
87072 + e_MODULE_ID_FM2_FPM, /**< FM FPM */
87073 + e_MODULE_ID_FM2_IRAM, /**< FM Instruction-RAM */
87074 + e_MODULE_ID_FM2_1GMDIO0, /**< FM 1G MDIO MAC 0*/
87075 + e_MODULE_ID_FM2_1GMDIO1, /**< FM 1G MDIO MAC 1*/
87076 + e_MODULE_ID_FM2_1GMDIO2, /**< FM 1G MDIO MAC 2*/
87077 + e_MODULE_ID_FM2_1GMDIO3, /**< FM 1G MDIO MAC 3*/
87078 + e_MODULE_ID_FM2_10GMDIO, /**< FM 10G MDIO */
87079 + e_MODULE_ID_FM2_PRS_IRAM, /**< FM SW-parser Instruction-RAM */
87080 + e_MODULE_ID_FM2_1GMAC0, /**< FM 1G MAC #0 */
87081 + e_MODULE_ID_FM2_1GMAC1, /**< FM 1G MAC #1 */
87082 + e_MODULE_ID_FM2_1GMAC2, /**< FM 1G MAC #2 */
87083 + e_MODULE_ID_FM2_1GMAC3, /**< FM 1G MAC #3 */
87084 + e_MODULE_ID_FM2_10GMAC0, /**< FM 10G MAC #0 */
87085 +
87086 + e_MODULE_ID_SEC_GEN, /**< SEC 4.0 General registers */
87087 + e_MODULE_ID_SEC_QI, /**< SEC 4.0 QI registers */
87088 + e_MODULE_ID_SEC_JQ0, /**< SEC 4.0 JQ-0 registers */
87089 + e_MODULE_ID_SEC_JQ1, /**< SEC 4.0 JQ-1 registers */
87090 + e_MODULE_ID_SEC_JQ2, /**< SEC 4.0 JQ-2 registers */
87091 + e_MODULE_ID_SEC_JQ3, /**< SEC 4.0 JQ-3 registers */
87092 + e_MODULE_ID_SEC_RTIC, /**< SEC 4.0 RTIC registers */
87093 + e_MODULE_ID_SEC_DECO0_CCB0, /**< SEC 4.0 DECO-0/CCB-0 registers */
87094 + e_MODULE_ID_SEC_DECO1_CCB1, /**< SEC 4.0 DECO-1/CCB-1 registers */
87095 + e_MODULE_ID_SEC_DECO2_CCB2, /**< SEC 4.0 DECO-2/CCB-2 registers */
87096 + e_MODULE_ID_SEC_DECO3_CCB3, /**< SEC 4.0 DECO-3/CCB-3 registers */
87097 + e_MODULE_ID_SEC_DECO4_CCB4, /**< SEC 4.0 DECO-4/CCB-4 registers */
87098 +
87099 + e_MODULE_ID_MPIC, /**< MPIC */
87100 + e_MODULE_ID_GPIO, /**< GPIO */
87101 + e_MODULE_ID_SERDES, /**< SERDES */
87102 + e_MODULE_ID_CPC_1, /**< CoreNet-Platform-Cache 1 */
87103 + e_MODULE_ID_CPC_2, /**< CoreNet-Platform-Cache 2 */
87104 +
87105 + e_MODULE_ID_SRIO_PORTS, /**< RapidIO controller */
87106 + e_MODULE_ID_SRIO_MU, /**< RapidIO messaging unit module */
87107 +
87108 + e_MODULE_ID_DUMMY_LAST
87109 +} e_ModuleId;
87110 +
87111 +#define NUM_OF_MODULES e_MODULE_ID_DUMMY_LAST
87112 +
87113 +#if 0 /* using unified values */
87114 +/*****************************************************************************
87115 + INTEGRATION-SPECIFIC MODULE CODES
87116 +******************************************************************************/
87117 +#define MODULE_UNKNOWN 0x00000000
87118 +#define MODULE_MEM 0x00010000
87119 +#define MODULE_MM 0x00020000
87120 +#define MODULE_CORE 0x00030000
87121 +#define MODULE_CHIP 0x00040000
87122 +#define MODULE_PLTFRM 0x00050000
87123 +#define MODULE_PM 0x00060000
87124 +#define MODULE_MMU 0x00070000
87125 +#define MODULE_PIC 0x00080000
87126 +#define MODULE_CPC 0x00090000
87127 +#define MODULE_DUART 0x000a0000
87128 +#define MODULE_SERDES 0x000b0000
87129 +#define MODULE_PIO 0x000c0000
87130 +#define MODULE_QM 0x000d0000
87131 +#define MODULE_BM 0x000e0000
87132 +#define MODULE_SEC 0x000f0000
87133 +#define MODULE_LAW 0x00100000
87134 +#define MODULE_LBC 0x00110000
87135 +#define MODULE_PAMU 0x00120000
87136 +#define MODULE_FM 0x00130000
87137 +#define MODULE_FM_MURAM 0x00140000
87138 +#define MODULE_FM_PCD 0x00150000
87139 +#define MODULE_FM_RTC 0x00160000
87140 +#define MODULE_FM_MAC 0x00170000
87141 +#define MODULE_FM_PORT 0x00180000
87142 +#define MODULE_FM_SP 0x00190000
87143 +#define MODULE_DPA_PORT 0x001a0000
87144 +#define MODULE_MII 0x001b0000
87145 +#define MODULE_I2C 0x001c0000
87146 +#define MODULE_DMA 0x001d0000
87147 +#define MODULE_DDR 0x001e0000
87148 +#define MODULE_ESPI 0x001f0000
87149 +#define MODULE_DPAA_IPSEC 0x00200000
87150 +#endif /* using unified values */
87151 +
87152 +/*****************************************************************************
87153 + PAMU INTEGRATION-SPECIFIC DEFINITIONS
87154 +******************************************************************************/
87155 +#define PAMU_NUM_OF_PARTITIONS 5
87156 +
87157 +#define PAMU_PICS_AVICS_ERRATA_PAMU3
87158 +
87159 +/*****************************************************************************
87160 + LAW INTEGRATION-SPECIFIC DEFINITIONS
87161 +******************************************************************************/
87162 +#define LAW_NUM_OF_WINDOWS 32
87163 +#define LAW_MIN_WINDOW_SIZE 0x0000000000001000LL /**< 4KB */
87164 +#define LAW_MAX_WINDOW_SIZE 0x0000002000000000LL /**< 64GB */
87165 +
87166 +
87167 +/*****************************************************************************
87168 + LBC INTEGRATION-SPECIFIC DEFINITIONS
87169 +******************************************************************************/
87170 +/**************************************************************************//**
87171 + @Group lbc_exception_grp LBC Exception Unit
87172 +
87173 + @Description LBC Exception unit API functions, definitions and enums
87174 +
87175 + @{
87176 +*//***************************************************************************/
87177 +
87178 +/**************************************************************************//**
87179 + @Anchor lbc_exbm
87180 +
87181 + @Collection LBC Errors Bit Mask
87182 +
87183 + These errors are reported through the exceptions callback..
87184 + The values can be or'ed in any combination in the errors mask
87185 + parameter of the errors report structure.
87186 +
87187 + These errors can also be passed as a bit-mask to
87188 + LBC_EnableErrorChecking() or LBC_DisableErrorChecking(),
87189 + for enabling or disabling error checking.
87190 + @{
87191 +*//***************************************************************************/
87192 +#define LBC_ERR_BUS_MONITOR 0x80000000 /**< Bus monitor error */
87193 +#define LBC_ERR_PARITY_ECC 0x20000000 /**< Parity error for GPCM/UPM */
87194 +#define LBC_ERR_WRITE_PROTECT 0x04000000 /**< Write protection error */
87195 +#define LBC_ERR_ATOMIC_WRITE 0x00800000 /**< Atomic write error */
87196 +#define LBC_ERR_ATOMIC_READ 0x00400000 /**< Atomic read error */
87197 +#define LBC_ERR_CHIP_SELECT 0x00080000 /**< Unrecognized chip select */
87198 +
87199 +#define LBC_ERR_ALL (LBC_ERR_BUS_MONITOR | LBC_ERR_PARITY_ECC | \
87200 + LBC_ERR_WRITE_PROTECT | LBC_ERR_ATOMIC_WRITE | \
87201 + LBC_ERR_ATOMIC_READ | LBC_ERR_CHIP_SELECT)
87202 + /**< All possible errors */
87203 +/* @} */
87204 +/** @} */ /* end of lbc_exception_grp group */
87205 +
87206 +#define LBC_INCORRECT_ERROR_REPORT_ERRATA
87207 +
87208 +#define LBC_NUM_OF_BANKS 8
87209 +#define LBC_MAX_CS_SIZE 0x0000000100000000LL
87210 +#define LBC_ATOMIC_OPERATION_SUPPORT
87211 +#define LBC_PARITY_SUPPORT
87212 +#define LBC_ADDRESS_HOLD_TIME_CTRL
87213 +#define LBC_HIGH_CLK_DIVIDERS
87214 +#define LBC_FCM_AVAILABLE
87215 +
87216 +/*****************************************************************************
87217 + GPIO INTEGRATION-SPECIFIC DEFINITIONS
87218 +******************************************************************************/
87219 +#define GPIO_NUM_OF_PORTS 1 /**< Number of ports in GPIO module;
87220 + Each port contains up to 32 i/O pins. */
87221 +
87222 +#define GPIO_VALID_PIN_MASKS \
87223 + { /* Port A */ 0xFFFFFFFF }
87224 +
87225 +#define GPIO_VALID_INTR_MASKS \
87226 + { /* Port A */ 0xFFFFFFFF }
87227 +
87228 +#endif /* __PART_INTEGRATION_EXT_H */
87229 --- /dev/null
87230 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/math_ext.h
87231 @@ -0,0 +1,99 @@
87232 +/*
87233 + * Copyright 2008-2012 Freescale Semiconductor Inc.
87234 + *
87235 + * Redistribution and use in source and binary forms, with or without
87236 + * modification, are permitted provided that the following conditions are met:
87237 + * * Redistributions of source code must retain the above copyright
87238 + * notice, this list of conditions and the following disclaimer.
87239 + * * Redistributions in binary form must reproduce the above copyright
87240 + * notice, this list of conditions and the following disclaimer in the
87241 + * documentation and/or other materials provided with the distribution.
87242 + * * Neither the name of Freescale Semiconductor nor the
87243 + * names of its contributors may be used to endorse or promote products
87244 + * derived from this software without specific prior written permission.
87245 + *
87246 + *
87247 + * ALTERNATIVELY, this software may be distributed under the terms of the
87248 + * GNU General Public License ("GPL") as published by the Free Software
87249 + * Foundation, either version 2 of that License or (at your option) any
87250 + * later version.
87251 + *
87252 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
87253 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
87254 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
87255 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
87256 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
87257 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
87258 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
87259 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
87260 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
87261 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
87262 + */
87263 +
87264 +
87265 +#ifndef __MATH_EXT_H
87266 +#define __MATH_EXT_H
87267 +
87268 +
87269 +#if defined(NCSW_LINUX) && defined(__KERNEL__)
87270 +#include <linux/math.h>
87271 +
87272 +#elif defined(__MWERKS__)
87273 +#define LOW(x) ( sizeof(x)==8 ? *(1+(int32_t*)&x) : (*(int32_t*)&x))
87274 +#define HIGH(x) (*(int32_t*)&x)
87275 +#define ULOW(x) ( sizeof(x)==8 ? *(1+(uint32_t*)&x) : (*(uint32_t*)&x))
87276 +#define UHIGH(x) (*(uint32_t*)&x)
87277 +
87278 +static const double big = 1.0e300;
87279 +
87280 +/* Macro for checking if a number is a power of 2 */
87281 +static __inline__ double ceil(double x)
87282 +{
87283 + int32_t i0,i1,j0; /*- cc 020130 -*/
87284 + uint32_t i,j; /*- cc 020130 -*/
87285 + i0 = HIGH(x);
87286 + i1 = LOW(x);
87287 + j0 = ((i0>>20)&0x7ff)-0x3ff;
87288 + if(j0<20) {
87289 + if(j0<0) { /* raise inexact if x != 0 */
87290 + if(big+x>0.0) {/* return 0*sign(x) if |x|<1 */
87291 + if(i0<0) {i0=0x80000000;i1=0;}
87292 + else if((i0|i1)!=0) { i0=0x3ff00000;i1=0;}
87293 + }
87294 + } else {
87295 + i = (uint32_t)(0x000fffff)>>j0;
87296 + if(((i0&i)|i1)==0) return x; /* x is integral */
87297 + if(big+x>0.0) { /* raise inexact flag */
87298 + if(i0>0) i0 += (0x00100000)>>j0;
87299 + i0 &= (~i); i1=0;
87300 + }
87301 + }
87302 + } else if (j0>51) {
87303 + if(j0==0x400) return x+x; /* inf or NaN */
87304 + else return x; /* x is integral */
87305 + } else {
87306 + i = ((uint32_t)(0xffffffff))>>(j0-20); /*- cc 020130 -*/
87307 + if((i1&i)==0) return x; /* x is integral */
87308 + if(big+x>0.0) { /* raise inexact flag */
87309 + if(i0>0) {
87310 + if(j0==20) i0+=1;
87311 + else {
87312 + j = (uint32_t)(i1 + (1<<(52-j0)));
87313 + if(j<i1) i0+=1; /* got a carry */
87314 + i1 = (int32_t)j;
87315 + }
87316 + }
87317 + i1 &= (~i);
87318 + }
87319 + }
87320 + HIGH(x) = i0;
87321 + LOW(x) = i1;
87322 + return x;
87323 +}
87324 +
87325 +#else
87326 +#include <math.h>
87327 +#endif /* defined(NCSW_LINUX) && defined(__KERNEL__) */
87328 +
87329 +
87330 +#endif /* __MATH_EXT_H */
87331 --- /dev/null
87332 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/ncsw_ext.h
87333 @@ -0,0 +1,435 @@
87334 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
87335 + * All rights reserved.
87336 + *
87337 + * Redistribution and use in source and binary forms, with or without
87338 + * modification, are permitted provided that the following conditions are met:
87339 + * * Redistributions of source code must retain the above copyright
87340 + * notice, this list of conditions and the following disclaimer.
87341 + * * Redistributions in binary form must reproduce the above copyright
87342 + * notice, this list of conditions and the following disclaimer in the
87343 + * documentation and/or other materials provided with the distribution.
87344 + * * Neither the name of Freescale Semiconductor nor the
87345 + * names of its contributors may be used to endorse or promote products
87346 + * derived from this software without specific prior written permission.
87347 + *
87348 + *
87349 + * ALTERNATIVELY, this software may be distributed under the terms of the
87350 + * GNU General Public License ("GPL") as published by the Free Software
87351 + * Foundation, either version 2 of that License or (at your option) any
87352 + * later version.
87353 + *
87354 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
87355 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
87356 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
87357 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
87358 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
87359 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
87360 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
87361 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
87362 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
87363 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
87364 + */
87365 +
87366 +
87367 +/**************************************************************************//**
87368 + @File ncsw_ext.h
87369 +
87370 + @Description General NetCommSw Standard Definitions
87371 +*//***************************************************************************/
87372 +
87373 +#ifndef __NCSW_EXT_H
87374 +#define __NCSW_EXT_H
87375 +
87376 +
87377 +#include "memcpy_ext.h"
87378 +
87379 +#define WRITE_BLOCK IOMemSet32 /* include memcpy_ext.h */
87380 +#define COPY_BLOCK Mem2IOCpy32 /* include memcpy_ext.h */
87381 +
87382 +#define PTR_TO_UINT(_ptr) ((uintptr_t)(_ptr))
87383 +#define UINT_TO_PTR(_val) ((void*)(uintptr_t)(_val))
87384 +
87385 +#define PTR_MOVE(_ptr, _offset) (void*)((uint8_t*)(_ptr) + (_offset))
87386 +
87387 +
87388 +#define WRITE_UINT8_UINT24(arg, data08, data24) \
87389 + WRITE_UINT32(arg,((uint32_t)(data08)<<24)|((uint32_t)(data24)&0x00FFFFFF))
87390 +#define WRITE_UINT24_UINT8(arg, data24, data08) \
87391 + WRITE_UINT32(arg,((uint32_t)(data24)<< 8)|((uint32_t)(data08)&0x000000FF))
87392 +
87393 +/* Little-Endian access macros */
87394 +
87395 +#define WRITE_UINT16_LE(arg, data) \
87396 + WRITE_UINT16((arg), SwapUint16(data))
87397 +
87398 +#define WRITE_UINT32_LE(arg, data) \
87399 + WRITE_UINT32((arg), SwapUint32(data))
87400 +
87401 +#define WRITE_UINT64_LE(arg, data) \
87402 + WRITE_UINT64((arg), SwapUint64(data))
87403 +
87404 +#define GET_UINT16_LE(arg) \
87405 + SwapUint16(GET_UINT16(arg))
87406 +
87407 +#define GET_UINT32_LE(arg) \
87408 + SwapUint32(GET_UINT32(arg))
87409 +
87410 +#define GET_UINT64_LE(arg) \
87411 + SwapUint64(GET_UINT64(arg))
87412 +
87413 +/* Write and Read again macros */
87414 +#define WRITE_UINT_SYNC(size, arg, data) \
87415 + do { \
87416 + WRITE_UINT##size((arg), (data)); \
87417 + CORE_MemoryBarrier(); \
87418 + } while (0)
87419 +
87420 +#define WRITE_UINT8_SYNC(arg, data) WRITE_UINT_SYNC(8, (arg), (data))
87421 +
87422 +#define WRITE_UINT16_SYNC(arg, data) WRITE_UINT_SYNC(16, (arg), (data))
87423 +#define WRITE_UINT32_SYNC(arg, data) WRITE_UINT_SYNC(32, (arg), (data))
87424 +
87425 +#define MAKE_UINT64(high32, low32) (((uint64_t)high32 << 32) | (low32))
87426 +
87427 +
87428 +/*----------------------*/
87429 +/* Miscellaneous macros */
87430 +/*----------------------*/
87431 +
87432 +#define UNUSED(_x) ((void)(_x))
87433 +
87434 +#define KILOBYTE 0x400UL /* 1024 */
87435 +#define MEGABYTE (KILOBYTE * KILOBYTE) /* 1024*1024 */
87436 +#define GIGABYTE ((uint64_t)(KILOBYTE * MEGABYTE)) /* 1024*1024*1024 */
87437 +#define TERABYTE ((uint64_t)(KILOBYTE * GIGABYTE)) /* 1024*1024*1024*1024 */
87438 +
87439 +#ifndef NO_IRQ
87440 +#define NO_IRQ (0)
87441 +#endif
87442 +#define NCSW_MASTER_ID (0)
87443 +
87444 +/* Macro for checking if a number is a power of 2 */
87445 +#define POWER_OF_2(n) (!((n) & ((n)-1)))
87446 +
87447 +/* Macro for calculating log of base 2 */
87448 +#define LOG2(num, log2Num) \
87449 + do \
87450 + { \
87451 + uint64_t tmp = (num); \
87452 + log2Num = 0; \
87453 + while (tmp > 1) \
87454 + { \
87455 + log2Num++; \
87456 + tmp >>= 1; \
87457 + } \
87458 + } while (0)
87459 +
87460 +#define NEXT_POWER_OF_2(_num, _nextPow) \
87461 +do \
87462 +{ \
87463 + if (POWER_OF_2(_num)) \
87464 + _nextPow = (_num); \
87465 + else \
87466 + { \
87467 + uint64_t tmp = (_num); \
87468 + _nextPow = 1; \
87469 + while (tmp) \
87470 + { \
87471 + _nextPow <<= 1; \
87472 + tmp >>= 1; \
87473 + } \
87474 + } \
87475 +} while (0)
87476 +
87477 +/* Ceiling division - not the fastest way, but safer in terms of overflow */
87478 +#define DIV_CEIL(x,y) (((x)/(y)) + ((((((x)/(y)))*(y)) == (x)) ? 0 : 1))
87479 +
87480 +/* Round up a number to be a multiple of a second number */
87481 +#define ROUND_UP(x,y) ((((x) + (y) - 1) / (y)) * (y))
87482 +
87483 +/* Timing macro for converting usec units to number of ticks. */
87484 +/* (number of usec * clock_Hz) / 1,000,000) - since */
87485 +/* clk is in MHz units, no division needed. */
87486 +#define USEC_TO_CLK(usec,clk) ((usec) * (clk))
87487 +#define CYCLES_TO_USEC(cycles,clk) ((cycles) / (clk))
87488 +
87489 +/* Timing macros for converting between nsec units and number of clocks. */
87490 +#define NSEC_TO_CLK(nsec,clk) DIV_CEIL(((nsec) * (clk)), 1000)
87491 +#define CYCLES_TO_NSEC(cycles,clk) (((cycles) * 1000) / (clk))
87492 +
87493 +/* Timing macros for converting between psec units and number of clocks. */
87494 +#define PSEC_TO_CLK(psec,clk) DIV_CEIL(((psec) * (clk)), 1000000)
87495 +#define CYCLES_TO_PSEC(cycles,clk) (((cycles) * 1000000) / (clk))
87496 +
87497 +/* Min, Max macros */
87498 +#define MIN(a,b) ((a) < (b) ? (a) : (b))
87499 +#define MAX(a,b) ((a) > (b) ? (a) : (b))
87500 +#define IN_RANGE(min,val,max) ((min)<=(val) && (val)<=(max))
87501 +
87502 +#define ABS(a) ((a<0)?(a*-1):a)
87503 +
87504 +#if !(defined(ARRAY_SIZE))
87505 +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
87506 +#endif /* !defined(ARRAY_SIZE) */
87507 +
87508 +
87509 +/* possible alignments */
87510 +#define HALF_WORD_ALIGNMENT 2
87511 +#define WORD_ALIGNMENT 4
87512 +#define DOUBLE_WORD_ALIGNMENT 8
87513 +#define BURST_ALIGNMENT 32
87514 +
87515 +#define HALF_WORD_ALIGNED 0x00000001
87516 +#define WORD_ALIGNED 0x00000003
87517 +#define DOUBLE_WORD_ALIGNED 0x00000007
87518 +#define BURST_ALIGNED 0x0000001f
87519 +#ifndef IS_ALIGNED
87520 +#define IS_ALIGNED(n,align) (!((uint32_t)(n) & (align - 1)))
87521 +#endif /* IS_ALIGNED */
87522 +
87523 +
87524 +#define LAST_BUF 1
87525 +#define FIRST_BUF 2
87526 +#define SINGLE_BUF (LAST_BUF | FIRST_BUF)
87527 +#define MIDDLE_BUF 4
87528 +
87529 +#define ARRAY_END -1
87530 +
87531 +#define ILLEGAL_BASE (~0)
87532 +
87533 +#define BUF_POSITION(first, last) state[(!!(last))<<1 | !!(first)]
87534 +#define DECLARE_POSITION static uint8_t state[4] = { (uint8_t)MIDDLE_BUF, (uint8_t)FIRST_BUF, (uint8_t)LAST_BUF, (uint8_t)SINGLE_BUF };
87535 +
87536 +
87537 +/**************************************************************************//**
87538 + @Description Timers operation mode
87539 +*//***************************************************************************/
87540 +typedef enum e_TimerMode
87541 +{
87542 + e_TIMER_MODE_INVALID = 0,
87543 + e_TIMER_MODE_FREE_RUN, /**< Free run - counter continues to increase
87544 + after reaching the reference value. */
87545 + e_TIMER_MODE_PERIODIC, /**< Periodic - counter restarts counting from 0
87546 + after reaching the reference value. */
87547 + e_TIMER_MODE_SINGLE /**< Single (one-shot) - counter stops counting
87548 + after reaching the reference value. */
87549 +} e_TimerMode;
87550 +
87551 +
87552 +/**************************************************************************//**
87553 + @Description Enumeration (bit flags) of communication modes (Transmit,
87554 + receive or both).
87555 +*//***************************************************************************/
87556 +typedef enum e_CommMode
87557 +{
87558 + e_COMM_MODE_NONE = 0, /**< No transmit/receive communication */
87559 + e_COMM_MODE_RX = 1, /**< Only receive communication */
87560 + e_COMM_MODE_TX = 2, /**< Only transmit communication */
87561 + e_COMM_MODE_RX_AND_TX = 3 /**< Both transmit and receive communication */
87562 +} e_CommMode;
87563 +
87564 +/**************************************************************************//**
87565 + @Description General Diagnostic Mode
87566 +*//***************************************************************************/
87567 +typedef enum e_DiagMode
87568 +{
87569 + e_DIAG_MODE_NONE = 0, /**< Normal operation; no diagnostic mode */
87570 + e_DIAG_MODE_CTRL_LOOPBACK, /**< Loopback in the controller */
87571 + e_DIAG_MODE_CHIP_LOOPBACK, /**< Loopback in the chip but not in the
87572 + controller; e.g. IO-pins, SerDes, etc. */
87573 + e_DIAG_MODE_PHY_LOOPBACK, /**< Loopback in the external PHY */
87574 + e_DIAG_MODE_EXT_LOOPBACK, /**< Loopback in the external line (beyond the PHY) */
87575 + e_DIAG_MODE_CTRL_ECHO, /**< Echo incoming data by the controller */
87576 + e_DIAG_MODE_PHY_ECHO /**< Echo incoming data by the PHY */
87577 +} e_DiagMode;
87578 +
87579 +/**************************************************************************//**
87580 + @Description Possible RxStore callback responses.
87581 +*//***************************************************************************/
87582 +typedef enum e_RxStoreResponse
87583 +{
87584 + e_RX_STORE_RESPONSE_PAUSE /**< Pause invoking callback with received data;
87585 + in polling mode, start again invoking callback
87586 + only next time user invokes the receive routine;
87587 + in interrupt mode, start again invoking callback
87588 + only next time a receive event triggers an interrupt;
87589 + in all cases, received data that are pending are not
87590 + lost, rather, their processing is temporarily deferred;
87591 + in all cases, received data are processed in the order
87592 + in which they were received. */
87593 + , e_RX_STORE_RESPONSE_CONTINUE /**< Continue invoking callback with received data. */
87594 +} e_RxStoreResponse;
87595 +
87596 +
87597 +/**************************************************************************//**
87598 + @Description General Handle
87599 +*//***************************************************************************/
87600 +typedef void * t_Handle; /**< handle, used as object's descriptor */
87601 +
87602 +/**************************************************************************//**
87603 + @Description MUTEX type
87604 +*//***************************************************************************/
87605 +typedef uint32_t t_Mutex;
87606 +
87607 +/**************************************************************************//**
87608 + @Description Error Code.
87609 +
87610 + The high word of the error code is the code of the software
87611 + module (driver). The low word is the error type (e_ErrorType).
87612 + To get the values from the error code, use GET_ERROR_TYPE()
87613 + and GET_ERROR_MODULE().
87614 +*//***************************************************************************/
87615 +typedef uint32_t t_Error;
87616 +
87617 +/**************************************************************************//**
87618 + @Description General prototype of interrupt service routine (ISR).
87619 +
87620 + @Param[in] handle - Optional handle of the module handling the interrupt.
87621 +
87622 + @Return None
87623 + *//***************************************************************************/
87624 +typedef void (t_Isr)(t_Handle handle);
87625 +
87626 +/**************************************************************************//**
87627 + @Anchor mem_attr
87628 +
87629 + @Collection Memory Attributes
87630 +
87631 + Various attributes of memory partitions. These values may be
87632 + or'ed together to create a mask of all memory attributes.
87633 + @{
87634 +*//***************************************************************************/
87635 +#define MEMORY_ATTR_CACHEABLE 0x00000001
87636 + /**< Memory is cacheable */
87637 +#define MEMORY_ATTR_QE_2ND_BUS_ACCESS 0x00000002
87638 + /**< Memory can be accessed by QUICC Engine
87639 + through its secondary bus interface */
87640 +
87641 +/* @} */
87642 +
87643 +
87644 +/**************************************************************************//**
87645 + @Function t_GetBufFunction
87646 +
87647 + @Description User callback function called by driver to get data buffer.
87648 +
87649 + User provides this function. Driver invokes it.
87650 +
87651 + @Param[in] h_BufferPool - A handle to buffer pool manager
87652 + @Param[out] p_BufContextHandle - Returns the user's private context that
87653 + should be associated with the buffer
87654 +
87655 + @Return Pointer to data buffer, NULL if error
87656 + *//***************************************************************************/
87657 +typedef uint8_t * (t_GetBufFunction)(t_Handle h_BufferPool,
87658 + t_Handle *p_BufContextHandle);
87659 +
87660 +/**************************************************************************//**
87661 + @Function t_PutBufFunction
87662 +
87663 + @Description User callback function called by driver to return data buffer.
87664 +
87665 + User provides this function. Driver invokes it.
87666 +
87667 + @Param[in] h_BufferPool - A handle to buffer pool manager
87668 + @Param[in] p_Buffer - A pointer to buffer to return
87669 + @Param[in] h_BufContext - The user's private context associated with
87670 + the returned buffer
87671 +
87672 + @Return E_OK on success; Error code otherwise
87673 + *//***************************************************************************/
87674 +typedef t_Error (t_PutBufFunction)(t_Handle h_BufferPool,
87675 + uint8_t *p_Buffer,
87676 + t_Handle h_BufContext);
87677 +
87678 +/**************************************************************************//**
87679 + @Function t_PhysToVirt
87680 +
87681 + @Description Translates a physical address to the matching virtual address.
87682 +
87683 + @Param[in] addr - The physical address to translate.
87684 +
87685 + @Return Virtual address.
87686 +*//***************************************************************************/
87687 +typedef void * t_PhysToVirt(physAddress_t addr);
87688 +
87689 +/**************************************************************************//**
87690 + @Function t_VirtToPhys
87691 +
87692 + @Description Translates a virtual address to the matching physical address.
87693 +
87694 + @Param[in] addr - The virtual address to translate.
87695 +
87696 + @Return Physical address.
87697 +*//***************************************************************************/
87698 +typedef physAddress_t t_VirtToPhys(void *addr);
87699 +
87700 +/**************************************************************************//**
87701 + @Description Buffer Pool Information Structure.
87702 +*//***************************************************************************/
87703 +typedef struct t_BufferPoolInfo
87704 +{
87705 + t_Handle h_BufferPool; /**< A handle to the buffer pool manager */
87706 + t_GetBufFunction *f_GetBuf; /**< User callback to get a free buffer */
87707 + t_PutBufFunction *f_PutBuf; /**< User callback to return a buffer */
87708 + uint16_t bufferSize; /**< Buffer size (in bytes) */
87709 +
87710 + t_PhysToVirt *f_PhysToVirt; /**< User callback to translate pool buffers
87711 + physical addresses to virtual addresses */
87712 + t_VirtToPhys *f_VirtToPhys; /**< User callback to translate pool buffers
87713 + virtual addresses to physical addresses */
87714 +} t_BufferPoolInfo;
87715 +
87716 +
87717 +/**************************************************************************//**
87718 + @Description User callback function called by driver when transmit completed.
87719 +
87720 + User provides this function. Driver invokes it.
87721 +
87722 + @Param[in] h_App - Application's handle, as was provided to the
87723 + driver by the user
87724 + @Param[in] queueId - Transmit queue ID
87725 + @Param[in] p_Data - Pointer to the data buffer
87726 + @Param[in] h_BufContext - The user's private context associated with
87727 + the given data buffer
87728 + @Param[in] status - Transmit status and errors
87729 + @Param[in] flags - Driver-dependent information
87730 + *//***************************************************************************/
87731 +typedef void (t_TxConfFunction)(t_Handle h_App,
87732 + uint32_t queueId,
87733 + uint8_t *p_Data,
87734 + t_Handle h_BufContext,
87735 + uint16_t status,
87736 + uint32_t flags);
87737 +
87738 +/**************************************************************************//**
87739 + @Description User callback function called by driver with receive data.
87740 +
87741 + User provides this function. Driver invokes it.
87742 +
87743 + @Param[in] h_App - Application's handle, as was provided to the
87744 + driver by the user
87745 + @Param[in] queueId - Receive queue ID
87746 + @Param[in] p_Data - Pointer to the buffer with received data
87747 + @Param[in] h_BufContext - The user's private context associated with
87748 + the given data buffer
87749 + @Param[in] length - Length of received data
87750 + @Param[in] status - Receive status and errors
87751 + @Param[in] position - Position of buffer in frame
87752 + @Param[in] flags - Driver-dependent information
87753 +
87754 + @Retval e_RX_STORE_RESPONSE_CONTINUE - order the driver to continue Rx
87755 + operation for all ready data.
87756 + @Retval e_RX_STORE_RESPONSE_PAUSE - order the driver to stop Rx operation.
87757 + *//***************************************************************************/
87758 +typedef e_RxStoreResponse (t_RxStoreFunction)(t_Handle h_App,
87759 + uint32_t queueId,
87760 + uint8_t *p_Data,
87761 + t_Handle h_BufContext,
87762 + uint32_t length,
87763 + uint16_t status,
87764 + uint8_t position,
87765 + uint32_t flags);
87766 +
87767 +
87768 +#endif /* __NCSW_EXT_H */
87769 --- /dev/null
87770 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/net_ext.h
87771 @@ -0,0 +1,430 @@
87772 +/*
87773 + * Copyright 2008-2012 Freescale Semiconductor Inc.
87774 + *
87775 + * Redistribution and use in source and binary forms, with or without
87776 + * modification, are permitted provided that the following conditions are met:
87777 + * * Redistributions of source code must retain the above copyright
87778 + * notice, this list of conditions and the following disclaimer.
87779 + * * Redistributions in binary form must reproduce the above copyright
87780 + * notice, this list of conditions and the following disclaimer in the
87781 + * documentation and/or other materials provided with the distribution.
87782 + * * Neither the name of Freescale Semiconductor nor the
87783 + * names of its contributors may be used to endorse or promote products
87784 + * derived from this software without specific prior written permission.
87785 + *
87786 + *
87787 + * ALTERNATIVELY, this software may be distributed under the terms of the
87788 + * GNU General Public License ("GPL") as published by the Free Software
87789 + * Foundation, either version 2 of that License or (at your option) any
87790 + * later version.
87791 + *
87792 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
87793 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
87794 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
87795 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
87796 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
87797 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
87798 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
87799 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
87800 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
87801 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
87802 + */
87803 +
87804 +
87805 +/**************************************************************************//**
87806 + @File net_ext.h
87807 +
87808 + @Description This file contains common and general netcomm headers definitions.
87809 +*//***************************************************************************/
87810 +#ifndef __NET_EXT_H
87811 +#define __NET_EXT_H
87812 +
87813 +#include "std_ext.h"
87814 +
87815 +
87816 +typedef uint8_t headerFieldPpp_t;
87817 +
87818 +#define NET_HEADER_FIELD_PPP_PID (1)
87819 +#define NET_HEADER_FIELD_PPP_COMPRESSED (NET_HEADER_FIELD_PPP_PID << 1)
87820 +#define NET_HEADER_FIELD_PPP_ALL_FIELDS ((NET_HEADER_FIELD_PPP_PID << 2) - 1)
87821 +
87822 +
87823 +typedef uint8_t headerFieldPppoe_t;
87824 +
87825 +#define NET_HEADER_FIELD_PPPoE_VER (1)
87826 +#define NET_HEADER_FIELD_PPPoE_TYPE (NET_HEADER_FIELD_PPPoE_VER << 1)
87827 +#define NET_HEADER_FIELD_PPPoE_CODE (NET_HEADER_FIELD_PPPoE_VER << 2)
87828 +#define NET_HEADER_FIELD_PPPoE_SID (NET_HEADER_FIELD_PPPoE_VER << 3)
87829 +#define NET_HEADER_FIELD_PPPoE_LEN (NET_HEADER_FIELD_PPPoE_VER << 4)
87830 +#define NET_HEADER_FIELD_PPPoE_SESSION (NET_HEADER_FIELD_PPPoE_VER << 5)
87831 +#define NET_HEADER_FIELD_PPPoE_PID (NET_HEADER_FIELD_PPPoE_VER << 6)
87832 +#define NET_HEADER_FIELD_PPPoE_ALL_FIELDS ((NET_HEADER_FIELD_PPPoE_VER << 7) - 1)
87833 +
87834 +#define NET_HEADER_FIELD_PPPMUX_PID (1)
87835 +#define NET_HEADER_FIELD_PPPMUX_CKSUM (NET_HEADER_FIELD_PPPMUX_PID << 1)
87836 +#define NET_HEADER_FIELD_PPPMUX_COMPRESSED (NET_HEADER_FIELD_PPPMUX_PID << 2)
87837 +#define NET_HEADER_FIELD_PPPMUX_ALL_FIELDS ((NET_HEADER_FIELD_PPPMUX_PID << 3) - 1)
87838 +
87839 +#define NET_HEADER_FIELD_PPPMUX_SUBFRAME_PFF (1)
87840 +#define NET_HEADER_FIELD_PPPMUX_SUBFRAME_LXT (NET_HEADER_FIELD_PPPMUX_SUBFRAME_PFF << 1)
87841 +#define NET_HEADER_FIELD_PPPMUX_SUBFRAME_LEN (NET_HEADER_FIELD_PPPMUX_SUBFRAME_PFF << 2)
87842 +#define NET_HEADER_FIELD_PPPMUX_SUBFRAME_PID (NET_HEADER_FIELD_PPPMUX_SUBFRAME_PFF << 3)
87843 +#define NET_HEADER_FIELD_PPPMUX_SUBFRAME_USE_PID (NET_HEADER_FIELD_PPPMUX_SUBFRAME_PFF << 4)
87844 +#define NET_HEADER_FIELD_PPPMUX_SUBFRAME_ALL_FIELDS ((NET_HEADER_FIELD_PPPMUX_SUBFRAME_PFF << 5) - 1)
87845 +
87846 +
87847 +typedef uint8_t headerFieldEth_t;
87848 +
87849 +#define NET_HEADER_FIELD_ETH_DA (1)
87850 +#define NET_HEADER_FIELD_ETH_SA (NET_HEADER_FIELD_ETH_DA << 1)
87851 +#define NET_HEADER_FIELD_ETH_LENGTH (NET_HEADER_FIELD_ETH_DA << 2)
87852 +#define NET_HEADER_FIELD_ETH_TYPE (NET_HEADER_FIELD_ETH_DA << 3)
87853 +#define NET_HEADER_FIELD_ETH_FINAL_CKSUM (NET_HEADER_FIELD_ETH_DA << 4)
87854 +#define NET_HEADER_FIELD_ETH_PADDING (NET_HEADER_FIELD_ETH_DA << 5)
87855 +#define NET_HEADER_FIELD_ETH_ALL_FIELDS ((NET_HEADER_FIELD_ETH_DA << 6) - 1)
87856 +
87857 +#define NET_HEADER_FIELD_ETH_ADDR_SIZE 6
87858 +
87859 +typedef uint16_t headerFieldIp_t;
87860 +
87861 +#define NET_HEADER_FIELD_IP_VER (1)
87862 +#define NET_HEADER_FIELD_IP_DSCP (NET_HEADER_FIELD_IP_VER << 2)
87863 +#define NET_HEADER_FIELD_IP_ECN (NET_HEADER_FIELD_IP_VER << 3)
87864 +#define NET_HEADER_FIELD_IP_PROTO (NET_HEADER_FIELD_IP_VER << 4)
87865 +
87866 +#define NET_HEADER_FIELD_IP_PROTO_SIZE 1
87867 +
87868 +typedef uint16_t headerFieldIpv4_t;
87869 +
87870 +#define NET_HEADER_FIELD_IPv4_VER (1)
87871 +#define NET_HEADER_FIELD_IPv4_HDR_LEN (NET_HEADER_FIELD_IPv4_VER << 1)
87872 +#define NET_HEADER_FIELD_IPv4_TOS (NET_HEADER_FIELD_IPv4_VER << 2)
87873 +#define NET_HEADER_FIELD_IPv4_TOTAL_LEN (NET_HEADER_FIELD_IPv4_VER << 3)
87874 +#define NET_HEADER_FIELD_IPv4_ID (NET_HEADER_FIELD_IPv4_VER << 4)
87875 +#define NET_HEADER_FIELD_IPv4_FLAG_D (NET_HEADER_FIELD_IPv4_VER << 5)
87876 +#define NET_HEADER_FIELD_IPv4_FLAG_M (NET_HEADER_FIELD_IPv4_VER << 6)
87877 +#define NET_HEADER_FIELD_IPv4_OFFSET (NET_HEADER_FIELD_IPv4_VER << 7)
87878 +#define NET_HEADER_FIELD_IPv4_TTL (NET_HEADER_FIELD_IPv4_VER << 8)
87879 +#define NET_HEADER_FIELD_IPv4_PROTO (NET_HEADER_FIELD_IPv4_VER << 9)
87880 +#define NET_HEADER_FIELD_IPv4_CKSUM (NET_HEADER_FIELD_IPv4_VER << 10)
87881 +#define NET_HEADER_FIELD_IPv4_SRC_IP (NET_HEADER_FIELD_IPv4_VER << 11)
87882 +#define NET_HEADER_FIELD_IPv4_DST_IP (NET_HEADER_FIELD_IPv4_VER << 12)
87883 +#define NET_HEADER_FIELD_IPv4_OPTS (NET_HEADER_FIELD_IPv4_VER << 13)
87884 +#define NET_HEADER_FIELD_IPv4_OPTS_COUNT (NET_HEADER_FIELD_IPv4_VER << 14)
87885 +#define NET_HEADER_FIELD_IPv4_ALL_FIELDS ((NET_HEADER_FIELD_IPv4_VER << 15) - 1)
87886 +
87887 +#define NET_HEADER_FIELD_IPv4_ADDR_SIZE 4
87888 +#define NET_HEADER_FIELD_IPv4_PROTO_SIZE 1
87889 +
87890 +
87891 +typedef uint8_t headerFieldIpv6_t;
87892 +
87893 +#define NET_HEADER_FIELD_IPv6_VER (1)
87894 +#define NET_HEADER_FIELD_IPv6_TC (NET_HEADER_FIELD_IPv6_VER << 1)
87895 +#define NET_HEADER_FIELD_IPv6_SRC_IP (NET_HEADER_FIELD_IPv6_VER << 2)
87896 +#define NET_HEADER_FIELD_IPv6_DST_IP (NET_HEADER_FIELD_IPv6_VER << 3)
87897 +#define NET_HEADER_FIELD_IPv6_NEXT_HDR (NET_HEADER_FIELD_IPv6_VER << 4)
87898 +#define NET_HEADER_FIELD_IPv6_FL (NET_HEADER_FIELD_IPv6_VER << 5)
87899 +#define NET_HEADER_FIELD_IPv6_HOP_LIMIT (NET_HEADER_FIELD_IPv6_VER << 6)
87900 +#define NET_HEADER_FIELD_IPv6_ALL_FIELDS ((NET_HEADER_FIELD_IPv6_VER << 7) - 1)
87901 +
87902 +#define NET_HEADER_FIELD_IPv6_ADDR_SIZE 16
87903 +#define NET_HEADER_FIELD_IPv6_NEXT_HDR_SIZE 1
87904 +
87905 +#define NET_HEADER_FIELD_ICMP_TYPE (1)
87906 +#define NET_HEADER_FIELD_ICMP_CODE (NET_HEADER_FIELD_ICMP_TYPE << 1)
87907 +#define NET_HEADER_FIELD_ICMP_CKSUM (NET_HEADER_FIELD_ICMP_TYPE << 2)
87908 +#define NET_HEADER_FIELD_ICMP_ID (NET_HEADER_FIELD_ICMP_TYPE << 3)
87909 +#define NET_HEADER_FIELD_ICMP_SQ_NUM (NET_HEADER_FIELD_ICMP_TYPE << 4)
87910 +#define NET_HEADER_FIELD_ICMP_ALL_FIELDS ((NET_HEADER_FIELD_ICMP_TYPE << 5) - 1)
87911 +
87912 +#define NET_HEADER_FIELD_ICMP_CODE_SIZE 1
87913 +#define NET_HEADER_FIELD_ICMP_TYPE_SIZE 1
87914 +
87915 +#define NET_HEADER_FIELD_IGMP_VERSION (1)
87916 +#define NET_HEADER_FIELD_IGMP_TYPE (NET_HEADER_FIELD_IGMP_VERSION << 1)
87917 +#define NET_HEADER_FIELD_IGMP_CKSUM (NET_HEADER_FIELD_IGMP_VERSION << 2)
87918 +#define NET_HEADER_FIELD_IGMP_DATA (NET_HEADER_FIELD_IGMP_VERSION << 3)
87919 +#define NET_HEADER_FIELD_IGMP_ALL_FIELDS ((NET_HEADER_FIELD_IGMP_VERSION << 4) - 1)
87920 +
87921 +
87922 +typedef uint16_t headerFieldTcp_t;
87923 +
87924 +#define NET_HEADER_FIELD_TCP_PORT_SRC (1)
87925 +#define NET_HEADER_FIELD_TCP_PORT_DST (NET_HEADER_FIELD_TCP_PORT_SRC << 1)
87926 +#define NET_HEADER_FIELD_TCP_SEQ (NET_HEADER_FIELD_TCP_PORT_SRC << 2)
87927 +#define NET_HEADER_FIELD_TCP_ACK (NET_HEADER_FIELD_TCP_PORT_SRC << 3)
87928 +#define NET_HEADER_FIELD_TCP_OFFSET (NET_HEADER_FIELD_TCP_PORT_SRC << 4)
87929 +#define NET_HEADER_FIELD_TCP_FLAGS (NET_HEADER_FIELD_TCP_PORT_SRC << 5)
87930 +#define NET_HEADER_FIELD_TCP_WINDOW (NET_HEADER_FIELD_TCP_PORT_SRC << 6)
87931 +#define NET_HEADER_FIELD_TCP_CKSUM (NET_HEADER_FIELD_TCP_PORT_SRC << 7)
87932 +#define NET_HEADER_FIELD_TCP_URGPTR (NET_HEADER_FIELD_TCP_PORT_SRC << 8)
87933 +#define NET_HEADER_FIELD_TCP_OPTS (NET_HEADER_FIELD_TCP_PORT_SRC << 9)
87934 +#define NET_HEADER_FIELD_TCP_OPTS_COUNT (NET_HEADER_FIELD_TCP_PORT_SRC << 10)
87935 +#define NET_HEADER_FIELD_TCP_ALL_FIELDS ((NET_HEADER_FIELD_TCP_PORT_SRC << 11) - 1)
87936 +
87937 +#define NET_HEADER_FIELD_TCP_PORT_SIZE 2
87938 +
87939 +
87940 +typedef uint8_t headerFieldSctp_t;
87941 +
87942 +#define NET_HEADER_FIELD_SCTP_PORT_SRC (1)
87943 +#define NET_HEADER_FIELD_SCTP_PORT_DST (NET_HEADER_FIELD_SCTP_PORT_SRC << 1)
87944 +#define NET_HEADER_FIELD_SCTP_VER_TAG (NET_HEADER_FIELD_SCTP_PORT_SRC << 2)
87945 +#define NET_HEADER_FIELD_SCTP_CKSUM (NET_HEADER_FIELD_SCTP_PORT_SRC << 3)
87946 +#define NET_HEADER_FIELD_SCTP_ALL_FIELDS ((NET_HEADER_FIELD_SCTP_PORT_SRC << 4) - 1)
87947 +
87948 +#define NET_HEADER_FIELD_SCTP_PORT_SIZE 2
87949 +
87950 +typedef uint8_t headerFieldDccp_t;
87951 +
87952 +#define NET_HEADER_FIELD_DCCP_PORT_SRC (1)
87953 +#define NET_HEADER_FIELD_DCCP_PORT_DST (NET_HEADER_FIELD_DCCP_PORT_SRC << 1)
87954 +#define NET_HEADER_FIELD_DCCP_ALL_FIELDS ((NET_HEADER_FIELD_DCCP_PORT_SRC << 2) - 1)
87955 +
87956 +#define NET_HEADER_FIELD_DCCP_PORT_SIZE 2
87957 +
87958 +
87959 +typedef uint8_t headerFieldUdp_t;
87960 +
87961 +#define NET_HEADER_FIELD_UDP_PORT_SRC (1)
87962 +#define NET_HEADER_FIELD_UDP_PORT_DST (NET_HEADER_FIELD_UDP_PORT_SRC << 1)
87963 +#define NET_HEADER_FIELD_UDP_LEN (NET_HEADER_FIELD_UDP_PORT_SRC << 2)
87964 +#define NET_HEADER_FIELD_UDP_CKSUM (NET_HEADER_FIELD_UDP_PORT_SRC << 3)
87965 +#define NET_HEADER_FIELD_UDP_ALL_FIELDS ((NET_HEADER_FIELD_UDP_PORT_SRC << 4) - 1)
87966 +
87967 +#define NET_HEADER_FIELD_UDP_PORT_SIZE 2
87968 +
87969 +typedef uint8_t headerFieldUdpLite_t;
87970 +
87971 +#define NET_HEADER_FIELD_UDP_LITE_PORT_SRC (1)
87972 +#define NET_HEADER_FIELD_UDP_LITE_PORT_DST (NET_HEADER_FIELD_UDP_LITE_PORT_SRC << 1)
87973 +#define NET_HEADER_FIELD_UDP_LITE_ALL_FIELDS ((NET_HEADER_FIELD_UDP_LITE_PORT_SRC << 2) - 1)
87974 +
87975 +#define NET_HEADER_FIELD_UDP_LITE_PORT_SIZE 2
87976 +
87977 +typedef uint8_t headerFieldUdpEncapEsp_t;
87978 +
87979 +#define NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC (1)
87980 +#define NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_DST (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 1)
87981 +#define NET_HEADER_FIELD_UDP_ENCAP_ESP_LEN (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 2)
87982 +#define NET_HEADER_FIELD_UDP_ENCAP_ESP_CKSUM (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 3)
87983 +#define NET_HEADER_FIELD_UDP_ENCAP_ESP_SPI (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 4)
87984 +#define NET_HEADER_FIELD_UDP_ENCAP_ESP_SEQUENCE_NUM (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 5)
87985 +#define NET_HEADER_FIELD_UDP_ENCAP_ESP_ALL_FIELDS ((NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 6) - 1)
87986 +
87987 +#define NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SIZE 2
87988 +#define NET_HEADER_FIELD_UDP_ENCAP_ESP_SPI_SIZE 4
87989 +
87990 +#define NET_HEADER_FIELD_IPHC_CID (1)
87991 +#define NET_HEADER_FIELD_IPHC_CID_TYPE (NET_HEADER_FIELD_IPHC_CID << 1)
87992 +#define NET_HEADER_FIELD_IPHC_HCINDEX (NET_HEADER_FIELD_IPHC_CID << 2)
87993 +#define NET_HEADER_FIELD_IPHC_GEN (NET_HEADER_FIELD_IPHC_CID << 3)
87994 +#define NET_HEADER_FIELD_IPHC_D_BIT (NET_HEADER_FIELD_IPHC_CID << 4)
87995 +#define NET_HEADER_FIELD_IPHC_ALL_FIELDS ((NET_HEADER_FIELD_IPHC_CID << 5) - 1)
87996 +
87997 +#define NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE (1)
87998 +#define NET_HEADER_FIELD_SCTP_CHUNK_DATA_FLAGS (NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 1)
87999 +#define NET_HEADER_FIELD_SCTP_CHUNK_DATA_LENGTH (NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 2)
88000 +#define NET_HEADER_FIELD_SCTP_CHUNK_DATA_TSN (NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 3)
88001 +#define NET_HEADER_FIELD_SCTP_CHUNK_DATA_STREAM_ID (NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 4)
88002 +#define NET_HEADER_FIELD_SCTP_CHUNK_DATA_STREAM_SQN (NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 5)
88003 +#define NET_HEADER_FIELD_SCTP_CHUNK_DATA_PAYLOAD_PID (NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 6)
88004 +#define NET_HEADER_FIELD_SCTP_CHUNK_DATA_UNORDERED (NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 7)
88005 +#define NET_HEADER_FIELD_SCTP_CHUNK_DATA_BEGGINING (NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 8)
88006 +#define NET_HEADER_FIELD_SCTP_CHUNK_DATA_END (NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 9)
88007 +#define NET_HEADER_FIELD_SCTP_CHUNK_DATA_ALL_FIELDS ((NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 10) - 1)
88008 +
88009 +#define NET_HEADER_FIELD_L2TPv2_TYPE_BIT (1)
88010 +#define NET_HEADER_FIELD_L2TPv2_LENGTH_BIT (NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 1)
88011 +#define NET_HEADER_FIELD_L2TPv2_SEQUENCE_BIT (NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 2)
88012 +#define NET_HEADER_FIELD_L2TPv2_OFFSET_BIT (NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 3)
88013 +#define NET_HEADER_FIELD_L2TPv2_PRIORITY_BIT (NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 4)
88014 +#define NET_HEADER_FIELD_L2TPv2_VERSION (NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 5)
88015 +#define NET_HEADER_FIELD_L2TPv2_LEN (NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 6)
88016 +#define NET_HEADER_FIELD_L2TPv2_TUNNEL_ID (NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 7)
88017 +#define NET_HEADER_FIELD_L2TPv2_SESSION_ID (NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 8)
88018 +#define NET_HEADER_FIELD_L2TPv2_NS (NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 9)
88019 +#define NET_HEADER_FIELD_L2TPv2_NR (NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 10)
88020 +#define NET_HEADER_FIELD_L2TPv2_OFFSET_SIZE (NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 11)
88021 +#define NET_HEADER_FIELD_L2TPv2_FIRST_BYTE (NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 12)
88022 +#define NET_HEADER_FIELD_L2TPv2_ALL_FIELDS ((NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 13) - 1)
88023 +
88024 +#define NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT (1)
88025 +#define NET_HEADER_FIELD_L2TPv3_CTRL_LENGTH_BIT (NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 1)
88026 +#define NET_HEADER_FIELD_L2TPv3_CTRL_SEQUENCE_BIT (NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 2)
88027 +#define NET_HEADER_FIELD_L2TPv3_CTRL_VERSION (NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 3)
88028 +#define NET_HEADER_FIELD_L2TPv3_CTRL_LENGTH (NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 4)
88029 +#define NET_HEADER_FIELD_L2TPv3_CTRL_CONTROL (NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 5)
88030 +#define NET_HEADER_FIELD_L2TPv3_CTRL_SENT (NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 6)
88031 +#define NET_HEADER_FIELD_L2TPv3_CTRL_RECV (NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 7)
88032 +#define NET_HEADER_FIELD_L2TPv3_CTRL_FIRST_BYTE (NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 8)
88033 +#define NET_HEADER_FIELD_L2TPv3_CTRL_ALL_FIELDS ((NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 9) - 1)
88034 +
88035 +#define NET_HEADER_FIELD_L2TPv3_SESS_TYPE_BIT (1)
88036 +#define NET_HEADER_FIELD_L2TPv3_SESS_VERSION (NET_HEADER_FIELD_L2TPv3_SESS_TYPE_BIT << 1)
88037 +#define NET_HEADER_FIELD_L2TPv3_SESS_ID (NET_HEADER_FIELD_L2TPv3_SESS_TYPE_BIT << 2)
88038 +#define NET_HEADER_FIELD_L2TPv3_SESS_COOKIE (NET_HEADER_FIELD_L2TPv3_SESS_TYPE_BIT << 3)
88039 +#define NET_HEADER_FIELD_L2TPv3_SESS_ALL_FIELDS ((NET_HEADER_FIELD_L2TPv3_SESS_TYPE_BIT << 4) - 1)
88040 +
88041 +
88042 +typedef uint8_t headerFieldVlan_t;
88043 +
88044 +#define NET_HEADER_FIELD_VLAN_VPRI (1)
88045 +#define NET_HEADER_FIELD_VLAN_CFI (NET_HEADER_FIELD_VLAN_VPRI << 1)
88046 +#define NET_HEADER_FIELD_VLAN_VID (NET_HEADER_FIELD_VLAN_VPRI << 2)
88047 +#define NET_HEADER_FIELD_VLAN_LENGTH (NET_HEADER_FIELD_VLAN_VPRI << 3)
88048 +#define NET_HEADER_FIELD_VLAN_TYPE (NET_HEADER_FIELD_VLAN_VPRI << 4)
88049 +#define NET_HEADER_FIELD_VLAN_ALL_FIELDS ((NET_HEADER_FIELD_VLAN_VPRI << 5) - 1)
88050 +
88051 +#define NET_HEADER_FIELD_VLAN_TCI (NET_HEADER_FIELD_VLAN_VPRI | \
88052 + NET_HEADER_FIELD_VLAN_CFI | \
88053 + NET_HEADER_FIELD_VLAN_VID)
88054 +
88055 +
88056 +typedef uint8_t headerFieldLlc_t;
88057 +
88058 +#define NET_HEADER_FIELD_LLC_DSAP (1)
88059 +#define NET_HEADER_FIELD_LLC_SSAP (NET_HEADER_FIELD_LLC_DSAP << 1)
88060 +#define NET_HEADER_FIELD_LLC_CTRL (NET_HEADER_FIELD_LLC_DSAP << 2)
88061 +#define NET_HEADER_FIELD_LLC_ALL_FIELDS ((NET_HEADER_FIELD_LLC_DSAP << 3) - 1)
88062 +
88063 +#define NET_HEADER_FIELD_NLPID_NLPID (1)
88064 +#define NET_HEADER_FIELD_NLPID_ALL_FIELDS ((NET_HEADER_FIELD_NLPID_NLPID << 1) - 1)
88065 +
88066 +
88067 +typedef uint8_t headerFieldSnap_t;
88068 +
88069 +#define NET_HEADER_FIELD_SNAP_OUI (1)
88070 +#define NET_HEADER_FIELD_SNAP_PID (NET_HEADER_FIELD_SNAP_OUI << 1)
88071 +#define NET_HEADER_FIELD_SNAP_ALL_FIELDS ((NET_HEADER_FIELD_SNAP_OUI << 2) - 1)
88072 +
88073 +
88074 +typedef uint8_t headerFieldLlcSnap_t;
88075 +
88076 +#define NET_HEADER_FIELD_LLC_SNAP_TYPE (1)
88077 +#define NET_HEADER_FIELD_LLC_SNAP_ALL_FIELDS ((NET_HEADER_FIELD_LLC_SNAP_TYPE << 1) - 1)
88078 +
88079 +#define NET_HEADER_FIELD_ARP_HTYPE (1)
88080 +#define NET_HEADER_FIELD_ARP_PTYPE (NET_HEADER_FIELD_ARP_HTYPE << 1)
88081 +#define NET_HEADER_FIELD_ARP_HLEN (NET_HEADER_FIELD_ARP_HTYPE << 2)
88082 +#define NET_HEADER_FIELD_ARP_PLEN (NET_HEADER_FIELD_ARP_HTYPE << 3)
88083 +#define NET_HEADER_FIELD_ARP_OPER (NET_HEADER_FIELD_ARP_HTYPE << 4)
88084 +#define NET_HEADER_FIELD_ARP_SHA (NET_HEADER_FIELD_ARP_HTYPE << 5)
88085 +#define NET_HEADER_FIELD_ARP_SPA (NET_HEADER_FIELD_ARP_HTYPE << 6)
88086 +#define NET_HEADER_FIELD_ARP_THA (NET_HEADER_FIELD_ARP_HTYPE << 7)
88087 +#define NET_HEADER_FIELD_ARP_TPA (NET_HEADER_FIELD_ARP_HTYPE << 8)
88088 +#define NET_HEADER_FIELD_ARP_ALL_FIELDS ((NET_HEADER_FIELD_ARP_HTYPE << 9) - 1)
88089 +
88090 +#define NET_HEADER_FIELD_RFC2684_LLC (1)
88091 +#define NET_HEADER_FIELD_RFC2684_NLPID (NET_HEADER_FIELD_RFC2684_LLC << 1)
88092 +#define NET_HEADER_FIELD_RFC2684_OUI (NET_HEADER_FIELD_RFC2684_LLC << 2)
88093 +#define NET_HEADER_FIELD_RFC2684_PID (NET_HEADER_FIELD_RFC2684_LLC << 3)
88094 +#define NET_HEADER_FIELD_RFC2684_VPN_OUI (NET_HEADER_FIELD_RFC2684_LLC << 4)
88095 +#define NET_HEADER_FIELD_RFC2684_VPN_IDX (NET_HEADER_FIELD_RFC2684_LLC << 5)
88096 +#define NET_HEADER_FIELD_RFC2684_ALL_FIELDS ((NET_HEADER_FIELD_RFC2684_LLC << 6) - 1)
88097 +
88098 +#define NET_HEADER_FIELD_USER_DEFINED_SRCPORT (1)
88099 +#define NET_HEADER_FIELD_USER_DEFINED_PCDID (NET_HEADER_FIELD_USER_DEFINED_SRCPORT << 1)
88100 +#define NET_HEADER_FIELD_USER_DEFINED_ALL_FIELDS ((NET_HEADER_FIELD_USER_DEFINED_SRCPORT << 2) - 1)
88101 +
88102 +#define NET_HEADER_FIELD_PAYLOAD_BUFFER (1)
88103 +#define NET_HEADER_FIELD_PAYLOAD_SIZE (NET_HEADER_FIELD_PAYLOAD_BUFFER << 1)
88104 +#define NET_HEADER_FIELD_MAX_FRM_SIZE (NET_HEADER_FIELD_PAYLOAD_BUFFER << 2)
88105 +#define NET_HEADER_FIELD_MIN_FRM_SIZE (NET_HEADER_FIELD_PAYLOAD_BUFFER << 3)
88106 +#define NET_HEADER_FIELD_PAYLOAD_TYPE (NET_HEADER_FIELD_PAYLOAD_BUFFER << 4)
88107 +#define NET_HEADER_FIELD_FRAME_SIZE (NET_HEADER_FIELD_PAYLOAD_BUFFER << 5)
88108 +#define NET_HEADER_FIELD_PAYLOAD_ALL_FIELDS ((NET_HEADER_FIELD_PAYLOAD_BUFFER << 6) - 1)
88109 +
88110 +
88111 +typedef uint8_t headerFieldGre_t;
88112 +
88113 +#define NET_HEADER_FIELD_GRE_TYPE (1)
88114 +#define NET_HEADER_FIELD_GRE_ALL_FIELDS ((NET_HEADER_FIELD_GRE_TYPE << 1) - 1)
88115 +
88116 +
88117 +typedef uint8_t headerFieldMinencap_t;
88118 +
88119 +#define NET_HEADER_FIELD_MINENCAP_SRC_IP (1)
88120 +#define NET_HEADER_FIELD_MINENCAP_DST_IP (NET_HEADER_FIELD_MINENCAP_SRC_IP << 1)
88121 +#define NET_HEADER_FIELD_MINENCAP_TYPE (NET_HEADER_FIELD_MINENCAP_SRC_IP << 2)
88122 +#define NET_HEADER_FIELD_MINENCAP_ALL_FIELDS ((NET_HEADER_FIELD_MINENCAP_SRC_IP << 3) - 1)
88123 +
88124 +
88125 +typedef uint8_t headerFieldIpsecAh_t;
88126 +
88127 +#define NET_HEADER_FIELD_IPSEC_AH_SPI (1)
88128 +#define NET_HEADER_FIELD_IPSEC_AH_NH (NET_HEADER_FIELD_IPSEC_AH_SPI << 1)
88129 +#define NET_HEADER_FIELD_IPSEC_AH_ALL_FIELDS ((NET_HEADER_FIELD_IPSEC_AH_SPI << 2) - 1)
88130 +
88131 +
88132 +typedef uint8_t headerFieldIpsecEsp_t;
88133 +
88134 +#define NET_HEADER_FIELD_IPSEC_ESP_SPI (1)
88135 +#define NET_HEADER_FIELD_IPSEC_ESP_SEQUENCE_NUM (NET_HEADER_FIELD_IPSEC_ESP_SPI << 1)
88136 +#define NET_HEADER_FIELD_IPSEC_ESP_ALL_FIELDS ((NET_HEADER_FIELD_IPSEC_ESP_SPI << 2) - 1)
88137 +
88138 +#define NET_HEADER_FIELD_IPSEC_ESP_SPI_SIZE 4
88139 +
88140 +
88141 +typedef uint8_t headerFieldMpls_t;
88142 +
88143 +#define NET_HEADER_FIELD_MPLS_LABEL_STACK (1)
88144 +#define NET_HEADER_FIELD_MPLS_LABEL_STACK_ALL_FIELDS ((NET_HEADER_FIELD_MPLS_LABEL_STACK << 1) - 1)
88145 +
88146 +
88147 +typedef uint8_t headerFieldMacsec_t;
88148 +
88149 +#define NET_HEADER_FIELD_MACSEC_SECTAG (1)
88150 +#define NET_HEADER_FIELD_MACSEC_ALL_FIELDS ((NET_HEADER_FIELD_MACSEC_SECTAG << 1) - 1)
88151 +
88152 +
88153 +typedef enum {
88154 + HEADER_TYPE_NONE = 0,
88155 + HEADER_TYPE_PAYLOAD,
88156 + HEADER_TYPE_ETH,
88157 + HEADER_TYPE_VLAN,
88158 + HEADER_TYPE_IPv4,
88159 + HEADER_TYPE_IPv6,
88160 + HEADER_TYPE_IP,
88161 + HEADER_TYPE_TCP,
88162 + HEADER_TYPE_UDP,
88163 + HEADER_TYPE_UDP_LITE,
88164 + HEADER_TYPE_IPHC,
88165 + HEADER_TYPE_SCTP,
88166 + HEADER_TYPE_SCTP_CHUNK_DATA,
88167 + HEADER_TYPE_PPPoE,
88168 + HEADER_TYPE_PPP,
88169 + HEADER_TYPE_PPPMUX,
88170 + HEADER_TYPE_PPPMUX_SUBFRAME,
88171 + HEADER_TYPE_L2TPv2,
88172 + HEADER_TYPE_L2TPv3_CTRL,
88173 + HEADER_TYPE_L2TPv3_SESS,
88174 + HEADER_TYPE_LLC,
88175 + HEADER_TYPE_LLC_SNAP,
88176 + HEADER_TYPE_NLPID,
88177 + HEADER_TYPE_SNAP,
88178 + HEADER_TYPE_MPLS,
88179 + HEADER_TYPE_IPSEC_AH,
88180 + HEADER_TYPE_IPSEC_ESP,
88181 + HEADER_TYPE_UDP_ENCAP_ESP, /* RFC 3948 */
88182 + HEADER_TYPE_MACSEC,
88183 + HEADER_TYPE_GRE,
88184 + HEADER_TYPE_MINENCAP,
88185 + HEADER_TYPE_DCCP,
88186 + HEADER_TYPE_ICMP,
88187 + HEADER_TYPE_IGMP,
88188 + HEADER_TYPE_ARP,
88189 + HEADER_TYPE_CAPWAP,
88190 + HEADER_TYPE_CAPWAP_DTLS,
88191 + HEADER_TYPE_RFC2684,
88192 + HEADER_TYPE_USER_DEFINED_L2,
88193 + HEADER_TYPE_USER_DEFINED_L3,
88194 + HEADER_TYPE_USER_DEFINED_L4,
88195 + HEADER_TYPE_USER_DEFINED_SHIM1,
88196 + HEADER_TYPE_USER_DEFINED_SHIM2,
88197 + MAX_HEADER_TYPE_COUNT
88198 +} e_NetHeaderType;
88199 +
88200 +
88201 +#endif /* __NET_EXT_H */
88202 --- /dev/null
88203 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/std_ext.h
88204 @@ -0,0 +1,48 @@
88205 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
88206 + * All rights reserved.
88207 + *
88208 + * Redistribution and use in source and binary forms, with or without
88209 + * modification, are permitted provided that the following conditions are met:
88210 + * * Redistributions of source code must retain the above copyright
88211 + * notice, this list of conditions and the following disclaimer.
88212 + * * Redistributions in binary form must reproduce the above copyright
88213 + * notice, this list of conditions and the following disclaimer in the
88214 + * documentation and/or other materials provided with the distribution.
88215 + * * Neither the name of Freescale Semiconductor nor the
88216 + * names of its contributors may be used to endorse or promote products
88217 + * derived from this software without specific prior written permission.
88218 + *
88219 + *
88220 + * ALTERNATIVELY, this software may be distributed under the terms of the
88221 + * GNU General Public License ("GPL") as published by the Free Software
88222 + * Foundation, either version 2 of that License or (at your option) any
88223 + * later version.
88224 + *
88225 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
88226 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
88227 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
88228 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
88229 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
88230 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
88231 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
88232 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
88233 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
88234 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88235 + */
88236 +
88237 +
88238 +/**************************************************************************//**
88239 + @File std_ext.h
88240 +
88241 + @Description General Standard Definitions
88242 +*//***************************************************************************/
88243 +
88244 +#ifndef __STD_EXT_H
88245 +#define __STD_EXT_H
88246 +
88247 +
88248 +#include "types_ext.h"
88249 +#include "ncsw_ext.h"
88250 +
88251 +
88252 +#endif /* __STD_EXT_H */
88253 --- /dev/null
88254 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/stdarg_ext.h
88255 @@ -0,0 +1,49 @@
88256 +/*
88257 + * Copyright 2008-2012 Freescale Semiconductor Inc.
88258 + *
88259 + * Redistribution and use in source and binary forms, with or without
88260 + * modification, are permitted provided that the following conditions are met:
88261 + * * Redistributions of source code must retain the above copyright
88262 + * notice, this list of conditions and the following disclaimer.
88263 + * * Redistributions in binary form must reproduce the above copyright
88264 + * notice, this list of conditions and the following disclaimer in the
88265 + * documentation and/or other materials provided with the distribution.
88266 + * * Neither the name of Freescale Semiconductor nor the
88267 + * names of its contributors may be used to endorse or promote products
88268 + * derived from this software without specific prior written permission.
88269 + *
88270 + *
88271 + * ALTERNATIVELY, this software may be distributed under the terms of the
88272 + * GNU General Public License ("GPL") as published by the Free Software
88273 + * Foundation, either version 2 of that License or (at your option) any
88274 + * later version.
88275 + *
88276 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
88277 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
88278 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
88279 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
88280 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
88281 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
88282 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
88283 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
88284 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
88285 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88286 + */
88287 +
88288 +
88289 +#ifndef __STDARG_EXT_H
88290 +#define __STDARG_EXT_H
88291 +
88292 +
88293 +#if defined(NCSW_LINUX) && defined(__KERNEL__)
88294 +#include <stdarg.h>
88295 +
88296 +#else
88297 +#include <stdarg.h>
88298 +
88299 +#endif /* defined(NCSW_LINUX) && defined(__KERNEL__) */
88300 +
88301 +#include "std_ext.h"
88302 +
88303 +
88304 +#endif /* __STDARG_EXT_H */
88305 --- /dev/null
88306 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/stdlib_ext.h
88307 @@ -0,0 +1,162 @@
88308 +/*
88309 + * Copyright 2008-2012 Freescale Semiconductor Inc.
88310 + *
88311 + * Redistribution and use in source and binary forms, with or without
88312 + * modification, are permitted provided that the following conditions are met:
88313 + * * Redistributions of source code must retain the above copyright
88314 + * notice, this list of conditions and the following disclaimer.
88315 + * * Redistributions in binary form must reproduce the above copyright
88316 + * notice, this list of conditions and the following disclaimer in the
88317 + * documentation and/or other materials provided with the distribution.
88318 + * * Neither the name of Freescale Semiconductor nor the
88319 + * names of its contributors may be used to endorse or promote products
88320 + * derived from this software without specific prior written permission.
88321 + *
88322 + *
88323 + * ALTERNATIVELY, this software may be distributed under the terms of the
88324 + * GNU General Public License ("GPL") as published by the Free Software
88325 + * Foundation, either version 2 of that License or (at your option) any
88326 + * later version.
88327 + *
88328 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
88329 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
88330 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
88331 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
88332 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
88333 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
88334 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
88335 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
88336 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
88337 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88338 + */
88339 +
88340 +
88341 +
88342 +#ifndef __STDLIB_EXT_H
88343 +#define __STDLIB_EXT_H
88344 +
88345 +
88346 +#if (defined(NCSW_LINUX)) && defined(__KERNEL__)
88347 +#include "stdarg_ext.h"
88348 +#include "std_ext.h"
88349 +
88350 +
88351 +/**
88352 + * strtoul - convert a string to an uint32_t
88353 + * @cp: The start of the string
88354 + * @endp: A pointer to the end of the parsed string will be placed here
88355 + * @base: The number base to use
88356 + */
88357 +uint32_t strtoul(const char *cp,char **endp,uint32_t base);
88358 +
88359 +/**
88360 + * strtol - convert a string to a int32_t
88361 + * @cp: The start of the string
88362 + * @endp: A pointer to the end of the parsed string will be placed here
88363 + * @base: The number base to use
88364 + */
88365 +long strtol(const char *cp,char **endp,uint32_t base);
88366 +
88367 +/**
88368 + * strtoull - convert a string to an uint64_t
88369 + * @cp: The start of the string
88370 + * @endp: A pointer to the end of the parsed string will be placed here
88371 + * @base: The number base to use
88372 + */
88373 +uint64_t strtoull(const char *cp,char **endp,uint32_t base);
88374 +
88375 +/**
88376 + * strtoll - convert a string to a int64 long
88377 + * @cp: The start of the string
88378 + * @endp: A pointer to the end of the parsed string will be placed here
88379 + * @base: The number base to use
88380 + */
88381 +long long strtoll(const char *cp,char **endp,uint32_t base);
88382 +
88383 +/**
88384 + * atoi - convert a character to a int
88385 + * @s: The start of the string
88386 + */
88387 +int atoi(const char *s);
88388 +
88389 +/**
88390 + * strnlen - Find the length of a length-limited string
88391 + * @s: The string to be sized
88392 + * @count: The maximum number of bytes to search
88393 + */
88394 +size_t strnlen(const char * s, size_t count);
88395 +
88396 +/**
88397 + * strlen - Find the length of a string
88398 + * @s: The string to be sized
88399 + */
88400 +size_t strlen(const char * s);
88401 +
88402 +/**
88403 + * strtok - Split a string into tokens
88404 + * @s: The string to be searched
88405 + * @ct: The characters to search for
88406 + *
88407 + * WARNING: strtok is deprecated, use strsep instead.
88408 + */
88409 +char * strtok(char * s,const char * ct);
88410 +
88411 +/**
88412 + * strncpy - Copy a length-limited, %NUL-terminated string
88413 + * @dest: Where to copy the string to
88414 + * @src: Where to copy the string from
88415 + * @count: The maximum number of bytes to copy
88416 + *
88417 + * Note that unlike userspace strncpy, this does not %NUL-pad the buffer.
88418 + * However, the result is not %NUL-terminated if the source exceeds
88419 + * @count bytes.
88420 + */
88421 +char * strncpy(char * dest,const char *src,size_t count);
88422 +
88423 +/**
88424 + * strcpy - Copy a %NUL terminated string
88425 + * @dest: Where to copy the string to
88426 + * @src: Where to copy the string from
88427 + */
88428 +char * strcpy(char * dest,const char *src);
88429 +
88430 +/**
88431 + * vsscanf - Unformat a buffer into a list of arguments
88432 + * @buf: input buffer
88433 + * @fmt: format of buffer
88434 + * @args: arguments
88435 + */
88436 +int vsscanf(const char * buf, const char * fmt, va_list args);
88437 +
88438 +/**
88439 + * vsnprintf - Format a string and place it in a buffer
88440 + * @buf: The buffer to place the result into
88441 + * @size: The size of the buffer, including the trailing null space
88442 + * @fmt: The format string to use
88443 + * @args: Arguments for the format string
88444 + *
88445 + * Call this function if you are already dealing with a va_list.
88446 + * You probably want snprintf instead.
88447 + */
88448 +int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
88449 +
88450 +/**
88451 + * vsprintf - Format a string and place it in a buffer
88452 + * @buf: The buffer to place the result into
88453 + * @fmt: The format string to use
88454 + * @args: Arguments for the format string
88455 + *
88456 + * Call this function if you are already dealing with a va_list.
88457 + * You probably want sprintf instead.
88458 + */
88459 +int vsprintf(char *buf, const char *fmt, va_list args);
88460 +
88461 +#else
88462 +#include <stdlib.h>
88463 +#include <stdio.h>
88464 +#endif /* defined(NCSW_LINUX) && defined(__KERNEL__) */
88465 +
88466 +#include "std_ext.h"
88467 +
88468 +
88469 +#endif /* __STDLIB_EXT_H */
88470 --- /dev/null
88471 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/string_ext.h
88472 @@ -0,0 +1,56 @@
88473 +/*
88474 + * Copyright 2008-2012 Freescale Semiconductor Inc.
88475 + *
88476 + * Redistribution and use in source and binary forms, with or without
88477 + * modification, are permitted provided that the following conditions are met:
88478 + * * Redistributions of source code must retain the above copyright
88479 + * notice, this list of conditions and the following disclaimer.
88480 + * * Redistributions in binary form must reproduce the above copyright
88481 + * notice, this list of conditions and the following disclaimer in the
88482 + * documentation and/or other materials provided with the distribution.
88483 + * * Neither the name of Freescale Semiconductor nor the
88484 + * names of its contributors may be used to endorse or promote products
88485 + * derived from this software without specific prior written permission.
88486 + *
88487 + *
88488 + * ALTERNATIVELY, this software may be distributed under the terms of the
88489 + * GNU General Public License ("GPL") as published by the Free Software
88490 + * Foundation, either version 2 of that License or (at your option) any
88491 + * later version.
88492 + *
88493 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
88494 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
88495 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
88496 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
88497 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
88498 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
88499 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
88500 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
88501 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
88502 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88503 + */
88504 +
88505 +
88506 +#ifndef __STRING_EXT_H
88507 +#define __STRING_EXT_H
88508 +
88509 +
88510 +#if defined(NCSW_LINUX) && defined(__KERNEL__)
88511 +#include <linux/kernel.h>
88512 +#include <linux/string.h>
88513 +extern char * strtok ( char * str, const char * delimiters );
88514 +
88515 +#elif defined(__KERNEL__)
88516 +#include "linux/types.h"
88517 +#include "linux/posix_types.h"
88518 +#include "linux/string.h"
88519 +
88520 +#else
88521 +#include <string.h>
88522 +
88523 +#endif /* defined(NCSW_LINUX) && defined(__KERNEL__) */
88524 +
88525 +#include "std_ext.h"
88526 +
88527 +
88528 +#endif /* __STRING_EXT_H */
88529 --- /dev/null
88530 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/types_ext.h
88531 @@ -0,0 +1,62 @@
88532 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
88533 + * All rights reserved.
88534 + *
88535 + * Redistribution and use in source and binary forms, with or without
88536 + * modification, are permitted provided that the following conditions are met:
88537 + * * Redistributions of source code must retain the above copyright
88538 + * notice, this list of conditions and the following disclaimer.
88539 + * * Redistributions in binary form must reproduce the above copyright
88540 + * notice, this list of conditions and the following disclaimer in the
88541 + * documentation and/or other materials provided with the distribution.
88542 + * * Neither the name of Freescale Semiconductor nor the
88543 + * names of its contributors may be used to endorse or promote products
88544 + * derived from this software without specific prior written permission.
88545 + *
88546 + *
88547 + * ALTERNATIVELY, this software may be distributed under the terms of the
88548 + * GNU General Public License ("GPL") as published by the Free Software
88549 + * Foundation, either version 2 of that License or (at your option) any
88550 + * later version.
88551 + *
88552 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
88553 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
88554 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
88555 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
88556 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
88557 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
88558 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
88559 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
88560 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
88561 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88562 + */
88563 +
88564 +
88565 +/**************************************************************************//**
88566 + @File types_ext.h
88567 +
88568 + @Description General types Standard Definitions
88569 +*//***************************************************************************/
88570 +
88571 +#ifndef __TYPES_EXT_H
88572 +#define __TYPES_EXT_H
88573 +
88574 +#if defined(NCSW_LINUX)
88575 +#include "types_linux.h"
88576 +
88577 +#elif defined(NCSW_VXWORKS)
88578 +#include "types_vxworks.h"
88579 +
88580 +#elif defined(__GNUC__) && defined(__cplusplus)
88581 +#include "types_bb_gpp.h"
88582 +
88583 +#elif defined(__GNUC__)
88584 +#include "types_bb_gcc.h"
88585 +
88586 +#elif defined(__ghs__)
88587 +#include "types_ghs.h"
88588 +
88589 +#else
88590 +#include "types_dflt.h"
88591 +#endif /* defined (__ROCOO__) */
88592 +
88593 +#endif /* __TYPES_EXT_H */
88594 --- /dev/null
88595 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/xx_common.h
88596 @@ -0,0 +1,56 @@
88597 +/*
88598 + * Copyright 2012 Freescale Semiconductor Inc.
88599 + *
88600 + * Redistribution and use in source and binary forms, with or without
88601 + * modification, are permitted provided that the following conditions are met:
88602 + * * Redistributions of source code must retain the above copyright
88603 + * notice, this list of conditions and the following disclaimer.
88604 + * * Redistributions in binary form must reproduce the above copyright
88605 + * notice, this list of conditions and the following disclaimer in the
88606 + * documentation and/or other materials provided with the distribution.
88607 + * * Neither the name of Freescale Semiconductor nor the
88608 + * names of its contributors may be used to endorse or promote products
88609 + * derived from this software without specific prior written permission.
88610 + *
88611 + *
88612 + * ALTERNATIVELY, this software may be distributed under the terms of the
88613 + * GNU General Public License ("GPL") as published by the Free Software
88614 + * Foundation, either version 2 of that License or (at your option) any
88615 + * later version.
88616 + *
88617 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
88618 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
88619 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
88620 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
88621 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
88622 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
88623 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
88624 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
88625 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
88626 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88627 + */
88628 +
88629 +
88630 +/**************************************************************************//**
88631 + @File debug_ext.h
88632 +
88633 + @Description Debug mode definitions.
88634 +*//***************************************************************************/
88635 +
88636 +#ifndef __XX_COMMON_H
88637 +#define __XX_COMMON_H
88638 +
88639 +/*****************************************************************************
88640 + * UNIFIED MODULE CODES
88641 + *****************************************************************************/
88642 +#define MODULE_UNKNOWN 0x00000000
88643 +#define MODULE_FM 0x00010000
88644 +#define MODULE_FM_MURAM 0x00020000
88645 +#define MODULE_FM_PCD 0x00030000
88646 +#define MODULE_FM_RTC 0x00040000
88647 +#define MODULE_FM_MAC 0x00050000
88648 +#define MODULE_FM_PORT 0x00060000
88649 +#define MODULE_MM 0x00070000
88650 +#define MODULE_FM_SP 0x00080000
88651 +#define MODULE_FM_MACSEC 0x00090000
88652 +#endif /* __XX_COMMON_H */
88653 --- /dev/null
88654 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/xx_ext.h
88655 @@ -0,0 +1,791 @@
88656 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
88657 + * All rights reserved.
88658 + *
88659 + * Redistribution and use in source and binary forms, with or without
88660 + * modification, are permitted provided that the following conditions are met:
88661 + * * Redistributions of source code must retain the above copyright
88662 + * notice, this list of conditions and the following disclaimer.
88663 + * * Redistributions in binary form must reproduce the above copyright
88664 + * notice, this list of conditions and the following disclaimer in the
88665 + * documentation and/or other materials provided with the distribution.
88666 + * * Neither the name of Freescale Semiconductor nor the
88667 + * names of its contributors may be used to endorse or promote products
88668 + * derived from this software without specific prior written permission.
88669 + *
88670 + *
88671 + * ALTERNATIVELY, this software may be distributed under the terms of the
88672 + * GNU General Public License ("GPL") as published by the Free Software
88673 + * Foundation, either version 2 of that License or (at your option) any
88674 + * later version.
88675 + *
88676 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
88677 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
88678 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
88679 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
88680 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
88681 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
88682 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
88683 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
88684 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
88685 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88686 + */
88687 +
88688 +
88689 +/**************************************************************************//**
88690 + @File xx_ext.h
88691 +
88692 + @Description Prototypes, externals and typedefs for system-supplied
88693 + (external) routines
88694 +*//***************************************************************************/
88695 +
88696 +#ifndef __XX_EXT_H
88697 +#define __XX_EXT_H
88698 +
88699 +#include "std_ext.h"
88700 +#include "xx_common.h"
88701 +#include "part_ext.h"
88702 +
88703 +
88704 +
88705 +/**************************************************************************//**
88706 + @Group xx_id XX Interface (System call hooks)
88707 +
88708 + @Description Prototypes, externals and typedefs for system-supplied
88709 + (external) routines
88710 +
88711 + @{
88712 +*//***************************************************************************/
88713 +
88714 +#ifdef DEBUG_XX_MALLOC
88715 +void * XX_MallocDebug(uint32_t size, char *fname, int line);
88716 +
88717 +void * XX_MallocSmartDebug(uint32_t size,
88718 + int memPartitionId,
88719 + uint32_t alignment,
88720 + char *fname,
88721 + int line);
88722 +
88723 +#define XX_Malloc(sz) \
88724 + XX_MallocDebug((sz), __FILE__, __LINE__)
88725 +
88726 +#define XX_MallocSmart(sz, memt, al) \
88727 + XX_MallocSmartDebug((sz), (memt), (al), __FILE__, __LINE__)
88728 +
88729 +#else /* not DEBUG_XX_MALLOC */
88730 +/**************************************************************************//**
88731 + @Function XX_Malloc
88732 +
88733 + @Description allocates contiguous block of memory.
88734 +
88735 + @Param[in] size - Number of bytes to allocate.
88736 +
88737 + @Return The address of the newly allocated block on success, NULL on failure.
88738 +*//***************************************************************************/
88739 +void * XX_Malloc(uint32_t size);
88740 +
88741 +/**************************************************************************//**
88742 + @Function XX_MallocSmart
88743 +
88744 + @Description Allocates contiguous block of memory in a specified
88745 + alignment and from the specified segment.
88746 +
88747 + @Param[in] size - Number of bytes to allocate.
88748 + @Param[in] memPartitionId - Memory partition ID; The value zero must
88749 + be mapped to the default heap partition.
88750 + @Param[in] alignment - Required memory alignment (in bytes).
88751 +
88752 + @Return The address of the newly allocated block on success, NULL on failure.
88753 +*//***************************************************************************/
88754 +void * XX_MallocSmart(uint32_t size, int memPartitionId, uint32_t alignment);
88755 +#endif /* not DEBUG_XX_MALLOC */
88756 +
88757 +/**************************************************************************//**
88758 + @Function XX_FreeSmart
88759 +
88760 + @Description Frees the memory block pointed to by "p".
88761 + Only for memory allocated by XX_MallocSmart
88762 +
88763 + @Param[in] p_Memory - pointer to the memory block.
88764 +
88765 + @Return None.
88766 +*//***************************************************************************/
88767 +void XX_FreeSmart(void *p_Memory);
88768 +
88769 +/**************************************************************************//**
88770 + @Function XX_Free
88771 +
88772 + @Description frees the memory block pointed to by "p".
88773 +
88774 + @Param[in] p_Memory - pointer to the memory block.
88775 +
88776 + @Return None.
88777 +*//***************************************************************************/
88778 +void XX_Free(void *p_Memory);
88779 +
88780 +/**************************************************************************//**
88781 + @Function XX_Print
88782 +
88783 + @Description print a string.
88784 +
88785 + @Param[in] str - string to print.
88786 +
88787 + @Return None.
88788 +*//***************************************************************************/
88789 +void XX_Print(char *str, ...);
88790 +
88791 +/**************************************************************************//**
88792 + @Function XX_SetIntr
88793 +
88794 + @Description Set an interrupt service routine for a specific interrupt source.
88795 +
88796 + @Param[in] irq - Interrupt ID (system-specific number).
88797 + @Param[in] f_Isr - Callback routine that will be called when the interrupt occurs.
88798 + @Param[in] handle - The argument for the user callback routine.
88799 +
88800 + @Return E_OK on success; error code otherwise..
88801 +*//***************************************************************************/
88802 +t_Error XX_SetIntr(int irq, t_Isr *f_Isr, t_Handle handle);
88803 +
88804 +/**************************************************************************//**
88805 + @Function XX_FreeIntr
88806 +
88807 + @Description Free a specific interrupt and a specific callback routine.
88808 +
88809 + @Param[in] irq - Interrupt ID (system-specific number).
88810 +
88811 + @Return E_OK on success; error code otherwise..
88812 +*//***************************************************************************/
88813 +t_Error XX_FreeIntr(int irq);
88814 +
88815 +/**************************************************************************//**
88816 + @Function XX_EnableIntr
88817 +
88818 + @Description Enable a specific interrupt.
88819 +
88820 + @Param[in] irq - Interrupt ID (system-specific number).
88821 +
88822 + @Return E_OK on success; error code otherwise..
88823 +*//***************************************************************************/
88824 +t_Error XX_EnableIntr(int irq);
88825 +
88826 +/**************************************************************************//**
88827 + @Function XX_DisableIntr
88828 +
88829 + @Description Disable a specific interrupt.
88830 +
88831 + @Param[in] irq - Interrupt ID (system-specific number).
88832 +
88833 + @Return E_OK on success; error code otherwise..
88834 +*//***************************************************************************/
88835 +t_Error XX_DisableIntr(int irq);
88836 +
88837 +/**************************************************************************//**
88838 + @Function XX_DisableAllIntr
88839 +
88840 + @Description Disable all interrupts by masking them at the CPU.
88841 +
88842 + @Return A value that represents the interrupts state before the
88843 + operation, and should be passed to the matching
88844 + XX_RestoreAllIntr() call.
88845 +*//***************************************************************************/
88846 +uint32_t XX_DisableAllIntr(void);
88847 +
88848 +/**************************************************************************//**
88849 + @Function XX_RestoreAllIntr
88850 +
88851 + @Description Restore previous state of interrupts level at the CPU.
88852 +
88853 + @Param[in] flags - A value that represents the interrupts state to restore,
88854 + as returned by the matching call for XX_DisableAllIntr().
88855 +
88856 + @Return None.
88857 +*//***************************************************************************/
88858 +void XX_RestoreAllIntr(uint32_t flags);
88859 +
88860 +
88861 +/**************************************************************************//**
88862 + @Function XX_Exit
88863 +
88864 + @Description Stop execution and report status (where it is applicable)
88865 +
88866 + @Param[in] status - exit status
88867 +*//***************************************************************************/
88868 +void XX_Exit(int status);
88869 +
88870 +
88871 +/*****************************************************************************/
88872 +/* Tasklet Service Routines */
88873 +/*****************************************************************************/
88874 +typedef t_Handle t_TaskletHandle;
88875 +
88876 +/**************************************************************************//**
88877 + @Function XX_InitTasklet
88878 +
88879 + @Description Create and initialize a tasklet object.
88880 +
88881 + @Param[in] routine - A routine to be ran as a tasklet.
88882 + @Param[in] data - An argument to pass to the tasklet.
88883 +
88884 + @Return Tasklet handle is returned on success. NULL is returned otherwise.
88885 +*//***************************************************************************/
88886 +t_TaskletHandle XX_InitTasklet (void (*routine)(void *), void *data);
88887 +
88888 +/**************************************************************************//**
88889 + @Function XX_FreeTasklet
88890 +
88891 + @Description Free a tasklet object.
88892 +
88893 + @Param[in] h_Tasklet - A handle to a tasklet to be free.
88894 +
88895 + @Return None.
88896 +*//***************************************************************************/
88897 +void XX_FreeTasklet (t_TaskletHandle h_Tasklet);
88898 +
88899 +/**************************************************************************//**
88900 + @Function XX_ScheduleTask
88901 +
88902 + @Description Schedule a tasklet object.
88903 +
88904 + @Param[in] h_Tasklet - A handle to a tasklet to be scheduled.
88905 + @Param[in] immediate - Indicate whether to schedule this tasklet on
88906 + the immediate queue or on the delayed one.
88907 +
88908 + @Return 0 - on success. Error code - otherwise.
88909 +*//***************************************************************************/
88910 +int XX_ScheduleTask(t_TaskletHandle h_Tasklet, int immediate);
88911 +
88912 +/**************************************************************************//**
88913 + @Function XX_FlushScheduledTasks
88914 +
88915 + @Description Flush all tasks there are in the scheduled tasks queue.
88916 +
88917 + @Return None.
88918 +*//***************************************************************************/
88919 +void XX_FlushScheduledTasks(void);
88920 +
88921 +/**************************************************************************//**
88922 + @Function XX_TaskletIsQueued
88923 +
88924 + @Description Check if task is queued.
88925 +
88926 + @Param[in] h_Tasklet - A handle to a tasklet to be scheduled.
88927 +
88928 + @Return 1 - task is queued. 0 - otherwise.
88929 +*//***************************************************************************/
88930 +int XX_TaskletIsQueued(t_TaskletHandle h_Tasklet);
88931 +
88932 +/**************************************************************************//**
88933 + @Function XX_SetTaskletData
88934 +
88935 + @Description Set data to a scheduled task. Used to change data of already
88936 + scheduled task.
88937 +
88938 + @Param[in] h_Tasklet - A handle to a tasklet to be scheduled.
88939 + @Param[in] data - Data to be set.
88940 +*//***************************************************************************/
88941 +void XX_SetTaskletData(t_TaskletHandle h_Tasklet, t_Handle data);
88942 +
88943 +/**************************************************************************//**
88944 + @Function XX_GetTaskletData
88945 +
88946 + @Description Get the data of scheduled task.
88947 +
88948 + @Param[in] h_Tasklet - A handle to a tasklet to be scheduled.
88949 +
88950 + @Return handle to the data of the task.
88951 +*//***************************************************************************/
88952 +t_Handle XX_GetTaskletData(t_TaskletHandle h_Tasklet);
88953 +
88954 +/**************************************************************************//**
88955 + @Function XX_BottomHalf
88956 +
88957 + @Description Bottom half implementation, invoked by the interrupt handler.
88958 +
88959 + This routine handles all bottom-half tasklets with interrupts
88960 + enabled.
88961 +
88962 + @Return None.
88963 +*//***************************************************************************/
88964 +void XX_BottomHalf(void);
88965 +
88966 +
88967 +/*****************************************************************************/
88968 +/* Spinlock Service Routines */
88969 +/*****************************************************************************/
88970 +
88971 +/**************************************************************************//**
88972 + @Function XX_InitSpinlock
88973 +
88974 + @Description Creates a spinlock.
88975 +
88976 + @Return Spinlock handle is returned on success; NULL otherwise.
88977 +*//***************************************************************************/
88978 +t_Handle XX_InitSpinlock(void);
88979 +
88980 +/**************************************************************************//**
88981 + @Function XX_FreeSpinlock
88982 +
88983 + @Description Frees the memory allocated for the spinlock creation.
88984 +
88985 + @Param[in] h_Spinlock - A handle to a spinlock.
88986 +
88987 + @Return None.
88988 +*//***************************************************************************/
88989 +void XX_FreeSpinlock(t_Handle h_Spinlock);
88990 +
88991 +/**************************************************************************//**
88992 + @Function XX_LockSpinlock
88993 +
88994 + @Description Locks a spinlock.
88995 +
88996 + @Param[in] h_Spinlock - A handle to a spinlock.
88997 +
88998 + @Return None.
88999 +*//***************************************************************************/
89000 +void XX_LockSpinlock(t_Handle h_Spinlock);
89001 +
89002 +/**************************************************************************//**
89003 + @Function XX_UnlockSpinlock
89004 +
89005 + @Description Unlocks a spinlock.
89006 +
89007 + @Param[in] h_Spinlock - A handle to a spinlock.
89008 +
89009 + @Return None.
89010 +*//***************************************************************************/
89011 +void XX_UnlockSpinlock(t_Handle h_Spinlock);
89012 +
89013 +/**************************************************************************//**
89014 + @Function XX_LockIntrSpinlock
89015 +
89016 + @Description Locks a spinlock (interrupt safe).
89017 +
89018 + @Param[in] h_Spinlock - A handle to a spinlock.
89019 +
89020 + @Return A value that represents the interrupts state before the
89021 + operation, and should be passed to the matching
89022 + XX_UnlockIntrSpinlock() call.
89023 +*//***************************************************************************/
89024 +uint32_t XX_LockIntrSpinlock(t_Handle h_Spinlock);
89025 +
89026 +/**************************************************************************//**
89027 + @Function XX_UnlockIntrSpinlock
89028 +
89029 + @Description Unlocks a spinlock (interrupt safe).
89030 +
89031 + @Param[in] h_Spinlock - A handle to a spinlock.
89032 + @Param[in] intrFlags - A value that represents the interrupts state to
89033 + restore, as returned by the matching call for
89034 + XX_LockIntrSpinlock().
89035 +
89036 + @Return None.
89037 +*//***************************************************************************/
89038 +void XX_UnlockIntrSpinlock(t_Handle h_Spinlock, uint32_t intrFlags);
89039 +
89040 +
89041 +/*****************************************************************************/
89042 +/* Timers Service Routines */
89043 +/*****************************************************************************/
89044 +
89045 +/**************************************************************************//**
89046 + @Function XX_CurrentTime
89047 +
89048 + @Description Returns current system time.
89049 +
89050 + @Return Current system time (in milliseconds).
89051 +*//***************************************************************************/
89052 +uint32_t XX_CurrentTime(void);
89053 +
89054 +/**************************************************************************//**
89055 + @Function XX_CreateTimer
89056 +
89057 + @Description Creates a timer.
89058 +
89059 + @Return Timer handle is returned on success; NULL otherwise.
89060 +*//***************************************************************************/
89061 +t_Handle XX_CreateTimer(void);
89062 +
89063 +/**************************************************************************//**
89064 + @Function XX_FreeTimer
89065 +
89066 + @Description Frees the memory allocated for the timer creation.
89067 +
89068 + @Param[in] h_Timer - A handle to a timer.
89069 +
89070 + @Return None.
89071 +*//***************************************************************************/
89072 +void XX_FreeTimer(t_Handle h_Timer);
89073 +
89074 +/**************************************************************************//**
89075 + @Function XX_StartTimer
89076 +
89077 + @Description Starts a timer.
89078 +
89079 + The user can select to start the timer as periodic timer or as
89080 + one-shot timer. The user should provide a callback routine that
89081 + will be called when the timer expires.
89082 +
89083 + @Param[in] h_Timer - A handle to a timer.
89084 + @Param[in] msecs - Timer expiration period (in milliseconds).
89085 + @Param[in] periodic - TRUE for a periodic timer;
89086 + FALSE for a one-shot timer..
89087 + @Param[in] f_TimerExpired - A callback routine to be called when the
89088 + timer expires.
89089 + @Param[in] h_Arg - The argument to pass in the timer-expired
89090 + callback routine.
89091 +
89092 + @Return None.
89093 +*//***************************************************************************/
89094 +void XX_StartTimer(t_Handle h_Timer,
89095 + uint32_t msecs,
89096 + bool periodic,
89097 + void (*f_TimerExpired)(t_Handle h_Arg),
89098 + t_Handle h_Arg);
89099 +
89100 +/**************************************************************************//**
89101 + @Function XX_StopTimer
89102 +
89103 + @Description Frees the memory allocated for the timer creation.
89104 +
89105 + @Param[in] h_Timer - A handle to a timer.
89106 +
89107 + @Return None.
89108 +*//***************************************************************************/
89109 +void XX_StopTimer(t_Handle h_Timer);
89110 +
89111 +/**************************************************************************//**
89112 + @Function XX_ModTimer
89113 +
89114 + @Description Updates the expiration time of a timer.
89115 +
89116 + This routine adds the given time to the current system time,
89117 + and sets this value as the new expiration time of the timer.
89118 +
89119 + @Param[in] h_Timer - A handle to a timer.
89120 + @Param[in] msecs - The new interval until timer expiration
89121 + (in milliseconds).
89122 +
89123 + @Return None.
89124 +*//***************************************************************************/
89125 +void XX_ModTimer(t_Handle h_Timer, uint32_t msecs);
89126 +
89127 +/**************************************************************************//**
89128 + @Function XX_Sleep
89129 +
89130 + @Description Non-busy wait until the desired time (in milliseconds) has passed.
89131 +
89132 + @Param[in] msecs - The requested sleep time (in milliseconds).
89133 +
89134 + @Return Zero if the requested time has elapsed; Otherwise, the value
89135 + returned will be the unslept amount) in milliseconds.
89136 +
89137 + @Cautions This routine enables interrupts during its wait time.
89138 +*//***************************************************************************/
89139 +uint32_t XX_Sleep(uint32_t msecs);
89140 +
89141 +/**************************************************************************//**
89142 + @Function XX_UDelay
89143 +
89144 + @Description Busy-wait until the desired time (in microseconds) has passed.
89145 +
89146 + @Param[in] usecs - The requested delay time (in microseconds).
89147 +
89148 + @Return None.
89149 +
89150 + @Cautions It is highly unrecommended to call this routine during interrupt
89151 + time, because the system time may not be updated properly during
89152 + the delay loop. The behavior of this routine during interrupt
89153 + time is unexpected.
89154 +*//***************************************************************************/
89155 +void XX_UDelay(uint32_t usecs);
89156 +
89157 +
89158 +/*****************************************************************************/
89159 +/* Other Service Routines */
89160 +/*****************************************************************************/
89161 +
89162 +/**************************************************************************//**
89163 + @Function XX_PhysToVirt
89164 +
89165 + @Description Translates a physical address to the matching virtual address.
89166 +
89167 + @Param[in] addr - The physical address to translate.
89168 +
89169 + @Return Virtual address.
89170 +*//***************************************************************************/
89171 +void * XX_PhysToVirt(physAddress_t addr);
89172 +
89173 +/**************************************************************************//**
89174 + @Function XX_VirtToPhys
89175 +
89176 + @Description Translates a virtual address to the matching physical address.
89177 +
89178 + @Param[in] addr - The virtual address to translate.
89179 +
89180 + @Return Physical address.
89181 +*//***************************************************************************/
89182 +physAddress_t XX_VirtToPhys(void *addr);
89183 +
89184 +
89185 +/**************************************************************************//**
89186 + @Group xx_ipc XX Inter-Partition-Communication API
89187 +
89188 + @Description The following API is to be used when working with multiple
89189 + partitions configuration.
89190 +
89191 + @{
89192 +*//***************************************************************************/
89193 +
89194 +#define XX_IPC_MAX_ADDR_NAME_LENGTH 16 /**< Maximum length of an endpoint name string;
89195 + The IPC service can use this constant to limit
89196 + the storage space for IPC endpoint names. */
89197 +
89198 +
89199 +/**************************************************************************//**
89200 + @Function t_IpcMsgCompletion
89201 +
89202 + @Description Callback function used upon IPC non-blocking transaction completion
89203 + to return message buffer to the caller and to forward reply if available.
89204 +
89205 + This callback function may be attached by the source endpoint to any outgoing
89206 + IPC message to indicate a non-blocking send (see also XX_IpcSendMessage() routine).
89207 + Upon completion of an IPC transaction (consisting of a message and an optional reply),
89208 + the IPC service invokes this callback routine to return the message buffer to the sender
89209 + and to provide the received reply, if requested.
89210 +
89211 + User provides this function. Driver invokes it.
89212 +
89213 + @Param[in] h_Module - Abstract handle to the sending module - the same handle as was passed
89214 + in the XX_IpcSendMessage() function; This handle is typically used to point
89215 + to the internal data structure of the source endpoint.
89216 + @Param[in] p_Msg - Pointer to original (sent) message buffer;
89217 + The source endpoint can free (or reuse) this buffer when message
89218 + completion callback is called.
89219 + @Param[in] p_Reply - Pointer to (received) reply buffer;
89220 + This pointer is the same as was provided by the source endpoint in
89221 + XX_IpcSendMessage().
89222 + @Param[in] replyLength - Length (in bytes) of actual data in the reply buffer.
89223 + @Param[in] status - Completion status - E_OK or failure indication, e.g. IPC transaction completion
89224 + timeout.
89225 +
89226 + @Return None
89227 + *//***************************************************************************/
89228 +typedef void (t_IpcMsgCompletion)(t_Handle h_Module,
89229 + uint8_t *p_Msg,
89230 + uint8_t *p_Reply,
89231 + uint32_t replyLength,
89232 + t_Error status);
89233 +
89234 +/**************************************************************************//**
89235 + @Function t_IpcMsgHandler
89236 +
89237 + @Description Callback function used as IPC message handler.
89238 +
89239 + The IPC service invokes message handlers for each IPC message received.
89240 + The actual function pointer should be registered by each destination endpoint
89241 + via the XX_IpcRegisterMsgHandler() routine.
89242 +
89243 + User provides this function. Driver invokes it.
89244 +
89245 + @Param[in] h_Module - Abstract handle to the message handling module - the same handle as
89246 + was passed in the XX_IpcRegisterMsgHandler() function; this handle is
89247 + typically used to point to the internal data structure of the destination
89248 + endpoint.
89249 + @Param[in] p_Msg - Pointer to message buffer with data received from peer.
89250 + @Param[in] msgLength - Length (in bytes) of message data.
89251 + @Param[in] p_Reply - Pointer to reply buffer, to be filled by the message handler and then sent
89252 + by the IPC service;
89253 + The reply buffer is allocated by the IPC service with size equals to the
89254 + replyLength parameter provided in message handler registration (see
89255 + XX_IpcRegisterMsgHandler() function);
89256 + If replyLength was initially specified as zero during message handler registration,
89257 + the IPC service may set this pointer to NULL and assume that a reply is not needed;
89258 + The IPC service is also responsible for freeing the reply buffer after the
89259 + reply has been sent or dismissed.
89260 + @Param[in,out] p_ReplyLength - Pointer to reply length, which has a dual role in this function:
89261 + [In] equals the replyLength parameter provided in message handler
89262 + registration (see XX_IpcRegisterMsgHandler() function), and
89263 + [Out] should be updated by message handler to the actual reply length; if
89264 + this value is set to zero, the IPC service must assume that a reply should
89265 + not be sent;
89266 + Note: If p_Reply is not NULL, p_ReplyLength must not be NULL as well.
89267 +
89268 + @Return E_OK on success; Error code otherwise.
89269 + *//***************************************************************************/
89270 +typedef t_Error (t_IpcMsgHandler)(t_Handle h_Module,
89271 + uint8_t *p_Msg,
89272 + uint32_t msgLength,
89273 + uint8_t *p_Reply,
89274 + uint32_t *p_ReplyLength);
89275 +
89276 +/**************************************************************************//**
89277 + @Function XX_IpcRegisterMsgHandler
89278 +
89279 + @Description IPC mailbox registration.
89280 +
89281 + This function is used for registering an IPC message handler in the IPC service.
89282 + This function is called by each destination endpoint to indicate that it is ready
89283 + to handle incoming messages. The IPC service invokes the message handler upon receiving
89284 + a message addressed to the specified destination endpoint.
89285 +
89286 + @Param[in] addr - The address name string associated with the destination endpoint;
89287 + This address must be unique across the IPC service domain to ensure
89288 + correct message routing.
89289 + @Param[in] f_MsgHandler - Pointer to the message handler callback for processing incoming
89290 + message; invoked by the IPC service upon receiving a message
89291 + addressed to the destination endpoint specified by the addr
89292 + parameter.
89293 + @Param[in] h_Module - Abstract handle to the message handling module, passed unchanged
89294 + to f_MsgHandler callback function.
89295 + @Param[in] replyLength - The maximal data length (in bytes) of any reply that the specified message handler
89296 + may generate; the IPC service provides the message handler with buffer
89297 + for reply according to the length specified here (refer also to the description
89298 + of #t_IpcMsgHandler callback function type);
89299 + This size shall be zero if the message handler never generates replies.
89300 +
89301 + @Return E_OK on success; Error code otherwise.
89302 +*//***************************************************************************/
89303 +t_Error XX_IpcRegisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH],
89304 + t_IpcMsgHandler *f_MsgHandler,
89305 + t_Handle h_Module,
89306 + uint32_t replyLength);
89307 +
89308 +/**************************************************************************//**
89309 + @Function XX_IpcUnregisterMsgHandler
89310 +
89311 + @Description Release IPC mailbox routine.
89312 +
89313 + This function is used for unregistering an IPC message handler from the IPC service.
89314 + This function is called by each destination endpoint to indicate that it is no longer
89315 + capable of handling incoming messages.
89316 +
89317 + @Param[in] addr - The address name string associated with the destination endpoint;
89318 + This address is the same as was used when the message handler was
89319 + registered via XX_IpcRegisterMsgHandler().
89320 +
89321 + @Return E_OK on success; Error code otherwise.
89322 +*//***************************************************************************/
89323 +t_Error XX_IpcUnregisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH]);
89324 +
89325 +/**************************************************************************//**
89326 + @Function XX_IpcInitSession
89327 +
89328 + @Description This function is used for creating an IPC session between the source endpoint
89329 + and the destination endpoint.
89330 +
89331 + The actual implementation and representation of a session is left for the IPC service.
89332 + The function returns an abstract handle to the created session. This handle shall be used
89333 + by the source endpoint in subsequent calls to XX_IpcSendMessage().
89334 + The IPC service assumes that before this function is called, no messages are sent from
89335 + the specified source endpoint to the specified destination endpoint.
89336 +
89337 + The IPC service may use a connection-oriented approach or a connectionless approach (or both)
89338 + as described below.
89339 +
89340 + @par Connection-Oriented Approach
89341 +
89342 + The IPC service may implement a session in a connection-oriented approach - when this function is called,
89343 + the IPC service should take the necessary steps to bring up a source-to-destination channel for messages
89344 + and a destination-to-source channel for replies. The returned handle should represent the internal
89345 + representation of these channels.
89346 +
89347 + @par Connectionless Approach
89348 +
89349 + The IPC service may implement a session in a connectionless approach - when this function is called, the
89350 + IPC service should not perform any particular steps, but it must store the pair of source and destination
89351 + addresses in some session representation and return it as a handle. When XX_IpcSendMessage() shall be
89352 + called, the IPC service may use this handle to provide the necessary identifiers for routing the messages
89353 + through the connectionless medium.
89354 +
89355 + @Param[in] destAddr - The address name string associated with the destination endpoint.
89356 + @Param[in] srcAddr - The address name string associated with the source endpoint.
89357 +
89358 + @Return Abstract handle to the initialized session, or NULL on error.
89359 +*//***************************************************************************/
89360 +t_Handle XX_IpcInitSession(char destAddr[XX_IPC_MAX_ADDR_NAME_LENGTH],
89361 + char srcAddr[XX_IPC_MAX_ADDR_NAME_LENGTH]);
89362 +
89363 +/**************************************************************************//**
89364 + @Function XX_IpcFreeSession
89365 +
89366 + @Description This function is used for terminating an existing IPC session between a source endpoint
89367 + and a destination endpoint.
89368 +
89369 + The IPC service assumes that after this function is called, no messages shall be sent from
89370 + the associated source endpoint to the associated destination endpoint.
89371 +
89372 + @Param[in] h_Session - Abstract handle to the IPC session - the same handle as was originally
89373 + returned by the XX_IpcInitSession() function.
89374 +
89375 + @Return E_OK on success; Error code otherwise.
89376 +*//***************************************************************************/
89377 +t_Error XX_IpcFreeSession(t_Handle h_Session);
89378 +
89379 +/**************************************************************************//**
89380 + @Function XX_IpcSendMessage
89381 +
89382 + @Description IPC message send routine.
89383 +
89384 + This function may be used by a source endpoint to send an IPC message to a destination
89385 + endpoint. The source endpoint cannot send a message to the destination endpoint without
89386 + first initiating a session with that destination endpoint via XX_IpcInitSession() routine.
89387 +
89388 + The source endpoint must provide the buffer pointer and length of the outgoing message.
89389 + Optionally, it may also provide a buffer for an expected reply. In the latter case, the
89390 + transaction is not considered complete by the IPC service until the reply has been received.
89391 + If the source endpoint does not provide a reply buffer, the transaction is considered
89392 + complete after the message has been sent. The source endpoint must keep the message (and
89393 + optional reply) buffers valid until the transaction is complete.
89394 +
89395 + @par Non-blocking mode
89396 +
89397 + The source endpoint may request a non-blocking send by providing a non-NULL pointer to a message
89398 + completion callback function (f_Completion). Upon completion of the IPC transaction (consisting of a
89399 + message and an optional reply), the IPC service invokes this callback routine to return the message
89400 + buffer to the sender and to provide the received reply, if requested.
89401 +
89402 + @par Blocking mode
89403 +
89404 + The source endpoint may request a blocking send by setting f_Completion to NULL. The function is
89405 + expected to block until the IPC transaction is complete - either the reply has been received or (if no reply
89406 + was requested) the message has been sent.
89407 +
89408 + @Param[in] h_Session - Abstract handle to the IPC session - the same handle as was originally
89409 + returned by the XX_IpcInitSession() function.
89410 + @Param[in] p_Msg - Pointer to message buffer to send.
89411 + @Param[in] msgLength - Length (in bytes) of actual data in the message buffer.
89412 + @Param[in] p_Reply - Pointer to reply buffer - if this buffer is not NULL, the IPC service
89413 + fills this buffer with the received reply data;
89414 + In blocking mode, the reply data must be valid when the function returns;
89415 + In non-blocking mode, the reply data is valid when f_Completion is called;
89416 + If this pointer is NULL, no reply is expected.
89417 + @Param[in,out] p_ReplyLength - Pointer to reply length, which has a dual role in this function:
89418 + [In] specifies the maximal length (in bytes) of the reply buffer pointed by
89419 + p_Reply, and
89420 + [Out] in non-blocking mode this value is updated by the IPC service to the
89421 + actual reply length (in bytes).
89422 + @Param[in] f_Completion - Pointer to a completion callback to be used in non-blocking send mode;
89423 + The completion callback is invoked by the IPC service upon
89424 + completion of the IPC transaction (consisting of a message and an optional
89425 + reply);
89426 + If this pointer is NULL, the function is expected to block until the IPC
89427 + transaction is complete.
89428 + @Param[in] h_Arg - Abstract handle to the sending module; passed unchanged to the f_Completion
89429 + callback function as the first argument.
89430 +
89431 + @Return E_OK on success; Error code otherwise.
89432 +*//***************************************************************************/
89433 +t_Error XX_IpcSendMessage(t_Handle h_Session,
89434 + uint8_t *p_Msg,
89435 + uint32_t msgLength,
89436 + uint8_t *p_Reply,
89437 + uint32_t *p_ReplyLength,
89438 + t_IpcMsgCompletion *f_Completion,
89439 + t_Handle h_Arg);
89440 +
89441 +
89442 +/** @} */ /* end of xx_ipc group */
89443 +/** @} */ /* end of xx_id group */
89444 +
89445 +
89446 +#endif /* __XX_EXT_H */
89447 --- /dev/null
89448 +++ b/drivers/net/ethernet/freescale/sdk_fman/ls1043_dflags.h
89449 @@ -0,0 +1,56 @@
89450 +/*
89451 + * Copyright 2012 Freescale Semiconductor Inc.
89452 + *
89453 + * Redistribution and use in source and binary forms, with or without
89454 + * modification, are permitted provided that the following conditions are met:
89455 + * * Redistributions of source code must retain the above copyright
89456 + * notice, this list of conditions and the following disclaimer.
89457 + * * Redistributions in binary form must reproduce the above copyright
89458 + * notice, this list of conditions and the following disclaimer in the
89459 + * documentation and/or other materials provided with the distribution.
89460 + * * Neither the name of Freescale Semiconductor nor the
89461 + * names of its contributors may be used to endorse or promote products
89462 + * derived from this software without specific prior written permission.
89463 + *
89464 + *
89465 + * ALTERNATIVELY, this software may be distributed under the terms of the
89466 + * GNU General Public License ("GPL") as published by the Free Software
89467 + * Foundation, either version 2 of that License or (at your option) any
89468 + * later version.
89469 + *
89470 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
89471 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
89472 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
89473 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
89474 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
89475 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
89476 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
89477 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
89478 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
89479 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
89480 + */
89481 +
89482 +#ifndef __dflags_h
89483 +#define __dflags_h
89484 +
89485 +
89486 +#define NCSW_LINUX
89487 +
89488 +#define LS1043
89489 +
89490 +#define DEBUG_ERRORS 1
89491 +
89492 +#if defined(DEBUG)
89493 +#define DEBUG_GLOBAL_LEVEL REPORT_LEVEL_INFO
89494 +
89495 +#define DEBUG_XX_MALLOC
89496 +#define DEBUG_MEM_LEAKS
89497 +
89498 +#else
89499 +#define DEBUG_GLOBAL_LEVEL REPORT_LEVEL_WARNING
89500 +#endif /* (DEBUG) */
89501 +
89502 +#define REPORT_EVENTS 1
89503 +#define EVENT_GLOBAL_LEVEL REPORT_LEVEL_MINOR
89504 +
89505 +#endif /* __dflags_h */
89506 --- /dev/null
89507 +++ b/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
89508 @@ -0,0 +1,53 @@
89509 +#
89510 +# Makefile config for the Freescale NetcommSW
89511 +#
89512 +NET_DPA = $(srctree)/drivers/net
89513 +DRV_DPA = $(srctree)/drivers/net/ethernet/freescale/sdk_dpaa
89514 +FMAN = $(srctree)/drivers/net/ethernet/freescale/sdk_fman
89515 +
89516 +ifeq ("$(CONFIG_FMAN_P3040_P4080_P5020)", "y")
89517 +ccflags-y +=-include $(FMAN)/p3040_4080_5020_dflags.h
89518 +endif
89519 +ifeq ("$(CONFIG_FMAN_P1023)", "y")
89520 +ccflags-y +=-include $(FMAN)/p1023_dflags.h
89521 +endif
89522 +ifdef CONFIG_FMAN_V3H
89523 +ccflags-y +=-include $(FMAN)/fmanv3h_dflags.h
89524 +endif
89525 +ifdef CONFIG_FMAN_V3L
89526 +ccflags-y +=-include $(FMAN)/fmanv3l_dflags.h
89527 +endif
89528 +ifdef CONFIG_FMAN_ARM
89529 +ccflags-y +=-include $(FMAN)/ls1043_dflags.h
89530 +endif
89531 +
89532 +ccflags-y += -I$(DRV_DPA)/
89533 +ccflags-y += -I$(FMAN)/inc
89534 +ccflags-y += -I$(FMAN)/inc/cores
89535 +ccflags-y += -I$(FMAN)/inc/etc
89536 +ccflags-y += -I$(FMAN)/inc/Peripherals
89537 +ccflags-y += -I$(FMAN)/inc/flib
89538 +
89539 +ifeq ("$(CONFIG_FMAN_P3040_P4080_P5020)", "y")
89540 +ccflags-y += -I$(FMAN)/inc/integrations/P3040_P4080_P5020
89541 +endif
89542 +ifeq ("$(CONFIG_FMAN_P1023)", "y")
89543 +ccflags-y += -I$(FMAN)/inc/integrations/P1023
89544 +endif
89545 +ifdef CONFIG_FMAN_V3H
89546 +ccflags-y += -I$(FMAN)/inc/integrations/FMANV3H
89547 +endif
89548 +ifdef CONFIG_FMAN_V3L
89549 +ccflags-y += -I$(FMAN)/inc/integrations/FMANV3L
89550 +endif
89551 +ifdef CONFIG_FMAN_ARM
89552 +ccflags-y += -I$(FMAN)/inc/integrations/LS1043
89553 +endif
89554 +
89555 +ccflags-y += -I$(FMAN)/src/inc
89556 +ccflags-y += -I$(FMAN)/src/inc/system
89557 +ccflags-y += -I$(FMAN)/src/inc/wrapper
89558 +ccflags-y += -I$(FMAN)/src/inc/xx
89559 +ccflags-y += -I$(srctree)/include/uapi/linux/fmd
89560 +ccflags-y += -I$(srctree)/include/uapi/linux/fmd/Peripherals
89561 +ccflags-y += -I$(srctree)/include/uapi/linux/fmd/integrations
89562 --- /dev/null
89563 +++ b/drivers/net/ethernet/freescale/sdk_fman/p1023_dflags.h
89564 @@ -0,0 +1,65 @@
89565 +/*
89566 + * Copyright 2008-2012 Freescale Semiconductor Inc.
89567 + *
89568 + * Redistribution and use in source and binary forms, with or without
89569 + * modification, are permitted provided that the following conditions are met:
89570 + * * Redistributions of source code must retain the above copyright
89571 + * notice, this list of conditions and the following disclaimer.
89572 + * * Redistributions in binary form must reproduce the above copyright
89573 + * notice, this list of conditions and the following disclaimer in the
89574 + * documentation and/or other materials provided with the distribution.
89575 + * * Neither the name of Freescale Semiconductor nor the
89576 + * names of its contributors may be used to endorse or promote products
89577 + * derived from this software without specific prior written permission.
89578 + *
89579 + *
89580 + * ALTERNATIVELY, this software may be distributed under the terms of the
89581 + * GNU General Public License ("GPL") as published by the Free Software
89582 + * Foundation, either version 2 of that License or (at your option) any
89583 + * later version.
89584 + *
89585 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
89586 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
89587 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
89588 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
89589 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
89590 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
89591 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
89592 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
89593 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
89594 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
89595 + */
89596 +
89597 +#ifndef __dflags_h
89598 +#define __dflags_h
89599 +
89600 +
89601 +#define NCSW_LINUX
89602 +#if 0
89603 +#define DEBUG
89604 +#endif
89605 +
89606 +#define P1023
89607 +#define NCSW_PPC_CORE
89608 +
89609 +#define DEBUG_ERRORS 1
89610 +
89611 +#if defined(DEBUG)
89612 +#define DEBUG_GLOBAL_LEVEL REPORT_LEVEL_INFO
89613 +
89614 +#define DEBUG_XX_MALLOC
89615 +#define DEBUG_MEM_LEAKS
89616 +
89617 +#else
89618 +#define DEBUG_GLOBAL_LEVEL REPORT_LEVEL_WARNING
89619 +#endif /* (DEBUG) */
89620 +
89621 +#define REPORT_EVENTS 1
89622 +#define EVENT_GLOBAL_LEVEL REPORT_LEVEL_MINOR
89623 +
89624 +#ifdef CONFIG_P4080_SIM
89625 +#error "Do not define CONFIG_P4080_SIM..."
89626 +#endif
89627 +
89628 +
89629 +#endif /* __dflags_h */
89630 --- /dev/null
89631 +++ b/drivers/net/ethernet/freescale/sdk_fman/p3040_4080_5020_dflags.h
89632 @@ -0,0 +1,62 @@
89633 +/*
89634 + * Copyright 2008-2012 Freescale Semiconductor Inc.
89635 + *
89636 + * Redistribution and use in source and binary forms, with or without
89637 + * modification, are permitted provided that the following conditions are met:
89638 + * * Redistributions of source code must retain the above copyright
89639 + * notice, this list of conditions and the following disclaimer.
89640 + * * Redistributions in binary form must reproduce the above copyright
89641 + * notice, this list of conditions and the following disclaimer in the
89642 + * documentation and/or other materials provided with the distribution.
89643 + * * Neither the name of Freescale Semiconductor nor the
89644 + * names of its contributors may be used to endorse or promote products
89645 + * derived from this software without specific prior written permission.
89646 + *
89647 + *
89648 + * ALTERNATIVELY, this software may be distributed under the terms of the
89649 + * GNU General Public License ("GPL") as published by the Free Software
89650 + * Foundation, either version 2 of that License or (at your option) any
89651 + * later version.
89652 + *
89653 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
89654 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
89655 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
89656 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
89657 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
89658 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
89659 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
89660 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
89661 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
89662 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
89663 + */
89664 +
89665 +#ifndef __dflags_h
89666 +#define __dflags_h
89667 +
89668 +
89669 +#define NCSW_LINUX
89670 +
89671 +#define P4080
89672 +#define NCSW_PPC_CORE
89673 +
89674 +#define DEBUG_ERRORS 1
89675 +
89676 +#if defined(DEBUG)
89677 +#define DEBUG_GLOBAL_LEVEL REPORT_LEVEL_INFO
89678 +
89679 +#define DEBUG_XX_MALLOC
89680 +#define DEBUG_MEM_LEAKS
89681 +
89682 +#else
89683 +#define DEBUG_GLOBAL_LEVEL REPORT_LEVEL_WARNING
89684 +#endif /* (DEBUG) */
89685 +
89686 +#define REPORT_EVENTS 1
89687 +#define EVENT_GLOBAL_LEVEL REPORT_LEVEL_MINOR
89688 +
89689 +#ifdef CONFIG_P4080_SIM
89690 +#define SIMULATOR
89691 +#endif /* CONFIG_P4080_SIM */
89692 +
89693 +
89694 +#endif /* __dflags_h */
89695 --- /dev/null
89696 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/Makefile
89697 @@ -0,0 +1,11 @@
89698 +#
89699 +# Makefile for the Freescale Ethernet controllers
89700 +#
89701 +ccflags-y += -DVERSION=\"\"
89702 +#
89703 +#Include netcomm SW specific definitions
89704 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
89705 +#
89706 +obj-y += system/
89707 +obj-y += wrapper/
89708 +obj-y += xx/
89709 --- /dev/null
89710 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/system/sys_ext.h
89711 @@ -0,0 +1,118 @@
89712 +/*
89713 + * Copyright 2008-2012 Freescale Semiconductor Inc.
89714 + *
89715 + * Redistribution and use in source and binary forms, with or without
89716 + * modification, are permitted provided that the following conditions are met:
89717 + * * Redistributions of source code must retain the above copyright
89718 + * notice, this list of conditions and the following disclaimer.
89719 + * * Redistributions in binary form must reproduce the above copyright
89720 + * notice, this list of conditions and the following disclaimer in the
89721 + * documentation and/or other materials provided with the distribution.
89722 + * * Neither the name of Freescale Semiconductor nor the
89723 + * names of its contributors may be used to endorse or promote products
89724 + * derived from this software without specific prior written permission.
89725 + *
89726 + *
89727 + * ALTERNATIVELY, this software may be distributed under the terms of the
89728 + * GNU General Public License ("GPL") as published by the Free Software
89729 + * Foundation, either version 2 of that License or (at your option) any
89730 + * later version.
89731 + *
89732 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
89733 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
89734 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
89735 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
89736 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
89737 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
89738 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
89739 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
89740 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
89741 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
89742 + */
89743 +
89744 +#ifndef __SYS_EXT_H
89745 +#define __SYS_EXT_H
89746 +
89747 +#include "std_ext.h"
89748 +
89749 +
89750 +/**************************************************************************//**
89751 + @Group sys_grp System Interfaces
89752 +
89753 + @Description Linux system programming interfaces.
89754 +
89755 + @{
89756 +*//***************************************************************************/
89757 +
89758 +/**************************************************************************//**
89759 + @Group sys_gen_grp System General Interface
89760 +
89761 + @Description General definitions, structures and routines of the linux
89762 + system programming interface.
89763 +
89764 + @{
89765 +*//***************************************************************************/
89766 +
89767 +/**************************************************************************//**
89768 + @Collection Macros for Advanced Configuration Requests
89769 + @{
89770 +*//***************************************************************************/
89771 +#define SYS_MAX_ADV_CONFIG_ARGS 4
89772 + /**< Maximum number of arguments in
89773 + an advanced configuration entry */
89774 +/* @} */
89775 +
89776 +/**************************************************************************//**
89777 + @Description System Object Advanced Configuration Entry
89778 +
89779 + This structure represents a single request for an advanced
89780 + configuration call on the initialized object. An array of such
89781 + requests may be contained in the settings structure of the
89782 + corresponding object.
89783 +
89784 + The maximum number of arguments is limited to #SYS_MAX_ADV_CONFIG_ARGS.
89785 +*//***************************************************************************/
89786 +typedef struct t_SysObjectAdvConfigEntry
89787 +{
89788 + void *p_Function; /**< Pointer to advanced configuration routine */
89789 +
89790 + uintptr_t args[SYS_MAX_ADV_CONFIG_ARGS];
89791 + /**< Array of arguments for the specified routine;
89792 + All arguments should be casted to uint32_t. */
89793 +} t_SysObjectAdvConfigEntry;
89794 +
89795 +
89796 +/** @} */ /* end of sys_gen_grp */
89797 +/** @} */ /* end of sys_grp */
89798 +
89799 +#define NCSW_PARAMS(_num, _params) ADV_CONFIG_PARAMS_##_num _params
89800 +
89801 +#define ADV_CONFIG_PARAMS_1(_type) \
89802 + , (_type)p_Entry->args[0]
89803 +
89804 +#define SET_ADV_CONFIG_ARGS_1(_arg0) \
89805 + p_Entry->args[0] = (uintptr_t )(_arg0); \
89806 +
89807 +#define ARGS(_num, _params) SET_ADV_CONFIG_ARGS_##_num _params
89808 +
89809 +#define ADD_ADV_CONFIG_START(_p_Entries, _maxEntries) \
89810 + { \
89811 + t_SysObjectAdvConfigEntry *p_Entry; \
89812 + t_SysObjectAdvConfigEntry *p_Entrys = (_p_Entries); \
89813 + int i=0, max = (_maxEntries); \
89814 +
89815 +#define ADD_ADV_CONFIG_END \
89816 + }
89817 +
89818 +#define ADV_CONFIG_CHECK_START(_p_Entry) \
89819 + { \
89820 + t_SysObjectAdvConfigEntry *p_Entry = _p_Entry; \
89821 + t_Error errCode; \
89822 +
89823 +#define ADV_CONFIG_CHECK(_handle, _func, _params) \
89824 + if (p_Entry->p_Function == _func) \
89825 + { \
89826 + errCode = _func(_handle _params); \
89827 + } else
89828 +
89829 +#endif /* __SYS_EXT_H */
89830 --- /dev/null
89831 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/system/sys_io_ext.h
89832 @@ -0,0 +1,46 @@
89833 +/*
89834 + * Copyright 2008-2012 Freescale Semiconductor Inc.
89835 + *
89836 + * Redistribution and use in source and binary forms, with or without
89837 + * modification, are permitted provided that the following conditions are met:
89838 + * * Redistributions of source code must retain the above copyright
89839 + * notice, this list of conditions and the following disclaimer.
89840 + * * Redistributions in binary form must reproduce the above copyright
89841 + * notice, this list of conditions and the following disclaimer in the
89842 + * documentation and/or other materials provided with the distribution.
89843 + * * Neither the name of Freescale Semiconductor nor the
89844 + * names of its contributors may be used to endorse or promote products
89845 + * derived from this software without specific prior written permission.
89846 + *
89847 + *
89848 + * ALTERNATIVELY, this software may be distributed under the terms of the
89849 + * GNU General Public License ("GPL") as published by the Free Software
89850 + * Foundation, either version 2 of that License or (at your option) any
89851 + * later version.
89852 + *
89853 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
89854 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
89855 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
89856 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
89857 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
89858 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
89859 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
89860 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
89861 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
89862 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
89863 + */
89864 +
89865 +#ifndef __SYS_IO_EXT_H
89866 +#define __SYS_IO_EXT_H
89867 +
89868 +#include "std_ext.h"
89869 +#include "error_ext.h"
89870 +
89871 +
89872 +t_Error SYS_RegisterIoMap (uint64_t virtAddr, uint64_t physAddr, uint32_t size);
89873 +t_Error SYS_UnregisterIoMap (uint64_t virtAddr);
89874 +uint64_t SYS_PhysToVirt (uint64_t addr);
89875 +uint64_t SYS_VirtToPhys (uint64_t addr);
89876 +
89877 +
89878 +#endif /* __SYS_IO_EXT_H */
89879 --- /dev/null
89880 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/types_linux.h
89881 @@ -0,0 +1,208 @@
89882 +/*
89883 + * Copyright 2008-2012 Freescale Semiconductor Inc.
89884 + *
89885 + * Redistribution and use in source and binary forms, with or without
89886 + * modification, are permitted provided that the following conditions are met:
89887 + * * Redistributions of source code must retain the above copyright
89888 + * notice, this list of conditions and the following disclaimer.
89889 + * * Redistributions in binary form must reproduce the above copyright
89890 + * notice, this list of conditions and the following disclaimer in the
89891 + * documentation and/or other materials provided with the distribution.
89892 + * * Neither the name of Freescale Semiconductor nor the
89893 + * names of its contributors may be used to endorse or promote products
89894 + * derived from this software without specific prior written permission.
89895 + *
89896 + *
89897 + * ALTERNATIVELY, this software may be distributed under the terms of the
89898 + * GNU General Public License ("GPL") as published by the Free Software
89899 + * Foundation, either version 2 of that License or (at your option) any
89900 + * later version.
89901 + *
89902 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
89903 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
89904 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
89905 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
89906 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
89907 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
89908 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
89909 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
89910 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
89911 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
89912 + */
89913 +
89914 +#ifndef __TYPES_LINUX_H__
89915 +#define __TYPES_LINUX_H__
89916 +
89917 +#include <linux/version.h>
89918 +
89919 +#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
89920 +#define MODVERSIONS
89921 +#endif
89922 +#ifdef MODVERSIONS
89923 +#include <config/modversions.h>
89924 +#endif /* MODVERSIONS */
89925 +
89926 +#include <linux/kernel.h>
89927 +#include <linux/types.h>
89928 +#include <asm/io.h>
89929 +#include <linux/delay.h>
89930 +
89931 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
89932 + #error "This kernel is probably not supported!!!"
89933 +#elif (!((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) || \
89934 + (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27)) || \
89935 + (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,30))))
89936 + #warning "This kernel is probably not supported!!! You may need to add some fixes."
89937 +#endif /* LINUX_VERSION_CODE */
89938 +
89939 +
89940 +typedef float float_t; /* Single precision floating point */
89941 +typedef double double_t; /* Double precision floating point */
89942 +
89943 +
89944 +#define _Packed
89945 +#define _PackedType __attribute__ ((packed))
89946 +
89947 +typedef phys_addr_t physAddress_t;
89948 +
89949 +#define UINT8_MAX 0xFF
89950 +#define UINT8_MIN 0
89951 +#define UINT16_MAX 0xFFFF
89952 +#define UINT16_MIN 0
89953 +#define UINT32_MAX 0xFFFFFFFF
89954 +#define UINT32_MIN 0
89955 +#define UINT64_MAX 0xFFFFFFFFFFFFFFFFLL
89956 +#define UINT64_MIN 0
89957 +#define INT8_MAX 0x7F
89958 +#define INT8_MIN 0x80
89959 +#define INT16_MAX 0x7FFF
89960 +#define INT16_MIN 0x8000
89961 +#define INT32_MAX 0x7FFFFFFF
89962 +#define INT32_MIN 0x80000000
89963 +#define INT64_MAX 0x7FFFFFFFFFFFFFFFLL
89964 +#define INT64_MIN 0x8000000000000000LL
89965 +
89966 +#define ON 1
89967 +#define OFF 0
89968 +
89969 +#define FALSE false
89970 +#define TRUE true
89971 +
89972 +
89973 +/************************/
89974 +/* memory access macros */
89975 +/************************/
89976 +#ifdef CONFIG_FMAN_ARM
89977 +#define in_be16(a) __be16_to_cpu(__raw_readw(a))
89978 +#define in_be32(a) __be32_to_cpu(__raw_readl(a))
89979 +#define out_be16(a, v) __raw_writew(__cpu_to_be16(v), a)
89980 +#define out_be32(a, v) __raw_writel(__cpu_to_be32(v), a)
89981 +#endif
89982 +
89983 +#define GET_UINT8(arg) *(volatile uint8_t *)(&(arg))
89984 +#define GET_UINT16(arg) in_be16(&(arg))//*(volatile uint16_t*)(&(arg))
89985 +#define GET_UINT32(arg) in_be32(&(arg))//*(volatile uint32_t*)(&(arg))
89986 +#define GET_UINT64(arg) *(volatile uint64_t*)(&(arg))
89987 +
89988 +#ifdef VERBOSE_WRITE
89989 +void XX_Print(char *str, ...);
89990 +#define WRITE_UINT8(arg, data) \
89991 + do { XX_Print("ADDR: 0x%08x, VAL: 0x%02x\r\n", (uint32_t)&(arg), (data)); *(volatile uint8_t *)(&(arg)) = (data); } while (0)
89992 +#define WRITE_UINT16(arg, data) \
89993 + do { XX_Print("ADDR: 0x%08x, VAL: 0x%04x\r\n", (uint32_t)&(arg), (data)); out_be16(&(arg), data); /* *(volatile uint16_t*)(&(arg)) = (data);*/ } while (0)
89994 +#define WRITE_UINT32(arg, data) \
89995 + do { XX_Print("ADDR: 0x%08x, VAL: 0x%08x\r\n", (uint32_t)&(arg), (data)); out_be32(&(arg), data); /* *(volatile uint32_t*)(&(arg)) = (data);*/ } while (0)
89996 +#define WRITE_UINT64(arg, data) \
89997 + do { XX_Print("ADDR: 0x%08x, VAL: 0x%016llx\r\n", (uint32_t)&(arg), (data)); *(volatile uint64_t*)(&(arg)) = (data); } while (0)
89998 +
89999 +#else /* not VERBOSE_WRITE */
90000 +#define WRITE_UINT8(arg, data) *(volatile uint8_t *)(&(arg)) = (data)
90001 +#define WRITE_UINT16(arg, data) out_be16(&(arg), data)//*(volatile uint16_t*)(&(arg)) = (data)
90002 +#define WRITE_UINT32(arg, data) out_be32(&(arg), data)//*(volatile unsigned int *)(&(arg)) = (data)
90003 +#define WRITE_UINT64(arg, data) *(volatile uint64_t*)(&(arg)) = (data)
90004 +#endif /* not VERBOSE_WRITE */
90005 +
90006 +
90007 +/*****************************************************************************/
90008 +/* General stuff */
90009 +/*****************************************************************************/
90010 +#ifdef ARRAY_SIZE
90011 +#undef ARRAY_SIZE
90012 +#endif /* ARRAY_SIZE */
90013 +
90014 +#ifdef MAJOR
90015 +#undef MAJOR
90016 +#endif /* MAJOR */
90017 +
90018 +#ifdef MINOR
90019 +#undef MINOR
90020 +#endif /* MINOR */
90021 +
90022 +#ifdef QE_SIZEOF_BD
90023 +#undef QE_SIZEOF_BD
90024 +#endif /* QE_SIZEOF_BD */
90025 +
90026 +#ifdef BD_BUFFER_CLEAR
90027 +#undef BD_BUFFER_CLEAR
90028 +#endif /* BD_BUFFER_CLEAR */
90029 +
90030 +#ifdef BD_BUFFER
90031 +#undef BD_BUFFER
90032 +#endif /* BD_BUFFER */
90033 +
90034 +#ifdef BD_STATUS_AND_LENGTH_SET
90035 +#undef BD_STATUS_AND_LENGTH_SET
90036 +#endif /* BD_STATUS_AND_LENGTH_SET */
90037 +
90038 +#ifdef BD_STATUS_AND_LENGTH
90039 +#undef BD_STATUS_AND_LENGTH
90040 +#endif /* BD_STATUS_AND_LENGTH */
90041 +
90042 +#ifdef BD_BUFFER_ARG
90043 +#undef BD_BUFFER_ARG
90044 +#endif /* BD_BUFFER_ARG */
90045 +
90046 +#ifdef BD_GET_NEXT
90047 +#undef BD_GET_NEXT
90048 +#endif /* BD_GET_NEXT */
90049 +
90050 +#ifdef QE_SDEBCR_BA_MASK
90051 +#undef QE_SDEBCR_BA_MASK
90052 +#endif /* QE_SDEBCR_BA_MASK */
90053 +
90054 +#ifdef BD_BUFFER_SET
90055 +#undef BD_BUFFER_SET
90056 +#endif /* BD_BUFFER_SET */
90057 +
90058 +#ifdef UPGCR_PROTOCOL
90059 +#undef UPGCR_PROTOCOL
90060 +#endif /* UPGCR_PROTOCOL */
90061 +
90062 +#ifdef UPGCR_TMS
90063 +#undef UPGCR_TMS
90064 +#endif /* UPGCR_TMS */
90065 +
90066 +#ifdef UPGCR_RMS
90067 +#undef UPGCR_RMS
90068 +#endif /* UPGCR_RMS */
90069 +
90070 +#ifdef UPGCR_ADDR
90071 +#undef UPGCR_ADDR
90072 +#endif /* UPGCR_ADDR */
90073 +
90074 +#ifdef UPGCR_DIAG
90075 +#undef UPGCR_DIAG
90076 +#endif /* UPGCR_DIAG */
90077 +
90078 +#ifdef NCSW_PARAMS
90079 +#undef NCSW_PARAMS
90080 +#endif /* NCSW_PARAMS */
90081 +
90082 +#ifdef NO_IRQ
90083 +#undef NO_IRQ
90084 +#endif /* NO_IRQ */
90085 +
90086 +#define PRINT_LINE XX_Print("%s:\n %s [%d]\n",__FILE__,__FUNCTION__,__LINE__);
90087 +
90088 +
90089 +#endif /* __TYPES_LINUX_H__ */
90090 --- /dev/null
90091 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/fsl_fman_test.h
90092 @@ -0,0 +1,84 @@
90093 +/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
90094 + * All rights reserved.
90095 + *
90096 + * Redistribution and use in source and binary forms, with or without
90097 + * modification, are permitted provided that the following conditions are met:
90098 + * * Redistributions of source code must retain the above copyright
90099 + * notice, this list of conditions and the following disclaimer.
90100 + * * Redistributions in binary form must reproduce the above copyright
90101 + * notice, this list of conditions and the following disclaimer in the
90102 + * documentation and/or other materials provided with the distribution.
90103 + * * Neither the name of Freescale Semiconductor nor the
90104 + * names of its contributors may be used to endorse or promote products
90105 + * derived from this software without specific prior written permission.
90106 + *
90107 + *
90108 + * ALTERNATIVELY, this software may be distributed under the terms of the
90109 + * GNU General Public License ("GPL") as published by the Free Software
90110 + * Foundation, either version 2 of that License or (at your option) any
90111 + * later version.
90112 + *
90113 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
90114 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
90115 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
90116 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
90117 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
90118 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
90119 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
90120 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
90121 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90122 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90123 + */
90124 +
90125 +/******************************************************************************
90126 + @File fsl_fman_test.h
90127 +
90128 + @Description
90129 +*//***************************************************************************/
90130 +
90131 +#ifndef __FSL_FMAN_TEST_H
90132 +#define __FSL_FMAN_TEST_H
90133 +
90134 +#include <linux/types.h>
90135 +#include <linux/smp.h> /* raw_smp_processor_id() */
90136 +
90137 +//#define FMT_K_DBG
90138 +//#define FMT_K_DBG_RUNTIME
90139 +
90140 +#define _fmt_prk(stage, format, arg...) \
90141 + printk(stage "fmt (cpu:%u): " format, raw_smp_processor_id(), ##arg)
90142 +
90143 +#define _fmt_inf(format, arg...) _fmt_prk(KERN_INFO, format, ##arg)
90144 +#define _fmt_wrn(format, arg...) _fmt_prk(KERN_WARNING, format, ##arg)
90145 +#define _fmt_err(format, arg...) _fmt_prk(KERN_ERR, format, ##arg)
90146 +
90147 +/* there are two macros for debugging: for runtime and generic.
90148 + * Helps when the runtime functions are not targeted for debugging,
90149 + * thus all the unnecessary information will be skipped.
90150 + */
90151 +/* used for generic debugging */
90152 +#if defined(FMT_K_DBG)
90153 + #define _fmt_dbg(format, arg...) \
90154 + printk("fmt [%s:%u](cpu:%u) - " format, \
90155 + __func__, __LINE__, raw_smp_processor_id(), ##arg)
90156 +#else
90157 +# define _fmt_dbg(arg...)
90158 +#endif
90159 +
90160 +/* used for debugging runtime functions */
90161 +#if defined(FMT_K_DBG_RUNTIME)
90162 + #define _fmt_dbgr(format, arg...) \
90163 + printk("fmt [%s:%u](cpu:%u) - " format, \
90164 + __func__, __LINE__, raw_smp_processor_id(), ##arg)
90165 +#else
90166 +# define _fmt_dbgr(arg...)
90167 +#endif
90168 +
90169 +#define FMT_RX_ERR_Q 0xffffffff
90170 +#define FMT_RX_DFLT_Q 0xfffffffe
90171 +#define FMT_TX_ERR_Q 0xfffffffd
90172 +#define FMT_TX_CONF_Q 0xfffffffc
90173 +
90174 +#define FMAN_TEST_MAX_TX_FQS 8
90175 +
90176 +#endif /* __FSL_FMAN_TEST_H */
90177 --- /dev/null
90178 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_exp_sym.h
90179 @@ -0,0 +1,127 @@
90180 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc.
90181 + * All rights reserved.
90182 + *
90183 + * Redistribution and use in source and binary forms, with or without
90184 + * modification, are permitted provided that the following conditions are met:
90185 + * * Redistributions of source code must retain the above copyright
90186 + * notice, this list of conditions and the following disclaimer.
90187 + * * Redistributions in binary form must reproduce the above copyright
90188 + * notice, this list of conditions and the following disclaimer in the
90189 + * documentation and/or other materials provided with the distribution.
90190 + * * Neither the name of Freescale Semiconductor nor the
90191 + * names of its contributors may be used to endorse or promote products
90192 + * derived from this software without specific prior written permission.
90193 + *
90194 + *
90195 + * ALTERNATIVELY, this software may be distributed under the terms of the
90196 + * GNU General Public License ("GPL") as published by the Free Software
90197 + * Foundation, either version 2 of that License or (at your option) any
90198 + * later version.
90199 + *
90200 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
90201 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
90202 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
90203 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
90204 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
90205 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
90206 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
90207 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
90208 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90209 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90210 + */
90211 +
90212 +/*
90213 + @File lnxwrp_exp_sym.h
90214 + @Description FMan exported routines
90215 +*/
90216 +
90217 +#ifndef __LNXWRP_EXP_SYM_H
90218 +#define __LNXWRP_EXP_SYM_H
90219 +
90220 +#include "fm_port_ext.h"
90221 +#include "fm_pcd_ext.h"
90222 +#include "fm_mac_ext.h"
90223 +
90224 +
90225 +/* FMAN Port exported routines */
90226 +EXPORT_SYMBOL(FM_PORT_Disable);
90227 +EXPORT_SYMBOL(FM_PORT_Enable);
90228 +EXPORT_SYMBOL(FM_PORT_SetPCD);
90229 +
90230 +/* Runtime PCD exported routines */
90231 +EXPORT_SYMBOL(FM_PCD_Enable);
90232 +EXPORT_SYMBOL(FM_PCD_Disable);
90233 +EXPORT_SYMBOL(FM_PCD_GetCounter);
90234 +EXPORT_SYMBOL(FM_PCD_PrsLoadSw);
90235 +EXPORT_SYMBOL(FM_PCD_KgSetDfltValue);
90236 +EXPORT_SYMBOL(FM_PCD_KgSetAdditionalDataAfterParsing);
90237 +EXPORT_SYMBOL(FM_PCD_SetException);
90238 +EXPORT_SYMBOL(FM_PCD_ModifyCounter);
90239 +EXPORT_SYMBOL(FM_PCD_SetPlcrStatistics);
90240 +EXPORT_SYMBOL(FM_PCD_SetPrsStatistics);
90241 +EXPORT_SYMBOL(FM_PCD_ForceIntr);
90242 +EXPORT_SYMBOL(FM_PCD_HcTxConf);
90243 +
90244 +EXPORT_SYMBOL(FM_PCD_NetEnvCharacteristicsSet);
90245 +EXPORT_SYMBOL(FM_PCD_NetEnvCharacteristicsDelete);
90246 +EXPORT_SYMBOL(FM_PCD_KgSchemeSet);
90247 +EXPORT_SYMBOL(FM_PCD_KgSchemeDelete);
90248 +EXPORT_SYMBOL(FM_PCD_KgSchemeGetCounter);
90249 +EXPORT_SYMBOL(FM_PCD_KgSchemeSetCounter);
90250 +EXPORT_SYMBOL(FM_PCD_CcRootBuild);
90251 +EXPORT_SYMBOL(FM_PCD_CcRootDelete);
90252 +EXPORT_SYMBOL(FM_PCD_MatchTableSet);
90253 +EXPORT_SYMBOL(FM_PCD_MatchTableDelete);
90254 +EXPORT_SYMBOL(FM_PCD_CcRootModifyNextEngine);
90255 +EXPORT_SYMBOL(FM_PCD_MatchTableModifyNextEngine);
90256 +EXPORT_SYMBOL(FM_PCD_MatchTableFindNModifyNextEngine);
90257 +EXPORT_SYMBOL(FM_PCD_MatchTableModifyMissNextEngine);
90258 +EXPORT_SYMBOL(FM_PCD_MatchTableRemoveKey);
90259 +EXPORT_SYMBOL(FM_PCD_MatchTableFindNRemoveKey);
90260 +EXPORT_SYMBOL(FM_PCD_MatchTableAddKey);
90261 +EXPORT_SYMBOL(FM_PCD_MatchTableModifyKeyAndNextEngine);
90262 +EXPORT_SYMBOL(FM_PCD_MatchTableFindNModifyKeyAndNextEngine);
90263 +EXPORT_SYMBOL(FM_PCD_MatchTableModifyKey);
90264 +EXPORT_SYMBOL(FM_PCD_MatchTableFindNModifyKey);
90265 +EXPORT_SYMBOL(FM_PCD_MatchTableGetIndexedHashBucket);
90266 +EXPORT_SYMBOL(FM_PCD_MatchTableGetNextEngine);
90267 +EXPORT_SYMBOL(FM_PCD_MatchTableGetKeyCounter);
90268 +EXPORT_SYMBOL(FM_PCD_MatchTableGetKeyStatistics);
90269 +EXPORT_SYMBOL(FM_PCD_MatchTableFindNGetKeyStatistics);
90270 +EXPORT_SYMBOL(FM_PCD_MatchTableGetMissStatistics);
90271 +EXPORT_SYMBOL(FM_PCD_HashTableGetMissStatistics);
90272 +EXPORT_SYMBOL(FM_PCD_HashTableSet);
90273 +EXPORT_SYMBOL(FM_PCD_HashTableDelete);
90274 +EXPORT_SYMBOL(FM_PCD_HashTableAddKey);
90275 +EXPORT_SYMBOL(FM_PCD_HashTableRemoveKey);
90276 +EXPORT_SYMBOL(FM_PCD_HashTableModifyNextEngine);
90277 +EXPORT_SYMBOL(FM_PCD_HashTableModifyMissNextEngine);
90278 +EXPORT_SYMBOL(FM_PCD_HashTableGetMissNextEngine);
90279 +EXPORT_SYMBOL(FM_PCD_HashTableFindNGetKeyStatistics);
90280 +EXPORT_SYMBOL(FM_PCD_PlcrProfileSet);
90281 +EXPORT_SYMBOL(FM_PCD_PlcrProfileDelete);
90282 +EXPORT_SYMBOL(FM_PCD_PlcrProfileGetCounter);
90283 +EXPORT_SYMBOL(FM_PCD_PlcrProfileSetCounter);
90284 +EXPORT_SYMBOL(FM_PCD_ManipNodeSet);
90285 +EXPORT_SYMBOL(FM_PCD_ManipNodeDelete);
90286 +EXPORT_SYMBOL(FM_PCD_ManipGetStatistics);
90287 +EXPORT_SYMBOL(FM_PCD_ManipNodeReplace);
90288 +#if (DPAA_VERSION >= 11)
90289 +EXPORT_SYMBOL(FM_PCD_FrmReplicSetGroup);
90290 +EXPORT_SYMBOL(FM_PCD_FrmReplicDeleteGroup);
90291 +EXPORT_SYMBOL(FM_PCD_FrmReplicAddMember);
90292 +EXPORT_SYMBOL(FM_PCD_FrmReplicRemoveMember);
90293 +#endif /* DPAA_VERSION >= 11 */
90294 +
90295 +#ifdef FM_CAPWAP_SUPPORT
90296 +EXPORT_SYMBOL(FM_PCD_StatisticsSetNode);
90297 +#endif /* FM_CAPWAP_SUPPORT */
90298 +
90299 +EXPORT_SYMBOL(FM_PCD_SetAdvancedOffloadSupport);
90300 +
90301 +/* FMAN MAC exported routines */
90302 +EXPORT_SYMBOL(FM_MAC_GetStatistics);
90303 +
90304 +EXPORT_SYMBOL(FM_GetSpecialOperationCoding);
90305 +
90306 +#endif /* __LNXWRP_EXP_SYM_H */
90307 --- /dev/null
90308 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fm_ext.h
90309 @@ -0,0 +1,163 @@
90310 +/*
90311 + * Copyright 2008-2012 Freescale Semiconductor Inc.
90312 + *
90313 + * Redistribution and use in source and binary forms, with or without
90314 + * modification, are permitted provided that the following conditions are met:
90315 + * * Redistributions of source code must retain the above copyright
90316 + * notice, this list of conditions and the following disclaimer.
90317 + * * Redistributions in binary form must reproduce the above copyright
90318 + * notice, this list of conditions and the following disclaimer in the
90319 + * documentation and/or other materials provided with the distribution.
90320 + * * Neither the name of Freescale Semiconductor nor the
90321 + * names of its contributors may be used to endorse or promote products
90322 + * derived from this software without specific prior written permission.
90323 + *
90324 + *
90325 + * ALTERNATIVELY, this software may be distributed under the terms of the
90326 + * GNU General Public License ("GPL") as published by the Free Software
90327 + * Foundation, either version 2 of that License or (at your option) any
90328 + * later version.
90329 + *
90330 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
90331 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
90332 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
90333 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
90334 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
90335 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
90336 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
90337 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
90338 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90339 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90340 + */
90341 +
90342 +/******************************************************************************
90343 + @File lnxwrp_fm_ext.h
90344 +
90345 + @Description TODO
90346 +*//***************************************************************************/
90347 +
90348 +#ifndef __LNXWRP_FM_EXT_H
90349 +#define __LNXWRP_FM_EXT_H
90350 +
90351 +#include "std_ext.h"
90352 +#include "sys_ext.h"
90353 +#include "fm_ext.h"
90354 +#include "fm_muram_ext.h"
90355 +#include "fm_pcd_ext.h"
90356 +#include "fm_port_ext.h"
90357 +#include "fm_mac_ext.h"
90358 +#include "fm_rtc_ext.h"
90359 +
90360 +
90361 +/**************************************************************************//**
90362 + @Group FM_LnxKern_grp Frame Manager Linux wrapper API
90363 +
90364 + @Description FM API functions, definitions and enums.
90365 +
90366 + @{
90367 +*//***************************************************************************/
90368 +
90369 +/**************************************************************************//**
90370 + @Group FM_LnxKern_init_grp Initialization Unit
90371 +
90372 + @Description Initialization Unit
90373 +
90374 + Initialization Flow:
90375 + Initialization of the FM Module will be carried out by the Linux
90376 + kernel according to the following sequence:
90377 + a. Calling the initialization routine with no parameters.
90378 + b. The driver will register to the Device-Tree.
90379 + c. The Linux Device-Tree will initiate a call to the driver for
90380 + initialization.
90381 + d. The driver will read the appropriate information from the Device-Tree
90382 + e. [Optional] Calling the advance initialization routines to change
90383 + driver's defaults.
90384 + f. Initialization of the device will be automatically upon using it.
90385 +
90386 + @{
90387 +*//***************************************************************************/
90388 +
90389 +typedef struct t_WrpFmDevSettings
90390 +{
90391 + t_FmParams param;
90392 + t_SysObjectAdvConfigEntry *advConfig;
90393 +} t_WrpFmDevSettings;
90394 +
90395 +typedef struct t_WrpFmPcdDevSettings
90396 +{
90397 + t_FmPcdParams param;
90398 + t_SysObjectAdvConfigEntry *advConfig;
90399 +} t_WrpFmPcdDevSettings;
90400 +
90401 +typedef struct t_WrpFmPortDevSettings
90402 +{
90403 + bool frag_enabled;
90404 + t_FmPortParams param;
90405 + t_SysObjectAdvConfigEntry *advConfig;
90406 +} t_WrpFmPortDevSettings;
90407 +
90408 +typedef struct t_WrpFmMacDevSettings
90409 +{
90410 + t_FmMacParams param;
90411 + t_SysObjectAdvConfigEntry *advConfig;
90412 +} t_WrpFmMacDevSettings;
90413 +
90414 +
90415 +/**************************************************************************//**
90416 + @Function LNXWRP_FM_Init
90417 +
90418 + @Description Initialize the FM linux wrapper.
90419 +
90420 + @Return A handle (descriptor) of the newly created FM Linux wrapper
90421 + structure.
90422 +*//***************************************************************************/
90423 +t_Handle LNXWRP_FM_Init(void);
90424 +
90425 +/**************************************************************************//**
90426 + @Function LNXWRP_FM_Free
90427 +
90428 + @Description Free the FM linux wrapper.
90429 +
90430 + @Param[in] h_LnxWrpFm - A handle to the FM linux wrapper.
90431 +
90432 + @Return E_OK on success; Error code otherwise.
90433 +*//***************************************************************************/
90434 +t_Error LNXWRP_FM_Free(t_Handle h_LnxWrpFm);
90435 +
90436 +/**************************************************************************//**
90437 + @Function LNXWRP_FM_GetMacHandle
90438 +
90439 + @Description Get the FM-MAC LLD handle from the FM linux wrapper.
90440 +
90441 + @Param[in] h_LnxWrpFm - A handle to the FM linux wrapper.
90442 + @Param[in] fmId - Index of the FM device to get the MAC handle from.
90443 + @Param[in] macId - Index of the mac handle.
90444 +
90445 + @Return A handle of the LLD compressor.
90446 +*//***************************************************************************/
90447 +t_Handle LNXWRP_FM_GetMacHandle(t_Handle h_LnxWrpFm, uint8_t fmId, uint8_t macId);
90448 +
90449 +#ifdef CONFIG_FSL_SDK_FMAN_TEST
90450 +t_Handle LNXWRP_FM_TEST_Init(void);
90451 +t_Error LNXWRP_FM_TEST_Free(t_Handle h_FmTestLnxWrp);
90452 +#endif /* CONFIG_FSL_SDK_FMAN_TEST */
90453 +
90454 +/** @} */ /* end of FM_LnxKern_init_grp group */
90455 +
90456 +
90457 +/**************************************************************************//**
90458 + @Group FM_LnxKern_ctrl_grp Control Unit
90459 +
90460 + @Description Control Unit
90461 +
90462 + TODO
90463 + @{
90464 +*//***************************************************************************/
90465 +
90466 +#include "lnxwrp_fsl_fman.h"
90467 +
90468 +/** @} */ /* end of FM_LnxKern_ctrl_grp group */
90469 +/** @} */ /* end of FM_LnxKern_grp group */
90470 +
90471 +
90472 +#endif /* __LNXWRP_FM_EXT_H */
90473 --- /dev/null
90474 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
90475 @@ -0,0 +1,919 @@
90476 +/*
90477 + * Copyright 2008-2012 Freescale Semiconductor Inc.
90478 + *
90479 + * Redistribution and use in source and binary forms, with or without
90480 + * modification, are permitted provided that the following conditions are met:
90481 + * * Redistributions of source code must retain the above copyright
90482 + * notice, this list of conditions and the following disclaimer.
90483 + * * Redistributions in binary form must reproduce the above copyright
90484 + * notice, this list of conditions and the following disclaimer in the
90485 + * documentation and/or other materials provided with the distribution.
90486 + * * Neither the name of Freescale Semiconductor nor the
90487 + * names of its contributors may be used to endorse or promote products
90488 + * derived from this software without specific prior written permission.
90489 + *
90490 + *
90491 + * ALTERNATIVELY, this software may be distributed under the terms of the
90492 + * GNU General Public License ("GPL") as published by the Free Software
90493 + * Foundation, either version 2 of that License or (at your option) any
90494 + * later version.
90495 + *
90496 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
90497 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
90498 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
90499 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
90500 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
90501 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
90502 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
90503 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
90504 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90505 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90506 + */
90507 +
90508 +/******************************************************************************
90509 + @File lnxwrp_fsl_fman.h
90510 +
90511 + @Description Linux internal kernel API
90512 +*//***************************************************************************/
90513 +
90514 +#ifndef __LNXWRP_FSL_FMAN_H
90515 +#define __LNXWRP_FSL_FMAN_H
90516 +
90517 +#include <linux/types.h>
90518 +#include <linux/device.h> /* struct device */
90519 +#include <linux/fsl_qman.h> /* struct qman_fq */
90520 +#include "dpaa_integration_ext.h"
90521 +#include "fm_port_ext.h"
90522 +#include "fm_mac_ext.h"
90523 +#include "fm_macsec_ext.h"
90524 +#include "fm_rtc_ext.h"
90525 +
90526 +/**************************************************************************//**
90527 + @Group FM_LnxKern_grp Frame Manager Linux wrapper API
90528 +
90529 + @Description FM API functions, definitions and enums.
90530 +
90531 + @{
90532 +*//***************************************************************************/
90533 +
90534 +/**************************************************************************//**
90535 + @Group FM_LnxKern_ctrl_grp Control Unit
90536 +
90537 + @Description Control Unit
90538 +
90539 + Internal Kernel Control Unit API
90540 + @{
90541 +*//***************************************************************************/
90542 +
90543 +/*****************************************************************************/
90544 +/* Internal Linux kernel routines */
90545 +/*****************************************************************************/
90546 +
90547 +/**************************************************************************//**
90548 + @Description MACSEC Exceptions wrapper
90549 +*//***************************************************************************/
90550 +typedef enum fm_macsec_exception {
90551 + SINGLE_BIT_ECC = e_FM_MACSEC_EX_SINGLE_BIT_ECC,
90552 + MULTI_BIT_ECC = e_FM_MACSEC_EX_MULTI_BIT_ECC
90553 +} fm_macsec_exception;
90554 +
90555 +/**************************************************************************//**
90556 + @Description Unknown sci frame treatment wrapper
90557 +*//***************************************************************************/
90558 +typedef enum fm_macsec_unknown_sci_frame_treatment {
90559 + SCI_DISCARD_BOTH = e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DISCARD_BOTH,
90560 + SCI_DISCARD_UNCTRL_DELIVER_DISCARD_CTRL = \
90561 + e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DISCARD_UNCONTROLLED_DELIVER_OR_DISCARD_CONTROLLED,
90562 + SCI_DELIVER_UNCTRL_DISCARD_CTRL = \
90563 + e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DELIVER_UNCONTROLLED_DISCARD_CONTROLLED,
90564 + SCI_DELIVER_DISCARD_UNCTRL_DELIVER_DISCARD_CTRL = \
90565 + e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DELIVER_OR_DISCARD_UNCONTROLLED_DELIVER_OR_DISCARD_CONTROLLED
90566 +} fm_macsec_unknown_sci_frame_treatment;
90567 +
90568 +/**************************************************************************//**
90569 + @Description Untag frame treatment wrapper
90570 +*//***************************************************************************/
90571 +typedef enum fm_macsec_untag_frame_treatment {
90572 + UNTAG_DELIVER_UNCTRL_DISCARD_CTRL = \
90573 + e_FM_MACSEC_UNTAG_FRAME_TREATMENT_DELIVER_UNCONTROLLED_DISCARD_CONTROLLED,
90574 + UNTAG_DISCARD_BOTH = e_FM_MACSEC_UNTAG_FRAME_TREATMENT_DISCARD_BOTH,
90575 + UNTAG_DISCARD_UNCTRL_DELIVER_CTRL_UNMODIFIED = \
90576 + e_FM_MACSEC_UNTAG_FRAME_TREATMENT_DISCARD_UNCONTROLLED_DELIVER_CONTROLLED_UNMODIFIED
90577 +} fm_macsec_untag_frame_treatment;
90578 +
90579 +/**************************************************************************//**
90580 +@Description MACSEC SECY Cipher Suite wrapper
90581 +*//***************************************************************************/
90582 +typedef enum fm_macsec_secy_cipher_suite {
90583 + SECY_GCM_AES_128 = e_FM_MACSEC_SECY_GCM_AES_128, /**< GCM-AES-128 */
90584 +#if (DPAA_VERSION >= 11)
90585 + SECY_GCM_AES_256 = e_FM_MACSEC_SECY_GCM_AES_256 /**< GCM-AES-256 */
90586 +#endif /* (DPAA_VERSION >= 11) */
90587 +} fm_macsec_secy_cipher_suite;
90588 +
90589 +/**************************************************************************//**
90590 + @Description MACSEC SECY Exceptions wrapper
90591 +*//***************************************************************************/
90592 +typedef enum fm_macsec_secy_exception {
90593 + SECY_EX_FRAME_DISCARDED = e_FM_MACSEC_SECY_EX_FRAME_DISCARDED
90594 +} fm_macsec_secy_exception;
90595 +
90596 +/**************************************************************************//**
90597 + @Description MACSEC SECY Events wrapper
90598 +*//***************************************************************************/
90599 +typedef enum fm_macsec_secy_event {
90600 + SECY_EV_NEXT_PN = e_FM_MACSEC_SECY_EV_NEXT_PN
90601 +} fm_macsec_secy_event;
90602 +
90603 +/**************************************************************************//**
90604 + @Description Valid frame behaviors wrapper
90605 +*//***************************************************************************/
90606 +typedef enum fm_macsec_valid_frame_behavior {
90607 + VALID_FRAME_BEHAVIOR_DISABLE = e_FM_MACSEC_VALID_FRAME_BEHAVIOR_DISABLE,
90608 + VALID_FRAME_BEHAVIOR_CHECK = e_FM_MACSEC_VALID_FRAME_BEHAVIOR_CHECK,
90609 + VALID_FRAME_BEHAVIOR_STRICT = e_FM_MACSEC_VALID_FRAME_BEHAVIOR_STRICT
90610 +} fm_macsec_valid_frame_behavior;
90611 +
90612 +/**************************************************************************//**
90613 + @Description SCI insertion modes wrapper
90614 +*//***************************************************************************/
90615 +typedef enum fm_macsec_sci_insertion_mode {
90616 + SCI_INSERTION_MODE_EXPLICIT_SECTAG = \
90617 + e_FM_MACSEC_SCI_INSERTION_MODE_EXPLICIT_SECTAG,
90618 + SCI_INSERTION_MODE_EXPLICIT_MAC_SA = \
90619 + e_FM_MACSEC_SCI_INSERTION_MODE_EXPLICIT_MAC_SA,
90620 + SCI_INSERTION_MODE_IMPLICT_PTP = e_FM_MACSEC_SCI_INSERTION_MODE_IMPLICT_PTP
90621 +} fm_macsec_sci_insertion_mode;
90622 +
90623 +typedef macsecSAKey_t macsec_sa_key_t;
90624 +typedef macsecSCI_t macsec_sci_t;
90625 +typedef macsecAN_t macsec_an_t;
90626 +typedef t_Handle handle_t;
90627 +
90628 +/**************************************************************************//**
90629 + @Function fm_macsec_secy_exception_callback wrapper
90630 + @Description Exceptions user callback routine, will be called upon an
90631 + exception passing the exception identification.
90632 + @Param[in] app_h A handle to an application layer object; This handle
90633 + will be passed by the driver upon calling this callback.
90634 + @Param[in] exception The exception.
90635 +*//***************************************************************************/
90636 +typedef void (fm_macsec_secy_exception_callback) (handle_t app_h,
90637 + fm_macsec_secy_exception exception);
90638 +
90639 +/**************************************************************************//**
90640 + @Function fm_macsec_secy_event_callback wrapper
90641 + @Description Events user callback routine, will be called upon an
90642 + event passing the event identification.
90643 + @Param[in] app_h A handle to an application layer object; This handle
90644 + will be passed by the driver upon calling this callback.
90645 + @Param[in] event The event.
90646 +*//***************************************************************************/
90647 +typedef void (fm_macsec_secy_event_callback) (handle_t app_h,
90648 + fm_macsec_secy_event event);
90649 +
90650 +/**************************************************************************//**
90651 + @Function fm_macsec_exception_callback wrapper
90652 + @Description Exceptions user callback routine, will be called upon an
90653 + exception passing the exception identification.
90654 + @Param[in] app_h A handle to an application layer object; This handle
90655 + will be passed by the driver upon calling this callback.
90656 + @Param[in] exception The exception.
90657 +*//***************************************************************************/
90658 +typedef void (fm_macsec_exception_callback) (handle_t app_h,
90659 + fm_macsec_exception exception);
90660 +
90661 +/**************************************************************************//**
90662 + @Description MACSEC SecY SC Params wrapper
90663 +*//***************************************************************************/
90664 +struct fm_macsec_secy_sc_params {
90665 + macsec_sci_t sci;
90666 + fm_macsec_secy_cipher_suite cipher_suite;
90667 +};
90668 +
90669 +/**************************************************************************//**
90670 + @Description FM MACSEC SecY config input wrapper
90671 +*//***************************************************************************/
90672 +struct fm_macsec_secy_params {
90673 + handle_t fm_macsec_h;
90674 + struct fm_macsec_secy_sc_params tx_sc_params;
90675 + uint32_t num_receive_channels;
90676 + fm_macsec_secy_exception_callback *exception_f;
90677 + fm_macsec_secy_event_callback *event_f;
90678 + handle_t app_h;
90679 +};
90680 +
90681 +/**************************************************************************//**
90682 + @Description FM MACSEC config input wrapper
90683 +*//***************************************************************************/
90684 +struct fm_macsec_params {
90685 + handle_t fm_h;
90686 + bool guest_mode;
90687 +
90688 + union {
90689 + struct {
90690 + uint8_t fm_mac_id;
90691 + } guest_params;
90692 +
90693 + struct {
90694 + uintptr_t base_addr;
90695 + handle_t fm_mac_h;
90696 + fm_macsec_exception_callback *exception_f;
90697 + handle_t app_h;
90698 + } non_guest_params;
90699 + };
90700 +
90701 +};
90702 +
90703 +/**************************************************************************//**
90704 + @Description FM device opaque structure used for type checking
90705 +*//***************************************************************************/
90706 +struct fm;
90707 +
90708 +/**************************************************************************//**
90709 + @Description FM MAC device opaque structure used for type checking
90710 +*//***************************************************************************/
90711 +struct fm_mac_dev;
90712 +
90713 +/**************************************************************************//**
90714 + @Description FM MACSEC device opaque structure used for type checking
90715 +*//***************************************************************************/
90716 +struct fm_macsec_dev;
90717 +struct fm_macsec_secy_dev;
90718 +
90719 +/**************************************************************************//**
90720 + @Description A structure ..,
90721 +*//***************************************************************************/
90722 +struct fm_port;
90723 +
90724 +typedef int (*alloc_pcd_fqids)(struct device *dev, uint32_t num,
90725 + uint8_t alignment, uint32_t *base_fqid);
90726 +
90727 +typedef int (*free_pcd_fqids)(struct device *dev, uint32_t base_fqid);
90728 +
90729 +struct fm_port_pcd_param {
90730 + alloc_pcd_fqids cba;
90731 + free_pcd_fqids cbf;
90732 + struct device *dev;
90733 +};
90734 +
90735 +/**************************************************************************//**
90736 + @Description A structure of information about each of the external
90737 + buffer pools used by the port,
90738 +*//***************************************************************************/
90739 +struct fm_port_pool_param {
90740 + uint8_t id; /**< External buffer pool id */
90741 + uint16_t size; /**< External buffer pool buffer size */
90742 +};
90743 +
90744 +/**************************************************************************//**
90745 + @Description structure for additional port parameters
90746 +*//***************************************************************************/
90747 +struct fm_port_params {
90748 + uint32_t errq; /**< Error Queue Id. */
90749 + uint32_t defq; /**< For Tx and HC - Default Confirmation queue,
90750 + 0 means no Tx conf for processed frames.
90751 + For Rx and OP - default Rx queue. */
90752 + uint8_t num_pools; /**< Number of pools use by this port */
90753 + struct fm_port_pool_param pool_param[FM_PORT_MAX_NUM_OF_EXT_POOLS];
90754 + /**< Parameters for each pool */
90755 + uint16_t priv_data_size; /**< Area that user may save for his own
90756 + need (E.g. save the SKB) */
90757 + bool parse_results; /**< Put the parser-results in the Rx/Tx buffer */
90758 + bool hash_results; /**< Put the hash-results in the Rx/Tx buffer */
90759 + bool time_stamp; /**< Put the time-stamp in the Rx/Tx buffer */
90760 + bool frag_enable; /**< Fragmentation support, for OP only */
90761 + uint16_t data_align; /**< value for selecting a data alignment (must be a power of 2);
90762 + if write optimization is used, must be >= 16. */
90763 + uint8_t manip_extra_space; /**< Maximum extra size needed (insertion-size minus removal-size);
90764 + Note that this field impacts the size of the buffer-prefix
90765 + (i.e. it pushes the data offset); */
90766 +};
90767 +
90768 +/**************************************************************************//**
90769 + @Function fm_bind
90770 +
90771 + @Description Bind to a specific FM device.
90772 +
90773 + @Param[in] fm_dev - the OF handle of the FM device.
90774 +
90775 + @Return A handle of the FM device.
90776 +
90777 + @Cautions Allowed only after the port was created.
90778 +*//***************************************************************************/
90779 +struct fm *fm_bind(struct device *fm_dev);
90780 +
90781 +/**************************************************************************//**
90782 + @Function fm_unbind
90783 +
90784 + @Description Un-bind from a specific FM device.
90785 +
90786 + @Param[in] fm - A handle of the FM device.
90787 +
90788 + @Cautions Allowed only after the port was created.
90789 +*//***************************************************************************/
90790 +void fm_unbind(struct fm *fm);
90791 +
90792 +void *fm_get_handle(struct fm *fm);
90793 +void *fm_get_rtc_handle(struct fm *fm);
90794 +struct resource *fm_get_mem_region(struct fm *fm);
90795 +
90796 +/**************************************************************************//**
90797 + @Function fm_port_bind
90798 +
90799 + @Description Bind to a specific FM-port device (may be Rx or Tx port).
90800 +
90801 + @Param[in] fm_port_dev - the OF handle of the FM port device.
90802 +
90803 + @Return A handle of the FM port device.
90804 +
90805 + @Cautions Allowed only after the port was created.
90806 +*//***************************************************************************/
90807 +struct fm_port *fm_port_bind(struct device *fm_port_dev);
90808 +
90809 +/**************************************************************************//**
90810 + @Function fm_port_unbind
90811 +
90812 + @Description Un-bind from a specific FM-port device (may be Rx or Tx port).
90813 +
90814 + @Param[in] port - A handle of the FM port device.
90815 +
90816 + @Cautions Allowed only after the port was created.
90817 +*//***************************************************************************/
90818 +void fm_port_unbind(struct fm_port *port);
90819 +
90820 +/**************************************************************************//**
90821 + @Function fm_set_rx_port_params
90822 +
90823 + @Description Configure parameters for a specific Rx FM-port device.
90824 +
90825 + @Param[in] port - A handle of the FM port device.
90826 + @Param[in] params - Rx port parameters
90827 +
90828 + @Cautions Allowed only after the port is binded.
90829 +*//***************************************************************************/
90830 +void fm_set_rx_port_params(struct fm_port *port,
90831 + struct fm_port_params *params);
90832 +
90833 +/**************************************************************************//**
90834 + @Function fm_port_pcd_bind
90835 +
90836 + @Description Bind as a listener on a port PCD.
90837 +
90838 + @Param[in] port - A handle of the FM port device.
90839 + @Param[in] params - PCD port parameters
90840 +
90841 + @Cautions Allowed only after the port is binded.
90842 +*//***************************************************************************/
90843 +void fm_port_pcd_bind (struct fm_port *port, struct fm_port_pcd_param *params);
90844 +
90845 +/**************************************************************************//**
90846 + @Function fm_port_get_buff_layout_ext_params
90847 +
90848 + @Description Get data_align and manip_extra_space from the device tree
90849 + chosen node if applied.
90850 + This function will only update these two parameters.
90851 + When this port has no such parameters in the device tree
90852 + values will be set to 0.
90853 +
90854 + @Param[in] port - A handle of the FM port device.
90855 + @Param[in] params - PCD port parameters
90856 +
90857 + @Cautions Allowed only after the port is binded.
90858 +*//***************************************************************************/
90859 +void fm_port_get_buff_layout_ext_params(struct fm_port *port, struct fm_port_params *params);
90860 +
90861 +/**************************************************************************//**
90862 + @Function fm_get_tx_port_channel
90863 +
90864 + @Description Get qman-channel number for this Tx port.
90865 +
90866 + @Param[in] port - A handle of the FM port device.
90867 +
90868 + @Return qman-channel number for this Tx port.
90869 +
90870 + @Cautions Allowed only after the port is binded.
90871 +*//***************************************************************************/
90872 +uint16_t fm_get_tx_port_channel(struct fm_port *port);
90873 +
90874 +/**************************************************************************//**
90875 + @Function fm_set_tx_port_params
90876 +
90877 + @Description Configure parameters for a specific Tx FM-port device
90878 +
90879 + @Param[in] port - A handle of the FM port device.
90880 + @Param[in] params - Tx port parameters
90881 +
90882 + @Cautions Allowed only after the port is binded.
90883 +*//***************************************************************************/
90884 +void fm_set_tx_port_params(struct fm_port *port, struct fm_port_params *params);
90885 +
90886 +
90887 +/**************************************************************************//**
90888 + @Function fm_mac_set_handle
90889 +
90890 + @Description Set mac handle
90891 +
90892 + @Param[in] h_lnx_wrp_fm_dev - A handle of the LnxWrp FM device.
90893 + @Param[in] h_fm_mac - A handle of the LnxWrp FM MAC device.
90894 + @Param[in] mac_id - MAC id.
90895 +*//***************************************************************************/
90896 +void fm_mac_set_handle(t_Handle h_lnx_wrp_fm_dev, t_Handle h_fm_mac,
90897 + int mac_id);
90898 +
90899 +/**************************************************************************//**
90900 + @Function fm_port_enable
90901 +
90902 + @Description Enable specific FM-port device (may be Rx or Tx port).
90903 +
90904 + @Param[in] port - A handle of the FM port device.
90905 +
90906 + @Cautions Allowed only after the port is initialized.
90907 +*//***************************************************************************/
90908 +int fm_port_enable(struct fm_port *port);
90909 +
90910 +/**************************************************************************//**
90911 + @Function fm_port_disable
90912 +
90913 + @Description Disable specific FM-port device (may be Rx or Tx port).
90914 +
90915 + @Param[in] port - A handle of the FM port device.
90916 +
90917 + @Cautions Allowed only after the port is initialized.
90918 +*//***************************************************************************/
90919 +int fm_port_disable(struct fm_port *port);
90920 +
90921 +void *fm_port_get_handle(const struct fm_port *port);
90922 +
90923 +u64 *fm_port_get_buffer_time_stamp(const struct fm_port *port,
90924 + const void *data);
90925 +
90926 +/**************************************************************************//**
90927 + @Function fm_port_get_base_address
90928 +
90929 + @Description Get base address of this port. Useful for accessing
90930 + port-specific registers (i.e., not common ones).
90931 +
90932 + @Param[in] port - A handle of the FM port device.
90933 +
90934 + @Param[out] base_addr - The port's base addr (virtual address).
90935 +*//***************************************************************************/
90936 +void fm_port_get_base_addr(const struct fm_port *port, uint64_t *base_addr);
90937 +
90938 +/**************************************************************************//**
90939 + @Function fm_mutex_lock
90940 +
90941 + @Description Lock function required before any FMD/LLD call.
90942 +*//***************************************************************************/
90943 +void fm_mutex_lock(void);
90944 +
90945 +/**************************************************************************//**
90946 + @Function fm_mutex_unlock
90947 +
90948 + @Description Unlock function required after any FMD/LLD call.
90949 +*//***************************************************************************/
90950 +void fm_mutex_unlock(void);
90951 +
90952 +/**************************************************************************//**
90953 + @Function fm_get_max_frm
90954 +
90955 + @Description Get the maximum frame size
90956 +*//***************************************************************************/
90957 +int fm_get_max_frm(void);
90958 +
90959 +/**************************************************************************//**
90960 + @Function fm_get_rx_extra_headroom
90961 +
90962 + @Description Get the extra headroom size
90963 +*//***************************************************************************/
90964 +int fm_get_rx_extra_headroom(void);
90965 +
90966 +/**************************************************************************//**
90967 +@Function fm_port_set_rate_limit
90968 +
90969 +@Description Configure Shaper parameter on FM-port device (Tx port).
90970 +
90971 +@Param[in] port - A handle of the FM port device.
90972 +@Param[in] max_burst_size - Value of maximum burst size allowed.
90973 +@Param[in] rate_limit - The required rate value.
90974 +
90975 +@Cautions Allowed only after the port is initialized.
90976 +*//***************************************************************************/
90977 +int fm_port_set_rate_limit(struct fm_port *port,
90978 + uint16_t max_burst_size,
90979 + uint32_t rate_limit);
90980 +/**************************************************************************//**
90981 +@Function fm_port_set_rate_limit
90982 +
90983 +@Description Delete Shaper configuration on FM-port device (Tx port).
90984 +
90985 +@Param[in] port - A handle of the FM port device.
90986 +
90987 +@Cautions Allowed only after the port is initialized.
90988 +*//***************************************************************************/
90989 +int fm_port_del_rate_limit(struct fm_port *port);
90990 +
90991 +struct auto_res_tables_sizes
90992 +{
90993 + uint16_t max_num_of_arp_entries;
90994 + uint16_t max_num_of_echo_ipv4_entries;
90995 + uint16_t max_num_of_ndp_entries;
90996 + uint16_t max_num_of_echo_ipv6_entries;
90997 + uint16_t max_num_of_snmp_ipv4_entries;
90998 + uint16_t max_num_of_snmp_ipv6_entries;
90999 + uint16_t max_num_of_snmp_oid_entries;
91000 + uint16_t max_num_of_snmp_char; /* total amount of character needed
91001 + for the snmp table */
91002 + uint16_t max_num_of_ip_prot_filtering;
91003 + uint16_t max_num_of_tcp_port_filtering;
91004 + uint16_t max_num_of_udp_port_filtering;
91005 +};
91006 +/* ARP */
91007 +struct auto_res_arp_entry
91008 +{
91009 + uint32_t ip_address;
91010 + uint8_t mac[6];
91011 + bool is_vlan;
91012 + uint16_t vid;
91013 +};
91014 +struct auto_res_arp_info
91015 +{
91016 + uint8_t table_size;
91017 + struct auto_res_arp_entry *auto_res_table;
91018 + bool enable_conflict_detection; /* when TRUE
91019 + Conflict Detection will be checked and wake the host if
91020 + needed */
91021 +};
91022 +
91023 +/* NDP */
91024 +struct auto_res_ndp_entry
91025 +{
91026 + uint32_t ip_address[4];
91027 + uint8_t mac[6];
91028 + bool is_vlan;
91029 + uint16_t vid;
91030 +};
91031 +struct auto_res_ndp_info
91032 +{
91033 + uint32_t multicast_group;
91034 + uint8_t table_size_assigned;
91035 + struct auto_res_ndp_entry *auto_res_table_assigned; /* This list
91036 + refer to solicitation IP addresses. Note that all IP adresses
91037 + must be from the same multicast group. This will be checked and
91038 + if not operation will fail. */
91039 + uint8_t table_size_tmp;
91040 + struct auto_res_ndp_entry *auto_res_table_tmp; /* This list
91041 + refer to temp IP addresses. Note that all temp IP adresses must
91042 + be from the same multicast group. This will be checked and if
91043 + not operation will fail. */
91044 +
91045 + bool enable_conflict_detection; /* when TRUE
91046 + Conflict Detection will be checked and wake the host if
91047 + needed */
91048 +};
91049 +
91050 +/* ICMP ECHO */
91051 +struct auto_res_echo_ipv4_info
91052 +{
91053 + uint8_t table_size;
91054 + struct auto_res_arp_entry *auto_res_table;
91055 +};
91056 +
91057 +struct auto_res_echo_ipv6_info
91058 +{
91059 + uint8_t table_size;
91060 + struct auto_res_ndp_entry *auto_res_table;
91061 +};
91062 +
91063 +/* SNMP */
91064 +struct auto_res_snmp_entry
91065 +{
91066 + uint16_t oidSize;
91067 + uint8_t *oidVal; /* only the oid string */
91068 + uint16_t resSize;
91069 + uint8_t *resVal; /* resVal will be the entire reply,
91070 + i.e. "Type|Length|Value" */
91071 +};
91072 +
91073 +/**************************************************************************//**
91074 + @Description Deep Sleep Auto Response SNMP IPv4 Addresses Table Entry
91075 + Refer to the FMan Controller spec for more details.
91076 +*//***************************************************************************/
91077 +struct auto_res_snmp_ipv4addr_tbl_entry
91078 +{
91079 + uint32_t ipv4addr; /*!< 32 bit IPv4 Address. */
91080 + bool is_vlan;
91081 + uint16_t vid; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
91082 + /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
91083 +};
91084 +
91085 +/**************************************************************************//**
91086 + @Description Deep Sleep Auto Response SNMP IPv6 Addresses Table Entry
91087 + Refer to the FMan Controller spec for more details.
91088 +*//***************************************************************************/
91089 +struct auto_res_snmp_ipv6addr_tbl_entry
91090 +{
91091 + uint32_t ipv6Addr[4]; /*!< 4 * 32 bit IPv6 Address. */
91092 + bool isVlan;
91093 + uint16_t vid; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
91094 + /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
91095 +};
91096 +
91097 +struct auto_res_snmp_info
91098 +{
91099 + uint16_t control; /**< Control bits [0-15]. */
91100 + uint16_t max_snmp_msg_length; /**< Maximal allowed SNMP message length. */
91101 + uint16_t num_ipv4_addresses; /**< Number of entries in IPv4 addresses table. */
91102 + uint16_t num_ipv6_addresses; /**< Number of entries in IPv6 addresses table. */
91103 + struct auto_res_snmp_ipv4addr_tbl_entry *ipv4addr_tbl; /**< Pointer to IPv4 addresses table. */
91104 + struct auto_res_snmp_ipv6addr_tbl_entry *ipv6addr_tbl; /**< Pointer to IPv6 addresses table. */
91105 + char *community_read_write_string;
91106 + char *community_read_only_string;
91107 + struct auto_res_snmp_entry *oid_table;
91108 + uint32_t oid_table_size;
91109 + uint32_t *statistics;
91110 +};
91111 +
91112 +/* Filtering */
91113 +struct auto_res_port_filtering_entry
91114 +{
91115 + uint16_t src_port;
91116 + uint16_t dst_port;
91117 + uint16_t src_port_mask;
91118 + uint16_t dst_port_mask;
91119 +};
91120 +struct auto_res_filtering_info
91121 +{
91122 + /* IP protocol filtering parameters */
91123 + uint8_t ip_prot_table_size;
91124 + uint8_t *ip_prot_table_ptr;
91125 + bool ip_prot_pass_on_hit; /* when TRUE, miss in the table will
91126 + cause the packet to be droped, hit will pass the packet to
91127 + UDP/TCP filters if needed and if not to the classification
91128 + tree. If the classification tree will pass the packet to a
91129 + queue it will cause a wake interupt. When FALSE it the other
91130 + way around. */
91131 + /* UDP port filtering parameters */
91132 + uint8_t udp_ports_table_size;
91133 + struct auto_res_port_filtering_entry *udp_ports_table_ptr;
91134 + bool udp_port_pass_on_hit; /* when TRUE, miss in the table will
91135 + cause the packet to be droped, hit will pass the packet to
91136 + classification tree. If the classification tree will pass the
91137 + packet to a queue it will cause a wake interupt. When FALSE it
91138 + the other way around. */
91139 + /* TCP port filtering parameters */
91140 + uint16_t tcp_flags_mask;
91141 + uint8_t tcp_ports_table_size;
91142 + struct auto_res_port_filtering_entry *tcp_ports_table_ptr;
91143 + bool tcp_port_pass_on_hit; /* when TRUE, miss in the table will
91144 + cause the packet to be droped, hit will pass the packet to
91145 + classification tree. If the classification tree will pass the
91146 + packet to a queue it will cause a wake interupt. When FALSE it
91147 + the other way around. */
91148 +};
91149 +
91150 +struct auto_res_port_params
91151 +{
91152 + t_Handle h_FmPortTx;
91153 + struct auto_res_arp_info *p_auto_res_arp_info;
91154 + struct auto_res_echo_ipv4_info *p_auto_res_echo_ipv4_info;
91155 + struct auto_res_ndp_info *p_auto_res_ndp_info;
91156 + struct auto_res_echo_ipv6_info *p_auto_res_echo_ipv6_info;
91157 + struct auto_res_snmp_info *p_auto_res_snmp_info;
91158 + struct auto_res_filtering_info *p_auto_res_filtering_info;
91159 +};
91160 +
91161 +struct auto_res_port_stats
91162 +{
91163 + uint32_t arp_ar_cnt;
91164 + uint32_t echo_icmpv4_ar_cnt;
91165 + uint32_t ndp_ar_cnt;
91166 + uint32_t echo_icmpv6_ar_cnt;
91167 +};
91168 +
91169 +int fm_port_config_autores_for_deepsleep_support(struct fm_port *port,
91170 + struct auto_res_tables_sizes *params);
91171 +
91172 +int fm_port_enter_autores_for_deepsleep(struct fm_port *port,
91173 + struct auto_res_port_params *params);
91174 +
91175 +void fm_port_exit_auto_res_for_deep_sleep(struct fm_port *port_rx,
91176 + struct fm_port *port_tx);
91177 +
91178 +bool fm_port_is_in_auto_res_mode(struct fm_port *port);
91179 +
91180 +struct auto_res_tables_sizes *fm_port_get_autores_maxsize(
91181 + struct fm_port *port);
91182 +
91183 +int fm_port_get_autores_stats(struct fm_port *port, struct auto_res_port_stats
91184 + *stats);
91185 +
91186 +int fm_port_resume(struct fm_port *port);
91187 +
91188 +int fm_port_suspend(struct fm_port *port);
91189 +
91190 +#ifdef CONFIG_FMAN_PFC
91191 +/**************************************************************************//**
91192 +@Function fm_port_set_pfc_priorities_mapping_to_qman_wq
91193 +
91194 +@Description Associate a QMan Work Queue with a PFC priority on this
91195 + FM-port device (Tx port).
91196 +
91197 +@Param[in] port - A handle of the FM port device.
91198 +
91199 +@Param[in] prio - The PFC priority.
91200 +
91201 +@Param[in] wq - The Work Queue associated with the PFC priority.
91202 +
91203 +@Cautions Allowed only after the port is initialized.
91204 +*//***************************************************************************/
91205 +int fm_port_set_pfc_priorities_mapping_to_qman_wq(struct fm_port *port,
91206 + uint8_t prio, uint8_t wq);
91207 +#endif
91208 +
91209 +/**************************************************************************//**
91210 +@Function fm_mac_set_exception
91211 +
91212 +@Description Set MAC exception state.
91213 +
91214 +@Param[in] fm_mac_dev - A handle of the FM MAC device.
91215 +@Param[in] exception - FM MAC exception type.
91216 +@Param[in] enable - new state.
91217 +
91218 +*//***************************************************************************/
91219 +int fm_mac_set_exception(struct fm_mac_dev *fm_mac_dev,
91220 + e_FmMacExceptions exception, bool enable);
91221 +
91222 +int fm_mac_free(struct fm_mac_dev *fm_mac_dev);
91223 +
91224 +struct fm_mac_dev *fm_mac_config(t_FmMacParams *params);
91225 +
91226 +int fm_mac_config_max_frame_length(struct fm_mac_dev *fm_mac_dev,
91227 + int len);
91228 +
91229 +int fm_mac_config_pad_and_crc(struct fm_mac_dev *fm_mac_dev, bool enable);
91230 +
91231 +int fm_mac_config_half_duplex(struct fm_mac_dev *fm_mac_dev, bool enable);
91232 +
91233 +int fm_mac_config_reset_on_init(struct fm_mac_dev *fm_mac_dev, bool enable);
91234 +
91235 +int fm_mac_init(struct fm_mac_dev *fm_mac_dev);
91236 +
91237 +int fm_mac_get_version(struct fm_mac_dev *fm_mac_dev, uint32_t *version);
91238 +
91239 +int fm_mac_enable(struct fm_mac_dev *fm_mac_dev);
91240 +
91241 +int fm_mac_disable(struct fm_mac_dev *fm_mac_dev);
91242 +
91243 +int fm_mac_set_promiscuous(struct fm_mac_dev *fm_mac_dev,
91244 + bool enable);
91245 +
91246 +int fm_mac_remove_hash_mac_addr(struct fm_mac_dev *fm_mac_dev,
91247 + t_EnetAddr *mac_addr);
91248 +
91249 +int fm_mac_add_hash_mac_addr(struct fm_mac_dev *fm_mac_dev,
91250 + t_EnetAddr *mac_addr);
91251 +
91252 +int fm_mac_modify_mac_addr(struct fm_mac_dev *fm_mac_dev,
91253 + uint8_t *addr);
91254 +
91255 +int fm_mac_adjust_link(struct fm_mac_dev *fm_mac_dev,
91256 + bool link, int speed, bool duplex);
91257 +
91258 +int fm_mac_enable_1588_time_stamp(struct fm_mac_dev *fm_mac_dev);
91259 +
91260 +int fm_mac_disable_1588_time_stamp(struct fm_mac_dev *fm_mac_dev);
91261 +
91262 +int fm_mac_set_rx_pause_frames(
91263 + struct fm_mac_dev *fm_mac_dev, bool en);
91264 +
91265 +int fm_mac_set_tx_pause_frames(struct fm_mac_dev *fm_mac_dev,
91266 + bool en);
91267 +
91268 +int fm_rtc_enable(struct fm *fm_dev);
91269 +
91270 +int fm_rtc_disable(struct fm *fm_dev);
91271 +
91272 +int fm_rtc_get_cnt(struct fm *fm_dev, uint64_t *ts);
91273 +
91274 +int fm_rtc_set_cnt(struct fm *fm_dev, uint64_t ts);
91275 +
91276 +int fm_rtc_get_drift(struct fm *fm_dev, uint32_t *drift);
91277 +
91278 +int fm_rtc_set_drift(struct fm *fm_dev, uint32_t drift);
91279 +
91280 +int fm_rtc_set_alarm(struct fm *fm_dev, uint32_t id,
91281 + uint64_t time);
91282 +
91283 +int fm_rtc_set_fiper(struct fm *fm_dev, uint32_t id,
91284 + uint64_t fiper);
91285 +
91286 +int fm_mac_set_wol(struct fm_port *port, struct fm_mac_dev *fm_mac_dev,
91287 + bool en);
91288 +
91289 +/**************************************************************************//**
91290 +@Function fm_macsec_set_exception
91291 +
91292 +@Description Set MACSEC exception state.
91293 +
91294 +@Param[in] fm_macsec_dev - A handle of the FM MACSEC device.
91295 +@Param[in] exception - FM MACSEC exception type.
91296 +@Param[in] enable - new state.
91297 +
91298 +*//***************************************************************************/
91299 +
91300 +int fm_macsec_set_exception(struct fm_macsec_dev *fm_macsec_dev,
91301 + fm_macsec_exception exception, bool enable);
91302 +int fm_macsec_free(struct fm_macsec_dev *fm_macsec_dev);
91303 +struct fm_macsec_dev *fm_macsec_config(struct fm_macsec_params *fm_params);
91304 +int fm_macsec_init(struct fm_macsec_dev *fm_macsec_dev);
91305 +int fm_macsec_config_unknown_sci_frame_treatment(struct fm_macsec_dev
91306 + *fm_macsec_dev,
91307 + fm_macsec_unknown_sci_frame_treatment treat_mode);
91308 +int fm_macsec_config_invalid_tags_frame_treatment(struct fm_macsec_dev *fm_macsec_dev,
91309 + bool deliver_uncontrolled);
91310 +int fm_macsec_config_kay_frame_treatment(struct fm_macsec_dev *fm_macsec_dev,
91311 + bool discard_uncontrolled);
91312 +int fm_macsec_config_untag_frame_treatment(struct fm_macsec_dev *fm_macsec_dev,
91313 + fm_macsec_untag_frame_treatment treat_mode);
91314 +int fm_macsec_config_pn_exhaustion_threshold(struct fm_macsec_dev *fm_macsec_dev,
91315 + uint32_t pnExhThr);
91316 +int fm_macsec_config_keys_unreadable(struct fm_macsec_dev *fm_macsec_dev);
91317 +int fm_macsec_config_sectag_without_sci(struct fm_macsec_dev *fm_macsec_dev);
91318 +int fm_macsec_config_exception(struct fm_macsec_dev *fm_macsec_dev,
91319 + fm_macsec_exception exception, bool enable);
91320 +int fm_macsec_get_revision(struct fm_macsec_dev *fm_macsec_dev,
91321 + int *macsec_revision);
91322 +int fm_macsec_enable(struct fm_macsec_dev *fm_macsec_dev);
91323 +int fm_macsec_disable(struct fm_macsec_dev *fm_macsec_dev);
91324 +
91325 +
91326 +int fm_macsec_secy_config_exception(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91327 + fm_macsec_secy_exception exception,
91328 + bool enable);
91329 +int fm_macsec_secy_free(struct fm_macsec_secy_dev *fm_macsec_secy_dev);
91330 +struct fm_macsec_secy_dev *fm_macsec_secy_config(struct fm_macsec_secy_params *secy_params);
91331 +int fm_macsec_secy_init(struct fm_macsec_secy_dev *fm_macsec_secy_dev);
91332 +int fm_macsec_secy_config_sci_insertion_mode(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91333 + fm_macsec_sci_insertion_mode sci_insertion_mode);
91334 +int fm_macsec_secy_config_protect_frames(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91335 + bool protect_frames);
91336 +int fm_macsec_secy_config_replay_window(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91337 + bool replay_protect, uint32_t replay_window);
91338 +int fm_macsec_secy_config_validation_mode(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91339 + fm_macsec_valid_frame_behavior validate_frames);
91340 +int fm_macsec_secy_config_confidentiality(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91341 + bool confidentiality_enable,
91342 + uint32_t confidentiality_offset);
91343 +int fm_macsec_secy_config_point_to_point(struct fm_macsec_secy_dev *fm_macsec_secy_dev);
91344 +int fm_macsec_secy_config_event(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91345 + fm_macsec_secy_event event,
91346 + bool enable);
91347 +struct rx_sc_dev *fm_macsec_secy_create_rxsc(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91348 + struct fm_macsec_secy_sc_params *params);
91349 +int fm_macsec_secy_delete_rxsc(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91350 + struct rx_sc_dev *sc);
91351 +int fm_macsec_secy_create_rx_sa(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91352 + struct rx_sc_dev *sc, macsec_an_t an,
91353 + uint32_t lowest_pn, macsec_sa_key_t key);
91354 +int fm_macsec_secy_delete_rx_sa(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91355 + struct rx_sc_dev *sc, macsec_an_t an);
91356 +int fm_macsec_secy_rxsa_enable_receive(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91357 + struct rx_sc_dev *sc,
91358 + macsec_an_t an);
91359 +int fm_macsec_secy_rxsa_disable_receive(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91360 + struct rx_sc_dev *sc,
91361 + macsec_an_t an);
91362 +int fm_macsec_secy_rxsa_update_next_pn(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91363 + struct rx_sc_dev *sc,
91364 + macsec_an_t an, uint32_t updt_next_pn);
91365 +int fm_macsec_secy_rxsa_update_lowest_pn(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91366 + struct rx_sc_dev *sc,
91367 + macsec_an_t an, uint32_t updt_lowest_pn);
91368 +int fm_macsec_secy_rxsa_modify_key(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91369 + struct rx_sc_dev *sc,
91370 + macsec_an_t an, macsec_sa_key_t key);
91371 +int fm_macsec_secy_create_tx_sa(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91372 + macsec_an_t an, macsec_sa_key_t key);
91373 +int fm_macsec_secy_delete_tx_sa(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91374 + macsec_an_t an);
91375 +int fm_macsec_secy_txsa_modify_key(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91376 + macsec_an_t next_active_an,
91377 + macsec_sa_key_t key);
91378 +int fm_macsec_secy_txsa_set_active(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91379 + macsec_an_t an);
91380 +int fm_macsec_secy_txsa_get_active(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91381 + macsec_an_t *p_an);
91382 +int fm_macsec_secy_get_rxsc_phys_id(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91383 + struct rx_sc_dev *sc, uint32_t *sc_phys_id);
91384 +int fm_macsec_secy_get_txsc_phys_id(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
91385 + uint32_t *sc_phys_id);
91386 +
91387 +/** @} */ /* end of FM_LnxKern_ctrl_grp group */
91388 +/** @} */ /* end of FM_LnxKern_grp group */
91389 +
91390 +/* default values for initializing PTP 1588 timer clock */
91391 +#define DPA_PTP_NOMINAL_FREQ_PERIOD_SHIFT 2 /* power of 2 for better performance */
91392 +#define DPA_PTP_NOMINAL_FREQ_PERIOD_NS (1 << DPA_PTP_NOMINAL_FREQ_PERIOD_SHIFT) /* 4ns,250MHz */
91393 +
91394 +#endif /* __LNXWRP_FSL_FMAN_H */
91395 --- /dev/null
91396 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/xx/xx.h
91397 @@ -0,0 +1,50 @@
91398 +/*
91399 + * Copyright 2008-2012 Freescale Semiconductor Inc.
91400 + *
91401 + * Redistribution and use in source and binary forms, with or without
91402 + * modification, are permitted provided that the following conditions are met:
91403 + * * Redistributions of source code must retain the above copyright
91404 + * notice, this list of conditions and the following disclaimer.
91405 + * * Redistributions in binary form must reproduce the above copyright
91406 + * notice, this list of conditions and the following disclaimer in the
91407 + * documentation and/or other materials provided with the distribution.
91408 + * * Neither the name of Freescale Semiconductor nor the
91409 + * names of its contributors may be used to endorse or promote products
91410 + * derived from this software without specific prior written permission.
91411 + *
91412 + *
91413 + * ALTERNATIVELY, this software may be distributed under the terms of the
91414 + * GNU General Public License ("GPL") as published by the Free Software
91415 + * Foundation, either version 2 of that License or (at your option) any
91416 + * later version.
91417 + *
91418 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
91419 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
91420 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
91421 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
91422 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
91423 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
91424 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
91425 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
91426 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
91427 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
91428 + */
91429 +
91430 +#ifndef __XX_H
91431 +#define __XX_H
91432 +
91433 +#include "xx_ext.h"
91434 +
91435 +void * xx_Malloc(uint32_t n);
91436 +void xx_Free(void *p);
91437 +
91438 +void *xx_MallocSmart(uint32_t size, int memPartitionId, uint32_t align);
91439 +void xx_FreeSmart(void *p);
91440 +
91441 +/* never used: */
91442 +#define GetDeviceName(irq) ((char *)NULL)
91443 +
91444 +int GetDeviceIrqNum(int irq);
91445 +
91446 +
91447 +#endif /* __XX_H */
91448 --- /dev/null
91449 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/system/Makefile
91450 @@ -0,0 +1,10 @@
91451 +#
91452 +# Makefile for the Freescale Ethernet controllers
91453 +#
91454 +ccflags-y += -DVERSION=\"\"
91455 +#
91456 +#Include netcomm SW specific definitions
91457 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
91458 +#
91459 +
91460 +obj-y += sys_io.o
91461 --- /dev/null
91462 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/system/sys_io.c
91463 @@ -0,0 +1,171 @@
91464 +/*
91465 + * Copyright 2008-2012 Freescale Semiconductor Inc.
91466 + *
91467 + * Redistribution and use in source and binary forms, with or without
91468 + * modification, are permitted provided that the following conditions are met:
91469 + * * Redistributions of source code must retain the above copyright
91470 + * notice, this list of conditions and the following disclaimer.
91471 + * * Redistributions in binary form must reproduce the above copyright
91472 + * notice, this list of conditions and the following disclaimer in the
91473 + * documentation and/or other materials provided with the distribution.
91474 + * * Neither the name of Freescale Semiconductor nor the
91475 + * names of its contributors may be used to endorse or promote products
91476 + * derived from this software without specific prior written permission.
91477 + *
91478 + *
91479 + * ALTERNATIVELY, this software may be distributed under the terms of the
91480 + * GNU General Public License ("GPL") as published by the Free Software
91481 + * Foundation, either version 2 of that License or (at your option) any
91482 + * later version.
91483 + *
91484 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
91485 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
91486 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
91487 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
91488 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
91489 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
91490 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
91491 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
91492 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
91493 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
91494 + */
91495 +
91496 +#include <linux/version.h>
91497 +
91498 +#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
91499 +#define MODVERSIONS
91500 +#endif
91501 +#ifdef MODVERSIONS
91502 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
91503 +#include <linux/modversions.h>
91504 +#else
91505 +#include <config/modversions.h>
91506 +#endif /* LINUX_VERSION_CODE */
91507 +#endif /* MODVERSIONS */
91508 +
91509 +#include <linux/module.h>
91510 +#include <linux/kernel.h>
91511 +
91512 +#include <asm/io.h>
91513 +
91514 +#include "std_ext.h"
91515 +#include "error_ext.h"
91516 +#include "string_ext.h"
91517 +#include "list_ext.h"
91518 +#include "sys_io_ext.h"
91519 +
91520 +
91521 +#define __ERR_MODULE__ MODULE_UNKNOWN
91522 +
91523 +
91524 +typedef struct {
91525 + uint64_t virtAddr;
91526 + uint64_t physAddr;
91527 + uint32_t size;
91528 + t_List node;
91529 +} t_IoMap;
91530 +#define IOMAP_OBJECT(ptr) LIST_OBJECT(ptr, t_IoMap, node)
91531 +
91532 +LIST(mapsList);
91533 +
91534 +
91535 +static void EnqueueIoMap(t_IoMap *p_IoMap)
91536 +{
91537 + uint32_t intFlags;
91538 +
91539 + intFlags = XX_DisableAllIntr();
91540 + LIST_AddToTail(&p_IoMap->node, &mapsList);
91541 + XX_RestoreAllIntr(intFlags);
91542 +}
91543 +
91544 +static t_IoMap * FindIoMapByVirtAddr(uint64_t addr)
91545 +{
91546 + t_IoMap *p_IoMap;
91547 + t_List *p_Pos;
91548 +
91549 + LIST_FOR_EACH(p_Pos, &mapsList)
91550 + {
91551 + p_IoMap = IOMAP_OBJECT(p_Pos);
91552 + if ((addr >= p_IoMap->virtAddr) && (addr < p_IoMap->virtAddr+p_IoMap->size))
91553 + return p_IoMap;
91554 + }
91555 +
91556 + return NULL;
91557 +}
91558 +
91559 +static t_IoMap * FindIoMapByPhysAddr(uint64_t addr)
91560 +{
91561 + t_IoMap *p_IoMap;
91562 + t_List *p_Pos;
91563 +
91564 + LIST_FOR_EACH(p_Pos, &mapsList)
91565 + {
91566 + p_IoMap = IOMAP_OBJECT(p_Pos);
91567 + if ((addr >= p_IoMap->physAddr) && (addr < p_IoMap->physAddr+p_IoMap->size))
91568 + return p_IoMap;
91569 + }
91570 +
91571 + return NULL;
91572 +}
91573 +
91574 +t_Error SYS_RegisterIoMap (uint64_t virtAddr, uint64_t physAddr, uint32_t size)
91575 +{
91576 + t_IoMap *p_IoMap;
91577 +
91578 + p_IoMap = (t_IoMap*)XX_Malloc(sizeof(t_IoMap));
91579 + if (!p_IoMap)
91580 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("message handler object!!!"));
91581 + memset(p_IoMap, 0, sizeof(t_IoMap));
91582 +
91583 + p_IoMap->virtAddr = virtAddr;
91584 + p_IoMap->physAddr = physAddr;
91585 + p_IoMap->size = size;
91586 +
91587 + INIT_LIST(&p_IoMap->node);
91588 + EnqueueIoMap(p_IoMap);
91589 +
91590 + return E_OK;
91591 +}
91592 +
91593 +t_Error SYS_UnregisterIoMap (uint64_t virtAddr)
91594 +{
91595 + t_IoMap *p_IoMap = FindIoMapByVirtAddr(virtAddr);
91596 + if (!p_IoMap)
91597 + RETURN_ERROR(MINOR, E_NO_DEVICE, ("message handler not found in list!!!"));
91598 +
91599 + LIST_Del(&p_IoMap->node);
91600 + XX_Free(p_IoMap);
91601 +
91602 + return E_OK;
91603 +}
91604 +
91605 +uint64_t SYS_PhysToVirt(uint64_t addr)
91606 +{
91607 + t_IoMap *p_IoMap = FindIoMapByPhysAddr(addr);
91608 + if (p_IoMap)
91609 + {
91610 + /* This is optimization - put the latest in the list-head - like a cache */
91611 + if (mapsList.p_Next != &p_IoMap->node)
91612 + {
91613 + uint32_t intFlags = XX_DisableAllIntr();
91614 + LIST_DelAndInit(&p_IoMap->node);
91615 + LIST_Add(&p_IoMap->node, &mapsList);
91616 + XX_RestoreAllIntr(intFlags);
91617 + }
91618 + return (uint64_t)(addr - p_IoMap->physAddr + p_IoMap->virtAddr);
91619 + }
91620 + return PTR_TO_UINT(phys_to_virt((unsigned long)addr));
91621 +}
91622 +
91623 +uint64_t SYS_VirtToPhys(uint64_t addr)
91624 +{
91625 + t_IoMap *p_IoMap;
91626 +
91627 + if (addr == 0)
91628 + return 0;
91629 +
91630 + p_IoMap = FindIoMapByVirtAddr(addr);
91631 + if (p_IoMap)
91632 + return (uint64_t)(addr - p_IoMap->virtAddr + p_IoMap->physAddr);
91633 + return (uint64_t)virt_to_phys(UINT_TO_PTR(addr));
91634 +}
91635 --- /dev/null
91636 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/Makefile
91637 @@ -0,0 +1,19 @@
91638 +#
91639 +# Makefile for the Freescale Ethernet controllers
91640 +#
91641 +ccflags-y += -DVERSION=\"\"
91642 +#
91643 +#Include netcomm SW specific definitions
91644 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
91645 +
91646 +NCSW_FM_INC = $(srctree)/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc
91647 +
91648 +ccflags-y += -I$(NCSW_FM_INC)
91649 +ccflags-y += -I$(NET_DPA)
91650 +
91651 +obj-y += fsl-ncsw-PFM.o
91652 +obj-$(CONFIG_FSL_SDK_FMAN_TEST) += fman_test.o
91653 +
91654 +fsl-ncsw-PFM-objs := lnxwrp_fm.o lnxwrp_fm_port.o lnxwrp_ioctls_fm.o \
91655 + lnxwrp_sysfs.o lnxwrp_sysfs_fm.o lnxwrp_sysfs_fm_port.o
91656 +obj-$(CONFIG_COMPAT) += lnxwrp_ioctls_fm_compat.o
91657 --- /dev/null
91658 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/fman_test.c
91659 @@ -0,0 +1,1665 @@
91660 +/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
91661 + * All rights reserved.
91662 + *
91663 + * Redistribution and use in source and binary forms, with or without
91664 + * modification, are permitted provided that the following conditions are met:
91665 + * * Redistributions of source code must retain the above copyright
91666 + * notice, this list of conditions and the following disclaimer.
91667 + * * Redistributions in binary form must reproduce the above copyright
91668 + * notice, this list of conditions and the following disclaimer in the
91669 + * documentation and/or other materials provided with the distribution.
91670 + * * Neither the name of Freescale Semiconductor nor the
91671 + * names of its contributors may be used to endorse or promote products
91672 + * derived from this software without specific prior written permission.
91673 + *
91674 + *
91675 + * ALTERNATIVELY, this software may be distributed under the terms of the
91676 + * GNU General Public License ("GPL") as published by the Free Software
91677 + * Foundation, either version 2 of that License or (at your option) any
91678 + * later version.
91679 + *
91680 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
91681 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
91682 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
91683 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
91684 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
91685 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
91686 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
91687 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
91688 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
91689 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
91690 + */
91691 +
91692 +/*
91693 + @File fman_test.c
91694 + @Authors Pistirica Sorin Andrei
91695 + @Description FM Linux test environment
91696 +*/
91697 +
91698 +#include <linux/kernel.h>
91699 +#include <linux/module.h>
91700 +#include <linux/fs.h>
91701 +#include <linux/cdev.h>
91702 +#include <linux/device.h>
91703 +#include <linux/io.h>
91704 +#include <linux/ioport.h>
91705 +#include <linux/of_platform.h>
91706 +#include <linux/ip.h>
91707 +#include <linux/compat.h>
91708 +#include <linux/uaccess.h>
91709 +#include <linux/errno.h>
91710 +#include <linux/netdevice.h>
91711 +#include <linux/spinlock.h>
91712 +#include <linux/types.h>
91713 +#include <linux/fsl_qman.h>
91714 +#include <linux/fsl_bman.h>
91715 +
91716 +/* private headers */
91717 +#include "fm_ext.h"
91718 +#include "lnxwrp_fsl_fman.h"
91719 +#include "fm_port_ext.h"
91720 +#if (DPAA_VERSION == 11)
91721 +#include "../../Peripherals/FM/MAC/memac.h"
91722 +#endif
91723 +#include "fm_test_ioctls.h"
91724 +#include "fsl_fman_test.h"
91725 +
91726 +#include "dpaa_eth.h"
91727 +#include "dpaa_eth_common.h"
91728 +
91729 +#define FMT_FRM_WATERMARK 0xdeadbeefdeadbeeaLL
91730 +
91731 +struct fmt_frame_s {
91732 + ioc_fmt_buff_desc_t buff;
91733 + struct list_head list;
91734 +};
91735 +
91736 +struct fmt_fqs_s {
91737 + struct qman_fq fq_base;
91738 + bool init;
91739 + struct fmt_port_s *fmt_port_priv;
91740 +};
91741 +
91742 +struct fmt_port_pcd_s {
91743 + int num_queues;
91744 + struct fmt_fqs_s *fmt_pcd_fqs;
91745 + uint32_t fqid_base;
91746 +};
91747 +
91748 +/* char dev structure: fm test port */
91749 +struct fmt_port_s {
91750 + bool valid;
91751 + uint8_t id;
91752 + ioc_fmt_port_type port_type;
91753 + ioc_diag_mode diag;
91754 + bool compat_test_type;
91755 +
91756 + /* fm ports */
91757 + /* ! for oh ports p_tx_fm_port_dev == p_rx_fm_port_dev &&
91758 + * p_tx_port == p_rx_port */
91759 + /* t_LnxWrpFmPortDev */
91760 + struct fm_port *p_tx_port;
91761 + /* t_LnxWrpFmPortDev->h_Dev: t_FmPort */
91762 + void *p_tx_fm_port_dev;
91763 + /* t_LnxWrpFmPortDev */
91764 + struct fm_port *p_rx_port;
91765 + /* t_LnxWrpFmPortDev->h_Dev: t_FmPort */
91766 + void *p_rx_fm_port_dev;
91767 +
91768 + void *p_mac_dev;
91769 + uint64_t fm_phys_base_addr;
91770 +
91771 + /* read/write queue manipulation */
91772 + spinlock_t rx_q_lock;
91773 + struct list_head rx_q;
91774 +
91775 + /* tx queuee for injecting traffic */
91776 + int num_of_tx_fqs;
91777 + struct fmt_fqs_s p_tx_fqs[FMAN_TEST_MAX_TX_FQS];
91778 +
91779 + /* pcd private queues manipulation */
91780 + struct fmt_port_pcd_s fmt_port_pcd;
91781 +
91782 + /* debugging stuff */
91783 +
91784 +#if defined(FMT_K_DBG) || defined(FMT_K_DBG_RUNTIME)
91785 + atomic_t enqueue_to_qman_frm;
91786 + atomic_t enqueue_to_rxq;
91787 + atomic_t dequeue_from_rxq;
91788 + atomic_t not_enqueue_to_rxq_wrong_frm;
91789 +#endif
91790 +
91791 +};
91792 +
91793 +/* The devices. */
91794 +struct fmt_s {
91795 + int major;
91796 + struct fmt_port_s ports[IOC_FMT_MAX_NUM_OF_PORTS];
91797 + struct class *fmt_class;
91798 +};
91799 +
91800 +/* fm test structure */
91801 +static struct fmt_s fm_test;
91802 +
91803 +#if (DPAA_VERSION == 11)
91804 +struct mac_priv_s {
91805 + t_Handle mac;
91806 +};
91807 +#endif
91808 +
91809 +#define DTSEC_BASE_ADDR 0x000e0000
91810 +#define DTSEC_MEM_RANGE 0x00002000
91811 +#define MAC_1G_MACCFG1 0x00000100
91812 +#define MAC_1G_LOOP_MASK 0x00000100
91813 +static int set_1gmac_loopback(
91814 + struct fmt_port_s *fmt_port,
91815 + bool en)
91816 +{
91817 +#if (DPAA_VERSION <= 10)
91818 + uint32_t dtsec_idx = fmt_port->id; /* dtsec for which port */
91819 + uint32_t dtsec_idx_off = dtsec_idx * DTSEC_MEM_RANGE;
91820 + phys_addr_t maccfg1_hw;
91821 + void *maccfg1_map;
91822 + uint32_t maccfg1_val;
91823 +
91824 + /* compute the maccfg1 register address */
91825 + maccfg1_hw = fmt_port->fm_phys_base_addr +
91826 + (phys_addr_t)(DTSEC_BASE_ADDR +
91827 + dtsec_idx_off +
91828 + MAC_1G_MACCFG1);
91829 +
91830 + /* map register */
91831 + maccfg1_map = ioremap(maccfg1_hw, sizeof(u32));
91832 +
91833 + /* set register */
91834 + maccfg1_val = in_be32(maccfg1_map);
91835 + if (en)
91836 + maccfg1_val |= MAC_1G_LOOP_MASK;
91837 + else
91838 + maccfg1_val &= ~MAC_1G_LOOP_MASK;
91839 + out_be32(maccfg1_map, maccfg1_val);
91840 +
91841 + /* unmap register */
91842 + iounmap(maccfg1_map);
91843 +#else
91844 + struct mac_device *mac_dev;
91845 + struct mac_priv_s *priv;
91846 + t_Memac *p_memac;
91847 +
91848 + if (!fmt_port)
91849 + return -EINVAL;
91850 +
91851 + mac_dev = (struct mac_device *)fmt_port->p_mac_dev;
91852 +
91853 + if (!mac_dev)
91854 + return -EINVAL;
91855 +
91856 + priv = macdev_priv(mac_dev);
91857 +
91858 + if (!priv)
91859 + return -EINVAL;
91860 +
91861 + p_memac = priv->mac;
91862 +
91863 + if (!p_memac)
91864 + return -EINVAL;
91865 +
91866 + memac_set_loopback(p_memac->p_MemMap, en);
91867 +#endif
91868 + return 0;
91869 +}
91870 +
91871 +/* TODO: re-write this function */
91872 +static int set_10gmac_int_loopback(
91873 + struct fmt_port_s *fmt_port,
91874 + bool en)
91875 +{
91876 +#ifndef FM_10G_MAC_NO_CTRL_LOOPBACK
91877 +#define FM_10GMAC0_OFFSET 0x000f0000
91878 +#define FM_10GMAC_CMD_CONF_CTRL_OFFSET 0x8
91879 +#define CMD_CFG_LOOPBACK_EN 0x00000400
91880 +
91881 + uint64_t base_addr, reg_addr;
91882 + uint32_t tmp_val;
91883 +
91884 + base_addr = fmt_port->fm_phys_base_addr + (FM_10GMAC0_OFFSET +
91885 + ((fmt_port->id-FM_MAX_NUM_OF_1G_RX_PORTS)*0x2000));
91886 +
91887 + base_addr = PTR_TO_UINT(ioremap(base_addr, 0x1000));
91888 +
91889 + reg_addr = base_addr + FM_10GMAC_CMD_CONF_CTRL_OFFSET;
91890 + tmp_val = GET_UINT32(*((uint32_t *)UINT_TO_PTR(reg_addr)));
91891 + if (en)
91892 + tmp_val |= CMD_CFG_LOOPBACK_EN;
91893 + else
91894 + tmp_val &= ~CMD_CFG_LOOPBACK_EN;
91895 + WRITE_UINT32(*((uint32_t *)UINT_TO_PTR(reg_addr)), tmp_val);
91896 +
91897 + iounmap(UINT_TO_PTR(base_addr));
91898 +
91899 + return 0;
91900 +#else
91901 + _fmt_err("TGEC don't have internal-loopback.\n");
91902 + return -EPERM;
91903 +#endif
91904 +}
91905 +
91906 +static int set_mac_int_loopback(struct fmt_port_s *fmt_port, bool en)
91907 +{
91908 + int _err = 0;
91909 +
91910 + switch (fmt_port->port_type) {
91911 +
91912 + case e_IOC_FMT_PORT_T_RXTX:
91913 + /* 1G port */
91914 + if (fmt_port->id < FM_MAX_NUM_OF_1G_RX_PORTS)
91915 + _err = set_1gmac_loopback(fmt_port, en);
91916 + /* 10g port */
91917 + else if ((fmt_port->id >= FM_MAX_NUM_OF_1G_RX_PORTS) &&
91918 + (fmt_port->id < FM_MAX_NUM_OF_1G_RX_PORTS +
91919 + FM_MAX_NUM_OF_10G_RX_PORTS)) {
91920 +
91921 + _err = set_10gmac_int_loopback(fmt_port, en);
91922 + } else
91923 + _err = -EINVAL;
91924 + break;
91925 + /* op port does not have MAC (loopback mode) */
91926 + case e_IOC_FMT_PORT_T_OP:
91927 +
91928 + _err = 0;
91929 + break;
91930 + default:
91931 +
91932 + _err = -EPERM;
91933 + break;
91934 + }
91935 +
91936 + return _err;
91937 +}
91938 +
91939 +static void enqueue_fmt_frame(
91940 + struct fmt_port_s *fmt_port,
91941 + struct fmt_frame_s *p_fmt_frame)
91942 +{
91943 + spinlock_t *rx_q_lock = NULL;
91944 +
91945 + rx_q_lock = &fmt_port->rx_q_lock;
91946 +
91947 + spin_lock(rx_q_lock);
91948 + list_add_tail(&p_fmt_frame->list, &fmt_port->rx_q);
91949 + spin_unlock(rx_q_lock);
91950 +
91951 +#if defined(FMT_K_DBG) || defined(FMT_K_DBG_RUNTIME)
91952 + atomic_inc(&fmt_port->enqueue_to_rxq);
91953 +#endif
91954 +}
91955 +
91956 +static struct fmt_frame_s *dequeue_fmt_frame(
91957 + struct fmt_port_s *fmt_port)
91958 +{
91959 + struct fmt_frame_s *p_fmt_frame = NULL;
91960 + spinlock_t *rx_q_lock = NULL;
91961 +
91962 + rx_q_lock = &fmt_port->rx_q_lock;
91963 +
91964 + spin_lock(rx_q_lock);
91965 +
91966 +#define list_last_entry(ptr, type, member) list_entry((ptr)->prev, type, member)
91967 +
91968 + if (!list_empty(&fmt_port->rx_q)) {
91969 + p_fmt_frame = list_last_entry(&fmt_port->rx_q,
91970 + struct fmt_frame_s,
91971 + list);
91972 + list_del(&p_fmt_frame->list);
91973 +
91974 +#if defined(FMT_K_DBG) || defined(FMT_K_DBG_RUNTIME)
91975 + atomic_inc(&fmt_port->dequeue_from_rxq);
91976 +#endif
91977 + }
91978 +
91979 + spin_unlock(rx_q_lock);
91980 +
91981 + return p_fmt_frame;
91982 +}
91983 +
91984 +/* eth-dev -to- fmt port association */
91985 +struct fmt_port_s *match_dpa_to_fmt_port(
91986 + struct dpa_priv_s *dpa_priv) {
91987 + struct mac_device *mac_dev = dpa_priv->mac_dev;
91988 + struct fm_port *fm_port = (struct fm_port *) mac_dev;
91989 + struct fmt_port_s *fmt_port = NULL;
91990 + int i;
91991 +
91992 + _fmt_dbgr("calling...\n");
91993 +
91994 + /* find the FM-test-port object */
91995 + for (i = 0; i < IOC_FMT_MAX_NUM_OF_PORTS; i++)
91996 + if ((fm_test.ports[i].p_mac_dev &&
91997 + mac_dev == fm_test.ports[i].p_mac_dev) ||
91998 + fm_port == fm_test.ports[i].p_tx_port) {
91999 +
92000 + fmt_port = &fm_test.ports[i];
92001 + break;
92002 + }
92003 +
92004 + _fmt_dbgr("called\n");
92005 + return fmt_port;
92006 +}
92007 +
92008 +void dump_frame(
92009 + uint8_t *buffer,
92010 + uint32_t size)
92011 +{
92012 +#if defined(FMT_K_DBG) || defined(FMT_K_DBG_RUNTIME)
92013 + unsigned int i;
92014 +
92015 + for (i = 0; i < size; i++) {
92016 + if (i%16 == 0)
92017 + printk(KERN_DEBUG "\n");
92018 + printk(KERN_DEBUG "%2x ", *(buffer+i));
92019 + }
92020 +#endif
92021 + return;
92022 +}
92023 +
92024 +bool test_and_steal_frame(struct fmt_port_s *fmt_port,
92025 + uint32_t fqid,
92026 + uint8_t *buffer,
92027 + uint32_t size)
92028 +{
92029 + struct fmt_frame_s *p_fmt_frame = NULL;
92030 + bool test_and_steal_frame_frame;
92031 + uint32_t data_offset;
92032 + uint32_t i;
92033 +
92034 + _fmt_dbgr("calling...\n");
92035 +
92036 + if (!fmt_port || !fmt_port->p_rx_fm_port_dev)
92037 + return false;
92038 +
92039 + /* check watermark */
92040 + test_and_steal_frame_frame = false;
92041 + for (i = 0; i < size; i++) {
92042 + uint64_t temp = *((uint64_t *)(buffer + i));
92043 +
92044 + if (temp == (uint64_t) FMT_FRM_WATERMARK) {
92045 + _fmt_dbgr("watermark found!\n");
92046 + test_and_steal_frame_frame = true;
92047 + break;
92048 + }
92049 + }
92050 +
92051 + if (!test_and_steal_frame_frame) {
92052 +#if defined(FMT_K_DBG) || defined(FMT_K_DBG_RUNTIME)
92053 + atomic_inc(&fmt_port->not_enqueue_to_rxq_wrong_frm);
92054 +#endif
92055 + _fmt_dbgr("NOT watermark found!\n");
92056 + return false;
92057 + }
92058 +
92059 + /* do not enqueue the tx conf/err frames */
92060 + if ((fqid == FMT_TX_CONF_Q) || (fqid == FMT_TX_ERR_Q))
92061 + goto _test_and_steal_frame_return_true;
92062 +
92063 + _fmt_dbgr("on port %d got FMUC frame\n", fmt_port->id);
92064 + data_offset = FM_PORT_GetBufferDataOffset(
92065 + fmt_port->p_rx_fm_port_dev);
92066 +
92067 + p_fmt_frame = kmalloc(sizeof(struct fmt_frame_s), GFP_KERNEL);
92068 +
92069 + /* dump frame... no more space left on device */
92070 + if (p_fmt_frame == NULL) {
92071 + _fmt_err("no space left on device!\n");
92072 + goto _test_and_steal_frame_return_true;
92073 + }
92074 +
92075 + memset(p_fmt_frame, 0, sizeof(struct fmt_frame_s));
92076 + p_fmt_frame->buff.p_data = kmalloc(size * sizeof(uint8_t), GFP_KERNEL);
92077 +
92078 + /* No more space left on device*/
92079 + if (p_fmt_frame->buff.p_data == NULL) {
92080 + _fmt_err("no space left on device!\n");
92081 + kfree(p_fmt_frame);
92082 + goto _test_and_steal_frame_return_true;
92083 + }
92084 +
92085 + p_fmt_frame->buff.size = size-data_offset;
92086 + p_fmt_frame->buff.qid = fqid;
92087 +
92088 + memcpy(p_fmt_frame->buff.p_data,
92089 + (uint8_t *)PTR_MOVE(buffer, data_offset),
92090 + p_fmt_frame->buff.size);
92091 +
92092 + memcpy(p_fmt_frame->buff.buff_context.fm_prs_res,
92093 + FM_PORT_GetBufferPrsResult(fmt_port->p_rx_fm_port_dev,
92094 + (char *)buffer),
92095 + 32);
92096 +
92097 + /* enqueue frame - this frame will go to us */
92098 + enqueue_fmt_frame(fmt_port, p_fmt_frame);
92099 +
92100 +_test_and_steal_frame_return_true:
92101 + return true;
92102 +}
92103 +
92104 +static int fmt_fq_release(const struct qm_fd *fd)
92105 +{
92106 + struct dpa_bp *_dpa_bp;
92107 + struct bm_buffer _bmb;
92108 +
92109 + if (fd->format == qm_fd_contig) {
92110 + _dpa_bp = dpa_bpid2pool(fd->bpid);
92111 + BUG_ON(IS_ERR(_dpa_bp));
92112 +
92113 + _bmb.hi = fd->addr_hi;
92114 + _bmb.lo = fd->addr_lo;
92115 +
92116 + while (bman_release(_dpa_bp->pool, &_bmb, 1, 0))
92117 + cpu_relax();
92118 +
92119 + } else {
92120 + _fmt_err("frame not supported !\n");
92121 + return -1;
92122 + }
92123 +
92124 + return 0;
92125 +}
92126 +
92127 +/* sync it w/ dpaa_eth.c: DPA_BP_HEAD */
92128 +#define DPA_BP_HEADROOM (DPA_TX_PRIV_DATA_SIZE + \
92129 + fm_get_rx_extra_headroom() + \
92130 + DPA_PARSE_RESULTS_SIZE + \
92131 + DPA_HASH_RESULTS_SIZE)
92132 +#define MAC_HEADER_LENGTH 14
92133 +#define L2_AND_HEADROOM_OFF ((DPA_BP_HEADROOM) + (MAC_HEADER_LENGTH))
92134 +
92135 +/* dpa ingress hooks definition */
92136 +enum dpaa_eth_hook_result fmt_rx_default_hook(
92137 + struct sk_buff *skb,
92138 + struct net_device *net_dev,
92139 + u32 fqid)
92140 +{
92141 + struct dpa_priv_s *dpa_priv = NULL;
92142 + struct fmt_port_s *fmt_port = NULL;
92143 + uint8_t *buffer;
92144 + uint32_t buffer_len;
92145 +
92146 + _fmt_dbgr("calling...\n");
92147 +
92148 + dpa_priv = netdev_priv(net_dev);
92149 + fmt_port = match_dpa_to_fmt_port(dpa_priv);
92150 +
92151 + /* conversion from skb to fd:
92152 + * skb cames processed for L3, so we need to go back for
92153 + * layer 2 offset */
92154 + buffer = (uint8_t *)(skb->data - ((int)L2_AND_HEADROOM_OFF));
92155 + buffer_len = skb->len + ((int)L2_AND_HEADROOM_OFF);
92156 +
92157 + /* if is not out frame let dpa to handle it */
92158 + if (test_and_steal_frame(fmt_port,
92159 + FMT_RX_DFLT_Q,
92160 + buffer,
92161 + buffer_len))
92162 + goto _fmt_rx_default_hook_stolen;
92163 +
92164 + _fmt_dbgr("called:DPAA_ETH_CONTINUE.\n");
92165 + return DPAA_ETH_CONTINUE;
92166 +
92167 +_fmt_rx_default_hook_stolen:
92168 + dev_kfree_skb(skb);
92169 +
92170 + _fmt_dbgr("called:DPAA_ETH_STOLEN.\n");
92171 + return DPAA_ETH_STOLEN;
92172 +}
92173 +
92174 +enum dpaa_eth_hook_result fmt_rx_error_hook(
92175 + struct net_device *net_dev,
92176 + const struct qm_fd *fd,
92177 + u32 fqid)
92178 +{
92179 + struct dpa_priv_s *dpa_priv = NULL;
92180 + struct dpa_bp *dpa_bp = NULL;
92181 + struct fmt_port_s *fmt_port = NULL;
92182 + void *fd_virt_addr = NULL;
92183 + dma_addr_t addr = qm_fd_addr(fd);
92184 +
92185 + _fmt_dbgr("calling...\n");
92186 +
92187 + dpa_priv = netdev_priv(net_dev);
92188 + fmt_port = match_dpa_to_fmt_port(dpa_priv);
92189 +
92190 + /* dpaa doesn't do this... we have to do it here */
92191 + dpa_bp = dpa_bpid2pool(fd->bpid);
92192 + dma_unmap_single(dpa_bp->dev, addr, dpa_bp->size, DMA_BIDIRECTIONAL);
92193 +
92194 + fd_virt_addr = phys_to_virt(addr);
92195 + /* if is not out frame let dpa to handle it */
92196 + if (test_and_steal_frame(fmt_port,
92197 + FMT_RX_ERR_Q,
92198 + fd_virt_addr,
92199 + fd->length20 + fd->offset)) {
92200 + goto _fmt_rx_error_hook_stolen;
92201 + }
92202 +
92203 + _fmt_dbgr("called:DPAA_ETH_CONTINUE.\n");
92204 + return DPAA_ETH_CONTINUE;
92205 +
92206 +_fmt_rx_error_hook_stolen:
92207 + /* the frame data doesn't matter,
92208 + * so, no mapping is needed */
92209 + fmt_fq_release(fd);
92210 +
92211 + _fmt_dbgr("called:DPAA_ETH_STOLEN.\n");
92212 + return DPAA_ETH_STOLEN;
92213 +}
92214 +
92215 +enum dpaa_eth_hook_result fmt_tx_confirm_hook(
92216 + struct net_device *net_dev,
92217 + const struct qm_fd *fd,
92218 + u32 fqid)
92219 +{
92220 + struct dpa_priv_s *dpa_priv = NULL;
92221 + struct fmt_port_s *fmt_port = NULL;
92222 + dma_addr_t addr = qm_fd_addr(fd);
92223 + void *fd_virt_addr = NULL;
92224 + uint32_t fd_len = 0;
92225 +
92226 + _fmt_dbgr("calling...\n");
92227 +
92228 + dpa_priv = netdev_priv(net_dev);
92229 + fmt_port = match_dpa_to_fmt_port(dpa_priv);
92230 +
92231 + fd_virt_addr = phys_to_virt(addr);
92232 + fd_len = fd->length20 + fd->offset;
92233 +
92234 + if (fd_len > fm_get_max_frm()) {
92235 + _fmt_err("tx confirm bad frame size: %u!\n", fd_len);
92236 + goto _fmt_tx_confirm_hook_continue;
92237 + }
92238 +
92239 + if (test_and_steal_frame(fmt_port,
92240 + FMT_TX_CONF_Q,
92241 + fd_virt_addr,
92242 + fd_len))
92243 + goto _fmt_tx_confirm_hook_stolen;
92244 +
92245 +_fmt_tx_confirm_hook_continue:
92246 + _fmt_dbgr("called:DPAA_ETH_CONTINUE.\n");
92247 + return DPAA_ETH_CONTINUE;
92248 +
92249 +_fmt_tx_confirm_hook_stolen:
92250 + kfree(fd_virt_addr);
92251 +
92252 + _fmt_dbgr("called:DPAA_ETH_STOLEN.\n");
92253 + return DPAA_ETH_STOLEN;
92254 +}
92255 +
92256 +enum dpaa_eth_hook_result fmt_tx_confirm_error_hook(
92257 + struct net_device *net_dev,
92258 + const struct qm_fd *fd,
92259 + u32 fqid)
92260 +{
92261 + struct dpa_priv_s *dpa_priv = NULL;
92262 + struct fmt_port_s *fmt_port = NULL;
92263 + dma_addr_t addr = qm_fd_addr(fd);
92264 + void *fd_virt_addr = NULL;
92265 + uint32_t fd_len = 0;
92266 +
92267 + _fmt_dbgr("calling...\n");
92268 +
92269 + dpa_priv = netdev_priv(net_dev);
92270 + fmt_port = match_dpa_to_fmt_port(dpa_priv);
92271 +
92272 + fd_virt_addr = phys_to_virt(addr);
92273 + fd_len = fd->length20 + fd->offset;
92274 +
92275 + if (fd_len > fm_get_max_frm()) {
92276 + _fmt_err("tx confirm err bad frame size: %u !\n", fd_len);
92277 + goto _priv_ingress_tx_err_continue;
92278 + }
92279 +
92280 + if (test_and_steal_frame(fmt_port, FMT_TX_ERR_Q, fd_virt_addr, fd_len))
92281 + goto _priv_ingress_tx_err_stolen;
92282 +
92283 +_priv_ingress_tx_err_continue:
92284 + _fmt_dbgr("called:DPAA_ETH_CONTINUE.\n");
92285 + return DPAA_ETH_CONTINUE;
92286 +
92287 +_priv_ingress_tx_err_stolen:
92288 + kfree(fd_virt_addr);
92289 +
92290 + _fmt_dbgr("called:DPAA_ETH_STOLEN.\n");
92291 + return DPAA_ETH_STOLEN;
92292 +}
92293 +
92294 +/* egress callbacks definition */
92295 +enum qman_cb_dqrr_result fmt_egress_dqrr(
92296 + struct qman_portal *portal,
92297 + struct qman_fq *fq,
92298 + const struct qm_dqrr_entry *dqrr)
92299 +{
92300 + /* this callback should never be called */
92301 + BUG();
92302 + return qman_cb_dqrr_consume;
92303 +}
92304 +
92305 +static void fmt_egress_error_dqrr(
92306 + struct qman_portal *p,
92307 + struct qman_fq *fq,
92308 + const struct qm_mr_entry *msg)
92309 +{
92310 + uint8_t *fd_virt_addr = NULL;
92311 +
92312 + /* tx failure, on the ern callback - release buffer */
92313 + fd_virt_addr = (uint8_t *)phys_to_virt(qm_fd_addr(&msg->ern.fd));
92314 + kfree(fd_virt_addr);
92315 +
92316 + return;
92317 +}
92318 +
92319 +static const struct qman_fq fmt_egress_fq = {
92320 + .cb = { .dqrr = fmt_egress_dqrr,
92321 + .ern = fmt_egress_error_dqrr,
92322 + .fqs = NULL}
92323 +};
92324 +
92325 +int fmt_fq_alloc(
92326 + struct fmt_fqs_s *fmt_fqs,
92327 + const struct qman_fq *qman_fq,
92328 + uint32_t fqid, uint32_t flags,
92329 + uint16_t channel, uint8_t wq)
92330 +{
92331 + int _errno = 0;
92332 +
92333 + _fmt_dbg("calling...\n");
92334 +
92335 + fmt_fqs->fq_base = *qman_fq;
92336 +
92337 + if (fqid == 0) {
92338 + flags |= QMAN_FQ_FLAG_DYNAMIC_FQID;
92339 + flags &= ~QMAN_FQ_FLAG_NO_MODIFY;
92340 + } else
92341 + flags &= ~QMAN_FQ_FLAG_DYNAMIC_FQID;
92342 +
92343 + fmt_fqs->init = !(flags & QMAN_FQ_FLAG_NO_MODIFY);
92344 +
92345 + _errno = qman_create_fq(fqid, flags, &fmt_fqs->fq_base);
92346 + if (_errno < 0) {
92347 + _fmt_err("frame queues create failed.\n");
92348 + return -EINVAL;
92349 + }
92350 +
92351 + if (fmt_fqs->init) {
92352 + struct qm_mcc_initfq initfq;
92353 +
92354 + initfq.we_mask = QM_INITFQ_WE_DESTWQ;
92355 + initfq.fqd.dest.channel = channel;
92356 + initfq.fqd.dest.wq = wq;
92357 +
92358 + _errno = qman_init_fq(&fmt_fqs->fq_base,
92359 + QMAN_INITFQ_FLAG_SCHED,
92360 + &initfq);
92361 + if (_errno < 0) {
92362 + _fmt_err("frame queues init erorr.\n");
92363 + qman_destroy_fq(&fmt_fqs->fq_base, 0);
92364 + return -EINVAL;
92365 + }
92366 + }
92367 +
92368 + _fmt_dbg("called.\n");
92369 + return 0;
92370 +}
92371 +
92372 +static int fmt_fq_free(struct fmt_fqs_s *fmt_fq)
92373 +{
92374 + int _err = 0;
92375 +
92376 + _fmt_dbg("calling...\n");
92377 +
92378 + if (fmt_fq->init) {
92379 + _err = qman_retire_fq(&fmt_fq->fq_base, NULL);
92380 + if (unlikely(_err < 0))
92381 + _fmt_err("qman_retire_fq(%u) = %d\n",
92382 + qman_fq_fqid(&fmt_fq->fq_base), _err);
92383 +
92384 + _err = qman_oos_fq(&fmt_fq->fq_base);
92385 + if (unlikely(_err < 0))
92386 + _fmt_err("qman_oos_fq(%u) = %d\n",
92387 + qman_fq_fqid(&fmt_fq->fq_base), _err);
92388 + }
92389 +
92390 + qman_destroy_fq(&fmt_fq->fq_base, 0);
92391 +
92392 + _fmt_dbg("called.\n");
92393 + return _err;
92394 +}
92395 +
92396 +/* private pcd dqrr calbacks */
92397 +static enum qman_cb_dqrr_result fmt_pcd_dqrr(
92398 + struct qman_portal *portal,
92399 + struct qman_fq *fq,
92400 + const struct qm_dqrr_entry *dq)
92401 +{
92402 + struct dpa_bp *dpa_bp = NULL;
92403 + dma_addr_t addr = qm_fd_addr(&dq->fd);
92404 + uint8_t *fd_virt_addr = NULL;
92405 + struct fmt_port_s *fmt_port;
92406 + struct fmt_port_pcd_s *fmt_port_pcd;
92407 + uint32_t relative_fqid = 0;
92408 + uint32_t fd_len = 0;
92409 +
92410 + _fmt_dbgr("calling...\n");
92411 +
92412 + /* upcast - from pcd_alloc_fq */
92413 + fmt_port = ((struct fmt_fqs_s *)fq)->fmt_port_priv;
92414 + if (!fmt_port) {
92415 + _fmt_err(" wrong fmt port -to- fq match.\n");
92416 + goto _fmt_pcd_dqrr_return;
92417 + }
92418 + fmt_port_pcd = &fmt_port->fmt_port_pcd;
92419 +
92420 + relative_fqid = dq->fqid - fmt_port_pcd->fqid_base;
92421 + _fmt_dbgr("pcd dqrr got frame on relative fq:%u@base:%u\n",
92422 + relative_fqid, fmt_port_pcd->fqid_base);
92423 +
92424 + fd_len = dq->fd.length20 + dq->fd.offset;
92425 +
92426 + if (fd_len > fm_get_max_frm()) {
92427 + _fmt_err("pcd dqrr wrong frame size: %u (%u:%u)!\n",
92428 + fd_len, dq->fd.length20, dq->fd.offset);
92429 + goto _fmt_pcd_dqrr_return;
92430 + }
92431 +
92432 + dpa_bp = dpa_bpid2pool(dq->fd.bpid);
92433 + dma_unmap_single(dpa_bp->dev, addr, dpa_bp->size, DMA_BIDIRECTIONAL);
92434 +
92435 + fd_virt_addr = phys_to_virt(addr);
92436 + if (!test_and_steal_frame(fmt_port, relative_fqid, fd_virt_addr,
92437 + fd_len)) {
92438 +
92439 +#if defined(FMT_K_DBG) || defined(FMT_K_DBG_RUNTIME)
92440 + atomic_inc(&fmt_port->not_enqueue_to_rxq_wrong_frm);
92441 +#endif
92442 + _fmt_wrn("pcd dqrr unrecognized frame@fqid: %u,"
92443 + " frame len: %u (dropped).\n",
92444 + dq->fqid, dq->fd.length20);
92445 + dump_frame(fd_virt_addr, fd_len);
92446 + }
92447 +
92448 +_fmt_pcd_dqrr_return:
92449 + /* no need to map again here */
92450 + fmt_fq_release(&dq->fd);
92451 +
92452 + _fmt_dbgr("calle.\n");
92453 + return qman_cb_dqrr_consume;
92454 +}
92455 +
92456 +static void fmt_pcd_err_dqrr(
92457 + struct qman_portal *qm,
92458 + struct qman_fq *fq,
92459 + const struct qm_mr_entry *msg)
92460 +{
92461 + _fmt_err("this callback should never be called.\n");
92462 + BUG();
92463 + return;
92464 +}
92465 +
92466 +static void fmt_pcd_fqs_dqrr(
92467 + struct qman_portal *qm,
92468 + struct qman_fq *fq,
92469 + const struct qm_mr_entry *msg)
92470 +{
92471 + _fmt_dbg(" fq state(0x%x)@fqid(%u.\n", msg->fq.fqs, msg->fq.fqid);
92472 + return;
92473 +}
92474 +
92475 +/* private pcd queue template */
92476 +static const struct qman_fq pcd_fq = {
92477 + .cb = { .dqrr = fmt_pcd_dqrr,
92478 + .ern = fmt_pcd_err_dqrr,
92479 + .fqs = fmt_pcd_fqs_dqrr}
92480 +};
92481 +
92482 +/* defined as weak in dpaa driver. */
92483 +/* ! parameters come from IOCTL call - US */
92484 +int dpa_alloc_pcd_fqids(
92485 + struct device *dev,
92486 + uint32_t num, uint8_t alignment,
92487 + uint32_t *base_fqid)
92488 +{
92489 + int _err = 0, i;
92490 + struct net_device *net_dev = NULL;
92491 + struct dpa_priv_s *dpa_priv = NULL;
92492 + struct fmt_port_pcd_s *fmt_port_pcd = NULL;
92493 + struct fmt_fqs_s *fmt_fqs = NULL;
92494 + struct fmt_port_s *fmt_port = NULL;
92495 + int num_allocated = 0;
92496 +
92497 + _fmt_dbg("calling...\n");
92498 +
92499 + net_dev = (typeof(net_dev))dev_get_drvdata(dev);
92500 + dpa_priv = (typeof(dpa_priv))netdev_priv(net_dev);
92501 +
92502 + if (!netif_msg_probe(dpa_priv)) {
92503 + _fmt_err("dpa not probe.\n");
92504 + _err = -ENODEV;
92505 + goto _pcd_alloc_fqs_err;
92506 + }
92507 +
92508 + fmt_port = match_dpa_to_fmt_port(dpa_priv);
92509 + if (!fmt_port) {
92510 + _fmt_err("fmt port not found.");
92511 + _err = -EINVAL;
92512 + goto _pcd_alloc_fqs_err;
92513 + }
92514 +
92515 + fmt_port_pcd = &fmt_port->fmt_port_pcd;
92516 +
92517 + num_allocated = qman_alloc_fqid_range(base_fqid, num, alignment, 0);
92518 +
92519 + if ((num_allocated <= 0) ||
92520 + (num_allocated < num) ||
92521 + (alignment && (*base_fqid) % alignment)) {
92522 + *base_fqid = 0;
92523 + _fmt_err("Failed to alloc pcd fqs rang.\n");
92524 + _err = -EINVAL;
92525 + goto _pcd_alloc_fqs_err;
92526 + }
92527 +
92528 + _fmt_dbg("wanted %d fqs(align %d), got %d fqids@%u.\n",
92529 + num, alignment, num_allocated, *base_fqid);
92530 +
92531 + /* alloc pcd queues */
92532 + fmt_port_pcd->fmt_pcd_fqs = kmalloc(num_allocated *
92533 + sizeof(struct fmt_fqs_s),
92534 + GFP_KERNEL);
92535 + fmt_port_pcd->num_queues = num_allocated;
92536 + fmt_port_pcd->fqid_base = *base_fqid;
92537 + fmt_fqs = fmt_port_pcd->fmt_pcd_fqs;
92538 +
92539 + /* alloc the pcd queues */
92540 + for (i = 0; i < num_allocated; i++, fmt_fqs++) {
92541 + _err = fmt_fq_alloc(
92542 + fmt_fqs,
92543 + &pcd_fq,
92544 + (*base_fqid) + i, QMAN_FQ_FLAG_NO_ENQUEUE,
92545 + dpa_priv->channel, 7);
92546 +
92547 + if (_err < 0)
92548 + goto _pcd_alloc_fqs_err;
92549 +
92550 + /* upcast to identify from where the frames came from */
92551 + fmt_fqs->fmt_port_priv = fmt_port;
92552 + }
92553 +
92554 + _fmt_dbg("called.\n");
92555 + return _err;
92556 +_pcd_alloc_fqs_err:
92557 + if (num_allocated > 0)
92558 + qman_release_fqid_range(*base_fqid, num_allocated);
92559 + /*TODO: free fmt_pcd_fqs if are any */
92560 +
92561 + _fmt_dbg("called(_err:%d).\n", _err);
92562 + return _err;
92563 +}
92564 +
92565 +/* defined as weak in dpaa driver. */
92566 +int dpa_free_pcd_fqids(
92567 + struct device *dev,
92568 + uint32_t base_fqid)
92569 +{
92570 +
92571 + int _err = 0, i;
92572 + struct net_device *net_dev = NULL;
92573 + struct dpa_priv_s *dpa_priv = NULL;
92574 + struct fmt_port_pcd_s *fmt_port_pcd = NULL;
92575 + struct fmt_fqs_s *fmt_fqs = NULL;
92576 + struct fmt_port_s *fmt_port = NULL;
92577 + int num_allocated = 0;
92578 +
92579 + _fmt_dbg("calling...\n");
92580 +
92581 + net_dev = (typeof(net_dev))dev_get_drvdata(dev);
92582 + dpa_priv = (typeof(dpa_priv))netdev_priv(net_dev);
92583 +
92584 + if (!netif_msg_probe(dpa_priv)) {
92585 + _fmt_err("dpa not probe.\n");
92586 + _err = -ENODEV;
92587 + goto _pcd_free_fqs_err;
92588 + }
92589 +
92590 + fmt_port = match_dpa_to_fmt_port(dpa_priv);
92591 + if (!fmt_port) {
92592 + _fmt_err("fmt port not found.");
92593 + _err = -EINVAL;
92594 + goto _pcd_free_fqs_err;
92595 + }
92596 +
92597 + fmt_port_pcd = &fmt_port->fmt_port_pcd;
92598 + num_allocated = fmt_port_pcd->num_queues;
92599 + fmt_fqs = fmt_port_pcd->fmt_pcd_fqs;
92600 +
92601 + for (i = 0; i < num_allocated; i++, fmt_fqs++)
92602 + fmt_fq_free(fmt_fqs);
92603 +
92604 + qman_release_fqid_range(base_fqid,num_allocated);
92605 +
92606 + kfree(fmt_port_pcd->fmt_pcd_fqs);
92607 + memset(fmt_port_pcd, 0, sizeof(*fmt_port_pcd));
92608 +
92609 + /* debugging stuff */
92610 +#if defined(FMT_K_DBG) || defined(FMT_K_DBG_RUNTIME)
92611 + _fmt_dbg(" portid: %u.\n", fmt_port->id);
92612 + _fmt_dbg(" frames enqueue to qman: %u.\n",
92613 + atomic_read(&fmt_port->enqueue_to_qman_frm));
92614 + _fmt_dbg(" frames enqueue to rxq: %u.\n",
92615 + atomic_read(&fmt_port->enqueue_to_rxq));
92616 + _fmt_dbg(" frames dequeue from rxq: %u.\n",
92617 + atomic_read(&fmt_port->dequeue_from_rxq));
92618 + _fmt_dbg(" frames not enqueue to rxq - wrong frm: %u.\n",
92619 + atomic_read(&fmt_port->not_enqueue_to_rxq_wrong_frm));
92620 + atomic_set(&fmt_port->enqueue_to_qman_frm, 0);
92621 + atomic_set(&fmt_port->enqueue_to_rxq, 0);
92622 + atomic_set(&fmt_port->dequeue_from_rxq, 0);
92623 + atomic_set(&fmt_port->not_enqueue_to_rxq_wrong_frm, 0);
92624 +#endif
92625 + return 0;
92626 +
92627 +_pcd_free_fqs_err:
92628 + return _err;
92629 +}
92630 +
92631 +static int fmt_port_init(
92632 + struct fmt_port_s *fmt_port,
92633 + ioc_fmt_port_param_t *p_Params)
92634 +{
92635 + struct device_node *fm_node, *fm_port_node;
92636 + const uint32_t *uint32_prop;
92637 + int _errno = 0, lenp = 0, i;
92638 + static struct of_device_id fm_node_of_match[] = {
92639 + { .compatible = "fsl,fman", },
92640 + { /* end of list */ },
92641 + };
92642 +
92643 + _fmt_dbg("calling...\n");
92644 +
92645 + /* init send/receive tu US list */
92646 + INIT_LIST_HEAD(&fmt_port->rx_q);
92647 +
92648 + /* check parameters */
92649 + if (p_Params->num_tx_queues > FMAN_TEST_MAX_TX_FQS ||
92650 + p_Params->fm_port_id > IOC_FMT_MAX_NUM_OF_PORTS) {
92651 + _fmt_dbg("wrong test parameters.\n");
92652 + return -EINVAL;
92653 + }
92654 +
92655 + /* set port parameters */
92656 + fmt_port->num_of_tx_fqs = p_Params->num_tx_queues;
92657 + fmt_port->id = p_Params->fm_port_id;
92658 + fmt_port->port_type = p_Params->fm_port_type;
92659 + fmt_port->diag = e_IOC_DIAG_MODE_NONE;
92660 +
92661 + /* init debugging stuff */
92662 +#if defined(FMT_K_DBG) || defined(FMT_K_DBG_RUNTIME)
92663 + atomic_set(&fmt_port->enqueue_to_qman_frm, 0);
92664 + atomic_set(&fmt_port->enqueue_to_rxq, 0);
92665 + atomic_set(&fmt_port->dequeue_from_rxq, 0);
92666 + atomic_set(&fmt_port->not_enqueue_to_rxq_wrong_frm, 0);
92667 +#endif
92668 +
92669 + /* TODO: This should be done at probe time not at runtime
92670 + * very ugly function */
92671 + /* fill fmt port properties from dts */
92672 + for_each_matching_node(fm_node, fm_node_of_match) {
92673 +
92674 + uint32_prop = (uint32_t *)of_get_property(fm_node,
92675 + "cell-index", &lenp);
92676 + if (unlikely(uint32_prop == NULL)) {
92677 + _fmt_wrn("of_get_property(%s, cell-index) invalid",
92678 + fm_node->full_name);
92679 + return -EINVAL;
92680 + }
92681 + if (WARN_ON(lenp != sizeof(uint32_t))) {
92682 + _fmt_wrn("of_get_property(%s, cell-index) invalid",
92683 + fm_node->full_name);
92684 + return -EINVAL;
92685 + }
92686 +
92687 + if (*uint32_prop == p_Params->fm_id) {
92688 + struct resource res;
92689 +
92690 + /* Get the FM address */
92691 + _errno = of_address_to_resource(fm_node, 0, &res);
92692 + if (unlikely(_errno < 0)) {
92693 + _fmt_wrn("of_address_to_resource() = %u.\n", _errno);
92694 + return -EINVAL;
92695 + }
92696 +
92697 + fmt_port->fm_phys_base_addr = res.start;
92698 +
92699 + for_each_child_of_node(fm_node, fm_port_node) {
92700 + struct platform_device *of_dev;
92701 +
92702 + if (!of_device_is_available(fm_port_node))
92703 + continue;
92704 +
92705 + uint32_prop = (uint32_t *)of_get_property(
92706 + fm_port_node,
92707 + "cell-index",
92708 + &lenp);
92709 + if (uint32_prop == NULL)
92710 + continue;
92711 +
92712 + if (of_device_is_compatible(fm_port_node,
92713 + "fsl,fman-port-oh") &&
92714 + (fmt_port->port_type == e_IOC_FMT_PORT_T_OP)) {
92715 +
92716 + if (*uint32_prop == fmt_port->id) {
92717 + of_dev = of_find_device_by_node(fm_port_node);
92718 + if (unlikely(of_dev == NULL)) {
92719 + _fmt_wrn("fm id invalid\n");
92720 + return -EINVAL;
92721 + }
92722 +
92723 + fmt_port->p_tx_port =
92724 + fm_port_bind(&of_dev->dev);
92725 + fmt_port->p_tx_fm_port_dev =
92726 + (void *)fm_port_get_handle(
92727 + fmt_port->p_tx_port);
92728 + fmt_port->p_rx_port =
92729 + fmt_port->p_tx_port;
92730 + fmt_port->p_rx_fm_port_dev =
92731 + fmt_port->p_tx_fm_port_dev;
92732 + fmt_port->p_mac_dev = NULL;
92733 + break;
92734 + }
92735 + } else if ((*uint32_prop == fmt_port->id) &&
92736 + fmt_port->port_type == e_IOC_FMT_PORT_T_RXTX) {
92737 +
92738 + of_dev = of_find_device_by_node(fm_port_node);
92739 + if (unlikely(of_dev == NULL)) {
92740 + _fmt_wrn("dtb fm id invalid value");
92741 + return -EINVAL;
92742 + }
92743 +
92744 + if (of_device_is_compatible(fm_port_node,
92745 + "fsl,fman-port-1g-tx")) {
92746 + fmt_port->p_tx_port =
92747 + fm_port_bind(&of_dev->dev);
92748 + fmt_port->p_tx_fm_port_dev = (void *)
92749 + fm_port_get_handle(
92750 + fmt_port->p_tx_port);
92751 + } else if (of_device_is_compatible(fm_port_node,
92752 + "fsl,fman-port-1g-rx")) {
92753 + fmt_port->p_rx_port =
92754 + fm_port_bind(&of_dev->dev);
92755 + fmt_port->p_rx_fm_port_dev = (void *)
92756 + fm_port_get_handle(
92757 + fmt_port->p_rx_port);
92758 + } else if (of_device_is_compatible(fm_port_node,
92759 + "fsl,fman-1g-mac") ||
92760 + of_device_is_compatible(fm_port_node,
92761 + "fsl,fman-memac"))
92762 + fmt_port->p_mac_dev =
92763 + (typeof(fmt_port->p_mac_dev))
92764 + dev_get_drvdata(&of_dev->dev);
92765 + else
92766 + continue;
92767 +
92768 + if (fmt_port->p_tx_fm_port_dev &&
92769 + fmt_port->p_rx_fm_port_dev && fmt_port->p_mac_dev)
92770 + break;
92771 + } else if (((*uint32_prop + FM_MAX_NUM_OF_1G_RX_PORTS) ==
92772 + fmt_port->id) &&
92773 + fmt_port->port_type == e_IOC_FMT_PORT_T_RXTX) {
92774 +
92775 + of_dev = of_find_device_by_node(fm_port_node);
92776 + if (unlikely(of_dev == NULL)) {
92777 + _fmt_wrn("dtb fm id invalid value\n");
92778 + return -EINVAL;
92779 + }
92780 +
92781 + if (of_device_is_compatible(fm_port_node,
92782 + "fsl,fman-port-10g-tx")) {
92783 + fmt_port->p_tx_port =
92784 + fm_port_bind(&of_dev->dev);
92785 + fmt_port->p_tx_fm_port_dev = (void *)
92786 + fm_port_get_handle(
92787 + fmt_port->p_tx_port);
92788 + } else if (of_device_is_compatible(fm_port_node,
92789 + "fsl,fman-port-10g-rx")) {
92790 + fmt_port->p_rx_port =
92791 + fm_port_bind(&of_dev->dev);
92792 + fmt_port->p_rx_fm_port_dev = (void *)
92793 + fm_port_get_handle(
92794 + fmt_port->p_rx_port);
92795 + } else if (of_device_is_compatible(fm_port_node,
92796 + "fsl,fman-10g-mac") ||
92797 + of_device_is_compatible(fm_port_node,
92798 + "fsl,fman-memac"))
92799 + fmt_port->p_mac_dev =
92800 + (typeof(fmt_port->p_mac_dev))
92801 + dev_get_drvdata(&of_dev->dev);
92802 + else
92803 + continue;
92804 +
92805 + if (fmt_port->p_tx_fm_port_dev &&
92806 + fmt_port->p_rx_fm_port_dev && fmt_port->p_mac_dev)
92807 + break;
92808 + }
92809 + } /* for_each_child */
92810 + }
92811 + } /* for each matching node */
92812 +
92813 + if (fmt_port->p_tx_fm_port_dev == 0 ||
92814 + fmt_port->p_rx_fm_port_dev == 0) {
92815 +
92816 + _fmt_err("bad fm port pointers.\n");
92817 + return -EINVAL;
92818 + }
92819 +
92820 + _fmt_dbg("alloc %u tx queues.\n", fmt_port->num_of_tx_fqs);
92821 +
92822 + /* init fman test egress dynamic frame queues */
92823 + for (i = 0; i < fmt_port->num_of_tx_fqs; i++) {
92824 + int _errno;
92825 + _errno = fmt_fq_alloc(
92826 + &fmt_port->p_tx_fqs[i],
92827 + &fmt_egress_fq,
92828 + 0,
92829 + QMAN_FQ_FLAG_TO_DCPORTAL,
92830 + fm_get_tx_port_channel(fmt_port->p_tx_port),
92831 + i);
92832 +
92833 + if (_errno < 0) {
92834 + _fmt_err("tx queues allocation failed.\n");
92835 + /* TODO: memory leak here if 1 queue is allocated and
92836 + * next queues are failing ... */
92837 + return -EINVAL;
92838 + }
92839 + }
92840 +
92841 + /* port is valid and ready to use. */
92842 + fmt_port->valid = TRUE;
92843 +
92844 + _fmt_dbg("called.\n");
92845 + return 0;
92846 +}
92847 +
92848 +/* fm test chardev functions */
92849 +static int fmt_open(struct inode *inode, struct file *file)
92850 +{
92851 + unsigned int minor = iminor(inode);
92852 +
92853 + _fmt_dbg("calling...\n");
92854 +
92855 + if (file->private_data != NULL)
92856 + return 0;
92857 +
92858 + /* The minor represent the port number.
92859 + * Set the port structure accordingly, thus all the operations
92860 + * will be done on this port. */
92861 + if ((minor >= DEV_FM_TEST_PORTS_MINOR_BASE) &&
92862 + (minor < DEV_FM_TEST_MAX_MINORS))
92863 + file->private_data = &fm_test.ports[minor];
92864 + else
92865 + return -ENXIO;
92866 +
92867 + _fmt_dbg("called.\n");
92868 + return 0;
92869 +}
92870 +
92871 +static int fmt_close(struct inode *inode, struct file *file)
92872 +{
92873 + struct fmt_port_s *fmt_port = NULL;
92874 + struct fmt_frame_s *fmt_frame = NULL;
92875 +
92876 + int err = 0;
92877 +
92878 + _fmt_dbg("calling...\n");
92879 +
92880 + fmt_port = file->private_data;
92881 + if (!fmt_port)
92882 + return -ENODEV;
92883 +
92884 + /* Close the current test port by invalidating it. */
92885 + fmt_port->valid = FALSE;
92886 +
92887 + /* clean the fmt port queue */
92888 + while ((fmt_frame = dequeue_fmt_frame(fmt_port)) != NULL) {
92889 + if (fmt_frame && fmt_frame->buff.p_data){
92890 + kfree(fmt_frame->buff.p_data);
92891 + kfree(fmt_frame);
92892 + }
92893 + }
92894 +
92895 + /* !!! the qman queues are cleaning from fm_ioctl...
92896 + * - very ugly */
92897 +
92898 + _fmt_dbg("called.\n");
92899 + return err;
92900 +}
92901 +
92902 +static int fmt_ioctls(unsigned int minor,
92903 + struct file *file,
92904 + unsigned int cmd,
92905 + unsigned long arg,
92906 + bool compat)
92907 +{
92908 + struct fmt_port_s *fmt_port = NULL;
92909 +
92910 + _fmt_dbg("IOCTL minor:%u "
92911 + " arg:0x%08lx ioctl cmd (0x%08x):(0x%02x:0x%02x.\n",
92912 + minor, arg, cmd, _IOC_TYPE(cmd), _IOC_NR(cmd));
92913 +
92914 + fmt_port = file->private_data;
92915 + if (!fmt_port) {
92916 + _fmt_err("invalid fmt port.\n");
92917 + return -ENODEV;
92918 + }
92919 +
92920 + /* set test type properly */
92921 + if (compat)
92922 + fmt_port->compat_test_type = true;
92923 + else
92924 + fmt_port->compat_test_type = false;
92925 +
92926 + switch (cmd) {
92927 + case FMT_PORT_IOC_INIT:
92928 + {
92929 + ioc_fmt_port_param_t param;
92930 +
92931 + if (fmt_port->valid) {
92932 + _fmt_wrn("port is already initialized.\n");
92933 + return -EFAULT;
92934 + }
92935 +#if defined(CONFIG_COMPAT)
92936 + if (compat) {
92937 + if (copy_from_user(&param,
92938 + (ioc_fmt_port_param_t *)compat_ptr(arg),
92939 + sizeof(ioc_fmt_port_param_t)))
92940 +
92941 + return -EFAULT;
92942 + } else
92943 +#endif
92944 + {
92945 + if (copy_from_user(&param,
92946 + (ioc_fmt_port_param_t *) arg,
92947 + sizeof(ioc_fmt_port_param_t)))
92948 +
92949 + return -EFAULT;
92950 + }
92951 +
92952 + return fmt_port_init(fmt_port, &param);
92953 + }
92954 +
92955 + case FMT_PORT_IOC_SET_DIAG_MODE:
92956 + if (get_user(fmt_port->diag, (ioc_diag_mode *)arg))
92957 + return -EFAULT;
92958 +
92959 + if (fmt_port->diag == e_IOC_DIAG_MODE_CTRL_LOOPBACK)
92960 + return set_mac_int_loopback(fmt_port, TRUE);
92961 + else
92962 + return set_mac_int_loopback(fmt_port, FALSE);
92963 + break;
92964 +
92965 + case FMT_PORT_IOC_SET_DPAECHO_MODE:
92966 + case FMT_PORT_IOC_SET_IP_HEADER_MANIP:
92967 + default:
92968 + _fmt_wrn("ioctl unimplemented minor:%u@ioctl"
92969 + " cmd:0x%08x(type:0x%02x, nr:0x%02x.\n",
92970 + minor, cmd, _IOC_TYPE(cmd), _IOC_NR(cmd));
92971 + return -EFAULT;
92972 + }
92973 +
92974 + return 0;
92975 +}
92976 +
92977 +#ifdef CONFIG_COMPAT
92978 +static long fmt_compat_ioctl(
92979 + struct file *file,
92980 + unsigned int cmd,
92981 + unsigned long arg)
92982 +{
92983 + unsigned int minor = iminor(file->f_path.dentry->d_inode);
92984 +
92985 + _fmt_dbg("calling...\n");
92986 + return fmt_ioctls(minor, file, cmd, arg, true);
92987 +}
92988 +#endif
92989 +
92990 +static long fmt_ioctl(
92991 + struct file *file,
92992 + unsigned int cmd,
92993 + unsigned long arg)
92994 +{
92995 + unsigned int minor = iminor(file->f_path.dentry->d_inode);
92996 + unsigned int res;
92997 +
92998 + _fmt_dbg("calling...\n");
92999 +
93000 + fm_mutex_lock();
93001 + res = fmt_ioctls(minor, file, cmd, arg, false);
93002 + fm_mutex_unlock();
93003 +
93004 + _fmt_dbg("called.\n");
93005 +
93006 + return res;
93007 +}
93008 +
93009 +#ifdef CONFIG_COMPAT
93010 +void copy_compat_test_frame_buffer(
93011 + ioc_fmt_buff_desc_t *buff,
93012 + ioc_fmt_compat_buff_desc_t *compat_buff)
93013 +{
93014 + compat_buff->qid = buff->qid;
93015 + compat_buff->p_data = ptr_to_compat(buff->p_data);
93016 + compat_buff->size = buff->size;
93017 + compat_buff->status = buff->status;
93018 +
93019 + compat_buff->buff_context.p_user_priv =
93020 + ptr_to_compat(buff->buff_context.p_user_priv);
93021 + memcpy(compat_buff->buff_context.fm_prs_res,
93022 + buff->buff_context.fm_prs_res,
93023 + FM_PRS_MAX * sizeof(uint8_t));
93024 + memcpy(compat_buff->buff_context.fm_time_stamp,
93025 + buff->buff_context.fm_time_stamp,
93026 + FM_TIME_STAMP_MAX * sizeof(uint8_t));
93027 +}
93028 +#endif
93029 +
93030 +ssize_t fmt_read(
93031 + struct file *file,
93032 + char __user *buf,
93033 + size_t size,
93034 + loff_t *ppos)
93035 +{
93036 + struct fmt_port_s *fmt_port = NULL;
93037 + struct fmt_frame_s *p_fmt_frame = NULL;
93038 + ssize_t cnt = 0;
93039 +
93040 + fmt_port = file->private_data;
93041 + if (!fmt_port || !fmt_port->valid) {
93042 + _fmt_err("fmt port not valid!\n");
93043 + return -ENODEV;
93044 + }
93045 +
93046 + p_fmt_frame = dequeue_fmt_frame(fmt_port);
93047 + if (p_fmt_frame == NULL)
93048 + return 0;
93049 +
93050 + _fmt_dbgr("calling...\n");
93051 +
93052 +#ifdef CONFIG_COMPAT
93053 + if (fmt_port->compat_test_type){
93054 + cnt = sizeof(ioc_fmt_compat_buff_desc_t);
93055 + }
93056 + else
93057 +#endif
93058 + {
93059 + cnt = sizeof(ioc_fmt_buff_desc_t);
93060 + }
93061 +
93062 + if (size < cnt) {
93063 + _fmt_err("illegal buffer-size!\n");
93064 + cnt = 0;
93065 + goto _fmt_read_return;
93066 + }
93067 +
93068 + /* Copy structure */
93069 +#ifdef CONFIG_COMPAT
93070 + if (fmt_port->compat_test_type) {
93071 + {
93072 + ioc_fmt_compat_buff_desc_t compat_buff;
93073 + copy_compat_test_frame_buffer(&p_fmt_frame->buff,
93074 + &compat_buff);
93075 +
93076 + if (copy_to_user(buf, &compat_buff, cnt)) {
93077 + _fmt_err("copy_to_user failed!\n");
93078 + goto _fmt_read_return;
93079 + }
93080 + }
93081 +
93082 + ((ioc_fmt_compat_buff_desc_t *)buf)->p_data =
93083 + ptr_to_compat(buf+sizeof(ioc_fmt_compat_buff_desc_t));
93084 + cnt += MIN(p_fmt_frame->buff.size, size-cnt);
93085 + } else
93086 +#endif
93087 + {
93088 + if (copy_to_user(buf, &p_fmt_frame->buff, cnt)) {
93089 + _fmt_err("copy_to_user failed!\n");
93090 + goto _fmt_read_return;
93091 + }
93092 +
93093 + ((ioc_fmt_buff_desc_t *)buf)->p_data =
93094 + buf + sizeof(ioc_fmt_buff_desc_t);
93095 + cnt += MIN(p_fmt_frame->buff.size, size-cnt);
93096 + }
93097 +
93098 + if (size < cnt) {
93099 + _fmt_err("illegal buffer-size!\n");
93100 + goto _fmt_read_return;
93101 + }
93102 +
93103 + /* copy frame */
93104 +#ifdef CONFIG_COMPAT
93105 + if (fmt_port->compat_test_type) {
93106 + if (copy_to_user(buf+sizeof(ioc_fmt_compat_buff_desc_t),
93107 + p_fmt_frame->buff.p_data, cnt)) {
93108 + _fmt_err("copy_to_user failed!\n");
93109 + goto _fmt_read_return;
93110 + }
93111 + } else
93112 +#endif
93113 + {
93114 + if (copy_to_user(buf+sizeof(ioc_fmt_buff_desc_t),
93115 + p_fmt_frame->buff.p_data, cnt)) {
93116 + _fmt_err("copy_to_user failed!\n");
93117 + goto _fmt_read_return;
93118 + }
93119 + }
93120 +
93121 +_fmt_read_return:
93122 + kfree(p_fmt_frame->buff.p_data);
93123 + kfree(p_fmt_frame);
93124 +
93125 + _fmt_dbgr("called.\n");
93126 + return cnt;
93127 +}
93128 +
93129 +ssize_t fmt_write(
93130 + struct file *file,
93131 + const char __user *buf,
93132 + size_t size,
93133 + loff_t *ppos)
93134 +{
93135 + struct fmt_port_s *fmt_port = NULL;
93136 + ioc_fmt_buff_desc_t buff_desc;
93137 +#ifdef CONFIG_COMPAT
93138 + ioc_fmt_compat_buff_desc_t buff_desc_compat;
93139 +#endif
93140 + uint8_t *p_data = NULL;
93141 + uint32_t data_offset;
93142 + int _errno;
93143 + t_DpaaFD fd;
93144 +
93145 + _fmt_dbgr("calling...\n");
93146 +
93147 + fmt_port = file->private_data;
93148 + if (!fmt_port || !fmt_port->valid) {
93149 + _fmt_err("fmt port not valid.\n");
93150 + return -EINVAL;
93151 + }
93152 +
93153 + /* If Compat (32B UserSpace - 64B KernelSpace) */
93154 +#ifdef CONFIG_COMPAT
93155 + if (fmt_port->compat_test_type) {
93156 + if (size < sizeof(ioc_fmt_compat_buff_desc_t)) {
93157 + _fmt_err("invalid buff_desc size.\n");
93158 + return -EFAULT;
93159 + }
93160 +
93161 + if (copy_from_user(&buff_desc_compat, buf,
93162 + sizeof(ioc_fmt_compat_buff_desc_t)))
93163 + return -EFAULT;
93164 +
93165 + buff_desc.qid = buff_desc_compat.qid;
93166 + buff_desc.p_data = compat_ptr(buff_desc_compat.p_data);
93167 + buff_desc.size = buff_desc_compat.size;
93168 + buff_desc.status = buff_desc_compat.status;
93169 +
93170 + buff_desc.buff_context.p_user_priv =
93171 + compat_ptr(buff_desc_compat.buff_context.p_user_priv);
93172 + memcpy(buff_desc.buff_context.fm_prs_res,
93173 + buff_desc_compat.buff_context.fm_prs_res,
93174 + FM_PRS_MAX * sizeof(uint8_t));
93175 + memcpy(buff_desc.buff_context.fm_time_stamp,
93176 + buff_desc_compat.buff_context.fm_time_stamp,
93177 + FM_TIME_STAMP_MAX * sizeof(uint8_t));
93178 + } else
93179 +#endif
93180 + {
93181 + if (size < sizeof(ioc_fmt_buff_desc_t)) {
93182 + _fmt_err("invalid buff_desc size.\n");
93183 + return -EFAULT;
93184 + }
93185 +
93186 + if (copy_from_user(&buff_desc, (ioc_fmt_buff_desc_t *)buf,
93187 + sizeof(ioc_fmt_buff_desc_t)))
93188 + return -EFAULT;
93189 + }
93190 +
93191 + data_offset = FM_PORT_GetBufferDataOffset(fmt_port->p_tx_fm_port_dev);
93192 + p_data = kmalloc(buff_desc.size+data_offset, GFP_KERNEL);
93193 + if (!p_data)
93194 + return -ENOMEM;
93195 +
93196 + /* If Compat (32UserSpace - 64KernelSpace) the buff_desc.p_data is ok */
93197 + if (copy_from_user((uint8_t *)PTR_MOVE(p_data, data_offset),
93198 + buff_desc.p_data,
93199 + buff_desc.size)) {
93200 + kfree(p_data);
93201 + return -EFAULT;
93202 + }
93203 +
93204 + /* TODO: dma_map_single here (cannot access the bpool struct) */
93205 +
93206 + /* prepare fd */
93207 + memset(&fd, 0, sizeof(fd));
93208 + DPAA_FD_SET_ADDR(&fd, p_data);
93209 + DPAA_FD_SET_OFFSET(&fd, data_offset);
93210 + DPAA_FD_SET_LENGTH(&fd, buff_desc.size);
93211 +
93212 + _errno = qman_enqueue(&fmt_port->p_tx_fqs[buff_desc.qid].fq_base,
93213 + (struct qm_fd *)&fd, 0);
93214 + if (_errno) {
93215 + buff_desc.status = (uint32_t)_errno;
93216 + if (copy_to_user((ioc_fmt_buff_desc_t *)buf, &buff_desc,
93217 + sizeof(ioc_fmt_buff_desc_t))) {
93218 + kfree(p_data);
93219 + return -EFAULT;
93220 + }
93221 + }
93222 +
93223 + /* for debugging */
93224 +#if defined(FMT_K_DBG) || defined(FMT_K_DBG_RUNTIME)
93225 + atomic_inc(&fmt_port->enqueue_to_qman_frm);
93226 +#endif
93227 + _fmt_dbgr("called.\n");
93228 + return buff_desc.size;
93229 +}
93230 +
93231 +/* fm test character device definition */
93232 +static const struct file_operations fmt_fops =
93233 +{
93234 + .owner = THIS_MODULE,
93235 +#ifdef CONFIG_COMPAT
93236 + .compat_ioctl = fmt_compat_ioctl,
93237 +#endif
93238 + .unlocked_ioctl = fmt_ioctl,
93239 + .open = fmt_open,
93240 + .release = fmt_close,
93241 + .read = fmt_read,
93242 + .write = fmt_write,
93243 +};
93244 +
93245 +static int fmt_init(void)
93246 +{
93247 + int id;
93248 +
93249 + _fmt_dbg("calling...\n");
93250 +
93251 + /* Register to the /dev for IOCTL API */
93252 + /* Register dynamically a new major number for the character device: */
93253 + fm_test.major = register_chrdev(0, DEV_FM_TEST_NAME, &fmt_fops);
93254 + if (fm_test.major <= 0) {
93255 + _fmt_wrn("Failed to allocate major number for device %s.\n",
93256 + DEV_FM_TEST_NAME);
93257 + return -ENODEV;
93258 + }
93259 +
93260 + /* Creating class for FMan_test */
93261 + fm_test.fmt_class = class_create(THIS_MODULE, DEV_FM_TEST_NAME);
93262 + if (IS_ERR(fm_test.fmt_class)) {
93263 + unregister_chrdev(fm_test.major, DEV_FM_TEST_NAME);
93264 + _fmt_wrn("Error creating %s class.\n", DEV_FM_TEST_NAME);
93265 + return -ENODEV;
93266 + }
93267 +
93268 + for (id = 0; id < IOC_FMT_MAX_NUM_OF_PORTS; id++)
93269 + if (NULL == device_create(fm_test.fmt_class, NULL,
93270 + MKDEV(fm_test.major,
93271 + DEV_FM_TEST_PORTS_MINOR_BASE + id), NULL,
93272 + DEV_FM_TEST_NAME "%d", id)) {
93273 +
93274 + _fmt_err("Error creating %s device.\n",
93275 + DEV_FM_TEST_NAME);
93276 + return -ENODEV;
93277 + }
93278 +
93279 + return 0;
93280 +}
93281 +
93282 +static void fmt_free(void)
93283 +{
93284 + int id;
93285 +
93286 + for (id = 0; id < IOC_FMT_MAX_NUM_OF_PORTS; id++)
93287 + device_destroy(fm_test.fmt_class, MKDEV(fm_test.major,
93288 + DEV_FM_TEST_PORTS_MINOR_BASE + id));
93289 + class_destroy(fm_test.fmt_class);
93290 +}
93291 +
93292 +static int __init __cold fmt_load(void)
93293 +{
93294 + struct dpaa_eth_hooks_s priv_dpaa_eth_hooks;
93295 +
93296 + /* set dpaa hooks for default queues */
93297 + memset(&priv_dpaa_eth_hooks, 0, sizeof(priv_dpaa_eth_hooks));
93298 + priv_dpaa_eth_hooks.rx_default = fmt_rx_default_hook;
93299 + priv_dpaa_eth_hooks.rx_error = fmt_rx_error_hook;
93300 + priv_dpaa_eth_hooks.tx_confirm = fmt_tx_confirm_hook;
93301 + priv_dpaa_eth_hooks.tx_error = fmt_tx_confirm_error_hook;
93302 +
93303 + fsl_dpaa_eth_set_hooks(&priv_dpaa_eth_hooks);
93304 +
93305 + /* initialize the fman test environment */
93306 + if (fmt_init() < 0) {
93307 + _fmt_err("Failed to init FM-test modul.\n");
93308 + fmt_free();
93309 + return -ENODEV;
93310 + }
93311 +
93312 + _fmt_inf("FSL FM test module loaded.\n");
93313 +
93314 + return 0;
93315 +}
93316 +
93317 +static void __exit __cold fmt_unload(void)
93318 +{
93319 + fmt_free();
93320 + _fmt_inf("FSL FM test module unloaded.\n");
93321 +}
93322 +
93323 +module_init(fmt_load);
93324 +module_exit(fmt_unload);
93325 --- /dev/null
93326 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
93327 @@ -0,0 +1,2795 @@
93328 +/*
93329 + * Copyright 2008-2012 Freescale Semiconductor Inc.
93330 + *
93331 + * Redistribution and use in source and binary forms, with or without
93332 + * modification, are permitted provided that the following conditions are met:
93333 + * * Redistributions of source code must retain the above copyright
93334 + * notice, this list of conditions and the following disclaimer.
93335 + * * Redistributions in binary form must reproduce the above copyright
93336 + * notice, this list of conditions and the following disclaimer in the
93337 + * documentation and/or other materials provided with the distribution.
93338 + * * Neither the name of Freescale Semiconductor nor the
93339 + * names of its contributors may be used to endorse or promote products
93340 + * derived from this software without specific prior written permission.
93341 + *
93342 + *
93343 + * ALTERNATIVELY, this software may be distributed under the terms of the
93344 + * GNU General Public License ("GPL") as published by the Free Software
93345 + * Foundation, either version 2 of that License or (at your option) any
93346 + * later version.
93347 + *
93348 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
93349 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
93350 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
93351 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
93352 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
93353 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
93354 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
93355 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
93356 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
93357 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
93358 + */
93359 +
93360 +/*
93361 + @File lnxwrp_fm.c
93362 + @Author Shlomi Gridish
93363 + @Description FM Linux wrapper functions.
93364 +*/
93365 +
93366 +#include <linux/version.h>
93367 +#include <linux/slab.h>
93368 +#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
93369 +#define MODVERSIONS
93370 +#endif
93371 +#ifdef MODVERSIONS
93372 +#include <config/modversions.h>
93373 +#endif /* MODVERSIONS */
93374 +#include <linux/kernel.h>
93375 +#include <linux/module.h>
93376 +#include <linux/fs.h>
93377 +#include <linux/cdev.h>
93378 +#include <linux/device.h>
93379 +#include <linux/irq.h>
93380 +#include <linux/interrupt.h>
93381 +#include <linux/io.h>
93382 +#include <linux/ioport.h>
93383 +#include <linux/of_platform.h>
93384 +#include <linux/of_address.h>
93385 +#include <linux/of_irq.h>
93386 +#include <linux/clk.h>
93387 +#include <asm/uaccess.h>
93388 +#include <asm/errno.h>
93389 +#include <linux/fsl/qe.h> /* For struct qe_firmware */
93390 +#ifndef CONFIG_FMAN_ARM
93391 +#include <sysdev/fsl_soc.h>
93392 +#include <linux/fsl/guts.h>
93393 +#endif
93394 +#include <linux/stat.h> /* For file access mask */
93395 +#include <linux/skbuff.h>
93396 +#include <linux/proc_fs.h>
93397 +
93398 +/* NetCommSw Headers --------------- */
93399 +#include "std_ext.h"
93400 +#include "error_ext.h"
93401 +#include "sprint_ext.h"
93402 +#include "debug_ext.h"
93403 +#include "sys_io_ext.h"
93404 +
93405 +#include "fm_ioctls.h"
93406 +
93407 +#include "lnxwrp_fm.h"
93408 +#include "lnxwrp_resources.h"
93409 +#include "lnxwrp_sysfs_fm.h"
93410 +#include "lnxwrp_sysfs_fm_port.h"
93411 +#include "lnxwrp_exp_sym.h"
93412 +#include "fm_common.h"
93413 +#include "../../sdk_fman/Peripherals/FM/fm.h"
93414 +#define __ERR_MODULE__ MODULE_FM
93415 +
93416 +extern struct device_node *GetFmPortAdvArgsDevTreeNode (struct device_node *fm_node,
93417 + e_FmPortType portType,
93418 + uint8_t portId);
93419 +
93420 +#define PROC_PRINT(args...) offset += sprintf(buf+offset,args)
93421 +
93422 +#define ADD_ADV_CONFIG_NO_RET(_func, _param) \
93423 + do { \
93424 + if (i<max){ \
93425 + p_Entry = &p_Entrys[i]; \
93426 + p_Entry->p_Function = _func; \
93427 + _param \
93428 + i++; \
93429 + } \
93430 + else \
93431 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,\
93432 + ("Number of advanced-configuration entries exceeded"));\
93433 + } while (0)
93434 +
93435 +/* Bootarg used to override the Kconfig FSL_FM_MAX_FRAME_SIZE value */
93436 +#define FSL_FM_MAX_FRM_BOOTARG "fsl_fm_max_frm"
93437 +
93438 +/* Bootarg used to override FSL_FM_RX_EXTRA_HEADROOM Kconfig value */
93439 +#define FSL_FM_RX_EXTRA_HEADROOM_BOOTARG "fsl_fm_rx_extra_headroom"
93440 +
93441 +/* Minimum and maximum value for the fsl_fm_rx_extra_headroom bootarg */
93442 +#define FSL_FM_RX_EXTRA_HEADROOM_MIN 16
93443 +#define FSL_FM_RX_EXTRA_HEADROOM_MAX 384
93444 +
93445 +#define FSL_FM_PAUSE_TIME_ENABLE 0xf000
93446 +#define FSL_FM_PAUSE_TIME_DISABLE 0
93447 +#define FSL_FM_PAUSE_THRESH_DEFAULT 0
93448 +
93449 +/*
93450 + * Max frame size, across all interfaces.
93451 + * Configurable from Kconfig or bootargs, to avoid allocating
93452 + * oversized (socket) buffers when not using jumbo frames.
93453 + * Must be large enough to accommodate the network MTU, but small enough
93454 + * to avoid wasting skb memory.
93455 + *
93456 + * Could be overridden once, at boot-time, via the
93457 + * fm_set_max_frm() callback.
93458 + */
93459 +int fsl_fm_max_frm = CONFIG_FSL_FM_MAX_FRAME_SIZE;
93460 +
93461 +/*
93462 + * Extra headroom for Rx buffers.
93463 + * FMan is instructed to allocate, on the Rx path, this amount of
93464 + * space at the beginning of a data buffer, beside the DPA private
93465 + * data area and the IC fields.
93466 + * Does not impact Tx buffer layout.
93467 + *
93468 + * Configurable from Kconfig or bootargs. Zero by default, it's needed
93469 + * on particular forwarding scenarios that add extra headers to the
93470 + * forwarded frame.
93471 + */
93472 +int fsl_fm_rx_extra_headroom = CONFIG_FSL_FM_RX_EXTRA_HEADROOM;
93473 +
93474 +#ifdef CONFIG_FMAN_PFC
93475 +static int fsl_fm_pfc_quanta[] = {
93476 + CONFIG_FMAN_PFC_QUANTA_0,
93477 + CONFIG_FMAN_PFC_QUANTA_1,
93478 + CONFIG_FMAN_PFC_QUANTA_2,
93479 + CONFIG_FMAN_PFC_QUANTA_3
93480 +};
93481 +#endif
93482 +
93483 +static t_LnxWrpFm lnxWrpFm;
93484 +
93485 +int fm_get_max_frm()
93486 +{
93487 + return fsl_fm_max_frm;
93488 +}
93489 +EXPORT_SYMBOL(fm_get_max_frm);
93490 +
93491 +int fm_get_rx_extra_headroom()
93492 +{
93493 + return ALIGN(fsl_fm_rx_extra_headroom, 16);
93494 +}
93495 +EXPORT_SYMBOL(fm_get_rx_extra_headroom);
93496 +
93497 +static int __init fm_set_max_frm(char *str)
93498 +{
93499 + int ret = 0;
93500 +
93501 + ret = get_option(&str, &fsl_fm_max_frm);
93502 + if (ret != 1) {
93503 + /*
93504 + * This will only work if CONFIG_EARLY_PRINTK is compiled in,
93505 + * and something like "earlyprintk=serial,uart0,115200" is
93506 + * specified in the bootargs
93507 + */
93508 + printk(KERN_WARNING "No suitable %s=<int> prop in bootargs; "
93509 + "will use the default FSL_FM_MAX_FRAME_SIZE (%d) "
93510 + "from Kconfig.\n", FSL_FM_MAX_FRM_BOOTARG,
93511 + CONFIG_FSL_FM_MAX_FRAME_SIZE);
93512 +
93513 + fsl_fm_max_frm = CONFIG_FSL_FM_MAX_FRAME_SIZE;
93514 + return 1;
93515 + }
93516 +
93517 + /* Don't allow invalid bootargs; fallback to the Kconfig value */
93518 + if (fsl_fm_max_frm < 64 || fsl_fm_max_frm > 9600) {
93519 + printk(KERN_WARNING "Invalid %s=%d in bootargs, valid range is "
93520 + "64-9600. Falling back to the FSL_FM_MAX_FRAME_SIZE (%d) "
93521 + "from Kconfig.\n",
93522 + FSL_FM_MAX_FRM_BOOTARG, fsl_fm_max_frm,
93523 + CONFIG_FSL_FM_MAX_FRAME_SIZE);
93524 +
93525 + fsl_fm_max_frm = CONFIG_FSL_FM_MAX_FRAME_SIZE;
93526 + return 1;
93527 + }
93528 +
93529 + printk(KERN_INFO "Using fsl_fm_max_frm=%d from bootargs\n",
93530 + fsl_fm_max_frm);
93531 + return 0;
93532 +}
93533 +early_param(FSL_FM_MAX_FRM_BOOTARG, fm_set_max_frm);
93534 +
93535 +static int __init fm_set_rx_extra_headroom(char *str)
93536 +{
93537 + int ret;
93538 +
93539 + ret = get_option(&str, &fsl_fm_rx_extra_headroom);
93540 +
93541 + if (ret != 1) {
93542 + printk(KERN_WARNING "No suitable %s=<int> prop in bootargs; "
93543 + "will use the default FSL_FM_RX_EXTRA_HEADROOM (%d) "
93544 + "from Kconfig.\n", FSL_FM_RX_EXTRA_HEADROOM_BOOTARG,
93545 + CONFIG_FSL_FM_RX_EXTRA_HEADROOM);
93546 + fsl_fm_rx_extra_headroom = CONFIG_FSL_FM_RX_EXTRA_HEADROOM;
93547 +
93548 + return 1;
93549 + }
93550 +
93551 + if (fsl_fm_rx_extra_headroom < FSL_FM_RX_EXTRA_HEADROOM_MIN ||
93552 + fsl_fm_rx_extra_headroom > FSL_FM_RX_EXTRA_HEADROOM_MAX) {
93553 + printk(KERN_WARNING "Invalid value for %s=%d prop in "
93554 + "bootargs; will use the default "
93555 + "FSL_FM_RX_EXTRA_HEADROOM (%d) from Kconfig.\n",
93556 + FSL_FM_RX_EXTRA_HEADROOM_BOOTARG,
93557 + fsl_fm_rx_extra_headroom,
93558 + CONFIG_FSL_FM_RX_EXTRA_HEADROOM);
93559 + fsl_fm_rx_extra_headroom = CONFIG_FSL_FM_RX_EXTRA_HEADROOM;
93560 + }
93561 +
93562 + printk(KERN_INFO "Using fsl_fm_rx_extra_headroom=%d from bootargs\n",
93563 + fsl_fm_rx_extra_headroom);
93564 +
93565 + return 0;
93566 +}
93567 +early_param(FSL_FM_RX_EXTRA_HEADROOM_BOOTARG, fm_set_rx_extra_headroom);
93568 +
93569 +static irqreturn_t fm_irq(int irq, void *_dev)
93570 +{
93571 + t_LnxWrpFmDev *p_LnxWrpFmDev = (t_LnxWrpFmDev *)_dev;
93572 +#ifdef CONFIG_PM_SLEEP
93573 + t_Fm *p_Fm = (t_Fm*)p_LnxWrpFmDev->h_Dev;
93574 +#endif
93575 + if (!p_LnxWrpFmDev || !p_LnxWrpFmDev->h_Dev)
93576 + return IRQ_NONE;
93577 +
93578 +#ifdef CONFIG_PM_SLEEP
93579 + if (fman_get_normal_pending(p_Fm->p_FmFpmRegs) & INTR_EN_WAKEUP)
93580 + {
93581 + pm_wakeup_event(p_LnxWrpFmDev->dev, 200);
93582 + }
93583 +#endif
93584 + FM_EventIsr(p_LnxWrpFmDev->h_Dev);
93585 + return IRQ_HANDLED;
93586 +}
93587 +
93588 +static irqreturn_t fm_err_irq(int irq, void *_dev)
93589 +{
93590 + t_LnxWrpFmDev *p_LnxWrpFmDev = (t_LnxWrpFmDev *)_dev;
93591 +
93592 + if (!p_LnxWrpFmDev || !p_LnxWrpFmDev->h_Dev)
93593 + return IRQ_NONE;
93594 +
93595 + if (FM_ErrorIsr(p_LnxWrpFmDev->h_Dev) == E_OK)
93596 + return IRQ_HANDLED;
93597 +
93598 + return IRQ_NONE;
93599 +}
93600 +
93601 +/* used to protect FMD/LLD from concurrent calls in functions fm_mutex_lock / fm_mutex_unlock */
93602 +static struct mutex lnxwrp_mutex;
93603 +
93604 +static t_LnxWrpFmDev * CreateFmDev(uint8_t id)
93605 +{
93606 + t_LnxWrpFmDev *p_LnxWrpFmDev;
93607 + int j;
93608 +
93609 + p_LnxWrpFmDev = (t_LnxWrpFmDev *)XX_Malloc(sizeof(t_LnxWrpFmDev));
93610 + if (!p_LnxWrpFmDev)
93611 + {
93612 + REPORT_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
93613 + return NULL;
93614 + }
93615 +
93616 + memset(p_LnxWrpFmDev, 0, sizeof(t_LnxWrpFmDev));
93617 + p_LnxWrpFmDev->fmDevSettings.advConfig = (t_SysObjectAdvConfigEntry*)XX_Malloc(FM_MAX_NUM_OF_ADV_SETTINGS*sizeof(t_SysObjectAdvConfigEntry));
93618 + memset(p_LnxWrpFmDev->fmDevSettings.advConfig, 0, (FM_MAX_NUM_OF_ADV_SETTINGS*sizeof(t_SysObjectAdvConfigEntry)));
93619 + p_LnxWrpFmDev->fmPcdDevSettings.advConfig = (t_SysObjectAdvConfigEntry*)XX_Malloc(FM_MAX_NUM_OF_ADV_SETTINGS*sizeof(t_SysObjectAdvConfigEntry));
93620 + memset(p_LnxWrpFmDev->fmPcdDevSettings.advConfig, 0, (FM_MAX_NUM_OF_ADV_SETTINGS*sizeof(t_SysObjectAdvConfigEntry)));
93621 + p_LnxWrpFmDev->hcPort.settings.advConfig = (t_SysObjectAdvConfigEntry*)XX_Malloc(FM_MAX_NUM_OF_ADV_SETTINGS*sizeof(t_SysObjectAdvConfigEntry));
93622 + memset(p_LnxWrpFmDev->hcPort.settings.advConfig, 0, (FM_MAX_NUM_OF_ADV_SETTINGS*sizeof(t_SysObjectAdvConfigEntry)));
93623 + for (j=0; j<FM_MAX_NUM_OF_RX_PORTS; j++)
93624 + {
93625 + p_LnxWrpFmDev->rxPorts[j].settings.advConfig = (t_SysObjectAdvConfigEntry*)XX_Malloc(FM_MAX_NUM_OF_ADV_SETTINGS*sizeof(t_SysObjectAdvConfigEntry));
93626 + memset(p_LnxWrpFmDev->rxPorts[j].settings.advConfig, 0, (FM_MAX_NUM_OF_ADV_SETTINGS*sizeof(t_SysObjectAdvConfigEntry)));
93627 + }
93628 + for (j=0; j<FM_MAX_NUM_OF_TX_PORTS; j++)
93629 + {
93630 + p_LnxWrpFmDev->txPorts[j].settings.advConfig = (t_SysObjectAdvConfigEntry*)XX_Malloc(FM_MAX_NUM_OF_ADV_SETTINGS*sizeof(t_SysObjectAdvConfigEntry));
93631 + memset(p_LnxWrpFmDev->txPorts[j].settings.advConfig, 0, (FM_MAX_NUM_OF_ADV_SETTINGS*sizeof(t_SysObjectAdvConfigEntry)));
93632 + }
93633 + for (j=0; j<FM_MAX_NUM_OF_OH_PORTS-1; j++)
93634 + {
93635 + p_LnxWrpFmDev->opPorts[j].settings.advConfig = (t_SysObjectAdvConfigEntry*)XX_Malloc(FM_MAX_NUM_OF_ADV_SETTINGS*sizeof(t_SysObjectAdvConfigEntry));
93636 + memset(p_LnxWrpFmDev->opPorts[j].settings.advConfig, 0, (FM_MAX_NUM_OF_ADV_SETTINGS*sizeof(t_SysObjectAdvConfigEntry)));
93637 + }
93638 +
93639 + return p_LnxWrpFmDev;
93640 +}
93641 +
93642 +static void DestroyFmDev(t_LnxWrpFmDev *p_LnxWrpFmDev)
93643 +{
93644 + int j;
93645 +
93646 + for (j=0; j<FM_MAX_NUM_OF_OH_PORTS-1; j++)
93647 + if (p_LnxWrpFmDev->opPorts[j].settings.advConfig)
93648 + XX_Free(p_LnxWrpFmDev->opPorts[j].settings.advConfig);
93649 + for (j=0; j<FM_MAX_NUM_OF_TX_PORTS; j++)
93650 + if (p_LnxWrpFmDev->txPorts[j].settings.advConfig)
93651 + XX_Free(p_LnxWrpFmDev->txPorts[j].settings.advConfig);
93652 + for (j=0; j<FM_MAX_NUM_OF_RX_PORTS; j++)
93653 + if (p_LnxWrpFmDev->rxPorts[j].settings.advConfig)
93654 + XX_Free(p_LnxWrpFmDev->rxPorts[j].settings.advConfig);
93655 + if (p_LnxWrpFmDev->hcPort.settings.advConfig)
93656 + XX_Free(p_LnxWrpFmDev->hcPort.settings.advConfig);
93657 + if (p_LnxWrpFmDev->fmPcdDevSettings.advConfig)
93658 + XX_Free(p_LnxWrpFmDev->fmPcdDevSettings.advConfig);
93659 + if (p_LnxWrpFmDev->fmDevSettings.advConfig)
93660 + XX_Free(p_LnxWrpFmDev->fmDevSettings.advConfig);
93661 +
93662 + XX_Free(p_LnxWrpFmDev);
93663 +}
93664 +
93665 +static t_Error FillRestFmInfo(t_LnxWrpFmDev *p_LnxWrpFmDev)
93666 +{
93667 +#define FM_BMI_PPIDS_OFFSET 0x00080304
93668 +#define FM_DMA_PLR_OFFSET 0x000c2060
93669 +#define FM_FPM_IP_REV_1_OFFSET 0x000c30c4
93670 +#define DMA_HIGH_LIODN_MASK 0x0FFF0000
93671 +#define DMA_LOW_LIODN_MASK 0x00000FFF
93672 +#define DMA_LIODN_SHIFT 16
93673 +
93674 +typedef _Packed struct {
93675 + uint32_t plr[32];
93676 +} _PackedType t_Plr;
93677 +
93678 +typedef _Packed struct {
93679 + volatile uint32_t fmbm_ppid[63];
93680 +} _PackedType t_Ppids;
93681 +
93682 + t_Plr *p_Plr;
93683 + t_Ppids *p_Ppids;
93684 + int i,j;
93685 + uint32_t fmRev;
93686 +
93687 + static const uint8_t phys1GRxPortId[] = {0x8,0x9,0xa,0xb,0xc,0xd,0xe,0xf};
93688 + static const uint8_t phys10GRxPortId[] = {0x10,0x11};
93689 +#if (DPAA_VERSION >= 11)
93690 + static const uint8_t physOhPortId[] = {/* 0x1, */0x2,0x3,0x4,0x5,0x6,0x7};
93691 +#else
93692 + static const uint8_t physOhPortId[] = {0x1,0x2,0x3,0x4,0x5,0x6,0x7};
93693 +#endif
93694 + static const uint8_t phys1GTxPortId[] = {0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f};
93695 + static const uint8_t phys10GTxPortId[] = {0x30,0x31};
93696 +
93697 + fmRev = (uint32_t)(*((volatile uint32_t *)UINT_TO_PTR(p_LnxWrpFmDev->fmBaseAddr+FM_FPM_IP_REV_1_OFFSET)));
93698 + fmRev &= 0xffff;
93699 +
93700 + p_Plr = (t_Plr *)UINT_TO_PTR(p_LnxWrpFmDev->fmBaseAddr+FM_DMA_PLR_OFFSET);
93701 +#ifdef MODULE
93702 + for (i=0;i<FM_MAX_NUM_OF_PARTITIONS/2;i++)
93703 + p_Plr->plr[i] = 0;
93704 +#endif /* MODULE */
93705 +
93706 + for (i=0; i<FM_MAX_NUM_OF_PARTITIONS; i++)
93707 + {
93708 + uint16_t liodnBase = (uint16_t)((i%2) ?
93709 + (p_Plr->plr[i/2] & DMA_LOW_LIODN_MASK) :
93710 + ((p_Plr->plr[i/2] & DMA_HIGH_LIODN_MASK) >> DMA_LIODN_SHIFT));
93711 +#ifdef FM_PARTITION_ARRAY
93712 + /* TODO: this was .liodnPerPartition[i] = liodnBase; is the index meaning the same? */
93713 + p_LnxWrpFmDev->fmDevSettings.param.liodnBasePerPort[i] = liodnBase;
93714 +#endif /* FM_PARTITION_ARRAY */
93715 +
93716 + if ((i >= phys1GRxPortId[0]) &&
93717 + (i <= phys1GRxPortId[FM_MAX_NUM_OF_1G_RX_PORTS-1]))
93718 + {
93719 + for (j=0; j<ARRAY_SIZE(phys1GRxPortId); j++)
93720 + if (phys1GRxPortId[j] == i)
93721 + break;
93722 + ASSERT_COND(j<ARRAY_SIZE(phys1GRxPortId));
93723 + p_LnxWrpFmDev->rxPorts[j].settings.param.liodnBase = liodnBase;
93724 + }
93725 + else if (FM_MAX_NUM_OF_10G_RX_PORTS &&
93726 + (i >= phys10GRxPortId[0]) &&
93727 + (i <= phys10GRxPortId[FM_MAX_NUM_OF_10G_RX_PORTS-1]))
93728 + {
93729 + for (j=0; j<ARRAY_SIZE(phys10GRxPortId); j++)
93730 + if (phys10GRxPortId[j] == i)
93731 + break;
93732 + ASSERT_COND(j<ARRAY_SIZE(phys10GRxPortId));
93733 + p_LnxWrpFmDev->rxPorts[FM_MAX_NUM_OF_1G_RX_PORTS+j].settings.param.liodnBase = liodnBase;
93734 + }
93735 + else if ((i >= physOhPortId[0]) &&
93736 + (i <= physOhPortId[FM_MAX_NUM_OF_OH_PORTS-1]))
93737 + {
93738 + for (j=0; j<ARRAY_SIZE(physOhPortId); j++)
93739 + if (physOhPortId[j] == i)
93740 + break;
93741 + ASSERT_COND(j<ARRAY_SIZE(physOhPortId));
93742 + if (j == 0)
93743 + p_LnxWrpFmDev->hcPort.settings.param.liodnBase = liodnBase;
93744 + else
93745 + p_LnxWrpFmDev->opPorts[j - 1].settings.param.liodnBase = liodnBase;
93746 + }
93747 + else if ((i >= phys1GTxPortId[0]) &&
93748 + (i <= phys1GTxPortId[FM_MAX_NUM_OF_1G_TX_PORTS-1]))
93749 + {
93750 + for (j=0; j<ARRAY_SIZE(phys1GTxPortId); j++)
93751 + if (phys1GTxPortId[j] == i)
93752 + break;
93753 + ASSERT_COND(j<ARRAY_SIZE(phys1GTxPortId));
93754 + p_LnxWrpFmDev->txPorts[j].settings.param.liodnBase = liodnBase;
93755 + }
93756 + else if (FM_MAX_NUM_OF_10G_TX_PORTS &&
93757 + (i >= phys10GTxPortId[0]) &&
93758 + (i <= phys10GTxPortId[FM_MAX_NUM_OF_10G_TX_PORTS-1]))
93759 + {
93760 + for (j=0; j<ARRAY_SIZE(phys10GTxPortId); j++)
93761 + if (phys10GTxPortId[j] == i)
93762 + break;
93763 + ASSERT_COND(j<ARRAY_SIZE(phys10GTxPortId));
93764 + p_LnxWrpFmDev->txPorts[FM_MAX_NUM_OF_1G_TX_PORTS+j].settings.param.liodnBase = liodnBase;
93765 + }
93766 + }
93767 +
93768 + p_Ppids = (t_Ppids *)UINT_TO_PTR(p_LnxWrpFmDev->fmBaseAddr+FM_BMI_PPIDS_OFFSET);
93769 +
93770 + for (i=0; i<FM_MAX_NUM_OF_1G_RX_PORTS; i++)
93771 + p_LnxWrpFmDev->rxPorts[i].settings.param.specificParams.rxParams.liodnOffset =
93772 + p_Ppids->fmbm_ppid[phys1GRxPortId[i]-1];
93773 +
93774 + for (i=0; i<FM_MAX_NUM_OF_10G_RX_PORTS; i++)
93775 + p_LnxWrpFmDev->rxPorts[FM_MAX_NUM_OF_1G_RX_PORTS+i].settings.param.specificParams.rxParams.liodnOffset =
93776 + p_Ppids->fmbm_ppid[phys10GRxPortId[i]-1];
93777 +
93778 + return E_OK;
93779 +}
93780 +
93781 +/**
93782 + * FindFmanMicrocode - find the Fman microcode
93783 + *
93784 + * This function returns a pointer to the QE Firmware blob that holds
93785 + * the Fman microcode. We use the QE Firmware structure because Fman microcode
93786 + * is similar to QE microcode, so there's no point in defining a new layout.
93787 + *
93788 + * Current versions of U-Boot embed the Fman firmware into the device tree,
93789 + * so we check for that first. Each Fman node in the device tree contains a
93790 + * node or a pointer to node that holds the firmware. Technically, we should
93791 + * be fetching the firmware node for the current Fman, but we don't have that
93792 + * information any more, so we assume that there is only one firmware node in
93793 + * the device tree, and that all Fmen use the same firmware.
93794 + */
93795 +static const struct qe_firmware *FindFmanMicrocode(void)
93796 +{
93797 + static const struct qe_firmware *P4080_UCPatch;
93798 + struct device_node *np;
93799 +
93800 + if (P4080_UCPatch)
93801 + return P4080_UCPatch;
93802 +
93803 + /* The firmware should be inside the device tree. */
93804 + np = of_find_compatible_node(NULL, NULL, "fsl,fman-firmware");
93805 + if (np) {
93806 + P4080_UCPatch = of_get_property(np, "fsl,firmware", NULL);
93807 + of_node_put(np);
93808 + if (P4080_UCPatch)
93809 + return P4080_UCPatch;
93810 + else
93811 + REPORT_ERROR(WARNING, E_NOT_FOUND, ("firmware node is incomplete"));
93812 + }
93813 +
93814 + /* Returning NULL here forces the reuse of the IRAM content */
93815 + return NULL;
93816 +}
93817 +#define SVR_SECURITY_MASK 0x00080000
93818 +#define SVR_PERSONALITY_MASK 0x0000FF00
93819 +#define SVR_VER_IGNORE_MASK (SVR_SECURITY_MASK | SVR_PERSONALITY_MASK)
93820 +#define SVR_B4860_REV1_VALUE 0x86800010
93821 +#define SVR_B4860_REV2_VALUE 0x86800020
93822 +#define SVR_T4240_VALUE 0x82400000
93823 +#define SVR_T4120_VALUE 0x82400100
93824 +#define SVR_T4160_VALUE 0x82410000
93825 +#define SVR_T4080_VALUE 0x82410200
93826 +#define SVR_T4_DEVICE_ID 0x82400000
93827 +#define SVR_DEVICE_ID_MASK 0xFFF00000
93828 +
93829 +static t_LnxWrpFmDev * ReadFmDevTreeNode (struct platform_device *of_dev)
93830 +{
93831 + t_LnxWrpFmDev *p_LnxWrpFmDev;
93832 + struct device_node *fm_node, *dev_node;
93833 + struct of_device_id name;
93834 + struct resource res;
93835 + struct clk *clk;
93836 + u32 clk_rate;
93837 + const uint32_t *uint32_prop;
93838 + int _errno=0, lenp;
93839 + uint32_t tmp_prop;
93840 +
93841 + fm_node = of_node_get(of_dev->dev.of_node);
93842 +
93843 + uint32_prop = (uint32_t *)of_get_property(fm_node, "cell-index", &lenp);
93844 + if (unlikely(uint32_prop == NULL)) {
93845 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("of_get_property(%s, cell-index) failed", fm_node->full_name));
93846 + return NULL;
93847 + }
93848 + tmp_prop = be32_to_cpu(*uint32_prop);
93849 +
93850 + if (WARN_ON(lenp != sizeof(uint32_t)))
93851 + return NULL;
93852 +
93853 + if (tmp_prop > INTG_MAX_NUM_OF_FM) {
93854 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("fm id!"));
93855 + return NULL;
93856 + }
93857 + p_LnxWrpFmDev = CreateFmDev(tmp_prop);
93858 + if (!p_LnxWrpFmDev) {
93859 + REPORT_ERROR(MAJOR, E_NULL_POINTER, NO_MSG);
93860 + return NULL;
93861 + }
93862 + p_LnxWrpFmDev->dev = &of_dev->dev;
93863 + p_LnxWrpFmDev->id = tmp_prop;
93864 +
93865 + /* Get the FM interrupt */
93866 + p_LnxWrpFmDev->irq = of_irq_to_resource(fm_node, 0, NULL);
93867 + if (unlikely(p_LnxWrpFmDev->irq == /*NO_IRQ*/0)) {
93868 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("of_irq_to_resource() = %d", NO_IRQ));
93869 + return NULL;
93870 + }
93871 +
93872 + /* Get the FM error interrupt */
93873 + p_LnxWrpFmDev->err_irq = of_irq_to_resource(fm_node, 1, NULL);
93874 +
93875 + if (unlikely(p_LnxWrpFmDev->err_irq == /*NO_IRQ*/0)) {
93876 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("of_irq_to_resource() = %d", NO_IRQ));
93877 + return NULL;
93878 + }
93879 +
93880 + /* Get the FM address */
93881 + _errno = of_address_to_resource(fm_node, 0, &res);
93882 + if (unlikely(_errno < 0)) {
93883 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("of_address_to_resource() = %d", _errno));
93884 + return NULL;
93885 + }
93886 +
93887 +
93888 + p_LnxWrpFmDev->fmBaseAddr = 0;
93889 + p_LnxWrpFmDev->fmPhysBaseAddr = res.start;
93890 + p_LnxWrpFmDev->fmMemSize = res.end + 1 - res.start;
93891 +
93892 + clk = of_clk_get(fm_node, 0);
93893 + if (IS_ERR(clk)) {
93894 + dev_err(&of_dev->dev, "%s: Failed to get FM clock structure\n",
93895 + __func__);
93896 + of_node_put(fm_node);
93897 + return NULL;
93898 + }
93899 +
93900 + clk_rate = clk_get_rate(clk);
93901 + if (!clk_rate) {
93902 + dev_err(&of_dev->dev, "%s: Failed to determine FM clock rate\n",
93903 + __func__);
93904 + of_node_put(fm_node);
93905 + return NULL;
93906 + }
93907 +
93908 + p_LnxWrpFmDev->fmDevSettings.param.fmClkFreq = DIV_ROUND_UP(clk_rate, 1000000); /* In MHz, rounded */
93909 + /* Get the MURAM base address and size */
93910 + memset(&name, 0, sizeof(struct of_device_id));
93911 + if (WARN_ON(strlen("muram") >= sizeof(name.name)))
93912 + return NULL;
93913 + strcpy(name.name, "muram");
93914 + if (WARN_ON(strlen("fsl,fman-muram") >= sizeof(name.compatible)))
93915 + return NULL;
93916 + strcpy(name.compatible, "fsl,fman-muram");
93917 + for_each_child_of_node(fm_node, dev_node) {
93918 + if (likely(of_match_node(&name, dev_node) != NULL)) {
93919 + _errno = of_address_to_resource(dev_node, 0, &res);
93920 + if (unlikely(_errno < 0)) {
93921 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("of_address_to_resource() = %d", _errno));
93922 + return NULL;
93923 + }
93924 +
93925 + p_LnxWrpFmDev->fmMuramBaseAddr = 0;
93926 + p_LnxWrpFmDev->fmMuramPhysBaseAddr = res.start;
93927 + p_LnxWrpFmDev->fmMuramMemSize = res.end + 1 - res.start;
93928 +
93929 +#ifndef CONFIG_FMAN_ARM
93930 + {
93931 + uint32_t svr;
93932 + svr = mfspr(SPRN_SVR);
93933 +
93934 + if ((svr & ~SVR_VER_IGNORE_MASK) >= SVR_B4860_REV2_VALUE)
93935 + p_LnxWrpFmDev->fmMuramMemSize = 0x80000;
93936 + }
93937 +#endif
93938 + }
93939 + }
93940 +
93941 + /* Get the RTC base address and size */
93942 + memset(&name, 0, sizeof(struct of_device_id));
93943 + if (WARN_ON(strlen("rtc") >= sizeof(name.name)))
93944 + return NULL;
93945 + strcpy(name.name, "rtc");
93946 + if (WARN_ON(strlen("fsl,fman-rtc") >= sizeof(name.compatible)))
93947 + return NULL;
93948 + strcpy(name.compatible, "fsl,fman-rtc");
93949 + for_each_child_of_node(fm_node, dev_node) {
93950 + if (likely(of_match_node(&name, dev_node) != NULL)) {
93951 + _errno = of_address_to_resource(dev_node, 0, &res);
93952 + if (unlikely(_errno < 0)) {
93953 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("of_address_to_resource() = %d", _errno));
93954 + return NULL;
93955 + }
93956 +
93957 + p_LnxWrpFmDev->fmRtcBaseAddr = 0;
93958 + p_LnxWrpFmDev->fmRtcPhysBaseAddr = res.start;
93959 + p_LnxWrpFmDev->fmRtcMemSize = res.end + 1 - res.start;
93960 + }
93961 + }
93962 +
93963 +#if (DPAA_VERSION >= 11)
93964 + /* Get the VSP base address */
93965 + for_each_child_of_node(fm_node, dev_node) {
93966 + if (of_device_is_compatible(dev_node, "fsl,fman-vsps")) {
93967 + _errno = of_address_to_resource(dev_node, 0, &res);
93968 + if (unlikely(_errno < 0)) {
93969 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("of_address_to_resource() = %d", _errno));
93970 + return NULL;
93971 + }
93972 + p_LnxWrpFmDev->fmVspBaseAddr = 0;
93973 + p_LnxWrpFmDev->fmVspPhysBaseAddr = res.start;
93974 + p_LnxWrpFmDev->fmVspMemSize = res.end + 1 - res.start;
93975 + }
93976 + }
93977 +#endif
93978 +
93979 + /* Get all PCD nodes */
93980 + memset(&name, 0, sizeof(struct of_device_id));
93981 + if (WARN_ON(strlen("parser") >= sizeof(name.name)))
93982 + return NULL;
93983 + strcpy(name.name, "parser");
93984 + if (WARN_ON(strlen("fsl,fman-parser") >= sizeof(name.compatible)))
93985 + return NULL;
93986 + strcpy(name.compatible, "fsl,fman-parser");
93987 + for_each_child_of_node(fm_node, dev_node)
93988 + if (likely(of_match_node(&name, dev_node) != NULL))
93989 + p_LnxWrpFmDev->prsActive = TRUE;
93990 +
93991 + memset(&name, 0, sizeof(struct of_device_id));
93992 + if (WARN_ON(strlen("keygen") >= sizeof(name.name)))
93993 + return NULL;
93994 + strcpy(name.name, "keygen");
93995 + if (WARN_ON(strlen("fsl,fman-keygen") >= sizeof(name.compatible)))
93996 + return NULL;
93997 + strcpy(name.compatible, "fsl,fman-keygen");
93998 + for_each_child_of_node(fm_node, dev_node)
93999 + if (likely(of_match_node(&name, dev_node) != NULL))
94000 + p_LnxWrpFmDev->kgActive = TRUE;
94001 +
94002 + memset(&name, 0, sizeof(struct of_device_id));
94003 + if (WARN_ON(strlen("cc") >= sizeof(name.name)))
94004 + return NULL;
94005 + strcpy(name.name, "cc");
94006 + if (WARN_ON(strlen("fsl,fman-cc") >= sizeof(name.compatible)))
94007 + return NULL;
94008 + strcpy(name.compatible, "fsl,fman-cc");
94009 + for_each_child_of_node(fm_node, dev_node)
94010 + if (likely(of_match_node(&name, dev_node) != NULL))
94011 + p_LnxWrpFmDev->ccActive = TRUE;
94012 +
94013 + memset(&name, 0, sizeof(struct of_device_id));
94014 + if (WARN_ON(strlen("policer") >= sizeof(name.name)))
94015 + return NULL;
94016 + strcpy(name.name, "policer");
94017 + if (WARN_ON(strlen("fsl,fman-policer") >= sizeof(name.compatible)))
94018 + return NULL;
94019 + strcpy(name.compatible, "fsl,fman-policer");
94020 + for_each_child_of_node(fm_node, dev_node)
94021 + if (likely(of_match_node(&name, dev_node) != NULL))
94022 + p_LnxWrpFmDev->plcrActive = TRUE;
94023 +
94024 + if (p_LnxWrpFmDev->prsActive || p_LnxWrpFmDev->kgActive ||
94025 + p_LnxWrpFmDev->ccActive || p_LnxWrpFmDev->plcrActive)
94026 + p_LnxWrpFmDev->pcdActive = TRUE;
94027 +
94028 + if (p_LnxWrpFmDev->pcdActive)
94029 + {
94030 + const char *str_prop = (char *)of_get_property(fm_node, "fsl,default-pcd", &lenp);
94031 + if (str_prop) {
94032 + if (strncmp(str_prop, "3-tuple", strlen("3-tuple")) == 0)
94033 + p_LnxWrpFmDev->defPcd = e_FM_PCD_3_TUPLE;
94034 + }
94035 + else
94036 + p_LnxWrpFmDev->defPcd = e_NO_PCD;
94037 + }
94038 +
94039 + of_node_put(fm_node);
94040 +
94041 + p_LnxWrpFmDev->hcCh =
94042 + qman_affine_channel(cpumask_first(qman_affine_cpus()));
94043 +
94044 + p_LnxWrpFmDev->active = TRUE;
94045 +
94046 + return p_LnxWrpFmDev;
94047 +}
94048 +
94049 +struct device_node *GetFmAdvArgsDevTreeNode (uint8_t fmIndx)
94050 +{
94051 + struct device_node *dev_node;
94052 + const uint32_t *uint32_prop;
94053 + int lenp;
94054 + uint32_t tmp_prop;
94055 +
94056 + for_each_compatible_node(dev_node, NULL, "fsl,fman-extended-args") {
94057 + uint32_prop = (uint32_t *)of_get_property(dev_node, "cell-index", &lenp);
94058 + if (unlikely(uint32_prop == NULL)) {
94059 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
94060 + ("of_get_property(%s, cell-index) failed",
94061 + dev_node->full_name));
94062 + return NULL;
94063 + }
94064 + tmp_prop = be32_to_cpu(*uint32_prop);
94065 + if (WARN_ON(lenp != sizeof(uint32_t)))
94066 + return NULL;
94067 + if (tmp_prop > INTG_MAX_NUM_OF_FM) {
94068 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("fm id!"));
94069 + return NULL;
94070 + }
94071 + if (fmIndx == tmp_prop)
94072 + return dev_node;
94073 + }
94074 +
94075 + return NULL;
94076 +}
94077 +
94078 +static t_Error CheckNConfigFmAdvArgs (t_LnxWrpFmDev *p_LnxWrpFmDev)
94079 +{
94080 + struct device_node *dev_node;
94081 + t_Error err = E_INVALID_VALUE;
94082 + const uint32_t *uint32_prop;
94083 + const char *str_prop;
94084 + int lenp;
94085 + uint32_t tmp_prop;
94086 +
94087 + dev_node = GetFmAdvArgsDevTreeNode(p_LnxWrpFmDev->id);
94088 + if (!dev_node) /* no advance parameters for FMan */
94089 + return E_OK;
94090 +
94091 + str_prop = (char *)of_get_property(dev_node, "dma-aid-mode", &lenp);
94092 + if (str_prop) {
94093 + if (strcmp(str_prop, "port") == 0)
94094 + err = FM_ConfigDmaAidMode(p_LnxWrpFmDev->h_Dev, e_FM_DMA_AID_OUT_PORT_ID);
94095 + else if (strcmp(str_prop, "tnum") == 0)
94096 + err = FM_ConfigDmaAidMode(p_LnxWrpFmDev->h_Dev, e_FM_DMA_AID_OUT_TNUM);
94097 +
94098 + if (err != E_OK)
94099 + RETURN_ERROR(MINOR, err, NO_MSG);
94100 + }
94101 +
94102 + uint32_prop = (uint32_t *)of_get_property(dev_node,
94103 + "total-fifo-size", &lenp);
94104 + if (uint32_prop) {
94105 + tmp_prop = be32_to_cpu(*uint32_prop);
94106 + if (WARN_ON(lenp != sizeof(uint32_t)))
94107 + RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
94108 +
94109 + if (FM_ConfigTotalFifoSize(p_LnxWrpFmDev->h_Dev,
94110 + tmp_prop) != E_OK)
94111 + RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
94112 + }
94113 +
94114 + uint32_prop = (uint32_t *)of_get_property(dev_node, "tnum-aging-period",
94115 + &lenp);
94116 + if (uint32_prop) {
94117 + tmp_prop = be32_to_cpu(*uint32_prop);
94118 + if (WARN_ON(lenp != sizeof(uint32_t)))
94119 + RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
94120 +
94121 + err = FM_ConfigTnumAgingPeriod(p_LnxWrpFmDev->h_Dev,
94122 + (uint16_t)tmp_prop/*tnumAgingPeriod*/);
94123 +
94124 + if (err != E_OK)
94125 + RETURN_ERROR(MINOR, err, NO_MSG);
94126 + }
94127 +
94128 + of_node_put(dev_node);
94129 +
94130 + return E_OK;
94131 +}
94132 +
94133 +static void LnxwrpFmDevExceptionsCb(t_Handle h_App, e_FmExceptions exception)
94134 +{
94135 + t_LnxWrpFmDev *p_LnxWrpFmDev = (t_LnxWrpFmDev *)h_App;
94136 +
94137 + ASSERT_COND(p_LnxWrpFmDev);
94138 +
94139 + DBG(INFO, ("got fm exception %d", exception));
94140 +
94141 + /* do nothing */
94142 + UNUSED(exception);
94143 +}
94144 +
94145 +static void LnxwrpFmDevBusErrorCb(t_Handle h_App,
94146 + e_FmPortType portType,
94147 + uint8_t portId,
94148 + uint64_t addr,
94149 + uint8_t tnum,
94150 + uint16_t liodn)
94151 +{
94152 + t_LnxWrpFmDev *p_LnxWrpFmDev = (t_LnxWrpFmDev *)h_App;
94153 +
94154 + ASSERT_COND(p_LnxWrpFmDev);
94155 +
94156 + /* do nothing */
94157 + UNUSED(portType);UNUSED(portId);UNUSED(addr);UNUSED(tnum);UNUSED(liodn);
94158 +}
94159 +
94160 +static t_Error ConfigureFmDev(t_LnxWrpFmDev *p_LnxWrpFmDev)
94161 +{
94162 + struct resource *dev_res;
94163 + int _errno;
94164 +
94165 + if (!p_LnxWrpFmDev->active)
94166 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM not configured!!!"));
94167 +
94168 +#ifndef MODULE
94169 + _errno = can_request_irq(p_LnxWrpFmDev->irq, 0);
94170 + if (unlikely(_errno < 0))
94171 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("can_request_irq() = %d", _errno));
94172 +#endif
94173 + _errno = devm_request_irq(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->irq, fm_irq, 0, "fman", p_LnxWrpFmDev);
94174 + if (unlikely(_errno < 0))
94175 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("request_irq(%d) = %d", p_LnxWrpFmDev->irq, _errno));
94176 +
94177 + enable_irq_wake(p_LnxWrpFmDev->irq);
94178 +
94179 + if (p_LnxWrpFmDev->err_irq != 0) {
94180 +#ifndef MODULE
94181 + _errno = can_request_irq(p_LnxWrpFmDev->err_irq, 0);
94182 + if (unlikely(_errno < 0))
94183 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("can_request_irq() = %d", _errno));
94184 +#endif
94185 + _errno = devm_request_irq(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->err_irq, fm_err_irq, IRQF_SHARED, "fman-err", p_LnxWrpFmDev);
94186 + if (unlikely(_errno < 0))
94187 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("request_irq(%d) = %d", p_LnxWrpFmDev->err_irq, _errno));
94188 +
94189 + enable_irq_wake(p_LnxWrpFmDev->err_irq);
94190 + }
94191 +
94192 + p_LnxWrpFmDev->res = devm_request_mem_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->fmPhysBaseAddr, p_LnxWrpFmDev->fmMemSize, "fman");
94193 + if (unlikely(p_LnxWrpFmDev->res == NULL))
94194 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("request_mem_region() failed"));
94195 +
94196 + p_LnxWrpFmDev->fmBaseAddr = PTR_TO_UINT(devm_ioremap(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->fmPhysBaseAddr, p_LnxWrpFmDev->fmMemSize));
94197 + if (unlikely(p_LnxWrpFmDev->fmBaseAddr == 0))
94198 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("devm_ioremap() failed"));
94199 +
94200 + if (SYS_RegisterIoMap((uint64_t)p_LnxWrpFmDev->fmBaseAddr, (uint64_t)p_LnxWrpFmDev->fmPhysBaseAddr, p_LnxWrpFmDev->fmMemSize) != E_OK)
94201 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM memory map"));
94202 +
94203 + dev_res = __devm_request_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->res, p_LnxWrpFmDev->fmMuramPhysBaseAddr, p_LnxWrpFmDev->fmMuramMemSize, "fman-muram");
94204 + if (unlikely(dev_res == NULL))
94205 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("__devm_request_region() failed"));
94206 +
94207 + p_LnxWrpFmDev->fmMuramBaseAddr = PTR_TO_UINT(devm_ioremap(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->fmMuramPhysBaseAddr, p_LnxWrpFmDev->fmMuramMemSize));
94208 + if (unlikely(p_LnxWrpFmDev->fmMuramBaseAddr == 0))
94209 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("devm_ioremap() failed"));
94210 +
94211 + if (SYS_RegisterIoMap((uint64_t)p_LnxWrpFmDev->fmMuramBaseAddr, (uint64_t)p_LnxWrpFmDev->fmMuramPhysBaseAddr, p_LnxWrpFmDev->fmMuramMemSize) != E_OK)
94212 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM MURAM memory map"));
94213 +
94214 + if (p_LnxWrpFmDev->fmRtcPhysBaseAddr)
94215 + {
94216 + dev_res = __devm_request_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->res, p_LnxWrpFmDev->fmRtcPhysBaseAddr, p_LnxWrpFmDev->fmRtcMemSize, "fman-rtc");
94217 + if (unlikely(dev_res == NULL))
94218 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("__devm_request_region() failed"));
94219 +
94220 + p_LnxWrpFmDev->fmRtcBaseAddr = PTR_TO_UINT(devm_ioremap(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->fmRtcPhysBaseAddr, p_LnxWrpFmDev->fmRtcMemSize));
94221 + if (unlikely(p_LnxWrpFmDev->fmRtcBaseAddr == 0))
94222 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("devm_ioremap() failed"));
94223 +
94224 + if (SYS_RegisterIoMap((uint64_t)p_LnxWrpFmDev->fmRtcBaseAddr, (uint64_t)p_LnxWrpFmDev->fmRtcPhysBaseAddr, p_LnxWrpFmDev->fmRtcMemSize) != E_OK)
94225 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM-RTC memory map"));
94226 + }
94227 +
94228 +#if (DPAA_VERSION >= 11)
94229 + if (p_LnxWrpFmDev->fmVspPhysBaseAddr) {
94230 + dev_res = __devm_request_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->res, p_LnxWrpFmDev->fmVspPhysBaseAddr, p_LnxWrpFmDev->fmVspMemSize, "fman-vsp");
94231 + if (unlikely(dev_res == NULL))
94232 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("__devm_request_region() failed"));
94233 +
94234 + p_LnxWrpFmDev->fmVspBaseAddr = PTR_TO_UINT(devm_ioremap(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->fmVspPhysBaseAddr, p_LnxWrpFmDev->fmVspMemSize));
94235 + if (unlikely(p_LnxWrpFmDev->fmVspBaseAddr == 0))
94236 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("devm_ioremap() failed"));
94237 + }
94238 +#endif
94239 +
94240 + p_LnxWrpFmDev->fmDevSettings.param.baseAddr = p_LnxWrpFmDev->fmBaseAddr;
94241 + p_LnxWrpFmDev->fmDevSettings.param.fmId = p_LnxWrpFmDev->id;
94242 + p_LnxWrpFmDev->fmDevSettings.param.irq = NO_IRQ;
94243 + p_LnxWrpFmDev->fmDevSettings.param.errIrq = NO_IRQ;
94244 + p_LnxWrpFmDev->fmDevSettings.param.f_Exception = LnxwrpFmDevExceptionsCb;
94245 + p_LnxWrpFmDev->fmDevSettings.param.f_BusError = LnxwrpFmDevBusErrorCb;
94246 + p_LnxWrpFmDev->fmDevSettings.param.h_App = p_LnxWrpFmDev;
94247 +
94248 + return FillRestFmInfo(p_LnxWrpFmDev);
94249 +}
94250 +
94251 +#ifndef CONFIG_FMAN_ARM
94252 +/*
94253 + * Table for matching compatible strings, for device tree
94254 + * guts node, for QorIQ SOCs.
94255 + * "fsl,qoriq-device-config-2.0" corresponds to T4 & B4
94256 + * SOCs. For the older SOCs "fsl,qoriq-device-config-1.0"
94257 + * string would be used.
94258 +*/
94259 +static const struct of_device_id guts_device_ids[] = {
94260 + { .compatible = "fsl,qoriq-device-config-1.0", },
94261 + { .compatible = "fsl,qoriq-device-config-2.0", },
94262 + {}
94263 +};
94264 +
94265 +static unsigned int get_rcwsr(int regnum)
94266 +{
94267 + struct ccsr_guts __iomem *guts_regs = NULL;
94268 + struct device_node *guts_node;
94269 +
94270 + guts_node = of_find_matching_node(NULL, guts_device_ids);
94271 + if (!guts_node) {
94272 + pr_err("could not find GUTS node\n");
94273 + return 0;
94274 + }
94275 + guts_regs = of_iomap(guts_node, 0);
94276 + of_node_put(guts_node);
94277 + if (!guts_regs) {
94278 + pr_err("ioremap of GUTS node failed\n");
94279 + return 0;
94280 + }
94281 +
94282 + return ioread32be(&guts_regs->rcwsr[regnum]);
94283 +}
94284 +#endif
94285 +
94286 +static t_Error InitFmDev(t_LnxWrpFmDev *p_LnxWrpFmDev)
94287 +{
94288 + const struct qe_firmware *fw;
94289 +
94290 + if (!p_LnxWrpFmDev->active)
94291 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM not configured!!!"));
94292 +
94293 + if ((p_LnxWrpFmDev->h_MuramDev = FM_MURAM_ConfigAndInit(p_LnxWrpFmDev->fmMuramBaseAddr, p_LnxWrpFmDev->fmMuramMemSize)) == NULL)
94294 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("FM-MURAM!"));
94295 +
94296 + /* Loading the fman-controller code */
94297 + fw = FindFmanMicrocode();
94298 +
94299 + if (!fw) {
94300 + /* this forces the reuse of the current IRAM content */
94301 + p_LnxWrpFmDev->fmDevSettings.param.firmware.size = 0;
94302 + p_LnxWrpFmDev->fmDevSettings.param.firmware.p_Code = NULL;
94303 + } else {
94304 + p_LnxWrpFmDev->fmDevSettings.param.firmware.p_Code =
94305 + (void *) fw + be32_to_cpu(fw->microcode[0].code_offset);
94306 + p_LnxWrpFmDev->fmDevSettings.param.firmware.size =
94307 + sizeof(u32) * be32_to_cpu(fw->microcode[0].count);
94308 + DBG(INFO, ("Loading fman-controller code version %d.%d.%d",
94309 + fw->microcode[0].major,
94310 + fw->microcode[0].minor,
94311 + fw->microcode[0].revision));
94312 + }
94313 +
94314 +#ifdef CONFIG_FMAN_ARM
94315 + { /* endianness adjustments: byteswap the ucode retrieved from the f/w blob */
94316 + int i;
94317 + int usz = p_LnxWrpFmDev->fmDevSettings.param.firmware.size;
94318 + void * p_Code = p_LnxWrpFmDev->fmDevSettings.param.firmware.p_Code;
94319 +
94320 + for(i=0; i < usz / 4; ++i)
94321 + ((u32 *)p_Code)[i] = be32_to_cpu(((u32 *)p_Code)[i]);
94322 + }
94323 +#endif
94324 +
94325 + p_LnxWrpFmDev->fmDevSettings.param.h_FmMuram = p_LnxWrpFmDev->h_MuramDev;
94326 +
94327 +#if (DPAA_VERSION >= 11)
94328 + if (p_LnxWrpFmDev->fmVspBaseAddr) {
94329 + p_LnxWrpFmDev->fmDevSettings.param.vspBaseAddr = p_LnxWrpFmDev->fmVspBaseAddr;
94330 + p_LnxWrpFmDev->fmDevSettings.param.partVSPBase = 0;
94331 + p_LnxWrpFmDev->fmDevSettings.param.partNumOfVSPs = FM_VSP_MAX_NUM_OF_ENTRIES;
94332 + }
94333 +#endif
94334 +
94335 +#ifdef CONFIG_FMAN_ARM
94336 + p_LnxWrpFmDev->fmDevSettings.param.fmMacClkRatio = 1;
94337 +#else
94338 + if(p_LnxWrpFmDev->fmDevSettings.param.fmId == 0)
94339 + p_LnxWrpFmDev->fmDevSettings.param.fmMacClkRatio =
94340 + !!(get_rcwsr(4) & 0x2); /* RCW[FM_MAC_RAT0] */
94341 + else
94342 + p_LnxWrpFmDev->fmDevSettings.param.fmMacClkRatio =
94343 + !!(get_rcwsr(4) & 0x1); /* RCW[FM_MAC_RAT1] */
94344 +
94345 + {
94346 + /* T4 Devices ClkRatio is always 1 regardless of RCW[FM_MAC_RAT1] */
94347 + uint32_t svr;
94348 + svr = mfspr(SPRN_SVR);
94349 +
94350 + if ((svr & SVR_DEVICE_ID_MASK) == SVR_T4_DEVICE_ID)
94351 + p_LnxWrpFmDev->fmDevSettings.param.fmMacClkRatio = 1;
94352 + }
94353 +#endif /* CONFIG_FMAN_ARM */
94354 +
94355 + if ((p_LnxWrpFmDev->h_Dev = FM_Config(&p_LnxWrpFmDev->fmDevSettings.param)) == NULL)
94356 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("FM"));
94357 +
94358 +
94359 + if (FM_ConfigResetOnInit(p_LnxWrpFmDev->h_Dev, TRUE) != E_OK)
94360 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM"));
94361 +
94362 +#ifdef CONFIG_FMAN_P1023
94363 + if (FM_ConfigDmaAidOverride(p_LnxWrpFmDev->h_Dev, TRUE) != E_OK)
94364 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM"));
94365 +#endif
94366 +
94367 +
94368 + CheckNConfigFmAdvArgs(p_LnxWrpFmDev);
94369 +
94370 + if (FM_Init(p_LnxWrpFmDev->h_Dev) != E_OK)
94371 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM"));
94372 +
94373 + /* TODO: Why we mask these interrupts? */
94374 + if (p_LnxWrpFmDev->err_irq == 0) {
94375 + FM_SetException(p_LnxWrpFmDev->h_Dev, e_FM_EX_DMA_BUS_ERROR,FALSE);
94376 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_DMA_READ_ECC,FALSE);
94377 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_DMA_SYSTEM_WRITE_ECC,FALSE);
94378 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_DMA_FM_WRITE_ECC,FALSE);
94379 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_DMA_SINGLE_PORT_ECC, FALSE);
94380 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_FPM_STALL_ON_TASKS , FALSE);
94381 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_FPM_SINGLE_ECC, FALSE);
94382 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_FPM_DOUBLE_ECC,FALSE);
94383 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_QMI_SINGLE_ECC, FALSE);
94384 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_QMI_DOUBLE_ECC,FALSE);
94385 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,FALSE);
94386 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_BMI_LIST_RAM_ECC,FALSE);
94387 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_BMI_STORAGE_PROFILE_ECC, FALSE);
94388 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_BMI_STATISTICS_RAM_ECC, FALSE);
94389 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_BMI_DISPATCH_RAM_ECC, FALSE);
94390 + FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_IRAM_ECC,FALSE);
94391 + /* TODO: FmDisableRamsEcc assert for ramsEccOwners.
94392 + * FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_MURAM_ECC,FALSE);*/
94393 + }
94394 +
94395 + if (p_LnxWrpFmDev->fmRtcBaseAddr)
94396 + {
94397 + t_FmRtcParams fmRtcParam;
94398 +
94399 + memset(&fmRtcParam, 0, sizeof(fmRtcParam));
94400 + fmRtcParam.h_App = p_LnxWrpFmDev;
94401 + fmRtcParam.h_Fm = p_LnxWrpFmDev->h_Dev;
94402 + fmRtcParam.baseAddress = p_LnxWrpFmDev->fmRtcBaseAddr;
94403 +
94404 + if(!(p_LnxWrpFmDev->h_RtcDev = FM_RTC_Config(&fmRtcParam)))
94405 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("FM-RTC"));
94406 +
94407 + if (FM_RTC_ConfigPeriod(p_LnxWrpFmDev->h_RtcDev, DPA_PTP_NOMINAL_FREQ_PERIOD_NS) != E_OK)
94408 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM-RTC"));
94409 +
94410 + if (FM_RTC_Init(p_LnxWrpFmDev->h_RtcDev) != E_OK)
94411 + RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM-RTC"));
94412 + }
94413 +
94414 + return E_OK;
94415 +}
94416 +
94417 +/* TODO: to be moved back here */
94418 +extern void FreeFmPcdDev(t_LnxWrpFmDev *p_LnxWrpFmDev);
94419 +
94420 +static void FreeFmDev(t_LnxWrpFmDev *p_LnxWrpFmDev)
94421 +{
94422 + if (!p_LnxWrpFmDev->active)
94423 + return;
94424 +
94425 + FreeFmPcdDev(p_LnxWrpFmDev);
94426 +
94427 + if (p_LnxWrpFmDev->h_RtcDev)
94428 + FM_RTC_Free(p_LnxWrpFmDev->h_RtcDev);
94429 +
94430 + if (p_LnxWrpFmDev->h_Dev)
94431 + FM_Free(p_LnxWrpFmDev->h_Dev);
94432 +
94433 + if (p_LnxWrpFmDev->h_MuramDev)
94434 + FM_MURAM_Free(p_LnxWrpFmDev->h_MuramDev);
94435 +
94436 + if (p_LnxWrpFmDev->fmRtcBaseAddr)
94437 + {
94438 + SYS_UnregisterIoMap(p_LnxWrpFmDev->fmRtcBaseAddr);
94439 + devm_iounmap(p_LnxWrpFmDev->dev, UINT_TO_PTR(p_LnxWrpFmDev->fmRtcBaseAddr));
94440 + __devm_release_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->res, p_LnxWrpFmDev->fmRtcPhysBaseAddr, p_LnxWrpFmDev->fmRtcMemSize);
94441 + }
94442 + SYS_UnregisterIoMap(p_LnxWrpFmDev->fmMuramBaseAddr);
94443 + devm_iounmap(p_LnxWrpFmDev->dev, UINT_TO_PTR(p_LnxWrpFmDev->fmMuramBaseAddr));
94444 + __devm_release_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->res, p_LnxWrpFmDev->fmMuramPhysBaseAddr, p_LnxWrpFmDev->fmMuramMemSize);
94445 + SYS_UnregisterIoMap(p_LnxWrpFmDev->fmBaseAddr);
94446 + devm_iounmap(p_LnxWrpFmDev->dev, UINT_TO_PTR(p_LnxWrpFmDev->fmBaseAddr));
94447 + devm_release_mem_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->fmPhysBaseAddr, p_LnxWrpFmDev->fmMemSize);
94448 + if (p_LnxWrpFmDev->err_irq != 0) {
94449 + devm_free_irq(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->err_irq, p_LnxWrpFmDev);
94450 + }
94451 +
94452 + devm_free_irq(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->irq, p_LnxWrpFmDev);
94453 +}
94454 +
94455 +/* FMan character device file operations */
94456 +extern struct file_operations fm_fops;
94457 +
94458 +static int /*__devinit*/ fm_probe(struct platform_device *of_dev)
94459 +{
94460 + t_LnxWrpFmDev *p_LnxWrpFmDev;
94461 +
94462 + if ((p_LnxWrpFmDev = ReadFmDevTreeNode(of_dev)) == NULL)
94463 + return -EIO;
94464 + if (ConfigureFmDev(p_LnxWrpFmDev) != E_OK)
94465 + return -EIO;
94466 + if (InitFmDev(p_LnxWrpFmDev) != E_OK)
94467 + return -EIO;
94468 +
94469 + /* IOCTL ABI checking */
94470 + LnxWrpPCDIOCTLEnumChecking();
94471 + LnxWrpPCDIOCTLTypeChecking();
94472 +
94473 + Sprint (p_LnxWrpFmDev->name, "%s%d", DEV_FM_NAME, p_LnxWrpFmDev->id);
94474 +
94475 + /* Register to the /dev for IOCTL API */
94476 + /* Register dynamically a new major number for the character device: */
94477 + if ((p_LnxWrpFmDev->major = register_chrdev(0, p_LnxWrpFmDev->name, &fm_fops)) <= 0) {
94478 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Failed to allocate a major number for device \"%s\"", p_LnxWrpFmDev->name));
94479 + return -EIO;
94480 + }
94481 +
94482 + /* Creating classes for FM */
94483 + DBG(TRACE ,("class_create fm_class"));
94484 + p_LnxWrpFmDev->fm_class = class_create(THIS_MODULE, p_LnxWrpFmDev->name);
94485 + if (IS_ERR(p_LnxWrpFmDev->fm_class)) {
94486 + unregister_chrdev(p_LnxWrpFmDev->major, p_LnxWrpFmDev->name);
94487 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("class_create error fm_class"));
94488 + return -EIO;
94489 + }
94490 +
94491 + device_create(p_LnxWrpFmDev->fm_class, NULL, MKDEV(p_LnxWrpFmDev->major, DEV_FM_MINOR_BASE), NULL,
94492 + "fm%d", p_LnxWrpFmDev->id);
94493 + device_create(p_LnxWrpFmDev->fm_class, NULL, MKDEV(p_LnxWrpFmDev->major, DEV_FM_PCD_MINOR_BASE), NULL,
94494 + "fm%d-pcd", p_LnxWrpFmDev->id);
94495 + dev_set_drvdata(p_LnxWrpFmDev->dev, p_LnxWrpFmDev);
94496 +
94497 + /* create sysfs entries for stats and regs */
94498 + if ( fm_sysfs_create(p_LnxWrpFmDev->dev) !=0 )
94499 + {
94500 + FreeFmDev(p_LnxWrpFmDev);
94501 + REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Unable to create sysfs entry - fm!!!"));
94502 + return -EIO;
94503 + }
94504 +
94505 +#ifdef CONFIG_PM
94506 + device_set_wakeup_capable(p_LnxWrpFmDev->dev, true);
94507 +#endif
94508 +
94509 + DBG(TRACE, ("FM%d probed", p_LnxWrpFmDev->id));
94510 +
94511 + return 0;
94512 +}
94513 +
94514 +static int fm_remove(struct platform_device *of_dev)
94515 +{
94516 + t_LnxWrpFmDev *p_LnxWrpFmDev;
94517 + struct device *dev;
94518 +
94519 + dev = &of_dev->dev;
94520 + p_LnxWrpFmDev = dev_get_drvdata(dev);
94521 +
94522 + fm_sysfs_destroy(dev);
94523 +
94524 + DBG(TRACE, ("destroy fm_class"));
94525 + device_destroy(p_LnxWrpFmDev->fm_class, MKDEV(p_LnxWrpFmDev->major, DEV_FM_MINOR_BASE));
94526 + device_destroy(p_LnxWrpFmDev->fm_class, MKDEV(p_LnxWrpFmDev->major, DEV_FM_PCD_MINOR_BASE));
94527 + class_destroy(p_LnxWrpFmDev->fm_class);
94528 +
94529 + /* Destroy chardev */
94530 + unregister_chrdev(p_LnxWrpFmDev->major, p_LnxWrpFmDev->name);
94531 +
94532 + FreeFmDev(p_LnxWrpFmDev);
94533 +
94534 + DestroyFmDev(p_LnxWrpFmDev);
94535 +
94536 + dev_set_drvdata(dev, NULL);
94537 +
94538 + return 0;
94539 +}
94540 +
94541 +static const struct of_device_id fm_match[] = {
94542 + {
94543 + .compatible = "fsl,fman"
94544 + },
94545 + {}
94546 +};
94547 +#ifndef MODULE
94548 +MODULE_DEVICE_TABLE(of, fm_match);
94549 +#endif /* !MODULE */
94550 +
94551 +#ifdef CONFIG_PM
94552 +
94553 +#define SCFG_FMCLKDPSLPCR_ADDR 0xFFE0FC00C
94554 +#define SCFG_FMCLKDPSLPCR_DS_VAL 0x48402000
94555 +#define SCFG_FMCLKDPSLPCR_NORMAL_VAL 0x00402000
94556 +
94557 +struct device *g_fm_dev;
94558 +
94559 +static int fm_soc_suspend(struct device *dev)
94560 +{
94561 + int err = 0;
94562 + uint32_t *fmclk;
94563 + t_LnxWrpFmDev *p_LnxWrpFmDev = dev_get_drvdata(get_device(dev));
94564 + g_fm_dev = dev;
94565 + fmclk = ioremap(SCFG_FMCLKDPSLPCR_ADDR, 4);
94566 + WRITE_UINT32(*fmclk, SCFG_FMCLKDPSLPCR_DS_VAL);
94567 + if (p_LnxWrpFmDev->h_DsarRxPort)
94568 + {
94569 +#ifdef CONFIG_FSL_QORIQ_PM
94570 + device_set_wakeup_enable(p_LnxWrpFmDev->dev, 1);
94571 +#endif
94572 + err = FM_PORT_EnterDsarFinal(p_LnxWrpFmDev->h_DsarRxPort,
94573 + p_LnxWrpFmDev->h_DsarTxPort);
94574 + }
94575 + return err;
94576 +}
94577 +
94578 +static int fm_soc_resume(struct device *dev)
94579 +{
94580 + t_LnxWrpFmDev *p_LnxWrpFmDev = dev_get_drvdata(get_device(dev));
94581 + uint32_t *fmclk;
94582 + fmclk = ioremap(SCFG_FMCLKDPSLPCR_ADDR, 4);
94583 + WRITE_UINT32(*fmclk, SCFG_FMCLKDPSLPCR_NORMAL_VAL);
94584 + if (p_LnxWrpFmDev->h_DsarRxPort)
94585 + {
94586 +#ifdef CONFIG_FSL_QORIQ_PM
94587 + device_set_wakeup_enable(p_LnxWrpFmDev->dev, 0);
94588 +#endif
94589 + FM_PORT_ExitDsar(p_LnxWrpFmDev->h_DsarRxPort,
94590 + p_LnxWrpFmDev->h_DsarTxPort);
94591 + p_LnxWrpFmDev->h_DsarRxPort = 0;
94592 + p_LnxWrpFmDev->h_DsarTxPort = 0;
94593 + }
94594 + return 0;
94595 +}
94596 +
94597 +static const struct dev_pm_ops fm_pm_ops = {
94598 + .suspend = fm_soc_suspend,
94599 + .resume = fm_soc_resume,
94600 +};
94601 +
94602 +#define FM_PM_OPS (&fm_pm_ops)
94603 +
94604 +#else /* CONFIG_PM */
94605 +
94606 +#define FM_PM_OPS NULL
94607 +
94608 +#endif /* CONFIG_PM */
94609 +
94610 +static struct platform_driver fm_driver = {
94611 + .driver = {
94612 + .name = "fsl-fman",
94613 + .of_match_table = fm_match,
94614 + .owner = THIS_MODULE,
94615 + .pm = FM_PM_OPS,
94616 + },
94617 + .probe = fm_probe,
94618 + .remove = fm_remove
94619 +};
94620 +
94621 +t_Handle LNXWRP_FM_Init(void)
94622 +{
94623 + memset(&lnxWrpFm, 0, sizeof(lnxWrpFm));
94624 + mutex_init(&lnxwrp_mutex);
94625 +
94626 + /* Register to the DTB for basic FM API */
94627 + platform_driver_register(&fm_driver);
94628 +
94629 + return &lnxWrpFm;
94630 +}
94631 +
94632 +t_Error LNXWRP_FM_Free(t_Handle h_LnxWrpFm)
94633 +{
94634 + platform_driver_unregister(&fm_driver);
94635 + mutex_destroy(&lnxwrp_mutex);
94636 +
94637 + return E_OK;
94638 +}
94639 +
94640 +
94641 +struct fm * fm_bind(struct device *fm_dev)
94642 +{
94643 + return (struct fm *)(dev_get_drvdata(get_device(fm_dev)));
94644 +}
94645 +EXPORT_SYMBOL(fm_bind);
94646 +
94647 +void fm_unbind(struct fm *fm)
94648 +{
94649 + t_LnxWrpFmDev *p_LnxWrpFmDev = (t_LnxWrpFmDev*)fm;
94650 +
94651 + put_device(p_LnxWrpFmDev->dev);
94652 +}
94653 +EXPORT_SYMBOL(fm_unbind);
94654 +
94655 +struct resource * fm_get_mem_region(struct fm *fm)
94656 +{
94657 + t_LnxWrpFmDev *p_LnxWrpFmDev = (t_LnxWrpFmDev*)fm;
94658 +
94659 + return p_LnxWrpFmDev->res;
94660 +}
94661 +EXPORT_SYMBOL(fm_get_mem_region);
94662 +
94663 +void * fm_get_handle(struct fm *fm)
94664 +{
94665 + t_LnxWrpFmDev *p_LnxWrpFmDev = (t_LnxWrpFmDev*)fm;
94666 +
94667 + return (void *)p_LnxWrpFmDev->h_Dev;
94668 +}
94669 +EXPORT_SYMBOL(fm_get_handle);
94670 +
94671 +void * fm_get_rtc_handle(struct fm *fm)
94672 +{
94673 + t_LnxWrpFmDev *p_LnxWrpFmDev = (t_LnxWrpFmDev*)fm;
94674 +
94675 + return (void *)p_LnxWrpFmDev->h_RtcDev;
94676 +}
94677 +EXPORT_SYMBOL(fm_get_rtc_handle);
94678 +
94679 +struct fm_port * fm_port_bind (struct device *fm_port_dev)
94680 +{
94681 + return (struct fm_port *)(dev_get_drvdata(get_device(fm_port_dev)));
94682 +}
94683 +EXPORT_SYMBOL(fm_port_bind);
94684 +
94685 +void fm_port_unbind(struct fm_port *port)
94686 +{
94687 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev*)port;
94688 +
94689 + put_device(p_LnxWrpFmPortDev->dev);
94690 +}
94691 +EXPORT_SYMBOL(fm_port_unbind);
94692 +
94693 +void *fm_port_get_handle(const struct fm_port *port)
94694 +{
94695 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev*)port;
94696 +
94697 + return (void *)p_LnxWrpFmPortDev->h_Dev;
94698 +}
94699 +EXPORT_SYMBOL(fm_port_get_handle);
94700 +
94701 +u64 *fm_port_get_buffer_time_stamp(const struct fm_port *port,
94702 + const void *data)
94703 +{
94704 + return FM_PORT_GetBufferTimeStamp(fm_port_get_handle(port),
94705 + (void *)data);
94706 +}
94707 +EXPORT_SYMBOL(fm_port_get_buffer_time_stamp);
94708 +
94709 +void fm_port_get_base_addr(const struct fm_port *port, uint64_t *base_addr)
94710 +{
94711 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *)port;
94712 +
94713 + *base_addr = p_LnxWrpFmPortDev->settings.param.baseAddr;
94714 +}
94715 +EXPORT_SYMBOL(fm_port_get_base_addr);
94716 +
94717 +void fm_port_pcd_bind (struct fm_port *port, struct fm_port_pcd_param *params)
94718 +{
94719 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev*)port;
94720 +
94721 + p_LnxWrpFmPortDev->pcd_owner_params.cba = params->cba;
94722 + p_LnxWrpFmPortDev->pcd_owner_params.cbf = params->cbf;
94723 + p_LnxWrpFmPortDev->pcd_owner_params.dev = params->dev;
94724 +}
94725 +EXPORT_SYMBOL(fm_port_pcd_bind);
94726 +
94727 +void fm_port_get_buff_layout_ext_params(struct fm_port *port, struct fm_port_params *params)
94728 +{
94729 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *)port;
94730 + struct device_node *fm_node, *port_node;
94731 + const uint32_t *uint32_prop;
94732 + int lenp;
94733 +
94734 + params->data_align = 0;
94735 + params->manip_extra_space = 0;
94736 +
94737 + fm_node = GetFmAdvArgsDevTreeNode(((t_LnxWrpFmDev *) p_LnxWrpFmPortDev->h_LnxWrpFmDev)->id);
94738 + if (!fm_node) /* no advance parameters for FMan */
94739 + return;
94740 +
94741 + port_node = GetFmPortAdvArgsDevTreeNode(fm_node,
94742 + p_LnxWrpFmPortDev->settings.param.portType,
94743 + p_LnxWrpFmPortDev->settings.param.portId);
94744 + if (!port_node) /* no advance parameters for FMan-Port */
94745 + return;
94746 +
94747 + uint32_prop = (uint32_t *)of_get_property(port_node, "buffer-layout", &lenp);
94748 + if (uint32_prop) {
94749 + if (WARN_ON(lenp != sizeof(uint32_t)*2))
94750 + return;
94751 +
94752 + params->manip_extra_space = (uint8_t)be32_to_cpu(uint32_prop[0]);
94753 + params->data_align = (uint16_t)be32_to_cpu(uint32_prop[1]);
94754 + }
94755 +
94756 + of_node_put(port_node);
94757 + of_node_put(fm_node);
94758 +}
94759 +EXPORT_SYMBOL(fm_port_get_buff_layout_ext_params);
94760 +
94761 +uint16_t fm_get_tx_port_channel(struct fm_port *port)
94762 +{
94763 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev*)port;
94764 +
94765 + return p_LnxWrpFmPortDev->txCh;
94766 +}
94767 +EXPORT_SYMBOL(fm_get_tx_port_channel);
94768 +
94769 +int fm_port_enable (struct fm_port *port)
94770 +{
94771 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev*)port;
94772 + t_Error err = FM_PORT_Enable(p_LnxWrpFmPortDev->h_Dev);
94773 +
94774 + return GET_ERROR_TYPE(err);
94775 +}
94776 +EXPORT_SYMBOL(fm_port_enable);
94777 +
94778 +int fm_port_disable(struct fm_port *port)
94779 +{
94780 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev*)port;
94781 + t_Error err = FM_PORT_Disable(p_LnxWrpFmPortDev->h_Dev);
94782 +
94783 + return GET_ERROR_TYPE(err);
94784 +}
94785 +EXPORT_SYMBOL(fm_port_disable);
94786 +
94787 +int fm_port_set_rate_limit(struct fm_port *port,
94788 + uint16_t max_burst_size,
94789 + uint32_t rate_limit)
94790 +{
94791 + t_FmPortRateLimit param;
94792 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *)port;
94793 + int err = 0;
94794 +
94795 + param.maxBurstSize = max_burst_size;
94796 + param.rateLimit = rate_limit;
94797 + param.rateLimitDivider = 0;
94798 +
94799 + err = FM_PORT_SetRateLimit(p_LnxWrpFmPortDev->h_Dev, &param);
94800 + return err;
94801 +}
94802 +EXPORT_SYMBOL(fm_port_set_rate_limit);
94803 +
94804 +int fm_port_del_rate_limit(struct fm_port *port)
94805 +{
94806 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *)port;
94807 +
94808 + FM_PORT_DeleteRateLimit(p_LnxWrpFmPortDev->h_Dev);
94809 + return 0;
94810 +}
94811 +EXPORT_SYMBOL(fm_port_del_rate_limit);
94812 +
94813 +void FM_PORT_Dsar_DumpRegs(void);
94814 +int ar_showmem(struct file *file, const char __user *buffer,
94815 + unsigned long count, void *data)
94816 +{
94817 + FM_PORT_Dsar_DumpRegs();
94818 + return 2;
94819 +}
94820 +
94821 +struct auto_res_tables_sizes *fm_port_get_autores_maxsize(
94822 + struct fm_port *port)
94823 +{
94824 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *)port;
94825 + return &p_LnxWrpFmPortDev->dsar_table_sizes;
94826 +}
94827 +EXPORT_SYMBOL(fm_port_get_autores_maxsize);
94828 +
94829 +int fm_port_enter_autores_for_deepsleep(struct fm_port *port,
94830 + struct auto_res_port_params *params)
94831 +{
94832 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *)port;
94833 + t_LnxWrpFmDev* p_LnxWrpFmDev = (t_LnxWrpFmDev*)p_LnxWrpFmPortDev->h_LnxWrpFmDev;
94834 + p_LnxWrpFmDev->h_DsarRxPort = p_LnxWrpFmPortDev->h_Dev;
94835 + p_LnxWrpFmDev->h_DsarTxPort = params->h_FmPortTx;
94836 +
94837 + /*Register other under /proc/autoresponse */
94838 + if (WARN_ON(sizeof(t_FmPortDsarParams) != sizeof(struct auto_res_port_params)))
94839 + return -EFAULT;
94840 +
94841 + FM_PORT_EnterDsar(p_LnxWrpFmPortDev->h_Dev, (t_FmPortDsarParams*)params);
94842 + return 0;
94843 +}
94844 +EXPORT_SYMBOL(fm_port_enter_autores_for_deepsleep);
94845 +
94846 +void fm_port_exit_auto_res_for_deep_sleep(struct fm_port *port_rx,
94847 + struct fm_port *port_tx)
94848 +{
94849 +}
94850 +EXPORT_SYMBOL(fm_port_exit_auto_res_for_deep_sleep);
94851 +
94852 +int fm_port_get_autores_stats(struct fm_port *port,
94853 + struct auto_res_port_stats *stats)
94854 +{
94855 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *)port;
94856 + if (WARN_ON(sizeof(t_FmPortDsarStats) != sizeof(struct auto_res_port_stats)))
94857 + return -EFAULT;
94858 + return FM_PORT_GetDsarStats(p_LnxWrpFmPortDev->h_Dev, (t_FmPortDsarStats*)stats);
94859 +}
94860 +EXPORT_SYMBOL(fm_port_get_autores_stats);
94861 +
94862 +int fm_port_suspend(struct fm_port *port)
94863 +{
94864 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *)port;
94865 + if (!FM_PORT_IsInDsar(p_LnxWrpFmPortDev->h_Dev))
94866 + return FM_PORT_Disable(p_LnxWrpFmPortDev->h_Dev);
94867 + else
94868 + return 0;
94869 +}
94870 +EXPORT_SYMBOL(fm_port_suspend);
94871 +
94872 +int fm_port_resume(struct fm_port *port)
94873 +{
94874 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *)port;
94875 + if (!FM_PORT_IsInDsar(p_LnxWrpFmPortDev->h_Dev))
94876 + return FM_PORT_Enable(p_LnxWrpFmPortDev->h_Dev);
94877 + else
94878 + return 0;
94879 +}
94880 +EXPORT_SYMBOL(fm_port_resume);
94881 +
94882 +bool fm_port_is_in_auto_res_mode(struct fm_port *port)
94883 +{
94884 + return FM_PORT_IsInDsar(port);
94885 +}
94886 +EXPORT_SYMBOL(fm_port_is_in_auto_res_mode);
94887 +
94888 +#ifdef CONFIG_FMAN_PFC
94889 +int fm_port_set_pfc_priorities_mapping_to_qman_wq(struct fm_port *port,
94890 + uint8_t prio, uint8_t wq)
94891 +{
94892 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *)port;
94893 + int err;
94894 + int _errno;
94895 +
94896 + err = FM_PORT_SetPfcPrioritiesMappingToQmanWQ(p_LnxWrpFmPortDev->h_Dev,
94897 + prio, wq);
94898 + _errno = -GET_ERROR_TYPE(err);
94899 + if (unlikely(_errno < 0))
94900 + pr_err("FM_PORT_SetPfcPrioritiesMappingToQmanWQ() = 0x%08x\n", err);
94901 +
94902 + return _errno;
94903 +}
94904 +EXPORT_SYMBOL(fm_port_set_pfc_priorities_mapping_to_qman_wq);
94905 +#endif
94906 +
94907 +int fm_mac_set_exception(struct fm_mac_dev *fm_mac_dev,
94908 + e_FmMacExceptions exception, bool enable)
94909 +{
94910 + int err;
94911 + int _errno;
94912 +
94913 + err = FM_MAC_SetException(fm_mac_dev, exception, enable);
94914 +
94915 + _errno = -GET_ERROR_TYPE(err);
94916 + if (unlikely(_errno < 0))
94917 + pr_err("FM_MAC_SetException() = 0x%08x\n", err);
94918 +
94919 + return _errno;
94920 +}
94921 +EXPORT_SYMBOL(fm_mac_set_exception);
94922 +
94923 +int fm_mac_free(struct fm_mac_dev *fm_mac_dev)
94924 +{
94925 + int err;
94926 + int _error;
94927 +
94928 + err = FM_MAC_Free(fm_mac_dev);
94929 + _error = -GET_ERROR_TYPE(err);
94930 +
94931 + if (unlikely(_error < 0))
94932 + pr_err("FM_MAC_Free() = 0x%08x\n", err);
94933 +
94934 + return _error;
94935 +}
94936 +EXPORT_SYMBOL(fm_mac_free);
94937 +
94938 +struct fm_mac_dev *fm_mac_config(t_FmMacParams *params)
94939 +{
94940 + struct fm_mac_dev *fm_mac_dev;
94941 +
94942 + fm_mac_dev = FM_MAC_Config(params);
94943 + if (unlikely(fm_mac_dev == NULL))
94944 + pr_err("FM_MAC_Config() failed\n");
94945 +
94946 + return fm_mac_dev;
94947 +}
94948 +EXPORT_SYMBOL(fm_mac_config);
94949 +
94950 +int fm_mac_config_max_frame_length(struct fm_mac_dev *fm_mac_dev,
94951 + int len)
94952 +{
94953 + int err;
94954 + int _errno;
94955 +
94956 + err = FM_MAC_ConfigMaxFrameLength(fm_mac_dev, len);
94957 + _errno = -GET_ERROR_TYPE(err);
94958 + if (unlikely(_errno < 0))
94959 + pr_err("FM_MAC_ConfigMaxFrameLength() = 0x%08x\n", err);
94960 +
94961 + return _errno;
94962 +}
94963 +EXPORT_SYMBOL(fm_mac_config_max_frame_length);
94964 +
94965 +int fm_mac_config_pad_and_crc(struct fm_mac_dev *fm_mac_dev, bool enable)
94966 +{
94967 + int err;
94968 + int _errno;
94969 +
94970 + err = FM_MAC_ConfigPadAndCrc(fm_mac_dev, enable);
94971 + _errno = -GET_ERROR_TYPE(err);
94972 + if (unlikely(_errno < 0))
94973 + pr_err("FM_MAC_ConfigPadAndCrc() = 0x%08x\n", err);
94974 +
94975 + return _errno;
94976 +}
94977 +EXPORT_SYMBOL(fm_mac_config_pad_and_crc);
94978 +
94979 +int fm_mac_config_half_duplex(struct fm_mac_dev *fm_mac_dev, bool enable)
94980 +{
94981 + int err;
94982 + int _errno;
94983 +
94984 + err = FM_MAC_ConfigHalfDuplex(fm_mac_dev, enable);
94985 + _errno = -GET_ERROR_TYPE(err);
94986 + if (unlikely(_errno < 0))
94987 + pr_err("FM_MAC_ConfigHalfDuplex() = 0x%08x\n", err);
94988 +
94989 + return _errno;
94990 +}
94991 +EXPORT_SYMBOL(fm_mac_config_half_duplex);
94992 +
94993 +int fm_mac_config_reset_on_init(struct fm_mac_dev *fm_mac_dev, bool enable)
94994 +{
94995 + int err;
94996 + int _errno;
94997 +
94998 + err = FM_MAC_ConfigResetOnInit(fm_mac_dev, enable);
94999 + _errno = -GET_ERROR_TYPE(err);
95000 + if (unlikely(_errno < 0))
95001 + pr_err("FM_MAC_ConfigResetOnInit() = 0x%08x\n", err);
95002 +
95003 + return _errno;
95004 +}
95005 +EXPORT_SYMBOL(fm_mac_config_reset_on_init);
95006 +
95007 +int fm_mac_init(struct fm_mac_dev *fm_mac_dev)
95008 +{
95009 + int err;
95010 + int _errno;
95011 +
95012 + err = FM_MAC_Init(fm_mac_dev);
95013 + _errno = -GET_ERROR_TYPE(err);
95014 + if (unlikely(_errno < 0))
95015 + pr_err("FM_MAC_Init() = 0x%08x\n", err);
95016 +
95017 + return _errno;
95018 +}
95019 +EXPORT_SYMBOL(fm_mac_init);
95020 +
95021 +int fm_mac_get_version(struct fm_mac_dev *fm_mac_dev, uint32_t *version)
95022 +{
95023 + int err;
95024 + int _errno;
95025 +
95026 + err = FM_MAC_GetVesrion(fm_mac_dev, version);
95027 + _errno = -GET_ERROR_TYPE(err);
95028 + if (unlikely(_errno < 0))
95029 + pr_err("FM_MAC_GetVesrion() = 0x%08x\n", err);
95030 +
95031 + return _errno;
95032 +}
95033 +EXPORT_SYMBOL(fm_mac_get_version);
95034 +
95035 +int fm_mac_enable(struct fm_mac_dev *fm_mac_dev)
95036 +{
95037 + int _errno;
95038 + t_Error err;
95039 +
95040 + err = FM_MAC_Enable(fm_mac_dev, e_COMM_MODE_RX_AND_TX);
95041 + _errno = -GET_ERROR_TYPE(err);
95042 + if (unlikely(_errno < 0))
95043 + pr_err("FM_MAC_Enable() = 0x%08x\n", err);
95044 +
95045 + return _errno;
95046 +}
95047 +EXPORT_SYMBOL(fm_mac_enable);
95048 +
95049 +int fm_mac_disable(struct fm_mac_dev *fm_mac_dev)
95050 +{
95051 + int _errno;
95052 + t_Error err;
95053 +
95054 + err = FM_MAC_Disable(fm_mac_dev, e_COMM_MODE_RX_AND_TX);
95055 + _errno = -GET_ERROR_TYPE(err);
95056 + if (unlikely(_errno < 0))
95057 + pr_err("FM_MAC_Disable() = 0x%08x\n", err);
95058 +
95059 + return _errno;
95060 +}
95061 +EXPORT_SYMBOL(fm_mac_disable);
95062 +
95063 +int fm_mac_set_promiscuous(struct fm_mac_dev *fm_mac_dev,
95064 + bool enable)
95065 +{
95066 + int _errno;
95067 + t_Error err;
95068 +
95069 + err = FM_MAC_SetPromiscuous(fm_mac_dev, enable);
95070 + _errno = -GET_ERROR_TYPE(err);
95071 + if (unlikely(_errno < 0))
95072 + pr_err("FM_MAC_SetPromiscuous() = 0x%08x\n", err);
95073 +
95074 + return _errno;
95075 +}
95076 +EXPORT_SYMBOL(fm_mac_set_promiscuous);
95077 +
95078 +int fm_mac_remove_hash_mac_addr(struct fm_mac_dev *fm_mac_dev,
95079 + t_EnetAddr *mac_addr)
95080 +{
95081 + int _errno;
95082 + t_Error err;
95083 +
95084 + err = FM_MAC_RemoveHashMacAddr(fm_mac_dev, mac_addr);
95085 + _errno = -GET_ERROR_TYPE(err);
95086 + if (_errno < 0) {
95087 + pr_err("FM_MAC_RemoveHashMacAddr() = 0x%08x\n", err);
95088 + return _errno;
95089 + }
95090 +
95091 + return 0;
95092 +}
95093 +EXPORT_SYMBOL(fm_mac_remove_hash_mac_addr);
95094 +
95095 +int fm_mac_add_hash_mac_addr(struct fm_mac_dev *fm_mac_dev,
95096 + t_EnetAddr *mac_addr)
95097 +{
95098 + int _errno;
95099 + t_Error err;
95100 +
95101 + err = FM_MAC_AddHashMacAddr(fm_mac_dev, mac_addr);
95102 + _errno = -GET_ERROR_TYPE(err);
95103 + if (_errno < 0) {
95104 + pr_err("FM_MAC_AddHashMacAddr() = 0x%08x\n", err);
95105 + return _errno;
95106 + }
95107 +
95108 + return 0;
95109 +}
95110 +EXPORT_SYMBOL(fm_mac_add_hash_mac_addr);
95111 +
95112 +int fm_mac_modify_mac_addr(struct fm_mac_dev *fm_mac_dev,
95113 + uint8_t *addr)
95114 +{
95115 + int _errno;
95116 + t_Error err;
95117 +
95118 + err = FM_MAC_ModifyMacAddr(fm_mac_dev, (t_EnetAddr *)addr);
95119 + _errno = -GET_ERROR_TYPE(err);
95120 + if (_errno < 0)
95121 + pr_err("FM_MAC_ModifyMacAddr() = 0x%08x\n", err);
95122 +
95123 + return _errno;
95124 +}
95125 +EXPORT_SYMBOL(fm_mac_modify_mac_addr);
95126 +
95127 +int fm_mac_adjust_link(struct fm_mac_dev *fm_mac_dev,
95128 + bool link, int speed, bool duplex)
95129 +{
95130 + int _errno;
95131 + t_Error err;
95132 +
95133 + if (!link) {
95134 +#if (DPAA_VERSION < 11)
95135 + FM_MAC_RestartAutoneg(fm_mac_dev);
95136 +#endif
95137 + return 0;
95138 + }
95139 +
95140 + err = FM_MAC_AdjustLink(fm_mac_dev, speed, duplex);
95141 + _errno = -GET_ERROR_TYPE(err);
95142 + if (unlikely(_errno < 0))
95143 + pr_err("FM_MAC_AdjustLink() = 0x%08x\n", err);
95144 +
95145 + return _errno;
95146 +}
95147 +EXPORT_SYMBOL(fm_mac_adjust_link);
95148 +
95149 +int fm_mac_enable_1588_time_stamp(struct fm_mac_dev *fm_mac_dev)
95150 +{
95151 + int _errno;
95152 + t_Error err;
95153 +
95154 + err = FM_MAC_Enable1588TimeStamp(fm_mac_dev);
95155 + _errno = -GET_ERROR_TYPE(err);
95156 + if (unlikely(_errno < 0))
95157 + pr_err("FM_MAC_Enable1588TimeStamp() = 0x%08x\n", err);
95158 + return _errno;
95159 +}
95160 +EXPORT_SYMBOL(fm_mac_enable_1588_time_stamp);
95161 +
95162 +int fm_mac_disable_1588_time_stamp(struct fm_mac_dev *fm_mac_dev)
95163 +{
95164 + int _errno;
95165 + t_Error err;
95166 +
95167 + err = FM_MAC_Disable1588TimeStamp(fm_mac_dev);
95168 + _errno = -GET_ERROR_TYPE(err);
95169 + if (unlikely(_errno < 0))
95170 + pr_err("FM_MAC_Disable1588TimeStamp() = 0x%08x\n", err);
95171 + return _errno;
95172 +}
95173 +EXPORT_SYMBOL(fm_mac_disable_1588_time_stamp);
95174 +
95175 +int fm_mac_set_rx_pause_frames(
95176 + struct fm_mac_dev *fm_mac_dev, bool en)
95177 +{
95178 + int _errno;
95179 + t_Error err;
95180 +
95181 + /* if rx pause is enabled, do NOT ignore pause frames */
95182 + err = FM_MAC_SetRxIgnorePauseFrames(fm_mac_dev, !en);
95183 +
95184 + _errno = -GET_ERROR_TYPE(err);
95185 + if (_errno < 0)
95186 + pr_err("FM_MAC_SetRxIgnorePauseFrames() = 0x%08x\n", err);
95187 +
95188 + return _errno;
95189 +}
95190 +EXPORT_SYMBOL(fm_mac_set_rx_pause_frames);
95191 +
95192 +#ifdef CONFIG_FMAN_PFC
95193 +int fm_mac_set_tx_pause_frames(struct fm_mac_dev *fm_mac_dev,
95194 + bool en)
95195 +{
95196 + int _errno, i;
95197 + t_Error err;
95198 +
95199 + if (en)
95200 + for (i = 0; i < CONFIG_FMAN_PFC_COS_COUNT; i++) {
95201 + err = FM_MAC_SetTxPauseFrames(fm_mac_dev,
95202 + i, fsl_fm_pfc_quanta[i],
95203 + FSL_FM_PAUSE_THRESH_DEFAULT);
95204 + _errno = -GET_ERROR_TYPE(err);
95205 + if (_errno < 0) {
95206 + pr_err("FM_MAC_SetTxPauseFrames() = 0x%08x\n", err);
95207 + return _errno;
95208 + }
95209 + }
95210 + else
95211 + for (i = 0; i < CONFIG_FMAN_PFC_COS_COUNT; i++) {
95212 + err = FM_MAC_SetTxPauseFrames(fm_mac_dev,
95213 + i, FSL_FM_PAUSE_TIME_DISABLE,
95214 + FSL_FM_PAUSE_THRESH_DEFAULT);
95215 + _errno = -GET_ERROR_TYPE(err);
95216 + if (_errno < 0) {
95217 + pr_err("FM_MAC_SetTxPauseFrames() = 0x%08x\n", err);
95218 + return _errno;
95219 + }
95220 + }
95221 +
95222 + return _errno;
95223 +}
95224 +#else
95225 +int fm_mac_set_tx_pause_frames(struct fm_mac_dev *fm_mac_dev,
95226 + bool en)
95227 +{
95228 + int _errno;
95229 + t_Error err;
95230 +
95231 + if (en)
95232 + err = FM_MAC_SetTxAutoPauseFrames(fm_mac_dev,
95233 + FSL_FM_PAUSE_TIME_ENABLE);
95234 + else
95235 + err = FM_MAC_SetTxAutoPauseFrames(fm_mac_dev,
95236 + FSL_FM_PAUSE_TIME_DISABLE);
95237 +
95238 + _errno = -GET_ERROR_TYPE(err);
95239 + if (_errno < 0)
95240 + pr_err("FM_MAC_SetTxAutoPauseFrames() = 0x%08x\n", err);
95241 +
95242 + return _errno;
95243 +}
95244 +#endif
95245 +EXPORT_SYMBOL(fm_mac_set_tx_pause_frames);
95246 +
95247 +int fm_rtc_enable(struct fm *fm_dev)
95248 +{
95249 + int _errno;
95250 + t_Error err;
95251 +
95252 + err = FM_RTC_Enable(fm_get_rtc_handle(fm_dev), 0);
95253 + _errno = -GET_ERROR_TYPE(err);
95254 + if (unlikely(_errno < 0))
95255 + pr_err("FM_RTC_Enable = 0x%08x\n", err);
95256 +
95257 + return _errno;
95258 +}
95259 +EXPORT_SYMBOL(fm_rtc_enable);
95260 +
95261 +int fm_rtc_disable(struct fm *fm_dev)
95262 +{
95263 + int _errno;
95264 + t_Error err;
95265 +
95266 + err = FM_RTC_Disable(fm_get_rtc_handle(fm_dev));
95267 + _errno = -GET_ERROR_TYPE(err);
95268 + if (unlikely(_errno < 0))
95269 + pr_err("FM_RTC_Disable = 0x%08x\n", err);
95270 +
95271 + return _errno;
95272 +}
95273 +EXPORT_SYMBOL(fm_rtc_disable);
95274 +
95275 +int fm_rtc_get_cnt(struct fm *fm_dev, uint64_t *ts)
95276 +{
95277 + int _errno;
95278 + t_Error err;
95279 +
95280 + err = FM_RTC_GetCurrentTime(fm_get_rtc_handle(fm_dev), ts);
95281 + _errno = -GET_ERROR_TYPE(err);
95282 + if (unlikely(_errno < 0))
95283 + pr_err("FM_RTC_GetCurrentTime = 0x%08x\n", err);
95284 +
95285 + return _errno;
95286 +}
95287 +EXPORT_SYMBOL(fm_rtc_get_cnt);
95288 +
95289 +int fm_rtc_set_cnt(struct fm *fm_dev, uint64_t ts)
95290 +{
95291 + int _errno;
95292 + t_Error err;
95293 +
95294 + err = FM_RTC_SetCurrentTime(fm_get_rtc_handle(fm_dev), ts);
95295 + _errno = -GET_ERROR_TYPE(err);
95296 + if (unlikely(_errno < 0))
95297 + pr_err("FM_RTC_SetCurrentTime = 0x%08x\n", err);
95298 +
95299 + return _errno;
95300 +}
95301 +EXPORT_SYMBOL(fm_rtc_set_cnt);
95302 +
95303 +int fm_rtc_get_drift(struct fm *fm_dev, uint32_t *drift)
95304 +{
95305 + int _errno;
95306 + t_Error err;
95307 +
95308 + err = FM_RTC_GetFreqCompensation(fm_get_rtc_handle(fm_dev),
95309 + drift);
95310 + _errno = -GET_ERROR_TYPE(err);
95311 + if (unlikely(_errno < 0))
95312 + pr_err("FM_RTC_GetFreqCompensation = 0x%08x\n", err);
95313 +
95314 + return _errno;
95315 +}
95316 +EXPORT_SYMBOL(fm_rtc_get_drift);
95317 +
95318 +int fm_rtc_set_drift(struct fm *fm_dev, uint32_t drift)
95319 +{
95320 + int _errno;
95321 + t_Error err;
95322 +
95323 + err = FM_RTC_SetFreqCompensation(fm_get_rtc_handle(fm_dev),
95324 + drift);
95325 + _errno = -GET_ERROR_TYPE(err);
95326 + if (unlikely(_errno < 0))
95327 + pr_err("FM_RTC_SetFreqCompensation = 0x%08x\n", err);
95328 +
95329 + return _errno;
95330 +}
95331 +EXPORT_SYMBOL(fm_rtc_set_drift);
95332 +
95333 +int fm_rtc_set_alarm(struct fm *fm_dev, uint32_t id,
95334 + uint64_t time)
95335 +{
95336 + t_FmRtcAlarmParams alarm;
95337 + int _errno;
95338 + t_Error err;
95339 +
95340 + alarm.alarmId = id;
95341 + alarm.alarmTime = time;
95342 + alarm.f_AlarmCallback = NULL;
95343 + err = FM_RTC_SetAlarm(fm_get_rtc_handle(fm_dev),
95344 + &alarm);
95345 + _errno = -GET_ERROR_TYPE(err);
95346 + if (unlikely(_errno < 0))
95347 + pr_err("FM_RTC_SetAlarm = 0x%08x\n", err);
95348 +
95349 + return _errno;
95350 +}
95351 +EXPORT_SYMBOL(fm_rtc_set_alarm);
95352 +
95353 +int fm_rtc_set_fiper(struct fm *fm_dev, uint32_t id,
95354 + uint64_t fiper)
95355 +{
95356 + t_FmRtcPeriodicPulseParams pp;
95357 + int _errno;
95358 + t_Error err;
95359 +
95360 + pp.periodicPulseId = id;
95361 + pp.periodicPulsePeriod = fiper;
95362 + pp.f_PeriodicPulseCallback = NULL;
95363 + err = FM_RTC_SetPeriodicPulse(fm_get_rtc_handle(fm_dev), &pp);
95364 + _errno = -GET_ERROR_TYPE(err);
95365 + if (unlikely(_errno < 0))
95366 + pr_err("FM_RTC_SetPeriodicPulse = 0x%08x\n", err);
95367 +
95368 + return _errno;
95369 +}
95370 +EXPORT_SYMBOL(fm_rtc_set_fiper);
95371 +
95372 +#ifdef CONFIG_PTP_1588_CLOCK_DPAA
95373 +int fm_rtc_enable_interrupt(struct fm *fm_dev, uint32_t events)
95374 +{
95375 + int _errno;
95376 + t_Error err;
95377 +
95378 + err = FM_RTC_EnableInterrupt(fm_get_rtc_handle(fm_dev),
95379 + events);
95380 + _errno = -GET_ERROR_TYPE(err);
95381 + if (unlikely(_errno < 0))
95382 + pr_err("FM_RTC_EnableInterrupt = 0x%08x\n", err);
95383 +
95384 + return _errno;
95385 +}
95386 +EXPORT_SYMBOL(fm_rtc_enable_interrupt);
95387 +
95388 +int fm_rtc_disable_interrupt(struct fm *fm_dev, uint32_t events)
95389 +{
95390 + int _errno;
95391 + t_Error err;
95392 +
95393 + err = FM_RTC_DisableInterrupt(fm_get_rtc_handle(fm_dev),
95394 + events);
95395 + _errno = -GET_ERROR_TYPE(err);
95396 + if (unlikely(_errno < 0))
95397 + pr_err("FM_RTC_DisableInterrupt = 0x%08x\n", err);
95398 +
95399 + return _errno;
95400 +}
95401 +EXPORT_SYMBOL(fm_rtc_disable_interrupt);
95402 +#endif
95403 +
95404 +int fm_mac_set_wol(struct fm_port *port, struct fm_mac_dev *fm_mac_dev, bool en)
95405 +{
95406 + int _errno;
95407 + t_Error err;
95408 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *)port;
95409 +
95410 + /* Do not set WoL on AR ports */
95411 + if (FM_PORT_IsInDsar(p_LnxWrpFmPortDev->h_Dev)) {
95412 + printk(KERN_WARNING "Port is AutoResponse enabled! WoL will not be set on this port!\n");
95413 + return 0;
95414 + }
95415 +
95416 + err = FM_MAC_SetWakeOnLan(fm_mac_dev, en);
95417 +
95418 + _errno = -GET_ERROR_TYPE(err);
95419 + if (_errno < 0)
95420 + pr_err("FM_MAC_SetWakeOnLan() = 0x%08x\n", err);
95421 +
95422 + return _errno;
95423 +}
95424 +EXPORT_SYMBOL(fm_mac_set_wol);
95425 +
95426 +void fm_mutex_lock(void)
95427 +{
95428 + mutex_lock(&lnxwrp_mutex);
95429 +}
95430 +EXPORT_SYMBOL(fm_mutex_lock);
95431 +
95432 +void fm_mutex_unlock(void)
95433 +{
95434 + mutex_unlock(&lnxwrp_mutex);
95435 +}
95436 +EXPORT_SYMBOL(fm_mutex_unlock);
95437 +
95438 +/*Macsec wrapper functions*/
95439 +struct fm_macsec_dev *fm_macsec_config(struct fm_macsec_params *fm_params)
95440 +{
95441 + struct fm_macsec_dev *fm_macsec_dev;
95442 +
95443 + fm_macsec_dev = FM_MACSEC_Config((t_FmMacsecParams *)fm_params);
95444 + if (unlikely(fm_macsec_dev == NULL))
95445 + pr_err("FM_MACSEC_Config() failed\n");
95446 +
95447 + return fm_macsec_dev;
95448 +}
95449 +EXPORT_SYMBOL(fm_macsec_config);
95450 +
95451 +int fm_macsec_init(struct fm_macsec_dev *fm_macsec_dev)
95452 +{
95453 + int err;
95454 + int _errno;
95455 +
95456 + err = FM_MACSEC_Init(fm_macsec_dev);
95457 + _errno = -GET_ERROR_TYPE(err);
95458 + if (unlikely(_errno < 0))
95459 + pr_err("FM_MACSEC_Init() = 0x%08x\n", err);
95460 +
95461 + return _errno;
95462 +}
95463 +EXPORT_SYMBOL(fm_macsec_init);
95464 +
95465 +int fm_macsec_free(struct fm_macsec_dev *fm_macsec_dev)
95466 +{
95467 + int err;
95468 + int _error;
95469 +
95470 + err = FM_MACSEC_Free(fm_macsec_dev);
95471 + _error = -GET_ERROR_TYPE(err);
95472 +
95473 + if (unlikely(_error < 0))
95474 + pr_err("FM_MACSEC_Free() = 0x%08x\n", err);
95475 +
95476 + return _error;
95477 +}
95478 +EXPORT_SYMBOL(fm_macsec_free);
95479 +
95480 +int fm_macsec_config_unknown_sci_frame_treatment(struct fm_macsec_dev
95481 + *fm_macsec_dev,
95482 + fm_macsec_unknown_sci_frame_treatment treat_mode)
95483 +{
95484 + int err;
95485 + int _errno;
95486 +
95487 + err = FM_MACSEC_ConfigUnknownSciFrameTreatment(fm_macsec_dev,
95488 + treat_mode);
95489 + _errno = -GET_ERROR_TYPE(err);
95490 + if (unlikely(_errno < 0))
95491 + pr_err("FM_MACSEC_ConfigUnknownSciFrameTreatmen() = 0x%08x\n", err);
95492 +
95493 + return _errno;
95494 +}
95495 +EXPORT_SYMBOL(fm_macsec_config_unknown_sci_frame_treatment);
95496 +
95497 +int fm_macsec_config_invalid_tags_frame_treatment(struct fm_macsec_dev *fm_macsec_dev,
95498 + bool deliver_uncontrolled)
95499 +{
95500 + int err;
95501 + int _errno;
95502 +
95503 + err = FM_MACSEC_ConfigInvalidTagsFrameTreatment(fm_macsec_dev,
95504 + deliver_uncontrolled);
95505 + _errno = -GET_ERROR_TYPE(err);
95506 + if (unlikely(_errno < 0))
95507 + pr_err("FM_MAC_ConfigMaxFrameLength() = 0x%08x\n", err);
95508 +
95509 + return _errno;
95510 +}
95511 +EXPORT_SYMBOL(fm_macsec_config_invalid_tags_frame_treatment);
95512 +
95513 +int fm_macsec_config_kay_frame_treatment(struct fm_macsec_dev *fm_macsec_dev,
95514 + bool discard_uncontrolled)
95515 +{
95516 + int err;
95517 + int _errno;
95518 +
95519 + err = FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment(fm_macsec_dev,
95520 + discard_uncontrolled);
95521 + _errno = -GET_ERROR_TYPE(err);
95522 + if (unlikely(_errno < 0))
95523 + pr_err("FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatmen() = 0x%08x\n", err);
95524 +
95525 + return _errno;
95526 +}
95527 +EXPORT_SYMBOL(fm_macsec_config_kay_frame_treatment);
95528 +
95529 +int fm_macsec_config_untag_frame_treatment(struct fm_macsec_dev *fm_macsec_dev,
95530 + fm_macsec_untag_frame_treatment treat_mode)
95531 +{
95532 + int err;
95533 + int _errno;
95534 +
95535 + err = FM_MACSEC_ConfigUntagFrameTreatment(fm_macsec_dev, treat_mode);
95536 + _errno = -GET_ERROR_TYPE(err);
95537 + if (unlikely(_errno < 0))
95538 + pr_err("FM_MACSEC_ConfigUntagFrameTreatment() = 0x%08x\n", err);
95539 +
95540 + return _errno;
95541 +}
95542 +EXPORT_SYMBOL(fm_macsec_config_untag_frame_treatment);
95543 +
95544 +int fm_macsec_config_pn_exhaustion_threshold(struct fm_macsec_dev *fm_macsec_dev,
95545 + uint32_t pn_exh_thr)
95546 +{
95547 + int err;
95548 + int _errno;
95549 +
95550 + err = FM_MACSEC_ConfigPnExhaustionThreshold(fm_macsec_dev, pn_exh_thr);
95551 + _errno = -GET_ERROR_TYPE(err);
95552 + if (unlikely(_errno < 0))
95553 + pr_err("FM_MACSEC_ConfigPnExhaustionThreshold() = 0x%08x\n", err);
95554 +
95555 + return _errno;
95556 +}
95557 +EXPORT_SYMBOL(fm_macsec_config_pn_exhaustion_threshold);
95558 +
95559 +int fm_macsec_config_keys_unreadable(struct fm_macsec_dev *fm_macsec_dev)
95560 +{
95561 + int err;
95562 + int _errno;
95563 +
95564 + err = FM_MACSEC_ConfigKeysUnreadable(fm_macsec_dev);
95565 + _errno = -GET_ERROR_TYPE(err);
95566 + if (unlikely(_errno < 0))
95567 + pr_err("FM_MACSEC_ConfigKeysUnreadable() = 0x%08x\n", err);
95568 +
95569 + return _errno;
95570 +}
95571 +EXPORT_SYMBOL(fm_macsec_config_keys_unreadable);
95572 +
95573 +int fm_macsec_config_sectag_without_sci(struct fm_macsec_dev *fm_macsec_dev)
95574 +{
95575 + int err;
95576 + int _errno;
95577 +
95578 + err = FM_MACSEC_ConfigSectagWithoutSCI(fm_macsec_dev);
95579 + _errno = -GET_ERROR_TYPE(err);
95580 + if (unlikely(_errno < 0))
95581 + pr_err("FM_MACSEC_ConfigSectagWithoutSCI() = 0x%08x\n", err);
95582 +
95583 + return _errno;
95584 +}
95585 +EXPORT_SYMBOL(fm_macsec_config_sectag_without_sci);
95586 +
95587 +int fm_macsec_config_exception(struct fm_macsec_dev *fm_macsec_dev,
95588 + fm_macsec_exception exception, bool enable)
95589 +{
95590 + int err;
95591 + int _errno;
95592 +
95593 + err = FM_MACSEC_ConfigException(fm_macsec_dev, exception, enable);
95594 + _errno = -GET_ERROR_TYPE(err);
95595 + if (unlikely(_errno < 0))
95596 + pr_err("FM_MACSEC_ConfigException() = 0x%08x\n", err);
95597 +
95598 + return _errno;
95599 +}
95600 +EXPORT_SYMBOL(fm_macsec_config_exception);
95601 +
95602 +int fm_macsec_get_revision(struct fm_macsec_dev *fm_macsec_dev,
95603 + int *macsec_revision)
95604 +{
95605 + int err;
95606 + int _errno;
95607 +
95608 + err = FM_MACSEC_GetRevision(fm_macsec_dev, macsec_revision);
95609 + _errno = -GET_ERROR_TYPE(err);
95610 + if (unlikely(_errno < 0))
95611 + pr_err("FM_MACSEC_GetRevision() = 0x%08x\n", err);
95612 +
95613 + return _errno;
95614 +}
95615 +EXPORT_SYMBOL(fm_macsec_get_revision);
95616 +
95617 +int fm_macsec_enable(struct fm_macsec_dev *fm_macsec_dev)
95618 +{
95619 + int err;
95620 + int _errno;
95621 +
95622 + err = FM_MACSEC_Enable(fm_macsec_dev);
95623 + _errno = -GET_ERROR_TYPE(err);
95624 + if (unlikely(_errno < 0))
95625 + pr_err("FM_MACSEC_Enable() = 0x%08x\n", err);
95626 +
95627 + return _errno;
95628 +}
95629 +EXPORT_SYMBOL(fm_macsec_enable);
95630 +
95631 +int fm_macsec_disable(struct fm_macsec_dev *fm_macsec_dev)
95632 +{
95633 + int err;
95634 + int _errno;
95635 +
95636 + err = FM_MACSEC_Disable(fm_macsec_dev);
95637 + _errno = -GET_ERROR_TYPE(err);
95638 + if (unlikely(_errno < 0))
95639 + pr_err("FM_MACSEC_Disable() = 0x%08x\n", err);
95640 +
95641 + return _errno;
95642 +}
95643 +EXPORT_SYMBOL(fm_macsec_disable);
95644 +
95645 +int fm_macsec_set_exception(struct fm_macsec_dev *fm_macsec_dev,
95646 + fm_macsec_exception exception, bool enable)
95647 +{
95648 + int err;
95649 + int _errno;
95650 +
95651 + err = FM_MACSEC_SetException(fm_macsec_dev, exception, enable);
95652 + _errno = -GET_ERROR_TYPE(err);
95653 + if (unlikely(_errno < 0))
95654 + pr_err("FM_MACSEC_SetException() = 0x%08x\n", err);
95655 +
95656 + return _errno;
95657 +}
95658 +EXPORT_SYMBOL(fm_macsec_set_exception);
95659 +
95660 +/* Macsec SECY wrapper API */
95661 +struct fm_macsec_secy_dev *fm_macsec_secy_config(struct fm_macsec_secy_params *secy_params)
95662 +{
95663 + struct fm_macsec_secy_dev *fm_macsec_secy;
95664 +
95665 + fm_macsec_secy = FM_MACSEC_SECY_Config((t_FmMacsecSecYParams *)secy_params);
95666 + if (unlikely(fm_macsec_secy < 0))
95667 + pr_err("FM_MACSEC_SECY_Config() failed\n");
95668 +
95669 + return fm_macsec_secy;
95670 +}
95671 +EXPORT_SYMBOL(fm_macsec_secy_config);
95672 +
95673 +int fm_macsec_secy_init(struct fm_macsec_secy_dev *fm_macsec_secy_dev)
95674 +{
95675 + int err;
95676 + int _errno;
95677 +
95678 + err = FM_MACSEC_SECY_Init(fm_macsec_secy_dev);
95679 + _errno = -GET_ERROR_TYPE(err);
95680 + if (unlikely(_errno < 0))
95681 + pr_err("FM_MACSEC_SECY_Init() = 0x%08x\n", err);
95682 +
95683 + return _errno;
95684 +}
95685 +EXPORT_SYMBOL(fm_macsec_secy_init);
95686 +
95687 +int fm_macsec_secy_free(struct fm_macsec_secy_dev *fm_macsec_secy_dev)
95688 +{
95689 + int err;
95690 + int _errno;
95691 +
95692 + err = FM_MACSEC_SECY_Free(fm_macsec_secy_dev);
95693 + _errno = -GET_ERROR_TYPE(err);
95694 + if (unlikely(_errno < 0))
95695 + pr_err("FM_MACSEC_SECY_Free() = 0x%08x\n", err);
95696 +
95697 + return _errno;
95698 +}
95699 +EXPORT_SYMBOL(fm_macsec_secy_free);
95700 +
95701 +int fm_macsec_secy_config_sci_insertion_mode(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95702 + fm_macsec_sci_insertion_mode sci_insertion_mode)
95703 +{
95704 + int err;
95705 + int _errno;
95706 +
95707 + err = FM_MACSEC_SECY_ConfigSciInsertionMode(fm_macsec_secy_dev,
95708 + sci_insertion_mode);
95709 + _errno = -GET_ERROR_TYPE(err);
95710 + if (unlikely(_errno < 0))
95711 + pr_err("FM_MACSEC_SECY_ConfigSciInsertionMode() = 0x%08x\n", err);
95712 +
95713 + return _errno;
95714 +}
95715 +EXPORT_SYMBOL(fm_macsec_secy_config_sci_insertion_mode);
95716 +
95717 +int fm_macsec_secy_config_protect_frames(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95718 + bool protect_frames)
95719 +{
95720 + int err;
95721 + int _errno;
95722 +
95723 + err = FM_MACSEC_SECY_ConfigProtectFrames(fm_macsec_secy_dev,
95724 + protect_frames);
95725 + _errno = -GET_ERROR_TYPE(err);
95726 + if (unlikely(_errno < 0))
95727 + pr_err("FM_MACSEC_SECY_ConfigProtectFrames() = 0x%08x\n", err);
95728 +
95729 + return _errno;
95730 +}
95731 +EXPORT_SYMBOL(fm_macsec_secy_config_protect_frames);
95732 +
95733 +int fm_macsec_secy_config_replay_window(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95734 + bool replay_protect, uint32_t replay_window)
95735 +{
95736 + int err;
95737 + int _errno;
95738 +
95739 + err = FM_MACSEC_SECY_ConfigReplayWindow(fm_macsec_secy_dev,
95740 + replay_protect, replay_window);
95741 + _errno = -GET_ERROR_TYPE(err);
95742 + if (unlikely(_errno < 0))
95743 + pr_err("FM_MACSEC_SECY_ConfigReplayWindow() = 0x%08x\n", err);
95744 +
95745 + return _errno;
95746 +}
95747 +EXPORT_SYMBOL(fm_macsec_secy_config_replay_window);
95748 +
95749 +int fm_macsec_secy_config_validation_mode(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95750 + fm_macsec_valid_frame_behavior validate_frames)
95751 +{
95752 + int err;
95753 + int _errno;
95754 +
95755 + err = FM_MACSEC_SECY_ConfigValidationMode(fm_macsec_secy_dev,
95756 + validate_frames);
95757 + _errno = -GET_ERROR_TYPE(err);
95758 + if (unlikely(_errno < 0))
95759 + pr_err("FM_MACSEC_SECY_ConfigValidationMode() = 0x%08x\n", err);
95760 +
95761 + return _errno;
95762 +}
95763 +EXPORT_SYMBOL(fm_macsec_secy_config_validation_mode);
95764 +
95765 +int fm_macsec_secy_config_confidentiality(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95766 + bool confidentiality_enable,
95767 + uint32_t confidentiality_offset)
95768 +{
95769 + int err;
95770 + int _errno;
95771 +
95772 + err = FM_MACSEC_SECY_ConfigConfidentiality(fm_macsec_secy_dev,
95773 + confidentiality_enable,
95774 + confidentiality_offset);
95775 + _errno = -GET_ERROR_TYPE(err);
95776 + if (unlikely(_errno < 0))
95777 + pr_err("FM_MACSEC_SECY_ConfigConfidentiality() = 0x%08x\n",
95778 + err);
95779 +
95780 + return _errno;
95781 +}
95782 +EXPORT_SYMBOL(fm_macsec_secy_config_confidentiality);
95783 +
95784 +int fm_macsec_secy_config_point_to_point(struct fm_macsec_secy_dev *fm_macsec_secy_dev)
95785 +{
95786 + int err;
95787 + int _errno;
95788 +
95789 + err = FM_MACSEC_SECY_ConfigPointToPoint(fm_macsec_secy_dev);
95790 + _errno = -GET_ERROR_TYPE(err);
95791 + if (unlikely(_errno < 0))
95792 + pr_err("FM_MACSEC_SECY_ConfigPointToPoint() = 0x%08x\n",
95793 + err);
95794 +
95795 + return _errno;
95796 +}
95797 +EXPORT_SYMBOL(fm_macsec_secy_config_point_to_point);
95798 +
95799 +int fm_macsec_secy_config_exception(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95800 + fm_macsec_secy_exception exception,
95801 + bool enable)
95802 +{
95803 + int err;
95804 + int _errno;
95805 +
95806 + err = FM_MACSEC_SECY_ConfigException(fm_macsec_secy_dev, exception,
95807 + enable);
95808 + _errno = -GET_ERROR_TYPE(err);
95809 + if (unlikely(_errno < 0))
95810 + pr_err("FM_MACSEC_SECY_ConfigException() = 0x%08x\n",
95811 + err);
95812 +
95813 + return _errno;
95814 +}
95815 +EXPORT_SYMBOL(fm_macsec_secy_config_exception);
95816 +
95817 +int fm_macsec_secy_config_event(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95818 + fm_macsec_secy_event event,
95819 + bool enable)
95820 +{
95821 + int err;
95822 + int _errno;
95823 +
95824 + err = FM_MACSEC_SECY_ConfigEvent(fm_macsec_secy_dev, event, enable);
95825 + _errno = -GET_ERROR_TYPE(err);
95826 + if (unlikely(_errno < 0))
95827 + pr_err("FM_MACSEC_SECY_ConfigEvent() = 0x%08x\n",
95828 + err);
95829 +
95830 + return _errno;
95831 +}
95832 +EXPORT_SYMBOL(fm_macsec_secy_config_event);
95833 +
95834 +struct rx_sc_dev *fm_macsec_secy_create_rxsc(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95835 + struct fm_macsec_secy_sc_params *params)
95836 +{
95837 + struct rx_sc_dev *rx_sc_dev;
95838 +
95839 + rx_sc_dev = FM_MACSEC_SECY_CreateRxSc(fm_macsec_secy_dev, (t_FmMacsecSecYSCParams *)params);
95840 + if (unlikely(rx_sc_dev == NULL))
95841 + pr_err("FM_MACSEC_SECY_CreateRxSc() failed\n");
95842 +
95843 + return rx_sc_dev;
95844 +}
95845 +EXPORT_SYMBOL(fm_macsec_secy_create_rxsc);
95846 +
95847 +int fm_macsec_secy_delete_rxsc(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95848 + struct rx_sc_dev *sc)
95849 +{
95850 + int err;
95851 + int _errno;
95852 +
95853 + err = FM_MACSEC_SECY_DeleteRxSc(fm_macsec_secy_dev, sc);
95854 + _errno = -GET_ERROR_TYPE(err);
95855 + if (unlikely(_errno < 0))
95856 + pr_err("FM_MACSEC_SECY_DeleteRxSc() = 0x%08x\n",
95857 + err);
95858 +
95859 + return _errno;
95860 +}
95861 +EXPORT_SYMBOL(fm_macsec_secy_delete_rxsc);
95862 +
95863 +int fm_macsec_secy_create_rx_sa(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95864 + struct rx_sc_dev *sc, macsec_an_t an,
95865 + uint32_t lowest_pn, macsec_sa_key_t key)
95866 +{
95867 + int err;
95868 + int _errno;
95869 +
95870 + err = FM_MACSEC_SECY_CreateRxSa(fm_macsec_secy_dev, sc, an,
95871 + lowest_pn, key);
95872 + _errno = -GET_ERROR_TYPE(err);
95873 + if (unlikely(_errno < 0))
95874 + pr_err("FM_MACSEC_SECY_CreateRxSa() = 0x%08x\n",
95875 + err);
95876 +
95877 + return _errno;
95878 +}
95879 +EXPORT_SYMBOL(fm_macsec_secy_create_rx_sa);
95880 +
95881 +int fm_macsec_secy_delete_rx_sa(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95882 + struct rx_sc_dev *sc, macsec_an_t an)
95883 +{
95884 + int err;
95885 + int _errno;
95886 +
95887 + err = FM_MACSEC_SECY_DeleteRxSa(fm_macsec_secy_dev, sc, an);
95888 + _errno = -GET_ERROR_TYPE(err);
95889 + if (unlikely(_errno < 0))
95890 + pr_err("FM_MACSEC_SECY_DeleteRxSa() = 0x%08x\n",
95891 + err);
95892 +
95893 + return _errno;
95894 +}
95895 +EXPORT_SYMBOL(fm_macsec_secy_delete_rx_sa);
95896 +
95897 +int fm_macsec_secy_rxsa_enable_receive(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95898 + struct rx_sc_dev *sc,
95899 + macsec_an_t an)
95900 +{
95901 + int err;
95902 + int _errno;
95903 +
95904 + err = FM_MACSEC_SECY_RxSaEnableReceive(fm_macsec_secy_dev, sc, an);
95905 + _errno = -GET_ERROR_TYPE(err);
95906 + if (unlikely(_errno < 0))
95907 + pr_err("FM_MACSEC_SECY_RxSaEnableReceive() = 0x%08x\n",
95908 + err);
95909 +
95910 + return _errno;
95911 +}
95912 +EXPORT_SYMBOL(fm_macsec_secy_rxsa_enable_receive);
95913 +
95914 +int fm_macsec_secy_rxsa_disable_receive(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95915 + struct rx_sc_dev *sc,
95916 + macsec_an_t an)
95917 +{
95918 + int err;
95919 + int _errno;
95920 +
95921 + err = FM_MACSEC_SECY_RxSaDisableReceive(fm_macsec_secy_dev, sc, an);
95922 + _errno = -GET_ERROR_TYPE(err);
95923 + if (unlikely(_errno < 0))
95924 + pr_err("FM_MACSEC_SECY_RxSaDisableReceive() = 0x%08x\n",
95925 + err);
95926 +
95927 + return _errno;
95928 +}
95929 +EXPORT_SYMBOL(fm_macsec_secy_rxsa_disable_receive);
95930 +
95931 +int fm_macsec_secy_rxsa_update_next_pn(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95932 + struct rx_sc_dev *sc,
95933 + macsec_an_t an, uint32_t updt_next_pn)
95934 +{
95935 + int err;
95936 + int _errno;
95937 +
95938 + err = FM_MACSEC_SECY_RxSaUpdateNextPn(fm_macsec_secy_dev, sc, an,
95939 + updt_next_pn);
95940 + _errno = -GET_ERROR_TYPE(err);
95941 + if (unlikely(_errno < 0))
95942 + pr_err("FM_MACSEC_SECY_RxSaUpdateNextPn() = 0x%08x\n", err);
95943 +
95944 + return _errno;
95945 +}
95946 +EXPORT_SYMBOL(fm_macsec_secy_rxsa_update_next_pn);
95947 +
95948 +int fm_macsec_secy_rxsa_update_lowest_pn(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95949 + struct rx_sc_dev *sc,
95950 + macsec_an_t an, uint32_t updt_lowest_pn)
95951 +{
95952 + int err;
95953 + int _errno;
95954 +
95955 + err = FM_MACSEC_SECY_RxSaUpdateLowestPn(fm_macsec_secy_dev, sc, an,
95956 + updt_lowest_pn);
95957 + _errno = -GET_ERROR_TYPE(err);
95958 + if (unlikely(_errno < 0))
95959 + pr_err("FM_MACSEC_SECY_RxSaUpdateLowestPn() = 0x%08x\n",
95960 + err);
95961 +
95962 + return _errno;
95963 +}
95964 +EXPORT_SYMBOL(fm_macsec_secy_rxsa_update_lowest_pn);
95965 +
95966 +int fm_macsec_secy_rxsa_modify_key(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95967 + struct rx_sc_dev *sc,
95968 + macsec_an_t an, macsec_sa_key_t key)
95969 +{
95970 + int err;
95971 + int _errno;
95972 +
95973 + err = FM_MACSEC_SECY_RxSaModifyKey(fm_macsec_secy_dev, sc, an, key);
95974 + _errno = -GET_ERROR_TYPE(err);
95975 + if (unlikely(_errno < 0))
95976 + pr_err("FM_MACSEC_SECY_RxSaModifyKey() = 0x%08x\n",
95977 + err);
95978 +
95979 + return _errno;
95980 +}
95981 +EXPORT_SYMBOL(fm_macsec_secy_rxsa_modify_key);
95982 +
95983 +int fm_macsec_secy_create_tx_sa(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
95984 + macsec_an_t an, macsec_sa_key_t key)
95985 +{
95986 + int err;
95987 + int _errno;
95988 +
95989 + err = FM_MACSEC_SECY_CreateTxSa(fm_macsec_secy_dev, an, key);
95990 + _errno = -GET_ERROR_TYPE(err);
95991 + if (unlikely(_errno < 0))
95992 + pr_err("FM_MACSEC_SECY_CreateTxSa() = 0x%08x\n",
95993 + err);
95994 +
95995 + return _errno;
95996 +}
95997 +EXPORT_SYMBOL(fm_macsec_secy_create_tx_sa);
95998 +
95999 +int fm_macsec_secy_delete_tx_sa(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
96000 + macsec_an_t an)
96001 +{
96002 + int err;
96003 + int _errno;
96004 +
96005 + err = FM_MACSEC_SECY_DeleteTxSa(fm_macsec_secy_dev, an);
96006 + _errno = -GET_ERROR_TYPE(err);
96007 + if (unlikely(_errno < 0))
96008 + pr_err("FM_MACSEC_SECY_DeleteTxSa() = 0x%08x\n",
96009 + err);
96010 +
96011 + return _errno;
96012 +}
96013 +EXPORT_SYMBOL(fm_macsec_secy_delete_tx_sa);
96014 +
96015 +int fm_macsec_secy_txsa_modify_key(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
96016 + macsec_an_t next_active_an,
96017 + macsec_sa_key_t key)
96018 +{
96019 + int err;
96020 + int _errno;
96021 +
96022 + err = FM_MACSEC_SECY_TxSaModifyKey(fm_macsec_secy_dev, next_active_an,
96023 + key);
96024 + _errno = -GET_ERROR_TYPE(err);
96025 + if (unlikely(_errno < 0))
96026 + pr_err("FM_MACSEC_SECY_TxSaModifyKey() = 0x%08x\n",
96027 + err);
96028 +
96029 + return _errno;
96030 +}
96031 +EXPORT_SYMBOL(fm_macsec_secy_txsa_modify_key);
96032 +
96033 +int fm_macsec_secy_txsa_set_active(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
96034 + macsec_an_t an)
96035 +{
96036 + int err;
96037 + int _errno;
96038 +
96039 + err = FM_MACSEC_SECY_TxSaSetActive(fm_macsec_secy_dev, an);
96040 + _errno = -GET_ERROR_TYPE(err);
96041 + if (unlikely(_errno < 0))
96042 + pr_err("FM_MACSEC_SECY_TxSaSetActive() = 0x%08x\n",
96043 + err);
96044 +
96045 + return _errno;
96046 +}
96047 +EXPORT_SYMBOL(fm_macsec_secy_txsa_set_active);
96048 +
96049 +int fm_macsec_secy_txsa_get_active(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
96050 + macsec_an_t *p_an)
96051 +{
96052 + int err;
96053 + int _errno;
96054 +
96055 + err = FM_MACSEC_SECY_TxSaGetActive(fm_macsec_secy_dev, p_an);
96056 + _errno = -GET_ERROR_TYPE(err);
96057 + if (unlikely(_errno < 0))
96058 + pr_err("FM_MACSEC_SECY_TxSaGetActive() = 0x%08x\n",
96059 + err);
96060 +
96061 + return _errno;
96062 +}
96063 +EXPORT_SYMBOL(fm_macsec_secy_txsa_get_active);
96064 +
96065 +int fm_macsec_secy_get_rxsc_phys_id(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
96066 + struct rx_sc_dev *sc, uint32_t *sc_phys_id)
96067 +{
96068 + int err;
96069 + int _errno;
96070 +
96071 + err = FM_MACSEC_SECY_GetRxScPhysId(fm_macsec_secy_dev, sc, sc_phys_id);
96072 + _errno = -GET_ERROR_TYPE(err);
96073 + if (unlikely(_errno < 0))
96074 + pr_err("FM_MACSEC_SECY_GetRxScPhysId() = 0x%08x\n",
96075 + err);
96076 +
96077 + return _errno;
96078 +}
96079 +EXPORT_SYMBOL(fm_macsec_secy_get_rxsc_phys_id);
96080 +
96081 +int fm_macsec_secy_get_txsc_phys_id(struct fm_macsec_secy_dev *fm_macsec_secy_dev,
96082 + uint32_t *sc_phys_id)
96083 +{
96084 + int err;
96085 + int _errno;
96086 +
96087 + err = FM_MACSEC_SECY_GetTxScPhysId(fm_macsec_secy_dev, sc_phys_id);
96088 + _errno = -GET_ERROR_TYPE(err);
96089 + if (unlikely(_errno < 0))
96090 + pr_err("FM_MACSEC_SECY_GetTxScPhysId() = 0x%08x\n",
96091 + err);
96092 +
96093 + return _errno;
96094 +}
96095 +EXPORT_SYMBOL(fm_macsec_secy_get_txsc_phys_id);
96096 +
96097 +static t_Handle h_FmLnxWrp;
96098 +
96099 +static int __init __cold fm_load (void)
96100 +{
96101 + if ((h_FmLnxWrp = LNXWRP_FM_Init()) == NULL)
96102 + {
96103 + printk("Failed to init FM wrapper!\n");
96104 + return -ENODEV;
96105 + }
96106 +
96107 + printk(KERN_CRIT "Freescale FM module," \
96108 + " FMD API version %d.%d.%d\n",
96109 + FMD_API_VERSION_MAJOR,
96110 + FMD_API_VERSION_MINOR,
96111 + FMD_API_VERSION_RESPIN);
96112 + return 0;
96113 +}
96114 +
96115 +static void __exit __cold fm_unload (void)
96116 +{
96117 + if (h_FmLnxWrp)
96118 + LNXWRP_FM_Free(h_FmLnxWrp);
96119 +}
96120 +
96121 +module_init (fm_load);
96122 +module_exit (fm_unload);
96123 --- /dev/null
96124 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.h
96125 @@ -0,0 +1,294 @@
96126 +/*
96127 + * Copyright 2008-2012 Freescale Semiconductor Inc.
96128 + *
96129 + * Redistribution and use in source and binary forms, with or without
96130 + * modification, are permitted provided that the following conditions are met:
96131 + * * Redistributions of source code must retain the above copyright
96132 + * notice, this list of conditions and the following disclaimer.
96133 + * * Redistributions in binary form must reproduce the above copyright
96134 + * notice, this list of conditions and the following disclaimer in the
96135 + * documentation and/or other materials provided with the distribution.
96136 + * * Neither the name of Freescale Semiconductor nor the
96137 + * names of its contributors may be used to endorse or promote products
96138 + * derived from this software without specific prior written permission.
96139 + *
96140 + *
96141 + * ALTERNATIVELY, this software may be distributed under the terms of the
96142 + * GNU General Public License ("GPL") as published by the Free Software
96143 + * Foundation, either version 2 of that License or (at your option) any
96144 + * later version.
96145 + *
96146 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
96147 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96148 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
96149 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
96150 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
96151 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
96152 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
96153 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
96154 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
96155 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96156 + */
96157 +
96158 +/*
96159 + @File lnxwrp_fm.h
96160 +
96161 + @Author Shlomi Gridish
96162 +
96163 + @Description FM Linux wrapper functions.
96164 +
96165 +*/
96166 +
96167 +#ifndef __LNXWRP_FM_H__
96168 +#define __LNXWRP_FM_H__
96169 +
96170 +#include <linux/fsl_qman.h> /* struct qman_fq */
96171 +
96172 +#include "std_ext.h"
96173 +#include "error_ext.h"
96174 +#include "list_ext.h"
96175 +
96176 +#include "lnxwrp_fm_ext.h"
96177 +
96178 +#define FM_MAX_NUM_OF_ADV_SETTINGS 10
96179 +
96180 +#define LNXWRP_FM_NUM_OF_SHARED_PROFILES 16
96181 +
96182 +#if defined(CONFIG_FMAN_DISABLE_OH_TO_REUSE_RESOURCES)
96183 +#define FM_10G_OPENDMA_MIN_TRESHOLD 8 /* 10g minimum treshold if only HC is enabled and no OH port enabled */
96184 +#define FM_OPENDMA_RX_TX_RAPORT 2 /* RX = 2*TX */
96185 +#else
96186 +#define FM_10G_OPENDMA_MIN_TRESHOLD 7 /* 10g minimum treshold if 7 OH ports are enabled */
96187 +#define FM_OPENDMA_RX_TX_RAPORT 1 /* RX = TX */
96188 +#endif
96189 +#define FM_DEFAULT_TX10G_OPENDMA 8 /* default TX 10g open dmas */
96190 +#define FM_DEFAULT_RX10G_OPENDMA 8 /* default RX 10g open dmas */
96191 +
96192 +#define FRAG_MANIP_SPACE 128
96193 +#define FRAG_DATA_ALIGN 64
96194 +
96195 +#ifndef CONFIG_FSL_FM_MAX_FRAME_SIZE
96196 +#define CONFIG_FSL_FM_MAX_FRAME_SIZE 0
96197 +#endif
96198 +
96199 +#ifndef CONFIG_FSL_FM_RX_EXTRA_HEADROOM
96200 +#define CONFIG_FSL_FM_RX_EXTRA_HEADROOM 16
96201 +#endif
96202 +
96203 +typedef enum {
96204 + e_NO_PCD = 0,
96205 + e_FM_PCD_3_TUPLE
96206 +} e_LnxWrpFmPortPcdDefUseCase;
96207 +
96208 +
96209 +typedef struct t_FmTestFq {
96210 + struct qman_fq fq_base;
96211 + t_Handle h_Arg;
96212 +} t_FmTestFq;
96213 +
96214 +typedef struct {
96215 + uint8_t id; /* sw port id, see SW_PORT_ID_TO_HW_PORT_ID() in fm_common.h */
96216 + int minor;
96217 + char name[20];
96218 + bool active;
96219 + uint64_t phys_baseAddr;
96220 + uint64_t baseAddr; /* Port's *virtual* address */
96221 + uint32_t memSize;
96222 + t_WrpFmPortDevSettings settings;
96223 + t_FmExtPools opExtPools;
96224 + uint8_t totalNumOfSchemes;
96225 + uint8_t schemesBase;
96226 + uint8_t numOfSchemesUsed;
96227 + uint32_t pcdBaseQ;
96228 + uint16_t pcdNumOfQs;
96229 + struct fm_port_pcd_param pcd_owner_params;
96230 + e_LnxWrpFmPortPcdDefUseCase defPcd;
96231 + t_Handle h_DefNetEnv;
96232 + t_Handle h_Schemes[FM_PCD_KG_NUM_OF_SCHEMES];
96233 + t_FmBufferPrefixContent buffPrefixContent;
96234 + t_Handle h_Dev;
96235 + t_Handle h_DfltVsp;
96236 + t_Handle h_LnxWrpFmDev;
96237 + uint16_t txCh;
96238 + struct device *dev;
96239 + struct device_attribute *dev_attr_stats;
96240 + struct device_attribute *dev_attr_regs;
96241 + struct device_attribute *dev_attr_bmi_regs;
96242 + struct device_attribute *dev_attr_qmi_regs;
96243 +#if (DPAA_VERSION >= 11)
96244 + struct device_attribute *dev_attr_ipv4_opt;
96245 +#endif
96246 + struct device_attribute *dev_attr_dsar_regs;
96247 + struct device_attribute *dev_attr_dsar_mem;
96248 + struct auto_res_tables_sizes dsar_table_sizes;
96249 +} t_LnxWrpFmPortDev;
96250 +
96251 +typedef struct {
96252 + uint8_t id;
96253 + bool active;
96254 + uint64_t baseAddr;
96255 + uint32_t memSize;
96256 + t_WrpFmMacDevSettings settings;
96257 + t_Handle h_Dev;
96258 + t_Handle h_LnxWrpFmDev;
96259 +} t_LnxWrpFmMacDev;
96260 +
96261 +/* information about all active ports for an FMan.
96262 + * !Some ports may be disabled by u-boot, thus will not be available */
96263 +struct fm_active_ports {
96264 + uint32_t num_oh_ports;
96265 + uint32_t num_tx_ports;
96266 + uint32_t num_rx_ports;
96267 + uint32_t num_tx25_ports;
96268 + uint32_t num_rx25_ports;
96269 + uint32_t num_tx10_ports;
96270 + uint32_t num_rx10_ports;
96271 +};
96272 +
96273 +/* FMan resources precalculated at fm probe based
96274 + * on available FMan port. */
96275 +struct fm_resource_settings {
96276 + /* buffers - fifo sizes */
96277 + uint32_t tx1g_num_buffers;
96278 + uint32_t rx1g_num_buffers;
96279 + uint32_t tx2g5_num_buffers; /* Not supported yet by LLD */
96280 + uint32_t rx2g5_num_buffers; /* Not supported yet by LLD */
96281 + uint32_t tx10g_num_buffers;
96282 + uint32_t rx10g_num_buffers;
96283 + uint32_t oh_num_buffers;
96284 + uint32_t shared_ext_buffers;
96285 +
96286 + /* open DMAs */
96287 + uint32_t tx_1g_dmas;
96288 + uint32_t rx_1g_dmas;
96289 + uint32_t tx_2g5_dmas; /* Not supported yet by LLD */
96290 + uint32_t rx_2g5_dmas; /* Not supported yet by LLD */
96291 + uint32_t tx_10g_dmas;
96292 + uint32_t rx_10g_dmas;
96293 + uint32_t oh_dmas;
96294 + uint32_t shared_ext_open_dma;
96295 +
96296 + /* Tnums */
96297 + uint32_t tx_1g_tnums;
96298 + uint32_t rx_1g_tnums;
96299 + uint32_t tx_2g5_tnums; /* Not supported yet by LLD */
96300 + uint32_t rx_2g5_tnums; /* Not supported yet by LLD */
96301 + uint32_t tx_10g_tnums;
96302 + uint32_t rx_10g_tnums;
96303 + uint32_t oh_tnums;
96304 + uint32_t shared_ext_tnums;
96305 +};
96306 +
96307 +typedef struct {
96308 + uint8_t id;
96309 + char name[10];
96310 + bool active;
96311 + bool pcdActive;
96312 + bool prsActive;
96313 + bool kgActive;
96314 + bool ccActive;
96315 + bool plcrActive;
96316 + e_LnxWrpFmPortPcdDefUseCase defPcd;
96317 + uint32_t usedSchemes;
96318 + uint8_t totalNumOfSharedSchemes;
96319 + uint8_t sharedSchemesBase;
96320 + uint8_t numOfSchemesUsed;
96321 + uint8_t defNetEnvId;
96322 + uint64_t fmPhysBaseAddr;
96323 + uint64_t fmBaseAddr;
96324 + uint32_t fmMemSize;
96325 + uint64_t fmMuramPhysBaseAddr;
96326 + uint64_t fmMuramBaseAddr;
96327 + uint32_t fmMuramMemSize;
96328 + uint64_t fmRtcPhysBaseAddr;
96329 + uint64_t fmRtcBaseAddr;
96330 + uint32_t fmRtcMemSize;
96331 + uint64_t fmVspPhysBaseAddr;
96332 + uint64_t fmVspBaseAddr;
96333 + uint32_t fmVspMemSize;
96334 + int irq;
96335 + int err_irq;
96336 + t_WrpFmDevSettings fmDevSettings;
96337 + t_WrpFmPcdDevSettings fmPcdDevSettings;
96338 + t_Handle h_Dev;
96339 + uint16_t hcCh;
96340 +
96341 + t_Handle h_MuramDev;
96342 + t_Handle h_PcdDev;
96343 + t_Handle h_RtcDev;
96344 +
96345 + t_Handle h_DsarRxPort;
96346 + t_Handle h_DsarTxPort;
96347 +
96348 + t_LnxWrpFmPortDev hcPort;
96349 + t_LnxWrpFmPortDev opPorts[FM_MAX_NUM_OF_OH_PORTS-1];
96350 + t_LnxWrpFmPortDev rxPorts[FM_MAX_NUM_OF_RX_PORTS];
96351 + t_LnxWrpFmPortDev txPorts[FM_MAX_NUM_OF_TX_PORTS];
96352 + t_LnxWrpFmMacDev macs[FM_MAX_NUM_OF_MACS];
96353 + struct fm_active_ports fm_active_ports_info;
96354 + struct fm_resource_settings fm_resource_settings_info;
96355 +
96356 + struct device *dev;
96357 + struct resource *res;
96358 + int major;
96359 + struct class *fm_class;
96360 + struct device_attribute *dev_attr_stats;
96361 + struct device_attribute *dev_attr_regs;
96362 + struct device_attribute *dev_attr_risc_load;
96363 +
96364 + struct device_attribute *dev_pcd_attr_stats;
96365 + struct device_attribute *dev_plcr_attr_regs;
96366 + struct device_attribute *dev_prs_attr_regs;
96367 + struct device_attribute *dev_fm_fpm_attr_regs;
96368 + struct device_attribute *dev_fm_kg_attr_regs;
96369 + struct device_attribute *dev_fm_kg_pe_attr_regs;
96370 + struct device_attribute *dev_attr_muram_free_size;
96371 + struct device_attribute *dev_attr_fm_ctrl_code_ver;
96372 +
96373 +
96374 + struct qman_fq *hc_tx_conf_fq, *hc_tx_err_fq, *hc_tx_fq;
96375 +} t_LnxWrpFmDev;
96376 +
96377 +typedef struct {
96378 + t_LnxWrpFmDev *p_FmDevs[INTG_MAX_NUM_OF_FM];
96379 +} t_LnxWrpFm;
96380 +#define LNXWRP_FM_OBJECT(ptr) LIST_OBJECT(ptr, t_LnxWrpFm, fms[((t_LnxWrpFmDev *)ptr)->id])
96381 +
96382 +
96383 +t_Error LnxwrpFmIOCTL(t_LnxWrpFmDev *p_LnxWrpFmDev, unsigned int cmd, unsigned long arg, bool compat);
96384 +t_Error LnxwrpFmPortIOCTL(t_LnxWrpFmPortDev *p_LnxWrpFmPortDev, unsigned int cmd, unsigned long arg, bool compat);
96385 +
96386 +
96387 +#if 0
96388 +static __inline__ t_Error AllocSchemesForPort(t_LnxWrpFmDev *p_LnxWrpFmDev, uint8_t numSchemes, uint8_t *p_BaseSchemeNum)
96389 +{
96390 + uint32_t schemeMask;
96391 + uint8_t i;
96392 +
96393 + if (!numSchemes)
96394 + RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
96395 +
96396 + schemeMask = 0x80000000;
96397 + *p_BaseSchemeNum = 0xff;
96398 +
96399 + for (i=0; schemeMask && numSchemes; schemeMask>>=1, i++)
96400 + if ((p_LnxWrpFmDev->usedSchemes & schemeMask) == 0)
96401 + {
96402 + p_LnxWrpFmDev->usedSchemes |= schemeMask;
96403 + numSchemes--;
96404 + if (*p_BaseSchemeNum==0xff)
96405 + *p_BaseSchemeNum = i;
96406 + }
96407 + else if (*p_BaseSchemeNum!=0xff)
96408 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("Fragmentation on schemes array!!!"));
96409 +
96410 + if (numSchemes)
96411 + RETURN_ERROR(MINOR, E_FULL, ("schemes!!!"));
96412 + return E_OK;
96413 +}
96414 +#endif
96415 +
96416 +void LnxWrpPCDIOCTLTypeChecking(void);
96417 +void LnxWrpPCDIOCTLEnumChecking(void);
96418 +
96419 +#endif /* __LNXWRP_FM_H__ */
96420 --- /dev/null
96421 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm_port.c
96422 @@ -0,0 +1,1507 @@
96423 +/*
96424 + * Copyright 2008-2012 Freescale Semiconductor Inc.
96425 + *
96426 + * Redistribution and use in source and binary forms, with or without
96427 + * modification, are permitted provided that the following conditions are met:
96428 + * * Redistributions of source code must retain the above copyright
96429 + * notice, this list of conditions and the following disclaimer.
96430 + * * Redistributions in binary form must reproduce the above copyright
96431 + * notice, this list of conditions and the following disclaimer in the
96432 + * documentation and/or other materials provided with the distribution.
96433 + * * Neither the name of Freescale Semiconductor nor the
96434 + * names of its contributors may be used to endorse or promote products
96435 + * derived from this software without specific prior written permission.
96436 + *
96437 + *
96438 + * ALTERNATIVELY, this software may be distributed under the terms of the
96439 + * GNU General Public License ("GPL") as published by the Free Software
96440 + * Foundation, either version 2 of that License or (at your option) any
96441 + * later version.
96442 + *
96443 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
96444 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
96445 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
96446 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
96447 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
96448 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
96449 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
96450 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
96451 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
96452 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96453 + */
96454 +
96455 +/*
96456 + @File lnxwrp_fm_port.c
96457 +
96458 + @Description FMD wrapper - FMan port functions.
96459 +
96460 +*/
96461 +
96462 +#include <linux/version.h>
96463 +#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
96464 +#define MODVERSIONS
96465 +#endif
96466 +#ifdef MODVERSIONS
96467 +#include <config/modversions.h>
96468 +#endif /* MODVERSIONS */
96469 +#include <linux/kernel.h>
96470 +#include <linux/module.h>
96471 +#include <linux/of_platform.h>
96472 +#include <linux/of_address.h>
96473 +#include <linux/cdev.h>
96474 +#include <linux/slab.h>
96475 +#include <linux/spinlock.h>
96476 +#ifndef CONFIG_FMAN_ARM
96477 +#include <linux/fsl/svr.h>
96478 +#endif
96479 +#include <linux/io.h>
96480 +
96481 +#include "sprint_ext.h"
96482 +#include "fm_common.h"
96483 +#include "lnxwrp_fsl_fman.h"
96484 +#include "fm_port_ext.h"
96485 +#if (DPAA_VERSION >= 11)
96486 +#include "fm_vsp_ext.h"
96487 +#endif /* DPAA_VERSION >= 11 */
96488 +#include "fm_ioctls.h"
96489 +#include "lnxwrp_resources.h"
96490 +#include "lnxwrp_sysfs_fm_port.h"
96491 +
96492 +#define __ERR_MODULE__ MODULE_FM
96493 +
96494 +extern struct device_node *GetFmAdvArgsDevTreeNode (uint8_t fmIndx);
96495 +
96496 +/* TODO: duplicated, see lnxwrp_fm.c */
96497 +#define ADD_ADV_CONFIG_NO_RET(_func, _param)\
96498 +do {\
96499 + if (i < max) {\
96500 + p_Entry = &p_Entrys[i];\
96501 + p_Entry->p_Function = _func;\
96502 + _param\
96503 + i++;\
96504 + } else {\
96505 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,\
96506 + ("Number of advanced-configuration entries exceeded"));\
96507 + } \
96508 +} while (0)
96509 +
96510 +#ifndef CONFIG_FMAN_ARM
96511 +#define IS_T1023_T1024 (SVR_SOC_VER(mfspr(SPRN_SVR)) == SVR_T1024 || \
96512 + SVR_SOC_VER(mfspr(SPRN_SVR)) == SVR_T1023)
96513 +#endif
96514 +
96515 +static volatile int hcFrmRcv/* = 0 */;
96516 +static spinlock_t lock;
96517 +
96518 +static enum qman_cb_dqrr_result qm_tx_conf_dqrr_cb(struct qman_portal *portal,
96519 + struct qman_fq *fq,
96520 + const struct qm_dqrr_entry
96521 + *dq)
96522 +{
96523 + t_LnxWrpFmDev *p_LnxWrpFmDev = ((t_FmTestFq *) fq)->h_Arg;
96524 + unsigned long flags;
96525 +
96526 +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
96527 +{
96528 + /* extract the HC frame address */
96529 +#ifdef CONFIG_ARM
96530 + uint32_t *hcf_va = XX_PhysToVirt(((struct qm_fd *)&dq->fd)->addr);
96531 +#else
96532 + uint64_t hcf_va = (uint64_t)XX_PhysToVirt(((struct qm_fd *)&dq->fd)->addr);
96533 +#endif
96534 + int hcf_l = ((struct qm_fd *)&dq->fd)->length20;
96535 + int i;
96536 +
96537 + /* 32b byteswap of all data in the HC Frame */
96538 + for(i = 0; i < hcf_l / 4; ++i)
96539 + ((uint32_t *)(hcf_va))[i] =
96540 + ___constant_swab32(((uint32_t *)(hcf_va))[i]);
96541 +}
96542 +{
96543 + /* byteswap FD's 40bit address field LE to BE*/
96544 + uint8_t t;
96545 +
96546 + t = ((uint8_t*)&dq->fd)[6];
96547 + ((uint8_t*)&dq->fd)[6] = ((uint8_t*)&dq->fd)[5];
96548 + ((uint8_t*)&dq->fd)[5] = ((uint8_t*)&dq->fd)[4];
96549 + ((uint8_t*)&dq->fd)[4] = ((uint8_t*)&dq->fd)[3];
96550 + ((uint8_t*)&dq->fd)[3] = ((uint8_t*)&dq->fd)[7];
96551 + ((uint8_t*)&dq->fd)[7] = t;
96552 +}
96553 +
96554 +#endif
96555 + FM_PCD_HcTxConf(p_LnxWrpFmDev->h_PcdDev, (t_DpaaFD *)&dq->fd);
96556 + spin_lock_irqsave(&lock, flags);
96557 + hcFrmRcv--;
96558 + spin_unlock_irqrestore(&lock, flags);
96559 +
96560 + return qman_cb_dqrr_consume;
96561 +}
96562 +
96563 +static enum qman_cb_dqrr_result qm_tx_dqrr_cb(struct qman_portal *portal,
96564 + struct qman_fq *fq,
96565 + const struct qm_dqrr_entry *dq)
96566 +{
96567 + WARN(1, "FMD: failure at %s:%d/%s()!\n", __FILE__, __LINE__,
96568 + __func__);
96569 + return qman_cb_dqrr_consume;
96570 +}
96571 +
96572 +static void qm_err_cb(struct qman_portal *portal,
96573 + struct qman_fq *fq, const struct qm_mr_entry *msg)
96574 +{
96575 + WARN(1, "FMD: failure at %s:%d/%s()!\n", __FILE__, __LINE__,
96576 + __func__);
96577 +}
96578 +
96579 +static struct qman_fq *FqAlloc(t_LnxWrpFmDev * p_LnxWrpFmDev,
96580 + uint32_t fqid,
96581 + uint32_t flags, uint16_t channel, uint8_t wq)
96582 +{
96583 + int _errno;
96584 + struct qman_fq *fq = NULL;
96585 + t_FmTestFq *p_FmtFq;
96586 + struct qm_mcc_initfq initfq;
96587 +
96588 + p_FmtFq = (t_FmTestFq *) XX_Malloc(sizeof(t_FmTestFq));
96589 + if (!p_FmtFq) {
96590 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FQ obj!!!"));
96591 + return NULL;
96592 + }
96593 +
96594 + p_FmtFq->fq_base.cb.dqrr = ((flags & QMAN_FQ_FLAG_NO_ENQUEUE)
96595 + ? qm_tx_conf_dqrr_cb
96596 + : qm_tx_dqrr_cb);
96597 + p_FmtFq->fq_base.cb.ern = qm_err_cb;
96598 + /* p_FmtFq->fq_base.cb.fqs = qm_err_cb; */
96599 + /* qm_err_cb wrongly called when the FQ is parked */
96600 + p_FmtFq->fq_base.cb.fqs = NULL;
96601 + p_FmtFq->h_Arg = (t_Handle) p_LnxWrpFmDev;
96602 + if (fqid == 0) {
96603 + flags |= QMAN_FQ_FLAG_DYNAMIC_FQID;
96604 + flags &= ~QMAN_FQ_FLAG_NO_MODIFY;
96605 + } else {
96606 + flags &= ~QMAN_FQ_FLAG_DYNAMIC_FQID;
96607 + }
96608 +
96609 + if (qman_create_fq(fqid, flags, &p_FmtFq->fq_base)) {
96610 + REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FQ obj - qman_new_fq!!!"));
96611 + XX_Free(p_FmtFq);
96612 + return NULL;
96613 + }
96614 + fq = &p_FmtFq->fq_base;
96615 +
96616 + if (!(flags & QMAN_FQ_FLAG_NO_MODIFY)) {
96617 + initfq.we_mask = QM_INITFQ_WE_DESTWQ;
96618 + initfq.fqd.dest.channel = channel;
96619 + initfq.fqd.dest.wq = wq;
96620 +
96621 + _errno = qman_init_fq(fq, QMAN_INITFQ_FLAG_SCHED, &initfq);
96622 + if (unlikely(_errno < 0)) {
96623 + REPORT_ERROR(MAJOR, E_NO_MEMORY,
96624 + ("FQ obj - qman_init_fq!!!"));
96625 + qman_destroy_fq(fq, 0);
96626 + XX_Free(p_FmtFq);
96627 + return NULL;
96628 + }
96629 + }
96630 +
96631 + DBG(TRACE,
96632 + ("fqid %d, flags 0x%08x, channel %d, wq %d", qman_fq_fqid(fq),
96633 + flags, channel, wq));
96634 +
96635 + return fq;
96636 +}
96637 +
96638 +static void FqFree(struct qman_fq *fq)
96639 +{
96640 + int _errno;
96641 +
96642 + _errno = qman_retire_fq(fq, NULL);
96643 + if (unlikely(_errno < 0))
96644 + printk(KERN_WARNING "qman_retire_fq(%u) = %d\n", qman_fq_fqid(fq), _errno);
96645 +
96646 + _errno = qman_oos_fq(fq);
96647 + if (unlikely(_errno < 0))
96648 + printk(KERN_WARNING "qman_oos_fq(%u) = %d\n", qman_fq_fqid(fq), _errno);
96649 +
96650 + qman_destroy_fq(fq, 0);
96651 + XX_Free((t_FmTestFq *) fq);
96652 +}
96653 +
96654 +static t_Error QmEnqueueCB(t_Handle h_Arg, void *p_Fd)
96655 +{
96656 + t_LnxWrpFmDev *p_LnxWrpFmDev = (t_LnxWrpFmDev *) h_Arg;
96657 + int _errno, timeout = 1000000;
96658 + unsigned long flags;
96659 +
96660 + ASSERT_COND(p_LnxWrpFmDev);
96661 +
96662 + spin_lock_irqsave(&lock, flags);
96663 + hcFrmRcv++;
96664 + spin_unlock_irqrestore(&lock, flags);
96665 +
96666 +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
96667 +{
96668 + /* byteswap FD's 40bit address field */
96669 + uint8_t t;
96670 +
96671 + t = ((uint8_t*)p_Fd)[7];
96672 + ((uint8_t*)p_Fd)[7] = ((uint8_t*)p_Fd)[3];
96673 + ((uint8_t*)p_Fd)[3] = ((uint8_t*)p_Fd)[4];
96674 + ((uint8_t*)p_Fd)[4] = ((uint8_t*)p_Fd)[5];
96675 + ((uint8_t*)p_Fd)[5] = ((uint8_t*)p_Fd)[6];
96676 + ((uint8_t*)p_Fd)[6] = t;
96677 +}
96678 +{
96679 + /* extract the HC frame address */
96680 +#ifdef CONFIG_ARM
96681 + uint32_t *hcf_va = XX_PhysToVirt(((struct qm_fd *) p_Fd)->addr);
96682 +#else
96683 + uint64_t hcf_va = (uint64_t)XX_PhysToVirt(((struct qm_fd *) p_Fd)->addr);
96684 +#endif
96685 + int hcf_l = ((struct qm_fd *)p_Fd)->length20;
96686 + int i;
96687 +
96688 + /* 32b byteswap of all data in the HC Frame */
96689 + for(i = 0; i < hcf_l / 4; ++i)
96690 + ((uint32_t *)(hcf_va))[i] =
96691 + ___constant_swab32(((uint32_t *)(hcf_va))[i]);
96692 +}
96693 +#endif
96694 +
96695 + _errno = qman_enqueue(p_LnxWrpFmDev->hc_tx_fq, (struct qm_fd *) p_Fd,
96696 + 0);
96697 + if (_errno)
96698 + RETURN_ERROR(MINOR, E_INVALID_STATE,
96699 + ("qman_enqueue() failed"));
96700 +
96701 + while (hcFrmRcv && --timeout) {
96702 + udelay(1);
96703 + cpu_relax();
96704 + }
96705 + if (timeout == 0) {
96706 + dump_stack();
96707 + RETURN_ERROR(MINOR, E_WRITE_FAILED,
96708 + ("timeout waiting for Tx confirmation"));
96709 + return E_WRITE_FAILED;
96710 + }
96711 +
96712 + return E_OK;
96713 +}
96714 +
96715 +static t_LnxWrpFmPortDev *ReadFmPortDevTreeNode(struct platform_device
96716 + *of_dev)
96717 +{
96718 + t_LnxWrpFmDev *p_LnxWrpFmDev;
96719 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev;
96720 + struct device_node *fm_node, *port_node;
96721 + struct resource res;
96722 + const uint32_t *uint32_prop;
96723 + int _errno = 0, lenp;
96724 + uint32_t tmp_prop;
96725 +
96726 +#ifdef CONFIG_FMAN_P1023
96727 + static unsigned char have_oh_port/* = 0 */;
96728 +#endif
96729 +
96730 + port_node = of_node_get(of_dev->dev.of_node);
96731 +
96732 + /* Get the FM node */
96733 + fm_node = of_get_parent(port_node);
96734 + if (unlikely(fm_node == NULL)) {
96735 + REPORT_ERROR(MAJOR, E_NO_DEVICE,
96736 + ("of_get_parent() = %d", _errno));
96737 + return NULL;
96738 + }
96739 +
96740 + p_LnxWrpFmDev =
96741 + dev_get_drvdata(&of_find_device_by_node(fm_node)->dev);
96742 + of_node_put(fm_node);
96743 +
96744 + /* if fm_probe() failed, no point in going further with port probing */
96745 + if (p_LnxWrpFmDev == NULL)
96746 + return NULL;
96747 +
96748 + uint32_prop =
96749 + (uint32_t *) of_get_property(port_node, "cell-index", &lenp);
96750 + if (unlikely(uint32_prop == NULL)) {
96751 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
96752 + ("of_get_property(%s, cell-index) failed",
96753 + port_node->full_name));
96754 + return NULL;
96755 + }
96756 + tmp_prop = be32_to_cpu(*uint32_prop);
96757 + if (WARN_ON(lenp != sizeof(uint32_t)))
96758 + return NULL;
96759 + if (of_device_is_compatible(port_node, "fsl,fman-port-oh")) {
96760 + if (unlikely(tmp_prop >= FM_MAX_NUM_OF_OH_PORTS)) {
96761 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
96762 + ("of_get_property(%s, cell-index) failed",
96763 + port_node->full_name));
96764 + return NULL;
96765 + }
96766 +
96767 +#ifdef CONFIG_FMAN_P1023
96768 + /* Beware, this can be done when there is only
96769 + one FMan to be initialized */
96770 + if (!have_oh_port) {
96771 + have_oh_port = 1; /* first OP/HC port
96772 + is used for host command */
96773 +#else
96774 + /* Here it is hardcoded the use of the OH port 1
96775 + (with cell-index 0) */
96776 + if (tmp_prop == 0) {
96777 +#endif
96778 + p_LnxWrpFmPortDev = &p_LnxWrpFmDev->hcPort;
96779 + p_LnxWrpFmPortDev->id = 0;
96780 + /*
96781 + p_LnxWrpFmPortDev->id = *uint32_prop-1;
96782 + p_LnxWrpFmPortDev->id = *uint32_prop;
96783 + */
96784 + p_LnxWrpFmPortDev->settings.param.portType =
96785 + e_FM_PORT_TYPE_OH_HOST_COMMAND;
96786 + } else {
96787 + p_LnxWrpFmPortDev =
96788 + &p_LnxWrpFmDev->opPorts[tmp_prop - 1];
96789 + p_LnxWrpFmPortDev->id = tmp_prop- 1;
96790 + p_LnxWrpFmPortDev->settings.param.portType =
96791 + e_FM_PORT_TYPE_OH_OFFLINE_PARSING;
96792 + }
96793 + p_LnxWrpFmPortDev->settings.param.portId = tmp_prop;
96794 +
96795 + uint32_prop =
96796 + (uint32_t *) of_get_property(port_node,
96797 + "fsl,qman-channel-id",
96798 + &lenp);
96799 + if (uint32_prop == NULL) {
96800 + /*
96801 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("missing fsl,qman-channel-id"));
96802 + */
96803 + XX_Print("FM warning: missing fsl,qman-channel-id"
96804 + " for OH port.\n");
96805 + return NULL;
96806 + }
96807 + tmp_prop = be32_to_cpu(*uint32_prop);
96808 + if (WARN_ON(lenp != sizeof(uint32_t)))
96809 + return NULL;
96810 + p_LnxWrpFmPortDev->txCh = tmp_prop;
96811 +
96812 + p_LnxWrpFmPortDev->settings.param.specificParams.nonRxParams.
96813 + qmChannel = p_LnxWrpFmPortDev->txCh;
96814 + } else if (of_device_is_compatible(port_node, "fsl,fman-port-1g-tx")) {
96815 + if (unlikely(tmp_prop >= FM_MAX_NUM_OF_1G_TX_PORTS)) {
96816 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
96817 + ("of_get_property(%s, cell-index) failed",
96818 + port_node->full_name));
96819 + return NULL;
96820 + }
96821 + p_LnxWrpFmPortDev = &p_LnxWrpFmDev->txPorts[tmp_prop];
96822 +
96823 + p_LnxWrpFmPortDev->id = tmp_prop;
96824 + p_LnxWrpFmPortDev->settings.param.portId =
96825 + p_LnxWrpFmPortDev->id;
96826 + p_LnxWrpFmPortDev->settings.param.portType = e_FM_PORT_TYPE_TX;
96827 +
96828 + uint32_prop = (uint32_t *) of_get_property(port_node,
96829 + "fsl,qman-channel-id", &lenp);
96830 + if (uint32_prop == NULL) {
96831 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
96832 + ("missing fsl,qman-channel-id"));
96833 + return NULL;
96834 + }
96835 + tmp_prop = be32_to_cpu(*uint32_prop);
96836 + if (WARN_ON(lenp != sizeof(uint32_t)))
96837 + return NULL;
96838 + p_LnxWrpFmPortDev->txCh = tmp_prop;
96839 + p_LnxWrpFmPortDev->
96840 + settings.param.specificParams.nonRxParams.qmChannel =
96841 + p_LnxWrpFmPortDev->txCh;
96842 + } else if (of_device_is_compatible(port_node, "fsl,fman-port-10g-tx")) {
96843 + if (unlikely(tmp_prop>= FM_MAX_NUM_OF_10G_TX_PORTS)) {
96844 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
96845 + ("of_get_property(%s, cell-index) failed",
96846 + port_node->full_name));
96847 + return NULL;
96848 + }
96849 + p_LnxWrpFmPortDev = &p_LnxWrpFmDev->txPorts[tmp_prop +
96850 + FM_MAX_NUM_OF_1G_TX_PORTS];
96851 +#ifndef CONFIG_FMAN_ARM
96852 + if (IS_T1023_T1024)
96853 + p_LnxWrpFmPortDev = &p_LnxWrpFmDev->txPorts[*uint32_prop];
96854 +#endif
96855 +
96856 + p_LnxWrpFmPortDev->id = tmp_prop;
96857 + p_LnxWrpFmPortDev->settings.param.portId =
96858 + p_LnxWrpFmPortDev->id;
96859 + p_LnxWrpFmPortDev->settings.param.portType =
96860 + e_FM_PORT_TYPE_TX_10G;
96861 + uint32_prop = (uint32_t *) of_get_property(port_node,
96862 + "fsl,qman-channel-id", &lenp);
96863 + if (uint32_prop == NULL) {
96864 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
96865 + ("missing fsl,qman-channel-id"));
96866 + return NULL;
96867 + }
96868 + tmp_prop = be32_to_cpu(*uint32_prop);
96869 + if (WARN_ON(lenp != sizeof(uint32_t)))
96870 + return NULL;
96871 + p_LnxWrpFmPortDev->txCh = tmp_prop;
96872 + p_LnxWrpFmPortDev->settings.param.specificParams.nonRxParams.
96873 + qmChannel = p_LnxWrpFmPortDev->txCh;
96874 + } else if (of_device_is_compatible(port_node, "fsl,fman-port-1g-rx")) {
96875 + if (unlikely(tmp_prop >= FM_MAX_NUM_OF_1G_RX_PORTS)) {
96876 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
96877 + ("of_get_property(%s, cell-index) failed",
96878 + port_node->full_name));
96879 + return NULL;
96880 + }
96881 + p_LnxWrpFmPortDev = &p_LnxWrpFmDev->rxPorts[tmp_prop];
96882 +
96883 + p_LnxWrpFmPortDev->id = tmp_prop;
96884 + p_LnxWrpFmPortDev->settings.param.portId =
96885 + p_LnxWrpFmPortDev->id;
96886 + p_LnxWrpFmPortDev->settings.param.portType = e_FM_PORT_TYPE_RX;
96887 + if (p_LnxWrpFmDev->pcdActive)
96888 + p_LnxWrpFmPortDev->defPcd = p_LnxWrpFmDev->defPcd;
96889 + } else if (of_device_is_compatible(port_node, "fsl,fman-port-10g-rx")) {
96890 + if (unlikely(tmp_prop >= FM_MAX_NUM_OF_10G_RX_PORTS)) {
96891 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
96892 + ("of_get_property(%s, cell-index) failed",
96893 + port_node->full_name));
96894 + return NULL;
96895 + }
96896 + p_LnxWrpFmPortDev = &p_LnxWrpFmDev->rxPorts[tmp_prop +
96897 + FM_MAX_NUM_OF_1G_RX_PORTS];
96898 +
96899 +#ifndef CONFIG_FMAN_ARM
96900 + if (IS_T1023_T1024)
96901 + p_LnxWrpFmPortDev = &p_LnxWrpFmDev->rxPorts[*uint32_prop];
96902 +#endif
96903 +
96904 + p_LnxWrpFmPortDev->id = tmp_prop;
96905 + p_LnxWrpFmPortDev->settings.param.portId =
96906 + p_LnxWrpFmPortDev->id;
96907 + p_LnxWrpFmPortDev->settings.param.portType =
96908 + e_FM_PORT_TYPE_RX_10G;
96909 + if (p_LnxWrpFmDev->pcdActive)
96910 + p_LnxWrpFmPortDev->defPcd = p_LnxWrpFmDev->defPcd;
96911 + } else {
96912 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal port type"));
96913 + return NULL;
96914 + }
96915 +
96916 + _errno = of_address_to_resource(port_node, 0, &res);
96917 + if (unlikely(_errno < 0)) {
96918 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
96919 + ("of_address_to_resource() = %d", _errno));
96920 + return NULL;
96921 + }
96922 +
96923 + p_LnxWrpFmPortDev->dev = &of_dev->dev;
96924 + p_LnxWrpFmPortDev->baseAddr = 0;
96925 + p_LnxWrpFmPortDev->phys_baseAddr = res.start;
96926 + p_LnxWrpFmPortDev->memSize = res.end + 1 - res.start;
96927 + p_LnxWrpFmPortDev->settings.param.h_Fm = p_LnxWrpFmDev->h_Dev;
96928 + p_LnxWrpFmPortDev->h_LnxWrpFmDev = (t_Handle) p_LnxWrpFmDev;
96929 +
96930 + of_node_put(port_node);
96931 +
96932 + p_LnxWrpFmPortDev->active = TRUE;
96933 +
96934 +#if defined(CONFIG_FMAN_DISABLE_OH_TO_REUSE_RESOURCES)
96935 + /* for performance mode no OH port available. */
96936 + if (p_LnxWrpFmPortDev->settings.param.portType ==
96937 + e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
96938 + p_LnxWrpFmPortDev->active = FALSE;
96939 +#endif
96940 +
96941 + return p_LnxWrpFmPortDev;
96942 +}
96943 +
96944 +struct device_node * GetFmPortAdvArgsDevTreeNode (struct device_node *fm_node,
96945 + e_FmPortType portType,
96946 + uint8_t portId)
96947 +{
96948 + struct device_node *port_node;
96949 + const uint32_t *uint32_prop;
96950 + int lenp;
96951 + char *portTypeString;
96952 + uint32_t tmp_prop;
96953 +
96954 + switch(portType) {
96955 + case e_FM_PORT_TYPE_OH_OFFLINE_PARSING:
96956 + portTypeString = "fsl,fman-port-op-extended-args";
96957 + break;
96958 + case e_FM_PORT_TYPE_TX:
96959 + portTypeString = "fsl,fman-port-1g-tx-extended-args";
96960 + break;
96961 + case e_FM_PORT_TYPE_TX_10G:
96962 + portTypeString = "fsl,fman-port-10g-tx-extended-args";
96963 + break;
96964 + case e_FM_PORT_TYPE_RX:
96965 + portTypeString = "fsl,fman-port-1g-rx-extended-args";
96966 + break;
96967 + case e_FM_PORT_TYPE_RX_10G:
96968 + portTypeString = "fsl,fman-port-10g-rx-extended-args";
96969 + break;
96970 + default:
96971 + return NULL;
96972 + }
96973 +
96974 + for_each_child_of_node(fm_node, port_node) {
96975 + uint32_prop = (uint32_t *)of_get_property(port_node, "cell-index", &lenp);
96976 + if (unlikely(uint32_prop == NULL)) {
96977 + REPORT_ERROR(MAJOR, E_INVALID_VALUE,
96978 + ("of_get_property(%s, cell-index) failed",
96979 + port_node->full_name));
96980 + return NULL;
96981 + }
96982 + tmp_prop = be32_to_cpu(*uint32_prop);
96983 + if (WARN_ON(lenp != sizeof(uint32_t)))
96984 + return NULL;
96985 + if ((portId == tmp_prop) &&
96986 + (of_device_is_compatible(port_node, portTypeString))) {
96987 + return port_node;
96988 + }
96989 + }
96990 +
96991 + return NULL;
96992 +}
96993 +
96994 +static t_Error CheckNConfigFmPortAdvArgs (t_LnxWrpFmPortDev *p_LnxWrpFmPortDev)
96995 +{
96996 + struct device_node *fm_node, *port_node;
96997 + t_Error err;
96998 + t_FmPortRsrc portRsrc;
96999 + const uint32_t *uint32_prop;
97000 + /*const char *str_prop;*/
97001 + int lenp;
97002 +#ifdef CONFIG_FMAN_PFC
97003 + uint8_t i, id, num_pools;
97004 + t_FmBufPoolDepletion poolDepletion;
97005 +
97006 + if (p_LnxWrpFmPortDev->settings.param.portType == e_FM_PORT_TYPE_RX ||
97007 + p_LnxWrpFmPortDev->settings.param.portType == e_FM_PORT_TYPE_RX_10G) {
97008 + memset(&poolDepletion, 0, sizeof(t_FmBufPoolDepletion));
97009 + poolDepletion.singlePoolModeEnable = true;
97010 + num_pools = p_LnxWrpFmPortDev->settings.param.specificParams.rxParams.
97011 + extBufPools.numOfPoolsUsed;
97012 + for (i = 0; i < num_pools; i++) {
97013 + id = p_LnxWrpFmPortDev->settings.param.specificParams.rxParams.
97014 + extBufPools.extBufPool[i].id;
97015 + poolDepletion.poolsToConsiderForSingleMode[id] = true;
97016 + }
97017 +
97018 + for (i = 0; i < CONFIG_FMAN_PFC_COS_COUNT; i++)
97019 + poolDepletion.pfcPrioritiesEn[i] = true;
97020 +
97021 + err = FM_PORT_ConfigPoolDepletion(p_LnxWrpFmPortDev->h_Dev,
97022 + &poolDepletion);
97023 + if (err != E_OK)
97024 + RETURN_ERROR(MAJOR, err, ("FM_PORT_ConfigPoolDepletion() failed"));
97025 + }
97026 +#endif
97027 +
97028 + fm_node = GetFmAdvArgsDevTreeNode(((t_LnxWrpFmDev *) p_LnxWrpFmPortDev->h_LnxWrpFmDev)->id);
97029 + if (!fm_node) /* no advance parameters for FMan */
97030 + return E_OK;
97031 +
97032 + port_node = GetFmPortAdvArgsDevTreeNode(fm_node,
97033 + p_LnxWrpFmPortDev->settings.param.portType,
97034 + p_LnxWrpFmPortDev->settings.param.portId);
97035 + if (!port_node) /* no advance parameters for FMan-Port */
97036 + return E_OK;
97037 +
97038 + uint32_prop = (uint32_t *)of_get_property(port_node, "num-tnums", &lenp);
97039 + if (uint32_prop) {
97040 + if (WARN_ON(lenp != sizeof(uint32_t)*2))
97041 + RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
97042 +
97043 + portRsrc.num = be32_to_cpu(uint32_prop[0]);
97044 + portRsrc.extra = be32_to_cpu(uint32_prop[1]);
97045 +
97046 + if ((err = FM_PORT_ConfigNumOfTasks(p_LnxWrpFmPortDev->h_Dev,
97047 + &portRsrc)) != E_OK)
97048 + RETURN_ERROR(MINOR, err, NO_MSG);
97049 + }
97050 +
97051 + uint32_prop = (uint32_t *)of_get_property(port_node, "num-dmas", &lenp);
97052 + if (uint32_prop) {
97053 + if (WARN_ON(lenp != sizeof(uint32_t)*2))
97054 + RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
97055 +
97056 + portRsrc.num = be32_to_cpu(uint32_prop[0]);
97057 + portRsrc.extra = be32_to_cpu(uint32_prop[1]);
97058 +
97059 + if ((err = FM_PORT_ConfigNumOfOpenDmas(p_LnxWrpFmPortDev->h_Dev,
97060 + &portRsrc)) != E_OK)
97061 + RETURN_ERROR(MINOR, err, NO_MSG);
97062 + }
97063 +
97064 + uint32_prop = (uint32_t *)of_get_property(port_node, "fifo-size", &lenp);
97065 + if (uint32_prop) {
97066 + if (WARN_ON(lenp != sizeof(uint32_t)*2))
97067 + RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
97068 +
97069 + portRsrc.num = be32_to_cpu(uint32_prop[0]);
97070 + portRsrc.extra = be32_to_cpu(uint32_prop[1]);
97071 +
97072 + if ((err = FM_PORT_ConfigSizeOfFifo(p_LnxWrpFmPortDev->h_Dev,
97073 + &portRsrc)) != E_OK)
97074 + RETURN_ERROR(MINOR, err, NO_MSG);
97075 + }
97076 +
97077 + uint32_prop = (uint32_t *)of_get_property(port_node, "errors-to-discard", &lenp);
97078 + if (uint32_prop) {
97079 + if (WARN_ON(lenp != sizeof(uint32_t)))
97080 + RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
97081 + if ((err = FM_PORT_ConfigErrorsToDiscard(p_LnxWrpFmPortDev->h_Dev,
97082 + be32_to_cpu(uint32_prop[0]))) != E_OK)
97083 + RETURN_ERROR(MINOR, err, NO_MSG);
97084 + }
97085 +
97086 + uint32_prop = (uint32_t *)of_get_property(port_node, "ar-tables-sizes",
97087 + &lenp);
97088 + if (uint32_prop) {
97089 +
97090 + if (WARN_ON(lenp != sizeof(uint32_t)*8))
97091 + RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
97092 + if (WARN_ON(p_LnxWrpFmPortDev->settings.param.portType !=
97093 + e_FM_PORT_TYPE_RX) &&
97094 + (p_LnxWrpFmPortDev->settings.param.portType !=
97095 + e_FM_PORT_TYPE_RX_10G))
97096 + RETURN_ERROR(MINOR, E_INVALID_VALUE,
97097 + ("Auto Response is an Rx port atribute."));
97098 +
97099 + memset(&p_LnxWrpFmPortDev->dsar_table_sizes, 0, sizeof(struct auto_res_tables_sizes));
97100 +
97101 + p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_arp_entries =
97102 + (uint16_t)be32_to_cpu(uint32_prop[0]);
97103 + p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_echo_ipv4_entries =
97104 + (uint16_t)be32_to_cpu(uint32_prop[1]);
97105 + p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_ndp_entries =
97106 + (uint16_t)be32_to_cpu(uint32_prop[2]);
97107 + p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_echo_ipv6_entries =
97108 + (uint16_t)be32_to_cpu(uint32_prop[3]);
97109 + p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_snmp_ipv4_entries =
97110 + (uint16_t)be32_to_cpu(uint32_prop[4]);
97111 + p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_snmp_ipv6_entries =
97112 + (uint16_t)be32_to_cpu(uint32_prop[5]);
97113 + p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_snmp_oid_entries =
97114 + (uint16_t)be32_to_cpu(uint32_prop[6]);
97115 + p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_snmp_char =
97116 + (uint16_t)be32_to_cpu(uint32_prop[7]);
97117 +
97118 + uint32_prop = (uint32_t *)of_get_property(port_node,
97119 + "ar-filters-sizes", &lenp);
97120 + if (uint32_prop) {
97121 + if (WARN_ON(lenp != sizeof(uint32_t)*3))
97122 + RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
97123 +
97124 + p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_ip_prot_filtering =
97125 + (uint16_t)be32_to_cpu(uint32_prop[0]);
97126 + p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_tcp_port_filtering =
97127 + (uint16_t)be32_to_cpu(uint32_prop[1]);
97128 + p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_udp_port_filtering =
97129 + (uint16_t)be32_to_cpu(uint32_prop[2]);
97130 + }
97131 +
97132 + if ((err = FM_PORT_ConfigDsarSupport(p_LnxWrpFmPortDev->h_Dev,
97133 + (t_FmPortDsarTablesSizes*)&p_LnxWrpFmPortDev->dsar_table_sizes)) != E_OK)
97134 + RETURN_ERROR(MINOR, err, NO_MSG);
97135 + }
97136 +
97137 + of_node_put(port_node);
97138 + of_node_put(fm_node);
97139 +
97140 + return E_OK;
97141 +}
97142 +
97143 +static t_Error CheckNSetFmPortAdvArgs (t_LnxWrpFmPortDev *p_LnxWrpFmPortDev)
97144 +{
97145 + struct device_node *fm_node, *port_node;
97146 + t_Error err;
97147 + const uint32_t *uint32_prop;
97148 + /*const char *str_prop;*/
97149 + int lenp;
97150 +
97151 + fm_node = GetFmAdvArgsDevTreeNode(((t_LnxWrpFmDev *) p_LnxWrpFmPortDev->h_LnxWrpFmDev)->id);
97152 + if (!fm_node) /* no advance parameters for FMan */
97153 + return E_OK;
97154 +
97155 + port_node = GetFmPortAdvArgsDevTreeNode(fm_node,
97156 + p_LnxWrpFmPortDev->settings.param.portType,
97157 + p_LnxWrpFmPortDev->settings.param.portId);
97158 + if (!port_node) /* no advance parameters for FMan-Port */
97159 + return E_OK;
97160 +
97161 +#if (DPAA_VERSION >= 11)
97162 + uint32_prop = (uint32_t *)of_get_property(port_node, "vsp-window", &lenp);
97163 + if (uint32_prop) {
97164 + t_FmPortVSPAllocParams portVSPAllocParams;
97165 + t_FmVspParams fmVspParams;
97166 + t_LnxWrpFmDev *p_LnxWrpFmDev;
97167 + uint8_t portId;
97168 +
97169 + p_LnxWrpFmDev = ((t_LnxWrpFmDev *)p_LnxWrpFmPortDev->h_LnxWrpFmDev);
97170 +
97171 + if (WARN_ON(lenp != sizeof(uint32_t)*2))
97172 + RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
97173 +
97174 + if ((p_LnxWrpFmPortDev->settings.param.portType == e_FM_PORT_TYPE_TX) ||
97175 + (p_LnxWrpFmPortDev->settings.param.portType == e_FM_PORT_TYPE_TX_10G) ||
97176 + ((p_LnxWrpFmPortDev->settings.param.portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) &&
97177 + p_LnxWrpFmPortDev->settings.frag_enabled))
97178 + return E_OK;
97179 +
97180 + memset(&portVSPAllocParams, 0, sizeof(portVSPAllocParams));
97181 + memset(&fmVspParams, 0, sizeof(fmVspParams));
97182 +
97183 + portVSPAllocParams.numOfProfiles = (uint8_t)be32_to_cpu(uint32_prop[0]);
97184 + portVSPAllocParams.dfltRelativeId = (uint8_t)be32_to_cpu(uint32_prop[1]);
97185 + fmVspParams.h_Fm = p_LnxWrpFmDev->h_Dev;
97186 +
97187 + fmVspParams.portParams.portType = p_LnxWrpFmPortDev->settings.param.portType;
97188 + fmVspParams.portParams.portId = p_LnxWrpFmPortDev->settings.param.portId;
97189 + fmVspParams.relativeProfileId = portVSPAllocParams.dfltRelativeId;
97190 +
97191 + if (p_LnxWrpFmPortDev->settings.param.portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
97192 + {
97193 + portId = fmVspParams.portParams.portId;
97194 + if (p_LnxWrpFmPortDev->settings.param.portType == e_FM_PORT_TYPE_RX_10G){
97195 +#ifndef CONFIG_FMAN_ARM
97196 + if (!(IS_T1023_T1024))
97197 +#endif
97198 + portId += FM_MAX_NUM_OF_1G_RX_PORTS;
97199 + }
97200 + portVSPAllocParams.h_FmTxPort =
97201 + p_LnxWrpFmDev->txPorts[portId].h_Dev;
97202 + fmVspParams.liodnOffset =
97203 + p_LnxWrpFmDev->rxPorts[portId].settings.param.specificParams.rxParams.liodnOffset;
97204 + memcpy(&fmVspParams.extBufPools,
97205 + &p_LnxWrpFmPortDev->settings.param.specificParams.rxParams.extBufPools,
97206 + sizeof(t_FmExtPools));
97207 + }
97208 + else
97209 + {
97210 + memcpy(&fmVspParams.extBufPools,
97211 + &p_LnxWrpFmPortDev->opExtPools,
97212 + sizeof(t_FmExtPools));
97213 + }
97214 +
97215 + if ((err = FM_PORT_VSPAlloc(p_LnxWrpFmPortDev->h_Dev,
97216 + &portVSPAllocParams)) != E_OK)
97217 + RETURN_ERROR(MINOR, err, NO_MSG);
97218 +
97219 + /* We're initializing only the default VSP that are being used by the Linux-Ethernet-driver */
97220 + if ((p_LnxWrpFmPortDev->settings.param.portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) &&
97221 + !p_LnxWrpFmPortDev->opExtPools.numOfPoolsUsed)
97222 + return E_OK;
97223 +
97224 + p_LnxWrpFmPortDev->h_DfltVsp = FM_VSP_Config(&fmVspParams);
97225 + if (!p_LnxWrpFmPortDev->h_DfltVsp)
97226 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("default-VSP for port!"));
97227 +
97228 + if ((err = FM_VSP_ConfigBufferPrefixContent(p_LnxWrpFmPortDev->h_DfltVsp,
97229 + &p_LnxWrpFmPortDev->buffPrefixContent)) != E_OK)
97230 + RETURN_ERROR(MINOR, err, NO_MSG);
97231 +
97232 + if ((err = FM_VSP_Init(p_LnxWrpFmPortDev->h_DfltVsp)) != E_OK)
97233 + RETURN_ERROR(MINOR, err, NO_MSG);
97234 + }
97235 +#else
97236 +UNUSED(err); UNUSED(uint32_prop); UNUSED(lenp);
97237 +#endif /* (DPAA_VERSION >= 11) */
97238 +
97239 + of_node_put(port_node);
97240 + of_node_put(fm_node);
97241 +
97242 + return E_OK;
97243 +}
97244 +
97245 +static t_Error ConfigureFmPortDev(t_LnxWrpFmPortDev *p_LnxWrpFmPortDev)
97246 +{
97247 + t_LnxWrpFmDev *p_LnxWrpFmDev =
97248 + (t_LnxWrpFmDev *) p_LnxWrpFmPortDev->h_LnxWrpFmDev;
97249 + struct resource *dev_res;
97250 +
97251 + if (!p_LnxWrpFmPortDev->active)
97252 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
97253 + ("FM port not configured!!!"));
97254 +
97255 + dev_res =
97256 + __devm_request_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->res,
97257 + p_LnxWrpFmPortDev->phys_baseAddr,
97258 + p_LnxWrpFmPortDev->memSize,
97259 + "fman-port-hc");
97260 + if (unlikely(dev_res == NULL))
97261 + RETURN_ERROR(MAJOR, E_INVALID_STATE,
97262 + ("__devm_request_region() failed"));
97263 + p_LnxWrpFmPortDev->baseAddr =
97264 + PTR_TO_UINT(devm_ioremap
97265 + (p_LnxWrpFmDev->dev,
97266 + p_LnxWrpFmPortDev->phys_baseAddr,
97267 + p_LnxWrpFmPortDev->memSize));
97268 + if (unlikely(p_LnxWrpFmPortDev->baseAddr == 0))
97269 + REPORT_ERROR(MAJOR, E_INVALID_STATE,
97270 + ("devm_ioremap() failed"));
97271 +
97272 + p_LnxWrpFmPortDev->settings.param.baseAddr =
97273 + p_LnxWrpFmPortDev->baseAddr;
97274 +
97275 + return E_OK;
97276 +}
97277 +
97278 +static t_Error InitFmPortDev(t_LnxWrpFmPortDev *p_LnxWrpFmPortDev)
97279 +{
97280 +#define MY_ADV_CONFIG_CHECK_END \
97281 + RETURN_ERROR(MAJOR, E_INVALID_SELECTION,\
97282 + ("Advanced configuration routine"));\
97283 + if (errCode != E_OK)\
97284 + RETURN_ERROR(MAJOR, errCode, NO_MSG);\
97285 + }
97286 +
97287 + int i = 0;
97288 +
97289 + if (!p_LnxWrpFmPortDev->active || p_LnxWrpFmPortDev->h_Dev)
97290 + return E_INVALID_STATE;
97291 +
97292 + p_LnxWrpFmPortDev->h_Dev =
97293 + FM_PORT_Config(&p_LnxWrpFmPortDev->settings.param);
97294 + if (p_LnxWrpFmPortDev->h_Dev == NULL)
97295 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("FM-port"));
97296 +
97297 +#ifndef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
97298 + if ((p_LnxWrpFmPortDev->settings.param.portType ==
97299 + e_FM_PORT_TYPE_TX_10G)
97300 + || (p_LnxWrpFmPortDev->settings.param.portType ==
97301 + e_FM_PORT_TYPE_TX)) {
97302 + t_Error errCode = E_OK;
97303 + errCode =
97304 + FM_PORT_ConfigDeqHighPriority(p_LnxWrpFmPortDev->h_Dev,
97305 + TRUE);
97306 + if (errCode != E_OK)
97307 + RETURN_ERROR(MAJOR, errCode, NO_MSG);
97308 + errCode =
97309 + FM_PORT_ConfigDeqPrefetchOption(p_LnxWrpFmPortDev->h_Dev,
97310 + e_FM_PORT_DEQ_FULL_PREFETCH);
97311 + if (errCode
97312 + != E_OK)
97313 + RETURN_ERROR(MAJOR, errCode, NO_MSG);
97314 + }
97315 +#endif /* !FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
97316 +
97317 +#ifndef CONFIG_FMAN_ARM
97318 +#ifdef FM_BCB_ERRATA_BMI_SW001
97319 +/* Configure BCB workaround on Rx ports, only for B4860 rev1 */
97320 +#define SVR_SECURITY_MASK 0x00080000
97321 +#define SVR_PERSONALITY_MASK 0x0000FF00
97322 +#define SVR_VER_IGNORE_MASK (SVR_SECURITY_MASK | SVR_PERSONALITY_MASK)
97323 +#define SVR_B4860_REV1_VALUE 0x86800010
97324 +
97325 + if ((p_LnxWrpFmPortDev->settings.param.portType ==
97326 + e_FM_PORT_TYPE_RX_10G) ||
97327 + (p_LnxWrpFmPortDev->settings.param.portType ==
97328 + e_FM_PORT_TYPE_RX)) {
97329 + unsigned int svr;
97330 +
97331 + svr = mfspr(SPRN_SVR);
97332 +
97333 + if ((svr & ~SVR_VER_IGNORE_MASK) == SVR_B4860_REV1_VALUE)
97334 + FM_PORT_ConfigBCBWorkaround(p_LnxWrpFmPortDev->h_Dev);
97335 + }
97336 +#endif /* FM_BCB_ERRATA_BMI_SW001 */
97337 +#endif /* CONFIG_FMAN_ARM */
97338 +/* Call the driver's advanced configuration routines, if requested:
97339 + Compare the function pointer of each entry to the available routines,
97340 + and invoke the matching routine with proper casting of arguments. */
97341 + while (p_LnxWrpFmPortDev->settings.advConfig[i].p_Function
97342 + && (i < FM_MAX_NUM_OF_ADV_SETTINGS)) {
97343 +
97344 +/* TODO: Change this MACRO */
97345 + ADV_CONFIG_CHECK_START(
97346 + &(p_LnxWrpFmPortDev->settings.advConfig[i]))
97347 +
97348 + ADV_CONFIG_CHECK(p_LnxWrpFmPortDev->h_Dev,
97349 + FM_PORT_ConfigBufferPrefixContent,
97350 + NCSW_PARAMS(1,
97351 + (t_FmBufferPrefixContent *)))
97352 +
97353 + if ((p_LnxWrpFmPortDev->settings.param.portType ==
97354 + e_FM_PORT_TYPE_OH_OFFLINE_PARSING) &&
97355 + (p_LnxWrpFmPortDev->settings.frag_enabled == TRUE)) {
97356 +
97357 + ADV_CONFIG_CHECK(p_LnxWrpFmPortDev->h_Dev,
97358 + FM_PORT_ConfigExtBufPools,
97359 + NCSW_PARAMS(1, (t_FmExtPools *)))
97360 +
97361 + /* this define contains an else */
97362 + MY_ADV_CONFIG_CHECK_END
97363 + }
97364 +
97365 + /* Advance to next advanced configuration entry */
97366 + i++;
97367 + }
97368 +
97369 +
97370 + if ((p_LnxWrpFmPortDev->settings.param.portType != e_FM_PORT_TYPE_TX) &&
97371 + (p_LnxWrpFmPortDev->settings.param.portType != e_FM_PORT_TYPE_TX_10G)) {
97372 + if (FM_PORT_ConfigErrorsToDiscard(p_LnxWrpFmPortDev->h_Dev, (FM_PORT_FRM_ERR_IPRE |
97373 + FM_PORT_FRM_ERR_IPR_NCSP |
97374 + FM_PORT_FRM_ERR_CLS_DISCARD)) !=E_OK)
97375 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
97376 + }
97377 +
97378 + if (CheckNConfigFmPortAdvArgs(p_LnxWrpFmPortDev) != E_OK)
97379 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
97380 +
97381 + if (FM_PORT_Init(p_LnxWrpFmPortDev->h_Dev) != E_OK)
97382 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
97383 +
97384 + if (CheckNSetFmPortAdvArgs(p_LnxWrpFmPortDev) != E_OK)
97385 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
97386 +
97387 +/* FMan Fifo sizes behind the scene":
97388 + * Using the following formulae (*), under a set of simplifying assumptions (.):
97389 + * . all ports are configured in Normal Mode (rather than Independent Mode)
97390 + * . the DPAA Eth driver allocates buffers of size:
97391 + * . MAXFRM + NET_IP_ALIGN + DPA_PRIV_DATA_SIZE + DPA_PARSE_RESULTS_SIZE
97392 + * + DPA_HASH_RESULTS_SIZE, i.e.:
97393 + * MAXFRM + 2 + 16 + sizeof(t_FmPrsResult) + 16, i.e.:
97394 + * MAXFRM + 66
97395 + * . excessive buffer pools not accounted for
97396 + *
97397 + * * for Rx ports on P4080:
97398 + * . IFSZ = ceil(max(FMBM_EBMPI[PBS]) / 256) * 256 + 7 * 256
97399 + * . no internal frame offset (FMBM_RIM[FOF] == 0) - otherwise,
97400 + * add up to 256 to the above
97401 + *
97402 + * * for Rx ports on P1023:
97403 + * . IFSZ = ceil(second_largest(FMBM_EBMPI[PBS] / 256)) * 256 + 7 * 256,
97404 + * if at least 2 bpools are configured
97405 + * . IFSZ = 8 * 256, if only a single bpool is configured
97406 + *
97407 + * * for Tx ports:
97408 + * . IFSZ = ceil(frame_size / 256) * 256 + 3 * 256
97409 + * + FMBM_TFP[DPDE] * 256, i.e.:
97410 + * IFSZ = ceil(MAXFRM / 256) * 256 + 3 x 256 + FMBM_TFP[DPDE] * 256
97411 + *
97412 + * * for OH ports on P4080:
97413 + * . IFSZ = ceil(frame_size / 256) * 256 + 1 * 256 + FMBM_PP[MXT] * 256
97414 + * * for OH ports on P1023:
97415 + * . IFSZ = ceil(frame_size / 256) * 256 + 3 * 256 + FMBM_TFP[DPDE] * 256
97416 + * * for both P4080 and P1023:
97417 + * . (conservative decisions, assuming that BMI must bring the entire
97418 + * frame, not only the frame header)
97419 + * . no internal frame offset (FMBM_OIM[FOF] == 0) - otherwise,
97420 + * add up to 256 to the above
97421 + *
97422 + * . for P4080/P5020/P3041/P2040, DPDE is:
97423 + * > 0 or 1, for 1Gb ports, HW default: 0
97424 + * > 2..7 (recommended: 3..7) for 10Gb ports, HW default: 3
97425 + * . for P1023, DPDE should be 1
97426 + *
97427 + * . for P1023, MXT is in range (0..31)
97428 + * . for P4080, MXT is in range (0..63)
97429 + *
97430 + */
97431 +#if 0
97432 + if ((p_LnxWrpFmPortDev->defPcd != e_NO_PCD) &&
97433 + (InitFmPort3TupleDefPcd(p_LnxWrpFmPortDev) != E_OK))
97434 + RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
97435 +#endif
97436 + return E_OK;
97437 +}
97438 +
97439 +void fm_set_rx_port_params(struct fm_port *port,
97440 + struct fm_port_params *params)
97441 +{
97442 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *) port;
97443 + int i;
97444 +
97445 + p_LnxWrpFmPortDev->settings.param.specificParams.rxParams.errFqid =
97446 + params->errq;
97447 + p_LnxWrpFmPortDev->settings.param.specificParams.rxParams.dfltFqid =
97448 + params->defq;
97449 + p_LnxWrpFmPortDev->settings.param.specificParams.rxParams.extBufPools.
97450 + numOfPoolsUsed = params->num_pools;
97451 + for (i = 0; i < params->num_pools; i++) {
97452 + p_LnxWrpFmPortDev->settings.param.specificParams.rxParams.
97453 + extBufPools.extBufPool[i].id =
97454 + params->pool_param[i].id;
97455 + p_LnxWrpFmPortDev->settings.param.specificParams.rxParams.
97456 + extBufPools.extBufPool[i].size =
97457 + params->pool_param[i].size;
97458 + }
97459 +
97460 + p_LnxWrpFmPortDev->buffPrefixContent.privDataSize =
97461 + params->priv_data_size;
97462 + p_LnxWrpFmPortDev->buffPrefixContent.passPrsResult =
97463 + params->parse_results;
97464 + p_LnxWrpFmPortDev->buffPrefixContent.passHashResult =
97465 + params->hash_results;
97466 + p_LnxWrpFmPortDev->buffPrefixContent.passTimeStamp =
97467 + params->time_stamp;
97468 + p_LnxWrpFmPortDev->buffPrefixContent.dataAlign =
97469 + params->data_align;
97470 + p_LnxWrpFmPortDev->buffPrefixContent.manipExtraSpace =
97471 + params->manip_extra_space;
97472 +
97473 + ADD_ADV_CONFIG_START(p_LnxWrpFmPortDev->settings.advConfig,
97474 + FM_MAX_NUM_OF_ADV_SETTINGS)
97475 +
97476 + ADD_ADV_CONFIG_NO_RET(FM_PORT_ConfigBufferPrefixContent,
97477 + ARGS(1,
97478 + (&p_LnxWrpFmPortDev->
97479 + buffPrefixContent)));
97480 +
97481 + ADD_ADV_CONFIG_END InitFmPortDev(p_LnxWrpFmPortDev);
97482 +}
97483 +EXPORT_SYMBOL(fm_set_rx_port_params);
97484 +
97485 +/* this function is called from oh_probe as well, thus it contains oh port
97486 + * specific parameters (make sure everything is checked) */
97487 +void fm_set_tx_port_params(struct fm_port *port,
97488 + struct fm_port_params *params)
97489 +{
97490 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *) port;
97491 +
97492 + p_LnxWrpFmPortDev->settings.param.specificParams.nonRxParams.errFqid =
97493 + params->errq;
97494 + p_LnxWrpFmPortDev->settings.param.specificParams.nonRxParams.
97495 + dfltFqid = params->defq;
97496 +
97497 + p_LnxWrpFmPortDev->buffPrefixContent.privDataSize =
97498 + params->priv_data_size;
97499 + p_LnxWrpFmPortDev->buffPrefixContent.passPrsResult =
97500 + params->parse_results;
97501 + p_LnxWrpFmPortDev->buffPrefixContent.passHashResult =
97502 + params->hash_results;
97503 + p_LnxWrpFmPortDev->buffPrefixContent.passTimeStamp =
97504 + params->time_stamp;
97505 + p_LnxWrpFmPortDev->settings.frag_enabled =
97506 + params->frag_enable;
97507 + p_LnxWrpFmPortDev->buffPrefixContent.dataAlign =
97508 + params->data_align;
97509 + p_LnxWrpFmPortDev->buffPrefixContent.manipExtraSpace =
97510 + params->manip_extra_space;
97511 +
97512 + ADD_ADV_CONFIG_START(p_LnxWrpFmPortDev->settings.advConfig,
97513 + FM_MAX_NUM_OF_ADV_SETTINGS)
97514 +
97515 + ADD_ADV_CONFIG_NO_RET(FM_PORT_ConfigBufferPrefixContent,
97516 + ARGS(1,
97517 + (&p_LnxWrpFmPortDev->
97518 + buffPrefixContent)));
97519 +
97520 + /* oh port specific parameter (for fragmentation only) */
97521 + if ((p_LnxWrpFmPortDev->settings.param.portType ==
97522 + e_FM_PORT_TYPE_OH_OFFLINE_PARSING) &&
97523 + params->num_pools) {
97524 + int i;
97525 +
97526 + p_LnxWrpFmPortDev->opExtPools.numOfPoolsUsed = params->num_pools;
97527 + for (i = 0; i < params->num_pools; i++) {
97528 + p_LnxWrpFmPortDev->opExtPools.extBufPool[i].id = params->pool_param[i].id;
97529 + p_LnxWrpFmPortDev->opExtPools.extBufPool[i].size = params->pool_param[i].size;
97530 + }
97531 +
97532 + if (p_LnxWrpFmPortDev->settings.frag_enabled)
97533 + ADD_ADV_CONFIG_NO_RET(FM_PORT_ConfigExtBufPools,
97534 + ARGS(1, (&p_LnxWrpFmPortDev->opExtPools)));
97535 + }
97536 +
97537 + ADD_ADV_CONFIG_END InitFmPortDev(p_LnxWrpFmPortDev);
97538 +}
97539 +EXPORT_SYMBOL(fm_set_tx_port_params);
97540 +
97541 +void fm_mac_set_handle(t_Handle h_lnx_wrp_fm_dev,
97542 + t_Handle h_fm_mac,
97543 + int mac_id)
97544 +{
97545 + t_LnxWrpFmDev *p_lnx_wrp_fm_dev = (t_LnxWrpFmDev *)h_lnx_wrp_fm_dev;
97546 +
97547 + p_lnx_wrp_fm_dev->macs[mac_id].h_Dev = h_fm_mac;
97548 + p_lnx_wrp_fm_dev->macs[mac_id].h_LnxWrpFmDev = h_lnx_wrp_fm_dev;
97549 +}
97550 +EXPORT_SYMBOL(fm_mac_set_handle);
97551 +
97552 +static void LnxwrpFmPcdDevExceptionsCb(t_Handle h_App,
97553 + e_FmPcdExceptions exception)
97554 +{
97555 + t_LnxWrpFmDev *p_LnxWrpFmDev = (t_LnxWrpFmDev *) h_App;
97556 +
97557 + ASSERT_COND(p_LnxWrpFmDev);
97558 +
97559 + DBG(INFO, ("got fm-pcd exception %d", exception));
97560 +
97561 + /* do nothing */
97562 + UNUSED(exception);
97563 +}
97564 +
97565 +static void LnxwrpFmPcdDevIndexedExceptionsCb(t_Handle h_App,
97566 + e_FmPcdExceptions exception,
97567 + uint16_t index)
97568 +{
97569 + t_LnxWrpFmDev *p_LnxWrpFmDev = (t_LnxWrpFmDev *) h_App;
97570 +
97571 + ASSERT_COND(p_LnxWrpFmDev);
97572 +
97573 + DBG(INFO,
97574 + ("got fm-pcd-indexed exception %d, indx %d", exception, index));
97575 +
97576 + /* do nothing */
97577 + UNUSED(exception);
97578 + UNUSED(index);
97579 +}
97580 +
97581 +static t_Error InitFmPcdDev(t_LnxWrpFmDev *p_LnxWrpFmDev)
97582 +{
97583 + spin_lock_init(&lock);
97584 +
97585 + if (p_LnxWrpFmDev->pcdActive) {
97586 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = &p_LnxWrpFmDev->hcPort;
97587 + t_FmPcdParams fmPcdParams;
97588 + t_Error err;
97589 +
97590 + memset(&fmPcdParams, 0, sizeof(fmPcdParams));
97591 + fmPcdParams.h_Fm = p_LnxWrpFmDev->h_Dev;
97592 + fmPcdParams.prsSupport = p_LnxWrpFmDev->prsActive;
97593 + fmPcdParams.kgSupport = p_LnxWrpFmDev->kgActive;
97594 + fmPcdParams.plcrSupport = p_LnxWrpFmDev->plcrActive;
97595 + fmPcdParams.ccSupport = p_LnxWrpFmDev->ccActive;
97596 + fmPcdParams.numOfSchemes = FM_PCD_KG_NUM_OF_SCHEMES;
97597 +
97598 +#ifndef CONFIG_GUEST_PARTITION
97599 + fmPcdParams.f_Exception = LnxwrpFmPcdDevExceptionsCb;
97600 + if (fmPcdParams.kgSupport)
97601 + fmPcdParams.f_ExceptionId =
97602 + LnxwrpFmPcdDevIndexedExceptionsCb;
97603 + fmPcdParams.h_App = p_LnxWrpFmDev;
97604 +#endif /* !CONFIG_GUEST_PARTITION */
97605 +
97606 +#ifdef CONFIG_MULTI_PARTITION_SUPPORT
97607 + fmPcdParams.numOfSchemes = 0;
97608 + fmPcdParams.numOfClsPlanEntries = 0;
97609 + fmPcdParams.partitionId = 0;
97610 +#endif /* CONFIG_MULTI_PARTITION_SUPPORT */
97611 + fmPcdParams.useHostCommand = TRUE;
97612 +
97613 + p_LnxWrpFmDev->hc_tx_fq =
97614 + FqAlloc(p_LnxWrpFmDev,
97615 + 0,
97616 + QMAN_FQ_FLAG_TO_DCPORTAL,
97617 + p_LnxWrpFmPortDev->txCh, 0);
97618 + if (!p_LnxWrpFmDev->hc_tx_fq)
97619 + RETURN_ERROR(MAJOR, E_NULL_POINTER,
97620 + ("Frame queue allocation failed..."));
97621 +
97622 + p_LnxWrpFmDev->hc_tx_conf_fq =
97623 + FqAlloc(p_LnxWrpFmDev,
97624 + 0,
97625 + QMAN_FQ_FLAG_NO_ENQUEUE,
97626 + p_LnxWrpFmDev->hcCh, 7);
97627 + if (!p_LnxWrpFmDev->hc_tx_conf_fq)
97628 + RETURN_ERROR(MAJOR, E_NULL_POINTER,
97629 + ("Frame queue allocation failed..."));
97630 +
97631 + p_LnxWrpFmDev->hc_tx_err_fq =
97632 + FqAlloc(p_LnxWrpFmDev,
97633 + 0,
97634 + QMAN_FQ_FLAG_NO_ENQUEUE,
97635 + p_LnxWrpFmDev->hcCh, 7);
97636 + if (!p_LnxWrpFmDev->hc_tx_err_fq)
97637 + RETURN_ERROR(MAJOR, E_NULL_POINTER,
97638 + ("Frame queue allocation failed..."));
97639 +
97640 + fmPcdParams.hc.portBaseAddr = p_LnxWrpFmPortDev->baseAddr;
97641 + fmPcdParams.hc.portId =
97642 + p_LnxWrpFmPortDev->settings.param.portId;
97643 + fmPcdParams.hc.liodnBase =
97644 + p_LnxWrpFmPortDev->settings.param.liodnBase;
97645 + fmPcdParams.hc.errFqid =
97646 + qman_fq_fqid(p_LnxWrpFmDev->hc_tx_err_fq);
97647 + fmPcdParams.hc.confFqid =
97648 + qman_fq_fqid(p_LnxWrpFmDev->hc_tx_conf_fq);
97649 + fmPcdParams.hc.qmChannel = p_LnxWrpFmPortDev->txCh;
97650 + fmPcdParams.hc.f_QmEnqueue = QmEnqueueCB;
97651 + fmPcdParams.hc.h_QmArg = (t_Handle) p_LnxWrpFmDev;
97652 +
97653 + p_LnxWrpFmDev->h_PcdDev = FM_PCD_Config(&fmPcdParams);
97654 + if (!p_LnxWrpFmDev->h_PcdDev)
97655 + RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("FM PCD!"));
97656 +
97657 + err =
97658 + FM_PCD_ConfigPlcrNumOfSharedProfiles(p_LnxWrpFmDev->h_PcdDev,
97659 + LNXWRP_FM_NUM_OF_SHARED_PROFILES);
97660 + if (err != E_OK)
97661 + RETURN_ERROR(MAJOR, err, NO_MSG);
97662 +
97663 + err = FM_PCD_Init(p_LnxWrpFmDev->h_PcdDev);
97664 + if (err != E_OK)
97665 + RETURN_ERROR(MAJOR, err, NO_MSG);
97666 +
97667 + if (p_LnxWrpFmDev->err_irq == 0) {
97668 + FM_PCD_SetException(p_LnxWrpFmDev->h_PcdDev,
97669 + e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC,
97670 + FALSE);
97671 + FM_PCD_SetException(p_LnxWrpFmDev->h_PcdDev,
97672 + e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW,
97673 + FALSE);
97674 + FM_PCD_SetException(p_LnxWrpFmDev->h_PcdDev,
97675 + e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR,
97676 + FALSE);
97677 + FM_PCD_SetException(p_LnxWrpFmDev->h_PcdDev,
97678 + e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC,
97679 + FALSE);
97680 + FM_PCD_SetException(p_LnxWrpFmDev->h_PcdDev,
97681 + e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC,
97682 + FALSE);
97683 + FM_PCD_SetException(p_LnxWrpFmDev->h_PcdDev,
97684 + e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE,
97685 + FALSE);
97686 + FM_PCD_SetException(p_LnxWrpFmDev->h_PcdDev,
97687 + e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE,
97688 + FALSE);
97689 + FM_PCD_SetException(p_LnxWrpFmDev->h_PcdDev,
97690 + e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC,
97691 + FALSE);
97692 + }
97693 + }
97694 +
97695 + return E_OK;
97696 +}
97697 +
97698 +void FreeFmPcdDev(t_LnxWrpFmDev *p_LnxWrpFmDev)
97699 +{
97700 +
97701 + if (p_LnxWrpFmDev->h_PcdDev)
97702 + FM_PCD_Free(p_LnxWrpFmDev->h_PcdDev);
97703 +
97704 + if (p_LnxWrpFmDev->hc_tx_err_fq)
97705 + FqFree(p_LnxWrpFmDev->hc_tx_err_fq);
97706 +
97707 + if (p_LnxWrpFmDev->hc_tx_conf_fq)
97708 + FqFree(p_LnxWrpFmDev->hc_tx_conf_fq);
97709 +
97710 + if (p_LnxWrpFmDev->hc_tx_fq)
97711 + FqFree(p_LnxWrpFmDev->hc_tx_fq);
97712 +}
97713 +
97714 +static void FreeFmPortDev(t_LnxWrpFmPortDev *p_LnxWrpFmPortDev)
97715 +{
97716 + t_LnxWrpFmDev *p_LnxWrpFmDev =
97717 + (t_LnxWrpFmDev *) p_LnxWrpFmPortDev->h_LnxWrpFmDev;
97718 +
97719 + if (!p_LnxWrpFmPortDev->active)
97720 + return;
97721 +
97722 + if (p_LnxWrpFmPortDev->h_Dev)
97723 + FM_PORT_Free(p_LnxWrpFmPortDev->h_Dev);
97724 +
97725 + devm_iounmap(p_LnxWrpFmDev->dev,
97726 + UINT_TO_PTR(p_LnxWrpFmPortDev->baseAddr));
97727 + __devm_release_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->res,
97728 + p_LnxWrpFmPortDev->phys_baseAddr,
97729 + p_LnxWrpFmPortDev->memSize);
97730 +}
97731 +
97732 +static int /*__devinit*/ fm_port_probe(struct platform_device *of_dev)
97733 +{
97734 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev;
97735 + t_LnxWrpFmDev *p_LnxWrpFmDev;
97736 + struct device *dev;
97737 +
97738 + dev = &of_dev->dev;
97739 +
97740 + p_LnxWrpFmPortDev = ReadFmPortDevTreeNode(of_dev);
97741 + if (p_LnxWrpFmPortDev == NULL)
97742 + return -EIO;
97743 + /* Port can be inactive, thus will not be probed:
97744 + - in performance mode, OH ports are disabled
97745 + ...
97746 + */
97747 + if (!p_LnxWrpFmPortDev->active)
97748 + return 0;
97749 +
97750 + if (ConfigureFmPortDev(p_LnxWrpFmPortDev) != E_OK)
97751 + return -EIO;
97752 +
97753 + dev_set_drvdata(dev, p_LnxWrpFmPortDev);
97754 +
97755 + if (p_LnxWrpFmPortDev->settings.param.portType ==
97756 + e_FM_PORT_TYPE_OH_HOST_COMMAND)
97757 + InitFmPcdDev((t_LnxWrpFmDev *) p_LnxWrpFmPortDev->h_LnxWrpFmDev);
97758 +
97759 + p_LnxWrpFmDev = (t_LnxWrpFmDev *) p_LnxWrpFmPortDev->h_LnxWrpFmDev;
97760 +
97761 + if (p_LnxWrpFmPortDev->settings.param.portType == e_FM_PORT_TYPE_RX) {
97762 + Sprint(p_LnxWrpFmPortDev->name, "%s-port-rx%d",
97763 + p_LnxWrpFmDev->name, p_LnxWrpFmPortDev->id);
97764 + p_LnxWrpFmPortDev->minor =
97765 + p_LnxWrpFmPortDev->id + DEV_FM_RX_PORTS_MINOR_BASE;
97766 + } else if (p_LnxWrpFmPortDev->settings.param.portType ==
97767 + e_FM_PORT_TYPE_RX_10G) {
97768 + Sprint(p_LnxWrpFmPortDev->name, "%s-port-rx%d",
97769 + p_LnxWrpFmDev->name,
97770 + p_LnxWrpFmPortDev->id + FM_MAX_NUM_OF_1G_RX_PORTS);
97771 + p_LnxWrpFmPortDev->minor =
97772 + p_LnxWrpFmPortDev->id + FM_MAX_NUM_OF_1G_RX_PORTS +
97773 + DEV_FM_RX_PORTS_MINOR_BASE;
97774 +#ifndef CONFIG_FMAN_ARM
97775 + if (IS_T1023_T1024) {
97776 + Sprint(p_LnxWrpFmPortDev->name, "%s-port-rx%d",
97777 + p_LnxWrpFmDev->name,
97778 + p_LnxWrpFmPortDev->id);
97779 + p_LnxWrpFmPortDev->minor =
97780 + p_LnxWrpFmPortDev->id +
97781 + DEV_FM_RX_PORTS_MINOR_BASE;
97782 + }
97783 +#endif
97784 + } else if (p_LnxWrpFmPortDev->settings.param.portType ==
97785 + e_FM_PORT_TYPE_TX) {
97786 + Sprint(p_LnxWrpFmPortDev->name, "%s-port-tx%d",
97787 + p_LnxWrpFmDev->name, p_LnxWrpFmPortDev->id);
97788 + p_LnxWrpFmPortDev->minor =
97789 + p_LnxWrpFmPortDev->id + DEV_FM_TX_PORTS_MINOR_BASE;
97790 + } else if (p_LnxWrpFmPortDev->settings.param.portType ==
97791 + e_FM_PORT_TYPE_TX_10G) {
97792 + Sprint(p_LnxWrpFmPortDev->name, "%s-port-tx%d",
97793 + p_LnxWrpFmDev->name,
97794 + p_LnxWrpFmPortDev->id + FM_MAX_NUM_OF_1G_TX_PORTS);
97795 + p_LnxWrpFmPortDev->minor =
97796 + p_LnxWrpFmPortDev->id + FM_MAX_NUM_OF_1G_TX_PORTS +
97797 + DEV_FM_TX_PORTS_MINOR_BASE;
97798 +#ifndef CONFIG_FMAN_ARM
97799 + if (IS_T1023_T1024) {
97800 + Sprint(p_LnxWrpFmPortDev->name, "%s-port-tx%d",
97801 + p_LnxWrpFmDev->name,
97802 + p_LnxWrpFmPortDev->id);
97803 + p_LnxWrpFmPortDev->minor =
97804 + p_LnxWrpFmPortDev->id +
97805 + DEV_FM_TX_PORTS_MINOR_BASE;
97806 + }
97807 +#endif
97808 + } else if (p_LnxWrpFmPortDev->settings.param.portType ==
97809 + e_FM_PORT_TYPE_OH_HOST_COMMAND) {
97810 + Sprint(p_LnxWrpFmPortDev->name, "%s-port-oh%d",
97811 + p_LnxWrpFmDev->name, p_LnxWrpFmPortDev->id);
97812 + p_LnxWrpFmPortDev->minor =
97813 + p_LnxWrpFmPortDev->id + DEV_FM_OH_PORTS_MINOR_BASE;
97814 + } else if (p_LnxWrpFmPortDev->settings.param.portType ==
97815 + e_FM_PORT_TYPE_OH_OFFLINE_PARSING) {
97816 + Sprint(p_LnxWrpFmPortDev->name, "%s-port-oh%d",
97817 + p_LnxWrpFmDev->name, p_LnxWrpFmPortDev->id + 1);
97818 + p_LnxWrpFmPortDev->minor =
97819 + p_LnxWrpFmPortDev->id + 1 +
97820 + DEV_FM_OH_PORTS_MINOR_BASE;
97821 + }
97822 +
97823 + device_create(p_LnxWrpFmDev->fm_class, NULL,
97824 + MKDEV(p_LnxWrpFmDev->major, p_LnxWrpFmPortDev->minor),
97825 + NULL, p_LnxWrpFmPortDev->name);
97826 +
97827 + /* create sysfs entries for stats and regs */
97828 +
97829 + if (fm_port_sysfs_create(dev) != 0) {
97830 + FreeFmPortDev(p_LnxWrpFmPortDev);
97831 + REPORT_ERROR(MAJOR, E_INVALID_STATE,
97832 + ("Unable to create sys entry - fm port!!!"));
97833 + return -EIO;
97834 + }
97835 +
97836 +#ifdef FM_TX_INVALID_ECC_ERRATA_10GMAC_A009
97837 + FM_DisableRamsEcc(p_LnxWrpFmDev->h_Dev);
97838 +#endif /* FM_TX_INVALID_ECC_ERRATA_10GMAC_A009 */
97839 +
97840 + DBG(TRACE, ("%s probed", p_LnxWrpFmPortDev->name));
97841 +
97842 + return 0;
97843 +}
97844 +
97845 +static int fm_port_remove(struct platform_device *of_dev)
97846 +{
97847 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev;
97848 + t_LnxWrpFmDev *p_LnxWrpFmDev;
97849 + struct device *dev;
97850 +
97851 + dev = &of_dev->dev;
97852 + p_LnxWrpFmPortDev = dev_get_drvdata(dev);
97853 +
97854 + fm_port_sysfs_destroy(dev);
97855 +
97856 + p_LnxWrpFmDev = (t_LnxWrpFmDev *) p_LnxWrpFmPortDev->h_LnxWrpFmDev;
97857 + device_destroy(p_LnxWrpFmDev->fm_class,
97858 + MKDEV(p_LnxWrpFmDev->major, p_LnxWrpFmPortDev->minor));
97859 +
97860 + FreeFmPortDev(p_LnxWrpFmPortDev);
97861 +
97862 + dev_set_drvdata(dev, NULL);
97863 +
97864 + return 0;
97865 +}
97866 +
97867 +static const struct of_device_id fm_port_match[] = {
97868 + {
97869 + .compatible = "fsl,fman-port-oh"},
97870 + {
97871 + .compatible = "fsl,fman-port-1g-rx"},
97872 + {
97873 + .compatible = "fsl,fman-port-10g-rx"},
97874 + {
97875 + .compatible = "fsl,fman-port-1g-tx"},
97876 + {
97877 + .compatible = "fsl,fman-port-10g-tx"},
97878 + {}
97879 +};
97880 +
97881 +#ifndef MODULE
97882 +MODULE_DEVICE_TABLE(of, fm_port_match);
97883 +#endif /* !MODULE */
97884 +
97885 +static struct platform_driver fm_port_driver = {
97886 +
97887 + .driver = {
97888 + .name = "fsl-fman-port",
97889 + .of_match_table = fm_port_match,
97890 + .owner = THIS_MODULE,
97891 + },
97892 + .probe = fm_port_probe,
97893 + .remove = fm_port_remove
97894 +};
97895 +
97896 +
97897 +t_Error LNXWRP_FM_Port_Init(void)
97898 +{
97899 + /* Register to the DTB for basic FM port API */
97900 + if (platform_driver_register(&fm_port_driver))
97901 + return E_NO_DEVICE;
97902 +
97903 + return E_OK;
97904 +}
97905 +
97906 +void LNXWRP_FM_Port_Free(void)
97907 +{
97908 + platform_driver_unregister(&fm_port_driver);
97909 +}
97910 +
97911 +static int __init __cold fm_port_load(void)
97912 +{
97913 + if (LNXWRP_FM_Port_Init() != E_OK) {
97914 + printk(KERN_CRIT "Failed to init FM Ports wrapper!\n");
97915 + return -ENODEV;
97916 + }
97917 +
97918 + printk(KERN_CRIT "Freescale FM Ports module\n");
97919 +
97920 + return 0;
97921 +}
97922 +
97923 +static void __exit __cold fm_port_unload(void)
97924 +{
97925 + LNXWRP_FM_Port_Free();
97926 +}
97927 +
97928 +module_init(fm_port_load);
97929 +module_exit(fm_port_unload);
97930 --- /dev/null
97931 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm.c
97932 @@ -0,0 +1,4813 @@
97933 +/*
97934 + * Copyright 2008-2012 Freescale Semiconductor Inc.
97935 + *
97936 + * Redistribution and use in source and binary forms, with or without
97937 + * modification, are permitted provided that the following conditions are met:
97938 + * * Redistributions of source code must retain the above copyright
97939 + * notice, this list of conditions and the following disclaimer.
97940 + * * Redistributions in binary form must reproduce the above copyright
97941 + * notice, this list of conditions and the following disclaimer in the
97942 + * documentation and/or other materials provided with the distribution.
97943 + * * Neither the name of Freescale Semiconductor nor the
97944 + * names of its contributors may be used to endorse or promote products
97945 + * derived from this software without specific prior written permission.
97946 + *
97947 + *
97948 + * ALTERNATIVELY, this software may be distributed under the terms of the
97949 + * GNU General Public License ("GPL") as published by the Free Software
97950 + * Foundation, either version 2 of that License or (at your option) any
97951 + * later version.
97952 + *
97953 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
97954 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
97955 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
97956 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
97957 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
97958 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
97959 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
97960 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
97961 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
97962 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
97963 + */
97964 +
97965 +/*
97966 + @File lnxwrp_ioctls_fm.c
97967 + @Author Shlomi Gridish
97968 + @Description FM Linux wrapper functions.
97969 +*/
97970 +
97971 +/* Linux Headers ------------------- */
97972 +#include <linux/version.h>
97973 +
97974 +#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
97975 +#define MODVERSIONS
97976 +#endif
97977 +#ifdef MODVERSIONS
97978 +#include <config/modversions.h>
97979 +#endif /* MODVERSIONS */
97980 +
97981 +#include <linux/kernel.h>
97982 +#include <linux/module.h>
97983 +#include <linux/slab.h>
97984 +#include <linux/fs.h>
97985 +#include <linux/cdev.h>
97986 +#include <linux/device.h>
97987 +#include <linux/irq.h>
97988 +#include <linux/interrupt.h>
97989 +#include <linux/io.h>
97990 +#include <linux/ioport.h>
97991 +#include <linux/of_platform.h>
97992 +#include <asm/uaccess.h>
97993 +#include <asm/errno.h>
97994 +#ifndef CONFIG_FMAN_ARM
97995 +#include <sysdev/fsl_soc.h>
97996 +#include <linux/fsl/svr.h>
97997 +#endif
97998 +
97999 +#if defined(CONFIG_COMPAT)
98000 +#include <linux/compat.h>
98001 +#endif
98002 +
98003 +#include "part_ext.h"
98004 +#include "fm_ioctls.h"
98005 +#include "fm_pcd_ioctls.h"
98006 +#include "fm_port_ioctls.h"
98007 +#include "fm_vsp_ext.h"
98008 +
98009 +#ifndef CONFIG_FMAN_ARM
98010 +#define IS_T1023_T1024 (SVR_SOC_VER(mfspr(SPRN_SVR)) == SVR_T1024 || \
98011 + SVR_SOC_VER(mfspr(SPRN_SVR)) == SVR_T1023)
98012 +#endif
98013 +
98014 +#define __ERR_MODULE__ MODULE_FM
98015 +
98016 +#if defined(CONFIG_COMPAT)
98017 +#include "lnxwrp_ioctls_fm_compat.h"
98018 +#endif
98019 +
98020 +#include "lnxwrp_fm.h"
98021 +
98022 +#define CMP_IOC_DEFINE(def) (IOC_##def != def)
98023 +
98024 +/* fm_pcd_ioctls.h === fm_pcd_ext.h assertions */
98025 +#if CMP_IOC_DEFINE(FM_PCD_MAX_NUM_OF_PRIVATE_HDRS)
98026 +#error Error: please synchronize IOC_ defines!
98027 +#endif
98028 +
98029 +#if CMP_IOC_DEFINE(FM_PCD_PRS_NUM_OF_HDRS)
98030 +#error Error: please synchronize IOC_ defines!
98031 +#endif
98032 +
98033 +#if CMP_IOC_DEFINE(FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
98034 +#error Error: please synchronize IOC_ defines!
98035 +#endif
98036 +
98037 +#if CMP_IOC_DEFINE(FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS)
98038 +#error Error: please synchronize IOC_ defines!
98039 +#endif
98040 +
98041 +#if CMP_IOC_DEFINE(FM_PCD_KG_NUM_OF_GENERIC_REGS)
98042 +#error Error: please synchronize IOC_ defines!
98043 +#endif
98044 +
98045 +#if CMP_IOC_DEFINE(FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY)
98046 +#error Error: please synchronize IOC_ defines!
98047 +#endif
98048 +
98049 +#if CMP_IOC_DEFINE(FM_PCD_KG_NUM_OF_EXTRACT_MASKS)
98050 +#error Error: please synchronize IOC_ defines!
98051 +#endif
98052 +
98053 +#if CMP_IOC_DEFINE(FM_PCD_KG_NUM_OF_DEFAULT_GROUPS)
98054 +#error Error: please synchronize IOC_ defines!
98055 +#endif
98056 +
98057 +#if CMP_IOC_DEFINE(FM_PCD_PRS_NUM_OF_LABELS)
98058 +#error Error: please synchronize IOC_ defines!
98059 +#endif
98060 +
98061 +#if CMP_IOC_DEFINE(FM_PCD_SW_PRS_SIZE)
98062 +#error Error: please synchronize IOC_ defines!
98063 +#endif
98064 +
98065 +#if CMP_IOC_DEFINE(FM_PCD_MAX_MANIP_INSRT_TEMPLATE_SIZE)
98066 +#error Error: please synchronize IOC_ defines!
98067 +#endif
98068 +
98069 +#if DPAA_VERSION >= 11
98070 +#if CMP_IOC_DEFINE(FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES)
98071 +#error Error: please synchronize IOC_ defines!
98072 +#endif
98073 +#endif
98074 +
98075 +#if CMP_IOC_DEFINE(FM_PCD_MAX_NUM_OF_CC_TREES)
98076 +#error Error: please synchronize IOC_ defines!
98077 +#endif
98078 +
98079 +#if CMP_IOC_DEFINE(FM_PCD_MAX_NUM_OF_CC_GROUPS)
98080 +#error Error: please synchronize IOC_ defines!
98081 +#endif
98082 +
98083 +#if CMP_IOC_DEFINE(FM_PCD_MAX_NUM_OF_CC_UNITS)
98084 +#error Error: please synchronize IOC_ defines!
98085 +#endif
98086 +
98087 +#if CMP_IOC_DEFINE(FM_PCD_MAX_NUM_OF_KEYS)
98088 +#error Error: please synchronize IOC_ defines!
98089 +#endif
98090 +
98091 +#if CMP_IOC_DEFINE(FM_PCD_MAX_SIZE_OF_KEY)
98092 +#error Error: please synchronize IOC_ defines!
98093 +#endif
98094 +
98095 +#if CMP_IOC_DEFINE(FM_PCD_MAX_NUM_OF_CC_ENTRIES_IN_GRP)
98096 +#error Error: please synchronize IOC_ defines!
98097 +#endif
98098 +
98099 +#if CMP_IOC_DEFINE(FM_PCD_LAST_KEY_INDEX)
98100 +#error Error: please synchronize IOC_ defines!
98101 +#endif
98102 +
98103 +/* net_ioctls.h === net_ext.h assertions */
98104 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_PPP_PID)
98105 +#error Error: please synchronize IOC_ defines!
98106 +#endif
98107 +
98108 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_PPP_COMPRESSED)
98109 +#error Error: please synchronize IOC_ defines!
98110 +#endif
98111 +
98112 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_PPP_ALL_FIELDS)
98113 +#error Error: please synchronize IOC_ defines!
98114 +#endif
98115 +
98116 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_PPPoE_ALL_FIELDS)
98117 +#error Error: please synchronize IOC_ defines!
98118 +#endif
98119 +
98120 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_PPPMUX_ALL_FIELDS)
98121 +#error Error: please synchronize IOC_ defines!
98122 +#endif
98123 +
98124 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_PPPMUX_SUBFRAME_ALL_FIELDS)
98125 +#error Error: please synchronize IOC_ defines!
98126 +#endif
98127 +
98128 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_ETH_ALL_FIELDS)
98129 +#error Error: please synchronize IOC_ defines!
98130 +#endif
98131 +
98132 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_IPv4_ALL_FIELDS)
98133 +#error Error: please synchronize IOC_ defines!
98134 +#endif
98135 +
98136 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_IPv6_ALL_FIELDS)
98137 +#error Error: please synchronize IOC_ defines!
98138 +#endif
98139 +
98140 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_ICMP_ALL_FIELDS)
98141 +#error Error: please synchronize IOC_ defines!
98142 +#endif
98143 +
98144 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_IGMP_ALL_FIELDS)
98145 +#error Error: please synchronize IOC_ defines!
98146 +#endif
98147 +
98148 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_TCP_ALL_FIELDS)
98149 +#error Error: please synchronize IOC_ defines!
98150 +#endif
98151 +
98152 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_SCTP_ALL_FIELDS)
98153 +#error Error: please synchronize IOC_ defines!
98154 +#endif
98155 +
98156 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_DCCP_ALL_FIELDS)
98157 +#error Error: please synchronize IOC_ defines!
98158 +#endif
98159 +
98160 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_UDP_ALL_FIELDS)
98161 +#error Error: please synchronize IOC_ defines!
98162 +#endif
98163 +
98164 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_UDP_ENCAP_ESP_ALL_FIELDS)
98165 +#error Error: please synchronize IOC_ defines!
98166 +#endif
98167 +
98168 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_IPHC_ALL_FIELDS)
98169 +#error Error: please synchronize IOC_ defines!
98170 +#endif
98171 +
98172 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_SCTP_CHUNK_DATA_ALL_FIELDS)
98173 +#error Error: please synchronize IOC_ defines!
98174 +#endif
98175 +
98176 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_L2TPv2_ALL_FIELDS)
98177 +#error Error: please synchronize IOC_ defines!
98178 +#endif
98179 +
98180 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_L2TPv3_CTRL_ALL_FIELDS)
98181 +#error Error: please synchronize IOC_ defines!
98182 +#endif
98183 +
98184 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_L2TPv3_SESS_ALL_FIELDS)
98185 +#error Error: please synchronize IOC_ defines!
98186 +#endif
98187 +
98188 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_VLAN_ALL_FIELDS)
98189 +#error Error: please synchronize IOC_ defines!
98190 +#endif
98191 +
98192 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_LLC_ALL_FIELDS)
98193 +#error Error: please synchronize IOC_ defines!
98194 +#endif
98195 +
98196 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_NLPID_ALL_FIELDS)
98197 +#error Error: please synchronize IOC_ defines!
98198 +#endif
98199 +
98200 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_SNAP_ALL_FIELDS)
98201 +#error Error: please synchronize IOC_ defines!
98202 +#endif
98203 +
98204 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_LLC_SNAP_ALL_FIELDS)
98205 +#warning Error: please synchronize IOC_ defines!
98206 +#endif
98207 +
98208 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_ARP_ALL_FIELDS)
98209 +#error Error: please synchronize IOC_ defines!
98210 +#endif
98211 +
98212 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_RFC2684_ALL_FIELDS)
98213 +#error Error: please synchronize IOC_ defines!
98214 +#endif
98215 +
98216 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_USER_DEFINED_ALL_FIELDS)
98217 +#error Error: please synchronize IOC_ defines!
98218 +#endif
98219 +
98220 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_PAYLOAD_ALL_FIELDS)
98221 +#error Error: please synchronize IOC_ defines!
98222 +#endif
98223 +
98224 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_GRE_ALL_FIELDS)
98225 +#error Error: please synchronize IOC_ defines!
98226 +#endif
98227 +
98228 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_MINENCAP_ALL_FIELDS)
98229 +#error Error: please synchronize IOC_ defines!
98230 +#endif
98231 +
98232 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_IPSEC_AH_ALL_FIELDS)
98233 +#error Error: please synchronize IOC_ defines!
98234 +#endif
98235 +
98236 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_IPSEC_ESP_ALL_FIELDS)
98237 +#error Error: please synchronize IOC_ defines!
98238 +#endif
98239 +
98240 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_MPLS_LABEL_STACK_ALL_FIELDS)
98241 +#error Error: please synchronize IOC_ defines!
98242 +#endif
98243 +
98244 +#if CMP_IOC_DEFINE(NET_HEADER_FIELD_MACSEC_ALL_FIELDS)
98245 +#error Error: please synchronize IOC_ defines!
98246 +#endif
98247 +
98248 +/* fm_ioctls.h === fm_ext.h assertions */
98249 +#if CMP_IOC_DEFINE(FM_MAX_NUM_OF_VALID_PORTS)
98250 +#error Error: please synchronize IOC_ defines!
98251 +#endif
98252 +
98253 +void LnxWrpPCDIOCTLTypeChecking(void)
98254 +{
98255 + /* fm_ext.h == fm_ioctls.h */
98256 + ASSERT_COND(sizeof(ioc_fm_port_bandwidth_params) == sizeof(t_FmPortsBandwidthParams));
98257 + ASSERT_COND(sizeof(ioc_fm_revision_info_t) == sizeof(t_FmRevisionInfo));
98258 +
98259 + /* fm_pcd_ext.h == fm_pcd_ioctls.h */
98260 + /*ioc_fm_pcd_counters_params_t : NOT USED */
98261 + /*ioc_fm_pcd_exception_params_t : private */
98262 +#if (DPAA_VERSION >= 11)
98263 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_frag_capwap_params_t) == sizeof(t_FmPcdManipFragCapwapParams));
98264 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_reassem_capwap_params_t) == sizeof(t_FmPcdManipReassemCapwapParams));
98265 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_hdr_insrt_by_hdr_params_t) == sizeof(t_FmPcdManipHdrInsrtByHdrParams));
98266 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_hdr_insrt_ip_params_t) == sizeof(t_FmPcdManipHdrInsrtIpParams));
98267 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_hdr_insrt_t) == sizeof(t_FmPcdManipHdrInsrt));
98268 + ASSERT_COND(sizeof(ioc_fm_manip_hdr_info_t) == sizeof(t_FmManipHdrInfo));
98269 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_hdr_rmv_by_hdr_params_t) == sizeof(t_FmPcdManipHdrRmvByHdrParams));
98270 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_special_offload_capwap_params_t) == sizeof(t_FmPcdManipSpecialOffloadCapwapParams));
98271 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_frag_capwap_stats_t) == sizeof(t_FmPcdManipFragCapwapStats));
98272 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_reassem_capwap_stats_t) == sizeof(t_FmPcdManipReassemCapwapStats));
98273 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_frag_params_t) == sizeof(t_FmPcdManipFragParams));
98274 +#endif /* (DPAA_VERSION >= 11) */
98275 +
98276 + ASSERT_COND(sizeof(ioc_fm_pcd_prs_label_params_t) == sizeof(t_FmPcdPrsLabelParams));
98277 + ASSERT_COND(sizeof(ioc_fm_pcd_prs_sw_params_t) == sizeof(t_FmPcdPrsSwParams));
98278 + /*ioc_fm_pcd_kg_dflt_value_params_t : private */
98279 + ASSERT_COND(sizeof(ioc_fm_pcd_hdr_protocol_opt_u) == sizeof(u_FmPcdHdrProtocolOpt));
98280 + ASSERT_COND(sizeof(ioc_fm_pcd_fields_u) == sizeof(t_FmPcdFields));
98281 + ASSERT_COND(sizeof(ioc_fm_pcd_from_hdr_t) == sizeof(t_FmPcdFromHdr));
98282 + ASSERT_COND(sizeof(ioc_fm_pcd_from_field_t) == sizeof(t_FmPcdFromField));
98283 + ASSERT_COND(sizeof(ioc_fm_pcd_distinction_unit_t) == sizeof(t_FmPcdDistinctionUnit));
98284 +
98285 +#if defined(CONFIG_ARM64)
98286 + /* different alignment */
98287 + ASSERT_COND(sizeof(ioc_fm_pcd_net_env_params_t) == sizeof(t_FmPcdNetEnvParams) + sizeof(void *) + 4);
98288 +#else
98289 +#if !defined(CONFIG_COMPAT)
98290 + /* different alignment */
98291 + ASSERT_COND(sizeof(ioc_fm_pcd_net_env_params_t) == sizeof(t_FmPcdNetEnvParams) + sizeof(void *));
98292 +#endif
98293 +#endif
98294 + ASSERT_COND(sizeof(ioc_fm_pcd_extract_entry_t) == sizeof(t_FmPcdExtractEntry));
98295 + ASSERT_COND(sizeof(ioc_fm_pcd_kg_extract_mask_t) == sizeof(t_FmPcdKgExtractMask));
98296 + ASSERT_COND(sizeof(ioc_fm_pcd_kg_extract_dflt_t) == sizeof(t_FmPcdKgExtractDflt));
98297 + ASSERT_COND(sizeof(ioc_fm_pcd_kg_key_extract_and_hash_params_t) == sizeof(t_FmPcdKgKeyExtractAndHashParams));
98298 + ASSERT_COND(sizeof(ioc_fm_pcd_kg_extracted_or_params_t) == sizeof(t_FmPcdKgExtractedOrParams));
98299 + ASSERT_COND(sizeof(ioc_fm_pcd_kg_scheme_counter_t) == sizeof(t_FmPcdKgSchemeCounter));
98300 + ASSERT_COND(sizeof(ioc_fm_pcd_kg_plcr_profile_t) == sizeof(t_FmPcdKgPlcrProfile));
98301 +#if (DPAA_VERSION >= 11)
98302 + ASSERT_COND(sizeof(ioc_fm_pcd_kg_storage_profile_t) == sizeof(t_FmPcdKgStorageProfile));
98303 +#endif
98304 + ASSERT_COND(sizeof(ioc_fm_pcd_kg_cc_t) == sizeof(t_FmPcdKgCc));
98305 +#if !defined(CONFIG_COMPAT)
98306 + /* different alignment */
98307 + ASSERT_COND(sizeof(ioc_fm_pcd_kg_scheme_params_t) == sizeof(t_FmPcdKgSchemeParams) + sizeof(void *));
98308 +#endif
98309 + ASSERT_COND(sizeof(ioc_fm_pcd_cc_next_cc_params_t) == sizeof(t_FmPcdCcNextCcParams));
98310 + ASSERT_COND(sizeof(ioc_fm_pcd_cc_next_plcr_params_t) == sizeof(t_FmPcdCcNextPlcrParams));
98311 + ASSERT_COND(sizeof(ioc_fm_pcd_cc_next_enqueue_params_t) == sizeof(t_FmPcdCcNextEnqueueParams));
98312 + ASSERT_COND(sizeof(ioc_fm_pcd_cc_next_kg_params_t) == sizeof(t_FmPcdCcNextKgParams));
98313 + ASSERT_COND(sizeof(ioc_fm_pcd_cc_next_engine_params_t) == sizeof(t_FmPcdCcNextEngineParams));
98314 + ASSERT_COND(sizeof(ioc_fm_pcd_cc_key_params_t) == sizeof(t_FmPcdCcKeyParams));
98315 + ASSERT_COND(sizeof(ioc_keys_params_t) == sizeof(t_KeysParams));
98316 +#if !defined(CONFIG_COMPAT)
98317 + /* different alignment */
98318 + ASSERT_COND(sizeof(ioc_fm_pcd_cc_node_params_t) == sizeof(t_FmPcdCcNodeParams) + sizeof(void *));
98319 + ASSERT_COND(sizeof(ioc_fm_pcd_hash_table_params_t) == sizeof(t_FmPcdHashTableParams) + sizeof(void *));
98320 +#endif
98321 + ASSERT_COND(sizeof(ioc_fm_pcd_cc_grp_params_t) == sizeof(t_FmPcdCcGrpParams));
98322 +#if !defined(CONFIG_COMPAT)
98323 + /* different alignment */
98324 + ASSERT_COND(sizeof(ioc_fm_pcd_cc_tree_params_t) == sizeof(t_FmPcdCcTreeParams) + sizeof(void *));
98325 +#endif
98326 + ASSERT_COND(sizeof(ioc_fm_pcd_plcr_byte_rate_mode_param_t) == sizeof(t_FmPcdPlcrByteRateModeParams));
98327 + ASSERT_COND(sizeof(ioc_fm_pcd_plcr_non_passthrough_alg_param_t) == sizeof(t_FmPcdPlcrNonPassthroughAlgParams));
98328 + ASSERT_COND(sizeof(ioc_fm_pcd_plcr_next_engine_params_u) == sizeof(u_FmPcdPlcrNextEngineParams));
98329 + /*ioc_fm_pcd_port_params_t : private */
98330 + ASSERT_COND(sizeof(ioc_fm_pcd_plcr_profile_params_t) == sizeof(t_FmPcdPlcrProfileParams) + sizeof(void *));
98331 + /*ioc_fm_pcd_cc_tree_modify_next_engine_params_t : private */
98332 +
98333 +#ifdef FM_CAPWAP_SUPPORT
98334 +#error TODO: unsupported feature
98335 +/*
98336 + ASSERT_COND(sizeof(TODO) == sizeof(t_FmPcdManipHdrInsrtByTemplateParams));
98337 + ASSERT_COND(sizeof(TODO) == sizeof(t_CapwapFragmentationParams));
98338 + ASSERT_COND(sizeof(TODO) == sizeof(t_CapwapReassemblyParams));
98339 +*/
98340 +#endif
98341 +
98342 + /*ioc_fm_pcd_cc_node_modify_next_engine_params_t : private */
98343 + /*ioc_fm_pcd_cc_node_remove_key_params_t : private */
98344 + /*ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t : private */
98345 + /*ioc_fm_pcd_cc_node_modify_key_params_t : private */
98346 + /*ioc_fm_manip_hdr_info_t : private */
98347 + /*ioc_fm_pcd_hash_table_set_t : private */
98348 +
98349 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_frag_ip_params_t) == sizeof(t_FmPcdManipFragIpParams));
98350 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_reassem_ip_params_t) == sizeof(t_FmPcdManipReassemIpParams));
98351 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_special_offload_ipsec_params_t) == sizeof(t_FmPcdManipSpecialOffloadIPSecParams));
98352 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_special_offload_params_t) == sizeof(t_FmPcdManipSpecialOffloadParams));
98353 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_hdr_rmv_generic_params_t) == sizeof(t_FmPcdManipHdrRmvGenericParams));
98354 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_hdr_insrt_generic_params_t) == sizeof(t_FmPcdManipHdrInsrtGenericParams));
98355 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_hdr_insrt_params_t) == sizeof(t_FmPcdManipHdrInsrtParams));
98356 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_hdr_rmv_params_t) == sizeof(t_FmPcdManipHdrRmvParams));
98357 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_hdr_params_t) == sizeof(t_FmPcdManipHdrParams));
98358 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_frag_params_t) == sizeof(t_FmPcdManipFragParams));
98359 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_reassem_params_t) == sizeof(t_FmPcdManipReassemParams));
98360 +#if !defined(CONFIG_COMPAT)
98361 + /* different alignment */
98362 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_params_t) == sizeof(t_FmPcdManipParams) + sizeof(void *));
98363 +#endif
98364 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_reassem_ip_stats_t) == sizeof(t_FmPcdManipReassemIpStats));
98365 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_frag_ip_stats_t) == sizeof(t_FmPcdManipFragIpStats));
98366 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_reassem_stats_t) == sizeof(t_FmPcdManipReassemStats));
98367 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_frag_stats_t) == sizeof(t_FmPcdManipFragStats));
98368 + ASSERT_COND(sizeof(ioc_fm_pcd_manip_stats_t) == sizeof(t_FmPcdManipStats));
98369 +#if DPAA_VERSION >= 11
98370 + ASSERT_COND(sizeof(ioc_fm_pcd_frm_replic_group_params_t) == sizeof(t_FmPcdFrmReplicGroupParams) + sizeof(void *));
98371 +#endif
98372 +
98373 + /* fm_port_ext.h == fm_port_ioctls.h */
98374 + ASSERT_COND(sizeof(ioc_fm_port_rate_limit_t) == sizeof(t_FmPortRateLimit));
98375 + ASSERT_COND(sizeof(ioc_fm_port_pcd_params_t) == sizeof(t_FmPortPcdParams));
98376 + ASSERT_COND(sizeof(ioc_fm_pcd_kg_scheme_select_t) == sizeof(t_FmPcdKgSchemeSelect));
98377 + ASSERT_COND(sizeof(ioc_fm_pcd_port_schemes_params_t) == sizeof(t_FmPcdPortSchemesParams));
98378 + ASSERT_COND(sizeof(ioc_fm_pcd_prs_start_t) == sizeof(t_FmPcdPrsStart));
98379 +
98380 + return;
98381 +}
98382 +
98383 +#define ASSERT_IOC_NET_ENUM(def) ASSERT_COND((unsigned long)e_IOC_NET_##def == (unsigned long)def)
98384 +
98385 +void LnxWrpPCDIOCTLEnumChecking(void)
98386 +{
98387 + /* net_ext.h == net_ioctls.h : sampling checks */
98388 + ASSERT_IOC_NET_ENUM(HEADER_TYPE_MACSEC);
98389 + ASSERT_IOC_NET_ENUM(HEADER_TYPE_PPP);
98390 + ASSERT_IOC_NET_ENUM(MAX_HEADER_TYPE_COUNT);
98391 +
98392 + /* fm_ext.h == fm_ioctls.h */
98393 + ASSERT_COND((unsigned long)e_IOC_FM_PORT_TYPE_DUMMY == (unsigned long)e_FM_PORT_TYPE_DUMMY);
98394 + ASSERT_COND((unsigned long)e_IOC_EX_MURAM_ECC == (unsigned long)e_FM_EX_MURAM_ECC);
98395 + ASSERT_COND((unsigned long)e_IOC_FM_COUNTERS_DEQ_CONFIRM == (unsigned long)e_FM_COUNTERS_DEQ_CONFIRM);
98396 +
98397 + /* fm_pcd_ext.h == fm_pcd_ioctls.h */
98398 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES == (unsigned long)e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES);
98399 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_PRS_EXCEPTION_SINGLE_ECC == (unsigned long)e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC);
98400 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_PRS == (unsigned long)e_FM_PCD_PRS);
98401 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_EXTRACT_FULL_FIELD == (unsigned long)e_FM_PCD_EXTRACT_FULL_FIELD);
98402 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_EXTRACT_FROM_FLOW_ID == (unsigned long)e_FM_PCD_EXTRACT_FROM_FLOW_ID);
98403 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_KG_EXTRACT_PORT_PRIVATE_INFO == (unsigned long)e_FM_PCD_KG_EXTRACT_PORT_PRIVATE_INFO);
98404 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_KG_DFLT_ILLEGAL == (unsigned long)e_FM_PCD_KG_DFLT_ILLEGAL);
98405 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_KG_GENERIC_NOT_FROM_DATA == (unsigned long)e_FM_PCD_KG_GENERIC_NOT_FROM_DATA);
98406 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_HDR_INDEX_LAST == (unsigned long)e_FM_PCD_HDR_INDEX_LAST);
98407 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_PLCR_SHARED == (unsigned long)e_FM_PCD_PLCR_SHARED);
98408 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_PLCR_RFC_4115 == (unsigned long)e_FM_PCD_PLCR_RFC_4115);
98409 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_PLCR_COLOR_AWARE == (unsigned long)e_FM_PCD_PLCR_COLOR_AWARE);
98410 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_PLCR_OVERRIDE == (unsigned long)e_FM_PCD_PLCR_OVERRIDE);
98411 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_PLCR_FULL_FRM_LEN == (unsigned long)e_FM_PCD_PLCR_FULL_FRM_LEN);
98412 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_PLCR_ROLLBACK_FULL_FRM_LEN == (unsigned long)e_FM_PCD_PLCR_ROLLBACK_FULL_FRM_LEN);
98413 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_PLCR_PACKET_MODE == (unsigned long)e_FM_PCD_PLCR_PACKET_MODE);
98414 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_DROP_FRAME == (unsigned long)e_FM_PCD_DROP_FRAME);
98415 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_PLCR_PROFILE_RECOLOURED_RED_PACKET_TOTAL_COUNTER == (unsigned long)e_FM_PCD_PLCR_PROFILE_RECOLOURED_RED_PACKET_TOTAL_COUNTER);
98416 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP == (unsigned long)e_FM_PCD_ACTION_INDEXED_LOOKUP);
98417 + ASSERT_COND((unsigned long)e_IOC_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR == (unsigned long)e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR);
98418 +#if !defined(FM_CAPWAP_SUPPORT)
98419 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_MANIP_INSRT_GENERIC == (unsigned long)e_FM_PCD_MANIP_INSRT_GENERIC);
98420 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_MANIP_RMV_GENERIC == (unsigned long)e_FM_PCD_MANIP_RMV_GENERIC);
98421 +#else
98422 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_MANIP_INSRT_BY_TEMPLATE == (unsigned long)e_FM_PCD_MANIP_INSRT_BY_TEMPLATE);
98423 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_MANIP_RMV_BY_HDR == (unsigned long)e_FM_PCD_MANIP_RMV_BY_HDR);
98424 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_MANIP_RMV_BY_HDR_FROM_START == (unsigned long)e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START);
98425 +#endif
98426 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAG == (unsigned long)e_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAG);
98427 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_MANIP_EIGHT_WAYS_HASH == (unsigned long)e_FM_PCD_MANIP_EIGHT_WAYS_HASH);
98428 +
98429 +#ifdef FM_CAPWAP_SUPPORT
98430 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_STATS_PER_FLOWID == (unsigned long)e_FM_PCD_STATS_PER_FLOWID);
98431 +#endif
98432 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_MANIP_SPECIAL_OFFLOAD == (unsigned long)e_FM_PCD_MANIP_SPECIAL_OFFLOAD);
98433 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_CC_STATS_MODE_FRAME == (unsigned long)e_FM_PCD_CC_STATS_MODE_FRAME);
98434 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_MANIP_CONTINUE_WITHOUT_FRAG == (unsigned long)e_FM_PCD_MANIP_CONTINUE_WITHOUT_FRAG);
98435 + ASSERT_COND((unsigned long)e_IOC_FM_PCD_MANIP_SPECIAL_OFFLOAD_IPSEC == (unsigned long)e_FM_PCD_MANIP_SPECIAL_OFFLOAD_IPSEC);
98436 +
98437 + /* fm_port_ext.h == fm_port_ioctls.h */
98438 +#if !defined(FM_CAPWAP_SUPPORT)
98439 + ASSERT_COND((unsigned long)e_IOC_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR == (unsigned long)e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR);
98440 +#else
98441 + ASSERT_COND((unsigned long)e_IOC_FM_PORT_PCD_SUPPORT_CC_AND_KG_AND_PLCR == (unsigned long)e_FM_PORT_PCD_SUPPORT_CC_AND_KG_AND_PLCR);
98442 +#endif
98443 + ASSERT_COND((unsigned long)e_IOC_FM_PORT_COUNTERS_DEQ_CONFIRM == (unsigned long)e_FM_PORT_COUNTERS_DEQ_CONFIRM);
98444 + ASSERT_COND((unsigned long)e_IOC_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_8 == (unsigned long)e_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_8);
98445 +
98446 + return;
98447 +}
98448 +
98449 +static t_Error LnxwrpFmPcdIOCTL(t_LnxWrpFmDev *p_LnxWrpFmDev, unsigned int cmd, unsigned long arg, bool compat)
98450 +{
98451 + t_Error err = E_OK;
98452 +
98453 +/*
98454 +Status: PCD API to fmlib (file: drivers/net/dpa/NetCommSw/inc/Peripherals/fm_pcd_ext.h):
98455 +
98456 + FM_PCD_PrsLoadSw
98457 + FM_PCD_SetAdvancedOffloadSupport
98458 + FM_PCD_Enable
98459 + FM_PCD_Disable
98460 + FM_PCD_ForceIntr
98461 + FM_PCD_SetException
98462 + FM_PCD_KgSetAdditionalDataAfterParsing
98463 + FM_PCD_KgSetDfltValue
98464 + FM_PCD_NetEnvCharacteristicsSet
98465 + FM_PCD_NetEnvCharacteristicsDelete
98466 + FM_PCD_KgSchemeSet
98467 + FM_PCD_KgSchemeDelete
98468 + FM_PCD_MatchTableSet
98469 + FM_PCD_MatchTableDelete
98470 + FM_PCD_CcRootBuild
98471 + FM_PCD_CcRootDelete
98472 + FM_PCD_PlcrProfileSet
98473 + FM_PCD_PlcrProfileDelete
98474 + FM_PCD_CcRootModifyNextEngine
98475 + FM_PCD_MatchTableModifyNextEngine
98476 + FM_PCD_MatchTableModifyMissNextEngine
98477 + FM_PCD_MatchTableRemoveKey
98478 + FM_PCD_MatchTableAddKey
98479 + FM_PCD_MatchTableModifyKeyAndNextEngine
98480 + FM_PCD_HashTableSet
98481 + FM_PCD_HashTableDelete
98482 + FM_PCD_HashTableAddKey
98483 + FM_PCD_HashTableRemoveKey
98484 + FM_PCD_MatchTableModifyKey
98485 + FM_PCD_ManipNodeReplace
98486 + FM_PCD_ManipNodeSet
98487 + FM_PCD_ManipNodeDelete
98488 +
98489 +Status: not exported, should be thru sysfs
98490 + FM_PCD_KgSchemeGetCounter
98491 + FM_PCD_KgSchemeSetCounter
98492 + FM_PCD_PlcrProfileGetCounter
98493 + FM_PCD_PlcrProfileSetCounter
98494 +
98495 +Status: not exported
98496 + FM_PCD_MatchTableFindNRemoveKey
98497 + FM_PCD_MatchTableFindNModifyNextEngine
98498 + FM_PCD_MatchTableFindNModifyKeyAndNextEngine
98499 + FM_PCD_MatchTableFindNModifyKey
98500 + FM_PCD_MatchTableGetIndexedHashBucket
98501 + FM_PCD_MatchTableGetNextEngine
98502 + FM_PCD_MatchTableGetKeyCounter
98503 +
98504 +Status: not exported, would be nice to have
98505 + FM_PCD_HashTableModifyNextEngine
98506 + FM_PCD_HashTableModifyMissNextEngine
98507 + FM_PCD_HashTableGetMissNextEngine
98508 + FM_PCD_ManipGetStatistics
98509 +
98510 +Status: not exported
98511 +#if DPAA_VERSION >= 11
98512 +
98513 + FM_VSP_GetStatistics -- it's not available yet
98514 +#endif
98515 +
98516 +Status: feature not supported
98517 +#ifdef FM_CAPWAP_SUPPORT
98518 +#error unsupported feature
98519 + FM_PCD_StatisticsSetNode
98520 +#endif
98521 +
98522 + */
98523 + _fm_ioctl_dbg("cmd:0x%08x(type:0x%02x, nr:%u).\n",
98524 + cmd, _IOC_TYPE(cmd), _IOC_NR(cmd) - 20);
98525 +
98526 + switch (cmd)
98527 + {
98528 +#if defined(CONFIG_COMPAT)
98529 + case FM_PCD_IOC_PRS_LOAD_SW_COMPAT:
98530 +#endif
98531 + case FM_PCD_IOC_PRS_LOAD_SW:
98532 + {
98533 + ioc_fm_pcd_prs_sw_params_t *param;
98534 + uint8_t *p_code;
98535 +
98536 + param = (ioc_fm_pcd_prs_sw_params_t *) XX_Malloc(sizeof(ioc_fm_pcd_prs_sw_params_t));
98537 + if (!param)
98538 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
98539 +
98540 + memset(param, 0, sizeof(ioc_fm_pcd_prs_sw_params_t));
98541 +
98542 +#if defined(CONFIG_COMPAT)
98543 + if (compat)
98544 + {
98545 + ioc_compat_fm_pcd_prs_sw_params_t *compat_param;
98546 +
98547 + compat_param = (ioc_compat_fm_pcd_prs_sw_params_t *) XX_Malloc(
98548 + sizeof(ioc_compat_fm_pcd_prs_sw_params_t));
98549 + if (!compat_param)
98550 + {
98551 + XX_Free(param);
98552 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
98553 + }
98554 +
98555 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_prs_sw_params_t));
98556 + if (copy_from_user(compat_param,
98557 + (ioc_compat_fm_pcd_prs_sw_params_t *) compat_ptr(arg),
98558 + sizeof(ioc_compat_fm_pcd_prs_sw_params_t)))
98559 + {
98560 + XX_Free(compat_param);
98561 + XX_Free(param);
98562 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98563 + }
98564 +
98565 + compat_fm_pcd_prs_sw(compat_param, param, COMPAT_US_TO_K);
98566 +
98567 + XX_Free(compat_param);
98568 + }
98569 + else
98570 +#endif
98571 + {
98572 + if (copy_from_user(param, (ioc_fm_pcd_prs_sw_params_t *)arg,
98573 + sizeof(ioc_fm_pcd_prs_sw_params_t)))
98574 + {
98575 + XX_Free(param);
98576 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98577 + }
98578 + }
98579 +
98580 + if (!param->p_code || !param->size)
98581 + {
98582 + XX_Free(param);
98583 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98584 + }
98585 +
98586 + p_code = (uint8_t *) XX_Malloc(param->size);
98587 + if (!p_code)
98588 + {
98589 + XX_Free(param);
98590 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
98591 + }
98592 +
98593 + memset(p_code, 0, param->size);
98594 + if (copy_from_user(p_code, param->p_code, param->size))
98595 + {
98596 + XX_Free(p_code);
98597 + XX_Free(param);
98598 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98599 + }
98600 +
98601 + param->p_code = p_code;
98602 +
98603 + err = FM_PCD_PrsLoadSw(p_LnxWrpFmDev->h_PcdDev, (t_FmPcdPrsSwParams*)param);
98604 +
98605 + XX_Free(p_code);
98606 + XX_Free(param);
98607 + break;
98608 + }
98609 +
98610 + case FM_PCD_IOC_SET_ADVANCED_OFFLOAD_SUPPORT:
98611 + err = FM_PCD_SetAdvancedOffloadSupport(p_LnxWrpFmDev->h_PcdDev);
98612 + break;
98613 +
98614 + case FM_PCD_IOC_ENABLE:
98615 + err = FM_PCD_Enable(p_LnxWrpFmDev->h_PcdDev);
98616 + break;
98617 +
98618 + case FM_PCD_IOC_DISABLE:
98619 + err = FM_PCD_Disable(p_LnxWrpFmDev->h_PcdDev);
98620 + break;
98621 +
98622 + case FM_PCD_IOC_FORCE_INTR:
98623 + {
98624 + int exception;
98625 +
98626 +#if defined(CONFIG_COMPAT)
98627 + if (compat)
98628 + {
98629 + if (get_user(exception, (int *) compat_ptr(arg)))
98630 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98631 + }
98632 + else
98633 +#endif
98634 + {
98635 + if (get_user(exception, (int *)arg))
98636 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98637 + }
98638 +
98639 + err = FM_PCD_ForceIntr(p_LnxWrpFmDev->h_PcdDev, (e_FmPcdExceptions)exception);
98640 + break;
98641 + }
98642 +
98643 + case FM_PCD_IOC_SET_EXCEPTION:
98644 + {
98645 + ioc_fm_pcd_exception_params_t *param;
98646 +
98647 + param = (ioc_fm_pcd_exception_params_t *) XX_Malloc(
98648 + sizeof(ioc_fm_pcd_exception_params_t));
98649 + if (!param)
98650 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
98651 +
98652 + memset(param, 0, sizeof(ioc_fm_pcd_exception_params_t));
98653 +
98654 +#if defined(CONFIG_COMPAT)
98655 + if (compat)
98656 + {
98657 + if (copy_from_user(param, (ioc_fm_pcd_exception_params_t *)compat_ptr(arg),
98658 + sizeof(ioc_fm_pcd_exception_params_t)))
98659 + {
98660 + XX_Free(param);
98661 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98662 + }
98663 + }
98664 + else
98665 +#endif
98666 + {
98667 + if (copy_from_user(param, (ioc_fm_pcd_exception_params_t *)arg,
98668 + sizeof(ioc_fm_pcd_exception_params_t)))
98669 + {
98670 + XX_Free(param);
98671 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98672 + }
98673 + }
98674 +
98675 + err = FM_PCD_SetException(p_LnxWrpFmDev->h_PcdDev, param->exception, param->enable);
98676 +
98677 + XX_Free(param);
98678 + break;
98679 + }
98680 +
98681 + case FM_PCD_IOC_KG_SET_ADDITIONAL_DATA_AFTER_PARSING:
98682 + {
98683 + uint8_t payloadOffset;
98684 +
98685 +#if defined(CONFIG_COMPAT)
98686 + if (compat)
98687 + {
98688 + if (get_user(payloadOffset, (uint8_t*) compat_ptr(arg)))
98689 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98690 + }
98691 + else
98692 +#endif
98693 + {
98694 + if (get_user(payloadOffset, (uint8_t*) arg))
98695 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98696 + }
98697 +
98698 + err = FM_PCD_KgSetAdditionalDataAfterParsing(p_LnxWrpFmDev->h_PcdDev, payloadOffset);
98699 + break;
98700 + }
98701 +
98702 + case FM_PCD_IOC_KG_SET_DFLT_VALUE:
98703 + {
98704 + ioc_fm_pcd_kg_dflt_value_params_t *param;
98705 +
98706 + param = (ioc_fm_pcd_kg_dflt_value_params_t *) XX_Malloc(
98707 + sizeof(ioc_fm_pcd_kg_dflt_value_params_t));
98708 + if (!param)
98709 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
98710 +
98711 + memset(param, 0, sizeof(ioc_fm_pcd_kg_dflt_value_params_t));
98712 +
98713 +#if defined(CONFIG_COMPAT)
98714 + if (compat)
98715 + {
98716 + if (copy_from_user(param, (ioc_fm_pcd_kg_dflt_value_params_t *)compat_ptr(arg),
98717 + sizeof(ioc_fm_pcd_kg_dflt_value_params_t)))
98718 + {
98719 + XX_Free(param);
98720 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98721 + }
98722 + }
98723 + else
98724 +#endif
98725 + {
98726 + if (copy_from_user(param, (ioc_fm_pcd_kg_dflt_value_params_t *)arg,
98727 + sizeof(ioc_fm_pcd_kg_dflt_value_params_t)))
98728 + {
98729 + XX_Free(param);
98730 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98731 + }
98732 + }
98733 +
98734 + err = FM_PCD_KgSetDfltValue(p_LnxWrpFmDev->h_PcdDev, param->valueId, param->value);
98735 +
98736 + XX_Free(param);
98737 + break;
98738 + }
98739 +
98740 +#if defined(CONFIG_COMPAT)
98741 + case FM_PCD_IOC_NET_ENV_CHARACTERISTICS_SET_COMPAT:
98742 +#endif
98743 + case FM_PCD_IOC_NET_ENV_CHARACTERISTICS_SET:
98744 + {
98745 + ioc_fm_pcd_net_env_params_t *param;
98746 +
98747 + param = (ioc_fm_pcd_net_env_params_t *) XX_Malloc(sizeof(ioc_fm_pcd_net_env_params_t));
98748 + if (!param)
98749 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
98750 +
98751 + memset(param, 0, sizeof(ioc_fm_pcd_net_env_params_t));
98752 +
98753 +#if defined(CONFIG_COMPAT)
98754 + if (compat)
98755 + {
98756 + ioc_compat_fm_pcd_net_env_params_t *compat_param;
98757 +
98758 + compat_param = (ioc_compat_fm_pcd_net_env_params_t *) XX_Malloc(
98759 + sizeof(ioc_compat_fm_pcd_net_env_params_t));
98760 + if (!compat_param)
98761 + {
98762 + XX_Free(param);
98763 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
98764 + }
98765 +
98766 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_net_env_params_t));
98767 + if (copy_from_user(compat_param, (ioc_compat_fm_pcd_net_env_params_t *) compat_ptr(arg),
98768 + sizeof(ioc_compat_fm_pcd_net_env_params_t)))
98769 + {
98770 + XX_Free(compat_param);
98771 + XX_Free(param);
98772 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98773 + }
98774 +
98775 + compat_copy_fm_pcd_net_env(compat_param, param, COMPAT_US_TO_K);
98776 + XX_Free(compat_param);
98777 + }
98778 + else
98779 +#endif
98780 + {
98781 + if (copy_from_user(param, (ioc_fm_pcd_net_env_params_t *) arg,
98782 + sizeof(ioc_fm_pcd_net_env_params_t)))
98783 + {
98784 + XX_Free(param);
98785 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98786 + }
98787 + }
98788 +
98789 + param->id = FM_PCD_NetEnvCharacteristicsSet(p_LnxWrpFmDev->h_PcdDev, (t_FmPcdNetEnvParams*)param);
98790 +
98791 + if (!param->id)
98792 + {
98793 + XX_Free(param);
98794 + err = E_INVALID_VALUE;
98795 + /* Since the LLD has no errno-style error reporting,
98796 + we're left here with no other option than to report
98797 + a generic E_INVALID_VALUE */
98798 + break;
98799 + }
98800 +
98801 +#if defined(CONFIG_COMPAT)
98802 + if (compat)
98803 + {
98804 + ioc_compat_fm_pcd_net_env_params_t *compat_param;
98805 +
98806 + compat_param = (ioc_compat_fm_pcd_net_env_params_t *) XX_Malloc(
98807 + sizeof(ioc_compat_fm_pcd_net_env_params_t));
98808 + if (!compat_param)
98809 + {
98810 + XX_Free(param);
98811 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
98812 + }
98813 +
98814 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_net_env_params_t));
98815 + compat_copy_fm_pcd_net_env(compat_param, param, COMPAT_K_TO_US);
98816 +
98817 + if (copy_to_user((ioc_compat_fm_pcd_net_env_params_t *) compat_ptr(arg),
98818 + compat_param,
98819 + sizeof(ioc_compat_fm_pcd_net_env_params_t)))
98820 + err = E_READ_FAILED;
98821 +
98822 + XX_Free(compat_param);
98823 + }
98824 + else
98825 +#endif
98826 + {
98827 + if (copy_to_user((ioc_fm_pcd_net_env_params_t *)arg,
98828 + param,
98829 + sizeof(ioc_fm_pcd_net_env_params_t)))
98830 + err = E_READ_FAILED;
98831 + }
98832 +
98833 + XX_Free(param);
98834 + break;
98835 + }
98836 +
98837 +#if defined(CONFIG_COMPAT)
98838 + case FM_PCD_IOC_NET_ENV_CHARACTERISTICS_DELETE_COMPAT:
98839 +#endif
98840 + case FM_PCD_IOC_NET_ENV_CHARACTERISTICS_DELETE:
98841 + {
98842 + ioc_fm_obj_t id;
98843 +
98844 + memset(&id, 0 , sizeof(ioc_fm_obj_t));
98845 +
98846 +#if defined(CONFIG_COMPAT)
98847 + if (compat)
98848 + {
98849 + ioc_compat_fm_obj_t compat_id;
98850 +
98851 + if (copy_from_user(&compat_id, (ioc_compat_fm_obj_t *) compat_ptr(arg), sizeof(ioc_compat_fm_obj_t)))
98852 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98853 +
98854 + compat_obj_delete(&compat_id, &id);
98855 + }
98856 + else
98857 +#endif
98858 + {
98859 + if (copy_from_user(&id, (ioc_fm_obj_t *) arg, sizeof(ioc_fm_obj_t)))
98860 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98861 + }
98862 +
98863 + err = FM_PCD_NetEnvCharacteristicsDelete(id.obj);
98864 + break;
98865 + }
98866 +
98867 +#if defined(CONFIG_COMPAT)
98868 + case FM_PCD_IOC_KG_SCHEME_SET_COMPAT:
98869 +#endif
98870 + case FM_PCD_IOC_KG_SCHEME_SET:
98871 + {
98872 + ioc_fm_pcd_kg_scheme_params_t *param;
98873 +
98874 + param = (ioc_fm_pcd_kg_scheme_params_t *) XX_Malloc(sizeof(ioc_fm_pcd_kg_scheme_params_t));
98875 + if (!param)
98876 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
98877 +
98878 + memset(param, 0, sizeof(ioc_fm_pcd_kg_scheme_params_t));
98879 +
98880 +#if defined(CONFIG_COMPAT)
98881 + if (compat)
98882 + {
98883 + ioc_compat_fm_pcd_kg_scheme_params_t *compat_param = NULL;
98884 +
98885 + compat_param = (ioc_compat_fm_pcd_kg_scheme_params_t *) XX_Malloc(
98886 + sizeof(ioc_compat_fm_pcd_kg_scheme_params_t));
98887 + if (!compat_param)
98888 + {
98889 + XX_Free(param);
98890 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
98891 + }
98892 +
98893 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_kg_scheme_params_t));
98894 +
98895 + if (copy_from_user(compat_param, (ioc_compat_fm_pcd_kg_scheme_params_t *) compat_ptr(arg),
98896 + sizeof(ioc_compat_fm_pcd_kg_scheme_params_t)))
98897 + {
98898 + XX_Free(compat_param);
98899 + XX_Free(param);
98900 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98901 + }
98902 +
98903 + compat_copy_fm_pcd_kg_scheme(compat_param, param, COMPAT_US_TO_K);
98904 +
98905 + XX_Free(compat_param);
98906 + }
98907 + else
98908 +#endif
98909 + {
98910 + if (copy_from_user(param, (ioc_fm_pcd_kg_scheme_params_t *)arg,
98911 + sizeof(ioc_fm_pcd_kg_scheme_params_t)))
98912 + {
98913 + XX_Free(param);
98914 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98915 + }
98916 + }
98917 +
98918 + param->id = FM_PCD_KgSchemeSet(p_LnxWrpFmDev->h_PcdDev, (t_FmPcdKgSchemeParams*)param);
98919 +
98920 + if (!param->id)
98921 + {
98922 + XX_Free(param);
98923 + err = E_INVALID_VALUE;
98924 + /* Since the LLD has no errno-style error reporting,
98925 + we're left here with no other option than to report
98926 + a generic E_INVALID_VALUE */
98927 + break;
98928 + }
98929 +
98930 +#if defined(CONFIG_COMPAT)
98931 + if (compat)
98932 + {
98933 + ioc_compat_fm_pcd_kg_scheme_params_t *compat_param;
98934 +
98935 + compat_param = (ioc_compat_fm_pcd_kg_scheme_params_t *) XX_Malloc(
98936 + sizeof(ioc_compat_fm_pcd_kg_scheme_params_t));
98937 + if (!compat_param)
98938 + {
98939 + XX_Free(param);
98940 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
98941 + }
98942 +
98943 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_kg_scheme_params_t));
98944 + compat_copy_fm_pcd_kg_scheme(compat_param, param, COMPAT_K_TO_US);
98945 + if (copy_to_user((ioc_compat_fm_pcd_kg_scheme_params_t *)compat_ptr(arg),
98946 + compat_param,
98947 + sizeof(ioc_compat_fm_pcd_kg_scheme_params_t)))
98948 + err = E_READ_FAILED;
98949 +
98950 + XX_Free(compat_param);
98951 + }
98952 + else
98953 +#endif
98954 + {
98955 + if (copy_to_user((ioc_fm_pcd_kg_scheme_params_t *)arg,
98956 + param,
98957 + sizeof(ioc_fm_pcd_kg_scheme_params_t)))
98958 + err = E_READ_FAILED;
98959 + }
98960 +
98961 + XX_Free(param);
98962 + break;
98963 + }
98964 +
98965 +#if defined(CONFIG_COMPAT)
98966 + case FM_PCD_IOC_KG_SCHEME_GET_CNTR_COMPAT:
98967 +#endif
98968 + case FM_PCD_IOC_KG_SCHEME_GET_CNTR:
98969 + {
98970 + ioc_fm_pcd_kg_scheme_spc_t *param;
98971 +
98972 + param = (ioc_fm_pcd_kg_scheme_spc_t *) XX_Malloc(sizeof(ioc_fm_pcd_kg_scheme_spc_t));
98973 + if (!param)
98974 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
98975 +
98976 + memset(param, 0, sizeof(ioc_fm_pcd_kg_scheme_spc_t));
98977 +
98978 +#if defined(CONFIG_COMPAT)
98979 + if (compat)
98980 + {
98981 + ioc_compat_fm_pcd_kg_scheme_spc_t *compat_param = NULL;
98982 +
98983 + compat_param = (ioc_compat_fm_pcd_kg_scheme_spc_t *) XX_Malloc(
98984 + sizeof(ioc_compat_fm_pcd_kg_scheme_spc_t));
98985 + if (!compat_param)
98986 + {
98987 + XX_Free(param);
98988 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
98989 + }
98990 +
98991 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_kg_scheme_spc_t));
98992 +
98993 + if (copy_from_user(compat_param, (ioc_compat_fm_pcd_kg_scheme_spc_t *) compat_ptr(arg),
98994 + sizeof(ioc_compat_fm_pcd_kg_scheme_spc_t)))
98995 + {
98996 + XX_Free(compat_param);
98997 + XX_Free(param);
98998 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
98999 + }
99000 +
99001 + compat_copy_fm_pcd_kg_scheme_spc(compat_param, param, COMPAT_US_TO_K);
99002 +
99003 + XX_Free(compat_param);
99004 + }
99005 + else
99006 +#endif
99007 + {
99008 + if (copy_from_user(param, (ioc_fm_pcd_kg_scheme_spc_t *)arg,
99009 + sizeof(ioc_fm_pcd_kg_scheme_spc_t)))
99010 + {
99011 + XX_Free(param);
99012 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99013 + }
99014 + }
99015 +
99016 + param->val = FM_PCD_KgSchemeGetCounter((t_Handle)param->id);
99017 +
99018 +#if defined(CONFIG_COMPAT)
99019 + if (compat)
99020 + {
99021 + ioc_compat_fm_pcd_kg_scheme_spc_t *compat_param;
99022 +
99023 + compat_param = (ioc_compat_fm_pcd_kg_scheme_spc_t *) XX_Malloc(
99024 + sizeof(ioc_compat_fm_pcd_kg_scheme_spc_t));
99025 + if (!compat_param)
99026 + {
99027 + XX_Free(param);
99028 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99029 + }
99030 +
99031 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_kg_scheme_spc_t));
99032 + compat_copy_fm_pcd_kg_scheme_spc(compat_param, param, COMPAT_K_TO_US);
99033 + if (copy_to_user((ioc_compat_fm_pcd_kg_scheme_spc_t *)compat_ptr(arg),
99034 + compat_param,
99035 + sizeof(ioc_compat_fm_pcd_kg_scheme_spc_t)))
99036 + err = E_READ_FAILED;
99037 +
99038 + XX_Free(compat_param);
99039 + }
99040 + else
99041 +#endif
99042 + {
99043 + if (copy_to_user((ioc_fm_pcd_kg_scheme_spc_t *)arg,
99044 + param,
99045 + sizeof(ioc_fm_pcd_kg_scheme_spc_t)))
99046 + err = E_READ_FAILED;
99047 + }
99048 +
99049 + XX_Free(param);
99050 + break;
99051 + }
99052 +
99053 +#if defined(CONFIG_COMPAT)
99054 + case FM_PCD_IOC_KG_SCHEME_DELETE_COMPAT:
99055 +#endif
99056 + case FM_PCD_IOC_KG_SCHEME_DELETE:
99057 + {
99058 + ioc_fm_obj_t id;
99059 +
99060 + memset(&id, 0 , sizeof(ioc_fm_obj_t));
99061 +
99062 +#if defined(CONFIG_COMPAT)
99063 + if (compat)
99064 + {
99065 + ioc_compat_fm_obj_t compat_id;
99066 +
99067 + if (copy_from_user(&compat_id, (ioc_compat_fm_obj_t *) compat_ptr(arg), sizeof(ioc_compat_fm_obj_t)))
99068 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99069 +
99070 + compat_obj_delete(&compat_id, &id);
99071 + }
99072 + else
99073 +#endif
99074 + {
99075 + if (copy_from_user(&id, (ioc_fm_obj_t *) arg, sizeof(ioc_fm_obj_t)))
99076 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99077 + }
99078 +
99079 + err = FM_PCD_KgSchemeDelete(id.obj);
99080 + break;
99081 + }
99082 +
99083 +#if defined(CONFIG_COMPAT)
99084 + case FM_PCD_IOC_MATCH_TABLE_SET_COMPAT:
99085 +#endif
99086 + case FM_PCD_IOC_MATCH_TABLE_SET:
99087 + {
99088 + ioc_fm_pcd_cc_node_params_t *param;
99089 + uint8_t *keys;
99090 + uint8_t *masks;
99091 + int i,k;
99092 +
99093 + param = (ioc_fm_pcd_cc_node_params_t *) XX_Malloc(
99094 + sizeof(ioc_fm_pcd_cc_node_params_t) +
99095 + 2 * IOC_FM_PCD_MAX_NUM_OF_KEYS * IOC_FM_PCD_MAX_SIZE_OF_KEY);
99096 + if (!param)
99097 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99098 +
99099 + memset(param, 0, sizeof(ioc_fm_pcd_cc_node_params_t) +
99100 + 2 * IOC_FM_PCD_MAX_NUM_OF_KEYS * IOC_FM_PCD_MAX_SIZE_OF_KEY);
99101 +
99102 + keys = (uint8_t *) (param + 1);
99103 + masks = keys + IOC_FM_PCD_MAX_NUM_OF_KEYS * IOC_FM_PCD_MAX_SIZE_OF_KEY;
99104 +
99105 +#if defined(CONFIG_COMPAT)
99106 + if (compat)
99107 + {
99108 + ioc_compat_fm_pcd_cc_node_params_t *compat_param;
99109 +
99110 + compat_param = (ioc_compat_fm_pcd_cc_node_params_t *) XX_Malloc(
99111 + sizeof(ioc_compat_fm_pcd_cc_node_params_t) +
99112 + 2 * IOC_FM_PCD_MAX_NUM_OF_KEYS * IOC_FM_PCD_MAX_SIZE_OF_KEY);
99113 + if (!compat_param)
99114 + {
99115 + XX_Free(param);
99116 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99117 + }
99118 +
99119 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_node_params_t) +
99120 + 2 * IOC_FM_PCD_MAX_NUM_OF_KEYS * IOC_FM_PCD_MAX_SIZE_OF_KEY);
99121 +
99122 + if (copy_from_user(compat_param,
99123 + (ioc_compat_fm_pcd_cc_node_params_t *)compat_ptr(arg),
99124 + sizeof(ioc_compat_fm_pcd_cc_node_params_t)))
99125 + {
99126 + XX_Free(compat_param);
99127 + XX_Free(param);
99128 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99129 + }
99130 +
99131 + compat_copy_fm_pcd_cc_node(compat_param, param, COMPAT_US_TO_K);
99132 +
99133 + XX_Free(compat_param);
99134 + }
99135 + else
99136 +#endif
99137 + {
99138 + if (copy_from_user(param, (ioc_fm_pcd_cc_node_params_t *)arg, sizeof(ioc_fm_pcd_cc_node_params_t)))
99139 + {
99140 + XX_Free(param);
99141 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99142 + }
99143 + }
99144 +
99145 + ASSERT_COND(param->keys_params.num_of_keys <= IOC_FM_PCD_MAX_NUM_OF_KEYS);
99146 + ASSERT_COND(param->keys_params.key_size <= IOC_FM_PCD_MAX_SIZE_OF_KEY);
99147 +
99148 + /* support for indexed lookup */
99149 + if( !(param->extract_cc_params.type == e_IOC_FM_PCD_EXTRACT_NON_HDR &&
99150 + param->extract_cc_params.extract_params.extract_non_hdr.src == e_IOC_FM_PCD_EXTRACT_FROM_HASH &&
99151 + param->extract_cc_params.extract_params.extract_non_hdr.action == e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP))
99152 + {
99153 + for (i=0, k=0;
99154 + i < param->keys_params.num_of_keys;
99155 + i++, k += IOC_FM_PCD_MAX_SIZE_OF_KEY)
99156 + {
99157 + if (param->keys_params.key_params[i].p_key &&
99158 + param->keys_params.key_size)
99159 + {
99160 + if (copy_from_user(&keys[k],
99161 + param->keys_params.key_params[i].p_key,
99162 + param->keys_params.key_size))
99163 + {
99164 + XX_Free(param);
99165 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99166 + }
99167 +
99168 + param->keys_params.key_params[i].p_key = &keys[k];
99169 + }
99170 +
99171 + if (param->keys_params.key_params[i].p_mask)
99172 + {
99173 + if (copy_from_user(&masks[k],
99174 + param->keys_params.key_params[i].p_mask,
99175 + param->keys_params.key_size))
99176 + {
99177 + XX_Free(param);
99178 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99179 + }
99180 +
99181 + param->keys_params.key_params[i].p_mask = &masks[k];
99182 + }
99183 + }
99184 + }
99185 +
99186 + param->id = FM_PCD_MatchTableSet(p_LnxWrpFmDev->h_PcdDev, (t_FmPcdCcNodeParams*)param);
99187 +
99188 + if (!param->id) {
99189 + XX_Free(param);
99190 + err = E_INVALID_VALUE;
99191 + /* Since the LLD has no errno-style error reporting,
99192 + we're left here with no other option than to report
99193 + a generic E_INVALID_VALUE */
99194 + break;
99195 + }
99196 +
99197 +#if defined(CONFIG_COMPAT)
99198 + if (compat)
99199 + {
99200 + ioc_compat_fm_pcd_cc_node_params_t *compat_param;
99201 + compat_param = (ioc_compat_fm_pcd_cc_node_params_t *) XX_Malloc(
99202 + sizeof(ioc_compat_fm_pcd_cc_node_params_t) +
99203 + 2 * IOC_FM_PCD_MAX_NUM_OF_KEYS * IOC_FM_PCD_MAX_SIZE_OF_KEY);
99204 + if (!compat_param)
99205 + {
99206 + XX_Free(param);
99207 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99208 + }
99209 +
99210 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_node_params_t) +
99211 + 2 * IOC_FM_PCD_MAX_NUM_OF_KEYS * IOC_FM_PCD_MAX_SIZE_OF_KEY);
99212 + compat_copy_fm_pcd_cc_node(compat_param, param, COMPAT_K_TO_US);
99213 +
99214 + if (copy_to_user((ioc_compat_fm_pcd_cc_node_params_t *)compat_ptr(arg),
99215 + compat_param,
99216 + sizeof(ioc_compat_fm_pcd_cc_node_params_t)))
99217 + err = E_READ_FAILED;
99218 +
99219 + XX_Free(compat_param);
99220 + }
99221 + else
99222 +#endif
99223 + {
99224 + if (copy_to_user((ioc_fm_pcd_cc_node_params_t *)arg,
99225 + param,
99226 + sizeof(ioc_fm_pcd_cc_node_params_t)))
99227 + err = E_READ_FAILED;
99228 + }
99229 +
99230 + XX_Free(param);
99231 + break;
99232 + }
99233 +
99234 +#if defined(CONFIG_COMPAT)
99235 + case FM_PCD_IOC_MATCH_TABLE_DELETE_COMPAT:
99236 +#endif
99237 + case FM_PCD_IOC_MATCH_TABLE_DELETE:
99238 + {
99239 + ioc_fm_obj_t id;
99240 +
99241 + memset(&id, 0 , sizeof(ioc_fm_obj_t));
99242 +
99243 +#if defined(CONFIG_COMPAT)
99244 + if (compat)
99245 + {
99246 + ioc_compat_fm_obj_t compat_id;
99247 +
99248 + if (copy_from_user(&compat_id, (ioc_compat_fm_obj_t *) compat_ptr(arg), sizeof(ioc_compat_fm_obj_t)))
99249 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99250 +
99251 + compat_obj_delete(&compat_id, &id);
99252 + }
99253 + else
99254 +#endif
99255 + {
99256 + if (copy_from_user(&id, (ioc_fm_obj_t *) arg, sizeof(ioc_fm_obj_t)))
99257 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99258 + }
99259 +
99260 + err = FM_PCD_MatchTableDelete(id.obj);
99261 + break;
99262 + }
99263 +
99264 +#if defined(CONFIG_COMPAT)
99265 + case FM_PCD_IOC_CC_ROOT_BUILD_COMPAT:
99266 +#endif
99267 + case FM_PCD_IOC_CC_ROOT_BUILD:
99268 + {
99269 + ioc_fm_pcd_cc_tree_params_t *param;
99270 +
99271 + param = (ioc_fm_pcd_cc_tree_params_t *) XX_Malloc(sizeof(ioc_fm_pcd_cc_tree_params_t));
99272 + if (!param)
99273 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99274 +
99275 + memset(param, 0, sizeof(ioc_fm_pcd_cc_tree_params_t));
99276 +
99277 +#if defined(CONFIG_COMPAT)
99278 + if (compat)
99279 + {
99280 + ioc_compat_fm_pcd_cc_tree_params_t *compat_param;
99281 +
99282 + compat_param = (ioc_compat_fm_pcd_cc_tree_params_t *) XX_Malloc(
99283 + sizeof(ioc_compat_fm_pcd_cc_tree_params_t));
99284 + if (!compat_param)
99285 + {
99286 + XX_Free(param);
99287 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99288 + }
99289 +
99290 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tree_params_t));
99291 + if (copy_from_user(compat_param,
99292 + (ioc_compat_fm_pcd_cc_tree_params_t *)compat_ptr(arg),
99293 + sizeof(ioc_compat_fm_pcd_cc_tree_params_t)))
99294 + {
99295 + XX_Free(compat_param);
99296 + XX_Free(param);
99297 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99298 + }
99299 +
99300 + compat_copy_fm_pcd_cc_tree(compat_param, param, COMPAT_US_TO_K);
99301 +
99302 + XX_Free(compat_param);
99303 + }
99304 + else
99305 +#endif
99306 + {
99307 + if (copy_from_user(param, (ioc_fm_pcd_cc_tree_params_t *)arg,
99308 + sizeof(ioc_fm_pcd_cc_tree_params_t)))
99309 + {
99310 + XX_Free(param);
99311 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99312 + }
99313 + }
99314 +
99315 + param->id = FM_PCD_CcRootBuild(p_LnxWrpFmDev->h_PcdDev, (t_FmPcdCcTreeParams*)param);
99316 +
99317 + if (!param->id) {
99318 + XX_Free(param);
99319 + err = E_INVALID_VALUE;
99320 + /* Since the LLD has no errno-style error reporting,
99321 + we're left here with no other option than to report
99322 + a generic E_INVALID_VALUE */
99323 + break;
99324 + }
99325 +
99326 +#if defined(CONFIG_COMPAT)
99327 + if (compat)
99328 + {
99329 + ioc_compat_fm_pcd_cc_tree_params_t *compat_param;
99330 +
99331 + compat_param = (ioc_compat_fm_pcd_cc_tree_params_t *) XX_Malloc(sizeof(ioc_compat_fm_pcd_cc_tree_params_t));
99332 + if (!compat_param)
99333 + {
99334 + XX_Free(param);
99335 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99336 + }
99337 +
99338 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tree_params_t));
99339 +
99340 + compat_copy_fm_pcd_cc_tree(compat_param, param, COMPAT_K_TO_US);
99341 +
99342 + if (copy_to_user((ioc_compat_fm_pcd_cc_tree_params_t *)compat_ptr(arg),
99343 + compat_param,
99344 + sizeof(ioc_compat_fm_pcd_cc_tree_params_t)))
99345 + err = E_READ_FAILED;
99346 +
99347 + XX_Free(compat_param);
99348 + }
99349 + else
99350 +#endif
99351 + {
99352 + if (copy_to_user((ioc_fm_pcd_cc_tree_params_t *)arg,
99353 + param,
99354 + sizeof(ioc_fm_pcd_cc_tree_params_t)))
99355 + err = E_READ_FAILED;
99356 + }
99357 +
99358 + XX_Free(param);
99359 + break;
99360 + }
99361 +
99362 +#if defined(CONFIG_COMPAT)
99363 + case FM_PCD_IOC_CC_ROOT_DELETE_COMPAT:
99364 +#endif
99365 + case FM_PCD_IOC_CC_ROOT_DELETE:
99366 + {
99367 + ioc_fm_obj_t id;
99368 +
99369 + memset(&id, 0 , sizeof(ioc_fm_obj_t));
99370 +
99371 +#if defined(CONFIG_COMPAT)
99372 + if (compat)
99373 + {
99374 + ioc_compat_fm_obj_t compat_id;
99375 +
99376 + if (copy_from_user(&compat_id, (ioc_compat_fm_obj_t *) compat_ptr(arg), sizeof(ioc_compat_fm_obj_t)))
99377 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99378 +
99379 + compat_obj_delete(&compat_id, &id);
99380 + }
99381 + else
99382 +#endif
99383 + {
99384 + if (copy_from_user(&id, (ioc_fm_obj_t *) arg, sizeof(ioc_fm_obj_t)))
99385 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99386 + }
99387 +
99388 + err = FM_PCD_CcRootDelete(id.obj);
99389 + break;
99390 + }
99391 +
99392 +#if defined(CONFIG_COMPAT)
99393 + case FM_PCD_IOC_PLCR_PROFILE_SET_COMPAT:
99394 +#endif
99395 + case FM_PCD_IOC_PLCR_PROFILE_SET:
99396 + {
99397 + ioc_fm_pcd_plcr_profile_params_t *param;
99398 +
99399 + param = (ioc_fm_pcd_plcr_profile_params_t *) XX_Malloc(
99400 + sizeof(ioc_fm_pcd_plcr_profile_params_t));
99401 + if (!param)
99402 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99403 +
99404 + memset(param, 0, sizeof(ioc_fm_pcd_plcr_profile_params_t));
99405 +
99406 +#if defined(CONFIG_COMPAT)
99407 + if (compat)
99408 + {
99409 + ioc_compat_fm_pcd_plcr_profile_params_t *compat_param;
99410 +
99411 + compat_param = (ioc_compat_fm_pcd_plcr_profile_params_t *) XX_Malloc(
99412 + sizeof(ioc_compat_fm_pcd_plcr_profile_params_t));
99413 + if (!compat_param)
99414 + {
99415 + XX_Free(param);
99416 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99417 + }
99418 +
99419 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_plcr_profile_params_t));
99420 + if (copy_from_user(compat_param, (
99421 + ioc_compat_fm_pcd_plcr_profile_params_t *)compat_ptr(arg),
99422 + sizeof(ioc_compat_fm_pcd_plcr_profile_params_t)))
99423 + {
99424 + XX_Free(compat_param);
99425 + XX_Free(param);
99426 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99427 + }
99428 +
99429 + compat_copy_fm_pcd_plcr_profile(compat_param, param, COMPAT_US_TO_K);
99430 +
99431 + XX_Free(compat_param);
99432 + }
99433 + else
99434 +#endif
99435 + {
99436 + if (copy_from_user(param, (ioc_fm_pcd_plcr_profile_params_t *)arg,
99437 + sizeof(ioc_fm_pcd_plcr_profile_params_t)))
99438 + {
99439 + XX_Free(param);
99440 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99441 + }
99442 + }
99443 +
99444 + if (!param->modify &&
99445 + (((t_FmPcdPlcrProfileParams*)param)->id.newParams.profileType != e_FM_PCD_PLCR_SHARED))
99446 + {
99447 + t_Handle h_Port;
99448 + ioc_fm_pcd_port_params_t *port_params;
99449 +
99450 + port_params = (ioc_fm_pcd_port_params_t*) XX_Malloc(sizeof(ioc_fm_pcd_port_params_t));
99451 + if (!port_params)
99452 + {
99453 + XX_Free(param);
99454 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99455 + }
99456 +
99457 + memset(port_params, 0, sizeof(ioc_fm_pcd_port_params_t));
99458 + if (copy_from_user(port_params, (ioc_fm_pcd_port_params_t*)((t_FmPcdPlcrProfileParams*)param)->id.newParams.h_FmPort,
99459 + sizeof(ioc_fm_pcd_port_params_t)))
99460 + {
99461 + XX_Free(port_params);
99462 + XX_Free(param);
99463 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99464 + }
99465 +
99466 + switch(port_params->port_type)
99467 + {
99468 + case (e_IOC_FM_PORT_TYPE_RX):
99469 + if (port_params->port_id < FM_MAX_NUM_OF_1G_RX_PORTS) {
99470 + h_Port = p_LnxWrpFmDev->rxPorts[port_params->port_id].h_Dev;
99471 + break;
99472 + }
99473 + goto invalid_port_id;
99474 +
99475 + case (e_IOC_FM_PORT_TYPE_RX_10G):
99476 + if (port_params->port_id < FM_MAX_NUM_OF_10G_RX_PORTS) {
99477 +#ifndef CONFIG_FMAN_ARM
99478 + if (IS_T1023_T1024) {
99479 + h_Port = p_LnxWrpFmDev->rxPorts[port_params->port_id].h_Dev;
99480 + } else {
99481 +#else
99482 + {
99483 +#endif
99484 + h_Port = p_LnxWrpFmDev->rxPorts[port_params->port_id + FM_MAX_NUM_OF_1G_RX_PORTS].h_Dev;
99485 + }
99486 + break;
99487 + }
99488 + goto invalid_port_id;
99489 +
99490 + case (e_IOC_FM_PORT_TYPE_OH_OFFLINE_PARSING):
99491 + if (port_params->port_id && port_params->port_id < FM_MAX_NUM_OF_OH_PORTS) {
99492 + h_Port = p_LnxWrpFmDev->opPorts[port_params->port_id - 1].h_Dev;
99493 + break;
99494 + }
99495 + goto invalid_port_id;
99496 +
99497 + default:
99498 +invalid_port_id:
99499 + XX_Free(port_params);
99500 + XX_Free(param);
99501 + RETURN_ERROR(MINOR, E_INVALID_SELECTION, NO_MSG);
99502 + }
99503 +
99504 + ((t_FmPcdPlcrProfileParams*)param)->id.newParams.h_FmPort = h_Port;
99505 + XX_Free(port_params);
99506 + }
99507 +
99508 + param->id = FM_PCD_PlcrProfileSet(p_LnxWrpFmDev->h_PcdDev, (t_FmPcdPlcrProfileParams*)param);
99509 +
99510 + if (!param->id) {
99511 + XX_Free(param);
99512 + err = E_INVALID_VALUE;
99513 + /* Since the LLD has no errno-style error reporting,
99514 + we're left here with no other option than to report
99515 + a generic E_INVALID_VALUE */
99516 + break;
99517 + }
99518 +
99519 +#if defined(CONFIG_COMPAT)
99520 + if (compat)
99521 + {
99522 + ioc_compat_fm_pcd_plcr_profile_params_t *compat_param;
99523 +
99524 + compat_param = (ioc_compat_fm_pcd_plcr_profile_params_t *) XX_Malloc(
99525 + sizeof(ioc_compat_fm_pcd_plcr_profile_params_t));
99526 + if (!compat_param)
99527 + {
99528 + XX_Free(param);
99529 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99530 + }
99531 +
99532 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_plcr_profile_params_t));
99533 + compat_copy_fm_pcd_plcr_profile(compat_param, param, COMPAT_K_TO_US);
99534 + if (copy_to_user((ioc_compat_fm_pcd_plcr_profile_params_t *) compat_ptr(arg),
99535 + compat_param,
99536 + sizeof(ioc_compat_fm_pcd_plcr_profile_params_t)))
99537 + err = E_READ_FAILED;
99538 +
99539 + XX_Free(compat_param);
99540 + }
99541 + else
99542 +#endif
99543 + {
99544 + if (copy_to_user((ioc_fm_pcd_plcr_profile_params_t *)arg,
99545 + param,
99546 + sizeof(ioc_fm_pcd_plcr_profile_params_t)))
99547 + err = E_READ_FAILED;
99548 + }
99549 +
99550 + XX_Free(param);
99551 + break;
99552 + }
99553 +
99554 +#if defined(CONFIG_COMPAT)
99555 + case FM_PCD_IOC_PLCR_PROFILE_DELETE_COMPAT:
99556 +#endif
99557 + case FM_PCD_IOC_PLCR_PROFILE_DELETE:
99558 + {
99559 + ioc_fm_obj_t id;
99560 +
99561 + memset(&id, 0 , sizeof(ioc_fm_obj_t));
99562 +
99563 +#if defined(CONFIG_COMPAT)
99564 + if (compat)
99565 + {
99566 + ioc_compat_fm_obj_t compat_id;
99567 +
99568 + if (copy_from_user(&compat_id, (ioc_compat_fm_obj_t *) compat_ptr(arg), sizeof(ioc_compat_fm_obj_t)))
99569 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99570 +
99571 + compat_obj_delete(&compat_id, &id);
99572 + }
99573 + else
99574 +#endif
99575 + {
99576 + if (copy_from_user(&id, (ioc_fm_obj_t *) arg, sizeof(ioc_fm_obj_t)))
99577 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99578 + }
99579 +
99580 + err = FM_PCD_PlcrProfileDelete(id.obj);
99581 + break;
99582 + }
99583 +
99584 +#if defined(CONFIG_COMPAT)
99585 + case FM_PCD_IOC_CC_ROOT_MODIFY_NEXT_ENGINE_COMPAT:
99586 +#endif
99587 + case FM_PCD_IOC_CC_ROOT_MODIFY_NEXT_ENGINE:
99588 + {
99589 + ioc_fm_pcd_cc_tree_modify_next_engine_params_t *param;
99590 +
99591 + param = (ioc_fm_pcd_cc_tree_modify_next_engine_params_t *) XX_Malloc(
99592 + sizeof(ioc_fm_pcd_cc_tree_modify_next_engine_params_t));
99593 + if (!param)
99594 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99595 +
99596 + memset(param, 0, sizeof(ioc_fm_pcd_cc_tree_modify_next_engine_params_t));
99597 +
99598 +#if defined(CONFIG_COMPAT)
99599 + if (compat)
99600 + {
99601 + ioc_compat_fm_pcd_cc_tree_modify_next_engine_params_t *compat_param;
99602 +
99603 + compat_param = (ioc_compat_fm_pcd_cc_tree_modify_next_engine_params_t *) XX_Malloc(
99604 + sizeof(ioc_compat_fm_pcd_cc_tree_modify_next_engine_params_t));
99605 + if (!compat_param)
99606 + {
99607 + XX_Free(param);
99608 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99609 + }
99610 +
99611 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tree_modify_next_engine_params_t));
99612 + if (copy_from_user(compat_param, (ioc_compat_fm_pcd_cc_tree_modify_next_engine_params_t *) compat_ptr(arg),
99613 + sizeof(ioc_compat_fm_pcd_cc_tree_modify_next_engine_params_t)))
99614 + {
99615 + XX_Free(compat_param);
99616 + XX_Free(param);
99617 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99618 + }
99619 +
99620 + compat_fm_pcd_cc_tree_modify_next_engine(compat_param, param, COMPAT_US_TO_K);
99621 +
99622 + XX_Free(compat_param);
99623 + }
99624 + else
99625 +#endif
99626 + {
99627 + if (copy_from_user(param, (ioc_fm_pcd_cc_tree_modify_next_engine_params_t *)arg,
99628 + sizeof(ioc_fm_pcd_cc_tree_modify_next_engine_params_t)))
99629 + {
99630 + XX_Free(param);
99631 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99632 + }
99633 + }
99634 +
99635 + err = FM_PCD_CcRootModifyNextEngine(param->id,
99636 + param->grp_indx,
99637 + param->indx,
99638 + (t_FmPcdCcNextEngineParams*)(&param->cc_next_engine_params));
99639 +
99640 + XX_Free(param);
99641 + break;
99642 + }
99643 +
99644 +#if defined(CONFIG_COMPAT)
99645 + case FM_PCD_IOC_MATCH_TABLE_MODIFY_NEXT_ENGINE_COMPAT:
99646 +#endif
99647 + case FM_PCD_IOC_MATCH_TABLE_MODIFY_NEXT_ENGINE:
99648 + {
99649 + ioc_fm_pcd_cc_node_modify_next_engine_params_t *param;
99650 +
99651 + param = (ioc_fm_pcd_cc_node_modify_next_engine_params_t *) XX_Malloc(
99652 + sizeof(ioc_fm_pcd_cc_node_modify_next_engine_params_t));
99653 + if (!param)
99654 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99655 +
99656 + memset(param, 0, sizeof(ioc_fm_pcd_cc_node_modify_next_engine_params_t));
99657 +
99658 +#if defined(CONFIG_COMPAT)
99659 + if (compat)
99660 + {
99661 + ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t *compat_param;
99662 +
99663 + compat_param = (ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t *) XX_Malloc(
99664 + sizeof(ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t));
99665 + if (!compat_param)
99666 + {
99667 + XX_Free(param);
99668 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99669 + }
99670 +
99671 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t));
99672 + if (copy_from_user(compat_param, (ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t *) compat_ptr(arg),
99673 + sizeof(ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t)))
99674 + {
99675 + XX_Free(compat_param);
99676 + XX_Free(param);
99677 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99678 + }
99679 +
99680 + compat_copy_fm_pcd_cc_node_modify_next_engine(compat_param, param, COMPAT_US_TO_K);
99681 +
99682 + XX_Free(compat_param);
99683 + }
99684 + else
99685 +#endif
99686 + {
99687 + if (copy_from_user(param, (ioc_fm_pcd_cc_node_modify_next_engine_params_t *)arg,
99688 + sizeof(ioc_fm_pcd_cc_node_modify_next_engine_params_t)))
99689 + {
99690 + XX_Free(param);
99691 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99692 + }
99693 + }
99694 +
99695 + err = FM_PCD_MatchTableModifyNextEngine(param->id,
99696 + param->key_indx,
99697 + (t_FmPcdCcNextEngineParams*)(&param->cc_next_engine_params));
99698 +
99699 + XX_Free(param);
99700 + break;
99701 + }
99702 +
99703 +#if defined(CONFIG_COMPAT)
99704 + case FM_PCD_IOC_MATCH_TABLE_MODIFY_MISS_NEXT_ENGINE_COMPAT:
99705 +#endif
99706 + case FM_PCD_IOC_MATCH_TABLE_MODIFY_MISS_NEXT_ENGINE:
99707 + {
99708 + ioc_fm_pcd_cc_node_modify_next_engine_params_t *param;
99709 +
99710 + param = (ioc_fm_pcd_cc_node_modify_next_engine_params_t *) XX_Malloc(
99711 + sizeof(ioc_fm_pcd_cc_node_modify_next_engine_params_t));
99712 + if (!param)
99713 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99714 +
99715 + memset(param, 0, sizeof(ioc_fm_pcd_cc_node_modify_next_engine_params_t));
99716 +
99717 +#if defined(CONFIG_COMPAT)
99718 + if (compat)
99719 + {
99720 + ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t *compat_param;
99721 +
99722 + compat_param = (ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t *) XX_Malloc(
99723 + sizeof(ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t));
99724 + if (!compat_param)
99725 + {
99726 + XX_Free(param);
99727 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99728 + }
99729 +
99730 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t));
99731 + if (copy_from_user(compat_param, (ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t *) compat_ptr(arg),
99732 + sizeof(ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t)))
99733 + {
99734 + XX_Free(compat_param);
99735 + XX_Free(param);
99736 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99737 + }
99738 +
99739 + compat_copy_fm_pcd_cc_node_modify_next_engine(compat_param, param, COMPAT_US_TO_K);
99740 +
99741 + XX_Free(compat_param);
99742 + }
99743 + else
99744 +#endif
99745 + {
99746 + if (copy_from_user(param, (ioc_fm_pcd_cc_node_modify_next_engine_params_t *) arg,
99747 + sizeof(ioc_fm_pcd_cc_node_modify_next_engine_params_t)))
99748 + {
99749 + XX_Free(param);
99750 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99751 + }
99752 + }
99753 +
99754 + err = FM_PCD_MatchTableModifyMissNextEngine(param->id,
99755 + (t_FmPcdCcNextEngineParams*)(&param->cc_next_engine_params));
99756 +
99757 + XX_Free(param);
99758 + break;
99759 + }
99760 +
99761 +#if defined(CONFIG_COMPAT)
99762 + case FM_PCD_IOC_MATCH_TABLE_REMOVE_KEY_COMPAT:
99763 +#endif
99764 + case FM_PCD_IOC_MATCH_TABLE_REMOVE_KEY:
99765 + {
99766 + ioc_fm_pcd_cc_node_remove_key_params_t *param;
99767 +
99768 + param = (ioc_fm_pcd_cc_node_remove_key_params_t *) XX_Malloc(
99769 + sizeof(ioc_fm_pcd_cc_node_remove_key_params_t));
99770 + if (!param)
99771 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99772 +
99773 + memset(param, 0, sizeof(ioc_fm_pcd_cc_node_remove_key_params_t));
99774 +
99775 +#if defined(CONFIG_COMPAT)
99776 + if (compat)
99777 + {
99778 + ioc_compat_fm_pcd_cc_node_remove_key_params_t *compat_param;
99779 +
99780 + compat_param = (ioc_compat_fm_pcd_cc_node_remove_key_params_t *) XX_Malloc(
99781 + sizeof(ioc_compat_fm_pcd_cc_node_remove_key_params_t));
99782 + if (!compat_param)
99783 + {
99784 + XX_Free(param);
99785 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99786 + }
99787 +
99788 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_node_remove_key_params_t));
99789 + if (copy_from_user(compat_param,
99790 + (ioc_compat_fm_pcd_cc_node_remove_key_params_t *)compat_ptr(arg),
99791 + sizeof(ioc_compat_fm_pcd_cc_node_remove_key_params_t)))
99792 + {
99793 + XX_Free(compat_param);
99794 + XX_Free(param);
99795 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99796 + }
99797 +
99798 + param->id = compat_ptr(compat_param->id);
99799 + param->key_indx = compat_param->key_indx;
99800 +
99801 + XX_Free(compat_param);
99802 + }
99803 + else
99804 +#endif
99805 + {
99806 + if (copy_from_user(param, (ioc_fm_pcd_cc_node_remove_key_params_t *) arg,
99807 + sizeof(ioc_fm_pcd_cc_node_remove_key_params_t)))
99808 + {
99809 + XX_Free(param);
99810 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99811 + }
99812 + }
99813 +
99814 + err = FM_PCD_MatchTableRemoveKey(param->id, param->key_indx);
99815 +
99816 + XX_Free(param);
99817 + break;
99818 + }
99819 +#if defined(CONFIG_COMPAT)
99820 + case FM_PCD_IOC_MATCH_TABLE_ADD_KEY_COMPAT:
99821 +#endif
99822 + case FM_PCD_IOC_MATCH_TABLE_ADD_KEY:
99823 + {
99824 + ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t *param;
99825 +
99826 + param = (ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t *) XX_Malloc(
99827 + sizeof(ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t));
99828 + if (!param)
99829 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99830 +
99831 + memset(param, 0, sizeof(ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t));
99832 +
99833 +#if defined(CONFIG_COMPAT)
99834 + if (compat)
99835 + {
99836 + ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t *compat_param;
99837 +
99838 + compat_param = (ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t *) XX_Malloc(
99839 + sizeof(ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t));
99840 + if (!compat_param)
99841 + {
99842 + XX_Free(param);
99843 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99844 + }
99845 +
99846 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t));
99847 + if (copy_from_user(compat_param,
99848 + (ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t *)compat_ptr(arg),
99849 + sizeof(ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t)))
99850 + {
99851 + XX_Free(compat_param);
99852 + XX_Free(param);
99853 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99854 + }
99855 +
99856 + compat_copy_fm_pcd_cc_node_modify_key_and_next_engine(compat_param, param, COMPAT_US_TO_K);
99857 +
99858 + XX_Free(compat_param);
99859 + }
99860 + else
99861 +#endif
99862 + {
99863 + if (copy_from_user(param, (ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t *)arg,
99864 + sizeof(ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t)))
99865 + {
99866 + XX_Free(param);
99867 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99868 + }
99869 + }
99870 +
99871 + if (param->key_size)
99872 + {
99873 + int size = 0;
99874 +
99875 + if (param->key_params.p_key) size += param->key_size;
99876 + if (param->key_params.p_mask) size += param->key_size;
99877 +
99878 + if (size)
99879 + {
99880 + uint8_t *p_tmp;
99881 +
99882 + p_tmp = (uint8_t*) XX_Malloc(size);
99883 + if (!p_tmp)
99884 + {
99885 + XX_Free(param);
99886 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD key/mask"));
99887 + }
99888 +
99889 + if (param->key_params.p_key)
99890 + {
99891 + if (copy_from_user(p_tmp, param->key_params.p_key, param->key_size))
99892 + {
99893 + XX_Free(p_tmp);
99894 + XX_Free(param);
99895 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99896 + }
99897 +
99898 + param->key_params.p_key = p_tmp;
99899 + }
99900 +
99901 + if (param->key_params.p_mask)
99902 + {
99903 + p_tmp += param->key_size;
99904 + if (copy_from_user(p_tmp, param->key_params.p_mask, param->key_size))
99905 + {
99906 + XX_Free(p_tmp - param->key_size);
99907 + XX_Free(param);
99908 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99909 + }
99910 +
99911 + param->key_params.p_mask = p_tmp;
99912 + }
99913 + }
99914 + }
99915 +
99916 + err = FM_PCD_MatchTableAddKey(
99917 + param->id,
99918 + param->key_indx,
99919 + param->key_size,
99920 + (t_FmPcdCcKeyParams*)&param->key_params);
99921 +
99922 + if (param->key_params.p_key)
99923 + XX_Free(param->key_params.p_key);
99924 + XX_Free(param);
99925 + break;
99926 + }
99927 +
99928 +#if defined(CONFIG_COMPAT)
99929 + case FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY_AND_NEXT_ENGINE_COMPAT:
99930 +#endif
99931 + case FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY_AND_NEXT_ENGINE:
99932 + {
99933 + ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t *param;
99934 +
99935 + param = (ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t *) XX_Malloc(
99936 + sizeof(ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t));
99937 + if (!param)
99938 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99939 +
99940 + memset(param, 0, sizeof(ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t));
99941 +
99942 +#if defined(CONFIG_COMPAT)
99943 + if (compat)
99944 + {
99945 + ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t *compat_param;
99946 +
99947 + compat_param = (ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t *) XX_Malloc(
99948 + sizeof(ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t));
99949 + if (!compat_param)
99950 + {
99951 + XX_Free(param);
99952 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
99953 + }
99954 +
99955 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t));
99956 + if (copy_from_user(compat_param,
99957 + (ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t *)compat_ptr(arg),
99958 + sizeof(ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t)))
99959 + {
99960 + XX_Free(compat_param);
99961 + XX_Free(param);
99962 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99963 + }
99964 +
99965 + compat_copy_fm_pcd_cc_node_modify_key_and_next_engine(compat_param, param, COMPAT_US_TO_K);
99966 +
99967 + XX_Free(compat_param);
99968 + }
99969 + else
99970 +#endif
99971 + {
99972 + if (copy_from_user(param, (ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t *)arg,
99973 + sizeof(ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t)))
99974 + {
99975 + XX_Free(param);
99976 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
99977 + }
99978 + }
99979 +
99980 + err = FM_PCD_MatchTableModifyKeyAndNextEngine(param->id,
99981 + param->key_indx,
99982 + param->key_size,
99983 + (t_FmPcdCcKeyParams*)(&param->key_params));
99984 +
99985 + XX_Free(param);
99986 + break;
99987 + }
99988 +
99989 +
99990 +#if defined(CONFIG_COMPAT)
99991 + case FM_PCD_IOC_MATCH_TABLE_GET_KEY_STAT_COMPAT:
99992 +#endif
99993 + case FM_PCD_IOC_MATCH_TABLE_GET_KEY_STAT:
99994 + {
99995 + ioc_fm_pcd_cc_tbl_get_stats_t param;
99996 +
99997 +#if defined(CONFIG_COMPAT)
99998 + if (compat)
99999 + {
100000 + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param;
100001 +
100002 + compat_param = (ioc_compat_fm_pcd_cc_tbl_get_stats_t *) XX_Malloc(
100003 + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t));
100004 + if (!compat_param)
100005 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100006 +
100007 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t));
100008 + if (copy_from_user(compat_param,
100009 + (ioc_compat_fm_pcd_cc_tbl_get_stats_t *)compat_ptr(arg),
100010 + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)))
100011 + {
100012 + XX_Free(compat_param);
100013 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100014 + }
100015 +
100016 + compat_copy_fm_pcd_cc_tbl_get_stats(compat_param, &param, COMPAT_US_TO_K);
100017 +
100018 + XX_Free(compat_param);
100019 + }
100020 + else
100021 +#endif
100022 + {
100023 + if (copy_from_user(&param, (ioc_fm_pcd_cc_tbl_get_stats_t *)arg,
100024 + sizeof(ioc_fm_pcd_cc_tbl_get_stats_t)))
100025 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100026 + }
100027 +
100028 +
100029 + err = FM_PCD_MatchTableGetKeyStatistics((t_Handle) param.id,
100030 + param.key_index,
100031 + (t_FmPcdCcKeyStatistics *) &param.statistics);
100032 +
100033 +#if defined(CONFIG_COMPAT)
100034 + if (compat)
100035 + {
100036 + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param;
100037 +
100038 + compat_param = (ioc_compat_fm_pcd_cc_tbl_get_stats_t*) XX_Malloc(
100039 + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t));
100040 + if (!compat_param)
100041 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100042 +
100043 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t));
100044 + compat_copy_fm_pcd_cc_tbl_get_stats(compat_param, &param, COMPAT_K_TO_US);
100045 + if (copy_to_user((ioc_compat_fm_pcd_cc_tbl_get_stats_t*) compat_ptr(arg),
100046 + compat_param,
100047 + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t))){
100048 + XX_Free(compat_param);
100049 + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG);
100050 + }
100051 + XX_Free(compat_param);
100052 + }
100053 + else
100054 +#endif
100055 + {
100056 + if (copy_to_user((ioc_fm_pcd_cc_tbl_get_stats_t *)arg,
100057 + &param,
100058 + sizeof(ioc_fm_pcd_cc_tbl_get_stats_t)))
100059 + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG);
100060 + }
100061 +
100062 + break;
100063 + }
100064 +
100065 +
100066 +#if defined(CONFIG_COMPAT)
100067 + case FM_PCD_IOC_MATCH_TABLE_GET_MISS_STAT_COMPAT:
100068 +#endif
100069 + case FM_PCD_IOC_MATCH_TABLE_GET_MISS_STAT:
100070 + {
100071 + ioc_fm_pcd_cc_tbl_get_stats_t param;
100072 +
100073 +#if defined(CONFIG_COMPAT)
100074 + if (compat)
100075 + {
100076 + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param;
100077 +
100078 + compat_param = (ioc_compat_fm_pcd_cc_tbl_get_stats_t *) XX_Malloc(
100079 + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t));
100080 + if (!compat_param)
100081 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100082 +
100083 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t));
100084 + if (copy_from_user(compat_param,
100085 + (ioc_compat_fm_pcd_cc_tbl_get_stats_t *)compat_ptr(arg),
100086 + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)))
100087 + {
100088 + XX_Free(compat_param);
100089 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100090 + }
100091 +
100092 + compat_copy_fm_pcd_cc_tbl_get_stats(compat_param, &param, COMPAT_US_TO_K);
100093 +
100094 + XX_Free(compat_param);
100095 + }
100096 + else
100097 +#endif
100098 + {
100099 + if (copy_from_user(&param, (ioc_fm_pcd_cc_tbl_get_stats_t *)arg,
100100 + sizeof(ioc_fm_pcd_cc_tbl_get_stats_t)))
100101 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100102 + }
100103 +
100104 +
100105 + err = FM_PCD_MatchTableGetMissStatistics((t_Handle) param.id,
100106 + (t_FmPcdCcKeyStatistics *) &param.statistics);
100107 +
100108 +#if defined(CONFIG_COMPAT)
100109 + if (compat)
100110 + {
100111 + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param;
100112 +
100113 + compat_param = (ioc_compat_fm_pcd_cc_tbl_get_stats_t*) XX_Malloc(
100114 + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t));
100115 + if (!compat_param)
100116 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100117 +
100118 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t));
100119 + compat_copy_fm_pcd_cc_tbl_get_stats(compat_param, &param, COMPAT_K_TO_US);
100120 + if (copy_to_user((ioc_compat_fm_pcd_cc_tbl_get_stats_t*) compat_ptr(arg),
100121 + compat_param,
100122 + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t))){
100123 + XX_Free(compat_param);
100124 + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG);
100125 + }
100126 + XX_Free(compat_param);
100127 + }
100128 + else
100129 +#endif
100130 + {
100131 + if (copy_to_user((ioc_fm_pcd_cc_tbl_get_stats_t *)arg,
100132 + &param,
100133 + sizeof(ioc_fm_pcd_cc_tbl_get_stats_t)))
100134 + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG);
100135 + }
100136 +
100137 + break;
100138 + }
100139 +
100140 +
100141 +#if defined(CONFIG_COMPAT)
100142 + case FM_PCD_IOC_HASH_TABLE_GET_MISS_STAT_COMPAT:
100143 +#endif
100144 + case FM_PCD_IOC_HASH_TABLE_GET_MISS_STAT:
100145 + {
100146 + ioc_fm_pcd_cc_tbl_get_stats_t param;
100147 +
100148 +#if defined(CONFIG_COMPAT)
100149 + if (compat)
100150 + {
100151 + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param;
100152 +
100153 + compat_param = (ioc_compat_fm_pcd_cc_tbl_get_stats_t *) XX_Malloc(
100154 + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t));
100155 + if (!compat_param)
100156 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100157 +
100158 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t));
100159 + if (copy_from_user(compat_param,
100160 + (ioc_compat_fm_pcd_cc_tbl_get_stats_t *)compat_ptr(arg),
100161 + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t)))
100162 + {
100163 + XX_Free(compat_param);
100164 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100165 + }
100166 +
100167 + compat_copy_fm_pcd_cc_tbl_get_stats(compat_param, &param, COMPAT_US_TO_K);
100168 +
100169 + XX_Free(compat_param);
100170 + }
100171 + else
100172 +#endif
100173 + {
100174 + if (copy_from_user(&param, (ioc_fm_pcd_cc_tbl_get_stats_t *)arg,
100175 + sizeof(ioc_fm_pcd_cc_tbl_get_stats_t)))
100176 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100177 + }
100178 +
100179 +
100180 + err = FM_PCD_HashTableGetMissStatistics((t_Handle) param.id,
100181 + (t_FmPcdCcKeyStatistics *) &param.statistics);
100182 +
100183 +#if defined(CONFIG_COMPAT)
100184 + if (compat)
100185 + {
100186 + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param;
100187 +
100188 + compat_param = (ioc_compat_fm_pcd_cc_tbl_get_stats_t*) XX_Malloc(
100189 + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t));
100190 + if (!compat_param)
100191 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100192 +
100193 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t));
100194 + compat_copy_fm_pcd_cc_tbl_get_stats(compat_param, &param, COMPAT_K_TO_US);
100195 + if (copy_to_user((ioc_compat_fm_pcd_cc_tbl_get_stats_t*) compat_ptr(arg),
100196 + compat_param,
100197 + sizeof(ioc_compat_fm_pcd_cc_tbl_get_stats_t))){
100198 + XX_Free(compat_param);
100199 + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG);
100200 + }
100201 + XX_Free(compat_param);
100202 + }
100203 + else
100204 +#endif
100205 + {
100206 + if (copy_to_user((ioc_fm_pcd_cc_tbl_get_stats_t *)arg,
100207 + &param,
100208 + sizeof(ioc_fm_pcd_cc_tbl_get_stats_t)))
100209 + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG);
100210 + }
100211 +
100212 + break;
100213 + }
100214 +
100215 +#if defined(CONFIG_COMPAT)
100216 + case FM_PCD_IOC_HASH_TABLE_SET_COMPAT:
100217 +#endif
100218 + case FM_PCD_IOC_HASH_TABLE_SET:
100219 + {
100220 + ioc_fm_pcd_hash_table_params_t *param;
100221 +
100222 + param = (ioc_fm_pcd_hash_table_params_t*) XX_Malloc(
100223 + sizeof(ioc_fm_pcd_hash_table_params_t));
100224 + if (!param)
100225 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100226 +
100227 + memset(param, 0, sizeof(ioc_fm_pcd_hash_table_params_t));
100228 +
100229 +#if defined(CONFIG_COMPAT)
100230 + if (compat)
100231 + {
100232 + ioc_compat_fm_pcd_hash_table_params_t *compat_param;
100233 +
100234 + compat_param = (ioc_compat_fm_pcd_hash_table_params_t*) XX_Malloc(
100235 + sizeof(ioc_compat_fm_pcd_hash_table_params_t));
100236 + if (!compat_param)
100237 + {
100238 + XX_Free(param);
100239 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100240 + }
100241 +
100242 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_hash_table_params_t));
100243 + if (copy_from_user(compat_param,
100244 + (ioc_compat_fm_pcd_hash_table_params_t*)compat_ptr(arg),
100245 + sizeof(ioc_compat_fm_pcd_hash_table_params_t)))
100246 + {
100247 + XX_Free(compat_param);
100248 + XX_Free(param);
100249 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100250 + }
100251 +
100252 + compat_copy_fm_pcd_hash_table(compat_param, param, COMPAT_US_TO_K);
100253 +
100254 + XX_Free(compat_param);
100255 + }
100256 + else
100257 +#endif
100258 + {
100259 + if (copy_from_user(param, (ioc_fm_pcd_hash_table_params_t *)arg,
100260 + sizeof(ioc_fm_pcd_hash_table_params_t)))
100261 + {
100262 + XX_Free(param);
100263 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100264 + }
100265 + }
100266 +
100267 + param->id = FM_PCD_HashTableSet(p_LnxWrpFmDev->h_PcdDev, (t_FmPcdHashTableParams *) param);
100268 +
100269 + if (!param->id)
100270 + {
100271 + XX_Free(param);
100272 + err = E_INVALID_VALUE;
100273 + /* Since the LLD has no errno-style error reporting,
100274 + we're left here with no other option than to report
100275 + a generic E_INVALID_VALUE */
100276 + break;
100277 + }
100278 +
100279 +#if defined(CONFIG_COMPAT)
100280 + if (compat)
100281 + {
100282 + ioc_compat_fm_pcd_hash_table_params_t *compat_param;
100283 +
100284 + compat_param = (ioc_compat_fm_pcd_hash_table_params_t*) XX_Malloc(
100285 + sizeof(ioc_compat_fm_pcd_hash_table_params_t));
100286 + if (!compat_param)
100287 + {
100288 + XX_Free(param);
100289 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100290 + }
100291 +
100292 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_hash_table_params_t));
100293 + compat_copy_fm_pcd_hash_table(compat_param, param, COMPAT_K_TO_US);
100294 + if (copy_to_user((ioc_compat_fm_pcd_hash_table_params_t*) compat_ptr(arg),
100295 + compat_param,
100296 + sizeof(ioc_compat_fm_pcd_hash_table_params_t)))
100297 + err = E_READ_FAILED;
100298 +
100299 + XX_Free(compat_param);
100300 + }
100301 + else
100302 +#endif
100303 + {
100304 + if (copy_to_user((ioc_fm_pcd_hash_table_params_t *)arg,
100305 + param,
100306 + sizeof(ioc_fm_pcd_hash_table_params_t)))
100307 + err = E_READ_FAILED;
100308 + }
100309 +
100310 + XX_Free(param);
100311 + break;
100312 + }
100313 +
100314 +#if defined(CONFIG_COMPAT)
100315 + case FM_PCD_IOC_HASH_TABLE_DELETE_COMPAT:
100316 +#endif
100317 + case FM_PCD_IOC_HASH_TABLE_DELETE:
100318 + {
100319 + ioc_fm_obj_t id;
100320 +
100321 + memset(&id, 0, sizeof(ioc_fm_obj_t));
100322 +
100323 +#if defined(CONFIG_COMPAT)
100324 + if (compat)
100325 + {
100326 + ioc_compat_fm_obj_t compat_id;
100327 +
100328 + if (copy_from_user(&compat_id, (ioc_compat_fm_obj_t *) compat_ptr(arg), sizeof(ioc_compat_fm_obj_t)))
100329 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100330 +
100331 + id.obj = compat_pcd_id2ptr(compat_id.obj);
100332 + }
100333 + else
100334 +#endif
100335 + {
100336 + if (copy_from_user(&id, (ioc_fm_obj_t *) arg, sizeof(ioc_fm_obj_t)))
100337 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100338 + }
100339 +
100340 + err = FM_PCD_HashTableDelete(id.obj);
100341 + break;
100342 + }
100343 +
100344 +#if defined(CONFIG_COMPAT)
100345 + case FM_PCD_IOC_HASH_TABLE_ADD_KEY_COMPAT:
100346 +#endif
100347 + case FM_PCD_IOC_HASH_TABLE_ADD_KEY:
100348 + {
100349 + ioc_fm_pcd_hash_table_add_key_params_t *param = NULL;
100350 +
100351 + param = (ioc_fm_pcd_hash_table_add_key_params_t*) XX_Malloc(
100352 + sizeof(ioc_fm_pcd_hash_table_add_key_params_t));
100353 + if (!param)
100354 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100355 +
100356 + memset(param, 0, sizeof(ioc_fm_pcd_hash_table_add_key_params_t));
100357 +
100358 +#if defined(CONFIG_COMPAT)
100359 + if (compat)
100360 + {
100361 + ioc_compat_fm_pcd_hash_table_add_key_params_t *compat_param;
100362 +
100363 + compat_param = (ioc_compat_fm_pcd_hash_table_add_key_params_t*) XX_Malloc(
100364 + sizeof(ioc_compat_fm_pcd_hash_table_add_key_params_t));
100365 + if (!compat_param)
100366 + {
100367 + XX_Free(param);
100368 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100369 + }
100370 +
100371 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_hash_table_add_key_params_t));
100372 + if (copy_from_user(compat_param,
100373 + (ioc_compat_fm_pcd_hash_table_add_key_params_t*) compat_ptr(arg),
100374 + sizeof(ioc_compat_fm_pcd_hash_table_add_key_params_t)))
100375 + {
100376 + XX_Free(compat_param);
100377 + XX_Free(param);
100378 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100379 + }
100380 +
100381 + if (compat_param->key_size)
100382 + {
100383 + param->p_hash_tbl = compat_pcd_id2ptr(compat_param->p_hash_tbl);
100384 + param->key_size = compat_param->key_size;
100385 +
100386 + compat_copy_fm_pcd_cc_key(&compat_param->key_params, &param->key_params, COMPAT_US_TO_K);
100387 + }
100388 + else
100389 + {
100390 + XX_Free(compat_param);
100391 + XX_Free(param);
100392 + err = E_INVALID_VALUE;
100393 + break;
100394 + }
100395 +
100396 + XX_Free(compat_param);
100397 + }
100398 + else
100399 +#endif
100400 + {
100401 + if (copy_from_user(param, (ioc_fm_pcd_hash_table_add_key_params_t*) arg,
100402 + sizeof(ioc_fm_pcd_hash_table_add_key_params_t)))
100403 + {
100404 + XX_Free(param);
100405 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100406 + }
100407 + }
100408 +
100409 + if (param->key_size)
100410 + {
100411 + int size = 0;
100412 +
100413 + if (param->key_params.p_key) size += param->key_size;
100414 + if (param->key_params.p_mask) size += param->key_size;
100415 +
100416 + if (size)
100417 + {
100418 + uint8_t *p_tmp;
100419 +
100420 + p_tmp = (uint8_t*) XX_Malloc(size);
100421 + if (!p_tmp)
100422 + {
100423 + XX_Free(param);
100424 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD key/mask"));
100425 + }
100426 +
100427 + if (param->key_params.p_key)
100428 + {
100429 + if (copy_from_user(p_tmp, param->key_params.p_key, param->key_size))
100430 + {
100431 + XX_Free(p_tmp);
100432 + XX_Free(param);
100433 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100434 + }
100435 +
100436 + param->key_params.p_key = p_tmp;
100437 + }
100438 +
100439 + if (param->key_params.p_mask)
100440 + {
100441 + p_tmp += param->key_size;
100442 + if (copy_from_user(p_tmp, param->key_params.p_mask, param->key_size))
100443 + {
100444 + XX_Free(p_tmp - param->key_size);
100445 + XX_Free(param);
100446 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100447 + }
100448 +
100449 + param->key_params.p_mask = p_tmp;
100450 + }
100451 + }
100452 + }
100453 +
100454 + err = FM_PCD_HashTableAddKey(
100455 + param->p_hash_tbl,
100456 + param->key_size,
100457 + (t_FmPcdCcKeyParams*)&param->key_params);
100458 +
100459 + if (param->key_params.p_key)
100460 + XX_Free(param->key_params.p_key);
100461 + XX_Free(param);
100462 + break;
100463 + }
100464 +
100465 +#if defined(CONFIG_COMPAT)
100466 + case FM_PCD_IOC_HASH_TABLE_REMOVE_KEY_COMPAT:
100467 +#endif
100468 + case FM_PCD_IOC_HASH_TABLE_REMOVE_KEY:
100469 + {
100470 + ioc_fm_pcd_hash_table_remove_key_params_t *param = NULL;
100471 +
100472 + param = (ioc_fm_pcd_hash_table_remove_key_params_t*) XX_Malloc(
100473 + sizeof(ioc_fm_pcd_hash_table_remove_key_params_t));
100474 + if (!param)
100475 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100476 +
100477 + memset(param, 0, sizeof(ioc_fm_pcd_hash_table_remove_key_params_t));
100478 +
100479 +#if defined(CONFIG_COMPAT)
100480 + if (compat)
100481 + {
100482 + ioc_compat_fm_pcd_hash_table_remove_key_params_t *compat_param;
100483 +
100484 + compat_param = (ioc_compat_fm_pcd_hash_table_remove_key_params_t*) XX_Malloc(
100485 + sizeof(ioc_compat_fm_pcd_hash_table_remove_key_params_t));
100486 + if (!compat_param)
100487 + {
100488 + XX_Free(param);
100489 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100490 + }
100491 +
100492 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_hash_table_remove_key_params_t));
100493 + if (copy_from_user(compat_param,
100494 + (ioc_compat_fm_pcd_hash_table_remove_key_params_t*) compat_ptr(arg),
100495 + sizeof(ioc_compat_fm_pcd_hash_table_remove_key_params_t)))
100496 + {
100497 + XX_Free(compat_param);
100498 + XX_Free(param);
100499 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100500 + }
100501 +
100502 + param->p_hash_tbl = compat_pcd_id2ptr(compat_param->p_hash_tbl);
100503 + param->key_size = compat_param->key_size;
100504 +
100505 + XX_Free(compat_param);
100506 + }
100507 + else
100508 +#endif
100509 + {
100510 + if (copy_from_user(param, (ioc_fm_pcd_hash_table_remove_key_params_t*)arg,
100511 + sizeof(ioc_fm_pcd_hash_table_remove_key_params_t)))
100512 + {
100513 + XX_Free(param);
100514 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100515 + }
100516 + }
100517 +
100518 + if (param->key_size)
100519 + {
100520 + uint8_t *p_key;
100521 +
100522 + p_key = (uint8_t*) XX_Malloc(param->key_size);
100523 + if (!p_key)
100524 + {
100525 + XX_Free(param);
100526 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100527 + }
100528 +
100529 + if (param->p_key && copy_from_user(p_key, param->p_key, param->key_size))
100530 + {
100531 + XX_Free(p_key);
100532 + XX_Free(param);
100533 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100534 + }
100535 + param->p_key = p_key;
100536 + }
100537 +
100538 + err = FM_PCD_HashTableRemoveKey(
100539 + param->p_hash_tbl,
100540 + param->key_size,
100541 + param->p_key);
100542 +
100543 + if (param->p_key)
100544 + XX_Free(param->p_key);
100545 + XX_Free(param);
100546 + break;
100547 + }
100548 +
100549 +#if defined(CONFIG_COMPAT)
100550 + case FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY_COMPAT:
100551 +#endif
100552 + case FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY:
100553 + {
100554 + ioc_fm_pcd_cc_node_modify_key_params_t *param;
100555 +
100556 + param = (ioc_fm_pcd_cc_node_modify_key_params_t *) XX_Malloc(
100557 + sizeof(ioc_fm_pcd_cc_node_modify_key_params_t));
100558 + if (!param)
100559 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100560 +
100561 + memset(param, 0, sizeof(ioc_fm_pcd_cc_node_modify_key_params_t));
100562 +
100563 +#if defined(CONFIG_COMPAT)
100564 + if (compat)
100565 + {
100566 + ioc_compat_fm_pcd_cc_node_modify_key_params_t *compat_param;
100567 +
100568 + compat_param = (ioc_compat_fm_pcd_cc_node_modify_key_params_t *) XX_Malloc(
100569 + sizeof(ioc_compat_fm_pcd_cc_node_modify_key_params_t));
100570 + if (!compat_param)
100571 + {
100572 + XX_Free(param);
100573 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100574 + }
100575 +
100576 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_cc_node_modify_key_params_t));
100577 + if (copy_from_user(compat_param, (ioc_compat_fm_pcd_cc_node_modify_key_params_t *)compat_ptr(arg),
100578 + sizeof(ioc_compat_fm_pcd_cc_node_modify_key_params_t)))
100579 + {
100580 + XX_Free(compat_param);
100581 + XX_Free(param);
100582 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100583 + }
100584 +
100585 + compat_copy_fm_pcd_cc_node_modify_key(compat_param, param, COMPAT_US_TO_K);
100586 +
100587 + XX_Free(compat_param);
100588 + }
100589 + else
100590 +#endif
100591 + {
100592 + if (copy_from_user(param, (ioc_fm_pcd_cc_node_modify_key_params_t *)arg,
100593 + sizeof(ioc_fm_pcd_cc_node_modify_key_params_t)))
100594 + {
100595 + XX_Free(param);
100596 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100597 + }
100598 + }
100599 +
100600 + if (param->key_size)
100601 + {
100602 + int size = 0;
100603 +
100604 + if (param->p_key) size += param->key_size;
100605 + if (param->p_mask) size += param->key_size;
100606 +
100607 + if (size)
100608 + {
100609 + uint8_t *p_tmp;
100610 +
100611 + p_tmp = (uint8_t*) XX_Malloc(size);
100612 + if (!p_tmp)
100613 + {
100614 + XX_Free(param);
100615 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD key/mask"));
100616 + }
100617 +
100618 + if (param->p_key)
100619 + {
100620 + if (copy_from_user(p_tmp, param->p_key, param->key_size))
100621 + {
100622 + XX_Free(p_tmp);
100623 + XX_Free(param);
100624 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100625 + }
100626 +
100627 + param->p_key = p_tmp;
100628 + }
100629 +
100630 + if (param->p_mask)
100631 + {
100632 + p_tmp += param->key_size;
100633 + if (copy_from_user(p_tmp, param->p_mask, param->key_size))
100634 + {
100635 + XX_Free(p_tmp - param->key_size);
100636 + XX_Free(param);
100637 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100638 + }
100639 +
100640 + param->p_mask = p_tmp;
100641 + }
100642 + }
100643 + }
100644 +
100645 + err = FM_PCD_MatchTableModifyKey(param->id,
100646 + param->key_indx,
100647 + param->key_size,
100648 + param->p_key,
100649 + param->p_mask);
100650 +
100651 + if (param->p_key)
100652 + XX_Free(param->p_key);
100653 + else if (param->p_mask)
100654 + XX_Free(param->p_mask);
100655 + XX_Free(param);
100656 + break;
100657 + }
100658 +
100659 +#if defined(CONFIG_COMPAT)
100660 + case FM_PCD_IOC_MANIP_NODE_SET_COMPAT:
100661 +#endif
100662 + case FM_PCD_IOC_MANIP_NODE_SET:
100663 + {
100664 + ioc_fm_pcd_manip_params_t *param;
100665 + uint8_t *p_data = NULL;
100666 + uint8_t size;
100667 +
100668 + param = (ioc_fm_pcd_manip_params_t *) XX_Malloc(
100669 + sizeof(ioc_fm_pcd_manip_params_t));
100670 +
100671 + if (!param)
100672 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100673 +
100674 + memset(param, 0, sizeof(ioc_fm_pcd_manip_params_t));
100675 +
100676 +#if defined(CONFIG_COMPAT)
100677 + if (compat)
100678 + {
100679 + ioc_compat_fm_pcd_manip_params_t *compat_param;
100680 +
100681 + compat_param = (ioc_compat_fm_pcd_manip_params_t *) XX_Malloc(
100682 + sizeof(ioc_compat_fm_pcd_manip_params_t));
100683 + if (!compat_param)
100684 + {
100685 + XX_Free(param);
100686 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100687 + }
100688 +
100689 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_manip_params_t));
100690 + if (copy_from_user(compat_param,
100691 + (ioc_compat_fm_pcd_manip_params_t *) compat_ptr(arg),
100692 + sizeof(ioc_compat_fm_pcd_manip_params_t)))
100693 + {
100694 + XX_Free(compat_param);
100695 + XX_Free(param);
100696 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100697 + }
100698 +
100699 + compat_fm_pcd_manip_set_node(compat_param, param, COMPAT_US_TO_K);
100700 +
100701 + XX_Free(compat_param);
100702 + }
100703 + else
100704 +#endif
100705 + {
100706 + if (copy_from_user(param, (ioc_fm_pcd_manip_params_t *)arg,
100707 + sizeof(ioc_fm_pcd_manip_params_t)))
100708 + {
100709 + XX_Free(param);
100710 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100711 + }
100712 + }
100713 +
100714 + if (param->type == e_IOC_FM_PCD_MANIP_HDR)
100715 + {
100716 + size = param->u.hdr.insrt_params.u.generic.size;
100717 + p_data = (uint8_t *) XX_Malloc(size);
100718 + if (!p_data )
100719 + {
100720 + XX_Free(param);
100721 + RETURN_ERROR(MINOR, E_NO_MEMORY, NO_MSG);
100722 + }
100723 +
100724 + if (param->u.hdr.insrt_params.u.generic.p_data &&
100725 + copy_from_user(p_data,
100726 + param->u.hdr.insrt_params.u.generic.p_data, size))
100727 + {
100728 + XX_Free(p_data);
100729 + XX_Free(param);
100730 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100731 + }
100732 +
100733 + param->u.hdr.insrt_params.u.generic.p_data = p_data;
100734 + }
100735 +
100736 + if (param->id)
100737 + {
100738 + /* Security Hole: the user can pass any piece of garbage
100739 + in 'param->id', and that will go straight through to the LLD,
100740 + no checks being done by the wrapper! */
100741 + err = FM_PCD_ManipNodeReplace(
100742 + (t_Handle) param->id,
100743 + (t_FmPcdManipParams*) param);
100744 + if (err)
100745 + {
100746 + if (p_data)
100747 + XX_Free(p_data);
100748 + XX_Free(param);
100749 + break;
100750 + }
100751 + }
100752 + else
100753 + {
100754 + param->id = FM_PCD_ManipNodeSet(
100755 + p_LnxWrpFmDev->h_PcdDev,
100756 + (t_FmPcdManipParams*) param);
100757 + if (!param->id)
100758 + {
100759 + if (p_data)
100760 + XX_Free(p_data);
100761 + XX_Free(param);
100762 + err = E_INVALID_VALUE;
100763 + /* Since the LLD has no errno-style error reporting,
100764 + we're left here with no other option than to report
100765 + a generic E_INVALID_VALUE */
100766 + break;
100767 + }
100768 + }
100769 +
100770 +#if defined(CONFIG_COMPAT)
100771 + if (compat)
100772 + {
100773 + ioc_compat_fm_pcd_manip_params_t *compat_param;
100774 +
100775 + compat_param = (ioc_compat_fm_pcd_manip_params_t *) XX_Malloc(
100776 + sizeof(ioc_compat_fm_pcd_manip_params_t));
100777 + if (!compat_param)
100778 + {
100779 + if (p_data)
100780 + XX_Free(p_data);
100781 + XX_Free(param);
100782 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100783 + }
100784 +
100785 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_manip_params_t));
100786 +
100787 + compat_fm_pcd_manip_set_node(compat_param, param, COMPAT_K_TO_US);
100788 +
100789 + if (copy_to_user((ioc_compat_fm_pcd_manip_params_t *) compat_ptr(arg),
100790 + compat_param,
100791 + sizeof(ioc_compat_fm_pcd_manip_params_t)))
100792 + err = E_READ_FAILED;
100793 +
100794 + XX_Free(compat_param);
100795 + }
100796 + else
100797 +#endif
100798 + {
100799 + if (copy_to_user((ioc_fm_pcd_manip_params_t *)arg,
100800 + param, sizeof(ioc_fm_pcd_manip_params_t)))
100801 + err = E_READ_FAILED;
100802 + }
100803 +
100804 + if (p_data)
100805 + XX_Free(p_data);
100806 + XX_Free(param);
100807 + break;
100808 + }
100809 +
100810 +#if defined(CONFIG_COMPAT)
100811 + case FM_PCD_IOC_MANIP_NODE_DELETE_COMPAT:
100812 +#endif
100813 + case FM_PCD_IOC_MANIP_NODE_DELETE:
100814 + {
100815 + ioc_fm_obj_t id;
100816 +
100817 + memset(&id, 0, sizeof(ioc_fm_obj_t));
100818 +#if defined(CONFIG_COMPAT)
100819 + if (compat)
100820 + {
100821 + ioc_compat_fm_obj_t compat_id;
100822 +
100823 + if (copy_from_user(&compat_id, (ioc_compat_fm_obj_t *) compat_ptr(arg), sizeof(ioc_compat_fm_obj_t)))
100824 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100825 +
100826 + compat_obj_delete(&compat_id, &id);
100827 + }
100828 + else
100829 +#endif
100830 + {
100831 + if (copy_from_user(&id, (ioc_fm_obj_t *) arg, sizeof(ioc_fm_obj_t)))
100832 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100833 + }
100834 +
100835 + err = FM_PCD_ManipNodeDelete(id.obj);
100836 + break;
100837 + }
100838 +
100839 +#if defined(CONFIG_COMPAT)
100840 + case FM_PCD_IOC_MANIP_GET_STATS_COMPAT:
100841 +#endif
100842 + case FM_PCD_IOC_MANIP_GET_STATS:
100843 + {
100844 + ioc_fm_pcd_manip_get_stats_t param;
100845 +
100846 +#if defined(CONFIG_COMPAT)
100847 + if (compat)
100848 + {
100849 + ioc_compat_fm_pcd_manip_get_stats_t *compat_param;
100850 +
100851 + compat_param = (ioc_compat_fm_pcd_manip_get_stats_t *) XX_Malloc(
100852 + sizeof(ioc_compat_fm_pcd_manip_get_stats_t));
100853 + if (!compat_param)
100854 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100855 +
100856 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_manip_get_stats_t));
100857 + if (copy_from_user(compat_param,
100858 + (ioc_compat_fm_pcd_manip_get_stats_t *)compat_ptr(arg),
100859 + sizeof(ioc_compat_fm_pcd_manip_get_stats_t)))
100860 + {
100861 + XX_Free(compat_param);
100862 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100863 + }
100864 +
100865 + compat_copy_fm_pcd_manip_get_stats(compat_param, &param, COMPAT_US_TO_K);
100866 +
100867 + XX_Free(compat_param);
100868 + }
100869 + else
100870 +#endif
100871 + {
100872 + if (copy_from_user(&param, (ioc_fm_pcd_manip_get_stats_t *)arg,
100873 + sizeof(ioc_fm_pcd_manip_get_stats_t)))
100874 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
100875 + }
100876 +
100877 + err = FM_PCD_ManipGetStatistics((t_Handle) param.id,
100878 + (t_FmPcdManipStats*) &param.stats);
100879 +
100880 +#if defined(CONFIG_COMPAT)
100881 + if (compat)
100882 + {
100883 + ioc_compat_fm_pcd_manip_get_stats_t *compat_param;
100884 +
100885 + compat_param = (ioc_compat_fm_pcd_manip_get_stats_t*) XX_Malloc(
100886 + sizeof(ioc_compat_fm_pcd_manip_get_stats_t));
100887 + if (!compat_param)
100888 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100889 +
100890 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_manip_get_stats_t));
100891 + compat_copy_fm_pcd_manip_get_stats(compat_param, &param, COMPAT_K_TO_US);
100892 + if (copy_to_user((ioc_compat_fm_pcd_manip_get_stats_t*) compat_ptr(arg),
100893 + compat_param,
100894 + sizeof(ioc_compat_fm_pcd_manip_get_stats_t))){
100895 + XX_Free(compat_param);
100896 + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG);
100897 + }
100898 + XX_Free(compat_param);
100899 + }
100900 + else
100901 +#endif
100902 + if (copy_to_user((ioc_fm_pcd_manip_get_stats_t *)arg,
100903 + &param,
100904 + sizeof(ioc_fm_pcd_manip_get_stats_t)))
100905 + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG);
100906 +
100907 + break;
100908 + }
100909 +
100910 +#if (DPAA_VERSION >= 11)
100911 +#if defined(CONFIG_COMPAT)
100912 + case FM_PCD_IOC_FRM_REPLIC_GROUP_SET_COMPAT:
100913 +#endif
100914 + case FM_PCD_IOC_FRM_REPLIC_GROUP_SET:
100915 + {
100916 + ioc_fm_pcd_frm_replic_group_params_t *param;
100917 +
100918 + param = (ioc_fm_pcd_frm_replic_group_params_t *) XX_Malloc(
100919 + sizeof(ioc_fm_pcd_frm_replic_group_params_t));
100920 + if (!param)
100921 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
100922 +
100923 + memset(param, 0, sizeof(ioc_fm_pcd_frm_replic_group_params_t));
100924 +
100925 +#if defined(CONFIG_COMPAT)
100926 + if (compat)
100927 + {
100928 + ioc_compat_fm_pcd_frm_replic_group_params_t
100929 + *compat_param;
100930 +
100931 + compat_param =
100932 + (ioc_compat_fm_pcd_frm_replic_group_params_t *)
100933 + XX_Malloc(sizeof(ioc_compat_fm_pcd_frm_replic_group_params_t));
100934 + if (!compat_param)
100935 + {
100936 + XX_Free(param);
100937 + RETURN_ERROR(MINOR, E_NO_MEMORY,
100938 + ("IOCTL FM PCD"));
100939 + }
100940 +
100941 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_frm_replic_group_params_t));
100942 + if (copy_from_user(compat_param,
100943 + (ioc_compat_fm_pcd_frm_replic_group_params_t *)
100944 + compat_ptr(arg),
100945 + sizeof(ioc_compat_fm_pcd_frm_replic_group_params_t))) {
100946 + XX_Free(compat_param);
100947 + XX_Free(param);
100948 + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG);
100949 + }
100950 +
100951 + compat_copy_fm_pcd_frm_replic_group_params(compat_param,
100952 + param, COMPAT_US_TO_K);
100953 +
100954 + XX_Free(compat_param);
100955 + }
100956 + else
100957 +#endif
100958 + {
100959 + if (copy_from_user(param,
100960 + (ioc_fm_pcd_frm_replic_group_params_t *)arg,
100961 + sizeof(ioc_fm_pcd_frm_replic_group_params_t)))
100962 + {
100963 + XX_Free(param);
100964 + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG);
100965 + }
100966 + }
100967 +
100968 + param->id = FM_PCD_FrmReplicSetGroup(p_LnxWrpFmDev->h_PcdDev,
100969 + (t_FmPcdFrmReplicGroupParams*)param);
100970 +
100971 + if (!param->id) {
100972 + XX_Free(param);
100973 + err = E_INVALID_VALUE;
100974 + /*
100975 + * Since the LLD has no errno-style error reporting,
100976 + * we're left here with no other option than to report
100977 + * a generic E_INVALID_VALUE
100978 + */
100979 + break;
100980 + }
100981 +
100982 +#if defined(CONFIG_COMPAT)
100983 + if (compat)
100984 + {
100985 + ioc_compat_fm_pcd_frm_replic_group_params_t
100986 + *compat_param;
100987 +
100988 + compat_param =
100989 + (ioc_compat_fm_pcd_frm_replic_group_params_t *)
100990 + XX_Malloc(sizeof(ioc_compat_fm_pcd_frm_replic_group_params_t));
100991 + if (!compat_param)
100992 + {
100993 + XX_Free(param);
100994 + RETURN_ERROR(MINOR, E_NO_MEMORY,
100995 + ("IOCTL FM PCD"));
100996 + }
100997 +
100998 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_frm_replic_group_params_t));
100999 + compat_copy_fm_pcd_frm_replic_group_params(compat_param,
101000 + param, COMPAT_K_TO_US);
101001 + if (copy_to_user(
101002 + (ioc_compat_fm_pcd_frm_replic_group_params_t *)
101003 + compat_ptr(arg),
101004 + compat_param,
101005 + sizeof(ioc_compat_fm_pcd_frm_replic_group_params_t)))
101006 + err = E_WRITE_FAILED;
101007 +
101008 + XX_Free(compat_param);
101009 + }
101010 + else
101011 +#endif
101012 + {
101013 + if (copy_to_user(
101014 + (ioc_fm_pcd_frm_replic_group_params_t *)arg,
101015 + param,
101016 + sizeof(ioc_fm_pcd_frm_replic_group_params_t)))
101017 + err = E_WRITE_FAILED;
101018 + }
101019 +
101020 + XX_Free(param);
101021 + break;
101022 + }
101023 + break;
101024 +
101025 +#if defined(CONFIG_COMPAT)
101026 + case FM_PCD_IOC_FRM_REPLIC_GROUP_DELETE_COMPAT:
101027 +#endif
101028 + case FM_PCD_IOC_FRM_REPLIC_GROUP_DELETE:
101029 + {
101030 + ioc_fm_obj_t id;
101031 +
101032 + memset(&id, 0, sizeof(ioc_fm_obj_t));
101033 +#if defined(CONFIG_COMPAT)
101034 + if (compat)
101035 + {
101036 + ioc_compat_fm_obj_t compat_id;
101037 +
101038 + if (copy_from_user(&compat_id,
101039 + (ioc_compat_fm_obj_t *) compat_ptr(arg),
101040 + sizeof(ioc_compat_fm_obj_t)))
101041 + break;
101042 + compat_obj_delete(&compat_id, &id);
101043 + }
101044 + else
101045 +#endif
101046 + {
101047 + if (copy_from_user(&id, (ioc_fm_obj_t *) arg,
101048 + sizeof(ioc_fm_obj_t)))
101049 + break;
101050 + }
101051 +
101052 + return FM_PCD_FrmReplicDeleteGroup(id.obj);
101053 + }
101054 + break;
101055 +
101056 +#if defined(CONFIG_COMPAT)
101057 + case FM_PCD_IOC_FRM_REPLIC_MEMBER_ADD_COMPAT:
101058 +#endif
101059 + case FM_PCD_IOC_FRM_REPLIC_MEMBER_ADD:
101060 + {
101061 + ioc_fm_pcd_frm_replic_member_params_t param;
101062 +
101063 +#if defined(CONFIG_COMPAT)
101064 + if (compat)
101065 + {
101066 + ioc_compat_fm_pcd_frm_replic_member_params_t compat_param;
101067 +
101068 + if (copy_from_user(&compat_param, compat_ptr(arg), sizeof(compat_param)))
101069 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101070 +
101071 + compat_copy_fm_pcd_frm_replic_member_params(&compat_param, &param, COMPAT_US_TO_K);
101072 + }
101073 + else
101074 +#endif
101075 + if (copy_from_user(&param, (void *)arg, sizeof(param)))
101076 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101077 +
101078 + return FM_PCD_FrmReplicAddMember(param.member.h_replic_group,
101079 + param.member.member_index,
101080 + (t_FmPcdCcNextEngineParams*)&param.next_engine_params);
101081 + }
101082 + break;
101083 +
101084 +#if defined(CONFIG_COMPAT)
101085 + case FM_PCD_IOC_FRM_REPLIC_MEMBER_REMOVE_COMPAT:
101086 +#endif
101087 + case FM_PCD_IOC_FRM_REPLIC_MEMBER_REMOVE:
101088 + {
101089 + ioc_fm_pcd_frm_replic_member_t param;
101090 +
101091 +#if defined(CONFIG_COMPAT)
101092 + if (compat)
101093 + {
101094 + ioc_compat_fm_pcd_frm_replic_member_t compat_param;
101095 +
101096 + if (copy_from_user(&compat_param, compat_ptr(arg), sizeof(compat_param)))
101097 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101098 +
101099 + compat_copy_fm_pcd_frm_replic_member(&compat_param, &param, COMPAT_US_TO_K);
101100 + }
101101 + else
101102 +#endif
101103 + if (copy_from_user(&param, (void *)arg, sizeof(param)))
101104 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101105 +
101106 + return FM_PCD_FrmReplicRemoveMember(param.h_replic_group, param.member_index);
101107 + }
101108 + break;
101109 +
101110 +#if defined(CONFIG_COMPAT)
101111 + case FM_IOC_VSP_CONFIG_COMPAT:
101112 +#endif
101113 + case FM_IOC_VSP_CONFIG:
101114 + {
101115 + ioc_fm_vsp_params_t param;
101116 +
101117 +#if defined(CONFIG_COMPAT)
101118 + if (compat)
101119 + {
101120 + ioc_compat_fm_vsp_params_t compat_param;
101121 +
101122 + if (copy_from_user(&compat_param, compat_ptr(arg), sizeof(compat_param)))
101123 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101124 +
101125 + compat_copy_fm_vsp_params(&compat_param, &param, COMPAT_US_TO_K);
101126 + }
101127 + else
101128 +#endif
101129 + if (copy_from_user(&param, (void *)arg, sizeof(param)))
101130 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101131 + {
101132 + uint8_t portId = param.port_params.port_id;
101133 + param.p_fm = p_LnxWrpFmDev->h_Dev;
101134 + param.liodn_offset =
101135 + p_LnxWrpFmDev->rxPorts[portId].settings.param.specificParams.rxParams.liodnOffset;
101136 + }
101137 + param.id = FM_VSP_Config((t_FmVspParams *)&param);
101138 +
101139 +#if defined(CONFIG_COMPAT)
101140 + if (compat)
101141 + {
101142 + ioc_compat_fm_vsp_params_t compat_param;
101143 +
101144 + memset(&compat_param, 0, sizeof(compat_param));
101145 + compat_copy_fm_vsp_params(&compat_param, &param, COMPAT_K_TO_US);
101146 +
101147 + if (copy_to_user(compat_ptr(arg), &compat_param, sizeof(compat_param)))
101148 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101149 + }
101150 + else
101151 +#endif
101152 + if (copy_to_user((void *)arg, &param, sizeof(param)))
101153 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101154 + break;
101155 + }
101156 +
101157 +#if defined(CONFIG_COMPAT)
101158 + case FM_IOC_VSP_INIT_COMPAT:
101159 +#endif
101160 + case FM_IOC_VSP_INIT:
101161 + {
101162 + ioc_fm_obj_t id;
101163 +
101164 + memset(&id, 0, sizeof(ioc_fm_obj_t));
101165 +#if defined(CONFIG_COMPAT)
101166 + if (compat)
101167 + {
101168 + ioc_compat_fm_obj_t compat_id;
101169 +
101170 + if (copy_from_user(&compat_id,
101171 + (ioc_compat_fm_obj_t *) compat_ptr(arg),
101172 + sizeof(ioc_compat_fm_obj_t)))
101173 + break;
101174 + id.obj = compat_pcd_id2ptr(compat_id.obj);
101175 + }
101176 + else
101177 +#endif
101178 + {
101179 + if (copy_from_user(&id, (ioc_fm_obj_t *) arg,
101180 + sizeof(ioc_fm_obj_t)))
101181 + break;
101182 + }
101183 +
101184 + return FM_VSP_Init(id.obj);
101185 + }
101186 +
101187 +#if defined(CONFIG_COMPAT)
101188 + case FM_IOC_VSP_FREE_COMPAT:
101189 +#endif
101190 + case FM_IOC_VSP_FREE:
101191 + {
101192 + ioc_fm_obj_t id;
101193 +
101194 + memset(&id, 0, sizeof(ioc_fm_obj_t));
101195 +#if defined(CONFIG_COMPAT)
101196 + if (compat)
101197 + {
101198 + ioc_compat_fm_obj_t compat_id;
101199 +
101200 + if (copy_from_user(&compat_id,
101201 + (ioc_compat_fm_obj_t *) compat_ptr(arg),
101202 + sizeof(ioc_compat_fm_obj_t)))
101203 + break;
101204 + compat_obj_delete(&compat_id, &id);
101205 + }
101206 + else
101207 +#endif
101208 + {
101209 + if (copy_from_user(&id, (ioc_fm_obj_t *) arg,
101210 + sizeof(ioc_fm_obj_t)))
101211 + break;
101212 + }
101213 +
101214 + return FM_VSP_Free(id.obj);
101215 + }
101216 +
101217 +#if defined(CONFIG_COMPAT)
101218 + case FM_IOC_VSP_CONFIG_POOL_DEPLETION_COMPAT:
101219 +#endif
101220 + case FM_IOC_VSP_CONFIG_POOL_DEPLETION:
101221 + {
101222 + ioc_fm_buf_pool_depletion_params_t param;
101223 +
101224 +#if defined(CONFIG_COMPAT)
101225 + if (compat)
101226 + {
101227 + ioc_compat_fm_buf_pool_depletion_params_t compat_param;
101228 +
101229 + if (copy_from_user(&compat_param, compat_ptr(arg), sizeof(compat_param)))
101230 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101231 +
101232 + compat_copy_fm_buf_pool_depletion_params(&compat_param, &param, COMPAT_US_TO_K);
101233 + }
101234 + else
101235 +#endif
101236 + if (copy_from_user(&param, (void *)arg, sizeof(param)))
101237 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101238 +
101239 + if (FM_VSP_ConfigPoolDepletion(param.p_fm_vsp,
101240 + (t_FmBufPoolDepletion *)&param.fm_buf_pool_depletion))
101241 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101242 +
101243 + break;
101244 + }
101245 +
101246 +
101247 +#if defined(CONFIG_COMPAT)
101248 + case FM_IOC_VSP_CONFIG_BUFFER_PREFIX_CONTENT_COMPAT:
101249 +#endif
101250 + case FM_IOC_VSP_CONFIG_BUFFER_PREFIX_CONTENT:
101251 + {
101252 + ioc_fm_buffer_prefix_content_params_t param;
101253 +
101254 +#if defined(CONFIG_COMPAT)
101255 + if (compat)
101256 + {
101257 + ioc_compat_fm_buffer_prefix_content_params_t compat_param;
101258 +
101259 + if (copy_from_user(&compat_param, compat_ptr(arg), sizeof(compat_param)))
101260 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101261 +
101262 + compat_copy_fm_buffer_prefix_content_params(&compat_param, &param, COMPAT_US_TO_K);
101263 + }
101264 + else
101265 +#endif
101266 + if (copy_from_user(&param, (void *)arg, sizeof(param)))
101267 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101268 +
101269 + if (FM_VSP_ConfigBufferPrefixContent(param.p_fm_vsp,
101270 + (t_FmBufferPrefixContent *)&param.fm_buffer_prefix_content))
101271 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101272 +
101273 + break;
101274 + }
101275 +
101276 +#if defined(CONFIG_COMPAT)
101277 + case FM_IOC_VSP_CONFIG_NO_SG_COMPAT:
101278 +#endif
101279 + case FM_IOC_VSP_CONFIG_NO_SG:
101280 + {
101281 + ioc_fm_vsp_config_no_sg_params_t param;
101282 +
101283 +#if defined(CONFIG_COMPAT)
101284 + if (compat)
101285 + {
101286 + ioc_compat_fm_vsp_config_no_sg_params_t compat_param;
101287 +
101288 + if (copy_from_user(&compat_param, compat_ptr(arg), sizeof(compat_param)))
101289 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101290 +
101291 + compat_copy_fm_vsp_config_no_sg_params(&compat_param, &param, COMPAT_US_TO_K);
101292 + }
101293 + else
101294 +#endif
101295 + if (copy_from_user(&param, (void *)arg, sizeof(param)))
101296 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101297 +
101298 + if (FM_VSP_ConfigNoScatherGather(param.p_fm_vsp, param.no_sg))
101299 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101300 +
101301 + break;
101302 + }
101303 +
101304 +#if defined(CONFIG_COMPAT)
101305 + case FM_IOC_VSP_GET_BUFFER_PRS_RESULT_COMPAT:
101306 +#endif
101307 + case FM_IOC_VSP_GET_BUFFER_PRS_RESULT:
101308 + {
101309 + ioc_fm_vsp_prs_result_params_t param;
101310 +
101311 +#if defined(CONFIG_COMPAT)
101312 + if (compat)
101313 + {
101314 + ioc_compat_fm_vsp_prs_result_params_t compat_param;
101315 +
101316 + if (copy_from_user(&compat_param, compat_ptr(arg), sizeof(compat_param)))
101317 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101318 +
101319 + compat_copy_fm_vsp_prs_result_params(&compat_param, &param, COMPAT_US_TO_K);
101320 + }
101321 + else
101322 +#endif
101323 + if (copy_from_user(&param, (void *)arg, sizeof(param)))
101324 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101325 +
101326 + /* this call just adds the parse results offset to p_data */
101327 + param.p_data = FM_VSP_GetBufferPrsResult(param.p_fm_vsp, param.p_data);
101328 +
101329 + if (!param.p_data)
101330 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101331 +
101332 +#if defined(CONFIG_COMPAT)
101333 + if (compat)
101334 + {
101335 + ioc_compat_fm_vsp_prs_result_params_t compat_param;
101336 +
101337 + memset(&compat_param, 0, sizeof(compat_param));
101338 + compat_copy_fm_vsp_prs_result_params(&compat_param, &param, COMPAT_K_TO_US);
101339 +
101340 + if (copy_to_user(compat_ptr(arg), &compat_param, sizeof(compat_param)))
101341 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101342 + }
101343 + else
101344 +#endif
101345 + if (copy_to_user((void *)arg, &param, sizeof(param)))
101346 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101347 +
101348 + break;
101349 + }
101350 +#endif /* (DPAA_VERSION >= 11) */
101351 +
101352 +#ifdef FM_CAPWAP_SUPPORT
101353 +#warning "feature not supported!"
101354 +#if defined(CONFIG_COMPAT)
101355 + case FM_PCD_IOC_STATISTICS_SET_NODE_COMPAT:
101356 +#endif
101357 + case FM_PCD_IOC_STATISTICS_SET_NODE:
101358 + {
101359 +/* ioc_fm_pcd_stats_params_t param;
101360 + ...
101361 + param->id = FM_PCD_StatisticsSetNode(p_LnxWrpFmDev->h_PcdDev,
101362 + (t_FmPcdStatsParams *)&param);
101363 +*/
101364 + err = E_NOT_SUPPORTED;
101365 + break;
101366 + }
101367 +#endif /* FM_CAPWAP_SUPPORT */
101368 +
101369 + default:
101370 + RETURN_ERROR(MINOR, E_INVALID_SELECTION,
101371 + ("invalid ioctl: cmd:0x%08x(type:0x%02x, nr: %d.\n",
101372 + cmd, _IOC_TYPE(cmd), _IOC_NR(cmd)));
101373 + }
101374 +
101375 + if (err)
101376 + RETURN_ERROR(MINOR, err, ("IOCTL FM PCD"));
101377 +
101378 + return E_OK;
101379 +}
101380 +
101381 +void FM_Get_Api_Version(ioc_fm_api_version_t *p_version)
101382 +{
101383 + p_version->version.major = FMD_API_VERSION_MAJOR;
101384 + p_version->version.minor = FMD_API_VERSION_MINOR;
101385 + p_version->version.respin = FMD_API_VERSION_RESPIN;
101386 + p_version->version.reserved = 0;
101387 +}
101388 +
101389 +t_Error LnxwrpFmIOCTL(t_LnxWrpFmDev *p_LnxWrpFmDev, unsigned int cmd, unsigned long arg, bool compat)
101390 +{
101391 + t_Error err = E_OK;
101392 +
101393 + switch (cmd)
101394 + {
101395 + case FM_IOC_SET_PORTS_BANDWIDTH:
101396 + {
101397 + ioc_fm_port_bandwidth_params *param;
101398 +
101399 + param = (ioc_fm_port_bandwidth_params*) XX_Malloc(sizeof(ioc_fm_port_bandwidth_params));
101400 + if (!param)
101401 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
101402 +
101403 + memset(param, 0, sizeof(ioc_fm_port_bandwidth_params));
101404 +
101405 +#if defined(CONFIG_COMPAT)
101406 + if (compat)
101407 + {
101408 + if (copy_from_user(param, (ioc_fm_port_bandwidth_params*)compat_ptr(arg), sizeof(ioc_fm_port_bandwidth_params)))
101409 + {
101410 + XX_Free(param);
101411 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101412 + }
101413 + }
101414 + else
101415 +#endif
101416 + {
101417 + if (copy_from_user(param, (ioc_fm_port_bandwidth_params*)arg, sizeof(ioc_fm_port_bandwidth_params)))
101418 + {
101419 + XX_Free(param);
101420 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101421 + }
101422 + }
101423 +
101424 + err = FM_SetPortsBandwidth(p_LnxWrpFmDev->h_Dev, (t_FmPortsBandwidthParams*) param);
101425 +
101426 + XX_Free(param);
101427 + break;
101428 + }
101429 +
101430 + case FM_IOC_GET_REVISION:
101431 + {
101432 + ioc_fm_revision_info_t *param;
101433 +
101434 + param = (ioc_fm_revision_info_t *) XX_Malloc(sizeof(ioc_fm_revision_info_t));
101435 + if (!param)
101436 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
101437 +
101438 + FM_GetRevision(p_LnxWrpFmDev->h_Dev, (t_FmRevisionInfo*)param);
101439 + /* This one never returns anything other than E_OK */
101440 +
101441 +#if defined(CONFIG_COMPAT)
101442 + if (compat)
101443 + {
101444 + if (copy_to_user((ioc_fm_revision_info_t *)compat_ptr(arg),
101445 + param,
101446 + sizeof(ioc_fm_revision_info_t))){
101447 + XX_Free(param);
101448 + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG);
101449 + }
101450 + }
101451 + else
101452 +#endif
101453 + {
101454 + if (copy_to_user((ioc_fm_revision_info_t *)arg,
101455 + param,
101456 + sizeof(ioc_fm_revision_info_t))){
101457 + XX_Free(param);
101458 + RETURN_ERROR(MINOR, E_READ_FAILED, NO_MSG);
101459 + }
101460 + }
101461 + XX_Free(param);
101462 + break;
101463 + }
101464 +
101465 + case FM_IOC_SET_COUNTER:
101466 + {
101467 + ioc_fm_counters_params_t *param;
101468 +
101469 + param = (ioc_fm_counters_params_t *) XX_Malloc(sizeof(ioc_fm_counters_params_t));
101470 + if (!param)
101471 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
101472 +
101473 + memset(param, 0, sizeof(ioc_fm_counters_params_t));
101474 +
101475 +#if defined(CONFIG_COMPAT)
101476 + if (compat)
101477 + {
101478 + if (copy_from_user(param, (ioc_fm_counters_params_t *)compat_ptr(arg), sizeof(ioc_fm_counters_params_t)))
101479 + {
101480 + XX_Free(param);
101481 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101482 + }
101483 + }
101484 + else
101485 +#endif
101486 + {
101487 + if (copy_from_user(param, (ioc_fm_counters_params_t *)arg, sizeof(ioc_fm_counters_params_t)))
101488 + {
101489 + XX_Free(param);
101490 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101491 + }
101492 + }
101493 +
101494 + err = FM_ModifyCounter(p_LnxWrpFmDev->h_Dev, param->cnt, param->val);
101495 +
101496 + XX_Free(param);
101497 + break;
101498 + }
101499 +
101500 + case FM_IOC_GET_COUNTER:
101501 + {
101502 + ioc_fm_counters_params_t *param;
101503 +
101504 + param = (ioc_fm_counters_params_t *) XX_Malloc(sizeof(ioc_fm_counters_params_t));
101505 + if (!param)
101506 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PCD"));
101507 +
101508 + memset(param, 0, sizeof(ioc_fm_counters_params_t));
101509 +
101510 +#if defined(CONFIG_COMPAT)
101511 + if (compat)
101512 + {
101513 + if (copy_from_user(param, (ioc_fm_counters_params_t *)compat_ptr(arg), sizeof(ioc_fm_counters_params_t)))
101514 + {
101515 + XX_Free(param);
101516 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101517 + }
101518 + }
101519 + else
101520 +#endif
101521 + {
101522 + if (copy_from_user(param, (ioc_fm_counters_params_t *)arg, sizeof(ioc_fm_counters_params_t)))
101523 + {
101524 + XX_Free(param);
101525 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101526 + }
101527 + }
101528 +
101529 + param->val = FM_GetCounter(p_LnxWrpFmDev->h_Dev, param->cnt);
101530 +
101531 +#if defined(CONFIG_COMPAT)
101532 + if (compat)
101533 + {
101534 + if (copy_to_user((ioc_fm_counters_params_t *)compat_ptr(arg), param, sizeof(ioc_fm_counters_params_t)))
101535 + err = E_READ_FAILED;
101536 + }
101537 + else
101538 +#endif
101539 + {
101540 + if (copy_to_user((ioc_fm_counters_params_t *)arg, param, sizeof(ioc_fm_counters_params_t)))
101541 + err = E_READ_FAILED;
101542 + }
101543 +
101544 + XX_Free(param);
101545 + break;
101546 + }
101547 +
101548 + case FM_IOC_FORCE_INTR:
101549 + {
101550 + ioc_fm_exceptions param;
101551 +
101552 +#if defined(CONFIG_COMPAT)
101553 + if (compat)
101554 + {
101555 + if (get_user(param, (ioc_fm_exceptions*) compat_ptr(arg)))
101556 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101557 + }
101558 + else
101559 +#endif
101560 + {
101561 + if (get_user(param, (ioc_fm_exceptions*)arg))
101562 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101563 + }
101564 +
101565 + err = FM_ForceIntr(p_LnxWrpFmDev->h_Dev, (e_FmExceptions)param);
101566 + break;
101567 + }
101568 +
101569 + case FM_IOC_GET_API_VERSION:
101570 + {
101571 + ioc_fm_api_version_t version;
101572 +
101573 + FM_Get_Api_Version(&version);
101574 +
101575 +#if defined(CONFIG_COMPAT)
101576 + if (compat)
101577 + {
101578 + if (copy_to_user(
101579 + (ioc_fm_api_version_t *)compat_ptr(arg),
101580 + &version, sizeof(version)))
101581 + err = E_READ_FAILED;
101582 + }
101583 + else
101584 +#endif
101585 + {
101586 + if (copy_to_user((ioc_fm_api_version_t *)arg,
101587 + &version, sizeof(version)))
101588 + err = E_READ_FAILED;
101589 + }
101590 + }
101591 + break;
101592 +
101593 + case FM_IOC_CTRL_MON_START:
101594 + {
101595 + FM_CtrlMonStart(p_LnxWrpFmDev->h_Dev);
101596 + }
101597 + break;
101598 +
101599 + case FM_IOC_CTRL_MON_STOP:
101600 + {
101601 + FM_CtrlMonStop(p_LnxWrpFmDev->h_Dev);
101602 + }
101603 + break;
101604 +
101605 +#if defined(CONFIG_COMPAT)
101606 + case FM_IOC_CTRL_MON_GET_COUNTERS_COMPAT:
101607 +#endif
101608 + case FM_IOC_CTRL_MON_GET_COUNTERS:
101609 + {
101610 + ioc_fm_ctrl_mon_counters_params_t param;
101611 + t_FmCtrlMon mon;
101612 +
101613 +#if defined(CONFIG_COMPAT)
101614 + ioc_compat_fm_ctrl_mon_counters_params_t compat_param;
101615 +
101616 + if (compat)
101617 + {
101618 + if (copy_from_user(&compat_param, (void *)compat_ptr(arg),
101619 + sizeof(compat_param)))
101620 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101621 +
101622 + param.fm_ctrl_index = compat_param.fm_ctrl_index;
101623 + param.p_mon = (fm_ctrl_mon_t *)compat_ptr(compat_param.p_mon);
101624 + }
101625 + else
101626 +#endif
101627 + {
101628 + if (copy_from_user(&param, (void *)arg, sizeof(ioc_fm_ctrl_mon_counters_params_t)))
101629 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101630 + }
101631 +
101632 + if (FM_CtrlMonGetCounters(p_LnxWrpFmDev->h_Dev, param.fm_ctrl_index, &mon))
101633 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101634 +
101635 + if (copy_to_user(param.p_mon, &mon, sizeof(t_FmCtrlMon)))
101636 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101637 + }
101638 + break;
101639 +
101640 + default:
101641 + return LnxwrpFmPcdIOCTL(p_LnxWrpFmDev, cmd, arg, compat);
101642 + }
101643 +
101644 + if (err)
101645 + RETURN_ERROR(MINOR, E_INVALID_OPERATION, ("IOCTL FM"));
101646 +
101647 + return E_OK;
101648 +}
101649 +
101650 +t_Error LnxwrpFmPortIOCTL(t_LnxWrpFmPortDev *p_LnxWrpFmPortDev, unsigned int cmd, unsigned long arg, bool compat)
101651 +{
101652 + t_Error err = E_OK;
101653 +
101654 + _fm_ioctl_dbg("cmd:0x%08x(type:0x%02x, nr:%u).\n",
101655 + cmd, _IOC_TYPE(cmd), _IOC_NR(cmd) - 70);
101656 +
101657 + switch (cmd)
101658 + {
101659 + case FM_PORT_IOC_DISABLE:
101660 + FM_PORT_Disable(p_LnxWrpFmPortDev->h_Dev);
101661 + /* deliberately ignoring error codes here */
101662 + return E_OK;
101663 +
101664 + case FM_PORT_IOC_ENABLE:
101665 + FM_PORT_Enable(p_LnxWrpFmPortDev->h_Dev);
101666 + /* deliberately ignoring error codes here */
101667 + return E_OK;
101668 +
101669 + case FM_PORT_IOC_SET_ERRORS_ROUTE:
101670 + {
101671 + ioc_fm_port_frame_err_select_t errs;
101672 +
101673 +#if defined(CONFIG_COMPAT)
101674 + if (compat)
101675 + {
101676 + if (get_user(errs, (ioc_fm_port_frame_err_select_t*)compat_ptr(arg)))
101677 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101678 + }
101679 + else
101680 +#endif
101681 + {
101682 + if (get_user(errs, (ioc_fm_port_frame_err_select_t*)arg))
101683 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101684 + }
101685 +
101686 + err = FM_PORT_SetErrorsRoute(p_LnxWrpFmPortDev->h_Dev, (fmPortFrameErrSelect_t)errs);
101687 + break;
101688 + }
101689 +
101690 + case FM_PORT_IOC_SET_RATE_LIMIT:
101691 + {
101692 + ioc_fm_port_rate_limit_t *param;
101693 +
101694 + param = (ioc_fm_port_rate_limit_t *) XX_Malloc(sizeof(ioc_fm_port_rate_limit_t));
101695 + if (!param)
101696 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PORT"));
101697 +
101698 + memset(param, 0, sizeof(ioc_fm_port_rate_limit_t));
101699 +
101700 +#if defined(CONFIG_COMPAT)
101701 + if (compat)
101702 + {
101703 + if (copy_from_user(param, (ioc_fm_port_rate_limit_t *)compat_ptr(arg), sizeof(ioc_fm_port_rate_limit_t)))
101704 + {
101705 + XX_Free(param);
101706 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101707 + }
101708 + }
101709 + else
101710 +#endif
101711 + {
101712 + if (copy_from_user(param, (ioc_fm_port_rate_limit_t *)arg, sizeof(ioc_fm_port_rate_limit_t)))
101713 + {
101714 + XX_Free(param);
101715 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101716 + }
101717 + }
101718 +
101719 + err = FM_PORT_SetRateLimit(p_LnxWrpFmPortDev->h_Dev, (t_FmPortRateLimit *)param);
101720 +
101721 + XX_Free(param);
101722 + break;
101723 + }
101724 +
101725 + case FM_PORT_IOC_REMOVE_RATE_LIMIT:
101726 + FM_PORT_DeleteRateLimit(p_LnxWrpFmPortDev->h_Dev);
101727 + /* deliberately ignoring error codes here */
101728 + return E_OK;
101729 +
101730 + case FM_PORT_IOC_ALLOC_PCD_FQIDS:
101731 + {
101732 + ioc_fm_port_pcd_fqids_params_t *param;
101733 +
101734 + if (!p_LnxWrpFmPortDev->pcd_owner_params.cba)
101735 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("No one to listen on this PCD!!!"));
101736 +
101737 + param = (ioc_fm_port_pcd_fqids_params_t *) XX_Malloc(sizeof(ioc_fm_port_pcd_fqids_params_t));
101738 + if (!param)
101739 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PORT"));
101740 +
101741 + memset(param, 0, sizeof(ioc_fm_port_pcd_fqids_params_t));
101742 +
101743 +#if defined(CONFIG_COMPAT)
101744 + if (compat)
101745 + {
101746 + if (copy_from_user(param, (ioc_fm_port_pcd_fqids_params_t *)compat_ptr(arg),
101747 + sizeof(ioc_fm_port_pcd_fqids_params_t)))
101748 + {
101749 + XX_Free(param);
101750 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101751 + }
101752 + }
101753 + else
101754 +#endif
101755 + {
101756 + if (copy_from_user(param, (ioc_fm_port_pcd_fqids_params_t *)arg,
101757 + sizeof(ioc_fm_port_pcd_fqids_params_t)))
101758 + {
101759 + XX_Free(param);
101760 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101761 + }
101762 + }
101763 +
101764 + if (p_LnxWrpFmPortDev->pcd_owner_params.cba(p_LnxWrpFmPortDev->pcd_owner_params.dev,
101765 + param->num_fqids,
101766 + param->alignment,
101767 + &param->base_fqid))
101768 + {
101769 + XX_Free(param);
101770 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("can't allocate fqids for PCD!!!"));
101771 + }
101772 +
101773 +#if defined(CONFIG_COMPAT)
101774 + if (compat)
101775 + {
101776 + if (copy_to_user((ioc_fm_port_pcd_fqids_params_t *)compat_ptr(arg),
101777 + param, sizeof(ioc_fm_port_pcd_fqids_params_t)))
101778 + err = E_READ_FAILED;
101779 + }
101780 + else
101781 +#endif
101782 + {
101783 + if (copy_to_user((ioc_fm_port_pcd_fqids_params_t *)arg,
101784 + param, sizeof(ioc_fm_port_pcd_fqids_params_t)))
101785 + err = E_READ_FAILED;
101786 + }
101787 +
101788 + XX_Free(param);
101789 + break;
101790 + }
101791 +
101792 + case FM_PORT_IOC_FREE_PCD_FQIDS:
101793 + {
101794 + uint32_t base_fqid;
101795 +
101796 + if (!p_LnxWrpFmPortDev->pcd_owner_params.cbf)
101797 + RETURN_ERROR(MINOR, E_INVALID_STATE, ("No one to listen on this PCD!!!"));
101798 +
101799 +#if defined(CONFIG_COMPAT)
101800 + if (compat)
101801 + {
101802 + if (get_user(base_fqid, (uint32_t*) compat_ptr(arg)))
101803 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101804 + }
101805 + else
101806 +#endif
101807 + {
101808 + if (get_user(base_fqid, (uint32_t*)arg))
101809 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
101810 + }
101811 +
101812 + if (p_LnxWrpFmPortDev->pcd_owner_params.cbf(p_LnxWrpFmPortDev->pcd_owner_params.dev, base_fqid))
101813 + err = E_WRITE_FAILED;
101814 +
101815 + break;
101816 + }
101817 +
101818 +#if defined(CONFIG_COMPAT)
101819 + case FM_PORT_IOC_SET_PCD_COMPAT:
101820 +#endif
101821 + case FM_PORT_IOC_SET_PCD:
101822 + {
101823 + ioc_fm_port_pcd_params_t *port_pcd_params;
101824 + ioc_fm_port_pcd_prs_params_t *port_pcd_prs_params;
101825 + ioc_fm_port_pcd_cc_params_t *port_pcd_cc_params;
101826 + ioc_fm_port_pcd_kg_params_t *port_pcd_kg_params;
101827 + ioc_fm_port_pcd_plcr_params_t *port_pcd_plcr_params;
101828 +
101829 + port_pcd_params = (ioc_fm_port_pcd_params_t *) XX_Malloc(
101830 + sizeof(ioc_fm_port_pcd_params_t) +
101831 + sizeof(ioc_fm_port_pcd_prs_params_t) +
101832 + sizeof(ioc_fm_port_pcd_cc_params_t) +
101833 + sizeof(ioc_fm_port_pcd_kg_params_t) +
101834 + sizeof(ioc_fm_port_pcd_plcr_params_t));
101835 + if (!port_pcd_params)
101836 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PORT"));
101837 +
101838 + memset(port_pcd_params, 0,
101839 + sizeof(ioc_fm_port_pcd_params_t) +
101840 + sizeof(ioc_fm_port_pcd_prs_params_t) +
101841 + sizeof(ioc_fm_port_pcd_cc_params_t) +
101842 + sizeof(ioc_fm_port_pcd_kg_params_t) +
101843 + sizeof(ioc_fm_port_pcd_plcr_params_t));
101844 +
101845 + port_pcd_prs_params = (ioc_fm_port_pcd_prs_params_t *) (port_pcd_params + 1);
101846 + port_pcd_cc_params = (ioc_fm_port_pcd_cc_params_t *) (port_pcd_prs_params + 1);
101847 + port_pcd_kg_params = (ioc_fm_port_pcd_kg_params_t *) (port_pcd_cc_params + 1);
101848 + port_pcd_plcr_params = (ioc_fm_port_pcd_plcr_params_t *) (port_pcd_kg_params + 1);
101849 +
101850 +#if defined(CONFIG_COMPAT)
101851 + if (compat)
101852 + {
101853 + ioc_compat_fm_port_pcd_params_t *compat_port_pcd_params;
101854 + ioc_fm_port_pcd_prs_params_t *same_port_pcd_prs_params;
101855 + ioc_compat_fm_port_pcd_cc_params_t *compat_port_pcd_cc_params;
101856 + ioc_compat_fm_port_pcd_kg_params_t *compat_port_pcd_kg_params;
101857 + ioc_compat_fm_port_pcd_plcr_params_t *compat_port_pcd_plcr_params;
101858 +
101859 + compat_port_pcd_params = (ioc_compat_fm_port_pcd_params_t *) XX_Malloc(
101860 + sizeof(ioc_compat_fm_port_pcd_params_t) +
101861 + sizeof(ioc_fm_port_pcd_prs_params_t) +
101862 + sizeof(ioc_compat_fm_port_pcd_cc_params_t) +
101863 + sizeof(ioc_compat_fm_port_pcd_kg_params_t) +
101864 + sizeof(ioc_compat_fm_port_pcd_plcr_params_t));
101865 + if (!compat_port_pcd_params)
101866 + {
101867 + XX_Free(port_pcd_params);
101868 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PORT"));
101869 + }
101870 +
101871 + memset(compat_port_pcd_params, 0,
101872 + sizeof(ioc_compat_fm_port_pcd_params_t) +
101873 + sizeof(ioc_fm_port_pcd_prs_params_t) +
101874 + sizeof(ioc_compat_fm_port_pcd_cc_params_t) +
101875 + sizeof(ioc_compat_fm_port_pcd_kg_params_t) +
101876 + sizeof(ioc_compat_fm_port_pcd_plcr_params_t));
101877 + same_port_pcd_prs_params = (ioc_fm_port_pcd_prs_params_t *) (compat_port_pcd_params + 1);
101878 + compat_port_pcd_cc_params = (ioc_compat_fm_port_pcd_cc_params_t *) (same_port_pcd_prs_params + 1);
101879 + compat_port_pcd_kg_params = (ioc_compat_fm_port_pcd_kg_params_t *) (compat_port_pcd_cc_params + 1);
101880 + compat_port_pcd_plcr_params = (ioc_compat_fm_port_pcd_plcr_params_t *) (compat_port_pcd_kg_params + 1);
101881 +
101882 + if (copy_from_user(compat_port_pcd_params,
101883 + (ioc_compat_fm_port_pcd_params_t*) compat_ptr(arg),
101884 + sizeof(ioc_compat_fm_port_pcd_params_t)))
101885 + err = E_WRITE_FAILED;
101886 +
101887 + while (!err) /* pseudo-while */
101888 + {
101889 + /* set pointers from where to copy from: */
101890 + port_pcd_params->p_prs_params = compat_ptr(compat_port_pcd_params->p_prs_params); /* same structure */
101891 + port_pcd_params->p_cc_params = compat_ptr(compat_port_pcd_params->p_cc_params);
101892 + port_pcd_params->p_kg_params = compat_ptr(compat_port_pcd_params->p_kg_params);
101893 + port_pcd_params->p_plcr_params = compat_ptr(compat_port_pcd_params->p_plcr_params);
101894 + port_pcd_params->p_ip_reassembly_manip = compat_ptr(compat_port_pcd_params->p_ip_reassembly_manip);
101895 +#if (DPAA_VERSION >= 11)
101896 + port_pcd_params->p_capwap_reassembly_manip = compat_ptr(compat_port_pcd_params->p_capwap_reassembly_manip);
101897 +#endif
101898 + /* the prs member is the same, no compat structure...memcpy only */
101899 + if (port_pcd_params->p_prs_params)
101900 + {
101901 + if (copy_from_user(same_port_pcd_prs_params,
101902 + port_pcd_params->p_prs_params,
101903 + sizeof(ioc_fm_port_pcd_prs_params_t)))
101904 + {
101905 + err = E_WRITE_FAILED;
101906 + break; /* from pseudo-while */
101907 + }
101908 +
101909 + memcpy(port_pcd_prs_params, same_port_pcd_prs_params, sizeof(ioc_fm_port_pcd_prs_params_t));
101910 + port_pcd_params->p_prs_params = port_pcd_prs_params;
101911 + }
101912 +
101913 + if (port_pcd_params->p_cc_params)
101914 + {
101915 + if (copy_from_user(compat_port_pcd_cc_params,
101916 + port_pcd_params->p_cc_params,
101917 + sizeof(ioc_compat_fm_port_pcd_cc_params_t)))
101918 + {
101919 + err = E_WRITE_FAILED;
101920 + break; /* from pseudo-while */
101921 + }
101922 +
101923 + port_pcd_params->p_cc_params = port_pcd_cc_params;
101924 + }
101925 +
101926 + if (port_pcd_params->p_kg_params)
101927 + {
101928 + if (copy_from_user(compat_port_pcd_kg_params,
101929 + port_pcd_params->p_kg_params,
101930 + sizeof(ioc_compat_fm_port_pcd_kg_params_t)))
101931 + {
101932 + err = E_WRITE_FAILED;
101933 + break; /* from pseudo-while */
101934 + }
101935 +
101936 + port_pcd_params->p_kg_params = port_pcd_kg_params;
101937 + }
101938 +
101939 + if (port_pcd_params->p_plcr_params)
101940 + {
101941 + if (copy_from_user(compat_port_pcd_plcr_params,
101942 + port_pcd_params->p_plcr_params,
101943 + sizeof(ioc_compat_fm_port_pcd_plcr_params_t)))
101944 + {
101945 + err = E_WRITE_FAILED;
101946 + break; /* from pseudo-while */
101947 + }
101948 +
101949 + port_pcd_params->p_plcr_params = port_pcd_plcr_params;
101950 + }
101951 +
101952 + break; /* pseudo-while: always run once! */
101953 + }
101954 +
101955 + if (!err)
101956 + compat_copy_fm_port_pcd(compat_port_pcd_params, port_pcd_params, COMPAT_US_TO_K);
101957 +
101958 + XX_Free(compat_port_pcd_params);
101959 + }
101960 + else
101961 +#endif
101962 + {
101963 + if (copy_from_user(port_pcd_params,
101964 + (ioc_fm_port_pcd_params_t*) arg,
101965 + sizeof(ioc_fm_port_pcd_params_t)))
101966 + err = E_WRITE_FAILED;
101967 +
101968 + while (!err) /* pseudo-while */
101969 + {
101970 + if (port_pcd_params->p_prs_params)
101971 + {
101972 + if (copy_from_user(port_pcd_prs_params,
101973 + port_pcd_params->p_prs_params,
101974 + sizeof(ioc_fm_port_pcd_prs_params_t)))
101975 + {
101976 + err = E_WRITE_FAILED;
101977 + break; /* from pseudo-while */
101978 + }
101979 +
101980 + port_pcd_params->p_prs_params = port_pcd_prs_params;
101981 + }
101982 +
101983 + if (port_pcd_params->p_cc_params)
101984 + {
101985 + if (copy_from_user(port_pcd_cc_params,
101986 + port_pcd_params->p_cc_params,
101987 + sizeof(ioc_fm_port_pcd_cc_params_t)))
101988 + {
101989 + err = E_WRITE_FAILED;
101990 + break; /* from pseudo-while */
101991 + }
101992 +
101993 + port_pcd_params->p_cc_params = port_pcd_cc_params;
101994 + }
101995 +
101996 + if (port_pcd_params->p_kg_params)
101997 + {
101998 + if (copy_from_user(port_pcd_kg_params,
101999 + port_pcd_params->p_kg_params,
102000 + sizeof(ioc_fm_port_pcd_kg_params_t)))
102001 + {
102002 + err = E_WRITE_FAILED;
102003 + break; /* from pseudo-while */
102004 + }
102005 +
102006 + port_pcd_params->p_kg_params = port_pcd_kg_params;
102007 + }
102008 +
102009 + if (port_pcd_params->p_plcr_params)
102010 + {
102011 + if (copy_from_user(port_pcd_plcr_params,
102012 + port_pcd_params->p_plcr_params,
102013 + sizeof(ioc_fm_port_pcd_plcr_params_t)))
102014 + {
102015 + err = E_WRITE_FAILED;
102016 + break; /* from pseudo-while */
102017 + }
102018 +
102019 + port_pcd_params->p_plcr_params = port_pcd_plcr_params;
102020 + }
102021 +
102022 + break; /* pseudo-while: always run once! */
102023 + }
102024 + }
102025 +
102026 + if (!err)
102027 + err = FM_PORT_SetPCD(p_LnxWrpFmPortDev->h_Dev, (t_FmPortPcdParams*) port_pcd_params);
102028 +
102029 + XX_Free(port_pcd_params);
102030 + break;
102031 + }
102032 +
102033 + case FM_PORT_IOC_DELETE_PCD:
102034 + err = FM_PORT_DeletePCD(p_LnxWrpFmPortDev->h_Dev);
102035 + break;
102036 +
102037 +#if defined(CONFIG_COMPAT)
102038 + case FM_PORT_IOC_PCD_KG_MODIFY_INITIAL_SCHEME_COMPAT:
102039 +#endif
102040 + case FM_PORT_IOC_PCD_KG_MODIFY_INITIAL_SCHEME:
102041 + {
102042 + ioc_fm_pcd_kg_scheme_select_t *param;
102043 +
102044 + param = (ioc_fm_pcd_kg_scheme_select_t *) XX_Malloc(
102045 + sizeof(ioc_fm_pcd_kg_scheme_select_t));
102046 + if (!param)
102047 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PORT"));
102048 +
102049 + memset(param, 0, sizeof(ioc_fm_pcd_kg_scheme_select_t));
102050 +
102051 +#if defined(CONFIG_COMPAT)
102052 + if (compat)
102053 + {
102054 + ioc_compat_fm_pcd_kg_scheme_select_t *compat_param;
102055 +
102056 + compat_param = (ioc_compat_fm_pcd_kg_scheme_select_t *) XX_Malloc(
102057 + sizeof(ioc_compat_fm_pcd_kg_scheme_select_t));
102058 + if (!compat_param)
102059 + {
102060 + XX_Free(param);
102061 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PORT"));
102062 + }
102063 +
102064 + memset(compat_param, 0, sizeof(ioc_compat_fm_pcd_kg_scheme_select_t));
102065 + if (copy_from_user(compat_param,
102066 + (ioc_compat_fm_pcd_kg_scheme_select_t *) compat_ptr(arg),
102067 + sizeof(ioc_compat_fm_pcd_kg_scheme_select_t)))
102068 + {
102069 + XX_Free(compat_param);
102070 + XX_Free(param);
102071 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102072 + }
102073 +
102074 + compat_copy_fm_pcd_kg_scheme_select(compat_param, param, COMPAT_US_TO_K);
102075 +
102076 + XX_Free(compat_param);
102077 + }
102078 + else
102079 +#endif
102080 + {
102081 + if (copy_from_user(param, (ioc_fm_pcd_kg_scheme_select_t *)arg,
102082 + sizeof(ioc_fm_pcd_kg_scheme_select_t)))
102083 + {
102084 + XX_Free(param);
102085 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102086 + }
102087 + }
102088 +
102089 + err = FM_PORT_PcdKgModifyInitialScheme(p_LnxWrpFmPortDev->h_Dev, (t_FmPcdKgSchemeSelect *)param);
102090 +
102091 + XX_Free(param);
102092 + break;
102093 + }
102094 +
102095 +#if defined(CONFIG_COMPAT)
102096 + case FM_PORT_IOC_PCD_PLCR_MODIFY_INITIAL_PROFILE_COMPAT:
102097 +#endif
102098 + case FM_PORT_IOC_PCD_PLCR_MODIFY_INITIAL_PROFILE:
102099 + {
102100 + ioc_fm_obj_t id;
102101 +
102102 + memset(&id, 0 , sizeof(ioc_fm_obj_t));
102103 +
102104 +#if defined(CONFIG_COMPAT)
102105 + if (compat)
102106 + {
102107 + ioc_compat_fm_obj_t compat_id;
102108 +
102109 + if (copy_from_user(&compat_id, (ioc_compat_fm_obj_t *) compat_ptr(arg), sizeof(ioc_compat_fm_obj_t)))
102110 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102111 +
102112 + id.obj = compat_ptr(compat_id.obj);
102113 + }
102114 + else
102115 +#endif
102116 + {
102117 + if (copy_from_user(&id, (ioc_fm_obj_t *) arg, sizeof(ioc_fm_obj_t)))
102118 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102119 + }
102120 +
102121 + err = FM_PORT_PcdPlcrModifyInitialProfile(p_LnxWrpFmPortDev->h_Dev, id.obj);
102122 + break;
102123 + }
102124 +
102125 +#if defined(CONFIG_COMPAT)
102126 + case FM_PORT_IOC_PCD_KG_BIND_SCHEMES_COMPAT:
102127 +#endif
102128 + case FM_PORT_IOC_PCD_KG_BIND_SCHEMES:
102129 + {
102130 + ioc_fm_pcd_port_schemes_params_t *param;
102131 +
102132 + param = (ioc_fm_pcd_port_schemes_params_t *) XX_Malloc(
102133 + sizeof(ioc_fm_pcd_port_schemes_params_t));
102134 + if (!param)
102135 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PORT"));
102136 +
102137 + memset(param, 0 , sizeof(ioc_fm_pcd_port_schemes_params_t));
102138 +
102139 +#if defined(CONFIG_COMPAT)
102140 + if (compat)
102141 + {
102142 + ioc_compat_fm_pcd_port_schemes_params_t compat_param;
102143 +
102144 + if (copy_from_user(&compat_param,
102145 + (ioc_compat_fm_pcd_port_schemes_params_t *) compat_ptr(arg),
102146 + sizeof(ioc_compat_fm_pcd_port_schemes_params_t)))
102147 + {
102148 + XX_Free(param);
102149 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102150 + }
102151 +
102152 + compat_copy_fm_pcd_kg_schemes_params(&compat_param, param, COMPAT_US_TO_K);
102153 + }
102154 + else
102155 +#endif
102156 + {
102157 + if (copy_from_user(param, (ioc_fm_pcd_port_schemes_params_t *) arg,
102158 + sizeof(ioc_fm_pcd_port_schemes_params_t)))
102159 + {
102160 + XX_Free(param);
102161 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102162 + }
102163 + }
102164 +
102165 + err = FM_PORT_PcdKgBindSchemes(p_LnxWrpFmPortDev->h_Dev, (t_FmPcdPortSchemesParams *)param);
102166 +
102167 + XX_Free(param);
102168 + break;
102169 + }
102170 +
102171 +#if defined(CONFIG_COMPAT)
102172 + case FM_PORT_IOC_PCD_KG_UNBIND_SCHEMES_COMPAT:
102173 +#endif
102174 + case FM_PORT_IOC_PCD_KG_UNBIND_SCHEMES:
102175 + {
102176 + ioc_fm_pcd_port_schemes_params_t *param;
102177 +
102178 + param = (ioc_fm_pcd_port_schemes_params_t *) XX_Malloc(
102179 + sizeof(ioc_fm_pcd_port_schemes_params_t));
102180 + if (!param)
102181 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PORT"));
102182 +
102183 + memset(param, 0 , sizeof(ioc_fm_pcd_port_schemes_params_t));
102184 +
102185 +#if defined(CONFIG_COMPAT)
102186 + if (compat)
102187 + {
102188 + ioc_compat_fm_pcd_port_schemes_params_t compat_param;
102189 +
102190 + if (copy_from_user(&compat_param,
102191 + (ioc_compat_fm_pcd_port_schemes_params_t *) compat_ptr(arg),
102192 + sizeof(ioc_compat_fm_pcd_port_schemes_params_t)))
102193 + {
102194 + XX_Free(param);
102195 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102196 + }
102197 +
102198 + compat_copy_fm_pcd_kg_schemes_params(&compat_param, param, COMPAT_US_TO_K);
102199 + }
102200 + else
102201 +#endif
102202 + {
102203 + if (copy_from_user(param, (ioc_fm_pcd_port_schemes_params_t *) arg,
102204 + sizeof(ioc_fm_pcd_port_schemes_params_t)))
102205 + {
102206 + XX_Free(param);
102207 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102208 + }
102209 + }
102210 +
102211 + err = FM_PORT_PcdKgUnbindSchemes(p_LnxWrpFmPortDev->h_Dev, (t_FmPcdPortSchemesParams *)param);
102212 +
102213 + XX_Free(param);
102214 + break;
102215 + }
102216 +
102217 + case FM_PORT_IOC_PCD_PLCR_ALLOC_PROFILES:
102218 + {
102219 + uint16_t num;
102220 + if (get_user(num, (uint16_t*) arg))
102221 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102222 +
102223 + err = FM_PORT_PcdPlcrAllocProfiles(p_LnxWrpFmPortDev->h_Dev, num);
102224 + break;
102225 + }
102226 +
102227 + case FM_PORT_IOC_PCD_PLCR_FREE_PROFILES:
102228 + err = FM_PORT_PcdPlcrFreeProfiles(p_LnxWrpFmPortDev->h_Dev);
102229 + break;
102230 +
102231 + case FM_PORT_IOC_DETACH_PCD:
102232 + err = FM_PORT_DetachPCD(p_LnxWrpFmPortDev->h_Dev);
102233 + break;
102234 +
102235 + case FM_PORT_IOC_ATTACH_PCD:
102236 + err = FM_PORT_AttachPCD(p_LnxWrpFmPortDev->h_Dev);
102237 + break;
102238 +
102239 +#if defined(CONFIG_COMPAT)
102240 + case FM_PORT_IOC_PCD_CC_MODIFY_TREE_COMPAT:
102241 +#endif
102242 + case FM_PORT_IOC_PCD_CC_MODIFY_TREE:
102243 + {
102244 + ioc_fm_obj_t id;
102245 +
102246 + memset(&id, 0 , sizeof(ioc_fm_obj_t));
102247 +
102248 +#if defined(CONFIG_COMPAT)
102249 + if (compat)
102250 + {
102251 + ioc_compat_fm_obj_t compat_id;
102252 +
102253 + if (copy_from_user(&compat_id, (ioc_compat_fm_obj_t *) compat_ptr(arg), sizeof(ioc_compat_fm_obj_t)))
102254 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102255 +
102256 + compat_copy_fm_port_pcd_modify_tree(&compat_id, &id, COMPAT_US_TO_K);
102257 + }
102258 + else
102259 +#endif
102260 + {
102261 + if (copy_from_user(&id, (ioc_fm_obj_t *) arg, sizeof(ioc_fm_obj_t)))
102262 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102263 + }
102264 +
102265 + err = FM_PORT_PcdCcModifyTree(p_LnxWrpFmPortDev->h_Dev, id.obj);
102266 + break;
102267 + }
102268 +
102269 + case FM_PORT_IOC_ADD_CONGESTION_GRPS:
102270 + case FM_PORT_IOC_REMOVE_CONGESTION_GRPS:
102271 + {
102272 + ioc_fm_port_congestion_groups_t *param;
102273 +
102274 + param = (ioc_fm_port_congestion_groups_t*) XX_Malloc(sizeof(ioc_fm_port_congestion_groups_t));
102275 + if (!param)
102276 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PORT"));
102277 +
102278 + memset(param, 0, sizeof(ioc_fm_port_congestion_groups_t));
102279 +
102280 +#if defined(CONFIG_COMPAT)
102281 + if (compat)
102282 + {
102283 + if (copy_from_user(param, (t_FmPortCongestionGrps*) compat_ptr(arg),
102284 + sizeof(t_FmPortCongestionGrps)))
102285 + {
102286 + XX_Free(param);
102287 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102288 + }
102289 + }
102290 + else
102291 +#endif /* CONFIG_COMPAT */
102292 + {
102293 + if (copy_from_user(param, (t_FmPortCongestionGrps*) arg,
102294 + sizeof(t_FmPortCongestionGrps)))
102295 + {
102296 + XX_Free(param);
102297 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102298 + }
102299 + }
102300 +
102301 + err = (cmd == FM_PORT_IOC_ADD_CONGESTION_GRPS)
102302 + ? FM_PORT_AddCongestionGrps(p_LnxWrpFmPortDev->h_Dev, (t_FmPortCongestionGrps*) param)
102303 + : FM_PORT_RemoveCongestionGrps(p_LnxWrpFmPortDev->h_Dev, (t_FmPortCongestionGrps*) param)
102304 + ;
102305 +
102306 + XX_Free(param);
102307 + break;
102308 + }
102309 +
102310 + case FM_PORT_IOC_ADD_RX_HASH_MAC_ADDR:
102311 + case FM_PORT_IOC_REMOVE_RX_HASH_MAC_ADDR:
102312 + {
102313 + ioc_fm_port_mac_addr_params_t *param;
102314 +
102315 + param = (ioc_fm_port_mac_addr_params_t*) XX_Malloc(
102316 + sizeof(ioc_fm_port_mac_addr_params_t));
102317 + if (!param)
102318 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PORT"));
102319 +
102320 + memset(param, 0, sizeof(ioc_fm_port_mac_addr_params_t));
102321 +
102322 +#if defined(CONFIG_COMPAT)
102323 + if (compat)
102324 + {
102325 + if (copy_from_user(param, (ioc_fm_port_mac_addr_params_t*) compat_ptr(arg),
102326 + sizeof(ioc_fm_port_mac_addr_params_t)))
102327 + {
102328 + XX_Free(param);
102329 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102330 + }
102331 + }
102332 + else
102333 +#endif /* CONFIG_COMPAT */
102334 + {
102335 + if (copy_from_user(param, (ioc_fm_port_mac_addr_params_t*) arg,
102336 + sizeof(ioc_fm_port_mac_addr_params_t)))
102337 + {
102338 + XX_Free(param);
102339 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102340 + }
102341 + }
102342 +
102343 + if (p_LnxWrpFmPortDev->pcd_owner_params.dev)
102344 + {
102345 + int id = -1;
102346 +
102347 + switch(p_LnxWrpFmPortDev->settings.param.portType)
102348 + {
102349 + case e_FM_PORT_TYPE_RX:
102350 + case e_FM_PORT_TYPE_TX:
102351 + id = p_LnxWrpFmPortDev->id;
102352 + break;
102353 + case e_FM_PORT_TYPE_RX_10G:
102354 + case e_FM_PORT_TYPE_TX_10G:
102355 + id = p_LnxWrpFmPortDev->id + FM_MAX_NUM_OF_1G_MACS;
102356 + break;
102357 + default:
102358 + err = E_NOT_AVAILABLE;
102359 + REPORT_ERROR(MINOR, err, ("Attempt to add/remove hash MAC addr. to/from MAC-less port!"));
102360 + }
102361 + if (id >= 0)
102362 + {
102363 + t_LnxWrpFmDev *fm = (t_LnxWrpFmDev *)p_LnxWrpFmPortDev->h_LnxWrpFmDev;
102364 + t_Handle mac_handle = fm->macs[id].h_Dev;
102365 +
102366 + err = (cmd == FM_PORT_IOC_ADD_RX_HASH_MAC_ADDR)
102367 + ? FM_MAC_AddHashMacAddr(mac_handle, (t_EnetAddr*) param)
102368 + : FM_MAC_RemoveHashMacAddr(mac_handle, (t_EnetAddr*) param);
102369 + }
102370 + }
102371 + else
102372 + {
102373 + err = E_NOT_AVAILABLE;
102374 + REPORT_ERROR(MINOR, err, ("Port not initialized or other error!?!?"));
102375 + }
102376 +
102377 + XX_Free(param);
102378 + break;
102379 + }
102380 +
102381 + case FM_PORT_IOC_SET_TX_PAUSE_FRAMES:
102382 + {
102383 + t_LnxWrpFmDev *p_LnxWrpFmDev =
102384 + (t_LnxWrpFmDev *)p_LnxWrpFmPortDev->h_LnxWrpFmDev;
102385 + ioc_fm_port_tx_pause_frames_params_t param;
102386 + int mac_id = p_LnxWrpFmPortDev->id;
102387 +
102388 + if(&p_LnxWrpFmDev->txPorts[mac_id] != p_LnxWrpFmPortDev)
102389 + mac_id += FM_MAX_NUM_OF_1G_MACS; /* 10G port */
102390 +
102391 + if (copy_from_user(&param, (ioc_fm_port_tx_pause_frames_params_t *)arg,
102392 + sizeof(ioc_fm_port_tx_pause_frames_params_t)))
102393 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102394 +
102395 + if (p_LnxWrpFmDev && p_LnxWrpFmDev->macs[mac_id].h_Dev)
102396 + {
102397 + FM_MAC_SetTxPauseFrames(p_LnxWrpFmDev->macs[mac_id].h_Dev,
102398 + param.priority,
102399 + param.pause_time,
102400 + param.thresh_time);
102401 + }
102402 + else
102403 + {
102404 + err = E_NOT_AVAILABLE;
102405 + REPORT_ERROR(MINOR, err, ("Port not initialized or other error!"));
102406 + }
102407 +
102408 + break;
102409 + }
102410 +
102411 + case FM_PORT_IOC_CONFIG_BUFFER_PREFIX_CONTENT:
102412 + {
102413 + ioc_fm_buffer_prefix_content_t *param;
102414 +
102415 + param = (ioc_fm_buffer_prefix_content_t*) XX_Malloc(sizeof(ioc_fm_buffer_prefix_content_t));
102416 + if (!param)
102417 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PORT"));
102418 +
102419 + memset(param, 0, sizeof(ioc_fm_buffer_prefix_content_t));
102420 +
102421 + if (copy_from_user(param, (ioc_fm_buffer_prefix_content_t*) arg,
102422 + sizeof(ioc_fm_buffer_prefix_content_t)))
102423 + {
102424 + XX_Free(param);
102425 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102426 + }
102427 +
102428 + if (FM_PORT_ConfigBufferPrefixContent(p_LnxWrpFmPortDev->h_Dev,
102429 + (t_FmBufferPrefixContent *)param))
102430 + {
102431 + XX_Free(param);
102432 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102433 + }
102434 +
102435 + XX_Free(param);
102436 + break;
102437 + }
102438 +
102439 +#if (DPAA_VERSION >= 11)
102440 +#if defined(CONFIG_COMPAT)
102441 + case FM_PORT_IOC_VSP_ALLOC_COMPAT:
102442 +#endif
102443 + case FM_PORT_IOC_VSP_ALLOC:
102444 + {
102445 + ioc_fm_port_vsp_alloc_params_t *param;
102446 + t_LnxWrpFmDev *p_LnxWrpFmDev;
102447 + t_LnxWrpFmPortDev *p_LnxWrpFmTxPortDev;
102448 +
102449 + param = (ioc_fm_port_vsp_alloc_params_t *) XX_Malloc(
102450 + sizeof(ioc_fm_port_vsp_alloc_params_t));
102451 + if (!param)
102452 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PORT"));
102453 +
102454 + memset(param, 0, sizeof(ioc_fm_port_vsp_alloc_params_t));
102455 +
102456 +#if defined(CONFIG_COMPAT)
102457 + if (compat)
102458 + {
102459 + ioc_compat_fm_port_vsp_alloc_params_t *compat_param;
102460 +
102461 + compat_param = (ioc_compat_fm_port_vsp_alloc_params_t *) XX_Malloc(
102462 + sizeof(ioc_compat_fm_port_vsp_alloc_params_t));
102463 + if (!compat_param)
102464 + {
102465 + XX_Free(param);
102466 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("IOCTL FM PORT"));
102467 + }
102468 +
102469 + memset(compat_param, 0, sizeof(ioc_compat_fm_port_vsp_alloc_params_t));
102470 + if (copy_from_user(compat_param,
102471 + (ioc_compat_fm_port_vsp_alloc_params_t *) compat_ptr(arg),
102472 + sizeof(ioc_compat_fm_port_vsp_alloc_params_t)))
102473 + {
102474 + XX_Free(compat_param);
102475 + XX_Free(param);
102476 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102477 + }
102478 +
102479 + compat_copy_fm_port_vsp_alloc_params(compat_param, param, COMPAT_US_TO_K);
102480 +
102481 + XX_Free(compat_param);
102482 + }
102483 + else
102484 +#endif
102485 + {
102486 + if (copy_from_user(param, (ioc_fm_port_vsp_alloc_params_t *)arg,
102487 + sizeof(ioc_fm_port_vsp_alloc_params_t)))
102488 + {
102489 + XX_Free(param);
102490 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102491 + }
102492 + }
102493 +
102494 + /* Userspace may not have the Tx port t_handle when issuing the IOCTL */
102495 + if (p_LnxWrpFmPortDev->settings.param.portType == e_FM_PORT_TYPE_RX ||
102496 + p_LnxWrpFmPortDev->settings.param.portType == e_FM_PORT_TYPE_RX_10G)
102497 + {
102498 + /* Determine the Tx port t_Handle from the Rx port id */
102499 + p_LnxWrpFmDev = p_LnxWrpFmPortDev->h_LnxWrpFmDev;
102500 + p_LnxWrpFmTxPortDev = &p_LnxWrpFmDev->txPorts[p_LnxWrpFmPortDev->id];
102501 + param->p_fm_tx_port = p_LnxWrpFmTxPortDev->h_Dev;
102502 + }
102503 +
102504 + if (FM_PORT_VSPAlloc(p_LnxWrpFmPortDev->h_Dev, (t_FmPortVSPAllocParams *)param))
102505 + {
102506 + XX_Free(param);
102507 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102508 + }
102509 +
102510 + XX_Free(param);
102511 + break;
102512 + }
102513 +#endif /* (DPAA_VERSION >= 11) */
102514 +
102515 + case FM_PORT_IOC_GET_MAC_STATISTICS:
102516 + {
102517 + t_LnxWrpFmDev *p_LnxWrpFmDev =
102518 + (t_LnxWrpFmDev *)p_LnxWrpFmPortDev->h_LnxWrpFmDev;
102519 + ioc_fm_port_mac_statistics_t param;
102520 + int mac_id = p_LnxWrpFmPortDev->id;
102521 +
102522 + if (!p_LnxWrpFmDev)
102523 + RETURN_ERROR(MINOR, E_NOT_AVAILABLE, ("Port not initialized or other error!"));
102524 +
102525 + if (&p_LnxWrpFmDev->txPorts[mac_id] != p_LnxWrpFmPortDev &&
102526 + &p_LnxWrpFmDev->rxPorts[mac_id] != p_LnxWrpFmPortDev)
102527 + mac_id += FM_MAX_NUM_OF_1G_MACS; /* 10G port */
102528 +
102529 + if (!p_LnxWrpFmDev->macs[mac_id].h_Dev)
102530 + RETURN_ERROR(MINOR, E_NOT_AVAILABLE, ("Port not initialized or other error!"));
102531 +
102532 + if (FM_MAC_GetStatistics(p_LnxWrpFmDev->macs[mac_id].h_Dev,
102533 + (t_FmMacStatistics *)&param))
102534 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102535 +
102536 + if (copy_to_user((ioc_fm_port_mac_statistics_t *)arg, &param,
102537 + sizeof(ioc_fm_port_mac_statistics_t)))
102538 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102539 +
102540 + break;
102541 + }
102542 +
102543 + case FM_PORT_IOC_GET_BMI_COUNTERS:
102544 + {
102545 + t_LnxWrpFmDev *p_LnxWrpFmDev =
102546 + (t_LnxWrpFmDev *)p_LnxWrpFmPortDev->h_LnxWrpFmDev;
102547 + ioc_fm_port_bmi_stats_t param;
102548 +
102549 + if (!p_LnxWrpFmDev)
102550 + RETURN_ERROR(MINOR, E_NOT_AVAILABLE, ("Port not initialized or other error!"));
102551 +
102552 + if (FM_PORT_GetBmiCounters(p_LnxWrpFmPortDev->h_Dev,
102553 + (t_FmPortBmiStats *)&param))
102554 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102555 +
102556 + if (copy_to_user((ioc_fm_port_bmi_stats_t *)arg, &param,
102557 + sizeof(ioc_fm_port_bmi_stats_t)))
102558 + RETURN_ERROR(MINOR, E_WRITE_FAILED, NO_MSG);
102559 +
102560 + break;
102561 + }
102562 +
102563 + default:
102564 + RETURN_ERROR(MINOR, E_INVALID_SELECTION,
102565 + ("invalid ioctl: cmd:0x%08x(type:0x%02x, nr:0x%02x.\n",
102566 + cmd, _IOC_TYPE(cmd), _IOC_NR(cmd)));
102567 + }
102568 +
102569 + if (err)
102570 + RETURN_ERROR(MINOR, E_INVALID_OPERATION, ("IOCTL FM PORT"));
102571 +
102572 + return E_OK;
102573 +}
102574 +
102575 +/*****************************************************************************/
102576 +/* API routines for the FM Linux Device */
102577 +/*****************************************************************************/
102578 +
102579 +static int fm_open(struct inode *inode, struct file *file)
102580 +{
102581 + t_LnxWrpFmDev *p_LnxWrpFmDev = NULL;
102582 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = NULL;
102583 + unsigned int major = imajor(inode);
102584 + unsigned int minor = iminor(inode);
102585 + struct device_node *fm_node;
102586 + static struct of_device_id fm_node_of_match[] = {
102587 + { .compatible = "fsl,fman", },
102588 + { /* end of list */ },
102589 + };
102590 +
102591 + DBG(TRACE, ("Opening minor - %d - ", minor));
102592 +
102593 + if (file->private_data != NULL)
102594 + return 0;
102595 +
102596 + /* Get all the FM nodes */
102597 + for_each_matching_node(fm_node, fm_node_of_match) {
102598 + struct platform_device *of_dev;
102599 +
102600 + of_dev = of_find_device_by_node(fm_node);
102601 + if (unlikely(of_dev == NULL)) {
102602 + REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("fm id!"));
102603 + return -ENXIO;
102604 + }
102605 +
102606 + p_LnxWrpFmDev = (t_LnxWrpFmDev *)fm_bind(&of_dev->dev);
102607 + if (p_LnxWrpFmDev->major == major)
102608 + break;
102609 + fm_unbind((struct fm *)p_LnxWrpFmDev);
102610 + p_LnxWrpFmDev = NULL;
102611 + }
102612 +
102613 + if (!p_LnxWrpFmDev)
102614 + return -ENODEV;
102615 +
102616 + if (minor == DEV_FM_MINOR_BASE)
102617 + file->private_data = p_LnxWrpFmDev;
102618 + else if (minor == DEV_FM_PCD_MINOR_BASE)
102619 + file->private_data = p_LnxWrpFmDev;
102620 + else {
102621 + if (minor == DEV_FM_OH_PORTS_MINOR_BASE)
102622 + p_LnxWrpFmPortDev = &p_LnxWrpFmDev->hcPort;
102623 + else if ((minor > DEV_FM_OH_PORTS_MINOR_BASE) && (minor < DEV_FM_RX_PORTS_MINOR_BASE))
102624 + p_LnxWrpFmPortDev = &p_LnxWrpFmDev->opPorts[minor-DEV_FM_OH_PORTS_MINOR_BASE-1];
102625 + else if ((minor >= DEV_FM_RX_PORTS_MINOR_BASE) && (minor < DEV_FM_TX_PORTS_MINOR_BASE))
102626 + p_LnxWrpFmPortDev = &p_LnxWrpFmDev->rxPorts[minor-DEV_FM_RX_PORTS_MINOR_BASE];
102627 + else if ((minor >= DEV_FM_TX_PORTS_MINOR_BASE) && (minor < DEV_FM_MAX_MINORS))
102628 + p_LnxWrpFmPortDev = &p_LnxWrpFmDev->txPorts[minor-DEV_FM_TX_PORTS_MINOR_BASE];
102629 + else
102630 + return -EINVAL;
102631 +
102632 + /* if trying to open port, check if it initialized */
102633 + if (!p_LnxWrpFmPortDev->h_Dev)
102634 + return -ENODEV;
102635 +
102636 + p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *)fm_port_bind(p_LnxWrpFmPortDev->dev);
102637 + file->private_data = p_LnxWrpFmPortDev;
102638 + fm_unbind((struct fm *)p_LnxWrpFmDev);
102639 + }
102640 +
102641 + if (file->private_data == NULL)
102642 + return -ENXIO;
102643 +
102644 + return 0;
102645 +}
102646 +
102647 +static int fm_close(struct inode *inode, struct file *file)
102648 +{
102649 + t_LnxWrpFmDev *p_LnxWrpFmDev;
102650 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev;
102651 + unsigned int minor = iminor(inode);
102652 + int err = 0;
102653 +
102654 + DBG(TRACE, ("Closing minor - %d - ", minor));
102655 +
102656 + if ((minor == DEV_FM_MINOR_BASE) ||
102657 + (minor == DEV_FM_PCD_MINOR_BASE))
102658 + {
102659 + p_LnxWrpFmDev = (t_LnxWrpFmDev*)file->private_data;
102660 + if (!p_LnxWrpFmDev)
102661 + return -ENODEV;
102662 + fm_unbind((struct fm *)p_LnxWrpFmDev);
102663 + }
102664 + else if (((minor >= DEV_FM_OH_PORTS_MINOR_BASE) && (minor < DEV_FM_RX_PORTS_MINOR_BASE)) ||
102665 + ((minor >= DEV_FM_RX_PORTS_MINOR_BASE) && (minor < DEV_FM_TX_PORTS_MINOR_BASE)) ||
102666 + ((minor >= DEV_FM_TX_PORTS_MINOR_BASE) && (minor < DEV_FM_MAX_MINORS)))
102667 + {
102668 + p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev*)file->private_data;
102669 + if (!p_LnxWrpFmPortDev)
102670 + return -ENODEV;
102671 + fm_port_unbind((struct fm_port *)p_LnxWrpFmPortDev);
102672 + }
102673 +
102674 + return err;
102675 +}
102676 +
102677 +static int fm_ioctls(unsigned int minor, struct file *file, unsigned int cmd, unsigned long arg, bool compat)
102678 +{
102679 + DBG(TRACE, ("IOCTL minor - %u, cmd - 0x%08x, arg - 0x%08lx \n", minor, cmd, arg));
102680 +
102681 + if ((minor == DEV_FM_MINOR_BASE) ||
102682 + (minor == DEV_FM_PCD_MINOR_BASE))
102683 + {
102684 + t_LnxWrpFmDev *p_LnxWrpFmDev = ((t_LnxWrpFmDev*)file->private_data);
102685 + if (!p_LnxWrpFmDev)
102686 + return -ENODEV;
102687 + if (LnxwrpFmIOCTL(p_LnxWrpFmDev, cmd, arg, compat))
102688 + return -EFAULT;
102689 + }
102690 + else if (((minor >= DEV_FM_OH_PORTS_MINOR_BASE) && (minor < DEV_FM_RX_PORTS_MINOR_BASE)) ||
102691 + ((minor >= DEV_FM_RX_PORTS_MINOR_BASE) && (minor < DEV_FM_TX_PORTS_MINOR_BASE)) ||
102692 + ((minor >= DEV_FM_TX_PORTS_MINOR_BASE) && (minor < DEV_FM_MAX_MINORS)))
102693 + {
102694 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = ((t_LnxWrpFmPortDev*)file->private_data);
102695 + if (!p_LnxWrpFmPortDev)
102696 + return -ENODEV;
102697 + if (LnxwrpFmPortIOCTL(p_LnxWrpFmPortDev, cmd, arg, compat))
102698 + return -EFAULT;
102699 + }
102700 + else
102701 + {
102702 + REPORT_ERROR(MINOR, E_INVALID_VALUE, ("minor"));
102703 + return -ENODEV;
102704 + }
102705 +
102706 + return 0;
102707 +}
102708 +
102709 +#ifdef CONFIG_COMPAT
102710 +static long fm_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
102711 +{
102712 + unsigned int minor = iminor(file->f_path.dentry->d_inode);
102713 + long res;
102714 +
102715 + fm_mutex_lock();
102716 + res = fm_ioctls(minor, file, cmd, arg, true);
102717 + fm_mutex_unlock();
102718 +
102719 + return res;
102720 +}
102721 +#endif
102722 +
102723 +static long fm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
102724 +{
102725 + unsigned int minor = iminor(file->f_path.dentry->d_inode);
102726 + long res;
102727 +
102728 + fm_mutex_lock();
102729 + res = fm_ioctls(minor, file, cmd, arg, false);
102730 + fm_mutex_unlock();
102731 +
102732 + return res;
102733 +}
102734 +
102735 +/* Globals for FM character device */
102736 +struct file_operations fm_fops =
102737 +{
102738 + .owner = THIS_MODULE,
102739 + .unlocked_ioctl = fm_ioctl,
102740 +#ifdef CONFIG_COMPAT
102741 + .compat_ioctl = fm_compat_ioctl,
102742 +#endif
102743 + .open = fm_open,
102744 + .release = fm_close,
102745 +};
102746 --- /dev/null
102747 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.c
102748 @@ -0,0 +1,1300 @@
102749 +/*
102750 + * Copyright 2008-2012 Freescale Semiconductor Inc.
102751 + *
102752 + * Redistribution and use in source and binary forms, with or without
102753 + * modification, are permitted provided that the following conditions are met:
102754 + * * Redistributions of source code must retain the above copyright
102755 + * notice, this list of conditions and the following disclaimer.
102756 + * * Redistributions in binary form must reproduce the above copyright
102757 + * notice, this list of conditions and the following disclaimer in the
102758 + * documentation and/or other materials provided with the distribution.
102759 + * * Neither the name of Freescale Semiconductor nor the
102760 + * names of its contributors may be used to endorse or promote products
102761 + * derived from this software without specific prior written permission.
102762 + *
102763 + *
102764 + * ALTERNATIVELY, this software may be distributed under the terms of the
102765 + * GNU General Public License ("GPL") as published by the Free Software
102766 + * Foundation, either version 2 of that License or (at your option) any
102767 + * later version.
102768 + *
102769 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
102770 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
102771 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
102772 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
102773 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
102774 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
102775 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
102776 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
102777 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
102778 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
102779 + */
102780 +
102781 +/*
102782 + @File lnxwrp_fm_compat_ioctls.c
102783 +
102784 + @Description FM PCD compat functions
102785 +
102786 +*/
102787 +
102788 +#if !defined(CONFIG_COMPAT)
102789 +#error "missing COMPAT layer..."
102790 +#endif
102791 +
102792 +
102793 +#include <linux/kernel.h>
102794 +#include <linux/module.h>
102795 +#include <linux/fs.h>
102796 +#include <linux/cdev.h>
102797 +#include <linux/device.h>
102798 +#include <linux/irq.h>
102799 +#include <linux/interrupt.h>
102800 +#include <linux/io.h>
102801 +#include <linux/ioport.h>
102802 +#include <asm/uaccess.h>
102803 +#include <asm/errno.h>
102804 +#ifndef CONFIG_FMAN_ARM
102805 +#include <sysdev/fsl_soc.h>
102806 +#endif
102807 +
102808 +#include "part_ext.h"
102809 +#include "fm_ioctls.h"
102810 +#include "fm_pcd_ioctls.h"
102811 +#include "fm_port_ioctls.h"
102812 +#include "lnxwrp_ioctls_fm_compat.h"
102813 +
102814 +#if defined(FM_COMPAT_DBG)
102815 +static void hex_dump(void * p_addr, unsigned int size)
102816 +{
102817 + int i;
102818 +
102819 + for(i=0; i<size; i+=16)
102820 + {
102821 + printk("%p: 0x%08x 0x%08x 0x%08x 0x%08x\n", p_addr + i,
102822 + *(unsigned int *)(p_addr + i),
102823 + *(unsigned int *)(p_addr + i + 4),
102824 + *(unsigned int *)(p_addr + i + 8),
102825 + *(unsigned int *)(p_addr + i +12)
102826 + );
102827 + }
102828 +}
102829 +#endif
102830 +
102831 +/* maping kernel pointers w/ UserSpace id's { */
102832 +struct map_node {
102833 + void *ptr;
102834 + u8 node_type;
102835 +};
102836 +
102837 +static struct map_node compat_ptr2id_array[COMPAT_PTR2ID_ARRAY_MAX] = {{NULL},{FM_MAP_TYPE_UNSPEC}};
102838 +
102839 +void compat_del_ptr2id(void *p, enum fm_map_node_type node_type)
102840 +{
102841 + compat_uptr_t k;
102842 +
102843 + _fm_cpt_dbg(COMPAT_GENERIC, "delete (%p)\n", p);
102844 +
102845 + for(k=1; k < COMPAT_PTR2ID_ARRAY_MAX; k++)
102846 + if(compat_ptr2id_array[k].ptr == p){
102847 + compat_ptr2id_array[k].ptr = NULL;
102848 + compat_ptr2id_array[k].node_type = FM_MAP_TYPE_UNSPEC;
102849 + }
102850 +}
102851 +EXPORT_SYMBOL(compat_del_ptr2id);
102852 +
102853 +compat_uptr_t compat_add_ptr2id(void *p, enum fm_map_node_type node_type)
102854 +{
102855 + compat_uptr_t k;
102856 +
102857 + _fm_cpt_dbg(COMPAT_GENERIC, " (%p) do ->\n", p);
102858 +
102859 + if(!p)
102860 + return 0;
102861 +
102862 + for(k=1; k < COMPAT_PTR2ID_ARRAY_MAX; k++)
102863 + if(compat_ptr2id_array[k].ptr == NULL)
102864 + {
102865 + compat_ptr2id_array[k].ptr = p;
102866 + compat_ptr2id_array[k].node_type = node_type;
102867 + _fm_cpt_dbg(COMPAT_GENERIC, "0x%08x \n", k | COMPAT_PTR2ID_WATERMARK);
102868 + return k | COMPAT_PTR2ID_WATERMARK;
102869 + }
102870 +
102871 + printk(KERN_WARNING "FMan map list full! No more PCD space on kernel!\n");
102872 + return 0;
102873 +}
102874 +EXPORT_SYMBOL(compat_add_ptr2id);
102875 +
102876 +compat_uptr_t compat_get_ptr2id(void *p, enum fm_map_node_type node_type)
102877 +{
102878 + compat_uptr_t k;
102879 +
102880 + _fm_cpt_dbg(COMPAT_GENERIC, " (%p) get -> \n", p);
102881 +
102882 + for(k=1; k < COMPAT_PTR2ID_ARRAY_MAX; k++)
102883 + if(compat_ptr2id_array[k].ptr == p &&
102884 + compat_ptr2id_array[k].node_type == node_type) {
102885 +
102886 + _fm_cpt_dbg(COMPAT_GENERIC, "0x%08x\n", k | COMPAT_PTR2ID_WATERMARK);
102887 + return k | COMPAT_PTR2ID_WATERMARK;
102888 + }
102889 +
102890 + return 0;
102891 +}
102892 +EXPORT_SYMBOL(compat_get_ptr2id);
102893 +
102894 +void *compat_get_id2ptr(compat_uptr_t comp, enum fm_map_node_type node_type)
102895 +{
102896 +
102897 + _fm_cpt_dbg(COMPAT_GENERIC, " (0x%08x) get -> \n", comp);
102898 +
102899 + if((COMPAT_PTR2ID_WM_MASK & comp) != COMPAT_PTR2ID_WATERMARK) {
102900 + _fm_cpt_dbg(COMPAT_GENERIC, "Error, invalid watermark (0x%08x)!\n\n", comp);
102901 + dump_stack();
102902 + return compat_ptr(comp);
102903 + }
102904 +
102905 + comp &= ~COMPAT_PTR2ID_WM_MASK;
102906 +
102907 + if(((0 < comp) && (comp < COMPAT_PTR2ID_ARRAY_MAX) && (compat_ptr2id_array[comp].ptr != NULL)
102908 + && compat_ptr2id_array[comp].node_type == node_type)) {
102909 + _fm_cpt_dbg(COMPAT_GENERIC, "%p\n", compat_ptr2id_array[comp].ptr);
102910 + return compat_ptr2id_array[comp].ptr;
102911 + }
102912 + return NULL;
102913 +}
102914 +EXPORT_SYMBOL(compat_get_id2ptr);
102915 +/* } maping kernel pointers w/ UserSpace id's */
102916 +
102917 +void compat_obj_delete(
102918 + ioc_compat_fm_obj_t *compat_id,
102919 + ioc_fm_obj_t *id)
102920 +{
102921 + id->obj = compat_pcd_id2ptr(compat_id->obj);
102922 + compat_del_ptr2id(id->obj, FM_MAP_TYPE_PCD_NODE);
102923 +}
102924 +
102925 +static inline void compat_copy_fm_pcd_plcr_next_engine(
102926 + ioc_compat_fm_pcd_plcr_next_engine_params_u *compat_param,
102927 + ioc_fm_pcd_plcr_next_engine_params_u *param,
102928 + ioc_fm_pcd_engine next_engine,
102929 + uint8_t compat)
102930 +{
102931 + _fm_cpt_dbg (compat, " {->...\n");
102932 +
102933 + switch (next_engine)
102934 + {
102935 + case e_IOC_FM_PCD_PLCR:
102936 + if (compat == COMPAT_US_TO_K)
102937 + param->p_profile = compat_pcd_id2ptr(compat_param->p_profile);
102938 + else
102939 + compat_param->p_profile = compat_pcd_ptr2id(param->p_profile);
102940 + break;
102941 + case e_IOC_FM_PCD_KG:
102942 + if (compat == COMPAT_US_TO_K)
102943 + param->p_direct_scheme = compat_pcd_id2ptr(compat_param->p_direct_scheme);
102944 + else
102945 + compat_param->p_direct_scheme = compat_pcd_ptr2id(param->p_direct_scheme);
102946 + break;
102947 + default:
102948 + if (compat == COMPAT_US_TO_K)
102949 + param->action = compat_param->action;
102950 + else
102951 + compat_param->action = param->action;
102952 + break;
102953 + }
102954 +
102955 + _fm_cpt_dbg (compat, " ...->}\n");
102956 +}
102957 +
102958 +void compat_copy_fm_pcd_plcr_profile(
102959 + ioc_compat_fm_pcd_plcr_profile_params_t *compat_param,
102960 + ioc_fm_pcd_plcr_profile_params_t *param,
102961 + uint8_t compat)
102962 +{
102963 + _fm_cpt_dbg (compat, " {->...\n");
102964 +
102965 + if (compat == COMPAT_US_TO_K)
102966 + {
102967 + param->modify = compat_param->modify;
102968 +
102969 + /* profile_select */
102970 + if (!compat_param->modify)
102971 + {
102972 + param->profile_select.new_params.profile_type =
102973 + compat_param->profile_select.new_params.profile_type;
102974 + param->profile_select.new_params.p_fm_port =
102975 + compat_ptr(compat_param->profile_select.new_params.p_fm_port);
102976 + param->profile_select.new_params.relative_profile_id =
102977 + compat_param->profile_select.new_params.relative_profile_id;
102978 + }
102979 + else
102980 + param->profile_select.p_profile =
102981 + compat_pcd_id2ptr(compat_param->profile_select.p_profile);
102982 +
102983 + param->alg_selection = compat_param->alg_selection;
102984 + param->color_mode = compat_param->color_mode;
102985 +
102986 + /* both parameters in the union has the same size, so memcpy works */
102987 + memcpy(&param->color, &compat_param->color, sizeof(param->color));
102988 +
102989 + memcpy(&param->non_passthrough_alg_param,
102990 + &compat_param->non_passthrough_alg_param,
102991 + sizeof(ioc_fm_pcd_plcr_non_passthrough_alg_param_t));
102992 +
102993 + param->next_engine_on_green = compat_param->next_engine_on_green;
102994 + param->next_engine_on_yellow = compat_param->next_engine_on_yellow;
102995 + param->next_engine_on_red = compat_param->next_engine_on_red;
102996 +
102997 + param->trap_profile_on_flow_A = compat_param->trap_profile_on_flow_A;
102998 + param->trap_profile_on_flow_B = compat_param->trap_profile_on_flow_B;
102999 + param->trap_profile_on_flow_C = compat_param->trap_profile_on_flow_C;
103000 + }
103001 + else
103002 + {
103003 + compat_param->modify = param->modify;
103004 +
103005 + /* profile_select */
103006 + if (!param->modify)
103007 + {
103008 + compat_param->profile_select.new_params.profile_type =
103009 + param->profile_select.new_params.profile_type;
103010 + compat_param->profile_select.new_params.p_fm_port =
103011 + ptr_to_compat(param->profile_select.new_params.p_fm_port);
103012 + compat_param->profile_select.new_params.relative_profile_id =
103013 + param->profile_select.new_params.relative_profile_id;
103014 + }
103015 + else
103016 + compat_param->profile_select.p_profile =
103017 + compat_pcd_ptr2id(param->profile_select.p_profile);
103018 +
103019 + compat_param->alg_selection = param->alg_selection;
103020 + compat_param->color_mode = param->color_mode;
103021 +
103022 + /* both parameters in the union has the same size, so memcpy works */
103023 + memcpy(&compat_param->color, &param->color, sizeof(compat_param->color));
103024 +
103025 + memcpy(&compat_param->non_passthrough_alg_param,
103026 + &param->non_passthrough_alg_param,
103027 + sizeof(ioc_fm_pcd_plcr_non_passthrough_alg_param_t));
103028 +
103029 + compat_param->next_engine_on_green = param->next_engine_on_green;
103030 + compat_param->next_engine_on_yellow = param->next_engine_on_yellow;
103031 + compat_param->next_engine_on_red = param->next_engine_on_red;
103032 +
103033 + compat_param->trap_profile_on_flow_A = param->trap_profile_on_flow_A;
103034 + compat_param->trap_profile_on_flow_B = param->trap_profile_on_flow_B;
103035 + compat_param->trap_profile_on_flow_C = param->trap_profile_on_flow_C;
103036 +
103037 + compat_param->id = compat_add_ptr2id(param->id, FM_MAP_TYPE_PCD_NODE);
103038 + }
103039 +
103040 + compat_copy_fm_pcd_plcr_next_engine(&compat_param->params_on_green,
103041 + &param->params_on_green, param->next_engine_on_green, compat);
103042 +
103043 + compat_copy_fm_pcd_plcr_next_engine(&compat_param->params_on_yellow,
103044 + &param->params_on_yellow, param->next_engine_on_yellow, compat);
103045 +
103046 + compat_copy_fm_pcd_plcr_next_engine(&compat_param->params_on_red,
103047 + &param->params_on_red, param->next_engine_on_red, compat);
103048 +
103049 + _fm_cpt_dbg (compat, " ...->}\n");
103050 +}
103051 +
103052 +static inline void compat_copy_fm_pcd_cc_next_kg(
103053 + ioc_compat_fm_pcd_cc_next_kg_params_t *compat_param,
103054 + ioc_fm_pcd_cc_next_kg_params_t *param,
103055 + uint8_t compat)
103056 +{
103057 + _fm_cpt_dbg (compat, " {->...\n");
103058 +
103059 + if (compat == COMPAT_US_TO_K)
103060 + {
103061 + param->new_fqid = compat_param->new_fqid;
103062 + param->override_fqid = compat_param->override_fqid;
103063 +#if DPAA_VERSION >= 11
103064 + param->new_relative_storage_profile_id = compat_param->new_relative_storage_profile_id;
103065 +#endif
103066 + param->p_direct_scheme = compat_pcd_id2ptr(compat_param->p_direct_scheme);
103067 + }
103068 + else
103069 + {
103070 + compat_param->new_fqid = param->new_fqid;
103071 + compat_param->override_fqid = param->override_fqid;
103072 +#if DPAA_VERSION >= 11
103073 + compat_param->new_relative_storage_profile_id = param->new_relative_storage_profile_id;
103074 +#endif
103075 + compat_param->p_direct_scheme = compat_pcd_ptr2id(param->p_direct_scheme);
103076 + }
103077 +
103078 + _fm_cpt_dbg (compat, " ...->}\n");
103079 +}
103080 +
103081 +static inline void compat_copy_fm_pcd_cc_next_cc(
103082 + ioc_compat_fm_pcd_cc_next_cc_params_t *compat_param,
103083 + ioc_fm_pcd_cc_next_cc_params_t *param,
103084 + uint8_t compat)
103085 +{
103086 + _fm_cpt_dbg (compat, " {->...\n");
103087 +
103088 + if (compat == COMPAT_US_TO_K)
103089 + param->cc_node_id = compat_pcd_id2ptr(compat_param->cc_node_id);
103090 + else
103091 + compat_param->cc_node_id = compat_pcd_ptr2id(param->cc_node_id);
103092 +
103093 + _fm_cpt_dbg (compat, " ...->}\n");
103094 +}
103095 +
103096 +static inline void compat_copy_fm_pcd_cc_next_engine(
103097 + ioc_compat_fm_pcd_cc_next_engine_params_t *compat_param,
103098 + ioc_fm_pcd_cc_next_engine_params_t *param,
103099 + uint8_t compat)
103100 +{
103101 + _fm_cpt_dbg (compat, " {->...\n");
103102 +
103103 + if (compat == COMPAT_US_TO_K)
103104 + {
103105 + param->next_engine = compat_param->next_engine;
103106 + if (param->next_engine != e_IOC_FM_PCD_INVALID )
103107 + _fm_cpt_dbg(compat, " param->next_engine = %i \n", param->next_engine);
103108 +
103109 + switch (param->next_engine)
103110 + {
103111 +#if DPAA_VERSION >= 11
103112 + case e_IOC_FM_PCD_FR:
103113 + param->params.fr_params.frm_replic_id = compat_pcd_id2ptr(compat_param->params.fr_params.frm_replic_id);
103114 + break;
103115 +#endif /* DPAA_VERSION >= 11 */
103116 + case e_IOC_FM_PCD_CC:
103117 + param->manip_id = compat_pcd_id2ptr(compat_param->manip_id);
103118 + compat_copy_fm_pcd_cc_next_cc(&compat_param->params.cc_params, &param->params.cc_params, compat);
103119 + break;
103120 + case e_IOC_FM_PCD_KG:
103121 + param->manip_id = compat_pcd_id2ptr(compat_param->manip_id);
103122 + compat_copy_fm_pcd_cc_next_kg(&compat_param->params.kg_params, &param->params.kg_params, compat);
103123 + break;
103124 + case e_IOC_FM_PCD_DONE:
103125 + case e_IOC_FM_PCD_PLCR:
103126 + param->manip_id = compat_pcd_id2ptr(compat_param->manip_id);
103127 + default:
103128 + memcpy(&param->params, &compat_param->params, sizeof(param->params));
103129 + }
103130 + param->statistics_en = compat_param->statistics_en;
103131 + }
103132 + else
103133 + {
103134 + compat_param->next_engine = param->next_engine;
103135 +
103136 + switch (compat_param->next_engine)
103137 + {
103138 +#if DPAA_VERSION >= 11
103139 + case e_IOC_FM_PCD_FR:
103140 + compat_param->params.fr_params.frm_replic_id = compat_pcd_ptr2id(param->params.fr_params.frm_replic_id);
103141 + break;
103142 +#endif /* DPAA_VERSION >= 11 */
103143 + case e_IOC_FM_PCD_CC:
103144 + compat_param->manip_id = compat_pcd_ptr2id(param->manip_id);
103145 + compat_copy_fm_pcd_cc_next_cc(&compat_param->params.cc_params, &param->params.cc_params, compat);
103146 + break;
103147 + case e_IOC_FM_PCD_KG:
103148 + compat_param->manip_id = compat_pcd_ptr2id(param->manip_id);
103149 + compat_copy_fm_pcd_cc_next_kg(&compat_param->params.kg_params, &param->params.kg_params, compat);
103150 + break;
103151 + case e_IOC_FM_PCD_DONE:
103152 + case e_IOC_FM_PCD_PLCR:
103153 + compat_param->manip_id = compat_pcd_ptr2id(param->manip_id);
103154 + default:
103155 + memcpy(&compat_param->params, &param->params, sizeof(compat_param->params));
103156 + }
103157 + compat_param->statistics_en = param->statistics_en;
103158 + }
103159 +
103160 + _fm_cpt_dbg (compat, " ...->}\n");
103161 +}
103162 +
103163 +void compat_copy_fm_pcd_cc_key(
103164 + ioc_compat_fm_pcd_cc_key_params_t *compat_param,
103165 + ioc_fm_pcd_cc_key_params_t *param,
103166 + uint8_t compat)
103167 +{
103168 + if (compat == COMPAT_US_TO_K)
103169 + {
103170 + param->p_key = compat_ptr(compat_param->p_key);
103171 + param->p_mask = compat_ptr(compat_param->p_mask);
103172 + }
103173 + else
103174 + {
103175 + compat_param->p_key = ptr_to_compat(param->p_key);
103176 + compat_param->p_mask = ptr_to_compat(param->p_mask);
103177 + }
103178 +
103179 + compat_copy_fm_pcd_cc_next_engine(
103180 + &compat_param->cc_next_engine_params,
103181 + &param->cc_next_engine_params,
103182 + compat);
103183 +}
103184 +
103185 +void compat_copy_fm_pcd_cc_node_modify_key_and_next_engine(
103186 + ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t *compat_param,
103187 + ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t *param,
103188 + uint8_t compat)
103189 +{
103190 + if (compat == COMPAT_US_TO_K)
103191 + {
103192 + param->id = compat_pcd_id2ptr(compat_param->id);
103193 + param->key_indx = compat_param->key_indx;
103194 + param->key_size = compat_param->key_size;
103195 + compat_copy_fm_pcd_cc_key(
103196 + &compat_param->key_params,
103197 + &param->key_params,
103198 + compat);
103199 + }
103200 + else
103201 + {
103202 + compat_param->id = compat_pcd_ptr2id(param->id);
103203 + compat_param->key_indx = param->key_indx;
103204 + compat_param->key_size = param->key_size;
103205 + compat_copy_fm_pcd_cc_key(
103206 + &compat_param->key_params,
103207 + &param->key_params,
103208 + compat);
103209 + }
103210 +}
103211 +
103212 +void compat_copy_fm_pcd_cc_node_modify_next_engine(
103213 + ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t *compat_param,
103214 + ioc_fm_pcd_cc_node_modify_next_engine_params_t *param,
103215 + uint8_t compat)
103216 +{
103217 + if (compat == COMPAT_US_TO_K)
103218 + {
103219 + param->id = compat_pcd_id2ptr(compat_param->id);
103220 + param->key_indx = compat_param->key_indx;
103221 + param->key_size = compat_param->key_size;
103222 + }
103223 + else
103224 + {
103225 + compat_param->id = compat_pcd_ptr2id(param->id);
103226 + compat_param->key_indx = param->key_indx;
103227 + compat_param->key_size = param->key_size;
103228 + }
103229 +
103230 + compat_copy_fm_pcd_cc_next_engine(
103231 + &compat_param->cc_next_engine_params,
103232 + &param->cc_next_engine_params,
103233 + compat);
103234 +}
103235 +
103236 +void compat_fm_pcd_cc_tree_modify_next_engine(
103237 + ioc_compat_fm_pcd_cc_tree_modify_next_engine_params_t *compat_param,
103238 + ioc_fm_pcd_cc_tree_modify_next_engine_params_t *param,
103239 + uint8_t compat)
103240 +{
103241 + if (compat == COMPAT_US_TO_K)
103242 + {
103243 + param->id = compat_pcd_id2ptr(compat_param->id);
103244 + param->grp_indx = compat_param->grp_indx;
103245 + param->indx = compat_param->indx;
103246 + }
103247 + else
103248 + {
103249 + compat_param->id = compat_pcd_ptr2id(param->id);
103250 + compat_param->grp_indx = param->grp_indx;
103251 + compat_param->indx = param->indx;
103252 + }
103253 +
103254 + compat_copy_fm_pcd_cc_next_engine(
103255 + &compat_param->cc_next_engine_params,
103256 + &param->cc_next_engine_params,
103257 + compat);
103258 +}
103259 +
103260 +void compat_copy_fm_pcd_hash_table(
103261 + ioc_compat_fm_pcd_hash_table_params_t *compat_param,
103262 + ioc_fm_pcd_hash_table_params_t *param,
103263 + uint8_t compat)
103264 +{
103265 + if (compat == COMPAT_US_TO_K)
103266 + {
103267 + param->max_num_of_keys = compat_param->max_num_of_keys;
103268 + param->statistics_mode = compat_param->statistics_mode;
103269 + param->kg_hash_shift = compat_param->kg_hash_shift;
103270 + param->hash_res_mask = compat_param->hash_res_mask;
103271 + param->hash_shift = compat_param->hash_shift;
103272 + param->match_key_size = compat_param->match_key_size;
103273 + param->id = compat_pcd_id2ptr(compat_param->id);
103274 + }
103275 + else
103276 + {
103277 + compat_param->max_num_of_keys = param->max_num_of_keys;
103278 + compat_param->statistics_mode = param->statistics_mode;
103279 + compat_param->kg_hash_shift = param->kg_hash_shift;
103280 + compat_param->hash_res_mask = param->hash_res_mask;
103281 + compat_param->hash_shift = param->hash_shift;
103282 + compat_param->match_key_size = param->match_key_size;
103283 +
103284 + compat_param->id = compat_add_ptr2id(param->id, FM_MAP_TYPE_PCD_NODE);
103285 + }
103286 +
103287 + compat_copy_fm_pcd_cc_next_engine(
103288 + &compat_param->cc_next_engine_params_for_miss,
103289 + &param->cc_next_engine_params_for_miss,
103290 + compat);
103291 +}
103292 +
103293 +void compat_copy_fm_pcd_cc_grp(
103294 + ioc_compat_fm_pcd_cc_grp_params_t *compat_param,
103295 + ioc_fm_pcd_cc_grp_params_t *param,
103296 + uint8_t compat)
103297 +{
103298 + int k;
103299 +
103300 + _fm_cpt_dbg (compat, " {->...\n");
103301 +
103302 + if (compat == COMPAT_US_TO_K)
103303 + {
103304 + param->num_of_distinction_units = compat_param->num_of_distinction_units;
103305 + memcpy(param->unit_ids, compat_param->unit_ids, IOC_FM_PCD_MAX_NUM_OF_CC_UNITS);
103306 + }
103307 + else
103308 + {
103309 + compat_param->num_of_distinction_units = param->num_of_distinction_units;
103310 + memcpy(compat_param->unit_ids, param->unit_ids, IOC_FM_PCD_MAX_NUM_OF_CC_UNITS);
103311 + }
103312 +
103313 + for (k=0; k < IOC_FM_PCD_MAX_NUM_OF_CC_ENTRIES_IN_GRP; k++)
103314 + compat_copy_fm_pcd_cc_next_engine(
103315 + &compat_param->next_engine_per_entries_in_grp[k],
103316 + &param->next_engine_per_entries_in_grp[k],
103317 + compat);
103318 +
103319 + _fm_cpt_dbg (compat, " ...->}\n");
103320 +}
103321 +
103322 +void compat_copy_fm_pcd_cc_tree(
103323 + ioc_compat_fm_pcd_cc_tree_params_t *compat_param,
103324 + ioc_fm_pcd_cc_tree_params_t *param,
103325 + uint8_t compat)
103326 +{
103327 + int k;
103328 + _fm_cpt_dbg (compat, " {->...\n");
103329 +
103330 + if (compat == COMPAT_US_TO_K)
103331 + {
103332 + param->net_env_id = compat_pcd_id2ptr(compat_param->net_env_id);
103333 + param->num_of_groups = compat_param->num_of_groups;
103334 + }
103335 + else
103336 + {
103337 + compat_param->net_env_id = compat_pcd_ptr2id(param->net_env_id);
103338 + compat_param->num_of_groups = param->num_of_groups;
103339 +
103340 + compat_param->id = compat_add_ptr2id(param->id, FM_MAP_TYPE_PCD_NODE);
103341 + }
103342 +
103343 + for (k=0; k < IOC_FM_PCD_MAX_NUM_OF_CC_GROUPS; k++)
103344 + compat_copy_fm_pcd_cc_grp(
103345 + &compat_param->fm_pcd_cc_group_params[k],
103346 + &param->fm_pcd_cc_group_params[k],
103347 + compat);
103348 +
103349 + _fm_cpt_dbg (compat, " ...->}\n");
103350 +}
103351 +
103352 +void compat_fm_pcd_prs_sw(
103353 + ioc_compat_fm_pcd_prs_sw_params_t *compat_param,
103354 + ioc_fm_pcd_prs_sw_params_t *param,
103355 + uint8_t compat)
103356 +{
103357 + if (compat == COMPAT_US_TO_K)
103358 + {
103359 + param->override = compat_param->override;
103360 + param->size = compat_param->size;
103361 + param->base = compat_param->base;
103362 + param->p_code = compat_ptr(compat_param->p_code);
103363 + memcpy(param->sw_prs_data_params,compat_param->sw_prs_data_params,IOC_FM_PCD_PRS_NUM_OF_HDRS*sizeof(uint32_t));
103364 + param->num_of_labels = compat_param->num_of_labels;
103365 + memcpy(param->labels_table,compat_param->labels_table,IOC_FM_PCD_PRS_NUM_OF_LABELS*sizeof(ioc_fm_pcd_prs_label_params_t));
103366 + }
103367 +}
103368 +
103369 +void compat_copy_fm_pcd_kg_scheme(
103370 + ioc_compat_fm_pcd_kg_scheme_params_t *compat_param,
103371 + ioc_fm_pcd_kg_scheme_params_t *param,
103372 + uint8_t compat)
103373 +{
103374 + _fm_cpt_dbg(compat," {->...\n");
103375 +
103376 + if (compat == COMPAT_US_TO_K)
103377 + {
103378 + param->modify = compat_param->modify;
103379 +
103380 + /* scm_id */
103381 + if (compat_param->modify)
103382 + {
103383 + param->scm_id.scheme_id = compat_pcd_id2ptr(compat_param->scm_id.scheme_id);
103384 + _fm_cpt_dbg(compat," param->scm_id.scheme_id = %p \n", param->scm_id.scheme_id);
103385 + }
103386 + else
103387 + param->scm_id.relative_scheme_id = compat_param->scm_id.relative_scheme_id;
103388 +
103389 + param->always_direct = compat_param->always_direct;
103390 + /* net_env_params */
103391 + param->net_env_params.net_env_id = compat_pcd_id2ptr(compat_param->net_env_params.net_env_id);
103392 + param->net_env_params.num_of_distinction_units = compat_param->net_env_params.num_of_distinction_units;
103393 + memcpy(param->net_env_params.unit_ids,
103394 + compat_param->net_env_params.unit_ids,
103395 + IOC_FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
103396 +
103397 + param->use_hash = compat_param->use_hash;
103398 + memcpy(&param->key_extract_and_hash_params,
103399 + &compat_param->key_extract_and_hash_params,
103400 + sizeof(ioc_fm_pcd_kg_key_extract_and_hash_params_t));
103401 + param->bypass_fqid_generation = compat_param->bypass_fqid_generation;
103402 + param->base_fqid = compat_param->base_fqid;
103403 +#if DPAA_VERSION >= 11
103404 + param->override_storage_profile =
103405 + compat_param->override_storage_profile;
103406 + param->storage_profile = compat_param->storage_profile;
103407 +#endif
103408 + param->num_of_used_extracted_ors = compat_param->num_of_used_extracted_ors;
103409 + memcpy(param->extracted_ors,
103410 + compat_param->extracted_ors,
103411 + IOC_FM_PCD_KG_NUM_OF_GENERIC_REGS * sizeof(ioc_fm_pcd_kg_extracted_or_params_t));
103412 + param->next_engine = compat_param->next_engine;
103413 +
103414 + /* kg_next_engine_params */
103415 + if (param->next_engine == e_IOC_FM_PCD_CC)
103416 + {
103417 + param->kg_next_engine_params.cc.tree_id = compat_pcd_id2ptr(compat_param->kg_next_engine_params.cc.tree_id);
103418 + param->kg_next_engine_params.cc.grp_id = compat_param->kg_next_engine_params.cc.grp_id;
103419 + param->kg_next_engine_params.cc.plcr_next = compat_param->kg_next_engine_params.cc.plcr_next;
103420 + param->kg_next_engine_params.cc.bypass_plcr_profile_generation
103421 + = compat_param->kg_next_engine_params.cc.bypass_plcr_profile_generation;
103422 + memcpy(&param->kg_next_engine_params.cc.plcr_profile,
103423 + &compat_param->kg_next_engine_params.cc.plcr_profile,
103424 + sizeof(ioc_fm_pcd_kg_plcr_profile_t));
103425 + }
103426 + else
103427 + memcpy(&param->kg_next_engine_params,
103428 + &compat_param->kg_next_engine_params,
103429 + sizeof(param->kg_next_engine_params));
103430 +
103431 + memcpy(&param->scheme_counter,
103432 + &compat_param->scheme_counter,
103433 + sizeof(ioc_fm_pcd_kg_scheme_counter_t));
103434 + }
103435 + else
103436 + {
103437 + compat_param->modify = param->modify;
103438 +
103439 + /* scm_id */
103440 + if (param->modify)
103441 + compat_param->scm_id.scheme_id = compat_pcd_ptr2id(param->scm_id.scheme_id);
103442 + else
103443 + compat_param->scm_id.relative_scheme_id = param->scm_id.relative_scheme_id;
103444 +
103445 + compat_param->always_direct = param->always_direct;
103446 +
103447 + /* net_env_params */
103448 + compat_param->net_env_params.net_env_id = compat_pcd_ptr2id(param->net_env_params.net_env_id);
103449 + compat_param->net_env_params.num_of_distinction_units = param->net_env_params.num_of_distinction_units;
103450 + memcpy(compat_param->net_env_params.unit_ids, param->net_env_params.unit_ids, IOC_FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
103451 +
103452 + compat_param->use_hash = param->use_hash;
103453 + memcpy(&compat_param->key_extract_and_hash_params, &param->key_extract_and_hash_params, sizeof(ioc_fm_pcd_kg_key_extract_and_hash_params_t));
103454 + compat_param->bypass_fqid_generation = param->bypass_fqid_generation;
103455 + compat_param->base_fqid = param->base_fqid;
103456 +#if DPAA_VERSION >= 11
103457 + compat_param->override_storage_profile =
103458 + param->override_storage_profile;
103459 + compat_param->storage_profile = param->storage_profile;
103460 +#endif
103461 + compat_param->num_of_used_extracted_ors = param->num_of_used_extracted_ors;
103462 + memcpy(compat_param->extracted_ors, param->extracted_ors, IOC_FM_PCD_KG_NUM_OF_GENERIC_REGS * sizeof(ioc_fm_pcd_kg_extracted_or_params_t));
103463 + compat_param->next_engine = param->next_engine;
103464 +
103465 + /* kg_next_engine_params */
103466 + if (compat_param->next_engine == e_IOC_FM_PCD_CC)
103467 + {
103468 + compat_param->kg_next_engine_params.cc.tree_id = compat_pcd_ptr2id(param->kg_next_engine_params.cc.tree_id);
103469 + compat_param->kg_next_engine_params.cc.grp_id = param->kg_next_engine_params.cc.grp_id;
103470 + compat_param->kg_next_engine_params.cc.plcr_next = param->kg_next_engine_params.cc.plcr_next;
103471 + compat_param->kg_next_engine_params.cc.bypass_plcr_profile_generation
103472 + = param->kg_next_engine_params.cc.bypass_plcr_profile_generation;
103473 + memcpy(&compat_param->kg_next_engine_params.cc.plcr_profile,
103474 + &param->kg_next_engine_params.cc.plcr_profile,
103475 + sizeof(ioc_fm_pcd_kg_plcr_profile_t));
103476 + }
103477 + else
103478 + memcpy(&param->kg_next_engine_params, &compat_param->kg_next_engine_params, sizeof(compat_param->kg_next_engine_params));
103479 +
103480 + memcpy(&compat_param->scheme_counter, &param->scheme_counter, sizeof(ioc_fm_pcd_kg_scheme_counter_t));
103481 +
103482 + compat_param->id = compat_add_ptr2id(param->id, FM_MAP_TYPE_PCD_NODE);
103483 + }
103484 +
103485 + _fm_cpt_dbg(compat," ...->}\n");
103486 +}
103487 +
103488 +void compat_copy_fm_pcd_kg_scheme_spc(
103489 + ioc_compat_fm_pcd_kg_scheme_spc_t *compat_param,
103490 + ioc_fm_pcd_kg_scheme_spc_t *param,
103491 + uint8_t compat)
103492 +{
103493 + if (compat == COMPAT_US_TO_K)
103494 + {
103495 + param->id = compat_pcd_id2ptr(compat_param->id);
103496 + param->val = compat_param->val;
103497 + } else {
103498 + compat_param->id = compat_pcd_ptr2id(param->id);
103499 + compat_param->val = param->val;
103500 + }
103501 +}
103502 +
103503 +
103504 +void compat_copy_fm_pcd_kg_scheme_select(
103505 + ioc_compat_fm_pcd_kg_scheme_select_t *compat_param,
103506 + ioc_fm_pcd_kg_scheme_select_t *param,
103507 + uint8_t compat)
103508 +{
103509 + if (compat == COMPAT_US_TO_K)
103510 + {
103511 + param->direct = compat_param->direct;
103512 + if (param->direct)
103513 + param->scheme_id = compat_pcd_id2ptr(compat_param->scheme_id);
103514 + }
103515 +}
103516 +
103517 +void compat_copy_fm_pcd_kg_schemes_params(
103518 + ioc_compat_fm_pcd_port_schemes_params_t *compat_param,
103519 + ioc_fm_pcd_port_schemes_params_t *param,
103520 + uint8_t compat)
103521 +{
103522 + int k;
103523 +
103524 + if (compat == COMPAT_US_TO_K) {
103525 + param->num_of_schemes = compat_param->num_of_schemes;
103526 + for(k=0; k < compat_param->num_of_schemes; k++)
103527 + param->scheme_ids[k] = compat_pcd_id2ptr(compat_param->scheme_ids[k]);
103528 + }
103529 +}
103530 +
103531 +void compat_copy_fm_port_pcd_cc(
103532 + ioc_compat_fm_port_pcd_cc_params_t *compat_cc_params ,
103533 + ioc_fm_port_pcd_cc_params_t *p_cc_params,
103534 + uint8_t compat)
103535 +{
103536 + if (compat == COMPAT_US_TO_K){
103537 + p_cc_params->cc_tree_id = compat_pcd_id2ptr(compat_cc_params->cc_tree_id);
103538 + }
103539 +}
103540 +
103541 +void compat_copy_fm_port_pcd_kg(
103542 + ioc_compat_fm_port_pcd_kg_params_t *compat_param,
103543 + ioc_fm_port_pcd_kg_params_t *param,
103544 + uint8_t compat)
103545 +{
103546 + if (compat == COMPAT_US_TO_K){
103547 + uint8_t k;
103548 +
103549 + param->num_of_schemes = compat_param->num_of_schemes;
103550 + for(k=0; k<compat_param->num_of_schemes; k++)
103551 + param->scheme_ids[k] = compat_pcd_id2ptr(compat_param->scheme_ids[k]);
103552 +
103553 + param->direct_scheme = compat_param->direct_scheme;
103554 + if (param->direct_scheme)
103555 + param->direct_scheme_id = compat_pcd_id2ptr(compat_param->direct_scheme_id);
103556 + }
103557 +}
103558 +
103559 +void compat_copy_fm_port_pcd(
103560 + ioc_compat_fm_port_pcd_params_t *compat_param,
103561 + ioc_fm_port_pcd_params_t *param,
103562 + uint8_t compat)
103563 +{
103564 + if (compat == COMPAT_US_TO_K)
103565 + {
103566 + ioc_fm_port_pcd_prs_params_t *same_port_pcd_prs_params;
103567 + ioc_compat_fm_port_pcd_cc_params_t *compat_port_pcd_cc_params;
103568 + ioc_compat_fm_port_pcd_kg_params_t *compat_port_pcd_kg_params;
103569 + ioc_compat_fm_port_pcd_plcr_params_t *compat_port_pcd_plcr_params;
103570 +
103571 + same_port_pcd_prs_params = (ioc_fm_port_pcd_prs_params_t *) (compat_param + 1);
103572 + compat_port_pcd_cc_params = (ioc_compat_fm_port_pcd_cc_params_t *) (same_port_pcd_prs_params + 1);
103573 + compat_port_pcd_kg_params = (ioc_compat_fm_port_pcd_kg_params_t *) (compat_port_pcd_cc_params + 1);
103574 + compat_port_pcd_plcr_params = (ioc_compat_fm_port_pcd_plcr_params_t *) (compat_port_pcd_kg_params + 1);
103575 +
103576 + _fm_cpt_dbg(compat,"\n param->p_prs_params=%p \n", param->p_prs_params);
103577 + _fm_cpt_dbg(compat," param->p_cc_params=%p \n", param->p_cc_params);
103578 + _fm_cpt_dbg(compat," param->p_kg_params=%p \n", param->p_kg_params);
103579 + _fm_cpt_dbg(compat," param->p_plcr_params=%p \n", param->p_plcr_params);
103580 + _fm_cpt_dbg(compat," param->p_ip_reassembly_manip=%p \n", param->p_ip_reassembly_manip);
103581 +#if (DPAA_VERSION >= 11)
103582 + _fm_cpt_dbg(compat," param->p_capwap_reassembly_manip=%p \n", param->p_capwap_reassembly_manip);
103583 +#endif
103584 + param->pcd_support = compat_param->pcd_support;
103585 + param->net_env_id = compat_pcd_id2ptr(compat_param->net_env_id);
103586 +
103587 + if (param->p_cc_params)
103588 + compat_copy_fm_port_pcd_cc(compat_port_pcd_cc_params, param->p_cc_params, COMPAT_US_TO_K);
103589 + if (param->p_kg_params)
103590 + compat_copy_fm_port_pcd_kg(compat_port_pcd_kg_params, param->p_kg_params, COMPAT_US_TO_K);
103591 + if (param->p_plcr_params)
103592 + param->p_plcr_params->plcr_profile_id = compat_pcd_id2ptr(compat_port_pcd_plcr_params->plcr_profile_id);
103593 + param->p_ip_reassembly_manip = compat_pcd_id2ptr(compat_param->p_ip_reassembly_manip);
103594 +#if (DPAA_VERSION >= 11)
103595 + param->p_capwap_reassembly_manip = compat_pcd_id2ptr(compat_param->p_capwap_reassembly_manip);
103596 +#endif
103597 + }
103598 +}
103599 +
103600 +void compat_copy_fm_port_pcd_modify_tree(
103601 + ioc_compat_fm_obj_t *compat_id,
103602 + ioc_fm_obj_t *id,
103603 + uint8_t compat)
103604 +{
103605 + if (compat == COMPAT_US_TO_K)
103606 + id->obj = compat_pcd_id2ptr(compat_id->obj);
103607 +}
103608 +
103609 +#if (DPAA_VERSION >= 11)
103610 +void compat_copy_fm_port_vsp_alloc_params(
103611 + ioc_compat_fm_port_vsp_alloc_params_t *compat_param,
103612 + ioc_fm_port_vsp_alloc_params_t *param,
103613 + uint8_t compat)
103614 +{
103615 + if (compat == COMPAT_US_TO_K)
103616 + {
103617 + _fm_cpt_dbg(compat," param->p_fm_tx_port=%p \n", param->p_fm_tx_port);
103618 +
103619 + param->dflt_relative_id = compat_param->dflt_relative_id;
103620 + param->num_of_profiles = compat_param->num_of_profiles;
103621 + param->p_fm_tx_port = compat_pcd_id2ptr(compat_param->p_fm_tx_port);
103622 + }
103623 +}
103624 +#endif /* (DPAA_VERSION >= 11) */
103625 +
103626 +void compat_copy_fm_pcd_cc_tbl_get_stats(
103627 + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param,
103628 + ioc_fm_pcd_cc_tbl_get_stats_t *param,
103629 + uint8_t compat)
103630 +{
103631 + if (compat == COMPAT_US_TO_K)
103632 + {
103633 + param->id = compat_pcd_id2ptr(compat_param->id);
103634 + param->key_index = compat_param->key_index;
103635 + memcpy(&param->statistics, &compat_param->statistics, sizeof(ioc_fm_pcd_cc_key_statistics_t));
103636 + } else {
103637 + compat_param->id = compat_add_ptr2id(param->id, FM_MAP_TYPE_PCD_NODE);
103638 + compat_param->key_index = param->key_index;
103639 + memcpy(&compat_param->statistics, &param->statistics, sizeof(ioc_fm_pcd_cc_key_statistics_t));
103640 + }
103641 +}
103642 +
103643 +
103644 +void compat_copy_fm_pcd_net_env(
103645 + ioc_compat_fm_pcd_net_env_params_t *compat_param,
103646 + ioc_fm_pcd_net_env_params_t *param,
103647 + uint8_t compat)
103648 +{
103649 + if (compat == COMPAT_US_TO_K)
103650 + {
103651 + param->num_of_distinction_units = compat_param->num_of_distinction_units;
103652 + memcpy(param->units, compat_param->units, sizeof(ioc_fm_pcd_distinction_unit_t)*IOC_FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
103653 + param->id = NULL; /* to avoid passing garbage to the kernel */
103654 + }
103655 + else
103656 + {
103657 + compat_param->num_of_distinction_units = param->num_of_distinction_units;
103658 + memcpy(compat_param->units, param->units, sizeof(ioc_fm_pcd_distinction_unit_t)*IOC_FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
103659 +
103660 + compat_param->id = compat_add_ptr2id(param->id, FM_MAP_TYPE_PCD_NODE);
103661 + }
103662 +}
103663 +
103664 +void compat_copy_fm_pcd_cc_node_modify_key(
103665 + ioc_compat_fm_pcd_cc_node_modify_key_params_t *compat_param,
103666 + ioc_fm_pcd_cc_node_modify_key_params_t *param,
103667 + uint8_t compat)
103668 +{
103669 + if (compat == COMPAT_US_TO_K)
103670 + {
103671 + param->key_indx = compat_param->key_indx;
103672 + param->key_size = compat_param->key_size;
103673 + param->p_key = (uint8_t *)compat_ptr(compat_param->p_key);
103674 + _fm_cpt_dbg(compat," param->p_key = %p \n", param->p_key);
103675 + param->p_mask = (uint8_t *)compat_ptr(compat_param->p_mask);
103676 + _fm_cpt_dbg(compat," param->p_mask = %p\n", param->p_mask);
103677 + param->id = compat_pcd_id2ptr(compat_param->id);
103678 + _fm_cpt_dbg(compat," param->id = %p \n", param->id);
103679 + }
103680 + else
103681 + {
103682 + compat_param->key_indx = param->key_indx;
103683 + compat_param->key_size = param->key_size;
103684 + compat_param->p_key = ptr_to_compat((void *)param->p_key);
103685 + compat_param->p_mask = ptr_to_compat((void *)param->p_mask);
103686 +
103687 + compat_param->id = compat_add_ptr2id(param->id, FM_MAP_TYPE_PCD_NODE);
103688 + }
103689 +}
103690 +
103691 +void compat_copy_keys(
103692 + ioc_compat_keys_params_t *compat_param,
103693 + ioc_keys_params_t *param,
103694 + uint8_t compat)
103695 +{
103696 + int k = 0;
103697 +
103698 + _fm_cpt_dbg(compat," {->...\n");
103699 +
103700 + if (compat == COMPAT_US_TO_K) {
103701 + param->max_num_of_keys = compat_param->max_num_of_keys;
103702 + param->mask_support = compat_param->mask_support;
103703 + param->statistics_mode = compat_param->statistics_mode;
103704 + param->num_of_keys = compat_param->num_of_keys;
103705 + param->key_size = compat_param->key_size;
103706 +#if (DPAA_VERSION >= 11)
103707 + memcpy(&param->frame_length_ranges,
103708 + &compat_param->frame_length_ranges,
103709 + sizeof(param->frame_length_ranges[0]) *
103710 + IOC_FM_PCD_CC_STATS_MAX_NUM_OF_FLR);
103711 +#endif /* (DPAA_VERSION >= 11) */
103712 + }
103713 + else {
103714 + compat_param->max_num_of_keys = param->max_num_of_keys;
103715 + compat_param->mask_support = param->mask_support;
103716 + compat_param->statistics_mode = param->statistics_mode;
103717 + compat_param->num_of_keys = param->num_of_keys;
103718 + compat_param->key_size = param->key_size;
103719 +#if (DPAA_VERSION >= 11)
103720 + memcpy(&compat_param->frame_length_ranges,
103721 + &param->frame_length_ranges,
103722 + sizeof(compat_param->frame_length_ranges[0]) *
103723 + IOC_FM_PCD_CC_STATS_MAX_NUM_OF_FLR);
103724 +#endif /* (DPAA_VERSION >= 11) */
103725 + }
103726 +
103727 + for (k=0; k < IOC_FM_PCD_MAX_NUM_OF_KEYS; k++)
103728 + compat_copy_fm_pcd_cc_key(
103729 + &compat_param->key_params[k],
103730 + &param->key_params[k],
103731 + compat);
103732 +
103733 + compat_copy_fm_pcd_cc_next_engine(
103734 + &compat_param->cc_next_engine_params_for_miss,
103735 + &param->cc_next_engine_params_for_miss,
103736 + compat);
103737 +
103738 + _fm_cpt_dbg(compat," ...->}\n");
103739 +}
103740 +
103741 +void compat_copy_fm_pcd_cc_node(
103742 + ioc_compat_fm_pcd_cc_node_params_t *compat_param,
103743 + ioc_fm_pcd_cc_node_params_t *param,
103744 + uint8_t compat)
103745 +{
103746 + _fm_cpt_dbg(compat," {->...\n");
103747 +
103748 + if (compat == COMPAT_US_TO_K)
103749 + memcpy(&param->extract_cc_params, &compat_param->extract_cc_params, sizeof(ioc_fm_pcd_extract_entry_t));
103750 +
103751 + else
103752 + {
103753 + compat_copy_keys(&compat_param->keys_params, &param->keys_params, compat);
103754 +
103755 + compat_param->id = compat_add_ptr2id(param->id, FM_MAP_TYPE_PCD_NODE);
103756 + _fm_cpt_dbg(compat," param->id = %p \n", param->id);
103757 + }
103758 +
103759 + compat_copy_keys(&compat_param->keys_params, &param->keys_params, compat);
103760 +
103761 + _fm_cpt_dbg(compat," ...->}\n");
103762 +}
103763 +
103764 +void compat_fm_pcd_manip_set_node(
103765 + ioc_compat_fm_pcd_manip_params_t *compat_param,
103766 + ioc_fm_pcd_manip_params_t *param,
103767 + uint8_t compat)
103768 +{
103769 + if (compat == COMPAT_US_TO_K) {
103770 + param->type = compat_param->type;
103771 + switch (param->type) {
103772 + case e_IOC_FM_PCD_MANIP_HDR:
103773 + param->u.hdr.rmv = compat_param->u.hdr.rmv;
103774 + memcpy(&param->u.hdr.rmv_params,
103775 + &compat_param->u.hdr.rmv_params,
103776 + sizeof(param->u.hdr.rmv_params));
103777 +
103778 + param->u.hdr.insrt = compat_param->u.hdr.insrt;
103779 + param->u.hdr.insrt_params.type =
103780 + compat_param->u.hdr.insrt_params.type;
103781 + switch (compat_param->u.hdr.insrt_params.type)
103782 + {
103783 + case e_IOC_FM_PCD_MANIP_INSRT_GENERIC:
103784 + param->u.hdr.insrt_params.u.generic.offset =
103785 + compat_param->u.hdr.insrt_params.u.generic.offset;
103786 + param->u.hdr.insrt_params.u.generic.size =
103787 + compat_param->u.hdr.insrt_params.u.generic.size;
103788 + param->u.hdr.insrt_params.u.generic.replace =
103789 + compat_param->u.hdr.insrt_params.u.generic.replace;
103790 + param->u.hdr.insrt_params.u.generic.p_data =
103791 + compat_ptr(compat_param->u.hdr.insrt_params.u.generic.p_data);
103792 + break;
103793 + case e_IOC_FM_PCD_MANIP_INSRT_BY_HDR:
103794 + param->u.hdr.insrt_params.u.by_hdr.type =
103795 + compat_param->u.hdr.insrt_params.u.by_hdr.type;
103796 + param->u.hdr.insrt_params.u.by_hdr.u.specific_l2_params.specific_l2 =
103797 + compat_param->u.hdr.insrt_params.u.by_hdr.u.specific_l2_params.specific_l2;
103798 + param->u.hdr.insrt_params.u.by_hdr.u.specific_l2_params.update =
103799 + compat_param->u.hdr.insrt_params.u.by_hdr.u.specific_l2_params.update;
103800 + param->u.hdr.insrt_params.u.by_hdr.u.specific_l2_params.size =
103801 + compat_param->u.hdr.insrt_params.u.by_hdr.u.specific_l2_params.size;
103802 + param->u.hdr.insrt_params.u.by_hdr.u.specific_l2_params.p_data =
103803 + compat_ptr(compat_param->u.hdr.insrt_params.u.by_hdr.u.specific_l2_params.p_data);
103804 + break;
103805 + default:
103806 + _fm_cpt_err("Unsupported type: %d", compat_param->u.hdr.insrt_params.type);
103807 + }
103808 +
103809 + param->u.hdr.field_update = compat_param->u.hdr.field_update;
103810 + memcpy(&param->u.hdr.field_update_params,
103811 + &compat_param->u.hdr.field_update_params,
103812 + sizeof(param->u.hdr.field_update_params));
103813 +
103814 + param->u.hdr.custom = compat_param->u.hdr.custom;
103815 + memcpy(&param->u.hdr.custom_params,
103816 + &compat_param->u.hdr.custom_params,
103817 + sizeof(param->u.hdr.custom_params));
103818 +
103819 + param->u.hdr.dont_parse_after_manip =
103820 + compat_param->u.hdr.dont_parse_after_manip;
103821 + break;
103822 + case e_IOC_FM_PCD_MANIP_REASSEM:
103823 + memcpy(&param->u.reassem, &compat_param->u.reassem, sizeof(param->u.reassem));
103824 + break;
103825 + case e_IOC_FM_PCD_MANIP_FRAG:
103826 + memcpy(&param->u.frag, &compat_param->u.frag, sizeof(param->u.frag));
103827 + break;
103828 + case e_IOC_FM_PCD_MANIP_SPECIAL_OFFLOAD:
103829 + memcpy(&param->u.special_offload,
103830 + &compat_param->u.special_offload,
103831 + sizeof(param->u.special_offload));
103832 + break;
103833 + }
103834 +
103835 + param->p_next_manip = compat_pcd_id2ptr(compat_param->p_next_manip);
103836 + param->id = compat_pcd_id2ptr(compat_param->id);
103837 + }
103838 + else {
103839 + compat_param->type = param->type;
103840 + memcpy(&compat_param->u, &param->u, sizeof(compat_param->u));
103841 +
103842 + if (param->type == e_IOC_FM_PCD_MANIP_HDR &&
103843 + param->u.hdr.insrt_params.type == e_IOC_FM_PCD_MANIP_INSRT_GENERIC)
103844 + compat_param->u.hdr.insrt_params.u.generic.p_data =
103845 + ptr_to_compat(param->u.hdr.insrt_params.u.generic.p_data);
103846 +
103847 + compat_param->p_next_manip = compat_pcd_ptr2id(param->id);
103848 + /* ... should be one that was added previously by the very call to
103849 + compat_add_ptr2id() below: */
103850 + compat_param->id = compat_add_ptr2id(param->id, FM_MAP_TYPE_PCD_NODE);
103851 + }
103852 +}
103853 +
103854 +void compat_copy_fm_pcd_manip_get_stats(
103855 + ioc_compat_fm_pcd_manip_get_stats_t *compat_param,
103856 + ioc_fm_pcd_manip_get_stats_t *param,
103857 + uint8_t compat)
103858 +{
103859 + _fm_cpt_dbg (compat, " {->...\n");
103860 +
103861 + if (compat == COMPAT_US_TO_K)
103862 + {
103863 + param->id = compat_pcd_id2ptr(compat_param->id);
103864 + memcpy(&param->stats, &compat_param->stats,
103865 + sizeof(ioc_fm_pcd_manip_stats_t));
103866 + }
103867 + else
103868 + {
103869 + compat_param->id = compat_add_ptr2id(param->id,
103870 + FM_MAP_TYPE_PCD_NODE);
103871 + memcpy(&compat_param->stats, &param->stats,
103872 + sizeof(ioc_fm_pcd_manip_stats_t));
103873 + }
103874 +
103875 + _fm_cpt_dbg (compat, " ...->}\n");
103876 +}
103877 +
103878 +#if (DPAA_VERSION >= 11)
103879 +void compat_copy_fm_pcd_frm_replic_group_params(
103880 + ioc_compat_fm_pcd_frm_replic_group_params_t *compat_param,
103881 + ioc_fm_pcd_frm_replic_group_params_t *param,
103882 + uint8_t compat)
103883 +{
103884 + int k;
103885 +
103886 + _fm_cpt_dbg (compat, " {->...\n");
103887 +
103888 + if (compat == COMPAT_US_TO_K)
103889 + {
103890 + param->max_num_of_entries = compat_param->max_num_of_entries;
103891 + param->num_of_entries = compat_param->num_of_entries;
103892 + param->id = compat_pcd_id2ptr(compat_param->id);
103893 + }
103894 + else
103895 + {
103896 + compat_param->max_num_of_entries = param->max_num_of_entries;
103897 + compat_param->num_of_entries = param->num_of_entries;
103898 + compat_param->id = compat_add_ptr2id(param->id,
103899 + FM_MAP_TYPE_PCD_NODE);
103900 + }
103901 +
103902 + for (k=0; k < IOC_FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES; k++)
103903 + compat_copy_fm_pcd_cc_next_engine(
103904 + &compat_param->next_engine_params[k],
103905 + &param->next_engine_params[k],
103906 + compat);
103907 +
103908 + _fm_cpt_dbg (compat, " ...->}\n");
103909 +}
103910 +
103911 +void compat_copy_fm_pcd_frm_replic_member(
103912 + ioc_compat_fm_pcd_frm_replic_member_t *compat_param,
103913 + ioc_fm_pcd_frm_replic_member_t *param,
103914 + uint8_t compat)
103915 +{
103916 + _fm_cpt_dbg (compat, " {->...\n");
103917 +
103918 + if (compat == COMPAT_US_TO_K)
103919 + {
103920 + param->h_replic_group = compat_pcd_id2ptr(compat_param->h_replic_group);
103921 + param->member_index = compat_param->member_index;
103922 + }
103923 +
103924 + _fm_cpt_dbg (compat, " ...->}\n");
103925 +}
103926 +
103927 +void compat_copy_fm_pcd_frm_replic_member_params(
103928 + ioc_compat_fm_pcd_frm_replic_member_params_t *compat_param,
103929 + ioc_fm_pcd_frm_replic_member_params_t *param,
103930 + uint8_t compat)
103931 +{
103932 + _fm_cpt_dbg (compat, " {->...\n");
103933 +
103934 + compat_copy_fm_pcd_frm_replic_member(&compat_param->member,
103935 + &param->member, compat);
103936 +
103937 + compat_copy_fm_pcd_cc_next_engine(&compat_param->next_engine_params,
103938 + &param->next_engine_params, compat);
103939 +
103940 + _fm_cpt_dbg (compat, " ...->}\n");
103941 +}
103942 +
103943 +void compat_copy_fm_vsp_params(
103944 + ioc_compat_fm_vsp_params_t *compat_param,
103945 + ioc_fm_vsp_params_t *param,
103946 + uint8_t compat)
103947 +{
103948 + _fm_cpt_dbg (compat, " {->...\n");
103949 +
103950 + if (compat == COMPAT_US_TO_K)
103951 + {
103952 + param->p_fm = compat_pcd_id2ptr(compat_param->p_fm);
103953 + memcpy(&param->ext_buf_pools, &compat_param->ext_buf_pools, sizeof(ioc_fm_ext_pools));
103954 + param->liodn_offset = compat_param->liodn_offset;
103955 + param->port_params.port_id = compat_param->port_params.port_id;
103956 + param->port_params.port_type = compat_param->port_params.port_type;
103957 + param->relative_profile_id = compat_param->relative_profile_id;
103958 + param->id = compat_pcd_id2ptr(compat_param->id);
103959 + }
103960 + else
103961 + {
103962 + compat_param->p_fm = compat_pcd_ptr2id(param->p_fm);
103963 + memcpy(&compat_param->ext_buf_pools, &param->ext_buf_pools, sizeof(ioc_fm_ext_pools));
103964 + compat_param->liodn_offset = param->liodn_offset;
103965 + compat_param->port_params.port_id = param->port_params.port_id;
103966 + compat_param->port_params.port_type = param->port_params.port_type;
103967 + compat_param->relative_profile_id = param->relative_profile_id;
103968 + compat_param->id = compat_add_ptr2id(param->id, FM_MAP_TYPE_PCD_NODE);
103969 + }
103970 +
103971 + _fm_cpt_dbg (compat, " ...->}\n");
103972 +}
103973 +
103974 +void compat_copy_fm_buf_pool_depletion_params(
103975 + ioc_compat_fm_buf_pool_depletion_params_t *compat_param,
103976 + ioc_fm_buf_pool_depletion_params_t *param,
103977 + uint8_t compat)
103978 +{
103979 + _fm_cpt_dbg (compat, " {->...\n");
103980 +
103981 + if (compat == COMPAT_US_TO_K)
103982 + {
103983 + param->p_fm_vsp = compat_pcd_id2ptr(compat_param->p_fm_vsp);
103984 + memcpy(&param->fm_buf_pool_depletion,
103985 + &compat_param->fm_buf_pool_depletion,
103986 + sizeof(ioc_fm_buf_pool_depletion_t));
103987 + }
103988 +
103989 + _fm_cpt_dbg (compat, " ...->}\n");
103990 +}
103991 +
103992 +void compat_copy_fm_buffer_prefix_content_params(
103993 + ioc_compat_fm_buffer_prefix_content_params_t *compat_param,
103994 + ioc_fm_buffer_prefix_content_params_t *param,
103995 + uint8_t compat)
103996 +{
103997 + _fm_cpt_dbg (compat, " {->...\n");
103998 +
103999 + if (compat == COMPAT_US_TO_K)
104000 + {
104001 + param->p_fm_vsp = compat_pcd_id2ptr(compat_param->p_fm_vsp);
104002 + memcpy(&param->fm_buffer_prefix_content,
104003 + &compat_param->fm_buffer_prefix_content,
104004 + sizeof(ioc_fm_buffer_prefix_content_t));
104005 + }
104006 +
104007 + _fm_cpt_dbg (compat, " ...->}\n");
104008 +}
104009 +
104010 +void compat_copy_fm_vsp_config_no_sg_params(
104011 + ioc_compat_fm_vsp_config_no_sg_params_t *compat_param,
104012 + ioc_fm_vsp_config_no_sg_params_t *param,
104013 + uint8_t compat)
104014 +{
104015 + _fm_cpt_dbg (compat, " {->...\n");
104016 +
104017 + if (compat == COMPAT_US_TO_K)
104018 + {
104019 + param->p_fm_vsp = compat_pcd_id2ptr(compat_param->p_fm_vsp);
104020 + param->no_sg = compat_param->no_sg;
104021 + }
104022 +
104023 + _fm_cpt_dbg (compat, " ...->}\n");
104024 +}
104025 +
104026 +void compat_copy_fm_vsp_prs_result_params(
104027 + ioc_compat_fm_vsp_prs_result_params_t *compat_param,
104028 + ioc_fm_vsp_prs_result_params_t *param,
104029 + uint8_t compat)
104030 +{
104031 + _fm_cpt_dbg (compat, " {->...\n");
104032 +
104033 + if (compat == COMPAT_US_TO_K)
104034 + {
104035 + param->p_fm_vsp = compat_pcd_id2ptr(compat_param->p_fm_vsp);
104036 + /* p_data is an user-space pointer that needs to remain unmodified */
104037 + param->p_data = (void *)(unsigned long long)compat_param->p_data;
104038 + }
104039 + else
104040 + {
104041 + compat_param->p_fm_vsp = compat_pcd_ptr2id(param->p_fm_vsp);
104042 + /* p_data is an user-space pointer that needs to remain unmodified */
104043 + compat_param->p_data = (compat_uptr_t)((unsigned long long)param->p_data & 0xFFFFFFFF);
104044 + }
104045 +
104046 + _fm_cpt_dbg (compat, " ...->}\n");
104047 +}
104048 +#endif /* (DPAA_VERSION >= 11) */
104049 --- /dev/null
104050 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.h
104051 @@ -0,0 +1,755 @@
104052 +/*
104053 + * Copyright 2008-2012 Freescale Semiconductor Inc.
104054 + *
104055 + * Redistribution and use in source and binary forms, with or without
104056 + * modification, are permitted provided that the following conditions are met:
104057 + * * Redistributions of source code must retain the above copyright
104058 + * notice, this list of conditions and the following disclaimer.
104059 + * * Redistributions in binary form must reproduce the above copyright
104060 + * notice, this list of conditions and the following disclaimer in the
104061 + * documentation and/or other materials provided with the distribution.
104062 + * * Neither the name of Freescale Semiconductor nor the
104063 + * names of its contributors may be used to endorse or promote products
104064 + * derived from this software without specific prior written permission.
104065 + *
104066 + *
104067 + * ALTERNATIVELY, this software may be distributed under the terms of the
104068 + * GNU General Public License ("GPL") as published by the Free Software
104069 + * Foundation, either version 2 of that License or (at your option) any
104070 + * later version.
104071 + *
104072 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
104073 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
104074 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
104075 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
104076 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
104077 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
104078 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
104079 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
104080 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
104081 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
104082 + */
104083 +
104084 +/*
104085 + @File lnxwrp_ioctls_fm_compat.h
104086 +
104087 + @Description FM PCD compat structures definition.
104088 +
104089 +*/
104090 +
104091 +#ifndef __FM_COMPAT_IOCTLS_H
104092 +#define __FM_COMPAT_IOCTLS_H
104093 +
104094 +#include <linux/compat.h>
104095 +
104096 +#define COMPAT_K_TO_US 0 /* copy from Kernel to User */
104097 +#define COMPAT_US_TO_K 1 /* copy from User to Kernel */
104098 +#define COMPAT_GENERIC 2
104099 +
104100 +#define COMPAT_COPY_K2US(dest, src, type) compat_copy_##type(src, dest, 0)
104101 +#define COMPAT_COPY_US2K(dest, src, type) compat_copy_##type(dest, src, 1)
104102 +
104103 +/* mapping kernel pointers w/ UserSpace id's { */
104104 +/* Because compat_ptr(ptr_to_compat(X)) != X, this way we cannot exchange pointers
104105 + back and forth (US - KS). compat_ptr is a cast and pointers are broken. */
104106 +#define COMPAT_PTR2ID_ARRAY_MAX (512+1) /* first location is not used */
104107 +#define COMPAT_PTR2ID_WATERMARK 0xface0000
104108 +#define COMPAT_PTR2ID_WM_MASK 0xffff0000
104109 +
104110 +/* define it for debug trace */
104111 +/*#define FM_COMPAT_DBG*/
104112 +
104113 +#define _fm_cpt_prk(stage, format, arg...) \
104114 + printk(stage "fm_cpt (cpu:%u): " format, raw_smp_processor_id(), ##arg)
104115 +
104116 +#define _fm_cpt_inf(format, arg...) _fm_cpt_prk(KERN_INFO, format, ##arg)
104117 +#define _fm_cpt_wrn(format, arg...) _fm_cpt_prk(KERN_WARNING, format, ##arg)
104118 +#define _fm_cpt_err(format, arg...) _fm_cpt_prk(KERN_ERR, format, ##arg)
104119 +
104120 +/* used for compat IOCTL debugging */
104121 +#if defined(FM_COMPAT_DBG)
104122 + #define _fm_cpt_dbg(from, format, arg...) \
104123 + do{ \
104124 + if (from == COMPAT_US_TO_K) \
104125 + printk("fm_cpt to KS [%s:%u](cpu:%u) - " format, \
104126 + __func__, __LINE__, raw_smp_processor_id(), ##arg); \
104127 + else if (from == COMPAT_K_TO_US) \
104128 + printk("fm_cpt to US [%s:%u](cpu:%u) - " format, \
104129 + __func__, __LINE__, raw_smp_processor_id(), ##arg); \
104130 + else \
104131 + printk("fm_cpt [%s:%u](cpu:%u) - " format, \
104132 + __func__, __LINE__, raw_smp_processor_id(), ##arg); \
104133 + }while(0)
104134 +#else
104135 +# define _fm_cpt_dbg(arg...)
104136 +#endif
104137 +
104138 +/*TODO: per FMan module:
104139 + *
104140 + * Parser: FM_MAP_TYPE_PARSER_NODE,
104141 + * Kg: FM_MAP_TYPE_KG_NODE,
104142 + * Policer: FM_MAP_TYPE_POLICER_NODE
104143 + * Manip: FM_MAP_TYPE_MANIP_NODE
104144 + **/
104145 +enum fm_map_node_type {
104146 + FM_MAP_TYPE_UNSPEC = 0,
104147 + FM_MAP_TYPE_PCD_NODE,
104148 +
104149 + /* add types here, update the policy */
104150 +
104151 + __FM_MAP_TYPE_AFTER_LAST,
104152 + FM_MAP_TYPE_MAX = __FM_MAP_TYPE_AFTER_LAST - 1
104153 +};
104154 +
104155 +void compat_del_ptr2id(void *p, enum fm_map_node_type);
104156 +compat_uptr_t compat_add_ptr2id(void *p, enum fm_map_node_type);
104157 +compat_uptr_t compat_get_ptr2id(void *p, enum fm_map_node_type);
104158 +void *compat_get_id2ptr(compat_uptr_t comp, enum fm_map_node_type);
104159 +
104160 +static inline compat_uptr_t compat_pcd_ptr2id(void *ptr) {
104161 + return (ptr)? compat_get_ptr2id(ptr, FM_MAP_TYPE_PCD_NODE)
104162 + : (compat_uptr_t) 0;
104163 +}
104164 +
104165 +static inline void *compat_pcd_id2ptr(compat_uptr_t id) {
104166 + return (id) ? compat_get_id2ptr(id, FM_MAP_TYPE_PCD_NODE)
104167 + : NULL;
104168 +}
104169 +
104170 +/* other similar inlines may be added as new nodes are added
104171 + to enum fm_map_node_type above... */
104172 +/* } mapping kernel pointers w/ UserSpace id's */
104173 +
104174 +/* pcd compat structures { */
104175 +typedef struct ioc_compat_fm_pcd_cc_node_remove_key_params_t {
104176 + compat_uptr_t id;
104177 + uint16_t key_indx;
104178 +} ioc_compat_fm_pcd_cc_node_remove_key_params_t;
104179 +
104180 +typedef union ioc_compat_fm_pcd_plcr_next_engine_params_u {
104181 + ioc_fm_pcd_done_action action;
104182 + compat_uptr_t p_profile;
104183 + compat_uptr_t p_direct_scheme;
104184 +} ioc_compat_fm_pcd_plcr_next_engine_params_u;
104185 +
104186 +typedef struct ioc_compat_fm_pcd_plcr_profile_params_t {
104187 + bool modify;
104188 + union {
104189 + struct {
104190 + ioc_fm_pcd_profile_type_selection profile_type;
104191 + compat_uptr_t p_fm_port;
104192 + uint16_t relative_profile_id;
104193 + } new_params;
104194 + compat_uptr_t p_profile;
104195 + } profile_select;
104196 + ioc_fm_pcd_plcr_algorithm_selection alg_selection;
104197 + ioc_fm_pcd_plcr_color_mode color_mode;
104198 +
104199 + union {
104200 + ioc_fm_pcd_plcr_color dflt_color;
104201 + ioc_fm_pcd_plcr_color override;
104202 + } color;
104203 +
104204 + ioc_fm_pcd_plcr_non_passthrough_alg_param_t non_passthrough_alg_param;
104205 +
104206 + ioc_fm_pcd_engine next_engine_on_green;
104207 + ioc_compat_fm_pcd_plcr_next_engine_params_u params_on_green;
104208 +
104209 + ioc_fm_pcd_engine next_engine_on_yellow;
104210 + ioc_compat_fm_pcd_plcr_next_engine_params_u params_on_yellow;
104211 +
104212 + ioc_fm_pcd_engine next_engine_on_red;
104213 + ioc_compat_fm_pcd_plcr_next_engine_params_u params_on_red;
104214 +
104215 + bool trap_profile_on_flow_A;
104216 + bool trap_profile_on_flow_B;
104217 + bool trap_profile_on_flow_C;
104218 + compat_uptr_t id;
104219 +} ioc_compat_fm_pcd_plcr_profile_params_t;
104220 +
104221 +typedef struct ioc_compat_fm_obj_t {
104222 + compat_uptr_t obj;
104223 +} ioc_compat_fm_obj_t;
104224 +
104225 +typedef struct ioc_compat_fm_pcd_kg_scheme_select_t {
104226 + bool direct;
104227 + compat_uptr_t scheme_id;
104228 +} ioc_compat_fm_pcd_kg_scheme_select_t;
104229 +
104230 +typedef struct ioc_compat_fm_pcd_port_schemes_params_t {
104231 + uint8_t num_of_schemes;
104232 + compat_uptr_t scheme_ids[FM_PCD_KG_NUM_OF_SCHEMES];
104233 +} ioc_compat_fm_pcd_port_schemes_params_t;
104234 +
104235 +#if (DPAA_VERSION >= 11)
104236 +typedef struct ioc_compat_fm_port_vsp_alloc_params_t {
104237 + uint8_t num_of_profiles; /**< Number of Virtual Storage Profiles */
104238 + uint8_t dflt_relative_id; /**< The default Virtual-Storage-Profile-id dedicated to Rx/OP port
104239 + The same default Virtual-Storage-Profile-id will be for coupled Tx port
104240 + if relevant function called for Rx port */
104241 + compat_uptr_t p_fm_tx_port; /**< Handle to coupled Tx Port; not relevant for OP port. */
104242 +}ioc_compat_fm_port_vsp_alloc_params_t;
104243 +#endif /* (DPAA_VERSION >= 11) */
104244 +
104245 +typedef struct ioc_compat_fm_pcd_net_env_params_t {
104246 + uint8_t num_of_distinction_units;
104247 + ioc_fm_pcd_distinction_unit_t units[IOC_FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS]; /* same structure*/
104248 + compat_uptr_t id;
104249 +} ioc_compat_fm_pcd_net_env_params_t;
104250 +
104251 +typedef struct ioc_compat_fm_pcd_prs_sw_params_t {
104252 + bool override;
104253 + uint32_t size;
104254 + uint16_t base;
104255 + compat_uptr_t p_code;
104256 + uint32_t sw_prs_data_params[IOC_FM_PCD_PRS_NUM_OF_HDRS];
104257 + uint8_t num_of_labels;
104258 + ioc_fm_pcd_prs_label_params_t labels_table[IOC_FM_PCD_PRS_NUM_OF_LABELS];
104259 +} ioc_compat_fm_pcd_prs_sw_params_t;
104260 +
104261 +typedef struct ioc_compat_fm_pcd_cc_next_kg_params_t {
104262 + bool override_fqid;
104263 + uint32_t new_fqid;
104264 +#if DPAA_VERSION >= 11
104265 + uint8_t new_relative_storage_profile_id;
104266 +#endif
104267 + compat_uptr_t p_direct_scheme;
104268 +} ioc_compat_fm_pcd_cc_next_kg_params_t;
104269 +
104270 +typedef struct ioc_compat_fm_pcd_cc_next_cc_params_t {
104271 + compat_uptr_t cc_node_id;
104272 +} ioc_compat_fm_pcd_cc_next_cc_params_t;
104273 +
104274 +#if DPAA_VERSION >= 11
104275 +typedef struct ioc_compat_fm_pcd_cc_next_fr_params_t {
104276 + compat_uptr_t frm_replic_id;
104277 +} ioc_compat_fm_pcd_cc_next_fr_params_t;
104278 +#endif /* DPAA_VERSION >= 11 */
104279 +
104280 +typedef struct ioc_compat_fm_pcd_cc_next_engine_params_t {
104281 + ioc_fm_pcd_engine next_engine;
104282 + union {
104283 + ioc_compat_fm_pcd_cc_next_cc_params_t cc_params; /**< compat structure*/
104284 + ioc_fm_pcd_cc_next_plcr_params_t plcr_params; /**< same structure*/
104285 + ioc_fm_pcd_cc_next_enqueue_params_t enqueue_params; /**< same structure*/
104286 + ioc_compat_fm_pcd_cc_next_kg_params_t kg_params; /**< compat structure*/
104287 +#if DPAA_VERSION >= 11
104288 + ioc_compat_fm_pcd_cc_next_fr_params_t fr_params; /**< compat structure*/
104289 +#endif /* DPAA_VERSION >= 11 */
104290 + } params;
104291 + compat_uptr_t manip_id;
104292 + bool statistics_en;
104293 +} ioc_compat_fm_pcd_cc_next_engine_params_t;
104294 +
104295 +typedef struct ioc_compat_fm_pcd_cc_grp_params_t {
104296 + uint8_t num_of_distinction_units;
104297 + uint8_t unit_ids [IOC_FM_PCD_MAX_NUM_OF_CC_UNITS];
104298 + ioc_compat_fm_pcd_cc_next_engine_params_t next_engine_per_entries_in_grp[IOC_FM_PCD_MAX_NUM_OF_CC_ENTRIES_IN_GRP];
104299 +} ioc_compat_fm_pcd_cc_grp_params_t;
104300 +
104301 +typedef struct ioc_compat_fm_pcd_cc_tree_params_t {
104302 + compat_uptr_t net_env_id;
104303 + uint8_t num_of_groups;
104304 + ioc_compat_fm_pcd_cc_grp_params_t fm_pcd_cc_group_params [IOC_FM_PCD_MAX_NUM_OF_CC_GROUPS];
104305 + compat_uptr_t id;
104306 +} ioc_compat_fm_pcd_cc_tree_params_t;
104307 +
104308 +typedef struct ioc_compat_fm_pcd_cc_tree_modify_next_engine_params_t {
104309 + compat_uptr_t id;
104310 + uint8_t grp_indx;
104311 + uint8_t indx;
104312 + ioc_compat_fm_pcd_cc_next_engine_params_t cc_next_engine_params;
104313 +} ioc_compat_fm_pcd_cc_tree_modify_next_engine_params_t;
104314 +
104315 +typedef struct ioc_compat_fm_pcd_cc_key_params_t {
104316 + compat_uptr_t p_key;
104317 + compat_uptr_t p_mask;
104318 + ioc_compat_fm_pcd_cc_next_engine_params_t cc_next_engine_params; /**< compat structure*/
104319 +} ioc_compat_fm_pcd_cc_key_params_t;
104320 +
104321 +typedef struct ioc_compat_keys_params_t {
104322 + uint16_t max_num_of_keys;
104323 + bool mask_support;
104324 + ioc_fm_pcd_cc_stats_mode statistics_mode;
104325 +#if (DPAA_VERSION >= 11)
104326 + uint16_t frame_length_ranges[IOC_FM_PCD_CC_STATS_MAX_NUM_OF_FLR];
104327 +#endif /* (DPAA_VERSION >= 11) */
104328 + uint16_t num_of_keys;
104329 + uint8_t key_size;
104330 + ioc_compat_fm_pcd_cc_key_params_t key_params[IOC_FM_PCD_MAX_NUM_OF_KEYS]; /**< compat structure*/
104331 + ioc_compat_fm_pcd_cc_next_engine_params_t cc_next_engine_params_for_miss; /**< compat structure*/
104332 +} ioc_compat_keys_params_t;
104333 +
104334 +typedef struct ioc_compat_fm_pcd_cc_node_params_t {
104335 + ioc_fm_pcd_extract_entry_t extract_cc_params; /**< same structure*/
104336 + ioc_compat_keys_params_t keys_params; /**< compat structure*/
104337 + compat_uptr_t id;
104338 +} ioc_compat_fm_pcd_cc_node_params_t;
104339 +
104340 +/**************************************************************************//**
104341 + @Description Parameters for defining a hash table
104342 +*//***************************************************************************/
104343 +typedef struct ioc_compat_fm_pcd_hash_table_params_t {
104344 + uint16_t max_num_of_keys;
104345 + ioc_fm_pcd_cc_stats_mode statistics_mode;
104346 + uint8_t kg_hash_shift;
104347 + uint16_t hash_res_mask;
104348 + uint8_t hash_shift;
104349 + uint8_t match_key_size;
104350 + ioc_compat_fm_pcd_cc_next_engine_params_t cc_next_engine_params_for_miss;
104351 + compat_uptr_t id;
104352 +} ioc_compat_fm_pcd_hash_table_params_t;
104353 +
104354 +typedef struct ioc_compat_fm_pcd_hash_table_add_key_params_t {
104355 + compat_uptr_t p_hash_tbl;
104356 + uint8_t key_size;
104357 + ioc_compat_fm_pcd_cc_key_params_t key_params;
104358 +} ioc_compat_fm_pcd_hash_table_add_key_params_t;
104359 +
104360 +typedef struct ioc_compat_fm_pcd_cc_node_modify_key_params_t {
104361 + compat_uptr_t id;
104362 + uint16_t key_indx;
104363 + uint8_t key_size;
104364 + compat_uptr_t p_key;
104365 + compat_uptr_t p_mask;
104366 +} ioc_compat_fm_pcd_cc_node_modify_key_params_t;
104367 +
104368 +typedef struct ioc_compat_fm_pcd_hash_table_remove_key_params_t {
104369 + compat_uptr_t p_hash_tbl;
104370 + uint8_t key_size;
104371 + compat_uptr_t p_key;
104372 +} ioc_compat_fm_pcd_hash_table_remove_key_params_t;
104373 +
104374 +typedef struct ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t {
104375 + compat_uptr_t id;
104376 + uint16_t key_indx;
104377 + uint8_t key_size;
104378 + ioc_compat_fm_pcd_cc_key_params_t key_params;
104379 +} ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t;
104380 +
104381 +typedef struct ioc_compat_fm_port_pcd_plcr_params_t {
104382 + compat_uptr_t plcr_profile_id;
104383 +} ioc_compat_fm_port_pcd_plcr_params_t;
104384 +
104385 +typedef struct ioc_compat_fm_port_pcd_cc_params_t {
104386 + compat_uptr_t cc_tree_id;
104387 +} ioc_compat_fm_port_pcd_cc_params_t;
104388 +
104389 +typedef struct ioc_compat_fm_port_pcd_kg_params_t {
104390 + uint8_t num_of_schemes;
104391 + compat_uptr_t scheme_ids[FM_PCD_KG_NUM_OF_SCHEMES];
104392 + bool direct_scheme;
104393 + compat_uptr_t direct_scheme_id;
104394 +} ioc_compat_fm_port_pcd_kg_params_t;
104395 +
104396 +typedef struct ioc_compat_fm_port_pcd_params_t {
104397 + ioc_fm_port_pcd_support pcd_support;
104398 + compat_uptr_t net_env_id;
104399 + compat_uptr_t p_prs_params;
104400 + compat_uptr_t p_cc_params;
104401 + compat_uptr_t p_kg_params;
104402 + compat_uptr_t p_plcr_params;
104403 + compat_uptr_t p_ip_reassembly_manip;
104404 +#if DPAA_VERSION >= 11
104405 + compat_uptr_t p_capwap_reassembly_manip;
104406 +#endif
104407 +} ioc_compat_fm_port_pcd_params_t;
104408 +
104409 +typedef struct ioc_compat_fm_pcd_kg_cc_t {
104410 + compat_uptr_t tree_id;
104411 + uint8_t grp_id;
104412 + bool plcr_next;
104413 + bool bypass_plcr_profile_generation;
104414 + ioc_fm_pcd_kg_plcr_profile_t plcr_profile;
104415 +} ioc_compat_fm_pcd_kg_cc_t;
104416 +
104417 +typedef struct ioc_compat_fm_pcd_kg_scheme_params_t {
104418 + bool modify;
104419 + union {
104420 + uint8_t relative_scheme_id;
104421 + compat_uptr_t scheme_id;
104422 + } scm_id;
104423 + bool always_direct;
104424 + struct {
104425 + compat_uptr_t net_env_id;
104426 + uint8_t num_of_distinction_units;
104427 + uint8_t unit_ids[IOC_FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS];
104428 + } net_env_params;
104429 + bool use_hash;
104430 + ioc_fm_pcd_kg_key_extract_and_hash_params_t key_extract_and_hash_params;
104431 + bool bypass_fqid_generation;
104432 + uint32_t base_fqid;
104433 + uint8_t num_of_used_extracted_ors;
104434 + ioc_fm_pcd_kg_extracted_or_params_t extracted_ors[IOC_FM_PCD_KG_NUM_OF_GENERIC_REGS];
104435 +#if DPAA_VERSION >= 11
104436 + bool override_storage_profile;
104437 + ioc_fm_pcd_kg_storage_profile_t storage_profile;
104438 +#endif /* DPAA_VERSION >= 11 */
104439 + ioc_fm_pcd_engine next_engine;
104440 + union{
104441 + ioc_fm_pcd_done_action done_action;
104442 + ioc_fm_pcd_kg_plcr_profile_t plcr_profile;
104443 + ioc_compat_fm_pcd_kg_cc_t cc;
104444 + } kg_next_engine_params;
104445 + ioc_fm_pcd_kg_scheme_counter_t scheme_counter;
104446 + compat_uptr_t id;
104447 +} ioc_compat_fm_pcd_kg_scheme_params_t;
104448 +
104449 +typedef struct ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t {
104450 + compat_uptr_t id;
104451 + uint16_t key_indx;
104452 + uint8_t key_size;
104453 + ioc_compat_fm_pcd_cc_next_engine_params_t cc_next_engine_params;
104454 +} ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t;
104455 +
104456 +typedef struct ioc_compat_fm_pcd_manip_hdr_insrt_generic_params_t {
104457 + uint8_t offset;
104458 + uint8_t size;
104459 + bool replace;
104460 + compat_uptr_t p_data;
104461 +} ioc_compat_fm_pcd_manip_hdr_insrt_generic_params_t;
104462 +
104463 +typedef struct ioc_compat_fm_pcd_manip_hdr_insrt_specific_l2_params_t {
104464 + ioc_fm_pcd_manip_hdr_insrt_specific_l2 specific_l2;
104465 + bool update;
104466 + uint8_t size;
104467 + compat_uptr_t p_data;
104468 +} ioc_compat_fm_pcd_manip_hdr_insrt_specific_l2_params_t;
104469 +
104470 +typedef struct ioc_compat_fm_pcd_manip_hdr_insrt_t {
104471 + uint8_t size; /**< size of inserted section */
104472 + compat_uptr_t p_data; /**< data to be inserted */
104473 +} ioc_compat_fm_pcd_manip_hdr_insrt_t;
104474 +
104475 +#if (DPAA_VERSION >= 11)
104476 +typedef struct ioc_compat_fm_pcd_manip_hdr_insrt_ip_params_t {
104477 + bool calc_l4_checksum; /**< Calculate L4 checksum. */
104478 + ioc_fm_pcd_manip_hdr_qos_mapping_mode mapping_mode; /**< TODO */
104479 + uint8_t last_pid_offset; /**< the offset of the last Protocol within
104480 + the inserted header */
104481 + uint16_t id; /**< 16 bit New IP ID */
104482 + bool dont_frag_overwrite;
104483 + /**< IPv4 only. DF is overwritten with the hash-result next-to-last byte.
104484 + * This byte is configured to be overwritten when RPD is set. */
104485 + uint8_t last_dst_offset;
104486 + /**< IPv6 only. if routing extension exist, user should set the offset of the destination address
104487 + * in order to calculate UDP checksum pseudo header;
104488 + * Otherwise set it to '0'. */
104489 + ioc_compat_fm_pcd_manip_hdr_insrt_t insrt; /**< size and data to be inserted. */
104490 +} ioc_compat_fm_pcd_manip_hdr_insrt_ip_params_t;
104491 +#endif /* (DPAA_VERSION >= 11) */
104492 +
104493 +typedef struct ioc_compat_fm_pcd_manip_hdr_insrt_by_hdr_params_t {
104494 + ioc_fm_pcd_manip_hdr_insrt_by_hdr_type type;
104495 + union {
104496 + ioc_compat_fm_pcd_manip_hdr_insrt_specific_l2_params_t specific_l2_params;
104497 +#if (DPAA_VERSION >= 11)
104498 + ioc_compat_fm_pcd_manip_hdr_insrt_ip_params_t ip_params;
104499 + ioc_compat_fm_pcd_manip_hdr_insrt_t insrt;
104500 +#endif /* (DPAA_VERSION >= 11) */
104501 + } u;
104502 +} ioc_compat_fm_pcd_manip_hdr_insrt_by_hdr_params_t;
104503 +
104504 +typedef struct ioc_compat_fm_pcd_manip_hdr_insrt_params_t {
104505 + ioc_fm_pcd_manip_hdr_insrt_type type;
104506 + union {
104507 + ioc_compat_fm_pcd_manip_hdr_insrt_by_hdr_params_t by_hdr;
104508 + ioc_compat_fm_pcd_manip_hdr_insrt_generic_params_t generic;
104509 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
104510 +#error "FM_CAPWAP_SUPPORT feature not supported!"
104511 + ioc_fm_pcd_manip_hdr_insrt_by_template_params_t by_template;
104512 +#endif /* FM_CAPWAP_SUPPORT */
104513 + } u;
104514 +} ioc_compat_fm_pcd_manip_hdr_insrt_params_t;
104515 +
104516 +typedef struct ioc_compat_fm_pcd_manip_hdr_params_t {
104517 + bool rmv;
104518 + ioc_fm_pcd_manip_hdr_rmv_params_t rmv_params;
104519 + bool insrt;
104520 + ioc_compat_fm_pcd_manip_hdr_insrt_params_t insrt_params;
104521 + bool field_update;
104522 + ioc_fm_pcd_manip_hdr_field_update_params_t field_update_params;
104523 + bool custom;
104524 + ioc_fm_pcd_manip_hdr_custom_params_t custom_params;
104525 + bool dont_parse_after_manip;
104526 +} ioc_compat_fm_pcd_manip_hdr_params_t;
104527 +
104528 +typedef struct ioc_compat_fm_pcd_manip_special_offload_params_t {
104529 + bool decryption;
104530 + bool ecn_copy;
104531 + bool dscp_copy;
104532 + bool variable_ip_hdr_len;
104533 + bool variable_ip_version;
104534 + uint8_t outer_ip_hdr_len;
104535 + uint16_t arw_size;
104536 + compat_uptr_t arw_addr;
104537 +} ioc_compat_fm_pcd_manip_special_offload_params_t;
104538 +
104539 +typedef struct ioc_compat_fm_pcd_manip_params_t {
104540 + ioc_fm_pcd_manip_type type;
104541 + union {
104542 + ioc_compat_fm_pcd_manip_hdr_params_t hdr;
104543 + ioc_fm_pcd_manip_reassem_params_t reassem;
104544 + ioc_fm_pcd_manip_frag_params_t frag;
104545 + ioc_compat_fm_pcd_manip_special_offload_params_t special_offload;
104546 + } u;
104547 + compat_uptr_t p_next_manip;
104548 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
104549 +#error "FM_CAPWAP_SUPPORT feature not supported!"
104550 + bool frag_or_reasm;
104551 + ioc_fm_pcd_manip_frag_or_reasm_params_t frag_or_reasm_params;
104552 +#endif /* FM_CAPWAP_SUPPORT */
104553 + compat_uptr_t id;
104554 +} ioc_compat_fm_pcd_manip_params_t;
104555 +
104556 +typedef struct ioc_compat_fm_pcd_manip_get_stats_t {
104557 + compat_uptr_t id;
104558 + ioc_fm_pcd_manip_stats_t stats;
104559 +} ioc_compat_fm_pcd_manip_get_stats_t;
104560 +
104561 +#if (DPAA_VERSION >= 11)
104562 +typedef struct ioc_compat_fm_pcd_frm_replic_group_params_t {
104563 + uint8_t max_num_of_entries;
104564 + uint8_t num_of_entries;
104565 + ioc_compat_fm_pcd_cc_next_engine_params_t
104566 + next_engine_params[IOC_FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES];
104567 + compat_uptr_t id;
104568 +} ioc_compat_fm_pcd_frm_replic_group_params_t;
104569 +
104570 +typedef struct ioc_compat_fm_pcd_frm_replic_member_t {
104571 + compat_uptr_t h_replic_group;
104572 + uint16_t member_index;
104573 +} ioc_compat_fm_pcd_frm_replic_member_t;
104574 +
104575 +typedef struct ioc_compat_fm_pcd_frm_replic_member_params_t {
104576 + ioc_compat_fm_pcd_frm_replic_member_t member;
104577 + ioc_compat_fm_pcd_cc_next_engine_params_t next_engine_params;
104578 +} ioc_compat_fm_pcd_frm_replic_member_params_t;
104579 +
104580 +typedef struct ioc_compat_fm_vsp_params_t {
104581 + compat_uptr_t p_fm; /**< A handle to the FM object this VSP related to */
104582 + ioc_fm_ext_pools ext_buf_pools; /**< Which external buffer pools are used
104583 + (up to FM_PORT_MAX_NUM_OF_EXT_POOLS), and their sizes.
104584 + parameter associated with Rx / OP port */
104585 + uint16_t liodn_offset; /**< VSP's LIODN offset */
104586 + struct {
104587 + ioc_fm_port_type port_type; /**< Port type */
104588 + uint8_t port_id; /**< Port Id - relative to type */
104589 + } port_params;
104590 + uint8_t relative_profile_id; /**< VSP Id - relative to VSP's range
104591 + defined in relevant FM object */
104592 + compat_uptr_t id; /**< return value */
104593 +} ioc_compat_fm_vsp_params_t;
104594 +
104595 +typedef struct ioc_compat_fm_buf_pool_depletion_params_t {
104596 + compat_uptr_t p_fm_vsp;
104597 + ioc_fm_buf_pool_depletion_t fm_buf_pool_depletion;
104598 +} ioc_compat_fm_buf_pool_depletion_params_t;
104599 +
104600 +typedef struct ioc_compat_fm_buffer_prefix_content_params_t {
104601 + compat_uptr_t p_fm_vsp;
104602 + ioc_fm_buffer_prefix_content_t fm_buffer_prefix_content;
104603 +} ioc_compat_fm_buffer_prefix_content_params_t;
104604 +
104605 +typedef struct ioc_compat_fm_vsp_config_no_sg_params_t {
104606 + compat_uptr_t p_fm_vsp;
104607 + bool no_sg;
104608 +} ioc_compat_fm_vsp_config_no_sg_params_t;
104609 +
104610 +typedef struct ioc_compat_fm_vsp_prs_result_params_t {
104611 + compat_uptr_t p_fm_vsp;
104612 + compat_uptr_t p_data;
104613 +} ioc_compat_fm_vsp_prs_result_params_t;
104614 +
104615 +#endif /* (DPAA_VERSION >= 11) */
104616 +typedef struct ioc_compat_fm_pcd_kg_scheme_spc_t {
104617 + uint32_t val;
104618 + compat_uptr_t id;
104619 +} ioc_compat_fm_pcd_kg_scheme_spc_t;
104620 +
104621 +typedef struct ioc_compat_fm_ctrl_mon_counters_params_t {
104622 + uint8_t fm_ctrl_index;
104623 + compat_uptr_t p_mon;
104624 +} ioc_compat_fm_ctrl_mon_counters_params_t;
104625 +
104626 +typedef struct ioc_compat_fm_pcd_cc_tbl_get_stats_t {
104627 + compat_uptr_t id;
104628 + uint16_t key_index;
104629 + ioc_fm_pcd_cc_key_statistics_t statistics;
104630 +} ioc_compat_fm_pcd_cc_tbl_get_stats_t;
104631 +
104632 +
104633 +/* } pcd compat structures */
104634 +
104635 +void compat_obj_delete(
104636 + ioc_compat_fm_obj_t *compat_id,
104637 + ioc_fm_obj_t *id);
104638 +
104639 +/* pcd compat functions { */
104640 +void compat_copy_fm_pcd_plcr_profile(
104641 + ioc_compat_fm_pcd_plcr_profile_params_t *compat_param,
104642 + ioc_fm_pcd_plcr_profile_params_t *param,
104643 + uint8_t compat);
104644 +
104645 +void compat_copy_fm_pcd_cc_key(
104646 + ioc_compat_fm_pcd_cc_key_params_t *compat_param,
104647 + ioc_fm_pcd_cc_key_params_t *param,
104648 + uint8_t compat);
104649 +
104650 +void compat_copy_fm_pcd_cc_node_modify_key_and_next_engine(
104651 + ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t *compat_param,
104652 + ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t *param,
104653 + uint8_t compat);
104654 +
104655 +void compat_copy_fm_pcd_cc_node_modify_next_engine(
104656 + ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t *compat_param,
104657 + ioc_fm_pcd_cc_node_modify_next_engine_params_t *param,
104658 + uint8_t compat);
104659 +
104660 +void compat_fm_pcd_cc_tree_modify_next_engine(
104661 + ioc_compat_fm_pcd_cc_tree_modify_next_engine_params_t *compat_param,
104662 + ioc_fm_pcd_cc_tree_modify_next_engine_params_t *param,
104663 + uint8_t compat);
104664 +
104665 +void compat_copy_fm_pcd_hash_table(
104666 + ioc_compat_fm_pcd_hash_table_params_t *compat_param,
104667 + ioc_fm_pcd_hash_table_params_t *param,
104668 + uint8_t compat);
104669 +
104670 +void compat_copy_fm_pcd_cc_grp(
104671 + ioc_compat_fm_pcd_cc_grp_params_t *compat_param,
104672 + ioc_fm_pcd_cc_grp_params_t *param,
104673 + uint8_t compat);
104674 +
104675 +void compat_copy_fm_pcd_cc_tree(
104676 + ioc_compat_fm_pcd_cc_tree_params_t *compat_param,
104677 + ioc_fm_pcd_cc_tree_params_t *param,
104678 + uint8_t compat);
104679 +
104680 +void compat_copy_fm_pcd_cc_tbl_get_stats(
104681 + ioc_compat_fm_pcd_cc_tbl_get_stats_t *compat_param,
104682 + ioc_fm_pcd_cc_tbl_get_stats_t *param,
104683 + uint8_t compat);
104684 +
104685 +void compat_fm_pcd_prs_sw(
104686 + ioc_compat_fm_pcd_prs_sw_params_t *compat_param,
104687 + ioc_fm_pcd_prs_sw_params_t *param,
104688 + uint8_t compat);
104689 +
104690 +void compat_copy_fm_pcd_kg_scheme(
104691 + ioc_compat_fm_pcd_kg_scheme_params_t *compat_param,
104692 + ioc_fm_pcd_kg_scheme_params_t *param,
104693 + uint8_t compat);
104694 +
104695 +void compat_copy_fm_pcd_kg_scheme_select(
104696 + ioc_compat_fm_pcd_kg_scheme_select_t *compat_param,
104697 + ioc_fm_pcd_kg_scheme_select_t *param,
104698 + uint8_t compat);
104699 +
104700 +void compat_copy_fm_pcd_kg_schemes_params(
104701 + ioc_compat_fm_pcd_port_schemes_params_t *compat_param,
104702 + ioc_fm_pcd_port_schemes_params_t *param,
104703 + uint8_t compat);
104704 +
104705 +void compat_copy_fm_port_pcd_kg(
104706 + ioc_compat_fm_port_pcd_kg_params_t *compat_param,
104707 + ioc_fm_port_pcd_kg_params_t *param,
104708 + uint8_t compat);
104709 +
104710 +void compat_copy_fm_port_pcd(
104711 + ioc_compat_fm_port_pcd_params_t *compat_param,
104712 + ioc_fm_port_pcd_params_t *param,
104713 + uint8_t compat);
104714 +
104715 +#if (DPAA_VERSION >= 11)
104716 +void compat_copy_fm_port_vsp_alloc_params(
104717 + ioc_compat_fm_port_vsp_alloc_params_t *compat_param,
104718 + ioc_fm_port_vsp_alloc_params_t *param,
104719 + uint8_t compat);
104720 +#endif /* (DPAA_VERSION >= 11) */
104721 +
104722 +void compat_copy_fm_pcd_net_env(
104723 + ioc_compat_fm_pcd_net_env_params_t *compat_param,
104724 + ioc_fm_pcd_net_env_params_t *param,
104725 + uint8_t compat);
104726 +
104727 +void compat_copy_fm_pcd_cc_node_modify_key(
104728 + ioc_compat_fm_pcd_cc_node_modify_key_params_t *compat_param,
104729 + ioc_fm_pcd_cc_node_modify_key_params_t *param,
104730 + uint8_t compat);
104731 +
104732 +void compat_copy_keys(
104733 + ioc_compat_keys_params_t *compat_param,
104734 + ioc_keys_params_t *param,
104735 + uint8_t compat);
104736 +
104737 +void compat_copy_fm_pcd_cc_node(
104738 + ioc_compat_fm_pcd_cc_node_params_t *compat_param,
104739 + ioc_fm_pcd_cc_node_params_t *param,
104740 + uint8_t compat);
104741 +
104742 +void compat_fm_pcd_manip_set_node(
104743 + ioc_compat_fm_pcd_manip_params_t *compat_param,
104744 + ioc_fm_pcd_manip_params_t *param,
104745 + uint8_t compat);
104746 +
104747 +void compat_copy_fm_pcd_manip_get_stats(
104748 + ioc_compat_fm_pcd_manip_get_stats_t *compat_param,
104749 + ioc_fm_pcd_manip_get_stats_t *param,
104750 + uint8_t compat);
104751 +
104752 +void compat_copy_fm_port_pcd_modify_tree(
104753 + ioc_compat_fm_obj_t *compat_id,
104754 + ioc_fm_obj_t *id,
104755 + uint8_t compat);
104756 +
104757 +#if (DPAA_VERSION >= 11)
104758 +void compat_copy_fm_pcd_frm_replic_group_params(
104759 + ioc_compat_fm_pcd_frm_replic_group_params_t *compat_param,
104760 + ioc_fm_pcd_frm_replic_group_params_t *param,
104761 + uint8_t compat);
104762 +
104763 +void compat_copy_fm_pcd_frm_replic_member(
104764 + ioc_compat_fm_pcd_frm_replic_member_t *compat_param,
104765 + ioc_fm_pcd_frm_replic_member_t *param,
104766 + uint8_t compat);
104767 +
104768 +void compat_copy_fm_pcd_frm_replic_member_params(
104769 + ioc_compat_fm_pcd_frm_replic_member_params_t *compat_param,
104770 + ioc_fm_pcd_frm_replic_member_params_t *param,
104771 + uint8_t compat);
104772 +
104773 +void compat_copy_fm_vsp_params(
104774 + ioc_compat_fm_vsp_params_t *compat_param,
104775 + ioc_fm_vsp_params_t *param,
104776 + uint8_t compat);
104777 +
104778 +void compat_copy_fm_buf_pool_depletion_params(
104779 + ioc_compat_fm_buf_pool_depletion_params_t *compat_param,
104780 + ioc_fm_buf_pool_depletion_params_t *param,
104781 + uint8_t compat);
104782 +
104783 +void compat_copy_fm_buffer_prefix_content_params(
104784 + ioc_compat_fm_buffer_prefix_content_params_t *compat_param,
104785 + ioc_fm_buffer_prefix_content_params_t *param,
104786 + uint8_t compat);
104787 +
104788 +void compat_copy_fm_vsp_config_no_sg_params(
104789 + ioc_compat_fm_vsp_config_no_sg_params_t *compat_param,
104790 + ioc_fm_vsp_config_no_sg_params_t *param,
104791 + uint8_t compat);
104792 +
104793 +void compat_copy_fm_vsp_prs_result_params(
104794 + ioc_compat_fm_vsp_prs_result_params_t *compat_param,
104795 + ioc_fm_vsp_prs_result_params_t *param,
104796 + uint8_t compat);
104797 +
104798 +#endif /* (DPAA_VERSION >= 11) */
104799 +
104800 +void compat_copy_fm_pcd_kg_scheme_spc(
104801 + ioc_compat_fm_pcd_kg_scheme_spc_t *compat_param,
104802 + ioc_fm_pcd_kg_scheme_spc_t *param,
104803 + uint8_t compat);
104804 +
104805 +/* } pcd compat functions */
104806 +#endif
104807 --- /dev/null
104808 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_resources.h
104809 @@ -0,0 +1,121 @@
104810 +/*
104811 + * Copyright 2008-2012 Freescale Semiconductor Inc.
104812 + *
104813 + * Redistribution and use in source and binary forms, with or without
104814 + * modification, are permitted provided that the following conditions are met:
104815 + * * Redistributions of source code must retain the above copyright
104816 + * notice, this list of conditions and the following disclaimer.
104817 + * * Redistributions in binary form must reproduce the above copyright
104818 + * notice, this list of conditions and the following disclaimer in the
104819 + * documentation and/or other materials provided with the distribution.
104820 + * * Neither the name of Freescale Semiconductor nor the
104821 + * names of its contributors may be used to endorse or promote products
104822 + * derived from this software without specific prior written permission.
104823 + *
104824 + *
104825 + * ALTERNATIVELY, this software may be distributed under the terms of the
104826 + * GNU General Public License ("GPL") as published by the Free Software
104827 + * Foundation, either version 2 of that License or (at your option) any
104828 + * later version.
104829 + *
104830 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
104831 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
104832 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
104833 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
104834 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
104835 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
104836 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
104837 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
104838 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
104839 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
104840 + */
104841 +
104842 +/*
104843 + @File lnxwrp_resources.h
104844 +
104845 + @Description FMD wrapper resource allocation functions.
104846 +
104847 +*/
104848 +
104849 +#ifndef LNXWRP_RESOURCES_H_
104850 +#define LNXWRP_RESOURCES_H_
104851 +
104852 +#if !defined(FMAN_RESOURCES_UNIT_TEST)
104853 +#include "lnxwrp_fm.h"
104854 +#else
104855 +#include "lnxwrp_resources_ut.h"
104856 +#endif
104857 +
104858 +#define ROUND(X) ((2*(X)+1)/2)
104859 +#define CEIL(X) ((X)+1)
104860 +/* #define ROUND_DIV(X, Y) (((X)+(Y)/2)/(Y)) */
104861 +#define ROUND_DIV(X, Y) ((2*(X)+(Y))/(2*(Y)))
104862 +#define CEIL_DIV(X, Y) (((X)+(Y)-1)/(Y))
104863 +
104864 +/* used for resource calculus */
104865 +#define DPDE_1G 2 /* DQDP 1g - from LLD:
104866 + DEFAULT_PORT_txFifoDeqPipelineDepth_1G */
104867 +#define DPDE_10G 8 /* DQDP 10g - from LLD:
104868 + DEFAULT_PORT_txFifoDeqPipelineDepth_10G */
104869 +
104870 +int fm_set_active_fman_ports(struct platform_device *of_dev,
104871 + t_LnxWrpFmDev *p_LnxWrpFmDev);
104872 +
104873 +/* Calculate the fifosize based on MURAM allocation, number of ports, dpde
104874 + * value and s/g software support (! Kernel does not suport s/g).
104875 + *
104876 + * Algorithm summary:
104877 + * - Calculate the the minimum fifosize required for every type of port
104878 + * (TX,RX for 1G, 2.5G and 10G).
104879 + * - Set TX the minimum fifosize required.
104880 + * - Distribute the remaining buffers (after all TX were set) to RX ports
104881 + * based on:
104882 + * 1G RX = Remaining_buffers * 1/(1+2.5+10)
104883 + * 2.5G RX = Remaining_buffers * 2.5/(1+2.5+10)
104884 + * 10G RX = Remaining_buffers * 10/(1+2.5+10)
104885 + * - if the RX is smaller than the minimum required, then set the minimum
104886 + * required
104887 + * - In the end distribuite the leftovers if there are any (due to
104888 + * unprecise calculus) or if over allocation cat some buffers from all RX
104889 + * ports w/o pass over minimum required treshold, but if there must be
104890 + * pass the treshold in order to cat the over allocation ,then this
104891 + * configuration can not be set - KERN_ALERT.
104892 +*/
104893 +int fm_precalculate_fifosizes(t_LnxWrpFmDev *p_LnxWrpFmDev,
104894 + int muram_fifo_size);
104895 +
104896 +#if !defined(FMAN_RESOURCES_UNIT_TEST)
104897 +int fm_config_precalculate_fifosize(t_LnxWrpFmPortDev *p_LnxWrpFmPortDev);
104898 +#endif
104899 +
104900 +/* Compute FMan open DMA based on total number of open DMAs and
104901 + * number of available fman ports.
104902 + *
104903 + * By default 10g ports are set to input parameters. The other ports
104904 + * tries to keep the proportion rx=2tx open dmas or tresholds.
104905 + *
104906 + * If leftovers, then those will be set as shared.
104907 + *
104908 + * If after computing overflow appears, then it decrements open dma
104909 + * for all ports w/o cross the tresholds. If the tresholds are meet
104910 + * and is still overflow, then it returns error.
104911 +*/
104912 +int fm_precalculate_open_dma(t_LnxWrpFmDev *p_LnxWrpFmDev,
104913 + int max_fm_open_dma,
104914 + int default_tx_10g_dmas,
104915 + int default_rx_10g_dmas,
104916 + int min_tx_10g_treshold, int min_rx_10g_treshold);
104917 +
104918 +#if !defined(FMAN_RESOURCES_UNIT_TEST)
104919 +int fm_config_precalculate_open_dma(t_LnxWrpFmPortDev *p_LnxWrpFmPortDev);
104920 +#endif
104921 +
104922 +/* Compute FMan tnums based on available tnums and number of ports.
104923 + * Set defaults (minim tresholds) and then distribute leftovers.*/
104924 +int fm_precalculate_tnums(t_LnxWrpFmDev *p_LnxWrpFmDev, int max_fm_tnums);
104925 +
104926 +#if !defined(FMAN_RESOURCES_UNIT_TEST)
104927 +int fm_config_precalculate_tnums(t_LnxWrpFmPortDev *p_LnxWrpFmPortDev);
104928 +#endif
104929 +
104930 +#endif /* LNXWRP_RESOURCES_H_ */
104931 --- /dev/null
104932 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_resources_ut.c
104933 @@ -0,0 +1,191 @@
104934 +/* Copyright (c) 2012 Freescale Semiconductor, Inc.
104935 + * All rights reserved.
104936 + *
104937 + * Redistribution and use in source and binary forms, with or without
104938 + * modification, are permitted provided that the following conditions are met:
104939 + * * Redistributions of source code must retain the above copyright
104940 + * notice, this list of conditions and the following disclaimer.
104941 + * * Redistributions in binary form must reproduce the above copyright
104942 + * notice, this list of conditions and the following disclaimer in the
104943 + * documentation and/or other materials provided with the distribution.
104944 + * * Neither the name of Freescale Semiconductor nor the
104945 + * names of its contributors may be used to endorse or promote products
104946 + * derived from this software without specific prior written permission.
104947 + *
104948 + *
104949 + * ALTERNATIVELY, this software may be distributed under the terms of the
104950 + * GNU General Public License ("GPL") as published by the Free Software
104951 + * Foundation, either version 2 of that License or (at your option) any
104952 + * later version.
104953 + *
104954 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
104955 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
104956 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
104957 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
104958 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
104959 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
104960 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
104961 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
104962 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
104963 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
104964 + */
104965 +
104966 +#include "lnxwrp_resources.h"
104967 +#include "lnxwrp_resources_ut.h"
104968 +
104969 +#define KILOBYTE 0x400 /* 1024 */
104970 +
104971 +typedef enum e_board_type {
104972 + e_p3041,
104973 + e_p4080,
104974 + e_p5020,
104975 + e_p1023
104976 +} e_board_type;
104977 +
104978 +uint8_t board_type;
104979 +uint32_t muram_size = 0;
104980 +uint32_t dmas_num = 0;
104981 +uint32_t task_num = 0;
104982 +uint32_t frame_size = 0;
104983 +uint32_t oh_num = 0;
104984 +uint32_t num_ports_1g = 0;
104985 +uint32_t num_ports_10g = 0;
104986 +uint32_t num_ports_2g5 = 0;
104987 +uint32_t fsl_fman_phy_maxfrm = 0;
104988 +uint32_t dpa_rx_extra_headroom = 0;
104989 +
104990 +void show_help(void){
104991 + printf(" help: \n");
104992 + printf(" -b <board_type> -f <max_fram_size(mtu)> -o <num_oh_ports> -g1"
104993 + " <num_1g_ports> -g10 <num_10g_ports> -g25 <num_2g5_ports>\n");
104994 + printf(" Maxim num of DMAS availbale: P3/P4/P5:32 , P1023:16 \n");
104995 + printf(" Maxim num of TNUMs availbale: P3/P4/P5:128, P1023:32 \n");
104996 + printf(" Muram size: P3/P4/P5:160K, P1023:64K \n");
104997 + printf(" Number of ports:\n");
104998 + printf(" P3/P5: 5p 1g, 1p 10g, 7p oh \n");
104999 + printf(" P4 : 4p 1g, 1p 10g, 7p oh \n");
105000 + printf(" P1 : 2p 1g, 0p 10g, 4p oh \n");
105001 + printf(" MTU: Default:1522, Jumbo:9600 \n");
105002 +}
105003 +
105004 +int fm_set_param(t_LnxWrpFmDev *p_LnxWrpFmDev) {
105005 + struct fm_active_ports *fm_active_ports_info = NULL;
105006 + fm_active_ports_info = &p_LnxWrpFmDev->fm_active_ports_info;
105007 +
105008 + switch(board_type){
105009 + case e_p3041:
105010 + case e_p5020:
105011 + muram_size = 160*KILOBYTE;
105012 + dmas_num = 32;
105013 + task_num = 128;
105014 + if ((num_ports_1g+num_ports_2g5) > 5 || num_ports_10g > 1 || oh_num > 7)
105015 + goto err_fm_set_param;
105016 + break;
105017 + case e_p4080:
105018 + muram_size = 160*KILOBYTE;
105019 + dmas_num = 32;
105020 + task_num = 128;
105021 + if ((num_ports_1g+num_ports_2g5) > 4 || num_ports_10g > 1 || oh_num > 7)
105022 + goto err_fm_set_param;
105023 + break;
105024 + case e_p1023:
105025 + muram_size = 64*KILOBYTE;
105026 + dmas_num = 16;
105027 + task_num = 128;
105028 + if ((num_ports_1g+num_ports_2g5) > 2 || oh_num > 4)
105029 + goto err_fm_set_param;
105030 + break;
105031 + default:
105032 + goto err_fm_set_param;
105033 + break;
105034 + }
105035 +
105036 + p_LnxWrpFmDev->id = 0;
105037 + fsl_fman_phy_maxfrm = frame_size;
105038 + dpa_rx_extra_headroom = 0; /* ATTENTION: can be != 0 */
105039 + fm_active_ports_info->num_oh_ports = oh_num;
105040 + fm_active_ports_info->num_tx_ports = num_ports_1g;
105041 + fm_active_ports_info->num_rx_ports = num_ports_1g;
105042 + fm_active_ports_info->num_tx25_ports = num_ports_2g5;
105043 + fm_active_ports_info->num_rx25_ports = num_ports_2g5;
105044 + fm_active_ports_info->num_tx10_ports = num_ports_10g;
105045 + fm_active_ports_info->num_rx10_ports = num_ports_10g;
105046 +
105047 + return 0;
105048 +
105049 +err_fm_set_param:
105050 + printf(" ERR: To many ports!!! \n");
105051 + return -1;
105052 +}
105053 +
105054 +int main (int argc, char *argv[]){
105055 + t_LnxWrpFmDev LnxWrpFmDev;
105056 + t_LnxWrpFmDev *p_LnxWrpFmDev = &LnxWrpFmDev;
105057 + int tokens_cnt = 1;
105058 +
105059 + char *token = NULL;
105060 +
105061 + while(tokens_cnt < argc)
105062 + {
105063 + token = argv[tokens_cnt++];
105064 + if (strcmp(token, "-b") == 0){
105065 + if(strcmp(argv[tokens_cnt],"p3") == 0)
105066 + board_type = e_p3041;
105067 + else if(strcmp(argv[tokens_cnt],"p4") == 0)
105068 + board_type = e_p4080;
105069 + else if(strcmp(argv[tokens_cnt],"p5") == 0)
105070 + board_type = e_p5020;
105071 + else if(strcmp(argv[tokens_cnt],"p1") == 0)
105072 + board_type = e_p1023;
105073 + else
105074 + show_help();
105075 + tokens_cnt++;
105076 + }
105077 + else if(strcmp(token, "-d") == 0){
105078 + dmas_num = atoi(argv[tokens_cnt++]);
105079 + }
105080 + else if(strcmp(token, "-t") == 0)
105081 + task_num = atoi(argv[tokens_cnt++]);
105082 + else if(strcmp(token, "-f") == 0)
105083 + frame_size = atoi(argv[tokens_cnt++]);
105084 + else if(strcmp(token, "-o") == 0)
105085 + oh_num = atoi(argv[tokens_cnt++]);
105086 + else if(strcmp(token, "-g1") == 0)
105087 + num_ports_1g = atoi(argv[tokens_cnt++]);
105088 + else if(strcmp(token, "-g10") == 0)
105089 + num_ports_10g = atoi(argv[tokens_cnt++]);
105090 + else if(strcmp(token, "-g25") == 0)
105091 + num_ports_2g5 = atoi(argv[tokens_cnt++]);
105092 + else {
105093 + show_help();
105094 + return -1;
105095 + }
105096 + }
105097 +
105098 + if(fm_set_param(p_LnxWrpFmDev) < 0){
105099 + show_help();
105100 + return -1;
105101 + }
105102 +
105103 + if(fm_precalculate_fifosizes(
105104 + p_LnxWrpFmDev,
105105 + 128*KILOBYTE)
105106 + != 0)
105107 + return -1;
105108 + if(fm_precalculate_open_dma(
105109 + p_LnxWrpFmDev,
105110 + dmas_num, /* max open dmas:dpaa_integration_ext.h */
105111 + FM_DEFAULT_TX10G_OPENDMA, /* default TX 10g open dmas */
105112 + FM_DEFAULT_RX10G_OPENDMA, /* default RX 10g open dmas */
105113 + FM_10G_OPENDMA_MIN_TRESHOLD,/* TX 10g minimum treshold */
105114 + FM_10G_OPENDMA_MIN_TRESHOLD)/* RX 10g minimum treshold */
105115 + != 0)
105116 + return -1;
105117 + if(fm_precalculate_tnums(
105118 + p_LnxWrpFmDev,
105119 + task_num) /* max TNUMS: dpa integration file. */
105120 + != 0)
105121 + return -1;
105122 +
105123 + return 0;
105124 +}
105125 --- /dev/null
105126 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_resources_ut.h
105127 @@ -0,0 +1,144 @@
105128 +/* Copyright (c) 2012 Freescale Semiconductor, Inc
105129 + * All rights reserved.
105130 + *
105131 + * Redistribution and use in source and binary forms, with or without
105132 + * modification, are permitted provided that the following conditions are met:
105133 + * * Redistributions of source code must retain the above copyright
105134 + * notice, this list of conditions and the following disclaimer.
105135 + * * Redistributions in binary form must reproduce the above copyright
105136 + * notice, this list of conditions and the following disclaimer in the
105137 + * documentation and/or other materials provided with the distribution.
105138 + * * Neither the name of Freescale Semiconductor nor the
105139 + * names of its contributors may be used to endorse or promote products
105140 + * derived from this software without specific prior written permission.
105141 + *
105142 + *
105143 + * ALTERNATIVELY, this software may be distributed under the terms of the
105144 + * GNU General Public License ("GPL") as published by the Free Software
105145 + * Foundation, either version 2 of that License or (at your option) any
105146 + * later version.
105147 + *
105148 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
105149 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
105150 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
105151 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
105152 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
105153 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
105154 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
105155 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
105156 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
105157 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
105158 + */
105159 +
105160 +#ifndef FM_RESS_TEST_H_
105161 +#define FM_RESS_TEST_H_
105162 +
105163 +#include <stdint.h>
105164 +#include <stdbool.h>
105165 +#include <stdio.h>
105166 +#include <assert.h>
105167 +#include <string.h>
105168 +#include <stdlib.h>
105169 +
105170 +#define _Packed
105171 +#define _PackedType __attribute__ ((packed))
105172 +#define MAX(x, y) (((x) > (y)) ? (x) : (y))
105173 +#define MIN(x, y) (((x) < (y)) ? (x) : (y))
105174 +#define KERN_ALERT ""
105175 +#define KERN_INFO ""
105176 +#define ASSERT_COND assert
105177 +#define printk printf
105178 +#define NET_IP_ALIGN 0
105179 +#define FM_FIFO_ALLOCATION_OLD_ALG
105180 +
105181 +#if defined(CONFIG_FMAN_DISABLE_OH_AND_DISTRIBUTE_RESOURCES)
105182 +#define FM_10G_OPENDMA_MIN_TRESHOLD 8 /* 10g minimum treshold if only HC is enabled and no OH port enabled */
105183 +#define FM_OPENDMA_RX_TX_RAPORT 2 /* RX = 2*TX */
105184 +#else
105185 +#define FM_10G_OPENDMA_MIN_TRESHOLD 7 /* 10g minimum treshold if 7 OH ports are enabled */
105186 +#define FM_OPENDMA_RX_TX_RAPORT 1 /* RX = TX */
105187 +#endif
105188 +#define FM_DEFAULT_TX10G_OPENDMA 8 /* default TX 10g open dmas */
105189 +#define FM_DEFAULT_RX10G_OPENDMA 8 /* default RX 10g open dmas */
105190 +
105191 +/* information about all active ports for an FMan.
105192 + * !Some ports may be disabled by u-boot, thus will not be available */
105193 +struct fm_active_ports {
105194 + uint32_t num_oh_ports;
105195 + uint32_t num_tx_ports;
105196 + uint32_t num_rx_ports;
105197 + uint32_t num_tx25_ports;
105198 + uint32_t num_rx25_ports;
105199 + uint32_t num_tx10_ports;
105200 + uint32_t num_rx10_ports;
105201 +};
105202 +
105203 +/* FMan resources precalculated at fm probe based
105204 + * on available FMan port. */
105205 +struct fm_resource_settings {
105206 + /* buffers - fifo sizes */
105207 + uint32_t tx1g_num_buffers;
105208 + uint32_t rx1g_num_buffers;
105209 + uint32_t tx2g5_num_buffers; /* Not supported yet by LLD */
105210 + uint32_t rx2g5_num_buffers; /* Not supported yet by LLD */
105211 + uint32_t tx10g_num_buffers;
105212 + uint32_t rx10g_num_buffers;
105213 + uint32_t oh_num_buffers;
105214 + uint32_t shared_ext_buffers;
105215 +
105216 +
105217 + /* open DMAs */
105218 + uint32_t tx_1g_dmas;
105219 + uint32_t rx_1g_dmas;
105220 + uint32_t tx_2g5_dmas; /* Not supported yet by LLD */
105221 + uint32_t rx_2g5_dmas; /* Not supported yet by LLD */
105222 + uint32_t tx_10g_dmas;
105223 + uint32_t rx_10g_dmas;
105224 + uint32_t oh_dmas;
105225 + uint32_t shared_ext_open_dma;
105226 +
105227 + /* Tnums */
105228 + uint32_t tx_1g_tnums;
105229 + uint32_t rx_1g_tnums;
105230 + uint32_t tx_2g5_tnums; /* Not supported yet by LLD */
105231 + uint32_t rx_2g5_tnums; /* Not supported yet by LLD */
105232 + uint32_t tx_10g_tnums;
105233 + uint32_t rx_10g_tnums;
105234 + uint32_t oh_tnums;
105235 + uint32_t shared_ext_tnums;
105236 +};
105237 +
105238 +typedef struct {
105239 + uint8_t id;
105240 + struct fm_active_ports fm_active_ports_info;
105241 + struct fm_resource_settings fm_resource_settings_info;
105242 +} t_LnxWrpFmDev;
105243 +
105244 +typedef struct {
105245 + uint8_t id;
105246 +} t_LnxWrpFmPortDev;
105247 +
105248 +typedef _Packed struct t_FmPrsResult {
105249 + volatile uint8_t lpid; /**< Logical port id */
105250 + volatile uint8_t shimr; /**< Shim header result */
105251 + volatile uint16_t l2r; /**< Layer 2 result */
105252 + volatile uint16_t l3r; /**< Layer 3 result */
105253 + volatile uint8_t l4r; /**< Layer 4 result */
105254 + volatile uint8_t cplan; /**< Classification plan id */
105255 + volatile uint16_t nxthdr; /**< Next Header */
105256 + volatile uint16_t cksum; /**< Checksum */
105257 + volatile uint32_t lcv; /**< LCV */
105258 + volatile uint8_t shim_off[3]; /**< Shim offset */
105259 + volatile uint8_t eth_off; /**< ETH offset */
105260 + volatile uint8_t llc_snap_off; /**< LLC_SNAP offset */
105261 + volatile uint8_t vlan_off[2]; /**< VLAN offset */
105262 + volatile uint8_t etype_off; /**< ETYPE offset */
105263 + volatile uint8_t pppoe_off; /**< PPP offset */
105264 + volatile uint8_t mpls_off[2]; /**< MPLS offset */
105265 + volatile uint8_t ip_off[2]; /**< IP offset */
105266 + volatile uint8_t gre_off; /**< GRE offset */
105267 + volatile uint8_t l4_off; /**< Layer 4 offset */
105268 + volatile uint8_t nxthdr_off; /**< Parser end point */
105269 +} _PackedType t_FmPrsResult;
105270 +
105271 +#endif
105272 --- /dev/null
105273 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_resources_ut.make
105274 @@ -0,0 +1,28 @@
105275 +CC=gcc
105276 +
105277 +LNXWRP_RESS_UT=lnxwrp_resources_ut
105278 +OBJ=lnxwrp_resources
105279 +
105280 +INC_PATH=
105281 +LIB_PATH=
105282 +
105283 +INC=$(addprefix -I,$(INC_PATH))
105284 +LIB=$(addprefix -L,$(LIB_PATH))
105285 +
105286 +CFLAGS= -gdwarf-2 -g -O0 -Wall
105287 +XFLAGS= -DFMAN_RESOURCES_UNIT_TEST
105288 +
105289 +all: $(LNXWRP_RESS_UT)
105290 +
105291 +$(LNXWRP_RESS_UT):$(addsuffix .o,$(OBJ)) $(LNXWRP_RESS_UT).o
105292 + $(CC) -o $(LNXWRP_RESS_UT) $(LNXWRP_RESS_UT).o $(addsuffix .o,$(OBJ))
105293 +
105294 +%.o: %.c
105295 + @(echo " (CC) $@")
105296 + @($(CC) $(INC) $(CFLAGS) $(XFLAGS) -o $(@) -c $<)
105297 +
105298 +.PHONY: clean
105299 +
105300 +clean:
105301 + rm -f *.o
105302 + rm -f $(LNXWRP_RESS_UT)
105303 --- /dev/null
105304 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs.c
105305 @@ -0,0 +1,60 @@
105306 +/*
105307 + * Copyright 2008-2012 Freescale Semiconductor Inc.
105308 + *
105309 + * Redistribution and use in source and binary forms, with or without
105310 + * modification, are permitted provided that the following conditions are met:
105311 + * * Redistributions of source code must retain the above copyright
105312 + * notice, this list of conditions and the following disclaimer.
105313 + * * Redistributions in binary form must reproduce the above copyright
105314 + * notice, this list of conditions and the following disclaimer in the
105315 + * documentation and/or other materials provided with the distribution.
105316 + * * Neither the name of Freescale Semiconductor nor the
105317 + * names of its contributors may be used to endorse or promote products
105318 + * derived from this software without specific prior written permission.
105319 + *
105320 + *
105321 + * ALTERNATIVELY, this software may be distributed under the terms of the
105322 + * GNU General Public License ("GPL") as published by the Free Software
105323 + * Foundation, either version 2 of that License or (at your option) any
105324 + * later version.
105325 + *
105326 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
105327 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
105328 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
105329 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
105330 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
105331 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
105332 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
105333 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
105334 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
105335 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
105336 + */
105337 +
105338 +/*
105339 + @File lnxwrp_sysfs.c
105340 +
105341 + @Description FM wrapper sysfs related functions.
105342 +
105343 +*/
105344 +
105345 +#include <linux/types.h>
105346 +#include "lnxwrp_sysfs.h"
105347 +
105348 +uint8_t fm_find_statistic_counter_by_name(const char *attr_name,
105349 + const struct sysfs_stats_t *sysfs_stats,
105350 + uint8_t *offset)
105351 +{
105352 + int i = 0;
105353 +
105354 + while (sysfs_stats[i].stat_name != NULL) {
105355 + if (strcmp(sysfs_stats[i].stat_name, attr_name) == 0) {
105356 + if (offset != NULL)
105357 + *offset = i;
105358 + return sysfs_stats[i].stat_counter;
105359 + }
105360 +
105361 + i++;
105362 + }
105363 + WARN(1, "FMD: Should never get here!");
105364 + return 0;
105365 +}
105366 --- /dev/null
105367 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs.h
105368 @@ -0,0 +1,60 @@
105369 +/*
105370 + * Copyright 2008-2012 Freescale Semiconductor Inc.
105371 + *
105372 + * Redistribution and use in source and binary forms, with or without
105373 + * modification, are permitted provided that the following conditions are met:
105374 + * * Redistributions of source code must retain the above copyright
105375 + * notice, this list of conditions and the following disclaimer.
105376 + * * Redistributions in binary form must reproduce the above copyright
105377 + * notice, this list of conditions and the following disclaimer in the
105378 + * documentation and/or other materials provided with the distribution.
105379 + * * Neither the name of Freescale Semiconductor nor the
105380 + * names of its contributors may be used to endorse or promote products
105381 + * derived from this software without specific prior written permission.
105382 + *
105383 + *
105384 + * ALTERNATIVELY, this software may be distributed under the terms of the
105385 + * GNU General Public License ("GPL") as published by the Free Software
105386 + * Foundation, either version 2 of that License or (at your option) any
105387 + * later version.
105388 + *
105389 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
105390 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
105391 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
105392 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
105393 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
105394 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
105395 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
105396 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
105397 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
105398 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
105399 + */
105400 +
105401 +#ifndef LNXWRP_SYSFS_H_
105402 +#define LNXWRP_SYSFS_H_
105403 +
105404 +/* Linux Headers ------------------- */
105405 +#include <linux/version.h>
105406 +
105407 +#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
105408 +#define MODVERSIONS
105409 +#endif
105410 +#ifdef MODVERSIONS
105411 +#include <config/modversions.h>
105412 +#endif /* MODVERSIONS */
105413 +
105414 +#include <linux/kernel.h>
105415 +#include <linux/module.h>
105416 +#include <linux/device.h>
105417 +#include <linux/sysfs.h>
105418 +
105419 +struct sysfs_stats_t {
105420 + const char *stat_name;
105421 + uint8_t stat_counter;
105422 +};
105423 +
105424 +uint8_t fm_find_statistic_counter_by_name(const char *attr_name,
105425 + const struct sysfs_stats_t *sysfs_stats,
105426 + uint8_t *offset);
105427 +
105428 +#endif /* LNXWRP_SYSFS_H_ */
105429 --- /dev/null
105430 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm.c
105431 @@ -0,0 +1,1855 @@
105432 +/*
105433 + * Copyright 2008-2012 Freescale Semiconductor Inc.
105434 + *
105435 + * Redistribution and use in source and binary forms, with or without
105436 + * modification, are permitted provided that the following conditions are met:
105437 + * * Redistributions of source code must retain the above copyright
105438 + * notice, this list of conditions and the following disclaimer.
105439 + * * Redistributions in binary form must reproduce the above copyright
105440 + * notice, this list of conditions and the following disclaimer in the
105441 + * documentation and/or other materials provided with the distribution.
105442 + * * Neither the name of Freescale Semiconductor nor the
105443 + * names of its contributors may be used to endorse or promote products
105444 + * derived from this software without specific prior written permission.
105445 + *
105446 + *
105447 + * ALTERNATIVELY, this software may be distributed under the terms of the
105448 + * GNU General Public License ("GPL") as published by the Free Software
105449 + * Foundation, either version 2 of that License or (at your option) any
105450 + * later version.
105451 + *
105452 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
105453 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
105454 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
105455 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
105456 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
105457 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
105458 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
105459 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
105460 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
105461 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
105462 + */
105463 +
105464 +#include "lnxwrp_sysfs.h"
105465 +#include "lnxwrp_sysfs_fm.h"
105466 +#include "lnxwrp_fm.h"
105467 +
105468 +#include "../../sdk_fman/Peripherals/FM/inc/fm_common.h"
105469 +#include "../../sdk_fman/Peripherals/FM/Pcd/fm_pcd.h"
105470 +#include "../../sdk_fman/Peripherals/FM/Pcd/fm_kg.h"
105471 +#include "../../sdk_fman/Peripherals/FM/Pcd/fm_plcr.h"
105472 +
105473 +#if defined(__ERR_MODULE__)
105474 +#undef __ERR_MODULE__
105475 +#endif
105476 +
105477 +#include "../../sdk_fman/Peripherals/FM/fm.h"
105478 +#include <linux/delay.h>
105479 +
105480 +
105481 +static int fm_get_counter(void *h_fm, e_FmCounters cnt_e, uint32_t *cnt_val);
105482 +
105483 +enum fm_dma_match_stats {
105484 + FM_DMA_COUNTERS_CMQ_NOT_EMPTY,
105485 + FM_DMA_COUNTERS_BUS_ERROR,
105486 + FM_DMA_COUNTERS_READ_BUF_ECC_ERROR,
105487 + FM_DMA_COUNTERS_WRITE_BUF_ECC_SYS_ERROR,
105488 + FM_DMA_COUNTERS_WRITE_BUF_ECC_FM_ERROR
105489 +};
105490 +
105491 +static const struct sysfs_stats_t fm_sysfs_stats[] = {
105492 + /* FM statistics */
105493 + {
105494 + .stat_name = "enq_total_frame",
105495 + .stat_counter = e_FM_COUNTERS_ENQ_TOTAL_FRAME,
105496 + },
105497 + {
105498 + .stat_name = "deq_total_frame",
105499 + .stat_counter = e_FM_COUNTERS_DEQ_TOTAL_FRAME,
105500 + },
105501 + {
105502 + .stat_name = "deq_0",
105503 + .stat_counter = e_FM_COUNTERS_DEQ_0,
105504 + },
105505 + {
105506 + .stat_name = "deq_1",
105507 + .stat_counter = e_FM_COUNTERS_DEQ_1,
105508 + },
105509 + {
105510 + .stat_name = "deq_2",
105511 + .stat_counter = e_FM_COUNTERS_DEQ_2,
105512 + },
105513 + {
105514 + .stat_name = "deq_3",
105515 + .stat_counter = e_FM_COUNTERS_DEQ_3,
105516 + },
105517 + {
105518 + .stat_name = "deq_from_default",
105519 + .stat_counter = e_FM_COUNTERS_DEQ_FROM_DEFAULT,
105520 + },
105521 + {
105522 + .stat_name = "deq_from_context",
105523 + .stat_counter = e_FM_COUNTERS_DEQ_FROM_CONTEXT,
105524 + },
105525 + {
105526 + .stat_name = "deq_from_fd",
105527 + .stat_counter = e_FM_COUNTERS_DEQ_FROM_FD,
105528 + },
105529 + {
105530 + .stat_name = "deq_confirm",
105531 + .stat_counter = e_FM_COUNTERS_DEQ_CONFIRM,
105532 + },
105533 + /* FM:DMA statistics */
105534 + {
105535 + .stat_name = "cmq_not_empty",
105536 + .stat_counter = FM_DMA_COUNTERS_CMQ_NOT_EMPTY,
105537 + },
105538 + {
105539 + .stat_name = "bus_error",
105540 + .stat_counter = FM_DMA_COUNTERS_BUS_ERROR,
105541 + },
105542 + {
105543 + .stat_name = "read_buf_ecc_error",
105544 + .stat_counter = FM_DMA_COUNTERS_READ_BUF_ECC_ERROR,
105545 + },
105546 + {
105547 + .stat_name = "write_buf_ecc_sys_error",
105548 + .stat_counter = FM_DMA_COUNTERS_WRITE_BUF_ECC_SYS_ERROR,
105549 + },
105550 + {
105551 + .stat_name = "write_buf_ecc_fm_error",
105552 + .stat_counter = FM_DMA_COUNTERS_WRITE_BUF_ECC_FM_ERROR,
105553 + },
105554 + /* FM:PCD statistics */
105555 + {
105556 + .stat_name = "pcd_kg_total",
105557 + .stat_counter = e_FM_PCD_KG_COUNTERS_TOTAL,
105558 + },
105559 + {
105560 + .stat_name = "pcd_plcr_yellow",
105561 + .stat_counter = e_FM_PCD_PLCR_COUNTERS_YELLOW,
105562 + },
105563 + {
105564 + .stat_name = "pcd_plcr_red",
105565 + .stat_counter = e_FM_PCD_PLCR_COUNTERS_RED,
105566 + },
105567 + {
105568 + .stat_name = "pcd_plcr_recolored_to_red",
105569 + .stat_counter = e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED,
105570 + },
105571 + {
105572 + .stat_name = "pcd_plcr_recolored_to_yellow",
105573 + .stat_counter = e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW,
105574 + },
105575 + {
105576 + .stat_name = "pcd_plcr_total",
105577 + .stat_counter = e_FM_PCD_PLCR_COUNTERS_TOTAL,
105578 + },
105579 + {
105580 + .stat_name = "pcd_plcr_length_mismatch",
105581 + .stat_counter = e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH,
105582 + },
105583 + {
105584 + .stat_name = "pcd_prs_parse_dispatch",
105585 + .stat_counter = e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH,
105586 + },
105587 + {
105588 + .stat_name = "pcd_prs_l2_parse_result_returned",
105589 + .stat_counter = e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED,
105590 + },
105591 + {
105592 + .stat_name = "pcd_prs_l3_parse_result_returned",
105593 + .stat_counter = e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED,
105594 + },
105595 + {
105596 + .stat_name = "pcd_prs_l4_parse_result_returned",
105597 + .stat_counter = e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED,
105598 + },
105599 + {
105600 + .stat_name = "pcd_prs_shim_parse_result_returned",
105601 + .stat_counter = e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED,
105602 + },
105603 + {
105604 + .stat_name = "pcd_prs_l2_parse_result_returned_with_err",
105605 + .stat_counter =
105606 + e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR,
105607 + },
105608 + {
105609 + .stat_name = "pcd_prs_l3_parse_result_returned_with_err",
105610 + .stat_counter =
105611 + e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR,
105612 + },
105613 + {
105614 + .stat_name = "pcd_prs_l4_parse_result_returned_with_err",
105615 + .stat_counter =
105616 + e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR,
105617 + },
105618 + {
105619 + .stat_name = "pcd_prs_shim_parse_result_returned_with_err",
105620 + .stat_counter =
105621 + e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR,
105622 + },
105623 + {
105624 + .stat_name = "pcd_prs_soft_prs_cycles",
105625 + .stat_counter = e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES,
105626 + },
105627 + {
105628 + .stat_name = "pcd_prs_soft_prs_stall_cycles",
105629 + .stat_counter = e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES,
105630 + },
105631 + {
105632 + .stat_name = "pcd_prs_hard_prs_cycle_incl_stall_cycles",
105633 + .stat_counter =
105634 + e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES,
105635 + },
105636 + {
105637 + .stat_name = "pcd_prs_muram_read_cycles",
105638 + .stat_counter = e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES,
105639 + },
105640 + {
105641 + .stat_name = "pcd_prs_muram_read_stall_cycles",
105642 + .stat_counter = e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES,
105643 + },
105644 + {
105645 + .stat_name = "pcd_prs_muram_write_cycles",
105646 + .stat_counter = e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES,
105647 + },
105648 + {
105649 + .stat_name = "pcd_prs_muram_write_stall_cycles",
105650 + .stat_counter = e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES,
105651 + },
105652 + {
105653 + .stat_name = "pcd_prs_fpm_command_stall_cycles",
105654 + .stat_counter = e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES,
105655 + },
105656 + {}
105657 +};
105658 +
105659 +
105660 +static ssize_t show_fm_risc_load(struct device *dev,
105661 + struct device_attribute *attr, char *buf)
105662 +{
105663 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
105664 + unsigned long flags;
105665 + int m =0;
105666 + int err =0;
105667 + unsigned n = 0;
105668 + t_FmCtrlMon util;
105669 + uint8_t i =0 ;
105670 +
105671 + if (attr == NULL || buf == NULL || dev == NULL)
105672 + return -EINVAL;
105673 +
105674 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
105675 + if (WARN_ON(p_wrp_fm_dev == NULL))
105676 + return -EINVAL;
105677 +
105678 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_Dev)
105679 + return -EIO;
105680 +
105681 + local_irq_save(flags);
105682 +
105683 + /* Calculate risc load */
105684 + FM_CtrlMonStart(p_wrp_fm_dev->h_Dev);
105685 + msleep(1000);
105686 + FM_CtrlMonStop(p_wrp_fm_dev->h_Dev);
105687 +
105688 + for (i = 0; i < FM_NUM_OF_CTRL; i++) {
105689 + err |= FM_CtrlMonGetCounters(p_wrp_fm_dev->h_Dev, i, &util);
105690 + m = snprintf(&buf[n],PAGE_SIZE,"\tRisc%u: util-%u%%, efficiency-%u%%\n",
105691 + i, util.percentCnt[0], util.percentCnt[1]);
105692 + n=m+n;
105693 + }
105694 +
105695 + local_irq_restore(flags);
105696 +
105697 + return n;
105698 +}
105699 +
105700 +/* Fm stats and regs dumps via sysfs */
105701 +static ssize_t show_fm_dma_stats(struct device *dev,
105702 + struct device_attribute *attr, char *buf)
105703 +{
105704 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
105705 + t_FmDmaStatus dma_status;
105706 + unsigned long flags = 0;
105707 + unsigned n = 0;
105708 + uint8_t counter_value = 0, counter = 0;
105709 +
105710 + if (attr == NULL || buf == NULL || dev == NULL)
105711 + return -EINVAL;
105712 +
105713 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
105714 + if (WARN_ON(p_wrp_fm_dev == NULL))
105715 + return -EINVAL;
105716 +
105717 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_Dev)
105718 + return -EIO;
105719 +
105720 + counter = fm_find_statistic_counter_by_name(
105721 + attr->attr.name,
105722 + fm_sysfs_stats, NULL);
105723 +
105724 + local_irq_save(flags);
105725 +
105726 + memset(&dma_status, 0, sizeof(dma_status));
105727 + FM_GetDmaStatus(p_wrp_fm_dev->h_Dev, &dma_status);
105728 +
105729 + switch (counter) {
105730 + case FM_DMA_COUNTERS_CMQ_NOT_EMPTY:
105731 + counter_value = dma_status.cmqNotEmpty;
105732 + break;
105733 + case FM_DMA_COUNTERS_BUS_ERROR:
105734 + counter_value = dma_status.busError;
105735 + break;
105736 + case FM_DMA_COUNTERS_READ_BUF_ECC_ERROR:
105737 + counter_value = dma_status.readBufEccError;
105738 + break;
105739 + case FM_DMA_COUNTERS_WRITE_BUF_ECC_SYS_ERROR:
105740 + counter_value = dma_status.writeBufEccSysError;
105741 + break;
105742 + case FM_DMA_COUNTERS_WRITE_BUF_ECC_FM_ERROR:
105743 + counter_value = dma_status.writeBufEccFmError;
105744 + break;
105745 + default:
105746 + WARN(1, "FMD: failure at %s:%d/%s()!\n", __FILE__, __LINE__,
105747 + __func__);
105748 + break;
105749 + };
105750 +
105751 + n = snprintf(buf, PAGE_SIZE, "\tFM %u counter: %c\n",
105752 + p_wrp_fm_dev->id, counter_value ? 'T' : 'F');
105753 +
105754 + local_irq_restore(flags);
105755 +
105756 + return n;
105757 +}
105758 +
105759 +static ssize_t show_fm_stats(struct device *dev,
105760 + struct device_attribute *attr, char *buf)
105761 +{
105762 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
105763 + unsigned long flags = 0;
105764 + unsigned n = 0, cnt_e = 0;
105765 + uint32_t cnt_val;
105766 + int err;
105767 +
105768 + if (attr == NULL || buf == NULL || dev == NULL)
105769 + return -EINVAL;
105770 +
105771 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
105772 + if (WARN_ON(p_wrp_fm_dev == NULL))
105773 + return -EINVAL;
105774 +
105775 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_Dev)
105776 + return -EIO;
105777 +
105778 + cnt_e = fm_find_statistic_counter_by_name(
105779 + attr->attr.name,
105780 + fm_sysfs_stats, NULL);
105781 +
105782 + err = fm_get_counter(p_wrp_fm_dev->h_Dev,
105783 + (e_FmCounters) cnt_e, &cnt_val);
105784 +
105785 + if (err)
105786 + return err;
105787 +
105788 + local_irq_save(flags);
105789 +
105790 + n = snprintf(buf, PAGE_SIZE, "\tFM %d counter: %d\n",
105791 + p_wrp_fm_dev->id, cnt_val);
105792 +
105793 + local_irq_restore(flags);
105794 +
105795 + return n;
105796 +}
105797 +
105798 +static ssize_t show_fm_muram_free_sz(struct device *dev,
105799 + struct device_attribute *attr, char *buf)
105800 +{
105801 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
105802 + unsigned long flags = 0;
105803 + unsigned n = 0;
105804 + uint64_t muram_free_size = 0;
105805 +
105806 + if (attr == NULL || buf == NULL || dev == NULL)
105807 + return -EINVAL;
105808 +
105809 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
105810 + if (WARN_ON(p_wrp_fm_dev == NULL))
105811 + return -EINVAL;
105812 +
105813 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_Dev)
105814 + return -EIO;
105815 +
105816 + muram_free_size = FM_MURAM_GetFreeMemSize(p_wrp_fm_dev->h_MuramDev);
105817 +
105818 + local_irq_save(flags);
105819 +
105820 + n = snprintf(buf, PAGE_SIZE, "\tFM %d muram_free_size: %lld\n",
105821 + p_wrp_fm_dev->id, muram_free_size);
105822 +
105823 + local_irq_restore(flags);
105824 +
105825 + return n;
105826 +}
105827 +
105828 +static ssize_t show_fm_ctrl_code_ver(struct device *dev,
105829 + struct device_attribute *attr, char *buf)
105830 +{
105831 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
105832 + unsigned long flags = 0;
105833 + unsigned n = 0;
105834 + t_FmCtrlCodeRevisionInfo rv_info;
105835 +
105836 + if (attr == NULL || buf == NULL || dev == NULL)
105837 + return -EINVAL;
105838 +
105839 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
105840 + if (WARN_ON(p_wrp_fm_dev == NULL))
105841 + return -EINVAL;
105842 +
105843 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_Dev)
105844 + return -EIO;
105845 +
105846 + FM_GetFmanCtrlCodeRevision((t_Fm *)p_wrp_fm_dev->h_Dev, &rv_info);
105847 +
105848 + local_irq_save(flags);
105849 +
105850 + FM_DMP_LN(buf, n, "- FM %d ctrl code pkg info:\n", p_wrp_fm_dev->id);
105851 + FM_DMP_LN(buf, n, "Package rev: %d\n", rv_info.packageRev);
105852 + FM_DMP_LN(buf, n, "major rev: %d\n", rv_info.majorRev);
105853 + FM_DMP_LN(buf, n, "minor rev: %d\n", rv_info.minorRev);
105854 +
105855 + local_irq_restore(flags);
105856 +
105857 + return n;
105858 +}
105859 +
105860 +static ssize_t show_fm_pcd_stats(struct device *dev,
105861 + struct device_attribute *attr, char *buf)
105862 +{
105863 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
105864 + unsigned long flags = 0;
105865 + unsigned n = 0, counter = 0;
105866 +
105867 + if (attr == NULL || buf == NULL || dev == NULL)
105868 + return -EINVAL;
105869 +
105870 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
105871 + if (WARN_ON(p_wrp_fm_dev == NULL))
105872 + return -EINVAL;
105873 +
105874 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_Dev ||
105875 + !p_wrp_fm_dev->h_PcdDev)
105876 + return -EIO;
105877 +
105878 + counter = fm_find_statistic_counter_by_name(
105879 + attr->attr.name,
105880 + fm_sysfs_stats, NULL);
105881 +
105882 + local_irq_save(flags);
105883 +
105884 + n = snprintf(buf, PAGE_SIZE, "\tFM %d counter: %d\n",
105885 + p_wrp_fm_dev->id,
105886 + FM_PCD_GetCounter(p_wrp_fm_dev->h_PcdDev,
105887 + (e_FmPcdCounters) counter));
105888 +
105889 + local_irq_restore(flags);
105890 +
105891 + return n;
105892 +}
105893 +
105894 +static ssize_t show_fm_tnum_dbg(struct device *dev,
105895 + struct device_attribute *attr,
105896 + char *buf)
105897 +{
105898 + unsigned long flags;
105899 + unsigned n = 0;
105900 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
105901 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
105902 +#endif
105903 +
105904 + if (attr == NULL || buf == NULL || dev == NULL)
105905 + return -EINVAL;
105906 +
105907 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
105908 +
105909 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
105910 + if (WARN_ON(p_wrp_fm_dev == NULL))
105911 + return -EINVAL;
105912 +
105913 + local_irq_save(flags);
105914 +
105915 + if (!p_wrp_fm_dev->active)
105916 + return -EIO;
105917 + else {
105918 + int tn_s;
105919 +
105920 + if (!sscanf(attr->attr.name, "tnum_dbg_%d", &tn_s))
105921 + return -EINVAL;
105922 +
105923 + n = fm_dump_tnum_dbg(p_wrp_fm_dev->h_Dev,
105924 + tn_s, tn_s + 15, buf, n);
105925 + }
105926 + local_irq_restore(flags);
105927 +#else
105928 +
105929 + local_irq_save(flags);
105930 + n = snprintf(buf, PAGE_SIZE,
105931 + "Debug level is too low to dump registers!!!\n");
105932 + local_irq_restore(flags);
105933 +#endif /* (defined(DEBUG_ERRORS) && ... */
105934 +
105935 + return n;
105936 +}
105937 +
105938 +static ssize_t show_fm_cls_plan(struct device *dev,
105939 + struct device_attribute *attr,
105940 + char *buf)
105941 +{
105942 + unsigned long flags;
105943 + unsigned n = 0;
105944 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
105945 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
105946 +#endif
105947 +
105948 + if (attr == NULL || buf == NULL || dev == NULL)
105949 + return -EINVAL;
105950 +
105951 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
105952 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
105953 + if (WARN_ON(p_wrp_fm_dev == NULL))
105954 + return -EINVAL;
105955 +
105956 + local_irq_save(flags);
105957 +
105958 + n = snprintf(buf, PAGE_SIZE, "\n FM-KG classification plan dump.\n");
105959 +
105960 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_PcdDev)
105961 + return -EIO;
105962 + else {
105963 + int cpn;
105964 +
105965 + if (!sscanf(attr->attr.name, "cls_plan_%d", &cpn))
105966 + return -EINVAL;
105967 +
105968 + n = fm_dump_cls_plan(p_wrp_fm_dev->h_PcdDev, cpn, buf, n);
105969 + }
105970 + local_irq_restore(flags);
105971 +#else
105972 + local_irq_save(flags);
105973 + n = snprintf(buf, PAGE_SIZE,
105974 + "Debug level is too low to dump registers!!!\n");
105975 + local_irq_restore(flags);
105976 +#endif /* (defined(DEBUG_ERRORS) && ... */
105977 +
105978 + return n;
105979 +}
105980 +
105981 +static ssize_t show_fm_profiles(struct device *dev,
105982 + struct device_attribute *attr,
105983 + char *buf)
105984 +{
105985 + unsigned long flags;
105986 + unsigned n = 0;
105987 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
105988 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
105989 +#endif
105990 +
105991 + if (attr == NULL || buf == NULL || dev == NULL)
105992 + return -EINVAL;
105993 +
105994 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
105995 +
105996 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
105997 + if (WARN_ON(p_wrp_fm_dev == NULL))
105998 + return -EINVAL;
105999 +
106000 + local_irq_save(flags);
106001 +
106002 + n = snprintf(buf, PAGE_SIZE, "FM policer profile dump.\n");
106003 +
106004 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_PcdDev)
106005 + return -EIO;
106006 + else {
106007 + int pn;
106008 +
106009 + if (!sscanf(attr->attr.name, "profile_%d", &pn))
106010 + return -EINVAL;
106011 +
106012 + n = fm_profile_dump_regs(p_wrp_fm_dev->h_PcdDev, pn, buf, n);
106013 + }
106014 + local_irq_restore(flags);
106015 +#else
106016 + local_irq_save(flags);
106017 + n = snprintf(buf, PAGE_SIZE,
106018 + "Debug level is too low to dump registers!!!\n");
106019 + local_irq_restore(flags);
106020 +#endif /* (defined(DEBUG_ERRORS) && ... */
106021 +
106022 + return n;
106023 +}
106024 +
106025 +static ssize_t show_fm_schemes(struct device *dev,
106026 + struct device_attribute *attr,
106027 + char *buf)
106028 +{
106029 + unsigned long flags;
106030 + unsigned n = 0;
106031 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106032 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
106033 +#endif
106034 +
106035 + if (attr == NULL || buf == NULL || dev == NULL)
106036 + return -EINVAL;
106037 +
106038 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106039 +
106040 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
106041 + if (WARN_ON(p_wrp_fm_dev == NULL))
106042 + return -EINVAL;
106043 +
106044 + local_irq_save(flags);
106045 +
106046 + n = snprintf(buf, PAGE_SIZE, "FM-KG driver schemes dump.\n");
106047 +
106048 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_PcdDev)
106049 + return -EIO;
106050 + else {
106051 + int sn;
106052 +
106053 + if (!sscanf(attr->attr.name, "scheme_%d", &sn))
106054 + return -EINVAL;
106055 +
106056 + n = fm_dump_scheme(p_wrp_fm_dev->h_PcdDev, sn, buf, n);
106057 + }
106058 + local_irq_restore(flags);
106059 +#else
106060 +
106061 + local_irq_save(flags);
106062 + n = snprintf(buf, PAGE_SIZE,
106063 + "Debug level is too low to dump registers!!!\n");
106064 + local_irq_restore(flags);
106065 +#endif /* (defined(DEBUG_ERRORS) && ... */
106066 +
106067 + return n;
106068 +}
106069 +
106070 +/* FM */
106071 +static DEVICE_ATTR(enq_total_frame, S_IRUGO, show_fm_stats, NULL);
106072 +static DEVICE_ATTR(deq_total_frame, S_IRUGO, show_fm_stats, NULL);
106073 +static DEVICE_ATTR(fm_risc_load_val, S_IRUGO, show_fm_risc_load, NULL);
106074 +static DEVICE_ATTR(deq_0, S_IRUGO, show_fm_stats, NULL);
106075 +static DEVICE_ATTR(deq_1, S_IRUGO, show_fm_stats, NULL);
106076 +static DEVICE_ATTR(deq_2, S_IRUGO, show_fm_stats, NULL);
106077 +static DEVICE_ATTR(deq_3, S_IRUGO, show_fm_stats, NULL);
106078 +static DEVICE_ATTR(deq_from_default, S_IRUGO, show_fm_stats, NULL);
106079 +static DEVICE_ATTR(deq_from_context, S_IRUGO, show_fm_stats, NULL);
106080 +static DEVICE_ATTR(deq_from_fd, S_IRUGO, show_fm_stats, NULL);
106081 +static DEVICE_ATTR(deq_confirm, S_IRUGO, show_fm_stats, NULL);
106082 +/* FM:DMA */
106083 +static DEVICE_ATTR(cmq_not_empty, S_IRUGO, show_fm_dma_stats, NULL);
106084 +static DEVICE_ATTR(bus_error, S_IRUGO, show_fm_dma_stats, NULL);
106085 +static DEVICE_ATTR(read_buf_ecc_error, S_IRUGO, show_fm_dma_stats, NULL);
106086 +static DEVICE_ATTR(write_buf_ecc_sys_error, S_IRUGO, show_fm_dma_stats, NULL);
106087 +static DEVICE_ATTR(write_buf_ecc_fm_error, S_IRUGO, show_fm_dma_stats, NULL);
106088 +/* FM:PCD */
106089 +static DEVICE_ATTR(pcd_kg_total, S_IRUGO, show_fm_pcd_stats, NULL);
106090 +static DEVICE_ATTR(pcd_plcr_yellow, S_IRUGO, show_fm_pcd_stats, NULL);
106091 +static DEVICE_ATTR(pcd_plcr_red, S_IRUGO, show_fm_pcd_stats, NULL);
106092 +static DEVICE_ATTR(pcd_plcr_recolored_to_red, S_IRUGO, show_fm_pcd_stats,
106093 + NULL);
106094 +static DEVICE_ATTR(pcd_plcr_recolored_to_yellow, S_IRUGO, show_fm_pcd_stats,
106095 + NULL);
106096 +static DEVICE_ATTR(pcd_plcr_total, S_IRUGO, show_fm_pcd_stats, NULL);
106097 +static DEVICE_ATTR(pcd_plcr_length_mismatch, S_IRUGO, show_fm_pcd_stats,
106098 + NULL);
106099 +static DEVICE_ATTR(pcd_prs_parse_dispatch, S_IRUGO, show_fm_pcd_stats, NULL);
106100 +static DEVICE_ATTR(pcd_prs_l2_parse_result_returned, S_IRUGO,
106101 + show_fm_pcd_stats, NULL);
106102 +static DEVICE_ATTR(pcd_prs_l3_parse_result_returned, S_IRUGO,
106103 + show_fm_pcd_stats, NULL);
106104 +static DEVICE_ATTR(pcd_prs_l4_parse_result_returned, S_IRUGO,
106105 + show_fm_pcd_stats, NULL);
106106 +static DEVICE_ATTR(pcd_prs_shim_parse_result_returned, S_IRUGO,
106107 + show_fm_pcd_stats, NULL);
106108 +static DEVICE_ATTR(pcd_prs_l2_parse_result_returned_with_err, S_IRUGO,
106109 + show_fm_pcd_stats, NULL);
106110 +static DEVICE_ATTR(pcd_prs_l3_parse_result_returned_with_err, S_IRUGO,
106111 + show_fm_pcd_stats, NULL);
106112 +static DEVICE_ATTR(pcd_prs_l4_parse_result_returned_with_err, S_IRUGO,
106113 + show_fm_pcd_stats, NULL);
106114 +static DEVICE_ATTR(pcd_prs_shim_parse_result_returned_with_err, S_IRUGO,
106115 + show_fm_pcd_stats, NULL);
106116 +static DEVICE_ATTR(pcd_prs_soft_prs_cycles, S_IRUGO, show_fm_pcd_stats, NULL);
106117 +static DEVICE_ATTR(pcd_prs_soft_prs_stall_cycles, S_IRUGO, show_fm_pcd_stats,
106118 + NULL);
106119 +static DEVICE_ATTR(pcd_prs_hard_prs_cycle_incl_stall_cycles, S_IRUGO,
106120 + show_fm_pcd_stats, NULL);
106121 +static DEVICE_ATTR(pcd_prs_muram_read_cycles, S_IRUGO, show_fm_pcd_stats,
106122 + NULL);
106123 +static DEVICE_ATTR(pcd_prs_muram_read_stall_cycles, S_IRUGO,
106124 + show_fm_pcd_stats, NULL);
106125 +static DEVICE_ATTR(pcd_prs_muram_write_cycles, S_IRUGO, show_fm_pcd_stats,
106126 + NULL);
106127 +static DEVICE_ATTR(pcd_prs_muram_write_stall_cycles, S_IRUGO,
106128 + show_fm_pcd_stats, NULL);
106129 +static DEVICE_ATTR(pcd_prs_fpm_command_stall_cycles, S_IRUGO,
106130 + show_fm_pcd_stats, NULL);
106131 +
106132 +static DEVICE_ATTR(tnum_dbg_0, S_IRUGO, show_fm_tnum_dbg, NULL);
106133 +static DEVICE_ATTR(tnum_dbg_16, S_IRUGO, show_fm_tnum_dbg, NULL);
106134 +static DEVICE_ATTR(tnum_dbg_32, S_IRUGO, show_fm_tnum_dbg, NULL);
106135 +static DEVICE_ATTR(tnum_dbg_48, S_IRUGO, show_fm_tnum_dbg, NULL);
106136 +static DEVICE_ATTR(tnum_dbg_64, S_IRUGO, show_fm_tnum_dbg, NULL);
106137 +static DEVICE_ATTR(tnum_dbg_80, S_IRUGO, show_fm_tnum_dbg, NULL);
106138 +static DEVICE_ATTR(tnum_dbg_96, S_IRUGO, show_fm_tnum_dbg, NULL);
106139 +static DEVICE_ATTR(tnum_dbg_112, S_IRUGO, show_fm_tnum_dbg, NULL);
106140 +
106141 +static DEVICE_ATTR(cls_plan_0, S_IRUGO, show_fm_cls_plan, NULL);
106142 +static DEVICE_ATTR(cls_plan_1, S_IRUGO, show_fm_cls_plan, NULL);
106143 +static DEVICE_ATTR(cls_plan_2, S_IRUGO, show_fm_cls_plan, NULL);
106144 +static DEVICE_ATTR(cls_plan_3, S_IRUGO, show_fm_cls_plan, NULL);
106145 +static DEVICE_ATTR(cls_plan_4, S_IRUGO, show_fm_cls_plan, NULL);
106146 +static DEVICE_ATTR(cls_plan_5, S_IRUGO, show_fm_cls_plan, NULL);
106147 +static DEVICE_ATTR(cls_plan_6, S_IRUGO, show_fm_cls_plan, NULL);
106148 +static DEVICE_ATTR(cls_plan_7, S_IRUGO, show_fm_cls_plan, NULL);
106149 +static DEVICE_ATTR(cls_plan_8, S_IRUGO, show_fm_cls_plan, NULL);
106150 +static DEVICE_ATTR(cls_plan_9, S_IRUGO, show_fm_cls_plan, NULL);
106151 +static DEVICE_ATTR(cls_plan_10, S_IRUGO, show_fm_cls_plan, NULL);
106152 +static DEVICE_ATTR(cls_plan_11, S_IRUGO, show_fm_cls_plan, NULL);
106153 +static DEVICE_ATTR(cls_plan_12, S_IRUGO, show_fm_cls_plan, NULL);
106154 +static DEVICE_ATTR(cls_plan_13, S_IRUGO, show_fm_cls_plan, NULL);
106155 +static DEVICE_ATTR(cls_plan_14, S_IRUGO, show_fm_cls_plan, NULL);
106156 +static DEVICE_ATTR(cls_plan_15, S_IRUGO, show_fm_cls_plan, NULL);
106157 +static DEVICE_ATTR(cls_plan_16, S_IRUGO, show_fm_cls_plan, NULL);
106158 +static DEVICE_ATTR(cls_plan_17, S_IRUGO, show_fm_cls_plan, NULL);
106159 +static DEVICE_ATTR(cls_plan_18, S_IRUGO, show_fm_cls_plan, NULL);
106160 +static DEVICE_ATTR(cls_plan_19, S_IRUGO, show_fm_cls_plan, NULL);
106161 +static DEVICE_ATTR(cls_plan_20, S_IRUGO, show_fm_cls_plan, NULL);
106162 +static DEVICE_ATTR(cls_plan_21, S_IRUGO, show_fm_cls_plan, NULL);
106163 +static DEVICE_ATTR(cls_plan_22, S_IRUGO, show_fm_cls_plan, NULL);
106164 +static DEVICE_ATTR(cls_plan_23, S_IRUGO, show_fm_cls_plan, NULL);
106165 +static DEVICE_ATTR(cls_plan_24, S_IRUGO, show_fm_cls_plan, NULL);
106166 +static DEVICE_ATTR(cls_plan_25, S_IRUGO, show_fm_cls_plan, NULL);
106167 +static DEVICE_ATTR(cls_plan_26, S_IRUGO, show_fm_cls_plan, NULL);
106168 +static DEVICE_ATTR(cls_plan_27, S_IRUGO, show_fm_cls_plan, NULL);
106169 +static DEVICE_ATTR(cls_plan_28, S_IRUGO, show_fm_cls_plan, NULL);
106170 +static DEVICE_ATTR(cls_plan_29, S_IRUGO, show_fm_cls_plan, NULL);
106171 +static DEVICE_ATTR(cls_plan_30, S_IRUGO, show_fm_cls_plan, NULL);
106172 +static DEVICE_ATTR(cls_plan_31, S_IRUGO, show_fm_cls_plan, NULL);
106173 +
106174 +static DEVICE_ATTR(profile_0, S_IRUGO, show_fm_profiles, NULL);
106175 +static DEVICE_ATTR(profile_1, S_IRUGO, show_fm_profiles, NULL);
106176 +static DEVICE_ATTR(profile_2, S_IRUGO, show_fm_profiles, NULL);
106177 +static DEVICE_ATTR(profile_3, S_IRUGO, show_fm_profiles, NULL);
106178 +static DEVICE_ATTR(profile_4, S_IRUGO, show_fm_profiles, NULL);
106179 +static DEVICE_ATTR(profile_5, S_IRUGO, show_fm_profiles, NULL);
106180 +static DEVICE_ATTR(profile_6, S_IRUGO, show_fm_profiles, NULL);
106181 +static DEVICE_ATTR(profile_7, S_IRUGO, show_fm_profiles, NULL);
106182 +static DEVICE_ATTR(profile_8, S_IRUGO, show_fm_profiles, NULL);
106183 +static DEVICE_ATTR(profile_9, S_IRUGO, show_fm_profiles, NULL);
106184 +static DEVICE_ATTR(profile_10, S_IRUGO, show_fm_profiles, NULL);
106185 +static DEVICE_ATTR(profile_11, S_IRUGO, show_fm_profiles, NULL);
106186 +static DEVICE_ATTR(profile_12, S_IRUGO, show_fm_profiles, NULL);
106187 +static DEVICE_ATTR(profile_13, S_IRUGO, show_fm_profiles, NULL);
106188 +static DEVICE_ATTR(profile_14, S_IRUGO, show_fm_profiles, NULL);
106189 +static DEVICE_ATTR(profile_15, S_IRUGO, show_fm_profiles, NULL);
106190 +static DEVICE_ATTR(profile_16, S_IRUGO, show_fm_profiles, NULL);
106191 +static DEVICE_ATTR(profile_17, S_IRUGO, show_fm_profiles, NULL);
106192 +static DEVICE_ATTR(profile_18, S_IRUGO, show_fm_profiles, NULL);
106193 +static DEVICE_ATTR(profile_19, S_IRUGO, show_fm_profiles, NULL);
106194 +static DEVICE_ATTR(profile_20, S_IRUGO, show_fm_profiles, NULL);
106195 +static DEVICE_ATTR(profile_21, S_IRUGO, show_fm_profiles, NULL);
106196 +static DEVICE_ATTR(profile_22, S_IRUGO, show_fm_profiles, NULL);
106197 +static DEVICE_ATTR(profile_23, S_IRUGO, show_fm_profiles, NULL);
106198 +static DEVICE_ATTR(profile_24, S_IRUGO, show_fm_profiles, NULL);
106199 +static DEVICE_ATTR(profile_25, S_IRUGO, show_fm_profiles, NULL);
106200 +static DEVICE_ATTR(profile_26, S_IRUGO, show_fm_profiles, NULL);
106201 +static DEVICE_ATTR(profile_27, S_IRUGO, show_fm_profiles, NULL);
106202 +static DEVICE_ATTR(profile_28, S_IRUGO, show_fm_profiles, NULL);
106203 +static DEVICE_ATTR(profile_29, S_IRUGO, show_fm_profiles, NULL);
106204 +static DEVICE_ATTR(profile_30, S_IRUGO, show_fm_profiles, NULL);
106205 +static DEVICE_ATTR(profile_31, S_IRUGO, show_fm_profiles, NULL);
106206 +
106207 +static DEVICE_ATTR(scheme_0, S_IRUGO, show_fm_schemes, NULL);
106208 +static DEVICE_ATTR(scheme_1, S_IRUGO, show_fm_schemes, NULL);
106209 +static DEVICE_ATTR(scheme_2, S_IRUGO, show_fm_schemes, NULL);
106210 +static DEVICE_ATTR(scheme_3, S_IRUGO, show_fm_schemes, NULL);
106211 +static DEVICE_ATTR(scheme_4, S_IRUGO, show_fm_schemes, NULL);
106212 +static DEVICE_ATTR(scheme_5, S_IRUGO, show_fm_schemes, NULL);
106213 +static DEVICE_ATTR(scheme_6, S_IRUGO, show_fm_schemes, NULL);
106214 +static DEVICE_ATTR(scheme_7, S_IRUGO, show_fm_schemes, NULL);
106215 +static DEVICE_ATTR(scheme_8, S_IRUGO, show_fm_schemes, NULL);
106216 +static DEVICE_ATTR(scheme_9, S_IRUGO, show_fm_schemes, NULL);
106217 +static DEVICE_ATTR(scheme_10, S_IRUGO, show_fm_schemes, NULL);
106218 +static DEVICE_ATTR(scheme_11, S_IRUGO, show_fm_schemes, NULL);
106219 +static DEVICE_ATTR(scheme_12, S_IRUGO, show_fm_schemes, NULL);
106220 +static DEVICE_ATTR(scheme_13, S_IRUGO, show_fm_schemes, NULL);
106221 +static DEVICE_ATTR(scheme_14, S_IRUGO, show_fm_schemes, NULL);
106222 +static DEVICE_ATTR(scheme_15, S_IRUGO, show_fm_schemes, NULL);
106223 +static DEVICE_ATTR(scheme_16, S_IRUGO, show_fm_schemes, NULL);
106224 +static DEVICE_ATTR(scheme_17, S_IRUGO, show_fm_schemes, NULL);
106225 +static DEVICE_ATTR(scheme_18, S_IRUGO, show_fm_schemes, NULL);
106226 +static DEVICE_ATTR(scheme_19, S_IRUGO, show_fm_schemes, NULL);
106227 +static DEVICE_ATTR(scheme_20, S_IRUGO, show_fm_schemes, NULL);
106228 +static DEVICE_ATTR(scheme_21, S_IRUGO, show_fm_schemes, NULL);
106229 +static DEVICE_ATTR(scheme_22, S_IRUGO, show_fm_schemes, NULL);
106230 +static DEVICE_ATTR(scheme_23, S_IRUGO, show_fm_schemes, NULL);
106231 +static DEVICE_ATTR(scheme_24, S_IRUGO, show_fm_schemes, NULL);
106232 +static DEVICE_ATTR(scheme_25, S_IRUGO, show_fm_schemes, NULL);
106233 +static DEVICE_ATTR(scheme_26, S_IRUGO, show_fm_schemes, NULL);
106234 +static DEVICE_ATTR(scheme_27, S_IRUGO, show_fm_schemes, NULL);
106235 +static DEVICE_ATTR(scheme_28, S_IRUGO, show_fm_schemes, NULL);
106236 +static DEVICE_ATTR(scheme_29, S_IRUGO, show_fm_schemes, NULL);
106237 +static DEVICE_ATTR(scheme_30, S_IRUGO, show_fm_schemes, NULL);
106238 +static DEVICE_ATTR(scheme_31, S_IRUGO, show_fm_schemes, NULL);
106239 +
106240 +
106241 +static struct attribute *fm_dev_stats_attributes[] = {
106242 + &dev_attr_enq_total_frame.attr,
106243 + &dev_attr_deq_total_frame.attr,
106244 + &dev_attr_deq_0.attr,
106245 + &dev_attr_deq_1.attr,
106246 + &dev_attr_deq_2.attr,
106247 + &dev_attr_deq_3.attr,
106248 + &dev_attr_deq_from_default.attr,
106249 + &dev_attr_deq_from_context.attr,
106250 + &dev_attr_deq_from_fd.attr,
106251 + &dev_attr_deq_confirm.attr,
106252 + &dev_attr_cmq_not_empty.attr,
106253 + &dev_attr_bus_error.attr,
106254 + &dev_attr_read_buf_ecc_error.attr,
106255 + &dev_attr_write_buf_ecc_sys_error.attr,
106256 + &dev_attr_write_buf_ecc_fm_error.attr,
106257 + &dev_attr_pcd_kg_total.attr,
106258 + &dev_attr_pcd_plcr_yellow.attr,
106259 + &dev_attr_pcd_plcr_red.attr,
106260 + &dev_attr_pcd_plcr_recolored_to_red.attr,
106261 + &dev_attr_pcd_plcr_recolored_to_yellow.attr,
106262 + &dev_attr_pcd_plcr_total.attr,
106263 + &dev_attr_pcd_plcr_length_mismatch.attr,
106264 + &dev_attr_pcd_prs_parse_dispatch.attr,
106265 + &dev_attr_pcd_prs_l2_parse_result_returned.attr,
106266 + &dev_attr_pcd_prs_l3_parse_result_returned.attr,
106267 + &dev_attr_pcd_prs_l4_parse_result_returned.attr,
106268 + &dev_attr_pcd_prs_shim_parse_result_returned.attr,
106269 + &dev_attr_pcd_prs_l2_parse_result_returned_with_err.attr,
106270 + &dev_attr_pcd_prs_l3_parse_result_returned_with_err.attr,
106271 + &dev_attr_pcd_prs_l4_parse_result_returned_with_err.attr,
106272 + &dev_attr_pcd_prs_shim_parse_result_returned_with_err.attr,
106273 + &dev_attr_pcd_prs_soft_prs_cycles.attr,
106274 + &dev_attr_pcd_prs_soft_prs_stall_cycles.attr,
106275 + &dev_attr_pcd_prs_hard_prs_cycle_incl_stall_cycles.attr,
106276 + &dev_attr_pcd_prs_muram_read_cycles.attr,
106277 + &dev_attr_pcd_prs_muram_read_stall_cycles.attr,
106278 + &dev_attr_pcd_prs_muram_write_cycles.attr,
106279 + &dev_attr_pcd_prs_muram_write_stall_cycles.attr,
106280 + &dev_attr_pcd_prs_fpm_command_stall_cycles.attr,
106281 + NULL
106282 +};
106283 +
106284 +static struct attribute *fm_dev_tnums_dbg_attributes[] = {
106285 + &dev_attr_tnum_dbg_0.attr,
106286 + &dev_attr_tnum_dbg_16.attr,
106287 + &dev_attr_tnum_dbg_32.attr,
106288 + &dev_attr_tnum_dbg_48.attr,
106289 + &dev_attr_tnum_dbg_64.attr,
106290 + &dev_attr_tnum_dbg_80.attr,
106291 + &dev_attr_tnum_dbg_96.attr,
106292 + &dev_attr_tnum_dbg_112.attr,
106293 + NULL
106294 +};
106295 +
106296 +static struct attribute *fm_dev_cls_plans_attributes[] = {
106297 + &dev_attr_cls_plan_0.attr,
106298 + &dev_attr_cls_plan_1.attr,
106299 + &dev_attr_cls_plan_2.attr,
106300 + &dev_attr_cls_plan_3.attr,
106301 + &dev_attr_cls_plan_4.attr,
106302 + &dev_attr_cls_plan_5.attr,
106303 + &dev_attr_cls_plan_6.attr,
106304 + &dev_attr_cls_plan_7.attr,
106305 + &dev_attr_cls_plan_8.attr,
106306 + &dev_attr_cls_plan_9.attr,
106307 + &dev_attr_cls_plan_10.attr,
106308 + &dev_attr_cls_plan_11.attr,
106309 + &dev_attr_cls_plan_12.attr,
106310 + &dev_attr_cls_plan_13.attr,
106311 + &dev_attr_cls_plan_14.attr,
106312 + &dev_attr_cls_plan_15.attr,
106313 + &dev_attr_cls_plan_16.attr,
106314 + &dev_attr_cls_plan_17.attr,
106315 + &dev_attr_cls_plan_18.attr,
106316 + &dev_attr_cls_plan_19.attr,
106317 + &dev_attr_cls_plan_20.attr,
106318 + &dev_attr_cls_plan_21.attr,
106319 + &dev_attr_cls_plan_22.attr,
106320 + &dev_attr_cls_plan_23.attr,
106321 + &dev_attr_cls_plan_24.attr,
106322 + &dev_attr_cls_plan_25.attr,
106323 + &dev_attr_cls_plan_26.attr,
106324 + &dev_attr_cls_plan_27.attr,
106325 + &dev_attr_cls_plan_28.attr,
106326 + &dev_attr_cls_plan_29.attr,
106327 + &dev_attr_cls_plan_30.attr,
106328 + &dev_attr_cls_plan_31.attr,
106329 + NULL
106330 +};
106331 +
106332 +static struct attribute *fm_dev_profiles_attributes[] = {
106333 + &dev_attr_profile_0.attr,
106334 + &dev_attr_profile_1.attr,
106335 + &dev_attr_profile_2.attr,
106336 + &dev_attr_profile_3.attr,
106337 + &dev_attr_profile_4.attr,
106338 + &dev_attr_profile_5.attr,
106339 + &dev_attr_profile_6.attr,
106340 + &dev_attr_profile_7.attr,
106341 + &dev_attr_profile_8.attr,
106342 + &dev_attr_profile_9.attr,
106343 + &dev_attr_profile_10.attr,
106344 + &dev_attr_profile_11.attr,
106345 + &dev_attr_profile_12.attr,
106346 + &dev_attr_profile_13.attr,
106347 + &dev_attr_profile_14.attr,
106348 + &dev_attr_profile_15.attr,
106349 + &dev_attr_profile_16.attr,
106350 + &dev_attr_profile_17.attr,
106351 + &dev_attr_profile_18.attr,
106352 + &dev_attr_profile_19.attr,
106353 + &dev_attr_profile_20.attr,
106354 + &dev_attr_profile_21.attr,
106355 + &dev_attr_profile_22.attr,
106356 + &dev_attr_profile_23.attr,
106357 + &dev_attr_profile_24.attr,
106358 + &dev_attr_profile_25.attr,
106359 + &dev_attr_profile_26.attr,
106360 + &dev_attr_profile_27.attr,
106361 + &dev_attr_profile_28.attr,
106362 + &dev_attr_profile_29.attr,
106363 + &dev_attr_profile_30.attr,
106364 + &dev_attr_profile_31.attr,
106365 + NULL
106366 +};
106367 +
106368 +static struct attribute *fm_dev_schemes_attributes[] = {
106369 + &dev_attr_scheme_0.attr,
106370 + &dev_attr_scheme_1.attr,
106371 + &dev_attr_scheme_2.attr,
106372 + &dev_attr_scheme_3.attr,
106373 + &dev_attr_scheme_4.attr,
106374 + &dev_attr_scheme_5.attr,
106375 + &dev_attr_scheme_6.attr,
106376 + &dev_attr_scheme_7.attr,
106377 + &dev_attr_scheme_8.attr,
106378 + &dev_attr_scheme_9.attr,
106379 + &dev_attr_scheme_10.attr,
106380 + &dev_attr_scheme_11.attr,
106381 + &dev_attr_scheme_12.attr,
106382 + &dev_attr_scheme_13.attr,
106383 + &dev_attr_scheme_14.attr,
106384 + &dev_attr_scheme_15.attr,
106385 + &dev_attr_scheme_16.attr,
106386 + &dev_attr_scheme_17.attr,
106387 + &dev_attr_scheme_18.attr,
106388 + &dev_attr_scheme_19.attr,
106389 + &dev_attr_scheme_20.attr,
106390 + &dev_attr_scheme_21.attr,
106391 + &dev_attr_scheme_22.attr,
106392 + &dev_attr_scheme_23.attr,
106393 + &dev_attr_scheme_24.attr,
106394 + &dev_attr_scheme_25.attr,
106395 + &dev_attr_scheme_26.attr,
106396 + &dev_attr_scheme_27.attr,
106397 + &dev_attr_scheme_28.attr,
106398 + &dev_attr_scheme_29.attr,
106399 + &dev_attr_scheme_30.attr,
106400 + &dev_attr_scheme_31.attr,
106401 + NULL
106402 +};
106403 +
106404 +static const struct attribute_group fm_dev_stats_attr_grp = {
106405 + .name = "statistics",
106406 + .attrs = fm_dev_stats_attributes
106407 +};
106408 +
106409 +static const struct attribute_group fm_dev_tnums_dbg_attr_grp = {
106410 + .name = "tnums_dbg",
106411 + .attrs = fm_dev_tnums_dbg_attributes
106412 +};
106413 +
106414 +static const struct attribute_group fm_dev_cls_plans_attr_grp = {
106415 + .name = "cls_plans",
106416 + .attrs = fm_dev_cls_plans_attributes
106417 +};
106418 +
106419 +static const struct attribute_group fm_dev_schemes_attr_grp = {
106420 + .name = "schemes",
106421 + .attrs = fm_dev_schemes_attributes
106422 +};
106423 +
106424 +static const struct attribute_group fm_dev_profiles_attr_grp = {
106425 + .name = "profiles",
106426 + .attrs = fm_dev_profiles_attributes
106427 +};
106428 +
106429 +static ssize_t show_fm_regs(struct device *dev,
106430 + struct device_attribute *attr,
106431 + char *buf)
106432 +{
106433 + unsigned long flags;
106434 + unsigned n = 0;
106435 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106436 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
106437 +#endif
106438 + if (attr == NULL || buf == NULL || dev == NULL)
106439 + return -EINVAL;
106440 +
106441 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106442 +
106443 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
106444 + if (WARN_ON(p_wrp_fm_dev == NULL))
106445 + return -EINVAL;
106446 +
106447 + local_irq_save(flags);
106448 +
106449 + n = snprintf(buf, PAGE_SIZE, "FM driver registers dump.\n");
106450 +
106451 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_Dev)
106452 + return -EIO;
106453 + else
106454 + n = fm_dump_regs(p_wrp_fm_dev->h_Dev, buf, n);
106455 +
106456 + local_irq_restore(flags);
106457 +#else
106458 +
106459 + local_irq_save(flags);
106460 + n = snprintf(buf, PAGE_SIZE,
106461 + "Debug level is too low to dump registers!!!\n");
106462 + local_irq_restore(flags);
106463 +#endif /* (defined(DEBUG_ERRORS) && ... */
106464 +
106465 + return n;
106466 +}
106467 +
106468 +static ssize_t show_fm_kg_pe_regs(struct device *dev,
106469 + struct device_attribute *attr,
106470 + char *buf)
106471 +{
106472 + unsigned long flags;
106473 + unsigned n = 0;
106474 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106475 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
106476 +#endif
106477 +
106478 + if (attr == NULL || buf == NULL || dev == NULL)
106479 + return -EINVAL;
106480 +
106481 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106482 +
106483 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
106484 + if (WARN_ON(p_wrp_fm_dev == NULL))
106485 + return -EINVAL;
106486 +
106487 + local_irq_save(flags);
106488 +
106489 + n = snprintf(buf, PAGE_SIZE,
106490 + "\n FM-KG Port Partition Config registers dump.\n");
106491 +
106492 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_PcdDev)
106493 + return -EIO;
106494 + else
106495 + n = fm_kg_pe_dump_regs(p_wrp_fm_dev->h_PcdDev, buf, n);
106496 +
106497 + local_irq_restore(flags);
106498 +#else
106499 +
106500 + local_irq_save(flags);
106501 + n = snprintf(buf, PAGE_SIZE,
106502 + "Debug level is too low to dump registers!!!\n");
106503 + local_irq_restore(flags);
106504 +#endif /* (defined(DEBUG_ERRORS) && ... */
106505 +
106506 + return n;
106507 +}
106508 +
106509 +static ssize_t show_fm_kg_regs(struct device *dev,
106510 + struct device_attribute *attr,
106511 + char *buf)
106512 +{
106513 + unsigned long flags;
106514 + unsigned n = 0;
106515 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106516 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
106517 +#endif
106518 +
106519 + if (attr == NULL || buf == NULL || dev == NULL)
106520 + return -EINVAL;
106521 +
106522 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106523 +
106524 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
106525 + if (WARN_ON(p_wrp_fm_dev == NULL))
106526 + return -EINVAL;
106527 +
106528 + local_irq_save(flags);
106529 +
106530 + n = snprintf(buf, PAGE_SIZE, "FM-KG registers dump.\n");
106531 +
106532 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_PcdDev)
106533 + return -EIO;
106534 + else
106535 + n = fm_kg_dump_regs(p_wrp_fm_dev->h_PcdDev, buf, n);
106536 +
106537 + local_irq_restore(flags);
106538 +#else
106539 +
106540 + local_irq_save(flags);
106541 + n = snprintf(buf, PAGE_SIZE,
106542 + "Debug level is too low to dump registers!!!\n");
106543 + local_irq_restore(flags);
106544 +#endif /* (defined(DEBUG_ERRORS) && ... */
106545 +
106546 + return n;
106547 +}
106548 +
106549 +
106550 +static ssize_t show_fm_fpm_regs(struct device *dev,
106551 + struct device_attribute *attr,
106552 + char *buf)
106553 +{
106554 + unsigned long flags;
106555 + unsigned n = 0;
106556 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106557 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
106558 +#endif
106559 +
106560 + if (attr == NULL || buf == NULL || dev == NULL)
106561 + return -EINVAL;
106562 +
106563 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106564 +
106565 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
106566 + if (WARN_ON(p_wrp_fm_dev == NULL))
106567 + return -EINVAL;
106568 +
106569 + local_irq_save(flags);
106570 +
106571 + n = snprintf(buf, PAGE_SIZE, "FM-FPM registers dump.\n");
106572 +
106573 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_Dev)
106574 + return -EIO;
106575 + else
106576 + n = fm_fpm_dump_regs(p_wrp_fm_dev->h_Dev, buf, n);
106577 +
106578 + local_irq_restore(flags);
106579 +#else
106580 +
106581 + local_irq_save(flags);
106582 + n = snprintf(buf, PAGE_SIZE,
106583 + "Debug level is too low to dump registers!!!\n");
106584 + local_irq_restore(flags);
106585 +#endif /* (defined(DEBUG_ERRORS) && ... */
106586 +
106587 + return n;
106588 +}
106589 +
106590 +static ssize_t show_prs_regs(struct device *dev,
106591 + struct device_attribute *attr, char *buf)
106592 +{
106593 + unsigned long flags;
106594 + unsigned n = 0;
106595 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106596 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
106597 +#endif
106598 +
106599 + if (attr == NULL || buf == NULL || dev == NULL)
106600 + return -EINVAL;
106601 +
106602 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106603 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
106604 + if (WARN_ON(p_wrp_fm_dev == NULL))
106605 + return -EINVAL;
106606 +
106607 + local_irq_save(flags);
106608 + n = snprintf(buf, PAGE_SIZE, "FM Policer registers dump.\n");
106609 +
106610 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_PcdDev)
106611 + return -EIO;
106612 + else
106613 + n = fm_prs_dump_regs(p_wrp_fm_dev->h_PcdDev, buf, n);
106614 +
106615 + local_irq_restore(flags);
106616 +#else
106617 +
106618 + local_irq_save(flags);
106619 + n = snprintf(buf, PAGE_SIZE,
106620 + "Debug level is too low to dump registers!!!\n");
106621 + local_irq_restore(flags);
106622 +
106623 +#endif /* (defined(DEBUG_ERRORS) && ... */
106624 +
106625 + return n;
106626 +}
106627 +
106628 +static ssize_t show_plcr_regs(struct device *dev,
106629 + struct device_attribute *attr,
106630 + char *buf)
106631 +{
106632 + unsigned long flags;
106633 + unsigned n = 0;
106634 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106635 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
106636 +#endif
106637 +
106638 + if (attr == NULL || buf == NULL || dev == NULL)
106639 + return -EINVAL;
106640 +
106641 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
106642 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
106643 + if (WARN_ON(p_wrp_fm_dev == NULL))
106644 + return -EINVAL;
106645 +
106646 + local_irq_save(flags);
106647 + n = snprintf(buf, PAGE_SIZE, "FM Policer registers dump.\n");
106648 +
106649 + if (!p_wrp_fm_dev->active || !p_wrp_fm_dev->h_PcdDev)
106650 + return -EIO;
106651 + else
106652 + n = fm_plcr_dump_regs(p_wrp_fm_dev->h_PcdDev, buf, n);
106653 +
106654 + local_irq_restore(flags);
106655 +#else
106656 +
106657 + local_irq_save(flags);
106658 + n = snprintf(buf, PAGE_SIZE,
106659 + "Debug level is too low to dump registers!!!\n");
106660 + local_irq_restore(flags);
106661 +
106662 +#endif /* (defined(DEBUG_ERRORS) && ... */
106663 +
106664 + return n;
106665 +}
106666 +
106667 +static DEVICE_ATTR(fm_regs, S_IRUGO, show_fm_regs, NULL);
106668 +static DEVICE_ATTR(fm_fpm_regs, S_IRUGO, show_fm_fpm_regs, NULL);
106669 +static DEVICE_ATTR(fm_kg_regs, S_IRUGO, show_fm_kg_regs, NULL);
106670 +static DEVICE_ATTR(fm_kg_pe_regs, S_IRUGO, show_fm_kg_pe_regs, NULL);
106671 +static DEVICE_ATTR(fm_plcr_regs, S_IRUGO, show_plcr_regs, NULL);
106672 +static DEVICE_ATTR(fm_prs_regs, S_IRUGO, show_prs_regs, NULL);
106673 +static DEVICE_ATTR(fm_muram_free_size, S_IRUGO, show_fm_muram_free_sz, NULL);
106674 +static DEVICE_ATTR(fm_ctrl_code_ver, S_IRUGO, show_fm_ctrl_code_ver, NULL);
106675 +
106676 +int fm_sysfs_create(struct device *dev)
106677 +{
106678 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
106679 +
106680 + if (dev == NULL)
106681 + return -EIO;
106682 +
106683 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
106684 +
106685 + /* store to remove them when module is disabled */
106686 + p_wrp_fm_dev->dev_attr_regs = &dev_attr_fm_regs;
106687 + p_wrp_fm_dev->dev_attr_risc_load = &dev_attr_fm_risc_load_val;
106688 + p_wrp_fm_dev->dev_fm_fpm_attr_regs = &dev_attr_fm_fpm_regs;
106689 + p_wrp_fm_dev->dev_fm_kg_attr_regs = &dev_attr_fm_kg_regs;
106690 + p_wrp_fm_dev->dev_fm_kg_pe_attr_regs = &dev_attr_fm_kg_pe_regs;
106691 + p_wrp_fm_dev->dev_plcr_attr_regs = &dev_attr_fm_plcr_regs;
106692 + p_wrp_fm_dev->dev_prs_attr_regs = &dev_attr_fm_prs_regs;
106693 + p_wrp_fm_dev->dev_attr_muram_free_size = &dev_attr_fm_muram_free_size;
106694 + p_wrp_fm_dev->dev_attr_fm_ctrl_code_ver = &dev_attr_fm_ctrl_code_ver;
106695 +
106696 + /* Create sysfs statistics group for FM module */
106697 + if (sysfs_create_group(&dev->kobj, &fm_dev_stats_attr_grp) != 0)
106698 + return -EIO;
106699 +
106700 + if (sysfs_create_group(&dev->kobj, &fm_dev_schemes_attr_grp) != 0)
106701 + return -EIO;
106702 +
106703 + if (sysfs_create_group(&dev->kobj, &fm_dev_profiles_attr_grp) != 0)
106704 + return -EIO;
106705 +
106706 + if (sysfs_create_group(&dev->kobj, &fm_dev_tnums_dbg_attr_grp) != 0)
106707 + return -EIO;
106708 +
106709 + if (sysfs_create_group(&dev->kobj, &fm_dev_cls_plans_attr_grp) != 0)
106710 + return -EIO;
106711 +
106712 + /* Registers dump entry - in future will be moved to debugfs */
106713 + if (device_create_file(dev, &dev_attr_fm_regs) != 0)
106714 + return -EIO;
106715 +
106716 + if (device_create_file(dev, &dev_attr_fm_risc_load_val) != 0)
106717 + return -EIO;
106718 +
106719 + if (device_create_file(dev, &dev_attr_fm_fpm_regs) != 0)
106720 + return -EIO;
106721 +
106722 + if (device_create_file(dev, &dev_attr_fm_kg_regs) != 0)
106723 + return -EIO;
106724 +
106725 + if (device_create_file(dev, &dev_attr_fm_kg_pe_regs) != 0)
106726 + return -EIO;
106727 +
106728 + if (device_create_file(dev, &dev_attr_fm_plcr_regs) != 0)
106729 + return -EIO;
106730 +
106731 + if (device_create_file(dev, &dev_attr_fm_prs_regs) != 0)
106732 + return -EIO;
106733 +
106734 + /* muram free size */
106735 + if (device_create_file(dev, &dev_attr_fm_muram_free_size) != 0)
106736 + return -EIO;
106737 +
106738 + /* fm ctrl code version */
106739 + if (device_create_file(dev, &dev_attr_fm_ctrl_code_ver) != 0)
106740 + return -EIO;
106741 +
106742 + return 0;
106743 +}
106744 +
106745 +void fm_sysfs_destroy(struct device *dev)
106746 +{
106747 + t_LnxWrpFmDev *p_wrp_fm_dev = NULL;
106748 +
106749 + if (WARN_ON(dev == NULL))
106750 + return;
106751 +
106752 + p_wrp_fm_dev = (t_LnxWrpFmDev *) dev_get_drvdata(dev);
106753 + if (WARN_ON(p_wrp_fm_dev == NULL))
106754 + return;
106755 +
106756 + sysfs_remove_group(&dev->kobj, &fm_dev_stats_attr_grp);
106757 + sysfs_remove_group(&dev->kobj, &fm_dev_schemes_attr_grp);
106758 + sysfs_remove_group(&dev->kobj, &fm_dev_profiles_attr_grp);
106759 + sysfs_remove_group(&dev->kobj, &fm_dev_cls_plans_attr_grp);
106760 + sysfs_remove_group(&dev->kobj, &fm_dev_tnums_dbg_attr_grp);
106761 + device_remove_file(dev, p_wrp_fm_dev->dev_attr_regs);
106762 + device_remove_file(dev, p_wrp_fm_dev->dev_fm_fpm_attr_regs);
106763 + device_remove_file(dev, p_wrp_fm_dev->dev_fm_kg_attr_regs);
106764 + device_remove_file(dev, p_wrp_fm_dev->dev_fm_kg_pe_attr_regs);
106765 + device_remove_file(dev, p_wrp_fm_dev->dev_plcr_attr_regs);
106766 + device_remove_file(dev, p_wrp_fm_dev->dev_prs_attr_regs);
106767 + device_remove_file(dev, p_wrp_fm_dev->dev_attr_muram_free_size);
106768 + device_remove_file(dev, p_wrp_fm_dev->dev_attr_fm_ctrl_code_ver);
106769 +}
106770 +
106771 +int fm_dump_regs(void *h_fm, char *buf, int nn)
106772 +{
106773 + t_Fm *p_Fm = (t_Fm *)h_fm;
106774 + uint8_t i = 0;
106775 + int n = nn;
106776 +
106777 + FM_DMP_SUBTITLE(buf, n, "\n");
106778 +
106779 + FM_DMP_TITLE(buf, n, p_Fm->p_FmDmaRegs, "FM-DMA Regs");
106780 +
106781 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmsr);
106782 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmemsr);
106783 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmmr);
106784 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmtr);
106785 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmhy);
106786 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmsetr);
106787 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmtah);
106788 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmtal);
106789 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmtcid);
106790 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmra);
106791 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmrd);
106792 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmwcr);
106793 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmebcr);
106794 + FM_DMP_V32(buf, n, p_Fm->p_FmDmaRegs, fmdmdcr);
106795 +
106796 + FM_DMP_TITLE(buf, n, &p_Fm->p_FmDmaRegs->fmdmplr, "fmdmplr");
106797 +
106798 + for (i = 0; i < FM_MAX_NUM_OF_HW_PORT_IDS / 2 ; ++i)
106799 + FM_DMP_MEM_32(buf, n, &p_Fm->p_FmDmaRegs->fmdmplr[i]);
106800 +
106801 + FM_DMP_TITLE(buf, n, p_Fm->p_FmBmiRegs, "FM-BMI COMMON Regs");
106802 + FM_DMP_V32(buf, n, p_Fm->p_FmBmiRegs, fmbm_init);
106803 + FM_DMP_V32(buf, n, p_Fm->p_FmBmiRegs, fmbm_cfg1);
106804 + FM_DMP_V32(buf, n, p_Fm->p_FmBmiRegs, fmbm_cfg2);
106805 + FM_DMP_V32(buf, n, p_Fm->p_FmBmiRegs, fmbm_ievr);
106806 + FM_DMP_V32(buf, n, p_Fm->p_FmBmiRegs, fmbm_ier);
106807 +
106808 + FM_DMP_TITLE(buf, n, &p_Fm->p_FmBmiRegs->fmbm_arb, "fmbm_arb");
106809 + for (i = 0; i < 8 ; ++i)
106810 + FM_DMP_MEM_32(buf, n, &p_Fm->p_FmBmiRegs->fmbm_arb[i]);
106811 +
106812 + FM_DMP_TITLE(buf, n, p_Fm->p_FmQmiRegs, "FM-QMI COMMON Regs");
106813 + FM_DMP_V32(buf, n, p_Fm->p_FmQmiRegs, fmqm_gc);
106814 + FM_DMP_V32(buf, n, p_Fm->p_FmQmiRegs, fmqm_eie);
106815 + FM_DMP_V32(buf, n, p_Fm->p_FmQmiRegs, fmqm_eien);
106816 + FM_DMP_V32(buf, n, p_Fm->p_FmQmiRegs, fmqm_eif);
106817 + FM_DMP_V32(buf, n, p_Fm->p_FmQmiRegs, fmqm_ie);
106818 + FM_DMP_V32(buf, n, p_Fm->p_FmQmiRegs, fmqm_ien);
106819 + FM_DMP_V32(buf, n, p_Fm->p_FmQmiRegs, fmqm_if);
106820 + FM_DMP_V32(buf, n, p_Fm->p_FmQmiRegs, fmqm_gs);
106821 + FM_DMP_V32(buf, n, p_Fm->p_FmQmiRegs, fmqm_etfc);
106822 +
106823 + return n;
106824 +}
106825 +
106826 +int fm_dump_tnum_dbg(void *h_fm, int tn_s, int tn_e, char *buf, int nn)
106827 +{
106828 + t_Fm *p_Fm = (t_Fm *)h_fm;
106829 + uint8_t i, j = 0;
106830 + int n = nn;
106831 +
106832 + FM_DMP_TITLE(buf, n, NULL, "Tnums and Tnum dbg regs %d - %d",
106833 + tn_s, tn_e);
106834 +
106835 + iowrite32be(tn_s << 24, &p_Fm->p_FmFpmRegs->fmfp_dra);
106836 +
106837 + mb();
106838 +
106839 + for (j = tn_s; j <= tn_e; j++) {
106840 + FM_DMP_LN(buf, n, "> fmfp_ts[%d]\n", j);
106841 + FM_DMP_MEM_32(buf, n, &p_Fm->p_FmFpmRegs->fmfp_ts[j]);
106842 + FM_DMP_V32(buf, n, p_Fm->p_FmFpmRegs, fmfp_dra);
106843 + FM_DMP_LN(buf, n, "> fmfp_drd[0-3]\n");
106844 +
106845 + for (i = 0; i < 4 ; ++i)
106846 + FM_DMP_MEM_32(buf, n, &p_Fm->p_FmFpmRegs->fmfp_drd[i]);
106847 +
106848 + FM_DMP_LN(buf, n, "\n");
106849 +
106850 + }
106851 +
106852 + return n;
106853 +}
106854 +
106855 +int fm_dump_cls_plan(void *h_fm_pcd, int cpn, char *buf, int nn)
106856 +{
106857 + t_FmPcd *p_pcd = (t_FmPcd *)h_fm_pcd;
106858 + int i = 0;
106859 + uint32_t tmp;
106860 + unsigned long i_flg;
106861 + int n = nn;
106862 + u_FmPcdKgIndirectAccessRegs *idac;
106863 + spinlock_t *p_lk;
106864 +
106865 + p_lk = (spinlock_t *)p_pcd->p_FmPcdKg->h_HwSpinlock;
106866 + idac = p_pcd->p_FmPcdKg->p_IndirectAccessRegs;
106867 +
106868 + spin_lock_irqsave(p_lk, i_flg);
106869 +
106870 + /* Read ClsPlan Block Action Regs */
106871 + tmp = (uint32_t)(FM_KG_KGAR_GO |
106872 + FM_KG_KGAR_READ |
106873 + FM_PCD_KG_KGAR_SEL_CLS_PLAN_ENTRY |
106874 + DUMMY_PORT_ID |
106875 + ((uint32_t)cpn << FM_PCD_KG_KGAR_NUM_SHIFT) |
106876 + FM_PCD_KG_KGAR_WSEL_MASK);
106877 +
106878 + if (fman_kg_write_ar_wait(p_pcd->p_FmPcdKg->p_FmPcdKgRegs, tmp)) {
106879 + FM_DMP_LN(buf, nn, "Keygen scheme access violation");
106880 + spin_unlock_irqrestore(p_lk, i_flg);
106881 + return nn;
106882 + }
106883 + FM_DMP_TITLE(buf, n, &idac->clsPlanRegs,
106884 + "ClsPlan %d Indirect Access Regs", cpn);
106885 +
106886 + for (i = 0; i < 8; i++)
106887 + FM_DMP_MEM_32(buf, n, &idac->clsPlanRegs.kgcpe[i]);
106888 +
106889 + spin_unlock_irqrestore(p_lk, i_flg);
106890 +
106891 + return n;
106892 +}
106893 +
106894 +int fm_profile_dump_regs(void *h_fm_pcd, int ppn, char *buf, int nn)
106895 +{
106896 + t_FmPcd *p_pcd = (t_FmPcd *)h_fm_pcd;
106897 + t_FmPcdPlcrProfileRegs *p_prof_regs;
106898 + t_FmPcdPlcrRegs *p_plcr_regs;
106899 + t_FmPcdPlcr *p_plcr;
106900 + uint32_t tmp;
106901 + unsigned long i_flg;
106902 + int n = nn;
106903 + int toc = 10;
106904 + spinlock_t *p_lk;
106905 +
106906 + p_plcr = p_pcd->p_FmPcdPlcr;
106907 + p_prof_regs = &p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->profileRegs;
106908 + p_plcr_regs = p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
106909 +
106910 + p_lk = (spinlock_t *)((t_FmPcdPlcr *)p_plcr)->h_HwSpinlock;
106911 +
106912 + FM_DMP_SUBTITLE(buf, n, "\n");
106913 + FM_DMP_TITLE(buf, n, p_plcr_regs, "FM-PCD policer-profile regs");
106914 +
106915 + tmp = (uint32_t)(FM_PCD_PLCR_PAR_GO |
106916 + FM_PCD_PLCR_PAR_R |
106917 + ((uint32_t)ppn << FM_PCD_PLCR_PAR_PNUM_SHIFT) |
106918 + FM_PCD_PLCR_PAR_PWSEL_MASK);
106919 +
106920 + spin_lock_irqsave(p_lk, i_flg);
106921 +
106922 + iowrite32be(tmp, &p_plcr_regs->fmpl_par);
106923 +
106924 + mb();
106925 +
106926 + /* wait for the porfile regs to be present */
106927 + do {
106928 + --toc;
106929 + udelay(10);
106930 + if (!toc) {
106931 + /* looks like PLCR_PAR_GO refuses to clear */
106932 + spin_unlock_irqrestore(p_lk, i_flg);
106933 + FM_DMP_LN(buf, n, "Profile regs not accessible -");
106934 + FM_DMP_LN(buf, n, " check profile init process\n");
106935 + return n;
106936 + }
106937 + } while ((ioread32be(&p_plcr_regs->fmpl_par) & FM_PCD_PLCR_PAR_GO));
106938 +
106939 + FM_DMP_TITLE(buf, n, p_prof_regs, "Profile %d regs", ppn);
106940 +
106941 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_pemode);
106942 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_pegnia);
106943 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_peynia);
106944 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_pernia);
106945 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_pecir);
106946 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_pecbs);
106947 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_pepepir_eir);
106948 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_pepbs_ebs);
106949 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_pelts);
106950 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_pects);
106951 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_pepts_ets);
106952 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_pegpc);
106953 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_peypc);
106954 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_perpc);
106955 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_perypc);
106956 + FM_DMP_V32(buf, n, p_prof_regs, fmpl_perrpc);
106957 +
106958 + spin_unlock_irqrestore(p_lk, i_flg);
106959 +
106960 + return n;
106961 +}
106962 +
106963 +int fm_dump_scheme(void *h_fm_pcd, int scnum, char *buf, int nn)
106964 +{
106965 + t_FmPcd *p_pcd = (t_FmPcd *)h_fm_pcd;
106966 + uint32_t tmp_ar;
106967 + unsigned long i_flg;
106968 + int i, n = nn;
106969 + spinlock_t *p_lk;
106970 + u_FmPcdKgIndirectAccessRegs *idac;
106971 +
106972 + idac = p_pcd->p_FmPcdKg->p_IndirectAccessRegs;
106973 + p_lk = (spinlock_t *)p_pcd->p_FmPcdKg->h_HwSpinlock;
106974 +
106975 + spin_lock_irqsave(p_lk, i_flg);
106976 +
106977 + tmp_ar = FmPcdKgBuildReadSchemeActionReg((uint8_t)scnum);
106978 + if (fman_kg_write_ar_wait(p_pcd->p_FmPcdKg->p_FmPcdKgRegs, tmp_ar)) {
106979 + FM_DMP_LN(buf, nn,
106980 + "Keygen scheme access violation or no such scheme");
106981 + spin_unlock_irqrestore(p_lk, i_flg);
106982 + return nn;
106983 + }
106984 +
106985 + FM_DMP_TITLE(buf, n, &idac->schemeRegs,
106986 + "Scheme %d Indirect Access Regs", scnum);
106987 +
106988 + FM_DMP_V32(buf, n, &idac->schemeRegs, kgse_mode);
106989 + FM_DMP_V32(buf, n, &idac->schemeRegs, kgse_ekfc);
106990 + FM_DMP_V32(buf, n, &idac->schemeRegs, kgse_ekdv);
106991 + FM_DMP_V32(buf, n, &idac->schemeRegs, kgse_bmch);
106992 + FM_DMP_V32(buf, n, &idac->schemeRegs, kgse_bmcl);
106993 + FM_DMP_V32(buf, n, &idac->schemeRegs, kgse_fqb);
106994 + FM_DMP_V32(buf, n, &idac->schemeRegs, kgse_hc);
106995 + FM_DMP_V32(buf, n, &idac->schemeRegs, kgse_ppc);
106996 +
106997 + FM_DMP_TITLE(buf, n, &idac->schemeRegs.kgse_gec, "kgse_gec");
106998 +
106999 + for (i = 0; i < FM_KG_NUM_OF_GENERIC_REGS; i++)
107000 + FM_DMP_MEM_32(buf, n, &idac->schemeRegs.kgse_gec[i]);
107001 +
107002 + FM_DMP_V32(buf, n, &idac->schemeRegs, kgse_spc);
107003 + FM_DMP_V32(buf, n, &idac->schemeRegs, kgse_dv0);
107004 + FM_DMP_V32(buf, n, &idac->schemeRegs, kgse_dv1);
107005 + FM_DMP_V32(buf, n, &idac->schemeRegs, kgse_ccbs);
107006 + FM_DMP_V32(buf, n, &idac->schemeRegs, kgse_mv);
107007 +
107008 + FM_DMP_SUBTITLE(buf, n, "\n");
107009 +
107010 + spin_unlock_irqrestore(p_lk, i_flg);
107011 +
107012 + return n;
107013 +}
107014 +
107015 +int fm_kg_pe_dump_regs(void *h_fm_pcd, char *buf, int nn)
107016 +{
107017 + t_FmPcd *p_pcd = (t_FmPcd *)h_fm_pcd;
107018 + int i = 0;
107019 + uint8_t prt_id = 0;
107020 + uint32_t tmp_ar;
107021 + unsigned long i_flg;
107022 + int n = nn;
107023 + u_FmPcdKgIndirectAccessRegs *idac;
107024 + t_FmPcdKg *p_kg;
107025 + spinlock_t *p_lk;
107026 +
107027 + p_kg = p_pcd->p_FmPcdKg;
107028 + idac = p_pcd->p_FmPcdKg->p_IndirectAccessRegs;
107029 + p_lk = (spinlock_t *)p_kg->h_HwSpinlock;
107030 +
107031 + spin_lock_irqsave(p_lk, i_flg);
107032 +
107033 + FM_DMP_SUBTITLE(buf, n, "\n");
107034 +
107035 + for (i = 0; i < FM_MAX_NUM_OF_PORTS; i++) {
107036 + SW_PORT_INDX_TO_HW_PORT_ID(prt_id, i);
107037 +
107038 + tmp_ar = FmPcdKgBuildReadPortSchemeBindActionReg(prt_id);
107039 +
107040 + if (fman_kg_write_ar_wait(p_kg->p_FmPcdKgRegs, tmp_ar)) {
107041 + FM_DMP_LN(buf, nn, "Keygen scheme access violation");
107042 + spin_unlock_irqrestore(p_lk, i_flg);
107043 + return nn;
107044 + }
107045 + FM_DMP_TITLE(buf, n, &idac->portRegs, "Port %d regs", prt_id);
107046 + FM_DMP_V32(buf, n, &idac->portRegs, fmkg_pe_sp);
107047 + FM_DMP_V32(buf, n, &idac->portRegs, fmkg_pe_cpp);
107048 + }
107049 +
107050 + FM_DMP_SUBTITLE(buf, n, "\n");
107051 +
107052 + spin_unlock_irqrestore(p_lk, i_flg);
107053 +
107054 + return n;
107055 +}
107056 +
107057 +int fm_kg_dump_regs(void *h_fm_pcd, char *buf, int nn)
107058 +{
107059 + t_FmPcd *p_pcd = (t_FmPcd *)h_fm_pcd;
107060 + int n = nn;
107061 +
107062 + FM_DMP_SUBTITLE(buf, n, "\n");
107063 + FM_DMP_TITLE(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs,
107064 + "FmPcdKgRegs Regs");
107065 +
107066 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs, fmkg_gcr);
107067 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs, fmkg_eer);
107068 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs, fmkg_eeer);
107069 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs, fmkg_seer);
107070 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs, fmkg_seeer);
107071 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs, fmkg_gsr);
107072 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs, fmkg_tpc);
107073 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs, fmkg_serc);
107074 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs, fmkg_fdor);
107075 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs, fmkg_gdv0r);
107076 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs, fmkg_gdv1r);
107077 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs, fmkg_feer);
107078 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdKg->p_FmPcdKgRegs, fmkg_ar);
107079 +
107080 + FM_DMP_SUBTITLE(buf, n, "\n");
107081 +
107082 + return n;
107083 +}
107084 +
107085 +
107086 +int fm_fpm_dump_regs(void *h_fm, char *buf, int nn)
107087 +{
107088 + t_Fm *p_fm = (t_Fm *)h_fm;
107089 + uint8_t i;
107090 + int n = nn;
107091 +
107092 + FM_DMP_SUBTITLE(buf, n, "\n");
107093 +
107094 + FM_DMP_TITLE(buf, n, p_fm->p_FmFpmRegs, "FM-FPM Regs");
107095 +
107096 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_tnc);
107097 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_prc);
107098 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_brkc);
107099 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_mxd);
107100 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_dist1);
107101 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_dist2);
107102 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fm_epi);
107103 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fm_rie);
107104 +
107105 + FM_DMP_TITLE(buf, n, &p_fm->p_FmFpmRegs->fmfp_fcev, "fmfp_fcev");
107106 + for (i = 0; i < 4; ++i)
107107 + FM_DMP_MEM_32(buf, n, &p_fm->p_FmFpmRegs->fmfp_fcev[i]);
107108 +
107109 + FM_DMP_TITLE(buf, n, &p_fm->p_FmFpmRegs->fmfp_cee, "fmfp_cee");
107110 + for (i = 0; i < 4; ++i)
107111 + FM_DMP_MEM_32(buf, n, &p_fm->p_FmFpmRegs->fmfp_cee[i]);
107112 +
107113 + FM_DMP_SUBTITLE(buf, n, "\n");
107114 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_tsc1);
107115 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_tsc2);
107116 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_tsp);
107117 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_tsf);
107118 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fm_rcr);
107119 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_extc);
107120 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_ext1);
107121 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_ext2);
107122 +
107123 + FM_DMP_SUBTITLE(buf, n, "\n");
107124 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fm_ip_rev_1);
107125 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fm_ip_rev_2);
107126 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fm_rstc);
107127 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fm_cld);
107128 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fm_npi);
107129 + FM_DMP_V32(buf, n, p_fm->p_FmFpmRegs, fmfp_ee);
107130 +
107131 + FM_DMP_TITLE(buf, n, &p_fm->p_FmFpmRegs->fmfp_cev, "fmfp_cev");
107132 + for (i = 0; i < 4; ++i)
107133 + FM_DMP_MEM_32(buf, n, &p_fm->p_FmFpmRegs->fmfp_cev[i]);
107134 +
107135 + FM_DMP_TITLE(buf, n, &p_fm->p_FmFpmRegs->fmfp_ps, "fmfp_ps");
107136 + for (i = 0; i < 64; ++i)
107137 + FM_DMP_MEM_32(buf, n, &p_fm->p_FmFpmRegs->fmfp_ps[i]);
107138 +
107139 + return n;
107140 +}
107141 +
107142 +int fm_prs_dump_regs(void *h_fm_pcd, char *buf, int nn)
107143 +{
107144 + t_FmPcd *p_pcd = (t_FmPcd *)h_fm_pcd;
107145 + int n = nn;
107146 +
107147 + FM_DMP_SUBTITLE(buf, n, "\n");
107148 +
107149 + FM_DMP_TITLE(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs,
107150 + "FM-PCD parser regs");
107151 +
107152 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_rpclim);
107153 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_rpimac);
107154 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, pmeec);
107155 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_pevr);
107156 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_pever);
107157 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_perr);
107158 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_perer);
107159 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_ppsc);
107160 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_pds);
107161 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_l2rrs);
107162 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_l3rrs);
107163 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_l4rrs);
107164 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_srrs);
107165 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_l2rres);
107166 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_l3rres);
107167 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_l4rres);
107168 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_srres);
107169 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_spcs);
107170 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_spscs);
107171 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_hxscs);
107172 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_mrcs);
107173 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_mwcs);
107174 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_mrscs);
107175 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_mwscs);
107176 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPrs->p_FmPcdPrsRegs, fmpr_fcscs);
107177 +
107178 + return n;
107179 +}
107180 +
107181 +int fm_plcr_dump_regs(void *h_fm_pcd, char *buf, int nn)
107182 +{
107183 + t_FmPcd *p_pcd = (t_FmPcd *)h_fm_pcd;
107184 + int i = 0;
107185 + int n = nn;
107186 +
107187 + FM_DMP_SUBTITLE(buf, n, "\n");
107188 +
107189 + FM_DMP_TITLE(buf, n,
107190 + p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,
107191 + "FM policer regs");
107192 +
107193 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_gcr);
107194 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_gsr);
107195 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_evr);
107196 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_ier);
107197 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_ifr);
107198 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_eevr);
107199 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_eier);
107200 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_eifr);
107201 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_rpcnt);
107202 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_ypcnt);
107203 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_rrpcnt);
107204 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_rypcnt);
107205 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_tpcnt);
107206 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_flmcnt);
107207 +
107208 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_serc);
107209 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_upcr);
107210 + FM_DMP_V32(buf, n, p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, fmpl_dpmr);
107211 +
107212 + FM_DMP_TITLE(buf, n,
107213 + &p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_pmr,
107214 + "fmpl_pmr");
107215 +
107216 + for (i = 0; i < 63; ++i)
107217 + FM_DMP_MEM_32(buf, n,
107218 + &p_pcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_pmr[i]);
107219 +
107220 + return n;
107221 +}
107222 +
107223 +int fm_get_counter(void *h_fm, e_FmCounters cnt_e, uint32_t *cnt_val)
107224 +{
107225 + t_Fm *p_fm = (t_Fm *)h_fm;
107226 +
107227 + /* When applicable (when there is an "enable counters" bit),
107228 + check that counters are enabled */
107229 +
107230 + switch (cnt_e) {
107231 + case (e_FM_COUNTERS_DEQ_1):
107232 + case (e_FM_COUNTERS_DEQ_2):
107233 + case (e_FM_COUNTERS_DEQ_3):
107234 + if (p_fm->p_FmStateStruct->revInfo.majorRev >= 6)
107235 + return -EINVAL; /* counter not available */
107236 +
107237 + case (e_FM_COUNTERS_ENQ_TOTAL_FRAME):
107238 + case (e_FM_COUNTERS_DEQ_TOTAL_FRAME):
107239 + case (e_FM_COUNTERS_DEQ_0):
107240 + case (e_FM_COUNTERS_DEQ_FROM_DEFAULT):
107241 + case (e_FM_COUNTERS_DEQ_FROM_CONTEXT):
107242 + case (e_FM_COUNTERS_DEQ_FROM_FD):
107243 + case (e_FM_COUNTERS_DEQ_CONFIRM):
107244 + if (!(ioread32be(&p_fm->p_FmQmiRegs->fmqm_gc) &
107245 + QMI_CFG_EN_COUNTERS))
107246 + return -EINVAL; /* Requested counter not available */
107247 + break;
107248 + default:
107249 + break;
107250 + }
107251 +
107252 + switch (cnt_e) {
107253 + case (e_FM_COUNTERS_ENQ_TOTAL_FRAME):
107254 + *cnt_val = ioread32be(&p_fm->p_FmQmiRegs->fmqm_etfc);
107255 + return 0;
107256 + case (e_FM_COUNTERS_DEQ_TOTAL_FRAME):
107257 + *cnt_val = ioread32be(&p_fm->p_FmQmiRegs->fmqm_dtfc);
107258 + return 0;
107259 + case (e_FM_COUNTERS_DEQ_0):
107260 + *cnt_val = ioread32be(&p_fm->p_FmQmiRegs->fmqm_dc0);
107261 + return 0;
107262 + case (e_FM_COUNTERS_DEQ_1):
107263 + *cnt_val = ioread32be(&p_fm->p_FmQmiRegs->fmqm_dc1);
107264 + return 0;
107265 + case (e_FM_COUNTERS_DEQ_2):
107266 + *cnt_val = ioread32be(&p_fm->p_FmQmiRegs->fmqm_dc2);
107267 + return 0;
107268 + case (e_FM_COUNTERS_DEQ_3):
107269 + *cnt_val = ioread32be(&p_fm->p_FmQmiRegs->fmqm_dc3);
107270 + return 0;
107271 + case (e_FM_COUNTERS_DEQ_FROM_DEFAULT):
107272 + *cnt_val = ioread32be(&p_fm->p_FmQmiRegs->fmqm_dfdc);
107273 + return 0;
107274 + case (e_FM_COUNTERS_DEQ_FROM_CONTEXT):
107275 + *cnt_val = ioread32be(&p_fm->p_FmQmiRegs->fmqm_dfcc);
107276 + return 0;
107277 + case (e_FM_COUNTERS_DEQ_FROM_FD):
107278 + *cnt_val = ioread32be(&p_fm->p_FmQmiRegs->fmqm_dffc);
107279 + return 0;
107280 + case (e_FM_COUNTERS_DEQ_CONFIRM):
107281 + *cnt_val = ioread32be(&p_fm->p_FmQmiRegs->fmqm_dcc);
107282 + return 0;
107283 + }
107284 + /* should never get here */
107285 + return -EINVAL; /* counter not available */
107286 +}
107287 --- /dev/null
107288 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm.h
107289 @@ -0,0 +1,136 @@
107290 +/*
107291 + * Copyright 2008-2012 Freescale Semiconductor Inc.
107292 + *
107293 + * Redistribution and use in source and binary forms, with or without
107294 + * modification, are permitted provided that the following conditions are met:
107295 + * * Redistributions of source code must retain the above copyright
107296 + * notice, this list of conditions and the following disclaimer.
107297 + * * Redistributions in binary form must reproduce the above copyright
107298 + * notice, this list of conditions and the following disclaimer in the
107299 + * documentation and/or other materials provided with the distribution.
107300 + * * Neither the name of Freescale Semiconductor nor the
107301 + * names of its contributors may be used to endorse or promote products
107302 + * derived from this software without specific prior written permission.
107303 + *
107304 + *
107305 + * ALTERNATIVELY, this software may be distributed under the terms of the
107306 + * GNU General Public License ("GPL") as published by the Free Software
107307 + * Foundation, either version 2 of that License or (at your option) any
107308 + * later version.
107309 + *
107310 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
107311 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
107312 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
107313 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
107314 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
107315 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
107316 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
107317 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
107318 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
107319 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
107320 + */
107321 +
107322 +
107323 +#ifndef LNXWRP_SYSFS_FM_H_
107324 +#define LNXWRP_SYSFS_FM_H_
107325 +
107326 +#include "lnxwrp_sysfs.h"
107327 +
107328 +int fm_sysfs_create(struct device *dev);
107329 +void fm_sysfs_destroy(struct device *dev);
107330 +int fm_dump_regs(void *h_dev, char *buf, int nn);
107331 +int fm_fpm_dump_regs(void *h_dev, char *buf, int nn);
107332 +int fm_kg_dump_regs(void *h_pcd, char *buf, int nn);
107333 +int fm_kg_pe_dump_regs(void *h_pcd, char *buf, int nn);
107334 +int fm_dump_scheme(void *h_pcd, int scnum, char *buf, int nn);
107335 +int fm_dump_tnum_dbg(void *h_fm, int tn_s, int tn_e, char *buf, int nn);
107336 +int fm_dump_cls_plan(void *h_pcd, int cpn, char *buf, int nn);
107337 +int fm_plcr_dump_regs(void *h_pcd, char *buf, int nn);
107338 +int fm_prs_dump_regs(void *h_pcd, char *buf, int nn);
107339 +int fm_profile_dump_regs(void *h_pcd, int ppnum, char *buf, int nn);
107340 +
107341 +#define FM_DMP_PGSZ_ERR { \
107342 + snprintf(&buf[PAGE_SIZE - 80], 70, \
107343 + "\n Err: current sysfs buffer reached PAGE_SIZE\n");\
107344 + n = PAGE_SIZE - 2; \
107345 + }
107346 +
107347 +#define FM_DMP_LN(buf, n, ...) \
107348 + do { \
107349 + int k, m = n; \
107350 + m += k = snprintf(&buf[m], PAGE_SIZE - m, __VA_ARGS__); \
107351 + if (k < 0 || m > PAGE_SIZE - 90) \
107352 + FM_DMP_PGSZ_ERR \
107353 + n = m; \
107354 + } while (0)
107355 +
107356 +#define FM_DMP_TITLE(buf, n, addr, ...) \
107357 + do { \
107358 + int k, m = n; \
107359 + m += k = snprintf(&buf[m], PAGE_SIZE - m, "\n"); \
107360 + if (k < 0 || m > PAGE_SIZE - 90) \
107361 + FM_DMP_PGSZ_ERR \
107362 + m += k = snprintf(&buf[m], PAGE_SIZE - m, __VA_ARGS__); \
107363 + if (k < 0 || m > PAGE_SIZE - 90) \
107364 + FM_DMP_PGSZ_ERR \
107365 + if (addr) { \
107366 + phys_addr_t pa; \
107367 + pa = virt_to_phys(addr); \
107368 + m += k = \
107369 + snprintf(&buf[m], PAGE_SIZE - m, " (0x%lX)", \
107370 + (long unsigned int)(pa)); \
107371 + if (k < 0 || m > PAGE_SIZE - 90) \
107372 + FM_DMP_PGSZ_ERR \
107373 + } \
107374 + m += k = snprintf(&buf[m], PAGE_SIZE - m, \
107375 + "\n----------------------------------------\n\n"); \
107376 + if (k < 0 || m > PAGE_SIZE - 90) \
107377 + FM_DMP_PGSZ_ERR \
107378 + n = m; \
107379 + } while (0)
107380 +
107381 +#define FM_DMP_SUBTITLE(buf, n, ...) \
107382 + do { \
107383 + int k, m = n; \
107384 + m += k = snprintf(&buf[m], PAGE_SIZE - m, "------- "); \
107385 + if (k < 0 || m > PAGE_SIZE - 90) \
107386 + FM_DMP_PGSZ_ERR \
107387 + m += k = snprintf(&buf[m], PAGE_SIZE - m, __VA_ARGS__); \
107388 + if (k < 0 || m > PAGE_SIZE - 90) \
107389 + FM_DMP_PGSZ_ERR \
107390 + m += k = snprintf(&buf[m], PAGE_SIZE - m, "\n"); \
107391 + if (k < 0 || m > PAGE_SIZE - 90) \
107392 + FM_DMP_PGSZ_ERR \
107393 + n = m; \
107394 + } while (0)
107395 +
107396 +#define FM_DMP_MEM_32(buf, n, addr) \
107397 + { \
107398 + uint32_t val; \
107399 + phys_addr_t pa; \
107400 + int k, m = n; \
107401 + pa = virt_to_phys(addr); \
107402 + val = ioread32be((addr)); \
107403 + do { \
107404 + m += k = snprintf(&buf[m], \
107405 + PAGE_SIZE - m, "0x%010llX: 0x%08x\n", \
107406 + pa, val); \
107407 + if (k < 0 || m > PAGE_SIZE - 90) \
107408 + FM_DMP_PGSZ_ERR \
107409 + n += k; \
107410 + } while (0) ;\
107411 + }
107412 +
107413 +#define FM_DMP_V32(buf, n, st, phrase) \
107414 + do { \
107415 + int k, m = n; \
107416 + phys_addr_t pa = virt_to_phys(&((st)->phrase)); \
107417 + k = snprintf(&buf[m], PAGE_SIZE - m, \
107418 + "0x%010llX: 0x%08x%8s\t%s\n", (unsigned long long) pa, \
107419 + ioread32be((uint32_t *)&((st)->phrase)), "", #phrase); \
107420 + if (k < 0 || m > PAGE_SIZE - 90) \
107421 + FM_DMP_PGSZ_ERR \
107422 + n += k; \
107423 + } while (0)
107424 +
107425 +#endif /* LNXWRP_SYSFS_FM_H_ */
107426 --- /dev/null
107427 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm_port.c
107428 @@ -0,0 +1,1255 @@
107429 +/*
107430 + * Copyright 2008-2012 Freescale Semiconductor Inc.
107431 + *
107432 + * Redistribution and use in source and binary forms, with or without
107433 + * modification, are permitted provided that the following conditions are met:
107434 + * * Redistributions of source code must retain the above copyright
107435 + * notice, this list of conditions and the following disclaimer.
107436 + * * Redistributions in binary form must reproduce the above copyright
107437 + * notice, this list of conditions and the following disclaimer in the
107438 + * documentation and/or other materials provided with the distribution.
107439 + * * Neither the name of Freescale Semiconductor nor the
107440 + * names of its contributors may be used to endorse or promote products
107441 + * derived from this software without specific prior written permission.
107442 + *
107443 + *
107444 + * ALTERNATIVELY, this software may be distributed under the terms of the
107445 + * GNU General Public License ("GPL") as published by the Free Software
107446 + * Foundation, either version 2 of that License or (at your option) any
107447 + * later version.
107448 + *
107449 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
107450 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
107451 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
107452 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
107453 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
107454 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
107455 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
107456 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
107457 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
107458 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
107459 + */
107460 +
107461 +#include "lnxwrp_sysfs.h"
107462 +#include "lnxwrp_fm.h"
107463 +#include "debug_ext.h"
107464 +#include "lnxwrp_sysfs_fm_port.h"
107465 +#include "lnxwrp_sysfs_fm.h"
107466 +
107467 +#include "../../sdk_fman/Peripherals/FM/Port/fm_port.h"
107468 +#include "../../sdk_fman/Peripherals/FM/Port/fm_port_dsar.h"
107469 +
107470 +#if defined(__ERR_MODULE__)
107471 +#undef __ERR_MODULE__
107472 +#endif
107473 +
107474 +#include "../../sdk_fman/Peripherals/FM/fm.h"
107475 +
107476 +static const struct sysfs_stats_t portSysfsStats[] = {
107477 + /* RX/TX/OH common statistics */
107478 + {
107479 + .stat_name = "port_frame",
107480 + .stat_counter = e_FM_PORT_COUNTERS_FRAME,
107481 + },
107482 + {
107483 + .stat_name = "port_discard_frame",
107484 + .stat_counter = e_FM_PORT_COUNTERS_DISCARD_FRAME,
107485 + },
107486 + {
107487 + .stat_name = "port_dealloc_buf",
107488 + .stat_counter = e_FM_PORT_COUNTERS_DEALLOC_BUF,
107489 + },
107490 + {
107491 + .stat_name = "port_enq_total",
107492 + .stat_counter = e_FM_PORT_COUNTERS_ENQ_TOTAL,
107493 + },
107494 + /* TX/OH */
107495 + {
107496 + .stat_name = "port_length_err",
107497 + .stat_counter = e_FM_PORT_COUNTERS_LENGTH_ERR,
107498 + },
107499 + {
107500 + .stat_name = "port_unsupprted_format",
107501 + .stat_counter = e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT,
107502 + },
107503 + {
107504 + .stat_name = "port_deq_total",
107505 + .stat_counter = e_FM_PORT_COUNTERS_DEQ_TOTAL,
107506 + },
107507 + {
107508 + .stat_name = "port_deq_from_default",
107509 + .stat_counter = e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT,
107510 + },
107511 + {
107512 + .stat_name = "port_deq_confirm",
107513 + .stat_counter = e_FM_PORT_COUNTERS_DEQ_CONFIRM,
107514 + },
107515 + /* RX/OH */
107516 + {
107517 + .stat_name = "port_rx_bad_frame",
107518 + .stat_counter = e_FM_PORT_COUNTERS_RX_BAD_FRAME,
107519 + },
107520 + {
107521 + .stat_name = "port_rx_large_frame",
107522 + .stat_counter = e_FM_PORT_COUNTERS_RX_LARGE_FRAME,
107523 + },
107524 + {
107525 + .stat_name = "port_rx_out_of_buffers_discard",
107526 + .stat_counter = e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD,
107527 + },
107528 + {
107529 + .stat_name = "port_rx_filter_frame",
107530 + .stat_counter = e_FM_PORT_COUNTERS_RX_FILTER_FRAME,
107531 + },
107532 + /* TODO: Particular statistics for OH ports */
107533 + {}
107534 +};
107535 +
107536 +static ssize_t show_fm_port_stats(struct device *dev,
107537 + struct device_attribute *attr, char *buf)
107538 +{
107539 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev;
107540 + t_LnxWrpFmDev *p_LnxWrpFmDev;
107541 + unsigned long flags;
107542 + int n = 0;
107543 + uint8_t counter = 0;
107544 +
107545 + if (attr == NULL || buf == NULL || dev == NULL)
107546 + return -EINVAL;
107547 +
107548 + p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *) dev_get_drvdata(dev);
107549 + if (WARN_ON(p_LnxWrpFmPortDev == NULL))
107550 + return -EINVAL;
107551 +
107552 + p_LnxWrpFmDev = (t_LnxWrpFmDev *) p_LnxWrpFmPortDev->h_LnxWrpFmDev;
107553 + if (WARN_ON(p_LnxWrpFmDev == NULL))
107554 + return -EINVAL;
107555 +
107556 + if (!p_LnxWrpFmDev->active || !p_LnxWrpFmDev->h_Dev)
107557 + return -EIO;
107558 +
107559 + if (!p_LnxWrpFmPortDev->h_Dev) {
107560 + n = snprintf(buf, PAGE_SIZE, "\tFM Port not configured...\n");
107561 + return n;
107562 + }
107563 +
107564 + counter = fm_find_statistic_counter_by_name(
107565 + attr->attr.name,
107566 + portSysfsStats, NULL);
107567 +
107568 + if (counter == e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR) {
107569 + uint32_t fmRev = 0;
107570 + fmRev = 0xffff &
107571 + ioread32(UINT_TO_PTR(p_LnxWrpFmDev->fmBaseAddr +
107572 + 0x000c30c4));
107573 +
107574 + if (fmRev == 0x0100) {
107575 + local_irq_save(flags);
107576 + n = snprintf(buf, PAGE_SIZE,
107577 + "counter not available for revision 1\n");
107578 + local_irq_restore(flags);
107579 + }
107580 + return n;
107581 + }
107582 +
107583 + local_irq_save(flags);
107584 + n = snprintf(buf, PAGE_SIZE, "\t%s counter: %u\n",
107585 + p_LnxWrpFmPortDev->name,
107586 + FM_PORT_GetCounter(p_LnxWrpFmPortDev->h_Dev,
107587 + (e_FmPortCounters) counter));
107588 + local_irq_restore(flags);
107589 +
107590 + return n;
107591 +}
107592 +
107593 +/* FM PORT RX/TX/OH statistics */
107594 +static DEVICE_ATTR(port_frame, S_IRUGO, show_fm_port_stats, NULL);
107595 +static DEVICE_ATTR(port_discard_frame, S_IRUGO, show_fm_port_stats, NULL);
107596 +static DEVICE_ATTR(port_dealloc_buf, S_IRUGO, show_fm_port_stats, NULL);
107597 +static DEVICE_ATTR(port_enq_total, S_IRUGO, show_fm_port_stats, NULL);
107598 +/* FM PORT TX/OH statistics */
107599 +static DEVICE_ATTR(port_length_err, S_IRUGO, show_fm_port_stats, NULL);
107600 +static DEVICE_ATTR(port_unsupprted_format, S_IRUGO, show_fm_port_stats, NULL);
107601 +static DEVICE_ATTR(port_deq_total, S_IRUGO, show_fm_port_stats, NULL);
107602 +static DEVICE_ATTR(port_deq_from_default, S_IRUGO, show_fm_port_stats, NULL);
107603 +static DEVICE_ATTR(port_deq_confirm, S_IRUGO, show_fm_port_stats, NULL);
107604 +/* FM PORT RX/OH statistics */
107605 +static DEVICE_ATTR(port_rx_bad_frame, S_IRUGO, show_fm_port_stats, NULL);
107606 +static DEVICE_ATTR(port_rx_large_frame, S_IRUGO, show_fm_port_stats, NULL);
107607 +static DEVICE_ATTR(port_rx_out_of_buffers_discard, S_IRUGO,
107608 + show_fm_port_stats, NULL);
107609 +static DEVICE_ATTR(port_rx_filter_frame, S_IRUGO, show_fm_port_stats, NULL);
107610 +
107611 +/* FM PORT TX statistics */
107612 +static struct attribute *fm_tx_port_dev_stats_attributes[] = {
107613 + &dev_attr_port_frame.attr,
107614 + &dev_attr_port_discard_frame.attr,
107615 + &dev_attr_port_dealloc_buf.attr,
107616 + &dev_attr_port_enq_total.attr,
107617 + &dev_attr_port_length_err.attr,
107618 + &dev_attr_port_unsupprted_format.attr,
107619 + &dev_attr_port_deq_total.attr,
107620 + &dev_attr_port_deq_from_default.attr,
107621 + &dev_attr_port_deq_confirm.attr,
107622 + NULL
107623 +};
107624 +
107625 +static const struct attribute_group fm_tx_port_dev_stats_attr_grp = {
107626 + .name = "statistics",
107627 + .attrs = fm_tx_port_dev_stats_attributes
107628 +};
107629 +
107630 +/* FM PORT RX statistics */
107631 +static struct attribute *fm_rx_port_dev_stats_attributes[] = {
107632 + &dev_attr_port_frame.attr,
107633 + &dev_attr_port_discard_frame.attr,
107634 + &dev_attr_port_dealloc_buf.attr,
107635 + &dev_attr_port_enq_total.attr,
107636 + &dev_attr_port_rx_bad_frame.attr,
107637 + &dev_attr_port_rx_large_frame.attr,
107638 + &dev_attr_port_rx_out_of_buffers_discard.attr,
107639 + &dev_attr_port_rx_filter_frame.attr,
107640 + NULL
107641 +};
107642 +
107643 +static const struct attribute_group fm_rx_port_dev_stats_attr_grp = {
107644 + .name = "statistics",
107645 + .attrs = fm_rx_port_dev_stats_attributes
107646 +};
107647 +
107648 +/* TODO: add particular OH ports statistics */
107649 +static struct attribute *fm_oh_port_dev_stats_attributes[] = {
107650 + &dev_attr_port_frame.attr,
107651 + &dev_attr_port_discard_frame.attr,
107652 + &dev_attr_port_dealloc_buf.attr,
107653 + &dev_attr_port_enq_total.attr,
107654 + /*TX*/ &dev_attr_port_length_err.attr,
107655 + &dev_attr_port_unsupprted_format.attr,
107656 + &dev_attr_port_deq_total.attr,
107657 + &dev_attr_port_deq_from_default.attr,
107658 + &dev_attr_port_deq_confirm.attr,
107659 + /* &dev_attr_port_rx_bad_frame.attr, */
107660 + /* &dev_attr_port_rx_large_frame.attr, */
107661 + &dev_attr_port_rx_out_of_buffers_discard.attr,
107662 + /*&dev_attr_port_rx_filter_frame.attr, */
107663 + NULL
107664 +};
107665 +
107666 +static const struct attribute_group fm_oh_port_dev_stats_attr_grp = {
107667 + .name = "statistics",
107668 + .attrs = fm_oh_port_dev_stats_attributes
107669 +};
107670 +
107671 +static ssize_t show_fm_port_regs(struct device *dev,
107672 + struct device_attribute *attr, char *buf)
107673 +{
107674 + unsigned long flags;
107675 + unsigned n = 0;
107676 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
107677 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev =
107678 + (t_LnxWrpFmPortDev *) dev_get_drvdata(dev);
107679 +#endif
107680 + if (attr == NULL || buf == NULL || dev == NULL)
107681 + return -EINVAL;
107682 +
107683 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
107684 + local_irq_save(flags);
107685 +
107686 + if (!p_LnxWrpFmPortDev->h_Dev) {
107687 + n = snprintf(buf, PAGE_SIZE, "\tFM Port not configured...\n");
107688 + return n;
107689 + } else {
107690 + n = snprintf(buf, PAGE_SIZE,
107691 + "FM port driver registers dump.\n");
107692 + n = fm_port_dump_regs(p_LnxWrpFmPortDev->h_Dev, buf, n);
107693 + }
107694 +
107695 + local_irq_restore(flags);
107696 +
107697 + return n;
107698 +#else
107699 +
107700 + local_irq_save(flags);
107701 + n = snprintf(buf, PAGE_SIZE,
107702 + "Debug level is too low to dump registers!!!\n");
107703 + local_irq_restore(flags);
107704 +
107705 + return n;
107706 +#endif
107707 +}
107708 +static int fm_port_dsar_dump_mem(void *h_dev, char *buf, int nn)
107709 +{
107710 + t_FmPort *p_FmPort;
107711 + t_Fm *p_Fm;
107712 + uint8_t hardwarePortId;
107713 + uint32_t *param_page;
107714 + t_ArCommonDesc *ArCommonDescPtr;
107715 + uint32_t *mem;
107716 + int i, n = nn;
107717 +
107718 + p_FmPort = (t_FmPort *)h_dev;
107719 + hardwarePortId = p_FmPort->hardwarePortId;
107720 + p_Fm = (t_Fm *)p_FmPort->h_Fm;
107721 +
107722 + if (!FM_PORT_IsInDsar(p_FmPort))
107723 + {
107724 + FM_DMP_LN(buf, n, "port %u is not a DSAR port\n",
107725 + hardwarePortId);
107726 + return n;
107727 + }
107728 + FM_DMP_LN(buf, n, "port %u DSAR mem\n", hardwarePortId);
107729 + FM_DMP_LN(buf, n, "========================\n");
107730 +
107731 + /* do I need request_mem_region here? */
107732 + param_page = ioremap(p_FmPort->fmMuramPhysBaseAddr + ioread32be(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rgpr), 4);
107733 + ArCommonDescPtr = (t_ArCommonDesc*)(ioremap(p_FmPort->fmMuramPhysBaseAddr + ioread32be(param_page), 300*4)); /* this should be changed*/
107734 + mem = (uint32_t*)ArCommonDescPtr;
107735 + for (i = 0; i < 300; i+=4)
107736 + FM_DMP_LN(buf, n, "%08x: %08x %08x %08x %08x\n", i*4, mem[i], mem[i + 1], mem[i + 2], mem[i + 3]);
107737 + iounmap(ArCommonDescPtr);
107738 + iounmap(param_page);
107739 + return n;
107740 +}
107741 +
107742 +static int fm_port_dsar_dump_regs(void *h_dev, char *buf, int nn)
107743 +{
107744 + t_FmPort *p_FmPort;
107745 + t_Fm *p_Fm;
107746 + uint8_t hardwarePortId;
107747 + uint32_t *param_page;
107748 + t_ArCommonDesc *ArCommonDescPtr;
107749 + int i, n = nn;
107750 +
107751 + p_FmPort = (t_FmPort *)h_dev;
107752 + hardwarePortId = p_FmPort->hardwarePortId;
107753 + p_Fm = (t_Fm *)p_FmPort->h_Fm;
107754 +
107755 + if (!FM_PORT_IsInDsar(p_FmPort))
107756 + {
107757 + FM_DMP_LN(buf, n, "port %u is not a DSAR port\n",
107758 + hardwarePortId);
107759 + return n;
107760 + }
107761 + FM_DMP_LN(buf, n, "port %u DSAR information\n", hardwarePortId);
107762 + FM_DMP_LN(buf, n, "========================\n");
107763 +
107764 + /* do I need request_mem_region here? */
107765 + param_page = ioremap(p_FmPort->fmMuramPhysBaseAddr + ioread32be(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rgpr), 4);
107766 + ArCommonDescPtr = (t_ArCommonDesc*)(ioremap(p_FmPort->fmMuramPhysBaseAddr + ioread32be(param_page), sizeof(t_ArCommonDesc))); /* this should be changed*/
107767 + FM_DMP_LN(buf, n, "Tx port: 0x%x\n", ArCommonDescPtr->arTxPort);
107768 + FM_DMP_LN(buf, n, "Active HPNIA: 0x%08x\n", ArCommonDescPtr->activeHPNIA);
107769 + FM_DMP_LN(buf, n, "Snmp port: 0x%x\n", ArCommonDescPtr->snmpPort);
107770 + FM_DMP_LN(buf, n, "MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n", ArCommonDescPtr->macStationAddr[0],
107771 + ArCommonDescPtr->macStationAddr[1], ArCommonDescPtr->macStationAddr[2],
107772 + ArCommonDescPtr->macStationAddr[3], ArCommonDescPtr->macStationAddr[4],
107773 + ArCommonDescPtr->macStationAddr[5]);
107774 + FM_DMP_LN(buf, n, "filterControl: 0x%02x\n", ArCommonDescPtr->filterControl);
107775 + FM_DMP_LN(buf, n, "tcpControlPass: 0x%04x\n", ArCommonDescPtr->tcpControlPass);
107776 + FM_DMP_LN(buf, n, "ipProtocolTblSize: 0x%x\n", ArCommonDescPtr->ipProtocolTblSize);
107777 + FM_DMP_LN(buf, n, "udpPortTblSize: 0x%x\n", ArCommonDescPtr->udpPortTblSize);
107778 + FM_DMP_LN(buf, n, "tcpPortTblSize: 0x%x\n", ArCommonDescPtr->tcpPortTblSize);
107779 + if (ArCommonDescPtr->p_ArStats)
107780 + {
107781 + t_ArStatistics *arStatistics = (t_ArStatistics*)
107782 + ioremap(ioread32be(&ArCommonDescPtr->p_ArStats) +
107783 + p_FmPort->fmMuramPhysBaseAddr,
107784 + sizeof (t_ArStatistics));
107785 + FM_DMP_LN(buf, n, "\nDSAR statistics\n");
107786 + FM_DMP_LN(buf, n, "DSAR_Discarded: 0x%x\n", arStatistics->dsarDiscarded);
107787 + FM_DMP_LN(buf, n, "DSAR_Err_Discarded: 0x%x\n", arStatistics->dsarErrDiscarded);
107788 + FM_DMP_LN(buf, n, "DSAR_Frag_Discarded: 0x%x\n", arStatistics->dsarFragDiscarded);
107789 + FM_DMP_LN(buf, n, "DSAR_Tunnel_Discarded: 0x%x\n", arStatistics->dsarTunnelDiscarded);
107790 + FM_DMP_LN(buf, n, "DSAR_ARP_Discarded: 0x%x\n", arStatistics->dsarArpDiscarded);
107791 + FM_DMP_LN(buf, n, "DSAR_IP_Discarded: 0x%x\n", arStatistics->dsarIpDiscarded);
107792 + FM_DMP_LN(buf, n, "DSAR_TCP_Discarded: 0x%x\n", arStatistics->dsarTcpDiscarded);
107793 + FM_DMP_LN(buf, n, "DSAR_UDP_Discarded: 0x%x\n", arStatistics->dsarUdpDiscarded);
107794 + FM_DMP_LN(buf, n, "DSAR_ICMPv6_Checksum_Err: 0x%x\n", arStatistics->dsarIcmpV6ChecksumErr);
107795 + FM_DMP_LN(buf, n, "DSAR_ICMPv6_Other_Type: 0x%x\n", arStatistics->dsarIcmpV6OtherType);
107796 + FM_DMP_LN(buf, n, "DSAR_ICMPv4_Other_Type: 0x%x\n", arStatistics->dsarIcmpV4OtherType);
107797 +
107798 + iounmap(arStatistics);
107799 + }
107800 + if (ArCommonDescPtr->p_ArpDescriptor)
107801 + {
107802 + t_DsarArpDescriptor* ArpDescriptor = (t_DsarArpDescriptor*)
107803 + ioremap(ioread32be(&ArCommonDescPtr->p_ArpDescriptor) +
107804 + p_FmPort->fmMuramPhysBaseAddr,
107805 + sizeof (t_DsarArpDescriptor));
107806 + FM_DMP_LN(buf, n, "\nARP\n");
107807 + FM_DMP_LN(buf, n, "===\n");
107808 + FM_DMP_LN(buf, n, "control bits 0x%04x\n", ArpDescriptor->control);
107809 + if (ArpDescriptor->numOfBindings)
107810 + {
107811 + char ip_str[100];
107812 + t_DsarArpBindingEntry* bindings = ioremap(
107813 + ioread32be(&ArpDescriptor->p_Bindings) +
107814 + p_FmPort->fmMuramPhysBaseAddr,
107815 + ArpDescriptor->numOfBindings *
107816 + sizeof(t_DsarArpBindingEntry));
107817 + uint8_t* ip_addr = (uint8_t*)&bindings->ipv4Addr;
107818 + FM_DMP_LN(buf, n, " ip vlan id\n");
107819 + for (i = 0; i < ArpDescriptor->numOfBindings; i++)
107820 + {
107821 + n += snprintf(ip_str, 100, "%d.%d.%d.%d",
107822 + ip_addr[0], ip_addr[1],
107823 + ip_addr[2], ip_addr[3]);
107824 + FM_DMP_LN(buf, n, "%-15s 0x%x\n",
107825 + ip_str, bindings->vlanId);
107826 + }
107827 + iounmap(bindings);
107828 + }
107829 + if (ArpDescriptor->p_Statistics)
107830 + {
107831 + t_DsarArpStatistics* arpStats = ioremap(
107832 + ioread32be(&ArpDescriptor->p_Statistics) +
107833 + p_FmPort->fmMuramPhysBaseAddr,
107834 + sizeof(t_DsarArpStatistics));
107835 + FM_DMP_LN(buf, n, "statistics\n");
107836 + FM_DMP_LN(buf, n, "INVAL_CNT: 0x%x\n", arpStats->invalCnt);
107837 + FM_DMP_LN(buf, n, "ECHO_CNT: 0x%x\n", arpStats->echoCnt);
107838 + FM_DMP_LN(buf, n, "CD_CNT: 0x%x\n", arpStats->cdCnt);
107839 + FM_DMP_LN(buf, n, "AR_CNT: 0x%x\n", arpStats->arCnt);
107840 + FM_DMP_LN(buf, n, "RATM_CNT: 0x%x\n", arpStats->ratmCnt);
107841 + FM_DMP_LN(buf, n, "UKOP_CNT: 0x%x\n", arpStats->ukopCnt);
107842 + FM_DMP_LN(buf, n, "NMTP_CNT: 0x%x\n", arpStats->nmtpCnt);
107843 + FM_DMP_LN(buf, n, "NMVLAN_CNT: 0x%x\n", arpStats->nmVlanCnt);
107844 + iounmap(arpStats);
107845 + }
107846 +
107847 + iounmap(ArpDescriptor);
107848 + }
107849 + if (ArCommonDescPtr->p_IcmpV4Descriptor)
107850 + {
107851 + t_DsarIcmpV4Descriptor* ICMPV4Descriptor =
107852 + (t_DsarIcmpV4Descriptor*)ioremap(ioread32be(
107853 + &ArCommonDescPtr->p_IcmpV4Descriptor) +
107854 + p_FmPort->fmMuramPhysBaseAddr,
107855 + sizeof (t_DsarIcmpV4Descriptor));
107856 + FM_DMP_LN(buf, n, "\nEcho ICMPv4\n");
107857 + FM_DMP_LN(buf, n, "===========\n");
107858 + FM_DMP_LN(buf, n, "control bits 0x%04x\n", ICMPV4Descriptor->control);
107859 + if (ICMPV4Descriptor->numOfBindings)
107860 + {
107861 + char ip_str[100];
107862 + t_DsarArpBindingEntry* bindings = ioremap(
107863 + ioread32be(&ICMPV4Descriptor->p_Bindings) +
107864 + p_FmPort->fmMuramPhysBaseAddr,
107865 + ICMPV4Descriptor->numOfBindings *
107866 + sizeof(t_DsarArpBindingEntry));
107867 + uint8_t* ip_addr = (uint8_t*)&bindings->ipv4Addr;
107868 + FM_DMP_LN(buf, n, " ip vlan id\n");
107869 + for (i = 0; i < ICMPV4Descriptor->numOfBindings; i++)
107870 + {
107871 + n += snprintf(ip_str, 100, "%d.%d.%d.%d",
107872 + ip_addr[0], ip_addr[1],
107873 + ip_addr[2], ip_addr[3]);
107874 + FM_DMP_LN(buf, n, "%-15s 0x%x\n",
107875 + ip_str, bindings->vlanId);
107876 + }
107877 + iounmap(bindings);
107878 + }
107879 + if (ICMPV4Descriptor->p_Statistics)
107880 + {
107881 + t_DsarIcmpV4Statistics* icmpv4Stats = ioremap(
107882 + ioread32be(&ICMPV4Descriptor->p_Statistics) +
107883 + p_FmPort->fmMuramPhysBaseAddr,
107884 + sizeof(t_DsarIcmpV4Statistics));
107885 + FM_DMP_LN(buf, n, "statistics\n");
107886 + FM_DMP_LN(buf, n, "INVAL_CNT: 0x%x\n", icmpv4Stats->invalCnt);
107887 + FM_DMP_LN(buf, n, "NMVLAN_CNT: 0x%x\n", icmpv4Stats->nmVlanCnt);
107888 + FM_DMP_LN(buf, n, "NMIP_CNT: 0x%x\n", icmpv4Stats->nmIpCnt);
107889 + FM_DMP_LN(buf, n, "AR_CNT: 0x%x\n", icmpv4Stats->arCnt);
107890 + FM_DMP_LN(buf, n, "CSERR_CNT: 0x%x\n", icmpv4Stats->cserrCnt);
107891 + iounmap(icmpv4Stats);
107892 + }
107893 + iounmap(ICMPV4Descriptor);
107894 + }
107895 + if (ArCommonDescPtr->p_NdDescriptor)
107896 + {
107897 + t_DsarNdDescriptor *NDDescriptor =
107898 + (t_DsarNdDescriptor*)ioremap(ioread32be(
107899 + &ArCommonDescPtr->p_NdDescriptor) + p_FmPort->
107900 + fmMuramPhysBaseAddr, sizeof (t_DsarNdDescriptor));
107901 + FM_DMP_LN(buf, n, "\nNDP\n");
107902 + FM_DMP_LN(buf, n, "===\n");
107903 + FM_DMP_LN(buf, n, "control bits 0x%04x\n", NDDescriptor->control);
107904 + FM_DMP_LN(buf, n, "solicited address 0x%08x\n", NDDescriptor->solicitedAddr);
107905 + if (NDDescriptor->numOfBindings)
107906 + {
107907 + char ip_str[100];
107908 + t_DsarIcmpV6BindingEntry* bindings = ioremap(
107909 + ioread32be(&NDDescriptor->p_Bindings) +
107910 + p_FmPort->fmMuramPhysBaseAddr,
107911 + NDDescriptor->numOfBindings *
107912 + sizeof(t_DsarIcmpV6BindingEntry));
107913 + uint16_t* ip_addr = (uint16_t*)&bindings->ipv6Addr;
107914 + FM_DMP_LN(buf, n, " ip vlan id\n");
107915 + for (i = 0; i < NDDescriptor->numOfBindings; i++)
107916 + {
107917 + n += snprintf(ip_str, 100,
107918 + "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
107919 + ip_addr[0], ip_addr[1], ip_addr[2], ip_addr[3],
107920 + ip_addr[4], ip_addr[5], ip_addr[6], ip_addr[7]);
107921 + FM_DMP_LN(buf, n, "%s 0x%x\n", ip_str, bindings->vlanId);
107922 + }
107923 + iounmap(bindings);
107924 + }
107925 + if (NDDescriptor->p_Statistics)
107926 + {
107927 + t_NdStatistics* ndStats = ioremap(
107928 + ioread32be(&NDDescriptor->p_Statistics) +
107929 + p_FmPort->fmMuramPhysBaseAddr,
107930 + sizeof(t_NdStatistics));
107931 + FM_DMP_LN(buf, n, "statistics\n");
107932 + FM_DMP_LN(buf, n, "INVAL_CNT: 0x%x\n", ndStats->invalCnt);
107933 + FM_DMP_LN(buf, n, "NMVLAN_CNT: 0x%x\n", ndStats->nmVlanCnt);
107934 + FM_DMP_LN(buf, n, "NMIP_CNT: 0x%x\n", ndStats->nmIpCnt);
107935 + FM_DMP_LN(buf, n, "AR_CNT: 0x%x\n", ndStats->arCnt);
107936 + FM_DMP_LN(buf, n, "USADVERT_CNT: 0x%x\n", ndStats->usadvertCnt);
107937 + FM_DMP_LN(buf, n, "NMMCAST_CNT: 0x%x\n", ndStats->nmmcastCnt);
107938 + FM_DMP_LN(buf, n, "NSLLA_CNT: 0x%x\n", ndStats->nsllaCnt);
107939 + iounmap(ndStats);
107940 + }
107941 + iounmap(NDDescriptor);
107942 + }
107943 + if (ArCommonDescPtr->p_IcmpV6Descriptor)
107944 + {
107945 + t_DsarIcmpV6Descriptor *ICMPV6Descriptor =
107946 + (t_DsarIcmpV6Descriptor*)ioremap(ioread32be(
107947 + &ArCommonDescPtr->p_IcmpV6Descriptor) + p_FmPort->
107948 + fmMuramPhysBaseAddr, sizeof (t_DsarIcmpV6Descriptor));
107949 + FM_DMP_LN(buf, n, "\nEcho ICMPv6\n");
107950 + FM_DMP_LN(buf, n, "===========\n");
107951 + FM_DMP_LN(buf, n, "control bits 0x%04x\n", ICMPV6Descriptor->control);
107952 + if (ICMPV6Descriptor->numOfBindings)
107953 + {
107954 + char ip_str[100];
107955 + t_DsarIcmpV6BindingEntry* bindings = ioremap(
107956 + ioread32be(&ICMPV6Descriptor->p_Bindings) +
107957 + p_FmPort->fmMuramPhysBaseAddr,
107958 + ICMPV6Descriptor->numOfBindings *
107959 + sizeof(t_DsarIcmpV6BindingEntry));
107960 + uint16_t* ip_addr = (uint16_t*)&bindings->ipv6Addr;
107961 + FM_DMP_LN(buf, n, " ip vlan id\n");
107962 + for (i = 0; i < ICMPV6Descriptor->numOfBindings; i++)
107963 + {
107964 + n += snprintf(ip_str, 100,
107965 + "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
107966 + ip_addr[0], ip_addr[1], ip_addr[2], ip_addr[3],
107967 + ip_addr[4], ip_addr[5], ip_addr[6], ip_addr[7]);
107968 + FM_DMP_LN(buf, n, "%s 0x%x\n", ip_str, bindings->vlanId);
107969 + }
107970 + iounmap(bindings);
107971 + }
107972 + if (ICMPV6Descriptor->p_Statistics)
107973 + {
107974 + t_DsarIcmpV6Statistics* icmpv6Stats = ioremap(
107975 + ioread32be(&ICMPV6Descriptor->p_Statistics) +
107976 + p_FmPort->fmMuramPhysBaseAddr,
107977 + sizeof(t_DsarIcmpV6Statistics));
107978 + FM_DMP_LN(buf, n, "statistics\n");
107979 + FM_DMP_LN(buf, n, "INVAL_CNT: 0x%x\n", icmpv6Stats->invalCnt);
107980 + FM_DMP_LN(buf, n, "NMVLAN_CNT: 0x%x\n", icmpv6Stats->nmVlanCnt);
107981 + FM_DMP_LN(buf, n, "NMIP_CNT: 0x%x\n", icmpv6Stats->nmIpCnt);
107982 + FM_DMP_LN(buf, n, "AR_CNT: 0x%x\n", icmpv6Stats->arCnt);
107983 + iounmap(icmpv6Stats);
107984 + }
107985 + iounmap(ICMPV6Descriptor);
107986 + }
107987 + if (ArCommonDescPtr->p_SnmpDescriptor)
107988 + {
107989 + t_DsarSnmpDescriptor *SnmpDescriptor =
107990 + (t_DsarSnmpDescriptor*)ioremap(ioread32be(
107991 + &ArCommonDescPtr->p_SnmpDescriptor) + p_FmPort->
107992 + fmMuramPhysBaseAddr, sizeof (t_DsarSnmpDescriptor));
107993 + FM_DMP_LN(buf, n, "\nSNMP\n");
107994 + FM_DMP_LN(buf, n, "===========\n");
107995 + FM_DMP_LN(buf, n, "control bits 0x%04x\n", SnmpDescriptor->control);
107996 + FM_DMP_LN(buf, n, "max message length 0x%04x\n", SnmpDescriptor->maxSnmpMsgLength);
107997 + if (SnmpDescriptor->numOfIpv4Addresses)
107998 + {
107999 + char ip_str[100];
108000 + t_DsarSnmpIpv4AddrTblEntry* addrs = ioremap(
108001 + ioread32be(&SnmpDescriptor->p_Ipv4AddrTbl) +
108002 + p_FmPort->fmMuramPhysBaseAddr,
108003 + SnmpDescriptor->numOfIpv4Addresses *
108004 + sizeof(t_DsarSnmpIpv4AddrTblEntry));
108005 + uint8_t* ip_addr = (uint8_t*)&addrs->ipv4Addr;
108006 + FM_DMP_LN(buf, n, " ip vlan id\n");
108007 + for (i = 0; i < SnmpDescriptor->numOfIpv4Addresses; i++)
108008 + {
108009 + n += snprintf(ip_str, 100, "%d.%d.%d.%d",
108010 + ip_addr[0], ip_addr[1],
108011 + ip_addr[2], ip_addr[3]);
108012 + FM_DMP_LN(buf, n, "%-15s 0x%x\n", ip_str, addrs->vlanId);
108013 + }
108014 + iounmap(addrs);
108015 + }
108016 + if (SnmpDescriptor->p_Statistics)
108017 + {
108018 + t_DsarSnmpStatistics* snmpStats = ioremap(
108019 + ioread32be(&SnmpDescriptor->p_Statistics) +
108020 + p_FmPort->fmMuramPhysBaseAddr,
108021 + sizeof(t_DsarSnmpStatistics));
108022 + FM_DMP_LN(buf, n, "statistics\n");
108023 + FM_DMP_LN(buf, n, "snmpErrCnt: 0x%x\n", snmpStats->snmpErrCnt);
108024 + FM_DMP_LN(buf, n, "snmpCommunityErrCnt: 0x%x\n", snmpStats->snmpCommunityErrCnt);
108025 + FM_DMP_LN(buf, n, "snmpTotalDiscardCnt: 0x%x\n", snmpStats->snmpTotalDiscardCnt);
108026 + FM_DMP_LN(buf, n, "snmpGetReqCnt: 0x%x\n", snmpStats->snmpGetReqCnt);
108027 + FM_DMP_LN(buf, n, "snmpGetNextReqCnt: 0x%x\n", snmpStats->snmpGetNextReqCnt);
108028 + iounmap(snmpStats);
108029 + }
108030 + iounmap(SnmpDescriptor);
108031 + }
108032 + iounmap(ArCommonDescPtr);
108033 + iounmap(param_page);
108034 + return n;
108035 +}
108036 +
108037 +static ssize_t show_fm_port_dsar_mem(struct device *dev,
108038 + struct device_attribute *attr, char *buf)
108039 +{
108040 + unsigned long flags;
108041 + unsigned n = 0;
108042 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
108043 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev =
108044 + (t_LnxWrpFmPortDev *) dev_get_drvdata(dev);
108045 +#endif
108046 + if (attr == NULL || buf == NULL || dev == NULL)
108047 + return -EINVAL;
108048 +
108049 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
108050 + local_irq_save(flags);
108051 +
108052 + if (!p_LnxWrpFmPortDev->h_Dev) {
108053 + n = snprintf(buf, PAGE_SIZE, "\tFM Port not configured...\n");
108054 + return n;
108055 + } else {
108056 + n = snprintf(buf, PAGE_SIZE,
108057 + "FM port driver registers dump.\n");
108058 + n = fm_port_dsar_dump_mem(p_LnxWrpFmPortDev->h_Dev, buf, n);
108059 + }
108060 +
108061 + local_irq_restore(flags);
108062 +
108063 + return n;
108064 +#else
108065 +
108066 + local_irq_save(flags);
108067 + n = snprintf(buf, PAGE_SIZE,
108068 + "Debug level is too low to dump registers!!!\n");
108069 + local_irq_restore(flags);
108070 +
108071 + return n;
108072 +#endif
108073 +}
108074 +
108075 +static ssize_t show_fm_port_dsar_regs(struct device *dev,
108076 + struct device_attribute *attr, char *buf)
108077 +{
108078 + unsigned long flags;
108079 + unsigned n = 0;
108080 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
108081 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev =
108082 + (t_LnxWrpFmPortDev *) dev_get_drvdata(dev);
108083 +#endif
108084 + if (attr == NULL || buf == NULL || dev == NULL)
108085 + return -EINVAL;
108086 +
108087 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
108088 + local_irq_save(flags);
108089 +
108090 + if (!p_LnxWrpFmPortDev->h_Dev) {
108091 + n = snprintf(buf, PAGE_SIZE, "\tFM Port not configured...\n");
108092 + return n;
108093 + } else {
108094 + n = snprintf(buf, PAGE_SIZE,
108095 + "FM port driver registers dump.\n");
108096 + n = fm_port_dsar_dump_regs(p_LnxWrpFmPortDev->h_Dev, buf, n);
108097 + }
108098 +
108099 + local_irq_restore(flags);
108100 +
108101 + return n;
108102 +#else
108103 +
108104 + local_irq_save(flags);
108105 + n = snprintf(buf, PAGE_SIZE,
108106 + "Debug level is too low to dump registers!!!\n");
108107 + local_irq_restore(flags);
108108 +
108109 + return n;
108110 +#endif
108111 +}
108112 +
108113 +#if (DPAA_VERSION >= 11)
108114 +static ssize_t show_fm_port_ipv4_options(struct device *dev,
108115 + struct device_attribute *attr, char *buf)
108116 +{
108117 + unsigned long flags;
108118 + unsigned n = 0;
108119 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
108120 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev =
108121 + (t_LnxWrpFmPortDev *) dev_get_drvdata(dev);
108122 +#endif
108123 +
108124 + if (attr == NULL || buf == NULL || dev == NULL)
108125 + return -EINVAL;
108126 +
108127 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
108128 + local_irq_save(flags);
108129 +
108130 + if (!p_LnxWrpFmPortDev->h_Dev) {
108131 + n = snprintf(buf, PAGE_SIZE, "\tFM Port not configured...\n");
108132 + return n;
108133 + } else if (((t_FmPort *)p_LnxWrpFmPortDev->h_Dev)->p_ParamsPage
108134 + == NULL) {
108135 + n = snprintf(buf, PAGE_SIZE,
108136 + "\tPort: FMan-controller params page not set\n");
108137 + return n;
108138 + } else {
108139 + n = snprintf(buf, PAGE_SIZE,
108140 + "Counter for fragmented pkt with IP header options\n");
108141 + n = fm_port_dump_ipv4_opt(p_LnxWrpFmPortDev->h_Dev, buf, n);
108142 + }
108143 +
108144 + local_irq_restore(flags);
108145 +
108146 + return n;
108147 +#else
108148 +
108149 + local_irq_save(flags);
108150 + n = snprintf(buf, PAGE_SIZE,
108151 + "Debug level is too low to dump registers!!!\n");
108152 + local_irq_restore(flags);
108153 +
108154 + return n;
108155 +#endif
108156 +}
108157 +
108158 +#endif
108159 +
108160 +static ssize_t show_fm_port_bmi_regs(struct device *dev,
108161 + struct device_attribute *attr, char *buf)
108162 +{
108163 + unsigned long flags;
108164 + unsigned n = 0;
108165 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
108166 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev =
108167 + (t_LnxWrpFmPortDev *) dev_get_drvdata(dev);
108168 +#endif
108169 +
108170 + if (attr == NULL || buf == NULL || dev == NULL)
108171 + return -EINVAL;
108172 +
108173 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
108174 + local_irq_save(flags);
108175 +
108176 + if (!p_LnxWrpFmPortDev->h_Dev) {
108177 + n = snprintf(buf, PAGE_SIZE, "\tFM Port not configured...\n");
108178 + return n;
108179 + } else {
108180 + n = snprintf(buf, PAGE_SIZE,
108181 + "FM port driver registers dump.\n");
108182 + n = fm_port_dump_regs_bmi(p_LnxWrpFmPortDev->h_Dev, buf, n);
108183 + }
108184 +
108185 + local_irq_restore(flags);
108186 +
108187 + return n;
108188 +#else
108189 +
108190 + local_irq_save(flags);
108191 + n = snprintf(buf, PAGE_SIZE,
108192 + "Debug level is too low to dump registers!!!\n");
108193 + local_irq_restore(flags);
108194 +
108195 + return n;
108196 +#endif
108197 +}
108198 +
108199 +static ssize_t show_fm_port_qmi_regs(struct device *dev,
108200 + struct device_attribute *attr, char *buf)
108201 +{
108202 + unsigned long flags;
108203 + unsigned n = 0;
108204 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
108205 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev =
108206 + (t_LnxWrpFmPortDev *) dev_get_drvdata(dev);
108207 +#endif
108208 +
108209 + if (attr == NULL || buf == NULL || dev == NULL)
108210 + return -EINVAL;
108211 +
108212 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
108213 + local_irq_save(flags);
108214 +
108215 + if (!p_LnxWrpFmPortDev->h_Dev) {
108216 + n = snprintf(buf, PAGE_SIZE, "\tFM Port not configured...\n");
108217 + return n;
108218 + } else {
108219 + n = snprintf(buf, PAGE_SIZE,
108220 + "FM port driver registers dump.\n");
108221 + n = fm_port_dump_regs_qmi(p_LnxWrpFmPortDev->h_Dev, buf, n);
108222 + }
108223 +
108224 + local_irq_restore(flags);
108225 +
108226 + return n;
108227 +#else
108228 +
108229 + local_irq_save(flags);
108230 + n = snprintf(buf, PAGE_SIZE,
108231 + "Debug level is too low to dump registers!!!\n");
108232 + local_irq_restore(flags);
108233 +
108234 + return n;
108235 +#endif
108236 +}
108237 +
108238 +static DEVICE_ATTR(fm_port_regs, S_IRUGO | S_IRUSR, show_fm_port_regs, NULL);
108239 +static DEVICE_ATTR(fm_port_qmi_regs, S_IRUGO | S_IRUSR, show_fm_port_qmi_regs, NULL);
108240 +static DEVICE_ATTR(fm_port_bmi_regs, S_IRUGO | S_IRUSR, show_fm_port_bmi_regs, NULL);
108241 +#if (DPAA_VERSION >= 11)
108242 +static DEVICE_ATTR(fm_port_ipv4_opt, S_IRUGO | S_IRUSR, show_fm_port_ipv4_options, NULL);
108243 +#endif
108244 +static DEVICE_ATTR(fm_port_dsar_regs, S_IRUGO | S_IRUSR, show_fm_port_dsar_regs, NULL);
108245 +static DEVICE_ATTR(fm_port_dsar_mem, S_IRUGO | S_IRUSR, show_fm_port_dsar_mem, NULL);
108246 +
108247 +int fm_port_sysfs_create(struct device *dev)
108248 +{
108249 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev;
108250 +
108251 + if (dev == NULL)
108252 + return -EINVAL;
108253 +
108254 + p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *) dev_get_drvdata(dev);
108255 + if (WARN_ON(p_LnxWrpFmPortDev == NULL))
108256 + return -EINVAL;
108257 +
108258 + /* store to remove them when module is disabled */
108259 + p_LnxWrpFmPortDev->dev_attr_regs = &dev_attr_fm_port_regs;
108260 + p_LnxWrpFmPortDev->dev_attr_qmi_regs = &dev_attr_fm_port_qmi_regs;
108261 + p_LnxWrpFmPortDev->dev_attr_bmi_regs = &dev_attr_fm_port_bmi_regs;
108262 +#if (DPAA_VERSION >= 11)
108263 + p_LnxWrpFmPortDev->dev_attr_ipv4_opt = &dev_attr_fm_port_ipv4_opt;
108264 +#endif
108265 + p_LnxWrpFmPortDev->dev_attr_dsar_regs = &dev_attr_fm_port_dsar_regs;
108266 + p_LnxWrpFmPortDev->dev_attr_dsar_mem = &dev_attr_fm_port_dsar_mem;
108267 + /* Registers dump entry - in future will be moved to debugfs */
108268 + if (device_create_file(dev, &dev_attr_fm_port_regs) != 0)
108269 + return -EIO;
108270 + if (device_create_file(dev, &dev_attr_fm_port_qmi_regs) != 0)
108271 + return -EIO;
108272 + if (device_create_file(dev, &dev_attr_fm_port_bmi_regs) != 0)
108273 + return -EIO;
108274 +#if (DPAA_VERSION >= 11)
108275 + if (device_create_file(dev, &dev_attr_fm_port_ipv4_opt) != 0)
108276 + return -EIO;
108277 +#endif
108278 + if (device_create_file(dev, &dev_attr_fm_port_dsar_regs) != 0)
108279 + return -EIO;
108280 + if (device_create_file(dev, &dev_attr_fm_port_dsar_mem) != 0)
108281 + return -EIO;
108282 +
108283 + /* FM Ports statistics */
108284 + switch (p_LnxWrpFmPortDev->settings.param.portType) {
108285 + case e_FM_PORT_TYPE_TX:
108286 + case e_FM_PORT_TYPE_TX_10G:
108287 + if (sysfs_create_group
108288 + (&dev->kobj, &fm_tx_port_dev_stats_attr_grp) != 0)
108289 + return -EIO;
108290 + break;
108291 + case e_FM_PORT_TYPE_RX:
108292 + case e_FM_PORT_TYPE_RX_10G:
108293 + if (sysfs_create_group
108294 + (&dev->kobj, &fm_rx_port_dev_stats_attr_grp) != 0)
108295 + return -EIO;
108296 + break;
108297 + case e_FM_PORT_TYPE_DUMMY:
108298 + case e_FM_PORT_TYPE_OH_OFFLINE_PARSING:
108299 + if (sysfs_create_group
108300 + (&dev->kobj, &fm_oh_port_dev_stats_attr_grp) != 0)
108301 + return -EIO;
108302 + break;
108303 + default:
108304 + WARN(1, "FMD: failure at %s:%d/%s()!\n", __FILE__, __LINE__,
108305 + __func__);
108306 + return -EINVAL;
108307 + break;
108308 + };
108309 +
108310 + return 0;
108311 +}
108312 +
108313 +void fm_port_sysfs_destroy(struct device *dev)
108314 +{
108315 + t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = NULL;
108316 +
108317 + /* this function has never been tested !!! */
108318 +
108319 + if (WARN_ON(dev == NULL))
108320 + return;
108321 +
108322 + p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *) dev_get_drvdata(dev);
108323 + if (WARN_ON(p_LnxWrpFmPortDev == NULL))
108324 + return;
108325 +
108326 + /* The name attribute will be freed also by these 2 functions? */
108327 + switch (p_LnxWrpFmPortDev->settings.param.portType) {
108328 + case e_FM_PORT_TYPE_TX:
108329 + case e_FM_PORT_TYPE_TX_10G:
108330 + sysfs_remove_group(&dev->kobj, &fm_tx_port_dev_stats_attr_grp);
108331 + break;
108332 + case e_FM_PORT_TYPE_RX:
108333 + case e_FM_PORT_TYPE_RX_10G:
108334 + sysfs_remove_group(&dev->kobj, &fm_rx_port_dev_stats_attr_grp);
108335 + break;
108336 + case e_FM_PORT_TYPE_DUMMY:
108337 + case e_FM_PORT_TYPE_OH_OFFLINE_PARSING:
108338 + sysfs_remove_group(&dev->kobj, &fm_oh_port_dev_stats_attr_grp);
108339 + break;
108340 + default:
108341 + WARN(1, "FMD: failure at %s:%d/%s()!\n", __FILE__, __LINE__,
108342 + __func__);
108343 + break;
108344 + };
108345 +
108346 + device_remove_file(dev, p_LnxWrpFmPortDev->dev_attr_regs);
108347 + device_remove_file(dev, p_LnxWrpFmPortDev->dev_attr_qmi_regs);
108348 + device_remove_file(dev, p_LnxWrpFmPortDev->dev_attr_bmi_regs);
108349 +#if (DPAA_VERSION >= 11)
108350 + device_remove_file(dev, p_LnxWrpFmPortDev->dev_attr_ipv4_opt);
108351 +#endif
108352 + device_remove_file(dev, p_LnxWrpFmPortDev->dev_attr_dsar_regs);
108353 + device_remove_file(dev, p_LnxWrpFmPortDev->dev_attr_dsar_mem);
108354 +}
108355 +
108356 +
108357 +int fm_port_dump_regs(void *h_dev, char *buf, int nn)
108358 +{
108359 + t_FmPort *p_FmPort;
108360 + t_Fm *p_Fm;
108361 + uint8_t hardwarePortId;
108362 + int n = nn;
108363 +
108364 + p_FmPort = (t_FmPort *)h_dev;
108365 + hardwarePortId = p_FmPort->hardwarePortId;
108366 + p_Fm = (t_Fm *)p_FmPort->h_Fm;
108367 +
108368 + FM_DMP_TITLE(buf, n, &p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId - 1],
108369 + "fmbm_pp for port %u", hardwarePortId);
108370 + FM_DMP_MEM_32(buf, n,
108371 + &p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId - 1]);
108372 +
108373 + FM_DMP_TITLE(buf, n, &p_Fm->p_FmBmiRegs->fmbm_pfs[hardwarePortId - 1],
108374 + "fmbm_pfs for port %u", hardwarePortId);
108375 + FM_DMP_MEM_32(buf, n,
108376 + &p_Fm->p_FmBmiRegs->fmbm_pfs[hardwarePortId - 1]);
108377 +
108378 + FM_DMP_TITLE(buf, n,
108379 + &p_Fm->p_FmBmiRegs->fmbm_spliodn[hardwarePortId - 1],
108380 + "fmbm_spliodn for port %u", hardwarePortId);
108381 + FM_DMP_MEM_32(buf, n,
108382 + &p_Fm->p_FmBmiRegs->fmbm_spliodn[hardwarePortId - 1]);
108383 +
108384 + FM_DMP_TITLE(buf, n, &p_Fm->p_FmFpmRegs->fmfp_ps[hardwarePortId],
108385 + "fmfp_psfor port %u", hardwarePortId);
108386 + FM_DMP_MEM_32(buf, n, &p_Fm->p_FmFpmRegs->fmfp_ps[hardwarePortId]);
108387 +
108388 + FM_DMP_TITLE(buf, n, &p_Fm->p_FmDmaRegs->fmdmplr[hardwarePortId / 2],
108389 + "fmdmplrfor port %u", hardwarePortId);
108390 + FM_DMP_MEM_32(buf, n,
108391 + &p_Fm->p_FmDmaRegs->fmdmplr[hardwarePortId / 2]);
108392 + return n;
108393 +}
108394 +
108395 +#if (DPAA_VERSION >= 11)
108396 +
108397 +int fm_port_dump_ipv4_opt(void *h_dev, char *buf, int nn)
108398 +{
108399 + t_FmPort *p_FmPort;
108400 + int n = nn;
108401 +
108402 + p_FmPort = (t_FmPort *)h_dev;
108403 +
108404 + FM_DMP_V32(buf, n, p_FmPort->p_ParamsPage, ipfOptionsCounter);
108405 +
108406 + FM_DMP_SUBTITLE(buf, n, "\n");
108407 +
108408 + return n;
108409 +}
108410 +#endif
108411 +
108412 +int fm_port_dump_regs_bmi(void *h_dev, char *buf, int nn)
108413 +{
108414 + t_FmPort *p_FmPort;
108415 + u_FmPortBmiRegs *p_bmi;
108416 +
108417 + char arr[20];
108418 + uint8_t flag;
108419 + int i = 0;
108420 + int n = nn;
108421 +
108422 + p_FmPort = (t_FmPort *)h_dev;
108423 + p_bmi = p_FmPort->p_FmPortBmiRegs;
108424 +
108425 + memset(arr, 0, sizeof(arr));
108426 + switch (p_FmPort->portType) {
108427 + case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
108428 + strcpy(arr, "OFFLINE-PARSING");
108429 + flag = 0;
108430 + break;
108431 + case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
108432 + strcpy(arr, "HOST-COMMAND");
108433 + flag = 0;
108434 + break;
108435 + case (e_FM_PORT_TYPE_RX):
108436 + strcpy(arr, "RX");
108437 + flag = 1;
108438 + break;
108439 + case (e_FM_PORT_TYPE_RX_10G):
108440 + strcpy(arr, "RX-10G");
108441 + flag = 1;
108442 + break;
108443 + case (e_FM_PORT_TYPE_TX):
108444 + strcpy(arr, "TX");
108445 + flag = 2;
108446 + break;
108447 + case (e_FM_PORT_TYPE_TX_10G):
108448 + strcpy(arr, "TX-10G");
108449 + flag = 2;
108450 + break;
108451 + default:
108452 + return -EINVAL;
108453 + }
108454 +
108455 + FM_DMP_TITLE(buf, n, NULL,
108456 + "FMan-Port (%s #%d) registers:",
108457 + arr, p_FmPort->portId);
108458 +
108459 + FM_DMP_TITLE(buf, n, p_bmi, "Bmi Port Regs");
108460 +
108461 + switch (flag) {
108462 + case (0):
108463 + FM_DMP_SUBTITLE(buf, n, "\n");
108464 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ocfg);
108465 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ost);
108466 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_oda);
108467 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_oicp);
108468 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofdne);
108469 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofne);
108470 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofca);
108471 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofpne);
108472 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_opso);
108473 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_opp);
108474 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_occb);
108475 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_oim);
108476 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofp);
108477 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofed);
108478 +
108479 + FM_DMP_TITLE(buf, n,
108480 + &(p_bmi->ohPortBmiRegs.fmbm_oprai), "fmbm_oprai");
108481 + for (i = 0; i < FM_PORT_PRS_RESULT_NUM_OF_WORDS; ++i) {
108482 + FM_DMP_MEM_32(buf, n,
108483 + &(p_bmi->ohPortBmiRegs.fmbm_oprai[i]));
108484 + }
108485 + FM_DMP_SUBTITLE(buf, n, "\n");
108486 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofqid);
108487 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_oefqid);
108488 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofsdm);
108489 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofsem);
108490 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofene);
108491 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_orlmts);
108492 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_orlmt);
108493 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ocmne);
108494 + {
108495 +#ifndef FM_NO_OP_OBSERVED_POOLS
108496 + if (p_FmPort->fmRevInfo.majorRev == 4) {
108497 + FM_DMP_TITLE(buf, n,
108498 + &p_bmi->ohPortBmiRegs.fmbm_oebmpi,
108499 + "fmbm_oebmpi");
108500 +
108501 + for (i = 0; i < FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS; ++i) {
108502 + FM_DMP_MEM_32(buf, n,
108503 + &(p_bmi->ohPortBmiRegs.fmbm_oebmpi[i]));
108504 + }
108505 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ocgm);
108506 + }
108507 +#endif /* !FM_NO_OP_OBSERVED_POOLS */
108508 + }
108509 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ostc);
108510 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofrc);
108511 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofdc);
108512 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofledc);
108513 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofufdc);
108514 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_offc);
108515 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofwdc);
108516 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofldec);
108517 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_opc);
108518 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_opcp);
108519 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_occn);
108520 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_otuc);
108521 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_oduc);
108522 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ofuc);
108523 + FM_DMP_TITLE(buf, n, &(p_bmi->ohPortBmiRegs.fmbm_odcfg),
108524 + "fmbm_odcfg");
108525 + for (i = 0; i < 3; ++i) {
108526 + FM_DMP_MEM_32(buf, n,
108527 + &(p_bmi->ohPortBmiRegs.fmbm_odcfg[i]));
108528 + }
108529 + FM_DMP_SUBTITLE(buf, n, "\n");
108530 +
108531 + FM_DMP_V32(buf, n, &p_bmi->ohPortBmiRegs, fmbm_ogpr);
108532 + break;
108533 + case (1):
108534 + FM_DMP_SUBTITLE(buf, n, "\n");
108535 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rcfg);
108536 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rst);
108537 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rda);
108538 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfp);
108539 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_reth);
108540 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfed);
108541 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_ricp);
108542 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rebm);
108543 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfne);
108544 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfca);
108545 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfpne);
108546 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rpso);
108547 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rpp);
108548 + FM_DMP_TITLE(buf, n, &(p_bmi->rxPortBmiRegs.fmbm_rprai),
108549 + "fmbm_rprai");
108550 + for (i = 0; i < FM_PORT_PRS_RESULT_NUM_OF_WORDS; ++i) {
108551 + FM_DMP_MEM_32(buf, n,
108552 + &(p_bmi->rxPortBmiRegs.fmbm_rprai[i]));
108553 + }
108554 + FM_DMP_SUBTITLE(buf, n, "\n");
108555 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfqid);
108556 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_refqid);
108557 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfsdm);
108558 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfsem);
108559 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfene);
108560 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rcmne);
108561 + FM_DMP_TITLE(buf, n, &p_bmi->rxPortBmiRegs.fmbm_ebmpi,
108562 + "fmbm_ebmpi");
108563 + for (i = 0; i < FM_PORT_MAX_NUM_OF_EXT_POOLS; ++i) {
108564 + FM_DMP_MEM_32(buf, n,
108565 + &(p_bmi->rxPortBmiRegs.fmbm_ebmpi[i]));
108566 + }
108567 + FM_DMP_TITLE(buf, n, &p_bmi->rxPortBmiRegs.fmbm_acnt,
108568 + "fmbm_acnt");
108569 + for (i = 0; i < FM_PORT_MAX_NUM_OF_EXT_POOLS; ++i) {
108570 + FM_DMP_MEM_32(buf, n,
108571 + &(p_bmi->rxPortBmiRegs.fmbm_acnt[i]));
108572 + }
108573 + FM_DMP_TITLE(buf, n, &p_bmi->rxPortBmiRegs.fmbm_rcgm,
108574 + "fmbm_rcgm");
108575 + for (i = 0; i < FM_PORT_NUM_OF_CONGESTION_GRPS / 32; ++i) {
108576 + FM_DMP_MEM_32(buf, n,
108577 + &(p_bmi->rxPortBmiRegs.fmbm_rcgm[i]));
108578 + }
108579 +
108580 + FM_DMP_SUBTITLE(buf, n, "\n");
108581 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rmpd);
108582 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rstc);
108583 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfrc);
108584 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfbc);
108585 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rlfc);
108586 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rffc);
108587 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfcd);
108588 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfldec);
108589 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rodc);
108590 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rpc);
108591 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rpcp);
108592 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rccn);
108593 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rtuc);
108594 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rrquc);
108595 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rduc);
108596 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rfuc);
108597 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rpac);
108598 + FM_DMP_TITLE(buf, n, &(p_bmi->rxPortBmiRegs.fmbm_rdcfg),
108599 + "fmbm_rdcfg");
108600 + for (i = 0; i < 3; ++i) {
108601 + FM_DMP_MEM_32(buf, n,
108602 + &(p_bmi->rxPortBmiRegs.fmbm_rdcfg[i]));
108603 + }
108604 + FM_DMP_SUBTITLE(buf, n, "\n");
108605 + FM_DMP_V32(buf, n, &p_bmi->rxPortBmiRegs, fmbm_rgpr);
108606 + break;
108607 + case (2):
108608 + FM_DMP_SUBTITLE(buf, n, "\n");
108609 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tcfg);
108610 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tst);
108611 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tda);
108612 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tfp);
108613 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tfed);
108614 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_ticp);
108615 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tfdne);
108616 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tfca);
108617 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tcfqid);
108618 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tfeqid);
108619 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tfene);
108620 +#if (DPAA_VERSION >= 11)
108621 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tfne);
108622 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tcmne);
108623 +#endif /* (DPAA_VERSION >= 11) */
108624 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_trlmts);
108625 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_trlmt);
108626 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tstc);
108627 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tfrc);
108628 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tfdc);
108629 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tfledc);
108630 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tfufdc);
108631 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tpc);
108632 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tpcp);
108633 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tccn);
108634 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_ttuc);
108635 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_ttcquc);
108636 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tduc);
108637 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tfuc);
108638 + FM_DMP_TITLE(buf, n, &(p_bmi->txPortBmiRegs.fmbm_tdcfg),
108639 + "fmbm_tdcfg");
108640 + for (i = 0; i < 3 ; ++i) {
108641 + FM_DMP_MEM_32(buf, n,
108642 + &(p_bmi->txPortBmiRegs.fmbm_tdcfg[i]));
108643 + }
108644 + FM_DMP_SUBTITLE(buf, n, "\n");
108645 + FM_DMP_V32(buf, n, &p_bmi->txPortBmiRegs, fmbm_tgpr);
108646 + break;
108647 + }
108648 +
108649 + FM_DMP_SUBTITLE(buf, n, "\n");
108650 +
108651 + return n;
108652 +}
108653 +
108654 +int fm_port_dump_regs_qmi(void *h_dev, char *buf, int nn)
108655 +{
108656 + t_FmPort *p_FmPort;
108657 + int n = nn;
108658 +
108659 + p_FmPort = (t_FmPort *)h_dev;
108660 +
108661 + FM_DMP_TITLE(buf, n, p_FmPort->p_FmPortQmiRegs, "Qmi Port Regs");
108662 +
108663 + FM_DMP_V32(buf, n, p_FmPort->p_FmPortQmiRegs, fmqm_pnc);
108664 + FM_DMP_V32(buf, n, p_FmPort->p_FmPortQmiRegs, fmqm_pns);
108665 + FM_DMP_V32(buf, n, p_FmPort->p_FmPortQmiRegs, fmqm_pnts);
108666 + FM_DMP_V32(buf, n, p_FmPort->p_FmPortQmiRegs, fmqm_pnen);
108667 + FM_DMP_V32(buf, n, p_FmPort->p_FmPortQmiRegs, fmqm_pnetfc);
108668 + FM_DMP_V32(buf, n,
108669 + &p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs, fmqm_pndn);
108670 + FM_DMP_V32(buf, n,
108671 + &p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs, fmqm_pndc);
108672 + FM_DMP_V32(buf, n,
108673 + &p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs, fmqm_pndtfc);
108674 + FM_DMP_V32(buf, n,
108675 + &p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs, fmqm_pndfdc);
108676 + FM_DMP_V32(buf, n,
108677 + &p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs, fmqm_pndcc);
108678 +
108679 + FM_DMP_SUBTITLE(buf, n, "\n");
108680 +
108681 + return n;
108682 +}
108683 +
108684 --- /dev/null
108685 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm_port.h
108686 @@ -0,0 +1,56 @@
108687 +/*
108688 + * Copyright 2008-2012 Freescale Semiconductor Inc.
108689 + *
108690 + * Redistribution and use in source and binary forms, with or without
108691 + * modification, are permitted provided that the following conditions are met:
108692 + * * Redistributions of source code must retain the above copyright
108693 + * notice, this list of conditions and the following disclaimer.
108694 + * * Redistributions in binary form must reproduce the above copyright
108695 + * notice, this list of conditions and the following disclaimer in the
108696 + * documentation and/or other materials provided with the distribution.
108697 + * * Neither the name of Freescale Semiconductor nor the
108698 + * names of its contributors may be used to endorse or promote products
108699 + * derived from this software without specific prior written permission.
108700 + *
108701 + *
108702 + * ALTERNATIVELY, this software may be distributed under the terms of the
108703 + * GNU General Public License ("GPL") as published by the Free Software
108704 + * Foundation, either version 2 of that License or (at your option) any
108705 + * later version.
108706 + *
108707 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
108708 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
108709 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
108710 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
108711 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
108712 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
108713 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
108714 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
108715 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
108716 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
108717 + */
108718 +
108719 +/*
108720 + @File lnxwrp_sysfs_fm_port.h
108721 +
108722 + @Description FM port sysfs functions.
108723 +
108724 +*/
108725 +
108726 +#ifndef LNXWRP_SYSFS_FM_PORT_H_
108727 +#define LNXWRP_SYSFS_FM_PORT_H_
108728 +
108729 +#include "lnxwrp_sysfs.h"
108730 +
108731 +int fm_port_sysfs_create(struct device *dev);
108732 +void fm_port_sysfs_destroy(struct device *dev);
108733 +
108734 +int fm_port_dump_regs(void *h_dev, char *buf, int n);
108735 +int fm_port_dump_regs_bmi(void *h_dev, char *buf, int n);
108736 +int fm_port_dump_regs_qmi(void *h_dev, char *buf, int n);
108737 +
108738 +#if (DPAA_VERSION >= 11)
108739 +int fm_port_dump_ipv4_opt(void *h_dev, char *buf, int n);
108740 +#endif
108741 +
108742 +#endif /* LNXWRP_SYSFS_FM_PORT_H_ */
108743 --- /dev/null
108744 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/xx/Makefile
108745 @@ -0,0 +1,18 @@
108746 +#
108747 +# Makefile for the Freescale Ethernet controllers
108748 +#
108749 +ccflags-y += -DVERSION=\"\"
108750 +#
108751 +#Include netcomm SW specific definitions
108752 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
108753 +
108754 +obj-y += fsl-ncsw-xx.o
108755 +
108756 +ifneq ($(CONFIG_FMAN_ARM),y)
108757 +fsl-ncsw-xx-objs := xx_linux.o udivdi3.o \
108758 + module_strings.o
108759 +else
108760 +fsl-ncsw-xx-objs := xx_arm_linux.o udivdi3.o \
108761 + module_strings.o
108762 +endif
108763 +
108764 --- /dev/null
108765 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/xx/module_strings.c
108766 @@ -0,0 +1,45 @@
108767 +/*
108768 + * Copyright 2012 Freescale Semiconductor Inc.
108769 + *
108770 + * Redistribution and use in source and binary forms, with or without
108771 + * modification, are permitted provided that the following conditions are met:
108772 + * * Redistributions of source code must retain the above copyright
108773 + * notice, this list of conditions and the following disclaimer.
108774 + * * Redistributions in binary form must reproduce the above copyright
108775 + * notice, this list of conditions and the following disclaimer in the
108776 + * documentation and/or other materials provided with the distribution.
108777 + * * Neither the name of Freescale Semiconductor nor the
108778 + * names of its contributors may be used to endorse or promote products
108779 + * derived from this software without specific prior written permission.
108780 + *
108781 + *
108782 + * ALTERNATIVELY, this software may be distributed under the terms of the
108783 + * GNU General Public License ("GPL") as published by the Free Software
108784 + * Foundation, either version 2 of that License or (at your option) any
108785 + * later version.
108786 + *
108787 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
108788 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
108789 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
108790 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
108791 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
108792 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
108793 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
108794 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
108795 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
108796 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
108797 + */
108798 +
108799 +/* Module names for debug messages */
108800 +const char *moduleStrings[] =
108801 +{
108802 + "", /* MODULE_UNKNOWN */
108803 + "FM", /* MODULE_FM */
108804 + "FM-MURAM", /* MODULE_FM_MURAM */
108805 + "FM-PCD", /* MODULE_FM_PCD */
108806 + "FM-RTC", /* MODULE_FM_RTC */
108807 + "FM-MAC", /* MODULE_FM_MAC */
108808 + "FM-Port", /* MODULE_FM_PORT */
108809 + "MM", /* MODULE_MM */
108810 + "FM-SP" /* MODULE_FM_SP */
108811 +};
108812 --- /dev/null
108813 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/xx/udivdi3.c
108814 @@ -0,0 +1,132 @@
108815 +/*
108816 + * Copyright 2008-2012 Freescale Semiconductor Inc.
108817 + *
108818 + * Redistribution and use in source and binary forms, with or without
108819 + * modification, are permitted provided that the following conditions are met:
108820 + * * Redistributions of source code must retain the above copyright
108821 + * notice, this list of conditions and the following disclaimer.
108822 + * * Redistributions in binary form must reproduce the above copyright
108823 + * notice, this list of conditions and the following disclaimer in the
108824 + * documentation and/or other materials provided with the distribution.
108825 + * * Neither the name of Freescale Semiconductor nor the
108826 + * names of its contributors may be used to endorse or promote products
108827 + * derived from this software without specific prior written permission.
108828 + *
108829 + *
108830 + * ALTERNATIVELY, this software may be distributed under the terms of the
108831 + * GNU General Public License ("GPL") as published by the Free Software
108832 + * Foundation, either version 2 of that License or (at your option) any
108833 + * later version.
108834 + *
108835 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
108836 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
108837 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
108838 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
108839 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
108840 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
108841 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
108842 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
108843 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
108844 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
108845 + */
108846 +
108847 +#include <linux/version.h>
108848 +
108849 +#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
108850 +#define MODVERSIONS
108851 +#endif
108852 +#ifdef MODVERSIONS
108853 +#include <config/modversions.h>
108854 +#endif /* MODVERSIONS */
108855 +
108856 +#include <linux/module.h>
108857 +#include <linux/kernel.h>
108858 +#include <asm/div64.h>
108859 +
108860 +
108861 +#define BITS_PER_UNIT 8
108862 +#define SI_TYPE_SIZE (sizeof (SItype) * BITS_PER_UNIT)
108863 +
108864 +
108865 +typedef unsigned int UQItype __attribute__ ((mode (QI)));
108866 +typedef int SItype __attribute__ ((mode (SI)));
108867 +typedef unsigned int USItype __attribute__ ((mode (SI)));
108868 +typedef int DItype __attribute__ ((mode (DI)));
108869 +typedef int word_type __attribute__ ((mode (__word__)));
108870 +typedef unsigned int UDItype __attribute__ ((mode (DI)));
108871 +
108872 +struct DIstruct {SItype low, high;};
108873 +
108874 +typedef union
108875 +{
108876 + struct DIstruct s;
108877 + DItype ll;
108878 +} DIunion;
108879 +
108880 +
108881 +/* bit divisor, dividend and result. dynamic precision */
108882 +static __inline__ uint64_t _div64_64(uint64_t dividend, uint64_t divisor)
108883 +{
108884 + uint32_t d = divisor;
108885 +
108886 + if (divisor > 0xffffffffULL)
108887 + {
108888 + unsigned int shift = fls(divisor >> 32);
108889 +
108890 + d = divisor >> shift;
108891 + dividend >>= shift;
108892 + }
108893 +
108894 + /* avoid 64 bit division if possible */
108895 + if (dividend >> 32)
108896 + do_div(dividend, d);
108897 + else
108898 + dividend = (uint32_t) dividend / d;
108899 +
108900 + return dividend;
108901 +}
108902 +
108903 +UDItype __udivdi3 (UDItype n, UDItype d)
108904 +{
108905 + return _div64_64(n, d);
108906 +}
108907 +
108908 +DItype __divdi3 (DItype n, DItype d)
108909 +{
108910 + DItype sign = 1;
108911 + if (n<0)
108912 + {
108913 + sign *= -1;
108914 + n *= -1;
108915 + }
108916 + if (d<0)
108917 + {
108918 + sign *= -1;
108919 + d *= -1;
108920 + }
108921 + return sign*_div64_64((UDItype)n, (UDItype)d);
108922 +}
108923 +
108924 +UDItype __umoddi3 (UDItype n, UDItype d)
108925 +{
108926 + return n-(_div64_64(n, d)*d);
108927 +}
108928 +
108929 +#ifdef MODULE
108930 +word_type __ucmpdi2 (DItype a, DItype b)
108931 +{
108932 + DIunion au, bu;
108933 +
108934 + au.ll = a, bu.ll = b;
108935 +
108936 + if ((USItype) au.s.high < (USItype) bu.s.high)
108937 + return 0;
108938 + else if ((USItype) au.s.high > (USItype) bu.s.high)
108939 + return 2;
108940 + if ((USItype) au.s.low < (USItype) bu.s.low)
108941 + return 0;
108942 + else if ((USItype) au.s.low > (USItype) bu.s.low)
108943 + return 2;
108944 + return 1;
108945 +}
108946 +#endif /* MODULE */
108947 --- /dev/null
108948 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/xx/xx_arm_linux.c
108949 @@ -0,0 +1,905 @@
108950 +/*
108951 + * Copyright 2008-2012 Freescale Semiconductor Inc.
108952 + *
108953 + * Redistribution and use in source and binary forms, with or without
108954 + * modification, are permitted provided that the following conditions are met:
108955 + * * Redistributions of source code must retain the above copyright
108956 + * notice, this list of conditions and the following disclaimer.
108957 + * * Redistributions in binary form must reproduce the above copyright
108958 + * notice, this list of conditions and the following disclaimer in the
108959 + * documentation and/or other materials provided with the distribution.
108960 + * * Neither the name of Freescale Semiconductor nor the
108961 + * names of its contributors may be used to endorse or promote products
108962 + * derived from this software without specific prior written permission.
108963 + *
108964 + *
108965 + * ALTERNATIVELY, this software may be distributed under the terms of the
108966 + * GNU General Public License ("GPL") as published by the Free Software
108967 + * Foundation, either version 2 of that License or (at your option) any
108968 + * later version.
108969 + *
108970 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
108971 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
108972 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
108973 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
108974 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
108975 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
108976 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
108977 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
108978 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
108979 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
108980 + */
108981 +
108982 +/**************************************************************************//**
108983 + @File xx_arm_linux.c
108984 +
108985 + @Description XX routines implementation for Linux.
108986 +*//***************************************************************************/
108987 +#include <linux/version.h>
108988 +
108989 +#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
108990 +#define MODVERSIONS
108991 +#endif
108992 +#ifdef MODVERSIONS
108993 +#include <config/modversions.h>
108994 +#endif /* MODVERSIONS */
108995 +
108996 +#include <linux/module.h>
108997 +#include <linux/kernel.h>
108998 +#include <linux/sched.h>
108999 +#include <linux/string.h>
109000 +#include <linux/ptrace.h>
109001 +#include <linux/errno.h>
109002 +#include <linux/ioport.h>
109003 +#include <linux/slab.h>
109004 +#include <linux/interrupt.h>
109005 +#include <linux/fs.h>
109006 +#include <linux/vmalloc.h>
109007 +#include <linux/init.h>
109008 +#include <linux/timer.h>
109009 +#include <linux/spinlock.h>
109010 +#include <linux/delay.h>
109011 +#include <linux/proc_fs.h>
109012 +#include <linux/smp.h>
109013 +#include <linux/of.h>
109014 +#include <linux/irqdomain.h>
109015 +
109016 +#include <linux/workqueue.h>
109017 +
109018 +#ifdef BIGPHYSAREA_ENABLE
109019 +#include <linux/bigphysarea.h>
109020 +#endif /* BIGPHYSAREA_ENABLE */
109021 +
109022 +//#include <sysdev/fsl_soc.h>
109023 +#include <asm/pgtable.h>
109024 +#include <asm/irq.h>
109025 +#include <asm/bitops.h>
109026 +#include <asm/uaccess.h>
109027 +#include <asm/io.h>
109028 +#include <asm/atomic.h>
109029 +#include <asm/string.h>
109030 +#include <asm/byteorder.h>
109031 +#include <asm/page.h>
109032 +
109033 +#include "error_ext.h"
109034 +#include "std_ext.h"
109035 +#include "list_ext.h"
109036 +#include "mm_ext.h"
109037 +#include "sys_io_ext.h"
109038 +#include "xx.h"
109039 +
109040 +
109041 +#define __ERR_MODULE__ MODULE_UNKNOWN
109042 +
109043 +#ifdef BIGPHYSAREA_ENABLE
109044 +#define MAX_ALLOCATION_SIZE 128 * 1024 /* Maximum size allocated with kmalloc is 128K */
109045 +
109046 +
109047 +/* TODO: large allocations => use big phys area */
109048 +/******************************************************************************
109049 + * routine: get_nr_pages
109050 + *
109051 + * description:
109052 + * calculates the number of memory pages for a given size (in bytes)
109053 + *
109054 + * arguments:
109055 + * size - the number of bytes
109056 + *
109057 + * return code:
109058 + * The number of pages
109059 + *
109060 + *****************************************************************************/
109061 +static __inline__ uint32_t get_nr_pages (uint32_t size)
109062 +{
109063 + return (uint32_t)((size >> PAGE_SHIFT) + (size & PAGE_SHIFT ? 1 : 0));
109064 +}
109065 +
109066 +static bool in_big_phys_area (uint32_t addr)
109067 +{
109068 + uint32_t base, size;
109069 +
109070 + bigphysarea_get_details (&base, &size);
109071 + return ((addr >= base) && (addr < base + size));
109072 +}
109073 +#endif /* BIGPHYSAREA_ENABLE */
109074 +
109075 +void * xx_Malloc(uint32_t n)
109076 +{
109077 + void *a;
109078 + uint32_t flags;
109079 +
109080 + flags = XX_DisableAllIntr();
109081 +#ifdef BIGPHYSAREA_ENABLE
109082 + if (n >= MAX_ALLOCATION_SIZE)
109083 + a = (void*)bigphysarea_alloc_pages(get_nr_pages(n), 0, GFP_ATOMIC);
109084 + else
109085 +#endif /* BIGPHYSAREA_ENABLE */
109086 + a = (void *)kmalloc((uint32_t)n, GFP_ATOMIC);
109087 + if (!a)
109088 + XX_Print("No memory for XX_Malloc\n");
109089 + XX_RestoreAllIntr(flags);
109090 +
109091 + return a;
109092 +}
109093 +
109094 +void xx_Free(void *p)
109095 +{
109096 +#ifdef BIGPHYSAREA_ENABLE
109097 + if (in_big_phys_area ((uint32_t)p))
109098 + bigphysarea_free_pages(p);
109099 + else
109100 +#endif /* BIGPHYSAREA_ENABLE */
109101 + kfree(p);
109102 +}
109103 +
109104 +void XX_Exit(int status)
109105 +{
109106 + WARN(1, "\n\nFMD: fatal error, driver can't go on!!!\n\n");
109107 +}
109108 +
109109 +#define BUF_SIZE 512
109110 +void XX_Print(char *str, ...)
109111 +{
109112 + va_list args;
109113 +#ifdef CONFIG_SMP
109114 + char buf[BUF_SIZE];
109115 +#endif /* CONFIG_SMP */
109116 +
109117 + va_start(args, str);
109118 +#ifdef CONFIG_SMP
109119 + if (vsnprintf (buf, BUF_SIZE, str, args) >= BUF_SIZE)
109120 + printk(KERN_WARNING "Illegal string to print!\n more than %d characters.\n\tString was not printed completelly.\n", BUF_SIZE);
109121 + printk(KERN_CRIT "cpu %d: %s", raw_smp_processor_id(), buf);
109122 +#else
109123 + vprintk(str, args);
109124 +#endif /* CONFIG_SMP */
109125 + va_end(args);
109126 +}
109127 +
109128 +void XX_Fprint(void *file, char *str, ...)
109129 +{
109130 + va_list args;
109131 +#ifdef CONFIG_SMP
109132 + char buf[BUF_SIZE];
109133 +#endif /* CONFIG_SMP */
109134 +
109135 + va_start(args, str);
109136 +#ifdef CONFIG_SMP
109137 + if (vsnprintf (buf, BUF_SIZE, str, args) >= BUF_SIZE)
109138 + printk(KERN_WARNING "Illegal string to print!\n more than %d characters.\n\tString was not printed completelly.\n", BUF_SIZE);
109139 + printk (KERN_CRIT "cpu %d: %s", smp_processor_id(), buf);
109140 +
109141 +#else
109142 + vprintk(str, args);
109143 +#endif /* CONFIG_SMP */
109144 + va_end(args);
109145 +}
109146 +
109147 +#ifdef DEBUG_XX_MALLOC
109148 +typedef void (*t_ffn)(void *);
109149 +typedef struct {
109150 + t_ffn f_free;
109151 + void *mem;
109152 + char *fname;
109153 + int fline;
109154 + uint32_t size;
109155 + t_List node;
109156 +} t_MemDebug;
109157 +#define MEMDBG_OBJECT(p_List) LIST_OBJECT(p_List, t_MemDebug, node)
109158 +
109159 +LIST(memDbgLst);
109160 +
109161 +
109162 +void * XX_MallocDebug(uint32_t size, char *fname, int line)
109163 +{
109164 + void *mem;
109165 + t_MemDebug *p_MemDbg;
109166 +
109167 + p_MemDbg = (t_MemDebug *)xx_Malloc(sizeof(t_MemDebug));
109168 + if (p_MemDbg == NULL)
109169 + return NULL;
109170 +
109171 + mem = xx_Malloc(size);
109172 + if (mem == NULL)
109173 + {
109174 + XX_Free(p_MemDbg);
109175 + return NULL;
109176 + }
109177 +
109178 + INIT_LIST(&p_MemDbg->node);
109179 + p_MemDbg->f_free = xx_Free;
109180 + p_MemDbg->mem = mem;
109181 + p_MemDbg->fname = fname;
109182 + p_MemDbg->fline = line;
109183 + p_MemDbg->size = size+sizeof(t_MemDebug);
109184 + LIST_AddToTail(&p_MemDbg->node, &memDbgLst);
109185 +
109186 + return mem;
109187 +}
109188 +
109189 +void * XX_MallocSmartDebug(uint32_t size,
109190 + int memPartitionId,
109191 + uint32_t align,
109192 + char *fname,
109193 + int line)
109194 +{
109195 + void *mem;
109196 + t_MemDebug *p_MemDbg;
109197 +
109198 + p_MemDbg = (t_MemDebug *)XX_Malloc(sizeof(t_MemDebug));
109199 + if (p_MemDbg == NULL)
109200 + return NULL;
109201 +
109202 + mem = xx_MallocSmart((uint32_t)size, memPartitionId, align);
109203 + if (mem == NULL)
109204 + {
109205 + XX_Free(p_MemDbg);
109206 + return NULL;
109207 + }
109208 +
109209 + INIT_LIST(&p_MemDbg->node);
109210 + p_MemDbg->f_free = xx_FreeSmart;
109211 + p_MemDbg->mem = mem;
109212 + p_MemDbg->fname = fname;
109213 + p_MemDbg->fline = line;
109214 + p_MemDbg->size = size+sizeof(t_MemDebug);
109215 + LIST_AddToTail(&p_MemDbg->node, &memDbgLst);
109216 +
109217 + return mem;
109218 +}
109219 +
109220 +static void debug_free(void *mem)
109221 +{
109222 + t_List *p_MemDbgLh = NULL;
109223 + t_MemDebug *p_MemDbg;
109224 + bool found = FALSE;
109225 +
109226 + if (LIST_IsEmpty(&memDbgLst))
109227 + {
109228 + REPORT_ERROR(MAJOR, E_ALREADY_FREE, ("Unbalanced free (0x%08x)", mem));
109229 + return;
109230 + }
109231 +
109232 + LIST_FOR_EACH(p_MemDbgLh, &memDbgLst)
109233 + {
109234 + p_MemDbg = MEMDBG_OBJECT(p_MemDbgLh);
109235 + if (p_MemDbg->mem == mem)
109236 + {
109237 + found = TRUE;
109238 + break;
109239 + }
109240 + }
109241 +
109242 + if (!found)
109243 + {
109244 + REPORT_ERROR(MAJOR, E_NOT_FOUND,
109245 + ("Attempt to free unallocated address (0x%08x)",mem));
109246 + dump_stack();
109247 + return;
109248 + }
109249 +
109250 + LIST_Del(p_MemDbgLh);
109251 + p_MemDbg->f_free(mem);
109252 + p_MemDbg->f_free(p_MemDbg);
109253 +}
109254 +
109255 +void XX_FreeSmart(void *p)
109256 +{
109257 + debug_free(p);
109258 +}
109259 +
109260 +
109261 +void XX_Free(void *p)
109262 +{
109263 + debug_free(p);
109264 +}
109265 +
109266 +#else /* not DEBUG_XX_MALLOC */
109267 +void * XX_Malloc(uint32_t size)
109268 +{
109269 + return xx_Malloc(size);
109270 +}
109271 +
109272 +void * XX_MallocSmart(uint32_t size, int memPartitionId, uint32_t alignment)
109273 +{
109274 + return xx_MallocSmart(size,memPartitionId, alignment);
109275 +}
109276 +
109277 +void XX_FreeSmart(void *p)
109278 +{
109279 + xx_FreeSmart(p);
109280 +}
109281 +
109282 +
109283 +void XX_Free(void *p)
109284 +{
109285 + xx_Free(p);
109286 +}
109287 +#endif /* not DEBUG_XX_MALLOC */
109288 +
109289 +
109290 +#if (defined(REPORT_EVENTS) && (REPORT_EVENTS > 0))
109291 +void XX_EventById(uint32_t event, t_Handle appId, uint16_t flags, char *msg)
109292 +{
109293 + e_Event eventCode = (e_Event)event;
109294 +
109295 + UNUSED(eventCode);
109296 + UNUSED(appId);
109297 + UNUSED(flags);
109298 + UNUSED(msg);
109299 +}
109300 +#endif /* (defined(REPORT_EVENTS) && ... */
109301 +
109302 +
109303 +uint32_t XX_DisableAllIntr(void)
109304 +{
109305 + unsigned long flags;
109306 +
109307 +#ifdef local_irq_save_nort
109308 + local_irq_save_nort(flags);
109309 +#else
109310 + local_irq_save(flags);
109311 +#endif
109312 +
109313 + return (uint32_t)flags;
109314 +}
109315 +
109316 +void XX_RestoreAllIntr(uint32_t flags)
109317 +{
109318 +#ifdef local_irq_restore_nort
109319 + local_irq_restore_nort((unsigned long)flags);
109320 +#else
109321 + local_irq_restore((unsigned long)flags);
109322 +#endif
109323 +}
109324 +
109325 +t_Error XX_Call( uint32_t qid, t_Error (* f)(t_Handle), t_Handle id, t_Handle appId, uint16_t flags )
109326 +{
109327 + UNUSED(qid);
109328 + UNUSED(appId);
109329 + UNUSED(flags);
109330 +
109331 + return f(id);
109332 +}
109333 +
109334 +int XX_IsICacheEnable(void)
109335 +{
109336 + return TRUE;
109337 +}
109338 +
109339 +int XX_IsDCacheEnable(void)
109340 +{
109341 + return TRUE;
109342 +}
109343 +
109344 +
109345 +typedef struct {
109346 + t_Isr *f_Isr;
109347 + t_Handle handle;
109348 +} t_InterruptHandler;
109349 +
109350 +
109351 +t_Handle interruptHandlers[0x00010000];
109352 +
109353 +static irqreturn_t LinuxInterruptHandler (int irq, void *dev_id)
109354 +{
109355 + t_InterruptHandler *p_IntrHndl = (t_InterruptHandler *)dev_id;
109356 + p_IntrHndl->f_Isr(p_IntrHndl->handle);
109357 + return IRQ_HANDLED;
109358 +}
109359 +
109360 +t_Error XX_SetIntr(int irq, t_Isr *f_Isr, t_Handle handle)
109361 +{
109362 + const char *device;
109363 + t_InterruptHandler *p_IntrHndl;
109364 +
109365 + device = GetDeviceName(irq);
109366 + if (device == NULL)
109367 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Interrupt source - %d", irq));
109368 +
109369 + p_IntrHndl = (t_InterruptHandler *)XX_Malloc(sizeof(t_InterruptHandler));
109370 + if (p_IntrHndl == NULL)
109371 + RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
109372 + p_IntrHndl->f_Isr = f_Isr;
109373 + p_IntrHndl->handle = handle;
109374 + interruptHandlers[irq] = p_IntrHndl;
109375 +
109376 + if (request_irq(GetDeviceIrqNum(irq), LinuxInterruptHandler, 0, device, p_IntrHndl) < 0)
109377 + RETURN_ERROR(MAJOR, E_BUSY, ("Can't get IRQ %s\n", device));
109378 + disable_irq(GetDeviceIrqNum(irq));
109379 +
109380 + return E_OK;
109381 +}
109382 +
109383 +t_Error XX_FreeIntr(int irq)
109384 +{
109385 + t_InterruptHandler *p_IntrHndl = interruptHandlers[irq];
109386 + free_irq(GetDeviceIrqNum(irq), p_IntrHndl);
109387 + XX_Free(p_IntrHndl);
109388 + interruptHandlers[irq] = 0;
109389 + return E_OK;
109390 +}
109391 +
109392 +t_Error XX_EnableIntr(int irq)
109393 +{
109394 + enable_irq(GetDeviceIrqNum(irq));
109395 + return E_OK;
109396 +}
109397 +
109398 +t_Error XX_DisableIntr(int irq)
109399 +{
109400 + disable_irq(GetDeviceIrqNum(irq));
109401 + return E_OK;
109402 +}
109403 +
109404 +
109405 +/*****************************************************************************/
109406 +/* Tasklet Service Routines */
109407 +/*****************************************************************************/
109408 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
109409 +typedef struct
109410 +{
109411 + t_Handle h_Data;
109412 + void (*f_Callback) (void *);
109413 + struct delayed_work dwork;
109414 +} t_Tasklet;
109415 +
109416 +static void GenericTaskletCallback(struct work_struct *p_Work)
109417 +{
109418 + t_Tasklet *p_Task = container_of(p_Work, t_Tasklet, dwork.work);
109419 +
109420 + p_Task->f_Callback(p_Task->h_Data);
109421 +}
109422 +#endif /* LINUX_VERSION_CODE */
109423 +
109424 +
109425 +t_TaskletHandle XX_InitTasklet (void (*routine)(void *), void *data)
109426 +{
109427 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
109428 + struct work_struct *p_Task;
109429 + p_Task = (struct work_struct *)XX_Malloc(sizeof(struct work_struct));
109430 + INIT_WORK(p_Task, routine, data);
109431 +#else
109432 + t_Tasklet *p_Task = (t_Tasklet *)XX_Malloc(sizeof(t_Tasklet));
109433 + p_Task->h_Data = data;
109434 + p_Task->f_Callback = routine;
109435 + INIT_DELAYED_WORK(&p_Task->dwork, GenericTaskletCallback);
109436 +#endif /* LINUX_VERSION_CODE */
109437 +
109438 + return (t_TaskletHandle)p_Task;
109439 +}
109440 +
109441 +
109442 +void XX_FreeTasklet (t_TaskletHandle h_Tasklet)
109443 +{
109444 + if (h_Tasklet)
109445 + XX_Free(h_Tasklet);
109446 +}
109447 +
109448 +int XX_ScheduleTask(t_TaskletHandle h_Tasklet, int immediate)
109449 +{
109450 + int ans;
109451 +
109452 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
109453 + if (immediate)
109454 + ans = schedule_work(h_Tasklet);
109455 + else
109456 + ans = schedule_delayed_work(h_Tasklet, 1);
109457 +#else
109458 + if (immediate)
109459 + ans = schedule_delayed_work(&((t_Tasklet *)h_Tasklet)->dwork, 0);
109460 + else
109461 + ans = schedule_delayed_work(&((t_Tasklet *)h_Tasklet)->dwork, HZ);
109462 +#endif /* LINUX_VERSION_CODE */
109463 +
109464 + return ans;
109465 +}
109466 +
109467 +void XX_FlushScheduledTasks(void)
109468 +{
109469 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
109470 + flush_scheduled_tasks();
109471 +#else
109472 + flush_scheduled_work();
109473 +#endif /* LINUX_VERSION_CODE */
109474 +}
109475 +
109476 +int XX_TaskletIsQueued(t_TaskletHandle h_Tasklet)
109477 +{
109478 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
109479 + return (int)(((struct work_struct *)h_Tasklet)->pending);
109480 +#else
109481 + return (int)delayed_work_pending(&((t_Tasklet *)h_Tasklet)->dwork);
109482 +#endif /* LINUX_VERSION_CODE */
109483 +}
109484 +
109485 +void XX_SetTaskletData(t_TaskletHandle h_Tasklet, t_Handle data)
109486 +{
109487 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
109488 + ((struct tq_struct *)h_Tasklet)->data = data;
109489 +#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
109490 + ((struct work_struct *)h_Tasklet)->data = data;
109491 +#else
109492 + ((t_Tasklet *)h_Tasklet)->h_Data = data;
109493 +#endif /* LINUX_VERSION_CODE */
109494 +}
109495 +
109496 +t_Handle XX_GetTaskletData(t_TaskletHandle h_Tasklet)
109497 +{
109498 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
109499 + return (t_Handle)(((struct work_struct *)h_Tasklet)->data);
109500 +#else
109501 + return ((t_Tasklet *)h_Tasklet)->h_Data;
109502 +#endif /* LINUX_VERSION_CODE */
109503 +}
109504 +
109505 +
109506 +/*****************************************************************************/
109507 +/* Spinlock Service Routines */
109508 +/*****************************************************************************/
109509 +
109510 +t_Handle XX_InitSpinlock(void)
109511 +{
109512 + spinlock_t *p_Spinlock = (spinlock_t *)XX_Malloc(sizeof(spinlock_t));
109513 + if (!p_Spinlock)
109514 + return NULL;
109515 +
109516 + spin_lock_init(p_Spinlock);
109517 +
109518 + return (t_Handle)p_Spinlock;
109519 +}
109520 +
109521 +void XX_FreeSpinlock(t_Handle h_Spinlock)
109522 +{
109523 + if (h_Spinlock)
109524 + XX_Free(h_Spinlock);
109525 +}
109526 +
109527 +void XX_LockSpinlock(t_Handle h_Spinlock)
109528 +{
109529 + spin_lock((spinlock_t *)h_Spinlock);
109530 +}
109531 +
109532 +void XX_UnlockSpinlock(t_Handle h_Spinlock)
109533 +{
109534 + spin_unlock((spinlock_t *)h_Spinlock);
109535 +}
109536 +
109537 +uint32_t XX_LockIntrSpinlock(t_Handle h_Spinlock)
109538 +{
109539 + unsigned long intrFlags;
109540 + spin_lock_irqsave((spinlock_t *)h_Spinlock, intrFlags);
109541 + return intrFlags;
109542 +}
109543 +
109544 +void XX_UnlockIntrSpinlock(t_Handle h_Spinlock, uint32_t intrFlags)
109545 +{
109546 + spin_unlock_irqrestore((spinlock_t *)h_Spinlock, (unsigned long)intrFlags);
109547 +}
109548 +
109549 +
109550 +/*****************************************************************************/
109551 +/* Timers Service Routines */
109552 +/*****************************************************************************/
109553 +/* The time now is in mili sec. resolution */
109554 +uint32_t XX_CurrentTime(void)
109555 +{
109556 + return (jiffies*1000)/HZ;
109557 +}
109558 +
109559 +
109560 +t_Handle XX_CreateTimer(void)
109561 +{
109562 + struct timer_list *p_Timer = (struct timer_list *)XX_Malloc(sizeof(struct timer_list));
109563 + if (p_Timer)
109564 + {
109565 + memset(p_Timer, 0, sizeof(struct timer_list));
109566 + init_timer(p_Timer);
109567 + }
109568 + return (t_Handle)p_Timer;
109569 +}
109570 +
109571 +void XX_FreeTimer(t_Handle h_Timer)
109572 +{
109573 + if (h_Timer)
109574 + XX_Free(h_Timer);
109575 +}
109576 +
109577 +void XX_StartTimer(t_Handle h_Timer,
109578 + uint32_t msecs,
109579 + bool periodic,
109580 + void (*f_TimerExpired)(t_Handle),
109581 + t_Handle h_Arg)
109582 +{
109583 + int tmp_jiffies = (msecs*HZ)/1000;
109584 + struct timer_list *p_Timer = (struct timer_list *)h_Timer;
109585 +
109586 + SANITY_CHECK_RETURN((periodic == FALSE), E_NOT_SUPPORTED);
109587 +
109588 + p_Timer->function = (void (*)(unsigned long))f_TimerExpired;
109589 + p_Timer->data = (unsigned long)h_Arg;
109590 + if ((msecs*HZ)%1000)
109591 + tmp_jiffies++;
109592 + p_Timer->expires = (jiffies + tmp_jiffies);
109593 +
109594 + add_timer((struct timer_list *)h_Timer);
109595 +}
109596 +
109597 +void XX_SetTimerData(t_Handle h_Timer, t_Handle data)
109598 +{
109599 + struct timer_list *p_Timer = (struct timer_list *)h_Timer;
109600 +
109601 + p_Timer->data = (unsigned long)data;
109602 +}
109603 +
109604 +t_Handle XX_GetTimerData(t_Handle h_Timer)
109605 +{
109606 + struct timer_list *p_Timer = (struct timer_list *)h_Timer;
109607 +
109608 + return (t_Handle)p_Timer->data;
109609 +}
109610 +
109611 +uint32_t XX_GetExpirationTime(t_Handle h_Timer)
109612 +{
109613 + struct timer_list *p_Timer = (struct timer_list *)h_Timer;
109614 +
109615 + return (uint32_t)p_Timer->expires;
109616 +}
109617 +
109618 +void XX_StopTimer(t_Handle h_Timer)
109619 +{
109620 + del_timer((struct timer_list *)h_Timer);
109621 +}
109622 +
109623 +void XX_ModTimer(t_Handle h_Timer, uint32_t msecs)
109624 +{
109625 + int tmp_jiffies = (msecs*HZ)/1000;
109626 +
109627 + if ((msecs*HZ)%1000)
109628 + tmp_jiffies++;
109629 + mod_timer((struct timer_list *)h_Timer, jiffies + tmp_jiffies);
109630 +}
109631 +
109632 +int XX_TimerIsActive(t_Handle h_Timer)
109633 +{
109634 + return timer_pending((struct timer_list *)h_Timer);
109635 +}
109636 +
109637 +uint32_t XX_Sleep(uint32_t msecs)
109638 +{
109639 + int tmp_jiffies = (msecs*HZ)/1000;
109640 +
109641 + if ((msecs*HZ)%1000)
109642 + tmp_jiffies++;
109643 + return schedule_timeout(tmp_jiffies);
109644 +}
109645 +
109646 +/*BEWARE!!!!! UDelay routine is BUSY WAITTING!!!!!*/
109647 +void XX_UDelay(uint32_t usecs)
109648 +{
109649 + udelay(usecs);
109650 +}
109651 +
109652 +/* TODO: verify that these are correct */
109653 +#define MSG_BODY_SIZE 512
109654 +typedef t_Error (t_MsgHandler) (t_Handle h_Mod, uint32_t msgId, uint8_t msgBody[MSG_BODY_SIZE]);
109655 +typedef void (t_MsgCompletionCB) (t_Handle h_Arg, uint8_t msgBody[MSG_BODY_SIZE]);
109656 +t_Error XX_SendMessage(char *p_DestAddr,
109657 + uint32_t msgId,
109658 + uint8_t msgBody[MSG_BODY_SIZE],
109659 + t_MsgCompletionCB *f_CompletionCB,
109660 + t_Handle h_CBArg);
109661 +
109662 +typedef struct {
109663 + char *p_Addr;
109664 + t_MsgHandler *f_MsgHandlerCB;
109665 + t_Handle h_Mod;
109666 + t_List node;
109667 +} t_MsgHndlr;
109668 +#define MSG_HNDLR_OBJECT(ptr) LIST_OBJECT(ptr, t_MsgHndlr, node)
109669 +
109670 +LIST(msgHndlrList);
109671 +
109672 +static void EnqueueMsgHndlr(t_MsgHndlr *p_MsgHndlr)
109673 +{
109674 + uint32_t intFlags;
109675 +
109676 + intFlags = XX_DisableAllIntr();
109677 + LIST_AddToTail(&p_MsgHndlr->node, &msgHndlrList);
109678 + XX_RestoreAllIntr(intFlags);
109679 +}
109680 +/* TODO: add this for multi-platform support
109681 +static t_MsgHndlr * DequeueMsgHndlr(void)
109682 +{
109683 + t_MsgHndlr *p_MsgHndlr = NULL;
109684 + uint32_t intFlags;
109685 +
109686 + intFlags = XX_DisableAllIntr();
109687 + if (!LIST_IsEmpty(&msgHndlrList))
109688 + {
109689 + p_MsgHndlr = MSG_HNDLR_OBJECT(msgHndlrList.p_Next);
109690 + LIST_DelAndInit(&p_MsgHndlr->node);
109691 + }
109692 + XX_RestoreAllIntr(intFlags);
109693 +
109694 + return p_MsgHndlr;
109695 +}
109696 +*/
109697 +static t_MsgHndlr * FindMsgHndlr(char *p_Addr)
109698 +{
109699 + t_MsgHndlr *p_MsgHndlr;
109700 + t_List *p_Pos;
109701 +
109702 + LIST_FOR_EACH(p_Pos, &msgHndlrList)
109703 + {
109704 + p_MsgHndlr = MSG_HNDLR_OBJECT(p_Pos);
109705 + if (strstr(p_MsgHndlr->p_Addr, p_Addr))
109706 + return p_MsgHndlr;
109707 + }
109708 +
109709 + return NULL;
109710 +}
109711 +
109712 +t_Error XX_RegisterMessageHandler (char *p_Addr, t_MsgHandler *f_MsgHandlerCB, t_Handle h_Mod)
109713 +{
109714 + t_MsgHndlr *p_MsgHndlr;
109715 + uint32_t len;
109716 +
109717 + p_MsgHndlr = (t_MsgHndlr*)XX_Malloc(sizeof(t_MsgHndlr));
109718 + if (!p_MsgHndlr)
109719 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("message handler object!!!"));
109720 + memset(p_MsgHndlr, 0, sizeof(t_MsgHndlr));
109721 +
109722 + len = strlen(p_Addr);
109723 + p_MsgHndlr->p_Addr = (char*)XX_Malloc(len+1);
109724 + strncpy(p_MsgHndlr->p_Addr,p_Addr, (uint32_t)(len+1));
109725 +
109726 + p_MsgHndlr->f_MsgHandlerCB = f_MsgHandlerCB;
109727 + p_MsgHndlr->h_Mod = h_Mod;
109728 + INIT_LIST(&p_MsgHndlr->node);
109729 + EnqueueMsgHndlr(p_MsgHndlr);
109730 +
109731 + return E_OK;
109732 +}
109733 +
109734 +t_Error XX_UnregisterMessageHandler (char *p_Addr)
109735 +{
109736 + t_MsgHndlr *p_MsgHndlr = FindMsgHndlr(p_Addr);
109737 + if (!p_MsgHndlr)
109738 + RETURN_ERROR(MINOR, E_NO_DEVICE, ("message handler not found in list!!!"));
109739 +
109740 + LIST_Del(&p_MsgHndlr->node);
109741 + XX_Free(p_MsgHndlr->p_Addr);
109742 + XX_Free(p_MsgHndlr);
109743 +
109744 + return E_OK;
109745 +}
109746 +
109747 +t_Error XX_SendMessage(char *p_DestAddr,
109748 + uint32_t msgId,
109749 + uint8_t msgBody[MSG_BODY_SIZE],
109750 + t_MsgCompletionCB *f_CompletionCB,
109751 + t_Handle h_CBArg)
109752 +{
109753 + t_Error ans;
109754 + t_MsgHndlr *p_MsgHndlr = FindMsgHndlr(p_DestAddr);
109755 + if (!p_MsgHndlr)
109756 + RETURN_ERROR(MINOR, E_NO_DEVICE, ("message handler not found in list!!!"));
109757 +
109758 + ans = p_MsgHndlr->f_MsgHandlerCB(p_MsgHndlr->h_Mod, msgId, msgBody);
109759 +
109760 + if (f_CompletionCB)
109761 + f_CompletionCB(h_CBArg, msgBody);
109762 +
109763 + return ans;
109764 +}
109765 +
109766 +t_Error XX_IpcRegisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH],
109767 + t_IpcMsgHandler *f_MsgHandler,
109768 + t_Handle h_Module,
109769 + uint32_t replyLength)
109770 +{
109771 + UNUSED(addr);UNUSED(f_MsgHandler);UNUSED(h_Module);UNUSED(replyLength);
109772 + return E_OK;
109773 +}
109774 +
109775 +t_Error XX_IpcUnregisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH])
109776 +{
109777 + UNUSED(addr);
109778 + return E_OK;
109779 +}
109780 +
109781 +
109782 +t_Error XX_IpcSendMessage(t_Handle h_Session,
109783 + uint8_t *p_Msg,
109784 + uint32_t msgLength,
109785 + uint8_t *p_Reply,
109786 + uint32_t *p_ReplyLength,
109787 + t_IpcMsgCompletion *f_Completion,
109788 + t_Handle h_Arg)
109789 +{
109790 + UNUSED(h_Session); UNUSED(p_Msg); UNUSED(msgLength); UNUSED(p_Reply);
109791 + UNUSED(p_ReplyLength); UNUSED(f_Completion); UNUSED(h_Arg);
109792 + return E_OK;
109793 +}
109794 +
109795 +t_Handle XX_IpcInitSession(char destAddr[XX_IPC_MAX_ADDR_NAME_LENGTH],
109796 + char srcAddr[XX_IPC_MAX_ADDR_NAME_LENGTH])
109797 +{
109798 + UNUSED(destAddr); UNUSED(srcAddr);
109799 + return E_OK;
109800 +}
109801 +
109802 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
109803 +int GetDeviceIrqNum(int irq)
109804 +{
109805 + struct device_node *iPar;
109806 + struct irq_domain *irqHost;
109807 + uint32_t hwIrq;
109808 +
109809 + /* Get the interrupt controller */
109810 + iPar = of_find_node_by_name(NULL, "mpic");
109811 + hwIrq = 0;
109812 +
109813 + ASSERT_COND(iPar != NULL);
109814 + /* Get the irq host */
109815 + irqHost = irq_find_host(iPar);
109816 + of_node_put(iPar);
109817 +
109818 + /* Create irq mapping */
109819 + return irq_create_mapping(irqHost, hwIrq);
109820 +}
109821 +#else
109822 +#error "kernel not supported!!!"
109823 +#endif /* LINUX_VERSION_CODE */
109824 +
109825 +void * XX_PhysToVirt(physAddress_t addr)
109826 +{
109827 + return UINT_TO_PTR(SYS_PhysToVirt((uint64_t)addr));
109828 +}
109829 +
109830 +physAddress_t XX_VirtToPhys(void * addr)
109831 +{
109832 + return (physAddress_t)SYS_VirtToPhys(PTR_TO_UINT(addr));
109833 +}
109834 +
109835 +void * xx_MallocSmart(uint32_t size, int memPartitionId, uint32_t alignment)
109836 +{
109837 + uintptr_t *returnCode, tmp;
109838 +
109839 + if (alignment < sizeof(uintptr_t))
109840 + alignment = sizeof(uintptr_t);
109841 + size += alignment + sizeof(returnCode);
109842 + tmp = (uintptr_t)xx_Malloc(size);
109843 + if (tmp == 0)
109844 + return NULL;
109845 + returnCode = (uintptr_t*)((tmp + alignment + sizeof(returnCode)) & ~((uintptr_t)alignment - 1));
109846 + *(returnCode - 1) = tmp;
109847 +
109848 + return (void*)returnCode;
109849 +}
109850 +
109851 +void xx_FreeSmart(void *p)
109852 +{
109853 + xx_Free((void*)(*((uintptr_t *)(p) - 1)));
109854 +}
109855 --- /dev/null
109856 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/xx/xx_linux.c
109857 @@ -0,0 +1,918 @@
109858 +/*
109859 + * Copyright 2008-2012 Freescale Semiconductor Inc.
109860 + *
109861 + * Redistribution and use in source and binary forms, with or without
109862 + * modification, are permitted provided that the following conditions are met:
109863 + * * Redistributions of source code must retain the above copyright
109864 + * notice, this list of conditions and the following disclaimer.
109865 + * * Redistributions in binary form must reproduce the above copyright
109866 + * notice, this list of conditions and the following disclaimer in the
109867 + * documentation and/or other materials provided with the distribution.
109868 + * * Neither the name of Freescale Semiconductor nor the
109869 + * names of its contributors may be used to endorse or promote products
109870 + * derived from this software without specific prior written permission.
109871 + *
109872 + *
109873 + * ALTERNATIVELY, this software may be distributed under the terms of the
109874 + * GNU General Public License ("GPL") as published by the Free Software
109875 + * Foundation, either version 2 of that License or (at your option) any
109876 + * later version.
109877 + *
109878 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
109879 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
109880 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
109881 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
109882 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
109883 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
109884 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
109885 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
109886 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
109887 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
109888 + */
109889 +
109890 +/**************************************************************************//**
109891 + @File xx_linux.c
109892 +
109893 + @Description XX routines implementation for Linux.
109894 +*//***************************************************************************/
109895 +#include <linux/version.h>
109896 +
109897 +#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
109898 +#define MODVERSIONS
109899 +#endif
109900 +#ifdef MODVERSIONS
109901 +#include <config/modversions.h>
109902 +#endif /* MODVERSIONS */
109903 +
109904 +#include <linux/module.h>
109905 +#include <linux/kernel.h>
109906 +#include <linux/sched.h>
109907 +#include <linux/string.h>
109908 +#include <linux/ptrace.h>
109909 +#include <linux/errno.h>
109910 +#include <linux/ioport.h>
109911 +#include <linux/slab.h>
109912 +#include <linux/interrupt.h>
109913 +#include <linux/fs.h>
109914 +#include <linux/vmalloc.h>
109915 +#include <linux/init.h>
109916 +#include <linux/timer.h>
109917 +#include <linux/spinlock.h>
109918 +#include <linux/delay.h>
109919 +#include <linux/proc_fs.h>
109920 +#include <linux/smp.h>
109921 +#include <linux/of.h>
109922 +#ifdef CONFIG_FMAN_ARM
109923 +#include <linux/irqdomain.h>
109924 +#endif
109925 +
109926 +#include <linux/workqueue.h>
109927 +
109928 +#ifdef BIGPHYSAREA_ENABLE
109929 +#include <linux/bigphysarea.h>
109930 +#endif /* BIGPHYSAREA_ENABLE */
109931 +
109932 +#ifndef CONFIG_FMAN_ARM
109933 +#include <sysdev/fsl_soc.h>
109934 +#endif
109935 +#include <asm/pgtable.h>
109936 +#include <asm/irq.h>
109937 +#include <asm/bitops.h>
109938 +#include <asm/uaccess.h>
109939 +#include <asm/io.h>
109940 +#include <asm/atomic.h>
109941 +#include <asm/string.h>
109942 +#include <asm/byteorder.h>
109943 +#include <asm/page.h>
109944 +
109945 +#include "error_ext.h"
109946 +#include "std_ext.h"
109947 +#include "list_ext.h"
109948 +#include "mm_ext.h"
109949 +#include "sys_io_ext.h"
109950 +#include "xx.h"
109951 +
109952 +
109953 +#define __ERR_MODULE__ MODULE_UNKNOWN
109954 +
109955 +#ifdef BIGPHYSAREA_ENABLE
109956 +#define MAX_ALLOCATION_SIZE 128 * 1024 /* Maximum size allocated with kmalloc is 128K */
109957 +
109958 +
109959 +/* TODO: large allocations => use big phys area */
109960 +/******************************************************************************
109961 + * routine: get_nr_pages
109962 + *
109963 + * description:
109964 + * calculates the number of memory pages for a given size (in bytes)
109965 + *
109966 + * arguments:
109967 + * size - the number of bytes
109968 + *
109969 + * return code:
109970 + * The number of pages
109971 + *
109972 + *****************************************************************************/
109973 +static __inline__ uint32_t get_nr_pages (uint32_t size)
109974 +{
109975 + return (uint32_t)((size >> PAGE_SHIFT) + (size & PAGE_SHIFT ? 1 : 0));
109976 +}
109977 +
109978 +static bool in_big_phys_area (uint32_t addr)
109979 +{
109980 + uint32_t base, size;
109981 +
109982 + bigphysarea_get_details (&base, &size);
109983 + return ((addr >= base) && (addr < base + size));
109984 +}
109985 +#endif /* BIGPHYSAREA_ENABLE */
109986 +
109987 +void * xx_Malloc(uint32_t n)
109988 +{
109989 + void *a;
109990 + uint32_t flags;
109991 +
109992 + flags = XX_DisableAllIntr();
109993 +#ifdef BIGPHYSAREA_ENABLE
109994 + if (n >= MAX_ALLOCATION_SIZE)
109995 + a = (void*)bigphysarea_alloc_pages(get_nr_pages(n), 0, GFP_ATOMIC);
109996 + else
109997 +#endif /* BIGPHYSAREA_ENABLE */
109998 + a = (void *)kmalloc((uint32_t)n, GFP_ATOMIC);
109999 + if (!a)
110000 + XX_Print("No memory for XX_Malloc\n");
110001 + XX_RestoreAllIntr(flags);
110002 +
110003 + return a;
110004 +}
110005 +
110006 +void xx_Free(void *p)
110007 +{
110008 +#ifdef BIGPHYSAREA_ENABLE
110009 + if (in_big_phys_area ((uint32_t)p))
110010 + bigphysarea_free_pages(p);
110011 + else
110012 +#endif /* BIGPHYSAREA_ENABLE */
110013 + kfree(p);
110014 +}
110015 +
110016 +void XX_Exit(int status)
110017 +{
110018 + WARN(1, "\n\nFMD: fatal error, driver can't go on!!!\n\n");
110019 +}
110020 +
110021 +#define BUF_SIZE 512
110022 +void XX_Print(char *str, ...)
110023 +{
110024 + va_list args;
110025 +#ifdef CONFIG_SMP
110026 + char buf[BUF_SIZE];
110027 +#endif /* CONFIG_SMP */
110028 +
110029 + va_start(args, str);
110030 +#ifdef CONFIG_SMP
110031 + if (vsnprintf (buf, BUF_SIZE, str, args) >= BUF_SIZE)
110032 + printk(KERN_WARNING "Illegal string to print!\n more than %d characters.\n\tString was not printed completelly.\n", BUF_SIZE);
110033 + printk(KERN_CRIT "cpu%d/%d: %s", raw_smp_processor_id(), NR_CPUS, buf);
110034 +#else
110035 + vprintk(str, args);
110036 +#endif /* CONFIG_SMP */
110037 + va_end(args);
110038 +}
110039 +
110040 +void XX_Fprint(void *file, char *str, ...)
110041 +{
110042 + va_list args;
110043 +#ifdef CONFIG_SMP
110044 + char buf[BUF_SIZE];
110045 +#endif /* CONFIG_SMP */
110046 +
110047 + va_start(args, str);
110048 +#ifdef CONFIG_SMP
110049 + if (vsnprintf (buf, BUF_SIZE, str, args) >= BUF_SIZE)
110050 + printk(KERN_WARNING "Illegal string to print!\n more than %d characters.\n\tString was not printed completelly.\n", BUF_SIZE);
110051 + printk (KERN_CRIT "cpu%d/%d: %s", raw_smp_processor_id(), NR_CPUS, buf);
110052 +
110053 +#else
110054 + vprintk(str, args);
110055 +#endif /* CONFIG_SMP */
110056 + va_end(args);
110057 +}
110058 +
110059 +#ifdef DEBUG_XX_MALLOC
110060 +typedef void (*t_ffn)(void *);
110061 +typedef struct {
110062 + t_ffn f_free;
110063 + void *mem;
110064 + char *fname;
110065 + int fline;
110066 + uint32_t size;
110067 + t_List node;
110068 +} t_MemDebug;
110069 +#define MEMDBG_OBJECT(p_List) LIST_OBJECT(p_List, t_MemDebug, node)
110070 +
110071 +LIST(memDbgLst);
110072 +
110073 +
110074 +void * XX_MallocDebug(uint32_t size, char *fname, int line)
110075 +{
110076 + void *mem;
110077 + t_MemDebug *p_MemDbg;
110078 +
110079 + p_MemDbg = (t_MemDebug *)xx_Malloc(sizeof(t_MemDebug));
110080 + if (p_MemDbg == NULL)
110081 + return NULL;
110082 +
110083 + mem = xx_Malloc(size);
110084 + if (mem == NULL)
110085 + {
110086 + XX_Free(p_MemDbg);
110087 + return NULL;
110088 + }
110089 +
110090 + INIT_LIST(&p_MemDbg->node);
110091 + p_MemDbg->f_free = xx_Free;
110092 + p_MemDbg->mem = mem;
110093 + p_MemDbg->fname = fname;
110094 + p_MemDbg->fline = line;
110095 + p_MemDbg->size = size+sizeof(t_MemDebug);
110096 + LIST_AddToTail(&p_MemDbg->node, &memDbgLst);
110097 +
110098 + return mem;
110099 +}
110100 +
110101 +void * XX_MallocSmartDebug(uint32_t size,
110102 + int memPartitionId,
110103 + uint32_t align,
110104 + char *fname,
110105 + int line)
110106 +{
110107 + void *mem;
110108 + t_MemDebug *p_MemDbg;
110109 +
110110 + p_MemDbg = (t_MemDebug *)XX_Malloc(sizeof(t_MemDebug));
110111 + if (p_MemDbg == NULL)
110112 + return NULL;
110113 +
110114 + mem = xx_MallocSmart((uint32_t)size, memPartitionId, align);
110115 + if (mem == NULL)
110116 + {
110117 + XX_Free(p_MemDbg);
110118 + return NULL;
110119 + }
110120 +
110121 + INIT_LIST(&p_MemDbg->node);
110122 + p_MemDbg->f_free = xx_FreeSmart;
110123 + p_MemDbg->mem = mem;
110124 + p_MemDbg->fname = fname;
110125 + p_MemDbg->fline = line;
110126 + p_MemDbg->size = size+sizeof(t_MemDebug);
110127 + LIST_AddToTail(&p_MemDbg->node, &memDbgLst);
110128 +
110129 + return mem;
110130 +}
110131 +
110132 +static void debug_free(void *mem)
110133 +{
110134 + t_List *p_MemDbgLh = NULL;
110135 + t_MemDebug *p_MemDbg;
110136 + bool found = FALSE;
110137 +
110138 + if (LIST_IsEmpty(&memDbgLst))
110139 + {
110140 + REPORT_ERROR(MAJOR, E_ALREADY_FREE, ("Unbalanced free (0x%08x)", mem));
110141 + return;
110142 + }
110143 +
110144 + LIST_FOR_EACH(p_MemDbgLh, &memDbgLst)
110145 + {
110146 + p_MemDbg = MEMDBG_OBJECT(p_MemDbgLh);
110147 + if (p_MemDbg->mem == mem)
110148 + {
110149 + found = TRUE;
110150 + break;
110151 + }
110152 + }
110153 +
110154 + if (!found)
110155 + {
110156 + REPORT_ERROR(MAJOR, E_NOT_FOUND,
110157 + ("Attempt to free unallocated address (0x%08x)",mem));
110158 + dump_stack();
110159 + return;
110160 + }
110161 +
110162 + LIST_Del(p_MemDbgLh);
110163 + p_MemDbg->f_free(mem);
110164 + p_MemDbg->f_free(p_MemDbg);
110165 +}
110166 +
110167 +void XX_FreeSmart(void *p)
110168 +{
110169 + debug_free(p);
110170 +}
110171 +
110172 +
110173 +void XX_Free(void *p)
110174 +{
110175 + debug_free(p);
110176 +}
110177 +
110178 +#else /* not DEBUG_XX_MALLOC */
110179 +void * XX_Malloc(uint32_t size)
110180 +{
110181 + return xx_Malloc(size);
110182 +}
110183 +
110184 +void * XX_MallocSmart(uint32_t size, int memPartitionId, uint32_t alignment)
110185 +{
110186 + return xx_MallocSmart(size,memPartitionId, alignment);
110187 +}
110188 +
110189 +void XX_FreeSmart(void *p)
110190 +{
110191 + xx_FreeSmart(p);
110192 +}
110193 +
110194 +
110195 +void XX_Free(void *p)
110196 +{
110197 + xx_Free(p);
110198 +}
110199 +#endif /* not DEBUG_XX_MALLOC */
110200 +
110201 +
110202 +#if (defined(REPORT_EVENTS) && (REPORT_EVENTS > 0))
110203 +void XX_EventById(uint32_t event, t_Handle appId, uint16_t flags, char *msg)
110204 +{
110205 + e_Event eventCode = (e_Event)event;
110206 +
110207 + UNUSED(eventCode);
110208 + UNUSED(appId);
110209 + UNUSED(flags);
110210 + UNUSED(msg);
110211 +}
110212 +#endif /* (defined(REPORT_EVENTS) && ... */
110213 +
110214 +
110215 +uint32_t XX_DisableAllIntr(void)
110216 +{
110217 + unsigned long flags;
110218 +
110219 +#ifdef local_irq_save_nort
110220 + local_irq_save_nort(flags);
110221 +#else
110222 + local_irq_save(flags);
110223 +#endif
110224 +
110225 + return (uint32_t)flags;
110226 +}
110227 +
110228 +void XX_RestoreAllIntr(uint32_t flags)
110229 +{
110230 +#ifdef local_irq_restore_nort
110231 + local_irq_restore_nort((unsigned long)flags);
110232 +#else
110233 + local_irq_restore((unsigned long)flags);
110234 +#endif
110235 +}
110236 +
110237 +t_Error XX_Call( uint32_t qid, t_Error (* f)(t_Handle), t_Handle id, t_Handle appId, uint16_t flags )
110238 +{
110239 + UNUSED(qid);
110240 + UNUSED(appId);
110241 + UNUSED(flags);
110242 +
110243 + return f(id);
110244 +}
110245 +
110246 +int XX_IsICacheEnable(void)
110247 +{
110248 + return TRUE;
110249 +}
110250 +
110251 +int XX_IsDCacheEnable(void)
110252 +{
110253 + return TRUE;
110254 +}
110255 +
110256 +
110257 +typedef struct {
110258 + t_Isr *f_Isr;
110259 + t_Handle handle;
110260 +} t_InterruptHandler;
110261 +
110262 +
110263 +t_Handle interruptHandlers[0x00010000];
110264 +
110265 +#ifdef CONFIG_FMAN_ARM
110266 +static irqreturn_t LinuxInterruptHandler (int irq, void *dev_id)
110267 +{
110268 + t_InterruptHandler *p_IntrHndl = (t_InterruptHandler *)dev_id;
110269 + p_IntrHndl->f_Isr(p_IntrHndl->handle);
110270 + return IRQ_HANDLED;
110271 +}
110272 +#endif
110273 +
110274 +t_Error XX_SetIntr(int irq, t_Isr *f_Isr, t_Handle handle)
110275 +{
110276 +#ifdef CONFIG_FMAN_ARM
110277 + const char *device;
110278 + t_InterruptHandler *p_IntrHndl;
110279 +
110280 + device = GetDeviceName(irq);
110281 + if (device == NULL)
110282 + RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Interrupt source - %d", irq));
110283 +
110284 + p_IntrHndl = (t_InterruptHandler *)XX_Malloc(sizeof(t_InterruptHandler));
110285 + if (p_IntrHndl == NULL)
110286 + RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
110287 + p_IntrHndl->f_Isr = f_Isr;
110288 + p_IntrHndl->handle = handle;
110289 + interruptHandlers[irq] = p_IntrHndl;
110290 +
110291 + if (request_irq(GetDeviceIrqNum(irq), LinuxInterruptHandler, 0, device, p_IntrHndl) < 0)
110292 + RETURN_ERROR(MAJOR, E_BUSY, ("Can't get IRQ %s\n", device));
110293 + disable_irq(GetDeviceIrqNum(irq));
110294 +#endif
110295 + return E_OK;
110296 +}
110297 +
110298 +t_Error XX_FreeIntr(int irq)
110299 +{
110300 + t_InterruptHandler *p_IntrHndl = interruptHandlers[irq];
110301 + free_irq(GetDeviceIrqNum(irq), p_IntrHndl);
110302 + XX_Free(p_IntrHndl);
110303 + interruptHandlers[irq] = 0;
110304 + return E_OK;
110305 +}
110306 +
110307 +t_Error XX_EnableIntr(int irq)
110308 +{
110309 + enable_irq(GetDeviceIrqNum(irq));
110310 + return E_OK;
110311 +}
110312 +
110313 +t_Error XX_DisableIntr(int irq)
110314 +{
110315 + disable_irq(GetDeviceIrqNum(irq));
110316 + return E_OK;
110317 +}
110318 +
110319 +
110320 +/*****************************************************************************/
110321 +/* Tasklet Service Routines */
110322 +/*****************************************************************************/
110323 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
110324 +typedef struct
110325 +{
110326 + t_Handle h_Data;
110327 + void (*f_Callback) (void *);
110328 + struct delayed_work dwork;
110329 +} t_Tasklet;
110330 +
110331 +static void GenericTaskletCallback(struct work_struct *p_Work)
110332 +{
110333 + t_Tasklet *p_Task = container_of(p_Work, t_Tasklet, dwork.work);
110334 +
110335 + p_Task->f_Callback(p_Task->h_Data);
110336 +}
110337 +#endif /* LINUX_VERSION_CODE */
110338 +
110339 +
110340 +t_TaskletHandle XX_InitTasklet (void (*routine)(void *), void *data)
110341 +{
110342 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
110343 + struct work_struct *p_Task;
110344 + p_Task = (struct work_struct *)XX_Malloc(sizeof(struct work_struct));
110345 + INIT_WORK(p_Task, routine, data);
110346 +#else
110347 + t_Tasklet *p_Task = (t_Tasklet *)XX_Malloc(sizeof(t_Tasklet));
110348 + p_Task->h_Data = data;
110349 + p_Task->f_Callback = routine;
110350 + INIT_DELAYED_WORK(&p_Task->dwork, GenericTaskletCallback);
110351 +#endif /* LINUX_VERSION_CODE */
110352 +
110353 + return (t_TaskletHandle)p_Task;
110354 +}
110355 +
110356 +
110357 +void XX_FreeTasklet (t_TaskletHandle h_Tasklet)
110358 +{
110359 + if (h_Tasklet)
110360 + XX_Free(h_Tasklet);
110361 +}
110362 +
110363 +int XX_ScheduleTask(t_TaskletHandle h_Tasklet, int immediate)
110364 +{
110365 + int ans;
110366 +
110367 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
110368 + if (immediate)
110369 + ans = schedule_work(h_Tasklet);
110370 + else
110371 + ans = schedule_delayed_work(h_Tasklet, 1);
110372 +#else
110373 + if (immediate)
110374 + ans = schedule_delayed_work(&((t_Tasklet *)h_Tasklet)->dwork, 0);
110375 + else
110376 + ans = schedule_delayed_work(&((t_Tasklet *)h_Tasklet)->dwork, HZ);
110377 +#endif /* LINUX_VERSION_CODE */
110378 +
110379 + return ans;
110380 +}
110381 +
110382 +void XX_FlushScheduledTasks(void)
110383 +{
110384 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
110385 + flush_scheduled_tasks();
110386 +#else
110387 + flush_scheduled_work();
110388 +#endif /* LINUX_VERSION_CODE */
110389 +}
110390 +
110391 +int XX_TaskletIsQueued(t_TaskletHandle h_Tasklet)
110392 +{
110393 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
110394 + return (int)(((struct work_struct *)h_Tasklet)->pending);
110395 +#else
110396 + return (int)delayed_work_pending(&((t_Tasklet *)h_Tasklet)->dwork);
110397 +#endif /* LINUX_VERSION_CODE */
110398 +}
110399 +
110400 +void XX_SetTaskletData(t_TaskletHandle h_Tasklet, t_Handle data)
110401 +{
110402 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
110403 + ((struct tq_struct *)h_Tasklet)->data = data;
110404 +#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
110405 + ((struct work_struct *)h_Tasklet)->data = data;
110406 +#else
110407 + ((t_Tasklet *)h_Tasklet)->h_Data = data;
110408 +#endif /* LINUX_VERSION_CODE */
110409 +}
110410 +
110411 +t_Handle XX_GetTaskletData(t_TaskletHandle h_Tasklet)
110412 +{
110413 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
110414 + return (t_Handle)(((struct work_struct *)h_Tasklet)->data);
110415 +#else
110416 + return ((t_Tasklet *)h_Tasklet)->h_Data;
110417 +#endif /* LINUX_VERSION_CODE */
110418 +}
110419 +
110420 +
110421 +/*****************************************************************************/
110422 +/* Spinlock Service Routines */
110423 +/*****************************************************************************/
110424 +
110425 +t_Handle XX_InitSpinlock(void)
110426 +{
110427 + spinlock_t *p_Spinlock = (spinlock_t *)XX_Malloc(sizeof(spinlock_t));
110428 + if (!p_Spinlock)
110429 + return NULL;
110430 +
110431 + spin_lock_init(p_Spinlock);
110432 +
110433 + return (t_Handle)p_Spinlock;
110434 +}
110435 +
110436 +void XX_FreeSpinlock(t_Handle h_Spinlock)
110437 +{
110438 + if (h_Spinlock)
110439 + XX_Free(h_Spinlock);
110440 +}
110441 +
110442 +void XX_LockSpinlock(t_Handle h_Spinlock)
110443 +{
110444 + spin_lock((spinlock_t *)h_Spinlock);
110445 +}
110446 +
110447 +void XX_UnlockSpinlock(t_Handle h_Spinlock)
110448 +{
110449 + spin_unlock((spinlock_t *)h_Spinlock);
110450 +}
110451 +
110452 +uint32_t XX_LockIntrSpinlock(t_Handle h_Spinlock)
110453 +{
110454 + unsigned long intrFlags;
110455 + spin_lock_irqsave((spinlock_t *)h_Spinlock, intrFlags);
110456 + return intrFlags;
110457 +}
110458 +
110459 +void XX_UnlockIntrSpinlock(t_Handle h_Spinlock, uint32_t intrFlags)
110460 +{
110461 + spin_unlock_irqrestore((spinlock_t *)h_Spinlock, (unsigned long)intrFlags);
110462 +}
110463 +
110464 +
110465 +/*****************************************************************************/
110466 +/* Timers Service Routines */
110467 +/*****************************************************************************/
110468 +/* The time now is in mili sec. resolution */
110469 +uint32_t XX_CurrentTime(void)
110470 +{
110471 + return (jiffies*1000)/HZ;
110472 +}
110473 +
110474 +
110475 +t_Handle XX_CreateTimer(void)
110476 +{
110477 + struct timer_list *p_Timer = (struct timer_list *)XX_Malloc(sizeof(struct timer_list));
110478 + if (p_Timer)
110479 + {
110480 + memset(p_Timer, 0, sizeof(struct timer_list));
110481 + init_timer(p_Timer);
110482 + }
110483 + return (t_Handle)p_Timer;
110484 +}
110485 +
110486 +void XX_FreeTimer(t_Handle h_Timer)
110487 +{
110488 + if (h_Timer)
110489 + XX_Free(h_Timer);
110490 +}
110491 +
110492 +void XX_StartTimer(t_Handle h_Timer,
110493 + uint32_t msecs,
110494 + bool periodic,
110495 + void (*f_TimerExpired)(t_Handle),
110496 + t_Handle h_Arg)
110497 +{
110498 + int tmp_jiffies = (msecs*HZ)/1000;
110499 + struct timer_list *p_Timer = (struct timer_list *)h_Timer;
110500 +
110501 + SANITY_CHECK_RETURN((periodic == FALSE), E_NOT_SUPPORTED);
110502 +
110503 + p_Timer->function = (void (*)(unsigned long))f_TimerExpired;
110504 + p_Timer->data = (unsigned long)h_Arg;
110505 + if ((msecs*HZ)%1000)
110506 + tmp_jiffies++;
110507 + p_Timer->expires = (jiffies + tmp_jiffies);
110508 +
110509 + add_timer((struct timer_list *)h_Timer);
110510 +}
110511 +
110512 +void XX_SetTimerData(t_Handle h_Timer, t_Handle data)
110513 +{
110514 + struct timer_list *p_Timer = (struct timer_list *)h_Timer;
110515 +
110516 + p_Timer->data = (unsigned long)data;
110517 +}
110518 +
110519 +t_Handle XX_GetTimerData(t_Handle h_Timer)
110520 +{
110521 + struct timer_list *p_Timer = (struct timer_list *)h_Timer;
110522 +
110523 + return (t_Handle)p_Timer->data;
110524 +}
110525 +
110526 +uint32_t XX_GetExpirationTime(t_Handle h_Timer)
110527 +{
110528 + struct timer_list *p_Timer = (struct timer_list *)h_Timer;
110529 +
110530 + return (uint32_t)p_Timer->expires;
110531 +}
110532 +
110533 +void XX_StopTimer(t_Handle h_Timer)
110534 +{
110535 + del_timer((struct timer_list *)h_Timer);
110536 +}
110537 +
110538 +void XX_ModTimer(t_Handle h_Timer, uint32_t msecs)
110539 +{
110540 + int tmp_jiffies = (msecs*HZ)/1000;
110541 +
110542 + if ((msecs*HZ)%1000)
110543 + tmp_jiffies++;
110544 + mod_timer((struct timer_list *)h_Timer, jiffies + tmp_jiffies);
110545 +}
110546 +
110547 +int XX_TimerIsActive(t_Handle h_Timer)
110548 +{
110549 + return timer_pending((struct timer_list *)h_Timer);
110550 +}
110551 +
110552 +uint32_t XX_Sleep(uint32_t msecs)
110553 +{
110554 + int tmp_jiffies = (msecs*HZ)/1000;
110555 +
110556 + if ((msecs*HZ)%1000)
110557 + tmp_jiffies++;
110558 + return schedule_timeout(tmp_jiffies);
110559 +}
110560 +
110561 +/*BEWARE!!!!! UDelay routine is BUSY WAITTING!!!!!*/
110562 +void XX_UDelay(uint32_t usecs)
110563 +{
110564 + udelay(usecs);
110565 +}
110566 +
110567 +/* TODO: verify that these are correct */
110568 +#define MSG_BODY_SIZE 512
110569 +typedef t_Error (t_MsgHandler) (t_Handle h_Mod, uint32_t msgId, uint8_t msgBody[MSG_BODY_SIZE]);
110570 +typedef void (t_MsgCompletionCB) (t_Handle h_Arg, uint8_t msgBody[MSG_BODY_SIZE]);
110571 +t_Error XX_SendMessage(char *p_DestAddr,
110572 + uint32_t msgId,
110573 + uint8_t msgBody[MSG_BODY_SIZE],
110574 + t_MsgCompletionCB *f_CompletionCB,
110575 + t_Handle h_CBArg);
110576 +
110577 +typedef struct {
110578 + char *p_Addr;
110579 + t_MsgHandler *f_MsgHandlerCB;
110580 + t_Handle h_Mod;
110581 + t_List node;
110582 +} t_MsgHndlr;
110583 +#define MSG_HNDLR_OBJECT(ptr) LIST_OBJECT(ptr, t_MsgHndlr, node)
110584 +
110585 +LIST(msgHndlrList);
110586 +
110587 +static void EnqueueMsgHndlr(t_MsgHndlr *p_MsgHndlr)
110588 +{
110589 + uint32_t intFlags;
110590 +
110591 + intFlags = XX_DisableAllIntr();
110592 + LIST_AddToTail(&p_MsgHndlr->node, &msgHndlrList);
110593 + XX_RestoreAllIntr(intFlags);
110594 +}
110595 +/* TODO: add this for multi-platform support
110596 +static t_MsgHndlr * DequeueMsgHndlr(void)
110597 +{
110598 + t_MsgHndlr *p_MsgHndlr = NULL;
110599 + uint32_t intFlags;
110600 +
110601 + intFlags = XX_DisableAllIntr();
110602 + if (!LIST_IsEmpty(&msgHndlrList))
110603 + {
110604 + p_MsgHndlr = MSG_HNDLR_OBJECT(msgHndlrList.p_Next);
110605 + LIST_DelAndInit(&p_MsgHndlr->node);
110606 + }
110607 + XX_RestoreAllIntr(intFlags);
110608 +
110609 + return p_MsgHndlr;
110610 +}
110611 +*/
110612 +static t_MsgHndlr * FindMsgHndlr(char *p_Addr)
110613 +{
110614 + t_MsgHndlr *p_MsgHndlr;
110615 + t_List *p_Pos;
110616 +
110617 + LIST_FOR_EACH(p_Pos, &msgHndlrList)
110618 + {
110619 + p_MsgHndlr = MSG_HNDLR_OBJECT(p_Pos);
110620 + if (strstr(p_MsgHndlr->p_Addr, p_Addr))
110621 + return p_MsgHndlr;
110622 + }
110623 +
110624 + return NULL;
110625 +}
110626 +
110627 +t_Error XX_RegisterMessageHandler (char *p_Addr, t_MsgHandler *f_MsgHandlerCB, t_Handle h_Mod)
110628 +{
110629 + t_MsgHndlr *p_MsgHndlr;
110630 + uint32_t len;
110631 +
110632 + p_MsgHndlr = (t_MsgHndlr*)XX_Malloc(sizeof(t_MsgHndlr));
110633 + if (!p_MsgHndlr)
110634 + RETURN_ERROR(MINOR, E_NO_MEMORY, ("message handler object!!!"));
110635 + memset(p_MsgHndlr, 0, sizeof(t_MsgHndlr));
110636 +
110637 + len = strlen(p_Addr);
110638 + p_MsgHndlr->p_Addr = (char*)XX_Malloc(len+1);
110639 + strncpy(p_MsgHndlr->p_Addr,p_Addr, (uint32_t)(len+1));
110640 +
110641 + p_MsgHndlr->f_MsgHandlerCB = f_MsgHandlerCB;
110642 + p_MsgHndlr->h_Mod = h_Mod;
110643 + INIT_LIST(&p_MsgHndlr->node);
110644 + EnqueueMsgHndlr(p_MsgHndlr);
110645 +
110646 + return E_OK;
110647 +}
110648 +
110649 +t_Error XX_UnregisterMessageHandler (char *p_Addr)
110650 +{
110651 + t_MsgHndlr *p_MsgHndlr = FindMsgHndlr(p_Addr);
110652 + if (!p_MsgHndlr)
110653 + RETURN_ERROR(MINOR, E_NO_DEVICE, ("message handler not found in list!!!"));
110654 +
110655 + LIST_Del(&p_MsgHndlr->node);
110656 + XX_Free(p_MsgHndlr->p_Addr);
110657 + XX_Free(p_MsgHndlr);
110658 +
110659 + return E_OK;
110660 +}
110661 +
110662 +t_Error XX_SendMessage(char *p_DestAddr,
110663 + uint32_t msgId,
110664 + uint8_t msgBody[MSG_BODY_SIZE],
110665 + t_MsgCompletionCB *f_CompletionCB,
110666 + t_Handle h_CBArg)
110667 +{
110668 + t_Error ans;
110669 + t_MsgHndlr *p_MsgHndlr = FindMsgHndlr(p_DestAddr);
110670 + if (!p_MsgHndlr)
110671 + RETURN_ERROR(MINOR, E_NO_DEVICE, ("message handler not found in list!!!"));
110672 +
110673 + ans = p_MsgHndlr->f_MsgHandlerCB(p_MsgHndlr->h_Mod, msgId, msgBody);
110674 +
110675 + if (f_CompletionCB)
110676 + f_CompletionCB(h_CBArg, msgBody);
110677 +
110678 + return ans;
110679 +}
110680 +
110681 +t_Error XX_IpcRegisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH],
110682 + t_IpcMsgHandler *f_MsgHandler,
110683 + t_Handle h_Module,
110684 + uint32_t replyLength)
110685 +{
110686 + UNUSED(addr);UNUSED(f_MsgHandler);UNUSED(h_Module);UNUSED(replyLength);
110687 + return E_OK;
110688 +}
110689 +
110690 +t_Error XX_IpcUnregisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH])
110691 +{
110692 + UNUSED(addr);
110693 + return E_OK;
110694 +}
110695 +
110696 +
110697 +t_Error XX_IpcSendMessage(t_Handle h_Session,
110698 + uint8_t *p_Msg,
110699 + uint32_t msgLength,
110700 + uint8_t *p_Reply,
110701 + uint32_t *p_ReplyLength,
110702 + t_IpcMsgCompletion *f_Completion,
110703 + t_Handle h_Arg)
110704 +{
110705 + UNUSED(h_Session); UNUSED(p_Msg); UNUSED(msgLength); UNUSED(p_Reply);
110706 + UNUSED(p_ReplyLength); UNUSED(f_Completion); UNUSED(h_Arg);
110707 + return E_OK;
110708 +}
110709 +
110710 +t_Handle XX_IpcInitSession(char destAddr[XX_IPC_MAX_ADDR_NAME_LENGTH],
110711 + char srcAddr[XX_IPC_MAX_ADDR_NAME_LENGTH])
110712 +{
110713 + UNUSED(destAddr); UNUSED(srcAddr);
110714 + return E_OK;
110715 +}
110716 +
110717 +/*Forced to introduce due to PRINT_FMT_PARAMS define*/
110718 +uint32_t E500_GetId(void)
110719 +{
110720 + return raw_smp_processor_id();
110721 +}
110722 +
110723 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
110724 +int GetDeviceIrqNum(int irq)
110725 +{
110726 + struct device_node *iPar;
110727 + struct irq_domain *irqHost;
110728 + uint32_t hwIrq;
110729 +
110730 + /* Get the interrupt controller */
110731 + iPar = of_find_node_by_name(NULL, "mpic");
110732 + hwIrq = 0;
110733 +
110734 + ASSERT_COND(iPar != NULL);
110735 + /* Get the irq host */
110736 + irqHost = irq_find_host(iPar);
110737 + of_node_put(iPar);
110738 +
110739 + /* Create irq mapping */
110740 + return irq_create_mapping(irqHost, hwIrq);
110741 +}
110742 +#else
110743 +#error "kernel not supported!!!"
110744 +#endif /* LINUX_VERSION_CODE */
110745 +
110746 +void * XX_PhysToVirt(physAddress_t addr)
110747 +{
110748 + return UINT_TO_PTR(SYS_PhysToVirt((uint64_t)addr));
110749 +}
110750 +
110751 +physAddress_t XX_VirtToPhys(void * addr)
110752 +{
110753 + return (physAddress_t)SYS_VirtToPhys(PTR_TO_UINT(addr));
110754 +}
110755 +
110756 +void * xx_MallocSmart(uint32_t size, int memPartitionId, uint32_t alignment)
110757 +{
110758 + uintptr_t *returnCode, tmp;
110759 +
110760 + if (alignment < sizeof(uintptr_t))
110761 + alignment = sizeof(uintptr_t);
110762 + size += alignment + sizeof(returnCode);
110763 + tmp = (uintptr_t)xx_Malloc(size);
110764 + if (tmp == 0)
110765 + return NULL;
110766 + returnCode = (uintptr_t*)((tmp + alignment + sizeof(returnCode)) & ~((uintptr_t)alignment - 1));
110767 + *(returnCode - 1) = tmp;
110768 +
110769 + return (void*)returnCode;
110770 +}
110771 +
110772 +void xx_FreeSmart(void *p)
110773 +{
110774 + xx_Free((void*)(*((uintptr_t *)(p) - 1)));
110775 +}
110776 --- /dev/null
110777 +++ b/include/uapi/linux/fmd/Kbuild
110778 @@ -0,0 +1,5 @@
110779 +header-y += integrations/
110780 +header-y += Peripherals/
110781 +
110782 +header-y += ioctls.h
110783 +header-y += net_ioctls.h
110784 --- /dev/null
110785 +++ b/include/uapi/linux/fmd/Peripherals/Kbuild
110786 @@ -0,0 +1,4 @@
110787 +header-y += fm_ioctls.h
110788 +header-y += fm_port_ioctls.h
110789 +header-y += fm_pcd_ioctls.h
110790 +header-y += fm_test_ioctls.h
110791 --- /dev/null
110792 +++ b/include/uapi/linux/fmd/Peripherals/fm_ioctls.h
110793 @@ -0,0 +1,628 @@
110794 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc.
110795 + * All rights reserved.
110796 + *
110797 + * Redistribution and use in source and binary forms, with or without
110798 + * modification, are permitted provided that the following conditions are met:
110799 + * * Redistributions of source code must retain the above copyright
110800 + * notice, this list of conditions and the following disclaimer.
110801 + * * Redistributions in binary form must reproduce the above copyright
110802 + * notice, this list of conditions and the following disclaimer in the
110803 + * documentation and/or other materials provided with the distribution.
110804 + * * Neither the name of Freescale Semiconductor nor the
110805 + * names of its contributors may be used to endorse or promote products
110806 + * derived from this software without specific prior written permission.
110807 + *
110808 + *
110809 + * ALTERNATIVELY, this software may be distributed under the terms of the
110810 + * GNU General Public License ("GPL") as published by the Free Software
110811 + * Foundation, either version 2 of that License or (at your option) any
110812 + * later version.
110813 + *
110814 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
110815 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
110816 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
110817 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
110818 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
110819 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
110820 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
110821 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
110822 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
110823 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
110824 + */
110825 +
110826 +/**************************************************************************//**
110827 + @File fm_ioctls.h
110828 +
110829 + @Description FM Char device ioctls
110830 +*//***************************************************************************/
110831 +#ifndef __FM_IOCTLS_H
110832 +#define __FM_IOCTLS_H
110833 +
110834 +
110835 +/**************************************************************************//**
110836 + @Group lnx_ioctl_FM_grp Frame Manager Linux IOCTL API
110837 +
110838 + @Description FM Linux ioctls definitions and enums
110839 +
110840 + @{
110841 +*//***************************************************************************/
110842 +
110843 +/**************************************************************************//**
110844 + @Collection FM IOCTL device ('/dev') definitions
110845 +*//***************************************************************************/
110846 +#define DEV_FM_NAME "fm" /**< Name of the FM chardev */
110847 +
110848 +#define DEV_FM_MINOR_BASE 0
110849 +#define DEV_FM_PCD_MINOR_BASE (DEV_FM_MINOR_BASE + 1) /*/dev/fmx-pcd */
110850 +#define DEV_FM_OH_PORTS_MINOR_BASE (DEV_FM_PCD_MINOR_BASE + 1) /*/dev/fmx-port-ohy */
110851 +#define DEV_FM_RX_PORTS_MINOR_BASE (DEV_FM_OH_PORTS_MINOR_BASE + FM_MAX_NUM_OF_OH_PORTS) /*/dev/fmx-port-rxy */
110852 +#define DEV_FM_TX_PORTS_MINOR_BASE (DEV_FM_RX_PORTS_MINOR_BASE + FM_MAX_NUM_OF_RX_PORTS) /*/dev/fmx-port-txy */
110853 +#define DEV_FM_MAX_MINORS (DEV_FM_TX_PORTS_MINOR_BASE + FM_MAX_NUM_OF_TX_PORTS)
110854 +
110855 +#define FM_IOC_NUM(n) (n)
110856 +#define FM_PCD_IOC_NUM(n) (n+20)
110857 +#define FM_PORT_IOC_NUM(n) (n+70)
110858 +/* @} */
110859 +
110860 +#define IOC_FM_MAX_NUM_OF_PORTS 64
110861 +
110862 +
110863 +/**************************************************************************//**
110864 + @Description Enum for defining port types
110865 + (must match enum e_FmPortType defined in fm_ext.h)
110866 +*//***************************************************************************/
110867 +typedef enum ioc_fm_port_type {
110868 + e_IOC_FM_PORT_TYPE_OH_OFFLINE_PARSING = 0, /**< Offline parsing port */
110869 + e_IOC_FM_PORT_TYPE_RX, /**< 1G Rx port */
110870 + e_IOC_FM_PORT_TYPE_RX_10G, /**< 10G Rx port */
110871 + e_IOC_FM_PORT_TYPE_TX, /**< 1G Tx port */
110872 + e_IOC_FM_PORT_TYPE_TX_10G, /**< 10G Tx port */
110873 + e_IOC_FM_PORT_TYPE_DUMMY
110874 +} ioc_fm_port_type;
110875 +
110876 +
110877 +/**************************************************************************//**
110878 + @Group lnx_ioctl_FM_lib_grp FM library
110879 +
110880 + @Description FM API functions, definitions and enums
110881 + The FM module is the main driver module and is a mandatory module
110882 + for FM driver users. Before any further module initialization,
110883 + this module must be initialized.
110884 + The FM is a "single-tone" module. It is responsible of the common
110885 + HW modules: FPM, DMA, common QMI, common BMI initializations and
110886 + run-time control routines. This module must be initialized always
110887 + when working with any of the FM modules.
110888 + NOTE - We assumes that the FML will be initialize only by core No. 0!
110889 +
110890 + @{
110891 +*//***************************************************************************/
110892 +
110893 +/**************************************************************************//**
110894 + @Description FM Exceptions
110895 +*//***************************************************************************/
110896 +typedef enum ioc_fm_exceptions {
110897 + e_IOC_FM_EX_DMA_BUS_ERROR, /**< DMA bus error. */
110898 + e_IOC_EX_DMA_READ_ECC, /**< Read Buffer ECC error (Valid for FM rev < 6)*/
110899 + e_IOC_EX_DMA_SYSTEM_WRITE_ECC, /**< Write Buffer ECC error on system side (Valid for FM rev < 6)*/
110900 + e_IOC_EX_DMA_FM_WRITE_ECC, /**< Write Buffer ECC error on FM side (Valid for FM rev < 6)*/
110901 + e_IOC_EX_DMA_SINGLE_PORT_ECC, /**< Single Port ECC error on FM side (Valid for FM rev > 6)*/
110902 + e_IOC_EX_FPM_STALL_ON_TASKS, /**< Stall of tasks on FPM */
110903 + e_IOC_EX_FPM_SINGLE_ECC, /**< Single ECC on FPM. */
110904 + e_IOC_EX_FPM_DOUBLE_ECC, /**< Double ECC error on FPM ram access */
110905 + e_IOC_EX_QMI_SINGLE_ECC, /**< Single ECC on QMI. */
110906 + e_IOC_EX_QMI_DOUBLE_ECC, /**< Double bit ECC occurred on QMI */
110907 + e_IOC_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,/**< Dequeue from unknown port id */
110908 + e_IOC_EX_BMI_LIST_RAM_ECC, /**< Linked List RAM ECC error */
110909 + e_IOC_EX_BMI_STORAGE_PROFILE_ECC, /**< Storage Profile ECC Error */
110910 + e_IOC_EX_BMI_STATISTICS_RAM_ECC, /**< Statistics Count RAM ECC Error Enable */
110911 + e_IOC_EX_BMI_DISPATCH_RAM_ECC, /**< Dispatch RAM ECC Error Enable */
110912 + e_IOC_EX_IRAM_ECC, /**< Double bit ECC occurred on IRAM*/
110913 + e_IOC_EX_MURAM_ECC /**< Double bit ECC occurred on MURAM*/
110914 +} ioc_fm_exceptions;
110915 +
110916 +/**************************************************************************//**
110917 + @Group lnx_ioctl_FM_runtime_control_grp FM Runtime Control Unit
110918 +
110919 + @Description FM Runtime control unit API functions, definitions and enums.
110920 + The FM driver provides a set of control routines for each module.
110921 + These routines may only be called after the module was fully
110922 + initialized (both configuration and initialization routines were
110923 + called). They are typically used to get information from hardware
110924 + (status, counters/statistics, revision etc.), to modify a current
110925 + state or to force/enable a required action. Run-time control may
110926 + be called whenever necessary and as many times as needed.
110927 + @{
110928 +*//***************************************************************************/
110929 +
110930 +/**************************************************************************//**
110931 + @Collection General FM defines.
110932 + *//***************************************************************************/
110933 +#define IOC_FM_MAX_NUM_OF_VALID_PORTS (FM_MAX_NUM_OF_OH_PORTS + \
110934 + FM_MAX_NUM_OF_1G_RX_PORTS + \
110935 + FM_MAX_NUM_OF_10G_RX_PORTS + \
110936 + FM_MAX_NUM_OF_1G_TX_PORTS + \
110937 + FM_MAX_NUM_OF_10G_TX_PORTS)
110938 +/* @} */
110939 +
110940 +/**************************************************************************//**
110941 + @Description Structure for Port bandwidth requirement. Port is identified
110942 + by type and relative id.
110943 + (must be identical to t_FmPortBandwidth defined in fm_ext.h)
110944 +*//***************************************************************************/
110945 +typedef struct ioc_fm_port_bandwidth_t {
110946 + ioc_fm_port_type type; /**< FM port type */
110947 + uint8_t relative_port_id; /**< Type relative port id */
110948 + uint8_t bandwidth; /**< bandwidth - (in term of percents) */
110949 +} ioc_fm_port_bandwidth_t;
110950 +
110951 +/**************************************************************************//**
110952 + @Description A Structure containing an array of Port bandwidth requirements.
110953 + The user should state the ports requiring bandwidth in terms of
110954 + percentage - i.e. all port's bandwidths in the array must add
110955 + up to 100.
110956 + (must be identical to t_FmPortsBandwidthParams defined in fm_ext.h)
110957 +*//***************************************************************************/
110958 +typedef struct ioc_fm_port_bandwidth_params {
110959 + uint8_t num_of_ports;
110960 + /**< num of ports listed in the array below */
110961 + ioc_fm_port_bandwidth_t ports_bandwidths[IOC_FM_MAX_NUM_OF_VALID_PORTS];
110962 + /**< for each port, it's bandwidth (all port's
110963 + bandwidths must add up to 100.*/
110964 +} ioc_fm_port_bandwidth_params;
110965 +
110966 +/**************************************************************************//**
110967 + @Description enum for defining FM counters
110968 +*//***************************************************************************/
110969 +typedef enum ioc_fm_counters {
110970 + e_IOC_FM_COUNTERS_ENQ_TOTAL_FRAME, /**< QMI total enqueued frames counter */
110971 + e_IOC_FM_COUNTERS_DEQ_TOTAL_FRAME, /**< QMI total dequeued frames counter */
110972 + e_IOC_FM_COUNTERS_DEQ_0, /**< QMI 0 frames from QMan counter */
110973 + e_IOC_FM_COUNTERS_DEQ_1, /**< QMI 1 frames from QMan counter */
110974 + e_IOC_FM_COUNTERS_DEQ_2, /**< QMI 2 frames from QMan counter */
110975 + e_IOC_FM_COUNTERS_DEQ_3, /**< QMI 3 frames from QMan counter */
110976 + e_IOC_FM_COUNTERS_DEQ_FROM_DEFAULT, /**< QMI dequeue from default queue counter */
110977 + e_IOC_FM_COUNTERS_DEQ_FROM_CONTEXT, /**< QMI dequeue from FQ context counter */
110978 + e_IOC_FM_COUNTERS_DEQ_FROM_FD, /**< QMI dequeue from FD command field counter */
110979 + e_IOC_FM_COUNTERS_DEQ_CONFIRM, /**< QMI dequeue confirm counter */
110980 +} ioc_fm_counters;
110981 +
110982 +typedef struct ioc_fm_obj_t {
110983 + void *obj;
110984 +} ioc_fm_obj_t;
110985 +
110986 +/**************************************************************************//**
110987 + @Description A structure for returning revision information
110988 + (must match struct t_FmRevisionInfo declared in fm_ext.h)
110989 +*//***************************************************************************/
110990 +typedef struct ioc_fm_revision_info_t {
110991 + uint8_t major; /**< Major revision */
110992 + uint8_t minor; /**< Minor revision */
110993 +} ioc_fm_revision_info_t;
110994 +
110995 +/**************************************************************************//**
110996 + @Description A structure for FM counters
110997 +*//***************************************************************************/
110998 +typedef struct ioc_fm_counters_params_t {
110999 + ioc_fm_counters cnt; /**< The requested counter */
111000 + uint32_t val; /**< The requested value to get/set from/into the counter */
111001 +} ioc_fm_counters_params_t;
111002 +
111003 +typedef union ioc_fm_api_version_t {
111004 + struct {
111005 + uint8_t major;
111006 + uint8_t minor;
111007 + uint8_t respin;
111008 + uint8_t reserved;
111009 + } version;
111010 + uint32_t ver;
111011 +} ioc_fm_api_version_t;
111012 +
111013 +#if (DPAA_VERSION >= 11)
111014 +/**************************************************************************//**
111015 + @Description A structure of information about each of the external
111016 + buffer pools used by a port or storage-profile.
111017 + (must be identical to t_FmExtPoolParams defined in fm_ext.h)
111018 +*//***************************************************************************/
111019 +typedef struct ioc_fm_ext_pool_params {
111020 + uint8_t id; /**< External buffer pool id */
111021 + uint16_t size; /**< External buffer pool buffer size */
111022 +} ioc_fm_ext_pool_params;
111023 +
111024 +/**************************************************************************//**
111025 + @Description A structure for informing the driver about the external
111026 + buffer pools allocated in the BM and used by a port or a
111027 + storage-profile.
111028 + (must be identical to t_FmExtPools defined in fm_ext.h)
111029 +*//***************************************************************************/
111030 +typedef struct ioc_fm_ext_pools {
111031 + uint8_t num_of_pools_used; /**< Number of pools use by this port */
111032 + ioc_fm_ext_pool_params ext_buf_pool[FM_PORT_MAX_NUM_OF_EXT_POOLS];
111033 + /**< Parameters for each port */
111034 +} ioc_fm_ext_pools;
111035 +
111036 +typedef struct ioc_fm_vsp_params_t {
111037 + void *p_fm; /**< A handle to the FM object this VSP related to */
111038 + ioc_fm_ext_pools ext_buf_pools; /**< Which external buffer pools are used
111039 + (up to FM_PORT_MAX_NUM_OF_EXT_POOLS), and their sizes.
111040 + parameter associated with Rx / OP port */
111041 + uint16_t liodn_offset; /**< VSP's LIODN offset */
111042 + struct {
111043 + ioc_fm_port_type port_type; /**< Port type */
111044 + uint8_t port_id; /**< Port Id - relative to type */
111045 + } port_params;
111046 + uint8_t relative_profile_id; /**< VSP Id - relative to VSP's range
111047 + defined in relevant FM object */
111048 + void *id; /**< return value */
111049 +} ioc_fm_vsp_params_t;
111050 +#endif /* (DPAA_VERSION >= 11) */
111051 +
111052 +/**************************************************************************//**
111053 + @Description A structure for defining BM pool depletion criteria
111054 +*//***************************************************************************/
111055 +typedef struct ioc_fm_buf_pool_depletion_t {
111056 + bool pools_grp_mode_enable; /**< select mode in which pause frames will be sent after
111057 + a number of pools (all together!) are depleted */
111058 + uint8_t num_of_pools; /**< the number of depleted pools that will invoke
111059 + pause frames transmission. */
111060 + bool pools_to_consider[BM_MAX_NUM_OF_POOLS];
111061 + /**< For each pool, TRUE if it should be considered for
111062 + depletion (Note - this pool must be used by this port!). */
111063 + bool single_pool_mode_enable; /**< select mode in which pause frames will be sent after
111064 + a single-pool is depleted; */
111065 + bool pools_to_consider_for_single_mode[BM_MAX_NUM_OF_POOLS];
111066 + /**< For each pool, TRUE if it should be considered for
111067 + depletion (Note - this pool must be used by this port!) */
111068 +#if (DPAA_VERSION >= 11)
111069 + bool pfc_priorities_en[FM_MAX_NUM_OF_PFC_PRIORITIES];
111070 + /**< This field is used by the MAC as the Priority Enable Vector in the PFC frame
111071 + which is transmitted */
111072 +#endif /* (DPAA_VERSION >= 11) */
111073 +} ioc_fm_buf_pool_depletion_t;
111074 +
111075 +#if (DPAA_VERSION >= 11)
111076 +typedef struct ioc_fm_buf_pool_depletion_params_t {
111077 + void *p_fm_vsp;
111078 + ioc_fm_buf_pool_depletion_t fm_buf_pool_depletion;
111079 +} ioc_fm_buf_pool_depletion_params_t;
111080 +#endif /* (DPAA_VERSION >= 11) */
111081 +
111082 +typedef struct ioc_fm_buffer_prefix_content_t {
111083 + uint16_t priv_data_size; /**< Number of bytes to be left at the beginning
111084 + of the external buffer; Note that the private-area will
111085 + start from the base of the buffer address. */
111086 + bool pass_prs_result; /**< TRUE to pass the parse result to/from the FM;
111087 + User may use FM_PORT_GetBufferPrsResult() in order to
111088 + get the parser-result from a buffer. */
111089 + bool pass_time_stamp; /**< TRUE to pass the timeStamp to/from the FM
111090 + User may use FM_PORT_GetBufferTimeStamp() in order to
111091 + get the parser-result from a buffer. */
111092 + bool pass_hash_result; /**< TRUE to pass the KG hash result to/from the FM
111093 + User may use FM_PORT_GetBufferHashResult() in order to
111094 + get the parser-result from a buffer. */
111095 + bool pass_all_other_pcd_info; /**< Add all other Internal-Context information:
111096 + AD, hash-result, key, etc. */
111097 + uint16_t data_align; /**< 0 to use driver's default alignment [64],
111098 + other value for selecting a data alignment (must be a power of 2);
111099 + if write optimization is used, must be >= 16. */
111100 + uint8_t manip_extra_space; /**< Maximum extra size needed (insertion-size minus removal-size);
111101 + Note that this field impacts the size of the buffer-prefix
111102 + (i.e. it pushes the data offset);
111103 + This field is irrelevant if DPAA_VERSION==10 */
111104 +} ioc_fm_buffer_prefix_content_t;
111105 +
111106 +typedef struct ioc_fm_buffer_prefix_content_params_t {
111107 + void *p_fm_vsp;
111108 + ioc_fm_buffer_prefix_content_t fm_buffer_prefix_content;
111109 +} ioc_fm_buffer_prefix_content_params_t;
111110 +
111111 +#if (DPAA_VERSION >= 11)
111112 +typedef struct ioc_fm_vsp_config_no_sg_params_t {
111113 + void *p_fm_vsp;
111114 + bool no_sg;
111115 +} ioc_fm_vsp_config_no_sg_params_t;
111116 +
111117 +typedef struct ioc_fm_vsp_prs_result_params_t {
111118 + void *p_fm_vsp;
111119 + void *p_data;
111120 +} ioc_fm_vsp_prs_result_params_t;
111121 +#endif
111122 +
111123 +typedef struct fm_ctrl_mon_t {
111124 + uint8_t percent_cnt[2];
111125 +} fm_ctrl_mon_t;
111126 +
111127 +typedef struct ioc_fm_ctrl_mon_counters_params_t {
111128 + uint8_t fm_ctrl_index;
111129 + fm_ctrl_mon_t *p_mon;
111130 +} ioc_fm_ctrl_mon_counters_params_t;
111131 +
111132 +/**************************************************************************//**
111133 + @Function FM_IOC_SET_PORTS_BANDWIDTH
111134 +
111135 + @Description Sets relative weights between ports when accessing common resources.
111136 +
111137 + @Param[in] ioc_fm_port_bandwidth_params Port bandwidth percentages,
111138 + their sum must equal 100.
111139 +
111140 + @Return E_OK on success; Error code otherwise.
111141 +
111142 + @Cautions Allowed only following FM_Init().
111143 +*//***************************************************************************/
111144 +#define FM_IOC_SET_PORTS_BANDWIDTH _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(2), ioc_fm_port_bandwidth_params)
111145 +
111146 +/**************************************************************************//**
111147 + @Function FM_IOC_GET_REVISION
111148 +
111149 + @Description Returns the FM revision
111150 +
111151 + @Param[out] ioc_fm_revision_info_t A structure of revision information parameters.
111152 +
111153 + @Return None.
111154 +
111155 + @Cautions Allowed only following FM_Init().
111156 +*//***************************************************************************/
111157 +#define FM_IOC_GET_REVISION _IOR(FM_IOC_TYPE_BASE, FM_IOC_NUM(3), ioc_fm_revision_info_t)
111158 +
111159 +/**************************************************************************//**
111160 + @Function FM_IOC_GET_COUNTER
111161 +
111162 + @Description Reads one of the FM counters.
111163 +
111164 + @Param[in,out] ioc_fm_counters_params_t The requested counter parameters.
111165 +
111166 + @Return Counter's current value.
111167 +
111168 + @Cautions Allowed only following FM_Init().
111169 + Note that it is user's responsibilty to call this routine only
111170 + for enabled counters, and there will be no indication if a
111171 + disabled counter is accessed.
111172 +*//***************************************************************************/
111173 +#define FM_IOC_GET_COUNTER _IOWR(FM_IOC_TYPE_BASE, FM_IOC_NUM(4), ioc_fm_counters_params_t)
111174 +
111175 +/**************************************************************************//**
111176 + @Function FM_IOC_SET_COUNTER
111177 +
111178 + @Description Sets a value to an enabled counter. Use "0" to reset the counter.
111179 +
111180 + @Param[in] ioc_fm_counters_params_t The requested counter parameters.
111181 +
111182 + @Return E_OK on success; Error code otherwise.
111183 +
111184 + @Cautions Allowed only following FM_Init().
111185 +*//***************************************************************************/
111186 +#define FM_IOC_SET_COUNTER _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(5), ioc_fm_counters_params_t)
111187 +
111188 +/**************************************************************************//**
111189 + @Function FM_IOC_FORCE_INTR
111190 +
111191 + @Description Causes an interrupt event on the requested source.
111192 +
111193 + @Param[in] ioc_fm_exceptions An exception to be forced.
111194 +
111195 + @Return E_OK on success; Error code if the exception is not enabled,
111196 + or is not able to create interrupt.
111197 +
111198 + @Cautions Allowed only following FM_Init().
111199 +*//***************************************************************************/
111200 +#define FM_IOC_FORCE_INTR _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(6), ioc_fm_exceptions)
111201 +
111202 +/**************************************************************************//**
111203 + @Function FM_IOC_GET_API_VERSION
111204 +
111205 + @Description Reads the FMD IOCTL API version.
111206 +
111207 + @Param[in,out] ioc_fm_api_version_t The requested counter parameters.
111208 +
111209 + @Return Version's value.
111210 +*//***************************************************************************/
111211 +#define FM_IOC_GET_API_VERSION _IOR(FM_IOC_TYPE_BASE, FM_IOC_NUM(7), ioc_fm_api_version_t)
111212 +
111213 +#if (DPAA_VERSION >= 11)
111214 +/**************************************************************************//**
111215 + @Function FM_VSP_Config
111216 +
111217 + @Description Creates descriptor for the FM VSP module.
111218 +
111219 + The routine returns a handle (descriptor) to the FM VSP object.
111220 + This descriptor must be passed as first parameter to all other
111221 + FM VSP function calls.
111222 +
111223 + No actual initialization or configuration of FM hardware is
111224 + done by this routine.
111225 +
111226 +@Param[in] p_FmVspParams Pointer to data structure of parameters
111227 +
111228 + @Retval Handle to FM VSP object, or NULL for Failure.
111229 +*//***************************************************************************/
111230 +#if defined(CONFIG_COMPAT)
111231 +#define FM_IOC_VSP_CONFIG_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_IOC_NUM(8), ioc_compat_fm_vsp_params_t)
111232 +#endif
111233 +#define FM_IOC_VSP_CONFIG _IOWR(FM_IOC_TYPE_BASE, FM_IOC_NUM(8), ioc_fm_vsp_params_t)
111234 +
111235 +/**************************************************************************//**
111236 + @Function FM_VSP_Init
111237 +
111238 + @Description Initializes the FM VSP module
111239 +
111240 + @Param[in] h_FmVsp - FM VSP module descriptor
111241 +
111242 + @Return E_OK on success; Error code otherwise.
111243 +*//***************************************************************************/
111244 +#if defined(CONFIG_COMPAT)
111245 +#define FM_IOC_VSP_INIT_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(9), ioc_compat_fm_obj_t)
111246 +#endif
111247 +#define FM_IOC_VSP_INIT _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(9), ioc_fm_obj_t)
111248 +
111249 +/**************************************************************************//**
111250 + @Function FM_VSP_Free
111251 +
111252 + @Description Frees all resources that were assigned to FM VSP module.
111253 +
111254 + Calling this routine invalidates the descriptor.
111255 +
111256 + @Param[in] h_FmVsp - FM VSP module descriptor
111257 +
111258 + @Return E_OK on success; Error code otherwise.
111259 +*//***************************************************************************/
111260 +#if defined(CONFIG_COMPAT)
111261 +#define FM_IOC_VSP_FREE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(10), ioc_compat_fm_obj_t)
111262 +#endif
111263 +#define FM_IOC_VSP_FREE _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(10), ioc_fm_obj_t)
111264 +
111265 +/**************************************************************************//**
111266 + @Function FM_VSP_ConfigPoolDepletion
111267 +
111268 + @Description Calling this routine enables pause frame generation depending on the
111269 + depletion status of BM pools. It also defines the conditions to activate
111270 + this functionality. By default, this functionality is disabled.
111271 +
111272 + @Param[in] ioc_fm_buf_pool_depletion_params_t A structure holding the required parameters.
111273 +
111274 + @Return E_OK on success; Error code otherwise.
111275 +
111276 + @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
111277 +*//***************************************************************************/
111278 +#if defined(CONFIG_COMPAT)
111279 +#define FM_IOC_VSP_CONFIG_POOL_DEPLETION_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(11), ioc_compat_fm_buf_pool_depletion_params_t)
111280 +#endif
111281 +#define FM_IOC_VSP_CONFIG_POOL_DEPLETION _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(11), ioc_fm_buf_pool_depletion_params_t)
111282 +
111283 +/**************************************************************************//**
111284 + @Function FM_VSP_ConfigBufferPrefixContent
111285 +
111286 + @Description Defines the structure, size and content of the application buffer.
111287 +
111288 + The prefix will
111289 + In VSPs defined for Tx ports, if 'passPrsResult', the application
111290 + should set a value to their offsets in the prefix of
111291 + the FM will save the first 'privDataSize', than,
111292 + depending on 'passPrsResult' and 'passTimeStamp', copy parse result
111293 + and timeStamp, and the packet itself (in this order), to the
111294 + application buffer, and to offset.
111295 +
111296 + Calling this routine changes the buffer margins definitions
111297 + in the internal driver data base from its default
111298 + configuration: Data size: [DEFAULT_FM_SP_bufferPrefixContent_privDataSize]
111299 + Pass Parser result: [DEFAULT_FM_SP_bufferPrefixContent_passPrsResult].
111300 + Pass timestamp: [DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp].
111301 +
111302 + @Param[in] ioc_fm_buffer_prefix_content_params_t A structure holding the required parameters.
111303 +
111304 + @Return E_OK on success; Error code otherwise.
111305 +
111306 + @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
111307 +*//***************************************************************************/
111308 +#if defined(CONFIG_COMPAT)
111309 +#define FM_IOC_VSP_CONFIG_BUFFER_PREFIX_CONTENT_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(12), ioc_compat_fm_buffer_prefix_content_params_t)
111310 +#endif
111311 +#define FM_IOC_VSP_CONFIG_BUFFER_PREFIX_CONTENT _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(12), ioc_fm_buffer_prefix_content_params_t)
111312 +
111313 +/**************************************************************************//**
111314 + @Function FM_VSP_ConfigNoScatherGather
111315 +
111316 + @Description Calling this routine changes the possibility to receive S/G frame
111317 + in the internal driver data base
111318 + from its default configuration: optimize = [DEFAULT_FM_SP_noScatherGather]
111319 +
111320 + @Param[in] ioc_fm_vsp_config_no_sg_params_t A structure holding the required parameters.
111321 +
111322 + @Return E_OK on success; Error code otherwise.
111323 +
111324 + @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
111325 +*//***************************************************************************/
111326 +#if defined(CONFIG_COMPAT)
111327 +#define FM_IOC_VSP_CONFIG_NO_SG_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(13), ioc_compat_fm_vsp_config_no_sg_params_t)
111328 +#endif
111329 +#define FM_IOC_VSP_CONFIG_NO_SG _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(13), ioc_fm_vsp_config_no_sg_params_t)
111330 +
111331 +/**************************************************************************//**
111332 + @Function FM_VSP_GetBufferPrsResult
111333 +
111334 + @Description Returns the pointer to the parse result in the data buffer.
111335 + In Rx ports this is relevant after reception, if parse
111336 + result is configured to be part of the data passed to the
111337 + application. For non Rx ports it may be used to get the pointer
111338 + of the area in the buffer where parse result should be
111339 + initialized - if so configured.
111340 + See FM_VSP_ConfigBufferPrefixContent for data buffer prefix
111341 + configuration.
111342 +
111343 + @Param[in] ioc_fm_vsp_prs_result_params_t A structure holding the required parameters.
111344 +
111345 + @Return Parse result pointer on success, NULL if parse result was not
111346 + configured for this port.
111347 +
111348 + @Cautions Allowed only following FM_VSP_Init().
111349 +*//***************************************************************************/
111350 +#if defined(CONFIG_COMPAT)
111351 +#define FM_IOC_VSP_GET_BUFFER_PRS_RESULT_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_IOC_NUM(14), ioc_compat_fm_vsp_prs_result_params_t)
111352 +#endif
111353 +#define FM_IOC_VSP_GET_BUFFER_PRS_RESULT _IOWR(FM_IOC_TYPE_BASE, FM_IOC_NUM(14), ioc_fm_vsp_prs_result_params_t)
111354 +#endif /* (DPAA_VERSION >= 11) */
111355 +
111356 +/**************************************************************************//**
111357 + @Function FM_CtrlMonStart
111358 +
111359 + @Description Start monitoring utilization of all available FM controllers.
111360 +
111361 + In order to obtain FM controllers utilization the following sequence
111362 + should be used:
111363 + -# FM_CtrlMonStart()
111364 + -# FM_CtrlMonStop()
111365 + -# FM_CtrlMonGetCounters() - issued for each FM controller
111366 +
111367 + @Return E_OK on success; Error code otherwise.
111368 +
111369 + @Cautions Allowed only following FM_Init().
111370 +*//***************************************************************************/
111371 +#define FM_IOC_CTRL_MON_START _IO(FM_IOC_TYPE_BASE, FM_IOC_NUM(15))
111372 +
111373 +
111374 +/**************************************************************************//**
111375 + @Function FM_CtrlMonStop
111376 +
111377 + @Description Stop monitoring utilization of all available FM controllers.
111378 +
111379 + In order to obtain FM controllers utilization the following sequence
111380 + should be used:
111381 + -# FM_CtrlMonStart()
111382 + -# FM_CtrlMonStop()
111383 + -# FM_CtrlMonGetCounters() - issued for each FM controller
111384 +
111385 + @Return E_OK on success; Error code otherwise.
111386 +
111387 + @Cautions Allowed only following FM_Init().
111388 +*//***************************************************************************/
111389 +#define FM_IOC_CTRL_MON_STOP _IO(FM_IOC_TYPE_BASE, FM_IOC_NUM(16))
111390 +
111391 +/**************************************************************************//**
111392 + @Function FM_CtrlMonGetCounters
111393 +
111394 + @Description Obtain FM controller utilization parameters.
111395 +
111396 + In order to obtain FM controllers utilization the following sequence
111397 + should be used:
111398 + -# FM_CtrlMonStart()
111399 + -# FM_CtrlMonStop()
111400 + -# FM_CtrlMonGetCounters() - issued for each FM controller
111401 +
111402 + @Param[in] ioc_fm_ctrl_mon_counters_params_t A structure holding the required parameters.
111403 +
111404 + @Return E_OK on success; Error code otherwise.
111405 +
111406 + @Cautions Allowed only following FM_Init().
111407 +*//***************************************************************************/
111408 +#if defined(CONFIG_COMPAT)
111409 +#define FM_IOC_CTRL_MON_GET_COUNTERS_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(17), ioc_compat_fm_ctrl_mon_counters_params_t)
111410 +#endif
111411 +#define FM_IOC_CTRL_MON_GET_COUNTERS _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(17), ioc_fm_ctrl_mon_counters_params_t)
111412 +
111413 +/** @} */ /* end of lnx_ioctl_FM_runtime_control_grp group */
111414 +/** @} */ /* end of lnx_ioctl_FM_lib_grp group */
111415 +/** @} */ /* end of lnx_ioctl_FM_grp */
111416 +
111417 +#define FMD_API_VERSION_MAJOR 21
111418 +#define FMD_API_VERSION_MINOR 1
111419 +#define FMD_API_VERSION_RESPIN 0
111420 +
111421 +#endif /* __FM_IOCTLS_H */
111422 --- /dev/null
111423 +++ b/include/uapi/linux/fmd/Peripherals/fm_pcd_ioctls.h
111424 @@ -0,0 +1,3084 @@
111425 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc.
111426 + * All rights reserved.
111427 + *
111428 + * Redistribution and use in source and binary forms, with or without
111429 + * modification, are permitted provided that the following conditions are met:
111430 + * * Redistributions of source code must retain the above copyright
111431 + * notice, this list of conditions and the following disclaimer.
111432 + * * Redistributions in binary form must reproduce the above copyright
111433 + * notice, this list of conditions and the following disclaimer in the
111434 + * documentation and/or other materials provided with the distribution.
111435 + * * Neither the name of Freescale Semiconductor nor the
111436 + * names of its contributors may be used to endorse or promote products
111437 + * derived from this software without specific prior written permission.
111438 + *
111439 + *
111440 + * ALTERNATIVELY, this software may be distributed under the terms of the
111441 + * GNU General Public License ("GPL") as published by the Free Software
111442 + * Foundation, either version 2 of that License or (at your option) any
111443 + * later version.
111444 + *
111445 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
111446 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
111447 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
111448 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
111449 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
111450 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
111451 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
111452 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
111453 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
111454 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
111455 + */
111456 +
111457 +
111458 +/******************************************************************************
111459 + @File fm_pcd_ioctls.h
111460 +
111461 + @Description FM PCD ...
111462 +*//***************************************************************************/
111463 +#ifndef __FM_PCD_IOCTLS_H
111464 +#define __FM_PCD_IOCTLS_H
111465 +
111466 +#include "net_ioctls.h"
111467 +#include "fm_ioctls.h"
111468 +
111469 +
111470 +/**************************************************************************//**
111471 +
111472 + @Group lnx_ioctl_FM_grp Frame Manager Linux IOCTL API
111473 +
111474 + @Description Frame Manager Linux ioctls definitions and enums
111475 +
111476 + @{
111477 +*//***************************************************************************/
111478 +
111479 +/**************************************************************************//**
111480 + @Group lnx_ioctl_FM_PCD_grp FM PCD
111481 +
111482 + @Description Frame Manager PCD API functions, definitions and enums
111483 +
111484 + The FM PCD module is responsible for the initialization of all
111485 + global classifying FM modules. This includes the parser general and
111486 + common registers, the key generator global and common registers,
111487 + and the policer global and common registers.
111488 + In addition, the FM PCD SW module will initialize all required
111489 + key generator schemes, coarse classification flows, and policer
111490 + profiles. When an FM module is configured to work with one of these
111491 + entities, it will register to it using the FM PORT API. The PCD
111492 + module will manage the PCD resources - i.e. resource management of
111493 + KeyGen schemes, etc.
111494 +
111495 + @{
111496 +*//***************************************************************************/
111497 +
111498 +/**************************************************************************//**
111499 + @Collection General PCD defines
111500 +*//***************************************************************************/
111501 +#define IOC_FM_PCD_MAX_NUM_OF_PRIVATE_HDRS 2 /**< Number of units/headers saved for user */
111502 +
111503 +#define IOC_FM_PCD_PRS_NUM_OF_HDRS 16 /**< Number of headers supported by HW parser */
111504 +#define IOC_FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS (32 - IOC_FM_PCD_MAX_NUM_OF_PRIVATE_HDRS)
111505 + /**< Number of distinction units is limited by
111506 + register size (32 bits) minus reserved bits
111507 + for private headers. */
111508 +#define IOC_FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS 4 /**< Maximum number of interchangeable headers
111509 + in a distinction unit */
111510 +#define IOC_FM_PCD_KG_NUM_OF_GENERIC_REGS 8 /**< Total number of generic KeyGen registers */
111511 +#define IOC_FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY 35 /**< Max number allowed on any configuration;
111512 + For HW implementation reasons, in most
111513 + cases less than this will be allowed; The
111514 + driver will return an initialization error
111515 + if resource is unavailable. */
111516 +#define IOC_FM_PCD_KG_NUM_OF_EXTRACT_MASKS 4 /**< Total number of masks allowed on KeyGen extractions. */
111517 +#define IOC_FM_PCD_KG_NUM_OF_DEFAULT_GROUPS 16 /**< Number of default value logical groups */
111518 +
111519 +#define IOC_FM_PCD_PRS_NUM_OF_LABELS 32 /**< Maximum number of SW parser labels */
111520 +#define IOC_FM_PCD_SW_PRS_SIZE 0x00000800 /**< Total size of SW parser area */
111521 +
111522 +#define IOC_FM_PCD_MAX_MANIP_INSRT_TEMPLATE_SIZE 128 /**< Maximum size of insertion template for
111523 + insert manipulation */
111524 +
111525 +#if DPAA_VERSION >= 11
111526 +#define IOC_FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES 64 /**< Maximum possible entries for frame replicator group */
111527 +#endif /* DPAA_VERSION >= 11 */
111528 +/* @} */
111529 +
111530 +#ifdef FM_CAPWAP_SUPPORT
111531 +#error "FM_CAPWAP_SUPPORT not implemented!"
111532 +#endif
111533 +
111534 +
111535 +/**************************************************************************//**
111536 + @Group lnx_ioctl_FM_PCD_init_grp FM PCD Initialization Unit
111537 +
111538 + @Description Frame Manager PCD Initialization Unit API
111539 +
111540 + @{
111541 +*//***************************************************************************/
111542 +
111543 +/**************************************************************************//**
111544 + @Description PCD counters
111545 + (must match enum e_FmPcdCounters defined in fm_pcd_ext.h)
111546 +*//***************************************************************************/
111547 +typedef enum ioc_fm_pcd_counters {
111548 + e_IOC_FM_PCD_KG_COUNTERS_TOTAL, /**< KeyGen counter */
111549 + e_IOC_FM_PCD_PLCR_COUNTERS_RED, /**< Policer counter - counts the total number of RED packets that exit the Policer. */
111550 + e_IOC_FM_PCD_PLCR_COUNTERS_YELLOW, /**< Policer counter - counts the total number of YELLOW packets that exit the Policer. */
111551 + e_IOC_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED, /**< Policer counter - counts the number of packets that changed color to RED by the Policer;
111552 + This is a subset of e_IOC_FM_PCD_PLCR_COUNTERS_RED packet count, indicating active color changes. */
111553 + e_IOC_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW, /**< Policer counter - counts the number of packets that changed color to YELLOW by the Policer;
111554 + This is a subset of e_IOC_FM_PCD_PLCR_COUNTERS_YELLOW packet count, indicating active color changes. */
111555 + e_IOC_FM_PCD_PLCR_COUNTERS_TOTAL, /**< Policer counter - counts the total number of packets passed in the Policer. */
111556 + e_IOC_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH, /**< Policer counter - counts the number of packets with length mismatch. */
111557 + e_IOC_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH, /**< Parser counter - counts the number of times the parser block is dispatched. */
111558 + e_IOC_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED, /**< Parser counter - counts the number of times L2 parse result is returned (including errors). */
111559 + e_IOC_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED, /**< Parser counter - counts the number of times L3 parse result is returned (including errors). */
111560 + e_IOC_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED, /**< Parser counter - counts the number of times L4 parse result is returned (including errors). */
111561 + e_IOC_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED, /**< Parser counter - counts the number of times SHIM parse result is returned (including errors). */
111562 + e_IOC_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter - counts the number of times L2 parse result is returned with errors. */
111563 + e_IOC_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter - counts the number of times L3 parse result is returned with errors. */
111564 + e_IOC_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter - counts the number of times L4 parse result is returned with errors. */
111565 + e_IOC_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter - counts the number of times SHIM parse result is returned with errors. */
111566 + e_IOC_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES, /**< Parser counter - counts the number of cycles spent executing soft parser instruction (including stall cycles). */
111567 + e_IOC_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES, /**< Parser counter - counts the number of cycles stalled waiting for parser internal memory reads while executing soft parser instruction. */
111568 + e_IOC_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES, /**< Parser counter - counts the number of cycles spent executing hard parser (including stall cycles). */
111569 + e_IOC_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES, /**< MURAM counter - counts the number of cycles while performing FMan Memory read. */
111570 + e_IOC_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES, /**< MURAM counter - counts the number of cycles stalled while performing FMan Memory read. */
111571 + e_IOC_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES, /**< MURAM counter - counts the number of cycles while performing FMan Memory write. */
111572 + e_IOC_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES, /**< MURAM counter - counts the number of cycles stalled while performing FMan Memory write. */
111573 + e_IOC_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES /**< FPM counter - counts the number of cycles stalled while performing a FPM Command. */
111574 +} ioc_fm_pcd_counters;
111575 +
111576 +/**************************************************************************//**
111577 + @Description PCD interrupts
111578 + (must match enum e_FmPcdExceptions defined in fm_pcd_ext.h)
111579 +*//***************************************************************************/
111580 +typedef enum ioc_fm_pcd_exceptions {
111581 + e_IOC_FM_PCD_KG_EXCEPTION_DOUBLE_ECC, /**< KeyGen double-bit ECC error is detected on internal memory read access. */
111582 + e_IOC_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW, /**< KeyGen scheme configuration error indicating a key size larger than 56 bytes. */
111583 + e_IOC_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC, /**< Policer double-bit ECC error has been detected on PRAM read access. */
111584 + e_IOC_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR, /**< Policer access to a non-initialized profile has been detected. */
111585 + e_IOC_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE, /**< Policer RAM self-initialization complete */
111586 + e_IOC_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE, /**< Policer atomic action complete */
111587 + e_IOC_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC, /**< Parser double-bit ECC error */
111588 + e_IOC_FM_PCD_PRS_EXCEPTION_SINGLE_ECC /**< Parser single-bit ECC error */
111589 +} ioc_fm_pcd_exceptions;
111590 +
111591 +/** @} */ /* end of lnx_ioctl_FM_PCD_init_grp group */
111592 +
111593 +
111594 +/**************************************************************************//**
111595 + @Group lnx_ioctl_FM_PCD_Runtime_grp FM PCD Runtime Unit
111596 +
111597 + @Description Frame Manager PCD Runtime Unit
111598 +
111599 + The runtime control allows creation of PCD infrastructure modules
111600 + such as Network Environment Characteristics, Classification Plan
111601 + Groups and Coarse Classification Trees.
111602 + It also allows on-the-fly initialization, modification and removal
111603 + of PCD modules such as KeyGen schemes, coarse classification nodes
111604 + and Policer profiles.
111605 +
111606 + In order to explain the programming model of the PCD driver interface
111607 + a few terms should be explained, and will be used below.
111608 + - Distinction Header - One of the 16 protocols supported by the FM parser,
111609 + or one of the SHIM headers (1 or 2). May be a header with a special
111610 + option (see below).
111611 + - Interchangeable Headers Group - This is a group of Headers recognized
111612 + by either one of them. For example, if in a specific context the user
111613 + chooses to treat IPv4 and IPV6 in the same way, they may create an
111614 + interchangeable Headers Unit consisting of these 2 headers.
111615 + - A Distinction Unit - a Distinction Header or an Interchangeable Headers
111616 + Group.
111617 + - Header with special option - applies to Ethernet, MPLS, VLAN, IPv4 and
111618 + IPv6, includes multicast, broadcast and other protocol specific options.
111619 + In terms of hardware it relates to the options available in the classification
111620 + plan.
111621 + - Network Environment Characteristics - a set of Distinction Units that define
111622 + the total recognizable header selection for a certain environment. This is
111623 + NOT the list of all headers that will ever appear in a flow, but rather
111624 + everything that needs distinction in a flow, where distinction is made by KeyGen
111625 + schemes and coarse classification action descriptors.
111626 +
111627 + The PCD runtime modules initialization is done in stages. The first stage after
111628 + initializing the PCD module itself is to establish a Network Flows Environment
111629 + Definition. The application may choose to establish one or more such environments.
111630 + Later, when needed, the application will have to state, for some of its modules,
111631 + to which single environment it belongs.
111632 +
111633 + @{
111634 +*//***************************************************************************/
111635 +
111636 +
111637 +/**************************************************************************//**
111638 + @Description structure for FM counters
111639 +*//***************************************************************************/
111640 +typedef struct ioc_fm_pcd_counters_params_t {
111641 + ioc_fm_pcd_counters cnt; /**< The requested counter */
111642 + uint32_t val; /**< The requested value to get/set from/into the counter */
111643 +} ioc_fm_pcd_counters_params_t;
111644 +
111645 +/**************************************************************************//**
111646 + @Description structure for FM exception definitios
111647 +*//***************************************************************************/
111648 +typedef struct ioc_fm_pcd_exception_params_t {
111649 + ioc_fm_pcd_exceptions exception; /**< The requested exception */
111650 + bool enable; /**< TRUE to enable interrupt, FALSE to mask it. */
111651 +} ioc_fm_pcd_exception_params_t;
111652 +
111653 +/**************************************************************************//**
111654 + @Description A structure for SW parser labels
111655 + (must be identical to struct t_FmPcdPrsLabelParams defined in fm_pcd_ext.h)
111656 + *//***************************************************************************/
111657 +typedef struct ioc_fm_pcd_prs_label_params_t {
111658 + uint32_t instruction_offset; /**< SW parser label instruction offset (2 bytes
111659 + resolution), relative to Parser RAM. */
111660 + ioc_net_header_type hdr; /**< The existence of this header will invoke
111661 + the SW parser code. */
111662 + uint8_t index_per_hdr; /**< Normally 0, if more than one SW parser
111663 + attachments for the same header, use this
111664 + index to distinguish between them. */
111665 +} ioc_fm_pcd_prs_label_params_t;
111666 +
111667 +/**************************************************************************//**
111668 + @Description A structure for SW parser
111669 + (Must match struct t_FmPcdPrsSwParams defined in fm_pcd_ext.h)
111670 + *//***************************************************************************/
111671 +typedef struct ioc_fm_pcd_prs_sw_params_t {
111672 + bool override; /**< FALSE to invoke a check that nothing else
111673 + was loaded to this address, including
111674 + internal patches.
111675 + TRUE to override any existing code.*/
111676 + uint32_t size; /**< SW parser code size */
111677 + uint16_t base; /**< SW parser base (in instruction counts!
111678 + must be larger than 0x20)*/
111679 + uint8_t *p_code; /**< SW parser code */
111680 + uint32_t sw_prs_data_params[IOC_FM_PCD_PRS_NUM_OF_HDRS];
111681 + /**< SW parser data (parameters) */
111682 + uint8_t num_of_labels; /**< Number of labels for SW parser. */
111683 + ioc_fm_pcd_prs_label_params_t labels_table[IOC_FM_PCD_PRS_NUM_OF_LABELS];
111684 + /**< SW parser labels table,
111685 + containing num_of_labels entries */
111686 +} ioc_fm_pcd_prs_sw_params_t;
111687 +
111688 +/**************************************************************************//**
111689 + @Description A structure to set the a KeyGen default value
111690 + *//***************************************************************************/
111691 +typedef struct ioc_fm_pcd_kg_dflt_value_params_t {
111692 + uint8_t valueId; /**< 0,1 - one of 2 global default values */
111693 + uint32_t value; /**< The requested default value */
111694 +} ioc_fm_pcd_kg_dflt_value_params_t;
111695 +
111696 +
111697 +/**************************************************************************//**
111698 + @Function FM_PCD_Enable
111699 +
111700 + @Description This routine should be called after PCD is initialized for enabling all
111701 + PCD engines according to their existing configuration.
111702 +
111703 + @Return 0 on success; Error code otherwise.
111704 +
111705 + @Cautions Allowed only when PCD is disabled.
111706 +*//***************************************************************************/
111707 +#define FM_PCD_IOC_ENABLE _IO(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(1))
111708 +
111709 +/**************************************************************************//**
111710 + @Function FM_PCD_Disable
111711 +
111712 + @Description This routine may be called when PCD is enabled in order to
111713 + disable all PCD engines. It may be called
111714 + only when none of the ports in the system are using the PCD.
111715 +
111716 + @Return 0 on success; Error code otherwise.
111717 +
111718 + @Cautions Allowed only when PCD is enabled.
111719 +*//***************************************************************************/
111720 +#define FM_PCD_IOC_DISABLE _IO(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(2))
111721 +
111722 + /**************************************************************************//**
111723 + @Function FM_PCD_PrsLoadSw
111724 +
111725 + @Description This routine may be called only when all ports in the
111726 + system are actively using the classification plan scheme.
111727 + In such cases it is recommended in order to save resources.
111728 + The driver automatically saves 8 classification plans for
111729 + ports that do NOT use the classification plan mechanism, to
111730 + avoid this (in order to save those entries) this routine may
111731 + be called.
111732 +
111733 + @Param[in] ioc_fm_pcd_prs_sw_params_t A pointer to the image of the software parser code.
111734 +
111735 + @Return 0 on success; Error code otherwise.
111736 +
111737 + @Cautions Allowed only when PCD is disabled.
111738 +*//***************************************************************************/
111739 +#if defined(CONFIG_COMPAT)
111740 +#define FM_PCD_IOC_PRS_LOAD_SW_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(3), ioc_compat_fm_pcd_prs_sw_params_t)
111741 +#endif
111742 +#define FM_PCD_IOC_PRS_LOAD_SW _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(3), ioc_fm_pcd_prs_sw_params_t)
111743 +
111744 +/**************************************************************************//**
111745 + @Function FM_PCD_KgSetDfltValue
111746 +
111747 + @Description Calling this routine sets a global default value to be used
111748 + by the KeyGen when parser does not recognize a required
111749 + field/header.
111750 + By default default values are 0.
111751 +
111752 + @Param[in] ioc_fm_pcd_kg_dflt_value_params_t A pointer to a structure with the relevant parameters
111753 +
111754 + @Return 0 on success; Error code otherwise.
111755 +
111756 + @Cautions Allowed only when PCD is disabled.
111757 +*//***************************************************************************/
111758 +#define FM_PCD_IOC_KG_SET_DFLT_VALUE _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(6), ioc_fm_pcd_kg_dflt_value_params_t)
111759 +
111760 +/**************************************************************************//**
111761 + @Function FM_PCD_KgSetAdditionalDataAfterParsing
111762 +
111763 + @Description Calling this routine allows the keygen to access data past
111764 + the parser finishing point.
111765 +
111766 + @Param[in] uint8_t payload-offset; the number of bytes beyond the parser location.
111767 +
111768 + @Return 0 on success; Error code otherwise.
111769 +
111770 + @Cautions Allowed only when PCD is disabled.
111771 +*//***************************************************************************/
111772 +#define FM_PCD_IOC_KG_SET_ADDITIONAL_DATA_AFTER_PARSING _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(7), uint8_t)
111773 +
111774 +/**************************************************************************//**
111775 + @Function FM_PCD_SetException
111776 +
111777 + @Description Calling this routine enables/disables PCD interrupts.
111778 +
111779 + @Param[in] ioc_fm_pcd_exception_params_t Arguments struct with exception to be enabled/disabled.
111780 +
111781 + @Return 0 on success; Error code otherwise.
111782 +*//***************************************************************************/
111783 +#define FM_PCD_IOC_SET_EXCEPTION _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(8), ioc_fm_pcd_exception_params_t)
111784 +
111785 +/**************************************************************************//**
111786 + @Function FM_PCD_GetCounter
111787 +
111788 + @Description Reads one of the FM PCD counters.
111789 +
111790 + @Param[in,out] ioc_fm_pcd_counters_params_t The requested counter parameters.
111791 +
111792 + @Return 0 on success; Error code otherwise.
111793 +
111794 + @Cautions Note that it is user's responsibilty to call this routine only
111795 + for enabled counters, and there will be no indication if a
111796 + disabled counter is accessed.
111797 +*//***************************************************************************/
111798 +#define FM_PCD_IOC_GET_COUNTER _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(9), ioc_fm_pcd_counters_params_t)
111799 +
111800 +/**************************************************************************//**
111801 +
111802 + @Function FM_PCD_KgSchemeGetCounter
111803 +
111804 + @Description Reads scheme packet counter.
111805 +
111806 + @Param[in] h_Scheme scheme handle as returned by FM_PCD_KgSchemeSet().
111807 +
111808 + @Return Counter's current value.
111809 +
111810 + @Cautions Allowed only following FM_PCD_Init() & FM_PCD_KgSchemeSet().
111811 +*//***************************************************************************/
111812 +#if defined(CONFIG_COMPAT)
111813 +#define FM_PCD_IOC_KG_SCHEME_GET_CNTR_COMPAT _IOR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(4), ioc_compat_fm_pcd_kg_scheme_spc_t)
111814 +#endif
111815 +#define FM_PCD_IOC_KG_SCHEME_GET_CNTR _IOR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(4), ioc_fm_pcd_kg_scheme_spc_t)
111816 +
111817 +#if 0
111818 +TODO: unused IOCTL
111819 +/**************************************************************************//**
111820 + @Function FM_PCD_ModifyCounter
111821 +
111822 + @Description Writes a value to an enabled counter. Use "0" to reset the counter.
111823 +
111824 + @Param[in] ioc_fm_pcd_counters_params_t - The requested counter parameters.
111825 +
111826 + @Return 0 on success; Error code otherwise.
111827 +*//***************************************************************************/
111828 +#define FM_PCD_IOC_MODIFY_COUNTER _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(10), ioc_fm_pcd_counters_params_t)
111829 +#define FM_PCD_IOC_SET_COUNTER FM_PCD_IOC_MODIFY_COUNTER
111830 +#endif
111831 +
111832 +/**************************************************************************//**
111833 + @Function FM_PCD_ForceIntr
111834 +
111835 + @Description Causes an interrupt event on the requested source.
111836 +
111837 + @Param[in] ioc_fm_pcd_exceptions - An exception to be forced.
111838 +
111839 + @Return 0 on success; error code if the exception is not enabled,
111840 + or is not able to create interrupt.
111841 +*//***************************************************************************/
111842 +#define FM_PCD_IOC_FORCE_INTR _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(11), ioc_fm_pcd_exceptions)
111843 +
111844 +/**************************************************************************//**
111845 + @Collection Definitions of coarse classification parameters as required by KeyGen
111846 + (when coarse classification is the next engine after this scheme).
111847 +*//***************************************************************************/
111848 +#define IOC_FM_PCD_MAX_NUM_OF_CC_TREES 8
111849 +#define IOC_FM_PCD_MAX_NUM_OF_CC_GROUPS 16
111850 +#define IOC_FM_PCD_MAX_NUM_OF_CC_UNITS 4
111851 +#define IOC_FM_PCD_MAX_NUM_OF_KEYS 256
111852 +#define IOC_FM_PCD_MAX_NUM_OF_FLOWS (4*KILOBYTE)
111853 +#define IOC_FM_PCD_MAX_SIZE_OF_KEY 56
111854 +#define IOC_FM_PCD_MAX_NUM_OF_CC_ENTRIES_IN_GRP 16
111855 +#define IOC_FM_PCD_LAST_KEY_INDEX 0xffff
111856 +#define IOC_FM_PCD_MANIP_DSCP_VALUES 64
111857 +/* @} */
111858 +
111859 +/**************************************************************************//**
111860 + @Collection A set of definitions to allow protocol
111861 + special option description.
111862 +*//***************************************************************************/
111863 +typedef uint32_t ioc_protocol_opt_t; /**< A general type to define a protocol option. */
111864 +
111865 +typedef ioc_protocol_opt_t ioc_eth_protocol_opt_t; /**< Ethernet protocol options. */
111866 +#define IOC_ETH_BROADCAST 0x80000000 /**< Ethernet Broadcast. */
111867 +#define IOC_ETH_MULTICAST 0x40000000 /**< Ethernet Multicast. */
111868 +
111869 +typedef ioc_protocol_opt_t ioc_vlan_protocol_opt_t; /**< Vlan protocol options. */
111870 +#define IOC_VLAN_STACKED 0x20000000 /**< Stacked VLAN. */
111871 +
111872 +typedef ioc_protocol_opt_t ioc_mpls_protocol_opt_t; /**< MPLS protocol options. */
111873 +#define IOC_MPLS_STACKED 0x10000000 /**< Stacked MPLS. */
111874 +
111875 +typedef ioc_protocol_opt_t ioc_ipv4_protocol_opt_t; /**< IPv4 protocol options. */
111876 +#define IOC_IPV4_BROADCAST_1 0x08000000 /**< IPv4 Broadcast. */
111877 +#define IOC_IPV4_MULTICAST_1 0x04000000 /**< IPv4 Multicast. */
111878 +#define IOC_IPV4_UNICAST_2 0x02000000 /**< Tunneled IPv4 - Unicast. */
111879 +#define IOC_IPV4_MULTICAST_BROADCAST_2 0x01000000 /**< Tunneled IPv4 - Broadcast/Multicast. */
111880 +
111881 +#define IOC_IPV4_FRAG_1 0x00000008 /**< IPV4 reassembly option.
111882 + IPV4 Reassembly manipulation requires network
111883 + environment with IPV4 header and IPV4_FRAG_1 option */
111884 +
111885 +typedef ioc_protocol_opt_t ioc_ipv6_protocol_opt_t; /**< IPv6 protocol options. */
111886 +#define IOC_IPV6_MULTICAST_1 0x00800000 /**< IPv6 Multicast. */
111887 +#define IOC_IPV6_UNICAST_2 0x00400000 /**< Tunneled IPv6 - Unicast. */
111888 +#define IOC_IPV6_MULTICAST_2 0x00200000 /**< Tunneled IPv6 - Multicast. */
111889 +
111890 +#define IOC_IPV6_FRAG_1 0x00000004 /**< IPV6 reassembly option.
111891 + IPV6 Reassembly manipulation requires network
111892 + environment with IPV6 header and IPV6_FRAG_1 option */
111893 +#if (DPAA_VERSION >= 11)
111894 +typedef ioc_protocol_opt_t ioc_capwap_protocol_opt_t; /**< CAPWAP protocol options. */
111895 +#define CAPWAP_FRAG_1 0x00000008 /**< CAPWAP reassembly option.
111896 + CAPWAP Reassembly manipulation requires network
111897 + environment with CAPWAP header and CAPWAP_FRAG_1 option;
111898 + in case where fragment found, the fragment-extension offset
111899 + may be found at 'shim2' (in parser-result). */
111900 +#endif /* (DPAA_VERSION >= 11) */
111901 +
111902 +/* @} */
111903 +
111904 +#define IOC_FM_PCD_MANIP_MAX_HDR_SIZE 256
111905 +#define IOC_FM_PCD_MANIP_DSCP_TO_VLAN_TRANS 64
111906 +/**************************************************************************//**
111907 + @Collection A set of definitions to support Header Manipulation selection.
111908 +*//***************************************************************************/
111909 +typedef uint32_t ioc_hdr_manip_flags_t; /**< A general type to define a HMan update command flags. */
111910 +
111911 +typedef ioc_hdr_manip_flags_t ioc_ipv4_hdr_manip_update_flags_t; /**< IPv4 protocol HMan update command flags. */
111912 +
111913 +#define IOC_HDR_MANIP_IPV4_TOS 0x80000000 /**< update TOS with the given value ('tos' field
111914 + of ioc_fm_pcd_manip_hdr_field_update_ipv4_t) */
111915 +#define IOC_HDR_MANIP_IPV4_ID 0x40000000 /**< update IP ID with the given value ('id' field
111916 + of ioc_fm_pcd_manip_hdr_field_update_ipv4_t) */
111917 +#define IOC_HDR_MANIP_IPV4_TTL 0x20000000 /**< Decrement TTL by 1 */
111918 +#define IOC_HDR_MANIP_IPV4_SRC 0x10000000 /**< update IP source address with the given value
111919 + ('src' field of ioc_fm_pcd_manip_hdr_field_update_ipv4_t) */
111920 +#define IOC_HDR_MANIP_IPV4_DST 0x08000000 /**< update IP destination address with the given value
111921 + ('dst' field of ioc_fm_pcd_manip_hdr_field_update_ipv4_t) */
111922 +
111923 +typedef ioc_hdr_manip_flags_t ioc_ipv6_hdr_manip_update_flags_t; /**< IPv6 protocol HMan update command flags. */
111924 +
111925 +#define IOC_HDR_MANIP_IPV6_TC 0x80000000 /**< update Traffic Class address with the given value
111926 + ('traffic_class' field of ioc_fm_pcd_manip_hdr_field_update_ipv6_t) */
111927 +#define IOC_HDR_MANIP_IPV6_HL 0x40000000 /**< Decrement Hop Limit by 1 */
111928 +#define IOC_HDR_MANIP_IPV6_SRC 0x20000000 /**< update IP source address with the given value
111929 + ('src' field of ioc_fm_pcd_manip_hdr_field_update_ipv6_t) */
111930 +#define IOC_HDR_MANIP_IPV6_DST 0x10000000 /**< update IP destination address with the given value
111931 + ('dst' field of ioc_fm_pcd_manip_hdr_field_update_ipv6_t) */
111932 +
111933 +typedef ioc_hdr_manip_flags_t ioc_tcp_udp_hdr_manip_update_flags_t;/**< TCP/UDP protocol HMan update command flags. */
111934 +
111935 +#define IOC_HDR_MANIP_TCP_UDP_SRC 0x80000000 /**< update TCP/UDP source address with the given value
111936 + ('src' field of ioc_fm_pcd_manip_hdr_field_update_tcp_udp_t) */
111937 +#define IOC_HDR_MANIP_TCP_UDP_DST 0x40000000 /**< update TCP/UDP destination address with the given value
111938 + ('dst' field of ioc_fm_pcd_manip_hdr_field_update_tcp_udp_t) */
111939 +#define IOC_HDR_MANIP_TCP_UDP_CHECKSUM 0x20000000 /**< update TCP/UDP checksum */
111940 +
111941 +/* @} */
111942 +
111943 +/**************************************************************************//**
111944 + @Description A type used for returning the order of the key extraction.
111945 + each value in this array represents the index of the extraction
111946 + command as defined by the user in the initialization extraction array.
111947 + The valid size of this array is the user define number of extractions
111948 + required (also marked by the second '0' in this array).
111949 +*//***************************************************************************/
111950 +typedef uint8_t ioc_fm_pcd_kg_key_order_t [IOC_FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY];
111951 +
111952 +/**************************************************************************//**
111953 + @Description All PCD engines
111954 + (must match enum e_FmPcdEngine defined in fm_pcd_ext.h)
111955 +*//***************************************************************************/
111956 +typedef enum ioc_fm_pcd_engine {
111957 + e_IOC_FM_PCD_INVALID = 0, /**< Invalid PCD engine */
111958 + e_IOC_FM_PCD_DONE, /**< No PCD Engine indicated */
111959 + e_IOC_FM_PCD_KG, /**< KeyGen */
111960 + e_IOC_FM_PCD_CC, /**< Coarse Classifier */
111961 + e_IOC_FM_PCD_PLCR, /**< Policer */
111962 + e_IOC_FM_PCD_PRS, /**< Parser */
111963 +#if DPAA_VERSION >= 11
111964 + e_IOC_FM_PCD_FR, /**< Frame Replicator */
111965 +#endif /* DPAA_VERSION >= 11 */
111966 + e_IOC_FM_PCD_HASH /**< Hash Table */
111967 +} ioc_fm_pcd_engine;
111968 +
111969 +/**************************************************************************//**
111970 + @Description An enum for selecting extraction by header types
111971 + (Must match enum e_FmPcdExtractByHdrType defined in fm_pcd_ext.h)
111972 +*//***************************************************************************/
111973 +typedef enum ioc_fm_pcd_extract_by_hdr_type {
111974 + e_IOC_FM_PCD_EXTRACT_FROM_HDR, /**< Extract bytes from header */
111975 + e_IOC_FM_PCD_EXTRACT_FROM_FIELD, /**< Extract bytes from header field */
111976 + e_IOC_FM_PCD_EXTRACT_FULL_FIELD /**< Extract a full field */
111977 +} ioc_fm_pcd_extract_by_hdr_type;
111978 +
111979 +/**************************************************************************//**
111980 + @Description An enum for selecting extraction source (when it is not the header)
111981 + (Must match enum e_FmPcdExtractFrom defined in fm_pcd_ext.h)
111982 +*//***************************************************************************/
111983 +typedef enum ioc_fm_pcd_extract_from {
111984 + e_IOC_FM_PCD_EXTRACT_FROM_FRAME_START, /**< KG & CC: Extract from beginning of frame */
111985 + e_IOC_FM_PCD_EXTRACT_FROM_DFLT_VALUE, /**< KG only: Extract from a default value */
111986 + e_IOC_FM_PCD_EXTRACT_FROM_CURR_END_OF_PARSE, /**< KG only: Extract from the point where parsing had finished */
111987 + e_IOC_FM_PCD_EXTRACT_FROM_KEY, /**< CC only: Field where saved KEY */
111988 + e_IOC_FM_PCD_EXTRACT_FROM_HASH, /**< CC only: Field where saved HASH */
111989 + e_IOC_FM_PCD_EXTRACT_FROM_PARSE_RESULT, /**< KG & CC: Extract from the parser result */
111990 + e_IOC_FM_PCD_EXTRACT_FROM_ENQ_FQID, /**< KG & CC: Extract from enqueue FQID */
111991 + e_IOC_FM_PCD_EXTRACT_FROM_FLOW_ID /**< CC only: Field where saved Dequeue FQID */
111992 +} ioc_fm_pcd_extract_from;
111993 +
111994 +/**************************************************************************//**
111995 + @Description An enum for selecting extraction type
111996 +*//***************************************************************************/
111997 +typedef enum ioc_fm_pcd_extract_type {
111998 + e_IOC_FM_PCD_EXTRACT_BY_HDR, /**< Extract according to header */
111999 + e_IOC_FM_PCD_EXTRACT_NON_HDR, /**< Extract from data that is not the header */
112000 + e_IOC_FM_PCD_KG_EXTRACT_PORT_PRIVATE_INFO /**< Extract private info as specified by user */
112001 +} ioc_fm_pcd_extract_type;
112002 +
112003 +/**************************************************************************//**
112004 + @Description An enum for selecting a default
112005 +*//***************************************************************************/
112006 +typedef enum ioc_fm_pcd_kg_extract_dflt_select {
112007 + e_IOC_FM_PCD_KG_DFLT_GBL_0, /**< Default selection is KG register 0 */
112008 + e_IOC_FM_PCD_KG_DFLT_GBL_1, /**< Default selection is KG register 1 */
112009 + e_IOC_FM_PCD_KG_DFLT_PRIVATE_0, /**< Default selection is a per scheme register 0 */
112010 + e_IOC_FM_PCD_KG_DFLT_PRIVATE_1, /**< Default selection is a per scheme register 1 */
112011 + e_IOC_FM_PCD_KG_DFLT_ILLEGAL /**< Illegal selection */
112012 +} ioc_fm_pcd_kg_extract_dflt_select;
112013 +
112014 +/**************************************************************************//**
112015 + @Description Enumeration type defining all default groups - each group shares
112016 + a default value, one of four user-initialized values.
112017 +*//***************************************************************************/
112018 +typedef enum ioc_fm_pcd_kg_known_fields_dflt_types {
112019 + e_IOC_FM_PCD_KG_MAC_ADDR, /**< MAC Address */
112020 + e_IOC_FM_PCD_KG_TCI, /**< TCI field */
112021 + e_IOC_FM_PCD_KG_ENET_TYPE, /**< ENET Type */
112022 + e_IOC_FM_PCD_KG_PPP_SESSION_ID, /**< PPP Session id */
112023 + e_IOC_FM_PCD_KG_PPP_PROTOCOL_ID, /**< PPP Protocol id */
112024 + e_IOC_FM_PCD_KG_MPLS_LABEL, /**< MPLS label */
112025 + e_IOC_FM_PCD_KG_IP_ADDR, /**< IP addr */
112026 + e_IOC_FM_PCD_KG_PROTOCOL_TYPE, /**< Protocol type */
112027 + e_IOC_FM_PCD_KG_IP_TOS_TC, /**< TOS or TC */
112028 + e_IOC_FM_PCD_KG_IPV6_FLOW_LABEL, /**< IPV6 flow label */
112029 + e_IOC_FM_PCD_KG_IPSEC_SPI, /**< IPSEC SPI */
112030 + e_IOC_FM_PCD_KG_L4_PORT, /**< L4 Port */
112031 + e_IOC_FM_PCD_KG_TCP_FLAG, /**< TCP Flag */
112032 + e_IOC_FM_PCD_KG_GENERIC_FROM_DATA, /**< grouping implemented by SW,
112033 + any data extraction that is not the full
112034 + field described above */
112035 + e_IOC_FM_PCD_KG_GENERIC_FROM_DATA_NO_V, /**< grouping implemented by SW,
112036 + any data extraction without validation */
112037 + e_IOC_FM_PCD_KG_GENERIC_NOT_FROM_DATA /**< grouping implemented by SW,
112038 + extraction from parser result or
112039 + direct use of default value */
112040 +} ioc_fm_pcd_kg_known_fields_dflt_types;
112041 +
112042 +/**************************************************************************//**
112043 + @Description Enumeration type for defining header index for scenarios with
112044 + multiple (tunneled) headers
112045 +*//***************************************************************************/
112046 +typedef enum ioc_fm_pcd_hdr_index {
112047 + e_IOC_FM_PCD_HDR_INDEX_NONE = 0, /**< used when multiple headers not used, also
112048 + to specify regular IP (not tunneled). */
112049 + e_IOC_FM_PCD_HDR_INDEX_1, /**< may be used for VLAN, MPLS, tunneled IP */
112050 + e_IOC_FM_PCD_HDR_INDEX_2, /**< may be used for MPLS, tunneled IP */
112051 + e_IOC_FM_PCD_HDR_INDEX_3, /**< may be used for MPLS */
112052 + e_IOC_FM_PCD_HDR_INDEX_LAST = 0xFF /**< may be used for VLAN, MPLS */
112053 +} ioc_fm_pcd_hdr_index;
112054 +
112055 +/**************************************************************************//**
112056 + @Description Enumeration type for selecting the policer profile functional type
112057 +*//***************************************************************************/
112058 +typedef enum ioc_fm_pcd_profile_type_selection {
112059 + e_IOC_FM_PCD_PLCR_PORT_PRIVATE, /**< Port dedicated profile */
112060 + e_IOC_FM_PCD_PLCR_SHARED /**< Shared profile (shared within partition) */
112061 +} ioc_fm_pcd_profile_type_selection;
112062 +
112063 +/**************************************************************************//**
112064 + @Description Enumeration type for selecting the policer profile algorithm
112065 +*//***************************************************************************/
112066 +typedef enum ioc_fm_pcd_plcr_algorithm_selection {
112067 + e_IOC_FM_PCD_PLCR_PASS_THROUGH, /**< Policer pass through */
112068 + e_IOC_FM_PCD_PLCR_RFC_2698, /**< Policer algorithm RFC 2698 */
112069 + e_IOC_FM_PCD_PLCR_RFC_4115 /**< Policer algorithm RFC 4115 */
112070 +} ioc_fm_pcd_plcr_algorithm_selection;
112071 +
112072 +/**************************************************************************//**
112073 + @Description Enumeration type for selecting a policer profile color mode
112074 +*//***************************************************************************/
112075 +typedef enum ioc_fm_pcd_plcr_color_mode {
112076 + e_IOC_FM_PCD_PLCR_COLOR_BLIND, /**< Color blind */
112077 + e_IOC_FM_PCD_PLCR_COLOR_AWARE /**< Color aware */
112078 +} ioc_fm_pcd_plcr_color_mode;
112079 +
112080 +/**************************************************************************//**
112081 + @Description Enumeration type for selecting a policer profile color
112082 +*//***************************************************************************/
112083 +typedef enum ioc_fm_pcd_plcr_color {
112084 + e_IOC_FM_PCD_PLCR_GREEN, /**< Green */
112085 + e_IOC_FM_PCD_PLCR_YELLOW, /**< Yellow */
112086 + e_IOC_FM_PCD_PLCR_RED, /**< Red */
112087 + e_IOC_FM_PCD_PLCR_OVERRIDE /**< Color override */
112088 +} ioc_fm_pcd_plcr_color;
112089 +
112090 +/**************************************************************************//**
112091 + @Description Enumeration type for selecting the policer profile packet frame length selector
112092 +*//***************************************************************************/
112093 +typedef enum ioc_fm_pcd_plcr_frame_length_select {
112094 + e_IOC_FM_PCD_PLCR_L2_FRM_LEN, /**< L2 frame length */
112095 + e_IOC_FM_PCD_PLCR_L3_FRM_LEN, /**< L3 frame length */
112096 + e_IOC_FM_PCD_PLCR_L4_FRM_LEN, /**< L4 frame length */
112097 + e_IOC_FM_PCD_PLCR_FULL_FRM_LEN /**< Full frame length */
112098 +} ioc_fm_pcd_plcr_frame_length_select;
112099 +
112100 +/**************************************************************************//**
112101 + @Description Enumeration type for selecting roll-back frame
112102 +*//***************************************************************************/
112103 +typedef enum ioc_fm_pcd_plcr_roll_back_frame_select {
112104 + e_IOC_FM_PCD_PLCR_ROLLBACK_L2_FRM_LEN, /**< Rollback L2 frame length */
112105 + e_IOC_FM_PCD_PLCR_ROLLBACK_FULL_FRM_LEN /**< Rollback Full frame length */
112106 +} ioc_fm_pcd_plcr_roll_back_frame_select;
112107 +
112108 +/**************************************************************************//**
112109 + @Description Enumeration type for selecting the policer profile packet or byte mode
112110 +*//***************************************************************************/
112111 +typedef enum ioc_fm_pcd_plcr_rate_mode {
112112 + e_IOC_FM_PCD_PLCR_BYTE_MODE, /**< Byte mode */
112113 + e_IOC_FM_PCD_PLCR_PACKET_MODE /**< Packet mode */
112114 +} ioc_fm_pcd_plcr_rate_mode;
112115 +
112116 +/**************************************************************************//**
112117 + @Description Enumeration type for defining action of frame
112118 +*//***************************************************************************/
112119 +typedef enum ioc_fm_pcd_done_action {
112120 + e_IOC_FM_PCD_ENQ_FRAME = 0, /**< Enqueue frame */
112121 + e_IOC_FM_PCD_DROP_FRAME /**< Drop frame */
112122 +} ioc_fm_pcd_done_action;
112123 +
112124 +/**************************************************************************//**
112125 + @Description Enumeration type for selecting the policer counter
112126 +*//***************************************************************************/
112127 +typedef enum ioc_fm_pcd_plcr_profile_counters {
112128 + e_IOC_FM_PCD_PLCR_PROFILE_GREEN_PACKET_TOTAL_COUNTER, /**< Green packets counter */
112129 + e_IOC_FM_PCD_PLCR_PROFILE_YELLOW_PACKET_TOTAL_COUNTER, /**< Yellow packets counter */
112130 + e_IOC_FM_PCD_PLCR_PROFILE_RED_PACKET_TOTAL_COUNTER, /**< Red packets counter */
112131 + e_IOC_FM_PCD_PLCR_PROFILE_RECOLOURED_YELLOW_PACKET_TOTAL_COUNTER, /**< Recolored yellow packets counter */
112132 + e_IOC_FM_PCD_PLCR_PROFILE_RECOLOURED_RED_PACKET_TOTAL_COUNTER /**< Recolored red packets counter */
112133 +} ioc_fm_pcd_plcr_profile_counters;
112134 +
112135 +/**************************************************************************//**
112136 + @Description Enumeration type for selecting the PCD action after extraction
112137 +*//***************************************************************************/
112138 +typedef enum ioc_fm_pcd_action {
112139 + e_IOC_FM_PCD_ACTION_NONE, /**< NONE */
112140 + e_IOC_FM_PCD_ACTION_EXACT_MATCH, /**< Exact match on the selected extraction*/
112141 + e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP /**< Indexed lookup on the selected extraction*/
112142 +} ioc_fm_pcd_action;
112143 +
112144 +/**************************************************************************//**
112145 + @Description Enumeration type for selecting type of insert manipulation
112146 +*//***************************************************************************/
112147 +typedef enum ioc_fm_pcd_manip_hdr_insrt_type {
112148 + e_IOC_FM_PCD_MANIP_INSRT_GENERIC, /**< Insert according to offset & size */
112149 + e_IOC_FM_PCD_MANIP_INSRT_BY_HDR, /**< Insert according to protocol */
112150 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
112151 + e_IOC_FM_PCD_MANIP_INSRT_BY_TEMPLATE /**< Insert template to start of frame */
112152 +#endif /* FM_CAPWAP_SUPPORT */
112153 +} ioc_fm_pcd_manip_hdr_insrt_type;
112154 +
112155 +/**************************************************************************//**
112156 + @Description Enumeration type for selecting type of remove manipulation
112157 +*//***************************************************************************/
112158 +typedef enum ioc_fm_pcd_manip_hdr_rmv_type {
112159 + e_IOC_FM_PCD_MANIP_RMV_GENERIC, /**< Remove according to offset & size */
112160 + e_IOC_FM_PCD_MANIP_RMV_BY_HDR /**< Remove according to offset & size */
112161 +} ioc_fm_pcd_manip_hdr_rmv_type;
112162 +
112163 +/**************************************************************************//**
112164 + @Description An enum for selecting specific L2 fields removal
112165 +*//***************************************************************************/
112166 +typedef enum ioc_fm_pcd_manip_hdr_rmv_specific_l2 {
112167 + e_IOC_FM_PCD_MANIP_HDR_RMV_ETHERNET, /**< Ethernet/802.3 MAC */
112168 + e_IOC_FM_PCD_MANIP_HDR_RMV_STACKED_QTAGS, /**< stacked QTags */
112169 + e_IOC_FM_PCD_MANIP_HDR_RMV_ETHERNET_AND_MPLS, /**< MPLS and Ethernet/802.3 MAC header until
112170 + the header which follows the MPLS header */
112171 + e_IOC_FM_PCD_MANIP_HDR_RMV_MPLS /**< Remove MPLS header (Unlimited MPLS labels) */
112172 +} ioc_fm_pcd_manip_hdr_rmv_specific_l2;
112173 +
112174 +/**************************************************************************//**
112175 + @Description Enumeration type for selecting specific fields updates
112176 +*//***************************************************************************/
112177 +typedef enum ioc_fm_pcd_manip_hdr_field_update_type {
112178 + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN, /**< VLAN updates */
112179 + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV4, /**< IPV4 updates */
112180 + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV6, /**< IPV6 updates */
112181 + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_TCP_UDP, /**< TCP_UDP updates */
112182 +} ioc_fm_pcd_manip_hdr_field_update_type;
112183 +
112184 +/**************************************************************************//**
112185 + @Description Enumeration type for selecting VLAN updates
112186 +*//***************************************************************************/
112187 +typedef enum ioc_fm_pcd_manip_hdr_field_update_vlan {
112188 + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN_VPRI, /**< Replace VPri of outer most VLAN tag. */
112189 + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN /**< DSCP to VLAN priority bits translation */
112190 +} ioc_fm_pcd_manip_hdr_field_update_vlan;
112191 +
112192 +/**************************************************************************//**
112193 + @Description Enumeration type for selecting specific L2 fields removal
112194 +*//***************************************************************************/
112195 +typedef enum ioc_fm_pcd_manip_hdr_insrt_specific_l2 {
112196 + e_IOC_FM_PCD_MANIP_HDR_INSRT_MPLS /**< Insert MPLS header (Unlimited MPLS labels) */
112197 +} ioc_fm_pcd_manip_hdr_insrt_specific_l2;
112198 +
112199 +#if (DPAA_VERSION >= 11)
112200 +/**************************************************************************//**
112201 + @Description Enumeration type for selecting QoS mapping mode
112202 +
112203 + Note: In all cases except 'e_FM_PCD_MANIP_HDR_QOS_MAPPING_NONE'
112204 + User should instruct the port to read the parser-result
112205 +*//***************************************************************************/
112206 +typedef enum ioc_fm_pcd_manip_hdr_qos_mapping_mode {
112207 + e_IOC_FM_PCD_MANIP_HDR_QOS_MAPPING_NONE = 0, /**< No mapping, QoS field will not be changed */
112208 + e_IOC_FM_PCD_MANIP_HDR_QOS_MAPPING_AS_IS, /**< QoS field will be overwritten by the last byte in the parser-result. */
112209 +} ioc_fm_pcd_manip_hdr_qos_mapping_mode;
112210 +
112211 +/**************************************************************************//**
112212 + @Description Enumeration type for selecting QoS source
112213 +
112214 + Note: In all cases except 'e_FM_PCD_MANIP_HDR_QOS_SRC_NONE'
112215 + User should left room for the parser-result on input/output buffer
112216 + and instruct the port to read/write the parser-result to the buffer (RPD should be set)
112217 +*//***************************************************************************/
112218 +typedef enum ioc_fm_pcd_manip_hdr_qos_src {
112219 + e_IOC_FM_PCD_MANIP_HDR_QOS_SRC_NONE = 0, /**< TODO */
112220 + e_IOC_FM_PCD_MANIP_HDR_QOS_SRC_USER_DEFINED, /**< QoS will be taken from the last byte in the parser-result. */
112221 +} ioc_fm_pcd_manip_hdr_qos_src;
112222 +#endif /* (DPAA_VERSION >= 11) */
112223 +
112224 +/**************************************************************************//**
112225 + @Description Enumeration type for selecting type of header insertion
112226 +*//***************************************************************************/
112227 +typedef enum ioc_fm_pcd_manip_hdr_insrt_by_hdr_type {
112228 + e_IOC_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2, /**< Specific L2 fields insertion */
112229 +#if (DPAA_VERSION >= 11)
112230 + e_IOC_FM_PCD_MANIP_INSRT_BY_HDR_IP, /**< IP insertion */
112231 + e_IOC_FM_PCD_MANIP_INSRT_BY_HDR_UDP, /**< UDP insertion */
112232 + e_IOC_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE, /**< UDP lite insertion */
112233 + e_IOC_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP /**< CAPWAP insertion */
112234 +#endif /* (DPAA_VERSION >= 11) */
112235 +} ioc_fm_pcd_manip_hdr_insrt_by_hdr_type;
112236 +
112237 +/**************************************************************************//**
112238 + @Description Enumeration type for selecting specific custom command
112239 +*//***************************************************************************/
112240 +typedef enum ioc_fm_pcd_manip_hdr_custom_type {
112241 + e_IOC_FM_PCD_MANIP_HDR_CUSTOM_IP_REPLACE, /**< Replace IPv4/IPv6 */
112242 +} ioc_fm_pcd_manip_hdr_custom_type;
112243 +
112244 +/**************************************************************************//**
112245 + @Description Enumeration type for selecting specific custom command
112246 +*//***************************************************************************/
112247 +typedef enum ioc_fm_pcd_manip_hdr_custom_ip_replace {
112248 + e_IOC_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV4_BY_IPV6, /**< Replace IPv4 by IPv6 */
112249 + e_IOC_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4 /**< Replace IPv6 by IPv4 */
112250 +} ioc_fm_pcd_manip_hdr_custom_ip_replace;
112251 +
112252 +/**************************************************************************//**
112253 + @Description Enumeration type for selecting type of header removal
112254 +*//***************************************************************************/
112255 +typedef enum ioc_fm_pcd_manip_hdr_rmv_by_hdr_type {
112256 + e_IOC_FM_PCD_MANIP_RMV_BY_HDR_SPECIFIC_L2 = 0, /**< Specific L2 fields removal */
112257 +#if (DPAA_VERSION >= 11)
112258 + e_IOC_FM_PCD_MANIP_RMV_BY_HDR_CAPWAP, /**< CAPWAP removal */
112259 +#endif /* (DPAA_VERSION >= 11) */
112260 +#if (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
112261 + e_IOC_FM_PCD_MANIP_RMV_BY_HDR_FROM_START, /**< Locate from data that is not the header */
112262 +#endif /* (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
112263 +} ioc_fm_pcd_manip_hdr_rmv_by_hdr_type;
112264 +
112265 +/**************************************************************************//**
112266 + @Description Enumeration type for selecting type of timeout mode
112267 +*//***************************************************************************/
112268 +typedef enum ioc_fm_pcd_manip_reassem_time_out_mode {
112269 + e_IOC_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAMES, /**< Limits the time of the reassembly process
112270 + from the first fragment to the last */
112271 + e_IOC_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAG /**< Limits the time of receiving the fragment */
112272 +} ioc_fm_pcd_manip_reassem_time_out_mode;
112273 +
112274 +/**************************************************************************//**
112275 + @Description Enumeration type for selecting type of WaysNumber mode
112276 +*//***************************************************************************/
112277 +typedef enum ioc_fm_pcd_manip_reassem_ways_number {
112278 + e_IOC_FM_PCD_MANIP_ONE_WAY_HASH = 1, /**< One way hash */
112279 + e_IOC_FM_PCD_MANIP_TWO_WAYS_HASH, /**< Two ways hash */
112280 + e_IOC_FM_PCD_MANIP_THREE_WAYS_HASH, /**< Three ways hash */
112281 + e_IOC_FM_PCD_MANIP_FOUR_WAYS_HASH, /**< Four ways hash */
112282 + e_IOC_FM_PCD_MANIP_FIVE_WAYS_HASH, /**< Five ways hash */
112283 + e_IOC_FM_PCD_MANIP_SIX_WAYS_HASH, /**< Six ways hash */
112284 + e_IOC_FM_PCD_MANIP_SEVEN_WAYS_HASH, /**< Seven ways hash */
112285 + e_IOC_FM_PCD_MANIP_EIGHT_WAYS_HASH /**< Eight ways hash */
112286 +} ioc_fm_pcd_manip_reassem_ways_number;
112287 +
112288 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
112289 +/**************************************************************************//**
112290 + @Description Enumeration type for selecting type of statistics mode
112291 +*//***************************************************************************/
112292 +typedef enum ioc_fm_pcd_stats {
112293 + e_IOC_FM_PCD_STATS_PER_FLOWID = 0 /**< Flow ID is used as index for getting statistics */
112294 +} ioc_fm_pcd_stats;
112295 +#endif
112296 +
112297 +/**************************************************************************//**
112298 + @Description Enumeration type for selecting manipulation type
112299 +*//***************************************************************************/
112300 +typedef enum ioc_fm_pcd_manip_type {
112301 + e_IOC_FM_PCD_MANIP_HDR = 0, /**< Header manipulation */
112302 + e_IOC_FM_PCD_MANIP_REASSEM, /**< Reassembly */
112303 + e_IOC_FM_PCD_MANIP_FRAG, /**< Fragmentation */
112304 + e_IOC_FM_PCD_MANIP_SPECIAL_OFFLOAD /**< Special Offloading */
112305 +} ioc_fm_pcd_manip_type;
112306 +
112307 +/**************************************************************************//**
112308 + @Description Enumeration type for selecting type of statistics mode
112309 +*//***************************************************************************/
112310 +typedef enum ioc_fm_pcd_cc_stats_mode {
112311 + e_IOC_FM_PCD_CC_STATS_MODE_NONE = 0, /**< No statistics support */
112312 + e_IOC_FM_PCD_CC_STATS_MODE_FRAME, /**< Frame count statistics */
112313 + e_IOC_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME, /**< Byte and frame count statistics */
112314 +#if (DPAA_VERSION >= 11)
112315 + e_IOC_FM_PCD_CC_STATS_MODE_RMON, /**< Byte and frame length range count statistics */
112316 +#endif /* (DPAA_VERSION >= 11) */
112317 +} ioc_fm_pcd_cc_stats_mode;
112318 +
112319 +/**************************************************************************//**
112320 + @Description Enumeration type for determining the action in case an IP packet
112321 + is larger than MTU but its DF (Don't Fragment) bit is set.
112322 +*//***************************************************************************/
112323 +typedef enum ioc_fm_pcd_manip_dont_frag_action {
112324 + e_IOC_FM_PCD_MANIP_DISCARD_PACKET = 0, /**< Discard packet */
112325 + e_IOC_FM_PCD_MANIP_ENQ_TO_ERR_Q_OR_DISCARD_PACKET = e_IOC_FM_PCD_MANIP_DISCARD_PACKET,
112326 + /**< Obsolete, cannot enqueue to error queue;
112327 + In practice, selects to discard packets;
112328 + Will be removed in the future */
112329 + e_IOC_FM_PCD_MANIP_FRAGMENT_PACKECT, /**< Fragment packet and continue normal processing */
112330 + e_IOC_FM_PCD_MANIP_CONTINUE_WITHOUT_FRAG /**< Continue normal processing without fragmenting the packet */
112331 +} ioc_fm_pcd_manip_dont_frag_action;
112332 +
112333 +/**************************************************************************//**
112334 + @Description Enumeration type for selecting type of special offload manipulation
112335 +*//***************************************************************************/
112336 +typedef enum ioc_fm_pcd_manip_special_offload_type {
112337 + e_IOC_FM_PCD_MANIP_SPECIAL_OFFLOAD_IPSEC, /**< IPSec offload manipulation */
112338 +#if (DPAA_VERSION >= 11)
112339 + e_IOC_FM_PCD_MANIP_SPECIAL_OFFLOAD_CAPWAP /**< CAPWAP offload manipulation */
112340 +#endif /* (DPAA_VERSION >= 11) */
112341 +} ioc_fm_pcd_manip_special_offload_type;
112342 +
112343 +/**************************************************************************//**
112344 + @Description A union of protocol dependent special options
112345 + (Must match union u_FmPcdHdrProtocolOpt defined in fm_pcd_ext.h)
112346 +*//***************************************************************************/
112347 +typedef union ioc_fm_pcd_hdr_protocol_opt_u {
112348 + ioc_eth_protocol_opt_t eth_opt; /**< Ethernet options */
112349 + ioc_vlan_protocol_opt_t vlan_opt; /**< Vlan options */
112350 + ioc_mpls_protocol_opt_t mpls_opt; /**< MPLS options */
112351 + ioc_ipv4_protocol_opt_t ipv4_opt; /**< IPv4 options */
112352 + ioc_ipv6_protocol_opt_t ipv6_opt; /**< IPv6 options */
112353 +#if (DPAA_VERSION >= 11)
112354 + ioc_capwap_protocol_opt_t capwap_opt; /**< CAPWAP options */
112355 +#endif /* (DPAA_VERSION >= 11) */
112356 +} ioc_fm_pcd_hdr_protocol_opt_u;
112357 +
112358 +/**************************************************************************//**
112359 + @Description A union holding all known protocol fields
112360 +*//***************************************************************************/
112361 +typedef union ioc_fm_pcd_fields_u {
112362 + ioc_header_field_eth_t eth; /**< Ethernet */
112363 + ioc_header_field_vlan_t vlan; /**< VLAN */
112364 + ioc_header_field_llc_snap_t llc_snap; /**< LLC SNAP */
112365 + ioc_header_field_pppoe_t pppoe; /**< PPPoE */
112366 + ioc_header_field_mpls_t mpls; /**< MPLS */
112367 + ioc_header_field_ip_t ip; /**< IP */
112368 + ioc_header_field_ipv4_t ipv4; /**< IPv4 */
112369 + ioc_header_field_ipv6_t ipv6; /**< IPv6 */
112370 + ioc_header_field_udp_t udp; /**< UDP */
112371 + ioc_header_field_udp_lite_t udp_lite; /**< UDP_Lite */
112372 + ioc_header_field_tcp_t tcp; /**< TCP */
112373 + ioc_header_field_sctp_t sctp; /**< SCTP */
112374 + ioc_header_field_dccp_t dccp; /**< DCCP */
112375 + ioc_header_field_gre_t gre; /**< GRE */
112376 + ioc_header_field_minencap_t minencap; /**< Minimal Encapsulation */
112377 + ioc_header_field_ipsec_ah_t ipsec_ah; /**< IPSec AH */
112378 + ioc_header_field_ipsec_esp_t ipsec_esp; /**< IPSec ESP */
112379 + ioc_header_field_udp_encap_esp_t udp_encap_esp; /**< UDP Encapsulation ESP */
112380 +} ioc_fm_pcd_fields_u;
112381 +
112382 +/**************************************************************************//**
112383 + @Description Parameters for defining header extraction for key generation
112384 +*//***************************************************************************/
112385 +typedef struct ioc_fm_pcd_from_hdr_t {
112386 + uint8_t size; /**< Size in byte */
112387 + uint8_t offset; /**< Byte offset */
112388 +} ioc_fm_pcd_from_hdr_t;
112389 +
112390 +/**************************************************************************//**
112391 + @Description Parameters for defining field extraction for key generation
112392 +*//***************************************************************************/
112393 +typedef struct ioc_fm_pcd_from_field_t {
112394 + ioc_fm_pcd_fields_u field; /**< Field selection */
112395 + uint8_t size; /**< Size in byte */
112396 + uint8_t offset; /**< Byte offset */
112397 +} ioc_fm_pcd_from_field_t;
112398 +
112399 +/**************************************************************************//**
112400 + @Description Parameters for defining a single network environment unit
112401 + A distinction unit should be defined if it will later be used
112402 + by one or more PCD engines to distinguish between flows.
112403 + (Must match struct t_FmPcdDistinctionUnit defined in fm_pcd_ext.h)
112404 +*//***************************************************************************/
112405 +typedef struct ioc_fm_pcd_distinction_unit_t {
112406 + struct {
112407 + ioc_net_header_type hdr; /**< One of the headers supported by the FM */
112408 + ioc_fm_pcd_hdr_protocol_opt_u opt; /**< Select only one option! */
112409 + } hdrs[IOC_FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS];
112410 +} ioc_fm_pcd_distinction_unit_t;
112411 +
112412 +/**************************************************************************//**
112413 + @Description Parameters for defining all different distinction units supported
112414 + by a specific PCD Network Environment Characteristics module.
112415 +
112416 + Each unit represent a protocol or a group of protocols that may
112417 + be used later by the different PCD engines to distinguish between flows.
112418 + (Must match struct t_FmPcdNetEnvParams defined in fm_pcd_ext.h)
112419 +*//***************************************************************************/
112420 +typedef struct ioc_fm_pcd_net_env_params_t {
112421 + uint8_t num_of_distinction_units;/**< Number of different units to be identified */
112422 + ioc_fm_pcd_distinction_unit_t units[IOC_FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS];
112423 + /**< An array of num_of_distinction_units of the
112424 + different units to be identified */
112425 + void *id; /**< Output parameter; Returns the net-env Id to be used */
112426 +} ioc_fm_pcd_net_env_params_t;
112427 +
112428 +/**************************************************************************//**
112429 + @Description Parameters for defining a single extraction action when
112430 + creating a key
112431 +*//***************************************************************************/
112432 +typedef struct ioc_fm_pcd_extract_entry_t {
112433 + ioc_fm_pcd_extract_type type; /**< Extraction type select */
112434 + union {
112435 + struct {
112436 + ioc_net_header_type hdr; /**< Header selection */
112437 + bool ignore_protocol_validation;
112438 + /**< Ignore protocol validation */
112439 + ioc_fm_pcd_hdr_index hdr_index; /**< Relevant only for MPLS, VLAN and tunneled
112440 + IP. Otherwise should be cleared.*/
112441 + ioc_fm_pcd_extract_by_hdr_type type; /**< Header extraction type select */
112442 + union {
112443 + ioc_fm_pcd_from_hdr_t from_hdr; /**< Extract bytes from header parameters */
112444 + ioc_fm_pcd_from_field_t from_field; /**< Extract bytes from field parameters */
112445 + ioc_fm_pcd_fields_u full_field; /**< Extract full field parameters */
112446 + } extract_by_hdr_type;
112447 + } extract_by_hdr; /**< Used when type = e_IOC_FM_PCD_KG_EXTRACT_BY_HDR */
112448 + struct {
112449 + ioc_fm_pcd_extract_from src; /**< Non-header extraction source */
112450 + ioc_fm_pcd_action action; /**< Relevant for CC Only */
112451 + uint16_t ic_indx_mask; /**< Relevant only for CC when
112452 + action = e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP;
112453 + Note that the number of bits that are set within
112454 + this mask must be log2 of the CC-node 'num_of_keys'.
112455 + Note that the mask cannot be set on the lower bits. */
112456 + uint8_t offset; /**< Byte offset */
112457 + uint8_t size; /**< Size in bytes */
112458 + } extract_non_hdr; /**< Used when type = e_IOC_FM_PCD_KG_EXTRACT_NON_HDR */
112459 + } extract_params;
112460 +} ioc_fm_pcd_extract_entry_t;
112461 +
112462 +/**************************************************************************//**
112463 + @Description A structure for defining masks for each extracted
112464 + field in the key.
112465 +*//***************************************************************************/
112466 +typedef struct ioc_fm_pcd_kg_extract_mask_t {
112467 + uint8_t extract_array_index; /**< Index in the extraction array, as initialized by user */
112468 + uint8_t offset; /**< Byte offset */
112469 + uint8_t mask; /**< A byte mask (selected bits will be ignored) */
112470 +} ioc_fm_pcd_kg_extract_mask_t;
112471 +
112472 +/**************************************************************************//**
112473 + @Description A structure for defining default selection per groups
112474 + of fields
112475 +*//***************************************************************************/
112476 +typedef struct ioc_fm_pcd_kg_extract_dflt_t {
112477 + ioc_fm_pcd_kg_known_fields_dflt_types type; /**< Default type select*/
112478 + ioc_fm_pcd_kg_extract_dflt_select dflt_select; /**< Default register select */
112479 +} ioc_fm_pcd_kg_extract_dflt_t;
112480 +
112481 +
112482 +/**************************************************************************//**
112483 + @Description A structure for defining all parameters needed for
112484 + generation a key and using a hash function
112485 +*//***************************************************************************/
112486 +typedef struct ioc_fm_pcd_kg_key_extract_and_hash_params_t {
112487 + uint32_t private_dflt0; /**< Scheme default register 0 */
112488 + uint32_t private_dflt1; /**< Scheme default register 1 */
112489 + uint8_t num_of_used_extracts; /**< defines the valid size of the following array */
112490 + ioc_fm_pcd_extract_entry_t extract_array [IOC_FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY];
112491 + /**< An array of extraction definitions. */
112492 + uint8_t num_of_used_dflts; /**< defines the valid size of the following array */
112493 + ioc_fm_pcd_kg_extract_dflt_t dflts[IOC_FM_PCD_KG_NUM_OF_DEFAULT_GROUPS];
112494 + /**< For each extraction used in this scheme, specify the required
112495 + default register to be used when header is not found.
112496 + types not specified in this array will get undefined value. */
112497 + uint8_t num_of_used_masks; /**< Defines the valid size of the following array */
112498 + ioc_fm_pcd_kg_extract_mask_t masks[IOC_FM_PCD_KG_NUM_OF_EXTRACT_MASKS];
112499 + uint8_t hash_shift; /**< Hash result right shift.
112500 + Selects the 24 bits out of the 64 hash result.
112501 + 0 means using the 24 LSB's, otherwise use the
112502 + 24 LSB's after shifting right.*/
112503 + uint32_t hash_distribution_num_of_fqids; /**< must be > 1 and a power of 2. Represents the range
112504 + of queues for the key and hash functionality */
112505 + uint8_t hash_distribution_fqids_shift; /**< selects the FQID bits that will be effected by the hash */
112506 + bool symmetric_hash; /**< TRUE to generate the same hash for frames with swapped source and
112507 + destination fields on all layers; If TRUE, driver will check that for
112508 + all layers, if SRC extraction is selected, DST extraction must also be
112509 + selected, and vice versa. */
112510 +} ioc_fm_pcd_kg_key_extract_and_hash_params_t;
112511 +
112512 +/**************************************************************************//**
112513 + @Description A structure of parameters for defining a single
112514 + Qid mask (extracted OR).
112515 +*//***************************************************************************/
112516 +typedef struct ioc_fm_pcd_kg_extracted_or_params_t {
112517 + ioc_fm_pcd_extract_type type; /**< Extraction type select */
112518 + union {
112519 + struct { /**< used when type = e_IOC_FM_PCD_KG_EXTRACT_BY_HDR */
112520 + ioc_net_header_type hdr;
112521 + ioc_fm_pcd_hdr_index hdr_index; /**< Relevant only for MPLS, VLAN and tunneled
112522 + IP. Otherwise should be cleared.*/
112523 + bool ignore_protocol_validation;
112524 +
112525 + } extract_by_hdr;
112526 + ioc_fm_pcd_extract_from src; /**< used when type = e_IOC_FM_PCD_KG_EXTRACT_NON_HDR */
112527 + } extract_params;
112528 + uint8_t extraction_offset; /**< Offset for extraction */
112529 + ioc_fm_pcd_kg_extract_dflt_select dflt_value; /**< Select register from which extraction is taken if
112530 + field not found */
112531 + uint8_t mask; /**< Mask LSB byte of extraction (specified bits are ignored) */
112532 + uint8_t bit_offset_in_fqid; /**< 0-31, Selects which bits of the 24 FQID bits to effect using
112533 + the extracted byte; Assume byte is placed as the 8 MSB's in
112534 + a 32 bit word where the lower bits
112535 + are the FQID; i.e if bitOffsetInFqid=1 than its LSB
112536 + will effect the FQID MSB, if bitOffsetInFqid=24 than the
112537 + extracted byte will effect the 8 LSB's of the FQID,
112538 + if bitOffsetInFqid=31 than the byte's MSB will effect
112539 + the FQID's LSB; 0 means - no effect on FQID;
112540 + Note that one, and only one of
112541 + bitOffsetInFqid or bitOffsetInPlcrProfile must be set (i.e,
112542 + extracted byte must effect either FQID or Policer profile).*/
112543 + uint8_t bit_offset_in_plcr_profile;
112544 + /**< 0-15, Selects which bits of the 8 policer profile id bits to
112545 + effect using the extracted byte; Assume byte is placed
112546 + as the 8 MSB's in a 16 bit word where the lower bits
112547 + are the policer profile id; i.e if bitOffsetInPlcrProfile=1
112548 + than its LSB will effect the profile MSB, if bitOffsetInFqid=8
112549 + than the extracted byte will effect the whole policer profile id,
112550 + if bitOffsetInFqid=15 than the byte's MSB will effect
112551 + the Policer Profile id's LSB;
112552 + 0 means - no effect on policer profile; Note that one, and only one of
112553 + bitOffsetInFqid or bitOffsetInPlcrProfile must be set (i.e,
112554 + extracted byte must effect either FQID or Policer profile).*/
112555 +} ioc_fm_pcd_kg_extracted_or_params_t;
112556 +
112557 +/**************************************************************************//**
112558 + @Description A structure for configuring scheme counter
112559 +*//***************************************************************************/
112560 +typedef struct ioc_fm_pcd_kg_scheme_counter_t {
112561 + bool update; /**< FALSE to keep the current counter state
112562 + and continue from that point, TRUE to update/reset
112563 + the counter when the scheme is written. */
112564 + uint32_t value; /**< If update=TRUE, this value will be written into the
112565 + counter; clear this field to reset the counter. */
112566 +} ioc_fm_pcd_kg_scheme_counter_t;
112567 +
112568 +
112569 +/**************************************************************************//**
112570 + @Description A structure for retrieving FMKG_SE_SPC
112571 +*//***************************************************************************/
112572 +typedef struct ioc_fm_pcd_kg_scheme_spc_t {
112573 + uint32_t val; /**< return value */
112574 + void *id; /**< scheme handle */
112575 +} ioc_fm_pcd_kg_scheme_spc_t;
112576 +
112577 +/**************************************************************************//**
112578 + @Description A structure for defining policer profile parameters as required by keygen
112579 + (when policer is the next engine after this scheme).
112580 + (Must match struct t_FmPcdKgPlcrProfile defined in fm_pcd_ext.h)
112581 +*//***************************************************************************/
112582 +typedef struct ioc_fm_pcd_kg_plcr_profile_t {
112583 + bool shared_profile; /**< TRUE if this profile is shared between ports
112584 + (i.e. managed by master partition) May not be TRUE
112585 + if profile is after Coarse Classification*/
112586 + bool direct; /**< If TRUE, direct_relative_profile_id only selects the profile
112587 + id, if FALSE fqid_offset_relative_profile_id_base is used
112588 + together with fqid_offset_shift and num_of_profiles
112589 + parameters, to define a range of profiles from
112590 + which the KeyGen result will determine the
112591 + destination policer profile. */
112592 + union {
112593 + uint16_t direct_relative_profile_id; /**< Used if 'direct' is TRUE, to select policer profile.
112594 + This parameter should indicate the policer profile offset within the port's
112595 + policer profiles or SHARED window. */
112596 + struct {
112597 + uint8_t fqid_offset_shift; /**< Shift of KG results without the qid base */
112598 + uint8_t fqid_offset_relative_profile_id_base;
112599 + /**< OR of KG results without the qid base
112600 + This parameter should indicate the policer profile
112601 + offset within the port's policer profiles window
112602 + or SHARED window depends on shared_profile */
112603 + uint8_t num_of_profiles; /**< Range of profiles starting at base */
112604 + } indirect_profile; /**< Indirect profile parameters */
112605 + } profile_select; /**< Direct/indirect profile selection and parameters */
112606 +} ioc_fm_pcd_kg_plcr_profile_t;
112607 +
112608 +#if DPAA_VERSION >= 11
112609 +/**************************************************************************//**
112610 + @Description Parameters for configuring a storage profile for a KeyGen scheme.
112611 +*//***************************************************************************/
112612 +typedef struct ioc_fm_pcd_kg_storage_profile_t {
112613 + bool direct; /**< If TRUE, directRelativeProfileId only selects the
112614 + profile id;
112615 + If FALSE, fqidOffsetRelativeProfileIdBase is used
112616 + together with fqidOffsetShift and numOfProfiles
112617 + parameters to define a range of profiles from which
112618 + the KeyGen result will determine the destination
112619 + storage profile. */
112620 + union {
112621 + uint16_t direct_relative_profileId; /**< Used when 'direct' is TRUE, to select a storage profile;
112622 + should indicate the storage profile offset within the
112623 + port's storage profiles window. */
112624 + struct {
112625 + uint8_t fqid_offset_shift; /**< Shift of KeyGen results without the FQID base */
112626 + uint8_t fqid_offset_relative_profile_id_base;
112627 + /**< OR of KeyGen results without the FQID base;
112628 + should indicate the policer profile offset within the
112629 + port's storage profiles window. */
112630 + uint8_t num_of_profiles; /**< Range of profiles starting at base. */
112631 + } indirect_profile; /**< Indirect profile parameters. */
112632 + } profile_select; /**< Direct/indirect profile selection and parameters. */
112633 +} ioc_fm_pcd_kg_storage_profile_t;
112634 +#endif /* DPAA_VERSION >= 11 */
112635 +
112636 +/**************************************************************************//**
112637 + @Description Parameters for defining CC as the next engine after KeyGen
112638 + (Must match struct t_FmPcdKgCc defined in fm_pcd_ext.h)
112639 +*//***************************************************************************/
112640 +typedef struct ioc_fm_pcd_kg_cc_t {
112641 + void *tree_id; /**< CC Tree id */
112642 + uint8_t grp_id; /**< CC group id within the CC tree */
112643 + bool plcr_next; /**< TRUE if after CC, in case of data frame,
112644 + policing is required. */
112645 + bool bypass_plcr_profile_generation;
112646 + /**< TRUE to bypass KeyGen policer profile generation;
112647 + selected profile is the one set at port initialization. */
112648 + ioc_fm_pcd_kg_plcr_profile_t plcr_profile; /**< Valid only if plcr_next = TRUE and
112649 + bypass_plcr_profile_generation = FALSE */
112650 +} ioc_fm_pcd_kg_cc_t;
112651 +
112652 +/**************************************************************************//**
112653 + @Description Parameters for defining initializing a KeyGen scheme
112654 + (Must match struct t_FmPcdKgSchemeParams defined in fm_pcd_ext.h)
112655 +*//***************************************************************************/
112656 +typedef struct ioc_fm_pcd_kg_scheme_params_t {
112657 + bool modify; /**< TRUE to change an existing scheme */
112658 + union {
112659 + uint8_t relative_scheme_id;
112660 + /**< if modify=FALSE: partition-relative scheme id */
112661 + void *scheme_id; /**< if modify=TRUE: the id of an existing scheme */
112662 + } scm_id;
112663 + bool always_direct; /**< This scheme is reached only directly, i.e. no need
112664 + for match vector; KeyGen will ignore it when matching */
112665 + struct { /**< HL relevant only if always_direct=FALSE */
112666 + void *net_env_id; /**< The id of the Network Environment as returned
112667 + by FM_PCD_NetEnvCharacteristicsSet() */
112668 + uint8_t num_of_distinction_units;
112669 + /**< Number of NetEnv units listed in unit_ids array */
112670 + uint8_t unit_ids[IOC_FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS];
112671 + /**< Indexes as passed to SetNetEnvCharacteristics (?) array */
112672 + } net_env_params;
112673 + bool use_hash; /**< use the KG Hash functionality */
112674 + ioc_fm_pcd_kg_key_extract_and_hash_params_t key_extract_and_hash_params;
112675 + /**< used only if useHash = TRUE */
112676 + bool bypass_fqid_generation;
112677 + /**< Normally - FALSE, TRUE to avoid FQID update in the IC;
112678 + In such a case FQID after KG will be the default FQID
112679 + defined for the relevant port, or the FQID defined by CC
112680 + in cases where CC was the previous engine. */
112681 + uint32_t base_fqid; /**< Base FQID; Relevant only if bypass_fqid_generation = FALSE;
112682 + If hash is used and an even distribution is expected
112683 + according to hash_distribution_num_of_fqids, base_fqid must be aligned to
112684 + hash_distribution_num_of_fqids. */
112685 + uint8_t num_of_used_extracted_ors;
112686 + /**< Number of FQID masks listed in extracted_ors array*/
112687 + ioc_fm_pcd_kg_extracted_or_params_t extracted_ors[IOC_FM_PCD_KG_NUM_OF_GENERIC_REGS];
112688 + /**< IOC_FM_PCD_KG_NUM_OF_GENERIC_REGS
112689 + registers are shared between qid_masks
112690 + functionality and some of the extraction
112691 + actions; Normally only some will be used
112692 + for qid_mask. Driver will return error if
112693 + resource is full at initialization time. */
112694 +#if DPAA_VERSION >= 11
112695 + bool override_storage_profile;
112696 + /**< TRUE if KeyGen override previously decided storage profile */
112697 + ioc_fm_pcd_kg_storage_profile_t storage_profile;/**< Used when override_storage_profile=TRUE */
112698 +#endif /* DPAA_VERSION >= 11 */
112699 + ioc_fm_pcd_engine next_engine; /**< may be BMI, PLCR or CC */
112700 + union { /**< depends on nextEngine */
112701 + ioc_fm_pcd_done_action done_action; /**< Used when next engine is BMI (done) */
112702 + ioc_fm_pcd_kg_plcr_profile_t plcr_profile; /**< Used when next engine is PLCR */
112703 + ioc_fm_pcd_kg_cc_t cc; /**< Used when next engine is CC */
112704 + } kg_next_engine_params;
112705 + ioc_fm_pcd_kg_scheme_counter_t scheme_counter; /**< A structure of parameters for updating
112706 + the scheme counter */
112707 + void *id; /**< Returns the scheme Id to be used */
112708 +} ioc_fm_pcd_kg_scheme_params_t;
112709 +
112710 +/**************************************************************************//**
112711 + @Collection
112712 +*//***************************************************************************/
112713 +#if DPAA_VERSION >= 11
112714 +#define IOC_FM_PCD_CC_STATS_MAX_NUM_OF_FLR 10 /* Maximal supported number of frame length ranges */
112715 +#define IOC_FM_PCD_CC_STATS_FLR_SIZE 2 /* Size in bytes of a frame length range limit */
112716 +#endif /* DPAA_VERSION >= 11 */
112717 +#define IOC_FM_PCD_CC_STATS_FLR_COUNT_SIZE 4 /* Size in bytes of a frame length range counter */
112718 +/* @} */
112719 +
112720 +/**************************************************************************//**
112721 + @Description Parameters for defining CC as the next engine after a CC node.
112722 + (Must match struct t_FmPcdCcNextCcParams defined in fm_pcd_ext.h)
112723 +*//***************************************************************************/
112724 +typedef struct ioc_fm_pcd_cc_next_cc_params_t {
112725 + void *cc_node_id; /**< Id of the next CC node */
112726 +} ioc_fm_pcd_cc_next_cc_params_t;
112727 +
112728 +#if DPAA_VERSION >= 11
112729 +/**************************************************************************//**
112730 + @Description A structure for defining Frame Replicator as the next engine after a CC node.
112731 + (Must match struct t_FmPcdCcNextFrParams defined in fm_pcd_ext.h)
112732 +*//***************************************************************************/
112733 +typedef struct ioc_fm_pcd_cc_next_fr_params_t {
112734 + void* frm_replic_id; /**< The id of the next frame replicator group */
112735 +} ioc_fm_pcd_cc_next_fr_params_t;
112736 +#endif /* DPAA_VERSION >= 11 */
112737 +
112738 +/**************************************************************************//**
112739 + @Description A structure for defining PLCR params when PLCR is the
112740 + next engine after a CC node
112741 + (Must match struct t_FmPcdCcNextPlcrParams defined in fm_pcd_ext.h)
112742 +*//***************************************************************************/
112743 +typedef struct ioc_fm_pcd_cc_next_plcr_params_t {
112744 + bool override_params; /**< TRUE if CC override previously decided parameters*/
112745 + bool shared_profile; /**< Relevant only if overrideParams=TRUE:
112746 + TRUE if this profile is shared between ports */
112747 + uint16_t new_relative_profile_id; /**< Relevant only if overrideParams=TRUE:
112748 + (otherwise profile id is taken from keygen);
112749 + This parameter should indicate the policer
112750 + profile offset within the port's
112751 + policer profiles or from SHARED window.*/
112752 + uint32_t new_fqid; /**< Relevant only if overrideParams=TRUE:
112753 + FQID for enquing the frame;
112754 + In earlier chips if policer next engine is KEYGEN,
112755 + this parameter can be 0, because the KEYGEN always decides
112756 + the enqueue FQID.*/
112757 +#if DPAA_VERSION >= 11
112758 + uint8_t new_relative_storage_profile_id;
112759 + /**< Indicates the relative storage profile offset within
112760 + the port's storage profiles window;
112761 + Relevant only if the port was configured with VSP. */
112762 +#endif /* DPAA_VERSION >= 11 */
112763 +} ioc_fm_pcd_cc_next_plcr_params_t;
112764 +
112765 +/**************************************************************************//**
112766 + @Description A structure for defining enqueue params when BMI is the
112767 + next engine after a CC node
112768 + (Must match struct t_FmPcdCcNextEnqueueParams defined in fm_pcd_ext.h)
112769 +*//***************************************************************************/
112770 +typedef struct ioc_fm_pcd_cc_next_enqueue_params_t {
112771 + ioc_fm_pcd_done_action action; /**< Action - when next engine is BMI (done) */
112772 + bool override_fqid; /**< TRUE if CC override previously decided fqid and vspid,
112773 + relevant if action = e_IOC_FM_PCD_ENQ_FRAME */
112774 + uint32_t new_fqid; /**< Valid if overrideFqid=TRUE, FQID for enqueuing the frame
112775 + (otherwise FQID is taken from KeyGen),
112776 + relevant if action = e_IOC_FM_PCD_ENQ_FRAME*/
112777 +#if DPAA_VERSION >= 11
112778 + uint8_t new_relative_storage_profile_id;
112779 + /**< Valid if override_fqid=TRUE, Indicates the relative virtual
112780 + storage profile offset within the port's storage profiles
112781 + window; Relevant only if the port was configured with VSP. */
112782 +#endif /* DPAA_VERSION >= 11 */
112783 +
112784 +} ioc_fm_pcd_cc_next_enqueue_params_t;
112785 +
112786 +/**************************************************************************//**
112787 + @Description A structure for defining KG params when KG is the next engine after a CC node
112788 + (Must match struct t_FmPcdCcNextKgParams defined in fm_pcd_ext.h)
112789 +*//***************************************************************************/
112790 +typedef struct ioc_fm_pcd_cc_next_kg_params_t {
112791 + bool override_fqid; /**< TRUE if CC override previously decided fqid and vspid,
112792 + Note - this parameters are irrelevant for earlier chips */
112793 + uint32_t new_fqid; /**< Valid if overrideFqid=TRUE, FQID for enqueuing the frame
112794 + (otherwise FQID is taken from KeyGen),
112795 + Note - this parameters are irrelevant for earlier chips */
112796 +#if DPAA_VERSION >= 11
112797 + uint8_t new_relative_storage_profile_id;
112798 + /**< Valid if override_fqid=TRUE, Indicates the relative virtual
112799 + storage profile offset within the port's storage profiles
112800 + window; Relevant only if the port was configured with VSP. */
112801 +#endif /* DPAA_VERSION >= 11 */
112802 + void *p_direct_scheme; /**< Direct scheme id to go to. */
112803 +} ioc_fm_pcd_cc_next_kg_params_t;
112804 +
112805 +/**************************************************************************//**
112806 + @Description Parameters for defining the next engine after a CC node.
112807 + (Must match struct t_FmPcdCcNextEngineParams defined in fm_pcd_ext.h)
112808 +*//***************************************************************************/
112809 +typedef struct ioc_fm_pcd_cc_next_engine_params_t {
112810 + ioc_fm_pcd_engine next_engine; /**< User has to initialize parameters
112811 + according to nextEngine definition */
112812 + union {
112813 + ioc_fm_pcd_cc_next_cc_params_t cc_params; /**< Parameters in case next engine is CC */
112814 + ioc_fm_pcd_cc_next_plcr_params_t plcr_params; /**< Parameters in case next engine is PLCR */
112815 + ioc_fm_pcd_cc_next_enqueue_params_t enqueue_params; /**< Parameters in case next engine is BMI */
112816 + ioc_fm_pcd_cc_next_kg_params_t kg_params; /**< Parameters in case next engine is KG */
112817 +#if DPAA_VERSION >= 11
112818 + ioc_fm_pcd_cc_next_fr_params_t fr_params; /**< Parameters in case next engine is FR */
112819 +#endif /* DPAA_VERSION >= 11 */
112820 + } params; /**< Union used for all the next-engine parameters options */
112821 + void *manip_id; /**< Handle to Manipulation object.
112822 + Relevant if next engine is of type result
112823 + (e_IOC_FM_PCD_PLCR, e_IOC_FM_PCD_KG, e_IOC_FM_PCD_DONE) */
112824 + bool statistics_en; /**< If TRUE, statistics counters are incremented
112825 + for each frame passing through this
112826 + Coarse Classification entry. */
112827 +} ioc_fm_pcd_cc_next_engine_params_t;
112828 +
112829 +/**************************************************************************//**
112830 + @Description Parameters for defining a single CC key
112831 +*//***************************************************************************/
112832 +typedef struct ioc_fm_pcd_cc_key_params_t {
112833 + uint8_t *p_key; /**< pointer to the key of the size defined in key_size */
112834 + uint8_t *p_mask; /**< pointer to the Mask per key of the size defined
112835 + in keySize. p_key and p_mask (if defined) has to be
112836 + of the same size defined in the key_size */
112837 + ioc_fm_pcd_cc_next_engine_params_t cc_next_engine_params;
112838 + /**< parameters for the next for the defined Key in p_key */
112839 +
112840 +} ioc_fm_pcd_cc_key_params_t;
112841 +
112842 +/**************************************************************************//**
112843 + @Description Parameters for defining CC keys parameters
112844 + The driver supports two methods for CC node allocation: dynamic and static.
112845 + Static mode was created in order to prevent runtime alloc/free
112846 + of FMan memory (MURAM), which may cause fragmentation; in this mode,
112847 + the driver automatically allocates the memory according to
112848 + 'max_num_of_keys' parameter. The driver calculates the maximal memory
112849 + size that may be used for this CC-Node taking into consideration
112850 + 'mask_support' and 'statistics_mode' parameters.
112851 + When 'action' = e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP in the extraction
112852 + parameters of this node, 'max_num_of_keys' must be equal to 'num_of_keys'.
112853 + In dynamic mode, 'max_num_of_keys' must be zero. At initialization,
112854 + all required structures are allocated according to 'num_of_keys'
112855 + parameter. During runtime modification, these structures are
112856 + re-allocated according to the updated number of keys.
112857 +
112858 + Please note that 'action' and 'ic_indx_mask' mentioned in the
112859 + specific parameter explanations are passed in the extraction
112860 + parameters of the node (fields of extractccparams.extractnonhdr).
112861 +*//***************************************************************************/
112862 +typedef struct ioc_keys_params_t {
112863 + uint16_t max_num_of_keys;/**< Maximum number of keys that will (ever) be used in this CC-Node;
112864 + A value of zero may be used for dynamic memory allocation. */
112865 + bool mask_support; /**< This parameter is relevant only if a node is initialized with
112866 + action = e_IOC_FM_PCD_ACTION_EXACT_MATCH and max_num_of_keys > 0;
112867 + Should be TRUE to reserve table memory for key masks, even if
112868 + initial keys do not contain masks, or if the node was initialized
112869 + as 'empty' (without keys); this will allow user to add keys with
112870 + masks at runtime. */
112871 + ioc_fm_pcd_cc_stats_mode statistics_mode;/**< Determines the supported statistics mode for all node's keys.
112872 + To enable statistics gathering, statistics should be enabled per
112873 + every key, using 'statistics_en' in next engine parameters structure
112874 + of that key;
112875 + If 'max_num_of_keys' is set, all required structures will be
112876 + preallocated for all keys. */
112877 +#if (DPAA_VERSION >= 11)
112878 + uint16_t frame_length_ranges[IOC_FM_PCD_CC_STATS_MAX_NUM_OF_FLR];
112879 + /**< Relevant only for 'RMON' statistics mode
112880 + (this feature is supported only on B4860 device);
112881 + Holds a list of programmable thresholds. For each received frame,
112882 + its length in bytes is examined against these range thresholds and
112883 + the appropriate counter is incremented by 1. For example, to belong
112884 + to range i, the following should hold:
112885 + range i-1 threshold < frame length <= range i threshold
112886 + Each range threshold must be larger then its preceding range
112887 + threshold. Last range threshold must be 0xFFFF. */
112888 +#endif /* (DPAA_VERSION >= 11) */
112889 + uint16_t num_of_keys; /**< Number of initial keys;
112890 + Note that in case of 'action' = e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP,
112891 + this field should be power-of-2 of the number of bits that are
112892 + set in 'ic_indx_mask'. */
112893 + uint8_t key_size; /**< Size of key - for extraction of type FULL_FIELD, 'key_size' has
112894 + to be the standard size of the selected key; For other extraction
112895 + types, 'key_size' has to be as size of extraction; When 'action' =
112896 + e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP, 'keySize' must be 2. */
112897 + ioc_fm_pcd_cc_key_params_t key_params[IOC_FM_PCD_MAX_NUM_OF_KEYS];
112898 + /**< An array with 'num_of_keys' entries, each entry specifies the
112899 + corresponding key parameters;
112900 + When 'action' = e_IOC_FM_PCD_ACTION_EXACT_MATCH, this value must not
112901 + exceed 255 (IOC_FM_PCD_MAX_NUM_OF_KEYS-1) as the last entry is saved
112902 + for the 'miss' entry. */
112903 + ioc_fm_pcd_cc_next_engine_params_t cc_next_engine_params_for_miss;
112904 + /**< Parameters for defining the next engine when a key is not matched;
112905 + Not relevant if action = e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP. */
112906 +} ioc_keys_params_t;
112907 +
112908 +/**************************************************************************//**
112909 + @Description Parameters for defining a CC node
112910 +*//***************************************************************************/
112911 +typedef struct ioc_fm_pcd_cc_node_params_t {
112912 + ioc_fm_pcd_extract_entry_t extract_cc_params; /**< Extraction parameters */
112913 + ioc_keys_params_t keys_params; /**< Keys definition matching the selected extraction */
112914 + void *id; /**< Output parameter; returns the CC node Id to be used */
112915 +} ioc_fm_pcd_cc_node_params_t;
112916 +
112917 +/**************************************************************************//**
112918 + @Description Parameters for defining a hash table
112919 + (Must match struct t_FmPcdHashTableParams defined in fm_pcd_ext.h)
112920 +*//***************************************************************************/
112921 +typedef struct ioc_fm_pcd_hash_table_params_t {
112922 + uint16_t max_num_of_keys; /**< Maximum Number Of Keys that will (ever) be used in this Hash-table */
112923 + ioc_fm_pcd_cc_stats_mode statistics_mode; /**< If not e_IOC_FM_PCD_CC_STATS_MODE_NONE, the required structures for the
112924 + requested statistics mode will be allocated according to max_num_of_keys. */
112925 + uint8_t kg_hash_shift; /**< KG-Hash-shift as it was configured in the KG-scheme
112926 + that leads to this hash-table. */
112927 + uint16_t hash_res_mask; /**< Mask that will be used on the hash-result;
112928 + The number-of-sets for this hash will be calculated
112929 + as (2^(number of bits set in 'hash_res_mask'));
112930 + The 4 lower bits must be cleared. */
112931 + uint8_t hash_shift; /**< Byte offset from the beginning of the KeyGen hash result to the
112932 + 2-bytes to be used as hash index. */
112933 + uint8_t match_key_size; /**< Size of the exact match keys held by the hash buckets */
112934 +
112935 + ioc_fm_pcd_cc_next_engine_params_t cc_next_engine_params_for_miss;
112936 + /**< Parameters for defining the next engine when a key is not matched */
112937 + void *id;
112938 +} ioc_fm_pcd_hash_table_params_t;
112939 +
112940 +/**************************************************************************//**
112941 + @Description A structure with the arguments for the FM_PCD_HashTableAddKey ioctl() call
112942 +*//***************************************************************************/
112943 +typedef struct ioc_fm_pcd_hash_table_add_key_params_t {
112944 + void *p_hash_tbl;
112945 + uint8_t key_size;
112946 + ioc_fm_pcd_cc_key_params_t key_params;
112947 +} ioc_fm_pcd_hash_table_add_key_params_t;
112948 +
112949 +/**************************************************************************//**
112950 + @Description Parameters for defining a CC tree group.
112951 +
112952 + This structure defines a CC group in terms of NetEnv units
112953 + and the action to be taken in each case. The unit_ids list must
112954 + be given in order from low to high indices.
112955 +
112956 + ioc_fm_pcd_cc_next_engine_params_t is a list of 2^num_of_distinction_units
112957 + structures where each defines the next action to be taken for
112958 + each units combination. for example:
112959 + num_of_distinction_units = 2
112960 + unit_ids = {1,3}
112961 + next_engine_per_entries_in_grp[0] = ioc_fm_pcd_cc_next_engine_params_t for the case that
112962 + unit 1 - not found; unit 3 - not found;
112963 + next_engine_per_entries_in_grp[1] = ioc_fm_pcd_cc_next_engine_params_t for the case that
112964 + unit 1 - not found; unit 3 - found;
112965 + next_engine_per_entries_in_grp[2] = ioc_fm_pcd_cc_next_engine_params_t for the case that
112966 + unit 1 - found; unit 3 - not found;
112967 + next_engine_per_entries_in_grp[3] = ioc_fm_pcd_cc_next_engine_params_t for the case that
112968 + unit 1 - found; unit 3 - found;
112969 +*//***************************************************************************/
112970 +typedef struct ioc_fm_pcd_cc_grp_params_t {
112971 + uint8_t num_of_distinction_units; /**< Up to 4 */
112972 + uint8_t unit_ids [IOC_FM_PCD_MAX_NUM_OF_CC_UNITS];
112973 + /**< Indexes of the units as defined in
112974 + FM_PCD_NetEnvCharacteristicsSet() */
112975 + ioc_fm_pcd_cc_next_engine_params_t next_engine_per_entries_in_grp[IOC_FM_PCD_MAX_NUM_OF_CC_ENTRIES_IN_GRP];
112976 + /**< Maximum entries per group is 16 */
112977 +} ioc_fm_pcd_cc_grp_params_t;
112978 +
112979 +/**************************************************************************//**
112980 + @Description Parameters for defining the CC tree groups
112981 + (Must match struct t_FmPcdCcTreeParams defined in fm_pcd_ext.h)
112982 +*//***************************************************************************/
112983 +typedef struct ioc_fm_pcd_cc_tree_params_t {
112984 + void *net_env_id; /**< Id of the Network Environment as returned
112985 + by FM_PCD_NetEnvCharacteristicsSet() */
112986 + uint8_t num_of_groups; /**< Number of CC groups within the CC tree */
112987 + ioc_fm_pcd_cc_grp_params_t fm_pcd_cc_group_params [IOC_FM_PCD_MAX_NUM_OF_CC_GROUPS];
112988 + /**< Parameters for each group. */
112989 + void *id; /**< Output parameter; Returns the tree Id to be used */
112990 +} ioc_fm_pcd_cc_tree_params_t;
112991 +
112992 +/**************************************************************************//**
112993 + @Description Parameters for defining policer byte rate
112994 +*//***************************************************************************/
112995 +typedef struct ioc_fm_pcd_plcr_byte_rate_mode_param_t {
112996 + ioc_fm_pcd_plcr_frame_length_select frame_length_selection; /**< Frame length selection */
112997 + ioc_fm_pcd_plcr_roll_back_frame_select roll_back_frame_selection; /**< relevant option only e_IOC_FM_PCD_PLCR_L2_FRM_LEN,
112998 + e_IOC_FM_PCD_PLCR_FULL_FRM_LEN */
112999 +} ioc_fm_pcd_plcr_byte_rate_mode_param_t;
113000 +
113001 +/**************************************************************************//**
113002 + @Description Parameters for defining the policer profile (based on
113003 + RFC-2698 or RFC-4115 attributes).
113004 +*//***************************************************************************/
113005 +typedef struct ioc_fm_pcd_plcr_non_passthrough_alg_param_t {
113006 + ioc_fm_pcd_plcr_rate_mode rate_mode; /**< Byte / Packet */
113007 + ioc_fm_pcd_plcr_byte_rate_mode_param_t byte_mode_param; /**< Valid for Byte NULL for Packet */
113008 + uint32_t committed_info_rate; /**< KBits/Sec or Packets/Sec */
113009 + uint32_t committed_burst_size; /**< KBits or Packets */
113010 + uint32_t peak_or_excess_info_rate; /**< KBits/Sec or Packets/Sec */
113011 + uint32_t peak_or_excess_burst_size; /**< KBits or Packets */
113012 +} ioc_fm_pcd_plcr_non_passthrough_alg_param_t;
113013 +
113014 +/**************************************************************************//**
113015 + @Description Parameters for defining the next engine after policer
113016 +*//***************************************************************************/
113017 +typedef union ioc_fm_pcd_plcr_next_engine_params_u {
113018 + ioc_fm_pcd_done_action action; /**< Action - when next engine is BMI (done) */
113019 + void *p_profile; /**< Policer profile handle - used when next engine
113020 + is PLCR, must be a SHARED profile */
113021 + void *p_direct_scheme; /**< Direct scheme select - when next engine is Keygen */
113022 +} ioc_fm_pcd_plcr_next_engine_params_u;
113023 +
113024 +typedef struct ioc_fm_pcd_port_params_t {
113025 + ioc_fm_port_type port_type; /**< Type of port for this profile */
113026 + uint8_t port_id; /**< FM-Port id of port for this profile */
113027 +} ioc_fm_pcd_port_params_t;
113028 +
113029 +/**************************************************************************//**
113030 + @Description Parameters for defining the policer profile entry
113031 + (Must match struct t_FmPcdPlcrProfileParams defined in fm_pcd_ext.h)
113032 +*//***************************************************************************/
113033 +typedef struct ioc_fm_pcd_plcr_profile_params_t {
113034 + bool modify; /**< TRUE to change an existing profile */
113035 + union {
113036 + struct {
113037 + ioc_fm_pcd_profile_type_selection profile_type; /**< Type of policer profile */
113038 + ioc_fm_pcd_port_params_t *p_fm_port; /**< Relevant for per-port profiles only */
113039 + uint16_t relative_profile_id; /**< Profile id - relative to shared group or to port */
113040 + } new_params; /**< Use it when modify = FALSE */
113041 + void *p_profile; /**< A handle to a profile - use it when modify=TRUE */
113042 + } profile_select;
113043 + ioc_fm_pcd_plcr_algorithm_selection alg_selection; /**< Profile Algorithm PASS_THROUGH, RFC_2698, RFC_4115 */
113044 + ioc_fm_pcd_plcr_color_mode color_mode; /**< COLOR_BLIND, COLOR_AWARE */
113045 +
113046 + union {
113047 + ioc_fm_pcd_plcr_color dflt_color; /**< For Color-Blind Pass-Through mode; the policer will re-color
113048 + any incoming packet with the default value. */
113049 + ioc_fm_pcd_plcr_color override; /**< For Color-Aware modes; the profile response to a
113050 + pre-color value of 2'b11. */
113051 + } color;
113052 +
113053 + ioc_fm_pcd_plcr_non_passthrough_alg_param_t non_passthrough_alg_param; /**< RFC2698 or RFC4115 parameters */
113054 +
113055 + ioc_fm_pcd_engine next_engine_on_green; /**< Next engine for green-colored frames */
113056 + ioc_fm_pcd_plcr_next_engine_params_u params_on_green; /**< Next engine parameters for green-colored frames */
113057 +
113058 + ioc_fm_pcd_engine next_engine_on_yellow; /**< Next engine for yellow-colored frames */
113059 + ioc_fm_pcd_plcr_next_engine_params_u params_on_yellow; /**< Next engine parameters for yellow-colored frames */
113060 +
113061 + ioc_fm_pcd_engine next_engine_on_red; /**< Next engine for red-colored frames */
113062 + ioc_fm_pcd_plcr_next_engine_params_u params_on_red; /**< Next engine parameters for red-colored frames */
113063 +
113064 + bool trap_profile_on_flow_A; /**< Obsolete - do not use */
113065 + bool trap_profile_on_flow_B; /**< Obsolete - do not use */
113066 + bool trap_profile_on_flow_C; /**< Obsolete - do not use */
113067 +
113068 + void *id; /**< output parameter; Returns the profile Id to be used */
113069 +} ioc_fm_pcd_plcr_profile_params_t;
113070 +
113071 +/**************************************************************************//**
113072 + @Description A structure for modifying CC tree next engine
113073 +*//***************************************************************************/
113074 +typedef struct ioc_fm_pcd_cc_tree_modify_next_engine_params_t {
113075 + void *id; /**< CC tree Id to be used */
113076 + uint8_t grp_indx; /**< A Group index in the tree */
113077 + uint8_t indx; /**< Entry index in the group defined by grp_index */
113078 + ioc_fm_pcd_cc_next_engine_params_t cc_next_engine_params;
113079 + /**< Parameters for the next for the defined Key in the p_Key */
113080 +} ioc_fm_pcd_cc_tree_modify_next_engine_params_t;
113081 +
113082 +/**************************************************************************//**
113083 + @Description A structure for modifying CC node next engine
113084 +*//***************************************************************************/
113085 +typedef struct ioc_fm_pcd_cc_node_modify_next_engine_params_t {
113086 + void *id; /**< CC node Id to be used */
113087 + uint16_t key_indx; /**< Key index for Next Engine Params modifications;
113088 + NOTE: This parameter is IGNORED for miss-key! */
113089 + uint8_t key_size; /**< Key size of added key */
113090 + ioc_fm_pcd_cc_next_engine_params_t cc_next_engine_params;
113091 + /**< parameters for the next for the defined Key in the p_Key */
113092 +} ioc_fm_pcd_cc_node_modify_next_engine_params_t;
113093 +
113094 +/**************************************************************************//**
113095 + @Description A structure for remove CC node key
113096 +*//***************************************************************************/
113097 +typedef struct ioc_fm_pcd_cc_node_remove_key_params_t {
113098 + void *id; /**< CC node Id to be used */
113099 + uint16_t key_indx; /**< Key index for Next Engine Params modifications;
113100 + NOTE: This parameter is IGNORED for miss-key! */
113101 +} ioc_fm_pcd_cc_node_remove_key_params_t;
113102 +
113103 +/**************************************************************************//**
113104 + @Description A structure for modifying CC node key and next engine
113105 +*//***************************************************************************/
113106 +typedef struct ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t {
113107 + void *id; /**< CC node Id to be used */
113108 + uint16_t key_indx; /**< Key index for Next Engine Params modifications;
113109 + NOTE: This parameter is IGNORED for miss-key! */
113110 + uint8_t key_size; /**< Key size of added key */
113111 + ioc_fm_pcd_cc_key_params_t key_params; /**< it's array with numOfKeys entries each entry in
113112 + the array of the type ioc_fm_pcd_cc_key_params_t */
113113 +} ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t;
113114 +
113115 +/**************************************************************************//**
113116 + @Description A structure for modifying CC node key
113117 +*//***************************************************************************/
113118 +typedef struct ioc_fm_pcd_cc_node_modify_key_params_t {
113119 + void *id; /**< CC node Id to be used */
113120 + uint16_t key_indx; /**< Key index for Next Engine Params modifications;
113121 + NOTE: This parameter is IGNORED for miss-key! */
113122 + uint8_t key_size; /**< Key size of added key */
113123 + uint8_t *p_key; /**< Pointer to the key of the size defined in key_size */
113124 + uint8_t *p_mask; /**< Pointer to the Mask per key of the size defined
113125 + in keySize. p_Key and p_Mask (if defined) have to be
113126 + of the same size as defined in the key_size */
113127 +} ioc_fm_pcd_cc_node_modify_key_params_t;
113128 +
113129 +/**************************************************************************//**
113130 + @Description A structure with the arguments for the FM_PCD_HashTableRemoveKey ioctl() call
113131 +*//***************************************************************************/
113132 +typedef struct ioc_fm_pcd_hash_table_remove_key_params_t {
113133 + void *p_hash_tbl; /**< The id of the hash table */
113134 + uint8_t key_size; /**< The size of the key to remove */
113135 + uint8_t *p_key; /**< Pointer to the key to remove */
113136 +} ioc_fm_pcd_hash_table_remove_key_params_t;
113137 +
113138 +/**************************************************************************//**
113139 + @Description Parameters for selecting a location for requested manipulation
113140 +*//***************************************************************************/
113141 +typedef struct ioc_fm_manip_hdr_info_t {
113142 + ioc_net_header_type hdr; /**< Header selection */
113143 + ioc_fm_pcd_hdr_index hdr_index; /**< Relevant only for MPLS, VLAN and tunneled IP. Otherwise should be cleared. */
113144 + bool by_field; /**< TRUE if the location of manipulation is according to some field in the specific header*/
113145 + ioc_fm_pcd_fields_u full_field; /**< Relevant only when by_field = TRUE: Extract field */
113146 +} ioc_fm_manip_hdr_info_t;
113147 +
113148 +/**************************************************************************//**
113149 + @Description Parameters for defining header removal by header type
113150 +*//***************************************************************************/
113151 +typedef struct ioc_fm_pcd_manip_hdr_rmv_by_hdr_params_t {
113152 + ioc_fm_pcd_manip_hdr_rmv_by_hdr_type type; /**< Selection of header removal location */
113153 + union {
113154 +#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
113155 + struct {
113156 + bool include;/**< If FALSE, remove until the specified header (not including the header);
113157 + If TRUE, remove also the specified header. */
113158 + ioc_fm_manip_hdr_info_t hdr_info;
113159 + } from_start_by_hdr; /**< Relevant when type = e_IOC_FM_PCD_MANIP_RMV_BY_HDR_FROM_START */
113160 +#endif /* FM_CAPWAP_SUPPORT */
113161 +#if (DPAA_VERSION >= 11)
113162 + ioc_fm_manip_hdr_info_t hdr_info; /**< Relevant when type = e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START */
113163 +#endif /* (DPAA_VERSION >= 11) */
113164 + ioc_fm_pcd_manip_hdr_rmv_specific_l2 specific_l2;/**< Relevant when type = e_IOC_FM_PCD_MANIP_BY_HDR_SPECIFIC_L2;
113165 + Defines which L2 headers to remove. */
113166 + } u;
113167 +} ioc_fm_pcd_manip_hdr_rmv_by_hdr_params_t;
113168 +
113169 +/**************************************************************************//**
113170 + @Description Parameters for configuring IP fragmentation manipulation
113171 +*//***************************************************************************/
113172 +typedef struct ioc_fm_pcd_manip_frag_ip_params_t {
113173 + uint16_t size_for_fragmentation; /**< If length of the frame is greater than this value,
113174 + IP fragmentation will be executed.*/
113175 +#if DPAA_VERSION == 10
113176 + uint8_t scratch_bpid; /**< Absolute buffer pool id according to BM configuration.*/
113177 +#endif /* DPAA_VERSION == 10 */
113178 + bool sg_bpid_en; /**< Enable a dedicated buffer pool id for the Scatter/Gather buffer allocation;
113179 + If disabled, the Scatter/Gather buffer will be allocated from the same pool as the
113180 + received frame's buffer. */
113181 + uint8_t sg_bpid; /**< Scatter/Gather buffer pool id;
113182 + This parameter is relevant when 'sg_bpid_en=TRUE';
113183 + Same LIODN number is used for these buffers as for the received frames buffers, so buffers
113184 + of this pool need to be allocated in the same memory area as the received buffers.
113185 + If the received buffers arrive from different sources, the Scatter/Gather BP id should be
113186 + mutual to all these sources. */
113187 + ioc_fm_pcd_manip_dont_frag_action dont_frag_action; /**< Dont Fragment Action - If an IP packet is larger
113188 + than MTU and its DF bit is set, then this field will
113189 + determine the action to be taken.*/
113190 +} ioc_fm_pcd_manip_frag_ip_params_t;
113191 +
113192 +/**************************************************************************//**
113193 + @Description Parameters for configuring IP reassembly manipulation.
113194 +
113195 + This is a common structure for both IPv4 and IPv6 reassembly
113196 + manipulation. For reassembly of both IPv4 and IPv6, make sure to
113197 + set the 'hdr' field in ioc_fm_pcd_manip_reassem_params_t to IOC_HEADER_TYPE_IPv6.
113198 +*//***************************************************************************/
113199 +typedef struct ioc_fm_pcd_manip_reassem_ip_params_t {
113200 + uint8_t relative_scheme_id[2]; /**< Partition relative scheme id:
113201 + relativeSchemeId[0] - Relative scheme ID for IPV4 Reassembly manipulation;
113202 + relativeSchemeId[1] - Relative scheme ID for IPV6 Reassembly manipulation;
113203 + NOTE: The following comment is relevant only for FMAN v2 devices:
113204 + Relative scheme ID for IPv4/IPv6 Reassembly manipulation must be smaller than
113205 + the user schemes id to ensure that the reassembly's schemes will be first match.
113206 + The remaining schemes, if defined, should have higher relative scheme ID. */
113207 +#if DPAA_VERSION >= 11
113208 + uint32_t non_consistent_sp_fqid; /**< In case that other fragments of the frame corresponds to different storage
113209 + profile than the opening fragment (Non-Consistent-SP state)
113210 + then one of two possible scenarios occurs:
113211 + if 'nonConsistentSpFqid != 0', the reassembled frame will be enqueued to
113212 + this fqid, otherwise a 'Non Consistent SP' bit will be set in the FD[status].*/
113213 +#else
113214 + uint8_t sg_bpid; /**< Buffer pool id for the S/G frame created by the reassembly process */
113215 +#endif /* DPAA_VERSION >= 11 */
113216 + uint8_t data_mem_id; /**< Memory partition ID for the IPR's external tables structure */
113217 + uint16_t data_liodn_offset; /**< LIODN offset for access the IPR's external tables structure. */
113218 + uint16_t min_frag_size[2]; /**< Minimum fragment size:
113219 + minFragSize[0] - for ipv4, minFragSize[1] - for ipv6 */
113220 + ioc_fm_pcd_manip_reassem_ways_number num_of_frames_per_hash_entry[2];
113221 + /**< Number of frames per hash entry needed for reassembly process:
113222 + numOfFramesPerHashEntry[0] - for ipv4 (max value is e_IOC_FM_PCD_MANIP_EIGHT_WAYS_HASH);
113223 + numOfFramesPerHashEntry[1] - for ipv6 (max value is e_IOC_FM_PCD_MANIP_SIX_WAYS_HASH). */
113224 + uint16_t max_num_frames_in_process;/**< Number of frames which can be processed by Reassembly in the same time;
113225 + Must be power of 2;
113226 + In the case numOfFramesPerHashEntry == e_IOC_FM_PCD_MANIP_FOUR_WAYS_HASH,
113227 + maxNumFramesInProcess has to be in the range of 4 - 512;
113228 + In the case numOfFramesPerHashEntry == e_IOC_FM_PCD_MANIP_EIGHT_WAYS_HASH,
113229 + maxNumFramesInProcess has to be in the range of 8 - 2048. */
113230 + ioc_fm_pcd_manip_reassem_time_out_mode time_out_mode; /**< Expiration delay initialized by Reassembly process */
113231 + uint32_t fqid_for_time_out_frames;/**< FQID in which time out frames will enqueue during Time Out Process */
113232 + uint32_t timeout_threshold_for_reassm_process;
113233 + /**< Represents the time interval in microseconds which defines
113234 + if opened frame (at least one fragment was processed but not all the fragments)is found as too old*/
113235 +} ioc_fm_pcd_manip_reassem_ip_params_t;
113236 +
113237 +/**************************************************************************//**
113238 + @Description Parameters for defining IPSEC manipulation
113239 +*//***************************************************************************/
113240 +typedef struct ioc_fm_pcd_manip_special_offload_ipsec_params_t {
113241 + bool decryption; /**< TRUE if being used in decryption direction;
113242 + FALSE if being used in encryption direction. */
113243 + bool ecn_copy; /**< TRUE to copy the ECN bits from inner/outer to outer/inner
113244 + (direction depends on the 'decryption' field). */
113245 + bool dscp_copy; /**< TRUE to copy the DSCP bits from inner/outer to outer/inner
113246 + (direction depends on the 'decryption' field). */
113247 + bool variable_ip_hdr_len; /**< TRUE for supporting variable IP header length in decryption. */
113248 + bool variable_ip_version; /**< TRUE for supporting both IP version on the same SA in encryption */
113249 + uint8_t outer_ip_hdr_len; /**< If 'variable_ip_version == TRUE' than this field must be set to non-zero value;
113250 + It is specifies the length of the outer IP header that was configured in the
113251 + corresponding SA. */
113252 + uint16_t arw_size; /**< if <> '0' then will perform ARW check for this SA;
113253 + The value must be a multiplication of 16 */
113254 + void *arw_addr; /**< if arwSize <> '0' then this field must be set to non-zero value;
113255 + MUST be allocated from FMAN's MURAM that the post-sec op-port belong
113256 + Must be 4B aligned. Required MURAM size is '(NEXT_POWER_OF_2(arwSize+32))/8+4' Bytes */
113257 +} ioc_fm_pcd_manip_special_offload_ipsec_params_t;
113258 +
113259 +#if (DPAA_VERSION >= 11)
113260 +/**************************************************************************//**
113261 + @Description Parameters for configuring CAPWAP fragmentation manipulation
113262 +
113263 + Restrictions:
113264 + - Maximum number of fragments per frame is 16.
113265 + - Transmit confirmation is not supported.
113266 + - Fragmentation nodes must be set as the last PCD action (i.e. the
113267 + corresponding CC node key must have next engine set to e_FM_PCD_DONE).
113268 + - Only BMan buffers shall be used for frames to be fragmented.
113269 + - NOTE: The following comment is relevant only for FMAN v3 devices: IPF
113270 + does not support VSP. Therefore, on the same port where we have IPF we
113271 + cannot support VSP.
113272 +*//***************************************************************************/
113273 +typedef struct ioc_fm_pcd_manip_frag_capwap_params_t {
113274 + uint16_t size_for_fragmentation; /**< If length of the frame is greater than this value,
113275 + CAPWAP fragmentation will be executed.*/
113276 + bool sg_bpid_en; /**< Enable a dedicated buffer pool id for the Scatter/Gather buffer allocation;
113277 + If disabled, the Scatter/Gather buffer will be allocated from the same pool as the
113278 + received frame's buffer. */
113279 + uint8_t sg_bpid; /**< Scatter/Gather buffer pool id;
113280 + This parameters is relevant when 'sgBpidEn=TRUE';
113281 + Same LIODN number is used for these buffers as for the received frames buffers, so buffers
113282 + of this pool need to be allocated in the same memory area as the received buffers.
113283 + If the received buffers arrive from different sources, the Scatter/Gather BP id should be
113284 + mutual to all these sources. */
113285 + bool compress_mode_en; /**< CAPWAP Header Options Compress Enable mode;
113286 + When this mode is enabled then only the first fragment include the CAPWAP header options
113287 + field (if user provides it in the input frame) and all other fragments exclude the CAPWAP
113288 + options field (CAPWAP header is updated accordingly).*/
113289 +} ioc_fm_pcd_manip_frag_capwap_params_t;
113290 +
113291 +/**************************************************************************//**
113292 + @Description Parameters for configuring CAPWAP reassembly manipulation.
113293 +
113294 + Restrictions:
113295 + - Application must define one scheme to catch the reassembled frames.
113296 + - Maximum number of fragments per frame is 16.
113297 +
113298 +*//***************************************************************************/
113299 +typedef struct ioc_fm_pcd_manip_reassem_capwap_params_t {
113300 + uint8_t relative_scheme_id; /**< Partition relative scheme id;
113301 + NOTE: this id must be smaller than the user schemes id to ensure that the reassembly scheme will be first match;
113302 + Rest schemes, if defined, should have higher relative scheme ID. */
113303 + uint8_t data_mem_id; /**< Memory partition ID for the IPR's external tables structure */
113304 + uint16_t data_liodn_offset; /**< LIODN offset for access the IPR's external tables structure. */
113305 + uint16_t max_reassembled_frame_length;/**< The maximum CAPWAP reassembled frame length in bytes;
113306 + If maxReassembledFrameLength == 0, any successful reassembled frame length is
113307 + considered as a valid length;
113308 + if maxReassembledFrameLength > 0, a successful reassembled frame which its length
113309 + exceeds this value is considered as an error frame (FD status[CRE] bit is set). */
113310 + ioc_fm_pcd_manip_reassem_ways_number num_of_frames_per_hash_entry;
113311 + /**< Number of frames per hash entry needed for reassembly process */
113312 + uint16_t max_num_frames_in_process; /**< Number of frames which can be processed by reassembly in the same time;
113313 + Must be power of 2;
113314 + In the case numOfFramesPerHashEntry == e_FM_PCD_MANIP_FOUR_WAYS_HASH,
113315 + maxNumFramesInProcess has to be in the range of 4 - 512;
113316 + In the case numOfFramesPerHashEntry == e_FM_PCD_MANIP_EIGHT_WAYS_HASH,
113317 + maxNumFramesInProcess has to be in the range of 8 - 2048. */
113318 + ioc_fm_pcd_manip_reassem_time_out_mode time_out_mode; /**< Expiration delay initialized by Reassembly process */
113319 + uint32_t fqid_for_time_out_frames; /**< FQID in which time out frames will enqueue during Time Out Process;
113320 + Recommended value for this field is 0; in this way timed-out frames will be discarded */
113321 + uint32_t timeout_threshold_for_reassm_process;
113322 + /**< Represents the time interval in microseconds which defines
113323 + if opened frame (at least one fragment was processed but not all the fragments)is found as too old*/
113324 +} ioc_fm_pcd_manip_reassem_capwap_params_t;
113325 +
113326 +/**************************************************************************//**
113327 + @Description structure for defining CAPWAP manipulation
113328 +*//***************************************************************************/
113329 +typedef struct ioc_fm_pcd_manip_special_offload_capwap_params_t {
113330 + bool dtls; /**< TRUE if continue to SEC DTLS encryption */
113331 + ioc_fm_pcd_manip_hdr_qos_src qos_src; /**< TODO */
113332 +} ioc_fm_pcd_manip_special_offload_capwap_params_t;
113333 +
113334 +#endif /* (DPAA_VERSION >= 11) */
113335 +
113336 +/**************************************************************************//**
113337 + @Description Parameters for defining special offload manipulation
113338 +*//***************************************************************************/
113339 +typedef struct ioc_fm_pcd_manip_special_offload_params_t {
113340 + ioc_fm_pcd_manip_special_offload_type type; /**< Type of special offload manipulation */
113341 + union
113342 + {
113343 + ioc_fm_pcd_manip_special_offload_ipsec_params_t ipsec; /**< Parameters for IPSec; Relevant when
113344 + type = e_IOC_FM_PCD_MANIP_SPECIAL_OFFLOAD_IPSEC */
113345 +
113346 +#if (DPAA_VERSION >= 11)
113347 + ioc_fm_pcd_manip_special_offload_capwap_params_t capwap; /**< Parameters for CAPWAP; Relevant when
113348 + type = e_FM_PCD_MANIP_SPECIAL_OFFLOAD_CAPWAP */
113349 +#endif /* (DPAA_VERSION >= 11) */
113350 + } u;
113351 +} ioc_fm_pcd_manip_special_offload_params_t;
113352 +
113353 +/**************************************************************************//**
113354 + @Description Parameters for defining generic removal manipulation
113355 +*//***************************************************************************/
113356 +typedef struct ioc_fm_pcd_manip_hdr_rmv_generic_params_t {
113357 + uint8_t offset; /**< Offset from beginning of header to the start
113358 + location of the removal */
113359 + uint8_t size; /**< Size of removed section */
113360 +} ioc_fm_pcd_manip_hdr_rmv_generic_params_t;
113361 +
113362 +/**************************************************************************//**
113363 + @Description Parameters for defining insertion manipulation
113364 +*//***************************************************************************/
113365 +typedef struct ioc_fm_pcd_manip_hdr_insrt_t {
113366 + uint8_t size; /**< size of inserted section */
113367 + uint8_t *p_data; /**< data to be inserted */
113368 +} ioc_fm_pcd_manip_hdr_insrt_t;
113369 +
113370 +/**************************************************************************//**
113371 + @Description Parameters for defining generic insertion manipulation
113372 +*//***************************************************************************/
113373 +typedef struct ioc_fm_pcd_manip_hdr_insrt_generic_params_t {
113374 + uint8_t offset; /**< Offset from beginning of header to the start
113375 + location of the insertion */
113376 + uint8_t size; /**< Size of inserted section */
113377 + bool replace; /**< TRUE to override (replace) existing data at
113378 + 'offset', FALSE to insert */
113379 + uint8_t *p_data; /**< Pointer to data to be inserted */
113380 +} ioc_fm_pcd_manip_hdr_insrt_generic_params_t;
113381 +
113382 +/**************************************************************************//**
113383 + @Description Parameters for defining header manipulation VLAN DSCP To Vpri translation
113384 +*//***************************************************************************/
113385 +typedef struct ioc_fm_pcd_manip_hdr_field_update_vlan_dscp_to_vpri_t {
113386 + uint8_t dscp_to_vpri_table[IOC_FM_PCD_MANIP_DSCP_TO_VLAN_TRANS];
113387 + /**< A table of VPri values for each DSCP value;
113388 + The index is the D_SCP value (0-0x3F) and the
113389 + value is the corresponding VPRI (0-15). */
113390 + uint8_t vpri_def_val; /**< 0-7, Relevant only if if update_type =
113391 + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN,
113392 + this field is the Q Tag default value if the
113393 + IP header is not found. */
113394 +} ioc_fm_pcd_manip_hdr_field_update_vlan_dscp_to_vpri_t;
113395 +
113396 +/**************************************************************************//**
113397 + @Description Parameters for defining header manipulation VLAN fields updates
113398 +*//***************************************************************************/
113399 +typedef struct ioc_fm_pcd_manip_hdr_field_update_vlan_t {
113400 + ioc_fm_pcd_manip_hdr_field_update_vlan update_type; /**< Selects VLAN update type */
113401 + union {
113402 + uint8_t vpri; /**< 0-7, Relevant only if If update_type =
113403 + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN_PRI, this
113404 + is the new VLAN pri. */
113405 + ioc_fm_pcd_manip_hdr_field_update_vlan_dscp_to_vpri_t dscp_to_vpri;
113406 + /**< Parameters structure, Relevant only if update_type =
113407 + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN. */
113408 + } u;
113409 +} ioc_fm_pcd_manip_hdr_field_update_vlan_t;
113410 +
113411 +/**************************************************************************//**
113412 + @Description Parameters for defining header manipulation IPV4 fields updates
113413 +*//***************************************************************************/
113414 +typedef struct ioc_fm_pcd_manip_hdr_field_update_ipv4_t {
113415 + ioc_ipv4_hdr_manip_update_flags_t valid_updates; /**< ORed flag, selecting the required updates */
113416 + uint8_t tos; /**< 8 bit New TOS; Relevant if valid_updates contains
113417 + IOC_HDR_MANIP_IPV4_TOS */
113418 + uint16_t id; /**< 16 bit New IP ID; Relevant only if valid_updates
113419 + contains IOC_HDR_MANIP_IPV4_ID */
113420 + uint32_t src; /**< 32 bit New IP SRC; Relevant only if valid_updates
113421 + contains IOC_HDR_MANIP_IPV4_SRC */
113422 + uint32_t dst; /**< 32 bit New IP DST; Relevant only if valid_updates
113423 + contains IOC_HDR_MANIP_IPV4_DST */
113424 +} ioc_fm_pcd_manip_hdr_field_update_ipv4_t;
113425 +
113426 +/**************************************************************************//**
113427 + @Description Parameters for defining header manipulation IPV6 fields updates
113428 +*//***************************************************************************/
113429 +typedef struct ioc_fm_pcd_manip_hdr_field_update_ipv6_t {
113430 + ioc_ipv6_hdr_manip_update_flags_t valid_updates; /**< ORed flag, selecting the required updates */
113431 + uint8_t traffic_class; /**< 8 bit New Traffic Class; Relevant if valid_updates contains
113432 + IOC_HDR_MANIP_IPV6_TC */
113433 + uint8_t src[IOC_NET_HEADER_FIELD_IPv6_ADDR_SIZE];
113434 + /**< 16 byte new IP SRC; Relevant only if valid_updates
113435 + contains IOC_HDR_MANIP_IPV6_SRC */
113436 + uint8_t dst[IOC_NET_HEADER_FIELD_IPv6_ADDR_SIZE];
113437 + /**< 16 byte new IP DST; Relevant only if valid_updates
113438 + contains IOC_HDR_MANIP_IPV6_DST */
113439 +} ioc_fm_pcd_manip_hdr_field_update_ipv6_t;
113440 +
113441 +/**************************************************************************//**
113442 + @Description Parameters for defining header manipulation TCP/UDP fields updates
113443 +*//***************************************************************************/
113444 +typedef struct ioc_fm_pcd_manip_hdr_field_update_tcp_udp_t {
113445 + ioc_tcp_udp_hdr_manip_update_flags_t valid_updates; /**< ORed flag, selecting the required updates */
113446 + uint16_t src; /**< 16 bit New TCP/UDP SRC; Relevant only if valid_updates
113447 + contains IOC_HDR_MANIP_TCP_UDP_SRC */
113448 + uint16_t dst; /**< 16 bit New TCP/UDP DST; Relevant only if valid_updates
113449 + contains IOC_HDR_MANIP_TCP_UDP_DST */
113450 +} ioc_fm_pcd_manip_hdr_field_update_tcp_udp_t;
113451 +
113452 +/**************************************************************************//**
113453 + @Description Parameters for defining header manipulation fields updates
113454 +*//***************************************************************************/
113455 +typedef struct ioc_fm_pcd_manip_hdr_field_update_params_t {
113456 + ioc_fm_pcd_manip_hdr_field_update_type type; /**< Type of header field update manipulation */
113457 + union {
113458 + ioc_fm_pcd_manip_hdr_field_update_vlan_t vlan; /**< Parameters for VLAN update. Relevant when
113459 + type = e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN */
113460 + ioc_fm_pcd_manip_hdr_field_update_ipv4_t ipv4; /**< Parameters for IPv4 update. Relevant when
113461 + type = e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV4 */
113462 + ioc_fm_pcd_manip_hdr_field_update_ipv6_t ipv6; /**< Parameters for IPv6 update. Relevant when
113463 + type = e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV6 */
113464 + ioc_fm_pcd_manip_hdr_field_update_tcp_udp_t tcp_udp;/**< Parameters for TCP/UDP update. Relevant when
113465 + type = e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_TCP_UDP */
113466 + } u;
113467 +} ioc_fm_pcd_manip_hdr_field_update_params_t;
113468 +
113469 +/**************************************************************************//**
113470 + @Description Parameters for defining custom header manipulation for IP replacement
113471 +*//***************************************************************************/
113472 +typedef struct ioc_fm_pcd_manip_hdr_custom_ip_hdr_replace_t {
113473 + ioc_fm_pcd_manip_hdr_custom_ip_replace replace_type; /**< Selects replace update type */
113474 + bool dec_ttl_hl; /**< Decrement TTL (IPV4) or Hop limit (IPV6) by 1 */
113475 + bool update_ipv4_id; /**< Relevant when replace_type =
113476 + e_IOC_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4 */
113477 + uint16_t id; /**< 16 bit New IP ID; Relevant only if
113478 + update_ipv4_id = TRUE */
113479 + uint8_t hdr_size; /**< The size of the new IP header */
113480 + uint8_t hdr[IOC_FM_PCD_MANIP_MAX_HDR_SIZE];
113481 + /**< The new IP header */
113482 +} ioc_fm_pcd_manip_hdr_custom_ip_hdr_replace_t;
113483 +
113484 +/**************************************************************************//**
113485 + @Description Parameters for defining custom header manipulation
113486 +*//***************************************************************************/
113487 +typedef struct ioc_fm_pcd_manip_hdr_custom_params_t {
113488 + ioc_fm_pcd_manip_hdr_custom_type type; /**< Type of header field update manipulation */
113489 + union {
113490 + ioc_fm_pcd_manip_hdr_custom_ip_hdr_replace_t ip_hdr_replace;
113491 + /**< Parameters IP header replacement */
113492 + } u;
113493 +} ioc_fm_pcd_manip_hdr_custom_params_t;
113494 +
113495 +/**************************************************************************//**
113496 + @Description Parameters for defining specific L2 insertion manipulation
113497 +*//***************************************************************************/
113498 +typedef struct ioc_fm_pcd_manip_hdr_insrt_specific_l2_params_t {
113499 + ioc_fm_pcd_manip_hdr_insrt_specific_l2 specific_l2; /**< Selects which L2 headers to insert */
113500 + bool update; /**< TRUE to update MPLS header */
113501 + uint8_t size; /**< size of inserted section */
113502 + uint8_t *p_data; /**< data to be inserted */
113503 +} ioc_fm_pcd_manip_hdr_insrt_specific_l2_params_t;
113504 +
113505 +#if (DPAA_VERSION >= 11)
113506 +/**************************************************************************//**
113507 + @Description Parameters for defining IP insertion manipulation
113508 +*//***************************************************************************/
113509 +typedef struct ioc_fm_pcd_manip_hdr_insrt_ip_params_t {
113510 + bool calc_l4_checksum; /**< Calculate L4 checksum. */
113511 + ioc_fm_pcd_manip_hdr_qos_mapping_mode mapping_mode; /**< TODO */
113512 + uint8_t last_pid_offset; /**< the offset of the last Protocol within
113513 + the inserted header */
113514 + uint16_t id; /**< 16 bit New IP ID */
113515 + bool dont_frag_overwrite;
113516 + /**< IPv4 only. DF is overwritten with the hash-result next-to-last byte.
113517 + * This byte is configured to be overwritten when RPD is set. */
113518 + uint8_t last_dst_offset;
113519 + /**< IPv6 only. if routing extension exist, user should set the offset of the destination address
113520 + * in order to calculate UDP checksum pseudo header;
113521 + * Otherwise set it to '0'. */
113522 + ioc_fm_pcd_manip_hdr_insrt_t insrt; /**< size and data to be inserted. */
113523 +} ioc_fm_pcd_manip_hdr_insrt_ip_params_t;
113524 +#endif /* (DPAA_VERSION >= 11) */
113525 +
113526 +/**************************************************************************//**
113527 + @Description Parameters for defining header insertion manipulation by header type
113528 +*//***************************************************************************/
113529 +typedef struct ioc_fm_pcd_manip_hdr_insrt_by_hdr_params_t {
113530 + ioc_fm_pcd_manip_hdr_insrt_by_hdr_type type; /**< Selects manipulation type */
113531 + union {
113532 + ioc_fm_pcd_manip_hdr_insrt_specific_l2_params_t specific_l2_params;
113533 + /**< Used when type = e_IOC_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2:
113534 + Selects which L2 headers to remove */
113535 +#if (DPAA_VERSION >= 11)
113536 + ioc_fm_pcd_manip_hdr_insrt_ip_params_t ip_params; /**< Used when type = e_FM_PCD_MANIP_INSRT_BY_HDR_IP */
113537 + ioc_fm_pcd_manip_hdr_insrt_t insrt; /**< Used when type is one of e_FM_PCD_MANIP_INSRT_BY_HDR_UDP,
113538 + e_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE, or
113539 + e_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP */
113540 +#endif /* (DPAA_VERSION >= 11) */
113541 + } u;
113542 +} ioc_fm_pcd_manip_hdr_insrt_by_hdr_params_t;
113543 +
113544 +/**************************************************************************//**
113545 + @Description Parameters for defining header insertion manipulation
113546 +*//***************************************************************************/
113547 +typedef struct ioc_fm_pcd_manip_hdr_insrt_params_t {
113548 + ioc_fm_pcd_manip_hdr_insrt_type type; /**< Type of insertion manipulation */
113549 + union {
113550 + ioc_fm_pcd_manip_hdr_insrt_by_hdr_params_t by_hdr; /**< Parameters for defining header insertion manipulation by header type,
113551 + relevant if 'type' = e_IOC_FM_PCD_MANIP_INSRT_BY_HDR */
113552 + ioc_fm_pcd_manip_hdr_insrt_generic_params_t generic;/**< Parameters for defining generic header insertion manipulation,
113553 + relevant if type = e_IOC_FM_PCD_MANIP_INSRT_GENERIC */
113554 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
113555 + ioc_fm_pcd_manip_hdr_insrt_by_template_params_t by_template;
113556 + /**< Parameters for defining header insertion manipulation by template,
113557 + relevant if 'type' = e_IOC_FM_PCD_MANIP_INSRT_BY_TEMPLATE */
113558 +#endif /* FM_CAPWAP_SUPPORT */
113559 + } u;
113560 +} ioc_fm_pcd_manip_hdr_insrt_params_t;
113561 +
113562 +/**************************************************************************//**
113563 + @Description Parameters for defining header removal manipulation
113564 +*//***************************************************************************/
113565 +typedef struct ioc_fm_pcd_manip_hdr_rmv_params_t {
113566 + ioc_fm_pcd_manip_hdr_rmv_type type; /**< Type of header removal manipulation */
113567 + union {
113568 + ioc_fm_pcd_manip_hdr_rmv_by_hdr_params_t by_hdr; /**< Parameters for defining header removal manipulation by header type,
113569 + relevant if type = e_IOC_FM_PCD_MANIP_RMV_BY_HDR */
113570 + ioc_fm_pcd_manip_hdr_rmv_generic_params_t generic; /**< Parameters for defining generic header removal manipulation,
113571 + relevant if type = e_IOC_FM_PCD_MANIP_RMV_GENERIC */
113572 + } u;
113573 +} ioc_fm_pcd_manip_hdr_rmv_params_t;
113574 +
113575 +/**************************************************************************//**
113576 + @Description Parameters for defining header manipulation node
113577 +*//***************************************************************************/
113578 +typedef struct ioc_fm_pcd_manip_hdr_params_t {
113579 + bool rmv; /**< TRUE, to define removal manipulation */
113580 + ioc_fm_pcd_manip_hdr_rmv_params_t rmv_params; /**< Parameters for removal manipulation, relevant if 'rmv' = TRUE */
113581 +
113582 + bool insrt; /**< TRUE, to define insertion manipulation */
113583 + ioc_fm_pcd_manip_hdr_insrt_params_t insrt_params; /**< Parameters for insertion manipulation, relevant if 'insrt' = TRUE */
113584 +
113585 + bool field_update; /**< TRUE, to define field update manipulation */
113586 + ioc_fm_pcd_manip_hdr_field_update_params_t field_update_params; /**< Parameters for field update manipulation, relevant if 'fieldUpdate' = TRUE */
113587 +
113588 + bool custom; /**< TRUE, to define custom manipulation */
113589 + ioc_fm_pcd_manip_hdr_custom_params_t custom_params; /**< Parameters for custom manipulation, relevant if 'custom' = TRUE */
113590 +
113591 + bool dont_parse_after_manip;/**< FALSE to activate the parser a second time after
113592 + completing the manipulation on the frame */
113593 +} ioc_fm_pcd_manip_hdr_params_t;
113594 +
113595 +
113596 +/**************************************************************************//**
113597 + @Description structure for defining fragmentation manipulation
113598 +*//***************************************************************************/
113599 +typedef struct ioc_fm_pcd_manip_frag_params_t {
113600 + ioc_net_header_type hdr; /**< Header selection */
113601 + union {
113602 +#if (DPAA_VERSION >= 11)
113603 + ioc_fm_pcd_manip_frag_capwap_params_t capwap_frag; /**< Parameters for defining CAPWAP fragmentation,
113604 + relevant if 'hdr' = HEADER_TYPE_CAPWAP */
113605 +#endif /* (DPAA_VERSION >= 11) */
113606 + ioc_fm_pcd_manip_frag_ip_params_t ip_frag; /**< Parameters for defining IP fragmentation,
113607 + relevant if 'hdr' = HEADER_TYPE_Ipv4 or HEADER_TYPE_Ipv6 */
113608 + } u;
113609 +} ioc_fm_pcd_manip_frag_params_t;
113610 +
113611 +/**************************************************************************//**
113612 + @Description structure for defining reassemble manipulation
113613 +*//***************************************************************************/
113614 +typedef struct ioc_fm_pcd_manip_reassem_params_t {
113615 + ioc_net_header_type hdr; /**< Header selection */
113616 + union {
113617 +#if (DPAA_VERSION >= 11)
113618 + ioc_fm_pcd_manip_reassem_capwap_params_t capwap_reassem; /**< Parameters for defining CAPWAP reassembly,
113619 + relevant if 'hdr' = HEADER_TYPE_CAPWAP */
113620 +#endif /* (DPAA_VERSION >= 11) */
113621 + ioc_fm_pcd_manip_reassem_ip_params_t ip_reassem; /**< Parameters for defining IP reassembly,
113622 + relevant if 'hdr' = HEADER_TYPE_Ipv4 or HEADER_TYPE_Ipv6 */
113623 + } u;
113624 +} ioc_fm_pcd_manip_reassem_params_t;
113625 +
113626 +/**************************************************************************//**
113627 + @Description Parameters for defining a manipulation node
113628 +*//***************************************************************************/
113629 +typedef struct ioc_fm_pcd_manip_params_t {
113630 + ioc_fm_pcd_manip_type type; /**< Selects type of manipulation node */
113631 + union {
113632 + ioc_fm_pcd_manip_hdr_params_t hdr; /**< Parameters for defining header manipulation node */
113633 + ioc_fm_pcd_manip_reassem_params_t reassem;/**< Parameters for defining reassembly manipulation node */
113634 + ioc_fm_pcd_manip_frag_params_t frag; /**< Parameters for defining fragmentation manipulation node */
113635 + ioc_fm_pcd_manip_special_offload_params_t special_offload;/**< Parameters for defining special offload manipulation node */
113636 + } u;
113637 + void *p_next_manip;/**< Handle to another (previously defined) manipulation node;
113638 + Allows concatenation of manipulation actions
113639 + This parameter is optional and may be NULL. */
113640 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
113641 + bool frag_or_reasm;/**< TRUE, if defined fragmentation/reassembly manipulation */
113642 + ioc_fm_pcd_manip_frag_or_reasm_params_t frag_or_reasm_params;/**< Parameters for fragmentation/reassembly manipulation,
113643 + relevant if frag_or_reasm = TRUE */
113644 +#endif /* FM_CAPWAP_SUPPORT */
113645 + void *id;
113646 +} ioc_fm_pcd_manip_params_t;
113647 +
113648 +/**************************************************************************//**
113649 + @Description Structure for retrieving IP reassembly statistics
113650 +*//***************************************************************************/
113651 +typedef struct ioc_fm_pcd_manip_reassem_ip_stats_t {
113652 + /* common counters for both IPv4 and IPv6 */
113653 + uint32_t timeout; /**< Counts the number of TimeOut occurrences */
113654 + uint32_t rfd_pool_busy; /**< Counts the number of failed attempts to allocate
113655 + a Reassembly Frame Descriptor */
113656 + uint32_t internal_buffer_busy; /**< Counts the number of times an internal buffer busy occurred */
113657 + uint32_t external_buffer_busy; /**< Counts the number of times external buffer busy occurred */
113658 + uint32_t sg_fragments; /**< Counts the number of Scatter/Gather fragments */
113659 + uint32_t dma_semaphore_depletion; /**< Counts the number of failed attempts to allocate a DMA semaphore */
113660 +#if (DPAA_VERSION >= 11)
113661 + uint32_t non_consistent_sp; /**< Counts the number of Non Consistent Storage Profile events for
113662 + successfully reassembled frames */
113663 +#endif /* (DPAA_VERSION >= 11) */
113664 +struct {
113665 + uint32_t successfully_reassembled; /**< Counts the number of successfully reassembled frames */
113666 + uint32_t valid_fragments; /**< Counts the total number of valid fragments that
113667 + have been processed for all frames */
113668 + uint32_t processed_fragments; /**< Counts the number of processed fragments
113669 + (valid and error fragments) for all frames */
113670 + uint32_t malformed_fragments; /**< Counts the number of malformed fragments processed for all frames */
113671 + uint32_t discarded_fragments; /**< Counts the number of fragments discarded by the reassembly process */
113672 + uint32_t auto_learn_busy; /**< Counts the number of times a busy condition occurs when attempting
113673 + to access an IP-Reassembly Automatic Learning Hash set */
113674 + uint32_t more_than16fragments; /**< Counts the fragment occurrences in which the number of fragments-per-frame
113675 + exceeds 16 */
113676 + } specific_hdr_statistics[2]; /**< slot '0' is for IPv4, slot '1' is for IPv6 */
113677 +} ioc_fm_pcd_manip_reassem_ip_stats_t;
113678 +
113679 +/**************************************************************************//**
113680 + @Description Structure for retrieving IP fragmentation statistics
113681 +*//***************************************************************************/
113682 +typedef struct ioc_fm_pcd_manip_frag_ip_stats_t {
113683 + uint32_t total_frames; /**< Number of frames that passed through the manipulation node */
113684 + uint32_t fragmented_frames; /**< Number of frames that were fragmented */
113685 + uint32_t generated_fragments; /**< Number of fragments that were generated */
113686 +} ioc_fm_pcd_manip_frag_ip_stats_t;
113687 +
113688 +#if (DPAA_VERSION >= 11)
113689 +/**************************************************************************//**
113690 + @Description Structure for retrieving CAPWAP reassembly statistics
113691 +*//***************************************************************************/
113692 +typedef struct ioc_fm_pcd_manip_reassem_capwap_stats_t {
113693 + uint32_t timeout; /**< Counts the number of timeout occurrences */
113694 + uint32_t rfd_pool_busy; /**< Counts the number of failed attempts to allocate
113695 + a Reassembly Frame Descriptor */
113696 + uint32_t internal_buffer_busy; /**< Counts the number of times an internal buffer busy occurred */
113697 + uint32_t external_buffer_busy; /**< Counts the number of times external buffer busy occurred */
113698 + uint32_t sg_fragments; /**< Counts the number of Scatter/Gather fragments */
113699 + uint32_t dma_semaphore_depletion; /**< Counts the number of failed attempts to allocate a DMA semaphore */
113700 + uint32_t successfully_reassembled; /**< Counts the number of successfully reassembled frames */
113701 + uint32_t valid_fragments; /**< Counts the total number of valid fragments that
113702 + have been processed for all frames */
113703 + uint32_t processed_fragments; /**< Counts the number of processed fragments
113704 + (valid and error fragments) for all frames */
113705 + uint32_t malformed_fragments; /**< Counts the number of malformed fragments processed for all frames */
113706 + uint32_t autoLearn_busy; /**< Counts the number of times a busy condition occurs when attempting
113707 + to access an Reassembly Automatic Learning Hash set */
113708 + uint32_t discarded_fragments; /**< Counts the number of fragments discarded by the reassembly process */
113709 + uint32_t more_than16fragments; /**< Counts the fragment occurrences in which the number of fragments-per-frame
113710 + exceeds 16 */
113711 + uint32_t exceed_max_reassembly_frame_len;/**< ounts the number of times that a successful reassembled frame
113712 + length exceeds MaxReassembledFrameLength value */
113713 +} ioc_fm_pcd_manip_reassem_capwap_stats_t;
113714 +
113715 +/**************************************************************************//**
113716 + @Description Structure for retrieving CAPWAP fragmentation statistics
113717 +*//***************************************************************************/
113718 +typedef struct ioc_fm_pcd_manip_frag_capwap_stats_t {
113719 + uint32_t total_frames; /**< Number of frames that passed through the manipulation node */
113720 + uint32_t fragmented_frames; /**< Number of frames that were fragmented */
113721 + uint32_t generated_fragments; /**< Number of fragments that were generated */
113722 +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
113723 + uint8_t sg_allocation_failure; /**< Number of allocation failure of s/g buffers */
113724 +#endif /* (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)) */
113725 +} ioc_fm_pcd_manip_frag_capwap_stats_t;
113726 +#endif /* (DPAA_VERSION >= 11) */
113727 +
113728 +/**************************************************************************//**
113729 + @Description Structure for retrieving reassembly statistics
113730 +*//***************************************************************************/
113731 +typedef struct ioc_fm_pcd_manip_reassem_stats_t {
113732 + union {
113733 + ioc_fm_pcd_manip_reassem_ip_stats_t ip_reassem; /**< Structure for IP reassembly statistics */
113734 +#if (DPAA_VERSION >= 11)
113735 + ioc_fm_pcd_manip_reassem_capwap_stats_t capwap_reassem; /**< Structure for CAPWAP reassembly statistics */
113736 +#endif /* (DPAA_VERSION >= 11) */
113737 + } u;
113738 +} ioc_fm_pcd_manip_reassem_stats_t;
113739 +
113740 +/**************************************************************************//**
113741 + @Description structure for retrieving fragmentation statistics
113742 +*//***************************************************************************/
113743 +typedef struct ioc_fm_pcd_manip_frag_stats_t {
113744 + union {
113745 + ioc_fm_pcd_manip_frag_ip_stats_t ip_frag; /**< Structure for IP fragmentation statistics */
113746 +#if (DPAA_VERSION >= 11)
113747 + ioc_fm_pcd_manip_frag_capwap_stats_t capwap_frag; /**< Structure for CAPWAP fragmentation statistics */
113748 +#endif /* (DPAA_VERSION >= 11) */
113749 + } u;
113750 +} ioc_fm_pcd_manip_frag_stats_t;
113751 +
113752 +/**************************************************************************//**
113753 + @Description structure for defining manipulation statistics
113754 +*//***************************************************************************/
113755 +typedef struct ioc_fm_pcd_manip_stats_t {
113756 + union {
113757 + ioc_fm_pcd_manip_reassem_stats_t reassem; /**< Structure for reassembly statistics */
113758 + ioc_fm_pcd_manip_frag_stats_t frag; /**< Structure for fragmentation statistics */
113759 + } u;
113760 +} ioc_fm_pcd_manip_stats_t;
113761 +
113762 +/**************************************************************************//**
113763 + @Description Parameters for acquiring manipulation statistics
113764 +*//***************************************************************************/
113765 +typedef struct ioc_fm_pcd_manip_get_stats_t {
113766 + void *id;
113767 + ioc_fm_pcd_manip_stats_t stats;
113768 +} ioc_fm_pcd_manip_get_stats_t;
113769 +
113770 +#if DPAA_VERSION >= 11
113771 +/**************************************************************************//**
113772 + @Description Parameters for defining frame replicator group and its members
113773 +*//***************************************************************************/
113774 +typedef struct ioc_fm_pcd_frm_replic_group_params_t {
113775 + uint8_t max_num_of_entries; /**< Maximal number of members in the group - must be at least two */
113776 + uint8_t num_of_entries; /**< Number of members in the group - must be at least 1 */
113777 + ioc_fm_pcd_cc_next_engine_params_t next_engine_params[IOC_FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES];
113778 + /**< Array of members' parameters */
113779 + void *id;
113780 +} ioc_fm_pcd_frm_replic_group_params_t;
113781 +
113782 +typedef struct ioc_fm_pcd_frm_replic_member_t {
113783 + void *h_replic_group;
113784 + uint16_t member_index;
113785 +} ioc_fm_pcd_frm_replic_member_t;
113786 +
113787 +typedef struct ioc_fm_pcd_frm_replic_member_params_t {
113788 + ioc_fm_pcd_frm_replic_member_t member;
113789 + ioc_fm_pcd_cc_next_engine_params_t next_engine_params;
113790 +} ioc_fm_pcd_frm_replic_member_params_t;
113791 +#endif /* DPAA_VERSION >= 11 */
113792 +
113793 +
113794 +typedef struct ioc_fm_pcd_cc_key_statistics_t {
113795 + uint32_t byte_count; /**< This counter reflects byte count of frames that
113796 + were matched by this key. */
113797 + uint32_t frame_count; /**< This counter reflects count of frames that
113798 + were matched by this key. */
113799 +#if (DPAA_VERSION >= 11)
113800 + uint32_t frame_length_range_count[IOC_FM_PCD_CC_STATS_MAX_NUM_OF_FLR];
113801 + /**< These counters reflect how many frames matched
113802 + this key in 'RMON' statistics mode:
113803 + Each counter holds the number of frames of a
113804 + specific frames length range, according to the
113805 + ranges provided at initialization. */
113806 +#endif /* (DPAA_VERSION >= 11) */
113807 +} ioc_fm_pcd_cc_key_statistics_t;
113808 +
113809 +
113810 +typedef struct ioc_fm_pcd_cc_tbl_get_stats_t {
113811 + void *id;
113812 + uint16_t key_index;
113813 + ioc_fm_pcd_cc_key_statistics_t statistics;
113814 +} ioc_fm_pcd_cc_tbl_get_stats_t;
113815 +
113816 +/**************************************************************************//**
113817 + @Function FM_PCD_MatchTableGetKeyStatistics
113818 +
113819 + @Description This routine may be used to get statistics counters of specific key
113820 + in a CC Node.
113821 +
113822 + If 'e_FM_PCD_CC_STATS_MODE_FRAME' and
113823 + 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node,
113824 + these counters reflect how many frames passed that were matched
113825 + this key; The total frames count will be returned in the counter
113826 + of the first range (as only one frame length range was defined).
113827 + If 'e_FM_PCD_CC_STATS_MODE_RMON' was set for this node, the total
113828 + frame count will be separated to frame length counters, based on
113829 + provided frame length ranges.
113830 +
113831 + @Param[in] h_CcNode A handle to the node
113832 + @Param[in] keyIndex Key index for adding
113833 + @Param[out] p_KeyStatistics Key statistics counters
113834 +
113835 + @Return The specific key statistics.
113836 +
113837 + @Cautions Allowed only following FM_PCD_MatchTableSet().
113838 +*//***************************************************************************/
113839 +
113840 +#if defined(CONFIG_COMPAT)
113841 +#define FM_PCD_IOC_MATCH_TABLE_GET_KEY_STAT_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(12), ioc_compat_fm_pcd_cc_tbl_get_stats_t)
113842 +#endif
113843 +#define FM_PCD_IOC_MATCH_TABLE_GET_KEY_STAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(12), ioc_fm_pcd_cc_tbl_get_stats_t)
113844 +
113845 +/**************************************************************************//**
113846 + @Function FM_PCD_MatchTableGetMissStatistics
113847 +
113848 + @Description This routine may be used to get statistics counters of miss entry
113849 + in a CC Node.
113850 +
113851 + If 'e_FM_PCD_CC_STATS_MODE_FRAME' and
113852 + 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node,
113853 + these counters reflect how many frames were not matched to any
113854 + existing key and therefore passed through the miss entry; The
113855 + total frames count will be returned in the counter of the
113856 + first range (as only one frame length range was defined).
113857 +
113858 + @Param[in] h_CcNode A handle to the node
113859 + @Param[out] p_MissStatistics Statistics counters for 'miss'
113860 +
113861 + @Return E_OK on success; Error code otherwise.
113862 +
113863 + @Cautions Allowed only following FM_PCD_MatchTableSet().
113864 +*//***************************************************************************/
113865 +
113866 +#if defined(CONFIG_COMPAT)
113867 +#define FM_PCD_IOC_MATCH_TABLE_GET_MISS_STAT_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(13), ioc_compat_fm_pcd_cc_tbl_get_stats_t)
113868 +#endif
113869 +#define FM_PCD_IOC_MATCH_TABLE_GET_MISS_STAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(13), ioc_fm_pcd_cc_tbl_get_stats_t)
113870 +
113871 +/**************************************************************************//**
113872 + @Function FM_PCD_HashTableGetMissStatistics
113873 +
113874 + @Description This routine may be used to get statistics counters of 'miss'
113875 + entry of the a hash table.
113876 +
113877 + If 'e_FM_PCD_CC_STATS_MODE_FRAME' and
113878 + 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node,
113879 + these counters reflect how many frames were not matched to any
113880 + existing key and therefore passed through the miss entry;
113881 +
113882 + @Param[in] h_HashTbl A handle to a hash table
113883 + @Param[out] p_MissStatistics Statistics counters for 'miss'
113884 +
113885 + @Return E_OK on success; Error code otherwise.
113886 +
113887 + @Cautions Allowed only following FM_PCD_HashTableSet().
113888 +*//***************************************************************************/
113889 +
113890 +#if defined(CONFIG_COMPAT)
113891 +#define FM_PCD_IOC_HASH_TABLE_GET_MISS_STAT_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(14), ioc_compat_fm_pcd_cc_tbl_get_stats_t)
113892 +#endif
113893 +#define FM_PCD_IOC_HASH_TABLE_GET_MISS_STAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(14), ioc_fm_pcd_cc_tbl_get_stats_t)
113894 +
113895 +
113896 +/**************************************************************************//**
113897 + @Function FM_PCD_NetEnvCharacteristicsSet
113898 +
113899 + @Description Define a set of Network Environment Characteristics.
113900 +
113901 + When setting an environment it is important to understand its
113902 + application. It is not meant to describe the flows that will run
113903 + on the ports using this environment, but what the user means TO DO
113904 + with the PCD mechanisms in order to parse-classify-distribute those
113905 + frames.
113906 + By specifying a distinction unit, the user means it would use that option
113907 + for distinction between frames at either a KeyGen scheme or a coarse
113908 + classification action descriptor. Using interchangeable headers to define a
113909 + unit means that the user is indifferent to which of the interchangeable
113910 + headers is present in the frame, and wants the distinction to be based
113911 + on the presence of either one of them.
113912 +
113913 + Depending on context, there are limitations to the use of environments. A
113914 + port using the PCD functionality is bound to an environment. Some or even
113915 + all ports may share an environment but also an environment per port is
113916 + possible. When initializing a scheme, a classification plan group (see below),
113917 + or a coarse classification tree, one of the initialized environments must be
113918 + stated and related to. When a port is bound to a scheme, a classification
113919 + plan group, or a coarse classification tree, it MUST be bound to the same
113920 + environment.
113921 +
113922 + The different PCD modules, may relate (for flows definition) ONLY on
113923 + distinction units as defined by their environment. When initializing a
113924 + scheme for example, it may not choose to select IPV4 as a match for
113925 + recognizing flows unless it was defined in the relating environment. In
113926 + fact, to guide the user through the configuration of the PCD, each module's
113927 + characterization in terms of flows is not done using protocol names, but using
113928 + environment indexes.
113929 +
113930 + In terms of HW implementation, the list of distinction units sets the LCV vectors
113931 + and later used for match vector, classification plan vectors and coarse classification
113932 + indexing.
113933 +
113934 + @Param[in,out] ioc_fm_pcd_net_env_params_t A structure defining the distiction units for this configuration.
113935 +
113936 + @Return 0 on success; Error code otherwise.
113937 +*//***************************************************************************/
113938 +#if defined(CONFIG_COMPAT)
113939 +#define FM_PCD_IOC_NET_ENV_CHARACTERISTICS_SET_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(20), ioc_compat_fm_pcd_net_env_params_t)
113940 +#endif
113941 +#define FM_PCD_IOC_NET_ENV_CHARACTERISTICS_SET _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(20), ioc_fm_pcd_net_env_params_t)
113942 +
113943 +/**************************************************************************//**
113944 + @Function FM_PCD_NetEnvCharacteristicsDelete
113945 +
113946 + @Description Deletes a set of Network Environment Charecteristics.
113947 +
113948 + @Param[in] ioc_fm_obj_t - The id of a Network Environment object.
113949 +
113950 + @Return 0 on success; Error code otherwise.
113951 +*//***************************************************************************/
113952 +#if defined(CONFIG_COMPAT)
113953 +#define FM_PCD_IOC_NET_ENV_CHARACTERISTICS_DELETE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(21), ioc_compat_fm_obj_t)
113954 +#endif
113955 +#define FM_PCD_IOC_NET_ENV_CHARACTERISTICS_DELETE _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(21), ioc_fm_obj_t)
113956 +
113957 +/**************************************************************************//**
113958 + @Function FM_PCD_KgSchemeSet
113959 +
113960 + @Description Initializing or modifying and enabling a scheme for the KeyGen.
113961 + This routine should be called for adding or modifying a scheme.
113962 + When a scheme needs modifying, the API requires that it will be
113963 + rewritten. In such a case 'modify' should be TRUE. If the
113964 + routine is called for a valid scheme and 'modify' is FALSE,
113965 + it will return error.
113966 +
113967 + @Param[in,out] ioc_fm_pcd_kg_scheme_params_t A structure of parameters for defining the scheme
113968 +
113969 + @Return 0 on success; Error code otherwise.
113970 +*//***************************************************************************/
113971 +#if defined(CONFIG_COMPAT)
113972 +#define FM_PCD_IOC_KG_SCHEME_SET_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(24), ioc_compat_fm_pcd_kg_scheme_params_t)
113973 +#endif
113974 +#define FM_PCD_IOC_KG_SCHEME_SET _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(24), ioc_fm_pcd_kg_scheme_params_t)
113975 +
113976 +/**************************************************************************//**
113977 + @Function FM_PCD_KgSchemeDelete
113978 +
113979 + @Description Deleting an initialized scheme.
113980 +
113981 + @Param[in] ioc_fm_obj_t scheme id as initalized by application at FM_PCD_IOC_KG_SET_SCHEME
113982 +
113983 + @Return 0 on success; Error code otherwise.
113984 +*//***************************************************************************/
113985 +#if defined(CONFIG_COMPAT)
113986 +#define FM_PCD_IOC_KG_SCHEME_DELETE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(25), ioc_compat_fm_obj_t)
113987 +#endif
113988 +#define FM_PCD_IOC_KG_SCHEME_DELETE _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(25), ioc_fm_obj_t)
113989 +
113990 +/**************************************************************************//**
113991 + @Function FM_PCD_CcRootBuild
113992 +
113993 + @Description This routine must be called to define a complete coarse
113994 + classification tree. This is the way to define coarse
113995 + classification to a certain flow - the KeyGen schemes
113996 + may point only to trees defined in this way.
113997 +
113998 + @Param[in,out] ioc_fm_pcd_cc_tree_params_t A structure of parameters to define the tree.
113999 +
114000 + @Return 0 on success; Error code otherwise.
114001 +*//***************************************************************************/
114002 +#if defined(CONFIG_COMPAT)
114003 +#define FM_PCD_IOC_CC_ROOT_BUILD_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(26), compat_uptr_t)
114004 +#endif
114005 +#define FM_PCD_IOC_CC_ROOT_BUILD _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(26), void *) /* workaround ...*/
114006 +
114007 +/**************************************************************************//**
114008 + @Function FM_PCD_CcRootDelete
114009 +
114010 + @Description Deleting a built tree.
114011 +
114012 + @Param[in] ioc_fm_obj_t - The id of a CC tree.
114013 +*//***************************************************************************/
114014 +#if defined(CONFIG_COMPAT)
114015 +#define FM_PCD_IOC_CC_ROOT_DELETE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(27), ioc_compat_fm_obj_t)
114016 +#endif
114017 +#define FM_PCD_IOC_CC_ROOT_DELETE _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(27), ioc_fm_obj_t)
114018 +
114019 +/**************************************************************************//**
114020 + @Function FM_PCD_MatchTableSet
114021 +
114022 + @Description This routine should be called for each CC (coarse classification)
114023 + node. The whole CC tree should be built bottom up so that each
114024 + node points to already defined nodes. p_NodeId returns the node
114025 + Id to be used by other nodes.
114026 +
114027 + @Param[in,out] ioc_fm_pcd_cc_node_params_t A structure for defining the CC node params
114028 +
114029 + @Return 0 on success; Error code otherwise.
114030 +*//***************************************************************************/
114031 +#if defined(CONFIG_COMPAT)
114032 +#define FM_PCD_IOC_MATCH_TABLE_SET_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(28), compat_uptr_t)
114033 +#endif
114034 +#define FM_PCD_IOC_MATCH_TABLE_SET _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(28), void *) /* workaround ...*/
114035 +
114036 +/**************************************************************************//**
114037 + @Function FM_PCD_MatchTableDelete
114038 +
114039 + @Description Deleting a built node.
114040 +
114041 + @Param[in] ioc_fm_obj_t - The id of a CC node.
114042 +
114043 + @Return 0 on success; Error code otherwise.
114044 +*//***************************************************************************/
114045 +#if defined(CONFIG_COMPAT)
114046 +#define FM_PCD_IOC_MATCH_TABLE_DELETE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(29), ioc_compat_fm_obj_t)
114047 +#endif
114048 +#define FM_PCD_IOC_MATCH_TABLE_DELETE _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(29), ioc_fm_obj_t)
114049 +
114050 +/**************************************************************************//**
114051 + @Function FM_PCD_CcRootModifyNextEngine
114052 +
114053 + @Description Modify the Next Engine Parameters in the entry of the tree.
114054 +
114055 + @Param[in] ioc_fm_pcd_cc_tree_modify_next_engine_params_t - Pointer to a structure with the relevant parameters
114056 +
114057 + @Return 0 on success; Error code otherwise.
114058 +
114059 + @Cautions Allowed only following FM_PCD_CcRootBuild().
114060 +*//***************************************************************************/
114061 +#if defined(CONFIG_COMPAT)
114062 +#define FM_PCD_IOC_CC_ROOT_MODIFY_NEXT_ENGINE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(30), ioc_compat_fm_pcd_cc_tree_modify_next_engine_params_t)
114063 +#endif
114064 +#define FM_PCD_IOC_CC_ROOT_MODIFY_NEXT_ENGINE _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(30), ioc_fm_pcd_cc_tree_modify_next_engine_params_t)
114065 +
114066 +/**************************************************************************//**
114067 + @Function FM_PCD_MatchTableModifyNextEngine
114068 +
114069 + @Description Modify the Next Engine Parameters in the relevant key entry of the node.
114070 +
114071 + @Param[in] ioc_fm_pcd_cc_node_modify_next_engine_params_t A pointer to a structure with the relevant parameters
114072 +
114073 + @Return 0 on success; Error code otherwise.
114074 +
114075 + @Cautions Allowed only following FM_PCD_MatchTableSet().
114076 +*//***************************************************************************/
114077 +#if defined(CONFIG_COMPAT)
114078 +#define FM_PCD_IOC_MATCH_TABLE_MODIFY_NEXT_ENGINE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(31), ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t)
114079 +#endif
114080 +#define FM_PCD_IOC_MATCH_TABLE_MODIFY_NEXT_ENGINE _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(31), ioc_fm_pcd_cc_node_modify_next_engine_params_t)
114081 +
114082 +/**************************************************************************//**
114083 + @Function FM_PCD_MatchTableModifyMissNextEngine
114084 +
114085 + @Description Modify the Next Engine Parameters of the Miss key case of the node.
114086 +
114087 + @Param[in] ioc_fm_pcd_cc_node_modify_next_engine_params_t - Pointer to a structure with the relevant parameters
114088 +
114089 + @Return 0 on success; Error code otherwise.
114090 +
114091 + @Cautions Allowed only following FM_PCD_MatchTableSet().
114092 +*//***************************************************************************/
114093 +#if defined(CONFIG_COMPAT)
114094 +#define FM_PCD_IOC_MATCH_TABLE_MODIFY_MISS_NEXT_ENGINE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(32), ioc_compat_fm_pcd_cc_node_modify_next_engine_params_t)
114095 +#endif
114096 +#define FM_PCD_IOC_MATCH_TABLE_MODIFY_MISS_NEXT_ENGINE _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(32), ioc_fm_pcd_cc_node_modify_next_engine_params_t)
114097 +
114098 +/**************************************************************************//**
114099 + @Function FM_PCD_MatchTableRemoveKey
114100 +
114101 + @Description Remove the key (including next engine parameters of this key)
114102 + defined by the index of the relevant node.
114103 +
114104 + @Param[in] ioc_fm_pcd_cc_node_remove_key_params_t A pointer to a structure with the relevant parameters
114105 +
114106 + @Return 0 on success; Error code otherwise.
114107 +
114108 + @Cautions Allowed only after FM_PCD_MatchTableSet() has been called for this
114109 + node and for all of the nodes that lead to it.
114110 +*//***************************************************************************/
114111 +#if defined(CONFIG_COMPAT)
114112 +#define FM_PCD_IOC_MATCH_TABLE_REMOVE_KEY_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(33), ioc_compat_fm_pcd_cc_node_remove_key_params_t)
114113 +#endif
114114 +#define FM_PCD_IOC_MATCH_TABLE_REMOVE_KEY _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(33), ioc_fm_pcd_cc_node_remove_key_params_t)
114115 +
114116 +/**************************************************************************//**
114117 + @Function FM_PCD_MatchTableAddKey
114118 +
114119 + @Description Add the key (including next engine parameters of this key in the
114120 + index defined by the keyIndex. Note that 'FM_PCD_LAST_KEY_INDEX'
114121 + may be used when the user doesn't care about the position of the
114122 + key in the table - in that case, the key will be automatically
114123 + added by the driver in the last available entry.
114124 +
114125 + @Param[in] ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t A pointer to a structure with the relevant parameters
114126 +
114127 + @Return 0 on success; Error code otherwise.
114128 +
114129 + @Cautions Allowed only after FM_PCD_MatchTableSet() has been called for this
114130 + node and for all of the nodes that lead to it.
114131 +*//***************************************************************************/
114132 +#if defined(CONFIG_COMPAT)
114133 +#define FM_PCD_IOC_MATCH_TABLE_ADD_KEY_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(34), ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t)
114134 +#endif
114135 +#define FM_PCD_IOC_MATCH_TABLE_ADD_KEY _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(34), ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t)
114136 +
114137 +/**************************************************************************//**
114138 + @Function FM_PCD_MatchTableModifyKeyAndNextEngine
114139 +
114140 + @Description Modify the key and Next Engine Parameters of this key in the index defined by key_index.
114141 +
114142 + @Param[in] ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t A pointer to a structure with the relevant parameters
114143 +
114144 + @Return 0 on success; Error code otherwise.
114145 +
114146 + @Cautions Allowed only following FM_PCD_MatchTableSet() not only of the relevnt node but also
114147 + the node that points to this node
114148 +*//***************************************************************************/
114149 +#if defined(CONFIG_COMPAT)
114150 +#define FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY_AND_NEXT_ENGINE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(35), ioc_compat_fm_pcd_cc_node_modify_key_and_next_engine_params_t)
114151 +#endif
114152 +#define FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY_AND_NEXT_ENGINE _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(35), ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t)
114153 +
114154 +/**************************************************************************//**
114155 + @Function FM_PCD_MatchTableModifyKey
114156 +
114157 + @Description Modify the key at the index defined by key_index.
114158 +
114159 + @Param[in] ioc_fm_pcd_cc_node_modify_key_params_t - Pointer to a structure with the relevant parameters
114160 +
114161 + @Return 0 on success; Error code otherwise.
114162 +
114163 + @Cautions Allowed only after FM_PCD_MatchTableSet() has been called for this
114164 + node and for all of the nodes that lead to it.
114165 +*//***************************************************************************/
114166 +#if defined(CONFIG_COMPAT)
114167 +#define FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(36), ioc_compat_fm_pcd_cc_node_modify_key_params_t)
114168 +#endif
114169 +#define FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(36), ioc_fm_pcd_cc_node_modify_key_params_t)
114170 +
114171 +/**************************************************************************//**
114172 + @Function FM_PCD_HashTableSet
114173 +
114174 + @Description This routine initializes a hash table structure.
114175 + KeyGen hash result determines the hash bucket.
114176 + Next, KeyGen key is compared against all keys of this
114177 + bucket (exact match).
114178 + Number of sets (number of buckets) of the hash equals to the
114179 + number of 1-s in 'hash_res_mask' in the provided parameters.
114180 + Number of hash table ways is then calculated by dividing
114181 + 'max_num_of_keys' equally between the hash sets. This is the maximal
114182 + number of keys that a hash bucket may hold.
114183 + The hash table is initialized empty and keys may be
114184 + added to it following the initialization. Keys masks are not
114185 + supported in current hash table implementation.
114186 + The initialized hash table can be integrated as a node in a
114187 + CC tree.
114188 +
114189 + @Param[in,out] ioc_fm_pcd_hash_table_params_t - Pointer to a structure with the relevant parameters
114190 +
114191 + @Return 0 on success; Error code otherwise.
114192 +*//***************************************************************************/
114193 +#if defined(CONFIG_COMPAT)
114194 +#define FM_PCD_IOC_HASH_TABLE_SET_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(37), ioc_compat_fm_pcd_hash_table_params_t)
114195 +#endif
114196 +#define FM_PCD_IOC_HASH_TABLE_SET _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(37), ioc_fm_pcd_hash_table_params_t)
114197 +
114198 +
114199 +/**************************************************************************//**
114200 + @Function FM_PCD_HashTableDelete
114201 +
114202 + @Description This routine deletes the provided hash table and released all
114203 + its allocated resources.
114204 +
114205 + @Param[in] ioc_fm_obj_t - The ID of a hash table.
114206 +
114207 + @Return 0 on success; Error code otherwise.
114208 +
114209 + @Cautions Allowed only following FM_PCD_HashTableSet().
114210 +*//***************************************************************************/
114211 +#if defined(CONFIG_COMPAT)
114212 +#define FM_PCD_IOC_HASH_TABLE_DELETE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(37), ioc_compat_fm_obj_t)
114213 +#endif
114214 +#define FM_PCD_IOC_HASH_TABLE_DELETE _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(37), ioc_fm_obj_t)
114215 +
114216 +/**************************************************************************//**
114217 + @Function FM_PCD_HashTableAddKey
114218 +
114219 + @Description This routine adds the provided key (including next engine
114220 + parameters of this key) to the hash table.
114221 + The key is added as the last key of the bucket that it is
114222 + mapped to.
114223 +
114224 + @Param[in] ioc_fm_pcd_hash_table_add_key_params_t - Pointer to a structure with the relevant parameters
114225 +
114226 + @Return 0 on success; error code otherwise.
114227 +
114228 + @Cautions Allowed only following FM_PCD_HashTableSet().
114229 +*//***************************************************************************/
114230 +#if defined(CONFIG_COMPAT)
114231 +#define FM_PCD_IOC_HASH_TABLE_ADD_KEY_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(39), ioc_compat_fm_pcd_hash_table_add_key_params_t)
114232 +#endif
114233 +#define FM_PCD_IOC_HASH_TABLE_ADD_KEY _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(39), ioc_fm_pcd_hash_table_add_key_params_t)
114234 +
114235 +/**************************************************************************//**
114236 + @Function FM_PCD_HashTableRemoveKey
114237 +
114238 + @Description This routine removes the requested key (including next engine
114239 + parameters of this key) from the hash table.
114240 +
114241 + @Param[in] ioc_fm_pcd_hash_table_remove_key_params_t - Pointer to a structure with the relevant parameters
114242 +
114243 + @Return 0 on success; Error code otherwise.
114244 +
114245 + @Cautions Allowed only following FM_PCD_HashTableSet().
114246 +*//***************************************************************************/
114247 +#if defined(CONFIG_COMPAT)
114248 +#define FM_PCD_IOC_HASH_TABLE_REMOVE_KEY_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(40), ioc_compat_fm_pcd_hash_table_remove_key_params_t)
114249 +#endif
114250 +#define FM_PCD_IOC_HASH_TABLE_REMOVE_KEY _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(40), ioc_fm_pcd_hash_table_remove_key_params_t)
114251 +
114252 +/**************************************************************************//**
114253 + @Function FM_PCD_PlcrProfileSet
114254 +
114255 + @Description Sets a profile entry in the policer profile table.
114256 + The routine overrides any existing value.
114257 +
114258 + @Param[in,out] ioc_fm_pcd_plcr_profile_params_t A structure of parameters for defining a
114259 + policer profile entry.
114260 +
114261 + @Return 0 on success; Error code otherwise.
114262 +*//***************************************************************************/
114263 +#if defined(CONFIG_COMPAT)
114264 +#define FM_PCD_IOC_PLCR_PROFILE_SET_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(41), ioc_compat_fm_pcd_plcr_profile_params_t)
114265 +#endif
114266 +#define FM_PCD_IOC_PLCR_PROFILE_SET _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(41), ioc_fm_pcd_plcr_profile_params_t)
114267 +
114268 +/**************************************************************************//**
114269 + @Function FM_PCD_PlcrProfileDelete
114270 +
114271 + @Description Delete a profile entry in the policer profile table.
114272 + The routine set entry to invalid.
114273 +
114274 + @Param[in] ioc_fm_obj_t The id of a policer profile.
114275 +
114276 + @Return 0 on success; Error code otherwise.
114277 +*//***************************************************************************/
114278 +#if defined(CONFIG_COMPAT)
114279 +#define FM_PCD_IOC_PLCR_PROFILE_DELETE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(41), ioc_compat_fm_obj_t)
114280 +#endif
114281 +#define FM_PCD_IOC_PLCR_PROFILE_DELETE _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(41), ioc_fm_obj_t)
114282 +
114283 +/**************************************************************************//**
114284 + @Function FM_PCD_ManipNodeSet
114285 +
114286 + @Description This routine should be called for defining a manipulation
114287 + node. A manipulation node must be defined before the CC node
114288 + that precedes it.
114289 +
114290 + @Param[in] ioc_fm_pcd_manip_params_t - A structure of parameters defining the manipulation
114291 +
114292 + @Return A handle to the initialized object on success; NULL code otherwise.
114293 +*//***************************************************************************/
114294 +#if defined(CONFIG_COMPAT)
114295 +#define FM_PCD_IOC_MANIP_NODE_SET_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(43), ioc_compat_fm_pcd_manip_params_t)
114296 +#endif
114297 +#define FM_PCD_IOC_MANIP_NODE_SET _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(43), ioc_fm_pcd_manip_params_t)
114298 +
114299 +/**************************************************************************//**
114300 + @Function FM_PCD_ManipNodeReplace
114301 +
114302 + @Description Change existing manipulation node to be according to new requirement.
114303 + (Here, it's implemented as a variant of the same IOCTL as for
114304 + FM_PCD_ManipNodeSet(), and one that when called, the 'id' member
114305 + in its 'ioc_fm_pcd_manip_params_t' argument is set to contain
114306 + the manip node's handle)
114307 +
114308 + @Param[in] ioc_fm_pcd_manip_params_t - A structure of parameters defining the manipulation
114309 +
114310 + @Return 0 on success; error code otherwise.
114311 +
114312 + @Cautions Allowed only following FM_PCD_ManipNodeSet().
114313 +*//***************************************************************************/
114314 +#if defined(CONFIG_COMPAT)
114315 +#define FM_PCD_IOC_MANIP_NODE_REPLACE_COMPAT FM_PCD_IOC_MANIP_NODE_SET_COMPAT
114316 +#endif
114317 +#define FM_PCD_IOC_MANIP_NODE_REPLACE FM_PCD_IOC_MANIP_NODE_SET
114318 +
114319 +/**************************************************************************//**
114320 + @Function FM_PCD_ManipNodeDelete
114321 +
114322 + @Description Delete an existing manipulation node.
114323 +
114324 + @Param[in] ioc_fm_obj_t The id of the manipulation node to delete.
114325 +
114326 + @Return 0 on success; error code otherwise.
114327 +
114328 + @Cautions Allowed only following FM_PCD_ManipNodeSet().
114329 +*//***************************************************************************/
114330 +#if defined(CONFIG_COMPAT)
114331 +#define FM_PCD_IOC_MANIP_NODE_DELETE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(44), ioc_compat_fm_obj_t)
114332 +#endif
114333 +#define FM_PCD_IOC_MANIP_NODE_DELETE _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(44), ioc_fm_obj_t)
114334 +
114335 +/**************************************************************************//**
114336 + @Function FM_PCD_ManipGetStatistics
114337 +
114338 + @Description Retrieve the manipulation statistics.
114339 +
114340 + @Param[in] h_ManipNode A handle to a manipulation node.
114341 + @Param[out] p_FmPcdManipStats A structure for retrieving the manipulation statistics
114342 +
114343 + @Return E_OK on success; Error code otherwise.
114344 +
114345 + @Cautions Allowed only following FM_PCD_ManipNodeSet().
114346 +*//***************************************************************************/
114347 +#if defined(CONFIG_COMPAT)
114348 +#define FM_PCD_IOC_MANIP_GET_STATS_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(50), ioc_compat_fm_pcd_manip_get_stats_t)
114349 +#endif
114350 +#define FM_PCD_IOC_MANIP_GET_STATS _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(50), ioc_fm_pcd_manip_get_stats_t)
114351 +
114352 +/**************************************************************************//**
114353 +@Function FM_PCD_SetAdvancedOffloadSupport
114354 +
114355 +@Description This routine must be called in order to support the following features:
114356 + IP-fragmentation, IP-reassembly, IPsec, Header-manipulation, frame-replicator.
114357 +
114358 +@Param[in] h_FmPcd FM PCD module descriptor.
114359 +
114360 +@Return 0 on success; error code otherwise.
114361 +
114362 +@Cautions Allowed only when PCD is disabled.
114363 +*//***************************************************************************/
114364 +#define FM_PCD_IOC_SET_ADVANCED_OFFLOAD_SUPPORT _IO(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(45))
114365 +
114366 +#if (DPAA_VERSION >= 11)
114367 +/**************************************************************************//**
114368 + @Function FM_PCD_FrmReplicSetGroup
114369 +
114370 + @Description Initialize a Frame Replicator group.
114371 +
114372 + @Param[in] h_FmPcd FM PCD module descriptor.
114373 + @Param[in] p_FrmReplicGroupParam A structure of parameters for the initialization of
114374 + the frame replicator group.
114375 +
114376 + @Return A handle to the initialized object on success; NULL code otherwise.
114377 +
114378 + @Cautions Allowed only following FM_PCD_Init().
114379 +*//***************************************************************************/
114380 +#if defined(CONFIG_COMPAT)
114381 +#define FM_PCD_IOC_FRM_REPLIC_GROUP_SET_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(46), ioc_compat_fm_pcd_frm_replic_group_params_t)
114382 +#endif
114383 +#define FM_PCD_IOC_FRM_REPLIC_GROUP_SET _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(46), ioc_fm_pcd_frm_replic_group_params_t)
114384 +
114385 +/**************************************************************************//**
114386 + @Function FM_PCD_FrmReplicDeleteGroup
114387 +
114388 + @Description Delete a Frame Replicator group.
114389 +
114390 + @Param[in] h_FrmReplicGroup A handle to the frame replicator group.
114391 +
114392 + @Return E_OK on success; Error code otherwise.
114393 +
114394 + @Cautions Allowed only following FM_PCD_FrmReplicSetGroup().
114395 +*//***************************************************************************/
114396 +#if defined(CONFIG_COMPAT)
114397 +#define FM_PCD_IOC_FRM_REPLIC_GROUP_DELETE_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(47), ioc_compat_fm_obj_t)
114398 +#endif
114399 +#define FM_PCD_IOC_FRM_REPLIC_GROUP_DELETE _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(47), ioc_fm_obj_t)
114400 +
114401 +/**************************************************************************//**
114402 + @Function FM_PCD_FrmReplicAddMember
114403 +
114404 + @Description Add the member in the index defined by the memberIndex.
114405 +
114406 + @Param[in] h_FrmReplicGroup A handle to the frame replicator group.
114407 + @Param[in] memberIndex member index for adding.
114408 + @Param[in] p_MemberParams A pointer to the new member parameters.
114409 +
114410 + @Return E_OK on success; Error code otherwise.
114411 +
114412 + @Cautions Allowed only following FM_PCD_FrmReplicSetGroup() of this group.
114413 +*//***************************************************************************/
114414 +#if defined(CONFIG_COMPAT)
114415 +#define FM_PCD_IOC_FRM_REPLIC_MEMBER_ADD_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(48), ioc_compat_fm_pcd_frm_replic_member_params_t)
114416 +#endif
114417 +#define FM_PCD_IOC_FRM_REPLIC_MEMBER_ADD _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(48), ioc_fm_pcd_frm_replic_member_params_t)
114418 +
114419 +/**************************************************************************//**
114420 + @Function FM_PCD_FrmReplicRemoveMember
114421 +
114422 + @Description Remove the member defined by the index from the relevant group.
114423 +
114424 + @Param[in] h_FrmReplicGroup A handle to the frame replicator group.
114425 + @Param[in] memberIndex member index for removing.
114426 +
114427 + @Return E_OK on success; Error code otherwise.
114428 +
114429 + @Cautions Allowed only following FM_PCD_FrmReplicSetGroup() of this group.
114430 +*//***************************************************************************/
114431 +#if defined(CONFIG_COMPAT)
114432 +#define FM_PCD_IOC_FRM_REPLIC_MEMBER_REMOVE_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(49), ioc_compat_fm_pcd_frm_replic_member_t)
114433 +#endif
114434 +#define FM_PCD_IOC_FRM_REPLIC_MEMBER_REMOVE _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(49), ioc_fm_pcd_frm_replic_member_t)
114435 +
114436 +#endif
114437 +
114438 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
114439 +/**************************************************************************//**
114440 + @Function FM_PCD_StatisticsSetNode
114441 +
114442 + @Description This routine should be called for defining a statistics node.
114443 +
114444 + @Param[in,out] ioc_fm_pcd_stats_params_t A structure of parameters defining the statistics
114445 +
114446 + @Return 0 on success; Error code otherwise.
114447 +*//***************************************************************************/
114448 +#if defined(CONFIG_COMPAT)
114449 +#define FM_PCD_IOC_STATISTICS_SET_NODE_COMPAT _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(45), void *)
114450 +#endif
114451 +#define FM_PCD_IOC_STATISTICS_SET_NODE _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(45), void *)
114452 +
114453 +#endif /* FM_CAPWAP_SUPPORT */
114454 +
114455 +#ifdef NCSW_BACKWARD_COMPATIBLE_API
114456 +#if defined(CONFIG_COMPAT)
114457 +#define FM_PCD_IOC_SET_NET_ENV_CHARACTERISTICS_COMPAT \
114458 + FM_PCD_IOC_NET_ENV_CHARACTERISTICS_SET_COMPAT
114459 +#define FM_PCD_IOC_DELETE_NET_ENV_CHARACTERISTICS_COMPAT \
114460 + FM_PCD_IOC_NET_ENV_CHARACTERISTICS_DELETE_COMPAT
114461 +#define FM_PCD_IOC_KG_SET_SCHEME_COMPAT FM_PCD_IOC_KG_SCHEME_SET_COMPAT
114462 +#define FM_PCD_IOC_KG_DEL_SCHEME_COMPAT FM_PCD_IOC_KG_SCHEME_DELETE_COMPAT
114463 +#define FM_PCD_IOC_CC_BUILD_TREE_COMPAT FM_PCD_IOC_CC_ROOT_BUILD_COMPAT
114464 +#define FM_PCD_IOC_CC_DELETE_TREE_COMPAT FM_PCD_IOC_CC_ROOT_DELETE_COMPAT
114465 +#define FM_PCD_IOC_CC_DELETE_NODE_COMPAT FM_PCD_IOC_MATCH_TABLE_DELETE_COMPAT
114466 +#define FM_PCD_IOC_CC_TREE_MODIFY_NEXT_ENGINE_COMPAT \
114467 + FM_PCD_IOC_CC_ROOT_MODIFY_NEXT_ENGINE_COMPAT
114468 +#define FM_PCD_IOC_CC_NODE_MODIFY_NEXT_ENGINE_COMPAT \
114469 + FM_PCD_IOC_MATCH_TABLE_MODIFY_NEXT_ENGINE_COMPAT
114470 +#define FM_PCD_IOC_CC_NODE_MODIFY_MISS_NEXT_ENGINE_COMPAT \
114471 + FM_PCD_IOC_MATCH_TABLE_MODIFY_MISS_NEXT_ENGINE_COMPAT
114472 +#define FM_PCD_IOC_CC_NODE_REMOVE_KEY_COMPAT FM_PCD_IOC_MATCH_TABLE_REMOVE_KEY_COMPAT
114473 +#define FM_PCD_IOC_CC_NODE_ADD_KEY_COMPAT FM_PCD_IOC_MATCH_TABLE_ADD_KEY_COMPAT
114474 +#define FM_PCD_IOC_CC_NODE_MODIFY_KEY_AND_NEXT_ENGINE_COMPAT \
114475 + FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY_AND_NEXT_ENGINE_COMPAT
114476 +#define FM_PCD_IOC_CC_NODE_MODIFY_KEY_COMPAT FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY_COMPAT
114477 +#define FM_PCD_IOC_PLCR_SET_PROFILE_COMPAT FM_PCD_IOC_PLCR_PROFILE_SET_COMPAT
114478 +#define FM_PCD_IOC_PLCR_DEL_PROFILE_COMPAT FM_PCD_IOC_PLCR_PROFILE_DELETE_COMPAT
114479 +#define FM_PCD_IOC_MANIP_SET_NODE_COMPAT FM_PCD_IOC_MANIP_NODE_SET_COMPAT
114480 +#define FM_PCD_IOC_MANIP_DELETE_NODE_COMPAT FM_PCD_IOC_MANIP_NODE_DELETE_COMPAT
114481 +#endif
114482 +#define FM_PCD_IOC_SET_NET_ENV_CHARACTERISTICS FM_PCD_IOC_NET_ENV_CHARACTERISTICS_SET
114483 +#define FM_PCD_IOC_DELETE_NET_ENV_CHARACTERISTICS \
114484 + FM_PCD_IOC_NET_ENV_CHARACTERISTICS_DELETE
114485 +#define FM_PCD_IOC_KG_SET_SCHEME FM_PCD_IOC_KG_SCHEME_SET
114486 +#define FM_PCD_IOC_KG_DEL_SCHEME FM_PCD_IOC_KG_SCHEME_DELETE
114487 +#define FM_PCD_IOC_CC_BUILD_TREE FM_PCD_IOC_CC_ROOT_BUILD
114488 +#define FM_PCD_IOC_CC_DELETE_TREE FM_PCD_IOC_CC_ROOT_DELETE
114489 +#define FM_PCD_IOC_CC_DELETE_NODE FM_PCD_IOC_MATCH_TABLE_DELETE
114490 +#define FM_PCD_IOC_CC_TREE_MODIFY_NEXT_ENGINE FM_PCD_IOC_CC_ROOT_MODIFY_NEXT_ENGINE
114491 +#define FM_PCD_IOC_CC_NODE_MODIFY_NEXT_ENGINE FM_PCD_IOC_MATCH_TABLE_MODIFY_NEXT_ENGINE
114492 +#define FM_PCD_IOC_CC_NODE_MODIFY_MISS_NEXT_ENGINE \
114493 + FM_PCD_IOC_MATCH_TABLE_MODIFY_MISS_NEXT_ENGINE
114494 +#define FM_PCD_IOC_CC_NODE_REMOVE_KEY FM_PCD_IOC_MATCH_TABLE_REMOVE_KEY
114495 +#define FM_PCD_IOC_CC_NODE_ADD_KEY FM_PCD_IOC_MATCH_TABLE_ADD_KEY
114496 +#define FM_PCD_IOC_CC_NODE_MODIFY_KEY_AND_NEXT_ENGINE \
114497 + FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY_AND_NEXT_ENGINE
114498 +#define FM_PCD_IOC_CC_NODE_MODIFY_KEY FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY
114499 +#define FM_PCD_IOC_PLCR_SET_PROFILE FM_PCD_IOC_PLCR_PROFILE_SET
114500 +#define FM_PCD_IOC_PLCR_DEL_PROFILE FM_PCD_IOC_PLCR_PROFILE_DELETE
114501 +#define FM_PCD_IOC_MANIP_SET_NODE FM_PCD_IOC_MANIP_NODE_SET
114502 +#define FM_PCD_IOC_MANIP_DELETE_NODE FM_PCD_IOC_MANIP_NODE_DELETE
114503 +#endif /* NCSW_BACKWARD_COMPATIBLE_API */
114504 +
114505 +#endif /* __FM_PCD_IOCTLS_H */
114506 +/** @} */ /* end of lnx_ioctl_FM_PCD_Runtime_grp group */
114507 +/** @} */ /* end of lnx_ioctl_FM_PCD_grp group */
114508 +/** @} */ /* end of lnx_ioctl_FM_grp group */
114509 --- /dev/null
114510 +++ b/include/uapi/linux/fmd/Peripherals/fm_port_ioctls.h
114511 @@ -0,0 +1,948 @@
114512 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc.
114513 + * All rights reserved.
114514 + *
114515 + * Redistribution and use in source and binary forms, with or without
114516 + * modification, are permitted provided that the following conditions are met:
114517 + * * Redistributions of source code must retain the above copyright
114518 + * notice, this list of conditions and the following disclaimer.
114519 + * * Redistributions in binary form must reproduce the above copyright
114520 + * notice, this list of conditions and the following disclaimer in the
114521 + * documentation and/or other materials provided with the distribution.
114522 + * * Neither the name of Freescale Semiconductor nor the
114523 + * names of its contributors may be used to endorse or promote products
114524 + * derived from this software without specific prior written permission.
114525 + *
114526 + *
114527 + * ALTERNATIVELY, this software may be distributed under the terms of the
114528 + * GNU General Public License ("GPL") as published by the Free Software
114529 + * Foundation, either version 2 of that License or (at your option) any
114530 + * later version.
114531 + *
114532 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
114533 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
114534 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
114535 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
114536 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
114537 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
114538 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
114539 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
114540 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
114541 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
114542 + */
114543 +
114544 +/******************************************************************************
114545 + @File fm_port_ioctls.h
114546 +
114547 + @Description FM Port routines
114548 +*//***************************************************************************/
114549 +#ifndef __FM_PORT_IOCTLS_H
114550 +#define __FM_PORT_IOCTLS_H
114551 +
114552 +#include "enet_ext.h"
114553 +#include "net_ioctls.h"
114554 +#include "fm_ioctls.h"
114555 +#include "fm_pcd_ioctls.h"
114556 +
114557 +
114558 +/**************************************************************************//**
114559 +
114560 + @Group lnx_ioctl_FM_grp Frame Manager Linux IOCTL API
114561 +
114562 + @Description FM Linux ioctls definitions and enums
114563 +
114564 + @{
114565 +*//***************************************************************************/
114566 +
114567 +/**************************************************************************//**
114568 + @Group lnx_ioctl_FM_PORT_grp FM Port
114569 +
114570 + @Description FM Port API
114571 +
114572 + The FM uses a general module called "port" to represent a Tx port
114573 + (MAC), an Rx port (MAC), offline parsing flow or host command
114574 + flow. There may be up to 17 (may change) ports in an FM - 5 Tx
114575 + ports (4 for the 1G MACs, 1 for the 10G MAC), 5 Rx Ports, and 7
114576 + Host command/Offline parsing ports. The SW driver manages these
114577 + ports as sub-modules of the FM, i.e. after an FM is initialized,
114578 + its ports may be initialized and operated upon.
114579 +
114580 + The port is initialized aware of its type, but other functions on
114581 + a port may be indifferent to its type. When necessary, the driver
114582 + verifies coherency and returns error if applicable.
114583 +
114584 + On initialization, user specifies the port type and it's index
114585 + (relative to the port's type). Host command and Offline parsing
114586 + ports share the same id range, I.e user may not initialized host
114587 + command port 0 and offline parsing port 0.
114588 +
114589 + @{
114590 +*//***************************************************************************/
114591 +
114592 +/**************************************************************************//**
114593 + @Description An enum for defining port PCD modes.
114594 + (Must match enum e_FmPortPcdSupport defined in fm_port_ext.h)
114595 +
114596 + This enum defines the superset of PCD engines support - i.e. not
114597 + all engines have to be used, but all have to be enabled. The real
114598 + flow of a specific frame depends on the PCD configuration and the
114599 + frame headers and payload.
114600 + Note: the first engine and the first engine after the parser (if
114601 + exists) should be in order, the order is important as it will
114602 + define the flow of the port. However, as for the rest engines
114603 + (the ones that follows), the order is not important anymore as
114604 + it is defined by the PCD graph itself.
114605 +*//***************************************************************************/
114606 +typedef enum ioc_fm_port_pcd_support {
114607 + e_IOC_FM_PORT_PCD_SUPPORT_NONE = 0 /**< BMI to BMI, PCD is not used */
114608 + , e_IOC_FM_PORT_PCD_SUPPORT_PRS_ONLY /**< Use only Parser */
114609 + , e_IOC_FM_PORT_PCD_SUPPORT_PLCR_ONLY /**< Use only Policer */
114610 + , e_IOC_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR /**< Use Parser and Policer */
114611 + , e_IOC_FM_PORT_PCD_SUPPORT_PRS_AND_KG /**< Use Parser and Keygen */
114612 + , e_IOC_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC /**< Use Parser, Keygen and Coarse Classification */
114613 + , e_IOC_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR
114614 + /**< Use all PCD engines */
114615 + , e_IOC_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR /**< Use Parser, Keygen and Policer */
114616 + , e_IOC_FM_PORT_PCD_SUPPORT_PRS_AND_CC /**< Use Parser and Coarse Classification */
114617 + , e_IOC_FM_PORT_PCD_SUPPORT_PRS_AND_CC_AND_PLCR /**< Use Parser and Coarse Classification and Policer */
114618 + , e_IOC_FM_PORT_PCD_SUPPORT_CC_ONLY /**< Use only Coarse Classification */
114619 +#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
114620 + , e_IOC_FM_PORT_PCD_SUPPORT_CC_AND_KG /**< Use Coarse Classification,and Keygen */
114621 + , e_IOC_FM_PORT_PCD_SUPPORT_CC_AND_KG_AND_PLCR /**< Use Coarse Classification, Keygen and Policer */
114622 +#endif /* FM_CAPWAP_SUPPORT */
114623 +} ioc_fm_port_pcd_support;
114624 +
114625 +
114626 +/**************************************************************************//**
114627 + @Collection FM Frame error
114628 +*//***************************************************************************/
114629 +typedef uint32_t ioc_fm_port_frame_err_select_t; /**< typedef for defining Frame Descriptor errors */
114630 +
114631 +/* @} */
114632 +
114633 +
114634 +/**************************************************************************//**
114635 + @Description An enum for defining Dual Tx rate limiting scale.
114636 + (Must match e_FmPortDualRateLimiterScaleDown defined in fm_port_ext.h)
114637 +*//***************************************************************************/
114638 +typedef enum ioc_fm_port_dual_rate_limiter_scale_down {
114639 + e_IOC_FM_PORT_DUAL_RATE_LIMITER_NONE = 0, /**< Use only single rate limiter */
114640 + e_IOC_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_2, /**< Divide high rate limiter by 2 */
114641 + e_IOC_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_4, /**< Divide high rate limiter by 4 */
114642 + e_IOC_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_8 /**< Divide high rate limiter by 8 */
114643 +} ioc_fm_port_dual_rate_limiter_scale_down;
114644 +
114645 +/**************************************************************************//**
114646 + @Description A structure for defining Tx rate limiting
114647 + (Must match struct t_FmPortRateLimit defined in fm_port_ext.h)
114648 +*//***************************************************************************/
114649 +typedef struct ioc_fm_port_rate_limit_t {
114650 + uint16_t max_burst_size; /**< in KBytes for Tx ports, in frames
114651 + for offline parsing ports. (note that
114652 + for early chips burst size is
114653 + rounded up to a multiply of 1000 frames).*/
114654 + uint32_t rate_limit; /**< in Kb/sec for Tx ports, in frame/sec for
114655 + offline parsing ports. Rate limit refers to
114656 + data rate (rather than line rate). */
114657 + ioc_fm_port_dual_rate_limiter_scale_down rate_limit_divider; /**< For offline parsing ports only. Not-valid
114658 + for some earlier chip revisions */
114659 +} ioc_fm_port_rate_limit_t;
114660 +
114661 +
114662 +
114663 +/**************************************************************************//**
114664 + @Group lnx_ioctl_FM_PORT_runtime_control_grp FM Port Runtime Control Unit
114665 +
114666 + @Description FM Port Runtime control unit API functions, definitions and enums.
114667 +
114668 + @{
114669 +*//***************************************************************************/
114670 +
114671 +/**************************************************************************//**
114672 + @Description An enum for defining FM Port counters.
114673 + (Must match enum e_FmPortCounters defined in fm_port_ext.h)
114674 +*//***************************************************************************/
114675 +typedef enum ioc_fm_port_counters {
114676 + e_IOC_FM_PORT_COUNTERS_CYCLE, /**< BMI performance counter */
114677 + e_IOC_FM_PORT_COUNTERS_TASK_UTIL, /**< BMI performance counter */
114678 + e_IOC_FM_PORT_COUNTERS_QUEUE_UTIL, /**< BMI performance counter */
114679 + e_IOC_FM_PORT_COUNTERS_DMA_UTIL, /**< BMI performance counter */
114680 + e_IOC_FM_PORT_COUNTERS_FIFO_UTIL, /**< BMI performance counter */
114681 + e_IOC_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION, /**< BMI Rx only performance counter */
114682 + e_IOC_FM_PORT_COUNTERS_FRAME, /**< BMI statistics counter */
114683 + e_IOC_FM_PORT_COUNTERS_DISCARD_FRAME, /**< BMI statistics counter */
114684 + e_IOC_FM_PORT_COUNTERS_DEALLOC_BUF, /**< BMI deallocate buffer statistics counter */
114685 + e_IOC_FM_PORT_COUNTERS_RX_BAD_FRAME, /**< BMI Rx only statistics counter */
114686 + e_IOC_FM_PORT_COUNTERS_RX_LARGE_FRAME, /**< BMI Rx only statistics counter */
114687 + e_IOC_FM_PORT_COUNTERS_RX_FILTER_FRAME, /**< BMI Rx & OP only statistics counter */
114688 + e_IOC_FM_PORT_COUNTERS_RX_LIST_DMA_ERR, /**< BMI Rx, OP & HC only statistics counter */
114689 + e_IOC_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD, /**< BMI Rx, OP & HC statistics counter */
114690 + e_IOC_FM_PORT_COUNTERS_PREPARE_TO_ENQUEUE_COUNTER, /**< BMI Rx, OP & HC only statistics counter */
114691 + e_IOC_FM_PORT_COUNTERS_WRED_DISCARD, /**< BMI OP & HC only statistics counter */
114692 + e_IOC_FM_PORT_COUNTERS_LENGTH_ERR, /**< BMI non-Rx statistics counter */
114693 + e_IOC_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT, /**< BMI non-Rx statistics counter */
114694 + e_IOC_FM_PORT_COUNTERS_DEQ_TOTAL, /**< QMI total QM dequeues counter */
114695 + e_IOC_FM_PORT_COUNTERS_ENQ_TOTAL, /**< QMI total QM enqueues counter */
114696 + e_IOC_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT, /**< QMI counter */
114697 + e_IOC_FM_PORT_COUNTERS_DEQ_CONFIRM /**< QMI counter */
114698 +} ioc_fm_port_counters;
114699 +
114700 +typedef struct ioc_fm_port_bmi_stats_t {
114701 + uint32_t cnt_cycle;
114702 + uint32_t cnt_task_util;
114703 + uint32_t cnt_queue_util;
114704 + uint32_t cnt_dma_util;
114705 + uint32_t cnt_fifo_util;
114706 + uint32_t cnt_rx_pause_activation;
114707 + uint32_t cnt_frame;
114708 + uint32_t cnt_discard_frame;
114709 + uint32_t cnt_dealloc_buf;
114710 + uint32_t cnt_rx_bad_frame;
114711 + uint32_t cnt_rx_large_frame;
114712 + uint32_t cnt_rx_filter_frame;
114713 + uint32_t cnt_rx_list_dma_err;
114714 + uint32_t cnt_rx_out_of_buffers_discard;
114715 + uint32_t cnt_wred_discard;
114716 + uint32_t cnt_length_err;
114717 + uint32_t cnt_unsupported_format;
114718 +} ioc_fm_port_bmi_stats_t;
114719 +
114720 +/**************************************************************************//**
114721 + @Description Structure for Port id parameters.
114722 + (Description may be inaccurate;
114723 + must match struct t_FmPortCongestionGrps defined in fm_port_ext.h)
114724 +
114725 + Fields commented 'IN' are passed by the port module to be used
114726 + by the FM module.
114727 + Fields commented 'OUT' will be filled by FM before returning to port.
114728 +*//***************************************************************************/
114729 +typedef struct ioc_fm_port_congestion_groups_t {
114730 + uint16_t num_of_congestion_grps_to_consider; /**< The number of required congestion groups
114731 + to define the size of the following array */
114732 + uint8_t congestion_grps_to_consider [FM_PORT_NUM_OF_CONGESTION_GRPS];
114733 + /**< An array of CG indexes;
114734 + Note that the size of the array should be
114735 + 'num_of_congestion_grps_to_consider'. */
114736 +#if DPAA_VERSION >= 11
114737 + bool pfc_priorities_enable[FM_PORT_NUM_OF_CONGESTION_GRPS][FM_MAX_NUM_OF_PFC_PRIORITIES];
114738 + /**< A matrix that represents the map between the CG ids
114739 + defined in 'congestion_grps_to_consider' to the priorities
114740 + mapping array. */
114741 +#endif /* DPAA_VERSION >= 11 */
114742 +} ioc_fm_port_congestion_groups_t;
114743 +
114744 +
114745 +
114746 +/**************************************************************************//**
114747 + @Function FM_PORT_Disable
114748 +
114749 + @Description Gracefully disable an FM port. The port will not start new tasks after all
114750 + tasks associated with the port are terminated.
114751 +
114752 + @Return 0 on success; error code otherwise.
114753 +
114754 + @Cautions This is a blocking routine, it returns after port is
114755 + gracefully stopped, i.e. the port will not except new frames,
114756 + but it will finish all frames or tasks which were already began
114757 +*//***************************************************************************/
114758 +#define FM_PORT_IOC_DISABLE _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(1))
114759 +
114760 +/**************************************************************************//**
114761 + @Function FM_PORT_Enable
114762 +
114763 + @Description A runtime routine provided to allow disable/enable of port.
114764 +
114765 + @Return 0 on success; error code otherwise.
114766 +*//***************************************************************************/
114767 +#define FM_PORT_IOC_ENABLE _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(2))
114768 +
114769 +/**************************************************************************//**
114770 + @Function FM_PORT_SetRateLimit
114771 +
114772 + @Description Calling this routine enables rate limit algorithm.
114773 + By default, this functionality is disabled.
114774 + Note that rate-limit mechanism uses the FM time stamp.
114775 + The selected rate limit specified here would be
114776 + rounded DOWN to the nearest 16M.
114777 +
114778 + May be used for Tx and offline parsing ports only
114779 +
114780 + @Param[in] ioc_fm_port_rate_limit A structure of rate limit parameters
114781 +
114782 + @Return 0 on success; error code otherwise.
114783 +*//***************************************************************************/
114784 +#define FM_PORT_IOC_SET_RATE_LIMIT _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(3), ioc_fm_port_rate_limit_t)
114785 +
114786 +/**************************************************************************//**
114787 + @Function FM_PORT_DeleteRateLimit
114788 +
114789 + @Description Calling this routine disables the previously enabled rate limit.
114790 +
114791 + May be used for Tx and offline parsing ports only
114792 +
114793 + @Return 0 on success; error code otherwise.
114794 +*//***************************************************************************/
114795 +#define FM_PORT_IOC_DELETE_RATE_LIMIT _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(5))
114796 +#define FM_PORT_IOC_REMOVE_RATE_LIMIT FM_PORT_IOC_DELETE_RATE_LIMIT
114797 +
114798 +
114799 +/**************************************************************************//**
114800 + @Function FM_PORT_AddCongestionGrps
114801 +
114802 + @Description This routine effects the corresponding Tx port.
114803 + It should be called in order to enable pause
114804 + frame transmission in case of congestion in one or more
114805 + of the congestion groups relevant to this port.
114806 + Each call to this routine may add one or more congestion
114807 + groups to be considered relevant to this port.
114808 +
114809 + May be used for Rx, or RX+OP ports only (depending on chip)
114810 +
114811 + @Param[in] ioc_fm_port_congestion_groups_t - A pointer to an array of
114812 + congestion group ids to consider.
114813 +
114814 + @Return 0 on success; error code otherwise.
114815 +*//***************************************************************************/
114816 +#define FM_PORT_IOC_ADD_CONGESTION_GRPS _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(34), ioc_fm_port_congestion_groups_t)
114817 +
114818 +/**************************************************************************//**
114819 + @Function FM_PORT_RemoveCongestionGrps
114820 +
114821 + @Description This routine effects the corresponding Tx port. It should be
114822 + called when congestion groups were
114823 + defined for this port and are no longer relevant, or pause
114824 + frames transmitting is not required on their behalf.
114825 + Each call to this routine may remove one or more congestion
114826 + groups to be considered relevant to this port.
114827 +
114828 + May be used for Rx, or RX+OP ports only (depending on chip)
114829 +
114830 + @Param[in] ioc_fm_port_congestion_groups_t - A pointer to an array of
114831 + congestion group ids to consider.
114832 +
114833 + @Return 0 on success; error code otherwise.
114834 +*//***************************************************************************/
114835 +#define FM_PORT_IOC_REMOVE_CONGESTION_GRPS _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(35), ioc_fm_port_congestion_groups_t)
114836 +
114837 +/**************************************************************************//**
114838 + @Function FM_PORT_SetErrorsRoute
114839 +
114840 + @Description Errors selected for this routine will cause a frame with that error
114841 + to be enqueued to error queue.
114842 + Errors not selected for this routine will cause a frame with that error
114843 + to be enqueued to the one of the other port queues.
114844 + By default all errors are defined to be enqueued to error queue.
114845 + Errors that were configured to be discarded (at initialization)
114846 + may not be selected here.
114847 +
114848 + May be used for Rx and offline parsing ports only
114849 +
114850 + @Param[in] ioc_fm_port_frame_err_select_t A list of errors to enqueue to error queue
114851 +
114852 + @Return 0 on success; error code otherwise.
114853 +
114854 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
114855 + (szbs001: How is it possible to have one function that needs to be
114856 + called BEFORE FM_PORT_Init() implemented as an ioctl,
114857 + which will ALWAYS be called AFTER the FM_PORT_Init()
114858 + for that port!?!?!?!???!?!??!?!?)
114859 +*//***************************************************************************/
114860 +#define FM_PORT_IOC_SET_ERRORS_ROUTE _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(4), ioc_fm_port_frame_err_select_t)
114861 +
114862 +
114863 +/**************************************************************************//**
114864 + @Group lnx_ioctl_FM_PORT_pcd_runtime_control_grp FM Port PCD Runtime Control Unit
114865 +
114866 + @Description FM Port PCD Runtime control unit API functions, definitions and enums.
114867 +
114868 + @{
114869 +*//***************************************************************************/
114870 +
114871 +/**************************************************************************//**
114872 + @Description A structure defining the KG scheme after the parser.
114873 + (Must match struct t_FmPcdKgSchemeSelect defined in fm_port_ext.h)
114874 +
114875 + This is relevant only to change scheme selection mode - from
114876 + direct to indirect and vice versa, or when the scheme is selected directly,
114877 + to select the scheme id.
114878 +
114879 +*//***************************************************************************/
114880 +typedef struct ioc_fm_pcd_kg_scheme_select_t {
114881 + bool direct; /**< TRUE to use 'scheme_id' directly, FALSE to use LCV.*/
114882 + void *scheme_id; /**< Relevant for 'direct'=TRUE only.
114883 + 'scheme_id' selects the scheme after parser. */
114884 +} ioc_fm_pcd_kg_scheme_select_t;
114885 +
114886 +/**************************************************************************//**
114887 + @Description Scheme IDs structure
114888 + (Must match struct t_FmPcdPortSchemesParams defined in fm_port_ext.h)
114889 +*//***************************************************************************/
114890 +typedef struct ioc_fm_pcd_port_schemes_params_t {
114891 + uint8_t num_of_schemes; /**< Number of schemes for port to be bound to. */
114892 + void *scheme_ids[FM_PCD_KG_NUM_OF_SCHEMES]; /**< Array of 'num_of_schemes' schemes for the
114893 + port to be bound to */
114894 +} ioc_fm_pcd_port_schemes_params_t;
114895 +
114896 +/**************************************************************************//**
114897 + @Description A union for defining port protocol parameters for parser
114898 + (Must match union u_FmPcdHdrPrsOpts defined in fm_port_ext.h)
114899 +*//***************************************************************************/
114900 +typedef union ioc_fm_pcd_hdr_prs_opts_u {
114901 + /* MPLS */
114902 + struct {
114903 + bool label_interpretation_enable;/**< When this bit is set, the last MPLS label will be
114904 + interpreted as described in HW spec table. When the bit
114905 + is cleared, the parser will advance to MPLS next parse */
114906 + ioc_net_header_type next_parse; /**< must be equal or higher than IPv4 */
114907 + } mpls_prs_options;
114908 +
114909 + /* VLAN */
114910 + struct {
114911 + uint16_t tag_protocol_id1; /**< User defined Tag Protocol Identifier, to be recognized
114912 + on VLAN TAG on top of 0x8100 and 0x88A8 */
114913 + uint16_t tag_protocol_id2; /**< User defined Tag Protocol Identifier, to be recognized
114914 + on VLAN TAG on top of 0x8100 and 0x88A8 */
114915 + } vlan_prs_options;
114916 +
114917 + /* PPP */
114918 + struct{
114919 + bool enable_mtu_check; /**< Check validity of MTU according to RFC2516 */
114920 + } pppoe_prs_options;
114921 +
114922 + /* IPV6 */
114923 + struct {
114924 + bool routing_hdr_disable; /**< Disable routing header */
114925 + } ipv6_prs_options;
114926 +
114927 + /* UDP */
114928 + struct {
114929 + bool pad_ignore_checksum; /**< TRUE to ignore pad in checksum */
114930 + } udp_prs_options;
114931 +
114932 + /* TCP */
114933 + struct {
114934 + bool pad_ignore_checksum; /**< TRUE to ignore pad in checksum */
114935 + } tcp_prs_options;
114936 +} ioc_fm_pcd_hdr_prs_opts_u;
114937 +
114938 +/**************************************************************************//**
114939 + @Description A structure for defining each header for the parser
114940 + (must match struct t_FmPcdPrsAdditionalHdrParams defined in fm_port_ext.h)
114941 +*//***************************************************************************/
114942 +typedef struct ioc_fm_pcd_prs_additional_hdr_params_t {
114943 + ioc_net_header_type hdr; /**< Selected header */
114944 + bool err_disable; /**< TRUE to disable error indication */
114945 + bool soft_prs_enable; /**< Enable jump to SW parser when this
114946 + header is recognized by the HW parser. */
114947 + uint8_t index_per_hdr; /**< Normally 0, if more than one sw parser
114948 + attachments exists for the same header,
114949 + (in the main sw parser code) use this
114950 + index to distinguish between them. */
114951 + bool use_prs_opts; /**< TRUE to use parser options. */
114952 + ioc_fm_pcd_hdr_prs_opts_u prs_opts; /**< A unuion according to header type,
114953 + defining the parser options selected.*/
114954 +} ioc_fm_pcd_prs_additional_hdr_params_t;
114955 +
114956 +/**************************************************************************//**
114957 + @Description A structure for defining port PCD parameters
114958 + (Must match t_FmPortPcdPrsParams defined in fm_port_ext.h)
114959 +*//***************************************************************************/
114960 +typedef struct ioc_fm_port_pcd_prs_params_t {
114961 + uint8_t prs_res_priv_info; /**< The private info provides a method of inserting
114962 + port information into the parser result. This information
114963 + may be extracted by KeyGen and be used for frames
114964 + distribution when a per-port distinction is required,
114965 + it may also be used as a port logical id for analyzing
114966 + incoming frames. */
114967 + uint8_t parsing_offset; /**< Number of bytes from begining of packet to start parsing */
114968 + ioc_net_header_type first_prs_hdr; /**< The type of the first header axpected at 'parsing_offset' */
114969 + bool include_in_prs_statistics; /**< TRUE to include this port in the parser statistics */
114970 + uint8_t num_of_hdrs_with_additional_params;
114971 + /**< Normally 0, some headers may get special parameters */
114972 + ioc_fm_pcd_prs_additional_hdr_params_t additional_params[IOC_FM_PCD_PRS_NUM_OF_HDRS];
114973 + /**< 'num_of_hdrs_with_additional_params' structures
114974 + additional parameters for each header that requires them */
114975 + bool set_vlan_tpid1; /**< TRUE to configure user selection of Ethertype to
114976 + indicate a VLAN tag (in addition to the TPID values
114977 + 0x8100 and 0x88A8). */
114978 + uint16_t vlan_tpid1; /**< extra tag to use if set_vlan_tpid1=TRUE. */
114979 + bool set_vlan_tpid2; /**< TRUE to configure user selection of Ethertype to
114980 + indicate a VLAN tag (in addition to the TPID values
114981 + 0x8100 and 0x88A8). */
114982 + uint16_t vlan_tpid2; /**< extra tag to use if set_vlan_tpid1=TRUE. */
114983 +} ioc_fm_port_pcd_prs_params_t;
114984 +
114985 +/**************************************************************************//**
114986 + @Description A structure for defining coarse alassification parameters
114987 + (Must match t_FmPortPcdCcParams defined in fm_port_ext.h)
114988 +*//***************************************************************************/
114989 +typedef struct ioc_fm_port_pcd_cc_params_t {
114990 + void *cc_tree_id; /**< CC tree id */
114991 +} ioc_fm_port_pcd_cc_params_t;
114992 +
114993 +/**************************************************************************//**
114994 + @Description A structure for defining keygen parameters
114995 + (Must match t_FmPortPcdKgParams defined in fm_port_ext.h)
114996 +*//***************************************************************************/
114997 +typedef struct ioc_fm_port_pcd_kg_params_t {
114998 + uint8_t num_of_schemes; /**< Number of schemes for port to be bound to. */
114999 + void *scheme_ids[FM_PCD_KG_NUM_OF_SCHEMES];
115000 + /**< Array of 'num_of_schemes' schemes for the
115001 + port to be bound to */
115002 + bool direct_scheme; /**< TRUE for going from parser to a specific scheme,
115003 + regardless of parser result */
115004 + void *direct_scheme_id; /**< Scheme id, as returned by FM_PCD_KgSetScheme;
115005 + relevant only if direct=TRUE. */
115006 +} ioc_fm_port_pcd_kg_params_t;
115007 +
115008 +/**************************************************************************//**
115009 + @Description A structure for defining policer parameters
115010 + (Must match t_FmPortPcdPlcrParams defined in fm_port_ext.h)
115011 +*//***************************************************************************/
115012 +typedef struct ioc_fm_port_pcd_plcr_params_t {
115013 + void *plcr_profile_id; /**< Selected profile handle;
115014 + relevant in one of the following cases:
115015 + e_IOC_FM_PORT_PCD_SUPPORT_PLCR_ONLY or
115016 + e_IOC_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR were selected,
115017 + or if any flow uses a KG scheme where policer
115018 + profile is not generated (bypass_plcr_profile_generation selected) */
115019 +} ioc_fm_port_pcd_plcr_params_t;
115020 +
115021 +/**************************************************************************//**
115022 + @Description A structure for defining port PCD parameters
115023 + (Must match struct t_FmPortPcdParams defined in fm_port_ext.h)
115024 +*//***************************************************************************/
115025 +typedef struct ioc_fm_port_pcd_params_t {
115026 + ioc_fm_port_pcd_support pcd_support; /**< Relevant for Rx and offline ports only.
115027 + Describes the active PCD engines for this port. */
115028 + void *net_env_id; /**< HL Unused in PLCR only mode */
115029 + ioc_fm_port_pcd_prs_params_t *p_prs_params; /**< Parser parameters for this port */
115030 + ioc_fm_port_pcd_cc_params_t *p_cc_params; /**< Coarse classification parameters for this port */
115031 + ioc_fm_port_pcd_kg_params_t *p_kg_params; /**< Keygen parameters for this port */
115032 + ioc_fm_port_pcd_plcr_params_t *p_plcr_params; /**< Policer parameters for this port */
115033 + void *p_ip_reassembly_manip;/**< IP Reassembly manipulation */
115034 +#if (DPAA_VERSION >= 11)
115035 + void *p_capwap_reassembly_manip;/**< CAPWAP Reassembly manipulation */
115036 +#endif /* (DPAA_VERSION >= 11) */
115037 +} ioc_fm_port_pcd_params_t;
115038 +
115039 +/**************************************************************************//**
115040 + @Description A structure for defining the Parser starting point
115041 + (Must match struct t_FmPcdPrsStart defined in fm_port_ext.h)
115042 +*//***************************************************************************/
115043 +typedef struct ioc_fm_pcd_prs_start_t {
115044 + uint8_t parsing_offset; /**< Number of bytes from begining of packet to
115045 + start parsing */
115046 + ioc_net_header_type first_prs_hdr; /**< The type of the first header axpected at
115047 + 'parsing_offset' */
115048 +} ioc_fm_pcd_prs_start_t;
115049 +
115050 +
115051 +/**************************************************************************//**
115052 + @Description FQID parameters structure
115053 +*//***************************************************************************/
115054 +typedef struct ioc_fm_port_pcd_fqids_params_t {
115055 + uint32_t num_fqids; /**< Number of fqids to be allocated for the port */
115056 + uint8_t alignment; /**< Alignment required for this port */
115057 + uint32_t base_fqid; /**< output parameter - the base fqid */
115058 +} ioc_fm_port_pcd_fqids_params_t;
115059 +
115060 +
115061 +/**************************************************************************//**
115062 + @Function FM_PORT_IOC_ALLOC_PCD_FQIDS
115063 +
115064 + @Description Allocates FQID's
115065 +
115066 + May be used for Rx and offline parsing ports only
115067 +
115068 + @Param[in,out] ioc_fm_port_pcd_fqids_params_t Parameters for allocating FQID's
115069 +
115070 + @Return 0 on success; error code otherwise.
115071 +*//***************************************************************************/
115072 +#define FM_PORT_IOC_ALLOC_PCD_FQIDS _IOWR(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(19), ioc_fm_port_pcd_fqids_params_t)
115073 +
115074 +/**************************************************************************//**
115075 + @Function FM_PORT_IOC_FREE_PCD_FQIDS
115076 +
115077 + @Description Frees previously-allocated FQIDs
115078 +
115079 + May be used for Rx and offline parsing ports only
115080 +
115081 + @Param[in] uint32_t Base FQID of previously allocated range.
115082 +
115083 + @Return 0 on success; error code otherwise.
115084 +*//***************************************************************************/
115085 +#define FM_PORT_IOC_FREE_PCD_FQIDS _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(19), uint32_t)
115086 +
115087 +
115088 +/**************************************************************************//**
115089 + @Function FM_PORT_SetPCD
115090 +
115091 + @Description Calling this routine defines the port's PCD configuration.
115092 + It changes it from its default configuration which is PCD
115093 + disabled (BMI to BMI) and configures it according to the passed
115094 + parameters.
115095 +
115096 + May be used for Rx and offline parsing ports only
115097 +
115098 + @Param[in] ioc_fm_port_pcd_params_t A Structure of parameters defining the port's PCD
115099 + configuration.
115100 +
115101 + @Return 0 on success; error code otherwise.
115102 +*//***************************************************************************/
115103 +#if defined(CONFIG_COMPAT)
115104 +#define FM_PORT_IOC_SET_PCD_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(20), ioc_compat_fm_port_pcd_params_t)
115105 +#endif
115106 +#define FM_PORT_IOC_SET_PCD _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(20), ioc_fm_port_pcd_params_t)
115107 +
115108 +/**************************************************************************//**
115109 + @Function FM_PORT_DeletePCD
115110 +
115111 + @Description Calling this routine releases the port's PCD configuration.
115112 + The port returns to its default configuration which is PCD
115113 + disabled (BMI to BMI) and all PCD configuration is removed.
115114 +
115115 + May be used for Rx and offline parsing ports which are
115116 + in PCD mode only
115117 +
115118 + @Return 0 on success; error code otherwise.
115119 +*//***************************************************************************/
115120 +#define FM_PORT_IOC_DELETE_PCD _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(21))
115121 +
115122 +/**************************************************************************//**
115123 + @Function FM_PORT_AttachPCD
115124 +
115125 + @Description This routine may be called after FM_PORT_DetachPCD was called,
115126 + to return to the originally configured PCD support flow.
115127 + The couple of routines are used to allow PCD configuration changes
115128 + that demand that PCD will not be used while changes take place.
115129 +
115130 + May be used for Rx and offline parsing ports which are
115131 + in PCD mode only
115132 +
115133 + @Return 0 on success; error code otherwise.
115134 +*//***************************************************************************/
115135 +#define FM_PORT_IOC_ATTACH_PCD _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(23))
115136 +
115137 +/**************************************************************************//**
115138 + @Function FM_PORT_DetachPCD
115139 +
115140 + @Description Calling this routine detaches the port from its PCD functionality.
115141 + The port returns to its default flow which is BMI to BMI.
115142 +
115143 + May be used for Rx and offline parsing ports which are
115144 + in PCD mode only
115145 +
115146 + @Return 0 on success; error code otherwise.
115147 +*//***************************************************************************/
115148 +#define FM_PORT_IOC_DETACH_PCD _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(22))
115149 +
115150 +/**************************************************************************//**
115151 + @Function FM_PORT_PcdPlcrAllocProfiles
115152 +
115153 + @Description This routine may be called only for ports that use the Policer in
115154 + order to allocate private policer profiles.
115155 +
115156 + @Param[in] uint16_t The number of required policer profiles
115157 +
115158 + @Return 0 on success; error code otherwise.
115159 +
115160 + @Cautions Allowed before FM_PORT_SetPCD() only.
115161 +*//***************************************************************************/
115162 +#define FM_PORT_IOC_PCD_PLCR_ALLOC_PROFILES _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(24), uint16_t)
115163 +
115164 +/**************************************************************************//**
115165 + @Function FM_PORT_PcdPlcrFreeProfiles
115166 +
115167 + @Description This routine should be called for freeing private policer profiles.
115168 +
115169 + @Return 0 on success; error code otherwise.
115170 +
115171 + @Cautions Allowed before FM_PORT_SetPCD() only.
115172 +*//***************************************************************************/
115173 +#define FM_PORT_IOC_PCD_PLCR_FREE_PROFILES _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(25))
115174 +
115175 +/**************************************************************************//**
115176 + @Function FM_PORT_PcdKgModifyInitialScheme
115177 +
115178 + @Description This routine may be called only for ports that use the keygen in
115179 + order to change the initial scheme frame should be routed to.
115180 + The change may be of a scheme id (in case of direct mode),
115181 + from direct to indirect, or from indirect to direct - specifying the scheme id.
115182 +
115183 + @Param[in] ioc_fm_pcd_kg_scheme_select_t A structure of parameters for defining whether
115184 + a scheme is direct/indirect, and if direct - scheme id.
115185 +
115186 + @Return 0 on success; error code otherwise.
115187 +*//***************************************************************************/
115188 +#if defined(CONFIG_COMPAT)
115189 +#define FM_PORT_IOC_PCD_KG_MODIFY_INITIAL_SCHEME_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(26), ioc_compat_fm_pcd_kg_scheme_select_t)
115190 +#endif
115191 +#define FM_PORT_IOC_PCD_KG_MODIFY_INITIAL_SCHEME _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(26), ioc_fm_pcd_kg_scheme_select_t)
115192 +
115193 +/**************************************************************************//**
115194 + @Function FM_PORT_PcdPlcrModifyInitialProfile
115195 +
115196 + @Description This routine may be called for ports with flows
115197 + e_IOC_FM_PCD_SUPPORT_PLCR_ONLY or e_IOC_FM_PCD_SUPPORT_PRS_AND_PLCR only,
115198 + to change the initial Policer profile frame should be routed to.
115199 + The change may be of a profile and/or absolute/direct mode selection.
115200 +
115201 + @Param[in] ioc_fm_obj_t Policer profile Id as returned from FM_PCD_PlcrSetProfile.
115202 +
115203 + @Return 0 on success; error code otherwise.
115204 +*//***************************************************************************/
115205 +#if defined(CONFIG_COMPAT)
115206 +#define FM_PORT_IOC_PCD_PLCR_MODIFY_INITIAL_PROFILE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(27), ioc_compat_fm_obj_t)
115207 +#endif
115208 +#define FM_PORT_IOC_PCD_PLCR_MODIFY_INITIAL_PROFILE _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(27), ioc_fm_obj_t)
115209 +
115210 +/**************************************************************************//**
115211 + @Function FM_PORT_PcdCcModifyTree
115212 +
115213 + @Description This routine may be called to change this port connection to
115214 + a pre-initializes coarse classification Tree.
115215 +
115216 + @Param[in] ioc_fm_obj_t Id of new coarse classification tree selected for this port.
115217 +
115218 + @Return 0 on success; error code otherwise.
115219 +
115220 + @Cautions Allowed only following FM_PORT_SetPCD() and FM_PORT_DetachPCD()
115221 +*//***************************************************************************/
115222 +#if defined(CONFIG_COMPAT)
115223 +#define FM_PORT_IOC_PCD_CC_MODIFY_TREE_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(28), ioc_compat_fm_obj_t)
115224 +#endif
115225 +#define FM_PORT_IOC_PCD_CC_MODIFY_TREE _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(28), ioc_fm_obj_t)
115226 +
115227 +/**************************************************************************//**
115228 + @Function FM_PORT_PcdKgBindSchemes
115229 +
115230 + @Description These routines may be called for modifying the binding of ports
115231 + to schemes. The scheme itself is not added,
115232 + just this specific port starts using it.
115233 +
115234 + @Param[in] ioc_fm_pcd_port_schemes_params_t Schemes parameters structre
115235 +
115236 + @Return 0 on success; error code otherwise.
115237 +
115238 + @Cautions Allowed only following FM_PORT_SetPCD().
115239 +*//***************************************************************************/
115240 +#if defined(CONFIG_COMPAT)
115241 +#define FM_PORT_IOC_PCD_KG_BIND_SCHEMES_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(30), ioc_compat_fm_pcd_port_schemes_params_t)
115242 +#endif
115243 +#define FM_PORT_IOC_PCD_KG_BIND_SCHEMES _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(30), ioc_fm_pcd_port_schemes_params_t)
115244 +
115245 +/**************************************************************************//**
115246 + @Function FM_PORT_PcdKgUnbindSchemes
115247 +
115248 + @Description These routines may be called for modifying the binding of ports
115249 + to schemes. The scheme itself is not removed or invalidated,
115250 + just this specific port stops using it.
115251 +
115252 + @Param[in] ioc_fm_pcd_port_schemes_params_t Schemes parameters structre
115253 +
115254 + @Return 0 on success; error code otherwise.
115255 +
115256 + @Cautions Allowed only following FM_PORT_SetPCD().
115257 +*//***************************************************************************/
115258 +#if defined(CONFIG_COMPAT)
115259 +#define FM_PORT_IOC_PCD_KG_UNBIND_SCHEMES_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(31), ioc_compat_fm_pcd_port_schemes_params_t)
115260 +#endif
115261 +#define FM_PORT_IOC_PCD_KG_UNBIND_SCHEMES _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(31), ioc_fm_pcd_port_schemes_params_t)
115262 +
115263 +typedef struct ioc_fm_port_mac_addr_params_t {
115264 + uint8_t addr[ENET_NUM_OCTETS_PER_ADDRESS];
115265 +} ioc_fm_port_mac_addr_params_t;
115266 +
115267 +/**************************************************************************//**
115268 + @Function FM_MAC_AddHashMacAddr
115269 +
115270 + @Description Add an Address to the hash table. This is for filter purpose only.
115271 +
115272 + @Param[in] ioc_fm_port_mac_addr_params_t - Ethernet Mac address
115273 +
115274 + @Return E_OK on success; Error code otherwise.
115275 +
115276 + @Cautions Allowed only following FM_MAC_Init(). It is a filter only address.
115277 + @Cautions Some address need to be filtered out in upper FM blocks.
115278 +*//***************************************************************************/
115279 +#define FM_PORT_IOC_ADD_RX_HASH_MAC_ADDR _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(36), ioc_fm_port_mac_addr_params_t)
115280 +
115281 +/**************************************************************************//**
115282 + @Function FM_MAC_RemoveHashMacAddr
115283 +
115284 + @Description Delete an Address to the hash table. This is for filter purpose only.
115285 +
115286 + @Param[in] ioc_fm_port_mac_addr_params_t - Ethernet Mac address
115287 +
115288 + @Return E_OK on success; Error code otherwise.
115289 +
115290 + @Cautions Allowed only following FM_MAC_Init().
115291 +*//***************************************************************************/
115292 +#define FM_PORT_IOC_REMOVE_RX_HASH_MAC_ADDR _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(37), ioc_fm_port_mac_addr_params_t)
115293 +
115294 +typedef struct ioc_fm_port_tx_pause_frames_params_t {
115295 + uint8_t priority;
115296 + uint16_t pause_time;
115297 + uint16_t thresh_time;
115298 +} ioc_fm_port_tx_pause_frames_params_t;
115299 +
115300 +/**************************************************************************//**
115301 + @Function FM_MAC_SetTxPauseFrames
115302 +
115303 + @Description Enable/Disable transmission of Pause-Frames.
115304 + The routine changes the default configuration:
115305 + pause-time - [0xf000]
115306 + threshold-time - [0]
115307 +
115308 + @Param[in] ioc_fm_port_tx_pause_frames_params_t A structure holding the required parameters.
115309 +
115310 + @Return E_OK on success; Error code otherwise.
115311 +
115312 + @Cautions Allowed only following FM_MAC_Init().
115313 + PFC is supported only on new mEMAC; i.e. in MACs that don't have
115314 + PFC support (10G-MAC and dTSEC), user should use 'FM_MAC_NO_PFC'
115315 + in the 'priority' field.
115316 +*//***************************************************************************/
115317 +#define FM_PORT_IOC_SET_TX_PAUSE_FRAMES _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(40), ioc_fm_port_tx_pause_frames_params_t)
115318 +
115319 +typedef struct ioc_fm_port_mac_statistics_t {
115320 + /* RMON */
115321 + uint64_t e_stat_pkts_64; /**< r-10G tr-DT 64 byte frame counter */
115322 + uint64_t e_stat_pkts_65_to_127; /**< r-10G 65 to 127 byte frame counter */
115323 + uint64_t e_stat_pkts_128_to_255; /**< r-10G 128 to 255 byte frame counter */
115324 + uint64_t e_stat_pkts_256_to_511; /**< r-10G 256 to 511 byte frame counter */
115325 + uint64_t e_stat_pkts_512_to_1023; /**< r-10G 512 to 1023 byte frame counter */
115326 + uint64_t e_stat_pkts_1024_to_1518; /**< r-10G 1024 to 1518 byte frame counter */
115327 + uint64_t e_stat_pkts_1519_to_1522; /**< r-10G 1519 to 1522 byte good frame count */
115328 + /* */
115329 + uint64_t e_stat_fragments; /**< Total number of packets that were less than 64 octets long with a wrong CRC.*/
115330 + uint64_t e_stat_jabbers; /**< Total number of packets longer than valid maximum length octets */
115331 + uint64_t e_stat_drop_events; /**< number of dropped packets due to internal errors of the MAC Client (during recieve). */
115332 + uint64_t e_stat_CRC_align_errors; /**< Incremented when frames of correct length but with CRC error are received.*/
115333 + uint64_t e_stat_undersize_pkts; /**< Incremented for frames under 64 bytes with a valid FCS and otherwise well formed;
115334 + This count does not include range length errors */
115335 + uint64_t e_stat_oversize_pkts; /**< Incremented for frames which exceed 1518 (non VLAN) or 1522 (VLAN) and contains
115336 + a valid FCS and otherwise well formed */
115337 + /* Pause */
115338 + uint64_t te_stat_pause; /**< Pause MAC Control received */
115339 + uint64_t re_stat_pause; /**< Pause MAC Control sent */
115340 + /* MIB II */
115341 + uint64_t if_in_octets; /**< Total number of byte received. */
115342 + uint64_t if_in_pkts; /**< Total number of packets received.*/
115343 + uint64_t if_in_ucast_pkts; /**< Total number of unicast frame received;
115344 + NOTE: this counter is not supported on dTSEC MAC */
115345 + uint64_t if_in_mcast_pkts; /**< Total number of multicast frame received*/
115346 + uint64_t if_in_bcast_pkts; /**< Total number of broadcast frame received */
115347 + uint64_t if_in_discards; /**< Frames received, but discarded due to problems within the MAC RX. */
115348 + uint64_t if_in_errors; /**< Number of frames received with error:
115349 + - FIFO Overflow Error
115350 + - CRC Error
115351 + - Frame Too Long Error
115352 + - Alignment Error
115353 + - The dedicated Error Code (0xfe, not a code error) was received */
115354 + uint64_t if_out_octets; /**< Total number of byte sent. */
115355 + uint64_t if_out_pkts; /**< Total number of packets sent .*/
115356 + uint64_t if_out_ucast_pkts; /**< Total number of unicast frame sent;
115357 + NOTE: this counter is not supported on dTSEC MAC */
115358 + uint64_t if_out_mcast_pkts; /**< Total number of multicast frame sent */
115359 + uint64_t if_out_bcast_pkts; /**< Total number of multicast frame sent */
115360 + uint64_t if_out_discards; /**< Frames received, but discarded due to problems within the MAC TX N/A!.*/
115361 + uint64_t if_out_errors; /**< Number of frames transmitted with error:
115362 + - FIFO Overflow Error
115363 + - FIFO Underflow Error
115364 + - Other */
115365 +} ioc_fm_port_mac_statistics_t;
115366 +
115367 +/**************************************************************************//**
115368 + @Function FM_MAC_GetStatistics
115369 +
115370 + @Description get all MAC statistics counters
115371 +
115372 + @Param[out] ioc_fm_port_mac_statistics_t A structure holding the statistics
115373 +
115374 + @Return E_OK on success; Error code otherwise.
115375 +
115376 + @Cautions Allowed only following FM_Init().
115377 +*//***************************************************************************/
115378 +#define FM_PORT_IOC_GET_MAC_STATISTICS _IOR(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(41), ioc_fm_port_mac_statistics_t)
115379 +
115380 +/**************************************************************************//**
115381 + @Function FM_PORT_ConfigBufferPrefixContent
115382 +
115383 + @Description Defines the structure, size and content of the application buffer.
115384 + The prefix will
115385 + In Tx ports, if 'passPrsResult', the application
115386 + should set a value to their offsets in the prefix of
115387 + the FM will save the first 'privDataSize', than,
115388 + depending on 'passPrsResult' and 'passTimeStamp', copy parse result
115389 + and timeStamp, and the packet itself (in this order), to the
115390 + application buffer, and to offset.
115391 + Calling this routine changes the buffer margins definitions
115392 + in the internal driver data base from its default
115393 + configuration: Data size: [DEFAULT_FM_SP_bufferPrefixContent_privDataSize]
115394 + Pass Parser result: [DEFAULT_FM_SP_bufferPrefixContent_passPrsResult].
115395 + Pass timestamp: [DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp].
115396 +
115397 + May be used for all ports
115398 +
115399 + @Param[in] ioc_fm_buffer_prefix_content_t A structure holding the required parameters.
115400 +
115401 + @Return E_OK on success; Error code otherwise.
115402 +
115403 + @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
115404 +*//***************************************************************************/
115405 +#define FM_PORT_IOC_CONFIG_BUFFER_PREFIX_CONTENT _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(39), ioc_fm_buffer_prefix_content_t)
115406 +
115407 +#if (DPAA_VERSION >= 11)
115408 +typedef struct ioc_fm_port_vsp_alloc_params_t {
115409 + uint8_t num_of_profiles; /**< Number of Virtual Storage Profiles */
115410 + uint8_t dflt_relative_id; /**< The default Virtual-Storage-Profile-id dedicated to Rx/OP port
115411 + The same default Virtual-Storage-Profile-id will be for coupled Tx port
115412 + if relevant function called for Rx port */
115413 + void *p_fm_tx_port; /**< Handle to coupled Tx Port; not relevant for OP port. */
115414 +}ioc_fm_port_vsp_alloc_params_t;
115415 +
115416 +/**************************************************************************//**
115417 + @Function FM_PORT_VSPAlloc
115418 +
115419 + @Description This routine allocated VSPs per port and forces the port to work
115420 + in VSP mode. Note that the port is initialized by default with the
115421 + physical-storage-profile only.
115422 +
115423 + @Param[in] h_FmPort A handle to a FM Port module.
115424 + @Param[in] p_Params A structure of parameters for allocation VSP's per port
115425 +
115426 + @Return E_OK on success; Error code otherwise.
115427 +
115428 + @Cautions Allowed only following FM_PORT_Init(), and before FM_PORT_SetPCD()
115429 + and also before FM_PORT_Enable() (i.e. the port should be disabled).
115430 +*//***************************************************************************/
115431 +#if defined(CONFIG_COMPAT)
115432 +#define FM_PORT_IOC_VSP_ALLOC_COMPAT _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(38), ioc_compat_fm_port_vsp_alloc_params_t)
115433 +#endif
115434 +#define FM_PORT_IOC_VSP_ALLOC _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(38), ioc_fm_port_vsp_alloc_params_t)
115435 +#endif /* (DPAA_VERSION >= 11) */
115436 +
115437 +/**************************************************************************//**
115438 + @Function FM_PORT_GetBmiCounters
115439 +
115440 + @Description Read port's BMI stat counters and place them into
115441 + a designated structure of counters.
115442 +
115443 + @Param[in] h_FmPort A handle to a FM Port module.
115444 + @Param[out] p_BmiStats counters structure
115445 +
115446 + @Return E_OK on success; Error code otherwise.
115447 +
115448 + @Cautions Allowed only following FM_PORT_Init().
115449 +*//***************************************************************************/
115450 +
115451 +#define FM_PORT_IOC_GET_BMI_COUNTERS _IOR(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(42), ioc_fm_port_bmi_stats_t)
115452 +
115453 +
115454 +/** @} */ /* end of lnx_ioctl_FM_PORT_pcd_runtime_control_grp group */
115455 +/** @} */ /* end of lnx_ioctl_FM_PORT_runtime_control_grp group */
115456 +
115457 +/** @} */ /* end of lnx_ioctl_FM_PORT_grp group */
115458 +/** @} */ /* end of lnx_ioctl_FM_grp group */
115459 +#endif /* __FM_PORT_IOCTLS_H */
115460 --- /dev/null
115461 +++ b/include/uapi/linux/fmd/Peripherals/fm_test_ioctls.h
115462 @@ -0,0 +1,208 @@
115463 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc.
115464 + * All rights reserved.
115465 + *
115466 + * Redistribution and use in source and binary forms, with or without
115467 + * modification, are permitted provided that the following conditions are met:
115468 + * * Redistributions of source code must retain the above copyright
115469 + * notice, this list of conditions and the following disclaimer.
115470 + * * Redistributions in binary form must reproduce the above copyright
115471 + * notice, this list of conditions and the following disclaimer in the
115472 + * documentation and/or other materials provided with the distribution.
115473 + * * Neither the name of Freescale Semiconductor nor the
115474 + * names of its contributors may be used to endorse or promote products
115475 + * derived from this software without specific prior written permission.
115476 + *
115477 + *
115478 + * ALTERNATIVELY, this software may be distributed under the terms of the
115479 + * GNU General Public License ("GPL") as published by the Free Software
115480 + * Foundation, either version 2 of that License or (at your option) any
115481 + * later version.
115482 + *
115483 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
115484 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
115485 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
115486 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
115487 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
115488 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
115489 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
115490 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
115491 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
115492 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
115493 + */
115494 +
115495 +/**************************************************************************//**
115496 + @File fm_test_ioctls.h
115497 +
115498 + @Description FM Char device ioctls
115499 +*//***************************************************************************/
115500 +#ifndef __FM_TEST_IOCTLS_H
115501 +#define __FM_TEST_IOCTLS_H
115502 +
115503 +#include "ioctls.h"
115504 +
115505 +
115506 +/**************************************************************************//**
115507 + @Group lnx_ioctl_FMT_grp Frame Manager Test Linux IOCTL API
115508 +
115509 + @Description FM-Test Linux ioctls definitions and enums
115510 +
115511 + @{
115512 +*//***************************************************************************/
115513 +
115514 +#define IOC_FMT_MAX_NUM_OF_PORTS 26
115515 +
115516 +/**************************************************************************//**
115517 + @Collection TEST Parameters
115518 +*//***************************************************************************/
115519 +/**************************************************************************//**
115520 + @Description: Name of the FM-Test chardev
115521 +*//***************************************************************************/
115522 +#define DEV_FM_TEST_NAME "fm-test-port"
115523 +
115524 +#define DEV_FM_TEST_PORTS_MINOR_BASE 0
115525 +#define DEV_FM_TEST_MAX_MINORS (DEV_FM_TEST_PORTS_MINOR_BASE + IOC_FMT_MAX_NUM_OF_PORTS)
115526 +
115527 +#define FMT_PORT_IOC_NUM(n) n
115528 +/* @} */
115529 +
115530 +/**************************************************************************//**
115531 + @Group lnx_ioctl_FMT_lib_grp FM-Test library
115532 +
115533 + @Description TODO
115534 +
115535 + @{
115536 +*//***************************************************************************/
115537 +
115538 +/**************************************************************************//**
115539 + @Description TODO
115540 +*//***************************************************************************/
115541 +typedef uint8_t ioc_fmt_xxx_t;
115542 +
115543 +#define FM_PRS_MAX 32
115544 +#define FM_TIME_STAMP_MAX 8
115545 +
115546 +/**************************************************************************//**
115547 + @Description FM Port buffer content description
115548 +*//***************************************************************************/
115549 +typedef struct ioc_fmt_buff_context_t {
115550 + void *p_user_priv;
115551 + uint8_t fm_prs_res[FM_PRS_MAX];
115552 + uint8_t fm_time_stamp[FM_TIME_STAMP_MAX];
115553 +} ioc_fmt_buff_context_t;
115554 +
115555 +#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
115556 +typedef struct ioc_fmt_compat_buff_context_t {
115557 + compat_uptr_t p_user_priv;
115558 + uint8_t fm_prs_res[FM_PRS_MAX];
115559 + uint8_t fm_time_stamp[FM_TIME_STAMP_MAX];
115560 +} ioc_fmt_compat_buff_context_t;
115561 +#endif
115562 +
115563 +/**************************************************************************//**
115564 + @Description Buffer descriptor
115565 +*//***************************************************************************/
115566 +typedef struct ioc_fmt_buff_desc_t {
115567 + uint32_t qid;
115568 + void *p_data;
115569 + uint32_t size;
115570 + uint32_t status;
115571 + ioc_fmt_buff_context_t buff_context;
115572 +} ioc_fmt_buff_desc_t;
115573 +
115574 +#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
115575 +typedef struct ioc_fmt_compat_buff_desc_t {
115576 + uint32_t qid;
115577 + compat_uptr_t p_data;
115578 + uint32_t size;
115579 + uint32_t status;
115580 + ioc_fmt_compat_buff_context_t buff_context;
115581 +} ioc_fmt_compat_buff_desc_t;
115582 +#endif
115583 +
115584 +/**************************************************************************//**
115585 + @Group lnx_ioctl_FMT_runtime_control_grp FM-Test Runtime Control Unit
115586 +
115587 + @Description TODO
115588 + @{
115589 +*//***************************************************************************/
115590 +
115591 +/** @} */ /* end of lnx_ioctl_FMT_runtime_control_grp group */
115592 +
115593 +
115594 +/**************************************************************************//**
115595 + @Group lnx_ioctl_FMTP_lib_grp FM-Port-Test library
115596 +
115597 + @Description TODO
115598 +
115599 + @{
115600 +*//***************************************************************************/
115601 +
115602 +/**************************************************************************//**
115603 + @Description FM-Test FM port type
115604 +*//***************************************************************************/
115605 +typedef enum ioc_fmt_port_type {
115606 + e_IOC_FMT_PORT_T_RXTX, /**< Standard port */
115607 + e_IOC_FMT_PORT_T_OP, /**< Offline-parsing port */
115608 +} ioc_fmt_port_type;
115609 +
115610 +/**************************************************************************//**
115611 + @Description TODO
115612 +*//***************************************************************************/
115613 +typedef struct ioc_fmt_port_param_t {
115614 + uint8_t fm_id;
115615 + ioc_fmt_port_type fm_port_type;
115616 + uint8_t fm_port_id;
115617 + uint32_t num_tx_queues;
115618 +} ioc_fmt_port_param_t;
115619 +
115620 +
115621 +/**************************************************************************//**
115622 + @Function FMT_PORT_IOC_INIT
115623 +
115624 + @Description TODO
115625 +
115626 + @Param[in] ioc_fmt_port_param_t TODO
115627 +
115628 + @Cautions Allowed only after the FM equivalent port is already initialized.
115629 +*//***************************************************************************/
115630 +#define FMT_PORT_IOC_INIT _IOW(FMT_IOC_TYPE_BASE, FMT_PORT_IOC_NUM(0), ioc_fmt_port_param_t)
115631 +
115632 +/**************************************************************************//**
115633 + @Function FMT_PORT_IOC_SET_DIAG_MODE
115634 +
115635 + @Description TODO
115636 +
115637 + @Param[in] ioc_diag_mode TODO
115638 +
115639 + @Cautions Allowed only following FMT_PORT_IOC_INIT().
115640 +*//***************************************************************************/
115641 +#define FMT_PORT_IOC_SET_DIAG_MODE _IOW(FMT_IOC_TYPE_BASE, FMT_PORT_IOC_NUM(1), ioc_diag_mode)
115642 +
115643 +/**************************************************************************//**
115644 + @Function FMT_PORT_IOC_SET_IP_HEADER_MANIP
115645 +
115646 + @Description Set IP header manipulations for this port.
115647 +
115648 + @Param[in] int 1 to enable; 0 to disable
115649 +
115650 + @Cautions Allowed only following FMT_PORT_IOC_INIT().
115651 +*//***************************************************************************/
115652 +#define FMT_PORT_IOC_SET_IP_HEADER_MANIP _IOW(FMT_IOC_TYPE_BASE, FMT_PORT_IOC_NUM(2), int)
115653 +
115654 +/**************************************************************************//**
115655 + @Function FMT_PORT_IOC_SET_DPAECHO_MODE
115656 +
115657 + @Description Set DPA in echo mode - all frame are sent back.
115658 +
115659 + @Param[in] int 1 to enable; 0 to disable
115660 +
115661 + @Cautions Allowed only following FMT_PORT_IOC_INIT().
115662 +*//***************************************************************************/
115663 +#define FMT_PORT_IOC_SET_DPAECHO_MODE _IOW(FMT_IOC_TYPE_BASE, FMT_PORT_IOC_NUM(3), int)
115664 +
115665 +/** @} */ /* end of lnx_ioctl_FMTP_lib_grp group */
115666 +/** @} */ /* end of lnx_ioctl_FMT_lib_grp group */
115667 +/** @} */ /* end of lnx_ioctl_FMT_grp */
115668 +
115669 +
115670 +#endif /* __FM_TEST_IOCTLS_H */
115671 --- /dev/null
115672 +++ b/include/uapi/linux/fmd/integrations/Kbuild
115673 @@ -0,0 +1 @@
115674 +header-y += integration_ioctls.h
115675 --- /dev/null
115676 +++ b/include/uapi/linux/fmd/integrations/integration_ioctls.h
115677 @@ -0,0 +1,56 @@
115678 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc.
115679 + * All rights reserved.
115680 + *
115681 + * Redistribution and use in source and binary forms, with or without
115682 + * modification, are permitted provided that the following conditions are met:
115683 + * * Redistributions of source code must retain the above copyright
115684 + * notice, this list of conditions and the following disclaimer.
115685 + * * Redistributions in binary form must reproduce the above copyright
115686 + * notice, this list of conditions and the following disclaimer in the
115687 + * documentation and/or other materials provided with the distribution.
115688 + * * Neither the name of Freescale Semiconductor nor the
115689 + * names of its contributors may be used to endorse or promote products
115690 + * derived from this software without specific prior written permission.
115691 + *
115692 + *
115693 + * ALTERNATIVELY, this software may be distributed under the terms of the
115694 + * GNU General Public License ("GPL") as published by the Free Software
115695 + * Foundation, either version 2 of that License or (at your option) any
115696 + * later version.
115697 + *
115698 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
115699 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
115700 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
115701 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
115702 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
115703 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
115704 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
115705 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
115706 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
115707 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
115708 + */
115709 +
115710 +/**************************************************************************//**
115711 + @File integration_ioctls.h
115712 +
115713 + @Description External header file for Integration unit routines.
115714 +*//***************************************************************************/
115715 +
115716 +#ifndef __INTG_IOCTLS_H
115717 +#define __INTG_IOCTLS_H
115718 +
115719 +
115720 +#define FM_IOC_TYPE_BASE (NCSW_IOC_TYPE_BASE+1)
115721 +#define FMT_IOC_TYPE_BASE (NCSW_IOC_TYPE_BASE+3)
115722 +
115723 +/*#define FM_IOCTL_DBG*/
115724 +
115725 +#if defined(FM_IOCTL_DBG)
115726 + #define _fm_ioctl_dbg(format, arg...) \
115727 + printk("fm ioctl [%s:%u](cpu:%u) - " format, \
115728 + __func__, __LINE__, smp_processor_id(), ##arg)
115729 +#else
115730 +# define _fm_ioctl_dbg(arg...)
115731 +#endif
115732 +
115733 +#endif /* __INTG_IOCTLS_H */
115734 --- /dev/null
115735 +++ b/include/uapi/linux/fmd/ioctls.h
115736 @@ -0,0 +1,96 @@
115737 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc.
115738 + * All rights reserved.
115739 + *
115740 + * Redistribution and use in source and binary forms, with or without
115741 + * modification, are permitted provided that the following conditions are met:
115742 + * * Redistributions of source code must retain the above copyright
115743 + * notice, this list of conditions and the following disclaimer.
115744 + * * Redistributions in binary form must reproduce the above copyright
115745 + * notice, this list of conditions and the following disclaimer in the
115746 + * documentation and/or other materials provided with the distribution.
115747 + * * Neither the name of Freescale Semiconductor nor the
115748 + * names of its contributors may be used to endorse or promote products
115749 + * derived from this software without specific prior written permission.
115750 + *
115751 + *
115752 + * ALTERNATIVELY, this software may be distributed under the terms of the
115753 + * GNU General Public License ("GPL") as published by the Free Software
115754 + * Foundation, either version 2 of that License or (at your option) any
115755 + * later version.
115756 + *
115757 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
115758 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
115759 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
115760 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
115761 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
115762 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
115763 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
115764 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
115765 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
115766 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
115767 + */
115768 +
115769 +/**************************************************************************//**
115770 + @File ioctls.h
115771 +
115772 + @Description Structures and definitions for Command Relay Ioctls
115773 +*//***************************************************************************/
115774 +
115775 +#ifndef __IOCTLS_H__
115776 +#define __IOCTLS_H__
115777 +
115778 +#include <asm/ioctl.h>
115779 +
115780 +#include "integration_ioctls.h"
115781 +
115782 +
115783 +/**************************************************************************//**
115784 + @Group lnx_ioctl_ncsw_grp NetCommSw Linux User-Space (IOCTL) API
115785 + @{
115786 +*//***************************************************************************/
115787 +
115788 +#define NCSW_IOC_TYPE_BASE 0xe0 /**< defines the IOCTL type for all
115789 + the NCSW Linux module commands */
115790 +
115791 +
115792 +/**************************************************************************//**
115793 + @Description IOCTL Memory allocation types.
115794 +*//***************************************************************************/
115795 +typedef enum ioc_mem_type {
115796 + e_IOC_MEM_INVALID = 0x00000000, /**< Invalid memory type (error) */
115797 + e_IOC_MEM_CACHABLE_SYS = 0x00000001, /**< Primary DDR, cacheable segment */
115798 + e_IOC_MEM_NOCACHE_SYS = 0x00000004, /**< Primary DDR, non-cacheable segment */
115799 + e_IOC_MEM_SECONDARY = 0x00000002, /**< Either secondary DDR or SDRAM */
115800 + e_IOC_MEM_PRAM = 0x00000008 /**< Multi-user RAM identifier */
115801 +} ioc_mem_type;
115802 +
115803 +/**************************************************************************//**
115804 + @Description Enumeration (bit flags) of communication modes (Transmit,
115805 + receive or both).
115806 +*//***************************************************************************/
115807 +typedef enum ioc_comm_mode {
115808 + e_IOC_COMM_MODE_NONE = 0 /**< No transmit/receive communication */
115809 + , e_IOC_COMM_MODE_RX = 1 /**< Only receive communication */
115810 + , e_IOC_COMM_MODE_TX = 2 /**< Only transmit communication */
115811 + , e_IOC_COMM_MODE_RX_AND_TX = 3 /**< Both transmit and receive communication */
115812 +} ioc_comm_mode;
115813 +
115814 +/**************************************************************************//**
115815 + @Description General Diagnostic Mode
115816 +*//***************************************************************************/
115817 +typedef enum ioc_diag_mode
115818 +{
115819 + e_IOC_DIAG_MODE_NONE = 0,
115820 + e_IOC_DIAG_MODE_CTRL_LOOPBACK, /**< loopback in the controller; E.g. MAC, TDM, etc. */
115821 + e_IOC_DIAG_MODE_CHIP_LOOPBACK, /**< loopback in the chip but not in controller;
115822 + E.g. IO-pins, SerDes, etc. */
115823 + e_IOC_DIAG_MODE_PHY_LOOPBACK, /**< loopback in the external PHY */
115824 + e_IOC_DIAG_MODE_LINE_LOOPBACK, /**< loopback in the external line */
115825 + e_IOC_DIAG_MODE_CTRL_ECHO, /**< */
115826 + e_IOC_DIAG_MODE_PHY_ECHO /**< */
115827 +} ioc_diag_mode;
115828 +
115829 +/** @} */ /* end of lnx_ioctl_ncsw_grp */
115830 +
115831 +
115832 +#endif /* __IOCTLS_H__ */
115833 --- /dev/null
115834 +++ b/include/uapi/linux/fmd/net_ioctls.h
115835 @@ -0,0 +1,430 @@
115836 +/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc.
115837 + * All rights reserved.
115838 + *
115839 + * Redistribution and use in source and binary forms, with or without
115840 + * modification, are permitted provided that the following conditions are met:
115841 + * * Redistributions of source code must retain the above copyright
115842 + * notice, this list of conditions and the following disclaimer.
115843 + * * Redistributions in binary form must reproduce the above copyright
115844 + * notice, this list of conditions and the following disclaimer in the
115845 + * documentation and/or other materials provided with the distribution.
115846 + * * Neither the name of Freescale Semiconductor nor the
115847 + * names of its contributors may be used to endorse or promote products
115848 + * derived from this software without specific prior written permission.
115849 + *
115850 + *
115851 + * ALTERNATIVELY, this software may be distributed under the terms of the
115852 + * GNU General Public License ("GPL") as published by the Free Software
115853 + * Foundation, either version 2 of that License or (at your option) any
115854 + * later version.
115855 + *
115856 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
115857 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
115858 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
115859 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
115860 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
115861 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
115862 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
115863 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
115864 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
115865 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
115866 + */
115867 +
115868 +
115869 +/**************************************************************************//**
115870 + @File net_ioctls.h
115871 +
115872 + @Description This file contains common and general netcomm headers definitions.
115873 +*//***************************************************************************/
115874 +#ifndef __NET_IOCTLS_H
115875 +#define __NET_IOCTLS_H
115876 +
115877 +#include "ioctls.h"
115878 +
115879 +
115880 +typedef uint8_t ioc_header_field_ppp_t;
115881 +
115882 +#define IOC_NET_HEADER_FIELD_PPP_PID (1)
115883 +#define IOC_NET_HEADER_FIELD_PPP_COMPRESSED (IOC_NET_HEADER_FIELD_PPP_PID << 1)
115884 +#define IOC_NET_HEADER_FIELD_PPP_ALL_FIELDS ((IOC_NET_HEADER_FIELD_PPP_PID << 2) - 1)
115885 +
115886 +
115887 +typedef uint8_t ioc_header_field_pppoe_t;
115888 +
115889 +#define IOC_NET_HEADER_FIELD_PPPoE_VER (1)
115890 +#define IOC_NET_HEADER_FIELD_PPPoE_TYPE (IOC_NET_HEADER_FIELD_PPPoE_VER << 1)
115891 +#define IOC_NET_HEADER_FIELD_PPPoE_CODE (IOC_NET_HEADER_FIELD_PPPoE_VER << 2)
115892 +#define IOC_NET_HEADER_FIELD_PPPoE_SID (IOC_NET_HEADER_FIELD_PPPoE_VER << 3)
115893 +#define IOC_NET_HEADER_FIELD_PPPoE_LEN (IOC_NET_HEADER_FIELD_PPPoE_VER << 4)
115894 +#define IOC_NET_HEADER_FIELD_PPPoE_SESSION (IOC_NET_HEADER_FIELD_PPPoE_VER << 5)
115895 +#define IOC_NET_HEADER_FIELD_PPPoE_PID (IOC_NET_HEADER_FIELD_PPPoE_VER << 6)
115896 +#define IOC_NET_HEADER_FIELD_PPPoE_ALL_FIELDS ((IOC_NET_HEADER_FIELD_PPPoE_VER << 7) - 1)
115897 +
115898 +#define IOC_NET_HEADER_FIELD_PPPMUX_PID (1)
115899 +#define IOC_NET_HEADER_FIELD_PPPMUX_CKSUM (IOC_NET_HEADER_FIELD_PPPMUX_PID << 1)
115900 +#define IOC_NET_HEADER_FIELD_PPPMUX_COMPRESSED (IOC_NET_HEADER_FIELD_PPPMUX_PID << 2)
115901 +#define IOC_NET_HEADER_FIELD_PPPMUX_ALL_FIELDS ((IOC_NET_HEADER_FIELD_PPPMUX_PID << 3) - 1)
115902 +
115903 +#define IOC_NET_HEADER_FIELD_PPPMUX_SUBFRAME_PFF (1)
115904 +#define IOC_NET_HEADER_FIELD_PPPMUX_SUBFRAME_LXT (IOC_NET_HEADER_FIELD_PPPMUX_SUBFRAME_PFF << 1)
115905 +#define IOC_NET_HEADER_FIELD_PPPMUX_SUBFRAME_LEN (IOC_NET_HEADER_FIELD_PPPMUX_SUBFRAME_PFF << 2)
115906 +#define IOC_NET_HEADER_FIELD_PPPMUX_SUBFRAME_PID (IOC_NET_HEADER_FIELD_PPPMUX_SUBFRAME_PFF << 3)
115907 +#define IOC_NET_HEADER_FIELD_PPPMUX_SUBFRAME_USE_PID (IOC_NET_HEADER_FIELD_PPPMUX_SUBFRAME_PFF << 4)
115908 +#define IOC_NET_HEADER_FIELD_PPPMUX_SUBFRAME_ALL_FIELDS ((IOC_NET_HEADER_FIELD_PPPMUX_SUBFRAME_PFF << 5) - 1)
115909 +
115910 +
115911 +typedef uint8_t ioc_header_field_eth_t;
115912 +
115913 +#define IOC_NET_HEADER_FIELD_ETH_DA (1)
115914 +#define IOC_NET_HEADER_FIELD_ETH_SA (IOC_NET_HEADER_FIELD_ETH_DA << 1)
115915 +#define IOC_NET_HEADER_FIELD_ETH_LENGTH (IOC_NET_HEADER_FIELD_ETH_DA << 2)
115916 +#define IOC_NET_HEADER_FIELD_ETH_TYPE (IOC_NET_HEADER_FIELD_ETH_DA << 3)
115917 +#define IOC_NET_HEADER_FIELD_ETH_FINAL_CKSUM (IOC_NET_HEADER_FIELD_ETH_DA << 4)
115918 +#define IOC_NET_HEADER_FIELD_ETH_PADDING (IOC_NET_HEADER_FIELD_ETH_DA << 5)
115919 +#define IOC_NET_HEADER_FIELD_ETH_ALL_FIELDS ((IOC_NET_HEADER_FIELD_ETH_DA << 6) - 1)
115920 +
115921 +#define IOC_NET_HEADER_FIELD_ETH_ADDR_SIZE 6
115922 +
115923 +typedef uint16_t ioc_header_field_ip_t;
115924 +
115925 +#define IOC_NET_HEADER_FIELD_IP_VER (1)
115926 +#define IOC_NET_HEADER_FIELD_IP_DSCP (IOC_NET_HEADER_FIELD_IP_VER << 2)
115927 +#define IOC_NET_HEADER_FIELD_IP_ECN (IOC_NET_HEADER_FIELD_IP_VER << 3)
115928 +#define IOC_NET_HEADER_FIELD_IP_PROTO (IOC_NET_HEADER_FIELD_IP_VER << 4)
115929 +
115930 +#define IOC_NET_HEADER_FIELD_IP_PROTO_SIZE 1
115931 +
115932 +typedef uint16_t ioc_header_field_ipv4_t;
115933 +
115934 +#define IOC_NET_HEADER_FIELD_IPv4_VER (1)
115935 +#define IOC_NET_HEADER_FIELD_IPv4_HDR_LEN (IOC_NET_HEADER_FIELD_IPv4_VER << 1)
115936 +#define IOC_NET_HEADER_FIELD_IPv4_TOS (IOC_NET_HEADER_FIELD_IPv4_VER << 2)
115937 +#define IOC_NET_HEADER_FIELD_IPv4_TOTAL_LEN (IOC_NET_HEADER_FIELD_IPv4_VER << 3)
115938 +#define IOC_NET_HEADER_FIELD_IPv4_ID (IOC_NET_HEADER_FIELD_IPv4_VER << 4)
115939 +#define IOC_NET_HEADER_FIELD_IPv4_FLAG_D (IOC_NET_HEADER_FIELD_IPv4_VER << 5)
115940 +#define IOC_NET_HEADER_FIELD_IPv4_FLAG_M (IOC_NET_HEADER_FIELD_IPv4_VER << 6)
115941 +#define IOC_NET_HEADER_FIELD_IPv4_OFFSET (IOC_NET_HEADER_FIELD_IPv4_VER << 7)
115942 +#define IOC_NET_HEADER_FIELD_IPv4_TTL (IOC_NET_HEADER_FIELD_IPv4_VER << 8)
115943 +#define IOC_NET_HEADER_FIELD_IPv4_PROTO (IOC_NET_HEADER_FIELD_IPv4_VER << 9)
115944 +#define IOC_NET_HEADER_FIELD_IPv4_CKSUM (IOC_NET_HEADER_FIELD_IPv4_VER << 10)
115945 +#define IOC_NET_HEADER_FIELD_IPv4_SRC_IP (IOC_NET_HEADER_FIELD_IPv4_VER << 11)
115946 +#define IOC_NET_HEADER_FIELD_IPv4_DST_IP (IOC_NET_HEADER_FIELD_IPv4_VER << 12)
115947 +#define IOC_NET_HEADER_FIELD_IPv4_OPTS (IOC_NET_HEADER_FIELD_IPv4_VER << 13)
115948 +#define IOC_NET_HEADER_FIELD_IPv4_OPTS_COUNT (IOC_NET_HEADER_FIELD_IPv4_VER << 14)
115949 +#define IOC_NET_HEADER_FIELD_IPv4_ALL_FIELDS ((IOC_NET_HEADER_FIELD_IPv4_VER << 15) - 1)
115950 +
115951 +#define IOC_NET_HEADER_FIELD_IPv4_ADDR_SIZE 4
115952 +#define IOC_NET_HEADER_FIELD_IPv4_PROTO_SIZE 1
115953 +
115954 +
115955 +typedef uint8_t ioc_header_field_ipv6_t;
115956 +
115957 +#define IOC_NET_HEADER_FIELD_IPv6_VER (1)
115958 +#define IOC_NET_HEADER_FIELD_IPv6_TC (IOC_NET_HEADER_FIELD_IPv6_VER << 1)
115959 +#define IOC_NET_HEADER_FIELD_IPv6_SRC_IP (IOC_NET_HEADER_FIELD_IPv6_VER << 2)
115960 +#define IOC_NET_HEADER_FIELD_IPv6_DST_IP (IOC_NET_HEADER_FIELD_IPv6_VER << 3)
115961 +#define IOC_NET_HEADER_FIELD_IPv6_NEXT_HDR (IOC_NET_HEADER_FIELD_IPv6_VER << 4)
115962 +#define IOC_NET_HEADER_FIELD_IPv6_FL (IOC_NET_HEADER_FIELD_IPv6_VER << 5)
115963 +#define IOC_NET_HEADER_FIELD_IPv6_HOP_LIMIT (IOC_NET_HEADER_FIELD_IPv6_VER << 6)
115964 +#define IOC_NET_HEADER_FIELD_IPv6_ALL_FIELDS ((IOC_NET_HEADER_FIELD_IPv6_VER << 7) - 1)
115965 +
115966 +#define IOC_NET_HEADER_FIELD_IPv6_ADDR_SIZE 16
115967 +#define IOC_NET_HEADER_FIELD_IPv6_NEXT_HDR_SIZE 1
115968 +
115969 +#define IOC_NET_HEADER_FIELD_ICMP_TYPE (1)
115970 +#define IOC_NET_HEADER_FIELD_ICMP_CODE (IOC_NET_HEADER_FIELD_ICMP_TYPE << 1)
115971 +#define IOC_NET_HEADER_FIELD_ICMP_CKSUM (IOC_NET_HEADER_FIELD_ICMP_TYPE << 2)
115972 +#define IOC_NET_HEADER_FIELD_ICMP_ID (IOC_NET_HEADER_FIELD_ICMP_TYPE << 3)
115973 +#define IOC_NET_HEADER_FIELD_ICMP_SQ_NUM (IOC_NET_HEADER_FIELD_ICMP_TYPE << 4)
115974 +#define IOC_NET_HEADER_FIELD_ICMP_ALL_FIELDS ((IOC_NET_HEADER_FIELD_ICMP_TYPE << 5) - 1)
115975 +
115976 +#define IOC_NET_HEADER_FIELD_ICMP_CODE_SIZE 1
115977 +#define IOC_NET_HEADER_FIELD_ICMP_TYPE_SIZE 1
115978 +
115979 +#define IOC_NET_HEADER_FIELD_IGMP_VERSION (1)
115980 +#define IOC_NET_HEADER_FIELD_IGMP_TYPE (IOC_NET_HEADER_FIELD_IGMP_VERSION << 1)
115981 +#define IOC_NET_HEADER_FIELD_IGMP_CKSUM (IOC_NET_HEADER_FIELD_IGMP_VERSION << 2)
115982 +#define IOC_NET_HEADER_FIELD_IGMP_DATA (IOC_NET_HEADER_FIELD_IGMP_VERSION << 3)
115983 +#define IOC_NET_HEADER_FIELD_IGMP_ALL_FIELDS ((IOC_NET_HEADER_FIELD_IGMP_VERSION << 4) - 1)
115984 +
115985 +
115986 +typedef uint16_t ioc_header_field_tcp_t;
115987 +
115988 +#define IOC_NET_HEADER_FIELD_TCP_PORT_SRC (1)
115989 +#define IOC_NET_HEADER_FIELD_TCP_PORT_DST (IOC_NET_HEADER_FIELD_TCP_PORT_SRC << 1)
115990 +#define IOC_NET_HEADER_FIELD_TCP_SEQ (IOC_NET_HEADER_FIELD_TCP_PORT_SRC << 2)
115991 +#define IOC_NET_HEADER_FIELD_TCP_ACK (IOC_NET_HEADER_FIELD_TCP_PORT_SRC << 3)
115992 +#define IOC_NET_HEADER_FIELD_TCP_OFFSET (IOC_NET_HEADER_FIELD_TCP_PORT_SRC << 4)
115993 +#define IOC_NET_HEADER_FIELD_TCP_FLAGS (IOC_NET_HEADER_FIELD_TCP_PORT_SRC << 5)
115994 +#define IOC_NET_HEADER_FIELD_TCP_WINDOW (IOC_NET_HEADER_FIELD_TCP_PORT_SRC << 6)
115995 +#define IOC_NET_HEADER_FIELD_TCP_CKSUM (IOC_NET_HEADER_FIELD_TCP_PORT_SRC << 7)
115996 +#define IOC_NET_HEADER_FIELD_TCP_URGPTR (IOC_NET_HEADER_FIELD_TCP_PORT_SRC << 8)
115997 +#define IOC_NET_HEADER_FIELD_TCP_OPTS (IOC_NET_HEADER_FIELD_TCP_PORT_SRC << 9)
115998 +#define IOC_NET_HEADER_FIELD_TCP_OPTS_COUNT (IOC_NET_HEADER_FIELD_TCP_PORT_SRC << 10)
115999 +#define IOC_NET_HEADER_FIELD_TCP_ALL_FIELDS ((IOC_NET_HEADER_FIELD_TCP_PORT_SRC << 11) - 1)
116000 +
116001 +#define IOC_NET_HEADER_FIELD_TCP_PORT_SIZE 2
116002 +
116003 +
116004 +typedef uint8_t ioc_header_field_sctp_t;
116005 +
116006 +#define IOC_NET_HEADER_FIELD_SCTP_PORT_SRC (1)
116007 +#define IOC_NET_HEADER_FIELD_SCTP_PORT_DST (IOC_NET_HEADER_FIELD_SCTP_PORT_SRC << 1)
116008 +#define IOC_NET_HEADER_FIELD_SCTP_VER_TAG (IOC_NET_HEADER_FIELD_SCTP_PORT_SRC << 2)
116009 +#define IOC_NET_HEADER_FIELD_SCTP_CKSUM (IOC_NET_HEADER_FIELD_SCTP_PORT_SRC << 3)
116010 +#define IOC_NET_HEADER_FIELD_SCTP_ALL_FIELDS ((IOC_NET_HEADER_FIELD_SCTP_PORT_SRC << 4) - 1)
116011 +
116012 +#define IOC_NET_HEADER_FIELD_SCTP_PORT_SIZE 2
116013 +
116014 +typedef uint8_t ioc_header_field_dccp_t;
116015 +
116016 +#define IOC_NET_HEADER_FIELD_DCCP_PORT_SRC (1)
116017 +#define IOC_NET_HEADER_FIELD_DCCP_PORT_DST (IOC_NET_HEADER_FIELD_DCCP_PORT_SRC << 1)
116018 +#define IOC_NET_HEADER_FIELD_DCCP_ALL_FIELDS ((IOC_NET_HEADER_FIELD_DCCP_PORT_SRC << 2) - 1)
116019 +
116020 +#define IOC_NET_HEADER_FIELD_DCCP_PORT_SIZE 2
116021 +
116022 +
116023 +typedef uint8_t ioc_header_field_udp_t;
116024 +
116025 +#define IOC_NET_HEADER_FIELD_UDP_PORT_SRC (1)
116026 +#define IOC_NET_HEADER_FIELD_UDP_PORT_DST (IOC_NET_HEADER_FIELD_UDP_PORT_SRC << 1)
116027 +#define IOC_NET_HEADER_FIELD_UDP_LEN (IOC_NET_HEADER_FIELD_UDP_PORT_SRC << 2)
116028 +#define IOC_NET_HEADER_FIELD_UDP_CKSUM (IOC_NET_HEADER_FIELD_UDP_PORT_SRC << 3)
116029 +#define IOC_NET_HEADER_FIELD_UDP_ALL_FIELDS ((IOC_NET_HEADER_FIELD_UDP_PORT_SRC << 4) - 1)
116030 +
116031 +#define IOC_NET_HEADER_FIELD_UDP_PORT_SIZE 2
116032 +
116033 +typedef uint8_t ioc_header_field_udp_lite_t;
116034 +
116035 +#define IOC_NET_HEADER_FIELD_UDP_LITE_PORT_SRC (1)
116036 +#define IOC_NET_HEADER_FIELD_UDP_LITE_PORT_DST (IOC_NET_HEADER_FIELD_UDP_LITE_PORT_SRC << 1)
116037 +#define IOC_NET_HEADER_FIELD_UDP_LITE_ALL_FIELDS ((IOC_NET_HEADER_FIELD_UDP_LITE_PORT_SRC << 2) - 1)
116038 +
116039 +#define IOC_NET_HEADER_FIELD_UDP_LITE_PORT_SIZE 2
116040 +
116041 +typedef uint8_t ioc_header_field_udp_encap_esp_t;
116042 +
116043 +#define IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC (1)
116044 +#define IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_DST (IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 1)
116045 +#define IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_LEN (IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 2)
116046 +#define IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_CKSUM (IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 3)
116047 +#define IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_SPI (IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 4)
116048 +#define IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_SEQUENCE_NUM (IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 5)
116049 +#define IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_ALL_FIELDS ((IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 6) - 1)
116050 +
116051 +#define IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SIZE 2
116052 +#define IOC_NET_HEADER_FIELD_UDP_ENCAP_ESP_SPI_SIZE 4
116053 +
116054 +#define IOC_NET_HEADER_FIELD_IPHC_CID (1)
116055 +#define IOC_NET_HEADER_FIELD_IPHC_CID_TYPE (IOC_NET_HEADER_FIELD_IPHC_CID << 1)
116056 +#define IOC_NET_HEADER_FIELD_IPHC_HCINDEX (IOC_NET_HEADER_FIELD_IPHC_CID << 2)
116057 +#define IOC_NET_HEADER_FIELD_IPHC_GEN (IOC_NET_HEADER_FIELD_IPHC_CID << 3)
116058 +#define IOC_NET_HEADER_FIELD_IPHC_D_BIT (IOC_NET_HEADER_FIELD_IPHC_CID << 4)
116059 +#define IOC_NET_HEADER_FIELD_IPHC_ALL_FIELDS ((IOC_NET_HEADER_FIELD_IPHC_CID << 5) - 1)
116060 +
116061 +#define IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE (1)
116062 +#define IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_FLAGS (IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 1)
116063 +#define IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_LENGTH (IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 2)
116064 +#define IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_TSN (IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 3)
116065 +#define IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_STREAM_ID (IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 4)
116066 +#define IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_STREAM_SQN (IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 5)
116067 +#define IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_PAYLOAD_PID (IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 6)
116068 +#define IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_UNORDERED (IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 7)
116069 +#define IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_BEGGINING (IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 8)
116070 +#define IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_END (IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 9)
116071 +#define IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_ALL_FIELDS ((IOC_NET_HEADER_FIELD_SCTP_CHUNK_DATA_TYPE << 10) - 1)
116072 +
116073 +#define IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT (1)
116074 +#define IOC_NET_HEADER_FIELD_L2TPv2_LENGTH_BIT (IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 1)
116075 +#define IOC_NET_HEADER_FIELD_L2TPv2_SEQUENCE_BIT (IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 2)
116076 +#define IOC_NET_HEADER_FIELD_L2TPv2_OFFSET_BIT (IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 3)
116077 +#define IOC_NET_HEADER_FIELD_L2TPv2_PRIORITY_BIT (IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 4)
116078 +#define IOC_NET_HEADER_FIELD_L2TPv2_VERSION (IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 5)
116079 +#define IOC_NET_HEADER_FIELD_L2TPv2_LEN (IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 6)
116080 +#define IOC_NET_HEADER_FIELD_L2TPv2_TUNNEL_ID (IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 7)
116081 +#define IOC_NET_HEADER_FIELD_L2TPv2_SESSION_ID (IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 8)
116082 +#define IOC_NET_HEADER_FIELD_L2TPv2_NS (IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 9)
116083 +#define IOC_NET_HEADER_FIELD_L2TPv2_NR (IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 10)
116084 +#define IOC_NET_HEADER_FIELD_L2TPv2_OFFSET_SIZE (IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 11)
116085 +#define IOC_NET_HEADER_FIELD_L2TPv2_FIRST_BYTE (IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 12)
116086 +#define IOC_NET_HEADER_FIELD_L2TPv2_ALL_FIELDS ((IOC_NET_HEADER_FIELD_L2TPv2_TYPE_BIT << 13) - 1)
116087 +
116088 +#define IOC_NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT (1)
116089 +#define IOC_NET_HEADER_FIELD_L2TPv3_CTRL_LENGTH_BIT (IOC_NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 1)
116090 +#define IOC_NET_HEADER_FIELD_L2TPv3_CTRL_SEQUENCE_BIT (IOC_NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 2)
116091 +#define IOC_NET_HEADER_FIELD_L2TPv3_CTRL_VERSION (IOC_NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 3)
116092 +#define IOC_NET_HEADER_FIELD_L2TPv3_CTRL_LENGTH (IOC_NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 4)
116093 +#define IOC_NET_HEADER_FIELD_L2TPv3_CTRL_CONTROL (IOC_NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 5)
116094 +#define IOC_NET_HEADER_FIELD_L2TPv3_CTRL_SENT (IOC_NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 6)
116095 +#define IOC_NET_HEADER_FIELD_L2TPv3_CTRL_RECV (IOC_NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 7)
116096 +#define IOC_NET_HEADER_FIELD_L2TPv3_CTRL_FIRST_BYTE (IOC_NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 8)
116097 +#define IOC_NET_HEADER_FIELD_L2TPv3_CTRL_ALL_FIELDS ((IOC_NET_HEADER_FIELD_L2TPv3_CTRL_TYPE_BIT << 9) - 1)
116098 +
116099 +#define IOC_NET_HEADER_FIELD_L2TPv3_SESS_TYPE_BIT (1)
116100 +#define IOC_NET_HEADER_FIELD_L2TPv3_SESS_VERSION (IOC_NET_HEADER_FIELD_L2TPv3_SESS_TYPE_BIT << 1)
116101 +#define IOC_NET_HEADER_FIELD_L2TPv3_SESS_ID (IOC_NET_HEADER_FIELD_L2TPv3_SESS_TYPE_BIT << 2)
116102 +#define IOC_NET_HEADER_FIELD_L2TPv3_SESS_COOKIE (IOC_NET_HEADER_FIELD_L2TPv3_SESS_TYPE_BIT << 3)
116103 +#define IOC_NET_HEADER_FIELD_L2TPv3_SESS_ALL_FIELDS ((IOC_NET_HEADER_FIELD_L2TPv3_SESS_TYPE_BIT << 4) - 1)
116104 +
116105 +
116106 +typedef uint8_t ioc_header_field_vlan_t;
116107 +
116108 +#define IOC_NET_HEADER_FIELD_VLAN_VPRI (1)
116109 +#define IOC_NET_HEADER_FIELD_VLAN_CFI (IOC_NET_HEADER_FIELD_VLAN_VPRI << 1)
116110 +#define IOC_NET_HEADER_FIELD_VLAN_VID (IOC_NET_HEADER_FIELD_VLAN_VPRI << 2)
116111 +#define IOC_NET_HEADER_FIELD_VLAN_LENGTH (IOC_NET_HEADER_FIELD_VLAN_VPRI << 3)
116112 +#define IOC_NET_HEADER_FIELD_VLAN_TYPE (IOC_NET_HEADER_FIELD_VLAN_VPRI << 4)
116113 +#define IOC_NET_HEADER_FIELD_VLAN_ALL_FIELDS ((IOC_NET_HEADER_FIELD_VLAN_VPRI << 5) - 1)
116114 +
116115 +#define IOC_NET_HEADER_FIELD_VLAN_TCI (IOC_NET_HEADER_FIELD_VLAN_VPRI | \
116116 + IOC_NET_HEADER_FIELD_VLAN_CFI | \
116117 + IOC_NET_HEADER_FIELD_VLAN_VID)
116118 +
116119 +
116120 +typedef uint8_t ioc_header_field_llc_t;
116121 +
116122 +#define IOC_NET_HEADER_FIELD_LLC_DSAP (1)
116123 +#define IOC_NET_HEADER_FIELD_LLC_SSAP (IOC_NET_HEADER_FIELD_LLC_DSAP << 1)
116124 +#define IOC_NET_HEADER_FIELD_LLC_CTRL (IOC_NET_HEADER_FIELD_LLC_DSAP << 2)
116125 +#define IOC_NET_HEADER_FIELD_LLC_ALL_FIELDS ((IOC_NET_HEADER_FIELD_LLC_DSAP << 3) - 1)
116126 +
116127 +#define IOC_NET_HEADER_FIELD_NLPID_NLPID (1)
116128 +#define IOC_NET_HEADER_FIELD_NLPID_ALL_FIELDS ((IOC_NET_HEADER_FIELD_NLPID_NLPID << 1) - 1)
116129 +
116130 +
116131 +typedef uint8_t ioc_header_field_snap_t;
116132 +
116133 +#define IOC_NET_HEADER_FIELD_SNAP_OUI (1)
116134 +#define IOC_NET_HEADER_FIELD_SNAP_PID (IOC_NET_HEADER_FIELD_SNAP_OUI << 1)
116135 +#define IOC_NET_HEADER_FIELD_SNAP_ALL_FIELDS ((IOC_NET_HEADER_FIELD_SNAP_OUI << 2) - 1)
116136 +
116137 +
116138 +typedef uint8_t ioc_header_field_llc_snap_t;
116139 +
116140 +#define IOC_NET_HEADER_FIELD_LLC_SNAP_TYPE (1)
116141 +#define IOC_NET_HEADER_FIELD_LLC_SNAP_ALL_FIELDS ((IOC_NET_HEADER_FIELD_LLC_SNAP_TYPE << 1) - 1)
116142 +
116143 +#define IOC_NET_HEADER_FIELD_ARP_HTYPE (1)
116144 +#define IOC_NET_HEADER_FIELD_ARP_PTYPE (IOC_NET_HEADER_FIELD_ARP_HTYPE << 1)
116145 +#define IOC_NET_HEADER_FIELD_ARP_HLEN (IOC_NET_HEADER_FIELD_ARP_HTYPE << 2)
116146 +#define IOC_NET_HEADER_FIELD_ARP_PLEN (IOC_NET_HEADER_FIELD_ARP_HTYPE << 3)
116147 +#define IOC_NET_HEADER_FIELD_ARP_OPER (IOC_NET_HEADER_FIELD_ARP_HTYPE << 4)
116148 +#define IOC_NET_HEADER_FIELD_ARP_SHA (IOC_NET_HEADER_FIELD_ARP_HTYPE << 5)
116149 +#define IOC_NET_HEADER_FIELD_ARP_SPA (IOC_NET_HEADER_FIELD_ARP_HTYPE << 6)
116150 +#define IOC_NET_HEADER_FIELD_ARP_THA (IOC_NET_HEADER_FIELD_ARP_HTYPE << 7)
116151 +#define IOC_NET_HEADER_FIELD_ARP_TPA (IOC_NET_HEADER_FIELD_ARP_HTYPE << 8)
116152 +#define IOC_NET_HEADER_FIELD_ARP_ALL_FIELDS ((IOC_NET_HEADER_FIELD_ARP_HTYPE << 9) - 1)
116153 +
116154 +#define IOC_NET_HEADER_FIELD_RFC2684_LLC (1)
116155 +#define IOC_NET_HEADER_FIELD_RFC2684_NLPID (IOC_NET_HEADER_FIELD_RFC2684_LLC << 1)
116156 +#define IOC_NET_HEADER_FIELD_RFC2684_OUI (IOC_NET_HEADER_FIELD_RFC2684_LLC << 2)
116157 +#define IOC_NET_HEADER_FIELD_RFC2684_PID (IOC_NET_HEADER_FIELD_RFC2684_LLC << 3)
116158 +#define IOC_NET_HEADER_FIELD_RFC2684_VPN_OUI (IOC_NET_HEADER_FIELD_RFC2684_LLC << 4)
116159 +#define IOC_NET_HEADER_FIELD_RFC2684_VPN_IDX (IOC_NET_HEADER_FIELD_RFC2684_LLC << 5)
116160 +#define IOC_NET_HEADER_FIELD_RFC2684_ALL_FIELDS ((IOC_NET_HEADER_FIELD_RFC2684_LLC << 6) - 1)
116161 +
116162 +#define IOC_NET_HEADER_FIELD_USER_DEFINED_SRCPORT (1)
116163 +#define IOC_NET_HEADER_FIELD_USER_DEFINED_PCDID (IOC_NET_HEADER_FIELD_USER_DEFINED_SRCPORT << 1)
116164 +#define IOC_NET_HEADER_FIELD_USER_DEFINED_ALL_FIELDS ((IOC_NET_HEADER_FIELD_USER_DEFINED_SRCPORT << 2) - 1)
116165 +
116166 +#define IOC_NET_HEADER_FIELD_PAYLOAD_BUFFER (1)
116167 +#define IOC_NET_HEADER_FIELD_PAYLOAD_SIZE (IOC_NET_HEADER_FIELD_PAYLOAD_BUFFER << 1)
116168 +#define IOC_NET_HEADER_FIELD_MAX_FRM_SIZE (IOC_NET_HEADER_FIELD_PAYLOAD_BUFFER << 2)
116169 +#define IOC_NET_HEADER_FIELD_MIN_FRM_SIZE (IOC_NET_HEADER_FIELD_PAYLOAD_BUFFER << 3)
116170 +#define IOC_NET_HEADER_FIELD_PAYLOAD_TYPE (IOC_NET_HEADER_FIELD_PAYLOAD_BUFFER << 4)
116171 +#define IOC_NET_HEADER_FIELD_FRAME_SIZE (IOC_NET_HEADER_FIELD_PAYLOAD_BUFFER << 5)
116172 +#define IOC_NET_HEADER_FIELD_PAYLOAD_ALL_FIELDS ((IOC_NET_HEADER_FIELD_PAYLOAD_BUFFER << 6) - 1)
116173 +
116174 +
116175 +typedef uint8_t ioc_header_field_gre_t;
116176 +
116177 +#define IOC_NET_HEADER_FIELD_GRE_TYPE (1)
116178 +#define IOC_NET_HEADER_FIELD_GRE_ALL_FIELDS ((IOC_NET_HEADER_FIELD_GRE_TYPE << 1) - 1)
116179 +
116180 +
116181 +typedef uint8_t ioc_header_field_minencap_t;
116182 +
116183 +#define IOC_NET_HEADER_FIELD_MINENCAP_SRC_IP (1)
116184 +#define IOC_NET_HEADER_FIELD_MINENCAP_DST_IP (IOC_NET_HEADER_FIELD_MINENCAP_SRC_IP << 1)
116185 +#define IOC_NET_HEADER_FIELD_MINENCAP_TYPE (IOC_NET_HEADER_FIELD_MINENCAP_SRC_IP << 2)
116186 +#define IOC_NET_HEADER_FIELD_MINENCAP_ALL_FIELDS ((IOC_NET_HEADER_FIELD_MINENCAP_SRC_IP << 3) - 1)
116187 +
116188 +
116189 +typedef uint8_t ioc_header_field_ipsec_ah_t;
116190 +
116191 +#define IOC_NET_HEADER_FIELD_IPSEC_AH_SPI (1)
116192 +#define IOC_NET_HEADER_FIELD_IPSEC_AH_NH (IOC_NET_HEADER_FIELD_IPSEC_AH_SPI << 1)
116193 +#define IOC_NET_HEADER_FIELD_IPSEC_AH_ALL_FIELDS ((IOC_NET_HEADER_FIELD_IPSEC_AH_SPI << 2) - 1)
116194 +
116195 +
116196 +typedef uint8_t ioc_header_field_ipsec_esp_t;
116197 +
116198 +#define IOC_NET_HEADER_FIELD_IPSEC_ESP_SPI (1)
116199 +#define IOC_NET_HEADER_FIELD_IPSEC_ESP_SEQUENCE_NUM (IOC_NET_HEADER_FIELD_IPSEC_ESP_SPI << 1)
116200 +#define IOC_NET_HEADER_FIELD_IPSEC_ESP_ALL_FIELDS ((IOC_NET_HEADER_FIELD_IPSEC_ESP_SPI << 2) - 1)
116201 +
116202 +#define IOC_NET_HEADER_FIELD_IPSEC_ESP_SPI_SIZE 4
116203 +
116204 +
116205 +typedef uint8_t ioc_header_field_mpls_t;
116206 +
116207 +#define IOC_NET_HEADER_FIELD_MPLS_LABEL_STACK (1)
116208 +#define IOC_NET_HEADER_FIELD_MPLS_LABEL_STACK_ALL_FIELDS ((IOC_NET_HEADER_FIELD_MPLS_LABEL_STACK << 1) - 1)
116209 +
116210 +
116211 +typedef uint8_t ioc_header_field_macsec_t;
116212 +
116213 +#define IOC_NET_HEADER_FIELD_MACSEC_SECTAG (1)
116214 +#define IOC_NET_HEADER_FIELD_MACSEC_ALL_FIELDS ((IOC_NET_HEADER_FIELD_MACSEC_SECTAG << 1) - 1)
116215 +
116216 +
116217 +typedef enum {
116218 + e_IOC_NET_HEADER_TYPE_NONE = 0,
116219 + e_IOC_NET_HEADER_TYPE_PAYLOAD,
116220 + e_IOC_NET_HEADER_TYPE_ETH,
116221 + e_IOC_NET_HEADER_TYPE_VLAN,
116222 + e_IOC_NET_HEADER_TYPE_IPv4,
116223 + e_IOC_NET_HEADER_TYPE_IPv6,
116224 + e_IOC_NET_HEADER_TYPE_IP,
116225 + e_IOC_NET_HEADER_TYPE_TCP,
116226 + e_IOC_NET_HEADER_TYPE_UDP,
116227 + e_IOC_NET_HEADER_TYPE_UDP_LITE,
116228 + e_IOC_NET_HEADER_TYPE_IPHC,
116229 + e_IOC_NET_HEADER_TYPE_SCTP,
116230 + e_IOC_NET_HEADER_TYPE_SCTP_CHUNK_DATA,
116231 + e_IOC_NET_HEADER_TYPE_PPPoE,
116232 + e_IOC_NET_HEADER_TYPE_PPP,
116233 + e_IOC_NET_HEADER_TYPE_PPPMUX,
116234 + e_IOC_NET_HEADER_TYPE_PPPMUX_SUBFRAME,
116235 + e_IOC_NET_HEADER_TYPE_L2TPv2,
116236 + e_IOC_NET_HEADER_TYPE_L2TPv3_CTRL,
116237 + e_IOC_NET_HEADER_TYPE_L2TPv3_SESS,
116238 + e_IOC_NET_HEADER_TYPE_LLC,
116239 + e_IOC_NET_HEADER_TYPE_LLC_SNAP,
116240 + e_IOC_NET_HEADER_TYPE_NLPID,
116241 + e_IOC_NET_HEADER_TYPE_SNAP,
116242 + e_IOC_NET_HEADER_TYPE_MPLS,
116243 + e_IOC_NET_HEADER_TYPE_IPSEC_AH,
116244 + e_IOC_NET_HEADER_TYPE_IPSEC_ESP,
116245 + e_IOC_NET_HEADER_TYPE_UDP_ENCAP_ESP, /* RFC 3948 */
116246 + e_IOC_NET_HEADER_TYPE_MACSEC,
116247 + e_IOC_NET_HEADER_TYPE_GRE,
116248 + e_IOC_NET_HEADER_TYPE_MINENCAP,
116249 + e_IOC_NET_HEADER_TYPE_DCCP,
116250 + e_IOC_NET_HEADER_TYPE_ICMP,
116251 + e_IOC_NET_HEADER_TYPE_IGMP,
116252 + e_IOC_NET_HEADER_TYPE_ARP,
116253 + e_IOC_NET_HEADER_TYPE_CAPWAP,
116254 + e_IOC_NET_HEADER_TYPE_CAPWAP_DTLS,
116255 + e_IOC_NET_HEADER_TYPE_RFC2684,
116256 + e_IOC_NET_HEADER_TYPE_USER_DEFINED_L2,
116257 + e_IOC_NET_HEADER_TYPE_USER_DEFINED_L3,
116258 + e_IOC_NET_HEADER_TYPE_USER_DEFINED_L4,
116259 + e_IOC_NET_HEADER_TYPE_USER_DEFINED_SHIM1,
116260 + e_IOC_NET_HEADER_TYPE_USER_DEFINED_SHIM2,
116261 + e_IOC_NET_MAX_HEADER_TYPE_COUNT
116262 +} ioc_net_header_type;
116263 +
116264 +
116265 +#endif /* __NET_IOCTLS_H */