Presently, Rx metadata is sent to PMD by default, leading
to a performance drop as processing for the same in Rx path
takes extra cycles.

Hence, add new testpmd command,
  'enable port <port_id> nic_to_pmd_rx_metadata'

This command helps in sending Rx metadata to PMD and thereby
Rx metadata flow command requests are processed.

Signed-off-by: Hanumanth Pothula <hpoth...@marvell.com>
---
 app/test-pmd/cmdline.c                      | 58 +++++++++++++++++++++
 app/test-pmd/config.c                       |  9 ++++
 app/test-pmd/testpmd.c                      |  5 +-
 app/test-pmd/testpmd.h                      |  1 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  6 +++
 5 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b32dc8bfd4..e3abc9e830 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -610,6 +610,9 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "set port (port_id) fec_mode auto|off|rs|baser\n"
                        "    set fec mode for a specific port\n\n"
 
+                       "enable port <port_id> nic_to_pmd_rx_metadata"
+                       "    Allow nic to pmd Rx metadata negotiation\n\n"
+
                        , list_pkt_forwarding_modes()
                );
        }
@@ -12621,6 +12624,60 @@ static cmdline_parse_inst_t 
cmd_show_port_flow_transfer_proxy = {
        }
 };
 
+/* Allow negotiating Rx metadata between NIC and PMD */
+struct cmd_config_port_rx_metadata {
+       cmdline_fixed_string_t enable;
+       cmdline_fixed_string_t port;
+       uint16_t port_id;
+       cmdline_fixed_string_t nic_to_pmd_rx_metadata;
+};
+
+static void
+cmd_config_port_rx_metadata_parsed(void *parsed_result,
+                               __rte_unused struct cmdline *cl,
+                               __rte_unused void *data)
+{
+       struct cmd_config_port_rx_metadata *res = parsed_result;
+
+       if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+               return;
+       if (!port_is_stopped(res->port_id)) {
+               fprintf(stderr, "Please stop port %u first\n", res->port_id);
+               return;
+       }
+
+       ports[res->port_id].nic_to_pmd_rx_metadata = 1;
+
+       reset_port(res->port_id);
+}
+
+
+static cmdline_parse_token_string_t cmd_config_port_rx_metadata_enable =
+       TOKEN_STRING_INITIALIZER(struct cmd_config_port_rx_metadata, enable,
+                                                               "enable");
+static cmdline_parse_token_string_t cmd_config_port_rx_metadata_port =
+       TOKEN_STRING_INITIALIZER(struct cmd_config_port_rx_metadata, port,
+                                                               "port");
+static cmdline_parse_token_num_t cmd_config_port_rx_metadata_id =
+       TOKEN_NUM_INITIALIZER(struct cmd_config_port_rx_metadata, port_id,
+                                                               RTE_UINT16);
+static cmdline_parse_token_string_t 
cmd_config_port_rx_metadata_nic_to_pmd_rx_metadata =
+       TOKEN_STRING_INITIALIZER(struct cmd_config_port_rx_metadata, 
nic_to_pmd_rx_metadata,
+                                                               
"nic_to_pmd_rx_metadata");
+
+static cmdline_parse_inst_t cmd_config_port_rx_metadata_parse = {
+       .f = cmd_config_port_rx_metadata_parsed,
+       .data = NULL,
+       .help_str = "enable port <port_id> nic_to_pmd_rx_metadata",
+       .tokens = {
+               (void *)&cmd_config_port_rx_metadata_enable,
+               (void *)&cmd_config_port_rx_metadata_port,
+               (void *)&cmd_config_port_rx_metadata_id,
+               (void *)&cmd_config_port_rx_metadata_nic_to_pmd_rx_metadata,
+               NULL,
+       },
+};
+
 /* 
********************************************************************************
 */
 
 /* list of instructions */
@@ -12851,6 +12908,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_show_capability,
        (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
        (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
+       (cmdline_parse_inst_t *)&cmd_config_port_rx_metadata_parse,
        NULL,
 };
 
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index acccb6b035..60df47407e 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -3249,6 +3249,15 @@ port_flow_create(portid_t port_id,
                }
                id = port->flow_list->id + 1;
        }
+
+       if (port->nic_to_pmd_rx_metadata == 0 &&
+          (actions->type == RTE_FLOW_ACTION_TYPE_MARK ||
+           actions->type == RTE_FLOW_ACTION_TYPE_FLAG)) {
+               fprintf(stderr,
+                       "rx metadata is not negotiated with PMD\n");
+               return -EINVAL;
+       }
+
        if (tunnel_ops->enabled) {
                pft = port_flow_tunnel_offload_cmd_prep(port_id, pattern,
                                                        actions, tunnel_ops);
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 134d79a555..66d5a2634a 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1604,8 +1604,6 @@ init_config_port_offloads(portid_t pid, uint32_t 
socket_id)
        int ret;
        int i;
 
-       eth_rx_metadata_negotiate_mp(pid);
-
        port->dev_conf.txmode = tx_mode;
        port->dev_conf.rxmode = rx_mode;
 
@@ -2946,6 +2944,9 @@ start_port(portid_t pid)
                                port->update_conf = 0;
                        }
 
+                       if (port->nic_to_pmd_rx_metadata)
+                               eth_rx_metadata_negotiate_mp(pi);
+
                        /* configure port */
                        diag = eth_dev_configure_mp(pi, nb_rxq + nb_hairpinq,
                                                     nb_txq + nb_hairpinq,
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 7d24d25970..f44756173b 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -309,6 +309,7 @@ struct rte_port {
        uint8_t                 need_setup;     /**< port just attached */
        uint8_t                 need_reconfig;  /**< need reconfiguring port or 
not */
        uint8_t                 need_reconfig_queues; /**< need reconfiguring 
queues or not */
+       uint8_t                 nic_to_pmd_rx_metadata; /**< send rx metadata 
to PMD. */
        uint8_t                 rss_flag;   /**< enable rss or not */
        uint8_t                 dcb_flag;   /**< enable dcb */
        uint16_t                nb_rx_desc[RTE_MAX_QUEUES_PER_PORT+1]; /**< per 
queue rx desc number */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst 
b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 0037506a79..024dbf6012 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1558,6 +1558,12 @@ Enable or disable a per port Rx offloading on all Rx 
queues of a port::
 
 This command should be run when the port is stopped, or else it will fail.
 
+Enable Rx metadata negotiation
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Enable NIC to PMD Rx metadata negotiation::
+   testpmd> enable port <port_id> nic_to_pmd_rx_metadata
+
 config per queue Rx offloading
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.25.1

Reply via email to