diff options
author | françois romieu <romieu@fr.zoreil.com> | 2013-05-17 21:24:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-05-20 03:01:07 -0400 |
commit | b423e9ae49d78ea3f53b131c8d5a6087aed16fd6 (patch) | |
tree | 4ba19fa8459f53280b1c70b85c67b614d141ad0e | |
parent | 318debd897735fe834545b6f3d2e96bcc9210b9f (diff) |
r8169: fix offloaded tx checksum for small packets.
8168evl offloaded checksums are wrong since commit
e5195c1f31f399289347e043d6abf3ffa80f0005 ("r8169: fix 8168evl frame padding.")
pads small packets to 60 bytes (without ethernet checksum). Typical symptoms
appear as UDP checksums which are wrong by the count of added bytes.
It isn't worth compensating. Let the driver checksum.
Due to the skb length changes, TSO code is moved before the Tx descriptor gets
written.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Tested-by: Holger Hoffstätte <holger.hoffstaette@googlemail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/realtek/r8169.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 79c520b64fdd..393f961a013c 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c | |||
@@ -5856,7 +5856,20 @@ err_out: | |||
5856 | return -EIO; | 5856 | return -EIO; |
5857 | } | 5857 | } |
5858 | 5858 | ||
5859 | static inline void rtl8169_tso_csum(struct rtl8169_private *tp, | 5859 | static bool rtl_skb_pad(struct sk_buff *skb) |
5860 | { | ||
5861 | if (skb_padto(skb, ETH_ZLEN)) | ||
5862 | return false; | ||
5863 | skb_put(skb, ETH_ZLEN - skb->len); | ||
5864 | return true; | ||
5865 | } | ||
5866 | |||
5867 | static bool rtl_test_hw_pad_bug(struct rtl8169_private *tp, struct sk_buff *skb) | ||
5868 | { | ||
5869 | return skb->len < ETH_ZLEN && tp->mac_version == RTL_GIGA_MAC_VER_34; | ||
5870 | } | ||
5871 | |||
5872 | static inline bool rtl8169_tso_csum(struct rtl8169_private *tp, | ||
5860 | struct sk_buff *skb, u32 *opts) | 5873 | struct sk_buff *skb, u32 *opts) |
5861 | { | 5874 | { |
5862 | const struct rtl_tx_desc_info *info = tx_desc_info + tp->txd_version; | 5875 | const struct rtl_tx_desc_info *info = tx_desc_info + tp->txd_version; |
@@ -5869,13 +5882,20 @@ static inline void rtl8169_tso_csum(struct rtl8169_private *tp, | |||
5869 | } else if (skb->ip_summed == CHECKSUM_PARTIAL) { | 5882 | } else if (skb->ip_summed == CHECKSUM_PARTIAL) { |
5870 | const struct iphdr *ip = ip_hdr(skb); | 5883 | const struct iphdr *ip = ip_hdr(skb); |
5871 | 5884 | ||
5885 | if (unlikely(rtl_test_hw_pad_bug(tp, skb))) | ||
5886 | return skb_checksum_help(skb) == 0 && rtl_skb_pad(skb); | ||
5887 | |||
5872 | if (ip->protocol == IPPROTO_TCP) | 5888 | if (ip->protocol == IPPROTO_TCP) |
5873 | opts[offset] |= info->checksum.tcp; | 5889 | opts[offset] |= info->checksum.tcp; |
5874 | else if (ip->protocol == IPPROTO_UDP) | 5890 | else if (ip->protocol == IPPROTO_UDP) |
5875 | opts[offset] |= info->checksum.udp; | 5891 | opts[offset] |= info->checksum.udp; |
5876 | else | 5892 | else |
5877 | WARN_ON_ONCE(1); | 5893 | WARN_ON_ONCE(1); |
5894 | } else { | ||
5895 | if (unlikely(rtl_test_hw_pad_bug(tp, skb))) | ||
5896 | return rtl_skb_pad(skb); | ||
5878 | } | 5897 | } |
5898 | return true; | ||
5879 | } | 5899 | } |
5880 | 5900 | ||
5881 | static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, | 5901 | static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, |
@@ -5896,17 +5916,15 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, | |||
5896 | goto err_stop_0; | 5916 | goto err_stop_0; |
5897 | } | 5917 | } |
5898 | 5918 | ||
5899 | /* 8168evl does not automatically pad to minimum length. */ | ||
5900 | if (unlikely(tp->mac_version == RTL_GIGA_MAC_VER_34 && | ||
5901 | skb->len < ETH_ZLEN)) { | ||
5902 | if (skb_padto(skb, ETH_ZLEN)) | ||
5903 | goto err_update_stats; | ||
5904 | skb_put(skb, ETH_ZLEN - skb->len); | ||
5905 | } | ||
5906 | |||
5907 | if (unlikely(le32_to_cpu(txd->opts1) & DescOwn)) | 5919 | if (unlikely(le32_to_cpu(txd->opts1) & DescOwn)) |
5908 | goto err_stop_0; | 5920 | goto err_stop_0; |
5909 | 5921 | ||
5922 | opts[1] = cpu_to_le32(rtl8169_tx_vlan_tag(skb)); | ||
5923 | opts[0] = DescOwn; | ||
5924 | |||
5925 | if (!rtl8169_tso_csum(tp, skb, opts)) | ||
5926 | goto err_update_stats; | ||
5927 | |||
5910 | len = skb_headlen(skb); | 5928 | len = skb_headlen(skb); |
5911 | mapping = dma_map_single(d, skb->data, len, DMA_TO_DEVICE); | 5929 | mapping = dma_map_single(d, skb->data, len, DMA_TO_DEVICE); |
5912 | if (unlikely(dma_mapping_error(d, mapping))) { | 5930 | if (unlikely(dma_mapping_error(d, mapping))) { |
@@ -5918,11 +5936,6 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, | |||
5918 | tp->tx_skb[entry].len = len; | 5936 | tp->tx_skb[entry].len = len; |
5919 | txd->addr = cpu_to_le64(mapping); | 5937 | txd->addr = cpu_to_le64(mapping); |
5920 | 5938 | ||
5921 | opts[1] = cpu_to_le32(rtl8169_tx_vlan_tag(skb)); | ||
5922 | opts[0] = DescOwn; | ||
5923 | |||
5924 | rtl8169_tso_csum(tp, skb, opts); | ||
5925 | |||
5926 | frags = rtl8169_xmit_frags(tp, skb, opts); | 5939 | frags = rtl8169_xmit_frags(tp, skb, opts); |
5927 | if (frags < 0) | 5940 | if (frags < 0) |
5928 | goto err_dma_1; | 5941 | goto err_dma_1; |