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

Function dlb2_bitmap_alloc

dpdk/drivers/event/dlb2/pf/base/dlb2_osdep_bitmap.h:41–80  ·  view source on GitHub ↗

* dlb2_bitmap_alloc() - alloc a bitmap data structure * @bitmap: pointer to dlb2_bitmap structure pointer. * @len: number of entries in the bitmap. * * This function allocates a bitmap and initializes it with length @len. All * entries are initially zero. * * Return: * Returns 0 upon success, < 0 otherwise. * * Errors: * EINVAL - bitmap is NULL or len is 0. * ENOMEM - could not allocat

Source from the content-addressed store, hash-verified

39 * ENOMEM - could not allocate memory for the bitmap data structure.
40 */
41static inline int dlb2_bitmap_alloc(struct dlb2_bitmap **bitmap,
42 unsigned int len)
43{
44 struct dlb2_bitmap *bm;
45 void *mem;
46 uint32_t alloc_size;
47 uint32_t nbits = (uint32_t)len;
48
49 if (bitmap == NULL || nbits == 0)
50 return -EINVAL;
51
52 /* Allocate DLB2 bitmap control struct */
53 bm = rte_malloc("DLB2_PF",
54 sizeof(struct dlb2_bitmap),
55 RTE_CACHE_LINE_SIZE);
56
57 if (bm == NULL)
58 return -ENOMEM;
59
60 /* Allocate bitmap memory */
61 alloc_size = rte_bitmap_get_memory_footprint(nbits);
62 mem = rte_malloc("DLB2_PF_BITMAP", alloc_size, RTE_CACHE_LINE_SIZE);
63 if (mem == NULL) {
64 rte_free(bm);
65 return -ENOMEM;
66 }
67
68 bm->map = rte_bitmap_init(len, mem, alloc_size);
69 if (bm->map == NULL) {
70 rte_free(mem);
71 rte_free(bm);
72 return -ENOMEM;
73 }
74
75 bm->len = len;
76
77 *bitmap = bm;
78
79 return 0;
80}
81
82/**
83 * dlb2_bitmap_free() - free a previously allocated bitmap data structure

Callers 1

dlb2_resource_initFunction · 0.85

Calls 4

rte_mallocFunction · 0.85
rte_freeFunction · 0.85
rte_bitmap_initFunction · 0.85

Tested by

no test coverage detected