Skip to contentSkip to conversation

net/eth_device: keep index inside each device

PATCH New Jean-Christophe PLAGNIOL-VILLARD 3 participants 19 messages Aug 11, 2009 – Aug 12, 2009

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

PATCH 1/3 net/eth_device: keep index inside each device

---
 include/net.h |    1 +
 net/eth.c     |   17 +++++------------
 2 files changed, 6 insertions(+), 12 deletions(-)
include/net.h +1 -0
index 4a03717..2a8a12d 100644
@@ -93,6 +93,7 @@ enum eth_state_t {
 };
 
 struct eth_device {
+	int index;
 	char name[NAMESIZE];
 	unsigned char enetaddr[6];
 	int iobase;
net/eth.c +5 -12
index 42f74da..2316a22 100644
@@ -83,6 +83,7 @@ static unsigned int eth_rcv_current = 0, eth_rcv_last = 0;
 #endif
 
 static struct eth_device *eth_devices, *eth_current;
+static int nb_eth_devices = 0;
 
 struct eth_device *eth_get_dev(void)
 {
@@ -133,22 +134,12 @@ struct eth_device *eth_get_dev_by_index(int index)
 
 int eth_get_dev_index (void)
 {
-	struct eth_device *dev;
-	int num = 0;
-
 	if (!eth_devices) {
 		return (-1);
 	}
 
-	for (dev = eth_devices; dev; dev = dev->next) {
-		if (dev == eth_current)
-			break;
-		++num;
-	}
-
-	if (dev) {
-		return (num);
-	}
+	if (eth_current)
+		return eth_current->index;
 
 	return (0);
 }
@@ -172,6 +163,8 @@ int eth_register(struct eth_device* dev)
 		d->next = dev;
 	}
 
+	dev->index = nb_eth_devices;
+	nb_eth_devices++;
 	dev->state = ETH_STATE_INIT;
 	dev->next  = eth_devices;
 
Signature · 1 line
1.6.4
#1 lore raw

PATCH 2/3 net: add getenv/setenv enetaddr function to use ethernet device num

---
 include/net.h |    2 ++
 net/eth.c     |   28 +++++++++++++++++++++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)
include/net.h +2 -0
index 2a8a12d..dc4ae41 100644
@@ -124,6 +124,8 @@ extern void eth_set_enetaddr(int num, char* a);	/* Set new MAC address */
 extern void eth_parse_enetaddr(const char *addr, uchar *enetaddr);
 extern int eth_getenv_enetaddr(char *name, uchar *enetaddr);
 extern int eth_setenv_enetaddr(char *name, const uchar *enetaddr);
+extern int eth_getenv_num_enetaddr(int num, uchar *enetaddr);
+extern int eth_setenv_num_enetaddr(int num, const uchar *enetaddr);
 
 extern int eth_init(bd_t *bis);			/* Initialize the device */
 extern int eth_send(volatile void *packet, int length);	   /* Send a packet */
net/eth.c +25 -3
index 2316a22..9bdf961 100644
@@ -27,6 +27,12 @@
 #include <miidev.h>
 
 #ifdef CONFIG_CMD_NET
+
+static void get_enetvar(int num, char *enetvar)
+{
+	sprintf(enetvar, num ? "eth%daddr" : "ethaddr", num);
+}
+
 void eth_parse_enetaddr(const char *addr, uchar *enetaddr)
 {
 	char *end;
@@ -53,6 +59,24 @@ int eth_setenv_enetaddr(char *name, const uchar *enetaddr)
 
 	return setenv(name, buf);
 }
+
+int eth_getenv_num_enetaddr(int num, uchar *enetaddr)
+{
+	char enetvar[32];
+
+	get_enetvar(num, enetvar);
+
+	return eth_getenv_enetaddr(enetvar, enetaddr);
+}
+
+int eth_setenv_num_enetaddr(int num, const uchar *enetaddr)
+{
+	char enetvar[32];
+
+	get_enetvar(num, enetvar);
+
+	return eth_setenv_enetaddr(enetvar, enetaddr);
+}
 #endif
 
 #if defined(CONFIG_CMD_NET) && defined(CONFIG_NET_MULTI)
@@ -173,7 +197,6 @@ int eth_register(struct eth_device* dev)
 
 int eth_initialize(bd_t *bis)
 {
-	char enetvar[32];
 	unsigned char env_enetaddr[6];
 	int eth_number = 0;
 
@@ -214,8 +237,7 @@ int eth_initialize(bd_t *bis)
 				puts (" [PRIME]");
 			}
 
-			sprintf(enetvar, eth_number ? "eth%daddr" : "ethaddr", eth_number);
-			eth_getenv_enetaddr(enetvar, env_enetaddr);
+			eth_getenv_num_enetaddr(eth_number, env_enetaddr);
 
 			if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
 				if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&
Signature · 1 line
1.6.4
#2 lore raw

PATCH 3/3 smc91111: switch to MULTI_NET api

---
 board/netstar/eeprom.c           |    3 +-
 board/voiceblue/eeprom.c         |    3 +-
 drivers/net/smc91111.c           |  420 +++++++++++++++++++------------------
 drivers/net/smc91111.h           |    8 +-
 include/configs/ADNPESC1.h       |    1 +
 include/configs/DK1C20.h         |    1 +
 include/configs/DK1S10.h         |    1 +
 include/configs/EP1C20.h         |    1 +
 include/configs/EP1S10.h         |    1 +
 include/configs/EP1S40.h         |    1 +
 include/configs/MigoR.h          |    1 +
 include/configs/PK1C20.h         |    1 +
 include/configs/bf533-ezkit.h    |    1 +
 include/configs/bf533-stamp.h    |    1 +
 include/configs/bf538f-ezkit.h   |    1 +
 include/configs/bf561-ezkit.h    |    1 +
 include/configs/blackstamp.h     |    1 +
 include/configs/cerf250.h        |    1 +
 include/configs/cm-bf533.h       |    1 +
 include/configs/cm-bf561.h       |    1 +
 include/configs/cradle.h         |    1 +
 include/configs/delta.h          |    1 +
 include/configs/dnp1110.h        |    1 +
 include/configs/gr_cpci_ax2000.h |    1 +
 include/configs/gr_ep2s60.h      |    1 +
 include/configs/innokom.h        |    1 +
 include/configs/integratorcp.h   |    1 +
 include/configs/logodl.h         |    1 +
 include/configs/lpd7a400-10.h    |    1 +
 include/configs/lpd7a404-10.h    |    1 +
 include/configs/ms7722se.h       |    1 +
 include/configs/netstar.h        |    1 +
 include/configs/nhk8815.h        |    1 +
 include/configs/pxa255_idp.h     |    1 +
 include/configs/versatile.h      |    1 +
 include/configs/voiceblue.h      |    1 +
 include/configs/xaeniax.h        |    1 +
 include/configs/xm250.h          |    1 +
 include/configs/xsengine.h       |    1 +
 include/configs/zylonite.h       |    1 +
 include/netdev.h                 |    1 +
 41 files changed, 259 insertions(+), 212 deletions(-)
board/netstar/eeprom.c +1 -2
index 5806128..05c6768 100644
@@ -27,9 +27,8 @@
 #include <common.h>
 #include <exports.h>
 #include <timestamp.h>
-#include "../drivers/net/smc91111.h"
-
 #define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE
+#include "../drivers/net/smc91111.h"
 
 static u16 read_eeprom_reg(u16 reg)
 {
board/voiceblue/eeprom.c +1 -2
index f01597a..8b3fbed 100644
@@ -27,9 +27,8 @@
 #include <common.h>
 #include <exports.h>
 #include <timestamp.h>
-#include "../drivers/net/smc91111.h"
-
 #define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE
+#include "../drivers/net/smc91111.h"
 
 static u16 read_eeprom_reg(u16 reg)
 {
drivers/net/smc91111.c +216 -204

765 lines not on this page · raw message

drivers/net/smc91111.h +4 -4
index 967addd..b2ed6a5 100644
@@ -72,6 +72,10 @@ typedef unsigned long int		dword;
 
 /* Because of bank switching, the LAN91xxx uses only 16 I/O ports */
 
+#ifndef SMC_BASE_ADDRESS
+#define SMC_BASE_ADDRESS smc->regs
+#endif
+
 #define	SMC_IO_EXTENT	16
 
 #ifdef CONFIG_PXA250
@@ -301,8 +305,6 @@ typedef unsigned long int		dword;
 
 #endif  /* CONFIG_SMC_USE_IOFUNCS */
 
-#if defined(CONFIG_SMC_USE_32_BIT)
-
 #ifdef CONFIG_XSENGINE
 #define	SMC_inl(r)	(*((volatile dword *)(SMC_BASE_ADDRESS+(r<<1))))
 #else
@@ -331,8 +333,6 @@ typedef unsigned long int		dword;
 					} \
 				})
 
-#endif /* CONFIG_SMC_USE_32_BIT */
-
 #endif
 
 /*---------------------------------------------------------------
include/configs/ADNPESC1.h +1 -0
index b8afc17..664a073 100644
@@ -412,6 +412,7 @@
 #if	(CONFIG_SYS_NIOS_CPU_LAN0_TYPE == 0)		/* LAN91C111		*/
 
 #define	CONFIG_DRIVER_SMC91111			/* Using SMC91c111	*/
+#define CONFIG_NET_MULTI
 #undef	CONFIG_SMC91111_EXT_PHY			/* Internal PHY		*/
 #define	CONFIG_SMC91111_BASE	(CONFIG_SYS_NIOS_CPU_LAN0_BASE + CONFIG_SYS_NIOS_CPU_LAN0_OFFS)
 
include/configs/DK1C20.h +1 -0
index 45ff2f7..36e7aa0 100644
@@ -218,6 +218,7 @@
 #if	(CONFIG_SYS_NIOS_CPU_LAN0_TYPE == 0)		/* LAN91C111		*/
 
 #define	CONFIG_DRIVER_SMC91111			/* Using SMC91c111	*/
+#define CONFIG_NET_MULTI
 #undef	CONFIG_SMC91111_EXT_PHY			/* Internal PHY		*/
 #define	CONFIG_SMC91111_BASE	(CONFIG_SYS_NIOS_CPU_LAN0_BASE + CONFIG_SYS_NIOS_CPU_LAN0_OFFS)
 
include/configs/DK1S10.h +1 -0
index ae567a3..6f74b20 100644
@@ -235,6 +235,7 @@
 #if	(CONFIG_SYS_NIOS_CPU_LAN0_TYPE == 0)		/* LAN91C111		*/
 
 #define	CONFIG_DRIVER_SMC91111			/* Using SMC91c111	*/
+#define CONFIG_NET_MULTI
 #undef	CONFIG_SMC91111_EXT_PHY			/* Internal PHY		*/
 #define	CONFIG_SMC91111_BASE	(CONFIG_SYS_NIOS_CPU_LAN0_BASE + CONFIG_SYS_NIOS_CPU_LAN0_OFFS)
 
include/configs/EP1C20.h +1 -0
index 8941e4d..fc6cf20 100644
@@ -151,6 +151,7 @@
  * cache bypass so there's no need to monkey with inx/outx macros.
  *----------------------------------------------------------------------*/
 #define CONFIG_SMC91111_BASE	0x82110300	/* Base addr (bypass)	*/
+#define CONFIG_NET_MULTI
 #define CONFIG_DRIVER_SMC91111			/* Using SMC91c111	*/
 #undef	CONFIG_SMC91111_EXT_PHY			/* Internal PHY		*/
 #define CONFIG_SMC_USE_32_BIT			/* 32-bit interface	*/
include/configs/EP1S10.h +1 -0
index 53bd0d8..21176b1 100644
@@ -145,6 +145,7 @@
  * cache bypass so there's no need to monkey with inx/outx macros.
  *----------------------------------------------------------------------*/
 #define CONFIG_SMC91111_BASE	0x82110300	/* Base addr (bypass)	*/
+#define CONFIG_NET_MULTI
 #define CONFIG_DRIVER_SMC91111			/* Using SMC91c111	*/
 #undef	CONFIG_SMC91111_EXT_PHY			/* Internal PHY		*/
 #define CONFIG_SMC_USE_32_BIT			/* 32-bit interface	*/
include/configs/EP1S40.h +1 -0
index 9e9a8a4..cbf150a 100644
@@ -145,6 +145,7 @@
  * cache bypass so there's no need to monkey with inx/outx macros.
  *----------------------------------------------------------------------*/
 #define CONFIG_SMC91111_BASE	0x82110300	/* Base addr (bypass)	*/
+#define CONFIG_NET_MULTI
 #define CONFIG_DRIVER_SMC91111			/* Using SMC91c111	*/
 #undef	CONFIG_SMC91111_EXT_PHY			/* Internal PHY		*/
 #define CONFIG_SMC_USE_32_BIT			/* 32-bit interface	*/
include/configs/MigoR.h +1 -0
index 3853574..3324a8c 100644
@@ -51,6 +51,7 @@
 
 /* SMC9111 */
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE    (0xB0000000)
 
 /* MEMORY */
include/configs/PK1C20.h +1 -0
index 522349f..75843a7 100644
@@ -151,6 +151,7 @@
  * cache bypass so there's no need to monkey with inx/outx macros.
  *----------------------------------------------------------------------*/
 #define CONFIG_SMC91111_BASE	0x82110300	/* Base addr (bypass)	*/
+#define CONFIG_NET_MULTI
 #define CONFIG_DRIVER_SMC91111			/* Using SMC91c111	*/
 #undef	CONFIG_SMC91111_EXT_PHY			/* Internal PHY		*/
 #define CONFIG_SMC_USE_32_BIT			/* 32-bit interface	*/
include/configs/bf533-ezkit.h +1 -0
index f896cb0..532bc77 100644
@@ -66,6 +66,7 @@
  */
 #define ADI_CMDS_NETWORK	1
 #define CONFIG_DRIVER_SMC91111	1
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE	0x20310300
 #define SMC91111_EEPROM_INIT() \
 	do { \
include/configs/bf533-stamp.h +1 -0
index 4be2a5c..ac2093c 100644
@@ -61,6 +61,7 @@
  */
 #define ADI_CMDS_NETWORK	1
 #define CONFIG_DRIVER_SMC91111	1
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE	0x20300300
 #define SMC91111_EEPROM_INIT() \
 	do { \
include/configs/bf538f-ezkit.h +1 -0
index 535687f..309c8b8 100644
@@ -61,6 +61,7 @@
  */
 #define ADI_CMDS_NETWORK	1
 #define CONFIG_DRIVER_SMC91111	1
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE	0x20310300
 #define CONFIG_HOSTNAME		bf538f-ezkit
 /* Uncomment next line to use fixed MAC address */
include/configs/bf561-ezkit.h +1 -0
index 4779a97..9b40d02 100644
@@ -61,6 +61,7 @@
  */
 #define ADI_CMDS_NETWORK	1
 #define CONFIG_DRIVER_SMC91111	1
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE	0x2C010300
 #define CONFIG_SMC_USE_32_BIT	1
 #define CONFIG_HOSTNAME		bf561-ezkit
include/configs/blackstamp.h +1 -0
index 887f3fb..789e922 100644
@@ -31,6 +31,7 @@
  * Board settings
  */
 #define CONFIG_DRIVER_SMC91111	1
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE	0x20300300
 
 /* FLASH/ETHERNET uses the same address range
include/configs/cerf250.h +1 -0
index b924758..6e00679 100644
@@ -54,6 +54,7 @@
  * Hardware drivers
  */
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE 0x04000300
 #define CONFIG_SMC_USE_32_BIT
 
include/configs/cm-bf533.h +1 -0
index ea548e9..3c670e0 100644
@@ -61,6 +61,7 @@
  */
 #define ADI_CMDS_NETWORK	1
 #define CONFIG_DRIVER_SMC91111	1
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE	0x20200300
 #define CONFIG_HOSTNAME		cm-bf533
 /* Uncomment next line to use fixed MAC address */
include/configs/cm-bf561.h +1 -0
index 59dc8d2..8ea7de5 100644
@@ -62,6 +62,7 @@
 #define ADI_CMDS_NETWORK	1
 /* The next 2 lines are for use with DEV-BF5xx */
 #define CONFIG_DRIVER_SMC91111	1
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE	0x28000300
 /* The next 3 lines are for use with EXT-BF5xx-USB-ETH2 */
 /* #define CONFIG_DRIVER_SMC911X 1 */
include/configs/cradle.h +1 -0
index b150c22..11db360 100644
@@ -50,6 +50,7 @@
  * Hardware drivers
  */
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE 0x10000300
 #define CONFIG_SMC91111_EXT_PHY
 #define CONFIG_SMC_USE_32_BIT
include/configs/delta.h +1 -0
index 95e04f9..3c69a4d 100644
@@ -54,6 +54,7 @@
 #undef TURN_ON_ETHERNET
 #ifdef TURN_ON_ETHERNET
 # define CONFIG_DRIVER_SMC91111 1
+# define CONFIG_NET_MULTI
 # define CONFIG_SMC91111_BASE   0x14000300
 # define CONFIG_SMC91111_EXT_PHY
 # define CONFIG_SMC_USE_32_BIT
include/configs/dnp1110.h +1 -0
index b6cfc67..a6af22d 100644
@@ -55,6 +55,7 @@
  * Hardware drivers
  */
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE 0x20000300
 
 
include/configs/gr_cpci_ax2000.h +1 -0
index bbe635b..79043b9 100644
@@ -293,6 +293,7 @@
  * Ethernet configuration uses on board SMC91C111
  */
 #define CONFIG_DRIVER_SMC91111          1
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE		0x20000300	/* chip select 3         */
 #define CONFIG_SMC_USE_32_BIT		1	/* 32 bit bus  */
 #undef  CONFIG_SMC_91111_EXT_PHY	/* we use internal phy   */
include/configs/gr_ep2s60.h +1 -0
index 7b0a08f..aa5edc8 100644
@@ -268,6 +268,7 @@
 
 /* USE SMC91C111 MAC */
 #define CONFIG_DRIVER_SMC91111          1
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE		0x20000300	/* chip select 3         */
 #define CONFIG_SMC_USE_32_BIT		1	/* 32 bit bus  */
 #undef  CONFIG_SMC_91111_EXT_PHY	/* we use internal phy   */
include/configs/innokom.h +1 -0
index ed03ad3..307a6d8 100644
@@ -158,6 +158,7 @@
  * SMSC91C111 Network Card
  */
 #define CONFIG_DRIVER_SMC91111		1
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE		0x14000000 /* chip select 5         */
 #undef  CONFIG_SMC_USE_32_BIT		           /* 16 bit bus access     */
 #undef  CONFIG_SMC_91111_EXT_PHY		   /* we use internal phy   */
include/configs/integratorcp.h +1 -0
index e38d569..70bf5de 100644
@@ -54,6 +54,7 @@
  * Hardware drivers
  */
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC_USE_32_BIT
 #define CONFIG_SMC91111_BASE    0xC8000000
 #undef CONFIG_SMC91111_EXT_PHY
include/configs/logodl.h +1 -0
index 5b903f0..6407757 100644
@@ -134,6 +134,7 @@
  */
 #if 0
 #define CONFIG_DRIVER_SMC91111		1
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE		0x10000000 /* chip select 4         */
 #undef  CONFIG_SMC_USE_32_BIT		           /* 16 bit bus access     */
 #undef  CONFIG_SMC_91111_EXT_PHY		   /* we use internal phy   */
include/configs/lpd7a400-10.h +1 -0
index 6145c37..28b6976 100644
@@ -73,6 +73,7 @@
  * (LAN chip) tied to Vcc, so we just care about the chip select
  */
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE	(0x70000000)
 #undef CONFIG_SMC_USE_32_BIT
 #define CONFIG_SMC_USE_IOFUNCS
include/configs/lpd7a404-10.h +1 -0
index ce23f3d..33069f6 100644
@@ -73,6 +73,7 @@
  * (LAN chip) tied to Vcc, so we just care about the chip select
  */
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE	(0x70000000)
 #undef CONFIG_SMC_USE_32_BIT
 #define CONFIG_SMC_USE_IOFUNCS
include/configs/ms7722se.h +1 -0
index 6755af3..f949cb1 100644
@@ -49,6 +49,7 @@
 
 /* SMC9111 */
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE    (0xB8000000)
 
 /* MEMORY */
include/configs/netstar.h +1 -0
index f0b4207..df0c5b1 100644
@@ -94,6 +94,7 @@
 #define CONFIG_SYS_NS16550_COM1		OMAP1510_UART1_BASE	/* uart1 */
 
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE		0x04000300
 
 #define CONFIG_SYS_FLASH_BASE		PHYS_FLASH_1
include/configs/nhk8815.h +1 -0
index 8a83d92..3309fb7 100644
@@ -133,6 +133,7 @@
 #define __mem_isa(a)		((a) + PCI_MEMORY_VADDR)
 
 #define CONFIG_DRIVER_SMC91111	/* Using SMC91c111*/
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE	0x34000300
 #undef  CONFIG_SMC91111_EXT_PHY	/* Internal PHY */
 #define CONFIG_SMC_USE_32_BIT
include/configs/pxa255_idp.h +1 -0
index 2cae8ca..1087dd7 100644
@@ -88,6 +88,7 @@
  * Hardware drivers
  */
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE	(PXA_CS5_PHYS + IDP_CS5_ETH_OFFSET + 0x300)
 #define CONFIG_SMC_USE_32_BIT	1
 /* #define CONFIG_SMC_USE_IOFUNCS */
include/configs/versatile.h +1 -0
index a9b70cc..09c38e6 100644
@@ -83,6 +83,7 @@
  */
 
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC_USE_32_BIT
 #define CONFIG_SMC91111_BASE	0x10010000
 #undef CONFIG_SMC91111_EXT_PHY
include/configs/voiceblue.h +1 -0
index c9c3132..fd2f1c9 100644
@@ -95,6 +95,7 @@
  * Hardware drivers
  */
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE	0x08000300
 
 #define CONFIG_HARD_I2C
include/configs/xaeniax.h +1 -0
index 83883f6..22ea650 100644
@@ -197,6 +197,7 @@
  * SMSC91C111 Network Card
  */
 #define CONFIG_DRIVER_SMC91111		1
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE		0x10000300  /* chip select 3         */
 #define CONFIG_SMC_USE_32_BIT		1          /* 32 bit bus  */
 #undef  CONFIG_SMC_91111_EXT_PHY		   /* we use internal phy   */
include/configs/xm250.h +1 -0
index f18701a..36e6c82 100644
@@ -51,6 +51,7 @@
  * Hardware drivers
  */
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE		0x04000300
 #undef	CONFIG_SMC91111_EXT_PHY
 #define CONFIG_SMC_USE_32_BIT
include/configs/xsengine.h +1 -0
index 2697cca..330f6c3 100644
@@ -95,6 +95,7 @@
 
 /* Hardware drivers */
 #define CONFIG_DRIVER_SMC91111
+#define CONFIG_NET_MULTI
 #define CONFIG_SMC91111_BASE		0x04000300
 #define CONFIG_SMC_USE_32_BIT		1
 
include/configs/zylonite.h +1 -0
index 86b6ea1..40478bf 100644
@@ -63,6 +63,7 @@
 #undef TURN_ON_ETHERNET
 #ifdef TURN_ON_ETHERNET
 # define CONFIG_DRIVER_SMC91111 1
+# define CONFIG_NET_MULTI
 # define CONFIG_SMC91111_BASE   0x14000300
 # define CONFIG_SMC91111_EXT_PHY
 # define CONFIG_SMC_USE_32_BIT
include/netdev.h +1 -0
index 3e66586..834d3c0 100644
@@ -73,6 +73,7 @@ int rtl8169_initialize(bd_t *bis);
 int scc_initialize(bd_t *bis);
 int skge_initialize(bd_t *bis);
 int smc911x_initialize(u8 dev_num, int base_addr);
+int smc91111_initialize(int id, void *regs, int use_32bit);
 int tsi108_eth_initialize(bd_t *bis);
 int uec_initialize(int index);
 int uec_standard_init(bd_t *bis);
Signature · 1 line
1.6.4
#3 lore raw

PATCH 3/3 smc91111: switch to MULTI_NET api

Jean-Christophe,

Quoted 1 line · Jean-Christophe PLAGNIOL-VILLARD

I already posted a patch that does this and asked for help testing. It is available in the net/next repo. If you find it to be inadequate, please provide patches to make it work.

regards,
Ben

#4 lore raw

PATCH 3/3 smc91111: switch to MULTI_NET api

Quoted 6 lines · Ben Warren

Jean-Christophe,

Quoted 1 line · Jean-Christophe PLAGNIOL-VILLARD

I already posted a patch that does this and asked for help testing. It is available in the net/next repo. If you find it to be inadequate, please provide patches to make it work.

I've also update the mac support and allow multi chip support does you pacth do the same?

as I do need multi chip support

and the one I send work fine

Best Regards,
J.

#5 lore raw

PATCH 3/3 smc91111: switch to MULTI_NET api

Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines · Ben Warren

Jean-Christophe,
Jean-Christophe PLAGNIOL-VILLARD wrote:

Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

I already posted a patch that does this and asked for help testing. It is available in the net/next repo. If you find it to be inadequate, please provide patches to make it work.

I've also update the mac support and allow multi chip support does you pacth do the same?

Of course it does. I don't know why you'd just ignore it and implement your own.

Ben

#6 lore raw

PATCH 3/3 smc91111: switch to MULTI_NET api

In reply to Jean-Christophe PLAGNIOL-VILLARD

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 1 line · In message <[email protected]> you wrote:

...

drivers/net/smc91111.c static const char version[] = · line 139

Quoted 3 lines

#ifdef CONFIG_SMC_USE_32_BIT

drivers/net/smc91111.c +1 -1
-#define USE_32_BIT  1
+#define is_use_32bit(x) (x->use_32bit)

Does switching from a compile time check to a run time check not cause an avoidable growth of the memory footprint?

How much bigger is the new code?

Quoted 3 lines
drivers/net/smc91111.c +1 -1
-#undef USE_32_BIT
+#define is_use_32bit(x) (0)
 #endif

...

Quoted 8 lines
drivers/net/smc91111.c +2 -2
-static inline word SMC_inw(dword offset)
+static inline word SMC_io_inw(struct smc91111_device *smc, dword offset)
 {
 	word v;
-	v = *((volatile word*)(SMC_BASE_ADDRESS+offset));
+	v = *((volatile word*)(smc->regs+offset));
 	barrier(); *(volatile u32*)(0xc0000000);
 	return v;

drivers/net/smc91111.c int get_rom_mac(uchar *v_rom_mac); · line 227

Quoted 10 lines
drivers/net/smc91111.c +3 -2
 }
 
-static inline void SMC_outw(word value, dword offset)
+static inline void SMC_io_outw(struct smc91111_device *smc, word value,
+			       dword offset)
 {
-	*((volatile word*)(SMC_BASE_ADDRESS+offset)) = value;
+	*((volatile word*)(smc->regs+offset)) = value;
 	barrier(); *(volatile u32*)(0xc0000000);
 }

Please use proper I/O accessor functions here.

drivers/net/smc91111.c int get_rom_mac(uchar *v_rom_mac); · line 231

Quoted 4 lines
drivers/net/smc91111.c +1 -1
-static inline byte SMC_inb(dword offset)
+static inline byte SMC_io_inb(struct smc91111_device *smc, dword offset)
 {
 	word  _w;

...and here.

Quoted 10 lines
drivers/net/smc91111.c +2 -1
@@ -264,18 +234,22 @@ static inline byte SMC_inb(dword offset)
 	return (offset & 1) ? (byte)(_w >> 8) : (byte)(_w);
 }
 
-static inline void SMC_outb(byte value, dword offset)
+static inline void SMC_io_outb(struct smc91111_device *smc, byte value,
+			       dword offset)
 {
 	word  _w;
 

drivers/net/smc91111.c static inline byte SMC_inb(dword offset) · line 249

Quoted 10 lines
drivers/net/smc91111.c +4 -2
 	_w = SMC_inw(offset & ~((dword)1));
 	if (offset & 1)
-			*((volatile word*)(SMC_BASE_ADDRESS+(offset & ~((dword)1)))) = (value<<8) | (_w & 0x00ff);
+			*((volatile word*)(smc->regs+(offset & ~((dword)1)))) =
+				(value<<8) | (_w & 0x00ff);
 	else
-			*((volatile word*)(SMC_BASE_ADDRESS+offset)) = value | (_w & 0xff00);
+			*((volatile word*)(smc->regs+offset)) =
+				value | (_w & 0xff00);
 }

...and here.

drivers/net/smc91111.c static inline byte SMC_inb(dword offset) · line 254

Quoted 5 lines
drivers/net/smc91111.c +2 -1
-static inline void SMC_insw(dword offset, volatile uchar* buf, dword len)
+static inline void SMC_io_insw(struct smc91111_device *smc, dword offset,
+			       volatile uchar* buf, dword len)
 {
 	volatile word *p = (volatile word *)buf;

...and here.

drivers/net/smc91111.c static inline void SMC_insw(dword offset, volatile uchar* buf, dword len) · line 266

Quoted 9 lines
drivers/net/smc91111.c +2 -1
@@ -286,7 +260,8 @@ static inline void SMC_insw(dword offset, volatile uchar* buf, dword len)
 	}
 }
 
-static inline void SMC_outsw(dword offset, uchar* buf, dword len)
+static inline void SMC_io_outsw(struct smc91111_device *smc, dword offset,
+				uchar* buf, dword len)
 {
 	volatile word *p = (volatile word *)buf;

...and here.

drivers/net/smc91111.c static int smc_rcv() · line 981

Quoted 5 lines
drivers/net/smc91111.c +1 -1
-static int smc_close()
+static void smc_halt(struct eth_device *netdev)

{

drivers/net/smc91111.c +1 -0
+	struct smc91111_device *smc = to_smc91111(netdev);
 	PRINTK2("%s: smc_close\n", SMC_DEV_NAME);

You should also adapt the debug messages to the changed function names.

drivers/net/smc91111.c int get_rom_mac (uchar *v_rom_mac) · line 1575

Quoted 5 lines
drivers/net/smc91111.c +5 -0
+#ifdef CONFIG_SMC_USE_32_BIT
+#define USE_32BIT 1
+#else
+#define USE_32BIT 0
+#endif

Above you get rid of the USE_32BIT stuff; here you re-introduce it. Why?

Quoted 16 lines
drivers/net/smc91111.h +4 -0
index 967addd..b2ed6a5 100644
@@ -72,6 +72,10 @@ typedef unsigned long int		dword;
 
 /* Because of bank switching, the LAN91xxx uses only 16 I/O ports */
 
+#ifndef SMC_BASE_ADDRESS
+#define SMC_BASE_ADDRESS smc->regs
+#endif
+
 #define	SMC_IO_EXTENT	16
 
 #ifdef CONFIG_PXA250

drivers/net/smc91111.h typedef unsigned long int dword; · line 309

Quoted 7 lines
drivers/net/smc91111.h +0 -2
@@ -301,8 +305,6 @@ typedef unsigned long int		dword;
 
 #endif  /* CONFIG_SMC_USE_IOFUNCS */
 
-#if defined(CONFIG_SMC_USE_32_BIT)
-
 #ifdef CONFIG_XSENGINE
 #define	SMC_inl(r)	(*((volatile dword *)(SMC_BASE_ADDRESS+(r<<1))))

This should be fixed to use I/O accessors, too.

Quoted 28 lines
drivers/net/smc91111.h +0 -0
 include/configs/ADNPESC1.h       |    1 +
 include/configs/DK1C20.h         |    1 +
 include/configs/DK1S10.h         |    1 +
 include/configs/EP1C20.h         |    1 +
 include/configs/EP1S10.h         |    1 +
 include/configs/EP1S40.h         |    1 +
 include/configs/MigoR.h          |    1 +
 include/configs/PK1C20.h         |    1 +
 include/configs/bf533-ezkit.h    |    1 +
 include/configs/bf533-stamp.h    |    1 +
 include/configs/bf538f-ezkit.h   |    1 +
 include/configs/bf561-ezkit.h    |    1 +
 include/configs/blackstamp.h     |    1 +
 include/configs/cerf250.h        |    1 +
 include/configs/cm-bf533.h       |    1 +
 include/configs/cm-bf561.h       |    1 +
 include/configs/cradle.h         |    1 +
 include/configs/delta.h          |    1 +
 include/configs/dnp1110.h        |    1 +
 include/configs/gr_cpci_ax2000.h |    1 +
 include/configs/gr_ep2s60.h      |    1 +
 include/configs/innokom.h        |    1 +
 include/configs/integratorcp.h   |    1 +
 include/configs/logodl.h         |    1 +
 include/configs/lpd7a400-10.h    |    1 +
 include/configs/lpd7a404-10.h    |    1 +
 include/configs/ms7722se.h       |    1 +
 include/configs/netstar.h        |    1 +
Quoted 8 lines
 include/configs/nhk8815.h        |    1 +
 include/configs/pxa255_idp.h     |    1 +
 include/configs/versatile.h      |    1 +
 include/configs/voiceblue.h      |    1 +
 include/configs/xaeniax.h        |    1 +
 include/configs/xm250.h          |    1 +
 include/configs/xsengine.h       |    1 +
 include/configs/zylonite.h       |    1 +

This is a pretty long list of boards which is affected. How many of these have actuaaly been tested with this patch, and which ones, and to what extent?

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
Lack of skill dictates economy of style.                - Joey Ramone
#7 lore raw

PATCH 3/3 smc91111: switch to MULTI_NET api

Quoted 5 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 1 line · In message <[email protected]> you wrote:

...

Quoted 8 lines

drivers/net/smc91111.c static const char version[] = · line 139

Quoted 3 lines

#ifdef CONFIG_SMC_USE_32_BIT

drivers/net/smc91111.c +1 -1
-#define USE_32_BIT  1
+#define is_use_32bit(x) (x->use_32bit)

Does switching from a compile time check to a run time check not cause an avoidable growth of the memory footprint?

How much bigger is the new code?

none for the non 32 bit support it will only impact you if you do enable the 32bits support but the impact depend on the arch you use I've seen different impact on arm and sh
but on the board I've test less than 300 bytes for dual support

with dual support
... configured to boot from Nand Flash
Configuring for nhk8815 board...
text data bss dec hex filename
189330 8132 24984 222446 364ee u-boot

with 32bit only
... configured to boot from Nand Flash
Configuring for nhk8815 board...
text data bss dec hex filename
189082 8132 24984 222198 363f6 u-boot

with non 32bit
... configured to boot from Nand Flash
Configuring for nhk8815 board...
text data bss dec hex filename
189050 8132 24984 222166 363d6 u-boot

Quoted 17 lines
Quoted 4 lines
drivers/net/smc91111.c +1 -1
-#undef USE_32_BIT
+#define is_use_32bit(x) (0)
 #endif

...

Quoted 10 lines
drivers/net/smc91111.c +2 -2
-static inline word SMC_inw(dword offset)
+static inline word SMC_io_inw(struct smc91111_device *smc, dword offset)
 {
 	word v;
-	v = *((volatile word*)(SMC_BASE_ADDRESS+offset));
+	v = *((volatile word*)(smc->regs+offset));
 	barrier(); *(volatile u32*)(0xc0000000);
 	return v;
 }
Quoted 10 lines

drivers/net/smc91111.c int get_rom_mac(uchar *v_rom_mac); · line 227

Quoted 8 lines
drivers/net/smc91111.c +3 -2
-static inline void SMC_outw(word value, dword offset)
+static inline void SMC_io_outw(struct smc91111_device *smc, word value,
+			       dword offset)
 {
-	*((volatile word*)(SMC_BASE_ADDRESS+offset)) = value;
+	*((volatile word*)(smc->regs+offset)) = value;
 	barrier(); *(volatile u32*)(0xc0000000);
 }

Please use proper I/O accessor functions here.

this will be for an other patch I do not want to mix Net multi api update and I/O cleanup

Quoted 10 lines

drivers/net/smc91111.c static int smc_rcv() · line 981

Quoted 6 lines
drivers/net/smc91111.c +2 -1
-static int smc_close()
+static void smc_halt(struct eth_device *netdev)
 {
+	struct smc91111_device *smc = to_smc91111(netdev);
 	PRINTK2("%s: smc_close\n", SMC_DEV_NAME);

You should also adapt the debug messages to the changed function names.

Quoted 8 lines

drivers/net/smc91111.c int get_rom_mac (uchar *v_rom_mac) · line 1575

Quoted 5 lines
drivers/net/smc91111.c +5 -0
+#ifdef CONFIG_SMC_USE_32_BIT
+#define USE_32BIT 1
+#else
+#define USE_32BIT 0
+#endif

Above you get rid of the USE_32BIT stuff; here you re-introduce it. Why?

yes it's different here it's to declare that you want to activate the 32bit for the default driver init

Quoted 37 lines
Quoted 28 lines
 include/configs/ADNPESC1.h       |    1 +
 include/configs/DK1C20.h         |    1 +
 include/configs/DK1S10.h         |    1 +
 include/configs/EP1C20.h         |    1 +
 include/configs/EP1S10.h         |    1 +
 include/configs/EP1S40.h         |    1 +
 include/configs/MigoR.h          |    1 +
 include/configs/PK1C20.h         |    1 +
 include/configs/bf533-ezkit.h    |    1 +
 include/configs/bf533-stamp.h    |    1 +
 include/configs/bf538f-ezkit.h   |    1 +
 include/configs/bf561-ezkit.h    |    1 +
 include/configs/blackstamp.h     |    1 +
 include/configs/cerf250.h        |    1 +
 include/configs/cm-bf533.h       |    1 +
 include/configs/cm-bf561.h       |    1 +
 include/configs/cradle.h         |    1 +
 include/configs/delta.h          |    1 +
 include/configs/dnp1110.h        |    1 +
 include/configs/gr_cpci_ax2000.h |    1 +
 include/configs/gr_ep2s60.h      |    1 +
 include/configs/innokom.h        |    1 +
 include/configs/integratorcp.h   |    1 +
 include/configs/logodl.h         |    1 +
 include/configs/lpd7a400-10.h    |    1 +
 include/configs/lpd7a404-10.h    |    1 +
 include/configs/ms7722se.h       |    1 +
 include/configs/netstar.h        |    1 +
Quoted 8 lines
 include/configs/nhk8815.h        |    1 +
 include/configs/pxa255_idp.h     |    1 +
 include/configs/versatile.h      |    1 +
 include/configs/voiceblue.h      |    1 +
 include/configs/xaeniax.h        |    1 +
 include/configs/xm250.h          |    1 +
 include/configs/xsengine.h       |    1 +
 include/configs/zylonite.h       |    1 +
Quoted 3 lines

This is a pretty long list of boards which is affected. How many of these have actuaaly been tested with this patch, and which ones, and to what extent?

none will be impact as the share the same init and I've not modify any config just active the multi support
and the code is tested on custom boards (4 differents) + nhk8815

and compile on arm & sh

Best Regards,
J.

#8 lore raw

PATCH 3/3 smc91111: switch to MULTI_NET api

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 11 lines · In message <[email protected]> you wrote:
Quoted 9 lines

drivers/net/smc91111.c int get_rom_mac (uchar *v_rom_mac) · line 1575

Quoted 6 lines
drivers/net/smc91111.c +5 -0
+#ifdef CONFIG_SMC_USE_32_BIT
+#define USE_32BIT 1
+#else
+#define USE_32BIT 0
+#endif

Above you get rid of the USE_32BIT stuff; here you re-introduce it. Why?

yes it's different here it's to declare that you want to activate the 32bit for the default driver init

Why not use the same method as above?

Quoted 5 lines
Quoted 3 lines

This is a pretty long list of boards which is affected. How many of these have actuaaly been tested with this patch, and which ones, and to what extent?

none will be impact as the share the same init and I've not modify any config just active the multi support

Come on. You make heavy changes to the driver ans claim that none of the boards would be affected? This is... very na?ve at best.

Quoted 1 line

and the code is tested on custom boards (4 differents) + nhk8815

I see. You should ask board maintainers for feedback, then.

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
Let the programmers be many and the managers few -- then all will  be
productive.               -- Geoffrey James, "The Tao of Programming"
#9 lore raw

PATCH 2/3 net: add getenv/setenv enetaddr function to use ethernet device num

In reply to Jean-Christophe PLAGNIOL-VILLARD

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 5 lines · In message <[email protected]> you wrote:
---
 include/net.h |    2 ++
 net/eth.c     |   28 +++++++++++++++++++++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)

NAK.

First, there are formal issues:

- The subject line is way too long.

- There is no commit message and no description what this patch is supposed to do or to fix. Why should we add it?

include/net.h extern void eth_set_enetaddr(int num, char* a); /* Set new MAC address */ · line 128

Quoted 9 lines

index 2a8a12d..dc4ae41 100644

include/net.h +2 -0
@@ -124,6 +124,8 @@ extern void eth_set_enetaddr(int num, char* a);	/* Set new MAC address */
 extern void eth_parse_enetaddr(const char *addr, uchar *enetaddr);
 extern int eth_getenv_enetaddr(char *name, uchar *enetaddr);
 extern int eth_setenv_enetaddr(char *name, const uchar *enetaddr);
+extern int eth_getenv_num_enetaddr(int num, uchar *enetaddr);
+extern int eth_setenv_num_enetaddr(int num, const uchar *enetaddr);

What are these functions god for? Are they by any chance duplicationg existing code, got example eth_getenv_enetaddr_by_index() ?

net/eth.c line 31

Quoted 12 lines
include/net.h +0 -0
 extern int eth_init(bd_t *bis);			/* Initialize the device */
 extern int eth_send(volatile void *packet, int length);	   /* Send a packet */
net/eth.c +2 -0
index 2316a22..9bdf961 100644
@@ -27,6 +27,12 @@
 #include <miidev.h>
 
 #ifdef CONFIG_CMD_NET
+
+static void get_enetvar(int num, char *enetvar)

Should this not be "uchar *", to stay consistent with the other code?

Quoted 10 lines
net/eth.c +4 -0
+{
+	sprintf(enetvar, num ? "eth%daddr" : "ethaddr", num);
+}
+
 void eth_parse_enetaddr(const char *addr, uchar *enetaddr)
 {
 	char *end;
@@ -53,6 +59,24 @@ int eth_setenv_enetaddr(char *name, const uchar *enetaddr)
 
 	return setenv(name, buf);

net/eth.c int eth_setenv_enetaddr(char *name, const uchar *enetaddr) · line 70

Quoted 10 lines
net/eth.c +9 -0
 }
+
+int eth_getenv_num_enetaddr(int num, uchar *enetaddr)
+{
+	char enetvar[32];
+
+	get_enetvar(num, enetvar);
+
+	return eth_getenv_enetaddr(enetvar, enetaddr);
+}

Looks very much like eth_getenv_enetaddr_by_index() to me. What do you need this for?

Please elucidate...

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
"The algorithm to do that is extremely nasty. You might want  to  mug
someone with it."                   - M. Devine, Computer Science 340
#10 lore raw

PATCH 2/3 net: add getenv/setenv enetaddr function to use ethernet device num

Quoted 9 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 5 lines · In message <[email protected]> you wrote:
---
 include/net.h |    2 ++
 net/eth.c     |   28 +++++++++++++++++++++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)
Quoted 5 lines

NAK.

First, there are formal issues:

- The subject line is way too long.

why it's only 67 chars

Quoted 3 lines

- There is no commit message and no description what this patch is supposed to do or to fix. Why should we add it?

just to stop to duplicate this in every driver

Quoted 13 lines

include/net.h extern void eth_set_enetaddr(int num, char* a); /* Set new MAC address */ · line 128

Quoted 10 lines

index 2a8a12d..dc4ae41 100644

include/net.h +2 -0
@@ -124,6 +124,8 @@ extern void eth_set_enetaddr(int num, char* a);	/* Set new MAC address */
 extern void eth_parse_enetaddr(const char *addr, uchar *enetaddr);
 extern int eth_getenv_enetaddr(char *name, uchar *enetaddr);
 extern int eth_setenv_enetaddr(char *name, const uchar *enetaddr);
+extern int eth_getenv_num_enetaddr(int num, uchar *enetaddr);
+extern int eth_setenv_num_enetaddr(int num, const uchar *enetaddr);

What are these functions god for? Are they by any chance duplicationg existing code, got example eth_getenv_enetaddr_by_index() ?

the get yes but not there is no set

Best Regards,
J.

#11 lore raw

PATCH 2/3 net: add getenv/setenv enetaddr function to use ethernet device num

Dear Jean-Christophe PLAGNIOL-VILLARD,

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

- There is no commit message and no description what this patch is supposed to do or to fix. Why should we add it?

just to stop to duplicate this in every driver

I would expect then that you remove such duplicated code from "every driver", but I do not see any such removal?

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines

index 2a8a12d..dc4ae41 100644

include/net.h +0 -0
@@ -124,6 +124,8 @@ extern void eth_set_enetaddr(int num, char* a);	/* Set new MAC address */
Quoted 8 lines

include/net.h extern void eth_set_enetaddr(int num, char* a); /* Set new MAC address */ · line 128

Quoted 5 lines
include/net.h +2 -0
 extern void eth_parse_enetaddr(const char *addr, uchar *enetaddr);
 extern int eth_getenv_enetaddr(char *name, uchar *enetaddr);
 extern int eth_setenv_enetaddr(char *name, const uchar *enetaddr);
+extern int eth_getenv_num_enetaddr(int num, uchar *enetaddr);
+extern int eth_setenv_num_enetaddr(int num, const uchar *enetaddr);

What are these functions god for? Are they by any chance duplicationg existing code, got example eth_getenv_enetaddr_by_index() ?

Quoted 1 line

the get yes but not there is no set

Makes no sense to me. Above you claim you want to avoid code duplication, and here you duplicate existing functions? Please use the existing code instead, and add only what might be missing.

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
"An organization dries up if you don't challenge it with growth."
       - Mark Shepherd, former President and CEO of Texas Instruments
#12 lore raw

PATCH 1/3 net/eth_device: keep index inside each device

In reply to Jean-Christophe PLAGNIOL-VILLARD

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 5 lines · In message <[email protected]> you wrote:
---
 include/net.h |    1 +
 net/eth.c     |   17 +++++------------
 2 files changed, 6 insertions(+), 12 deletions(-)

What exactly is the problem you are addressing with this patch?

Please provide a commit message that explains what is going on, and what is being changed or fixed.

Thanks.

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
When a program is being  tested,  it  is  too  late  to  make  design
changes.                  -- Geoffrey James, "The Tao of Programming"
#13 lore raw

PATCH 1/3 net/eth_device: keep index inside each device

Quoted 9 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 5 lines · In message <[email protected]> you wrote:
---
 include/net.h |    1 +
 net/eth.c     |   17 +++++------------
 2 files changed, 6 insertions(+), 12 deletions(-)
Quoted 4 lines

What exactly is the problem you are addressing with this patch?

Please provide a commit message that explains what is going on, and what is being changed or fixed.

simple it impossible to known what will be your device index in the driver specially when you have 2 or more drivers instance once or more so you can not update the mac addres in the env if you want to do it as we do on smc91111 as we can not known eth%daddr you are
which allow us the avoid to read the eeprom every time we want to use the eth

Best Regards,
J.

#14 lore raw

PATCH 1/3 net/eth_device: keep index inside each device

Quoted 14 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 12 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 6 lines · In message <[email protected]> you wrote:
---
 include/net.h |    1 +
 net/eth.c     |   17 +++++------------
 2 files changed, 6 insertions(+), 12 deletions(-)

What exactly is the problem you are addressing with this patch?

Quoted 10 lines
Quoted 3 lines

Please provide a commit message that explains what is going on, and what is being changed or fixed.

simple it impossible to known what will be your device index in the driver specially when you have 2 or more drivers instance once or more so you can not update the mac addres in the env if you want to do it as we do on smc91111 as we can not known eth%daddr you are
which allow us the avoid to read the eeprom every time we want to use the eth

While I'm not completely opposed to the idea of tracking indices, it's simply not true that you don't know the indices of the controllers on your board. They're all instantiated in board_eth_init(), so the first will be 0 and the second will be 1 etc. If you had a mix of devices and they were found by probing as in Linux, it would be different. Here in U-boot, ordering is deterministic and dictated by the developer.

BTW - this is hardly the first driver that can have multiple
instances. Others, such as TSEC, seem to be managing just fine.

regards,
Ben

#15 lore raw

PATCH 1/3 net/eth_device: keep index inside each device

Quoted 20 lines · Ben Warren
Quoted 11 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 10 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

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

---
include/net.h | 1 +
net/eth.c | 17 +++++------------

2 files changed, 6 insertions(+), 12 deletions(-)

What exactly is the problem you are addressing with this patch?

Quoted 8 lines
Quoted 2 lines

Please provide a commit message that explains what is going on, and what is being changed or fixed.

simple it impossible to known what will be your device index in the driver specially when you have 2 or more drivers instance once or more so you can not update the mac addres in the env if you want to do it as we do on smc91111 as we can not known eth%daddr you are
which allow us the avoid to read the eeprom every time we want to use the eth

Quoted 7 lines

While I'm not completely opposed to the idea of tracking indices, it's simply not true that you don't know the indices of the controllers on your board. They're all instantiated in board_eth_init(), so the first will be 0 and the second will be 1 etc. If you had a mix of devices and they were found by probing as in Linux, it would be different. Here in U-boot, ordering is deterministic and dictated by the developer.

but you can not known it in the driver specially if you have multi different MAC chip
2 SMC91111
+ 1 SOC MAC

and you will add it in the order of preferance to use for the board to let u-boot try to connect in the order of your preference

as example this order
SOC_M_0
SMC9111_0
SMC9111_1

so you can do this

board_eth_init() {
	call cpu_eth_init
	register smc91111_0
	register smc91111_1
}

in an other board I can prefer

board_eth_init() {
	call cpu_eth_init
	register smc91111_0
	register smc91111_1
}

so instead of duplicate the info and the code you just allow the driver to known is index

Quoted 3 lines

BTW - this is hardly the first driver that can have multiple
instances. Others, such as TSEC, seem to be managing just fine.

each drivers do his own way

this one is generic

Best Regards,
J.

#16 lore raw

PATCH 1/3 net/eth_device: keep index inside each device

Dear Jean-Christophe PLAGNIOL-VILLARD,

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

While I'm not completely opposed to the idea of tracking indices, it's simply not true that you don't know the indices of the controllers on your board. They're all instantiated in board_eth_init(), so the first will be 0 and the second will be 1 etc. If you had a mix of devices and they were found by probing as in Linux, it would be different. Here in U-boot, ordering is deterministic and dictated by the developer.

Quoted 7 lines

but you can not known it in the driver specially if you have multi different MAC chip
2 SMC91111
+ 1 SOC MAC

and you will add it in the order of preferance to use for the board to let u-boot try to connect in the order of your preference

Like Ben I don't really understand where your problem is. We have many boards with multiple Ethernet Interfaces; for example, we see boards with up to 4 x TSEC and up to 2 x EEPRO100 controllers. And there is never more than a single "active" device.

We don't need any such code there. Why would you need 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
Advice is seldom welcome; and those who want it the most always like
it the least.                         -- Philip Earl of Chesterfield
#17 lore raw

PATCH 1/3 net/eth_device: keep index inside each device

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 57 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 26 lines · Ben Warren
Quoted 14 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 12 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

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

---
include/net.h | 1 +
net/eth.c | 17 +++++------------

2 files changed, 6 insertions(+), 12 deletions(-)

What exactly is the problem you are addressing with this patch?

Quoted 10 lines
Quoted 3 lines

Please provide a commit message that explains what is going on, and what is being changed or fixed.

simple it impossible to known what will be your device index in the driver specially when you have 2 or more drivers instance once or more so you can not update the mac addres in the env if you want to do it as we do on smc91111 as we can not known eth%daddr you are
which allow us the avoid to read the eeprom every time we want to use the eth

Quoted 8 lines

While I'm not completely opposed to the idea of tracking indices, it's simply not true that you don't know the indices of the controllers on your board. They're all instantiated in board_eth_init(), so the first will be 0 and the second will be 1 etc. If you had a mix of devices and they were found by probing as in Linux, it would be different. Here in U-boot, ordering is deterministic and dictated by the developer.

but you can not known it in the driver specially if you have multi different MAC chip
2 SMC91111
+ 1 SOC MAC

and you will add it in the order of preferance to use for the board to let u-boot try to connect in the order of your preference

as example this order
SOC_M_0
SMC9111_0
SMC9111_1

so you can do this

board_eth_init() {
	call cpu_eth_init
	register smc91111_0
	register smc91111_1
}

in an other board I can prefer

Quoted 9 lines
board_eth_init() {
	call cpu_eth_init
	register smc91111_0
	register smc91111_1
}

so instead of duplicate the info and the code you just allow the driver to known is index

I find it convenient to get a driver handle via eth_get_dev_by_name() and then access its elements (MAC address etc.) through the handle. Not exactly the most efficient way, but it's certainly convenient. This is how I modified all the eeprom-accessing standalone apps with SMC911X and SMC91111 (which, BTW, your SMC91111 patch didn't fix) to work with CONFIG_NET_MULTI.

Quoted 6 lines
Quoted 3 lines

BTW - this is hardly the first driver that can have multiple
instances. Others, such as TSEC, seem to be managing just fine.

each drivers do his own way

Not a good direction to take if possible.

Quoted 5 lines

this one is generic

Best Regards,
J.

Ben

#18 lore raw

PATCH 1/3 net/eth_device: keep index inside each device

In reply to Jean-Christophe PLAGNIOL-VILLARD

Dear Jean-Christophe PLAGNIOL-VILLARD,

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

What exactly is the problem you are addressing with this patch?

Please provide a commit message that explains what is going on, and what is being changed or fixed.

simple it impossible to known what will be your device index in the driver specially when you have 2 or more drivers instance once or more

Sorry, but we don't have driver instances in U-Boot. Even if you have several Ethernet interfaces of the same type, there will be only a single device driver instance.

Quoted 3 lines

so you can not update the mac addres in the env if you want to do it as we do on smc91111 as we can not known eth%daddr you are
which allow us the avoid to read the eeprom every time we want to use the eth

At any time, there is (at most) a single active interface.

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
Time is an illusion perpetrated by the manufacturers of space.