diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/r8169.c | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 653b9a7a4178..5d620d81e8cb 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -6,26 +6,26 @@ | |||
6 | History: | 6 | History: |
7 | Feb 4 2002 - created initially by ShuChen <shuchen@realtek.com.tw>. | 7 | Feb 4 2002 - created initially by ShuChen <shuchen@realtek.com.tw>. |
8 | May 20 2002 - Add link status force-mode and TBI mode support. | 8 | May 20 2002 - Add link status force-mode and TBI mode support. |
9 | 2004 - Massive updates. See kernel SCM system for details. | 9 | 2004 - Massive updates. See kernel SCM system for details. |
10 | ========================================================================= | 10 | ========================================================================= |
11 | 1. [DEPRECATED: use ethtool instead] The media can be forced in 5 modes. | 11 | 1. [DEPRECATED: use ethtool instead] The media can be forced in 5 modes. |
12 | Command: 'insmod r8169 media = SET_MEDIA' | 12 | Command: 'insmod r8169 media = SET_MEDIA' |
13 | Ex: 'insmod r8169 media = 0x04' will force PHY to operate in 100Mpbs Half-duplex. | 13 | Ex: 'insmod r8169 media = 0x04' will force PHY to operate in 100Mpbs Half-duplex. |
14 | 14 | ||
15 | SET_MEDIA can be: | 15 | SET_MEDIA can be: |
16 | _10_Half = 0x01 | 16 | _10_Half = 0x01 |
17 | _10_Full = 0x02 | 17 | _10_Full = 0x02 |
18 | _100_Half = 0x04 | 18 | _100_Half = 0x04 |
19 | _100_Full = 0x08 | 19 | _100_Full = 0x08 |
20 | _1000_Full = 0x10 | 20 | _1000_Full = 0x10 |
21 | 21 | ||
22 | 2. Support TBI mode. | 22 | 2. Support TBI mode. |
23 | ========================================================================= | 23 | ========================================================================= |
24 | VERSION 1.1 <2002/10/4> | 24 | VERSION 1.1 <2002/10/4> |
25 | 25 | ||
26 | The bit4:0 of MII register 4 is called "selector field", and have to be | 26 | The bit4:0 of MII register 4 is called "selector field", and have to be |
27 | 00001b to indicate support of IEEE std 802.3 during NWay process of | 27 | 00001b to indicate support of IEEE std 802.3 during NWay process of |
28 | exchanging Link Code Word (FLP). | 28 | exchanging Link Code Word (FLP). |
29 | 29 | ||
30 | VERSION 1.2 <2002/11/30> | 30 | VERSION 1.2 <2002/11/30> |
31 | 31 | ||
@@ -81,10 +81,10 @@ VERSION 2.2LK <2005/01/25> | |||
81 | 81 | ||
82 | #ifdef RTL8169_DEBUG | 82 | #ifdef RTL8169_DEBUG |
83 | #define assert(expr) \ | 83 | #define assert(expr) \ |
84 | if(!(expr)) { \ | 84 | if (!(expr)) { \ |
85 | printk( "Assertion failed! %s,%s,%s,line=%d\n", \ | 85 | printk( "Assertion failed! %s,%s,%s,line=%d\n", \ |
86 | #expr,__FILE__,__FUNCTION__,__LINE__); \ | 86 | #expr,__FILE__,__FUNCTION__,__LINE__); \ |
87 | } | 87 | } |
88 | #define dprintk(fmt, args...) do { printk(PFX fmt, ## args); } while (0) | 88 | #define dprintk(fmt, args...) do { printk(PFX fmt, ## args); } while (0) |
89 | #else | 89 | #else |
90 | #define assert(expr) do {} while (0) | 90 | #define assert(expr) do {} while (0) |
@@ -520,7 +520,7 @@ static const u16 rtl8169_intr_mask = | |||
520 | static const u16 rtl8169_napi_event = | 520 | static const u16 rtl8169_napi_event = |
521 | RxOK | RxOverflow | RxFIFOOver | TxOK | TxErr; | 521 | RxOK | RxOverflow | RxFIFOOver | TxOK | TxErr; |
522 | static const unsigned int rtl8169_rx_config = | 522 | static const unsigned int rtl8169_rx_config = |
523 | (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift); | 523 | (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift); |
524 | 524 | ||
525 | #define PHY_Cap_10_Half_Or_Less PHY_Cap_10_Half | 525 | #define PHY_Cap_10_Half_Or_Less PHY_Cap_10_Half |
526 | #define PHY_Cap_10_Full_Or_Less PHY_Cap_10_Full | PHY_Cap_10_Half_Or_Less | 526 | #define PHY_Cap_10_Full_Or_Less PHY_Cap_10_Full | PHY_Cap_10_Half_Or_Less |
@@ -535,7 +535,7 @@ static void mdio_write(void __iomem *ioaddr, int RegAddr, int value) | |||
535 | 535 | ||
536 | for (i = 20; i > 0; i--) { | 536 | for (i = 20; i > 0; i--) { |
537 | /* Check if the RTL8169 has completed writing to the specified MII register */ | 537 | /* Check if the RTL8169 has completed writing to the specified MII register */ |
538 | if (!(RTL_R32(PHYAR) & 0x80000000)) | 538 | if (!(RTL_R32(PHYAR) & 0x80000000)) |
539 | break; | 539 | break; |
540 | udelay(25); | 540 | udelay(25); |
541 | } | 541 | } |
@@ -640,7 +640,7 @@ static void rtl8169_link_option(int idx, u8 *autoneg, u16 *speed, u8 *duplex) | |||
640 | { SPEED_1000, DUPLEX_FULL, AUTONEG_ENABLE, 0xff } | 640 | { SPEED_1000, DUPLEX_FULL, AUTONEG_ENABLE, 0xff } |
641 | }, *p; | 641 | }, *p; |
642 | unsigned char option; | 642 | unsigned char option; |
643 | 643 | ||
644 | option = ((idx < MAX_UNITS) && (idx >= 0)) ? media[idx] : 0xff; | 644 | option = ((idx < MAX_UNITS) && (idx >= 0)) ? media[idx] : 0xff; |
645 | 645 | ||
646 | if ((option != 0xff) && !idx && netif_msg_drv(&debug)) | 646 | if ((option != 0xff) && !idx && netif_msg_drv(&debug)) |
@@ -682,9 +682,9 @@ static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |||
682 | if (options & UWF) | 682 | if (options & UWF) |
683 | wol->wolopts |= WAKE_UCAST; | 683 | wol->wolopts |= WAKE_UCAST; |
684 | if (options & BWF) | 684 | if (options & BWF) |
685 | wol->wolopts |= WAKE_BCAST; | 685 | wol->wolopts |= WAKE_BCAST; |
686 | if (options & MWF) | 686 | if (options & MWF) |
687 | wol->wolopts |= WAKE_MCAST; | 687 | wol->wolopts |= WAKE_MCAST; |
688 | 688 | ||
689 | out_unlock: | 689 | out_unlock: |
690 | spin_unlock_irq(&tp->lock); | 690 | spin_unlock_irq(&tp->lock); |
@@ -855,7 +855,7 @@ static int rtl8169_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
855 | spin_lock_irqsave(&tp->lock, flags); | 855 | spin_lock_irqsave(&tp->lock, flags); |
856 | ret = rtl8169_set_speed(dev, cmd->autoneg, cmd->speed, cmd->duplex); | 856 | ret = rtl8169_set_speed(dev, cmd->autoneg, cmd->speed, cmd->duplex); |
857 | spin_unlock_irqrestore(&tp->lock, flags); | 857 | spin_unlock_irqrestore(&tp->lock, flags); |
858 | 858 | ||
859 | return ret; | 859 | return ret; |
860 | } | 860 | } |
861 | 861 | ||
@@ -988,7 +988,7 @@ static void rtl8169_gset_xmii(struct net_device *dev, struct ethtool_cmd *cmd) | |||
988 | SUPPORTED_100baseT_Full | | 988 | SUPPORTED_100baseT_Full | |
989 | SUPPORTED_1000baseT_Full | | 989 | SUPPORTED_1000baseT_Full | |
990 | SUPPORTED_Autoneg | | 990 | SUPPORTED_Autoneg | |
991 | SUPPORTED_TP; | 991 | SUPPORTED_TP; |
992 | 992 | ||
993 | cmd->autoneg = 1; | 993 | cmd->autoneg = 1; |
994 | cmd->advertising = ADVERTISED_TP | ADVERTISED_Autoneg; | 994 | cmd->advertising = ADVERTISED_TP | ADVERTISED_Autoneg; |
@@ -1038,15 +1038,15 @@ static int rtl8169_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1038 | static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs, | 1038 | static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs, |
1039 | void *p) | 1039 | void *p) |
1040 | { | 1040 | { |
1041 | struct rtl8169_private *tp = netdev_priv(dev); | 1041 | struct rtl8169_private *tp = netdev_priv(dev); |
1042 | unsigned long flags; | 1042 | unsigned long flags; |
1043 | 1043 | ||
1044 | if (regs->len > R8169_REGS_SIZE) | 1044 | if (regs->len > R8169_REGS_SIZE) |
1045 | regs->len = R8169_REGS_SIZE; | 1045 | regs->len = R8169_REGS_SIZE; |
1046 | 1046 | ||
1047 | spin_lock_irqsave(&tp->lock, flags); | 1047 | spin_lock_irqsave(&tp->lock, flags); |
1048 | memcpy_fromio(p, tp->mmio_addr, regs->len); | 1048 | memcpy_fromio(p, tp->mmio_addr, regs->len); |
1049 | spin_unlock_irqrestore(&tp->lock, flags); | 1049 | spin_unlock_irqrestore(&tp->lock, flags); |
1050 | } | 1050 | } |
1051 | 1051 | ||
1052 | static u32 rtl8169_get_msglevel(struct net_device *dev) | 1052 | static u32 rtl8169_get_msglevel(struct net_device *dev) |
@@ -1128,7 +1128,7 @@ static void rtl8169_get_ethtool_stats(struct net_device *dev, | |||
1128 | RTL_W32(CounterAddrLow, 0); | 1128 | RTL_W32(CounterAddrLow, 0); |
1129 | RTL_W32(CounterAddrHigh, 0); | 1129 | RTL_W32(CounterAddrHigh, 0); |
1130 | 1130 | ||
1131 | data[0] = le64_to_cpu(counters->tx_packets); | 1131 | data[0] = le64_to_cpu(counters->tx_packets); |
1132 | data[1] = le64_to_cpu(counters->rx_packets); | 1132 | data[1] = le64_to_cpu(counters->rx_packets); |
1133 | data[2] = le64_to_cpu(counters->tx_errors); | 1133 | data[2] = le64_to_cpu(counters->tx_errors); |
1134 | data[3] = le32_to_cpu(counters->rx_errors); | 1134 | data[3] = le32_to_cpu(counters->rx_errors); |
@@ -1188,7 +1188,7 @@ static void rtl8169_write_gmii_reg_bit(void __iomem *ioaddr, int reg, int bitnum | |||
1188 | val = mdio_read(ioaddr, reg); | 1188 | val = mdio_read(ioaddr, reg); |
1189 | val = (bitval == 1) ? | 1189 | val = (bitval == 1) ? |
1190 | val | (bitval << bitnum) : val & ~(0x0001 << bitnum); | 1190 | val | (bitval << bitnum) : val & ~(0x0001 << bitnum); |
1191 | mdio_write(ioaddr, reg, val & 0xffff); | 1191 | mdio_write(ioaddr, reg, val & 0xffff); |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | static void rtl8169_get_mac_version(struct rtl8169_private *tp, void __iomem *ioaddr) | 1194 | static void rtl8169_get_mac_version(struct rtl8169_private *tp, void __iomem *ioaddr) |
@@ -1201,7 +1201,7 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp, void __iomem *io | |||
1201 | { 0x38000000, RTL_GIGA_MAC_VER_12 }, | 1201 | { 0x38000000, RTL_GIGA_MAC_VER_12 }, |
1202 | { 0x34000000, RTL_GIGA_MAC_VER_13 }, | 1202 | { 0x34000000, RTL_GIGA_MAC_VER_13 }, |
1203 | { 0x30800000, RTL_GIGA_MAC_VER_14 }, | 1203 | { 0x30800000, RTL_GIGA_MAC_VER_14 }, |
1204 | { 0x30000000, RTL_GIGA_MAC_VER_11 }, | 1204 | { 0x30000000, RTL_GIGA_MAC_VER_11 }, |
1205 | { 0x18000000, RTL_GIGA_MAC_VER_05 }, | 1205 | { 0x18000000, RTL_GIGA_MAC_VER_05 }, |
1206 | { 0x10000000, RTL_GIGA_MAC_VER_04 }, | 1206 | { 0x10000000, RTL_GIGA_MAC_VER_04 }, |
1207 | { 0x04000000, RTL_GIGA_MAC_VER_03 }, | 1207 | { 0x04000000, RTL_GIGA_MAC_VER_03 }, |
@@ -1361,7 +1361,7 @@ static void rtl8169_phy_timer(unsigned long __opaque) | |||
1361 | spin_lock_irq(&tp->lock); | 1361 | spin_lock_irq(&tp->lock); |
1362 | 1362 | ||
1363 | if (tp->phy_reset_pending(ioaddr)) { | 1363 | if (tp->phy_reset_pending(ioaddr)) { |
1364 | /* | 1364 | /* |
1365 | * A busy loop could burn quite a few cycles on nowadays CPU. | 1365 | * A busy loop could burn quite a few cycles on nowadays CPU. |
1366 | * Let's delay the execution of the timer for a few ticks. | 1366 | * Let's delay the execution of the timer for a few ticks. |
1367 | */ | 1367 | */ |
@@ -1887,9 +1887,8 @@ rtl8169_hw_start(struct net_device *dev) | |||
1887 | RTL_W32(RxConfig, i); | 1887 | RTL_W32(RxConfig, i); |
1888 | 1888 | ||
1889 | /* Set DMA burst size and Interframe Gap Time */ | 1889 | /* Set DMA burst size and Interframe Gap Time */ |
1890 | RTL_W32(TxConfig, | 1890 | RTL_W32(TxConfig, (TX_DMA_BURST << TxDMAShift) | |
1891 | (TX_DMA_BURST << TxDMAShift) | (InterFrameGap << | 1891 | (InterFrameGap << TxInterFrameGapShift)); |
1892 | TxInterFrameGapShift)); | ||
1893 | 1892 | ||
1894 | tp->cp_cmd |= RTL_R16(CPlusCmd) | PCIMulRW; | 1893 | tp->cp_cmd |= RTL_R16(CPlusCmd) | PCIMulRW; |
1895 | 1894 | ||
@@ -2042,7 +2041,7 @@ static u32 rtl8169_rx_fill(struct rtl8169_private *tp, struct net_device *dev, | |||
2042 | u32 start, u32 end) | 2041 | u32 start, u32 end) |
2043 | { | 2042 | { |
2044 | u32 cur; | 2043 | u32 cur; |
2045 | 2044 | ||
2046 | for (cur = start; end - cur > 0; cur++) { | 2045 | for (cur = start; end - cur > 0; cur++) { |
2047 | int ret, i = cur % NUM_RX_DESC; | 2046 | int ret, i = cur % NUM_RX_DESC; |
2048 | 2047 | ||
@@ -2280,7 +2279,7 @@ static int rtl8169_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2280 | u32 status, len; | 2279 | u32 status, len; |
2281 | u32 opts1; | 2280 | u32 opts1; |
2282 | int ret = NETDEV_TX_OK; | 2281 | int ret = NETDEV_TX_OK; |
2283 | 2282 | ||
2284 | if (unlikely(TX_BUFFS_AVAIL(tp) < skb_shinfo(skb)->nr_frags)) { | 2283 | if (unlikely(TX_BUFFS_AVAIL(tp) < skb_shinfo(skb)->nr_frags)) { |
2285 | if (netif_msg_drv(tp)) { | 2284 | if (netif_msg_drv(tp)) { |
2286 | printk(KERN_ERR | 2285 | printk(KERN_ERR |
@@ -2637,7 +2636,7 @@ rtl8169_interrupt(int irq, void *dev_instance, struct pt_regs *regs) | |||
2637 | __netif_rx_schedule(dev); | 2636 | __netif_rx_schedule(dev); |
2638 | else if (netif_msg_intr(tp)) { | 2637 | else if (netif_msg_intr(tp)) { |
2639 | printk(KERN_INFO "%s: interrupt %04x taken in poll\n", | 2638 | printk(KERN_INFO "%s: interrupt %04x taken in poll\n", |
2640 | dev->name, status); | 2639 | dev->name, status); |
2641 | } | 2640 | } |
2642 | break; | 2641 | break; |
2643 | #else | 2642 | #else |
@@ -2844,7 +2843,7 @@ static struct net_device_stats *rtl8169_get_stats(struct net_device *dev) | |||
2844 | RTL_W32(RxMissed, 0); | 2843 | RTL_W32(RxMissed, 0); |
2845 | spin_unlock_irqrestore(&tp->lock, flags); | 2844 | spin_unlock_irqrestore(&tp->lock, flags); |
2846 | } | 2845 | } |
2847 | 2846 | ||
2848 | return &tp->stats; | 2847 | return &tp->stats; |
2849 | } | 2848 | } |
2850 | 2849 | ||