5c32f5308de1b60a578b5d7c84cd05d881a37ba0
[vpp.git] / src / vlibmemory / api.h
1 /*
2  *------------------------------------------------------------------
3  * api.h
4  *
5  * Copyright (c) 2009 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19
20 #ifndef included_vlibmemory_api_h
21 #define included_vlibmemory_api_h
22
23 #include <svm/svm.h>
24 #include <vlib/vlib.h>
25 #include <vlibmemory/unix_shared_memory_queue.h>
26 #include <vlib/unix/unix.h>
27 #include <vlibapi/api.h>
28 #include <vlibmemory/api_common.h>
29
30 static inline u32
31 vl_msg_api_handle_get_epoch (u32 index)
32 {
33   return (index & VL_API_EPOCH_MASK);
34 }
35
36 static inline u32
37 vl_msg_api_handle_get_index (u32 index)
38 {
39   return (index >> VL_API_EPOCH_SHIFT);
40 }
41
42 static inline u32
43 vl_msg_api_handle_from_index_and_epoch (u32 index, u32 epoch)
44 {
45   u32 handle;
46   ASSERT (index < 0x00FFFFFF);
47
48   handle = (index << VL_API_EPOCH_SHIFT) | (epoch & VL_API_EPOCH_MASK);
49   return handle;
50 }
51
52 void vl_enable_disable_memory_api (vlib_main_t * vm, int yesno);
53
54 #endif /* included_vlibmemory_api_h */
55
56 /*
57  * fd.io coding-style-patch-verification: ON
58  *
59  * Local Variables:
60  * eval: (c-set-style "gnu")
61  * End:
62  */