Damjan Marion | 7cd468a | 2016-12-19 23:05:39 +0100 | [diff] [blame] | 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 | |
Damjan Marion | 7cd468a | 2016-12-19 23:05:39 +0100 | [diff] [blame] | 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> |
Klement Sekera | 58eb866 | 2017-06-09 06:06:49 +0200 | [diff] [blame] | 28 | #include <vlibmemory/api_common.h> |
Damjan Marion | 7cd468a | 2016-12-19 23:05:39 +0100 | [diff] [blame] | 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 | |
Damjan Marion | 7cd468a | 2016-12-19 23:05:39 +0100 | [diff] [blame] | 52 | void vl_enable_disable_memory_api (vlib_main_t * vm, int yesno); |
Dave Barach | 59b2565 | 2017-09-10 15:04:27 -0400 | [diff] [blame] | 53 | |
Damjan Marion | 7cd468a | 2016-12-19 23:05:39 +0100 | [diff] [blame] | 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 | */ |