kernels/linux-2.4.0/drivers/net/dmfe.c
/*
 *	Open the interface.
 *	The interface is opened whenever "ifconfig" actives it.
 */
Open the interface.
The interface is opened whenever "ifconfig" actives it.
Open the interface . The interface is opened whenever " ifconfig " actives it .
static int dmfe_open(struct net_device *dev)
{
	int ret;
	struct dmfe_board_info *db = dev->priv;
	DMFE_DBUG(0, "dmfe_open", 0);
	ret = request_irq(dev->irq, &dmfe_interrupt, SA_SHIRQ, dev->name, dev);
	if (ret)
		return ret;
	db->desc_pool_ptr = kmalloc(sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, GFP_KERNEL | GFP_DMA);
	if (db->desc_pool_ptr == NULL)
		return -ENOMEM;
	if ((u32) db->desc_pool_ptr & 0x1f)
		db->first_tx_desc = (struct tx_desc *) (((u32) db->desc_pool_ptr & ~0x1f) + 0x20);
	else
		db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr;
	db->buf_pool_ptr = kmalloc(TX_BUF_ALLOC * TX_DESC_CNT + 4, GFP_KERNEL | GFP_DMA);
	if (db->buf_pool_ptr == NULL) {
		kfree(db->desc_pool_ptr);
		return -ENOMEM;
	}
	if ((u32) db->buf_pool_ptr & 0x3)
		db->buf_pool_start = (char *) (((u32) db->buf_pool_ptr & ~0x3) + 0x4);
	else
		db->buf_pool_start = db->buf_pool_ptr;
	db->cr6_data = CR6_DEFAULT | dmfe_cr6_user_set;
	db->tx_packet_cnt = 0;
	db->tx_queue_cnt = 0;
	db->rx_avail_cnt = 0;
	db->link_failed = 0;
	db->wait_reset = 0;
	db->in_reset_state = 0;
	db->rx_error_cnt = 0;
	if (!chkmode || (db->chip_id == PCI_DM9132_ID) || (db->chip_revision >= 0x02000030)) {
		db->cr0_data = 0xc00000;	
		db->dm910x_chk_mode = 4;	
	} else {
		db->cr0_data = 0;
		db->dm910x_chk_mode = 1;	
	}
	dmfe_init_dm910x(dev);
	init_timer(&db->timer);
	db->timer.expires = DMFE_TIMER_WUT;
	db->timer.data = (unsigned long) dev;
	db->timer.function = &dmfe_timer;
	add_timer(&db->timer);
	netif_wake_queue(dev);
	return 0;
}
static int dmfe_open ( struct net_device * dev ) { int ret ; struct dmfe_board_info * db = dev -> priv ; DMFE_DBUG ( 0 , " " , 0 ) ; ret = request_irq ( dev -> irq , & dmfe_interrupt , SA_SHIRQ , dev -> name , dev ) ; if ( ret ) return ret ; db -> desc_pool_ptr = kmalloc ( sizeof ( struct tx_desc ) * DESC_ALL_CNT + 0x20 , GFP_KERNEL | GFP_DMA ) ; if ( db -> desc_pool_ptr == NULL ) return - ENOMEM ; if ( ( u32 ) db -> desc_pool_ptr & 0x1f ) db -> first_tx_desc = ( struct tx_desc * ) ( ( ( u32 ) db -> desc_pool_ptr & ~ 0x1f ) + 0x20 ) ; else db -> first_tx_desc = ( struct tx_desc * ) db -> desc_pool_ptr ; db -> buf_pool_ptr = kmalloc ( TX_BUF_ALLOC * TX_DESC_CNT + 4 , GFP_KERNEL | GFP_DMA ) ; if ( db -> buf_pool_ptr == NULL ) { kfree ( db -> desc_pool_ptr ) ; return - ENOMEM ; } if ( ( u32 ) db -> buf_pool_ptr & 0x3 ) db -> buf_pool_start = ( char * ) ( ( ( u32 ) db -> buf_pool_ptr & ~ 0x3 ) + 0x4 ) ; else db -> buf_pool_start = db -> buf_pool_ptr ; db -> cr6_data = CR6_DEFAULT | dmfe_cr6_user_set ; db -> tx_packet_cnt = 0 ; db -> tx_queue_cnt = 0 ; db -> rx_avail_cnt = 0 ; db -> link_failed = 0 ; db -> wait_reset = 0 ; db -> in_reset_state = 0 ; db -> rx_error_cnt = 0 ; if ( ! chkmode || ( db -> chip_id == PCI_DM9132_ID ) || ( db -> chip_revision >= 0x02000030 ) ) { db -> cr0_data = 0xc00000 ; db -> dm910x_chk_mode = 4 ; } else { db -> cr0_data = 0 ; db -> dm910x_chk_mode = 1 ; } dmfe_init_dm910x ( dev ) ; init_timer ( & db -> timer ) ; db -> timer . expires = DMFE_TIMER_WUT ; db -> timer . data = ( unsigned long ) dev ; db -> timer . function = & dmfe_timer ; add_timer ( & db -> timer ) ; netif_wake_queue ( dev ) ; return 0 ; }
Open the interface.
Open the interface .
/* Allocated Tx/Rx descriptor memory */ /* Allocated Tx buffer memory */ /* system variable init */ //db->cr6_data &= ~CR6_SFT;         /* Used Tx threshold */ //db->cr6_data |= CR6_NO_PURGE;     /* No purge if rx unavailable */ /* TX/RX desc burst mode */ /* Enter the normal mode */ /* Enter the check mode */ /* Initilize DM910X board */ /* set and active a timer process */