From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Zerun Fu <zerun.fu@corigine.com>,
stable@dpdk.org, Chaoyong He <chaoyong.he@corigine.com>,
Long Wu <long.wu@corigine.com>,
Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH 12/17] net/nfp: fix getting firmware version
Date: Mon, 24 Jun 2024 09:57:18 +0800 [thread overview]
Message-ID: <20240624015723.3712898-13-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240624015723.3712898-1-chaoyong.he@corigine.com>
From: Zerun Fu <zerun.fu@corigine.com>
The original logic try to get the NSP resource every time the application
call 'rte_eth_dev_fw_version_get()' interface, there are chances the NSP
resource busy and fail to get it. And because the local string variables
not initialized, there will be out of range problem when it fail to get
the NSP resource.
Fix this by initializing the local string variables and storing the
firmware version string once we get it.
Fixes: 128c8ad951bf ("net/nfp: support getting firmware version")
Cc: stable@dpdk.org
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_net_common.c | 26 ++++++++++++++++++--------
drivers/net/nfp/nfp_net_common.h | 6 ++++++
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index a6573ed45c..84893e2d73 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -193,9 +193,6 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
nfp_net_link_speed_rte2nfp(link->link_speed));
}
-/* The length of firmware version string */
-#define FW_VER_LEN 32
-
/**
* Reconfigure the firmware of VF configure
*
@@ -2274,11 +2271,11 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
size_t fw_size)
{
struct nfp_net_hw *hw;
- char mip_name[FW_VER_LEN];
- char app_name[FW_VER_LEN];
- char nsp_version[FW_VER_LEN];
- char vnic_version[FW_VER_LEN];
struct nfp_net_hw_priv *hw_priv;
+ char app_name[FW_VER_LEN] = {0};
+ char mip_name[FW_VER_LEN] = {0};
+ char nsp_version[FW_VER_LEN] = {0};
+ char vnic_version[FW_VER_LEN] = {0};
if (fw_size < FW_VER_LEN)
return FW_VER_LEN;
@@ -2286,6 +2283,11 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
hw = nfp_net_get_hw(dev);
hw_priv = dev->process_private;
+ if (hw->fw_version[0] != 0) {
+ snprintf(fw_version, FW_VER_LEN, "%s", hw->fw_version);
+ return 0;
+ }
+
if (!rte_eth_dev_is_repr(dev)) {
snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d",
hw->ver.extend, hw->ver.class,
@@ -2298,8 +2300,16 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
nfp_net_get_mip_name(hw_priv, mip_name);
nfp_net_get_app_name(hw_priv, app_name);
- snprintf(fw_version, FW_VER_LEN, "%s %s %s %s",
+ if (nsp_version[0] == 0 || mip_name[0] == 0) {
+ snprintf(fw_version, FW_VER_LEN, "%s %s %s %s",
vnic_version, nsp_version, mip_name, app_name);
+ return 0;
+ }
+
+ snprintf(hw->fw_version, FW_VER_LEN, "%s %s %s %s",
+ vnic_version, nsp_version, mip_name, app_name);
+
+ snprintf(fw_version, FW_VER_LEN, "%s", hw->fw_version);
return 0;
}
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 6c739891be..3c4d305b01 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -50,6 +50,9 @@
RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
+/* The length of firmware version string */
+#define FW_VER_LEN 32
+
/*
* Each PF has corresponding word to beat:
* Offset | Usage
@@ -255,6 +258,9 @@ struct nfp_net_hw {
/** Used for rte_flow of CoreNIC firmware */
struct nfp_net_priv *priv;
+
+ /** Used for firmware version */
+ char fw_version[FW_VER_LEN];
};
static inline uint32_t
--
2.39.1
next prev parent reply other threads:[~2024-06-24 1:59 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 ` [PATCH 02/17] net/nfp: refactor device speed update logic Chaoyong He
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 ` Chaoyong He [this message]
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-13-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=stable@dpdk.org \
--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).