diff options
Diffstat (limited to 'drivers/net/pcnet32.c')
-rw-r--r-- | drivers/net/pcnet32.c | 532 |
1 files changed, 219 insertions, 313 deletions
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c index c1b3f09f452c..084d78dd1637 100644 --- a/drivers/net/pcnet32.c +++ b/drivers/net/pcnet32.c | |||
@@ -21,6 +21,8 @@ | |||
21 | * | 21 | * |
22 | *************************************************************************/ | 22 | *************************************************************************/ |
23 | 23 | ||
24 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
25 | |||
24 | #define DRV_NAME "pcnet32" | 26 | #define DRV_NAME "pcnet32" |
25 | #define DRV_VERSION "1.35" | 27 | #define DRV_VERSION "1.35" |
26 | #define DRV_RELDATE "21.Apr.2008" | 28 | #define DRV_RELDATE "21.Apr.2008" |
@@ -45,20 +47,21 @@ static const char *const version = | |||
45 | #include <linux/crc32.h> | 47 | #include <linux/crc32.h> |
46 | #include <linux/netdevice.h> | 48 | #include <linux/netdevice.h> |
47 | #include <linux/etherdevice.h> | 49 | #include <linux/etherdevice.h> |
50 | #include <linux/if_ether.h> | ||
48 | #include <linux/skbuff.h> | 51 | #include <linux/skbuff.h> |
49 | #include <linux/spinlock.h> | 52 | #include <linux/spinlock.h> |
50 | #include <linux/moduleparam.h> | 53 | #include <linux/moduleparam.h> |
51 | #include <linux/bitops.h> | 54 | #include <linux/bitops.h> |
55 | #include <linux/io.h> | ||
56 | #include <linux/uaccess.h> | ||
52 | 57 | ||
53 | #include <asm/dma.h> | 58 | #include <asm/dma.h> |
54 | #include <asm/io.h> | ||
55 | #include <asm/uaccess.h> | ||
56 | #include <asm/irq.h> | 59 | #include <asm/irq.h> |
57 | 60 | ||
58 | /* | 61 | /* |
59 | * PCI device identifiers for "new style" Linux PCI Device Drivers | 62 | * PCI device identifiers for "new style" Linux PCI Device Drivers |
60 | */ | 63 | */ |
61 | static struct pci_device_id pcnet32_pci_tbl[] = { | 64 | static DEFINE_PCI_DEVICE_TABLE(pcnet32_pci_tbl) = { |
62 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE_HOME), }, | 65 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE_HOME), }, |
63 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE), }, | 66 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE), }, |
64 | 67 | ||
@@ -82,7 +85,7 @@ static int cards_found; | |||
82 | static unsigned int pcnet32_portlist[] __initdata = | 85 | static unsigned int pcnet32_portlist[] __initdata = |
83 | { 0x300, 0x320, 0x340, 0x360, 0 }; | 86 | { 0x300, 0x320, 0x340, 0x360, 0 }; |
84 | 87 | ||
85 | static int pcnet32_debug = 0; | 88 | static int pcnet32_debug; |
86 | static int tx_start = 1; /* Mapping -- 0:20, 1:64, 2:128, 3:~220 (depends on chip vers) */ | 89 | static int tx_start = 1; /* Mapping -- 0:20, 1:64, 2:128, 3:~220 (depends on chip vers) */ |
87 | static int pcnet32vlb; /* check for VLB cards ? */ | 90 | static int pcnet32vlb; /* check for VLB cards ? */ |
88 | 91 | ||
@@ -389,7 +392,7 @@ static struct pcnet32_access pcnet32_wio = { | |||
389 | static u16 pcnet32_dwio_read_csr(unsigned long addr, int index) | 392 | static u16 pcnet32_dwio_read_csr(unsigned long addr, int index) |
390 | { | 393 | { |
391 | outl(index, addr + PCNET32_DWIO_RAP); | 394 | outl(index, addr + PCNET32_DWIO_RAP); |
392 | return (inl(addr + PCNET32_DWIO_RDP) & 0xffff); | 395 | return inl(addr + PCNET32_DWIO_RDP) & 0xffff; |
393 | } | 396 | } |
394 | 397 | ||
395 | static void pcnet32_dwio_write_csr(unsigned long addr, int index, u16 val) | 398 | static void pcnet32_dwio_write_csr(unsigned long addr, int index, u16 val) |
@@ -401,7 +404,7 @@ static void pcnet32_dwio_write_csr(unsigned long addr, int index, u16 val) | |||
401 | static u16 pcnet32_dwio_read_bcr(unsigned long addr, int index) | 404 | static u16 pcnet32_dwio_read_bcr(unsigned long addr, int index) |
402 | { | 405 | { |
403 | outl(index, addr + PCNET32_DWIO_RAP); | 406 | outl(index, addr + PCNET32_DWIO_RAP); |
404 | return (inl(addr + PCNET32_DWIO_BDP) & 0xffff); | 407 | return inl(addr + PCNET32_DWIO_BDP) & 0xffff; |
405 | } | 408 | } |
406 | 409 | ||
407 | static void pcnet32_dwio_write_bcr(unsigned long addr, int index, u16 val) | 410 | static void pcnet32_dwio_write_bcr(unsigned long addr, int index, u16 val) |
@@ -412,7 +415,7 @@ static void pcnet32_dwio_write_bcr(unsigned long addr, int index, u16 val) | |||
412 | 415 | ||
413 | static u16 pcnet32_dwio_read_rap(unsigned long addr) | 416 | static u16 pcnet32_dwio_read_rap(unsigned long addr) |
414 | { | 417 | { |
415 | return (inl(addr + PCNET32_DWIO_RAP) & 0xffff); | 418 | return inl(addr + PCNET32_DWIO_RAP) & 0xffff; |
416 | } | 419 | } |
417 | 420 | ||
418 | static void pcnet32_dwio_write_rap(unsigned long addr, u16 val) | 421 | static void pcnet32_dwio_write_rap(unsigned long addr, u16 val) |
@@ -486,10 +489,7 @@ static void pcnet32_realloc_tx_ring(struct net_device *dev, | |||
486 | (1 << size), | 489 | (1 << size), |
487 | &new_ring_dma_addr); | 490 | &new_ring_dma_addr); |
488 | if (new_tx_ring == NULL) { | 491 | if (new_tx_ring == NULL) { |
489 | if (netif_msg_drv(lp)) | 492 | netif_err(lp, drv, dev, "Consistent memory allocation failed\n"); |
490 | printk(KERN_ERR | ||
491 | "%s: Consistent memory allocation failed.\n", | ||
492 | dev->name); | ||
493 | return; | 493 | return; |
494 | } | 494 | } |
495 | memset(new_tx_ring, 0, sizeof(struct pcnet32_tx_head) * (1 << size)); | 495 | memset(new_tx_ring, 0, sizeof(struct pcnet32_tx_head) * (1 << size)); |
@@ -497,18 +497,14 @@ static void pcnet32_realloc_tx_ring(struct net_device *dev, | |||
497 | new_dma_addr_list = kcalloc((1 << size), sizeof(dma_addr_t), | 497 | new_dma_addr_list = kcalloc((1 << size), sizeof(dma_addr_t), |
498 | GFP_ATOMIC); | 498 | GFP_ATOMIC); |
499 | if (!new_dma_addr_list) { | 499 | if (!new_dma_addr_list) { |
500 | if (netif_msg_drv(lp)) | 500 | netif_err(lp, drv, dev, "Memory allocation failed\n"); |
501 | printk(KERN_ERR | ||
502 | "%s: Memory allocation failed.\n", dev->name); | ||
503 | goto free_new_tx_ring; | 501 | goto free_new_tx_ring; |
504 | } | 502 | } |
505 | 503 | ||
506 | new_skb_list = kcalloc((1 << size), sizeof(struct sk_buff *), | 504 | new_skb_list = kcalloc((1 << size), sizeof(struct sk_buff *), |
507 | GFP_ATOMIC); | 505 | GFP_ATOMIC); |
508 | if (!new_skb_list) { | 506 | if (!new_skb_list) { |
509 | if (netif_msg_drv(lp)) | 507 | netif_err(lp, drv, dev, "Memory allocation failed\n"); |
510 | printk(KERN_ERR | ||
511 | "%s: Memory allocation failed.\n", dev->name); | ||
512 | goto free_new_lists; | 508 | goto free_new_lists; |
513 | } | 509 | } |
514 | 510 | ||
@@ -528,15 +524,14 @@ static void pcnet32_realloc_tx_ring(struct net_device *dev, | |||
528 | lp->tx_skbuff = new_skb_list; | 524 | lp->tx_skbuff = new_skb_list; |
529 | return; | 525 | return; |
530 | 526 | ||
531 | free_new_lists: | 527 | free_new_lists: |
532 | kfree(new_dma_addr_list); | 528 | kfree(new_dma_addr_list); |
533 | free_new_tx_ring: | 529 | free_new_tx_ring: |
534 | pci_free_consistent(lp->pci_dev, | 530 | pci_free_consistent(lp->pci_dev, |
535 | sizeof(struct pcnet32_tx_head) * | 531 | sizeof(struct pcnet32_tx_head) * |
536 | (1 << size), | 532 | (1 << size), |
537 | new_tx_ring, | 533 | new_tx_ring, |
538 | new_ring_dma_addr); | 534 | new_ring_dma_addr); |
539 | return; | ||
540 | } | 535 | } |
541 | 536 | ||
542 | /* | 537 | /* |
@@ -564,10 +559,7 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev, | |||
564 | (1 << size), | 559 | (1 << size), |
565 | &new_ring_dma_addr); | 560 | &new_ring_dma_addr); |
566 | if (new_rx_ring == NULL) { | 561 | if (new_rx_ring == NULL) { |
567 | if (netif_msg_drv(lp)) | 562 | netif_err(lp, drv, dev, "Consistent memory allocation failed\n"); |
568 | printk(KERN_ERR | ||
569 | "%s: Consistent memory allocation failed.\n", | ||
570 | dev->name); | ||
571 | return; | 563 | return; |
572 | } | 564 | } |
573 | memset(new_rx_ring, 0, sizeof(struct pcnet32_rx_head) * (1 << size)); | 565 | memset(new_rx_ring, 0, sizeof(struct pcnet32_rx_head) * (1 << size)); |
@@ -575,18 +567,14 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev, | |||
575 | new_dma_addr_list = kcalloc((1 << size), sizeof(dma_addr_t), | 567 | new_dma_addr_list = kcalloc((1 << size), sizeof(dma_addr_t), |
576 | GFP_ATOMIC); | 568 | GFP_ATOMIC); |
577 | if (!new_dma_addr_list) { | 569 | if (!new_dma_addr_list) { |
578 | if (netif_msg_drv(lp)) | 570 | netif_err(lp, drv, dev, "Memory allocation failed\n"); |
579 | printk(KERN_ERR | ||
580 | "%s: Memory allocation failed.\n", dev->name); | ||
581 | goto free_new_rx_ring; | 571 | goto free_new_rx_ring; |
582 | } | 572 | } |
583 | 573 | ||
584 | new_skb_list = kcalloc((1 << size), sizeof(struct sk_buff *), | 574 | new_skb_list = kcalloc((1 << size), sizeof(struct sk_buff *), |
585 | GFP_ATOMIC); | 575 | GFP_ATOMIC); |
586 | if (!new_skb_list) { | 576 | if (!new_skb_list) { |
587 | if (netif_msg_drv(lp)) | 577 | netif_err(lp, drv, dev, "Memory allocation failed\n"); |
588 | printk(KERN_ERR | ||
589 | "%s: Memory allocation failed.\n", dev->name); | ||
590 | goto free_new_lists; | 578 | goto free_new_lists; |
591 | } | 579 | } |
592 | 580 | ||
@@ -598,15 +586,14 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev, | |||
598 | new_skb_list[new] = lp->rx_skbuff[new]; | 586 | new_skb_list[new] = lp->rx_skbuff[new]; |
599 | } | 587 | } |
600 | /* now allocate any new buffers needed */ | 588 | /* now allocate any new buffers needed */ |
601 | for (; new < size; new++ ) { | 589 | for (; new < size; new++) { |
602 | struct sk_buff *rx_skbuff; | 590 | struct sk_buff *rx_skbuff; |
603 | new_skb_list[new] = dev_alloc_skb(PKT_BUF_SKB); | 591 | new_skb_list[new] = dev_alloc_skb(PKT_BUF_SKB); |
604 | if (!(rx_skbuff = new_skb_list[new])) { | 592 | rx_skbuff = new_skb_list[new]; |
593 | if (!rx_skbuff) { | ||
605 | /* keep the original lists and buffers */ | 594 | /* keep the original lists and buffers */ |
606 | if (netif_msg_drv(lp)) | 595 | netif_err(lp, drv, dev, "%s dev_alloc_skb failed\n", |
607 | printk(KERN_ERR | 596 | __func__); |
608 | "%s: pcnet32_realloc_rx_ring dev_alloc_skb failed.\n", | ||
609 | dev->name); | ||
610 | goto free_all_new; | 597 | goto free_all_new; |
611 | } | 598 | } |
612 | skb_reserve(rx_skbuff, NET_IP_ALIGN); | 599 | skb_reserve(rx_skbuff, NET_IP_ALIGN); |
@@ -643,8 +630,8 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev, | |||
643 | lp->rx_skbuff = new_skb_list; | 630 | lp->rx_skbuff = new_skb_list; |
644 | return; | 631 | return; |
645 | 632 | ||
646 | free_all_new: | 633 | free_all_new: |
647 | for (; --new >= lp->rx_ring_size; ) { | 634 | while (--new >= lp->rx_ring_size) { |
648 | if (new_skb_list[new]) { | 635 | if (new_skb_list[new]) { |
649 | pci_unmap_single(lp->pci_dev, new_dma_addr_list[new], | 636 | pci_unmap_single(lp->pci_dev, new_dma_addr_list[new], |
650 | PKT_BUF_SIZE, PCI_DMA_FROMDEVICE); | 637 | PKT_BUF_SIZE, PCI_DMA_FROMDEVICE); |
@@ -652,9 +639,9 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev, | |||
652 | } | 639 | } |
653 | } | 640 | } |
654 | kfree(new_skb_list); | 641 | kfree(new_skb_list); |
655 | free_new_lists: | 642 | free_new_lists: |
656 | kfree(new_dma_addr_list); | 643 | kfree(new_dma_addr_list); |
657 | free_new_rx_ring: | 644 | free_new_rx_ring: |
658 | pci_free_consistent(lp->pci_dev, | 645 | pci_free_consistent(lp->pci_dev, |
659 | sizeof(struct pcnet32_rx_head) * | 646 | sizeof(struct pcnet32_rx_head) * |
660 | (1 << size), | 647 | (1 << size), |
@@ -837,16 +824,14 @@ static int pcnet32_set_ringparam(struct net_device *dev, | |||
837 | 824 | ||
838 | spin_unlock_irqrestore(&lp->lock, flags); | 825 | spin_unlock_irqrestore(&lp->lock, flags); |
839 | 826 | ||
840 | if (netif_msg_drv(lp)) | 827 | netif_info(lp, drv, dev, "Ring Param Settings: RX: %d, TX: %d\n", |
841 | printk(KERN_INFO | 828 | lp->rx_ring_size, lp->tx_ring_size); |
842 | "%s: Ring Param Settings: RX: %d, TX: %d\n", dev->name, | ||
843 | lp->rx_ring_size, lp->tx_ring_size); | ||
844 | 829 | ||
845 | return 0; | 830 | return 0; |
846 | } | 831 | } |
847 | 832 | ||
848 | static void pcnet32_get_strings(struct net_device *dev, u32 stringset, | 833 | static void pcnet32_get_strings(struct net_device *dev, u32 stringset, |
849 | u8 * data) | 834 | u8 *data) |
850 | { | 835 | { |
851 | memcpy(data, pcnet32_gstrings_test, sizeof(pcnet32_gstrings_test)); | 836 | memcpy(data, pcnet32_gstrings_test, sizeof(pcnet32_gstrings_test)); |
852 | } | 837 | } |
@@ -870,17 +855,15 @@ static void pcnet32_ethtool_test(struct net_device *dev, | |||
870 | if (test->flags == ETH_TEST_FL_OFFLINE) { | 855 | if (test->flags == ETH_TEST_FL_OFFLINE) { |
871 | rc = pcnet32_loopback_test(dev, data); | 856 | rc = pcnet32_loopback_test(dev, data); |
872 | if (rc) { | 857 | if (rc) { |
873 | if (netif_msg_hw(lp)) | 858 | netif_printk(lp, hw, KERN_DEBUG, dev, |
874 | printk(KERN_DEBUG "%s: Loopback test failed.\n", | 859 | "Loopback test failed\n"); |
875 | dev->name); | ||
876 | test->flags |= ETH_TEST_FL_FAILED; | 860 | test->flags |= ETH_TEST_FL_FAILED; |
877 | } else if (netif_msg_hw(lp)) | 861 | } else |
878 | printk(KERN_DEBUG "%s: Loopback test passed.\n", | 862 | netif_printk(lp, hw, KERN_DEBUG, dev, |
879 | dev->name); | 863 | "Loopback test passed\n"); |
880 | } else if (netif_msg_hw(lp)) | 864 | } else |
881 | printk(KERN_DEBUG | 865 | netif_printk(lp, hw, KERN_DEBUG, dev, |
882 | "%s: No tests to run (specify 'Offline' on ethtool).", | 866 | "No tests to run (specify 'Offline' on ethtool)\n"); |
883 | dev->name); | ||
884 | } /* end pcnet32_ethtool_test */ | 867 | } /* end pcnet32_ethtool_test */ |
885 | 868 | ||
886 | static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1) | 869 | static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1) |
@@ -925,40 +908,39 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1) | |||
925 | /* Initialize Transmit buffers. */ | 908 | /* Initialize Transmit buffers. */ |
926 | size = data_len + 15; | 909 | size = data_len + 15; |
927 | for (x = 0; x < numbuffs; x++) { | 910 | for (x = 0; x < numbuffs; x++) { |
928 | if (!(skb = dev_alloc_skb(size))) { | 911 | skb = dev_alloc_skb(size); |
929 | if (netif_msg_hw(lp)) | 912 | if (!skb) { |
930 | printk(KERN_DEBUG | 913 | netif_printk(lp, hw, KERN_DEBUG, dev, |
931 | "%s: Cannot allocate skb at line: %d!\n", | 914 | "Cannot allocate skb at line: %d!\n", |
932 | dev->name, __LINE__); | 915 | __LINE__); |
933 | goto clean_up; | 916 | goto clean_up; |
934 | } else { | ||
935 | packet = skb->data; | ||
936 | skb_put(skb, size); /* create space for data */ | ||
937 | lp->tx_skbuff[x] = skb; | ||
938 | lp->tx_ring[x].length = cpu_to_le16(-skb->len); | ||
939 | lp->tx_ring[x].misc = 0; | ||
940 | |||
941 | /* put DA and SA into the skb */ | ||
942 | for (i = 0; i < 6; i++) | ||
943 | *packet++ = dev->dev_addr[i]; | ||
944 | for (i = 0; i < 6; i++) | ||
945 | *packet++ = dev->dev_addr[i]; | ||
946 | /* type */ | ||
947 | *packet++ = 0x08; | ||
948 | *packet++ = 0x06; | ||
949 | /* packet number */ | ||
950 | *packet++ = x; | ||
951 | /* fill packet with data */ | ||
952 | for (i = 0; i < data_len; i++) | ||
953 | *packet++ = i; | ||
954 | |||
955 | lp->tx_dma_addr[x] = | ||
956 | pci_map_single(lp->pci_dev, skb->data, skb->len, | ||
957 | PCI_DMA_TODEVICE); | ||
958 | lp->tx_ring[x].base = cpu_to_le32(lp->tx_dma_addr[x]); | ||
959 | wmb(); /* Make sure owner changes after all others are visible */ | ||
960 | lp->tx_ring[x].status = cpu_to_le16(status); | ||
961 | } | 917 | } |
918 | packet = skb->data; | ||
919 | skb_put(skb, size); /* create space for data */ | ||
920 | lp->tx_skbuff[x] = skb; | ||
921 | lp->tx_ring[x].length = cpu_to_le16(-skb->len); | ||
922 | lp->tx_ring[x].misc = 0; | ||
923 | |||
924 | /* put DA and SA into the skb */ | ||
925 | for (i = 0; i < 6; i++) | ||
926 | *packet++ = dev->dev_addr[i]; | ||
927 | for (i = 0; i < 6; i++) | ||
928 | *packet++ = dev->dev_addr[i]; | ||
929 | /* type */ | ||
930 | *packet++ = 0x08; | ||
931 | *packet++ = 0x06; | ||
932 | /* packet number */ | ||
933 | *packet++ = x; | ||
934 | /* fill packet with data */ | ||
935 | for (i = 0; i < data_len; i++) | ||
936 | *packet++ = i; | ||
937 | |||
938 | lp->tx_dma_addr[x] = | ||
939 | pci_map_single(lp->pci_dev, skb->data, skb->len, | ||
940 | PCI_DMA_TODEVICE); | ||
941 | lp->tx_ring[x].base = cpu_to_le32(lp->tx_dma_addr[x]); | ||
942 | wmb(); /* Make sure owner changes after all others are visible */ | ||
943 | lp->tx_ring[x].status = cpu_to_le16(status); | ||
962 | } | 944 | } |
963 | 945 | ||
964 | x = a->read_bcr(ioaddr, 32); /* set internal loopback in BCR32 */ | 946 | x = a->read_bcr(ioaddr, 32); /* set internal loopback in BCR32 */ |
@@ -983,9 +965,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1) | |||
983 | ticks++; | 965 | ticks++; |
984 | } | 966 | } |
985 | if (ticks == 200) { | 967 | if (ticks == 200) { |
986 | if (netif_msg_hw(lp)) | 968 | netif_err(lp, hw, dev, "Desc %d failed to reset!\n", x); |
987 | printk("%s: Desc %d failed to reset!\n", | ||
988 | dev->name, x); | ||
989 | break; | 969 | break; |
990 | } | 970 | } |
991 | } | 971 | } |
@@ -993,15 +973,14 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1) | |||
993 | lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); /* Set STOP bit */ | 973 | lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); /* Set STOP bit */ |
994 | wmb(); | 974 | wmb(); |
995 | if (netif_msg_hw(lp) && netif_msg_pktdata(lp)) { | 975 | if (netif_msg_hw(lp) && netif_msg_pktdata(lp)) { |
996 | printk(KERN_DEBUG "%s: RX loopback packets:\n", dev->name); | 976 | netdev_printk(KERN_DEBUG, dev, "RX loopback packets:\n"); |
997 | 977 | ||
998 | for (x = 0; x < numbuffs; x++) { | 978 | for (x = 0; x < numbuffs; x++) { |
999 | printk(KERN_DEBUG "%s: Packet %d:\n", dev->name, x); | 979 | netdev_printk(KERN_DEBUG, dev, "Packet %d: ", x); |
1000 | skb = lp->rx_skbuff[x]; | 980 | skb = lp->rx_skbuff[x]; |
1001 | for (i = 0; i < size; i++) { | 981 | for (i = 0; i < size; i++) |
1002 | printk("%02x ", *(skb->data + i)); | 982 | pr_cont(" %02x", *(skb->data + i)); |
1003 | } | 983 | pr_cont("\n"); |
1004 | printk("\n"); | ||
1005 | } | 984 | } |
1006 | } | 985 | } |
1007 | 986 | ||
@@ -1012,11 +991,9 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1) | |||
1012 | packet = lp->tx_skbuff[x]->data; | 991 | packet = lp->tx_skbuff[x]->data; |
1013 | for (i = 0; i < size; i++) { | 992 | for (i = 0; i < size; i++) { |
1014 | if (*(skb->data + i) != packet[i]) { | 993 | if (*(skb->data + i) != packet[i]) { |
1015 | if (netif_msg_hw(lp)) | 994 | netif_printk(lp, hw, KERN_DEBUG, dev, |
1016 | printk(KERN_DEBUG | 995 | "Error in compare! %2x - %02x %02x\n", |
1017 | "%s: Error in compare! %2x - %02x %02x\n", | 996 | i, *(skb->data + i), packet[i]); |
1018 | dev->name, i, *(skb->data + i), | ||
1019 | packet[i]); | ||
1020 | rc = 1; | 997 | rc = 1; |
1021 | break; | 998 | break; |
1022 | } | 999 | } |
@@ -1024,7 +1001,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1) | |||
1024 | x++; | 1001 | x++; |
1025 | } | 1002 | } |
1026 | 1003 | ||
1027 | clean_up: | 1004 | clean_up: |
1028 | *data1 = rc; | 1005 | *data1 = rc; |
1029 | pcnet32_purge_tx_ring(dev); | 1006 | pcnet32_purge_tx_ring(dev); |
1030 | 1007 | ||
@@ -1043,7 +1020,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1) | |||
1043 | } | 1020 | } |
1044 | spin_unlock_irqrestore(&lp->lock, flags); | 1021 | spin_unlock_irqrestore(&lp->lock, flags); |
1045 | 1022 | ||
1046 | return (rc); | 1023 | return rc; |
1047 | } /* end pcnet32_loopback_test */ | 1024 | } /* end pcnet32_loopback_test */ |
1048 | 1025 | ||
1049 | static void pcnet32_led_blink_callback(struct net_device *dev) | 1026 | static void pcnet32_led_blink_callback(struct net_device *dev) |
@@ -1055,9 +1032,8 @@ static void pcnet32_led_blink_callback(struct net_device *dev) | |||
1055 | int i; | 1032 | int i; |
1056 | 1033 | ||
1057 | spin_lock_irqsave(&lp->lock, flags); | 1034 | spin_lock_irqsave(&lp->lock, flags); |
1058 | for (i = 4; i < 8; i++) { | 1035 | for (i = 4; i < 8; i++) |
1059 | a->write_bcr(ioaddr, i, a->read_bcr(ioaddr, i) ^ 0x4000); | 1036 | a->write_bcr(ioaddr, i, a->read_bcr(ioaddr, i) ^ 0x4000); |
1060 | } | ||
1061 | spin_unlock_irqrestore(&lp->lock, flags); | 1037 | spin_unlock_irqrestore(&lp->lock, flags); |
1062 | 1038 | ||
1063 | mod_timer(&lp->blink_timer, PCNET32_BLINK_TIMEOUT); | 1039 | mod_timer(&lp->blink_timer, PCNET32_BLINK_TIMEOUT); |
@@ -1079,9 +1055,8 @@ static int pcnet32_phys_id(struct net_device *dev, u32 data) | |||
1079 | 1055 | ||
1080 | /* Save the current value of the bcrs */ | 1056 | /* Save the current value of the bcrs */ |
1081 | spin_lock_irqsave(&lp->lock, flags); | 1057 | spin_lock_irqsave(&lp->lock, flags); |
1082 | for (i = 4; i < 8; i++) { | 1058 | for (i = 4; i < 8; i++) |
1083 | regs[i - 4] = a->read_bcr(ioaddr, i); | 1059 | regs[i - 4] = a->read_bcr(ioaddr, i); |
1084 | } | ||
1085 | spin_unlock_irqrestore(&lp->lock, flags); | 1060 | spin_unlock_irqrestore(&lp->lock, flags); |
1086 | 1061 | ||
1087 | mod_timer(&lp->blink_timer, jiffies); | 1062 | mod_timer(&lp->blink_timer, jiffies); |
@@ -1096,9 +1071,8 @@ static int pcnet32_phys_id(struct net_device *dev, u32 data) | |||
1096 | 1071 | ||
1097 | /* Restore the original value of the bcrs */ | 1072 | /* Restore the original value of the bcrs */ |
1098 | spin_lock_irqsave(&lp->lock, flags); | 1073 | spin_lock_irqsave(&lp->lock, flags); |
1099 | for (i = 4; i < 8; i++) { | 1074 | for (i = 4; i < 8; i++) |
1100 | a->write_bcr(ioaddr, i, regs[i - 4]); | 1075 | a->write_bcr(ioaddr, i, regs[i - 4]); |
1101 | } | ||
1102 | spin_unlock_irqrestore(&lp->lock, flags); | 1076 | spin_unlock_irqrestore(&lp->lock, flags); |
1103 | 1077 | ||
1104 | return 0; | 1078 | return 0; |
@@ -1135,10 +1109,8 @@ static int pcnet32_suspend(struct net_device *dev, unsigned long *flags, | |||
1135 | spin_lock_irqsave(&lp->lock, *flags); | 1109 | spin_lock_irqsave(&lp->lock, *flags); |
1136 | ticks++; | 1110 | ticks++; |
1137 | if (ticks > 200) { | 1111 | if (ticks > 200) { |
1138 | if (netif_msg_hw(lp)) | 1112 | netif_printk(lp, hw, KERN_DEBUG, dev, |
1139 | printk(KERN_DEBUG | 1113 | "Error getting into suspend!\n"); |
1140 | "%s: Error getting into suspend!\n", | ||
1141 | dev->name); | ||
1142 | return 0; | 1114 | return 0; |
1143 | } | 1115 | } |
1144 | } | 1116 | } |
@@ -1183,15 +1155,13 @@ static void pcnet32_rx_entry(struct net_device *dev, | |||
1183 | 1155 | ||
1184 | /* Discard oversize frames. */ | 1156 | /* Discard oversize frames. */ |
1185 | if (unlikely(pkt_len > PKT_BUF_SIZE)) { | 1157 | if (unlikely(pkt_len > PKT_BUF_SIZE)) { |
1186 | if (netif_msg_drv(lp)) | 1158 | netif_err(lp, drv, dev, "Impossible packet size %d!\n", |
1187 | printk(KERN_ERR "%s: Impossible packet size %d!\n", | 1159 | pkt_len); |
1188 | dev->name, pkt_len); | ||
1189 | dev->stats.rx_errors++; | 1160 | dev->stats.rx_errors++; |
1190 | return; | 1161 | return; |
1191 | } | 1162 | } |
1192 | if (pkt_len < 60) { | 1163 | if (pkt_len < 60) { |
1193 | if (netif_msg_rx_err(lp)) | 1164 | netif_err(lp, rx_err, dev, "Runt packet!\n"); |
1194 | printk(KERN_ERR "%s: Runt packet!\n", dev->name); | ||
1195 | dev->stats.rx_errors++; | 1165 | dev->stats.rx_errors++; |
1196 | return; | 1166 | return; |
1197 | } | 1167 | } |
@@ -1199,7 +1169,8 @@ static void pcnet32_rx_entry(struct net_device *dev, | |||
1199 | if (pkt_len > rx_copybreak) { | 1169 | if (pkt_len > rx_copybreak) { |
1200 | struct sk_buff *newskb; | 1170 | struct sk_buff *newskb; |
1201 | 1171 | ||
1202 | if ((newskb = dev_alloc_skb(PKT_BUF_SKB))) { | 1172 | newskb = dev_alloc_skb(PKT_BUF_SKB); |
1173 | if (newskb) { | ||
1203 | skb_reserve(newskb, NET_IP_ALIGN); | 1174 | skb_reserve(newskb, NET_IP_ALIGN); |
1204 | skb = lp->rx_skbuff[entry]; | 1175 | skb = lp->rx_skbuff[entry]; |
1205 | pci_unmap_single(lp->pci_dev, | 1176 | pci_unmap_single(lp->pci_dev, |
@@ -1217,15 +1188,11 @@ static void pcnet32_rx_entry(struct net_device *dev, | |||
1217 | rx_in_place = 1; | 1188 | rx_in_place = 1; |
1218 | } else | 1189 | } else |
1219 | skb = NULL; | 1190 | skb = NULL; |
1220 | } else { | 1191 | } else |
1221 | skb = dev_alloc_skb(pkt_len + NET_IP_ALIGN); | 1192 | skb = dev_alloc_skb(pkt_len + NET_IP_ALIGN); |
1222 | } | ||
1223 | 1193 | ||
1224 | if (skb == NULL) { | 1194 | if (skb == NULL) { |
1225 | if (netif_msg_drv(lp)) | 1195 | netif_err(lp, drv, dev, "Memory squeeze, dropping packet\n"); |
1226 | printk(KERN_ERR | ||
1227 | "%s: Memory squeeze, dropping packet.\n", | ||
1228 | dev->name); | ||
1229 | dev->stats.rx_dropped++; | 1196 | dev->stats.rx_dropped++; |
1230 | return; | 1197 | return; |
1231 | } | 1198 | } |
@@ -1296,11 +1263,9 @@ static int pcnet32_tx(struct net_device *dev) | |||
1296 | /* There was a major error, log it. */ | 1263 | /* There was a major error, log it. */ |
1297 | int err_status = le32_to_cpu(lp->tx_ring[entry].misc); | 1264 | int err_status = le32_to_cpu(lp->tx_ring[entry].misc); |
1298 | dev->stats.tx_errors++; | 1265 | dev->stats.tx_errors++; |
1299 | if (netif_msg_tx_err(lp)) | 1266 | netif_err(lp, tx_err, dev, |
1300 | printk(KERN_ERR | 1267 | "Tx error status=%04x err_status=%08x\n", |
1301 | "%s: Tx error status=%04x err_status=%08x\n", | 1268 | status, err_status); |
1302 | dev->name, status, | ||
1303 | err_status); | ||
1304 | if (err_status & 0x04000000) | 1269 | if (err_status & 0x04000000) |
1305 | dev->stats.tx_aborted_errors++; | 1270 | dev->stats.tx_aborted_errors++; |
1306 | if (err_status & 0x08000000) | 1271 | if (err_status & 0x08000000) |
@@ -1312,10 +1277,7 @@ static int pcnet32_tx(struct net_device *dev) | |||
1312 | dev->stats.tx_fifo_errors++; | 1277 | dev->stats.tx_fifo_errors++; |
1313 | /* Ackk! On FIFO errors the Tx unit is turned off! */ | 1278 | /* Ackk! On FIFO errors the Tx unit is turned off! */ |
1314 | /* Remove this verbosity later! */ | 1279 | /* Remove this verbosity later! */ |
1315 | if (netif_msg_tx_err(lp)) | 1280 | netif_err(lp, tx_err, dev, "Tx FIFO error!\n"); |
1316 | printk(KERN_ERR | ||
1317 | "%s: Tx FIFO error!\n", | ||
1318 | dev->name); | ||
1319 | must_restart = 1; | 1281 | must_restart = 1; |
1320 | } | 1282 | } |
1321 | #else | 1283 | #else |
@@ -1324,10 +1286,7 @@ static int pcnet32_tx(struct net_device *dev) | |||
1324 | if (!lp->dxsuflo) { /* If controller doesn't recover ... */ | 1286 | if (!lp->dxsuflo) { /* If controller doesn't recover ... */ |
1325 | /* Ackk! On FIFO errors the Tx unit is turned off! */ | 1287 | /* Ackk! On FIFO errors the Tx unit is turned off! */ |
1326 | /* Remove this verbosity later! */ | 1288 | /* Remove this verbosity later! */ |
1327 | if (netif_msg_tx_err(lp)) | 1289 | netif_err(lp, tx_err, dev, "Tx FIFO error!\n"); |
1328 | printk(KERN_ERR | ||
1329 | "%s: Tx FIFO error!\n", | ||
1330 | dev->name); | ||
1331 | must_restart = 1; | 1290 | must_restart = 1; |
1332 | } | 1291 | } |
1333 | } | 1292 | } |
@@ -1353,11 +1312,8 @@ static int pcnet32_tx(struct net_device *dev) | |||
1353 | 1312 | ||
1354 | delta = (lp->cur_tx - dirty_tx) & (lp->tx_mod_mask + lp->tx_ring_size); | 1313 | delta = (lp->cur_tx - dirty_tx) & (lp->tx_mod_mask + lp->tx_ring_size); |
1355 | if (delta > lp->tx_ring_size) { | 1314 | if (delta > lp->tx_ring_size) { |
1356 | if (netif_msg_drv(lp)) | 1315 | netif_err(lp, drv, dev, "out-of-sync dirty pointer, %d vs. %d, full=%d\n", |
1357 | printk(KERN_ERR | 1316 | dirty_tx, lp->cur_tx, lp->tx_full); |
1358 | "%s: out-of-sync dirty pointer, %d vs. %d, full=%d.\n", | ||
1359 | dev->name, dirty_tx, lp->cur_tx, | ||
1360 | lp->tx_full); | ||
1361 | dirty_tx += lp->tx_ring_size; | 1317 | dirty_tx += lp->tx_ring_size; |
1362 | delta -= lp->tx_ring_size; | 1318 | delta -= lp->tx_ring_size; |
1363 | } | 1319 | } |
@@ -1420,7 +1376,7 @@ static int pcnet32_get_regs_len(struct net_device *dev) | |||
1420 | struct pcnet32_private *lp = netdev_priv(dev); | 1376 | struct pcnet32_private *lp = netdev_priv(dev); |
1421 | int j = lp->phycount * PCNET32_REGS_PER_PHY; | 1377 | int j = lp->phycount * PCNET32_REGS_PER_PHY; |
1422 | 1378 | ||
1423 | return ((PCNET32_NUM_REGS + j) * sizeof(u16)); | 1379 | return (PCNET32_NUM_REGS + j) * sizeof(u16); |
1424 | } | 1380 | } |
1425 | 1381 | ||
1426 | static void pcnet32_get_regs(struct net_device *dev, struct ethtool_regs *regs, | 1382 | static void pcnet32_get_regs(struct net_device *dev, struct ethtool_regs *regs, |
@@ -1444,21 +1400,20 @@ static void pcnet32_get_regs(struct net_device *dev, struct ethtool_regs *regs, | |||
1444 | *buff++ = inw(ioaddr + i); | 1400 | *buff++ = inw(ioaddr + i); |
1445 | 1401 | ||
1446 | /* read control and status registers */ | 1402 | /* read control and status registers */ |
1447 | for (i = 0; i < 90; i++) { | 1403 | for (i = 0; i < 90; i++) |
1448 | *buff++ = a->read_csr(ioaddr, i); | 1404 | *buff++ = a->read_csr(ioaddr, i); |
1449 | } | ||
1450 | 1405 | ||
1451 | *buff++ = a->read_csr(ioaddr, 112); | 1406 | *buff++ = a->read_csr(ioaddr, 112); |
1452 | *buff++ = a->read_csr(ioaddr, 114); | 1407 | *buff++ = a->read_csr(ioaddr, 114); |
1453 | 1408 | ||
1454 | /* read bus configuration registers */ | 1409 | /* read bus configuration registers */ |
1455 | for (i = 0; i < 30; i++) { | 1410 | for (i = 0; i < 30; i++) |
1456 | *buff++ = a->read_bcr(ioaddr, i); | 1411 | *buff++ = a->read_bcr(ioaddr, i); |
1457 | } | 1412 | |
1458 | *buff++ = 0; /* skip bcr30 so as not to hang 79C976 */ | 1413 | *buff++ = 0; /* skip bcr30 so as not to hang 79C976 */ |
1459 | for (i = 31; i < 36; i++) { | 1414 | |
1415 | for (i = 31; i < 36; i++) | ||
1460 | *buff++ = a->read_bcr(ioaddr, i); | 1416 | *buff++ = a->read_bcr(ioaddr, i); |
1461 | } | ||
1462 | 1417 | ||
1463 | /* read mii phy registers */ | 1418 | /* read mii phy registers */ |
1464 | if (lp->mii) { | 1419 | if (lp->mii) { |
@@ -1515,8 +1470,8 @@ static void __devinit pcnet32_probe_vlbus(unsigned int *pcnet32_portlist) | |||
1515 | if (request_region | 1470 | if (request_region |
1516 | (ioaddr, PCNET32_TOTAL_SIZE, "pcnet32_probe_vlbus")) { | 1471 | (ioaddr, PCNET32_TOTAL_SIZE, "pcnet32_probe_vlbus")) { |
1517 | /* check if there is really a pcnet chip on that ioaddr */ | 1472 | /* check if there is really a pcnet chip on that ioaddr */ |
1518 | if ((inb(ioaddr + 14) == 0x57) | 1473 | if ((inb(ioaddr + 14) == 0x57) && |
1519 | && (inb(ioaddr + 15) == 0x57)) { | 1474 | (inb(ioaddr + 15) == 0x57)) { |
1520 | pcnet32_probe1(ioaddr, 0, NULL); | 1475 | pcnet32_probe1(ioaddr, 0, NULL); |
1521 | } else { | 1476 | } else { |
1522 | release_region(ioaddr, PCNET32_TOTAL_SIZE); | 1477 | release_region(ioaddr, PCNET32_TOTAL_SIZE); |
@@ -1534,8 +1489,7 @@ pcnet32_probe_pci(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1534 | err = pci_enable_device(pdev); | 1489 | err = pci_enable_device(pdev); |
1535 | if (err < 0) { | 1490 | if (err < 0) { |
1536 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1491 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1537 | printk(KERN_ERR PFX | 1492 | pr_err("failed to enable device -- err=%d\n", err); |
1538 | "failed to enable device -- err=%d\n", err); | ||
1539 | return err; | 1493 | return err; |
1540 | } | 1494 | } |
1541 | pci_set_master(pdev); | 1495 | pci_set_master(pdev); |
@@ -1543,29 +1497,25 @@ pcnet32_probe_pci(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1543 | ioaddr = pci_resource_start(pdev, 0); | 1497 | ioaddr = pci_resource_start(pdev, 0); |
1544 | if (!ioaddr) { | 1498 | if (!ioaddr) { |
1545 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1499 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1546 | printk(KERN_ERR PFX | 1500 | pr_err("card has no PCI IO resources, aborting\n"); |
1547 | "card has no PCI IO resources, aborting\n"); | ||
1548 | return -ENODEV; | 1501 | return -ENODEV; |
1549 | } | 1502 | } |
1550 | 1503 | ||
1551 | if (!pci_dma_supported(pdev, PCNET32_DMA_MASK)) { | 1504 | if (!pci_dma_supported(pdev, PCNET32_DMA_MASK)) { |
1552 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1505 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1553 | printk(KERN_ERR PFX | 1506 | pr_err("architecture does not support 32bit PCI busmaster DMA\n"); |
1554 | "architecture does not support 32bit PCI busmaster DMA\n"); | ||
1555 | return -ENODEV; | 1507 | return -ENODEV; |
1556 | } | 1508 | } |
1557 | if (request_region(ioaddr, PCNET32_TOTAL_SIZE, "pcnet32_probe_pci") == | 1509 | if (!request_region(ioaddr, PCNET32_TOTAL_SIZE, "pcnet32_probe_pci")) { |
1558 | NULL) { | ||
1559 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1510 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1560 | printk(KERN_ERR PFX | 1511 | pr_err("io address range already allocated\n"); |
1561 | "io address range already allocated\n"); | ||
1562 | return -EBUSY; | 1512 | return -EBUSY; |
1563 | } | 1513 | } |
1564 | 1514 | ||
1565 | err = pcnet32_probe1(ioaddr, 1, pdev); | 1515 | err = pcnet32_probe1(ioaddr, 1, pdev); |
1566 | if (err < 0) { | 1516 | if (err < 0) |
1567 | pci_disable_device(pdev); | 1517 | pci_disable_device(pdev); |
1568 | } | 1518 | |
1569 | return err; | 1519 | return err; |
1570 | } | 1520 | } |
1571 | 1521 | ||
@@ -1610,12 +1560,12 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1610 | a = &pcnet32_wio; | 1560 | a = &pcnet32_wio; |
1611 | } else { | 1561 | } else { |
1612 | pcnet32_dwio_reset(ioaddr); | 1562 | pcnet32_dwio_reset(ioaddr); |
1613 | if (pcnet32_dwio_read_csr(ioaddr, 0) == 4 | 1563 | if (pcnet32_dwio_read_csr(ioaddr, 0) == 4 && |
1614 | && pcnet32_dwio_check(ioaddr)) { | 1564 | pcnet32_dwio_check(ioaddr)) { |
1615 | a = &pcnet32_dwio; | 1565 | a = &pcnet32_dwio; |
1616 | } else { | 1566 | } else { |
1617 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1567 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1618 | printk(KERN_ERR PFX "No access methods\n"); | 1568 | pr_err("No access methods\n"); |
1619 | goto err_release_region; | 1569 | goto err_release_region; |
1620 | } | 1570 | } |
1621 | } | 1571 | } |
@@ -1623,11 +1573,10 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1623 | chip_version = | 1573 | chip_version = |
1624 | a->read_csr(ioaddr, 88) | (a->read_csr(ioaddr, 89) << 16); | 1574 | a->read_csr(ioaddr, 88) | (a->read_csr(ioaddr, 89) << 16); |
1625 | if ((pcnet32_debug & NETIF_MSG_PROBE) && (pcnet32_debug & NETIF_MSG_HW)) | 1575 | if ((pcnet32_debug & NETIF_MSG_PROBE) && (pcnet32_debug & NETIF_MSG_HW)) |
1626 | printk(KERN_INFO " PCnet chip version is %#x.\n", | 1576 | pr_info(" PCnet chip version is %#x\n", chip_version); |
1627 | chip_version); | ||
1628 | if ((chip_version & 0xfff) != 0x003) { | 1577 | if ((chip_version & 0xfff) != 0x003) { |
1629 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1578 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1630 | printk(KERN_INFO PFX "Unsupported chip version.\n"); | 1579 | pr_info("Unsupported chip version\n"); |
1631 | goto err_release_region; | 1580 | goto err_release_region; |
1632 | } | 1581 | } |
1633 | 1582 | ||
@@ -1680,7 +1629,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1680 | if (cards_found < MAX_UNITS && homepna[cards_found]) | 1629 | if (cards_found < MAX_UNITS && homepna[cards_found]) |
1681 | media |= 1; /* switch to home wiring mode */ | 1630 | media |= 1; /* switch to home wiring mode */ |
1682 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1631 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1683 | printk(KERN_DEBUG PFX "media set to %sMbit mode.\n", | 1632 | printk(KERN_DEBUG PFX "media set to %sMbit mode\n", |
1684 | (media & 1) ? "1" : "10"); | 1633 | (media & 1) ? "1" : "10"); |
1685 | a->write_bcr(ioaddr, 49, media); | 1634 | a->write_bcr(ioaddr, 49, media); |
1686 | break; | 1635 | break; |
@@ -1696,9 +1645,8 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1696 | break; | 1645 | break; |
1697 | default: | 1646 | default: |
1698 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1647 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1699 | printk(KERN_INFO PFX | 1648 | pr_info("PCnet version %#x, no PCnet32 chip\n", |
1700 | "PCnet version %#x, no PCnet32 chip.\n", | 1649 | chip_version); |
1701 | chip_version); | ||
1702 | goto err_release_region; | 1650 | goto err_release_region; |
1703 | } | 1651 | } |
1704 | 1652 | ||
@@ -1720,7 +1668,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1720 | dev = alloc_etherdev(sizeof(*lp)); | 1668 | dev = alloc_etherdev(sizeof(*lp)); |
1721 | if (!dev) { | 1669 | if (!dev) { |
1722 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1670 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1723 | printk(KERN_ERR PFX "Memory allocation failed.\n"); | 1671 | pr_err("Memory allocation failed\n"); |
1724 | ret = -ENOMEM; | 1672 | ret = -ENOMEM; |
1725 | goto err_release_region; | 1673 | goto err_release_region; |
1726 | } | 1674 | } |
@@ -1729,7 +1677,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1729 | SET_NETDEV_DEV(dev, &pdev->dev); | 1677 | SET_NETDEV_DEV(dev, &pdev->dev); |
1730 | 1678 | ||
1731 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1679 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1732 | printk(KERN_INFO PFX "%s at %#3lx,", chipname, ioaddr); | 1680 | pr_info("%s at %#3lx,", chipname, ioaddr); |
1733 | 1681 | ||
1734 | /* In most chips, after a chip reset, the ethernet address is read from the | 1682 | /* In most chips, after a chip reset, the ethernet address is read from the |
1735 | * station address PROM at the base address and programmed into the | 1683 | * station address PROM at the base address and programmed into the |
@@ -1750,13 +1698,12 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1750 | for (i = 0; i < 6; i++) | 1698 | for (i = 0; i < 6; i++) |
1751 | promaddr[i] = inb(ioaddr + i); | 1699 | promaddr[i] = inb(ioaddr + i); |
1752 | 1700 | ||
1753 | if (memcmp(promaddr, dev->dev_addr, 6) | 1701 | if (memcmp(promaddr, dev->dev_addr, 6) || |
1754 | || !is_valid_ether_addr(dev->dev_addr)) { | 1702 | !is_valid_ether_addr(dev->dev_addr)) { |
1755 | if (is_valid_ether_addr(promaddr)) { | 1703 | if (is_valid_ether_addr(promaddr)) { |
1756 | if (pcnet32_debug & NETIF_MSG_PROBE) { | 1704 | if (pcnet32_debug & NETIF_MSG_PROBE) { |
1757 | printk(" warning: CSR address invalid,\n"); | 1705 | pr_cont(" warning: CSR address invalid,\n"); |
1758 | printk(KERN_INFO | 1706 | pr_info(" using instead PROM address of"); |
1759 | " using instead PROM address of"); | ||
1760 | } | 1707 | } |
1761 | memcpy(dev->dev_addr, promaddr, 6); | 1708 | memcpy(dev->dev_addr, promaddr, 6); |
1762 | } | 1709 | } |
@@ -1765,57 +1712,57 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1765 | 1712 | ||
1766 | /* if the ethernet address is not valid, force to 00:00:00:00:00:00 */ | 1713 | /* if the ethernet address is not valid, force to 00:00:00:00:00:00 */ |
1767 | if (!is_valid_ether_addr(dev->perm_addr)) | 1714 | if (!is_valid_ether_addr(dev->perm_addr)) |
1768 | memset(dev->dev_addr, 0, sizeof(dev->dev_addr)); | 1715 | memset(dev->dev_addr, 0, ETH_ALEN); |
1769 | 1716 | ||
1770 | if (pcnet32_debug & NETIF_MSG_PROBE) { | 1717 | if (pcnet32_debug & NETIF_MSG_PROBE) { |
1771 | printk(" %pM", dev->dev_addr); | 1718 | pr_cont(" %pM", dev->dev_addr); |
1772 | 1719 | ||
1773 | /* Version 0x2623 and 0x2624 */ | 1720 | /* Version 0x2623 and 0x2624 */ |
1774 | if (((chip_version + 1) & 0xfffe) == 0x2624) { | 1721 | if (((chip_version + 1) & 0xfffe) == 0x2624) { |
1775 | i = a->read_csr(ioaddr, 80) & 0x0C00; /* Check tx_start_pt */ | 1722 | i = a->read_csr(ioaddr, 80) & 0x0C00; /* Check tx_start_pt */ |
1776 | printk(KERN_INFO " tx_start_pt(0x%04x):", i); | 1723 | pr_info(" tx_start_pt(0x%04x):", i); |
1777 | switch (i >> 10) { | 1724 | switch (i >> 10) { |
1778 | case 0: | 1725 | case 0: |
1779 | printk(KERN_CONT " 20 bytes,"); | 1726 | pr_cont(" 20 bytes,"); |
1780 | break; | 1727 | break; |
1781 | case 1: | 1728 | case 1: |
1782 | printk(KERN_CONT " 64 bytes,"); | 1729 | pr_cont(" 64 bytes,"); |
1783 | break; | 1730 | break; |
1784 | case 2: | 1731 | case 2: |
1785 | printk(KERN_CONT " 128 bytes,"); | 1732 | pr_cont(" 128 bytes,"); |
1786 | break; | 1733 | break; |
1787 | case 3: | 1734 | case 3: |
1788 | printk(KERN_CONT "~220 bytes,"); | 1735 | pr_cont("~220 bytes,"); |
1789 | break; | 1736 | break; |
1790 | } | 1737 | } |
1791 | i = a->read_bcr(ioaddr, 18); /* Check Burst/Bus control */ | 1738 | i = a->read_bcr(ioaddr, 18); /* Check Burst/Bus control */ |
1792 | printk(KERN_CONT " BCR18(%x):", i & 0xffff); | 1739 | pr_cont(" BCR18(%x):", i & 0xffff); |
1793 | if (i & (1 << 5)) | 1740 | if (i & (1 << 5)) |
1794 | printk(KERN_CONT "BurstWrEn "); | 1741 | pr_cont("BurstWrEn "); |
1795 | if (i & (1 << 6)) | 1742 | if (i & (1 << 6)) |
1796 | printk(KERN_CONT "BurstRdEn "); | 1743 | pr_cont("BurstRdEn "); |
1797 | if (i & (1 << 7)) | 1744 | if (i & (1 << 7)) |
1798 | printk(KERN_CONT "DWordIO "); | 1745 | pr_cont("DWordIO "); |
1799 | if (i & (1 << 11)) | 1746 | if (i & (1 << 11)) |
1800 | printk(KERN_CONT "NoUFlow "); | 1747 | pr_cont("NoUFlow "); |
1801 | i = a->read_bcr(ioaddr, 25); | 1748 | i = a->read_bcr(ioaddr, 25); |
1802 | printk(KERN_INFO " SRAMSIZE=0x%04x,", i << 8); | 1749 | pr_info(" SRAMSIZE=0x%04x,", i << 8); |
1803 | i = a->read_bcr(ioaddr, 26); | 1750 | i = a->read_bcr(ioaddr, 26); |
1804 | printk(KERN_CONT " SRAM_BND=0x%04x,", i << 8); | 1751 | pr_cont(" SRAM_BND=0x%04x,", i << 8); |
1805 | i = a->read_bcr(ioaddr, 27); | 1752 | i = a->read_bcr(ioaddr, 27); |
1806 | if (i & (1 << 14)) | 1753 | if (i & (1 << 14)) |
1807 | printk(KERN_CONT "LowLatRx"); | 1754 | pr_cont("LowLatRx"); |
1808 | } | 1755 | } |
1809 | } | 1756 | } |
1810 | 1757 | ||
1811 | dev->base_addr = ioaddr; | 1758 | dev->base_addr = ioaddr; |
1812 | lp = netdev_priv(dev); | 1759 | lp = netdev_priv(dev); |
1813 | /* pci_alloc_consistent returns page-aligned memory, so we do not have to check the alignment */ | 1760 | /* pci_alloc_consistent returns page-aligned memory, so we do not have to check the alignment */ |
1814 | if ((lp->init_block = | 1761 | lp->init_block = pci_alloc_consistent(pdev, sizeof(*lp->init_block), |
1815 | pci_alloc_consistent(pdev, sizeof(*lp->init_block), &lp->init_dma_addr)) == NULL) { | 1762 | &lp->init_dma_addr); |
1763 | if (!lp->init_block) { | ||
1816 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1764 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1817 | printk(KERN_ERR PFX | 1765 | pr_err("Consistent memory allocation failed\n"); |
1818 | "Consistent memory allocation failed.\n"); | ||
1819 | ret = -ENOMEM; | 1766 | ret = -ENOMEM; |
1820 | goto err_free_netdev; | 1767 | goto err_free_netdev; |
1821 | } | 1768 | } |
@@ -1840,8 +1787,8 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1840 | lp->mii = mii; | 1787 | lp->mii = mii; |
1841 | lp->chip_version = chip_version; | 1788 | lp->chip_version = chip_version; |
1842 | lp->msg_enable = pcnet32_debug; | 1789 | lp->msg_enable = pcnet32_debug; |
1843 | if ((cards_found >= MAX_UNITS) | 1790 | if ((cards_found >= MAX_UNITS) || |
1844 | || (options[cards_found] >= sizeof(options_mapping))) | 1791 | (options[cards_found] >= sizeof(options_mapping))) |
1845 | lp->options = PCNET32_PORT_ASEL; | 1792 | lp->options = PCNET32_PORT_ASEL; |
1846 | else | 1793 | else |
1847 | lp->options = options_mapping[options[cards_found]]; | 1794 | lp->options = options_mapping[options[cards_found]]; |
@@ -1866,8 +1813,8 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1866 | goto err_free_ring; | 1813 | goto err_free_ring; |
1867 | } | 1814 | } |
1868 | /* detect special T1/E1 WAN card by checking for MAC address */ | 1815 | /* detect special T1/E1 WAN card by checking for MAC address */ |
1869 | if (dev->dev_addr[0] == 0x00 && dev->dev_addr[1] == 0xe0 | 1816 | if (dev->dev_addr[0] == 0x00 && dev->dev_addr[1] == 0xe0 && |
1870 | && dev->dev_addr[2] == 0x75) | 1817 | dev->dev_addr[2] == 0x75) |
1871 | lp->options = PCNET32_PORT_FD | PCNET32_PORT_GPSI; | 1818 | lp->options = PCNET32_PORT_FD | PCNET32_PORT_GPSI; |
1872 | 1819 | ||
1873 | lp->init_block->mode = cpu_to_le16(0x0003); /* Disable Rx and Tx. */ | 1820 | lp->init_block->mode = cpu_to_le16(0x0003); /* Disable Rx and Tx. */ |
@@ -1889,7 +1836,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1889 | if (pdev) { /* use the IRQ provided by PCI */ | 1836 | if (pdev) { /* use the IRQ provided by PCI */ |
1890 | dev->irq = pdev->irq; | 1837 | dev->irq = pdev->irq; |
1891 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1838 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1892 | printk(" assigned IRQ %d.\n", dev->irq); | 1839 | pr_cont(" assigned IRQ %d\n", dev->irq); |
1893 | } else { | 1840 | } else { |
1894 | unsigned long irq_mask = probe_irq_on(); | 1841 | unsigned long irq_mask = probe_irq_on(); |
1895 | 1842 | ||
@@ -1905,12 +1852,12 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1905 | dev->irq = probe_irq_off(irq_mask); | 1852 | dev->irq = probe_irq_off(irq_mask); |
1906 | if (!dev->irq) { | 1853 | if (!dev->irq) { |
1907 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1854 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1908 | printk(", failed to detect IRQ line.\n"); | 1855 | pr_cont(", failed to detect IRQ line\n"); |
1909 | ret = -ENODEV; | 1856 | ret = -ENODEV; |
1910 | goto err_free_ring; | 1857 | goto err_free_ring; |
1911 | } | 1858 | } |
1912 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1859 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1913 | printk(", probed IRQ %d.\n", dev->irq); | 1860 | pr_cont(", probed IRQ %d\n", dev->irq); |
1914 | } | 1861 | } |
1915 | 1862 | ||
1916 | /* Set the mii phy_id so that we can query the link state */ | 1863 | /* Set the mii phy_id so that we can query the link state */ |
@@ -1934,14 +1881,12 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1934 | lp->phymask |= (1 << i); | 1881 | lp->phymask |= (1 << i); |
1935 | lp->mii_if.phy_id = i; | 1882 | lp->mii_if.phy_id = i; |
1936 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1883 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1937 | printk(KERN_INFO PFX | 1884 | pr_info("Found PHY %04x:%04x at address %d\n", |
1938 | "Found PHY %04x:%04x at address %d.\n", | 1885 | id1, id2, i); |
1939 | id1, id2, i); | ||
1940 | } | 1886 | } |
1941 | lp->a.write_bcr(ioaddr, 33, (lp->mii_if.phy_id) << 5); | 1887 | lp->a.write_bcr(ioaddr, 33, (lp->mii_if.phy_id) << 5); |
1942 | if (lp->phycount > 1) { | 1888 | if (lp->phycount > 1) |
1943 | lp->options |= PCNET32_PORT_MII; | 1889 | lp->options |= PCNET32_PORT_MII; |
1944 | } | ||
1945 | } | 1890 | } |
1946 | 1891 | ||
1947 | init_timer(&lp->watchdog_timer); | 1892 | init_timer(&lp->watchdog_timer); |
@@ -1965,7 +1910,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1965 | } | 1910 | } |
1966 | 1911 | ||
1967 | if (pcnet32_debug & NETIF_MSG_PROBE) | 1912 | if (pcnet32_debug & NETIF_MSG_PROBE) |
1968 | printk(KERN_INFO "%s: registered as %s\n", dev->name, lp->name); | 1913 | pr_info("%s: registered as %s\n", dev->name, lp->name); |
1969 | cards_found++; | 1914 | cards_found++; |
1970 | 1915 | ||
1971 | /* enable LED writes */ | 1916 | /* enable LED writes */ |
@@ -1994,10 +1939,7 @@ static int pcnet32_alloc_ring(struct net_device *dev, const char *name) | |||
1994 | lp->tx_ring_size, | 1939 | lp->tx_ring_size, |
1995 | &lp->tx_ring_dma_addr); | 1940 | &lp->tx_ring_dma_addr); |
1996 | if (lp->tx_ring == NULL) { | 1941 | if (lp->tx_ring == NULL) { |
1997 | if (netif_msg_drv(lp)) | 1942 | netif_err(lp, drv, dev, "Consistent memory allocation failed\n"); |
1998 | printk(KERN_ERR PFX | ||
1999 | "%s: Consistent memory allocation failed.\n", | ||
2000 | name); | ||
2001 | return -ENOMEM; | 1943 | return -ENOMEM; |
2002 | } | 1944 | } |
2003 | 1945 | ||
@@ -2006,46 +1948,35 @@ static int pcnet32_alloc_ring(struct net_device *dev, const char *name) | |||
2006 | lp->rx_ring_size, | 1948 | lp->rx_ring_size, |
2007 | &lp->rx_ring_dma_addr); | 1949 | &lp->rx_ring_dma_addr); |
2008 | if (lp->rx_ring == NULL) { | 1950 | if (lp->rx_ring == NULL) { |
2009 | if (netif_msg_drv(lp)) | 1951 | netif_err(lp, drv, dev, "Consistent memory allocation failed\n"); |
2010 | printk(KERN_ERR PFX | ||
2011 | "%s: Consistent memory allocation failed.\n", | ||
2012 | name); | ||
2013 | return -ENOMEM; | 1952 | return -ENOMEM; |
2014 | } | 1953 | } |
2015 | 1954 | ||
2016 | lp->tx_dma_addr = kcalloc(lp->tx_ring_size, sizeof(dma_addr_t), | 1955 | lp->tx_dma_addr = kcalloc(lp->tx_ring_size, sizeof(dma_addr_t), |
2017 | GFP_ATOMIC); | 1956 | GFP_ATOMIC); |
2018 | if (!lp->tx_dma_addr) { | 1957 | if (!lp->tx_dma_addr) { |
2019 | if (netif_msg_drv(lp)) | 1958 | netif_err(lp, drv, dev, "Memory allocation failed\n"); |
2020 | printk(KERN_ERR PFX | ||
2021 | "%s: Memory allocation failed.\n", name); | ||
2022 | return -ENOMEM; | 1959 | return -ENOMEM; |
2023 | } | 1960 | } |
2024 | 1961 | ||
2025 | lp->rx_dma_addr = kcalloc(lp->rx_ring_size, sizeof(dma_addr_t), | 1962 | lp->rx_dma_addr = kcalloc(lp->rx_ring_size, sizeof(dma_addr_t), |
2026 | GFP_ATOMIC); | 1963 | GFP_ATOMIC); |
2027 | if (!lp->rx_dma_addr) { | 1964 | if (!lp->rx_dma_addr) { |
2028 | if (netif_msg_drv(lp)) | 1965 | netif_err(lp, drv, dev, "Memory allocation failed\n"); |
2029 | printk(KERN_ERR PFX | ||
2030 | "%s: Memory allocation failed.\n", name); | ||
2031 | return -ENOMEM; | 1966 | return -ENOMEM; |
2032 | } | 1967 | } |
2033 | 1968 | ||
2034 | lp->tx_skbuff = kcalloc(lp->tx_ring_size, sizeof(struct sk_buff *), | 1969 | lp->tx_skbuff = kcalloc(lp->tx_ring_size, sizeof(struct sk_buff *), |
2035 | GFP_ATOMIC); | 1970 | GFP_ATOMIC); |
2036 | if (!lp->tx_skbuff) { | 1971 | if (!lp->tx_skbuff) { |
2037 | if (netif_msg_drv(lp)) | 1972 | netif_err(lp, drv, dev, "Memory allocation failed\n"); |
2038 | printk(KERN_ERR PFX | ||
2039 | "%s: Memory allocation failed.\n", name); | ||
2040 | return -ENOMEM; | 1973 | return -ENOMEM; |
2041 | } | 1974 | } |
2042 | 1975 | ||
2043 | lp->rx_skbuff = kcalloc(lp->rx_ring_size, sizeof(struct sk_buff *), | 1976 | lp->rx_skbuff = kcalloc(lp->rx_ring_size, sizeof(struct sk_buff *), |
2044 | GFP_ATOMIC); | 1977 | GFP_ATOMIC); |
2045 | if (!lp->rx_skbuff) { | 1978 | if (!lp->rx_skbuff) { |
2046 | if (netif_msg_drv(lp)) | 1979 | netif_err(lp, drv, dev, "Memory allocation failed\n"); |
2047 | printk(KERN_ERR PFX | ||
2048 | "%s: Memory allocation failed.\n", name); | ||
2049 | return -ENOMEM; | 1980 | return -ENOMEM; |
2050 | } | 1981 | } |
2051 | 1982 | ||
@@ -2095,7 +2026,7 @@ static int pcnet32_open(struct net_device *dev) | |||
2095 | int rc; | 2026 | int rc; |
2096 | unsigned long flags; | 2027 | unsigned long flags; |
2097 | 2028 | ||
2098 | if (request_irq(dev->irq, &pcnet32_interrupt, | 2029 | if (request_irq(dev->irq, pcnet32_interrupt, |
2099 | lp->shared_irq ? IRQF_SHARED : 0, dev->name, | 2030 | lp->shared_irq ? IRQF_SHARED : 0, dev->name, |
2100 | (void *)dev)) { | 2031 | (void *)dev)) { |
2101 | return -EAGAIN; | 2032 | return -EAGAIN; |
@@ -2114,12 +2045,11 @@ static int pcnet32_open(struct net_device *dev) | |||
2114 | /* switch pcnet32 to 32bit mode */ | 2045 | /* switch pcnet32 to 32bit mode */ |
2115 | lp->a.write_bcr(ioaddr, 20, 2); | 2046 | lp->a.write_bcr(ioaddr, 20, 2); |
2116 | 2047 | ||
2117 | if (netif_msg_ifup(lp)) | 2048 | netif_printk(lp, ifup, KERN_DEBUG, dev, |
2118 | printk(KERN_DEBUG | 2049 | "%s() irq %d tx/rx rings %#x/%#x init %#x\n", |
2119 | "%s: pcnet32_open() irq %d tx/rx rings %#x/%#x init %#x.\n", | 2050 | __func__, dev->irq, (u32) (lp->tx_ring_dma_addr), |
2120 | dev->name, dev->irq, (u32) (lp->tx_ring_dma_addr), | 2051 | (u32) (lp->rx_ring_dma_addr), |
2121 | (u32) (lp->rx_ring_dma_addr), | 2052 | (u32) (lp->init_dma_addr)); |
2122 | (u32) (lp->init_dma_addr)); | ||
2123 | 2053 | ||
2124 | /* set/reset autoselect bit */ | 2054 | /* set/reset autoselect bit */ |
2125 | val = lp->a.read_bcr(ioaddr, 2) & ~2; | 2055 | val = lp->a.read_bcr(ioaddr, 2) & ~2; |
@@ -2154,10 +2084,8 @@ static int pcnet32_open(struct net_device *dev) | |||
2154 | pdev->subsystem_device == PCI_SUBDEVICE_ID_AT_2701FX)) { | 2084 | pdev->subsystem_device == PCI_SUBDEVICE_ID_AT_2701FX)) { |
2155 | if (lp->options & PCNET32_PORT_ASEL) { | 2085 | if (lp->options & PCNET32_PORT_ASEL) { |
2156 | lp->options = PCNET32_PORT_FD | PCNET32_PORT_100; | 2086 | lp->options = PCNET32_PORT_FD | PCNET32_PORT_100; |
2157 | if (netif_msg_link(lp)) | 2087 | netif_printk(lp, link, KERN_DEBUG, dev, |
2158 | printk(KERN_DEBUG | 2088 | "Setting 100Mb-Full Duplex\n"); |
2159 | "%s: Setting 100Mb-Full Duplex.\n", | ||
2160 | dev->name); | ||
2161 | } | 2089 | } |
2162 | } | 2090 | } |
2163 | if (lp->phycount < 2) { | 2091 | if (lp->phycount < 2) { |
@@ -2245,9 +2173,7 @@ static int pcnet32_open(struct net_device *dev) | |||
2245 | } | 2173 | } |
2246 | } | 2174 | } |
2247 | lp->mii_if.phy_id = first_phy; | 2175 | lp->mii_if.phy_id = first_phy; |
2248 | if (netif_msg_link(lp)) | 2176 | netif_info(lp, link, dev, "Using PHY number %d\n", first_phy); |
2249 | printk(KERN_INFO "%s: Using PHY number %d.\n", | ||
2250 | dev->name, first_phy); | ||
2251 | } | 2177 | } |
2252 | 2178 | ||
2253 | #ifdef DO_DXSUFLO | 2179 | #ifdef DO_DXSUFLO |
@@ -2294,18 +2220,17 @@ static int pcnet32_open(struct net_device *dev) | |||
2294 | */ | 2220 | */ |
2295 | lp->a.write_csr(ioaddr, CSR0, CSR0_NORMAL); | 2221 | lp->a.write_csr(ioaddr, CSR0, CSR0_NORMAL); |
2296 | 2222 | ||
2297 | if (netif_msg_ifup(lp)) | 2223 | netif_printk(lp, ifup, KERN_DEBUG, dev, |
2298 | printk(KERN_DEBUG | 2224 | "pcnet32 open after %d ticks, init block %#x csr0 %4.4x\n", |
2299 | "%s: pcnet32 open after %d ticks, init block %#x csr0 %4.4x.\n", | 2225 | i, |
2300 | dev->name, i, | 2226 | (u32) (lp->init_dma_addr), |
2301 | (u32) (lp->init_dma_addr), | 2227 | lp->a.read_csr(ioaddr, CSR0)); |
2302 | lp->a.read_csr(ioaddr, CSR0)); | ||
2303 | 2228 | ||
2304 | spin_unlock_irqrestore(&lp->lock, flags); | 2229 | spin_unlock_irqrestore(&lp->lock, flags); |
2305 | 2230 | ||
2306 | return 0; /* Always succeed */ | 2231 | return 0; /* Always succeed */ |
2307 | 2232 | ||
2308 | err_free_ring: | 2233 | err_free_ring: |
2309 | /* free any allocated skbuffs */ | 2234 | /* free any allocated skbuffs */ |
2310 | pcnet32_purge_rx_ring(dev); | 2235 | pcnet32_purge_rx_ring(dev); |
2311 | 2236 | ||
@@ -2315,7 +2240,7 @@ static int pcnet32_open(struct net_device *dev) | |||
2315 | */ | 2240 | */ |
2316 | lp->a.write_bcr(ioaddr, 20, 4); | 2241 | lp->a.write_bcr(ioaddr, 20, 4); |
2317 | 2242 | ||
2318 | err_free_irq: | 2243 | err_free_irq: |
2319 | spin_unlock_irqrestore(&lp->lock, flags); | 2244 | spin_unlock_irqrestore(&lp->lock, flags); |
2320 | free_irq(dev->irq, dev); | 2245 | free_irq(dev->irq, dev); |
2321 | return rc; | 2246 | return rc; |
@@ -2366,14 +2291,12 @@ static int pcnet32_init_ring(struct net_device *dev) | |||
2366 | for (i = 0; i < lp->rx_ring_size; i++) { | 2291 | for (i = 0; i < lp->rx_ring_size; i++) { |
2367 | struct sk_buff *rx_skbuff = lp->rx_skbuff[i]; | 2292 | struct sk_buff *rx_skbuff = lp->rx_skbuff[i]; |
2368 | if (rx_skbuff == NULL) { | 2293 | if (rx_skbuff == NULL) { |
2369 | if (! | 2294 | lp->rx_skbuff[i] = dev_alloc_skb(PKT_BUF_SKB); |
2370 | (rx_skbuff = lp->rx_skbuff[i] = | 2295 | rx_skbuff = lp->rx_skbuff[i]; |
2371 | dev_alloc_skb(PKT_BUF_SKB))) { | 2296 | if (!rx_skbuff) { |
2372 | /* there is not much, we can do at this point */ | 2297 | /* there is not much we can do at this point */ |
2373 | if (netif_msg_drv(lp)) | 2298 | netif_err(lp, drv, dev, "%s dev_alloc_skb failed\n", |
2374 | printk(KERN_ERR | 2299 | __func__); |
2375 | "%s: pcnet32_init_ring dev_alloc_skb failed.\n", | ||
2376 | dev->name); | ||
2377 | return -1; | 2300 | return -1; |
2378 | } | 2301 | } |
2379 | skb_reserve(rx_skbuff, NET_IP_ALIGN); | 2302 | skb_reserve(rx_skbuff, NET_IP_ALIGN); |
@@ -2423,10 +2346,9 @@ static void pcnet32_restart(struct net_device *dev, unsigned int csr0_bits) | |||
2423 | if (lp->a.read_csr(ioaddr, CSR0) & CSR0_STOP) | 2346 | if (lp->a.read_csr(ioaddr, CSR0) & CSR0_STOP) |
2424 | break; | 2347 | break; |
2425 | 2348 | ||
2426 | if (i >= 100 && netif_msg_drv(lp)) | 2349 | if (i >= 100) |
2427 | printk(KERN_ERR | 2350 | netif_err(lp, drv, dev, "%s timed out waiting for stop\n", |
2428 | "%s: pcnet32_restart timed out waiting for stop.\n", | 2351 | __func__); |
2429 | dev->name); | ||
2430 | 2352 | ||
2431 | pcnet32_purge_tx_ring(dev); | 2353 | pcnet32_purge_tx_ring(dev); |
2432 | if (pcnet32_init_ring(dev)) | 2354 | if (pcnet32_init_ring(dev)) |
@@ -2450,8 +2372,7 @@ static void pcnet32_tx_timeout(struct net_device *dev) | |||
2450 | spin_lock_irqsave(&lp->lock, flags); | 2372 | spin_lock_irqsave(&lp->lock, flags); |
2451 | /* Transmitter timeout, serious problems. */ | 2373 | /* Transmitter timeout, serious problems. */ |
2452 | if (pcnet32_debug & NETIF_MSG_DRV) | 2374 | if (pcnet32_debug & NETIF_MSG_DRV) |
2453 | printk(KERN_ERR | 2375 | pr_err("%s: transmit timed out, status %4.4x, resetting\n", |
2454 | "%s: transmit timed out, status %4.4x, resetting.\n", | ||
2455 | dev->name, lp->a.read_csr(ioaddr, CSR0)); | 2376 | dev->name, lp->a.read_csr(ioaddr, CSR0)); |
2456 | lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); | 2377 | lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); |
2457 | dev->stats.tx_errors++; | 2378 | dev->stats.tx_errors++; |
@@ -2494,11 +2415,9 @@ static netdev_tx_t pcnet32_start_xmit(struct sk_buff *skb, | |||
2494 | 2415 | ||
2495 | spin_lock_irqsave(&lp->lock, flags); | 2416 | spin_lock_irqsave(&lp->lock, flags); |
2496 | 2417 | ||
2497 | if (netif_msg_tx_queued(lp)) { | 2418 | netif_printk(lp, tx_queued, KERN_DEBUG, dev, |
2498 | printk(KERN_DEBUG | 2419 | "%s() called, csr0 %4.4x\n", |
2499 | "%s: pcnet32_start_xmit() called, csr0 %4.4x.\n", | 2420 | __func__, lp->a.read_csr(ioaddr, CSR0)); |
2500 | dev->name, lp->a.read_csr(ioaddr, CSR0)); | ||
2501 | } | ||
2502 | 2421 | ||
2503 | /* Default status -- will not enable Successful-TxDone | 2422 | /* Default status -- will not enable Successful-TxDone |
2504 | * interrupt when that option is available to us. | 2423 | * interrupt when that option is available to us. |
@@ -2557,16 +2476,14 @@ pcnet32_interrupt(int irq, void *dev_id) | |||
2557 | 2476 | ||
2558 | csr0 = lp->a.read_csr(ioaddr, CSR0); | 2477 | csr0 = lp->a.read_csr(ioaddr, CSR0); |
2559 | while ((csr0 & 0x8f00) && --boguscnt >= 0) { | 2478 | while ((csr0 & 0x8f00) && --boguscnt >= 0) { |
2560 | if (csr0 == 0xffff) { | 2479 | if (csr0 == 0xffff) |
2561 | break; /* PCMCIA remove happened */ | 2480 | break; /* PCMCIA remove happened */ |
2562 | } | ||
2563 | /* Acknowledge all of the current interrupt sources ASAP. */ | 2481 | /* Acknowledge all of the current interrupt sources ASAP. */ |
2564 | lp->a.write_csr(ioaddr, CSR0, csr0 & ~0x004f); | 2482 | lp->a.write_csr(ioaddr, CSR0, csr0 & ~0x004f); |
2565 | 2483 | ||
2566 | if (netif_msg_intr(lp)) | 2484 | netif_printk(lp, intr, KERN_DEBUG, dev, |
2567 | printk(KERN_DEBUG | 2485 | "interrupt csr0=%#2.2x new csr=%#2.2x\n", |
2568 | "%s: interrupt csr0=%#2.2x new csr=%#2.2x.\n", | 2486 | csr0, lp->a.read_csr(ioaddr, CSR0)); |
2569 | dev->name, csr0, lp->a.read_csr(ioaddr, CSR0)); | ||
2570 | 2487 | ||
2571 | /* Log misc errors. */ | 2488 | /* Log misc errors. */ |
2572 | if (csr0 & 0x4000) | 2489 | if (csr0 & 0x4000) |
@@ -2586,10 +2503,8 @@ pcnet32_interrupt(int irq, void *dev_id) | |||
2586 | dev->stats.rx_errors++; /* Missed a Rx frame. */ | 2503 | dev->stats.rx_errors++; /* Missed a Rx frame. */ |
2587 | } | 2504 | } |
2588 | if (csr0 & 0x0800) { | 2505 | if (csr0 & 0x0800) { |
2589 | if (netif_msg_drv(lp)) | 2506 | netif_err(lp, drv, dev, "Bus master arbitration failure, status %4.4x\n", |
2590 | printk(KERN_ERR | 2507 | csr0); |
2591 | "%s: Bus master arbitration failure, status %4.4x.\n", | ||
2592 | dev->name, csr0); | ||
2593 | /* unlike for the lance, there is no restart needed */ | 2508 | /* unlike for the lance, there is no restart needed */ |
2594 | } | 2509 | } |
2595 | if (napi_schedule_prep(&lp->napi)) { | 2510 | if (napi_schedule_prep(&lp->napi)) { |
@@ -2605,9 +2520,9 @@ pcnet32_interrupt(int irq, void *dev_id) | |||
2605 | csr0 = lp->a.read_csr(ioaddr, CSR0); | 2520 | csr0 = lp->a.read_csr(ioaddr, CSR0); |
2606 | } | 2521 | } |
2607 | 2522 | ||
2608 | if (netif_msg_intr(lp)) | 2523 | netif_printk(lp, intr, KERN_DEBUG, dev, |
2609 | printk(KERN_DEBUG "%s: exiting interrupt, csr0=%#4.4x.\n", | 2524 | "exiting interrupt, csr0=%#4.4x\n", |
2610 | dev->name, lp->a.read_csr(ioaddr, CSR0)); | 2525 | lp->a.read_csr(ioaddr, CSR0)); |
2611 | 2526 | ||
2612 | spin_unlock(&lp->lock); | 2527 | spin_unlock(&lp->lock); |
2613 | 2528 | ||
@@ -2629,10 +2544,9 @@ static int pcnet32_close(struct net_device *dev) | |||
2629 | 2544 | ||
2630 | dev->stats.rx_missed_errors = lp->a.read_csr(ioaddr, 112); | 2545 | dev->stats.rx_missed_errors = lp->a.read_csr(ioaddr, 112); |
2631 | 2546 | ||
2632 | if (netif_msg_ifdown(lp)) | 2547 | netif_printk(lp, ifdown, KERN_DEBUG, dev, |
2633 | printk(KERN_DEBUG | 2548 | "Shutting down ethercard, status was %2.2x\n", |
2634 | "%s: Shutting down ethercard, status was %2.2x.\n", | 2549 | lp->a.read_csr(ioaddr, CSR0)); |
2635 | dev->name, lp->a.read_csr(ioaddr, CSR0)); | ||
2636 | 2550 | ||
2637 | /* We stop the PCNET32 here -- it occasionally polls memory if we don't. */ | 2551 | /* We stop the PCNET32 here -- it occasionally polls memory if we don't. */ |
2638 | lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); | 2552 | lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); |
@@ -2676,7 +2590,7 @@ static void pcnet32_load_multicast(struct net_device *dev) | |||
2676 | struct pcnet32_private *lp = netdev_priv(dev); | 2590 | struct pcnet32_private *lp = netdev_priv(dev); |
2677 | volatile struct pcnet32_init_block *ib = lp->init_block; | 2591 | volatile struct pcnet32_init_block *ib = lp->init_block; |
2678 | volatile __le16 *mcast_table = (__le16 *)ib->filter; | 2592 | volatile __le16 *mcast_table = (__le16 *)ib->filter; |
2679 | struct dev_mc_list *dmi = dev->mc_list; | 2593 | struct dev_mc_list *dmi; |
2680 | unsigned long ioaddr = dev->base_addr; | 2594 | unsigned long ioaddr = dev->base_addr; |
2681 | char *addrs; | 2595 | char *addrs; |
2682 | int i; | 2596 | int i; |
@@ -2697,9 +2611,8 @@ static void pcnet32_load_multicast(struct net_device *dev) | |||
2697 | ib->filter[1] = 0; | 2611 | ib->filter[1] = 0; |
2698 | 2612 | ||
2699 | /* Add addresses */ | 2613 | /* Add addresses */ |
2700 | for (i = 0; i < dev->mc_count; i++) { | 2614 | netdev_for_each_mc_addr(dmi, dev) { |
2701 | addrs = dmi->dmi_addr; | 2615 | addrs = dmi->dmi_addr; |
2702 | dmi = dmi->next; | ||
2703 | 2616 | ||
2704 | /* multicast address? */ | 2617 | /* multicast address? */ |
2705 | if (!(*addrs & 1)) | 2618 | if (!(*addrs & 1)) |
@@ -2729,9 +2642,7 @@ static void pcnet32_set_multicast_list(struct net_device *dev) | |||
2729 | csr15 = lp->a.read_csr(ioaddr, CSR15); | 2642 | csr15 = lp->a.read_csr(ioaddr, CSR15); |
2730 | if (dev->flags & IFF_PROMISC) { | 2643 | if (dev->flags & IFF_PROMISC) { |
2731 | /* Log any net taps. */ | 2644 | /* Log any net taps. */ |
2732 | if (netif_msg_hw(lp)) | 2645 | netif_info(lp, hw, dev, "Promiscuous mode enabled\n"); |
2733 | printk(KERN_INFO "%s: Promiscuous mode enabled.\n", | ||
2734 | dev->name); | ||
2735 | lp->init_block->mode = | 2646 | lp->init_block->mode = |
2736 | cpu_to_le16(0x8000 | (lp->options & PCNET32_PORT_PORTSEL) << | 2647 | cpu_to_le16(0x8000 | (lp->options & PCNET32_PORT_PORTSEL) << |
2737 | 7); | 2648 | 7); |
@@ -2818,10 +2729,8 @@ static int pcnet32_check_otherphy(struct net_device *dev) | |||
2818 | mii.phy_id = i; | 2729 | mii.phy_id = i; |
2819 | if (mii_link_ok(&mii)) { | 2730 | if (mii_link_ok(&mii)) { |
2820 | /* found PHY with active link */ | 2731 | /* found PHY with active link */ |
2821 | if (netif_msg_link(lp)) | 2732 | netif_info(lp, link, dev, "Using PHY number %d\n", |
2822 | printk(KERN_INFO | 2733 | i); |
2823 | "%s: Using PHY number %d.\n", | ||
2824 | dev->name, i); | ||
2825 | 2734 | ||
2826 | /* isolate inactive phy */ | 2735 | /* isolate inactive phy */ |
2827 | bmcr = | 2736 | bmcr = |
@@ -2867,8 +2776,7 @@ static void pcnet32_check_media(struct net_device *dev, int verbose) | |||
2867 | if (!curr_link) { | 2776 | if (!curr_link) { |
2868 | if (prev_link || verbose) { | 2777 | if (prev_link || verbose) { |
2869 | netif_carrier_off(dev); | 2778 | netif_carrier_off(dev); |
2870 | if (netif_msg_link(lp)) | 2779 | netif_info(lp, link, dev, "link down\n"); |
2871 | printk(KERN_INFO "%s: link down\n", dev->name); | ||
2872 | } | 2780 | } |
2873 | if (lp->phycount > 1) { | 2781 | if (lp->phycount > 1) { |
2874 | curr_link = pcnet32_check_otherphy(dev); | 2782 | curr_link = pcnet32_check_otherphy(dev); |
@@ -2880,12 +2788,11 @@ static void pcnet32_check_media(struct net_device *dev, int verbose) | |||
2880 | if (netif_msg_link(lp)) { | 2788 | if (netif_msg_link(lp)) { |
2881 | struct ethtool_cmd ecmd; | 2789 | struct ethtool_cmd ecmd; |
2882 | mii_ethtool_gset(&lp->mii_if, &ecmd); | 2790 | mii_ethtool_gset(&lp->mii_if, &ecmd); |
2883 | printk(KERN_INFO | 2791 | netdev_info(dev, "link up, %sMbps, %s-duplex\n", |
2884 | "%s: link up, %sMbps, %s-duplex\n", | 2792 | (ecmd.speed == SPEED_100) |
2885 | dev->name, | 2793 | ? "100" : "10", |
2886 | (ecmd.speed == SPEED_100) ? "100" : "10", | 2794 | (ecmd.duplex == DUPLEX_FULL) |
2887 | (ecmd.duplex == | 2795 | ? "full" : "half"); |
2888 | DUPLEX_FULL) ? "full" : "half"); | ||
2889 | } | 2796 | } |
2890 | bcr9 = lp->a.read_bcr(dev->base_addr, 9); | 2797 | bcr9 = lp->a.read_bcr(dev->base_addr, 9); |
2891 | if ((bcr9 & (1 << 0)) != lp->mii_if.full_duplex) { | 2798 | if ((bcr9 & (1 << 0)) != lp->mii_if.full_duplex) { |
@@ -2896,8 +2803,7 @@ static void pcnet32_check_media(struct net_device *dev, int verbose) | |||
2896 | lp->a.write_bcr(dev->base_addr, 9, bcr9); | 2803 | lp->a.write_bcr(dev->base_addr, 9, bcr9); |
2897 | } | 2804 | } |
2898 | } else { | 2805 | } else { |
2899 | if (netif_msg_link(lp)) | 2806 | netif_info(lp, link, dev, "link up\n"); |
2900 | printk(KERN_INFO "%s: link up\n", dev->name); | ||
2901 | } | 2807 | } |
2902 | } | 2808 | } |
2903 | } | 2809 | } |
@@ -3009,7 +2915,7 @@ MODULE_LICENSE("GPL"); | |||
3009 | 2915 | ||
3010 | static int __init pcnet32_init_module(void) | 2916 | static int __init pcnet32_init_module(void) |
3011 | { | 2917 | { |
3012 | printk(KERN_INFO "%s", version); | 2918 | pr_info("%s", version); |
3013 | 2919 | ||
3014 | pcnet32_debug = netif_msg_init(debug, PCNET32_MSG_DEFAULT); | 2920 | pcnet32_debug = netif_msg_init(debug, PCNET32_MSG_DEFAULT); |
3015 | 2921 | ||
@@ -3025,7 +2931,7 @@ static int __init pcnet32_init_module(void) | |||
3025 | pcnet32_probe_vlbus(pcnet32_portlist); | 2931 | pcnet32_probe_vlbus(pcnet32_portlist); |
3026 | 2932 | ||
3027 | if (cards_found && (pcnet32_debug & NETIF_MSG_PROBE)) | 2933 | if (cards_found && (pcnet32_debug & NETIF_MSG_PROBE)) |
3028 | printk(KERN_INFO PFX "%d cards_found.\n", cards_found); | 2934 | pr_info("%d cards_found\n", cards_found); |
3029 | 2935 | ||
3030 | return (pcnet32_have_pci + cards_found) ? 0 : -ENODEV; | 2936 | return (pcnet32_have_pci + cards_found) ? 0 : -ENODEV; |
3031 | } | 2937 | } |