From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes
Date: Mon, 23 Nov 2020 14:19:18 -0800 [thread overview]
Message-ID: <20201123221918.20825-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20201123221918.20825-1-stephen@networkplumber.org>
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
next prev parent reply other threads:[~2020-11-23 22:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2020-12-08 15:53 ` [dpdk-dev] [PATCH 2/2] net/netvsc: fix ethdev get_supported_ptypes Ferruh Yigit
2020-12-08 17:04 ` Kevin Traynor
2021-01-29 16:56 ` Ferruh Yigit
2021-02-19 17:41 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201123221918.20825-3-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).