From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Matthew Vick <matthew.vick@intel.com>,
netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
jogreene@redhat.com, Joe Stringer <joestringer@nicira.com>,
Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 01/18] fm10k: Modify tunnel length header check when offloading
Date: Sat, 28 Feb 2015 03:29:32 -0800 [thread overview]
Message-ID: <1425122989-354-2-git-send-email-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <1425122989-354-1-git-send-email-jeffrey.t.kirsher@intel.com>
From: Matthew Vick <matthew.vick@intel.com>
The FM10000 host interface can only support up to 184 bytes when
performing tunnel offloads. Because of this, a check was added to
prevent the driver from attempting to feed a header to the hardware too
big for it to parse. Make this check a little more robust by calculating
the inner L4 header length based on whether it is TCP or UDP.
Cc: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Matthew Vick <matthew.vick@intel.com>
Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/fm10k/fm10k_main.c | 33 +++++++++++++++++++--------
drivers/net/ethernet/intel/fm10k/fm10k_type.h | 3 +++
2 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
index 84ab9ee..a7d3798 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
@@ -711,10 +711,6 @@ static struct ethhdr *fm10k_gre_is_nvgre(struct sk_buff *skb)
if (nvgre_hdr->flags & FM10K_NVGRE_RESERVED0_FLAGS)
return NULL;
- /* verify protocol is transparent Ethernet bridging */
- if (nvgre_hdr->proto != htons(ETH_P_TEB))
- return NULL;
-
/* report start of ethernet header */
if (nvgre_hdr->flags & NVGRE_TNI)
return (struct ethhdr *)(nvgre_hdr + 1);
@@ -724,13 +720,11 @@ static struct ethhdr *fm10k_gre_is_nvgre(struct sk_buff *skb)
static __be16 fm10k_tx_encap_offload(struct sk_buff *skb)
{
+ u8 l4_hdr = 0, inner_l4_hdr = 0, inner_l4_hlen;
struct ethhdr *eth_hdr;
- u8 l4_hdr = 0;
-/* fm10k supports 184 octets of outer+inner headers. Minus 20 for inner L4. */
-#define FM10K_MAX_ENCAP_TRANSPORT_OFFSET 164
- if (skb_inner_transport_header(skb) - skb_mac_header(skb) >
- FM10K_MAX_ENCAP_TRANSPORT_OFFSET)
+ if (skb->inner_protocol_type != ENCAP_TYPE_ETHER ||
+ skb->inner_protocol != htons(ETH_P_TEB))
return 0;
switch (vlan_get_protocol(skb)) {
@@ -760,12 +754,33 @@ static __be16 fm10k_tx_encap_offload(struct sk_buff *skb)
switch (eth_hdr->h_proto) {
case htons(ETH_P_IP):
+ inner_l4_hdr = inner_ip_hdr(skb)->protocol;
+ break;
case htons(ETH_P_IPV6):
+ inner_l4_hdr = inner_ipv6_hdr(skb)->nexthdr;
break;
default:
return 0;
}
+ switch (inner_l4_hdr) {
+ case IPPROTO_TCP:
+ inner_l4_hlen = inner_tcp_hdrlen(skb);
+ break;
+ case IPPROTO_UDP:
+ inner_l4_hlen = 8;
+ break;
+ default:
+ return 0;
+ }
+
+ /* The hardware allows tunnel offloads only if the combined inner and
+ * outer header is 184 bytes or less
+ */
+ if (skb_inner_transport_header(skb) + inner_l4_hlen -
+ skb_mac_header(skb) > FM10K_TUNNEL_HEADER_LENGTH)
+ return 0;
+
return eth_hdr->h_proto;
}
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_type.h b/drivers/net/ethernet/intel/fm10k/fm10k_type.h
index 7c6d9d5..abb8a03 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_type.h
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_type.h
@@ -356,6 +356,9 @@ struct fm10k_hw;
#define FM10K_QUEUE_DISABLE_TIMEOUT 100
#define FM10K_RESET_TIMEOUT 150
+/* Maximum supported combined inner and outer header length for encapsulation */
+#define FM10K_TUNNEL_HEADER_LENGTH 184
+
/* VF registers */
#define FM10K_VFCTRL 0x00000
#define FM10K_VFCTRL_RST 0x00000008
--
1.9.3
next prev parent reply other threads:[~2015-02-28 11:29 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-28 11:29 [net-next 00/18][pull request] Intel Wired LAN Driver Updates 2015-02-28 Jeff Kirsher
2015-02-28 11:29 ` Jeff Kirsher [this message]
2015-02-28 11:29 ` [net-next 02/18] fm10k: Implement ndo_features_check Jeff Kirsher
2015-02-28 11:29 ` [net-next 03/18] fm10k: Resolve various spelling errors and checkpatch warnings Jeff Kirsher
2015-02-28 11:29 ` [net-next 04/18] i40e: Skip the priority tagging if DCB is not enabled Jeff Kirsher
2015-02-28 11:29 ` [net-next 05/18] i40e/i40evf: print FW build number in version string Jeff Kirsher
2015-02-28 11:29 ` [net-next 06/18] i40e: Add safety net for switch calling Jeff Kirsher
2015-02-28 11:29 ` [net-next 07/18] i40e: don't disable PF LB when disabling VFs Jeff Kirsher
2015-02-28 11:29 ` [net-next 08/18] i40e: Enable more than 64 qps for the Main VSI Jeff Kirsher
2015-02-28 11:29 ` [net-next 09/18] i40e/i40evf: Add capability to gather VEB per TC stats Jeff Kirsher
2015-03-01 4:30 ` David Miller
2015-03-03 1:34 ` Jeff Kirsher
2015-02-28 11:29 ` [net-next 10/18] i40e: Add FW check to disable DCB and wrap autoneg workaround with FW check Jeff Kirsher
2015-02-28 11:29 ` [net-next 11/18] i40e: Fix issue with removal of apps from DBCNL app table Jeff Kirsher
2015-02-28 11:29 ` [net-next 12/18] i40e/i40evf: Add missing packet types for VXLAN encapsulated packet types Jeff Kirsher
2015-02-28 11:29 ` [net-next 13/18] i40e: Move RSS table size for VSIs to the VSI struct Jeff Kirsher
2015-02-28 11:29 ` [net-next 14/18] i40e: Fix RSS size at init since default num queue calculation has changed Jeff Kirsher
2015-02-28 11:29 ` [net-next 15/18] i40evf: ethtool RSS fixes Jeff Kirsher
2015-02-28 11:29 ` [net-next 16/18] i40e: Register DCBNL ops in MFP mode Jeff Kirsher
2015-02-28 11:29 ` [net-next 17/18] i40e: Only enable TC0 for NIC partition type Jeff Kirsher
2015-02-28 11:29 ` [net-next 18/18] i40e/i40evf: Bump versions Jeff Kirsher
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=1425122989-354-2-git-send-email-jeffrey.t.kirsher@intel.com \
--to=jeffrey.t.kirsher@intel.com \
--cc=davem@davemloft.net \
--cc=joestringer@nicira.com \
--cc=jogreene@redhat.com \
--cc=matthew.vick@intel.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).