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 11/11] drivers: enable multiple PF in application firmware
Date: Thu,  2 Nov 2023 10:23:21 +0800	[thread overview]
Message-ID: <20231102022321.2254224-12-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20231102022321.2254224-1-chaoyong.he@corigine.com>

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

For backward compatibility concern, the new application firmware
is designed to support both single PF scenario and multiple PF scenario.
Thus driver should inform application firmware which setup current
is. This should be done as early as possible since the setup may
affect some configurations exposed by firmware.

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/common/nfp/nfp_common_ctrl.h |  1 +
 drivers/net/nfp/nfp_ethdev.c         | 50 ++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index 7033c8ea00..8a8a2c5efc 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -221,6 +221,7 @@ struct nfp_net_fw_ver {
 #define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
 #define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match lookup */
 #define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup */
+#define NFP_NET_CFG_CTRL_MULTI_PF         (0x1 << 5)
 #define NFP_NET_CFG_CTRL_IN_ORDER         (0x1 << 11) /**< Virtio in-order flag */
 
 #define NFP_NET_CFG_CAP_WORD1           0x00a4
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index bbc0109f5f..e5f1d9f6f1 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -935,6 +935,50 @@ nfp_check_multi_pf_from_nsp(struct rte_pci_device *pci_dev,
 	return flag;
 }
 
+static int
+nfp_enable_multi_pf(struct nfp_pf_dev *pf_dev)
+{
+	int err = 0;
+	uint64_t tx_base;
+	uint8_t *ctrl_bar;
+	struct nfp_hw *hw;
+	uint32_t cap_extend;
+	struct nfp_net_hw net_hw;
+	struct nfp_cpp_area *area;
+	char name[RTE_ETH_NAME_MAX_LEN];
+
+	memset(&net_hw, 0, sizeof(struct nfp_net_hw));
+
+	/* Map the symbol table */
+	snprintf(name, sizeof(name), "_pf%u_net_bar0",
+			pf_dev->multi_pf.function_id);
+	ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, name, NFP_NET_CFG_BAR_SZ,
+			&area);
+	if (ctrl_bar == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to find data vNIC memory symbol");
+		return -ENODEV;
+	}
+
+	hw = &net_hw.super;
+	hw->ctrl_bar = ctrl_bar;
+
+	cap_extend = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
+	if ((cap_extend & NFP_NET_CFG_CTRL_MULTI_PF) == 0) {
+		PMD_INIT_LOG(ERR, "Loaded firmware doesn't support multiple PF");
+		err = -EINVAL;
+		goto end;
+	}
+
+	tx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
+	net_hw.tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
+	nfp_net_cfg_queue_setup(&net_hw);
+	rte_spinlock_init(&hw->reconfig_lock);
+	nfp_ext_reconfig(&net_hw.super, NFP_NET_CFG_CTRL_MULTI_PF, NFP_NET_CFG_UPDATE_GEN);
+end:
+	nfp_cpp_area_release_free(area);
+	return err;
+}
+
 static int
 nfp_init_app_fw_nic(struct nfp_pf_dev *pf_dev,
 		const struct nfp_dev_info *dev_info)
@@ -1222,6 +1266,12 @@ nfp_pf_init(struct rte_pci_device *pci_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)
+				goto hwqueues_cleanup;
+		}
+
 		PMD_INIT_LOG(INFO, "Initializing coreNIC");
 		ret = nfp_init_app_fw_nic(pf_dev, dev_info);
 		if (ret != 0) {
-- 
2.39.1


  parent reply	other threads:[~2023-11-02  2:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02  2:23 [PATCH 00/11] Add the support of multiple PF Chaoyong He
2023-11-02  2:23 ` [PATCH 01/11] net/nfp: refactor the probe logic of the secondary process Chaoyong He
2023-11-02  2:23 ` [PATCH 02/11] net/nfp: fix the failure to initialize the LSC mask Chaoyong He
2023-11-02  2:23 ` [PATCH 03/11] net/nfp: fix the DMA error caused by app exit abnormally Chaoyong He
2023-11-02  2:23 ` [PATCH 04/11] net/nfp: add flag to indicate multiple PFs support Chaoyong He
2023-11-02  2:23 ` [PATCH 05/11] net/nfp: add major version to nsp commands Chaoyong He
2023-11-02  2:23 ` [PATCH 06/11] net/nfp: adjust physical port check for multiple PFs Chaoyong He
2023-11-02  2:23 ` [PATCH 07/11] net/nfp: add the check about the firmware load Chaoyong He
2023-11-02  2:23 ` [PATCH 08/11] net/nfp: add PF ID used to format symbols Chaoyong He
2023-11-02  2:23 ` [PATCH 09/11] net/nfp: add nsp command to check if firmware is loaded Chaoyong He
2023-11-02  2:23 ` [PATCH 10/11] net/nfp: introduce keepalive mechanism for multiple PF Chaoyong He
2023-11-02  2:23 ` Chaoyong He [this message]
2023-11-02 14:52 ` [PATCH 00/11] Add the support of " 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=20231102022321.2254224-12-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).