summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2016-01-26 10:23:20 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2016-01-26 10:23:20 +0000
commit0c91ece94fd469546f55b36ee67aa264c7387f0a (patch)
treef5bccb9959263a6b2d1fa770f03ee84974aadeff /sys/dev
parent7e210d27cbffdff3a13dd9c22864cbedca6f5b0b (diff)
Improve the previous fix: call vmxnet3_load_mbuf, bpf_mtap, and flip
the generation bit to pass the tx descriptor and mbuf to the "hardware". This way bpf is not called if vmxnet3_load_mbuf dropped the mbuf. Tested by me OK mikeb@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/if_vmx.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/sys/dev/pci/if_vmx.c b/sys/dev/pci/if_vmx.c
index 9fd77cc7a6b..bac7710efe0 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.42 2016/01/25 10:39:20 reyk Exp $ */
+/* $OpenBSD: if_vmx.c,v 1.43 2016/01/26 10:23:19 reyk Exp $ */
/*
* Copyright (c) 2013 Tsubai Masanari
@@ -1045,6 +1045,7 @@ vmxnet3_start(struct ifnet *ifp)
struct vmxnet3_softc *sc = ifp->if_softc;
struct vmxnet3_txqueue *tq = sc->sc_txq;
struct vmxnet3_txring *ring = &tq->cmd_ring;
+ struct vmxnet3_txdesc *txd;
struct mbuf *m;
u_int free, used;
int n;
@@ -1065,10 +1066,7 @@ vmxnet3_start(struct ifnet *ifp)
if (m == NULL)
break;
-#if NBPFILTER > 0
- if (ifp->if_bpf)
- bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_OUT);
-#endif
+ txd = &ring->txd[ring->prod];
n = vmxnet3_load_mbuf(sc, ring, &m);
if (n == -1) {
@@ -1076,6 +1074,14 @@ vmxnet3_start(struct ifnet *ifp)
continue;
}
+#if NBPFILTER > 0
+ if (ifp->if_bpf)
+ bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_OUT);
+#endif
+
+ /* Change the ownership by flipping the "generation" bit */
+ txd->tx_word2 ^= htole32(VMXNET3_TX_GEN_M << VMXNET3_TX_GEN_S);
+
ifp->if_opackets++;
used += n;
}
@@ -1182,9 +1188,6 @@ vmxnet3_load_mbuf(struct vmxnet3_softc *sc, struct vmxnet3_txring *ring,
ring->prod = prod;
- /* Change the ownership by flipping the "generation" bit */
- sop->tx_word2 ^= htole32(VMXNET3_TX_GEN_M << VMXNET3_TX_GEN_S);
-
return (map->dm_nsegs);
}