fdt: Deprecate "usbethaddr" usage in fdt_fixup_ethernet()
PATCH v3 1/2 fdt: Deprecate "usbethaddr" usage in fdt_fixup_ethernet()
In fdt_fixup_ethernet() only "usbethaddr" is handled to fix up the first usb ethernet port MAC address. Other additional usb ethernet ports are ignored as there is no logic to handle "usbeth%daddr".
It is suggested we should use "ethaddr" for all ethernet devices. Hence deprecate "usbethaddr" usage in fdt_fixup_ethernet().
This actually reverts commit b1f49ab8c7bad60426b30c134ae065ef77d2dfc1 "ARM: fdt support: Add usbethaddr as an acceptable MAC".
On OMAP4 Panda (+ v4.3 kernel)
---
Changes in v3:
- Update commit message to include full commit id and subject.
Changes in v2:
- New patch to deprecate "usbethaddr" usage in fdt_fixup_ethernet()
common/fdt_support.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
common/fdt_support.c +1 -11
@@ -490,18 +490,8 @@ void fdt_fixup_ethernet(void *fdt)if (node <0 )return ; -if (!getenv ("ethaddr" )) { -if (getenv ("usbethaddr" )) { -strcpy (mac,"usbethaddr" ); - }else { -debug ("No ethernet MAC Address defined\n" ); -return ; - } - }else { -strcpy (mac,"ethaddr" ); - } - i =0 ; +strcpy (mac,"ethaddr" );while ((tmp =getenv (mac)) !=NULL ) {sprintf (enet,"ethernet%d" , i); path =fdt_getprop (fdt, node, enet,NULL );
Signature · 1 line
1.8.2.1
PATCH v3 1/2 fdt: Deprecate "usbethaddr" usage in fdt_fixup_ethernet()
Hi Joe,
Quoted 42 lines · Bin Meng
In
fdt_fixup_ethernet()only "usbethaddr" is handled to fix up the first usb ethernet port MAC address. Other additional usb ethernet ports are ignored as there is no logic to handle "usbeth%daddr".It is suggested we should use "ethaddr" for all ethernet devices. Hence deprecate "usbethaddr" usage in
fdt_fixup_ethernet().This actually reverts commit
b1f49ab8c7bad60426b30c134ae065ef77d2dfc1"ARM: fdt support: Add usbethaddr as an acceptable MAC".Signed-off-by Bin Meng <[email protected]>Acked-by Joe Hershberger <[email protected]>Reviewed-by Tom Rini <[email protected]>On OMAP4 Panda (+ v4.3 kernel)
Tested-by Tom Rini <[email protected]>---
Changes in v3:
- Update commit message to include full commit id and subject.Changes in v2:
- New patch to deprecate "usbethaddr" usage infdt_fixup_ethernet()common/fdt_support.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)common/fdt_support.c +0
-7@@ -490,18 +490,8 @@ void fdt_fixup_ethernet(void *fdt)if (node <0 )return ; -if (!getenv ("ethaddr" )) { -if (getenv ("usbethaddr" )) { -strcpy (mac,"usbethaddr" ); - }else { -debug ("No ethernet MAC Address defined\n" ); -return ; - }
common/fdt_support.c void fdt_fixup_ethernet(void *fdt)
Quoted 10 lines
common/fdt_support.c +1
-5- }else { -strcpy (mac,"ethaddr" ); - } - i =0 ; +strcpy (mac,"ethaddr" );while ((tmp =getenv (mac)) !=NULL ) {sprintf (enet,"ethernet%d" , i); path =fdt_getprop (fdt, node, enet,NULL ); --
I see these two patches are assigned to you on patchwork. When will these get merged?
Regards,
Bin
PATCH v3 1/2 fdt: Deprecate "usbethaddr" usage in fdt_fixup_ethernet()
Hi Bin,
Quoted 50 lines · Bin Meng
Hi Joe,
Quoted 47 lines · Bin Meng
In
fdt_fixup_ethernet()only "usbethaddr" is handled to fix up the first usb ethernet port MAC address. Other additional usb ethernet ports are ignored as there is no logic to handle "usbeth%daddr".It is suggested we should use "ethaddr" for all ethernet devices. Hence deprecate "usbethaddr" usage in
fdt_fixup_ethernet().This actually reverts commit
b1f49ab8c7bad60426b30c134ae065ef77d2dfc1"ARM: fdt support: Add usbethaddr as an acceptable MAC".Signed-off-by Bin Meng <[email protected]>Acked-by Joe Hershberger <[email protected]>Reviewed-by Tom Rini <[email protected]>On OMAP4 Panda (+ v4.3 kernel)
Tested-by Tom Rini <[email protected]>---
Changes in v3:
- Update commit message to include full commit id and subject.Changes in v2:
- New patch to deprecate "usbethaddr" usage infdt_fixup_ethernet()common/fdt_support.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)common/fdt_support.c +0
-11@@ -490,18 +490,8 @@ void fdt_fixup_ethernet(void *fdt)if (node <0 )return ; -if (!getenv ("ethaddr" )) { -if (getenv ("usbethaddr" )) { -strcpy (mac,"usbethaddr" ); - }else { -debug ("No ethernet MAC Address defined\n" ); -return ; - } - }else { -strcpy (mac,"ethaddr" ); - } - i =0 ;
Quoted 8 lines
common/fdt_support.c void fdt_fixup_ethernet(void *fdt)
Quoted 5 lines
common/fdt_support.c +1
-1+strcpy (mac,"ethaddr" );while ((tmp =getenv (mac)) !=NULL ) {sprintf (enet,"ethernet%d" , i); path =fdt_getprop (fdt, node, enet,NULL ); --I see these two patches are assigned to you on patchwork. When will these get merged?
I plan to do another round of patch application next week sometime.
Cheers,
-Joe
PATCH v3 1/2 fdt: Deprecate "usbethaddr" usage in fdt_fixup_ethernet()
Hi Joe,
Quoted 62 lines · Joe Hershberger
Hi Bin,
Quoted 50 lines · Bin Meng
Hi Joe,
Quoted 47 lines · Bin Meng
In
fdt_fixup_ethernet()only "usbethaddr" is handled to fix up the first usb ethernet port MAC address. Other additional usb ethernet ports are ignored as there is no logic to handle "usbeth%daddr".It is suggested we should use "ethaddr" for all ethernet devices. Hence deprecate "usbethaddr" usage in
fdt_fixup_ethernet().This actually reverts commit
b1f49ab8c7bad60426b30c134ae065ef77d2dfc1"ARM: fdt support: Add usbethaddr as an acceptable MAC".Signed-off-by Bin Meng <[email protected]>Acked-by Joe Hershberger <[email protected]>Reviewed-by Tom Rini <[email protected]>On OMAP4 Panda (+ v4.3 kernel)
Tested-by Tom Rini <[email protected]>---
Changes in v3:
- Update commit message to include full commit id and subject.Changes in v2:
- New patch to deprecate "usbethaddr" usage infdt_fixup_ethernet()common/fdt_support.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)common/fdt_support.c +0
-11@@ -490,18 +490,8 @@ void fdt_fixup_ethernet(void *fdt)if (node <0 )return ; -if (!getenv ("ethaddr" )) { -if (getenv ("usbethaddr" )) { -strcpy (mac,"usbethaddr" ); - }else { -debug ("No ethernet MAC Address defined\n" ); -return ; - } - }else { -strcpy (mac,"ethaddr" ); - } - i =0 ;Quoted 8 lines
common/fdt_support.c void fdt_fixup_ethernet(void *fdt)
Quoted 5 lines
common/fdt_support.c +1
-1+strcpy (mac,"ethaddr" );while ((tmp =getenv (mac)) !=NULL ) {sprintf (enet,"ethernet%d" , i); path =fdt_getprop (fdt, node, enet,NULL ); --I see these two patches are assigned to you on patchwork. When will these get merged?
Quoted 2 lines
I plan to do another round of patch application next week sometime.
ping? I hope this won't miss the release train.
Regards,
Bin
PATCH v3 2/2 fdt: Rewrite the logic in fdt_fixup_ethernet()
In reply to Bin MengCurrently in fdt_fixup_ethernet() the MAC address fix up is handled in a loop of which the exit condition is to test the "eth%daddr" env is not NULL. However this creates unnecessary constrains that those "eth%daddr" env variables must be sequential even if "ethernet%d" does not start from 0 in the "/aliases" node. For example, with "/aliases" node below:
aliases {
ethernet3 = &enet3;
ethernet4 = &enet4;
};"ethaddr", "eth1addr", "eth2addr" must exist in order to fix up ethernet3's MAC address successfully.
Now we change the loop logic to iterate the properties in the "/aliases" node. For each property, test if it is in a format of "ethernet%d", then get its MAC address from corresponding "eth%daddr" env and fix it up in the dtb.
On OMAP4 Panda (+v4.3 kernel)
---
Changes in v3: None
Changes in v2: None
common/fdt_support.c | 54 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 21 deletions(-)
common/fdt_support.c +33 -21
@@ -481,37 +481,49 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)void fdt_fixup_ethernet (void *fdt) {int node, i, j; -char enet[16 ], *tmp, *end; +char *tmp, *end;char mac[16 ];const char *path;unsigned char mac_addr[6 ]; +int offset; node =fdt_path_offset (fdt,"/aliases" );if (node <0 )return ; - i =0 ; -strcpy (mac,"ethaddr" ); -while ((tmp =getenv (mac)) !=NULL ) { -sprintf (enet,"ethernet%d" , i); - path =fdt_getprop (fdt, node, enet,NULL ); -if (!path) { -debug ("No alias for %s\n" , enet); -sprintf (mac,"eth%daddr" , ++i); -continue ; - } +for (offset =fdt_first_property_offset (fdt, node); + offset >0 ; + offset =fdt_next_property_offset (fdt, offset)) { +const char *name; +int len =strlen ("ethernet" ); + + path =fdt_getprop_by_offset (fdt, offset, &name,NULL ); +if (!strncmp (name,"ethernet" , len)) { + i =trailing_strtol (name); +if (i !=-1 ) { +if (i ==0 ) +strcpy (mac,"ethaddr" ); +else +sprintf (mac,"eth%daddr" , i); + }else { +continue ; + } + tmp =getenv (mac); +if (!tmp) +continue ; + +for (j =0 ; j <6 ; j++) { + mac_addr[j] = tmp ? +simple_strtoul (tmp, &end,16 ) :0 ; +if (tmp) + tmp = (*end) ? end +1 : end; + } -for (j =0 ; j <6 ; j++) { - mac_addr[j] = tmp ?simple_strtoul (tmp, &end,16 ) :0 ; -if (tmp) - tmp = (*end) ? end+1 : end; +do_fixup_by_path (fdt, path,"mac-address" , + &mac_addr,6 ,0 ); +do_fixup_by_path (fdt, path,"local-mac-address" , + &mac_addr,6 ,1 ); } - -do_fixup_by_path (fdt, path,"mac-address" , &mac_addr,6 ,0 ); -do_fixup_by_path (fdt, path,"local-mac-address" , - &mac_addr,6 ,1 ); - -sprintf (mac,"eth%daddr" , ++i); } }
Signature · 1 line
1.8.2.1
PATCH v3 2/2 fdt: Rewrite the logic in fdt_fixup_ethernet()
Hi Bin,
Quoted 20 lines · Bin Meng
Currently in
fdt_fixup_ethernet()the MAC address fix up is handled in a loop of which the exit condition is to test the "eth%daddr" env is not NULL. However this creates unnecessary constrains that those "eth%daddr" env variables must be sequential even if "ethernet%d" does not start from 0 in the "/aliases" node. For example, with "/aliases" node below:aliases { ethernet3 = &enet3; ethernet4 = &enet4; };"ethaddr", "eth1addr", "eth2addr" must exist in order to fix up ethernet3's MAC address successfully.
Now we change the loop logic to iterate the properties in the "/aliases" node. For each property, test if it is in a format of "ethernet%d", then get its MAC address from corresponding "eth%daddr" env and fix it up in the dtb.
Quoted 5 lines
Signed-off-by Bin Meng <[email protected]>Acked-by Joe Hershberger <[email protected]>Reviewed-by Tom Rini <[email protected]>On OMAP4 Panda (+v4.3 kernel)
Tested-by Tom Rini <[email protected]>
Applied to u-boot-net/master, thanks!
-Joe
PATCH v3 1/2 fdt: Deprecate "usbethaddr" usage in fdt_fixup_ethernet()
In reply to Bin MengHi Bin,
Quoted 7 lines · Bin Meng
In
fdt_fixup_ethernet()only "usbethaddr" is handled to fix up the first usb ethernet port MAC address. Other additional usb ethernet ports are ignored as there is no logic to handle "usbeth%daddr".It is suggested we should use "ethaddr" for all ethernet devices. Hence deprecate "usbethaddr" usage in
fdt_fixup_ethernet().
Quoted 8 lines
This actually reverts commit
b1f49ab8c7bad60426b30c134ae065ef77d2dfc1"ARM: fdt support: Add usbethaddr as an acceptable MAC".Signed-off-by Bin Meng <[email protected]>Acked-by Joe Hershberger <[email protected]>Reviewed-by Tom Rini <[email protected]>On OMAP4 Panda (+ v4.3 kernel)
Tested-by Tom Rini <[email protected]>
Applied to u-boot-net/master, thanks!
-Joe