This commit is contained in:
yongari 2009-12-21 20:18:01 +00:00
parent 5fbacdf9a7
commit 6fa6ee6af2

View File

@ -202,7 +202,7 @@ SYSCTL_INT(_hw_ste, OID_AUTO, rxsyncs, CTLFLAG_RW, &ste_rxsyncs, 0, "");
static void
ste_mii_sync(struct ste_softc *sc)
{
int i;
int i;
MII_SET(STE_PHYCTL_MDIR|STE_PHYCTL_MDATA);
@ -220,7 +220,7 @@ ste_mii_sync(struct ste_softc *sc)
static void
ste_mii_send(struct ste_softc *sc, uint32_t bits, int cnt)
{
int i;
int i;
MII_CLR(STE_PHYCTL_MCLK);
@ -243,7 +243,7 @@ ste_mii_send(struct ste_softc *sc, uint32_t bits, int cnt)
static int
ste_mii_readreg(struct ste_softc *sc, struct ste_mii_frame *frame)
{
int i, ack;
int i, ack;
/*
* Set up frame for RX.
@ -290,7 +290,7 @@ ste_mii_readreg(struct ste_softc *sc, struct ste_mii_frame *frame)
* need to clock through 16 cycles to keep the PHY(s) in sync.
*/
if (ack) {
for(i = 0; i < 16; i++) {
for (i = 0; i < 16; i++) {
MII_CLR(STE_PHYCTL_MCLK);
DELAY(1);
MII_SET(STE_PHYCTL_MCLK);
@ -319,8 +319,8 @@ fail:
DELAY(1);
if (ack)
return(1);
return(0);
return (1);
return (0);
}
/*
@ -363,14 +363,14 @@ ste_mii_writereg(struct ste_softc *sc, struct ste_mii_frame *frame)
*/
MII_CLR(STE_PHYCTL_MDIR);
return(0);
return (0);
}
static int
ste_miibus_readreg(device_t dev, int phy, int reg)
{
struct ste_softc *sc;
struct ste_mii_frame frame;
struct ste_softc *sc;
struct ste_mii_frame frame;
sc = device_get_softc(dev);
@ -383,14 +383,14 @@ ste_miibus_readreg(device_t dev, int phy, int reg)
frame.mii_regaddr = reg;
ste_mii_readreg(sc, &frame);
return(frame.mii_data);
return (frame.mii_data);
}
static int
ste_miibus_writereg(device_t dev, int phy, int reg, int data)
{
struct ste_softc *sc;
struct ste_mii_frame frame;
struct ste_softc *sc;
struct ste_mii_frame frame;
sc = device_get_softc(dev);
bzero((char *)&frame, sizeof(frame));
@ -401,14 +401,14 @@ ste_miibus_writereg(device_t dev, int phy, int reg, int data)
ste_mii_writereg(sc, &frame);
return(0);
return (0);
}
static void
ste_miibus_statchg(device_t dev)
{
struct ste_softc *sc;
struct mii_data *mii;
struct ste_softc *sc;
struct mii_data *mii;
sc = device_get_softc(dev);
@ -424,21 +424,21 @@ ste_miibus_statchg(device_t dev)
static int
ste_ifmedia_upd(struct ifnet *ifp)
{
struct ste_softc *sc;
struct ste_softc *sc;
sc = ifp->if_softc;
STE_LOCK(sc);
ste_ifmedia_upd_locked(ifp);
STE_UNLOCK(sc);
return(0);
return (0);
}
static void
ste_ifmedia_upd_locked(struct ifnet *ifp)
{
struct ste_softc *sc;
struct mii_data *mii;
struct ste_softc *sc;
struct mii_data *mii;
sc = ifp->if_softc;
STE_LOCK_ASSERT(sc);
@ -455,8 +455,8 @@ ste_ifmedia_upd_locked(struct ifnet *ifp)
static void
ste_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
{
struct ste_softc *sc;
struct mii_data *mii;
struct ste_softc *sc;
struct mii_data *mii;
sc = ifp->if_softc;
mii = device_get_softc(sc->ste_miibus);
@ -471,7 +471,7 @@ ste_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
static void
ste_wait(struct ste_softc *sc)
{
int i;
int i;
for (i = 0; i < STE_TIMEOUT; i++) {
if (!(CSR_READ_4(sc, STE_DMACTL) & STE_DMACTL_DMA_HALTINPROG))
@ -489,7 +489,7 @@ ste_wait(struct ste_softc *sc)
static int
ste_eeprom_wait(struct ste_softc *sc)
{
int i;
int i;
DELAY(1000);
@ -502,10 +502,10 @@ ste_eeprom_wait(struct ste_softc *sc)
if (i == 100) {
device_printf(sc->ste_dev, "eeprom failed to come ready\n");
return(1);
return (1);
}
return(0);
return (0);
}
/*
@ -515,11 +515,11 @@ ste_eeprom_wait(struct ste_softc *sc)
static int
ste_read_eeprom(struct ste_softc *sc, caddr_t dest, int off, int cnt, int swap)
{
int err = 0, i;
uint16_t word = 0, *ptr;
uint16_t word, *ptr;
int err = 0, i;
if (ste_eeprom_wait(sc))
return(1);
return (1);
for (i = 0; i < cnt; i++) {
CSR_WRITE_2(sc, STE_EEPROM_CTL, STE_EEOPCODE_READ | (off + i));
@ -534,16 +534,16 @@ ste_read_eeprom(struct ste_softc *sc, caddr_t dest, int off, int cnt, int swap)
*ptr = word;
}
return(err ? 1 : 0);
return (err ? 1 : 0);
}
static void
ste_setmulti(struct ste_softc *sc)
{
struct ifnet *ifp;
int h = 0;
uint32_t hashes[2] = { 0, 0 };
struct ifmultiaddr *ifma;
struct ifnet *ifp;
struct ifmultiaddr *ifma;
uint32_t hashes[2] = { 0, 0 };
int h;
ifp = sc->ste_ifp;
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
@ -640,9 +640,9 @@ ste_poll_locked(struct ifnet *ifp, enum poll_cmd cmd, int count)
static void
ste_intr(void *xsc)
{
struct ste_softc *sc;
struct ifnet *ifp;
uint16_t status;
struct ste_softc *sc;
struct ifnet *ifp;
uint16_t status;
sc = xsc;
STE_LOCK(sc);
@ -732,17 +732,17 @@ ste_rxeoc(struct ste_softc *sc)
static int
ste_rxeof(struct ste_softc *sc)
{
struct mbuf *m;
struct ifnet *ifp;
struct ste_chain_onefrag *cur_rx;
int total_len = 0, count=0, rx_npkts = 0;
uint32_t rxstat;
struct mbuf *m;
struct ifnet *ifp;
struct ste_chain_onefrag *cur_rx;
uint32_t rxstat;
int total_len = 0, count = 0, rx_npkts = 0;
STE_LOCK_ASSERT(sc);
ifp = sc->ste_ifp;
while((rxstat = sc->ste_cdata.ste_rx_head->ste_ptr->ste_status)
while ((rxstat = sc->ste_cdata.ste_rx_head->ste_ptr->ste_status)
& STE_RXSTAT_DMADONE) {
#ifdef DEVICE_POLLING
if (ifp->if_capenable & IFCAP_POLLING) {
@ -819,8 +819,8 @@ ste_rxeof(struct ste_softc *sc)
static void
ste_txeoc(struct ste_softc *sc)
{
uint8_t txstat;
struct ifnet *ifp;
struct ifnet *ifp;
uint8_t txstat;
ifp = sc->ste_ifp;
@ -856,14 +856,14 @@ ste_txeoc(struct ste_softc *sc)
static void
ste_txeof(struct ste_softc *sc)
{
struct ste_chain *cur_tx;
struct ifnet *ifp;
int idx;
struct ifnet *ifp;
struct ste_chain *cur_tx;
int idx;
ifp = sc->ste_ifp;
idx = sc->ste_cdata.ste_tx_cons;
while(idx != sc->ste_cdata.ste_tx_prod) {
while (idx != sc->ste_cdata.ste_tx_prod) {
cur_tx = &sc->ste_cdata.ste_tx_chain[idx];
if (!(cur_tx->ste_ptr->ste_ctl & STE_TXCTL_DMADONE))
@ -885,9 +885,9 @@ ste_txeof(struct ste_softc *sc)
static void
ste_stats_update(void *xsc)
{
struct ste_softc *sc;
struct ifnet *ifp;
struct mii_data *mii;
struct ste_softc *sc;
struct ifnet *ifp;
struct mii_data *mii;
sc = xsc;
STE_LOCK_ASSERT(sc);
@ -927,11 +927,11 @@ ste_stats_update(void *xsc)
static int
ste_probe(device_t dev)
{
struct ste_type *t;
struct ste_type *t;
t = ste_devs;
while(t->ste_name != NULL) {
while (t->ste_name != NULL) {
if ((pci_get_vendor(dev) == t->ste_vid) &&
(pci_get_device(dev) == t->ste_did)) {
device_set_desc(dev, t->ste_name);
@ -940,7 +940,7 @@ ste_probe(device_t dev)
t++;
}
return(ENXIO);
return (ENXIO);
}
/*
@ -950,10 +950,10 @@ ste_probe(device_t dev)
static int
ste_attach(device_t dev)
{
struct ste_softc *sc;
struct ifnet *ifp;
int error = 0, rid;
u_char eaddr[6];
struct ste_softc *sc;
struct ifnet *ifp;
u_char eaddr[6];
int error = 0, rid;
sc = device_get_softc(dev);
sc->ste_dev = dev;
@ -1082,7 +1082,7 @@ fail:
if (error)
ste_detach(dev);
return(error);
return (error);
}
/*
@ -1095,8 +1095,8 @@ fail:
static int
ste_detach(device_t dev)
{
struct ste_softc *sc;
struct ifnet *ifp;
struct ste_softc *sc;
struct ifnet *ifp;
sc = device_get_softc(dev);
KASSERT(mtx_initialized(&sc->ste_mtx), ("ste mutex not initialized"));
@ -1136,22 +1136,22 @@ ste_detach(device_t dev)
mtx_destroy(&sc->ste_mtx);
return(0);
return (0);
}
static int
ste_newbuf(struct ste_softc *sc, struct ste_chain_onefrag *c, struct mbuf *m)
{
struct mbuf *m_new = NULL;
struct mbuf *m_new = NULL;
if (m == NULL) {
MGETHDR(m_new, M_DONTWAIT, MT_DATA);
if (m_new == NULL)
return(ENOBUFS);
return (ENOBUFS);
MCLGET(m_new, M_DONTWAIT);
if (!(m_new->m_flags & M_EXT)) {
m_freem(m_new);
return(ENOBUFS);
return (ENOBUFS);
}
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
} else {
@ -1167,15 +1167,15 @@ ste_newbuf(struct ste_softc *sc, struct ste_chain_onefrag *c, struct mbuf *m)
c->ste_ptr->ste_frag.ste_addr = vtophys(mtod(m_new, caddr_t));
c->ste_ptr->ste_frag.ste_len = (1536 + ETHER_VLAN_ENCAP_LEN) | STE_FRAG_LAST;
return(0);
return (0);
}
static int
ste_init_rx_list(struct ste_softc *sc)
{
struct ste_chain_data *cd;
struct ste_list_data *ld;
int i;
struct ste_chain_data *cd;
struct ste_list_data *ld;
int i;
cd = &sc->ste_cdata;
ld = sc->ste_ldata;
@ -1183,7 +1183,7 @@ ste_init_rx_list(struct ste_softc *sc)
for (i = 0; i < STE_RX_LIST_CNT; i++) {
cd->ste_rx_chain[i].ste_ptr = &ld->ste_rx_list[i];
if (ste_newbuf(sc, &cd->ste_rx_chain[i], NULL) == ENOBUFS)
return(ENOBUFS);
return (ENOBUFS);
if (i == (STE_RX_LIST_CNT - 1)) {
cd->ste_rx_chain[i].ste_next =
&cd->ste_rx_chain[0];
@ -1200,15 +1200,15 @@ ste_init_rx_list(struct ste_softc *sc)
cd->ste_rx_head = &cd->ste_rx_chain[0];
return(0);
return (0);
}
static void
ste_init_tx_list(struct ste_softc *sc)
{
struct ste_chain_data *cd;
struct ste_list_data *ld;
int i;
struct ste_chain_data *cd;
struct ste_list_data *ld;
int i;
cd = &sc->ste_cdata;
ld = sc->ste_ldata;
@ -1232,7 +1232,7 @@ ste_init_tx_list(struct ste_softc *sc)
static void
ste_init(void *xsc)
{
struct ste_softc *sc;
struct ste_softc *sc;
sc = xsc;
STE_LOCK(sc);
@ -1243,8 +1243,8 @@ ste_init(void *xsc)
static void
ste_init_locked(struct ste_softc *sc)
{
int i;
struct ifnet *ifp;
struct ifnet *ifp;
int i;
STE_LOCK_ASSERT(sc);
ifp = sc->ste_ifp;
@ -1353,8 +1353,8 @@ ste_init_locked(struct ste_softc *sc)
static void
ste_stop(struct ste_softc *sc)
{
int i;
struct ifnet *ifp;
struct ifnet *ifp;
int i;
STE_LOCK_ASSERT(sc);
ifp = sc->ste_ifp;
@ -1397,7 +1397,7 @@ ste_stop(struct ste_softc *sc)
static void
ste_reset(struct ste_softc *sc)
{
int i;
int i;
STE_SETBIT4(sc, STE_ASICCTL,
STE_ASICCTL_GLOBAL_RESET|STE_ASICCTL_RX_RESET|
@ -1420,15 +1420,15 @@ ste_reset(struct ste_softc *sc)
static int
ste_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
{
struct ste_softc *sc;
struct ifreq *ifr;
struct mii_data *mii;
int error = 0;
struct ste_softc *sc;
struct ifreq *ifr;
struct mii_data *mii;
int error = 0;
sc = ifp->if_softc;
ifr = (struct ifreq *)data;
switch(command) {
switch (command) {
case SIOCSIFFLAGS:
STE_LOCK(sc);
if (ifp->if_flags & IFF_UP) {
@ -1476,7 +1476,7 @@ ste_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
!(ifp->if_capenable & IFCAP_POLLING)) {
error = ether_poll_register(ste_poll, ifp);
if (error)
return(error);
return (error);
STE_LOCK(sc);
/* Disable interrupts */
CSR_WRITE_2(sc, STE_IMR, 0);
@ -1502,16 +1502,16 @@ ste_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
break;
}
return(error);
return (error);
}
static int
ste_encap(struct ste_softc *sc, struct ste_chain *c, struct mbuf *m_head)
{
int frag = 0;
struct ste_frag *f = NULL;
struct mbuf *m;
struct ste_desc *d;
struct mbuf *m;
struct ste_desc *d;
struct ste_frag *f = NULL;
int frag = 0;
d = c->ste_ptr;
d->ste_ctl = 0;
@ -1549,13 +1549,13 @@ encap_retry:
d->ste_frags[frag - 1].ste_len |= STE_FRAG_LAST;
d->ste_ctl = 1;
return(0);
return (0);
}
static void
ste_start(struct ifnet *ifp)
{
struct ste_softc *sc;
struct ste_softc *sc;
sc = ifp->if_softc;
STE_LOCK(sc);
@ -1566,10 +1566,10 @@ ste_start(struct ifnet *ifp)
static void
ste_start_locked(struct ifnet *ifp)
{
struct ste_softc *sc;
struct mbuf *m_head = NULL;
struct ste_chain *cur_tx;
int idx;
struct ste_softc *sc;
struct ste_chain *cur_tx;
struct mbuf *m_head = NULL;
int idx;
sc = ifp->if_softc;
STE_LOCK_ASSERT(sc);
@ -1582,7 +1582,7 @@ ste_start_locked(struct ifnet *ifp)
idx = sc->ste_cdata.ste_tx_prod;
while(sc->ste_cdata.ste_tx_chain[idx].ste_mbuf == NULL) {
while (sc->ste_cdata.ste_tx_chain[idx].ste_mbuf == NULL) {
/*
* We cannot re-use the last (free) descriptor;
* the chip may not have read its ste_next yet.
@ -1641,7 +1641,7 @@ ste_start_locked(struct ifnet *ifp)
static void
ste_watchdog(struct ste_softc *sc)
{
struct ifnet *ifp;
struct ifnet *ifp;
ifp = sc->ste_ifp;
STE_LOCK_ASSERT(sc);
@ -1663,7 +1663,7 @@ ste_watchdog(struct ste_softc *sc)
static int
ste_shutdown(device_t dev)
{
struct ste_softc *sc;
struct ste_softc *sc;
sc = device_get_softc(dev);