FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
memory_api.h
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2018 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *------------------------------------------------------------------
16  */
17 
18 #ifndef SRC_VLIBMEMORY_MEMORY_API_H_
19 #define SRC_VLIBMEMORY_MEMORY_API_H_
20 
21 #include <svm/svm.h>
22 #include <svm/ssvm.h>
23 #include <svm/queue.h>
24 #include <vlib/vlib.h>
25 #include <vlibapi/api.h>
27 
29 int vl_mem_api_init (const char *region_name);
31  f64 now);
34  vlib_node_runtime_t * node, u32 reg_index);
36 
38 void vl_mem_api_enable_disable (vlib_main_t * vm, int yesno);
40 
41 static inline u32
43 {
44  return (index & VL_API_EPOCH_MASK);
45 }
46 
47 static inline u32
49 {
50  return (index >> VL_API_EPOCH_SHIFT);
51 }
52 
53 static inline u32
55 {
56  u32 handle;
57  ASSERT (index < 0x00FFFFFF);
58 
59  handle = (index << VL_API_EPOCH_SHIFT) | (epoch & VL_API_EPOCH_MASK);
60  return handle;
61 }
62 
63 static inline u8
65 {
66  u32 epoch = vl_msg_api_handle_get_epoch (handle);
67  return ((restarts & VL_API_EPOCH_MASK) == epoch);
68 }
69 
70 #define VL_MEM_API_LOG_Q_LEN(fmt, qlen) \
71  if (TRACE_VLIB_MEMORY_QUEUE) \
72  do \
73  { \
74  ELOG_TYPE_DECLARE (e) = { \
75  .format = fmt, \
76  .format_args = "i4", \
77  }; \
78  struct \
79  { \
80  u32 len; \
81  } * ed; \
82  ed = ELOG_DATA (&vlib_global_main.elog_main, e); \
83  ed->len = qlen; \
84  } \
85  while (0)
86 
87 #endif /* SRC_VLIBMEMORY_MEMORY_API_H_ */
88 
89 /*
90  * fd.io coding-style-patch-verification: ON
91  *
92  * Local Variables:
93  * eval: (c-set-style "gnu")
94  * End:
95  */
vlib.h
vl_mem_api_handle_msg_main
int vl_mem_api_handle_msg_main(vlib_main_t *vm, vlib_node_runtime_t *node)
Definition: memory_api.c:710
VL_API_EPOCH_SHIFT
#define VL_API_EPOCH_SHIFT
Definition: memory_shared.h:109
vl_msg_api_handle_get_index
static u32 vl_msg_api_handle_get_index(u32 index)
Definition: memory_api.h:48
vl_api_memclnt_create_internal
u32 vl_api_memclnt_create_internal(char *, svm_queue_t *)
Definition: memory_api.c:126
vl_msg_api_handle_from_index_and_epoch
static u32 vl_msg_api_handle_from_index_and_epoch(u32 index, u32 epoch)
Definition: memory_api.h:54
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
svm_queue_t
struct _svm_queue svm_queue_t
am
app_main_t * am
Definition: application.c:489
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
api.h
vl_msg_api_handle_is_valid
static u8 vl_msg_api_handle_is_valid(u32 handle, u32 restarts)
Definition: memory_api.h:64
vl_shmem_hdr_
Definition: memory_shared.h:76
svm.h
vl_api_client_index_to_input_queue
svm_queue_t * vl_api_client_index_to_input_queue(u32 index)
Definition: memory_api.c:800
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
f64
double f64
Definition: types.h:142
vl_mem_api_handle_msg_private
int vl_mem_api_handle_msg_private(vlib_main_t *vm, vlib_node_runtime_t *node, u32 reg_index)
Definition: memory_api.c:762
vl_mem_api_init
int vl_mem_api_init(const char *region_name)
Definition: memory_api.c:430
queue.h
api_main_t
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:228
index
u32 index
Definition: flow_types.api:221
VL_API_EPOCH_MASK
#define VL_API_EPOCH_MASK
Definition: memory_shared.h:108
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vl_msg_api_handle_get_epoch
static u32 vl_msg_api_handle_get_epoch(u32 index)
Definition: memory_api.h:42
u32
unsigned int u32
Definition: types.h:88
memory_shared.h
vl_mem_api_dead_client_scan
void vl_mem_api_dead_client_scan(api_main_t *am, vl_shmem_hdr_t *shm, f64 now)
Definition: memory_api.c:582
now
f64 now
Definition: nat44_ei_out2in.c:710
vlib_main_t
Definition: main.h:102
u8
unsigned char u8
Definition: types.h:56
vl_mem_api_handle_rpc
int vl_mem_api_handle_rpc(vlib_main_t *vm, vlib_node_runtime_t *node)
Definition: memory_api.c:718
vl_mem_api_client_index_to_registration
vl_api_registration_t * vl_mem_api_client_index_to_registration(u32 handle)
Definition: memory_api.c:771
ssvm.h
vlib_node_runtime_t
Definition: node.h:454
vl_mem_api_enable_disable
void vl_mem_api_enable_disable(vlib_main_t *vm, int yesno)
Definition: vlib_api.c:445