From owner-p4-projects@FreeBSD.ORG Fri Aug 22 08:59:49 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D33961065671; Fri, 22 Aug 2008 08:59:48 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 96AEF106564A for ; Fri, 22 Aug 2008 08:59:48 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 848588FC1B for ; Fri, 22 Aug 2008 08:59:48 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m7M8xm27021510 for ; Fri, 22 Aug 2008 08:59:48 GMT (envelope-from ed@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m7M8xmch021508 for perforce@freebsd.org; Fri, 22 Aug 2008 08:59:48 GMT (envelope-from ed@FreeBSD.org) Date: Fri, 22 Aug 2008 08:59:48 GMT Message-Id: <200808220859.m7M8xmch021508@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to ed@FreeBSD.org using -f From: Ed Schouten To: Perforce Change Reviews Cc: Subject: PERFORCE change 148089 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Aug 2008 08:59:49 -0000 http://perforce.freebsd.org/chv.cgi?CH=148089 Change 148089 by ed@ed_dull on 2008/08/22 08:59:14 IFC my tty.c fix in -CURRENT. Affected files ... .. //depot/projects/mpsafetty/lib/libkvm/kvm_getpcpu.3#2 integrate .. //depot/projects/mpsafetty/sys/amd64/include/pci_cfgreg.h#2 integrate .. //depot/projects/mpsafetty/sys/amd64/pci/pci_cfgreg.c#2 integrate .. //depot/projects/mpsafetty/sys/compat/freebsd32/syscalls.master#4 integrate .. //depot/projects/mpsafetty/sys/dev/acpica/acpi.c#4 integrate .. //depot/projects/mpsafetty/sys/dev/bfe/if_bfe.c#5 integrate .. //depot/projects/mpsafetty/sys/dev/bfe/if_bfereg.h#4 integrate .. //depot/projects/mpsafetty/sys/dev/puc/pucdata.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/usb/umass.c#3 integrate .. //depot/projects/mpsafetty/sys/dev/usb/usbdevs#7 integrate .. //depot/projects/mpsafetty/sys/i386/include/pci_cfgreg.h#2 integrate .. //depot/projects/mpsafetty/sys/i386/pci/pci_cfgreg.c#4 integrate .. //depot/projects/mpsafetty/sys/kern/syscalls.master#4 integrate .. //depot/projects/mpsafetty/sys/kern/tty.c#29 integrate .. //depot/projects/mpsafetty/usr.bin/cpio/test/test_basic.c#2 integrate .. //depot/projects/mpsafetty/usr.bin/cpio/test/test_format_newc.c#2 integrate .. //depot/projects/mpsafetty/usr.bin/cpio/test/test_gcpio_compat.c#2 integrate .. //depot/projects/mpsafetty/usr.bin/cpio/test/test_option_a.c#2 integrate .. //depot/projects/mpsafetty/usr.bin/tar/Makefile#2 integrate .. //depot/projects/mpsafetty/usr.bin/tar/bsdtar.c#2 integrate .. //depot/projects/mpsafetty/usr.bin/tar/test/Makefile#2 integrate .. //depot/projects/mpsafetty/usr.bin/tar/test/test_option_q.c#1 branch .. //depot/projects/mpsafetty/usr.bin/tar/test/test_patterns.c#5 integrate .. //depot/projects/mpsafetty/usr.bin/tar/test/test_patterns_2.tgz.out.uu#3 delete Differences ... ==== //depot/projects/mpsafetty/lib/libkvm/kvm_getpcpu.3#2 (text+ko) ==== @@ -26,7 +26,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libkvm/kvm_getpcpu.3,v 1.1 2008/08/19 19:55:33 jhb Exp $ +.\" $FreeBSD: src/lib/libkvm/kvm_getpcpu.3,v 1.2 2008/08/21 19:22:13 jhb Exp $ .\" .Dd August 19, 2008 .Dt KVM_GETPCPU 3 @@ -71,6 +71,14 @@ is not active, then .Dv NULL is returned instead. +.Sh CACHING +These functions cache the nlist values for various kernel variables which are +reused in successive calls. +You may call either function with +.Fa kd +set to +.Dv NULL +to clear this cache. .Sh RETURN VALUES On success, the .Fn kvm_getmaxcpu ==== //depot/projects/mpsafetty/sys/amd64/include/pci_cfgreg.h#2 (text+ko) ==== @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/amd64/include/pci_cfgreg.h,v 1.14 2007/11/28 22:20:07 jhb Exp $ + * $FreeBSD: src/sys/amd64/include/pci_cfgreg.h,v 1.15 2008/08/22 02:14:23 jhb Exp $ * */ @@ -37,6 +37,7 @@ #define CONF1_ENABLE_MSK1 0x80000001ul #define CONF1_ENABLE_RES1 0x80000000ul +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); int pci_cfgregopen(void); u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); ==== //depot/projects/mpsafetty/sys/amd64/pci/pci_cfgreg.c#2 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/amd64/pci/pci_cfgreg.c,v 1.110 2007/11/28 22:20:08 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/pci/pci_cfgreg.c,v 1.111 2008/08/22 02:14:23 jhb Exp $"); #include #include @@ -36,11 +36,26 @@ #include #include #include +#include +#include #include +enum { + CFGMECH_NONE = 0, + CFGMECH_1, + CFGMECH_PCIE, +}; + +static int pciereg_cfgread(int bus, unsigned slot, unsigned func, + unsigned reg, unsigned bytes); +static void pciereg_cfgwrite(int bus, unsigned slot, unsigned func, + unsigned reg, int data, unsigned bytes); static int pcireg_cfgread(int bus, int slot, int func, int reg, int bytes); static void pcireg_cfgwrite(int bus, int slot, int func, int reg, int data, int bytes); +static int cfgmech; +static vm_offset_t pcie_base; +static int pcie_minbus, pcie_maxbus; static struct mtx pcicfg_mtx; /* @@ -49,12 +64,42 @@ int pci_cfgregopen(void) { - static int opened = 0; + uint64_t pciebar; + uint16_t did, vid; - if (opened) + if (cfgmech != CFGMECH_NONE) return (1); mtx_init(&pcicfg_mtx, "pcicfg", NULL, MTX_SPIN); - opened = 1; + cfgmech = CFGMECH_1; + + /* + * Grope around in the PCI config space to see if this is a + * chipset that is capable of doing memory-mapped config cycles. + * This also implies that it can do PCIe extended config cycles. + */ + + /* Check for supported chipsets */ + vid = pci_cfgregread(0, 0, 0, PCIR_VENDOR, 2); + did = pci_cfgregread(0, 0, 0, PCIR_DEVICE, 2); + switch (vid) { + case 0x8086: + switch (did) { + case 0x3590: + case 0x3592: + /* Intel 7520 or 7320 */ + pciebar = pci_cfgregread(0, 0, 0, 0xce, 2) << 16; + pcie_cfgregopen(pciebar, 0, 255); + break; + case 0x2580: + case 0x2584: + case 0x2590: + /* Intel 915, 925, or 915GM */ + pciebar = pci_cfgregread(0, 0, 0, 0x48, 4); + pcie_cfgregopen(pciebar, 0, 255); + break; + } + } + return (1); } @@ -130,6 +175,11 @@ int data = -1; int port; + if (cfgmech == CFGMECH_PCIE) { + data = pciereg_cfgread(bus, slot, func, reg, bytes); + return (data); + } + mtx_lock_spin(&pcicfg_mtx); port = pci_cfgenable(bus, slot, func, reg, bytes); if (port != 0) { @@ -155,6 +205,11 @@ { int port; + if (cfgmech == CFGMECH_PCIE) { + pciereg_cfgwrite(bus, slot, func, reg, data, bytes); + return; + } + mtx_lock_spin(&pcicfg_mtx); port = pci_cfgenable(bus, slot, func, reg, bytes); if (port != 0) { @@ -173,3 +228,82 @@ } mtx_unlock_spin(&pcicfg_mtx); } + +int +pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus) +{ + + if (minbus != 0) + return (0); + + if (bootverbose) + printf("PCIe: Memory Mapped configuration base @ 0x%lx\n", + base); + + /* XXX: We should make sure this really fits into the direct map. */ + pcie_base = (vm_offset_t)pmap_mapdev(base, (maxbus + 1) << 20); + pcie_minbus = minbus; + pcie_maxbus = maxbus; + cfgmech = CFGMECH_PCIE; + return (1); +} + +#define PCIE_VADDR(base, reg, bus, slot, func) \ + ((base) + \ + ((((bus) & 0xff) << 20) | \ + (((slot) & 0x1f) << 15) | \ + (((func) & 0x7) << 12) | \ + ((reg) & 0xfff))) + +static int +pciereg_cfgread(int bus, unsigned slot, unsigned func, unsigned reg, + unsigned bytes) +{ + volatile vm_offset_t va; + int data = -1; + + if (bus < pcie_minbus || bus > pcie_maxbus || slot >= 32 || + func > PCI_FUNCMAX || reg >= 0x1000) + return (-1); + + va = PCIE_VADDR(pcie_base, reg, bus, slot, func); + + switch (bytes) { + case 4: + data = *(volatile uint32_t *)(va); + break; + case 2: + data = *(volatile uint16_t *)(va); + break; + case 1: + data = *(volatile uint8_t *)(va); + break; + } + + return (data); +} + +static void +pciereg_cfgwrite(int bus, unsigned slot, unsigned func, unsigned reg, int data, + unsigned bytes) +{ + volatile vm_offset_t va; + + if (bus < pcie_minbus || bus > pcie_maxbus || slot >= 32 || + func > PCI_FUNCMAX || reg >= 0x1000) + return; + + va = PCIE_VADDR(pcie_base, reg, bus, slot, func); + + switch (bytes) { + case 4: + *(volatile uint32_t *)(va) = data; + break; + case 2: + *(volatile uint16_t *)(va) = data; + break; + case 1: + *(volatile uint8_t *)(va) = data; + break; + } +} ==== //depot/projects/mpsafetty/sys/compat/freebsd32/syscalls.master#4 (text+ko) ==== @@ -1,4 +1,4 @@ - $FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.102 2008/08/20 08:31:58 ed Exp $ + $FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.103 2008/08/21 22:57:31 obrien Exp $ ; from: @(#)syscalls.master 8.2 (Berkeley) 1/13/94 ; from: src/sys/kern/syscalls.master 1.107 ; @@ -31,6 +31,13 @@ ; NOSTD implemented but as a lkm that can be statically ; compiled in; sysent entry will be filled with lkmsys ; so the SYSCALL_MODULE macro works +; NOARGS same as STD except do not create structure in sys/sysproto.h +; NODEF same as STD except only have the entry in the syscall table +; added. Meaning - do do not create structure or function +; prototype in sys/sysproto.h +; NOPROTO same as STD except do not create structure or +; function prototype in sys/sysproto.h. Does add a +; definition to syscall.h besides adding a sysent. ; #ifdef's, etc. may be included, and are copied to the output files. ==== //depot/projects/mpsafetty/sys/dev/acpica/acpi.c#4 (text+ko) ==== @@ -28,7 +28,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi.c,v 1.250 2008/08/04 19:45:15 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi.c,v 1.251 2008/08/22 02:14:23 jhb Exp $"); #include "opt_acpi.h" #include @@ -48,6 +48,9 @@ #include #include +#if defined(__i386__) || defined(__amd64__) +#include +#endif #include #include #include @@ -152,6 +155,9 @@ char *buf, size_t buflen); static int acpi_child_pnpinfo_str_method(device_t acdev, device_t child, char *buf, size_t buflen); +#if defined(__i386__) || defined(__amd64__) +static void acpi_enable_pcie(void); +#endif static device_method_t acpi_methods[] = { /* Device interface */ @@ -448,6 +454,11 @@ goto out; } +#if defined(__i386__) || defined(__amd64__) + /* Handle MCFG table if present. */ + acpi_enable_pcie(); +#endif + /* Install the default address space handlers. */ status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, ACPI_ADR_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL); @@ -1466,6 +1477,36 @@ return_VALUE (result); } +#if defined(__i386__) || defined(__amd64__) +/* + * Look for a MCFG table. If it is present, use the settings for + * domain (segment) 0 to setup PCI config space access via the memory + * map. + */ +static void +acpi_enable_pcie(void) +{ + ACPI_TABLE_HEADER *hdr; + ACPI_MCFG_ALLOCATION *alloc, *end; + ACPI_STATUS status; + + status = AcpiGetTable(ACPI_SIG_MCFG, 1, &hdr); + if (ACPI_FAILURE(status)) + return; + + end = (ACPI_MCFG_ALLOCATION *)((char *)hdr + hdr->Length); + alloc = (ACPI_MCFG_ALLOCATION *)((ACPI_TABLE_MCFG *)hdr + 1); + while (alloc < end) { + if (alloc->PciSegment == 0) { + pcie_cfgregopen(alloc->Address, alloc->StartBusNumber, + alloc->EndBusNumber); + return; + } + alloc++; + } +} +#endif + /* * Scan all of the ACPI namespace and attach child devices. * ==== //depot/projects/mpsafetty/sys/dev/bfe/if_bfe.c#5 (text+ko) ==== @@ -26,7 +26,7 @@ #include -__FBSDID("$FreeBSD: src/sys/dev/bfe/if_bfe.c,v 1.51 2008/08/21 04:21:53 yongari Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/bfe/if_bfe.c,v 1.54 2008/08/22 06:46:55 yongari Exp $"); #include #include @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -125,6 +126,7 @@ static void bfe_dma_free (struct bfe_softc *sc); static void bfe_dma_map (void *, bus_dma_segment_t *, int, int); static void bfe_cam_write (struct bfe_softc *, u_char *, int); +static int sysctl_bfe_stats (SYSCTL_HANDLER_ARGS); static device_method_t bfe_methods[] = { /* Device interface */ @@ -473,6 +475,11 @@ goto fail; } + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, + "stats", CTLTYPE_INT | CTLFLAG_RW, sc, 0, sysctl_bfe_stats, + "I", "Statistics"); + /* Set up ifnet structure */ ifp = sc->bfe_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { @@ -542,6 +549,7 @@ if (device_is_attached(dev)) { BFE_LOCK(sc); + sc->bfe_flags |= BFE_FLAG_DETACH; bfe_stop(sc); BFE_UNLOCK(sc); callout_drain(&sc->bfe_stat_co); @@ -653,11 +661,18 @@ sc = device_get_softc(dev); mii = device_get_softc(sc->bfe_miibus); - if ((mii->mii_media_status & IFM_ACTIVE) != 0) { - if (IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) - sc->bfe_link = 1; - } else - sc->bfe_link = 0; + sc->bfe_flags &= ~BFE_FLAG_LINK; + if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == + (IFM_ACTIVE | IFM_AVALID)) { + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_10_T: + case IFM_100_TX: + sc->bfe_flags |= BFE_FLAG_LINK; + break; + default: + break; + } + } /* XXX Should stop Rx/Tx engine prior to touching MAC. */ val = CSR_READ_4(sc, BFE_TX_CTRL); @@ -869,7 +884,7 @@ static void bfe_clear_stats(struct bfe_softc *sc) { - u_long reg; + uint32_t reg; BFE_LOCK_ASSERT(sc); @@ -1074,6 +1089,8 @@ u_int32_t val; int i = 0; + BFE_LOCK_ASSERT(sc); + val = CSR_READ_4(sc, BFE_RXCONF); if (ifp->if_flags & IFF_PROMISC) @@ -1233,17 +1250,89 @@ static void bfe_stats_update(struct bfe_softc *sc) { - u_long reg; - u_int32_t *val; + struct bfe_hw_stats *stats; + struct ifnet *ifp; + uint32_t mib[BFE_MIB_CNT]; + uint32_t reg, *val; + + BFE_LOCK_ASSERT(sc); + + val = mib; + CSR_WRITE_4(sc, BFE_MIB_CTRL, BFE_MIB_CLR_ON_READ); + for (reg = BFE_TX_GOOD_O; reg <= BFE_TX_PAUSE; reg += 4) + *val++ = CSR_READ_4(sc, reg); + for (reg = BFE_RX_GOOD_O; reg <= BFE_RX_NPAUSE; reg += 4) + *val++ = CSR_READ_4(sc, reg); + + ifp = sc->bfe_ifp; + stats = &sc->bfe_stats; + /* Tx stat. */ + stats->tx_good_octets += mib[MIB_TX_GOOD_O]; + stats->tx_good_frames += mib[MIB_TX_GOOD_P]; + stats->tx_octets += mib[MIB_TX_O]; + stats->tx_frames += mib[MIB_TX_P]; + stats->tx_bcast_frames += mib[MIB_TX_BCAST]; + stats->tx_mcast_frames += mib[MIB_TX_MCAST]; + stats->tx_pkts_64 += mib[MIB_TX_64]; + stats->tx_pkts_65_127 += mib[MIB_TX_65_127]; + stats->tx_pkts_128_255 += mib[MIB_TX_128_255]; + stats->tx_pkts_256_511 += mib[MIB_TX_256_511]; + stats->tx_pkts_512_1023 += mib[MIB_TX_512_1023]; + stats->tx_pkts_1024_max += mib[MIB_TX_1024_MAX]; + stats->tx_jabbers += mib[MIB_TX_JABBER]; + stats->tx_oversize_frames += mib[MIB_TX_OSIZE]; + stats->tx_frag_frames += mib[MIB_TX_FRAG]; + stats->tx_underruns += mib[MIB_TX_URUNS]; + stats->tx_colls += mib[MIB_TX_TCOLS]; + stats->tx_single_colls += mib[MIB_TX_SCOLS]; + stats->tx_multi_colls += mib[MIB_TX_MCOLS]; + stats->tx_excess_colls += mib[MIB_TX_ECOLS]; + stats->tx_late_colls += mib[MIB_TX_LCOLS]; + stats->tx_deferrals += mib[MIB_TX_DEFERED]; + stats->tx_carrier_losts += mib[MIB_TX_CLOST]; + stats->tx_pause_frames += mib[MIB_TX_PAUSE]; + /* Rx stat. */ + stats->rx_good_octets += mib[MIB_RX_GOOD_O]; + stats->rx_good_frames += mib[MIB_RX_GOOD_P]; + stats->rx_octets += mib[MIB_RX_O]; + stats->rx_frames += mib[MIB_RX_P]; + stats->rx_bcast_frames += mib[MIB_RX_BCAST]; + stats->rx_mcast_frames += mib[MIB_RX_MCAST]; + stats->rx_pkts_64 += mib[MIB_RX_64]; + stats->rx_pkts_65_127 += mib[MIB_RX_65_127]; + stats->rx_pkts_128_255 += mib[MIB_RX_128_255]; + stats->rx_pkts_256_511 += mib[MIB_RX_256_511]; + stats->rx_pkts_512_1023 += mib[MIB_RX_512_1023]; + stats->rx_pkts_1024_max += mib[MIB_RX_1024_MAX]; + stats->rx_jabbers += mib[MIB_RX_JABBER]; + stats->rx_oversize_frames += mib[MIB_RX_OSIZE]; + stats->rx_frag_frames += mib[MIB_RX_FRAG]; + stats->rx_missed_frames += mib[MIB_RX_MISS]; + stats->rx_crc_align_errs += mib[MIB_RX_CRCA]; + stats->rx_runts += mib[MIB_RX_USIZE]; + stats->rx_crc_errs += mib[MIB_RX_CRC]; + stats->rx_align_errs += mib[MIB_RX_ALIGN]; + stats->rx_symbol_errs += mib[MIB_RX_SYM]; + stats->rx_pause_frames += mib[MIB_RX_PAUSE]; + stats->rx_control_frames += mib[MIB_RX_NPAUSE]; + + /* Update counters in ifnet. */ + ifp->if_opackets += (u_long)mib[MIB_TX_GOOD_P]; + ifp->if_collisions += (u_long)mib[MIB_TX_TCOLS]; + ifp->if_oerrors += (u_long)mib[MIB_TX_URUNS] + + (u_long)mib[MIB_TX_ECOLS] + + (u_long)mib[MIB_TX_DEFERED] + + (u_long)mib[MIB_TX_CLOST]; + + ifp->if_ipackets += (u_long)mib[MIB_RX_GOOD_P]; - val = &sc->bfe_hwstats.tx_good_octets; - for (reg = BFE_TX_GOOD_O; reg <= BFE_TX_PAUSE; reg += 4) { - *val++ += CSR_READ_4(sc, reg); - } - val = &sc->bfe_hwstats.rx_good_octets; - for (reg = BFE_RX_GOOD_O; reg <= BFE_RX_NPAUSE; reg += 4) { - *val++ += CSR_READ_4(sc, reg); - } + ifp->if_ierrors += mib[MIB_RX_JABBER] + + mib[MIB_RX_MISS] + + mib[MIB_RX_CRCA] + + mib[MIB_RX_USIZE] + + mib[MIB_RX_CRC] + + mib[MIB_RX_ALIGN] + + mib[MIB_RX_SYM]; } static void @@ -1275,7 +1364,6 @@ BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc->bfe_txmbuf_tag, r->bfe_map); - ifp->if_opackets++; m_freem(r->bfe_mbuf); r->bfe_mbuf = NULL; } @@ -1335,9 +1423,6 @@ /* flag an error and try again */ if ((len > ETHER_MAX_LEN+32) || (flags & BFE_RX_FLAG_ERRORS)) { - ifp->if_ierrors++; - if (flags & BFE_RX_FLAG_SERR) - ifp->if_collisions++; m_freem(m); continue; } @@ -1346,7 +1431,6 @@ m_adj(m, BFE_RX_OFFSET); m->m_len = m->m_pkthdr.len = len; - ifp->if_ipackets++; m->m_pkthdr.rcvif = ifp; BFE_UNLOCK(sc); (*ifp->if_input)(ifp, m); @@ -1365,30 +1449,37 @@ { struct bfe_softc *sc = xsc; struct ifnet *ifp; - u_int32_t istat, imask, flag; + u_int32_t istat; ifp = sc->bfe_ifp; BFE_LOCK(sc); istat = CSR_READ_4(sc, BFE_ISTAT); - imask = CSR_READ_4(sc, BFE_IMASK); /* * Defer unsolicited interrupts - This is necessary because setting the * chips interrupt mask register to 0 doesn't actually stop the * interrupts */ - istat &= imask; + istat &= BFE_IMASK_DEF; CSR_WRITE_4(sc, BFE_ISTAT, istat); CSR_READ_4(sc, BFE_ISTAT); /* not expecting this interrupt, disregard it */ - if (istat == 0) { + if (istat == 0 || (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { BFE_UNLOCK(sc); return; } + /* A packet was received */ + if (istat & BFE_ISTAT_RX) + bfe_rxeof(sc); + + /* A packet was sent */ + if (istat & BFE_ISTAT_TX) + bfe_txeof(sc); + if (istat & BFE_ISTAT_ERRORS) { if (istat & BFE_ISTAT_DSCE) { @@ -1405,30 +1496,12 @@ BFE_UNLOCK(sc); return; } - - flag = CSR_READ_4(sc, BFE_DMATX_STAT); - if (flag & BFE_STAT_EMASK) - ifp->if_oerrors++; - - flag = CSR_READ_4(sc, BFE_DMARX_STAT); - if (flag & BFE_RX_FLAG_ERRORS) - ifp->if_ierrors++; - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; bfe_init_locked(sc); } - /* A packet was received */ - if (istat & BFE_ISTAT_RX) - bfe_rxeof(sc); - - /* A packet was sent */ - if (istat & BFE_ISTAT_TX) - bfe_txeof(sc); - /* We have packets pending, fire them out */ - if (ifp->if_drv_flags & IFF_DRV_RUNNING && - !IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) bfe_start_locked(ifp); BFE_UNLOCK(sc); @@ -1551,7 +1624,7 @@ * or we have nothing to send. */ if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != - IFF_DRV_RUNNING || sc->bfe_link == 0) + IFF_DRV_RUNNING || (sc->bfe_flags & BFE_FLAG_LINK) == 0) return; for (queued = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd) && @@ -1649,7 +1722,7 @@ CSR_WRITE_4(sc, BFE_IMASK, BFE_IMASK_DEF); /* Clear link state and change media. */ - sc->bfe_link = 0; + sc->bfe_flags &= ~BFE_FLAG_LINK; mii_mediachg(mii); ifp->if_drv_flags |= IFF_DRV_RUNNING; @@ -1712,12 +1785,12 @@ switch (command) { case SIOCSIFFLAGS: BFE_LOCK(sc); - if (ifp->if_flags & IFF_UP) + if (ifp->if_flags & IFF_UP) { if (ifp->if_drv_flags & IFF_DRV_RUNNING) bfe_set_rx_mode(sc); - else + else if ((sc->bfe_flags & BFE_FLAG_DETACH) == 0) bfe_init_locked(sc); - else if (ifp->if_drv_flags & IFF_DRV_RUNNING) + } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) bfe_stop(sc); BFE_UNLOCK(sc); break; @@ -1791,7 +1864,7 @@ ifp = sc->bfe_ifp; ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); - sc->bfe_link = 0; + sc->bfe_flags &= ~BFE_FLAG_LINK; callout_stop(&sc->bfe_stat_co); sc->bfe_watchdog_timer = 0; @@ -1799,3 +1872,103 @@ bfe_tx_ring_free(sc); bfe_rx_ring_free(sc); } + +static int +sysctl_bfe_stats(SYSCTL_HANDLER_ARGS) +{ + struct bfe_softc *sc; + struct bfe_hw_stats *stats; + int error, result; + + result = -1; + error = sysctl_handle_int(oidp, &result, 0, req); + + if (error != 0 || req->newptr == NULL) + return (error); + + if (result != 1) + return (error); + + sc = (struct bfe_softc *)arg1; + stats = &sc->bfe_stats; + + printf("%s statistics:\n", device_get_nameunit(sc->bfe_dev)); + printf("Transmit good octets : %ju\n", + (uintmax_t)stats->tx_good_octets); + printf("Transmit good frames : %ju\n", + (uintmax_t)stats->tx_good_frames); + printf("Transmit octets : %ju\n", + (uintmax_t)stats->tx_octets); + printf("Transmit frames : %ju\n", + (uintmax_t)stats->tx_frames); + printf("Transmit broadcast frames : %ju\n", + (uintmax_t)stats->tx_bcast_frames); + printf("Transmit multicast frames : %ju\n", + (uintmax_t)stats->tx_mcast_frames); + printf("Transmit frames 64 bytes : %ju\n", + (uint64_t)stats->tx_pkts_64); + printf("Transmit frames 65 to 127 bytes : %ju\n", + (uint64_t)stats->tx_pkts_65_127); + printf("Transmit frames 128 to 255 bytes : %ju\n", + (uint64_t)stats->tx_pkts_128_255); + printf("Transmit frames 256 to 511 bytes : %ju\n", + (uint64_t)stats->tx_pkts_256_511); + printf("Transmit frames 512 to 1023 bytes : %ju\n", + (uint64_t)stats->tx_pkts_512_1023); + printf("Transmit frames 1024 to max bytes : %ju\n", + (uint64_t)stats->tx_pkts_1024_max); + printf("Transmit jabber errors : %u\n", stats->tx_jabbers); + printf("Transmit oversized frames : %ju\n", + (uint64_t)stats->tx_oversize_frames); + printf("Transmit fragmented frames : %ju\n", + (uint64_t)stats->tx_frag_frames); + printf("Transmit underruns : %u\n", stats->tx_colls); + printf("Transmit total collisions : %u\n", stats->tx_single_colls); + printf("Transmit single collisions : %u\n", stats->tx_single_colls); + printf("Transmit multiple collisions : %u\n", stats->tx_multi_colls); + printf("Transmit excess collisions : %u\n", stats->tx_excess_colls); + printf("Transmit late collisions : %u\n", stats->tx_late_colls); + printf("Transmit deferrals : %u\n", stats->tx_deferrals); + printf("Transmit carrier losts : %u\n", stats->tx_carrier_losts); + printf("Transmit pause frames : %u\n", stats->tx_pause_frames); + + printf("Receive good octets : %ju\n", + (uintmax_t)stats->rx_good_octets); + printf("Receive good frames : %ju\n", + (uintmax_t)stats->rx_good_frames); + printf("Receive octets : %ju\n", + (uintmax_t)stats->rx_octets); + printf("Receive frames : %ju\n", + (uintmax_t)stats->rx_frames); + printf("Receive broadcast frames : %ju\n", + (uintmax_t)stats->rx_bcast_frames); + printf("Receive multicast frames : %ju\n", + (uintmax_t)stats->rx_mcast_frames); + printf("Receive frames 64 bytes : %ju\n", + (uint64_t)stats->rx_pkts_64); + printf("Receive frames 65 to 127 bytes : %ju\n", + (uint64_t)stats->rx_pkts_65_127); + printf("Receive frames 128 to 255 bytes : %ju\n", + (uint64_t)stats->rx_pkts_128_255); + printf("Receive frames 256 to 511 bytes : %ju\n", + (uint64_t)stats->rx_pkts_256_511); + printf("Receive frames 512 to 1023 bytes : %ju\n", + (uint64_t)stats->rx_pkts_512_1023); + printf("Receive frames 1024 to max bytes : %ju\n", + (uint64_t)stats->rx_pkts_1024_max); + printf("Receive jabber errors : %u\n", stats->rx_jabbers); + printf("Receive oversized frames : %ju\n", + (uint64_t)stats->rx_oversize_frames); + printf("Receive fragmented frames : %ju\n", + (uint64_t)stats->rx_frag_frames); + printf("Receive missed frames : %u\n", stats->rx_missed_frames); + printf("Receive CRC align errors : %u\n", stats->rx_crc_align_errs); + printf("Receive undersized frames : %u\n", stats->rx_runts); + printf("Receive CRC errors : %u\n", stats->rx_crc_errs); + printf("Receive align errors : %u\n", stats->rx_align_errs); + printf("Receive symbol errors : %u\n", stats->rx_symbol_errs); + printf("Receive pause frames : %u\n", stats->rx_pause_frames); + printf("Receive control frames : %u\n", stats->rx_control_frames); + + return (error); +} ==== //depot/projects/mpsafetty/sys/dev/bfe/if_bfereg.h#4 (text+ko) ==== @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* $FreeBSD: src/sys/dev/bfe/if_bfereg.h,v 1.13 2008/08/21 04:21:53 yongari Exp $ */ +/* $FreeBSD: src/sys/dev/bfe/if_bfereg.h,v 1.15 2008/08/22 06:46:55 yongari Exp $ */ #ifndef _BFE_H #define _BFE_H @@ -479,25 +479,105 @@ u_int16_t pad[12]; }; +#define MIB_TX_GOOD_O 0 +#define MIB_TX_GOOD_P 1 +#define MIB_TX_O 2 +#define MIB_TX_P 3 +#define MIB_TX_BCAST 4 +#define MIB_TX_MCAST 5 +#define MIB_TX_64 6 +#define MIB_TX_65_127 7 +#define MIB_TX_128_255 8 +#define MIB_TX_256_511 9 +#define MIB_TX_512_1023 10 +#define MIB_TX_1024_MAX 11 +#define MIB_TX_JABBER 12 +#define MIB_TX_OSIZE 13 +#define MIB_TX_FRAG 14 +#define MIB_TX_URUNS 15 +#define MIB_TX_TCOLS 16 +#define MIB_TX_SCOLS 17 +#define MIB_TX_MCOLS 18 +#define MIB_TX_ECOLS 19 +#define MIB_TX_LCOLS 20 +#define MIB_TX_DEFERED 21 +#define MIB_TX_CLOST 22 +#define MIB_TX_PAUSE 23 +#define MIB_RX_GOOD_O 24 +#define MIB_RX_GOOD_P 25 +#define MIB_RX_O 26 +#define MIB_RX_P 27 +#define MIB_RX_BCAST 28 +#define MIB_RX_MCAST 29 +#define MIB_RX_64 30 +#define MIB_RX_65_127 31 +#define MIB_RX_128_255 32 +#define MIB_RX_256_511 33 +#define MIB_RX_512_1023 34 +#define MIB_RX_1024_MAX 35 +#define MIB_RX_JABBER 36 +#define MIB_RX_OSIZE 37 +#define MIB_RX_FRAG 38 +#define MIB_RX_MISS 39 +#define MIB_RX_CRCA 40 +#define MIB_RX_USIZE 41 +#define MIB_RX_CRC 42 +#define MIB_RX_ALIGN 43 +#define MIB_RX_SYM 44 +#define MIB_RX_PAUSE 45 +#define MIB_RX_NPAUSE 46 + +#define BFE_MIB_CNT (MIB_RX_NPAUSE - MIB_TX_GOOD_O + 1) + struct bfe_hw_stats { - u_int32_t tx_good_octets, tx_good_pkts, tx_octets; - u_int32_t tx_pkts, tx_broadcast_pkts, tx_multicast_pkts; - u_int32_t tx_len_64, tx_len_65_to_127, tx_len_128_to_255; - u_int32_t tx_len_256_to_511, tx_len_512_to_1023, tx_len_1024_to_max; - u_int32_t tx_jabber_pkts, tx_oversize_pkts, tx_fragment_pkts; - u_int32_t tx_underruns, tx_total_cols, tx_single_cols; - u_int32_t tx_multiple_cols, tx_excessive_cols, tx_late_cols; - u_int32_t tx_defered, tx_carrier_lost, tx_pause_pkts; - u_int32_t __pad1[8]; + uint64_t tx_good_octets; + uint64_t tx_good_frames; + uint64_t tx_octets; + uint64_t tx_frames; + uint64_t tx_bcast_frames; + uint64_t tx_mcast_frames; + uint64_t tx_pkts_64; + uint64_t tx_pkts_65_127; + uint64_t tx_pkts_128_255; + uint64_t tx_pkts_256_511; + uint64_t tx_pkts_512_1023; + uint64_t tx_pkts_1024_max; + uint32_t tx_jabbers; + uint64_t tx_oversize_frames; + uint64_t tx_frag_frames; + uint32_t tx_underruns; + uint32_t tx_colls; + uint32_t tx_single_colls; + uint32_t tx_multi_colls; + uint32_t tx_excess_colls; + uint32_t tx_late_colls; + uint32_t tx_deferrals; + uint32_t tx_carrier_losts; + uint32_t tx_pause_frames; - u_int32_t rx_good_octets, rx_good_pkts, rx_octets; - u_int32_t rx_pkts, rx_broadcast_pkts, rx_multicast_pkts; - u_int32_t rx_len_64, rx_len_65_to_127, rx_len_128_to_255; - u_int32_t rx_len_256_to_511, rx_len_512_to_1023, rx_len_1024_to_max; - u_int32_t rx_jabber_pkts, rx_oversize_pkts, rx_fragment_pkts; - u_int32_t rx_missed_pkts, rx_crc_align_errs, rx_undersize; - u_int32_t rx_crc_errs, rx_align_errs, rx_symbol_errs; - u_int32_t rx_pause_pkts, rx_nonpause_pkts; + uint64_t rx_good_octets; + uint64_t rx_good_frames; + uint64_t rx_octets; + uint64_t rx_frames; + uint64_t rx_bcast_frames; + uint64_t rx_mcast_frames; + uint64_t rx_pkts_64; + uint64_t rx_pkts_65_127; + uint64_t rx_pkts_128_255; + uint64_t rx_pkts_256_511; + uint64_t rx_pkts_512_1023; + uint64_t rx_pkts_1024_max; + uint32_t rx_jabbers; + uint64_t rx_oversize_frames; + uint64_t rx_frag_frames; + uint32_t rx_missed_frames; + uint32_t rx_crc_align_errs; + uint32_t rx_runts; + uint32_t rx_crc_errs; + uint32_t rx_align_errs; + uint32_t rx_symbol_errs; + uint32_t rx_pause_frames; + uint32_t rx_control_frames; }; struct bfe_softc @@ -515,18 +595,19 @@ struct resource *bfe_irq; struct resource *bfe_res; struct callout bfe_stat_co; - struct bfe_hw_stats bfe_hwstats; + struct bfe_hw_stats bfe_stats; struct bfe_desc *bfe_tx_list, *bfe_rx_list; struct bfe_tx_data bfe_tx_ring[BFE_TX_LIST_CNT]; /* XXX */ struct bfe_rx_data bfe_rx_ring[BFE_RX_LIST_CNT]; /* XXX */ struct mtx bfe_mtx; u_int32_t bfe_flags; +#define BFE_FLAG_DETACH 0x4000 +#define BFE_FLAG_LINK 0x8000 u_int32_t bfe_imask; u_int32_t bfe_dma_offset; u_int32_t bfe_tx_cnt, bfe_tx_cons, bfe_tx_prod; u_int32_t bfe_rx_prod, bfe_rx_cons; u_int32_t bfe_tx_dma, bfe_rx_dma; - u_int32_t bfe_link; int bfe_watchdog_timer; u_int8_t bfe_phyaddr; /* Address of the card's PHY */ u_int8_t bfe_mdc_port; ==== //depot/projects/mpsafetty/sys/dev/puc/pucdata.c#2 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/puc/pucdata.c,v 1.62 2008/05/29 07:15:52 mckusick Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/puc/pucdata.c,v 1.65 2008/08/22 00:13:17 thompsa Exp $"); /* * PCI "universal" communications card driver configuration data (used to @@ -626,6 +626,12 @@ PUC_PORT_2S, 0x10, 4, 0, }, + { 0x14d2, 0x8010, 0xffff, 0, + "VScom PCI-100L", + DEFAULT_RCLK * 8, + PUC_PORT_1S, 0x14, 0, 0, + }, + { 0x14d2, 0x8020, 0xffff, 0, "VScom PCI-200L", DEFAULT_RCLK * 8, @@ -694,6 +700,12 @@ PUC_PORT_4S, 0x10, 4, 0, }, + { 0x14db, 0x2152, 0xffff, 0, + "Avlab Low Profile PCI 4 Serial", >>> TRUNCATED FOR MAIL (1000 lines) <<<