.TH "rte_fbarray.h" 3 "Version 25.11.0" "DPDK" \" -*- nroff -*-
.ad l
.nh
.SH NAME
rte_fbarray.h
.SH SYNOPSIS
.br
.PP
\fR#include <stdio\&.h>\fP
.br
\fR#include <rte_rwlock\&.h>\fP
.br

.SS "Functions"

.in +1c
.ti -1c
.RI "int \fBrte_fbarray_init\fP (struct rte_fbarray *arr, const char *name, unsigned int len, unsigned int elt_sz)"
.br
.ti -1c
.RI "int \fBrte_fbarray_attach\fP (struct rte_fbarray *arr)"
.br
.ti -1c
.RI "int \fBrte_fbarray_destroy\fP (struct rte_fbarray *arr)"
.br
.ti -1c
.RI "int \fBrte_fbarray_detach\fP (struct rte_fbarray *arr)"
.br
.ti -1c
.RI "void * \fBrte_fbarray_get\fP (const struct rte_fbarray *arr, unsigned int idx)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_idx\fP (const struct rte_fbarray *arr, const void *elt)"
.br
.ti -1c
.RI "int \fBrte_fbarray_set_used\fP (struct rte_fbarray *arr, unsigned int idx)"
.br
.ti -1c
.RI "int \fBrte_fbarray_set_free\fP (struct rte_fbarray *arr, unsigned int idx)"
.br
.ti -1c
.RI "int \fBrte_fbarray_is_used\fP (struct rte_fbarray *arr, unsigned int idx)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_next_free\fP (struct rte_fbarray *arr, unsigned int start)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_next_used\fP (struct rte_fbarray *arr, unsigned int start)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_next_n_free\fP (struct rte_fbarray *arr, unsigned int start, unsigned int n)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_next_n_used\fP (struct rte_fbarray *arr, unsigned int start, unsigned int n)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_contig_free\fP (struct rte_fbarray *arr, unsigned int start)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_contig_used\fP (struct rte_fbarray *arr, unsigned int start)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_prev_free\fP (struct rte_fbarray *arr, unsigned int start)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_prev_used\fP (struct rte_fbarray *arr, unsigned int start)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_prev_n_free\fP (struct rte_fbarray *arr, unsigned int start, unsigned int n)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_prev_n_used\fP (struct rte_fbarray *arr, unsigned int start, unsigned int n)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_rev_contig_free\fP (struct rte_fbarray *arr, unsigned int start)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_rev_contig_used\fP (struct rte_fbarray *arr, unsigned int start)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_biggest_free\fP (struct rte_fbarray *arr, unsigned int start)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_biggest_used\fP (struct rte_fbarray *arr, unsigned int start)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_rev_biggest_free\fP (struct rte_fbarray *arr, unsigned int start)"
.br
.ti -1c
.RI "int \fBrte_fbarray_find_rev_biggest_used\fP (struct rte_fbarray *arr, unsigned int start)"
.br
.ti -1c
.RI "void \fBrte_fbarray_dump_metadata\fP (struct rte_fbarray *arr, FILE *f)"
.br
.in -1c
.SH "Detailed Description"
.PP 
File-backed shared indexed array for DPDK\&.

.PP
Basic workflow is expected to be the following: 1) Allocate array either using \fR\fBrte_fbarray_init()\fP\fP or \fR\fBrte_fbarray_attach()\fP\fP (depending on whether it's shared between multiple DPDK processes) 2) find free spots using \fR\fBrte_fbarray_find_next_free()\fP\fP 3) get pointer to data in the free spot using \fR\fBrte_fbarray_get()\fP\fP, and copy data into the pointer (element size is fixed) 4) mark entry as used using \fR\fBrte_fbarray_set_used()\fP\fP

.PP
Calls to \fR\fBrte_fbarray_init()\fP\fP and \fR\fBrte_fbarray_destroy()\fP\fP will have consequences for all processes, while calls to \fR\fBrte_fbarray_attach()\fP\fP and \fR\fBrte_fbarray_detach()\fP\fP will only have consequences within a single process\&. Therefore, it is safe to call \fR\fBrte_fbarray_attach()\fP\fP or \fR\fBrte_fbarray_detach()\fP\fP while another process is using \fRrte_fbarray\fP, provided no other thread within the same process will try to use \fRrte_fbarray\fP before attaching or after detaching\&. It is not safe to call \fR\fBrte_fbarray_init()\fP\fP or \fR\fBrte_fbarray_destroy()\fP\fP while another thread or another process is using \fRrte_fbarray\fP\&. 
.PP
Definition in file \fBrte_fbarray\&.h\fP\&.
.SH "Function Documentation"
.PP 
.SS "int rte_fbarray_init (struct rte_fbarray * arr, const char * name, unsigned int len, unsigned int elt_sz)"
Set up \fRrte_fbarray\fP structure and allocate underlying resources\&.

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

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated \fRrte_fbarray\fP structure\&.
.br
\fIname\fP Unique name to be assigned to this array\&.
.br
\fIlen\fP Number of elements initially available in the array\&.
.br
\fIelt_sz\fP Size of each element\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
0 on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_attach (struct rte_fbarray * arr)"
Attach to a file backing an already allocated and correctly set up \fRrte_fbarray\fP structure\&.

.PP
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 \fR\fBrte_fbarray_init()\fP\fP\&. Calls to \fR\fBrte_fbarray_attach()\fP\fP are usually meant to be performed in a multiprocessing scenario, with data pointed to by \fRarr\fP pointer allocated in shared memory\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up rte_fbarray structure\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
0 on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_destroy (struct rte_fbarray * arr)"
Deallocate resources for an already allocated and correctly set up \fRrte_fbarray\fP structure, and remove the underlying file\&.

.PP
Call this function to deallocate all resources associated with an \fRrte_fbarray\fP structure within the current process\&. This will also zero-fill data pointed to by \fRarr\fP 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 \fRrte_fbarray\fP\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
0 on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_detach (struct rte_fbarray * arr)"
Deallocate resources for an already allocated and correctly set up \fRrte_fbarray\fP structure\&.

.PP
Call this function to deallocate all resources associated with an \fRrte_fbarray\fP structure within current process\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
0 on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "void * rte_fbarray_get (const struct rte_fbarray * arr, unsigned int idx)"
Get pointer to element residing at specified index\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIidx\fP Index of an element to get a pointer to\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-NULL pointer on success\&.
.IP "\(bu" 2
NULL on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_idx (const struct rte_fbarray * arr, const void * elt)"
Find index of a specified element within the array\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIelt\fP Pointer to element to find index to\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_set_used (struct rte_fbarray * arr, unsigned int idx)"
Mark specified element as used\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIidx\fP Element index to mark as used\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
0 on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_set_free (struct rte_fbarray * arr, unsigned int idx)"
Mark specified element as free\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIidx\fP Element index to mark as free\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
0 on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_is_used (struct rte_fbarray * arr, unsigned int idx)"
Check whether element at specified index is marked as used\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIidx\fP Element index to check as used\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
1 if element is used\&.
.IP "\(bu" 2
0 if element is unused\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_next_free (struct rte_fbarray * arr, unsigned int start)"
Find index of next free element, starting at specified index\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_next_used (struct rte_fbarray * arr, unsigned int start)"
Find index of next used element, starting at specified index\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_next_n_free (struct rte_fbarray * arr, unsigned int start, unsigned int n)"
Find index of next chunk of \fRn\fP free elements, starting at specified index\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.br
\fIn\fP Number of free elements to look for\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_next_n_used (struct rte_fbarray * arr, unsigned int start, unsigned int n)"
Find index of next chunk of \fRn\fP used elements, starting at specified index\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.br
\fIn\fP Number of used elements to look for\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "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\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "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\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_prev_free (struct rte_fbarray * arr, unsigned int start)"
Find index of previous free element, starting at specified index\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_prev_used (struct rte_fbarray * arr, unsigned int start)"
Find index of previous used element, starting at specified index\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_prev_n_free (struct rte_fbarray * arr, unsigned int start, unsigned int n)"
Find lowest start index of chunk of \fRn\fP free elements, down from specified index\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.br
\fIn\fP Number of free elements to look for\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_prev_n_used (struct rte_fbarray * arr, unsigned int start, unsigned int n)"
Find lowest start index of chunk of \fRn\fP used elements, down from specified index\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.br
\fIn\fP Number of used elements to look for\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_rev_contig_free (struct rte_fbarray * arr, unsigned int start)"
Find how many more free entries there are before specified index (like \fR\fBrte_fbarray_find_contig_free\fP\fP but going in reverse)\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_rev_contig_used (struct rte_fbarray * arr, unsigned int start)"
Find how many more used entries there are before specified index (like \fR\fBrte_fbarray_find_contig_used\fP\fP but going in reverse)\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_biggest_free (struct rte_fbarray * arr, unsigned int start)"
Find index of biggest chunk of free elements, starting at specified index\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_biggest_used (struct rte_fbarray * arr, unsigned int start)"
Find index of biggest chunk of used elements, starting at specified index\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_rev_biggest_free (struct rte_fbarray * arr, unsigned int start)"
Find index of biggest chunk of free elements before a specified index (like \fR\fBrte_fbarray_find_biggest_free\fP\fP, but going in reverse)\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "int rte_fbarray_find_rev_biggest_used (struct rte_fbarray * arr, unsigned int start)"
Find index of biggest chunk of used elements before a specified index (like \fR\fBrte_fbarray_find_biggest_used\fP\fP, but going in reverse)\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIstart\fP Element index to start search from\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
non-negative integer on success\&.
.IP "\(bu" 2
-1 on failure, with \fR\fBrte_errno\fP\fP indicating reason for failure\&. 
.PP
.RE
.PP

.SS "void rte_fbarray_dump_metadata (struct rte_fbarray * arr, FILE * f)"
Dump \fRrte_fbarray\fP metadata\&.

.PP
\fBParameters\fP
.RS 4
\fIarr\fP Valid pointer to allocated and correctly set up \fRrte_fbarray\fP structure\&.
.br
\fIf\fP File object to dump information into\&. 
.RE
.PP

.SH "Author"
.PP 
Generated automatically by Doxygen for DPDK from the source code\&.
