From: Ioana Ciornei Date: Thu, 9 Feb 2023 16:07:04 +0000 (+0200) Subject: drivers: net: fsl-mc: fix MAC address fixup procedure X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=8491a7e4ed82a996189a8c97acca90e88f63d345;p=u-boot.git drivers: net: fsl-mc: fix MAC address fixup procedure In the process of adopting CONFIG_DM_ETH on the DPAA2 based platforms, interfaces which were previously defined as "xgmii" were transitioned to be defined as "xfi" in the DTS. See the commit below for reference: commit 87274918f2f4 ("arm: dts: ls2088ardb: add DPMAC and PHY nodes") Then Vladimir's commit replaced all occurrences of "xfi" with "10gbase-r" in an effort to make U-Boot work with the same device tree as Linux. commit 77b11f760416 ("net: replace the "xfi" phy-mode with "10gbase-r"") These changes to the phy_interface_t of an Ethernet port meant that the mc_fixup_mac_addrs() function was no longer capable to properly fixup the MAC addresses. The problem arises from the fact that the hardcoded information about an interface (wriop_get_enet_if()) was no longer matching any actual device. For example, the function tried to search for "DPMAC1@xgmii1" by name using eth_get_dev_by_name() when only "DPMAC1@10gbase-r" was available. This function removes the need to rely on the hardcoded information by iterating through all the UCLASS_ETH devices which are DPAA2 and request a fixup for each of them. Signed-off-by: Ioana Ciornei Reviewed-by: Ramon Fried --- diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c index 4f84403d95..78a40f285a 100644 --- a/drivers/net/fsl-mc/mc.c +++ b/drivers/net/fsl-mc/mc.c @@ -29,6 +29,7 @@ #include #include #include +#include #define MC_RAM_BASE_ADDR_ALIGNMENT (512UL * 1024 * 1024) #define MC_RAM_BASE_ADDR_ALIGNMENT_MASK (~(MC_RAM_BASE_ADDR_ALIGNMENT - 1)) @@ -383,37 +384,31 @@ static int mc_fixup_dpc_mac_addr(void *blob, int dpmac_id, static int mc_fixup_mac_addrs(void *blob, enum mc_fixup_type type) { - int i, err = 0, ret = 0; -#define ETH_NAME_LEN 20 struct udevice *eth_dev; - char ethname[ETH_NAME_LEN]; - - for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) { - /* port not enabled */ - if (wriop_is_enabled_dpmac(i) != 1) - continue; - - snprintf(ethname, ETH_NAME_LEN, "DPMAC%d@%s", i, - phy_interface_strings[wriop_get_enet_if(i)]); - - eth_dev = eth_get_dev_by_name(ethname); - if (eth_dev == NULL) + int err = 0, ret = 0; + struct uclass *uc; + uint32_t dpmac_id; + + uclass_get(UCLASS_ETH, &uc); + uclass_foreach_dev(eth_dev, uc) { + if (!eth_dev->driver || !eth_dev->driver->name || + strcmp(eth_dev->driver->name, LDPAA_ETH_DRIVER_NAME)) continue; + dpmac_id = ldpaa_eth_get_dpmac_id(eth_dev); switch (type) { case MC_FIXUP_DPL: - err = mc_fixup_dpl_mac_addr(blob, i, eth_dev); + err = mc_fixup_dpl_mac_addr(blob, dpmac_id, eth_dev); break; case MC_FIXUP_DPC: - err = mc_fixup_dpc_mac_addr(blob, i, eth_dev); + err = mc_fixup_dpc_mac_addr(blob, dpmac_id, eth_dev); break; default: break; } if (err) - printf("fsl-mc: ERROR fixing mac address for %s\n", - ethname); + printf("fsl-mc: ERROR fixing mac address for %s\n", eth_dev->name); ret |= err; }