diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2006-08-27 21:06:17 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2006-08-27 21:06:17 +0000 |
commit | a0f43a3590ae069bc43846d13b3bbbe17488122f (patch) | |
tree | bcc98fa88d9175481a2b7a85610daa5c89abe526 | |
parent | fbae5ca93f1391c422f92f1634389c7bf9041962 (diff) |
pack several boolean fields into the existing bge_flags field.
-rw-r--r-- | sys/dev/mii/brgphy.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_bge.c | 82 | ||||
-rw-r--r-- | sys/dev/pci/if_bgereg.h | 30 |
3 files changed, 62 insertions, 56 deletions
diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c index 7151fd9a5a2..fe68b9fdc68 100644 --- a/sys/dev/mii/brgphy.c +++ b/sys/dev/mii/brgphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: brgphy.c,v 1.50 2006/07/23 06:34:03 brad Exp $ */ +/* $OpenBSD: brgphy.c,v 1.51 2006/08/27 21:06:16 brad Exp $ */ /* * Copyright (c) 2000 @@ -339,6 +339,8 @@ setit: break; } } + + /* Callback if something changed. */ mii_phy_update(sc, cmd); return (0); @@ -482,7 +484,7 @@ brgphy_reset(struct mii_softc *sc) PHY_WRITE(sc, BRGPHY_MII_AUXCTL, val | (1 << 15) | (1 << 4)); /* Enable Link LED on Dell boxes */ - if (bge_sc->bge_no_3_led) { + if (bge_sc->bge_flags & BGE_NO3LED) { PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL, PHY_READ(sc, BRGPHY_MII_PHY_EXTCTL) & ~BRGPHY_PHY_EXTCTL_3_LED); diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c index 093f7224352..3fbb0ce33de 100644 --- a/sys/dev/pci/if_bge.c +++ b/sys/dev/pci/if_bge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bge.c,v 1.167 2006/08/04 15:22:41 brad Exp $ */ +/* $OpenBSD: if_bge.c,v 1.168 2006/08/27 21:06:16 brad Exp $ */ /* * Copyright (c) 2001 Wind River Systems @@ -753,7 +753,7 @@ bge_newbuf_std(struct bge_softc *sc, int i, struct mbuf *m, m_new->m_data = m_new->m_ext.ext_buf; } - if (!sc->bge_rx_alignment_bug) + if (!(sc->bge_flags & BGE_RX_ALIGNBUG)) m_adj(m_new, ETHER_ALIGN); error = bus_dmamap_load_mbuf(sc->bge_dmatag, dmamap, m_new, @@ -822,7 +822,7 @@ bge_newbuf_jumbo(struct bge_softc *sc, int i, struct mbuf *m) m_new->m_ext.ext_size = BGE_JUMBO_FRAMELEN; } - if (!sc->bge_rx_alignment_bug) + if (!(sc->bge_flags & BGE_RX_ALIGNBUG)) m_adj(m_new, ETHER_ALIGN); /* Set up the descriptor. */ r = &sc->bge_rdata->bge_rx_jumbo_ring[i]; @@ -1104,7 +1104,7 @@ bge_chipinit(struct bge_softc *sc) BGE_MEMWIN_WRITE(pa->pa_pc, pa->pa_tag, i, 0); /* Set up the PCI DMA control register. */ - if (sc->bge_pcie) { + if (sc->bge_flags & BGE_PCIE) { /* PCI Express bus */ u_int32_t device_ctl; @@ -1127,7 +1127,7 @@ bge_chipinit(struct bge_softc *sc) } else { dma_rw_ctl |= BGE_PCIDMA_RWCTL_PCIE_WRITE_WATRMARK_128; } - } else if (sc->bge_pcix) { + } else if (sc->bge_flags & BGE_PCIX) { /* PCI-X bus */ if (BGE_IS_5714_FAMILY(sc)) { dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD; @@ -1233,7 +1233,7 @@ bge_blockinit(struct bge_softc *sc) /* Configure mbuf memory pool */ if (!(BGE_IS_5705_OR_BEYOND(sc))) { - if (sc->bge_extram) + if (sc->bge_flags & BGE_EXTRAM) CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_BASEADDR, BGE_EXT_SSRAM); else @@ -1309,7 +1309,7 @@ bge_blockinit(struct bge_softc *sc) else rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(ETHER_MAX_DIX_LEN, 0); - if (sc->bge_extram) + if (sc->bge_flags & BGE_EXTRAM) rcb->bge_nicaddr = BGE_EXT_STD_RX_RINGS; else rcb->bge_nicaddr = BGE_STD_RX_RINGS; @@ -1332,7 +1332,7 @@ bge_blockinit(struct bge_softc *sc) rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(BGE_JUMBO_FRAMELEN, BGE_RCB_FLAG_RING_DISABLED); - if (sc->bge_extram) + if (sc->bge_flags & BGE_EXTRAM) rcb->bge_nicaddr = BGE_EXT_JUMBO_RX_RINGS; else rcb->bge_nicaddr = BGE_JUMBO_RX_RINGS; @@ -1516,7 +1516,8 @@ bge_blockinit(struct bge_softc *sc) BGE_MACMODE_RXDMA_ENB|BGE_MACMODE_RX_STATS_CLEAR| BGE_MACMODE_TX_STATS_CLEAR|BGE_MACMODE_RX_STATS_ENB| BGE_MACMODE_TX_STATS_ENB|BGE_MACMODE_FRMHDR_DMA_ENB| - (sc->bge_tbi ? BGE_PORTMODE_TBI : BGE_PORTMODE_MII)); + ((sc->bge_flags & BGE_TBI) ? + BGE_PORTMODE_TBI : BGE_PORTMODE_MII)); /* Set misc. local control, enable interrupts on attentions */ CSR_WRITE_4(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_INTR_ONATTN); @@ -1544,7 +1545,7 @@ bge_blockinit(struct bge_softc *sc) dma_read_modebits = BGE_RDMAMODE_ENABLE | BGE_RDMAMODE_ALL_ATTNS; - if (sc->bge_pcie && 0) + if (sc->bge_flags & BGE_PCIE && 0) dma_read_modebits |= BGE_RDMA_MODE_FIFO_LONG_BURST; CSR_WRITE_4(sc, BGE_RDMA_MODE, dma_read_modebits); @@ -1588,7 +1589,7 @@ bge_blockinit(struct bge_softc *sc) BGE_MACSTAT_LINK_CHANGED); /* Enable PHY auto polling (for MII/GMII only) */ - if (sc->bge_tbi) { + if (sc->bge_flags & BGE_TBI) { CSR_WRITE_4(sc, BGE_MI_STS, BGE_MISTS_LINK); } else { BGE_SETBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL|10<<16); @@ -1740,18 +1741,16 @@ bge_attach(struct device *parent, struct device *self, void *aux) /* * PCI Express check. */ - sc->bge_pcie = 0; if (pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_PCIEXPRESS, NULL, NULL) != 0) - sc->bge_pcie = 1; + sc->bge_flags |= BGE_PCIE; /* * PCI-X check. */ - sc->bge_pcix = 0; if ((pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_PCISTATE) & BGE_PCISTATE_PCI_BUSMODE) == 0) - sc->bge_pcix = 1; + sc->bge_flags |= BGE_PCIX; /* Try to reset the chip. */ DPRINTFN(5, ("bge_reset\n")); @@ -1891,14 +1890,14 @@ bge_attach(struct device *parent, struct device *self, void *aux) } if ((hwcfg & BGE_HWCFG_MEDIA) == BGE_MEDIA_FIBER) - sc->bge_tbi = 1; + sc->bge_flags |= BGE_TBI; /* The SysKonnect SK-9D41 is a 1000baseSX card. */ if ((pci_conf_read(pc, pa->pa_tag, BGE_PCI_SUBSYS) >> 16) == SK_SUBSYSID_9D41) - sc->bge_tbi = 1; + sc->bge_flags |= BGE_TBI; - if (sc->bge_tbi) { + if (sc->bge_flags & BGE_TBI) { ifmedia_init(&sc->bge_ifmedia, IFM_IMASK, bge_ifmedia_upd, bge_ifmedia_sts); ifmedia_add(&sc->bge_ifmedia, IFM_ETHER|IFM_1000_SX, 0, NULL); @@ -1935,8 +1934,9 @@ bge_attach(struct device *parent, struct device *self, void *aux) * which do not support unaligned accesses, we will realign the * payloads by copying the received packets. */ - if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5701 && sc->bge_pcix) - sc->bge_rx_alignment_bug = 1; + if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5701 && + sc->bge_flags & BGE_PCIX) + sc->bge_flags |= BGE_RX_ALIGNBUG; /* * Call MI attach routine. @@ -1986,11 +1986,16 @@ bge_reset(struct bge_softc *sc) reset = BGE_MISCCFG_RESET_CORE_CLOCKS|(65<<1); - if (sc->bge_pcie) { - if (CSR_READ_4(sc, 0x7e2c) == 0x60) /* PCI-E 1.0 system */ + if (sc->bge_flags & BGE_PCIE) { + if (CSR_READ_4(sc, 0x7e2c) == 0x60) { + /* PCI Express 1.0 system */ CSR_WRITE_4(sc, 0x7e2c, 0x20); + } if (sc->bge_chipid != BGE_CHIPID_BCM5750_A0) { - /* Prevent PCI-E link training during global reset */ + /* + * Prevent PCI Express link training + * during global reset. + */ CSR_WRITE_4(sc, BGE_MISC_CFG, (1<<29)); reset |= (1<<29); } @@ -2001,7 +2006,7 @@ bge_reset(struct bge_softc *sc) DELAY(1000); - if (sc->bge_pcie) { + if (sc->bge_flags & BGE_PCIE) { if (sc->bge_chipid == BGE_CHIPID_BCM5750_A0) { pcireg_t v; @@ -2009,7 +2014,7 @@ bge_reset(struct bge_softc *sc) v = pci_conf_read(pa->pa_pc, pa->pa_tag, 0xc4); pci_conf_write(pa->pa_pc, pa->pa_tag, 0xc4, v | (1<<15)); } - /* Set PCI-E max payload size and clear error status. */ + /* Set PCI Express max payload size and clear error status. */ pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_CONF_DEV_CTRL, 0xf5000); } @@ -2086,7 +2091,8 @@ bge_reset(struct bge_softc *sc) * adjustment to insure the SERDES drive level is set * to 1.2V. */ - if (sc->bge_tbi && BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5704) { + if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5704 && + sc->bge_flags & BGE_TBI) { u_int32_t serdescfg; serdescfg = CSR_READ_4(sc, BGE_SERDES_CFG); @@ -2094,10 +2100,11 @@ bge_reset(struct bge_softc *sc) CSR_WRITE_4(sc, BGE_SERDES_CFG, serdescfg); } - if (sc->bge_pcie && sc->bge_chipid != BGE_CHIPID_BCM5750_A0) { + if (sc->bge_chipid != BGE_CHIPID_BCM5750_A0 && + if (sc->bge_flags & BGE_PCIE) { u_int32_t v; - /* Enable PCI-E bug fix */ + /* Enable PCI Express bug fix */ v = CSR_READ_4(sc, 0x7c00); CSR_WRITE_4(sc, 0x7c00, v | (1<<25)); } @@ -2219,7 +2226,7 @@ bge_rxeof(struct bge_softc *sc) * The i386 allows unaligned accesses, but for other * platforms we must make sure the payload is aligned. */ - if (sc->bge_rx_alignment_bug) { + if (sc->bge_flags & BGE_RX_ALIGNBUG) { bcopy(m->m_data, m->m_data + ETHER_ALIGN, cur_rx->bge_len); m->m_data += ETHER_ALIGN; @@ -2402,9 +2409,7 @@ bge_tick(void *xsc) else bge_stats_update(sc); - if (!sc->bge_tbi) { - mii_tick(mii); - } else { + if (sc->bge_flags & BGE_TBI) { /* * Since in TBI mode auto-polling can't be used we should poll * link status manually. Here we register pending link event @@ -2412,7 +2417,8 @@ bge_tick(void *xsc) */ sc->bge_link_evt++; BGE_SETBIT(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_INTR_SET); - } + } else + mii_tick(mii); timeout_add(&sc->bge_timeout, hz); @@ -2870,7 +2876,7 @@ bge_ifmedia_upd(struct ifnet *ifp) struct ifmedia *ifm = &sc->bge_ifmedia; /* If this is a 1000baseX NIC, enable the TBI port. */ - if (sc->bge_tbi) { + if (sc->bge_flags & BGE_TBI) { if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) return (EINVAL); switch(IFM_SUBTYPE(ifm->ifm_media)) { @@ -2929,7 +2935,7 @@ bge_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) struct bge_softc *sc = ifp->if_softc; struct mii_data *mii = &sc->bge_mii; - if (sc->bge_tbi) { + if (sc->bge_flags & BGE_TBI) { ifmr->ifm_status = IFM_AVALID; ifmr->ifm_active = IFM_ETHER; if (CSR_READ_4(sc, BGE_MAC_STS) & @@ -3026,7 +3032,7 @@ bge_ioctl(struct ifnet *ifp, u_long command, caddr_t data) break; case SIOCSIFMEDIA: case SIOCGIFMEDIA: - if (sc->bge_tbi) { + if (sc->bge_flags & BGE_TBI) { error = ifmedia_ioctl(ifp, ifr, &sc->bge_ifmedia, command); } else { @@ -3157,7 +3163,7 @@ bge_stop(struct bge_softc *sc) * unchanged so that things will be put back to normal when * we bring the interface back up. */ - if (!sc->bge_tbi) { + if (!(sc->bge_flags & BGE_TBI)) { mii = &sc->bge_mii; itmp = ifp->if_flags; ifp->if_flags |= IFF_UP; @@ -3245,7 +3251,7 @@ bge_link_upd(struct bge_softc *sc) return; } - if (sc->bge_tbi) { + if (sc->bge_flags & BGE_TBI) { status = CSR_READ_4(sc, BGE_MAC_STS); if (status & BGE_MACSTAT_TBI_PCS_SYNCHED) { if (!sc->bge_link) { diff --git a/sys/dev/pci/if_bgereg.h b/sys/dev/pci/if_bgereg.h index 39bf3e7b978..b520565ee6f 100644 --- a/sys/dev/pci/if_bgereg.h +++ b/sys/dev/pci/if_bgereg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bgereg.h,v 1.52 2006/08/16 02:37:00 brad Exp $ */ +/* $OpenBSD: if_bgereg.h,v 1.53 2006/08/27 21:06:16 brad Exp $ */ /* * Copyright (c) 2001 Wind River Systems @@ -2327,13 +2327,6 @@ struct txdmamap_pool_entry { SLIST_ENTRY(txdmamap_pool_entry) link; }; -/* - * Flags for bge_flags. - */ -#define BGE_TXRING_VALID 0x0001 -#define BGE_RXRING_VALID 0x0002 -#define BGE_JUMBO_RXRING_VALID 0x0004 - #define ASF_ENABLE 1 #define ASF_NEW_HANDSHAKE 2 #define ASF_STACKUP 4 @@ -2347,15 +2340,20 @@ struct bge_softc { struct pci_attach_args bge_pa; struct mii_data bge_mii; struct ifmedia bge_ifmedia; /* media info */ - u_int8_t bge_extram; /* has external SSRAM */ - u_int8_t bge_tbi; - u_int8_t bge_rx_alignment_bug; + u_int32_t bge_flags; +#define BGE_TXRING_VALID 0x00000001 +#define BGE_RXRING_VALID 0x00000002 +#define BGE_JUMBO_RXRING_VALID 0x00000004 +#define BGE_EXTRAM 0x00000008 /* Has external SSRAM. */ +#define BGE_TBI 0x00000010 +#define BGE_RX_ALIGNBUG 0x00000020 +#define BGE_NO3LED 0x00000040 +#define BGE_PCIX 0x00000080 +#define BGE_PCIE 0x00000100 +#define BGE_ASF_MODE 0x00000200 + bus_dma_tag_t bge_dmatag; u_int32_t bge_chipid; - u_int8_t bge_no_3_led; - u_int8_t bge_asf_mode; - u_int8_t bge_pcie; - u_int8_t bge_pcix; struct bge_ring_data *bge_rdata; /* rings */ struct bge_chain_data bge_cdata; /* mbufs */ bus_dmamap_t bge_ring_map; @@ -2375,7 +2373,7 @@ struct bge_softc { u_int32_t bge_tx_max_coal_bds; u_int32_t bge_tx_buf_ratio; int bge_if_flags; - int bge_flags; + int bge_ring_flags; int bge_txcnt; int bge_link; /* link state */ int bge_link_evt; /* pending link event */ |