2002-11-21 19:47:11

by Neil Cafferkey

[permalink] [raw]
Subject: Setting MAC address in ewrk3 driver

Hi,

I think I may have found a bug in the ewrk3 network driver. When I try to
change the MAC address of a Digital DE205 NIC using "ifconfig eth0 hw
ether XX:XX:XX:XX:XX:XX", it appears to work ("ifconfig eth0" reports the
new address), but in fact it isn't sending or receiving packets any more.
I'm using kernel version 2.4.10.

I've tried this with the same result in two machines using different DE205
cards. I have changed the MAC address of other types of NICs without
problems, so I don't think it's something silly like an ARP problem.

I tried to report this to the driver author, David Davies, but the address
given in the driver bounced. Please CC any responses to me, since I'm not
subscribed to the list.

Regards,
Neil Cafferkey


2002-11-21 20:52:13

by Alan

[permalink] [raw]
Subject: Re: Setting MAC address in ewrk3 driver

On Thu, 2002-11-21 at 19:54, Neil Cafferkey wrote:
> Hi,
>
> I think I may have found a bug in the ewrk3 network driver. When I try to
> change the MAC address of a Digital DE205 NIC using "ifconfig eth0 hw
> ether XX:XX:XX:XX:XX:XX", it appears to work ("ifconfig eth0" reports the
> new address), but in fact it isn't sending or receiving packets any more.
> I'm using kernel version 2.4.10.

The default handler assumes the card mac address is set by the "up"
method. That driver is old enough it may not do so.

2002-11-21 23:22:49

by Adam Kropelin

[permalink] [raw]
Subject: Re: Setting MAC address in ewrk3 driver

On Thu, Nov 21, 2002 at 07:54:17PM +0000, Neil Cafferkey wrote:
> Hi,
>
> I think I may have found a bug in the ewrk3 network driver. When I try to
> change the MAC address of a Digital DE205 NIC using "ifconfig eth0 hw
> ether XX:XX:XX:XX:XX:XX", it appears to work ("ifconfig eth0" reports the
> new address), but in fact it isn't sending or receiving packets any more.
> I'm using kernel version 2.4.10.

Try the driver from 2.4.20-rc2. There are some locking updates in the
ioctl code for setting the hw address. I'm running 2.5 (approx same
driver as 2.4.20-rc2) here and I observe that the address really does
change (i.e. I see packets on the wire with the new MAC addr) but the
kernel oopses shortly thereafter somewhere in the network stack. I'm
blaming this on 2.5 instability for the moment but will fix it if it
turns out to be ewrk3's fault.

--Adam

2002-11-21 23:32:49

by Adam Kropelin

[permalink] [raw]
Subject: Re: Setting MAC address in ewrk3 driver

On Thu, Nov 21, 2002 at 09:28:15PM +0000, Alan Cox wrote:
> On Thu, 2002-11-21 at 19:54, Neil Cafferkey wrote:
> > Hi,
> >
> > I think I may have found a bug in the ewrk3 network driver. When I try to
> > change the MAC address of a Digital DE205 NIC using "ifconfig eth0 hw
> > ether XX:XX:XX:XX:XX:XX", it appears to work ("ifconfig eth0" reports the
> > new address), but in fact it isn't sending or receiving packets any more.
> > I'm using kernel version 2.4.10.
>
> The default handler assumes the card mac address is set by the "up"
> method. That driver is old enough it may not do so.

Alan, could you clarify for me? I'm the last guy to diddle with ewrk3 so
I'll track this down if there is indeed something to track down. ewrk3
has a private ioctl for setting the mac address. By the "up" method do
you mean the etherdev open method? Should there be a standard ioctl
implemented for setting the mac address?

--Adam

2002-11-21 23:50:12

by Alan

[permalink] [raw]
Subject: Re: Setting MAC address in ewrk3 driver

On Thu, 2002-11-21 at 23:39, Adam Kropelin wrote:
> Alan, could you clarify for me? I'm the last guy to diddle with ewrk3 so
> I'll track this down if there is indeed something to track down. ewrk3
> has a private ioctl for setting the mac address. By the "up" method do
> you mean the etherdev open method? Should there be a standard ioctl
> implemented for setting the mac address?

dev->set_mac_address()


2002-11-21 23:56:05

by Jeff Garzik

[permalink] [raw]
Subject: Re: Setting MAC address in ewrk3 driver

Alan Cox wrote:

> On Thu, 2002-11-21 at 23:39, Adam Kropelin wrote:
>
> >Alan, could you clarify for me? I'm the last guy to diddle with ewrk3 so
> >I'll track this down if there is indeed something to track down. ewrk3
> >has a private ioctl for setting the mac address. By the "up" method do
> >you mean the etherdev open method? Should there be a standard ioctl
> >implemented for setting the mac address?
>
>
> dev->set_mac_address()



To be more specific:

Read the MAC address in the probe phase.
Write MAC address to NIC on _each_ dev->open().
If you care about changing the MAC address while interface is up,
implement dev->set_mac_address().

So, dev->set_mac_address() is pretty useless, when you can just tell
users "down the interface before setting MAC address" which is a sane
thing to do anyway, and much less complicated.

Jeff



2002-11-22 01:23:05

by Adam Kropelin

[permalink] [raw]
Subject: [PATCH] Re: Setting MAC address in ewrk3 driver

On Thu, Nov 21, 2002 at 07:02:32PM -0500, Jeff Garzik wrote:
> Alan Cox wrote:
>
> >On Thu, 2002-11-21 at 23:39, Adam Kropelin wrote:
> >
> >>Alan, could you clarify for me? I'm the last guy to diddle with ewrk3 so
> >>I'll track this down if there is indeed something to track down. ewrk3
> >>has a private ioctl for setting the mac address. By the "up" method do
> >>you mean the etherdev open method? Should there be a standard ioctl
> >>implemented for setting the mac address?
> >
> >
> >dev->set_mac_address()
>
> To be more specific:
>
> Read the MAC address in the probe phase.
> Write MAC address to NIC on _each_ dev->open().

Got it. Quick patch below. Works for me (TM). Against recent 2.5 but
should apply to 2.4 with offsets.

Neil, does this work for you?

> If you care about changing the MAC address while interface is up,
> implement dev->set_mac_address().

Sounds like that is best avoided unless someone specifically needs it.
Even then it'll get implemented as a close/open sequence internally
anyway, so there's not much point.

--Adam

--- linux-2.5.47/drivers/net/ewrk3.c.orig Thu Nov 21 20:24:00 2002
+++ linux-2.5.47/drivers/net/ewrk3.c Thu Nov 21 20:22:24 2002
@@ -712,6 +712,7 @@
struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
u_char csr, page;
u_long iobase = dev->base_addr;
+ int i;

/*
** Enable any multicasts
@@ -719,6 +720,13 @@
set_multicast_list(dev);

/*
+ ** Set hardware MAC address. Address is initialized from the EEPROM
+ ** during startup but may have since been changed by the user.
+ */
+ for (i=0; i<ETH_ALEN; i++)
+ outb(dev->dev_addr[i], EWRK3_PAR0 + i);
+
+ /*
** Clean out any remaining entries in all the queues here
*/
while (inb(EWRK3_TQ));

2002-11-26 01:40:34

by Neil Cafferkey

[permalink] [raw]
Subject: Re: Setting MAC address in ewrk3 driver

On Thu, Nov 21, 2002 at 08:30:04PM -0500, Adam Kropelin wrote:
>
> Got it. Quick patch below. Works for me (TM). Against recent 2.5 but
> should apply to 2.4 with offsets.
>
> Neil, does this work for you?

Yes, it works fine with 2.4.19. Thanks a lot. Sorry for the delay, but I
didn't have the opportunity to test it for a few days.

Regards,
Neil Cafferkey