DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] net/netvsc: fix supported_ptypes
@ 2020-11-23 22:19 Stephen Hemminger
  2020-11-23 22:19 ` [dpdk-dev] [PATCH 1/2] net/netvsc: remove unused code Stephen Hemminger
  2020-11-23 22:19 ` [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes Stephen Hemminger
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen Hemminger @ 2020-11-23 22:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

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(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH 1/2] net/netvsc: remove unused code
  2020-11-23 22:19 [dpdk-dev] [PATCH 0/2] net/netvsc: fix supported_ptypes Stephen Hemminger
@ 2020-11-23 22:19 ` Stephen Hemminger
  2020-11-23 22:19 ` [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes Stephen Hemminger
  1 sibling, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2020-11-23 22:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This code is not called anywhere.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/netvsc/hn_rndis.c | 31 -------------------------------
 drivers/net/netvsc/hn_rndis.h |  1 -
 2 files changed, 32 deletions(-)

diff --git a/drivers/net/netvsc/hn_rndis.c b/drivers/net/netvsc/hn_rndis.c
index 1ce260c89b95..beb716f3c96c 100644
--- a/drivers/net/netvsc/hn_rndis.c
+++ b/drivers/net/netvsc/hn_rndis.c
@@ -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)
 {
diff --git a/drivers/net/netvsc/hn_rndis.h b/drivers/net/netvsc/hn_rndis.h
index 9a8251fc2fb4..11b89042dd4b 100644
--- a/drivers/net/netvsc/hn_rndis.h
+++ b/drivers/net/netvsc/hn_rndis.h
@@ -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);
-- 
2.27.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes
  2020-11-23 22:19 [dpdk-dev] [PATCH 0/2] net/netvsc: fix supported_ptypes Stephen Hemminger
  2020-11-23 22:19 ` [dpdk-dev] [PATCH 1/2] net/netvsc: remove unused code Stephen Hemminger
@ 2020-11-23 22:19 ` Stephen Hemminger
  2020-12-08 15:53   ` Ferruh Yigit
  2021-02-19 17:41   ` Stephen Hemminger
  1 sibling, 2 replies; 7+ messages in thread
From: Stephen Hemminger @ 2020-11-23 22:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes
  2020-11-23 22:19 ` [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes Stephen Hemminger
@ 2020-12-08 15:53   ` Ferruh Yigit
  2020-12-08 17:04     ` Kevin Traynor
  2021-02-19 17:41   ` Stephen Hemminger
  1 sibling, 1 reply; 7+ messages in thread
From: Ferruh Yigit @ 2020-12-08 15:53 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

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?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes
  2020-12-08 15:53   ` Ferruh Yigit
@ 2020-12-08 17:04     ` Kevin Traynor
  2021-01-29 16:56       ` Ferruh Yigit
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Traynor @ 2020-12-08 17:04 UTC (permalink / raw)
  To: Ferruh Yigit, Stephen Hemminger; +Cc: dev

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes
  2020-12-08 17:04     ` Kevin Traynor
@ 2021-01-29 16:56       ` Ferruh Yigit
  0 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2021-01-29 16:56 UTC (permalink / raw)
  To: Kevin Traynor, Stephen Hemminger; +Cc: dev

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes
  2020-11-23 22:19 ` [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes Stephen Hemminger
  2020-12-08 15:53   ` Ferruh Yigit
@ 2021-02-19 17:41   ` Stephen Hemminger
  1 sibling, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2021-02-19 17:41 UTC (permalink / raw)
  To: dev

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
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-02-19 17:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-23 22:19 [dpdk-dev] [PATCH 0/2] net/netvsc: fix supported_ptypes Stephen Hemminger
2020-11-23 22:19 ` [dpdk-dev] [PATCH 1/2] net/netvsc: remove unused code Stephen Hemminger
2020-11-23 22:19 ` [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes Stephen Hemminger
2020-12-08 15:53   ` Ferruh Yigit
2020-12-08 17:04     ` Kevin Traynor
2021-01-29 16:56       ` Ferruh Yigit
2021-02-19 17:41   ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).