netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Alexander Duyck <alexander.h.duyck@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com, guru.anbalagane@oracle.com,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 02/18] i40evf: Be much more verbose about what we can and cannot offload
Date: Sat,  3 Dec 2016 01:19:14 -0800	[thread overview]
Message-ID: <20161203091930.14268-3-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <20161203091930.14268-1-jeffrey.t.kirsher@intel.com>

From: Alexander Duyck <alexander.h.duyck@intel.com>

This change makes it so that we are much more robust about defining what we
can and cannot offload.  Previously we were performing no checks.  This
should bring us up to parity with the i40e PF driver.

In addition the device only supports GSO as long as the MSS is 64 or
greater.  We were not checking this so an MSS less than that was resulting
in Tx hangs.

Change-ID: If533553ec92fc6ba694eab6ac81fdaf3004f3592
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/i40evf/i40evf_main.c | 59 +++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index db36744..7bbb55f 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -2172,6 +2172,64 @@ static int i40evf_change_mtu(struct net_device *netdev, int new_mtu)
 	return 0;
 }
 
+/**
+ * i40evf_features_check - Validate encapsulated packet conforms to limits
+ * @skb: skb buff
+ * @netdev: This physical port's netdev
+ * @features: Offload features that the stack believes apply
+ **/
+static netdev_features_t i40evf_features_check(struct sk_buff *skb,
+					       struct net_device *dev,
+					       netdev_features_t features)
+{
+	size_t len;
+
+	/* No point in doing any of this if neither checksum nor GSO are
+	 * being requested for this frame.  We can rule out both by just
+	 * checking for CHECKSUM_PARTIAL
+	 */
+	if (skb->ip_summed != CHECKSUM_PARTIAL)
+		return features;
+
+	/* We cannot support GSO if the MSS is going to be less than
+	 * 64 bytes.  If it is then we need to drop support for GSO.
+	 */
+	if (skb_is_gso(skb) && (skb_shinfo(skb)->gso_size < 64))
+		features &= ~NETIF_F_GSO_MASK;
+
+	/* MACLEN can support at most 63 words */
+	len = skb_network_header(skb) - skb->data;
+	if (len & ~(63 * 2))
+		goto out_err;
+
+	/* IPLEN and EIPLEN can support at most 127 dwords */
+	len = skb_transport_header(skb) - skb_network_header(skb);
+	if (len & ~(127 * 4))
+		goto out_err;
+
+	if (skb->encapsulation) {
+		/* L4TUNLEN can support 127 words */
+		len = skb_inner_network_header(skb) - skb_transport_header(skb);
+		if (len & ~(127 * 2))
+			goto out_err;
+
+		/* IPLEN can support at most 127 dwords */
+		len = skb_inner_transport_header(skb) -
+		      skb_inner_network_header(skb);
+		if (len & ~(127 * 4))
+			goto out_err;
+	}
+
+	/* No need to validate L4LEN as TCP is the only protocol with a
+	 * a flexible value and we support all possible values supported
+	 * by TCP, which is at most 15 dwords
+	 */
+
+	return features;
+out_err:
+	return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
+}
+
 #define I40EVF_VLAN_FEATURES (NETIF_F_HW_VLAN_CTAG_TX |\
 			      NETIF_F_HW_VLAN_CTAG_RX |\
 			      NETIF_F_HW_VLAN_CTAG_FILTER)
@@ -2206,6 +2264,7 @@ static const struct net_device_ops i40evf_netdev_ops = {
 	.ndo_tx_timeout		= i40evf_tx_timeout,
 	.ndo_vlan_rx_add_vid	= i40evf_vlan_rx_add_vid,
 	.ndo_vlan_rx_kill_vid	= i40evf_vlan_rx_kill_vid,
+	.ndo_features_check	= i40evf_features_check,
 	.ndo_fix_features	= i40evf_fix_features,
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	.ndo_poll_controller	= i40evf_netpoll,
-- 
2.9.3

  parent reply	other threads:[~2016-12-03  9:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-03  9:19 [net-next 00/18][pull request] 40GbE Intel Wired LAN Driver Updates 2016-12-02 Jeff Kirsher
2016-12-03  9:19 ` [net-next 01/18] i40e: Be much more verbose about what we can and cannot offload Jeff Kirsher
2016-12-03  9:19 ` Jeff Kirsher [this message]
2016-12-03  9:19 ` [net-next 03/18] i40e: remove error_param_int label from i40e_vc_config_promiscuous_mode_msg Jeff Kirsher
2016-12-03  9:19 ` [net-next 04/18] i40e: remove second check of VLAN_N_VID in i40e_vlan_rx_add_vid Jeff Kirsher
2016-12-03  9:19 ` [net-next 05/18] i40e: avoid duplicate private flags definitions Jeff Kirsher
2016-12-03  9:19 ` [net-next 06/18] i40e: Add Clause22 implementation Jeff Kirsher
2016-12-03  9:19 ` [net-next 07/18] i40e: fix trivial typo in naming of i40e_sync_filters_subtask Jeff Kirsher
2016-12-03  9:19 ` [net-next 08/18] i40e: Add protocols over MCTP to i40e_aq_discover_capabilities Jeff Kirsher
2016-12-03  9:19 ` [net-next 09/18] i40e: fix panic on SPARC while changing num of desc Jeff Kirsher
2016-12-03  9:19 ` [net-next 10/18] i40evf: Move some i40evf_reset_task code to separate function Jeff Kirsher
2016-12-03  9:19 ` [net-next 11/18] i40evf: check for msix_entries null dereference Jeff Kirsher
2016-12-03  9:19 ` [net-next 12/18] i40e: Remove unreachable code Jeff Kirsher
2016-12-03  9:19 ` [net-next 13/18] i40e: Pass unknown PHY type for unknown PHYs Jeff Kirsher
2016-12-03  9:19 ` [net-next 14/18] i40evf: protect against NULL msix_entries and q_vectors pointers Jeff Kirsher
2016-12-03  9:19 ` [net-next 15/18] i40e: Fix for ethtool Supported link modes Jeff Kirsher
2016-12-03  9:19 ` [net-next 16/18] i40e: set broadcast promiscuous mode for each active VLAN Jeff Kirsher
2016-12-03  9:19 ` [net-next 17/18] i40e/i40evf: replace for memcpy with single memcpy call in ethtool Jeff Kirsher
2016-12-03  9:19 ` [net-next 18/18] i40e: change message to only appear when extra debug info is wanted Jeff Kirsher
2016-12-04  0:11 ` [net-next 00/18][pull request] 40GbE Intel Wired LAN Driver Updates 2016-12-02 David Miller

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=20161203091930.14268-3-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=alexander.h.duyck@intel.com \
    --cc=davem@davemloft.net \
    --cc=guru.anbalagane@oracle.com \
    --cc=jogreene@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.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;
as well as URLs for NNTP newsgroup(s).