OpenCloudOS-Kernel/drivers/net/ethernet/freescale
Vladimir Oltean 5d14c304bf dpaa_eth: fix usage as DSA master, try 3
The dpaa-eth driver probes on compatible string for the MAC node, and
the fman/mac.c driver allocates a dpaa-ethernet platform device that
triggers the probing of the dpaa-eth net device driver.

All of this is fine, but the problem is that the struct device of the
dpaa_eth net_device is 2 parents away from the MAC which can be
referenced via of_node. So of_find_net_device_by_node can't find it, and
DSA switches won't be able to probe on top of FMan ports.

It would be a bit silly to modify a core function
(of_find_net_device_by_node) to look for dev->parent->parent->of_node
just for one driver. We're just 1 step away from implementing full
recursion.

Actually there have already been at least 2 previous attempts to make
this work:
- Commit a1a50c8e4c ("fsl/man: Inherit parent device and of_node")
- One or more of the patches in "[v3,0/6] adapt DPAA drivers for DSA":
  https://patchwork.ozlabs.org/project/netdev/cover/1508178970-28945-1-git-send-email-madalin.bucur@nxp.com/
  (I couldn't really figure out which one was supposed to solve the
  problem and how).

Point being, it looks like this is still pretty much a problem today.
On T1040, the /sys/class/net/eth0 symlink currently points to

../../devices/platform/ffe000000.soc/ffe400000.fman/ffe4e6000.ethernet/dpaa-ethernet.0/net/eth0

which pretty much illustrates the problem. The closest of_node we've got
is the "fsl,fman-memac" at /soc@ffe000000/fman@400000/ethernet@e6000,
which is what we'd like to be able to reference from DSA as host port.

For of_find_net_device_by_node to find the eth0 port, we would need the
parent of the eth0 net_device to not be the "dpaa-ethernet" platform
device, but to point 1 level higher, aka the "fsl,fman-memac" node
directly. The new sysfs path would look like this:

../../devices/platform/ffe000000.soc/ffe400000.fman/ffe4e6000.ethernet/net/eth0

And this is exactly what SET_NETDEV_DEV does. It sets the parent of the
net_device. The new parent has an of_node associated with it, and
of_dev_node_match already checks for the of_node of the device or of its
parent.

Fixes: a1a50c8e4c ("fsl/man: Inherit parent device and of_node")
Fixes: c6e26ea8c8 ("dpaa_eth: change device used")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-05-25 17:56:53 -07:00
..
dpaa dpaa_eth: fix usage as DSA master, try 3 2020-05-25 17:56:53 -07:00
dpaa2 dpaa2-eth: properly handle buffer size restrictions 2020-05-15 10:30:47 -07:00
enetc net: enetc: fix an issue about leak system resources 2020-05-04 10:51:20 -07:00
fman Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-03-25 18:58:11 -07:00
fs_enet net/freescale: Clean drivers from static versions 2020-03-03 17:54:55 -08:00
Kconfig net: freescale: select CONFIG_FIXED_PHY where needed 2020-05-09 15:47:21 -07:00
Makefile net: dsa: felix: fix link error 2020-01-08 16:05:54 -08:00
fec.h net: fec: set GPR bit on suspend by DT configuration. 2020-04-07 18:23:37 -07:00
fec_main.c net: fec: set GPR bit on suspend by DT configuration. 2020-04-07 18:23:37 -07:00
fec_mpc52xx.c net: convert suitable network drivers to use phy_do_ioctl 2020-01-21 10:50:41 +01:00
fec_mpc52xx.h
fec_mpc52xx_phy.c mdio: Move allocation of interrupts into core 2016-01-07 14:31:26 -05:00
fec_ptp.c net: fec_ptp: Use platform_get_irq_xxx_optional() to avoid error message 2019-10-29 17:57:16 -07:00
fsl_pq_mdio.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
gianfar.c net/freescale: Clean drivers from static versions 2020-03-03 17:54:55 -08:00
gianfar.h net/freescale: Clean drivers from static versions 2020-03-03 17:54:55 -08:00
gianfar_ethtool.c net: gianfar: reject unsupported coalescing params 2020-03-12 11:32:35 -07:00
ucc_geth.c net/ethernet/freescale: rework quiesce/activate for ucc_geth 2020-05-22 15:50:34 -07:00
ucc_geth.h net/freescale: Clean drivers from static versions 2020-03-03 17:54:55 -08:00
ucc_geth_ethtool.c net/freescale: Don't set zero if FW not-available in ucc_geth 2020-03-03 17:54:55 -08:00
xgmac_mdio.c net/fsl: treat fsl,erratum-a011043 2020-01-23 21:17:13 +01:00