patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Chaoyong He <chaoyong.he@corigine.com>,
	stable@dpdk.org, Long Wu <long.wu@corigine.com>,
	Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH 1/2] net/nfp: fix logic of load firmware from flash
Date: Wed, 22 Jan 2025 09:47:50 +0800	[thread overview]
Message-ID: <20250122014751.1706413-2-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20250122014751.1706413-1-chaoyong.he@corigine.com>

The firmware load policy 'NFP_NSP_APP_FW_LOAD_FLASH' means first try to
load from file system, if failed then try to load from flash.

The original logic will cause load firmware fail if any mistake occurs
in the load from file system process.

Fix this by relocated the related logic.

Fixes: 08ea495d624b ("net/nfp: support loading firmware from flash")
Cc: stable@dpdk.org

Signed-off-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 | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index f54483822f..13751469b8 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -1529,16 +1529,16 @@ nfp_fw_reload_for_single_pf(struct nfp_nsp *nsp,
 {
 	int ret;
 
-	if (policy == NFP_NSP_APP_FW_LOAD_FLASH && nfp_nsp_has_stored_fw_load(nsp)) {
-		ret = nfp_fw_reload_from_flash(nsp);
+	if (fw_name[0] != 0 && policy != NFP_NSP_APP_FW_LOAD_FLASH) {
+		ret = nfp_fw_reload_for_single_pf_from_disk(nsp, fw_name, pf_dev, reset);
 		if (ret != 0) {
-			PMD_DRV_LOG(ERR, "Load single PF firmware from flash failed.");
+			PMD_DRV_LOG(ERR, "Load single PF firmware from disk failed.");
 			return ret;
 		}
-	} else if (fw_name[0] != 0) {
-		ret = nfp_fw_reload_for_single_pf_from_disk(nsp, fw_name, pf_dev, reset);
+	} else if (policy != NFP_NSP_APP_FW_LOAD_DISK && nfp_nsp_has_stored_fw_load(nsp)) {
+		ret = nfp_fw_reload_from_flash(nsp);
 		if (ret != 0) {
-			PMD_DRV_LOG(ERR, "Load single PF firmware from disk failed.");
+			PMD_DRV_LOG(ERR, "Load single PF firmware from flash failed.");
 			return ret;
 		}
 	} else {
@@ -1605,19 +1605,19 @@ nfp_fw_reload_for_multi_pf(struct nfp_nsp *nsp,
 		goto keepalive_uninit;
 	}
 
-	if (policy == NFP_NSP_APP_FW_LOAD_FLASH && nfp_nsp_has_stored_fw_load(nsp)) {
-		err = nfp_fw_reload_from_flash(nsp);
-		if (err != 0) {
-			PMD_DRV_LOG(ERR, "Load multi PF firmware from flash failed.");
-			goto keepalive_stop;
-		}
-	} else if (fw_name[0] != 0) {
+	if (fw_name[0] != 0 && policy != NFP_NSP_APP_FW_LOAD_FLASH) {
 		err = nfp_fw_reload_for_multi_pf_from_disk(nsp, fw_name, dev_info,
 				pf_dev, reset);
 		if (err != 0) {
 			PMD_DRV_LOG(ERR, "Load multi PF firmware from disk failed.");
 			goto keepalive_stop;
 		}
+	} else if (policy != NFP_NSP_APP_FW_LOAD_DISK && nfp_nsp_has_stored_fw_load(nsp)) {
+		err = nfp_fw_reload_from_flash(nsp);
+		if (err != 0) {
+			PMD_DRV_LOG(ERR, "Load multi PF firmware from flash failed.");
+			goto keepalive_stop;
+		}
 	} else {
 		PMD_DRV_LOG(ERR, "Not load firmware, please update flash or recofigure card.");
 		err = -ENODATA;
@@ -1723,8 +1723,8 @@ nfp_fw_setup(struct nfp_pf_dev *pf_dev,
 	if (policy != NFP_NSP_APP_FW_LOAD_FLASH) {
 		err = nfp_fw_get_name(pf_dev, fw_name, sizeof(fw_name));
 		if (err != 0) {
-			PMD_DRV_LOG(ERR, "Can not find suitable firmware.");
-			goto close_nsp;
+			fw_name[0] = 0;
+			PMD_DRV_LOG(DEBUG, "Can not find suitable firmware.");
 		}
 	}
 
-- 
2.43.5


           reply	other threads:[~2025-01-22  1:48 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20250122014751.1706413-1-chaoyong.he@corigine.com>]

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=20250122014751.1706413-2-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 \
    /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).