diff options
| author | <jgarzik@pretzel.yyz.us> | 2005-05-27 20:12:17 -0400 |
|---|---|---|
| committer | Jeff Garzik <jgarzik@pobox.com> | 2005-05-27 20:12:17 -0400 |
| commit | befc9e10d64f93472aff0b0280968f447f5402df (patch) | |
| tree | d0b20bb986cf87b000e291ad7bb77427f6c14161 /drivers | |
| parent | 07b08a16186bd083ba06c37c621ea91fc580eb97 (diff) | |
| parent | 4dcb7d33770541ae3e65a57351f3875df64e8af6 (diff) | |
Automatic merge of rsync://www.fr.zoreil.com/linux-2.6.git branch HEAD
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/net/r8169.c | 320 |
1 files changed, 252 insertions, 68 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index b3768d844747..882c59fe9f8d 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
| @@ -69,7 +69,13 @@ VERSION 2.2LK <2005/01/25> | |||
| 69 | #include <asm/io.h> | 69 | #include <asm/io.h> |
| 70 | #include <asm/irq.h> | 70 | #include <asm/irq.h> |
| 71 | 71 | ||
| 72 | #define RTL8169_VERSION "2.2LK" | 72 | #ifdef CONFIG_R8169_NAPI |
| 73 | #define NAPI_SUFFIX "-NAPI" | ||
| 74 | #else | ||
| 75 | #define NAPI_SUFFIX "" | ||
| 76 | #endif | ||
| 77 | |||
| 78 | #define RTL8169_VERSION "2.2LK" NAPI_SUFFIX | ||
| 73 | #define MODULENAME "r8169" | 79 | #define MODULENAME "r8169" |
| 74 | #define PFX MODULENAME ": " | 80 | #define PFX MODULENAME ": " |
| 75 | 81 | ||
| @@ -85,6 +91,10 @@ VERSION 2.2LK <2005/01/25> | |||
| 85 | #define dprintk(fmt, args...) do {} while (0) | 91 | #define dprintk(fmt, args...) do {} while (0) |
| 86 | #endif /* RTL8169_DEBUG */ | 92 | #endif /* RTL8169_DEBUG */ |
| 87 | 93 | ||
| 94 | #define R8169_MSG_DEFAULT \ | ||
| 95 | (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | NETIF_MSG_IFUP | \ | ||
| 96 | NETIF_MSG_IFDOWN) | ||
| 97 | |||
| 88 | #define TX_BUFFS_AVAIL(tp) \ | 98 | #define TX_BUFFS_AVAIL(tp) \ |
| 89 | (tp->dirty_tx + NUM_TX_DESC - tp->cur_tx - 1) | 99 | (tp->dirty_tx + NUM_TX_DESC - tp->cur_tx - 1) |
| 90 | 100 | ||
| @@ -174,8 +184,9 @@ const static struct { | |||
| 174 | #undef _R | 184 | #undef _R |
| 175 | 185 | ||
| 176 | static struct pci_device_id rtl8169_pci_tbl[] = { | 186 | static struct pci_device_id rtl8169_pci_tbl[] = { |
| 177 | {0x10ec, 0x8169, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 187 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), }, |
| 178 | {0x1186, 0x4300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 188 | { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), }, |
| 189 | { PCI_DEVICE(0x16ec, 0x0116), }, | ||
| 179 | {0,}, | 190 | {0,}, |
| 180 | }; | 191 | }; |
| 181 | 192 | ||
| @@ -183,10 +194,15 @@ MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl); | |||
| 183 | 194 | ||
| 184 | static int rx_copybreak = 200; | 195 | static int rx_copybreak = 200; |
| 185 | static int use_dac; | 196 | static int use_dac; |
| 197 | static struct { | ||
| 198 | u32 msg_enable; | ||
| 199 | } debug = { -1 }; | ||
| 186 | 200 | ||
| 187 | enum RTL8169_registers { | 201 | enum RTL8169_registers { |
| 188 | MAC0 = 0, /* Ethernet hardware address. */ | 202 | MAC0 = 0, /* Ethernet hardware address. */ |
| 189 | MAR0 = 8, /* Multicast filter. */ | 203 | MAR0 = 8, /* Multicast filter. */ |
| 204 | CounterAddrLow = 0x10, | ||
| 205 | CounterAddrHigh = 0x14, | ||
| 190 | TxDescStartAddrLow = 0x20, | 206 | TxDescStartAddrLow = 0x20, |
| 191 | TxDescStartAddrHigh = 0x24, | 207 | TxDescStartAddrHigh = 0x24, |
| 192 | TxHDescStartAddrLow = 0x28, | 208 | TxHDescStartAddrLow = 0x28, |
| @@ -328,6 +344,9 @@ enum RTL8169_register_content { | |||
| 328 | 344 | ||
| 329 | /* _TBICSRBit */ | 345 | /* _TBICSRBit */ |
| 330 | TBILinkOK = 0x02000000, | 346 | TBILinkOK = 0x02000000, |
| 347 | |||
| 348 | /* DumpCounterCommand */ | ||
| 349 | CounterDump = 0x8, | ||
| 331 | }; | 350 | }; |
| 332 | 351 | ||
| 333 | enum _DescStatusBit { | 352 | enum _DescStatusBit { |
| @@ -385,6 +404,7 @@ struct rtl8169_private { | |||
| 385 | struct pci_dev *pci_dev; /* Index of PCI device */ | 404 | struct pci_dev *pci_dev; /* Index of PCI device */ |
| 386 | struct net_device_stats stats; /* statistics of net device */ | 405 | struct net_device_stats stats; /* statistics of net device */ |
| 387 | spinlock_t lock; /* spin lock flag */ | 406 | spinlock_t lock; /* spin lock flag */ |
| 407 | u32 msg_enable; | ||
| 388 | int chipset; | 408 | int chipset; |
| 389 | int mac_version; | 409 | int mac_version; |
| 390 | int phy_version; | 410 | int phy_version; |
| @@ -418,9 +438,13 @@ struct rtl8169_private { | |||
| 418 | MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@oss.sgi.com>"); | 438 | MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@oss.sgi.com>"); |
| 419 | MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver"); | 439 | MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver"); |
| 420 | module_param_array(media, int, &num_media, 0); | 440 | module_param_array(media, int, &num_media, 0); |
| 441 | MODULE_PARM_DESC(media, "force phy operation. Deprecated by ethtool (8)."); | ||
| 421 | module_param(rx_copybreak, int, 0); | 442 | module_param(rx_copybreak, int, 0); |
| 443 | MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames"); | ||
| 422 | module_param(use_dac, int, 0); | 444 | module_param(use_dac, int, 0); |
| 423 | MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot."); | 445 | MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot."); |
| 446 | module_param_named(debug, debug.msg_enable, int, 0); | ||
| 447 | MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)"); | ||
| 424 | MODULE_LICENSE("GPL"); | 448 | MODULE_LICENSE("GPL"); |
| 425 | MODULE_VERSION(RTL8169_VERSION); | 449 | MODULE_VERSION(RTL8169_VERSION); |
| 426 | 450 | ||
| @@ -433,10 +457,10 @@ static void rtl8169_hw_start(struct net_device *dev); | |||
| 433 | static int rtl8169_close(struct net_device *dev); | 457 | static int rtl8169_close(struct net_device *dev); |
| 434 | static void rtl8169_set_rx_mode(struct net_device *dev); | 458 | static void rtl8169_set_rx_mode(struct net_device *dev); |
| 435 | static void rtl8169_tx_timeout(struct net_device *dev); | 459 | static void rtl8169_tx_timeout(struct net_device *dev); |
| 436 | static struct net_device_stats *rtl8169_get_stats(struct net_device *netdev); | 460 | static struct net_device_stats *rtl8169_get_stats(struct net_device *dev); |
| 437 | static int rtl8169_rx_interrupt(struct net_device *, struct rtl8169_private *, | 461 | static int rtl8169_rx_interrupt(struct net_device *, struct rtl8169_private *, |
| 438 | void __iomem *); | 462 | void __iomem *); |
| 439 | static int rtl8169_change_mtu(struct net_device *netdev, int new_mtu); | 463 | static int rtl8169_change_mtu(struct net_device *dev, int new_mtu); |
| 440 | static void rtl8169_down(struct net_device *dev); | 464 | static void rtl8169_down(struct net_device *dev); |
| 441 | 465 | ||
| 442 | #ifdef CONFIG_R8169_NAPI | 466 | #ifdef CONFIG_R8169_NAPI |
| @@ -543,9 +567,13 @@ static void rtl8169_check_link_status(struct net_device *dev, | |||
| 543 | spin_lock_irqsave(&tp->lock, flags); | 567 | spin_lock_irqsave(&tp->lock, flags); |
| 544 | if (tp->link_ok(ioaddr)) { | 568 | if (tp->link_ok(ioaddr)) { |
| 545 | netif_carrier_on(dev); | 569 | netif_carrier_on(dev); |
| 546 | printk(KERN_INFO PFX "%s: link up\n", dev->name); | 570 | if (netif_msg_ifup(tp)) |
| 547 | } else | 571 | printk(KERN_INFO PFX "%s: link up\n", dev->name); |
| 572 | } else { | ||
| 573 | if (netif_msg_ifdown(tp)) | ||
| 574 | printk(KERN_INFO PFX "%s: link down\n", dev->name); | ||
| 548 | netif_carrier_off(dev); | 575 | netif_carrier_off(dev); |
| 576 | } | ||
| 549 | spin_unlock_irqrestore(&tp->lock, flags); | 577 | spin_unlock_irqrestore(&tp->lock, flags); |
| 550 | } | 578 | } |
| 551 | 579 | ||
| @@ -569,7 +597,7 @@ static void rtl8169_link_option(int idx, u8 *autoneg, u16 *speed, u8 *duplex) | |||
| 569 | 597 | ||
| 570 | option = ((idx < MAX_UNITS) && (idx >= 0)) ? media[idx] : 0xff; | 598 | option = ((idx < MAX_UNITS) && (idx >= 0)) ? media[idx] : 0xff; |
| 571 | 599 | ||
| 572 | if ((option != 0xff) && !idx) | 600 | if ((option != 0xff) && !idx && netif_msg_drv(&debug)) |
| 573 | printk(KERN_WARNING PFX "media option is deprecated.\n"); | 601 | printk(KERN_WARNING PFX "media option is deprecated.\n"); |
| 574 | 602 | ||
| 575 | for (p = link_settings; p->media != 0xff; p++) { | 603 | for (p = link_settings; p->media != 0xff; p++) { |
| @@ -611,9 +639,11 @@ static int rtl8169_set_speed_tbi(struct net_device *dev, | |||
| 611 | } else if (autoneg == AUTONEG_ENABLE) | 639 | } else if (autoneg == AUTONEG_ENABLE) |
| 612 | RTL_W32(TBICSR, reg | TBINwEnable | TBINwRestart); | 640 | RTL_W32(TBICSR, reg | TBINwEnable | TBINwRestart); |
| 613 | else { | 641 | else { |
| 614 | printk(KERN_WARNING PFX | 642 | if (netif_msg_link(tp)) { |
| 615 | "%s: incorrect speed setting refused in TBI mode\n", | 643 | printk(KERN_WARNING "%s: " |
| 616 | dev->name); | 644 | "incorrect speed setting refused in TBI mode\n", |
| 645 | dev->name); | ||
| 646 | } | ||
| 617 | ret = -EOPNOTSUPP; | 647 | ret = -EOPNOTSUPP; |
| 618 | } | 648 | } |
| 619 | 649 | ||
| @@ -871,12 +901,120 @@ static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs, | |||
| 871 | spin_unlock_irqrestore(&tp->lock, flags); | 901 | spin_unlock_irqrestore(&tp->lock, flags); |
| 872 | } | 902 | } |
| 873 | 903 | ||
| 904 | static u32 rtl8169_get_msglevel(struct net_device *dev) | ||
| 905 | { | ||
| 906 | struct rtl8169_private *tp = netdev_priv(dev); | ||
| 907 | |||
| 908 | return tp->msg_enable; | ||
| 909 | } | ||
| 910 | |||
| 911 | static void rtl8169_set_msglevel(struct net_device *dev, u32 value) | ||
| 912 | { | ||
| 913 | struct rtl8169_private *tp = netdev_priv(dev); | ||
| 914 | |||
| 915 | tp->msg_enable = value; | ||
| 916 | } | ||
| 917 | |||
| 918 | static const char rtl8169_gstrings[][ETH_GSTRING_LEN] = { | ||
| 919 | "tx_packets", | ||
| 920 | "rx_packets", | ||
| 921 | "tx_errors", | ||
| 922 | "rx_errors", | ||
| 923 | "rx_missed", | ||
| 924 | "align_errors", | ||
| 925 | "tx_single_collisions", | ||
| 926 | "tx_multi_collisions", | ||
| 927 | "unicast", | ||
| 928 | "broadcast", | ||
| 929 | "multicast", | ||
| 930 | "tx_aborted", | ||
| 931 | "tx_underrun", | ||
| 932 | }; | ||
| 933 | |||
| 934 | struct rtl8169_counters { | ||
| 935 | u64 tx_packets; | ||
| 936 | u64 rx_packets; | ||
| 937 | u64 tx_errors; | ||
| 938 | u32 rx_errors; | ||
| 939 | u16 rx_missed; | ||
| 940 | u16 align_errors; | ||
| 941 | u32 tx_one_collision; | ||
| 942 | u32 tx_multi_collision; | ||
| 943 | u64 rx_unicast; | ||
| 944 | u64 rx_broadcast; | ||
| 945 | u32 rx_multicast; | ||
| 946 | u16 tx_aborted; | ||
| 947 | u16 tx_underun; | ||
| 948 | }; | ||
| 949 | |||
| 950 | static int rtl8169_get_stats_count(struct net_device *dev) | ||
| 951 | { | ||
| 952 | return ARRAY_SIZE(rtl8169_gstrings); | ||
| 953 | } | ||
| 954 | |||
| 955 | static void rtl8169_get_ethtool_stats(struct net_device *dev, | ||
| 956 | struct ethtool_stats *stats, u64 *data) | ||
| 957 | { | ||
| 958 | struct rtl8169_private *tp = netdev_priv(dev); | ||
| 959 | void __iomem *ioaddr = tp->mmio_addr; | ||
| 960 | struct rtl8169_counters *counters; | ||
| 961 | dma_addr_t paddr; | ||
| 962 | u32 cmd; | ||
| 963 | |||
| 964 | ASSERT_RTNL(); | ||
| 965 | |||
| 966 | counters = pci_alloc_consistent(tp->pci_dev, sizeof(*counters), &paddr); | ||
| 967 | if (!counters) | ||
| 968 | return; | ||
| 969 | |||
| 970 | RTL_W32(CounterAddrHigh, (u64)paddr >> 32); | ||
| 971 | cmd = (u64)paddr & DMA_32BIT_MASK; | ||
| 972 | RTL_W32(CounterAddrLow, cmd); | ||
| 973 | RTL_W32(CounterAddrLow, cmd | CounterDump); | ||
| 974 | |||
| 975 | while (RTL_R32(CounterAddrLow) & CounterDump) { | ||
| 976 | if (msleep_interruptible(1)) | ||
| 977 | break; | ||
| 978 | } | ||
| 979 | |||
| 980 | RTL_W32(CounterAddrLow, 0); | ||
| 981 | RTL_W32(CounterAddrHigh, 0); | ||
| 982 | |||
| 983 | data[0] = le64_to_cpu(counters->tx_packets); | ||
| 984 | data[1] = le64_to_cpu(counters->rx_packets); | ||
| 985 | data[2] = le64_to_cpu(counters->tx_errors); | ||
| 986 | data[3] = le32_to_cpu(counters->rx_errors); | ||
| 987 | data[4] = le16_to_cpu(counters->rx_missed); | ||
| 988 | data[5] = le16_to_cpu(counters->align_errors); | ||
| 989 | data[6] = le32_to_cpu(counters->tx_one_collision); | ||
| 990 | data[7] = le32_to_cpu(counters->tx_multi_collision); | ||
| 991 | data[8] = le64_to_cpu(counters->rx_unicast); | ||
| 992 | data[9] = le64_to_cpu(counters->rx_broadcast); | ||
| 993 | data[10] = le32_to_cpu(counters->rx_multicast); | ||
| 994 | data[11] = le16_to_cpu(counters->tx_aborted); | ||
| 995 | data[12] = le16_to_cpu(counters->tx_underun); | ||
| 996 | |||
| 997 | pci_free_consistent(tp->pci_dev, sizeof(*counters), counters, paddr); | ||
| 998 | } | ||
| 999 | |||
| 1000 | static void rtl8169_get_strings(struct net_device *dev, u32 stringset, u8 *data) | ||
| 1001 | { | ||
| 1002 | switch(stringset) { | ||
| 1003 | case ETH_SS_STATS: | ||
| 1004 | memcpy(data, *rtl8169_gstrings, sizeof(rtl8169_gstrings)); | ||
| 1005 | break; | ||
| 1006 | } | ||
| 1007 | } | ||
| 1008 | |||
| 1009 | |||
| 874 | static struct ethtool_ops rtl8169_ethtool_ops = { | 1010 | static struct ethtool_ops rtl8169_ethtool_ops = { |
| 875 | .get_drvinfo = rtl8169_get_drvinfo, | 1011 | .get_drvinfo = rtl8169_get_drvinfo, |
| 876 | .get_regs_len = rtl8169_get_regs_len, | 1012 | .get_regs_len = rtl8169_get_regs_len, |
| 877 | .get_link = ethtool_op_get_link, | 1013 | .get_link = ethtool_op_get_link, |
| 878 | .get_settings = rtl8169_get_settings, | 1014 | .get_settings = rtl8169_get_settings, |
| 879 | .set_settings = rtl8169_set_settings, | 1015 | .set_settings = rtl8169_set_settings, |
| 1016 | .get_msglevel = rtl8169_get_msglevel, | ||
| 1017 | .set_msglevel = rtl8169_set_msglevel, | ||
| 880 | .get_rx_csum = rtl8169_get_rx_csum, | 1018 | .get_rx_csum = rtl8169_get_rx_csum, |
| 881 | .set_rx_csum = rtl8169_set_rx_csum, | 1019 | .set_rx_csum = rtl8169_set_rx_csum, |
| 882 | .get_tx_csum = ethtool_op_get_tx_csum, | 1020 | .get_tx_csum = ethtool_op_get_tx_csum, |
| @@ -886,6 +1024,9 @@ static struct ethtool_ops rtl8169_ethtool_ops = { | |||
| 886 | .get_tso = ethtool_op_get_tso, | 1024 | .get_tso = ethtool_op_get_tso, |
| 887 | .set_tso = ethtool_op_set_tso, | 1025 | .set_tso = ethtool_op_set_tso, |
| 888 | .get_regs = rtl8169_get_regs, | 1026 | .get_regs = rtl8169_get_regs, |
| 1027 | .get_strings = rtl8169_get_strings, | ||
| 1028 | .get_stats_count = rtl8169_get_stats_count, | ||
| 1029 | .get_ethtool_stats = rtl8169_get_ethtool_stats, | ||
| 889 | }; | 1030 | }; |
| 890 | 1031 | ||
| 891 | static void rtl8169_write_gmii_reg_bit(void __iomem *ioaddr, int reg, int bitnum, | 1032 | static void rtl8169_write_gmii_reg_bit(void __iomem *ioaddr, int reg, int bitnum, |
| @@ -1091,7 +1232,8 @@ static void rtl8169_phy_timer(unsigned long __opaque) | |||
| 1091 | if (tp->link_ok(ioaddr)) | 1232 | if (tp->link_ok(ioaddr)) |
| 1092 | goto out_unlock; | 1233 | goto out_unlock; |
| 1093 | 1234 | ||
| 1094 | printk(KERN_WARNING PFX "%s: PHY reset until link up\n", dev->name); | 1235 | if (netif_msg_link(tp)) |
| 1236 | printk(KERN_WARNING "%s: PHY reset until link up\n", dev->name); | ||
| 1095 | 1237 | ||
| 1096 | tp->phy_reset_enable(ioaddr); | 1238 | tp->phy_reset_enable(ioaddr); |
| 1097 | 1239 | ||
| @@ -1169,18 +1311,23 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out, | |||
| 1169 | /* dev zeroed in alloc_etherdev */ | 1311 | /* dev zeroed in alloc_etherdev */ |
| 1170 | dev = alloc_etherdev(sizeof (*tp)); | 1312 | dev = alloc_etherdev(sizeof (*tp)); |
| 1171 | if (dev == NULL) { | 1313 | if (dev == NULL) { |
| 1172 | printk(KERN_ERR PFX "unable to alloc new ethernet\n"); | 1314 | if (netif_msg_drv(&debug)) |
| 1315 | printk(KERN_ERR PFX "unable to alloc new ethernet\n"); | ||
| 1173 | goto err_out; | 1316 | goto err_out; |
| 1174 | } | 1317 | } |
| 1175 | 1318 | ||
| 1176 | SET_MODULE_OWNER(dev); | 1319 | SET_MODULE_OWNER(dev); |
| 1177 | SET_NETDEV_DEV(dev, &pdev->dev); | 1320 | SET_NETDEV_DEV(dev, &pdev->dev); |
| 1178 | tp = netdev_priv(dev); | 1321 | tp = netdev_priv(dev); |
| 1322 | tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT); | ||
| 1179 | 1323 | ||
| 1180 | /* enable device (incl. PCI PM wakeup and hotplug setup) */ | 1324 | /* enable device (incl. PCI PM wakeup and hotplug setup) */ |
| 1181 | rc = pci_enable_device(pdev); | 1325 | rc = pci_enable_device(pdev); |
| 1182 | if (rc) { | 1326 | if (rc < 0) { |
| 1183 | printk(KERN_ERR PFX "%s: enable failure\n", pci_name(pdev)); | 1327 | if (netif_msg_probe(tp)) { |
| 1328 | printk(KERN_ERR PFX "%s: enable failure\n", | ||
| 1329 | pci_name(pdev)); | ||
| 1330 | } | ||
| 1184 | goto err_out_free_dev; | 1331 | goto err_out_free_dev; |
| 1185 | } | 1332 | } |
| 1186 | 1333 | ||
| @@ -1196,29 +1343,39 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out, | |||
| 1196 | pci_read_config_word(pdev, pm_cap + PCI_PM_CTRL, &pwr_command); | 1343 | pci_read_config_word(pdev, pm_cap + PCI_PM_CTRL, &pwr_command); |
| 1197 | acpi_idle_state = pwr_command & PCI_PM_CTRL_STATE_MASK; | 1344 | acpi_idle_state = pwr_command & PCI_PM_CTRL_STATE_MASK; |
| 1198 | } else { | 1345 | } else { |
| 1199 | printk(KERN_ERR PFX | 1346 | if (netif_msg_probe(tp)) { |
| 1200 | "Cannot find PowerManagement capability, aborting.\n"); | 1347 | printk(KERN_ERR PFX |
| 1348 | "Cannot find PowerManagement capability. " | ||
| 1349 | "Aborting.\n"); | ||
| 1350 | } | ||
| 1201 | goto err_out_mwi; | 1351 | goto err_out_mwi; |
| 1202 | } | 1352 | } |
| 1203 | 1353 | ||
| 1204 | /* make sure PCI base addr 1 is MMIO */ | 1354 | /* make sure PCI base addr 1 is MMIO */ |
| 1205 | if (!(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) { | 1355 | if (!(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) { |
| 1206 | printk(KERN_ERR PFX | 1356 | if (netif_msg_probe(tp)) { |
| 1207 | "region #1 not an MMIO resource, aborting\n"); | 1357 | printk(KERN_ERR PFX |
| 1358 | "region #1 not an MMIO resource, aborting\n"); | ||
| 1359 | } | ||
| 1208 | rc = -ENODEV; | 1360 | rc = -ENODEV; |
| 1209 | goto err_out_mwi; | 1361 | goto err_out_mwi; |
| 1210 | } | 1362 | } |
| 1211 | /* check for weird/broken PCI region reporting */ | 1363 | /* check for weird/broken PCI region reporting */ |
| 1212 | if (pci_resource_len(pdev, 1) < R8169_REGS_SIZE) { | 1364 | if (pci_resource_len(pdev, 1) < R8169_REGS_SIZE) { |
| 1213 | printk(KERN_ERR PFX "Invalid PCI region size(s), aborting\n"); | 1365 | if (netif_msg_probe(tp)) { |
| 1366 | printk(KERN_ERR PFX | ||
| 1367 | "Invalid PCI region size(s), aborting\n"); | ||
| 1368 | } | ||
| 1214 | rc = -ENODEV; | 1369 | rc = -ENODEV; |
| 1215 | goto err_out_mwi; | 1370 | goto err_out_mwi; |
| 1216 | } | 1371 | } |
| 1217 | 1372 | ||
| 1218 | rc = pci_request_regions(pdev, MODULENAME); | 1373 | rc = pci_request_regions(pdev, MODULENAME); |
| 1219 | if (rc) { | 1374 | if (rc < 0) { |
| 1220 | printk(KERN_ERR PFX "%s: could not request regions.\n", | 1375 | if (netif_msg_probe(tp)) { |
| 1221 | pci_name(pdev)); | 1376 | printk(KERN_ERR PFX "%s: could not request regions.\n", |
| 1377 | pci_name(pdev)); | ||
| 1378 | } | ||
| 1222 | goto err_out_mwi; | 1379 | goto err_out_mwi; |
| 1223 | } | 1380 | } |
| 1224 | 1381 | ||
| @@ -1231,7 +1388,10 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out, | |||
| 1231 | } else { | 1388 | } else { |
| 1232 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 1389 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
| 1233 | if (rc < 0) { | 1390 | if (rc < 0) { |
| 1234 | printk(KERN_ERR PFX "DMA configuration failed.\n"); | 1391 | if (netif_msg_probe(tp)) { |
| 1392 | printk(KERN_ERR PFX | ||
| 1393 | "DMA configuration failed.\n"); | ||
| 1394 | } | ||
| 1235 | goto err_out_free_res; | 1395 | goto err_out_free_res; |
| 1236 | } | 1396 | } |
| 1237 | } | 1397 | } |
| @@ -1241,7 +1401,8 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out, | |||
| 1241 | /* ioremap MMIO region */ | 1401 | /* ioremap MMIO region */ |
| 1242 | ioaddr = ioremap(pci_resource_start(pdev, 1), R8169_REGS_SIZE); | 1402 | ioaddr = ioremap(pci_resource_start(pdev, 1), R8169_REGS_SIZE); |
| 1243 | if (ioaddr == NULL) { | 1403 | if (ioaddr == NULL) { |
| 1244 | printk(KERN_ERR PFX "cannot remap MMIO, aborting\n"); | 1404 | if (netif_msg_probe(tp)) |
| 1405 | printk(KERN_ERR PFX "cannot remap MMIO, aborting\n"); | ||
| 1245 | rc = -EIO; | 1406 | rc = -EIO; |
| 1246 | goto err_out_free_res; | 1407 | goto err_out_free_res; |
| 1247 | } | 1408 | } |
| @@ -1272,9 +1433,11 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out, | |||
| 1272 | } | 1433 | } |
| 1273 | if (i < 0) { | 1434 | if (i < 0) { |
| 1274 | /* Unknown chip: assume array element #0, original RTL-8169 */ | 1435 | /* Unknown chip: assume array element #0, original RTL-8169 */ |
| 1275 | printk(KERN_DEBUG PFX | 1436 | if (netif_msg_probe(tp)) { |
| 1276 | "PCI device %s: unknown chip version, assuming %s\n", | 1437 | printk(KERN_DEBUG PFX "PCI device %s: " |
| 1277 | pci_name(pdev), rtl_chip_info[0].name); | 1438 | "unknown chip version, assuming %s\n", |
| 1439 | pci_name(pdev), rtl_chip_info[0].name); | ||
| 1440 | } | ||
| 1278 | i++; | 1441 | i++; |
| 1279 | } | 1442 | } |
| 1280 | tp->chipset = i; | 1443 | tp->chipset = i; |
| @@ -1308,7 +1471,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 1308 | struct rtl8169_private *tp; | 1471 | struct rtl8169_private *tp; |
| 1309 | void __iomem *ioaddr = NULL; | 1472 | void __iomem *ioaddr = NULL; |
| 1310 | static int board_idx = -1; | 1473 | static int board_idx = -1; |
| 1311 | static int printed_version = 0; | ||
| 1312 | u8 autoneg, duplex; | 1474 | u8 autoneg, duplex; |
| 1313 | u16 speed; | 1475 | u16 speed; |
| 1314 | int i, rc; | 1476 | int i, rc; |
| @@ -1318,10 +1480,9 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 1318 | 1480 | ||
| 1319 | board_idx++; | 1481 | board_idx++; |
| 1320 | 1482 | ||
| 1321 | if (!printed_version) { | 1483 | if (netif_msg_drv(&debug)) { |
| 1322 | printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", | 1484 | printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", |
| 1323 | MODULENAME, RTL8169_VERSION); | 1485 | MODULENAME, RTL8169_VERSION); |
| 1324 | printed_version = 1; | ||
| 1325 | } | 1486 | } |
| 1326 | 1487 | ||
| 1327 | rc = rtl8169_init_board(pdev, &dev, &ioaddr); | 1488 | rc = rtl8169_init_board(pdev, &dev, &ioaddr); |
| @@ -1366,7 +1527,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 1366 | #ifdef CONFIG_R8169_NAPI | 1527 | #ifdef CONFIG_R8169_NAPI |
| 1367 | dev->poll = rtl8169_poll; | 1528 | dev->poll = rtl8169_poll; |
| 1368 | dev->weight = R8169_NAPI_WEIGHT; | 1529 | dev->weight = R8169_NAPI_WEIGHT; |
| 1369 | printk(KERN_INFO PFX "NAPI enabled\n"); | ||
| 1370 | #endif | 1530 | #endif |
| 1371 | 1531 | ||
| 1372 | #ifdef CONFIG_R8169_VLAN | 1532 | #ifdef CONFIG_R8169_VLAN |
| @@ -1391,20 +1551,24 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 1391 | return rc; | 1551 | return rc; |
| 1392 | } | 1552 | } |
| 1393 | 1553 | ||
| 1394 | printk(KERN_DEBUG "%s: Identified chip type is '%s'.\n", dev->name, | 1554 | if (netif_msg_probe(tp)) { |
| 1395 | rtl_chip_info[tp->chipset].name); | 1555 | printk(KERN_DEBUG "%s: Identified chip type is '%s'.\n", |
| 1556 | dev->name, rtl_chip_info[tp->chipset].name); | ||
| 1557 | } | ||
| 1396 | 1558 | ||
| 1397 | pci_set_drvdata(pdev, dev); | 1559 | pci_set_drvdata(pdev, dev); |
| 1398 | 1560 | ||
| 1399 | printk(KERN_INFO "%s: %s at 0x%lx, " | 1561 | if (netif_msg_probe(tp)) { |
| 1400 | "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x, " | 1562 | printk(KERN_INFO "%s: %s at 0x%lx, " |
| 1401 | "IRQ %d\n", | 1563 | "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x, " |
| 1402 | dev->name, | 1564 | "IRQ %d\n", |
| 1403 | rtl_chip_info[ent->driver_data].name, | 1565 | dev->name, |
| 1404 | dev->base_addr, | 1566 | rtl_chip_info[ent->driver_data].name, |
| 1405 | dev->dev_addr[0], dev->dev_addr[1], | 1567 | dev->base_addr, |
| 1406 | dev->dev_addr[2], dev->dev_addr[3], | 1568 | dev->dev_addr[0], dev->dev_addr[1], |
| 1407 | dev->dev_addr[4], dev->dev_addr[5], dev->irq); | 1569 | dev->dev_addr[2], dev->dev_addr[3], |
| 1570 | dev->dev_addr[4], dev->dev_addr[5], dev->irq); | ||
| 1571 | } | ||
| 1408 | 1572 | ||
| 1409 | rtl8169_hw_phy_config(dev); | 1573 | rtl8169_hw_phy_config(dev); |
| 1410 | 1574 | ||
| @@ -1427,7 +1591,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 1427 | 1591 | ||
| 1428 | rtl8169_set_speed(dev, autoneg, speed, duplex); | 1592 | rtl8169_set_speed(dev, autoneg, speed, duplex); |
| 1429 | 1593 | ||
| 1430 | if (RTL_R8(PHYstatus) & TBI_Enable) | 1594 | if ((RTL_R8(PHYstatus) & TBI_Enable) && netif_msg_link(tp)) |
| 1431 | printk(KERN_INFO PFX "%s: TBI auto-negotiating\n", dev->name); | 1595 | printk(KERN_INFO PFX "%s: TBI auto-negotiating\n", dev->name); |
| 1432 | 1596 | ||
| 1433 | return 0; | 1597 | return 0; |
| @@ -1860,8 +2024,13 @@ static void rtl8169_reinit_task(void *_data) | |||
| 1860 | ret = rtl8169_open(dev); | 2024 | ret = rtl8169_open(dev); |
| 1861 | if (unlikely(ret < 0)) { | 2025 | if (unlikely(ret < 0)) { |
| 1862 | if (net_ratelimit()) { | 2026 | if (net_ratelimit()) { |
| 1863 | printk(PFX KERN_ERR "%s: reinit failure (status = %d)." | 2027 | struct rtl8169_private *tp = netdev_priv(dev); |
| 1864 | " Rescheduling.\n", dev->name, ret); | 2028 | |
| 2029 | if (netif_msg_drv(tp)) { | ||
| 2030 | printk(PFX KERN_ERR | ||
| 2031 | "%s: reinit failure (status = %d)." | ||
| 2032 | " Rescheduling.\n", dev->name, ret); | ||
| 2033 | } | ||
| 1865 | } | 2034 | } |
| 1866 | rtl8169_schedule_work(dev, rtl8169_reinit_task); | 2035 | rtl8169_schedule_work(dev, rtl8169_reinit_task); |
| 1867 | } | 2036 | } |
| @@ -1886,8 +2055,12 @@ static void rtl8169_reset_task(void *_data) | |||
| 1886 | netif_wake_queue(dev); | 2055 | netif_wake_queue(dev); |
| 1887 | } else { | 2056 | } else { |
| 1888 | if (net_ratelimit()) { | 2057 | if (net_ratelimit()) { |
| 1889 | printk(PFX KERN_EMERG "%s: Rx buffers shortage\n", | 2058 | struct rtl8169_private *tp = netdev_priv(dev); |
| 1890 | dev->name); | 2059 | |
| 2060 | if (netif_msg_intr(tp)) { | ||
| 2061 | printk(PFX KERN_EMERG | ||
| 2062 | "%s: Rx buffers shortage\n", dev->name); | ||
| 2063 | } | ||
| 1891 | } | 2064 | } |
| 1892 | rtl8169_schedule_work(dev, rtl8169_reset_task); | 2065 | rtl8169_schedule_work(dev, rtl8169_reset_task); |
| 1893 | } | 2066 | } |
| @@ -1973,8 +2146,11 @@ static int rtl8169_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1973 | int ret = 0; | 2146 | int ret = 0; |
| 1974 | 2147 | ||
| 1975 | if (unlikely(TX_BUFFS_AVAIL(tp) < skb_shinfo(skb)->nr_frags)) { | 2148 | if (unlikely(TX_BUFFS_AVAIL(tp) < skb_shinfo(skb)->nr_frags)) { |
| 1976 | printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n", | 2149 | if (netif_msg_drv(tp)) { |
| 1977 | dev->name); | 2150 | printk(KERN_ERR |
| 2151 | "%s: BUG! Tx Ring full when queue awake!\n", | ||
| 2152 | dev->name); | ||
| 2153 | } | ||
| 1978 | goto err_stop; | 2154 | goto err_stop; |
| 1979 | } | 2155 | } |
| 1980 | 2156 | ||
| @@ -2049,8 +2225,11 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev) | |||
| 2049 | pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd); | 2225 | pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd); |
| 2050 | pci_read_config_word(pdev, PCI_STATUS, &pci_status); | 2226 | pci_read_config_word(pdev, PCI_STATUS, &pci_status); |
| 2051 | 2227 | ||
| 2052 | printk(KERN_ERR PFX "%s: PCI error (cmd = 0x%04x, status = 0x%04x).\n", | 2228 | if (netif_msg_intr(tp)) { |
| 2053 | dev->name, pci_cmd, pci_status); | 2229 | printk(KERN_ERR |
| 2230 | "%s: PCI error (cmd = 0x%04x, status = 0x%04x).\n", | ||
| 2231 | dev->name, pci_cmd, pci_status); | ||
| 2232 | } | ||
| 2054 | 2233 | ||
| 2055 | /* | 2234 | /* |
| 2056 | * The recovery sequence below admits a very elaborated explanation: | 2235 | * The recovery sequence below admits a very elaborated explanation: |
| @@ -2069,7 +2248,8 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev) | |||
| 2069 | 2248 | ||
| 2070 | /* The infamous DAC f*ckup only happens at boot time */ | 2249 | /* The infamous DAC f*ckup only happens at boot time */ |
| 2071 | if ((tp->cp_cmd & PCIDAC) && !tp->dirty_rx && !tp->cur_rx) { | 2250 | if ((tp->cp_cmd & PCIDAC) && !tp->dirty_rx && !tp->cur_rx) { |
| 2072 | printk(KERN_INFO PFX "%s: disabling PCI DAC.\n", dev->name); | 2251 | if (netif_msg_intr(tp)) |
| 2252 | printk(KERN_INFO "%s: disabling PCI DAC.\n", dev->name); | ||
| 2073 | tp->cp_cmd &= ~PCIDAC; | 2253 | tp->cp_cmd &= ~PCIDAC; |
| 2074 | RTL_W16(CPlusCmd, tp->cp_cmd); | 2254 | RTL_W16(CPlusCmd, tp->cp_cmd); |
| 2075 | dev->features &= ~NETIF_F_HIGHDMA; | 2255 | dev->features &= ~NETIF_F_HIGHDMA; |
| @@ -2180,7 +2360,7 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp, | |||
| 2180 | rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; | 2360 | rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; |
| 2181 | rx_left = rtl8169_rx_quota(rx_left, (u32) dev->quota); | 2361 | rx_left = rtl8169_rx_quota(rx_left, (u32) dev->quota); |
| 2182 | 2362 | ||
| 2183 | while (rx_left > 0) { | 2363 | for (; rx_left > 0; rx_left--, cur_rx++) { |
| 2184 | unsigned int entry = cur_rx % NUM_RX_DESC; | 2364 | unsigned int entry = cur_rx % NUM_RX_DESC; |
| 2185 | struct RxDesc *desc = tp->RxDescArray + entry; | 2365 | struct RxDesc *desc = tp->RxDescArray + entry; |
| 2186 | u32 status; | 2366 | u32 status; |
| @@ -2190,9 +2370,12 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp, | |||
| 2190 | 2370 | ||
| 2191 | if (status & DescOwn) | 2371 | if (status & DescOwn) |
| 2192 | break; | 2372 | break; |
| 2193 | if (status & RxRES) { | 2373 | if (unlikely(status & RxRES)) { |
| 2194 | printk(KERN_INFO "%s: Rx ERROR. status = %08x\n", | 2374 | if (netif_msg_rx_err(tp)) { |
| 2195 | dev->name, status); | 2375 | printk(KERN_INFO |
| 2376 | "%s: Rx ERROR. status = %08x\n", | ||
| 2377 | dev->name, status); | ||
| 2378 | } | ||
| 2196 | tp->stats.rx_errors++; | 2379 | tp->stats.rx_errors++; |
| 2197 | if (status & (RxRWT | RxRUNT)) | 2380 | if (status & (RxRWT | RxRUNT)) |
| 2198 | tp->stats.rx_length_errors++; | 2381 | tp->stats.rx_length_errors++; |
| @@ -2214,7 +2397,7 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp, | |||
| 2214 | tp->stats.rx_dropped++; | 2397 | tp->stats.rx_dropped++; |
| 2215 | tp->stats.rx_length_errors++; | 2398 | tp->stats.rx_length_errors++; |
| 2216 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); | 2399 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); |
| 2217 | goto move_on; | 2400 | continue; |
| 2218 | } | 2401 | } |
| 2219 | 2402 | ||
| 2220 | rtl8169_rx_csum(skb, desc); | 2403 | rtl8169_rx_csum(skb, desc); |
| @@ -2243,16 +2426,13 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp, | |||
| 2243 | tp->stats.rx_bytes += pkt_size; | 2426 | tp->stats.rx_bytes += pkt_size; |
| 2244 | tp->stats.rx_packets++; | 2427 | tp->stats.rx_packets++; |
| 2245 | } | 2428 | } |
| 2246 | move_on: | ||
| 2247 | cur_rx++; | ||
| 2248 | rx_left--; | ||
| 2249 | } | 2429 | } |
| 2250 | 2430 | ||
| 2251 | count = cur_rx - tp->cur_rx; | 2431 | count = cur_rx - tp->cur_rx; |
| 2252 | tp->cur_rx = cur_rx; | 2432 | tp->cur_rx = cur_rx; |
| 2253 | 2433 | ||
| 2254 | delta = rtl8169_rx_fill(tp, dev, tp->dirty_rx, tp->cur_rx); | 2434 | delta = rtl8169_rx_fill(tp, dev, tp->dirty_rx, tp->cur_rx); |
| 2255 | if (!delta && count) | 2435 | if (!delta && count && netif_msg_intr(tp)) |
| 2256 | printk(KERN_INFO "%s: no Rx buffer allocated\n", dev->name); | 2436 | printk(KERN_INFO "%s: no Rx buffer allocated\n", dev->name); |
| 2257 | tp->dirty_rx += delta; | 2437 | tp->dirty_rx += delta; |
| 2258 | 2438 | ||
| @@ -2263,7 +2443,7 @@ move_on: | |||
| 2263 | * after refill ? | 2443 | * after refill ? |
| 2264 | * - how do others driver handle this condition (Uh oh...). | 2444 | * - how do others driver handle this condition (Uh oh...). |
| 2265 | */ | 2445 | */ |
| 2266 | if (tp->dirty_rx + NUM_RX_DESC == tp->cur_rx) | 2446 | if ((tp->dirty_rx + NUM_RX_DESC == tp->cur_rx) && netif_msg_intr(tp)) |
| 2267 | printk(KERN_EMERG "%s: Rx buffers exhausted\n", dev->name); | 2447 | printk(KERN_EMERG "%s: Rx buffers exhausted\n", dev->name); |
| 2268 | 2448 | ||
| 2269 | return count; | 2449 | return count; |
| @@ -2315,7 +2495,7 @@ rtl8169_interrupt(int irq, void *dev_instance, struct pt_regs *regs) | |||
| 2315 | 2495 | ||
| 2316 | if (likely(netif_rx_schedule_prep(dev))) | 2496 | if (likely(netif_rx_schedule_prep(dev))) |
| 2317 | __netif_rx_schedule(dev); | 2497 | __netif_rx_schedule(dev); |
| 2318 | else { | 2498 | else if (netif_msg_intr(tp)) { |
| 2319 | printk(KERN_INFO "%s: interrupt %04x taken in poll\n", | 2499 | printk(KERN_INFO "%s: interrupt %04x taken in poll\n", |
| 2320 | dev->name, status); | 2500 | dev->name, status); |
| 2321 | } | 2501 | } |
| @@ -2334,8 +2514,10 @@ rtl8169_interrupt(int irq, void *dev_instance, struct pt_regs *regs) | |||
| 2334 | } while (boguscnt > 0); | 2514 | } while (boguscnt > 0); |
| 2335 | 2515 | ||
| 2336 | if (boguscnt <= 0) { | 2516 | if (boguscnt <= 0) { |
| 2337 | printk(KERN_WARNING "%s: Too much work at interrupt!\n", | 2517 | if (net_ratelimit() && netif_msg_intr(tp)) { |
| 2338 | dev->name); | 2518 | printk(KERN_WARNING |
| 2519 | "%s: Too much work at interrupt!\n", dev->name); | ||
| 2520 | } | ||
| 2339 | /* Clear all interrupt sources. */ | 2521 | /* Clear all interrupt sources. */ |
| 2340 | RTL_W16(IntrStatus, 0xffff); | 2522 | RTL_W16(IntrStatus, 0xffff); |
| 2341 | } | 2523 | } |
| @@ -2458,8 +2640,10 @@ rtl8169_set_rx_mode(struct net_device *dev) | |||
| 2458 | 2640 | ||
| 2459 | if (dev->flags & IFF_PROMISC) { | 2641 | if (dev->flags & IFF_PROMISC) { |
| 2460 | /* Unconditionally log net taps. */ | 2642 | /* Unconditionally log net taps. */ |
| 2461 | printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", | 2643 | if (netif_msg_link(tp)) { |
| 2462 | dev->name); | 2644 | printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", |
| 2645 | dev->name); | ||
| 2646 | } | ||
| 2463 | rx_mode = | 2647 | rx_mode = |
| 2464 | AcceptBroadcast | AcceptMulticast | AcceptMyPhys | | 2648 | AcceptBroadcast | AcceptMulticast | AcceptMyPhys | |
| 2465 | AcceptAllPhys; | 2649 | AcceptAllPhys; |
