public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] km/ivm: always set ethaddr after reading IVM
@ 2017-07-13  9:15 Holger Brunck
  2017-07-13  9:15 ` [U-Boot] [PATCH 2/2] km/ivm: allow to set locally administred MAC addresses Holger Brunck
  2017-07-25  0:43 ` [U-Boot] [U-Boot, 1/2] km/ivm: always set ethaddr after reading IVM Tom Rini
  0 siblings, 2 replies; 4+ messages in thread
From: Holger Brunck @ 2017-07-13  9:15 UTC (permalink / raw)
  To: u-boot

If we rebrand the IVM and ethaddr was set previously we need to change
ethaddr. Otherwise we end up with a wrong MAC adress for the ethernet
interface.

Cc: Heiko Schocher <hs@denx.de>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
---
 board/keymile/common/ivm.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c
index 42db54221b..3495fafffe 100644
--- a/board/keymile/common/ivm.c
+++ b/board/keymile/common/ivm.c
@@ -302,14 +302,11 @@ static int ivm_populate_env(unsigned char *buf, int len)
 
 	/* if an offset is defined, add it */
 	process_mac(valbuf, page2, CONFIG_PIGGY_MAC_ADRESS_OFFSET);
-	if (getenv("ethaddr") == NULL)
-		setenv((char *)"ethaddr", (char *)valbuf);
+	setenv((char *)"ethaddr", (char *)valbuf);
 #ifdef CONFIG_KMVECT1
 /* KMVECT1 has two ethernet interfaces */
-	if (getenv("eth1addr") == NULL) {
-		process_mac(valbuf, page2, 1);
-		setenv((char *)"eth1addr", (char *)valbuf);
-	}
+	process_mac(valbuf, page2, 1);
+	setenv((char *)"eth1addr", (char *)valbuf);
 #endif
 
 	return 0;
-- 
2.12.0.rc1

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

* [U-Boot] [PATCH 2/2] km/ivm: allow to set locally administred MAC addresses
  2017-07-13  9:15 [U-Boot] [PATCH 1/2] km/ivm: always set ethaddr after reading IVM Holger Brunck
@ 2017-07-13  9:15 ` Holger Brunck
  2017-07-25  0:43   ` [U-Boot] [U-Boot, " Tom Rini
  2017-07-25  0:43 ` [U-Boot] [U-Boot, 1/2] km/ivm: always set ethaddr after reading IVM Tom Rini
  1 sibling, 1 reply; 4+ messages in thread
From: Holger Brunck @ 2017-07-13  9:15 UTC (permalink / raw)
  To: u-boot

It is possible to flag MAC addresses as locally administred. In this
case they don't need to be unique. This is only allowed for interfaces
which have no connection to the outside. For the TEGR1 board we use
this feature.

Cc: Heiko Schocher <hs@denx.de>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
---
 board/keymile/common/ivm.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c
index 3495fafffe..e9e518cf72 100644
--- a/board/keymile/common/ivm.c
+++ b/board/keymile/common/ivm.c
@@ -189,7 +189,7 @@ static int ivm_check_crc(unsigned char *buf, int block)
 
 /* take care of the possible MAC address offset and the IVM content offset */
 static int process_mac(unsigned char *valbuf, unsigned char *buf,
-				int offset)
+				int offset, bool unique)
 {
 	unsigned char mac[6];
 	unsigned long val = (buf[4] << 16) + (buf[5] << 8) + buf[6];
@@ -199,6 +199,13 @@ static int process_mac(unsigned char *valbuf, unsigned char *buf,
 	 */
 	memcpy(mac, buf+1, 6);
 
+	/* MAC adress can be set to locally administred, this is only allowed
+	 * for interfaces which have now connection to the outside. For these
+	 * addresses we need to set the second bit in the first byte.
+	 */
+	if (!unique)
+		mac[0] |= 0x2;
+
 	if (offset) {
 		val += offset;
 		mac[3] = (val >> 16) & 0xff;
@@ -300,12 +307,23 @@ static int ivm_populate_env(unsigned char *buf, int len)
 		return 0;
 	page2 = &buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN*2];
 
+#ifndef CONFIG_KMTEGR1
 	/* if an offset is defined, add it */
-	process_mac(valbuf, page2, CONFIG_PIGGY_MAC_ADRESS_OFFSET);
+	process_mac(valbuf, page2, CONFIG_PIGGY_MAC_ADRESS_OFFSET, true);
 	setenv((char *)"ethaddr", (char *)valbuf);
 #ifdef CONFIG_KMVECT1
 /* KMVECT1 has two ethernet interfaces */
-	process_mac(valbuf, page2, 1);
+	process_mac(valbuf, page2, 1, true);
+	setenv((char *)"eth1addr", (char *)valbuf);
+#endif
+#else
+/* KMTEGR1 has a special setup. eth0 has no connection to the outside and
+ * gets an locally administred MAC address, eth1 is the debug interface and
+ * gets the official MAC address from the IVM
+ */
+	process_mac(valbuf, page2, CONFIG_PIGGY_MAC_ADRESS_OFFSET, false);
+	setenv((char *)"ethaddr", (char *)valbuf);
+	process_mac(valbuf, page2, CONFIG_PIGGY_MAC_ADRESS_OFFSET, true);
 	setenv((char *)"eth1addr", (char *)valbuf);
 #endif
 
-- 
2.12.0.rc1

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

* [U-Boot] [U-Boot, 1/2] km/ivm: always set ethaddr after reading IVM
  2017-07-13  9:15 [U-Boot] [PATCH 1/2] km/ivm: always set ethaddr after reading IVM Holger Brunck
  2017-07-13  9:15 ` [U-Boot] [PATCH 2/2] km/ivm: allow to set locally administred MAC addresses Holger Brunck
@ 2017-07-25  0:43 ` Tom Rini
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2017-07-25  0:43 UTC (permalink / raw)
  To: u-boot

On Thu, Jul 13, 2017 at 11:15:40AM +0200, Holger Brunck wrote:

> If we rebrand the IVM and ethaddr was set previously we need to change
> ethaddr. Otherwise we end up with a wrong MAC adress for the ethernet
> interface.
> 
> Cc: Heiko Schocher <hs@denx.de>
> Signed-off-by: Holger Brunck <holger.brunck@keymile.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170724/76ab8217/attachment.sig>

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

* [U-Boot] [U-Boot, 2/2] km/ivm: allow to set locally administred MAC addresses
  2017-07-13  9:15 ` [U-Boot] [PATCH 2/2] km/ivm: allow to set locally administred MAC addresses Holger Brunck
@ 2017-07-25  0:43   ` Tom Rini
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2017-07-25  0:43 UTC (permalink / raw)
  To: u-boot

On Thu, Jul 13, 2017 at 11:15:41AM +0200, Holger Brunck wrote:

> It is possible to flag MAC addresses as locally administred. In this
> case they don't need to be unique. This is only allowed for interfaces
> which have no connection to the outside. For the TEGR1 board we use
> this feature.
> 
> Cc: Heiko Schocher <hs@denx.de>
> Signed-off-by: Holger Brunck <holger.brunck@keymile.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170724/a52f0ba4/attachment.sig>

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

end of thread, other threads:[~2017-07-25  0:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-13  9:15 [U-Boot] [PATCH 1/2] km/ivm: always set ethaddr after reading IVM Holger Brunck
2017-07-13  9:15 ` [U-Boot] [PATCH 2/2] km/ivm: allow to set locally administred MAC addresses Holger Brunck
2017-07-25  0:43   ` [U-Boot] [U-Boot, " Tom Rini
2017-07-25  0:43 ` [U-Boot] [U-Boot, 1/2] km/ivm: always set ethaddr after reading IVM Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox