Add testpmd CLI to set VF unicast promiscuous mode on i40e. Signed-off-by: Wenzhuo Lu <wenzhuo...@intel.com> --- app/test-pmd/cmdline.c | 92 +++++++++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 +++ 2 files changed, 100 insertions(+)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 12126ce..d39712e 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -404,6 +404,11 @@ static void cmd_help_long_parsed(void *parsed_result, "set allmulti (port_id|all) (on|off)\n" " Set the allmulti mode on port_id, or all.\n\n" +#ifdef RTE_LIBRTE_I40E_PMD + "set vf unicast-promisc (port_id) (vf_id) (on|off)\n" + " Set unicast promiscuous mode for a VF from the PF.\n\n" +#endif + "set flow_ctrl rx (on|off) tx (on|off) (high_water)" " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" " (on|off) autoneg (on|off) (port_id)\n" @@ -11489,6 +11494,90 @@ struct cmd_set_vf_mac_addr_result { }; #endif +#ifdef RTE_LIBRTE_I40E_PMD +/* VF unicast promiscuous mode configuration */ + +/* Common result structure for VF unicast promiscuous mode */ +struct cmd_vf_unicast_promisc_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t vf; + cmdline_fixed_string_t unicast_promisc; + uint8_t port_id; + uint32_t vf_id; + cmdline_fixed_string_t on_off; +}; + +/* Common CLI fields for VF unicast promiscuous mode enable disable */ +cmdline_parse_token_string_t cmd_vf_unicast_promisc_set = + TOKEN_STRING_INITIALIZER + (struct cmd_vf_unicast_promisc_result, + set, "set"); +cmdline_parse_token_string_t cmd_vf_unicast_promisc_vf = + TOKEN_STRING_INITIALIZER + (struct cmd_vf_unicast_promisc_result, + vf, "vf"); +cmdline_parse_token_string_t cmd_vf_unicast_promisc_unicast_promisc = + TOKEN_STRING_INITIALIZER + (struct cmd_vf_unicast_promisc_result, + unicast_promisc, "unicast-promisc"); +cmdline_parse_token_num_t cmd_vf_unicast_promisc_port_id = + TOKEN_NUM_INITIALIZER + (struct cmd_vf_unicast_promisc_result, + port_id, UINT8); +cmdline_parse_token_num_t cmd_vf_unicast_promisc_vf_id = + TOKEN_NUM_INITIALIZER + (struct cmd_vf_unicast_promisc_result, + vf_id, UINT32); +cmdline_parse_token_string_t cmd_vf_unicast_promisc_on_off = + TOKEN_STRING_INITIALIZER + (struct cmd_vf_unicast_promisc_result, + on_off, "on#off"); + +static void +cmd_set_vf_unicast_promisc_parsed( + void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_vf_unicast_promisc_result *res = parsed_result; + int ret = 0; + int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + + ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, + res->vf_id, is_on); + switch (ret) { + case 0: + break; + case -EINVAL: + printf("invalid vf_id %d\n", res->vf_id); + 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_unicast_promisc = { + .f = cmd_set_vf_unicast_promisc_parsed, + .data = NULL, + .help_str = "set vf unicast promiscuous port_id vf_id on|off", + .tokens = { + (void *)&cmd_vf_unicast_promisc_set, + (void *)&cmd_vf_unicast_promisc_vf, + (void *)&cmd_vf_unicast_promisc_unicast_promisc, + (void *)&cmd_vf_unicast_promisc_port_id, + (void *)&cmd_vf_unicast_promisc_vf_id, + (void *)&cmd_vf_unicast_promisc_on_off, + NULL, + }, +}; +#endif + /* ******************************************************************************** */ /* list of instructions */ @@ -11655,6 +11744,9 @@ struct cmd_set_vf_mac_addr_result { (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, #endif +#ifdef RTE_LIBRTE_I40E_PMD + (cmdline_parse_inst_t *)&cmd_set_vf_unicast_promisc, +#endif NULL, }; diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index f1c269a..e17e3d5 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -820,6 +820,14 @@ Set the allmulti mode for a port or for all ports:: Same as the ifconfig (8) option. Controls how multicast packets are handled. +set unicast promisc (for VF) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Set the unicast promiscuous mode for a VF from PF. +In promiscuous mode packets are not dropped if they aren't for the specified MAC address:: + + testpmd> set vf unicast-promisc (port_id) (vf_id) (on|off) + set flow_ctrl rx ~~~~~~~~~~~~~~~~ -- 1.9.3