[PATCH 2/2] drivers: net: fsl-mc: fix MAC address fixup procedure

Ramon Fried rfried.dev at gmail.com
Sat Feb 18 21:07:30 CET 2023


On Thu, Feb 9, 2023 at 6:07 PM Ioana Ciornei <ioana.ciornei at nxp.com> wrote:
>
> 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 at xgmii1" by name
> using eth_get_dev_by_name() when only "DPMAC1 at 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 <ioana.ciornei at nxp.com>
> ---
>  drivers/net/fsl-mc/mc.c | 31 +++++++++++++------------------
>  1 file changed, 13 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
> index 4f84403d956c..78a40f285aa2 100644
> --- a/drivers/net/fsl-mc/mc.c
> +++ b/drivers/net/fsl-mc/mc.c
> @@ -29,6 +29,7 @@
>  #include <fsl-mc/fsl_dpsparser.h>
>  #include <fsl-mc/fsl_qbman_portal.h>
>  #include <fsl-mc/ldpaa_wriop.h>
> +#include <net/ldpaa_eth.h>
>
>  #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;
>         }
>
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev at gmail.com>


More information about the U-Boot mailing list