From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Zerun Fu <zerun.fu@corigine.com>,
Chaoyong He <chaoyong.he@corigine.com>,
Long Wu <long.wu@corigine.com>,
Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH 02/17] net/nfp: refactor device speed update logic
Date: Mon, 24 Jun 2024 09:57:08 +0800 [thread overview]
Message-ID: <20240624015723.3712898-3-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240624015723.3712898-1-chaoyong.he@corigine.com>
From: Zerun Fu <zerun.fu@corigine.com>
The previous logic will call 'nfp_eth_read_ports()' every time when the
link status changed, but some of which are not necessary.
Refactor this part of logic and only call 'nfp_eth_read_ports()' when
the speed is really updated or the device is under auto-negotiation mode.
Signed-off-by: Zerun Fu <zerun.fu@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_ethdev.c | 3 +++
drivers/net/nfp/nfp_net_common.c | 18 ++++++++++++------
drivers/net/nfp/nfp_net_common.h | 3 +++
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index f4fd013a51..9870b2dd33 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -339,6 +339,8 @@ nfp_net_speed_configure(struct rte_eth_dev *dev)
}
}
+ hw_priv->pf_dev->speed_updated = true;
+
return 0;
}
@@ -2250,6 +2252,7 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
pf_dev->nfp_eth_table = nfp_eth_table;
pf_dev->sync = sync;
pf_dev->total_phyports = nfp_net_get_port_num(pf_dev, nfp_eth_table);
+ pf_dev->speed_updated = false;
ret = nfp_net_speed_cap_get(pf_dev);
if (ret != 0) {
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 5616160686..fed8daa188 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -738,22 +738,28 @@ nfp_net_speed_aneg_update(struct rte_eth_dev *dev,
{
uint32_t i;
uint32_t speed;
+ enum nfp_eth_aneg aneg;
+ struct nfp_pf_dev *pf_dev;
struct nfp_eth_table *nfp_eth_table;
struct nfp_eth_table_port *eth_port;
+ pf_dev = hw_priv->pf_dev;
+ aneg = pf_dev->nfp_eth_table->ports[hw->idx].aneg;
+
/* 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_priv->pf_dev->cpp);
+ if (pf_dev->speed_updated || aneg == NFP_ANEG_AUTO) {
+ nfp_eth_table = nfp_eth_read_ports(pf_dev->cpp);
if (nfp_eth_table == NULL) {
PMD_DRV_LOG(DEBUG, "Error reading NFP ethernet table.");
return -EIO;
+ } else {
+ pf_dev->nfp_eth_table->ports[hw->idx] = nfp_eth_table->ports[hw->idx];
+ free(nfp_eth_table);
+ pf_dev->speed_updated = false;
}
-
- hw_priv->pf_dev->nfp_eth_table->ports[hw->idx] = nfp_eth_table->ports[hw->idx];
- free(nfp_eth_table);
}
- nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
+ nfp_eth_table = pf_dev->nfp_eth_table;
eth_port = &nfp_eth_table->ports[hw->idx];
speed = eth_port->speed;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index b43f815951..8e3e219261 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -160,6 +160,9 @@ struct nfp_pf_dev {
uint8_t vf_base_id;
/** Number of queues per VF */
uint32_t queue_per_vf;
+
+ /** Record the speed uptade */
+ bool speed_updated;
};
#define NFP_NET_FLOW_LIMIT 1024
--
2.39.1
next prev parent reply other threads:[~2024-06-24 1:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 1:57 [PATCH 00/17] NFP bugfix Chaoyong He
2024-06-24 1:57 ` [PATCH 01/17] net/nfp: refactor speed configuration logic Chaoyong He
2024-06-24 1:57 ` Chaoyong He [this message]
2024-06-24 1:57 ` [PATCH 03/17] net/nfp: fix link status display problem Chaoyong He
2024-06-24 1:57 ` [PATCH 04/17] net/nfp: fix coredump caused by firmware abnormal cleanup Chaoyong He
2024-06-24 1:57 ` [PATCH 05/17] net/nfp: forbid offload flow rules with empty action list Chaoyong He
2024-06-24 1:57 ` [PATCH 06/17] net/nfp: remove redundancy function call Chaoyong He
2024-06-24 1:57 ` [PATCH 07/17] net/nfp: fix flow rule match data problem Chaoyong He
2024-06-24 1:57 ` [PATCH 08/17] net/nfp: fix flow rule action " Chaoyong He
2024-06-24 1:57 ` [PATCH 09/17] net/nfp: enlarge the flow rules limitation Chaoyong He
2024-06-24 1:57 ` [PATCH 10/17] net/nfp: enlarge flow hash table size Chaoyong He
2024-06-24 1:57 ` [PATCH 11/17] net/nfp: fix flow position index problem Chaoyong He
2024-06-24 1:57 ` [PATCH 12/17] net/nfp: fix getting firmware version Chaoyong He
2024-06-24 1:57 ` [PATCH 13/17] doc: update the metadata description section Chaoyong He
2024-06-24 1:57 ` [PATCH 14/17] net/nfp: remove the unneeded logic Chaoyong He
2024-06-24 1:57 ` [PATCH 15/17] net/nfp: adapts the reverse sequence card Chaoyong He
2024-06-24 1:57 ` [PATCH 16/17] net/nfp: fix null pointer dereferences Chaoyong He
2024-06-24 1:57 ` [PATCH 17/17] net/nfp: fix port action core dump Chaoyong He
2024-07-07 23:57 ` Ferruh Yigit
2024-07-08 3:12 ` [PATCH v2] " Chaoyong He
2024-07-08 16:00 ` Ferruh Yigit
2024-07-07 23:58 ` [PATCH 00/17] NFP bugfix 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=20240624015723.3712898-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=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).