All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] drivers: net: fsl-mc: fix MAC address fixup procedure
@ 2023-02-09 16:07 Ioana Ciornei
  2023-02-09 16:07 ` [PATCH 1/2] drivers: net: ldpaa: export driver name and API to get DPMAC id Ioana Ciornei
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ioana Ciornei @ 2023-02-09 16:07 UTC (permalink / raw)
  To: joe.hershberger, rfried.dev, u-boot
  Cc: sjg, peng.fan, vladimir.oltean, Ioana Ciornei

This patch set fixes the MAC address fixup procedure which was impacted
by several changes in the phy_interface_t used to describe some
interfaces. The transitions from "xgmii" to "xfi" and then finally
to "10gbase-r" were involved.

The first patch just exports a function to identify the DPMAC id of an
UCLASS_ETH device and the DPAA2 driver name as a macro.

Ioana Ciornei (2):
  drivers: net: ldpaa: export driver name and API to get DPMAC id
  drivers: net: fsl-mc: fix MAC address fixup procedure

 drivers/net/fsl-mc/mc.c           | 31 +++++++++++++------------------
 drivers/net/ldpaa_eth/ldpaa_eth.c |  7 ++++---
 include/net/ldpaa_eth.h           | 15 +++++++++++++++
 3 files changed, 32 insertions(+), 21 deletions(-)
 create mode 100644 include/net/ldpaa_eth.h

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] drivers: net: ldpaa: export driver name and API to get DPMAC id
  2023-02-09 16:07 [PATCH 0/2] drivers: net: fsl-mc: fix MAC address fixup procedure Ioana Ciornei
@ 2023-02-09 16:07 ` Ioana Ciornei
  2023-05-06 14:54   ` Tom Rini
  2023-02-09 16:07 ` [PATCH 2/2] drivers: net: fsl-mc: fix MAC address fixup procedure Ioana Ciornei
  2023-03-15 13:11 ` [PATCH 0/2] " Ioana Ciornei
  2 siblings, 1 reply; 7+ messages in thread
From: Ioana Ciornei @ 2023-02-09 16:07 UTC (permalink / raw)
  To: joe.hershberger, rfried.dev, u-boot
  Cc: sjg, peng.fan, vladimir.oltean, Ioana Ciornei

Export the ldpaa_eth_get_dpmac_id() function so that it can be used from
other drivers, especially by fsl-mc which will need it the next patch.
Also, create a macro for the Ethernet ldpaa driver name and export it as
well.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/ldpaa_eth/ldpaa_eth.c |  7 ++++---
 include/net/ldpaa_eth.h           | 15 +++++++++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)
 create mode 100644 include/net/ldpaa_eth.h

diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 24850777949a..2cb6e9b7d705 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2014-2016 Freescale Semiconductor, Inc.
- * Copyright 2017 NXP
+ * Copyright 2017, 2023 NXP
  */
 
 #include <common.h>
@@ -21,6 +21,7 @@
 #include <linux/compat.h>
 #include <linux/delay.h>
 #include <asm/global_data.h>
+#include <net/ldpaa_eth.h>
 #include "ldpaa_eth.h"
 
 #ifdef CONFIG_PHYLIB
@@ -995,7 +996,7 @@ static int ldpaa_eth_probe(struct udevice *dev)
 	return 0;
 }
 
-static uint32_t ldpaa_eth_get_dpmac_id(struct udevice *dev)
+uint32_t ldpaa_eth_get_dpmac_id(struct udevice *dev)
 {
 	int port_node = dev_of_offset(dev);
 
@@ -1049,7 +1050,7 @@ static const struct udevice_id ldpaa_eth_of_ids[] = {
 };
 
 U_BOOT_DRIVER(ldpaa_eth) = {
-	.name = "ldpaa_eth",
+	.name = LDPAA_ETH_DRIVER_NAME,
 	.id = UCLASS_ETH,
 	.of_match = ldpaa_eth_of_ids,
 	.of_to_plat = ldpaa_eth_of_to_plat,
diff --git a/include/net/ldpaa_eth.h b/include/net/ldpaa_eth.h
new file mode 100644
index 000000000000..7474bfaeec30
--- /dev/null
+++ b/include/net/ldpaa_eth.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2023 NXP
+ */
+
+#define LDPAA_ETH_DRIVER_NAME	"ldpaa_eth"
+
+/**
+ * ldpaa_eth_get_dpmac_id() - Get the dpmac_id of a DPAA2 ethernet device
+ *
+ * @dev:	DPAA2 ethernet udevice pointer
+ * Return: requested dpmac_id
+ */
+
+uint32_t ldpaa_eth_get_dpmac_id(struct udevice *dev);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] drivers: net: fsl-mc: fix MAC address fixup procedure
  2023-02-09 16:07 [PATCH 0/2] drivers: net: fsl-mc: fix MAC address fixup procedure Ioana Ciornei
  2023-02-09 16:07 ` [PATCH 1/2] drivers: net: ldpaa: export driver name and API to get DPMAC id Ioana Ciornei
@ 2023-02-09 16:07 ` Ioana Ciornei
  2023-02-18 20:07   ` Ramon Fried
  2023-05-06 14:54   ` Tom Rini
  2023-03-15 13:11 ` [PATCH 0/2] " Ioana Ciornei
  2 siblings, 2 replies; 7+ messages in thread
From: Ioana Ciornei @ 2023-02-09 16:07 UTC (permalink / raw)
  To: joe.hershberger, rfried.dev, u-boot
  Cc: sjg, peng.fan, vladimir.oltean, Ioana Ciornei

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 <ioana.ciornei@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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] drivers: net: fsl-mc: fix MAC address fixup procedure
  2023-02-09 16:07 ` [PATCH 2/2] drivers: net: fsl-mc: fix MAC address fixup procedure Ioana Ciornei
@ 2023-02-18 20:07   ` Ramon Fried
  2023-05-06 14:54   ` Tom Rini
  1 sibling, 0 replies; 7+ messages in thread
From: Ramon Fried @ 2023-02-18 20:07 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: joe.hershberger, u-boot, sjg, peng.fan, vladimir.oltean

On Thu, Feb 9, 2023 at 6:07 PM Ioana Ciornei <ioana.ciornei@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@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 <ioana.ciornei@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@gmail.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] drivers: net: fsl-mc: fix MAC address fixup procedure
  2023-02-09 16:07 [PATCH 0/2] drivers: net: fsl-mc: fix MAC address fixup procedure Ioana Ciornei
  2023-02-09 16:07 ` [PATCH 1/2] drivers: net: ldpaa: export driver name and API to get DPMAC id Ioana Ciornei
  2023-02-09 16:07 ` [PATCH 2/2] drivers: net: fsl-mc: fix MAC address fixup procedure Ioana Ciornei
@ 2023-03-15 13:11 ` Ioana Ciornei
  2 siblings, 0 replies; 7+ messages in thread
From: Ioana Ciornei @ 2023-03-15 13:11 UTC (permalink / raw)
  To: joe.hershberger, rfried.dev, u-boot; +Cc: sjg, peng.fan, vladimir.oltean

On Thu, Feb 09, 2023 at 06:07:02PM +0200, Ioana Ciornei wrote:
> This patch set fixes the MAC address fixup procedure which was impacted
> by several changes in the phy_interface_t used to describe some
> interfaces. The transitions from "xgmii" to "xfi" and then finally
> to "10gbase-r" were involved.
> 
> The first patch just exports a function to identify the DPMAC id of an
> UCLASS_ETH device and the DPAA2 driver name as a macro.
> 
> Ioana Ciornei (2):
>   drivers: net: ldpaa: export driver name and API to get DPMAC id
>   drivers: net: fsl-mc: fix MAC address fixup procedure
> 

Is there any chance for this two patches to be picked up for the
v2023.04 release?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] drivers: net: ldpaa: export driver name and API to get DPMAC id
  2023-02-09 16:07 ` [PATCH 1/2] drivers: net: ldpaa: export driver name and API to get DPMAC id Ioana Ciornei
@ 2023-05-06 14:54   ` Tom Rini
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2023-05-06 14:54 UTC (permalink / raw)
  To: Ioana Ciornei
  Cc: joe.hershberger, rfried.dev, u-boot, sjg, peng.fan, vladimir.oltean

[-- Attachment #1: Type: text/plain, Size: 410 bytes --]

On Thu, Feb 09, 2023 at 06:07:03PM +0200, Ioana Ciornei wrote:

> Export the ldpaa_eth_get_dpmac_id() function so that it can be used from
> other drivers, especially by fsl-mc which will need it the next patch.
> Also, create a macro for the Ethernet ldpaa driver name and export it as
> well.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] drivers: net: fsl-mc: fix MAC address fixup procedure
  2023-02-09 16:07 ` [PATCH 2/2] drivers: net: fsl-mc: fix MAC address fixup procedure Ioana Ciornei
  2023-02-18 20:07   ` Ramon Fried
@ 2023-05-06 14:54   ` Tom Rini
  1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2023-05-06 14:54 UTC (permalink / raw)
  To: Ioana Ciornei
  Cc: joe.hershberger, rfried.dev, u-boot, sjg, peng.fan, vladimir.oltean

[-- Attachment #1: Type: text/plain, Size: 1417 bytes --]

On Thu, Feb 09, 2023 at 06:07:04PM +0200, Ioana Ciornei 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@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 <ioana.ciornei@nxp.com>
> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-06 14:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09 16:07 [PATCH 0/2] drivers: net: fsl-mc: fix MAC address fixup procedure Ioana Ciornei
2023-02-09 16:07 ` [PATCH 1/2] drivers: net: ldpaa: export driver name and API to get DPMAC id Ioana Ciornei
2023-05-06 14:54   ` Tom Rini
2023-02-09 16:07 ` [PATCH 2/2] drivers: net: fsl-mc: fix MAC address fixup procedure Ioana Ciornei
2023-02-18 20:07   ` Ramon Fried
2023-05-06 14:54   ` Tom Rini
2023-03-15 13:11 ` [PATCH 0/2] " Ioana Ciornei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.