net/mlx5: replace Linux sleep
authorOphir Munk <ophirmu@nvidia.com>
Mon, 28 Dec 2020 09:54:09 +0000 (11:54 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 8 Jan 2021 15:03:07 +0000 (16:03 +0100)
Replace Linux API usleep() and nanosleep() with rte_delay_us_sleep().
The replacement occurs in shared files compiled under different
operating systems.

Signed-off-by: Ophir Munk <ophirmu@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/net/mlx5/mlx5.c
drivers/net/mlx5/mlx5_trigger.c
drivers/net/mlx5/mlx5_txpp.c

index 52a8a25..8e9df6a 100644 (file)
@@ -21,6 +21,7 @@
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
 #include <rte_alarm.h>
+#include <rte_cycles.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -1330,7 +1331,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
        mlx5_flex_parser_ecpri_release(dev);
        if (priv->rxqs != NULL) {
                /* XXX race condition if mlx5_rx_burst() is still running. */
-               usleep(1000);
+               rte_delay_us_sleep(1000);
                for (i = 0; (i != priv->rxqs_n); ++i)
                        mlx5_rxq_release(dev, i);
                priv->rxqs_n = 0;
@@ -1338,7 +1339,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
        }
        if (priv->txqs != NULL) {
                /* XXX race condition if mlx5_tx_burst() is still running. */
-               usleep(1000);
+               rte_delay_us_sleep(1000);
                for (i = 0; (i != priv->txqs_n); ++i)
                        mlx5_txq_release(dev, i);
                priv->txqs_n = 0;
index bd02915..646f29b 100644 (file)
@@ -9,6 +9,7 @@
 #include <rte_ethdev_driver.h>
 #include <rte_interrupts.h>
 #include <rte_alarm.h>
+#include <rte_cycles.h>
 
 #include <mlx5_malloc.h>
 
@@ -1171,7 +1172,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)
        rte_wmb();
        /* Disable datapath on secondary process. */
        mlx5_mp_os_req_stop_rxtx(dev);
-       usleep(1000 * priv->rxqs_n);
+       rte_delay_us_sleep(1000 * priv->rxqs_n);
        DRV_LOG(DEBUG, "port %u stopping device", dev->data->port_id);
        mlx5_flow_stop_default(dev);
        /* Control flows for default traffic can be removed firstly. */
index 21675ab..a1ec294 100644 (file)
@@ -769,15 +769,11 @@ mlx5_txpp_init_timestamp(struct mlx5_dev_ctx_shared *sh)
        sh->txpp.ts_p = 0;
        sh->txpp.ts_n = 0;
        for (wait = 0; wait < MLX5_TXPP_WAIT_INIT_TS; wait++) {
-               struct timespec onems;
-
                mlx5_txpp_update_timestamp(sh);
                if (wq->sq_ci)
                        return;
                /* Wait one millisecond and try again. */
-               onems.tv_sec = 0;
-               onems.tv_nsec = NS_PER_S / MS_PER_S;
-               nanosleep(&onems, 0);
+               rte_delay_us_sleep(US_PER_S / MS_PER_S);
        }
        DRV_LOG(ERR, "Unable to initialize timestamp.");
        sh->txpp.sync_lost = 1;