Bläddra i källkod

added nat_irq to natsemi.c

tags/v0.9.3
Udayan Kumar 17 år sedan
förälder
incheckning
a8c2a4fa11
1 ändrade filer med 25 tillägg och 22 borttagningar
  1. 25
    22
      src/drivers/net/natsemi.c

+ 25
- 22
src/drivers/net/natsemi.c Visa fil

@@ -371,7 +371,7 @@ static int nat_open ( struct net_device *netdev ) {
371 371
 		if (!nat->iobuf[i])
372 372
 			goto memory_alloc_err;
373 373
 		nat->rx[i].link   = virt_to_bus((i+1 < NUM_RX_DESC) ? &nat->rx[i+1] : &nat->rx[0]);
374
-		nat->rx[i].cmdsts = (uint32_t) RX_BUF_SIZE;
374
+		nat->rx[i].cmdsts = RX_BUF_SIZE;
375 375
 		nat->rx[i].bufptr = virt_to_bus(nat->iobuf[i]->data);
376 376
 	}
377 377
 
@@ -410,10 +410,8 @@ static int nat_open ( struct net_device *netdev ) {
410 410
 	 */
411 411
         outl(RxOn, nat->ioaddr + ChipCmd);
412 412
 
413
-	/*enable interrupts
413
+	/* mask the interrupts. note interrupt is not enabled here
414 414
 	 */
415
-	outl((RxOk|RxErr|TxOk|TxErr),nat->ioaddr + IntrMask); 
416
-	//outl(1,nat->ioaddr +IntrEnable);
417 415
 	return 0;
418 416
 		       
419 417
 memory_alloc_err:
@@ -421,7 +419,7 @@ memory_alloc_err:
421 419
 	 * if memory for all the buffers is not available
422 420
 	 */
423 421
 	i=0;
424
-	while(nat->rx[i].cmdsts == (uint32_t) RX_BUF_SIZE) {
422
+	while(nat->rx[i].cmdsts == RX_BUF_SIZE) {
425 423
 		free_iob(nat->iobuf[i]);
426 424
 		i++;
427 425
 	}
@@ -446,9 +444,6 @@ static void nat_close ( struct net_device *netdev ) {
446 444
 		
447 445
 		free_iob( nat->iobuf[i] );
448 446
 	}
449
-	/* disable interrupts
450
-	 */
451
-	//outl(0,nat->ioaddr + IntrMask) ;
452 447
 }
453 448
 
454 449
 /** 
@@ -509,7 +504,6 @@ static void nat_poll ( struct net_device *netdev, unsigned int rx_quota ) {
509 504
 	struct io_buffer *rx_iob;
510 505
 	int i;
511 506
 	
512
-	//outl(1,nat->ioaddr +IntrEnable);
513 507
 	/* read the interrupt register
514 508
 	 */
515 509
 	intr_status=inl(nat->ioaddr+IntrStatus);
@@ -581,15 +575,33 @@ end:
581 575
 	/* re-enable the potentially idle receive state machine 
582 576
 	 */
583 577
 	outl(RxOn, nat->ioaddr + ChipCmd);	
584
-//	outl(1,nat->ioaddr +IntrEnable);
585 578
 }				
586 579
 
587
-/** RTL8139 net device operations */
580
+/**
581
+ * Enable/disable interrupts
582
+ *
583
+ * @v netdev    Network device
584
+ * @v enable    Interrupts should be enabled
585
+ */
586
+static void nat_irq ( struct net_device *netdev, int enable ) {
587
+        struct natsemi_nic *nat= netdev->priv;
588
+
589
+	outl((enable?(RxOk|RxErr|TxOk|TxErr):0),
590
+		nat->ioaddr + IntrMask); 
591
+	outl((enable ? 1:0),nat->ioaddr +IntrEnable);
592
+}
593
+
594
+
595
+
596
+
597
+
598
+/** natsemi net device operations */
588 599
 static struct net_device_operations nat_operations = {
589 600
         .open           = nat_open,
590 601
         .close          = nat_close,
591 602
         .transmit       = nat_transmit,
592 603
         .poll           = nat_poll,
604
+	.irq		= nat_irq,
593 605
 };
594 606
 
595 607
 /*
@@ -634,11 +646,10 @@ static int nat_probe ( struct pci_device *pci,
634 646
 	/* decoding the MAC address read from NVS 
635 647
 	 * and save it in netdev->ll_addr
636 648
          */
637
-	for ( i = 0 ; i < ETH_ALEN ; i+=2 ) {
649
+	for ( i = 0 ; i < ETH_ALEN ; i++) {
638 650
 		last1=ll_addr_encoded[i]>>7;
639 651
 	 	netdev->ll_addr[i]=ll_addr_encoded[i]<<1|last;
640
-		last=(ll_addr_encoded[i+1]>>7);
641
-		netdev->ll_addr[i+1]=(ll_addr_encoded[i+1]<<1)+last1;
652
+		last=last1;
642 653
 	}
643 654
 
644 655
 	/* Register network device
@@ -646,16 +657,8 @@ static int nat_probe ( struct pci_device *pci,
646 657
 	if ( ( rc = register_netdev ( netdev ) ) != 0 )
647 658
 		goto err_register_netdev;
648 659
 
649
-	/* Register non-volatile storage 
650
-	 */
651
-	if ( nat->nvo.nvs ) {
652
-		if ( ( rc = nvo_register ( &nat->nvo ) ) != 0 )
653
-			goto err_register_nvo;
654
-	}
655 660
 	return 0;
656 661
 
657
-err_register_nvo:
658
-	unregister_netdev ( netdev );
659 662
 err_register_netdev:
660 663
 	/* Disable NIC
661 664
 	 */

Laddar…
Avbryt
Spara