From aaffc740ec2cfdb304523c67020f09ad343cfacf Mon Sep 17 00:00:00 2001 From: "E. Scott Daniels" Date: Wed, 19 Oct 2016 15:47:33 +0100 Subject: [PATCH] net/ixgbe: fix VF VLAN insert API The final parameter to rte_pmd_ixgbe_set_vf_vlan_insert is uint8_t and treated as a binary flag when it needs to be a uint16_t and treated as a VLAN id. The data sheet (sect 8.2.3.27.13) describes the right most 16 bits as the VLAN id that is to be inserted; the 16.11 code is accepting only a 1 or 0 thus effectively only allowing the VLAN id 1 to be inserted (0 disables the insertion setting). This patch changes the final parm name to represent the data that is being accepted (vlan_id), changes the type to permit all valid VLAN ids, and validates the parameter based on the range of 0 to 4095. Corresponding changes to prototype and documentation in the .h file. Fixes: 49e248223e9f71 ("net/ixgbe: add API for VF management") Signed-off-by: E. Scott Daniels Signed-off-by: Bernard Iremonger Acked-by: Wenzhuo Lu --- app/test-pmd/cmdline.c | 19 +++++++++---------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 8 ++++---- drivers/net/ixgbe/rte_pmd_ixgbe.h | 9 +++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 160ac06efd..63b55dcbeb 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -286,7 +286,7 @@ static void cmd_help_long_parsed(void *parsed_result, "set vf vlan stripq (port_id) (vf_id) (on|off)\n" " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" - "set vf vlan insert (port_id) (vf_id) (on|off)\n" + "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" " Set VLAN insert for a VF from the PF.\n\n" "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" @@ -11018,7 +11018,7 @@ struct cmd_vf_vlan_insert_result { cmdline_fixed_string_t insert; uint8_t port_id; uint16_t vf_id; - cmdline_fixed_string_t on_off; + uint16_t vlan_id; }; /* Common CLI fields for vf vlan insert enable disable */ @@ -11046,10 +11046,10 @@ cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = TOKEN_NUM_INITIALIZER (struct cmd_vf_vlan_insert_result, vf_id, UINT16); -cmdline_parse_token_string_t cmd_vf_vlan_insert_on_off = - TOKEN_STRING_INITIALIZER +cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = + TOKEN_NUM_INITIALIZER (struct cmd_vf_vlan_insert_result, - on_off, "on#off"); + vlan_id, UINT16); static void cmd_set_vf_vlan_insert_parsed( @@ -11059,14 +11059,13 @@ cmd_set_vf_vlan_insert_parsed( { struct cmd_vf_vlan_insert_result *res = parsed_result; int ret; - int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; - ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, is_on); + ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, res->vlan_id); switch (ret) { case 0: break; case -EINVAL: - printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); + printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); break; case -ENODEV: printf("invalid port_id %d\n", res->port_id); @@ -11079,7 +11078,7 @@ cmd_set_vf_vlan_insert_parsed( cmdline_parse_inst_t cmd_set_vf_vlan_insert = { .f = cmd_set_vf_vlan_insert_parsed, .data = NULL, - .help_str = "set vf vlan insert port_id vf_id on|off", + .help_str = "set vf vlan insert port_id vf_id vlan_id", .tokens = { (void *)&cmd_vf_vlan_insert_set, (void *)&cmd_vf_vlan_insert_vf, @@ -11087,7 +11086,7 @@ cmdline_parse_inst_t cmd_set_vf_vlan_insert = { (void *)&cmd_vf_vlan_insert_insert, (void *)&cmd_vf_vlan_insert_port_id, (void *)&cmd_vf_vlan_insert_vf_id, - (void *)&cmd_vf_vlan_insert_on_off, + (void *)&cmd_vf_vlan_insert_vlan_id, NULL, }, }; diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index b1b9736c81..f1c269a352 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -533,7 +533,7 @@ vlan set insert (for VF) Set VLAN insert for a VF from the PF:: - testpmd> set vf vlan insert (port_id) (vf_id) (on|off) + testpmd> set vf vlan insert (port_id) (vf_id) (vlan_id) vlan set antispoof (for VF) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 4ca574749f..316af73f3f 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -4727,7 +4727,7 @@ rte_pmd_ixgbe_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on) } int -rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, uint8_t on) +rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, uint16_t vlan_id) { struct ixgbe_hw *hw; uint32_t ctrl; @@ -4742,13 +4742,13 @@ rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, uint8_t on) if (vf >= dev_info.max_vfs) return -EINVAL; - if (on > 1) + if (vlan_id > 4095) return -EINVAL; hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); ctrl = IXGBE_READ_REG(hw, IXGBE_VMVIR(vf)); - if (on) { - ctrl = on; + if (vlan_id) { + ctrl = vlan_id; ctrl |= IXGBE_VMVIR_VLANA_DEFAULT; } else { ctrl = 0; diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe.h b/drivers/net/ixgbe/rte_pmd_ixgbe.h index 2fdf53077d..c2fb826157 100644 --- a/drivers/net/ixgbe/rte_pmd_ixgbe.h +++ b/drivers/net/ixgbe/rte_pmd_ixgbe.h @@ -99,16 +99,17 @@ int rte_pmd_ixgbe_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on); * The port identifier of the Ethernet device. * @param vf * ID specifying VF. - * @param on - * 1 - Enable VF's vlan insert. - * 0 - Disable VF's vlan insert + * @param vlan_id + * 0 - Disable VF's vlan insert. + * n - Enable; n is inserted as the vlan id. * * @return * - (0) if successful. * - (-ENODEV) if *port* invalid. * - (-EINVAL) if bad parameter. */ -int rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, uint8_t on); +int rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, + uint16_t vlan_id); /** * Enable/Disable tx loopback -- 2.20.1