FD.io VPP  v21.01.1
Vector Packet Processing
vec_bootstrap.h File Reference

Vector bootstrap header file. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vec_header_t
 vector header structure More...
 

Macros

#define VEC_NUMA_UNSPECIFIED   (0xFF)
 
#define vec_len(v)   ((v) ? _vec_len(v) : 0)
 Number of elements in vector (rvalue-only, NULL tolerant) More...
 
#define vec_numa(v)   ((v) ? _vec_numa(v) : 0)
 Return vector's NUMA ID (rvalue-only, NULL tolerant) vec_numa(v) checks for NULL, but cannot be used as an lvalue. More...
 
#define vec_bytes(v)   (vec_len (v) * sizeof (v[0]))
 Number of data bytes in vector. More...
 
#define vec_capacity(v, b)
 Total number of bytes that can fit in vector with current allocation. More...
 
#define vec_max_len(v)   (vec_capacity(v,0) / sizeof (v[0]))
 Total number of elements that can fit into vector. More...
 
#define vec_set_len(v, l)
 Set vector length to a user-defined value. More...
 
#define vec_reset_length(v)   do { if (v) vec_set_len (v, 0); } while (0)
 Reset vector length to zero NULL-pointer tolerant. More...
 
#define vec_end(v)   ((v) + vec_len (v))
 End (last data address) of vector. More...
 
#define vec_is_member(v, e)   ((e) >= (v) && (e) < vec_end (v))
 True if given pointer is within given vector. More...
 
#define vec_elt_at_index(v, i)
 Get vector value at index i checking that i is in bounds. More...
 
#define vec_elt(v, i)   (vec_elt_at_index(v,i))[0]
 Get vector value at index i. More...
 
#define vec_foreach(var, vec)   for (var = (vec); var < vec_end (vec); var++)
 Vector iterator. More...
 
#define vec_foreach_backwards(var, vec)   for (var = vec_end (vec) - 1; var >= (vec); var--)
 Vector iterator (reverse) More...
 
#define vec_foreach_index(var, v)   for ((var) = 0; (var) < vec_len (v); (var)++)
 Iterate over vector indices. More...
 
#define vec_foreach_index_backwards(var, v)   for ((var) = vec_len((v)) - 1; (var) >= 0; (var)--)
 Iterate over vector indices (reverse). More...
 

Functions

static uword vec_header_bytes (uword header_bytes)
 
static void * vec_header (void *v, uword header_bytes)
 Find a user vector header. More...
 
static void * vec_header_end (void *v, uword header_bytes)
 Find the end of user vector header. More...
 
static uword vec_aligned_header_bytes (uword header_bytes, uword align)
 
static void * vec_aligned_header (void *v, uword header_bytes, uword align)
 
static void * vec_aligned_header_end (void *v, uword header_bytes, uword align)
 
u32 vec_len_not_inline (void *v)
 
static uword vec_get_numa (void *v)
 return the NUMA index for a vector More...
 

Detailed Description

Vector bootstrap header file.

Definition in file vec_bootstrap.h.

Macro Definition Documentation

◆ vec_bytes

#define vec_bytes (   v)    (vec_len (v) * sizeof (v[0]))

Number of data bytes in vector.

Definition at line 161 of file vec_bootstrap.h.

◆ vec_capacity

#define vec_capacity (   v,
  b 
)
Value:
({ \
void * _vec_capacity_v = (void *) (v); \
uword _vec_capacity_b = (b); \
_vec_capacity_b = sizeof (vec_header_t) + _vec_round_size (_vec_capacity_b); \
_vec_capacity_v ? clib_mem_size (_vec_capacity_v - _vec_capacity_b) : 0; \
})
const cJSON *const b
Definition: cJSON.h:255
static uword clib_mem_size(void *p)
Definition: mem.h:343
vector header structure
Definition: vec_bootstrap.h:55

Total number of bytes that can fit in vector with current allocation.

Definition at line 165 of file vec_bootstrap.h.

◆ vec_elt

#define vec_elt (   v,
  i 
)    (vec_elt_at_index(v,i))[0]

Get vector value at index i.

Definition at line 209 of file vec_bootstrap.h.

◆ vec_elt_at_index

#define vec_elt_at_index (   v,
  i 
)
Value:
({ \
ASSERT ((i) < vec_len (v)); \
(v) + (i); \
})
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)

Get vector value at index i checking that i is in bounds.

Definition at line 202 of file vec_bootstrap.h.

◆ vec_end

#define vec_end (   v)    ((v) + vec_len (v))

End (last data address) of vector.

Definition at line 196 of file vec_bootstrap.h.

◆ vec_foreach

#define vec_foreach (   var,
  vec 
)    for (var = (vec); var < vec_end (vec); var++)

Vector iterator.

Definition at line 212 of file vec_bootstrap.h.

◆ vec_foreach_backwards

#define vec_foreach_backwards (   var,
  vec 
)    for (var = vec_end (vec) - 1; var >= (vec); var--)

Vector iterator (reverse)

Definition at line 215 of file vec_bootstrap.h.

◆ vec_foreach_index

#define vec_foreach_index (   var,
 
)    for ((var) = 0; (var) < vec_len (v); (var)++)

Iterate over vector indices.

Definition at line 219 of file vec_bootstrap.h.

◆ vec_foreach_index_backwards

#define vec_foreach_index_backwards (   var,
 
)    for ((var) = vec_len((v)) - 1; (var) >= 0; (var)--)

Iterate over vector indices (reverse).

Definition at line 222 of file vec_bootstrap.h.

◆ vec_is_member

#define vec_is_member (   v,
 
)    ((e) >= (v) && (e) < vec_end (v))

True if given pointer is within given vector.

Definition at line 199 of file vec_bootstrap.h.

◆ vec_len

#define vec_len (   v)    ((v) ? _vec_len(v) : 0)

Number of elements in vector (rvalue-only, NULL tolerant)

vec_len (v) checks for NULL, but cannot be used as an lvalue. If in doubt, use vec_len...

Definition at line 142 of file vec_bootstrap.h.

◆ vec_max_len

#define vec_max_len (   v)    (vec_capacity(v,0) / sizeof (v[0]))

Total number of elements that can fit into vector.

Definition at line 174 of file vec_bootstrap.h.

◆ vec_numa

#define vec_numa (   v)    ((v) ? _vec_numa(v) : 0)

Return vector's NUMA ID (rvalue-only, NULL tolerant) vec_numa(v) checks for NULL, but cannot be used as an lvalue.

Definition at line 156 of file vec_bootstrap.h.

◆ VEC_NUMA_UNSPECIFIED

#define VEC_NUMA_UNSPECIFIED   (0xFF)

Definition at line 63 of file vec_bootstrap.h.

◆ vec_reset_length

#define vec_reset_length (   v)    do { if (v) vec_set_len (v, 0); } while (0)

Reset vector length to zero NULL-pointer tolerant.

Definition at line 193 of file vec_bootstrap.h.

◆ vec_set_len

#define vec_set_len (   v,
 
)
Value:
do { \
ASSERT(v); \
ASSERT((l) <= vec_max_len(v)); \
CLIB_MEM_POISON_LEN((void *)(v), _vec_len(v) * sizeof((v)[0]), (l) * sizeof((v)[0])); \
_vec_len(v) = (l); \
} while (0)
#define vec_max_len(v)
Total number of elements that can fit into vector.

Set vector length to a user-defined value.

Definition at line 178 of file vec_bootstrap.h.

Function Documentation

◆ vec_aligned_header()

static void* vec_aligned_header ( void *  v,
uword  header_bytes,
uword  align 
)
inlinestatic

Definition at line 116 of file vec_bootstrap.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vec_aligned_header_bytes()

static uword vec_aligned_header_bytes ( uword  header_bytes,
uword  align 
)
inlinestatic

Definition at line 110 of file vec_bootstrap.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vec_aligned_header_end()

static void* vec_aligned_header_end ( void *  v,
uword  header_bytes,
uword  align 
)
inlinestatic

Definition at line 122 of file vec_bootstrap.h.

+ Here is the call graph for this function:

◆ vec_get_numa()

static uword vec_get_numa ( void *  v)
inlinestatic

return the NUMA index for a vector

Definition at line 227 of file vec_bootstrap.h.

◆ vec_header()

static void* vec_header ( void *  v,
uword  header_bytes 
)
inlinestatic

Find a user vector header.

Finds the user header of a vector with unspecified alignment given the user pointer to the vector.

Definition at line 92 of file vec_bootstrap.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vec_header_bytes()

static uword vec_header_bytes ( uword  header_bytes)
inlinestatic

Definition at line 79 of file vec_bootstrap.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vec_header_end()

static void* vec_header_end ( void *  v,
uword  header_bytes 
)
inlinestatic

Find the end of user vector header.

Finds the end of the user header of a vector with unspecified alignment given the user pointer to the vector.

Definition at line 104 of file vec_bootstrap.h.

+ Here is the call graph for this function:

◆ vec_len_not_inline()

u32 vec_len_not_inline ( void *  v)

Definition at line 144 of file vec.c.