[v1,09/43] net/dpaa2: support link state for eth interfaces

Message ID 20240913055959.3246917-10-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@nxp.com Sept. 13, 2024, 5:59 a.m. UTC
From: Rohit Raj <rohit.raj@nxp.com>

This patch add support to update the duplex value along with
link status and link speed after setting the link UP.

Signed-off-by: Rohit Raj <rohit.raj@nxp.com>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
  

Patch

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 4dc7a82b47..9172097abf 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1985,7 +1985,7 @@  dpaa2_dev_set_link_up(struct rte_eth_dev *dev)
 	if (ret) {
 		/* Unable to obtain dpni status; Not continuing */
 		DPAA2_PMD_ERR("Interface Link UP failed (%d)", ret);
-		return -EINVAL;
+		return ret;
 	}
 
 	/* Enable link if not already enabled */
@@ -1993,13 +1993,13 @@  dpaa2_dev_set_link_up(struct rte_eth_dev *dev)
 		ret = dpni_enable(dpni, CMD_PRI_LOW, priv->token);
 		if (ret) {
 			DPAA2_PMD_ERR("Interface Link UP failed (%d)", ret);
-			return -EINVAL;
+			return ret;
 		}
 	}
 	ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state);
 	if (ret < 0) {
 		DPAA2_PMD_DEBUG("Unable to get link state (%d)", ret);
-		return -1;
+		return ret;
 	}
 
 	/* changing tx burst function to start enqueues */
@@ -2007,10 +2007,15 @@  dpaa2_dev_set_link_up(struct rte_eth_dev *dev)
 	dev->data->dev_link.link_status = state.up;
 	dev->data->dev_link.link_speed = state.rate;
 
+	if (state.options & DPNI_LINK_OPT_HALF_DUPLEX)
+		dev->data->dev_link.link_duplex = RTE_ETH_LINK_HALF_DUPLEX;
+	else
+		dev->data->dev_link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
+
 	if (state.up)
-		DPAA2_PMD_INFO("Port %d Link is Up", dev->data->port_id);
+		DPAA2_PMD_DEBUG("Port %d Link is Up", dev->data->port_id);
 	else
-		DPAA2_PMD_INFO("Port %d Link is Down", dev->data->port_id);
+		DPAA2_PMD_DEBUG("Port %d Link is Down", dev->data->port_id);
 	return ret;
 }