diff options
-rw-r--r-- | drivers/net/Kconfig | 9 | ||||
-rw-r--r-- | drivers/net/r8169.c | 272 |
2 files changed, 178 insertions, 103 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index fba89ae2926b..7ce3dd01d6eb 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -2245,15 +2245,6 @@ config R8169 | |||
2245 | To compile this driver as a module, choose M here: the module | 2245 | To compile this driver as a module, choose M here: the module |
2246 | will be called r8169. This is recommended. | 2246 | will be called r8169. This is recommended. |
2247 | 2247 | ||
2248 | config R8169_VLAN | ||
2249 | bool "VLAN support" | ||
2250 | depends on R8169 && VLAN_8021Q | ||
2251 | ---help--- | ||
2252 | Say Y here for the r8169 driver to support the functions required | ||
2253 | by the kernel 802.1Q code. | ||
2254 | |||
2255 | If in doubt, say Y. | ||
2256 | |||
2257 | config SB1250_MAC | 2248 | config SB1250_MAC |
2258 | tristate "SB1250 Gigabit Ethernet support" | 2249 | tristate "SB1250 Gigabit Ethernet support" |
2259 | depends on SIBYTE_SB1xxx_SOC | 2250 | depends on SIBYTE_SB1xxx_SOC |
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 7ffdb80adf40..5e403511289d 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | #define FIRMWARE_8168D_1 "rtl_nic/rtl8168d-1.fw" | 38 | #define FIRMWARE_8168D_1 "rtl_nic/rtl8168d-1.fw" |
39 | #define FIRMWARE_8168D_2 "rtl_nic/rtl8168d-2.fw" | 39 | #define FIRMWARE_8168D_2 "rtl_nic/rtl8168d-2.fw" |
40 | #define FIRMWARE_8105E_1 "rtl_nic/rtl8105e-1.fw" | ||
40 | 41 | ||
41 | #ifdef RTL8169_DEBUG | 42 | #ifdef RTL8169_DEBUG |
42 | #define assert(expr) \ | 43 | #define assert(expr) \ |
@@ -124,6 +125,8 @@ enum mac_version { | |||
124 | RTL_GIGA_MAC_VER_26 = 0x1a, // 8168D | 125 | RTL_GIGA_MAC_VER_26 = 0x1a, // 8168D |
125 | RTL_GIGA_MAC_VER_27 = 0x1b, // 8168DP | 126 | RTL_GIGA_MAC_VER_27 = 0x1b, // 8168DP |
126 | RTL_GIGA_MAC_VER_28 = 0x1c, // 8168DP | 127 | RTL_GIGA_MAC_VER_28 = 0x1c, // 8168DP |
128 | RTL_GIGA_MAC_VER_29 = 0x1d, // 8105E | ||
129 | RTL_GIGA_MAC_VER_30 = 0x1e, // 8105E | ||
127 | }; | 130 | }; |
128 | 131 | ||
129 | #define _R(NAME,MAC,MASK) \ | 132 | #define _R(NAME,MAC,MASK) \ |
@@ -161,7 +164,9 @@ static const struct { | |||
161 | _R("RTL8168d/8111d", RTL_GIGA_MAC_VER_25, 0xff7e1880), // PCI-E | 164 | _R("RTL8168d/8111d", RTL_GIGA_MAC_VER_25, 0xff7e1880), // PCI-E |
162 | _R("RTL8168d/8111d", RTL_GIGA_MAC_VER_26, 0xff7e1880), // PCI-E | 165 | _R("RTL8168d/8111d", RTL_GIGA_MAC_VER_26, 0xff7e1880), // PCI-E |
163 | _R("RTL8168dp/8111dp", RTL_GIGA_MAC_VER_27, 0xff7e1880), // PCI-E | 166 | _R("RTL8168dp/8111dp", RTL_GIGA_MAC_VER_27, 0xff7e1880), // PCI-E |
164 | _R("RTL8168dp/8111dp", RTL_GIGA_MAC_VER_28, 0xff7e1880) // PCI-E | 167 | _R("RTL8168dp/8111dp", RTL_GIGA_MAC_VER_28, 0xff7e1880), // PCI-E |
168 | _R("RTL8105e", RTL_GIGA_MAC_VER_29, 0xff7e1880), // PCI-E | ||
169 | _R("RTL8105e", RTL_GIGA_MAC_VER_30, 0xff7e1880) // PCI-E | ||
165 | }; | 170 | }; |
166 | #undef _R | 171 | #undef _R |
167 | 172 | ||
@@ -268,9 +273,15 @@ enum rtl8168_8101_registers { | |||
268 | #define EPHYAR_REG_MASK 0x1f | 273 | #define EPHYAR_REG_MASK 0x1f |
269 | #define EPHYAR_REG_SHIFT 16 | 274 | #define EPHYAR_REG_SHIFT 16 |
270 | #define EPHYAR_DATA_MASK 0xffff | 275 | #define EPHYAR_DATA_MASK 0xffff |
276 | DLLPR = 0xd0, | ||
277 | #define PM_SWITCH (1 << 6) | ||
271 | DBG_REG = 0xd1, | 278 | DBG_REG = 0xd1, |
272 | #define FIX_NAK_1 (1 << 4) | 279 | #define FIX_NAK_1 (1 << 4) |
273 | #define FIX_NAK_2 (1 << 3) | 280 | #define FIX_NAK_2 (1 << 3) |
281 | TWSI = 0xd2, | ||
282 | MCU = 0xd3, | ||
283 | #define EN_NDP (1 << 3) | ||
284 | #define EN_OOB_RESET (1 << 2) | ||
274 | EFUSEAR = 0xdc, | 285 | EFUSEAR = 0xdc, |
275 | #define EFUSEAR_FLAG 0x80000000 | 286 | #define EFUSEAR_FLAG 0x80000000 |
276 | #define EFUSEAR_WRITE_CMD 0x80000000 | 287 | #define EFUSEAR_WRITE_CMD 0x80000000 |
@@ -527,9 +538,6 @@ struct rtl8169_private { | |||
527 | u16 napi_event; | 538 | u16 napi_event; |
528 | u16 intr_mask; | 539 | u16 intr_mask; |
529 | int phy_1000_ctrl_reg; | 540 | int phy_1000_ctrl_reg; |
530 | #ifdef CONFIG_R8169_VLAN | ||
531 | struct vlan_group *vlgrp; | ||
532 | #endif | ||
533 | 541 | ||
534 | struct mdio_ops { | 542 | struct mdio_ops { |
535 | void (*write)(void __iomem *, int, int); | 543 | void (*write)(void __iomem *, int, int); |
@@ -541,7 +549,7 @@ struct rtl8169_private { | |||
541 | void (*up)(struct rtl8169_private *); | 549 | void (*up)(struct rtl8169_private *); |
542 | } pll_power_ops; | 550 | } pll_power_ops; |
543 | 551 | ||
544 | int (*set_speed)(struct net_device *, u8 autoneg, u16 speed, u8 duplex); | 552 | int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv); |
545 | int (*get_settings)(struct net_device *, struct ethtool_cmd *); | 553 | int (*get_settings)(struct net_device *, struct ethtool_cmd *); |
546 | void (*phy_reset_enable)(struct rtl8169_private *tp); | 554 | void (*phy_reset_enable)(struct rtl8169_private *tp); |
547 | void (*hw_start)(struct net_device *); | 555 | void (*hw_start)(struct net_device *); |
@@ -569,6 +577,7 @@ MODULE_LICENSE("GPL"); | |||
569 | MODULE_VERSION(RTL8169_VERSION); | 577 | MODULE_VERSION(RTL8169_VERSION); |
570 | MODULE_FIRMWARE(FIRMWARE_8168D_1); | 578 | MODULE_FIRMWARE(FIRMWARE_8168D_1); |
571 | MODULE_FIRMWARE(FIRMWARE_8168D_2); | 579 | MODULE_FIRMWARE(FIRMWARE_8168D_2); |
580 | MODULE_FIRMWARE(FIRMWARE_8105E_1); | ||
572 | 581 | ||
573 | static int rtl8169_open(struct net_device *dev); | 582 | static int rtl8169_open(struct net_device *dev); |
574 | static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, | 583 | static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, |
@@ -1098,7 +1107,7 @@ static int rtl8169_get_regs_len(struct net_device *dev) | |||
1098 | } | 1107 | } |
1099 | 1108 | ||
1100 | static int rtl8169_set_speed_tbi(struct net_device *dev, | 1109 | static int rtl8169_set_speed_tbi(struct net_device *dev, |
1101 | u8 autoneg, u16 speed, u8 duplex) | 1110 | u8 autoneg, u16 speed, u8 duplex, u32 ignored) |
1102 | { | 1111 | { |
1103 | struct rtl8169_private *tp = netdev_priv(dev); | 1112 | struct rtl8169_private *tp = netdev_priv(dev); |
1104 | void __iomem *ioaddr = tp->mmio_addr; | 1113 | void __iomem *ioaddr = tp->mmio_addr; |
@@ -1121,17 +1130,30 @@ static int rtl8169_set_speed_tbi(struct net_device *dev, | |||
1121 | } | 1130 | } |
1122 | 1131 | ||
1123 | static int rtl8169_set_speed_xmii(struct net_device *dev, | 1132 | static int rtl8169_set_speed_xmii(struct net_device *dev, |
1124 | u8 autoneg, u16 speed, u8 duplex) | 1133 | u8 autoneg, u16 speed, u8 duplex, u32 adv) |
1125 | { | 1134 | { |
1126 | struct rtl8169_private *tp = netdev_priv(dev); | 1135 | struct rtl8169_private *tp = netdev_priv(dev); |
1127 | int giga_ctrl, bmcr; | 1136 | int giga_ctrl, bmcr; |
1137 | int rc = -EINVAL; | ||
1138 | |||
1139 | rtl_writephy(tp, 0x1f, 0x0000); | ||
1128 | 1140 | ||
1129 | if (autoneg == AUTONEG_ENABLE) { | 1141 | if (autoneg == AUTONEG_ENABLE) { |
1130 | int auto_nego; | 1142 | int auto_nego; |
1131 | 1143 | ||
1132 | auto_nego = rtl_readphy(tp, MII_ADVERTISE); | 1144 | auto_nego = rtl_readphy(tp, MII_ADVERTISE); |
1133 | auto_nego |= (ADVERTISE_10HALF | ADVERTISE_10FULL | | 1145 | auto_nego &= ~(ADVERTISE_10HALF | ADVERTISE_10FULL | |
1134 | ADVERTISE_100HALF | ADVERTISE_100FULL); | 1146 | ADVERTISE_100HALF | ADVERTISE_100FULL); |
1147 | |||
1148 | if (adv & ADVERTISED_10baseT_Half) | ||
1149 | auto_nego |= ADVERTISE_10HALF; | ||
1150 | if (adv & ADVERTISED_10baseT_Full) | ||
1151 | auto_nego |= ADVERTISE_10FULL; | ||
1152 | if (adv & ADVERTISED_100baseT_Half) | ||
1153 | auto_nego |= ADVERTISE_100HALF; | ||
1154 | if (adv & ADVERTISED_100baseT_Full) | ||
1155 | auto_nego |= ADVERTISE_100FULL; | ||
1156 | |||
1135 | auto_nego |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM; | 1157 | auto_nego |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM; |
1136 | 1158 | ||
1137 | giga_ctrl = rtl_readphy(tp, MII_CTRL1000); | 1159 | giga_ctrl = rtl_readphy(tp, MII_CTRL1000); |
@@ -1145,27 +1167,22 @@ static int rtl8169_set_speed_xmii(struct net_device *dev, | |||
1145 | (tp->mac_version != RTL_GIGA_MAC_VER_13) && | 1167 | (tp->mac_version != RTL_GIGA_MAC_VER_13) && |
1146 | (tp->mac_version != RTL_GIGA_MAC_VER_14) && | 1168 | (tp->mac_version != RTL_GIGA_MAC_VER_14) && |
1147 | (tp->mac_version != RTL_GIGA_MAC_VER_15) && | 1169 | (tp->mac_version != RTL_GIGA_MAC_VER_15) && |
1148 | (tp->mac_version != RTL_GIGA_MAC_VER_16)) { | 1170 | (tp->mac_version != RTL_GIGA_MAC_VER_16) && |
1149 | giga_ctrl |= ADVERTISE_1000FULL | ADVERTISE_1000HALF; | 1171 | (tp->mac_version != RTL_GIGA_MAC_VER_29) && |
1150 | } else { | 1172 | (tp->mac_version != RTL_GIGA_MAC_VER_30)) { |
1173 | if (adv & ADVERTISED_1000baseT_Half) | ||
1174 | giga_ctrl |= ADVERTISE_1000HALF; | ||
1175 | if (adv & ADVERTISED_1000baseT_Full) | ||
1176 | giga_ctrl |= ADVERTISE_1000FULL; | ||
1177 | } else if (adv & (ADVERTISED_1000baseT_Half | | ||
1178 | ADVERTISED_1000baseT_Full)) { | ||
1151 | netif_info(tp, link, dev, | 1179 | netif_info(tp, link, dev, |
1152 | "PHY does not support 1000Mbps\n"); | 1180 | "PHY does not support 1000Mbps\n"); |
1181 | goto out; | ||
1153 | } | 1182 | } |
1154 | 1183 | ||
1155 | bmcr = BMCR_ANENABLE | BMCR_ANRESTART; | 1184 | bmcr = BMCR_ANENABLE | BMCR_ANRESTART; |
1156 | 1185 | ||
1157 | if ((tp->mac_version == RTL_GIGA_MAC_VER_11) || | ||
1158 | (tp->mac_version == RTL_GIGA_MAC_VER_12) || | ||
1159 | (tp->mac_version >= RTL_GIGA_MAC_VER_17)) { | ||
1160 | /* | ||
1161 | * Wake up the PHY. | ||
1162 | * Vendor specific (0x1f) and reserved (0x0e) MII | ||
1163 | * registers. | ||
1164 | */ | ||
1165 | rtl_writephy(tp, 0x1f, 0x0000); | ||
1166 | rtl_writephy(tp, 0x0e, 0x0000); | ||
1167 | } | ||
1168 | |||
1169 | rtl_writephy(tp, MII_ADVERTISE, auto_nego); | 1186 | rtl_writephy(tp, MII_ADVERTISE, auto_nego); |
1170 | rtl_writephy(tp, MII_CTRL1000, giga_ctrl); | 1187 | rtl_writephy(tp, MII_CTRL1000, giga_ctrl); |
1171 | } else { | 1188 | } else { |
@@ -1176,12 +1193,10 @@ static int rtl8169_set_speed_xmii(struct net_device *dev, | |||
1176 | else if (speed == SPEED_100) | 1193 | else if (speed == SPEED_100) |
1177 | bmcr = BMCR_SPEED100; | 1194 | bmcr = BMCR_SPEED100; |
1178 | else | 1195 | else |
1179 | return -EINVAL; | 1196 | goto out; |
1180 | 1197 | ||
1181 | if (duplex == DUPLEX_FULL) | 1198 | if (duplex == DUPLEX_FULL) |
1182 | bmcr |= BMCR_FULLDPLX; | 1199 | bmcr |= BMCR_FULLDPLX; |
1183 | |||
1184 | rtl_writephy(tp, 0x1f, 0x0000); | ||
1185 | } | 1200 | } |
1186 | 1201 | ||
1187 | tp->phy_1000_ctrl_reg = giga_ctrl; | 1202 | tp->phy_1000_ctrl_reg = giga_ctrl; |
@@ -1199,16 +1214,18 @@ static int rtl8169_set_speed_xmii(struct net_device *dev, | |||
1199 | } | 1214 | } |
1200 | } | 1215 | } |
1201 | 1216 | ||
1202 | return 0; | 1217 | rc = 0; |
1218 | out: | ||
1219 | return rc; | ||
1203 | } | 1220 | } |
1204 | 1221 | ||
1205 | static int rtl8169_set_speed(struct net_device *dev, | 1222 | static int rtl8169_set_speed(struct net_device *dev, |
1206 | u8 autoneg, u16 speed, u8 duplex) | 1223 | u8 autoneg, u16 speed, u8 duplex, u32 advertising) |
1207 | { | 1224 | { |
1208 | struct rtl8169_private *tp = netdev_priv(dev); | 1225 | struct rtl8169_private *tp = netdev_priv(dev); |
1209 | int ret; | 1226 | int ret; |
1210 | 1227 | ||
1211 | ret = tp->set_speed(dev, autoneg, speed, duplex); | 1228 | ret = tp->set_speed(dev, autoneg, speed, duplex, advertising); |
1212 | 1229 | ||
1213 | if (netif_running(dev) && (tp->phy_1000_ctrl_reg & ADVERTISE_1000FULL)) | 1230 | if (netif_running(dev) && (tp->phy_1000_ctrl_reg & ADVERTISE_1000FULL)) |
1214 | mod_timer(&tp->timer, jiffies + RTL8169_PHY_TIMEOUT); | 1231 | mod_timer(&tp->timer, jiffies + RTL8169_PHY_TIMEOUT); |
@@ -1223,7 +1240,8 @@ static int rtl8169_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1223 | int ret; | 1240 | int ret; |
1224 | 1241 | ||
1225 | spin_lock_irqsave(&tp->lock, flags); | 1242 | spin_lock_irqsave(&tp->lock, flags); |
1226 | ret = rtl8169_set_speed(dev, cmd->autoneg, cmd->speed, cmd->duplex); | 1243 | ret = rtl8169_set_speed(dev, |
1244 | cmd->autoneg, cmd->speed, cmd->duplex, cmd->advertising); | ||
1227 | spin_unlock_irqrestore(&tp->lock, flags); | 1245 | spin_unlock_irqrestore(&tp->lock, flags); |
1228 | 1246 | ||
1229 | return ret; | 1247 | return ret; |
@@ -1257,8 +1275,6 @@ static int rtl8169_set_rx_csum(struct net_device *dev, u32 data) | |||
1257 | return 0; | 1275 | return 0; |
1258 | } | 1276 | } |
1259 | 1277 | ||
1260 | #ifdef CONFIG_R8169_VLAN | ||
1261 | |||
1262 | static inline u32 rtl8169_tx_vlan_tag(struct rtl8169_private *tp, | 1278 | static inline u32 rtl8169_tx_vlan_tag(struct rtl8169_private *tp, |
1263 | struct sk_buff *skb) | 1279 | struct sk_buff *skb) |
1264 | { | 1280 | { |
@@ -1266,64 +1282,37 @@ static inline u32 rtl8169_tx_vlan_tag(struct rtl8169_private *tp, | |||
1266 | TxVlanTag | swab16(vlan_tx_tag_get(skb)) : 0x00; | 1282 | TxVlanTag | swab16(vlan_tx_tag_get(skb)) : 0x00; |
1267 | } | 1283 | } |
1268 | 1284 | ||
1269 | static void rtl8169_vlan_rx_register(struct net_device *dev, | 1285 | #define NETIF_F_HW_VLAN_TX_RX (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX) |
1270 | struct vlan_group *grp) | 1286 | |
1287 | static void rtl8169_vlan_mode(struct net_device *dev) | ||
1271 | { | 1288 | { |
1272 | struct rtl8169_private *tp = netdev_priv(dev); | 1289 | struct rtl8169_private *tp = netdev_priv(dev); |
1273 | void __iomem *ioaddr = tp->mmio_addr; | 1290 | void __iomem *ioaddr = tp->mmio_addr; |
1274 | unsigned long flags; | 1291 | unsigned long flags; |
1275 | 1292 | ||
1276 | spin_lock_irqsave(&tp->lock, flags); | 1293 | spin_lock_irqsave(&tp->lock, flags); |
1277 | tp->vlgrp = grp; | 1294 | if (dev->features & NETIF_F_HW_VLAN_RX) |
1278 | /* | ||
1279 | * Do not disable RxVlan on 8110SCd. | ||
1280 | */ | ||
1281 | if (tp->vlgrp || (tp->mac_version == RTL_GIGA_MAC_VER_05)) | ||
1282 | tp->cp_cmd |= RxVlan; | 1295 | tp->cp_cmd |= RxVlan; |
1283 | else | 1296 | else |
1284 | tp->cp_cmd &= ~RxVlan; | 1297 | tp->cp_cmd &= ~RxVlan; |
1285 | RTL_W16(CPlusCmd, tp->cp_cmd); | 1298 | RTL_W16(CPlusCmd, tp->cp_cmd); |
1299 | /* PCI commit */ | ||
1286 | RTL_R16(CPlusCmd); | 1300 | RTL_R16(CPlusCmd); |
1287 | spin_unlock_irqrestore(&tp->lock, flags); | 1301 | spin_unlock_irqrestore(&tp->lock, flags); |
1302 | |||
1303 | dev->vlan_features = dev->features &~ NETIF_F_HW_VLAN_TX_RX; | ||
1288 | } | 1304 | } |
1289 | 1305 | ||
1290 | static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, | 1306 | static void rtl8169_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb) |
1291 | struct sk_buff *skb, int polling) | ||
1292 | { | 1307 | { |
1293 | u32 opts2 = le32_to_cpu(desc->opts2); | 1308 | u32 opts2 = le32_to_cpu(desc->opts2); |
1294 | struct vlan_group *vlgrp = tp->vlgrp; | ||
1295 | int ret; | ||
1296 | 1309 | ||
1297 | if (vlgrp && (opts2 & RxVlanTag)) { | 1310 | if (opts2 & RxVlanTag) |
1298 | u16 vtag = swab16(opts2 & 0xffff); | 1311 | __vlan_hwaccel_put_tag(skb, swab16(opts2 & 0xffff)); |
1299 | 1312 | ||
1300 | if (likely(polling)) | ||
1301 | vlan_gro_receive(&tp->napi, vlgrp, vtag, skb); | ||
1302 | else | ||
1303 | __vlan_hwaccel_rx(skb, vlgrp, vtag, polling); | ||
1304 | ret = 0; | ||
1305 | } else | ||
1306 | ret = -1; | ||
1307 | desc->opts2 = 0; | 1313 | desc->opts2 = 0; |
1308 | return ret; | ||
1309 | } | 1314 | } |
1310 | 1315 | ||
1311 | #else /* !CONFIG_R8169_VLAN */ | ||
1312 | |||
1313 | static inline u32 rtl8169_tx_vlan_tag(struct rtl8169_private *tp, | ||
1314 | struct sk_buff *skb) | ||
1315 | { | ||
1316 | return 0; | ||
1317 | } | ||
1318 | |||
1319 | static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, | ||
1320 | struct sk_buff *skb, int polling) | ||
1321 | { | ||
1322 | return -1; | ||
1323 | } | ||
1324 | |||
1325 | #endif | ||
1326 | |||
1327 | static int rtl8169_gset_tbi(struct net_device *dev, struct ethtool_cmd *cmd) | 1316 | static int rtl8169_gset_tbi(struct net_device *dev, struct ethtool_cmd *cmd) |
1328 | { | 1317 | { |
1329 | struct rtl8169_private *tp = netdev_priv(dev); | 1318 | struct rtl8169_private *tp = netdev_priv(dev); |
@@ -1494,6 +1483,28 @@ static void rtl8169_get_strings(struct net_device *dev, u32 stringset, u8 *data) | |||
1494 | } | 1483 | } |
1495 | } | 1484 | } |
1496 | 1485 | ||
1486 | static int rtl8169_set_flags(struct net_device *dev, u32 data) | ||
1487 | { | ||
1488 | struct rtl8169_private *tp = netdev_priv(dev); | ||
1489 | unsigned long old_feat = dev->features; | ||
1490 | int rc; | ||
1491 | |||
1492 | if ((tp->mac_version == RTL_GIGA_MAC_VER_05) && | ||
1493 | !(data & ETH_FLAG_RXVLAN)) { | ||
1494 | netif_info(tp, drv, dev, "8110SCd requires hardware Rx VLAN\n"); | ||
1495 | return -EINVAL; | ||
1496 | } | ||
1497 | |||
1498 | rc = ethtool_op_set_flags(dev, data, ETH_FLAG_TXVLAN | ETH_FLAG_RXVLAN); | ||
1499 | if (rc) | ||
1500 | return rc; | ||
1501 | |||
1502 | if ((old_feat ^ dev->features) & NETIF_F_HW_VLAN_RX) | ||
1503 | rtl8169_vlan_mode(dev); | ||
1504 | |||
1505 | return 0; | ||
1506 | } | ||
1507 | |||
1497 | static const struct ethtool_ops rtl8169_ethtool_ops = { | 1508 | static const struct ethtool_ops rtl8169_ethtool_ops = { |
1498 | .get_drvinfo = rtl8169_get_drvinfo, | 1509 | .get_drvinfo = rtl8169_get_drvinfo, |
1499 | .get_regs_len = rtl8169_get_regs_len, | 1510 | .get_regs_len = rtl8169_get_regs_len, |
@@ -1513,6 +1524,8 @@ static const struct ethtool_ops rtl8169_ethtool_ops = { | |||
1513 | .get_strings = rtl8169_get_strings, | 1524 | .get_strings = rtl8169_get_strings, |
1514 | .get_sset_count = rtl8169_get_sset_count, | 1525 | .get_sset_count = rtl8169_get_sset_count, |
1515 | .get_ethtool_stats = rtl8169_get_ethtool_stats, | 1526 | .get_ethtool_stats = rtl8169_get_ethtool_stats, |
1527 | .set_flags = rtl8169_set_flags, | ||
1528 | .get_flags = ethtool_op_get_flags, | ||
1516 | }; | 1529 | }; |
1517 | 1530 | ||
1518 | static void rtl8169_get_mac_version(struct rtl8169_private *tp, | 1531 | static void rtl8169_get_mac_version(struct rtl8169_private *tp, |
@@ -1561,6 +1574,9 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp, | |||
1561 | { 0x7c800000, 0x30000000, RTL_GIGA_MAC_VER_11 }, | 1574 | { 0x7c800000, 0x30000000, RTL_GIGA_MAC_VER_11 }, |
1562 | 1575 | ||
1563 | /* 8101 family. */ | 1576 | /* 8101 family. */ |
1577 | { 0x7cf00000, 0x40a00000, RTL_GIGA_MAC_VER_30 }, | ||
1578 | { 0x7cf00000, 0x40900000, RTL_GIGA_MAC_VER_29 }, | ||
1579 | { 0x7c800000, 0x40800000, RTL_GIGA_MAC_VER_30 }, | ||
1564 | { 0x7cf00000, 0x34a00000, RTL_GIGA_MAC_VER_09 }, | 1580 | { 0x7cf00000, 0x34a00000, RTL_GIGA_MAC_VER_09 }, |
1565 | { 0x7cf00000, 0x24a00000, RTL_GIGA_MAC_VER_09 }, | 1581 | { 0x7cf00000, 0x24a00000, RTL_GIGA_MAC_VER_09 }, |
1566 | { 0x7cf00000, 0x34900000, RTL_GIGA_MAC_VER_08 }, | 1582 | { 0x7cf00000, 0x34900000, RTL_GIGA_MAC_VER_08 }, |
@@ -2437,6 +2453,33 @@ static void rtl8102e_hw_phy_config(struct rtl8169_private *tp) | |||
2437 | rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); | 2453 | rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); |
2438 | } | 2454 | } |
2439 | 2455 | ||
2456 | static void rtl8105e_hw_phy_config(struct rtl8169_private *tp) | ||
2457 | { | ||
2458 | static const struct phy_reg phy_reg_init[] = { | ||
2459 | { 0x1f, 0x0005 }, | ||
2460 | { 0x1a, 0x0000 }, | ||
2461 | { 0x1f, 0x0000 }, | ||
2462 | |||
2463 | { 0x1f, 0x0004 }, | ||
2464 | { 0x1c, 0x0000 }, | ||
2465 | { 0x1f, 0x0000 }, | ||
2466 | |||
2467 | { 0x1f, 0x0001 }, | ||
2468 | { 0x15, 0x7701 }, | ||
2469 | { 0x1f, 0x0000 } | ||
2470 | }; | ||
2471 | |||
2472 | /* Disable ALDPS before ram code */ | ||
2473 | rtl_writephy(tp, 0x1f, 0x0000); | ||
2474 | rtl_writephy(tp, 0x18, 0x0310); | ||
2475 | msleep(100); | ||
2476 | |||
2477 | if (rtl_apply_firmware(tp, FIRMWARE_8105E_1) < 0) | ||
2478 | netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n"); | ||
2479 | |||
2480 | rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); | ||
2481 | } | ||
2482 | |||
2440 | static void rtl_hw_phy_config(struct net_device *dev) | 2483 | static void rtl_hw_phy_config(struct net_device *dev) |
2441 | { | 2484 | { |
2442 | struct rtl8169_private *tp = netdev_priv(dev); | 2485 | struct rtl8169_private *tp = netdev_priv(dev); |
@@ -2504,6 +2547,10 @@ static void rtl_hw_phy_config(struct net_device *dev) | |||
2504 | case RTL_GIGA_MAC_VER_28: | 2547 | case RTL_GIGA_MAC_VER_28: |
2505 | rtl8168d_4_hw_phy_config(tp); | 2548 | rtl8168d_4_hw_phy_config(tp); |
2506 | break; | 2549 | break; |
2550 | case RTL_GIGA_MAC_VER_29: | ||
2551 | case RTL_GIGA_MAC_VER_30: | ||
2552 | rtl8105e_hw_phy_config(tp); | ||
2553 | break; | ||
2507 | 2554 | ||
2508 | default: | 2555 | default: |
2509 | break; | 2556 | break; |
@@ -2635,11 +2682,12 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) | |||
2635 | 2682 | ||
2636 | rtl8169_phy_reset(dev, tp); | 2683 | rtl8169_phy_reset(dev, tp); |
2637 | 2684 | ||
2638 | /* | 2685 | rtl8169_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL, |
2639 | * rtl8169_set_speed_xmii takes good care of the Fast Ethernet | 2686 | ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full | |
2640 | * only 8101. Don't panic. | 2687 | ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full | |
2641 | */ | 2688 | tp->mii.supports_gmii ? |
2642 | rtl8169_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL); | 2689 | ADVERTISED_1000baseT_Half | |
2690 | ADVERTISED_1000baseT_Full : 0); | ||
2643 | 2691 | ||
2644 | if (RTL_R8(PHYstatus) & TBI_Enable) | 2692 | if (RTL_R8(PHYstatus) & TBI_Enable) |
2645 | netif_info(tp, link, dev, "TBI auto-negotiating\n"); | 2693 | netif_info(tp, link, dev, "TBI auto-negotiating\n"); |
@@ -2795,9 +2843,6 @@ static const struct net_device_ops rtl8169_netdev_ops = { | |||
2795 | .ndo_set_mac_address = rtl_set_mac_address, | 2843 | .ndo_set_mac_address = rtl_set_mac_address, |
2796 | .ndo_do_ioctl = rtl8169_ioctl, | 2844 | .ndo_do_ioctl = rtl8169_ioctl, |
2797 | .ndo_set_multicast_list = rtl_set_rx_mode, | 2845 | .ndo_set_multicast_list = rtl_set_rx_mode, |
2798 | #ifdef CONFIG_R8169_VLAN | ||
2799 | .ndo_vlan_rx_register = rtl8169_vlan_rx_register, | ||
2800 | #endif | ||
2801 | #ifdef CONFIG_NET_POLL_CONTROLLER | 2846 | #ifdef CONFIG_NET_POLL_CONTROLLER |
2802 | .ndo_poll_controller = rtl8169_netpoll, | 2847 | .ndo_poll_controller = rtl8169_netpoll, |
2803 | #endif | 2848 | #endif |
@@ -2952,6 +2997,8 @@ static void __devinit rtl_init_pll_power_ops(struct rtl8169_private *tp) | |||
2952 | case RTL_GIGA_MAC_VER_09: | 2997 | case RTL_GIGA_MAC_VER_09: |
2953 | case RTL_GIGA_MAC_VER_10: | 2998 | case RTL_GIGA_MAC_VER_10: |
2954 | case RTL_GIGA_MAC_VER_16: | 2999 | case RTL_GIGA_MAC_VER_16: |
3000 | case RTL_GIGA_MAC_VER_29: | ||
3001 | case RTL_GIGA_MAC_VER_30: | ||
2955 | ops->down = r810x_pll_power_down; | 3002 | ops->down = r810x_pll_power_down; |
2956 | ops->up = r810x_pll_power_up; | 3003 | ops->up = r810x_pll_power_up; |
2957 | break; | 3004 | break; |
@@ -3104,6 +3151,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3104 | /* Identify chip attached to board */ | 3151 | /* Identify chip attached to board */ |
3105 | rtl8169_get_mac_version(tp, ioaddr); | 3152 | rtl8169_get_mac_version(tp, ioaddr); |
3106 | 3153 | ||
3154 | /* | ||
3155 | * Pretend we are using VLANs; This bypasses a nasty bug where | ||
3156 | * Interrupts stop flowing on high load on 8110SCd controllers. | ||
3157 | */ | ||
3158 | if (tp->mac_version == RTL_GIGA_MAC_VER_05) | ||
3159 | tp->cp_cmd |= RxVlan; | ||
3160 | |||
3107 | rtl_init_mdio_ops(tp); | 3161 | rtl_init_mdio_ops(tp); |
3108 | rtl_init_pll_power_ops(tp); | 3162 | rtl_init_pll_power_ops(tp); |
3109 | 3163 | ||
@@ -3172,10 +3226,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3172 | 3226 | ||
3173 | netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT); | 3227 | netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT); |
3174 | 3228 | ||
3175 | #ifdef CONFIG_R8169_VLAN | 3229 | dev->features |= NETIF_F_HW_VLAN_TX_RX | NETIF_F_GRO; |
3176 | dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; | ||
3177 | #endif | ||
3178 | dev->features |= NETIF_F_GRO; | ||
3179 | 3230 | ||
3180 | tp->intr_mask = 0xffff; | 3231 | tp->intr_mask = 0xffff; |
3181 | tp->hw_start = cfg->hw_start; | 3232 | tp->hw_start = cfg->hw_start; |
@@ -3293,12 +3344,7 @@ static int rtl8169_open(struct net_device *dev) | |||
3293 | 3344 | ||
3294 | rtl8169_init_phy(dev, tp); | 3345 | rtl8169_init_phy(dev, tp); |
3295 | 3346 | ||
3296 | /* | 3347 | rtl8169_vlan_mode(dev); |
3297 | * Pretend we are using VLANs; This bypasses a nasty bug where | ||
3298 | * Interrupts stop flowing on high load on 8110SCd controllers. | ||
3299 | */ | ||
3300 | if (tp->mac_version == RTL_GIGA_MAC_VER_05) | ||
3301 | RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) | RxVlan); | ||
3302 | 3348 | ||
3303 | rtl_pll_power_up(tp); | 3349 | rtl_pll_power_up(tp); |
3304 | 3350 | ||
@@ -3915,6 +3961,37 @@ static void rtl_hw_start_8102e_3(void __iomem *ioaddr, struct pci_dev *pdev) | |||
3915 | rtl_ephy_write(ioaddr, 0x03, 0xc2f9); | 3961 | rtl_ephy_write(ioaddr, 0x03, 0xc2f9); |
3916 | } | 3962 | } |
3917 | 3963 | ||
3964 | static void rtl_hw_start_8105e_1(void __iomem *ioaddr, struct pci_dev *pdev) | ||
3965 | { | ||
3966 | static const struct ephy_info e_info_8105e_1[] = { | ||
3967 | { 0x07, 0, 0x4000 }, | ||
3968 | { 0x19, 0, 0x0200 }, | ||
3969 | { 0x19, 0, 0x0020 }, | ||
3970 | { 0x1e, 0, 0x2000 }, | ||
3971 | { 0x03, 0, 0x0001 }, | ||
3972 | { 0x19, 0, 0x0100 }, | ||
3973 | { 0x19, 0, 0x0004 }, | ||
3974 | { 0x0a, 0, 0x0020 } | ||
3975 | }; | ||
3976 | |||
3977 | /* Force LAN exit from ASPM if Rx/Tx are not idel */ | ||
3978 | RTL_W32(FuncEvent, RTL_R32(FuncEvent) | 0x002800); | ||
3979 | |||
3980 | /* disable Early Tally Counter */ | ||
3981 | RTL_W32(FuncEvent, RTL_R32(FuncEvent) & ~0x010000); | ||
3982 | |||
3983 | RTL_W8(MCU, RTL_R8(MCU) | EN_NDP | EN_OOB_RESET); | ||
3984 | RTL_W8(DLLPR, RTL_R8(DLLPR) | PM_SWITCH); | ||
3985 | |||
3986 | rtl_ephy_init(ioaddr, e_info_8105e_1, ARRAY_SIZE(e_info_8105e_1)); | ||
3987 | } | ||
3988 | |||
3989 | static void rtl_hw_start_8105e_2(void __iomem *ioaddr, struct pci_dev *pdev) | ||
3990 | { | ||
3991 | rtl_hw_start_8105e_1(ioaddr, pdev); | ||
3992 | rtl_ephy_write(ioaddr, 0x1e, rtl_ephy_read(ioaddr, 0x1e) | 0x8000); | ||
3993 | } | ||
3994 | |||
3918 | static void rtl_hw_start_8101(struct net_device *dev) | 3995 | static void rtl_hw_start_8101(struct net_device *dev) |
3919 | { | 3996 | { |
3920 | struct rtl8169_private *tp = netdev_priv(dev); | 3997 | struct rtl8169_private *tp = netdev_priv(dev); |
@@ -3945,6 +4022,13 @@ static void rtl_hw_start_8101(struct net_device *dev) | |||
3945 | case RTL_GIGA_MAC_VER_09: | 4022 | case RTL_GIGA_MAC_VER_09: |
3946 | rtl_hw_start_8102e_2(ioaddr, pdev); | 4023 | rtl_hw_start_8102e_2(ioaddr, pdev); |
3947 | break; | 4024 | break; |
4025 | |||
4026 | case RTL_GIGA_MAC_VER_29: | ||
4027 | rtl_hw_start_8105e_1(ioaddr, pdev); | ||
4028 | break; | ||
4029 | case RTL_GIGA_MAC_VER_30: | ||
4030 | rtl_hw_start_8105e_2(ioaddr, pdev); | ||
4031 | break; | ||
3948 | } | 4032 | } |
3949 | 4033 | ||
3950 | RTL_W8(Cfg9346, Cfg9346_Lock); | 4034 | RTL_W8(Cfg9346, Cfg9346_Lock); |
@@ -4603,12 +4687,12 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
4603 | skb_put(skb, pkt_size); | 4687 | skb_put(skb, pkt_size); |
4604 | skb->protocol = eth_type_trans(skb, dev); | 4688 | skb->protocol = eth_type_trans(skb, dev); |
4605 | 4689 | ||
4606 | if (rtl8169_rx_vlan_skb(tp, desc, skb, polling) < 0) { | 4690 | rtl8169_rx_vlan_tag(desc, skb); |
4607 | if (likely(polling)) | 4691 | |
4608 | napi_gro_receive(&tp->napi, skb); | 4692 | if (likely(polling)) |
4609 | else | 4693 | napi_gro_receive(&tp->napi, skb); |
4610 | netif_rx(skb); | 4694 | else |
4611 | } | 4695 | netif_rx(skb); |
4612 | 4696 | ||
4613 | dev->stats.rx_bytes += pkt_size; | 4697 | dev->stats.rx_bytes += pkt_size; |
4614 | dev->stats.rx_packets++; | 4698 | dev->stats.rx_packets++; |