diff options
author | 2016-01-26 10:23:19 +0000 | |
---|---|---|
committer | 2016-01-26 10:23:19 +0000 | |
commit | 386f0f8f1cc34969afecdb91e21036cf27311d0b (patch) | |
tree | d1f7c727e21f691add655b0bead93d54516c99f4 | |
parent | lseek() + write() can be replaced by a slightly shorter ftruncate() (diff) | |
download | wireguard-openbsd-386f0f8f1cc34969afecdb91e21036cf27311d0b.tar.xz wireguard-openbsd-386f0f8f1cc34969afecdb91e21036cf27311d0b.zip |
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@
-rw-r--r-- | sys/dev/pci/if_vmx.c | 19 |
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); } |