r8169: add workaround for RTL8168evl TSO hw issues

Add 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.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Heiner Kallweit 2020-04-18 23:11:32 +02:00 committed by David S. Miller
parent 0623b98b41
commit 773235f4e1
1 changed files with 34 additions and 0 deletions

View File

@ -4306,6 +4306,37 @@ err_stop_0:
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)
@ -4314,6 +4345,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;