aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Romieu <romieu@fr.zoreil.com>2007-02-23 17:36:39 -0500
committerJeff Garzik <jeff@garzik.org>2007-07-08 22:16:43 -0400
commit07ce4064677806e330599ade772a914f500e74af (patch)
treef18c54c277c89f54aaf957b34f8fa412b6fd3363
parentb449655ff52ff8a29c66c5fc3fc03617e61182ee (diff)
r8169: add hooks for per-device hw_start handler
Rationale: rtl8169_hw_start will not help maintaining an unified driver for different chipsets but people at Realtek are probably too polite to say it distinctly. Let's add the hook and keep hw_start handler unchanged. As can be seen from the content of rtl8169_pci_tbl, the RTL_CFG_1 entry in rtl_cfg_info was unused. I recycled it for the 0x8168. Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Cc: Edward Hsu <edward_hsu@realtek.com.tw>
-rw-r--r--drivers/net/r8169.c64
1 files changed, 45 insertions, 19 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 4d0cdbaf527e..5e24a0cf4d5f 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -199,20 +199,25 @@ enum cfg_version {
199 RTL_CFG_2 199 RTL_CFG_2
200}; 200};
201 201
202static void rtl_hw_start_8169(struct net_device *);
203static void rtl_hw_start_8168(struct net_device *);
204static void rtl_hw_start_8101(struct net_device *);
205
202static const struct { 206static const struct {
207 void (*hw_start)(struct net_device *);
203 unsigned int region; 208 unsigned int region;
204 unsigned int align; 209 unsigned int align;
205} rtl_cfg_info[] = { 210} rtl_cfg_info[] = {
206 [RTL_CFG_0] = { 1, NET_IP_ALIGN }, 211 [RTL_CFG_0] = { rtl_hw_start_8169, 1, NET_IP_ALIGN },
207 [RTL_CFG_1] = { 2, NET_IP_ALIGN }, 212 [RTL_CFG_1] = { rtl_hw_start_8168, 2, 8 },
208 [RTL_CFG_2] = { 2, 8 } 213 [RTL_CFG_2] = { rtl_hw_start_8101, 2, 8 }
209}; 214};
210 215
211static struct pci_device_id rtl8169_pci_tbl[] = { 216static struct pci_device_id rtl8169_pci_tbl[] = {
212 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 }, 217 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 },
213 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 }, 218 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 },
214 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 }, 219 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 },
215 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_2 }, 220 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_1 },
216 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 }, 221 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 },
217 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), 0, 0, RTL_CFG_0 }, 222 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), 0, 0, RTL_CFG_0 },
218 { PCI_DEVICE(0x1259, 0xc107), 0, 0, RTL_CFG_0 }, 223 { PCI_DEVICE(0x1259, 0xc107), 0, 0, RTL_CFG_0 },
@@ -455,6 +460,7 @@ struct rtl8169_private {
455 int (*set_speed)(struct net_device *, u8 autoneg, u16 speed, u8 duplex); 460 int (*set_speed)(struct net_device *, u8 autoneg, u16 speed, u8 duplex);
456 void (*get_settings)(struct net_device *, struct ethtool_cmd *); 461 void (*get_settings)(struct net_device *, struct ethtool_cmd *);
457 void (*phy_reset_enable)(void __iomem *); 462 void (*phy_reset_enable)(void __iomem *);
463 void (*hw_start)(struct net_device *);
458 unsigned int (*phy_reset_pending)(void __iomem *); 464 unsigned int (*phy_reset_pending)(void __iomem *);
459 unsigned int (*link_ok)(void __iomem *); 465 unsigned int (*link_ok)(void __iomem *);
460 struct delayed_work task; 466 struct delayed_work task;
@@ -478,9 +484,9 @@ static int rtl8169_open(struct net_device *dev);
478static int rtl8169_start_xmit(struct sk_buff *skb, struct net_device *dev); 484static int rtl8169_start_xmit(struct sk_buff *skb, struct net_device *dev);
479static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance); 485static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance);
480static int rtl8169_init_ring(struct net_device *dev); 486static int rtl8169_init_ring(struct net_device *dev);
481static void rtl8169_hw_start(struct net_device *dev); 487static void rtl_hw_start(struct net_device *dev);
482static int rtl8169_close(struct net_device *dev); 488static int rtl8169_close(struct net_device *dev);
483static void rtl8169_set_rx_mode(struct net_device *dev); 489static void rtl_set_rx_mode(struct net_device *dev);
484static void rtl8169_tx_timeout(struct net_device *dev); 490static void rtl8169_tx_timeout(struct net_device *dev);
485static struct net_device_stats *rtl8169_get_stats(struct net_device *dev); 491static struct net_device_stats *rtl8169_get_stats(struct net_device *dev);
486static int rtl8169_rx_interrupt(struct net_device *, struct rtl8169_private *, 492static int rtl8169_rx_interrupt(struct net_device *, struct rtl8169_private *,
@@ -1647,7 +1653,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1647 SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops); 1653 SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops);
1648 dev->stop = rtl8169_close; 1654 dev->stop = rtl8169_close;
1649 dev->tx_timeout = rtl8169_tx_timeout; 1655 dev->tx_timeout = rtl8169_tx_timeout;
1650 dev->set_multicast_list = rtl8169_set_rx_mode; 1656 dev->set_multicast_list = rtl_set_rx_mode;
1651 dev->watchdog_timeo = RTL8169_TX_TIMEOUT; 1657 dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
1652 dev->irq = pdev->irq; 1658 dev->irq = pdev->irq;
1653 dev->base_addr = (unsigned long) ioaddr; 1659 dev->base_addr = (unsigned long) ioaddr;
@@ -1676,6 +1682,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1676 tp->timer.data = (unsigned long) dev; 1682 tp->timer.data = (unsigned long) dev;
1677 tp->timer.function = rtl8169_phy_timer; 1683 tp->timer.function = rtl8169_phy_timer;
1678 1684
1685 tp->hw_start = rtl_cfg_info[ent->driver_data].hw_start;
1686
1679 spin_lock_init(&tp->lock); 1687 spin_lock_init(&tp->lock);
1680 1688
1681 rc = register_netdev(dev); 1689 rc = register_netdev(dev);
@@ -1774,7 +1782,7 @@ static int rtl8169_open(struct net_device *dev)
1774 if (retval < 0) 1782 if (retval < 0)
1775 goto err_release_ring_2; 1783 goto err_release_ring_2;
1776 1784
1777 rtl8169_hw_start(dev); 1785 rtl_hw_start(dev);
1778 1786
1779 rtl8169_request_timer(dev); 1787 rtl8169_request_timer(dev);
1780 1788
@@ -1818,12 +1826,10 @@ static void rtl8169_set_rx_tx_config_registers(struct rtl8169_private *tp)
1818 (InterFrameGap << TxInterFrameGapShift)); 1826 (InterFrameGap << TxInterFrameGapShift));
1819} 1827}
1820 1828
1821static void rtl8169_hw_start(struct net_device *dev) 1829static void rtl_hw_start(struct net_device *dev)
1822{ 1830{
1823 struct rtl8169_private *tp = netdev_priv(dev); 1831 struct rtl8169_private *tp = netdev_priv(dev);
1824 void __iomem *ioaddr = tp->mmio_addr; 1832 void __iomem *ioaddr = tp->mmio_addr;
1825 struct pci_dev *pdev = tp->pci_dev;
1826 u16 cmd;
1827 u32 i; 1833 u32 i;
1828 1834
1829 /* Soft reset the chip. */ 1835 /* Soft reset the chip. */
@@ -1836,6 +1842,22 @@ static void rtl8169_hw_start(struct net_device *dev)
1836 msleep_interruptible(1); 1842 msleep_interruptible(1);
1837 } 1843 }
1838 1844
1845 tp->hw_start(dev);
1846
1847 /* Enable all known interrupts by setting the interrupt mask. */
1848 RTL_W16(IntrMask, rtl8169_intr_mask);
1849
1850 netif_start_queue(dev);
1851}
1852
1853
1854static void rtl_hw_start_8169(struct net_device *dev)
1855{
1856 struct rtl8169_private *tp = netdev_priv(dev);
1857 void __iomem *ioaddr = tp->mmio_addr;
1858 struct pci_dev *pdev = tp->pci_dev;
1859 u16 cmd;
1860
1839 if (tp->mac_version == RTL_GIGA_MAC_VER_05) { 1861 if (tp->mac_version == RTL_GIGA_MAC_VER_05) {
1840 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) | PCIMulRW); 1862 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) | PCIMulRW);
1841 pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x08); 1863 pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x08);
@@ -1922,15 +1944,20 @@ static void rtl8169_hw_start(struct net_device *dev)
1922 1944
1923 RTL_W32(RxMissed, 0); 1945 RTL_W32(RxMissed, 0);
1924 1946
1925 rtl8169_set_rx_mode(dev); 1947 rtl_set_rx_mode(dev);
1926 1948
1927 /* no early-rx interrupts */ 1949 /* no early-rx interrupts */
1928 RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000); 1950 RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000);
1951}
1929 1952
1930 /* Enable all known interrupts by setting the interrupt mask. */ 1953static void rtl_hw_start_8168(struct net_device *dev)
1931 RTL_W16(IntrMask, rtl8169_intr_mask); 1954{
1955 rtl_hw_start_8169(dev);
1956}
1932 1957
1933 netif_start_queue(dev); 1958static void rtl_hw_start_8101(struct net_device *dev)
1959{
1960 rtl_hw_start_8169(dev);
1934} 1961}
1935 1962
1936static int rtl8169_change_mtu(struct net_device *dev, int new_mtu) 1963static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
@@ -1956,7 +1983,7 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
1956 1983
1957 netif_poll_enable(dev); 1984 netif_poll_enable(dev);
1958 1985
1959 rtl8169_hw_start(dev); 1986 rtl_hw_start(dev);
1960 1987
1961 rtl8169_request_timer(dev); 1988 rtl8169_request_timer(dev);
1962 1989
@@ -2201,7 +2228,7 @@ static void rtl8169_reset_task(struct work_struct *work)
2201 2228
2202 if (tp->dirty_rx == tp->cur_rx) { 2229 if (tp->dirty_rx == tp->cur_rx) {
2203 rtl8169_init_ring_indexes(tp); 2230 rtl8169_init_ring_indexes(tp);
2204 rtl8169_hw_start(dev); 2231 rtl_hw_start(dev);
2205 netif_wake_queue(dev); 2232 netif_wake_queue(dev);
2206 } else { 2233 } else {
2207 if (net_ratelimit()) { 2234 if (net_ratelimit()) {
@@ -2792,8 +2819,7 @@ static int rtl8169_close(struct net_device *dev)
2792 return 0; 2819 return 0;
2793} 2820}
2794 2821
2795static void 2822static void rtl_set_rx_mode(struct net_device *dev)
2796rtl8169_set_rx_mode(struct net_device *dev)
2797{ 2823{
2798 struct rtl8169_private *tp = netdev_priv(dev); 2824 struct rtl8169_private *tp = netdev_priv(dev);
2799 void __iomem *ioaddr = tp->mmio_addr; 2825 void __iomem *ioaddr = tp->mmio_addr;