diff options
author | Florin Coras <fcoras@cisco.com> | 2020-09-29 18:11:24 -0700 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2020-09-30 21:52:42 +0000 |
commit | 5220a26af059d7578abcbad2aea158b32cdb22b9 (patch) | |
tree | b496eedcb27f502ad327f8c4ba14727066233a17 /src | |
parent | f2b4a375d68b29130801c17f05ae66294d007d90 (diff) |
svm: harmonize ssvm names
Type: refactor
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I26e4ad6bfd9e0be7745f6ba948bf51550fd4215e
Diffstat (limited to 'src')
-rw-r--r-- | src/svm/fifo_segment.c | 6 | ||||
-rw-r--r-- | src/svm/ssvm.c | 78 | ||||
-rw-r--r-- | src/svm/ssvm.h | 28 | ||||
-rw-r--r-- | src/vlibmemory/socket_api.c | 4 | ||||
-rw-r--r-- | src/vlibmemory/socket_client.c | 2 | ||||
-rw-r--r-- | src/vnet/session/segment_manager.c | 2 | ||||
-rw-r--r-- | src/vnet/session/session.c | 3 |
7 files changed, 61 insertions, 62 deletions
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c index a247929a058..83437183d1d 100644 --- a/src/svm/fifo_segment.c +++ b/src/svm/fifo_segment.c @@ -206,12 +206,12 @@ fifo_segment_create (fifo_segment_main_t * sm, fifo_segment_create_args_t * a) baseva = a->segment_type == SSVM_SEGMENT_PRIVATE ? ~0ULL : sm->next_baseva; fs->ssvm.ssvm_size = a->segment_size; - fs->ssvm.i_am_master = 1; + fs->ssvm.is_server = 1; fs->ssvm.my_pid = getpid (); fs->ssvm.name = format (0, "%s%c", a->segment_name, 0); fs->ssvm.requested_va = baseva; - if ((rv = ssvm_master_init (&fs->ssvm, a->segment_type))) + if ((rv = ssvm_server_init (&fs->ssvm, a->segment_type))) { pool_put (sm->segments, fs); return (rv); @@ -245,7 +245,7 @@ fifo_segment_attach (fifo_segment_main_t * sm, fifo_segment_create_args_t * a) else fs->ssvm.attach_timeout = sm->timeout_in_seconds; - if ((rv = ssvm_slave_init (&fs->ssvm, a->segment_type))) + if ((rv = ssvm_client_init (&fs->ssvm, a->segment_type))) { _vec_len (fs) = vec_len (fs) - 1; return (rv); diff --git a/src/svm/ssvm.c b/src/svm/ssvm.c index 191dbe571c7..aca65ad6f42 100644 --- a/src/svm/ssvm.c +++ b/src/svm/ssvm.c @@ -18,15 +18,15 @@ typedef int (*init_fn) (ssvm_private_t *); typedef void (*delete_fn) (ssvm_private_t *); -static init_fn master_init_fns[SSVM_N_SEGMENT_TYPES] = - { ssvm_master_init_shm, ssvm_master_init_memfd, ssvm_master_init_private }; -static init_fn slave_init_fns[SSVM_N_SEGMENT_TYPES] = - { ssvm_slave_init_shm, ssvm_slave_init_memfd, ssvm_slave_init_private }; +static init_fn server_init_fns[SSVM_N_SEGMENT_TYPES] = + { ssvm_server_init_shm, ssvm_server_init_memfd, ssvm_server_init_private }; +static init_fn client_init_fns[SSVM_N_SEGMENT_TYPES] = + { ssvm_client_init_shm, ssvm_client_init_memfd, ssvm_client_init_private }; static delete_fn delete_fns[SSVM_N_SEGMENT_TYPES] = { ssvm_delete_shm, ssvm_delete_memfd, ssvm_delete_private }; int -ssvm_master_init_shm (ssvm_private_t * ssvm) +ssvm_server_init_shm (ssvm_private_t * ssvm) { int ssvm_fd; u8 junk = 0, *ssvm_filename; @@ -96,13 +96,13 @@ ssvm_master_init_shm (ssvm_private_t * ssvm) close (ssvm_fd); CLIB_MEM_UNPOISON (sh, sizeof (*sh)); - sh->master_pid = ssvm->my_pid; + sh->server_pid = ssvm->my_pid; sh->ssvm_size = ssvm->ssvm_size; sh->ssvm_va = pointer_to_uword (sh); sh->type = SSVM_SEGMENT_SHM; sh->heap = clib_mem_create_heap (((u8 *) sh) + page_size, ssvm->ssvm_size - page_size, - 1 /* locked */ , "ssvm master shm"); + 1 /* locked */ , "ssvm server shm"); oldheap = ssvm_push_heap (sh); sh->name = format (0, "%s", ssvm->name, 0); @@ -110,21 +110,21 @@ ssvm_master_init_shm (ssvm_private_t * ssvm) ssvm->sh = sh; ssvm->my_pid = getpid (); - ssvm->i_am_master = 1; + ssvm->is_server = 1; /* The application has to set set sh->ready... */ return 0; } int -ssvm_slave_init_shm (ssvm_private_t * ssvm) +ssvm_client_init_shm (ssvm_private_t * ssvm) { struct stat stat; int ssvm_fd = -1; ssvm_shared_header_t *sh; ASSERT (vec_c_string_is_terminated (ssvm->name)); - ssvm->i_am_master = 0; + ssvm->is_server = 0; while (ssvm->attach_timeout-- > 0) { @@ -144,15 +144,15 @@ ssvm_slave_init_shm (ssvm_private_t * ssvm) if (stat.st_size > 0) goto map_it; } - clib_warning ("slave timeout"); - return SSVM_API_ERROR_SLAVE_TIMEOUT; + clib_warning ("client timeout"); + return SSVM_API_ERROR_CLIENT_TIMEOUT; map_it: sh = (void *) mmap (0, MMAP_PAGESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, ssvm_fd, 0); if (sh == MAP_FAILED) { - clib_unix_warning ("slave research mmap"); + clib_unix_warning ("client research mmap"); close (ssvm_fd); return SSVM_API_ERROR_MMAP; } @@ -164,8 +164,8 @@ map_it: } close (ssvm_fd); munmap (sh, MMAP_PAGESIZE); - clib_warning ("slave timeout 2"); - return SSVM_API_ERROR_SLAVE_TIMEOUT; + clib_warning ("client timeout 2"); + return SSVM_API_ERROR_CLIENT_TIMEOUT; re_map_it: ssvm->requested_va = sh->ssvm_va; @@ -178,11 +178,11 @@ re_map_it: if (sh == MAP_FAILED) { - clib_unix_warning ("slave final mmap"); + clib_unix_warning ("client final mmap"); close (ssvm_fd); return SSVM_API_ERROR_MMAP; } - sh->slave_pid = getpid (); + sh->client_pid = getpid (); return 0; } @@ -204,17 +204,17 @@ ssvm_delete_shm (ssvm_private_t * ssvm) vec_free (fn); vec_free (ssvm->name); - if (ssvm->i_am_master) + if (ssvm->is_server) clib_mem_vm_unmap (ssvm->sh); else munmap ((void *) ssvm->sh, ssvm->ssvm_size); } /** - * Initialize memfd segment master + * Initialize memfd segment server */ int -ssvm_master_init_memfd (ssvm_private_t * memfd) +ssvm_server_init_memfd (ssvm_private_t * memfd) { int log2_page_size, n_pages; uword page_size; @@ -262,9 +262,9 @@ ssvm_master_init_memfd (ssvm_private_t * memfd) memfd->sh = sh; memfd->my_pid = getpid (); - memfd->i_am_master = 1; + memfd->is_server = 1; - sh->master_pid = memfd->my_pid; + sh->server_pid = memfd->my_pid; sh->ssvm_size = memfd->ssvm_size; sh->ssvm_va = pointer_to_uword (sh); sh->type = SSVM_SEGMENT_MEMFD; @@ -272,7 +272,7 @@ ssvm_master_init_memfd (ssvm_private_t * memfd) page_size = 1 << log2_page_size; sh->heap = clib_mem_create_heap (((u8 *) sh) + page_size, memfd->ssvm_size - page_size, - 1 /* locked */ , "ssvm master memfd"); + 1 /* locked */ , "ssvm server memfd"); oldheap = ssvm_push_heap (sh); sh->name = format (0, "%s", memfd->name, 0); ssvm_pop_heap (oldheap); @@ -282,20 +282,20 @@ ssvm_master_init_memfd (ssvm_private_t * memfd) } /** - * Initialize memfd segment slave + * Initialize memfd segment client * - * Subtly different than svm_slave_init. The caller needs to acquire + * Subtly different than svm_client_init. The caller needs to acquire * a usable file descriptor for the memfd segment e.g. via * vppinfra/socket.c:default_socket_recvmsg */ int -ssvm_slave_init_memfd (ssvm_private_t * memfd) +ssvm_client_init_memfd (ssvm_private_t * memfd) { clib_mem_vm_map_t mapa = { 0 }; ssvm_shared_header_t *sh; uword page_size; - memfd->i_am_master = 0; + memfd->is_server = 0; page_size = clib_mem_get_fd_page_size (memfd->fd); if (!page_size) @@ -312,7 +312,7 @@ ssvm_slave_init_memfd (ssvm_private_t * memfd) if (clib_mem_vm_ext_map (&mapa)) { - clib_unix_warning ("slave research mmap (fd %d)", mapa.fd); + clib_unix_warning ("client research mmap (fd %d)", mapa.fd); close (memfd->fd); return SSVM_API_ERROR_MMAP; } @@ -329,13 +329,13 @@ ssvm_slave_init_memfd (ssvm_private_t * memfd) mapa.size = memfd->ssvm_size; if (clib_mem_vm_ext_map (&mapa)) { - clib_unix_warning ("slave final mmap"); + clib_unix_warning ("client final mmap"); close (memfd->fd); return SSVM_API_ERROR_MMAP; } sh = mapa.addr; - sh->slave_pid = getpid (); + sh->client_pid = getpid (); memfd->sh = sh; return 0; } @@ -344,7 +344,7 @@ void ssvm_delete_memfd (ssvm_private_t * memfd) { vec_free (memfd->name); - if (memfd->i_am_master) + if (memfd->is_server) clib_mem_vm_unmap (memfd->sh); else clib_mem_vm_free (memfd->sh, memfd->ssvm_size); @@ -355,7 +355,7 @@ ssvm_delete_memfd (ssvm_private_t * memfd) * Initialize segment in a private heap */ int -ssvm_master_init_private (ssvm_private_t * ssvm) +ssvm_server_init_private (ssvm_private_t * ssvm) { uword page_size, log2_page_size, rnd_size = 0; ssvm_shared_header_t *sh; @@ -382,7 +382,7 @@ ssvm_master_init_private (ssvm_private_t * ssvm) } heap = clib_mem_create_heap ((u8 *) sh + page_size, rnd_size, - 1 /* locked */ , "ssvm master private"); + 1 /* locked */ , "ssvm server private"); if (heap == 0) { clib_unix_warning ("heap alloc"); @@ -392,7 +392,7 @@ ssvm_master_init_private (ssvm_private_t * ssvm) rnd_size = clib_mem_get_heap_free_space (heap); ssvm->ssvm_size = rnd_size; - ssvm->i_am_master = 1; + ssvm->is_server = 1; ssvm->my_pid = getpid (); ssvm->requested_va = ~0; @@ -413,7 +413,7 @@ ssvm_master_init_private (ssvm_private_t * ssvm) } int -ssvm_slave_init_private (ssvm_private_t * ssvm) +ssvm_client_init_private (ssvm_private_t * ssvm) { clib_warning ("BUG: this should not be called!"); return -1; @@ -428,15 +428,15 @@ ssvm_delete_private (ssvm_private_t * ssvm) } int -ssvm_master_init (ssvm_private_t * ssvm, ssvm_segment_type_t type) +ssvm_server_init (ssvm_private_t * ssvm, ssvm_segment_type_t type) { - return (master_init_fns[type]) (ssvm); + return (server_init_fns[type]) (ssvm); } int -ssvm_slave_init (ssvm_private_t * ssvm, ssvm_segment_type_t type) +ssvm_client_init (ssvm_private_t * ssvm, ssvm_segment_type_t type) { - return (slave_init_fns[type]) (ssvm); + return (client_init_fns[type]) (ssvm); } void diff --git a/src/svm/ssvm.h b/src/svm/ssvm.h index 3a277cb5c5f..60ff3e4a2d0 100644 --- a/src/svm/ssvm.h +++ b/src/svm/ssvm.h @@ -67,12 +67,12 @@ typedef struct uword ssvm_va; /* The actual mmap size */ uword ssvm_size; - u32 master_pid; - u32 slave_pid; + u32 server_pid; + u32 client_pid; u8 *name; void *opaque[SSVM_N_OPAQUE]; - /* Set when the master application thinks it's time to make the donuts */ + /* Set when server init done */ volatile u32 ready; ssvm_segment_type_t type; @@ -86,7 +86,7 @@ typedef struct u32 my_pid; u8 *name; u8 numa; /**< UNUSED: numa requested at alloc time */ - int i_am_master; + int is_server; union { @@ -167,11 +167,11 @@ ssvm_mem_alloc (ssvm_private_t * ssvm, uword size) #define foreach_ssvm_api_error \ _(NO_NAME, "No shared segment name", -100) \ -_(NO_SIZE, "Size not set (master)", -101) \ +_(NO_SIZE, "Size not set (server)", -101) \ _(CREATE_FAILURE, "Create failed", -102) \ _(SET_SIZE, "Set size failed", -103) \ _(MMAP, "mmap failed", -104) \ -_(SLAVE_TIMEOUT, "Slave map timeout", -105) +_(CLIENT_TIMEOUT, "Client map timeout", -105) typedef enum { @@ -182,20 +182,20 @@ typedef enum #define SSVM_API_ERROR_NO_NAME (-10) -int ssvm_master_init (ssvm_private_t * ssvm, ssvm_segment_type_t type); -int ssvm_slave_init (ssvm_private_t * ssvm, ssvm_segment_type_t type); +int ssvm_server_init (ssvm_private_t * ssvm, ssvm_segment_type_t type); +int ssvm_client_init (ssvm_private_t * ssvm, ssvm_segment_type_t type); void ssvm_delete (ssvm_private_t * ssvm); -int ssvm_master_init_shm (ssvm_private_t * ssvm); -int ssvm_slave_init_shm (ssvm_private_t * ssvm); +int ssvm_server_init_shm (ssvm_private_t * ssvm); +int ssvm_client_init_shm (ssvm_private_t * ssvm); void ssvm_delete_shm (ssvm_private_t * ssvm); -int ssvm_master_init_memfd (ssvm_private_t * memfd); -int ssvm_slave_init_memfd (ssvm_private_t * memfd); +int ssvm_server_init_memfd (ssvm_private_t * memfd); +int ssvm_client_init_memfd (ssvm_private_t * memfd); void ssvm_delete_memfd (ssvm_private_t * memfd); -int ssvm_master_init_private (ssvm_private_t * ssvm); -int ssvm_slave_init_private (ssvm_private_t * ssvm); +int ssvm_server_init_private (ssvm_private_t * ssvm); +int ssvm_client_init_private (ssvm_private_t * ssvm); void ssvm_delete_private (ssvm_private_t * ssvm); ssvm_segment_type_t ssvm_type (const ssvm_private_t * ssvm); diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c index a3a0c3b2eb9..51c52b43e7a 100644 --- a/src/vlibmemory/socket_api.c +++ b/src/vlibmemory/socket_api.c @@ -639,10 +639,10 @@ vl_api_sock_init_shm_t_handler (vl_api_sock_init_shm_t * mp) clib_memset (memfd, 0, sizeof (*memfd)); memfd->ssvm_size = mp->requested_size; memfd->requested_va = 0ULL; - memfd->i_am_master = 1; + memfd->is_server = 1; memfd->name = format (0, "%s%c", regp->name, 0); - if ((rv = ssvm_master_init_memfd (memfd))) + if ((rv = ssvm_server_init_memfd (memfd))) goto reply; /* Remember to close this fd when the socket connection goes away */ diff --git a/src/vlibmemory/socket_client.c b/src/vlibmemory/socket_client.c index b7d4f2d6e54..8d9d7cefc0d 100644 --- a/src/vlibmemory/socket_client.c +++ b/src/vlibmemory/socket_client.c @@ -379,7 +379,7 @@ static void vl_api_sock_init_shm_reply_t_handler memfd->fd = my_fd; /* Note: this closes memfd.fd */ - retval = ssvm_slave_init_memfd (memfd); + retval = ssvm_client_init_memfd (memfd); if (retval) clib_warning ("WARNING: segment map returned %d", retval); diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c index 44ff5fefd70..d734d64172e 100644 --- a/src/vnet/session/segment_manager.c +++ b/src/vnet/session/segment_manager.c @@ -149,7 +149,7 @@ segment_manager_add_segment (segment_manager_t * sm, uword segment_size) /* clib_mem_vm_map_shared consumes first page before requested_va */ fs->ssvm.requested_va = baseva + page_size; - if ((rv = ssvm_master_init (&fs->ssvm, props->segment_type))) + if ((rv = ssvm_server_init (&fs->ssvm, props->segment_type))) { clib_warning ("svm_master_init ('%v', %u) failed", seg_name, segment_size); diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c index 5065f7834b1..3295ce7649d 100644 --- a/src/vnet/session/session.c +++ b/src/vnet/session/session.c @@ -1494,13 +1494,12 @@ session_vpp_event_queues_allocate (session_main_t * smm) eqs_size = smm->evt_qs_segment_size; eqs->ssvm_size = eqs_size; - eqs->i_am_master = 1; eqs->my_pid = vpp_pid; eqs->name = format (0, "%s%c", "session: evt-qs-segment", 0); /* clib_mem_vm_map_shared consumes first page before requested_va */ eqs->requested_va = smm->session_baseva + clib_mem_get_page_size (); - if (ssvm_master_init (eqs, SSVM_SEGMENT_MEMFD)) + if (ssvm_server_init (eqs, SSVM_SEGMENT_MEMFD)) { clib_warning ("failed to initialize queue segment"); return; |