diff options
author | Florin Coras <fcoras@cisco.com> | 2018-01-15 01:08:33 -0800 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2018-01-25 23:53:35 +0000 |
commit | b384b543313b6b47a277c903e9d4fcd4343054fa (patch) | |
tree | 1996e3a25eb3a32fe5bbc405d75f38dd041a5a40 /src/svm/ssvm.h | |
parent | 4e578068fc3fe8ba176d211123ddd88962dab315 (diff) |
session: add support for memfd segments
- update segment manager and session api to work with both flavors of
ssvm segments
- added generic ssvm slave/master init and del functions
- cleanup/refactor tcp_echo
- fixed uses of svm fifo pool as vector
Change-Id: Ieee8b163faa407da6e77e657a2322de213a9d2a0
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/svm/ssvm.h')
-rw-r--r-- | src/svm/ssvm.h | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/src/svm/ssvm.h b/src/svm/ssvm.h index a181f2ef864..9bf009e73d2 100644 --- a/src/svm/ssvm.h +++ b/src/svm/ssvm.h @@ -45,6 +45,13 @@ #define SSVM_N_OPAQUE 7 +typedef enum ssvm_segment_type_ +{ + SSVM_SEGMENT_SHM = 0, + SSVM_SEGMENT_MEMFD, + SSVM_N_SEGMENT_TYPES /**< Private segments */ +} ssvm_segment_type_t; + typedef struct { /* Spin-lock */ @@ -68,8 +75,7 @@ typedef struct /* Set when the master application thinks it's time to make the donuts */ volatile u32 ready; - /* Needed to make unique MAC addresses, etc. */ - u32 master_index; + ssvm_segment_type_t type; } ssvm_shared_header_t; typedef struct @@ -81,8 +87,11 @@ typedef struct uword requested_va; int i_am_master; - /* Needed by memfd segments */ - int fd; + union + { + int fd; /**< memfd segments */ + int attach_timeout; /**< shm segments attach timeout (sec) */ + }; } ssvm_private_t; always_inline void @@ -145,6 +154,18 @@ ssvm_pop_heap (void *oldheap) clib_mem_set_heap (oldheap); } +static inline void * +ssvm_mem_alloc (ssvm_private_t * ssvm, uword size) +{ + u8 *oldheap; + void *rv; + + oldheap = clib_mem_set_heap (ssvm->sh->heap); + rv = clib_mem_alloc (size); + clib_mem_set_heap (oldheap); + return (rv); +} + #define foreach_ssvm_api_error \ _(NO_NAME, "No shared segment name", -100) \ _(NO_SIZE, "Size not set (master)", -101) \ @@ -162,14 +183,21 @@ typedef enum #define SSVM_API_ERROR_NO_NAME (-10) -int ssvm_master_init (ssvm_private_t * ssvm, u32 master_index); -int ssvm_slave_init (ssvm_private_t * ssvm, int timeout_in_seconds); +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); void ssvm_delete (ssvm_private_t * ssvm); -int ssvm_master_init_memfd (ssvm_private_t * memfd, u32 master_index); +int ssvm_master_init_shm (ssvm_private_t * ssvm); +int ssvm_slave_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); void ssvm_delete_memfd (ssvm_private_t * memfd); +ssvm_segment_type_t ssvm_type (const ssvm_private_t * ssvm); +u8 *ssvm_name (const ssvm_private_t * ssvm); + #endif /* __included_ssvm_h__ */ /* |