diff mbox series

[2/2] net/netvsc: fix ethdev get_supported_ptypes

Message ID 20201123221918.20825-3-stephen@networkplumber.org (mailing list archive)
State Changes Requested
Delegated to: Ferruh Yigit
Headers show
Series net/netvsc: fix supported_ptypes | expand

Checks

Context Check Description
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-testing warning Testing issues
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Nov. 23, 2020, 10:19 p.m. UTC
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 <stephen@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(-)

Comments

Ferruh Yigit Dec. 8, 2020, 3:53 p.m. UTC | #1
On 11/23/2020 10:19 PM, Stephen Hemminger wrote:
> 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 <stephen@networkplumber.org>

Which commit is fixed, can you please add Fixes tag?
Kevin Traynor Dec. 8, 2020, 5:04 p.m. UTC | #2
On 08/12/2020 15:53, Ferruh Yigit wrote:
> On 11/23/2020 10:19 PM, Stephen Hemminger wrote:
>> 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 <stephen@networkplumber.org>
> 
> Which commit is fixed, can you please add Fixes tag?
> 

and stable tag if it is requested for backport
Ferruh Yigit Jan. 29, 2021, 4:56 p.m. UTC | #3
On 12/8/2020 5:04 PM, Kevin Traynor wrote:
> On 08/12/2020 15:53, Ferruh Yigit wrote:
>> On 11/23/2020 10:19 PM, Stephen Hemminger wrote:
>>> 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 <stephen@networkplumber.org>
>>
>> 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.
Stephen Hemminger Feb. 19, 2021, 5:41 p.m. UTC | #4
I have been without power and offline all week.
Will try and get back next week

On Mon, Nov 23, 2020, 2:19 PM Stephen Hemminger <stephen@networkplumber.org>
wrote:

> 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 <stephen@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
>
>
diff mbox series

Patch

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;