Skip to contentSkip to conversation

lan91c96 driver MAC address detection

PATCH New Dave Peverley 3 participants 8 messages Apr 29, 2004 – Jun 6, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lan91c96 driver MAC address detection

Hi all,

This is a small patch for the lan91c96 ethernet driver that adds the
capability to automatically detect the MAC address stored in EPROM in the absence of a valid MAC address in the environment. It is modelled on the system used by the smc91111 driver as suggested by Marius Groeger (thanks!)

The patch itself was created against the CVS repository tag "U-Boot-1_1_0" using the command :
diff -purN u-boot u-boot-omap730p2 > u-boot-1.1.0-omap730p2.patch

All comments and feedback welcome.

Best Wishes,

Dave Peverley

---------------------------------------------------------------------------
Dave Peverley, Software Engineer, MPC Data Limited.
Phone : [+44] (0) 1225 868 228 Web : http://www.mpc-data.co.uk
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: u-boot-1.1.0-lan91c96-mac-detect.patch
Url: http://lists.denx.de/pipermail/u-boot/attachments/20040429/02301e27/attachment.txt

#1 lore raw

PATCH 1/1 lan91c96 driver MAC address detection

Quoted 8 lines · Dave Peverley

Hi all,

This is a small patch for the lan91c96 ethernet driver that adds the
capability to automatically detect the MAC address stored in EPROM in the absence of a valid MAC address in the environment. It is modelled on the system used by the smc91111 driver as suggested by Marius Groeger (thanks!)

Quoted 5 lines

The patch itself was created against the CVS repository tag "U-Boot-1_1_0" using the command :
diff -purN u-boot u-boot-omap730p2 > u-boot-1.1.0-omap730p2.patch

All comments and feedback welcome.

Cool! Thanks for that! I have a minor suggestion though. Can we squelch the warning for the "setenv ethaddr" case? Like so:

lan91c96.c renamed from lan91c96.c.orig +3 -4
@@ -886,9 +886,7 @@
 	uchar v_rom_mac[6];
 
 	env_size = getenv_r ("ethaddr", s_env_mac, sizeof (s_env_mac));
-	if (env_size != sizeof(es)) {	/* Ignore if env is bad or not set */
-		printf ("\n*** Warning: ethaddr is not set properly, ignoring!!\n");
-	} else {
+	if (env_size == sizeof(es)) {
 		env_present = 1;
 		s = s_env_mac;
 
@@ -897,7 +895,8 @@
 			if (s)
 				s = (*e) ? e + 1 : e;
 		}
-	}
+	} else if (env_size >= 0)	/* Ignore if env is bad */
+		printf ("\n*** Warning: ethaddr is not set properly, ignoring!!\n");
 
 	rom_valid = get_rom_mac (v_rom_mac);	/* get ROM mac value if any */
 

I've tested your patch with the above change and it works for me:

OMAP1510 Innovator # bootp
Using MAC Address 08:00:28:32:0F:FF
BOOTP broadcast 1
DHCP client bound to address 192.168.1.91 OMAP1510 Innovator # setenv ethaddr 00:11:22:33:44 OMAP1510 Innovator # bootp

*** Warning: ethaddr is not set properly, ignoring!! Using MAC Address 08:00:28:32:0F:FF
BOOTP broadcast 1
DHCP client bound to address 192.168.1.91 OMAP1510 Innovator # setenv ethaddr
OMAP1510 Innovator # bootp
Using MAC Address 08:00:28:32:0F:FF
BOOTP broadcast 1
DHCP client bound to address 192.168.1.91

Thanks again!

--
Regards,
George

Quoted 4 lines

Best Wishes,

Dave Peverley

<snip>

#2 lore raw

PATCH 1/1 lan91c96 driver MAC address detection

Quoted 1 line · George G. Davis

Cool! Thanks for that!

No porbs :-)

Quoted 2 lines

I have a minor suggestion though. Can we squelch the warning for the "setenv ethaddr" case? Like so:

Sure, I have no preference either way. I think I originally put in the warning as I have the impression that Wolfgang's preference is to have the user use the environment to set the MAC address rather than have it detected.

Of course the easiest way to suppress the message is to do a 'bootp' to read teh detected address, and then 'saveenv' to set it permenently. This is perhaps something I should have added to the README?

Best Wishes,

~Pev

---------------------------------------------------------------------------
Dave Peverley, Software Engineer, MPC Data Limited.
Phone : [+44] (0) 1225 868 228 Web : http://www.mpc-data.co.uk

#3 lore raw

PATCH 1/1 lan91c96 driver MAC address detection

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

I have a minor suggestion though. Can we squelch the warning for the "setenv ethaddr" case? Like so:

Sure, I have no preference either way. I think I originally put in the warning as I have the impression that Wolfgang's preference is to have the user use the environment to set the MAC address rather than have it detected.

The rules are simple and documented:

o If the SROM has a valid MAC address, and there is no address in the environment, the SROM's address is used.

o If there is no valid address in the SROM, and a definition in the environment exists, then the value from the environment variable is used.

o If both the SROM and the environment contain a MAC address, and both addresses are the same, this MAC address is used.

o If both the SROM and the environment contain a MAC address, and the addresses differ, the value from the environment is used and a warning is printed.

o If neither SROM nor the environment contain a MAC address, an error is raised.

Quoted 2 lines

Of course the easiest way to suppress the message is to do a 'bootp' to read teh detected address, and then 'saveenv' to set it permenently.

You cannot use BOOTP (nor ony other network related protocol) to detect a MAC address!!!

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
It is easier to write an incorrect program than understand a  correct
one.
#4 lore raw

PATCH 1/1 lan91c96 driver MAC address detection

Quoted 1 line · Wolfgang Denk

The rules are simple and documented:

Sure, I've read these...

Quoted 2 lines

You cannot use BOOTP (nor ony other network related protocol) to detect a MAC address!!!

I think that either we operate on utterly different brainwave-lengths or theres some kind of language barrier issue here!

If you issue a 'bootp' command to u-boot via its interface as I stated, the following call sequence happens if you're using the lan91c96 (with patch) or smc91111 ethernet devices :

   do_bootp()                     [cmd_net.c]
    netboot_common()              [cmd_net.c]
     NetLoop()                    [net.c]
      eth_init()                  [lan91c96.c]
       smc_open()                 [lan91c96.c]
        smc_get_ethaddr()         [lan91c96.c]
         get_rom_mac()            [lan91c96.c]

So in practical use, issuing a bootp detects the mac address of the adapter.

Quoted 1 line

(nor ony other network related protocol)

Well, the following network related protocol calls :
do_tftpb()
do_rarpb()
do_dhcp()
do_nfs()
all call netboot_common() so will in effect detect the MAC address as well ;-)

Best Wishes,

Dave Peverley

---------------------------------------------------------------------------
Dave Peverley, Software Engineer, MPC Data Limited.
Phone : [+44] (0) 1225 868 228 Web : http://www.mpc-data.co.uk

#5 lore raw

PATCH 1/1 lan91c96 driver MAC address detection

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

You cannot use BOOTP (nor ony other network related protocol) to detect a MAC address!!!

I think that either we operate on utterly different brainwave-lengths or theres some kind of language barrier issue here!

BOOTP is a well-defined protocol which is based on the assumption that you have a network interface that can be used to send and receive packets. To do so, the interface must be initialized. BOOTP does in NO WAY work if your interface does not have a MAC address set. Especially, it does NOT retrieve the MAC address from anywhere.

Quoted 8 lines

If you issue a 'bootp' command to u-boot via its interface as I stated, the following call sequence happens if you're using the lan91c96 (with patch) or smc91111 ethernet devices :

   do_bootp()                     [cmd_net.c]
    netboot_common()              [cmd_net.c]
     NetLoop()                    [net.c]
      eth_init()                  [lan91c96.c]

Stop here. eth_init() performs the initialization of the ethernet interface, if this did not happen before, because an initialized ethernet interface is a precondition to use BOOTP.

Quoted 2 lines

So in practical use, issuing a bootp detects the mac address of the adapter.

No, no, no. This is plainly wrong.

Quoted 7 lines

Well, the following network related protocol calls :
do_tftpb()
do_rarpb()
do_dhcp()
do_nfs()
all call netboot_common() so will in effect detect the MAC address as well ;-)

None of these protocols has ato do anything with setting the MAC address. Please don't mix things up.

You could as well claim that bootp sets the baudrate of the serial console, because to run bootp you must execute an initialization sequence which includes the serial port, thus setting the baudrate.

IT AIN'T SO!

Wolfgang Denk

Signature · 5 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
Oh, that sound of male ego.  You travel halfway across the galaxy and
it's still the same song.
	-- Eve McHuron, "Mudd's Women", stardate 1330.1
#6 lore raw

Communication (Was Re: [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection)

Quoted 2 lines · Wolfgang Denk
Quoted 2 lines

If you issue a 'bootp' command to u-boot via its interface as I stated, the following call sequence happens

...

Quoted 3 lines
Quoted 2 lines

So in practical use, issuing a bootp detects the mac address of the adapter.

No, no, no. This is plainly wrong.

I've tried my best to explain this concisely and with no room for mis-interpretation but I have seemed to fail and I can't see why. I don't think anyone else managed to mis-read me as radically as this, so I've taken this off list to try and clear up with Wolfgang whatever the mixup seems to be. Apologies to all....

Best Wishes,

~Pev

---------------------------------------------------------------------------
Dave Peverley, Software Engineer, MPC Data Limited.
Phone : [+44] (0) 1225 868 228 Web : http://www.mpc-data.co.uk

#7 lore raw

PATCH 1/1 lan91c96 driver MAC address detection

In reply to Dave Peverley

Dear Dave,

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

This is a small patch for the lan91c96 ethernet driver that adds the
capability to automatically detect the MAC address stored in EPROM in the absence of a valid MAC address in the environment. It is modelled on the system used by the smc91111 driver as suggested by Marius Groeger

Added, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
There are very few personal problems that cannot be solved through  a
suitable application of high explosives.