kernels/linux-2.4.0/drivers/net/dmfe.c
/*
   Initialize transmit/Receive descriptor 
   Using Chain structure, and allocated Tx/Rx buffer
 */
Initialize transmit/Receive descriptor
Using Chain structure, and allocated Tx/Rx buffer
Initialize transmit / Receive descriptor Using Chain structure and allocated Tx / Rx buffer
static void dmfe_descriptor_init(struct dmfe_board_info *db, u32 ioaddr)
{
	struct tx_desc *tmp_tx;
	struct rx_desc *tmp_rx;
	unsigned char *tmp_buf;
	int i;
	DMFE_DBUG(0, "dmfe_descriptor_init()", 0);
	db->tx_insert_ptr = db->first_tx_desc;
	db->tx_remove_ptr = db->first_tx_desc;
	outl(virt_to_bus(db->first_tx_desc), ioaddr + DCR4);	
	db->first_rx_desc = (struct rx_desc *)
	    ((u32) db->first_tx_desc + sizeof(struct rx_desc) * TX_DESC_CNT);
	db->rx_insert_ptr = db->first_rx_desc;
	db->rx_ready_ptr = db->first_rx_desc;
	outl(virt_to_bus(db->first_rx_desc), ioaddr + DCR3);	
	tmp_buf = db->buf_pool_start;
	for (tmp_tx = db->first_tx_desc, i = 0; i < TX_DESC_CNT; i++, tmp_tx++) {
		tmp_tx->tx_buf_ptr = (u32) tmp_buf;
		tmp_tx->tdes0 = 0;
		tmp_tx->tdes1 = 0x81000000;	
		tmp_tx->tdes2 = (u32) virt_to_bus(tmp_buf);
		tmp_tx->tdes3 = (u32) virt_to_bus(tmp_tx) + sizeof(struct tx_desc);
		tmp_tx->next_tx_desc = (u32) ((u32) tmp_tx + sizeof(struct tx_desc));
		tmp_buf = (unsigned char *) ((u32) tmp_buf + TX_BUF_ALLOC);
	}
	(--tmp_tx)->tdes3 = (u32) virt_to_bus(db->first_tx_desc);
	tmp_tx->next_tx_desc = (u32) db->first_tx_desc;
	for (tmp_rx = db->first_rx_desc, i = 0; i < RX_DESC_CNT; i++, tmp_rx++) {
		tmp_rx->rdes0 = 0;
		tmp_rx->rdes1 = 0x01000600;
		tmp_rx->rdes3 = (u32) virt_to_bus(tmp_rx) + sizeof(struct rx_desc);
		tmp_rx->next_rx_desc = (u32) ((u32) tmp_rx + sizeof(struct rx_desc));
	}
	(--tmp_rx)->rdes3 = (u32) virt_to_bus(db->first_rx_desc);
	tmp_rx->next_rx_desc = (u32) db->first_rx_desc;
	allocated_rx_buffer(db);
}
static void dmfe_descriptor_init ( struct dmfe_board_info * db , u32 ioaddr ) { struct tx_desc * tmp_tx ; struct rx_desc * tmp_rx ; unsigned char * tmp_buf ; int i ; DMFE_DBUG ( 0 , " " , 0 ) ; db -> tx_insert_ptr = db -> first_tx_desc ; db -> tx_remove_ptr = db -> first_tx_desc ; outl ( virt_to_bus ( db -> first_tx_desc ) , ioaddr + DCR4 ) ; db -> first_rx_desc = ( struct rx_desc * ) ( ( u32 ) db -> first_tx_desc + sizeof ( struct rx_desc ) * TX_DESC_CNT ) ; db -> rx_insert_ptr = db -> first_rx_desc ; db -> rx_ready_ptr = db -> first_rx_desc ; outl ( virt_to_bus ( db -> first_rx_desc ) , ioaddr + DCR3 ) ; tmp_buf = db -> buf_pool_start ; for ( tmp_tx = db -> first_tx_desc , i = 0 ; i < TX_DESC_CNT ; i ++ , tmp_tx ++ ) { tmp_tx -> tx_buf_ptr = ( u32 ) tmp_buf ; tmp_tx -> tdes0 = 0 ; tmp_tx -> tdes1 = 0x81000000 ; tmp_tx -> tdes2 = ( u32 ) virt_to_bus ( tmp_buf ) ; tmp_tx -> tdes3 = ( u32 ) virt_to_bus ( tmp_tx ) + sizeof ( struct tx_desc ) ; tmp_tx -> next_tx_desc = ( u32 ) ( ( u32 ) tmp_tx + sizeof ( struct tx_desc ) ) ; tmp_buf = ( unsigned char * ) ( ( u32 ) tmp_buf + TX_BUF_ALLOC ) ; } ( -- tmp_tx ) -> tdes3 = ( u32 ) virt_to_bus ( db -> first_tx_desc ) ; tmp_tx -> next_tx_desc = ( u32 ) db -> first_tx_desc ; for ( tmp_rx = db -> first_rx_desc , i = 0 ; i < RX_DESC_CNT ; i ++ , tmp_rx ++ ) { tmp_rx -> rdes0 = 0 ; tmp_rx -> rdes1 = 0x01000600 ; tmp_rx -> rdes3 = ( u32 ) virt_to_bus ( tmp_rx ) + sizeof ( struct rx_desc ) ; tmp_rx -> next_rx_desc = ( u32 ) ( ( u32 ) tmp_rx + sizeof ( struct rx_desc ) ) ; } ( -- tmp_rx ) -> rdes3 = ( u32 ) virt_to_bus ( db -> first_rx_desc ) ; tmp_rx -> next_rx_desc = ( u32 ) db -> first_rx_desc ; allocated_rx_buffer ( db ) ; }
Initialize transmit/Receive descriptor
Using Chain structure, and allocated Tx/Rx buffer
Initialize transmit / Receive descriptor Using Chain structure and allocated Tx / Rx buffer
/* tx descriptor start pointer */ /* Init CR4 */ /* rx descriptor start pointer */ /* Init CR3 */ /* Init Transmit chain */ /* IC, chain */ /* Init Receive descriptor chain */ /* pre-allocated Rx buffer */