mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: akpm@linux-foundation.org, "hayeswang" <hayeswang@realtek.com>,
	"Francois Romieu" <romieu@fr.zoreil.com>,
	"Stefan Bader" <stefan.bader@canonical.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [16/26] r8169: fix 8168evl frame padding.
Date: Wed, 26 Jun 2013 03:35:58 +0100	[thread overview]
Message-ID: <lsq.1372214158.437609827@decadent.org.uk> (raw)
In-Reply-To: <lsq.1372214158.425780530@decadent.org.uk>

3.2.48-rc1 review patch.  If anyone has any objections, please let me know.

------------------

From: Stefan Bader <stefan.bader@canonical.com>

[ Upstream commits e5195c1f31f399289347e043d6abf3ffa80f0005 and
  b423e9ae49d78ea3f53b131c8d5a6087aed16fd6 ]

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Francois Romieu <romieu@fr.zoreil.com>
Cc: hayeswang <hayeswang@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/net/ethernet/realtek/r8169.c | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index f698183..ed7a5a6 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -5524,7 +5524,20 @@ err_out:
 	return -EIO;
 }
 
-static inline void rtl8169_tso_csum(struct rtl8169_private *tp,
+static bool rtl_skb_pad(struct sk_buff *skb)
+{
+	if (skb_padto(skb, ETH_ZLEN))
+		return false;
+	skb_put(skb, ETH_ZLEN - skb->len);
+	return true;
+}
+
+static bool rtl_test_hw_pad_bug(struct rtl8169_private *tp, struct sk_buff *skb)
+{
+	return skb->len < ETH_ZLEN && tp->mac_version == RTL_GIGA_MAC_VER_34;
+}
+
+static inline bool rtl8169_tso_csum(struct rtl8169_private *tp,
 				    struct sk_buff *skb, u32 *opts)
 {
 	const struct rtl_tx_desc_info *info = tx_desc_info + tp->txd_version;
@@ -5537,13 +5550,20 @@ static inline void rtl8169_tso_csum(struct rtl8169_private *tp,
 	} else if (skb->ip_summed == CHECKSUM_PARTIAL) {
 		const struct iphdr *ip = ip_hdr(skb);
 
+		if (unlikely(rtl_test_hw_pad_bug(tp, skb)))
+			return skb_checksum_help(skb) == 0 && rtl_skb_pad(skb);
+
 		if (ip->protocol == IPPROTO_TCP)
 			opts[offset] |= info->checksum.tcp;
 		else if (ip->protocol == IPPROTO_UDP)
 			opts[offset] |= info->checksum.udp;
 		else
 			WARN_ON_ONCE(1);
+	} else {
+		if (unlikely(rtl_test_hw_pad_bug(tp, skb)))
+			return rtl_skb_pad(skb);
 	}
+	return true;
 }
 
 static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
@@ -5575,6 +5595,12 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
 	if (unlikely(le32_to_cpu(txd->opts1) & DescOwn))
 		goto err_stop_0;
 
+	opts[1] = cpu_to_le32(rtl8169_tx_vlan_tag(tp, skb));
+	opts[0] = DescOwn;
+
+	if (!rtl8169_tso_csum(tp, skb, opts))
+		goto err_update_stats;
+
 	len = skb_headlen(skb);
 	mapping = dma_map_single(d, skb->data, len, DMA_TO_DEVICE);
 	if (unlikely(dma_mapping_error(d, mapping))) {
@@ -5586,11 +5612,6 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
 	tp->tx_skb[entry].len = len;
 	txd->addr = cpu_to_le64(mapping);
 
-	opts[1] = cpu_to_le32(rtl8169_tx_vlan_tag(tp, skb));
-	opts[0] = DescOwn;
-
-	rtl8169_tso_csum(tp, skb, opts);
-
 	frags = rtl8169_xmit_frags(tp, skb, opts);
 	if (frags < 0)
 		goto err_dma_1;


  parent reply	other threads:[~2013-06-26  2:46 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-26  2:35 [00/26] 3.2.48-rc1 review Ben Hutchings
2013-06-26  2:35 ` [12/26] tcp: fix tcp_md5_hash_skb_data() Ben Hutchings
2013-06-26  2:35 ` [11/26] virtio-blk: Call revalidate_disk() upon online disk resize Ben Hutchings
2013-06-26  2:35 ` [19/26] net: Block MSG_CMSG_COMPAT in send(m)msg and recv(m)msg Ben Hutchings
2013-06-26  2:35 ` [09/26] x86/efi: Fix dummy variable buffer allocation Ben Hutchings
2013-06-26  2:35 ` [04/26] ARM: 7755/1: handle user space mapped pages in flush_kernel_dcache_page Ben Hutchings
2013-06-26  9:04   ` Luis Henriques
2013-06-26 22:35     ` Simon Baatz
2013-06-27  8:21       ` Luis Henriques
2013-06-29  3:01       ` Ben Hutchings
2013-06-26  2:35 ` [01/26] tilepro: work around module link error with gcc 4.7 Ben Hutchings
2013-06-26  2:35 ` [02/26] ALSA: usb-audio: work around Android accessory firmware bug Ben Hutchings
2013-06-26  2:35 ` [17/26] tcp: xps: fix reordering issues Ben Hutchings
2013-06-26  2:35 ` [05/26] KVM: x86: remove vcpu's CPL check in host-invoked XCR set Ben Hutchings
2013-06-26  2:35 ` [18/26] ip_tunnel: fix kernel panic with icmp_dest_unreach Ben Hutchings
2013-06-26  2:35 ` [14/26] ipv6: fix possible crashes in ip6_cork_release() Ben Hutchings
2013-06-26  2:35 ` [06/26] x86: fix build error and kconfig for ia32_emulation and binfmt Ben Hutchings
2013-06-26  2:35 ` [13/26] gianfar: add missing iounmap() on error in gianfar_ptp_probe() Ben Hutchings
2013-06-26  2:35 ` [15/26] netlabel: improve domain mapping validation Ben Hutchings
2013-06-26  2:35 ` [03/26] ALSA: usb-audio: Fix invalid volume resolution for Logitech HD Webcam c310 Ben Hutchings
2013-06-26  2:35 ` Ben Hutchings [this message]
2013-06-26  8:51   ` [16/26] r8169: fix 8168evl frame padding Stefan Bader
2013-06-26 18:37     ` David Miller
2013-06-26 20:00       ` Stefan Bader
2013-06-26  2:35 ` [07/26] USB: serial: ti_usb_3410_5052: new device id for Abbot strip port cable Ben Hutchings
2013-06-26  8:21   ` Anders Hammarquist
2013-06-26 17:22     ` Greg Kroah-Hartman
2013-06-26  2:35 ` [10/26] Revert "drm/i915: GFX_MODE Flush TLB Invalidate Mode must be '1' for scanline waits" Ben Hutchings
2013-06-26  2:35 ` [21/26] ipv6: assign rt6_info to inet6_ifaddr in init_loopback Ben Hutchings
2013-06-26  2:35 ` [22/26] net: sctp: fix NULL pointer dereference in socket destruction Ben Hutchings
2013-06-26  2:35 ` [24/26] l2tp: Fix PPP header erasure and memory leak Ben Hutchings
2013-06-26  2:35 ` [23/26] packet: packet_getname_spkt: make sure string is always 0-terminated Ben Hutchings
2013-06-26  2:35 ` [26/26] ncpfs: fix rmdir returns Device or resource busy Ben Hutchings
2013-06-26  2:35 ` [25/26] l2tp: Fix sendmsg() return value Ben Hutchings
2013-06-26  2:35 ` [20/26] net: force a reload of first item in hlist_nulls_for_each_entry_rcu Ben Hutchings

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=lsq.1372214158.437609827@decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=hayeswang@realtek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=romieu@fr.zoreil.com \
    --cc=stable@vger.kernel.org \
    --cc=stefan.bader@canonical.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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

all inboxes | Powered by JetHome®