diff options
Diffstat (limited to 'drivers/net/r8169.c')
-rw-r--r-- | drivers/net/r8169.c | 311 |
1 files changed, 149 insertions, 162 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 0fe2fc90f207..dd8106ff35aa 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -168,7 +168,7 @@ static void rtl_hw_start_8169(struct net_device *); | |||
168 | static void rtl_hw_start_8168(struct net_device *); | 168 | static void rtl_hw_start_8168(struct net_device *); |
169 | static void rtl_hw_start_8101(struct net_device *); | 169 | static void rtl_hw_start_8101(struct net_device *); |
170 | 170 | ||
171 | static struct pci_device_id rtl8169_pci_tbl[] = { | 171 | static DEFINE_PCI_DEVICE_TABLE(rtl8169_pci_tbl) = { |
172 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 }, | 172 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 }, |
173 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 }, | 173 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 }, |
174 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 }, | 174 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 }, |
@@ -186,7 +186,12 @@ static struct pci_device_id rtl8169_pci_tbl[] = { | |||
186 | 186 | ||
187 | MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl); | 187 | MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl); |
188 | 188 | ||
189 | static int rx_copybreak = 200; | 189 | /* |
190 | * we set our copybreak very high so that we don't have | ||
191 | * to allocate 16k frames all the time (see note in | ||
192 | * rtl8169_open() | ||
193 | */ | ||
194 | static int rx_copybreak = 16383; | ||
190 | static int use_dac; | 195 | static int use_dac; |
191 | static struct { | 196 | static struct { |
192 | u32 msg_enable; | 197 | u32 msg_enable; |
@@ -744,12 +749,10 @@ static void rtl8169_check_link_status(struct net_device *dev, | |||
744 | spin_lock_irqsave(&tp->lock, flags); | 749 | spin_lock_irqsave(&tp->lock, flags); |
745 | if (tp->link_ok(ioaddr)) { | 750 | if (tp->link_ok(ioaddr)) { |
746 | netif_carrier_on(dev); | 751 | netif_carrier_on(dev); |
747 | if (netif_msg_ifup(tp)) | 752 | netif_info(tp, ifup, dev, "link up\n"); |
748 | printk(KERN_INFO PFX "%s: link up\n", dev->name); | ||
749 | } else { | 753 | } else { |
750 | if (netif_msg_ifdown(tp)) | ||
751 | printk(KERN_INFO PFX "%s: link down\n", dev->name); | ||
752 | netif_carrier_off(dev); | 754 | netif_carrier_off(dev); |
755 | netif_info(tp, ifdown, dev, "link down\n"); | ||
753 | } | 756 | } |
754 | spin_unlock_irqrestore(&tp->lock, flags); | 757 | spin_unlock_irqrestore(&tp->lock, flags); |
755 | } | 758 | } |
@@ -794,7 +797,7 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |||
794 | struct rtl8169_private *tp = netdev_priv(dev); | 797 | struct rtl8169_private *tp = netdev_priv(dev); |
795 | void __iomem *ioaddr = tp->mmio_addr; | 798 | void __iomem *ioaddr = tp->mmio_addr; |
796 | unsigned int i; | 799 | unsigned int i; |
797 | static struct { | 800 | static const struct { |
798 | u32 opt; | 801 | u32 opt; |
799 | u16 reg; | 802 | u16 reg; |
800 | u8 mask; | 803 | u8 mask; |
@@ -862,11 +865,8 @@ static int rtl8169_set_speed_tbi(struct net_device *dev, | |||
862 | } else if (autoneg == AUTONEG_ENABLE) | 865 | } else if (autoneg == AUTONEG_ENABLE) |
863 | RTL_W32(TBICSR, reg | TBINwEnable | TBINwRestart); | 866 | RTL_W32(TBICSR, reg | TBINwEnable | TBINwRestart); |
864 | else { | 867 | else { |
865 | if (netif_msg_link(tp)) { | 868 | netif_warn(tp, link, dev, |
866 | printk(KERN_WARNING "%s: " | 869 | "incorrect speed setting refused in TBI mode\n"); |
867 | "incorrect speed setting refused in TBI mode\n", | ||
868 | dev->name); | ||
869 | } | ||
870 | ret = -EOPNOTSUPP; | 870 | ret = -EOPNOTSUPP; |
871 | } | 871 | } |
872 | 872 | ||
@@ -901,9 +901,9 @@ static int rtl8169_set_speed_xmii(struct net_device *dev, | |||
901 | (tp->mac_version != RTL_GIGA_MAC_VER_15) && | 901 | (tp->mac_version != RTL_GIGA_MAC_VER_15) && |
902 | (tp->mac_version != RTL_GIGA_MAC_VER_16)) { | 902 | (tp->mac_version != RTL_GIGA_MAC_VER_16)) { |
903 | giga_ctrl |= ADVERTISE_1000FULL | ADVERTISE_1000HALF; | 903 | giga_ctrl |= ADVERTISE_1000FULL | ADVERTISE_1000HALF; |
904 | } else if (netif_msg_link(tp)) { | 904 | } else { |
905 | printk(KERN_INFO "%s: PHY does not support 1000Mbps.\n", | 905 | netif_info(tp, link, dev, |
906 | dev->name); | 906 | "PHY does not support 1000Mbps\n"); |
907 | } | 907 | } |
908 | 908 | ||
909 | bmcr = BMCR_ANENABLE | BMCR_ANRESTART; | 909 | bmcr = BMCR_ANENABLE | BMCR_ANRESTART; |
@@ -1042,14 +1042,14 @@ static void rtl8169_vlan_rx_register(struct net_device *dev, | |||
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, | 1044 | static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, |
1045 | struct sk_buff *skb) | 1045 | struct sk_buff *skb, int polling) |
1046 | { | 1046 | { |
1047 | u32 opts2 = le32_to_cpu(desc->opts2); | 1047 | u32 opts2 = le32_to_cpu(desc->opts2); |
1048 | struct vlan_group *vlgrp = tp->vlgrp; | 1048 | struct vlan_group *vlgrp = tp->vlgrp; |
1049 | int ret; | 1049 | int ret; |
1050 | 1050 | ||
1051 | if (vlgrp && (opts2 & RxVlanTag)) { | 1051 | if (vlgrp && (opts2 & RxVlanTag)) { |
1052 | vlan_hwaccel_receive_skb(skb, vlgrp, swab16(opts2 & 0xffff)); | 1052 | __vlan_hwaccel_rx(skb, vlgrp, swab16(opts2 & 0xffff), polling); |
1053 | ret = 0; | 1053 | ret = 0; |
1054 | } else | 1054 | } else |
1055 | ret = -1; | 1055 | ret = -1; |
@@ -1066,7 +1066,7 @@ static inline u32 rtl8169_tx_vlan_tag(struct rtl8169_private *tp, | |||
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, | 1068 | static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, |
1069 | struct sk_buff *skb) | 1069 | struct sk_buff *skb, int polling) |
1070 | { | 1070 | { |
1071 | return -1; | 1071 | return -1; |
1072 | } | 1072 | } |
@@ -1277,7 +1277,7 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp, | |||
1277 | * | 1277 | * |
1278 | * (RTL_R32(TxConfig) & 0x700000) == 0x200000 ? 8101Eb : 8101Ec | 1278 | * (RTL_R32(TxConfig) & 0x700000) == 0x200000 ? 8101Eb : 8101Ec |
1279 | */ | 1279 | */ |
1280 | const struct { | 1280 | static const struct { |
1281 | u32 mask; | 1281 | u32 mask; |
1282 | u32 val; | 1282 | u32 val; |
1283 | int mac_version; | 1283 | int mac_version; |
@@ -1351,7 +1351,7 @@ struct phy_reg { | |||
1351 | u16 val; | 1351 | u16 val; |
1352 | }; | 1352 | }; |
1353 | 1353 | ||
1354 | static void rtl_phy_write(void __iomem *ioaddr, struct phy_reg *regs, int len) | 1354 | static void rtl_phy_write(void __iomem *ioaddr, const struct phy_reg *regs, int len) |
1355 | { | 1355 | { |
1356 | while (len-- > 0) { | 1356 | while (len-- > 0) { |
1357 | mdio_write(ioaddr, regs->reg, regs->val); | 1357 | mdio_write(ioaddr, regs->reg, regs->val); |
@@ -1361,7 +1361,7 @@ static void rtl_phy_write(void __iomem *ioaddr, struct phy_reg *regs, int len) | |||
1361 | 1361 | ||
1362 | static void rtl8169s_hw_phy_config(void __iomem *ioaddr) | 1362 | static void rtl8169s_hw_phy_config(void __iomem *ioaddr) |
1363 | { | 1363 | { |
1364 | struct phy_reg phy_reg_init[] = { | 1364 | static const struct phy_reg phy_reg_init[] = { |
1365 | { 0x1f, 0x0001 }, | 1365 | { 0x1f, 0x0001 }, |
1366 | { 0x06, 0x006e }, | 1366 | { 0x06, 0x006e }, |
1367 | { 0x08, 0x0708 }, | 1367 | { 0x08, 0x0708 }, |
@@ -1428,7 +1428,7 @@ static void rtl8169s_hw_phy_config(void __iomem *ioaddr) | |||
1428 | 1428 | ||
1429 | static void rtl8169sb_hw_phy_config(void __iomem *ioaddr) | 1429 | static void rtl8169sb_hw_phy_config(void __iomem *ioaddr) |
1430 | { | 1430 | { |
1431 | struct phy_reg phy_reg_init[] = { | 1431 | static const struct phy_reg phy_reg_init[] = { |
1432 | { 0x1f, 0x0002 }, | 1432 | { 0x1f, 0x0002 }, |
1433 | { 0x01, 0x90d0 }, | 1433 | { 0x01, 0x90d0 }, |
1434 | { 0x1f, 0x0000 } | 1434 | { 0x1f, 0x0000 } |
@@ -1457,7 +1457,7 @@ static void rtl8169scd_hw_phy_config_quirk(struct rtl8169_private *tp, | |||
1457 | static void rtl8169scd_hw_phy_config(struct rtl8169_private *tp, | 1457 | static void rtl8169scd_hw_phy_config(struct rtl8169_private *tp, |
1458 | void __iomem *ioaddr) | 1458 | void __iomem *ioaddr) |
1459 | { | 1459 | { |
1460 | struct phy_reg phy_reg_init[] = { | 1460 | static const struct phy_reg phy_reg_init[] = { |
1461 | { 0x1f, 0x0001 }, | 1461 | { 0x1f, 0x0001 }, |
1462 | { 0x04, 0x0000 }, | 1462 | { 0x04, 0x0000 }, |
1463 | { 0x03, 0x00a1 }, | 1463 | { 0x03, 0x00a1 }, |
@@ -1504,7 +1504,7 @@ static void rtl8169scd_hw_phy_config(struct rtl8169_private *tp, | |||
1504 | 1504 | ||
1505 | static void rtl8169sce_hw_phy_config(void __iomem *ioaddr) | 1505 | static void rtl8169sce_hw_phy_config(void __iomem *ioaddr) |
1506 | { | 1506 | { |
1507 | struct phy_reg phy_reg_init[] = { | 1507 | static const struct phy_reg phy_reg_init[] = { |
1508 | { 0x1f, 0x0001 }, | 1508 | { 0x1f, 0x0001 }, |
1509 | { 0x04, 0x0000 }, | 1509 | { 0x04, 0x0000 }, |
1510 | { 0x03, 0x00a1 }, | 1510 | { 0x03, 0x00a1 }, |
@@ -1557,7 +1557,7 @@ static void rtl8169sce_hw_phy_config(void __iomem *ioaddr) | |||
1557 | 1557 | ||
1558 | static void rtl8168bb_hw_phy_config(void __iomem *ioaddr) | 1558 | static void rtl8168bb_hw_phy_config(void __iomem *ioaddr) |
1559 | { | 1559 | { |
1560 | struct phy_reg phy_reg_init[] = { | 1560 | static const struct phy_reg phy_reg_init[] = { |
1561 | { 0x10, 0xf41b }, | 1561 | { 0x10, 0xf41b }, |
1562 | { 0x1f, 0x0000 } | 1562 | { 0x1f, 0x0000 } |
1563 | }; | 1563 | }; |
@@ -1570,7 +1570,7 @@ static void rtl8168bb_hw_phy_config(void __iomem *ioaddr) | |||
1570 | 1570 | ||
1571 | static void rtl8168bef_hw_phy_config(void __iomem *ioaddr) | 1571 | static void rtl8168bef_hw_phy_config(void __iomem *ioaddr) |
1572 | { | 1572 | { |
1573 | struct phy_reg phy_reg_init[] = { | 1573 | static const struct phy_reg phy_reg_init[] = { |
1574 | { 0x1f, 0x0001 }, | 1574 | { 0x1f, 0x0001 }, |
1575 | { 0x10, 0xf41b }, | 1575 | { 0x10, 0xf41b }, |
1576 | { 0x1f, 0x0000 } | 1576 | { 0x1f, 0x0000 } |
@@ -1581,7 +1581,7 @@ static void rtl8168bef_hw_phy_config(void __iomem *ioaddr) | |||
1581 | 1581 | ||
1582 | static void rtl8168cp_1_hw_phy_config(void __iomem *ioaddr) | 1582 | static void rtl8168cp_1_hw_phy_config(void __iomem *ioaddr) |
1583 | { | 1583 | { |
1584 | struct phy_reg phy_reg_init[] = { | 1584 | static const struct phy_reg phy_reg_init[] = { |
1585 | { 0x1f, 0x0000 }, | 1585 | { 0x1f, 0x0000 }, |
1586 | { 0x1d, 0x0f00 }, | 1586 | { 0x1d, 0x0f00 }, |
1587 | { 0x1f, 0x0002 }, | 1587 | { 0x1f, 0x0002 }, |
@@ -1594,7 +1594,7 @@ static void rtl8168cp_1_hw_phy_config(void __iomem *ioaddr) | |||
1594 | 1594 | ||
1595 | static void rtl8168cp_2_hw_phy_config(void __iomem *ioaddr) | 1595 | static void rtl8168cp_2_hw_phy_config(void __iomem *ioaddr) |
1596 | { | 1596 | { |
1597 | struct phy_reg phy_reg_init[] = { | 1597 | static const struct phy_reg phy_reg_init[] = { |
1598 | { 0x1f, 0x0001 }, | 1598 | { 0x1f, 0x0001 }, |
1599 | { 0x1d, 0x3d98 }, | 1599 | { 0x1d, 0x3d98 }, |
1600 | { 0x1f, 0x0000 } | 1600 | { 0x1f, 0x0000 } |
@@ -1609,7 +1609,7 @@ static void rtl8168cp_2_hw_phy_config(void __iomem *ioaddr) | |||
1609 | 1609 | ||
1610 | static void rtl8168c_1_hw_phy_config(void __iomem *ioaddr) | 1610 | static void rtl8168c_1_hw_phy_config(void __iomem *ioaddr) |
1611 | { | 1611 | { |
1612 | struct phy_reg phy_reg_init[] = { | 1612 | static const struct phy_reg phy_reg_init[] = { |
1613 | { 0x1f, 0x0001 }, | 1613 | { 0x1f, 0x0001 }, |
1614 | { 0x12, 0x2300 }, | 1614 | { 0x12, 0x2300 }, |
1615 | { 0x1f, 0x0002 }, | 1615 | { 0x1f, 0x0002 }, |
@@ -1638,7 +1638,7 @@ static void rtl8168c_1_hw_phy_config(void __iomem *ioaddr) | |||
1638 | 1638 | ||
1639 | static void rtl8168c_2_hw_phy_config(void __iomem *ioaddr) | 1639 | static void rtl8168c_2_hw_phy_config(void __iomem *ioaddr) |
1640 | { | 1640 | { |
1641 | struct phy_reg phy_reg_init[] = { | 1641 | static const struct phy_reg phy_reg_init[] = { |
1642 | { 0x1f, 0x0001 }, | 1642 | { 0x1f, 0x0001 }, |
1643 | { 0x12, 0x2300 }, | 1643 | { 0x12, 0x2300 }, |
1644 | { 0x03, 0x802f }, | 1644 | { 0x03, 0x802f }, |
@@ -1666,7 +1666,7 @@ static void rtl8168c_2_hw_phy_config(void __iomem *ioaddr) | |||
1666 | 1666 | ||
1667 | static void rtl8168c_3_hw_phy_config(void __iomem *ioaddr) | 1667 | static void rtl8168c_3_hw_phy_config(void __iomem *ioaddr) |
1668 | { | 1668 | { |
1669 | struct phy_reg phy_reg_init[] = { | 1669 | static const struct phy_reg phy_reg_init[] = { |
1670 | { 0x1f, 0x0001 }, | 1670 | { 0x1f, 0x0001 }, |
1671 | { 0x12, 0x2300 }, | 1671 | { 0x12, 0x2300 }, |
1672 | { 0x1d, 0x3d98 }, | 1672 | { 0x1d, 0x3d98 }, |
@@ -1693,7 +1693,7 @@ static void rtl8168c_4_hw_phy_config(void __iomem *ioaddr) | |||
1693 | 1693 | ||
1694 | static void rtl8168d_1_hw_phy_config(void __iomem *ioaddr) | 1694 | static void rtl8168d_1_hw_phy_config(void __iomem *ioaddr) |
1695 | { | 1695 | { |
1696 | static struct phy_reg phy_reg_init_0[] = { | 1696 | static const struct phy_reg phy_reg_init_0[] = { |
1697 | { 0x1f, 0x0001 }, | 1697 | { 0x1f, 0x0001 }, |
1698 | { 0x06, 0x4064 }, | 1698 | { 0x06, 0x4064 }, |
1699 | { 0x07, 0x2863 }, | 1699 | { 0x07, 0x2863 }, |
@@ -1712,14 +1712,14 @@ static void rtl8168d_1_hw_phy_config(void __iomem *ioaddr) | |||
1712 | { 0x1a, 0x05ad }, | 1712 | { 0x1a, 0x05ad }, |
1713 | { 0x14, 0x94c0 } | 1713 | { 0x14, 0x94c0 } |
1714 | }; | 1714 | }; |
1715 | static struct phy_reg phy_reg_init_1[] = { | 1715 | static const struct phy_reg phy_reg_init_1[] = { |
1716 | { 0x1f, 0x0002 }, | 1716 | { 0x1f, 0x0002 }, |
1717 | { 0x06, 0x5561 }, | 1717 | { 0x06, 0x5561 }, |
1718 | { 0x1f, 0x0005 }, | 1718 | { 0x1f, 0x0005 }, |
1719 | { 0x05, 0x8332 }, | 1719 | { 0x05, 0x8332 }, |
1720 | { 0x06, 0x5561 } | 1720 | { 0x06, 0x5561 } |
1721 | }; | 1721 | }; |
1722 | static struct phy_reg phy_reg_init_2[] = { | 1722 | static const struct phy_reg phy_reg_init_2[] = { |
1723 | { 0x1f, 0x0005 }, | 1723 | { 0x1f, 0x0005 }, |
1724 | { 0x05, 0xffc2 }, | 1724 | { 0x05, 0xffc2 }, |
1725 | { 0x1f, 0x0005 }, | 1725 | { 0x1f, 0x0005 }, |
@@ -2084,7 +2084,7 @@ static void rtl8168d_1_hw_phy_config(void __iomem *ioaddr) | |||
2084 | rtl_phy_write(ioaddr, phy_reg_init_1, ARRAY_SIZE(phy_reg_init_1)); | 2084 | rtl_phy_write(ioaddr, phy_reg_init_1, ARRAY_SIZE(phy_reg_init_1)); |
2085 | 2085 | ||
2086 | if (rtl8168d_efuse_read(ioaddr, 0x01) == 0xb1) { | 2086 | if (rtl8168d_efuse_read(ioaddr, 0x01) == 0xb1) { |
2087 | struct phy_reg phy_reg_init[] = { | 2087 | static const struct phy_reg phy_reg_init[] = { |
2088 | { 0x1f, 0x0002 }, | 2088 | { 0x1f, 0x0002 }, |
2089 | { 0x05, 0x669a }, | 2089 | { 0x05, 0x669a }, |
2090 | { 0x1f, 0x0005 }, | 2090 | { 0x1f, 0x0005 }, |
@@ -2099,7 +2099,7 @@ static void rtl8168d_1_hw_phy_config(void __iomem *ioaddr) | |||
2099 | val = mdio_read(ioaddr, 0x0d); | 2099 | val = mdio_read(ioaddr, 0x0d); |
2100 | 2100 | ||
2101 | if ((val & 0x00ff) != 0x006c) { | 2101 | if ((val & 0x00ff) != 0x006c) { |
2102 | u32 set[] = { | 2102 | static const u32 set[] = { |
2103 | 0x0065, 0x0066, 0x0067, 0x0068, | 2103 | 0x0065, 0x0066, 0x0067, 0x0068, |
2104 | 0x0069, 0x006a, 0x006b, 0x006c | 2104 | 0x0069, 0x006a, 0x006b, 0x006c |
2105 | }; | 2105 | }; |
@@ -2112,7 +2112,7 @@ static void rtl8168d_1_hw_phy_config(void __iomem *ioaddr) | |||
2112 | mdio_write(ioaddr, 0x0d, val | set[i]); | 2112 | mdio_write(ioaddr, 0x0d, val | set[i]); |
2113 | } | 2113 | } |
2114 | } else { | 2114 | } else { |
2115 | struct phy_reg phy_reg_init[] = { | 2115 | static const struct phy_reg phy_reg_init[] = { |
2116 | { 0x1f, 0x0002 }, | 2116 | { 0x1f, 0x0002 }, |
2117 | { 0x05, 0x6662 }, | 2117 | { 0x05, 0x6662 }, |
2118 | { 0x1f, 0x0005 }, | 2118 | { 0x1f, 0x0005 }, |
@@ -2136,7 +2136,7 @@ static void rtl8168d_1_hw_phy_config(void __iomem *ioaddr) | |||
2136 | 2136 | ||
2137 | static void rtl8168d_2_hw_phy_config(void __iomem *ioaddr) | 2137 | static void rtl8168d_2_hw_phy_config(void __iomem *ioaddr) |
2138 | { | 2138 | { |
2139 | static struct phy_reg phy_reg_init_0[] = { | 2139 | static const struct phy_reg phy_reg_init_0[] = { |
2140 | { 0x1f, 0x0001 }, | 2140 | { 0x1f, 0x0001 }, |
2141 | { 0x06, 0x4064 }, | 2141 | { 0x06, 0x4064 }, |
2142 | { 0x07, 0x2863 }, | 2142 | { 0x07, 0x2863 }, |
@@ -2161,7 +2161,7 @@ static void rtl8168d_2_hw_phy_config(void __iomem *ioaddr) | |||
2161 | { 0x05, 0x8332 }, | 2161 | { 0x05, 0x8332 }, |
2162 | { 0x06, 0x5561 } | 2162 | { 0x06, 0x5561 } |
2163 | }; | 2163 | }; |
2164 | static struct phy_reg phy_reg_init_1[] = { | 2164 | static const struct phy_reg phy_reg_init_1[] = { |
2165 | { 0x1f, 0x0005 }, | 2165 | { 0x1f, 0x0005 }, |
2166 | { 0x05, 0xffc2 }, | 2166 | { 0x05, 0xffc2 }, |
2167 | { 0x1f, 0x0005 }, | 2167 | { 0x1f, 0x0005 }, |
@@ -2477,7 +2477,7 @@ static void rtl8168d_2_hw_phy_config(void __iomem *ioaddr) | |||
2477 | rtl_phy_write(ioaddr, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0)); | 2477 | rtl_phy_write(ioaddr, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0)); |
2478 | 2478 | ||
2479 | if (rtl8168d_efuse_read(ioaddr, 0x01) == 0xb1) { | 2479 | if (rtl8168d_efuse_read(ioaddr, 0x01) == 0xb1) { |
2480 | struct phy_reg phy_reg_init[] = { | 2480 | static const struct phy_reg phy_reg_init[] = { |
2481 | { 0x1f, 0x0002 }, | 2481 | { 0x1f, 0x0002 }, |
2482 | { 0x05, 0x669a }, | 2482 | { 0x05, 0x669a }, |
2483 | { 0x1f, 0x0005 }, | 2483 | { 0x1f, 0x0005 }, |
@@ -2505,7 +2505,7 @@ static void rtl8168d_2_hw_phy_config(void __iomem *ioaddr) | |||
2505 | mdio_write(ioaddr, 0x0d, val | set[i]); | 2505 | mdio_write(ioaddr, 0x0d, val | set[i]); |
2506 | } | 2506 | } |
2507 | } else { | 2507 | } else { |
2508 | struct phy_reg phy_reg_init[] = { | 2508 | static const struct phy_reg phy_reg_init[] = { |
2509 | { 0x1f, 0x0002 }, | 2509 | { 0x1f, 0x0002 }, |
2510 | { 0x05, 0x2642 }, | 2510 | { 0x05, 0x2642 }, |
2511 | { 0x1f, 0x0005 }, | 2511 | { 0x1f, 0x0005 }, |
@@ -2531,7 +2531,7 @@ static void rtl8168d_2_hw_phy_config(void __iomem *ioaddr) | |||
2531 | 2531 | ||
2532 | static void rtl8168d_3_hw_phy_config(void __iomem *ioaddr) | 2532 | static void rtl8168d_3_hw_phy_config(void __iomem *ioaddr) |
2533 | { | 2533 | { |
2534 | struct phy_reg phy_reg_init[] = { | 2534 | static const struct phy_reg phy_reg_init[] = { |
2535 | { 0x1f, 0x0002 }, | 2535 | { 0x1f, 0x0002 }, |
2536 | { 0x10, 0x0008 }, | 2536 | { 0x10, 0x0008 }, |
2537 | { 0x0d, 0x006c }, | 2537 | { 0x0d, 0x006c }, |
@@ -2592,7 +2592,7 @@ static void rtl8168d_3_hw_phy_config(void __iomem *ioaddr) | |||
2592 | 2592 | ||
2593 | static void rtl8102e_hw_phy_config(void __iomem *ioaddr) | 2593 | static void rtl8102e_hw_phy_config(void __iomem *ioaddr) |
2594 | { | 2594 | { |
2595 | struct phy_reg phy_reg_init[] = { | 2595 | static const struct phy_reg phy_reg_init[] = { |
2596 | { 0x1f, 0x0003 }, | 2596 | { 0x1f, 0x0003 }, |
2597 | { 0x08, 0x441d }, | 2597 | { 0x08, 0x441d }, |
2598 | { 0x01, 0x9100 }, | 2598 | { 0x01, 0x9100 }, |
@@ -2705,8 +2705,7 @@ static void rtl8169_phy_timer(unsigned long __opaque) | |||
2705 | if (tp->link_ok(ioaddr)) | 2705 | if (tp->link_ok(ioaddr)) |
2706 | goto out_unlock; | 2706 | goto out_unlock; |
2707 | 2707 | ||
2708 | if (netif_msg_link(tp)) | 2708 | netif_warn(tp, link, dev, "PHY reset until link up\n"); |
2709 | printk(KERN_WARNING "%s: PHY reset until link up\n", dev->name); | ||
2710 | 2709 | ||
2711 | tp->phy_reset_enable(ioaddr); | 2710 | tp->phy_reset_enable(ioaddr); |
2712 | 2711 | ||
@@ -2760,6 +2759,7 @@ static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev, | |||
2760 | { | 2759 | { |
2761 | iounmap(ioaddr); | 2760 | iounmap(ioaddr); |
2762 | pci_release_regions(pdev); | 2761 | pci_release_regions(pdev); |
2762 | pci_clear_mwi(pdev); | ||
2763 | pci_disable_device(pdev); | 2763 | pci_disable_device(pdev); |
2764 | free_netdev(dev); | 2764 | free_netdev(dev); |
2765 | } | 2765 | } |
@@ -2776,8 +2776,7 @@ static void rtl8169_phy_reset(struct net_device *dev, | |||
2776 | return; | 2776 | return; |
2777 | msleep(1); | 2777 | msleep(1); |
2778 | } | 2778 | } |
2779 | if (netif_msg_link(tp)) | 2779 | netif_err(tp, link, dev, "PHY reset failed\n"); |
2780 | printk(KERN_ERR "%s: PHY reset failed.\n", dev->name); | ||
2781 | } | 2780 | } |
2782 | 2781 | ||
2783 | static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) | 2782 | static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) |
@@ -2811,8 +2810,8 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) | |||
2811 | */ | 2810 | */ |
2812 | rtl8169_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL); | 2811 | rtl8169_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL); |
2813 | 2812 | ||
2814 | if ((RTL_R8(PHYstatus) & TBI_Enable) && netif_msg_link(tp)) | 2813 | if (RTL_R8(PHYstatus) & TBI_Enable) |
2815 | printk(KERN_INFO PFX "%s: TBI auto-negotiating\n", dev->name); | 2814 | netif_info(tp, link, dev, "TBI auto-negotiating\n"); |
2816 | } | 2815 | } |
2817 | 2816 | ||
2818 | static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr) | 2817 | static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr) |
@@ -2827,8 +2826,13 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr) | |||
2827 | spin_lock_irq(&tp->lock); | 2826 | spin_lock_irq(&tp->lock); |
2828 | 2827 | ||
2829 | RTL_W8(Cfg9346, Cfg9346_Unlock); | 2828 | RTL_W8(Cfg9346, Cfg9346_Unlock); |
2830 | RTL_W32(MAC0, low); | 2829 | |
2831 | RTL_W32(MAC4, high); | 2830 | RTL_W32(MAC4, high); |
2831 | RTL_R32(MAC4); | ||
2832 | |||
2833 | RTL_W32(MAC0, low); | ||
2834 | RTL_R32(MAC0); | ||
2835 | |||
2832 | RTL_W8(Cfg9346, Cfg9346_Lock); | 2836 | RTL_W8(Cfg9346, Cfg9346_Lock); |
2833 | 2837 | ||
2834 | spin_unlock_irq(&tp->lock); | 2838 | spin_unlock_irq(&tp->lock); |
@@ -3012,41 +3016,34 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3012 | /* enable device (incl. PCI PM wakeup and hotplug setup) */ | 3016 | /* enable device (incl. PCI PM wakeup and hotplug setup) */ |
3013 | rc = pci_enable_device(pdev); | 3017 | rc = pci_enable_device(pdev); |
3014 | if (rc < 0) { | 3018 | if (rc < 0) { |
3015 | if (netif_msg_probe(tp)) | 3019 | netif_err(tp, probe, dev, "enable failure\n"); |
3016 | dev_err(&pdev->dev, "enable failure\n"); | ||
3017 | goto err_out_free_dev_1; | 3020 | goto err_out_free_dev_1; |
3018 | } | 3021 | } |
3019 | 3022 | ||
3020 | rc = pci_set_mwi(pdev); | 3023 | if (pci_set_mwi(pdev) < 0) |
3021 | if (rc < 0) | 3024 | netif_info(tp, probe, dev, "Mem-Wr-Inval unavailable\n"); |
3022 | goto err_out_disable_2; | ||
3023 | 3025 | ||
3024 | /* make sure PCI base addr 1 is MMIO */ | 3026 | /* make sure PCI base addr 1 is MMIO */ |
3025 | if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) { | 3027 | if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) { |
3026 | if (netif_msg_probe(tp)) { | 3028 | netif_err(tp, probe, dev, |
3027 | dev_err(&pdev->dev, | 3029 | "region #%d not an MMIO resource, aborting\n", |
3028 | "region #%d not an MMIO resource, aborting\n", | 3030 | region); |
3029 | region); | ||
3030 | } | ||
3031 | rc = -ENODEV; | 3031 | rc = -ENODEV; |
3032 | goto err_out_mwi_3; | 3032 | goto err_out_mwi_2; |
3033 | } | 3033 | } |
3034 | 3034 | ||
3035 | /* check for weird/broken PCI region reporting */ | 3035 | /* check for weird/broken PCI region reporting */ |
3036 | if (pci_resource_len(pdev, region) < R8169_REGS_SIZE) { | 3036 | if (pci_resource_len(pdev, region) < R8169_REGS_SIZE) { |
3037 | if (netif_msg_probe(tp)) { | 3037 | netif_err(tp, probe, dev, |
3038 | dev_err(&pdev->dev, | 3038 | "Invalid PCI region size(s), aborting\n"); |
3039 | "Invalid PCI region size(s), aborting\n"); | ||
3040 | } | ||
3041 | rc = -ENODEV; | 3039 | rc = -ENODEV; |
3042 | goto err_out_mwi_3; | 3040 | goto err_out_mwi_2; |
3043 | } | 3041 | } |
3044 | 3042 | ||
3045 | rc = pci_request_regions(pdev, MODULENAME); | 3043 | rc = pci_request_regions(pdev, MODULENAME); |
3046 | if (rc < 0) { | 3044 | if (rc < 0) { |
3047 | if (netif_msg_probe(tp)) | 3045 | netif_err(tp, probe, dev, "could not request regions\n"); |
3048 | dev_err(&pdev->dev, "could not request regions.\n"); | 3046 | goto err_out_mwi_2; |
3049 | goto err_out_mwi_3; | ||
3050 | } | 3047 | } |
3051 | 3048 | ||
3052 | tp->cp_cmd = PCIMulRW | RxChkSum; | 3049 | tp->cp_cmd = PCIMulRW | RxChkSum; |
@@ -3058,26 +3055,22 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3058 | } else { | 3055 | } else { |
3059 | rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); | 3056 | rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
3060 | if (rc < 0) { | 3057 | if (rc < 0) { |
3061 | if (netif_msg_probe(tp)) { | 3058 | netif_err(tp, probe, dev, "DMA configuration failed\n"); |
3062 | dev_err(&pdev->dev, | 3059 | goto err_out_free_res_3; |
3063 | "DMA configuration failed.\n"); | ||
3064 | } | ||
3065 | goto err_out_free_res_4; | ||
3066 | } | 3060 | } |
3067 | } | 3061 | } |
3068 | 3062 | ||
3069 | /* ioremap MMIO region */ | 3063 | /* ioremap MMIO region */ |
3070 | ioaddr = ioremap(pci_resource_start(pdev, region), R8169_REGS_SIZE); | 3064 | ioaddr = ioremap(pci_resource_start(pdev, region), R8169_REGS_SIZE); |
3071 | if (!ioaddr) { | 3065 | if (!ioaddr) { |
3072 | if (netif_msg_probe(tp)) | 3066 | netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n"); |
3073 | dev_err(&pdev->dev, "cannot remap MMIO, aborting\n"); | ||
3074 | rc = -EIO; | 3067 | rc = -EIO; |
3075 | goto err_out_free_res_4; | 3068 | goto err_out_free_res_3; |
3076 | } | 3069 | } |
3077 | 3070 | ||
3078 | tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); | 3071 | tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); |
3079 | if (!tp->pcie_cap && netif_msg_probe(tp)) | 3072 | if (!tp->pcie_cap) |
3080 | dev_info(&pdev->dev, "no PCI Express capability\n"); | 3073 | netif_info(tp, probe, dev, "no PCI Express capability\n"); |
3081 | 3074 | ||
3082 | RTL_W16(IntrMask, 0x0000); | 3075 | RTL_W16(IntrMask, 0x0000); |
3083 | 3076 | ||
@@ -3100,10 +3093,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3100 | 3093 | ||
3101 | /* Use appropriate default if unknown */ | 3094 | /* Use appropriate default if unknown */ |
3102 | if (tp->mac_version == RTL_GIGA_MAC_NONE) { | 3095 | if (tp->mac_version == RTL_GIGA_MAC_NONE) { |
3103 | if (netif_msg_probe(tp)) { | 3096 | netif_notice(tp, probe, dev, |
3104 | dev_notice(&pdev->dev, | 3097 | "unknown MAC, using family default\n"); |
3105 | "unknown MAC, using family default\n"); | ||
3106 | } | ||
3107 | tp->mac_version = cfg->default_ver; | 3098 | tp->mac_version = cfg->default_ver; |
3108 | } | 3099 | } |
3109 | 3100 | ||
@@ -3116,7 +3107,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3116 | if (i == ARRAY_SIZE(rtl_chip_info)) { | 3107 | if (i == ARRAY_SIZE(rtl_chip_info)) { |
3117 | dev_err(&pdev->dev, | 3108 | dev_err(&pdev->dev, |
3118 | "driver bug, MAC version not found in rtl_chip_info\n"); | 3109 | "driver bug, MAC version not found in rtl_chip_info\n"); |
3119 | goto err_out_msi_5; | 3110 | goto err_out_msi_4; |
3120 | } | 3111 | } |
3121 | tp->chipset = i; | 3112 | tp->chipset = i; |
3122 | 3113 | ||
@@ -3181,23 +3172,14 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3181 | 3172 | ||
3182 | rc = register_netdev(dev); | 3173 | rc = register_netdev(dev); |
3183 | if (rc < 0) | 3174 | if (rc < 0) |
3184 | goto err_out_msi_5; | 3175 | goto err_out_msi_4; |
3185 | 3176 | ||
3186 | pci_set_drvdata(pdev, dev); | 3177 | pci_set_drvdata(pdev, dev); |
3187 | 3178 | ||
3188 | if (netif_msg_probe(tp)) { | 3179 | netif_info(tp, probe, dev, "%s at 0x%lx, %pM, XID %08x IRQ %d\n", |
3189 | u32 xid = RTL_R32(TxConfig) & 0x9cf0f8ff; | 3180 | rtl_chip_info[tp->chipset].name, |
3190 | 3181 | dev->base_addr, dev->dev_addr, | |
3191 | printk(KERN_INFO "%s: %s at 0x%lx, " | 3182 | (u32)(RTL_R32(TxConfig) & 0x9cf0f8ff), dev->irq); |
3192 | "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x, " | ||
3193 | "XID %08x IRQ %d\n", | ||
3194 | dev->name, | ||
3195 | rtl_chip_info[tp->chipset].name, | ||
3196 | dev->base_addr, | ||
3197 | dev->dev_addr[0], dev->dev_addr[1], | ||
3198 | dev->dev_addr[2], dev->dev_addr[3], | ||
3199 | dev->dev_addr[4], dev->dev_addr[5], xid, dev->irq); | ||
3200 | } | ||
3201 | 3183 | ||
3202 | rtl8169_init_phy(dev, tp); | 3184 | rtl8169_init_phy(dev, tp); |
3203 | 3185 | ||
@@ -3213,14 +3195,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3213 | out: | 3195 | out: |
3214 | return rc; | 3196 | return rc; |
3215 | 3197 | ||
3216 | err_out_msi_5: | 3198 | err_out_msi_4: |
3217 | rtl_disable_msi(pdev, tp); | 3199 | rtl_disable_msi(pdev, tp); |
3218 | iounmap(ioaddr); | 3200 | iounmap(ioaddr); |
3219 | err_out_free_res_4: | 3201 | err_out_free_res_3: |
3220 | pci_release_regions(pdev); | 3202 | pci_release_regions(pdev); |
3221 | err_out_mwi_3: | 3203 | err_out_mwi_2: |
3222 | pci_clear_mwi(pdev); | 3204 | pci_clear_mwi(pdev); |
3223 | err_out_disable_2: | ||
3224 | pci_disable_device(pdev); | 3205 | pci_disable_device(pdev); |
3225 | err_out_free_dev_1: | 3206 | err_out_free_dev_1: |
3226 | free_netdev(dev); | 3207 | free_netdev(dev); |
@@ -3245,9 +3226,13 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) | |||
3245 | } | 3226 | } |
3246 | 3227 | ||
3247 | static void rtl8169_set_rxbufsize(struct rtl8169_private *tp, | 3228 | static void rtl8169_set_rxbufsize(struct rtl8169_private *tp, |
3248 | struct net_device *dev) | 3229 | unsigned int mtu) |
3249 | { | 3230 | { |
3250 | unsigned int max_frame = dev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN; | 3231 | unsigned int max_frame = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN; |
3232 | |||
3233 | if (max_frame != 16383) | ||
3234 | printk(KERN_WARNING PFX "WARNING! Changing of MTU on this " | ||
3235 | "NIC may lead to frame reception errors!\n"); | ||
3251 | 3236 | ||
3252 | tp->rx_buf_sz = (max_frame > RX_BUF_SIZE) ? max_frame : RX_BUF_SIZE; | 3237 | tp->rx_buf_sz = (max_frame > RX_BUF_SIZE) ? max_frame : RX_BUF_SIZE; |
3253 | } | 3238 | } |
@@ -3259,7 +3244,17 @@ static int rtl8169_open(struct net_device *dev) | |||
3259 | int retval = -ENOMEM; | 3244 | int retval = -ENOMEM; |
3260 | 3245 | ||
3261 | 3246 | ||
3262 | rtl8169_set_rxbufsize(tp, dev); | 3247 | /* |
3248 | * Note that we use a magic value here, its wierd I know | ||
3249 | * its done because, some subset of rtl8169 hardware suffers from | ||
3250 | * a problem in which frames received that are longer than | ||
3251 | * the size set in RxMaxSize register return garbage sizes | ||
3252 | * when received. To avoid this we need to turn off filtering, | ||
3253 | * which is done by setting a value of 16383 in the RxMaxSize register | ||
3254 | * and allocating 16k frames to handle the largest possible rx value | ||
3255 | * thats what the magic math below does. | ||
3256 | */ | ||
3257 | rtl8169_set_rxbufsize(tp, 16383 - VLAN_ETH_HLEN - ETH_FCS_LEN); | ||
3263 | 3258 | ||
3264 | /* | 3259 | /* |
3265 | * Rx and Tx desscriptors needs 256 bytes alignment. | 3260 | * Rx and Tx desscriptors needs 256 bytes alignment. |
@@ -3388,7 +3383,7 @@ static void rtl_set_rx_max_size(void __iomem *ioaddr, unsigned int rx_buf_sz) | |||
3388 | 3383 | ||
3389 | static void rtl8169_set_magic_reg(void __iomem *ioaddr, unsigned mac_version) | 3384 | static void rtl8169_set_magic_reg(void __iomem *ioaddr, unsigned mac_version) |
3390 | { | 3385 | { |
3391 | struct { | 3386 | static const struct { |
3392 | u32 mac_version; | 3387 | u32 mac_version; |
3393 | u32 clk; | 3388 | u32 clk; |
3394 | u32 val; | 3389 | u32 val; |
@@ -3512,7 +3507,7 @@ struct ephy_info { | |||
3512 | u16 bits; | 3507 | u16 bits; |
3513 | }; | 3508 | }; |
3514 | 3509 | ||
3515 | static void rtl_ephy_init(void __iomem *ioaddr, struct ephy_info *e, int len) | 3510 | static void rtl_ephy_init(void __iomem *ioaddr, const struct ephy_info *e, int len) |
3516 | { | 3511 | { |
3517 | u16 w; | 3512 | u16 w; |
3518 | 3513 | ||
@@ -3583,7 +3578,7 @@ static void __rtl_hw_start_8168cp(void __iomem *ioaddr, struct pci_dev *pdev) | |||
3583 | 3578 | ||
3584 | static void rtl_hw_start_8168cp_1(void __iomem *ioaddr, struct pci_dev *pdev) | 3579 | static void rtl_hw_start_8168cp_1(void __iomem *ioaddr, struct pci_dev *pdev) |
3585 | { | 3580 | { |
3586 | static struct ephy_info e_info_8168cp[] = { | 3581 | static const struct ephy_info e_info_8168cp[] = { |
3587 | { 0x01, 0, 0x0001 }, | 3582 | { 0x01, 0, 0x0001 }, |
3588 | { 0x02, 0x0800, 0x1000 }, | 3583 | { 0x02, 0x0800, 0x1000 }, |
3589 | { 0x03, 0, 0x0042 }, | 3584 | { 0x03, 0, 0x0042 }, |
@@ -3627,7 +3622,7 @@ static void rtl_hw_start_8168cp_3(void __iomem *ioaddr, struct pci_dev *pdev) | |||
3627 | 3622 | ||
3628 | static void rtl_hw_start_8168c_1(void __iomem *ioaddr, struct pci_dev *pdev) | 3623 | static void rtl_hw_start_8168c_1(void __iomem *ioaddr, struct pci_dev *pdev) |
3629 | { | 3624 | { |
3630 | static struct ephy_info e_info_8168c_1[] = { | 3625 | static const struct ephy_info e_info_8168c_1[] = { |
3631 | { 0x02, 0x0800, 0x1000 }, | 3626 | { 0x02, 0x0800, 0x1000 }, |
3632 | { 0x03, 0, 0x0002 }, | 3627 | { 0x03, 0, 0x0002 }, |
3633 | { 0x06, 0x0080, 0x0000 } | 3628 | { 0x06, 0x0080, 0x0000 } |
@@ -3644,7 +3639,7 @@ static void rtl_hw_start_8168c_1(void __iomem *ioaddr, struct pci_dev *pdev) | |||
3644 | 3639 | ||
3645 | static void rtl_hw_start_8168c_2(void __iomem *ioaddr, struct pci_dev *pdev) | 3640 | static void rtl_hw_start_8168c_2(void __iomem *ioaddr, struct pci_dev *pdev) |
3646 | { | 3641 | { |
3647 | static struct ephy_info e_info_8168c_2[] = { | 3642 | static const struct ephy_info e_info_8168c_2[] = { |
3648 | { 0x01, 0, 0x0001 }, | 3643 | { 0x01, 0, 0x0001 }, |
3649 | { 0x03, 0x0400, 0x0220 } | 3644 | { 0x03, 0x0400, 0x0220 } |
3650 | }; | 3645 | }; |
@@ -3787,7 +3782,7 @@ static void rtl_hw_start_8168(struct net_device *dev) | |||
3787 | 3782 | ||
3788 | static void rtl_hw_start_8102e_1(void __iomem *ioaddr, struct pci_dev *pdev) | 3783 | static void rtl_hw_start_8102e_1(void __iomem *ioaddr, struct pci_dev *pdev) |
3789 | { | 3784 | { |
3790 | static struct ephy_info e_info_8102e_1[] = { | 3785 | static const struct ephy_info e_info_8102e_1[] = { |
3791 | { 0x01, 0, 0x6e65 }, | 3786 | { 0x01, 0, 0x6e65 }, |
3792 | { 0x02, 0, 0x091f }, | 3787 | { 0x02, 0, 0x091f }, |
3793 | { 0x03, 0, 0xc2f9 }, | 3788 | { 0x03, 0, 0xc2f9 }, |
@@ -3912,7 +3907,7 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu) | |||
3912 | 3907 | ||
3913 | rtl8169_down(dev); | 3908 | rtl8169_down(dev); |
3914 | 3909 | ||
3915 | rtl8169_set_rxbufsize(tp, dev); | 3910 | rtl8169_set_rxbufsize(tp, dev->mtu); |
3916 | 3911 | ||
3917 | ret = rtl8169_init_ring(dev); | 3912 | ret = rtl8169_init_ring(dev); |
3918 | if (ret < 0) | 3913 | if (ret < 0) |
@@ -4136,10 +4131,10 @@ static void rtl8169_reinit_task(struct work_struct *work) | |||
4136 | 4131 | ||
4137 | ret = rtl8169_open(dev); | 4132 | ret = rtl8169_open(dev); |
4138 | if (unlikely(ret < 0)) { | 4133 | if (unlikely(ret < 0)) { |
4139 | if (net_ratelimit() && netif_msg_drv(tp)) { | 4134 | if (net_ratelimit()) |
4140 | printk(KERN_ERR PFX "%s: reinit failure (status = %d)." | 4135 | netif_err(tp, drv, dev, |
4141 | " Rescheduling.\n", dev->name, ret); | 4136 | "reinit failure (status = %d). Rescheduling\n", |
4142 | } | 4137 | ret); |
4143 | rtl8169_schedule_work(dev, rtl8169_reinit_task); | 4138 | rtl8169_schedule_work(dev, rtl8169_reinit_task); |
4144 | } | 4139 | } |
4145 | 4140 | ||
@@ -4169,10 +4164,8 @@ static void rtl8169_reset_task(struct work_struct *work) | |||
4169 | netif_wake_queue(dev); | 4164 | netif_wake_queue(dev); |
4170 | rtl8169_check_link_status(dev, tp, tp->mmio_addr); | 4165 | rtl8169_check_link_status(dev, tp, tp->mmio_addr); |
4171 | } else { | 4166 | } else { |
4172 | if (net_ratelimit() && netif_msg_intr(tp)) { | 4167 | if (net_ratelimit()) |
4173 | printk(KERN_EMERG PFX "%s: Rx buffers shortage\n", | 4168 | netif_emerg(tp, intr, dev, "Rx buffers shortage\n"); |
4174 | dev->name); | ||
4175 | } | ||
4176 | rtl8169_schedule_work(dev, rtl8169_reset_task); | 4169 | rtl8169_schedule_work(dev, rtl8169_reset_task); |
4177 | } | 4170 | } |
4178 | 4171 | ||
@@ -4260,11 +4253,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, | |||
4260 | u32 opts1; | 4253 | u32 opts1; |
4261 | 4254 | ||
4262 | if (unlikely(TX_BUFFS_AVAIL(tp) < skb_shinfo(skb)->nr_frags)) { | 4255 | if (unlikely(TX_BUFFS_AVAIL(tp) < skb_shinfo(skb)->nr_frags)) { |
4263 | if (netif_msg_drv(tp)) { | 4256 | netif_err(tp, drv, dev, "BUG! Tx Ring full when queue awake!\n"); |
4264 | printk(KERN_ERR | ||
4265 | "%s: BUG! Tx Ring full when queue awake!\n", | ||
4266 | dev->name); | ||
4267 | } | ||
4268 | goto err_stop; | 4257 | goto err_stop; |
4269 | } | 4258 | } |
4270 | 4259 | ||
@@ -4297,7 +4286,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, | |||
4297 | 4286 | ||
4298 | tp->cur_tx += frags + 1; | 4287 | tp->cur_tx += frags + 1; |
4299 | 4288 | ||
4300 | smp_wmb(); | 4289 | wmb(); |
4301 | 4290 | ||
4302 | RTL_W8(TxPoll, NPQ); /* set polling bit */ | 4291 | RTL_W8(TxPoll, NPQ); /* set polling bit */ |
4303 | 4292 | ||
@@ -4326,11 +4315,8 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev) | |||
4326 | pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd); | 4315 | pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd); |
4327 | pci_read_config_word(pdev, PCI_STATUS, &pci_status); | 4316 | pci_read_config_word(pdev, PCI_STATUS, &pci_status); |
4328 | 4317 | ||
4329 | if (netif_msg_intr(tp)) { | 4318 | netif_err(tp, intr, dev, "PCI error (cmd = 0x%04x, status = 0x%04x)\n", |
4330 | printk(KERN_ERR | 4319 | pci_cmd, pci_status); |
4331 | "%s: PCI error (cmd = 0x%04x, status = 0x%04x).\n", | ||
4332 | dev->name, pci_cmd, pci_status); | ||
4333 | } | ||
4334 | 4320 | ||
4335 | /* | 4321 | /* |
4336 | * The recovery sequence below admits a very elaborated explanation: | 4322 | * The recovery sequence below admits a very elaborated explanation: |
@@ -4354,8 +4340,7 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev) | |||
4354 | 4340 | ||
4355 | /* The infamous DAC f*ckup only happens at boot time */ | 4341 | /* The infamous DAC f*ckup only happens at boot time */ |
4356 | if ((tp->cp_cmd & PCIDAC) && !tp->dirty_rx && !tp->cur_rx) { | 4342 | if ((tp->cp_cmd & PCIDAC) && !tp->dirty_rx && !tp->cur_rx) { |
4357 | if (netif_msg_intr(tp)) | 4343 | netif_info(tp, intr, dev, "disabling PCI DAC\n"); |
4358 | printk(KERN_INFO "%s: disabling PCI DAC.\n", dev->name); | ||
4359 | tp->cp_cmd &= ~PCIDAC; | 4344 | tp->cp_cmd &= ~PCIDAC; |
4360 | RTL_W16(CPlusCmd, tp->cp_cmd); | 4345 | RTL_W16(CPlusCmd, tp->cp_cmd); |
4361 | dev->features &= ~NETIF_F_HIGHDMA; | 4346 | dev->features &= ~NETIF_F_HIGHDMA; |
@@ -4447,13 +4432,12 @@ static inline bool rtl8169_try_rx_copy(struct sk_buff **sk_buff, | |||
4447 | if (pkt_size >= rx_copybreak) | 4432 | if (pkt_size >= rx_copybreak) |
4448 | goto out; | 4433 | goto out; |
4449 | 4434 | ||
4450 | skb = netdev_alloc_skb(tp->dev, pkt_size + NET_IP_ALIGN); | 4435 | skb = netdev_alloc_skb_ip_align(tp->dev, pkt_size); |
4451 | if (!skb) | 4436 | if (!skb) |
4452 | goto out; | 4437 | goto out; |
4453 | 4438 | ||
4454 | pci_dma_sync_single_for_cpu(tp->pci_dev, addr, pkt_size, | 4439 | pci_dma_sync_single_for_cpu(tp->pci_dev, addr, pkt_size, |
4455 | PCI_DMA_FROMDEVICE); | 4440 | PCI_DMA_FROMDEVICE); |
4456 | skb_reserve(skb, NET_IP_ALIGN); | ||
4457 | skb_copy_from_linear_data(*sk_buff, skb->data, pkt_size); | 4441 | skb_copy_from_linear_data(*sk_buff, skb->data, pkt_size); |
4458 | *sk_buff = skb; | 4442 | *sk_buff = skb; |
4459 | done = true; | 4443 | done = true; |
@@ -4461,12 +4445,20 @@ out: | |||
4461 | return done; | 4445 | return done; |
4462 | } | 4446 | } |
4463 | 4447 | ||
4448 | /* | ||
4449 | * Warning : rtl8169_rx_interrupt() might be called : | ||
4450 | * 1) from NAPI (softirq) context | ||
4451 | * (polling = 1 : we should call netif_receive_skb()) | ||
4452 | * 2) from process context (rtl8169_reset_task()) | ||
4453 | * (polling = 0 : we must call netif_rx() instead) | ||
4454 | */ | ||
4464 | static int rtl8169_rx_interrupt(struct net_device *dev, | 4455 | static int rtl8169_rx_interrupt(struct net_device *dev, |
4465 | struct rtl8169_private *tp, | 4456 | struct rtl8169_private *tp, |
4466 | void __iomem *ioaddr, u32 budget) | 4457 | void __iomem *ioaddr, u32 budget) |
4467 | { | 4458 | { |
4468 | unsigned int cur_rx, rx_left; | 4459 | unsigned int cur_rx, rx_left; |
4469 | unsigned int delta, count; | 4460 | unsigned int delta, count; |
4461 | int polling = (budget != ~(u32)0) ? 1 : 0; | ||
4470 | 4462 | ||
4471 | cur_rx = tp->cur_rx; | 4463 | cur_rx = tp->cur_rx; |
4472 | rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; | 4464 | rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; |
@@ -4483,11 +4475,8 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
4483 | if (status & DescOwn) | 4475 | if (status & DescOwn) |
4484 | break; | 4476 | break; |
4485 | if (unlikely(status & RxRES)) { | 4477 | if (unlikely(status & RxRES)) { |
4486 | if (netif_msg_rx_err(tp)) { | 4478 | netif_info(tp, rx_err, dev, "Rx ERROR. status = %08x\n", |
4487 | printk(KERN_INFO | 4479 | status); |
4488 | "%s: Rx ERROR. status = %08x\n", | ||
4489 | dev->name, status); | ||
4490 | } | ||
4491 | dev->stats.rx_errors++; | 4480 | dev->stats.rx_errors++; |
4492 | if (status & (RxRWT | RxRUNT)) | 4481 | if (status & (RxRWT | RxRUNT)) |
4493 | dev->stats.rx_length_errors++; | 4482 | dev->stats.rx_length_errors++; |
@@ -4531,8 +4520,12 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
4531 | skb_put(skb, pkt_size); | 4520 | skb_put(skb, pkt_size); |
4532 | skb->protocol = eth_type_trans(skb, dev); | 4521 | skb->protocol = eth_type_trans(skb, dev); |
4533 | 4522 | ||
4534 | if (rtl8169_rx_vlan_skb(tp, desc, skb) < 0) | 4523 | if (rtl8169_rx_vlan_skb(tp, desc, skb, polling) < 0) { |
4535 | netif_receive_skb(skb); | 4524 | if (likely(polling)) |
4525 | netif_receive_skb(skb); | ||
4526 | else | ||
4527 | netif_rx(skb); | ||
4528 | } | ||
4536 | 4529 | ||
4537 | dev->stats.rx_bytes += pkt_size; | 4530 | dev->stats.rx_bytes += pkt_size; |
4538 | dev->stats.rx_packets++; | 4531 | dev->stats.rx_packets++; |
@@ -4550,8 +4543,8 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
4550 | tp->cur_rx = cur_rx; | 4543 | tp->cur_rx = cur_rx; |
4551 | 4544 | ||
4552 | delta = rtl8169_rx_fill(tp, dev, tp->dirty_rx, tp->cur_rx); | 4545 | delta = rtl8169_rx_fill(tp, dev, tp->dirty_rx, tp->cur_rx); |
4553 | if (!delta && count && netif_msg_intr(tp)) | 4546 | if (!delta && count) |
4554 | printk(KERN_INFO "%s: no Rx buffer allocated\n", dev->name); | 4547 | netif_info(tp, intr, dev, "no Rx buffer allocated\n"); |
4555 | tp->dirty_rx += delta; | 4548 | tp->dirty_rx += delta; |
4556 | 4549 | ||
4557 | /* | 4550 | /* |
@@ -4561,8 +4554,8 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
4561 | * after refill ? | 4554 | * after refill ? |
4562 | * - how do others driver handle this condition (Uh oh...). | 4555 | * - how do others driver handle this condition (Uh oh...). |
4563 | */ | 4556 | */ |
4564 | if ((tp->dirty_rx + NUM_RX_DESC == tp->cur_rx) && netif_msg_intr(tp)) | 4557 | if (tp->dirty_rx + NUM_RX_DESC == tp->cur_rx) |
4565 | printk(KERN_EMERG "%s: Rx buffers exhausted\n", dev->name); | 4558 | netif_emerg(tp, intr, dev, "Rx buffers exhausted\n"); |
4566 | 4559 | ||
4567 | return count; | 4560 | return count; |
4568 | } | 4561 | } |
@@ -4617,10 +4610,9 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) | |||
4617 | 4610 | ||
4618 | if (likely(napi_schedule_prep(&tp->napi))) | 4611 | if (likely(napi_schedule_prep(&tp->napi))) |
4619 | __napi_schedule(&tp->napi); | 4612 | __napi_schedule(&tp->napi); |
4620 | else if (netif_msg_intr(tp)) { | 4613 | else |
4621 | printk(KERN_INFO "%s: interrupt %04x in poll\n", | 4614 | netif_info(tp, intr, dev, |
4622 | dev->name, status); | 4615 | "interrupt %04x in poll\n", status); |
4623 | } | ||
4624 | } | 4616 | } |
4625 | 4617 | ||
4626 | /* We only get a new MSI interrupt when all active irq | 4618 | /* We only get a new MSI interrupt when all active irq |
@@ -4657,7 +4649,7 @@ static int rtl8169_poll(struct napi_struct *napi, int budget) | |||
4657 | * until it does. | 4649 | * until it does. |
4658 | */ | 4650 | */ |
4659 | tp->intr_mask = 0xffff; | 4651 | tp->intr_mask = 0xffff; |
4660 | smp_wmb(); | 4652 | wmb(); |
4661 | RTL_W16(IntrMask, tp->intr_event); | 4653 | RTL_W16(IntrMask, tp->intr_event); |
4662 | } | 4654 | } |
4663 | 4655 | ||
@@ -4756,27 +4748,22 @@ static void rtl_set_rx_mode(struct net_device *dev) | |||
4756 | 4748 | ||
4757 | if (dev->flags & IFF_PROMISC) { | 4749 | if (dev->flags & IFF_PROMISC) { |
4758 | /* Unconditionally log net taps. */ | 4750 | /* Unconditionally log net taps. */ |
4759 | if (netif_msg_link(tp)) { | 4751 | netif_notice(tp, link, dev, "Promiscuous mode enabled\n"); |
4760 | printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", | ||
4761 | dev->name); | ||
4762 | } | ||
4763 | rx_mode = | 4752 | rx_mode = |
4764 | AcceptBroadcast | AcceptMulticast | AcceptMyPhys | | 4753 | AcceptBroadcast | AcceptMulticast | AcceptMyPhys | |
4765 | AcceptAllPhys; | 4754 | AcceptAllPhys; |
4766 | mc_filter[1] = mc_filter[0] = 0xffffffff; | 4755 | mc_filter[1] = mc_filter[0] = 0xffffffff; |
4767 | } else if ((dev->mc_count > multicast_filter_limit) | 4756 | } else if ((netdev_mc_count(dev) > multicast_filter_limit) || |
4768 | || (dev->flags & IFF_ALLMULTI)) { | 4757 | (dev->flags & IFF_ALLMULTI)) { |
4769 | /* Too many to filter perfectly -- accept all multicasts. */ | 4758 | /* Too many to filter perfectly -- accept all multicasts. */ |
4770 | rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; | 4759 | rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; |
4771 | mc_filter[1] = mc_filter[0] = 0xffffffff; | 4760 | mc_filter[1] = mc_filter[0] = 0xffffffff; |
4772 | } else { | 4761 | } else { |
4773 | struct dev_mc_list *mclist; | 4762 | struct dev_mc_list *mclist; |
4774 | unsigned int i; | ||
4775 | 4763 | ||
4776 | rx_mode = AcceptBroadcast | AcceptMyPhys; | 4764 | rx_mode = AcceptBroadcast | AcceptMyPhys; |
4777 | mc_filter[1] = mc_filter[0] = 0; | 4765 | mc_filter[1] = mc_filter[0] = 0; |
4778 | for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count; | 4766 | netdev_for_each_mc_addr(mclist, dev) { |
4779 | i++, mclist = mclist->next) { | ||
4780 | int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; | 4767 | int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; |
4781 | mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); | 4768 | mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); |
4782 | rx_mode |= AcceptMulticast; | 4769 | rx_mode |= AcceptMulticast; |
@@ -4795,8 +4782,8 @@ static void rtl_set_rx_mode(struct net_device *dev) | |||
4795 | mc_filter[1] = swab32(data); | 4782 | mc_filter[1] = swab32(data); |
4796 | } | 4783 | } |
4797 | 4784 | ||
4798 | RTL_W32(MAR0 + 0, mc_filter[0]); | ||
4799 | RTL_W32(MAR0 + 4, mc_filter[1]); | 4785 | RTL_W32(MAR0 + 4, mc_filter[1]); |
4786 | RTL_W32(MAR0 + 0, mc_filter[0]); | ||
4800 | 4787 | ||
4801 | RTL_W32(RxConfig, tmp); | 4788 | RTL_W32(RxConfig, tmp); |
4802 | 4789 | ||
@@ -4860,7 +4847,7 @@ out: | |||
4860 | return 0; | 4847 | return 0; |
4861 | } | 4848 | } |
4862 | 4849 | ||
4863 | static struct dev_pm_ops rtl8169_pm_ops = { | 4850 | static const struct dev_pm_ops rtl8169_pm_ops = { |
4864 | .suspend = rtl8169_suspend, | 4851 | .suspend = rtl8169_suspend, |
4865 | .resume = rtl8169_resume, | 4852 | .resume = rtl8169_resume, |
4866 | .freeze = rtl8169_suspend, | 4853 | .freeze = rtl8169_suspend, |