net/ixgbe: move set VF functions.
cover net/ixgbe: move set VF functions.
This patchset implements the following deprecation notice:
[PATCH v1] doc: announce API and ABI change for librte_ether
The following functions from eth_dev_ops have been moved to the ixgbe PMD and renamed:
ixgbe_set_pool_rx_modeixgbe_set_pool_rxixgbe_set_pool_txixgbe_set_pool_vlan_filterixgbe_set_vf_rate_limit
Renamed the functions to the following:
rte_pmd_ixgbe_set_vf_rxmoderte_pmd_ixgbe_set_vf_rxrte_pmd_ixgbe_set_vf_txrte_pmd_ixgbe_set_vf_vlan_filterrte_pmd_ixgbe_set_vf_rate_limit
Testpmd has been modified to use the following functions:rte_pmd_ixgbe_set_vf_rxmode rte_pmd_ixgbe_set_vf_rate_limit
New testpmd commands have been added to test the following functions:rte_pmd_ixgbe_set_vf_rxrte_pmd_ixgbe_set_vf_txrte_pmd_ixgbe_set_vf_vlan_filter
The testpmd user guide has been updated for the new commands.
Bernard Iremonger (5):
net/ixgbe: move set VF functions from the ethdev app/testpmd: use ixgbe public functions app/testpmd: add command for set VF VLAN filter app/testpmd: add command for set VF receive app/testpmd: add command for set VF transmit
app/test-pmd/cmdline.c | 270 +++++++++++++++++++++++++++- app/test-pmd/config.c | 31 ++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 21 +++ drivers/net/ixgbe/ixgbe_ethdev.c | 263 +++++++++++++++++++++++++++ drivers/net/ixgbe/rte_pmd_ixgbe.h | 104 +++++++++++ drivers/net/ixgbe/rte_pmd_ixgbe_version.map | 10 ++ 6 files changed, 678 insertions(+), 21 deletions(-)
Signature · 1 line
2.10.1
PATCH 1/5 net/ixgbe: move set VF functions from the ethdev
Move the following functions from eth_dev_ops to the ixgbe PMD and rename:
ixgbe_set_pool_rx_modeixgbe_set_pool_rxixgbe_set_pool_txixgbe_set_pool_vlan_filterixgbe_set_vf_rate_limit
Rename the functions to the following:
rte_pmd_ixgbe_set_vf_rxmoderte_pmd_ixgbe_set_vf_rxrte_pmd_ixgbe_set_vf_txrte_pmd_ixgbe_set_vf_vlan_filterrte_pmd_ixgbe_set_vf_rate_limit
--- drivers/net/ixgbe/ixgbe_ethdev.c | 263 ++++++++++++++++++++++++++++ drivers/net/ixgbe/rte_pmd_ixgbe.h | 104 +++++++++++ drivers/net/ixgbe/rte_pmd_ixgbe_version.map | 10 ++ 3 files changed, 377 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +263 -0
@@ -4883,6 +4883,269 @@ rte_pmd_ixgbe_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on)return 0 ; } +int +rte_pmd_ixgbe_set_vf_rxmode (uint8_t port,uint16_t vf,uint16_t rx_mask,uint8_t on) +{ +int val =0 ; +struct rte_eth_dev *dev; +struct rte_eth_dev_info dev_info; +struct ixgbe_hw *hw; +uint32_t vmolr; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); + + dev = &rte_eth_devices[port]; +rte_eth_dev_info_get (port, &dev_info); + +if (strstr (dev_info.driver_name,"ixgbe_vf" )) +return -ENOTSUP ; + +if (vf >= dev_info.max_vfs) +return -EINVAL ; + +if (on >1 ) +return -EINVAL ; + + hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); + vmolr =IXGBE_READ_REG (hw,IXGBE_VMOLR (vf)); + +if (hw->mac.type == ixgbe_mac_82598EB) { +PMD_INIT_LOG (ERR ,"setting VF receive mode set should be done" +" on 82599 hardware and newer" ); +return -ENOTSUP ; + } +if (ixgbe_vmdq_mode_check (hw) <0 ) +return -ENOTSUP ; + + val =ixgbe_convert_vm_rx_mask_to_val (rx_mask, val); + +if (on) + vmolr |= val; +else + vmolr &= ~val; + +IXGBE_WRITE_REG (hw,IXGBE_VMOLR (vf), vmolr); + +return 0 ; +} + +int +rte_pmd_ixgbe_set_vf_rx (uint8_t port,uint16_t vf,uint8_t on) +{ +struct rte_eth_dev *dev; +struct rte_eth_dev_info dev_info; +uint32_t reg, addr; +uint32_t val; +const uint8_t bit1 =0x1 ; +struct ixgbe_hw *hw; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); + + dev = &rte_eth_devices[port]; +rte_eth_dev_info_get (port, &dev_info); + +if (strstr (dev_info.driver_name,"ixgbe_vf" )) +return -ENOTSUP ; + +if (vf >= dev_info.max_vfs) +return -EINVAL ; + +if (on >1 ) +return -EINVAL ; + + hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); + +if (ixgbe_vmdq_mode_check (hw) <0 ) +return -ENOTSUP ; + +/* for vf >= 32, set bit in PFVFRE[1], otherwise PFVFRE[0] */ +if (vf >=32 ) { + addr =IXGBE_VFRE (1 ); + val = bit1 << (vf -32 ); + }else { + addr =IXGBE_VFRE (0 ); + val = bit1 << vf; + } + + reg =IXGBE_READ_REG (hw, addr); + +if (on) + reg |= val; +else + reg &= ~val; + +IXGBE_WRITE_REG (hw, addr, reg); + +return 0 ; +} + +int +rte_pmd_ixgbe_set_vf_tx (uint8_t port,uint16_t vf,uint8_t on) +{ +struct rte_eth_dev *dev; +struct rte_eth_dev_info dev_info; +uint32_t reg, addr; +uint32_t val; +const uint8_t bit1 =0x1 ; + +struct ixgbe_hw *hw; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); + + dev = &rte_eth_devices[port]; +rte_eth_dev_info_get (port, &dev_info); + +if (strstr (dev_info.driver_name,"ixgbe_vf" )) +return -ENOTSUP ; + +if (vf >= dev_info.max_vfs) +return -EINVAL ; + +if (on >1 ) +return -EINVAL ; + + hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +if (ixgbe_vmdq_mode_check (hw) <0 ) +return -ENOTSUP ; + +/* for vf >= 32, set bit in PFVFTE[1], otherwise PFVFTE[0] */ +if (vf >=32 ) { + addr =IXGBE_VFTE (1 ); + val = bit1 << (vf -32 ); + }else { + addr =IXGBE_VFTE (0 ); + val = bit1 << vf; + } + + reg =IXGBE_READ_REG (hw, addr); + +if (on) + reg |= val; +else + reg &= ~val; + +IXGBE_WRITE_REG (hw, addr, reg); + +return 0 ; +} + +int +rte_pmd_ixgbe_set_vf_vlan_filter (uint8_t port,uint16_t vlan, +uint64_t vf_mask,uint8_t vlan_on) +{ +struct rte_eth_dev *dev; +struct rte_eth_dev_info dev_info; +int ret =0 ; +uint16_t vf_idx; +struct ixgbe_hw *hw; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); + + dev = &rte_eth_devices[port]; +rte_eth_dev_info_get (port, &dev_info); + +if (strstr (dev_info.driver_name,"ixgbe_vf" )) +return -ENOTSUP ; + +if ((vlan >ETHER_MAX_VLAN_ID ) || (vf_mask ==0 )) +return -EINVAL ; + + hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +if (ixgbe_vmdq_mode_check (hw) <0 ) +return -ENOTSUP ; + +for (vf_idx =0 ; vf_idx <64 ; vf_idx++) { +if (vf_mask & ((uint64_t )(1ULL << vf_idx))) { + ret = hw->mac.ops.set_vfta (hw, vlan, vf_idx, + vlan_on, false); +if (ret <0 ) +return ret; + } + } + +return ret; +} + +int rte_pmd_ixgbe_set_vf_rate_limit (uint8_t port,uint16_t vf, +uint16_t tx_rate,uint64_t q_msk) +{ +struct rte_eth_dev *dev; +struct rte_eth_dev_info dev_info; +struct ixgbe_hw *hw; +struct ixgbe_vf_info *vfinfo; +struct rte_eth_link link; +uint8_t nb_q_per_pool; +uint32_t queue_stride; +uint32_t queue_idx, idx =0 , vf_idx; +uint32_t queue_end; +uint16_t total_rate =0 ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); + + dev = &rte_eth_devices[port]; +rte_eth_dev_info_get (port, &dev_info); +rte_eth_link_get_nowait (port, &link); + +if (strstr (dev_info.driver_name,"ixgbe_vf" )) +return -ENOTSUP ; + +if (vf >= dev_info.max_vfs) +return -EINVAL ; + +if (tx_rate > link.link_speed) +return -EINVAL ; + +if (q_msk ==0 ) +return 0 ; + + hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); + vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA (dev->data->dev_private)); + nb_q_per_pool =RTE_ETH_DEV_SRIOV (dev).nb_q_per_pool; + queue_stride =IXGBE_MAX_RX_QUEUE_NUM /RTE_ETH_DEV_SRIOV (dev).active; + queue_idx = vf * queue_stride; + queue_end = queue_idx + nb_q_per_pool -1 ; +if (queue_end >= hw->mac.max_tx_queues) +return -EINVAL ; + +if (vfinfo) { +for (vf_idx =0 ; vf_idx < dev->pci_dev->max_vfs; vf_idx++) { +if (vf_idx == vf) +continue ; +for (idx =0 ; idx <RTE_DIM (vfinfo[vf_idx].tx_rate); + idx++) + total_rate += vfinfo[vf_idx].tx_rate[idx]; + } + }else { +return -EINVAL ; + } + +/* Store tx_rate for this vf. */ +for (idx =0 ; idx < nb_q_per_pool; idx++) { +if (((uint64_t )0x1 << idx) & q_msk) { +if (vfinfo[vf].tx_rate[idx] != tx_rate) + vfinfo[vf].tx_rate[idx] = tx_rate; + total_rate += tx_rate; + } + } + +if (total_rate > dev->data->dev_link.link_speed) { +/* Reset stored TX rate of the VF if it causes exceed +* link speed. +*/ +memset (vfinfo[vf].tx_rate,0 ,sizeof (vfinfo[vf].tx_rate)); +return -EINVAL ; + } + +/* Set RTTBCNRC of each queue/pool for vf X */ +for (; queue_idx <= queue_end; queue_idx++) { +if (0x1 & q_msk) +ixgbe_set_queue_rate_limit (dev, queue_idx, tx_rate); + q_msk = q_msk >>1 ; + } + +return 0 ; +} +#define IXGBE_MRCTL_VPME 0x01/* Virtual Pool Mirroring. */ #define IXGBE_MRCTL_UPME 0x02/* Uplink Port Mirroring. */ #define IXGBE_MRCTL_DPME 0x04/* Downlink Port Mirroring. */
drivers/net/ixgbe/rte_pmd_ixgbe.h +104 -0
110 lines not on this page · raw message
drivers/net/ixgbe/rte_pmd_ixgbe_version.map +10 -0
@@ -15,3 +15,13 @@ DPDK_16.11 { rte_pmd_ixgbe_set_vf_vlan_insert; rte_pmd_ixgbe_set_vf_vlan_stripq; } DPDK_2.0; + +DPDK_17.02 { + global: + + rte_pmd_ixgbe_set_vf_rate_limit; + rte_pmd_ixgbe_set_vf_rx; + rte_pmd_ixgbe_set_vf_rxmode; + rte_pmd_ixgbe_set_vf_tx; + rte_pmd_ixgbe_set_vf_vlan_filter; +} DPDK_16.11;
Signature · 1 line
2.10.1
PATCH 2/5 app/testpmd: use ixgbe public functions
In reply to Bernard IremongerUse the the following ixgbe public functions:
rte_pmd_ixgbe_set_vf_rate_limitrte_pmd_ixgbe_set_vf_rxrte_pmd_ixgbe_set_vf_rxmoderte_pmd_ixgbe_set_vf_txrte_pmd_ixgbe_set_vf_vlan_filter
--- app/test-pmd/cmdline.c | 2 +- app/test-pmd/config.c | 31 +++++++++++-------------------- 2 files changed, 12 insertions(+), 21 deletions(-)
app/test-pmd/cmdline.c +1 -1
@@ -6708,7 +6708,7 @@ cmd_set_vf_rxmode_parsed(void *parsed_result, rx_mode |=ETH_VMDQ_ACCEPT_MULTICAST ; } - ret =rte_eth_dev_set_vf_rxmode (res->port_id,res->vf_id,rx_mode,(uint8_t )is_on); + ret =rte_pmd_ixgbe_set_vf_rxmode (res->port_id, res->vf_id, rx_mode, (uint8_t )is_on);if (ret <0 )printf ("bad VF receive mode parameter, return code = %d \n" , ret);
app/test-pmd/config.c +11 -20
@@ -92,6 +92,9 @@#include <rte_ethdev.h> #include <rte_string_fns.h> #include <rte_cycles.h> +#ifdef RTE_LIBRTE_IXGBE_PMD +#include <rte_pmd_ixgbe.h> +#endif #include "testpmd.h"
@@ -2332,16 +2335,16 @@ set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on)if (port_id_is_invalid (port_id,ENABLED_WARN ))return ;if (is_rx) - diag =rte_eth_dev_set_vf_rx (port_id,vf,on); + diag =rte_pmd_ixgbe_set_vf_rx (port_id, vf, on);else - diag =rte_eth_dev_set_vf_tx (port_id,vf,on); + diag =rte_pmd_ixgbe_set_vf_tx (port_id, vf, on);if (diag ==0 )return ;if (is_rx) -printf ("rte_eth_dev_set_vf_rx for port_id=%d failed " +printf ("rte_pmd_ixgbe_set_vf_rx for port_id=%d failed " "diag=%d\n" , port_id, diag);else -printf ("rte_eth_dev_set_vf_tx for port_id=%d failed " +printf ("rte_pmd_ixgbe_set_vf_tx for port_id=%d failed " "diag=%d\n" , port_id, diag); }
@@ -2355,10 +2358,10 @@ set_vf_rx_vlan(portid_t port_id, uint16_t vlan_id, uint64_t vf_mask, uint8_t on)return ;if (vlan_id_is_invalid (vlan_id))return ; - diag =rte_eth_dev_set_vf_vlan_filter (port_id, vlan_id, vf_mask, on); + diag =rte_pmd_ixgbe_set_vf_vlan_filter (port_id, vlan_id, vf_mask, on);if (diag ==0 )return ; -printf ("rte_eth_dev_set_vf_vlan_filter for port_id=%d failed " +printf ("rte_pmd_ixgbe_set_vf_vlan_filter for port_id=%d failed " "diag=%d\n" , port_id, diag); }
@@ -2388,23 +2391,11 @@ int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate, uint64_t q_msk) { int diag; -struct rte_eth_link link; - -if (q_msk ==0 ) -return 0 ; -if (port_id_is_invalid (port_id,ENABLED_WARN )) -return 1 ; -rte_eth_link_get_nowait (port_id, &link); -if (rate > link.link_speed) { -printf ("Invalid rate value:%u bigger than link speed: %u\n" , - rate, link.link_speed); -return 1 ; - } - diag =rte_eth_set_vf_rate_limit (port_id, vf, rate, q_msk); + diag =rte_pmd_ixgbe_set_vf_rate_limit (port_id, vf, rate, q_msk);if (diag ==0 )return diag; -printf ("rte_eth_set_vf_rate_limit for port_id=%d failed diag=%d\n" , +printf ("rte_pmd_ixgbe_set_vf_rate_limit for port_id=%d failed diag=%d\n" , port_id, diag);return diag; }
Signature · 1 line
2.10.1
PATCH 4/5 app/testpmd: add command for set VF receive
In reply to Bernard Iremongeradd the following command to testpmd:
set vf rx <port_id> <vf_id> <on|off>
add command to the testpmd user guide.
--- app/test-pmd/cmdline.c | 85 +++++++++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++ 2 files changed, 92 insertions(+)
app/test-pmd/cmdline.c +85 -0
@@ -274,6 +274,9 @@ static void cmd_help_long_parsed(void *parsed_result,"set vf mac antispoof (port_id) (vf_id) (on|off).\n" " Set MAC antispoof for a VF from the PF.\n\n" + +"set vf rx (port_id) (vf_id) (on|off).\n" + " Enable or disable RX for a VF from the PF.\n\n"#endif "vlan set strip (on|off) (port_id)\n"
@@ -11236,6 +11239,87 @@ cmdline_parse_inst_t cmd_set_vf_vlan_filter = { }, }; +/* vf rx configuration */ + +/* Common result structure for vf rx */ +struct cmd_vf_rx_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t vf; +cmdline_fixed_string_t rx; +uint8_t port_id; +uint16_t vf_id; +cmdline_fixed_string_t on_off; +}; + +/* Common CLI fields for vf rx enable disable */ +cmdline_parse_token_string_t cmd_vf_rx_set = +TOKEN_STRING_INITIALIZER + (struct cmd_vf_rx_result, + set,"set" ); +cmdline_parse_token_string_t cmd_vf_rx_vf = +TOKEN_STRING_INITIALIZER + (struct cmd_vf_rx_result, + vf,"vf" ); +cmdline_parse_token_string_t cmd_vf_rx_rx = +TOKEN_STRING_INITIALIZER + (struct cmd_vf_rx_result, + rx,"rx" ); +cmdline_parse_token_num_t cmd_vf_rx_port_id = +TOKEN_NUM_INITIALIZER + (struct cmd_vf_rx_result, + port_id,UINT8 ); +cmdline_parse_token_num_t cmd_vf_rx_vf_id = +TOKEN_NUM_INITIALIZER + (struct cmd_vf_rx_result, + vf_id,UINT16 ); +cmdline_parse_token_string_t cmd_vf_rx_on_off = +TOKEN_STRING_INITIALIZER + (struct cmd_vf_rx_result, + on_off,"on#off" ); + +static void +cmd_set_vf_rx_parsed ( +void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_vf_rx_result *res = parsed_result; +int ret =0 ; +int is_on = (strcmp (res->on_off,"on" ) ==0 ) ?1 :0 ; + + ret =rte_pmd_ixgbe_set_vf_rx (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 ; +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_rx = { + .f = cmd_set_vf_rx_parsed, + .data =NULL , + .help_str ="set vf rx <port_id> <vf_id> <on|off>" , + .tokens = { + (void *)&cmd_vf_rx_set, + (void *)&cmd_vf_rx_vf, + (void *)&cmd_vf_rx_rx, + (void *)&cmd_vf_rx_port_id, + (void *)&cmd_vf_rx_vf_id, + (void *)&cmd_vf_rx_on_off, +NULL , + }, +}; +/* tx loopback configuration */ /* Common result structure for tx loopback */
@@ -11722,6 +11806,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, + (cmdline_parse_inst_t *)&cmd_set_vf_rx, #endif NULL, };
doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -0
@@ -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 rx (for VF) +~~~~~~~~~~~~~~~ + +Enable/disable rx for a VF from the PF:: + + testpmd> set vf rx (port_id) (vf_id) (on|off) + vlan set strip ~~~~~~~~~~~~~~
Signature · 1 line
2.10.1
PATCH 3/5 app/testpmd: add command for set VF VLAN filter
In reply to Bernard IremongerAdd the following command to testpmd:
set vf vlan filter <port_id> <vlan_id> <vf_mask> <on|off>
Add command to the testpmd user guide.
--- app/test-pmd/cmdline.c | 98 +++++++++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++ 2 files changed, 105 insertions(+)
app/test-pmd/cmdline.c +98 -0
@@ -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,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -0
@@ -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) ~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.10.1
PATCH 5/5 app/testpmd: add command for set VF transmit
In reply to Bernard Iremongeradd the following command to testpmd:
set vf tx <port_id> <vf_id> <on|off>
add command to the testpmd user guide.
--- app/test-pmd/cmdline.c | 85 +++++++++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++ 2 files changed, 92 insertions(+)
app/test-pmd/cmdline.c +85 -0
@@ -277,6 +277,9 @@ static void cmd_help_long_parsed(void *parsed_result,"set vf rx (port_id) (vf_id) (on|off).\n" " Enable or disable RX for a VF from the PF.\n\n" + +"set vf tx (port_id) (vf_id) (on|off).\n" + " Enable or disable TX for a VF from the PF.\n\n"#endif "vlan set strip (on|off) (port_id)\n"
@@ -11320,6 +11323,87 @@ cmdline_parse_inst_t cmd_set_vf_rx = { }, }; +/* vf tx configuration */ + +/* Common result structure for vf tx */ +struct cmd_vf_tx_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t vf; +cmdline_fixed_string_t tx; +uint8_t port_id; +uint16_t vf_id; +cmdline_fixed_string_t on_off; +}; + +/* Common CLI fields for vf tx enable disable */ +cmdline_parse_token_string_t cmd_vf_tx_set = +TOKEN_STRING_INITIALIZER + (struct cmd_vf_tx_result, + set,"set" ); +cmdline_parse_token_string_t cmd_vf_tx_vf = +TOKEN_STRING_INITIALIZER + (struct cmd_vf_tx_result, + vf,"vf" ); +cmdline_parse_token_string_t cmd_vf_tx_tx = +TOKEN_STRING_INITIALIZER + (struct cmd_vf_tx_result, + tx,"tx" ); +cmdline_parse_token_num_t cmd_vf_tx_port_id = +TOKEN_NUM_INITIALIZER + (struct cmd_vf_tx_result, + port_id,UINT8 ); +cmdline_parse_token_num_t cmd_vf_tx_vf_id = +TOKEN_NUM_INITIALIZER + (struct cmd_vf_tx_result, + vf_id,UINT16 ); +cmdline_parse_token_string_t cmd_vf_tx_on_off = +TOKEN_STRING_INITIALIZER + (struct cmd_vf_tx_result, + on_off,"on#off" ); + +static void +cmd_set_vf_tx_parsed ( +void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_vf_tx_result *res = parsed_result; +int ret =0 ; +int is_on = (strcmp (res->on_off,"on" ) ==0 ) ?1 :0 ; + + ret =rte_pmd_ixgbe_set_vf_tx (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 ; +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_tx = { + .f = cmd_set_vf_tx_parsed, + .data =NULL , + .help_str ="set vf tx <port_id> <vf_id> <on|off>" , + .tokens = { + (void *)&cmd_vf_tx_set, + (void *)&cmd_vf_tx_vf, + (void *)&cmd_vf_tx_tx, + (void *)&cmd_vf_tx_port_id, + (void *)&cmd_vf_tx_vf_id, + (void *)&cmd_vf_tx_on_off, +NULL , + }, +}; +/* tx loopback configuration */ /* Common result structure for tx loopback */
@@ -11807,6 +11891,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, (cmdline_parse_inst_t *)&cmd_set_vf_rx, + (cmdline_parse_inst_t *)&cmd_set_vf_tx, #endif NULL, };
doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -0
@@ -514,6 +514,13 @@ Enable/disable rx for a VF from the PF:: testpmd> set vf rx (port_id) (vf_id) (on|off) +set tx (for VF) +~~~~~~~~~~~~~~~ + +Enable/disable tx for a VF from the PF:: + + testpmd> set vf tx (port_id) (vf_id) (on|off) + vlan set strip ~~~~~~~~~~~~~~
Signature · 1 line
2.10.1