kernels/linux-2.4.0/drivers/net/sundance.c
/* Initialize the Rx and Tx rings, along with various 'dev' bits. */
Initialize the Rx and Tx rings, along with various 'dev' bits.
Initialize the Rx and Tx rings along with various ' dev ' bits .
static void init_ring(struct net_device *dev)
{
	struct netdev_private *np = (struct netdev_private *)dev->priv;
	int i;
	np->tx_full = 0;
	np->cur_rx = np->cur_tx = 0;
	np->dirty_rx = np->dirty_tx = 0;
	np->rx_buf_sz = (dev->mtu <= 1500 ? PKT_BUF_SZ : dev->mtu + 32);
	np->rx_head_desc = &np->rx_ring[0];
	for (i = 0; i < RX_RING_SIZE; i++) {
		np->rx_ring[i].next_desc = virt_to_le32desc(&np->rx_ring[i+1]);
		np->rx_ring[i].status = 0;
		np->rx_ring[i].frag[0].length = 0;
		np->rx_skbuff[i] = 0;
	}
	np->rx_ring[i-1].next_desc = virt_to_le32desc(&np->rx_ring[0]);
	for (i = 0; i < RX_RING_SIZE; i++) {
		struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz);
		np->rx_skbuff[i] = skb;
		if (skb == NULL)
			break;
		skb->dev = dev;			
		skb_reserve(skb, 2);	
		np->rx_ring[i].frag[0].addr = virt_to_le32desc(skb->tail);
		np->rx_ring[i].frag[0].length = cpu_to_le32(np->rx_buf_sz | LastFrag);
	}
	np->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
	for (i = 0; i < TX_RING_SIZE; i++) {
		np->tx_skbuff[i] = 0;
		np->tx_ring[i].status = 0;
	}
	return;
}
static void init_ring ( struct net_device * dev ) { struct netdev_private * np = ( struct netdev_private * ) dev -> priv ; int i ; np -> tx_full = 0 ; np -> cur_rx = np -> cur_tx = 0 ; np -> dirty_rx = np -> dirty_tx = 0 ; np -> rx_buf_sz = ( dev -> mtu <= 1500 ? PKT_BUF_SZ : dev -> mtu + 32 ) ; np -> rx_head_desc = & np -> rx_ring [ 0 ] ; for ( i = 0 ; i < RX_RING_SIZE ; i ++ ) { np -> rx_ring [ i ] . next_desc = virt_to_le32desc ( & np -> rx_ring [ i + 1 ] ) ; np -> rx_ring [ i ] . status = 0 ; np -> rx_ring [ i ] . frag [ 0 ] . length = 0 ; np -> rx_skbuff [ i ] = 0 ; } np -> rx_ring [ i - 1 ] . next_desc = virt_to_le32desc ( & np -> rx_ring [ 0 ] ) ; for ( i = 0 ; i < RX_RING_SIZE ; i ++ ) { struct sk_buff * skb = dev_alloc_skb ( np -> rx_buf_sz ) ; np -> rx_skbuff [ i ] = skb ; if ( skb == NULL ) break ; skb -> dev = dev ; skb_reserve ( skb , 2 ) ; np -> rx_ring [ i ] . frag [ 0 ] . addr = virt_to_le32desc ( skb -> tail ) ; np -> rx_ring [ i ] . frag [ 0 ] . length = cpu_to_le32 ( np -> rx_buf_sz | LastFrag ) ; } np -> dirty_rx = ( unsigned int ) ( i - RX_RING_SIZE ) ; for ( i = 0 ; i < TX_RING_SIZE ; i ++ ) { np -> tx_skbuff [ i ] = 0 ; np -> tx_ring [ i ] . status = 0 ; } return ; }
Initialize the Rx and Tx rings, along with various 'dev' bits.
Initialize the Rx and Tx rings along with various ' dev ' bits .
/* Initialize all Rx descriptors. */ /* Wrap the ring. */ /* Fill in the Rx buffers.  Handle allocation failure gracefully. */ /* Mark as being used by this device. */ /* 16 byte align the IP header. */