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

Function mlx5_flow_meter_init

dpdk/drivers/net/mlx5/mlx5_flow_hw.c:12851–13017  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12849}
12850
12851int
12852mlx5_flow_meter_init(struct rte_eth_dev *dev,
12853 uint32_t nb_meters,
12854 uint32_t nb_meter_profiles,
12855 uint32_t nb_meter_policies,
12856 uint32_t nb_queues)
12857{
12858 struct mlx5_priv *priv = dev->data->dev_private;
12859 struct mlx5_devx_obj *dcs = NULL;
12860 uint32_t log_obj_size;
12861 int ret = 0;
12862 int reg_id;
12863 struct mlx5_aso_mtr *aso;
12864 uint32_t i;
12865 struct rte_flow_error error;
12866 uint32_t flags;
12867 uint32_t nb_mtrs = rte_align32pow2(nb_meters);
12868 struct mlx5_indexed_pool_config cfg = {
12869 .size = sizeof(struct mlx5_aso_mtr),
12870 .trunk_size = 1 << 12,
12871 .per_core_cache = 1 << 13,
12872 .need_lock = 1,
12873 .release_mem_en = !!priv->sh->config.reclaim_mode,
12874 .malloc = mlx5_malloc,
12875 .max_idx = nb_meters,
12876 .free = mlx5_free,
12877 .type = "mlx5_hw_mtr_mark_action",
12878 };
12879
12880 if (!nb_meters) {
12881 ret = ENOTSUP;
12882 rte_flow_error_set(&error, ENOMEM,
12883 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
12884 NULL, "Meter configuration is invalid.");
12885 goto err;
12886 }
12887 if (!priv->mtr_en || !priv->sh->meter_aso_en) {
12888 ret = ENOTSUP;
12889 rte_flow_error_set(&error, ENOMEM,
12890 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
12891 NULL, "Meter ASO is not supported.");
12892 goto err;
12893 }
12894 priv->mtr_config.nb_meters = nb_meters;
12895 log_obj_size = rte_log2_u32(nb_meters >> 1);
12896 dcs = mlx5_devx_cmd_create_flow_meter_aso_obj
12897 (priv->sh->cdev->ctx, priv->sh->cdev->pdn,
12898 log_obj_size);
12899 if (!dcs) {
12900 ret = ENOMEM;
12901 rte_flow_error_set(&error, ENOMEM,
12902 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
12903 NULL, "Meter ASO object allocation failed.");
12904 goto err;
12905 }
12906 priv->mtr_bulk.devx_obj = dcs;
12907 reg_id = mlx5_flow_get_reg_id(dev, MLX5_MTR_COLOR, 0, NULL);
12908 if (reg_id < 0) {

Callers 1

flow_hw_configureFunction · 0.85

Calls 10

rte_flow_error_setFunction · 0.85
mlx5_flow_get_reg_idFunction · 0.85
mlx5_mallocFunction · 0.85
mlx5_aso_mtr_queue_initFunction · 0.85
mlx5_ipool_createFunction · 0.85
mlx5_flow_meter_uninitFunction · 0.85
rte_align32pow2Function · 0.50
rte_log2_u32Function · 0.50

Tested by

no test coverage detected