|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
32 u8 junk = 0, *ssvm_filename;
34 uword page_size, requested_va = 0;
38 return SSVM_API_ERROR_NO_SIZE;
44 ssvm_filename =
format (0,
"/dev/shm/%s%c", ssvm->
name, 0);
45 unlink ((
char *) ssvm_filename);
48 ssvm_fd = shm_open ((
char *) ssvm->
name, O_RDWR | O_CREAT | O_EXCL, 0777);
52 return SSVM_API_ERROR_CREATE_FAILURE;
55 if (fchmod (ssvm_fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0)
61 if (fchown (ssvm_fd, smr->
uid, smr->
gid) < 0)
65 if (lseek (ssvm_fd, ssvm->
ssvm_size, SEEK_SET) < 0)
69 return SSVM_API_ERROR_SET_SIZE;
72 if (write (ssvm_fd, &junk, 1) != 1)
76 return SSVM_API_ERROR_SET_SIZE;
93 return SSVM_API_ERROR_MMAP;
105 1 ,
"ssvm server shm");
132 ssvm_fd = shm_open ((
char *) ssvm->
name, O_RDWR, 0777);
138 if (fstat (ssvm_fd, &stat) < 0)
144 if (stat.st_size > 0)
148 return SSVM_API_ERROR_CLIENT_TIMEOUT;
151 sh = (
void *) mmap (0,
MMAP_PAGESIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
153 if (sh == MAP_FAILED)
157 return SSVM_API_ERROR_MMAP;
168 return SSVM_API_ERROR_CLIENT_TIMEOUT;
176 PROT_READ | PROT_WRITE,
177 MAP_SHARED | MAP_FIXED, ssvm_fd, 0);
179 if (sh == MAP_FAILED)
183 return SSVM_API_ERROR_MMAP;
194 fn =
format (0,
"/dev/shm/%s%c", ssvm->
name, 0);
197 clib_warning (
"[%d] unlinking ssvm (%s) backing file '%s'", getpid (),
201 if (unlink ((
char *) fn) < 0)
219 uword page_size, n_pages;
225 return SSVM_API_ERROR_NO_SIZE;
230 (
char *) memfd->
name);
235 return SSVM_API_ERROR_CREATE_FAILURE;
239 if (log2_page_size == 0)
242 return SSVM_API_ERROR_CREATE_FAILURE;
245 n_pages = ((memfd->
ssvm_size - 1) >> log2_page_size) + 1;
247 if ((ftruncate (memfd->
fd, n_pages << log2_page_size)) == -1)
250 return SSVM_API_ERROR_CREATE_FAILURE;
255 (
char *) memfd->
name);
260 return SSVM_API_ERROR_CREATE_FAILURE;
264 memfd->
my_pid = getpid ();
272 page_size = 1ULL << log2_page_size;
275 1 ,
"ssvm server memfd");
294 int mmap_flags = MAP_SHARED;
304 return SSVM_API_ERROR_MMAP;
310 sh = (
void *) mmap (0, page_size, PROT_READ | PROT_WRITE, MAP_SHARED,
313 if (sh == MAP_FAILED)
317 return SSVM_API_ERROR_MMAP;
322 munmap (sh, page_size);
325 mmap_flags |= MAP_FIXED;
332 PROT_READ | PROT_WRITE, mmap_flags, memfd->
fd, 0);
334 if (sh == MAP_FAILED)
338 return SSVM_API_ERROR_MMAP;
363 uword page_size, log2_page_size, rnd_size = 0;
368 if (log2_page_size == 0)
371 return SSVM_API_ERROR_CREATE_FAILURE;
374 page_size = 1ULL << log2_page_size;
376 rnd_size &= ~(page_size - 1);
379 (
char *) ssvm->
name);
383 return SSVM_API_ERROR_CREATE_FAILURE;
387 1 ,
"ssvm server private");
svm_region_t * svm_get_root_rp(void)
static uword pointer_to_uword(const void *p)
static void ssvm_pop_heap(void *oldheap)
#define vec_c_string_is_terminated(V)
Test whether a vector is a NULL terminated c-string.
uword clib_mem_get_heap_free_space(clib_mem_heap_t *heap)
__clib_export void * clib_mem_vm_map_shared(void *base, uword size, int fd, uword offset, char *fmt,...)
__clib_export int clib_mem_vm_unmap(void *base)
static init_fn server_init_fns[SSVM_N_SEGMENT_TYPES]
int ssvm_server_init_memfd(ssvm_private_t *memfd)
Initialize memfd segment server.
static void * ssvm_push_heap(ssvm_shared_header_t *sh)
@ SSVM_N_SEGMENT_TYPES
Private segments.
__clib_export void * clib_mem_vm_map(void *base, uword size, clib_mem_page_sz_t log2_page_sz, char *fmt,...)
static delete_fn delete_fns[SSVM_N_SEGMENT_TYPES]
void ssvm_delete_memfd(ssvm_private_t *memfd)
ssvm_shared_header_t * sh
#define CLIB_MEM_VM_MAP_FAILED
void ssvm_delete_shm(ssvm_private_t *ssvm)
#define clib_unix_warning(format, args...)
enum ssvm_segment_type_ ssvm_segment_type_t
__clib_export int clib_mem_vm_create_fd(clib_mem_page_sz_t log2_page_size, char *fmt,...)
int ssvm_server_init_private(ssvm_private_t *ssvm)
Initialize segment in a private heap.
clib_mem_heap_t * clib_mem_create_heap(void *base, uword size, int is_locked, char *fmt,...)
void ssvm_delete(ssvm_private_t *ssvm)
void clib_mem_destroy_heap(clib_mem_heap_t *heap)
void ssvm_delete_private(ssvm_private_t *ssvm)
int attach_timeout
shm segments attach timeout (sec)
__clib_export clib_mem_page_sz_t clib_mem_get_fd_log2_page_size(int fd)
static init_fn client_init_fns[SSVM_N_SEGMENT_TYPES]
int ssvm_client_init_shm(ssvm_private_t *ssvm)
#define vec_free(V)
Free vector's memory (no header).
__clib_export u64 clib_mem_get_fd_page_size(int fd)
description fragment has unexpected format
int ssvm_server_init(ssvm_private_t *ssvm, ssvm_segment_type_t type)
ssvm_segment_type_t ssvm_type(const ssvm_private_t *ssvm)
@ CLIB_MEM_PAGE_SZ_DEFAULT
#define CLIB_MEM_UNPOISON(a, s)
int ssvm_client_init_private(ssvm_private_t *ssvm)
static_always_inline clib_mem_page_sz_t clib_mem_get_log2_page_size(void)
void(* delete_fn)(ssvm_private_t *)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
int ssvm_client_init_memfd(ssvm_private_t *memfd)
Initialize memfd segment client.
int ssvm_server_init_shm(ssvm_private_t *ssvm)
#define uword_to_pointer(u, type)
#define clib_warning(format, args...)
u8 * ssvm_name(const ssvm_private_t *ssvm)
static uword min_log2(uword x)
int(* init_fn)(ssvm_private_t *)
int ssvm_client_init(ssvm_private_t *ssvm, ssvm_segment_type_t type)
vl_api_fib_path_type_t type
__clib_export void clib_mem_vm_randomize_va(uword *requested_va, clib_mem_page_sz_t log2_page_size)