[v5,09/42] net/dpaa2: support link state for eth interfaces

Message ID 20241023115955.1207617-10-vanshika.shukla@nxp.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series DPAA2 specific patches |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Vanshika Shukla Oct. 23, 2024, 11: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 439b8f97a4..b120e2c815 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1988,7 +1988,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 */
@@ -1996,13 +1996,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 */
@@ -2010,10 +2010,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;
 }