From bdcfb926d312d4fba7c5ea44f672b068b9096b06 Mon Sep 17 00:00:00 2001 From: mpi Date: Thu, 30 Apr 2015 07:51:07 +0000 Subject: [PATCH] Convert moar drivers to if_input(). ok dlg@ --- sys/dev/pci/if_age.c | 14 +++++--------- sys/dev/pci/if_et.c | 15 +++++---------- sys/dev/pci/if_ixgb.c | 17 +++++------------ sys/dev/pci/if_msk.c | 13 ++++--------- sys/dev/pci/if_oce.c | 14 ++++---------- sys/dev/pci/if_se.c | 13 +++++-------- sys/dev/pci/if_stge.c | 18 +++++------------- sys/dev/pci/if_tht.c | 13 +++++-------- sys/dev/pci/if_tl.c | 13 +++++-------- sys/dev/pci/if_txp.c | 20 +++++--------------- sys/dev/pci/if_vte.c | 14 +++++--------- sys/dev/pci/if_xge.c | 13 +++++-------- 12 files changed, 58 insertions(+), 119 deletions(-) diff --git a/sys/dev/pci/if_age.c b/sys/dev/pci/if_age.c index b81d77facc5..e73c408623c 100644 --- a/sys/dev/pci/if_age.c +++ b/sys/dev/pci/if_age.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_age.c,v 1.26 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: if_age.c,v 1.27 2015/04/30 07:51:07 mpi Exp $ */ /*- * Copyright (c) 2008, Pyun YongHyeon @@ -1282,6 +1282,7 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd) struct ifnet *ifp = &sc->sc_arpcom.ac_if; struct age_rxdesc *rxd; struct rx_desc *desc; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct mbuf *mp, *m; uint32_t status, index; int count, nsegs, pktlen; @@ -1368,7 +1369,6 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd) m = sc->age_cdata.age_rxhead; m->m_flags |= M_PKTHDR; - m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = sc->age_cdata.age_rxlen; /* Set the first mbuf length. */ m->m_len = sc->age_cdata.age_rxlen - pktlen; @@ -1410,19 +1410,15 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd) } #endif -#if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap_ether(ifp->if_bpf, m, - BPF_DIRECTION_IN); -#endif - /* Pass it on. */ - ether_input_mbuf(ifp, m); + ml_enqueue(&ml, m); /* Reset mbuf chains. */ AGE_RXCHAIN_RESET(sc); } } + if_input(ifp, &ml); + if (count != nsegs) { sc->age_cdata.age_rx_cons += nsegs; sc->age_cdata.age_rx_cons %= AGE_RX_RING_CNT; diff --git a/sys/dev/pci/if_et.c b/sys/dev/pci/if_et.c index eb4ffcc7929..7e63cea4725 100644 --- a/sys/dev/pci/if_et.c +++ b/sys/dev/pci/if_et.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_et.c,v 1.26 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: if_et.c,v 1.27 2015/04/30 07:51:07 mpi Exp $ */ /* * Copyright (c) 2007 The DragonFly Project. All rights reserved. * @@ -1677,6 +1677,7 @@ void et_rxeof(struct et_softc *sc) { struct ifnet *ifp = &sc->sc_arpcom.ac_if; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct et_rxstatus_data *rxsd = &sc->sc_rx_status; struct et_rxstat_ring *rxst_ring = &sc->sc_rxstat_ring; uint32_t rxs_stat_ring; @@ -1744,16 +1745,8 @@ et_rxeof(struct et_softc *sc) } else { m->m_pkthdr.len = m->m_len = buflen - ETHER_CRC_LEN; - m->m_pkthdr.rcvif = ifp; - -#if NBPFILTER > 0 - if (ifp->if_bpf != NULL) - bpf_mtap(ifp->if_bpf, m, - BPF_DIRECTION_IN); -#endif - + ml_enqueue(&ml, m); ifp->if_ipackets++; - ether_input_mbuf(ifp, m); } } else { ifp->if_ierrors++; @@ -1777,6 +1770,8 @@ et_rxeof(struct et_softc *sc) rxring_pos |= ET_RX_RING_POS_WRAP; CSR_WRITE_4(sc, rx_ring->rr_posreg, rxring_pos); } + + if_input(ifp, &ml); } int diff --git a/sys/dev/pci/if_ixgb.c b/sys/dev/pci/if_ixgb.c index 9d238f3a9c2..a6e54d0b1de 100644 --- a/sys/dev/pci/if_ixgb.c +++ b/sys/dev/pci/if_ixgb.c @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ -/* $OpenBSD: if_ixgb.c,v 1.63 2014/12/22 02:28:52 tedu Exp $ */ +/* $OpenBSD: if_ixgb.c,v 1.64 2015/04/30 07:51:07 mpi Exp $ */ #include @@ -1705,6 +1705,7 @@ void ixgb_rxeof(struct ixgb_softc *sc, int count) { struct ifnet *ifp; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct mbuf *mp; int eop = 0; int len; @@ -1769,7 +1770,6 @@ ixgb_rxeof(struct ixgb_softc *sc, int count) if (eop) { eop_desc = i; - sc->fmp->m_pkthdr.rcvif = ifp; ifp->if_ipackets++; ixgb_receive_checksum(sc, current_desc, sc->fmp); @@ -1781,17 +1781,8 @@ ixgb_rxeof(struct ixgb_softc *sc, int count) } #endif -#if NBPFILTER > 0 - /* - * Handle BPF listeners. Let the BPF - * user see the packet. - */ - if (ifp->if_bpf) - bpf_mtap_ether(ifp->if_bpf, sc->fmp, - BPF_DIRECTION_IN); -#endif - ether_input_mbuf(ifp, sc->fmp); + ml_enqueue(&ml, sc->fmp); sc->fmp = NULL; sc->lmp = NULL; } @@ -1860,6 +1851,8 @@ ixgb_rxeof(struct ixgb_softc *sc, int count) next_to_use = (sc->num_rx_desc - 1); /* Advance the IXGB's Receive Queue #0 "Tail Pointer" */ IXGB_WRITE_REG(&sc->hw, RDT, next_to_use); + + if_input(ifp, &ml); } /********************************************************************* diff --git a/sys/dev/pci/if_msk.c b/sys/dev/pci/if_msk.c index 0b6866ca683..cde67d0b0bb 100644 --- a/sys/dev/pci/if_msk.c +++ b/sys/dev/pci/if_msk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_msk.c,v 1.113 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: if_msk.c,v 1.114 2015/04/30 07:51:07 mpi Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -1628,6 +1628,7 @@ msk_rxeof(struct sk_if_softc *sc_if, u_int16_t len, u_int32_t rxstat) { struct sk_softc *sc = sc_if->sk_softc; struct ifnet *ifp = &sc_if->arpcom.ac_if; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct mbuf *m; struct sk_chain *cur_rx; int i, cur, total_len = len; @@ -1665,18 +1666,12 @@ msk_rxeof(struct sk_if_softc *sc_if, u_int16_t len, u_int32_t rxstat) return; } - m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = total_len; + ml_enqueue(&ml, m); ifp->if_ipackets++; -#if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); -#endif - - /* pass it on. */ - ether_input_mbuf(ifp, m); + if_input(ifp, &ml); } void diff --git a/sys/dev/pci/if_oce.c b/sys/dev/pci/if_oce.c index 6e6f7937534..b77aebb23c8 100644 --- a/sys/dev/pci/if_oce.c +++ b/sys/dev/pci/if_oce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_oce.c,v 1.82 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: if_oce.c,v 1.83 2015/04/30 07:51:07 mpi Exp $ */ /* * Copyright (c) 2012 Mike Belopuhov @@ -1547,6 +1547,7 @@ oce_rxeof(struct oce_rq *rq, struct oce_nic_rx_cqe *cqe) struct oce_softc *sc = rq->sc; struct oce_pkt *pkt = NULL; struct ifnet *ifp = &sc->sc_ac.ac_if; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct mbuf *m = NULL, *tail = NULL; int i, len, frag_len; uint16_t vtag; @@ -1606,8 +1607,6 @@ oce_rxeof(struct oce_rq *rq, struct oce_nic_rx_cqe *cqe) goto exit; } - m->m_pkthdr.rcvif = ifp; - #if NVLAN > 0 /* This determines if vlan tag is valid */ if (oce_vtp_valid(sc, cqe)) { @@ -1645,15 +1644,10 @@ oce_rxeof(struct oce_rq *rq, struct oce_nic_rx_cqe *cqe) } #endif -#if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); -#endif - - ether_input_mbuf(ifp, m); + ml_enqueue(&ml, m); } exit: - return; + if_input(ifp, &ml); } void diff --git a/sys/dev/pci/if_se.c b/sys/dev/pci/if_se.c index bd1e51e396a..d4cce3eb905 100644 --- a/sys/dev/pci/if_se.c +++ b/sys/dev/pci/if_se.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_se.c,v 1.11 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: if_se.c,v 1.12 2015/04/30 07:51:07 mpi Exp $ */ /*- * Copyright (c) 2009, 2010 Christopher Zimmermann @@ -909,6 +909,7 @@ void se_rxeof(struct se_softc *sc) { struct mbuf *m; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct ifnet *ifp = &sc->sc_ac.ac_if; struct se_list_data *ld = &sc->se_ldata; struct se_chain_data *cd = &sc->se_cdata; @@ -960,16 +961,12 @@ se_rxeof(struct se_softc *sc) m->m_pkthdr.len = m->m_len = SE_RX_BYTES(rxstat) - SE_RX_PAD_BYTES; + ml_enqueue(&ml, m); ifp->if_ipackets++; - m->m_pkthdr.rcvif = ifp; - -#if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); -#endif - ether_input_mbuf(ifp, m); } + if_input(ifp, &ml); + cd->se_rx_prod = i; } diff --git a/sys/dev/pci/if_stge.c b/sys/dev/pci/if_stge.c index d9bec728bcd..5afbe346e44 100644 --- a/sys/dev/pci/if_stge.c +++ b/sys/dev/pci/if_stge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_stge.c,v 1.59 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: if_stge.c,v 1.60 2015/04/30 07:51:07 mpi Exp $ */ /* $NetBSD: if_stge.c,v 1.27 2005/05/16 21:35:32 bouyer Exp $ */ /*- @@ -854,6 +854,7 @@ stge_rxintr(struct stge_softc *sc) struct ifnet *ifp = &sc->sc_arpcom.ac_if; struct stge_descsoft *ds; struct mbuf *m, *tailm; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); uint64_t status; int i, len; @@ -992,24 +993,15 @@ stge_rxintr(struct stge_softc *sc) } #endif - m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = len; -#if NBPFILTER > 0 - /* - * Pass this up to any BPF listeners, but only - * pass if up the stack if it's for us. - */ - if (ifp->if_bpf) - bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); -#endif /* NBPFILTER > 0 */ - - /* Pass it on. */ - ether_input_mbuf(ifp, m); + ml_enqueue(&ml, m); } /* Update the receive pointer. */ sc->sc_rxptr = i; + + if_input(ifp, &ml); } /* diff --git a/sys/dev/pci/if_tht.c b/sys/dev/pci/if_tht.c index 71f533c8411..56c6ffaa1f1 100644 --- a/sys/dev/pci/if_tht.c +++ b/sys/dev/pci/if_tht.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tht.c,v 1.130 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: if_tht.c,v 1.131 2015/04/30 07:51:07 mpi Exp $ */ /* * Copyright (c) 2007 David Gwynne @@ -1333,6 +1333,7 @@ tht_rxd(struct tht_softc *sc) struct tht_rx_desc rxd; struct tht_pkt *pkt; struct mbuf *m; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); int bc; u_int32_t flags; @@ -1356,17 +1357,11 @@ tht_rxd(struct tht_softc *sc) bus_dmamap_unload(dmat, dmap); m = pkt->tp_m; - m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = letoh16(rxd.len); /* XXX process type 3 rx descriptors */ -#if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); -#endif - - ether_input_mbuf(ifp, m); + ml_enqueue(&ml, m); tht_pkt_put(&sc->sc_rx_list, pkt); @@ -1383,6 +1378,8 @@ tht_rxd(struct tht_softc *sc) tht_fifo_post(sc, &sc->sc_rxd); + if_input(ifp, &ml); + /* put more pkts on the fifo */ tht_rxf_fill(sc, 0); } diff --git a/sys/dev/pci/if_tl.c b/sys/dev/pci/if_tl.c index 36b9e7ae4a7..499ca6a71a7 100644 --- a/sys/dev/pci/if_tl.c +++ b/sys/dev/pci/if_tl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tl.c,v 1.62 2015/04/01 14:29:54 mpi Exp $ */ +/* $OpenBSD: if_tl.c,v 1.63 2015/04/30 07:51:07 mpi Exp $ */ /* * Copyright (c) 1997, 1998 @@ -1031,6 +1031,7 @@ tl_intvec_rxeof(void *xsc, u_int32_t type) int r = 0, total_len = 0; struct ether_header *eh; struct mbuf *m; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct ifnet *ifp; struct tl_chain_onefrag *cur_rx; @@ -1060,7 +1061,6 @@ tl_intvec_rxeof(void *xsc, u_int32_t type) sc->tl_cdata.tl_rx_tail = cur_rx; eh = mtod(m, struct ether_header *); - m->m_pkthdr.rcvif = ifp; /* * Note: when the ThunderLAN chip is in 'capture all @@ -1076,14 +1076,11 @@ tl_intvec_rxeof(void *xsc, u_int32_t type) } m->m_pkthdr.len = m->m_len = total_len; -#if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); -#endif - /* pass it on. */ - ether_input_mbuf(ifp, m); + ml_enqueue(&ml, m); } + if_input(ifp, &ml); + return(r); } diff --git a/sys/dev/pci/if_txp.c b/sys/dev/pci/if_txp.c index 1daf695eaed..2ac49288666 100644 --- a/sys/dev/pci/if_txp.c +++ b/sys/dev/pci/if_txp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_txp.c,v 1.114 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: if_txp.c,v 1.115 2015/04/30 07:51:07 mpi Exp $ */ /* * Copyright (c) 2001 @@ -602,6 +602,7 @@ txp_rx_reclaim(struct txp_softc *sc, struct txp_rx_ring *r, struct ifnet *ifp = &sc->sc_arpcom.ac_if; struct txp_rx_desc *rxd; struct mbuf *m; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct txp_swdesc *sd; u_int32_t roff, woff; int idx; @@ -659,7 +660,6 @@ txp_rx_reclaim(struct txp_softc *sc, struct txp_rx_ring *r, goto next; } } - mnew->m_pkthdr.rcvif = ifp; mnew->m_pkthdr.len = mnew->m_len = m->m_len; mnew->m_data += 2; bcopy(m->m_data, mnew->m_data, m->m_len); @@ -680,14 +680,6 @@ txp_rx_reclaim(struct txp_softc *sc, struct txp_rx_ring *r, } #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 - if (rxd->rx_stat & htole32(RX_STAT_IPCKSUMBAD)) sumflags |= M_IPV4_CSUM_IN_BAD; else if (rxd->rx_stat & htole32(RX_STAT_IPCKSUMGOOD)) @@ -705,7 +697,7 @@ txp_rx_reclaim(struct txp_softc *sc, struct txp_rx_ring *r, m->m_pkthdr.csum_flags = sumflags; - ether_input_mbuf(ifp, m); + ml_enqueue(&ml, m); next: bus_dmamap_sync(sc->sc_dmat, dma->dma_map, @@ -724,13 +716,14 @@ next: woff = letoh32(*r->r_woff); } + if_input(ifp, &ml); + *r->r_roff = htole32(woff); } void txp_rxbuf_reclaim(struct txp_softc *sc) { - struct ifnet *ifp = &sc->sc_arpcom.ac_if; struct txp_hostvar *hv = sc->sc_hostvar; struct txp_rxbuf_desc *rbd; struct txp_swdesc *sd; @@ -757,7 +750,6 @@ txp_rxbuf_reclaim(struct txp_softc *sc) MCLGET(sd->sd_mbuf, M_DONTWAIT); if ((sd->sd_mbuf->m_flags & M_EXT) == 0) goto err_mbuf; - sd->sd_mbuf->m_pkthdr.rcvif = ifp; sd->sd_mbuf->m_pkthdr.len = sd->sd_mbuf->m_len = MCLBYTES; if (bus_dmamap_create(sc->sc_dmat, TXP_MAX_PKTLEN, 1, TXP_MAX_PKTLEN, 0, BUS_DMA_NOWAIT, &sd->sd_map)) @@ -862,7 +854,6 @@ txp_tx_reclaim(struct txp_softc *sc, struct txp_tx_ring *r, int txp_alloc_rings(struct txp_softc *sc) { - struct ifnet *ifp = &sc->sc_arpcom.ac_if; struct txp_boot_record *boot; struct txp_swdesc *sd; u_int32_t r; @@ -1024,7 +1015,6 @@ txp_alloc_rings(struct txp_softc *sc) goto bail_rxbufring; } sd->sd_mbuf->m_pkthdr.len = sd->sd_mbuf->m_len = MCLBYTES; - sd->sd_mbuf->m_pkthdr.rcvif = ifp; if (bus_dmamap_create(sc->sc_dmat, TXP_MAX_PKTLEN, 1, TXP_MAX_PKTLEN, 0, BUS_DMA_NOWAIT, &sd->sd_map)) { goto bail_rxbufring; diff --git a/sys/dev/pci/if_vte.c b/sys/dev/pci/if_vte.c index eb34e094ff2..a226b8a03a7 100644 --- a/sys/dev/pci/if_vte.c +++ b/sys/dev/pci/if_vte.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vte.c,v 1.11 2014/12/22 02:28:52 tedu Exp $ */ +/* $OpenBSD: if_vte.c,v 1.12 2015/04/30 07:51:07 mpi Exp $ */ /*- * Copyright (c) 2010, Pyun YongHyeon * All rights reserved. @@ -1000,6 +1000,7 @@ vte_rxeof(struct vte_softc *sc) struct ifnet *ifp = &sc->sc_arpcom.ac_if; struct vte_rxdesc *rxd; struct mbuf *m; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); uint16_t status, total_len; int cons, prog; @@ -1033,16 +1034,11 @@ vte_rxeof(struct vte_softc *sc) * It seems there is no way to strip FCS bytes. */ m->m_pkthdr.len = m->m_len = total_len - ETHER_CRC_LEN; - m->m_pkthdr.rcvif = ifp; - -#if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); -#endif - - ether_input_mbuf(ifp, m); + ml_enqueue(&ml, m); } + if_input(ifp, &ml); + if (prog > 0) { /* Update the consumer index. */ sc->vte_cdata.vte_rx_cons = cons; diff --git a/sys/dev/pci/if_xge.c b/sys/dev/pci/if_xge.c index 6d9310c29f2..94d3de68124 100644 --- a/sys/dev/pci/if_xge.c +++ b/sys/dev/pci/if_xge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_xge.c,v 1.60 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: if_xge.c,v 1.61 2015/04/30 07:51:07 mpi Exp $ */ /* $NetBSD: if_xge.c,v 1.1 2005/09/09 10:30:27 ragge Exp $ */ /* @@ -804,6 +804,7 @@ xge_intr(void *pv) struct xge_softc *sc = pv; struct txd *txd; struct ifnet *ifp = &sc->sc_arpcom.ac_if; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); bus_dmamap_t dmp; uint64_t val; int i, lasttx, plen; @@ -892,7 +893,6 @@ xge_intr(void *pv) plen += m->m_next->m_next->m_next->m_next->m_len = RXD_CTL3_BUF4SIZ(rxd->rxd_control3); #endif - m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = plen; val = rxd->rxd_control1; @@ -928,17 +928,14 @@ xge_intr(void *pv) } #endif -#if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); -#endif /* NBPFILTER > 0 */ - - ether_input_mbuf(ifp, m); + ml_enqueue(&ml, m); if (++sc->sc_nextrx == NRXREAL) sc->sc_nextrx = 0; } + if_input(ifp, &ml); + return (1); } -- 2.20.1