Commit 6488f11f authored by David S. Miller's avatar David S. Miller

Merge branch 'r8169-improve-chip-config-handling'

Heiner Kallweit says:

====================
r8169: improve chip config handling

Series includes two improvements for chip configuration handling.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 45c9cbec 10478283
...@@ -388,10 +388,12 @@ enum rtl_register_content { ...@@ -388,10 +388,12 @@ enum rtl_register_content {
/* rx_mode_bits */ /* rx_mode_bits */
AcceptErr = 0x20, AcceptErr = 0x20,
AcceptRunt = 0x10, AcceptRunt = 0x10,
#define RX_CONFIG_ACCEPT_ERR_MASK 0x30
AcceptBroadcast = 0x08, AcceptBroadcast = 0x08,
AcceptMulticast = 0x04, AcceptMulticast = 0x04,
AcceptMyPhys = 0x02, AcceptMyPhys = 0x02,
AcceptAllPhys = 0x01, AcceptAllPhys = 0x01,
#define RX_CONFIG_ACCEPT_OK_MASK 0x0f
#define RX_CONFIG_ACCEPT_MASK 0x3f #define RX_CONFIG_ACCEPT_MASK 0x3f
/* TxConfigBits */ /* TxConfigBits */
...@@ -1497,19 +1499,15 @@ static netdev_features_t rtl8169_fix_features(struct net_device *dev, ...@@ -1497,19 +1499,15 @@ static netdev_features_t rtl8169_fix_features(struct net_device *dev,
return features; return features;
} }
static int rtl8169_set_features(struct net_device *dev, static void rtl_set_rx_config_features(struct rtl8169_private *tp,
netdev_features_t features) netdev_features_t features)
{ {
struct rtl8169_private *tp = netdev_priv(dev); u32 rx_config = RTL_R32(tp, RxConfig);
u32 rx_config;
rtl_lock_work(tp);
rx_config = RTL_R32(tp, RxConfig);
if (features & NETIF_F_RXALL) if (features & NETIF_F_RXALL)
rx_config |= (AcceptErr | AcceptRunt); rx_config |= RX_CONFIG_ACCEPT_ERR_MASK;
else else
rx_config &= ~(AcceptErr | AcceptRunt); rx_config &= ~RX_CONFIG_ACCEPT_ERR_MASK;
if (rtl_is_8125(tp)) { if (rtl_is_8125(tp)) {
if (features & NETIF_F_HW_VLAN_CTAG_RX) if (features & NETIF_F_HW_VLAN_CTAG_RX)
...@@ -1519,6 +1517,16 @@ static int rtl8169_set_features(struct net_device *dev, ...@@ -1519,6 +1517,16 @@ static int rtl8169_set_features(struct net_device *dev,
} }
RTL_W32(tp, RxConfig, rx_config); RTL_W32(tp, RxConfig, rx_config);
}
static int rtl8169_set_features(struct net_device *dev,
netdev_features_t features)
{
struct rtl8169_private *tp = netdev_priv(dev);
rtl_lock_work(tp);
rtl_set_rx_config_features(tp, features);
if (features & NETIF_F_RXCSUM) if (features & NETIF_F_RXCSUM)
tp->cp_cmd |= RxChkSum; tp->cp_cmd |= RxChkSum;
...@@ -2395,8 +2403,6 @@ static void rtl_pll_power_up(struct rtl8169_private *tp) ...@@ -2395,8 +2403,6 @@ static void rtl_pll_power_up(struct rtl8169_private *tp)
static void rtl_init_rxcfg(struct rtl8169_private *tp) static void rtl_init_rxcfg(struct rtl8169_private *tp)
{ {
u32 vlan;
switch (tp->mac_version) { switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_02 ... RTL_GIGA_MAC_VER_06: case RTL_GIGA_MAC_VER_02 ... RTL_GIGA_MAC_VER_06:
case RTL_GIGA_MAC_VER_10 ... RTL_GIGA_MAC_VER_17: case RTL_GIGA_MAC_VER_10 ... RTL_GIGA_MAC_VER_17:
...@@ -2411,9 +2417,7 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp) ...@@ -2411,9 +2417,7 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)
RTL_W32(tp, RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | RX_EARLY_OFF); RTL_W32(tp, RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | RX_EARLY_OFF);
break; break;
case RTL_GIGA_MAC_VER_60 ... RTL_GIGA_MAC_VER_61: case RTL_GIGA_MAC_VER_60 ... RTL_GIGA_MAC_VER_61:
/* VLAN flags are controlled by NETIF_F_HW_VLAN_CTAG_RX */ RTL_W32(tp, RxConfig, RX_FETCH_DFLT_8125 | RX_DMA_BURST);
vlan = RTL_R32(tp, RxConfig) & RX_VLAN_8125;
RTL_W32(tp, RxConfig, vlan | RX_FETCH_DFLT_8125 | RX_DMA_BURST);
break; break;
default: default:
RTL_W32(tp, RxConfig, RX128_INT_EN | RX_DMA_BURST); RTL_W32(tp, RxConfig, RX128_INT_EN | RX_DMA_BURST);
...@@ -2680,14 +2684,11 @@ static void rtl_set_rx_mode(struct net_device *dev) ...@@ -2680,14 +2684,11 @@ static void rtl_set_rx_mode(struct net_device *dev)
} }
} }
if (dev->features & NETIF_F_RXALL)
rx_mode |= (AcceptErr | AcceptRunt);
RTL_W32(tp, MAR0 + 4, mc_filter[1]); RTL_W32(tp, MAR0 + 4, mc_filter[1]);
RTL_W32(tp, MAR0 + 0, mc_filter[0]); RTL_W32(tp, MAR0 + 0, mc_filter[0]);
tmp = RTL_R32(tp, RxConfig); tmp = RTL_R32(tp, RxConfig);
RTL_W32(tp, RxConfig, (tmp & ~RX_CONFIG_ACCEPT_MASK) | rx_mode); RTL_W32(tp, RxConfig, (tmp & ~RX_CONFIG_ACCEPT_OK_MASK) | rx_mode);
} }
DECLARE_RTL_COND(rtl_csiar_cond) DECLARE_RTL_COND(rtl_csiar_cond)
...@@ -3845,7 +3846,6 @@ static void rtl_hw_start(struct rtl8169_private *tp) ...@@ -3845,7 +3846,6 @@ static void rtl_hw_start(struct rtl8169_private *tp)
{ {
rtl_unlock_config_regs(tp); rtl_unlock_config_regs(tp);
tp->cp_cmd &= CPCMD_MASK;
RTL_W16(tp, CPlusCmd, tp->cp_cmd); RTL_W16(tp, CPlusCmd, tp->cp_cmd);
if (tp->mac_version <= RTL_GIGA_MAC_VER_06) if (tp->mac_version <= RTL_GIGA_MAC_VER_06)
...@@ -3867,6 +3867,7 @@ static void rtl_hw_start(struct rtl8169_private *tp) ...@@ -3867,6 +3867,7 @@ static void rtl_hw_start(struct rtl8169_private *tp)
RTL_W8(tp, ChipCmd, CmdTxEnb | CmdRxEnb); RTL_W8(tp, ChipCmd, CmdTxEnb | CmdRxEnb);
rtl_init_rxcfg(tp); rtl_init_rxcfg(tp);
rtl_set_tx_config_registers(tp); rtl_set_tx_config_registers(tp);
rtl_set_rx_config_features(tp, tp->dev->features);
rtl_set_rx_mode(tp->dev); rtl_set_rx_mode(tp->dev);
rtl_irq_enable(tp); rtl_irq_enable(tp);
} }
...@@ -5424,7 +5425,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -5424,7 +5425,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->mac_version = chipset; tp->mac_version = chipset;
tp->cp_cmd = RTL_R16(tp, CPlusCmd); tp->cp_cmd = RTL_R16(tp, CPlusCmd) & CPCMD_MASK;
if (sizeof(dma_addr_t) > 4 && tp->mac_version >= RTL_GIGA_MAC_VER_18 && if (sizeof(dma_addr_t) > 4 && tp->mac_version >= RTL_GIGA_MAC_VER_18 &&
!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) !dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)))
......
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