gso: support VxLAN GSO
[dpdk.git] / lib / librte_gso / rte_gso.c
index 822693f..0a3ef11 100644 (file)
@@ -39,6 +39,7 @@
 #include "rte_gso.h"
 #include "gso_common.h"
 #include "gso_tcp4.h"
+#include "gso_tunnel_tcp4.h"
 
 int
 rte_gso_segment(struct rte_mbuf *pkt,
@@ -56,7 +57,8 @@ rte_gso_segment(struct rte_mbuf *pkt,
        if (pkt == NULL || pkts_out == NULL || gso_ctx == NULL ||
                        nb_pkts_out < 1 ||
                        gso_ctx->gso_size < RTE_GSO_SEG_SIZE_MIN ||
-                       gso_ctx->gso_types != DEV_TX_OFFLOAD_TCP_TSO)
+                       ((gso_ctx->gso_types & (DEV_TX_OFFLOAD_TCP_TSO |
+                       DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) == 0))
                return -EINVAL;
 
        if (gso_ctx->gso_size >= pkt->pkt_len) {
@@ -71,12 +73,20 @@ rte_gso_segment(struct rte_mbuf *pkt,
        ipid_delta = (gso_ctx->flag != RTE_GSO_FLAG_IPID_FIXED);
        ol_flags = pkt->ol_flags;
 
-       if (IS_IPV4_TCP(pkt->ol_flags)) {
+       if (IS_IPV4_VXLAN_TCP4(pkt->ol_flags)
+               && (gso_ctx->gso_types & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) {
+               pkt->ol_flags &= (~PKT_TX_TCP_SEG);
+               ret = gso_tunnel_tcp4_segment(pkt, gso_size, ipid_delta,
+                               direct_pool, indirect_pool,
+                               pkts_out, nb_pkts_out);
+       } else if (IS_IPV4_TCP(pkt->ol_flags) &&
+                       (gso_ctx->gso_types & DEV_TX_OFFLOAD_TCP_TSO)) {
                pkt->ol_flags &= (~PKT_TX_TCP_SEG);
                ret = gso_tcp4_segment(pkt, gso_size, ipid_delta,
                                direct_pool, indirect_pool,
                                pkts_out, nb_pkts_out);
        } else {
+               /* unsupported packet, skip */
                pkts_out[0] = pkt;
                RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
                return 1;