DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 00/17] NFP bugfix
@ 2024-06-24  1:57 Chaoyong He
  2024-06-24  1:57 ` [PATCH 01/17] net/nfp: refactor speed configuration logic Chaoyong He
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He

This patch series consist a branch of bugfix patches from NFP PMD,
in order to speed up the review process and avoid send them out one
by one.

Chaoyong He (4):
  net/nfp: fix coredump caused by firmware abnormal cleanup
  net/nfp: forbid offload flow rules with empty action list
  net/nfp: remove redundancy function call
  net/nfp: fix null pointer dereferences

Long Wu (6):
  net/nfp: fix flow rule match data problem
  net/nfp: fix flow rule action data problem
  net/nfp: enlarge the flow rules limitation
  net/nfp: enlarge flow hash table size
  net/nfp: fix flow position index problem
  net/nfp: fix port action core dump

Peng Zhang (3):
  doc: update the metadata description section
  net/nfp: remove the unneeded logic
  net/nfp: adapts the reverse sequence card

Zerun Fu (4):
  net/nfp: refactor speed configuration logic
  net/nfp: refactor device speed update logic
  net/nfp: fix link status display problem
  net/nfp: fix getting firmware version

 doc/guides/nics/nfp.rst                       |   4 -
 drivers/net/nfp/flower/nfp_flower_flow.c      |   9 +-
 .../net/nfp/flower/nfp_flower_representor.c   |   2 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c            |   6 -
 drivers/net/nfp/nfp_ethdev.c                  | 109 +++++++++++++-----
 drivers/net/nfp/nfp_ethdev_vf.c               |   2 -
 drivers/net/nfp/nfp_net_cmsg.h                |   6 +-
 drivers/net/nfp/nfp_net_common.c              |  61 ++++++----
 drivers/net/nfp/nfp_net_common.h              |  28 ++++-
 drivers/net/nfp/nfp_net_flow.c                |  95 +++++++++++++--
 10 files changed, 239 insertions(+), 83 deletions(-)

-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 01/17] net/nfp: refactor speed configuration logic
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 02/17] net/nfp: refactor device speed update logic Chaoyong He
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Zerun Fu, Chaoyong He, Long Wu, Peng Zhang

From: Zerun Fu <zerun.fu@corigine.com>

The speed configuration logic will execute every time the
device start, even if the speed is not changed. Refactor
this part of logic to make sure it only executes when the
speed is really need to be changed.

Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
Reviewed-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 | 100 +++++++++++++++++++++++++----------
 1 file changed, 73 insertions(+), 27 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index b04bc955b5..f4fd013a51 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -220,12 +220,68 @@ nfp_net_nfp4000_speed_configure_check(uint16_t port_id,
 	return 0;
 }
 
+static int
+nfp_net_speed_autoneg_set(struct nfp_net_hw_priv *hw_priv,
+		struct nfp_eth_table_port *eth_port)
+{
+	int ret;
+	struct nfp_nsp *nsp;
+
+	nsp = nfp_eth_config_start(hw_priv->pf_dev->cpp, eth_port->index);
+	if (nsp == NULL) {
+		PMD_DRV_LOG(ERR, "Could not get NSP.");
+		return -EIO;
+	}
+
+	ret = nfp_eth_set_aneg(nsp, NFP_ANEG_AUTO);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to set ANEG enable.");
+		nfp_eth_config_cleanup_end(nsp);
+		return ret;
+	}
+
+	return nfp_eth_config_commit_end(nsp);
+}
+
+static int
+nfp_net_speed_fixed_set(struct nfp_net_hw_priv *hw_priv,
+		struct nfp_eth_table_port *eth_port,
+		uint32_t configure_speed)
+{
+	int ret;
+	struct nfp_nsp *nsp;
+
+	nsp = nfp_eth_config_start(hw_priv->pf_dev->cpp, eth_port->index);
+	if (nsp == NULL) {
+		PMD_DRV_LOG(ERR, "Could not get NSP.");
+		return -EIO;
+	}
+
+	ret = nfp_eth_set_aneg(nsp, NFP_ANEG_DISABLED);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to set ANEG disable.");
+		goto config_cleanup;
+	}
+
+	ret = nfp_eth_set_speed(nsp, configure_speed);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to set speed.");
+		goto config_cleanup;
+	}
+
+	return nfp_eth_config_commit_end(nsp);
+
+config_cleanup:
+	nfp_eth_config_cleanup_end(nsp);
+
+	return ret;
+}
+
 static int
 nfp_net_speed_configure(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint32_t speed_capa;
-	struct nfp_nsp *nsp;
 	uint32_t link_speeds;
 	uint32_t configure_speed;
 	struct nfp_eth_table_port *eth_port;
@@ -260,40 +316,30 @@ nfp_net_speed_configure(struct rte_eth_dev *dev)
 		}
 	}
 
-	nsp = nfp_eth_config_start(hw_priv->pf_dev->cpp, eth_port->index);
-	if (nsp == NULL) {
-		PMD_DRV_LOG(ERR, "Couldn't get NSP.");
-		return -EIO;
-	}
+	if (configure_speed == RTE_ETH_LINK_SPEED_AUTONEG) {
+		if (!eth_port->supp_aneg)
+			return 0;
 
-	if (link_speeds == RTE_ETH_LINK_SPEED_AUTONEG) {
-		if (eth_port->supp_aneg) {
-			ret = nfp_eth_set_aneg(nsp, NFP_ANEG_AUTO);
-			if (ret != 0) {
-				PMD_DRV_LOG(ERR, "Failed to set ANEG enable.");
-				goto config_cleanup;
-			}
-		}
-	} else {
-		ret = nfp_eth_set_aneg(nsp, NFP_ANEG_DISABLED);
+		if (eth_port->aneg == NFP_ANEG_AUTO)
+			return 0;
+
+		ret = nfp_net_speed_autoneg_set(hw_priv, eth_port);
 		if (ret != 0) {
-			PMD_DRV_LOG(ERR, "Failed to set ANEG disable.");
-			goto config_cleanup;
+			PMD_DRV_LOG(ERR, "Failed to set speed autoneg.");
+			return ret;
 		}
+	} else {
+		if (eth_port->aneg == NFP_ANEG_DISABLED && configure_speed == eth_port->speed)
+			return 0;
 
-		ret = nfp_eth_set_speed(nsp, configure_speed);
+		ret = nfp_net_speed_fixed_set(hw_priv, eth_port, configure_speed);
 		if (ret != 0) {
-			PMD_DRV_LOG(ERR, "Failed to set speed.");
-			goto config_cleanup;
+			PMD_DRV_LOG(ERR, "Failed to set speed fixed.");
+			return ret;
 		}
 	}
 
-	return nfp_eth_config_commit_end(nsp);
-
-config_cleanup:
-	nfp_eth_config_cleanup_end(nsp);
-
-	return ret;
+	return 0;
 }
 
 static int
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 02/17] net/nfp: refactor device speed update logic
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
  2024-06-24  1:57 ` [PATCH 01/17] net/nfp: refactor speed configuration logic Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 03/17] net/nfp: fix link status display problem Chaoyong He
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Zerun Fu, Chaoyong He, Long Wu, Peng Zhang

From: Zerun Fu <zerun.fu@corigine.com>

The previous logic will call 'nfp_eth_read_ports()' every time when the
link status changed, but some of which are not necessary.

Refactor this part of logic and only call 'nfp_eth_read_ports()' when
the speed is really updated or the device is under auto-negotiation mode.

Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
Reviewed-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     |  3 +++
 drivers/net/nfp/nfp_net_common.c | 18 ++++++++++++------
 drivers/net/nfp/nfp_net_common.h |  3 +++
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index f4fd013a51..9870b2dd33 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -339,6 +339,8 @@ nfp_net_speed_configure(struct rte_eth_dev *dev)
 		}
 	}
 
+	hw_priv->pf_dev->speed_updated = true;
+
 	return 0;
 }
 
@@ -2250,6 +2252,7 @@ nfp_pf_init(struct rte_pci_device *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);
+	pf_dev->speed_updated = false;
 
 	ret = nfp_net_speed_cap_get(pf_dev);
 	if (ret != 0) {
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 5616160686..fed8daa188 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -738,22 +738,28 @@ nfp_net_speed_aneg_update(struct rte_eth_dev *dev,
 {
 	uint32_t i;
 	uint32_t speed;
+	enum nfp_eth_aneg aneg;
+	struct nfp_pf_dev *pf_dev;
 	struct nfp_eth_table *nfp_eth_table;
 	struct nfp_eth_table_port *eth_port;
 
+	pf_dev = hw_priv->pf_dev;
+	aneg = pf_dev->nfp_eth_table->ports[hw->idx].aneg;
+
 	/* Compare whether the current status has changed. */
-	if (dev->data->dev_link.link_status != link->link_status) {
-		nfp_eth_table = nfp_eth_read_ports(hw_priv->pf_dev->cpp);
+	if (pf_dev->speed_updated || aneg == NFP_ANEG_AUTO) {
+		nfp_eth_table = nfp_eth_read_ports(pf_dev->cpp);
 		if (nfp_eth_table == NULL) {
 			PMD_DRV_LOG(DEBUG, "Error reading NFP ethernet table.");
 			return -EIO;
+		} else {
+			pf_dev->nfp_eth_table->ports[hw->idx] = nfp_eth_table->ports[hw->idx];
+			free(nfp_eth_table);
+			pf_dev->speed_updated = false;
 		}
-
-		hw_priv->pf_dev->nfp_eth_table->ports[hw->idx] = nfp_eth_table->ports[hw->idx];
-		free(nfp_eth_table);
 	}
 
-	nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
+	nfp_eth_table = pf_dev->nfp_eth_table;
 	eth_port = &nfp_eth_table->ports[hw->idx];
 	speed = eth_port->speed;
 
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index b43f815951..8e3e219261 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -160,6 +160,9 @@ struct nfp_pf_dev {
 	uint8_t vf_base_id;
 	/** Number of queues per VF */
 	uint32_t queue_per_vf;
+
+	/** Record the speed uptade */
+	bool speed_updated;
 };
 
 #define NFP_NET_FLOW_LIMIT    1024
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 03/17] net/nfp: fix link status display problem
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
  2024-06-24  1:57 ` [PATCH 01/17] net/nfp: refactor speed configuration logic Chaoyong He
  2024-06-24  1:57 ` [PATCH 02/17] net/nfp: refactor device speed update logic Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 04/17] net/nfp: fix coredump caused by firmware abnormal cleanup Chaoyong He
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Zerun Fu, stable, Chaoyong He, Long Wu, Peng Zhang

From: Zerun Fu <zerun.fu@corigine.com>

In the previous logic, the link status will shown as down wrongly
whenever the call to 'nfp_eth_read_ports()' fail.

Fix this by removing the exit logic when call to 'nfp_eth_read_ports()'
fail and just giving a warning.

Fixes: 8412feed3f26 ("net/nfp: modify link update function")
Cc: stable@dpdk.org

Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
Reviewed-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_net_common.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index fed8daa188..a6573ed45c 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -730,7 +730,7 @@ nfp_net_allmulticast_disable(struct rte_eth_dev *dev)
 	return nfp_net_set_allmulticast_mode(dev, false);
 }
 
-static int
+static void
 nfp_net_speed_aneg_update(struct rte_eth_dev *dev,
 		struct nfp_net_hw *hw,
 		struct nfp_net_hw_priv *hw_priv,
@@ -750,8 +750,7 @@ nfp_net_speed_aneg_update(struct rte_eth_dev *dev,
 	if (pf_dev->speed_updated || aneg == NFP_ANEG_AUTO) {
 		nfp_eth_table = nfp_eth_read_ports(pf_dev->cpp);
 		if (nfp_eth_table == NULL) {
-			PMD_DRV_LOG(DEBUG, "Error reading NFP ethernet table.");
-			return -EIO;
+			PMD_DRV_LOG(WARNING, "Failed to update port speed.");
 		} else {
 			pf_dev->nfp_eth_table->ports[hw->idx] = nfp_eth_table->ports[hw->idx];
 			free(nfp_eth_table);
@@ -773,8 +772,6 @@ nfp_net_speed_aneg_update(struct rte_eth_dev *dev,
 	if (dev->data->dev_conf.link_speeds == RTE_ETH_LINK_SPEED_AUTONEG &&
 			eth_port->supp_aneg)
 		link->link_autoneg = RTE_ETH_LINK_AUTONEG;
-
-	return 0;
 }
 
 int
@@ -790,11 +787,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) {
-			ret = nfp_net_speed_aneg_update(dev, hw, hw_priv, link);
-			if (ret != 0) {
-				PMD_DRV_LOG(DEBUG, "Failed to update speed and aneg.");
-				return ret;
-			}
+			nfp_net_speed_aneg_update(dev, hw, hw_priv, link);
 		} else {
 			/*
 			 * Shift and mask nn_link_status so that it is effectively the value
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 04/17] net/nfp: fix coredump caused by firmware abnormal cleanup
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (2 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 03/17] net/nfp: fix link status display problem Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 05/17] net/nfp: forbid offload flow rules with empty action list Chaoyong He
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, peng.zhang, stable, Long Wu

The logic of 'nfp_fw_setup()' consider both single-pf and multi-pf
firmware, but the abnormal firmware cleanup logic only consider multi-pf
firmware and try to write the heart beat value, which will cause
coredump when using the single-pf firmware.

Fixes: 8ba461d1eecc ("net/nfp: introduce keepalive mechanism for multiple PF")
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 | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 9870b2dd33..9196d5d0a4 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -2335,9 +2335,11 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
 	free(sym_tbl);
 fw_cleanup:
 	nfp_fw_unload(cpp);
-	nfp_net_keepalive_stop(&pf_dev->multi_pf);
-	nfp_net_keepalive_clear(pf_dev->multi_pf.beat_addr, pf_dev->multi_pf.function_id);
-	nfp_net_keepalive_uninit(&pf_dev->multi_pf);
+	if (pf_dev->multi_pf.enabled) {
+		nfp_net_keepalive_stop(&pf_dev->multi_pf);
+		nfp_net_keepalive_clear(pf_dev->multi_pf.beat_addr, pf_dev->multi_pf.function_id);
+		nfp_net_keepalive_uninit(&pf_dev->multi_pf);
+	}
 eth_table_cleanup:
 	free(nfp_eth_table);
 hwinfo_cleanup:
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 05/17] net/nfp: forbid offload flow rules with empty action list
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (3 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 04/17] net/nfp: fix coredump caused by firmware abnormal cleanup Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 06/17] net/nfp: remove redundancy function call Chaoyong He
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, stable, Long Wu, Peng Zhang

The original logic allow offload flow rules with empty action list, but
the matched packets will be drop by the flower firmware.

Fix this by forbidding offload this type flow rules.

Fixes: 4d946034bf9c ("net/nfp: support basic flow actions")
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/flower/nfp_flower_flow.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 9f410515e6..d127171fdb 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -4757,6 +4757,11 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
 		total_actions++;
 	}
 
+	if (total_actions == 0 || param.position == param.action_data) {
+		PMD_DRV_LOG(ERR, "The action list is empty");
+		return -ENOTSUP;
+	}
+
 	nfp_flow_meta = nfp_flow->payload.meta;
 	if (flag.drop_flag)
 		nfp_flow_meta->shortcut = rte_cpu_to_be_32(NFP_FL_SC_ACT_DROP);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 06/17] net/nfp: remove redundancy function call
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (4 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 05/17] net/nfp: forbid offload flow rules with empty action list Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 07/17] net/nfp: fix flow rule match data problem Chaoyong He
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, stable, Long Wu, Peng Zhang

Remove the redundancy call of 'rte_eth_copy_pci_info()' as the API
'rte_eth_dev_pci_allocate()' already done that.

Fixes: e1124c4f8a45 ("net/nfp: add flower representor framework")
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_vf.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index a5c600c87b..cdf5da3af7 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -303,8 +303,6 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
-	rte_eth_copy_pci_info(eth_dev, pci_dev);
-
 	net_hw->eth_xstats_base = rte_malloc("rte_eth_xstat",
 			sizeof(struct rte_eth_xstat) * nfp_net_xstats_size(eth_dev), 0);
 	if (net_hw->eth_xstats_base == NULL) {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 07/17] net/nfp: fix flow rule match data problem
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (5 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 06/17] net/nfp: remove redundancy function call Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 08/17] net/nfp: fix flow rule action " Chaoyong He
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, chaoyong.he, stable, Peng Zhang

From: Long Wu <long.wu@corigine.com>

The port and port mask field of 'struct nfp_net_cmsg_match_v4'
are in the wrong position, and this will cause firmware not
work as expected.

Fixes: 42eabda06b0f ("net/nfp: support IPv4 flow item")
Cc: chaoyong.he@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/nfp_net_cmsg.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_cmsg.h b/drivers/net/nfp/nfp_net_cmsg.h
index 4fab462cb9..b3d9bc33cf 100644
--- a/drivers/net/nfp/nfp_net_cmsg.h
+++ b/drivers/net/nfp/nfp_net_cmsg.h
@@ -52,10 +52,10 @@ struct nfp_net_cmsg_match_v4 {
 	uint32_t src_ipv4_mask;
 	uint32_t dst_ipv4;
 	uint32_t dst_ipv4_mask;
-	uint16_t src_port;
 	uint16_t src_port_mask;
-	uint16_t dst_port;
+	uint16_t src_port;
 	uint16_t dst_port_mask;
+	uint16_t dst_port;
 };
 
 /**
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 08/17] net/nfp: fix flow rule action data problem
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (6 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 07/17] net/nfp: fix flow rule match data problem Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 09/17] net/nfp: enlarge the flow rules limitation Chaoyong He
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, chaoyong.he, stable, Peng Zhang

From: Long Wu <long.wu@corigine.com>

The data type of 'mark_id' field in 'struct nfp_net_cmsg_action'
should be 'uint32_t' rather than 'uint16_t'.

Fixes: 0b9079d24808 ("net/nfp: support flow API for CoreNIC firmware")
Cc: chaoyong.he@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/nfp_net_cmsg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/nfp/nfp_net_cmsg.h b/drivers/net/nfp/nfp_net_cmsg.h
index b3d9bc33cf..ccb607f443 100644
--- a/drivers/net/nfp/nfp_net_cmsg.h
+++ b/drivers/net/nfp/nfp_net_cmsg.h
@@ -144,7 +144,7 @@ struct nfp_net_cmsg_action {
 	uint16_t action;
 	uint8_t queue;
 	uint8_t spare;
-	uint16_t mark_id;
+	uint32_t mark_id;
 };
 
 enum nfp_net_cfg_mbox_cmd {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 09/17] net/nfp: enlarge the flow rules limitation
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (7 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 08/17] net/nfp: fix flow rule action " Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 10/17] net/nfp: enlarge flow hash table size Chaoyong He
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

The firmware rules limitation is enlarged to
2056(8 Eth + 1024 IPv4 + 1024 IPv6 rules).
So enlarge the flow rules limitation and add
more precise checks to flow count.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/nfp_net_common.h | 16 +++++-
 drivers/net/nfp/nfp_net_flow.c   | 87 +++++++++++++++++++++++++++++---
 2 files changed, 94 insertions(+), 9 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 8e3e219261..6db849eb07 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -165,12 +165,24 @@ struct nfp_pf_dev {
 	bool speed_updated;
 };
 
-#define NFP_NET_FLOW_LIMIT    1024
+#define NFP_NET_ETH_FLOW_LIMIT    8
+#define NFP_NET_IPV4_FLOW_LIMIT   1024
+#define NFP_NET_IPV6_FLOW_LIMIT   1024
+
+#define NFP_NET_FLOW_LIMIT    ((NFP_NET_ETH_FLOW_LIMIT) +   \
+				(NFP_NET_IPV4_FLOW_LIMIT) + \
+				(NFP_NET_IPV6_FLOW_LIMIT))
+
+struct nfp_net_flow_count {
+	uint16_t eth_count;
+	uint16_t ipv4_count;
+	uint16_t ipv6_count;
+};
 
 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. */
-	uint16_t flow_count; /**< Flow count in hash table */
+	struct nfp_net_flow_count flow_count; /**< Flow count in hash table */
 	bool flow_position[NFP_NET_FLOW_LIMIT]; /**< Flow position array */
 };
 
diff --git a/drivers/net/nfp/nfp_net_flow.c b/drivers/net/nfp/nfp_net_flow.c
index b0d1a57d99..74dd67abd4 100644
--- a/drivers/net/nfp/nfp_net_flow.c
+++ b/drivers/net/nfp/nfp_net_flow.c
@@ -178,7 +178,8 @@ nfp_net_flow_free(struct nfp_net_priv *priv,
 
 static int
 nfp_net_flow_calculate_items(const struct rte_flow_item items[],
-		uint32_t *match_len)
+		uint32_t *match_len,
+		uint32_t *item_type)
 {
 	int ret = -EINVAL;
 	const struct rte_flow_item *item;
@@ -188,15 +189,18 @@ nfp_net_flow_calculate_items(const struct rte_flow_item items[],
 		case RTE_FLOW_ITEM_TYPE_ETH:
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_ETH detected");
 			*match_len = sizeof(struct nfp_net_cmsg_match_eth);
+			*item_type = RTE_FLOW_ITEM_TYPE_ETH;
 			ret = 0;
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV4:
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV4 detected");
 			*match_len = sizeof(struct nfp_net_cmsg_match_v4);
+			*item_type = RTE_FLOW_ITEM_TYPE_IPV4;
 			return 0;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV6 detected");
 			*match_len = sizeof(struct nfp_net_cmsg_match_v6);
+			*item_type = RTE_FLOW_ITEM_TYPE_IPV6;
 			return 0;
 		default:
 			PMD_DRV_LOG(ERR, "Can't calculate match length");
@@ -643,6 +647,66 @@ nfp_net_flow_process_priority(struct rte_flow *nfp_flow,
 	}
 }
 
+static int
+nfp_net_flow_check_count(struct nfp_net_flow_count *flow_count,
+		uint32_t item_type)
+{
+	int ret = 0;
+
+	switch (item_type) {
+	case RTE_FLOW_ITEM_TYPE_ETH:
+		if (flow_count->eth_count >= NFP_NET_ETH_FLOW_LIMIT)
+			ret = -ENOSPC;
+		break;
+	case RTE_FLOW_ITEM_TYPE_IPV4:
+		if (flow_count->ipv4_count >= NFP_NET_IPV4_FLOW_LIMIT)
+			ret = -ENOSPC;
+		break;
+	case RTE_FLOW_ITEM_TYPE_IPV6:
+		if (flow_count->ipv6_count >= NFP_NET_IPV6_FLOW_LIMIT)
+			ret = -ENOSPC;
+		break;
+	default:
+		ret = -ENOTSUP;
+		break;
+	}
+
+	return ret;
+}
+
+static int
+nfp_net_flow_calculate_count(struct rte_flow *nfp_flow,
+		struct nfp_net_flow_count *flow_count,
+		bool delete_flag)
+{
+	uint16_t *count;
+
+	switch (nfp_flow->payload.cmsg_type) {
+	case NFP_NET_CFG_MBOX_CMD_FS_ADD_V4:
+	case NFP_NET_CFG_MBOX_CMD_FS_DEL_V4:
+		count = &flow_count->ipv4_count;
+		break;
+	case NFP_NET_CFG_MBOX_CMD_FS_ADD_V6:
+	case NFP_NET_CFG_MBOX_CMD_FS_DEL_V6:
+		count = &flow_count->ipv6_count;
+		break;
+	case NFP_NET_CFG_MBOX_CMD_FS_ADD_ETHTYPE:
+	case NFP_NET_CFG_MBOX_CMD_FS_DEL_ETHTYPE:
+		count = &flow_count->eth_count;
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Flow count calculate failed.");
+		return -EINVAL;
+	}
+
+	if (delete_flag)
+		(*count)--;
+	else
+		(*count)++;
+
+	return 0;
+}
+
 static struct rte_flow *
 nfp_net_flow_setup(struct rte_eth_dev *dev,
 		const struct rte_flow_attr *attr,
@@ -652,6 +716,7 @@ nfp_net_flow_setup(struct rte_eth_dev *dev,
 	int ret;
 	char *hash_data;
 	uint32_t port_id;
+	uint32_t item_type;
 	uint32_t action_len;
 	struct nfp_net_hw *hw;
 	uint32_t match_len = 0;
@@ -666,12 +731,18 @@ nfp_net_flow_setup(struct rte_eth_dev *dev,
 	app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(hw_priv->pf_dev->app_fw_priv);
 	priv = app_fw_nic->ports[hw->idx]->priv;
 
-	ret = nfp_net_flow_calculate_items(items, &match_len);
+	ret = nfp_net_flow_calculate_items(items, &match_len, &item_type);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Key layers calculate failed.");
 		return NULL;
 	}
 
+	ret = nfp_net_flow_check_count(&priv->flow_count, item_type);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Flow count check failed.");
+		return NULL;
+	}
+
 	action_len = sizeof(struct nfp_net_cmsg_action);
 	port_id = ((struct nfp_net_hw *)dev->data->dev_private)->nfp_idx;
 
@@ -705,7 +776,11 @@ nfp_net_flow_setup(struct rte_eth_dev *dev,
 		goto free_flow;
 	}
 
-	priv->flow_count++;
+	ret = nfp_net_flow_calculate_count(nfp_flow, &priv->flow_count, false);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "NFP flow calculate count failed.");
+		goto free_flow;
+	}
 
 	nfp_net_flow_process_priority(nfp_flow, match_len);
 
@@ -719,11 +794,9 @@ nfp_net_flow_setup(struct rte_eth_dev *dev,
 
 static int
 nfp_net_flow_teardown(struct nfp_net_priv *priv,
-		__rte_unused struct rte_flow *nfp_flow)
+		struct rte_flow *nfp_flow)
 {
-	priv->flow_count--;
-
-	return 0;
+	return nfp_net_flow_calculate_count(nfp_flow, &priv->flow_count, true);
 }
 
 static int
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 10/17] net/nfp: enlarge flow hash table size
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (8 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 09/17] net/nfp: enlarge the flow rules limitation Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 11/17] net/nfp: fix flow position index problem Chaoyong He
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

The flow rules limitation is 2056 and driver needs
to store it in hash table. Considering hash conflicts,
driver use a new macro to enlarge hash table size.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/nfp_net_common.h | 3 +++
 drivers/net/nfp/nfp_net_flow.c   | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 6db849eb07..6c739891be 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -179,6 +179,9 @@ struct nfp_net_flow_count {
 	uint16_t ipv6_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. */
diff --git a/drivers/net/nfp/nfp_net_flow.c b/drivers/net/nfp/nfp_net_flow.c
index 74dd67abd4..2dab317a5f 100644
--- a/drivers/net/nfp/nfp_net_flow.c
+++ b/drivers/net/nfp/nfp_net_flow.c
@@ -1063,7 +1063,7 @@ 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_LIMIT,
+		.entries    = NFP_NET_FLOW_HASH_TBALE_SIZE,
 		.hash_func  = rte_jhash,
 		.socket_id  = rte_socket_id(),
 		.key_len    = sizeof(uint32_t),
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 11/17] net/nfp: fix flow position index problem
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (9 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 10/17] net/nfp: enlarge flow hash table size Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 12/17] net/nfp: fix getting firmware version Chaoyong He
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, chaoyong.he, stable, Peng Zhang

From: Long Wu <long.wu@corigine.com>

The flow position acquire and free interfaces use different index,
and this will cause the flow free logic failed.

Fix this problem by using the same flow position index.

Fixes: 0b9079d24808 ("net/nfp: support flow API for CoreNIC firmware")
Cc: chaoyong.he@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/nfp_net_flow.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/nfp/nfp_net_flow.c b/drivers/net/nfp/nfp_net_flow.c
index 2dab317a5f..2c7801ed41 100644
--- a/drivers/net/nfp/nfp_net_flow.c
+++ b/drivers/net/nfp/nfp_net_flow.c
@@ -123,7 +123,11 @@ static void
 nfp_net_flow_position_free(struct nfp_net_priv *priv,
 		struct rte_flow *nfp_flow)
 {
-	priv->flow_position[nfp_flow->position] = false;
+	uint32_t index;
+
+	index = NFP_NET_FLOW_LIMIT - 1 - nfp_flow->position;
+
+	priv->flow_position[index] = false;
 }
 
 static struct rte_flow *
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 12/17] net/nfp: fix getting firmware version
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (10 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 11/17] net/nfp: fix flow position index problem Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 13/17] doc: update the metadata description section Chaoyong He
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Zerun Fu, stable, Chaoyong He, Long Wu, Peng Zhang

From: Zerun Fu <zerun.fu@corigine.com>

The original logic try to get the NSP resource every time the application
call 'rte_eth_dev_fw_version_get()' interface, there are chances the NSP
resource busy and fail to get it. And because the local string variables
not initialized, there will be out of range problem when it fail to get
the NSP resource.

Fix this by initializing the local string variables and storing the
firmware version string once we get it.

Fixes: 128c8ad951bf ("net/nfp: support getting firmware version")
Cc: stable@dpdk.org

Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
Reviewed-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_net_common.c | 26 ++++++++++++++++++--------
 drivers/net/nfp/nfp_net_common.h |  6 ++++++
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index a6573ed45c..84893e2d73 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -193,9 +193,6 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 			nfp_net_link_speed_rte2nfp(link->link_speed));
 }
 
-/* The length of firmware version string */
-#define FW_VER_LEN        32
-
 /**
  * Reconfigure the firmware of VF configure
  *
@@ -2274,11 +2271,11 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
 		size_t fw_size)
 {
 	struct nfp_net_hw *hw;
-	char mip_name[FW_VER_LEN];
-	char app_name[FW_VER_LEN];
-	char nsp_version[FW_VER_LEN];
-	char vnic_version[FW_VER_LEN];
 	struct nfp_net_hw_priv *hw_priv;
+	char app_name[FW_VER_LEN] = {0};
+	char mip_name[FW_VER_LEN] = {0};
+	char nsp_version[FW_VER_LEN] = {0};
+	char vnic_version[FW_VER_LEN] = {0};
 
 	if (fw_size < FW_VER_LEN)
 		return FW_VER_LEN;
@@ -2286,6 +2283,11 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
 	hw = nfp_net_get_hw(dev);
 	hw_priv = dev->process_private;
 
+	if (hw->fw_version[0] != 0) {
+		snprintf(fw_version, FW_VER_LEN, "%s", hw->fw_version);
+		return 0;
+	}
+
 	if (!rte_eth_dev_is_repr(dev)) {
 		snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d",
 			hw->ver.extend, hw->ver.class,
@@ -2298,8 +2300,16 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
 	nfp_net_get_mip_name(hw_priv, mip_name);
 	nfp_net_get_app_name(hw_priv, app_name);
 
-	snprintf(fw_version, FW_VER_LEN, "%s %s %s %s",
+	if (nsp_version[0] == 0 || mip_name[0] == 0) {
+		snprintf(fw_version, FW_VER_LEN, "%s %s %s %s",
 			vnic_version, nsp_version, mip_name, app_name);
+		return 0;
+	}
+
+	snprintf(hw->fw_version, FW_VER_LEN, "%s %s %s %s",
+			vnic_version, nsp_version, mip_name, app_name);
+
+	snprintf(fw_version, FW_VER_LEN, "%s", hw->fw_version);
 
 	return 0;
 }
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 6c739891be..3c4d305b01 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -50,6 +50,9 @@
 				RTE_ETH_RSS_NONFRAG_IPV6_UDP  | \
 				RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
 
+/* The length of firmware version string */
+#define FW_VER_LEN        32
+
 /*
  * Each PF has corresponding word to beat:
  * Offset | Usage
@@ -255,6 +258,9 @@ struct nfp_net_hw {
 
 	/** Used for rte_flow of CoreNIC firmware */
 	struct nfp_net_priv *priv;
+
+	/** Used for firmware version */
+	char fw_version[FW_VER_LEN];
 };
 
 static inline uint32_t
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 13/17] doc: update the metadata description section
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (11 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 12/17] net/nfp: fix getting firmware version Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 14/17] net/nfp: remove the unneeded logic Chaoyong He
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Peng Zhang, stable, Chaoyong He, Long Wu

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

The description about the metadata of Tx direction
when using the firmware with NFDk is not correct.
Because of the exist of 8-bits metadata length, the
32-bits field type header contains only 6 4-bits
datatype specifiers rather than 8.

Fixes: c4b058784e75 ("net/nfp: modify parse metadata logic")
Cc: stable@dpdk.org

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>
---
 doc/guides/nics/nfp.rst | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/doc/guides/nics/nfp.rst b/doc/guides/nics/nfp.rst
index ed9548de0b..d2c7afc8cb 100644
--- a/doc/guides/nics/nfp.rst
+++ b/doc/guides/nics/nfp.rst
@@ -329,10 +329,6 @@ be wrote N times in the heads. It is the same with NFD3.
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                        Data for field 5                       |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-   |                        Data for field 6                       |
-   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-   |                        Data for field 7                       |
-   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                          Packet Data                          |
    |                              ...                              |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 14/17] net/nfp: remove the unneeded logic
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (12 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 13/17] doc: update the metadata description section Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 15/17] net/nfp: adapts the reverse sequence card Chaoyong He
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Peng Zhang, stable, Chaoyong He, Long Wu

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

The logic in NFDk datapatch can make sure there only one layer VLAN,
so remove the unneeded logic here and make it clean and easy to
understand.

Fixes: 7c82b8626af8 ("net/nfp: support VLAN insert with NFDk")
Cc: stable@dpdk.org

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index e6847ccb33..2cea5688b3 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -141,7 +141,6 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
 	uint32_t meta_type;
 	struct nfp_net_hw *hw;
 	uint32_t header_offset;
-	uint8_t vlan_layer = 0;
 	uint8_t ipsec_layer = 0;
 	struct nfp_net_meta_raw meta_data;
 
@@ -184,12 +183,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
 			meta += NFP_NET_META_FIELD_SIZE) {
 		switch (meta_type & NFP_NET_META_FIELD_MASK) {
 		case NFP_NET_META_VLAN:
-			if (vlan_layer > 0) {
-				PMD_DRV_LOG(ERR, "At most 1 layers of vlan is supported");
-				return -EINVAL;
-			}
 			nfp_net_meta_set_vlan(&meta_data, pkt, layer);
-			vlan_layer++;
 			break;
 		case NFP_NET_META_IPSEC:
 			if (ipsec_layer > 2) {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 15/17] net/nfp: adapts the reverse sequence card
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (13 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 14/17] net/nfp: remove the unneeded logic Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 16/17] net/nfp: fix null pointer dereferences Chaoyong He
  2024-06-24  1:57 ` [PATCH 17/17] net/nfp: fix port action core dump Chaoyong He
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Peng Zhang, chaoyong.he, stable

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

The NFP chip-wide port index is 'eth_port->index'.
In the normal card, it uses 'eth_port->eth_index', but because
'eth_port->eth_index' and 'eth_port->index' have the same value,
it doesn't have any problem.
But in the reverse sequence card, the value is different,
so it will lead the 'nfp_eth_config_start()' failed.

In this commit, fix this bug by using 'eth_port->index'.

Fixes: e1124c4f8a45 ("net/nfp: add flower representor framework")
Cc: chaoyong.he@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_representor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 086dbc58e3..b1589cf78c 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -845,7 +845,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
 		eth_port = &nfp_eth_table->ports[id];
 		flower_repr.repr_type = NFP_REPR_TYPE_PHYS_PORT;
 		flower_repr.port_id = nfp_flower_get_phys_port_id(eth_port->index);
-		flower_repr.nfp_idx = eth_port->eth_index;
+		flower_repr.nfp_idx = eth_port->index;
 		flower_repr.vf_id = i + 1;
 
 		/* Copy the real mac of the interface to the representor struct */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 16/17] net/nfp: fix null pointer dereferences
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (14 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 15/17] net/nfp: adapts the reverse sequence card Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  2024-06-24  1:57 ` [PATCH 17/17] net/nfp: fix port action core dump Chaoyong He
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, stable, Long Wu, Peng Zhang

CI found null pointer dereferences problem.

Coverity issue: 426271
Fixes: 153ef2e49ed7 ("net/nfp: add process private structure")
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_net_common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 84893e2d73..aed40daa67 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -1265,6 +1265,8 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	hw = nfp_net_get_hw(dev);
 	hw_priv = dev->process_private;
+	if (hw_priv == NULL)
+		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);
@@ -1367,7 +1369,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 != NULL && hw_priv->pf_dev != NULL)
+	if (hw_priv->pf_dev != NULL)
 		dev_info->speed_capa = hw_priv->pf_dev->speed_capa;
 
 	return 0;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 17/17] net/nfp: fix port action core dump
  2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
                   ` (15 preceding siblings ...)
  2024-06-24  1:57 ` [PATCH 16/17] net/nfp: fix null pointer dereferences Chaoyong He
@ 2024-06-24  1:57 ` Chaoyong He
  16 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2024-06-24  1:57 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, chaoyong.he, stable

From: Long Wu <long.wu@corigine.com>

The app will be destroyed if add a port flow action which its
destination port id is invalid.

Add a check to avoid the problem.

Cc: chaoyong.he@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Long Wu <long.wu@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_flow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index d127171fdb..24e7047407 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -931,7 +931,7 @@ nfp_flow_item_check_port(struct nfp_item_calculate_param *param)
 	const struct rte_flow_item_port_id *port_id;
 
 	port_id = param->item->spec;
-	if (port_id == NULL || port_id->id >= RTE_MAX_ETHPORTS)
+	if (port_id == NULL || rte_eth_dev_is_valid_port(port_id->id) == 0)
 		return -ERANGE;
 
 	return 0;
@@ -1256,7 +1256,7 @@ nfp_flow_action_check_port(struct nfp_action_calculate_param *param)
 		port_id = action_port_id->id;
 	}
 
-	if (port_id >= RTE_MAX_ETHPORTS)
+	if (rte_eth_dev_is_valid_port(port_id) == 0)
 		return -ERANGE;
 
 	return 0;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-06-24  2:00 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-24  1:57 [PATCH 00/17] NFP bugfix Chaoyong He
2024-06-24  1:57 ` [PATCH 01/17] net/nfp: refactor speed configuration logic Chaoyong He
2024-06-24  1:57 ` [PATCH 02/17] net/nfp: refactor device speed update logic Chaoyong He
2024-06-24  1:57 ` [PATCH 03/17] net/nfp: fix link status display problem Chaoyong He
2024-06-24  1:57 ` [PATCH 04/17] net/nfp: fix coredump caused by firmware abnormal cleanup Chaoyong He
2024-06-24  1:57 ` [PATCH 05/17] net/nfp: forbid offload flow rules with empty action list Chaoyong He
2024-06-24  1:57 ` [PATCH 06/17] net/nfp: remove redundancy function call Chaoyong He
2024-06-24  1:57 ` [PATCH 07/17] net/nfp: fix flow rule match data problem Chaoyong He
2024-06-24  1:57 ` [PATCH 08/17] net/nfp: fix flow rule action " Chaoyong He
2024-06-24  1:57 ` [PATCH 09/17] net/nfp: enlarge the flow rules limitation Chaoyong He
2024-06-24  1:57 ` [PATCH 10/17] net/nfp: enlarge flow hash table size Chaoyong He
2024-06-24  1:57 ` [PATCH 11/17] net/nfp: fix flow position index problem Chaoyong He
2024-06-24  1:57 ` [PATCH 12/17] net/nfp: fix getting firmware version Chaoyong He
2024-06-24  1:57 ` [PATCH 13/17] doc: update the metadata description section Chaoyong He
2024-06-24  1:57 ` [PATCH 14/17] net/nfp: remove the unneeded logic Chaoyong He
2024-06-24  1:57 ` [PATCH 15/17] net/nfp: adapts the reverse sequence card Chaoyong He
2024-06-24  1:57 ` [PATCH 16/17] net/nfp: fix null pointer dereferences Chaoyong He
2024-06-24  1:57 ` [PATCH 17/17] net/nfp: fix port action core dump Chaoyong He

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