Hook the identification LEDs of igb(4), lem(4) and em(4) devices up with

led(4) so they can be lit or f.e. made blink via `echo f2 > /dev/led/em0`
for localization purposes.

Approved by:	jfv
MFC afer:	1 week (after r205869)
This commit is contained in:
Marius Strobl 2010-03-31 20:43:24 +00:00
parent d6b013b537
commit 79c7b7190f
6 changed files with 85 additions and 3 deletions

View File

@ -77,6 +77,7 @@
#include <netinet/udp.h>
#include <machine/in_cksum.h>
#include <dev/led/led.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
@ -267,6 +268,7 @@ static void em_release_hw_control(struct adapter *);
static void em_get_wakeup(device_t);
static void em_enable_wakeup(device_t);
static int em_enable_phy_wakeup(struct adapter *);
static void em_led_func(void *, int);
static int em_irq_fast(void *);
@ -656,6 +658,9 @@ em_attach(device_t dev)
/* Tell the stack that the interface is not active */
adapter->ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
adapter->led_dev = led_create(em_led_func, adapter,
device_get_nameunit(dev));
INIT_DEBUGOUT("em_attach: end");
return (0);
@ -769,6 +774,9 @@ em_resume(device_t dev)
struct adapter *adapter = device_get_softc(dev);
struct ifnet *ifp = adapter->ifp;
if (adapter->led_dev != NULL)
led_destroy(adapter->led_dev);
EM_CORE_LOCK(adapter);
em_init_locked(adapter);
em_init_manageability(adapter);
@ -2163,6 +2171,9 @@ em_stop(void *arg)
e1000_reset_hw(&adapter->hw);
E1000_WRITE_REG(&adapter->hw, E1000_WUC, 0);
e1000_led_off(&adapter->hw);
e1000_cleanup_led(&adapter->hw);
}
@ -4538,7 +4549,7 @@ em_get_wakeup(device_t dev)
/*
* Enable PCI Wake On Lan capability
*/
void
static void
em_enable_wakeup(device_t dev)
{
struct adapter *adapter = device_get_softc(dev);
@ -4690,6 +4701,22 @@ out:
return ret;
}
static void
em_led_func(void *arg, int onoff)
{
struct adapter *adapter = arg;
EM_CORE_LOCK(adapter);
if (onoff) {
e1000_setup_led(&adapter->hw);
e1000_led_on(&adapter->hw);
} else {
e1000_led_off(&adapter->hw);
e1000_cleanup_led(&adapter->hw);
}
EM_CORE_UNLOCK(adapter);
}
/**********************************************************************
*
* Update the board statistics counters.

View File

@ -337,6 +337,7 @@ struct adapter {
/* FreeBSD operating-system-specific structures. */
struct e1000_osdep osdep;
struct device *dev;
struct cdev *led_dev;
struct resource *memory;
struct resource *flash;

View File

@ -83,6 +83,7 @@
#include <netinet/udp.h>
#include <machine/in_cksum.h>
#include <dev/led/led.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
@ -234,6 +235,7 @@ static void igb_release_manageability(struct adapter *);
static void igb_get_hw_control(struct adapter *);
static void igb_release_hw_control(struct adapter *);
static void igb_enable_wakeup(device_t);
static void igb_led_func(void *, int);
static int igb_irq_fast(void *);
static void igb_add_rx_process_limit(struct adapter *, const char *,
@ -585,6 +587,9 @@ igb_attach(device_t dev)
/* Tell the stack that the interface is not active */
adapter->ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
adapter->led_dev = led_create(igb_led_func, adapter,
device_get_nameunit(dev));
INIT_DEBUGOUT("igb_attach: end");
return (0);
@ -624,6 +629,9 @@ igb_detach(device_t dev)
return (EBUSY);
}
if (adapter->led_dev != NULL)
led_destroy(adapter->led_dev);
#ifdef DEVICE_POLLING
if (ifp->if_capenable & IFCAP_POLLING)
ether_poll_deregister(ifp);
@ -2002,6 +2010,9 @@ igb_stop(void *arg)
e1000_reset_hw(&adapter->hw);
E1000_WRITE_REG(&adapter->hw, E1000_WUC, 0);
e1000_led_off(&adapter->hw);
e1000_cleanup_led(&adapter->hw);
}
@ -4613,7 +4624,7 @@ igb_is_valid_ether_addr(uint8_t *addr)
/*
* Enable PCI Wake On Lan capability
*/
void
static void
igb_enable_wakeup(device_t dev)
{
u16 cap, status;
@ -4634,6 +4645,21 @@ igb_enable_wakeup(device_t dev)
return;
}
static void
igb_led_func(void *arg, int onoff)
{
struct adapter *adapter = arg;
IGB_CORE_LOCK(adapter);
if (onoff) {
e1000_setup_led(&adapter->hw);
e1000_led_on(&adapter->hw);
} else {
e1000_led_off(&adapter->hw);
e1000_cleanup_led(&adapter->hw);
}
IGB_CORE_UNLOCK(adapter);
}
/**********************************************************************
*

View File

@ -361,6 +361,7 @@ struct adapter {
struct e1000_osdep osdep;
struct device *dev;
struct cdev *led_dev;
struct resource *pci_mem;
struct resource *msix_mem;

View File

@ -79,6 +79,7 @@
#include <netinet/udp.h>
#include <machine/in_cksum.h>
#include <dev/led/led.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
@ -253,6 +254,7 @@ static void lem_release_hw_control(struct adapter *);
static void lem_get_wakeup(device_t);
static void lem_enable_wakeup(device_t);
static int lem_enable_phy_wakeup(struct adapter *);
static void lem_led_func(void *, int);
#ifdef EM_LEGACY_IRQ
static void lem_intr(void *);
@ -667,6 +669,9 @@ lem_attach(device_t dev)
/* Tell the stack that the interface is not active */
adapter->ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
adapter->led_dev = led_create(lem_led_func, adapter,
device_get_nameunit(dev));
INIT_DEBUGOUT("lem_attach: end");
return (0);
@ -722,6 +727,9 @@ lem_detach(device_t dev)
ether_poll_deregister(ifp);
#endif
if (adapter->led_dev != NULL)
led_destroy(adapter->led_dev);
EM_CORE_LOCK(adapter);
EM_TX_LOCK(adapter);
adapter->in_detach = 1;
@ -2252,6 +2260,9 @@ lem_stop(void *arg)
e1000_reset_hw(&adapter->hw);
if (adapter->hw.mac.type >= e1000_82544)
E1000_WRITE_REG(&adapter->hw, E1000_WUC, 0);
e1000_led_off(&adapter->hw);
e1000_cleanup_led(&adapter->hw);
}
@ -4126,7 +4137,7 @@ lem_get_wakeup(device_t dev)
/*
* Enable PCI Wake On Lan capability
*/
void
static void
lem_enable_wakeup(device_t dev)
{
struct adapter *adapter = device_get_softc(dev);
@ -4268,6 +4279,21 @@ out:
return ret;
}
static void
lem_led_func(void *arg, int onoff)
{
struct adapter *adapter = arg;
EM_CORE_LOCK(adapter);
if (onoff) {
e1000_setup_led(&adapter->hw);
e1000_led_on(&adapter->hw);
} else {
e1000_led_off(&adapter->hw);
e1000_cleanup_led(&adapter->hw);
}
EM_CORE_UNLOCK(adapter);
}
/*********************************************************************
* 82544 Coexistence issue workaround.

View File

@ -293,6 +293,7 @@ struct adapter {
/* FreeBSD operating-system-specific structures. */
struct e1000_osdep osdep;
struct device *dev;
struct cdev *led_dev;
struct resource *memory;
struct resource *flash;