DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/nfp: add support reading linkspeed from port table
@ 2022-12-09  2:43 Chaoyong He
  2023-01-18 15:34 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Chaoyong He @ 2022-12-09  2:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, niklas.soderlund, Long Wu, Chaoyong He

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

The NFP PMD driver retrieves the linkspeed by reading the
NFP_NET_CFG_STS_LINK register. This register is not set by all versions
of the firmware.

Add a second preferred method to read the linkspeed from the port table
instead, while keeping the old lookup method as a fallback in case that
is not supported.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 drivers/net/nfp/nfp_common.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 71711bfa22..71f649e606 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -492,7 +492,9 @@ nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
 {
 	struct nfp_net_hw *hw;
 	struct rte_eth_link link;
+	struct nfp_eth_table *nfp_eth_table;
 	uint32_t nn_link_status;
+	uint32_t i;
 	int ret;
 
 	static const uint32_t ls_to_ethtool[] = {
@@ -519,13 +521,28 @@ nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
 
 	link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
 
-	nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) &
-			 NFP_NET_CFG_STS_LINK_RATE_MASK;
+	if (hw->pf_dev != NULL) {
+		nfp_eth_table = hw->pf_dev->nfp_eth_table;
+		if (nfp_eth_table != NULL) {
+			link.link_speed = nfp_eth_table->ports[hw->idx].speed;
+			for (i = 0; i < RTE_DIM(ls_to_ethtool); i++) {
+				if (ls_to_ethtool[i] == link.link_speed)
+					break;
+			}
+			if (i == RTE_DIM(ls_to_ethtool))
+				link.link_speed = RTE_ETH_SPEED_NUM_NONE;
+		} else {
+			link.link_speed = RTE_ETH_SPEED_NUM_NONE;
+		}
+	} else {
+		nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) &
+				NFP_NET_CFG_STS_LINK_RATE_MASK;
 
-	if (nn_link_status >= RTE_DIM(ls_to_ethtool))
-		link.link_speed = RTE_ETH_SPEED_NUM_NONE;
-	else
-		link.link_speed = ls_to_ethtool[nn_link_status];
+		if (nn_link_status >= RTE_DIM(ls_to_ethtool))
+			link.link_speed = RTE_ETH_SPEED_NUM_NONE;
+		else
+			link.link_speed = ls_to_ethtool[nn_link_status];
+	}
 
 	ret = rte_eth_linkstatus_set(dev, &link);
 	if (ret == 0) {
-- 
2.29.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] net/nfp: add support reading linkspeed from port table
  2022-12-09  2:43 [PATCH] net/nfp: add support reading linkspeed from port table Chaoyong He
@ 2023-01-18 15:34 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2023-01-18 15:34 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, niklas.soderlund, Long Wu

On 12/9/2022 2:43 AM, Chaoyong He wrote:
> From: Long Wu <long.wu@corigine.com>
> 
> The NFP PMD driver retrieves the linkspeed by reading the
> NFP_NET_CFG_STS_LINK register. This register is not set by all versions
> of the firmware.
> 
> Add a second preferred method to read the linkspeed from the port table
> instead, while keeping the old lookup method as a fallback in case that
> is not supported.
> 
> Signed-off-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>

Applied to dpdk-next-net/main, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-18 15:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-09  2:43 [PATCH] net/nfp: add support reading linkspeed from port table Chaoyong He
2023-01-18 15:34 ` Ferruh Yigit

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).