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

Function _mlx5_ipool_malloc_cache

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

Source from the content-addressed store, hash-verified

404
405
406static void *
407_mlx5_ipool_malloc_cache(struct mlx5_indexed_pool *pool, int cidx,
408 uint32_t *idx)
409{
410 if (unlikely(!pool->cache[cidx])) {
411 pool->cache[cidx] = pool->cfg.malloc(MLX5_MEM_ZERO,
412 sizeof(struct mlx5_ipool_per_lcore) +
413 (pool->cfg.per_core_cache * sizeof(uint32_t)),
414 RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
415 if (!pool->cache[cidx]) {
416 DRV_LOG(ERR, "Ipool cache%d allocate failed\n", cidx);
417 return NULL;
418 }
419 } else if (pool->cache[cidx]->len) {
420 pool->cache[cidx]->len--;
421 *idx = pool->cache[cidx]->idx[pool->cache[cidx]->len];
422 return _mlx5_ipool_get_cache(pool, cidx, *idx);
423 }
424 /* Not enough idx in global cache. Keep fetching from global. */
425 *idx = mlx5_ipool_allocate_from_global(pool, cidx);
426 if (unlikely(!(*idx)))
427 return NULL;
428 return _mlx5_ipool_get_cache(pool, cidx, *idx);
429}
430
431static void *
432mlx5_ipool_malloc_cache(struct mlx5_indexed_pool *pool, uint32_t *idx)

Callers 1

mlx5_ipool_malloc_cacheFunction · 0.85

Calls 2

_mlx5_ipool_get_cacheFunction · 0.85

Tested by

no test coverage detected