i40e/i40evf: Refactor tunnel interpretation
authorJesse Brandeburg <jesse.brandeburg@intel.com>
Mon, 18 Apr 2016 18:33:41 +0000 (11:33 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Fri, 6 May 2016 01:24:10 +0000 (18:24 -0700)
Refactor the interpretation of a tunnel.  This removes
some code and lets us start using the hardware's parsing.

Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@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 2765d7efdd9c621d1c26ae8538c85673af1ec7bb..dab733c5343d576c02081c3ed7f8ebb98ba0dd9e 100644 (file)
@@ -1392,7 +1392,7 @@ static inline void i40e_rx_checksum(struct i40e_vsi *vsi,
                                    u16 rx_ptype)
 {
        struct i40e_rx_ptype_decoded decoded = decode_rx_desc_ptype(rx_ptype);
-       bool ipv4, ipv6, ipv4_tunnel, ipv6_tunnel;
+       bool ipv4, ipv6, tunnel = false;
 
        skb->ip_summed = CHECKSUM_NONE;
 
@@ -1441,14 +1441,13 @@ static inline void i40e_rx_checksum(struct i40e_vsi *vsi,
         * doesn't make it a hard requirement so if we have validated the
         * inner checksum report CHECKSUM_UNNECESSARY.
         */
-
-       ipv4_tunnel = (rx_ptype >= I40E_RX_PTYPE_GRENAT4_MAC_PAY3) &&
-                    (rx_ptype <= I40E_RX_PTYPE_GRENAT4_MACVLAN_IPV6_ICMP_PAY4);
-       ipv6_tunnel = (rx_ptype >= I40E_RX_PTYPE_GRENAT6_MAC_PAY3) &&
-                    (rx_ptype <= I40E_RX_PTYPE_GRENAT6_MACVLAN_IPV6_ICMP_PAY4);
+       if (decoded.inner_prot & (I40E_RX_PTYPE_INNER_PROT_TCP |
+                                 I40E_RX_PTYPE_INNER_PROT_UDP |
+                                 I40E_RX_PTYPE_INNER_PROT_SCTP))
+               tunnel = true;
 
        skb->ip_summed = CHECKSUM_UNNECESSARY;
-       skb->csum_level = ipv4_tunnel || ipv6_tunnel;
+       skb->csum_level = tunnel ? 1 : 0;
 
        return;
 
index ede8dfc189bcc5597e1fabb4e77cd6855807b995..a37a3f34ed4f35e8884d30fae18553c600426e61 100644 (file)
@@ -864,7 +864,7 @@ static inline void i40e_rx_checksum(struct i40e_vsi *vsi,
                                    u16 rx_ptype)
 {
        struct i40e_rx_ptype_decoded decoded = decode_rx_desc_ptype(rx_ptype);
-       bool ipv4, ipv6, ipv4_tunnel, ipv6_tunnel;
+       bool ipv4, ipv6, tunnel = false;
 
        skb->ip_summed = CHECKSUM_NONE;
 
@@ -913,14 +913,13 @@ static inline void i40e_rx_checksum(struct i40e_vsi *vsi,
         * doesn't make it a hard requirement so if we have validated the
         * inner checksum report CHECKSUM_UNNECESSARY.
         */
-
-       ipv4_tunnel = (rx_ptype >= I40E_RX_PTYPE_GRENAT4_MAC_PAY3) &&
-                    (rx_ptype <= I40E_RX_PTYPE_GRENAT4_MACVLAN_IPV6_ICMP_PAY4);
-       ipv6_tunnel = (rx_ptype >= I40E_RX_PTYPE_GRENAT6_MAC_PAY3) &&
-                    (rx_ptype <= I40E_RX_PTYPE_GRENAT6_MACVLAN_IPV6_ICMP_PAY4);
+       if (decoded.inner_prot & (I40E_RX_PTYPE_INNER_PROT_TCP |
+                                 I40E_RX_PTYPE_INNER_PROT_UDP |
+                                 I40E_RX_PTYPE_INNER_PROT_SCTP))
+               tunnel = true;
 
        skb->ip_summed = CHECKSUM_UNNECESSARY;
-       skb->csum_level = ipv4_tunnel || ipv6_tunnel;
+       skb->csum_level = tunnel ? 1 : 0;
 
        return;