DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Peng Zhang <peng.zhang@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>,
	Long Wu <long.wu@corigine.com>
Subject: [PATCH 10/23] net/nfp: extract the initialize helper function
Date: Wed, 19 Jun 2024 17:58:17 +0800	[thread overview]
Message-ID: <20240619095830.3479757-11-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240619095830.3479757-1-chaoyong.he@corigine.com>

From: Peng Zhang <peng.zhang@corigine.com>

Extract the helper function of the firmware application initialization
for both primary and secondary process.

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
 drivers/net/nfp/nfp_ethdev.c | 122 ++++++++++++++++++++++-------------
 1 file changed, 76 insertions(+), 46 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 06811c7673..177e5d1e06 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -1820,6 +1820,44 @@ nfp_net_force_port_down(struct nfp_pf_dev *pf_dev,
 	return 0;
 }
 
+static int
+nfp_fw_app_primary_init(struct nfp_net_hw_priv *hw_priv)
+{
+	int ret;
+	struct nfp_pf_dev *pf_dev = hw_priv->pf_dev;
+
+	switch (pf_dev->app_fw_id) {
+	case NFP_APP_FW_CORE_NIC:
+		if (pf_dev->multi_pf.enabled) {
+			ret = nfp_enable_multi_pf(pf_dev);
+			if (ret != 0)
+				return ret;
+		}
+
+		PMD_INIT_LOG(INFO, "Initializing coreNIC");
+		ret = nfp_init_app_fw_nic(hw_priv);
+		if (ret != 0) {
+			PMD_INIT_LOG(ERR, "Could not initialize coreNIC!");
+			return ret;
+		}
+		break;
+	case NFP_APP_FW_FLOWER_NIC:
+		PMD_INIT_LOG(INFO, "Initializing Flower");
+		ret = nfp_init_app_fw_flower(hw_priv);
+		if (ret != 0) {
+			PMD_INIT_LOG(ERR, "Could not initialize Flower!");
+			return ret;
+		}
+		break;
+	default:
+		PMD_INIT_LOG(ERR, "Unsupported Firmware loaded");
+		ret = -EINVAL;
+		return ret;
+	}
+
+	return 0;
+}
+
 static int
 nfp_pf_init(struct rte_pci_device *pci_dev)
 {
@@ -2011,32 +2049,9 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
 	 * PF initialization has been done at this point. Call app specific
 	 * init code now.
 	 */
-	switch (pf_dev->app_fw_id) {
-	case NFP_APP_FW_CORE_NIC:
-		if (pf_dev->multi_pf.enabled) {
-			ret = nfp_enable_multi_pf(pf_dev);
-			if (ret != 0)
-				goto mac_stats_cleanup;
-		}
-
-		PMD_INIT_LOG(INFO, "Initializing coreNIC");
-		ret = nfp_init_app_fw_nic(hw_priv);
-		if (ret != 0) {
-			PMD_INIT_LOG(ERR, "Could not initialize coreNIC!");
-			goto mac_stats_cleanup;
-		}
-		break;
-	case NFP_APP_FW_FLOWER_NIC:
-		PMD_INIT_LOG(INFO, "Initializing Flower");
-		ret = nfp_init_app_fw_flower(hw_priv);
-		if (ret != 0) {
-			PMD_INIT_LOG(ERR, "Could not initialize Flower!");
-			goto mac_stats_cleanup;
-		}
-		break;
-	default:
-		PMD_INIT_LOG(ERR, "Unsupported Firmware loaded");
-		ret = -EINVAL;
+	ret = nfp_fw_app_primary_init(hw_priv);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init hw app primary.");
 		goto mac_stats_cleanup;
 	}
 
@@ -2135,6 +2150,38 @@ nfp_secondary_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv)
 	return ret;
 }
 
+static int
+nfp_fw_app_secondary_init(struct nfp_net_hw_priv *hw_priv)
+{
+	int ret;
+	struct nfp_pf_dev *pf_dev = hw_priv->pf_dev;
+
+	switch (pf_dev->app_fw_id) {
+	case NFP_APP_FW_CORE_NIC:
+		PMD_INIT_LOG(INFO, "Initializing coreNIC");
+		ret = nfp_secondary_init_app_fw_nic(hw_priv);
+		if (ret != 0) {
+			PMD_INIT_LOG(ERR, "Could not initialize coreNIC!");
+			return ret;
+		}
+		break;
+	case NFP_APP_FW_FLOWER_NIC:
+		PMD_INIT_LOG(INFO, "Initializing Flower");
+		ret = nfp_secondary_init_app_fw_flower(hw_priv);
+		if (ret != 0) {
+			PMD_INIT_LOG(ERR, "Could not initialize Flower!");
+			return ret;
+		}
+		break;
+	default:
+		PMD_INIT_LOG(ERR, "Unsupported Firmware loaded");
+		ret = -EINVAL;
+		return ret;
+	}
+
+	return 0;
+}
+
 /*
  * When attaching to the NFP4000/6000 PF on a secondary process there
  * is no need to initialise the PF again. Only minimal work is required
@@ -2241,26 +2288,9 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev)
 	hw_priv->dev_info = dev_info;
 
 	/* Call app specific init code now */
-	switch (app_fw_id) {
-	case NFP_APP_FW_CORE_NIC:
-		PMD_INIT_LOG(INFO, "Initializing coreNIC");
-		ret = nfp_secondary_init_app_fw_nic(hw_priv);
-		if (ret != 0) {
-			PMD_INIT_LOG(ERR, "Could not initialize coreNIC!");
-			goto sym_tbl_cleanup;
-		}
-		break;
-	case NFP_APP_FW_FLOWER_NIC:
-		PMD_INIT_LOG(INFO, "Initializing Flower");
-		ret = nfp_secondary_init_app_fw_flower(hw_priv);
-		if (ret != 0) {
-			PMD_INIT_LOG(ERR, "Could not initialize Flower!");
-			goto sym_tbl_cleanup;
-		}
-		break;
-	default:
-		PMD_INIT_LOG(ERR, "Unsupported Firmware loaded");
-		ret = -EINVAL;
+	ret = nfp_fw_app_secondary_init(hw_priv);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init hw app primary.");
 		goto sym_tbl_cleanup;
 	}
 
-- 
2.39.1


  parent reply	other threads:[~2024-06-19 10:00 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-19  9:58 [PATCH 00/23] support flower firmware with multiple PF Chaoyong He
2024-06-19  9:58 ` [PATCH 01/23] net/nfp: fix dereference of null pointer Chaoyong He
2024-07-07 18:56   ` Ferruh Yigit
2024-07-08  1:35     ` Chaoyong He
2024-06-19  9:58 ` [PATCH 02/23] net/nfp: disable ctrl VNIC queues Chaoyong He
2024-06-19  9:58 ` [PATCH 03/23] net/nfp: fix dereference of null pointer Chaoyong He
2024-06-19  9:58 ` [PATCH 04/23] net/nfp: fix repeat disable the port Chaoyong He
2024-06-19  9:58 ` [PATCH 05/23] net/nfp: fix repeat set the speed configure Chaoyong He
2024-06-19  9:58 ` [PATCH 06/23] net/nfp: make the logic simpler by adding local variable Chaoyong He
2024-06-19  9:58 ` [PATCH 07/23] net/nfp: rename the variable name Chaoyong He
2024-06-19  9:58 ` [PATCH 08/23] net/nfp: export function ID get interface Chaoyong He
2024-06-19  9:58 ` [PATCH 09/23] net/nfp: extract total phyports Chaoyong He
2024-06-19  9:58 ` Chaoyong He [this message]
2024-06-19  9:58 ` [PATCH 11/23] net/nfp: get the VF configuration Chaoyong He
2024-06-19  9:58 ` [PATCH 12/23] net/nfp: refactor the logic of flower service Chaoyong He
2024-06-19  9:58 ` [PATCH 13/23] net/nfp: get the first VF ID of the PF Chaoyong He
2024-06-19  9:58 ` [PATCH 14/23] net/nfp: add the helper function to map rtsym with offset Chaoyong He
2024-06-19  9:58 ` [PATCH 15/23] net/nfp: add the VF table to record the VF information Chaoyong He
2024-06-19  9:58 ` [PATCH 16/23] net/nfp: support configuration of VF numbers Chaoyong He
2024-06-19  9:58 ` [PATCH 17/23] net/nfp: configure the VF queue Chaoyong He
2024-06-19  9:58 ` [PATCH 18/23] net/nfp: add check for numbers of VF representor port Chaoyong He
2024-06-19  9:58 ` [PATCH 19/23] net/nfp: add support of ring pop and push Chaoyong He
2024-06-19  9:58 ` [PATCH 20/23] net/nfp: add resource share mode of host context Chaoyong He
2024-06-19  9:58 ` [PATCH 21/23] net/nfp: add resource share mode of mask ID Chaoyong He
2024-06-19  9:58 ` [PATCH 22/23] net/nfp: add device active command for nsp service Chaoyong He
2024-06-19  9:58 ` [PATCH 23/23] net/nfp: add support of flower firmware with multiple PF Chaoyong He
2024-07-07 18:56 ` [PATCH 00/23] support " 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=20240619095830.3479757-11-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 \
    /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).