DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Zerun Fu <zerun.fu@corigine.com>,
	Long Wu <long.wu@corigine.com>,
	Peng Zhang <peng.zhang@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 4/7] net/nfp: modify the link update function
Date: Mon, 11 Dec 2023 11:08:55 +0800	[thread overview]
Message-ID: <20231211030858.1693240-5-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20231211030858.1693240-1-chaoyong.he@corigine.com>

From: Zerun Fu <zerun.fu@corigine.com>

Modify the link update function to get the new port speed state
after the port speed is changed, including the new speed and
whether the auto negotiation mode is enabled.

Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/nfp_net_common.c  | 59 ++++++++++++++++++++++++-------
 drivers/net/nfp/nfpcore/nfp_nsp.c |  4 +--
 2 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index ed410a7313..1658cc7d3c 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -643,6 +643,46 @@ nfp_net_allmulticast_disable(struct rte_eth_dev *dev)
 	return nfp_net_set_allmulticast_mode(dev, false);
 }
 
+static int
+nfp_net_speed_aneg_update(struct rte_eth_dev *dev,
+		struct nfp_net_hw *hw,
+		struct rte_eth_link *link)
+{
+	uint32_t i;
+	uint32_t speed;
+	struct nfp_eth_table *nfp_eth_table;
+	struct nfp_eth_table_port *eth_port;
+
+	/* Compare whether the current status has changed. */
+	if (dev->data->dev_link.link_status != link->link_status) {
+		nfp_eth_table = nfp_eth_read_ports(hw->cpp);
+		if (nfp_eth_table == NULL) {
+			PMD_DRV_LOG(DEBUG, "Error reading NFP ethernet table.");
+			return -EIO;
+		}
+
+		hw->pf_dev->nfp_eth_table->ports[hw->idx] = nfp_eth_table->ports[hw->idx];
+		free(nfp_eth_table);
+	}
+
+	nfp_eth_table = hw->pf_dev->nfp_eth_table;
+	eth_port = &nfp_eth_table->ports[hw->idx];
+	speed = eth_port->speed;
+
+	for (i = 0; i < RTE_DIM(nfp_net_link_speed_nfp2rte); i++) {
+		if (nfp_net_link_speed_nfp2rte[i] == speed) {
+			link->link_speed = speed;
+			break;
+		}
+	}
+
+	if (dev->data->dev_conf.link_speeds == RTE_ETH_LINK_SPEED_AUTONEG &&
+			eth_port->supp_aneg)
+		link->link_autoneg = RTE_ETH_LINK_AUTONEG;
+
+	return 0;
+}
+
 int
 nfp_net_link_update_common(struct rte_eth_dev *dev,
 		struct nfp_net_hw *hw,
@@ -650,23 +690,14 @@ nfp_net_link_update_common(struct rte_eth_dev *dev,
 		uint32_t link_status)
 {
 	int ret;
-	uint32_t i;
 	uint32_t nn_link_status;
-	struct nfp_eth_table *nfp_eth_table;
-
-	link->link_speed = RTE_ETH_SPEED_NUM_NONE;
 
 	if (link->link_status == RTE_ETH_LINK_UP) {
 		if (hw->pf_dev != NULL) {
-			nfp_eth_table = hw->pf_dev->nfp_eth_table;
-			if (nfp_eth_table != NULL) {
-				uint32_t speed = nfp_eth_table->ports[hw->idx].speed;
-				for (i = 0; i < RTE_DIM(nfp_net_link_speed_nfp2rte); i++) {
-					if (nfp_net_link_speed_nfp2rte[i] == speed) {
-						link->link_speed = speed;
-						break;
-					}
-				}
+			ret = nfp_net_speed_aneg_update(dev, hw, link);
+			if (ret != 0) {
+				PMD_DRV_LOG(DEBUG, "Failed to update speed and aneg.");
+				return ret;
 			}
 		} else {
 			/*
@@ -718,6 +749,8 @@ 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);
+	if (ret == -EIO)
+		return ret;
 
 	/*
 	 * Notify the port to update the speed value in the CTRL BAR from NSP.
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c
index f67572be87..6a2ba709ab 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.c
@@ -221,7 +221,7 @@ nfp_nsp_check(struct nfp_nsp *state)
 	}
 
 	if ((reg & NSP_STATUS_BUSY) != 0) {
-		PMD_DRV_LOG(ERR, "Service processor busy!");
+		PMD_DRV_LOG(DEBUG, "Service processor busy!");
 		return -EBUSY;
 	}
 
@@ -258,7 +258,7 @@ nfp_nsp_open(struct nfp_cpp *cpp)
 
 	err = nfp_nsp_check(state);
 	if (err != 0) {
-		PMD_DRV_LOG(ERR, "NSP - check failed");
+		PMD_DRV_LOG(DEBUG, "NSP - check failed");
 		nfp_nsp_close(state);
 		return NULL;
 	}
-- 
2.39.1


  parent reply	other threads:[~2023-12-11  3:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-11  3:08 [PATCH 0/7] support link auto negotiation Chaoyong He
2023-12-11  3:08 ` [PATCH 1/7] net/nfp: set a new parameter to hwinfo Chaoyong He
2023-12-11  3:08 ` [PATCH 2/7] net/nfp: support getting speed capability Chaoyong He
2023-12-11  3:08 ` [PATCH 3/7] net/nfp: support setting port speed Chaoyong He
2023-12-11  3:08 ` Chaoyong He [this message]
2023-12-11  3:08 ` [PATCH 5/7] net/nfp: support getting FEC capability Chaoyong He
2023-12-11  3:08 ` [PATCH 6/7] net/nfp: support getting FEC mode Chaoyong He
2023-12-11  3:08 ` [PATCH 7/7] net/nfp: support setting " Chaoyong He
2023-12-12 15:28 ` [PATCH 0/7] support link auto negotiation Ferruh Yigit

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=20231211030858.1693240-5-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=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).