diff options
-rw-r--r-- | sys/arch/sgi/dev/if_iec.c | 30 | ||||
-rw-r--r-- | sys/arch/sgi/pci/iocreg.h | 7 |
2 files changed, 25 insertions, 12 deletions
diff --git a/sys/arch/sgi/dev/if_iec.c b/sys/arch/sgi/dev/if_iec.c index 6d8ee416b11..9fad9e35e36 100644 --- a/sys/arch/sgi/dev/if_iec.c +++ b/sys/arch/sgi/dev/if_iec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iec.c,v 1.3 2009/11/02 22:16:00 miod Exp $ */ +/* $OpenBSD: if_iec.c,v 1.4 2009/11/03 18:48:38 miod Exp $ */ /* * Copyright (c) 2009 Miodrag Vallat. @@ -560,13 +560,18 @@ iec_statchg(struct device *self) struct iec_softc *sc = (void *)self; bus_space_tag_t st = sc->sc_st; bus_space_handle_t sh = sc->sc_sh; - uint32_t tcsr; + uint32_t tcsr, emcr; - if ((sc->sc_mii.mii_media_active & IFM_FDX) != 0) + if ((sc->sc_mii.mii_media_active & IFM_FDX) != 0) { tcsr = IOC3_ENET_TCSR_FULL_DUPLEX; - else + emcr = IOC3_ENET_MCR_DUPLEX; + } else { tcsr = IOC3_ENET_TCSR_HALF_DUPLEX; + emcr = 0; + } + bus_space_write_4(st, sh, IOC3_ENET_MCR, emcr | + (bus_space_read_4(st, sh, IOC3_ENET_MCR) & ~IOC3_ENET_MCR_DUPLEX)); bus_space_write_4(st, sh, IOC3_ENET_TCSR, tcsr); } @@ -635,12 +640,16 @@ iec_init(struct ifnet *ifp) bus_space_write_4(st, sh, IOC3_ENET_RBR_H, sc->sc_rxptrdma >> 32); bus_space_write_4(st, sh, IOC3_ENET_RBR_L, (uint32_t)sc->sc_rxptrdma); - bus_space_write_4(st, sh, IOC3_ENET_RCIR, 0); + sc->sc_rxci = 0; + sc->sc_rxpi = IEC_NRXDESC + 1; + bus_space_write_4(st, sh, IOC3_ENET_RCIR, + sc->sc_rxci * sizeof(uint64_t)); bus_space_write_4(st, sh, IOC3_ENET_RPIR, - (IEC_NRXDESC * sizeof(uint64_t)) | IOC3_ENET_PIR_SET); + (sc->sc_rxpi * sizeof(uint64_t)) | IOC3_ENET_PIR_SET); /* Interrupt as soon as available RX desc reach this limit */ - bus_space_write_4(st, sh, IOC3_ENET_RCSR, IEC_NRXDESC - 1); + bus_space_write_4(st, sh, IOC3_ENET_RCSR, + sc->sc_rxpi - sc->sc_rxci - 1); /* Set up RX timer to interrupt immediately upon reception. */ bus_space_write_4(st, sh, IOC3_ENET_RTR, 0); @@ -651,8 +660,6 @@ iec_init(struct ifnet *ifp) IEC_RXSTATSYNC(sc, i, BUS_DMASYNC_PREREAD); IEC_RXBUFSYNC(sc, i, ETHER_MAX_LEN, BUS_DMASYNC_PREREAD); } - sc->sc_rxci = 0; - sc->sc_rxpi = IEC_NRXDESC; /* Enable DMA, and RX and TX interrupts */ bus_space_write_4(st, sh, IOC3_ENET_MCR, IOC3_ENET_MCR_TX_DMA | @@ -1319,12 +1326,13 @@ iec_txintr(struct iec_softc *sc, uint32_t stat) struct ifnet *ifp = &sc->sc_ac.ac_if; struct iec_txsoft *txs; bus_dmamap_t dmamap; + uint32_t tcir; int i, once, last; ifp->if_flags &= ~IFF_OACTIVE; - last = (bus_space_read_4(st, sh, IOC3_ENET_TCIR) / IEC_TXDESCSIZE) % - IEC_NTXDESC_MAX; + tcir = bus_space_read_4(st, sh, IOC3_ENET_TCIR) & ~IOC3_ENET_TCIR_IDLE; + last = (tcir / IEC_TXDESCSIZE) % IEC_NTXDESC_MAX; DPRINTF(IEC_DEBUG_TXINTR, ("iec_txintr: dirty %d last %d\n", sc->sc_txdirty, last)); diff --git a/sys/arch/sgi/pci/iocreg.h b/sys/arch/sgi/pci/iocreg.h index 1249b89b080..4e9874f4c55 100644 --- a/sys/arch/sgi/pci/iocreg.h +++ b/sys/arch/sgi/pci/iocreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: iocreg.h,v 1.5 2009/11/01 19:17:56 miod Exp $ */ +/* $OpenBSD: iocreg.h,v 1.6 2009/11/03 18:48:39 miod Exp $ */ /* * Copyright (c) 2008 Joel Sing. @@ -107,6 +107,8 @@ #define IOC3_ENET_MCR_PADEN 0x00000004 #define IOC3_ENET_MCR_RXOFF_MASK 0x000001f8 #define IOC3_ENET_MCR_RXOFF_SHIFT 3 +#define IOC3_ENET_MCR_PARITY_ENABLE 0x00000200 +#define IOC3_ENET_MCR_LARGE_SSRAM 0x00001000 #define IOC3_ENET_MCR_TX_DMA 0x00002000 #define IOC3_ENET_MCR_TX 0x00004000 #define IOC3_ENET_MCR_RX_DMA 0x00008000 @@ -163,6 +165,9 @@ #define IOC3_ENET_TCDC_DEFER_MASK 0xffff0000 #define IOC3_ENET_TCDC_DEFER_SHIFT 16 +/* bits in ENET_TCIR */ +#define IOC3_ENET_TCIR_IDLE 0x80000000 + /* bits in ENET_MICR */ #define IOC3_ENET_MICR_REG_MASK 0x0000001f #define IOC3_ENET_MICR_PHY_MASK 0x000003e0 |