rte_bitmap.h(3)
π NAME π
rte_bitmap.h β the DPDK bitmap header, aka the rte_bitmap.h(3) manual page, bestie. Yes, weβre doing bits today. π
β¨ SYNOPSIS β¨
Includes first, because obviously:
#include <string.h>
#include <rte_common.h>
#include <rte_config.h>
#include <rte_debug.h>
#include <rte_memory.h>
#include <rte_branch_prediction.h>
#include <rte_prefetch.h>
π§Έ Data Structures π§Έ
struct rte_bitmapβ the whole bitmap vibe, main character energy.
π οΈ Functions π οΈ
static uint32_t rte_bitmap_get_memory_footprint (uint32_t n_bits)
static struct rte_bitmap * rte_bitmap_init (uint32_t n_bits, uint8_t *mem, uint32_t mem_size)
static void __rte_bitmap_clear_slab_overhead_bits (uint64_t *slabs, uint32_t slab_size, uint32_t pos)
static struct rte_bitmap * rte_bitmap_init_with_all_set (uint32_t n_bits, uint8_t *mem, uint32_t mem_size)
static void rte_bitmap_free (struct rte_bitmap *bmp)
static void rte_bitmap_reset (struct rte_bitmap *bmp)
static void rte_bitmap_prefetch0 (struct rte_bitmap *bmp, uint32_t pos)
static uint64_t rte_bitmap_get (struct rte_bitmap *bmp, uint32_t pos)
static void rte_bitmap_set (struct rte_bitmap *bmp, uint32_t pos)
static void rte_bitmap_set_slab (struct rte_bitmap *bmp, uint32_t pos, uint64_t slab)
static void rte_bitmap_clear (struct rte_bitmap *bmp, uint32_t pos)
static int rte_bitmap_scan (struct rte_bitmap *bmp, uint32_t *pos, uint64_t *slab)
π Detailed Description π
Okay so RTE Bitmap is the whole moment here. π
The bitmap component gives you a mechanism to manage large arrays of bits through bit get/set/clear and bit array scan operations. Itβs giving βI have a lot of bits and I need them organized.β
The bitmap scan operation is optimized for 64-bit CPUs using 64/128 byte cache lines. The bitmap is hierarchically organized using two arrays (array1 and array2), with each bit in array1 being associated with a full cache line (512/1024 bits) of bitmap bits, which are stored in array2: the bit in array1 is set only when there is at least one bit set within its associated array2 bits, otherwise the bit in array1 is cleared. The read and write operations for array1 and array2 are always done in slabs of 64 bits. Slay, hierarchy. π§
Bestie, listen: this bitmap is not thread safe. Not even a little. Periodt. π
For lock free operation on a specific bitmap instance, a single writer thread performing bit set/clear operations is allowed, only the writer thread can do bitmap scan operations, while there can be several reader threads performing bit get operations in parallel with the writer thread. When the use of locking primitives is acceptable, the serialization of the bit set/clear and bitmap scan operations needs to be enforced by the caller, while the bit get operation does not require locking the bitmap.
Definition in file rte_bitmap.h.
π§ Function Documentation π§
static uint32_t rte_bitmap_get_memory_footprint (uint32_t n_bits) [inline], [static]
Bitmap memory footprint calculation. Basically βhow much memory does this bit situation need?β πΈ
n_bitsβ number of bits in the bitmap.
Returns: bitmap memory footprint measured in bytes on success, 0 on error.
Definition at line 148 of file rte_bitmap.h.
static struct rte_bitmap* rte_bitmap_init (uint32_t n_bits, uint8_t * mem, uint32_t mem_size) [inline], [static]
Bitmap initialization. Set the whole thing up, bestie. β¨
n_bitsβ number of pre-allocated bits inarray2.memβ base address ofarray1andarray2.mem_sizeβ minimum expected size of bitmap.
Returns: handle to bitmap instance.
Definition at line 170 of file rte_bitmap.h.
static void __rte_bitmap_clear_slab_overhead_bits (uint64_t * slabs, uint32_t slab_size, uint32_t pos) [inline], [static]
Bitmap clear slab overhead bits. Cleanup era. π§Ή
slabsβ slab array.slab_sizeβ number of 64-bit slabs in theslabsarray.posβ the start bit position in theslabsto be cleared.
Definition at line 216 of file rte_bitmap.h.
static struct rte_bitmap* rte_bitmap_init_with_all_set (uint32_t n_bits, uint8_t * mem, uint32_t mem_size) [inline], [static]
Bitmap initialization with all bits set. Everything on from the jump. π₯
n_bitsβ number of pre-allocated bits inarray2.memβ base address ofarray1andarray2.mem_sizeβ minimum expected size of bitmap.
Returns: handle to bitmap instance.
Definition at line 246 of file rte_bitmap.h.
static void rte_bitmap_free (struct rte_bitmap * bmp) [inline], [static]
Bitmap free. But plot twist: this function does nothing in current implementation. π Literally nothing. Not me expecting a free. π
bmpβ handle to bitmap instance.
Definition at line 291 of file rte_bitmap.h.
static void rte_bitmap_reset (struct rte_bitmap * bmp) [inline], [static]
Bitmap reset. Fresh start energy. π
bmpβ handle to bitmap instance.
Definition at line 303 of file rte_bitmap.h.
static void rte_bitmap_prefetch0 (struct rte_bitmap * bmp, uint32_t pos) [inline], [static]
Bitmap location prefetch into CPU L1 cache. Get it into the cache early, iykyk. π§ β¨
bmpβ handle to bitmap instance.posβ bit position.
Definition at line 319 of file rte_bitmap.h.
static uint64_t rte_bitmap_get (struct rte_bitmap * bmp, uint32_t pos) [inline], [static]
Bitmap bit get. Read the vibe of one bit. π
bmpβ handle to bitmap instance.posβ bit position.
Returns: 0 when bit is cleared, non-zero when bit is set.
Definition at line 340 of file rte_bitmap.h.
static void rte_bitmap_set (struct rte_bitmap * bmp, uint32_t pos) [inline], [static]
Bitmap bit set. Turn that bit on. π‘
bmpβ handle to bitmap instance.posβ bit position.
Definition at line 360 of file rte_bitmap.h.
static void rte_bitmap_set_slab (struct rte_bitmap * bmp, uint32_t pos, uint64_t slab) [inline], [static]
Bitmap slab set. Whole 64-bit slab gets the assignment. π
bmpβ handle to bitmap instance.posβ bit position identifying thearray2slab.slabβ value to be assigned to the 64-bit slab inarray2.
Definition at line 388 of file rte_bitmap.h.
static void rte_bitmap_clear (struct rte_bitmap * bmp, uint32_t pos) [inline], [static]
Bitmap bit clear. Turn that bit off. π«Ά
bmpβ handle to bitmap instance.posβ bit position.
Definition at line 453 of file rte_bitmap.h.
static int rte_bitmap_scan (struct rte_bitmap * bmp, uint32_t * pos, uint64_t * slab) [inline], [static]
Bitmap scan (with automatic wrap-around). This is the main character scan operation. π
bmpβ handle to bitmap instance.posβ when function call returns1,poscontains the position of the next set bit, otherwise not modified.slabβ when function call returns1,slabcontains the value of the entire 64-bit slab where the bit indicated byposis located. Slabs are always 64-bit aligned, so the position of the first bit of the slab (this bit is not necessarily set) ispos / 64. Once a slab has been returned by the bitmap scan operation, the internal pointers of the bitmap are updated to point after this slab, so the same slab will not be returned again if it contains more than one bit which is set. When function call returns0,slabis not modified.
Returns: 0 if there is no bit set in the bitmap, 1 otherwise.
Definition at line 562 of file rte_bitmap.h.
πΈ Author πΈ
Generated automatically by Doxygen for DPDK from the source code. No cap, thatβs the author situation. π«‘
mwah π β DPDK version 25.11.0, dated Fri Jan 30 2026, and this whole glow-up is for the rte_bitmap.h(3) manual page. Youβre welcome, bestie. πβ¨π
π¦ where this page comes from
- centos-stream 9: dpdk-devel 2:25.11-1.el9 Β· BSD and LGPLv2 and GPLv2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms