netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Herbert <therbert@google.com>
To: davem@davemloft.net, netdev@vger.kernel.org, gerlitz.or@gmail.com
Subject: [PATCH] net: Add ndo_gso_check
Date: Sun, 28 Sep 2014 20:50:07 -0700	[thread overview]
Message-ID: <1411962607-27878-1-git-send-email-therbert@google.com> (raw)

Add ndo_gso_check which a device can define to indicate whether is
is capable of doing GSO on a packet. This funciton would be called from
the stack to determine whether software GSO is needed to be done. A
driver should populate this function if it advertises GSO types for
which there are combinations that it wouldn't be able to handle. For
instance a device that performs UDP tunneling might only implement
support for transparent Ethernet bridging type of inner packets
or might have limitations on lengths of inner headers.

Signed-off-by: Tom Herbert <therbert@google.com>
---
 include/linux/netdevice.h | 12 +++++++++++-
 net/core/dev.c            |  2 +-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9f5d293..f8c2027 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -997,6 +997,12 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
  *	Callback to use for xmit over the accelerated station. This
  *	is used in place of ndo_start_xmit on accelerated net
  *	devices.
+ * bool	(*ndo_gso_check) (struct sk_buff *skb,
+ *			  struct net_device *dev);
+ *	Called by core transmit path to determine if device is capable of
+ *	performing GSO on a packet. The device returns true if it is
+ *	able to GSO the packet, false otherwise. If the return value is
+ *	false the stack will do software GSO.
  */
 struct net_device_ops {
 	int			(*ndo_init)(struct net_device *dev);
@@ -1146,6 +1152,8 @@ struct net_device_ops {
 							struct net_device *dev,
 							void *priv);
 	int			(*ndo_get_lock_subclass)(struct net_device *dev);
+	bool			(*ndo_gso_check) (struct sk_buff *skb,
+						  struct net_device *dev);
 };
 
 /**
@@ -3536,10 +3544,12 @@ static inline bool skb_gso_ok(struct sk_buff *skb, netdev_features_t features)
 	       (!skb_has_frag_list(skb) || (features & NETIF_F_FRAGLIST));
 }
 
-static inline bool netif_needs_gso(struct sk_buff *skb,
+static inline bool netif_needs_gso(struct net_device *dev, struct sk_buff *skb,
 				   netdev_features_t features)
 {
 	return skb_is_gso(skb) && (!skb_gso_ok(skb, features) ||
+		(dev->netdev_ops->ndo_gso_check &&
+		 !dev->netdev_ops->ndo_gso_check(skb, dev)) ||
 		unlikely((skb->ip_summed != CHECKSUM_PARTIAL) &&
 			 (skb->ip_summed != CHECKSUM_UNNECESSARY)));
 }
diff --git a/net/core/dev.c b/net/core/dev.c
index e2ced01..8c2b9bb 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2680,7 +2680,7 @@ struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device *dev)
 	if (skb->encapsulation)
 		features &= dev->hw_enc_features;
 
-	if (netif_needs_gso(skb, features)) {
+	if (netif_needs_gso(dev, skb, features)) {
 		struct sk_buff *segs;
 
 		segs = skb_gso_segment(skb, features);
-- 
2.1.0.rc2.206.gedb03e5

             reply	other threads:[~2014-09-29  3:50 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-29  3:50 Tom Herbert [this message]
2014-09-29 19:59 ` [PATCH] net: Add ndo_gso_check Or Gerlitz
2014-09-29 20:12   ` David Miller
2014-09-29 20:53   ` Tom Herbert
2014-09-29 21:10     ` Or Gerlitz
2014-09-29 21:38       ` Tom Herbert
2014-09-30 14:30         ` Or Gerlitz
2014-09-30 15:34           ` Tom Herbert
2014-09-30 21:37             ` Stephen Hemminger
2014-09-30 22:11               ` Eric Dumazet
2014-10-01  0:05               ` Tom Herbert
2014-10-01  0:18                 ` Eric Dumazet
2014-10-01  6:12                   ` Eric Dumazet
2014-10-01 20:58             ` Or Gerlitz
2014-10-01 21:12               ` Jesse Gross
2014-10-01 23:06               ` Tom Herbert
2014-10-05 14:04                 ` Or Gerlitz
2014-10-05 18:49                   ` Tom Herbert
2014-10-05 19:13                     ` Or Gerlitz
2014-10-06 17:59                       ` Tom Herbert
2014-10-06 20:22                         ` Or Gerlitz
2014-10-06 21:28                           ` Tom Herbert
2014-10-07 11:07                             ` Or Gerlitz
2015-01-15 18:18                             ` Or Gerlitz
2014-10-06 22:33                         ` Jesse Gross
2014-10-07  0:17                           ` Tom Herbert
2014-10-09  0:30                             ` Jesse Gross
2014-10-09  1:46                               ` Tom Herbert
2014-10-06 21:51                     ` Jesse Gross
2014-09-29 20:13 ` Jesse Gross
2014-09-29 20:47   ` Tom Herbert
2014-09-30  0:33     ` Jesse Gross
2014-09-30  1:59       ` Tom Herbert
2014-10-07 18:13 ` Tom Herbert
2014-10-07 20:15   ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2014-10-07 16:50 Alexei Starovoitov
2014-10-07 17:05 ` David Miller
2014-10-07 17:18   ` Alexei Starovoitov
2014-10-07 18:47     ` David Miller
2014-10-07 20:28       ` Alexei Starovoitov
2014-10-07 20:32         ` David Miller
2014-10-07 20:43           ` Alexei Starovoitov
2014-10-07 20:48             ` David Miller
2014-10-07 21:41               ` Thomas Graf
2014-10-07 17:23 ` Eric Dumazet
2014-10-07 18:15   ` Alexei Starovoitov
2014-10-07 18:50     ` Eric Dumazet
2014-10-07 18:51     ` David Miller
2014-10-07 19:10       ` Tom Herbert
2014-10-07 22:05 Alexei Starovoitov
2014-10-07 23:43 ` Tom Herbert

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=1411962607-27878-1-git-send-email-therbert@google.com \
    --to=therbert@google.com \
    --cc=davem@davemloft.net \
    --cc=gerlitz.or@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).