[realtek] Implementing set_mac_address for the rtl8139 driver?

Ben Greear greearb@candelatech.com
Wed, 03 Jan 2001 23:58:16 -0700


Donald Becker wrote:
> 
> On Wed, 3 Jan 2001, Ben Greear wrote:
> 
> > After poking around in the 8139 driver included with linux 2.4.prerelease,
> > and the one on scyld.com, I've come to the conclusion that there is
> > absolutely no way that ifconfig can set the mac_address on the
> > interface correctly.  The reason seems to be that the driver
> > does not set it's own method at dev->set_mac_address, so the default
> > is used, which just updates the in-memory net_device structure, and
> > does nothing to tell the actual NIC what's goin on....
> 
> The key is that dev->dev_addr[] can only be modified when the interface is
> stopped.
> Here is the generic set method in drivers/net/net_init.c.
> Note the check for dev->start.
> ____
> static int eth_mac_addr(struct device *dev, void *p)
> {
>         struct sockaddr *addr=p;
>         if(dev->start)
>                 return -EBUSY;
>         memcpy(dev->dev_addr, addr->sa_data,dev->addr_len);
>         return 0;
> }
> ____
> 
> Properly written Ethernet drivers always copy dev->dev_addr[] to the NIC at
> every open() call.  Here is the code from rtl8129_open()
> 
>         outl(cpu_to_le32(*(u32*)(dev->dev_addr + 0)), ioaddr + MAC0 + 0);
>         outl(cpu_to_le32(*(u32*)(dev->dev_addr + 4)), ioaddr + MAC0 + 4);
> 
> This is how 'ifconfig hw ether aa:bb:cc:dd:ee:ff' works.

Yep, I noticed similar code after digging around a while.  Do you
know of any reasons why the ifconfig changes would not take effect
on the NIC (ie why I have to put it into promisc mode to get it
to receive any packets?)

I haven't been able to get either the tulip based card nor the 8139
to work as I want them too...and changing them to PROMISC does work...

When I use something like tulip-diags, and it tells me the MAC address,
it's reading out of ROM, right?  Is there some way to get it to tell
me what it has in RAM, ie what it's using right now?

Thanks,
Ben


> 
> Donald Becker                           becker@scyld.com
> Scyld Computing Corporation             http://www.scyld.com
> 410 Severn Ave. Suite 210               Second Generation Beowulf Clusters
> Annapolis MD 21403                      410-990-9993
> 
> _______________________________________________
> realtek mailing list
> realtek@scyld.com
> http://www.scyld.com/mailman/listinfo/realtek

-- 
Ben Greear (greearb@candelatech.com)  http://www.candelatech.com
Author of ScryMUD:  scry.wanfear.com 4444        (Released under GPL)
http://scry.wanfear.com               http://scry.wanfear.com/~greear