kernels/linux-2.4.0/drivers/net/epic100.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 epic_init_ring(struct net_device *dev)
{
	struct epic_private *ep = (struct epic_private *)dev->priv;
	int i;
	ep->tx_full = 0;
	ep->lock = (spinlock_t) SPIN_LOCK_UNLOCKED;
	ep->dirty_tx = ep->cur_tx = 0;
	ep->cur_rx = ep->dirty_rx = 0;
	ep->last_rx_time = jiffies;
	ep->rx_buf_sz = (dev->mtu <= 1500 ? PKT_BUF_SZ : dev->mtu + 32);
	for (i = 0; i < RX_RING_SIZE; i++) {
		ep->rx_ring[i].rxstatus = 0;
		ep->rx_ring[i].buflength = cpu_to_le32(ep->rx_buf_sz);
		ep->rx_ring[i].next = virt_to_le32desc(&ep->rx_ring[i+1]);
		ep->rx_skbuff[i] = 0;
	}
	ep->rx_ring[i-1].next = virt_to_le32desc(&ep->rx_ring[0]);
	for (i = 0; i < RX_RING_SIZE; i++) {
		struct sk_buff *skb = dev_alloc_skb(ep->rx_buf_sz);
		ep->rx_skbuff[i] = skb;
		if (skb == NULL)
			break;
		skb->dev = dev;			
		skb_reserve(skb, 2);	
		ep->rx_ring[i].bufaddr = virt_to_le32desc(skb->tail);
		ep->rx_ring[i].rxstatus = cpu_to_le32(DescOwn);
	}
	ep->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
	for (i = 0; i < TX_RING_SIZE; i++) {
		ep->tx_skbuff[i] = 0;
		ep->tx_ring[i].txstatus = 0x0000;
		ep->tx_ring[i].next = virt_to_le32desc(&ep->tx_ring[i+1]);
	}
	ep->tx_ring[i-1].next = virt_to_le32desc(&ep->tx_ring[0]);
	return;
}
static void epic_init_ring ( struct net_device * dev ) { struct epic_private * ep = ( struct epic_private * ) dev -> priv ; int i ; ep -> tx_full = 0 ; ep -> lock = ( spinlock_t ) SPIN_LOCK_UNLOCKED ; ep -> dirty_tx = ep -> cur_tx = 0 ; ep -> cur_rx = ep -> dirty_rx = 0 ; ep -> last_rx_time = jiffies ; ep -> rx_buf_sz = ( dev -> mtu <= 1500 ? PKT_BUF_SZ : dev -> mtu + 32 ) ; for ( i = 0 ; i < RX_RING_SIZE ; i ++ ) { ep -> rx_ring [ i ] . rxstatus = 0 ; ep -> rx_ring [ i ] . buflength = cpu_to_le32 ( ep -> rx_buf_sz ) ; ep -> rx_ring [ i ] . next = virt_to_le32desc ( & ep -> rx_ring [ i + 1 ] ) ; ep -> rx_skbuff [ i ] = 0 ; } ep -> rx_ring [ i - 1 ] . next = virt_to_le32desc ( & ep -> rx_ring [ 0 ] ) ; for ( i = 0 ; i < RX_RING_SIZE ; i ++ ) { struct sk_buff * skb = dev_alloc_skb ( ep -> rx_buf_sz ) ; ep -> rx_skbuff [ i ] = skb ; if ( skb == NULL ) break ; skb -> dev = dev ; skb_reserve ( skb , 2 ) ; ep -> rx_ring [ i ] . bufaddr = virt_to_le32desc ( skb -> tail ) ; ep -> rx_ring [ i ] . rxstatus = cpu_to_le32 ( DescOwn ) ; } ep -> dirty_rx = ( unsigned int ) ( i - RX_RING_SIZE ) ; for ( i = 0 ; i < TX_RING_SIZE ; i ++ ) { ep -> tx_skbuff [ i ] = 0 ; ep -> tx_ring [ i ] . txstatus = 0x0000 ; ep -> tx_ring [ i ] . next = virt_to_le32desc ( & ep -> tx_ring [ i + 1 ] ) ; } ep -> tx_ring [ i - 1 ] . next = virt_to_le32desc ( & ep -> tx_ring [ 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. */ /* Mark the last entry as wrapping the ring. */ /* Fill in the Rx buffers.  Handle allocation failure gracefully. */ /* Mark as being used by this device. */ /* 16 byte align the IP header. */ /* The Tx buffer descriptor is filled in as needed, but we
	   do need to clear the ownership bit. */