r8169: series with improvements
Heiner Kallweit
maintainercover r8169: series with improvements
Again a series with few improvements.
Heiner Kallweit (6):
r8169: move setting OCP base to generic init code
r8169: remove NETIF_F_HIGHDMA from vlan_features
r8169: preserve VLAN setting on RTL8125 in rtl_init_rxcfg
r8169: use rtl8169_set_features in rtl8169_init_one
r8169: improve rtl8169_tso_csum_v2
r8169: add workaround for RTL8168evl TSO hw issues
drivers/net/ethernet/realtek/r8169_main.c | 75 +++++++++++++++-------- 1 file changed, 51 insertions(+), 24 deletions(-)
Signature · 1 line
2.26.1
Heiner Kallweit
maintainerPATCH 1/6 r8169: move setting OCP base to generic init code
Move setting the ocp_base to rtl_init_one(). Where supported the value is always the same, and if not supported it doesn't hurt.
--- drivers/net/ethernet/realtek/r8169_main.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +3 -6
@@ -75,6 +75,8 @@#define R8169_TX_RING_BYTES (NUM_TX_DESC * sizeof(struct TxDesc))#define R8169_RX_RING_BYTES (NUM_RX_DESC * sizeof(struct RxDesc)) +#define OCP_STD_PHY_BASE 0xa400 +#define RTL_CFG_NO_GBIT 1/* write/read MMIO register */
@@ -847,8 +849,6 @@ static void r8168_mac_ocp_modify(struct rtl8169_private *tp, u32 reg, u16 mask,r8168_mac_ocp_write (tp, reg, (data & ~mask) | set); } -#define OCP_STD_PHY_BASE 0xa400 -static void r8168g_mdio_write (struct rtl8169_private *tp,int reg,int value) {if (reg ==0x1f ) {
@@ -5187,8 +5187,6 @@ static int r8169_mdio_register(struct rtl8169_private *tp)static void rtl_hw_init_8168g (struct rtl8169_private *tp) { - tp->ocp_base =OCP_STD_PHY_BASE ; -RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) |RXDV_GATED_EN );if (!rtl_udelay_loop_wait_high (tp, &rtl_txcfg_empty_cond,100 ,42 ))
@@ -5213,8 +5211,6 @@ static void rtl_hw_init_8168g(struct rtl8169_private *tp)static void rtl_hw_init_8125 (struct rtl8169_private *tp) { - tp->ocp_base =OCP_STD_PHY_BASE ; -RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) |RXDV_GATED_EN );if (!rtl_udelay_loop_wait_high (tp, &rtl_rxtx_empty_cond,100 ,42 ))
@@ -5351,6 +5347,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) tp->msg_enable =netif_msg_init (debug.msg_enable,R8169_MSG_DEFAULT ); tp->supports_gmii = ent->driver_data ==RTL_CFG_NO_GBIT ?0 :1 ; tp->eee_adv =-1 ; + tp->ocp_base =OCP_STD_PHY_BASE ;/* Get the *optional* external "ether_clk" used on some boards */ rc =rtl_get_ether_clk (tp);
Signature · 1 line
2.26.1
Heiner Kallweit
maintainerPATCH 2/6 r8169: remove NETIF_F_HIGHDMA from vlan_features
In reply to Heiner KallweitNETIF_F_HIGHDMA is added to vlan_features by register_netdev(), therefore we can omit this here.
--- drivers/net/ethernet/realtek/r8169_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +1 -2
@@ -5438,8 +5438,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) dev->hw_features =NETIF_F_IP_CSUM |NETIF_F_RXCSUM |NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_CTAG_RX ; - dev->vlan_features =NETIF_F_SG |NETIF_F_IP_CSUM |NETIF_F_TSO | -NETIF_F_HIGHDMA ; + dev->vlan_features =NETIF_F_SG |NETIF_F_IP_CSUM |NETIF_F_TSO ; dev->priv_flags |=IFF_LIVE_ADDR_CHANGE ; tp->cp_cmd |= RxChkSum;
Signature · 1 line
2.26.1
Heiner Kallweit
maintainerPATCH 3/6 r8169: preserve VLAN setting on RTL8125 in rtl_init_rxcfg
In reply to Heiner KallweitSo far we set RX_VLAN_8125 unconditionally, even if NETIF_F_HW_VLAN_CTAG_RX may not be set. Don't touch these bits, and let only rtl8169_set_features() control them.
--- drivers/net/ethernet/realtek/r8169_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +5 -2
@@ -2395,6 +2395,8 @@ static void rtl_pll_power_up(struct rtl8169_private *tp)static void rtl_init_rxcfg (struct rtl8169_private *tp) { +u32 vlan; +switch (tp->mac_version) { case RTL_GIGA_MAC_VER_02 ... RTL_GIGA_MAC_VER_06: case RTL_GIGA_MAC_VER_10 ... RTL_GIGA_MAC_VER_17:
@@ -2409,8 +2411,9 @@ 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 );break ; case RTL_GIGA_MAC_VER_60 ... RTL_GIGA_MAC_VER_61: -RTL_W32 (tp, RxConfig,RX_FETCH_DFLT_8125 |RX_VLAN_8125 | -RX_DMA_BURST ); +/* VLAN flags are controlled by NETIF_F_HW_VLAN_CTAG_RX */ + vlan =RTL_R32 (tp, RxConfig) &RX_VLAN_8125 ; +RTL_W32 (tp, RxConfig, vlan |RX_FETCH_DFLT_8125 |RX_DMA_BURST );break ;default :RTL_W32 (tp, RxConfig,RX128_INT_EN |RX_DMA_BURST );
Signature · 1 line
2.26.1
Heiner Kallweit
maintainerPATCH 4/6 r8169: use rtl8169_set_features in rtl8169_init_one
In reply to Heiner KallweitAt that place in rtl_init_one() we can safely use rtl8169_set_features() to configure the chip according to the default features.
--- drivers/net/ethernet/realtek/r8169_main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +3 -4
@@ -5444,10 +5444,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) dev->vlan_features =NETIF_F_SG |NETIF_F_IP_CSUM |NETIF_F_TSO ; dev->priv_flags |=IFF_LIVE_ADDR_CHANGE ; - tp->cp_cmd |= RxChkSum; -/* RTL8125 uses register RxConfig for VLAN offloading config */ -if (!rtl_is_8125 (tp)) - tp->cp_cmd |= RxVlan;/* * Pretend we are using VLANs; This bypasses a nasty bug where * Interrupts stop flowing on high load on 8110SCd controllers.
@@ -5479,6 +5475,9 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) dev->hw_features |=NETIF_F_RXALL ; dev->hw_features |=NETIF_F_RXFCS ; +/* configure chip for default features */ +rtl8169_set_features (dev, dev->features); + jumbo_max =rtl_jumbo_max (tp);if (jumbo_max) dev->max_mtu = jumbo_max;
Signature · 1 line
2.26.1
Heiner Kallweit
maintainerPATCH 5/6 r8169: improve rtl8169_tso_csum_v2
In reply to Heiner KallweitSimplify the code and avoid the overhead of calling vlan_get_protocol().
--- drivers/net/ethernet/realtek/r8169_main.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +5 -10
@@ -4125,25 +4125,20 @@ static bool rtl8169_tso_csum_v2(struct rtl8169_private *tp, struct sk_buff *skb, u32 *opts) { u32 transport_offset = (u32)skb_transport_offset(skb); -u32 mss =skb_shinfo (skb)->gso_size; +struct skb_shared_info *shinfo =skb_shinfo (skb); +u32 mss = shinfo->gso_size;if (mss) { -switch (vlan_get_protocol (skb)) { -case htons (ETH_P_IP ): +if (shinfo->gso_type &SKB_GSO_TCPV4 ) { opts[0 ] |=TD1_GTSENV4 ; -break ; - -case htons (ETH_P_IPV6 ): + }else if (shinfo->gso_type &SKB_GSO_TCPV6 ) {if (skb_cow_head (skb,0 ))return false;tcp_v6_gso_csum_prep (skb); opts[0 ] |=TD1_GTSENV6 ; -break ; - -default : + }else {WARN_ON_ONCE (1 ); -break ; } opts[0 ] |= transport_offset <<GTTCPHO_SHIFT ;
Signature · 1 line
2.26.1
Heiner Kallweit
maintainerPATCH 6/6 r8169: add workaround for RTL8168evl TSO hw issues
In reply to Heiner KallweitAdd workaround for hw issues with TSO on RTL8168evl. This workaround is based on information I got from Realtek, and *should* allow to safely enable TSO on this chip version.
--- drivers/net/ethernet/realtek/r8169_main.c | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/net/ethernet/realtek/r8169_main.c +34 -0
@@ -4304,6 +4304,37 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,return NETDEV_TX_BUSY ; } +static unsigned int rtl_last_frag_len (struct sk_buff *skb) +{ +struct skb_shared_info *info =skb_shinfo (skb); +unsigned int nr_frags = info->nr_frags; + +if (!nr_frags) +return UINT_MAX ; + +return skb_frag_size (info->frags + nr_frags -1 ); +} + +/* Workaround for hw issues with TSO on RTL8168evl */ +static netdev_features_t rtl8168evl_fix_tso (struct sk_buff *skb, +netdev_features_t features) +{ +/* IPv4 header has options field */ +if (vlan_get_protocol (skb) ==htons (ETH_P_IP ) && +ip_hdrlen (skb) >sizeof (struct iphdr )) + features &= ~NETIF_F_ALL_TSO ; + +/* IPv4 TCP header has options field */ +else if (skb_shinfo (skb)->gso_type &SKB_GSO_TCPV4 && +tcp_hdrlen (skb) >sizeof (struct tcphdr )) + features &= ~NETIF_F_ALL_TSO ; + +else if (rtl_last_frag_len (skb) <=6 ) + features &= ~NETIF_F_ALL_TSO ; + +return features; +} +static netdev_features_t rtl8169_features_check (struct sk_buff *skb,struct net_device *dev,netdev_features_t features)
@@ -4312,6 +4343,9 @@ static netdev_features_t rtl8169_features_check(struct sk_buff *skb,struct rtl8169_private *tp =netdev_priv (dev);if (skb_is_gso (skb)) { +if (tp->mac_version ==RTL_GIGA_MAC_VER_34 ) + features =rtl8168evl_fix_tso (skb, features); +if (transport_offset >GTTCPHO_MAX &&rtl_chip_supports_csum_v2 (tp)) features &= ~NETIF_F_ALL_TSO ;
Signature · 1 line
2.26.1
David Miller
maintainerFrom: Heiner Kallweit <[email protected]>
Date: Sat, 18 Apr 2020 23:05:50 +0200
Quoted 1 line
Again a series with few improvements.
Series applied, thanks.