From: Heiner Kallweit <hkallweit1@gmail•com>
To: Realtek linux nic maintainers <nic_swsd@realtek•com>,
David Miller <davem@davemloft•net>
Cc: "netdev@vger•kernel.org" <netdev@vger•kernel.org>
Subject: [PATCH net-next 6/6] r8169: add workaround for RTL8168evl TSO hw issues
Date: Sat, 18 Apr 2020 23:11:32 +0200 [thread overview]
Message-ID: <d1efe35c-3755-8981-cfe7-0ebfa4babc30@gmail.com> (raw)
In-Reply-To: <f7c53dc0-768c-7eb9-ffc0-b2e39b1ddfa4@gmail.com>
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>
---
drivers/net/ethernet/realtek/r8169_main.c | 34 +++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index c7d9325f4..1bc415d00 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -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;
--
2.26.1
next prev parent reply other threads:[~2020-04-18 21:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-18 21:05 [PATCH net-next 0/6] r8169: series with improvements Heiner Kallweit
2020-04-18 21:06 ` [PATCH net-next 1/6] r8169: move setting OCP base to generic init code Heiner Kallweit
2020-04-18 21:07 ` [PATCH net-next 2/6] r8169: remove NETIF_F_HIGHDMA from vlan_features Heiner Kallweit
2020-04-18 21:08 ` [PATCH net-next 3/6] r8169: preserve VLAN setting on RTL8125 in rtl_init_rxcfg Heiner Kallweit
2020-04-18 21:10 ` [PATCH net-next 4/6] r8169: use rtl8169_set_features in rtl8169_init_one Heiner Kallweit
2020-04-18 21:10 ` [PATCH net-next 5/6] r8169: improve rtl8169_tso_csum_v2 Heiner Kallweit
2020-04-18 21:11 ` Heiner Kallweit [this message]
2020-04-19 3:20 ` [PATCH net-next 0/6] r8169: series with improvements David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d1efe35c-3755-8981-cfe7-0ebfa4babc30@gmail.com \
--to=hkallweit1@gmail$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nic_swsd@realtek$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox