From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Chaoyong He <chaoyong.he@corigine.com>,
peng.zhang@corigine.com, stable@dpdk.org,
Long Wu <long.wu@corigine.com>
Subject: [PATCH 1/2] net/nfp: fix xstats problem for multi PF firmware
Date: Thu, 23 May 2024 10:49:15 +0800 [thread overview]
Message-ID: <20240523024916.2291031-2-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240523024916.2291031-1-chaoyong.he@corigine.com>
When using multi PF firmware, the other ports always get the
xstats of the first port.
Fix it by adding the offset for other ports.
Fixes: 8ad2cc8fec37 ("net/nfp: add flag for multiple PFs support")
Cc: peng.zhang@corigine.com
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 | 50 ++++++++++++++------------------
drivers/net/nfp/nfp_net_common.h | 5 ++--
2 files changed, 25 insertions(+), 30 deletions(-)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index cdc946faff..f98af2044b 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -585,8 +585,6 @@ nfp_net_uninit(struct rte_eth_dev *eth_dev)
if ((net_hw->super.cap & NFP_NET_CFG_CTRL_TXRWB) != 0)
nfp_net_txrwb_free(eth_dev);
nfp_ipsec_uninit(eth_dev);
- if (net_hw->mac_stats_area != NULL)
- nfp_cpp_area_release_free(net_hw->mac_stats_area);
return 0;
}
@@ -617,6 +615,7 @@ nfp_pf_uninit(struct nfp_net_hw_priv *hw_priv)
{
struct nfp_pf_dev *pf_dev = hw_priv->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);
if (pf_dev->multi_pf.enabled) {
@@ -933,43 +932,31 @@ nfp_net_init(struct rte_eth_dev *eth_dev,
rte_eth_copy_pci_info(eth_dev, pci_dev);
- if (port == 0 || pf_dev->multi_pf.enabled) {
- uint32_t min_size;
-
+ if (pf_dev->multi_pf.enabled)
hw->ctrl_bar = pf_dev->ctrl_bar;
- min_size = NFP_MAC_STATS_SIZE * pf_dev->nfp_eth_table->max_index;
- net_hw->mac_stats_bar = nfp_rtsym_map(pf_dev->sym_tbl, "_mac_stats",
- min_size, &net_hw->mac_stats_area);
- if (net_hw->mac_stats_bar == NULL) {
- PMD_INIT_LOG(ERR, "nfp_rtsym_map fails for _mac_stats_bar");
- return -EIO;
- }
-
- net_hw->mac_stats = net_hw->mac_stats_bar;
- } else {
- /* Use port offset in pf ctrl_bar for this ports control bar */
+ else
hw->ctrl_bar = pf_dev->ctrl_bar + (port * NFP_NET_CFG_BAR_SZ);
- net_hw->mac_stats = app_fw_nic->ports[0]->mac_stats_bar +
+
+ net_hw->mac_stats = pf_dev->mac_stats_bar +
(net_hw->nfp_idx * NFP_MAC_STATS_SIZE);
- }
PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
PMD_INIT_LOG(DEBUG, "MAC stats: %p", net_hw->mac_stats);
err = nfp_net_common_init(pci_dev, net_hw);
if (err != 0)
- goto free_area;
+ return err;
err = nfp_net_tlv_caps_parse(eth_dev);
if (err != 0) {
PMD_INIT_LOG(ERR, "Failed to parser TLV caps");
- goto free_area;
+ return err;
}
err = nfp_ipsec_init(eth_dev);
if (err != 0) {
PMD_INIT_LOG(ERR, "Failed to init IPsec module");
- goto free_area;
+ return err;
}
nfp_net_ethdev_ops_mount(net_hw, eth_dev);
@@ -1070,9 +1057,6 @@ nfp_net_init(struct rte_eth_dev *eth_dev,
rte_free(net_hw->eth_xstats_base);
ipsec_exit:
nfp_ipsec_uninit(eth_dev);
-free_area:
- if (net_hw->mac_stats_area != NULL)
- nfp_cpp_area_release_free(net_hw->mac_stats_area);
return err;
}
@@ -1931,6 +1915,14 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
PMD_INIT_LOG(DEBUG, "qc_bar address: %p", pf_dev->qc_bar);
+ pf_dev->mac_stats_bar = nfp_rtsym_map(sym_tbl, "_mac_stats",
+ NFP_MAC_STATS_SIZE * nfp_eth_table->max_index,
+ &pf_dev->mac_stats_area);
+ if (pf_dev->mac_stats_bar == NULL) {
+ PMD_INIT_LOG(ERR, "nfp_rtsym_map fails for _mac_stats");
+ goto hwqueues_cleanup;
+ }
+
hw_priv->pf_dev = pf_dev;
hw_priv->dev_info = dev_info;
@@ -1943,14 +1935,14 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
if (pf_dev->multi_pf.enabled) {
ret = nfp_enable_multi_pf(pf_dev);
if (ret != 0)
- goto hwqueues_cleanup;
+ 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 hwqueues_cleanup;
+ goto mac_stats_cleanup;
}
break;
case NFP_APP_FW_FLOWER_NIC:
@@ -1958,13 +1950,13 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
ret = nfp_init_app_fw_flower(hw_priv);
if (ret != 0) {
PMD_INIT_LOG(ERR, "Could not initialize Flower!");
- goto hwqueues_cleanup;
+ goto mac_stats_cleanup;
}
break;
default:
PMD_INIT_LOG(ERR, "Unsupported Firmware loaded");
ret = -EINVAL;
- goto hwqueues_cleanup;
+ goto mac_stats_cleanup;
}
/* Register the CPP bridge service here for primary use */
@@ -1974,6 +1966,8 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
return 0;
+mac_stats_cleanup:
+ nfp_cpp_area_release_free(pf_dev->mac_stats_area);
hwqueues_cleanup:
nfp_cpp_area_release_free(pf_dev->qc_area);
sym_tbl_cleanup:
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index a4eaed6433..8d9851f969 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -116,6 +116,9 @@ struct nfp_pf_dev {
uint8_t *qc_bar;
+ struct nfp_cpp_area *mac_stats_area;
+ uint8_t *mac_stats_bar;
+
struct nfp_hwinfo *hwinfo;
struct nfp_rtsym_table *sym_tbl;
@@ -199,8 +202,6 @@ struct nfp_net_hw {
struct rte_eth_xstat *eth_xstats_base;
struct nfp_cpp_area *ctrl_area;
- struct nfp_cpp_area *mac_stats_area;
- uint8_t *mac_stats_bar;
uint8_t *mac_stats;
/** Sequential physical port number, only valid for CoreNIC firmware */
--
2.39.1
next prev parent reply other threads:[~2024-05-23 2:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 2:49 [PATCH 0/2] NFP extend stats Chaoyong He
2024-05-23 2:49 ` Chaoyong He [this message]
2024-05-23 2:49 ` [PATCH 2/2] net/nfp: add support of xstats for flower firmware Chaoyong He
2024-06-12 1:40 ` [PATCH 0/2] NFP extend stats 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=20240523024916.2291031-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).