summaryrefslogtreecommitdiff
path: root/sys/dev/pci/if_vmx.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/pci/if_vmx.c')
-rw-r--r--sys/dev/pci/if_vmx.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/sys/dev/pci/if_vmx.c b/sys/dev/pci/if_vmx.c
index f0712005afa..386c3fa8627 100644
--- a/sys/dev/pci/if_vmx.c
+++ b/sys/dev/pci/if_vmx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $ */
+/* $OpenBSD: if_vmx.c,v 1.17 2014/07/08 05:35:19 dlg Exp $ */
/*
* Copyright (c) 2013 Tsubai Masanari
@@ -71,6 +71,7 @@ struct vmxnet3_txring {
struct vmxnet3_rxring {
struct mbuf *m[NRXDESC];
bus_dmamap_t dmap[NRXDESC];
+ struct if_rxring rxr;
struct vmxnet3_rxdesc *rxd;
u_int fill;
u_int8_t gen;
@@ -483,17 +484,21 @@ vmxnet3_rxinit(struct vmxnet3_softc *sc, struct vmxnet3_rxqueue *rq)
{
struct vmxnet3_rxring *ring;
struct vmxnet3_comp_ring *comp_ring;
- int i, idx;
+ int i;
+ u_int slots;
for (i = 0; i < 2; i++) {
ring = &rq->cmd_ring[i];
ring->fill = 0;
ring->gen = 1;
bzero(ring->rxd, NRXDESC * sizeof ring->rxd[0]);
- for (idx = 0; idx < NRXDESC; idx++) {
+ if_rxr_init(&ring->rxr, 2, NRXDESC - 1);
+ for (slots = if_rxr_get(&ring->rxr, NRXDESC);
+ slots > 0; slots--) {
if (vmxnet3_getbuf(sc, ring))
break;
}
+ if_rxr_put(&ring->rxr, slots);
}
comp_ring = &rq->comp_ring;
comp_ring->next = 0;
@@ -688,6 +693,7 @@ vmxnet3_rxintr(struct vmxnet3_softc *sc, struct vmxnet3_rxqueue *rq)
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct mbuf *m;
int idx, len;
+ u_int slots;
for (;;) {
rxcd = &comp_ring->rxcd[comp_ring->next];
@@ -713,6 +719,7 @@ vmxnet3_rxintr(struct vmxnet3_softc *sc, struct vmxnet3_rxqueue *rq)
VMXNET3_RXC_LEN_M);
m = ring->m[idx];
ring->m[idx] = NULL;
+ if_rxr_put(&ring->rxr, 1);
bus_dmamap_unload(sc->sc_dmat, ring->dmap[idx]);
if (m == NULL)
@@ -772,13 +779,11 @@ skip_buffer:
/* XXX Should we (try to) allocate buffers for ring 2 too? */
ring = &rq->cmd_ring[0];
- for (;;) {
- idx = ring->fill;
- if (ring->m[idx])
- return;
+ for (slots = if_rxr_get(&ring->rxr, NRXDESC); slots > 0; slots--) {
if (vmxnet3_getbuf(sc, ring))
- return;
+ break;
}
+ if_rxr_put(&ring->rxr, slots);
}
void
@@ -855,7 +860,6 @@ vmxnet3_getbuf(struct vmxnet3_softc *sc, struct vmxnet3_rxring *ring)
{
int idx = ring->fill;
struct vmxnet3_rxdesc *rxd = &ring->rxd[idx];
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct mbuf *m;
int btype;
@@ -874,7 +878,7 @@ vmxnet3_getbuf(struct vmxnet3_softc *sc, struct vmxnet3_rxring *ring)
btype = VMXNET3_BTYPE_BODY;
#endif
- m = MCLGETI(NULL, M_DONTWAIT, ifp, JUMBO_LEN);
+ m = MCLGETI(NULL, M_DONTWAIT, NULL, JUMBO_LEN);
if (m == NULL)
return -1;