netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] natsemi update 1/4 Use assigned MAC address
@ 2004-06-04 19:51 Gary N Spiess
  2004-06-06 13:30 ` Manfred Spraul
  0 siblings, 1 reply; 10+ messages in thread
From: Gary N Spiess @ 2004-06-04 19:51 UTC (permalink / raw)
  To: netdev; +Cc: manfred


[-- Attachment #1.1: Type: text/plain, Size: 636 bytes --]

Jeff,
This is the first of a series of patches needed to support our product using the DP83815.
This patch accepts the MAC address as a parameter because our implementation does not have an EEPROM.  I tried to upgrade to the new module_param_array() macro, but couldn't find a tutorial on the new param scheme.  To get things working for our development, I use a __setup() wrapper to get "ethaddr=" from the linux command line.
Gary
 oooooooooooooooooooooooooooooooooooooooooooooooooo
 Gary Spiess (Gary.Spiess@Intermec.com)
 MobileLan Wireless Products Group, Intermec Technology Corp
 voice: 319 369-3580  fax: 319 369-3804


[-- Attachment #1.2: Type: text/html, Size: 1005 bytes --]

[-- Attachment #2: natsemi-2.6.6-1.patch --]
[-- Type: application/octet-stream, Size: 2883 bytes --]

--- linux-2.6.6/drivers/net/natsemi.c	2004-06-02 13:31:37.000000000 -0500
+++ linux/drivers/net/natsemi.c	2004-06-02 16:56:38.000000000 -0500
@@ -147,6 +147,7 @@
 
 #include <linux/config.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/timer.h>
@@ -209,6 +210,8 @@
 #define MAX_UNITS 8		/* More are supported, limit only on options */
 static int options[MAX_UNITS];
 static int full_duplex[MAX_UNITS];
+static char *ethaddr[MAX_UNITS] = {NULL, };
+static int ethaddr_num = 0;
 
 /* Operational parameters that are set at compile time. */
 
@@ -256,6 +259,7 @@
 MODULE_PARM(rx_copybreak, "i");
 MODULE_PARM(options, "1-" __MODULE_STRING(MAX_UNITS) "i");
 MODULE_PARM(full_duplex, "1-" __MODULE_STRING(MAX_UNITS) "i");
+module_param_array(ethaddr, charp, ethaddr_num, S_IRUGO);
 MODULE_PARM_DESC(max_interrupt_work, 
 	"DP8381x maximum events handled per interrupt");
 MODULE_PARM_DESC(mtu, "DP8381x MTU (all boards)");
@@ -265,6 +269,7 @@
 MODULE_PARM_DESC(options, 
 	"DP8381x: Bits 0-3: media type, bit 17: full duplex");
 MODULE_PARM_DESC(full_duplex, "DP8381x full duplex setting(s) (1)");
+MODULE_PARM_DESC(ethaddr, "DP8381x MAC addr(s) xx:xx:xx:xx:xx:xx");
 
 /*
 				Theory of Operation
@@ -776,13 +781,22 @@
 		goto err_ioremap;
 	}
 
-	/* Work around the dropped serial bit. */
-	prev_eedata = eeprom_read(ioaddr, 6);
-	for (i = 0; i < 3; i++) {
-		int eedata = eeprom_read(ioaddr, i + 7);
-		dev->dev_addr[i*2] = (eedata << 1) + (prev_eedata >> 15);
-		dev->dev_addr[i*2+1] = eedata >> 7;
-		prev_eedata = eedata;
+	if (find_cnt < ethaddr_num)
+	{
+		int i, a[6];
+		sscanf(ethaddr[find_cnt], "%2x:%2x:%2x:%2x:%2x:%2x",
+			&a[0], &a[1], &a[2], &a[3], &a[4], &a[5]);
+		for (i = 6; i--; )
+			dev->dev_addr[i] = (unsigned char)a[i];
+	} else {
+		/* Work around the dropped serial bit. */
+		prev_eedata = eeprom_read(ioaddr, 6);
+		for (i = 0; i < 3; i++) {
+			int eedata = eeprom_read(ioaddr, i + 7);
+			dev->dev_addr[i*2] = (eedata << 1) + (prev_eedata >> 15);
+			dev->dev_addr[i*2+1] = eedata >> 7;
+			prev_eedata = eedata;
+		}
 	}
 
 	dev->base_addr = ioaddr;
@@ -2696,6 +2712,28 @@
 	pci_unregister_driver (&natsemi_driver);
 }
 
+/* permit ethaddr to be specified in the linux command line as
+ * bootargs="ethaddr=xx:xx:xx:xx:xx:xx".
+ */
+static int __init get_mac_addr(char *str)
+{
+	/* can't deal with multiple definitions */
+	if (!ethaddr_num)
+	{
+		static unsigned char tempethaddr[18];
+
+		/* Unsafe to just save the pointer?  I'll make a copy */
+		strncpy(tempethaddr, str, sizeof(tempethaddr));
+		tempethaddr[sizeof(tempethaddr)-1] = 0;
+
+		/* Do what I think module_param_array() should do */
+		ethaddr[ethaddr_num++] = tempethaddr;
+	}
+	return 0;
+}
+
+__setup("ethaddr=", get_mac_addr);
+
 module_init(natsemi_init_mod);
 module_exit(natsemi_exit_mod);
 

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [PATCH] natsemi update 1/4 Use assigned MAC address
@ 2004-06-07 21:42 Mark Smith
  2004-06-07 21:46 ` Stephen Hemminger
  2004-06-07 21:48 ` Stephen Hemminger
  0 siblings, 2 replies; 10+ messages in thread
From: Mark Smith @ 2004-06-07 21:42 UTC (permalink / raw)
  To: manfred, Gary.Spiess, shemminger; +Cc: netdev

Hi Manfred, Gary, Stephen,

"But: I'm not sure that the change is required. What about just
setting the mac to 0, and the actual mac address is set from user
space? It's possible to set the mac address with"

Could I suggest if this is the solution implemented, setting the
first octet of the MAC address to 0x02, as in a Locally Assigned
MAC address ?

If an interface with an all zero's MAC address is added to a
bridge, running the Spanning Tree Protocol (STP), it will always
attempt to take over as the root bridge, unless STP root bridge
priorities are being used. This would disrupt traffic on the
attached LAN.

Ideally, assigning "zero" a MAC address which has almost no
chance of disrupting STP or any other protocol could be useful.
Maybe fe:ff:ff:ff:ff:ff ?

I think this would fit in with the "be conservative in what you
send, liberal in what you receive" philosophy.

Regards,
Mark.

ps, please CC on any replies, I'm not subscribed to the list yet.

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

end of thread, other threads:[~2004-06-08 18:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-04 19:51 [PATCH] natsemi update 1/4 Use assigned MAC address Gary N Spiess
2004-06-06 13:30 ` Manfred Spraul
2004-06-07 17:58   ` Gary N Spiess
2004-06-07 18:16     ` Stephen Hemminger
2004-06-07 21:12       ` Gary N Spiess
2004-06-08 18:31   ` Jeff Garzik
  -- strict thread matches above, loose matches on Subject: below --
2004-06-07 21:42 Mark Smith
2004-06-07 21:46 ` Stephen Hemminger
2004-06-07 22:11   ` Mark Smith
2004-06-07 21:48 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).