From: Vivek Sharma <viveksha...@marvell.com>

Support QinQ strip RX offload configuration through
testpmd command line and boot time arguments.

Signed-off-by: Vivek Sharma <viveksha...@marvell.com>
---
 app/test-pmd/cmdline.c                      | 24 ++++++++++++++-----
 app/test-pmd/config.c                       | 36 +++++++++++++++++++++++++++--
 app/test-pmd/parameters.c                   |  6 +++++
 app/test-pmd/testpmd.h                      |  1 +
 doc/guides/testpmd_app_ug/run_app.rst       |  4 ++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 14 ++++++++++-
 6 files changed, 76 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 2a92ea1..04d7773 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -802,7 +802,7 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "    Set the max packet length.\n\n"
 
                        "port config all 
(crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
-                       "hw-vlan-strip|hw-vlan-extend|drop-en)"
+                       "hw-vlan-strip|hw-vlan-extend|hw-qinq-strip|drop-en)"
                        " (on|off)\n"
                        "    Set 
crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
                        " for ports.\n\n"
@@ -2133,6 +2133,15 @@ cmd_config_rx_mode_flag_parsed(void *parsed_result,
                                printf("Unknown parameter\n");
                                return;
                        }
+               } else if (!strcmp(res->name, "hw-qinq-strip")) {
+                       if (!strcmp(res->value, "on"))
+                               rx_offloads |= DEV_RX_OFFLOAD_QINQ_STRIP;
+                       else if (!strcmp(res->value, "off"))
+                               rx_offloads &= ~DEV_RX_OFFLOAD_QINQ_STRIP;
+                       else {
+                               printf("Unknown parameter\n");
+                               return;
+                       }
                } else if (!strcmp(res->name, "drop-en")) {
                        if (!strcmp(res->value, "on"))
                                rx_drop_en = 1;
@@ -2164,7 +2173,8 @@ cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
        TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
                                        
"crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
-                                       
"hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
+                                       
"hw-vlan-filter#hw-vlan-strip#hw-vlan-extend#"
+                                       "hw-qinq-strip");
 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
        TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
                                                        "on#off");
@@ -2173,7 +2183,7 @@ cmdline_parse_inst_t cmd_config_rx_mode_flag = {
        .f = cmd_config_rx_mode_flag_parsed,
        .data = NULL,
        .help_str = "port config all 
crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
-               "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
+               "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend|hw-qinq-strip 
on|off",
        .tokens = {
                (void *)&cmd_config_rx_mode_flag_port,
                (void *)&cmd_config_rx_mode_flag_keyword,
@@ -3926,6 +3936,8 @@ cmd_vlan_offload_parsed(void *parsed_result,
        }
        else if (!strcmp(res->what, "filter"))
                rx_vlan_filter_set(port_id, on);
+       else if (!strcmp(res->what, "qinq"))
+               rx_vlan_qinq_strip_set(port_id, on);
        else
                vlan_extend_set(port_id, on);
 
@@ -3940,7 +3952,7 @@ cmdline_parse_token_string_t cmd_vlan_offload_set =
                                 set, "set");
 cmdline_parse_token_string_t cmd_vlan_offload_what =
        TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
-                                what, "strip#filter#qinq#stripq");
+                                what, "strip#filter#extend#qinq#stripq");
 cmdline_parse_token_string_t cmd_vlan_offload_on =
        TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
                              on, "on#off");
@@ -3951,9 +3963,9 @@ cmdline_parse_token_string_t cmd_vlan_offload_portid =
 cmdline_parse_inst_t cmd_vlan_offload = {
        .f = cmd_vlan_offload_parsed,
        .data = NULL,
-       .help_str = "vlan set strip|filter|qinq|stripq on|off "
+       .help_str = "vlan set strip|filter|extend|qinq|stripq on|off "
                "<port_id[,queue_id]>: "
-               "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
+               "Filter/Strip/QinQ strip for rx side extend for both rx/tx 
sides",
        .tokens = {
                (void *)&cmd_vlan_offload_vlan,
                (void *)&cmd_vlan_offload_set,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index ab458c8..8024584 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -458,9 +458,14 @@ port_infos_display(portid_t port_id)
                        printf("  filter off \n");
 
                if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)
-                       printf("  qinq(extend) on \n");
+                       printf("  extend on\n");
                else
-                       printf("  qinq(extend) off \n");
+                       printf("  extend off\n");
+
+               if (vlan_offload & ETH_QINQ_STRIP_OFFLOAD)
+                       printf("  qinq strip on\n");
+               else
+                       printf("  qinq strip off\n");
        }
 
        if (dev_info.hash_key_size > 0)
@@ -2912,6 +2917,33 @@ rx_vlan_filter_set(portid_t port_id, int on)
        ports[port_id].dev_conf.rxmode.offloads = port_rx_offloads;
 }
 
+void
+rx_vlan_qinq_strip_set(portid_t port_id, int on)
+{
+       int diag;
+       int vlan_offload;
+       uint64_t port_rx_offloads = ports[port_id].dev_conf.rxmode.offloads;
+
+       if (port_id_is_invalid(port_id, ENABLED_WARN))
+               return;
+
+       vlan_offload = rte_eth_dev_get_vlan_offload(port_id);
+
+       if (on) {
+               vlan_offload |= ETH_QINQ_STRIP_OFFLOAD;
+               port_rx_offloads |= DEV_RX_OFFLOAD_QINQ_STRIP;
+       } else {
+               vlan_offload &= ~ETH_QINQ_STRIP_OFFLOAD;
+               port_rx_offloads &= ~DEV_RX_OFFLOAD_QINQ_STRIP;
+       }
+
+       diag = rte_eth_dev_set_vlan_offload(port_id, vlan_offload);
+       if (diag < 0)
+               printf("%s(port_pi=%d, on=%d) failed "
+              "diag=%d\n", __func__, port_id, on, diag);
+       ports[port_id].dev_conf.rxmode.offloads = port_rx_offloads;
+}
+
 int
 rx_vft_set(portid_t port_id, uint16_t vlan_id, int on)
 {
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 245b610..214f25c 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -139,6 +139,7 @@ usage(char* progname)
        printf("  --enable-hw-vlan-filter: enable hardware vlan filter.\n");
        printf("  --enable-hw-vlan-strip: enable hardware vlan strip.\n");
        printf("  --enable-hw-vlan-extend: enable hardware vlan extend.\n");
+       printf("  --enable-hw-qinq-strip: enable hardware qinq strip.\n");
        printf("  --enable-drop-en: enable per queue packet drop.\n");
        printf("  --disable-rss: disable rss.\n");
        printf("  --port-topology=N: set port topology (N: paired (default) or "
@@ -611,6 +612,7 @@ launch_args_parse(int argc, char** argv)
                { "enable-hw-vlan-filter",      0, 0, 0 },
                { "enable-hw-vlan-strip",       0, 0, 0 },
                { "enable-hw-vlan-extend",      0, 0, 0 },
+               { "enable-hw-qinq-strip",       0, 0, 0 },
                { "enable-drop-en",            0, 0, 0 },
                { "disable-rss",                0, 0, 0 },
                { "port-topology",              1, 0, 0 },
@@ -1001,6 +1003,10 @@ launch_args_parse(int argc, char** argv)
                                        "enable-hw-vlan-extend"))
                                rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
 
+                       if (!strcmp(lgopts[opt_idx].name,
+                                       "enable-hw-qinq-strip"))
+                               rx_offloads |= DEV_RX_OFFLOAD_QINQ_STRIP;
+
                        if (!strcmp(lgopts[opt_idx].name, "enable-drop-en"))
                                rx_drop_en = 1;
 
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index e3a6f7c..ab9e9fd 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -748,6 +748,7 @@ void rx_vlan_strip_set_on_queue(portid_t port_id, uint16_t 
queue_id, int on);
 
 void rx_vlan_filter_set(portid_t port_id, int on);
 void rx_vlan_all_filter_set(portid_t port_id, int on);
+void rx_vlan_qinq_strip_set(portid_t port_id, int on);
 int rx_vft_set(portid_t port_id, uint16_t vlan_id, int on);
 void vlan_extend_set(portid_t port_id, int on);
 void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
diff --git a/doc/guides/testpmd_app_ug/run_app.rst 
b/doc/guides/testpmd_app_ug/run_app.rst
index e7db520..e6b48f0 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -198,6 +198,10 @@ The command line options are:
 
     Enable hardware VLAN extend.
 
+*   ``--enable-hw-qinq-strip``
+
+    Enable hardware QINQ strip.
+
 *   ``--enable-drop-en``
 
     Enable per-queue packet drop for packets with no descriptors.
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst 
b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index cb83a3c..996cc3a 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -200,7 +200,8 @@ For example:
    VLAN offload:
        strip on
        filter on
-       qinq(extend) off
+       extend off
+       qinq off
    Redirection table size: 512
    Supported flow types:
      ipv4-frag
@@ -2129,6 +2130,17 @@ Hardware VLAN extend is off by default.
 
 The ``on`` option is equivalent to the ``--enable-hw-vlan-extend`` 
command-line option.
 
+port config - QINQ strip
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+Set hardware QINQ strip on or off for all ports::
+
+   testpmd> port config all hw-qinq-strip (on|off)
+
+Hardware QINQ strip is off by default.
+
+The ``on`` option is equivalent to the ``--enable-hw-qinq-strip`` command-line 
option.
+
 port config - Drop Packets
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.7.4

Reply via email to