The two flags by default are enabled, but sometimes we want to know the 
performance influence due to encapsulation and decapsulation operations, and
I think we should add the two options. 

Signed-off-by: Jijiang Liu <jijiang.liu at intel.com>
---
 examples/tep_termination/main.c        |   36 ++++++++++++++++++++++++++++++-
 examples/tep_termination/vxlan_setup.c |    8 +++++-
 2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index 8ce78ee..7d021f9 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -125,6 +125,12 @@ uint8_t tx_checksum;
 /* TSO segment size */
 uint16_t tso_segsz = 0;

+/* enable/disable decapsulation */
+uint8_t rx_decap = 1;
+
+/* enable/disable encapsulation */
+uint8_t tx_encap = 1;
+
 /* RX filter type for tunneling packet */
 uint8_t filter_idx;

@@ -250,6 +256,8 @@ vep_termination_usage(const char *prgname)
        "               --nb-devices: number of virtIO device\n"
        "               --tx-checksum [0|1]: inner Tx checksum offload\n"
        "               --tso-segsz [0-N]: TSO segment size\n"
+       "               --decap [0|1]: Decapsulation for tunneling packet\n"
+       "               --encap [0|1]: Encapsulation for tunneling packet\n"
        "               --filter-type[1-3]: filter type for tunneling packet\n"
        "                   1: Inner MAC&VLAN and tenent ID\n"
        "                   2: Inner MAC and tenent ID\n"
@@ -276,6 +284,8 @@ tep_parse_args(int argc, char **argv)
                {"nb-devices", required_argument, NULL, 0},
                {"tx-checksum", required_argument, NULL, 0},
                {"tso-segsz", required_argument, NULL, 0},
+               {"decap", required_argument, NULL, 0},
+               {"encap", required_argument, NULL, 0},
                {"filter-type", required_argument, NULL, 0},
                {"stats", required_argument, NULL, 0},
                {"dev-basename", required_argument, NULL, 0},
@@ -325,8 +335,30 @@ tep_parse_args(int argc, char **argv)
                                        return -1;
                                }
                        }
-                       
-                       if (!strncmp(long_option[option_index].name, 
"tx-checksum", MAX_LONG_OPT_SZ)) {
+
+                       /* Enable/disable encapsulation on RX. */
+                       if (!strncmp(long_option[option_index].name, "decap", 
MAX_LONG_OPT_SZ)) {
+                               ret = parse_num_opt(optarg, 1);
+                               if (ret == -1) {
+                                       RTE_LOG(INFO, VHOST_CONFIG, "Invalid 
argument for decapsulation [0|1]\n");
+                                       vep_termination_usage(prgname);
+                                       return -1;
+                               } else
+                                       rx_decap = ret;
+                       }
+
+                       /* Enable/disable encapsulation on TX. */
+                       if (!strncmp(long_option[option_index].name, "encap", 
MAX_LONG_OPT_SZ)) {
+                               ret = parse_num_opt(optarg, 1);
+                               if (ret == -1) {
+                                       RTE_LOG(INFO, VHOST_CONFIG, "Invalid 
argument for encapsulation [0|1]\n");
+                                       vep_termination_usage(prgname);
+                                       return -1;
+                               } else
+                                       tx_encap = ret;
+                       }
+
+                        if (!strncmp(long_option[option_index].name, 
"tx-checksum", MAX_LONG_OPT_SZ)) {
                                ret = parse_num_opt(optarg, 1);
                                if (ret == -1) {
                                        RTE_LOG(INFO, VHOST_CONFIG, "Invalid 
argument for tx-checksum [0|1]\n");
diff --git a/examples/tep_termination/vxlan_setup.c 
b/examples/tep_termination/vxlan_setup.c
index 312a878..b4e8fbc 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -83,6 +83,8 @@ extern uint16_t num_devices;
 extern uint16_t udp_port;
 extern uint8_t ports[RTE_MAX_ETHPORTS];
 extern uint8_t filter_idx;
+extern uint8_t rx_decap;
+extern uint8_t tx_encap;

 /* ethernet addresses of ports */
 extern struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
@@ -237,7 +239,8 @@ vxlan_rx_process(struct rte_mbuf *pkt)
                | PKT_RX_TUNNEL_IPV6_HDR)) == 0)
                return -1;

-       ret = decapsulation(pkt);
+       if(rx_decap)
+               ret = decapsulation(pkt);

        return ret;
 }
@@ -252,7 +255,8 @@ vxlan_tx_process(uint8_t vport_id, struct rte_mbuf *pkt)
                return -1;
        }

-       ret = encapsulation(pkt, vport_id);
+       if (tx_encap)
+               ret = encapsulation(pkt, vport_id);

        return ret;
 }
-- 
1.7.7.6

Reply via email to