> On 8 Apr 2015, at 8:09 pm, Martin Pieuchot <[email protected]> wrote:
>
> On 08/04/15(Wed) 10:03, David Gwynne wrote:
>>
>>> 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.
>>> [...]
>>> 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.
>
> Like that?
yes. ok :)
>
> 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 8 Apr 2015 10:08:37 -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;
> @@ -912,7 +913,7 @@ mtd_rxeof(struct mtd_softc *sc)
> continue;
> } else {
> mtd_init(ifp);
> - return;
> + break;
> }
> }
>
> @@ -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;
> }
>