net/mlx5: add C++ include guard to public header
[dpdk.git] / drivers / net / mlx5 / mlx5_flow_meter.c
index a24bd9c..0dc7fbf 100644 (file)
@@ -251,7 +251,7 @@ mlx5_flow_meter_xir_man_exp_calc(int64_t xir, uint8_t *man, uint8_t *exp)
        uint8_t _exp = 0;
        uint64_t m, e;
 
-       /* Special case xir == 0 ? both exp and matissa are 0. */
+       /* Special case xir == 0 ? both exp and mantissa are 0. */
        if (xir == 0) {
                *man = 0;
                *exp = 0;
@@ -287,7 +287,7 @@ mlx5_flow_meter_xbs_man_exp_calc(uint64_t xbs, uint8_t *man, uint8_t *exp)
        int _exp;
        double _man;
 
-       /* Special case xbs == 0 ? both exp and matissa are 0. */
+       /* Special case xbs == 0 ? both exp and mantissa are 0. */
        if (xbs == 0) {
                *man = 0;
                *exp = 0;
@@ -305,7 +305,7 @@ mlx5_flow_meter_xbs_man_exp_calc(uint64_t xbs, uint8_t *man, uint8_t *exp)
  * Fill the prm meter parameter.
  *
  * @param[in,out] fmp
- *   Pointer to meter profie to be converted.
+ *   Pointer to meter profile to be converted.
  * @param[out] error
  *   Pointer to the error structure.
  *
@@ -1101,7 +1101,7 @@ mlx5_flow_meter_action_modify(struct mlx5_priv *priv,
                        if (ret)
                                return ret;
                }
-               /* Update succeedded modify meter parameters. */
+               /* Update succeeded modify meter parameters. */
                if (modify_bits & MLX5_FLOW_METER_OBJ_MODIFY_FIELD_ACTIVE)
                        fm->active_state = !!active_state;
        }
@@ -1167,7 +1167,8 @@ mlx5_flow_meter_create(struct rte_eth_dev *dev, uint32_t meter_id,
        struct mlx5_legacy_flow_meters *fms = &priv->flow_meters;
        struct mlx5_flow_meter_profile *fmp;
        struct mlx5_flow_meter_info *fm;
-       struct mlx5_legacy_flow_meter *legacy_fm;
+       /* GCC fails to infer legacy_fm is set when !priv->sh->meter_aso_en. */
+       struct mlx5_legacy_flow_meter *legacy_fm = NULL;
        struct mlx5_flow_meter_policy *mtr_policy = NULL;
        struct mlx5_indexed_pool_config flow_ipool_cfg = {
                .size = 0,
@@ -1273,8 +1274,10 @@ mlx5_flow_meter_create(struct rte_eth_dev *dev, uint32_t meter_id,
        if (mlx5_flow_create_mtr_tbls(dev, fm, mtr_idx, domain_bitmap))
                goto error;
        /* Add to the flow meter list. */
-       if (!priv->sh->meter_aso_en)
+       if (!priv->sh->meter_aso_en) {
+               MLX5_ASSERT(legacy_fm != NULL);
                TAILQ_INSERT_TAIL(fms, legacy_fm, next);
+       }
        /* Add to the flow meter list. */
        fm->active_state = 1; /* Config meter starts as active. */
        fm->is_enable = 1;
@@ -1615,7 +1618,7 @@ mlx5_flow_meter_profile_update(struct rte_eth_dev *dev,
                return -rte_mtr_error_set(error, -ret,
                                          RTE_MTR_ERROR_TYPE_MTR_PARAMS,
                                          NULL, "Failed to update meter"
-                                         " parmeters in hardware.");
+                                         " parameters in hardware.");
        }
        old_fmp->ref_cnt--;
        fmp->ref_cnt++;
@@ -1789,24 +1792,21 @@ mlx5_flow_meter_find(struct mlx5_priv *priv, uint32_t meter_id,
        struct mlx5_aso_mtr_pools_mng *pools_mng =
                                &priv->sh->mtrmng->pools_mng;
        union mlx5_l3t_data data;
+       uint16_t n_valid;
 
        if (priv->sh->meter_aso_en) {
-               rte_spinlock_lock(&pools_mng->mtrsl);
-               if (!pools_mng->n_valid || !priv->mtr_idx_tbl) {
-                       rte_spinlock_unlock(&pools_mng->mtrsl);
-                       return NULL;
-               }
-               if (mlx5_l3t_get_entry(priv->mtr_idx_tbl, meter_id, &data) ||
-                       !data.dword) {
-                       rte_spinlock_unlock(&pools_mng->mtrsl);
+               rte_rwlock_read_lock(&pools_mng->resize_mtrwl);
+               n_valid = pools_mng->n_valid;
+               rte_rwlock_read_unlock(&pools_mng->resize_mtrwl);
+               if (!n_valid || !priv->mtr_idx_tbl ||
+                   (mlx5_l3t_get_entry(priv->mtr_idx_tbl, meter_id, &data) ||
+                   !data.dword))
                        return NULL;
-               }
                if (mtr_idx)
                        *mtr_idx = data.dword;
                aso_mtr = mlx5_aso_meter_by_idx(priv, data.dword);
                /* Remove reference taken by the mlx5_l3t_get_entry. */
                mlx5_l3t_clear_entry(priv->mtr_idx_tbl, meter_id);
-               rte_spinlock_unlock(&pools_mng->mtrsl);
                if (!aso_mtr || aso_mtr->state == ASO_METER_FREE)
                        return NULL;
                return &aso_mtr->fm;
@@ -2168,7 +2168,7 @@ mlx5_flow_meter_flush(struct rte_eth_dev *dev, struct rte_mtr_error *error)
                        priv->mtr_idx_tbl = NULL;
                }
        } else {
-               TAILQ_FOREACH_SAFE(legacy_fm, fms, next, tmp) {
+               RTE_TAILQ_FOREACH_SAFE(legacy_fm, fms, next, tmp) {
                        fm = &legacy_fm->fm;
                        if (mlx5_flow_meter_params_flush(dev, fm, 0))
                                return -rte_mtr_error_set(error, EINVAL,