aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tulip/xircom_cb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/tulip/xircom_cb.c')
-rw-r--r--drivers/net/tulip/xircom_cb.c268
1 files changed, 85 insertions, 183 deletions
diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
index 5a73752be2ca..988b8eb24d37 100644
--- a/drivers/net/tulip/xircom_cb.c
+++ b/drivers/net/tulip/xircom_cb.c
@@ -37,15 +37,6 @@
37#include <asm/irq.h> 37#include <asm/irq.h>
38#endif 38#endif
39 39
40#ifdef DEBUG
41#define enter(x) printk("Enter: %s, %s line %i\n",x,__FILE__,__LINE__)
42#define leave(x) printk("Leave: %s, %s line %i\n",x,__FILE__,__LINE__)
43#else
44#define enter(x) do {} while (0)
45#define leave(x) do {} while (0)
46#endif
47
48
49MODULE_DESCRIPTION("Xircom Cardbus ethernet driver"); 40MODULE_DESCRIPTION("Xircom Cardbus ethernet driver");
50MODULE_AUTHOR("Arjan van de Ven <arjanv@redhat.com>"); 41MODULE_AUTHOR("Arjan van de Ven <arjanv@redhat.com>");
51MODULE_LICENSE("GPL"); 42MODULE_LICENSE("GPL");
@@ -161,7 +152,7 @@ static struct pci_driver xircom_ops = {
161}; 152};
162 153
163 154
164#ifdef DEBUG 155#if defined DEBUG && DEBUG > 1
165static void print_binary(unsigned int number) 156static void print_binary(unsigned int number)
166{ 157{
167 int i,i2; 158 int i,i2;
@@ -176,7 +167,7 @@ static void print_binary(unsigned int number)
176 if ((i&3)==0) 167 if ((i&3)==0)
177 buffer[i2++]=' '; 168 buffer[i2++]=' ';
178 } 169 }
179 printk("%s\n",buffer); 170 pr_debug("%s\n",buffer);
180} 171}
181#endif 172#endif
182 173
@@ -205,7 +196,6 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
205 struct xircom_private *private; 196 struct xircom_private *private;
206 unsigned long flags; 197 unsigned long flags;
207 unsigned short tmp16; 198 unsigned short tmp16;
208 enter("xircom_probe");
209 199
210 /* First do the PCI initialisation */ 200 /* First do the PCI initialisation */
211 201
@@ -272,8 +262,8 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
272 goto reg_fail; 262 goto reg_fail;
273 } 263 }
274 264
275 dev_info(&dev->dev, "Xircom cardbus revision %i at irq %i\n", 265 netdev_info(dev, "Xircom cardbus revision %i at irq %i\n",
276 pdev->revision, pdev->irq); 266 pdev->revision, pdev->irq);
277 /* start the transmitter to get a heartbeat */ 267 /* start the transmitter to get a heartbeat */
278 /* TODO: send 2 dummy packets here */ 268 /* TODO: send 2 dummy packets here */
279 transceiver_voodoo(private); 269 transceiver_voodoo(private);
@@ -285,7 +275,6 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
285 275
286 trigger_receive(private); 276 trigger_receive(private);
287 277
288 leave("xircom_probe");
289 return 0; 278 return 0;
290 279
291reg_fail: 280reg_fail:
@@ -310,7 +299,6 @@ static void __devexit xircom_remove(struct pci_dev *pdev)
310 struct net_device *dev = pci_get_drvdata(pdev); 299 struct net_device *dev = pci_get_drvdata(pdev);
311 struct xircom_private *card = netdev_priv(dev); 300 struct xircom_private *card = netdev_priv(dev);
312 301
313 enter("xircom_remove");
314 pci_free_consistent(pdev,8192,card->rx_buffer,card->rx_dma_handle); 302 pci_free_consistent(pdev,8192,card->rx_buffer,card->rx_dma_handle);
315 pci_free_consistent(pdev,8192,card->tx_buffer,card->tx_dma_handle); 303 pci_free_consistent(pdev,8192,card->tx_buffer,card->tx_dma_handle);
316 304
@@ -318,7 +306,6 @@ static void __devexit xircom_remove(struct pci_dev *pdev)
318 unregister_netdev(dev); 306 unregister_netdev(dev);
319 free_netdev(dev); 307 free_netdev(dev);
320 pci_set_drvdata(pdev, NULL); 308 pci_set_drvdata(pdev, NULL);
321 leave("xircom_remove");
322} 309}
323 310
324static irqreturn_t xircom_interrupt(int irq, void *dev_instance) 311static irqreturn_t xircom_interrupt(int irq, void *dev_instance)
@@ -328,17 +315,15 @@ static irqreturn_t xircom_interrupt(int irq, void *dev_instance)
328 unsigned int status; 315 unsigned int status;
329 int i; 316 int i;
330 317
331 enter("xircom_interrupt\n");
332
333 spin_lock(&card->lock); 318 spin_lock(&card->lock);
334 status = inl(card->io_port+CSR5); 319 status = inl(card->io_port+CSR5);
335 320
336#ifdef DEBUG 321#if defined DEBUG && DEBUG > 1
337 print_binary(status); 322 print_binary(status);
338 printk("tx status 0x%08x 0x%08x\n", 323 pr_debug("tx status 0x%08x 0x%08x\n",
339 card->tx_buffer[0], card->tx_buffer[4]); 324 card->tx_buffer[0], card->tx_buffer[4]);
340 printk("rx status 0x%08x 0x%08x\n", 325 pr_debug("rx status 0x%08x 0x%08x\n",
341 card->rx_buffer[0], card->rx_buffer[4]); 326 card->rx_buffer[0], card->rx_buffer[4]);
342#endif 327#endif
343 /* Handle shared irq and hotplug */ 328 /* Handle shared irq and hotplug */
344 if (status == 0 || status == 0xffffffff) { 329 if (status == 0 || status == 0xffffffff) {
@@ -348,9 +333,9 @@ static irqreturn_t xircom_interrupt(int irq, void *dev_instance)
348 333
349 if (link_status_changed(card)) { 334 if (link_status_changed(card)) {
350 int newlink; 335 int newlink;
351 printk(KERN_DEBUG "xircom_cb: Link status has changed\n"); 336 netdev_dbg(dev, "Link status has changed\n");
352 newlink = link_status(card); 337 newlink = link_status(card);
353 dev_info(&dev->dev, "Link is %i mbit\n", newlink); 338 netdev_info(dev, "Link is %d mbit\n", newlink);
354 if (newlink) 339 if (newlink)
355 netif_carrier_on(dev); 340 netif_carrier_on(dev);
356 else 341 else
@@ -369,9 +354,7 @@ static irqreturn_t xircom_interrupt(int irq, void *dev_instance)
369 for (i=0;i<NUMDESCRIPTORS;i++) 354 for (i=0;i<NUMDESCRIPTORS;i++)
370 investigate_read_descriptor(dev,card,i,bufferoffsets[i]); 355 investigate_read_descriptor(dev,card,i,bufferoffsets[i]);
371 356
372
373 spin_unlock(&card->lock); 357 spin_unlock(&card->lock);
374 leave("xircom_interrupt");
375 return IRQ_HANDLED; 358 return IRQ_HANDLED;
376} 359}
377 360
@@ -382,7 +365,6 @@ static netdev_tx_t xircom_start_xmit(struct sk_buff *skb,
382 unsigned long flags; 365 unsigned long flags;
383 int nextdescriptor; 366 int nextdescriptor;
384 int desc; 367 int desc;
385 enter("xircom_start_xmit");
386 368
387 card = netdev_priv(dev); 369 card = netdev_priv(dev);
388 spin_lock_irqsave(&card->lock,flags); 370 spin_lock_irqsave(&card->lock,flags);
@@ -424,13 +406,10 @@ static netdev_tx_t xircom_start_xmit(struct sk_buff *skb,
424 netif_stop_queue(dev); 406 netif_stop_queue(dev);
425 } 407 }
426 card->transmit_used = nextdescriptor; 408 card->transmit_used = nextdescriptor;
427 leave("xircom-start_xmit - sent");
428 spin_unlock_irqrestore(&card->lock,flags); 409 spin_unlock_irqrestore(&card->lock,flags);
429 return NETDEV_TX_OK; 410 return NETDEV_TX_OK;
430 } 411 }
431 412
432
433
434 /* Uh oh... no free descriptor... drop the packet */ 413 /* Uh oh... no free descriptor... drop the packet */
435 netif_stop_queue(dev); 414 netif_stop_queue(dev);
436 spin_unlock_irqrestore(&card->lock,flags); 415 spin_unlock_irqrestore(&card->lock,flags);
@@ -446,18 +425,16 @@ static int xircom_open(struct net_device *dev)
446{ 425{
447 struct xircom_private *xp = netdev_priv(dev); 426 struct xircom_private *xp = netdev_priv(dev);
448 int retval; 427 int retval;
449 enter("xircom_open"); 428
450 pr_info("xircom cardbus adaptor found, registering as %s, using irq %i\n", 429 netdev_info(dev, "xircom cardbus adaptor found, using irq %i\n",
451 dev->name, dev->irq); 430 dev->irq);
452 retval = request_irq(dev->irq, xircom_interrupt, IRQF_SHARED, dev->name, dev); 431 retval = request_irq(dev->irq, xircom_interrupt, IRQF_SHARED, dev->name, dev);
453 if (retval) { 432 if (retval)
454 leave("xircom_open - No IRQ");
455 return retval; 433 return retval;
456 }
457 434
458 xircom_up(xp); 435 xircom_up(xp);
459 xp->open = 1; 436 xp->open = 1;
460 leave("xircom_open"); 437
461 return 0; 438 return 0;
462} 439}
463 440
@@ -466,7 +443,6 @@ static int xircom_close(struct net_device *dev)
466 struct xircom_private *card; 443 struct xircom_private *card;
467 unsigned long flags; 444 unsigned long flags;
468 445
469 enter("xircom_close");
470 card = netdev_priv(dev); 446 card = netdev_priv(dev);
471 netif_stop_queue(dev); /* we don't want new packets */ 447 netif_stop_queue(dev); /* we don't want new packets */
472 448
@@ -486,8 +462,6 @@ static int xircom_close(struct net_device *dev)
486 card->open = 0; 462 card->open = 0;
487 free_irq(dev->irq,dev); 463 free_irq(dev->irq,dev);
488 464
489 leave("xircom_close");
490
491 return 0; 465 return 0;
492 466
493} 467}
@@ -507,8 +481,6 @@ static void initialize_card(struct xircom_private *card)
507{ 481{
508 unsigned int val; 482 unsigned int val;
509 unsigned long flags; 483 unsigned long flags;
510 enter("initialize_card");
511
512 484
513 spin_lock_irqsave(&card->lock, flags); 485 spin_lock_irqsave(&card->lock, flags);
514 486
@@ -534,8 +506,6 @@ static void initialize_card(struct xircom_private *card)
534 deactivate_transmitter(card); 506 deactivate_transmitter(card);
535 507
536 spin_unlock_irqrestore(&card->lock, flags); 508 spin_unlock_irqrestore(&card->lock, flags);
537
538 leave("initialize_card");
539} 509}
540 510
541/* 511/*
@@ -547,12 +517,9 @@ ignored; I chose zero.
547static void trigger_transmit(struct xircom_private *card) 517static void trigger_transmit(struct xircom_private *card)
548{ 518{
549 unsigned int val; 519 unsigned int val;
550 enter("trigger_transmit");
551 520
552 val = 0; 521 val = 0;
553 outl(val, card->io_port + CSR1); 522 outl(val, card->io_port + CSR1);
554
555 leave("trigger_transmit");
556} 523}
557 524
558/* 525/*
@@ -565,12 +532,9 @@ ignored; I chose zero.
565static void trigger_receive(struct xircom_private *card) 532static void trigger_receive(struct xircom_private *card)
566{ 533{
567 unsigned int val; 534 unsigned int val;
568 enter("trigger_receive");
569 535
570 val = 0; 536 val = 0;
571 outl(val, card->io_port + CSR2); 537 outl(val, card->io_port + CSR2);
572
573 leave("trigger_receive");
574} 538}
575 539
576/* 540/*
@@ -581,8 +545,6 @@ static void setup_descriptors(struct xircom_private *card)
581{ 545{
582 u32 address; 546 u32 address;
583 int i; 547 int i;
584 enter("setup_descriptors");
585
586 548
587 BUG_ON(card->rx_buffer == NULL); 549 BUG_ON(card->rx_buffer == NULL);
588 BUG_ON(card->tx_buffer == NULL); 550 BUG_ON(card->tx_buffer == NULL);
@@ -636,8 +598,6 @@ static void setup_descriptors(struct xircom_private *card)
636 /* wite the transmit descriptor ring to the card */ 598 /* wite the transmit descriptor ring to the card */
637 address = card->tx_dma_handle; 599 address = card->tx_dma_handle;
638 outl(address, card->io_port + CSR4); /* xmit descr list address */ 600 outl(address, card->io_port + CSR4); /* xmit descr list address */
639
640 leave("setup_descriptors");
641} 601}
642 602
643/* 603/*
@@ -647,13 +607,10 @@ valid by setting the address in the card to 0x00.
647static void remove_descriptors(struct xircom_private *card) 607static void remove_descriptors(struct xircom_private *card)
648{ 608{
649 unsigned int val; 609 unsigned int val;
650 enter("remove_descriptors");
651 610
652 val = 0; 611 val = 0;
653 outl(val, card->io_port + CSR3); /* Receive descriptor address */ 612 outl(val, card->io_port + CSR3); /* Receive descriptor address */
654 outl(val, card->io_port + CSR4); /* Send descriptor address */ 613 outl(val, card->io_port + CSR4); /* Send descriptor address */
655
656 leave("remove_descriptors");
657} 614}
658 615
659/* 616/*
@@ -665,21 +622,17 @@ This function also clears the status-bit.
665static int link_status_changed(struct xircom_private *card) 622static int link_status_changed(struct xircom_private *card)
666{ 623{
667 unsigned int val; 624 unsigned int val;
668 enter("link_status_changed");
669 625
670 val = inl(card->io_port + CSR5); /* Status register */ 626 val = inl(card->io_port + CSR5); /* Status register */
671 627
672 if ((val & (1 << 27)) == 0) { /* no change */ 628 if ((val & (1 << 27)) == 0) /* no change */
673 leave("link_status_changed - nochange");
674 return 0; 629 return 0;
675 }
676 630
677 /* clear the event by writing a 1 to the bit in the 631 /* clear the event by writing a 1 to the bit in the
678 status register. */ 632 status register. */
679 val = (1 << 27); 633 val = (1 << 27);
680 outl(val, card->io_port + CSR5); 634 outl(val, card->io_port + CSR5);
681 635
682 leave("link_status_changed - changed");
683 return 1; 636 return 1;
684} 637}
685 638
@@ -691,16 +644,12 @@ in a non-stopped state.
691static int transmit_active(struct xircom_private *card) 644static int transmit_active(struct xircom_private *card)
692{ 645{
693 unsigned int val; 646 unsigned int val;
694 enter("transmit_active");
695 647
696 val = inl(card->io_port + CSR5); /* Status register */ 648 val = inl(card->io_port + CSR5); /* Status register */
697 649
698 if ((val & (7 << 20)) == 0) { /* transmitter disabled */ 650 if ((val & (7 << 20)) == 0) /* transmitter disabled */
699 leave("transmit_active - inactive");
700 return 0; 651 return 0;
701 }
702 652
703 leave("transmit_active - active");
704 return 1; 653 return 1;
705} 654}
706 655
@@ -711,17 +660,12 @@ in a non-stopped state.
711static int receive_active(struct xircom_private *card) 660static int receive_active(struct xircom_private *card)
712{ 661{
713 unsigned int val; 662 unsigned int val;
714 enter("receive_active");
715
716 663
717 val = inl(card->io_port + CSR5); /* Status register */ 664 val = inl(card->io_port + CSR5); /* Status register */
718 665
719 if ((val & (7 << 17)) == 0) { /* receiver disabled */ 666 if ((val & (7 << 17)) == 0) /* receiver disabled */
720 leave("receive_active - inactive");
721 return 0; 667 return 0;
722 }
723 668
724 leave("receive_active - active");
725 return 1; 669 return 1;
726} 670}
727 671
@@ -739,8 +683,6 @@ static void activate_receiver(struct xircom_private *card)
739{ 683{
740 unsigned int val; 684 unsigned int val;
741 int counter; 685 int counter;
742 enter("activate_receiver");
743
744 686
745 val = inl(card->io_port + CSR6); /* Operation mode */ 687 val = inl(card->io_port + CSR6); /* Operation mode */
746 688
@@ -761,7 +703,7 @@ static void activate_receiver(struct xircom_private *card)
761 udelay(50); 703 udelay(50);
762 counter--; 704 counter--;
763 if (counter <= 0) 705 if (counter <= 0)
764 pr_err("Receiver failed to deactivate\n"); 706 netdev_err(card->dev, "Receiver failed to deactivate\n");
765 } 707 }
766 708
767 /* enable the receiver */ 709 /* enable the receiver */
@@ -778,10 +720,9 @@ static void activate_receiver(struct xircom_private *card)
778 udelay(50); 720 udelay(50);
779 counter--; 721 counter--;
780 if (counter <= 0) 722 if (counter <= 0)
781 pr_err("Receiver failed to re-activate\n"); 723 netdev_err(card->dev,
724 "Receiver failed to re-activate\n");
782 } 725 }
783
784 leave("activate_receiver");
785} 726}
786 727
787/* 728/*
@@ -795,7 +736,6 @@ static void deactivate_receiver(struct xircom_private *card)
795{ 736{
796 unsigned int val; 737 unsigned int val;
797 int counter; 738 int counter;
798 enter("deactivate_receiver");
799 739
800 val = inl(card->io_port + CSR6); /* Operation mode */ 740 val = inl(card->io_port + CSR6); /* Operation mode */
801 val = val & ~2; /* disable the receiver */ 741 val = val & ~2; /* disable the receiver */
@@ -809,11 +749,8 @@ static void deactivate_receiver(struct xircom_private *card)
809 udelay(50); 749 udelay(50);
810 counter--; 750 counter--;
811 if (counter <= 0) 751 if (counter <= 0)
812 pr_err("Receiver failed to deactivate\n"); 752 netdev_err(card->dev, "Receiver failed to deactivate\n");
813 } 753 }
814
815
816 leave("deactivate_receiver");
817} 754}
818 755
819 756
@@ -831,8 +768,6 @@ static void activate_transmitter(struct xircom_private *card)
831{ 768{
832 unsigned int val; 769 unsigned int val;
833 int counter; 770 int counter;
834 enter("activate_transmitter");
835
836 771
837 val = inl(card->io_port + CSR6); /* Operation mode */ 772 val = inl(card->io_port + CSR6); /* Operation mode */
838 773
@@ -852,7 +787,8 @@ static void activate_transmitter(struct xircom_private *card)
852 udelay(50); 787 udelay(50);
853 counter--; 788 counter--;
854 if (counter <= 0) 789 if (counter <= 0)
855 pr_err("Transmitter failed to deactivate\n"); 790 netdev_err(card->dev,
791 "Transmitter failed to deactivate\n");
856 } 792 }
857 793
858 /* enable the transmitter */ 794 /* enable the transmitter */
@@ -869,10 +805,9 @@ static void activate_transmitter(struct xircom_private *card)
869 udelay(50); 805 udelay(50);
870 counter--; 806 counter--;
871 if (counter <= 0) 807 if (counter <= 0)
872 pr_err("Transmitter failed to re-activate\n"); 808 netdev_err(card->dev,
809 "Transmitter failed to re-activate\n");
873 } 810 }
874
875 leave("activate_transmitter");
876} 811}
877 812
878/* 813/*
@@ -886,7 +821,6 @@ static void deactivate_transmitter(struct xircom_private *card)
886{ 821{
887 unsigned int val; 822 unsigned int val;
888 int counter; 823 int counter;
889 enter("deactivate_transmitter");
890 824
891 val = inl(card->io_port + CSR6); /* Operation mode */ 825 val = inl(card->io_port + CSR6); /* Operation mode */
892 val = val & ~2; /* disable the transmitter */ 826 val = val & ~2; /* disable the transmitter */
@@ -900,11 +834,9 @@ static void deactivate_transmitter(struct xircom_private *card)
900 udelay(50); 834 udelay(50);
901 counter--; 835 counter--;
902 if (counter <= 0) 836 if (counter <= 0)
903 pr_err("Transmitter failed to deactivate\n"); 837 netdev_err(card->dev,
838 "Transmitter failed to deactivate\n");
904 } 839 }
905
906
907 leave("deactivate_transmitter");
908} 840}
909 841
910 842
@@ -916,13 +848,10 @@ must be called with the lock held and interrupts disabled.
916static void enable_transmit_interrupt(struct xircom_private *card) 848static void enable_transmit_interrupt(struct xircom_private *card)
917{ 849{
918 unsigned int val; 850 unsigned int val;
919 enter("enable_transmit_interrupt");
920 851
921 val = inl(card->io_port + CSR7); /* Interrupt enable register */ 852 val = inl(card->io_port + CSR7); /* Interrupt enable register */
922 val |= 1; /* enable the transmit interrupt */ 853 val |= 1; /* enable the transmit interrupt */
923 outl(val, card->io_port + CSR7); 854 outl(val, card->io_port + CSR7);
924
925 leave("enable_transmit_interrupt");
926} 855}
927 856
928 857
@@ -934,13 +863,10 @@ must be called with the lock held and interrupts disabled.
934static void enable_receive_interrupt(struct xircom_private *card) 863static void enable_receive_interrupt(struct xircom_private *card)
935{ 864{
936 unsigned int val; 865 unsigned int val;
937 enter("enable_receive_interrupt");
938 866
939 val = inl(card->io_port + CSR7); /* Interrupt enable register */ 867 val = inl(card->io_port + CSR7); /* Interrupt enable register */
940 val = val | (1 << 6); /* enable the receive interrupt */ 868 val = val | (1 << 6); /* enable the receive interrupt */
941 outl(val, card->io_port + CSR7); 869 outl(val, card->io_port + CSR7);
942
943 leave("enable_receive_interrupt");
944} 870}
945 871
946/* 872/*
@@ -951,13 +877,10 @@ must be called with the lock held and interrupts disabled.
951static void enable_link_interrupt(struct xircom_private *card) 877static void enable_link_interrupt(struct xircom_private *card)
952{ 878{
953 unsigned int val; 879 unsigned int val;
954 enter("enable_link_interrupt");
955 880
956 val = inl(card->io_port + CSR7); /* Interrupt enable register */ 881 val = inl(card->io_port + CSR7); /* Interrupt enable register */
957 val = val | (1 << 27); /* enable the link status chage interrupt */ 882 val = val | (1 << 27); /* enable the link status chage interrupt */
958 outl(val, card->io_port + CSR7); 883 outl(val, card->io_port + CSR7);
959
960 leave("enable_link_interrupt");
961} 884}
962 885
963 886
@@ -970,12 +893,9 @@ must be called with the lock held and interrupts disabled.
970static void disable_all_interrupts(struct xircom_private *card) 893static void disable_all_interrupts(struct xircom_private *card)
971{ 894{
972 unsigned int val; 895 unsigned int val;
973 enter("enable_all_interrupts");
974 896
975 val = 0; /* disable all interrupts */ 897 val = 0; /* disable all interrupts */
976 outl(val, card->io_port + CSR7); 898 outl(val, card->io_port + CSR7);
977
978 leave("disable_all_interrupts");
979} 899}
980 900
981/* 901/*
@@ -986,7 +906,6 @@ must be called with the lock held and interrupts disabled.
986static void enable_common_interrupts(struct xircom_private *card) 906static void enable_common_interrupts(struct xircom_private *card)
987{ 907{
988 unsigned int val; 908 unsigned int val;
989 enter("enable_link_interrupt");
990 909
991 val = inl(card->io_port + CSR7); /* Interrupt enable register */ 910 val = inl(card->io_port + CSR7); /* Interrupt enable register */
992 val |= (1<<16); /* Normal Interrupt Summary */ 911 val |= (1<<16); /* Normal Interrupt Summary */
@@ -998,8 +917,6 @@ static void enable_common_interrupts(struct xircom_private *card)
998 val |= (1<<2); /* Transmit Buffer Unavailable */ 917 val |= (1<<2); /* Transmit Buffer Unavailable */
999 val |= (1<<1); /* Transmit Process Stopped */ 918 val |= (1<<1); /* Transmit Process Stopped */
1000 outl(val, card->io_port + CSR7); 919 outl(val, card->io_port + CSR7);
1001
1002 leave("enable_link_interrupt");
1003} 920}
1004 921
1005/* 922/*
@@ -1010,13 +927,11 @@ must be called with the lock held and interrupts disabled.
1010static int enable_promisc(struct xircom_private *card) 927static int enable_promisc(struct xircom_private *card)
1011{ 928{
1012 unsigned int val; 929 unsigned int val;
1013 enter("enable_promisc");
1014 930
1015 val = inl(card->io_port + CSR6); 931 val = inl(card->io_port + CSR6);
1016 val = val | (1 << 6); 932 val = val | (1 << 6);
1017 outl(val, card->io_port + CSR6); 933 outl(val, card->io_port + CSR6);
1018 934
1019 leave("enable_promisc");
1020 return 1; 935 return 1;
1021} 936}
1022 937
@@ -1031,7 +946,6 @@ Must be called in locked state with interrupts disabled
1031static int link_status(struct xircom_private *card) 946static int link_status(struct xircom_private *card)
1032{ 947{
1033 unsigned int val; 948 unsigned int val;
1034 enter("link_status");
1035 949
1036 val = inb(card->io_port + CSR12); 950 val = inb(card->io_port + CSR12);
1037 951
@@ -1042,7 +956,6 @@ static int link_status(struct xircom_private *card)
1042 956
1043 /* If we get here -> no link at all */ 957 /* If we get here -> no link at all */
1044 958
1045 leave("link_status");
1046 return 0; 959 return 0;
1047} 960}
1048 961
@@ -1061,8 +974,6 @@ static void read_mac_address(struct xircom_private *card)
1061 unsigned long flags; 974 unsigned long flags;
1062 int i; 975 int i;
1063 976
1064 enter("read_mac_address");
1065
1066 spin_lock_irqsave(&card->lock, flags); 977 spin_lock_irqsave(&card->lock, flags);
1067 978
1068 outl(1 << 12, card->io_port + CSR9); /* enable boot rom access */ 979 outl(1 << 12, card->io_port + CSR9); /* enable boot rom access */
@@ -1090,7 +1001,6 @@ static void read_mac_address(struct xircom_private *card)
1090 } 1001 }
1091 spin_unlock_irqrestore(&card->lock, flags); 1002 spin_unlock_irqrestore(&card->lock, flags);
1092 pr_debug(" %pM\n", card->dev->dev_addr); 1003 pr_debug(" %pM\n", card->dev->dev_addr);
1093 leave("read_mac_address");
1094} 1004}
1095 1005
1096 1006
@@ -1103,8 +1013,6 @@ static void transceiver_voodoo(struct xircom_private *card)
1103{ 1013{
1104 unsigned long flags; 1014 unsigned long flags;
1105 1015
1106 enter("transceiver_voodoo");
1107
1108 /* disable all powermanagement */ 1016 /* disable all powermanagement */
1109 pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000); 1017 pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000);
1110 1018
@@ -1122,7 +1030,6 @@ static void transceiver_voodoo(struct xircom_private *card)
1122 spin_unlock_irqrestore(&card->lock, flags); 1030 spin_unlock_irqrestore(&card->lock, flags);
1123 1031
1124 netif_start_queue(card->dev); 1032 netif_start_queue(card->dev);
1125 leave("transceiver_voodoo");
1126} 1033}
1127 1034
1128 1035
@@ -1131,8 +1038,6 @@ static void xircom_up(struct xircom_private *card)
1131 unsigned long flags; 1038 unsigned long flags;
1132 int i; 1039 int i;
1133 1040
1134 enter("xircom_up");
1135
1136 /* disable all powermanagement */ 1041 /* disable all powermanagement */
1137 pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000); 1042 pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000);
1138 1043
@@ -1156,87 +1061,84 @@ static void xircom_up(struct xircom_private *card)
1156 trigger_receive(card); 1061 trigger_receive(card);
1157 trigger_transmit(card); 1062 trigger_transmit(card);
1158 netif_start_queue(card->dev); 1063 netif_start_queue(card->dev);
1159 leave("xircom_up");
1160} 1064}
1161 1065
1162/* Bufferoffset is in BYTES */ 1066/* Bufferoffset is in BYTES */
1163static void investigate_read_descriptor(struct net_device *dev,struct xircom_private *card, int descnr, unsigned int bufferoffset) 1067static void
1068investigate_read_descriptor(struct net_device *dev, struct xircom_private *card,
1069 int descnr, unsigned int bufferoffset)
1164{ 1070{
1165 int status; 1071 int status;
1166
1167 enter("investigate_read_descriptor");
1168 status = le32_to_cpu(card->rx_buffer[4*descnr]);
1169 1072
1170 if ((status > 0)) { /* packet received */ 1073 status = le32_to_cpu(card->rx_buffer[4*descnr]);
1171 1074
1172 /* TODO: discard error packets */ 1075 if (status > 0) { /* packet received */
1173 1076
1174 short pkt_len = ((status >> 16) & 0x7ff) - 4; /* minus 4, we don't want the CRC */ 1077 /* TODO: discard error packets */
1175 struct sk_buff *skb;
1176 1078
1177 if (pkt_len > 1518) { 1079 short pkt_len = ((status >> 16) & 0x7ff) - 4;
1178 pr_err("Packet length %i is bogus\n", pkt_len); 1080 /* minus 4, we don't want the CRC */
1179 pkt_len = 1518; 1081 struct sk_buff *skb;
1180 }
1181 1082
1182 skb = dev_alloc_skb(pkt_len + 2); 1083 if (pkt_len > 1518) {
1183 if (skb == NULL) { 1084 netdev_err(dev, "Packet length %i is bogus\n", pkt_len);
1184 dev->stats.rx_dropped++; 1085 pkt_len = 1518;
1185 goto out;
1186 }
1187 skb_reserve(skb, 2);
1188 skb_copy_to_linear_data(skb, (unsigned char*)&card->rx_buffer[bufferoffset / 4], pkt_len);
1189 skb_put(skb, pkt_len);
1190 skb->protocol = eth_type_trans(skb, dev);
1191 netif_rx(skb);
1192 dev->stats.rx_packets++;
1193 dev->stats.rx_bytes += pkt_len;
1194
1195 out:
1196 /* give the buffer back to the card */
1197 card->rx_buffer[4*descnr] = cpu_to_le32(0x80000000);
1198 trigger_receive(card);
1199 } 1086 }
1200 1087
1201 leave("investigate_read_descriptor"); 1088 skb = dev_alloc_skb(pkt_len + 2);
1202 1089 if (skb == NULL) {
1090 dev->stats.rx_dropped++;
1091 goto out;
1092 }
1093 skb_reserve(skb, 2);
1094 skb_copy_to_linear_data(skb,
1095 &card->rx_buffer[bufferoffset / 4],
1096 pkt_len);
1097 skb_put(skb, pkt_len);
1098 skb->protocol = eth_type_trans(skb, dev);
1099 netif_rx(skb);
1100 dev->stats.rx_packets++;
1101 dev->stats.rx_bytes += pkt_len;
1102
1103out:
1104 /* give the buffer back to the card */
1105 card->rx_buffer[4*descnr] = cpu_to_le32(0x80000000);
1106 trigger_receive(card);
1107 }
1203} 1108}
1204 1109
1205 1110
1206/* Bufferoffset is in BYTES */ 1111/* Bufferoffset is in BYTES */
1207static void investigate_write_descriptor(struct net_device *dev, struct xircom_private *card, int descnr, unsigned int bufferoffset) 1112static void
1113investigate_write_descriptor(struct net_device *dev,
1114 struct xircom_private *card,
1115 int descnr, unsigned int bufferoffset)
1208{ 1116{
1209 int status; 1117 int status;
1210
1211 enter("investigate_write_descriptor");
1212 1118
1213 status = le32_to_cpu(card->tx_buffer[4*descnr]); 1119 status = le32_to_cpu(card->tx_buffer[4*descnr]);
1214#if 0 1120#if 0
1215 if (status & 0x8000) { /* Major error */ 1121 if (status & 0x8000) { /* Major error */
1216 pr_err("Major transmit error status %x\n", status); 1122 pr_err("Major transmit error status %x\n", status);
1217 card->tx_buffer[4*descnr] = 0; 1123 card->tx_buffer[4*descnr] = 0;
1218 netif_wake_queue (dev); 1124 netif_wake_queue (dev);
1219 } 1125 }
1220#endif 1126#endif
1221 if (status > 0) { /* bit 31 is 0 when done */ 1127 if (status > 0) { /* bit 31 is 0 when done */
1222 if (card->tx_skb[descnr]!=NULL) { 1128 if (card->tx_skb[descnr]!=NULL) {
1223 dev->stats.tx_bytes += card->tx_skb[descnr]->len; 1129 dev->stats.tx_bytes += card->tx_skb[descnr]->len;
1224 dev_kfree_skb_irq(card->tx_skb[descnr]); 1130 dev_kfree_skb_irq(card->tx_skb[descnr]);
1225 }
1226 card->tx_skb[descnr] = NULL;
1227 /* Bit 8 in the status field is 1 if there was a collision */
1228 if (status&(1<<8))
1229 dev->stats.collisions++;
1230 card->tx_buffer[4*descnr] = 0; /* descriptor is free again */
1231 netif_wake_queue (dev);
1232 dev->stats.tx_packets++;
1233 } 1131 }
1234 1132 card->tx_skb[descnr] = NULL;
1235 leave("investigate_write_descriptor"); 1133 /* Bit 8 in the status field is 1 if there was a collision */
1236 1134 if (status & (1 << 8))
1135 dev->stats.collisions++;
1136 card->tx_buffer[4*descnr] = 0; /* descriptor is free again */
1137 netif_wake_queue (dev);
1138 dev->stats.tx_packets++;
1139 }
1237} 1140}
1238 1141
1239
1240static int __init xircom_init(void) 1142static int __init xircom_init(void)
1241{ 1143{
1242 return pci_register_driver(&xircom_ops); 1144 return pci_register_driver(&xircom_ops);