Skip to contentSkip to conversation

net: extend the netdev to have a common way to set the hw mac address

PATCH New Jean-Christophe PLAGNIOL-VILLARD 8 participants 37 messages May 11, 2009 – May 15, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

init it at the eth_initialize

this will allow to add later a hook to update the enetadd hw storage when it's updated in env or when the env is saved

---
 include/net.h |    2 ++
 net/eth.c     |    4 ++++
 2 files changed, 6 insertions(+), 0 deletions(-)
include/net.h +2 -0
index 5a1d36e..2ed6263 100644
@@ -93,6 +93,7 @@ enum eth_state_t {
 };
 
 struct eth_device {
+	int num;
 	char name[NAMESIZE];
 	unsigned char enetaddr[6];
 	int iobase;
@@ -105,6 +106,7 @@ struct eth_device {
 #ifdef CONFIG_MCAST_TFTP
 	int (*mcast) (struct eth_device*, u32 ip, u8 set);
 #endif
+	int  (*set_hw_enetaddr) (struct eth_device*, bd_t*);
 	struct eth_device *next;
 	void *priv;
 };
net/eth.c +4 -0
index c6fa5b9..99bb6c2 100644
@@ -217,6 +217,8 @@ int eth_initialize(bd_t *bis)
 			if (eth_number)
 				puts (", ");
 
+			dev->num = eth_number;
+
 			printf("%s", dev->name);
 
 			if (ethprime && strcmp (dev->name, ethprime) == 0) {
@@ -240,6 +242,8 @@ int eth_initialize(bd_t *bis)
 				}
 
 				memcpy(dev->enetaddr, env_enetaddr, 6);
+				if(dev->set_hw_enetaddr)
+					dev->set_hw_enetaddr(dev, bis);
 			}
 
 			eth_number++;
Signature · 1 line
1.6.1.3
#1 lore raw

PATCH 2/4 macb: add set_hw_enetaddr support

---
 drivers/net/macb.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)
drivers/net/macb.c +17 -6
index 6de0a04..a339730 100644
@@ -404,12 +404,25 @@ static int macb_phy_init(struct macb_device *macb)
 	}
 }
 
-static int macb_init(struct eth_device *netdev, bd_t *bd)
+static int macb_set_hw_enetaddr(struct eth_device *netdev, bd_t *bd)
 {
 	struct macb_device *macb = to_macb(netdev);
-	unsigned long paddr;
 	u32 hwaddr_bottom;
 	u16 hwaddr_top;
+
+	/* set hardware address */
+	hwaddr_bottom = cpu_to_le32(*((u32 *)netdev->enetaddr));
+	macb_writel(macb, SA1B, hwaddr_bottom);
+	hwaddr_top = cpu_to_le16(*((u16 *)(netdev->enetaddr + 4)));
+	macb_writel(macb, SA1T, hwaddr_top);
+
+	return 0;
+}
+
+static int macb_init(struct eth_device *netdev, bd_t *bd)
+{
+	struct macb_device *macb = to_macb(netdev);
+	unsigned long paddr;
 	int i;
 
 	/*
@@ -439,10 +452,7 @@ static int macb_init(struct eth_device *netdev, bd_t *bd)
 	macb_writel(macb, TBQP, macb->tx_ring_dma);
 
 	/* set hardware address */
-	hwaddr_bottom = cpu_to_le32(*((u32 *)netdev->enetaddr));
-	macb_writel(macb, SA1B, hwaddr_bottom);
-	hwaddr_top = cpu_to_le16(*((u16 *)(netdev->enetaddr + 4)));
-	macb_writel(macb, SA1T, hwaddr_top);
+	macb_set_hw_enetaddr(netdev, bd);
 
 	/* choose RMII or MII mode. This depends on the board */
 #ifdef CONFIG_RMII
@@ -521,6 +531,7 @@ int macb_eth_initialize(int id, void *regs, unsigned int phy_addr)
 	netdev->halt = macb_halt;
 	netdev->send = macb_send;
 	netdev->recv = macb_recv;
+	netdev->set_hw_enetaddr = macb_set_hw_enetaddr;
 
 	/*
 	 * Do some basic initialization so that we at least can talk
Signature · 1 line
1.6.1.3
#2 lore raw

PATCH 3/4 net/dm9000: move the CONFIG_NET_MULTI api

this add multi devices support and merge dm9000's eeprom command support

Cc Ben Warren <[email protected]>
Cc TsiChung Liew <[email protected]>
Cc Konstantin Kletschke <[email protected]>
Cc Stelian Pop <[email protected]>
---
 board/atmel/at91sam9261ek/at91sam9261ek.c |   17 +-
 board/freescale/m5253demo/m5253demo.c     |   10 +
 board/scb9328/scb9328.c                   |    9 +
 board/trizepsiv/Makefile                  |    2 +-
 board/trizepsiv/conxs.c                   |   10 +
 board/trizepsiv/eeprom.c                  |   84 -----
 drivers/net/dm9000x.c                     |  469 ++++++++++++++++++-----------
 include/configs/M5253DEMO.h               |    3 +-
 include/configs/at91sam9261ek.h           |    5 +-
 include/configs/scb9328.h                 |    3 +-
 include/configs/trizepsiv.h               |    4 +-
 include/netdev.h                          |    1 +
 12 files changed, 341 insertions(+), 276 deletions(-)
 delete mode 100644 board/trizepsiv/eeprom.c
board/atmel/at91sam9261ek/at91sam9261ek.c +5 -12
index a89cb8b..6aec5c6 100644
@@ -34,9 +34,7 @@
 #include <asm/arch/io.h>
 #include <lcd.h>
 #include <atmel_lcdc.h>
-#if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_DRIVER_DM9000)
-#include <net.h>
-#endif
+#include <netdev.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -234,15 +232,10 @@ int dram_init(void)
 	return 0;
 }
 
-#ifdef CONFIG_RESET_PHY_R
-void reset_phy(void)
-{
 #ifdef CONFIG_DRIVER_DM9000
-	/*
-	 * Initialize ethernet HW addr prior to starting Linux,
-	 * needed for nfsroot
-	 */
-	eth_init(gd->bd);
-#endif
+int board_eth_init(bd_t *bis)
+{
+	return dm9000_eth_initialize(0, (u32*)CONFIG_DM9000_BASE,
+					(u32*)(CONFIG_DM9000_BASE + 4));
 }
 #endif
board/freescale/m5253demo/m5253demo.c +10 -0
index b39cd4d..25d6f9e 100644
@@ -25,6 +25,8 @@
  */
 
 #include <common.h>
+#include <netdev.h>
+
 #include <asm/immap.h>
 
 int checkboard(void)
@@ -138,3 +140,11 @@ void ide_set_reset(int idereset)
 	}
 }
 #endif				/* CONFIG_CMD_IDE */
+
+#ifdef CONFIG_DRIVER_DM9000
+int board_eth_init(bd_t *bis)
+{
+	return dm9000_eth_initialize(0, (u32*)CONFIG_DM9000_BASE,
+					(u32*)(CONFIG_DM9000_BASE + 4));
+}
+#endif
board/scb9328/scb9328.c +9 -0
index 3f6831b..1e8ea67 100644
@@ -19,6 +19,7 @@
  */
 
 #include <common.h>
+#include <netdev.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -70,3 +71,11 @@ void show_boot_progress (int status)
 {
 	return;
 }
+
+#ifdef CONFIG_DRIVER_DM9000
+int board_eth_init(bd_t *bis)
+{
+	return dm9000_eth_initialize(0, (u32*)CONFIG_DM9000_BASE,
+					(u32*)(CONFIG_DM9000_BASE + 4));
+}
+#endif
board/trizepsiv/Makefile +1 -1
index 44c0d49..b105dd7 100644
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).a
 
-COBJS	:= conxs.o eeprom.o
+COBJS	:= conxs.o
 SOBJS	:= lowlevel_init.o pxavoltage.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
board/trizepsiv/conxs.c +10 -0
index 7c6c855..272f7b6 100644
@@ -32,6 +32,8 @@
  */
 
 #include <common.h>
+#include <netdev.h>
+
 #include <asm/arch/pxa-regs.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -144,3 +146,11 @@ int dram_init (void)
 
 	return 0;
 }
+
+#ifdef CONFIG_DRIVER_DM9000
+int board_eth_init(bd_t *bis)
+{
+	return dm9000_eth_initialize(0, (u32*)CONFIG_DM9000_BASE,
+					(u32*)(CONFIG_DM9000_BASE + 0x8004));
+}
+#endif
board/trizepsiv/eeprom.c deleted +0 -84

84 lines not on this page · raw message

drivers/net/dm9000x.c +300 -169

763 lines not on this page · raw message

include/configs/M5253DEMO.h +1 -2
index 1fea6c3..b61de14 100644
@@ -91,9 +91,8 @@
 #define CONFIG_DRIVER_DM9000
 #ifdef CONFIG_DRIVER_DM9000
 #	define CONFIG_DM9000_BASE	(CONFIG_SYS_CS1_BASE | 0x300)
-#	define DM9000_IO		CONFIG_DM9000_BASE
-#	define DM9000_DATA		(CONFIG_DM9000_BASE + 4)
 #	undef CONFIG_DM9000_DEBUG
+#	define CONFIG_NET_MULTI
 
 #	define CONFIG_ETHADDR		00:e0:0c:bc:e5:60
 #	define CONFIG_IPADDR		10.82.121.249
include/configs/at91sam9261ek.h +1 -4
index fdaa71c..dad825a 100644
@@ -134,11 +134,8 @@
 /* Ethernet */
 #define CONFIG_DRIVER_DM9000		1
 #define CONFIG_DM9000_BASE		0x30000000
-#define DM9000_IO			CONFIG_DM9000_BASE
-#define DM9000_DATA			(CONFIG_DM9000_BASE + 4)
-#define CONFIG_DM9000_USE_16BIT		1
+#define CONFIG_NET_MULTI		1
 #define CONFIG_NET_RETRY_COUNT		20
-#define CONFIG_RESET_PHY_R		1
 
 /* USB */
 #define CONFIG_USB_ATMEL
include/configs/scb9328.h +1 -2
index 893c3d3..39e6a4a 100644
@@ -257,8 +257,7 @@
 
 #define CONFIG_DRIVER_DM9000		1
 #define CONFIG_DM9000_BASE		0x16000000
-#define DM9000_IO			CONFIG_DM9000_BASE
-#define DM9000_DATA			(CONFIG_DM9000_BASE+4)
+#define CONFIG_NET_MULTI		1
 
 /* f_{dpll}=2*f{ref}*(MFI+MFN/(MFD+1))/(PD+1)
    f_ref=16,777MHz
include/configs/trizepsiv.h +2 -2
index 4917318..fce9079 100644
@@ -279,8 +279,8 @@
 
 #define CONFIG_DRIVER_DM9000		1
 #define CONFIG_DM9000_BASE	0x08000000
-#define DM9000_IO			CONFIG_DM9000_BASE
-#define DM9000_DATA			(CONFIG_DM9000_BASE+0x8004)
+#define CONFIG_NET_MULTI		1
+#define CONFIG_CMD_DM9000_EEPROM
 
 #define CONFIG_USB_OHCI_NEW	1
 #define CONFIG_SYS_USB_OHCI_BOARD_INIT	1
include/netdev.h +1 -0
index 63cf730..07328fa 100644
@@ -44,6 +44,7 @@ int cpu_eth_init(bd_t *bis);
 int au1x00_enet_initialize(bd_t*);
 int bfin_EMAC_initialize(bd_t *bis);
 int dc21x4x_initialize(bd_t *bis);
+int dm9000_eth_initialize(int id, u32 *data_addr, u32 *io_addr);
 int dnet_eth_initialize(int id, void *regs, unsigned int phy_addr);
 int e1000_initialize(bd_t *bis);
 int eepro100_initialize(bd_t *bis);
Signature · 1 line
1.6.1.3
#3 lore raw

PATCH 4/4 at91/macb: remove reset_phy callback

reset_phy was used to force the macb to be always init in order to set the enetaddr in the hw registers which now done at the eth_initialize

This also reduce the boot time

---
 board/afeb9260/afeb9260.c                 |   16 ----------------
 board/atmel/at91cap9adk/at91cap9adk.c     |   16 ----------------
 board/atmel/at91sam9260ek/at91sam9260ek.c |   16 ----------------
 board/atmel/at91sam9263ek/at91sam9263ek.c |   16 ----------------
 board/atmel/at91sam9rlek/at91sam9rlek.c   |    3 ---
 board/ronetix/pm9263/pm9263.c             |   16 ----------------
 include/configs/afeb9260.h                |    1 -
 include/configs/at91cap9adk.h             |    1 -
 include/configs/at91sam9260ek.h           |    1 -
 include/configs/at91sam9263ek.h           |    1 -
 include/configs/pm9263.h                  |    1 -
 11 files changed, 0 insertions(+), 88 deletions(-)
board/afeb9260/afeb9260.c +0 -16
index 024db2b..6f74012 100644
@@ -33,10 +33,7 @@
 #include <asm/arch/gpio.h>
 #include <asm/arch/io.h>
 #include <asm/arch/hardware.h>
-#if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
 #include <netdev.h>
-#include <net.h>
-#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -160,19 +157,6 @@ int dram_init(void)
 	return 0;
 }
 
-#ifdef CONFIG_RESET_PHY_R
-void reset_phy(void)
-{
-#ifdef CONFIG_MACB
-	/*
-	 * Initialize ethernet HW addr prior to starting Linux,
-	 * needed for nfsroot
-	 */
-	eth_init(gd->bd);
-#endif
-}
-#endif
-
 int board_eth_init(bd_t *bis)
 {
 	int rc = 0;
board/atmel/at91cap9adk/at91cap9adk.c +0 -16
index 9f73df6..2fd20db 100644
@@ -35,9 +35,6 @@
 #include <asm/arch/hardware.h>
 #include <lcd.h>
 #include <atmel_lcdc.h>
-#if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
-#include <net.h>
-#endif
 #include <netdev.h>
 
 #define MP_BLOCK_3_BASE	0xFDF00000
@@ -336,19 +333,6 @@ int dram_init(void)
 	return 0;
 }
 
-#ifdef CONFIG_RESET_PHY_R
-void reset_phy(void)
-{
-#ifdef CONFIG_MACB
-	/*
-	 * Initialize ethernet HW addr prior to starting Linux,
-	 * needed for nfsroot
-	 */
-	eth_init(gd->bd);
-#endif
-}
-#endif
-
 int board_eth_init(bd_t *bis)
 {
 	int rc = 0;
board/atmel/at91sam9260ek/at91sam9260ek.c +0 -16
index 6bd3b44..8d01c4f 100644
@@ -32,9 +32,6 @@
 #include <asm/arch/gpio.h>
 #include <asm/arch/io.h>
 #include <asm/arch/hardware.h>
-#if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
-#include <net.h>
-#endif
 #include <netdev.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -172,19 +169,6 @@ int dram_init(void)
 	return 0;
 }
 
-#ifdef CONFIG_RESET_PHY_R
-void reset_phy(void)
-{
-#ifdef CONFIG_MACB
-	/*
-	 * Initialize ethernet HW addr prior to starting Linux,
-	 * needed for nfsroot
-	 */
-	eth_init(gd->bd);
-#endif
-}
-#endif
-
 int board_eth_init(bd_t *bis)
 {
 	int rc = 0;
board/atmel/at91sam9263ek/at91sam9263ek.c +0 -16
index 57d5c95..e19fd50 100644
@@ -36,9 +36,6 @@
 #include <asm/arch/hardware.h>
 #include <lcd.h>
 #include <atmel_lcdc.h>
-#if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
-#include <net.h>
-#endif
 #include <netdev.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -259,19 +256,6 @@ int dram_init(void)
 	return 0;
 }
 
-#ifdef CONFIG_RESET_PHY_R
-void reset_phy(void)
-{
-#ifdef CONFIG_MACB
-	/*
-	 * Initialize ethernet HW addr prior to starting Linux,
-	 * needed for nfsroot
-	 */
-	eth_init(gd->bd);
-#endif
-}
-#endif
-
 int board_eth_init(bd_t *bis)
 {
 	int rc = 0;
board/atmel/at91sam9rlek/at91sam9rlek.c +0 -3
index 7013ba2..94bcc17 100644
@@ -34,9 +34,6 @@
 #include <asm/arch/io.h>
 #include <lcd.h>
 #include <atmel_lcdc.h>
-#if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
-#include <net.h>
-#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
board/ronetix/pm9263/pm9263.c +0 -16
index d24ef9a..4927edd 100644
@@ -39,9 +39,6 @@
 #include <lcd.h>
 #include <atmel_lcdc.h>
 #include <dataflash.h>
-#if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
-#include <net.h>
-#endif
 #include <netdev.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -356,19 +353,6 @@ int dram_init(void)
 	return 0;
 }
 
-#ifdef CONFIG_RESET_PHY_R
-void reset_phy(void)
-{
-#ifdef CONFIG_MACB
-	/*
-	 * Initialize ethernet HW addr prior to starting Linux,
-	 * needed for nfsroot
-	 */
-	eth_init(gd->bd);
-#endif
-}
-#endif
-
 int board_eth_init(bd_t *bis)
 {
 	int rc = 0;
include/configs/afeb9260.h +0 -1
index c5134a2..2e891b0 100644
@@ -114,7 +114,6 @@
 /* Ethernet */
 #define CONFIG_MACB			1
 #undef CONFIG_RMII			/* We have full MII there */
-#define CONFIG_RESET_PHY_R		1
 
 #define CONFIG_NET_MULTI		1
 #define CONFIG_NET_RETRY_COUNT		20
include/configs/at91cap9adk.h +0 -1
index b2e6d7d..d3d2059 100644
@@ -138,7 +138,6 @@
 #define CONFIG_RMII			1
 #define CONFIG_NET_MULTI		1
 #define CONFIG_NET_RETRY_COUNT		20
-#define CONFIG_RESET_PHY_R		1
 
 /* USB */
 #define CONFIG_USB_ATMEL
include/configs/at91sam9260ek.h +0 -1
index e46c9d6..68e45a1 100644
@@ -134,7 +134,6 @@
 #define CONFIG_RMII			1
 #define CONFIG_NET_MULTI		1
 #define CONFIG_NET_RETRY_COUNT		20
-#define CONFIG_RESET_PHY_R		1
 
 /* USB */
 #define CONFIG_USB_ATMEL
include/configs/at91sam9263ek.h +0 -1
index d03ecee..016ec58 100644
@@ -144,7 +144,6 @@
 #define CONFIG_RMII			1
 #define CONFIG_NET_MULTI		1
 #define CONFIG_NET_RETRY_COUNT		20
-#define CONFIG_RESET_PHY_R		1
 
 /* USB */
 #define CONFIG_USB_ATMEL
include/configs/pm9263.h +0 -1
index 0db17b3..ffb40be 100644
@@ -232,7 +232,6 @@
 #define CONFIG_RMII			1
 #define CONFIG_NET_MULTI		1
 #define CONFIG_NET_RETRY_COUNT		20
-#define CONFIG_RESET_PHY_R		1
 
 /* USB */
 #define CONFIG_USB_ATMEL
Signature · 1 line
1.6.1.3
#4 lore raw

PATCH 4/4 at91/macb: remove reset_phy callback

Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD

reset_phy was used to force the macb to be always init in order to set the enetaddr in the hw registers which now done at the eth_initialize

I guess this is also NAK due to NAK'ing of parts 1 & 2.

regards,
Ben

#5 lore raw

PATCH 3/4 net/dm9000: move the CONFIG_NET_MULTI api

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 1 line · On Monday 11 May 2009 02:39:28 Jean-Christophe PLAGNIOL-VILLARD wrote:

this add multi devices support and merge dm9000's eeprom command support

assuming this doesnt depend on the first two patches in this series, this sounds great to me

drivers/net/dm9000x.c phy_read(int reg) · line 753

Quoted 8 lines
drivers/net/dm9000x.c +8 -0
+U_BOOT_CMD(
+	dm9000ee,4,1,do_dm9000_eeprom,
+	"Read/Write eeprom connected to Ethernet Controller",
+	"\ndm9000ee write <name> <word offset> <value> \n"
+	"\tdm9000ee read <name>\n"
+	"\tword:\t\t00-02 : MAC Address\n"
+	"\t\t\t03-07 : DM9000 Configuration\n"
+	"\t\t\t08-63 : User data\n");

the usage is slightly damaged in the original ... be nice to not copy over that broken crap. i.e. it should look like:

	"write <name> <word offset> <value>\n"
	"dm9000ee read <name>\n"
	"\tword:\t\t00-02 : MAC Address\n"
	"\t\t\t03-07 : DM9000 Configuration\n"
	"\t\t\t08-63 : User data\n");
Quoted 1 line

+int dm9000_eth_initialize(int id, u32 *data_addr, u32 *io_addr);

requiring the data and io addr to be 32bit aligned is not a real requirement is it ? so perhaps it should be void* here instead of u32*. -mike

#6 lore raw

PATCH 3/4 net/dm9000: move the CONFIG_NET_MULTI api

Quoted 5 lines · Mike Frysinger
Quoted 1 line · On Monday 11 May 2009 02:39:28 Jean-Christophe PLAGNIOL-VILLARD wrote:

this add multi devices support and merge dm9000's eeprom command support

assuming this doesnt depend on the first two patches in this series, this sounds great to me

no it does

Best Regards,
J.

#7 lore raw

PATCH 3/4 net/dm9000: move the CONFIG_NET_MULTI api

Quoted 9 lines · On Monday 11 May 2009 19:58:27 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 6 lines · Mike Frysinger
Quoted 2 lines · On Monday 11 May 2009 02:39:28 Jean-Christophe PLAGNIOL-VILLARD wrote:

this add multi devices support and merge dm9000's eeprom command support

assuming this doesnt depend on the first two patches in this series, this sounds great to me

no it does

shouldnt be hard to decouple it then considering the eth struct already passes down the initialized mac address
-mike

#8 lore raw

PATCH 3/4 net/dm9000: move the CONFIG_NET_MULTI api

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 9 lines · Jean-Christophe PLAGNIOL-VILLARD

this add multi devices support and merge dm9000's eeprom command support

Cc Ben Warren <[email protected]>
Cc TsiChung Liew <[email protected]>
Cc Konstantin Kletschke <[email protected]>
Cc Stelian Pop <[email protected]>

---

I'll go over this in the next few days.

thanks,
Ben

#10 lore raw

PATCH 2/4 macb: add set_hw_enetaddr support

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 52 lines · Jean-Christophe PLAGNIOL-VILLARD
---
 drivers/net/macb.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)
drivers/net/macb.c +16 -6
index 6de0a04..a339730 100644
@@ -404,12 +404,25 @@ static int macb_phy_init(struct macb_device *macb)
 	}
 }
 
-static int macb_init(struct eth_device *netdev, bd_t *bd)
+static int macb_set_hw_enetaddr(struct eth_device *netdev, bd_t *bd)
 {
 	struct macb_device *macb = to_macb(netdev);
-	unsigned long paddr;
 	u32 hwaddr_bottom;
 	u16 hwaddr_top;
+
+	/* set hardware address */
+	hwaddr_bottom = cpu_to_le32(*((u32 *)netdev->enetaddr));
+	macb_writel(macb, SA1B, hwaddr_bottom);
+	hwaddr_top = cpu_to_le16(*((u16 *)(netdev->enetaddr + 4)));
+	macb_writel(macb, SA1T, hwaddr_top);
+
+	return 0;
+}
+
+static int macb_init(struct eth_device *netdev, bd_t *bd)
+{
+	struct macb_device *macb = to_macb(netdev);
+	unsigned long paddr;
 	int i;
 
 	/*
@@ -439,10 +452,7 @@ static int macb_init(struct eth_device *netdev, bd_t *bd)
 	macb_writel(macb, TBQP, macb->tx_ring_dma);
 
 	/* set hardware address */
-	hwaddr_bottom = cpu_to_le32(*((u32 *)netdev->enetaddr));
-	macb_writel(macb, SA1B, hwaddr_bottom);
-	hwaddr_top = cpu_to_le16(*((u16 *)(netdev->enetaddr + 4)));
-	macb_writel(macb, SA1T, hwaddr_top);
+	macb_set_hw_enetaddr(netdev, bd);
 
 	/* choose RMII or MII mode. This depends on the board */
 #ifdef CONFIG_RMII

drivers/net/macb.c int macb_eth_initialize(int id, void *regs, unsigned int phy_addr) · line 535

Quoted 5 lines
drivers/net/macb.c +1 -0
@@ -521,6 +531,7 @@ int macb_eth_initialize(int id, void *regs, unsigned int phy_addr)
 	netdev->halt = macb_halt;
 	netdev->send = macb_send;
 	netdev->recv = macb_recv;
+	netdev->set_hw_enetaddr = macb_set_hw_enetaddr;
 

NAK, since this function pointer doesn't exist due to NAK'ing of part 1

regards,
Ben

#11 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 2 lines · On Monday 11 May 2009 02:39:26 Jean-Christophe PLAGNIOL-VILLARD wrote:

this will allow to add later a hook to update the enetadd hw storage when it's updated in env or when the env is saved

there is no need for that on purpose. the network layer will recheck the environment every time it gets initialized, and it gets initialized with every network step. this is already documented in doc/README.enetaddr.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090511/2d88e118/attachment.pgp

#12 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Quoted 7 lines · Mike Frysinger
Quoted 2 lines · On Monday 11 May 2009 02:39:26 Jean-Christophe PLAGNIOL-VILLARD wrote:

this will allow to add later a hook to update the enetadd hw storage when it's updated in env or when the env is saved

there is no need for that on purpose. the network layer will recheck the environment every time it gets initialized, and it gets initialized with every network step. this is already documented in doc/README.enetaddr.

Unfortunatly we need it to set the enetaddr in the register of the soc evenif there is no ethernet transfer as for the macb on at91 or the dm9000. This how the kernel pass the mac address for the bootloader.

Best Regards,
J.

#13 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 4 lines

there is no need for that on purpose. the network layer will recheck the environment every time it gets initialized, and it gets initialized with every network step. this is already documented in doc/README.enetaddr.

Unfortunatly we need it to set the enetaddr in the register of the soc evenif there is no ethernet transfer as for the macb on at91 or the dm9000. This how the kernel pass the mac address for the bootloader.

You mean, this is how U-Boot is supposed to pass the MAC address to the Kernel, right?

Well, strictly speaking this is (1) in direct violation of U-Boot's design principles which say NOT to initialize things it does not use itself, and (2) a bug in the Linux kernel that should be fixed there.

In this case it may be just writing to a register without further initialization of the hardware, but if we allow for that you can bet that tomorrow someone will try and add code that requires more extensive initialization of the hardware for the same purpose, and he will argue that his code must go in because there is preexisting code that does the same.

That's why I have to NAK this.

The problem should be fixed in the Linux kernel. I know that RMK does not alow for things like a MAC ATAG or similar, so the best you can do is hope for quick approach of device tree based drivers. Until then, you probably have to resort to out-of-tree (Linux) solutions like everybody else who hit this problem before.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Nobody trips over mountains. It is the small pebble that  causes  you
to  stumble.  Pass all the pebbles in your path and you will find you
have crossed the mountain.
#14 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Quoted 18 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 4 lines

there is no need for that on purpose. the network layer will recheck the environment every time it gets initialized, and it gets initialized with every network step. this is already documented in doc/README.enetaddr.

Unfortunatly we need it to set the enetaddr in the register of the soc evenif there is no ethernet transfer as for the macb on at91 or the dm9000. This how the kernel pass the mac address for the bootloader.

You mean, this is how U-Boot is supposed to pass the MAC address to the Kernel, right?

Well, strictly speaking this is (1) in direct violation of U-Boot's design principles which say NOT to initialize things it does not use itself, and (2) a bug in the Linux kernel that should be fixed there.

Quoted 6 lines

In this case it may be just writing to a register without further initialization of the hardware, but if we allow for that you can bet that tomorrow someone will try and add code that requires more extensive initialization of the hardware for the same purpose, and he will argue that his code must go in because there is preexisting code that does the same.

this exactly what is done only write mac hw register without init the eth stack

before we do need to init the mac and detect the phy if we want to store now we have to call the set_hw_enetaddr

Best Regards,
J.

#15 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 18 lines · In message <[email protected]> you wrote:
Quoted 12 lines
Quoted 4 lines

Unfortunatly we need it to set the enetaddr in the register of the soc evenif there is no ethernet transfer as for the macb on at91 or the dm9000. This how the kernel pass the mac address for the bootloader.

You mean, this is how U-Boot is supposed to pass the MAC address to the Kernel, right?

Well, strictly speaking this is (1) in direct violation of U-Boot's design principles which say NOT to initialize things it does not use itself, and (2) a bug in the Linux kernel that should be fixed there.

Quoted 6 lines

In this case it may be just writing to a register without further initialization of the hardware, but if we allow for that you can bet that tomorrow someone will try and add code that requires more extensive initialization of the hardware for the same purpose, and he will argue that his code must go in because there is preexisting code that does the same.

Quoted 5 lines

this exactly what is done only write mac hw register without init the eth stack

before we do need to init the mac and detect the phy if we want to store now we have to call the set_hw_enetaddr

Yes, I perfectly understood this. You did not have to explain it again.

Did you understand what I wrote, too?

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Minds are like parachutes - they only function when open.
#16 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Quoted 21 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 18 lines · In message <[email protected]> you wrote:
Quoted 18 lines
Quoted 4 lines

Unfortunatly we need it to set the enetaddr in the register of the soc evenif there is no ethernet transfer as for the macb on at91 or the dm9000. This how the kernel pass the mac address for the bootloader.

You mean, this is how U-Boot is supposed to pass the MAC address to the Kernel, right?

Well, strictly speaking this is (1) in direct violation of U-Boot's design principles which say NOT to initialize things it does not use itself, and (2) a bug in the Linux kernel that should be fixed there.

In this case it may be just writing to a register without further initialization of the hardware, but if we allow for that you can bet that tomorrow someone will try and add code that requires more extensive initialization of the hardware for the same purpose, and he will argue that his code must go in because there is preexisting code that does the same.

Quoted 8 lines
Quoted 5 lines

this exactly what is done only write mac hw register without init the eth stack

before we do need to init the mac and detect the phy if we want to store now we have to call the set_hw_enetaddr

Yes, I perfectly understood this. You did not have to explain it again.

So no I do not understand why you nack it

Best Regards,
J.

#17 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 27 lines · On Monday 11 May 2009 10:24:54 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 19 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 8 lines · In message <[email protected]> you wrote:
Quoted 4 lines

there is no need for that on purpose. the network layer will recheck the environment every time it gets initialized, and it gets initialized with every network step. this is already documented in doc/README.enetaddr.

Unfortunatly we need it to set the enetaddr in the register of the soc evenif there is no ethernet transfer as for the macb on at91 or the dm9000. This how the kernel pass the mac address for the bootloader.

You mean, this is how U-Boot is supposed to pass the MAC address to the Kernel, right?

Well, strictly speaking this is (1) in direct violation of U-Boot's design principles which say NOT to initialize things it does not use itself, and (2) a bug in the Linux kernel that should be fixed there.

Quoted 6 lines

In this case it may be just writing to a register without further initialization of the hardware, but if we allow for that you can bet that tomorrow someone will try and add code that requires more extensive initialization of the hardware for the same purpose, and he will argue that his code must go in because there is preexisting code that does the same.

Quoted 5 lines

this exactly what is done only write mac hw register without init the eth stack

before we do need to init the mac and detect the phy if we want to store now we have to call the set_hw_enetaddr

then we agree you're doing it wrong and this patch is not needed/wanted

there is this FAQ, but i think we can add more info to it:
http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090511/08ed61a4/attachment.pgp

#18 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Quoted 31 lines · Mike Frysinger
Quoted 30 lines · On Monday 11 May 2009 10:24:54 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 19 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 8 lines · In message <[email protected]> you wrote:
Quoted 4 lines

there is no need for that on purpose. the network layer will recheck the environment every time it gets initialized, and it gets initialized with every network step. this is already documented in doc/README.enetaddr.

Unfortunatly we need it to set the enetaddr in the register of the soc evenif there is no ethernet transfer as for the macb on at91 or the dm9000. This how the kernel pass the mac address for the bootloader.

You mean, this is how U-Boot is supposed to pass the MAC address to the Kernel, right?

Well, strictly speaking this is (1) in direct violation of U-Boot's design principles which say NOT to initialize things it does not use itself, and (2) a bug in the Linux kernel that should be fixed there.

Quoted 6 lines

In this case it may be just writing to a register without further initialization of the hardware, but if we allow for that you can bet that tomorrow someone will try and add code that requires more extensive initialization of the hardware for the same purpose, and he will argue that his code must go in because there is preexisting code that does the same.

this exactly what is done only write mac hw register without init the eth stack

Quoted 7 lines
Quoted 2 lines

before we do need to init the mac and detect the phy if we want to store now we have to call the set_hw_enetaddr

then we agree you're doing it wrong and this patch is not needed/wanted

there is this FAQ, but i think we can add more info to it:
http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux

It does not work ether
how do you deal with multiple nic? how do set a mac for NFS Rootfs? how do you boot a *mainline* kernel?

Best Regards,
J.

#19 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Quoted 34 lines · On Monday 11 May 2009 12:37:28 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 33 lines · Mike Frysinger
Quoted 31 lines · On Monday 11 May 2009 10:24:54 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 18 lines · Wolfgang Denk
Quoted 9 lines · In message Jean-Christophe
Quoted 4 lines

there is no need for that on purpose. the network layer will recheck the environment every time it gets initialized, and it gets initialized with every network step. this is already documented in doc/README.enetaddr.

Unfortunatly we need it to set the enetaddr in the register of the soc evenif there is no ethernet transfer as for the macb on at91 or the dm9000. This how the kernel pass the mac address for the bootloader.

You mean, this is how U-Boot is supposed to pass the MAC address to the Kernel, right?

Well, strictly speaking this is (1) in direct violation of U-Boot's design principles which say NOT to initialize things it does not use itself, and (2) a bug in the Linux kernel that should be fixed there.

Quoted 6 lines

In this case it may be just writing to a register without further initialization of the hardware, but if we allow for that you can bet that tomorrow someone will try and add code that requires more extensive initialization of the hardware for the same purpose, and he will argue that his code must go in because there is preexisting code that does the same.

this exactly what is done only write mac hw register without init the eth stack

before we do need to init the mac and detect the phy if we want to store now we have to call the set_hw_enetaddr

Quoted 6 lines
Quoted 4 lines

then we agree you're doing it wrong and this patch is not needed/wanted

there is this FAQ, but i think we can add more info to it:
http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux

It does not work ether

your solution blatantly ignores the issues raised in the FAQ. you cant push a change without clearing addressing those.

Quoted 1 line

how do you deal with multiple nic?

the ATAG/FDT tree handles most arches.

for the rest you have two major issues to address:
- how do i pass it to the next OS ?
* have the OS read the u-boot environment
* have the OS read the command line
- how does the OS set it ?
* add a board hook to set it
* set it via user space and normal methods (ifconfig hw)

Quoted 1 line

how do set a mac for NFS Rootfs?

use initramfs

Quoted 1 line

how do you boot a *mainline* kernel?

i dont know why you're emphasizing mainline. if it's your board and if you implement the change correctly, submit it to mainline.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090511/2e4100ca/attachment.pgp

#20 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

this exactly what is done only write mac hw register without init the eth stack

before we do need to init the mac and detect the phy if we want to store now we have to call the set_hw_enetaddr

then we agree you're doing it wrong and this patch is not needed/wanted

there is this FAQ, but i think we can add more info to it:
http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux

Quoted 8 lines
Quoted 1 line

It does not work ether

your solution blatantly ignores the issues raised in the FAQ. you cant push a change without clearing addressing those.

Quoted 1 line

how do you deal with multiple nic?

the ATAG/FDT tree handles most arches.

both not possible

Quoted 9 lines

for the rest you have two major issues to address:
- how do i pass it to the next OS ?
* have the OS read the u-boot environment
* have the OS read the command line
- how does the OS set it ?
* add a board hook to set it
* set it via user space and normal methods (ifconfig hw)

Quoted 3 lines
Quoted 1 line

how do set a mac for NFS Rootfs?

use initramfs

don't you think it's overkill to use a initramfs just for set a mac address??

Quoted 5 lines
Quoted 2 lines

how do you boot a *mainline* kernel?

i dont know why you're emphasizing mainline. if it's your board and if you implement the change correctly, submit it to mainline.

because I already known RMK answer
NACK

Best Regards,
J.

#21 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Quoted 31 lines · On Monday 11 May 2009 20:04:46 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines

this exactly what is done only write mac hw register without init the eth stack

before we do need to init the mac and detect the phy if we want to store now we have to call the set_hw_enetaddr

then we agree you're doing it wrong and this patch is not needed/wanted

there is this FAQ, but i think we can add more info to it:
http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux

Quoted 8 lines
Quoted 1 line

It does not work ether

your solution blatantly ignores the issues raised in the FAQ. you cant push a change without clearing addressing those.

Quoted 1 line

how do you deal with multiple nic?

the ATAG/FDT tree handles most arches.

both not possible

Quoted 8 lines

for the rest you have two major issues to address:
- how do i pass it to the next OS ?
* have the OS read the u-boot environment
* have the OS read the command line
- how does the OS set it ?
* add a board hook to set it
* set it via user space and normal methods (ifconfig hw)

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

how do set a mac for NFS Rootfs?

use initramfs

don't you think it's overkill to use a initramfs just for set a mac address??

no, i think it's perfectly reasonable. and considering you have no other option here that'll get merged ...
-mike

#22 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Hi,

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

how do set a mac for NFS Rootfs?

use initramfs

don't you think it's overkill to use a initramfs just for set a mac address??

no, i think it's perfectly reasonable. and considering you have no other option here that'll get merged ...

Can you please explain to me, why you think it to be reasonable to demand providing an initramfs in the order of 100s of k to set an attribute of a hardware device which has its own driver?

Apart from being constantly repeated, I do not understand this reasoning at all. My (old-school) belief was that an operating system deals with abstracting the hardware thus userspace does not need to (nor should) know too many hw details.

Knowing that there is not a clear distinction line, I still fail to see why a mac address of a network interface should be handled by userspace. Can someone enlighten me here?

Thanks
Detlev

Signature · 8 lines
Ftpd never switches uid and euid, it uses setfsuid(2) instead. The
main reason is that uid switching has been exploited in several
breakins, but the sheer ugliness of uid switching counts too.
                                     -- pure-ftpd(8)
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#23 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Quoted 14 lines · On Tuesday 12 May 2009 04:48:28 Detlev Zundel wrote:
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

how do set a mac for NFS Rootfs?

use initramfs

don't you think it's overkill to use a initramfs just for set a mac address??

no, i think it's perfectly reasonable. and considering you have no other option here that'll get merged ...

Can you please explain to me, why you think it to be reasonable to demand providing an initramfs in the order of 100s of k to set an attribute of a hardware device which has its own driver?

Quoted 8 lines

Apart from being constantly repeated, I do not understand this reasoning at all. My (old-school) belief was that an operating system deals with abstracting the hardware thus userspace does not need to (nor should) know too many hw details.

Knowing that there is not a clear distinction line, I still fail to see why a mac address of a network interface should be handled by userspace. Can someone enlighten me here?

no one said it must be done in userspace, that was just one method for doing it. read the FAQ for other possibilities.
-mike

#24 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Hi Mike,

Quoted 20 lines · On Tuesday 12 May 2009 04:48:28 Detlev Zundel wrote:
Quoted 19 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

how do set a mac for NFS Rootfs?

use initramfs

don't you think it's overkill to use a initramfs just for set a mac address??

no, i think it's perfectly reasonable. and considering you have no other option here that'll get merged ...

Can you please explain to me, why you think it to be reasonable to demand providing an initramfs in the order of 100s of k to set an attribute of a hardware device which has its own driver?

Apart from being constantly repeated, I do not understand this reasoning at all. My (old-school) belief was that an operating system deals with abstracting the hardware thus userspace does not need to (nor should) know too many hw details.

Quoted 6 lines
Quoted 3 lines

Knowing that there is not a clear distinction line, I still fail to see why a mac address of a network interface should be handled by userspace. Can someone enlighten me here?

no one said it must be done in userspace, that was just one method for doing it. read the FAQ for other possibilities.

No you lost me completely. The question cited above was whether you find it plausible to use initramfs - and thus userspace - to set a mac address. You answered that you find this plausible. This is what I do not understand.

I never ran across this outside of linux arm where people seriously repeat the statement over and over that a whole initramfs with an initial userspace and a pivot_root is plausible for nfs root whilst patches of a few lines float around doing the same in the kernel.

Now proof by repetition is not my preferred form of understanding a problem, so I was asking for an explanation from someone arguing along the same lines.

Cheers
Detlev

Signature · 8 lines
We can forgive a man for making a useful thing as long as he does not
admire it.  The only excuse  for making  a useless  thing is that one
admires it intensely.
                                    --- Oscar Wilde
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#25 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Quoted 8 lines · Detlev Zundel

I never ran across this outside of linux arm where people seriously repeat the statement over and over that a whole initramfs with an initial userspace and a pivot_root is plausible for nfs root whilst patches of a few lines float around doing the same in the kernel.

Now proof by repetition is not my preferred form of understanding a problem, so I was asking for an explanation from someone arguing along the same lines.

The wiki page that explains the problem and provides the suggested solutions does not repeat that same mantra. It mentions the initramfs method as one way out of several - I don't think it mentions that solution as particularly better in any way. Wolfgang also repeated (most of) them here just a few mails ago in this thread.

Signature · 1 line
  / daniel.haxx.se
#26 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

In reply to Detlev Zundel
Quoted 34 lines · On Tuesday 12 May 2009 10:18:25 Detlev Zundel wrote:

Hi Mike,

Quoted 20 lines · On Tuesday 12 May 2009 04:48:28 Detlev Zundel wrote:
Quoted 19 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

how do set a mac for NFS Rootfs?

use initramfs

don't you think it's overkill to use a initramfs just for set a mac address??

no, i think it's perfectly reasonable. and considering you have no other option here that'll get merged ...

Can you please explain to me, why you think it to be reasonable to demand providing an initramfs in the order of 100s of k to set an attribute of a hardware device which has its own driver?

Apart from being constantly repeated, I do not understand this reasoning at all. My (old-school) belief was that an operating system deals with abstracting the hardware thus userspace does not need to (nor should) know too many hw details.

Quoted 6 lines
Quoted 3 lines

Knowing that there is not a clear distinction line, I still fail to see why a mac address of a network interface should be handled by userspace. Can someone enlighten me here?

no one said it must be done in userspace, that was just one method for doing it. read the FAQ for other possibilities.

No you lost me completely. The question cited above was whether you find it plausible to use initramfs - and thus userspace - to set a mac address. You answered that you find this plausible. This is what I do not understand.

Quoted 4 lines

I never ran across this outside of linux arm where people seriously repeat the statement over and over that a whole initramfs with an initial userspace and a pivot_root is plausible for nfs root whilst patches of a few lines float around doing the same in the kernel.

i never said that a completely populated initramfs was needed. it can be accomplished pretty easily with very little code.
-mike

#27 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Hi Mike,

Quoted 7 lines
Quoted 4 lines

I never ran across this outside of linux arm where people seriously repeat the statement over and over that a whole initramfs with an initial userspace and a pivot_root is plausible for nfs root whilst patches of a few lines float around doing the same in the kernel.

i never said that a completely populated initramfs was needed. it can be accomplished pretty easily with very little code.

Sure, but still, how big is such an initramfs, do you have any numbers here?

And how many lines of C code does it take to set the MAC in the kernel? Is this really worth it?

Cheers
Detlev

Signature · 9 lines
Basically,  Barnes & Noble separates things by how old they are  -- current
stuff is "Fiction", stuff from 20 years ago is "Literature", stuff from 100
years ago is "Classics", stuff from 400 years ago is "Shakespeare" [..] and
stuff from 2000 years ago is "History".
                     -- James "Kibo" Parry in <[email protected]>
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#28 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Quoted 5 lines · On Wednesday 13 May 2009 04:41:29 Detlev Zundel wrote:
Quoted 5 lines
Quoted 4 lines

I never ran across this outside of linux arm where people seriously repeat the statement over and over that a whole initramfs with an initial userspace and a pivot_root is plausible for nfs root whilst patches of a few lines float around doing the same in the kernel.

Quoted 8 lines
Quoted 2 lines

i never said that a completely populated initramfs was needed. it can be accomplished pretty easily with very little code.

Sure, but still, how big is such an initramfs, do you have any numbers here?

And how many lines of C code does it take to set the MAC in the kernel? Is this really worth it?

that is the problem of whoever needs this functionality. -mike

#29 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Hi Mike,

Quoted 9 lines · On Wednesday 13 May 2009 04:41:29 Detlev Zundel wrote:
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

I never ran across this outside of linux arm where people seriously repeat the statement over and over that a whole initramfs with an initial userspace and a pivot_root is plausible for nfs root whilst patches of a few lines float around doing the same in the kernel.

i never said that a completely populated initramfs was needed. it can be accomplished pretty easily with very little code.

Quoted 7 lines
Quoted 5 lines

Sure, but still, how big is such an initramfs, do you have any numbers here?

And how many lines of C code does it take to set the MAC in the kernel? Is this really worth it?

that is the problem of whoever needs this functionality.

Ah. Now this is exactly what reminded me of the ARM Linux ML in the first place :(

Seeing that I do not learn anything new here, I'll stop.

Cheers
Detlev

Signature · 8 lines
We can forgive a man for making a useful thing as long as he does not
admire it.  The only excuse  for making  a useless  thing is that one
admires it intensely.
                                    --- Oscar Wilde
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#30 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

In reply to Detlev Zundel
Quoted 3 lines · Detlev Zundel

Can you please explain to me, why you think it to be reasonable to demand providing an initramfs in the order of 100s of k to set an attribute of a hardware device which has its own driver?

Kind of defeats any space-usage argument against putting device trees in ARM instead...

Quoted 4 lines

Apart from being constantly repeated, I do not understand this reasoning at all. My (old-school) belief was that an operating system deals with abstracting the hardware thus userspace does not need to (nor should) know too many hw details.

There's more to the operating system than the kernel.

-Scott

#31 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Hi Scott,

Quoted 7 lines · Detlev Zundel
Quoted 3 lines

Can you please explain to me, why you think it to be reasonable to demand providing an initramfs in the order of 100s of k to set an attribute of a hardware device which has its own driver?

Kind of defeats any space-usage argument against putting device trees in ARM instead...

Good point.

Quoted 6 lines
Quoted 4 lines

Apart from being constantly repeated, I do not understand this reasoning at all. My (old-school) belief was that an operating system deals with abstracting the hardware thus userspace does not need to (nor should) know too many hw details.

There's more to the operating system than the kernel.

Sure - but how does this affect the question at hand?

Cheers
Detlev

Signature · 5 lines
Practice random senselessness and act kind of beautiful.
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#32 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 2 lines

i dont know why you're emphasizing mainline. if it's your board and if you implement the change correctly, submit it to mainline.

because I already known RMK answer
NACK

So go to RMK and say you need device trees because you got NACKed in u-boot. :-)

-Scott

#33 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

In reply to Jean-Christophe PLAGNIOL-VILLARD

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 5 lines

then we agree you're doing it wrong and this patch is not needed/wanted

there is this FAQ, but i think we can add more info to it:
http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux

It does not work ether

What is "it" in this sentence?

You start a discussion here which is off topic on the U-Boot list. It deals with a problem that is caused by the ARM Linuxkernel design. It's a very old problem, that has been discussed many times before, and it's unlikely that we willsolve it here. If you want to solve it, then please explain it to RMK.

Quoted 1 line

how do you deal with multiple nic?

Other (more reasonable architectures) use a device tree (current PowerPC), a binary data structure (old PowerPC), or command line arguments.

Quoted 1 line

how do set a mac for NFS Rootfs?

Other (more reasonable architectures) use a device tree (current PowerPC), a binary data structure (old PowerPC), or command line arguments.

Quoted 1 line

how do you boot a *mainline* kernel?

Other (more reasonable architectures) use a device tree (current PowerPC), a binary data structure (old PowerPC), or command line arguments.

The fact that mainline ARM has serious deficiencies is another story. Or can you explain why the ARM kernel cannot load and uncompress a ramdisk image from NOR flash, why we instead have to load it to RAM first, adding a completely unnecessary copy operation? It's just one of the issues with the ARM Linux kernel that need to be fixed *there*.

But, as mentioned, this is off topic here.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The whole problem with the world is  that  fools  and  fanatics  are
always so certain of themselves, but wiser people so full of doubts."
- Bertrand Russell
#34 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

In reply to Mike Frysinger
Quoted 2 lines · On Monday 11 May 2009 12:24:31 Mike Frysinger wrote:

there is this FAQ, but i think we can add more info to it:
http://www.denx.de/wiki/view/DULG/EthernetDoesNotWorkInLinux

ive filled it out some more ... i'm assuming this is the best place for such information

also, i dont really know this wiki, so i cheated with the FDT wiki link and used the full path since i was unable to guess at how to make it work relatively.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090511/f403e4b0/attachment.pgp

#35 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

Dear Mike,

Quoted 3 lines · in message <[email protected]> you wrote:

ive filled it out some more ... i'm assuming this is the best place for such information

Thanks.

Quoted 3 lines

also, i dont really know this wiki, so i cheated with the FDT wiki link and used the full path since i was unable to guess at how to make it work relatively.

See http://www.denx.de/wiki/TWiki/TextFormattingRules next time you have such an issue. I fixed it.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Everyting looks interesting until you do it. Then you find it's  just
another job.                     - Terry Pratchett, _Moving Pictures_
#36 lore raw

PATCH 1/4 net: extend the netdev to have a common way to set the hw mac address

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 47 lines · Jean-Christophe PLAGNIOL-VILLARD

init it at the eth_initialize

this will allow to add later a hook to update the enetadd hw storage when it's updated in env or when the env is saved

---
 include/net.h |    2 ++
 net/eth.c     |    4 ++++
 2 files changed, 6 insertions(+), 0 deletions(-)
include/net.h +2 -0
index 5a1d36e..2ed6263 100644
@@ -93,6 +93,7 @@ enum eth_state_t {
 };
 
 struct eth_device {
+	int num;
 	char name[NAMESIZE];
 	unsigned char enetaddr[6];
 	int iobase;
@@ -105,6 +106,7 @@ struct eth_device {
 #ifdef CONFIG_MCAST_TFTP
 	int (*mcast) (struct eth_device*, u32 ip, u8 set);
 #endif
+	int  (*set_hw_enetaddr) (struct eth_device*, bd_t*);
 	struct eth_device *next;
 	void *priv;
 };
net/eth.c +2 -0
index c6fa5b9..99bb6c2 100644
@@ -217,6 +217,8 @@ int eth_initialize(bd_t *bis)
 			if (eth_number)
 				puts (", ");
 
+			dev->num = eth_number;
+
 			printf("%s", dev->name);
 
 			if (ethprime && strcmp (dev->name, ethprime) == 0) {

net/eth.c int eth_initialize(bd_t *bis) · line 249

Quoted 8 lines
net/eth.c +2 -0
@@ -240,6 +242,8 @@ int eth_initialize(bd_t *bis)
 				}
 
 				memcpy(dev->enetaddr, env_enetaddr, 6);
+				if(dev->set_hw_enetaddr)
+					dev->set_hw_enetaddr(dev, bis);
 			}
 
 			eth_number++;

NAK, as convincingly explained by others.

regards,
Ben