Add command to call rte_pmd_i40e_set_vf_broadcast.
Add set vf broadcast in testpmd_funcs.rst file.

Signed-off-by: Bernard Iremonger <bernard.iremon...@intel.com>
---
 app/test-pmd/cmdline.c                      | 84 +++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  7 +++
 2 files changed, 91 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index fa60086..56d275b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -279,6 +279,11 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "    Set MAC antispoof for a VF from the PF.\n\n"
 #endif
 
+#ifdef RTE_LIBRTE_I40E_PMD
+                       "set vf broadcast (port_id) (vf_id) (on|off)\n"
+                       "    Set VF broadcast for a VF from the PF.\n\n"
+#endif
+
                        "vlan set strip (on|off) (port_id)\n"
                        "    Set the VLAN strip on a port.\n\n"
 
@@ -11655,6 +11660,84 @@ struct cmd_vf_multicast_promisc_result {
                NULL,
        },
 };
+
+/* vf broadcast mode configuration */
+
+/* Common result structure for vf broadcast */
+struct cmd_set_vf_broadcast_result {
+       cmdline_fixed_string_t set;
+       cmdline_fixed_string_t vf;
+       cmdline_fixed_string_t broadcast;
+       uint8_t port_id;
+       uint16_t vf_id;
+       cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for vf broadcast enable disable */
+cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_set_vf_broadcast_result,
+                set, "set");
+cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_set_vf_broadcast_result,
+                vf, "vf");
+cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_set_vf_broadcast_result,
+                broadcast, "broadcast");
+cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
+       TOKEN_NUM_INITIALIZER
+               (struct cmd_set_vf_broadcast_result,
+                port_id, UINT8);
+cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
+       TOKEN_NUM_INITIALIZER
+               (struct cmd_set_vf_broadcast_result,
+                vf_id, UINT16);
+cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_set_vf_broadcast_result,
+                on_off, "on#off");
+
+static void
+cmd_set_vf_broadcast_parsed(
+       void *parsed_result,
+       __attribute__((unused)) struct cmdline *cl,
+       __attribute__((unused)) void *data)
+{
+       struct cmd_set_vf_broadcast_result *res = parsed_result;
+       int ret;
+       int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+       ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, res->vf_id, is_on);
+       switch (ret) {
+       case 0:
+               break;
+       case -EINVAL:
+               printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
+               break;
+       case -ENODEV:
+               printf("invalid port_id %d\n", res->port_id);
+               break;
+       default:
+               printf("programming error: (%s)\n", strerror(-ret));
+       }
+}
+
+cmdline_parse_inst_t cmd_set_vf_broadcast = {
+       .f = cmd_set_vf_broadcast_parsed,
+       .data = NULL,
+       .help_str = "set vf broadcast port_id vf_id on|off",
+       .tokens = {
+               (void *)&cmd_set_vf_broadcast_set,
+               (void *)&cmd_set_vf_broadcast_vf,
+               (void *)&cmd_set_vf_broadcast_broadcast,
+               (void *)&cmd_set_vf_broadcast_port_id,
+               (void *)&cmd_set_vf_broadcast_vf_id,
+               (void *)&cmd_set_vf_broadcast_on_off,
+               NULL,
+       },
+};
 #endif
 
 /* 
********************************************************************************
 */
@@ -11826,6 +11909,7 @@ struct cmd_vf_multicast_promisc_result {
 #ifdef RTE_LIBRTE_I40E_PMD
        (cmdline_parse_inst_t *)&cmd_set_vf_unicast_promisc,
        (cmdline_parse_inst_t *)&cmd_set_vf_multicast_promisc,
+       (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
 #endif
        NULL,
 };
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst 
b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index e1545b7..525d0df 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -507,6 +507,13 @@ Set mac antispoof for a VF from the PF::
 
    testpmd> set vf mac antispoof  (port_id) (vf_id) (on|off)
 
+set broadcast mode (for VF)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Set broadcast mode for a VF from the PF::
+
+   testpmd> set vf broadcast (port_id) (vf_id) (on|off)
+
 vlan set strip
 ~~~~~~~~~~~~~~
 
-- 
1.9.3

Reply via email to