kernels/linux-2.4.0/drivers/net/yellowfin.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 yellowfin_init_ring(struct net_device *dev)
{
	struct yellowfin_private *yp = (struct yellowfin_private *)dev->priv;
	int i;
	yp->tx_full = 0;
	yp->cur_rx = yp->cur_tx = 0;
	yp->dirty_tx = 0;
	yp->rx_buf_sz = (dev->mtu <= 1500 ? PKT_BUF_SZ : dev->mtu + 32);
	yp->rx_head_desc = &yp->rx_ring[0];
	for (i = 0; i < RX_RING_SIZE; i++) {
		yp->rx_ring[i].dbdma_cmd =
			cpu_to_le32(CMD_RX_BUF | INTR_ALWAYS | yp->rx_buf_sz);
		yp->rx_ring[i].branch_addr = virt_to_le32desc(&yp->rx_ring[i+1]);
	}
	yp->rx_ring[i-1].branch_addr = virt_to_le32desc(&yp->rx_ring[0]);
	for (i = 0; i < RX_RING_SIZE; i++) {
		struct sk_buff *skb = dev_alloc_skb(yp->rx_buf_sz);
		yp->rx_skbuff[i] = skb;
		if (skb == NULL)
			break;
		skb->dev = dev;			
		skb_reserve(skb, 2);	
		yp->rx_ring[i].addr = virt_to_le32desc(skb->tail);
	}
	yp->rx_ring[i-1].dbdma_cmd = cpu_to_le32(CMD_STOP);
	yp->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
#define NO_TXSTATS
#ifdef NO_TXSTATS
	for (i = 0; i < TX_RING_SIZE; i++) {
		yp->tx_skbuff[i] = 0;
		yp->tx_ring[i].dbdma_cmd = cpu_to_le32(CMD_STOP);
		yp->tx_ring[i].branch_addr = virt_to_le32desc(&yp->tx_ring[i+1]);
	}
	yp->tx_ring[--i].dbdma_cmd = cpu_to_le32(CMD_STOP | BRANCH_ALWAYS);
	yp->tx_ring[i].branch_addr = virt_to_le32desc(&yp->tx_ring[0]);
#else
	for (i = 0; i < TX_RING_SIZE*2; i++) {
		yp->tx_skbuff[i/2] = 0;
		yp->tx_ring[i].dbdma_cmd = cpu_to_le32(CMD_STOP);
		yp->tx_ring[i].branch_addr = virt_to_le32desc(&yp->tx_ring[i+1]);
		i++;
		if (yp->flags & FullTxStatus) {
			yp->tx_ring[i].dbdma_cmd =
				cpu_to_le32(CMD_TXSTATUS | sizeof(yp->tx_status[i]));
			yp->tx_ring[i].request_cnt = sizeof(yp->tx_status[i]);
			yp->tx_ring[i].addr = virt_to_le32desc(&yp->tx_status[i/2]);
		} else {				
			yp->tx_ring[i].dbdma_cmd =
				cpu_to_le32(CMD_TXSTATUS | INTR_ALWAYS | 2);
			yp->tx_ring[i].request_cnt = 2;
			yp->tx_ring[i].addr = virt_to_le32desc(&yp->tx_status[i/2].tx_errs);
		}
		yp->tx_ring[i].branch_addr = virt_to_le32desc(&yp->tx_ring[i+1]);
	}
	yp->tx_ring[--i].dbdma_cmd |= cpu_to_le32(BRANCH_ALWAYS | INTR_ALWAYS);
	yp->tx_ring[i].branch_addr = virt_to_le32desc(&yp->tx_ring[0]);
#endif
	yp->tx_tail_desc = &yp->tx_status[0];
	return;
}
static void yellowfin_init_ring ( struct net_device * dev ) { struct yellowfin_private * yp = ( struct yellowfin_private * ) dev -> priv ; int i ; yp -> tx_full = 0 ; yp -> cur_rx = yp -> cur_tx = 0 ; yp -> dirty_tx = 0 ; yp -> rx_buf_sz = ( dev -> mtu <= 1500 ? PKT_BUF_SZ : dev -> mtu + 32 ) ; yp -> rx_head_desc = & yp -> rx_ring [ 0 ] ; for ( i = 0 ; i < RX_RING_SIZE ; i ++ ) { yp -> rx_ring [ i ] . dbdma_cmd = cpu_to_le32 ( CMD_RX_BUF | INTR_ALWAYS | yp -> rx_buf_sz ) ; yp -> rx_ring [ i ] . branch_addr = virt_to_le32desc ( & yp -> rx_ring [ i + 1 ] ) ; } yp -> rx_ring [ i - 1 ] . branch_addr = virt_to_le32desc ( & yp -> rx_ring [ 0 ] ) ; for ( i = 0 ; i < RX_RING_SIZE ; i ++ ) { struct sk_buff * skb = dev_alloc_skb ( yp -> rx_buf_sz ) ; yp -> rx_skbuff [ i ] = skb ; if ( skb == NULL ) break ; skb -> dev = dev ; skb_reserve ( skb , 2 ) ; yp -> rx_ring [ i ] . addr = virt_to_le32desc ( skb -> tail ) ; } yp -> rx_ring [ i - 1 ] . dbdma_cmd = cpu_to_le32 ( CMD_STOP ) ; yp -> dirty_rx = ( unsigned int ) ( i - RX_RING_SIZE ) ; #define NO_TXSTATS #ifdef NO_TXSTATS for ( i = 0 ; i < TX_RING_SIZE ; i ++ ) { yp -> tx_skbuff [ i ] = 0 ; yp -> tx_ring [ i ] . dbdma_cmd = cpu_to_le32 ( CMD_STOP ) ; yp -> tx_ring [ i ] . branch_addr = virt_to_le32desc ( & yp -> tx_ring [ i + 1 ] ) ; } yp -> tx_ring [ -- i ] . dbdma_cmd = cpu_to_le32 ( CMD_STOP | BRANCH_ALWAYS ) ; yp -> tx_ring [ i ] . branch_addr = virt_to_le32desc ( & yp -> tx_ring [ 0 ] ) ; #else for ( i = 0 ; i < TX_RING_SIZE * 2 ; i ++ ) { yp -> tx_skbuff [ i / 2 ] = 0 ; yp -> tx_ring [ i ] . dbdma_cmd = cpu_to_le32 ( CMD_STOP ) ; yp -> tx_ring [ i ] . branch_addr = virt_to_le32desc ( & yp -> tx_ring [ i + 1 ] ) ; i ++ ; if ( yp -> flags & FullTxStatus ) { yp -> tx_ring [ i ] . dbdma_cmd = cpu_to_le32 ( CMD_TXSTATUS | sizeof ( yp -> tx_status [ i ] ) ) ; yp -> tx_ring [ i ] . request_cnt = sizeof ( yp -> tx_status [ i ] ) ; yp -> tx_ring [ i ] . addr = virt_to_le32desc ( & yp -> tx_status [ i / 2 ] ) ; } else { yp -> tx_ring [ i ] . dbdma_cmd = cpu_to_le32 ( CMD_TXSTATUS | INTR_ALWAYS | 2 ) ; yp -> tx_ring [ i ] . request_cnt = 2 ; yp -> tx_ring [ i ] . addr = virt_to_le32desc ( & yp -> tx_status [ i / 2 ] . tx_errs ) ; } yp -> tx_ring [ i ] . branch_addr = virt_to_le32desc ( & yp -> tx_ring [ i + 1 ] ) ; } yp -> tx_ring [ -- i ] . dbdma_cmd |= cpu_to_le32 ( BRANCH_ALWAYS | INTR_ALWAYS ) ; yp -> tx_ring [ i ] . branch_addr = virt_to_le32desc ( & yp -> tx_ring [ 0 ] ) ; #endif yp -> tx_tail_desc = & yp -> tx_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 .
/* Mark the last entry as wrapping the ring. */ /* Mark as being used by this device. */ /* 16 byte align the IP header. */ /* In this mode the Tx ring needs only a single descriptor. */ /* Wrap ring */ /* Tx ring needs a pair of descriptors, the second for the status. */ /* Branch on Tx error. */ /* Symbios chips write only tx_errs word. */ /* Wrap ring */