FreeBSD/sys/mips/idt/if_kr.c
/*
 * Initialize the RX descriptors and allocate mbufs for them. Note that
 * we arrange the descriptors in a closed ring, so that the last descriptor
 * points back to the first.
 */
Initialize the RX descriptors and allocate mbufs for them. Note that
we arrange the descriptors in a closed ring, so that the last descriptor
points back to the first.
Initialize the RX descriptors and allocate mbufs for them . Note that we arrange the descriptors in a closed ring so that the last descriptor points back to the first .
static int
kr_rx_ring_init(struct kr_softc *sc)
{
	struct kr_ring_data	*rd;
	struct kr_rxdesc	*rxd;
	bus_addr_t		addr;
	int			i;
	sc->kr_cdata.kr_rx_cons = 0;
	rd = &sc->kr_rdata;
	bzero(rd->kr_rx_ring, KR_RX_RING_SIZE);
	for (i = 0; i < KR_RX_RING_CNT; i++) {
		rxd = &sc->kr_cdata.kr_rxdesc[i];
		rxd->rx_m = NULL;
		rxd->desc = &rd->kr_rx_ring[i];
		if (i == KR_RX_RING_CNT - 1)
			addr = KR_RX_RING_ADDR(sc, 0);
		else
			addr = KR_RX_RING_ADDR(sc, i + 1);
		rd->kr_rx_ring[i].kr_ctl = KR_CTL_IOD;
		if (i == KR_RX_RING_CNT - 1)
			rd->kr_rx_ring[i].kr_ctl |= KR_CTL_COD;
		rd->kr_rx_ring[i].kr_devcs = 0;
		rd->kr_rx_ring[i].kr_ca = 0;
		rd->kr_rx_ring[i].kr_link = addr;
		if (kr_newbuf(sc, i) != 0)
			return (ENOBUFS);
	}
	bus_dmamap_sync(sc->kr_cdata.kr_rx_ring_tag,
	    sc->kr_cdata.kr_rx_ring_map,
	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
	return (0);
}
static int kr_rx_ring_init ( struct kr_softc * sc ) { struct kr_ring_data * rd ; struct kr_rxdesc * rxd ; bus_addr_t addr ; int i ; sc -> kr_cdata . kr_rx_cons = 0 ; rd = & sc -> kr_rdata ; bzero ( rd -> kr_rx_ring , KR_RX_RING_SIZE ) ; for ( i = 0 ; i < KR_RX_RING_CNT ; i ++ ) { rxd = & sc -> kr_cdata . kr_rxdesc [ i ] ; rxd -> rx_m = NULL ; rxd -> desc = & rd -> kr_rx_ring [ i ] ; if ( i == KR_RX_RING_CNT - 1 ) addr = KR_RX_RING_ADDR ( sc , 0 ) ; else addr = KR_RX_RING_ADDR ( sc , i + 1 ) ; rd -> kr_rx_ring [ i ] . kr_ctl = KR_CTL_IOD ; if ( i == KR_RX_RING_CNT - 1 ) rd -> kr_rx_ring [ i ] . kr_ctl |= KR_CTL_COD ; rd -> kr_rx_ring [ i ] . kr_devcs = 0 ; rd -> kr_rx_ring [ i ] . kr_ca = 0 ; rd -> kr_rx_ring [ i ] . kr_link = addr ; if ( kr_newbuf ( sc , i ) != 0 ) return ( ENOBUFS ) ; } bus_dmamap_sync ( sc -> kr_cdata . kr_rx_ring_tag , sc -> kr_cdata . kr_rx_ring_map , BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE ) ; return ( 0 ) ; }
Initialize the RX descriptors and allocate mbufs for them.
Initialize the RX descriptors and allocate mbufs for them .