#include <rte_malloc.h>
#include <rte_hash_crc.h>
+#include <mlx5_malloc.h>
+
#include "mlx5_utils.h"
struct mlx5_hlist *
alloc_size = sizeof(struct mlx5_hlist) +
sizeof(struct mlx5_hlist_head) * act_size;
/* Using zmalloc, then no need to initialize the heads. */
- h = rte_zmalloc(name, alloc_size, RTE_CACHE_LINE_SIZE);
+ h = mlx5_malloc(MLX5_MEM_ZERO, alloc_size, RTE_CACHE_LINE_SIZE,
+ SOCKET_ID_ANY);
if (!h) {
DRV_LOG(ERR, "No memory for hash list %s creation",
name ? name : "None");
if (cb)
cb(entry, ctx);
else
- rte_free(entry);
+ mlx5_free(entry);
}
}
- rte_free(h);
+ mlx5_free(h);
}
static inline void
(cfg->trunk_size && ((cfg->trunk_size & (cfg->trunk_size - 1)) ||
((__builtin_ffs(cfg->trunk_size) + TRUNK_IDX_BITS) > 32))))
return NULL;
- pool = rte_zmalloc("mlx5_ipool", sizeof(*pool) + cfg->grow_trunk *
- sizeof(pool->grow_tbl[0]), RTE_CACHE_LINE_SIZE);
+ pool = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*pool) + cfg->grow_trunk *
+ sizeof(pool->grow_tbl[0]), RTE_CACHE_LINE_SIZE,
+ SOCKET_ID_ANY);
if (!pool)
return NULL;
pool->cfg = *cfg;
if (!pool->cfg.trunk_size)
pool->cfg.trunk_size = MLX5_IPOOL_DEFAULT_TRUNK_SIZE;
if (!cfg->malloc && !cfg->free) {
- pool->cfg.malloc = rte_malloc_socket;
- pool->cfg.free = rte_free;
+ pool->cfg.malloc = mlx5_malloc;
+ pool->cfg.free = mlx5_free;
}
pool->free_list = TRUNK_INVALID;
if (pool->cfg.need_lock)
int n_grow = pool->n_trunk_valid ? pool->n_trunk :
RTE_CACHE_LINE_SIZE / sizeof(void *);
- p = pool->cfg.malloc(pool->cfg.type,
- (pool->n_trunk_valid + n_grow) *
- sizeof(struct mlx5_indexed_trunk *),
- RTE_CACHE_LINE_SIZE, rte_socket_id());
+ p = pool->cfg.malloc(0, (pool->n_trunk_valid + n_grow) *
+ sizeof(struct mlx5_indexed_trunk *),
+ RTE_CACHE_LINE_SIZE, rte_socket_id());
if (!p)
return -ENOMEM;
if (pool->trunks)
/* rte_bitmap requires memory cacheline aligned. */
trunk_size += RTE_CACHE_LINE_ROUNDUP(data_size * pool->cfg.size);
trunk_size += bmp_size;
- trunk = pool->cfg.malloc(pool->cfg.type, trunk_size,
+ trunk = pool->cfg.malloc(0, trunk_size,
RTE_CACHE_LINE_SIZE, rte_socket_id());
if (!trunk)
return -ENOMEM;
if (!pool->trunks)
pool->cfg.free(pool->trunks);
mlx5_ipool_unlock(pool);
- rte_free(pool);
+ mlx5_free(pool);
return 0;
}
.grow_shift = 1,
.need_lock = 0,
.release_mem_en = 1,
- .malloc = rte_malloc_socket,
- .free = rte_free,
+ .malloc = mlx5_malloc,
+ .free = mlx5_free,
};
if (type >= MLX5_L3T_TYPE_MAX) {
rte_errno = EINVAL;
return NULL;
}
- tbl = rte_zmalloc(NULL, sizeof(struct mlx5_l3t_tbl), 1);
+ tbl = mlx5_malloc(MLX5_MEM_ZERO, sizeof(struct mlx5_l3t_tbl), 1,
+ SOCKET_ID_ANY);
if (!tbl) {
rte_errno = ENOMEM;
return NULL;
tbl->eip = mlx5_ipool_create(&l3t_ip_cfg);
if (!tbl->eip) {
rte_errno = ENOMEM;
- rte_free(tbl);
+ mlx5_free(tbl);
tbl = NULL;
}
return tbl;
break;
}
MLX5_ASSERT(!m_tbl->ref_cnt);
- rte_free(g_tbl->tbl[i]);
+ mlx5_free(g_tbl->tbl[i]);
g_tbl->tbl[i] = 0;
if (!(--g_tbl->ref_cnt))
break;
}
MLX5_ASSERT(!g_tbl->ref_cnt);
- rte_free(tbl->tbl);
+ mlx5_free(tbl->tbl);
tbl->tbl = 0;
}
mlx5_ipool_destroy(tbl->eip);
- rte_free(tbl);
+ mlx5_free(tbl);
}
uint32_t
m_tbl->tbl[(idx >> MLX5_L3T_MT_OFFSET) & MLX5_L3T_MT_MASK] =
NULL;
if (!(--m_tbl->ref_cnt)) {
- rte_free(m_tbl);
+ mlx5_free(m_tbl);
g_tbl->tbl
[(idx >> MLX5_L3T_GT_OFFSET) & MLX5_L3T_GT_MASK] = NULL;
if (!(--g_tbl->ref_cnt)) {
- rte_free(g_tbl);
+ mlx5_free(g_tbl);
tbl->tbl = 0;
}
}
/* Check the global table, create it if empty. */
g_tbl = tbl->tbl;
if (!g_tbl) {
- g_tbl = rte_zmalloc(NULL, sizeof(struct mlx5_l3t_level_tbl) +
- sizeof(void *) * MLX5_L3T_GT_SIZE, 1);
+ g_tbl = mlx5_malloc(MLX5_MEM_ZERO,
+ sizeof(struct mlx5_l3t_level_tbl) +
+ sizeof(void *) * MLX5_L3T_GT_SIZE, 1,
+ SOCKET_ID_ANY);
if (!g_tbl) {
rte_errno = ENOMEM;
return -1;
*/
m_tbl = g_tbl->tbl[(idx >> MLX5_L3T_GT_OFFSET) & MLX5_L3T_GT_MASK];
if (!m_tbl) {
- m_tbl = rte_zmalloc(NULL, sizeof(struct mlx5_l3t_level_tbl) +
- sizeof(void *) * MLX5_L3T_MT_SIZE, 1);
+ m_tbl = mlx5_malloc(MLX5_MEM_ZERO,
+ sizeof(struct mlx5_l3t_level_tbl) +
+ sizeof(void *) * MLX5_L3T_MT_SIZE, 1,
+ SOCKET_ID_ANY);
if (!m_tbl) {
rte_errno = ENOMEM;
return -1;