[v3,10/43] net/dpaa2: update DPNI link status method

Message ID 20241014120126.170790-11-vanshika.shukla@nxp.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series DPAA2 specific patches |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Vanshika Shukla Oct. 14, 2024, noon UTC
From: Brick Yang <brick.yang@nxp.com>

If SFP module is not connected to the port and flow control is
configured using flow control API, link will show DOWN even after
connecting the SFP module and fiber cable.

This issue cannot be reproduced if only SFP module is connected and
fiber cable is disconnected before configuring flow control even
though link is down in this case too.

This patch improves it by getting configuration values from
dpni_get_link_cfg API instead of dpni_get_link_state API, which
provides us static configuration data.

Signed-off-by: Brick Yang <brick.yang@nxp.com>
Signed-off-by: Rohit Raj <rohit.raj@nxp.com>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)
  

Patch

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index b120e2c815..0adebc0bf1 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -2087,7 +2087,7 @@  dpaa2_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 	int ret = -EINVAL;
 	struct dpaa2_dev_priv *priv;
 	struct fsl_mc_io *dpni;
-	struct dpni_link_state state = {0};
+	struct dpni_link_cfg cfg = {0};
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -2099,14 +2099,14 @@  dpaa2_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 		return ret;
 	}
 
-	ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state);
+	ret = dpni_get_link_cfg(dpni, CMD_PRI_LOW, priv->token, &cfg);
 	if (ret) {
-		DPAA2_PMD_ERR("error: dpni_get_link_state %d", ret);
+		DPAA2_PMD_ERR("error: dpni_get_link_cfg %d", ret);
 		return ret;
 	}
 
 	memset(fc_conf, 0, sizeof(struct rte_eth_fc_conf));
-	if (state.options & DPNI_LINK_OPT_PAUSE) {
+	if (cfg.options & DPNI_LINK_OPT_PAUSE) {
 		/* DPNI_LINK_OPT_PAUSE set
 		 *  if ASYM_PAUSE not set,
 		 *	RX Side flow control (handle received Pause frame)
@@ -2115,7 +2115,7 @@  dpaa2_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 		 *	RX Side flow control (handle received Pause frame)
 		 *	No TX side flow control (send Pause frame disabled)
 		 */
-		if (!(state.options & DPNI_LINK_OPT_ASYM_PAUSE))
+		if (!(cfg.options & DPNI_LINK_OPT_ASYM_PAUSE))
 			fc_conf->mode = RTE_ETH_FC_FULL;
 		else
 			fc_conf->mode = RTE_ETH_FC_RX_PAUSE;
@@ -2127,7 +2127,7 @@  dpaa2_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 		 *  if ASYM_PAUSE not set,
 		 *	Flow control disabled
 		 */
-		if (state.options & DPNI_LINK_OPT_ASYM_PAUSE)
+		if (cfg.options & DPNI_LINK_OPT_ASYM_PAUSE)
 			fc_conf->mode = RTE_ETH_FC_TX_PAUSE;
 		else
 			fc_conf->mode = RTE_ETH_FC_NONE;
@@ -2142,7 +2142,6 @@  dpaa2_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 	int ret = -EINVAL;
 	struct dpaa2_dev_priv *priv;
 	struct fsl_mc_io *dpni;
-	struct dpni_link_state state = {0};
 	struct dpni_link_cfg cfg = {0};
 
 	PMD_INIT_FUNC_TRACE();
@@ -2155,23 +2154,19 @@  dpaa2_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 		return ret;
 	}
 
-	/* It is necessary to obtain the current state before setting fc_conf
+	/* It is necessary to obtain the current cfg before setting fc_conf
 	 * as MC would return error in case rate, autoneg or duplex values are
 	 * different.
 	 */
-	ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state);
+	ret = dpni_get_link_cfg(dpni, CMD_PRI_LOW, priv->token, &cfg);
 	if (ret) {
-		DPAA2_PMD_ERR("Unable to get link state (err=%d)", ret);
+		DPAA2_PMD_ERR("Unable to get link cfg (err=%d)", ret);
 		return -1;
 	}
 
 	/* Disable link before setting configuration */
 	dpaa2_dev_set_link_down(dev);
 
-	/* Based on fc_conf, update cfg */
-	cfg.rate = state.rate;
-	cfg.options = state.options;
-
 	/* update cfg with fc_conf */
 	switch (fc_conf->mode) {
 	case RTE_ETH_FC_FULL: