public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection
@ 2004-04-29 17:02 Dave Peverley
  2004-04-30 19:59 ` George G. Davis
  2004-06-06 22:12 ` [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection Wolfgang Denk
  0 siblings, 2 replies; 8+ messages in thread
From: Dave Peverley @ 2004-04-29 17:02 UTC (permalink / raw)
  To: u-boot

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 

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

* [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection
  2004-04-29 17:02 [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection Dave Peverley
@ 2004-04-30 19:59 ` George G. Davis
  2004-05-04  9:48   ` Dave Peverley
  2004-06-06 22:12 ` [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection Wolfgang Denk
  1 sibling, 1 reply; 8+ messages in thread
From: George G. Davis @ 2004-04-30 19:59 UTC (permalink / raw)
  To: u-boot

On Thu, Apr 29, 2004 at 06:02:01PM +0100, Dave Peverley wrote:
> 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.

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

--- drivers/lan91c96.c.orig	2004-04-29 13:15:14.000000000 -0400
+++ drivers/lan91c96.c	2004-04-30 15:47:45.000000000 -0400
@@ -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
> 
> Best Wishes,
> 
> Dave Peverley

<snip>

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

* [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection
  2004-04-30 19:59 ` George G. Davis
@ 2004-05-04  9:48   ` Dave Peverley
  2004-05-04 12:06     ` Wolfgang Denk
  0 siblings, 1 reply; 8+ messages in thread
From: Dave Peverley @ 2004-05-04  9:48 UTC (permalink / raw)
  To: u-boot

George G. Davis wrote:
> Cool! Thanks for that! 
No porbs :-)

> 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

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

* [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection
  2004-05-04  9:48   ` Dave Peverley
@ 2004-05-04 12:06     ` Wolfgang Denk
  2004-05-04 12:32       ` Dave Peverley
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Denk @ 2004-05-04 12:06 UTC (permalink / raw)
  To: u-boot

In message <409766D3.2030409@mpc-data.co.uk> you wrote:
> 
> > 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.


> 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

-- 
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.

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

* [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection
  2004-05-04 12:06     ` Wolfgang Denk
@ 2004-05-04 12:32       ` Dave Peverley
  2004-05-04 17:02         ` Wolfgang Denk
  0 siblings, 1 reply; 8+ messages in thread
From: Dave Peverley @ 2004-05-04 12:32 UTC (permalink / raw)
  To: u-boot

Wolfgang Denk wrote:
> The rules are simple and documented:
Sure, I've read these...

> 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. 

> (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

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

* [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection
  2004-05-04 12:32       ` Dave Peverley
@ 2004-05-04 17:02         ` Wolfgang Denk
  2004-05-04 17:55           ` Communication (Was Re: [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection) Dave Peverley
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Denk @ 2004-05-04 17:02 UTC (permalink / raw)
  To: u-boot

In message <40978D65.7030805@mpc-data.co.uk> you wrote:
>
> > 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.

> 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.

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

No, no, no. This is plainly wrong.

> 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

-- 
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

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

* Communication (Was Re: [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection)
  2004-05-04 17:02         ` Wolfgang Denk
@ 2004-05-04 17:55           ` Dave Peverley
  0 siblings, 0 replies; 8+ messages in thread
From: Dave Peverley @ 2004-05-04 17:55 UTC (permalink / raw)
  To: u-boot

Wolfgang Denk wrote:
>>If you issue a 'bootp' command to u-boot via its interface as I stated, 
>>the following call sequence happens
...
>>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

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

* [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection
  2004-04-29 17:02 [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection Dave Peverley
  2004-04-30 19:59 ` George G. Davis
@ 2004-06-06 22:12 ` Wolfgang Denk
  1 sibling, 0 replies; 8+ messages in thread
From: Wolfgang Denk @ 2004-06-06 22:12 UTC (permalink / raw)
  To: u-boot

Dear Dave,

in message <40913509.1090309@mpc-data.co.uk> 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

-- 
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.

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

end of thread, other threads:[~2004-06-06 22:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-29 17:02 [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection Dave Peverley
2004-04-30 19:59 ` George G. Davis
2004-05-04  9:48   ` Dave Peverley
2004-05-04 12:06     ` Wolfgang Denk
2004-05-04 12:32       ` Dave Peverley
2004-05-04 17:02         ` Wolfgang Denk
2004-05-04 17:55           ` Communication (Was Re: [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection) Dave Peverley
2004-06-06 22:12 ` [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection Wolfgang Denk

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