diff mbox

[2/3] odp_ring: add flag to put ring to shared memory

Message ID 1406973539-2268-2-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Aug. 2, 2014, 9:58 a.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(-)

Comments

Ciprian Barbu Aug. 4, 2014, noon UTC | #1
On Sat, Aug 2, 2014 at 12:58 PM, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
> 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 --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..fdff502 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_THREAD;
> +       else
> +               shm_flag = ODP_SHM_PROC;

The conditions should be the other way around.

>
>         /* 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 */
> --
> 1.8.5.1.163.gd7aced9
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Maxim Uvarov Aug. 4, 2014, 12:18 p.m. UTC | #2
On 08/04/2014 04:00 PM, Ciprian Barbu wrote:
>> +
>> >+       if (flags & ODP_RING_SHM_PROC)
>> >+               shm_flag = ODP_SHM_THREAD;
>> >+       else
>> >+               shm_flag = ODP_SHM_PROC;
> The conditions should be the other way around.
>
Thanks, looks like did error on patch clean up. Will fix in v2.

Maxim.
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..fdff502 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_THREAD;
+	else
+		shm_flag = ODP_SHM_PROC;
 
 	/* 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 */