Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Mar 2013 10:27:32 GMT
From:      Hielke Christian Braun <hcb@unco.de>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/177184: patch for bge network driver to enable wake on lan
Message-ID:  <201303211027.r2LARWel087918@red.freebsd.org>
Resent-Message-ID: <201303211030.r2LAU1ch046924@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         177184
>Category:       kern
>Synopsis:       patch for bge network driver to enable wake on lan
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 21 10:30:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Hielke Christian Braun
>Release:        9.1-RELEASE-p1
>Organization:
>Environment:
FreeBSD xxx 9.1-RELEASE-p1 FreeBSD 9.1-RELEASE-p1 #48: Fri Mar 15 01:09:33 CET 2013     root@freebsd:/usr/obj/nas4free/usr/src/sys/NAS4FREE-amd64  amd64
>Description:
Hello,

a patch to enable wake-on-lan (with magic packet) in the bge network driver. Maybe you can add it. Developed this for a HP ProLiant MicroServer N40L machine with a

bge0: <HP NC107i PCIe Gigabit Server Adapter, ASIC rev. 0x5784100> mem 0xfe9f0000-0xfe9fffff irq 18 at device 0.0 on pci2


Kind regards,
Christian. 
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- if_bge.c.orig       2013-03-13 23:42:26.000000000 +0100
+++ if_bge.c    2013-03-14 13:30:08.000000000 +0100
@@ -469,6 +469,7 @@
 static void bge_stop_fw(struct bge_softc *);
 static int bge_reset(struct bge_softc *);
 static void bge_link_upd(struct bge_softc *);
+static void bge_setwol(struct bge_softc *);

 /*
  * The BGE_REGISTER_DEBUG option is only for low-level debugging.  It may
@@ -3335,7 +3336,7 @@
        IFQ_SET_READY(&ifp->if_snd);
        ifp->if_hwassist = sc->bge_csum_features;
        ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_HWTAGGING |
-           IFCAP_VLAN_MTU;
+           IFCAP_VLAN_MTU | IFCAP_WOL_MAGIC;
        if ((sc->bge_flags & (BGE_FLAG_TSO | BGE_FLAG_TSO3)) != 0) {
                ifp->if_hwassist |= CSUM_TSO;
                ifp->if_capabilities |= IFCAP_TSO4 | IFCAP_VLAN_HWTSO;
@@ -5537,6 +5538,7 @@
        BGE_LOCK(sc);
        bge_stop(sc);
        bge_reset(sc);
+       bge_setwol(sc);
        BGE_UNLOCK(sc);

        return (0);
@@ -6206,3 +6208,34 @@
        }
        return (*func == NULL ? ENXIO : 0);
 }
+
+static void
+bge_setwol(struct bge_softc *sc)
+{
+       struct ifnet *ifp;
+       uint16_t pmstat;
+       int pmc;
+
+       ifp = sc->bge_ifp;
+
+       if ((ifp->if_capenable & IFCAP_WOL_MAGIC) == 0)
+           return;
+
+       if (pci_find_cap(sc->bge_dev, PCIY_PMG, &pmc) != 0)
+           return;
+
+       BGE_SETBIT(sc, BGE_MAC_MODE, BGE_MACMODE_MAGIC_PKT_ENB);
+
+       BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_PORTMODE);
+       BGE_SETBIT(sc, BGE_MAC_MODE, BGE_PORTMODE_GMII);
+
+       BGE_SETBIT(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE);
+
+       /* Request PME. */
+       pmstat = pci_read_config(sc->bge_dev,
+           pmc + PCIR_POWER_STATUS, 2);
+       pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
+       pci_write_config(sc->bge_dev,
+           pmc + PCIR_POWER_STATUS, pmstat, 2);
+}
+

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303211027.r2LARWel087918>