FD.io VPP  v18.04-17-g3a0d853
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 void vl_mem_api_enable_disable (vlib_main_t * vm, int yesno);
38 
39 static inline u32
41 {
42  return (index & VL_API_EPOCH_MASK);
43 }
44 
45 static inline u32
47 {
48  return (index >> VL_API_EPOCH_SHIFT);
49 }
50 
51 static inline u32
53 {
54  u32 handle;
55  ASSERT (index < 0x00FFFFFF);
56 
57  handle = (index << VL_API_EPOCH_SHIFT) | (epoch & VL_API_EPOCH_MASK);
58  return handle;
59 }
60 
61 static inline u8
63 {
64  u32 epoch = vl_msg_api_handle_get_epoch (handle);
65  return ((restarts & VL_API_EPOCH_MASK) == epoch);
66 }
67 
68 #define VL_MEM_API_LOG_Q_LEN(fmt,qlen) \
69 if (TRACE_VLIB_MEMORY_QUEUE) \
70  do { \
71  ELOG_TYPE_DECLARE (e) = { \
72  .format = fmt, \
73  .format_args = "i4", \
74  }; \
75  struct { u32 len; } *ed; \
76  ed = ELOG_DATA (&vm->elog_main, e); \
77  ed->len = qlen; \
78  } while (0)
79 
80 #endif /* SRC_VLIBMEMORY_MEMORY_API_H_ */
81 
82 /*
83  * fd.io coding-style-patch-verification: ON
84  *
85  * Local Variables:
86  * eval: (c-set-style "gnu")
87  * End:
88  */
static u32 vl_msg_api_handle_get_index(u32 index)
Definition: memory_api.h:46
vl_api_registration_t * vl_mem_api_client_index_to_registration(u32 handle)
Definition: memory_api.c:710
static u32 vl_msg_api_handle_from_index_and_epoch(u32 index, u32 epoch)
Definition: memory_api.h:52
void vl_mem_api_dead_client_scan(api_main_t *am, vl_shmem_hdr_t *shm, f64 now)
Definition: memory_api.c:558
int vl_mem_api_handle_msg_private(vlib_main_t *vm, vlib_node_runtime_t *node, u32 reg_index)
Definition: memory_api.c:687
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:199
An API client registration, only in vpp/vlib.
Definition: api_common.h:44
int vl_mem_api_init(const char *region_name)
Definition: memory_api.c:413
void vl_mem_api_enable_disable(vlib_main_t *vm, int yesno)
Definition: vlib_api.c:453
vlib_main_t * vm
Definition: buffer.c:294
int vl_mem_api_handle_msg_main(vlib_main_t *vm, vlib_node_runtime_t *node)
Definition: memory_api.c:679
svm_queue_t * vl_api_client_index_to_input_queue(u32 index)
Definition: memory_api.c:739
#define VL_API_EPOCH_SHIFT
u32 vl_api_memclnt_create_internal(char *, svm_queue_t *)
Definition: memory_api.c:112
static u32 vl_msg_api_handle_get_epoch(u32 index)
Definition: memory_api.h:40
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
static u8 vl_msg_api_handle_is_valid(u32 handle, u32 restarts)
Definition: memory_api.h:62
#define VL_API_EPOCH_MASK
double f64
Definition: types.h:142
unsigned char u8
Definition: types.h:56
struct _svm_queue svm_queue_t