FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
svm_common.h
Go to the documentation of this file.
1
/*
2
*------------------------------------------------------------------
3
* Copyright (c) 2009 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 __included_svm_common_h__
19
#define __included_svm_common_h__
20
21
#include <stdarg.h>
22
#include <pthread.h>
23
#include <sys/user.h>
24
#include <
vppinfra/types.h
>
25
26
#define SVM_VERSION ((1<<16) | 1)
/* set to declare region ready. */
27
28
#define SVM_FLAGS_MHEAP (1<<0)
/* region contains an mheap */
29
#define SVM_FLAGS_FILE (1<<1)
/* region backed by one or more files */
30
#define SVM_FLAGS_NODATA (1<<2)
/* region will be further subdivided */
31
#define SVM_FLAGS_NEED_DATA_INIT (1<<3)
32
33
#define SVM_PVT_MHEAP_SIZE (128<<10)
/* region's private mheap (128k) */
34
35
typedef
struct
svm_region_
36
{
37
volatile
uword
version
;
38
pthread_mutex_t
mutex
;
39
pthread_cond_t
condvar
;
40
int
mutex_owner_pid
;
/* in case of trouble */
41
int
mutex_owner_tag
;
42
uword
flags
;
43
uword
virtual_base
;
/* base of the region object */
44
uword
virtual_size
;
45
void
*
region_heap
;
46
void
*
data_base
;
/* data portion base address */
47
void
*
data_heap
;
/* data heap, if any */
48
volatile
void
*
user_ctx
;
/* user context pointer */
49
/* stuff allocated in the region's heap */
50
uword
bitmap_size
;
/* nbits in virtual alloc bitmap */
51
uword
*
bitmap
;
/* the bitmap */
52
char
*
region_name
;
53
char
*
backing_file
;
54
char
**
filenames
;
55
uword
*
client_pids
;
56
/* pad */
57
58
/* next page:
59
* (64K) clib heap for the region itself
60
*
61
* data_base -> whatever is in this region
62
*/
63
64
}
svm_region_t
;
65
66
typedef
struct
svm_map_region_args_
67
{
68
const
char
*
root_path
;
/* NULL means use the truly global arena */
69
const
char
*
name
;
70
uword
baseva
;
71
u64
size
;
72
u64
pvt_heap_size
;
73
uword
flags
;
74
char
*
backing_file
;
75
uword
backing_mmap_size
;
76
/* uid, gid to own the svm region(s) */
77
int
uid
;
78
int
gid
;
79
}
svm_map_region_args_t
;
80
81
/*
82
* Memory mapped to high addresses for session/vppcom/vcl/etc...
83
*/
84
#if __WORDSIZE == 64
85
#ifdef CLIB_SANITIZE_ADDR
86
#define HIGH_SEGMENT_BASEVA 0x300000000000
/* DO NOT CHANGE THIS: YOU'LL BREAK ASAN */
87
#else
/* CLIB_SANITIZE_ADDR */
88
#define HIGH_SEGMENT_BASEVA (128ULL << 30)
/* 128GB */
89
#endif
/* CLIB_SANITIZE_ADDR */
90
#elif __WORDSIZE == 32
91
#define HIGH_SEGMENT_BASEVA (3584UL << 20)
/* 3.5GB */
92
#else
93
#error "unknown __WORDSIZE"
94
#endif
95
96
/*
97
* Memory shared across all router instances. Packet buffers, etc
98
* Base should be "out of the way," and size should be big enough to
99
* cover everything we plan to put here.
100
*/
101
#define SVM_GLOBAL_REGION_SIZE (64<<20)
102
#define SVM_GLOBAL_REGION_NAME "/global_vm"
103
u64
svm_get_global_region_base_va
();
104
105
/*
106
* Memory shared across individual router instances.
107
*/
108
#define SVM_OVERLAY_REGION_BASEVA \
109
(SVM_GLOBAL_REGION_BASEVA + SVM_GLOBAL_REGION_SIZE)
110
#define SVM_OVERLAY_REGION_SIZE (1<<20)
111
#define SVM_OVERLAY_REGION_BASENAME "/overlay_vm"
112
113
typedef
struct
114
{
115
u8
*
subregion_name
;
116
}
svm_subregion_t
;
117
118
typedef
struct
119
{
120
svm_subregion_t
*
subregions
;
/* subregion pool */
121
uword
*
name_hash
;
122
u8
*
root_path
;
123
int
uid
;
124
int
gid
;
125
}
svm_main_region_t
;
126
127
128
void
*
svm_region_find_or_create
(
svm_map_region_args_t
*
a
);
129
void
svm_region_init
(
void
);
130
void
svm_region_init_mapped_region
(
svm_map_region_args_t
*
a
,
131
svm_region_t
* rp);
132
int
svm_region_init_chroot
(
const
char
*root_path);
133
void
svm_region_init_chroot_uid_gid
(
const
char
*root_path,
int
uid,
int
gid);
134
void
svm_region_init_args
(
svm_map_region_args_t
*
a
);
135
void
svm_region_exit
(
void
);
136
void
svm_region_exit_client
(
void
);
137
void
svm_region_unmap
(
void
*rp_arg);
138
void
svm_region_unmap_client
(
void
*rp_arg);
139
void
svm_client_scan
(
const
char
*root_path);
140
void
svm_client_scan_this_region_nolock
(
svm_region_t
* rp);
141
u8
*
shm_name_from_svm_map_region_args
(
svm_map_region_args_t
*
a
);
142
u8
*
format_svm_region
(
u8
* s, va_list * args);
143
144
svm_region_t
*
svm_get_root_rp
(
void
);
145
146
#endif
/* __included_svm_common_h__ */
147
148
/*
149
* fd.io coding-style-patch-verification: ON
150
*
151
* Local Variables:
152
* eval: (c-set-style "gnu")
153
* End:
154
*/
svm_region_::data_heap
void * data_heap
Definition:
svm_common.h:47
svm_client_scan
void svm_client_scan(const char *root_path)
Definition:
svm.c:1252
svm_region_init_chroot
int svm_region_init_chroot(const char *root_path)
Definition:
svm.c:842
format_svm_region
u8 * format_svm_region(u8 *s, va_list *args)
Definition:
svm.c:183
svm_main_region_t::uid
int uid
Definition:
svm_common.h:123
types.h
svm_region_::region_name
char * region_name
Definition:
svm_common.h:52
svm_map_region_args_::name
const char * name
Definition:
svm_common.h:69
svm_client_scan_this_region_nolock
void svm_client_scan_this_region_nolock(svm_region_t *rp)
Definition:
svm.c:1224
svm_map_region_args_::backing_file
char * backing_file
Definition:
svm_common.h:74
svm_region_unmap
void svm_region_unmap(void *rp_arg)
Definition:
svm.c:1145
svm_map_region_args_::baseva
uword baseva
Definition:
svm_common.h:70
svm_region_::client_pids
uword * client_pids
Definition:
svm_common.h:55
svm_subregion_t
Definition:
svm_common.h:113
svm_region_::filenames
char ** filenames
Definition:
svm_common.h:54
svm_map_region_args_t
struct svm_map_region_args_ svm_map_region_args_t
svm_region_::mutex
pthread_mutex_t mutex
Definition:
svm_common.h:38
svm_region_::data_base
void * data_base
Definition:
svm_common.h:46
svm_region_init
void svm_region_init(void)
Definition:
svm.c:825
svm_region_init_args
void svm_region_init_args(svm_map_region_args_t *a)
Definition:
svm.c:876
svm_main_region_t::gid
int gid
Definition:
svm_common.h:124
svm_region_::mutex_owner_pid
int mutex_owner_pid
Definition:
svm_common.h:40
svm_region_exit
void svm_region_exit(void)
Definition:
svm.c:1212
svm_region_::bitmap_size
uword bitmap_size
Definition:
svm_common.h:50
uword
u64 uword
Definition:
types.h:112
svm_main_region_t::subregions
svm_subregion_t * subregions
Definition:
svm_common.h:120
svm_main_region_t
Definition:
svm_common.h:118
svm_get_global_region_base_va
u64 svm_get_global_region_base_va()
Definition:
svm.c:61
svm_region_init_chroot_uid_gid
void svm_region_init_chroot_uid_gid(const char *root_path, int uid, int gid)
Definition:
svm.c:859
svm_region_::virtual_size
uword virtual_size
Definition:
svm_common.h:44
svm_subregion_t::subregion_name
u8 * subregion_name
Definition:
svm_common.h:115
u64
unsigned long u64
Definition:
types.h:89
svm_region_find_or_create
void * svm_region_find_or_create(svm_map_region_args_t *a)
Definition:
svm.c:882
svm_region_::user_ctx
volatile void * user_ctx
Definition:
svm_common.h:48
svm_map_region_args_::pvt_heap_size
u64 pvt_heap_size
Definition:
svm_common.h:72
svm_main_region_t::name_hash
uword * name_hash
Definition:
svm_common.h:121
svm_region_::flags
uword flags
Definition:
svm_common.h:42
svm_region_::virtual_base
uword virtual_base
Definition:
svm_common.h:43
svm_map_region_args_::size
u64 size
Definition:
svm_common.h:71
svm_region_::region_heap
void * region_heap
Definition:
svm_common.h:45
svm_map_region_args_::backing_mmap_size
uword backing_mmap_size
Definition:
svm_common.h:75
svm_map_region_args_::uid
int uid
Definition:
svm_common.h:77
svm_region_
Definition:
svm_common.h:35
u8
unsigned char u8
Definition:
types.h:56
a
a
Definition:
bitmap.h:544
svm_region_exit_client
void svm_region_exit_client(void)
Definition:
svm.c:1218
svm_region_init_mapped_region
void svm_region_init_mapped_region(svm_map_region_args_t *a, svm_region_t *rp)
Definition:
svm.c:446
shm_name_from_svm_map_region_args
u8 * shm_name_from_svm_map_region_args(svm_map_region_args_t *a)
Definition:
svm.c:422
svm_region_unmap_client
void svm_region_unmap_client(void *rp_arg)
Definition:
svm.c:1151
svm_region_::condvar
pthread_cond_t condvar
Definition:
svm_common.h:39
svm_map_region_args_::root_path
const char * root_path
Definition:
svm_common.h:68
svm_region_t
struct svm_region_ svm_region_t
svm_get_root_rp
svm_region_t * svm_get_root_rp(void)
Definition:
svm.c:53
svm_region_::bitmap
uword * bitmap
Definition:
svm_common.h:51
svm_main_region_t::root_path
u8 * root_path
Definition:
svm_common.h:122
svm_region_::backing_file
char * backing_file
Definition:
svm_common.h:53
svm_region_::version
volatile uword version
Definition:
svm_common.h:37
svm_map_region_args_::gid
int gid
Definition:
svm_common.h:78
svm_map_region_args_::flags
uword flags
Definition:
svm_common.h:73
svm_region_::mutex_owner_tag
int mutex_owner_tag
Definition:
svm_common.h:41
svm_map_region_args_
Definition:
svm_common.h:66
src
svm
svm_common.h
Generated on Sat Jan 8 2022 10:04:30 for FD.io VPP by
1.8.17