All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb:smsc: preserve MAC address when resetting device
@ 2011-02-01 10:34 Sergiy Kibrik
  2011-02-01 11:24 ` David Lamparter
  0 siblings, 1 reply; 3+ messages in thread
From: Sergiy Kibrik @ 2011-02-01 10:34 UTC (permalink / raw)
  To: Steve Glendinning; +Cc: netdev, linux-usb, Sergiy Kibrik

Initialize MAC address only once, when device opened first time
to avoid generation random addresses when failed to read one from ROM.

Some hardware hasn't hw address in ROM, e.g. Pandaboard  (http://pandaboard.org),
so every time device is up, its address is regenerated again.
It makeis impossible to set custom hw address and also makes DHCP servers and switches crazy.

Signed-off-by: Sergiy Kibrik <sakib@meta.ua>
---
 drivers/net/usb/smsc75xx.c |    6 +++++-
 drivers/net/usb/smsc95xx.c |    6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 753ee6e..a45dfa2 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -77,6 +77,7 @@ struct usb_context {
 };
 
 static int turbo_mode = true;
+static int first_reset = true;
 module_param(turbo_mode, bool, 0644);
 MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
 
@@ -836,7 +837,10 @@ static int smsc75xx_reset(struct usbnet *dev)
 
 	netif_dbg(dev, ifup, dev->net, "PHY reset complete");
 
-	smsc75xx_init_mac_address(dev);
+	if (first_reset){
+		smsc75xx_init_mac_address(dev);
+		first_reset = false;
+	}
 
 	ret = smsc75xx_set_mac_address(dev);
 	check_warn_return(ret, "Failed to set mac address");
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index bc86f4b..83008c1 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -59,6 +59,7 @@ struct usb_context {
 	struct usbnet *dev;
 };
 
+static int first_reset = true;
 static int turbo_mode = true;
 module_param(turbo_mode, bool, 0644);
 MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
@@ -1045,7 +1046,10 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
 	pdata->use_tx_csum = DEFAULT_TX_CSUM_ENABLE;
 	pdata->use_rx_csum = DEFAULT_RX_CSUM_ENABLE;
 
-	smsc95xx_init_mac_address(dev);
+	if (first_reset){
+		smsc95xx_init_mac_address(dev);
+		first_reset = false;
+	}
 
 	/* Init all registers */
 	ret = smsc95xx_reset(dev);
-- 
1.7.1


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

* Re: [PATCH] usb:smsc: preserve MAC address when resetting device
  2011-02-01 10:34 [PATCH] usb:smsc: preserve MAC address when resetting device Sergiy Kibrik
@ 2011-02-01 11:24 ` David Lamparter
  2011-02-01 20:58   ` Sergiy Kibrik
  0 siblings, 1 reply; 3+ messages in thread
From: David Lamparter @ 2011-02-01 11:24 UTC (permalink / raw)
  To: Sergiy Kibrik; +Cc: Steve Glendinning, netdev, linux-usb

[-- Attachment #1: Type: text/plain, Size: 1322 bytes --]

On Tue, Feb 01, 2011 at 12:34:17PM +0200, Sergiy Kibrik wrote:
> Initialize MAC address only once, when device opened first time
> to avoid generation random addresses when failed to read one from ROM.
> 
> Some hardware hasn't hw address in ROM, e.g. Pandaboard  (http://pandaboard.org),
> so every time device is up, its address is regenerated again.
> It makeis impossible to set custom hw address and also makes DHCP servers and switches crazy.
[snip]
> +++ b/drivers/net/usb/smsc75xx.c
> @@ -77,6 +77,7 @@ struct usb_context {
>  };
>  
>  static int turbo_mode = true;
> +static int first_reset = true;
>  module_param(turbo_mode, bool, 0644);
>  MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
>  
> @@ -836,7 +837,10 @@ static int smsc75xx_reset(struct usbnet *dev)
>  
>  	netif_dbg(dev, ifup, dev->net, "PHY reset complete");
>  
> -	smsc75xx_init_mac_address(dev);
> +	if (first_reset){
> +		smsc75xx_init_mac_address(dev);
> +		first_reset = false;
> +	}
[snip]

You cannot do that. Imagine if I plug in two devices. Only the first one
will get a MAC properly. Or imagine if i plug a device, unplug it and
plug it back. It will have an uninitialized mac address.

You need to move the init_mac_address call to happen on device plug-in.


-David


[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH] usb:smsc: preserve MAC address when resetting device
  2011-02-01 11:24 ` David Lamparter
@ 2011-02-01 20:58   ` Sergiy Kibrik
  0 siblings, 0 replies; 3+ messages in thread
From: Sergiy Kibrik @ 2011-02-01 20:58 UTC (permalink / raw)
  To: David Lamparter; +Cc: Steve Glendinning, netdev, linux-usb

[-- Attachment #1: Type: Text/Plain, Size: 448 bytes --]

On Tuesday 01 February 2011 13:24:25 David Lamparter wrote:
> You cannot do that. Imagine if I plug in two devices. Only the first one
> will get a MAC properly. Or imagine if i plug a device, unplug it and
> plug it back. It will have an uninitialized mac address.
> 
> You need to move the init_mac_address call to happen on device plug-in.
> 
> 
> -David

Sorry, didn't take into account such case. Will resubmit

-regards,
Sergey

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 316 bytes --]

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

end of thread, other threads:[~2011-02-01 20:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-01 10:34 [PATCH] usb:smsc: preserve MAC address when resetting device Sergiy Kibrik
2011-02-01 11:24 ` David Lamparter
2011-02-01 20:58   ` Sergiy Kibrik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.