Skip to content

Commit 929a031

Browse files
hayesorzdavem330
authored andcommitted
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>
1 parent 95cd6f4 commit 929a031

File tree

1 file changed

+34
-40
lines changed
  • drivers/net/ethernet/realtek

1 file changed

+34
-40
lines changed

drivers/net/ethernet/realtek/r8169.c

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,42 +1783,43 @@ static void __rtl8169_set_features(struct net_device *dev,
17831783
netdev_features_t features)
17841784
{
17851785
struct rtl8169_private *tp = netdev_priv(dev);
1786-
netdev_features_t changed = features ^ dev->features;
17871786
void __iomem *ioaddr = tp->mmio_addr;
1787+
u32 rx_config;
17881788

1789-
if (!(changed & (NETIF_F_RXALL | NETIF_F_RXCSUM |
1790-
NETIF_F_HW_VLAN_CTAG_RX)))
1791-
return;
1789+
rx_config = RTL_R32(RxConfig);
1790+
if (features & NETIF_F_RXALL)
1791+
rx_config |= (AcceptErr | AcceptRunt);
1792+
else
1793+
rx_config &= ~(AcceptErr | AcceptRunt);
17921794

1793-
if (changed & (NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX)) {
1794-
if (features & NETIF_F_RXCSUM)
1795-
tp->cp_cmd |= RxChkSum;
1796-
else
1797-
tp->cp_cmd &= ~RxChkSum;
1795+
RTL_W32(RxConfig, rx_config);
17981796

1799-
if (features & NETIF_F_HW_VLAN_CTAG_RX)
1800-
tp->cp_cmd |= RxVlan;
1801-
else
1802-
tp->cp_cmd &= ~RxVlan;
1797+
if (features & NETIF_F_RXCSUM)
1798+
tp->cp_cmd |= RxChkSum;
1799+
else
1800+
tp->cp_cmd &= ~RxChkSum;
18031801

1804-
RTL_W16(CPlusCmd, tp->cp_cmd);
1805-
RTL_R16(CPlusCmd);
1806-
}
1807-
if (changed & NETIF_F_RXALL) {
1808-
int tmp = (RTL_R32(RxConfig) & ~(AcceptErr | AcceptRunt));
1809-
if (features & NETIF_F_RXALL)
1810-
tmp |= (AcceptErr | AcceptRunt);
1811-
RTL_W32(RxConfig, tmp);
1812-
}
1802+
if (features & NETIF_F_HW_VLAN_CTAG_RX)
1803+
tp->cp_cmd |= RxVlan;
1804+
else
1805+
tp->cp_cmd &= ~RxVlan;
1806+
1807+
tp->cp_cmd |= RTL_R16(CPlusCmd) & ~(RxVlan | RxChkSum);
1808+
1809+
RTL_W16(CPlusCmd, tp->cp_cmd);
1810+
RTL_R16(CPlusCmd);
18131811
}
18141812

18151813
static int rtl8169_set_features(struct net_device *dev,
18161814
netdev_features_t features)
18171815
{
18181816
struct rtl8169_private *tp = netdev_priv(dev);
18191817

1818+
features &= NETIF_F_RXALL | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX;
1819+
18201820
rtl_lock_work(tp);
1821-
__rtl8169_set_features(dev, features);
1821+
if (features ^ dev->features);
1822+
__rtl8169_set_features(dev, features);
18221823
rtl_unlock_work(tp);
18231824

18241825
return 0;
@@ -6707,12 +6708,7 @@ static int rtl_open(struct net_device *dev)
67076708

67086709
rtl8169_init_phy(dev, tp);
67096710

6710-
if (dev->features & NETIF_F_HW_VLAN_CTAG_RX)
6711-
tp->cp_cmd |= RxVlan;
6712-
else
6713-
tp->cp_cmd &= ~RxVlan;
6714-
6715-
RTL_W16(CPlusCmd, tp->cp_cmd);
6711+
__rtl8169_set_features(dev, dev->features);
67166712

67176713
rtl_pll_power_up(tp);
67186714

@@ -7123,8 +7119,7 @@ static void rtl_hw_initialize(struct rtl8169_private *tp)
71237119
}
71247120
}
71257121

7126-
static int
7127-
rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
7122+
static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
71287123
{
71297124
const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data;
71307125
const unsigned int region = cfg->region;
@@ -7199,7 +7194,7 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
71997194
goto err_out_mwi_2;
72007195
}
72017196

7202-
tp->cp_cmd = RxChkSum;
7197+
tp->cp_cmd = 0;
72037198

72047199
if ((sizeof(dma_addr_t) > 4) &&
72057200
!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)
72407235

72417236
pci_set_master(pdev);
72427237

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-
72507238
rtl_init_mdio_ops(tp);
72517239
rtl_init_pll_power_ops(tp);
72527240
rtl_init_jumbo_ops(tp);
@@ -7307,8 +7295,14 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
73077295
dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO |
73087296
NETIF_F_HIGHDMA;
73097297

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+
*/
73107304
if (tp->mac_version == RTL_GIGA_MAC_VER_05)
7311-
/* 8110SCd requires hardware Rx VLAN - disallow toggling */
7305+
/* Disallow toggling */
73127306
dev->hw_features &= ~NETIF_F_HW_VLAN_CTAG_RX;
73137307

73147308
if (tp->txd_version == RTL_TD_0)

0 commit comments

Comments
 (0)