FD.io VPP  v16.09
Vector Packet Processing
adj_alloc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __adj_alloc_h__
17 #define __adj_alloc_h__
18 
19 /*
20  * Adjacency allocator: heap-like in that the code
21  * will dole out contiguous chunks of n items. In the interests of
22  * thread safety, we don't bother about coalescing free blocks of size r
23  * into free blocks of size s, where r < s.
24  *
25  * We include explicit references to worker thread barrier synchronization
26  * where necessary.
27  */
28 
29 #include <vppinfra/vec.h>
30 #include <vlib/vlib.h>
31 #include <vnet/ip/lookup.h>
32 
33 typedef struct {
35 } aa_header_t;
36 
37 #define aa_aligned_header_bytes \
38  vec_aligned_header_bytes (sizeof (aa_header_t), sizeof (void *))
39 
40 /* Pool header from user pointer */
41 static inline aa_header_t * aa_header (void * v)
42 {
43  return vec_aligned_header (v, sizeof (aa_header_t), sizeof (void *));
44 }
45 
47 aa_alloc (ip_adjacency_t * adjs, ip_adjacency_t **blockp, u32 n);
48 void aa_free (ip_adjacency_t * adjs, ip_adjacency_t * adj);
50 
52 
53 #endif /* __adj_alloc_h__ */
format_function_t format_adj_allocation
Definition: adj_alloc.h:51
IP unicast adjacency.
Definition: lookup.h:164
Definitions for all things IP (v4|v6) unicast and multicast lookup related.
ip_adjacency_t * aa_bootstrap(ip_adjacency_t *adjs, u32 n)
Definition: adj_alloc.c:116
static void * vec_aligned_header(void *v, uword header_bytes, uword align)
unsigned int u32
Definition: types.h:88
void aa_free(ip_adjacency_t *adjs, ip_adjacency_t *adj)
Definition: adj_alloc.c:104
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
u32 ** free_indices_by_size
Definition: adj_alloc.h:34
ip_adjacency_t * aa_alloc(ip_adjacency_t *adjs, ip_adjacency_t **blockp, u32 n)
Definition: adj_alloc.c:48
static aa_header_t * aa_header(void *v)
Definition: adj_alloc.h:41
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".