aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tulip/xircom_cb.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/net/tulip/xircom_cb.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/net/tulip/xircom_cb.c')
-rw-r--r--drivers/net/tulip/xircom_cb.c283
1 files changed, 85 insertions, 198 deletions
diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
index a439e93be22d..988b8eb24d37 100644
--- a/drivers/net/tulip/xircom_cb.c
+++ b/drivers/net/tulip/xircom_cb.c
@@ -29,7 +29,6 @@
29#include <linux/skbuff.h> 29#include <linux/skbuff.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/ethtool.h>
33#include <linux/bitops.h> 32#include <linux/bitops.h>
34 33
35#include <asm/uaccess.h> 34#include <asm/uaccess.h>
@@ -38,15 +37,6 @@
38#include <asm/irq.h> 37#include <asm/irq.h>
39#endif 38#endif
40 39
41#ifdef DEBUG
42#define enter(x) printk("Enter: %s, %s line %i\n",x,__FILE__,__LINE__)
43#define leave(x) printk("Leave: %s, %s line %i\n",x,__FILE__,__LINE__)
44#else
45#define enter(x) do {} while (0)
46#define leave(x) do {} while (0)
47#endif
48
49
50MODULE_DESCRIPTION("Xircom Cardbus ethernet driver"); 40MODULE_DESCRIPTION("Xircom Cardbus ethernet driver");
51MODULE_AUTHOR("Arjan van de Ven <arjanv@redhat.com>"); 41MODULE_AUTHOR("Arjan van de Ven <arjanv@redhat.com>");
52MODULE_LICENSE("GPL"); 42MODULE_LICENSE("GPL");
@@ -162,7 +152,7 @@ static struct pci_driver xircom_ops = {
162}; 152};
163 153
164 154
165#ifdef DEBUG 155#if defined DEBUG && DEBUG > 1
166static void print_binary(unsigned int number) 156static void print_binary(unsigned int number)
167{ 157{
168 int i,i2; 158 int i,i2;
@@ -177,23 +167,10 @@ static void print_binary(unsigned int number)
177 if ((i&3)==0) 167 if ((i&3)==0)
178 buffer[i2++]=' '; 168 buffer[i2++]=' ';
179 } 169 }
180 printk("%s\n",buffer); 170 pr_debug("%s\n",buffer);
181} 171}
182#endif 172#endif
183 173
184static void netdev_get_drvinfo(struct net_device *dev,
185 struct ethtool_drvinfo *info)
186{
187 struct xircom_private *private = netdev_priv(dev);
188
189 strcpy(info->driver, "xircom_cb");
190 strcpy(info->bus_info, pci_name(private->pdev));
191}
192
193static const struct ethtool_ops netdev_ethtool_ops = {
194 .get_drvinfo = netdev_get_drvinfo,
195};
196
197static const struct net_device_ops netdev_ops = { 174static const struct net_device_ops netdev_ops = {
198 .ndo_open = xircom_open, 175 .ndo_open = xircom_open,
199 .ndo_stop = xircom_close, 176 .ndo_stop = xircom_close,
@@ -219,7 +196,6 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
219 struct xircom_private *private; 196 struct xircom_private *private;
220 unsigned long flags; 197 unsigned long flags;
221 unsigned short tmp16; 198 unsigned short tmp16;
222 enter("xircom_probe");
223 199
224 /* First do the PCI initialisation */ 200 /* First do the PCI initialisation */
225 201
@@ -279,7 +255,6 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
279 setup_descriptors(private); 255 setup_descriptors(private);
280 256
281 dev->netdev_ops = &netdev_ops; 257 dev->netdev_ops = &netdev_ops;
282 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
283 pci_set_drvdata(pdev, dev); 258 pci_set_drvdata(pdev, dev);
284 259
285 if (register_netdev(dev)) { 260 if (register_netdev(dev)) {
@@ -287,8 +262,8 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
287 goto reg_fail; 262 goto reg_fail;
288 } 263 }
289 264
290 dev_info(&dev->dev, "Xircom cardbus revision %i at irq %i\n", 265 netdev_info(dev, "Xircom cardbus revision %i at irq %i\n",
291 pdev->revision, pdev->irq); 266 pdev->revision, pdev->irq);
292 /* start the transmitter to get a heartbeat */ 267 /* start the transmitter to get a heartbeat */
293 /* TODO: send 2 dummy packets here */ 268 /* TODO: send 2 dummy packets here */
294 transceiver_voodoo(private); 269 transceiver_voodoo(private);
@@ -300,7 +275,6 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
300 275
301 trigger_receive(private); 276 trigger_receive(private);
302 277
303 leave("xircom_probe");
304 return 0; 278 return 0;
305 279
306reg_fail: 280reg_fail:
@@ -325,7 +299,6 @@ static void __devexit xircom_remove(struct pci_dev *pdev)
325 struct net_device *dev = pci_get_drvdata(pdev); 299 struct net_device *dev = pci_get_drvdata(pdev);
326 struct xircom_private *card = netdev_priv(dev); 300 struct xircom_private *card = netdev_priv(dev);
327 301
328 enter("xircom_remove");
329 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);
330 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);
331 304
@@ -333,7 +306,6 @@ static void __devexit xircom_remove(struct pci_dev *pdev)
333 unregister_netdev(dev); 306 unregister_netdev(dev);
334 free_netdev(dev); 307 free_netdev(dev);
335 pci_set_drvdata(pdev, NULL); 308 pci_set_drvdata(pdev, NULL);
336 leave("xircom_remove");
337} 309}
338 310
339static irqreturn_t xircom_interrupt(int irq, void *dev_instance) 311static irqreturn_t xircom_interrupt(int irq, void *dev_instance)
@@ -343,17 +315,15 @@ static irqreturn_t xircom_interrupt(int irq, void *dev_instance)
343 unsigned int status; 315 unsigned int status;
344 int i; 316 int i;
345 317
346 enter("xircom_interrupt\n");
347
348 spin_lock(&card->lock); 318 spin_lock(&card->lock);
349 status = inl(card->io_port+CSR5); 319 status = inl(card->io_port+CSR5);
350 320
351#ifdef DEBUG 321#if defined DEBUG && DEBUG > 1
352 print_binary(status); 322 print_binary(status);
353 printk("tx status 0x%08x 0x%08x\n", 323 pr_debug("tx status 0x%08x 0x%08x\n",
354 card->tx_buffer[0], card->tx_buffer[4]); 324 card->tx_buffer[0], card->tx_buffer[4]);
355 printk("rx status 0x%08x 0x%08x\n", 325 pr_debug("rx status 0x%08x 0x%08x\n",
356 card->rx_buffer[0], card->rx_buffer[4]); 326 card->rx_buffer[0], card->rx_buffer[4]);
357#endif 327#endif
358 /* Handle shared irq and hotplug */ 328 /* Handle shared irq and hotplug */
359 if (status == 0 || status == 0xffffffff) { 329 if (status == 0 || status == 0xffffffff) {
@@ -363,9 +333,9 @@ static irqreturn_t xircom_interrupt(int irq, void *dev_instance)
363 333
364 if (link_status_changed(card)) { 334 if (link_status_changed(card)) {
365 int newlink; 335 int newlink;
366 printk(KERN_DEBUG "xircom_cb: Link status has changed\n"); 336 netdev_dbg(dev, "Link status has changed\n");
367 newlink = link_status(card); 337 newlink = link_status(card);
368 dev_info(&dev->dev, "Link is %i mbit\n", newlink); 338 netdev_info(dev, "Link is %d mbit\n", newlink);
369 if (newlink) 339 if (newlink)
370 netif_carrier_on(dev); 340 netif_carrier_on(dev);
371 else 341 else
@@ -384,9 +354,7 @@ static irqreturn_t xircom_interrupt(int irq, void *dev_instance)
384 for (i=0;i<NUMDESCRIPTORS;i++) 354 for (i=0;i<NUMDESCRIPTORS;i++)
385 investigate_read_descriptor(dev,card,i,bufferoffsets[i]); 355 investigate_read_descriptor(dev,card,i,bufferoffsets[i]);
386 356
387
388 spin_unlock(&card->lock); 357 spin_unlock(&card->lock);
389 leave("xircom_interrupt");
390 return IRQ_HANDLED; 358 return IRQ_HANDLED;
391} 359}
392 360
@@ -397,7 +365,6 @@ static netdev_tx_t xircom_start_xmit(struct sk_buff *skb,
397 unsigned long flags; 365 unsigned long flags;
398 int nextdescriptor; 366 int nextdescriptor;
399 int desc; 367 int desc;
400 enter("xircom_start_xmit");
401 368
402 card = netdev_priv(dev); 369 card = netdev_priv(dev);
403 spin_lock_irqsave(&card->lock,flags); 370 spin_lock_irqsave(&card->lock,flags);
@@ -439,13 +406,10 @@ static netdev_tx_t xircom_start_xmit(struct sk_buff *skb,
439 netif_stop_queue(dev); 406 netif_stop_queue(dev);
440 } 407 }
441 card->transmit_used = nextdescriptor; 408 card->transmit_used = nextdescriptor;
442 leave("xircom-start_xmit - sent");
443 spin_unlock_irqrestore(&card->lock,flags); 409 spin_unlock_irqrestore(&card->lock,flags);
444 return NETDEV_TX_OK; 410 return NETDEV_TX_OK;
445 } 411 }
446 412
447
448
449 /* Uh oh... no free descriptor... drop the packet */ 413 /* Uh oh... no free descriptor... drop the packet */
450 netif_stop_queue(dev); 414 netif_stop_queue(dev);
451 spin_unlock_irqrestore(&card->lock,flags); 415 spin_unlock_irqrestore(&card->lock,flags);
@@ -461,18 +425,16 @@ static int xircom_open(struct net_device *dev)
461{ 425{
462 struct xircom_private *xp = netdev_priv(dev); 426 struct xircom_private *xp = netdev_priv(dev);
463 int retval; 427 int retval;
464 enter("xircom_open"); 428
465 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",
466 dev->name, dev->irq); 430 dev->irq);
467 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);
468 if (retval) { 432 if (retval)
469 leave("xircom_open - No IRQ");
470 return retval; 433 return retval;
471 }
472 434
473 xircom_up(xp); 435 xircom_up(xp);
474 xp->open = 1; 436 xp->open = 1;
475 leave("xircom_open"); 437
476 return 0; 438 return 0;
477} 439}
478 440
@@ -481,7 +443,6 @@ static int xircom_close(struct net_device *dev)
481 struct xircom_private *card; 443 struct xircom_private *card;
482 unsigned long flags; 444 unsigned long flags;
483 445
484 enter("xircom_close");
485 card = netdev_priv(dev); 446 card = netdev_priv(dev);
486 netif_stop_queue(dev); /* we don't want new packets */ 447 netif_stop_queue(dev); /* we don't want new packets */
487 448
@@ -501,8 +462,6 @@ static int xircom_close(struct net_device *dev)
501 card->open = 0; 462 card->open = 0;
502 free_irq(dev->irq,dev); 463 free_irq(dev->irq,dev);
503 464
504 leave("xircom_close");
505
506 return 0; 465 return 0;
507 466
508} 467}
@@ -522,8 +481,6 @@ static void initialize_card(struct xircom_private *card)
522{ 481{
523 unsigned int val; 482 unsigned int val;
524 unsigned long flags; 483 unsigned long flags;
525 enter("initialize_card");
526
527 484
528 spin_lock_irqsave(&card->lock, flags); 485 spin_lock_irqsave(&card->lock, flags);
529 486
@@ -549,8 +506,6 @@ static void initialize_card(struct xircom_private *card)
549 deactivate_transmitter(card); 506 deactivate_transmitter(card);
550 507
551 spin_unlock_irqrestore(&card->lock, flags); 508 spin_unlock_irqrestore(&card->lock, flags);
552
553 leave("initialize_card");
554} 509}
555 510
556/* 511/*
@@ -562,12 +517,9 @@ ignored; I chose zero.
562static void trigger_transmit(struct xircom_private *card) 517static void trigger_transmit(struct xircom_private *card)
563{ 518{
564 unsigned int val; 519 unsigned int val;
565 enter("trigger_transmit");
566 520
567 val = 0; 521 val = 0;
568 outl(val, card->io_port + CSR1); 522 outl(val, card->io_port + CSR1);
569
570 leave("trigger_transmit");
571} 523}
572 524
573/* 525/*
@@ -580,12 +532,9 @@ ignored; I chose zero.
580static void trigger_receive(struct xircom_private *card) 532static void trigger_receive(struct xircom_private *card)
581{ 533{
582 unsigned int val; 534 unsigned int val;
583 enter("trigger_receive");
584 535
585 val = 0; 536 val = 0;
586 outl(val, card->io_port + CSR2); 537 outl(val, card->io_port + CSR2);
587
588 leave("trigger_receive");
589} 538}
590 539
591/* 540/*
@@ -596,8 +545,6 @@ static void setup_descriptors(struct xircom_private *card)
596{ 545{
597 u32 address; 546 u32 address;
598 int i; 547 int i;
599 enter("setup_descriptors");
600
601 548
602 BUG_ON(card->rx_buffer == NULL); 549 BUG_ON(card->rx_buffer == NULL);
603 BUG_ON(card->tx_buffer == NULL); 550 BUG_ON(card->tx_buffer == NULL);
@@ -651,8 +598,6 @@ static void setup_descriptors(struct xircom_private *card)
651 /* wite the transmit descriptor ring to the card */ 598 /* wite the transmit descriptor ring to the card */
652 address = card->tx_dma_handle; 599 address = card->tx_dma_handle;
653 outl(address, card->io_port + CSR4); /* xmit descr list address */ 600 outl(address, card->io_port + CSR4); /* xmit descr list address */
654
655 leave("setup_descriptors");
656} 601}
657 602
658/* 603/*
@@ -662,13 +607,10 @@ valid by setting the address in the card to 0x00.
662static void remove_descriptors(struct xircom_private *card) 607static void remove_descriptors(struct xircom_private *card)
663{ 608{
664 unsigned int val; 609 unsigned int val;
665 enter("remove_descriptors");
666 610
667 val = 0; 611 val = 0;
668 outl(val, card->io_port + CSR3); /* Receive descriptor address */ 612 outl(val, card->io_port + CSR3); /* Receive descriptor address */
669 outl(val, card->io_port + CSR4); /* Send descriptor address */ 613 outl(val, card->io_port + CSR4); /* Send descriptor address */
670
671 leave("remove_descriptors");
672} 614}
673 615
674/* 616/*
@@ -680,21 +622,17 @@ This function also clears the status-bit.
680static int link_status_changed(struct xircom_private *card) 622static int link_status_changed(struct xircom_private *card)
681{ 623{
682 unsigned int val; 624 unsigned int val;
683 enter("link_status_changed");
684 625
685 val = inl(card->io_port + CSR5); /* Status register */ 626 val = inl(card->io_port + CSR5); /* Status register */
686 627
687 if ((val & (1 << 27)) == 0) { /* no change */ 628 if ((val & (1 << 27)) == 0) /* no change */
688 leave("link_status_changed - nochange");
689 return 0; 629 return 0;
690 }
691 630
692 /* 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
693 status register. */ 632 status register. */
694 val = (1 << 27); 633 val = (1 << 27);
695 outl(val, card->io_port + CSR5); 634 outl(val, card->io_port + CSR5);
696 635
697 leave("link_status_changed - changed");
698 return 1; 636 return 1;
699} 637}
700 638
@@ -706,16 +644,12 @@ in a non-stopped state.
706static int transmit_active(struct xircom_private *card) 644static int transmit_active(struct xircom_private *card)
707{ 645{
708 unsigned int val; 646 unsigned int val;
709 enter("transmit_active");
710 647
711 val = inl(card->io_port + CSR5); /* Status register */ 648 val = inl(card->io_port + CSR5); /* Status register */
712 649
713 if ((val & (7 << 20)) == 0) { /* transmitter disabled */ 650 if ((val & (7 << 20)) == 0) /* transmitter disabled */
714 leave("transmit_active - inactive");
715 return 0; 651 return 0;
716 }
717 652
718 leave("transmit_active - active");
719 return 1; 653 return 1;
720} 654}
721 655
@@ -726,17 +660,12 @@ in a non-stopped state.
726static int receive_active(struct xircom_private *card) 660static int receive_active(struct xircom_private *card)
727{ 661{
728 unsigned int val; 662 unsigned int val;
729 enter("receive_active");
730
731 663
732 val = inl(card->io_port + CSR5); /* Status register */ 664 val = inl(card->io_port + CSR5); /* Status register */
733 665
734 if ((val & (7 << 17)) == 0) { /* receiver disabled */ 666 if ((val & (7 << 17)) == 0) /* receiver disabled */
735 leave("receive_active - inactive");
736 return 0; 667 return 0;
737 }
738 668
739 leave("receive_active - active");
740 return 1; 669 return 1;
741} 670}
742 671
@@ -754,8 +683,6 @@ static void activate_receiver(struct xircom_private *card)
754{ 683{
755 unsigned int val; 684 unsigned int val;
756 int counter; 685 int counter;
757 enter("activate_receiver");
758
759 686
760 val = inl(card->io_port + CSR6); /* Operation mode */ 687 val = inl(card->io_port + CSR6); /* Operation mode */
761 688
@@ -776,7 +703,7 @@ static void activate_receiver(struct xircom_private *card)
776 udelay(50); 703 udelay(50);
777 counter--; 704 counter--;
778 if (counter <= 0) 705 if (counter <= 0)
779 pr_err("Receiver failed to deactivate\n"); 706 netdev_err(card->dev, "Receiver failed to deactivate\n");
780 } 707 }
781 708
782 /* enable the receiver */ 709 /* enable the receiver */
@@ -793,10 +720,9 @@ static void activate_receiver(struct xircom_private *card)
793 udelay(50); 720 udelay(50);
794 counter--; 721 counter--;
795 if (counter <= 0) 722 if (counter <= 0)
796 pr_err("Receiver failed to re-activate\n"); 723 netdev_err(card->dev,
724 "Receiver failed to re-activate\n");
797 } 725 }
798
799 leave("activate_receiver");
800} 726}
801 727
802/* 728/*
@@ -810,7 +736,6 @@ static void deactivate_receiver(struct xircom_private *card)
810{ 736{
811 unsigned int val; 737 unsigned int val;
812 int counter; 738 int counter;
813 enter("deactivate_receiver");
814 739
815 val = inl(card->io_port + CSR6); /* Operation mode */ 740 val = inl(card->io_port + CSR6); /* Operation mode */
816 val = val & ~2; /* disable the receiver */ 741 val = val & ~2; /* disable the receiver */
@@ -824,11 +749,8 @@ static void deactivate_receiver(struct xircom_private *card)
824 udelay(50); 749 udelay(50);
825 counter--; 750 counter--;
826 if (counter <= 0) 751 if (counter <= 0)
827 pr_err("Receiver failed to deactivate\n"); 752 netdev_err(card->dev, "Receiver failed to deactivate\n");
828 } 753 }
829
830
831 leave("deactivate_receiver");
832} 754}
833 755
834 756
@@ -846,8 +768,6 @@ static void activate_transmitter(struct xircom_private *card)
846{ 768{
847 unsigned int val; 769 unsigned int val;
848 int counter; 770 int counter;
849 enter("activate_transmitter");
850
851 771
852 val = inl(card->io_port + CSR6); /* Operation mode */ 772 val = inl(card->io_port + CSR6); /* Operation mode */
853 773
@@ -867,7 +787,8 @@ static void activate_transmitter(struct xircom_private *card)
867 udelay(50); 787 udelay(50);
868 counter--; 788 counter--;
869 if (counter <= 0) 789 if (counter <= 0)
870 pr_err("Transmitter failed to deactivate\n"); 790 netdev_err(card->dev,
791 "Transmitter failed to deactivate\n");
871 } 792 }
872 793
873 /* enable the transmitter */ 794 /* enable the transmitter */
@@ -884,10 +805,9 @@ static void activate_transmitter(struct xircom_private *card)
884 udelay(50); 805 udelay(50);
885 counter--; 806 counter--;
886 if (counter <= 0) 807 if (counter <= 0)
887 pr_err("Transmitter failed to re-activate\n"); 808 netdev_err(card->dev,
809 "Transmitter failed to re-activate\n");
888 } 810 }
889
890 leave("activate_transmitter");
891} 811}
892 812
893/* 813/*
@@ -901,7 +821,6 @@ static void deactivate_transmitter(struct xircom_private *card)
901{ 821{
902 unsigned int val; 822 unsigned int val;
903 int counter; 823 int counter;
904 enter("deactivate_transmitter");
905 824
906 val = inl(card->io_port + CSR6); /* Operation mode */ 825 val = inl(card->io_port + CSR6); /* Operation mode */
907 val = val & ~2; /* disable the transmitter */ 826 val = val & ~2; /* disable the transmitter */
@@ -915,11 +834,9 @@ static void deactivate_transmitter(struct xircom_private *card)
915 udelay(50); 834 udelay(50);
916 counter--; 835 counter--;
917 if (counter <= 0) 836 if (counter <= 0)
918 pr_err("Transmitter failed to deactivate\n"); 837 netdev_err(card->dev,
838 "Transmitter failed to deactivate\n");
919 } 839 }
920
921
922 leave("deactivate_transmitter");
923} 840}
924 841
925 842
@@ -931,13 +848,10 @@ must be called with the lock held and interrupts disabled.
931static void enable_transmit_interrupt(struct xircom_private *card) 848static void enable_transmit_interrupt(struct xircom_private *card)
932{ 849{
933 unsigned int val; 850 unsigned int val;
934 enter("enable_transmit_interrupt");
935 851
936 val = inl(card->io_port + CSR7); /* Interrupt enable register */ 852 val = inl(card->io_port + CSR7); /* Interrupt enable register */
937 val |= 1; /* enable the transmit interrupt */ 853 val |= 1; /* enable the transmit interrupt */
938 outl(val, card->io_port + CSR7); 854 outl(val, card->io_port + CSR7);
939
940 leave("enable_transmit_interrupt");
941} 855}
942 856
943 857
@@ -949,13 +863,10 @@ must be called with the lock held and interrupts disabled.
949static void enable_receive_interrupt(struct xircom_private *card) 863static void enable_receive_interrupt(struct xircom_private *card)
950{ 864{
951 unsigned int val; 865 unsigned int val;
952 enter("enable_receive_interrupt");
953 866
954 val = inl(card->io_port + CSR7); /* Interrupt enable register */ 867 val = inl(card->io_port + CSR7); /* Interrupt enable register */
955 val = val | (1 << 6); /* enable the receive interrupt */ 868 val = val | (1 << 6); /* enable the receive interrupt */
956 outl(val, card->io_port + CSR7); 869 outl(val, card->io_port + CSR7);
957
958 leave("enable_receive_interrupt");
959} 870}
960 871
961/* 872/*
@@ -966,13 +877,10 @@ must be called with the lock held and interrupts disabled.
966static void enable_link_interrupt(struct xircom_private *card) 877static void enable_link_interrupt(struct xircom_private *card)
967{ 878{
968 unsigned int val; 879 unsigned int val;
969 enter("enable_link_interrupt");
970 880
971 val = inl(card->io_port + CSR7); /* Interrupt enable register */ 881 val = inl(card->io_port + CSR7); /* Interrupt enable register */
972 val = val | (1 << 27); /* enable the link status chage interrupt */ 882 val = val | (1 << 27); /* enable the link status chage interrupt */
973 outl(val, card->io_port + CSR7); 883 outl(val, card->io_port + CSR7);
974
975 leave("enable_link_interrupt");
976} 884}
977 885
978 886
@@ -985,12 +893,9 @@ must be called with the lock held and interrupts disabled.
985static void disable_all_interrupts(struct xircom_private *card) 893static void disable_all_interrupts(struct xircom_private *card)
986{ 894{
987 unsigned int val; 895 unsigned int val;
988 enter("enable_all_interrupts");
989 896
990 val = 0; /* disable all interrupts */ 897 val = 0; /* disable all interrupts */
991 outl(val, card->io_port + CSR7); 898 outl(val, card->io_port + CSR7);
992
993 leave("disable_all_interrupts");
994} 899}
995 900
996/* 901/*
@@ -1001,7 +906,6 @@ must be called with the lock held and interrupts disabled.
1001static void enable_common_interrupts(struct xircom_private *card) 906static void enable_common_interrupts(struct xircom_private *card)
1002{ 907{
1003 unsigned int val; 908 unsigned int val;
1004 enter("enable_link_interrupt");
1005 909
1006 val = inl(card->io_port + CSR7); /* Interrupt enable register */ 910 val = inl(card->io_port + CSR7); /* Interrupt enable register */
1007 val |= (1<<16); /* Normal Interrupt Summary */ 911 val |= (1<<16); /* Normal Interrupt Summary */
@@ -1013,8 +917,6 @@ static void enable_common_interrupts(struct xircom_private *card)
1013 val |= (1<<2); /* Transmit Buffer Unavailable */ 917 val |= (1<<2); /* Transmit Buffer Unavailable */
1014 val |= (1<<1); /* Transmit Process Stopped */ 918 val |= (1<<1); /* Transmit Process Stopped */
1015 outl(val, card->io_port + CSR7); 919 outl(val, card->io_port + CSR7);
1016
1017 leave("enable_link_interrupt");
1018} 920}
1019 921
1020/* 922/*
@@ -1025,13 +927,11 @@ must be called with the lock held and interrupts disabled.
1025static int enable_promisc(struct xircom_private *card) 927static int enable_promisc(struct xircom_private *card)
1026{ 928{
1027 unsigned int val; 929 unsigned int val;
1028 enter("enable_promisc");
1029 930
1030 val = inl(card->io_port + CSR6); 931 val = inl(card->io_port + CSR6);
1031 val = val | (1 << 6); 932 val = val | (1 << 6);
1032 outl(val, card->io_port + CSR6); 933 outl(val, card->io_port + CSR6);
1033 934
1034 leave("enable_promisc");
1035 return 1; 935 return 1;
1036} 936}
1037 937
@@ -1046,7 +946,6 @@ Must be called in locked state with interrupts disabled
1046static int link_status(struct xircom_private *card) 946static int link_status(struct xircom_private *card)
1047{ 947{
1048 unsigned int val; 948 unsigned int val;
1049 enter("link_status");
1050 949
1051 val = inb(card->io_port + CSR12); 950 val = inb(card->io_port + CSR12);
1052 951
@@ -1057,7 +956,6 @@ static int link_status(struct xircom_private *card)
1057 956
1058 /* If we get here -> no link at all */ 957 /* If we get here -> no link at all */
1059 958
1060 leave("link_status");
1061 return 0; 959 return 0;
1062} 960}
1063 961
@@ -1076,8 +974,6 @@ static void read_mac_address(struct xircom_private *card)
1076 unsigned long flags; 974 unsigned long flags;
1077 int i; 975 int i;
1078 976
1079 enter("read_mac_address");
1080
1081 spin_lock_irqsave(&card->lock, flags); 977 spin_lock_irqsave(&card->lock, flags);
1082 978
1083 outl(1 << 12, card->io_port + CSR9); /* enable boot rom access */ 979 outl(1 << 12, card->io_port + CSR9); /* enable boot rom access */
@@ -1105,7 +1001,6 @@ static void read_mac_address(struct xircom_private *card)
1105 } 1001 }
1106 spin_unlock_irqrestore(&card->lock, flags); 1002 spin_unlock_irqrestore(&card->lock, flags);
1107 pr_debug(" %pM\n", card->dev->dev_addr); 1003 pr_debug(" %pM\n", card->dev->dev_addr);
1108 leave("read_mac_address");
1109} 1004}
1110 1005
1111 1006
@@ -1118,8 +1013,6 @@ static void transceiver_voodoo(struct xircom_private *card)
1118{ 1013{
1119 unsigned long flags; 1014 unsigned long flags;
1120 1015
1121 enter("transceiver_voodoo");
1122
1123 /* disable all powermanagement */ 1016 /* disable all powermanagement */
1124 pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000); 1017 pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000);
1125 1018
@@ -1137,7 +1030,6 @@ static void transceiver_voodoo(struct xircom_private *card)
1137 spin_unlock_irqrestore(&card->lock, flags); 1030 spin_unlock_irqrestore(&card->lock, flags);
1138 1031
1139 netif_start_queue(card->dev); 1032 netif_start_queue(card->dev);
1140 leave("transceiver_voodoo");
1141} 1033}
1142 1034
1143 1035
@@ -1146,8 +1038,6 @@ static void xircom_up(struct xircom_private *card)
1146 unsigned long flags; 1038 unsigned long flags;
1147 int i; 1039 int i;
1148 1040
1149 enter("xircom_up");
1150
1151 /* disable all powermanagement */ 1041 /* disable all powermanagement */
1152 pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000); 1042 pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000);
1153 1043
@@ -1171,87 +1061,84 @@ static void xircom_up(struct xircom_private *card)
1171 trigger_receive(card); 1061 trigger_receive(card);
1172 trigger_transmit(card); 1062 trigger_transmit(card);
1173 netif_start_queue(card->dev); 1063 netif_start_queue(card->dev);
1174 leave("xircom_up");
1175} 1064}
1176 1065
1177/* Bufferoffset is in BYTES */ 1066/* Bufferoffset is in BYTES */
1178static 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)
1179{ 1070{
1180 int status; 1071 int status;
1181 1072
1182 enter("investigate_read_descriptor"); 1073 status = le32_to_cpu(card->rx_buffer[4*descnr]);
1183 status = le32_to_cpu(card->rx_buffer[4*descnr]);
1184 1074
1185 if ((status > 0)) { /* packet received */ 1075 if (status > 0) { /* packet received */
1186 1076
1187 /* TODO: discard error packets */ 1077 /* TODO: discard error packets */
1188 1078
1189 short pkt_len = ((status >> 16) & 0x7ff) - 4; /* minus 4, we don't want the CRC */ 1079 short pkt_len = ((status >> 16) & 0x7ff) - 4;
1190 struct sk_buff *skb; 1080 /* minus 4, we don't want the CRC */
1081 struct sk_buff *skb;
1191 1082
1192 if (pkt_len > 1518) { 1083 if (pkt_len > 1518) {
1193 pr_err("Packet length %i is bogus\n", pkt_len); 1084 netdev_err(dev, "Packet length %i is bogus\n", pkt_len);
1194 pkt_len = 1518; 1085 pkt_len = 1518;
1195 }
1196
1197 skb = dev_alloc_skb(pkt_len + 2);
1198 if (skb == NULL) {
1199 dev->stats.rx_dropped++;
1200 goto out;
1201 }
1202 skb_reserve(skb, 2);
1203 skb_copy_to_linear_data(skb, (unsigned char*)&card->rx_buffer[bufferoffset / 4], pkt_len);
1204 skb_put(skb, pkt_len);
1205 skb->protocol = eth_type_trans(skb, dev);
1206 netif_rx(skb);
1207 dev->stats.rx_packets++;
1208 dev->stats.rx_bytes += pkt_len;
1209
1210 out:
1211 /* give the buffer back to the card */
1212 card->rx_buffer[4*descnr] = cpu_to_le32(0x80000000);
1213 trigger_receive(card);
1214 } 1086 }
1215 1087
1216 leave("investigate_read_descriptor"); 1088 skb = dev_alloc_skb(pkt_len + 2);
1217 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 }
1218} 1108}
1219 1109
1220 1110
1221/* Bufferoffset is in BYTES */ 1111/* Bufferoffset is in BYTES */
1222static 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)
1223{ 1116{
1224 int status; 1117 int status;
1225
1226 enter("investigate_write_descriptor");
1227 1118
1228 status = le32_to_cpu(card->tx_buffer[4*descnr]); 1119 status = le32_to_cpu(card->tx_buffer[4*descnr]);
1229#if 0 1120#if 0
1230 if (status & 0x8000) { /* Major error */ 1121 if (status & 0x8000) { /* Major error */
1231 pr_err("Major transmit error status %x\n", status); 1122 pr_err("Major transmit error status %x\n", status);
1232 card->tx_buffer[4*descnr] = 0; 1123 card->tx_buffer[4*descnr] = 0;
1233 netif_wake_queue (dev); 1124 netif_wake_queue (dev);
1234 } 1125 }
1235#endif 1126#endif
1236 if (status > 0) { /* bit 31 is 0 when done */ 1127 if (status > 0) { /* bit 31 is 0 when done */
1237 if (card->tx_skb[descnr]!=NULL) { 1128 if (card->tx_skb[descnr]!=NULL) {
1238 dev->stats.tx_bytes += card->tx_skb[descnr]->len; 1129 dev->stats.tx_bytes += card->tx_skb[descnr]->len;
1239 dev_kfree_skb_irq(card->tx_skb[descnr]); 1130 dev_kfree_skb_irq(card->tx_skb[descnr]);
1240 }
1241 card->tx_skb[descnr] = NULL;
1242 /* Bit 8 in the status field is 1 if there was a collision */
1243 if (status&(1<<8))
1244 dev->stats.collisions++;
1245 card->tx_buffer[4*descnr] = 0; /* descriptor is free again */
1246 netif_wake_queue (dev);
1247 dev->stats.tx_packets++;
1248 } 1131 }
1249 1132 card->tx_skb[descnr] = NULL;
1250 leave("investigate_write_descriptor"); 1133 /* Bit 8 in the status field is 1 if there was a collision */
1251 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 }
1252} 1140}
1253 1141
1254
1255static int __init xircom_init(void) 1142static int __init xircom_init(void)
1256{ 1143{
1257 return pci_register_driver(&xircom_ops); 1144 return pci_register_driver(&xircom_ops);