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 15/23] net/nfp: add the VF table to record the VF information
Date: Wed, 19 Jun 2024 17:58:22 +0800	[thread overview]
Message-ID: <20240619095830.3479757-16-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240619095830.3479757-1-chaoyong.he@corigine.com>

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

In multiple PF case, different VF of different PF has
different VF configure, so need add the VF table to record
the VF information.

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 |  8 ++++
 drivers/net/nfp/nfp_ethdev.c         | 64 +++++++++++++++++++++++++++-
 drivers/net/nfp/nfp_net_common.h     |  9 ++++
 3 files changed, 79 insertions(+), 2 deletions(-)

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index 6badf769fc..e108720ff6 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -13,6 +13,14 @@
  */
 #define NFP_NET_CFG_BAR_SZ              (32 * 1024)
 
+/*
+ * Configuration sriov VF.
+ * The configuration memory begins with a mailbox region for communication with
+ * the firmware followed by individual VF entries.
+ */
+#define NFP_NET_VF_CFG_SZ               16
+#define NFP_NET_VF_CFG_MB_SZ            16
+
 /*
  * @NFP_NET_TXR_MAX:         Maximum number of TX rings
  * @NFP_NET_TXR_MASK:        Mask for TX rings
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 482d23eb5c..dc3890ef53 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -633,6 +633,16 @@ nfp_uninit_app_fw_nic(struct nfp_pf_dev *pf_dev)
 	rte_free(pf_dev->app_fw_priv);
 }
 
+static void
+nfp_net_vf_config_uninit(struct nfp_pf_dev *pf_dev)
+{
+	if (pf_dev->sriov_vf == 0)
+		return;
+
+	nfp_cpp_area_release_free(pf_dev->vf_cfg_tbl_area);
+	nfp_cpp_area_release_free(pf_dev->vf_area);
+}
+
 void
 nfp_pf_uninit(struct nfp_net_hw_priv *hw_priv)
 {
@@ -640,6 +650,7 @@ nfp_pf_uninit(struct nfp_net_hw_priv *hw_priv)
 
 	if (pf_dev->devargs.cpp_service_enable)
 		nfp_disable_cpp_service(pf_dev);
+	nfp_net_vf_config_uninit(pf_dev);
 	nfp_cpp_area_release_free(pf_dev->mac_stats_area);
 	nfp_cpp_area_release_free(pf_dev->qc_area);
 	free(pf_dev->sym_tbl);
@@ -1957,6 +1968,47 @@ nfp_net_get_vf_info(struct nfp_pf_dev *pf_dev,
 	return 0;
 }
 
+static int
+nfp_net_vf_config_init(struct nfp_pf_dev *pf_dev)
+{
+	int ret = 0;
+	uint32_t min_size;
+	char vf_bar_name[RTE_ETH_NAME_MAX_LEN];
+	char vf_cfg_name[RTE_ETH_NAME_MAX_LEN];
+
+	if (pf_dev->sriov_vf == 0)
+		return 0;
+
+	min_size = NFP_NET_CFG_BAR_SZ * pf_dev->sriov_vf;
+	snprintf(vf_bar_name, sizeof(vf_bar_name), "_pf%d_net_vf_bar",
+			pf_dev->multi_pf.function_id);
+	pf_dev->vf_bar = nfp_rtsym_map_offset(pf_dev->sym_tbl, vf_bar_name,
+			NFP_NET_CFG_BAR_SZ * pf_dev->vf_base_id,
+			min_size, &pf_dev->vf_area);
+	if (pf_dev->vf_bar == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to get vf cfg.");
+		return -EIO;
+	}
+
+	min_size = NFP_NET_VF_CFG_SZ * pf_dev->sriov_vf + NFP_NET_VF_CFG_MB_SZ;
+	snprintf(vf_cfg_name, sizeof(vf_cfg_name), "_pf%d_net_vf_cfg2",
+			pf_dev->multi_pf.function_id);
+	pf_dev->vf_cfg_tbl_bar = nfp_rtsym_map(pf_dev->sym_tbl, vf_cfg_name,
+			min_size, &pf_dev->vf_cfg_tbl_area);
+	if (pf_dev->vf_cfg_tbl_bar == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to get vf configure table.");
+		ret = -EIO;
+		goto vf_bar_cleanup;
+	}
+
+	return 0;
+
+vf_bar_cleanup:
+	nfp_cpp_area_release_free(pf_dev->vf_area);
+
+	return ret;
+}
+
 static int
 nfp_pf_init(struct rte_pci_device *pci_dev)
 {
@@ -2149,6 +2201,12 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
 		goto hwqueues_cleanup;
 	}
 
+	ret = nfp_net_vf_config_init(pf_dev);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init VF config.");
+		goto mac_stats_cleanup;
+	}
+
 	hw_priv->pf_dev = pf_dev;
 	hw_priv->dev_info = dev_info;
 
@@ -2159,7 +2217,7 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
 	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;
+		goto vf_cfg_tbl_cleanup;
 	}
 
 	/* Register the CPP bridge service here for primary use */
@@ -2167,12 +2225,14 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
 		ret = nfp_enable_cpp_service(pf_dev);
 		if (ret != 0) {
 			PMD_INIT_LOG(ERR, "Enable CPP service failed.");
-			goto hwqueues_cleanup;
+			goto vf_cfg_tbl_cleanup;
 		}
 	}
 
 	return 0;
 
+vf_cfg_tbl_cleanup:
+	nfp_net_vf_config_uninit(pf_dev);
 mac_stats_cleanup:
 	nfp_cpp_area_release_free(pf_dev->mac_stats_area);
 hwqueues_cleanup:
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index d3c70a21d4..c4d469599f 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -117,6 +117,15 @@ struct nfp_pf_dev {
 	struct nfp_cpp_area *ctrl_area;
 	struct nfp_cpp_area *qc_area;
 
+	/** Pointer to the CPP area for the VF configuration BAR */
+	struct nfp_cpp_area *vf_area;
+	/** Pointer to mapped VF configuration area */
+	uint8_t *vf_bar;
+	/** Pointer to the CPP area for the VF config table */
+	struct nfp_cpp_area *vf_cfg_tbl_area;
+	/** Pointer to mapped VF config table */
+	uint8_t *vf_cfg_tbl_bar;
+
 	uint8_t *qc_bar;
 
 	struct nfp_cpp_area *mac_stats_area;
-- 
2.39.1


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

Thread overview: 24+ 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-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 ` [PATCH 10/23] net/nfp: extract the initialize helper function Chaoyong He
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 ` Chaoyong He [this message]
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

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-16-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).