Skip to contentSkip to conversation

r8169: separate r8168 driver and add experimental phylib support

RFC PATCH In review Heiner Kallweit 3 participants 32 messages Dec 21, 2017 – Dec 22, 2017

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

cover r8169: separate r8168 driver and add experimental phylib support

This experimental series separates drivers for PCI / PCIE NIC's and adds initial phylib support to the separated r8168 driver.

There are significant differences between the older PCI-based chips (MAC version <= 6) and the newer PCIE-based chips, e.g. the older chips partially support a not MII-compatible TBI fibre mode. Adding phylib support is much easier focusing on the newer chips only. I think separating the drivers is justified and would be interested to hear the opinion of others.

The series works fine on my Zotac Mini-PC with a RTL8168evl (MAC version 34), see also system log (grepped for r8168).

r8168 Gigabit Ethernet driver 2.3LK-NAPI loaded
r8168 0000:03:00.0: enabling device (0000 -> 0003)
libphy: r8168: probed
RTL8211E Gigabit Ethernet r8168-03:00.0:00: attached PHY driver [RTL8211E Gigabit Ethernet] (mii_bus:phy_addr=r8168-03:00.0:00, irq=IGNORE) r8168 0000:03:00.0 eth0: RTL8168evl/8111evl at 0x0000000069abeaff, 00:01:2e:65:37:46, XID 0c900800 IRQ 50
r8168 0000:03:00.0 eth0: jumbo features [frames: 9200 bytes, tx checksumming: ko]
r8168 Gigabit Ethernet driver 2.3LK-NAPI loaded
r8168 0000:04:00.0: enabling device (0000 -> 0003)
libphy: r8168: probed
RTL8211E Gigabit Ethernet r8168-04:00.0:00: attached PHY driver [RTL8211E Gigabit Ethernet] (mii_bus:phy_addr=r8168-04:00.0:00, irq=IGNORE) r8168 0000:04:00.0 eth1: RTL8168evl/8111evl at 0x00000000841e72a7, 00:01:2e:65:37:47, XID 0c900800 IRQ 51
r8168 0000:04:00.0 eth1: jumbo features [frames: 9200 bytes, tx checksumming: ko]
r8168 0000:04:00.0 enp4s0: renamed from eth1
r8168 0000:03:00.0 enp3s0: renamed from eth0
r8168 0000:04:00.0 enp4s0: Link is Down
r8168 0000:04:00.0 enp4s0: Link is Up - 1Gbps/Full - flow control rx/tx

What's still missing:
- Remove all support for chips with MAC version > 06 from r8169 driver. This would drastically reduce its size.

- The driver loads firmware for the PHY, therefore we may need firmware loading support also for the Realtek driver under drivers/net/phy. Best should be to factor out firmware loading support into a separate driver under drivers/firmware.
I have a working experimental version, but it's still WIP.

- Support all NIC-internal PHY's by the Realtek driver under drivers/net/phy and move all PHY init code there.
To do this we'd need a list with the PHY id per chip / MAC version. Just by chance the PHY in RTL8168evl identifies as RTL8211E and has certain support already (w/o firmware).

Heiner Kallweit (18):
r8169: split driver to one for the non-PCIE cards (r8169) and one for the PCIE cards (r8168)
r8168: remove code specific to MAC version 01 - 06
r8168: remove magic register handling used on MAC version 05 and 06 only
r8168: remove TBI mode support needed for MAC version 01 only
r8168: remove unneeded callbacks from struct rtl8169_private
r8168: remove function rtl8169_rx_missed() being specific to MAC version 01 - 06
r8168: replace 8169 with 8168 in all relevant symbols
r8168: add basic phylib support
r8168: use genphy_soft_reset instead of open coding the soft reset
r8168: switch to phy_ethtool_get/set_link_ksettings
r8168: switch to phy_ethtool_nway_reset
r8168: switch to phy_mii_ioctl
r8168: replace speed_down with genphy_restart_aneg
r8168: remove rtl8168_set_speed
r8168: remove rtl_phy_work and rtl8168_phy_timer
r8168: use phy_read/write in rtl_readphy/writephy helpers
r8168: remove use of struct mii_if_info
r8168: use link speed information as maintained by phylib

 drivers/net/ethernet/realtek/Kconfig  |   20 +-
 drivers/net/ethernet/realtek/Makefile |    1 +
 drivers/net/ethernet/realtek/r8168.c  | 8053 +++++++++++++++++++++++++++++++++
 drivers/net/ethernet/realtek/r8169.c  |  112 +-
 4 files changed, 8077 insertions(+), 109 deletions(-)
 create mode 100644 drivers/net/ethernet/realtek/r8168.c
Signature · 1 line
2.15.1
author maintainer
#2 lore raw

RFC PATCH 2/18 r8168: remove code specific to MAC version 01 - 06

Remove code which is specific to MAC version 01 - 06.

---
 drivers/net/ethernet/realtek/r8168.c | 302 +----------------------------------
 1 file changed, 5 insertions(+), 297 deletions(-)
drivers/net/ethernet/realtek/r8168.c +5 -297
index 6863d8cce..468085f56 100644
@@ -1995,17 +1995,6 @@ static int rtl8169_set_speed_xmii(struct net_device *dev,
 
 	rtl_writephy(tp, MII_BMCR, bmcr);
 
-	if (tp->mac_version == RTL_GIGA_MAC_VER_02 ||
-	    tp->mac_version == RTL_GIGA_MAC_VER_03) {
-		if ((speed == SPEED_100) && (autoneg != AUTONEG_ENABLE)) {
-			rtl_writephy(tp, 0x17, 0x2138);
-			rtl_writephy(tp, 0x0e, 0x0260);
-		} else {
-			rtl_writephy(tp, 0x17, 0x2108);
-			rtl_writephy(tp, 0x0e, 0x0000);
-		}
-	}
-
 	rc = 0;
 out:
 	return rc;
@@ -3027,197 +3016,6 @@ static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 reg, u16 val)
 		rtl_apply_firmware(tp);
 }
 
-static void rtl8169s_hw_phy_config(struct rtl8169_private *tp)
-{
-	static const struct phy_reg phy_reg_init[] = {
-		{ 0x1f, 0x0001 },
-		{ 0x06, 0x006e },
-		{ 0x08, 0x0708 },
-		{ 0x15, 0x4000 },
-		{ 0x18, 0x65c7 },
-
-		{ 0x1f, 0x0001 },
-		{ 0x03, 0x00a1 },
-		{ 0x02, 0x0008 },
-		{ 0x01, 0x0120 },
-		{ 0x00, 0x1000 },
-		{ 0x04, 0x0800 },
-		{ 0x04, 0x0000 },
-
-		{ 0x03, 0xff41 },
-		{ 0x02, 0xdf60 },
-		{ 0x01, 0x0140 },
-		{ 0x00, 0x0077 },
-		{ 0x04, 0x7800 },
-		{ 0x04, 0x7000 },
-
-		{ 0x03, 0x802f },
-		{ 0x02, 0x4f02 },
-		{ 0x01, 0x0409 },
-		{ 0x00, 0xf0f9 },
-		{ 0x04, 0x9800 },
-		{ 0x04, 0x9000 },
-
-		{ 0x03, 0xdf01 },
-		{ 0x02, 0xdf20 },
-		{ 0x01, 0xff95 },
-		{ 0x00, 0xba00 },
-		{ 0x04, 0xa800 },
-		{ 0x04, 0xa000 },
-
-		{ 0x03, 0xff41 },
-		{ 0x02, 0xdf20 },
-		{ 0x01, 0x0140 },
-		{ 0x00, 0x00bb },
-		{ 0x04, 0xb800 },
-		{ 0x04, 0xb000 },
-
-		{ 0x03, 0xdf41 },
-		{ 0x02, 0xdc60 },
-		{ 0x01, 0x6340 },
-		{ 0x00, 0x007d },
-		{ 0x04, 0xd800 },
-		{ 0x04, 0xd000 },
-
-		{ 0x03, 0xdf01 },
-		{ 0x02, 0xdf20 },
-		{ 0x01, 0x100a },
-		{ 0x00, 0xa0ff },
-		{ 0x04, 0xf800 },
-		{ 0x04, 0xf000 },
-
-		{ 0x1f, 0x0000 },
-		{ 0x0b, 0x0000 },
-		{ 0x00, 0x9200 }
-	};
-
-	rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
-}
-
-static void rtl8169sb_hw_phy_config(struct rtl8169_private *tp)
-{
-	static const struct phy_reg phy_reg_init[] = {
-		{ 0x1f, 0x0002 },
-		{ 0x01, 0x90d0 },
-		{ 0x1f, 0x0000 }
-	};
-
-	rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
-}
-
-static void rtl8169scd_hw_phy_config_quirk(struct rtl8169_private *tp)
-{
-	struct pci_dev *pdev = tp->pci_dev;
-
-	if ((pdev->subsystem_vendor != PCI_VENDOR_ID_GIGABYTE) ||
-	    (pdev->subsystem_device != 0xe000))
-		return;
-
-	rtl_writephy(tp, 0x1f, 0x0001);
-	rtl_writephy(tp, 0x10, 0xf01b);
-	rtl_writephy(tp, 0x1f, 0x0000);
-}
-
-static void rtl8169scd_hw_phy_config(struct rtl8169_private *tp)
-{
-	static const struct phy_reg phy_reg_init[] = {
-		{ 0x1f, 0x0001 },
-		{ 0x04, 0x0000 },
-		{ 0x03, 0x00a1 },
-		{ 0x02, 0x0008 },
-		{ 0x01, 0x0120 },
-		{ 0x00, 0x1000 },
-		{ 0x04, 0x0800 },
-		{ 0x04, 0x9000 },
-		{ 0x03, 0x802f },
-		{ 0x02, 0x4f02 },
-		{ 0x01, 0x0409 },
-		{ 0x00, 0xf099 },
-		{ 0x04, 0x9800 },
-		{ 0x04, 0xa000 },
-		{ 0x03, 0xdf01 },
-		{ 0x02, 0xdf20 },
-		{ 0x01, 0xff95 },
-		{ 0x00, 0xba00 },
-		{ 0x04, 0xa800 },
-		{ 0x04, 0xf000 },
-		{ 0x03, 0xdf01 },
-		{ 0x02, 0xdf20 },
-		{ 0x01, 0x101a },
-		{ 0x00, 0xa0ff },
-		{ 0x04, 0xf800 },
-		{ 0x04, 0x0000 },
-		{ 0x1f, 0x0000 },
-
-		{ 0x1f, 0x0001 },
-		{ 0x10, 0xf41b },
-		{ 0x14, 0xfb54 },
-		{ 0x18, 0xf5c7 },
-		{ 0x1f, 0x0000 },
-
-		{ 0x1f, 0x0001 },
-		{ 0x17, 0x0cc0 },
-		{ 0x1f, 0x0000 }
-	};
-
-	rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
-
-	rtl8169scd_hw_phy_config_quirk(tp);
-}
-
-static void rtl8169sce_hw_phy_config(struct rtl8169_private *tp)
-{
-	static const struct phy_reg phy_reg_init[] = {
-		{ 0x1f, 0x0001 },
-		{ 0x04, 0x0000 },
-		{ 0x03, 0x00a1 },
-		{ 0x02, 0x0008 },
-		{ 0x01, 0x0120 },
-		{ 0x00, 0x1000 },
-		{ 0x04, 0x0800 },
-		{ 0x04, 0x9000 },
-		{ 0x03, 0x802f },
-		{ 0x02, 0x4f02 },
-		{ 0x01, 0x0409 },
-		{ 0x00, 0xf099 },
-		{ 0x04, 0x9800 },
-		{ 0x04, 0xa000 },
-		{ 0x03, 0xdf01 },
-		{ 0x02, 0xdf20 },
-		{ 0x01, 0xff95 },
-		{ 0x00, 0xba00 },
-		{ 0x04, 0xa800 },
-		{ 0x04, 0xf000 },
-		{ 0x03, 0xdf01 },
-		{ 0x02, 0xdf20 },
-		{ 0x01, 0x101a },
-		{ 0x00, 0xa0ff },
-		{ 0x04, 0xf800 },
-		{ 0x04, 0x0000 },
-		{ 0x1f, 0x0000 },
-
-		{ 0x1f, 0x0001 },
-		{ 0x0b, 0x8480 },
-		{ 0x1f, 0x0000 },
-
-		{ 0x1f, 0x0001 },
-		{ 0x18, 0x67c7 },
-		{ 0x04, 0x2000 },
-		{ 0x03, 0x002f },
-		{ 0x02, 0x4360 },
-		{ 0x01, 0x0109 },
-		{ 0x00, 0x3022 },
-		{ 0x04, 0x2800 },
-		{ 0x1f, 0x0000 },
-
-		{ 0x1f, 0x0001 },
-		{ 0x17, 0x0cc0 },
-		{ 0x1f, 0x0000 }
-	};
-
-	rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
-}
-
 static void rtl8168bb_hw_phy_config(struct rtl8169_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
@@ -4478,21 +4276,6 @@ static void rtl_hw_phy_config(struct net_device *dev)
 	rtl8169_print_mac_version(tp);
 
 	switch (tp->mac_version) {
-	case RTL_GIGA_MAC_VER_01:
-		break;
-	case RTL_GIGA_MAC_VER_02:
-	case RTL_GIGA_MAC_VER_03:
-		rtl8169s_hw_phy_config(tp);
-		break;
-	case RTL_GIGA_MAC_VER_04:
-		rtl8169sb_hw_phy_config(tp);
-		break;
-	case RTL_GIGA_MAC_VER_05:
-		rtl8169scd_hw_phy_config(tp);
-		break;
-	case RTL_GIGA_MAC_VER_06:
-		rtl8169sce_hw_phy_config(tp);
-		break;
 	case RTL_GIGA_MAC_VER_07:
 	case RTL_GIGA_MAC_VER_08:
 	case RTL_GIGA_MAC_VER_09:
@@ -4665,27 +4448,10 @@ static bool rtl_tbi_enabled(struct rtl8169_private *tp)
 
 static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
 {
-	void __iomem *ioaddr = tp->mmio_addr;
-
 	rtl_hw_phy_config(dev);
 
-	if (tp->mac_version <= RTL_GIGA_MAC_VER_06) {
-		dprintk("Set MAC Reg C+CR Offset 0x82h = 0x01h\n");
-		RTL_W8(0x82, 0x01);
-	}
-
 	pci_write_config_byte(tp->pci_dev, PCI_LATENCY_TIMER, 0x40);
 
-	if (tp->mac_version <= RTL_GIGA_MAC_VER_06)
-		pci_write_config_byte(tp->pci_dev, PCI_CACHE_LINE_SIZE, 0x08);
-
-	if (tp->mac_version == RTL_GIGA_MAC_VER_02) {
-		dprintk("Set MAC Reg C+CR Offset 0x82h = 0x01h\n");
-		RTL_W8(0x82, 0x01);
-		dprintk("Set PHY Reg 0x0bh = 0x00h\n");
-		rtl_writephy(tp, 0x0b, 0x0000); //w 0x0b 15 0 0
-	}
-
 	rtl8169_phy_reset(dev, tp);
 
 	rtl8169_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
@@ -5170,12 +4936,6 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)
 	void __iomem *ioaddr = tp->mmio_addr;
 
 	switch (tp->mac_version) {
-	case RTL_GIGA_MAC_VER_01:
-	case RTL_GIGA_MAC_VER_02:
-	case RTL_GIGA_MAC_VER_03:
-	case RTL_GIGA_MAC_VER_04:
-	case RTL_GIGA_MAC_VER_05:
-	case RTL_GIGA_MAC_VER_06:
 	case RTL_GIGA_MAC_VER_10:
 	case RTL_GIGA_MAC_VER_11:
 	case RTL_GIGA_MAC_VER_12:
@@ -5583,7 +5343,7 @@ static void rtl_set_rx_mode(struct net_device *dev)
 	void __iomem *ioaddr = tp->mmio_addr;
 	u32 mc_filter[2];	/* Multicast hash filter */
 	int rx_mode;
-	u32 tmp = 0;
+	u32 tmp = 0, data;
 
 	if (dev->flags & IFF_PROMISC) {
 		/* Unconditionally log net taps. */
@@ -5614,12 +5374,9 @@ static void rtl_set_rx_mode(struct net_device *dev)
 
 	tmp = (RTL_R32(RxConfig) & ~RX_CONFIG_ACCEPT_MASK) | rx_mode;
 
-	if (tp->mac_version > RTL_GIGA_MAC_VER_06) {
-		u32 data = mc_filter[0];
-
-		mc_filter[0] = swab32(mc_filter[1]);
-		mc_filter[1] = swab32(data);
-	}
+	data = mc_filter[0];
+	mc_filter[0] = swab32(mc_filter[1]);
+	mc_filter[1] = swab32(data);
 
 	if (tp->mac_version == RTL_GIGA_MAC_VER_35)
 		mc_filter[1] = mc_filter[0] = 0xffffffff;
@@ -5634,19 +5391,8 @@ static void rtl_hw_start_8169(struct net_device *dev)
 {
 	struct rtl8169_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
-	struct pci_dev *pdev = tp->pci_dev;
-
-	if (tp->mac_version == RTL_GIGA_MAC_VER_05) {
-		RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) | PCIMulRW);
-		pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x08);
-	}
 
 	RTL_W8(Cfg9346, Cfg9346_Unlock);
-	if (tp->mac_version == RTL_GIGA_MAC_VER_01 ||
-	    tp->mac_version == RTL_GIGA_MAC_VER_02 ||
-	    tp->mac_version == RTL_GIGA_MAC_VER_03 ||
-	    tp->mac_version == RTL_GIGA_MAC_VER_04)
-		RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
 
 	rtl_init_rxcfg(tp);
 
@@ -5654,21 +5400,8 @@ static void rtl_hw_start_8169(struct net_device *dev)
 
 	rtl_set_rx_max_size(ioaddr, rx_buf_sz);
 
-	if (tp->mac_version == RTL_GIGA_MAC_VER_01 ||
-	    tp->mac_version == RTL_GIGA_MAC_VER_02 ||
-	    tp->mac_version == RTL_GIGA_MAC_VER_03 ||
-	    tp->mac_version == RTL_GIGA_MAC_VER_04)
-		rtl_set_rx_tx_config_registers(tp);
-
 	tp->cp_cmd |= rtl_rw_cpluscmd(ioaddr) | PCIMulRW;
 
-	if (tp->mac_version == RTL_GIGA_MAC_VER_02 ||
-	    tp->mac_version == RTL_GIGA_MAC_VER_03) {
-		dprintk("Set MAC Reg C+CR Offset 0xe0. "
-			"Bit-3 and bit-14 MUST be 1\n");
-		tp->cp_cmd |= (1 << 14);
-	}
-
 	RTL_W16(CPlusCmd, tp->cp_cmd);
 
 	rtl8169_set_magic_reg(ioaddr, tp->mac_version);
@@ -5681,14 +5414,6 @@ static void rtl_hw_start_8169(struct net_device *dev)
 
 	rtl_set_rx_tx_desc_registers(tp, ioaddr);
 
-	if (tp->mac_version != RTL_GIGA_MAC_VER_01 &&
-	    tp->mac_version != RTL_GIGA_MAC_VER_02 &&
-	    tp->mac_version != RTL_GIGA_MAC_VER_03 &&
-	    tp->mac_version != RTL_GIGA_MAC_VER_04) {
-		RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
-		rtl_set_rx_tx_config_registers(tp);
-	}
-
 	RTL_W8(Cfg9346, Cfg9346_Lock);
 
 	/* Initially a 10 us delay. Turned it into a PCI commit. - FR */
@@ -5811,12 +5536,6 @@ static void rtl_init_csi_ops(struct rtl8169_private *tp)
 	struct csi_ops *ops = &tp->csi_ops;
 
 	switch (tp->mac_version) {
-	case RTL_GIGA_MAC_VER_01:
-	case RTL_GIGA_MAC_VER_02:
-	case RTL_GIGA_MAC_VER_03:
-	case RTL_GIGA_MAC_VER_04:
-	case RTL_GIGA_MAC_VER_05:
-	case RTL_GIGA_MAC_VER_06:
 	case RTL_GIGA_MAC_VER_10:
 	case RTL_GIGA_MAC_VER_11:
 	case RTL_GIGA_MAC_VER_12:
@@ -8322,8 +8041,6 @@ static unsigned rtl_try_msi(struct rtl8169_private *tp,
 			msi = RTL_FEATURE_MSI;
 		}
 	}
-	if (tp->mac_version <= RTL_GIGA_MAC_VER_06)
-		RTL_W8(Config2, cfg2);
 	return msi;
 }
 
@@ -8639,14 +8356,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	tp->cp_cmd |= RxChkSum | RxVlan;
 
-	/*
-	 * Pretend we are using VLANs; This bypasses a nasty bug where
-	 * Interrupts stop flowing on high load on 8110SCd controllers.
-	 */
-	if (tp->mac_version == RTL_GIGA_MAC_VER_05)
-		/* Disallow toggling */
-		dev->hw_features &= ~NETIF_F_HW_VLAN_CTAG_RX;
-
 	if (tp->txd_version == RTL_TD_0)
 		tp->tso_csum = rtl8169_tso_csum_v1;
 	else if (tp->txd_version == RTL_TD_1) {
@@ -8666,8 +8375,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	tp->event_slow = cfg->event_slow;
 	tp->coalesce_info = cfg->coalesce_info;
 
-	tp->opts1_mask = (tp->mac_version != RTL_GIGA_MAC_VER_01) ?
-		~(RxBOVF | RxFOVF) : ~0;
+	tp->opts1_mask = ~(RxBOVF | RxFOVF);
 
 	timer_setup(&tp->timer, rtl8169_phy_timer, 0);
 
Signature · 1 line
2.15.1
author maintainer
#1 lore raw

RFC PATCH 1/18 r8169: split driver to one for the non-PCIE cards (r8169) and one for the PCIE cards (r8168)

In reply to Heiner Kallweit

A significant part of the code is specific to either the old non-PCIE cards or the newer PCIE cards. In addition the non-PCIE cards partially support a not MII-compatible TBI fibre mode.
Therefore split driver to one for the non-PCIE cards (r8169) and one for the PCIE cards (r8168).

---
 drivers/net/ethernet/realtek/Kconfig  |   20 +-
 drivers/net/ethernet/realtek/Makefile |    1 +
 drivers/net/ethernet/realtek/r8168.c  | 8725 +++++++++++++++++++++++++++++++++
 drivers/net/ethernet/realtek/r8169.c  |  112 +-
 4 files changed, 8749 insertions(+), 109 deletions(-)
 create mode 100644 drivers/net/ethernet/realtek/r8168.c
drivers/net/ethernet/realtek/Kconfig +19 -1
index 7c69f4c81..011b524c5 100644
@@ -94,16 +94,34 @@ config 8139_OLD_RX_RESET
 	  experience problems, you can enable this option to restore the
 	  old RX-reset behavior.  If unsure, say N.
 
+config R8168
+	tristate "Realtek 8168 gigabit ethernet support"
+	depends on PCI
+	select FW_LOADER
+	select CRC32
+	select MII
+	---help---
+	  Say Y here if you have a Realtek 8168 PCI Gigabit Ethernet adapter.
+	  This driver supports the PCIE models.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called r8168.
+
 config R8169
 	tristate "Realtek 8169 gigabit ethernet support"
 	depends on PCI
 	select FW_LOADER
 	select CRC32
 	select MII
+	select R8168
 	---help---
 	  Say Y here if you have a Realtek 8169 PCI Gigabit Ethernet adapter.
+	  This driver supports the non-PCIE models.
+
+	  For now it automatically selects the separated R8168 driver for
+	  newer card models. After some time this will be removed.
 
 	  To compile this driver as a module, choose M here: the module
-	  will be called r8169.  This is recommended.
+	  will be called r8169.
 
 endif # NET_VENDOR_REALTEK
drivers/net/ethernet/realtek/Makefile +1 -0
index 71b1da30e..4952c7bf5 100644
@@ -5,4 +5,5 @@
 obj-$(CONFIG_8139CP) += 8139cp.o
 obj-$(CONFIG_8139TOO) += 8139too.o
 obj-$(CONFIG_ATP) += atp.o
+obj-$(CONFIG_R8168) += r8168.o
 obj-$(CONFIG_R8169) += r8169.o
drivers/net/ethernet/realtek/r8168.c new file +8725 -0

2,960 lines not on this page · raw message

drivers/net/ethernet/realtek/r8169.c +4 -108

112 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.15.1

Part of the diff is not shown here. View the raw message.

author maintainer
#3 lore raw

RFC PATCH 3/18 r8168: remove magic register handling used on MAC version 05 and 06 only

In reply to Heiner Kallweit

Remove magic register handling used on MAC version 05 and 06 only.

---
 drivers/net/ethernet/realtek/r8168.c | 27 ---------------------------
 1 file changed, 27 deletions(-)
drivers/net/ethernet/realtek/r8168.c +0 -27
index 468085f56..a80b7ce80 100644
@@ -5312,31 +5312,6 @@ static void rtl_set_rx_max_size(void __iomem *ioaddr, unsigned int rx_buf_sz)
 	RTL_W16(RxMaxSize, rx_buf_sz + 1);
 }
 
-static void rtl8169_set_magic_reg(void __iomem *ioaddr, unsigned mac_version)
-{
-	static const struct rtl_cfg2_info {
-		u32 mac_version;
-		u32 clk;
-		u32 val;
-	} cfg2_info [] = {
-		{ RTL_GIGA_MAC_VER_05, PCI_Clock_33MHz, 0x000fff00 }, // 8110SCd
-		{ RTL_GIGA_MAC_VER_05, PCI_Clock_66MHz, 0x000fffff },
-		{ RTL_GIGA_MAC_VER_06, PCI_Clock_33MHz, 0x00ffff00 }, // 8110SCe
-		{ RTL_GIGA_MAC_VER_06, PCI_Clock_66MHz, 0x00ffffff }
-	};
-	const struct rtl_cfg2_info *p = cfg2_info;
-	unsigned int i;
-	u32 clk;
-
-	clk = RTL_R8(Config2) & PCI_Clock_66MHz;
-	for (i = 0; i < ARRAY_SIZE(cfg2_info); i++, p++) {
-		if ((p->mac_version == mac_version) && (p->clk == clk)) {
-			RTL_W32(0x7c, p->val);
-			break;
-		}
-	}
-}
-
 static void rtl_set_rx_mode(struct net_device *dev)
 {
 	struct rtl8169_private *tp = netdev_priv(dev);
@@ -5404,8 +5379,6 @@ static void rtl_hw_start_8169(struct net_device *dev)
 
 	RTL_W16(CPlusCmd, tp->cp_cmd);
 
-	rtl8169_set_magic_reg(ioaddr, tp->mac_version);
-
 	/*
 	 * Undocumented corner. Supposedly:
 	 * (TxTimer << 12) | (TxPackets << 8) | (RxTimer << 4) | RxPackets
Signature · 1 line
2.15.1
author maintainer
#4 lore raw

RFC PATCH 4/18 r8168: remove TBI mode support needed for MAC version 01 only

In reply to Heiner Kallweit

Remove TBI mode support needed for MAC version 01 only.

---
 drivers/net/ethernet/realtek/r8168.c | 123 ++---------------------------------
 1 file changed, 6 insertions(+), 117 deletions(-)
drivers/net/ethernet/realtek/r8168.c +6 -117
index a80b7ce80..48b7edff8 100644
@@ -426,12 +426,6 @@ enum rtl_registers {
 	FuncForceEvent	= 0xfc,
 };
 
-enum rtl8110_registers {
-	TBICSR			= 0x64,
-	TBI_ANAR		= 0x68,
-	TBI_LPAR		= 0x6a,
-};
-
 enum rtl8168_8101_registers {
 	CSIDR			= 0x64,
 	CSIAR			= 0x68,
@@ -603,14 +597,6 @@ enum rtl_register_content {
 	PMEStatus	= (1 << 0),	/* PME status can be reset by PCI RST# */
 	ASPM_en		= (1 << 0),	/* ASPM enable */
 
-	/* TBICSR p.28 */
-	TBIReset	= 0x80000000,
-	TBILoopback	= 0x40000000,
-	TBINwEnable	= 0x20000000,
-	TBINwRestart	= 0x10000000,
-	TBILinkOk	= 0x02000000,
-	TBINwComplete	= 0x01000000,
-
 	/* CPlusCmd p.31 */
 	EnableBist	= (1 << 15),	// 8168 8101
 	Mac_dbgo_oe	= (1 << 14),	// 8168 8101
@@ -641,9 +627,6 @@ enum rtl_register_content {
 	LinkStatus	= 0x02,
 	FullDup		= 0x01,
 
-	/* _TBICSRBit */
-	TBILinkOK	= 0x02000000,
-
 	/* ResetCounterCommand */
 	CounterReset	= 0x1,
 
@@ -1581,35 +1564,16 @@ static void rtl8169_irq_mask_and_ack(struct rtl8169_private *tp)
 	RTL_R8(ChipCmd);
 }
 
-static unsigned int rtl8169_tbi_reset_pending(struct rtl8169_private *tp)
-{
-	void __iomem *ioaddr = tp->mmio_addr;
-
-	return RTL_R32(TBICSR) & TBIReset;
-}
-
 static unsigned int rtl8169_xmii_reset_pending(struct rtl8169_private *tp)
 {
 	return rtl_readphy(tp, MII_BMCR) & BMCR_RESET;
 }
 
-static unsigned int rtl8169_tbi_link_ok(void __iomem *ioaddr)
-{
-	return RTL_R32(TBICSR) & TBILinkOk;
-}
-
 static unsigned int rtl8169_xmii_link_ok(void __iomem *ioaddr)
 {
 	return RTL_R8(PHYstatus) & LinkStatus;
 }
 
-static void rtl8169_tbi_reset_enable(struct rtl8169_private *tp)
-{
-	void __iomem *ioaddr = tp->mmio_addr;
-
-	RTL_W32(TBICSR, RTL_R32(TBICSR) | TBIReset);
-}
-
 static void rtl8169_xmii_reset_enable(struct rtl8169_private *tp)
 {
 	unsigned int val;
@@ -1911,29 +1875,6 @@ static int rtl8169_get_regs_len(struct net_device *dev)
 	return R8169_REGS_SIZE;
 }
 
-static int rtl8169_set_speed_tbi(struct net_device *dev,
-				 u8 autoneg, u16 speed, u8 duplex, u32 ignored)
-{
-	struct rtl8169_private *tp = netdev_priv(dev);
-	void __iomem *ioaddr = tp->mmio_addr;
-	int ret = 0;
-	u32 reg;
-
-	reg = RTL_R32(TBICSR);
-	if ((autoneg == AUTONEG_DISABLE) && (speed == SPEED_1000) &&
-	    (duplex == DUPLEX_FULL)) {
-		RTL_W32(TBICSR, reg & ~(TBINwEnable | TBINwRestart));
-	} else if (autoneg == AUTONEG_ENABLE)
-		RTL_W32(TBICSR, reg | TBINwEnable | TBINwRestart);
-	else {
-		netif_warn(tp, link, dev,
-			   "incorrect speed setting refused in TBI mode\n");
-		ret = -EOPNOTSUPP;
-	}
-
-	return ret;
-}
-
 static int rtl8169_set_speed_xmii(struct net_device *dev,
 				  u8 autoneg, u16 speed, u8 duplex, u32 adv)
 {
@@ -2095,33 +2036,6 @@ static void rtl8169_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
 		__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), swab16(opts2 & 0xffff));
 }
 
-static int rtl8169_get_link_ksettings_tbi(struct net_device *dev,
-					  struct ethtool_link_ksettings *cmd)
-{
-	struct rtl8169_private *tp = netdev_priv(dev);
-	void __iomem *ioaddr = tp->mmio_addr;
-	u32 status;
-	u32 supported, advertising;
-
-	supported =
-		SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg | SUPPORTED_FIBRE;
-	cmd->base.port = PORT_FIBRE;
-
-	status = RTL_R32(TBICSR);
-	advertising = (status & TBINwEnable) ?  ADVERTISED_Autoneg : 0;
-	cmd->base.autoneg = !!(status & TBINwEnable);
-
-	cmd->base.speed = SPEED_1000;
-	cmd->base.duplex = DUPLEX_FULL; /* Always set */
-
-	ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
-						supported);
-	ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
-						advertising);
-
-	return 0;
-}
-
 static int rtl8169_get_link_ksettings_xmii(struct net_device *dev,
 					   struct ethtool_link_ksettings *cmd)
 {
@@ -4438,14 +4352,6 @@ static void rtl8169_phy_reset(struct net_device *dev,
 	rtl_msleep_loop_wait_low(tp, &rtl_phy_reset_cond, 1, 100);
 }
 
-static bool rtl_tbi_enabled(struct rtl8169_private *tp)
-{
-	void __iomem *ioaddr = tp->mmio_addr;
-
-	return (tp->mac_version == RTL_GIGA_MAC_VER_01) &&
-	    (RTL_R8(PHYstatus) & TBI_Enable);
-}
-
 static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
 {
 	rtl_hw_phy_config(dev);
@@ -4460,9 +4366,6 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
 			  (tp->mii.supports_gmii ?
 			   ADVERTISED_1000baseT_Half |
 			   ADVERTISED_1000baseT_Full : 0));
-
-	if (rtl_tbi_enabled(tp))
-		netif_info(tp, link, dev, "TBI auto-negotiating\n");
 }
 
 static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
@@ -4535,11 +4438,6 @@ static int rtl_xmii_ioctl(struct rtl8169_private *tp,
 	return -EOPNOTSUPP;
 }
 
-static int rtl_tbi_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd)
-{
-	return -EOPNOTSUPP;
-}
-
 static void rtl_init_mdio_ops(struct rtl8169_private *tp)
 {
 	struct mdio_ops *ops = &tp->mdio_ops;
@@ -8263,21 +8161,12 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	tp->features |= rtl_try_msi(tp, cfg);
 	RTL_W8(Cfg9346, Cfg9346_Lock);
 
-	if (rtl_tbi_enabled(tp)) {
-		tp->set_speed = rtl8169_set_speed_tbi;
-		tp->get_link_ksettings = rtl8169_get_link_ksettings_tbi;
-		tp->phy_reset_enable = rtl8169_tbi_reset_enable;
-		tp->phy_reset_pending = rtl8169_tbi_reset_pending;
-		tp->link_ok = rtl8169_tbi_link_ok;
-		tp->do_ioctl = rtl_tbi_ioctl;
-	} else {
-		tp->set_speed = rtl8169_set_speed_xmii;
-		tp->get_link_ksettings = rtl8169_get_link_ksettings_xmii;
-		tp->phy_reset_enable = rtl8169_xmii_reset_enable;
-		tp->phy_reset_pending = rtl8169_xmii_reset_pending;
-		tp->link_ok = rtl8169_xmii_link_ok;
-		tp->do_ioctl = rtl_xmii_ioctl;
-	}
+	tp->set_speed = rtl8169_set_speed_xmii;
+	tp->get_link_ksettings = rtl8169_get_link_ksettings_xmii;
+	tp->phy_reset_enable = rtl8169_xmii_reset_enable;
+	tp->phy_reset_pending = rtl8169_xmii_reset_pending;
+	tp->link_ok = rtl8169_xmii_link_ok;
+	tp->do_ioctl = rtl_xmii_ioctl;
 
 	mutex_init(&tp->wk.mutex);
 	u64_stats_init(&tp->rx_stats.syncp);
Signature · 1 line
2.15.1
author maintainer
#5 lore raw

RFC PATCH 5/18 r8168: remove unneeded callbacks from struct rtl8169_private

In reply to Heiner Kallweit

All supported chips provide a MII interface, therefore some callbacks can be removed from struct rtl8169_private.

---
 drivers/net/ethernet/realtek/r8168.c | 46 +++++++++++++-----------------------
 1 file changed, 16 insertions(+), 30 deletions(-)
drivers/net/ethernet/realtek/r8168.c +16 -30
index 48b7edff8..0ce789814 100644
@@ -806,14 +806,7 @@ struct rtl8169_private {
 		u32 (*read)(struct rtl8169_private *, int);
 	} csi_ops;
 
-	int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
-	int (*get_link_ksettings)(struct net_device *,
-				  struct ethtool_link_ksettings *);
-	void (*phy_reset_enable)(struct rtl8169_private *tp);
 	void (*hw_start)(struct net_device *);
-	unsigned int (*phy_reset_pending)(struct rtl8169_private *tp);
-	unsigned int (*link_ok)(void __iomem *);
-	int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd);
 	bool (*tso_csum)(struct rtl8169_private *, struct sk_buff *, u32 *);
 
 	struct {
@@ -1643,7 +1636,7 @@ static void __rtl8169_check_link_status(struct net_device *dev,
 					struct rtl8169_private *tp,
 					void __iomem *ioaddr, bool pm)
 {
-	if (tp->link_ok(ioaddr)) {
+	if (rtl8169_xmii_link_ok(ioaddr)) {
 		rtl_link_chg_patch(tp);
 		/* This is to cancel a scheduled suspend if there's one. */
 		if (pm)
@@ -1947,7 +1940,7 @@ static int rtl8169_set_speed(struct net_device *dev,
 	struct rtl8169_private *tp = netdev_priv(dev);
 	int ret;
 
-	ret = tp->set_speed(dev, autoneg, speed, duplex, advertising);
+	ret = rtl8169_set_speed_xmii(dev, autoneg, speed, duplex, advertising);
 	if (ret < 0)
 		goto out;
 
@@ -2053,7 +2046,7 @@ static int rtl8169_get_link_ksettings(struct net_device *dev,
 	int rc;
 
 	rtl_lock_work(tp);
-	rc = tp->get_link_ksettings(dev, cmd);
+	rc = rtl8169_get_link_ksettings_xmii(dev, cmd);
 	rtl_unlock_work(tp);
 
 	return rc;
@@ -4307,7 +4300,7 @@ static void rtl_phy_work(struct rtl8169_private *tp)
 
 	assert(tp->mac_version > RTL_GIGA_MAC_VER_01);
 
-	if (tp->phy_reset_pending(tp)) {
+	if (rtl8169_xmii_reset_pending(tp)) {
 		/*
 		 * A busy loop could burn quite a few cycles on nowadays CPU.
 		 * Let's delay the execution of the timer for a few ticks.
@@ -4316,12 +4309,12 @@ static void rtl_phy_work(struct rtl8169_private *tp)
 		goto out_mod_timer;
 	}
 
-	if (tp->link_ok(ioaddr))
+	if (rtl8169_xmii_link_ok(ioaddr))
 		return;
 
 	netif_dbg(tp, link, tp->dev, "PHY reset until link up\n");
 
-	tp->phy_reset_enable(tp);
+	rtl8169_xmii_reset_enable(tp);
 
 out_mod_timer:
 	mod_timer(timer, jiffies + timeout);
@@ -4342,13 +4335,13 @@ static void rtl8169_phy_timer(struct timer_list *t)
 
 DECLARE_RTL_COND(rtl_phy_reset_cond)
 {
-	return tp->phy_reset_pending(tp);
+	return rtl8169_xmii_reset_pending(tp);
 }
 
 static void rtl8169_phy_reset(struct net_device *dev,
 			      struct rtl8169_private *tp)
 {
-	tp->phy_reset_enable(tp);
+	rtl8169_xmii_reset_enable(tp);
 	rtl_msleep_loop_wait_low(tp, &rtl_phy_reset_cond, 1, 100);
 }
 
@@ -4411,14 +4404,6 @@ static int rtl_set_mac_address(struct net_device *dev, void *p)
 	return 0;
 }
 
-static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
-{
-	struct rtl8169_private *tp = netdev_priv(dev);
-	struct mii_ioctl_data *data = if_mii(ifr);
-
-	return netif_running(dev) ? tp->do_ioctl(tp, data, cmd) : -ENODEV;
-}
-
 static int rtl_xmii_ioctl(struct rtl8169_private *tp,
 			  struct mii_ioctl_data *data, int cmd)
 {
@@ -4438,6 +4423,14 @@ static int rtl_xmii_ioctl(struct rtl8169_private *tp,
 	return -EOPNOTSUPP;
 }
 
+static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+	struct rtl8169_private *tp = netdev_priv(dev);
+	struct mii_ioctl_data *data = if_mii(ifr);
+
+	return netif_running(dev) ? rtl_xmii_ioctl(tp, data, cmd) : -ENODEV;
+}
+
 static void rtl_init_mdio_ops(struct rtl8169_private *tp)
 {
 	struct mdio_ops *ops = &tp->mdio_ops;
@@ -8161,13 +8154,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	tp->features |= rtl_try_msi(tp, cfg);
 	RTL_W8(Cfg9346, Cfg9346_Lock);
 
-	tp->set_speed = rtl8169_set_speed_xmii;
-	tp->get_link_ksettings = rtl8169_get_link_ksettings_xmii;
-	tp->phy_reset_enable = rtl8169_xmii_reset_enable;
-	tp->phy_reset_pending = rtl8169_xmii_reset_pending;
-	tp->link_ok = rtl8169_xmii_link_ok;
-	tp->do_ioctl = rtl_xmii_ioctl;
-
 	mutex_init(&tp->wk.mutex);
 	u64_stats_init(&tp->rx_stats.syncp);
 	u64_stats_init(&tp->tx_stats.syncp);
Signature · 1 line
2.15.1
author maintainer
#6 lore raw

RFC PATCH 6/18 r8168: remove function rtl8169_rx_missed() being specific to MAC version 01 - 06

In reply to Heiner Kallweit

Function rtl8169_rx_missed() does nothing on MAC versions > 06, therefore remove it.

---
 drivers/net/ethernet/realtek/r8168.c | 23 -----------------------
 1 file changed, 23 deletions(-)
drivers/net/ethernet/realtek/r8168.c +0 -23
index 0ce789814..0ba0ac5ec 100644
@@ -7401,21 +7401,9 @@ static int rtl8169_poll(struct napi_struct *napi, int budget)
 	return work_done;
 }
 
-static void rtl8169_rx_missed(struct net_device *dev, void __iomem *ioaddr)
-{
-	struct rtl8169_private *tp = netdev_priv(dev);
-
-	if (tp->mac_version > RTL_GIGA_MAC_VER_06)
-		return;
-
-	dev->stats.rx_missed_errors += (RTL_R32(RxMissed) & 0xffffff);
-	RTL_W32(RxMissed, 0);
-}
-
 static void rtl8169_down(struct net_device *dev)
 {
 	struct rtl8169_private *tp = netdev_priv(dev);
-	void __iomem *ioaddr = tp->mmio_addr;
 
 	del_timer_sync(&tp->timer);
 
@@ -7423,12 +7411,6 @@ static void rtl8169_down(struct net_device *dev)
 	netif_stop_queue(dev);
 
 	rtl8169_hw_reset(tp);
-	/*
-	 * At this point device interrupts can not be enabled in any function,
-	 * as netif_running is not true (rtl8169_interrupt, rtl8169_reset_task)
-	 * and napi is disabled (rtl8169_poll).
-	 */
-	rtl8169_rx_missed(dev, ioaddr);
 
 	/* Give a racing hard_start_xmit a few cycles to complete. */
 	synchronize_sched();
@@ -7568,16 +7550,12 @@ static void
 rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
 {
 	struct rtl8169_private *tp = netdev_priv(dev);
-	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
 	struct rtl8169_counters *counters = tp->counters;
 	unsigned int start;
 
 	pm_runtime_get_noresume(&pdev->dev);
 
-	if (netif_running(dev) && pm_runtime_active(&pdev->dev))
-		rtl8169_rx_missed(dev, ioaddr);
-
 	do {
 		start = u64_stats_fetch_begin_irq(&tp->rx_stats.syncp);
 		stats->rx_packets = tp->rx_stats.packets;
@@ -7697,7 +7675,6 @@ static int rtl8169_runtime_suspend(struct device *device)
 	rtl8169_net_suspend(dev);
 
 	/* Update counters before going runtime suspend */
-	rtl8169_rx_missed(dev, tp->mmio_addr);
 	rtl8169_update_counters(dev);
 
 	return 0;
Signature · 1 line
2.15.1
author maintainer
#7 lore raw

RFC PATCH 7/18 r8168: replace 8169 with 8168 in all relevant symbols

In reply to Heiner Kallweit

After separation from the r8169 driver, replace 8169 with 8168 in all relevant symbols.

---
 drivers/net/ethernet/realtek/r8168.c | 1066 +++++++++++++++++-----------------
 1 file changed, 533 insertions(+), 533 deletions(-)
drivers/net/ethernet/realtek/r8168.c +533 -533
index 0ba0ac5ec..b0c4b5ea8 100644
@@ -1,5 +1,5 @@
 /*
- * r8169.c: RealTek 8169/8168/8101 ethernet driver.
+ * r8168.c: RealTek 8168/8101 ethernet driver.
  *
  * Copyright (c) 2002 ShuChen <[email protected]>
  * Copyright (c) 2003 - 2007 Francois Romieu <[email protected]>
@@ -33,7 +33,7 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 
-#define RTL8169_VERSION "2.3LK-NAPI"
+#define RTL8168_VERSION "2.3LK-NAPI"
 #define MODULENAME "r8168"
 #define PFX MODULENAME ": "
 
@@ -57,7 +57,7 @@
 #define FIRMWARE_8107E_1	"rtl_nic/rtl8107e-1.fw"
 #define FIRMWARE_8107E_2	"rtl_nic/rtl8107e-2.fw"
 
-#ifdef RTL8169_DEBUG
+#ifdef RTL8168_DEBUG
 #define assert(expr) \
 	if (!(expr)) {					\
 		printk( "Assertion failed! %s,%s,%s,line=%d\n",	\
@@ -68,9 +68,9 @@
 #else
 #define assert(expr) do {} while (0)
 #define dprintk(fmt, args...)	do {} while (0)
-#endif /* RTL8169_DEBUG */
+#endif /* RTL8168_DEBUG */
 
-#define R8169_MSG_DEFAULT \
+#define R8168_MSG_DEFAULT \
 	(NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN)
 
 #define TX_SLOTS_AVAIL(tp) \
@@ -88,15 +88,15 @@ static const int multicast_filter_limit = 32;
 #define TX_DMA_BURST	7	/* Maximum PCI burst, '7' is unlimited */
 #define InterFrameGap	0x03	/* 3 means InterFrameGap = the shortest one */
 
-#define R8169_REGS_SIZE		256
-#define R8169_NAPI_WEIGHT	64
+#define R8168_REGS_SIZE		256
+#define R8168_NAPI_WEIGHT	64
 #define NUM_TX_DESC	64	/* Number of Tx descriptor registers */
 #define NUM_RX_DESC	256U	/* Number of Rx descriptor registers */
-#define R8169_TX_RING_BYTES	(NUM_TX_DESC * sizeof(struct TxDesc))
-#define R8169_RX_RING_BYTES	(NUM_RX_DESC * sizeof(struct RxDesc))
+#define R8168_TX_RING_BYTES	(NUM_TX_DESC * sizeof(struct TxDesc))
+#define R8168_RX_RING_BYTES	(NUM_RX_DESC * sizeof(struct RxDesc))
 
-#define RTL8169_TX_TIMEOUT	(6*HZ)
-#define RTL8169_PHY_TIMEOUT	(10*HZ)
+#define RTL8168_TX_TIMEOUT	(6*HZ)
+#define RTL8168_PHY_TIMEOUT	(10*HZ)
 
 /* write/read MMIO register */
 #define RTL_W8(reg, val8)	writeb ((val8), ioaddr + (reg))
@@ -617,7 +617,7 @@ enum rtl_register_content {
 	INTT_2		= 0x0002,	// 8168
 	INTT_3		= 0x0003,	// 8168
 
-	/* rtl8169_PHYstatus */
+	/* rtl8168_PHYstatus */
 	TBI_Enable	= 0x80,
 	TxFlowCtrl	= 0x40,
 	RxFlowCtrl	= 0x20,
@@ -724,7 +724,7 @@ enum features {
 	RTL_FEATURE_GMII	= (1 << 2),
 };
 
-struct rtl8169_counters {
+struct rtl8168_counters {
 	__le64	tx_packets;
 	__le64	rx_packets;
 	__le64	tx_errors;
@@ -740,7 +740,7 @@ struct rtl8169_counters {
 	__le16	tx_underun;
 };
 
-struct rtl8169_tc_offsets {
+struct rtl8168_tc_offsets {
 	bool	inited;
 	__le64	tx_errors;
 	__le32	tx_multi_collision;
@@ -755,13 +755,13 @@ enum rtl_flag {
 	RTL_FLAG_MAX
 };
 
-struct rtl8169_stats {
+struct rtl8168_stats {
 	u64			packets;
 	u64			bytes;
 	struct u64_stats_sync	syncp;
 };
 
-struct rtl8169_private {
+struct rtl8168_private {
 	void __iomem *mmio_addr;	/* memory map physical address */
 	struct pci_dev *pci_dev;
 	struct net_device *dev;
@@ -772,8 +772,8 @@ struct rtl8169_private {
 	u32 cur_rx; /* Index into the Rx descriptor buffer of next Rx pkt. */
 	u32 cur_tx; /* Index into the Tx descriptor buffer of next Rx pkt. */
 	u32 dirty_tx;
-	struct rtl8169_stats rx_stats;
-	struct rtl8169_stats tx_stats;
+	struct rtl8168_stats rx_stats;
+	struct rtl8168_stats tx_stats;
 	struct TxDesc *TxDescArray;	/* 256-aligned Tx descriptor ring */
 	struct RxDesc *RxDescArray;	/* 256-aligned Rx descriptor ring */
 	dma_addr_t TxPhyAddr;
@@ -787,27 +787,27 @@ struct rtl8169_private {
 	const struct rtl_coalesce_info *coalesce_info;
 
 	struct mdio_ops {
-		void (*write)(struct rtl8169_private *, int, int);
-		int (*read)(struct rtl8169_private *, int);
+		void (*write)(struct rtl8168_private *, int, int);
+		int (*read)(struct rtl8168_private *, int);
 	} mdio_ops;
 
 	struct pll_power_ops {
-		void (*down)(struct rtl8169_private *);
-		void (*up)(struct rtl8169_private *);
+		void (*down)(struct rtl8168_private *);
+		void (*up)(struct rtl8168_private *);
 	} pll_power_ops;
 
 	struct jumbo_ops {
-		void (*enable)(struct rtl8169_private *);
-		void (*disable)(struct rtl8169_private *);
+		void (*enable)(struct rtl8168_private *);
+		void (*disable)(struct rtl8168_private *);
 	} jumbo_ops;
 
 	struct csi_ops {
-		void (*write)(struct rtl8169_private *, int, int);
-		u32 (*read)(struct rtl8169_private *, int);
+		void (*write)(struct rtl8168_private *, int, int);
+		u32 (*read)(struct rtl8168_private *, int);
 	} csi_ops;
 
 	void (*hw_start)(struct net_device *);
-	bool (*tso_csum)(struct rtl8169_private *, struct sk_buff *, u32 *);
+	bool (*tso_csum)(struct rtl8168_private *, struct sk_buff *, u32 *);
 
 	struct {
 		DECLARE_BITMAP(flags, RTL_FLAG_MAX);
@@ -819,8 +819,8 @@ struct rtl8169_private {
 
 	struct mii_if_info mii;
 	dma_addr_t counters_phys_addr;
-	struct rtl8169_counters *counters;
-	struct rtl8169_tc_offsets tc_offset;
+	struct rtl8168_counters *counters;
+	struct rtl8168_tc_offsets tc_offset;
 	u32 saved_wolopts;
 	u32 opts1_mask;
 
@@ -841,14 +841,14 @@ struct rtl8169_private {
 	u32 ocp_base;
 };
 
-MODULE_AUTHOR("Realtek and the Linux r8169 crew <[email protected]>");
-MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver");
+MODULE_AUTHOR("Realtek and the Linux r8168 crew <[email protected]>");
+MODULE_DESCRIPTION("RealTek RTL-8168 Gigabit Ethernet driver");
 module_param(use_dac, int, 0);
 MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot.");
 module_param_named(debug, debug.msg_enable, int, 0);
 MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)");
 MODULE_LICENSE("GPL");
-MODULE_VERSION(RTL8169_VERSION);
+MODULE_VERSION(RTL8168_VERSION);
 MODULE_FIRMWARE(FIRMWARE_8168D_1);
 MODULE_FIRMWARE(FIRMWARE_8168D_2);
 MODULE_FIRMWARE(FIRMWARE_8168E_1);
@@ -869,12 +869,12 @@ MODULE_FIRMWARE(FIRMWARE_8168H_2);
 MODULE_FIRMWARE(FIRMWARE_8107E_1);
 MODULE_FIRMWARE(FIRMWARE_8107E_2);
 
-static void rtl_lock_work(struct rtl8169_private *tp)
+static void rtl_lock_work(struct rtl8168_private *tp)
 {
 	mutex_lock(&tp->wk.mutex);
 }
 
-static void rtl_unlock_work(struct rtl8169_private *tp)
+static void rtl_unlock_work(struct rtl8168_private *tp)
 {
 	mutex_unlock(&tp->wk.mutex);
 }
@@ -886,7 +886,7 @@ static void rtl_tx_performance_tweak(struct pci_dev *pdev, u16 force)
 }
 
 struct rtl_cond {
-	bool (*check)(struct rtl8169_private *);
+	bool (*check)(struct rtl8168_private *);
 	const char *msg;
 };
 
@@ -895,7 +895,7 @@ static void rtl_udelay(unsigned int d)
 	udelay(d);
 }
 
-static bool rtl_loop_wait(struct rtl8169_private *tp, const struct rtl_cond *c,
+static bool rtl_loop_wait(struct rtl8168_private *tp, const struct rtl_cond *c,
 			  void (*delay)(unsigned int), unsigned int d, int n,
 			  bool high)
 {
@@ -911,28 +911,28 @@ static bool rtl_loop_wait(struct rtl8169_private *tp, const struct rtl_cond *c,
 	return false;
 }
 
-static bool rtl_udelay_loop_wait_high(struct rtl8169_private *tp,
+static bool rtl_udelay_loop_wait_high(struct rtl8168_private *tp,
 				      const struct rtl_cond *c,
 				      unsigned int d, int n)
 {
 	return rtl_loop_wait(tp, c, rtl_udelay, d, n, true);
 }
 
-static bool rtl_udelay_loop_wait_low(struct rtl8169_private *tp,
+static bool rtl_udelay_loop_wait_low(struct rtl8168_private *tp,
 				     const struct rtl_cond *c,
 				     unsigned int d, int n)
 {
 	return rtl_loop_wait(tp, c, rtl_udelay, d, n, false);
 }
 
-static bool rtl_msleep_loop_wait_high(struct rtl8169_private *tp,
+static bool rtl_msleep_loop_wait_high(struct rtl8168_private *tp,
 				      const struct rtl_cond *c,
 				      unsigned int d, int n)
 {
 	return rtl_loop_wait(tp, c, msleep, d, n, true);
 }
 
-static bool rtl_msleep_loop_wait_low(struct rtl8169_private *tp,
+static bool rtl_msleep_loop_wait_low(struct rtl8168_private *tp,
 				     const struct rtl_cond *c,
 				     unsigned int d, int n)
 {
@@ -940,16 +940,16 @@ static bool rtl_msleep_loop_wait_low(struct rtl8169_private *tp,
 }
 
 #define DECLARE_RTL_COND(name)				\
-static bool name ## _check(struct rtl8169_private *);	\
+static bool name ## _check(struct rtl8168_private *);	\
 							\
 static const struct rtl_cond name = {			\
 	.check	= name ## _check,			\
 	.msg	= #name					\
 };							\
 							\
-static bool name ## _check(struct rtl8169_private *tp)
+static bool name ## _check(struct rtl8168_private *tp)
 
-static bool rtl_ocp_reg_failure(struct rtl8169_private *tp, u32 reg)
+static bool rtl_ocp_reg_failure(struct rtl8168_private *tp, u32 reg)
 {
 	if (reg & 0xffff0001) {
 		netif_err(tp, drv, tp->dev, "Invalid ocp reg %x!\n", reg);
@@ -965,7 +965,7 @@ DECLARE_RTL_COND(rtl_ocp_gphy_cond)
 	return RTL_R32(GPHY_OCP) & OCPAR_FLAG;
 }
 
-static void r8168_phy_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data)
+static void r8168_phy_ocp_write(struct rtl8168_private *tp, u32 reg, u32 data)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -977,7 +977,7 @@ static void r8168_phy_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data)
 	rtl_udelay_loop_wait_low(tp, &rtl_ocp_gphy_cond, 25, 10);
 }
 
-static u16 r8168_phy_ocp_read(struct rtl8169_private *tp, u32 reg)
+static u16 r8168_phy_ocp_read(struct rtl8168_private *tp, u32 reg)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -990,7 +990,7 @@ static u16 r8168_phy_ocp_read(struct rtl8169_private *tp, u32 reg)
 		(RTL_R32(GPHY_OCP) & 0xffff) : ~0;
 }
 
-static void r8168_mac_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data)
+static void r8168_mac_ocp_write(struct rtl8168_private *tp, u32 reg, u32 data)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1000,7 +1000,7 @@ static void r8168_mac_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data)
 	RTL_W32(OCPDR, OCPAR_FLAG | (reg << 15) | data);
 }
 
-static u16 r8168_mac_ocp_read(struct rtl8169_private *tp, u32 reg)
+static u16 r8168_mac_ocp_read(struct rtl8168_private *tp, u32 reg)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1014,7 +1014,7 @@ static u16 r8168_mac_ocp_read(struct rtl8169_private *tp, u32 reg)
 
 #define OCP_STD_PHY_BASE	0xa400
 
-static void r8168g_mdio_write(struct rtl8169_private *tp, int reg, int value)
+static void r8168g_mdio_write(struct rtl8168_private *tp, int reg, int value)
 {
 	if (reg == 0x1f) {
 		tp->ocp_base = value ? value << 4 : OCP_STD_PHY_BASE;
@@ -1027,7 +1027,7 @@ static void r8168g_mdio_write(struct rtl8169_private *tp, int reg, int value)
 	r8168_phy_ocp_write(tp, tp->ocp_base + reg * 2, value);
 }
 
-static int r8168g_mdio_read(struct rtl8169_private *tp, int reg)
+static int r8168g_mdio_read(struct rtl8168_private *tp, int reg)
 {
 	if (tp->ocp_base != OCP_STD_PHY_BASE)
 		reg -= 0x10;
@@ -1035,7 +1035,7 @@ static int r8168g_mdio_read(struct rtl8169_private *tp, int reg)
 	return r8168_phy_ocp_read(tp, tp->ocp_base + reg * 2);
 }
 
-static void mac_mcu_write(struct rtl8169_private *tp, int reg, int value)
+static void mac_mcu_write(struct rtl8168_private *tp, int reg, int value)
 {
 	if (reg == 0x1f) {
 		tp->ocp_base = value << 4;
@@ -1045,7 +1045,7 @@ static void mac_mcu_write(struct rtl8169_private *tp, int reg, int value)
 	r8168_mac_ocp_write(tp, tp->ocp_base + reg, value);
 }
 
-static int mac_mcu_read(struct rtl8169_private *tp, int reg)
+static int mac_mcu_read(struct rtl8168_private *tp, int reg)
 {
 	return r8168_mac_ocp_read(tp, tp->ocp_base + reg);
 }
@@ -1057,7 +1057,7 @@ DECLARE_RTL_COND(rtl_phyar_cond)
 	return RTL_R32(PHYAR) & 0x80000000;
 }
 
-static void r8169_mdio_write(struct rtl8169_private *tp, int reg, int value)
+static void r8168_mdio_write(struct rtl8168_private *tp, int reg, int value)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1071,7 +1071,7 @@ static void r8169_mdio_write(struct rtl8169_private *tp, int reg, int value)
 	udelay(20);
 }
 
-static int r8169_mdio_read(struct rtl8169_private *tp, int reg)
+static int r8168_mdio_read(struct rtl8168_private *tp, int reg)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	int value;
@@ -1097,7 +1097,7 @@ DECLARE_RTL_COND(rtl_ocpar_cond)
 	return RTL_R32(OCPAR) & OCPAR_FLAG;
 }
 
-static void r8168dp_1_mdio_access(struct rtl8169_private *tp, int reg, u32 data)
+static void r8168dp_1_mdio_access(struct rtl8168_private *tp, int reg, u32 data)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1108,13 +1108,13 @@ static void r8168dp_1_mdio_access(struct rtl8169_private *tp, int reg, u32 data)
 	rtl_udelay_loop_wait_low(tp, &rtl_ocpar_cond, 1000, 100);
 }
 
-static void r8168dp_1_mdio_write(struct rtl8169_private *tp, int reg, int value)
+static void r8168dp_1_mdio_write(struct rtl8168_private *tp, int reg, int value)
 {
 	r8168dp_1_mdio_access(tp, reg,
 			      OCPDR_WRITE_CMD | (value & OCPDR_DATA_MASK));
 }
 
-static int r8168dp_1_mdio_read(struct rtl8169_private *tp, int reg)
+static int r8168dp_1_mdio_read(struct rtl8168_private *tp, int reg)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1140,47 +1140,47 @@ static void r8168dp_2_mdio_stop(void __iomem *ioaddr)
 	RTL_W32(0xd0, RTL_R32(0xd0) | R8168DP_1_MDIO_ACCESS_BIT);
 }
 
-static void r8168dp_2_mdio_write(struct rtl8169_private *tp, int reg, int value)
+static void r8168dp_2_mdio_write(struct rtl8168_private *tp, int reg, int value)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
 	r8168dp_2_mdio_start(ioaddr);
 
-	r8169_mdio_write(tp, reg, value);
+	r8168_mdio_write(tp, reg, value);
 
 	r8168dp_2_mdio_stop(ioaddr);
 }
 
-static int r8168dp_2_mdio_read(struct rtl8169_private *tp, int reg)
+static int r8168dp_2_mdio_read(struct rtl8168_private *tp, int reg)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	int value;
 
 	r8168dp_2_mdio_start(ioaddr);
 
-	value = r8169_mdio_read(tp, reg);
+	value = r8168_mdio_read(tp, reg);
 
 	r8168dp_2_mdio_stop(ioaddr);
 
 	return value;
 }
 
-static void rtl_writephy(struct rtl8169_private *tp, int location, u32 val)
+static void rtl_writephy(struct rtl8168_private *tp, int location, u32 val)
 {
 	tp->mdio_ops.write(tp, location, val);
 }
 
-static int rtl_readphy(struct rtl8169_private *tp, int location)
+static int rtl_readphy(struct rtl8168_private *tp, int location)
 {
 	return tp->mdio_ops.read(tp, location);
 }
 
-static void rtl_patchphy(struct rtl8169_private *tp, int reg_addr, int value)
+static void rtl_patchphy(struct rtl8168_private *tp, int reg_addr, int value)
 {
 	rtl_writephy(tp, reg_addr, rtl_readphy(tp, reg_addr) | value);
 }
 
-static void rtl_w0w1_phy(struct rtl8169_private *tp, int reg_addr, int p, int m)
+static void rtl_w0w1_phy(struct rtl8168_private *tp, int reg_addr, int p, int m)
 {
 	int val;
 
@@ -1191,14 +1191,14 @@ static void rtl_w0w1_phy(struct rtl8169_private *tp, int reg_addr, int p, int m)
 static void rtl_mdio_write(struct net_device *dev, int phy_id, int location,
 			   int val)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
 	rtl_writephy(tp, location, val);
 }
 
 static int rtl_mdio_read(struct net_device *dev, int phy_id, int location)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
 	return rtl_readphy(tp, location);
 }
@@ -1210,7 +1210,7 @@ DECLARE_RTL_COND(rtl_ephyar_cond)
 	return RTL_R32(EPHYAR) & EPHYAR_FLAG;
 }
 
-static void rtl_ephy_write(struct rtl8169_private *tp, int reg_addr, int value)
+static void rtl_ephy_write(struct rtl8168_private *tp, int reg_addr, int value)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1222,7 +1222,7 @@ static void rtl_ephy_write(struct rtl8169_private *tp, int reg_addr, int value)
 	udelay(10);
 }
 
-static u16 rtl_ephy_read(struct rtl8169_private *tp, int reg_addr)
+static u16 rtl_ephy_read(struct rtl8168_private *tp, int reg_addr)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1239,7 +1239,7 @@ DECLARE_RTL_COND(rtl_eriar_cond)
 	return RTL_R32(ERIAR) & ERIAR_FLAG;
 }
 
-static void rtl_eri_write(struct rtl8169_private *tp, int addr, u32 mask,
+static void rtl_eri_write(struct rtl8168_private *tp, int addr, u32 mask,
 			  u32 val, int type)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
@@ -1251,7 +1251,7 @@ static void rtl_eri_write(struct rtl8169_private *tp, int addr, u32 mask,
 	rtl_udelay_loop_wait_low(tp, &rtl_eriar_cond, 100, 100);
 }
 
-static u32 rtl_eri_read(struct rtl8169_private *tp, int addr, int type)
+static u32 rtl_eri_read(struct rtl8168_private *tp, int addr, int type)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1261,7 +1261,7 @@ static u32 rtl_eri_read(struct rtl8169_private *tp, int addr, int type)
 		RTL_R32(ERIDR) : ~0;
 }
 
-static void rtl_w0w1_eri(struct rtl8169_private *tp, int addr, u32 mask, u32 p,
+static void rtl_w0w1_eri(struct rtl8168_private *tp, int addr, u32 mask, u32 p,
 			 u32 m, int type)
 {
 	u32 val;
@@ -1270,7 +1270,7 @@ static void rtl_w0w1_eri(struct rtl8169_private *tp, int addr, u32 mask, u32 p,
 	rtl_eri_write(tp, addr, mask, (val & ~m) | p, type);
 }
 
-static u32 r8168dp_ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg)
+static u32 r8168dp_ocp_read(struct rtl8168_private *tp, u8 mask, u16 reg)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1279,12 +1279,12 @@ static u32 r8168dp_ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg)
 		RTL_R32(OCPDR) : ~0;
 }
 
-static u32 r8168ep_ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg)
+static u32 r8168ep_ocp_read(struct rtl8168_private *tp, u8 mask, u16 reg)
 {
 	return rtl_eri_read(tp, reg, ERIAR_OOB);
 }
 
-static u32 ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg)
+static u32 ocp_read(struct rtl8168_private *tp, u8 mask, u16 reg)
 {
 	switch (tp->mac_version) {
 	case RTL_GIGA_MAC_VER_27:
@@ -1301,7 +1301,7 @@ static u32 ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg)
 	}
 }
 
-static void r8168dp_ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg,
+static void r8168dp_ocp_write(struct rtl8168_private *tp, u8 mask, u16 reg,
 			      u32 data)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
@@ -1311,14 +1311,14 @@ static void r8168dp_ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg,
 	rtl_udelay_loop_wait_low(tp, &rtl_ocpar_cond, 100, 20);
 }
 
-static void r8168ep_ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg,
+static void r8168ep_ocp_write(struct rtl8168_private *tp, u8 mask, u16 reg,
 			      u32 data)
 {
 	rtl_eri_write(tp, reg, ((u32)mask & 0x0f) << ERIAR_MASK_SHIFT,
 		      data, ERIAR_OOB);
 }
 
-static void ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg, u32 data)
+static void ocp_write(struct rtl8168_private *tp, u8 mask, u16 reg, u32 data)
 {
 	switch (tp->mac_version) {
 	case RTL_GIGA_MAC_VER_27:
@@ -1337,7 +1337,7 @@ static void ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg, u32 data)
 	}
 }
 
-static void rtl8168_oob_notify(struct rtl8169_private *tp, u8 cmd)
+static void rtl8168_oob_notify(struct rtl8168_private *tp, u8 cmd)
 {
 	rtl_eri_write(tp, 0xe8, ERIAR_MASK_0001, cmd, ERIAR_EXGMAC);
 
@@ -1348,7 +1348,7 @@ static void rtl8168_oob_notify(struct rtl8169_private *tp, u8 cmd)
 #define OOB_CMD_DRIVER_START	0x05
 #define OOB_CMD_DRIVER_STOP	0x06
 
-static u16 rtl8168_get_ocp_reg(struct rtl8169_private *tp)
+static u16 rtl8168_get_ocp_reg(struct rtl8168_private *tp)
 {
 	return (tp->mac_version == RTL_GIGA_MAC_VER_31) ? 0xb8 : 0x10;
 }
@@ -1374,7 +1374,7 @@ DECLARE_RTL_COND(rtl_ocp_tx_cond)
 	return RTL_R8(IBISR0) & 0x02;
 }
 
-static void rtl8168ep_stop_cmac(struct rtl8169_private *tp)
+static void rtl8168ep_stop_cmac(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1384,20 +1384,20 @@ static void rtl8168ep_stop_cmac(struct rtl8169_private *tp)
 	RTL_W8(IBCR0, RTL_R8(IBCR0) & ~0x01);
 }
 
-static void rtl8168dp_driver_start(struct rtl8169_private *tp)
+static void rtl8168dp_driver_start(struct rtl8168_private *tp)
 {
 	rtl8168_oob_notify(tp, OOB_CMD_DRIVER_START);
 	rtl_msleep_loop_wait_high(tp, &rtl_ocp_read_cond, 10, 10);
 }
 
-static void rtl8168ep_driver_start(struct rtl8169_private *tp)
+static void rtl8168ep_driver_start(struct rtl8168_private *tp)
 {
 	ocp_write(tp, 0x01, 0x180, OOB_CMD_DRIVER_START);
 	ocp_write(tp, 0x01, 0x30, ocp_read(tp, 0x01, 0x30) | 0x01);
 	rtl_msleep_loop_wait_high(tp, &rtl_ep_ocp_read_cond, 10, 10);
 }
 
-static void rtl8168_driver_start(struct rtl8169_private *tp)
+static void rtl8168_driver_start(struct rtl8168_private *tp)
 {
 	switch (tp->mac_version) {
 	case RTL_GIGA_MAC_VER_27:
@@ -1416,13 +1416,13 @@ static void rtl8168_driver_start(struct rtl8169_private *tp)
 	}
 }
 
-static void rtl8168dp_driver_stop(struct rtl8169_private *tp)
+static void rtl8168dp_driver_stop(struct rtl8168_private *tp)
 {
 	rtl8168_oob_notify(tp, OOB_CMD_DRIVER_STOP);
 	rtl_msleep_loop_wait_low(tp, &rtl_ocp_read_cond, 10, 10);
 }
 
-static void rtl8168ep_driver_stop(struct rtl8169_private *tp)
+static void rtl8168ep_driver_stop(struct rtl8168_private *tp)
 {
 	rtl8168ep_stop_cmac(tp);
 	ocp_write(tp, 0x01, 0x180, OOB_CMD_DRIVER_STOP);
@@ -1430,7 +1430,7 @@ static void rtl8168ep_driver_stop(struct rtl8169_private *tp)
 	rtl_msleep_loop_wait_low(tp, &rtl_ep_ocp_read_cond, 10, 10);
 }
 
-static void rtl8168_driver_stop(struct rtl8169_private *tp)
+static void rtl8168_driver_stop(struct rtl8168_private *tp)
 {
 	switch (tp->mac_version) {
 	case RTL_GIGA_MAC_VER_27:
@@ -1449,19 +1449,19 @@ static void rtl8168_driver_stop(struct rtl8169_private *tp)
 	}
 }
 
-static int r8168dp_check_dash(struct rtl8169_private *tp)
+static int r8168dp_check_dash(struct rtl8168_private *tp)
 {
 	u16 reg = rtl8168_get_ocp_reg(tp);
 
 	return (ocp_read(tp, 0x0f, reg) & 0x00008000) ? 1 : 0;
 }
 
-static int r8168ep_check_dash(struct rtl8169_private *tp)
+static int r8168ep_check_dash(struct rtl8168_private *tp)
 {
 	return (ocp_read(tp, 0x0f, 0x128) & 0x00000001) ? 1 : 0;
 }
 
-static int r8168_check_dash(struct rtl8169_private *tp)
+static int r8168_check_dash(struct rtl8168_private *tp)
 {
 	switch (tp->mac_version) {
 	case RTL_GIGA_MAC_VER_27:
@@ -1483,7 +1483,7 @@ struct exgmac_reg {
 	u32 val;
 };
 
-static void rtl_write_exgmac_batch(struct rtl8169_private *tp,
+static void rtl_write_exgmac_batch(struct rtl8168_private *tp,
 				   const struct exgmac_reg *r, int len)
 {
 	while (len-- > 0) {
@@ -1499,7 +1499,7 @@ DECLARE_RTL_COND(rtl_efusear_cond)
 	return RTL_R32(EFUSEAR) & EFUSEAR_FLAG;
 }
 
-static u8 rtl8168d_efuse_read(struct rtl8169_private *tp, int reg_addr)
+static u8 rtl8168d_efuse_read(struct rtl8168_private *tp, int reg_addr)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1509,14 +1509,14 @@ static u8 rtl8168d_efuse_read(struct rtl8169_private *tp, int reg_addr)
 		RTL_R32(EFUSEAR) & EFUSEAR_DATA_MASK : ~0;
 }
 
-static u16 rtl_get_events(struct rtl8169_private *tp)
+static u16 rtl_get_events(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
 	return RTL_R16(IntrStatus);
 }
 
-static void rtl_ack_events(struct rtl8169_private *tp, u16 bits)
+static void rtl_ack_events(struct rtl8168_private *tp, u16 bits)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1524,7 +1524,7 @@ static void rtl_ack_events(struct rtl8169_private *tp, u16 bits)
 	mmiowb();
 }
 
-static void rtl_irq_disable(struct rtl8169_private *tp)
+static void rtl_irq_disable(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1532,7 +1532,7 @@ static void rtl_irq_disable(struct rtl8169_private *tp)
 	mmiowb();
 }
 
-static void rtl_irq_enable(struct rtl8169_private *tp, u16 bits)
+static void rtl_irq_enable(struct rtl8168_private *tp, u16 bits)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1543,12 +1543,12 @@ static void rtl_irq_enable(struct rtl8169_private *tp, u16 bits)
 #define RTL_EVENT_NAPI_TX	(TxOK | TxErr)
 #define RTL_EVENT_NAPI		(RTL_EVENT_NAPI_RX | RTL_EVENT_NAPI_TX)
 
-static void rtl_irq_enable_all(struct rtl8169_private *tp)
+static void rtl_irq_enable_all(struct rtl8168_private *tp)
 {
 	rtl_irq_enable(tp, RTL_EVENT_NAPI | tp->event_slow);
 }
 
-static void rtl8169_irq_mask_and_ack(struct rtl8169_private *tp)
+static void rtl8168_irq_mask_and_ack(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -1557,17 +1557,17 @@ static void rtl8169_irq_mask_and_ack(struct rtl8169_private *tp)
 	RTL_R8(ChipCmd);
 }
 
-static unsigned int rtl8169_xmii_reset_pending(struct rtl8169_private *tp)
+static unsigned int rtl8168_xmii_reset_pending(struct rtl8168_private *tp)
 {
 	return rtl_readphy(tp, MII_BMCR) & BMCR_RESET;
 }
 
-static unsigned int rtl8169_xmii_link_ok(void __iomem *ioaddr)
+static unsigned int rtl8168_xmii_link_ok(void __iomem *ioaddr)
 {
 	return RTL_R8(PHYstatus) & LinkStatus;
 }
 
-static void rtl8169_xmii_reset_enable(struct rtl8169_private *tp)
+static void rtl8168_xmii_reset_enable(struct rtl8168_private *tp)
 {
 	unsigned int val;
 
@@ -1575,7 +1575,7 @@ static void rtl8169_xmii_reset_enable(struct rtl8169_private *tp)
 	rtl_writephy(tp, MII_BMCR, val & 0xffff);
 }
 
-static void rtl_link_chg_patch(struct rtl8169_private *tp)
+static void rtl_link_chg_patch(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct net_device *dev = tp->dev;
@@ -1632,11 +1632,11 @@ static void rtl_link_chg_patch(struct rtl8169_private *tp)
 	}
 }
 
-static void __rtl8169_check_link_status(struct net_device *dev,
-					struct rtl8169_private *tp,
+static void __rtl8168_check_link_status(struct net_device *dev,
+					struct rtl8168_private *tp,
 					void __iomem *ioaddr, bool pm)
 {
-	if (rtl8169_xmii_link_ok(ioaddr)) {
+	if (rtl8168_xmii_link_ok(ioaddr)) {
 		rtl_link_chg_patch(tp);
 		/* This is to cancel a scheduled suspend if there's one. */
 		if (pm)
@@ -1652,16 +1652,16 @@ static void __rtl8169_check_link_status(struct net_device *dev,
 	}
 }
 
-static void rtl8169_check_link_status(struct net_device *dev,
-				      struct rtl8169_private *tp,
+static void rtl8168_check_link_status(struct net_device *dev,
+				      struct rtl8168_private *tp,
 				      void __iomem *ioaddr)
 {
-	__rtl8169_check_link_status(dev, tp, ioaddr, false);
+	__rtl8168_check_link_status(dev, tp, ioaddr, false);
 }
 
 #define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST)
 
-static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
+static u32 __rtl8168_get_wol(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	u8 options;
@@ -1712,9 +1712,9 @@ static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
 	return wolopts;
 }
 
-static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+static void rtl8168_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	struct device *d = &tp->pci_dev->dev;
 
 	pm_runtime_get_noresume(d);
@@ -1723,7 +1723,7 @@ static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 
 	wol->supported = WAKE_ANY;
 	if (pm_runtime_active(d))
-		wol->wolopts = __rtl8169_get_wol(tp);
+		wol->wolopts = __rtl8168_get_wol(tp);
 	else
 		wol->wolopts = tp->saved_wolopts;
 
@@ -1732,7 +1732,7 @@ static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 	pm_runtime_put_noidle(d);
 }
 
-static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
+static void __rtl8168_set_wol(struct rtl8168_private *tp, u32 wolopts)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	unsigned int i, tmp;
@@ -1816,9 +1816,9 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
 	RTL_W8(Cfg9346, Cfg9346_Lock);
 }
 
-static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+static int rtl8168_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	struct device *d = &tp->pci_dev->dev;
 
 	pm_runtime_get_noresume(d);
@@ -1830,7 +1830,7 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 	else
 		tp->features &= ~RTL_FEATURE_WOL;
 	if (pm_runtime_active(d))
-		__rtl8169_set_wol(tp, wol->wolopts);
+		__rtl8168_set_wol(tp, wol->wolopts);
 	else
 		tp->saved_wolopts = wol->wolopts;
 
@@ -1843,19 +1843,19 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 	return 0;
 }
 
-static const char *rtl_lookup_firmware_name(struct rtl8169_private *tp)
+static const char *rtl_lookup_firmware_name(struct rtl8168_private *tp)
 {
 	return rtl_chip_infos[tp->mac_version].fw_name;
 }
 
-static void rtl8169_get_drvinfo(struct net_device *dev,
+static void rtl8168_get_drvinfo(struct net_device *dev,
 				struct ethtool_drvinfo *info)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	struct rtl_fw *rtl_fw = tp->rtl_fw;
 
 	strlcpy(info->driver, MODULENAME, sizeof(info->driver));
-	strlcpy(info->version, RTL8169_VERSION, sizeof(info->version));
+	strlcpy(info->version, RTL8168_VERSION, sizeof(info->version));
 	strlcpy(info->bus_info, pci_name(tp->pci_dev), sizeof(info->bus_info));
 	BUILD_BUG_ON(sizeof(info->fw_version) < sizeof(rtl_fw->version));
 	if (!IS_ERR_OR_NULL(rtl_fw))
@@ -1863,15 +1863,15 @@ static void rtl8169_get_drvinfo(struct net_device *dev,
 			sizeof(info->fw_version));
 }
 
-static int rtl8169_get_regs_len(struct net_device *dev)
+static int rtl8168_get_regs_len(struct net_device *dev)
 {
-	return R8169_REGS_SIZE;
+	return R8168_REGS_SIZE;
 }
 
-static int rtl8169_set_speed_xmii(struct net_device *dev,
+static int rtl8168_set_speed_xmii(struct net_device *dev,
 				  u8 autoneg, u16 speed, u8 duplex, u32 adv)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	int giga_ctrl, bmcr;
 	int rc = -EINVAL;
 
@@ -1934,29 +1934,29 @@ static int rtl8169_set_speed_xmii(struct net_device *dev,
 	return rc;
 }
 
-static int rtl8169_set_speed(struct net_device *dev,
+static int rtl8168_set_speed(struct net_device *dev,
 			     u8 autoneg, u16 speed, u8 duplex, u32 advertising)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	int ret;
 
-	ret = rtl8169_set_speed_xmii(dev, autoneg, speed, duplex, advertising);
+	ret = rtl8168_set_speed_xmii(dev, autoneg, speed, duplex, advertising);
 	if (ret < 0)
 		goto out;
 
 	if (netif_running(dev) && (autoneg == AUTONEG_ENABLE) &&
 	    (advertising & ADVERTISED_1000baseT_Full) &&
 	    !pci_is_pcie(tp->pci_dev)) {
-		mod_timer(&tp->timer, jiffies + RTL8169_PHY_TIMEOUT);
+		mod_timer(&tp->timer, jiffies + RTL8168_PHY_TIMEOUT);
 	}
 out:
 	return ret;
 }
 
-static netdev_features_t rtl8169_fix_features(struct net_device *dev,
+static netdev_features_t rtl8168_fix_features(struct net_device *dev,
 	netdev_features_t features)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
 	if (dev->mtu > TD_MSS_MAX)
 		features &= ~NETIF_F_ALL_TSO;
@@ -1968,10 +1968,10 @@ static netdev_features_t rtl8169_fix_features(struct net_device *dev,
 	return features;
 }
 
-static void __rtl8169_set_features(struct net_device *dev,
+static void __rtl8168_set_features(struct net_device *dev,
 				   netdev_features_t features)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
 	u32 rx_config;
 
@@ -1999,29 +1999,29 @@ static void __rtl8169_set_features(struct net_device *dev,
 	RTL_R16(CPlusCmd);
 }
 
-static int rtl8169_set_features(struct net_device *dev,
+static int rtl8168_set_features(struct net_device *dev,
 				netdev_features_t features)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
 	features &= NETIF_F_RXALL | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX;
 
 	rtl_lock_work(tp);
 	if (features ^ dev->features)
-		__rtl8169_set_features(dev, features);
+		__rtl8168_set_features(dev, features);
 	rtl_unlock_work(tp);
 
 	return 0;
 }
 
 
-static inline u32 rtl8169_tx_vlan_tag(struct sk_buff *skb)
+static inline u32 rtl8168_tx_vlan_tag(struct sk_buff *skb)
 {
 	return (skb_vlan_tag_present(skb)) ?
 		TxVlanTag | swab16(skb_vlan_tag_get(skb)) : 0x00;
 }
 
-static void rtl8169_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
+static void rtl8168_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
 {
 	u32 opts2 = le32_to_cpu(desc->opts2);
 
@@ -2029,33 +2029,33 @@ static void rtl8169_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
 		__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), swab16(opts2 & 0xffff));
 }
 
-static int rtl8169_get_link_ksettings_xmii(struct net_device *dev,
+static int rtl8168_get_link_ksettings_xmii(struct net_device *dev,
 					   struct ethtool_link_ksettings *cmd)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
 	mii_ethtool_get_link_ksettings(&tp->mii, cmd);
 
 	return 0;
 }
 
-static int rtl8169_get_link_ksettings(struct net_device *dev,
+static int rtl8168_get_link_ksettings(struct net_device *dev,
 				      struct ethtool_link_ksettings *cmd)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	int rc;
 
 	rtl_lock_work(tp);
-	rc = rtl8169_get_link_ksettings_xmii(dev, cmd);
+	rc = rtl8168_get_link_ksettings_xmii(dev, cmd);
 	rtl_unlock_work(tp);
 
 	return rc;
 }
 
-static int rtl8169_set_link_ksettings(struct net_device *dev,
+static int rtl8168_set_link_ksettings(struct net_device *dev,
 				      const struct ethtool_link_ksettings *cmd)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	int rc;
 	u32 advertising;
 
@@ -2066,42 +2066,42 @@ static int rtl8169_set_link_ksettings(struct net_device *dev,
 	del_timer_sync(&tp->timer);
 
 	rtl_lock_work(tp);
-	rc = rtl8169_set_speed(dev, cmd->base.autoneg, cmd->base.speed,
+	rc = rtl8168_set_speed(dev, cmd->base.autoneg, cmd->base.speed,
 			       cmd->base.duplex, advertising);
 	rtl_unlock_work(tp);
 
 	return rc;
 }
 
-static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs,
+static void rtl8168_get_regs(struct net_device *dev, struct ethtool_regs *regs,
 			     void *p)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	u32 __iomem *data = tp->mmio_addr;
 	u32 *dw = p;
 	int i;
 
 	rtl_lock_work(tp);
-	for (i = 0; i < R8169_REGS_SIZE; i += 4)
+	for (i = 0; i < R8168_REGS_SIZE; i += 4)
 		memcpy_fromio(dw++, data++, 4);
 	rtl_unlock_work(tp);
 }
 
-static u32 rtl8169_get_msglevel(struct net_device *dev)
+static u32 rtl8168_get_msglevel(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
 	return tp->msg_enable;
 }
 
-static void rtl8169_set_msglevel(struct net_device *dev, u32 value)
+static void rtl8168_set_msglevel(struct net_device *dev, u32 value)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
 	tp->msg_enable = value;
 }
 
-static const char rtl8169_gstrings[][ETH_GSTRING_LEN] = {
+static const char rtl8168_gstrings[][ETH_GSTRING_LEN] = {
 	"tx_packets",
 	"rx_packets",
 	"tx_errors",
@@ -2117,11 +2117,11 @@ static const char rtl8169_gstrings[][ETH_GSTRING_LEN] = {
 	"tx_underrun",
 };
 
-static int rtl8169_get_sset_count(struct net_device *dev, int sset)
+static int rtl8168_get_sset_count(struct net_device *dev, int sset)
 {
 	switch (sset) {
 	case ETH_SS_STATS:
-		return ARRAY_SIZE(rtl8169_gstrings);
+		return ARRAY_SIZE(rtl8168_gstrings);
 	default:
 		return -EOPNOTSUPP;
 	}
@@ -2134,9 +2134,9 @@ DECLARE_RTL_COND(rtl_counters_cond)
 	return RTL_R32(CounterAddrLow) & (CounterReset | CounterDump);
 }
 
-static bool rtl8169_do_counters(struct net_device *dev, u32 counter_cmd)
+static bool rtl8168_do_counters(struct net_device *dev, u32 counter_cmd)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
 	dma_addr_t paddr = tp->counters_phys_addr;
 	u32 cmd;
@@ -2155,9 +2155,9 @@ static bool rtl8169_do_counters(struct net_device *dev, u32 counter_cmd)
 	return ret;
 }
 
-static bool rtl8169_reset_counters(struct net_device *dev)
+static bool rtl8168_reset_counters(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
 	/*
 	 * Versions prior to RTL_GIGA_MAC_VER_19 don't support resetting the
@@ -2166,12 +2166,12 @@ static bool rtl8169_reset_counters(struct net_device *dev)
 	if (tp->mac_version < RTL_GIGA_MAC_VER_19)
 		return true;
 
-	return rtl8169_do_counters(dev, CounterReset);
+	return rtl8168_do_counters(dev, CounterReset);
 }
 
-static bool rtl8169_update_counters(struct net_device *dev)
+static bool rtl8168_update_counters(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
 
 	/*
@@ -2181,17 +2181,17 @@ static bool rtl8169_update_counters(struct net_device *dev)
 	if ((RTL_R8(ChipCmd) & CmdRxEnb) == 0)
 		return true;
 
-	return rtl8169_do_counters(dev, CounterDump);
+	return rtl8168_do_counters(dev, CounterDump);
 }
 
-static bool rtl8169_init_counter_offsets(struct net_device *dev)
+static bool rtl8168_init_counter_offsets(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
-	struct rtl8169_counters *counters = tp->counters;
+	struct rtl8168_private *tp = netdev_priv(dev);
+	struct rtl8168_counters *counters = tp->counters;
 	bool ret = false;
 
 	/*
-	 * rtl8169_init_counter_offsets is called from rtl_open.  On chip
+	 * rtl8168_init_counter_offsets is called from rtl_open.  On chip
 	 * versions prior to RTL_GIGA_MAC_VER_19 the tally counters are only
 	 * reset by a power cycle, while the counter values collected by the
 	 * driver are reset at every driver unload/load cycle.
@@ -2200,8 +2200,8 @@ static bool rtl8169_init_counter_offsets(struct net_device *dev)
 	 * values, we collect the initial values at first open(*) and use them
 	 * as offsets to normalize the values returned by @get_stats64.
 	 *
-	 * (*) We can't call rtl8169_init_counter_offsets from rtl_init_one
-	 * for the reason stated in rtl8169_update_counters; CmdRxEnb is only
+	 * (*) We can't call rtl8168_init_counter_offsets from rtl_init_one
+	 * for the reason stated in rtl8168_update_counters; CmdRxEnb is only
 	 * set at open time by rtl_hw_start.
 	 */
 
@@ -2209,10 +2209,10 @@ static bool rtl8169_init_counter_offsets(struct net_device *dev)
 		return true;
 
 	/* If both, reset and update fail, propagate to caller. */
-	if (rtl8169_reset_counters(dev))
+	if (rtl8168_reset_counters(dev))
 		ret = true;
 
-	if (rtl8169_update_counters(dev))
+	if (rtl8168_update_counters(dev))
 		ret = true;
 
 	tp->tc_offset.tx_errors = counters->tx_errors;
@@ -2223,19 +2223,19 @@ static bool rtl8169_init_counter_offsets(struct net_device *dev)
 	return ret;
 }
 
-static void rtl8169_get_ethtool_stats(struct net_device *dev,
+static void rtl8168_get_ethtool_stats(struct net_device *dev,
 				      struct ethtool_stats *stats, u64 *data)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	struct device *d = &tp->pci_dev->dev;
-	struct rtl8169_counters *counters = tp->counters;
+	struct rtl8168_counters *counters = tp->counters;
 
 	ASSERT_RTNL();
 
 	pm_runtime_get_noresume(d);
 
 	if (pm_runtime_active(d))
-		rtl8169_update_counters(dev);
+		rtl8168_update_counters(dev);
 
 	pm_runtime_put_noidle(d);
 
@@ -2254,18 +2254,18 @@ static void rtl8169_get_ethtool_stats(struct net_device *dev,
 	data[12] = le16_to_cpu(counters->tx_underun);
 }
 
-static void rtl8169_get_strings(struct net_device *dev, u32 stringset, u8 *data)
+static void rtl8168_get_strings(struct net_device *dev, u32 stringset, u8 *data)
 {
 	switch(stringset) {
 	case ETH_SS_STATS:
-		memcpy(data, *rtl8169_gstrings, sizeof(rtl8169_gstrings));
+		memcpy(data, *rtl8168_gstrings, sizeof(rtl8168_gstrings));
 		break;
 	}
 }
 
-static int rtl8169_nway_reset(struct net_device *dev)
+static int rtl8168_nway_reset(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
 	return mii_nway_restart(&tp->mii);
 }
@@ -2337,12 +2337,12 @@ static const struct rtl_coalesce_info rtl_coalesce_info_8168_8136[] = {
 /* get rx/tx scale vector corresponding to current speed */
 static const struct rtl_coalesce_info *rtl_coalesce_info(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	struct ethtool_link_ksettings ecmd;
 	const struct rtl_coalesce_info *ci;
 	int rc;
 
-	rc = rtl8169_get_link_ksettings(dev, &ecmd);
+	rc = rtl8168_get_link_ksettings(dev, &ecmd);
 	if (rc < 0)
 		return ERR_PTR(rc);
 
@@ -2357,7 +2357,7 @@ static const struct rtl_coalesce_info *rtl_coalesce_info(struct net_device *dev)
 
 static int rtl_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
 	const struct rtl_coalesce_info *ci;
 	const struct rtl_coalesce_scale *scale;
@@ -2427,7 +2427,7 @@ static const struct rtl_coalesce_scale *rtl_coalesce_choose_scale(
 
 static int rtl_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
 	const struct rtl_coalesce_scale *scale;
 	struct {
@@ -2487,27 +2487,27 @@ static int rtl_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
 	return 0;
 }
 
-static const struct ethtool_ops rtl8169_ethtool_ops = {
-	.get_drvinfo		= rtl8169_get_drvinfo,
-	.get_regs_len		= rtl8169_get_regs_len,
+static const struct ethtool_ops rtl8168_ethtool_ops = {
+	.get_drvinfo		= rtl8168_get_drvinfo,
+	.get_regs_len		= rtl8168_get_regs_len,
 	.get_link		= ethtool_op_get_link,
 	.get_coalesce		= rtl_get_coalesce,
 	.set_coalesce		= rtl_set_coalesce,
-	.get_msglevel		= rtl8169_get_msglevel,
-	.set_msglevel		= rtl8169_set_msglevel,
-	.get_regs		= rtl8169_get_regs,
-	.get_wol		= rtl8169_get_wol,
-	.set_wol		= rtl8169_set_wol,
-	.get_strings		= rtl8169_get_strings,
-	.get_sset_count		= rtl8169_get_sset_count,
-	.get_ethtool_stats	= rtl8169_get_ethtool_stats,
+	.get_msglevel		= rtl8168_get_msglevel,
+	.set_msglevel		= rtl8168_set_msglevel,
+	.get_regs		= rtl8168_get_regs,
+	.get_wol		= rtl8168_get_wol,
+	.set_wol		= rtl8168_set_wol,
+	.get_strings		= rtl8168_get_strings,
+	.get_sset_count		= rtl8168_get_sset_count,
+	.get_ethtool_stats	= rtl8168_get_ethtool_stats,
 	.get_ts_info		= ethtool_op_get_ts_info,
-	.nway_reset		= rtl8169_nway_reset,
-	.get_link_ksettings	= rtl8169_get_link_ksettings,
-	.set_link_ksettings	= rtl8169_set_link_ksettings,
+	.nway_reset		= rtl8168_nway_reset,
+	.get_link_ksettings	= rtl8168_get_link_ksettings,
+	.set_link_ksettings	= rtl8168_set_link_ksettings,
 };
 
-static void rtl8169_get_mac_version(struct rtl8169_private *tp,
+static void rtl8168_get_mac_version(struct rtl8168_private *tp,
 				    struct net_device *dev, u8 default_version)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
@@ -2642,7 +2642,7 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp,
 	}
 }
 
-static void rtl8169_print_mac_version(struct rtl8169_private *tp)
+static void rtl8168_print_mac_version(struct rtl8168_private *tp)
 {
 	dprintk("mac_version = 0x%02x\n", tp->mac_version);
 }
@@ -2652,7 +2652,7 @@ struct phy_reg {
 	u16 val;
 };
 
-static void rtl_writephy_batch(struct rtl8169_private *tp,
+static void rtl_writephy_batch(struct rtl8168_private *tp,
 			       const struct phy_reg *regs, int len)
 {
 	while (len-- > 0) {
@@ -2685,7 +2685,7 @@ struct fw_info {
 
 #define FW_OPCODE_SIZE	sizeof(typeof(*((struct rtl_fw_phy_action *)0)->code))
 
-static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
+static bool rtl_fw_format_ok(struct rtl8168_private *tp, struct rtl_fw *rtl_fw)
 {
 	const struct firmware *fw = rtl_fw->fw;
 	struct fw_info *fw_info = (struct fw_info *)fw->data;
@@ -2736,7 +2736,7 @@ static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 	return rc;
 }
 
-static bool rtl_fw_data_ok(struct rtl8169_private *tp, struct net_device *dev,
+static bool rtl_fw_data_ok(struct rtl8168_private *tp, struct net_device *dev,
 			   struct rtl_fw_phy_action *pa)
 {
 	bool rc = false;
@@ -2792,7 +2792,7 @@ static bool rtl_fw_data_ok(struct rtl8169_private *tp, struct net_device *dev,
 	return rc;
 }
 
-static int rtl_check_firmware(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
+static int rtl_check_firmware(struct rtl8168_private *tp, struct rtl_fw *rtl_fw)
 {
 	struct net_device *dev = tp->dev;
 	int rc = -EINVAL;
@@ -2808,7 +2808,7 @@ static int rtl_check_firmware(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 	return rc;
 }
 
-static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
+static void rtl_phy_write_fw(struct rtl8168_private *tp, struct rtl_fw *rtl_fw)
 {
 	struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
 	struct mdio_ops org, *ops = &tp->mdio_ops;
@@ -2897,7 +2897,7 @@ static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
 	ops->read = org.read;
 }
 
-static void rtl_release_firmware(struct rtl8169_private *tp)
+static void rtl_release_firmware(struct rtl8168_private *tp)
 {
 	if (!IS_ERR_OR_NULL(tp->rtl_fw)) {
 		release_firmware(tp->rtl_fw->fw);
@@ -2906,7 +2906,7 @@ static void rtl_release_firmware(struct rtl8169_private *tp)
 	tp->rtl_fw = RTL_FIRMWARE_UNKNOWN;
 }
 
-static void rtl_apply_firmware(struct rtl8169_private *tp)
+static void rtl_apply_firmware(struct rtl8168_private *tp)
 {
 	struct rtl_fw *rtl_fw = tp->rtl_fw;
 
@@ -2915,7 +2915,7 @@ static void rtl_apply_firmware(struct rtl8169_private *tp)
 		rtl_phy_write_fw(tp, rtl_fw);
 }
 
-static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 reg, u16 val)
+static void rtl_apply_firmware_cond(struct rtl8168_private *tp, u8 reg, u16 val)
 {
 	if (rtl_readphy(tp, reg) != val)
 		netif_warn(tp, hw, tp->dev, "chipset not ready for firmware\n");
@@ -2923,7 +2923,7 @@ static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 reg, u16 val)
 		rtl_apply_firmware(tp);
 }
 
-static void rtl8168bb_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168bb_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		{ 0x10, 0xf41b },
@@ -2936,7 +2936,7 @@ static void rtl8168bb_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
 }
 
-static void rtl8168bef_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168bef_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		{ 0x1f, 0x0001 },
@@ -2947,7 +2947,7 @@ static void rtl8168bef_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
 }
 
-static void rtl8168cp_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168cp_1_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		{ 0x1f, 0x0000 },
@@ -2960,7 +2960,7 @@ static void rtl8168cp_1_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
 }
 
-static void rtl8168cp_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168cp_2_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		{ 0x1f, 0x0001 },
@@ -2975,7 +2975,7 @@ static void rtl8168cp_2_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
 }
 
-static void rtl8168c_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168c_1_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		{ 0x1f, 0x0001 },
@@ -3004,7 +3004,7 @@ static void rtl8168c_1_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8168c_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168c_2_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		{ 0x1f, 0x0001 },
@@ -3032,7 +3032,7 @@ static void rtl8168c_2_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8168c_3_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168c_3_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		{ 0x1f, 0x0001 },
@@ -3054,12 +3054,12 @@ static void rtl8168c_3_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8168c_4_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168c_4_hw_phy_config(struct rtl8168_private *tp)
 {
 	rtl8168c_3_hw_phy_config(tp);
 }
 
-static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168d_1_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init_0[] = {
 		/* Channel Estimation */
@@ -3170,7 +3170,7 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168d_2_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init_0[] = {
 		/* Channel Estimation */
@@ -3272,7 +3272,7 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8168d_3_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168d_3_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		{ 0x1f, 0x0002 },
@@ -3333,7 +3333,7 @@ static void rtl8168d_3_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
 }
 
-static void rtl8168d_4_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168d_4_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		{ 0x1f, 0x0001 },
@@ -3349,7 +3349,7 @@ static void rtl8168d_4_hw_phy_config(struct rtl8169_private *tp)
 	rtl_patchphy(tp, 0x0d, 1 << 5);
 }
 
-static void rtl8168e_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168e_1_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		/* Enable Delay cap */
@@ -3422,7 +3422,7 @@ static void rtl8168e_1_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x0d, 0x0000);
 }
 
-static void rtl_rar_exgmac_set(struct rtl8169_private *tp, u8 *addr)
+static void rtl_rar_exgmac_set(struct rtl8168_private *tp, u8 *addr)
 {
 	const u16 w[] = {
 		addr[0] | (addr[1] << 8),
@@ -3439,7 +3439,7 @@ static void rtl_rar_exgmac_set(struct rtl8169_private *tp, u8 *addr)
 	rtl_write_exgmac_batch(tp, e, ARRAY_SIZE(e));
 }
 
-static void rtl8168e_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168e_2_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		/* Enable Delay cap */
@@ -3531,7 +3531,7 @@ static void rtl8168e_2_hw_phy_config(struct rtl8169_private *tp)
 	rtl_rar_exgmac_set(tp, tp->dev->dev_addr);
 }
 
-static void rtl8168f_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168f_hw_phy_config(struct rtl8168_private *tp)
 {
 	/* For 4-corner performance improve */
 	rtl_writephy(tp, 0x1f, 0x0005);
@@ -3553,7 +3553,7 @@ static void rtl8168f_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8168f_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168f_1_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		/* Channel estimation fine tune */
@@ -3603,14 +3603,14 @@ static void rtl8168f_1_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8168f_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168f_2_hw_phy_config(struct rtl8168_private *tp)
 {
 	rtl_apply_firmware(tp);
 
 	rtl8168f_hw_phy_config(tp);
 }
 
-static void rtl8411_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8411_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		/* Channel estimation fine tune */
@@ -3707,7 +3707,7 @@ static void rtl8411_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8168g_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168g_1_hw_phy_config(struct rtl8168_private *tp)
 {
 	rtl_apply_firmware(tp);
 
@@ -3773,12 +3773,12 @@ static void rtl8168g_1_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8168g_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168g_2_hw_phy_config(struct rtl8168_private *tp)
 {
 	rtl_apply_firmware(tp);
 }
 
-static void rtl8168h_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168h_1_hw_phy_config(struct rtl8168_private *tp)
 {
 	u16 dout_tapbin;
 	u32 data;
@@ -3888,7 +3888,7 @@ static void rtl8168h_1_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8168h_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168h_2_hw_phy_config(struct rtl8168_private *tp)
 {
 	u16 ioffset_p3, ioffset_p2, ioffset_p1, ioffset_p0;
 	u16 rlen;
@@ -3961,7 +3961,7 @@ static void rtl8168h_2_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8168ep_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168ep_1_hw_phy_config(struct rtl8168_private *tp)
 {
 	/* Enable PHY auto speed down */
 	rtl_writephy(tp, 0x1f, 0x0a44);
@@ -4003,7 +4003,7 @@ static void rtl8168ep_1_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8168ep_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168ep_2_hw_phy_config(struct rtl8168_private *tp)
 {
 	/* patch 10M & ALDPS */
 	rtl_writephy(tp, 0x1f, 0x0bcc);
@@ -4094,7 +4094,7 @@ static void rtl8168ep_2_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8102e_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8102e_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		{ 0x1f, 0x0003 },
@@ -4111,7 +4111,7 @@ static void rtl8102e_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
 }
 
-static void rtl8105e_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8105e_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		{ 0x1f, 0x0005 },
@@ -4137,7 +4137,7 @@ static void rtl8105e_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
 }
 
-static void rtl8402_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8402_hw_phy_config(struct rtl8168_private *tp)
 {
 	/* Disable ALDPS before setting firmware */
 	rtl_writephy(tp, 0x1f, 0x0000);
@@ -4154,7 +4154,7 @@ static void rtl8402_hw_phy_config(struct rtl8169_private *tp)
 	rtl_writephy(tp, 0x1f, 0x0000);
 }
 
-static void rtl8106e_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8106e_hw_phy_config(struct rtl8168_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
 		{ 0x1f, 0x0004 },
@@ -4178,9 +4178,9 @@ static void rtl8106e_hw_phy_config(struct rtl8169_private *tp)
 
 static void rtl_hw_phy_config(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
-	rtl8169_print_mac_version(tp);
+	rtl8168_print_mac_version(tp);
 
 	switch (tp->mac_version) {
 	case RTL_GIGA_MAC_VER_07:
@@ -4292,15 +4292,15 @@ static void rtl_hw_phy_config(struct net_device *dev)
 	}
 }
 
-static void rtl_phy_work(struct rtl8169_private *tp)
+static void rtl_phy_work(struct rtl8168_private *tp)
 {
 	struct timer_list *timer = &tp->timer;
 	void __iomem *ioaddr = tp->mmio_addr;
-	unsigned long timeout = RTL8169_PHY_TIMEOUT;
+	unsigned long timeout = RTL8168_PHY_TIMEOUT;
 
 	assert(tp->mac_version > RTL_GIGA_MAC_VER_01);
 
-	if (rtl8169_xmii_reset_pending(tp)) {
+	if (rtl8168_xmii_reset_pending(tp)) {
 		/*
 		 * A busy loop could burn quite a few cycles on nowadays CPU.
 		 * Let's delay the execution of the timer for a few ticks.
@@ -4309,51 +4309,51 @@ static void rtl_phy_work(struct rtl8169_private *tp)
 		goto out_mod_timer;
 	}
 
-	if (rtl8169_xmii_link_ok(ioaddr))
+	if (rtl8168_xmii_link_ok(ioaddr))
 		return;
 
 	netif_dbg(tp, link, tp->dev, "PHY reset until link up\n");
 
-	rtl8169_xmii_reset_enable(tp);
+	rtl8168_xmii_reset_enable(tp);
 
 out_mod_timer:
 	mod_timer(timer, jiffies + timeout);
 }
 
-static void rtl_schedule_task(struct rtl8169_private *tp, enum rtl_flag flag)
+static void rtl_schedule_task(struct rtl8168_private *tp, enum rtl_flag flag)
 {
 	if (!test_and_set_bit(flag, tp->wk.flags))
 		schedule_work(&tp->wk.work);
 }
 
-static void rtl8169_phy_timer(struct timer_list *t)
+static void rtl8168_phy_timer(struct timer_list *t)
 {
-	struct rtl8169_private *tp = from_timer(tp, t, timer);
+	struct rtl8168_private *tp = from_timer(tp, t, timer);
 
 	rtl_schedule_task(tp, RTL_FLAG_TASK_PHY_PENDING);
 }
 
 DECLARE_RTL_COND(rtl_phy_reset_cond)
 {
-	return rtl8169_xmii_reset_pending(tp);
+	return rtl8168_xmii_reset_pending(tp);
 }
 
-static void rtl8169_phy_reset(struct net_device *dev,
-			      struct rtl8169_private *tp)
+static void rtl8168_phy_reset(struct net_device *dev,
+			      struct rtl8168_private *tp)
 {
-	rtl8169_xmii_reset_enable(tp);
+	rtl8168_xmii_reset_enable(tp);
 	rtl_msleep_loop_wait_low(tp, &rtl_phy_reset_cond, 1, 100);
 }
 
-static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
+static void rtl8168_init_phy(struct net_device *dev, struct rtl8168_private *tp)
 {
 	rtl_hw_phy_config(dev);
 
 	pci_write_config_byte(tp->pci_dev, PCI_LATENCY_TIMER, 0x40);
 
-	rtl8169_phy_reset(dev, tp);
+	rtl8168_phy_reset(dev, tp);
 
-	rtl8169_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
+	rtl8168_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
 			  ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
 			  ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
 			  (tp->mii.supports_gmii ?
@@ -4361,7 +4361,7 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
 			   ADVERTISED_1000baseT_Full : 0));
 }
 
-static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
+static void rtl_rar_set(struct rtl8168_private *tp, u8 *addr)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4385,7 +4385,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
 
 static int rtl_set_mac_address(struct net_device *dev, void *p)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	struct device *d = &tp->pci_dev->dev;
 	struct sockaddr *addr = p;
 
@@ -4404,7 +4404,7 @@ static int rtl_set_mac_address(struct net_device *dev, void *p)
 	return 0;
 }
 
-static int rtl_xmii_ioctl(struct rtl8169_private *tp,
+static int rtl_xmii_ioctl(struct rtl8168_private *tp,
 			  struct mii_ioctl_data *data, int cmd)
 {
 	switch (cmd) {
@@ -4423,15 +4423,15 @@ static int rtl_xmii_ioctl(struct rtl8169_private *tp,
 	return -EOPNOTSUPP;
 }
 
-static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+static int rtl8168_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	struct mii_ioctl_data *data = if_mii(ifr);
 
 	return netif_running(dev) ? rtl_xmii_ioctl(tp, data, cmd) : -ENODEV;
 }
 
-static void rtl_init_mdio_ops(struct rtl8169_private *tp)
+static void rtl_init_mdio_ops(struct rtl8168_private *tp)
 {
 	struct mdio_ops *ops = &tp->mdio_ops;
 
@@ -4461,13 +4461,13 @@ static void rtl_init_mdio_ops(struct rtl8169_private *tp)
 		ops->read	= r8168g_mdio_read;
 		break;
 	default:
-		ops->write	= r8169_mdio_write;
-		ops->read	= r8169_mdio_read;
+		ops->write	= r8168_mdio_write;
+		ops->read	= r8168_mdio_read;
 		break;
 	}
 }
 
-static void rtl_speed_down(struct rtl8169_private *tp)
+static void rtl_speed_down(struct rtl8168_private *tp)
 {
 	u32 adv;
 	int lpa;
@@ -4487,11 +4487,11 @@ static void rtl_speed_down(struct rtl8169_private *tp)
 		       ADVERTISED_1000baseT_Half |
 		       ADVERTISED_1000baseT_Full : 0);
 
-	rtl8169_set_speed(tp->dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
+	rtl8168_set_speed(tp->dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
 			  adv);
 }
 
-static void rtl_wol_suspend_quirk(struct rtl8169_private *tp)
+static void rtl_wol_suspend_quirk(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4526,9 +4526,9 @@ static void rtl_wol_suspend_quirk(struct rtl8169_private *tp)
 	}
 }
 
-static bool rtl_wol_pll_power_down(struct rtl8169_private *tp)
+static bool rtl_wol_pll_power_down(struct rtl8168_private *tp)
 {
-	if (!(__rtl8169_get_wol(tp) & WAKE_ANY))
+	if (!(__rtl8168_get_wol(tp) & WAKE_ANY))
 		return false;
 
 	rtl_speed_down(tp);
@@ -4537,19 +4537,19 @@ static bool rtl_wol_pll_power_down(struct rtl8169_private *tp)
 	return true;
 }
 
-static void r810x_phy_power_down(struct rtl8169_private *tp)
+static void r810x_phy_power_down(struct rtl8168_private *tp)
 {
 	rtl_writephy(tp, 0x1f, 0x0000);
 	rtl_writephy(tp, MII_BMCR, BMCR_PDOWN);
 }
 
-static void r810x_phy_power_up(struct rtl8169_private *tp)
+static void r810x_phy_power_up(struct rtl8168_private *tp)
 {
 	rtl_writephy(tp, 0x1f, 0x0000);
 	rtl_writephy(tp, MII_BMCR, BMCR_ANENABLE);
 }
 
-static void r810x_pll_power_down(struct rtl8169_private *tp)
+static void r810x_pll_power_down(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4572,7 +4572,7 @@ static void r810x_pll_power_down(struct rtl8169_private *tp)
 	}
 }
 
-static void r810x_pll_power_up(struct rtl8169_private *tp)
+static void r810x_pll_power_up(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4596,7 +4596,7 @@ static void r810x_pll_power_up(struct rtl8169_private *tp)
 	}
 }
 
-static void r8168_phy_power_up(struct rtl8169_private *tp)
+static void r8168_phy_power_up(struct rtl8168_private *tp)
 {
 	rtl_writephy(tp, 0x1f, 0x0000);
 	switch (tp->mac_version) {
@@ -4623,7 +4623,7 @@ static void r8168_phy_power_up(struct rtl8169_private *tp)
 	rtl_writephy(tp, MII_BMCR, BMCR_ANENABLE);
 }
 
-static void r8168_phy_power_down(struct rtl8169_private *tp)
+static void r8168_phy_power_down(struct rtl8168_private *tp)
 {
 	rtl_writephy(tp, 0x1f, 0x0000);
 	switch (tp->mac_version) {
@@ -4656,7 +4656,7 @@ static void r8168_phy_power_down(struct rtl8169_private *tp)
 	}
 }
 
-static void r8168_pll_power_down(struct rtl8169_private *tp)
+static void r8168_pll_power_down(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4710,7 +4710,7 @@ static void r8168_pll_power_down(struct rtl8169_private *tp)
 	}
 }
 
-static void r8168_pll_power_up(struct rtl8169_private *tp)
+static void r8168_pll_power_up(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4743,24 +4743,24 @@ static void r8168_pll_power_up(struct rtl8169_private *tp)
 	r8168_phy_power_up(tp);
 }
 
-static void rtl_generic_op(struct rtl8169_private *tp,
-			   void (*op)(struct rtl8169_private *))
+static void rtl_generic_op(struct rtl8168_private *tp,
+			   void (*op)(struct rtl8168_private *))
 {
 	if (op)
 		op(tp);
 }
 
-static void rtl_pll_power_down(struct rtl8169_private *tp)
+static void rtl_pll_power_down(struct rtl8168_private *tp)
 {
 	rtl_generic_op(tp, tp->pll_power_ops.down);
 }
 
-static void rtl_pll_power_up(struct rtl8169_private *tp)
+static void rtl_pll_power_up(struct rtl8168_private *tp)
 {
 	rtl_generic_op(tp, tp->pll_power_ops.up);
 }
 
-static void rtl_init_pll_power_ops(struct rtl8169_private *tp)
+static void rtl_init_pll_power_ops(struct rtl8168_private *tp)
 {
 	struct pll_power_ops *ops = &tp->pll_power_ops;
 
@@ -4822,7 +4822,7 @@ static void rtl_init_pll_power_ops(struct rtl8169_private *tp)
 	}
 }
 
-static void rtl_init_rxcfg(struct rtl8169_private *tp)
+static void rtl_init_rxcfg(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4868,12 +4868,12 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)
 	}
 }
 
-static void rtl8169_init_ring_indexes(struct rtl8169_private *tp)
+static void rtl8168_init_ring_indexes(struct rtl8168_private *tp)
 {
 	tp->dirty_tx = tp->cur_tx = tp->cur_rx = 0;
 }
 
-static void rtl_hw_jumbo_enable(struct rtl8169_private *tp)
+static void rtl_hw_jumbo_enable(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4882,7 +4882,7 @@ static void rtl_hw_jumbo_enable(struct rtl8169_private *tp)
 	RTL_W8(Cfg9346, Cfg9346_Lock);
 }
 
-static void rtl_hw_jumbo_disable(struct rtl8169_private *tp)
+static void rtl_hw_jumbo_disable(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4891,7 +4891,7 @@ static void rtl_hw_jumbo_disable(struct rtl8169_private *tp)
 	RTL_W8(Cfg9346, Cfg9346_Lock);
 }
 
-static void r8168c_hw_jumbo_enable(struct rtl8169_private *tp)
+static void r8168c_hw_jumbo_enable(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4900,7 +4900,7 @@ static void r8168c_hw_jumbo_enable(struct rtl8169_private *tp)
 	rtl_tx_performance_tweak(tp->pci_dev, PCI_EXP_DEVCTL_READRQ_512B);
 }
 
-static void r8168c_hw_jumbo_disable(struct rtl8169_private *tp)
+static void r8168c_hw_jumbo_disable(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4909,21 +4909,21 @@ static void r8168c_hw_jumbo_disable(struct rtl8169_private *tp)
 	rtl_tx_performance_tweak(tp->pci_dev, 0x5 << MAX_READ_REQUEST_SHIFT);
 }
 
-static void r8168dp_hw_jumbo_enable(struct rtl8169_private *tp)
+static void r8168dp_hw_jumbo_enable(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
 	RTL_W8(Config3, RTL_R8(Config3) | Jumbo_En0);
 }
 
-static void r8168dp_hw_jumbo_disable(struct rtl8169_private *tp)
+static void r8168dp_hw_jumbo_disable(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
 	RTL_W8(Config3, RTL_R8(Config3) & ~Jumbo_En0);
 }
 
-static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp)
+static void r8168e_hw_jumbo_enable(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4933,7 +4933,7 @@ static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp)
 	rtl_tx_performance_tweak(tp->pci_dev, PCI_EXP_DEVCTL_READRQ_512B);
 }
 
-static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp)
+static void r8168e_hw_jumbo_disable(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4943,19 +4943,19 @@ static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp)
 	rtl_tx_performance_tweak(tp->pci_dev, 0x5 << MAX_READ_REQUEST_SHIFT);
 }
 
-static void r8168b_0_hw_jumbo_enable(struct rtl8169_private *tp)
+static void r8168b_0_hw_jumbo_enable(struct rtl8168_private *tp)
 {
 	rtl_tx_performance_tweak(tp->pci_dev,
 		PCI_EXP_DEVCTL_READRQ_512B | PCI_EXP_DEVCTL_NOSNOOP_EN);
 }
 
-static void r8168b_0_hw_jumbo_disable(struct rtl8169_private *tp)
+static void r8168b_0_hw_jumbo_disable(struct rtl8168_private *tp)
 {
 	rtl_tx_performance_tweak(tp->pci_dev,
 		(0x5 << MAX_READ_REQUEST_SHIFT) | PCI_EXP_DEVCTL_NOSNOOP_EN);
 }
 
-static void r8168b_1_hw_jumbo_enable(struct rtl8169_private *tp)
+static void r8168b_1_hw_jumbo_enable(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4964,7 +4964,7 @@ static void r8168b_1_hw_jumbo_enable(struct rtl8169_private *tp)
 	RTL_W8(Config4, RTL_R8(Config4) | (1 << 0));
 }
 
-static void r8168b_1_hw_jumbo_disable(struct rtl8169_private *tp)
+static void r8168b_1_hw_jumbo_disable(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -4973,7 +4973,7 @@ static void r8168b_1_hw_jumbo_disable(struct rtl8169_private *tp)
 	RTL_W8(Config4, RTL_R8(Config4) & ~(1 << 0));
 }
 
-static void rtl_init_jumbo_ops(struct rtl8169_private *tp)
+static void rtl_init_jumbo_ops(struct rtl8168_private *tp)
 {
 	struct jumbo_ops *ops = &tp->jumbo_ops;
 
@@ -5042,7 +5042,7 @@ DECLARE_RTL_COND(rtl_chipcmd_cond)
 	return RTL_R8(ChipCmd) & CmdReset;
 }
 
-static void rtl_hw_reset(struct rtl8169_private *tp)
+static void rtl_hw_reset(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -5051,7 +5051,7 @@ static void rtl_hw_reset(struct rtl8169_private *tp)
 	rtl_udelay_loop_wait_low(tp, &rtl_chipcmd_cond, 100, 100);
 }
 
-static void rtl_request_uncached_firmware(struct rtl8169_private *tp)
+static void rtl_request_uncached_firmware(struct rtl8168_private *tp)
 {
 	struct rtl_fw *rtl_fw;
 	const char *name;
@@ -5089,13 +5089,13 @@ static void rtl_request_uncached_firmware(struct rtl8169_private *tp)
 	goto out;
 }
 
-static void rtl_request_firmware(struct rtl8169_private *tp)
+static void rtl_request_firmware(struct rtl8168_private *tp)
 {
 	if (IS_ERR(tp->rtl_fw))
 		rtl_request_uncached_firmware(tp);
 }
 
-static void rtl_rx_close(struct rtl8169_private *tp)
+static void rtl_rx_close(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -5116,12 +5116,12 @@ DECLARE_RTL_COND(rtl_txcfg_empty_cond)
 	return RTL_R32(TxConfig) & TXCFG_EMPTY;
 }
 
-static void rtl8169_hw_reset(struct rtl8169_private *tp)
+static void rtl8168_hw_reset(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
 	/* Disable interrupts */
-	rtl8169_irq_mask_and_ack(tp);
+	rtl8168_irq_mask_and_ack(tp);
 
 	rtl_rx_close(tp);
 
@@ -5156,7 +5156,7 @@ static void rtl8169_hw_reset(struct rtl8169_private *tp)
 	rtl_hw_reset(tp);
 }
 
-static void rtl_set_rx_tx_config_registers(struct rtl8169_private *tp)
+static void rtl_set_rx_tx_config_registers(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -5167,14 +5167,14 @@ static void rtl_set_rx_tx_config_registers(struct rtl8169_private *tp)
 
 static void rtl_hw_start(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
 	tp->hw_start(dev);
 
 	rtl_irq_enable_all(tp);
 }
 
-static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp,
+static void rtl_set_rx_tx_desc_registers(struct rtl8168_private *tp,
 					 void __iomem *ioaddr)
 {
 	/*
@@ -5205,7 +5205,7 @@ static void rtl_set_rx_max_size(void __iomem *ioaddr, unsigned int rx_buf_sz)
 
 static void rtl_set_rx_mode(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
 	u32 mc_filter[2];	/* Multicast hash filter */
 	int rx_mode;
@@ -5255,7 +5255,7 @@ static void rtl_set_rx_mode(struct net_device *dev)
 
 static void rtl_hw_start_8169(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
 
 	RTL_W8(Cfg9346, Cfg9346_Unlock);
@@ -5291,18 +5291,18 @@ static void rtl_hw_start_8169(struct net_device *dev)
 	RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xf000);
 }
 
-static void rtl_csi_write(struct rtl8169_private *tp, int addr, int value)
+static void rtl_csi_write(struct rtl8168_private *tp, int addr, int value)
 {
 	if (tp->csi_ops.write)
 		tp->csi_ops.write(tp, addr, value);
 }
 
-static u32 rtl_csi_read(struct rtl8169_private *tp, int addr)
+static u32 rtl_csi_read(struct rtl8168_private *tp, int addr)
 {
 	return tp->csi_ops.read ? tp->csi_ops.read(tp, addr) : ~0;
 }
 
-static void rtl_csi_access_enable(struct rtl8169_private *tp, u32 bits)
+static void rtl_csi_access_enable(struct rtl8168_private *tp, u32 bits)
 {
 	u32 csi;
 
@@ -5310,12 +5310,12 @@ static void rtl_csi_access_enable(struct rtl8169_private *tp, u32 bits)
 	rtl_csi_write(tp, 0x070c, csi | bits);
 }
 
-static void rtl_csi_access_enable_1(struct rtl8169_private *tp)
+static void rtl_csi_access_enable_1(struct rtl8168_private *tp)
 {
 	rtl_csi_access_enable(tp, 0x17000000);
 }
 
-static void rtl_csi_access_enable_2(struct rtl8169_private *tp)
+static void rtl_csi_access_enable_2(struct rtl8168_private *tp)
 {
 	rtl_csi_access_enable(tp, 0x27000000);
 }
@@ -5327,7 +5327,7 @@ DECLARE_RTL_COND(rtl_csiar_cond)
 	return RTL_R32(CSIAR) & CSIAR_FLAG;
 }
 
-static void r8169_csi_write(struct rtl8169_private *tp, int addr, int value)
+static void r8168_csi_write(struct rtl8168_private *tp, int addr, int value)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -5338,7 +5338,7 @@ static void r8169_csi_write(struct rtl8169_private *tp, int addr, int value)
 	rtl_udelay_loop_wait_low(tp, &rtl_csiar_cond, 10, 100);
 }
 
-static u32 r8169_csi_read(struct rtl8169_private *tp, int addr)
+static u32 r8168_csi_read(struct rtl8168_private *tp, int addr)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -5349,7 +5349,7 @@ static u32 r8169_csi_read(struct rtl8169_private *tp, int addr)
 		RTL_R32(CSIDR) : ~0;
 }
 
-static void r8402_csi_write(struct rtl8169_private *tp, int addr, int value)
+static void r8402_csi_write(struct rtl8168_private *tp, int addr, int value)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -5361,7 +5361,7 @@ static void r8402_csi_write(struct rtl8169_private *tp, int addr, int value)
 	rtl_udelay_loop_wait_low(tp, &rtl_csiar_cond, 10, 100);
 }
 
-static u32 r8402_csi_read(struct rtl8169_private *tp, int addr)
+static u32 r8402_csi_read(struct rtl8168_private *tp, int addr)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -5372,7 +5372,7 @@ static u32 r8402_csi_read(struct rtl8169_private *tp, int addr)
 		RTL_R32(CSIDR) : ~0;
 }
 
-static void r8411_csi_write(struct rtl8169_private *tp, int addr, int value)
+static void r8411_csi_write(struct rtl8168_private *tp, int addr, int value)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -5384,7 +5384,7 @@ static void r8411_csi_write(struct rtl8169_private *tp, int addr, int value)
 	rtl_udelay_loop_wait_low(tp, &rtl_csiar_cond, 10, 100);
 }
 
-static u32 r8411_csi_read(struct rtl8169_private *tp, int addr)
+static u32 r8411_csi_read(struct rtl8168_private *tp, int addr)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -5395,7 +5395,7 @@ static u32 r8411_csi_read(struct rtl8169_private *tp, int addr)
 		RTL_R32(CSIDR) : ~0;
 }
 
-static void rtl_init_csi_ops(struct rtl8169_private *tp)
+static void rtl_init_csi_ops(struct rtl8168_private *tp)
 {
 	struct csi_ops *ops = &tp->csi_ops;
 
@@ -5424,8 +5424,8 @@ static void rtl_init_csi_ops(struct rtl8169_private *tp)
 		break;
 
 	default:
-		ops->write	= r8169_csi_write;
-		ops->read	= r8169_csi_read;
+		ops->write	= r8168_csi_write;
+		ops->read	= r8168_csi_read;
 		break;
 	}
 }
@@ -5436,7 +5436,7 @@ struct ephy_info {
 	u16 bits;
 };
 
-static void rtl_ephy_init(struct rtl8169_private *tp, const struct ephy_info *e,
+static void rtl_ephy_init(struct rtl8168_private *tp, const struct ephy_info *e,
 			  int len)
 {
 	u16 w;
@@ -5460,7 +5460,7 @@ static void rtl_enable_clock_request(struct pci_dev *pdev)
 				 PCI_EXP_LNKCTL_CLKREQ_EN);
 }
 
-static void rtl_pcie_state_l2l3_enable(struct rtl8169_private *tp, bool enable)
+static void rtl_pcie_state_l2l3_enable(struct rtl8168_private *tp, bool enable)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	u8 data;
@@ -5486,7 +5486,7 @@ static void rtl_pcie_state_l2l3_enable(struct rtl8169_private *tp, bool enable)
 	PktCntrDisable | \
 	Mac_dbgo_sel)
 
-static void rtl_hw_start_8168bb(struct rtl8169_private *tp)
+static void rtl_hw_start_8168bb(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -5501,7 +5501,7 @@ static void rtl_hw_start_8168bb(struct rtl8169_private *tp)
 	}
 }
 
-static void rtl_hw_start_8168bef(struct rtl8169_private *tp)
+static void rtl_hw_start_8168bef(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -5512,7 +5512,7 @@ static void rtl_hw_start_8168bef(struct rtl8169_private *tp)
 	RTL_W8(Config4, RTL_R8(Config4) & ~(1 << 0));
 }
 
-static void __rtl_hw_start_8168cp(struct rtl8169_private *tp)
+static void __rtl_hw_start_8168cp(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -5529,7 +5529,7 @@ static void __rtl_hw_start_8168cp(struct rtl8169_private *tp)
 	RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK);
 }
 
-static void rtl_hw_start_8168cp_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168cp_1(struct rtl8168_private *tp)
 {
 	static const struct ephy_info e_info_8168cp[] = {
 		{ 0x01, 0,	0x0001 },
@@ -5546,7 +5546,7 @@ static void rtl_hw_start_8168cp_1(struct rtl8169_private *tp)
 	__rtl_hw_start_8168cp(tp);
 }
 
-static void rtl_hw_start_8168cp_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8168cp_2(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -5561,7 +5561,7 @@ static void rtl_hw_start_8168cp_2(struct rtl8169_private *tp)
 	RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK);
 }
 
-static void rtl_hw_start_8168cp_3(struct rtl8169_private *tp)
+static void rtl_hw_start_8168cp_3(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -5581,7 +5581,7 @@ static void rtl_hw_start_8168cp_3(struct rtl8169_private *tp)
 	RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK);
 }
 
-static void rtl_hw_start_8168c_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168c_1(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	static const struct ephy_info e_info_8168c_1[] = {
@@ -5599,7 +5599,7 @@ static void rtl_hw_start_8168c_1(struct rtl8169_private *tp)
 	__rtl_hw_start_8168cp(tp);
 }
 
-static void rtl_hw_start_8168c_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8168c_2(struct rtl8168_private *tp)
 {
 	static const struct ephy_info e_info_8168c_2[] = {
 		{ 0x01, 0,	0x0001 },
@@ -5613,19 +5613,19 @@ static void rtl_hw_start_8168c_2(struct rtl8169_private *tp)
 	__rtl_hw_start_8168cp(tp);
 }
 
-static void rtl_hw_start_8168c_3(struct rtl8169_private *tp)
+static void rtl_hw_start_8168c_3(struct rtl8168_private *tp)
 {
 	rtl_hw_start_8168c_2(tp);
 }
 
-static void rtl_hw_start_8168c_4(struct rtl8169_private *tp)
+static void rtl_hw_start_8168c_4(struct rtl8168_private *tp)
 {
 	rtl_csi_access_enable_2(tp);
 
 	__rtl_hw_start_8168cp(tp);
 }
 
-static void rtl_hw_start_8168d(struct rtl8169_private *tp)
+static void rtl_hw_start_8168d(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -5642,7 +5642,7 @@ static void rtl_hw_start_8168d(struct rtl8169_private *tp)
 	RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK);
 }
 
-static void rtl_hw_start_8168dp(struct rtl8169_private *tp)
+static void rtl_hw_start_8168dp(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -5657,7 +5657,7 @@ static void rtl_hw_start_8168dp(struct rtl8169_private *tp)
 	rtl_disable_clock_request(pdev);
 }
 
-static void rtl_hw_start_8168d_4(struct rtl8169_private *tp)
+static void rtl_hw_start_8168d_4(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -5678,7 +5678,7 @@ static void rtl_hw_start_8168d_4(struct rtl8169_private *tp)
 	rtl_enable_clock_request(pdev);
 }
 
-static void rtl_hw_start_8168e_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168e_1(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -5716,7 +5716,7 @@ static void rtl_hw_start_8168e_1(struct rtl8169_private *tp)
 	RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en);
 }
 
-static void rtl_hw_start_8168e_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8168e_2(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -5756,7 +5756,7 @@ static void rtl_hw_start_8168e_2(struct rtl8169_private *tp)
 	RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en);
 }
 
-static void rtl_hw_start_8168f(struct rtl8169_private *tp)
+static void rtl_hw_start_8168f(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -5787,7 +5787,7 @@ static void rtl_hw_start_8168f(struct rtl8169_private *tp)
 	RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en);
 }
 
-static void rtl_hw_start_8168f_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168f_1(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	static const struct ephy_info e_info_8168f_1[] = {
@@ -5807,7 +5807,7 @@ static void rtl_hw_start_8168f_1(struct rtl8169_private *tp)
 	RTL_W8(EEE_LED, RTL_R8(EEE_LED) & ~0x07);
 }
 
-static void rtl_hw_start_8411(struct rtl8169_private *tp)
+static void rtl_hw_start_8411(struct rtl8168_private *tp)
 {
 	static const struct ephy_info e_info_8168f_1[] = {
 		{ 0x06, 0x00c0,	0x0020 },
@@ -5824,7 +5824,7 @@ static void rtl_hw_start_8411(struct rtl8169_private *tp)
 	rtl_w0w1_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0c00, 0x0000, ERIAR_EXGMAC);
 }
 
-static void rtl_hw_start_8168g(struct rtl8169_private *tp)
+static void rtl_hw_start_8168g(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -5859,7 +5859,7 @@ static void rtl_hw_start_8168g(struct rtl8169_private *tp)
 	rtl_pcie_state_l2l3_enable(tp, false);
 }
 
-static void rtl_hw_start_8168g_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168g_1(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	static const struct ephy_info e_info_8168g_1[] = {
@@ -5877,7 +5877,7 @@ static void rtl_hw_start_8168g_1(struct rtl8169_private *tp)
 	rtl_ephy_init(tp, e_info_8168g_1, ARRAY_SIZE(e_info_8168g_1));
 }
 
-static void rtl_hw_start_8168g_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8168g_2(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	static const struct ephy_info e_info_8168g_2[] = {
@@ -5895,7 +5895,7 @@ static void rtl_hw_start_8168g_2(struct rtl8169_private *tp)
 	rtl_ephy_init(tp, e_info_8168g_2, ARRAY_SIZE(e_info_8168g_2));
 }
 
-static void rtl_hw_start_8411_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8411_2(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	static const struct ephy_info e_info_8411_2[] = {
@@ -5914,7 +5914,7 @@ static void rtl_hw_start_8411_2(struct rtl8169_private *tp)
 	rtl_ephy_init(tp, e_info_8411_2, ARRAY_SIZE(e_info_8411_2));
 }
 
-static void rtl_hw_start_8168h_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168h_1(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -6012,7 +6012,7 @@ static void rtl_hw_start_8168h_1(struct rtl8169_private *tp)
 	r8168_mac_ocp_write(tp, 0xc09e, 0x0000);
 }
 
-static void rtl_hw_start_8168ep(struct rtl8169_private *tp)
+static void rtl_hw_start_8168ep(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -6053,7 +6053,7 @@ static void rtl_hw_start_8168ep(struct rtl8169_private *tp)
 	rtl_pcie_state_l2l3_enable(tp, false);
 }
 
-static void rtl_hw_start_8168ep_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168ep_1(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	static const struct ephy_info e_info_8168ep_1[] = {
@@ -6072,7 +6072,7 @@ static void rtl_hw_start_8168ep_1(struct rtl8169_private *tp)
 	rtl_hw_start_8168ep(tp);
 }
 
-static void rtl_hw_start_8168ep_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8168ep_2(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	static const struct ephy_info e_info_8168ep_2[] = {
@@ -6092,7 +6092,7 @@ static void rtl_hw_start_8168ep_2(struct rtl8169_private *tp)
 	RTL_W8(MISC_1, RTL_R8(MISC_1) & ~PFM_D3COLD_EN);
 }
 
-static void rtl_hw_start_8168ep_3(struct rtl8169_private *tp)
+static void rtl_hw_start_8168ep_3(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	u32 data;
@@ -6129,7 +6129,7 @@ static void rtl_hw_start_8168ep_3(struct rtl8169_private *tp)
 
 static void rtl_hw_start_8168(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
 
 	RTL_W8(Cfg9346, Cfg9346_Unlock);
@@ -6280,7 +6280,7 @@ static void rtl_hw_start_8168(struct net_device *dev)
 	PktCntrDisable | \
 	Mac_dbgo_sel)
 
-static void rtl_hw_start_8102e_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8102e_1(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -6313,7 +6313,7 @@ static void rtl_hw_start_8102e_1(struct rtl8169_private *tp)
 	rtl_ephy_init(tp, e_info_8102e_1, ARRAY_SIZE(e_info_8102e_1));
 }
 
-static void rtl_hw_start_8102e_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8102e_2(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
@@ -6326,14 +6326,14 @@ static void rtl_hw_start_8102e_2(struct rtl8169_private *tp)
 	RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en);
 }
 
-static void rtl_hw_start_8102e_3(struct rtl8169_private *tp)
+static void rtl_hw_start_8102e_3(struct rtl8168_private *tp)
 {
 	rtl_hw_start_8102e_2(tp);
 
 	rtl_ephy_write(tp, 0x03, 0xc2f9);
 }
 
-static void rtl_hw_start_8105e_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8105e_1(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	static const struct ephy_info e_info_8105e_1[] = {
@@ -6361,13 +6361,13 @@ static void rtl_hw_start_8105e_1(struct rtl8169_private *tp)
 	rtl_pcie_state_l2l3_enable(tp, false);
 }
 
-static void rtl_hw_start_8105e_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8105e_2(struct rtl8168_private *tp)
 {
 	rtl_hw_start_8105e_1(tp);
 	rtl_ephy_write(tp, 0x1e, rtl_ephy_read(tp, 0x1e) | 0x8000);
 }
 
-static void rtl_hw_start_8402(struct rtl8169_private *tp)
+static void rtl_hw_start_8402(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	static const struct ephy_info e_info_8402[] = {
@@ -6398,7 +6398,7 @@ static void rtl_hw_start_8402(struct rtl8169_private *tp)
 	rtl_pcie_state_l2l3_enable(tp, false);
 }
 
-static void rtl_hw_start_8106(struct rtl8169_private *tp)
+static void rtl_hw_start_8106(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 
@@ -6414,7 +6414,7 @@ static void rtl_hw_start_8106(struct rtl8169_private *tp)
 
 static void rtl_hw_start_8101(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
 
@@ -6488,9 +6488,9 @@ static void rtl_hw_start_8101(struct net_device *dev)
 	RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xf000);
 }
 
-static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
+static int rtl8168_change_mtu(struct net_device *dev, int new_mtu)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
 	if (new_mtu > ETH_DATA_LEN)
 		rtl_hw_jumbo_enable(tp);
@@ -6503,13 +6503,13 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
 	return 0;
 }
 
-static inline void rtl8169_make_unusable_by_asic(struct RxDesc *desc)
+static inline void rtl8168_make_unusable_by_asic(struct RxDesc *desc)
 {
 	desc->addr = cpu_to_le64(0x0badbadbadbadbadull);
 	desc->opts1 &= ~cpu_to_le32(DescOwn | RsvdMask);
 }
 
-static void rtl8169_free_rx_databuff(struct rtl8169_private *tp,
+static void rtl8168_free_rx_databuff(struct rtl8168_private *tp,
 				     void **data_buff, struct RxDesc *desc)
 {
 	dma_unmap_single(&tp->pci_dev->dev, le64_to_cpu(desc->addr), rx_buf_sz,
@@ -6517,10 +6517,10 @@ static void rtl8169_free_rx_databuff(struct rtl8169_private *tp,
 
 	kfree(*data_buff);
 	*data_buff = NULL;
-	rtl8169_make_unusable_by_asic(desc);
+	rtl8168_make_unusable_by_asic(desc);
 }
 
-static inline void rtl8169_mark_to_asic(struct RxDesc *desc, u32 rx_buf_sz)
+static inline void rtl8168_mark_to_asic(struct RxDesc *desc, u32 rx_buf_sz)
 {
 	u32 eor = le32_to_cpu(desc->opts1) & RingEnd;
 
@@ -6530,19 +6530,19 @@ static inline void rtl8169_mark_to_asic(struct RxDesc *desc, u32 rx_buf_sz)
 	desc->opts1 = cpu_to_le32(DescOwn | eor | rx_buf_sz);
 }
 
-static inline void rtl8169_map_to_asic(struct RxDesc *desc, dma_addr_t mapping,
+static inline void rtl8168_map_to_asic(struct RxDesc *desc, dma_addr_t mapping,
 				       u32 rx_buf_sz)
 {
 	desc->addr = cpu_to_le64(mapping);
-	rtl8169_mark_to_asic(desc, rx_buf_sz);
+	rtl8168_mark_to_asic(desc, rx_buf_sz);
 }
 
-static inline void *rtl8169_align(void *data)
+static inline void *rtl8168_align(void *data)
 {
 	return (void *)ALIGN((long)data, 16);
 }
 
-static struct sk_buff *rtl8169_alloc_rx_data(struct rtl8169_private *tp,
+static struct sk_buff *rtl8168_alloc_rx_data(struct rtl8168_private *tp,
 					     struct RxDesc *desc)
 {
 	void *data;
@@ -6555,14 +6555,14 @@ static struct sk_buff *rtl8169_alloc_rx_data(struct rtl8169_private *tp,
 	if (!data)
 		return NULL;
 
-	if (rtl8169_align(data) != data) {
+	if (rtl8168_align(data) != data) {
 		kfree(data);
 		data = kmalloc_node(rx_buf_sz + 15, GFP_KERNEL, node);
 		if (!data)
 			return NULL;
 	}
 
-	mapping = dma_map_single(d, rtl8169_align(data), rx_buf_sz,
+	mapping = dma_map_single(d, rtl8168_align(data), rx_buf_sz,
 				 DMA_FROM_DEVICE);
 	if (unlikely(dma_mapping_error(d, mapping))) {
 		if (net_ratelimit())
@@ -6570,7 +6570,7 @@ static struct sk_buff *rtl8169_alloc_rx_data(struct rtl8169_private *tp,
 		goto err_out;
 	}
 
-	rtl8169_map_to_asic(desc, mapping, rx_buf_sz);
+	rtl8168_map_to_asic(desc, mapping, rx_buf_sz);
 	return data;
 
 err_out:
@@ -6578,24 +6578,24 @@ static struct sk_buff *rtl8169_alloc_rx_data(struct rtl8169_private *tp,
 	return NULL;
 }
 
-static void rtl8169_rx_clear(struct rtl8169_private *tp)
+static void rtl8168_rx_clear(struct rtl8168_private *tp)
 {
 	unsigned int i;
 
 	for (i = 0; i < NUM_RX_DESC; i++) {
 		if (tp->Rx_databuff[i]) {
-			rtl8169_free_rx_databuff(tp, tp->Rx_databuff + i,
+			rtl8168_free_rx_databuff(tp, tp->Rx_databuff + i,
 					    tp->RxDescArray + i);
 		}
 	}
 }
 
-static inline void rtl8169_mark_as_last_descriptor(struct RxDesc *desc)
+static inline void rtl8168_mark_as_last_descriptor(struct RxDesc *desc)
 {
 	desc->opts1 |= cpu_to_le32(RingEnd);
 }
 
-static int rtl8169_rx_fill(struct rtl8169_private *tp)
+static int rtl8168_rx_fill(struct rtl8168_private *tp)
 {
 	unsigned int i;
 
@@ -6605,35 +6605,35 @@ static int rtl8169_rx_fill(struct rtl8169_private *tp)
 		if (tp->Rx_databuff[i])
 			continue;
 
-		data = rtl8169_alloc_rx_data(tp, tp->RxDescArray + i);
+		data = rtl8168_alloc_rx_data(tp, tp->RxDescArray + i);
 		if (!data) {
-			rtl8169_make_unusable_by_asic(tp->RxDescArray + i);
+			rtl8168_make_unusable_by_asic(tp->RxDescArray + i);
 			goto err_out;
 		}
 		tp->Rx_databuff[i] = data;
 	}
 
-	rtl8169_mark_as_last_descriptor(tp->RxDescArray + NUM_RX_DESC - 1);
+	rtl8168_mark_as_last_descriptor(tp->RxDescArray + NUM_RX_DESC - 1);
 	return 0;
 
 err_out:
-	rtl8169_rx_clear(tp);
+	rtl8168_rx_clear(tp);
 	return -ENOMEM;
 }
 
-static int rtl8169_init_ring(struct net_device *dev)
+static int rtl8168_init_ring(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
-	rtl8169_init_ring_indexes(tp);
+	rtl8168_init_ring_indexes(tp);
 
 	memset(tp->tx_skb, 0x0, NUM_TX_DESC * sizeof(struct ring_info));
 	memset(tp->Rx_databuff, 0x0, NUM_RX_DESC * sizeof(void *));
 
-	return rtl8169_rx_fill(tp);
+	return rtl8168_rx_fill(tp);
 }
 
-static void rtl8169_unmap_tx_skb(struct device *d, struct ring_info *tx_skb,
+static void rtl8168_unmap_tx_skb(struct device *d, struct ring_info *tx_skb,
 				 struct TxDesc *desc)
 {
 	unsigned int len = tx_skb->len;
@@ -6646,7 +6646,7 @@ static void rtl8169_unmap_tx_skb(struct device *d, struct ring_info *tx_skb,
 	tx_skb->len = 0;
 }
 
-static void rtl8169_tx_clear_range(struct rtl8169_private *tp, u32 start,
+static void rtl8168_tx_clear_range(struct rtl8168_private *tp, u32 start,
 				   unsigned int n)
 {
 	unsigned int i;
@@ -6659,7 +6659,7 @@ static void rtl8169_tx_clear_range(struct rtl8169_private *tp, u32 start,
 		if (len) {
 			struct sk_buff *skb = tx_skb->skb;
 
-			rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
+			rtl8168_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
 					     tp->TxDescArray + entry);
 			if (skb) {
 				dev_consume_skb_any(skb);
@@ -6669,13 +6669,13 @@ static void rtl8169_tx_clear_range(struct rtl8169_private *tp, u32 start,
 	}
 }
 
-static void rtl8169_tx_clear(struct rtl8169_private *tp)
+static void rtl8168_tx_clear(struct rtl8168_private *tp)
 {
-	rtl8169_tx_clear_range(tp, tp->dirty_tx, NUM_TX_DESC);
+	rtl8168_tx_clear_range(tp, tp->dirty_tx, NUM_TX_DESC);
 	tp->cur_tx = tp->dirty_tx = 0;
 }
 
-static void rtl_reset_work(struct rtl8169_private *tp)
+static void rtl_reset_work(struct rtl8168_private *tp)
 {
 	struct net_device *dev = tp->dev;
 	int i;
@@ -6684,28 +6684,28 @@ static void rtl_reset_work(struct rtl8169_private *tp)
 	netif_stop_queue(dev);
 	synchronize_sched();
 
-	rtl8169_hw_reset(tp);
+	rtl8168_hw_reset(tp);
 
 	for (i = 0; i < NUM_RX_DESC; i++)
-		rtl8169_mark_to_asic(tp->RxDescArray + i, rx_buf_sz);
+		rtl8168_mark_to_asic(tp->RxDescArray + i, rx_buf_sz);
 
-	rtl8169_tx_clear(tp);
-	rtl8169_init_ring_indexes(tp);
+	rtl8168_tx_clear(tp);
+	rtl8168_init_ring_indexes(tp);
 
 	napi_enable(&tp->napi);
 	rtl_hw_start(dev);
 	netif_wake_queue(dev);
-	rtl8169_check_link_status(dev, tp, tp->mmio_addr);
+	rtl8168_check_link_status(dev, tp, tp->mmio_addr);
 }
 
-static void rtl8169_tx_timeout(struct net_device *dev)
+static void rtl8168_tx_timeout(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
 	rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
 }
 
-static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb,
+static int rtl8168_xmit_frags(struct rtl8168_private *tp, struct sk_buff *skb,
 			      u32 *opts)
 {
 	struct skb_shared_info *info = skb_shinfo(skb);
@@ -6752,22 +6752,22 @@ static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb,
 	return cur_frag;
 
 err_out:
-	rtl8169_tx_clear_range(tp, tp->cur_tx + 1, cur_frag);
+	rtl8168_tx_clear_range(tp, tp->cur_tx + 1, cur_frag);
 	return -EIO;
 }
 
-static bool rtl_test_hw_pad_bug(struct rtl8169_private *tp, struct sk_buff *skb)
+static bool rtl_test_hw_pad_bug(struct rtl8168_private *tp, struct sk_buff *skb)
 {
 	return skb->len < ETH_ZLEN && tp->mac_version == RTL_GIGA_MAC_VER_34;
 }
 
-static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
+static netdev_tx_t rtl8168_start_xmit(struct sk_buff *skb,
 				      struct net_device *dev);
-/* r8169_csum_workaround()
+/* r8168_csum_workaround()
  * The hw limites the value the transport offset. When the offset is out of the
  * range, calculate the checksum by sw.
  */
-static void r8169_csum_workaround(struct rtl8169_private *tp,
+static void r8168_csum_workaround(struct rtl8168_private *tp,
 				  struct sk_buff *skb)
 {
 	if (skb_shinfo(skb)->gso_size) {
@@ -6783,7 +6783,7 @@ static void r8169_csum_workaround(struct rtl8169_private *tp,
 			nskb = segs;
 			segs = segs->next;
 			nskb->next = NULL;
-			rtl8169_start_xmit(nskb, tp->dev);
+			rtl8168_start_xmit(nskb, tp->dev);
 		} while (segs);
 
 		dev_consume_skb_any(skb);
@@ -6791,7 +6791,7 @@ static void r8169_csum_workaround(struct rtl8169_private *tp,
 		if (skb_checksum_help(skb) < 0)
 			goto drop;
 
-		rtl8169_start_xmit(skb, tp->dev);
+		rtl8168_start_xmit(skb, tp->dev);
 	} else {
 		struct net_device_stats *stats;
 
@@ -6837,7 +6837,7 @@ static inline __be16 get_protocol(struct sk_buff *skb)
 	return protocol;
 }
 
-static bool rtl8169_tso_csum_v1(struct rtl8169_private *tp,
+static bool rtl8168_tso_csum_v1(struct rtl8168_private *tp,
 				struct sk_buff *skb, u32 *opts)
 {
 	u32 mss = skb_shinfo(skb)->gso_size;
@@ -6859,7 +6859,7 @@ static bool rtl8169_tso_csum_v1(struct rtl8169_private *tp,
 	return true;
 }
 
-static bool rtl8169_tso_csum_v2(struct rtl8169_private *tp,
+static bool rtl8168_tso_csum_v2(struct rtl8168_private *tp,
 				struct sk_buff *skb, u32 *opts)
 {
 	u32 transport_offset = (u32)skb_transport_offset(skb);
@@ -6937,10 +6937,10 @@ static bool rtl8169_tso_csum_v2(struct rtl8169_private *tp,
 	return true;
 }
 
-static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
+static netdev_tx_t rtl8168_start_xmit(struct sk_buff *skb,
 				      struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	unsigned int entry = tp->cur_tx % NUM_TX_DESC;
 	struct TxDesc *txd = tp->TxDescArray + entry;
 	void __iomem *ioaddr = tp->mmio_addr;
@@ -6958,11 +6958,11 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
 	if (unlikely(le32_to_cpu(txd->opts1) & DescOwn))
 		goto err_stop_0;
 
-	opts[1] = cpu_to_le32(rtl8169_tx_vlan_tag(skb));
+	opts[1] = cpu_to_le32(rtl8168_tx_vlan_tag(skb));
 	opts[0] = DescOwn;
 
 	if (!tp->tso_csum(tp, skb, opts)) {
-		r8169_csum_workaround(tp, skb);
+		r8168_csum_workaround(tp, skb);
 		return NETDEV_TX_OK;
 	}
 
@@ -6977,7 +6977,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
 	tp->tx_skb[entry].len = len;
 	txd->addr = cpu_to_le64(mapping);
 
-	frags = rtl8169_xmit_frags(tp, skb, opts);
+	frags = rtl8168_xmit_frags(tp, skb, opts);
 	if (frags < 0)
 		goto err_dma_1;
 	else if (frags)
@@ -7028,7 +7028,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
 	return NETDEV_TX_OK;
 
 err_dma_1:
-	rtl8169_unmap_tx_skb(d, tp->tx_skb + entry, txd);
+	rtl8168_unmap_tx_skb(d, tp->tx_skb + entry, txd);
 err_dma_0:
 	dev_kfree_skb_any(skb);
 	dev->stats.tx_dropped++;
@@ -7040,9 +7040,9 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
 	return NETDEV_TX_BUSY;
 }
 
-static void rtl8169_pcierr_interrupt(struct net_device *dev)
+static void rtl8168_pcierr_interrupt(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	struct pci_dev *pdev = tp->pci_dev;
 	u16 pci_status, pci_cmd;
 
@@ -7082,12 +7082,12 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
 		dev->features &= ~NETIF_F_HIGHDMA;
 	}
 
-	rtl8169_hw_reset(tp);
+	rtl8168_hw_reset(tp);
 
 	rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
 }
 
-static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
+static void rtl_tx(struct net_device *dev, struct rtl8168_private *tp)
 {
 	unsigned int dirty_tx, tx_left;
 
@@ -7110,7 +7110,7 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
 		 */
 		dma_rmb();
 
-		rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
+		rtl8168_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
 				     tp->TxDescArray + entry);
 		if (status & LastFrag) {
 			u64_stats_update_begin(&tp->tx_stats.syncp);
@@ -7126,7 +7126,7 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
 
 	if (tp->dirty_tx != dirty_tx) {
 		tp->dirty_tx = dirty_tx;
-		/* Sync with rtl8169_start_xmit:
+		/* Sync with rtl8168_start_xmit:
 		 * - publish dirty_tx ring index (write barrier)
 		 * - refresh cur_tx ring index and queue status (read barrier)
 		 * May the current thread miss the stopped queue condition,
@@ -7152,12 +7152,12 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
 	}
 }
 
-static inline int rtl8169_fragmented_frame(u32 status)
+static inline int rtl8168_fragmented_frame(u32 status)
 {
 	return (status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag);
 }
 
-static inline void rtl8169_rx_csum(struct sk_buff *skb, u32 opts1)
+static inline void rtl8168_rx_csum(struct sk_buff *skb, u32 opts1)
 {
 	u32 status = opts1 & RxProtoMask;
 
@@ -7168,15 +7168,15 @@ static inline void rtl8169_rx_csum(struct sk_buff *skb, u32 opts1)
 		skb_checksum_none_assert(skb);
 }
 
-static struct sk_buff *rtl8169_try_rx_copy(void *data,
-					   struct rtl8169_private *tp,
+static struct sk_buff *rtl8168_try_rx_copy(void *data,
+					   struct rtl8168_private *tp,
 					   int pkt_size,
 					   dma_addr_t addr)
 {
 	struct sk_buff *skb;
 	struct device *d = &tp->pci_dev->dev;
 
-	data = rtl8169_align(data);
+	data = rtl8168_align(data);
 	dma_sync_single_for_cpu(d, addr, pkt_size, DMA_FROM_DEVICE);
 	prefetch(data);
 	skb = napi_alloc_skb(&tp->napi, pkt_size);
@@ -7187,7 +7187,7 @@ static struct sk_buff *rtl8169_try_rx_copy(void *data,
 	return skb;
 }
 
-static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget)
+static int rtl_rx(struct net_device *dev, struct rtl8168_private *tp, u32 budget)
 {
 	unsigned int cur_rx, rx_left;
 	unsigned int count;
@@ -7242,24 +7242,24 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget
 			 * frames. They are seen as a symptom of over-mtu
 			 * sized frames.
 			 */
-			if (unlikely(rtl8169_fragmented_frame(status))) {
+			if (unlikely(rtl8168_fragmented_frame(status))) {
 				dev->stats.rx_dropped++;
 				dev->stats.rx_length_errors++;
 				goto release_descriptor;
 			}
 
-			skb = rtl8169_try_rx_copy(tp->Rx_databuff[entry],
+			skb = rtl8168_try_rx_copy(tp->Rx_databuff[entry],
 						  tp, pkt_size, addr);
 			if (!skb) {
 				dev->stats.rx_dropped++;
 				goto release_descriptor;
 			}
 
-			rtl8169_rx_csum(skb, status);
+			rtl8168_rx_csum(skb, status);
 			skb_put(skb, pkt_size);
 			skb->protocol = eth_type_trans(skb, dev);
 
-			rtl8169_rx_vlan_tag(desc, skb);
+			rtl8168_rx_vlan_tag(desc, skb);
 
 			if (skb->pkt_type == PACKET_MULTICAST)
 				dev->stats.multicast++;
@@ -7273,7 +7273,7 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget
 		}
 release_descriptor:
 		desc->opts2 = 0;
-		rtl8169_mark_to_asic(desc, rx_buf_sz);
+		rtl8168_mark_to_asic(desc, rx_buf_sz);
 	}
 
 	count = cur_rx - tp->cur_rx;
@@ -7282,10 +7282,10 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget
 	return count;
 }
 
-static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
+static irqreturn_t rtl8168_interrupt(int irq, void *dev_instance)
 {
 	struct net_device *dev = dev_instance;
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	int handled = 0;
 	u16 status;
 
@@ -7305,7 +7305,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
 /*
  * Workqueue context.
  */
-static void rtl_slow_event_work(struct rtl8169_private *tp)
+static void rtl_slow_event_work(struct rtl8168_private *tp)
 {
 	struct net_device *dev = tp->dev;
 	u16 status;
@@ -7326,10 +7326,10 @@ static void rtl_slow_event_work(struct rtl8169_private *tp)
 	}
 
 	if (unlikely(status & SYSErr))
-		rtl8169_pcierr_interrupt(dev);
+		rtl8168_pcierr_interrupt(dev);
 
 	if (status & LinkChg)
-		__rtl8169_check_link_status(dev, tp, tp->mmio_addr, true);
+		__rtl8168_check_link_status(dev, tp, tp->mmio_addr, true);
 
 	rtl_irq_enable_all(tp);
 }
@@ -7338,15 +7338,15 @@ static void rtl_task(struct work_struct *work)
 {
 	static const struct {
 		int bitnr;
-		void (*action)(struct rtl8169_private *);
+		void (*action)(struct rtl8168_private *);
 	} rtl_work[] = {
 		/* XXX - keep rtl_slow_event_work() as first element. */
 		{ RTL_FLAG_TASK_SLOW_PENDING,	rtl_slow_event_work },
 		{ RTL_FLAG_TASK_RESET_PENDING,	rtl_reset_work },
 		{ RTL_FLAG_TASK_PHY_PENDING,	rtl_phy_work }
 	};
-	struct rtl8169_private *tp =
-		container_of(work, struct rtl8169_private, wk.work);
+	struct rtl8168_private *tp =
+		container_of(work, struct rtl8168_private, wk.work);
 	struct net_device *dev = tp->dev;
 	int i;
 
@@ -7368,9 +7368,9 @@ static void rtl_task(struct work_struct *work)
 	rtl_unlock_work(tp);
 }
 
-static int rtl8169_poll(struct napi_struct *napi, int budget)
+static int rtl8168_poll(struct napi_struct *napi, int budget)
 {
-	struct rtl8169_private *tp = container_of(napi, struct rtl8169_private, napi);
+	struct rtl8168_private *tp = container_of(napi, struct rtl8168_private, napi);
 	struct net_device *dev = tp->dev;
 	u16 enable_mask = RTL_EVENT_NAPI | tp->event_slow;
 	int work_done= 0;
@@ -7401,50 +7401,50 @@ static int rtl8169_poll(struct napi_struct *napi, int budget)
 	return work_done;
 }
 
-static void rtl8169_down(struct net_device *dev)
+static void rtl8168_down(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
 	del_timer_sync(&tp->timer);
 
 	napi_disable(&tp->napi);
 	netif_stop_queue(dev);
 
-	rtl8169_hw_reset(tp);
+	rtl8168_hw_reset(tp);
 
 	/* Give a racing hard_start_xmit a few cycles to complete. */
 	synchronize_sched();
 
-	rtl8169_tx_clear(tp);
+	rtl8168_tx_clear(tp);
 
-	rtl8169_rx_clear(tp);
+	rtl8168_rx_clear(tp);
 
 	rtl_pll_power_down(tp);
 }
 
-static int rtl8169_close(struct net_device *dev)
+static int rtl8168_close(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	struct pci_dev *pdev = tp->pci_dev;
 
 	pm_runtime_get_sync(&pdev->dev);
 
 	/* Update counters before going down */
-	rtl8169_update_counters(dev);
+	rtl8168_update_counters(dev);
 
 	rtl_lock_work(tp);
 	clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
 
-	rtl8169_down(dev);
+	rtl8168_down(dev);
 	rtl_unlock_work(tp);
 
 	cancel_work_sync(&tp->wk.work);
 
 	free_irq(pdev->irq, dev);
 
-	dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray,
+	dma_free_coherent(&pdev->dev, R8168_RX_RING_BYTES, tp->RxDescArray,
 			  tp->RxPhyAddr);
-	dma_free_coherent(&pdev->dev, R8169_TX_RING_BYTES, tp->TxDescArray,
+	dma_free_coherent(&pdev->dev, R8168_TX_RING_BYTES, tp->TxDescArray,
 			  tp->TxPhyAddr);
 	tp->TxDescArray = NULL;
 	tp->RxDescArray = NULL;
@@ -7455,17 +7455,17 @@ static int rtl8169_close(struct net_device *dev)
 }
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
-static void rtl8169_netpoll(struct net_device *dev)
+static void rtl8168_netpoll(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 
-	rtl8169_interrupt(tp->pci_dev->irq, dev);
+	rtl8168_interrupt(tp->pci_dev->irq, dev);
 }
 #endif
 
 static int rtl_open(struct net_device *dev)
 {
-	struct rtl8169_private *tp = netdev_priv(dev);
+	struct rtl8168_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
 	int retval = -ENOMEM;
@@ -7476,17 +7476,17 @@ static int rtl_open(struct net_device *dev)
 	 * Rx and Tx descriptors needs 256 bytes alignment.
 	 * dma_alloc_coherent provides more.
 	 */
-	tp->TxDescArray = dma_alloc_coherent(&pdev->dev, R8169_TX_RING_BYTES,
+	tp->TxDescArray = dma_alloc_coherent(&pdev->dev, R8168_TX_RING_BYTES,
 					     &tp->TxPhyAddr, GFP_KERNEL);
 	if (!tp->TxDescArray)
 		goto err_pm_runtime_put;
 
-	tp->RxDescArray = dma_alloc_coherent(&pdev->dev, R8169_RX_RING_BYTES,
+	tp->RxDescArray = dma_alloc_coherent(&pdev->dev, R8168_RX_RING_BYTES,
 					     &tp->RxPhyAddr, GFP_KERNEL);
 	if (!tp->RxDescArray)
 		goto err_free_tx_0;
 
-	retval = rtl8169_init_ring(dev);
+	retval = rtl8168_init_ring(dev);
 	if (retval < 0)
 		goto err_free_rx_1;
 
@@ -7496,7 +7496,7 @@ static int rtl_open(struct net_device *dev)
 
 	rtl_request_firmware(tp);
 
-	retval = request_irq(pdev->irq, rtl8169_interrupt,
+	retval = request_irq(pdev->irq, rtl8168_interrupt,
 			     (tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED,
 			     dev->name, dev);
 	if (retval < 0)
@@ -7508,15 +7508,15 @@ static int rtl_open(struct net_device *dev)
 
 	napi_enable(&tp->napi);
 
-	rtl8169_init_phy(dev, tp);
+	rtl8168_init_phy(dev, tp);
 
-	__rtl8169_set_features(dev, dev->features);
+	__rtl8168_set_features(dev, dev->features);
 
 	rtl_pll_power_up(tp);
 
 	rtl_hw_start(dev);
 
-	if (!rtl8169_init_counter_offsets(dev))
+	if (!rtl8168_init_counter_offsets(dev))
 		netif_warn(tp, hw, dev, "counter reset/update failed\n");
 
 	netif_start_queue(dev);
@@ -7526,19 +7526,19 @@ static int rtl_open(struct net_device *dev)
 	tp->saved_wolopts = 0;
 	pm_runtime_put_noidle(&pdev->dev);
 
-	rtl8169_check_link_status(dev, tp, ioaddr);
+	rtl8168_check_link_status(dev, tp, ioaddr);
 out:
 	return retval;
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.15.1

Part of the diff is not shown here. View the raw message.

author maintainer
#8 lore raw

RFC PATCH 8/18 r8168: add basic phylib support

In reply to Heiner Kallweit

All PHY's of the supported chips are MII-compatible, therefore let phylib do the work.

---
 drivers/net/ethernet/realtek/Kconfig |   1 +
 drivers/net/ethernet/realtek/r8168.c | 152 +++++++++++++++++++++++++++--------
 2 files changed, 120 insertions(+), 33 deletions(-)
drivers/net/ethernet/realtek/Kconfig +1 -0
index 011b524c5..97b24103e 100644
@@ -99,6 +99,7 @@ config R8168
 	depends on PCI
 	select FW_LOADER
 	select CRC32
+	select PHYLIB
 	select MII
 	---help---
 	  Say Y here if you have a Realtek 8168 PCI Gigabit Ethernet adapter.
drivers/net/ethernet/realtek/r8168.c +119 -33

241 lines not on this page · raw message

Signature · 1 line
2.15.1
author maintainer
#10 lore raw

RFC PATCH 9/18 r8168: use genphy_soft_reset instead of open coding the soft reset

In reply to Heiner Kallweit

Use genphy_soft_reset instead of open coding the soft reset.

---
 drivers/net/ethernet/realtek/r8168.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/net/ethernet/realtek/r8168.c +1 -13
index be6c45b11..62d0e0169 100644
@@ -4308,25 +4308,13 @@ static void rtl8168_phy_timer(struct timer_list *t)
 	rtl_schedule_task(tp, RTL_FLAG_TASK_PHY_PENDING);
 }
 
-DECLARE_RTL_COND(rtl_phy_reset_cond)
-{
-	return rtl8168_xmii_reset_pending(tp);
-}
-
-static void rtl8168_phy_reset(struct net_device *dev,
-			      struct rtl8168_private *tp)
-{
-	rtl8168_xmii_reset_enable(tp);
-	rtl_msleep_loop_wait_low(tp, &rtl_phy_reset_cond, 1, 100);
-}
-
 static void rtl8168_init_phy(struct net_device *dev, struct rtl8168_private *tp)
 {
 	rtl_hw_phy_config(dev);
 
 	pci_write_config_byte(tp->pci_dev, PCI_LATENCY_TIMER, 0x40);
 
-	rtl8168_phy_reset(dev, tp);
+	genphy_soft_reset(dev->phydev);
 
 	rtl8168_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
 			  ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
Signature · 1 line
2.15.1
author maintainer
#13 lore raw

RFC PATCH 10/18 r8168: switch to phy_ethtool_get/set_link_ksettings

In reply to Heiner Kallweit

Use phy_ethtool_get/set_link_ksettings instead of open coding these ethtool ops.

---
 drivers/net/ethernet/realtek/r8168.c | 50 +++---------------------------------
 1 file changed, 3 insertions(+), 47 deletions(-)
drivers/net/ethernet/realtek/r8168.c +3 -47
index 62d0e0169..e698f13c2 100644
@@ -2004,50 +2004,6 @@ static void rtl8168_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
 		__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), swab16(opts2 & 0xffff));
 }
 
-static int rtl8168_get_link_ksettings_xmii(struct net_device *dev,
-					   struct ethtool_link_ksettings *cmd)
-{
-	struct rtl8168_private *tp = netdev_priv(dev);
-
-	mii_ethtool_get_link_ksettings(&tp->mii, cmd);
-
-	return 0;
-}
-
-static int rtl8168_get_link_ksettings(struct net_device *dev,
-				      struct ethtool_link_ksettings *cmd)
-{
-	struct rtl8168_private *tp = netdev_priv(dev);
-	int rc;
-
-	rtl_lock_work(tp);
-	rc = rtl8168_get_link_ksettings_xmii(dev, cmd);
-	rtl_unlock_work(tp);
-
-	return rc;
-}
-
-static int rtl8168_set_link_ksettings(struct net_device *dev,
-				      const struct ethtool_link_ksettings *cmd)
-{
-	struct rtl8168_private *tp = netdev_priv(dev);
-	int rc;
-	u32 advertising;
-
-	if (!ethtool_convert_link_mode_to_legacy_u32(&advertising,
-	    cmd->link_modes.advertising))
-		return -EINVAL;
-
-	del_timer_sync(&tp->timer);
-
-	rtl_lock_work(tp);
-	rc = rtl8168_set_speed(dev, cmd->base.autoneg, cmd->base.speed,
-			       cmd->base.duplex, advertising);
-	rtl_unlock_work(tp);
-
-	return rc;
-}
-
 static void rtl8168_get_regs(struct net_device *dev, struct ethtool_regs *regs,
 			     void *p)
 {
@@ -2317,7 +2273,7 @@ static const struct rtl_coalesce_info *rtl_coalesce_info(struct net_device *dev)
 	const struct rtl_coalesce_info *ci;
 	int rc;
 
-	rc = rtl8168_get_link_ksettings(dev, &ecmd);
+	rc = phy_ethtool_get_link_ksettings(dev, &ecmd);
 	if (rc < 0)
 		return ERR_PTR(rc);
 
@@ -2478,8 +2434,8 @@ static const struct ethtool_ops rtl8168_ethtool_ops = {
 	.get_ethtool_stats	= rtl8168_get_ethtool_stats,
 	.get_ts_info		= ethtool_op_get_ts_info,
 	.nway_reset		= rtl8168_nway_reset,
-	.get_link_ksettings	= rtl8168_get_link_ksettings,
-	.set_link_ksettings	= rtl8168_set_link_ksettings,
+	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
+	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
 };
 
 static void rtl8168_get_mac_version(struct rtl8168_private *tp,
Signature · 1 line
2.15.1
author maintainer
#15 lore raw

RFC PATCH 11/18 r8168: switch to phy_ethtool_nway_reset

In reply to Heiner Kallweit

Switch to phy_ethtool_nway_reset.

---
 drivers/net/ethernet/realtek/Kconfig | 1 -
 drivers/net/ethernet/realtek/r8168.c | 9 +--------
 2 files changed, 1 insertion(+), 9 deletions(-)
drivers/net/ethernet/realtek/Kconfig +0 -1
index 97b24103e..a31aa84be 100644
@@ -100,7 +100,6 @@ config R8168
 	select FW_LOADER
 	select CRC32
 	select PHYLIB
-	select MII
 	---help---
 	  Say Y here if you have a Realtek 8168 PCI Gigabit Ethernet adapter.
 	  This driver supports the PCIE models.
drivers/net/ethernet/realtek/r8168.c +1 -8
index e698f13c2..33f61e100 100644
@@ -2194,13 +2194,6 @@ static void rtl8168_get_strings(struct net_device *dev, u32 stringset, u8 *data)
 	}
 }
 
-static int rtl8168_nway_reset(struct net_device *dev)
-{
-	struct rtl8168_private *tp = netdev_priv(dev);
-
-	return mii_nway_restart(&tp->mii);
-}
-
 /*
  * Interrupt coalescing
  *
@@ -2433,7 +2426,7 @@ static const struct ethtool_ops rtl8168_ethtool_ops = {
 	.get_sset_count		= rtl8168_get_sset_count,
 	.get_ethtool_stats	= rtl8168_get_ethtool_stats,
 	.get_ts_info		= ethtool_op_get_ts_info,
-	.nway_reset		= rtl8168_nway_reset,
+	.nway_reset		= phy_ethtool_nway_reset,
 	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
 	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
 };
Signature · 1 line
2.15.1
author maintainer
#17 lore raw

RFC PATCH 12/18 r8168: switch to phy_mii_ioctl

In reply to Heiner Kallweit

Use phy_mii_ioctl for handling the ioctl's.

---
 drivers/net/ethernet/realtek/r8168.c | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)
drivers/net/ethernet/realtek/r8168.c +3 -22
index 33f61e100..d33f93a31 100644
@@ -4316,31 +4316,12 @@ static int rtl_set_mac_address(struct net_device *dev, void *p)
 	return 0;
 }
 
-static int rtl_xmii_ioctl(struct rtl8168_private *tp,
-			  struct mii_ioctl_data *data, int cmd)
-{
-	switch (cmd) {
-	case SIOCGMIIPHY:
-		data->phy_id = 32; /* Internal PHY */
-		return 0;
-
-	case SIOCGMIIREG:
-		data->val_out = rtl_readphy(tp, data->reg_num & 0x1f);
-		return 0;
-
-	case SIOCSMIIREG:
-		rtl_writephy(tp, data->reg_num & 0x1f, data->val_in);
-		return 0;
-	}
-	return -EOPNOTSUPP;
-}
-
 static int rtl8168_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
-	struct rtl8168_private *tp = netdev_priv(dev);
-	struct mii_ioctl_data *data = if_mii(ifr);
+	if (!netif_running(dev))
+		return -ENODEV;
 
-	return netif_running(dev) ? rtl_xmii_ioctl(tp, data, cmd) : -ENODEV;
+	return phy_mii_ioctl(dev->phydev, ifr, cmd);
 }
 
 static void rtl_init_mdio_ops(struct rtl8168_private *tp)
Signature · 1 line
2.15.1
author maintainer
#20 lore raw

RFC PATCH 13/18 r8168: replace speed_down with genphy_restart_aneg

In reply to Heiner Kallweit

Dealing with link partner abilities is handled by phylib, so let's just trigger autonegotiation here.

---
 drivers/net/ethernet/realtek/r8168.c | 26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)
drivers/net/ethernet/realtek/r8168.c +1 -25
index d33f93a31..6b398915f 100644
@@ -4360,30 +4360,6 @@ static void rtl_init_mdio_ops(struct rtl8168_private *tp)
 	}
 }
 
-static void rtl_speed_down(struct rtl8168_private *tp)
-{
-	u32 adv;
-	int lpa;
-
-	rtl_writephy(tp, 0x1f, 0x0000);
-	lpa = rtl_readphy(tp, MII_LPA);
-
-	if (lpa & (LPA_10HALF | LPA_10FULL))
-		adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full;
-	else if (lpa & (LPA_100HALF | LPA_100FULL))
-		adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
-		      ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full;
-	else
-		adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
-		      ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
-		      (tp->mii.supports_gmii ?
-		       ADVERTISED_1000baseT_Half |
-		       ADVERTISED_1000baseT_Full : 0);
-
-	rtl8168_set_speed(tp->dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
-			  adv);
-}
-
 static void rtl_wol_suspend_quirk(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
@@ -4424,7 +4400,7 @@ static bool rtl_wol_pll_power_down(struct rtl8168_private *tp)
 	if (!(__rtl8168_get_wol(tp) & WAKE_ANY))
 		return false;
 
-	rtl_speed_down(tp);
+	genphy_restart_aneg(tp->dev->phydev);
 	rtl_wol_suspend_quirk(tp);
 
 	return true;
Signature · 1 line
2.15.1
author maintainer
#23 lore raw

RFC PATCH 14/18 r8168: remove rtl8168_set_speed

In reply to Heiner Kallweit

All these PHY basics are handled by phylib, so let's remove this code.

---
 drivers/net/ethernet/realtek/r8168.c | 92 ------------------------------------
 1 file changed, 92 deletions(-)
drivers/net/ethernet/realtek/r8168.c +0 -92
index 6b398915f..f88fc0fa0 100644
@@ -1843,91 +1843,6 @@ static int rtl8168_get_regs_len(struct net_device *dev)
 	return R8168_REGS_SIZE;
 }
 
-static int rtl8168_set_speed_xmii(struct net_device *dev,
-				  u8 autoneg, u16 speed, u8 duplex, u32 adv)
-{
-	struct rtl8168_private *tp = netdev_priv(dev);
-	int giga_ctrl, bmcr;
-	int rc = -EINVAL;
-
-	rtl_writephy(tp, 0x1f, 0x0000);
-
-	if (autoneg == AUTONEG_ENABLE) {
-		int auto_nego;
-
-		auto_nego = rtl_readphy(tp, MII_ADVERTISE);
-		auto_nego &= ~(ADVERTISE_10HALF | ADVERTISE_10FULL |
-				ADVERTISE_100HALF | ADVERTISE_100FULL);
-
-		if (adv & ADVERTISED_10baseT_Half)
-			auto_nego |= ADVERTISE_10HALF;
-		if (adv & ADVERTISED_10baseT_Full)
-			auto_nego |= ADVERTISE_10FULL;
-		if (adv & ADVERTISED_100baseT_Half)
-			auto_nego |= ADVERTISE_100HALF;
-		if (adv & ADVERTISED_100baseT_Full)
-			auto_nego |= ADVERTISE_100FULL;
-
-		auto_nego |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
-
-		giga_ctrl = rtl_readphy(tp, MII_CTRL1000);
-		giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
-
-		/* The 8100e/8101e/8102e do Fast Ethernet only. */
-		if (tp->mii.supports_gmii) {
-			if (adv & ADVERTISED_1000baseT_Half)
-				giga_ctrl |= ADVERTISE_1000HALF;
-			if (adv & ADVERTISED_1000baseT_Full)
-				giga_ctrl |= ADVERTISE_1000FULL;
-		} else if (adv & (ADVERTISED_1000baseT_Half |
-				  ADVERTISED_1000baseT_Full)) {
-			netif_info(tp, link, dev,
-				   "PHY does not support 1000Mbps\n");
-			goto out;
-		}
-
-		bmcr = BMCR_ANENABLE | BMCR_ANRESTART;
-
-		rtl_writephy(tp, MII_ADVERTISE, auto_nego);
-		rtl_writephy(tp, MII_CTRL1000, giga_ctrl);
-	} else {
-		if (speed == SPEED_10)
-			bmcr = 0;
-		else if (speed == SPEED_100)
-			bmcr = BMCR_SPEED100;
-		else
-			goto out;
-
-		if (duplex == DUPLEX_FULL)
-			bmcr |= BMCR_FULLDPLX;
-	}
-
-	rtl_writephy(tp, MII_BMCR, bmcr);
-
-	rc = 0;
-out:
-	return rc;
-}
-
-static int rtl8168_set_speed(struct net_device *dev,
-			     u8 autoneg, u16 speed, u8 duplex, u32 advertising)
-{
-	struct rtl8168_private *tp = netdev_priv(dev);
-	int ret;
-
-	ret = rtl8168_set_speed_xmii(dev, autoneg, speed, duplex, advertising);
-	if (ret < 0)
-		goto out;
-
-	if (netif_running(dev) && (autoneg == AUTONEG_ENABLE) &&
-	    (advertising & ADVERTISED_1000baseT_Full) &&
-	    !pci_is_pcie(tp->pci_dev)) {
-		mod_timer(&tp->timer, jiffies + RTL8168_PHY_TIMEOUT);
-	}
-out:
-	return ret;
-}
-
 static netdev_features_t rtl8168_fix_features(struct net_device *dev,
 	netdev_features_t features)
 {
@@ -4264,13 +4179,6 @@ static void rtl8168_init_phy(struct net_device *dev, struct rtl8168_private *tp)
 	pci_write_config_byte(tp->pci_dev, PCI_LATENCY_TIMER, 0x40);
 
 	genphy_soft_reset(dev->phydev);
-
-	rtl8168_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
-			  ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
-			  ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
-			  (tp->mii.supports_gmii ?
-			   ADVERTISED_1000baseT_Half |
-			   ADVERTISED_1000baseT_Full : 0));
 }
 
 static void rtl_rar_set(struct rtl8168_private *tp, u8 *addr)
Signature · 1 line
2.15.1
author maintainer
#24 lore raw

RFC PATCH 15/18 r8168: remove rtl_phy_work and rtl8168_phy_timer

In reply to Heiner Kallweit

Remove further code which is replaced by phylib.

---
 drivers/net/ethernet/realtek/r8168.c | 60 ------------------------------------
 1 file changed, 60 deletions(-)
drivers/net/ethernet/realtek/r8168.c +0 -60
index f88fc0fa0..91191d178 100644
@@ -752,7 +752,6 @@ enum rtl_flag {
 	RTL_FLAG_TASK_ENABLED,
 	RTL_FLAG_TASK_SLOW_PENDING,
 	RTL_FLAG_TASK_RESET_PENDING,
-	RTL_FLAG_TASK_PHY_PENDING,
 	RTL_FLAG_MAX
 };
 
@@ -781,7 +780,6 @@ struct rtl8168_private {
 	dma_addr_t RxPhyAddr;
 	void *Rx_databuff[NUM_RX_DESC];	/* Rx data buffers */
 	struct ring_info tx_skb[NUM_TX_DESC];	/* Tx data buffers */
-	struct timer_list timer;
 	u16 cp_cmd;
 
 	u16 event_slow;
@@ -1559,24 +1557,6 @@ static void rtl8168_irq_mask_and_ack(struct rtl8168_private *tp)
 	RTL_R8(ChipCmd);
 }
 
-static unsigned int rtl8168_xmii_reset_pending(struct rtl8168_private *tp)
-{
-	return rtl_readphy(tp, MII_BMCR) & BMCR_RESET;
-}
-
-static unsigned int rtl8168_xmii_link_ok(void __iomem *ioaddr)
-{
-	return RTL_R8(PHYstatus) & LinkStatus;
-}
-
-static void rtl8168_xmii_reset_enable(struct rtl8168_private *tp)
-{
-	unsigned int val;
-
-	val = rtl_readphy(tp, MII_BMCR) | BMCR_RESET;
-	rtl_writephy(tp, MII_BMCR, val & 0xffff);
-}
-
 static void rtl_link_chg_patch(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
@@ -4131,47 +4111,12 @@ static void rtl_hw_phy_config(struct net_device *dev)
 	}
 }
 
-static void rtl_phy_work(struct rtl8168_private *tp)
-{
-	struct timer_list *timer = &tp->timer;
-	void __iomem *ioaddr = tp->mmio_addr;
-	unsigned long timeout = RTL8168_PHY_TIMEOUT;
-
-	assert(tp->mac_version > RTL_GIGA_MAC_VER_01);
-
-	if (rtl8168_xmii_reset_pending(tp)) {
-		/*
-		 * A busy loop could burn quite a few cycles on nowadays CPU.
-		 * Let's delay the execution of the timer for a few ticks.
-		 */
-		timeout = HZ/10;
-		goto out_mod_timer;
-	}
-
-	if (rtl8168_xmii_link_ok(ioaddr))
-		return;
-
-	netif_dbg(tp, link, tp->dev, "PHY reset until link up\n");
-
-	rtl8168_xmii_reset_enable(tp);
-
-out_mod_timer:
-	mod_timer(timer, jiffies + timeout);
-}
-
 static void rtl_schedule_task(struct rtl8168_private *tp, enum rtl_flag flag)
 {
 	if (!test_and_set_bit(flag, tp->wk.flags))
 		schedule_work(&tp->wk.work);
 }
 
-static void rtl8168_phy_timer(struct timer_list *t)
-{
-	struct rtl8168_private *tp = from_timer(tp, t, timer);
-
-	rtl_schedule_task(tp, RTL_FLAG_TASK_PHY_PENDING);
-}
-
 static void rtl8168_init_phy(struct net_device *dev, struct rtl8168_private *tp)
 {
 	rtl_hw_phy_config(dev);
@@ -7120,7 +7065,6 @@ static void rtl_task(struct work_struct *work)
 		/* XXX - keep rtl_slow_event_work() as first element. */
 		{ RTL_FLAG_TASK_SLOW_PENDING,	rtl_slow_event_work },
 		{ RTL_FLAG_TASK_RESET_PENDING,	rtl_reset_work },
-		{ RTL_FLAG_TASK_PHY_PENDING,	rtl_phy_work }
 	};
 	struct rtl8168_private *tp =
 		container_of(work, struct rtl8168_private, wk.work);
@@ -7184,8 +7128,6 @@ static void rtl8168_down(struct net_device *dev)
 
 	phy_stop(dev->phydev);
 
-	del_timer_sync(&tp->timer);
-
 	napi_disable(&tp->napi);
 	netif_stop_queue(dev);
 
@@ -8076,8 +8018,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	tp->opts1_mask = ~(RxBOVF | RxFOVF);
 
-	timer_setup(&tp->timer, rtl8168_phy_timer, 0);
-
 	tp->rtl_fw = RTL_FIRMWARE_UNKNOWN;
 
 	tp->counters = dmam_alloc_coherent (&pdev->dev, sizeof(*tp->counters),
Signature · 1 line
2.15.1
author maintainer
#25 lore raw

RFC PATCH 16/18 r8168: use phy_read/write in rtl_readphy/writephy helpers

In reply to Heiner Kallweit

Instead of accessing mdio_ops directly use phy_read/write in these helpers.

---
 drivers/net/ethernet/realtek/r8168.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/realtek/r8168.c +2 -2
index 91191d178..64c87509d 100644
@@ -1167,12 +1167,12 @@ static int r8168dp_2_mdio_read(struct rtl8168_private *tp, int reg)
 
 static void rtl_writephy(struct rtl8168_private *tp, int location, u32 val)
 {
-	tp->mdio_ops.write(tp, location, val);
+	phy_write(tp->dev->phydev, location, val);
 }
 
 static int rtl_readphy(struct rtl8168_private *tp, int location)
 {
-	return tp->mdio_ops.read(tp, location);
+	return phy_read(tp->dev->phydev, location);
 }
 
 static void rtl_patchphy(struct rtl8168_private *tp, int reg_addr, int value)
Signature · 1 line
2.15.1
author maintainer
#26 lore raw

RFC PATCH 17/18 r8168: remove use of struct mii_if_info

In reply to Heiner Kallweit

After switching to phylib we don't need most elements of struct mii_if_info any longer.

---
 drivers/net/ethernet/realtek/r8168.c | 37 +++++++-----------------------------
 1 file changed, 7 insertions(+), 30 deletions(-)
drivers/net/ethernet/realtek/r8168.c +7 -30
index 64c87509d..765c60bc1 100644
@@ -816,7 +816,7 @@ struct rtl8168_private {
 
 	unsigned features;
 
-	struct mii_if_info mii;
+	bool supports_gmii;
 	struct mii_bus *mii_bus;
 	dma_addr_t counters_phys_addr;
 	struct rtl8168_counters *counters;
@@ -1188,21 +1188,6 @@ static void rtl_w0w1_phy(struct rtl8168_private *tp, int reg_addr, int p, int m)
 	rtl_writephy(tp, reg_addr, (val & ~m) | p);
 }
 
-static void rtl_mdio_write(struct net_device *dev, int phy_id, int location,
-			   int val)
-{
-	struct rtl8168_private *tp = netdev_priv(dev);
-
-	rtl_writephy(tp, location, val);
-}
-
-static int rtl_mdio_read(struct net_device *dev, int phy_id, int location)
-{
-	struct rtl8168_private *tp = netdev_priv(dev);
-
-	return rtl_readphy(tp, location);
-}
-
 DECLARE_RTL_COND(rtl_ephyar_cond)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
@@ -2447,15 +2432,15 @@ static void rtl8168_get_mac_version(struct rtl8168_private *tp,
 			     "unknown MAC, using family default\n");
 		tp->mac_version = default_version;
 	} else if (tp->mac_version == RTL_GIGA_MAC_VER_42) {
-		tp->mac_version = tp->mii.supports_gmii ?
+		tp->mac_version = tp->supports_gmii ?
 				  RTL_GIGA_MAC_VER_42 :
 				  RTL_GIGA_MAC_VER_43;
 	} else if (tp->mac_version == RTL_GIGA_MAC_VER_45) {
-		tp->mac_version = tp->mii.supports_gmii ?
+		tp->mac_version = tp->supports_gmii ?
 				  RTL_GIGA_MAC_VER_45 :
 				  RTL_GIGA_MAC_VER_47;
 	} else if (tp->mac_version == RTL_GIGA_MAC_VER_46) {
-		tp->mac_version = tp->mii.supports_gmii ?
+		tp->mac_version = tp->supports_gmii ?
 				  RTL_GIGA_MAC_VER_46 :
 				  RTL_GIGA_MAC_VER_48;
 	}
@@ -7691,7 +7676,7 @@ static int r8168_phy_connect(struct rtl8168_private *tp)
 	phy_interface_t phy_mode;
 	int ret;
 
-	phy_mode = tp->mii.supports_gmii ? PHY_INTERFACE_MODE_GMII :
+	phy_mode = tp->supports_gmii ? PHY_INTERFACE_MODE_GMII :
 		   PHY_INTERFACE_MODE_MII;
 
 	phydev = phy_find_first(tp->mii_bus);
@@ -7705,7 +7690,7 @@ static int r8168_phy_connect(struct rtl8168_private *tp)
 
 	phy_attached_info(phydev);
 
-	if (!tp->mii.supports_gmii && (phydev->supported &
+	if (!tp->supports_gmii && (phydev->supported &
 	    (SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full))) {
 		netif_info(tp, probe, tp->dev, "Restrict PHY to 100Mbit because MAC doesn't support 1GBit");
 		phy_set_max_speed(phydev, SPEED_100);
@@ -7784,7 +7769,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data;
 	const unsigned int region = cfg->region;
 	struct rtl8168_private *tp;
-	struct mii_if_info *mii;
 	struct net_device *dev;
 	void __iomem *ioaddr;
 	int chipset, i;
@@ -7805,14 +7789,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	tp->dev = dev;
 	tp->pci_dev = pdev;
 	tp->msg_enable = netif_msg_init(debug.msg_enable, R8168_MSG_DEFAULT);
-
-	mii = &tp->mii;
-	mii->dev = dev;
-	mii->mdio_read = rtl_mdio_read;
-	mii->mdio_write = rtl_mdio_write;
-	mii->phy_id_mask = 0x1f;
-	mii->reg_num_mask = 0x1f;
-	mii->supports_gmii = !!(cfg->features & RTL_FEATURE_GMII);
+	tp->supports_gmii = !!(cfg->features & RTL_FEATURE_GMII);
 
 	/* disable ASPM completely as that cause random device stop working
 	 * problems as well as full system hangs for some PCIe devices users */
Signature · 1 line
2.15.1
author maintainer
#28 lore raw

RFC PATCH 18/18 r8168: use link speed information as maintained by phylib

In reply to Heiner Kallweit

Let's use the speed information as maintained by phylib instead of reading it directly from a register.

---
 drivers/net/ethernet/realtek/r8168.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)
drivers/net/ethernet/realtek/r8168.c +5 -15
index 765c60bc1..6c57af825 100644
@@ -618,16 +618,6 @@ enum rtl_register_content {
 	INTT_2		= 0x0002,	// 8168
 	INTT_3		= 0x0003,	// 8168
 
-	/* rtl8168_PHYstatus */
-	TBI_Enable	= 0x80,
-	TxFlowCtrl	= 0x40,
-	RxFlowCtrl	= 0x20,
-	_1000bpsF	= 0x10,
-	_100bps		= 0x08,
-	_10bps		= 0x04,
-	LinkStatus	= 0x02,
-	FullDup		= 0x01,
-
 	/* ResetCounterCommand */
 	CounterReset	= 0x1,
 
@@ -1544,20 +1534,20 @@ static void rtl8168_irq_mask_and_ack(struct rtl8168_private *tp)
 
 static void rtl_link_chg_patch(struct rtl8168_private *tp)
 {
-	void __iomem *ioaddr = tp->mmio_addr;
 	struct net_device *dev = tp->dev;
+	struct phy_device *phydev = dev->phydev;
 
 	if (!netif_running(dev))
 		return;
 
 	if (tp->mac_version == RTL_GIGA_MAC_VER_34 ||
 	    tp->mac_version == RTL_GIGA_MAC_VER_38) {
-		if (RTL_R8(PHYstatus) & _1000bpsF) {
+		if (phydev->speed == SPEED_1000) {
 			rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x00000011,
 				      ERIAR_EXGMAC);
 			rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005,
 				      ERIAR_EXGMAC);
-		} else if (RTL_R8(PHYstatus) & _100bps) {
+		} else if (phydev->speed == SPEED_100) {
 			rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x0000001f,
 				      ERIAR_EXGMAC);
 			rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005,
@@ -1575,7 +1565,7 @@ static void rtl_link_chg_patch(struct rtl8168_private *tp)
 			     ERIAR_EXGMAC);
 	} else if (tp->mac_version == RTL_GIGA_MAC_VER_35 ||
 		   tp->mac_version == RTL_GIGA_MAC_VER_36) {
-		if (RTL_R8(PHYstatus) & _1000bpsF) {
+		if (phydev->speed == SPEED_1000) {
 			rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x00000011,
 				      ERIAR_EXGMAC);
 			rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005,
@@ -1587,7 +1577,7 @@ static void rtl_link_chg_patch(struct rtl8168_private *tp)
 				      ERIAR_EXGMAC);
 		}
 	} else if (tp->mac_version == RTL_GIGA_MAC_VER_37) {
-		if (RTL_R8(PHYstatus) & _10bps) {
+		if (phydev->speed == SPEED_10) {
 			rtl_eri_write(tp, 0x1d0, ERIAR_MASK_0011, 0x4d02,
 				      ERIAR_EXGMAC);
 			rtl_eri_write(tp, 0x1dc, ERIAR_MASK_0011, 0x0060,
Signature · 1 line
2.15.1
maintainer
#30 lore raw
In reply to Heiner Kallweit

From: Heiner Kallweit <[email protected]>
Date: Thu, 21 Dec 2017 21:38:11 +0100

Quoted 2 lines

This experimental series separates drivers for PCI / PCIE NIC's and adds initial phylib support to the separated r8168 driver.

Thanks for working on this.

The RX and TX ring handling is basically going to be identical for the two chips, so it's very undesirable to duplicate that code in the two drivers.

Getting good test coverage is going to be extremely challenging for this, so the more code you share between the two drivers rather than duplicate the better.

author maintainer
#31 lore raw

Am 21.12.2017 um 22:16 schrieb David Miller:

Quoted 12 lines

From: Heiner Kallweit <[email protected]>
Date: Thu, 21 Dec 2017 21:38:11 +0100

Quoted 2 lines

This experimental series separates drivers for PCI / PCIE NIC's and adds initial phylib support to the separated r8168 driver.

Thanks for working on this.

The RX and TX ring handling is basically going to be identical for the two chips, so it's very undesirable to duplicate that code in the two drivers.

Agree .. My approach would be:
- remove everything that's not needed from both drivers
- see what's still identical and factor it out into lib(s)

Currently the driver is one source code file with 8.700 LoC. That's way too big anyway IMO and should be splitted.

Quoted 4 lines

Getting good test coverage is going to be extremely challenging for this, so the more code you share between the two drivers rather than duplicate the better.

I'm aware of this (seeing that basically every chip needs certain quirks) and don't expect the patch set to be mainline-ready very soon. I have access to one supported chip only, so I hope others give it a try too.

#9 lore raw

Re: [PATCH RFC 08/18] r8168: add basic phylib support

In reply to Heiner Kallweit

On Thu, Dec 21, 2017 at 09:50:25PM +0100, Heiner Kallweit wrote:

Hi Heiner

This code looks good. Just a few minor comments.

Quoted 16 lines
drivers/net/ethernet/realtek/r8168.c +16 -0
+static int r8168_phy_connect(struct rtl8168_private *tp)
+{
+	struct phy_device *phydev;
+	phy_interface_t phy_mode;
+	int ret;
+
+	phy_mode = tp->mii.supports_gmii ? PHY_INTERFACE_MODE_GMII :
+		   PHY_INTERFACE_MODE_MII;
+
+	phydev = phy_find_first(tp->mii_bus);
+	if (!phydev)
+		return -ENODEV;
+
+	ret = phy_connect_direct(tp->dev, phydev, r8168_phylink_handler,
+				 phy_mode);
+	if (ret)

drivers/net/ethernet/realtek/r8168.c DECLARE_RTL_COND(rtl_rxtx_empty_cond) · line 7969

Quoted 10 lines
drivers/net/ethernet/realtek/r8168.c +10 -0
+		return ret;
+
+	phy_attached_info(phydev);
+
+	if (!tp->mii.supports_gmii && (phydev->supported &
+	    (SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full))) {
+		netif_info(tp, probe, tp->dev, "Restrict PHY to 100Mbit because MAC doesn't support 1GBit");
+		phy_set_max_speed(phydev, SPEED_100);
+		ret = genphy_restart_aneg(phydev);
+	}

You might be able to put this higher up, after phy_first_first, and skip the genphy_restart_aneg(). When phy_start() is called i think it will perform an aneg, so there is no need to do it here.

Quoted 15 lines
drivers/net/ethernet/realtek/r8168.c +5 -1
+
+	return ret;
+}
+
 static void rtl_hw_init_8168g(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
@@ -8212,10 +8284,18 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (!tp->counters)
 		return -ENOMEM;
 
-	rc = register_netdev(dev);
+	rc = r8168_mdio_register(tp);
 	if (rc < 0)
 		return rc;

drivers/net/ethernet/realtek/r8168.c static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · line 8299

Quoted 10 lines
drivers/net/ethernet/realtek/r8168.c +8 -0
 
+	rc = register_netdev(dev);
+	if (rc < 0)
+		goto err_mdio_unregister;
+
+	rc = r8168_phy_connect(tp);
+	if (rc < 0)
+		goto err_netdev_unregister;
+
 	pci_set_drvdata(pdev, dev);

This is the wrong order. Everything should be setup before you call register_netdev(). As soon as that is called, things can start happening with the device, so it is dangerous not to have the phy connected, nor drvdata set. This is an old bug, but now would be a good time to fix it.

Andrew

#11 lore raw

Re: [PATCH RFC 09/18] r8168: use genphy_soft_reset instead of open coding the soft reset

In reply to Heiner Kallweit
Quoted 1 line · Heiner Kallweit

Use genphy_soft_reset instead of open coding the soft reset.

Hi Heiner

At this point, you have swapped over the phylib. Does one of the drivers in drivers/net/phy now take control of the PHY? Does the PHY ID match one of those in realtek.c?

The PHY driver and phylib should be responsible for resetting the PHY. The MAC driver should not need to do this.

Andrew

#18 lore raw

Re: [PATCH RFC 12/18] r8168: switch to phy_mii_ioctl

In reply to Heiner Kallweit

drivers/net/ethernet/realtek/r8168.c static int rtl_set_mac_address(struct net_device *dev, void *p) · line 4322

Quoted 6 lines

static int rtl8168_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) {

drivers/net/ethernet/realtek/r8168.c +2 -2
-	struct rtl8168_private *tp = netdev_priv(dev);
-	struct mii_ioctl_data *data = if_mii(ifr);
+	if (!netif_running(dev))
+		return -ENODEV;

It is sometimes useful to be able to prod and poke the PHY when the MAC is not running. Is this limit because of power saving?

Otherwise, this patch looks good.

Thanks
Andrew

#21 lore raw

Re: [PATCH RFC 13/18] r8168: replace speed_down with genphy_restart_aneg

In reply to Heiner Kallweit
Quoted 44 lines · Heiner Kallweit

Dealing with link partner abilities is handled by phylib, so let's just trigger autonegotiation here.

---
 drivers/net/ethernet/realtek/r8168.c | 26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)
drivers/net/ethernet/realtek/r8168.c +0 -24
index d33f93a31..6b398915f 100644
@@ -4360,30 +4360,6 @@ static void rtl_init_mdio_ops(struct rtl8168_private *tp)
 	}
 }
 
-static void rtl_speed_down(struct rtl8168_private *tp)
-{
-	u32 adv;
-	int lpa;
-
-	rtl_writephy(tp, 0x1f, 0x0000);
-	lpa = rtl_readphy(tp, MII_LPA);
-
-	if (lpa & (LPA_10HALF | LPA_10FULL))
-		adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full;
-	else if (lpa & (LPA_100HALF | LPA_100FULL))
-		adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
-		      ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full;
-	else
-		adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
-		      ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
-		      (tp->mii.supports_gmii ?
-		       ADVERTISED_1000baseT_Half |
-		       ADVERTISED_1000baseT_Full : 0);
-
-	rtl8168_set_speed(tp->dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
-			  adv);
-}
-
 static void rtl_wol_suspend_quirk(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;

drivers/net/ethernet/realtek/r8168.c static bool rtl_wol_pll_power_down(struct rtl8168_private *tp) · line 4406

Quoted 8 lines
drivers/net/ethernet/realtek/r8168.c +1 -1
@@ -4424,7 +4400,7 @@ static bool rtl_wol_pll_power_down(struct rtl8168_private *tp)
 	if (!(__rtl8168_get_wol(tp) & WAKE_ANY))
 		return false;
 
-	rtl_speed_down(tp);
+	genphy_restart_aneg(tp->dev->phydev);
 	rtl_wol_suspend_quirk(tp);
 
 	return true;

I'm not too clear what is going on here? Is this suspend while WOL is enabled? There should be no need to change the PHY settings. The PHY driver should leave the PHY running in whatever state it was configured to. The only danger here is that the MAC driver has called phy_stop() during suspend. That should not be done when WOL is enabled.

Is the wol being passed to the phylib? phy_ethtool_set_wol() and phy_ethtool_get_wol()?

Andrew

#27 lore raw

Re: [PATCH RFC 17/18] r8168: remove use of struct mii_if_info

In reply to Heiner Kallweit
Quoted 8 lines · Heiner Kallweit
drivers/net/ethernet/realtek/r8168.c +0 -4
@@ -1188,21 +1188,6 @@ static void rtl_w0w1_phy(struct rtl8168_private *tp, int reg_addr, int p, int m)
 	rtl_writephy(tp, reg_addr, (val & ~m) | p);
 }
 
-static void rtl_mdio_write(struct net_device *dev, int phy_id, int location,
-			   int val)
-{
-	struct rtl8168_private *tp = netdev_priv(dev);

drivers/net/ethernet/realtek/r8168.c static void rtl_w0w1_phy(struct rtl8168_private *tp, int reg_addr, int p, int m) · line 1204

Quoted 10 lines
drivers/net/ethernet/realtek/r8168.c +0 -10
-
-	rtl_writephy(tp, location, val);
-}
-
-static int rtl_mdio_read(struct net_device *dev, int phy_id, int location)
-{
-	struct rtl8168_private *tp = netdev_priv(dev);
-
-	return rtl_readphy(tp, location);
-}

Hi Heiner

With these two gone, it would be nice to rename r8168_mdio_read_reg() and r8168_mdio_write_reg() to rtl_mdio_read() and rtl_mdio_write().

Andrew

author maintainer
#12 lore raw

Re: [PATCH RFC 09/18] r8168: use genphy_soft_reset instead of open coding the soft reset

In reply to Andrew Lunn

Am 22.12.2017 um 10:57 schrieb Andrew Lunn:

Quoted 12 lines · Heiner Kallweit
Quoted 1 line

Use genphy_soft_reset instead of open coding the soft reset.

Hi Heiner

At this point, you have swapped over the phylib. Does one of the drivers in drivers/net/phy now take control of the PHY? Does the PHY ID match one of those in realtek.c?

The PHY driver and phylib should be responsible for resetting the PHY. The MAC driver should not need to do this.

In my case the PHY ID matches the existing RTL8211E driver in realtek.c and the MAC driver wouldn't have to do any soft reset.

However there may be chips with a PHY ID not yet being supported by realtek.c. AFAICS in such a case phylib uses genphy_driver which has a no-op soft reset.
Therefore I'd tend to say that we can remove the phy soft reset from MAC driver only after being sure that all PHY ID's of supported NIC's have a driver in realtek.c.

Quoted 2 lines

Andrew

Heiner

By the way: Thanks for the review comments.

author maintainer
#19 lore raw

Re: [PATCH RFC 12/18] r8168: switch to phy_mii_ioctl

In reply to Andrew Lunn

Am 22.12.2017 um 11:00 schrieb Andrew Lunn:

Quoted 10 lines

drivers/net/ethernet/realtek/r8168.c static int rtl_set_mac_address(struct net_device *dev, void *p) · line 4322

Quoted 6 lines

static int rtl8168_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) {

drivers/net/ethernet/realtek/r8168.c +2 -2
-	struct rtl8168_private *tp = netdev_priv(dev);
-	struct mii_ioctl_data *data = if_mii(ifr);
+	if (!netif_running(dev))
+		return -ENODEV;

It is sometimes useful to be able to prod and poke the PHY when the MAC is not running. Is this limit because of power saving?

Actually I'm not 100% sure, I just kept the existing logic. When checking other users of phy_mii_ioctl I saw that it is a typical pattern to return an error if the interface is down.

Quoted 5 lines

Otherwise, this patch looks good.

Thanks
Andrew

author maintainer
#22 lore raw

Re: [PATCH RFC 13/18] r8168: replace speed_down with genphy_restart_aneg

In reply to Andrew Lunn

Am 22.12.2017 um 11:14 schrieb Andrew Lunn:

Quoted 61 lines · Heiner Kallweit
Quoted 44 lines

Dealing with link partner abilities is handled by phylib, so let's just trigger autonegotiation here.

---
 drivers/net/ethernet/realtek/r8168.c | 26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)
drivers/net/ethernet/realtek/r8168.c +0 -24
index d33f93a31..6b398915f 100644
@@ -4360,30 +4360,6 @@ static void rtl_init_mdio_ops(struct rtl8168_private *tp)
 	}
 }
 
-static void rtl_speed_down(struct rtl8168_private *tp)
-{
-	u32 adv;
-	int lpa;
-
-	rtl_writephy(tp, 0x1f, 0x0000);
-	lpa = rtl_readphy(tp, MII_LPA);
-
-	if (lpa & (LPA_10HALF | LPA_10FULL))
-		adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full;
-	else if (lpa & (LPA_100HALF | LPA_100FULL))
-		adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
-		      ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full;
-	else
-		adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
-		      ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
-		      (tp->mii.supports_gmii ?
-		       ADVERTISED_1000baseT_Half |
-		       ADVERTISED_1000baseT_Full : 0);
-
-	rtl8168_set_speed(tp->dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
-			  adv);
-}
-
 static void rtl_wol_suspend_quirk(struct rtl8168_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;

drivers/net/ethernet/realtek/r8168.c static bool rtl_wol_pll_power_down(struct rtl8168_private *tp) · line 4406

Quoted 8 lines
drivers/net/ethernet/realtek/r8168.c +1 -1
@@ -4424,7 +4400,7 @@ static bool rtl_wol_pll_power_down(struct rtl8168_private *tp)
 	if (!(__rtl8168_get_wol(tp) & WAKE_ANY))
 		return false;
 
-	rtl_speed_down(tp);
+	genphy_restart_aneg(tp->dev->phydev);
 	rtl_wol_suspend_quirk(tp);
 
 	return true;

I'm not too clear what is going on here? Is this suspend while WOL is enabled? There should be no need to change the PHY settings. The PHY driver should leave the PHY running in whatever state it was configured to. The only danger here is that the MAC driver has called phy_stop() during suspend. That should not be done when WOL is enabled.

Quoted 3 lines

Is the wol being passed to the phylib? phy_ethtool_set_wol() and phy_ethtool_get_wol()?

I also have a hard time to understand what this is good for. Here's the mail thread regarding introduction of this function:
https://lkml.org/lkml/2013/4/2/669

If I understand this correctly it's about fixing an issue when aneg is disabled and the PHY automatically changes the speed.

In this case we may have to use genphy_config_aneg here which calls genphy_setup_forced if aneg is disabled.

Quoted 2 lines

Andrew