* [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