1 From 3cd36deb674720ab34eabb9783648ed743e52121 Mon Sep 17 00:00:00 2001
2 From: Yangbo Lu <yangbo.lu@nxp.com>
3 Date: Mon, 25 Sep 2017 11:58:03 +0800
4 Subject: [PATCH] sdk_dpaa: support layerscape
6 This is a integrated patch for layerscape dpaa1-sdk support.
8 Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
9 Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
10 Signed-off-by: Zhang Ying-22455 <ying.zhang22455@nxp.com>
11 Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
12 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
14 drivers/net/ethernet/freescale/sdk_dpaa/Kconfig | 173 +
15 drivers/net/ethernet/freescale/sdk_dpaa/Makefile | 46 +
16 .../net/ethernet/freescale/sdk_dpaa/dpaa_1588.c | 580 ++
17 .../net/ethernet/freescale/sdk_dpaa/dpaa_1588.h | 138 +
18 .../net/ethernet/freescale/sdk_dpaa/dpaa_debugfs.c | 180 +
19 .../net/ethernet/freescale/sdk_dpaa/dpaa_debugfs.h | 43 +
20 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c | 1213 ++++
21 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h | 687 ++
22 .../ethernet/freescale/sdk_dpaa/dpaa_eth_base.c | 205 +
23 .../ethernet/freescale/sdk_dpaa/dpaa_eth_base.h | 49 +
24 .../ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c | 1992 +++++
25 .../ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.h | 237 +
26 .../ethernet/freescale/sdk_dpaa/dpaa_eth_common.c | 1820 +++++
27 .../ethernet/freescale/sdk_dpaa/dpaa_eth_common.h | 225 +
28 .../ethernet/freescale/sdk_dpaa/dpaa_eth_proxy.c | 381 +
29 .../net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c | 1168 +++
30 .../ethernet/freescale/sdk_dpaa/dpaa_eth_sysfs.c | 278 +
31 .../ethernet/freescale/sdk_dpaa/dpaa_eth_trace.h | 144 +
32 .../net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c | 544 ++
33 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ptp.c | 291 +
34 drivers/net/ethernet/freescale/sdk_dpaa/mac-api.c | 907 +++
35 drivers/net/ethernet/freescale/sdk_dpaa/mac.c | 489 ++
36 drivers/net/ethernet/freescale/sdk_dpaa/mac.h | 135 +
37 .../net/ethernet/freescale/sdk_dpaa/offline_port.c | 848 +++
38 .../net/ethernet/freescale/sdk_dpaa/offline_port.h | 59 +
39 drivers/net/ethernet/freescale/sdk_fman/Kconfig | 153 +
40 drivers/net/ethernet/freescale/sdk_fman/Makefile | 11 +
41 .../freescale/sdk_fman/Peripherals/FM/HC/Makefile | 15 +
42 .../freescale/sdk_fman/Peripherals/FM/HC/hc.c | 1232 ++++
43 .../freescale/sdk_fman/Peripherals/FM/MAC/Makefile | 28 +
44 .../freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c | 1465 ++++
45 .../freescale/sdk_fman/Peripherals/FM/MAC/dtsec.h | 228 +
46 .../sdk_fman/Peripherals/FM/MAC/dtsec_mii_acc.c | 97 +
47 .../sdk_fman/Peripherals/FM/MAC/dtsec_mii_acc.h | 42 +
48 .../freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c | 674 ++
49 .../freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h | 226 +
50 .../sdk_fman/Peripherals/FM/MAC/fman_crc32.c | 119 +
51 .../sdk_fman/Peripherals/FM/MAC/fman_crc32.h | 43 +
52 .../sdk_fman/Peripherals/FM/MAC/fman_dtsec.c | 845 +++
53 .../Peripherals/FM/MAC/fman_dtsec_mii_acc.c | 163 +
54 .../sdk_fman/Peripherals/FM/MAC/fman_memac.c | 532 ++
55 .../Peripherals/FM/MAC/fman_memac_mii_acc.c | 213 +
56 .../sdk_fman/Peripherals/FM/MAC/fman_tgec.c | 367 +
57 .../freescale/sdk_fman/Peripherals/FM/MAC/memac.c | 1153 +++
58 .../freescale/sdk_fman/Peripherals/FM/MAC/memac.h | 110 +
59 .../sdk_fman/Peripherals/FM/MAC/memac_mii_acc.c | 78 +
60 .../sdk_fman/Peripherals/FM/MAC/memac_mii_acc.h | 73 +
61 .../freescale/sdk_fman/Peripherals/FM/MAC/tgec.c | 1017 +++
62 .../freescale/sdk_fman/Peripherals/FM/MAC/tgec.h | 151 +
63 .../sdk_fman/Peripherals/FM/MAC/tgec_mii_acc.c | 139 +
64 .../sdk_fman/Peripherals/FM/MAC/tgec_mii_acc.h | 80 +
65 .../sdk_fman/Peripherals/FM/MACSEC/Makefile | 15 +
66 .../sdk_fman/Peripherals/FM/MACSEC/fm_macsec.c | 237 +
67 .../sdk_fman/Peripherals/FM/MACSEC/fm_macsec.h | 203 +
68 .../Peripherals/FM/MACSEC/fm_macsec_guest.c | 59 +
69 .../Peripherals/FM/MACSEC/fm_macsec_master.c | 1031 +++
70 .../Peripherals/FM/MACSEC/fm_macsec_master.h | 479 ++
71 .../Peripherals/FM/MACSEC/fm_macsec_secy.c | 883 +++
72 .../Peripherals/FM/MACSEC/fm_macsec_secy.h | 144 +
73 .../freescale/sdk_fman/Peripherals/FM/Makefile | 23 +
74 .../freescale/sdk_fman/Peripherals/FM/Pcd/Makefile | 26 +
75 .../freescale/sdk_fman/Peripherals/FM/Pcd/crc64.h | 360 +
76 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.c | 7582 ++++++++++++++++++++
77 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.h | 399 +
78 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c | 3242 +++++++++
79 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.h | 206 +
80 .../sdk_fman/Peripherals/FM/Pcd/fm_manip.c | 5571 ++++++++++++++
81 .../sdk_fman/Peripherals/FM/Pcd/fm_manip.h | 555 ++
82 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_pcd.c | 2095 ++++++
83 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_pcd.h | 543 ++
84 .../sdk_fman/Peripherals/FM/Pcd/fm_pcd_ipc.h | 280 +
85 .../sdk_fman/Peripherals/FM/Pcd/fm_plcr.c | 1847 +++++
86 .../sdk_fman/Peripherals/FM/Pcd/fm_plcr.h | 165 +
87 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_prs.c | 423 ++
88 .../freescale/sdk_fman/Peripherals/FM/Pcd/fm_prs.h | 316 +
89 .../sdk_fman/Peripherals/FM/Pcd/fm_replic.c | 984 +++
90 .../sdk_fman/Peripherals/FM/Pcd/fm_replic.h | 101 +
91 .../sdk_fman/Peripherals/FM/Pcd/fman_kg.c | 888 +++
92 .../sdk_fman/Peripherals/FM/Pcd/fman_prs.c | 129 +
93 .../sdk_fman/Peripherals/FM/Port/Makefile | 15 +
94 .../sdk_fman/Peripherals/FM/Port/fm_port.c | 6436 +++++++++++++++++
95 .../sdk_fman/Peripherals/FM/Port/fm_port.h | 999 +++
96 .../sdk_fman/Peripherals/FM/Port/fm_port_dsar.h | 494 ++
97 .../sdk_fman/Peripherals/FM/Port/fm_port_im.c | 753 ++
98 .../sdk_fman/Peripherals/FM/Port/fman_port.c | 1568 ++++
99 .../freescale/sdk_fman/Peripherals/FM/Rtc/Makefile | 15 +
100 .../freescale/sdk_fman/Peripherals/FM/Rtc/fm_rtc.c | 692 ++
101 .../freescale/sdk_fman/Peripherals/FM/Rtc/fm_rtc.h | 96 +
102 .../sdk_fman/Peripherals/FM/Rtc/fman_rtc.c | 334 +
103 .../freescale/sdk_fman/Peripherals/FM/SP/Makefile | 15 +
104 .../freescale/sdk_fman/Peripherals/FM/SP/fm_sp.c | 757 ++
105 .../freescale/sdk_fman/Peripherals/FM/SP/fm_sp.h | 85 +
106 .../freescale/sdk_fman/Peripherals/FM/SP/fman_sp.c | 197 +
107 .../freescale/sdk_fman/Peripherals/FM/fm.c | 5216 ++++++++++++++
108 .../freescale/sdk_fman/Peripherals/FM/fm.h | 648 ++
109 .../freescale/sdk_fman/Peripherals/FM/fm_ipc.h | 465 ++
110 .../freescale/sdk_fman/Peripherals/FM/fm_muram.c | 174 +
111 .../freescale/sdk_fman/Peripherals/FM/fman.c | 1398 ++++
112 .../sdk_fman/Peripherals/FM/inc/fm_common.h | 1214 ++++
113 .../freescale/sdk_fman/Peripherals/FM/inc/fm_hc.h | 93 +
114 .../sdk_fman/Peripherals/FM/inc/fm_sp_common.h | 117 +
115 .../net/ethernet/freescale/sdk_fman/etc/Makefile | 12 +
116 .../net/ethernet/freescale/sdk_fman/etc/error.c | 95 +
117 drivers/net/ethernet/freescale/sdk_fman/etc/list.c | 71 +
118 .../net/ethernet/freescale/sdk_fman/etc/memcpy.c | 620 ++
119 drivers/net/ethernet/freescale/sdk_fman/etc/mm.c | 1155 +++
120 drivers/net/ethernet/freescale/sdk_fman/etc/mm.h | 105 +
121 .../net/ethernet/freescale/sdk_fman/etc/sprint.c | 81 +
122 .../ethernet/freescale/sdk_fman/fmanv3h_dflags.h | 57 +
123 .../ethernet/freescale/sdk_fman/fmanv3l_dflags.h | 56 +
124 .../sdk_fman/inc/Peripherals/crc_mac_addr_ext.h | 364 +
125 .../freescale/sdk_fman/inc/Peripherals/dpaa_ext.h | 210 +
126 .../freescale/sdk_fman/inc/Peripherals/fm_ext.h | 1731 +++++
127 .../sdk_fman/inc/Peripherals/fm_mac_ext.h | 887 +++
128 .../sdk_fman/inc/Peripherals/fm_macsec_ext.h | 1271 ++++
129 .../sdk_fman/inc/Peripherals/fm_muram_ext.h | 170 +
130 .../sdk_fman/inc/Peripherals/fm_pcd_ext.h | 3974 ++++++++++
131 .../sdk_fman/inc/Peripherals/fm_port_ext.h | 2608 +++++++
132 .../sdk_fman/inc/Peripherals/fm_rtc_ext.h | 619 ++
133 .../sdk_fman/inc/Peripherals/fm_vsp_ext.h | 411 ++
134 .../sdk_fman/inc/Peripherals/mii_acc_ext.h | 76 +
135 .../net/ethernet/freescale/sdk_fman/inc/core_ext.h | 90 +
136 .../freescale/sdk_fman/inc/cores/arm_ext.h | 55 +
137 .../freescale/sdk_fman/inc/cores/e500v2_ext.h | 476 ++
138 .../freescale/sdk_fman/inc/cores/ppc_ext.h | 141 +
139 .../ethernet/freescale/sdk_fman/inc/ddr_std_ext.h | 77 +
140 .../ethernet/freescale/sdk_fman/inc/debug_ext.h | 233 +
141 .../ethernet/freescale/sdk_fman/inc/endian_ext.h | 447 ++
142 .../net/ethernet/freescale/sdk_fman/inc/enet_ext.h | 205 +
143 .../ethernet/freescale/sdk_fman/inc/error_ext.h | 529 ++
144 .../ethernet/freescale/sdk_fman/inc/etc/list_ext.h | 358 +
145 .../ethernet/freescale/sdk_fman/inc/etc/mem_ext.h | 318 +
146 .../freescale/sdk_fman/inc/etc/memcpy_ext.h | 208 +
147 .../ethernet/freescale/sdk_fman/inc/etc/mm_ext.h | 310 +
148 .../freescale/sdk_fman/inc/etc/sprint_ext.h | 118 +
149 .../sdk_fman/inc/flib/common/arch/ppc_access.h | 37 +
150 .../freescale/sdk_fman/inc/flib/common/general.h | 52 +
151 .../freescale/sdk_fman/inc/flib/fman_common.h | 78 +
152 .../freescale/sdk_fman/inc/flib/fsl_enet.h | 273 +
153 .../freescale/sdk_fman/inc/flib/fsl_fman.h | 825 +++
154 .../freescale/sdk_fman/inc/flib/fsl_fman_dtsec.h | 1096 +++
155 .../sdk_fman/inc/flib/fsl_fman_dtsec_mii_acc.h | 107 +
156 .../freescale/sdk_fman/inc/flib/fsl_fman_kg.h | 514 ++
157 .../freescale/sdk_fman/inc/flib/fsl_fman_memac.h | 434 ++
158 .../sdk_fman/inc/flib/fsl_fman_memac_mii_acc.h | 78 +
159 .../freescale/sdk_fman/inc/flib/fsl_fman_port.h | 593 ++
160 .../freescale/sdk_fman/inc/flib/fsl_fman_prs.h | 102 +
161 .../freescale/sdk_fman/inc/flib/fsl_fman_rtc.h | 449 ++
162 .../freescale/sdk_fman/inc/flib/fsl_fman_sp.h | 138 +
163 .../freescale/sdk_fman/inc/flib/fsl_fman_tgec.h | 479 ++
164 .../integrations/FMANV3H/dpaa_integration_ext.h | 291 +
165 .../sdk_fman/inc/integrations/FMANV3H/part_ext.h | 71 +
166 .../integrations/FMANV3H/part_integration_ext.h | 304 +
167 .../integrations/FMANV3L/dpaa_integration_ext.h | 293 +
168 .../sdk_fman/inc/integrations/FMANV3L/part_ext.h | 59 +
169 .../integrations/FMANV3L/part_integration_ext.h | 304 +
170 .../inc/integrations/LS1043/dpaa_integration_ext.h | 291 +
171 .../sdk_fman/inc/integrations/LS1043/part_ext.h | 64 +
172 .../inc/integrations/LS1043/part_integration_ext.h | 185 +
173 .../inc/integrations/P1023/dpaa_integration_ext.h | 213 +
174 .../sdk_fman/inc/integrations/P1023/part_ext.h | 82 +
175 .../inc/integrations/P1023/part_integration_ext.h | 635 ++
176 .../P3040_P4080_P5020/dpaa_integration_ext.h | 276 +
177 .../inc/integrations/P3040_P4080_P5020/part_ext.h | 83 +
178 .../P3040_P4080_P5020/part_integration_ext.h | 336 +
179 .../net/ethernet/freescale/sdk_fman/inc/math_ext.h | 100 +
180 .../net/ethernet/freescale/sdk_fman/inc/ncsw_ext.h | 435 ++
181 .../net/ethernet/freescale/sdk_fman/inc/net_ext.h | 430 ++
182 .../net/ethernet/freescale/sdk_fman/inc/std_ext.h | 48 +
183 .../ethernet/freescale/sdk_fman/inc/stdarg_ext.h | 49 +
184 .../ethernet/freescale/sdk_fman/inc/stdlib_ext.h | 162 +
185 .../ethernet/freescale/sdk_fman/inc/string_ext.h | 56 +
186 .../ethernet/freescale/sdk_fman/inc/types_ext.h | 62 +
187 .../ethernet/freescale/sdk_fman/inc/xx_common.h | 56 +
188 .../net/ethernet/freescale/sdk_fman/inc/xx_ext.h | 791 ++
189 .../ethernet/freescale/sdk_fman/ls1043_dflags.h | 56 +
190 .../net/ethernet/freescale/sdk_fman/ncsw_config.mk | 53 +
191 .../net/ethernet/freescale/sdk_fman/p1023_dflags.h | 65 +
192 .../freescale/sdk_fman/p3040_4080_5020_dflags.h | 62 +
193 .../net/ethernet/freescale/sdk_fman/src/Makefile | 11 +
194 .../freescale/sdk_fman/src/inc/system/sys_ext.h | 118 +
195 .../freescale/sdk_fman/src/inc/system/sys_io_ext.h | 46 +
196 .../freescale/sdk_fman/src/inc/types_linux.h | 208 +
197 .../sdk_fman/src/inc/wrapper/fsl_fman_test.h | 84 +
198 .../sdk_fman/src/inc/wrapper/lnxwrp_exp_sym.h | 130 +
199 .../sdk_fman/src/inc/wrapper/lnxwrp_fm_ext.h | 163 +
200 .../sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h | 921 +++
201 .../ethernet/freescale/sdk_fman/src/inc/xx/xx.h | 50 +
202 .../freescale/sdk_fman/src/system/Makefile | 10 +
203 .../freescale/sdk_fman/src/system/sys_io.c | 171 +
204 .../freescale/sdk_fman/src/wrapper/Makefile | 19 +
205 .../freescale/sdk_fman/src/wrapper/fman_test.c | 1665 +++++
206 .../freescale/sdk_fman/src/wrapper/lnxwrp_fm.c | 2908 ++++++++
207 .../freescale/sdk_fman/src/wrapper/lnxwrp_fm.h | 294 +
208 .../sdk_fman/src/wrapper/lnxwrp_fm_port.c | 1480 ++++
209 .../sdk_fman/src/wrapper/lnxwrp_ioctls_fm.c | 4854 +++++++++++++
210 .../sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.c | 1297 ++++
211 .../sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.h | 755 ++
212 .../sdk_fman/src/wrapper/lnxwrp_resources.h | 121 +
213 .../sdk_fman/src/wrapper/lnxwrp_resources_ut.c | 191 +
214 .../sdk_fman/src/wrapper/lnxwrp_resources_ut.h | 144 +
215 .../sdk_fman/src/wrapper/lnxwrp_resources_ut.make | 28 +
216 .../freescale/sdk_fman/src/wrapper/lnxwrp_sysfs.c | 60 +
217 .../freescale/sdk_fman/src/wrapper/lnxwrp_sysfs.h | 60 +
218 .../sdk_fman/src/wrapper/lnxwrp_sysfs_fm.c | 1855 +++++
219 .../sdk_fman/src/wrapper/lnxwrp_sysfs_fm.h | 136 +
220 .../sdk_fman/src/wrapper/lnxwrp_sysfs_fm_port.c | 1268 ++++
221 .../sdk_fman/src/wrapper/lnxwrp_sysfs_fm_port.h | 56 +
222 .../ethernet/freescale/sdk_fman/src/xx/Makefile | 18 +
223 .../freescale/sdk_fman/src/xx/module_strings.c | 46 +
224 .../freescale/sdk_fman/src/xx/xx_arm_linux.c | 905 +++
225 .../ethernet/freescale/sdk_fman/src/xx/xx_linux.c | 918 +++
226 drivers/staging/fsl_qbman/Kconfig | 228 +
227 drivers/staging/fsl_qbman/Makefile | 28 +
228 drivers/staging/fsl_qbman/bman_config.c | 720 ++
229 drivers/staging/fsl_qbman/bman_debugfs.c | 119 +
230 drivers/staging/fsl_qbman/bman_driver.c | 575 ++
231 drivers/staging/fsl_qbman/bman_high.c | 1145 +++
232 drivers/staging/fsl_qbman/bman_low.h | 565 ++
233 drivers/staging/fsl_qbman/bman_private.h | 166 +
234 drivers/staging/fsl_qbman/bman_test.c | 56 +
235 drivers/staging/fsl_qbman/bman_test.h | 44 +
236 drivers/staging/fsl_qbman/bman_test_high.c | 183 +
237 drivers/staging/fsl_qbman/bman_test_thresh.c | 196 +
238 drivers/staging/fsl_qbman/dpa_alloc.c | 706 ++
239 drivers/staging/fsl_qbman/dpa_sys.h | 259 +
240 drivers/staging/fsl_qbman/dpa_sys_arm.h | 95 +
241 drivers/staging/fsl_qbman/dpa_sys_arm64.h | 102 +
242 drivers/staging/fsl_qbman/dpa_sys_ppc32.h | 70 +
243 drivers/staging/fsl_qbman/dpa_sys_ppc64.h | 79 +
244 drivers/staging/fsl_qbman/fsl_usdpaa.c | 1983 +++++
245 drivers/staging/fsl_qbman/fsl_usdpaa_irq.c | 289 +
246 drivers/staging/fsl_qbman/qbman_driver.c | 88 +
247 drivers/staging/fsl_qbman/qman_config.c | 1224 ++++
248 drivers/staging/fsl_qbman/qman_debugfs.c | 1594 ++++
249 drivers/staging/fsl_qbman/qman_driver.c | 977 +++
250 drivers/staging/fsl_qbman/qman_high.c | 5669 +++++++++++++++
251 drivers/staging/fsl_qbman/qman_low.h | 1427 ++++
252 drivers/staging/fsl_qbman/qman_private.h | 398 +
253 drivers/staging/fsl_qbman/qman_test.c | 57 +
254 drivers/staging/fsl_qbman/qman_test.h | 45 +
255 drivers/staging/fsl_qbman/qman_test_high.c | 216 +
256 drivers/staging/fsl_qbman/qman_test_hotpotato.c | 502 ++
257 drivers/staging/fsl_qbman/qman_utility.c | 129 +
258 include/linux/fsl_bman.h | 532 ++
259 include/linux/fsl_qman.h | 3888 ++++++++++
260 include/linux/fsl_usdpaa.h | 372 +
261 include/uapi/linux/fmd/Kbuild | 5 +
262 include/uapi/linux/fmd/Peripherals/Kbuild | 4 +
263 include/uapi/linux/fmd/Peripherals/fm_ioctls.h | 628 ++
264 include/uapi/linux/fmd/Peripherals/fm_pcd_ioctls.h | 3084 ++++++++
265 .../uapi/linux/fmd/Peripherals/fm_port_ioctls.h | 973 +++
266 .../uapi/linux/fmd/Peripherals/fm_test_ioctls.h | 208 +
267 include/uapi/linux/fmd/integrations/Kbuild | 1 +
268 .../linux/fmd/integrations/integration_ioctls.h | 56 +
269 include/uapi/linux/fmd/ioctls.h | 96 +
270 include/uapi/linux/fmd/net_ioctls.h | 430 ++
271 257 files changed, 153159 insertions(+)
272 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/Kconfig
273 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/Makefile
274 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_1588.c
275 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_1588.h
276 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_debugfs.c
277 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_debugfs.h
278 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
279 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h
280 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_base.c
281 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_base.h
282 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c
283 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.h
284 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.c
285 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.h
286 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_proxy.c
287 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
288 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sysfs.c
289 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_trace.h
290 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c
291 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ptp.c
292 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/mac-api.c
293 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/mac.c
294 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/mac.h
295 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/offline_port.c
296 create mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/offline_port.h
297 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Kconfig
298 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Makefile
299 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/HC/Makefile
300 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/HC/hc.c
301 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/Makefile
302 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c
303 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.h
304 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec_mii_acc.c
305 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec_mii_acc.h
306 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c
307 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h
308 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_crc32.c
309 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_crc32.h
310 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_dtsec.c
311 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_dtsec_mii_acc.c
312 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_memac.c
313 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_memac_mii_acc.c
314 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fman_tgec.c
315 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.c
316 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.h
317 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac_mii_acc.c
318 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac_mii_acc.h
319 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec.c
320 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec.h
321 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec_mii_acc.c
322 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec_mii_acc.h
323 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/Makefile
324 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec.c
325 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec.h
326 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_guest.c
327 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_master.c
328 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_master.h
329 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_secy.c
330 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MACSEC/fm_macsec_secy.h
331 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Makefile
332 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/Makefile
333 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/crc64.h
334 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.c
335 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.h
336 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c
337 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.h
338 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_manip.c
339 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_manip.h
340 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_pcd.c
341 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_pcd.h
342 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_pcd_ipc.h
343 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_plcr.c
344 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_plcr.h
345 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_prs.c
346 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_prs.h
347 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_replic.c
348 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_replic.h
349 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fman_kg.c
350 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fman_prs.c
351 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/Makefile
352 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c
353 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.h
354 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port_dsar.h
355 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port_im.c
356 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fman_port.c
357 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Rtc/Makefile
358 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Rtc/fm_rtc.c
359 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Rtc/fm_rtc.h
360 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Rtc/fman_rtc.c
361 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/SP/Makefile
362 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/SP/fm_sp.c
363 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/SP/fm_sp.h
364 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/SP/fman_sp.c
365 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.c
366 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.h
367 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm_ipc.h
368 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm_muram.c
369 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fman.c
370 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc/fm_common.h
371 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc/fm_hc.h
372 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/inc/fm_sp_common.h
373 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/Makefile
374 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/error.c
375 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/list.c
376 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/memcpy.c
377 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/mm.c
378 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/mm.h
379 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/etc/sprint.c
380 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/fmanv3h_dflags.h
381 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/fmanv3l_dflags.h
382 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/crc_mac_addr_ext.h
383 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/dpaa_ext.h
384 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_ext.h
385 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_mac_ext.h
386 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_macsec_ext.h
387 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_muram_ext.h
388 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_pcd_ext.h
389 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_port_ext.h
390 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_rtc_ext.h
391 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_vsp_ext.h
392 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/mii_acc_ext.h
393 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/core_ext.h
394 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/cores/arm_ext.h
395 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/cores/e500v2_ext.h
396 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/cores/ppc_ext.h
397 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/ddr_std_ext.h
398 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/debug_ext.h
399 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/endian_ext.h
400 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/enet_ext.h
401 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/error_ext.h
402 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/etc/list_ext.h
403 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/etc/mem_ext.h
404 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/etc/memcpy_ext.h
405 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/etc/mm_ext.h
406 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/etc/sprint_ext.h
407 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/common/arch/ppc_access.h
408 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/common/general.h
409 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fman_common.h
410 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_enet.h
411 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman.h
412 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_dtsec.h
413 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_dtsec_mii_acc.h
414 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_kg.h
415 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_memac.h
416 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_memac_mii_acc.h
417 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_port.h
418 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_prs.h
419 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_rtc.h
420 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_sp.h
421 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/flib/fsl_fman_tgec.h
422 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3H/dpaa_integration_ext.h
423 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3H/part_ext.h
424 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3H/part_integration_ext.h
425 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3L/dpaa_integration_ext.h
426 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3L/part_ext.h
427 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/FMANV3L/part_integration_ext.h
428 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/dpaa_integration_ext.h
429 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/part_ext.h
430 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/part_integration_ext.h
431 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P1023/dpaa_integration_ext.h
432 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P1023/part_ext.h
433 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P1023/part_integration_ext.h
434 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P3040_P4080_P5020/dpaa_integration_ext.h
435 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P3040_P4080_P5020/part_ext.h
436 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/integrations/P3040_P4080_P5020/part_integration_ext.h
437 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/math_ext.h
438 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/ncsw_ext.h
439 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/net_ext.h
440 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/std_ext.h
441 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/stdarg_ext.h
442 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/stdlib_ext.h
443 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/string_ext.h
444 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/types_ext.h
445 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/xx_common.h
446 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/inc/xx_ext.h
447 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/ls1043_dflags.h
448 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
449 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/p1023_dflags.h
450 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/p3040_4080_5020_dflags.h
451 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/Makefile
452 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/system/sys_ext.h
453 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/system/sys_io_ext.h
454 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/types_linux.h
455 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/fsl_fman_test.h
456 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_exp_sym.h
457 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fm_ext.h
458 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
459 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/inc/xx/xx.h
460 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/system/Makefile
461 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/system/sys_io.c
462 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/Makefile
463 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/fman_test.c
464 create mode 100755 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
465 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.h
466 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm_port.c
467 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm.c
468 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.c
469 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.h
470 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_resources.h
471 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_resources_ut.c
472 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_resources_ut.h
473 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_resources_ut.make
474 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs.c
475 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs.h
476 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm.c
477 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm.h
478 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm_port.c
479 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm_port.h
480 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/xx/Makefile
481 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/xx/module_strings.c
482 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/xx/xx_arm_linux.c
483 create mode 100644 drivers/net/ethernet/freescale/sdk_fman/src/xx/xx_linux.c
484 create mode 100644 drivers/staging/fsl_qbman/Kconfig
485 create mode 100644 drivers/staging/fsl_qbman/Makefile
486 create mode 100644 drivers/staging/fsl_qbman/bman_config.c
487 create mode 100644 drivers/staging/fsl_qbman/bman_debugfs.c
488 create mode 100644 drivers/staging/fsl_qbman/bman_driver.c
489 create mode 100644 drivers/staging/fsl_qbman/bman_high.c
490 create mode 100644 drivers/staging/fsl_qbman/bman_low.h
491 create mode 100644 drivers/staging/fsl_qbman/bman_private.h
492 create mode 100644 drivers/staging/fsl_qbman/bman_test.c
493 create mode 100644 drivers/staging/fsl_qbman/bman_test.h
494 create mode 100644 drivers/staging/fsl_qbman/bman_test_high.c
495 create mode 100644 drivers/staging/fsl_qbman/bman_test_thresh.c
496 create mode 100644 drivers/staging/fsl_qbman/dpa_alloc.c
497 create mode 100644 drivers/staging/fsl_qbman/dpa_sys.h
498 create mode 100644 drivers/staging/fsl_qbman/dpa_sys_arm.h
499 create mode 100644 drivers/staging/fsl_qbman/dpa_sys_arm64.h
500 create mode 100644 drivers/staging/fsl_qbman/dpa_sys_ppc32.h
501 create mode 100644 drivers/staging/fsl_qbman/dpa_sys_ppc64.h
502 create mode 100644 drivers/staging/fsl_qbman/fsl_usdpaa.c
503 create mode 100644 drivers/staging/fsl_qbman/fsl_usdpaa_irq.c
504 create mode 100644 drivers/staging/fsl_qbman/qbman_driver.c
505 create mode 100644 drivers/staging/fsl_qbman/qman_config.c
506 create mode 100644 drivers/staging/fsl_qbman/qman_debugfs.c
507 create mode 100644 drivers/staging/fsl_qbman/qman_driver.c
508 create mode 100644 drivers/staging/fsl_qbman/qman_high.c
509 create mode 100644 drivers/staging/fsl_qbman/qman_low.h
510 create mode 100644 drivers/staging/fsl_qbman/qman_private.h
511 create mode 100644 drivers/staging/fsl_qbman/qman_test.c
512 create mode 100644 drivers/staging/fsl_qbman/qman_test.h
513 create mode 100644 drivers/staging/fsl_qbman/qman_test_high.c
514 create mode 100644 drivers/staging/fsl_qbman/qman_test_hotpotato.c
515 create mode 100644 drivers/staging/fsl_qbman/qman_utility.c
516 create mode 100644 include/linux/fsl_bman.h
517 create mode 100644 include/linux/fsl_qman.h
518 create mode 100644 include/linux/fsl_usdpaa.h
519 create mode 100644 include/uapi/linux/fmd/Kbuild
520 create mode 100644 include/uapi/linux/fmd/Peripherals/Kbuild
521 create mode 100644 include/uapi/linux/fmd/Peripherals/fm_ioctls.h
522 create mode 100644 include/uapi/linux/fmd/Peripherals/fm_pcd_ioctls.h
523 create mode 100644 include/uapi/linux/fmd/Peripherals/fm_port_ioctls.h
524 create mode 100644 include/uapi/linux/fmd/Peripherals/fm_test_ioctls.h
525 create mode 100644 include/uapi/linux/fmd/integrations/Kbuild
526 create mode 100644 include/uapi/linux/fmd/integrations/integration_ioctls.h
527 create mode 100644 include/uapi/linux/fmd/ioctls.h
528 create mode 100644 include/uapi/linux/fmd/net_ioctls.h
530 diff --git a/drivers/net/ethernet/freescale/sdk_dpaa/Kconfig b/drivers/net/ethernet/freescale/sdk_dpaa/Kconfig
532 index 00000000..92118b76
534 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/Kconfig
536 +menuconfig FSL_SDK_DPAA_ETH
537 + tristate "DPAA Ethernet"
538 + depends on (FSL_SOC || ARM64 || ARM) && FSL_SDK_BMAN && FSL_SDK_QMAN && FSL_SDK_FMAN && !FSL_DPAA_ETH
541 + Data Path Acceleration Architecture Ethernet driver,
542 + supporting the Freescale QorIQ chips.
543 + Depends on Freescale Buffer Manager and Queue Manager
544 + driver and Frame Manager Driver.
548 +config FSL_DPAA_HOOKS
549 + bool "DPAA Ethernet driver hooks"
551 +config FSL_DPAA_CEETM
552 + bool "DPAA CEETM QoS"
553 + depends on NET_SCHED
556 + Enable QoS offloading support through the CEETM hardware block.
558 +config FSL_DPAA_OFFLINE_PORTS
559 + bool "Offline Ports support"
560 + depends on FSL_SDK_DPAA_ETH
563 + The Offline Parsing / Host Command ports (short: OH ports, of Offline ports) provide
564 + most of the functionality of the regular, online ports, except they receive their
565 + frames from a core or an accelerator on the SoC, via QMan frame queues,
566 + rather than directly from the network.
567 + Offline ports are configured via PCD (Parse-Classify-Distribute) schemes, just like
568 + any online FMan port. They deliver the processed frames to frame queues, according
569 + to the applied PCD configurations.
571 + Choosing this feature will not impact the functionality and/or performance of the system,
572 + so it is safe to have it.
574 +config FSL_DPAA_ADVANCED_DRIVERS
575 + bool "Advanced DPAA Ethernet drivers"
576 + depends on FSL_SDK_DPAA_ETH
579 + Besides the standard DPAA Ethernet driver the DPAA Proxy initialization driver
580 + is needed to support advanced scenarios. Select this to also build the advanced
583 +config FSL_DPAA_ETH_JUMBO_FRAME
584 + bool "Optimize for jumbo frames"
587 + Optimize the DPAA Ethernet driver throughput for large frames
588 + termination traffic (e.g. 4K and above).
589 + NOTE: This option can only be used if FSL_FM_MAX_FRAME_SIZE
590 + is set to 9600 bytes.
591 + Using this option in combination with small frames increases
592 + significantly the driver's memory footprint and may even deplete
593 + the system memory. Also, the skb truesize is altered and messages
594 + from the stack that warn against this are bypassed.
595 + This option is not available on LS1043.
598 + bool "Linux compliant timestamping"
599 + depends on FSL_SDK_DPAA_ETH
602 + Enable Linux API compliant timestamping support.
604 +config FSL_DPAA_1588
605 + bool "IEEE 1588-compliant timestamping"
606 + depends on FSL_SDK_DPAA_ETH
610 + Enable IEEE1588 support code.
612 +config FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
613 + bool "Use driver's Tx queue selection mechanism"
615 + depends on FSL_SDK_DPAA_ETH
617 + The DPAA-Ethernet driver defines a ndo_select_queue() callback for optimal selection
618 + of the egress FQ. That will override the XPS support for this netdevice.
619 + If for whatever reason you want to be in control of the egress FQ-to-CPU selection and mapping,
620 + or simply don't want to use the driver's ndo_select_queue() callback, then unselect this
621 + and use the standard XPS support instead.
623 +config FSL_DPAA_ETH_MAX_BUF_COUNT
624 + int "Maximum nuber of buffers in private bpool"
625 + depends on FSL_SDK_DPAA_ETH
629 + The maximum number of buffers to be by default allocated in the DPAA-Ethernet private port's
630 + buffer pool. One needn't normally modify this, as it has probably been tuned for performance
631 + already. This cannot be lower than DPAA_ETH_REFILL_THRESHOLD.
633 +config FSL_DPAA_ETH_REFILL_THRESHOLD
634 + int "Private bpool refill threshold"
635 + depends on FSL_SDK_DPAA_ETH
636 + range 32 FSL_DPAA_ETH_MAX_BUF_COUNT
639 + The DPAA-Ethernet driver will start replenishing buffer pools whose count
640 + falls below this threshold. This must be related to DPAA_ETH_MAX_BUF_COUNT. One needn't normally
641 + modify this value unless one has very specific performance reasons.
643 +config FSL_DPAA_CS_THRESHOLD_1G
644 + hex "Egress congestion threshold on 1G ports"
645 + depends on FSL_SDK_DPAA_ETH
646 + range 0x1000 0x10000000
647 + default "0x06000000"
649 + The size in bytes of the egress Congestion State notification threshold on 1G ports.
650 + The 1G dTSECs can quite easily be flooded by cores doing Tx in a tight loop
651 + (e.g. by sending UDP datagrams at "while(1) speed"),
652 + and the larger the frame size, the more acute the problem.
653 + So we have to find a balance between these factors:
654 + - avoiding the device staying congested for a prolonged time (risking
655 + the netdev watchdog to fire - see also the tx_timeout module param);
656 + - affecting performance of protocols such as TCP, which otherwise
657 + behave well under the congestion notification mechanism;
658 + - preventing the Tx cores from tightly-looping (as if the congestion
659 + threshold was too low to be effective);
660 + - running out of memory if the CS threshold is set too high.
662 +config FSL_DPAA_CS_THRESHOLD_10G
663 + hex "Egress congestion threshold on 10G ports"
664 + depends on FSL_SDK_DPAA_ETH
665 + range 0x1000 0x20000000
666 + default "0x10000000"
668 + The size in bytes of the egress Congestion State notification threshold on 10G ports.
670 +config FSL_DPAA_INGRESS_CS_THRESHOLD
671 + hex "Ingress congestion threshold on FMan ports"
672 + depends on FSL_SDK_DPAA_ETH
673 + default "0x10000000"
675 + The size in bytes of the ingress tail-drop threshold on FMan ports.
676 + Traffic piling up above this value will be rejected by QMan and discarded by FMan.
678 +config FSL_DPAA_ETH_DEBUGFS
679 + bool "DPAA Ethernet debugfs interface"
680 + depends on DEBUG_FS && FSL_SDK_DPAA_ETH
683 + This option compiles debugfs code for the DPAA Ethernet driver.
685 +config FSL_DPAA_ETH_DEBUG
686 + bool "DPAA Ethernet Debug Support"
687 + depends on FSL_SDK_DPAA_ETH
690 + This option compiles debug code for the DPAA Ethernet driver.
692 +config FSL_DPAA_DBG_LOOP
693 + bool "DPAA Ethernet Debug loopback"
694 + depends on FSL_DPAA_ETH_DEBUGFS && FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
697 + This option allows to divert all received traffic on a certain interface A towards a
698 + selected interface B. This option is used to benchmark the HW + Ethernet driver in
699 + isolation from the Linux networking stack. The loops are controlled by debugfs entries,
700 + one for each interface. By default all loops are disabled (target value is -1). I.e. to
701 + change the loop setting for interface 4 and divert all received traffic to interface 5
702 + write Tx interface number in the receive interface debugfs file:
703 + # cat /sys/kernel/debug/powerpc/fsl_dpa/eth4_loop
705 + # echo 5 > /sys/kernel/debug/powerpc/fsl_dpa/eth4_loop
706 + # cat /sys/kernel/debug/powerpc/fsl_dpa/eth4_loop
708 +endif # FSL_SDK_DPAA_ETH
709 diff --git a/drivers/net/ethernet/freescale/sdk_dpaa/Makefile b/drivers/net/ethernet/freescale/sdk_dpaa/Makefile
711 index 00000000..a0f4b190
713 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/Makefile
716 +# Makefile for the Freescale Ethernet controllers
718 +ccflags-y += -DVERSION=\"\"
720 +# Include netcomm SW specific definitions
721 +include $(srctree)/drivers/net/ethernet/freescale/sdk_fman/ncsw_config.mk
723 +ccflags-y += -I$(NET_DPA)
725 +obj-$(CONFIG_FSL_SDK_DPAA_ETH) += fsl_mac.o fsl_dpa.o
726 +obj-$(CONFIG_PTP_1588_CLOCK_DPAA) += dpaa_ptp.o
728 +fsl_dpa-objs += dpaa_ethtool.o dpaa_eth_sysfs.o dpaa_eth.o dpaa_eth_sg.o dpaa_eth_common.o
729 +ifeq ($(CONFIG_FSL_DPAA_DBG_LOOP),y)
730 +fsl_dpa-objs += dpaa_debugfs.o
732 +ifeq ($(CONFIG_FSL_DPAA_1588),y)
733 +fsl_dpa-objs += dpaa_1588.o
735 +ifeq ($(CONFIG_FSL_DPAA_CEETM),y)
736 +ccflags-y += -Idrivers/net/ethernet/freescale/sdk_fman/src/wrapper
737 +fsl_dpa-objs += dpaa_eth_ceetm.o
740 +fsl_mac-objs += mac.o mac-api.o
743 +ifeq ($(CONFIG_FSL_DPAA_ADVANCED_DRIVERS),y)
744 +obj-$(CONFIG_FSL_SDK_DPAA_ETH) += fsl_advanced.o
745 +obj-$(CONFIG_FSL_SDK_DPAA_ETH) += fsl_proxy.o
747 +fsl_advanced-objs += dpaa_eth_base.o
748 +# suport for multiple drivers per kernel module comes in kernel 3.14
749 +# so we are forced to generate several modules for the advanced drivers
750 +fsl_proxy-objs += dpaa_eth_proxy.o
752 +ifeq ($(CONFIG_FSL_DPAA_OFFLINE_PORTS),y)
753 +obj-$(CONFIG_FSL_SDK_DPAA_ETH) += fsl_oh.o
755 +fsl_oh-objs += offline_port.o
759 +# Needed by the tracing framework
760 +CFLAGS_dpaa_eth.o := -I$(src)
761 diff --git a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_1588.c b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_1588.c
763 index 00000000..3bf8cbca
765 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_1588.c
767 +/* Copyright (C) 2011 Freescale Semiconductor, Inc.
768 + * Copyright (C) 2009 IXXAT Automation, GmbH
770 + * DPAA Ethernet Driver -- IEEE 1588 interface functionality
772 + * This program is free software; you can redistribute it and/or modify
773 + * it under the terms of the GNU General Public License as published by
774 + * the Free Software Foundation; either version 2 of the License, or
775 + * (at your option) any later version.
777 + * This program is distributed in the hope that it will be useful,
778 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
779 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
780 + * GNU General Public License for more details.
782 + * You should have received a copy of the GNU General Public License along
783 + * with this program; if not, write to the Free Software Foundation, Inc.,
784 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
787 +#include <linux/io.h>
788 +#include <linux/device.h>
789 +#include <linux/fs.h>
790 +#include <linux/vmalloc.h>
791 +#include <linux/spinlock.h>
792 +#include <linux/ip.h>
793 +#include <linux/ipv6.h>
794 +#include <linux/udp.h>
795 +#include <asm/div64.h>
796 +#include "dpaa_eth.h"
797 +#include "dpaa_eth_common.h"
798 +#include "dpaa_1588.h"
801 +static int dpa_ptp_init_circ(struct dpa_ptp_circ_buf *ptp_buf, u32 size)
803 + struct circ_buf *circ_buf = &ptp_buf->circ_buf;
805 + circ_buf->buf = vmalloc(sizeof(struct dpa_ptp_data) * size);
806 + if (!circ_buf->buf)
809 + circ_buf->head = 0;
810 + circ_buf->tail = 0;
811 + ptp_buf->size = size;
812 + spin_lock_init(&ptp_buf->ptp_lock);
817 +static void dpa_ptp_reset_circ(struct dpa_ptp_circ_buf *ptp_buf, u32 size)
819 + struct circ_buf *circ_buf = &ptp_buf->circ_buf;
821 + circ_buf->head = 0;
822 + circ_buf->tail = 0;
823 + ptp_buf->size = size;
826 +static int dpa_ptp_insert(struct dpa_ptp_circ_buf *ptp_buf,
827 + struct dpa_ptp_data *data)
829 + struct circ_buf *circ_buf = &ptp_buf->circ_buf;
830 + int size = ptp_buf->size;
831 + struct dpa_ptp_data *tmp;
832 + unsigned long flags;
835 + spin_lock_irqsave(&ptp_buf->ptp_lock, flags);
837 + head = circ_buf->head;
838 + tail = circ_buf->tail;
840 + if (CIRC_SPACE(head, tail, size) <= 0)
841 + circ_buf->tail = (tail + 1) & (size - 1);
843 + tmp = (struct dpa_ptp_data *)(circ_buf->buf) + head;
844 + memcpy(tmp, data, sizeof(struct dpa_ptp_data));
846 + circ_buf->head = (head + 1) & (size - 1);
848 + spin_unlock_irqrestore(&ptp_buf->ptp_lock, flags);
853 +static int dpa_ptp_is_ident_match(struct dpa_ptp_ident *dst,
854 + struct dpa_ptp_ident *src)
858 + if ((dst->version != src->version) || (dst->msg_type != src->msg_type))
861 + if ((dst->netw_prot == src->netw_prot)
862 + || src->netw_prot == DPA_PTP_PROT_DONTCARE) {
863 + if (dst->seq_id != src->seq_id)
866 + ret = memcmp(dst->snd_port_id, src->snd_port_id,
867 + DPA_PTP_SOURCE_PORT_LENGTH);
877 +static int dpa_ptp_find_and_remove(struct dpa_ptp_circ_buf *ptp_buf,
878 + struct dpa_ptp_ident *ident,
879 + struct dpa_ptp_time *ts)
881 + struct circ_buf *circ_buf = &ptp_buf->circ_buf;
882 + int size = ptp_buf->size;
883 + int head, tail, idx;
884 + unsigned long flags;
885 + struct dpa_ptp_data *tmp, *tmp2;
886 + struct dpa_ptp_ident *tmp_ident;
888 + spin_lock_irqsave(&ptp_buf->ptp_lock, flags);
890 + head = circ_buf->head;
891 + tail = idx = circ_buf->tail;
893 + if (CIRC_CNT(head, tail, size) == 0) {
894 + spin_unlock_irqrestore(&ptp_buf->ptp_lock, flags);
898 + while (idx != head) {
899 + tmp = (struct dpa_ptp_data *)(circ_buf->buf) + idx;
900 + tmp_ident = &tmp->ident;
901 + if (dpa_ptp_is_ident_match(tmp_ident, ident))
903 + idx = (idx + 1) & (size - 1);
907 + spin_unlock_irqrestore(&ptp_buf->ptp_lock, flags);
911 + ts->sec = tmp->ts.sec;
912 + ts->nsec = tmp->ts.nsec;
915 + if (CIRC_CNT(idx, tail, size) > TS_ACCUMULATION_THRESHOLD) {
916 + tail = circ_buf->tail =
917 + (idx - TS_ACCUMULATION_THRESHOLD) & (size - 1);
920 + while (CIRC_CNT(idx, tail, size) > 0) {
921 + tmp = (struct dpa_ptp_data *)(circ_buf->buf) + idx;
922 + idx = (idx - 1) & (size - 1);
923 + tmp2 = (struct dpa_ptp_data *)(circ_buf->buf) + idx;
927 + circ_buf->tail = (tail + 1) & (size - 1);
929 + spin_unlock_irqrestore(&ptp_buf->ptp_lock, flags);
934 +/* Parse the PTP packets
936 + * The PTP header can be found in an IPv4 packet, IPv6 patcket or in
937 + * an IEEE802.3 ethernet frame. This function returns the position of
938 + * the PTP packet or NULL if no PTP found
940 +static u8 *dpa_ptp_parse_packet(struct sk_buff *skb, u16 *eth_type)
942 + u8 *pos = skb->data + ETH_ALEN + ETH_ALEN;
943 + u8 *ptp_loc = NULL;
945 + u32 access_len = ETH_ALEN + ETH_ALEN + DPA_ETYPE_LEN;
947 + struct udphdr *udph;
948 + struct ipv6hdr *ipv6h;
950 + /* when we can receive S/G frames we need to check the data we want to
951 + * access is in the linear skb buffer
953 + if (!pskb_may_pull(skb, access_len))
956 + *eth_type = *((u16 *)pos);
958 + /* Check if inner tag is here */
959 + if (*eth_type == ETH_P_8021Q) {
960 + access_len += DPA_VLAN_TAG_LEN;
962 + if (!pskb_may_pull(skb, access_len))
965 + pos += DPA_VLAN_TAG_LEN;
966 + *eth_type = *((u16 *)pos);
969 + pos += DPA_ETYPE_LEN;
971 + switch (*eth_type) {
972 + /* Transport of PTP over Ethernet */
976 + if (!pskb_may_pull(skb, access_len + PTP_OFFS_MSG_TYPE + 1))
979 + msg_type = *((u8 *)(ptp_loc + PTP_OFFS_MSG_TYPE)) & 0xf;
980 + if ((msg_type == PTP_MSGTYPE_SYNC)
981 + || (msg_type == PTP_MSGTYPE_DELREQ)
982 + || (msg_type == PTP_MSGTYPE_PDELREQ)
983 + || (msg_type == PTP_MSGTYPE_PDELRESP))
986 + /* Transport of PTP over IPv4 */
988 + iph = (struct iphdr *)pos;
989 + access_len += sizeof(struct iphdr);
991 + if (!pskb_may_pull(skb, access_len))
994 + if (ntohs(iph->protocol) != IPPROTO_UDP)
997 + access_len += iph->ihl * 4 - sizeof(struct iphdr) +
998 + sizeof(struct udphdr);
1000 + if (!pskb_may_pull(skb, access_len))
1003 + pos += iph->ihl * 4;
1004 + udph = (struct udphdr *)pos;
1005 + if (ntohs(udph->dest) != 319)
1007 + ptp_loc = pos + sizeof(struct udphdr);
1009 + /* Transport of PTP over IPv6 */
1011 + ipv6h = (struct ipv6hdr *)pos;
1013 + access_len += sizeof(struct ipv6hdr) + sizeof(struct udphdr);
1015 + if (ntohs(ipv6h->nexthdr) != IPPROTO_UDP)
1018 + pos += sizeof(struct ipv6hdr);
1019 + udph = (struct udphdr *)pos;
1020 + if (ntohs(udph->dest) != 319)
1022 + ptp_loc = pos + sizeof(struct udphdr);
1031 +static int dpa_ptp_store_stamp(const struct dpa_priv_s *priv,
1032 + struct sk_buff *skb, void *data, enum port_type rx_tx,
1033 + struct dpa_ptp_data *ptp_data)
1040 + ptp_loc = dpa_ptp_parse_packet(skb, ð_type);
1044 + switch (eth_type) {
1046 + ptp_data->ident.netw_prot = DPA_PTP_PROT_IPV4;
1049 + ptp_data->ident.netw_prot = DPA_PTP_PROT_IPV6;
1052 + ptp_data->ident.netw_prot = DPA_PTP_PROT_802_3;
1058 + if (!pskb_may_pull(skb, ptp_loc - skb->data + PTP_OFFS_SEQ_ID + 2))
1061 + ptp_data->ident.version = *(ptp_loc + PTP_OFFS_VER_PTP) & 0xf;
1062 + ptp_data->ident.msg_type = *(ptp_loc + PTP_OFFS_MSG_TYPE) & 0xf;
1063 + ptp_data->ident.seq_id = *((u16 *)(ptp_loc + PTP_OFFS_SEQ_ID));
1064 + memcpy(ptp_data->ident.snd_port_id, ptp_loc + PTP_OFFS_SRCPRTID,
1065 + DPA_PTP_SOURCE_PORT_LENGTH);
1067 + nsec = dpa_get_timestamp_ns(priv, rx_tx, data);
1068 + mod = do_div(nsec, NANOSEC_PER_SECOND);
1069 + ptp_data->ts.sec = nsec;
1070 + ptp_data->ts.nsec = mod;
1075 +void dpa_ptp_store_txstamp(const struct dpa_priv_s *priv,
1076 + struct sk_buff *skb, void *data)
1078 + struct dpa_ptp_tsu *tsu = priv->tsu;
1079 + struct dpa_ptp_data ptp_tx_data;
1081 + if (dpa_ptp_store_stamp(priv, skb, data, TX, &ptp_tx_data))
1084 + dpa_ptp_insert(&tsu->tx_timestamps, &ptp_tx_data);
1087 +void dpa_ptp_store_rxstamp(const struct dpa_priv_s *priv,
1088 + struct sk_buff *skb, void *data)
1090 + struct dpa_ptp_tsu *tsu = priv->tsu;
1091 + struct dpa_ptp_data ptp_rx_data;
1093 + if (dpa_ptp_store_stamp(priv, skb, data, RX, &ptp_rx_data))
1096 + dpa_ptp_insert(&tsu->rx_timestamps, &ptp_rx_data);
1099 +static uint8_t dpa_get_tx_timestamp(struct dpa_ptp_tsu *ptp_tsu,
1100 + struct dpa_ptp_ident *ident,
1101 + struct dpa_ptp_time *ts)
1103 + struct dpa_ptp_tsu *tsu = ptp_tsu;
1104 + struct dpa_ptp_time tmp;
1107 + flag = dpa_ptp_find_and_remove(&tsu->tx_timestamps, ident, &tmp);
1109 + ts->sec = tmp.sec;
1110 + ts->nsec = tmp.nsec;
1117 +static uint8_t dpa_get_rx_timestamp(struct dpa_ptp_tsu *ptp_tsu,
1118 + struct dpa_ptp_ident *ident,
1119 + struct dpa_ptp_time *ts)
1121 + struct dpa_ptp_tsu *tsu = ptp_tsu;
1122 + struct dpa_ptp_time tmp;
1125 + flag = dpa_ptp_find_and_remove(&tsu->rx_timestamps, ident, &tmp);
1127 + ts->sec = tmp.sec;
1128 + ts->nsec = tmp.nsec;
1135 +static void dpa_set_fiper_alarm(struct dpa_ptp_tsu *tsu,
1136 + struct dpa_ptp_time *cnt_time)
1138 + struct mac_device *mac_dev = tsu->dpa_priv->mac_dev;
1141 + if (mac_dev->fm_rtc_disable)
1142 + mac_dev->fm_rtc_disable(get_fm_handle(tsu->dpa_priv->net_dev));
1144 + /* TMR_FIPER1 will pulse every second after ALARM1 expired */
1145 + tmp = (u64)cnt_time->sec * NANOSEC_PER_SECOND + (u64)cnt_time->nsec;
1146 + fiper = NANOSEC_PER_SECOND - DPA_PTP_NOMINAL_FREQ_PERIOD_NS;
1147 + if (mac_dev->fm_rtc_set_alarm)
1148 + mac_dev->fm_rtc_set_alarm(get_fm_handle(tsu->dpa_priv->net_dev),
1150 + if (mac_dev->fm_rtc_set_fiper)
1151 + mac_dev->fm_rtc_set_fiper(get_fm_handle(tsu->dpa_priv->net_dev),
1154 + if (mac_dev->fm_rtc_enable)
1155 + mac_dev->fm_rtc_enable(get_fm_handle(tsu->dpa_priv->net_dev));
1158 +static void dpa_get_curr_cnt(struct dpa_ptp_tsu *tsu,
1159 + struct dpa_ptp_time *curr_time)
1161 + struct mac_device *mac_dev = tsu->dpa_priv->mac_dev;
1165 + if (mac_dev->fm_rtc_get_cnt)
1166 + mac_dev->fm_rtc_get_cnt(get_fm_handle(tsu->dpa_priv->net_dev),
1169 + mod = do_div(tmp, NANOSEC_PER_SECOND);
1170 + curr_time->sec = (u32)tmp;
1171 + curr_time->nsec = mod;
1174 +static void dpa_set_1588cnt(struct dpa_ptp_tsu *tsu,
1175 + struct dpa_ptp_time *cnt_time)
1177 + struct mac_device *mac_dev = tsu->dpa_priv->mac_dev;
1180 + tmp = (u64)cnt_time->sec * NANOSEC_PER_SECOND + (u64)cnt_time->nsec;
1182 + if (mac_dev->fm_rtc_set_cnt)
1183 + mac_dev->fm_rtc_set_cnt(get_fm_handle(tsu->dpa_priv->net_dev),
1186 + /* Restart fiper two seconds later */
1187 + cnt_time->sec += 2;
1188 + cnt_time->nsec = 0;
1189 + dpa_set_fiper_alarm(tsu, cnt_time);
1192 +static void dpa_get_drift(struct dpa_ptp_tsu *tsu, u32 *addend)
1194 + struct mac_device *mac_dev = tsu->dpa_priv->mac_dev;
1197 + if (mac_dev->fm_rtc_get_drift)
1198 + mac_dev->fm_rtc_get_drift(get_fm_handle(tsu->dpa_priv->net_dev),
1204 +static void dpa_set_drift(struct dpa_ptp_tsu *tsu, u32 addend)
1206 + struct mac_device *mac_dev = tsu->dpa_priv->mac_dev;
1208 + if (mac_dev->fm_rtc_set_drift)
1209 + mac_dev->fm_rtc_set_drift(get_fm_handle(tsu->dpa_priv->net_dev),
1213 +static void dpa_flush_timestamp(struct dpa_ptp_tsu *tsu)
1215 + dpa_ptp_reset_circ(&tsu->rx_timestamps, DEFAULT_PTP_RX_BUF_SZ);
1216 + dpa_ptp_reset_circ(&tsu->tx_timestamps, DEFAULT_PTP_TX_BUF_SZ);
1219 +int dpa_ioctl_1588(struct net_device *dev, struct ifreq *ifr, int cmd)
1221 + struct dpa_priv_s *priv = netdev_priv(dev);
1222 + struct dpa_ptp_tsu *tsu = priv->tsu;
1223 + struct mac_device *mac_dev = priv->mac_dev;
1224 + struct dpa_ptp_data ptp_data;
1225 + struct dpa_ptp_data *ptp_data_user;
1226 + struct dpa_ptp_time act_time;
1230 + if (!tsu || !tsu->valid)
1234 + case PTP_ENBL_TXTS_IOCTL:
1235 + tsu->hwts_tx_en_ioctl = 1;
1236 + if (mac_dev->fm_rtc_enable)
1237 + mac_dev->fm_rtc_enable(get_fm_handle(dev));
1238 + if (mac_dev->ptp_enable)
1239 + mac_dev->ptp_enable(mac_dev->get_mac_handle(mac_dev));
1241 + case PTP_DSBL_TXTS_IOCTL:
1242 + tsu->hwts_tx_en_ioctl = 0;
1243 + if (mac_dev->fm_rtc_disable)
1244 + mac_dev->fm_rtc_disable(get_fm_handle(dev));
1245 + if (mac_dev->ptp_disable)
1246 + mac_dev->ptp_disable(mac_dev->get_mac_handle(mac_dev));
1248 + case PTP_ENBL_RXTS_IOCTL:
1249 + tsu->hwts_rx_en_ioctl = 1;
1251 + case PTP_DSBL_RXTS_IOCTL:
1252 + tsu->hwts_rx_en_ioctl = 0;
1254 + case PTP_GET_RX_TIMESTAMP:
1255 + ptp_data_user = (struct dpa_ptp_data *)ifr->ifr_data;
1256 + if (copy_from_user(&ptp_data.ident,
1257 + &ptp_data_user->ident, sizeof(ptp_data.ident)))
1260 + if (dpa_get_rx_timestamp(tsu, &ptp_data.ident, &ptp_data.ts))
1263 + if (copy_to_user((void __user *)&ptp_data_user->ts,
1264 + &ptp_data.ts, sizeof(ptp_data.ts)))
1267 + case PTP_GET_TX_TIMESTAMP:
1268 + ptp_data_user = (struct dpa_ptp_data *)ifr->ifr_data;
1269 + if (copy_from_user(&ptp_data.ident,
1270 + &ptp_data_user->ident, sizeof(ptp_data.ident)))
1273 + if (dpa_get_tx_timestamp(tsu, &ptp_data.ident, &ptp_data.ts))
1276 + if (copy_to_user((void __user *)&ptp_data_user->ts,
1277 + &ptp_data.ts, sizeof(ptp_data.ts)))
1280 + case PTP_GET_TIME:
1281 + dpa_get_curr_cnt(tsu, &act_time);
1282 + if (copy_to_user(ifr->ifr_data, &act_time, sizeof(act_time)))
1285 + case PTP_SET_TIME:
1286 + if (copy_from_user(&act_time, ifr->ifr_data, sizeof(act_time)))
1288 + dpa_set_1588cnt(tsu, &act_time);
1291 + dpa_get_drift(tsu, &addend);
1292 + if (copy_to_user(ifr->ifr_data, &addend, sizeof(addend)))
1296 + if (copy_from_user(&addend, ifr->ifr_data, sizeof(addend)))
1298 + dpa_set_drift(tsu, addend);
1300 + case PTP_SET_FIPER_ALARM:
1301 + if (copy_from_user(&act_time, ifr->ifr_data, sizeof(act_time)))
1303 + dpa_set_fiper_alarm(tsu, &act_time);
1305 + case PTP_CLEANUP_TS:
1306 + dpa_flush_timestamp(tsu);
1315 +int dpa_ptp_init(struct dpa_priv_s *priv)
1317 + struct dpa_ptp_tsu *tsu;
1319 + /* Allocate memory for PTP structure */
1320 + tsu = kzalloc(sizeof(struct dpa_ptp_tsu), GFP_KERNEL);
1324 + tsu->valid = TRUE;
1325 + tsu->dpa_priv = priv;
1327 + dpa_ptp_init_circ(&tsu->rx_timestamps, DEFAULT_PTP_RX_BUF_SZ);
1328 + dpa_ptp_init_circ(&tsu->tx_timestamps, DEFAULT_PTP_TX_BUF_SZ);
1334 +EXPORT_SYMBOL(dpa_ptp_init);
1336 +void dpa_ptp_cleanup(struct dpa_priv_s *priv)
1338 + struct dpa_ptp_tsu *tsu = priv->tsu;
1340 + tsu->valid = FALSE;
1341 + vfree(tsu->rx_timestamps.circ_buf.buf);
1342 + vfree(tsu->tx_timestamps.circ_buf.buf);
1346 +EXPORT_SYMBOL(dpa_ptp_cleanup);
1347 diff --git a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_1588.h b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_1588.h
1348 new file mode 100644
1349 index 00000000..73390168
1351 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_1588.h
1353 +/* Copyright (C) 2011 Freescale Semiconductor, Inc.
1355 + * This program is free software; you can redistribute it and/or modify
1356 + * it under the terms of the GNU General Public License as published by
1357 + * the Free Software Foundation; either version 2 of the License, or
1358 + * (at your option) any later version.
1360 + * This program is distributed in the hope that it will be useful,
1361 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1362 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1363 + * GNU General Public License for more details.
1365 + * You should have received a copy of the GNU General Public License along
1366 + * with this program; if not, write to the Free Software Foundation, Inc.,
1367 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1370 +#ifndef __DPAA_1588_H__
1371 +#define __DPAA_1588_H__
1373 +#include <linux/netdevice.h>
1374 +#include <linux/etherdevice.h>
1375 +#include <linux/circ_buf.h>
1376 +#include <linux/fsl_qman.h>
1378 +#define DEFAULT_PTP_RX_BUF_SZ 256
1379 +#define DEFAULT_PTP_TX_BUF_SZ 256
1381 +/* 1588 private ioctl calls */
1382 +#define PTP_ENBL_TXTS_IOCTL SIOCDEVPRIVATE
1383 +#define PTP_DSBL_TXTS_IOCTL (SIOCDEVPRIVATE + 1)
1384 +#define PTP_ENBL_RXTS_IOCTL (SIOCDEVPRIVATE + 2)
1385 +#define PTP_DSBL_RXTS_IOCTL (SIOCDEVPRIVATE + 3)
1386 +#define PTP_GET_TX_TIMESTAMP (SIOCDEVPRIVATE + 4)
1387 +#define PTP_GET_RX_TIMESTAMP (SIOCDEVPRIVATE + 5)
1388 +#define PTP_SET_TIME (SIOCDEVPRIVATE + 6)
1389 +#define PTP_GET_TIME (SIOCDEVPRIVATE + 7)
1390 +#define PTP_SET_FIPER_ALARM (SIOCDEVPRIVATE + 8)
1391 +#define PTP_SET_ADJ (SIOCDEVPRIVATE + 9)
1392 +#define PTP_GET_ADJ (SIOCDEVPRIVATE + 10)
1393 +#define PTP_CLEANUP_TS (SIOCDEVPRIVATE + 11)
1395 +/* PTP V2 message type */
1397 + PTP_MSGTYPE_SYNC = 0x0,
1398 + PTP_MSGTYPE_DELREQ = 0x1,
1399 + PTP_MSGTYPE_PDELREQ = 0x2,
1400 + PTP_MSGTYPE_PDELRESP = 0x3,
1401 + PTP_MSGTYPE_FLWUP = 0x8,
1402 + PTP_MSGTYPE_DELRESP = 0x9,
1403 + PTP_MSGTYPE_PDELRES_FLWUP = 0xA,
1404 + PTP_MSGTYPE_ANNOUNCE = 0xB,
1405 + PTP_MSGTYPE_SGNLNG = 0xC,
1406 + PTP_MSGTYPE_MNGMNT = 0xD,
1409 +/* Byte offset of data in the PTP V2 headers */
1410 +#define PTP_OFFS_MSG_TYPE 0
1411 +#define PTP_OFFS_VER_PTP 1
1412 +#define PTP_OFFS_MSG_LEN 2
1413 +#define PTP_OFFS_DOM_NMB 4
1414 +#define PTP_OFFS_FLAGS 6
1415 +#define PTP_OFFS_CORFIELD 8
1416 +#define PTP_OFFS_SRCPRTID 20
1417 +#define PTP_OFFS_SEQ_ID 30
1418 +#define PTP_OFFS_CTRL 32
1419 +#define PTP_OFFS_LOGMEAN 33
1421 +#define PTP_IP_OFFS 14
1422 +#define PTP_UDP_OFFS 34
1423 +#define PTP_HEADER_OFFS 42
1424 +#define PTP_MSG_TYPE_OFFS (PTP_HEADER_OFFS + PTP_OFFS_MSG_TYPE)
1425 +#define PTP_SPORT_ID_OFFS (PTP_HEADER_OFFS + PTP_OFFS_SRCPRTID)
1426 +#define PTP_SEQ_ID_OFFS (PTP_HEADER_OFFS + PTP_OFFS_SEQ_ID)
1427 +#define PTP_CTRL_OFFS (PTP_HEADER_OFFS + PTP_OFFS_CTRL)
1429 +/* 1588-2008 network protocol enumeration values */
1430 +#define DPA_PTP_PROT_IPV4 1
1431 +#define DPA_PTP_PROT_IPV6 2
1432 +#define DPA_PTP_PROT_802_3 3
1433 +#define DPA_PTP_PROT_DONTCARE 0xFFFF
1435 +#define DPA_PTP_SOURCE_PORT_LENGTH 10
1436 +#define DPA_PTP_HEADER_SZE 34
1437 +#define DPA_ETYPE_LEN 2
1438 +#define DPA_VLAN_TAG_LEN 4
1439 +#define NANOSEC_PER_SECOND 1000000000
1441 +/* The threshold between the current found one and the oldest one */
1442 +#define TS_ACCUMULATION_THRESHOLD 50
1444 +/* Struct needed to identify a timestamp */
1445 +struct dpa_ptp_ident {
1450 + u8 snd_port_id[DPA_PTP_SOURCE_PORT_LENGTH];
1453 +/* Timestamp format in 1588-2008 */
1454 +struct dpa_ptp_time {
1455 + u64 sec; /* just 48 bit used */
1459 +/* needed for timestamp data over ioctl */
1460 +struct dpa_ptp_data {
1461 + struct dpa_ptp_ident ident;
1462 + struct dpa_ptp_time ts;
1465 +struct dpa_ptp_circ_buf {
1466 + struct circ_buf circ_buf;
1468 + spinlock_t ptp_lock;
1471 +/* PTP TSU control structure */
1472 +struct dpa_ptp_tsu {
1473 + struct dpa_priv_s *dpa_priv;
1475 + struct dpa_ptp_circ_buf rx_timestamps;
1476 + struct dpa_ptp_circ_buf tx_timestamps;
1478 + /* HW timestamping over ioctl enabled flag */
1479 + int hwts_tx_en_ioctl;
1480 + int hwts_rx_en_ioctl;
1483 +extern int dpa_ptp_init(struct dpa_priv_s *priv);
1484 +extern void dpa_ptp_cleanup(struct dpa_priv_s *priv);
1485 +extern void dpa_ptp_store_txstamp(const struct dpa_priv_s *priv,
1486 + struct sk_buff *skb, void *data);
1487 +extern void dpa_ptp_store_rxstamp(const struct dpa_priv_s *priv,
1488 + struct sk_buff *skb, void *data);
1489 +extern int dpa_ioctl_1588(struct net_device *dev, struct ifreq *ifr, int cmd);
1491 diff --git a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_debugfs.c b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_debugfs.c
1492 new file mode 100644
1493 index 00000000..25d9f5f1
1495 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_debugfs.c
1497 +/* Copyright 2008-2013 Freescale Semiconductor Inc.
1499 + * Redistribution and use in source and binary forms, with or without
1500 + * modification, are permitted provided that the following conditions are met:
1501 + * * Redistributions of source code must retain the above copyright
1502 + * notice, this list of conditions and the following disclaimer.
1503 + * * Redistributions in binary form must reproduce the above copyright
1504 + * notice, this list of conditions and the following disclaimer in the
1505 + * documentation and/or other materials provided with the distribution.
1506 + * * Neither the name of Freescale Semiconductor nor the
1507 + * names of its contributors may be used to endorse or promote products
1508 + * derived from this software without specific prior written permission.
1511 + * ALTERNATIVELY, this software may be distributed under the terms of the
1512 + * GNU General Public License ("GPL") as published by the Free Software
1513 + * Foundation, either version 2 of that License or (at your option) any
1516 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
1517 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1518 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1519 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
1520 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1521 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1522 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1523 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1524 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1525 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1528 +#include <linux/module.h>
1529 +#include <linux/fsl_qman.h> /* struct qm_mcr_querycgr */
1530 +#include <linux/debugfs.h>
1531 +#include "dpaa_debugfs.h"
1532 +#include "dpaa_eth.h" /* struct dpa_priv_s, dpa_percpu_priv_s, dpa_bp */
1534 +#define DPA_DEBUGFS_DESCRIPTION "FSL DPAA Ethernet debugfs entries"
1535 +#define DPA_ETH_DEBUGFS_ROOT "fsl_dpa"
1537 +static struct dentry *dpa_debugfs_root;
1539 +static int __cold dpa_debugfs_loop_open(struct inode *inode, struct file *file);
1540 +static ssize_t dpa_loop_write(struct file *f,
1541 + const char __user *buf, size_t count, loff_t *off);
1543 +static const struct file_operations dpa_debugfs_lp_fops = {
1544 + .open = dpa_debugfs_loop_open,
1545 + .write = dpa_loop_write,
1547 + .llseek = seq_lseek,
1548 + .release = single_release,
1551 +static int dpa_debugfs_loop_show(struct seq_file *file, void *offset)
1553 + struct dpa_priv_s *priv;
1555 + BUG_ON(offset == NULL);
1557 + priv = netdev_priv((struct net_device *)file->private);
1558 + seq_printf(file, "%d->%d\n", priv->loop_id, priv->loop_to);
1563 +static int user_input_convert(const char __user *user_buf, size_t count,
1568 + if (count > sizeof(buf) - 1)
1570 + if (copy_from_user(buf, user_buf, count))
1572 + buf[count] = '\0';
1573 + if (kstrtol(buf, 0, val))
1578 +static ssize_t dpa_loop_write(struct file *f,
1579 + const char __user *buf, size_t count, loff_t *off)
1581 + struct dpa_priv_s *priv;
1582 + struct net_device *netdev;
1583 + struct seq_file *sf;
1587 + ret = user_input_convert(buf, count, &val);
1591 + sf = (struct seq_file *)f->private_data;
1592 + netdev = (struct net_device *)sf->private;
1593 + priv = netdev_priv(netdev);
1595 + priv->loop_to = ((val < 0) || (val > 20)) ? -1 : val;
1600 +static int __cold dpa_debugfs_loop_open(struct inode *inode, struct file *file)
1603 + const struct net_device *net_dev;
1605 + _errno = single_open(file, dpa_debugfs_loop_show, inode->i_private);
1606 + if (unlikely(_errno < 0)) {
1607 + net_dev = (struct net_device *)inode->i_private;
1609 + if (netif_msg_drv((struct dpa_priv_s *)netdev_priv(net_dev)))
1610 + netdev_err(net_dev, "single_open() = %d\n",
1618 +int dpa_netdev_debugfs_create(struct net_device *net_dev)
1620 + struct dpa_priv_s *priv = netdev_priv(net_dev);
1622 + char loop_file_name[100];
1624 + if (unlikely(dpa_debugfs_root == NULL)) {
1625 + pr_err(KBUILD_MODNAME ": %s:%hu:%s(): \t%s\n",
1626 + KBUILD_BASENAME".c", __LINE__, __func__,
1627 + "root debugfs missing, possible module ordering issue");
1631 + sprintf(loop_file_name, "eth%d_loop", ++cnt);
1632 + priv->debugfs_loop_file = debugfs_create_file(loop_file_name,
1636 + &dpa_debugfs_lp_fops);
1637 + if (unlikely(priv->debugfs_loop_file == NULL)) {
1638 + netdev_err(net_dev, "debugfs_create_file(%s/%s)",
1639 + dpa_debugfs_root->d_iname,
1647 +void dpa_netdev_debugfs_remove(struct net_device *net_dev)
1649 + struct dpa_priv_s *priv = netdev_priv(net_dev);
1651 + debugfs_remove(priv->debugfs_loop_file);
1654 +int __init dpa_debugfs_module_init(void)
1658 + pr_info(KBUILD_MODNAME ": " DPA_DEBUGFS_DESCRIPTION "\n");
1660 + dpa_debugfs_root = debugfs_create_dir(DPA_ETH_DEBUGFS_ROOT, NULL);
1662 + if (unlikely(dpa_debugfs_root == NULL)) {
1664 + pr_err(KBUILD_MODNAME ": %s:%hu:%s():\n",
1665 + KBUILD_BASENAME".c", __LINE__, __func__);
1666 + pr_err("\tdebugfs_create_dir(%s/"KBUILD_MODNAME") = %d\n",
1667 + DPA_ETH_DEBUGFS_ROOT, _errno);
1673 +void __exit dpa_debugfs_module_exit(void)
1675 + debugfs_remove(dpa_debugfs_root);
1677 diff --git a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_debugfs.h b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_debugfs.h
1678 new file mode 100644
1679 index 00000000..63d35427
1681 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_debugfs.h
1683 +/* Copyright 2008-2013 Freescale Semiconductor Inc.
1685 + * Redistribution and use in source and binary forms, with or without
1686 + * modification, are permitted provided that the following conditions are met:
1687 + * * Redistributions of source code must retain the above copyright
1688 + * notice, this list of conditions and the following disclaimer.
1689 + * * Redistributions in binary form must reproduce the above copyright
1690 + * notice, this list of conditions and the following disclaimer in the
1691 + * documentation and/or other materials provided with the distribution.
1692 + * * Neither the name of Freescale Semiconductor nor the
1693 + * names of its contributors may be used to endorse or promote products
1694 + * derived from this software without specific prior written permission.
1697 + * ALTERNATIVELY, this software may be distributed under the terms of the
1698 + * GNU General Public License ("GPL") as published by the Free Software
1699 + * Foundation, either version 2 of that License or (at your option) any
1702 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
1703 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1704 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1705 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
1706 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1707 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1708 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1709 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1710 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1711 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1714 +#ifndef DPAA_DEBUGFS_H_
1715 +#define DPAA_DEBUGFS_H_
1717 +#include <linux/netdevice.h>
1718 +#include <linux/dcache.h> /* struct dentry needed in dpaa_eth.h */
1720 +int dpa_netdev_debugfs_create(struct net_device *net_dev);
1721 +void dpa_netdev_debugfs_remove(struct net_device *net_dev);
1722 +int __init dpa_debugfs_module_init(void);
1723 +void __exit dpa_debugfs_module_exit(void);
1725 +#endif /* DPAA_DEBUGFS_H_ */
1726 diff --git a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
1727 new file mode 100644
1728 index 00000000..7026f916
1730 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
1732 +/* Copyright 2008-2013 Freescale Semiconductor Inc.
1734 + * Redistribution and use in source and binary forms, with or without
1735 + * modification, are permitted provided that the following conditions are met:
1736 + * * Redistributions of source code must retain the above copyright
1737 + * notice, this list of conditions and the following disclaimer.
1738 + * * Redistributions in binary form must reproduce the above copyright
1739 + * notice, this list of conditions and the following disclaimer in the
1740 + * documentation and/or other materials provided with the distribution.
1741 + * * Neither the name of Freescale Semiconductor nor the
1742 + * names of its contributors may be used to endorse or promote products
1743 + * derived from this software without specific prior written permission.
1746 + * ALTERNATIVELY, this software may be distributed under the terms of the
1747 + * GNU General Public License ("GPL") as published by the Free Software
1748 + * Foundation, either version 2 of that License or (at your option) any
1751 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
1752 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1753 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1754 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
1755 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1756 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1757 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1758 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1759 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1760 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1763 +#ifdef CONFIG_FSL_DPAA_ETH_DEBUG
1764 +#define pr_fmt(fmt) \
1765 + KBUILD_MODNAME ": %s:%hu:%s() " fmt, \
1766 + KBUILD_BASENAME".c", __LINE__, __func__
1768 +#define pr_fmt(fmt) \
1769 + KBUILD_MODNAME ": " fmt
1772 +#include <linux/init.h>
1773 +#include <linux/module.h>
1774 +#include <linux/of_mdio.h>
1775 +#include <linux/of_net.h>
1776 +#include <linux/kthread.h>
1777 +#include <linux/io.h>
1778 +#include <linux/if_arp.h> /* arp_hdr_len() */
1779 +#include <linux/if_vlan.h> /* VLAN_HLEN */
1780 +#include <linux/icmp.h> /* struct icmphdr */
1781 +#include <linux/ip.h> /* struct iphdr */
1782 +#include <linux/ipv6.h> /* struct ipv6hdr */
1783 +#include <linux/udp.h> /* struct udphdr */
1784 +#include <linux/tcp.h> /* struct tcphdr */
1785 +#include <linux/net.h> /* net_ratelimit() */
1786 +#include <linux/if_ether.h> /* ETH_P_IP and ETH_P_IPV6 */
1787 +#include <linux/highmem.h>
1788 +#include <linux/percpu.h>
1789 +#include <linux/dma-mapping.h>
1790 +#include <linux/fsl_bman.h>
1791 +#ifdef CONFIG_SOC_BUS
1792 +#include <linux/sys_soc.h> /* soc_device_match */
1795 +#include "fsl_fman.h"
1796 +#include "fm_ext.h"
1797 +#include "fm_port_ext.h"
1800 +#include "dpaa_eth.h"
1801 +#include "dpaa_eth_common.h"
1802 +#ifdef CONFIG_FSL_DPAA_DBG_LOOP
1803 +#include "dpaa_debugfs.h"
1804 +#endif /* CONFIG_FSL_DPAA_DBG_LOOP */
1806 +/* CREATE_TRACE_POINTS only needs to be defined once. Other dpa files
1807 + * using trace events only need to #include <trace/events/sched.h>
1809 +#define CREATE_TRACE_POINTS
1810 +#include "dpaa_eth_trace.h"
1812 +#define DPA_NAPI_WEIGHT 64
1814 +/* Valid checksum indication */
1815 +#define DPA_CSUM_VALID 0xFFFF
1817 +#define DPA_DESCRIPTION "FSL DPAA Ethernet driver"
1819 +MODULE_LICENSE("Dual BSD/GPL");
1821 +MODULE_AUTHOR("Andy Fleming <afleming@freescale.com>");
1823 +MODULE_DESCRIPTION(DPA_DESCRIPTION);
1825 +static uint8_t debug = -1;
1826 +module_param(debug, byte, S_IRUGO);
1827 +MODULE_PARM_DESC(debug, "Module/Driver verbosity level");
1829 +/* This has to work in tandem with the DPA_CS_THRESHOLD_xxx values. */
1830 +static uint16_t tx_timeout = 1000;
1831 +module_param(tx_timeout, ushort, S_IRUGO);
1832 +MODULE_PARM_DESC(tx_timeout, "The Tx timeout in ms");
1834 +static const char rtx[][3] = {
1840 +bool dpaa_errata_a010022;
1841 +EXPORT_SYMBOL(dpaa_errata_a010022);
1846 +#define DPAA_ETH_MAX_PAD (L1_CACHE_BYTES * 8)
1848 +static uint8_t dpa_priv_common_bpid;
1850 +#ifdef CONFIG_FSL_DPAA_DBG_LOOP
1851 +struct net_device *dpa_loop_netdevs[20];
1856 +static int dpaa_suspend(struct device *dev)
1858 + struct net_device *net_dev;
1859 + struct dpa_priv_s *priv;
1860 + struct mac_device *mac_dev;
1863 + net_dev = dev_get_drvdata(dev);
1865 + if (net_dev->flags & IFF_UP) {
1866 + priv = netdev_priv(net_dev);
1867 + mac_dev = priv->mac_dev;
1869 + if (priv->wol & DPAA_WOL_MAGIC) {
1870 + err = priv->mac_dev->set_wol(mac_dev->port_dev[RX],
1871 + priv->mac_dev->get_mac_handle(mac_dev), true);
1873 + netdev_err(net_dev, "set_wol() = %d\n", err);
1874 + goto set_wol_failed;
1878 + err = fm_port_suspend(mac_dev->port_dev[RX]);
1880 + netdev_err(net_dev, "fm_port_suspend(RX) = %d\n", err);
1881 + goto rx_port_suspend_failed;
1884 + err = fm_port_suspend(mac_dev->port_dev[TX]);
1886 + netdev_err(net_dev, "fm_port_suspend(TX) = %d\n", err);
1887 + goto tx_port_suspend_failed;
1893 +tx_port_suspend_failed:
1894 + fm_port_resume(mac_dev->port_dev[RX]);
1895 +rx_port_suspend_failed:
1896 + if (priv->wol & DPAA_WOL_MAGIC) {
1897 + priv->mac_dev->set_wol(mac_dev->port_dev[RX],
1898 + priv->mac_dev->get_mac_handle(mac_dev), false);
1904 +static int dpaa_resume(struct device *dev)
1906 + struct net_device *net_dev;
1907 + struct dpa_priv_s *priv;
1908 + struct mac_device *mac_dev;
1911 + net_dev = dev_get_drvdata(dev);
1913 + if (net_dev->flags & IFF_UP) {
1914 + priv = netdev_priv(net_dev);
1915 + mac_dev = priv->mac_dev;
1917 + err = fm_mac_resume(mac_dev->get_mac_handle(mac_dev));
1919 + netdev_err(net_dev, "fm_mac_resume = %d\n", err);
1920 + goto resume_failed;
1923 + err = fm_port_resume(mac_dev->port_dev[TX]);
1925 + netdev_err(net_dev, "fm_port_resume(TX) = %d\n", err);
1926 + goto resume_failed;
1929 + err = fm_port_resume(mac_dev->port_dev[RX]);
1931 + netdev_err(net_dev, "fm_port_resume(RX) = %d\n", err);
1932 + goto resume_failed;
1935 + if (priv->wol & DPAA_WOL_MAGIC) {
1936 + err = priv->mac_dev->set_wol(mac_dev->port_dev[RX],
1937 + priv->mac_dev->get_mac_handle(mac_dev), false);
1939 + netdev_err(net_dev, "set_wol() = %d\n", err);
1940 + goto resume_failed;
1951 +static const struct dev_pm_ops dpaa_pm_ops = {
1952 + .suspend = dpaa_suspend,
1953 + .resume = dpaa_resume,
1956 +#define DPAA_PM_OPS (&dpaa_pm_ops)
1958 +#else /* CONFIG_PM */
1960 +#define DPAA_PM_OPS NULL
1962 +#endif /* CONFIG_PM */
1964 +/* Checks whether the checksum field in Parse Results array is valid
1965 + * (equals 0xFFFF) and increments the .cse counter otherwise
1968 +dpa_csum_validation(const struct dpa_priv_s *priv,
1969 + struct dpa_percpu_priv_s *percpu_priv,
1970 + const struct qm_fd *fd)
1972 + dma_addr_t addr = qm_fd_addr(fd);
1973 + struct dpa_bp *dpa_bp = priv->dpa_bp;
1974 + void *frm = phys_to_virt(addr);
1975 + fm_prs_result_t *parse_result;
1977 + if (unlikely(!frm))
1980 + dma_sync_single_for_cpu(dpa_bp->dev, addr, DPA_RX_PRIV_DATA_SIZE +
1981 + DPA_PARSE_RESULTS_SIZE, DMA_BIDIRECTIONAL);
1983 + parse_result = (fm_prs_result_t *)(frm + DPA_RX_PRIV_DATA_SIZE);
1985 + if (parse_result->cksum != DPA_CSUM_VALID)
1986 + percpu_priv->rx_errors.cse++;
1989 +static void _dpa_rx_error(struct net_device *net_dev,
1990 + const struct dpa_priv_s *priv,
1991 + struct dpa_percpu_priv_s *percpu_priv,
1992 + const struct qm_fd *fd,
1995 + /* limit common, possibly innocuous Rx FIFO Overflow errors'
1996 + * interference with zero-loss convergence benchmark results.
1998 + if (likely(fd->status & FM_FD_STAT_ERR_PHYSICAL))
1999 + pr_warn_once("fsl-dpa: non-zero error counters in fman statistics (sysfs)\n");
2001 + if (netif_msg_hw(priv) && net_ratelimit())
2002 + netdev_dbg(net_dev, "Err FD status = 0x%08x\n",
2003 + fd->status & FM_FD_STAT_RX_ERRORS);
2004 +#ifdef CONFIG_FSL_DPAA_HOOKS
2005 + if (dpaa_eth_hooks.rx_error &&
2006 + dpaa_eth_hooks.rx_error(net_dev, fd, fqid) == DPAA_ETH_STOLEN)
2007 + /* it's up to the hook to perform resource cleanup */
2010 + percpu_priv->stats.rx_errors++;
2012 + if (fd->status & FM_PORT_FRM_ERR_DMA)
2013 + percpu_priv->rx_errors.dme++;
2014 + if (fd->status & FM_PORT_FRM_ERR_PHYSICAL)
2015 + percpu_priv->rx_errors.fpe++;
2016 + if (fd->status & FM_PORT_FRM_ERR_SIZE)
2017 + percpu_priv->rx_errors.fse++;
2018 + if (fd->status & FM_PORT_FRM_ERR_PRS_HDR_ERR)
2019 + percpu_priv->rx_errors.phe++;
2020 + if (fd->status & FM_FD_STAT_L4CV)
2021 + dpa_csum_validation(priv, percpu_priv, fd);
2023 + dpa_fd_release(net_dev, fd);
2026 +static void _dpa_tx_error(struct net_device *net_dev,
2027 + const struct dpa_priv_s *priv,
2028 + struct dpa_percpu_priv_s *percpu_priv,
2029 + const struct qm_fd *fd,
2032 + struct sk_buff *skb;
2034 + if (netif_msg_hw(priv) && net_ratelimit())
2035 + netdev_warn(net_dev, "FD status = 0x%08x\n",
2036 + fd->status & FM_FD_STAT_TX_ERRORS);
2037 +#ifdef CONFIG_FSL_DPAA_HOOKS
2038 + if (dpaa_eth_hooks.tx_error &&
2039 + dpaa_eth_hooks.tx_error(net_dev, fd, fqid) == DPAA_ETH_STOLEN)
2040 + /* now the hook must ensure proper cleanup */
2043 + percpu_priv->stats.tx_errors++;
2045 + /* If we intended the buffers from this frame to go into the bpools
2046 + * when the FMan transmit was done, we need to put it in manually.
2048 + if (fd->bpid != 0xff) {
2049 + dpa_fd_release(net_dev, fd);
2053 + skb = _dpa_cleanup_tx_fd(priv, fd);
2054 + dev_kfree_skb(skb);
2057 +/* Helper function to factor out frame validation logic on all Rx paths. Its
2058 + * purpose is to extract from the Parse Results structure information about
2059 + * the integrity of the frame, its checksum, the length of the parsed headers
2060 + * and whether the frame is suitable for GRO.
2062 + * Assumes no parser errors, since any error frame is dropped before this
2063 + * function is called.
2065 + * @skb will have its ip_summed field overwritten;
2066 + * @use_gro will only be written with 0, if the frame is definitely not
2067 + * GRO-able; otherwise, it will be left unchanged;
2068 + * @hdr_size will be written with a safe value, at least the size of the
2069 + * headers' length.
2071 +void __hot _dpa_process_parse_results(const fm_prs_result_t *parse_results,
2072 + const struct qm_fd *fd,
2073 + struct sk_buff *skb, int *use_gro)
2075 + if (fd->status & FM_FD_STAT_L4CV) {
2076 + /* The parser has run and performed L4 checksum validation.
2077 + * We know there were no parser errors (and implicitly no
2078 + * L4 csum error), otherwise we wouldn't be here.
2080 + skb->ip_summed = CHECKSUM_UNNECESSARY;
2082 + /* Don't go through GRO for certain types of traffic that
2083 + * we know are not GRO-able, such as dgram-based protocols.
2084 + * In the worst-case scenarios, such as small-pkt terminating
2085 + * UDP, the extra GRO processing would be overkill.
2087 + * The only protocol the Parser supports that is also GRO-able
2088 + * is currently TCP.
2090 + if (!fm_l4_frame_is_tcp(parse_results))
2096 + /* We're here because either the parser didn't run or the L4 checksum
2097 + * was not verified. This may include the case of a UDP frame with
2098 + * checksum zero or an L4 proto other than TCP/UDP
2100 + skb->ip_summed = CHECKSUM_NONE;
2102 + /* Bypass GRO for unknown traffic or if no PCDs are applied */
2106 +int dpaa_eth_poll(struct napi_struct *napi, int budget)
2108 + struct dpa_napi_portal *np =
2109 + container_of(napi, struct dpa_napi_portal, napi);
2111 + int cleaned = qman_p_poll_dqrr(np->p, budget);
2113 + if (cleaned < budget) {
2115 + napi_complete(napi);
2116 + tmp = qman_p_irqsource_add(np->p, QM_PIRQ_DQRI);
2122 +EXPORT_SYMBOL(dpaa_eth_poll);
2124 +static void __hot _dpa_tx_conf(struct net_device *net_dev,
2125 + const struct dpa_priv_s *priv,
2126 + struct dpa_percpu_priv_s *percpu_priv,
2127 + const struct qm_fd *fd,
2130 + struct sk_buff *skb;
2132 + /* do we need the timestamp for the error frames? */
2134 + if (unlikely(fd->status & FM_FD_STAT_TX_ERRORS) != 0) {
2135 + if (netif_msg_hw(priv) && net_ratelimit())
2136 + netdev_warn(net_dev, "FD status = 0x%08x\n",
2137 + fd->status & FM_FD_STAT_TX_ERRORS);
2139 + percpu_priv->stats.tx_errors++;
2142 + /* hopefully we need not get the timestamp before the hook */
2143 +#ifdef CONFIG_FSL_DPAA_HOOKS
2144 + if (dpaa_eth_hooks.tx_confirm && dpaa_eth_hooks.tx_confirm(net_dev,
2145 + fd, fqid) == DPAA_ETH_STOLEN)
2146 + /* it's the hook that must now perform cleanup */
2149 + /* This might not perfectly reflect the reality, if the core dequeuing
2150 + * the Tx confirmation is different from the one that did the enqueue,
2151 + * but at least it'll show up in the total count.
2153 + percpu_priv->tx_confirm++;
2155 + skb = _dpa_cleanup_tx_fd(priv, fd);
2157 + dev_kfree_skb(skb);
2160 +enum qman_cb_dqrr_result
2161 +priv_rx_error_dqrr(struct qman_portal *portal,
2162 + struct qman_fq *fq,
2163 + const struct qm_dqrr_entry *dq)
2165 + struct net_device *net_dev;
2166 + struct dpa_priv_s *priv;
2167 + struct dpa_percpu_priv_s *percpu_priv;
2170 + net_dev = ((struct dpa_fq *)fq)->net_dev;
2171 + priv = netdev_priv(net_dev);
2173 + percpu_priv = raw_cpu_ptr(priv->percpu_priv);
2174 + count_ptr = raw_cpu_ptr(priv->dpa_bp->percpu_count);
2176 + if (dpaa_eth_napi_schedule(percpu_priv, portal))
2177 + return qman_cb_dqrr_stop;
2179 + if (unlikely(dpaa_eth_refill_bpools(priv->dpa_bp, count_ptr)))
2180 + /* Unable to refill the buffer pool due to insufficient
2181 + * system memory. Just release the frame back into the pool,
2182 + * otherwise we'll soon end up with an empty buffer pool.
2184 + dpa_fd_release(net_dev, &dq->fd);
2186 + _dpa_rx_error(net_dev, priv, percpu_priv, &dq->fd, fq->fqid);
2188 + return qman_cb_dqrr_consume;
2192 +enum qman_cb_dqrr_result __hot
2193 +priv_rx_default_dqrr(struct qman_portal *portal,
2194 + struct qman_fq *fq,
2195 + const struct qm_dqrr_entry *dq)
2197 + struct net_device *net_dev;
2198 + struct dpa_priv_s *priv;
2199 + struct dpa_percpu_priv_s *percpu_priv;
2201 + struct dpa_bp *dpa_bp;
2203 + net_dev = ((struct dpa_fq *)fq)->net_dev;
2204 + priv = netdev_priv(net_dev);
2205 + dpa_bp = priv->dpa_bp;
2207 + /* Trace the Rx fd */
2208 + trace_dpa_rx_fd(net_dev, fq, &dq->fd);
2210 + /* IRQ handler, non-migratable; safe to use raw_cpu_ptr here */
2211 + percpu_priv = raw_cpu_ptr(priv->percpu_priv);
2212 + count_ptr = raw_cpu_ptr(dpa_bp->percpu_count);
2214 + if (unlikely(dpaa_eth_napi_schedule(percpu_priv, portal)))
2215 + return qman_cb_dqrr_stop;
2217 + /* Vale of plenty: make sure we didn't run out of buffers */
2219 + if (unlikely(dpaa_eth_refill_bpools(dpa_bp, count_ptr)))
2220 + /* Unable to refill the buffer pool due to insufficient
2221 + * system memory. Just release the frame back into the pool,
2222 + * otherwise we'll soon end up with an empty buffer pool.
2224 + dpa_fd_release(net_dev, &dq->fd);
2226 + _dpa_rx(net_dev, portal, priv, percpu_priv, &dq->fd, fq->fqid,
2229 + return qman_cb_dqrr_consume;
2232 +enum qman_cb_dqrr_result
2233 +priv_tx_conf_error_dqrr(struct qman_portal *portal,
2234 + struct qman_fq *fq,
2235 + const struct qm_dqrr_entry *dq)
2237 + struct net_device *net_dev;
2238 + struct dpa_priv_s *priv;
2239 + struct dpa_percpu_priv_s *percpu_priv;
2241 + net_dev = ((struct dpa_fq *)fq)->net_dev;
2242 + priv = netdev_priv(net_dev);
2244 + percpu_priv = raw_cpu_ptr(priv->percpu_priv);
2246 + if (dpaa_eth_napi_schedule(percpu_priv, portal))
2247 + return qman_cb_dqrr_stop;
2249 + _dpa_tx_error(net_dev, priv, percpu_priv, &dq->fd, fq->fqid);
2251 + return qman_cb_dqrr_consume;
2254 +enum qman_cb_dqrr_result __hot
2255 +priv_tx_conf_default_dqrr(struct qman_portal *portal,
2256 + struct qman_fq *fq,
2257 + const struct qm_dqrr_entry *dq)
2259 + struct net_device *net_dev;
2260 + struct dpa_priv_s *priv;
2261 + struct dpa_percpu_priv_s *percpu_priv;
2263 + net_dev = ((struct dpa_fq *)fq)->net_dev;
2264 + priv = netdev_priv(net_dev);
2266 + /* Trace the fd */
2267 + trace_dpa_tx_conf_fd(net_dev, fq, &dq->fd);
2269 + /* Non-migratable context, safe to use raw_cpu_ptr */
2270 + percpu_priv = raw_cpu_ptr(priv->percpu_priv);
2272 + if (dpaa_eth_napi_schedule(percpu_priv, portal))
2273 + return qman_cb_dqrr_stop;
2275 + _dpa_tx_conf(net_dev, priv, percpu_priv, &dq->fd, fq->fqid);
2277 + return qman_cb_dqrr_consume;
2280 +void priv_ern(struct qman_portal *portal,
2281 + struct qman_fq *fq,
2282 + const struct qm_mr_entry *msg)
2284 + struct net_device *net_dev;
2285 + const struct dpa_priv_s *priv;
2286 + struct sk_buff *skb;
2287 + struct dpa_percpu_priv_s *percpu_priv;
2288 + struct qm_fd fd = msg->ern.fd;
2290 + net_dev = ((struct dpa_fq *)fq)->net_dev;
2291 + priv = netdev_priv(net_dev);
2292 + /* Non-migratable context, safe to use raw_cpu_ptr */
2293 + percpu_priv = raw_cpu_ptr(priv->percpu_priv);
2295 + percpu_priv->stats.tx_dropped++;
2296 + percpu_priv->stats.tx_fifo_errors++;
2297 + count_ern(percpu_priv, msg);
2299 + /* If we intended this buffer to go into the pool
2300 + * when the FM was done, we need to put it in
2303 + if (msg->ern.fd.bpid != 0xff) {
2304 + dpa_fd_release(net_dev, &fd);
2308 + skb = _dpa_cleanup_tx_fd(priv, &fd);
2309 + dev_kfree_skb_any(skb);
2312 +const struct dpa_fq_cbs_t private_fq_cbs = {
2313 + .rx_defq = { .cb = { .dqrr = priv_rx_default_dqrr } },
2314 + .tx_defq = { .cb = { .dqrr = priv_tx_conf_default_dqrr } },
2315 + .rx_errq = { .cb = { .dqrr = priv_rx_error_dqrr } },
2316 + .tx_errq = { .cb = { .dqrr = priv_tx_conf_error_dqrr } },
2317 + .egress_ern = { .cb = { .ern = priv_ern } }
2319 +EXPORT_SYMBOL(private_fq_cbs);
2321 +static void dpaa_eth_napi_enable(struct dpa_priv_s *priv)
2323 + struct dpa_percpu_priv_s *percpu_priv;
2326 + for_each_possible_cpu(i) {
2327 + percpu_priv = per_cpu_ptr(priv->percpu_priv, i);
2329 + for (j = 0; j < qman_portal_max; j++)
2330 + napi_enable(&percpu_priv->np[j].napi);
2334 +static void dpaa_eth_napi_disable(struct dpa_priv_s *priv)
2336 + struct dpa_percpu_priv_s *percpu_priv;
2339 + for_each_possible_cpu(i) {
2340 + percpu_priv = per_cpu_ptr(priv->percpu_priv, i);
2342 + for (j = 0; j < qman_portal_max; j++)
2343 + napi_disable(&percpu_priv->np[j].napi);
2347 +static int __cold dpa_eth_priv_start(struct net_device *net_dev)
2350 + struct dpa_priv_s *priv;
2352 + priv = netdev_priv(net_dev);
2354 + dpaa_eth_napi_enable(priv);
2356 + err = dpa_start(net_dev);
2358 + dpaa_eth_napi_disable(priv);
2365 +static int __cold dpa_eth_priv_stop(struct net_device *net_dev)
2368 + struct dpa_priv_s *priv;
2370 + _errno = dpa_stop(net_dev);
2371 + /* Allow NAPI to consume any frame still in the Rx/TxConfirm
2372 + * ingress queues. This is to avoid a race between the current
2373 + * context and ksoftirqd which could leave NAPI disabled while
2374 + * in fact there's still Rx traffic to be processed.
2376 + usleep_range(5000, 10000);
2378 + priv = netdev_priv(net_dev);
2379 + dpaa_eth_napi_disable(priv);
2384 +#ifdef CONFIG_NET_POLL_CONTROLLER
2385 +static void dpaa_eth_poll_controller(struct net_device *net_dev)
2387 + struct dpa_priv_s *priv = netdev_priv(net_dev);
2388 + struct dpa_percpu_priv_s *percpu_priv =
2389 + raw_cpu_ptr(priv->percpu_priv);
2390 + struct qman_portal *p;
2391 + const struct qman_portal_config *pc;
2392 + struct dpa_napi_portal *np;
2394 + p = (struct qman_portal *)qman_get_affine_portal(smp_processor_id());
2395 + pc = qman_p_get_portal_config(p);
2396 + np = &percpu_priv->np[pc->index];
2398 + qman_p_irqsource_remove(np->p, QM_PIRQ_DQRI);
2399 + qman_p_poll_dqrr(np->p, np->napi.weight);
2400 + qman_p_irqsource_add(np->p, QM_PIRQ_DQRI);
2404 +static const struct net_device_ops dpa_private_ops = {
2405 + .ndo_open = dpa_eth_priv_start,
2406 + .ndo_start_xmit = dpa_tx,
2407 + .ndo_stop = dpa_eth_priv_stop,
2408 + .ndo_tx_timeout = dpa_timeout,
2409 + .ndo_get_stats64 = dpa_get_stats64,
2410 + .ndo_set_mac_address = dpa_set_mac_address,
2411 + .ndo_validate_addr = eth_validate_addr,
2412 +#ifdef CONFIG_FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
2413 + .ndo_select_queue = dpa_select_queue,
2415 + .ndo_change_mtu = dpa_change_mtu,
2416 + .ndo_set_rx_mode = dpa_set_rx_mode,
2417 + .ndo_init = dpa_ndo_init,
2418 + .ndo_set_features = dpa_set_features,
2419 + .ndo_fix_features = dpa_fix_features,
2420 + .ndo_do_ioctl = dpa_ioctl,
2421 +#ifdef CONFIG_NET_POLL_CONTROLLER
2422 + .ndo_poll_controller = dpaa_eth_poll_controller,
2426 +static int dpa_private_napi_add(struct net_device *net_dev)
2428 + struct dpa_priv_s *priv = netdev_priv(net_dev);
2429 + struct dpa_percpu_priv_s *percpu_priv;
2432 + for_each_possible_cpu(cpu) {
2433 + percpu_priv = per_cpu_ptr(priv->percpu_priv, cpu);
2435 + percpu_priv->np = devm_kzalloc(net_dev->dev.parent,
2436 + qman_portal_max * sizeof(struct dpa_napi_portal),
2439 + if (unlikely(percpu_priv->np == NULL)) {
2440 + dev_err(net_dev->dev.parent, "devm_kzalloc() failed\n");
2444 + for (i = 0; i < qman_portal_max; i++)
2445 + netif_napi_add(net_dev, &percpu_priv->np[i].napi,
2446 + dpaa_eth_poll, DPA_NAPI_WEIGHT);
2452 +void dpa_private_napi_del(struct net_device *net_dev)
2454 + struct dpa_priv_s *priv = netdev_priv(net_dev);
2455 + struct dpa_percpu_priv_s *percpu_priv;
2458 + for_each_possible_cpu(cpu) {
2459 + percpu_priv = per_cpu_ptr(priv->percpu_priv, cpu);
2461 + if (percpu_priv->np) {
2462 + for (i = 0; i < qman_portal_max; i++)
2463 + netif_napi_del(&percpu_priv->np[i].napi);
2465 + devm_kfree(net_dev->dev.parent, percpu_priv->np);
2469 +EXPORT_SYMBOL(dpa_private_napi_del);
2471 +static int dpa_private_netdev_init(struct net_device *net_dev)
2474 + struct dpa_priv_s *priv = netdev_priv(net_dev);
2475 + struct dpa_percpu_priv_s *percpu_priv;
2476 + const uint8_t *mac_addr;
2478 + /* Although we access another CPU's private data here
2479 + * we do it at initialization so it is safe
2481 + for_each_possible_cpu(i) {
2482 + percpu_priv = per_cpu_ptr(priv->percpu_priv, i);
2483 + percpu_priv->net_dev = net_dev;
2486 + net_dev->netdev_ops = &dpa_private_ops;
2487 + mac_addr = priv->mac_dev->addr;
2489 + net_dev->mem_start = priv->mac_dev->res->start;
2490 + net_dev->mem_end = priv->mac_dev->res->end;
2492 + net_dev->hw_features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
2495 + /* Advertise S/G and HIGHDMA support for private interfaces */
2496 + net_dev->hw_features |= NETIF_F_SG | NETIF_F_HIGHDMA;
2497 + /* Recent kernels enable GSO automatically, if
2498 + * we declare NETIF_F_SG. For conformity, we'll
2499 + * still declare GSO explicitly.
2501 + net_dev->features |= NETIF_F_GSO;
2503 + /* Advertise GRO support */
2504 + net_dev->features |= NETIF_F_GRO;
2506 + /* Advertise NETIF_F_HW_ACCEL_MQ to avoid Tx timeout warnings */
2507 + net_dev->features |= NETIF_F_HW_ACCEL_MQ;
2509 + return dpa_netdev_init(net_dev, mac_addr, tx_timeout);
2512 +static struct dpa_bp * __cold
2513 +dpa_priv_bp_probe(struct device *dev)
2515 + struct dpa_bp *dpa_bp;
2517 + dpa_bp = devm_kzalloc(dev, sizeof(*dpa_bp), GFP_KERNEL);
2518 + if (unlikely(dpa_bp == NULL)) {
2519 + dev_err(dev, "devm_kzalloc() failed\n");
2520 + return ERR_PTR(-ENOMEM);
2523 + dpa_bp->percpu_count = devm_alloc_percpu(dev, *dpa_bp->percpu_count);
2524 + dpa_bp->target_count = CONFIG_FSL_DPAA_ETH_MAX_BUF_COUNT;
2526 + dpa_bp->seed_cb = dpa_bp_priv_seed;
2527 + dpa_bp->free_buf_cb = _dpa_bp_free_pf;
2532 +/* Place all ingress FQs (Rx Default, Rx Error, PCD FQs) in a dedicated CGR.
2533 + * We won't be sending congestion notifications to FMan; for now, we just use
2534 + * this CGR to generate enqueue rejections to FMan in order to drop the frames
2535 + * before they reach our ingress queues and eat up memory.
2537 +static int dpaa_eth_priv_ingress_cgr_init(struct dpa_priv_s *priv)
2539 + struct qm_mcc_initcgr initcgr;
2543 + err = qman_alloc_cgrid(&priv->ingress_cgr.cgrid);
2545 + pr_err("Error %d allocating CGR ID\n", err);
2549 + /* Enable CS TD, but disable Congestion State Change Notifications. */
2550 + initcgr.we_mask = QM_CGR_WE_CS_THRES;
2551 + initcgr.cgr.cscn_en = QM_CGR_EN;
2552 + cs_th = CONFIG_FSL_DPAA_INGRESS_CS_THRESHOLD;
2553 + qm_cgr_cs_thres_set64(&initcgr.cgr.cs_thres, cs_th, 1);
2555 + initcgr.we_mask |= QM_CGR_WE_CSTD_EN;
2556 + initcgr.cgr.cstd_en = QM_CGR_EN;
2558 + /* This is actually a hack, because this CGR will be associated with
2559 + * our affine SWP. However, we'll place our ingress FQs in it.
2561 + err = qman_create_cgr(&priv->ingress_cgr, QMAN_CGR_FLAG_USE_INIT,
2564 + pr_err("Error %d creating ingress CGR with ID %d\n", err,
2565 + priv->ingress_cgr.cgrid);
2566 + qman_release_cgrid(priv->ingress_cgr.cgrid);
2569 + pr_debug("Created ingress CGR %d for netdev with hwaddr %pM\n",
2570 + priv->ingress_cgr.cgrid, priv->mac_dev->addr);
2572 + /* struct qman_cgr allows special cgrid values (i.e. outside the 0..255
2573 + * range), but we have no common initialization path between the
2574 + * different variants of the DPAA Eth driver, so we do it here rather
2575 + * than modifying every other variant than "private Eth".
2577 + priv->use_ingress_cgr = true;
2583 +static int dpa_priv_bp_create(struct net_device *net_dev, struct dpa_bp *dpa_bp,
2586 + struct dpa_priv_s *priv = netdev_priv(net_dev);
2589 + if (netif_msg_probe(priv))
2590 + dev_dbg(net_dev->dev.parent,
2591 + "Using private BM buffer pools\n");
2593 + priv->bp_count = count;
2595 + for (i = 0; i < count; i++) {
2597 + err = dpa_bp_alloc(&dpa_bp[i]);
2599 + dpa_bp_free(priv);
2600 + priv->dpa_bp = NULL;
2604 + priv->dpa_bp = &dpa_bp[i];
2607 + dpa_priv_common_bpid = priv->dpa_bp->bpid;
2611 +static const struct of_device_id dpa_match[];
2613 +#ifdef CONFIG_FSL_DPAA_DBG_LOOP
2614 +static int dpa_new_loop_id(void)
2623 +dpaa_eth_priv_probe(struct platform_device *_of_dev)
2625 + int err = 0, i, channel;
2626 + struct device *dev;
2627 + struct device_node *dpa_node;
2628 + struct dpa_bp *dpa_bp;
2630 + struct net_device *net_dev = NULL;
2631 + struct dpa_priv_s *priv = NULL;
2632 + struct dpa_percpu_priv_s *percpu_priv;
2633 + struct fm_port_fqs port_fqs;
2634 + struct dpa_buffer_layout_s *buf_layout = NULL;
2635 + struct mac_device *mac_dev;
2637 + dev = &_of_dev->dev;
2639 + dpa_node = dev->of_node;
2641 + if (!of_device_is_available(dpa_node))
2644 + /* Get the buffer pools assigned to this interface;
2645 + * run only once the default pool probing code
2647 + dpa_bp = (dpa_bpid2pool(dpa_priv_common_bpid)) ? :
2648 + dpa_priv_bp_probe(dev);
2649 + if (IS_ERR(dpa_bp))
2650 + return PTR_ERR(dpa_bp);
2652 + /* Allocate this early, so we can store relevant information in
2653 + * the private area (needed by 1588 code in dpa_mac_probe)
2655 + net_dev = alloc_etherdev_mq(sizeof(*priv), DPAA_ETH_TX_QUEUES);
2657 + dev_err(dev, "alloc_etherdev_mq() failed\n");
2658 + goto alloc_etherdev_mq_failed;
2661 + /* Do this here, so we can be verbose early */
2662 + SET_NETDEV_DEV(net_dev, dev);
2663 + dev_set_drvdata(dev, net_dev);
2665 + priv = netdev_priv(net_dev);
2666 + priv->net_dev = net_dev;
2667 + strcpy(priv->if_type, "private");
2669 + priv->msg_enable = netif_msg_init(debug, -1);
2671 +#ifdef CONFIG_FSL_DPAA_DBG_LOOP
2672 + priv->loop_id = dpa_new_loop_id();
2673 + priv->loop_to = -1; /* disabled by default */
2674 + dpa_loop_netdevs[priv->loop_id] = net_dev;
2677 + mac_dev = dpa_mac_probe(_of_dev);
2678 + if (IS_ERR(mac_dev) || !mac_dev) {
2679 + err = PTR_ERR(mac_dev);
2680 + goto mac_probe_failed;
2683 + /* We have physical ports, so we need to establish
2684 + * the buffer layout.
2686 + buf_layout = devm_kzalloc(dev, 2 * sizeof(*buf_layout),
2688 + if (!buf_layout) {
2689 + dev_err(dev, "devm_kzalloc() failed\n");
2690 + goto alloc_failed;
2692 + dpa_set_buffers_layout(mac_dev, buf_layout);
2694 + /* For private ports, need to compute the size of the default
2695 + * buffer pool, based on FMan port buffer layout;also update
2696 + * the maximum buffer size for private ports if necessary
2698 + dpa_bp->size = dpa_bp_size(&buf_layout[RX]);
2700 +#ifdef CONFIG_FSL_DPAA_ETH_JUMBO_FRAME
2701 + /* We only want to use jumbo frame optimization if we actually have
2702 + * L2 MAX FRM set for jumbo frames as well.
2705 + if (likely(!dpaa_errata_a010022))
2707 + if(fm_get_max_frm() < 9600)
2709 + "Invalid configuration: if jumbo frames support is on, FSL_FM_MAX_FRAME_SIZE should be set to 9600\n");
2712 + INIT_LIST_HEAD(&priv->dpa_fq_list);
2714 + memset(&port_fqs, 0, sizeof(port_fqs));
2716 + err = dpa_fq_probe_mac(dev, &priv->dpa_fq_list, &port_fqs, true, RX);
2718 + err = dpa_fq_probe_mac(dev, &priv->dpa_fq_list,
2719 + &port_fqs, true, TX);
2722 + goto fq_probe_failed;
2726 + err = dpa_priv_bp_create(net_dev, dpa_bp, count);
2729 + goto bp_create_failed;
2731 + priv->mac_dev = mac_dev;
2733 + channel = dpa_get_channel();
2735 + if (channel < 0) {
2737 + goto get_channel_failed;
2740 + priv->channel = (uint16_t)channel;
2741 + dpaa_eth_add_channel(priv->channel);
2743 + dpa_fq_setup(priv, &private_fq_cbs, priv->mac_dev->port_dev[TX]);
2745 + /* Create a congestion group for this netdev, with
2746 + * dynamically-allocated CGR ID.
2747 + * Must be executed after probing the MAC, but before
2748 + * assigning the egress FQs to the CGRs.
2750 + err = dpaa_eth_cgr_init(priv);
2752 + dev_err(dev, "Error initializing CGR\n");
2753 + goto tx_cgr_init_failed;
2755 + err = dpaa_eth_priv_ingress_cgr_init(priv);
2757 + dev_err(dev, "Error initializing ingress CGR\n");
2758 + goto rx_cgr_init_failed;
2761 + /* Add the FQs to the interface, and make them active */
2762 + err = dpa_fqs_init(dev, &priv->dpa_fq_list, false);
2764 + goto fq_alloc_failed;
2766 + priv->buf_layout = buf_layout;
2767 + priv->tx_headroom = dpa_get_headroom(&priv->buf_layout[TX]);
2768 + priv->rx_headroom = dpa_get_headroom(&priv->buf_layout[RX]);
2770 + /* All real interfaces need their ports initialized */
2771 + dpaa_eth_init_ports(mac_dev, dpa_bp, count, &port_fqs,
2774 +#ifdef CONFIG_FMAN_PFC
2775 + for (i = 0; i < CONFIG_FMAN_PFC_COS_COUNT; i++) {
2776 + err = fm_port_set_pfc_priorities_mapping_to_qman_wq(
2777 + mac_dev->port_dev[TX], i, i);
2778 + if (unlikely(err != 0)) {
2779 + dev_err(dev, "Error maping PFC %u to WQ %u\n", i, i);
2780 + goto pfc_mapping_failed;
2785 + priv->percpu_priv = devm_alloc_percpu(dev, *priv->percpu_priv);
2787 + if (priv->percpu_priv == NULL) {
2788 + dev_err(dev, "devm_alloc_percpu() failed\n");
2790 + goto alloc_percpu_failed;
2792 + for_each_possible_cpu(i) {
2793 + percpu_priv = per_cpu_ptr(priv->percpu_priv, i);
2794 + memset(percpu_priv, 0, sizeof(*percpu_priv));
2797 + /* Initialize NAPI */
2798 + err = dpa_private_napi_add(net_dev);
2801 + goto napi_add_failed;
2803 + err = dpa_private_netdev_init(net_dev);
2806 + goto netdev_init_failed;
2808 + dpaa_eth_sysfs_init(&net_dev->dev);
2811 + device_set_wakeup_capable(dev, true);
2814 + pr_info("fsl_dpa: Probed interface %s\n", net_dev->name);
2818 +netdev_init_failed:
2820 + dpa_private_napi_del(net_dev);
2821 +alloc_percpu_failed:
2822 +#ifdef CONFIG_FMAN_PFC
2823 +pfc_mapping_failed:
2825 + dpa_fq_free(dev, &priv->dpa_fq_list);
2827 + qman_delete_cgr_safe(&priv->ingress_cgr);
2828 + qman_release_cgrid(priv->ingress_cgr.cgrid);
2829 +rx_cgr_init_failed:
2830 + qman_delete_cgr_safe(&priv->cgr_data.cgr);
2831 + qman_release_cgrid(priv->cgr_data.cgr.cgrid);
2832 +tx_cgr_init_failed:
2833 +get_channel_failed:
2834 + dpa_bp_free(priv);
2839 + dev_set_drvdata(dev, NULL);
2840 + free_netdev(net_dev);
2841 +alloc_etherdev_mq_failed:
2842 + if (atomic_read(&dpa_bp->refs) == 0)
2843 + devm_kfree(dev, dpa_bp);
2848 +static const struct of_device_id dpa_match[] = {
2850 + .compatible = "fsl,dpa-ethernet"
2854 +MODULE_DEVICE_TABLE(of, dpa_match);
2856 +static struct platform_driver dpa_driver = {
2858 + .name = KBUILD_MODNAME,
2859 + .of_match_table = dpa_match,
2860 + .owner = THIS_MODULE,
2861 + .pm = DPAA_PM_OPS,
2863 + .probe = dpaa_eth_priv_probe,
2864 + .remove = dpa_remove
2868 +static bool __init __cold soc_has_errata_a010022(void)
2870 +#ifdef CONFIG_SOC_BUS
2871 + const struct soc_device_attribute soc_msi_matches[] = {
2872 + { .family = "QorIQ LS1043A",
2877 + if (soc_device_match(soc_msi_matches))
2882 + return true; /* cannot identify SoC */
2887 +static int __init __cold dpa_load(void)
2891 + pr_info(DPA_DESCRIPTION "\n");
2893 +#ifdef CONFIG_FSL_DPAA_DBG_LOOP
2894 + dpa_debugfs_module_init();
2895 +#endif /* CONFIG_FSL_DPAA_DBG_LOOP */
2897 + /* initialise dpaa_eth mirror values */
2898 + dpa_rx_extra_headroom = fm_get_rx_extra_headroom();
2899 + dpa_max_frm = fm_get_max_frm();
2900 + dpa_num_cpus = num_possible_cpus();
2903 + /* Detect if the current SoC requires the 4K alignment workaround */
2904 + dpaa_errata_a010022 = soc_has_errata_a010022();
2907 +#ifdef CONFIG_FSL_DPAA_DBG_LOOP
2908 + memset(dpa_loop_netdevs, 0, sizeof(dpa_loop_netdevs));
2911 + _errno = platform_driver_register(&dpa_driver);
2912 + if (unlikely(_errno < 0)) {
2913 + pr_err(KBUILD_MODNAME
2914 + ": %s:%hu:%s(): platform_driver_register() = %d\n",
2915 + KBUILD_BASENAME".c", __LINE__, __func__, _errno);
2918 + pr_debug(KBUILD_MODNAME ": %s:%s() ->\n",
2919 + KBUILD_BASENAME".c", __func__);
2923 +module_init(dpa_load);
2925 +static void __exit __cold dpa_unload(void)
2927 + pr_debug(KBUILD_MODNAME ": -> %s:%s()\n",
2928 + KBUILD_BASENAME".c", __func__);
2930 + platform_driver_unregister(&dpa_driver);
2932 +#ifdef CONFIG_FSL_DPAA_DBG_LOOP
2933 + dpa_debugfs_module_exit();
2934 +#endif /* CONFIG_FSL_DPAA_DBG_LOOP */
2936 + /* Only one channel is used and needs to be relased after all
2937 + * interfaces are removed
2939 + dpa_release_channel();
2941 + pr_debug(KBUILD_MODNAME ": %s:%s() ->\n",
2942 + KBUILD_BASENAME".c", __func__);
2944 +module_exit(dpa_unload);
2945 diff --git a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h
2946 new file mode 100644
2947 index 00000000..57c9bef4
2949 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h
2951 +/* Copyright 2008-2012 Freescale Semiconductor Inc.
2953 + * Redistribution and use in source and binary forms, with or without
2954 + * modification, are permitted provided that the following conditions are met:
2955 + * * Redistributions of source code must retain the above copyright
2956 + * notice, this list of conditions and the following disclaimer.
2957 + * * Redistributions in binary form must reproduce the above copyright
2958 + * notice, this list of conditions and the following disclaimer in the
2959 + * documentation and/or other materials provided with the distribution.
2960 + * * Neither the name of Freescale Semiconductor nor the
2961 + * names of its contributors may be used to endorse or promote products
2962 + * derived from this software without specific prior written permission.
2965 + * ALTERNATIVELY, this software may be distributed under the terms of the
2966 + * GNU General Public License ("GPL") as published by the Free Software
2967 + * Foundation, either version 2 of that License or (at your option) any
2970 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
2971 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2972 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2973 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
2974 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
2975 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2976 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2977 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2978 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2979 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2985 +#include <linux/netdevice.h>
2986 +#include <linux/fsl_qman.h> /* struct qman_fq */
2988 +#include "fm_ext.h"
2989 +#include "dpaa_eth_trace.h"
2991 +extern int dpa_rx_extra_headroom;
2992 +extern int dpa_max_frm;
2993 +extern int dpa_num_cpus;
2995 +#define dpa_get_rx_extra_headroom() dpa_rx_extra_headroom
2996 +#define dpa_get_max_frm() dpa_max_frm
2998 +#define dpa_get_max_mtu() \
2999 + (dpa_get_max_frm() - (VLAN_ETH_HLEN + ETH_FCS_LEN))
3003 +/* Simple enum of FQ types - used for array indexing */
3004 +enum port_type {RX, TX};
3006 +/* TODO: This structure should be renamed & moved to the FMD wrapper */
3007 +struct dpa_buffer_layout_s {
3008 + uint16_t priv_data_size;
3009 + bool parse_results;
3011 + bool hash_results;
3012 + uint8_t manip_extra_space;
3013 + uint16_t data_align;
3016 +#ifdef CONFIG_FSL_DPAA_ETH_DEBUG
3017 +#define DPA_BUG_ON(cond) BUG_ON(cond)
3019 +#define DPA_BUG_ON(cond)
3022 +#define DPA_TX_PRIV_DATA_SIZE 16
3023 +#define DPA_PARSE_RESULTS_SIZE sizeof(fm_prs_result_t)
3024 +#define DPA_TIME_STAMP_SIZE 8
3025 +#define DPA_HASH_RESULTS_SIZE 8
3026 +#define DPA_RX_PRIV_DATA_SIZE (DPA_TX_PRIV_DATA_SIZE + \
3027 + dpa_get_rx_extra_headroom())
3029 +#define FM_FD_STAT_RX_ERRORS \
3030 + (FM_PORT_FRM_ERR_DMA | FM_PORT_FRM_ERR_PHYSICAL | \
3031 + FM_PORT_FRM_ERR_SIZE | FM_PORT_FRM_ERR_CLS_DISCARD | \
3032 + FM_PORT_FRM_ERR_EXTRACTION | FM_PORT_FRM_ERR_NO_SCHEME | \
3033 + FM_PORT_FRM_ERR_ILL_PLCR | FM_PORT_FRM_ERR_PRS_TIMEOUT | \
3034 + FM_PORT_FRM_ERR_PRS_ILL_INSTRUCT | FM_PORT_FRM_ERR_PRS_HDR_ERR)
3036 +#define FM_FD_STAT_TX_ERRORS \
3037 + (FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT | \
3038 + FM_PORT_FRM_ERR_LENGTH | FM_PORT_FRM_ERR_DMA)
3040 +#ifndef CONFIG_FSL_DPAA_ETH_JUMBO_FRAME
3041 +/* The raw buffer size must be cacheline aligned.
3042 + * Normally we use 2K buffers.
3044 +#define DPA_BP_RAW_SIZE 2048
3046 +/* For jumbo frame optimizations, use buffers large enough to accommodate
3047 + * 9.6K frames, FD maximum offset, skb sh_info overhead and some extra
3048 + * space to account for further alignments.
3050 +#define DPA_MAX_FRM_SIZE 9600
3052 +#define DPA_BP_RAW_SIZE \
3053 + ((DPA_MAX_FRM_SIZE + DPA_MAX_FD_OFFSET + \
3054 + sizeof(struct skb_shared_info) + 128) & ~(SMP_CACHE_BYTES - 1))
3055 +#else /* CONFIG_PPC */
3056 +#define DPA_BP_RAW_SIZE ((unlikely(dpaa_errata_a010022)) ? 2048 : \
3057 + ((DPA_MAX_FRM_SIZE + DPA_MAX_FD_OFFSET + \
3058 + sizeof(struct skb_shared_info) + 128) & ~(SMP_CACHE_BYTES - 1)))
3059 +#endif /* CONFIG_PPC */
3060 +#endif /* CONFIG_FSL_DPAA_ETH_JUMBO_FRAME */
3062 +/* This is what FMan is ever allowed to use.
3063 + * FMan-DMA requires 16-byte alignment for Rx buffers, but SKB_DATA_ALIGN is
3064 + * even stronger (SMP_CACHE_BYTES-aligned), so we just get away with that,
3065 + * via SKB_WITH_OVERHEAD(). We can't rely on netdev_alloc_frag() giving us
3066 + * half-page-aligned buffers (can we?), so we reserve some more space
3067 + * for start-of-buffer alignment.
3069 +#define dpa_bp_size(buffer_layout) (SKB_WITH_OVERHEAD(DPA_BP_RAW_SIZE) - \
3071 +/* We must ensure that skb_shinfo is always cacheline-aligned. */
3072 +#define DPA_SKB_SIZE(size) ((size) & ~(SMP_CACHE_BYTES - 1))
3074 +/* Maximum size of a buffer for which recycling is allowed.
3075 + * We need an upper limit such that forwarded skbs that get reallocated on Tx
3076 + * aren't allowed to grow unboundedly. On the other hand, we need to make sure
3077 + * that skbs allocated by us will not fail to be recycled due to their size.
3079 + * For a requested size, the kernel allocator provides the next power of two
3080 + * sized block, which the stack will use as is, regardless of the actual size
3081 + * it required; since we must accommodate at most 9.6K buffers (L2 maximum
3082 + * supported frame size), set the recycling upper limit to 16K.
3084 +#define DPA_RECYCLE_MAX_SIZE 16384
3086 +#if defined(CONFIG_FSL_SDK_FMAN_TEST)
3087 +/*TODO: temporary for fman pcd testing */
3088 +#define FMAN_PCD_TESTS_MAX_NUM_RANGES 20
3091 +#define DPAA_ETH_FQ_DELTA 0x10000
3093 +#define DPAA_ETH_PCD_FQ_BASE(device_addr) \
3094 + (((device_addr) & 0x1fffff) >> 6)
3096 +#define DPAA_ETH_PCD_FQ_HI_PRIO_BASE(device_addr) \
3097 + (DPAA_ETH_FQ_DELTA + DPAA_ETH_PCD_FQ_BASE(device_addr))
3099 +/* Largest value that the FQD's OAL field can hold.
3100 + * This is DPAA-1.x specific.
3101 + * TODO: This rather belongs in fsl_qman.h
3103 +#define FSL_QMAN_MAX_OAL 127
3105 +/* Maximum offset value for a contig or sg FD (represented on 9 bits) */
3106 +#define DPA_MAX_FD_OFFSET ((1 << 9) - 1)
3108 +/* Default alignment for start of data in an Rx FD */
3109 +#define DPA_FD_DATA_ALIGNMENT 16
3111 +/* Values for the L3R field of the FM Parse Results
3113 +/* L3 Type field: First IP Present IPv4 */
3114 +#define FM_L3_PARSE_RESULT_IPV4 0x8000
3115 +/* L3 Type field: First IP Present IPv6 */
3116 +#define FM_L3_PARSE_RESULT_IPV6 0x4000
3118 +/* Values for the L4R field of the FM Parse Results
3119 + * See $8.8.4.7.20 - L4 HXS - L4 Results from DPAA-Rev2 Reference Manual.
3121 +/* L4 Type field: UDP */
3122 +#define FM_L4_PARSE_RESULT_UDP 0x40
3123 +/* L4 Type field: TCP */
3124 +#define FM_L4_PARSE_RESULT_TCP 0x20
3125 +/* FD status field indicating whether the FM Parser has attempted to validate
3126 + * the L4 csum of the frame.
3127 + * Note that having this bit set doesn't necessarily imply that the checksum
3128 + * is valid. One would have to check the parse results to find that out.
3130 +#define FM_FD_STAT_L4CV 0x00000004
3133 +#define FM_FD_STAT_ERR_PHYSICAL FM_PORT_FRM_ERR_PHYSICAL
3135 +/* Check if the parsed frame was found to be a TCP segment.
3137 + * @parse_result_ptr must be of type (fm_prs_result_t *).
3139 +#define fm_l4_frame_is_tcp(parse_result_ptr) \
3140 + ((parse_result_ptr)->l4r & FM_L4_PARSE_RESULT_TCP)
3142 +/* number of Tx queues to FMan */
3143 +#ifdef CONFIG_FMAN_PFC
3144 +#define DPAA_ETH_TX_QUEUES (NR_CPUS * CONFIG_FMAN_PFC_COS_COUNT)
3146 +#define DPAA_ETH_TX_QUEUES NR_CPUS
3149 +#define DPAA_ETH_RX_QUEUES 128
3151 +/* Convenience macros for storing/retrieving the skb back-pointers. They must
3152 + * accommodate both recycling and confirmation paths - i.e. cases when the buf
3153 + * was allocated by ourselves, respectively by the stack. In the former case,
3154 + * we could store the skb at negative offset; in the latter case, we can't,
3155 + * so we'll use 0 as offset.
3157 + * NB: @off is an offset from a (struct sk_buff **) pointer!
3159 +#define DPA_WRITE_SKB_PTR(skb, skbh, addr, off) \
3161 + skbh = (struct sk_buff **)addr; \
3162 + *(skbh + (off)) = skb; \
3164 +#define DPA_READ_SKB_PTR(skb, skbh, addr, off) \
3166 + skbh = (struct sk_buff **)addr; \
3167 + skb = *(skbh + (off)); \
3171 +/* Magic Packet wakeup */
3172 +#define DPAA_WOL_MAGIC 0x00000001
3175 +#if defined(CONFIG_FSL_SDK_FMAN_TEST)
3182 +/* More detailed FQ types - used for fine-grained WQ assignments */
3184 + FQ_TYPE_RX_DEFAULT = 1, /* Rx Default FQs */
3185 + FQ_TYPE_RX_ERROR, /* Rx Error FQs */
3186 + FQ_TYPE_RX_PCD, /* User-defined PCDs */
3187 + FQ_TYPE_TX, /* "Real" Tx FQs */
3188 + FQ_TYPE_TX_CONFIRM, /* Tx default Conf FQ (actually an Rx FQ) */
3189 + FQ_TYPE_TX_CONF_MQ, /* Tx conf FQs (one for each Tx FQ) */
3190 + FQ_TYPE_TX_ERROR, /* Tx Error FQs (these are actually Rx FQs) */
3191 + FQ_TYPE_RX_PCD_HI_PRIO, /* User-defined high-priority PCDs */
3195 + struct qman_fq fq_base;
3196 + struct list_head list;
3197 + struct net_device *net_dev;
3203 + enum dpa_fq_type fq_type;
3206 +struct dpa_fq_cbs_t {
3207 + struct qman_fq rx_defq;
3208 + struct qman_fq tx_defq;
3209 + struct qman_fq rx_errq;
3210 + struct qman_fq tx_errq;
3211 + struct qman_fq egress_ern;
3220 + struct bman_pool *pool;
3222 + struct device *dev;
3224 + /* The buffer pools used for the private ports are initialized
3225 + * with target_count buffers for each CPU; at runtime the
3226 + * number of buffers per CPU is constantly brought back to this
3230 + /* The configured value for the number of buffers in the pool,
3231 + * used for shared port buffer pools
3237 + /* physical address of the contiguous memory used by the pool to store
3241 + /* virtual address of the contiguous memory used by the pool to store
3244 + void __iomem *vaddr;
3245 + /* current number of buffers in the bpool alloted to this CPU */
3246 + int __percpu *percpu_count;
3248 + /* some bpools need to be seeded before use by this cb */
3249 + int (*seed_cb)(struct dpa_bp *);
3250 + /* some bpools need to be emptied before freeing; this cb is used
3251 + * for freeing of individual buffers taken from the pool
3253 + void (*free_buf_cb)(void *addr);
3256 +struct dpa_rx_errors {
3257 + u64 dme; /* DMA Error */
3258 + u64 fpe; /* Frame Physical Error */
3259 + u64 fse; /* Frame Size Error */
3260 + u64 phe; /* Header Error */
3261 + u64 cse; /* Checksum Validation Error */
3264 +/* Counters for QMan ERN frames - one counter per rejection code */
3265 +struct dpa_ern_cnt {
3266 + u64 cg_tdrop; /* Congestion group taildrop */
3267 + u64 wred; /* WRED congestion */
3268 + u64 err_cond; /* Error condition */
3269 + u64 early_window; /* Order restoration, frame too early */
3270 + u64 late_window; /* Order restoration, frame too late */
3271 + u64 fq_tdrop; /* FQ taildrop */
3272 + u64 fq_retired; /* FQ is retired */
3273 + u64 orp_zero; /* ORP disabled */
3276 +struct dpa_napi_portal {
3277 + struct napi_struct napi;
3278 + struct qman_portal *p;
3281 +struct dpa_percpu_priv_s {
3282 + struct net_device *net_dev;
3283 + struct dpa_napi_portal *np;
3287 + /* fragmented (non-linear) skbuffs received from the stack */
3288 + u64 tx_frag_skbuffs;
3289 + /* number of S/G frames received */
3292 + struct rtnl_link_stats64 stats;
3293 + struct dpa_rx_errors rx_errors;
3294 + struct dpa_ern_cnt ern_cnt;
3297 +struct dpa_priv_s {
3298 + struct dpa_percpu_priv_s __percpu *percpu_priv;
3299 + struct dpa_bp *dpa_bp;
3300 + /* Store here the needed Tx headroom for convenience and speed
3301 + * (even though it can be computed based on the fields of buf_layout)
3303 + uint16_t tx_headroom;
3304 + struct net_device *net_dev;
3305 + struct mac_device *mac_dev;
3306 + struct qman_fq *egress_fqs[DPAA_ETH_TX_QUEUES];
3307 + struct qman_fq *conf_fqs[DPAA_ETH_TX_QUEUES];
3311 + uint16_t channel; /* "fsl,qman-channel-id" */
3312 + struct list_head dpa_fq_list;
3314 +#ifdef CONFIG_FSL_DPAA_DBG_LOOP
3315 + struct dentry *debugfs_loop_file;
3318 + uint32_t msg_enable; /* net_device message level */
3319 +#ifdef CONFIG_FSL_DPAA_1588
3320 + struct dpa_ptp_tsu *tsu;
3323 +#if defined(CONFIG_FSL_SDK_FMAN_TEST)
3324 +/* TODO: this is temporary until pcd support is implemented in dpaa */
3325 + int priv_pcd_num_ranges;
3326 + struct pcd_range priv_pcd_ranges[FMAN_PCD_TESTS_MAX_NUM_RANGES];
3331 + * All egress queues to a given net device belong to one
3332 + * (and the same) congestion group.
3334 + struct qman_cgr cgr;
3335 + /* If congested, when it began. Used for performance stats. */
3336 + u32 congestion_start_jiffies;
3337 + /* Number of jiffies the Tx port was congested. */
3338 + u32 congested_jiffies;
3340 + * Counter for the number of times the CGR
3341 + * entered congestion state
3343 + u32 cgr_congested_count;
3345 + /* Use a per-port CGR for ingress traffic. */
3346 + bool use_ingress_cgr;
3347 + struct qman_cgr ingress_cgr;
3349 +#ifdef CONFIG_FSL_DPAA_TS
3350 + bool ts_tx_en; /* Tx timestamping enabled */
3351 + bool ts_rx_en; /* Rx timestamping enabled */
3352 +#endif /* CONFIG_FSL_DPAA_TS */
3354 + struct dpa_buffer_layout_s *buf_layout;
3355 + uint16_t rx_headroom;
3362 +#ifdef CONFIG_FSL_DPAA_DBG_LOOP
3366 +#ifdef CONFIG_FSL_DPAA_CEETM
3367 + bool ceetm_en; /* CEETM QoS enabled */
3371 +struct fm_port_fqs {
3372 + struct dpa_fq *tx_defq;
3373 + struct dpa_fq *tx_errq;
3374 + struct dpa_fq *rx_defq;
3375 + struct dpa_fq *rx_errq;
3379 +#ifdef CONFIG_FSL_DPAA_DBG_LOOP
3380 +extern struct net_device *dpa_loop_netdevs[20];
3383 +/* functions with different implementation for SG and non-SG: */
3384 +int dpa_bp_priv_seed(struct dpa_bp *dpa_bp);
3385 +int dpaa_eth_refill_bpools(struct dpa_bp *dpa_bp, int *count_ptr);
3386 +void __hot _dpa_rx(struct net_device *net_dev,
3387 + struct qman_portal *portal,
3388 + const struct dpa_priv_s *priv,
3389 + struct dpa_percpu_priv_s *percpu_priv,
3390 + const struct qm_fd *fd,
3393 +int __hot dpa_tx(struct sk_buff *skb, struct net_device *net_dev);
3394 +int __hot dpa_tx_extended(struct sk_buff *skb, struct net_device *net_dev,
3395 + struct qman_fq *egress_fq, struct qman_fq *conf_fq);
3396 +struct sk_buff *_dpa_cleanup_tx_fd(const struct dpa_priv_s *priv,
3397 + const struct qm_fd *fd);
3398 +void __hot _dpa_process_parse_results(const fm_prs_result_t *parse_results,
3399 + const struct qm_fd *fd,
3400 + struct sk_buff *skb,
3402 +#ifndef CONFIG_FSL_DPAA_TS
3403 +bool dpa_skb_is_recyclable(struct sk_buff *skb);
3404 +bool dpa_buf_is_recyclable(struct sk_buff *skb,
3405 + uint32_t min_size,
3406 + uint16_t min_offset,
3407 + unsigned char **new_buf_start);
3409 +int __hot skb_to_contig_fd(struct dpa_priv_s *priv,
3410 + struct sk_buff *skb, struct qm_fd *fd,
3411 + int *count_ptr, int *offset);
3412 +int __hot skb_to_sg_fd(struct dpa_priv_s *priv,
3413 + struct sk_buff *skb, struct qm_fd *fd);
3414 +int __cold __attribute__((nonnull))
3415 + _dpa_fq_free(struct device *dev, struct qman_fq *fq);
3417 +/* Turn on HW checksum computation for this outgoing frame.
3418 + * If the current protocol is not something we support in this regard
3419 + * (or if the stack has already computed the SW checksum), we do nothing.
3421 + * Returns 0 if all goes well (or HW csum doesn't apply), and a negative value
3424 + * Note that this function may modify the fd->cmd field and the skb data buffer
3425 + * (the Parse Results area).
3427 +int dpa_enable_tx_csum(struct dpa_priv_s *priv,
3428 + struct sk_buff *skb, struct qm_fd *fd, char *parse_results);
3430 +static inline int dpaa_eth_napi_schedule(struct dpa_percpu_priv_s *percpu_priv,
3431 + struct qman_portal *portal)
3433 + /* In case of threaded ISR for RT enable kernel,
3434 + * in_irq() does not return appropriate value, so use
3435 + * in_serving_softirq to distinguish softirq or irq context.
3437 + if (unlikely(in_irq() || !in_serving_softirq())) {
3438 + /* Disable QMan IRQ and invoke NAPI */
3439 + int ret = qman_p_irqsource_remove(portal, QM_PIRQ_DQRI);
3440 + if (likely(!ret)) {
3441 + const struct qman_portal_config *pc =
3442 + qman_p_get_portal_config(portal);
3443 + struct dpa_napi_portal *np =
3444 + &percpu_priv->np[pc->index];
3447 + napi_schedule(&np->napi);
3448 + percpu_priv->in_interrupt++;
3455 +static inline ssize_t __const __must_check __attribute__((nonnull))
3456 +dpa_fd_length(const struct qm_fd *fd)
3458 + return fd->length20;
3461 +static inline ssize_t __const __must_check __attribute__((nonnull))
3462 +dpa_fd_offset(const struct qm_fd *fd)
3464 + return fd->offset;
3467 +static inline uint16_t dpa_get_headroom(struct dpa_buffer_layout_s *bl)
3469 + uint16_t headroom;
3470 + /* The frame headroom must accommodate:
3471 + * - the driver private data area
3472 + * - parse results, hash results, timestamp if selected
3473 + * - manip extra space
3474 + * If either hash results or time stamp are selected, both will
3475 + * be copied to/from the frame headroom, as TS is located between PR and
3476 + * HR in the IC and IC copy size has a granularity of 16bytes
3477 + * (see description of FMBM_RICP and FMBM_TICP registers in DPAARM)
3479 + * Also make sure the headroom is a multiple of data_align bytes
3481 + headroom = (uint16_t)(bl->priv_data_size +
3482 + (bl->parse_results ? DPA_PARSE_RESULTS_SIZE : 0) +
3483 + (bl->hash_results || bl->time_stamp ?
3484 + DPA_TIME_STAMP_SIZE + DPA_HASH_RESULTS_SIZE : 0) +
3485 + bl->manip_extra_space);
3487 + return bl->data_align ? ALIGN(headroom, bl->data_align) : headroom;
3490 +int fm_mac_dump_regs(struct mac_device *h_dev, char *buf, int n);
3491 +int fm_mac_dump_rx_stats(struct mac_device *h_dev, char *buf, int n);
3492 +int fm_mac_dump_tx_stats(struct mac_device *h_dev, char *buf, int n);
3494 +void dpaa_eth_sysfs_remove(struct device *dev);
3495 +void dpaa_eth_sysfs_init(struct device *dev);
3496 +int dpaa_eth_poll(struct napi_struct *napi, int budget);
3498 +void dpa_private_napi_del(struct net_device *net_dev);
3500 +/* Equivalent to a memset(0), but works faster */
3501 +static inline void clear_fd(struct qm_fd *fd)
3503 + fd->opaque_addr = 0;
3508 +static inline int _dpa_tx_fq_to_id(const struct dpa_priv_s *priv,
3509 + struct qman_fq *tx_fq)
3513 + for (i = 0; i < DPAA_ETH_TX_QUEUES; i++)
3514 + if (priv->egress_fqs[i] == tx_fq)
3520 +static inline int __hot dpa_xmit(struct dpa_priv_s *priv,
3521 + struct rtnl_link_stats64 *percpu_stats,
3522 + struct qm_fd *fd, struct qman_fq *egress_fq,
3523 + struct qman_fq *conf_fq)
3527 + if (fd->bpid == 0xff)
3528 + fd->cmd |= qman_fq_fqid(conf_fq);
3530 + /* Trace this Tx fd */
3531 + trace_dpa_tx_fd(priv->net_dev, egress_fq, fd);
3533 + for (i = 0; i < 100000; i++) {
3534 + err = qman_enqueue(egress_fq, fd, 0);
3535 + if (err != -EBUSY)
3539 + if (unlikely(err < 0)) {
3540 + /* TODO differentiate b/w -EBUSY (EQCR full) and other codes? */
3541 + percpu_stats->tx_errors++;
3542 + percpu_stats->tx_fifo_errors++;
3546 + percpu_stats->tx_packets++;
3547 + percpu_stats->tx_bytes += dpa_fd_length(fd);
3552 +/* Use multiple WQs for FQ assignment:
3553 + * - Tx Confirmation queues go to WQ1.
3554 + * - Rx Default, Tx and PCD queues go to WQ3 (no differentiation between
3555 + * Rx and Tx traffic, or between Rx Default and Rx PCD frames).
3556 + * - Rx Error and Tx Error queues go to WQ2 (giving them a better chance
3557 + * to be scheduled, in case there are many more FQs in WQ3).
3558 + * This ensures that Tx-confirmed buffers are timely released. In particular,
3559 + * it avoids congestion on the Tx Confirm FQs, which can pile up PFDRs if they
3560 + * are greatly outnumbered by other FQs in the system (usually PCDs), while
3561 + * dequeue scheduling is round-robin.
3563 +static inline void _dpa_assign_wq(struct dpa_fq *fq)
3565 + switch (fq->fq_type) {
3566 + case FQ_TYPE_TX_CONFIRM:
3567 + case FQ_TYPE_TX_CONF_MQ:
3570 + case FQ_TYPE_RX_DEFAULT:
3574 + case FQ_TYPE_RX_ERROR:
3575 + case FQ_TYPE_TX_ERROR:
3576 + case FQ_TYPE_RX_PCD_HI_PRIO:
3579 + case FQ_TYPE_RX_PCD:
3583 + WARN(1, "Invalid FQ type %d for FQID %d!\n",
3584 + fq->fq_type, fq->fqid);
3588 +#ifdef CONFIG_FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
3589 +/* Use in lieu of skb_get_queue_mapping() */
3590 +#ifdef CONFIG_FMAN_PFC
3591 +#define dpa_get_queue_mapping(skb) \
3592 + (((skb)->priority < CONFIG_FMAN_PFC_COS_COUNT) ? \
3593 + ((skb)->priority * dpa_num_cpus + smp_processor_id()) : \
3594 + ((CONFIG_FMAN_PFC_COS_COUNT - 1) * \
3595 + dpa_num_cpus + smp_processor_id()));
3598 +#define dpa_get_queue_mapping(skb) \
3599 + raw_smp_processor_id()
3602 +/* Use the queue selected by XPS */
3603 +#define dpa_get_queue_mapping(skb) \
3604 + skb_get_queue_mapping(skb)
3607 +#ifdef CONFIG_PTP_1588_CLOCK_DPAA
3608 +struct ptp_priv_s {
3609 + struct device_node *node;
3610 + struct platform_device *of_dev;
3611 + struct ptp_clock *clock;
3612 + struct mac_device *mac_dev;
3614 +extern struct ptp_priv_s ptp_priv;
3617 +static inline void _dpa_bp_free_pf(void *addr)
3619 + put_page(virt_to_head_page(addr));
3622 +/* LS1043A SoC has a HW issue regarding FMan DMA transactions; The issue
3623 + * manifests itself at high traffic rates when frames cross 4K memory
3624 + * boundaries or when they are not aligned to 16 bytes; For the moment, we
3625 + * use a SW workaround to avoid frames larger than 4K or that exceed 4K
3626 + * alignments and to realign the frames to 16 bytes.
3630 +extern bool dpaa_errata_a010022; /* SoC affected by A010022 errata */
3631 +#define NONREC_MARK 0x01
3632 +#define HAS_DMA_ISSUE(start, size) \
3633 + (((uintptr_t)(start) + (size)) > \
3634 + (((uintptr_t)(start) + 0x1000) & ~0xFFF))
3635 +#endif /* !CONFIG_PPC */
3637 +#endif /* __DPA_H */
3638 diff --git a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_base.c b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_base.c
3639 new file mode 100644
3640 index 00000000..507e77c3
3642 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_base.c
3644 +/* Copyright 2008-2013 Freescale Semiconductor, Inc.
3646 + * Redistribution and use in source and binary forms, with or without
3647 + * modification, are permitted provided that the following conditions are met:
3648 + * * Redistributions of source code must retain the above copyright
3649 + * notice, this list of conditions and the following disclaimer.
3650 + * * Redistributions in binary form must reproduce the above copyright
3651 + * notice, this list of conditions and the following disclaimer in the
3652 + * documentation and/or other materials provided with the distribution.
3653 + * * Neither the name of Freescale Semiconductor nor the
3654 + * names of its contributors may be used to endorse or promote products
3655 + * derived from this software without specific prior written permission.
3658 + * ALTERNATIVELY, this software may be distributed under the terms of the
3659 + * GNU General Public License ("GPL") as published by the Free Software
3660 + * Foundation, either version 2 of that License or (at your option) any
3663 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
3664 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3665 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3666 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
3667 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
3668 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
3669 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3670 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3671 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3672 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3675 +#ifdef CONFIG_FSL_DPAA_ETH_DEBUG
3676 +#define pr_fmt(fmt) \
3677 + KBUILD_MODNAME ": %s:%hu:%s() " fmt, \
3678 + KBUILD_BASENAME".c", __LINE__, __func__
3680 +#define pr_fmt(fmt) \
3681 + KBUILD_MODNAME ": " fmt
3684 +#include <linux/init.h>
3685 +#include <linux/module.h>
3686 +#include <linux/io.h>
3687 +#include <linux/of_platform.h>
3688 +#include <linux/of_net.h>
3689 +#include <linux/etherdevice.h>
3690 +#include <linux/kthread.h>
3691 +#include <linux/percpu.h>
3692 +#include <linux/highmem.h>
3693 +#include <linux/sort.h>
3694 +#include <linux/fsl_qman.h>
3695 +#include "dpaa_eth.h"
3696 +#include "dpaa_eth_common.h"
3697 +#include "dpaa_eth_base.h"
3699 +#define DPA_DESCRIPTION "FSL DPAA Advanced drivers:"
3701 +MODULE_LICENSE("Dual BSD/GPL");
3703 +uint8_t advanced_debug = -1;
3704 +module_param(advanced_debug, byte, S_IRUGO);
3705 +MODULE_PARM_DESC(advanced_debug, "Module/Driver verbosity level");
3706 +EXPORT_SYMBOL(advanced_debug);
3708 +static int dpa_bp_cmp(const void *dpa_bp0, const void *dpa_bp1)
3710 + return ((struct dpa_bp *)dpa_bp0)->size -
3711 + ((struct dpa_bp *)dpa_bp1)->size;
3714 +struct dpa_bp * __cold __must_check /* __attribute__((nonnull)) */
3715 +dpa_bp_probe(struct platform_device *_of_dev, size_t *count)
3717 + int i, lenp, na, ns, err;
3718 + struct device *dev;
3719 + struct device_node *dev_node;
3720 + const __be32 *bpool_cfg;
3721 + struct dpa_bp *dpa_bp;
3724 + dev = &_of_dev->dev;
3726 + *count = of_count_phandle_with_args(dev->of_node,
3727 + "fsl,bman-buffer-pools", NULL);
3729 + dev_err(dev, "missing fsl,bman-buffer-pools device tree entry\n");
3730 + return ERR_PTR(-EINVAL);
3733 + dpa_bp = devm_kzalloc(dev, *count * sizeof(*dpa_bp), GFP_KERNEL);
3734 + if (dpa_bp == NULL) {
3735 + dev_err(dev, "devm_kzalloc() failed\n");
3736 + return ERR_PTR(-ENOMEM);
3739 + dev_node = of_find_node_by_path("/");
3740 + if (unlikely(dev_node == NULL)) {
3741 + dev_err(dev, "of_find_node_by_path(/) failed\n");
3742 + return ERR_PTR(-EINVAL);
3745 + na = of_n_addr_cells(dev_node);
3746 + ns = of_n_size_cells(dev_node);
3748 + for (i = 0; i < *count; i++) {
3749 + of_node_put(dev_node);
3751 + dev_node = of_parse_phandle(dev->of_node,
3752 + "fsl,bman-buffer-pools", i);
3753 + if (dev_node == NULL) {
3754 + dev_err(dev, "of_find_node_by_phandle() failed\n");
3755 + return ERR_PTR(-EFAULT);
3758 + if (unlikely(!of_device_is_compatible(dev_node, "fsl,bpool"))) {
3760 + "!of_device_is_compatible(%s, fsl,bpool)\n",
3761 + dev_node->full_name);
3762 + dpa_bp = ERR_PTR(-EINVAL);
3763 + goto _return_of_node_put;
3766 + err = of_property_read_u32(dev_node, "fsl,bpid", &bpid);
3768 + dev_err(dev, "Cannot find buffer pool ID in the device tree\n");
3769 + dpa_bp = ERR_PTR(-EINVAL);
3770 + goto _return_of_node_put;
3772 + dpa_bp[i].bpid = (uint8_t)bpid;
3774 + bpool_cfg = of_get_property(dev_node, "fsl,bpool-ethernet-cfg",
3776 + if (bpool_cfg && (lenp == (2 * ns + na) * sizeof(*bpool_cfg))) {
3777 + const uint32_t *seed_pool;
3779 + dpa_bp[i].config_count =
3780 + (int)of_read_number(bpool_cfg, ns);
3782 + (size_t)of_read_number(bpool_cfg + ns, ns);
3784 + of_read_number(bpool_cfg + 2 * ns, na);
3786 + seed_pool = of_get_property(dev_node,
3787 + "fsl,bpool-ethernet-seeds", &lenp);
3788 + dpa_bp[i].seed_pool = !!seed_pool;
3792 + "Missing/invalid fsl,bpool-ethernet-cfg device tree entry for node %s\n",
3793 + dev_node->full_name);
3794 + dpa_bp = ERR_PTR(-EINVAL);
3795 + goto _return_of_node_put;
3799 + sort(dpa_bp, *count, sizeof(*dpa_bp), dpa_bp_cmp, NULL);
3803 +_return_of_node_put:
3805 + of_node_put(dev_node);
3809 +EXPORT_SYMBOL(dpa_bp_probe);
3811 +int dpa_bp_create(struct net_device *net_dev, struct dpa_bp *dpa_bp,
3814 + struct dpa_priv_s *priv = netdev_priv(net_dev);
3817 + priv->dpa_bp = dpa_bp;
3818 + priv->bp_count = count;
3820 + for (i = 0; i < count; i++) {
3822 + err = dpa_bp_alloc(&dpa_bp[i]);
3824 + dpa_bp_free(priv);
3825 + priv->dpa_bp = NULL;
3832 +EXPORT_SYMBOL(dpa_bp_create);
3834 +static int __init __cold dpa_advanced_load(void)
3836 + pr_info(DPA_DESCRIPTION "\n");
3840 +module_init(dpa_advanced_load);
3842 +static void __exit __cold dpa_advanced_unload(void)
3844 + pr_debug(KBUILD_MODNAME ": -> %s:%s()\n",
3845 + KBUILD_BASENAME".c", __func__);
3848 +module_exit(dpa_advanced_unload);
3849 diff --git a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_base.h b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_base.h
3850 new file mode 100644
3851 index 00000000..6ec68c3c
3853 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_base.h
3855 +/* Copyright 2008-2013 Freescale Semiconductor, Inc.
3857 + * Redistribution and use in source and binary forms, with or without
3858 + * modification, are permitted provided that the following conditions are met:
3859 + * * Redistributions of source code must retain the above copyright
3860 + * notice, this list of conditions and the following disclaimer.
3861 + * * Redistributions in binary form must reproduce the above copyright
3862 + * notice, this list of conditions and the following disclaimer in the
3863 + * documentation and/or other materials provided with the distribution.
3864 + * * Neither the name of Freescale Semiconductor nor the
3865 + * names of its contributors may be used to endorse or promote products
3866 + * derived from this software without specific prior written permission.
3869 + * ALTERNATIVELY, this software may be distributed under the terms of the
3870 + * GNU General Public License ("GPL") as published by the Free Software
3871 + * Foundation, either version 2 of that License or (at your option) any
3874 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
3875 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3876 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3877 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
3878 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
3879 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
3880 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3881 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3882 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3883 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3886 +#ifndef __DPAA_ETH_BASE_H
3887 +#define __DPAA_ETH_BASE_H
3889 +#include <linux/etherdevice.h> /* struct net_device */
3890 +#include <linux/fsl_bman.h> /* struct bm_buffer */
3891 +#include <linux/of_platform.h> /* struct platform_device */
3892 +#include <linux/net_tstamp.h> /* struct hwtstamp_config */
3894 +extern uint8_t advanced_debug;
3895 +extern const struct dpa_fq_cbs_t shared_fq_cbs;
3896 +extern int __hot dpa_shared_tx(struct sk_buff *skb, struct net_device *net_dev);
3898 +struct dpa_bp * __cold __must_check /* __attribute__((nonnull)) */
3899 +dpa_bp_probe(struct platform_device *_of_dev, size_t *count);
3900 +int dpa_bp_create(struct net_device *net_dev, struct dpa_bp *dpa_bp,
3903 +#endif /* __DPAA_ETH_BASE_H */
3904 diff --git a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c
3905 new file mode 100644
3906 index 00000000..cac613b7
3908 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c
3910 +/* Copyright 2008-2016 Freescale Semiconductor Inc.
3912 + * Redistribution and use in source and binary forms, with or without
3913 + * modification, are permitted provided that the following conditions are met:
3914 + * * Redistributions of source code must retain the above copyright
3915 + * notice, this list of conditions and the following disclaimer.
3916 + * * Redistributions in binary form must reproduce the above copyright
3917 + * notice, this list of conditions and the following disclaimer in the
3918 + * documentation and/or other materials provided with the distribution.
3919 + * * Neither the name of Freescale Semiconductor nor the
3920 + * names of its contributors may be used to endorse or promote products
3921 + * derived from this software without specific prior written permission.
3924 + * ALTERNATIVELY, this software may be distributed under the terms of the
3925 + * GNU General Public License ("GPL") as published by the Free Software
3926 + * Foundation, either version 2 of that License or (at your option) any
3929 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
3930 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3931 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3932 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
3933 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
3934 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
3935 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3936 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3937 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3938 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3941 +#include <linux/init.h>
3942 +#include "dpaa_eth_ceetm.h"
3944 +#define DPA_CEETM_DESCRIPTION "FSL DPAA CEETM qdisc"
3946 +const struct nla_policy ceetm_policy[TCA_CEETM_MAX + 1] = {
3947 + [TCA_CEETM_COPT] = { .len = sizeof(struct tc_ceetm_copt) },
3948 + [TCA_CEETM_QOPS] = { .len = sizeof(struct tc_ceetm_qopt) },
3951 +struct Qdisc_ops ceetm_qdisc_ops;