i40e/i40evf: Simplify tunnel selection logic
authorAnjali Singhai Jain <anjali.singhai@intel.com>
Fri, 27 Feb 2015 09:15:29 +0000 (09:15 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Sat, 7 Mar 2015 15:00:13 +0000 (07:00 -0800)
Use l4_tunnel type generically to keep code flow simple.

Change-ID: Ic52287e3b1ca4204e6b6e13431890c1a6ae9c422
Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_txrx.c
drivers/net/ethernet/intel/i40evf/i40e_txrx.c

index cdd5cc13cbeb59ca8fdb445424acc59b465bc697..a60b8405f046119baeb0a8af1f8a2af4444595fd 100644 (file)
@@ -2216,8 +2216,16 @@ static void i40e_tx_enable_csum(struct sk_buff *skb, u32 tx_flags,
        struct iphdr *this_ip_hdr;
        u32 network_hdr_len;
        u8 l4_hdr = 0;
+       u32 l4_tunnel = 0;
 
        if (skb->encapsulation) {
+               switch (ip_hdr(skb)->protocol) {
+               case IPPROTO_UDP:
+                       l4_tunnel = I40E_TXD_CTX_UDP_TUNNELING;
+                       break;
+               default:
+                       return;
+               }
                network_hdr_len = skb_inner_network_header_len(skb);
                this_ip_hdr = inner_ip_hdr(skb);
                this_ipv6_hdr = inner_ipv6_hdr(skb);
@@ -2240,8 +2248,8 @@ static void i40e_tx_enable_csum(struct sk_buff *skb, u32 tx_flags,
 
                /* Now set the ctx descriptor fields */
                *cd_tunneling |= (skb_network_header_len(skb) >> 2) <<
-                                       I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT |
-                                  I40E_TXD_CTX_UDP_TUNNELING            |
+                                  I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT      |
+                                  l4_tunnel                             |
                                   ((skb_inner_network_offset(skb) -
                                        skb_transport_offset(skb)) >> 1) <<
                                   I40E_TXD_CTX_QW0_NATLEN_SHIFT;
index 021b0d4d8a355c8e3a441f91b1126cc09d5637d5..1c2637b287282dada116ded96981969455722123 100644 (file)
@@ -1461,8 +1461,16 @@ static void i40e_tx_enable_csum(struct sk_buff *skb, u32 tx_flags,
        struct iphdr *this_ip_hdr;
        u32 network_hdr_len;
        u8 l4_hdr = 0;
+       u32 l4_tunnel = 0;
 
        if (skb->encapsulation) {
+               switch (ip_hdr(skb)->protocol) {
+               case IPPROTO_UDP:
+                       l4_tunnel = I40E_TXD_CTX_UDP_TUNNELING;
+                       break;
+               default:
+                       return;
+               }
                network_hdr_len = skb_inner_network_header_len(skb);
                this_ip_hdr = inner_ip_hdr(skb);
                this_ipv6_hdr = inner_ipv6_hdr(skb);
@@ -1485,8 +1493,8 @@ static void i40e_tx_enable_csum(struct sk_buff *skb, u32 tx_flags,
 
                /* Now set the ctx descriptor fields */
                *cd_tunneling |= (skb_network_header_len(skb) >> 2) <<
-                                       I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT |
-                                  I40E_TXD_CTX_UDP_TUNNELING            |
+                                  I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT      |
+                                  l4_tunnel                             |
                                   ((skb_inner_network_offset(skb) -
                                        skb_transport_offset(skb)) >> 1) <<
                                   I40E_TXD_CTX_QW0_NATLEN_SHIFT;