kernels/linux-2.4.0/drivers/net/tulip/tulip_core.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 tulip_init_ring(struct net_device *dev)
{
	struct tulip_private *tp = (struct tulip_private *)dev->priv;
	int i;
	DPRINTK("ENTER\n");
	tp->cur_rx = tp->cur_tx = 0;
	tp->dirty_rx = tp->dirty_tx = 0;
	tp->susp_rx = 0;
	tp->ttimer = 0;
	tp->nir = 0;
	for (i = 0; i < RX_RING_SIZE; i++) {
		tp->rx_ring[i].status = 0x00000000;
		tp->rx_ring[i].length = cpu_to_le32(PKT_BUF_SZ);
		tp->rx_ring[i].buffer2 = cpu_to_le32(tp->rx_ring_dma + sizeof(struct tulip_rx_desc) * (i + 1));
		tp->rx_buffers[i].skb = NULL;
		tp->rx_buffers[i].mapping = 0;
	}
	tp->rx_ring[i-1].length = cpu_to_le32(PKT_BUF_SZ | DESC_RING_WRAP);
	tp->rx_ring[i-1].buffer2 = cpu_to_le32(tp->rx_ring_dma);
	for (i = 0; i < RX_RING_SIZE; i++) {
		dma_addr_t mapping;
		struct sk_buff *skb = dev_alloc_skb(PKT_BUF_SZ);
		tp->rx_buffers[i].skb = skb;
		if (skb == NULL)
			break;
		mapping = pci_map_single(tp->pdev, skb->tail,
					 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
		tp->rx_buffers[i].mapping = mapping;
		skb->dev = dev;			
		tp->rx_ring[i].status = cpu_to_le32(DescOwned);	
		tp->rx_ring[i].buffer1 = cpu_to_le32(mapping);
	}
	tp->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
	for (i = 0; i < TX_RING_SIZE; i++) {
		tp->tx_buffers[i].skb = NULL;
		tp->tx_buffers[i].mapping = 0;
		tp->tx_ring[i].status = 0x00000000;
		tp->tx_ring[i].buffer2 = cpu_to_le32(tp->tx_ring_dma + sizeof(struct tulip_tx_desc) * (i + 1));
	}
	tp->tx_ring[i-1].buffer2 = cpu_to_le32(tp->tx_ring_dma);
}
static void tulip_init_ring ( struct net_device * dev ) { struct tulip_private * tp = ( struct tulip_private * ) dev -> priv ; int i ; DPRINTK ( " \n " ) ; tp -> cur_rx = tp -> cur_tx = 0 ; tp -> dirty_rx = tp -> dirty_tx = 0 ; tp -> susp_rx = 0 ; tp -> ttimer = 0 ; tp -> nir = 0 ; for ( i = 0 ; i < RX_RING_SIZE ; i ++ ) { tp -> rx_ring [ i ] . status = 0x00000000 ; tp -> rx_ring [ i ] . length = cpu_to_le32 ( PKT_BUF_SZ ) ; tp -> rx_ring [ i ] . buffer2 = cpu_to_le32 ( tp -> rx_ring_dma + sizeof ( struct tulip_rx_desc ) * ( i + 1 ) ) ; tp -> rx_buffers [ i ] . skb = NULL ; tp -> rx_buffers [ i ] . mapping = 0 ; } tp -> rx_ring [ i - 1 ] . length = cpu_to_le32 ( PKT_BUF_SZ | DESC_RING_WRAP ) ; tp -> rx_ring [ i - 1 ] . buffer2 = cpu_to_le32 ( tp -> rx_ring_dma ) ; for ( i = 0 ; i < RX_RING_SIZE ; i ++ ) { dma_addr_t mapping ; struct sk_buff * skb = dev_alloc_skb ( PKT_BUF_SZ ) ; tp -> rx_buffers [ i ] . skb = skb ; if ( skb == NULL ) break ; mapping = pci_map_single ( tp -> pdev , skb -> tail , PKT_BUF_SZ , PCI_DMA_FROMDEVICE ) ; tp -> rx_buffers [ i ] . mapping = mapping ; skb -> dev = dev ; tp -> rx_ring [ i ] . status = cpu_to_le32 ( DescOwned ) ; tp -> rx_ring [ i ] . buffer1 = cpu_to_le32 ( mapping ) ; } tp -> dirty_rx = ( unsigned int ) ( i - RX_RING_SIZE ) ; for ( i = 0 ; i < TX_RING_SIZE ; i ++ ) { tp -> tx_buffers [ i ] . skb = NULL ; tp -> tx_buffers [ i ] . mapping = 0 ; tp -> tx_ring [ i ] . status = 0x00000000 ; tp -> tx_ring [ i ] . buffer2 = cpu_to_le32 ( tp -> tx_ring_dma + sizeof ( struct tulip_tx_desc ) * ( i + 1 ) ) ; } tp -> tx_ring [ i - 1 ] . buffer2 = cpu_to_le32 ( tp -> tx_ring_dma ) ; }
Initialize the Rx and Tx rings, along with various 'dev' bits.
Initialize the Rx and Tx rings along with various ' dev ' bits .
/* Mark the last entry as wrapping the ring. */ /* Note the receive buffer must be longword aligned.
		   dev_alloc_skb() provides 16 byte alignment.  But do *not*
		   use skb_reserve() to align the IP header! */ /* Mark as being used by this device. */ /* Owned by Tulip chip */ /* The Tx buffer descriptor is filled in as needed, but we
	   do need to clear the ownership bit. */