FD.io VPP  v16.06
Vector Packet Processing
pool.h File Reference
+ Include dependency graph for pool.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pool_header_t
 

Macros

#define pool_aligned_header_bytes   vec_aligned_header_bytes (sizeof (pool_header_t), sizeof (void *))
 
#define pool_validate_index(v, i)
 
#define pool_len(p)   vec_len(p)
 
#define pool_bytes(P)   (vec_bytes (P) + pool_header_bytes (P))
 
#define pool_get_aligned(P, E, A)
 
#define pool_get(P, E)   pool_get_aligned(P,E,0)
 
#define pool_is_free(P, E)
 
#define pool_is_free_index(P, I)   pool_is_free((P),(P)+(I))
 
#define pool_put(P, E)
 
#define pool_put_index(p, i)
 
#define pool_alloc_aligned(P, N, A)
 
#define pool_alloc(P, N)   pool_alloc_aligned(P,N,0)
 
#define pool_free(p)   (p) = _pool_free(p)
 
#define pool_foreach_region(LO, HI, POOL, BODY)
 
#define pool_foreach(VAR, POOL, BODY)
 
#define pool_elt_at_index(p, i)
 
#define pool_next_index(P, I)
 
#define pool_foreach_index(i, v, body)
 

Functions

always_inline pool_header_tpool_header (void *v)
 
always_inline void pool_validate (void *v)
 
always_inline void pool_header_validate_index (void *v, uword index)
 
always_inline uword pool_elts (void *v)
 
always_inline uword pool_header_bytes (void *v)
 
always_inline uword pool_free_elts (void *v)
 

Macro Definition Documentation

#define pool_aligned_header_bytes   vec_aligned_header_bytes (sizeof (pool_header_t), sizeof (void *))

Definition at line 58 of file pool.h.

#define pool_alloc (   P,
 
)    pool_alloc_aligned(P,N,0)

Definition at line 233 of file pool.h.

#define pool_alloc_aligned (   P,
  N,
 
)
Value:
do { \
pool_header_t * _p; \
(P) = _vec_resize ((P), 0, (vec_len (P) + (N)) * sizeof (P[0]), \
(A)); \
_p = pool_header (P); \
vec_resize (_p->free_indices, (N)); \
_vec_len (_p->free_indices) -= (N); \
} while (0)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
Definition: vec.h:199
#define pool_aligned_header_bytes
Definition: pool.h:58
always_inline pool_header_t * pool_header(void *v)
Definition: pool.h:62
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)

Definition at line 221 of file pool.h.

#define pool_bytes (   P)    (vec_bytes (P) + pool_header_bytes (P))

Definition at line 129 of file pool.h.

#define pool_elt_at_index (   p,
  i 
)
Value:
({ \
typeof (p) _e = (p) + (i); \
ASSERT (! pool_is_free (p, _e)); \
_e; \
})
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:267
#define pool_is_free(P, E)
Definition: pool.h:189
#define ASSERT(truth)

Definition at line 346 of file pool.h.

#define pool_foreach (   VAR,
  POOL,
  BODY 
)
Value:
do { \
uword _pool_foreach_lo, _pool_foreach_hi; \
pool_foreach_region (_pool_foreach_lo, _pool_foreach_hi, (POOL), \
({ \
for ((VAR) = (POOL) + _pool_foreach_lo; \
(VAR) < (POOL) + _pool_foreach_hi; \
(VAR)++) \
do { BODY; } while (0); \
})); \
} while (0)
#define pool_foreach_region(LO, HI, POOL, BODY)
Definition: pool.h:260
u64 uword
Definition: types.h:112

Definition at line 328 of file pool.h.

#define pool_foreach_index (   i,
  v,
  body 
)
Value:
for ((i) = 0; (i) < vec_len (v); (i)++) \
{ \
if (! pool_is_free_index ((v), (i))) \
do { body; } while (0); \
}
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:267
#define pool_is_free_index(P, I)
Definition: pool.h:197
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)

Definition at line 366 of file pool.h.

#define pool_foreach_region (   LO,
  HI,
  POOL,
  BODY 
)
Value:
do { \
uword _pool_var (i), _pool_var (lo), _pool_var (hi), _pool_var (len); \
uword _pool_var (bl), * _pool_var (b); \
pool_header_t * _pool_var (p); \
\
_pool_var (p) = pool_header (POOL); \
_pool_var (b) = (POOL) ? _pool_var (p)->free_bitmap : 0; \
_pool_var (bl) = vec_len (_pool_var (b)); \
_pool_var (len) = vec_len (POOL); \
_pool_var (lo) = 0; \
\
for (_pool_var (i) = 0; \
_pool_var (i) <= _pool_var (bl); \
_pool_var (i)++) \
{ \
uword _pool_var (m), _pool_var (f); \
_pool_var (m) = (_pool_var (i) < _pool_var (bl) \
? _pool_var (b) [_pool_var (i)] \
: 1); \
while (_pool_var (m) != 0) \
{ \
_pool_var (f) = first_set (_pool_var (m)); \
_pool_var (hi) = (_pool_var (i) * BITS (_pool_var (b)[0]) \
+ min_log2 (_pool_var (f))); \
_pool_var (hi) = (_pool_var (i) < _pool_var (bl) \
? _pool_var (hi) : _pool_var (len)); \
_pool_var (m) ^= _pool_var (f); \
if (_pool_var (hi) > _pool_var (lo)) \
{ \
(LO) = _pool_var (lo); \
(HI) = _pool_var (hi); \
do { BODY; } while (0); \
} \
_pool_var (lo) = _pool_var (hi) + 1; \
} \
} \
} while (0)
vmrglw vmrglh hi
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:267
always_inline uword first_set(uword x)
Definition: clib.h:265
always_inline pool_header_t * pool_header(void *v)
Definition: pool.h:62
u64 uword
Definition: types.h:112
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
always_inline uword min_log2(uword x)
Definition: clib.h:181
#define BITS(x)
Definition: clib.h:58

Definition at line 260 of file pool.h.

#define pool_free (   p)    (p) = _pool_free(p)

Definition at line 248 of file pool.h.

#define pool_get (   P,
 
)    pool_get_aligned(P,E,0)

Definition at line 186 of file pool.h.

#define pool_get_aligned (   P,
  E,
 
)
Value:
do { \
pool_header_t * _pool_var (p) = pool_header (P); \
uword _pool_var (l); \
\
_pool_var (l) = 0; \
if (P) \
_pool_var (l) = vec_len (_pool_var (p)->free_indices); \
\
if (_pool_var (l) > 0) \
{ \
/* Return free element from free list. */ \
uword _pool_var (i) = _pool_var (p)->free_indices[_pool_var (l) - 1]; \
(E) = (P) + _pool_var (i); \
_pool_var (p)->free_bitmap = \
clib_bitmap_andnoti (_pool_var (p)->free_bitmap, _pool_var (i)); \
_vec_len (_pool_var (p)->free_indices) = _pool_var (l) - 1; \
} \
else \
{ \
/* Nothing on free list, make a new element and return it. */ \
P = _vec_resize (P, \
/* length_increment */ 1, \
/* new size */ (vec_len (P) + 1) * sizeof (P[0]), \
/* align */ (A)); \
E = vec_end (P) - 1; \
} \
} while (0)
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:267
#define vec_end(v)
End (last data address) of vector.
#define pool_aligned_header_bytes
Definition: pool.h:58
always_inline pool_header_t * pool_header(void *v)
Definition: pool.h:62
u64 uword
Definition: types.h:112
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)

Definition at line 155 of file pool.h.

#define pool_is_free (   P,
 
)
Value:
({ \
pool_header_t * _pool_var (p) = pool_header (P); \
uword _pool_var (i) = (E) - (P); \
(_pool_var (i) < vec_len (P)) ? clib_bitmap_get (_pool_var (p)->free_bitmap, _pool_i) : 1; \
})
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:267
always_inline uword clib_bitmap_get(uword *ai, uword i)
Definition: bitmap.h:158
always_inline pool_header_t * pool_header(void *v)
Definition: pool.h:62
u64 uword
Definition: types.h:112
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)

Definition at line 189 of file pool.h.

#define pool_is_free_index (   P,
  I 
)    pool_is_free((P),(P)+(I))

Definition at line 197 of file pool.h.

#define pool_len (   p)    vec_len(p)

Definition at line 109 of file pool.h.

#define pool_next_index (   P,
  I 
)
Value:
({ \
pool_header_t * _pool_var (p) = pool_header (P); \
uword _pool_var (rv) = (I) + 1; \
\
_pool_var(rv) = \
(_pool_var (rv) < vec_len (P) ? \
clib_bitmap_next_clear (_pool_var (p)->free_bitmap, _pool_var(rv)) \
: ~0); \
_pool_var(rv); \
})
always_inline uword clib_bitmap_next_clear(uword *ai, uword i)
Definition: bitmap.h:495
always_inline pool_header_t * pool_header(void *v)
Definition: pool.h:62
u64 uword
Definition: types.h:112
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define I(b, c, d)
Definition: md5.c:47

Definition at line 354 of file pool.h.

#define pool_put (   P,
 
)
Value:
do { \
pool_header_t * _pool_var (p) = pool_header (P); \
uword _pool_var (l) = (E) - (P); \
ASSERT (! pool_is_free (P, E)); \
\
/* Add element to free bitmap and to free list. */ \
_pool_var (p)->free_bitmap = \
clib_bitmap_ori (_pool_var (p)->free_bitmap, _pool_var (l)); \
vec_add1 (_pool_var (p)->free_indices, _pool_var (l)); \
} while (0)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:480
#define pool_is_free(P, E)
Definition: pool.h:189
#define ASSERT(truth)
#define vec_is_member(v, e)
True if given pointer is within given vector.
always_inline pool_header_t * pool_header(void *v)
Definition: pool.h:62
u64 uword
Definition: types.h:112

Definition at line 200 of file pool.h.

#define pool_put_index (   p,
  i 
)
Value:
do { \
typeof (p) _e = (p) + (i); \
pool_put (p, _e); \
} while (0)
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:267
#define pool_put(P, E)
Definition: pool.h:200

Definition at line 214 of file pool.h.

#define pool_validate_index (   v,
  i 
)
Value:
do { \
uword __pool_validate_index = (i); \
vec_validate_ha ((v), __pool_validate_index, \
pool_aligned_header_bytes, /* align */ 0); \
pool_header_validate_index ((v), __pool_validate_index); \
} while (0)
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:267
#define pool_aligned_header_bytes
Definition: pool.h:58
#define vec_validate_ha(V, I, H, A)
Make sure vector is long enough for given index (general version).
Definition: vec.h:374
always_inline void pool_header_validate_index(void *v, uword index)
Definition: pool.h:80
u64 uword
Definition: types.h:112

Definition at line 88 of file pool.h.

Function Documentation

always_inline uword pool_elts ( void v)

Definition at line 97 of file pool.h.

+ Here is the call graph for this function:

always_inline uword pool_free_elts ( void v)

Definition at line 136 of file pool.h.

+ Here is the call graph for this function:

always_inline pool_header_t* pool_header ( void v)

Definition at line 62 of file pool.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline uword pool_header_bytes ( void v)

Definition at line 118 of file pool.h.

+ Here is the call graph for this function:

always_inline void pool_header_validate_index ( void v,
uword  index 
)

Definition at line 80 of file pool.h.

+ Here is the call graph for this function:

always_inline void pool_validate ( void v)

Definition at line 66 of file pool.h.

+ Here is the call graph for this function: