Skip to contentSkip to conversation

r8169:update hardware parameter

PATCH Superseded Chunhao Lin 3 participants 15 messages Jan 7, 2015 – Jan 9, 2015

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover r8169:update hardware parameter

These series of patch include the ephy update of following adapters. rtl8411
rtl8168f
rtl8168evl
rtl8168dp
rtl8105
rtl8402

Jumbo frame patch update of following adapters.
rtl8168dp
rtl8168e
rtl8168evl

Also remove unnecessary function rtl_hw_start_8168dp. And add function rtl_hw_start_8168f_2 to set rtl8168f rev.b ephy paramerers.

Chunhao Lin (11):
r8169:change rtl8168dp jumbo frame patch r8169:update rtl8168e and rtl8168evl jumbo frame patch r8169:change the way of setting rtl8168dp ephy parameters. r8169:update rtl8168dp pcie ephy parameter r8169:remove function rtl_hw_start_8168dp r8169:update rtl8168evl pcie ephy parameter r8169:update rtl8168f pcie ephy parameter r8169:update rtl8411 pcie ephy parameter r8169:update rtl8105e pcie ephy parameter r8169:update rtl8402 pcie ephy parameter r8169:update rtl8168f rev.b pcie ephy parameter

 drivers/net/ethernet/realtek/r8169.c | 112 +++++++++++++++--------------------
 1 file changed, 49 insertions(+), 63 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/11 r8169:change rtl8168dp jumbo frame patch

For RTL8168DP, its jumbo frame patch is the same as RTL8168DP. So use RTL8168C jumbo frame patch instead and reomve function "r8168dp_hw_jumbo_enable" and "r8168dp_hw_jumbo_disable".

---
 drivers/net/ethernet/realtek/r8169.c | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)
drivers/net/ethernet/realtek/r8169.c +6 -22
index 14a1c5c..2f97476 100644
@@ -4927,20 +4927,6 @@ 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)
-{
-	void __iomem *ioaddr = tp->mmio_addr;
-
-	RTL_W8(Config3, RTL_R8(Config3) | Jumbo_En0);
-}
-
-static void r8168dp_hw_jumbo_disable(struct rtl8169_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)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
@@ -5014,16 +5000,13 @@ static void rtl_init_jumbo_ops(struct rtl8169_private *tp)
 	case RTL_GIGA_MAC_VER_24:
 	case RTL_GIGA_MAC_VER_25:
 	case RTL_GIGA_MAC_VER_26:
-		ops->disable	= r8168c_hw_jumbo_disable;
-		ops->enable	= r8168c_hw_jumbo_enable;
-		break;
 	case RTL_GIGA_MAC_VER_27:
 	case RTL_GIGA_MAC_VER_28:
-		ops->disable	= r8168dp_hw_jumbo_disable;
-		ops->enable	= r8168dp_hw_jumbo_enable;
+	case RTL_GIGA_MAC_VER_31:
+		ops->disable	= r8168c_hw_jumbo_disable;
+		ops->enable	= r8168c_hw_jumbo_enable;
 		break;
-	case RTL_GIGA_MAC_VER_31: /* Wild guess. Needs info from Realtek. */
-	case RTL_GIGA_MAC_VER_32:
+	case RTL_GIGA_MAC_VER_32: /* Wild guess. Needs info from Realtek. */
 	case RTL_GIGA_MAC_VER_33:
 	case RTL_GIGA_MAC_VER_34:
 		ops->disable	= r8168e_hw_jumbo_disable;
@@ -5758,7 +5741,8 @@ static void rtl_hw_start_8168d_4(struct rtl8169_private *tp)
 
 	rtl_csi_access_enable_1(tp);
 
-	rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT);
+	if (tp->dev->mtu <= ETH_DATA_LEN)
+		rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT);
 
 	RTL_W8(MaxTxPacketSize, TxPacketMax);
 
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/11 r8169:update rtl8168e and rtl8168evl jumbo frame patch

In reply to Chunhao Lin

For RTL8168E and RTL8168EVL, these two chips do not need to change pcie max read request size when jumbo frame is enabled.

---
 drivers/net/ethernet/realtek/r8169.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ethernet/realtek/r8169.c +0 -2
index 2f97476..5bfd0b9 100644
@@ -4934,7 +4934,6 @@ static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp)
 	RTL_W8(MaxTxPacketSize, 0x3f);
 	RTL_W8(Config3, RTL_R8(Config3) | Jumbo_En0);
 	RTL_W8(Config4, RTL_R8(Config4) | 0x01);
-	rtl_tx_performance_tweak(tp->pci_dev, 0x2 << MAX_READ_REQUEST_SHIFT);
 }
 
 static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp)
@@ -4944,7 +4943,6 @@ static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp)
 	RTL_W8(MaxTxPacketSize, 0x0c);
 	RTL_W8(Config3, RTL_R8(Config3) & ~Jumbo_En0);
 	RTL_W8(Config4, RTL_R8(Config4) & ~0x01);
-	rtl_tx_performance_tweak(tp->pci_dev, 0x5 << MAX_READ_REQUEST_SHIFT);
 }
 
 static void r8168b_0_hw_jumbo_enable(struct rtl8169_private *tp)
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/11 r8169:change the way of setting rtl8168dp ephy parameters.

In reply to Chunhao Lin

The original way is wrong. I correct it in this patch.

---
 drivers/net/ethernet/realtek/r8169.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/net/ethernet/realtek/r8169.c +4 -11
index 5bfd0b9..0fc7e62 100644
@@ -5731,11 +5731,10 @@ static void rtl_hw_start_8168d_4(struct rtl8169_private *tp)
 	void __iomem *ioaddr = tp->mmio_addr;
 	struct pci_dev *pdev = tp->pci_dev;
 	static const struct ephy_info e_info_8168d_4[] = {
-		{ 0x0b, ~0,	0x48 },
-		{ 0x19, 0x20,	0x50 },
-		{ 0x0c, ~0,	0x20 }
+		{ 0x0b, 0x0000,	0x0048 },
+		{ 0x19, 0x0020,	0x0050 },
+		{ 0x0c, 0x0100,	0x0020 }
 	};
-	int i;
 
 	rtl_csi_access_enable_1(tp);
 
@@ -5744,13 +5743,7 @@ static void rtl_hw_start_8168d_4(struct rtl8169_private *tp)
 
 	RTL_W8(MaxTxPacketSize, TxPacketMax);
 
-	for (i = 0; i < ARRAY_SIZE(e_info_8168d_4); i++) {
-		const struct ephy_info *e = e_info_8168d_4 + i;
-		u16 w;
-
-		w = rtl_ephy_read(tp, e->offset);
-		rtl_ephy_write(tp, 0x03, (w & e->mask) | e->bits);
-	}
+	rtl_ephy_init(tp, e_info_8168d_4, ARRAY_SIZE(e_info_8168d_4));
 
 	rtl_enable_clock_request(pdev);
 }
Signature · 1 line
1.9.1
#4 lore raw

PATCH 4/11 r8169:update rtl8168dp pcie ephy parameter

In reply to Chunhao Lin

Add following ephy parameter. This parameter will save more power when in ASPM mode.
{ 0x10, 0x0004, 0x0000 }

---
 drivers/net/ethernet/realtek/r8169.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169.c +2 -1
index 0fc7e62..15a0f5b 100644
@@ -5733,7 +5733,8 @@ static void rtl_hw_start_8168d_4(struct rtl8169_private *tp)
 	static const struct ephy_info e_info_8168d_4[] = {
 		{ 0x0b, 0x0000,	0x0048 },
 		{ 0x19, 0x0020,	0x0050 },
-		{ 0x0c, 0x0100,	0x0020 }
+		{ 0x0c, 0x0100,	0x0020 },
+		{ 0x10, 0x0004,	0x0000 }
 	};
 
 	rtl_csi_access_enable_1(tp);
Signature · 1 line
1.9.1
#5 lore raw

PATCH 5/11 r8169:remove function rtl_hw_start_8168dp

In reply to Chunhao Lin

RTL_GIGA_MAC_VER_31 is RTL8168DP and it use the same ephy parameter as RTL_GIGA_MAC_VER_28. So I use function rtl_hw_start_8168d_4 to set RTL_GIGA_MAC_VER_31 ephy parameter and remove unnecessary function rtl_hw_start_8168dp.

---
 drivers/net/ethernet/realtek/r8169.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)
drivers/net/ethernet/realtek/r8169.c +1 -19
index 15a0f5b..48d1f78 100644
@@ -5711,21 +5711,6 @@ 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)
-{
-	void __iomem *ioaddr = tp->mmio_addr;
-	struct pci_dev *pdev = tp->pci_dev;
-
-	rtl_csi_access_enable_1(tp);
-
-	if (tp->dev->mtu <= ETH_DATA_LEN)
-		rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT);
-
-	RTL_W8(MaxTxPacketSize, TxPacketMax);
-
-	rtl_disable_clock_request(pdev);
-}
-
 static void rtl_hw_start_8168d_4(struct rtl8169_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
@@ -6272,11 +6257,8 @@ static void rtl_hw_start_8168(struct net_device *dev)
 		break;
 
 	case RTL_GIGA_MAC_VER_28:
-		rtl_hw_start_8168d_4(tp);
-		break;
-
 	case RTL_GIGA_MAC_VER_31:
-		rtl_hw_start_8168dp(tp);
+		rtl_hw_start_8168d_4(tp);
 		break;
 
 	case RTL_GIGA_MAC_VER_32:
Signature · 1 line
1.9.1
#6 lore raw

PATCH 6/11 r8169:update rtl8168evl pcie ephy parameter

In reply to Chunhao Lin

rtl8168evl may return to PCIe L0 from PCIe L0s low power mode too slow. The following ephy parameters are for this issue.
{ 0x0c, 0x0100, 0x0020 }
{ 0x10, 0x0004, 0x0000 }

---
 drivers/net/ethernet/realtek/r8169.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169.c +3 -1
index 48d1f78..1874583 100644
@@ -5778,7 +5778,9 @@ static void rtl_hw_start_8168e_2(struct rtl8169_private *tp)
 	struct pci_dev *pdev = tp->pci_dev;
 	static const struct ephy_info e_info_8168e_2[] = {
 		{ 0x09, 0x0000,	0x0080 },
-		{ 0x19, 0x0000,	0x0224 }
+		{ 0x19, 0x0000,	0x0224 },
+		{ 0x00, 0x0000,	0x0008 },
+		{ 0x0c, 0x3df0,	0x0200 }
 	};
 
 	rtl_csi_access_enable_1(tp);
Signature · 1 line
1.9.1
#7 lore raw

PATCH 7/11 r8169:update rtl8168f pcie ephy parameter

In reply to Chunhao Lin

rtl8168f may return to PCIe L0 from PCIe L0s low power mode too slow. The following ephy parameters are for this issue.
{ 0x00, 0x0000, 0x0008 }
{ 0x0c, 0x3df0, 0x0200 }

---
 drivers/net/ethernet/realtek/r8169.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169.c +3 -1
index 1874583..bafa132 100644
@@ -5852,7 +5852,9 @@ static void rtl_hw_start_8168f_1(struct rtl8169_private *tp)
 		{ 0x06, 0x00c0,	0x0020 },
 		{ 0x08, 0x0001,	0x0002 },
 		{ 0x09, 0x0000,	0x0080 },
-		{ 0x19, 0x0000,	0x0224 }
+		{ 0x19, 0x0000,	0x0224 },
+		{ 0x00, 0x0000,	0x0008 },
+		{ 0x0c, 0x3df0,	0x0200 }
 	};
 
 	rtl_hw_start_8168f(tp);
Signature · 1 line
1.9.1
#8 lore raw

RE: [PATCH net-next 07/11] r8169:update rtl8168f pcie ephy parameter

From: Chunhao Lin

Quoted 15 lines

rtl8168f may return to PCIe L0 from PCIe L0s low power mode too slow. The following ephy parameters are for this issue.
{ 0x00, 0x0000, 0x0008 }
{ 0x0c, 0x3df0, 0x0200 }

---
 drivers/net/ethernet/realtek/r8169.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169.c +0 -0
index 1874583..bafa132 100644

drivers/net/ethernet/realtek/r8169.c static void rtl_hw_start_8168f_1(struct rtl8169_private *tp) · line 5857

Quoted 7 lines
drivers/net/ethernet/realtek/r8169.c +3 -1
@@ -5852,7 +5852,9 @@ static void rtl_hw_start_8168f_1(struct rtl8169_private *tp)
 		{ 0x06, 0x00c0,	0x0020 },
 		{ 0x08, 0x0001,	0x0002 },
 		{ 0x09, 0x0000,	0x0080 },
-		{ 0x19, 0x0000,	0x0224 }
+		{ 0x19, 0x0000,	0x0224 },
+		{ 0x00, 0x0000,	0x0008 },
+		{ 0x0c, 0x3df0,	0x0200 }

I can't help feeling these lines all require short comments.

David

maintainer
#9 lore raw

Re: [PATCH net-next 07/11] r8169:update rtl8168f pcie ephy parameter

From: David Laight <[email protected]>
Date: Wed, 7 Jan 2015 16:45:58 +0000

Quoted 11 lines

From: Chunhao Lin

drivers/net/ethernet/realtek/r8169.c static void rtl_hw_start_8168f_1(struct rtl8169_private *tp) · line 5857

Quoted 8 lines
drivers/net/ethernet/realtek/r8169.c +3 -1
@@ -5852,7 +5852,9 @@ static void rtl_hw_start_8168f_1(struct rtl8169_private *tp)
 		{ 0x06, 0x00c0,	0x0020 },
 		{ 0x08, 0x0001,	0x0002 },
 		{ 0x09, 0x0000,	0x0080 },
-		{ 0x19, 0x0000,	0x0224 }
+		{ 0x19, 0x0000,	0x0224 },
+		{ 0x00, 0x0000,	0x0008 },
+		{ 0x0c, 0x3df0,	0x0200 }

I can't help feeling these lines all require short comments.

Agreed.

And this goes for some of the other patches that look like this too.

author
#10 lore raw

RE: [PATCH net-next 07/11] r8169:update rtl8168f pcie ephy parameter

Quoted 24 lines

-----Original Message-----
From: David Miller [mailto:[email protected]]
Sent: Friday, January 09, 2015 12:09 PM
To: [email protected]
Cc: Hau; [email protected]; nic_swsd; [email protected]
Subject: Re: [PATCH net-next 07/11] r8169:update rtl8168f pcie ephy parameter

From: David Laight <[email protected]>
Date: Wed, 7 Jan 2015 16:45:58 +0000

Quoted 2 lines

From: Chunhao Lin

Review static void rtl_hw_start_8168f_1(struct

Quoted 1 line
(quoted diff) +0 -0
@@ -5852,7 +5852,9 @@ static void rtl_hw_start_8168f_1(struct

rtl8169_private *tp)

Quoted 9 lines

drivers/net/ethernet/realtek/r8169.c static void rtl_hw_start_8168f_1(struct rtl8169_private *tp) · line 5857

Quoted 7 lines
drivers/net/ethernet/realtek/r8169.c +3 -1
 		{ 0x06, 0x00c0,	0x0020 },
 		{ 0x08, 0x0001,	0x0002 },
 		{ 0x09, 0x0000,	0x0080 },
-		{ 0x19, 0x0000,	0x0224 }
+		{ 0x19, 0x0000,	0x0224 },
+		{ 0x00, 0x0000,	0x0008 },
+		{ 0x0c, 0x3df0,	0x0200 }

I can't help feeling these lines all require short comments.

Quoted 4 lines

Agreed.

And this goes for some of the other patches that look like this too.

I will merge the patches and update again.

Thanks.

------Please consider the environment before printing this e-mail.

#11 lore raw

PATCH 8/11 r8169:update rtl8411 pcie ephy parameter

In reply to Chunhao Lin

rtl8411 may return to PCIe L0 from PCIe L0s low power mode too slow. The following ephy parameters are for this issue.
{ 0x00, 0x0000, 0x0008 }
{ 0x0c, 0x3df0, 0x0200 }

---
 drivers/net/ethernet/realtek/r8169.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/realtek/r8169.c +5 -3
index bafa132..e92eece 100644
@@ -5869,17 +5869,19 @@ static void rtl_hw_start_8168f_1(struct rtl8169_private *tp)
 
 static void rtl_hw_start_8411(struct rtl8169_private *tp)
 {
-	static const struct ephy_info e_info_8168f_1[] = {
+	static const struct ephy_info e_info_8411[] = {
 		{ 0x06, 0x00c0,	0x0020 },
 		{ 0x0f, 0xffff,	0x5200 },
 		{ 0x1e, 0x0000,	0x4000 },
-		{ 0x19, 0x0000,	0x0224 }
+		{ 0x19, 0x0000,	0x0224 },
+		{ 0x00, 0x0000,	0x0008 },
+		{ 0x0c, 0x3df0,	0x0200 }
 	};
 
 	rtl_hw_start_8168f(tp);
 	rtl_pcie_state_l2l3_enable(tp, false);
 
-	rtl_ephy_init(tp, e_info_8168f_1, ARRAY_SIZE(e_info_8168f_1));
+	rtl_ephy_init(tp, e_info_8411, ARRAY_SIZE(e_info_8411));
 
 	rtl_w0w1_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0c00, 0x0000, ERIAR_EXGMAC);
 }
Signature · 1 line
1.9.1
#12 lore raw

PATCH 9/11 r8169:update rtl8105e pcie ephy parameter

In reply to Chunhao Lin

rtl8105e may return to PCIe L0 from PCIe L0s low power mode too slow. The following ephy parameters are for this issue.
{ 0x05, 0, 0x2000 }

---
 drivers/net/ethernet/realtek/r8169.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169.c +2 -1
index e92eece..ce98d2a 100644
@@ -6403,7 +6403,8 @@ static void rtl_hw_start_8105e_1(struct rtl8169_private *tp)
 		{ 0x03,	0, 0x0001 },
 		{ 0x19,	0, 0x0100 },
 		{ 0x19,	0, 0x0004 },
-		{ 0x0a,	0, 0x0020 }
+		{ 0x0a,	0, 0x0020 },
+		{ 0x05,	0, 0x2000 }
 	};
 
 	/* Force LAN exit from ASPM if Rx/Tx are not idle */
Signature · 1 line
1.9.1
#13 lore raw

PATCH 10/11 r8169:update rtl8402 pcie ephy parameter

In reply to Chunhao Lin

Remove following unnecessary ephy parameter.
{ 0x1e, 0, 0x4000 }

---
 drivers/net/ethernet/realtek/r8169.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/realtek/r8169.c +1 -2
index ce98d2a..b8a097c 100644
@@ -6431,8 +6431,7 @@ static void rtl_hw_start_8402(struct rtl8169_private *tp)
 {
 	void __iomem *ioaddr = tp->mmio_addr;
 	static const struct ephy_info e_info_8402[] = {
-		{ 0x19,	0xffff, 0xff64 },
-		{ 0x1e,	0, 0x4000 }
+		{ 0x19,	0xffff, 0xff64 }
 	};
 
 	rtl_csi_access_enable_2(tp);
Signature · 1 line
1.9.1
#14 lore raw

PATCH 11/11 r8169:update rtl8168f rev.b pcie ephy parameter

In reply to Chunhao Lin

RTL8168F rev.B does not have to set following two ephy parameters.
{ 0x06, 0x00c0, 0x0020 }
{ 0x08, 0x0001, 0x0002 }

Add function rtl_hw_start_8168f_2 to set RTL8168F rev.B ephy parameters, instead of using function rtl_hw_start_8168f_1.

---
 drivers/net/ethernet/realtek/r8169.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169.c +23 -1
index b8a097c..d62f8d8 100644
@@ -5867,6 +5867,26 @@ 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_8168f_2(struct rtl8169_private *tp)
+{
+	void __iomem *ioaddr = tp->mmio_addr;
+	static const struct ephy_info e_info_8168f_2[] = {
+		{ 0x09, 0x0000,	0x0080 },
+		{ 0x19, 0x0000,	0x0224 },
+		{ 0x00, 0x0000,	0x0008 },
+		{ 0x0c, 0x3df0,	0x0200 }
+	};
+
+	rtl_hw_start_8168f(tp);
+
+	rtl_ephy_init(tp, e_info_8168f_2, ARRAY_SIZE(e_info_8168f_2));
+
+	rtl_w0w1_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0c00, 0xff00, ERIAR_EXGMAC);
+
+	/* Adjust EEE LED frequency */
+	RTL_W8(EEE_LED, RTL_R8(EEE_LED) & ~0x07);
+}
+
 static void rtl_hw_start_8411(struct rtl8169_private *tp)
 {
 	static const struct ephy_info e_info_8411[] = {
@@ -6276,9 +6296,11 @@ static void rtl_hw_start_8168(struct net_device *dev)
 		break;
 
 	case RTL_GIGA_MAC_VER_35:
-	case RTL_GIGA_MAC_VER_36:
 		rtl_hw_start_8168f_1(tp);
 		break;
+	case RTL_GIGA_MAC_VER_36:
+		rtl_hw_start_8168f_2(tp);
+		break;
 
 	case RTL_GIGA_MAC_VER_38:
 		rtl_hw_start_8411(tp);
Signature · 1 line
1.9.1