net/nfp: fix failure of PF initiation on flower firmware

Message ID 20240308031110.2041280-1-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/nfp: fix failure of PF initiation on flower firmware |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Chaoyong He March 8, 2024, 3:11 a.m. UTC
  From: Zerun Fu <zerun.fu@corigine.com>

The previous logic did not distinguish the firmware type when
reading the value of "app_cap" during the initialization of the
PF. This operation is not supported by the flower firmware, and
this will lead to a startup failure.
Fix this by adding the logic to check the firmware type.

Fixes: c7a6970fc637 ("net/nfp: notify BSP if FW speed needs to be switched")
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_ethdev.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)
  

Comments

Ferruh Yigit March 8, 2024, 9:46 a.m. UTC | #1
On 3/8/2024 3:11 AM, Chaoyong He wrote:
> From: Zerun Fu <zerun.fu@corigine.com>
> 
> The previous logic did not distinguish the firmware type when
> reading the value of "app_cap" during the initialization of the
> PF. This operation is not supported by the flower firmware, and
> this will lead to a startup failure.
> Fix this by adding the logic to check the firmware type.
> 
> Fixes: c7a6970fc637 ("net/nfp: notify BSP if FW speed needs to be switched")
> 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>
>

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

Patch

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 8c38b4e134..1e713ee111 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -1605,30 +1605,34 @@  nfp_init_app_fw_nic(struct nfp_pf_dev *pf_dev,
 static int
 nfp_net_hwinfo_set(uint8_t function_id,
 		struct nfp_rtsym_table *sym_tbl,
-		struct nfp_cpp *cpp)
+		struct nfp_cpp *cpp,
+		enum nfp_app_fw_id app_fw_id)
 {
 	int ret = 0;
 	uint64_t app_cap;
-	uint8_t sp_indiff;
 	struct nfp_nsp *nsp;
+	uint8_t sp_indiff = 1;
 	char hw_info[RTE_ETH_NAME_MAX_LEN];
 	char app_cap_name[RTE_ETH_NAME_MAX_LEN];
 
-	/* Read the app capabilities of the firmware loaded */
-	snprintf(app_cap_name, sizeof(app_cap_name), "_pf%u_net_app_cap", function_id);
-	app_cap = nfp_rtsym_read_le(sym_tbl, app_cap_name, &ret);
-	if (ret != 0) {
-		PMD_INIT_LOG(ERR, "Couldn't read app_fw_cap from firmware.");
-		return ret;
+	if (app_fw_id != NFP_APP_FW_FLOWER_NIC) {
+		/* Read the app capabilities of the firmware loaded */
+		snprintf(app_cap_name, sizeof(app_cap_name), "_pf%u_net_app_cap", function_id);
+		app_cap = nfp_rtsym_read_le(sym_tbl, app_cap_name, &ret);
+		if (ret != 0) {
+			PMD_INIT_LOG(ERR, "Could not read app_fw_cap from firmware.");
+			return ret;
+		}
+
+		/* Calculate the value of sp_indiff and write to hw_info */
+		sp_indiff = app_cap & NFP_NET_APP_CAP_SP_INDIFF;
 	}
 
-	/* Calculate the value of sp_indiff and write to hw_info */
-	sp_indiff = app_cap & NFP_NET_APP_CAP_SP_INDIFF;
 	snprintf(hw_info, sizeof(hw_info), "sp_indiff=%u", sp_indiff);
 
 	nsp = nfp_nsp_open(cpp);
 	if (nsp == NULL) {
-		PMD_INIT_LOG(ERR, "Couldn't get NSP.");
+		PMD_INIT_LOG(ERR, "Could not get NSP.");
 		return -EIO;
 	}
 
@@ -1873,7 +1877,7 @@  nfp_pf_init(struct rte_pci_device *pci_dev)
 	}
 
 	/* Write sp_indiff to hw_info */
-	ret = nfp_net_hwinfo_set(function_id, sym_tbl, cpp);
+	ret = nfp_net_hwinfo_set(function_id, sym_tbl, cpp, app_fw_id);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to set hwinfo.");
 		ret = -EIO;