aboutsummaryrefslogtreecommitdiffstats
path: root/svm/ssvm.h
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-07-08 14:44:23 -0400
committerDave Barach <dave@barachs.net>2016-07-08 14:44:38 -0400
commit8a7fb0cf6844ed09173fd58224f7753a1b504cf4 (patch)
tree45e21bd6bac95034fd589daf0ea898c6ede80afa /svm/ssvm.h
parent49a6963b1387bf7535f589f02ffc99de5b59192f (diff)
fd-io-styleify for svm
Change-Id: I816de8b1f255dc3bc6d2904566ea0b0f68fac5d8 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'svm/ssvm.h')
-rw-r--r--svm/ssvm.h57
1 files changed, 36 insertions, 21 deletions
diff --git a/svm/ssvm.h b/svm/ssvm.h
index cd34afd2..9e61b9a0 100644
--- a/svm/ssvm.h
+++ b/svm/ssvm.h
@@ -41,15 +41,16 @@
#define MMAP_PAGESIZE (4<<10)
#define SSVM_N_OPAQUE 7
-typedef struct {
+typedef struct
+{
/* Spin-lock */
volatile u32 lock;
volatile u32 owner_pid;
int recursion_count;
- u32 tag; /* for debugging */
+ u32 tag; /* for debugging */
/* The allocation arena */
- void * heap;
+ void *heap;
/* Segment must be mapped at this address, or no supper */
u64 ssvm_va;
@@ -57,8 +58,8 @@ typedef struct {
u64 ssvm_size;
u32 master_pid;
u32 slave_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 */
volatile u32 ready;
@@ -67,55 +68,60 @@ typedef struct {
u32 master_index;
} ssvm_shared_header_t;
-typedef struct {
- ssvm_shared_header_t * sh;
+typedef struct
+{
+ ssvm_shared_header_t *sh;
u64 ssvm_size;
u32 my_pid;
u32 vlib_hw_if_index;
- u8 * name;
+ u8 *name;
uword requested_va;
int i_am_master;
u32 per_interface_next_index;
- u32 * rx_queue;
+ u32 *rx_queue;
} ssvm_private_t;
-always_inline void ssvm_lock (ssvm_shared_header_t * h, u32 my_pid, u32 tag)
+always_inline void
+ssvm_lock (ssvm_shared_header_t * h, u32 my_pid, u32 tag)
{
if (h->owner_pid == my_pid)
{
h->recursion_count++;
return;
}
-
+
while (__sync_lock_test_and_set (&h->lock, 1))
;
-
+
h->owner_pid = my_pid;
h->recursion_count = 1;
h->tag = tag;
}
-always_inline void ssvm_unlock (ssvm_shared_header_t * h)
+always_inline void
+ssvm_unlock (ssvm_shared_header_t * h)
{
if (--h->recursion_count == 0)
{
h->owner_pid = 0;
h->tag = 0;
- CLIB_MEMORY_BARRIER();
+ CLIB_MEMORY_BARRIER ();
h->lock = 0;
}
}
-static inline void *ssvm_push_heap (ssvm_shared_header_t *sh)
+static inline void *
+ssvm_push_heap (ssvm_shared_header_t * sh)
{
- u8 *oldheap;
- oldheap = clib_mem_set_heap(sh->heap);
- return ((void *) oldheap);
+ u8 *oldheap;
+ oldheap = clib_mem_set_heap (sh->heap);
+ return ((void *) oldheap);
}
-static inline void ssvm_pop_heap (void *oldheap)
+static inline void
+ssvm_pop_heap (void *oldheap)
{
- clib_mem_set_heap(oldheap);
+ clib_mem_set_heap (oldheap);
}
#define foreach_ssvm_api_error \
@@ -126,7 +132,8 @@ _(SET_SIZE, "Set size failed", -13) \
_(MMAP, "mmap failed", -14) \
_(SLAVE_TIMEOUT, "Slave map timeout", -15)
-typedef enum {
+typedef enum
+{
#define _(n,s,c) SSVM_API_ERROR_##n = c,
foreach_ssvm_api_error
#undef _
@@ -138,3 +145,11 @@ int ssvm_master_init (ssvm_private_t * ssvm, u32 master_index);
int ssvm_slave_init (ssvm_private_t * ssvm, int timeout_in_seconds);
#endif /* __included_ssvm_h__ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */