MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mlx5_flow_meter_find

Function mlx5_flow_meter_find

dpdk/drivers/net/mlx5/mlx5_flow_meter.c:2024–2066  ·  view source on GitHub ↗

* Find meter by id. * * @param priv * Pointer to mlx5_priv. * @param meter_id * Meter id. * @param mtr_idx * Pointer to Meter index. * * @return * Pointer to the meter info found on success, NULL otherwise. */

Source from the content-addressed store, hash-verified

2022 * Pointer to the meter info found on success, NULL otherwise.
2023 */
2024struct mlx5_flow_meter_info *
2025mlx5_flow_meter_find(struct mlx5_priv *priv, uint32_t meter_id,
2026 uint32_t *mtr_idx)
2027{
2028 struct mlx5_legacy_flow_meter *legacy_fm;
2029 struct mlx5_legacy_flow_meters *fms = &priv->flow_meters;
2030 struct mlx5_aso_mtr *aso_mtr;
2031 struct mlx5_aso_mtr_pools_mng *pools_mng =
2032 &priv->sh->mtrmng->pools_mng;
2033 union mlx5_l3t_data data;
2034 uint16_t n_valid;
2035
2036 if (priv->mtr_bulk.aso) {
2037 if (mtr_idx)
2038 *mtr_idx = meter_id;
2039 aso_mtr = priv->mtr_bulk.aso + meter_id;
2040 return &aso_mtr->fm;
2041 }
2042 if (priv->sh->meter_aso_en) {
2043 rte_rwlock_read_lock(&pools_mng->resize_mtrwl);
2044 n_valid = pools_mng->n_valid;
2045 rte_rwlock_read_unlock(&pools_mng->resize_mtrwl);
2046 if (!n_valid || !priv->mtr_idx_tbl ||
2047 (mlx5_l3t_get_entry(priv->mtr_idx_tbl, meter_id, &data) ||
2048 !data.dword))
2049 return NULL;
2050 if (mtr_idx)
2051 *mtr_idx = data.dword;
2052 aso_mtr = mlx5_aso_meter_by_idx(priv, data.dword);
2053 /* Remove reference taken by the mlx5_l3t_get_entry. */
2054 mlx5_l3t_clear_entry(priv->mtr_idx_tbl, meter_id);
2055 if (!aso_mtr || aso_mtr->state == ASO_METER_FREE)
2056 return NULL;
2057 return &aso_mtr->fm;
2058 }
2059 TAILQ_FOREACH(legacy_fm, fms, next)
2060 if (meter_id == legacy_fm->fm.meter_id) {
2061 if (mtr_idx)
2062 *mtr_idx = legacy_fm->idx;
2063 return &legacy_fm->fm;
2064 }
2065 return NULL;
2066}
2067
2068/**
2069 * Find meter by index.

Calls 3

mlx5_l3t_get_entryFunction · 0.85
mlx5_aso_meter_by_idxFunction · 0.85
mlx5_l3t_clear_entryFunction · 0.85

Tested by

no test coverage detected