diff options
author | hayeswang <hayeswang@realtek.com> | 2014-09-15 23:40:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-16 15:55:53 -0400 |
commit | 929a031dfd62aae34bf8e728f712e6751e416d1f (patch) | |
tree | 8a16cb912fb040552d3f3bd1f5b226be14723acb /drivers/net/ethernet/realtek/r8169.c | |
parent | 95cd6f488d164de462a8279e802a0ad05c33d167 (diff) |
r8169: adjust __rtl8169_set_features
Remove the "changed" test in __rtl8169_set_features(). Instead, do
simple test in rtl8169_set_features().
Set the RxChkSum and RxVlan through __rtl8169_set_features() in
rtl_open().
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/realtek/r8169.c')
-rw-r--r-- | drivers/net/ethernet/realtek/r8169.c | 74 |
1 files changed, 34 insertions, 40 deletions
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 7a7860a17f69..ef2cee5de62b 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c | |||
@@ -1783,33 +1783,31 @@ static void __rtl8169_set_features(struct net_device *dev, | |||
1783 | netdev_features_t features) | 1783 | netdev_features_t features) |
1784 | { | 1784 | { |
1785 | struct rtl8169_private *tp = netdev_priv(dev); | 1785 | struct rtl8169_private *tp = netdev_priv(dev); |
1786 | netdev_features_t changed = features ^ dev->features; | ||
1787 | void __iomem *ioaddr = tp->mmio_addr; | 1786 | void __iomem *ioaddr = tp->mmio_addr; |
1787 | u32 rx_config; | ||
1788 | 1788 | ||
1789 | if (!(changed & (NETIF_F_RXALL | NETIF_F_RXCSUM | | 1789 | rx_config = RTL_R32(RxConfig); |
1790 | NETIF_F_HW_VLAN_CTAG_RX))) | 1790 | if (features & NETIF_F_RXALL) |
1791 | return; | 1791 | rx_config |= (AcceptErr | AcceptRunt); |
1792 | else | ||
1793 | rx_config &= ~(AcceptErr | AcceptRunt); | ||
1792 | 1794 | ||
1793 | if (changed & (NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX)) { | 1795 | RTL_W32(RxConfig, rx_config); |
1794 | if (features & NETIF_F_RXCSUM) | ||
1795 | tp->cp_cmd |= RxChkSum; | ||
1796 | else | ||
1797 | tp->cp_cmd &= ~RxChkSum; | ||
1798 | 1796 | ||
1799 | if (features & NETIF_F_HW_VLAN_CTAG_RX) | 1797 | if (features & NETIF_F_RXCSUM) |
1800 | tp->cp_cmd |= RxVlan; | 1798 | tp->cp_cmd |= RxChkSum; |
1801 | else | 1799 | else |
1802 | tp->cp_cmd &= ~RxVlan; | 1800 | tp->cp_cmd &= ~RxChkSum; |
1803 | 1801 | ||
1804 | RTL_W16(CPlusCmd, tp->cp_cmd); | 1802 | if (features & NETIF_F_HW_VLAN_CTAG_RX) |
1805 | RTL_R16(CPlusCmd); | 1803 | tp->cp_cmd |= RxVlan; |
1806 | } | 1804 | else |
1807 | if (changed & NETIF_F_RXALL) { | 1805 | tp->cp_cmd &= ~RxVlan; |
1808 | int tmp = (RTL_R32(RxConfig) & ~(AcceptErr | AcceptRunt)); | 1806 | |
1809 | if (features & NETIF_F_RXALL) | 1807 | tp->cp_cmd |= RTL_R16(CPlusCmd) & ~(RxVlan | RxChkSum); |
1810 | tmp |= (AcceptErr | AcceptRunt); | 1808 | |
1811 | RTL_W32(RxConfig, tmp); | 1809 | RTL_W16(CPlusCmd, tp->cp_cmd); |
1812 | } | 1810 | RTL_R16(CPlusCmd); |
1813 | } | 1811 | } |
1814 | 1812 | ||
1815 | static int rtl8169_set_features(struct net_device *dev, | 1813 | static int rtl8169_set_features(struct net_device *dev, |
@@ -1817,8 +1815,11 @@ static int rtl8169_set_features(struct net_device *dev, | |||
1817 | { | 1815 | { |
1818 | struct rtl8169_private *tp = netdev_priv(dev); | 1816 | struct rtl8169_private *tp = netdev_priv(dev); |
1819 | 1817 | ||
1818 | features &= NETIF_F_RXALL | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX; | ||
1819 | |||
1820 | rtl_lock_work(tp); | 1820 | rtl_lock_work(tp); |
1821 | __rtl8169_set_features(dev, features); | 1821 | if (features ^ dev->features); |
1822 | __rtl8169_set_features(dev, features); | ||
1822 | rtl_unlock_work(tp); | 1823 | rtl_unlock_work(tp); |
1823 | 1824 | ||
1824 | return 0; | 1825 | return 0; |
@@ -6707,12 +6708,7 @@ static int rtl_open(struct net_device *dev) | |||
6707 | 6708 | ||
6708 | rtl8169_init_phy(dev, tp); | 6709 | rtl8169_init_phy(dev, tp); |
6709 | 6710 | ||
6710 | if (dev->features & NETIF_F_HW_VLAN_CTAG_RX) | 6711 | __rtl8169_set_features(dev, dev->features); |
6711 | tp->cp_cmd |= RxVlan; | ||
6712 | else | ||
6713 | tp->cp_cmd &= ~RxVlan; | ||
6714 | |||
6715 | RTL_W16(CPlusCmd, tp->cp_cmd); | ||
6716 | 6712 | ||
6717 | rtl_pll_power_up(tp); | 6713 | rtl_pll_power_up(tp); |
6718 | 6714 | ||
@@ -7123,8 +7119,7 @@ static void rtl_hw_initialize(struct rtl8169_private *tp) | |||
7123 | } | 7119 | } |
7124 | } | 7120 | } |
7125 | 7121 | ||
7126 | static int | 7122 | static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
7127 | rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | ||
7128 | { | 7123 | { |
7129 | const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data; | 7124 | const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data; |
7130 | const unsigned int region = cfg->region; | 7125 | const unsigned int region = cfg->region; |
@@ -7199,7 +7194,7 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
7199 | goto err_out_mwi_2; | 7194 | goto err_out_mwi_2; |
7200 | } | 7195 | } |
7201 | 7196 | ||
7202 | tp->cp_cmd = RxChkSum; | 7197 | tp->cp_cmd = 0; |
7203 | 7198 | ||
7204 | if ((sizeof(dma_addr_t) > 4) && | 7199 | if ((sizeof(dma_addr_t) > 4) && |
7205 | !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && use_dac) { | 7200 | !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && use_dac) { |
@@ -7240,13 +7235,6 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
7240 | 7235 | ||
7241 | pci_set_master(pdev); | 7236 | pci_set_master(pdev); |
7242 | 7237 | ||
7243 | /* | ||
7244 | * Pretend we are using VLANs; This bypasses a nasty bug where | ||
7245 | * Interrupts stop flowing on high load on 8110SCd controllers. | ||
7246 | */ | ||
7247 | if (tp->mac_version == RTL_GIGA_MAC_VER_05) | ||
7248 | tp->cp_cmd |= RxVlan; | ||
7249 | |||
7250 | rtl_init_mdio_ops(tp); | 7238 | rtl_init_mdio_ops(tp); |
7251 | rtl_init_pll_power_ops(tp); | 7239 | rtl_init_pll_power_ops(tp); |
7252 | rtl_init_jumbo_ops(tp); | 7240 | rtl_init_jumbo_ops(tp); |
@@ -7307,8 +7295,14 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
7307 | dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | | 7295 | dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | |
7308 | NETIF_F_HIGHDMA; | 7296 | NETIF_F_HIGHDMA; |
7309 | 7297 | ||
7298 | tp->cp_cmd |= RxChkSum | RxVlan; | ||
7299 | |||
7300 | /* | ||
7301 | * Pretend we are using VLANs; This bypasses a nasty bug where | ||
7302 | * Interrupts stop flowing on high load on 8110SCd controllers. | ||
7303 | */ | ||
7310 | if (tp->mac_version == RTL_GIGA_MAC_VER_05) | 7304 | if (tp->mac_version == RTL_GIGA_MAC_VER_05) |
7311 | /* 8110SCd requires hardware Rx VLAN - disallow toggling */ | 7305 | /* Disallow toggling */ |
7312 | dev->hw_features &= ~NETIF_F_HW_VLAN_CTAG_RX; | 7306 | dev->hw_features &= ~NETIF_F_HW_VLAN_CTAG_RX; |
7313 | 7307 | ||
7314 | if (tp->txd_version == RTL_TD_0) | 7308 | if (tp->txd_version == RTL_TD_0) |