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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef __adj_alloc_h__
17 #define __adj_alloc_h__
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.
25 * We include explicit references to worker thread barrier synchronization
29 #include <vppinfra/vec.h>
30 #include <vlib/vlib.h>
31 #include <vnet/ip/lookup.h>
34 u32 ** free_indices_by_size;
37 #define aa_aligned_header_bytes \
38 vec_aligned_header_bytes (sizeof (aa_header_t), sizeof (void *))
40 /* Pool header from user pointer */
41 static inline aa_header_t * aa_header (void * v)
43 return vec_aligned_header (v, sizeof (aa_header_t), sizeof (void *));
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);
49 ip_adjacency_t * aa_bootstrap (ip_adjacency_t * adjs, u32 n);
51 format_function_t format_adj_allocation;
53 #endif /* __adj_alloc_h__ */