FD.io VPP  v16.12-rc0-171-g5499b19
Vector Packet Processing
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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  * @brief
21  * Adjacency allocator: heap-like in that the code
22  * will dole out contiguous chunks of n items. In the interests of
23  * thread safety, we don't bother about coalescing free blocks of size r
24  * into free blocks of size s, where r < s.
25  *
26  * We include explicit references to worker thread barrier synchronization
27  * where necessary.
28  */
29 
30 #include <vppinfra/vec.h>
31 #include <vlib/vlib.h>
32 #include <vnet/ip/lookup.h>
33 
34 typedef struct {
36 } aa_header_t;
37 
38 #define aa_aligned_header_bytes \
39  vec_aligned_header_bytes (sizeof (aa_header_t), sizeof (void *))
40 
41 /* Pool header from user pointer */
42 static inline aa_header_t * aa_header (void * v)
43 {
44  return vec_aligned_header (v, sizeof (aa_header_t), sizeof (void *));
45 }
46 
47 extern ip_adjacency_t *aa_alloc(void);
48 extern void aa_free (ip_adjacency_t * adj);
49 extern void aa_bootstrap (u32 n);
50 
52 
53 #endif /* __adj_alloc_h__ */
Adjacency allocator: heap-like in that the code will dole out contiguous chunks of n items...
Definition: adj_alloc.h:34
format_function_t format_adj_allocation
Definition: adj_alloc.h:51
Definitions for all things IP (v4|v6) unicast and multicast lookup related.
IP unicast adjacency.
Definition: lookup.h:174
void aa_free(ip_adjacency_t *adj)
Definition: adj_alloc.c:115
ip_adjacency_t * aa_alloc(void)
Definition: adj_alloc.c:52
static void * vec_aligned_header(void *v, uword header_bytes, uword align)
unsigned int u32
Definition: types.h:88
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
u32 ** free_indices_by_size
Definition: adj_alloc.h:35
void aa_bootstrap(u32 n)
Definition: adj_alloc.c:126
static aa_header_t * aa_header(void *v)
Definition: adj_alloc.h:42
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".