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, Qin Ke <qin.ke@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>,
	Long Wu <long.wu@corigine.com>,
	Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH 2/8] net/nfp: add help function to check link speed
Date: Thu,  5 Sep 2024 14:25:05 +0800	[thread overview]
Message-ID: <20240905062511.2710102-3-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240905062511.2710102-1-chaoyong.he@corigine.com>

From: Qin Ke <qin.ke@corigine.com>

Add help function to check link speed.

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>
---
 drivers/net/nfp/nfp_net_common.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index be0b6dc0cf..25872a4131 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -170,6 +170,19 @@ nfp_net_link_speed_rte2nfp(uint32_t speed)
 	return NFP_NET_CFG_STS_LINK_RATE_UNKNOWN;
 }
 
+static uint32_t
+nfp_net_link_speed_nfp2rte_check(uint32_t speed)
+{
+	size_t i;
+
+	for (i = 0; i < RTE_DIM(nfp_net_link_speed_nfp2rte); i++) {
+		if (speed == nfp_net_link_speed_nfp2rte[i])
+			return nfp_net_link_speed_nfp2rte[i];
+	}
+
+	return RTE_ETH_SPEED_NUM_NONE;
+}
+
 static void
 nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 		struct rte_eth_link *link)
@@ -734,8 +747,6 @@ nfp_net_speed_aneg_update(struct rte_eth_dev *dev,
 		struct nfp_net_hw_priv *hw_priv,
 		struct rte_eth_link *link)
 {
-	uint32_t i;
-	uint32_t speed;
 	enum nfp_eth_aneg aneg;
 	struct nfp_pf_dev *pf_dev;
 	struct nfp_eth_table *nfp_eth_table;
@@ -758,14 +769,8 @@ nfp_net_speed_aneg_update(struct rte_eth_dev *dev,
 
 	nfp_eth_table = 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;
-		}
-	}
+	link->link_speed = nfp_net_link_speed_nfp2rte_check(eth_port->speed);
 
 	if (dev->data->dev_conf.link_speeds == RTE_ETH_LINK_SPEED_AUTONEG &&
 			eth_port->supp_aneg)
-- 
2.39.1


  parent reply	other threads:[~2024-09-05  6:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-05  6:25 [PATCH 0/8] fix the representor port link status and speed Chaoyong He
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 3/8] net/nfp: add help function to update VF link speed Chaoyong He
2024-09-05  6:25 ` [PATCH 4/8] net/nfp: rename PF speed update function Chaoyong He
2024-09-05  6:25 ` [PATCH 5/8] net/nfp: add new data field into representor port structure Chaoyong He
2024-09-05  6:25 ` [PATCH 6/8] net/nfp: fix representor port link speed update problem Chaoyong He
2024-09-05  6:25 ` [PATCH 7/8] net/nfp: standardize the use of port index in some functions Chaoyong He
2024-09-05  6:25 ` [PATCH 8/8] net/nfp: fix representor port link status update problem Chaoyong He
2024-10-04 18:17 ` [PATCH 0/8] fix the representor port link status and speed 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=20240905062511.2710102-3-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 \
    /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).