diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2006-11-01 23:25:19 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2006-11-01 23:25:19 +0000 |
commit | f9a31728f6753f90016705431761151520823c96 (patch) | |
tree | b258598ae27f9bc4c0506585ca9cd35ae674eacc /sys/dev/ic | |
parent | dd32e9f046d78a1b9954554a1f4a312d261b1e11 (diff) |
Put common data for each RX DMA descriptor into a new rxsoft structure.
From tsutsui@NetBSD
Tested by brad@ otto@
Tested on amd64/i386/sparc64
Diffstat (limited to 'sys/dev/ic')
-rw-r--r-- | sys/dev/ic/re.c | 52 | ||||
-rw-r--r-- | sys/dev/ic/rtl81x9reg.h | 10 |
2 files changed, 33 insertions, 29 deletions
diff --git a/sys/dev/ic/re.c b/sys/dev/ic/re.c index 18dc28ac58b..ff37fd84bd2 100644 --- a/sys/dev/ic/re.c +++ b/sys/dev/ic/re.c @@ -1,4 +1,4 @@ -/* $OpenBSD: re.c,v 1.51 2006/10/31 22:45:15 brad Exp $ */ +/* $OpenBSD: re.c,v 1.52 2006/11/01 23:25:18 brad Exp $ */ /* $FreeBSD: if_re.c,v 1.31 2004/09/04 07:54:05 ru Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -586,6 +586,7 @@ re_diag(struct rl_softc *sc) struct ifnet *ifp = &sc->sc_arpcom.ac_if; struct mbuf *m0; struct ether_header *eh; + struct rl_rxsoft *rxs; struct rl_desc *cur_rx; bus_dmamap_t dmamap; u_int16_t status; @@ -679,15 +680,14 @@ re_diag(struct rl_softc *sc) * entry in the RX DMA ring. Grab it from there. */ - dmamap = sc->rl_ldata.rl_rx_dmamap[0]; - bus_dmamap_sync(sc->sc_dmat, - dmamap, 0, dmamap->dm_mapsize, + rxs = &sc->rl_ldata.rl_rxsoft[0]; + dmamap = rxs->rxs_dmamap; + bus_dmamap_sync(sc->sc_dmat, dmamap, 0, dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); - bus_dmamap_unload(sc->sc_dmat, - sc->rl_ldata.rl_rx_dmamap[0]); + bus_dmamap_unload(sc->sc_dmat, dmamap); - m0 = sc->rl_ldata.rl_rx_mbuf[0]; - sc->rl_ldata.rl_rx_mbuf[0] = NULL; + m0 = rxs->rxs_mbuf; + rxs->rxs_mbuf = NULL; eh = mtod(m0, struct ether_header *); RL_RXDESCSYNC(sc, 0, BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE); @@ -919,7 +919,7 @@ re_attach(struct rl_softc *sc) /* Create DMA maps for RX buffers */ for (i = 0; i < RL_RX_DESC_CNT; i++) { error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1, MCLBYTES, - 0, 0, &sc->rl_ldata.rl_rx_dmamap[i]); + 0, 0, &sc->rl_ldata.rl_rxsoft[i].rxs_dmamap); if (error) { printf("%s: can't create DMA map for RX\n", sc->sc_dev.dv_xname); @@ -1000,9 +1000,9 @@ re_attach(struct rl_softc *sc) fail_8: /* Destroy DMA maps for RX buffers. */ for (i = 0; i < RL_RX_DESC_CNT; i++) { - if (sc->rl_ldata.rl_rx_dmamap[i] != NULL) + if (sc->rl_ldata.rl_rxsoft[i].rxs_dmamap != NULL) bus_dmamap_destroy(sc->sc_dmat, - sc->rl_ldata.rl_rx_dmamap[i]); + sc->rl_ldata.rl_rxsoft[i].rxs_dmamap); } /* Free DMA'able memory for the RX ring. */ @@ -1045,6 +1045,7 @@ re_newbuf(struct rl_softc *sc, int idx, struct mbuf *m) struct mbuf *n = NULL; bus_dmamap_t map; struct rl_desc *d; + struct rl_rxsoft *rxs; u_int32_t cmdstat; int error; @@ -1078,10 +1079,11 @@ re_newbuf(struct rl_softc *sc, int idx, struct mbuf *m) m_adj(m, RE_ETHER_ALIGN); #endif - map = sc->rl_ldata.rl_rx_dmamap[idx]; - + rxs = &sc->rl_ldata.rl_rxsoft[idx]; + map = rxs->rxs_dmamap; error = bus_dmamap_load_mbuf(sc->sc_dmat, map, m, BUS_DMA_READ|BUS_DMA_NOWAIT); + if (error) goto out; @@ -1098,6 +1100,8 @@ re_newbuf(struct rl_softc *sc, int idx, struct mbuf *m) goto out; } + rxs->rxs_mbuf = m; + cmdstat = map->dm_segs[0].ds_len; if (idx == (RL_RX_DESC_CNT - 1)) cmdstat |= RL_RDESC_CMD_EOR; @@ -1109,8 +1113,6 @@ re_newbuf(struct rl_softc *sc, int idx, struct mbuf *m) d->rl_cmdstat = htole32(cmdstat); RL_RXDESCSYNC(sc, idx, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); - sc->rl_ldata.rl_rx_mbuf[idx] = m; - return (0); out: if (n != NULL) @@ -1163,8 +1165,6 @@ re_rx_list_init(struct rl_softc *sc) int i; memset((char *)sc->rl_ldata.rl_rx_list, 0, RL_RX_LIST_SZ); - memset((char *)&sc->rl_ldata.rl_rx_mbuf, 0, - (RL_RX_DESC_CNT * sizeof(struct mbuf *))); for (i = 0; i < RL_RX_DESC_CNT; i++) { if (re_newbuf(sc, i, NULL) == ENOBUFS) @@ -1189,6 +1189,7 @@ re_rxeof(struct rl_softc *sc) struct ifnet *ifp; int i, total_len; struct rl_desc *cur_rx; + struct rl_rxsoft *rxs; u_int32_t rxstat; ifp = &sc->sc_arpcom.ac_if; @@ -1202,16 +1203,15 @@ re_rxeof(struct rl_softc *sc) if ((rxstat & RL_RDESC_STAT_OWN) != 0) break; total_len = rxstat & sc->rl_rxlenmask; - m = sc->rl_ldata.rl_rx_mbuf[i]; + rxs = &sc->rl_ldata.rl_rxsoft[i]; + m = rxs->rxs_mbuf; /* Invalidate the RX mbuf and unload its map */ bus_dmamap_sync(sc->sc_dmat, - sc->rl_ldata.rl_rx_dmamap[i], - 0, sc->rl_ldata.rl_rx_dmamap[i]->dm_mapsize, + rxs->rxs_dmamap, 0, rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); - bus_dmamap_unload(sc->sc_dmat, - sc->rl_ldata.rl_rx_dmamap[i]); + bus_dmamap_unload(sc->sc_dmat, rxs->rxs_dmamap); if (!(rxstat & RL_RDESC_STAT_EOF)) { m->m_len = RE_RX_DESC_BUFLEN; @@ -2053,11 +2053,11 @@ re_stop(struct ifnet *ifp, int disable) /* Free the RX list buffers. */ for (i = 0; i < RL_RX_DESC_CNT; i++) { - if (sc->rl_ldata.rl_rx_mbuf[i] != NULL) { + if (sc->rl_ldata.rl_rxsoft[i].rxs_mbuf != NULL) { bus_dmamap_unload(sc->sc_dmat, - sc->rl_ldata.rl_rx_dmamap[i]); - m_freem(sc->rl_ldata.rl_rx_mbuf[i]); - sc->rl_ldata.rl_rx_mbuf[i] = NULL; + sc->rl_ldata.rl_rxsoft[i].rxs_dmamap); + m_freem(sc->rl_ldata.rl_rxsoft[i].rxs_mbuf); + sc->rl_ldata.rl_rxsoft[i].rxs_mbuf = NULL; } } } diff --git a/sys/dev/ic/rtl81x9reg.h b/sys/dev/ic/rtl81x9reg.h index d95bae7cdcb..99ebe3a6962 100644 --- a/sys/dev/ic/rtl81x9reg.h +++ b/sys/dev/ic/rtl81x9reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rtl81x9reg.h,v 1.30 2006/10/31 22:45:15 brad Exp $ */ +/* $OpenBSD: rtl81x9reg.h,v 1.31 2006/11/01 23:25:18 brad Exp $ */ /* * Copyright (c) 1997, 1998 @@ -672,6 +672,11 @@ struct rl_mii_frame { #define RL_ISCPLUS(x) ((x)->rl_type == RL_8139CPLUS || \ (x)->rl_type == RL_8169) +struct rl_rxsoft { + struct mbuf *rxs_mbuf; + bus_dmamap_t rxs_dmamap; +}; + struct rl_list_data { struct rl_txq { struct mbuf *txq_mbuf; @@ -688,8 +693,7 @@ struct rl_list_data { int rl_tx_desc_cnt; /* # of descriptors */ int rl_tx_listnseg; - struct mbuf *rl_rx_mbuf[RL_RX_DESC_CNT]; - bus_dmamap_t rl_rx_dmamap[RL_RX_DESC_CNT]; + struct rl_rxsoft rl_rxsoft[RL_RX_DESC_CNT]; bus_dmamap_t rl_rx_list_map; struct rl_desc *rl_rx_list; bus_dma_segment_t rl_rx_listseg; |