From patchwork Fri Apr 19 07:29:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 237864 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A5A9A2C0311 for ; Fri, 19 Apr 2013 17:30:25 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757294Ab3DSHaQ (ORCPT ); Fri, 19 Apr 2013 03:30:16 -0400 Received: from kirsty.vergenet.net ([202.4.237.240]:53594 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757267Ab3DSHaN (ORCPT ); Fri, 19 Apr 2013 03:30:13 -0400 Received: from ayumi.akashicho.tokyo.vergenet.net (p8120-ipbfp1001kobeminato.hyogo.ocn.ne.jp [118.10.137.120]) by kirsty.vergenet.net (Postfix) with ESMTP id F3715266CEF; Fri, 19 Apr 2013 17:30:11 +1000 (EST) Received: by ayumi.akashicho.tokyo.vergenet.net (Postfix, from userid 7100) id 8DEE2EDE0B3; Fri, 19 Apr 2013 16:30:10 +0900 (JST) From: Simon Horman To: dev@openvswitch.org, netdev@vger.kernel.org Cc: Jesse Gross , jarno.rajahalme@nsn.com, Joseph Gasparakis , Peter P Waskiewicz Jr , Alexander Duyck , Eric Dumazet , =?UTF-8?q?Maciej=20=C5=BBenczykowski?= , Simon Horman Subject: [PATCH 1/2] net: More fine-grained support for encapsulated GSO features Date: Fri, 19 Apr 2013 16:29:54 +0900 Message-Id: <1366356595-3405-2-git-send-email-horms@verge.net.au> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1366356595-3405-1-git-send-email-horms@verge.net.au> References: <1366356595-3405-1-git-send-email-horms@verge.net.au> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org "net: Add support for hardware-offloaded encapsulation" introduced the encapsulation field of struct skb, which when set provides hints that GSO should handle an skb that encapsulates a packet. This patch adds an encapsulation_features field which provides a hint to dev dev_hard_start_xmit() that harware-offload encapsulation features should be used. Previously this hint was provided by the encapsulation field. The other uses of the encapsulation field are left unchanged. The two in-tree locations that set the encapsulation have been updated to also set encapsulation_field. The motivation for this is to provide support segmentation of GSO MPLS skbs. This may be necessary when a non-MPLS GSO skb is turned into an MPLS GSO skb by Open vSwtich and its MPLS push action. In this case it harware-offload encapsulation features should be used, actually to be more exact software segmentation should be selected, but other hints provided by the encapsulation field are not applicable. Cc: Joseph Gasparakis Cc: Peter P Waskiewicz Jr Cc: Alexander Duyck Signed-off-by: Simon Horman --- include/linux/skbuff.h | 9 ++++++++- net/core/dev.c | 2 +- net/core/skbuff.c | 1 + net/ipv4/gre.c | 1 + net/ipv4/ipip.c | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index e27d1c7..42e61c1 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -492,7 +492,14 @@ struct sk_buff { * headers if needed */ __u8 encapsulation:1; - /* 7/9 bit hole (depending on ndisc_nodetype presence) */ + /* Encapsulation protocol and NIC drivers should use + * this flag to indicate to each other if the skb contains + * encapsulated packet and GSO should use encapsulation features + * instead of standard features for the netdev. This is typically + * a subset of cases where skb->encapsulation is set. + */ + __u8 encapsulation_features:1; + /* 6/8 bit hole (depending on ndisc_nodetype presence) */ kmemcheck_bitfield_end(flags2); #ifdef CONFIG_NET_DMA diff --git a/net/core/dev.c b/net/core/dev.c index 3655ff9..ca81ac8 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2494,7 +2494,7 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, * hardware encapsulation features instead of standard * features for the netdev */ - if (skb->encapsulation) + if (skb->encapsulation_features) features &= dev->hw_enc_features; if (netif_needs_gso(skb, features)) { diff --git a/net/core/skbuff.c b/net/core/skbuff.c index ba64614..7504371 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -680,6 +680,7 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old) new->l4_rxhash = old->l4_rxhash; new->no_fcs = old->no_fcs; new->encapsulation = old->encapsulation; + new->encapsulation_features = old->encapsulation_features; #ifdef CONFIG_XFRM new->sp = secpath_get(old->sp); #endif diff --git a/net/ipv4/gre.c b/net/ipv4/gre.c index 0ae998b..8420f29 100644 --- a/net/ipv4/gre.c +++ b/net/ipv4/gre.c @@ -157,6 +157,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb, } skb->encapsulation = 0; + skb->encapsulation_features = 0; if (unlikely(!pskb_may_pull(skb, ghl))) goto out; diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 77bfcce..a6db3c0 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c @@ -220,6 +220,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) if (likely(!skb->encapsulation)) { skb_reset_inner_headers(skb); skb->encapsulation = 1; + skb->encapsulation_features = 1; } ip_tunnel_xmit(skb, dev, tiph);