From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Qin Ke <qin.ke@corigine.com>,
zerun.fu@corigine.com, stable@dpdk.org,
Chaoyong He <chaoyong.he@corigine.com>,
Long Wu <long.wu@corigine.com>,
Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH 6/8] net/nfp: fix representor port link speed update problem
Date: Thu, 5 Sep 2024 14:25:09 +0800 [thread overview]
Message-ID: <20240905062511.2710102-7-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240905062511.2710102-1-chaoyong.he@corigine.com>
From: Qin Ke <qin.ke@corigine.com>
For representor port link speed, the original logic finally calls
'nfp_net_speed_aneg_update()' to update it. But the reference of
'hw->idx' in this function is invalid for representor port devices,
the logic has problem.
Fix it by getting correct 'idx' for all type of deives including
representor port and make reference to it.
Fixes: 8412feed3f26 ("net/nfp: modify link update function")
Cc: zerun.fu@corigine.com
Cc: stable@dpdk.org
Signed-off-by: Qin Ke <qin.ke@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
.../net/nfp/flower/nfp_flower_representor.c | 2 +-
drivers/net/nfp/nfp_net_common.c | 32 +++++++++++++++----
drivers/net/nfp/nfp_net_common.h | 2 +-
3 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index e7593313e2..054ea1a938 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -40,7 +40,7 @@ nfp_flower_repr_link_update(struct rte_eth_dev *dev,
pf_hw = repr->app_fw_flower->pf_hw;
nn_link_status = nn_cfg_readw(&pf_hw->super, NFP_NET_CFG_STS);
- ret = nfp_net_link_update_common(dev, pf_hw, link, nn_link_status);
+ ret = nfp_net_link_update_common(dev, link, nn_link_status);
return ret;
}
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 6761a16ef2..daed57e374 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -311,6 +311,24 @@ nfp_net_get_hw(const struct rte_eth_dev *dev)
return hw;
}
+uint8_t
+nfp_net_get_idx(const struct rte_eth_dev *dev)
+{
+ uint8_t idx;
+
+ if (rte_eth_dev_is_repr(dev)) {
+ struct nfp_flower_representor *repr;
+ repr = dev->data->dev_private;
+ idx = repr->idx;
+ } else {
+ struct nfp_net_hw *hw;
+ hw = dev->data->dev_private;
+ idx = hw->idx;
+ }
+
+ return idx;
+}
+
/*
* Configure an Ethernet device.
*
@@ -743,17 +761,18 @@ nfp_net_allmulticast_disable(struct rte_eth_dev *dev)
static void
nfp_net_pf_speed_update(struct rte_eth_dev *dev,
- struct nfp_net_hw *hw,
struct nfp_net_hw_priv *hw_priv,
struct rte_eth_link *link)
{
+ uint8_t idx;
enum nfp_eth_aneg aneg;
struct nfp_pf_dev *pf_dev;
struct nfp_eth_table *nfp_eth_table;
struct nfp_eth_table_port *eth_port;
pf_dev = hw_priv->pf_dev;
- aneg = pf_dev->nfp_eth_table->ports[hw->idx].aneg;
+ idx = nfp_net_get_idx(dev);
+ aneg = pf_dev->nfp_eth_table->ports[idx].aneg;
/* Compare whether the current status has changed. */
if (pf_dev->speed_updated || aneg == NFP_ANEG_AUTO) {
@@ -761,14 +780,14 @@ nfp_net_pf_speed_update(struct rte_eth_dev *dev,
if (nfp_eth_table == NULL) {
PMD_DRV_LOG(WARNING, "Failed to update port speed.");
} else {
- pf_dev->nfp_eth_table->ports[hw->idx] = nfp_eth_table->ports[hw->idx];
+ pf_dev->nfp_eth_table->ports[idx] = nfp_eth_table->ports[idx];
free(nfp_eth_table);
pf_dev->speed_updated = false;
}
}
nfp_eth_table = pf_dev->nfp_eth_table;
- eth_port = &nfp_eth_table->ports[hw->idx];
+ eth_port = &nfp_eth_table->ports[idx];
link->link_speed = nfp_net_link_speed_nfp2rte_check(eth_port->speed);
@@ -797,7 +816,6 @@ nfp_net_vf_speed_update(struct rte_eth_link *link,
int
nfp_net_link_update_common(struct rte_eth_dev *dev,
- struct nfp_net_hw *hw,
struct rte_eth_link *link,
uint32_t link_status)
{
@@ -807,7 +825,7 @@ nfp_net_link_update_common(struct rte_eth_dev *dev,
hw_priv = dev->process_private;
if (link->link_status == RTE_ETH_LINK_UP) {
if (hw_priv->is_pf)
- nfp_net_pf_speed_update(dev, hw, hw_priv, link);
+ nfp_net_pf_speed_update(dev, hw_priv, link);
else
nfp_net_vf_speed_update(link, link_status);
}
@@ -851,7 +869,7 @@ nfp_net_link_update(struct rte_eth_dev *dev,
link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
- ret = nfp_net_link_update_common(dev, hw, &link, nn_link_status);
+ ret = nfp_net_link_update_common(dev, &link, nn_link_status);
if (ret == -EIO)
return ret;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index be5705636f..a32f3b330a 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -293,7 +293,6 @@ int nfp_net_promisc_disable(struct rte_eth_dev *dev);
int nfp_net_allmulticast_enable(struct rte_eth_dev *dev);
int nfp_net_allmulticast_disable(struct rte_eth_dev *dev);
int nfp_net_link_update_common(struct rte_eth_dev *dev,
- struct nfp_net_hw *hw,
struct rte_eth_link *link,
uint32_t link_status);
int nfp_net_link_update(struct rte_eth_dev *dev,
@@ -356,6 +355,7 @@ int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size
bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version);
bool nfp_net_is_valid_version_class(struct nfp_net_fw_ver version);
struct nfp_net_hw *nfp_net_get_hw(const struct rte_eth_dev *dev);
+uint8_t nfp_net_get_idx(const struct rte_eth_dev *dev);
int nfp_net_stop(struct rte_eth_dev *dev);
int nfp_net_flow_ctrl_get(struct rte_eth_dev *dev,
struct rte_eth_fc_conf *fc_conf);
--
2.39.1
next prev parent reply other threads:[~2024-09-05 6:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240905062511.2710102-1-chaoyong.he@corigine.com>
2024-09-05 6:25 ` [PATCH 1/8] net/nfp: fix incorrect type declaration of some variables Chaoyong He
2024-09-05 6:25 ` Chaoyong He [this message]
2024-09-05 6:25 ` [PATCH 8/8] net/nfp: fix representor port link status update problem Chaoyong He
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=20240905062511.2710102-7-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=long.wu@corigine.com \
--cc=oss-drivers@corigine.com \
--cc=peng.zhang@corigine.com \
--cc=qin.ke@corigine.com \
--cc=stable@dpdk.org \
--cc=zerun.fu@corigine.com \
/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).