summaryrefslogtreecommitdiff
path: root/sys/dev/pci/if_vr.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2014-07-08 05:35:20 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2014-07-08 05:35:20 +0000
commit4930c61b730e44cdce66c7f71fa9f703fcae2b38 (patch)
tree69bcdb82287306b3e015c5b2778bccc9790f2f81 /sys/dev/pci/if_vr.c
parentf201a4bbc9d2fe8c3664f8b02ebf1ac13ae5b94e (diff)
cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr. cut the reporting systat did over to the rxr ioctl. tested as much as i can on alpha, amd64, and sparc64. mpi@ has run it on macppc. ok mpi@
Diffstat (limited to 'sys/dev/pci/if_vr.c')
-rw-r--r--sys/dev/pci/if_vr.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c
index 923664c04e6..9a6f9441abc 100644
--- a/sys/dev/pci/if_vr.c
+++ b/sys/dev/pci/if_vr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vr.c,v 1.133 2014/04/19 14:47:51 henning Exp $ */
+/* $OpenBSD: if_vr.c,v 1.134 2014/07/08 05:35:19 dlg Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -678,7 +678,6 @@ vr_attach(struct device *parent, struct device *self, void *aux)
/*
* Call MI attach routines.
*/
- m_clsetwms(ifp, MCLBYTES, 2, VR_RX_LIST_CNT - 1);
if_attach(ifp);
ether_ifattach(ifp);
return;
@@ -794,7 +793,7 @@ vr_list_rx_init(struct vr_softc *sc)
}
cd->vr_rx_prod = cd->vr_rx_cons = &cd->vr_rx_chain[0];
- cd->vr_rx_cnt = 0;
+ if_rxr_init(&sc->sc_rxring, 2, VR_RX_LIST_CNT - 1);
vr_fill_rx_ring(sc);
return (0);
@@ -805,19 +804,22 @@ vr_fill_rx_ring(struct vr_softc *sc)
{
struct vr_chain_data *cd;
struct vr_list_data *ld;
+ u_int slots;
cd = &sc->vr_cdata;
ld = sc->vr_ldata;
- while (cd->vr_rx_cnt < VR_RX_LIST_CNT) {
- if (vr_alloc_mbuf(sc, cd->vr_rx_prod)) {
- if (cd->vr_rx_cnt == 0)
- timeout_add(&sc->sc_rxto, 0);
+ for (slots = if_rxr_get(&sc->sc_rxring, VR_RX_LIST_CNT);
+ slots > 0; slots--) {
+ if (vr_alloc_mbuf(sc, cd->vr_rx_prod))
break;
- }
+
cd->vr_rx_prod = cd->vr_rx_prod->vr_nextdesc;
- cd->vr_rx_cnt++;
}
+
+ if_rxr_put(&sc->sc_rxring, slots);
+ if (if_rxr_inuse(&sc->sc_rxring) == 0)
+ timeout_add(&sc->sc_rxto, 0);
}
/*
@@ -835,7 +837,7 @@ vr_rxeof(struct vr_softc *sc)
ifp = &sc->arpcom.ac_if;
- while(sc->vr_cdata.vr_rx_cnt > 0) {
+ while (if_rxr_inuse(&sc->sc_rxring) > 0) {
bus_dmamap_sync(sc->sc_dmat, sc->sc_listmap.vrm_map,
0, sc->sc_listmap.vrm_map->dm_mapsize,
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
@@ -849,7 +851,7 @@ vr_rxeof(struct vr_softc *sc)
m = cur_rx->vr_mbuf;
cur_rx->vr_mbuf = NULL;
sc->vr_cdata.vr_rx_cons = cur_rx->vr_nextdesc;
- sc->vr_cdata.vr_rx_cnt--;
+ if_rxr_put(&sc->sc_rxring, 1);
/*
* If an error occurs, update stats, clear the
@@ -1094,9 +1096,9 @@ vr_rxtick(void *xsc)
int s;
s = splnet();
- if (sc->vr_cdata.vr_rx_cnt == 0) {
+ if (if_rxr_inuse(&sc->sc_rxring) == 0) {
vr_fill_rx_ring(sc);
- if (sc->vr_cdata.vr_rx_cnt == 0)
+ if (if_rxr_inuse(&sc->sc_rxring) == 0)
timeout_add(&sc->sc_rxto, 1);
}
splx(s);
@@ -1726,7 +1728,7 @@ vr_alloc_mbuf(struct vr_softc *sc, struct vr_chain_onefrag *r)
if (r == NULL)
return (EINVAL);
- m = MCLGETI(NULL, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES);
+ m = MCLGETI(NULL, M_DONTWAIT, NULL, MCLBYTES);
if (!m)
return (ENOBUFS);