|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
47 result =
vec_dup (feature_vector);
68 if (last_node_index != ~0)
91 u32 last_node_index = ~0;
97 config_string =
cm->config_string_temp;
98 cm->config_string_temp = 0;
100 _vec_len (config_string) = 0;
105 f->next_index =
add_next (
vm,
cm, last_node_index,
f->node_index);
106 last_node_index =
f->node_index;
116 if (last_node_index == ~0 || last_node_index != end_node_index)
127 cm->config_string_temp = config_string;
136 c->index =
c -
cm->config_pool;
137 c->features = feature_vector;
138 c->config_string_vector = config_string;
143 c->config_string_heap_index
145 c->config_string_heap_handle);
150 c->config_string_heap_index);
155 c->reference_count = 0;
158 c->config_string_heap_index + 1,
159 cm->default_end_node_index);
160 cm->end_node_indices_by_user_index[
c->config_string_heap_index + 1]
170 char *start_node_names[],
171 int n_start_node_names,
172 char *feature_node_names[],
int n_feature_node_names)
179 cm->config_string_hash =
184 ASSERT (n_feature_node_names >= 1);
186 vec_resize (
cm->start_node_indices, n_start_node_names);
187 for (
i = 0;
i < n_start_node_names;
i++)
192 cm->start_node_indices[
i] = n->
index;
195 vec_resize (
cm->node_index_by_feature_index, n_feature_node_names);
196 for (
i = 0;
i < n_feature_node_names;
i++)
198 if (!feature_node_names[
i])
199 cm->node_index_by_feature_index[
i] = ~0;
206 if (
i + 1 == n_feature_node_names)
207 cm->default_end_node_index = n->
index;
208 cm->node_index_by_feature_index[
i] = n->
index;
211 cm->node_index_by_feature_index[
i] = ~0;
219 ASSERT (
c->reference_count > 0);
220 c->reference_count -= 1;
221 if (
c->reference_count == 0)
223 hash_unset (
cm->config_string_hash,
c->config_string_vector);
255 u32 config_string_heap_index,
u32 end_node_index)
260 if (end_node_index == ~0)
263 if (config_string_heap_index == ~0)
284 _vec_len (new_features) =
last;
292 new->reference_count += 1;
300 new->config_string_heap_index + 1);
301 cm->config_pool_index_by_user_index[
new->config_string_heap_index + 1]
302 =
new -
cm->config_pool;
303 return new->config_string_heap_index + 1;
309 u32 config_string_heap_index,
311 void *feature_config,
u32 n_feature_config_bytes)
315 u32 n_feature_config_u32s, end_node_index;
321 if (config_string_heap_index == ~0)
325 end_node_index =
cm->default_end_node_index;
333 cm->end_node_indices_by_user_index[config_string_heap_index];
339 f->feature_index = feature_index;
342 if (n_feature_config_bytes)
344 n_feature_config_u32s =
346 sizeof (
f->feature_config[0])) /
347 sizeof (
f->feature_config[0]);
350 n_feature_config_bytes);
354 if (
vec_len (new_features) > 1)
361 new->reference_count += 1;
369 new->config_string_heap_index + 1);
370 cm->config_pool_index_by_user_index[
new->config_string_heap_index + 1]
371 =
new -
cm->config_pool;
372 return new->config_string_heap_index + 1;
378 u32 config_string_heap_index,
380 void *feature_config,
u32 n_feature_config_bytes)
384 u32 n_feature_config_u32s;
392 n_feature_config_u32s =
394 sizeof (
f->feature_config[0])) /
395 sizeof (
f->feature_config[0]);
400 if (
f->feature_index == feature_index
401 &&
vec_len (
f->feature_config) == n_feature_config_u32s
402 && (n_feature_config_u32s == 0
403 || !memcmp (
f->feature_config, feature_config,
404 n_feature_config_bytes)))
423 cm->end_node_indices_by_user_index
424 [config_string_heap_index]);
425 new->reference_count += 1;
428 new->config_string_heap_index + 1);
429 cm->config_pool_index_by_user_index[
new->config_string_heap_index + 1]
430 =
new -
cm->config_pool;
431 return new->config_string_heap_index + 1;
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
static int feature_cmp(void *a1, void *a2)
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
u32 vnet_config_add_feature(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 feature_index, void *feature_config, u32 n_feature_config_bytes)
#define clib_memcpy(d, s, n)
nat44_ei_hairpin_src_next_t next_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define vec_end(v)
End (last data address) of vector.
#define hash_set_mem(h, key, value)
#define pool_put(P, E)
Free an object E in pool P.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
#define vec_delete(V, N, M)
Delete N elements starting at element M.
void vnet_config_del(vnet_config_main_t *cm, u32 config_id)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
static void free_feature_vector(vnet_config_feature_t *feature_vector)
#define hash_unset(h, key)
vnet_config_feature_t * features
#define vec_elt(v, i)
Get vector value at index i.
void vnet_config_init(vlib_main_t *vm, vnet_config_main_t *cm, char *start_node_names[], int n_start_node_names, char *feature_node_names[], int n_feature_node_names)
static uword round_pow2(uword x, uword pow2)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_dup(V)
Return copy of vector (no header, no alignment)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static heap_elt_t * last(heap_header_t *h)
static u32 add_next(vlib_main_t *vm, vnet_config_main_t *cm, u32 last_node_index, u32 this_node_index)
vnet_feature_config_main_t * cm
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
u32 vnet_config_modify_end_node(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 end_node_index)
vl_api_cnat_endpoint_t new
static void vnet_config_feature_free(vnet_config_feature_t *f)
#define hash_create_vec(elts, key_bytes, value_bytes)
#define hash_get_mem(h, key)
#define vec_free(V)
Free vector's memory (no header).
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
#define heap_elt_at_index(v, index)
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
static vnet_config_t * find_config_with_features(vlib_main_t *vm, vnet_config_main_t *cm, vnet_config_feature_t *feature_vector, u32 end_node_index)
#define vec_foreach(var, vec)
Vector iterator.
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V,...
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define heap_alloc(v, size, handle)
static void remove_reference(vnet_config_main_t *cm, vnet_config_t *c)
u32 vnet_config_del_feature(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 feature_index, void *feature_config, u32 n_feature_config_bytes)
static u32 * vnet_get_config_heap(vnet_config_main_t *cm, u32 ci)
static vnet_config_feature_t * duplicate_feature_vector(vnet_config_feature_t *feature_vector)
static void vnet_config_free(vnet_config_main_t *cm, vnet_config_t *c)
#define STRUCT_SIZE_OF(t, f)
#define vec_bytes(v)
Number of data bytes in vector.