From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
Long Wu <long.wu@corigine.com>,
Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH] net/nfp: add support reading linkspeed from port table
Date: Fri, 9 Dec 2022 10:43:59 +0800 [thread overview]
Message-ID: <20221209024359.15245-1-chaoyong.he@corigine.com> (raw)
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
next reply other threads:[~2022-12-09 2:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-09 2:43 Chaoyong He [this message]
2023-01-18 15:34 ` 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=20221209024359.15245-1-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=long.wu@corigine.com \
--cc=niklas.soderlund@corigine.com \
--cc=oss-drivers@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).