* Flush meter configuration. * * @param[in] dev * Pointer to Ethernet device. * @param[out] error * Pointer to rte meter error structure. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */
| 2376 | * 0 on success, a negative errno value otherwise and rte_errno is set. |
| 2377 | */ |
| 2378 | int |
| 2379 | mlx5_flow_meter_flush(struct rte_eth_dev *dev, struct rte_mtr_error *error) |
| 2380 | { |
| 2381 | struct mlx5_priv *priv = dev->data->dev_private; |
| 2382 | struct mlx5_legacy_flow_meters *fms = &priv->flow_meters; |
| 2383 | struct mlx5_flow_meter_profile *fmp; |
| 2384 | struct mlx5_legacy_flow_meter *legacy_fm; |
| 2385 | struct mlx5_flow_meter_info *fm; |
| 2386 | struct mlx5_flow_meter_sub_policy *sub_policy; |
| 2387 | void *tmp; |
| 2388 | uint32_t i, mtr_idx, policy_idx; |
| 2389 | void *entry; |
| 2390 | struct mlx5_aso_mtr *aso_mtr; |
| 2391 | |
| 2392 | if (!priv->mtr_en) |
| 2393 | return 0; |
| 2394 | if (priv->sh->meter_aso_en) { |
| 2395 | if (mlx5_flow_meter_flush_all_hierarchies(dev, error)) |
| 2396 | return -rte_errno; |
| 2397 | if (priv->mtr_idx_tbl) { |
| 2398 | MLX5_L3T_FOREACH(priv->mtr_idx_tbl, i, entry) { |
| 2399 | mtr_idx = *(uint32_t *)entry; |
| 2400 | if (mtr_idx) { |
| 2401 | aso_mtr = |
| 2402 | mlx5_aso_meter_by_idx(priv, mtr_idx); |
| 2403 | fm = &aso_mtr->fm; |
| 2404 | (void)mlx5_flow_meter_params_flush(dev, |
| 2405 | fm, mtr_idx); |
| 2406 | } |
| 2407 | } |
| 2408 | mlx5_l3t_destroy(priv->mtr_idx_tbl); |
| 2409 | priv->mtr_idx_tbl = NULL; |
| 2410 | } |
| 2411 | } else { |
| 2412 | RTE_TAILQ_FOREACH_SAFE(legacy_fm, fms, next, tmp) { |
| 2413 | fm = &legacy_fm->fm; |
| 2414 | if (mlx5_flow_meter_params_flush(dev, fm, 0)) |
| 2415 | return -rte_mtr_error_set(error, EINVAL, |
| 2416 | RTE_MTR_ERROR_TYPE_METER_PROFILE_ID, |
| 2417 | NULL, "MTR object meter profile invalid."); |
| 2418 | } |
| 2419 | } |
| 2420 | if (priv->policy_idx_tbl) { |
| 2421 | MLX5_L3T_FOREACH(priv->policy_idx_tbl, i, entry) { |
| 2422 | policy_idx = *(uint32_t *)entry; |
| 2423 | sub_policy = mlx5_ipool_get |
| 2424 | (priv->sh->ipool[MLX5_IPOOL_MTR_POLICY], |
| 2425 | policy_idx); |
| 2426 | if (!sub_policy) |
| 2427 | return -rte_mtr_error_set(error, |
| 2428 | EINVAL, |
| 2429 | RTE_MTR_ERROR_TYPE_METER_POLICY_ID, |
| 2430 | NULL, "MTR object " |
| 2431 | "meter policy invalid."); |
| 2432 | if (__mlx5_flow_meter_policy_delete(dev, i, |
| 2433 | sub_policy->main_policy, |
| 2434 | error, true)) |
| 2435 | return -rte_mtr_error_set(error, |
no test coverage detected