rte_fbarray.h(3)
๐ rte_fbarray.h ๐
okay so bestie, welcome to the <rte_fbarray.h> glow-up โจ this is a manual page, it lives in section 3, and it's all about a file-backed shared indexed array for DPDK. yes that's a mouthful. no we're not skipping a single detail. let's get into it ๐ซถ
๐ธ SYNOPSIS ๐ธ
#include <stdio.h>
#include <rte_rwlock.h>
โจ Functions
int rte_fbarray_init (struct rte_fbarray *arr, const char *name, unsigned int len, unsigned int elt_sz)
int rte_fbarray_attach (struct rte_fbarray *arr)
int rte_fbarray_destroy (struct rte_fbarray *arr)
int rte_fbarray_detach (struct rte_fbarray *arr)
void * rte_fbarray_get (const struct rte_fbarray *arr, unsigned int idx)
int rte_fbarray_find_idx (const struct rte_fbarray *arr, const void *elt)
int rte_fbarray_set_used (struct rte_fbarray *arr, unsigned int idx)
int rte_fbarray_set_free (struct rte_fbarray *arr, unsigned int idx)
int rte_fbarray_is_used (struct rte_fbarray *arr, unsigned int idx)
int rte_fbarray_find_next_free (struct rte_fbarray *arr, unsigned int start)
int rte_fbarray_find_next_used (struct rte_fbarray *arr, unsigned int start)
int rte_fbarray_find_next_n_free (struct rte_fbarray *arr, unsigned int start, unsigned int n)
int rte_fbarray_find_next_n_used (struct rte_fbarray *arr, unsigned int start, unsigned int n)
int rte_fbarray_find_contig_free (struct rte_fbarray *arr, unsigned int start)
int rte_fbarray_find_contig_used (struct rte_fbarray *arr, unsigned int start)
int rte_fbarray_find_prev_free (struct rte_fbarray *arr, unsigned int start)
int rte_fbarray_find_prev_used (struct rte_fbarray *arr, unsigned int start)
int rte_fbarray_find_prev_n_free (struct rte_fbarray *arr, unsigned int start, unsigned int n)
int rte_fbarray_find_prev_n_used (struct rte_fbarray *arr, unsigned int start, unsigned int n)
int rte_fbarray_find_rev_contig_free (struct rte_fbarray *arr, unsigned int start)
int rte_fbarray_find_rev_contig_used (struct rte_fbarray *arr, unsigned int start)
int rte_fbarray_find_biggest_free (struct rte_fbarray *arr, unsigned int start)
int rte_fbarray_find_biggest_used (struct rte_fbarray *arr, unsigned int start)
int rte_fbarray_find_rev_biggest_free (struct rte_fbarray *arr, unsigned int start)
int rte_fbarray_find_rev_biggest_used (struct rte_fbarray *arr, unsigned int start)
void rte_fbarray_dump_metadata (struct rte_fbarray *arr, FILE *f)
๐ฆ Detailed Description ๐ฆ
File-backed shared indexed array for DPDK. ๐ that's the whole vibe. it's an array, it's indexed, it's backed by a file, and it's shared. iconic behavior fr fr.
the basic workflow, bestie ๐
this is the expected flow and honestly it's giving main character energy:
- allocate the array, either with
rte_fbarray_init()or withrte_fbarray_attach()โ which one depends on whether it's shared between multiple DPDK processes or not ๐ค - find free spots using
rte_fbarray_find_next_free() - get a pointer to the data in that free spot using
rte_fbarray_get(), then copy your data into the pointer (element size is fixed, no cap ๐งข) - mark the entry as used using
rte_fbarray_set_used()
โ ๏ธ the "who gets affected" lore
calls torte_fbarray_init()andrte_fbarray_destroy()will have consequences for all processes, while calls torte_fbarray_attach()andrte_fbarray_detach()will only have consequences within a single process.
so like โ it is safe to call rte_fbarray_attach() or rte_fbarray_detach() while another process is using rte_fbarray, provided no other thread within the same process will try to use rte_fbarray before attaching or after detaching. read that twice, bestie, it's a whole condition.
and it is not safe to call rte_fbarray_init() or rte_fbarray_destroy() while another thread or another process is using rte_fbarray. like. do not do that. that's the danger zone ๐
Definition in file rte_fbarray.h.
๐ Function Documentation ๐
int rte_fbarray_init (struct rte_fbarray * arr, const char * name, unsigned int len, unsigned int elt_sz)
Set up rte_fbarray structure and allocate underlying resources. โจ
call this function to correctly set up rte_fbarray and allocate the underlying files that will be backing the data in the current process. lowkey important: in order to use and share rte_fbarray between multiple processes, the data pointed to by the arr pointer must itself be allocated in shared memory. don't forget that part ๐ซถ
Parameters
arrโ valid pointer to allocatedrte_fbarraystructure.nameโ unique name to be assigned to this array.lenโ number of elements initially available in the array.elt_szโ size of each element.
Returns
0on success ๐-1on failure, withrte_errnoindicating reason for failure ๐ญ
int rte_fbarray_attach (struct rte_fbarray * arr)
Attach to a file backing an already allocated and correctly set up rte_fbarray structure. ๐ง
call this function to attach to the file that will be backing the data in the current process. the structure must have been previously correctly set up with a call to rte_fbarray_init(). calls to rte_fbarray_attach() are usually meant to be performed in a multiprocessing scenario, with the data pointed to by the arr pointer allocated in shared memory. multiprocessing moment fr fr ๐ฅ
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.
Returns
0on success ๐-1on failure, withrte_errnoindicating reason for failure ๐ญ
int rte_fbarray_destroy (struct rte_fbarray * arr)
Deallocate resources for an already allocated and correctly set up rte_fbarray structure, and remove the underlying file. ๐ซฃ
call this function to deallocate all resources associated with an rte_fbarray structure within the current process. it will also zero-fill the data pointed to by the arr pointer and remove the underlying file backing the data, so it is expected that by the time this function is called, all other processes have detached from this rte_fbarray. like, all of them. everybody out. periodt ๐
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.
Returns
0on success ๐-1on failure, withrte_errnoindicating reason for failure ๐ญ
int rte_fbarray_detach (struct rte_fbarray * arr)
Deallocate resources for an already allocated and correctly set up rte_fbarray structure. ๐
call this function to deallocate all resources associated with an rte_fbarray structure within the current process. (note the difference from rte_fbarray_destroy() โ this one is just you, bestie, not the whole group chat ๐)
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.
Returns
0on success ๐-1on failure, withrte_errnoindicating reason for failure ๐ญ
void * rte_fbarray_get (const struct rte_fbarray * arr, unsigned int idx)
Get pointer to element residing at specified index. ๐
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.idxโ index of an element to get a pointer to.
Returns
- non-
NULLpointer on success ๐ NULLon failure, withrte_errnoindicating reason for failure ๐ญ
int rte_fbarray_find_idx (const struct rte_fbarray * arr, const void * elt)
Find index of a specified element within the array. ๐
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.eltโ pointer to element to find index to.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure ๐ญ
int rte_fbarray_set_used (struct rte_fbarray * arr, unsigned int idx)
Mark specified element as used. โ
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.idxโ element index to mark as used.
Returns
0on success ๐-1on failure, withrte_errnoindicating reason for failure ๐ญ
int rte_fbarray_set_free (struct rte_fbarray * arr, unsigned int idx)
Mark specified element as free. ๐๏ธ
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.idxโ element index to mark as free.
Returns
0on success ๐-1on failure, withrte_errnoindicating reason for failure ๐ญ
int rte_fbarray_is_used (struct rte_fbarray * arr, unsigned int idx)
Check whether element at specified index is marked as used. ๐ vibe check on that index
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.idxโ element index to check as used.
Returns
1if element is used0if element is unused-1on failure, withrte_errnoindicating reason for failure ๐ญ
int rte_fbarray_find_next_free (struct rte_fbarray * arr, unsigned int start)
Find index of next free element, starting at specified index. ๐ธ
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.startโ element index to start search from.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure ๐ญ
int rte_fbarray_find_next_used (struct rte_fbarray * arr, unsigned int start)
Find index of next used element, starting at specified index. ๐ธ
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.startโ element index to start search from.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure ๐ญ
int rte_fbarray_find_next_n_free (struct rte_fbarray * arr, unsigned int start, unsigned int n)
Find index of next chunk of n free elements, starting at specified index. ๐
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.startโ element index to start search from.nโ number of free elements to look for.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure ๐ญ
int rte_fbarray_find_next_n_used (struct rte_fbarray * arr, unsigned int start, unsigned int n)
Find index of next chunk of n used elements, starting at specified index. ๐
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.startโ element index to start search from.nโ number of used elements to look for.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure ๐ญ
int rte_fbarray_find_contig_free (struct rte_fbarray * arr, unsigned int start)
Find how many more free entries there are, starting at specified index. ๐งฎ
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.startโ element index to start search from.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure ๐ญ
int rte_fbarray_find_contig_used (struct rte_fbarray * arr, unsigned int start)
Find how many more used entries there are, starting at specified index. ๐งฎ
Parameters
arrโ valid pointer to allocated and correctly set uprte_fbarraystructure.startโ element index to start search from.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure ๐ญ
and that's only part 1, bestie โ there's more coming, don't go anywhere ๐ซถ
๐ธ rte_fbarray_find_prev_free ๐ธ
int rte_fbarray_find_prev_free (struct rte_fbarray * arr, unsigned int start)
okay so bestie, imagine you're scrolling backwards through the array โ this one finds the index of the previous free element, starting at the index you give it. Going up, not down. ๐
Parameters
arrโ valid pointer to an allocated and correctly set uprte_fbarraystructure. (yes it needs to be set up properly, we've been over this ๐ซถ)startโ element index to start the search from.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnotelling you why it failed. ๐ญ
๐ฆ rte_fbarray_find_prev_used ๐ฆ
int rte_fbarray_find_prev_used (struct rte_fbarray * arr, unsigned int start)
Same energy as above but for used elements โ finds the index of the previous used one, starting at the index you pass in. ๐
Parameters
arrโ valid pointer to an allocated and correctly set uprte_fbarraystructure.startโ element index to start the search from.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating the reason for failure. ๐
๐ rte_fbarray_find_prev_n_free ๐
int rte_fbarray_find_prev_n_free (struct rte_fbarray * arr, unsigned int start, unsigned int n)
This one is giving chunk energy: it finds the lowest start index of a chunk of n free elements, going down from the specified index. So you're not looking for one lil spot, you're looking for a whole squad of them. ๐
Parameters
arrโ valid pointer to an allocated and correctly set uprte_fbarraystructure.startโ element index to start the search from.nโ number of free elements to look for.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure. ๐ญ
๐ rte_fbarray_find_prev_n_used ๐
int rte_fbarray_find_prev_n_used (struct rte_fbarray * arr, unsigned int start, unsigned int n)
Fr fr the used-version of the last one โ finds the lowest start index of a chunk of n used elements, down from the specified index. ๐
Parameters
arrโ valid pointer to an allocated and correctly set uprte_fbarraystructure.startโ element index to start the search from.nโ number of used elements to look for.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure. ๐
๐ง rte_fbarray_find_rev_contig_free ๐ง
int rte_fbarray_find_rev_contig_free (struct rte_fbarray * arr, unsigned int start)
Find how many more free entries there are before the specified index โ literally like rte_fbarray_find_contig_free but going in reverse. Rewind-core. โช
Parameters
arrโ valid pointer to an allocated and correctly set uprte_fbarraystructure.startโ element index to start the search from.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure. ๐ญ
๐ rte_fbarray_find_rev_contig_used ๐
int rte_fbarray_find_rev_contig_used (struct rte_fbarray * arr, unsigned int start)
Find how many more used entries there are before the specified index โ like rte_fbarray_find_contig_used but going in reverse. Same vibe, opposite direction. ๐
Parameters
arrโ valid pointer to an allocated and correctly set uprte_fbarraystructure.startโ element index to start the search from.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure. ๐
โจ rte_fbarray_find_biggest_free โจ
int rte_fbarray_find_biggest_free (struct rte_fbarray * arr, unsigned int start)
Not me finding the biggest chunk of free elements for you ๐ โ it returns the index of the biggest chunk of free elements, starting at the specified index. Main character chunk energy only.
Parameters
arrโ valid pointer to an allocated and correctly set uprte_fbarraystructure.startโ element index to start the search from.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure. ๐ญ
๐ฅ rte_fbarray_find_biggest_used ๐ฅ
int rte_fbarray_find_biggest_used (struct rte_fbarray * arr, unsigned int start)
Find the index of the biggest chunk of used elements, starting at the specified index. Yup, biggest, not just any. No half-measures here bestie. ๐
Parameters
arrโ valid pointer to an allocated and correctly set uprte_fbarraystructure.startโ element index to start the search from.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure. ๐
๐ rte_fbarray_find_rev_biggest_free ๐
int rte_fbarray_find_rev_biggest_free (struct rte_fbarray * arr, unsigned int start)
Find the index of the biggest chunk of free elements before a specified index โ like rte_fbarray_find_biggest_free, but going in reverse. ๐ซถ
Parameters
arrโ valid pointer to an allocated and correctly set uprte_fbarraystructure.startโ element index to start the search from.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure. ๐ญ
๐ฆ rte_fbarray_find_rev_biggest_used ๐ฆ
int rte_fbarray_find_rev_biggest_used (struct rte_fbarray * arr, unsigned int start)
Find the index of the biggest chunk of used elements before a specified index โ like rte_fbarray_find_biggest_used, but going in reverse. Backwards but make it iconic. ๐
Parameters
arrโ valid pointer to an allocated and correctly set uprte_fbarraystructure.startโ element index to start the search from.
Returns
- non-negative integer on success โจ
-1on failure, withrte_errnoindicating reason for failure. ๐
๐ rte_fbarray_dump_metadata ๐
void rte_fbarray_dump_metadata (struct rte_fbarray * arr, FILE * f)
Dump rte_fbarray metadata. Just... spill all the tea into a file. ๐ต (It returns nothing โ void โ it just does the thing.)
Parameters
arrโ valid pointer to an allocated and correctly set uprte_fbarraystructure.fโ file object to dump the information into.
๐ Author ๐
Generated automatically by Doxygen for DPDK from the source code. (Not a human, not a bestie, just Doxygen doing its lil automated thing. Respect the machine. ๐คโจ)
okay that's the whole thing, we ate and left no crumbs ๐
this was DPDK, Version 25.11.3, and you've been reading rte_fbarray.h(3) โ go forth and free your elements, queen. ๐๐๐
๐ฆ where this page comes from
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 ยท BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms