Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
nat: nat44-ed pool address allocation improvement
[vpp.git]
/
src
/
svm
/
ssvm.h
diff --git
a/src/svm/ssvm.h
b/src/svm/ssvm.h
index
9bf009e
..
9bd16a9
100644
(file)
--- a/
src/svm/ssvm.h
+++ b/
src/svm/ssvm.h
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
+ * Copyright (c) 2015
-2019
Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@
-33,11
+33,10
@@
#include <vppinfra/bitmap.h>
#include <vppinfra/fifo.h>
#include <vppinfra/time.h>
#include <vppinfra/bitmap.h>
#include <vppinfra/fifo.h>
#include <vppinfra/time.h>
-#include <vppinfra/mheap.h>
#include <vppinfra/heap.h>
#include <vppinfra/pool.h>
#include <vppinfra/format.h>
#include <vppinfra/heap.h>
#include <vppinfra/pool.h>
#include <vppinfra/format.h>
-#include <vppinfra/l
inux/syscall
.h>
+#include <vppinfra/l
ock
.h>
#ifndef MMAP_PAGESIZE
#define MMAP_PAGESIZE (clib_mem_get_page_size())
#ifndef MMAP_PAGESIZE
#define MMAP_PAGESIZE (clib_mem_get_page_size())
@@
-49,6
+48,7
@@
typedef enum ssvm_segment_type_
{
SSVM_SEGMENT_SHM = 0,
SSVM_SEGMENT_MEMFD,
{
SSVM_SEGMENT_SHM = 0,
SSVM_SEGMENT_MEMFD,
+ SSVM_SEGMENT_PRIVATE,
SSVM_N_SEGMENT_TYPES /**< Private segments */
} ssvm_segment_type_t;
SSVM_N_SEGMENT_TYPES /**< Private segments */
} ssvm_segment_type_t;
@@
-64,15
+64,15
@@
typedef struct
void *heap;
/* Segment must be mapped at this address, or no supper */
void *heap;
/* Segment must be mapped at this address, or no supper */
- u
64
ssvm_va;
+ u
word
ssvm_va;
/* The actual mmap size */
/* The actual mmap size */
- u
64
ssvm_size;
- u32
mast
er_pid;
- u32
slave
_pid;
+ u
word
ssvm_size;
+ u32
serv
er_pid;
+ u32
client
_pid;
u8 *name;
void *opaque[SSVM_N_OPAQUE];
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;
volatile u32 ready;
ssvm_segment_type_t type;
@@
-81,11
+81,12
@@
typedef struct
typedef struct
{
ssvm_shared_header_t *sh;
typedef struct
{
ssvm_shared_header_t *sh;
- u64 ssvm_size;
+ uword ssvm_size;
+ uword requested_va;
u32 my_pid;
u8 *name;
u32 my_pid;
u8 *name;
- u
word requested_va;
- int i
_am_mast
er;
+ u
8 numa; /**< UNUSED: numa requested at alloc time */
+ int i
s_serv
er;
union
{
union
{
@@
-103,8
+104,8
@@
ssvm_lock (ssvm_shared_header_t * h, u32 my_pid, u32 tag)
return;
}
return;
}
- while (
__sync_lock_test_and_set (&h->lock, 1
))
- ;
+ while (
clib_atomic_test_and_set (&h->lock
))
+
CLIB_PAUSE ()
;
h->owner_pid = my_pid;
h->recursion_count = 1;
h->owner_pid = my_pid;
h->recursion_count = 1;
@@
-114,8
+115,8
@@
ssvm_lock (ssvm_shared_header_t * h, u32 my_pid, u32 tag)
always_inline void
ssvm_lock_non_recursive (ssvm_shared_header_t * h, u32 tag)
{
always_inline void
ssvm_lock_non_recursive (ssvm_shared_header_t * h, u32 tag)
{
- while (
__sync_lock_test_and_set (&h->lock, 1
))
- ;
+ while (
clib_atomic_test_and_set (&h->lock
))
+
CLIB_PAUSE ()
;
h->tag = tag;
}
h->tag = tag;
}
@@
-127,8
+128,7
@@
ssvm_unlock (ssvm_shared_header_t * h)
{
h->owner_pid = 0;
h->tag = 0;
{
h->owner_pid = 0;
h->tag = 0;
- CLIB_MEMORY_BARRIER ();
- h->lock = 0;
+ clib_atomic_release (&h->lock);
}
}
}
}
@@
-136,14
+136,13
@@
always_inline void
ssvm_unlock_non_recursive (ssvm_shared_header_t * h)
{
h->tag = 0;
ssvm_unlock_non_recursive (ssvm_shared_header_t * h)
{
h->tag = 0;
- CLIB_MEMORY_BARRIER ();
- h->lock = 0;
+ clib_atomic_release (&h->lock);
}
static inline void *
ssvm_push_heap (ssvm_shared_header_t * sh)
{
}
static inline void *
ssvm_push_heap (ssvm_shared_header_t * sh)
{
-
u8
*oldheap;
+
clib_mem_heap_t
*oldheap;
oldheap = clib_mem_set_heap (sh->heap);
return ((void *) oldheap);
}
oldheap = clib_mem_set_heap (sh->heap);
return ((void *) oldheap);
}
@@
-157,7
+156,7
@@
ssvm_pop_heap (void *oldheap)
static inline void *
ssvm_mem_alloc (ssvm_private_t * ssvm, uword size)
{
static inline void *
ssvm_mem_alloc (ssvm_private_t * ssvm, uword size)
{
-
u8
*oldheap;
+
clib_mem_heap_t
*oldheap;
void *rv;
oldheap = clib_mem_set_heap (ssvm->sh->heap);
void *rv;
oldheap = clib_mem_set_heap (ssvm->sh->heap);
@@
-168,11
+167,11
@@
ssvm_mem_alloc (ssvm_private_t * ssvm, uword size)
#define foreach_ssvm_api_error \
_(NO_NAME, "No shared segment name", -100) \
#define foreach_ssvm_api_error \
_(NO_NAME, "No shared segment name", -100) \
-_(NO_SIZE, "Size not set (
mast
er)", -101) \
+_(NO_SIZE, "Size not set (
serv
er)", -101) \
_(CREATE_FAILURE, "Create failed", -102) \
_(SET_SIZE, "Set size failed", -103) \
_(MMAP, "mmap failed", -104) \
_(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
{
typedef enum
{
@@
-183,18
+182,22
@@
typedef enum
#define SSVM_API_ERROR_NO_NAME (-10)
#define SSVM_API_ERROR_NO_NAME (-10)
-int ssvm_
mast
er_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_
serv
er_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);
void ssvm_delete (ssvm_private_t * ssvm);
-int ssvm_
mast
er_init_shm (ssvm_private_t * ssvm);
-int ssvm_
slave
_init_shm (ssvm_private_t * ssvm);
+int ssvm_
serv
er_init_shm (ssvm_private_t * ssvm);
+int ssvm_
client
_init_shm (ssvm_private_t * ssvm);
void ssvm_delete_shm (ssvm_private_t * ssvm);
void ssvm_delete_shm (ssvm_private_t * ssvm);
-int ssvm_
mast
er_init_memfd (ssvm_private_t * memfd);
-int ssvm_
slave
_init_memfd (ssvm_private_t * memfd);
+int ssvm_
serv
er_init_memfd (ssvm_private_t * memfd);
+int ssvm_
client
_init_memfd (ssvm_private_t * memfd);
void ssvm_delete_memfd (ssvm_private_t * memfd);
void ssvm_delete_memfd (ssvm_private_t * memfd);
+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);
u8 *ssvm_name (const ssvm_private_t * ssvm);
ssvm_segment_type_t ssvm_type (const ssvm_private_t * ssvm);
u8 *ssvm_name (const ssvm_private_t * ssvm);