* [PATCH 0/4] Support new card using NFP 3800 chip
@ 2024-09-03 1:41 Chaoyong He
2024-09-03 1:41 ` [PATCH 1/4] net/nfp: add a new flag to indicate PF Chaoyong He
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Chaoyong He @ 2024-09-03 1:41 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He
This patch series add support of a new card which using the NFP 3800 chip.
Because it has different configure BAR size and flow steering rules
limit, we also do some refactor to the related logic.
Chaoyong He (4):
net/nfp: add a new flag to indicate PF
net/nfp: refactor the firmware version logic
net/nfp: support different configuration BAR size
net/nfp: support different flow steering rules limit
drivers/common/nfp/nfp_common_ctrl.h | 13 +++-
drivers/net/nfp/flower/nfp_flower.c | 34 +++++----
drivers/net/nfp/flower/nfp_flower_ctrl.c | 8 +--
drivers/net/nfp/flower/nfp_flower_ctrl.h | 2 +-
drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 2 +-
drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +-
drivers/net/nfp/nfp_ethdev.c | 55 +++++++++------
drivers/net/nfp/nfp_ethdev_vf.c | 33 +++++++--
drivers/net/nfp/nfp_net_common.c | 87 +++++++++++++++++-------
drivers/net/nfp/nfp_net_common.h | 25 ++++---
drivers/net/nfp/nfp_net_ctrl.c | 4 +-
drivers/net/nfp/nfp_net_flow.c | 51 ++++++++++++--
drivers/net/nfp/nfp_net_meta.c | 5 +-
drivers/net/nfp/nfp_net_meta.h | 5 +-
drivers/net/nfp/nfp_rxtx.c | 10 +--
15 files changed, 231 insertions(+), 105 deletions(-)
--
2.39.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] net/nfp: add a new flag to indicate PF
2024-09-03 1:41 [PATCH 0/4] Support new card using NFP 3800 chip Chaoyong He
@ 2024-09-03 1:41 ` Chaoyong He
2024-09-03 1:41 ` [PATCH 2/4] net/nfp: refactor the firmware version logic Chaoyong He
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Chaoyong He @ 2024-09-03 1:41 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu
Add a new flag field 'is_pf' into 'struct nfp_net_hw_priv', to indicate
if the device is PF or not.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
drivers/net/nfp/nfp_ethdev.c | 2 ++
drivers/net/nfp/nfp_net_common.c | 6 +++---
drivers/net/nfp/nfp_net_common.h | 2 ++
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index bd35df2dc9..181fd74efe 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -2298,6 +2298,7 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
if (ret != 0)
goto vf_cfg_tbl_cleanup;
+ hw_priv->is_pf = true;
hw_priv->pf_dev = pf_dev;
hw_priv->dev_info = dev_info;
@@ -2544,6 +2545,7 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev)
pf_dev->pci_dev = pci_dev;
pf_dev->sync = sync;
+ hw_priv->is_pf = true;
hw_priv->pf_dev = pf_dev;
hw_priv->dev_info = dev_info;
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 3d916cd147..b471fd032a 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -783,7 +783,7 @@ nfp_net_link_update_common(struct rte_eth_dev *dev,
hw_priv = dev->process_private;
if (link->link_status == RTE_ETH_LINK_UP) {
- if (hw_priv->pf_dev != NULL) {
+ if (hw_priv->is_pf) {
nfp_net_speed_aneg_update(dev, hw, hw_priv, link);
} else {
/*
@@ -845,7 +845,7 @@ nfp_net_link_update(struct rte_eth_dev *dev,
* Not applicable for VFs as the associated PF is still attached to the
* kernel driver.
*/
- if (hw_priv != NULL && hw_priv->pf_dev != NULL)
+ if (hw_priv != NULL && hw_priv->is_pf)
nfp_net_notify_port_speed(hw, &link);
return ret;
@@ -1366,7 +1366,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
}
/* Only PF supports getting speed capability. */
- if (hw_priv->pf_dev != NULL)
+ if (hw_priv->is_pf)
dev_info->speed_capa = hw_priv->pf_dev->speed_capa;
return 0;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index bebb754ced..67ec5a2d89 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -207,6 +207,8 @@ struct nfp_net_hw_priv {
/** NFP ASIC params */
const struct nfp_dev_info *dev_info;
+
+ bool is_pf;
};
struct nfp_net_hw {
--
2.39.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/4] net/nfp: refactor the firmware version logic
2024-09-03 1:41 [PATCH 0/4] Support new card using NFP 3800 chip Chaoyong He
2024-09-03 1:41 ` [PATCH 1/4] net/nfp: add a new flag to indicate PF Chaoyong He
@ 2024-09-03 1:41 ` Chaoyong He
2024-09-03 1:41 ` [PATCH 3/4] net/nfp: support different configuration BAR size Chaoyong He
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Chaoyong He @ 2024-09-03 1:41 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu
Move the 'ver' data field from 'struct nfp_net_hw' into
'struct nfp_pf_dev', also modify the related logic.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
drivers/net/nfp/flower/nfp_flower.c | 30 ++++++-------
drivers/net/nfp/flower/nfp_flower_ctrl.c | 8 ++--
drivers/net/nfp/flower/nfp_flower_ctrl.h | 2 +-
drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 2 +-
drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +-
drivers/net/nfp/nfp_ethdev.c | 29 +++++++-----
drivers/net/nfp/nfp_ethdev_vf.c | 30 ++++++++++---
drivers/net/nfp/nfp_net_common.c | 56 ++++++++++++++----------
drivers/net/nfp/nfp_net_common.h | 16 ++++---
drivers/net/nfp/nfp_net_meta.c | 5 ++-
drivers/net/nfp/nfp_net_meta.h | 5 ++-
drivers/net/nfp/nfp_rxtx.c | 10 ++---
12 files changed, 118 insertions(+), 77 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 8d781658ea..4d91d548f7 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -166,15 +166,15 @@ nfp_flower_pf_nfdk_xmit_pkts(void *tx_queue,
}
static void
-nfp_flower_pf_xmit_pkts_register(struct nfp_app_fw_flower *app_fw_flower)
+nfp_flower_pf_xmit_pkts_register(struct nfp_pf_dev *pf_dev)
{
- struct nfp_net_hw *hw;
struct nfp_flower_nfd_func *nfd_func;
+ struct nfp_app_fw_flower *app_fw_flower;
- hw = app_fw_flower->pf_hw;
+ app_fw_flower = pf_dev->app_fw_priv;
nfd_func = &app_fw_flower->nfd_func;
- if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
+ if (pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
nfd_func->pf_xmit_t = nfp_flower_pf_nfd3_xmit_pkts;
else
nfd_func->pf_xmit_t = nfp_flower_pf_nfdk_xmit_pkts;
@@ -204,14 +204,12 @@ nfp_flower_init_vnic_common(struct nfp_net_hw_priv *hw_priv,
uint64_t rx_bar_off;
uint64_t tx_bar_off;
struct nfp_pf_dev *pf_dev;
- struct rte_pci_device *pci_dev;
pf_dev = hw_priv->pf_dev;
- pci_dev = pf_dev->pci_dev;
PMD_INIT_LOG(DEBUG, "%s vNIC ctrl bar: %p", vnic_type, hw->super.ctrl_bar);
- err = nfp_net_common_init(pci_dev, hw);
+ err = nfp_net_common_init(pf_dev, hw);
if (err != 0)
return err;
@@ -612,15 +610,15 @@ nfp_flower_start_ctrl_vnic(struct nfp_app_fw_flower *app_fw_flower)
}
static void
-nfp_flower_pkt_add_metadata_register(struct nfp_app_fw_flower *app_fw_flower)
+nfp_flower_pkt_add_metadata_register(struct nfp_pf_dev *pf_dev)
{
- struct nfp_net_hw *hw;
struct nfp_flower_nfd_func *nfd_func;
+ struct nfp_app_fw_flower *app_fw_flower;
- hw = app_fw_flower->pf_hw;
+ app_fw_flower = pf_dev->app_fw_priv;
nfd_func = &app_fw_flower->nfd_func;
- if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
+ if (pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
nfd_func->pkt_add_metadata_t = nfp_flower_nfd3_pkt_add_metadata;
else
nfd_func->pkt_add_metadata_t = nfp_flower_nfdk_pkt_add_metadata;
@@ -635,11 +633,11 @@ nfp_flower_pkt_add_metadata(struct nfp_app_fw_flower *app_fw_flower,
}
static void
-nfp_flower_nfd_func_register(struct nfp_app_fw_flower *app_fw_flower)
+nfp_flower_nfd_func_register(struct nfp_pf_dev *pf_dev)
{
- nfp_flower_pkt_add_metadata_register(app_fw_flower);
- nfp_flower_ctrl_vnic_xmit_register(app_fw_flower);
- nfp_flower_pf_xmit_pkts_register(app_fw_flower);
+ nfp_flower_pkt_add_metadata_register(pf_dev);
+ nfp_flower_ctrl_vnic_xmit_register(pf_dev);
+ nfp_flower_pf_xmit_pkts_register(pf_dev);
}
int
@@ -730,7 +728,7 @@ nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv)
goto pf_cpp_area_cleanup;
}
- nfp_flower_nfd_func_register(app_fw_flower);
+ nfp_flower_nfd_func_register(pf_dev);
/* The ctrl vNIC struct comes directly after the PF one */
app_fw_flower->ctrl_hw = pf_hw + 1;
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index a46b849d1b..9b957e1f1e 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -343,15 +343,15 @@ nfp_flower_ctrl_vnic_nfdk_xmit(struct nfp_app_fw_flower *app_fw_flower,
}
void
-nfp_flower_ctrl_vnic_xmit_register(struct nfp_app_fw_flower *app_fw_flower)
+nfp_flower_ctrl_vnic_xmit_register(struct nfp_pf_dev *pf_dev)
{
- struct nfp_net_hw *hw;
struct nfp_flower_nfd_func *nfd_func;
+ struct nfp_app_fw_flower *app_fw_flower;
- hw = app_fw_flower->pf_hw;
+ app_fw_flower = pf_dev->app_fw_priv;
nfd_func = &app_fw_flower->nfd_func;
- if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
+ if (pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
nfd_func->ctrl_vnic_xmit_t = nfp_flower_ctrl_vnic_nfd3_xmit;
else
nfd_func->ctrl_vnic_xmit_t = nfp_flower_ctrl_vnic_nfdk_xmit;
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.h b/drivers/net/nfp/flower/nfp_flower_ctrl.h
index b5d0036c01..f18c8f4095 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.h
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.h
@@ -11,6 +11,6 @@
void nfp_flower_ctrl_vnic_process(struct nfp_net_hw_priv *hw_priv);
uint16_t nfp_flower_ctrl_vnic_xmit(struct nfp_app_fw_flower *app_fw_flower,
struct rte_mbuf *mbuf);
-void nfp_flower_ctrl_vnic_xmit_register(struct nfp_app_fw_flower *app_fw_flower);
+void nfp_flower_ctrl_vnic_xmit_register(struct nfp_pf_dev *pf_dev);
#endif /* __NFP_FLOWER_CTRL_H__ */
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index ee96cd8e46..4ff1ae63b0 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -390,7 +390,7 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev,
hw = nfp_net_get_hw(dev);
hw_priv = dev->process_private;
- nfp_net_tx_desc_limits(hw, hw_priv, &min_tx_desc, &max_tx_desc);
+ nfp_net_tx_desc_limits(hw_priv, &min_tx_desc, &max_tx_desc);
/* Validating number of descriptors */
tx_desc_sz = nb_desc * sizeof(struct nfp_net_nfd3_tx_desc);
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 2cea5688b3..68fcbe93da 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -424,7 +424,7 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev,
hw = nfp_net_get_hw(dev);
hw_priv = dev->process_private;
- nfp_net_tx_desc_limits(hw, hw_priv, &min_tx_desc, &max_tx_desc);
+ nfp_net_tx_desc_limits(hw_priv, &min_tx_desc, &max_tx_desc);
/* Validating number of descriptors */
tx_desc_sz = nb_desc * sizeof(struct nfp_net_nfdk_tx_desc);
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 181fd74efe..d85993f70c 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -959,10 +959,10 @@ static const struct eth_dev_ops nfp_net_eth_dev_ops = {
};
static inline void
-nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw,
+nfp_net_ethdev_ops_mount(struct nfp_pf_dev *pf_dev,
struct rte_eth_dev *eth_dev)
{
- if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
+ if (pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
eth_dev->tx_pkt_burst = nfp_net_nfd3_xmit_pkts;
else
nfp_net_nfdk_xmit_pkts_set(eth_dev);
@@ -1030,7 +1030,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev,
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);
+ err = nfp_net_common_init(pf_dev, net_hw);
if (err != 0)
return err;
@@ -1046,7 +1046,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev,
return err;
}
- nfp_net_ethdev_ops_mount(net_hw, eth_dev);
+ nfp_net_ethdev_ops_mount(pf_dev, eth_dev);
net_hw->eth_xstats_base = rte_malloc("rte_eth_xstat", sizeof(struct rte_eth_xstat) *
nfp_net_xstats_size(eth_dev), 0);
@@ -1074,7 +1074,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev,
if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
- nfp_net_log_device_information(net_hw);
+ nfp_net_log_device_information(net_hw, pf_dev);
/* Initializing spinlock for reconfigs */
rte_spinlock_init(&hw->reconfig_lock);
@@ -1552,9 +1552,6 @@ nfp_enable_multi_pf(struct nfp_pf_dev *pf_dev)
struct nfp_cpp_area *area;
char name[RTE_ETH_NAME_MAX_LEN];
- if (!pf_dev->multi_pf.enabled)
- return 0;
-
memset(&net_hw, 0, sizeof(struct nfp_net_hw));
/* Map the symbol table */
@@ -1570,6 +1567,16 @@ nfp_enable_multi_pf(struct nfp_pf_dev *pf_dev)
hw = &net_hw.super;
hw->ctrl_bar = ctrl_bar;
+ /* Check the version from firmware */
+ if (!nfp_net_version_check(hw, pf_dev)) {
+ PMD_INIT_LOG(ERR, "Not the valid version.");
+ err = -EINVAL;
+ goto end;
+ }
+
+ if (!pf_dev->multi_pf.enabled)
+ goto end;
+
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");
@@ -2358,10 +2365,10 @@ static int
nfp_secondary_net_init(struct rte_eth_dev *eth_dev,
void *para)
{
- struct nfp_net_hw *net_hw;
+ struct nfp_net_hw_priv *hw_priv;
- net_hw = eth_dev->data->dev_private;
- nfp_net_ethdev_ops_mount(net_hw, eth_dev);
+ hw_priv = para;
+ nfp_net_ethdev_ops_mount(hw_priv->pf_dev, eth_dev);
eth_dev->process_private = para;
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index cdf5da3af7..2e581c7e45 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -235,10 +235,10 @@ static const struct eth_dev_ops nfp_netvf_eth_dev_ops = {
};
static inline void
-nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw,
+nfp_netvf_ethdev_ops_mount(struct nfp_pf_dev *pf_dev,
struct rte_eth_dev *eth_dev)
{
- if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
+ if (pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
eth_dev->tx_pkt_burst = nfp_net_nfd3_xmit_pkts;
else
nfp_net_nfdk_xmit_pkts_set(eth_dev);
@@ -256,6 +256,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
uint32_t start_q;
struct nfp_hw *hw;
struct nfp_net_hw *net_hw;
+ struct nfp_pf_dev *pf_dev;
uint64_t tx_bar_off = 0;
uint64_t rx_bar_off = 0;
struct rte_pci_device *pci_dev;
@@ -280,13 +281,27 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
return -ENODEV;
}
+ pf_dev = rte_zmalloc(NULL, sizeof(*pf_dev), 0);
+ if (pf_dev == NULL) {
+ PMD_INIT_LOG(ERR, "Can not allocate memory for the PF device.");
+ return -ENOMEM;
+ }
+
+ pf_dev->pci_dev = pci_dev;
+
+ /* Check the version from firmware */
+ if (!nfp_net_version_check(hw, pf_dev)) {
+ err = -EINVAL;
+ goto pf_dev_free;
+ }
+
PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
- err = nfp_net_common_init(pci_dev, net_hw);
+ err = nfp_net_common_init(pf_dev, net_hw);
if (err != 0)
- return err;
+ goto pf_dev_free;
- nfp_netvf_ethdev_ops_mount(net_hw, eth_dev);
+ nfp_netvf_ethdev_ops_mount(pf_dev, eth_dev);
hw_priv = rte_zmalloc(NULL, sizeof(*hw_priv), 0);
if (hw_priv == NULL) {
@@ -296,6 +311,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
}
hw_priv->dev_info = dev_info;
+ hw_priv->pf_dev = pf_dev;
eth_dev->process_private = hw_priv;
@@ -330,7 +346,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
- nfp_net_log_device_information(net_hw);
+ nfp_net_log_device_information(net_hw, pf_dev);
/* Initializing spinlock for reconfigs */
rte_spinlock_init(&hw->reconfig_lock);
@@ -381,6 +397,8 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
rte_free(net_hw->eth_xstats_base);
hw_priv_free:
rte_free(hw_priv);
+pf_dev_free:
+ rte_free(pf_dev);
return err;
}
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index b471fd032a..e4e01d8c79 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -349,13 +349,14 @@ nfp_net_configure(struct rte_eth_dev *dev)
}
void
-nfp_net_log_device_information(const struct nfp_net_hw *hw)
+nfp_net_log_device_information(const struct nfp_net_hw *hw,
+ struct nfp_pf_dev *pf_dev)
{
uint32_t cap = hw->super.cap;
uint32_t cap_ext = hw->super.cap_ext;
PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
- hw->ver.major, hw->ver.minor, hw->max_mtu);
+ pf_dev->ver.major, pf_dev->ver.minor, hw->max_mtu);
PMD_INIT_LOG(INFO, "CAP: %#x", cap);
PMD_INIT_LOG(INFO, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
@@ -1235,14 +1236,13 @@ nfp_net_rx_desc_limits(struct nfp_net_hw_priv *hw_priv,
}
void
-nfp_net_tx_desc_limits(struct nfp_net_hw *hw,
- struct nfp_net_hw_priv *hw_priv,
+nfp_net_tx_desc_limits(struct nfp_net_hw_priv *hw_priv,
uint16_t *min_tx_desc,
uint16_t *max_tx_desc)
{
uint16_t tx_dpp;
- if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
+ if (hw_priv->pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
tx_dpp = NFD3_TX_DESC_PER_PKT;
else
tx_dpp = NFDK_TX_DESC_PER_SIMPLE_PKT;
@@ -1269,7 +1269,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
return -EINVAL;
nfp_net_rx_desc_limits(hw_priv, &min_rx_desc, &max_rx_desc);
- nfp_net_tx_desc_limits(hw, hw_priv, &min_tx_desc, &max_tx_desc);
+ nfp_net_tx_desc_limits(hw_priv, &min_tx_desc, &max_tx_desc);
dev_info->max_rx_queues = (uint16_t)hw->max_rx_queues;
dev_info->max_tx_queues = (uint16_t)hw->max_tx_queues;
@@ -1373,11 +1373,13 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
}
int
-nfp_net_common_init(struct rte_pci_device *pci_dev,
+nfp_net_common_init(struct nfp_pf_dev *pf_dev,
struct nfp_net_hw *hw)
{
const int stride = 4;
+ struct rte_pci_device *pci_dev;
+ pci_dev = pf_dev->pci_dev;
hw->device_id = pci_dev->id.device_id;
hw->vendor_id = pci_dev->id.vendor_id;
hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
@@ -1391,11 +1393,7 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
return -ENODEV;
}
- nfp_net_cfg_read_version(hw);
- if (!nfp_net_is_valid_nfd_version(hw->ver))
- return -EINVAL;
-
- if (nfp_net_check_dma_mask(hw, pci_dev->name) != 0)
+ if (nfp_net_check_dma_mask(pf_dev, pci_dev->name) != 0)
return -ENODEV;
/* Get some of the read-only fields from the config BAR */
@@ -1404,10 +1402,10 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
hw->max_mtu = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_MTU);
hw->flbufsz = DEFAULT_FLBUF_SIZE;
- nfp_net_meta_init_format(hw);
+ nfp_net_meta_init_format(hw, pf_dev);
/* Read the Rx offset configured from firmware */
- if (hw->ver.major < 2)
+ if (pf_dev->ver.major < 2)
hw->rx_offset = NFP_NET_RX_OFFSET;
else
hw->rx_offset = nn_cfg_readl(&hw->super, NFP_NET_CFG_RX_OFFSET);
@@ -2118,10 +2116,10 @@ nfp_net_set_vxlan_port(struct nfp_net_hw *net_hw,
* than 40 bits.
*/
int
-nfp_net_check_dma_mask(struct nfp_net_hw *hw,
+nfp_net_check_dma_mask(struct nfp_pf_dev *pf_dev,
char *name)
{
- if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3 &&
+ if (pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3 &&
rte_mem_check_dma_mask(40) != 0) {
PMD_DRV_LOG(ERR, "Device %s can't be used: restricted dma mask to 40 bits!",
name);
@@ -2165,16 +2163,28 @@ nfp_net_txrwb_free(struct rte_eth_dev *eth_dev)
net_hw->txrwb_mz = NULL;
}
-void
-nfp_net_cfg_read_version(struct nfp_net_hw *hw)
+static void
+nfp_net_cfg_read_version(struct nfp_hw *hw,
+ struct nfp_pf_dev *pf_dev)
{
union {
uint32_t whole;
struct nfp_net_fw_ver split;
} version;
- version.whole = nn_cfg_readl(&hw->super, NFP_NET_CFG_VERSION);
- hw->ver = version.split;
+ version.whole = nn_cfg_readl(hw, NFP_NET_CFG_VERSION);
+ pf_dev->ver = version.split;
+}
+
+bool
+nfp_net_version_check(struct nfp_hw *hw,
+ struct nfp_pf_dev *pf_dev)
+{
+ nfp_net_cfg_read_version(hw, pf_dev);
+ if (!nfp_net_is_valid_nfd_version(pf_dev->ver))
+ return false;
+
+ return true;
}
static void
@@ -2249,6 +2259,7 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
size_t fw_size)
{
struct nfp_net_hw *hw;
+ struct nfp_pf_dev *pf_dev;
struct nfp_net_hw_priv *hw_priv;
char app_name[FW_VER_LEN] = {0};
char mip_name[FW_VER_LEN] = {0};
@@ -2260,6 +2271,7 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
hw = nfp_net_get_hw(dev);
hw_priv = dev->process_private;
+ pf_dev = hw_priv->pf_dev;
if (hw->fw_version[0] != 0) {
snprintf(fw_version, FW_VER_LEN, "%s", hw->fw_version);
@@ -2268,8 +2280,8 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
if (!rte_eth_dev_is_repr(dev)) {
snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d",
- hw->ver.extend, hw->ver.class,
- hw->ver.major, hw->ver.minor);
+ pf_dev->ver.extend, pf_dev->ver.class,
+ pf_dev->ver.major, pf_dev->ver.minor);
} else {
snprintf(vnic_version, FW_VER_LEN, "*");
}
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 67ec5a2d89..8d0922d48c 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -108,6 +108,8 @@ struct nfp_pf_dev {
enum nfp_app_fw_id app_fw_id;
+ struct nfp_net_fw_ver ver;
+
/** Pointer to the app running on the PF */
void *app_fw_priv;
@@ -219,7 +221,6 @@ struct nfp_net_hw {
const struct rte_memzone *txrwb_mz;
/** Info from the firmware */
- struct nfp_net_fw_ver ver;
uint32_t max_mtu;
uint32_t mtu;
uint32_t rx_offset;
@@ -276,8 +277,9 @@ nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
/* Prototypes for common NFP functions */
int nfp_net_mbox_reconfig(struct nfp_net_hw *hw, uint32_t mbox_cmd);
int nfp_net_configure(struct rte_eth_dev *dev);
-int nfp_net_common_init(struct rte_pci_device *pci_dev, struct nfp_net_hw *hw);
-void nfp_net_log_device_information(const struct nfp_net_hw *hw);
+int nfp_net_common_init(struct nfp_pf_dev *pf_dev, struct nfp_net_hw *hw);
+void nfp_net_log_device_information(const struct nfp_net_hw *hw,
+ struct nfp_pf_dev *pf_dev);
void nfp_net_enable_queues(struct rte_eth_dev *dev);
void nfp_net_disable_queues(struct rte_eth_dev *dev);
void nfp_net_params_setup(struct nfp_net_hw *hw);
@@ -345,12 +347,10 @@ int nfp_net_set_vxlan_port(struct nfp_net_hw *hw, size_t idx, uint16_t port);
void nfp_net_rx_desc_limits(struct nfp_net_hw_priv *hw_priv,
uint16_t *min_rx_desc,
uint16_t *max_rx_desc);
-void nfp_net_tx_desc_limits(struct nfp_net_hw *hw,
- struct nfp_net_hw_priv *hw_priv,
+void nfp_net_tx_desc_limits(struct nfp_net_hw_priv *hw_priv,
uint16_t *min_tx_desc,
uint16_t *max_tx_desc);
-int nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name);
-void nfp_net_cfg_read_version(struct nfp_net_hw *hw);
+int nfp_net_check_dma_mask(struct nfp_pf_dev *pf_dev, char *name);
int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size);
bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version);
struct nfp_net_hw *nfp_net_get_hw(const struct rte_eth_dev *dev);
@@ -377,6 +377,8 @@ uint8_t nfp_function_id_get(const struct nfp_pf_dev *pf_dev,
uint8_t port_id);
int nfp_net_vf_config_app_init(struct nfp_net_hw *net_hw,
struct nfp_pf_dev *pf_dev);
+bool nfp_net_version_check(struct nfp_hw *hw,
+ struct nfp_pf_dev *pf_dev);
#define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\
((struct nfp_app_fw_nic *)app_fw_priv)
diff --git a/drivers/net/nfp/nfp_net_meta.c b/drivers/net/nfp/nfp_net_meta.c
index 07c6758d33..5a67f87bee 100644
--- a/drivers/net/nfp/nfp_net_meta.c
+++ b/drivers/net/nfp/nfp_net_meta.c
@@ -269,14 +269,15 @@ nfp_net_meta_parse(struct nfp_net_rx_desc *rxds,
}
void
-nfp_net_meta_init_format(struct nfp_net_hw *hw)
+nfp_net_meta_init_format(struct nfp_net_hw *hw,
+ struct nfp_pf_dev *pf_dev)
{
/*
* ABI 4.x and ctrl vNIC always use chained metadata, in other cases we allow use of
* single metadata if only RSS(v1) is supported by hw capability, and RSS(v2)
* also indicate that we are using chained metadata.
*/
- if (hw->ver.major == 4) {
+ if (pf_dev->ver.major == 4) {
hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
} else if ((hw->super.cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) {
hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
diff --git a/drivers/net/nfp/nfp_net_meta.h b/drivers/net/nfp/nfp_net_meta.h
index 69d08cf3a7..c3d84dff60 100644
--- a/drivers/net/nfp/nfp_net_meta.h
+++ b/drivers/net/nfp/nfp_net_meta.h
@@ -89,7 +89,10 @@ struct nfp_net_meta_parsed {
} vlan[NFP_NET_META_MAX_VLANS];
};
-void nfp_net_meta_init_format(struct nfp_net_hw *hw);
+struct nfp_pf_dev;
+
+void nfp_net_meta_init_format(struct nfp_net_hw *hw,
+ struct nfp_pf_dev *pf_dev);
void nfp_net_meta_parse(struct nfp_net_rx_desc *rxds,
struct nfp_net_rxq *rxq,
struct nfp_net_hw *hw,
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 05218537f7..d101477161 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -816,11 +816,11 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev,
unsigned int socket_id,
const struct rte_eth_txconf *tx_conf)
{
- struct nfp_net_hw *hw;
+ struct nfp_net_hw_priv *hw_priv;
- hw = nfp_net_get_hw(dev);
+ hw_priv = dev->process_private;
- if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
+ if (hw_priv->pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
return nfp_net_nfd3_tx_queue_setup(dev, queue_idx,
nb_desc, socket_id, tx_conf);
else
@@ -852,10 +852,10 @@ nfp_net_tx_queue_info_get(struct rte_eth_dev *dev,
struct rte_eth_txq_info *info)
{
struct rte_eth_dev_info dev_info;
- struct nfp_net_hw *hw = nfp_net_get_hw(dev);
+ struct nfp_net_hw_priv *hw_priv = dev->process_private;
struct nfp_net_txq *txq = dev->data->tx_queues[queue_id];
- if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
+ if (hw_priv->pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
info->nb_desc = txq->tx_count / NFD3_TX_DESC_PER_PKT;
else
info->nb_desc = txq->tx_count / NFDK_TX_DESC_PER_SIMPLE_PKT;
--
2.39.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/4] net/nfp: support different configuration BAR size
2024-09-03 1:41 [PATCH 0/4] Support new card using NFP 3800 chip Chaoyong He
2024-09-03 1:41 ` [PATCH 1/4] net/nfp: add a new flag to indicate PF Chaoyong He
2024-09-03 1:41 ` [PATCH 2/4] net/nfp: refactor the firmware version logic Chaoyong He
@ 2024-09-03 1:41 ` Chaoyong He
2024-09-03 1:41 ` [PATCH 4/4] net/nfp: support different flow steering rules limit Chaoyong He
2024-10-04 4:26 ` [PATCH 0/4] Support new card using NFP 3800 chip Ferruh Yigit
4 siblings, 0 replies; 6+ messages in thread
From: Chaoyong He @ 2024-09-03 1:41 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu
A new NIC is introduced with different configuration
BAR size other than 32K, and this is distinguished by
the application firmware's class version ABI.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
drivers/common/nfp/nfp_common_ctrl.h | 10 +++++++++-
drivers/net/nfp/flower/nfp_flower.c | 4 ++--
drivers/net/nfp/nfp_ethdev.c | 24 ++++++++++++++----------
drivers/net/nfp/nfp_ethdev_vf.c | 3 +++
drivers/net/nfp/nfp_net_common.c | 25 +++++++++++++++++++++++++
drivers/net/nfp/nfp_net_common.h | 3 +++
drivers/net/nfp/nfp_net_ctrl.c | 4 +++-
7 files changed, 59 insertions(+), 14 deletions(-)
diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index 69596dd6f5..711577dc76 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -11,7 +11,9 @@
*
* On the NFP6000, due to THB-350, the configuration BAR is 32K in size.
*/
-#define NFP_NET_CFG_BAR_SZ (32 * 1024)
+#define NFP_NET_CFG_BAR_SZ_32K (32 * 1024)
+#define NFP_NET_CFG_BAR_SZ_8K (8 * 1024)
+#define NFP_NET_CFG_BAR_SZ_MIN NFP_NET_CFG_BAR_SZ_8K
/*
* Configuration sriov VF.
@@ -121,6 +123,10 @@
struct nfp_net_fw_ver {
uint8_t minor;
uint8_t major;
+ /**
+ * BIT0: class, refer NFP_NET_CFG_VERSION_CLASS_*
+ * BIT[7:1]: reserved
+ */
uint8_t class;
/**
* This byte can be extended for more use.
@@ -147,6 +153,8 @@ struct nfp_net_fw_ver {
#define NFP_NET_CFG_VERSION 0x0030
#define NFP_NET_CFG_VERSION_DP_NFD3 0
#define NFP_NET_CFG_VERSION_DP_NFDK 1
+#define NFP_NET_CFG_VERSION_CLASS_GENERIC 0
+#define NFP_NET_CFG_VERSION_CLASS_NO_EMEM 1
#define NFP_NET_CFG_STS 0x0034
#define NFP_NET_CFG_STS_LINK (0x1 << 0) /* Link up or down */
/* Link rate */
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 4d91d548f7..c1a3532c11 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -692,7 +692,7 @@ nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv)
/* Map the PF ctrl bar */
snprintf(bar_name, sizeof(bar_name), "_pf%u_net_bar0", id);
pf_dev->ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, bar_name,
- NFP_NET_CFG_BAR_SZ, &pf_dev->ctrl_area);
+ pf_dev->ctrl_bar_size, &pf_dev->ctrl_area);
if (pf_dev->ctrl_bar == NULL) {
PMD_INIT_LOG(ERR, "Cloud not map the PF vNIC ctrl bar");
ret = -ENODEV;
@@ -737,7 +737,7 @@ nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv)
/* Map the ctrl vNIC ctrl bar */
snprintf(ctrl_name, sizeof(ctrl_name), "_pf%u_net_ctrl_bar", id);
ctrl_hw->super.ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, ctrl_name,
- NFP_NET_CFG_BAR_SZ, &ctrl_hw->ctrl_area);
+ pf_dev->ctrl_bar_size, &ctrl_hw->ctrl_area);
if (ctrl_hw->super.ctrl_bar == NULL) {
PMD_INIT_LOG(ERR, "Cloud not map the ctrl vNIC ctrl bar");
ret = -ENODEV;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index d85993f70c..a09bbe52ca 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -1022,7 +1022,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev,
if (pf_dev->multi_pf.enabled)
hw->ctrl_bar = pf_dev->ctrl_bar;
else
- hw->ctrl_bar = pf_dev->ctrl_bar + (port * NFP_NET_CFG_BAR_SZ);
+ hw->ctrl_bar = pf_dev->ctrl_bar + (port * pf_dev->ctrl_bar_size);
net_hw->mac_stats = pf_dev->mac_stats_bar +
(net_hw->nfp_idx * NFP_MAC_STATS_SIZE);
@@ -1555,9 +1555,10 @@ nfp_enable_multi_pf(struct nfp_pf_dev *pf_dev)
memset(&net_hw, 0, sizeof(struct nfp_net_hw));
/* Map the symbol table */
+ pf_dev->ctrl_bar_size = NFP_NET_CFG_BAR_SZ_MIN;
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,
+ ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, name, pf_dev->ctrl_bar_size,
&area);
if (ctrl_bar == NULL) {
PMD_INIT_LOG(ERR, "Failed to find data vNIC memory symbol");
@@ -1574,6 +1575,9 @@ nfp_enable_multi_pf(struct nfp_pf_dev *pf_dev)
goto end;
}
+ /* Set the ctrl bar size */
+ nfp_net_ctrl_bar_size_set(pf_dev);
+
if (!pf_dev->multi_pf.enabled)
goto end;
@@ -1670,7 +1674,7 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv)
/* 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,
- pf_dev->total_phyports * NFP_NET_CFG_BAR_SZ,
+ pf_dev->total_phyports * pf_dev->ctrl_bar_size,
&pf_dev->ctrl_area);
if (pf_dev->ctrl_bar == NULL) {
PMD_INIT_LOG(ERR, "nfp_rtsym_map fails for %s", bar_name);
@@ -2065,11 +2069,11 @@ nfp_net_vf_config_init(struct nfp_pf_dev *pf_dev)
if (pf_dev->sriov_vf == 0)
return 0;
- min_size = NFP_NET_CFG_BAR_SZ * pf_dev->sriov_vf;
+ min_size = pf_dev->ctrl_bar_size * 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,
+ pf_dev->ctrl_bar_size * 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.");
@@ -2295,15 +2299,15 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
goto hwqueues_cleanup;
}
+ ret = nfp_enable_multi_pf(pf_dev);
+ if (ret != 0)
+ goto mac_stats_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;
- }
-
- ret = nfp_enable_multi_pf(pf_dev);
- if (ret != 0)
goto vf_cfg_tbl_cleanup;
+ }
hw_priv->is_pf = true;
hw_priv->pf_dev = pf_dev;
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 2e581c7e45..ab413a2c5a 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -295,6 +295,9 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
goto pf_dev_free;
}
+ /* Set the ctrl bar size */
+ nfp_net_ctrl_bar_size_set(pf_dev);
+
PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
err = nfp_net_common_init(pf_dev, net_hw);
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index e4e01d8c79..5f92c2c31d 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -2184,6 +2184,9 @@ nfp_net_version_check(struct nfp_hw *hw,
if (!nfp_net_is_valid_nfd_version(pf_dev->ver))
return false;
+ if (!nfp_net_is_valid_version_class(pf_dev->ver))
+ return false;
+
return true;
}
@@ -2325,6 +2328,28 @@ nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version)
return false;
}
+bool
+nfp_net_is_valid_version_class(struct nfp_net_fw_ver version)
+{
+ switch (version.class) {
+ case NFP_NET_CFG_VERSION_CLASS_GENERIC:
+ return true;
+ case NFP_NET_CFG_VERSION_CLASS_NO_EMEM:
+ return true;
+ default:
+ return false;
+ }
+}
+
+void
+nfp_net_ctrl_bar_size_set(struct nfp_pf_dev *pf_dev)
+{
+ if (pf_dev->ver.class == NFP_NET_CFG_VERSION_CLASS_GENERIC)
+ pf_dev->ctrl_bar_size = NFP_NET_CFG_BAR_SZ_32K;
+ else
+ pf_dev->ctrl_bar_size = NFP_NET_CFG_BAR_SZ_8K;
+}
+
/* Disable rx and tx functions to allow for reconfiguring. */
int
nfp_net_stop(struct rte_eth_dev *dev)
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 8d0922d48c..2c54815fc9 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -117,6 +117,7 @@ struct nfp_pf_dev {
struct nfp_eth_table *nfp_eth_table;
uint8_t *ctrl_bar;
+ uint32_t ctrl_bar_size;
struct nfp_cpp *cpp;
struct nfp_cpp_area *ctrl_area;
@@ -353,6 +354,7 @@ void nfp_net_tx_desc_limits(struct nfp_net_hw_priv *hw_priv,
int nfp_net_check_dma_mask(struct nfp_pf_dev *pf_dev, char *name);
int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size);
bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version);
+bool nfp_net_is_valid_version_class(struct nfp_net_fw_ver version);
struct nfp_net_hw *nfp_net_get_hw(const struct rte_eth_dev *dev);
int nfp_net_stop(struct rte_eth_dev *dev);
int nfp_net_flow_ctrl_get(struct rte_eth_dev *dev,
@@ -379,6 +381,7 @@ int nfp_net_vf_config_app_init(struct nfp_net_hw *net_hw,
struct nfp_pf_dev *pf_dev);
bool nfp_net_version_check(struct nfp_hw *hw,
struct nfp_pf_dev *pf_dev);
+void nfp_net_ctrl_bar_size_set(struct nfp_pf_dev *pf_dev);
#define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\
((struct nfp_app_fw_nic *)app_fw_priv)
diff --git a/drivers/net/nfp/nfp_net_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
index ea14b98924..b34d8f140f 100644
--- a/drivers/net/nfp/nfp_net_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -30,13 +30,15 @@ nfp_net_tlv_caps_parse(struct rte_eth_dev *dev)
uint32_t tlv_type;
struct nfp_net_hw *net_hw;
struct nfp_net_tlv_caps *caps;
+ struct nfp_net_hw_priv *hw_priv;
net_hw = dev->data->dev_private;
+ hw_priv = dev->process_private;
caps = &net_hw->tlv_caps;
nfp_net_tlv_caps_reset(caps);
data = net_hw->super.ctrl_bar + NFP_NET_CFG_TLV_BASE;
- end = net_hw->super.ctrl_bar + NFP_NET_CFG_BAR_SZ;
+ end = net_hw->super.ctrl_bar + hw_priv->pf_dev->ctrl_bar_size;
hdr = rte_read32(data);
if (hdr == 0) {
--
2.39.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/4] net/nfp: support different flow steering rules limit
2024-09-03 1:41 [PATCH 0/4] Support new card using NFP 3800 chip Chaoyong He
` (2 preceding siblings ...)
2024-09-03 1:41 ` [PATCH 3/4] net/nfp: support different configuration BAR size Chaoyong He
@ 2024-09-03 1:41 ` Chaoyong He
2024-10-04 4:26 ` [PATCH 0/4] Support new card using NFP 3800 chip Ferruh Yigit
4 siblings, 0 replies; 6+ messages in thread
From: Chaoyong He @ 2024-09-03 1:41 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu
Get the flow steering rules limit from the firmware rather than
the hard coded.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
drivers/common/nfp/nfp_common_ctrl.h | 3 +-
drivers/net/nfp/nfp_net_common.h | 4 +--
drivers/net/nfp/nfp_net_flow.c | 51 ++++++++++++++++++++++++----
3 files changed, 47 insertions(+), 11 deletions(-)
diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index 711577dc76..16a18348c6 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -219,8 +219,7 @@ struct nfp_net_fw_ver {
#define NFP_NET_CFG_CAP_WORD1 0x00a4
/* 16B reserved for future use (0x00b0 - 0x00c0). */
-#define NFP_NET_CFG_RESERVED 0x00b0
-#define NFP_NET_CFG_RESERVED_SZ 0x0010
+#define NFP_NET_CFG_MAX_FS_CAP 0x00b8
/*
* RSS configuration (0x0100 - 0x01ac):
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 2c54815fc9..be5705636f 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -186,13 +186,13 @@ struct nfp_net_flow_count {
};
#define NFP_NET_HASH_REDUNDANCE (1.2)
-#define NFP_NET_FLOW_HASH_TBALE_SIZE ((NFP_NET_FLOW_LIMIT) * (NFP_NET_HASH_REDUNDANCE))
struct nfp_net_priv {
uint32_t hash_seed; /**< Hash seed for hash tables in this structure. */
struct rte_hash *flow_table; /**< Hash table to store flow rules. */
struct nfp_net_flow_count flow_count; /**< Flow count in hash table */
- bool flow_position[NFP_NET_FLOW_LIMIT]; /**< Flow position array */
+ uint32_t flow_limit; /**< Flow limit of hash table */
+ bool *flow_position; /**< Flow position array */
};
struct nfp_app_fw_nic {
diff --git a/drivers/net/nfp/nfp_net_flow.c b/drivers/net/nfp/nfp_net_flow.c
index 2c7801ed41..5db4712193 100644
--- a/drivers/net/nfp/nfp_net_flow.c
+++ b/drivers/net/nfp/nfp_net_flow.c
@@ -88,9 +88,12 @@ nfp_net_flow_position_acquire(struct nfp_net_priv *priv,
struct rte_flow *nfp_flow)
{
uint32_t i;
+ uint32_t limit;
+
+ limit = priv->flow_limit;
if (priority != 0) {
- i = NFP_NET_FLOW_LIMIT - priority - 1;
+ i = limit - priority - 1;
if (priv->flow_position[i]) {
PMD_DRV_LOG(ERR, "There is already a flow rule in this place.");
@@ -102,19 +105,19 @@ nfp_net_flow_position_acquire(struct nfp_net_priv *priv,
return 0;
}
- for (i = 0; i < NFP_NET_FLOW_LIMIT; i++) {
+ for (i = 0; i < limit; i++) {
if (!priv->flow_position[i]) {
priv->flow_position[i] = true;
break;
}
}
- if (i == NFP_NET_FLOW_LIMIT) {
+ if (i == limit) {
PMD_DRV_LOG(ERR, "The limited flow number is reach.");
return -ERANGE;
}
- nfp_flow->position = NFP_NET_FLOW_LIMIT - i - 1;
+ nfp_flow->position = limit - i - 1;
return 0;
}
@@ -1053,11 +1056,24 @@ nfp_net_flow_ops_get(struct rte_eth_dev *dev,
return 0;
}
+static uint32_t
+nfp_net_fs_max_entry_get(struct nfp_hw *hw)
+{
+ uint32_t cnt;
+
+ cnt = nn_cfg_readl(hw, NFP_NET_CFG_MAX_FS_CAP);
+ if (cnt != 0)
+ return cnt;
+
+ return NFP_NET_FLOW_LIMIT;
+}
+
int
nfp_net_flow_priv_init(struct nfp_pf_dev *pf_dev,
uint16_t port)
{
int ret = 0;
+ struct nfp_hw *hw;
struct nfp_net_priv *priv;
char flow_name[RTE_HASH_NAMESIZE];
struct nfp_app_fw_nic *app_fw_nic;
@@ -1067,7 +1083,6 @@ nfp_net_flow_priv_init(struct nfp_pf_dev *pf_dev,
struct rte_hash_parameters flow_hash_params = {
.name = flow_name,
- .entries = NFP_NET_FLOW_HASH_TBALE_SIZE,
.hash_func = rte_jhash,
.socket_id = rte_socket_id(),
.key_len = sizeof(uint32_t),
@@ -1085,17 +1100,37 @@ nfp_net_flow_priv_init(struct nfp_pf_dev *pf_dev,
app_fw_nic->ports[port]->priv = priv;
priv->hash_seed = (uint32_t)rte_rand();
+ /* Flow limit */
+ hw = &app_fw_nic->ports[port]->super;
+ priv->flow_limit = nfp_net_fs_max_entry_get(hw);
+ if (priv->flow_limit == 0) {
+ PMD_INIT_LOG(ERR, "NFP app nic flow limit not right.");
+ ret = -EINVAL;
+ goto free_priv;
+ }
+
+ /* Flow position array */
+ priv->flow_position = rte_zmalloc(NULL, sizeof(bool) * priv->flow_limit, 0);
+ if (priv->flow_position == NULL) {
+ PMD_INIT_LOG(ERR, "NFP app nic flow position creation failed.");
+ ret = -ENOMEM;
+ goto free_priv;
+ }
+
/* Flow table */
flow_hash_params.hash_func_init_val = priv->hash_seed;
+ flow_hash_params.entries = priv->flow_limit * NFP_NET_HASH_REDUNDANCE;
priv->flow_table = rte_hash_create(&flow_hash_params);
if (priv->flow_table == NULL) {
PMD_INIT_LOG(ERR, "flow hash table creation failed");
ret = -ENOMEM;
- goto free_priv;
+ goto free_flow_position;
}
return 0;
+free_flow_position:
+ rte_free(priv->flow_position);
free_priv:
rte_free(priv);
exit:
@@ -1114,8 +1149,10 @@ nfp_net_flow_priv_uninit(struct nfp_pf_dev *pf_dev,
app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv);
priv = app_fw_nic->ports[port]->priv;
- if (priv != NULL)
+ if (priv != NULL) {
rte_hash_free(priv->flow_table);
+ rte_free(priv->flow_position);
+ }
rte_free(priv);
}
--
2.39.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] Support new card using NFP 3800 chip
2024-09-03 1:41 [PATCH 0/4] Support new card using NFP 3800 chip Chaoyong He
` (3 preceding siblings ...)
2024-09-03 1:41 ` [PATCH 4/4] net/nfp: support different flow steering rules limit Chaoyong He
@ 2024-10-04 4:26 ` Ferruh Yigit
4 siblings, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2024-10-04 4:26 UTC (permalink / raw)
To: Chaoyong He, dev; +Cc: oss-drivers
On 9/3/2024 2:41 AM, Chaoyong He wrote:
> This patch series add support of a new card which using the NFP 3800 chip.
> Because it has different configure BAR size and flow steering rules
> limit, we also do some refactor to the related logic.
>
> Chaoyong He (4):
> net/nfp: add a new flag to indicate PF
> net/nfp: refactor the firmware version logic
> net/nfp: support different configuration BAR size
> net/nfp: support different flow steering rules limit
>
Series applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-04 4:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-03 1:41 [PATCH 0/4] Support new card using NFP 3800 chip Chaoyong He
2024-09-03 1:41 ` [PATCH 1/4] net/nfp: add a new flag to indicate PF Chaoyong He
2024-09-03 1:41 ` [PATCH 2/4] net/nfp: refactor the firmware version logic Chaoyong He
2024-09-03 1:41 ` [PATCH 3/4] net/nfp: support different configuration BAR size Chaoyong He
2024-09-03 1:41 ` [PATCH 4/4] net/nfp: support different flow steering rules limit Chaoyong He
2024-10-04 4:26 ` [PATCH 0/4] Support new card using NFP 3800 chip Ferruh Yigit
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).