When doing rte_eth_dev_get_supported_ptypes on netvsc device the values reported are incorrect if VF is not present.
If no VF is present the device uses rte_net_get_ptype() which can return a wide range of values. Use the same table as TAP device in that case. Signed-off-by: Stephen Hemminger <step...@networkplumber.org> --- drivers/net/netvsc/hn_ethdev.c | 48 +++++++++++++++++++++++++++++++++- drivers/net/netvsc/hn_var.h | 1 - drivers/net/netvsc/hn_vf.c | 15 ----------- 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 49f954305dd8..9ce0134bd41b 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -438,6 +438,52 @@ static int hn_rss_hash_conf_get(struct rte_eth_dev *dev, return 0; } +static const uint32_t* +hn_dev_supported_ptypes(struct rte_eth_dev *dev) +{ + struct hn_data *hv = dev->data->dev_private; + struct rte_eth_dev *vf_dev; + const uint32_t *ptypes = NULL; + + /* List of possible ptypes comes from rte_net_get_ptype. */ + static const uint32_t net_ptypes[] = { + RTE_PTYPE_INNER_L2_ETHER, + RTE_PTYPE_INNER_L2_ETHER_VLAN, + RTE_PTYPE_INNER_L2_ETHER_QINQ, + RTE_PTYPE_INNER_L3_IPV4, + RTE_PTYPE_INNER_L3_IPV4_EXT, + RTE_PTYPE_INNER_L3_IPV6, + RTE_PTYPE_INNER_L3_IPV6_EXT, + RTE_PTYPE_INNER_L4_FRAG, + RTE_PTYPE_INNER_L4_UDP, + RTE_PTYPE_INNER_L4_TCP, + RTE_PTYPE_INNER_L4_SCTP, + RTE_PTYPE_L2_ETHER, + RTE_PTYPE_L2_ETHER_VLAN, + RTE_PTYPE_L2_ETHER_QINQ, + RTE_PTYPE_L3_IPV4, + RTE_PTYPE_L3_IPV4_EXT, + RTE_PTYPE_L3_IPV6_EXT, + RTE_PTYPE_L3_IPV6, + RTE_PTYPE_L4_FRAG, + RTE_PTYPE_L4_UDP, + RTE_PTYPE_L4_TCP, + RTE_PTYPE_L4_SCTP, + }; + + rte_rwlock_read_lock(&hv->vf_lock); + vf_dev = hn_get_vf_dev(hv); + if (vf_dev) { + if (vf_dev->dev_ops->dev_supported_ptypes_get) + ptypes = (*vf_dev->dev_ops->dev_supported_ptypes_get)(vf_dev); + } else { + ptypes = net_ptypes; + } + rte_rwlock_read_unlock(&hv->vf_lock); + + return ptypes; +} + static int hn_dev_promiscuous_enable(struct rte_eth_dev *dev) { @@ -880,7 +926,7 @@ static const struct eth_dev_ops hn_eth_dev_ops = { .dev_infos_get = hn_dev_info_get, .txq_info_get = hn_dev_tx_queue_info, .rxq_info_get = hn_dev_rx_queue_info, - .dev_supported_ptypes_get = hn_vf_supported_ptypes, + .dev_supported_ptypes_get = hn_dev_supported_ptypes, .promiscuous_enable = hn_dev_promiscuous_enable, .promiscuous_disable = hn_dev_promiscuous_disable, .allmulticast_enable = hn_dev_allmulticast_enable, diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h index bd874c6b4d70..7c84f58d430d 100644 --- a/drivers/net/netvsc/hn_var.h +++ b/drivers/net/netvsc/hn_var.h @@ -223,7 +223,6 @@ int hn_vf_info_get(struct hn_data *hv, int hn_vf_add(struct rte_eth_dev *dev, struct hn_data *hv); int hn_vf_configure(struct rte_eth_dev *dev, const struct rte_eth_conf *dev_conf); -const uint32_t *hn_vf_supported_ptypes(struct rte_eth_dev *dev); int hn_vf_start(struct rte_eth_dev *dev); void hn_vf_reset(struct rte_eth_dev *dev); int hn_vf_close(struct rte_eth_dev *dev); diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c index d43ebaa69fbb..e18596e77061 100644 --- a/drivers/net/netvsc/hn_vf.c +++ b/drivers/net/netvsc/hn_vf.c @@ -244,21 +244,6 @@ int hn_vf_configure(struct rte_eth_dev *dev, return ret; } -const uint32_t *hn_vf_supported_ptypes(struct rte_eth_dev *dev) -{ - struct hn_data *hv = dev->data->dev_private; - struct rte_eth_dev *vf_dev; - const uint32_t *ptypes = NULL; - - rte_rwlock_read_lock(&hv->vf_lock); - vf_dev = hn_get_vf_dev(hv); - if (vf_dev && vf_dev->dev_ops->dev_supported_ptypes_get) - ptypes = (*vf_dev->dev_ops->dev_supported_ptypes_get)(vf_dev); - rte_rwlock_read_unlock(&hv->vf_lock); - - return ptypes; -} - int hn_vf_start(struct rte_eth_dev *dev) { struct hn_data *hv = dev->data->dev_private; -- 2.27.0