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 09/23] net/nfp: extract total phyports
Date: Wed, 19 Jun 2024 17:58:16 +0800 [thread overview]
Message-ID: <20240619095830.3479757-10-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240619095830.3479757-1-chaoyong.he@corigine.com>
From: Peng Zhang <peng.zhang@corigine.com>
Extract the 'total_phyports' data field into the 'pf_dev' structure, make
it also valid for the flower 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>
---
.../net/nfp/flower/nfp_flower_representor.c | 8 +-
drivers/net/nfp/nfp_ethdev.c | 75 +++++++++++--------
drivers/net/nfp/nfp_net_common.h | 3 +-
3 files changed, 49 insertions(+), 37 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 1f34c4c263..a845253b01 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -917,7 +917,6 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower,
int ret;
struct nfp_pf_dev *pf_dev;
struct rte_pci_device *pci_dev;
- struct nfp_eth_table *nfp_eth_table;
struct rte_eth_devargs eth_da = {
.nb_representor_ports = 0
};
@@ -945,8 +944,7 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower,
}
/* There always exist phy repr */
- nfp_eth_table = pf_dev->nfp_eth_table;
- if (eth_da.nb_representor_ports < nfp_eth_table->count + 1) {
+ if (eth_da.nb_representor_ports < pf_dev->total_phyports + 1) {
PMD_INIT_LOG(ERR, "Should also create repr port for phy port and PF vNIC.");
return -ERANGE;
}
@@ -958,9 +956,9 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower,
}
/* Fill in flower app with repr counts */
- app_fw_flower->num_phyport_reprs = (uint8_t)nfp_eth_table->count;
+ app_fw_flower->num_phyport_reprs = pf_dev->total_phyports;
app_fw_flower->num_vf_reprs = eth_da.nb_representor_ports -
- nfp_eth_table->count - 1;
+ pf_dev->total_phyports - 1;
PMD_INIT_LOG(INFO, "%d number of VF reprs", app_fw_flower->num_vf_reprs);
PMD_INIT_LOG(INFO, "%d number of phyport reprs", app_fw_flower->num_phyport_reprs);
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 469fa4602e..06811c7673 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -724,7 +724,7 @@ nfp_net_close(struct rte_eth_dev *dev)
nfp_cleanup_port_app_fw_nic(pf_dev, hw->idx, dev);
- for (i = 0; i < app_fw_nic->total_phyports; i++) {
+ for (i = 0; i < pf_dev->total_phyports; i++) {
id = nfp_function_id_get(pf_dev, i);
/* Check to see if ports are still in use */
@@ -1492,18 +1492,52 @@ nfp_enable_multi_pf(struct nfp_pf_dev *pf_dev)
return err;
}
+static bool
+nfp_app_fw_nic_total_phyports_check(struct nfp_pf_dev *pf_dev)
+{
+ int ret;
+ uint8_t id;
+ uint8_t total_phyports;
+ char vnic_name[RTE_ETH_NAME_MAX_LEN];
+
+ /* Read the number of vNIC's created for the PF */
+ id = nfp_function_id_get(pf_dev, 0);
+ snprintf(vnic_name, sizeof(vnic_name), "nfd_cfg_pf%u_num_ports", id);
+ total_phyports = nfp_rtsym_read_le(pf_dev->sym_tbl, vnic_name, &ret);
+ if (ret != 0 || total_phyports == 0 || total_phyports > 8) {
+ PMD_INIT_LOG(ERR, "%s symbol with wrong value", vnic_name);
+ return false;
+ }
+
+ if (pf_dev->multi_pf.enabled) {
+ if (!nfp_check_multi_pf_from_fw(total_phyports)) {
+ PMD_INIT_LOG(ERR, "NSP report multipf, but FW report not multipf");
+ return false;
+ }
+ } else {
+ /*
+ * For single PF the number of vNICs exposed should be the same as the
+ * number of physical ports.
+ */
+ if (total_phyports != pf_dev->nfp_eth_table->count) {
+ PMD_INIT_LOG(ERR, "Total physical ports do not match number of vNICs");
+ return false;
+ }
+ }
+
+ return true;
+}
+
static int
nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv)
{
uint8_t i;
uint8_t id;
int ret = 0;
- uint32_t total_vnics;
struct nfp_app_fw_nic *app_fw_nic;
struct nfp_eth_table *nfp_eth_table;
char bar_name[RTE_ETH_NAME_MAX_LEN];
char port_name[RTE_ETH_NAME_MAX_LEN];
- char vnic_name[RTE_ETH_NAME_MAX_LEN];
struct nfp_pf_dev *pf_dev = hw_priv->pf_dev;
struct nfp_net_init hw_init = {
.hw_priv = hw_priv,
@@ -1521,42 +1555,20 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv)
/* Point the app_fw_priv pointer in the PF to the coreNIC app */
pf_dev->app_fw_priv = app_fw_nic;
- /* Read the number of vNIC's created for the PF */
- snprintf(vnic_name, sizeof(vnic_name), "nfd_cfg_pf%u_num_ports", id);
- total_vnics = nfp_rtsym_read_le(pf_dev->sym_tbl, vnic_name, &ret);
- if (ret != 0 || total_vnics == 0 || total_vnics > 8) {
- PMD_INIT_LOG(ERR, "%s symbol with wrong value", vnic_name);
+ /* Check the number of vNIC's created for the PF */
+ if (!nfp_app_fw_nic_total_phyports_check(pf_dev)) {
ret = -ENODEV;
goto app_cleanup;
}
- if (pf_dev->multi_pf.enabled) {
- if (!nfp_check_multi_pf_from_fw(total_vnics)) {
- PMD_INIT_LOG(ERR, "NSP report multipf, but FW report not multipf");
- ret = -ENODEV;
- goto app_cleanup;
- }
- } else {
- /*
- * For coreNIC the number of vNICs exposed should be the same as the
- * number of physical ports.
- */
- if (total_vnics != nfp_eth_table->count) {
- PMD_INIT_LOG(ERR, "Total physical ports do not match number of vNICs");
- ret = -ENODEV;
- goto app_cleanup;
- }
- }
-
/* Populate coreNIC app properties */
- app_fw_nic->total_phyports = total_vnics;
- if (total_vnics > 1)
+ if (pf_dev->total_phyports > 1)
app_fw_nic->multiport = true;
/* Map the symbol table */
snprintf(bar_name, sizeof(bar_name), "_pf%u_net_bar0", id);
pf_dev->ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, bar_name,
- app_fw_nic->total_phyports * NFP_NET_CFG_BAR_SZ,
+ pf_dev->total_phyports * NFP_NET_CFG_BAR_SZ,
&pf_dev->ctrl_area);
if (pf_dev->ctrl_bar == NULL) {
PMD_INIT_LOG(ERR, "nfp_rtsym_map fails for %s", bar_name);
@@ -1567,7 +1579,7 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv)
PMD_INIT_LOG(DEBUG, "ctrl bar: %p", pf_dev->ctrl_bar);
/* Loop through all physical ports on PF */
- for (i = 0; i < app_fw_nic->total_phyports; i++) {
+ for (i = 0; i < pf_dev->total_phyports; i++) {
if (pf_dev->multi_pf.enabled)
snprintf(port_name, sizeof(port_name), "%s",
pf_dev->pci_dev->device.name);
@@ -1589,7 +1601,7 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv)
return 0;
port_cleanup:
- for (i = 0; i < app_fw_nic->total_phyports; i++) {
+ for (i = 0; i < pf_dev->total_phyports; i++) {
struct rte_eth_dev *eth_dev;
if (pf_dev->multi_pf.enabled)
@@ -1961,6 +1973,7 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
pf_dev->pci_dev = pci_dev;
pf_dev->nfp_eth_table = nfp_eth_table;
pf_dev->sync = sync;
+ pf_dev->total_phyports = nfp_net_get_port_num(pf_dev, nfp_eth_table);
ret = nfp_net_speed_cap_get(pf_dev);
if (ret != 0) {
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index cbf96e5ab5..5c48b94d38 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -140,6 +140,8 @@ struct nfp_pf_dev {
/** NFP devarg param */
struct nfp_devargs devargs;
+
+ uint8_t total_phyports;
};
#define NFP_NET_FLOW_LIMIT 1024
@@ -159,7 +161,6 @@ struct nfp_app_fw_nic {
struct nfp_net_hw *ports[NFP_MAX_PHYPORTS];
bool multiport;
- uint8_t total_phyports;
};
struct nfp_net_hw_priv {
--
2.39.1
next prev 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 ` Chaoyong He [this message]
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 ` [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-10-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).