net/netvsc: fix supported_ptypes
cover net/netvsc: fix supported_ptypes
A couple of patches motivated by recent cppcheck patches from Ferruh. The handling of supported_ptypes is incorrect in netvsc PMD for non VF case.
Stephen Hemminger (2):
net/netvsc: remove unused code
net/netvsc: fix ethdev get_supported_ptypes
drivers/net/netvsc/hn_ethdev.c | 48 +++++++++++++++++++++++++++++++++- drivers/net/netvsc/hn_rndis.c | 31 ---------------------- drivers/net/netvsc/hn_rndis.h | 1 - drivers/net/netvsc/hn_var.h | 1 - drivers/net/netvsc/hn_vf.c | 15 ----------- 5 files changed, 47 insertions(+), 49 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/2 net/netvsc: remove unused code
This code is not called anywhere.
--- drivers/net/netvsc/hn_rndis.c | 31 ------------------------------- drivers/net/netvsc/hn_rndis.h | 1 - 2 files changed, 32 deletions(-)
drivers/net/netvsc/hn_rndis.c +0 -31
@@ -946,37 +946,6 @@ int hn_rndis_get_offload(struct hn_data *hv,return 0 ; } -uint32_t -hn_rndis_get_ptypes (struct hn_data *hv) -{ -struct ndis_offload hwcaps; -uint32_t ptypes; -int error; - -memset (&hwcaps,0 ,sizeof (hwcaps)); - - error =hn_rndis_query_hwcaps (hv, &hwcaps); -if (error) { -PMD_DRV_LOG (ERR ,"hwcaps query failed: %d" , error); -return RTE_PTYPE_L2_ETHER ; - } - - ptypes =RTE_PTYPE_L2_ETHER ; - -if (hwcaps.ndis_csum.ndis_ip4_rxcsum &NDIS_RXCSUM_CAP_IP4 ) - ptypes |=RTE_PTYPE_L3_IPV4 ; - -if ((hwcaps.ndis_csum.ndis_ip4_rxcsum &NDIS_RXCSUM_CAP_TCP4 ) || - (hwcaps.ndis_csum.ndis_ip6_rxcsum &NDIS_RXCSUM_CAP_TCP6 )) - ptypes |=RTE_PTYPE_L4_TCP ; - -if ((hwcaps.ndis_csum.ndis_ip4_rxcsum &NDIS_RXCSUM_CAP_UDP4 ) || - (hwcaps.ndis_csum.ndis_ip6_rxcsum &NDIS_RXCSUM_CAP_UDP6 )) - ptypes |=RTE_PTYPE_L4_UDP ; - -return ptypes; -} -int hn_rndis_set_rxfilter (struct hn_data *hv,uint32_t filter) {
drivers/net/netvsc/hn_rndis.h +0 -1
@@ -25,7 +25,6 @@ int hn_rndis_query_rsscaps(struct hn_data *hv,int hn_rndis_query_rss (struct hn_data *hv,struct rte_eth_rss_conf *rss_conf);int hn_rndis_conf_rss (struct hn_data *hv,uint32_t flags); -uint32_t hn_rndis_get_ptypes (struct hn_data *hv);#ifdef RTE_LIBRTE_NETVSC_DEBUG_DUMP void hn_rndis_dump (const void *buf);
Signature · 1 line
2.27.0
PATCH 2/2 net/netvsc: fix ethdev get_supported_ptypes
In reply to Stephen HemmingerWhen 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.
--- 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(-)
drivers/net/netvsc/hn_ethdev.c +47 -1
@@ -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,
drivers/net/netvsc/hn_var.h +0 -1
@@ -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);
drivers/net/netvsc/hn_vf.c +0 -15
@@ -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;
Signature · 1 line
2.27.0
Re: [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes
Quoted 8 lines · Stephen Hemminger
When doing
rte_eth_dev_get_supported_ptypeson 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 <[email protected]>
Which commit is fixed, can you please add Fixes tag?
Re: [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes
Quoted 4 lines · Ferruh Yigit
Quoted 3 lines · Stephen Hemminger
When doing
rte_eth_dev_get_supported_ptypeson netvsc device the values reported are incorrect if VF is not present.
Quoted 8 lines
Quoted 5 lines
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 <[email protected]>Which commit is fixed, can you please add Fixes tag?
and stable tag if it is requested for backport
Re: [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes
Quoted 9 lines · Kevin Traynor
Quoted 8 lines · Ferruh Yigit
Quoted 7 lines · Stephen Hemminger
When doing
rte_eth_dev_get_supported_ptypeson 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.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Stephen Hemminger <[email protected]>Which commit is fixed, can you please add Fixes tag?
and stable tag if it is requested for backport
Hi Stephen,
Reminder of this patch, which is still waiting for fixes tag.
Re: [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes
In reply to Stephen HemmingerI have been without power and offline all week.
Will try and get back next week
Quoted 126 lines · Stephen Hemminger
When doing
rte_eth_dev_get_supported_ptypeson 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 <[email protected]>--- 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(-)drivers/net/netvsc/hn_ethdev.c +46
-0@@ -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){drivers/net/netvsc/hn_ethdev.c +1
-1@@ -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,drivers/net/netvsc/hn_var.h +0
-1@@ -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);drivers/net/netvsc/hn_vf.c +0
-15@@ -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