netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][RFC] TSO for VLAN devices without VLAN tag insertion
@ 2008-06-10 19:59 Ben Hutchings
  2008-06-12 12:02 ` Patrick McHardy
  0 siblings, 1 reply; 2+ messages in thread
From: Ben Hutchings @ 2008-06-10 19:59 UTC (permalink / raw)
  To: netdev; +Cc: linux-net-drivers

The SFC4000 controller can set IP header, TCP and UDP checksums in IPv4
packets, with or without VLAN encapsulation.  However it does not do VLAN
tag insertion.

When I try to make TSO work for VLAN devices via the new vlan_features,
dev_queue_xmit() finds skb->ip_summed == CHECKSUM_PARTIAL &&
skb->protocol == htons(ETH_P_8021Q) and calls skb_checksum_help(), which
sets skb->ip_summed = CHECKSUM_NONE.

This causes netif_needs_gso() to return true when called by
dev_hard_start_xmit(), and GSO then does its worst.

Below is a patch which worked for me, but I'm not sure whether it's the
best way to fix the problem (so I'm not submitting or signing it off yet).

Ben.

--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -119,6 +119,7 @@
 #include <linux/err.h>
 #include <linux/ctype.h>
 #include <linux/if_arp.h>
+#include <linux/if_vlan.h>
 
 #include "net-sysfs.h"
 
@@ -1638,14 +1639,24 @@ int dev_queue_xmit(struct sk_buff *skb)
 	 * checksumming for this protocol, complete checksumming here.
 	 */
 	if (skb->ip_summed == CHECKSUM_PARTIAL) {
+		unsigned long features = dev->features;
+		__be16 protocol = skb->protocol;
+
+		if (protocol == htons(ETH_P_8021Q)) {
+			struct vlan_ethhdr *veh =
+				(struct vlan_ethhdr *)skb->data;
+			features &= dev->vlan_features;
+			protocol = veh->h_vlan_encapsulated_proto;
+		}
+
 		skb_set_transport_header(skb, skb->csum_start -
 					      skb_headroom(skb));
 
-		if (!(dev->features & NETIF_F_GEN_CSUM) &&
-		    !((dev->features & NETIF_F_IP_CSUM) &&
-		      skb->protocol == htons(ETH_P_IP)) &&
-		    !((dev->features & NETIF_F_IPV6_CSUM) &&
-		      skb->protocol == htons(ETH_P_IPV6)))
+		if (!(features & NETIF_F_GEN_CSUM) &&
+		    !((features & NETIF_F_IP_CSUM) &&
+		      protocol == htons(ETH_P_IP)) &&
+		    !((features & NETIF_F_IPV6_CSUM) &&
+		      protocol == htons(ETH_P_IPV6)))
 			if (skb_checksum_help(skb))
 				goto out_kfree_skb;
 	}

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-12 12:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-10 19:59 [PATCH][RFC] TSO for VLAN devices without VLAN tag insertion Ben Hutchings
2008-06-12 12:02 ` Patrick McHardy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).