[dpdk-dev,v1,3/5] app/testpmd: add command for set VF VLAN filter
Checks
Commit Message
Add the following command to testpmd:
set vf vlan filter <port_id> <vlan_id> <vf_mask> <on|off>
Add command to the testpmd user guide.
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
app/test-pmd/cmdline.c | 98 +++++++++++++++++++++++++++++
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++
2 files changed, 105 insertions(+)
Comments
On 12/9/2016 11:27 AM, Bernard Iremonger wrote:
> Add the following command to testpmd:
> set vf vlan filter <port_id> <vlan_id> <vf_mask> <on|off>
>
> Add command to the testpmd user guide.
>
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
<...>
> +
> +cmdline_parse_inst_t cmd_set_vf_vlan_filter = {
> + .f = cmd_set_vf_vlan_filter_parsed,
> + .data = NULL,
> + .help_str = "set vf vlan filter <port_id> <vlan_id> <vf_mask> <on_off>",
s/<on_off>/on|off
Only variables should be wrapped with "<>", fixed string with options
can be used as a|b|c .
similar issues in other testpmd patches.
Hi Ferruh,
> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Friday, December 9, 2016 12:03 PM
> To: Iremonger, Bernard <bernard.iremonger@intel.com>;
> thomas.monjalon@6wind.com; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v1 3/5] app/testpmd: add command for set
> VF VLAN filter
>
> On 12/9/2016 11:27 AM, Bernard Iremonger wrote:
> > Add the following command to testpmd:
> > set vf vlan filter <port_id> <vlan_id> <vf_mask> <on|off>
> >
> > Add command to the testpmd user guide.
> >
> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > ---
>
> <...>
>
> > +
> > +cmdline_parse_inst_t cmd_set_vf_vlan_filter = {
> > + .f = cmd_set_vf_vlan_filter_parsed,
> > + .data = NULL,
> > + .help_str = "set vf vlan filter <port_id> <vlan_id> <vf_mask>
> > +<on_off>",
>
> s/<on_off>/on|off
>
> Only variables should be wrapped with "<>", fixed string with options can be
> used as a|b|c .
>
> similar issues in other testpmd patches.
>
I will fix in a v2.
Regards,
Bernard.
@@ -291,6 +291,9 @@ static void cmd_help_long_parsed(void *parsed_result,
"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
" Set VLAN antispoof for a VF from the PF.\n\n"
+
+ "set vf vlan filter (port_id) (vlan_id) (vf_mask) (on|off)\n"
+ " Set VLAN filter for a VF pool from the PF.\n\n"
#endif
"vlan set filter (on|off) (port_id)\n"
@@ -11139,6 +11142,100 @@ cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
},
};
+
+/* vf vlan filter configuration */
+
+/* Common result structure for vf vlan filter */
+struct cmd_vf_vlan_filter_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t vf;
+ cmdline_fixed_string_t vlan;
+ cmdline_fixed_string_t filter;
+ uint8_t port_id;
+ uint16_t vlan_id;
+ uint16_t vf_mask;
+ cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for vf vlan filter enable disable */
+cmdline_parse_token_string_t cmd_vf_vlan_filter_set =
+ TOKEN_STRING_INITIALIZER
+ (struct cmd_vf_vlan_filter_result,
+ set, "set");
+cmdline_parse_token_string_t cmd_vf_vlan_filter_vf =
+ TOKEN_STRING_INITIALIZER
+ (struct cmd_vf_vlan_filter_result,
+ vf, "vf");
+cmdline_parse_token_string_t cmd_vf_vlan_filter_vlan =
+ TOKEN_STRING_INITIALIZER
+ (struct cmd_vf_vlan_filter_result,
+ vlan, "vlan");
+cmdline_parse_token_string_t cmd_vf_vlan_filter_filter =
+ TOKEN_STRING_INITIALIZER
+ (struct cmd_vf_vlan_filter_result,
+ filter, "filter");
+cmdline_parse_token_num_t cmd_vf_vlan_filter_port_id =
+ TOKEN_NUM_INITIALIZER
+ (struct cmd_vf_vlan_filter_result,
+ port_id, UINT8);
+cmdline_parse_token_num_t cmd_vf_vlan_filter_vlan_id =
+ TOKEN_NUM_INITIALIZER
+ (struct cmd_vf_vlan_filter_result,
+ vlan_id, UINT16);
+cmdline_parse_token_num_t cmd_vf_vlan_filter_vf_mask =
+ TOKEN_NUM_INITIALIZER
+ (struct cmd_vf_vlan_filter_result,
+ vf_mask, UINT16);
+cmdline_parse_token_string_t cmd_vf_vlan_filter_on_off =
+ TOKEN_STRING_INITIALIZER
+ (struct cmd_vf_vlan_filter_result,
+ on_off, "on#off");
+
+static void
+cmd_set_vf_vlan_filter_parsed(
+ void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+ struct cmd_vf_vlan_filter_result *res = parsed_result;
+ int ret;
+ int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+ ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, res->vlan_id, res->vf_mask, is_on);
+ switch (ret) {
+ case 0:
+ break;
+ case -EINVAL:
+ printf("invalid vf_mask %d or vlan_id %d\n", res->vf_mask, res->vlan_id);
+ break;
+ case -ENODEV:
+ printf("invalid port_id %d\n", res->port_id);
+ break;
+ case -ENOTSUP:
+ printf("not supported on vf port %d\n", res->port_id);
+ break;
+ default:
+ printf("programming error: (%s)\n", strerror(-ret));
+ }
+}
+
+cmdline_parse_inst_t cmd_set_vf_vlan_filter = {
+ .f = cmd_set_vf_vlan_filter_parsed,
+ .data = NULL,
+ .help_str = "set vf vlan filter <port_id> <vlan_id> <vf_mask> <on_off>",
+ .tokens = {
+ (void *)&cmd_vf_vlan_filter_set,
+ (void *)&cmd_vf_vlan_filter_vf,
+ (void *)&cmd_vf_vlan_filter_vlan,
+ (void *)&cmd_vf_vlan_filter_filter,
+ (void *)&cmd_vf_vlan_filter_port_id,
+ (void *)&cmd_vf_vlan_filter_vlan_id,
+ (void *)&cmd_vf_vlan_filter_vf_mask,
+ (void *)&cmd_vf_vlan_filter_on_off,
+ NULL,
+ },
+};
+
/* tx loopback configuration */
/* Common result structure for tx loopback */
@@ -11620,6 +11717,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
+ (cmdline_parse_inst_t *)&cmd_set_vf_vlan_filter,
(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
@@ -535,6 +535,13 @@ Set VLAN insert for a VF from the PF::
testpmd> set vf vlan insert (port_id) (vf_id) (vlan_id)
+vlan set filter (for VF pool)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Set VLAN filter for a VF pool from the PF::
+
+ testpmd> set vf vlan filter (port_id) (vlan_id) (vf_mask) (on|off)
+
vlan set antispoof (for VF)
~~~~~~~~~~~~~~~~~~~~~~~~~~~