summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>2001-10-09 15:07:21 +0000
committerJason Wright <jason@cvs.openbsd.org>2001-10-09 15:07:21 +0000
commit04f5ebd4b2bb2239f27bd32bd012886b681a6ea0 (patch)
treeb96f4e2caa394d513e49532e2470a6b179223983
parentedeea0042c9d775c4e35102da129a15ab48d52d5 (diff)
- keep a spare dmamap_t around for rx (use it to keep the old mbuf loaded
while trying to get the next buffer setup). - reduce ring size for both rx & tx
-rw-r--r--sys/dev/ic/hme.c41
-rw-r--r--sys/dev/ic/hmevar.h7
2 files changed, 32 insertions, 16 deletions
diff --git a/sys/dev/ic/hme.c b/sys/dev/ic/hme.c
index ebf8ff212ea..bec460f2109 100644
--- a/sys/dev/ic/hme.c
+++ b/sys/dev/ic/hme.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hme.c,v 1.11 2001/10/04 20:36:16 jason Exp $ */
+/* $OpenBSD: hme.c,v 1.12 2001/10/09 15:07:20 jason Exp $ */
/* $NetBSD: hme.c,v 1.21 2001/07/07 15:59:37 thorpej Exp $ */
/*-
@@ -183,6 +183,11 @@ hme_config(sc)
goto fail;
}
}
+ if (bus_dmamap_create(sc->sc_dmatag, MCLBYTES, 1, MCLBYTES, 0,
+ BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &sc->sc_rxmap_spare) != 0) {
+ sc->sc_rxmap_spare = NULL;
+ goto fail;
+ }
/*
* Allocate DMA capable memory
@@ -305,6 +310,8 @@ hme_config(sc)
return;
fail:
+ if (sc->sc_rxmap_spare != NULL)
+ bus_dmamap_destroy(sc->sc_dmatag, sc->sc_rxmap_spare);
for (i = 0; i < HME_TX_RING_SIZE; i++)
if (sc->sc_txd[i].sd_map != NULL)
bus_dmamap_destroy(sc->sc_dmatag, sc->sc_txd[i].sd_map);
@@ -1313,6 +1320,7 @@ hme_newbuf(sc, d, freeit)
int freeit;
{
struct mbuf *m;
+ bus_dmamap_t map;
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
@@ -1332,28 +1340,35 @@ hme_newbuf(sc, d, freeit)
d->sd_loaded = 0;
}
- if (bus_dmamap_load(sc->sc_dmatag, d->sd_map, mtod(m, caddr_t),
- MCLBYTES - HME_RX_OFFSET, NULL, BUS_DMA_NOWAIT) != 0) {
+ if (bus_dmamap_load(sc->sc_dmatag, sc->sc_rxmap_spare,
+ mtod(m, caddr_t), MCLBYTES - HME_RX_OFFSET, NULL,
+ BUS_DMA_NOWAIT) != 0) {
if (d->sd_mbuf == NULL)
return (ENOBUFS);
-
- /* XXX Reload old mbuf, and return. */
- bus_dmamap_load(sc->sc_dmatag, d->sd_map,
- mtod(d->sd_mbuf, caddr_t), MCLBYTES - HME_RX_OFFSET,
- NULL, BUS_DMA_NOWAIT);
- d->sd_loaded = 1;
- bus_dmamap_sync(sc->sc_dmatag, d->sd_map,
- 0, d->sd_map->dm_mapsize, BUS_DMASYNC_PREREAD);
m_freem(m);
return (ENOBUFS);
}
+
+ if (d->sd_loaded) {
+ bus_dmamap_sync(sc->sc_dmatag, d->sd_map, 0,
+ d->sd_map->dm_mapsize, BUS_DMASYNC_POSTREAD);
+ bus_dmamap_unload(sc->sc_dmatag, d->sd_map);
+ d->sd_loaded = 0;
+ }
+ if ((d->sd_mbuf != NULL) && freeit) {
+ m_freem(d->sd_mbuf);
+ d->sd_mbuf = NULL;
+ }
+
+ map = d->sd_map;
+ d->sd_map = sc->sc_rxmap_spare;
+ sc->sc_rxmap_spare = map;
+
d->sd_loaded = 1;
bus_dmamap_sync(sc->sc_dmatag, d->sd_map, 0, d->sd_map->dm_mapsize,
BUS_DMASYNC_PREREAD);
- if ((d->sd_mbuf != NULL) && freeit)
- m_freem(d->sd_mbuf);
m->m_data += HME_RX_OFFSET;
d->sd_mbuf = m;
return (0);
diff --git a/sys/dev/ic/hmevar.h b/sys/dev/ic/hmevar.h
index 0fd69900411..007b151e5e3 100644
--- a/sys/dev/ic/hmevar.h
+++ b/sys/dev/ic/hmevar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hmevar.h,v 1.4 2001/10/04 20:36:16 jason Exp $ */
+/* $OpenBSD: hmevar.h,v 1.5 2001/10/09 15:07:20 jason Exp $ */
/* $NetBSD: hmevar.h,v 1.6 2000/09/28 10:56:57 tsutsui Exp $ */
/*-
@@ -39,8 +39,8 @@
#include <sys/timeout.h>
-#define HME_TX_RING_SIZE 128
-#define HME_RX_RING_SIZE 128
+#define HME_TX_RING_SIZE 64
+#define HME_RX_RING_SIZE 64
#define HME_RX_RING_MAX 256
#define HME_TX_RING_MAX 256
#define HME_RX_PKTSIZE 1600
@@ -94,6 +94,7 @@ struct hme_softc {
void (*sc_hwinit) __P((struct hme_softc *));
struct hme_sxd sc_txd[HME_TX_RING_MAX], sc_rxd[HME_RX_RING_MAX];
+ bus_dmamap_t sc_rxmap_spare;
int sc_tx_cnt, sc_tx_prod, sc_tx_cons;
int sc_last_rd;
};