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

Function mlx5_ipool_create

dpdk/drivers/net/mlx5/mlx5_utils.c:78–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78struct mlx5_indexed_pool *
79mlx5_ipool_create(struct mlx5_indexed_pool_config *cfg)
80{
81 struct mlx5_indexed_pool *pool;
82 uint32_t i;
83
84 if (!cfg || (!cfg->malloc ^ !cfg->free) ||
85 (cfg->per_core_cache && cfg->release_mem_en) ||
86 (cfg->trunk_size && ((cfg->trunk_size & (cfg->trunk_size - 1)) ||
87 ((__builtin_ffs(cfg->trunk_size) + TRUNK_IDX_BITS) > 32))))
88 return NULL;
89 pool = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*pool) + cfg->grow_trunk *
90 sizeof(pool->grow_tbl[0]), RTE_CACHE_LINE_SIZE,
91 SOCKET_ID_ANY);
92 if (!pool)
93 return NULL;
94 pool->cfg = *cfg;
95 if (!pool->cfg.trunk_size)
96 pool->cfg.trunk_size = MLX5_IPOOL_DEFAULT_TRUNK_SIZE;
97 if (!cfg->malloc && !cfg->free) {
98 pool->cfg.malloc = mlx5_malloc;
99 pool->cfg.free = mlx5_free;
100 }
101 if (pool->cfg.need_lock)
102 rte_spinlock_init(&pool->rsz_lock);
103 /*
104 * Initialize the dynamic grow trunk size lookup table to have a quick
105 * lookup for the trunk entry index offset.
106 */
107 for (i = 0; i < cfg->grow_trunk; i++) {
108 pool->grow_tbl[i] = cfg->trunk_size << (cfg->grow_shift * i);
109 if (i > 0)
110 pool->grow_tbl[i] += pool->grow_tbl[i - 1];
111 }
112 if (!pool->cfg.max_idx)
113 pool->cfg.max_idx =
114 mlx5_trunk_idx_offset_get(pool, TRUNK_MAX_IDX + 1);
115 if (!cfg->per_core_cache)
116 pool->free_list = TRUNK_INVALID;
117 rte_spinlock_init(&pool->lcore_lock);
118 return pool;
119}
120
121static int
122mlx5_ipool_grow(struct mlx5_indexed_pool *pool)

Callers 12

mlx5_quota_init_hostFunction · 0.85
flow_dv_modify_ipool_getFunction · 0.85
mlx5_hws_age_pool_initFunction · 0.85
mlx5_flow_meter_createFunction · 0.85
mlx5_flow_ipool_createFunction · 0.85
flow_hw_table_createFunction · 0.85
flow_hw_ct_pool_createFunction · 0.85
flow_hw_configureFunction · 0.85
mlx5_flow_meter_initFunction · 0.85
mlx5_l3t_createFunction · 0.85
mlx5_dev_spawnFunction · 0.85
mlx5_dev_spawnFunction · 0.85

Calls 3

mlx5_mallocFunction · 0.85
rte_spinlock_initFunction · 0.85

Tested by

no test coverage detected