Commit 9db0ac57 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller

r8169: improve rtl_jumbo_config

Merge enabling and disabling jumbo packets to one function to make
the code a little simpler.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f1f9ca28
...@@ -2472,66 +2472,52 @@ static void r8168b_1_hw_jumbo_disable(struct rtl8169_private *tp) ...@@ -2472,66 +2472,52 @@ static void r8168b_1_hw_jumbo_disable(struct rtl8169_private *tp)
RTL_W8(tp, Config4, RTL_R8(tp, Config4) & ~(1 << 0)); RTL_W8(tp, Config4, RTL_R8(tp, Config4) & ~(1 << 0));
} }
static void rtl_hw_jumbo_enable(struct rtl8169_private *tp) static void rtl_jumbo_config(struct rtl8169_private *tp)
{ {
rtl_unlock_config_regs(tp); bool jumbo = tp->dev->mtu > ETH_DATA_LEN;
switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_12:
case RTL_GIGA_MAC_VER_17:
pcie_set_readrq(tp->pci_dev, 512);
r8168b_1_hw_jumbo_enable(tp);
break;
case RTL_GIGA_MAC_VER_18 ... RTL_GIGA_MAC_VER_26:
pcie_set_readrq(tp->pci_dev, 512);
r8168c_hw_jumbo_enable(tp);
break;
case RTL_GIGA_MAC_VER_27 ... RTL_GIGA_MAC_VER_28:
r8168dp_hw_jumbo_enable(tp);
break;
case RTL_GIGA_MAC_VER_31 ... RTL_GIGA_MAC_VER_33:
pcie_set_readrq(tp->pci_dev, 512);
r8168e_hw_jumbo_enable(tp);
break;
default:
break;
}
rtl_lock_config_regs(tp);
}
static void rtl_hw_jumbo_disable(struct rtl8169_private *tp)
{
rtl_unlock_config_regs(tp); rtl_unlock_config_regs(tp);
switch (tp->mac_version) { switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_12: case RTL_GIGA_MAC_VER_12:
case RTL_GIGA_MAC_VER_17: case RTL_GIGA_MAC_VER_17:
r8168b_1_hw_jumbo_disable(tp); if (jumbo) {
pcie_set_readrq(tp->pci_dev, 512);
r8168b_1_hw_jumbo_enable(tp);
} else {
r8168b_1_hw_jumbo_disable(tp);
}
break; break;
case RTL_GIGA_MAC_VER_18 ... RTL_GIGA_MAC_VER_26: case RTL_GIGA_MAC_VER_18 ... RTL_GIGA_MAC_VER_26:
r8168c_hw_jumbo_disable(tp); if (jumbo) {
pcie_set_readrq(tp->pci_dev, 512);
r8168c_hw_jumbo_enable(tp);
} else {
r8168c_hw_jumbo_disable(tp);
}
break; break;
case RTL_GIGA_MAC_VER_27 ... RTL_GIGA_MAC_VER_28: case RTL_GIGA_MAC_VER_27 ... RTL_GIGA_MAC_VER_28:
r8168dp_hw_jumbo_disable(tp); if (jumbo)
r8168dp_hw_jumbo_enable(tp);
else
r8168dp_hw_jumbo_disable(tp);
break; break;
case RTL_GIGA_MAC_VER_31 ... RTL_GIGA_MAC_VER_33: case RTL_GIGA_MAC_VER_31 ... RTL_GIGA_MAC_VER_33:
r8168e_hw_jumbo_disable(tp); if (jumbo) {
pcie_set_readrq(tp->pci_dev, 512);
r8168e_hw_jumbo_enable(tp);
} else {
r8168e_hw_jumbo_disable(tp);
}
break; break;
default: default:
break; break;
} }
rtl_lock_config_regs(tp); rtl_lock_config_regs(tp);
if (pci_is_pcie(tp->pci_dev) && tp->supports_gmii) if (!jumbo && pci_is_pcie(tp->pci_dev) && tp->supports_gmii)
pcie_set_readrq(tp->pci_dev, 4096); pcie_set_readrq(tp->pci_dev, 4096);
} }
static void rtl_jumbo_config(struct rtl8169_private *tp, int mtu)
{
if (mtu > ETH_DATA_LEN)
rtl_hw_jumbo_enable(tp);
else
rtl_hw_jumbo_disable(tp);
}
DECLARE_RTL_COND(rtl_chipcmd_cond) DECLARE_RTL_COND(rtl_chipcmd_cond)
{ {
return RTL_R8(tp, ChipCmd) & CmdReset; return RTL_R8(tp, ChipCmd) & CmdReset;
...@@ -3875,7 +3861,7 @@ static void rtl_hw_start(struct rtl8169_private *tp) ...@@ -3875,7 +3861,7 @@ static void rtl_hw_start(struct rtl8169_private *tp)
rtl_set_rx_tx_desc_registers(tp); rtl_set_rx_tx_desc_registers(tp);
rtl_lock_config_regs(tp); rtl_lock_config_regs(tp);
rtl_jumbo_config(tp, tp->dev->mtu); rtl_jumbo_config(tp);
/* Initially a 10 us delay. Turned it into a PCI commit. - FR */ /* Initially a 10 us delay. Turned it into a PCI commit. - FR */
rtl_pci_commit(tp); rtl_pci_commit(tp);
...@@ -3891,10 +3877,9 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu) ...@@ -3891,10 +3877,9 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
{ {
struct rtl8169_private *tp = netdev_priv(dev); struct rtl8169_private *tp = netdev_priv(dev);
rtl_jumbo_config(tp, new_mtu);
dev->mtu = new_mtu; dev->mtu = new_mtu;
netdev_update_features(dev); netdev_update_features(dev);
rtl_jumbo_config(tp);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment