From owner-svn-src-head@FreeBSD.ORG Thu Nov 19 21:45:06 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AED4F1065696; Thu, 19 Nov 2009 21:45:06 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9C7B68FC17; Thu, 19 Nov 2009 21:45:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nAJLj6cf020457; Thu, 19 Nov 2009 21:45:06 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nAJLj6KD020454; Thu, 19 Nov 2009 21:45:06 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200911192145.nAJLj6KD020454@svn.freebsd.org> From: Pyun YongHyeon Date: Thu, 19 Nov 2009 21:45:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199552 - head/sys/dev/et X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2009 21:45:06 -0000 Author: yongari Date: Thu Nov 19 21:45:06 2009 New Revision: 199552 URL: http://svn.freebsd.org/changeset/base/199552 Log: Add MSI support. Modified: head/sys/dev/et/if_et.c head/sys/dev/et/if_etvar.h Modified: head/sys/dev/et/if_et.c ============================================================================== --- head/sys/dev/et/if_et.c Thu Nov 19 21:39:43 2009 (r199551) +++ head/sys/dev/et/if_et.c Thu Nov 19 21:45:06 2009 (r199552) @@ -76,6 +76,10 @@ MODULE_DEPEND(et, pci, 1, 1, 1); MODULE_DEPEND(et, ether, 1, 1, 1); MODULE_DEPEND(et, miibus, 1, 1, 1); +/* Tunables. */ +static int msi_disable = 0; +TUNABLE_INT("hw.re.msi_disable", &msi_disable); + static int et_probe(device_t); static int et_attach(device_t); static int et_detach(device_t); @@ -230,7 +234,7 @@ et_attach(device_t dev) struct et_softc *sc; struct ifnet *ifp; uint8_t eaddr[ETHER_ADDR_LEN]; - int error; + int cap, error, msic; sc = device_get_softc(dev); sc->dev = dev; @@ -268,13 +272,38 @@ et_attach(device_t dev) sc->sc_mem_bt = rman_get_bustag(sc->sc_mem_res); sc->sc_mem_bh = rman_get_bushandle(sc->sc_mem_res); + msic = 0; + if (pci_find_extcap(dev, PCIY_EXPRESS, &cap) == 0) { + sc->sc_expcap = cap; + sc->sc_flags |= ET_FLAG_PCIE; + msic = pci_msi_count(dev); + if (bootverbose) + device_printf(dev, "MSI count : %d\n", msic); + } + if (msic > 0 && msi_disable == 0) { + msic = 1; + if (pci_alloc_msi(dev, &msic) == 0) { + if (msic == 1) { + device_printf(dev, "Using %d MSI message\n", + msic); + sc->sc_flags |= ET_FLAG_MSI; + } else + pci_release_msi(dev); + } + } + /* * Allocate IRQ */ - sc->sc_irq_rid = 0; - sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &sc->sc_irq_rid, - RF_SHAREABLE | RF_ACTIVE); + if ((sc->sc_flags & ET_FLAG_MSI) == 0) { + sc->sc_irq_rid = 0; + sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, + &sc->sc_irq_rid, RF_SHAREABLE | RF_ACTIVE); + } else { + sc->sc_irq_rid = 1; + sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, + &sc->sc_irq_rid, RF_ACTIVE); + } if (sc->sc_irq_res == NULL) { device_printf(dev, "can't allocate irq\n"); error = ENXIO; @@ -323,8 +352,7 @@ et_attach(device_t dev) callout_init_mtx(&sc->sc_tick, &sc->sc_mtx, 0); error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_NET | INTR_MPSAFE, - NULL, et_intr, sc, &sc->sc_irq_handle); - + NULL, et_intr, sc, &sc->sc_irq_handle); if (error) { ether_ifdetach(ifp); device_printf(dev, "can't setup intr\n"); @@ -363,6 +391,8 @@ et_detach(device_t dev) bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irq_rid, sc->sc_irq_res); } + if ((sc->sc_flags & ET_FLAG_MSI) != 0) + pci_release_msi(dev); if (sc->sc_mem_res != NULL) { bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_mem_rid, @@ -1433,7 +1463,8 @@ et_chip_init(struct et_softc *sc) CSR_WRITE_4(sc, ET_LOOPBACK, 0); /* Clear MSI configure */ - CSR_WRITE_4(sc, ET_MSI_CFG, 0); + if ((sc->sc_flags & ET_FLAG_MSI) == 0) + CSR_WRITE_4(sc, ET_MSI_CFG, 0); /* Disable timer */ CSR_WRITE_4(sc, ET_TIMER, 0); Modified: head/sys/dev/et/if_etvar.h ============================================================================== --- head/sys/dev/et/if_etvar.h Thu Nov 19 21:39:43 2009 (r199551) +++ head/sys/dev/et/if_etvar.h Thu Nov 19 21:45:06 2009 (r199552) @@ -238,6 +238,7 @@ struct et_softc { struct arpcom arpcom; int sc_if_flags; uint32_t sc_flags; /* ET_FLAG_ */ + int sc_expcap; int sc_mem_rid; @@ -277,7 +278,9 @@ struct et_softc { #define ET_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) #define ET_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED) -#define ET_FLAG_TXRX_ENABLED 0x1 -#define ET_FLAG_JUMBO 0x2 +#define ET_FLAG_PCIE 0x0001 +#define ET_FLAG_MSI 0x0002 +#define ET_FLAG_TXRX_ENABLED 0x0100 +#define ET_FLAG_JUMBO 0x0200 #endif /* !_IF_ETVAR_H */