2012-02-08 11:09:22

by Peter Meerwald-Stadler

[permalink] [raw]
Subject: [PATCH 1/2] smsc95xx: add module parameter to turn off NIC status leds

From: Peter Meerwald <[email protected]>

add module parameter to allow to turn off NIC status leds (link,
speed, activity); blinking LEDs are annoying outside the server room :)

default behaviour is not changed, tested on beagleboard-xm

Signed-off-by: Peter Meerwald <[email protected]>

---
drivers/net/usb/smsc95xx.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index d45520e..b7b2326 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -63,6 +63,10 @@ static bool turbo_mode = true;
module_param(turbo_mode, bool, 0644);
MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");

+static bool leds_off = false;
+module_param(leds_off, bool, 0644);
+MODULE_PARM_DESC(leds_off, "Turn off NIC LEDs");
+
static int smsc95xx_read_reg(struct usbnet *dev, u32 index, u32 *data)
{
u32 *buf = kmalloc(4, GFP_KERNEL);
@@ -894,8 +898,11 @@ static int smsc95xx_reset(struct usbnet *dev)
netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x\n", read_buf);

/* Configure GPIO pins as LED outputs */
- write_buf = LED_GPIO_CFG_SPD_LED | LED_GPIO_CFG_LNK_LED |
- LED_GPIO_CFG_FDX_LED;
+ if (!leds_off)
+ write_buf = LED_GPIO_CFG_SPD_LED | LED_GPIO_CFG_LNK_LED |
+ LED_GPIO_CFG_FDX_LED;
+ else
+ write_buf = 0;
ret = smsc95xx_write_reg(dev, LED_GPIO_CFG, write_buf);
if (ret < 0) {
netdev_warn(dev->net, "Failed to write LED_GPIO_CFG register, ret=%d\n",
--
1.7.4.1


2012-02-08 11:09:22

by Peter Meerwald-Stadler

[permalink] [raw]
Subject: [PATCH 2/2] smsc95xx: allow to re-use MAC address already programmed

From: Peter Meerwald <[email protected]>

patch adds a module parameter which allows to keep the MAC address already
set (e.g. by the boot loader) if it is valid (otherwise the MAC address is read
from an optional EEPROM or randomly generated)

tested on beagleboard-xm

Signed-off-by: Peter Meerwald <[email protected]>

---
drivers/net/usb/smsc95xx.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index b7b2326..5545a60 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -67,6 +67,10 @@ static bool leds_off = false;
module_param(leds_off, bool, 0644);
MODULE_PARM_DESC(leds_off, "Turn off NIC LEDs");

+static bool keep_mac = false;
+module_param(keep_mac, bool, 0644);
+MODULE_PARM_DESC(keep_mac, "Keep MAC address set by boot loader if available");
+
static int smsc95xx_read_reg(struct usbnet *dev, u32 index, u32 *data)
{
u32 *buf = kmalloc(4, GFP_KERNEL);
@@ -607,6 +611,21 @@ static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)

static void smsc95xx_init_mac_address(struct usbnet *dev)
{
+ if (keep_mac) {
+ u32 addr_lo, addr_hi;
+ int ret = smsc95xx_read_reg(dev, ADDRL, &addr_lo);
+ if (ret < 0) {
+ netdev_warn(dev->net, "Failed to read ADDRL: %d\n", ret);
+ }
+ ret = smsc95xx_read_reg(dev, ADDRH, &addr_hi);
+
+ if (is_valid_ether_addr(dev->net->dev_addr)) {
+ /* MAC values are valid so use them */
+ netif_dbg(dev, ifup, dev->net, "MAC address already configured\n");
+ return;
+ }
+ }
+
/* try reading mac address from EEPROM */
if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
dev->net->dev_addr) == 0) {
--
1.7.4.1

2012-02-08 20:26:39

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 1/2] smsc95xx: add module parameter to turn off NIC status leds

From: Peter Meerwald <[email protected]>
Date: Wed, 8 Feb 2012 12:08:51 +0100

> From: Peter Meerwald <[email protected]>
>
> add module parameter to allow to turn off NIC status leds (link,
> speed, activity); blinking LEDs are annoying outside the server room :)
>
> default behaviour is not changed, tested on beagleboard-xm
>
> Signed-off-by: Peter Meerwald <[email protected]>

No. Create a generic mechanism, perhaps via ethtool, for users to
configure something like this.

Otherwise the next driver that wants to provide this kind of knob
will add yet another module parameter with yet another name, and
this kind of ad-hoc set of interfaces absolutely sucks for users.

2012-02-08 20:26:58

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 2/2] smsc95xx: allow to re-use MAC address already programmed

From: Peter Meerwald <[email protected]>
Date: Wed, 8 Feb 2012 12:08:52 +0100

> From: Peter Meerwald <[email protected]>
>
> patch adds a module parameter which allows to keep the MAC address already
> set (e.g. by the boot loader) if it is valid (otherwise the MAC address is read
> from an optional EEPROM or randomly generated)
>
> tested on beagleboard-xm
>
> Signed-off-by: Peter Meerwald <[email protected]>

No way, for the same reason as your other patch.

Module parameters suck, use something generic.

2012-02-08 20:27:25

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 2/2] smsc95xx: allow to re-use MAC address already programmed


And please post networking patches CC:'d to the proper list next time,
[email protected]