kernels/linux-2.4.0/drivers/net/dmfe.c
/*
   Receive the come packet and pass to upper layer
 */
Receive the come packet and pass to upper layer
Receive the come packet and pass to upper layer
static void dmfe_rx_packet(struct net_device *dev, struct dmfe_board_info *db)
{
	struct rx_desc *rxptr;
	struct sk_buff *skb;
	int rxlen;
	rxptr = db->rx_ready_ptr;
	while (db->rx_avail_cnt) {
		if (rxptr->rdes0 & 0x80000000)	
			break;
		db->rx_avail_cnt--;
		db->interval_rx_cnt++;
		if ((rxptr->rdes0 & 0x300) != 0x300) {
			DMFE_DBUG(0, "Reused SK buffer, rdes0", rxptr->rdes0);
			dmfe_reused_skb(db, (struct sk_buff *) rxptr->rx_skb_ptr);
		} else {
			rxlen = ((rxptr->rdes0 >> 16) & 0x3fff) - 4;	
			if (rxptr->rdes0 & 0x8000) {	
				db->stats.rx_errors++;
				if (rxptr->rdes0 & 1)
					db->stats.rx_fifo_errors++;
				if (rxptr->rdes0 & 2)
					db->stats.rx_crc_errors++;
				if (rxptr->rdes0 & 0x80)
					db->stats.rx_length_errors++;
			}
			if (!(rxptr->rdes0 & 0x8000) ||
			    ((db->cr6_data & CR6_PM) && (rxlen > 6))) {
				skb = (struct sk_buff *) rxptr->rx_skb_ptr;
				if ((db->dm910x_chk_mode & 1) && (cal_CRC(skb->tail, rxlen, 1) != (*(unsigned long *) (skb->tail + rxlen)))) {
					dmfe_reused_skb(db, (struct sk_buff *) rxptr->rx_skb_ptr);
					db->dm910x_chk_mode = 3;
				} else {
					skb->dev = dev;
					skb_put(skb, rxlen);
					skb->protocol = eth_type_trans(skb, dev);
					netif_rx(skb);	
					dev->last_rx = jiffies;
					db->stats.rx_packets++;
					db->stats.rx_bytes += rxlen;
				}
			} else {
				DMFE_DBUG(0, "Reused SK buffer, rdes0", rxptr->rdes0);
				dmfe_reused_skb(db, (struct sk_buff *) rxptr->rx_skb_ptr);
			}
		}
		rxptr = (struct rx_desc *) rxptr->next_rx_desc;
	}
	db->rx_ready_ptr = rxptr;
}
static void dmfe_rx_packet ( struct net_device * dev , struct dmfe_board_info * db ) { struct rx_desc * rxptr ; struct sk_buff * skb ; int rxlen ; rxptr = db -> rx_ready_ptr ; while ( db -> rx_avail_cnt ) { if ( rxptr -> rdes0 & 0x80000000 ) break ; db -> rx_avail_cnt -- ; db -> interval_rx_cnt ++ ; if ( ( rxptr -> rdes0 & 0x300 ) != 0x300 ) { DMFE_DBUG ( 0 , " " , rxptr -> rdes0 ) ; dmfe_reused_skb ( db , ( struct sk_buff * ) rxptr -> rx_skb_ptr ) ; } else { rxlen = ( ( rxptr -> rdes0 >> 16 ) & 0x3fff ) - 4 ; if ( rxptr -> rdes0 & 0x8000 ) { db -> stats . rx_errors ++ ; if ( rxptr -> rdes0 & 1 ) db -> stats . rx_fifo_errors ++ ; if ( rxptr -> rdes0 & 2 ) db -> stats . rx_crc_errors ++ ; if ( rxptr -> rdes0 & 0x80 ) db -> stats . rx_length_errors ++ ; } if ( ! ( rxptr -> rdes0 & 0x8000 ) || ( ( db -> cr6_data & CR6_PM ) && ( rxlen > 6 ) ) ) { skb = ( struct sk_buff * ) rxptr -> rx_skb_ptr ; if ( ( db -> dm910x_chk_mode & 1 ) && ( cal_CRC ( skb -> tail , rxlen , 1 ) != ( * ( unsigned long * ) ( skb -> tail + rxlen ) ) ) ) { dmfe_reused_skb ( db , ( struct sk_buff * ) rxptr -> rx_skb_ptr ) ; db -> dm910x_chk_mode = 3 ; } else { skb -> dev = dev ; skb_put ( skb , rxlen ) ; skb -> protocol = eth_type_trans ( skb , dev ) ; netif_rx ( skb ) ; dev -> last_rx = jiffies ; db -> stats . rx_packets ++ ; db -> stats . rx_bytes += rxlen ; } } else { DMFE_DBUG ( 0 , " " , rxptr -> rdes0 ) ; dmfe_reused_skb ( db , ( struct sk_buff * ) rxptr -> rx_skb_ptr ) ; } } rxptr = ( struct rx_desc * ) rxptr -> next_rx_desc ; } db -> rx_ready_ptr = rxptr ; }
Receive the come packet and pass to upper layer
Receive the come packet and pass to upper layer
/* packet owner check */ /* A packet without First/Last flag */ /* reused this SKB */ /* db->rx_error_cnt++; */ /* A packet with First/Last flag */ /* skip CRC */ /* error summary bit check */ /* This is a error packet */ /* printk("rdes0 error : %x \n", rxptr->rdes0); */ /* Received Packet CRC check need or not */ /* Found a error received packet */ /* A good packet coming, send to upper layer */ /* Send to upper layer */ /* Reuse SKB buffer when the packet is error */