diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2015-02-09 03:09:58 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2015-02-09 03:09:58 +0000 |
commit | b0353336ff6ce726e4e5366de313c7cbf62de3c1 (patch) | |
tree | fd9f6697d602f010faef8ab7cea36876d97858f0 /sys | |
parent | a25e352d6018713d381fa67714bda8e417e30715 (diff) |
tweak the new if_input function so it takes an mbuf_list instead
of a single mbuf. this forces us to batch work between the hardware
rx handlers and the stack.
this includes a converstion of bge from ether_input to if_input.
ok claudio@ pelikan@ mpi@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/macppc/dev/if_bm.c | 6 | ||||
-rw-r--r-- | sys/arch/macppc/dev/if_mc.c | 6 | ||||
-rw-r--r-- | sys/dev/ic/gem.c | 7 | ||||
-rw-r--r-- | sys/dev/ic/re.c | 7 | ||||
-rw-r--r-- | sys/dev/pci/if_bge.c | 15 | ||||
-rw-r--r-- | sys/dev/pci/if_em.c | 8 | ||||
-rw-r--r-- | sys/dev/pci/if_pcn.c | 13 | ||||
-rw-r--r-- | sys/dev/pci/if_vio.c | 7 | ||||
-rw-r--r-- | sys/net/if.c | 21 | ||||
-rw-r--r-- | sys/net/if_var.h | 5 | ||||
-rw-r--r-- | sys/net80211/ieee80211_input.c | 9 |
11 files changed, 63 insertions, 41 deletions
diff --git a/sys/arch/macppc/dev/if_bm.c b/sys/arch/macppc/dev/if_bm.c index 903b05218cc..0e290d226ec 100644 --- a/sys/arch/macppc/dev/if_bm.c +++ b/sys/arch/macppc/dev/if_bm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bm.c,v 1.30 2015/02/08 07:00:48 mpi Exp $ */ +/* $OpenBSD: if_bm.c,v 1.31 2015/02/09 03:09:57 dlg Exp $ */ /* $NetBSD: if_bm.c,v 1.1 1999/01/01 01:27:52 tsubai Exp $ */ /*- @@ -500,6 +500,7 @@ bmac_rint(void *v) { struct bmac_softc *sc = v; struct ifnet *ifp = &sc->arpcom.ac_if; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct mbuf *m; dbdma_command_t *cmd; int status, resid, count, datalen; @@ -547,7 +548,7 @@ bmac_rint(void *v) goto next; } - if_input(ifp, m); + ml_enqueue(&ml, m); ifp->if_ipackets++; next: @@ -560,6 +561,7 @@ next: } dbdma_continue(sc->sc_rxdma); + if_input(ifp, &ml); return (1); } diff --git a/sys/arch/macppc/dev/if_mc.c b/sys/arch/macppc/dev/if_mc.c index 41768f10319..7f7d46df12a 100644 --- a/sys/arch/macppc/dev/if_mc.c +++ b/sys/arch/macppc/dev/if_mc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_mc.c,v 1.19 2015/02/08 07:00:48 mpi Exp $ */ +/* $OpenBSD: if_mc.c,v 1.20 2015/02/09 03:09:57 dlg Exp $ */ /* $NetBSD: if_mc.c,v 1.9.16.1 2006/06/21 14:53:13 yamt Exp $ */ /*- @@ -875,6 +875,7 @@ void mace_read(struct mc_softc *sc, caddr_t pkt, int len) { struct ifnet *ifp = &sc->sc_arpcom.ac_if; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct mbuf *m; if (len <= sizeof(struct ether_header) || @@ -893,7 +894,8 @@ mace_read(struct mc_softc *sc, caddr_t pkt, int len) return; } - if_input(ifp, m); + ml_enqueue(&ml, m); + if_input(ifp, &ml); ifp->if_ipackets++; } diff --git a/sys/dev/ic/gem.c b/sys/dev/ic/gem.c index fae8f1f33d2..1f58704f300 100644 --- a/sys/dev/ic/gem.c +++ b/sys/dev/ic/gem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gem.c,v 1.109 2015/02/08 06:02:03 mpi Exp $ */ +/* $OpenBSD: gem.c,v 1.110 2015/02/09 03:09:57 dlg Exp $ */ /* $NetBSD: gem.c,v 1.1 2001/09/16 00:11:43 eeh Exp $ */ /* @@ -945,6 +945,7 @@ gem_rint(struct gem_softc *sc) bus_space_tag_t t = sc->sc_bustag; bus_space_handle_t h = sc->sc_h1; struct gem_rxsoft *rxs; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct mbuf *m; u_int64_t rxstat; int i, len; @@ -1000,7 +1001,7 @@ gem_rint(struct gem_softc *sc) ifp->if_ipackets++; m->m_pkthdr.len = m->m_len = len; - if_input(ifp, m); + ml_enqueue(&ml, m); } /* Update the receive pointer. */ @@ -1011,6 +1012,8 @@ gem_rint(struct gem_softc *sc) DPRINTF(sc, ("gem_rint: done sc->sc_rx_cons %d, complete %d\n", sc->sc_rx_cons, bus_space_read_4(t, h, GEM_RX_COMPLETION))); + if_input(ifp, &ml); + return (1); } diff --git a/sys/dev/ic/re.c b/sys/dev/ic/re.c index d82b8322fac..51045cd3706 100644 --- a/sys/dev/ic/re.c +++ b/sys/dev/ic/re.c @@ -1,4 +1,4 @@ -/* $OpenBSD: re.c,v 1.174 2015/02/08 06:55:28 mpi Exp $ */ +/* $OpenBSD: re.c,v 1.175 2015/02/09 03:09:57 dlg Exp $ */ /* $FreeBSD: if_re.c,v 1.31 2004/09/04 07:54:05 ru Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -1272,6 +1272,7 @@ re_rx_list_fill(struct rl_softc *sc) int re_rxeof(struct rl_softc *sc) { + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct mbuf *m; struct ifnet *ifp; int i, total_len, rx = 0; @@ -1421,12 +1422,14 @@ re_rxeof(struct rl_softc *sc) } #endif - if_input(ifp, m); + ml_enqueue(&ml, m); } sc->rl_ldata.rl_rx_considx = i; re_rx_list_fill(sc); + if_input(ifp, &ml); + return (rx); } diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c index a7452c5b71d..43d9276771b 100644 --- a/sys/dev/pci/if_bge.c +++ b/sys/dev/pci/if_bge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bge.c,v 1.363 2015/01/24 02:36:03 brad Exp $ */ +/* $OpenBSD: if_bge.c,v 1.364 2015/02/09 03:09:57 dlg Exp $ */ /* * Copyright (c) 2001 Wind River Systems @@ -3415,6 +3415,7 @@ bge_reset(struct bge_softc *sc) void bge_rxeof(struct bge_softc *sc) { + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct ifnet *ifp; uint16_t rx_prod, rx_cons; int stdcnt = 0, jumbocnt = 0; @@ -3521,15 +3522,7 @@ bge_rxeof(struct bge_softc *sc) } #endif -#if NBPFILTER > 0 - /* - * Handle BPF listeners. Let the BPF user see the packet. - */ - if (ifp->if_bpf) - bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); -#endif - - ether_input_mbuf(ifp, m); + ml_enqueue(&ml, m); } sc->bge_rx_saved_considx = rx_cons; @@ -3542,6 +3535,8 @@ bge_rxeof(struct bge_softc *sc) if_rxr_put(&sc->bge_jumbo_ring, jumbocnt); bge_fill_rx_ring_jumbo(sc); } + + if_input(ifp, &ml); } void diff --git a/sys/dev/pci/if_em.c b/sys/dev/pci/if_em.c index 55daeb15e49..49939a03bbf 100644 --- a/sys/dev/pci/if_em.c +++ b/sys/dev/pci/if_em.c @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ -/* $OpenBSD: if_em.c,v 1.292 2015/02/08 06:02:24 mpi Exp $ */ +/* $OpenBSD: if_em.c,v 1.293 2015/02/09 03:09:57 dlg Exp $ */ /* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */ #include <dev/pci/if_em.h> @@ -2844,6 +2844,7 @@ void em_rxeof(struct em_softc *sc) { struct ifnet *ifp = &sc->interface_data.ac_if; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct mbuf *m; u_int8_t accept_frame = 0; u_int8_t eop = 0; @@ -2969,8 +2970,7 @@ em_rxeof(struct em_softc *sc) m->m_flags |= M_VLANTAG; } #endif - - if_input(ifp, m); + ml_enqueue(&ml, m); sc->fmp = NULL; sc->lmp = NULL; @@ -2996,6 +2996,8 @@ em_rxeof(struct em_softc *sc) 0, sizeof(*desc) * sc->num_rx_desc, BUS_DMASYNC_PREREAD); + if_input(ifp, &ml); + sc->next_rx_desc_to_check = i; } diff --git a/sys/dev/pci/if_pcn.c b/sys/dev/pci/if_pcn.c index e1a7151977d..954b3b3e53c 100644 --- a/sys/dev/pci/if_pcn.c +++ b/sys/dev/pci/if_pcn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pcn.c,v 1.34 2015/02/08 06:55:28 mpi Exp $ */ +/* $OpenBSD: if_pcn.c,v 1.35 2015/02/09 03:09:57 dlg Exp $ */ /* $NetBSD: if_pcn.c,v 1.26 2005/05/07 09:15:44 is Exp $ */ /* @@ -1298,8 +1298,10 @@ pcn_rxintr(struct pcn_softc *sc) struct ifnet *ifp = &sc->sc_arpcom.ac_if; struct pcn_rxsoft *rxs; struct mbuf *m; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); uint32_t rmd1; int i, len; + int rv = 0; for (i = sc->sc_rxptr;; i = PCN_NEXTRX(i)) { rxs = &sc->sc_rxsoft[i]; @@ -1324,7 +1326,8 @@ pcn_rxintr(struct pcn_softc *sc) (LE_R1_STP|LE_R1_ENP)) { printf("%s: packet spilled into next buffer\n", sc->sc_dev.dv_xname); - return (1); /* pcn_intr() will re-init */ + rv = 1; /* pcn_intr() will re-init */ + goto done; } /* @@ -1412,13 +1415,15 @@ pcn_rxintr(struct pcn_softc *sc) m->m_pkthdr.len = m->m_len = len; - if_input(ifp, m); + ml_enqueue(&ml, m); ifp->if_ipackets++; } /* Update the receive pointer. */ sc->sc_rxptr = i; - return (0); +done: + if_input(ifp, &ml); + return (rv); } /* diff --git a/sys/dev/pci/if_vio.c b/sys/dev/pci/if_vio.c index d61a6a28903..68ffb3ff794 100644 --- a/sys/dev/pci/if_vio.c +++ b/sys/dev/pci/if_vio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vio.c,v 1.23 2015/02/09 00:27:58 pelikan Exp $ */ +/* $OpenBSD: if_vio.c,v 1.24 2015/02/09 03:09:57 dlg Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg. @@ -973,6 +973,7 @@ vio_rxeof(struct vio_softc *sc) struct virtio_softc *vsc = sc->sc_virtio; struct virtqueue *vq = &sc->sc_vq[VQRX]; struct ifnet *ifp = &sc->sc_ac.ac_if; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct mbuf *m, *m0 = NULL, *mlast; int r = 0; int slot, len, bufs_left; @@ -1009,7 +1010,7 @@ vio_rxeof(struct vio_softc *sc) if (bufs_left == 0) { ifp->if_ipackets++; - if_input(ifp, m0); + ml_enqueue(&ml, m0); m0 = NULL; } } @@ -1019,6 +1020,8 @@ vio_rxeof(struct vio_softc *sc) ifp->if_ierrors++; m_freem(m0); } + + if_input(ifp, &ml); return r; } diff --git a/sys/net/if.c b/sys/net/if.c index 7a99fdf7255..1bd00d9db0e 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.318 2015/02/09 00:21:58 dlg Exp $ */ +/* $OpenBSD: if.c,v 1.319 2015/02/09 03:09:57 dlg Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -433,23 +433,26 @@ if_start(struct ifnet *ifp) } void -if_input(struct ifnet *ifp, struct mbuf *m) +if_input(struct ifnet *ifp, struct mbuf_list *ml) { + struct mbuf *m; struct ifih *ifih; splassert(IPL_NET); - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.ph_rtableid = ifp->if_rdomain; + while ((m = ml_dequeue(ml)) != NULL) { + m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.ph_rtableid = ifp->if_rdomain; #if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); + if (ifp->if_bpf) + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif - SLIST_FOREACH(ifih, &ifp->if_inputs, ifih_next) { - if ((*ifih->ifih_input)(ifp, NULL, m)) - break; + SLIST_FOREACH(ifih, &ifp->if_inputs, ifih_next) { + if ((*ifih->ifih_input)(ifp, NULL, m)) + break; + } } } diff --git a/sys/net/if_var.h b/sys/net/if_var.h index c488bf58868..92308d05023 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_var.h,v 1.19 2015/02/08 06:00:52 mpi Exp $ */ +/* $OpenBSD: if_var.h,v 1.20 2015/02/09 03:09:57 dlg Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -69,6 +69,7 @@ #include <sys/time.h> struct mbuf; +struct mbuf_list; struct proc; struct rtentry; struct socket; @@ -396,7 +397,7 @@ extern struct ifnet_head ifnet; extern struct ifnet *lo0ifp; void if_start(struct ifnet *); -void if_input(struct ifnet *, struct mbuf *); +void if_input(struct ifnet *, struct mbuf_list *); #define ether_input_mbuf(ifp, m) ether_input((ifp), NULL, (m)) diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c index 2a47c8a2ad4..fb1842dfdca 100644 --- a/sys/net80211/ieee80211_input.c +++ b/sys/net80211/ieee80211_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_input.c,v 1.131 2015/02/08 06:03:07 mpi Exp $ */ +/* $OpenBSD: ieee80211_input.c,v 1.132 2015/02/09 03:09:57 dlg Exp $ */ /*- * Copyright (c) 2001 Atsushi Onoe @@ -870,8 +870,11 @@ ieee80211_deliver_data(struct ieee80211com *ic, struct mbuf *m, bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif ieee80211_eapol_key_input(ic, m, ni); - } else - if_input(ifp, m); + } else { + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); + ml_enqueue(&ml, m); + if_input(ifp, &ml); + } } } |