PERFORCE change 93095 for review

John Baldwin jhb at freebsd.org
Sat Mar 11 02:03:37 GMT 2006


On Friday 10 March 2006 01:40 am, Warner Losh wrote:
> http://perforce.freebsd.org/chv.cgi?CH=93095
>
> Change 93095 by imp at imp_hammer on 2006/03/10 06:39:29
>
> 	Try to use m_devget() as suggested by jhb and done in the de
> 	driver.
>
> Affected files ...
>
> .. //depot/projects/arm/src/sys/arm/at91/if_ate.c#38 edit
>
> Differences ...
>
> ==== //depot/projects/arm/src/sys/arm/at91/if_ate.c#38 (text+ko) ====
>
> @@ -24,10 +24,8 @@
>
>  /* TODO: (in no order)
>   *
> - * 5) Setup RX buffers in ateinit_locked
>   * 8) Need to sync busdma goo in atestop
>   * 9) atestop should maybe free the mbufs?
> - * 10) On Rx, how do we get a new mbuf?
>   *
>   * 1) detach
>   * 2) Free dma setup
> @@ -657,7 +655,8 @@
>  			mb->m_len = rx_stat & ETH_LEN_MASK;
>  			mb->m_pkthdr.len = mb->m_len;
>  			mb->m_pkthdr.rcvif = sc->ifp;
> -			tmp_mbuf = m_copyup(mb, ETHER_HDR_LEN, 2);
> +			tmp_mbuf = m_devget(mtod(md, caddr_t), mb->m_len,
> +			  ETHER_ALIGN, sc->ifp, NULL);
>  			/*
>  			 * For the last buffer, set the wrap bit so
>  			 * the controller restarts from the first

Note that you can drop all the mb-> lines above, just pass in rx_stat & 
ETH_LEN_MASK to m_devget() where you pass mb->m_len.  It will setup the
pkthdr on the new mbuf.  You probably want to bump your iferrors count
if m_devget fails too.

> @@ -671,7 +670,8 @@
>  			    BUS_DMASYNC_PREREAD);
>  			bus_dmamap_sync(sc->rx_desc_tag, sc->rx_desc_map,
>  			    BUS_DMASYNC_PREWRITE);
> -			(*sc->ifp->if_input)(sc->ifp, tmp_mbuf);
> +			if (tmp_mbuf != NULL)
> +				(*sc->ifp->if_input)(sc->ifp, tmp_mbuf);
>  		}

Not sure if you have locking for this driver yet, but if you do, don't
forget to drop your driver lock around the call to if_input.

-- 
John Baldwin <jhb at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org


More information about the p4-projects mailing list