From owner-p4-projects Wed Jul 10 17: 6:17 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2807437B401; Wed, 10 Jul 2002 17:04:47 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B101037B400 for ; Wed, 10 Jul 2002 17:04:46 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id ABE2243E3B for ; Wed, 10 Jul 2002 17:04:44 -0700 (PDT) (envelope-from peter@freebsd.org) Received: from freefall.freebsd.org (perforce@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g6B04iJU073104 for ; Wed, 10 Jul 2002 17:04:44 -0700 (PDT) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g6B04iDC073101 for perforce@freebsd.org; Wed, 10 Jul 2002 17:04:44 -0700 (PDT) Date: Wed, 10 Jul 2002 17:04:44 -0700 (PDT) Message-Id: <200207110004.g6B04iDC073101@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm Subject: PERFORCE change 14063 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=14063 Change 14063 by peter@peter_daintree on 2002/07/10 17:04:18 IFC @14062 (catch up with locore.s) Affected files ... .. //depot/projects/pmap/sys/alpha/include/types.h#2 integrate .. //depot/projects/pmap/sys/arm/include/types.h#3 integrate .. //depot/projects/pmap/sys/boot/ofw/libofw/elf_freebsd.c#3 integrate .. //depot/projects/pmap/sys/boot/powerpc/loader/Makefile#3 integrate .. //depot/projects/pmap/sys/boot/powerpc/loader/metadata.c#1 branch .. //depot/projects/pmap/sys/conf/files.powerpc#4 integrate .. //depot/projects/pmap/sys/dev/gem/if_gem.c#3 integrate .. //depot/projects/pmap/sys/dev/gem/if_gem_pci.c#3 integrate .. //depot/projects/pmap/sys/dev/gem/if_gemreg.h#2 integrate .. //depot/projects/pmap/sys/dev/gem/if_gemvar.h#3 integrate .. //depot/projects/pmap/sys/dev/sio/sio_pci.c#4 integrate .. //depot/projects/pmap/sys/i386/i386/critical.c#2 integrate .. //depot/projects/pmap/sys/i386/i386/exception.s#6 integrate .. //depot/projects/pmap/sys/i386/i386/genassym.c#5 integrate .. //depot/projects/pmap/sys/i386/i386/locore.s#9 integrate .. //depot/projects/pmap/sys/i386/include/critical.h#2 integrate .. //depot/projects/pmap/sys/i386/include/proc.h#3 integrate .. //depot/projects/pmap/sys/i386/include/types.h#3 integrate .. //depot/projects/pmap/sys/i386/isa/ipl.s#3 delete .. //depot/projects/pmap/sys/ia64/include/types.h#3 integrate .. //depot/projects/pmap/sys/kern/kern_acct.c#5 integrate .. //depot/projects/pmap/sys/kern/vfs_bio.c#8 integrate .. //depot/projects/pmap/sys/kern/vfs_cluster.c#4 integrate .. //depot/projects/pmap/sys/kern/vfs_subr.c#7 integrate .. //depot/projects/pmap/sys/netkey/key.c#5 integrate .. //depot/projects/pmap/sys/nfsclient/nfs_bio.c#5 integrate .. //depot/projects/pmap/sys/nfsserver/nfs_serv.c#6 integrate .. //depot/projects/pmap/sys/powerpc/include/db_machdep.h#4 integrate .. //depot/projects/pmap/sys/powerpc/include/metadata.h#1 branch .. //depot/projects/pmap/sys/powerpc/include/setjmp.h#2 integrate .. //depot/projects/pmap/sys/powerpc/include/types.h#3 integrate .. //depot/projects/pmap/sys/powerpc/powermac/uninorth.c#2 integrate .. //depot/projects/pmap/sys/powerpc/powerpc/db_disasm.c#1 branch .. //depot/projects/pmap/sys/powerpc/powerpc/db_hwwatch.c#1 branch .. //depot/projects/pmap/sys/powerpc/powerpc/db_interface.c#1 branch .. //depot/projects/pmap/sys/powerpc/powerpc/db_memrw.c#1 branch .. //depot/projects/pmap/sys/powerpc/powerpc/db_trace.c#1 branch .. //depot/projects/pmap/sys/powerpc/powerpc/locore.s#5 integrate .. //depot/projects/pmap/sys/powerpc/powerpc/machdep.c#6 integrate .. //depot/projects/pmap/sys/powerpc/powerpc/nexus.c#2 integrate .. //depot/projects/pmap/sys/powerpc/powerpc/openpic.c#2 integrate .. //depot/projects/pmap/sys/powerpc/powerpc/setjmp.S#1 branch .. //depot/projects/pmap/sys/sparc64/include/types.h#2 integrate .. //depot/projects/pmap/sys/sys/buf.h#5 integrate .. //depot/projects/pmap/sys/sys/vnode.h#4 integrate .. //depot/projects/pmap/sys/x86_64/include/types.h#2 integrate Differences ... ==== //depot/projects/pmap/sys/alpha/include/types.h#2 (text+ko) ==== @@ -32,7 +32,7 @@ * * @(#)types.h 8.3 (Berkeley) 1/5/94 * $NetBSD: types.h,v 1.8 1997/04/06 08:47:45 cgd Exp $ - * $FreeBSD: src/sys/alpha/include/types.h,v 1.16 2001/12/09 19:12:05 obrien Exp $ + * $FreeBSD: src/sys/alpha/include/types.h,v 1.17 2002/07/10 15:47:57 mike Exp $ */ #ifndef _MACHTYPES_H_ @@ -40,16 +40,6 @@ #include -#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) -typedef struct _physadr { - long r[1]; -} *physadr; - -typedef struct label_t { - long val[10]; -} label_t; -#endif - typedef unsigned long vm_offset_t; typedef long vm_ooffset_t; typedef unsigned long vm_pindex_t; ==== //depot/projects/pmap/sys/arm/include/types.h#3 (text+ko) ==== @@ -31,22 +31,12 @@ * SUCH DAMAGE. * * @(#)types.h 8.3 (Berkeley) 1/5/94 - * $FreeBSD: src/sys/arm/include/types.h,v 1.4 2002/07/09 01:20:51 mike Exp $ + * $FreeBSD: src/sys/arm/include/types.h,v 1.5 2002/07/10 15:47:58 mike Exp $ */ #ifndef _MACHINE_TYPES_H_ #define _MACHINE_TYPES_H_ -#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) -typedef struct _physadr { - int r[1]; -} *physadr; - -typedef struct label_t { - int val[10]; -} label_t; -#endif - typedef unsigned int vm_offset_t; typedef __int64_t vm_ooffset_t; typedef __uint64_t vm_pindex_t; ==== //depot/projects/pmap/sys/boot/ofw/libofw/elf_freebsd.c#3 (text+ko) ==== @@ -23,15 +23,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/boot/ofw/libofw/elf_freebsd.c,v 1.2 2002/02/23 04:13:02 jake Exp $ + * $FreeBSD: src/sys/boot/ofw/libofw/elf_freebsd.c,v 1.3 2002/07/10 12:13:11 benno Exp $ */ #include #include -#if 0 -#include -#endif +#include #include #include @@ -65,51 +63,25 @@ int ofw_elf_exec(struct preloaded_file *fp) { - struct file_metadata *md; - Elf_Ehdr *ehdr; - vm_offset_t entry, bootinfop; - int boothowto, err, bootdev; -#if 0 - struct bootinfo *bi; -#endif - vm_offset_t ssym, esym; + struct file_metadata *fmp; + vm_offset_t mdp; + Elf_Ehdr *e; + int error; - if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) { - return(EFTYPE); /* XXX actually EFUCKUP */ + if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) { + return(EFTYPE); } - ehdr = (Elf_Ehdr *)&(md->md_data); + e = (Elf_Ehdr *)&fmp->md_data; -#if 0 - if ((err = bi_load(fp->f_args, &boothowto, &bootdev, &bootinfop)) != 0) - return(err); -#endif - entry = ehdr->e_entry & 0xffffff; + if ((error = md_load(fp->f_args, &mdp)) != 0) + return (error); - ssym = esym = 0; - if ((md = file_findmetadata(fp, MODINFOMD_SSYM)) != NULL) - ssym = *((vm_offset_t *)&(md->md_data)); - if ((md = file_findmetadata(fp, MODINFOMD_ESYM)) != NULL) - esym = *((vm_offset_t *)&(md->md_data)); - if (ssym == 0 || esym == 0) - ssym = esym = 0; /* sanity */ -#if 0 - bi = (struct bootinfo *)PTOV(bootinfop); - bi->bi_symtab = ssym; - bi->bi_esymtab = esym; -#endif - -/* -#ifdef DEBUG -*/ - printf("Start @ 0x%lx ...\n", entry); -/* -#endif -*/ + printf("Kernel entry at 0x%lx ...\n", e->e_entry); dev_cleanup(); ofw_release_heap(); -/* OF_chain(0, 0, entry, bootinfop, sizeof(struct bootinfo));*/ - OF_chain((void *)reloc, end - (char *)reloc, (void *)entry, NULL, 0); + OF_chain((void *)reloc, end - (char *)reloc, (void *)e->e_entry, + (void *)mdp, sizeof(mdp)); panic("exec returned"); } ==== //depot/projects/pmap/sys/boot/powerpc/loader/Makefile#3 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/boot/powerpc/loader/Makefile,v 1.9 2002/06/07 11:49:56 benno Exp $ +# $FreeBSD: src/sys/boot/powerpc/loader/Makefile,v 1.10 2002/07/10 12:13:16 benno Exp $ BASE= loader PROG= ${BASE} @@ -17,7 +17,7 @@ CFLAGS+= -DRELOC=${RELOC} # architecture-specific loader code -SRCS= conf.c +SRCS= conf.c metadata.c # Pull in common loader code .PATH: ${.CURDIR}/../../ofw/common ==== //depot/projects/pmap/sys/conf/files.powerpc#4 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.powerpc,v 1.17 2002/07/09 13:34:06 benno Exp $ +# $FreeBSD: src/sys/conf/files.powerpc,v 1.19 2002/07/10 12:26:10 benno Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -32,6 +32,7 @@ powerpc/powerpc/openpic.c standard powerpc/powerpc/pic_if.m standard powerpc/powerpc/pmap.c standard +powerpc/powerpc/setjmp.S standard powerpc/powerpc/sigcode.S standard powerpc/powerpc/suswintr.c standard powerpc/powerpc/syncicache.c standard @@ -42,6 +43,7 @@ powerpc/powerpc/db_disasm.c optional ddb powerpc/powerpc/db_interface.c optional ddb +powerpc/powerpc/db_hwwatch.c optional ddb powerpc/powerpc/db_memrw.c optional ddb powerpc/powerpc/db_trace.c optional ddb ==== //depot/projects/pmap/sys/dev/gem/if_gem.c#3 (text+ko) ==== @@ -23,9 +23,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: NetBSD: gem.c,v 1.9 2001/10/21 20:45:15 thorpej Exp + * from: NetBSD: gem.c,v 1.21 2002/06/01 23:50:58 lukem Exp * - * $FreeBSD: src/sys/dev/gem/if_gem.c,v 1.5 2002/05/24 12:47:41 tmm Exp $ + * $FreeBSD: src/sys/dev/gem/if_gem.c,v 1.6 2002/07/10 10:24:23 benno Exp $ */ /* @@ -124,6 +124,7 @@ struct ifnet *ifp = &sc->sc_arpcom.ac_if; struct mii_softc *child; int i, error; + u_int32_t v; /* Make sure the chip is stopped. */ ifp->if_softc = sc; @@ -228,7 +229,15 @@ device_printf(sc->sc_dev, "Ethernet address:"); for (i = 0; i < 6; i++) printf("%c%02x", i > 0 ? ':' : ' ', sc->sc_arpcom.ac_enaddr[i]); - printf("\n"); + + /* Get RX FIFO size */ + sc->sc_rxfifosize = 64 * + bus_space_read_4(sc->sc_bustag, sc->sc_h, GEM_RX_FIFO_SIZE); + printf(", %uKB RX fifo", sc->sc_rxfifosize / 1024); + + /* Get TX FIFO size */ + v = bus_space_read_4(sc->sc_bustag, sc->sc_h, GEM_TX_FIFO_SIZE); + printf(", %uKB TX fifo\n", v / 16); /* Initialize ifnet structure. */ ifp->if_softc = sc; @@ -416,6 +425,10 @@ CTR2(KTR_GEM, "txdma_cb: start of packet at seg %d, " "tx %d", seg, tx->txd_nexttx); flags |= GEM_TD_START_OF_PACKET; + if (++tx->txd_sc->sc_txwin > GEM_NTXSEGS * 2 / 3) { + tx->txd_sc->sc_txwin = 0; + flags |= GEM_TD_INTERRUPT_ME; + } } if ((tx->txd_flags & GTXD_LAST) != 0 && seg == nsegs - 1) { CTR2(KTR_GEM, "txdma_cb: end of packet at seg %d, " @@ -680,8 +693,9 @@ } GEM_CDTXSYNC(sc, 0, GEM_NTXDESC, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); - sc->sc_txfree = GEM_NTXDESC; + sc->sc_txfree = GEM_NTXDESC-1; sc->sc_txnext = 0; + sc->sc_txwin = 0; /* * Initialize the receive descriptor and receive job @@ -821,7 +835,8 @@ GEM_INTR_RX_TAG_ERR|GEM_INTR_PCS| GEM_INTR_MAC_CONTROL|GEM_INTR_MIF| GEM_INTR_BERR)); - bus_space_write_4(t, h, GEM_MAC_RX_MASK, 0); /* XXXX */ + bus_space_write_4(t, h, GEM_MAC_RX_MASK, + GEM_MAC_RX_DONE|GEM_MAC_RX_FRAME_CNT); bus_space_write_4(t, h, GEM_MAC_TX_MASK, 0xffff); /* XXXX */ bus_space_write_4(t, h, GEM_MAC_CONTROL_MASK, 0); /* XXXX */ @@ -844,14 +859,16 @@ (2<sc_rxfifosize / 256) | + ( (sc->sc_rxfifosize / 256) << 12)); + bus_space_write_4(t, h, GEM_RX_BLANKING, (6<<12)|6); /* step 11. Configure Media */ - (void)gem_mii_statchg(sc->sc_dev); + mii_mediachg(sc->sc_mii); /* step 12. RX_MAC Configuration Register */ v = bus_space_read_4(t, h, GEM_MAC_RX_CONFIG); @@ -873,7 +890,7 @@ ifp->if_flags |= IFF_RUNNING; ifp->if_flags &= ~IFF_OACTIVE; ifp->if_timer = 0; - sc->sc_flags = ifp->if_flags; + sc->sc_ifflags = ifp->if_flags; splx(s); } @@ -1005,12 +1022,12 @@ gem_init_regs(sc) struct gem_softc *sc; { - struct ifnet *ifp = &sc->sc_arpcom.ac_if; bus_space_tag_t t = sc->sc_bustag; bus_space_handle_t h = sc->sc_h; + const u_char *laddr = sc->sc_arpcom.ac_enaddr; + u_int32_t v; /* These regs are not cleared on reset */ - sc->sc_inited = 0; if (!sc->sc_inited) { /* Wooo. Magic values. */ @@ -1021,20 +1038,22 @@ bus_space_write_4(t, h, GEM_MAC_MAC_MIN_FRAME, ETHER_MIN_LEN); /* Max frame and max burst size */ bus_space_write_4(t, h, GEM_MAC_MAC_MAX_FRAME, - (ifp->if_mtu+18) | (0x2000<<16)/* Burst size */); + ETHER_MAX_LEN | (0x2000<<16)); + bus_space_write_4(t, h, GEM_MAC_PREAMBLE_LEN, 0x7); bus_space_write_4(t, h, GEM_MAC_JAM_SIZE, 0x4); bus_space_write_4(t, h, GEM_MAC_ATTEMPT_LIMIT, 0x10); /* Dunno.... */ bus_space_write_4(t, h, GEM_MAC_CONTROL_TYPE, 0x8088); bus_space_write_4(t, h, GEM_MAC_RANDOM_SEED, - ((sc->sc_arpcom.ac_enaddr[5]<<8)| - sc->sc_arpcom.ac_enaddr[4])&0x3ff); + ((laddr[5]<<8)|laddr[4])&0x3ff); + /* Secondary MAC addr set to 0:0:0:0:0:0 */ bus_space_write_4(t, h, GEM_MAC_ADDR3, 0); bus_space_write_4(t, h, GEM_MAC_ADDR4, 0); bus_space_write_4(t, h, GEM_MAC_ADDR5, 0); - /* MAC control addr set to 0:1:c2:0:1:80 */ + + /* MAC control addr set to 01:80:c2:00:00:01 */ bus_space_write_4(t, h, GEM_MAC_ADDR6, 0x0001); bus_space_write_4(t, h, GEM_MAC_ADDR7, 0xc200); bus_space_write_4(t, h, GEM_MAC_ADDR8, 0x0180); @@ -1073,12 +1092,21 @@ /* * Set the station address. */ - bus_space_write_4(t, h, GEM_MAC_ADDR0, - (sc->sc_arpcom.ac_enaddr[4]<<8) | sc->sc_arpcom.ac_enaddr[5]); - bus_space_write_4(t, h, GEM_MAC_ADDR1, - (sc->sc_arpcom.ac_enaddr[2]<<8) | sc->sc_arpcom.ac_enaddr[3]); - bus_space_write_4(t, h, GEM_MAC_ADDR2, - (sc->sc_arpcom.ac_enaddr[0]<<8) | sc->sc_arpcom.ac_enaddr[1]); + bus_space_write_4(t, h, GEM_MAC_ADDR0, (laddr[4]<<8)|laddr[5]); + bus_space_write_4(t, h, GEM_MAC_ADDR1, (laddr[2]<<8)|laddr[3]); + bus_space_write_4(t, h, GEM_MAC_ADDR2, (laddr[0]<<8)|laddr[1]); + + /* + * Enable MII outputs. Enable GMII if there is a gigabit PHY. + */ + sc->sc_mif_config = bus_space_read_4(t, h, GEM_MIF_CONFIG); + v = GEM_MAC_XIF_TX_MII_ENA; + if (sc->sc_mif_config & GEM_MIF_CONFIG_MDI1) { + v |= GEM_MAC_XIF_FDPLX_LED; + if (sc->sc_flags & GEM_GIGABIT) + v |= GEM_MAC_XIF_GMII_MODE; + } + bus_space_write_4(t, h, GEM_MAC_XIF_CONFIG, v); } static void @@ -1271,6 +1299,7 @@ bus_space_handle_t mac = sc->sc_h; struct gem_txsoft *txs; int txlast; + int progress = 0; DPRINTF(sc, ("%s: gem_tint\n", device_get_name(sc->sc_dev))); @@ -1360,6 +1389,7 @@ STAILQ_INSERT_TAIL(&sc->sc_txfreeq, txs, txs_q); ifp->if_opackets++; + progress = 1; } DPRINTF(sc, ("gem_tint: GEM_TX_STATE_MACHINE %x " @@ -1381,18 +1411,22 @@ GEM_TX_DATA_PTR_LO), bus_space_read_4(sc->sc_bustag, sc->sc_h, GEM_TX_COMPLETION)); - if (STAILQ_FIRST(&sc->sc_txdirtyq) == NULL) - ifp->if_timer = 0; + if (progress) { + if (sc->sc_txfree == GEM_NTXDESC - 1) + sc->sc_txwin = 0; + + /* Freed some descriptors, so reset IFF_OACTIVE and restart. */ + ifp->if_flags &= ~IFF_OACTIVE; + gem_start(ifp); + if (STAILQ_EMPTY(&sc->sc_txdirtyq)) + ifp->if_timer = 0; + } DPRINTF(sc, ("%s: gem_tint: watchdog %d\n", device_get_name(sc->sc_dev), ifp->if_timer)); CTR2(KTR_GEM, "%s: gem_tint: watchdog %d", device_get_name(sc->sc_dev), ifp->if_timer); - - /* Freed some descriptors, so reset IFF_OACTIVE and restart. */ - ifp->if_flags &= ~IFF_OACTIVE; - gem_start(ifp); } static void @@ -1417,19 +1451,27 @@ struct gem_rxsoft *rxs; struct mbuf *m; u_int64_t rxstat; - int i, len; + u_int32_t rxcomp; + int i, len, progress = 0; callout_stop(&sc->sc_rx_ch); DPRINTF(sc, ("%s: gem_rint\n", device_get_name(sc->sc_dev))); CTR1(KTR_GEM, "%s: gem_rint", device_get_name(sc->sc_dev)); + /* + * Read the completion register once. This limits + * how long the following loop can execute. + */ + rxcomp = bus_space_read_4(t, h, GEM_RX_COMPLETION); + + /* * XXXX Read the lastrx only once at the top for speed. */ DPRINTF(sc, ("gem_rint: sc->rxptr %d, complete %d\n", - sc->sc_rxptr, bus_space_read_4(t, h, GEM_RX_COMPLETION))); + sc->sc_rxptr, rxcomp)); CTR2(KTR_GEM, "gem_rint: sc->rxptr %d, complete %d", - sc->sc_rxptr, bus_space_read_4(t, h, GEM_RX_COMPLETION)); - for (i = sc->sc_rxptr; i != bus_space_read_4(t, h, GEM_RX_COMPLETION); + sc->sc_rxptr, rxcomp); + for (i = sc->sc_rxptr; i != rxcomp; i = GEM_NEXTRX(i)) { rxs = &sc->sc_rxsoft[i]; @@ -1439,6 +1481,7 @@ rxstat = GEM_DMA_READ(sc, sc->sc_rxdescs[i].gd_flags); if (rxstat & GEM_RD_OWN) { +#if 0 /* XXX: In case of emergency, re-enable this. */ /* * The descriptor is still marked as owned, although * it is supposed to have completed. This has been @@ -1449,10 +1492,15 @@ */ callout_reset(&sc->sc_rx_ch, GEM_RXOWN_TICKS, gem_rint_timeout, sc); +#endif break; } + progress++; + ifp->if_ipackets++; + if (rxstat & GEM_RD_BAD_CRC) { + ifp->if_ierrors++; device_printf(sc->sc_dev, "receive error: CRC error\n"); GEM_INIT_RXDESC(sc, i); continue; @@ -1491,7 +1539,6 @@ } m->m_data += 2; /* We're already off by two */ - ifp->if_ipackets++; eh = mtod(m, struct ether_header *); m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = len - ETHER_CRC_LEN; @@ -1501,9 +1548,14 @@ ether_input(ifp, eh, m); } - /* Update the receive pointer. */ - sc->sc_rxptr = i; - bus_space_write_4(t, h, GEM_RX_KICK, i); + if (progress) { + /* Update the receive pointer. */ + if (i == sc->sc_rxptr) { + device_printf(sc->sc_dev, "rint: ring wrap\n"); + } + sc->sc_rxptr = i; + bus_space_write_4(t, h, GEM_RX_KICK, GEM_PREVRX(i)); + } DPRINTF(sc, ("gem_rint: done sc->rxptr %d, complete %d\n", sc->sc_rxptr, bus_space_read_4(t, h, GEM_RX_COMPLETION))); @@ -1609,14 +1661,16 @@ if (status & GEM_INTR_TX_MAC) { int txstat = bus_space_read_4(t, seb, GEM_MAC_TX_STATUS); if (txstat & ~GEM_MAC_TX_XMIT_DONE) - printf("MAC tx fault, status %x\n", txstat); + device_printf(sc->sc_dev, "MAC tx fault, status %x\n", + txstat); if (txstat & (GEM_MAC_TX_UNDERRUN | GEM_MAC_TX_PKT_TOO_LONG)) gem_init(sc); } if (status & GEM_INTR_RX_MAC) { int rxstat = bus_space_read_4(t, seb, GEM_MAC_RX_STATUS); if (rxstat & ~(GEM_MAC_RX_DONE | GEM_MAC_RX_FRAME_CNT)) - printf("MAC rx fault, status %x\n", rxstat); + device_printf(sc->sc_dev, "MAC rx fault, status %x\n", + rxstat); if ((rxstat & GEM_MAC_RX_OVERFLOW) != 0) gem_init(sc); } @@ -1800,6 +1854,7 @@ v = bus_space_read_4(t, mac, GEM_MAC_XIF_CONFIG); v = GEM_MAC_XIF_LINK_LED; v |= GEM_MAC_XIF_TX_MII_ENA; + /* If an external transceiver is connected, enable its MII drivers */ sc->sc_mif_config = bus_space_read_4(t, mac, GEM_MIF_CONFIG); if ((sc->sc_mif_config & GEM_MIF_CONFIG_MDI1) != 0) { @@ -1807,9 +1862,14 @@ if ((IFM_OPTIONS(sc->sc_mii->mii_media_active) & IFM_FDX) != 0) /* turn on full duplex LED */ v |= GEM_MAC_XIF_FDPLX_LED; - else - /* half duplex -- disable echo */ - v |= GEM_MAC_XIF_ECHO_DISABL; + else + /* half duplex -- disable echo */ + v |= GEM_MAC_XIF_ECHO_DISABL; + + if (IFM_SUBTYPE(sc->sc_mii->mii_media_active) == IFM_1000_T) + v |= GEM_MAC_XIF_GMII_MODE; + else + v &= ~GEM_MAC_XIF_GMII_MODE; } else { /* Internal MII needs buf enable */ v |= GEM_MAC_XIF_MII_BUF_ENA; @@ -1864,7 +1924,7 @@ break; case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { - if ((sc->sc_flags ^ ifp->if_flags) == IFF_PROMISC) + if ((sc->sc_ifflags ^ ifp->if_flags) == IFF_PROMISC) gem_setladrf(sc); else gem_init(sc); @@ -1872,7 +1932,7 @@ if (ifp->if_flags & IFF_RUNNING) gem_stop(ifp, 0); } - sc->sc_flags = ifp->if_flags; + sc->sc_ifflags = ifp->if_flags; error = 0; break; case SIOCADDMULTI: @@ -1913,38 +1973,42 @@ u_int32_t hash[16]; u_int32_t v; int len; - - /* Clear hash table */ - memset(hash, 0, sizeof(hash)); + int i; /* Get current RX configuration */ v = bus_space_read_4(t, h, GEM_MAC_RX_CONFIG); + /* + * Turn off promiscuous mode, promiscuous group mode (all multicast), + * and hash filter. Depending on the case, the right bit will be + * enabled. + */ + v &= ~(GEM_MAC_RX_PROMISCUOUS|GEM_MAC_RX_HASH_FILTER| + GEM_MAC_RX_PROMISC_GRP); + if ((ifp->if_flags & IFF_PROMISC) != 0) { - /* Turn on promiscuous mode; turn off the hash filter */ + /* Turn on promiscuous mode */ v |= GEM_MAC_RX_PROMISCUOUS; - v &= ~GEM_MAC_RX_HASH_FILTER; - ; goto chipit; } if ((ifp->if_flags & IFF_ALLMULTI) != 0) { hash[3] = hash[2] = hash[1] = hash[0] = 0xffff; ifp->if_flags |= IFF_ALLMULTI; + v |= GEM_MAC_RX_PROMISC_GRP; goto chipit; } - /* Turn off promiscuous mode; turn on the hash filter */ - v &= ~GEM_MAC_RX_PROMISCUOUS; - v |= GEM_MAC_RX_HASH_FILTER; - /* * Set up multicast address filter by passing all multicast addresses - * through a crc generator, and then using the high order 6 bits as an - * index into the 256 bit logical address filter. The high order bit - * selects the word, while the rest of the bits select the bit within - * the word. + * through a crc generator, and then using the high order 8 bits as an + * index into the 256 bit logical address filter. The high order 4 + * bits selects the word, while the other 4 bits select the bit within + * the word (where bit 0 is the MSB). */ + /* Clear hash table */ + memset(hash, 0, sizeof(hash)); + TAILQ_FOREACH(inm, &sc->sc_arpcom.ac_if.if_multiaddrs, ifma_link) { if (inm->ifma_addr->sa_family != AF_LINK) continue; @@ -1970,28 +2034,20 @@ crc >>= 24; /* Set the corresponding bit in the filter. */ - hash[crc >> 4] |= 1 << (crc & 0xf); + hash[crc >> 4] |= 1 << (15 - (crc & 15)); + } + + v |= GEM_MAC_RX_HASH_FILTER; + ifp->if_flags &= ~IFF_ALLMULTI; + + /* Now load the hash table into the chip (if we are using it) */ + for (i = 0; i < 16; i++) { + bus_space_write_4(t, h, + GEM_MAC_HASH0 + i * (GEM_MAC_HASH1-GEM_MAC_HASH0), + hash[i]); } chipit: - /* Now load the hash table into the chip */ - bus_space_write_4(t, h, GEM_MAC_HASH0, hash[0]); - bus_space_write_4(t, h, GEM_MAC_HASH1, hash[1]); - bus_space_write_4(t, h, GEM_MAC_HASH2, hash[2]); - bus_space_write_4(t, h, GEM_MAC_HASH3, hash[3]); - bus_space_write_4(t, h, GEM_MAC_HASH4, hash[4]); - bus_space_write_4(t, h, GEM_MAC_HASH5, hash[5]); - bus_space_write_4(t, h, GEM_MAC_HASH6, hash[6]); - bus_space_write_4(t, h, GEM_MAC_HASH7, hash[7]); - bus_space_write_4(t, h, GEM_MAC_HASH8, hash[8]); - bus_space_write_4(t, h, GEM_MAC_HASH9, hash[9]); - bus_space_write_4(t, h, GEM_MAC_HASH10, hash[10]); - bus_space_write_4(t, h, GEM_MAC_HASH11, hash[11]); - bus_space_write_4(t, h, GEM_MAC_HASH12, hash[12]); - bus_space_write_4(t, h, GEM_MAC_HASH13, hash[13]); - bus_space_write_4(t, h, GEM_MAC_HASH14, hash[14]); - bus_space_write_4(t, h, GEM_MAC_HASH15, hash[15]); - bus_space_write_4(t, h, GEM_MAC_RX_CONFIG, v); } ==== //depot/projects/pmap/sys/dev/gem/if_gem_pci.c#3 (text+ko) ==== @@ -26,7 +26,7 @@ * * from: NetBSD: if_gem_pci.c,v 1.7 2001/10/18 15:09:15 thorpej Exp * - * $FreeBSD: src/sys/dev/gem/if_gem_pci.c,v 1.4 2002/03/20 02:07:21 alfred Exp $ + * $FreeBSD: src/sys/dev/gem/if_gem_pci.c,v 1.5 2002/07/10 10:24:23 benno Exp $ */ /* @@ -107,12 +107,13 @@ struct gem_pci_dev { u_int32_t gpd_devid; + int gpd_variant; char *gpd_desc; } gem_pci_devlist[] = { - { 0x1101108e, "Sun ERI 10/100 Ethernet Adaptor" }, - { 0x2bad108e, "Sun GEM Gigabit Ethernet Adaptor" }, - { 0x0021106b, "Apple GMAC Ethernet Adaptor" }, - { 0x0024106b, "Apple GMAC2 Ethernet Adaptor" }, + { 0x1101108e, GEM_SUN_GEM, "Sun ERI 10/100 Ethernet Adaptor" }, + { 0x2bad108e, GEM_SUN_GEM, "Sun GEM Gigabit Ethernet Adaptor" }, + { 0x0021106b, GEM_APPLE_GMAC, "Apple GMAC Ethernet Adaptor" }, + { 0x0024106b, GEM_APPLE_GMAC, "Apple GMAC2 Ethernet Adaptor" }, { 0, NULL } }; @@ -125,11 +126,15 @@ { int i; u_int32_t devid; + struct gem_pci_softc *gsc; devid = pci_get_devid(dev); for (i = 0; gem_pci_devlist[i].gpd_desc != NULL; i++) { if (devid == gem_pci_devlist[i].gpd_devid) { device_set_desc(dev, gem_pci_devlist[i].gpd_desc); + gsc = device_get_softc(dev); + gsc->gsc_gem.sc_variant = + gem_pci_devlist[i].gpd_variant; return (0); } } ==== //depot/projects/pmap/sys/dev/gem/if_gemreg.h#2 (text+ko) ==== @@ -24,9 +24,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: NetBSD: gemreg.h,v 1.2 2001/10/18 03:33:33 thorpej Exp + * from: NetBSD: gemreg.h,v 1.15 2002/05/11 00:36:02 matt Exp * - * $FreeBSD: src/sys/dev/gem/if_gemreg.h,v 1.1 2002/02/27 17:41:06 tmm Exp $ + * $FreeBSD: src/sys/dev/gem/if_gemreg.h,v 1.2 2002/07/10 10:24:23 benno Exp $ */ #ifndef _IF_GEMREG_H @@ -205,13 +205,14 @@ /* GEM_RX_PAUSE_THRESH register bits -- sizes in multiples of 64 bytes */ #define GEM_RX_PTH_XOFF_THRESH 0x000001ff -#define GEM_RX_PTH_XON_THRESH 0x07fc0000 +#define GEM_RX_PTH_XON_THRESH 0x001ff000 /* GEM_RX_BLANKING register bits */ #define GEM_RX_BLANKING_PACKETS 0x000001ff /* Delay intr for x packets */ -#define GEM_RX_BLANKING_TIME 0x03fc0000 /* Delay intr for x ticks */ -/* One tick is 1048 PCI clocs, or 16us at 66MHz */ +#define GEM_RX_BLANKING_TIME 0x000ff000 /* Delay intr for x ticks */ +#define GEM_RX_BLANKING_TIME_SHIFT 12 +/* One tick is 2048 PCI clocks, or 16us at 66MHz */ /* GEM_MAC registers */ @@ -324,7 +325,7 @@ #define GEM_MAC_XIF_TX_MII_ENA 0x00000001 /* Enable XIF output drivers */ #define GEM_MAC_XIF_MII_LOOPBK 0x00000002 /* Enable MII loopback mode */ #define GEM_MAC_XIF_ECHO_DISABL 0x00000004 /* Disable echo */ -#define GEM_MAC_XIF_MII_MODE 0x00000008 /* Select GMII/MII mode */ +#define GEM_MAC_XIF_GMII_MODE 0x00000008 /* Select GMII/MII mode */ #define GEM_MAC_XIF_MII_BUF_ENA 0x00000010 /* Enable MII recv buffers */ #define GEM_MAC_XIF_LINK_LED 0x00000020 /* force link LED active */ #define GEM_MAC_XIF_FDPLX_LED 0x00000040 /* force FDPLX LED active */ ==== //depot/projects/pmap/sys/dev/gem/if_gemvar.h#3 (text+ko) ==== @@ -23,9 +23,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: NetBSD: gemvar.h,v 1.5 2001/10/18 15:19:22 thorpej Exp + * from: NetBSD: gemvar.h,v 1.8 2002/05/15 02:36:12 matt Exp * - * $FreeBSD: src/sys/dev/gem/if_gemvar.h,v 1.3 2002/03/23 19:43:15 tmm Exp $ + * $FreeBSD: src/sys/dev/gem/if_gemvar.h,v 1.4 2002/07/10 10:24:23 benno Exp $ */ #ifndef _IF_GEMVAR_H @@ -57,6 +57,7 @@ */ #define GEM_NRXDESC 128 #define GEM_NRXDESC_MASK (GEM_NRXDESC - 1) +#define GEM_PREVRX(x) ((x - 1) & GEM_NRXDESC_MASK) #define GEM_NEXTRX(x) ((x + 1) & GEM_NRXDESC_MASK) /* @@ -153,6 +154,13 @@ int sc_mif_config; /* Selected MII reg setting */ int sc_pci; /* XXXXX -- PCI buses are LE. */ + u_int sc_variant; /* which GEM are we dealing with? */ +#define GEM_UNKNOWN 0 /* don't know */ +#define GEM_SUN_GEM 1 /* Sun GEM variant */ +#define GEM_APPLE_GMAC 2 /* Apple GMAC variant */ + + u_int sc_flags; /* */ +#define GEM_GIGABIT 0x0001 /* has a gigabit PHY */ /* * Ring buffer DMA stuff. @@ -177,16 +185,18 @@ int sc_txfree; /* number of free Tx descriptors */ int sc_txnext; /* next ready Tx descriptor */ + int sc_txwin; /* Tx descriptors since last Tx int */ struct gem_txsq sc_txfreeq; /* free Tx descsofts */ struct gem_txsq sc_txdirtyq; /* dirty Tx descsofts */ int sc_rxptr; /* next ready RX descriptor/descsoft */ + int sc_rxfifosize; /* Rx FIFO size (bytes) */ /* ========== */ int sc_inited; int sc_debug; - int sc_flags; + int sc_ifflags; /* Special hardware hooks */ void (*sc_hwreset)(struct gem_softc *); ==== //depot/projects/pmap/sys/dev/sio/sio_pci.c#4 (text+ko) ==== @@ -21,7 +21,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/dev/sio/sio_pci.c,v 1.7 2002/03/20 19:38:26 jhb Exp $ + * $FreeBSD: src/sys/dev/sio/sio_pci.c,v 1.8 2002/07/10 17:26:11 sobomax Exp $ */ #include @@ -76,6 +76,7 @@ { 0x7101135e, "SeaLevel Ultra 530.PCI Single Port Serial", 0x18 }, { 0x0000151f, "SmartLink 5634PCV SurfRider", 0x10 }, { 0x0103115d, "Xircom Cardbus modem", 0x10 }, + { 0x98459710, "Netmos Nm9845 PCI Bridge with Dual UART", 0x10 }, { 0x00000000, NULL, 0 } }; ==== //depot/projects/pmap/sys/i386/i386/critical.c#2 (text+ko) ==== @@ -2,7 +2,7 @@ * Copyright (c) 2001 Matthew Dillon. This code is distributed under * the BSD copyright, /usr/src/COPYRIGHT. * - * $FreeBSD: src/sys/i386/i386/critical.c,v 1.3 2002/04/01 23:51:16 dillon Exp $ + * $FreeBSD: src/sys/i386/i386/critical.c,v 1.4 2002/07/10 20:15:57 dillon Exp $ */ #include @@ -34,16 +34,6 @@ void i386_unpend(void); /* NOTE: not static, called from assembly */ /* - * Instrument our ability to run critical sections with interrupts - * enabled. Default is 1 (enabled). The value can be changed on the - * fly, at any time. If set to 0 the original interrupt disablement - * will be used for critical sections. - */ -int critical_mode = 1; -SYSCTL_INT(_debug, OID_AUTO, critical_mode, - CTLFLAG_RW, &critical_mode, 0, ""); - -/* * cpu_unpend() - called from critical_exit() inline after quick * interrupt-pending check. */ @@ -66,8 +56,8 @@ /* * cpu_critical_fork_exit() - cleanup after fork * - * For i386 we do not have to do anything, td_critnest and - * td_savecrit are handled by the fork trampoline code. + * For i386 we do not have to do anything, td_critnest is + * handled by the fork trampoline code. */ void cpu_critical_fork_exit(void) @@ -77,16 +67,12 @@ /* * cpu_thread_link() - thread linkup, initialize machine-dependant fields * - * (copy code originally in kern/kern_proc.c). XXX we actually - * don't have to initialize this field but it's probably a good - * idea for the moment for debugging's sake. The field is only - * valid when td_critnest is non-zero. + * There are currently no machine-dependant fields that require + * initialization. */ void cpu_thread_link(struct thread *td) { - - td->td_md.md_savecrit = 0; } /* ==== //depot/projects/pmap/sys/i386/i386/exception.s#6 (text+ko) ==== @@ -31,7 +31,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/i386/i386/exception.s,v 1.95 2002/07/10 02:24:44 julian Exp $ + * $FreeBSD: src/sys/i386/i386/exception.s,v 1.97 2002/07/10 21:17:23 julian Exp $ */ #include "opt_npx.h" @@ -225,23 +225,7 @@ pushl %esi /* function */ movl PCPU(CURTHREAD),%ebx /* setup critnest */ movl $1,TD_CRITNEST(%ebx) - /* - * Initialize md_savecrit based on critical_mode. If critical_mode - * is enabled (new/1) savecrit is basically not used but must - * be initialized to -1 so we know it isn't used in - * cpu_critical_exit(). If critical_mode is disabled (old/0) - * the eflags to restore must be saved in md_savecrit. - */ - cmpl $0,critical_mode - jne 1f - pushfl - popl TD_MD+MD_SAVECRIT(%ebx) - orl $PSL_I,TD_MD+MD_SAVECRIT(%ebx) - jmp 2f -1: - movl $-1,TD_MD+MD_SAVECRIT(%ebx) sti /* enable interrupts */ -2: call fork_exit addl $12,%esp /* cut from syscall */ @@ -285,12 +269,12 @@ */ testl $PSL_VM,TF_EFLAGS(%esp) /* are we in vm86 mode? */ jz doreti_notvm86 - cmpl $1,in_vm86call /* are we in a vm86 call? */ + cmpl $1,in_vm86call /* are we in a vm86 call? XXXSMP */ jne doreti_ast /* can handle ASTs now if not */ jmp doreti_exit doreti_notvm86: - testb $SEL_RPL_MASK,TF_CS(%esp) /* are we in user mode? */ + testb $SEL_RPL_MASK,TF_CS(%esp) /* are we returning to user mode? */ jz doreti_exit /* can't handle ASTs now if not */ doreti_ast: ==== //depot/projects/pmap/sys/i386/i386/genassym.c#5 (text+ko) ==== @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 - * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.125 2002/06/29 17:26:16 julian Exp $ + * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.126 2002/07/10 20:15:57 dillon Exp $ */ #include "opt_kstack_pages.h" @@ -94,7 +94,6 @@ ASSYM(P_MD, offsetof(struct proc, p_md)); ASSYM(MD_LDT, offsetof(struct mdproc, md_ldt)); -ASSYM(MD_SAVECRIT, offsetof(struct mdthread, md_savecrit)); ASSYM(KE_FLAGS, offsetof(struct kse, ke_flags)); ==== //depot/projects/pmap/sys/i386/i386/locore.s#9 (text+ko) ==== @@ -34,7 +34,7 @@ >>> TRUNCATED FOR MAIL (1000 lines) <<< To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message