All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC
@ 2017-01-11 15:58 Bogdan Purcareata
  2017-02-06 18:06 ` york sun
  0 siblings, 1 reply; 6+ messages in thread
From: Bogdan Purcareata @ 2017-01-11 15:58 UTC (permalink / raw)
  To: u-boot

Fixup port_mac_address property in MC DPC with values from the u-boot
environment. Since u-boot already reads the environment MAC addresses
when probing the PHYs, use these values.

The u-boot environment MAC addresses take precedence over any eventual
ones defined in the DPC, except for the case where they are randomly
assigned (no u-boot env value declared for port).

The patch assumes the "/board_info/ports/" node is present in the DPC.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
---
 drivers/net/fsl-mc/mc.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 101 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 2a2d3e5..cca579a 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -7,6 +7,7 @@
 #include <errno.h>
 #include <asm/io.h>
 #include <libfdt.h>
+#include <net.h>
 #include <fdt_support.h>
 #include <fsl-mc/fsl_mc.h>
 #include <fsl-mc/fsl_mc_sys.h>
@@ -197,10 +198,81 @@ static int calculate_mc_private_ram_params(u64 mc_private_ram_start_addr,
 	return 0;
 }
 
+static int mc_fixup_dpc_mac_addr(void *blob, int noff, int dpmac_id,
+		struct eth_device *eth_dev)
+{
+	int nodeoffset, err = 0;
+	char mac_name[10];
+	const char link_type_mode[] = "FIXED_LINK";
+	unsigned char env_enetaddr[6];
+
+	sprintf(mac_name, "mac@%d", dpmac_id);
+
+	/* node not found - create it */
+	nodeoffset = fdt_subnode_offset(blob, noff, (const char *) mac_name);
+	if (nodeoffset < 0) {
+		err = fdt_increase_size(blob, 200);
+		if (err) {
+			printf("fdt_increase_size: err=%s\n",
+				fdt_strerror(err));
+			return err;
+		}
+
+		nodeoffset = fdt_add_subnode(blob, noff, mac_name);
+
+		/* add default property of fixed link */
+		err = fdt_appendprop_string(blob, nodeoffset,
+			"link_type", link_type_mode);
+		if (err) {
+			printf("fdt_appendprop_string: err=%s\n",
+				fdt_strerror(err));
+			return err;
+		}
+	}
+
+	/* port_mac_address property present in DPC */
+	if (fdt_get_property(blob, nodeoffset, "port_mac_address", NULL)) {
+		/* MAC addr randomly assigned - leave the one in DPC */
+		eth_getenv_enetaddr_by_index("eth", eth_dev->index,
+						env_enetaddr);
+		if (is_zero_ethaddr(env_enetaddr))
+			return err;
+
+		/* replace DPC MAC address with u-boot env one */
+		err = fdt_setprop(blob, nodeoffset, "port_mac_address",
+			eth_dev->enetaddr, 6);
+		if (err) {
+			printf("fdt_setprop mac: err=%s\n", fdt_strerror(err));
+			return err;
+		}
+
+		return 0;
+	}
+
+	/* append port_mac_address property to mac node in DPC */
+	err = fdt_increase_size(blob, 80);
+	if (err) {
+		printf("fdt_increase_size: err=%s\n", fdt_strerror(err));
+		return err;
+	}
+
+	err = fdt_appendprop(blob, nodeoffset,
+			     "port_mac_address", eth_dev->enetaddr, 6);
+	if (err) {
+		printf("fdt_appendprop: err=%s\n", fdt_strerror(err));
+		return err;
+	}
+
+	return err;
+}
+
 static int mc_fixup_dpc(u64 dpc_addr)
 {
 	void *blob = (void *)dpc_addr;
-	int nodeoffset;
+	int nodeoffset, err = 0;
+	char ethname[10];
+	struct eth_device *eth_dev;
+	int i;
 
 	/* delete any existing ICID pools */
 	nodeoffset = fdt_path_offset(blob, "/resources/icid_pools");
@@ -222,9 +294,36 @@ static int mc_fixup_dpc(u64 dpc_addr)
 			     FSL_DPAA2_STREAM_ID_END -
 			     FSL_DPAA2_STREAM_ID_START + 1, 1);
 
+	/* fixup MAC addresses for dpmac ports */
+	nodeoffset = fdt_path_offset(blob, "/board_info/ports");
+	if (nodeoffset < 0)
+		goto out;
+
+	for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) {
+		/* port not enabled */
+		if ((wriop_is_enabled_dpmac(i) != 1) ||
+		    (wriop_get_phy_address(i) == -1))
+			continue;
+
+		sprintf(ethname, "DPMAC%d@%s", i,
+			phy_interface_strings[wriop_get_enet_if(i)]);
+
+		eth_dev = eth_get_dev_by_name(ethname);
+		if (eth_dev == NULL)
+			continue;
+
+		err = mc_fixup_dpc_mac_addr(blob, nodeoffset, i, eth_dev);
+		if (err) {
+			printf("mc_fixup_dpc_mac_addr failed: err=%s\n",
+			fdt_strerror(err));
+			goto out;
+		}
+	}
+
+out:
 	flush_dcache_range(dpc_addr, dpc_addr + fdt_totalsize(blob));
 
-	return 0;
+	return err;
 }
 
 static int load_mc_dpc(u64 mc_ram_aligned_base_addr, size_t mc_ram_size,
-- 
1.9.1

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

* [U-Boot] [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC
  2017-01-11 15:58 [U-Boot] [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC Bogdan Purcareata
@ 2017-02-06 18:06 ` york sun
  0 siblings, 0 replies; 6+ messages in thread
From: york sun @ 2017-02-06 18:06 UTC (permalink / raw)
  To: u-boot

On 01/11/2017 07:58 AM, Bogdan Purcareata wrote:
> Fixup port_mac_address property in MC DPC with values from the u-boot
> environment. Since u-boot already reads the environment MAC addresses
> when probing the PHYs, use these values.
>
> The u-boot environment MAC addresses take precedence over any eventual
> ones defined in the DPC, except for the case where they are randomly
> assigned (no u-boot env value declared for port).
>
> The patch assumes the "/board_info/ports/" node is present in the DPC.
>
> Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
> ---
>  drivers/net/fsl-mc/mc.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 101 insertions(+), 2 deletions(-)
>

Applied to u-boot-qoriq master. Thanks.

York

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

* [U-Boot] [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC
  2017-01-30 11:09     ` Prabhakar Kushwaha
@ 2017-01-30 16:04       ` york sun
  0 siblings, 0 replies; 6+ messages in thread
From: york sun @ 2017-01-30 16:04 UTC (permalink / raw)
  To: u-boot

On 01/30/2017 03:09 AM, Prabhakar Kushwaha wrote:
> Hi York,
>
>
>> -----Original Message-----
>> From: york sun
>> Sent: Saturday, January 28, 2017 2:15 AM
>> To: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>; Bogdan Purcareata
>> <bogdan.purcareata@nxp.com>; u-boot at lists.denx.de
>> Subject: Re: [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC
>>
>> On 01/26/2017 05:05 AM, Prabhakar Kushwaha wrote:
>>>
>>>> -----Original Message-----
>>>> From: Bogdan Purcareata [mailto:bogdan.purcareata at nxp.com]
>>>> Sent: Thursday, January 11, 2017 9:35 AM
>>>> To: u-boot at lists.denx.de
>>>> Cc: Bogdan Purcareata <bogdan.purcareata@nxp.com>
>>>> Subject: [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC
>>>>
>>>> Fixup port_mac_address property in MC DPC with values from the u-boot
>>>> environment. Since u-boot already reads the environment MAC addresses
>>>> when probing the PHYs, use these values.
>>>>
>>>> The u-boot environment MAC addresses take precedence over any eventual
>>>> ones defined in the DPC, except for the case where they are randomly
>>>> assigned (no u-boot env value declared for port).
>>>>
>>>> The patch assumes the "/board_info/ports/" node is present in the DPC.
>>>>
>>>> Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
>>>
>>> Reviewed-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
>>>
>>
>> Prabhakar,
>>
>> I don't know how you replied with your comment. But your email client
>> changed the message ID so patchwork couldn't match it.
>>
>
> Oh..
> Looks like I did some mistake...
>
> Will it be possible to provide original message/mail which was sent on the mailing list so that I can provide "review-by" again
>
> --prabhakar
>

I will manually add your review signature when merging this one. Just 
curious how it was messed up.

York

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

* [U-Boot] [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC
  2017-01-27 20:45   ` york sun
@ 2017-01-30 11:09     ` Prabhakar Kushwaha
  2017-01-30 16:04       ` york sun
  0 siblings, 1 reply; 6+ messages in thread
From: Prabhakar Kushwaha @ 2017-01-30 11:09 UTC (permalink / raw)
  To: u-boot

Hi York,


> -----Original Message-----
> From: york sun
> Sent: Saturday, January 28, 2017 2:15 AM
> To: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>; Bogdan Purcareata
> <bogdan.purcareata@nxp.com>; u-boot at lists.denx.de
> Subject: Re: [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC
> 
> On 01/26/2017 05:05 AM, Prabhakar Kushwaha wrote:
> >
> >> -----Original Message-----
> >> From: Bogdan Purcareata [mailto:bogdan.purcareata at nxp.com]
> >> Sent: Thursday, January 11, 2017 9:35 AM
> >> To: u-boot at lists.denx.de
> >> Cc: Bogdan Purcareata <bogdan.purcareata@nxp.com>
> >> Subject: [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC
> >>
> >> Fixup port_mac_address property in MC DPC with values from the u-boot
> >> environment. Since u-boot already reads the environment MAC addresses
> >> when probing the PHYs, use these values.
> >>
> >> The u-boot environment MAC addresses take precedence over any eventual
> >> ones defined in the DPC, except for the case where they are randomly
> >> assigned (no u-boot env value declared for port).
> >>
> >> The patch assumes the "/board_info/ports/" node is present in the DPC.
> >>
> >> Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
> >
> > Reviewed-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
> >
> 
> Prabhakar,
> 
> I don't know how you replied with your comment. But your email client
> changed the message ID so patchwork couldn't match it.
> 

Oh..  
Looks like I did some mistake... 

Will it be possible to provide original message/mail which was sent on the mailing list so that I can provide "review-by" again

--prabhakar

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

* [U-Boot] [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC
  2017-01-26 13:05 ` Prabhakar Kushwaha
@ 2017-01-27 20:45   ` york sun
  2017-01-30 11:09     ` Prabhakar Kushwaha
  0 siblings, 1 reply; 6+ messages in thread
From: york sun @ 2017-01-27 20:45 UTC (permalink / raw)
  To: u-boot

On 01/26/2017 05:05 AM, Prabhakar Kushwaha wrote:
>
>> -----Original Message-----
>> From: Bogdan Purcareata [mailto:bogdan.purcareata at nxp.com]
>> Sent: Thursday, January 11, 2017 9:35 AM
>> To: u-boot at lists.denx.de
>> Cc: Bogdan Purcareata <bogdan.purcareata@nxp.com>
>> Subject: [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC
>>
>> Fixup port_mac_address property in MC DPC with values from the u-boot
>> environment. Since u-boot already reads the environment MAC addresses
>> when probing the PHYs, use these values.
>>
>> The u-boot environment MAC addresses take precedence over any eventual
>> ones defined in the DPC, except for the case where they are randomly
>> assigned (no u-boot env value declared for port).
>>
>> The patch assumes the "/board_info/ports/" node is present in the DPC.
>>
>> Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
>
> Reviewed-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
>

Prabhakar,

I don't know how you replied with your comment. But your email client 
changed the message ID so patchwork couldn't match it.

York

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

* [U-Boot] [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC
       [not found] <1485435698-17392-1-git-send-email-bogdan.purcareata@nxp.com>
@ 2017-01-26 13:05 ` Prabhakar Kushwaha
  2017-01-27 20:45   ` york sun
  0 siblings, 1 reply; 6+ messages in thread
From: Prabhakar Kushwaha @ 2017-01-26 13:05 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Bogdan Purcareata [mailto:bogdan.purcareata at nxp.com]
> Sent: Thursday, January 11, 2017 9:35 AM
> To: u-boot at lists.denx.de
> Cc: Bogdan Purcareata <bogdan.purcareata@nxp.com>
> Subject: [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC
> 
> Fixup port_mac_address property in MC DPC with values from the u-boot
> environment. Since u-boot already reads the environment MAC addresses
> when probing the PHYs, use these values.
> 
> The u-boot environment MAC addresses take precedence over any eventual
> ones defined in the DPC, except for the case where they are randomly
> assigned (no u-boot env value declared for port).
> 
> The patch assumes the "/board_info/ports/" node is present in the DPC.
> 
> Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>

Reviewed-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>

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

end of thread, other threads:[~2017-02-06 18:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-11 15:58 [U-Boot] [PATCH] drivers: net: fsl-mc: Fixup MAC addresses in DPC Bogdan Purcareata
2017-02-06 18:06 ` york sun
     [not found] <1485435698-17392-1-git-send-email-bogdan.purcareata@nxp.com>
2017-01-26 13:05 ` Prabhakar Kushwaha
2017-01-27 20:45   ` york sun
2017-01-30 11:09     ` Prabhakar Kushwaha
2017-01-30 16:04       ` york sun

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.