Commit 773235f4 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller

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: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0623b98b
...@@ -4306,6 +4306,37 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, ...@@ -4306,6 +4306,37 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
return NETDEV_TX_BUSY; 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, static netdev_features_t rtl8169_features_check(struct sk_buff *skb,
struct net_device *dev, struct net_device *dev,
netdev_features_t features) netdev_features_t features)
...@@ -4314,6 +4345,9 @@ static netdev_features_t rtl8169_features_check(struct sk_buff *skb, ...@@ -4314,6 +4345,9 @@ static netdev_features_t rtl8169_features_check(struct sk_buff *skb,
struct rtl8169_private *tp = netdev_priv(dev); struct rtl8169_private *tp = netdev_priv(dev);
if (skb_is_gso(skb)) { 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 && if (transport_offset > GTTCPHO_MAX &&
rtl_chip_supports_csum_v2(tp)) rtl_chip_supports_csum_v2(tp))
features &= ~NETIF_F_ALL_TSO; features &= ~NETIF_F_ALL_TSO;
......
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