qede: GSO support for tunnels with outer csum
authorManish Chopra <manish.chopra@caviumnetworks.com>
Fri, 14 Oct 2016 09:19:18 +0000 (05:19 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 14 Oct 2016 15:59:58 +0000 (11:59 -0400)
This patch adds GSO support for GRE and UDP tunnels
where outer checksums are enabled.

Signed-off-by: Manish Chopra <manish.chopra@caviumnetworks.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@caviumnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qede/qede.h
drivers/net/ethernet/qlogic/qede/qede_main.c

index 28c0e9f42c9e777611ab085249a2efc74201a6e6..f50e5270ad3044c97b387ec9187bac5d651caa81 100644 (file)
@@ -320,6 +320,7 @@ struct qede_fastpath {
 #define XMIT_L4_CSUM           BIT(0)
 #define XMIT_LSO               BIT(1)
 #define XMIT_ENC               BIT(2)
+#define XMIT_ENC_GSO_L4_CSUM   BIT(3)
 
 #define QEDE_CSUM_ERROR                        BIT(0)
 #define QEDE_CSUM_UNNECESSARY          BIT(1)
index 9866d952e3e14049c1a02986e34d70e015afbf11..7d5dc1e15fc44e29f2f4a21d46170ebd6d28f5c2 100644 (file)
@@ -400,8 +400,19 @@ static u32 qede_xmit_type(struct qede_dev *edev,
            (ipv6_hdr(skb)->nexthdr == NEXTHDR_IPV6))
                *ipv6_ext = 1;
 
-       if (skb->encapsulation)
+       if (skb->encapsulation) {
                rc |= XMIT_ENC;
+               if (skb_is_gso(skb)) {
+                       unsigned short gso_type = skb_shinfo(skb)->gso_type;
+
+                       if ((gso_type & SKB_GSO_UDP_TUNNEL_CSUM) ||
+                           (gso_type & SKB_GSO_GRE_CSUM))
+                               rc |= XMIT_ENC_GSO_L4_CSUM;
+
+                       rc |= XMIT_LSO;
+                       return rc;
+               }
+       }
 
        if (skb_is_gso(skb))
                rc |= XMIT_LSO;
@@ -637,6 +648,12 @@ static netdev_tx_t qede_start_xmit(struct sk_buff *skb,
                if (unlikely(xmit_type & XMIT_ENC)) {
                        first_bd->data.bd_flags.bitfields |=
                                1 << ETH_TX_1ST_BD_FLAGS_TUNN_IP_CSUM_SHIFT;
+
+                       if (xmit_type & XMIT_ENC_GSO_L4_CSUM) {
+                               u8 tmp = ETH_TX_1ST_BD_FLAGS_TUNN_L4_CSUM_SHIFT;
+
+                               first_bd->data.bd_flags.bitfields |= 1 << tmp;
+                       }
                        hlen = qede_get_skb_hlen(skb, true);
                } else {
                        first_bd->data.bd_flags.bitfields |=
@@ -2320,11 +2337,14 @@ static void qede_init_ndev(struct qede_dev *edev)
 
        /* Encap features*/
        hw_features |= NETIF_F_GSO_GRE | NETIF_F_GSO_UDP_TUNNEL |
-                      NETIF_F_TSO_ECN;
+                      NETIF_F_TSO_ECN | NETIF_F_GSO_UDP_TUNNEL_CSUM |
+                      NETIF_F_GSO_GRE_CSUM;
        ndev->hw_enc_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
                                NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO_ECN |
                                NETIF_F_TSO6 | NETIF_F_GSO_GRE |
-                               NETIF_F_GSO_UDP_TUNNEL | NETIF_F_RXCSUM;
+                               NETIF_F_GSO_UDP_TUNNEL | NETIF_F_RXCSUM |
+                               NETIF_F_GSO_UDP_TUNNEL_CSUM |
+                               NETIF_F_GSO_GRE_CSUM;
 
        ndev->vlan_features = hw_features | NETIF_F_RXHASH | NETIF_F_RXCSUM |
                              NETIF_F_HIGHDMA;