DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/8] fix the representor port link status and speed
@ 2024-09-05  6:25 Chaoyong He
  2024-09-05  6:25 ` [PATCH 1/8] net/nfp: fix incorrect type declaration of some variables Chaoyong He
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Chaoyong He @ 2024-09-05  6:25 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He

This patch series aims to fix some problems in the representor port link
status and speed update logic, also do some refactors to the related
logics.

Qin Ke (8):
  net/nfp: fix incorrect type declaration of some variables
  net/nfp: add help function to check link speed
  net/nfp: add help function to update VF link speed
  net/nfp: rename PF speed update function
  net/nfp: add new data field into representor port structure
  net/nfp: fix representor port link speed update problem
  net/nfp: standardize the use of port index in some functions
  net/nfp: fix representor port link status update problem

 .../net/nfp/flower/nfp_flower_representor.c   |  11 +-
 .../net/nfp/flower/nfp_flower_representor.h   |   2 +
 drivers/net/nfp/nfp_ethdev.c                  |   6 +-
 drivers/net/nfp/nfp_net_common.c              | 124 +++++++++++-------
 drivers/net/nfp/nfp_net_common.h              |   2 +-
 5 files changed, 90 insertions(+), 55 deletions(-)

-- 
2.39.1


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

* [PATCH 1/8] net/nfp: fix incorrect type declaration of some variables
  2024-09-05  6:25 [PATCH 0/8] fix the representor port link status and speed Chaoyong He
@ 2024-09-05  6:25 ` Chaoyong He
  2024-09-05  6:25 ` [PATCH 2/8] net/nfp: add help function to check link speed Chaoyong He
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2024-09-05  6:25 UTC (permalink / raw)
  To: dev
  Cc: oss-drivers, Qin Ke, james.hershaw, stable, Chaoyong He, Long Wu,
	Peng Zhang

From: Qin Ke <qin.ke@corigine.com>

The type declaration of variable 'speed' and 'i' in
'nfp_net_link_speed_rte2nfp()' is not correct, fix it.

Fixes: 36a9abd4b679 ("net/nfp: write link speed to control BAR")
Cc: james.hershaw@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Qin Ke <qin.ke@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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 5f92c2c31d..be0b6dc0cf 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -157,10 +157,10 @@ static const uint32_t nfp_net_link_speed_nfp2rte[] = {
 	[NFP_NET_CFG_STS_LINK_RATE_100G]        = RTE_ETH_SPEED_NUM_100G,
 };
 
-static uint16_t
-nfp_net_link_speed_rte2nfp(uint16_t speed)
+static size_t
+nfp_net_link_speed_rte2nfp(uint32_t speed)
 {
-	uint16_t i;
+	size_t i;
 
 	for (i = 0; i < RTE_DIM(nfp_net_link_speed_nfp2rte); i++) {
 		if (speed == nfp_net_link_speed_nfp2rte[i])
-- 
2.39.1


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

* [PATCH 2/8] net/nfp: add help function to check link speed
  2024-09-05  6:25 [PATCH 0/8] fix the representor port link status and speed Chaoyong He
  2024-09-05  6:25 ` [PATCH 1/8] net/nfp: fix incorrect type declaration of some variables Chaoyong He
@ 2024-09-05  6:25 ` Chaoyong He
  2024-09-05  6:25 ` [PATCH 3/8] net/nfp: add help function to update VF " Chaoyong He
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2024-09-05  6:25 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Qin Ke, Chaoyong He, Long Wu, Peng Zhang

From: Qin Ke <qin.ke@corigine.com>

Add help function to check link speed.

Signed-off-by: Qin Ke <qin.ke@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 | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index be0b6dc0cf..25872a4131 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -170,6 +170,19 @@ nfp_net_link_speed_rte2nfp(uint32_t speed)
 	return NFP_NET_CFG_STS_LINK_RATE_UNKNOWN;
 }
 
+static uint32_t
+nfp_net_link_speed_nfp2rte_check(uint32_t speed)
+{
+	size_t i;
+
+	for (i = 0; i < RTE_DIM(nfp_net_link_speed_nfp2rte); i++) {
+		if (speed == nfp_net_link_speed_nfp2rte[i])
+			return nfp_net_link_speed_nfp2rte[i];
+	}
+
+	return RTE_ETH_SPEED_NUM_NONE;
+}
+
 static void
 nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 		struct rte_eth_link *link)
@@ -734,8 +747,6 @@ nfp_net_speed_aneg_update(struct rte_eth_dev *dev,
 		struct nfp_net_hw_priv *hw_priv,
 		struct rte_eth_link *link)
 {
-	uint32_t i;
-	uint32_t speed;
 	enum nfp_eth_aneg aneg;
 	struct nfp_pf_dev *pf_dev;
 	struct nfp_eth_table *nfp_eth_table;
@@ -758,14 +769,8 @@ nfp_net_speed_aneg_update(struct rte_eth_dev *dev,
 
 	nfp_eth_table = pf_dev->nfp_eth_table;
 	eth_port = &nfp_eth_table->ports[hw->idx];
-	speed = eth_port->speed;
 
-	for (i = 0; i < RTE_DIM(nfp_net_link_speed_nfp2rte); i++) {
-		if (nfp_net_link_speed_nfp2rte[i] == speed) {
-			link->link_speed = speed;
-			break;
-		}
-	}
+	link->link_speed = nfp_net_link_speed_nfp2rte_check(eth_port->speed);
 
 	if (dev->data->dev_conf.link_speeds == RTE_ETH_LINK_SPEED_AUTONEG &&
 			eth_port->supp_aneg)
-- 
2.39.1


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

* [PATCH 3/8] net/nfp: add help function to update VF link speed
  2024-09-05  6:25 [PATCH 0/8] fix the representor port link status and speed Chaoyong He
  2024-09-05  6:25 ` [PATCH 1/8] net/nfp: fix incorrect type declaration of some variables Chaoyong He
  2024-09-05  6:25 ` [PATCH 2/8] net/nfp: add help function to check link speed Chaoyong He
@ 2024-09-05  6:25 ` Chaoyong He
  2024-09-05  6:25 ` [PATCH 4/8] net/nfp: rename PF speed update function Chaoyong He
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2024-09-05  6:25 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Qin Ke, Chaoyong He, Long Wu, Peng Zhang

From: Qin Ke <qin.ke@corigine.com>

Add help function to encapsulate logic of updating vf link speed.

Signed-off-by: Qin Ke <qin.ke@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 | 33 ++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 25872a4131..c918469047 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -777,6 +777,24 @@ nfp_net_speed_aneg_update(struct rte_eth_dev *dev,
 		link->link_autoneg = RTE_ETH_LINK_AUTONEG;
 }
 
+static void
+nfp_net_vf_speed_update(struct rte_eth_link *link,
+		uint32_t link_status)
+{
+	size_t link_rate_index;
+
+	/*
+	 * Shift and mask link_status so that it is effectively the value
+	 * at offset NFP_NET_CFG_STS_NSP_LINK_RATE.
+	 */
+	link_rate_index = (link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) &
+			NFP_NET_CFG_STS_LINK_RATE_MASK;
+	if (link_rate_index < RTE_DIM(nfp_net_link_speed_nfp2rte))
+		link->link_speed = nfp_net_link_speed_nfp2rte[link_rate_index];
+	else
+		link->link_speed = RTE_ETH_SPEED_NUM_NONE;
+}
+
 int
 nfp_net_link_update_common(struct rte_eth_dev *dev,
 		struct nfp_net_hw *hw,
@@ -784,23 +802,14 @@ nfp_net_link_update_common(struct rte_eth_dev *dev,
 		uint32_t link_status)
 {
 	int ret;
-	uint32_t nn_link_status;
 	struct nfp_net_hw_priv *hw_priv;
 
 	hw_priv = dev->process_private;
 	if (link->link_status == RTE_ETH_LINK_UP) {
-		if (hw_priv->is_pf) {
+		if (hw_priv->is_pf)
 			nfp_net_speed_aneg_update(dev, hw, hw_priv, link);
-		} else {
-			/*
-			 * Shift and mask nn_link_status so that it is effectively the value
-			 * at offset NFP_NET_CFG_STS_NSP_LINK_RATE.
-			 */
-			nn_link_status = (link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) &
-					NFP_NET_CFG_STS_LINK_RATE_MASK;
-			if (nn_link_status < RTE_DIM(nfp_net_link_speed_nfp2rte))
-				link->link_speed = nfp_net_link_speed_nfp2rte[nn_link_status];
-		}
+		else
+			nfp_net_vf_speed_update(link, link_status);
 	}
 
 	ret = rte_eth_linkstatus_set(dev, link);
-- 
2.39.1


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

* [PATCH 4/8] net/nfp: rename PF speed update function
  2024-09-05  6:25 [PATCH 0/8] fix the representor port link status and speed Chaoyong He
                   ` (2 preceding siblings ...)
  2024-09-05  6:25 ` [PATCH 3/8] net/nfp: add help function to update VF " Chaoyong He
@ 2024-09-05  6:25 ` Chaoyong He
  2024-09-05  6:25 ` [PATCH 5/8] net/nfp: add new data field into representor port structure Chaoyong He
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2024-09-05  6:25 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Qin Ke, Chaoyong He, Long Wu, Peng Zhang

From: Qin Ke <qin.ke@corigine.com>

Rename PF speed update function of 'nfp_net_speed_aneg_update()'
to 'nfp_net_pf_speed_update()', which make codes more readable.

Also use maroc to replace the hard coded value.

Signed-off-by: Qin Ke <qin.ke@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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index c918469047..6761a16ef2 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -742,7 +742,7 @@ nfp_net_allmulticast_disable(struct rte_eth_dev *dev)
 }
 
 static void
-nfp_net_speed_aneg_update(struct rte_eth_dev *dev,
+nfp_net_pf_speed_update(struct rte_eth_dev *dev,
 		struct nfp_net_hw *hw,
 		struct nfp_net_hw_priv *hw_priv,
 		struct rte_eth_link *link)
@@ -807,14 +807,14 @@ 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->is_pf)
-			nfp_net_speed_aneg_update(dev, hw, hw_priv, link);
+			nfp_net_pf_speed_update(dev, hw, hw_priv, link);
 		else
 			nfp_net_vf_speed_update(link, link_status);
 	}
 
 	ret = rte_eth_linkstatus_set(dev, link);
 	if (ret == 0) {
-		if (link->link_status != 0)
+		if (link->link_status == RTE_ETH_LINK_UP)
 			PMD_DRV_LOG(INFO, "NIC Link is Up");
 		else
 			PMD_DRV_LOG(INFO, "NIC Link is Down");
-- 
2.39.1


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

* [PATCH 5/8] net/nfp: add new data field into representor port structure
  2024-09-05  6:25 [PATCH 0/8] fix the representor port link status and speed Chaoyong He
                   ` (3 preceding siblings ...)
  2024-09-05  6:25 ` [PATCH 4/8] net/nfp: rename PF speed update function Chaoyong He
@ 2024-09-05  6:25 ` Chaoyong He
  2024-09-05  6:25 ` [PATCH 6/8] net/nfp: fix representor port link speed update problem Chaoyong He
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2024-09-05  6:25 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Qin Ke, Chaoyong He, Long Wu, Peng Zhang

From: Qin Ke <qin.ke@corigine.com>

Add a new data field 'idx' into 'nfp_flower_representor' structure
to indicate the sequential physical port number of representor
devices, also initialize it for all representor ports.

Signed-off-by: Qin Ke <qin.ke@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/flower/nfp_flower_representor.c | 4 ++++
 drivers/net/nfp/flower/nfp_flower_representor.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 872b8a6db4..e7593313e2 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -649,6 +649,7 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev,
 	}
 
 	/* Copy data here from the input representor template */
+	repr->idx              = init_repr_data->idx;
 	repr->vf_id            = init_repr_data->vf_id;
 	repr->switch_domain_id = init_repr_data->switch_domain_id;
 	repr->port_id          = init_repr_data->port_id;
@@ -822,6 +823,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
 
 	/* Create a rte_eth_dev for PF vNIC representor */
 	flower_repr.repr_type = NFP_REPR_TYPE_PF;
+	flower_repr.idx = 0;
 
 	/* PF vNIC reprs get a random MAC address */
 	rte_eth_random_addr(flower_repr.mac_addr.addr_bytes);
@@ -854,6 +856,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
 		flower_repr.port_id = nfp_flower_get_phys_port_id(eth_port->index);
 		flower_repr.nfp_idx = eth_port->index;
 		flower_repr.vf_id = i + 1;
+		flower_repr.idx = id;
 
 		/* Copy the real mac of the interface to the representor struct */
 		rte_ether_addr_copy(&eth_port->mac_addr, &flower_repr.mac_addr);
@@ -887,6 +890,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
 				NFP_FLOWER_CMSG_PORT_VNIC_TYPE_VF, i + pf_dev->vf_base_id, 0);
 		flower_repr.nfp_idx = 0;
 		flower_repr.vf_id = i;
+		flower_repr.idx = 0;
 
 		/* VF reprs get a random MAC address */
 		rte_eth_random_addr(flower_repr.mac_addr.addr_bytes);
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.h b/drivers/net/nfp/flower/nfp_flower_representor.h
index 70ca7b97db..4211ddf798 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.h
+++ b/drivers/net/nfp/flower/nfp_flower_representor.h
@@ -23,6 +23,8 @@ struct nfp_flower_representor {
 
 	struct rte_eth_xstat *repr_xstats_base;
 	uint8_t *mac_stats;
+	/** Sequential physical port number, only valid for repr of physical port */
+	uint8_t idx;
 };
 
 int nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower,
-- 
2.39.1


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

* [PATCH 6/8] net/nfp: fix representor port link speed update problem
  2024-09-05  6:25 [PATCH 0/8] fix the representor port link status and speed Chaoyong He
                   ` (4 preceding siblings ...)
  2024-09-05  6:25 ` [PATCH 5/8] net/nfp: add new data field into representor port structure Chaoyong He
@ 2024-09-05  6:25 ` Chaoyong He
  2024-09-05  6:25 ` [PATCH 7/8] net/nfp: standardize the use of port index in some functions Chaoyong He
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2024-09-05  6:25 UTC (permalink / raw)
  To: dev
  Cc: oss-drivers, Qin Ke, zerun.fu, stable, Chaoyong He, Long Wu, Peng Zhang

From: Qin Ke <qin.ke@corigine.com>

For representor port link speed, the original logic finally calls
'nfp_net_speed_aneg_update()' to update it. But the reference of
'hw->idx' in this function is invalid for representor port devices,
the logic has problem.

Fix it by getting correct 'idx' for all type of deives including
representor port and make reference to it.

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

Signed-off-by: Qin Ke <qin.ke@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>
---
 .../net/nfp/flower/nfp_flower_representor.c   |  2 +-
 drivers/net/nfp/nfp_net_common.c              | 32 +++++++++++++++----
 drivers/net/nfp/nfp_net_common.h              |  2 +-
 3 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index e7593313e2..054ea1a938 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -40,7 +40,7 @@ nfp_flower_repr_link_update(struct rte_eth_dev *dev,
 	pf_hw = repr->app_fw_flower->pf_hw;
 	nn_link_status = nn_cfg_readw(&pf_hw->super, NFP_NET_CFG_STS);
 
-	ret = nfp_net_link_update_common(dev, pf_hw, link, nn_link_status);
+	ret = nfp_net_link_update_common(dev, link, nn_link_status);
 
 	return ret;
 }
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 6761a16ef2..daed57e374 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -311,6 +311,24 @@ nfp_net_get_hw(const struct rte_eth_dev *dev)
 	return hw;
 }
 
+uint8_t
+nfp_net_get_idx(const struct rte_eth_dev *dev)
+{
+	uint8_t idx;
+
+	if (rte_eth_dev_is_repr(dev)) {
+		struct nfp_flower_representor *repr;
+		repr = dev->data->dev_private;
+		idx = repr->idx;
+	} else {
+		struct nfp_net_hw *hw;
+		hw = dev->data->dev_private;
+		idx = hw->idx;
+	}
+
+	return idx;
+}
+
 /*
  * Configure an Ethernet device.
  *
@@ -743,17 +761,18 @@ nfp_net_allmulticast_disable(struct rte_eth_dev *dev)
 
 static void
 nfp_net_pf_speed_update(struct rte_eth_dev *dev,
-		struct nfp_net_hw *hw,
 		struct nfp_net_hw_priv *hw_priv,
 		struct rte_eth_link *link)
 {
+	uint8_t idx;
 	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;
+	idx = nfp_net_get_idx(dev);
+	aneg = pf_dev->nfp_eth_table->ports[idx].aneg;
 
 	/* Compare whether the current status has changed. */
 	if (pf_dev->speed_updated || aneg == NFP_ANEG_AUTO) {
@@ -761,14 +780,14 @@ nfp_net_pf_speed_update(struct rte_eth_dev *dev,
 		if (nfp_eth_table == NULL) {
 			PMD_DRV_LOG(WARNING, "Failed to update port speed.");
 		} else {
-			pf_dev->nfp_eth_table->ports[hw->idx] = nfp_eth_table->ports[hw->idx];
+			pf_dev->nfp_eth_table->ports[idx] = nfp_eth_table->ports[idx];
 			free(nfp_eth_table);
 			pf_dev->speed_updated = false;
 		}
 	}
 
 	nfp_eth_table = pf_dev->nfp_eth_table;
-	eth_port = &nfp_eth_table->ports[hw->idx];
+	eth_port = &nfp_eth_table->ports[idx];
 
 	link->link_speed = nfp_net_link_speed_nfp2rte_check(eth_port->speed);
 
@@ -797,7 +816,6 @@ nfp_net_vf_speed_update(struct rte_eth_link *link,
 
 int
 nfp_net_link_update_common(struct rte_eth_dev *dev,
-		struct nfp_net_hw *hw,
 		struct rte_eth_link *link,
 		uint32_t link_status)
 {
@@ -807,7 +825,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->is_pf)
-			nfp_net_pf_speed_update(dev, hw, hw_priv, link);
+			nfp_net_pf_speed_update(dev, hw_priv, link);
 		else
 			nfp_net_vf_speed_update(link, link_status);
 	}
@@ -851,7 +869,7 @@ nfp_net_link_update(struct rte_eth_dev *dev,
 
 	link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
 
-	ret = nfp_net_link_update_common(dev, hw, &link, nn_link_status);
+	ret = nfp_net_link_update_common(dev, &link, nn_link_status);
 	if (ret == -EIO)
 		return ret;
 
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index be5705636f..a32f3b330a 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -293,7 +293,6 @@ int nfp_net_promisc_disable(struct rte_eth_dev *dev);
 int nfp_net_allmulticast_enable(struct rte_eth_dev *dev);
 int nfp_net_allmulticast_disable(struct rte_eth_dev *dev);
 int nfp_net_link_update_common(struct rte_eth_dev *dev,
-		struct nfp_net_hw *hw,
 		struct rte_eth_link *link,
 		uint32_t link_status);
 int nfp_net_link_update(struct rte_eth_dev *dev,
@@ -356,6 +355,7 @@ int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, 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);
+uint8_t nfp_net_get_idx(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,
 		struct rte_eth_fc_conf *fc_conf);
-- 
2.39.1


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

* [PATCH 7/8] net/nfp: standardize the use of port index in some functions
  2024-09-05  6:25 [PATCH 0/8] fix the representor port link status and speed Chaoyong He
                   ` (5 preceding siblings ...)
  2024-09-05  6:25 ` [PATCH 6/8] net/nfp: fix representor port link speed update problem Chaoyong He
@ 2024-09-05  6:25 ` Chaoyong He
  2024-09-05  6:25 ` [PATCH 8/8] net/nfp: fix representor port link status update problem Chaoyong He
  2024-10-04 18:17 ` [PATCH 0/8] fix the representor port link status and speed Ferruh Yigit
  8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2024-09-05  6:25 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Qin Ke, Chaoyong He, Long Wu, Peng Zhang

From: Qin Ke <qin.ke@corigine.com>

Standardize the use of 'idx' in some functions which could be
used for both flower and coreNIC firmware.

Signed-off-by: Qin Ke <qin.ke@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     |  6 ++++--
 drivers/net/nfp/nfp_net_common.c | 26 +++++++++++++-------------
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index b35e40a7d0..2ddfdcd048 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -281,6 +281,7 @@ static int
 nfp_net_speed_configure(struct rte_eth_dev *dev)
 {
 	int ret;
+	uint8_t idx;
 	uint32_t speed_capa;
 	uint32_t link_speeds;
 	uint32_t configure_speed;
@@ -289,8 +290,9 @@ nfp_net_speed_configure(struct rte_eth_dev *dev)
 	struct nfp_net_hw *net_hw = dev->data->dev_private;
 	struct nfp_net_hw_priv *hw_priv = dev->process_private;
 
+	idx = nfp_net_get_idx(dev);
 	nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
-	eth_port = &nfp_eth_table->ports[net_hw->idx];
+	eth_port = &nfp_eth_table->ports[idx];
 
 	speed_capa = hw_priv->pf_dev->speed_capa;
 	if (speed_capa == 0) {
@@ -308,7 +310,7 @@ nfp_net_speed_configure(struct rte_eth_dev *dev)
 
 	/* NFP4000 does not allow the port 0 25Gbps and port 1 10Gbps at the same time. */
 	if (net_hw->device_id == PCI_DEVICE_ID_NFP4000_PF_NIC) {
-		ret = nfp_net_nfp4000_speed_configure_check(net_hw->idx,
+		ret = nfp_net_nfp4000_speed_configure_check(idx,
 				configure_speed, nfp_eth_table);
 		if (ret != 0) {
 			PMD_DRV_LOG(ERR, "Failed to configure speed for NFP4000.");
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index daed57e374..f440f31a4d 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -2489,20 +2489,20 @@ nfp_net_flow_ctrl_set(struct rte_eth_dev *dev,
 		struct rte_eth_fc_conf *fc_conf)
 {
 	int ret;
-	struct nfp_net_hw *net_hw;
+	uint8_t idx;
 	enum rte_eth_fc_mode set_mode;
 	struct nfp_net_hw_priv *hw_priv;
 	enum rte_eth_fc_mode original_mode;
 	struct nfp_eth_table *nfp_eth_table;
 	struct nfp_eth_table_port *eth_port;
 
-	net_hw = nfp_net_get_hw(dev);
+	idx = nfp_net_get_idx(dev);
 	hw_priv = dev->process_private;
 	if (hw_priv == NULL || hw_priv->pf_dev == NULL)
 		return -EINVAL;
 
 	nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
-	eth_port = &nfp_eth_table->ports[net_hw->idx];
+	eth_port = &nfp_eth_table->ports[idx];
 
 	original_mode = nfp_net_get_pause_mode(eth_port);
 	set_mode = fc_conf->mode;
@@ -2526,20 +2526,20 @@ nfp_net_fec_get_capability(struct rte_eth_dev *dev,
 		struct rte_eth_fec_capa *speed_fec_capa,
 		__rte_unused unsigned int num)
 {
+	uint8_t idx;
 	uint16_t speed;
-	struct nfp_net_hw *hw;
 	uint32_t supported_fec;
 	struct nfp_net_hw_priv *hw_priv;
 	struct nfp_eth_table *nfp_eth_table;
 	struct nfp_eth_table_port *eth_port;
 
-	hw = nfp_net_get_hw(dev);
+	idx = nfp_net_get_idx(dev);
 	hw_priv = dev->process_private;
 	if (hw_priv == NULL || hw_priv->pf_dev == NULL)
 		return -EINVAL;
 
 	nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
-	eth_port = &nfp_eth_table->ports[hw->idx];
+	eth_port = &nfp_eth_table->ports[idx];
 
 	speed = eth_port->speed;
 	supported_fec = nfp_eth_supported_fec_modes(eth_port);
@@ -2587,24 +2587,24 @@ int
 nfp_net_fec_get(struct rte_eth_dev *dev,
 		uint32_t *fec_capa)
 {
-	struct nfp_net_hw *hw;
+	uint8_t idx;
 	struct nfp_net_hw_priv *hw_priv;
 	struct nfp_eth_table *nfp_eth_table;
 	struct nfp_eth_table_port *eth_port;
 
-	hw = nfp_net_get_hw(dev);
+	idx = nfp_net_get_idx(dev);
 	hw_priv = dev->process_private;
 	if (hw_priv == NULL || hw_priv->pf_dev == NULL)
 		return -EINVAL;
 
 	if (dev->data->dev_link.link_status == RTE_ETH_LINK_DOWN) {
 		nfp_eth_table = nfp_eth_read_ports(hw_priv->pf_dev->cpp);
-		hw_priv->pf_dev->nfp_eth_table->ports[hw->idx] = nfp_eth_table->ports[hw->idx];
+		hw_priv->pf_dev->nfp_eth_table->ports[idx] = nfp_eth_table->ports[idx];
 		free(nfp_eth_table);
 	}
 
 	nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
-	eth_port = &nfp_eth_table->ports[hw->idx];
+	eth_port = &nfp_eth_table->ports[idx];
 
 	if (!nfp_eth_can_support_fec(eth_port)) {
 		PMD_DRV_LOG(ERR, "NFP can not support FEC.");
@@ -2648,20 +2648,20 @@ int
 nfp_net_fec_set(struct rte_eth_dev *dev,
 		uint32_t fec_capa)
 {
+	uint8_t idx;
 	enum nfp_eth_fec fec;
-	struct nfp_net_hw *hw;
 	uint32_t supported_fec;
 	struct nfp_net_hw_priv *hw_priv;
 	struct nfp_eth_table *nfp_eth_table;
 	struct nfp_eth_table_port *eth_port;
 
-	hw = nfp_net_get_hw(dev);
+	idx = nfp_net_get_idx(dev);
 	hw_priv = dev->process_private;
 	if (hw_priv == NULL || hw_priv->pf_dev == NULL)
 		return -EINVAL;
 
 	nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
-	eth_port = &nfp_eth_table->ports[hw->idx];
+	eth_port = &nfp_eth_table->ports[idx];
 
 	supported_fec = nfp_eth_supported_fec_modes(eth_port);
 	if (supported_fec == 0) {
-- 
2.39.1


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

* [PATCH 8/8] net/nfp: fix representor port link status update problem
  2024-09-05  6:25 [PATCH 0/8] fix the representor port link status and speed Chaoyong He
                   ` (6 preceding siblings ...)
  2024-09-05  6:25 ` [PATCH 7/8] net/nfp: standardize the use of port index in some functions Chaoyong He
@ 2024-09-05  6:25 ` Chaoyong He
  2024-10-04 18:17 ` [PATCH 0/8] fix the representor port link status and speed Ferruh Yigit
  8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2024-09-05  6:25 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Qin Ke, chaoyong.he, stable, Long Wu, Peng Zhang

From: Qin Ke <qin.ke@corigine.com>

The link status of representor port is reported by the flower
firmware through control message and it already parsed and
stored in the 'link' field of representor port structure.

The original logic read link status from the control BAR again,
and use it rather then the 'link' field of the representor port
structure in the following logic wrongly.

Fix this by delete the read control BAR statement and use the
right link status value.

Fixes: c4de52eca76c ("net/nfp: remove redundancy for representor port")
Cc: chaoyong.he@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Qin Ke <qin.ke@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/flower/nfp_flower_representor.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 054ea1a938..5db7d50618 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -29,18 +29,13 @@ nfp_flower_repr_link_update(struct rte_eth_dev *dev,
 		__rte_unused int wait_to_complete)
 {
 	int ret;
-	uint32_t nn_link_status;
-	struct nfp_net_hw *pf_hw;
 	struct rte_eth_link *link;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
 	link = &repr->link;
 
-	pf_hw = repr->app_fw_flower->pf_hw;
-	nn_link_status = nn_cfg_readw(&pf_hw->super, NFP_NET_CFG_STS);
-
-	ret = nfp_net_link_update_common(dev, link, nn_link_status);
+	ret = nfp_net_link_update_common(dev, link, link->link_status);
 
 	return ret;
 }
-- 
2.39.1


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

* Re: [PATCH 0/8] fix the representor port link status and speed
  2024-09-05  6:25 [PATCH 0/8] fix the representor port link status and speed Chaoyong He
                   ` (7 preceding siblings ...)
  2024-09-05  6:25 ` [PATCH 8/8] net/nfp: fix representor port link status update problem Chaoyong He
@ 2024-10-04 18:17 ` Ferruh Yigit
  8 siblings, 0 replies; 10+ messages in thread
From: Ferruh Yigit @ 2024-10-04 18:17 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers

On 9/5/2024 7:25 AM, Chaoyong He wrote:
> This patch series aims to fix some problems in the representor port link
> status and speed update logic, also do some refactors to the related
> logics.
> 
> Qin Ke (8):
>   net/nfp: fix incorrect type declaration of some variables
>   net/nfp: add help function to check link speed
>   net/nfp: add help function to update VF link speed
>   net/nfp: rename PF speed update function
>   net/nfp: add new data field into representor port structure
>   net/nfp: fix representor port link speed update problem
>   net/nfp: standardize the use of port index in some functions
>   net/nfp: fix representor port link status update problem
>

Series applied to dpdk-next-net/main, thanks.

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

end of thread, other threads:[~2024-10-04 18:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-05  6:25 [PATCH 0/8] fix the representor port link status and speed Chaoyong He
2024-09-05  6:25 ` [PATCH 1/8] net/nfp: fix incorrect type declaration of some variables Chaoyong He
2024-09-05  6:25 ` [PATCH 2/8] net/nfp: add help function to check link speed Chaoyong He
2024-09-05  6:25 ` [PATCH 3/8] net/nfp: add help function to update VF " Chaoyong He
2024-09-05  6:25 ` [PATCH 4/8] net/nfp: rename PF speed update function Chaoyong He
2024-09-05  6:25 ` [PATCH 5/8] net/nfp: add new data field into representor port structure Chaoyong He
2024-09-05  6:25 ` [PATCH 6/8] net/nfp: fix representor port link speed update problem Chaoyong He
2024-09-05  6:25 ` [PATCH 7/8] net/nfp: standardize the use of port index in some functions Chaoyong He
2024-09-05  6:25 ` [PATCH 8/8] net/nfp: fix representor port link status update problem Chaoyong He
2024-10-04 18:17 ` [PATCH 0/8] fix the representor port link status and speed 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).