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:

  1. allocate the array, either with rte_fbarray_init() or with rte_fbarray_attach() โ€” which one depends on whether it's shared between multiple DPDK processes or not ๐Ÿค”
  2. find free spots using rte_fbarray_find_next_free()
  3. 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 ๐Ÿงข)
  4. mark the entry as used using rte_fbarray_set_used()

โš ๏ธ the "who gets affected" lore

calls to rte_fbarray_init() and rte_fbarray_destroy() will have consequences for all processes, while calls to rte_fbarray_attach() and rte_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 allocated rte_fbarray structure.
  • 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

  • 0 on success ๐ŸŽ‰
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.

Returns

  • 0 on success ๐ŸŽ‰
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.

Returns

  • 0 on success ๐ŸŽ‰
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.

Returns

  • 0 on success ๐ŸŽ‰
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • idx โ€” index of an element to get a pointer to.

Returns

  • non-NULL pointer on success ๐Ÿ’…
  • NULL on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • elt โ€” pointer to element to find index to.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • idx โ€” element index to mark as used.

Returns

  • 0 on success ๐ŸŽ‰
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • idx โ€” element index to mark as free.

Returns

  • 0 on success ๐ŸŽ‰
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • idx โ€” element index to check as used.

Returns

  • 1 if element is used
  • 0 if element is unused
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start search from.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start search from.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start search from.
  • n โ€” number of free elements to look for.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start search from.
  • n โ€” number of used elements to look for.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start search from.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start search from.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure. (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 โœจ
  • -1 on failure, with rte_errno telling 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 up rte_fbarray structure.
  • start โ€” element index to start the search from.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start the search from.
  • n โ€” number of free elements to look for.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start the search from.
  • n โ€” number of used elements to look for.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start the search from.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start the search from.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start the search from.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start the search from.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start the search from.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • start โ€” element index to start the search from.

Returns

  • non-negative integer on success โœจ
  • -1 on failure, with rte_errno indicating 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 up rte_fbarray structure.
  • 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