From: Manfred Spraul <manfred@colorfullife.com>
To: Gary N Spiess <Gary.Spiess@Intermec.com>
Cc: netdev@oss.sgi.com, jgarzik@pobox.com
Subject: Re: [PATCH] natsemi update 1/4 Use assigned MAC address
Date: Sun, 06 Jun 2004 15:30:25 +0200 [thread overview]
Message-ID: <40C31C71.6000101@colorfullife.com> (raw)
In-Reply-To: <200406041451590078.0BC23855@136.179.85.112>
[-- Attachment #1: Type: text/plain, Size: 1318 bytes --]
Gary N Spiess wrote:
>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.
>
Ok. Appending "natsemi.ethaddr=00:01:02:04:05:06" works.
> To get things working for our development, I use a __setup() wrapper to get "ethaddr=" from the linux command line.
>
>
That's not a reason to merge a hack
>+ if (find_cnt < ethaddr_num)
>
>
I think we should add a special case: if strlen(ethaddr[find_cnt]) is 0,
then the address from the eeprom is used - this allows to replace one
mac address if multiple nics are installed.
>+ {
>
>
Coding style: the { should be in the same line as the if
>+ int i, a[6];
>
>
i already exists, no need to define another instance.
I've appended an updated patch - could you test it?
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
# ifconfig eth2 ether 80:01:02:03:04:05
Is there a reason why you cannot set the mac address from user space?
--
Manfred
[-- Attachment #2: natsemi-2.6.6-1.patch-new --]
[-- Type: text/plain, Size: 2189 bytes --]
--- 2.6/drivers/net/natsemi.c 2004-05-10 04:31:59.000000000 +0200
+++ build-2.6/drivers/net/natsemi.c 2004-06-06 15:27:12.124436291 +0200
@@ -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,21 @@
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 && strlen(ethaddr[find_cnt]) > 0) {
+ int 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;
next prev parent reply other threads:[~2004-06-06 13:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-04 19:51 [PATCH] natsemi update 1/4 Use assigned MAC address Gary N Spiess
2004-06-06 13:30 ` Manfred Spraul [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40C31C71.6000101@colorfullife.com \
--to=manfred@colorfullife.com \
--cc=Gary.Spiess@Intermec.com \
--cc=jgarzik@pobox.com \
--cc=netdev@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).