logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Author

       Generated automatically by Doxygen for DPDK from the source code.

DPDK                                             Version 24.11.2                                rte_fbarray.h(3)

Detailed Description

       File-backed shared indexed array for DPDK.

       Basic workflow is expected to be the following: 1) Allocate array either using rte_fbarray_init()orrte_fbarray_attach()(dependingonwhetherit'ssharedbetweenmultipleDPDKprocesses)2)findfreespotsusingrte_fbarray_find_next_free()3)getpointertodatainthefreespotusingrte_fbarray_get(),andcopydataintothepointer(elementsizeisfixed)4)markentryasusedusingrte_fbarray_set_used()

       Calls to rte_fbarray_init()andrte_fbarray_destroy()willhaveconsequencesforallprocesses,whilecallstorte_fbarray_attach()andrte_fbarray_detach()willonlyhaveconsequenceswithinasingleprocess.Therefore,itissafetocallrte_fbarray_attach()orrte_fbarray_detach()whileanotherprocessisusingrte_fbarray,providednootherthreadwithinthesameprocesswilltrytouserte_fbarraybeforeattachingorafterdetaching.Itisnotsafetocallrte_fbarray_init()orrte_fbarray_destroy()whileanotherthreadoranotherprocessisusingrte_fbarray.

       Definition in file rte_fbarray.h.

Function Documentation

intrte_fbarray_init(structrte_fbarray*arr,constchar*name,unsignedintlen,unsignedintelt_sz)
       Set up rte_fbarray structure and allocate underlying resources.

       Call this function to correctly set up rte_fbarray and allocate underlying files that will be backing the
       data in the current process. Note that in order to use and share rte_fbarray between multiple processes,
       data pointed to by arr pointer must itself be allocated in shared memory.

       Parametersarr 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.

   intrte_fbarray_attach(structrte_fbarray*arr)
       Attach to a file backing an already allocated and correctly set up rte_fbarray structure.

       Call  this function to attach to 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().Callstorte_fbarray_attach()areusuallymeanttobeperformedinamultiprocessingscenario,withdatapointedtobyarrpointerallocatedinsharedmemory.Parametersarr 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.

   intrte_fbarray_destroy(structrte_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. This will also zero-fill data pointed to by 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.

       Parametersarr 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.

   intrte_fbarray_detach(structrte_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  current
       process.

       Parametersarr 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(conststructrte_fbarray*arr,unsignedintidx)
       Get pointer to element residing at specified index.

       Parametersarr 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.

   intrte_fbarray_find_idx(conststructrte_fbarray*arr,constvoid*elt)
       Find index of a specified element within the array.

       Parametersarr 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.

   intrte_fbarray_set_used(structrte_fbarray*arr,unsignedintidx)
       Mark specified element as used.

       Parametersarr 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.

   intrte_fbarray_set_free(structrte_fbarray*arr,unsignedintidx)
       Mark specified element as free.

       Parametersarr 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.

   intrte_fbarray_is_used(structrte_fbarray*arr,unsignedintidx)
       Check whether element at specified index is marked as used.

       Parametersarr 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.

   intrte_fbarray_find_next_free(structrte_fbarray*arr,unsignedintstart)
       Find index of next free element, starting at specified index.

       Parametersarr 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.

   intrte_fbarray_find_next_used(structrte_fbarray*arr,unsignedintstart)
       Find index of next used element, starting at specified index.

       Parametersarr 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.

   intrte_fbarray_find_next_n_free(structrte_fbarray*arr,unsignedintstart,unsignedintn)
       Find index of next chunk of n free elements, starting at specified index.

       Parametersarr 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.

   intrte_fbarray_find_next_n_used(structrte_fbarray*arr,unsignedintstart,unsignedintn)
       Find index of next chunk of n used elements, starting at specified index.

       Parametersarr 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.

   intrte_fbarray_find_contig_free(structrte_fbarray*arr,unsignedintstart)
       Find how many more free entries there are, starting at specified index.

       Parametersarr 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.

   intrte_fbarray_find_contig_used(structrte_fbarray*arr,unsignedintstart)
       Find how many more used entries there are, starting at specified index.

       Parametersarr 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.

   intrte_fbarray_find_prev_free(structrte_fbarray*arr,unsignedintstart)
       Find index of previous free element, starting at specified index.

       Parametersarr 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.

   intrte_fbarray_find_prev_used(structrte_fbarray*arr,unsignedintstart)
       Find index of previous used element, starting at specified index.

       Parametersarr 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.

   intrte_fbarray_find_prev_n_free(structrte_fbarray*arr,unsignedintstart,unsignedintn)
       Find lowest start index of chunk of n free elements, down from specified index.

       Parametersarr 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.

   intrte_fbarray_find_prev_n_used(structrte_fbarray*arr,unsignedintstart,unsignedintn)
       Find lowest start index of chunk of n used elements, down from specified index.

       Parametersarr 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.

   intrte_fbarray_find_rev_contig_free(structrte_fbarray*arr,unsignedintstart)
       Find  how  many more free entries there are before specified index (like rte_fbarray_find_contig_free but
       going in reverse).

       Parametersarr 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.

   intrte_fbarray_find_rev_contig_used(structrte_fbarray*arr,unsignedintstart)
       Find how many more used entries there are before specified index (like  rte_fbarray_find_contig_used  but
       going in reverse).

       Parametersarr 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.

   intrte_fbarray_find_biggest_free(structrte_fbarray*arr,unsignedintstart)
       Find index of biggest chunk of free elements, starting at specified index.

       Parametersarr 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.

   intrte_fbarray_find_biggest_used(structrte_fbarray*arr,unsignedintstart)
       Find index of biggest chunk of used elements, starting at specified index.

       Parametersarr 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.

   intrte_fbarray_find_rev_biggest_free(structrte_fbarray*arr,unsignedintstart)
       Find    index    of    biggest    chunk    of    free   elements   before   a   specified   index   (like
       rte_fbarray_find_biggest_free, but going in reverse).

       Parametersarr 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.

   intrte_fbarray_find_rev_biggest_used(structrte_fbarray*arr,unsignedintstart)
       Find   index   of   biggest   chunk   of   used    elements    before    a    specified    index    (like
       rte_fbarray_find_biggest_used, but going in reverse).

       Parametersarr 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.

   voidrte_fbarray_dump_metadata(structrte_fbarray*arr,FILE*f)
       Dump rte_fbarray metadata.

       Parametersarr Valid pointer to allocated and correctly set up rte_fbarray structure.
           f File object to dump information into.

Name

       rte_fbarray.h

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)

See Also