diff mbox

[IPC,DISCUSSION,2/6] odp_ring: add flag to put ring to shared memory

Message ID 1407415686-352-3-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Aug. 7, 2014, 12:48 p.m. UTC
Add flag to put odp_ring to shared memory visible by different
processes.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 include/helper/odp_ring.h         | 2 ++
 platform/linux-generic/odp_ring.c | 8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/include/helper/odp_ring.h b/include/helper/odp_ring.h
index 0911531..60960a2 100644
--- a/include/helper/odp_ring.h
+++ b/include/helper/odp_ring.h
@@ -158,6 +158,8 @@  typedef struct odp_ring {
 
 #define ODP_RING_F_SP_ENQ 0x0001 /* The default enqueue is "single-producer". */
 #define ODP_RING_F_SC_DEQ 0x0002 /* The default dequeue is "single-consumer". */
+#define ODP_RING_SHM_PROC 0x0004 /* If set - ring is visible from different
+				    processes. Default is thread visible.     */
 #define ODP_RING_QUOT_EXCEED (1 << 31)  /* Quota exceed for burst ops */
 #define ODP_RING_SZ_MASK  (unsigned)(0x0fffffff) /* Ring size mask */
 
diff --git a/platform/linux-generic/odp_ring.c b/platform/linux-generic/odp_ring.c
index ee8175e..1ecc638 100644
--- a/platform/linux-generic/odp_ring.c
+++ b/platform/linux-generic/odp_ring.c
@@ -158,6 +158,12 @@  odp_ring_create(const char *name, unsigned count, unsigned flags)
 	char ring_name[ODP_RING_NAMESIZE];
 	odp_ring_t *r;
 	size_t ring_size;
+	odp_shm_e shm_flag;
+
+	if (flags & ODP_RING_SHM_PROC)
+		shm_flag = ODP_SHM_PROC;
+	else
+		shm_flag = ODP_SHM_THREAD;
 
 	/* count must be a power of 2 */
 	if (!ODP_VAL_IS_POWER_2(count) || (count > ODP_RING_SZ_MASK)) {
@@ -172,7 +178,7 @@  odp_ring_create(const char *name, unsigned count, unsigned flags)
 	odp_rwlock_write_lock(&qlock);
 	/* reserve a memory zone for this ring.*/
 	r = odp_shm_reserve(ring_name, ring_size, ODP_CACHE_LINE_SIZE,
-			    ODP_SHM_THREAD);
+			    shm_flag);
 
 	if (r != NULL) {
 		/* init the ring structure */