examples/l3fwd: share queue size variables
[dpdk.git] / drivers / net / mlx5 / mlx5_txpp.c
index 927c327..fe74317 100644 (file)
@@ -816,16 +816,16 @@ mlx5_txpp_start_service(struct mlx5_dev_ctx_shared *sh)
  * Returns 0 on success, negative otherwise
  */
 static int
-mlx5_txpp_create(struct mlx5_dev_ctx_shared *sh, struct mlx5_priv *priv)
+mlx5_txpp_create(struct mlx5_dev_ctx_shared *sh)
 {
-       int tx_pp = priv->config.tx_pp;
+       int tx_pp = sh->config.tx_pp;
        int ret;
 
        /* Store the requested pacing parameters. */
        sh->txpp.tick = tx_pp >= 0 ? tx_pp : -tx_pp;
        sh->txpp.test = !!(tx_pp < 0);
-       sh->txpp.skew = priv->config.tx_skew;
-       sh->txpp.freq = priv->config.hca_attr.dev_freq_khz;
+       sh->txpp.skew = sh->config.tx_skew;
+       sh->txpp.freq = sh->cdev->config.hca_attr.dev_freq_khz;
        ret = mlx5_txpp_create_event_channel(sh);
        if (ret)
                goto exit;
@@ -890,9 +890,8 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
        struct mlx5_priv *priv = dev->data->dev_private;
        struct mlx5_dev_ctx_shared *sh = priv->sh;
        int err = 0;
-       int ret;
 
-       if (!priv->config.tx_pp) {
+       if (!sh->config.tx_pp) {
                /* Packet pacing is not requested for the device. */
                MLX5_ASSERT(priv->txpp_en == 0);
                return 0;
@@ -902,20 +901,20 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
                MLX5_ASSERT(sh->txpp.refcnt);
                return 0;
        }
-       if (priv->config.tx_pp > 0) {
-               ret = rte_mbuf_dynflag_lookup
-                               (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME, NULL);
-               if (ret < 0)
+       if (sh->config.tx_pp > 0) {
+               err = rte_mbuf_dynflag_lookup
+                       (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME, NULL);
+               /* No flag registered means no service needed. */
+               if (err < 0)
                        return 0;
+               err = 0;
        }
-       ret = pthread_mutex_lock(&sh->txpp.mutex);
-       MLX5_ASSERT(!ret);
-       RTE_SET_USED(ret);
+       claim_zero(pthread_mutex_lock(&sh->txpp.mutex));
        if (sh->txpp.refcnt) {
                priv->txpp_en = 1;
                ++sh->txpp.refcnt;
        } else {
-               err = mlx5_txpp_create(sh, priv);
+               err = mlx5_txpp_create(sh);
                if (!err) {
                        MLX5_ASSERT(sh->txpp.tick);
                        priv->txpp_en = 1;
@@ -924,9 +923,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
                        rte_errno = -err;
                }
        }
-       ret = pthread_mutex_unlock(&sh->txpp.mutex);
-       MLX5_ASSERT(!ret);
-       RTE_SET_USED(ret);
+       claim_zero(pthread_mutex_unlock(&sh->txpp.mutex));
        return err;
 }
 
@@ -944,24 +941,21 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
        struct mlx5_dev_ctx_shared *sh = priv->sh;
-       int ret;
 
        if (!priv->txpp_en) {
                /* Packet pacing is already disabled for the device. */
                return;
        }
        priv->txpp_en = 0;
-       ret = pthread_mutex_lock(&sh->txpp.mutex);
-       MLX5_ASSERT(!ret);
-       RTE_SET_USED(ret);
+       claim_zero(pthread_mutex_lock(&sh->txpp.mutex));
        MLX5_ASSERT(sh->txpp.refcnt);
-       if (!sh->txpp.refcnt || --sh->txpp.refcnt)
+       if (!sh->txpp.refcnt || --sh->txpp.refcnt) {
+               claim_zero(pthread_mutex_unlock(&sh->txpp.mutex));
                return;
+       }
        /* No references any more, do actual destroy. */
        mlx5_txpp_destroy(sh);
-       ret = pthread_mutex_unlock(&sh->txpp.mutex);
-       MLX5_ASSERT(!ret);
-       RTE_SET_USED(ret);
+       claim_zero(pthread_mutex_unlock(&sh->txpp.mutex));
 }
 
 /*