480 struct timer_list timer; |
467 struct timer_list timer; |
481 u16 cp_cmd; |
468 u16 cp_cmd; |
482 u16 intr_event; |
469 u16 intr_event; |
483 u16 napi_event; |
470 u16 napi_event; |
484 u16 intr_mask; |
471 u16 intr_mask; |
|
472 int phy_auto_nego_reg; |
485 int phy_1000_ctrl_reg; |
473 int phy_1000_ctrl_reg; |
486 #ifdef CONFIG_R8169_VLAN |
474 #ifdef CONFIG_R8169_VLAN |
487 struct vlan_group *vlgrp; |
475 struct vlan_group *vlgrp; |
488 #endif |
476 #endif |
489 int (*set_speed)(struct net_device *, u8 autoneg, u16 speed, u8 duplex); |
477 int (*set_speed)(struct net_device *, u8 autoneg, u16 speed, u8 duplex); |
490 int (*get_settings)(struct net_device *, struct ethtool_cmd *); |
478 int (*get_settings)(struct net_device *, struct ethtool_cmd *); |
491 void (*phy_reset_enable)(void __iomem *); |
479 void (*phy_reset_enable)(void __iomem *); |
492 void (*hw_start)(struct net_device *); |
480 void (*hw_start)(struct net_device *); |
493 unsigned int (*phy_reset_pending)(void __iomem *); |
481 unsigned int (*phy_reset_pending)(void __iomem *); |
494 unsigned int (*link_ok)(void __iomem *); |
482 unsigned int (*link_ok)(void __iomem *); |
495 int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd); |
|
496 int pcie_cap; |
483 int pcie_cap; |
497 struct delayed_work task; |
484 struct delayed_work task; |
498 unsigned features; |
485 unsigned features; |
499 |
486 |
500 struct mii_if_info mii; |
487 struct mii_if_info mii; |
501 struct rtl8169_counters counters; |
|
502 |
488 |
503 ec_device_t *ecdev; |
489 ec_device_t *ecdev; |
504 unsigned long ec_watchdog_jiffies; |
490 unsigned long ec_watchdog_jiffies; |
505 }; |
491 }; |
506 |
492 |
852 static int rtl8169_set_speed_xmii(struct net_device *dev, |
838 static int rtl8169_set_speed_xmii(struct net_device *dev, |
853 u8 autoneg, u16 speed, u8 duplex) |
839 u8 autoneg, u16 speed, u8 duplex) |
854 { |
840 { |
855 struct rtl8169_private *tp = netdev_priv(dev); |
841 struct rtl8169_private *tp = netdev_priv(dev); |
856 void __iomem *ioaddr = tp->mmio_addr; |
842 void __iomem *ioaddr = tp->mmio_addr; |
857 int giga_ctrl, bmcr; |
843 int auto_nego, giga_ctrl; |
|
844 |
|
845 auto_nego = mdio_read(ioaddr, MII_ADVERTISE); |
|
846 auto_nego &= ~(ADVERTISE_10HALF | ADVERTISE_10FULL | |
|
847 ADVERTISE_100HALF | ADVERTISE_100FULL); |
|
848 giga_ctrl = mdio_read(ioaddr, MII_CTRL1000); |
|
849 giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); |
858 |
850 |
859 if (autoneg == AUTONEG_ENABLE) { |
851 if (autoneg == AUTONEG_ENABLE) { |
860 int auto_nego; |
|
861 |
|
862 auto_nego = mdio_read(ioaddr, MII_ADVERTISE); |
|
863 auto_nego |= (ADVERTISE_10HALF | ADVERTISE_10FULL | |
852 auto_nego |= (ADVERTISE_10HALF | ADVERTISE_10FULL | |
864 ADVERTISE_100HALF | ADVERTISE_100FULL); |
853 ADVERTISE_100HALF | ADVERTISE_100FULL); |
865 auto_nego |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM; |
854 giga_ctrl |= ADVERTISE_1000FULL | ADVERTISE_1000HALF; |
866 |
855 } else { |
867 giga_ctrl = mdio_read(ioaddr, MII_CTRL1000); |
856 if (speed == SPEED_10) |
868 giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); |
857 auto_nego |= ADVERTISE_10HALF | ADVERTISE_10FULL; |
869 |
858 else if (speed == SPEED_100) |
870 /* The 8100e/8101e/8102e do Fast Ethernet only. */ |
859 auto_nego |= ADVERTISE_100HALF | ADVERTISE_100FULL; |
871 if ((tp->mac_version != RTL_GIGA_MAC_VER_07) && |
860 else if (speed == SPEED_1000) |
872 (tp->mac_version != RTL_GIGA_MAC_VER_08) && |
|
873 (tp->mac_version != RTL_GIGA_MAC_VER_09) && |
|
874 (tp->mac_version != RTL_GIGA_MAC_VER_10) && |
|
875 (tp->mac_version != RTL_GIGA_MAC_VER_13) && |
|
876 (tp->mac_version != RTL_GIGA_MAC_VER_14) && |
|
877 (tp->mac_version != RTL_GIGA_MAC_VER_15) && |
|
878 (tp->mac_version != RTL_GIGA_MAC_VER_16)) { |
|
879 giga_ctrl |= ADVERTISE_1000FULL | ADVERTISE_1000HALF; |
861 giga_ctrl |= ADVERTISE_1000FULL | ADVERTISE_1000HALF; |
880 } else if (netif_msg_link(tp)) { |
862 |
|
863 if (duplex == DUPLEX_HALF) |
|
864 auto_nego &= ~(ADVERTISE_10FULL | ADVERTISE_100FULL); |
|
865 |
|
866 if (duplex == DUPLEX_FULL) |
|
867 auto_nego &= ~(ADVERTISE_10HALF | ADVERTISE_100HALF); |
|
868 |
|
869 /* This tweak comes straight from Realtek's driver. */ |
|
870 if ((speed == SPEED_100) && (duplex == DUPLEX_HALF) && |
|
871 ((tp->mac_version == RTL_GIGA_MAC_VER_13) || |
|
872 (tp->mac_version == RTL_GIGA_MAC_VER_16))) { |
|
873 auto_nego = ADVERTISE_100HALF | ADVERTISE_CSMA; |
|
874 } |
|
875 } |
|
876 |
|
877 /* The 8100e/8101e/8102e do Fast Ethernet only. */ |
|
878 if ((tp->mac_version == RTL_GIGA_MAC_VER_07) || |
|
879 (tp->mac_version == RTL_GIGA_MAC_VER_08) || |
|
880 (tp->mac_version == RTL_GIGA_MAC_VER_09) || |
|
881 (tp->mac_version == RTL_GIGA_MAC_VER_10) || |
|
882 (tp->mac_version == RTL_GIGA_MAC_VER_13) || |
|
883 (tp->mac_version == RTL_GIGA_MAC_VER_14) || |
|
884 (tp->mac_version == RTL_GIGA_MAC_VER_15) || |
|
885 (tp->mac_version == RTL_GIGA_MAC_VER_16)) { |
|
886 if ((giga_ctrl & (ADVERTISE_1000FULL | ADVERTISE_1000HALF)) && |
|
887 netif_msg_link(tp)) { |
881 printk(KERN_INFO "%s: PHY does not support 1000Mbps.\n", |
888 printk(KERN_INFO "%s: PHY does not support 1000Mbps.\n", |
882 dev->name); |
889 dev->name); |
883 } |
890 } |
884 |
891 giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); |
885 bmcr = BMCR_ANENABLE | BMCR_ANRESTART; |
892 } |
886 |
893 |
887 if ((tp->mac_version == RTL_GIGA_MAC_VER_11) || |
894 auto_nego |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM; |
888 (tp->mac_version == RTL_GIGA_MAC_VER_12) || |
895 |
889 (tp->mac_version >= RTL_GIGA_MAC_VER_17)) { |
896 if ((tp->mac_version == RTL_GIGA_MAC_VER_11) || |
890 /* |
897 (tp->mac_version == RTL_GIGA_MAC_VER_12) || |
891 * Wake up the PHY. |
898 (tp->mac_version >= RTL_GIGA_MAC_VER_17)) { |
892 * Vendor specific (0x1f) and reserved (0x0e) MII |
899 /* |
893 * registers. |
900 * Wake up the PHY. |
894 */ |
901 * Vendor specific (0x1f) and reserved (0x0e) MII registers. |
895 mdio_write(ioaddr, 0x1f, 0x0000); |
902 */ |
896 mdio_write(ioaddr, 0x0e, 0x0000); |
|
897 } |
|
898 |
|
899 mdio_write(ioaddr, MII_ADVERTISE, auto_nego); |
|
900 mdio_write(ioaddr, MII_CTRL1000, giga_ctrl); |
|
901 } else { |
|
902 giga_ctrl = 0; |
|
903 |
|
904 if (speed == SPEED_10) |
|
905 bmcr = 0; |
|
906 else if (speed == SPEED_100) |
|
907 bmcr = BMCR_SPEED100; |
|
908 else |
|
909 return -EINVAL; |
|
910 |
|
911 if (duplex == DUPLEX_FULL) |
|
912 bmcr |= BMCR_FULLDPLX; |
|
913 |
|
914 mdio_write(ioaddr, 0x1f, 0x0000); |
903 mdio_write(ioaddr, 0x1f, 0x0000); |
915 } |
904 mdio_write(ioaddr, 0x0e, 0x0000); |
916 |
905 } |
|
906 |
|
907 tp->phy_auto_nego_reg = auto_nego; |
917 tp->phy_1000_ctrl_reg = giga_ctrl; |
908 tp->phy_1000_ctrl_reg = giga_ctrl; |
918 |
909 |
919 mdio_write(ioaddr, MII_BMCR, bmcr); |
910 mdio_write(ioaddr, MII_ADVERTISE, auto_nego); |
920 |
911 mdio_write(ioaddr, MII_CTRL1000, giga_ctrl); |
921 if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || |
912 mdio_write(ioaddr, MII_BMCR, BMCR_ANENABLE | BMCR_ANRESTART); |
922 (tp->mac_version == RTL_GIGA_MAC_VER_03)) { |
|
923 if ((speed == SPEED_100) && (autoneg != AUTONEG_ENABLE)) { |
|
924 mdio_write(ioaddr, 0x17, 0x2138); |
|
925 mdio_write(ioaddr, 0x0e, 0x0260); |
|
926 } else { |
|
927 mdio_write(ioaddr, 0x17, 0x2108); |
|
928 mdio_write(ioaddr, 0x0e, 0x0000); |
|
929 } |
|
930 } |
|
931 |
|
932 return 0; |
913 return 0; |
933 } |
914 } |
934 |
915 |
935 static int rtl8169_set_speed(struct net_device *dev, |
916 static int rtl8169_set_speed(struct net_device *dev, |
936 u8 autoneg, u16 speed, u8 duplex) |
917 u8 autoneg, u16 speed, u8 duplex) |
1130 "multicast", |
1111 "multicast", |
1131 "tx_aborted", |
1112 "tx_aborted", |
1132 "tx_underrun", |
1113 "tx_underrun", |
1133 }; |
1114 }; |
1134 |
1115 |
|
1116 struct rtl8169_counters { |
|
1117 __le64 tx_packets; |
|
1118 __le64 rx_packets; |
|
1119 __le64 tx_errors; |
|
1120 __le32 rx_errors; |
|
1121 __le16 rx_missed; |
|
1122 __le16 align_errors; |
|
1123 __le32 tx_one_collision; |
|
1124 __le32 tx_multi_collision; |
|
1125 __le64 rx_unicast; |
|
1126 __le64 rx_broadcast; |
|
1127 __le32 rx_multicast; |
|
1128 __le16 tx_aborted; |
|
1129 __le16 tx_underun; |
|
1130 }; |
|
1131 |
1135 static int rtl8169_get_sset_count(struct net_device *dev, int sset) |
1132 static int rtl8169_get_sset_count(struct net_device *dev, int sset) |
1136 { |
1133 { |
1137 switch (sset) { |
1134 switch (sset) { |
1138 case ETH_SS_STATS: |
1135 case ETH_SS_STATS: |
1139 return ARRAY_SIZE(rtl8169_gstrings); |
1136 return ARRAY_SIZE(rtl8169_gstrings); |
1140 default: |
1137 default: |
1141 return -EOPNOTSUPP; |
1138 return -EOPNOTSUPP; |
1142 } |
1139 } |
1143 } |
1140 } |
1144 |
1141 |
1145 static void rtl8169_update_counters(struct net_device *dev) |
1142 static void rtl8169_get_ethtool_stats(struct net_device *dev, |
|
1143 struct ethtool_stats *stats, u64 *data) |
1146 { |
1144 { |
1147 struct rtl8169_private *tp = netdev_priv(dev); |
1145 struct rtl8169_private *tp = netdev_priv(dev); |
1148 void __iomem *ioaddr = tp->mmio_addr; |
1146 void __iomem *ioaddr = tp->mmio_addr; |
1149 struct rtl8169_counters *counters; |
1147 struct rtl8169_counters *counters; |
1150 dma_addr_t paddr; |
1148 dma_addr_t paddr; |
1151 u32 cmd; |
1149 u32 cmd; |
1152 int wait = 1000; |
1150 |
1153 |
1151 ASSERT_RTNL(); |
1154 /* |
|
1155 * Some chips are unable to dump tally counters when the receiver |
|
1156 * is disabled. |
|
1157 */ |
|
1158 if ((RTL_R8(ChipCmd) & CmdRxEnb) == 0) |
|
1159 return; |
|
1160 |
1152 |
1161 counters = pci_alloc_consistent(tp->pci_dev, sizeof(*counters), &paddr); |
1153 counters = pci_alloc_consistent(tp->pci_dev, sizeof(*counters), &paddr); |
1162 if (!counters) |
1154 if (!counters) |
1163 return; |
1155 return; |
1164 |
1156 |
1165 RTL_W32(CounterAddrHigh, (u64)paddr >> 32); |
1157 RTL_W32(CounterAddrHigh, (u64)paddr >> 32); |
1166 cmd = (u64)paddr & DMA_BIT_MASK(32); |
1158 cmd = (u64)paddr & DMA_32BIT_MASK; |
1167 RTL_W32(CounterAddrLow, cmd); |
1159 RTL_W32(CounterAddrLow, cmd); |
1168 RTL_W32(CounterAddrLow, cmd | CounterDump); |
1160 RTL_W32(CounterAddrLow, cmd | CounterDump); |
1169 |
1161 |
1170 while (wait--) { |
1162 while (RTL_R32(CounterAddrLow) & CounterDump) { |
1171 if ((RTL_R32(CounterAddrLow) & CounterDump) == 0) { |
1163 if (msleep_interruptible(1)) |
1172 /* copy updated counters */ |
|
1173 memcpy(&tp->counters, counters, sizeof(*counters)); |
|
1174 break; |
1164 break; |
1175 } |
|
1176 udelay(10); |
|
1177 } |
1165 } |
1178 |
1166 |
1179 RTL_W32(CounterAddrLow, 0); |
1167 RTL_W32(CounterAddrLow, 0); |
1180 RTL_W32(CounterAddrHigh, 0); |
1168 RTL_W32(CounterAddrHigh, 0); |
1181 |
1169 |
|
1170 data[0] = le64_to_cpu(counters->tx_packets); |
|
1171 data[1] = le64_to_cpu(counters->rx_packets); |
|
1172 data[2] = le64_to_cpu(counters->tx_errors); |
|
1173 data[3] = le32_to_cpu(counters->rx_errors); |
|
1174 data[4] = le16_to_cpu(counters->rx_missed); |
|
1175 data[5] = le16_to_cpu(counters->align_errors); |
|
1176 data[6] = le32_to_cpu(counters->tx_one_collision); |
|
1177 data[7] = le32_to_cpu(counters->tx_multi_collision); |
|
1178 data[8] = le64_to_cpu(counters->rx_unicast); |
|
1179 data[9] = le64_to_cpu(counters->rx_broadcast); |
|
1180 data[10] = le32_to_cpu(counters->rx_multicast); |
|
1181 data[11] = le16_to_cpu(counters->tx_aborted); |
|
1182 data[12] = le16_to_cpu(counters->tx_underun); |
|
1183 |
1182 pci_free_consistent(tp->pci_dev, sizeof(*counters), counters, paddr); |
1184 pci_free_consistent(tp->pci_dev, sizeof(*counters), counters, paddr); |
1183 } |
|
1184 |
|
1185 static void rtl8169_get_ethtool_stats(struct net_device *dev, |
|
1186 struct ethtool_stats *stats, u64 *data) |
|
1187 { |
|
1188 struct rtl8169_private *tp = netdev_priv(dev); |
|
1189 |
|
1190 ASSERT_RTNL(); |
|
1191 |
|
1192 rtl8169_update_counters(dev); |
|
1193 |
|
1194 data[0] = le64_to_cpu(tp->counters.tx_packets); |
|
1195 data[1] = le64_to_cpu(tp->counters.rx_packets); |
|
1196 data[2] = le64_to_cpu(tp->counters.tx_errors); |
|
1197 data[3] = le32_to_cpu(tp->counters.rx_errors); |
|
1198 data[4] = le16_to_cpu(tp->counters.rx_missed); |
|
1199 data[5] = le16_to_cpu(tp->counters.align_errors); |
|
1200 data[6] = le32_to_cpu(tp->counters.tx_one_collision); |
|
1201 data[7] = le32_to_cpu(tp->counters.tx_multi_collision); |
|
1202 data[8] = le64_to_cpu(tp->counters.rx_unicast); |
|
1203 data[9] = le64_to_cpu(tp->counters.rx_broadcast); |
|
1204 data[10] = le32_to_cpu(tp->counters.rx_multicast); |
|
1205 data[11] = le16_to_cpu(tp->counters.tx_aborted); |
|
1206 data[12] = le16_to_cpu(tp->counters.tx_underun); |
|
1207 } |
1185 } |
1208 |
1186 |
1209 static void rtl8169_get_strings(struct net_device *dev, u32 stringset, u8 *data) |
1187 static void rtl8169_get_strings(struct net_device *dev, u32 stringset, u8 *data) |
1210 { |
1188 { |
1211 switch(stringset) { |
1189 switch(stringset) { |
1309 { 0xfc800000, 0x10000000, RTL_GIGA_MAC_VER_04 }, |
1287 { 0xfc800000, 0x10000000, RTL_GIGA_MAC_VER_04 }, |
1310 { 0xfc800000, 0x04000000, RTL_GIGA_MAC_VER_03 }, |
1288 { 0xfc800000, 0x04000000, RTL_GIGA_MAC_VER_03 }, |
1311 { 0xfc800000, 0x00800000, RTL_GIGA_MAC_VER_02 }, |
1289 { 0xfc800000, 0x00800000, RTL_GIGA_MAC_VER_02 }, |
1312 { 0xfc800000, 0x00000000, RTL_GIGA_MAC_VER_01 }, |
1290 { 0xfc800000, 0x00000000, RTL_GIGA_MAC_VER_01 }, |
1313 |
1291 |
1314 /* Catch-all */ |
1292 { 0x00000000, 0x00000000, RTL_GIGA_MAC_VER_01 } /* Catch-all */ |
1315 { 0x00000000, 0x00000000, RTL_GIGA_MAC_NONE } |
|
1316 }, *p = mac_info; |
1293 }, *p = mac_info; |
1317 u32 reg; |
1294 u32 reg; |
1318 |
1295 |
1319 reg = RTL_R32(TxConfig); |
1296 reg = RTL_R32(TxConfig); |
1320 while ((reg & p->mask) != p->val) |
1297 while ((reg & p->mask) != p->val) |
1321 p++; |
1298 p++; |
1322 tp->mac_version = p->mac_version; |
1299 tp->mac_version = p->mac_version; |
|
1300 |
|
1301 if (p->mask == 0x00000000) { |
|
1302 struct pci_dev *pdev = tp->pci_dev; |
|
1303 |
|
1304 dev_info(&pdev->dev, "unknown MAC (%08x)\n", reg); |
|
1305 } |
1323 } |
1306 } |
1324 |
1307 |
1325 static void rtl8169_print_mac_version(struct rtl8169_private *tp) |
1308 static void rtl8169_print_mac_version(struct rtl8169_private *tp) |
1326 { |
1309 { |
1327 dprintk("mac_version = 0x%02x\n", tp->mac_version); |
1310 dprintk("mac_version = 0x%02x\n", tp->mac_version); |
1881 if (!capable(CAP_NET_ADMIN)) |
1862 if (!capable(CAP_NET_ADMIN)) |
1882 return -EPERM; |
1863 return -EPERM; |
1883 mdio_write(tp->mmio_addr, data->reg_num & 0x1f, data->val_in); |
1864 mdio_write(tp->mmio_addr, data->reg_num & 0x1f, data->val_in); |
1884 return 0; |
1865 return 0; |
1885 } |
1866 } |
1886 return -EOPNOTSUPP; |
|
1887 } |
|
1888 |
|
1889 static int rtl_tbi_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd) |
|
1890 { |
|
1891 return -EOPNOTSUPP; |
1867 return -EOPNOTSUPP; |
1892 } |
1868 } |
1893 |
1869 |
1894 static const struct rtl_cfg_info { |
1870 static const struct rtl_cfg_info { |
1895 void (*hw_start)(struct net_device *); |
1871 void (*hw_start)(struct net_device *); |
1896 unsigned int region; |
1872 unsigned int region; |
1897 unsigned int align; |
1873 unsigned int align; |
1898 u16 intr_event; |
1874 u16 intr_event; |
1899 u16 napi_event; |
1875 u16 napi_event; |
1900 unsigned features; |
1876 unsigned features; |
1901 u8 default_ver; |
|
1902 } rtl_cfg_infos [] = { |
1877 } rtl_cfg_infos [] = { |
1903 [RTL_CFG_0] = { |
1878 [RTL_CFG_0] = { |
1904 .hw_start = rtl_hw_start_8169, |
1879 .hw_start = rtl_hw_start_8169, |
1905 .region = 1, |
1880 .region = 1, |
1906 .align = 0, |
1881 .align = 0, |
1907 .intr_event = SYSErr | LinkChg | RxOverflow | |
1882 .intr_event = SYSErr | LinkChg | RxOverflow | |
1908 RxFIFOOver | TxErr | TxOK | RxOK | RxErr, |
1883 RxFIFOOver | TxErr | TxOK | RxOK | RxErr, |
1909 .napi_event = RxFIFOOver | TxErr | TxOK | RxOK | RxOverflow, |
1884 .napi_event = RxFIFOOver | TxErr | TxOK | RxOK | RxOverflow, |
1910 .features = RTL_FEATURE_GMII, |
1885 .features = RTL_FEATURE_GMII |
1911 .default_ver = RTL_GIGA_MAC_VER_01, |
|
1912 }, |
1886 }, |
1913 [RTL_CFG_1] = { |
1887 [RTL_CFG_1] = { |
1914 .hw_start = rtl_hw_start_8168, |
1888 .hw_start = rtl_hw_start_8168, |
1915 .region = 2, |
1889 .region = 2, |
1916 .align = 8, |
1890 .align = 8, |
1917 .intr_event = SYSErr | LinkChg | RxOverflow | |
1891 .intr_event = SYSErr | LinkChg | RxOverflow | |
1918 TxErr | TxOK | RxOK | RxErr, |
1892 TxErr | TxOK | RxOK | RxErr, |
1919 .napi_event = TxErr | TxOK | RxOK | RxOverflow, |
1893 .napi_event = TxErr | TxOK | RxOK | RxOverflow, |
1920 .features = RTL_FEATURE_GMII | RTL_FEATURE_MSI, |
1894 .features = RTL_FEATURE_GMII | RTL_FEATURE_MSI |
1921 .default_ver = RTL_GIGA_MAC_VER_11, |
|
1922 }, |
1895 }, |
1923 [RTL_CFG_2] = { |
1896 [RTL_CFG_2] = { |
1924 .hw_start = rtl_hw_start_8101, |
1897 .hw_start = rtl_hw_start_8101, |
1925 .region = 2, |
1898 .region = 2, |
1926 .align = 8, |
1899 .align = 8, |
1927 .intr_event = SYSErr | LinkChg | RxOverflow | PCSTimeout | |
1900 .intr_event = SYSErr | LinkChg | RxOverflow | PCSTimeout | |
1928 RxFIFOOver | TxErr | TxOK | RxOK | RxErr, |
1901 RxFIFOOver | TxErr | TxOK | RxOK | RxErr, |
1929 .napi_event = RxFIFOOver | TxErr | TxOK | RxOK | RxOverflow, |
1902 .napi_event = RxFIFOOver | TxErr | TxOK | RxOK | RxOverflow, |
1930 .features = RTL_FEATURE_MSI, |
1903 .features = RTL_FEATURE_MSI |
1931 .default_ver = RTL_GIGA_MAC_VER_13, |
|
1932 } |
1904 } |
1933 }; |
1905 }; |
1934 |
1906 |
1935 /* Cfg9346_Unlock assumed. */ |
1907 /* Cfg9346_Unlock assumed. */ |
1936 static unsigned rtl_try_msi(struct pci_dev *pdev, void __iomem *ioaddr, |
1908 static unsigned rtl_try_msi(struct pci_dev *pdev, void __iomem *ioaddr, |
1958 pci_disable_msi(pdev); |
1930 pci_disable_msi(pdev); |
1959 tp->features &= ~RTL_FEATURE_MSI; |
1931 tp->features &= ~RTL_FEATURE_MSI; |
1960 } |
1932 } |
1961 } |
1933 } |
1962 |
1934 |
1963 static const struct net_device_ops rtl8169_netdev_ops = { |
|
1964 .ndo_open = rtl8169_open, |
|
1965 .ndo_stop = rtl8169_close, |
|
1966 .ndo_get_stats = rtl8169_get_stats, |
|
1967 .ndo_start_xmit = rtl8169_start_xmit, |
|
1968 .ndo_tx_timeout = rtl8169_tx_timeout, |
|
1969 .ndo_validate_addr = eth_validate_addr, |
|
1970 .ndo_change_mtu = rtl8169_change_mtu, |
|
1971 .ndo_set_mac_address = rtl_set_mac_address, |
|
1972 .ndo_do_ioctl = rtl8169_ioctl, |
|
1973 .ndo_set_multicast_list = rtl_set_rx_mode, |
|
1974 #ifdef CONFIG_R8169_VLAN |
|
1975 .ndo_vlan_rx_register = rtl8169_vlan_rx_register, |
|
1976 #endif |
|
1977 #ifdef CONFIG_NET_POLL_CONTROLLER |
|
1978 .ndo_poll_controller = rtl8169_netpoll, |
|
1979 #endif |
|
1980 |
|
1981 }; |
|
1982 |
|
1983 static int __devinit |
1935 static int __devinit |
1984 rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
1936 rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
1985 { |
1937 { |
1986 const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data; |
1938 const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data; |
1987 const unsigned int region = cfg->region; |
1939 const unsigned int region = cfg->region; |
2061 } |
2012 } |
2062 |
2013 |
2063 tp->cp_cmd = PCIMulRW | RxChkSum; |
2014 tp->cp_cmd = PCIMulRW | RxChkSum; |
2064 |
2015 |
2065 if ((sizeof(dma_addr_t) > 4) && |
2016 if ((sizeof(dma_addr_t) > 4) && |
2066 !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && use_dac) { |
2017 !pci_set_dma_mask(pdev, DMA_64BIT_MASK) && use_dac) { |
2067 tp->cp_cmd |= PCIDAC; |
2018 tp->cp_cmd |= PCIDAC; |
2068 dev->features |= NETIF_F_HIGHDMA; |
2019 dev->features |= NETIF_F_HIGHDMA; |
2069 } else { |
2020 } else { |
2070 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
2021 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
2071 if (rc < 0) { |
2022 if (rc < 0) { |
2072 if (netif_msg_probe(tp)) { |
2023 if (netif_msg_probe(tp)) { |
2073 dev_err(&pdev->dev, |
2024 dev_err(&pdev->dev, |
2074 "DMA configuration failed.\n"); |
2025 "DMA configuration failed.\n"); |
2075 } |
2026 } |
2076 goto err_out_free_res_4; |
2027 goto err_out_free_res_4; |
2077 } |
2028 } |
2078 } |
2029 } |
2079 |
2030 |
|
2031 pci_set_master(pdev); |
|
2032 |
2080 /* ioremap MMIO region */ |
2033 /* ioremap MMIO region */ |
2081 ioaddr = ioremap(pci_resource_start(pdev, region), R8169_REGS_SIZE); |
2034 ioaddr = ioremap(pci_resource_start(pdev, region), R8169_REGS_SIZE); |
2082 if (!ioaddr) { |
2035 if (!ioaddr) { |
2083 if (netif_msg_probe(tp)) |
2036 if (netif_msg_probe(tp)) |
2084 dev_err(&pdev->dev, "cannot remap MMIO, aborting\n"); |
2037 dev_err(&pdev->dev, "cannot remap MMIO, aborting\n"); |
2102 msleep_interruptible(1); |
2055 msleep_interruptible(1); |
2103 } |
2056 } |
2104 |
2057 |
2105 RTL_W16(IntrStatus, 0xffff); |
2058 RTL_W16(IntrStatus, 0xffff); |
2106 |
2059 |
2107 pci_set_master(pdev); |
|
2108 |
|
2109 /* Identify chip attached to board */ |
2060 /* Identify chip attached to board */ |
2110 rtl8169_get_mac_version(tp, ioaddr); |
2061 rtl8169_get_mac_version(tp, ioaddr); |
2111 |
|
2112 /* Use appropriate default if unknown */ |
|
2113 if (tp->mac_version == RTL_GIGA_MAC_NONE) { |
|
2114 if (netif_msg_probe(tp)) { |
|
2115 dev_notice(&pdev->dev, |
|
2116 "unknown MAC, using family default\n"); |
|
2117 } |
|
2118 tp->mac_version = cfg->default_ver; |
|
2119 } |
|
2120 |
2062 |
2121 rtl8169_print_mac_version(tp); |
2063 rtl8169_print_mac_version(tp); |
2122 |
2064 |
2123 for (i = 0; i < ARRAY_SIZE(rtl_chip_info); i++) { |
2065 for (i = 0; i < ARRAY_SIZE(rtl_chip_info); i++) { |
2124 if (tp->mac_version == rtl_chip_info[i].mac_version) |
2066 if (tp->mac_version == rtl_chip_info[i].mac_version) |
2125 break; |
2067 break; |
2126 } |
2068 } |
2127 if (i == ARRAY_SIZE(rtl_chip_info)) { |
2069 if (i == ARRAY_SIZE(rtl_chip_info)) { |
2128 dev_err(&pdev->dev, |
2070 /* Unknown chip: assume array element #0, original RTL-8169 */ |
2129 "driver bug, MAC version not found in rtl_chip_info\n"); |
2071 if (netif_msg_probe(tp)) { |
2130 goto err_out_msi_5; |
2072 dev_printk(KERN_DEBUG, &pdev->dev, |
|
2073 "unknown chip version, assuming %s\n", |
|
2074 rtl_chip_info[0].name); |
|
2075 } |
|
2076 i = 0; |
2131 } |
2077 } |
2132 tp->chipset = i; |
2078 tp->chipset = i; |
2133 |
2079 |
2134 RTL_W8(Cfg9346, Cfg9346_Unlock); |
2080 RTL_W8(Cfg9346, Cfg9346_Unlock); |
2135 RTL_W8(Config1, RTL_R8(Config1) | PMEnable); |
2081 RTL_W8(Config1, RTL_R8(Config1) | PMEnable); |
2146 tp->set_speed = rtl8169_set_speed_tbi; |
2092 tp->set_speed = rtl8169_set_speed_tbi; |
2147 tp->get_settings = rtl8169_gset_tbi; |
2093 tp->get_settings = rtl8169_gset_tbi; |
2148 tp->phy_reset_enable = rtl8169_tbi_reset_enable; |
2094 tp->phy_reset_enable = rtl8169_tbi_reset_enable; |
2149 tp->phy_reset_pending = rtl8169_tbi_reset_pending; |
2095 tp->phy_reset_pending = rtl8169_tbi_reset_pending; |
2150 tp->link_ok = rtl8169_tbi_link_ok; |
2096 tp->link_ok = rtl8169_tbi_link_ok; |
2151 tp->do_ioctl = rtl_tbi_ioctl; |
|
2152 |
2097 |
2153 tp->phy_1000_ctrl_reg = ADVERTISE_1000FULL; /* Implied by TBI */ |
2098 tp->phy_1000_ctrl_reg = ADVERTISE_1000FULL; /* Implied by TBI */ |
2154 } else { |
2099 } else { |
2155 tp->set_speed = rtl8169_set_speed_xmii; |
2100 tp->set_speed = rtl8169_set_speed_xmii; |
2156 tp->get_settings = rtl8169_gset_xmii; |
2101 tp->get_settings = rtl8169_gset_xmii; |
2157 tp->phy_reset_enable = rtl8169_xmii_reset_enable; |
2102 tp->phy_reset_enable = rtl8169_xmii_reset_enable; |
2158 tp->phy_reset_pending = rtl8169_xmii_reset_pending; |
2103 tp->phy_reset_pending = rtl8169_xmii_reset_pending; |
2159 tp->link_ok = rtl8169_xmii_link_ok; |
2104 tp->link_ok = rtl8169_xmii_link_ok; |
2160 tp->do_ioctl = rtl_xmii_ioctl; |
2105 |
|
2106 dev->do_ioctl = rtl8169_ioctl; |
2161 } |
2107 } |
2162 |
2108 |
2163 spin_lock_init(&tp->lock); |
2109 spin_lock_init(&tp->lock); |
2164 |
2110 |
2165 tp->mmio_addr = ioaddr; |
2111 tp->mmio_addr = ioaddr; |
2167 /* Get MAC address */ |
2113 /* Get MAC address */ |
2168 for (i = 0; i < MAC_ADDR_LEN; i++) |
2114 for (i = 0; i < MAC_ADDR_LEN; i++) |
2169 dev->dev_addr[i] = RTL_R8(MAC0 + i); |
2115 dev->dev_addr[i] = RTL_R8(MAC0 + i); |
2170 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); |
2116 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); |
2171 |
2117 |
|
2118 dev->open = rtl8169_open; |
|
2119 dev->hard_start_xmit = rtl8169_start_xmit; |
|
2120 dev->get_stats = rtl8169_get_stats; |
2172 SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops); |
2121 SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops); |
|
2122 dev->stop = rtl8169_close; |
|
2123 dev->tx_timeout = rtl8169_tx_timeout; |
|
2124 dev->set_multicast_list = rtl_set_rx_mode; |
2173 dev->watchdog_timeo = RTL8169_TX_TIMEOUT; |
2125 dev->watchdog_timeo = RTL8169_TX_TIMEOUT; |
2174 dev->irq = pdev->irq; |
2126 dev->irq = pdev->irq; |
2175 dev->base_addr = (unsigned long) ioaddr; |
2127 dev->base_addr = (unsigned long) ioaddr; |
|
2128 dev->change_mtu = rtl8169_change_mtu; |
|
2129 dev->set_mac_address = rtl_set_mac_address; |
2176 |
2130 |
2177 netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT); |
2131 netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT); |
2178 |
2132 |
2179 #ifdef CONFIG_R8169_VLAN |
2133 #ifdef CONFIG_R8169_VLAN |
2180 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; |
2134 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; |
|
2135 dev->vlan_rx_register = rtl8169_vlan_rx_register; |
|
2136 #endif |
|
2137 |
|
2138 #ifdef CONFIG_NET_POLL_CONTROLLER |
|
2139 dev->poll_controller = rtl8169_netpoll; |
2181 #endif |
2140 #endif |
2182 |
2141 |
2183 tp->intr_mask = 0xffff; |
2142 tp->intr_mask = 0xffff; |
2184 tp->align = cfg->align; |
2143 tp->align = cfg->align; |
2185 tp->hw_start = cfg->hw_start; |
2144 tp->hw_start = cfg->hw_start; |
3624 struct rtl8169_private *tp = netdev_priv(dev); |
3592 struct rtl8169_private *tp = netdev_priv(dev); |
3625 void __iomem *ioaddr = tp->mmio_addr; |
3593 void __iomem *ioaddr = tp->mmio_addr; |
3626 int handled = 0; |
3594 int handled = 0; |
3627 int status; |
3595 int status; |
3628 |
3596 |
3629 /* loop handling interrupts until we have no new ones or |
|
3630 * we hit a invalid/hotplug case. |
|
3631 */ |
|
3632 status = RTL_R16(IntrStatus); |
3597 status = RTL_R16(IntrStatus); |
3633 while (status && status != 0xffff) { |
3598 |
3634 handled = 1; |
3599 /* hotplug/major error/no more work/shared irq */ |
3635 |
3600 if ((status == 0xffff) || !status) |
3636 /* Handle all of the error cases first. These will reset |
3601 goto out; |
3637 * the chip, so just exit the loop. |
3602 |
3638 */ |
3603 handled = 1; |
3639 if (unlikely(!tp->ecdev && !netif_running(dev))) { |
3604 |
3640 rtl8169_asic_down(ioaddr); |
3605 if (unlikely(!tp->ecdev && !netif_running(dev))) { |
3641 break; |
3606 rtl8169_asic_down(ioaddr); |
|
3607 goto out; |
|
3608 } |
|
3609 |
|
3610 status &= tp->intr_mask; |
|
3611 RTL_W16(IntrStatus, |
|
3612 (status & RxFIFOOver) ? (status | RxOverflow) : status); |
|
3613 |
|
3614 if (!(status & tp->intr_event)) |
|
3615 goto out; |
|
3616 |
|
3617 /* Work around for rx fifo overflow */ |
|
3618 if (unlikely(status & RxFIFOOver) && |
|
3619 (tp->mac_version == RTL_GIGA_MAC_VER_11)) { |
|
3620 netif_stop_queue(dev); |
|
3621 rtl8169_tx_timeout(dev); |
|
3622 goto out; |
|
3623 } |
|
3624 |
|
3625 if (unlikely(status & SYSErr)) { |
|
3626 rtl8169_pcierr_interrupt(dev); |
|
3627 goto out; |
|
3628 } |
|
3629 |
|
3630 if (status & LinkChg) |
|
3631 rtl8169_check_link_status(dev, tp, ioaddr); |
|
3632 |
|
3633 if (status & tp->napi_event) { |
|
3634 RTL_W16(IntrMask, tp->intr_event & ~tp->napi_event); |
|
3635 tp->intr_mask = ~tp->napi_event; |
|
3636 |
|
3637 if (likely(netif_rx_schedule_prep(dev, &tp->napi))) |
|
3638 __netif_rx_schedule(dev, &tp->napi); |
|
3639 else if (netif_msg_intr(tp)) { |
|
3640 printk(KERN_INFO "%s: interrupt %04x in poll\n", |
|
3641 dev->name, status); |
3642 } |
3642 } |
3643 |
3643 } |
3644 /* Work around for rx fifo overflow */ |
3644 out: |
3645 if (unlikely(status & RxFIFOOver) && |
|
3646 (tp->mac_version == RTL_GIGA_MAC_VER_11)) { |
|
3647 netif_stop_queue(dev); |
|
3648 rtl8169_tx_timeout(dev); |
|
3649 break; |
|
3650 } |
|
3651 |
|
3652 if (unlikely(status & SYSErr)) { |
|
3653 rtl8169_pcierr_interrupt(dev); |
|
3654 break; |
|
3655 } |
|
3656 |
|
3657 if (status & LinkChg) |
|
3658 rtl8169_check_link_status(dev, tp, ioaddr); |
|
3659 |
|
3660 /* We need to see the lastest version of tp->intr_mask to |
|
3661 * avoid ignoring an MSI interrupt and having to wait for |
|
3662 * another event which may never come. |
|
3663 */ |
|
3664 smp_rmb(); |
|
3665 if (status & tp->intr_mask & tp->napi_event) { |
|
3666 RTL_W16(IntrMask, tp->intr_event & ~tp->napi_event); |
|
3667 tp->intr_mask = ~tp->napi_event; |
|
3668 |
|
3669 if (likely(napi_schedule_prep(&tp->napi))) |
|
3670 __napi_schedule(&tp->napi); |
|
3671 else if (netif_msg_intr(tp)) { |
|
3672 printk(KERN_INFO "%s: interrupt %04x in poll\n", |
|
3673 dev->name, status); |
|
3674 } |
|
3675 } |
|
3676 |
|
3677 /* We only get a new MSI interrupt when all active irq |
|
3678 * sources on the chip have been acknowledged. So, ack |
|
3679 * everything we've seen and check if new sources have become |
|
3680 * active to avoid blocking all interrupts from the chip. |
|
3681 */ |
|
3682 RTL_W16(IntrStatus, |
|
3683 (status & RxFIFOOver) ? (status | RxOverflow) : status); |
|
3684 status = RTL_R16(IntrStatus); |
|
3685 } |
|
3686 |
|
3687 return IRQ_RETVAL(handled); |
3645 return IRQ_RETVAL(handled); |
3688 } |
3646 } |
3689 |
3647 |
3690 static void ec_poll(struct net_device *dev) |
3648 static void ec_poll(struct net_device *dev) |
3691 { |
3649 { |
3711 |
3669 |
3712 work_done = rtl8169_rx_interrupt(dev, tp, ioaddr, (u32) budget); |
3670 work_done = rtl8169_rx_interrupt(dev, tp, ioaddr, (u32) budget); |
3713 rtl8169_tx_interrupt(dev, tp, ioaddr); |
3671 rtl8169_tx_interrupt(dev, tp, ioaddr); |
3714 |
3672 |
3715 if (work_done < budget) { |
3673 if (work_done < budget) { |
3716 napi_complete(napi); |
3674 netif_rx_complete(dev, napi); |
3717 |
3675 tp->intr_mask = 0xffff; |
3718 /* We need for force the visibility of tp->intr_mask |
3676 /* |
3719 * for other CPUs, as we can loose an MSI interrupt |
3677 * 20040426: the barrier is not strictly required but the |
3720 * and potentially wait for a retransmit timeout if we don't. |
3678 * behavior of the irq handler could be less predictable |
3721 * The posted write to IntrMask is safe, as it will |
3679 * without it. Btw, the lack of flush for the posted pci |
3722 * eventually make it to the chip and we won't loose anything |
3680 * write is safe - FR |
3723 * until it does. |
|
3724 */ |
3681 */ |
3725 tp->intr_mask = 0xffff; |
|
3726 smp_wmb(); |
3682 smp_wmb(); |
3727 RTL_W16(IntrMask, tp->intr_event); |
3683 RTL_W16(IntrMask, tp->intr_event); |
3728 } |
3684 } |
3729 |
3685 |
3730 return work_done; |
3686 return work_done; |
3894 } |
3847 } |
3895 |
3848 |
3896 return &dev->stats; |
3849 return &dev->stats; |
3897 } |
3850 } |
3898 |
3851 |
3899 static void rtl8169_net_suspend(struct net_device *dev) |
3852 #ifdef CONFIG_PM |
3900 { |
3853 |
|
3854 static int rtl8169_suspend(struct pci_dev *pdev, pm_message_t state) |
|
3855 { |
|
3856 struct net_device *dev = pci_get_drvdata(pdev); |
|
3857 struct rtl8169_private *tp = netdev_priv(dev); |
|
3858 void __iomem *ioaddr = tp->mmio_addr; |
|
3859 |
|
3860 if (tp->ecdev) |
|
3861 return -EBUSY; |
|
3862 |
3901 if (!netif_running(dev)) |
3863 if (!netif_running(dev)) |
3902 return; |
3864 goto out_pci_suspend; |
3903 |
3865 |
3904 netif_device_detach(dev); |
3866 netif_device_detach(dev); |
3905 netif_stop_queue(dev); |
3867 netif_stop_queue(dev); |
3906 } |
3868 |
3907 |
3869 spin_lock_irq(&tp->lock); |
3908 #ifdef CONFIG_PM |
3870 |
3909 |
3871 rtl8169_asic_down(ioaddr); |
3910 static int rtl8169_suspend(struct device *device) |
3872 |
3911 { |
3873 rtl8169_rx_missed(dev, ioaddr); |
3912 struct pci_dev *pdev = to_pci_dev(device); |
3874 |
|
3875 spin_unlock_irq(&tp->lock); |
|
3876 |
|
3877 out_pci_suspend: |
|
3878 pci_save_state(pdev); |
|
3879 pci_enable_wake(pdev, pci_choose_state(pdev, state), |
|
3880 (tp->features & RTL_FEATURE_WOL) ? 1 : 0); |
|
3881 pci_set_power_state(pdev, pci_choose_state(pdev, state)); |
|
3882 |
|
3883 return 0; |
|
3884 } |
|
3885 |
|
3886 static int rtl8169_resume(struct pci_dev *pdev) |
|
3887 { |
3913 struct net_device *dev = pci_get_drvdata(pdev); |
3888 struct net_device *dev = pci_get_drvdata(pdev); |
3914 struct rtl8169_private *tp = netdev_priv(dev); |
3889 struct rtl8169_private *tp = netdev_priv(dev); |
3915 |
3890 |
3916 if (tp->ecdev) |
|
3917 return -EBUSY; |
|
3918 |
|
3919 rtl8169_net_suspend(dev); |
|
3920 |
|
3921 return 0; |
|
3922 } |
|
3923 |
|
3924 static int rtl8169_resume(struct device *device) |
|
3925 { |
|
3926 struct pci_dev *pdev = to_pci_dev(device); |
|
3927 struct net_device *dev = pci_get_drvdata(pdev); |
|
3928 struct rtl8169_private *tp = netdev_priv(dev); |
|
3929 |
|
3930 if (tp->ecdev) |
3891 if (tp->ecdev) |
3931 return -EBUSY; |
3892 return -EBUSY; |
|
3893 |
|
3894 pci_set_power_state(pdev, PCI_D0); |
|
3895 pci_restore_state(pdev); |
|
3896 pci_enable_wake(pdev, PCI_D0, 0); |
3932 |
3897 |
3933 if (!netif_running(dev)) |
3898 if (!netif_running(dev)) |
3934 goto out; |
3899 goto out; |
3935 |
3900 |
3936 netif_device_attach(dev); |
3901 netif_device_attach(dev); |
3938 rtl8169_schedule_work(dev, rtl8169_reset_task); |
3903 rtl8169_schedule_work(dev, rtl8169_reset_task); |
3939 out: |
3904 out: |
3940 return 0; |
3905 return 0; |
3941 } |
3906 } |
3942 |
3907 |
3943 static struct dev_pm_ops rtl8169_pm_ops = { |
|
3944 .suspend = rtl8169_suspend, |
|
3945 .resume = rtl8169_resume, |
|
3946 .freeze = rtl8169_suspend, |
|
3947 .thaw = rtl8169_resume, |
|
3948 .poweroff = rtl8169_suspend, |
|
3949 .restore = rtl8169_resume, |
|
3950 }; |
|
3951 |
|
3952 #define RTL8169_PM_OPS (&rtl8169_pm_ops) |
|
3953 |
|
3954 #else /* !CONFIG_PM */ |
|
3955 |
|
3956 #define RTL8169_PM_OPS NULL |
|
3957 |
|
3958 #endif /* !CONFIG_PM */ |
|
3959 |
|
3960 static void rtl_shutdown(struct pci_dev *pdev) |
3908 static void rtl_shutdown(struct pci_dev *pdev) |
3961 { |
3909 { |
3962 struct net_device *dev = pci_get_drvdata(pdev); |
3910 rtl8169_suspend(pdev, PMSG_SUSPEND); |
3963 struct rtl8169_private *tp = netdev_priv(dev); |
3911 } |
3964 void __iomem *ioaddr = tp->mmio_addr; |
3912 |
3965 |
3913 #endif /* CONFIG_PM */ |
3966 rtl8169_net_suspend(dev); |
|
3967 |
|
3968 spin_lock_irq(&tp->lock); |
|
3969 |
|
3970 rtl8169_asic_down(ioaddr); |
|
3971 |
|
3972 spin_unlock_irq(&tp->lock); |
|
3973 |
|
3974 if (system_state == SYSTEM_POWER_OFF) { |
|
3975 /* WoL fails with some 8168 when the receiver is disabled. */ |
|
3976 if (tp->features & RTL_FEATURE_WOL) { |
|
3977 pci_clear_master(pdev); |
|
3978 |
|
3979 RTL_W8(ChipCmd, CmdRxEnb); |
|
3980 /* PCI commit */ |
|
3981 RTL_R8(ChipCmd); |
|
3982 } |
|
3983 |
|
3984 pci_wake_from_d3(pdev, true); |
|
3985 pci_set_power_state(pdev, PCI_D3hot); |
|
3986 } |
|
3987 } |
|
3988 |
3914 |
3989 static struct pci_driver rtl8169_pci_driver = { |
3915 static struct pci_driver rtl8169_pci_driver = { |
3990 .name = MODULENAME, |
3916 .name = MODULENAME, |
3991 .id_table = rtl8169_pci_tbl, |
3917 .id_table = rtl8169_pci_tbl, |
3992 .probe = rtl8169_init_one, |
3918 .probe = rtl8169_init_one, |
3993 .remove = __devexit_p(rtl8169_remove_one), |
3919 .remove = __devexit_p(rtl8169_remove_one), |
|
3920 #ifdef CONFIG_PM |
|
3921 .suspend = rtl8169_suspend, |
|
3922 .resume = rtl8169_resume, |
3994 .shutdown = rtl_shutdown, |
3923 .shutdown = rtl_shutdown, |
3995 .driver.pm = RTL8169_PM_OPS, |
3924 #endif |
3996 }; |
3925 }; |
3997 |
3926 |
3998 static int __init rtl8169_init_module(void) |
3927 static int __init rtl8169_init_module(void) |
3999 { |
3928 { |
4000 return pci_register_driver(&rtl8169_pci_driver); |
3929 return pci_register_driver(&rtl8169_pci_driver); |