sun8i: On H3 Use words 1-3 instead of just word 3 from the SID
PATCH v2 1/1 sun8i: On H3 Use words 1-3 instead of just word 3 from the SID
It seems that bytes 13-14 of the SID / bytes 1-2 from word 3 of the SID are always 0 on H3 making it a poor candidate to use as source for the serialnr / mac-address, and the other non constant words (1 and 2) also have quite a few bits which are the same for some boards,
This commits switches to using words 1 - 3 ex-or-ed together to get a more unique value for the mac-address / serialnr.
---
Changes in v2:
-ex-or all 3 words together instead of picking a different word
--- board/sunxi/board.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
board/sunxi/board.c +15 -0
@@ -623,6 +623,21 @@ static void setup_environment(const void *fdt) ret =sunxi_get_sid (sid);if (ret ==0 && sid[0 ] !=0 && sid[3 ] !=0 ) { +#ifdef CONFIG_MACH_SUN8I_H3 +/* +* The single words 1 - 3 of the SID have quite a few bits +* which are the same on many models on the H3, so we ex-or +* them together to get a bit more unique value. +* +* Note we only do this on the H3 as we cannot change the +* algorithm on other SoCs since those have been using +* fixed mac-addresses based on only using word 3 for a +* a long time and changing a fixed mac-address with an +* u-boot update is not good. +*/ + sid[3 ] ^= sid[1 ] ^ sid[2 ]; +#endif +/* Ensure the NIC specific bytes of the mac are not all 0 */ if ((sid[3 ] &0xffffff ) ==0 ) sid[3 ] |=0x800000 ;
Signature · 1 line
2.7.4
PATCH v2 1/1 sun8i: On H3 Use words 1-3 instead of just word 3 from the SID
Quoted 27 lines · Hans de Goede
It seems that bytes 13-14 of the SID / bytes 1-2 from word 3 of the SID
are always 0 on H3 making it a poor candidate to use as source for the
serialnr / mac-address, and the other non constant words (1 and 2) also
have quite a few bits which are the same for some boards,This commits switches to using words 1 - 3 ex-or-ed together to get a more unique value for the mac-address / serialnr.
Cc Chen-Yu Tsai <[email protected]>Cc Corentin LABBE <[email protected]>Cc Amit Singh Tomar <[email protected]>Signed-off-by Hans de Goede <[email protected]>---
Changes in v2:
-ex-or all 3 words together instead of picking a different word
---
?board/sunxi/board.c | 15 +++++++++++++++
?1 file changed, 15 insertions(+)board/sunxi/board.c +0
-0@@ -623,6 +623,21 @@ static void setup_environment(const void *fdt)
Quoted 3 lines
?
? ret =sunxi_get_sid(sid);
? if (ret == 0 && sid[0] != 0 && sid[3] != 0) {
Could/should this check be removed now? Or should sid[1]/sid[2] be included?
Quoted 11 lines
+#ifdef
CONFIG_MACH_SUN8I_H3Quoted 10 lines
(quoted diff) +9
-0+ /* + ?* The single words 1 - 3 of the SID have quite a few bits + ?* which are the same on many models on the H3, so we ex-or + ?* them together to get a bit more unique value. + ?* + ?* Note we only do this on the H3 as we cannot change the + ?* algorithm on other SoCs since those have been using + ?* fixed mac-addresses based on only using word 3 for a + ?* a long time and changing a fixed mac-address with anReview
Quoted 1 line
(quoted diff) +1
-0+ ?* u-boot update is not good.
I wonder if we should invert this, i.e. make it not use this new method on all existing models. That would mean that all future models will automatically use this new (IMHO better) scheme instead of requiring it to be manually added each time (which we are sure to forget to do).
Main downside is the ifdef is going to be pretty long, but at least it would be static. Maybe doing it with select in Kconfig (i.e. select SUNXI_LEGACY_MAC_SID_THINGY on the existing platforms) would be a more tollerable approach?
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
(quoted diff) +1
-0+ ?*/board/sunxi/board.c +1
-0+ sid[3 ] ^= sid[1 ] ^ sid[2 ];board/sunxi/board.c +2
-0+#endif +Quoted 1 line
? /* Ensure the NIC specific bytes of the mac are not all 0 */
? if ((sid[3] &
0xffffff) == 0)
? sid[3] |=0x800000;
PATCH v2 1/1 sun8i: On H3 Use words 1-3 instead of just word 3 from the SID
Hi,
Quoted 29 lines · Ian Campbell
Quoted 28 lines · Hans de Goede
It seems that bytes 13-14 of the SID / bytes 1-2 from word 3 of the SID
are always 0 on H3 making it a poor candidate to use as source for the
serialnr / mac-address, and the other non constant words (1 and 2) also
have quite a few bits which are the same for some boards,This commits switches to using words 1 - 3 ex-or-ed together to get a more unique value for the mac-address / serialnr.
Cc Chen-Yu Tsai <[email protected]>Cc Corentin LABBE <[email protected]>Cc Amit Singh Tomar <[email protected]>Signed-off-by Hans de Goede <[email protected]>---
Changes in v2:(quoted diff) +0
-2-ex-or all 3 words together instead of picking a different word --- board/sunxi/board.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)board/sunxi/board.c +0
-0@@ -623,6 +623,21 @@ static void setup_environment(const void *fdt)
Quoted 5 lines
board/sunxi/board.c static void setup_environment(const void *fdt) · line 625
Quoted 2 lines
board/sunxi/board.c +0
-0ret =sunxi_get_sid (sid);if (ret ==0 && sid[0 ] !=0 && sid[3 ] !=0 ) {Could/should this check be removed now? Or should sid[1]/sid[2] be included?
Good point, the check is there because some A10 / A20 boards have an all 0 sid, now that we make sure that the NIC specific bytes of the mac are not all 0, only checking for sid[0] != 0 should be enough to capture non initialized sid-s.
Quoted 10 lines
Quoted 10 lines
board/sunxi/board.c +1
-0+#ifdef CONFIG_MACH_SUN8I_H3 Quoted 9 lines
board/sunxi/board.c +9
-0+/* +* The single words 1 - 3 of the SID have quite a few bits +* which are the same on many models on the H3, so we ex-or +* them together to get a bit more unique value. +* +* Note we only do this on the H3 as we cannot change the +* algorithm on other SoCs since those have been using +* fixed mac-addresses based on only using word 3 for a +* a long time and changing a fixed mac-address with an
Quoted 6 lines
Quoted 1 line
Quoted 1 line
board/sunxi/board.c static void setup_environment(const void *fdt) · line 636
Quoted 1 line
board/sunxi/board.c +1
-0+* u-boot update is not good. I wonder if we should invert this, i.e. make it not use this new method on all existing models. That would mean that all future models will automatically use this new (IMHO better) scheme instead of requiring it to be manually added each time (which we are sure to forget to do).
Good point, I'll fix this and the above check for v3.
Regards,
Hans
PATCH v2 1/1 sun8i: On H3 Use words 1-3 instead of just word 3 from the SID
In reply to Hans de GoedeQuoted 35 lines · On Fri, 29 Jul 2016 11:49:45 +0200 Hans de Goede <[email protected]> wrote:
It seems that bytes 13-14 of the SID / bytes 1-2 from word 3 of the SID are always 0 on H3 making it a poor candidate to use as source for the serialnr / mac-address, and the other non constant words (1 and 2) also have quite a few bits which are the same for some boards,
This commits switches to using words 1 - 3 ex-or-ed together to get a more unique value for the mac-address / serialnr.
Cc Chen-Yu Tsai <[email protected]>Cc Corentin LABBE <[email protected]>Cc Amit Singh Tomar <[email protected]>Signed-off-by Hans de Goede <[email protected]>---
Changes in v2:(quoted diff) +0
-2-ex-or all 3 words together instead of picking a different word --- board/sunxi/board.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)board/sunxi/board.c +8
-0@@ -623,6 +623,21 @@ static void setup_environment(const void *fdt) ret =sunxi_get_sid (sid);if (ret ==0 && sid[0 ] !=0 && sid[3 ] !=0 ) { +#ifdef CONFIG_MACH_SUN8I_H3 +/* +* The single words 1 - 3 of the SID have quite a few bits +* which are the same on many models on the H3, so we ex-or +* them together to get a bit more unique value. +* +* Note we only do this on the H3 as we cannot change the +* algorithm on other SoCs since those have been using
board/sunxi/board.c static void setup_environment(const void *fdt) · line 643
Quoted 10 lines
board/sunxi/board.c +7
-0+* fixed mac-addresses based on only using word 3 for a +* a long time and changing a fixed mac-address with an +* u-boot update is not good. +*/ + sid[3 ] ^= sid[1 ] ^ sid[2 ]; +#endif +/* Ensure the NIC specific bytes of the mac are not all 0 */ if ((sid[3 ] &0xffffff ) ==0 ) sid[3 ] |=0x800000 ;
Using XOR is not a good idea, see my reply in the v1 patch discussion:
http://lists.denx.de/pipermail/u-boot/2016-July/262298.html
Signature · 2 lines
Best regards, Siarhei Siamashka