summaryrefslogtreecommitdiff
path: root/drivers/net/mlx5/mlx5_ethdev.c
diff options
context:
space:
mode:
authorShahaf Shuler <shahafs@mellanox.com>2018-01-25 18:04:28 +0200
committerFerruh Yigit <ferruh.yigit@intel.com>2018-01-29 10:04:28 +0100
commite313ef4c2fe83509785ba195e75389d1ed6b6afb (patch)
treeb451b4c90b5533a617716969409a41ae90b72191 /drivers/net/mlx5/mlx5_ethdev.c
parent5a29b9a35a7214e2e36764ea67e13d7573eb925a (diff)
downloaddpdk-e313ef4c2fe83509785ba195e75389d1ed6b6afb.zip
dpdk-e313ef4c2fe83509785ba195e75389d1ed6b6afb.tar.gz
dpdk-e313ef4c2fe83509785ba195e75389d1ed6b6afb.tar.xz
net/mlx5: fix link state on device start
Following commit c7bf62255edf ("net/mlx5: fix handling link status event") the link state must be up in order for the burst function to be set on the device ops. As the link may take time to move between down and up state it is possible the rte_eth_dev_start call will return with wrong burst function (either null or the empty burst function). Fixing it by forcing the link to be up before returning from device start. In case the link is still not up after 5 seconds fail the function. In addition initialize the burst function on device probe to prevent crashes before the link is up. Fixes: c7bf62255edf ("net/mlx5: fix handling link status event") Cc: stable@dpdk.org Signed-off-by: Shahaf Shuler <shahafs@mellanox.com> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Diffstat (limited to 'drivers/net/mlx5/mlx5_ethdev.c')
-rw-r--r--drivers/net/mlx5/mlx5_ethdev.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index c886aef..83657f5 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -967,6 +967,33 @@ priv_link_update(struct priv *priv, int wait_to_complete)
}
/**
+ * Querying the link status till it changes to the desired state.
+ * Number of query attempts is bounded by MLX5_MAX_LINK_QUERY_ATTEMPTS.
+ *
+ * @param priv
+ * Pointer to private structure.
+ * @param status
+ * Link desired status.
+ *
+ * @return
+ * 0 on success, negative errno value on failure.
+ */
+int
+priv_force_link_status_change(struct priv *priv, int status)
+{
+ int try = 0;
+
+ while (try < MLX5_MAX_LINK_QUERY_ATTEMPTS) {
+ priv_link_update(priv, 0);
+ if (priv->dev->data->dev_link.link_status == status)
+ return 0;
+ try++;
+ sleep(1);
+ }
+ return -EAGAIN;
+}
+
+/**
* DPDK callback to retrieve physical link information.
*
* @param dev