> On 8 Apr 2015, at 01:38, Martin Pieuchot <[email protected]> wrote:
>
> Here's a diff to convert these drivers to if_input(). They all make
> use of m_devget(9) which takes an ifp as argument and I'd like to
> change that. But first I need to make sure all these drivers are
> converted.
>
> If you can try this diff on one or more chips, please let me know how
> it goes.
>
> Martin
>
> Index: arch/sparc/dev/hme.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/sparc/dev/hme.c,v
> retrieving revision 1.67
> diff -u -p -r1.67 hme.c
> --- arch/sparc/dev/hme.c 22 Dec 2014 02:26:54 -0000 1.67
> +++ arch/sparc/dev/hme.c 7 Apr 2015 15:16:37 -0000
> @@ -815,6 +815,7 @@ hme_read(sc, idx, len, flags)
> u_int32_t flags;
> {
> struct ifnet *ifp = &sc->sc_arpcom.ac_if;
> + struct mbuf_list ml = MBUF_LIST_INITIALIZER();
> struct mbuf *m;
>
> if (len <= sizeof(struct ether_header) ||
> @@ -835,16 +836,8 @@ hme_read(sc, idx, len, flags)
>
> ifp->if_ipackets++;
>
> -#if NBPFILTER > 0
> - /*
> - * Check if there's a BPF listener on this interface.
> - * If so, hand off the raw packet to BPF.
> - */
> - if (ifp->if_bpf)
> - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN);
> -#endif
> - /* Pass the packet up. */
> - ether_input_mbuf(ifp, m);
> + ml_enqueue(&ml, m);
> + if_input(ifp, &ml);
> }
>
> void
this is ok by me.
maybe miod will move sparc to using the bus independant hme now that he has
bus_dma on on it?
> Index: dev/ic/mtd8xx.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/mtd8xx.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 mtd8xx.c
> --- dev/ic/mtd8xx.c 22 Dec 2014 02:28:51 -0000 1.24
> +++ dev/ic/mtd8xx.c 7 Apr 2015 15:24:43 -0000
> @@ -874,6 +874,7 @@ mtd_intr(void *xsc)
> static void
> mtd_rxeof(struct mtd_softc *sc)
> {
> + struct mbuf_list ml = MBUF_LIST_INITIALIZER();
> struct mbuf *m;
> struct ifnet *ifp;
> struct mtd_rx_desc *cur_rx;
> @@ -934,12 +935,10 @@ mtd_rxeof(struct mtd_softc *sc)
>
> ifp->if_ipackets++;
>
> -#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);
> }
> +
> + if_input(ifp, &ml);
>
> sc->mtd_cdata.mtd_rx_prod = i;
> }
no.
there's a return inside the loop in this driver, which means you'll leak the
mbufs on ml. if you use break instead of return it should be ok.
> Index: dev/pci/if_bce.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_bce.c,v
> retrieving revision 1.43
> diff -u -p -r1.43 if_bce.c
> --- dev/pci/if_bce.c 14 Mar 2015 03:38:48 -0000 1.43
> +++ dev/pci/if_bce.c 7 Apr 2015 15:25:44 -0000
> @@ -694,6 +694,7 @@ void
> bce_rxintr(struct bce_softc *sc)
> {
> struct ifnet *ifp = &sc->bce_ac.ac_if;
> + struct mbuf_list ml = MBUF_LIST_INITIALIZER();
> struct rx_pph *pph;
> struct mbuf *m;
> int curr;
> @@ -741,17 +742,7 @@ bce_rxintr(struct bce_softc *sc)
> BCE_PREPKT_HEADER_SIZE, len, ETHER_ALIGN, ifp);
> ifp->if_ipackets++;
>
> -#if NBPFILTER > 0
> - /*
> - * Pass this up to any BPF listeners, but only
> - * pass it up the stack if it's for us.
> - */
> - 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);
>
> /* re-check current in case it changed */
> curr = (bus_space_read_4(sc->bce_btag, sc->bce_bhandle,
> @@ -760,6 +751,9 @@ bce_rxintr(struct bce_softc *sc)
> if (curr >= BCE_NRXDESC)
> curr = BCE_NRXDESC - 1;
> }
> +
> + if_input(ifp, &ml);
> +
> sc->bce_rxin = curr;
> }
>
ok on this one.
> Index: dev/pci/if_lge.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_lge.c,v
> retrieving revision 1.64
> diff -u -p -r1.64 if_lge.c
> --- dev/pci/if_lge.c 22 Dec 2014 02:28:52 -0000 1.64
> +++ dev/pci/if_lge.c 7 Apr 2015 15:27:14 -0000
> @@ -680,6 +680,7 @@ lge_newbuf(struct lge_softc *sc, struct
> void
> lge_rxeof(struct lge_softc *sc, int cnt)
> {
> + struct mbuf_list ml = MBUF_LIST_INITIALIZER();
> struct mbuf *m;
> struct ifnet *ifp;
> struct lge_rx_desc *cur_rx;
> @@ -727,20 +728,11 @@ lge_rxeof(struct lge_softc *sc, int cnt)
> }
> m = m0;
> } else {
> - m->m_pkthdr.rcvif = ifp;
> m->m_pkthdr.len = m->m_len = total_len;
> }
>
> ifp->if_ipackets++;
>
> -#if NBPFILTER > 0
> - /*
> - * Handle BPF listeners. Let the BPF user see the packet.
> - */
> - if (ifp->if_bpf)
> - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN);
> -#endif
> -
> /* Do IP checksum checking. */
> if (rxsts & LGE_RXSTS_ISIP) {
> if (!(rxsts & LGE_RXSTS_IPCSUMERR))
> @@ -755,8 +747,10 @@ lge_rxeof(struct lge_softc *sc, int cnt)
> m->m_pkthdr.csum_flags |= M_UDP_CSUM_IN_OK;
> }
>
> - ether_input_mbuf(ifp, m);
> + ml_enqueue(&ml, m);
> }
> +
> + if_input(ifp, &ml);
>
> sc->lge_cdata.lge_rx_cons = i;
> }
ok.
> Index: dev/pci/if_nge.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_nge.c,v
> retrieving revision 1.81
> diff -u -p -r1.81 if_nge.c
> --- dev/pci/if_nge.c 22 Dec 2014 02:28:52 -0000 1.81
> +++ dev/pci/if_nge.c 7 Apr 2015 15:27:12 -0000
> @@ -1002,6 +1002,7 @@ nge_newbuf(struct nge_softc *sc, struct
> void
> nge_rxeof(struct nge_softc *sc)
> {
> + struct mbuf_list ml = MBUF_LIST_INITIALIZER();
> struct mbuf *m;
> struct ifnet *ifp;
> struct nge_desc *cur_rx;
> @@ -1076,7 +1077,6 @@ nge_rxeof(struct nge_softc *sc)
> m = m0;
> #ifndef __STRICT_ALIGNMENT
> } else {
> - m->m_pkthdr.rcvif = ifp;
> m->m_pkthdr.len = m->m_len = total_len;
> }
> #endif
> @@ -1091,14 +1091,6 @@ nge_rxeof(struct nge_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
> -
> /* Do IP checksum checking. */
> if (extsts & NGE_RXEXTSTS_IPPKT) {
> if (!(extsts & NGE_RXEXTSTS_IPCSUMERR))
> @@ -1111,8 +1103,10 @@ nge_rxeof(struct nge_softc *sc)
> m->m_pkthdr.csum_flags |= M_UDP_CSUM_IN_OK;
> }
>
> - ether_input_mbuf(ifp, m);
> + ml_enqueue(&ml, m);
> }
> +
> + if_input(ifp, &ml);
>
> sc->nge_cdata.nge_rx_prod = i;
> }
ok.
> Index: dev/pci/if_vge.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_vge.c,v
> retrieving revision 1.60
> diff -u -p -r1.60 if_vge.c
> --- dev/pci/if_vge.c 14 Mar 2015 03:38:48 -0000 1.60
> +++ dev/pci/if_vge.c 7 Apr 2015 15:27:53 -0000
> @@ -983,6 +983,7 @@ vge_rx_list_init(struct vge_softc *sc)
> void
> vge_rxeof(struct vge_softc *sc)
> {
> + struct mbuf_list ml = MBUF_LIST_INITIALIZER();
> struct mbuf *m;
> struct ifnet *ifp;
> int i, total_len;
> @@ -1119,7 +1120,6 @@ vge_rxeof(struct vge_softc *sc)
> m->m_data += ETHER_ALIGN;
> #endif
> ifp->if_ipackets++;
> - m->m_pkthdr.rcvif = ifp;
>
> /* Do RX checksumming */
>
> @@ -1140,16 +1140,14 @@ vge_rxeof(struct vge_softc *sc)
> }
> #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);
>
> lim++;
> if (lim == VGE_RX_DESC_CNT)
> break;
> }
> +
> + if_input(ifp, &ml);
>
> /* Flush the RX DMA ring */
> bus_dmamap_sync(sc->sc_dmat,
ok.
> Index: dev/pci/if_wb.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_wb.c,v
> retrieving revision 1.58
> diff -u -p -r1.58 if_wb.c
> --- dev/pci/if_wb.c 22 Dec 2014 02:28:52 -0000 1.58
> +++ dev/pci/if_wb.c 7 Apr 2015 15:28:58 -0000
> @@ -922,6 +922,7 @@ wb_newbuf(sc, c)
> void wb_rxeof(sc)
> struct wb_softc *sc;
> {
> + struct mbuf_list ml = MBUF_LIST_INITIALIZER();
> struct ifnet *ifp;
> struct wb_chain_onefrag *cur_rx;
> int total_len = 0;
> @@ -947,7 +948,7 @@ void wb_rxeof(sc)
> "bug, forcing reset\n", sc->sc_dev.dv_xname);
> wb_fixmedia(sc);
> wb_init(sc);
> - return;
> + break;
> }
>
> if (rxstat & WB_RXSTAT_RXERR) {
> @@ -978,18 +979,10 @@ void wb_rxeof(sc)
>
> ifp->if_ipackets++;
>
> -#if NBPFILTER > 0
> - /*
> - * Handle BPF listeners. Let the BPF user see the packet.
> - */
> - 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);
> }
>
> - return;
> + if_input(ifp, &ml);
> }
>
> void wb_rxeoc(sc)
ok.
you caught the return in that loop.
> Index: dev/pcmcia/if_malo.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pcmcia/if_malo.c,v
> retrieving revision 1.82
> diff -u -p -r1.82 if_malo.c
> --- dev/pcmcia/if_malo.c 14 Mar 2015 03:38:49 -0000 1.82
> +++ dev/pcmcia/if_malo.c 7 Apr 2015 15:31:32 -0000
> @@ -925,6 +925,7 @@ cmalo_rx(struct malo_softc *sc)
> struct ieee80211com *ic = &sc->sc_ic;
> struct ifnet *ifp = &ic->ic_if;
> struct malo_rx_desc *rxdesc;
> + struct mbuf_list ml = MBUF_LIST_INITIALIZER();
> struct mbuf *m;
> uint8_t *data;
> uint16_t psize;
> @@ -972,16 +973,18 @@ cmalo_rx(struct malo_softc *sc)
> return;
> }
>
> -#if NBPFILTER > 0
> - if (ifp->if_bpf)
> - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN);
> -#endif
> -
> /* push the frame up to the network stack if not in monitor mode */
> if (ic->ic_opmode != IEEE80211_M_MONITOR) {
> - ether_input_mbuf(ifp, m);
> ifp->if_ipackets++;
> + ml_enqueue(&ml, m);
> + if_input(ifp, &ml);
> +#if NBPFILTER > 0
> + } else {
> + if (ifp->if_bpf)
> + bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN);
> +#endif
> }
> +
> }
>
> void
>
ok.