diff mbox series

[10/35] net/mlx5/windows: support link update

Message ID 20201217173037.11396-11-talshn@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers show
Series mlx5 Windows support - part #6 | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tal Shnaiderman Dec. 17, 2020, 5:30 p.m. UTC
Add support for mlx5_link_update() to get link speed and link state.
Other parameters are currently hard-coded.

Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/windows/mlx5_ethdev_os.c | 44 +++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/mlx5/windows/mlx5_ethdev_os.c b/drivers/net/mlx5/windows/mlx5_ethdev_os.c
index 4925fd893f..c99eac9868 100644
--- a/drivers/net/mlx5/windows/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/windows/mlx5_ethdev_os.c
@@ -170,6 +170,50 @@  mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats)
 	return -ENOTSUP;
 }
 
+/**
+ * DPDK callback to retrieve physical link information.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param wait_to_complete
+ *   Wait for request completion.
+ *
+ * @return
+ *   0 if link status was not updated, positive if it was, a negative errno
+ *   value otherwise and rte_errno is set.
+ */
+int
+mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete)
+{
+	RTE_SET_USED(wait_to_complete);
+	struct mlx5_priv *priv;
+	mlx5_context_st *context_obj;
+	struct rte_eth_link dev_link;
+	int ret;
+
+	ret = 0;
+	if (!dev) {
+		rte_errno = EINVAL;
+		return -rte_errno;
+	}
+	priv = dev->data->dev_private;
+	context_obj = (mlx5_context_st *)priv->sh->ctx;
+	dev_link.link_speed = context_obj->mlx5_dev.link_speed / (1024 * 1024);
+	dev_link.link_status =
+	      (context_obj->mlx5_dev.link_state == 1 && !mlx5_is_removed(dev))
+	      ? 1 : 0;
+	dev_link.link_duplex = 1;
+	if (dev->data->dev_link.link_speed != dev_link.link_speed ||
+	    dev->data->dev_link.link_duplex != dev_link.link_duplex ||
+	    dev->data->dev_link.link_autoneg != dev_link.link_autoneg ||
+	    dev->data->dev_link.link_status != dev_link.link_status)
+		ret = 1;
+	else
+		ret = 0;
+	dev->data->dev_link = dev_link;
+	return ret;
+}
+
 /**
  * DPDK callback to bring the link DOWN.
  *