patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Long Wu <long.wu@corigine.com>,
	stable@dpdk.org, Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH] net/nfp: fix VF link speed problem
Date: Wed, 18 Dec 2024 14:52:55 +0800	[thread overview]
Message-ID: <20241218065255.1698520-1-chaoyong.he@corigine.com> (raw)

From: Long Wu <long.wu@corigine.com>

The previous logic does not update the 'rte_eth_device' link status
when the port link status changed, which cause the firmware won't be
notified by the PMD.
Furthermore, the physical representor port should also notify firmware
its current speed with multi-pf firmware.

Fix these problems by modify the related logic, also add needed helper
function at the same time.

Fixes: eae7dadbe987 ("net/nfp: update link status reporting")
Cc: stable@dpdk.org

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_ctrl.c      | 14 ++++++++++++++
 .../net/nfp/flower/nfp_flower_representor.c   | 19 +++++++++++++++++--
 .../net/nfp/flower/nfp_flower_representor.h   |  3 +++
 drivers/net/nfp/nfp_net_common.c              | 11 ++++++++++-
 4 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 92887ce1be..21bf26b738 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -420,6 +420,8 @@ nfp_flower_cmsg_port_mod_rx(struct nfp_net_hw_priv *hw_priv,
 {
 	uint32_t port;
 	uint32_t index;
+	uint16_t link_status;
+	struct rte_eth_dev *eth_dev;
 	struct nfp_flower_representor *repr;
 	struct nfp_flower_cmsg_port_mod *msg;
 	struct nfp_app_fw_flower *app_fw_flower;
@@ -456,11 +458,23 @@ nfp_flower_cmsg_port_mod_rx(struct nfp_net_hw_priv *hw_priv,
 	}
 
 	repr->link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
+
+	link_status = repr->link.link_status;
 	if ((msg->info & NFP_FLOWER_CMSG_PORT_MOD_INFO_LINK) != 0)
 		repr->link.link_status = RTE_ETH_LINK_UP;
 	else
 		repr->link.link_status = RTE_ETH_LINK_DOWN;
 
+	if (link_status != repr->link.link_status) {
+		eth_dev = rte_eth_dev_get_by_name(repr->name);
+		if (eth_dev == NULL) {
+			PMD_DRV_LOG(ERR, "Can not get 'eth_dev' by name %s.", repr->name);
+			return -EINVAL;
+		}
+
+		nfp_flower_repr_link_update(eth_dev, 0);
+	}
+
 	return 0;
 }
 
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 4017f602a2..9601aa5f96 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -24,6 +24,21 @@ struct nfp_repr_init {
 	struct nfp_net_hw_priv *hw_priv;
 };
 
+bool
+nfp_flower_repr_is_pf(struct rte_eth_dev *dev)
+{
+	struct nfp_net_hw_priv *hw_priv;
+	struct nfp_flower_representor *repr;
+
+	hw_priv = dev->process_private;
+	repr = dev->data->dev_private;
+
+	if (hw_priv->pf_dev->multi_pf.enabled)
+		return repr->repr_type == NFP_REPR_TYPE_PHYS_PORT;
+	else
+		return repr->repr_type == NFP_REPR_TYPE_PF;
+}
+
 static int
 nfp_repr_get_eeprom_len(struct rte_eth_dev *dev)
 {
@@ -112,7 +127,7 @@ nfp_flower_repr_led_off(struct rte_eth_dev *dev)
 	return nfp_net_led_off(dev);
 }
 
-static int
+int
 nfp_flower_repr_link_update(struct rte_eth_dev *dev,
 		__rte_unused int wait_to_complete)
 {
@@ -125,7 +140,7 @@ nfp_flower_repr_link_update(struct rte_eth_dev *dev,
 
 	ret = nfp_net_link_update_common(dev, link, link->link_status);
 
-	if (repr->repr_type == NFP_REPR_TYPE_PF)
+	if (nfp_flower_repr_is_pf(dev))
 		nfp_net_notify_port_speed(repr->app_fw_flower->pf_hw, link);
 
 	return ret;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.h b/drivers/net/nfp/flower/nfp_flower_representor.h
index 3f6ee32fe4..a7416eccab 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.h
+++ b/drivers/net/nfp/flower/nfp_flower_representor.h
@@ -32,5 +32,8 @@ int nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower,
 bool nfp_flower_repr_is_vf(struct nfp_flower_representor *repr);
 bool nfp_flower_repr_is_phy(struct nfp_flower_representor *repr);
 int nfp_flower_repr_stats_reset(struct rte_eth_dev *ethdev);
+int nfp_flower_repr_link_update(struct rte_eth_dev *dev,
+		__rte_unused int wait_to_complete);
+bool nfp_flower_repr_is_pf(struct rte_eth_dev *dev);
 
 #endif /* __NFP_FLOWER_REPRESENTOR_H__ */
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index e68ce68229..aaa515bac2 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -159,6 +159,15 @@ static const uint32_t nfp_net_link_speed_nfp2rte[] = {
 	[NFP_NET_CFG_STS_LINK_RATE_100G]        = RTE_ETH_SPEED_NUM_100G,
 };
 
+static bool
+nfp_net_is_pf(struct rte_eth_dev *dev)
+{
+	if (rte_eth_dev_is_repr(dev))
+		return nfp_flower_repr_is_pf(dev);
+
+	return ((struct nfp_net_hw_priv *)dev->process_private)->is_pf;
+}
+
 static size_t
 nfp_net_link_speed_rte2nfp(uint32_t speed)
 {
@@ -826,7 +835,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)
+		if (nfp_net_is_pf(dev))
 			nfp_net_pf_speed_update(dev, hw_priv, link);
 		else
 			nfp_net_vf_speed_update(link, link_status);
-- 
2.43.5


                 reply	other threads:[~2024-12-18  6:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20241218065255.1698520-1-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=oss-drivers@corigine.com \
    --cc=stable@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).