1 Commit-Id: 9c14ceafa5ca7f57225a43fb0785c56ddc7f1823
2 From: Francois Romieu <romieu@fr.zoreil.com>
3 Date: Sat, 5 Jul 2008 00:21:15 +0200
4 Acked-by: Karsten Keil <kkeil@novell.com>
6 Subject: [PATCH] r8169: use pci_find_capability for the PCI-E features
8 Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
9 Cc: Edward Hsu <edward_hsu@realtek.com.tw>
12 drivers/net/r8169.c | 32 ++++++++++++++++++++++++--------
13 1 file changed, 24 insertions(+), 8 deletions(-)
15 --- a/drivers/net/r8169.c
16 +++ b/drivers/net/r8169.c
17 @@ -61,6 +61,7 @@ static const int multicast_filter_limit
18 /* MAC address length */
19 #define MAC_ADDR_LEN 6
21 +#define MAX_READ_REQUEST_SHIFT 12
22 #define RX_FIFO_THRESH 7 /* 7 means NO threshold, Rx buffer level before first PCI xfer. */
23 #define RX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */
24 #define TX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */
25 @@ -427,6 +428,7 @@ struct rtl8169_private {
26 void (*hw_start)(struct net_device *);
27 unsigned int (*phy_reset_pending)(void __iomem *);
28 unsigned int (*link_ok)(void __iomem *);
30 struct delayed_work task;
33 @@ -1686,6 +1688,10 @@ rtl8169_init_one(struct pci_dev *pdev, c
34 goto err_out_free_res_4;
37 + tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
38 + if (!tp->pcie_cap && netif_msg_probe(tp))
39 + dev_info(&pdev->dev, "no PCI Express capability\n");
41 RTL_W16(IntrMask, 0x0000);
43 /* Soft reset the chip. */
44 @@ -2078,13 +2084,19 @@ static void rtl_hw_start_8169(struct net
45 RTL_W16(IntrMask, tp->intr_event);
48 -static void rtl_tx_performance_tweak(struct pci_dev *pdev, u8 force)
49 +static void rtl_tx_performance_tweak(struct pci_dev *pdev, u16 force)
52 + struct net_device *dev = pci_get_drvdata(pdev);
53 + struct rtl8169_private *tp = netdev_priv(dev);
54 + int cap = tp->pcie_cap;
59 - pci_read_config_byte(pdev, 0x69, &ctl);
60 - ctl = (ctl & ~0x70) | force;
61 - pci_write_config_byte(pdev, 0x69, ctl);
62 + pci_read_config_word(pdev, cap + PCI_EXP_DEVCTL, &ctl);
63 + ctl = (ctl & ~PCI_EXP_DEVCTL_READRQ) | force;
64 + pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, ctl);
68 static void rtl_hw_start_8168(struct net_device *dev)
69 @@ -2105,7 +2117,7 @@ static void rtl_hw_start_8168(struct net
71 RTL_W16(CPlusCmd, tp->cp_cmd);
73 - rtl_tx_performance_tweak(pdev, 0x50);
74 + rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT);
76 RTL_W16(IntrMitigate, 0x5151);
78 @@ -2138,8 +2150,12 @@ static void rtl_hw_start_8101(struct net
80 if ((tp->mac_version == RTL_GIGA_MAC_VER_13) ||
81 (tp->mac_version == RTL_GIGA_MAC_VER_16)) {
82 - pci_write_config_word(pdev, 0x68, 0x00);
83 - pci_write_config_word(pdev, 0x69, 0x08);
84 + int cap = tp->pcie_cap;
87 + pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL,
88 + PCI_EXP_DEVCTL_NOSNOOP_EN);
92 RTL_W8(Cfg9346, Cfg9346_Unlock);