@@ -1183,7 +1183,7 @@
if (!priv->lb_used)
return;
MLX5_ASSERT(__atomic_load_n(&sh->self_lb.refcnt, __ATOMIC_RELAXED));
- if (!(__atomic_sub_fetch(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED))) {
+ if (!(__atomic_fetch_sub(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED) - 1)) {
if (sh->self_lb.qp) {
claim_zero(mlx5_glue->destroy_qp(sh->self_lb.qp));
sh->self_lb.qp = NULL;
@@ -1068,7 +1068,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
DRV_LOG(ERR, "Dynamic flex parser is not supported");
return -ENOTSUP;
}
- if (__atomic_add_fetch(&priv->sh->srh_flex_parser.refcnt, 1, __ATOMIC_RELAXED) > 1)
+ if (__atomic_fetch_add(&priv->sh->srh_flex_parser.refcnt, 1, __ATOMIC_RELAXED) + 1 > 1)
return 0;
node.header_length_mode = MLX5_GRAPH_NODE_LEN_FIELD;
@@ -1123,7 +1123,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
struct mlx5_priv *priv = dev->data->dev_private;
struct mlx5_internal_flex_parser_profile *fp = &priv->sh->srh_flex_parser;
- if (__atomic_sub_fetch(&fp->refcnt, 1, __ATOMIC_RELAXED))
+ if (__atomic_fetch_sub(&fp->refcnt, 1, __ATOMIC_RELAXED) - 1)
return;
if (fp->fp)
mlx5_devx_cmd_destroy(fp->fp);
@@ -7833,7 +7833,7 @@ struct rte_flow *
tunnel = mlx5_find_tunnel_id(dev, flow->tunnel_id);
RTE_VERIFY(tunnel);
- if (!__atomic_sub_fetch(&tunnel->refctn, 1, __ATOMIC_RELAXED))
+ if (!(__atomic_fetch_sub(&tunnel->refctn, 1, __ATOMIC_RELAXED) - 1))
mlx5_flow_tunnel_free(dev, tunnel);
}
flow_mreg_del_copy_action(dev, flow);
@@ -9742,9 +9742,9 @@ struct mlx5_flow_workspace*
__ATOMIC_RELAXED);
continue;
}
- if (__atomic_add_fetch(&age_param->sec_since_last_hit,
+ if (__atomic_fetch_add(&age_param->sec_since_last_hit,
time_delta,
- __ATOMIC_RELAXED) <= age_param->timeout)
+ __ATOMIC_RELAXED) + time_delta <= age_param->timeout)
continue;
/**
* Hold the lock first, or if between the
@@ -11387,7 +11387,7 @@ struct tunnel_db_element_release_ctx {
{
struct tunnel_db_element_release_ctx *ctx = x;
ctx->ret = 0;
- if (!__atomic_sub_fetch(&tunnel->refctn, 1, __ATOMIC_RELAXED))
+ if (!(__atomic_fetch_sub(&tunnel->refctn, 1, __ATOMIC_RELAXED) - 1))
mlx5_flow_tunnel_free(dev, tunnel);
}
@@ -6723,8 +6723,8 @@ struct mlx5_list_entry *
* indirect action API, shared info is 1 before the reduction,
* so this condition is failed and function doesn't return here.
*/
- if (__atomic_sub_fetch(&cnt->shared_info.refcnt, 1,
- __ATOMIC_RELAXED))
+ if (__atomic_fetch_sub(&cnt->shared_info.refcnt, 1,
+ __ATOMIC_RELAXED) - 1)
return;
}
cnt->pool = pool;
@@ -12797,7 +12797,7 @@ struct mlx5_list_entry *
struct mlx5_priv *priv = dev->data->dev_private;
struct mlx5_aso_age_mng *mng = priv->sh->aso_age_mng;
struct mlx5_aso_age_action *age = flow_aso_age_get_by_idx(dev, age_idx);
- uint32_t ret = __atomic_sub_fetch(&age->refcnt, 1, __ATOMIC_RELAXED);
+ uint32_t ret = __atomic_fetch_sub(&age->refcnt, 1, __ATOMIC_RELAXED) - 1;
if (!ret) {
flow_dv_aso_age_remove_from_age(dev, age);
@@ -13193,7 +13193,7 @@ struct mlx5_list_entry *
/* Cannot release when CT is in the ASO SQ. */
if (state == ASO_CONNTRACK_WAIT || state == ASO_CONNTRACK_QUERY)
return -1;
- ret = __atomic_sub_fetch(&ct->refcnt, 1, __ATOMIC_RELAXED);
+ ret = __atomic_fetch_sub(&ct->refcnt, 1, __ATOMIC_RELAXED) - 1;
if (!ret) {
if (ct->dr_action_orig) {
#ifdef HAVE_MLX5_DR_ACTION_ASO_CT
@@ -15582,8 +15582,8 @@ struct mlx5_list_entry *
sh->geneve_tlv_option_resource;
rte_spinlock_lock(&sh->geneve_tlv_opt_sl);
if (geneve_opt_resource) {
- if (!(__atomic_sub_fetch(&geneve_opt_resource->refcnt, 1,
- __ATOMIC_RELAXED))) {
+ if (!(__atomic_fetch_sub(&geneve_opt_resource->refcnt, 1,
+ __ATOMIC_RELAXED) - 1)) {
claim_zero(mlx5_devx_cmd_destroy
(geneve_opt_resource->obj));
mlx5_free(sh->geneve_tlv_option_resource);
@@ -458,7 +458,7 @@ static int flow_hw_translate_group(struct rte_eth_dev *dev,
}
if (acts->mark)
- if (!__atomic_sub_fetch(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED))
+ if (!(__atomic_fetch_sub(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED) - 1))
flow_hw_rxq_flag_set(dev, false);
if (acts->jump) {
@@ -3268,8 +3268,8 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions)
rte_errno = EINVAL;
goto it_error;
}
- ret = __atomic_add_fetch(&item_templates[i]->refcnt, 1,
- __ATOMIC_RELAXED);
+ ret = __atomic_fetch_add(&item_templates[i]->refcnt, 1,
+ __ATOMIC_RELAXED) + 1;
if (ret <= 1) {
rte_errno = EINVAL;
goto it_error;
@@ -3282,8 +3282,8 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions)
for (i = 0; i < nb_action_templates; i++) {
uint32_t ret;
- ret = __atomic_add_fetch(&action_templates[i]->refcnt, 1,
- __ATOMIC_RELAXED);
+ ret = __atomic_fetch_add(&action_templates[i]->refcnt, 1,
+ __ATOMIC_RELAXED) + 1;
if (ret <= 1) {
rte_errno = EINVAL;
goto at_error;
@@ -7624,8 +7624,8 @@ void flow_hw_clear_tags_set(struct rte_eth_dev *dev)
{
uint32_t refcnt;
- refcnt = __atomic_sub_fetch(&mlx5_flow_hw_flow_metadata_config_refcnt, 1,
- __ATOMIC_RELAXED);
+ refcnt = __atomic_fetch_sub(&mlx5_flow_hw_flow_metadata_config_refcnt, 1,
+ __ATOMIC_RELAXED) - 1;
if (refcnt > 0)
return;
mlx5_flow_hw_flow_metadata_esw_en = 0;
@@ -192,8 +192,8 @@
}
param->accumulator_hits = 0;
}
- if (__atomic_add_fetch(¶m->sec_since_last_hit, time_delta,
- __ATOMIC_RELAXED) <=
+ if (__atomic_fetch_add(¶m->sec_since_last_hit, time_delta,
+ __ATOMIC_RELAXED) + time_delta <=
__atomic_load_n(¶m->timeout, __ATOMIC_RELAXED))
continue;
/* Prepare the relevant ring for this AGE parameter */
@@ -2042,7 +2042,7 @@ struct mlx5_rxq_priv *
if (rxq == NULL)
return 0;
- return __atomic_sub_fetch(&rxq->refcnt, 1, __ATOMIC_RELAXED);
+ return __atomic_fetch_sub(&rxq->refcnt, 1, __ATOMIC_RELAXED) - 1;
}
/**
@@ -2141,7 +2141,7 @@ struct mlx5_external_rxq *
{
struct mlx5_external_rxq *rxq = mlx5_ext_rxq_get(dev, idx);
- return __atomic_sub_fetch(&rxq->refcnt, 1, __ATOMIC_RELAXED);
+ return __atomic_fetch_sub(&rxq->refcnt, 1, __ATOMIC_RELAXED) - 1;
}
/**
@@ -2462,7 +2462,7 @@ struct mlx5_ind_table_obj *
unsigned int ret;
rte_rwlock_write_lock(&priv->ind_tbls_lock);
- ret = __atomic_sub_fetch(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED);
+ ret = __atomic_fetch_sub(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED) - 1;
if (!ret)
LIST_REMOVE(ind_tbl, next);
rte_rwlock_write_unlock(&priv->ind_tbls_lock);
@@ -1203,7 +1203,7 @@ struct mlx5_txq_ctrl *
if (priv->txqs == NULL || (*priv->txqs)[idx] == NULL)
return 0;
txq_ctrl = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq);
- if (__atomic_sub_fetch(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) > 1)
+ if (__atomic_fetch_sub(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) - 1 > 1)
return 1;
if (txq_ctrl->obj) {
priv->obj_ops.txq_obj_release(txq_ctrl->obj);