Re: [lng-odp] [API-NEXT PATCH v3 0/6] Multi-queue pktio for poll mode

2016-01-18 Thread Maxim Uvarov

Stuart, can you please review this?

Maxim.

On 01/11/2016 14:39, Petri Savolainen wrote:

This patch set adds support for multi-queue pktio for poll mode queues.

v3:
   * Rebased

v2:
   * Bug correction in patch 2/6: bad netmap initialization when using
 the old API.

Matias Elo (1):
   linux-generic: netmap: map rings in netmap_start

Petri Savolainen (5):
   linux-generic: pktio: re-organize queue config code
   linux-generic: pktio: added poll type input queue
   linux-generic: pktio: use multiqueue recv internally
   test: l2fwd: re-organize functions
   test: l2fwd: added poll queue mode

  platform/linux-generic/include/odp_packet_netmap.h |   7 +-
  .../linux-generic/include/odp_queue_internal.h |   2 +-
  platform/linux-generic/odp_packet_io.c | 216 --
  platform/linux-generic/odp_queue.c |   2 +
  platform/linux-generic/pktio/netmap.c  | 124 +---
  test/performance/odp_l2fwd.c   | 797 -
  6 files changed, 632 insertions(+), 516 deletions(-)



___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v6] validation: system: add validation tests for odp_cpu_cycles_* calls

2016-01-18 Thread Ivan Khoronzhuk
https://bugs.linaro.org/show_bug.cgi?id=1906

Signed-off-by: Ivan Khoronzhuk 
---
Since v5:
- add res instead of "1" while wrap
- get cycle stamps a multiple of res instead direct valuues.
- move resolution test before diff test

Since v3:
- modified log "wrap is not detected"
- increased try num for diff to match 16 seconds
- decreased try num for resolution to match 1 second
- allow resolution to be up to max / 1024
- correct wrap detection for resolution

Since v2:
- added c <= max
- replaced etalon on tmp
- added msg about skip
- handled resolution wrap

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch validation_tests_corrections
# Changes to be committed:
#   modified:   platform/linux-keystone2/odp_crypto.c
#   modified:   test/validation/system/system.c
#
# Changes not staged for commit:
#   modified:   platform/linux-keystone2/odp_schedule.c
#
# Untracked files:
#   .checkpatch-camelcase.git.81a3df4
#   example/traffic_mgmt/
#

 test/validation/system/system.c | 125 
 test/validation/system/system.h |   4 ++
 2 files changed, 129 insertions(+)

diff --git a/test/validation/system/system.c b/test/validation/system/system.c
index 7dc2cc0..7f54338 100644
--- a/test/validation/system/system.c
+++ b/test/validation/system/system.c
@@ -10,6 +10,9 @@
 #include "test_debug.h"
 #include "system.h"
 
+#define DIFF_TRY_NUM   160
+#define RES_TRY_NUM10
+
 void system_test_odp_version_numbers(void)
 {
int char_ok = 0;
@@ -40,6 +43,124 @@ void system_test_odp_cpu_count(void)
CU_ASSERT(0 < cpus);
 }
 
+void system_test_odp_cpu_cycles(void)
+{
+   uint64_t c2, c1;
+
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(100);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c2 != c1);
+}
+
+void system_test_odp_cpu_cycles_max(void)
+{
+   uint64_t c2, c1;
+   uint64_t max1, max2;
+
+   max1 = odp_cpu_cycles_max();
+   odp_time_wait_ns(100);
+   max2 = odp_cpu_cycles_max();
+
+   CU_ASSERT(max1 >= UINT32_MAX / 2);
+   CU_ASSERT(max1 == max2);
+
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(1000);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c1 <= max1 && c2 <= max1);
+}
+
+void system_test_odp_cpu_cycles_resolution(void)
+{
+   int i;
+   uint64_t res;
+   uint64_t c2, c1, max;
+
+   max = odp_cpu_cycles_max();
+
+   res = odp_cpu_cycles_resolution();
+   CU_ASSERT(res != 0);
+   CU_ASSERT(res < max / 1024);
+
+   for (i = 0; i < RES_TRY_NUM; i++) {
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c1 % res == 0);
+   CU_ASSERT(c2 % res == 0);
+   }
+}
+
+void system_test_odp_cpu_cycles_diff(void)
+{
+   int i;
+   uint64_t c2, c1, c3, max;
+   uint64_t tmp, diff, res;
+
+   res = odp_cpu_cycles_resolution();
+   max = odp_cpu_cycles_max();
+
+   /* check resolution for wrap */
+   c1 = max - 2 * res;
+   do
+   c2 = odp_cpu_cycles();
+   while (c1 < c2);
+
+   diff = odp_cpu_cycles_diff(c1, c1);
+   CU_ASSERT(diff == 0);
+
+   /* wrap */
+   tmp = c2 + (max - c1) + res;
+   diff = odp_cpu_cycles_diff(c2, c1);
+   CU_ASSERT(diff == tmp);
+   CU_ASSERT(diff % res == 0);
+
+   /* no wrap, revert args */
+   tmp = c1 - c2;
+   diff = odp_cpu_cycles_diff(c1, c2);
+   CU_ASSERT(diff == tmp);
+   CU_ASSERT(diff % res == 0);
+
+   c3 = odp_cpu_cycles();
+   for (i = 0; i < DIFF_TRY_NUM; i++) {
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c2 != c1);
+   CU_ASSERT(c1 % res == 0);
+   CU_ASSERT(c2 % res == 0);
+   CU_ASSERT(c1 <= max && c2 <= max);
+
+   if (c2 > c1)
+   tmp = c2 - c1;
+   else
+   tmp = c2 + (max - c1) + res;
+
+   diff = odp_cpu_cycles_diff(c2, c1);
+   CU_ASSERT(diff == tmp);
+   CU_ASSERT(diff % res == 0);
+
+   /* wrap is detected and verified */
+   if (c2 < c1)
+   break;
+   }
+
+   /* wrap was detected, no need to continue */
+   if (i < DIFF_TRY_NUM)
+   return;
+
+   /* wrap has to be detected if possible */
+   CU_ASSERT(max > UINT32_MAX);
+   CU_ASSERT((max - c3) > UINT32_MAX);
+
+   printf("wrap was not detected...");
+}
+
 void system_test_odp_sys_cache_line_size(void)
 {
uint64_t cache_size;
@@ -91,6 +212,10 @@ odp_testinfo_t system_suite[] = {

[lng-odp] [API-NEXT PATCH v2 04/13] api: atomic: add non-relaxed 64bit operations

2016-01-18 Thread Petri Savolainen
Added 64 bit versions of the same set of non-relaxed atomic
operations that are already defined for 32 bit.

Signed-off-by: Petri Savolainen 
---
 include/odp/api/atomic.h | 99 
 1 file changed, 99 insertions(+)

diff --git a/include/odp/api/atomic.h b/include/odp/api/atomic.h
index aa20c61..1abaaf3 100644
--- a/include/odp/api/atomic.h
+++ b/include/odp/api/atomic.h
@@ -435,6 +435,105 @@ int odp_atomic_cas_rel_u32(odp_atomic_u32_t *atom, 
uint32_t *old_val,
 int odp_atomic_cas_acq_rel_u32(odp_atomic_u32_t *atom, uint32_t *old_val,
   uint32_t new_val);
 
+/*
+ * 64-bit operations in non-RELAXED memory ordering
+ * 
+ */
+
+/**
+ * Load value of atomic uint64 variable using ACQUIRE memory ordering
+ *
+ * Otherwise identical to odp_atomic_load_u64() but ensures ACQUIRE memory
+ * ordering.
+ *
+ * @param atomPointer to atomic variable
+ *
+ * @return Value of the variable
+ */
+uint64_t odp_atomic_load_acq_u64(odp_atomic_u64_t *atom);
+
+/**
+ * Store value to atomic uint64 variable using RELEASE memory ordering
+ *
+ * Otherwise identical to odp_atomic_store_u64() but ensures RELEASE memory
+ * ordering.
+ *
+ * @param atomPointer to atomic variable
+ * @param val Value to store in the variable
+ */
+void odp_atomic_store_rel_u64(odp_atomic_u64_t *atom, uint64_t val);
+
+/**
+ * Add to atomic uint64 variable using RELEASE memory ordering
+ *
+ * Otherwise identical to odp_atomic_add_u64() but ensures RELEASE memory
+ * ordering.
+ *
+ * @param atomPointer to atomic variable
+ * @param val Value to be added to the variable
+ */
+void odp_atomic_add_rel_u64(odp_atomic_u64_t *atom, uint64_t val);
+
+/**
+ * Subtract from atomic uint64 variable using RELEASE memory ordering
+ *
+ * Otherwise identical to odp_atomic_sub_u64() but ensures RELEASE memory
+ * ordering.
+ *
+ * @param atomPointer to atomic variable
+ * @param val Value to be subtracted from the variable
+ */
+void odp_atomic_sub_rel_u64(odp_atomic_u64_t *atom, uint64_t val);
+
+/**
+ * Compare and swap atomic uint64 variable using ACQUIRE memory ordering
+ *
+ * Otherwise identical to odp_atomic_cas_u64() but ensures ACQUIRE memory
+ * ordering on success. Memory ordering is RELAXED on failure.
+ *
+ * @param atom  Pointer to atomic variable
+ * @param[in,out] old_val   Pointer to the old value of the atomic variable.
+ *  Operation updates this value on failure.
+ * @param new_val   New value to be written into the atomic variable
+ *
+ * @return 0 on failure, !0 on success
+ */
+int odp_atomic_cas_acq_u64(odp_atomic_u64_t *atom, uint64_t *old_val,
+  uint64_t new_val);
+
+/**
+ * Compare and swap atomic uint64 variable using RELEASE memory ordering
+ *
+ * Otherwise identical to odp_atomic_cas_u64() but ensures RELEASE memory
+ * ordering on success. Memory ordering is RELAXED on failure.
+ *
+ * @param atom  Pointer to atomic variable
+ * @param[in,out] old_val   Pointer to the old value of the atomic variable.
+ *  Operation updates this value on failure.
+ * @param new_val   New value to be written into the atomic variable
+ *
+ * @return 0 on failure, !0 on success
+ */
+int odp_atomic_cas_rel_u64(odp_atomic_u64_t *atom, uint64_t *old_val,
+  uint64_t new_val);
+
+/**
+ * Compare and swap atomic uint64 variable using ACQUIRE-and-RELEASE memory
+ * ordering
+ *
+ * Otherwise identical to odp_atomic_cas_u64() but ensures ACQUIRE-and-RELEASE
+ * memory ordering on success. Memory ordering is RELAXED on failure.
+ *
+ * @param atom  Pointer to atomic variable
+ * @param[in,out] old_val   Pointer to the old value of the atomic variable.
+ *  Operation updates this value on failure.
+ * @param new_val   New value to be written into the atomic variable
+ *
+ * @return 0 on failure, !0 on success
+ */
+int odp_atomic_cas_acq_rel_u64(odp_atomic_u64_t *atom, uint64_t *old_val,
+  uint64_t new_val);
+
 /**
  * Atomic operations
  *
-- 
2.6.3

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [API-NEXT PATCH v2 11/13] validation: atomic: added non-relaxed test

2016-01-18 Thread Petri Savolainen
Added validation test for all operations with non-relaxed
memory model. Mainly testing that functions are available.

Signed-off-by: Petri Savolainen 
---
 test/validation/synchronizers/synchronizers.c | 82 +++
 test/validation/synchronizers/synchronizers.h |  1 +
 2 files changed, 83 insertions(+)

diff --git a/test/validation/synchronizers/synchronizers.c 
b/test/validation/synchronizers/synchronizers.c
index 6fb122a..c2f95c7 100644
--- a/test/validation/synchronizers/synchronizers.c
+++ b/test/validation/synchronizers/synchronizers.c
@@ -1329,6 +1329,68 @@ static void test_atomic_xchg_64(void)
}
 }
 
+static void test_atomic_non_relaxed_32(void)
+{
+   int i;
+   uint32_t tmp;
+
+   for (i = 0; i < CNT; i++) {
+   tmp = odp_atomic_load_acq_u32();
+   odp_atomic_store_rel_u32(, tmp);
+
+   tmp = odp_atomic_load_acq_u32(_max);
+   odp_atomic_add_rel_u32(_max, 1);
+
+   tmp = odp_atomic_load_acq_u32(_min);
+   odp_atomic_sub_rel_u32(_min, 1);
+
+   tmp = odp_atomic_load_u32(_xchg);
+   while (odp_atomic_cas_acq_u32(_xchg, , tmp + 1) == 0)
+   ;
+
+   tmp = odp_atomic_load_u32(_xchg);
+   while (odp_atomic_cas_rel_u32(_xchg, , tmp + 1) == 0)
+   ;
+
+   tmp = odp_atomic_load_u32(_xchg);
+   /* finally set to 1 for validation */
+   while (odp_atomic_cas_acq_rel_u32(_xchg, , 1)
+  == 0)
+   ;
+   }
+}
+
+static void test_atomic_non_relaxed_64(void)
+{
+   int i;
+   uint64_t tmp;
+
+   for (i = 0; i < CNT; i++) {
+   tmp = odp_atomic_load_acq_u64();
+   odp_atomic_store_rel_u64(, tmp);
+
+   tmp = odp_atomic_load_acq_u64(_max);
+   odp_atomic_add_rel_u64(_max, 1);
+
+   tmp = odp_atomic_load_acq_u64(_min);
+   odp_atomic_sub_rel_u64(_min, 1);
+
+   tmp = odp_atomic_load_u64(_xchg);
+   while (odp_atomic_cas_acq_u64(_xchg, , tmp + 1) == 0)
+   ;
+
+   tmp = odp_atomic_load_u64(_xchg);
+   while (odp_atomic_cas_rel_u64(_xchg, , tmp + 1) == 0)
+   ;
+
+   tmp = odp_atomic_load_u64(_xchg);
+   /* finally set to 1 for validation */
+   while (odp_atomic_cas_acq_rel_u64(_xchg, , 1)
+  == 0)
+   ;
+   }
+}
+
 static void test_atomic_inc_dec_32(void)
 {
test_atomic_inc_32();
@@ -1790,6 +1852,19 @@ static void *test_atomic_xchg_thread(void *arg UNUSED)
return NULL;
 }
 
+static void *test_atomic_non_relaxed_thread(void *arg UNUSED)
+{
+   per_thread_mem_t *per_thread_mem;
+
+   per_thread_mem = thread_init();
+   test_atomic_non_relaxed_32();
+   test_atomic_non_relaxed_64();
+
+   thread_finalize(per_thread_mem);
+
+   return NULL;
+}
+
 static void test_atomic_functional(void *func_ptr(void *), int check)
 {
pthrd_arg arg;
@@ -1837,6 +1912,12 @@ void synchronizers_test_atomic_xchg(void)
test_atomic_functional(test_atomic_xchg_thread, CHECK_XCHG);
 }
 
+void synchronizers_test_atomic_non_relaxed(void)
+{
+   test_atomic_functional(test_atomic_non_relaxed_thread,
+  CHECK_MAX_MIN | CHECK_XCHG);
+}
+
 odp_testinfo_t synchronizers_suite_atomic[] = {
ODP_TEST_INFO(synchronizers_test_atomic_inc_dec),
ODP_TEST_INFO(synchronizers_test_atomic_add_sub),
@@ -1845,6 +1926,7 @@ odp_testinfo_t synchronizers_suite_atomic[] = {
ODP_TEST_INFO(synchronizers_test_atomic_max_min),
ODP_TEST_INFO(synchronizers_test_atomic_cas_inc_dec),
ODP_TEST_INFO(synchronizers_test_atomic_xchg),
+   ODP_TEST_INFO(synchronizers_test_atomic_non_relaxed),
ODP_TEST_INFO_NULL,
 };
 
diff --git a/test/validation/synchronizers/synchronizers.h 
b/test/validation/synchronizers/synchronizers.h
index 98d8fae..6644522 100644
--- a/test/validation/synchronizers/synchronizers.h
+++ b/test/validation/synchronizers/synchronizers.h
@@ -31,6 +31,7 @@ void synchronizers_test_atomic_fetch_add_sub(void);
 void synchronizers_test_atomic_max_min(void);
 void synchronizers_test_atomic_cas_inc_dec(void);
 void synchronizers_test_atomic_xchg(void);
+void synchronizers_test_atomic_non_relaxed(void);
 
 /* test arrays: */
 extern odp_testinfo_t synchronizers_suite_barrier[];
-- 
2.6.3

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v5] validation: system: add validation tests for odp_cpu_cycles_* calls

2016-01-18 Thread Savolainen, Petri (Nokia - FI/Espoo)


> -Original Message-
> From: EXT Ivan Khoronzhuk [mailto:ivan.khoronz...@linaro.org]
> Sent: Monday, January 18, 2016 2:24 PM
> To: Savolainen, Petri (Nokia - FI/Espoo); lng-odp@lists.linaro.org
> Subject: Re: [lng-odp] [PATCH v5] validation: system: add validation tests
> for odp_cpu_cycles_* calls
> 
> 
> 
> On 18.01.16 13:37, Savolainen, Petri (Nokia - FI/Espoo) wrote:
> >
> >
> >> -Original Message-
> >> From: EXT Ivan Khoronzhuk [mailto:ivan.khoronz...@linaro.org]
> >> Sent: Friday, January 15, 2016 5:07 PM
> >> To: lng-odp@lists.linaro.org
> >> Cc: Savolainen, Petri (Nokia - FI/Espoo); Ivan Khoronzhuk
> >> Subject: [lng-odp] [PATCH v5] validation: system: add validation tests
> for
> >> odp_cpu_cycles_* calls
> >>
> >> https://bugs.linaro.org/show_bug.cgi?id=1906
> >>
> >> Signed-off-by: Ivan Khoronzhuk 
> >> ---
> >>   test/validation/system/system.c | 130
> >> 
> >>   test/validation/system/system.h |   4 ++
> >>   2 files changed, 134 insertions(+)
> >>
> >> diff --git a/test/validation/system/system.c
> >> b/test/validation/system/system.c
> >> index 7dc2cc0..f59c570 100644
> >> --- a/test/validation/system/system.c
> >> +++ b/test/validation/system/system.c
> >> @@ -10,6 +10,9 @@
> >>   #include "test_debug.h"
> >>   #include "system.h"
> >>
> >> +#define DIFF_TRY_NUM  160
> >> +#define RES_TRY_NUM   10
> >> +
> >>   void system_test_odp_version_numbers(void)
> >>   {
> >>int char_ok = 0;
> >> @@ -40,6 +43,129 @@ void system_test_odp_cpu_count(void)
> >>CU_ASSERT(0 < cpus);
> >>   }
> >>
> >> +void system_test_odp_cpu_cycles(void)
> >> +{
> >> +  uint64_t c2, c1;
> >> +
> >> +  c1 = odp_cpu_cycles();
> >> +  odp_time_wait_ns(100);
> >> +  c2 = odp_cpu_cycles();
> >> +
> >> +  CU_ASSERT(c2 != c1);
> >> +}
> >> +
> >> +void system_test_odp_cpu_cycles_max(void)
> >> +{
> >> +  uint64_t c2, c1;
> >> +  uint64_t max1, max2;
> >> +
> >> +  max1 = odp_cpu_cycles_max();
> >> +  odp_time_wait_ns(100);
> >> +  max2 = odp_cpu_cycles_max();
> >> +
> >> +  CU_ASSERT(max1 >= UINT32_MAX / 2);
> >> +  CU_ASSERT(max1 == max2);
> >> +
> >> +  c1 = odp_cpu_cycles();
> >> +  odp_time_wait_ns(1000);
> >> +  c2 = odp_cpu_cycles();
> >> +
> >> +  CU_ASSERT(c1 <= max1 && c2 <= max1);
> >> +}
> >> +
> >> +void system_test_odp_cpu_cycles_diff(void)
> >> +{
> >> +  int i;
> >> +  uint64_t c2, c1, c3;
> >> +  uint64_t tmp, diff;
> >> +
> >> +  c2 = 100;
> >> +  c1 = 39;
> >> +
> >> +  diff = odp_cpu_cycles_diff(c2, c2);
> >> +  CU_ASSERT(diff == 0);
> >> +
> >> +  tmp = c2 - c1;
> >> +  diff = odp_cpu_cycles_diff(c2, c1);
> >> +  CU_ASSERT(diff == tmp);
> >> +
> >> +  tmp = c1 + (odp_cpu_cycles_max() - c2) + 1;
> >
> >
> > As noted before, '+1' in the equation holds only if resolution is 1. The
> equation should be:
> >
> > diff = c2 + (odp_cpu_cycles_max() - c1) + odp_cpu_cycles_resolution();
> >
> > It would be also more readable if c1 is always the first sample and c2
> the second (c1 = 100, c2 = 39 in this test case).
> In one case it's used directly in other in reverse order, no see reason to
> assign it once again.

The reason is readability. Since it's not a performance target, it's better to 
assign values again and highlight what is being tested (100 -> 39 vs. 39 -> 
100).

Also, if reader compares the reference implementation to the test case, it's 
confusing when c1 and c2 have been swapped.

return c2 + (odp_cpu_cycles_max() - c1) + 1 (the resolution);

VS.

tmp = c1 + (odp_cpu_cycles_max() - c2) + res;



-Petri



> And I'll delete it at all and use the following instead:
> 
>   /* check resolution for wrap */
>   c1 = max - 2 * res;
>   do
>   c2 = odp_cpu_cycles();
>   while (c2 < c1);
> 
> and use it for different cases:
> 
>   diff = odp_cpu_cycles_diff(c1, c1);
>   CU_ASSERT(diff == 0);
> 
>   tmp = c2 - c1;
> // here c1 is supposed to be after c2, but in order to not read this
> values again...
>   diff = odp_cpu_cycles_diff(c2, c1);
>   CU_ASSERT(diff == tmp);
>   rest = diff % res;
>   CU_ASSERT(rest == 0);
> 
>   tmp = c1 + (odp_cpu_cycles_max() - c2) + res;
>   diff = odp_cpu_cycles_diff(c1, c2);
>   CU_ASSERT(diff == tmp);
>   rest = diff % res;
>   CU_ASSERT(rest == 0);
> 
> >
> >
> > Max: 90
> > Res: 10
> > Valid values: 0, 10, 20, ..., 80, 90
> >
> > c1 = 90
> > 
> > c2 = 0
> >
> > c2   max  c1   res
> > diff = 0 + (90 - 90) + 10 = 10
> >
> >
> > -Petri
> >
> >
> >> +  diff = odp_cpu_cycles_diff(c1, c2);
> >> +  CU_ASSERT(diff == tmp);
> >> +
> >> +  c3 = odp_cpu_cycles();
> >> +
> >> +  /* must handle one wrap */
> >> +  for (i = 0; i < DIFF_TRY_NUM; i++) {
> >> +  c1 = odp_cpu_cycles();
> >> +  odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
> >> +  c2 = odp_cpu_cycles();
> >> +
> >> +  CU_ASSERT(c2 != c1);
> >> +
> >> +  if (c2 > c1)
> 

[lng-odp] [API-NEXT PATCH v2 00/13] atomi api completion

2016-01-18 Thread Petri Savolainen
Completed additions to atomic API. Added exchange operation in relaxed memory 
model. Added CAS operations in rel and acq_rel memory order. Added 64 bit 
versions of all non-relaxed operations defined so far. Added all missing 
validation tests. Replaced internal atomics usage in lock, etc code 
(all except spinlock and timer) with API calls.

This set of atomic calls seem to be sufficient to current linux-generic use 
cases. Timer and spinlock use atomic flag and 128 bit types, but does not 
require additional operation types (e.g. load_acq, store_rel, cas, cas_rel, etc 
are supported by the API).

Additional operations can be added later if needed. Only commonly needed 
combinations of non-relaxed operations will be supported (added based on use 
case as any other ODP API). This set should already enable major part of 
lock-free algorithms.

v2:
  * rebased on latest api-next
 

Petri Savolainen (13):
  api: atomic: rename release ordering
  api: atomic: added 32bit cas_rel and cas_acq_rel
  linux-generic: atomic: 32bit cas_rel and cas_acq_rel
  api: atomic: add non-relaxed 64bit operations
  linux-generic: atomic: non-relaxed 64bit operations
  api: atomic: added relaxed exchange operation
  linux-generic: atomic: implemented exchange
  validation: atomic: added max and min tests
  validation: atomic: added cas test
  validation: atomic: added xchg test
  validation: atomic: added non-relaxed test
  linux-generic: locks: replace internal atomics
  linux-generic: barrier: use API memory barrier

 include/odp/api/atomic.h   | 220 --
 platform/linux-generic/include/odp/atomic.h| 142 -
 .../linux-generic/include/odp_atomic_internal.h|   6 -
 platform/linux-generic/include/odp_pool_internal.h |   1 -
 platform/linux-generic/odp_barrier.c   |   8 +-
 platform/linux-generic/odp_pool.c  |   1 -
 platform/linux-generic/odp_rwlock.c|  23 +-
 platform/linux-generic/odp_ticketlock.c|  21 +-
 test/validation/synchronizers/synchronizers.c  | 330 -
 test/validation/synchronizers/synchronizers.h  |   4 +
 10 files changed, 672 insertions(+), 84 deletions(-)

-- 
2.6.3

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [API-NEXT PATCH v2 07/13] linux-generic: atomic: implemented exchange

2016-01-18 Thread Petri Savolainen
Implemented 32 and 64 bit atomic exchange operations.

Signed-off-by: Petri Savolainen 
---
 platform/linux-generic/include/odp/atomic.h | 16 
 1 file changed, 16 insertions(+)

diff --git a/platform/linux-generic/include/odp/atomic.h 
b/platform/linux-generic/include/odp/atomic.h
index 4fbf4c4..8644fdb 100644
--- a/platform/linux-generic/include/odp/atomic.h
+++ b/platform/linux-generic/include/odp/atomic.h
@@ -94,6 +94,12 @@ static inline int odp_atomic_cas_u32(odp_atomic_u32_t *atom, 
uint32_t *old_val,
   __ATOMIC_RELAXED);
 }
 
+static inline uint32_t odp_atomic_xchg_u32(odp_atomic_u32_t *atom,
+  uint32_t new_val)
+{
+   return __atomic_exchange_n(>v, new_val, __ATOMIC_RELAXED);
+}
+
 static inline void odp_atomic_max_u32(odp_atomic_u32_t *atom, uint32_t new_max)
 {
uint32_t old_val;
@@ -234,6 +240,16 @@ static inline int odp_atomic_cas_u64(odp_atomic_u64_t 
*atom, uint64_t *old_val,
 #endif
 }
 
+static inline uint64_t odp_atomic_xchg_u64(odp_atomic_u64_t *atom,
+  uint64_t new_val)
+{
+#if __GCC_ATOMIC_LLONG_LOCK_FREE < 2
+   return ATOMIC_OP(atom, atom->v = new_val);
+#else
+   return __atomic_exchange_n(>v, new_val, __ATOMIC_RELAXED);
+#endif
+}
+
 static inline void odp_atomic_max_u64(odp_atomic_u64_t *atom, uint64_t new_max)
 {
uint64_t old_val;
-- 
2.6.3

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [API-NEXT PATCH v2 05/13] linux-generic: atomic: non-relaxed 64bit operations

2016-01-18 Thread Petri Savolainen
Implemented 64 bit non-relaxed atomic operations. Additional
ordering is not needed in case of using ATOMIC_OP since it
includes both acquire and release ordering.

Signed-off-by: Petri Savolainen 
---
 platform/linux-generic/include/odp/atomic.h | 83 +
 1 file changed, 83 insertions(+)

diff --git a/platform/linux-generic/include/odp/atomic.h 
b/platform/linux-generic/include/odp/atomic.h
index ef036ed..4fbf4c4 100644
--- a/platform/linux-generic/include/odp/atomic.h
+++ b/platform/linux-generic/include/odp/atomic.h
@@ -309,6 +309,89 @@ static inline int 
odp_atomic_cas_acq_rel_u32(odp_atomic_u32_t *atom,
   __ATOMIC_RELAXED);
 }
 
+static inline uint64_t odp_atomic_load_acq_u64(odp_atomic_u64_t *atom)
+{
+#if __GCC_ATOMIC_LLONG_LOCK_FREE < 2
+   return ATOMIC_OP(atom, (void)0);
+#else
+   return __atomic_load_n(>v, __ATOMIC_ACQUIRE);
+#endif
+}
+
+static inline void odp_atomic_store_rel_u64(odp_atomic_u64_t *atom,
+   uint64_t val)
+{
+#if __GCC_ATOMIC_LLONG_LOCK_FREE < 2
+   (void)ATOMIC_OP(atom, atom->v = val);
+#else
+   __atomic_store_n(>v, val, __ATOMIC_RELEASE);
+#endif
+}
+
+static inline void odp_atomic_add_rel_u64(odp_atomic_u64_t *atom, uint64_t val)
+{
+#if __GCC_ATOMIC_LLONG_LOCK_FREE < 2
+   (void)ATOMIC_OP(atom, atom->v += val);
+#else
+   (void)__atomic_fetch_add(>v, val, __ATOMIC_RELEASE);
+#endif
+}
+
+static inline void odp_atomic_sub_rel_u64(odp_atomic_u64_t *atom, uint64_t val)
+{
+#if __GCC_ATOMIC_LLONG_LOCK_FREE < 2
+   (void)ATOMIC_OP(atom, atom->v -= val);
+#else
+   (void)__atomic_fetch_sub(>v, val, __ATOMIC_RELEASE);
+#endif
+}
+
+static inline int odp_atomic_cas_acq_u64(odp_atomic_u64_t *atom,
+uint64_t *old_val, uint64_t new_val)
+{
+#if __GCC_ATOMIC_LLONG_LOCK_FREE < 2
+   int ret;
+   *old_val = ATOMIC_OP(atom, ATOMIC_CAS_OP(, *old_val, new_val));
+   return ret;
+#else
+   return __atomic_compare_exchange_n(>v, old_val, new_val,
+  0 /* strong */,
+  __ATOMIC_ACQUIRE,
+  __ATOMIC_RELAXED);
+#endif
+}
+
+static inline int odp_atomic_cas_rel_u64(odp_atomic_u64_t *atom,
+uint64_t *old_val, uint64_t new_val)
+{
+#if __GCC_ATOMIC_LLONG_LOCK_FREE < 2
+   int ret;
+   *old_val = ATOMIC_OP(atom, ATOMIC_CAS_OP(, *old_val, new_val));
+   return ret;
+#else
+   return __atomic_compare_exchange_n(>v, old_val, new_val,
+  0 /* strong */,
+  __ATOMIC_RELEASE,
+  __ATOMIC_RELAXED);
+#endif
+}
+
+static inline int odp_atomic_cas_acq_rel_u64(odp_atomic_u64_t *atom,
+uint64_t *old_val,
+uint64_t new_val)
+{
+#if __GCC_ATOMIC_LLONG_LOCK_FREE < 2
+   int ret;
+   *old_val = ATOMIC_OP(atom, ATOMIC_CAS_OP(, *old_val, new_val));
+   return ret;
+#else
+   return __atomic_compare_exchange_n(>v, old_val, new_val,
+  0 /* strong */,
+  __ATOMIC_ACQ_REL,
+  __ATOMIC_RELAXED);
+#endif
+}
+
 /**
  * @}
  */
-- 
2.6.3

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [API-NEXT PATCH v2 12/13] linux-generic: locks: replace internal atomics

2016-01-18 Thread Petri Savolainen
Replace internal non-relaxed atomics with API calls. Timer and
spinlock were not converted since those use flags and 128 variables.

Signed-off-by: Petri Savolainen 
---
 platform/linux-generic/include/odp_pool_internal.h |  1 -
 platform/linux-generic/odp_pool.c  |  1 -
 platform/linux-generic/odp_rwlock.c| 23 --
 platform/linux-generic/odp_ticketlock.c| 21 ++--
 4 files changed, 14 insertions(+), 32 deletions(-)

diff --git a/platform/linux-generic/include/odp_pool_internal.h 
b/platform/linux-generic/include/odp_pool_internal.h
index b12bca8..aae020f 100644
--- a/platform/linux-generic/include/odp_pool_internal.h
+++ b/platform/linux-generic/include/odp_pool_internal.h
@@ -28,7 +28,6 @@ extern "C" {
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
diff --git a/platform/linux-generic/odp_pool.c 
b/platform/linux-generic/odp_pool.c
index 84d35bf..4c02b79 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
diff --git a/platform/linux-generic/odp_rwlock.c 
b/platform/linux-generic/odp_rwlock.c
index 0b8bb46..42ad0cc 100644
--- a/platform/linux-generic/odp_rwlock.c
+++ b/platform/linux-generic/odp_rwlock.c
@@ -6,7 +6,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -21,23 +20,20 @@ void odp_rwlock_read_lock(odp_rwlock_t *rwlock)
int  is_locked = 0;
 
while (is_locked == 0) {
-   cnt = _odp_atomic_u32_load_mm(>cnt, _ODP_MEMMODEL_RLX);
+   cnt = odp_atomic_load_u32(>cnt);
/* waiting for read lock */
if ((int32_t)cnt < 0) {
odp_cpu_pause();
continue;
}
-   is_locked = _odp_atomic_u32_cmp_xchg_strong_mm(>cnt,
-   ,
-   cnt + 1,
-   _ODP_MEMMODEL_ACQ,
-   _ODP_MEMMODEL_RLX);
+   is_locked = odp_atomic_cas_acq_u32(>cnt,
+  , cnt + 1);
}
 }
 
 void odp_rwlock_read_unlock(odp_rwlock_t *rwlock)
 {
-   _odp_atomic_u32_sub_mm(>cnt, 1, _ODP_MEMMODEL_RLS);
+   odp_atomic_sub_rel_u32(>cnt, 1);
 }
 
 void odp_rwlock_write_lock(odp_rwlock_t *rwlock)
@@ -47,21 +43,18 @@ void odp_rwlock_write_lock(odp_rwlock_t *rwlock)
 
while (is_locked == 0) {
uint32_t zero = 0;
-   cnt = _odp_atomic_u32_load_mm(>cnt, _ODP_MEMMODEL_RLX);
+   cnt = odp_atomic_load_u32(>cnt);
/* lock acquired, wait */
if (cnt != 0) {
odp_cpu_pause();
continue;
}
-   is_locked = _odp_atomic_u32_cmp_xchg_strong_mm(>cnt,
-   ,
-   (uint32_t)-1,
-   _ODP_MEMMODEL_ACQ,
-   _ODP_MEMMODEL_RLX);
+   is_locked = odp_atomic_cas_acq_u32(>cnt,
+  , (uint32_t)-1);
}
 }
 
 void odp_rwlock_write_unlock(odp_rwlock_t *rwlock)
 {
-   _odp_atomic_u32_store_mm(>cnt, 0, _ODP_MEMMODEL_RLS);
+   odp_atomic_store_rel_u32(>cnt, 0);
 }
diff --git a/platform/linux-generic/odp_ticketlock.c 
b/platform/linux-generic/odp_ticketlock.c
index 6ab2b9a..84b893a 100644
--- a/platform/linux-generic/odp_ticketlock.c
+++ b/platform/linux-generic/odp_ticketlock.c
@@ -6,18 +6,15 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 
-
 void odp_ticketlock_init(odp_ticketlock_t *ticketlock)
 {
odp_atomic_init_u32(>next_ticket, 0);
odp_atomic_init_u32(>cur_ticket, 0);
 }
 
-
 void odp_ticketlock_lock(odp_ticketlock_t *ticketlock)
 {
uint32_t ticket;
@@ -29,8 +26,7 @@ void odp_ticketlock_lock(odp_ticketlock_t *ticketlock)
 
/* Spin waiting for our turn. Use load-acquire so that we acquire
 * all stores from the previous lock owner */
-   while (ticket != _odp_atomic_u32_load_mm(>cur_ticket,
-_ODP_MEMMODEL_ACQ))
+   while (ticket != odp_atomic_load_acq_u32(>cur_ticket))
odp_cpu_pause();
 }
 
@@ -55,11 +51,8 @@ int odp_ticketlock_trylock(odp_ticketlock_t *tklock)
 * If CAS fails, it means some other thread intercepted and
 * took a ticket which means the lock is not available
 * anymore */
-   if (_odp_atomic_u32_cmp_xchg_strong_mm(>next_ticket,
-  ,
-  next + 1,
-  _ODP_MEMMODEL_ACQ,
-  

[lng-odp] [API-NEXT PATCH v2 13/13] linux-generic: barrier: use API memory barrier

2016-01-18 Thread Petri Savolainen
Use full memory barrier from API instead of the internal
function.

Signed-off-by: Petri Savolainen 
---
 platform/linux-generic/include/odp_atomic_internal.h | 6 --
 platform/linux-generic/odp_barrier.c | 8 
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/platform/linux-generic/include/odp_atomic_internal.h 
b/platform/linux-generic/include/odp_atomic_internal.h
index ce62368..ff3813f 100644
--- a/platform/linux-generic/include/odp_atomic_internal.h
+++ b/platform/linux-generic/include/odp_atomic_internal.h
@@ -64,12 +64,6 @@ typedef enum {
_ODP_MEMMODEL_SC = __ATOMIC_SEQ_CST
 } _odp_memmodel_t;
 
-/**
- * Insert a full memory barrier (fence) in the compiler and instruction
- * sequence.
- */
-#define _ODP_FULL_BARRIER() __atomic_thread_fence(__ATOMIC_SEQ_CST)
-
 /*
  * Operations on 32-bit atomics
  * _odp_atomic_u32_load_mm - return current value
diff --git a/platform/linux-generic/odp_barrier.c 
b/platform/linux-generic/odp_barrier.c
index 0bfc0f0..f3525e2 100644
--- a/platform/linux-generic/odp_barrier.c
+++ b/platform/linux-generic/odp_barrier.c
@@ -7,7 +7,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 void odp_barrier_init(odp_barrier_t *barrier, int count)
 {
@@ -27,13 +27,13 @@ void odp_barrier_init(odp_barrier_t *barrier, int count)
  *   the cycle the barrier was in upon entry.  Exit is when the
  *   barrier crosses to the other half of the cycle.
  */
-
 void odp_barrier_wait(odp_barrier_t *barrier)
 {
uint32_t count;
int wasless;
 
-   _ODP_FULL_BARRIER();
+   odp_mb_full();
+
count   = odp_atomic_fetch_inc_u32(>bar);
wasless = count < barrier->count;
 
@@ -46,5 +46,5 @@ void odp_barrier_wait(odp_barrier_t *barrier)
odp_cpu_pause();
}
 
-   _ODP_FULL_BARRIER();
+   odp_mb_full();
 }
-- 
2.6.3

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v5] validation: system: add validation tests for odp_cpu_cycles_* calls

2016-01-18 Thread Ivan Khoronzhuk

v6 is sent.

On 18.01.16 14:58, Savolainen, Petri (Nokia - FI/Espoo) wrote:




-Original Message-
From: EXT Ivan Khoronzhuk [mailto:ivan.khoronz...@linaro.org]
Sent: Monday, January 18, 2016 2:24 PM
To: Savolainen, Petri (Nokia - FI/Espoo); lng-odp@lists.linaro.org
Subject: Re: [lng-odp] [PATCH v5] validation: system: add validation tests
for odp_cpu_cycles_* calls



On 18.01.16 13:37, Savolainen, Petri (Nokia - FI/Espoo) wrote:




-Original Message-
From: EXT Ivan Khoronzhuk [mailto:ivan.khoronz...@linaro.org]
Sent: Friday, January 15, 2016 5:07 PM
To: lng-odp@lists.linaro.org
Cc: Savolainen, Petri (Nokia - FI/Espoo); Ivan Khoronzhuk
Subject: [lng-odp] [PATCH v5] validation: system: add validation tests

for

odp_cpu_cycles_* calls

https://bugs.linaro.org/show_bug.cgi?id=1906

Signed-off-by: Ivan Khoronzhuk 
---
   test/validation/system/system.c | 130

   test/validation/system/system.h |   4 ++
   2 files changed, 134 insertions(+)

diff --git a/test/validation/system/system.c
b/test/validation/system/system.c
index 7dc2cc0..f59c570 100644
--- a/test/validation/system/system.c
+++ b/test/validation/system/system.c
@@ -10,6 +10,9 @@
   #include "test_debug.h"
   #include "system.h"

+#define DIFF_TRY_NUM   160
+#define RES_TRY_NUM10
+
   void system_test_odp_version_numbers(void)
   {
int char_ok = 0;
@@ -40,6 +43,129 @@ void system_test_odp_cpu_count(void)
CU_ASSERT(0 < cpus);
   }

+void system_test_odp_cpu_cycles(void)
+{
+   uint64_t c2, c1;
+
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(100);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c2 != c1);
+}
+
+void system_test_odp_cpu_cycles_max(void)
+{
+   uint64_t c2, c1;
+   uint64_t max1, max2;
+
+   max1 = odp_cpu_cycles_max();
+   odp_time_wait_ns(100);
+   max2 = odp_cpu_cycles_max();
+
+   CU_ASSERT(max1 >= UINT32_MAX / 2);
+   CU_ASSERT(max1 == max2);
+
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(1000);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c1 <= max1 && c2 <= max1);
+}
+
+void system_test_odp_cpu_cycles_diff(void)
+{
+   int i;
+   uint64_t c2, c1, c3;
+   uint64_t tmp, diff;
+
+   c2 = 100;
+   c1 = 39;
+
+   diff = odp_cpu_cycles_diff(c2, c2);
+   CU_ASSERT(diff == 0);
+
+   tmp = c2 - c1;
+   diff = odp_cpu_cycles_diff(c2, c1);
+   CU_ASSERT(diff == tmp);
+
+   tmp = c1 + (odp_cpu_cycles_max() - c2) + 1;



As noted before, '+1' in the equation holds only if resolution is 1. The

equation should be:


diff = c2 + (odp_cpu_cycles_max() - c1) + odp_cpu_cycles_resolution();

It would be also more readable if c1 is always the first sample and c2

the second (c1 = 100, c2 = 39 in this test case).
In one case it's used directly in other in reverse order, no see reason to
assign it once again.


The reason is readability. Since it's not a performance target, it's better to assign 
values again and highlight what is being tested (100 -> 39 vs. 39 -> 100).

Also, if reader compares the reference implementation to the test case, it's 
confusing when c1 and c2 have been swapped.

return c2 + (odp_cpu_cycles_max() - c1) + 1 (the resolution);

VS.

tmp = c1 + (odp_cpu_cycles_max() - c2) + res;



-Petri




And I'll delete it at all and use the following instead:

/* check resolution for wrap */
c1 = max - 2 * res;
do
c2 = odp_cpu_cycles();
while (c2 < c1);

and use it for different cases:

diff = odp_cpu_cycles_diff(c1, c1);
CU_ASSERT(diff == 0);

tmp = c2 - c1;
// here c1 is supposed to be after c2, but in order to not read this
values again...
diff = odp_cpu_cycles_diff(c2, c1);
CU_ASSERT(diff == tmp);
rest = diff % res;
CU_ASSERT(rest == 0);

tmp = c1 + (odp_cpu_cycles_max() - c2) + res;
diff = odp_cpu_cycles_diff(c1, c2);
CU_ASSERT(diff == tmp);
rest = diff % res;
CU_ASSERT(rest == 0);




Max: 90
Res: 10
Valid values: 0, 10, 20, ..., 80, 90

c1 = 90

c2 = 0

 c2   max  c1   res
diff = 0 + (90 - 90) + 10 = 10


-Petri



+   diff = odp_cpu_cycles_diff(c1, c2);
+   CU_ASSERT(diff == tmp);
+
+   c3 = odp_cpu_cycles();
+
+   /* must handle one wrap */
+   for (i = 0; i < DIFF_TRY_NUM; i++) {
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c2 != c1);
+
+   if (c2 > c1)
+   tmp = c2 - c1;
+   else
+   tmp = c2 + (odp_cpu_cycles_max() - c1) + 1;
+
+   diff = odp_cpu_cycles_diff(c2, c1);
+   CU_ASSERT(diff == tmp);
+
+   /* wrap is detected and verified */
+   if (c2 < c1)
+   break;

[lng-odp] [API-NEXT PATCH v2 02/13] api: atomic: added 32bit cas_rel and cas_acq_rel

2016-01-18 Thread Petri Savolainen
Added RELEASE and ACQUIRE-and-RELEASE versions of 32 bit CAS.
These are commonly needed operations in lock-free algorithms.

Signed-off-by: Petri Savolainen 
---
 include/odp/api/atomic.h | 86 +---
 1 file changed, 67 insertions(+), 19 deletions(-)

diff --git a/include/odp/api/atomic.h b/include/odp/api/atomic.h
index b0a46ba..aa20c61 100644
--- a/include/odp/api/atomic.h
+++ b/include/odp/api/atomic.h
@@ -31,7 +31,7 @@ extern "C" {
  * before or after the operation), only atomicity of the operation itself is
  * guaranteed.
  *
- *  Operations with other than relaxed memory ordering 
+ *  Operations with non-relaxed memory ordering 
  *
  *  An operation with RELEASE  memory ordering 
(odp_atomic_xxx_rel_xxx())
  * ensures that other threads loading the same atomic variable with ACQUIRE
@@ -43,6 +43,11 @@ extern "C" {
  * thread) that happened before a RELEASE memory ordered store to the same
  * atomic variable.
  *
+ *  An operation with ACQUIRE-and-RELEASE  memory ordering
+ * (odp_atomic_xxx_acq_rel_xxx()) combines the effects of ACQUIRE and RELEASE
+ * memory orders. A single operation acts as both an acquiring load and
+ * a releasing store.
+ *
  * @{
  */
 
@@ -54,6 +59,11 @@ extern "C" {
  * Atomic 32-bit unsigned integer
  */
 
+/*
+ * 32-bit operations in RELAXED memory ordering
+ * 
+ */
+
 /**
  * Initialize atomic uint32 variable
  *
@@ -188,6 +198,11 @@ void odp_atomic_min_u32(odp_atomic_u32_t *atom, uint32_t 
new_min);
 int odp_atomic_cas_u32(odp_atomic_u32_t *atom, uint32_t *old_val,
   uint32_t new_val);
 
+/*
+ * 64-bit operations in RELAXED memory ordering
+ * 
+ */
+
 /**
  * Initialize atomic uint64 variable
  *
@@ -322,8 +337,8 @@ int odp_atomic_cas_u64(odp_atomic_u64_t *atom, uint64_t 
*old_val,
   uint64_t new_val);
 
 /*
- * Operations with other than relaxed memory ordering
- * --
+ * 32-bit operations in non-RELAXED memory ordering
+ * 
  */
 
 /**
@@ -339,22 +354,6 @@ int odp_atomic_cas_u64(odp_atomic_u64_t *atom, uint64_t 
*old_val,
 uint32_t odp_atomic_load_acq_u32(odp_atomic_u32_t *atom);
 
 /**
- * Compare and swap atomic uint32 variable using ACQUIRE memory ordering
- *
- * Otherwise identical to odp_atomic_cas_u32() but ensures ACQUIRE memory
- * ordering.
- *
- * @param atom  Pointer to atomic variable
- * @param[in,out] old_val   Pointer to the old value of the atomic variable.
- *  Operation updates this value on failure.
- * @param new_val   New value to be written into the atomic variable
- *
- * @return 0 on failure, !0 on success
- */
-int odp_atomic_cas_acq_u32(odp_atomic_u32_t *atom, uint32_t *old_val,
-  uint32_t new_val);
-
-/**
  * Store value to atomic uint32 variable using RELEASE memory ordering
  *
  * Otherwise identical to odp_atomic_store_u32() but ensures RELEASE memory
@@ -388,6 +387,55 @@ void odp_atomic_add_rel_u32(odp_atomic_u32_t *atom, 
uint32_t val);
 void odp_atomic_sub_rel_u32(odp_atomic_u32_t *atom, uint32_t val);
 
 /**
+ * Compare and swap atomic uint32 variable using ACQUIRE memory ordering
+ *
+ * Otherwise identical to odp_atomic_cas_u32() but ensures ACQUIRE memory
+ * ordering on success. Memory ordering is RELAXED on failure.
+ *
+ * @param atom  Pointer to atomic variable
+ * @param[in,out] old_val   Pointer to the old value of the atomic variable.
+ *  Operation updates this value on failure.
+ * @param new_val   New value to be written into the atomic variable
+ *
+ * @return 0 on failure, !0 on success
+ */
+int odp_atomic_cas_acq_u32(odp_atomic_u32_t *atom, uint32_t *old_val,
+  uint32_t new_val);
+
+/**
+ * Compare and swap atomic uint32 variable using RELEASE memory ordering
+ *
+ * Otherwise identical to odp_atomic_cas_u32() but ensures RELEASE memory
+ * ordering on success. Memory ordering is RELAXED on failure.
+ *
+ * @param atom  Pointer to atomic variable
+ * @param[in,out] old_val   Pointer to the old value of the atomic variable.
+ *  Operation updates this value on failure.
+ * @param new_val   New value to be written into the atomic variable
+ *
+ * @return 0 on failure, !0 on success
+ */
+int odp_atomic_cas_rel_u32(odp_atomic_u32_t *atom, uint32_t *old_val,
+  uint32_t new_val);
+
+/**
+ * Compare and swap atomic uint32 variable using ACQUIRE-and-RELEASE memory
+ * ordering
+ *
+ * Otherwise identical to odp_atomic_cas_u32() but ensures ACQUIRE-and-RELEASE
+ * memory ordering on success. Memory ordering is RELAXED on failure.
+ *
+ * @param atom  Pointer to atomic variable
+ * @param[in,out] old_val   Pointer 

[lng-odp] [API-NEXT PATCH v2 03/13] linux-generic: atomic: 32bit cas_rel and cas_acq_rel

2016-01-18 Thread Petri Savolainen
Implemented 32bit cas_rel and cas_acq_rel calls.

Signed-off-by: Petri Savolainen 
---
 platform/linux-generic/include/odp/atomic.h | 37 ++---
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/platform/linux-generic/include/odp/atomic.h 
b/platform/linux-generic/include/odp/atomic.h
index 9dffa09..ef036ed 100644
--- a/platform/linux-generic/include/odp/atomic.h
+++ b/platform/linux-generic/include/odp/atomic.h
@@ -263,15 +263,6 @@ static inline uint32_t 
odp_atomic_load_acq_u32(odp_atomic_u32_t *atom)
return __atomic_load_n(>v, __ATOMIC_ACQUIRE);
 }
 
-static inline int odp_atomic_cas_acq_u32(odp_atomic_u32_t *atom,
-uint32_t *old_val, uint32_t new_val)
-{
-   return __atomic_compare_exchange_n(>v, old_val, new_val,
-  0 /* strong */,
-  __ATOMIC_ACQUIRE,
-  __ATOMIC_RELAXED);
-}
-
 static inline void odp_atomic_store_rel_u32(odp_atomic_u32_t *atom,
uint32_t val)
 {
@@ -290,6 +281,34 @@ static inline void odp_atomic_sub_rel_u32(odp_atomic_u32_t 
*atom,
(void)__atomic_fetch_sub(>v, val, __ATOMIC_RELEASE);
 }
 
+static inline int odp_atomic_cas_acq_u32(odp_atomic_u32_t *atom,
+uint32_t *old_val, uint32_t new_val)
+{
+   return __atomic_compare_exchange_n(>v, old_val, new_val,
+  0 /* strong */,
+  __ATOMIC_ACQUIRE,
+  __ATOMIC_RELAXED);
+}
+
+static inline int odp_atomic_cas_rel_u32(odp_atomic_u32_t *atom,
+uint32_t *old_val, uint32_t new_val)
+{
+   return __atomic_compare_exchange_n(>v, old_val, new_val,
+  0 /* strong */,
+  __ATOMIC_RELEASE,
+  __ATOMIC_RELAXED);
+}
+
+static inline int odp_atomic_cas_acq_rel_u32(odp_atomic_u32_t *atom,
+uint32_t *old_val,
+uint32_t new_val)
+{
+   return __atomic_compare_exchange_n(>v, old_val, new_val,
+  0 /* strong */,
+  __ATOMIC_ACQ_REL,
+  __ATOMIC_RELAXED);
+}
+
 /**
  * @}
  */
-- 
2.6.3

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [API-NEXT PATCH v2 01/13] api: atomic: rename release ordering

2016-01-18 Thread Petri Savolainen
Rename release ordering from _rls_ to _rel_ since it matches
better with _acq_rel_, which is going to be used for C11
memory_order_acq_rel order.

Signed-off-by: Petri Savolainen 
---
 include/odp/api/atomic.h| 8 
 platform/linux-generic/include/odp/atomic.h | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/odp/api/atomic.h b/include/odp/api/atomic.h
index cd62f98..b0a46ba 100644
--- a/include/odp/api/atomic.h
+++ b/include/odp/api/atomic.h
@@ -33,7 +33,7 @@ extern "C" {
  *
  *  Operations with other than relaxed memory ordering 
  *
- *  An operation with RELEASE  memory ordering 
(odp_atomic_xxx_rls_xxx())
+ *  An operation with RELEASE  memory ordering 
(odp_atomic_xxx_rel_xxx())
  * ensures that other threads loading the same atomic variable with ACQUIRE
  * memory ordering see all stores (from the calling thread) that happened 
before
  * this releasing store.
@@ -363,7 +363,7 @@ int odp_atomic_cas_acq_u32(odp_atomic_u32_t *atom, uint32_t 
*old_val,
  * @param atomPointer to atomic variable
  * @param val Value to store in the variable
  */
-void odp_atomic_store_rls_u32(odp_atomic_u32_t *atom, uint32_t val);
+void odp_atomic_store_rel_u32(odp_atomic_u32_t *atom, uint32_t val);
 
 /**
  * Add to atomic uint32 variable using RELEASE memory ordering
@@ -374,7 +374,7 @@ void odp_atomic_store_rls_u32(odp_atomic_u32_t *atom, 
uint32_t val);
  * @param atomPointer to atomic variable
  * @param val Value to be added to the variable
  */
-void odp_atomic_add_rls_u32(odp_atomic_u32_t *atom, uint32_t val);
+void odp_atomic_add_rel_u32(odp_atomic_u32_t *atom, uint32_t val);
 
 /**
  * Subtract from atomic uint32 variable using RELEASE memory ordering
@@ -385,7 +385,7 @@ void odp_atomic_add_rls_u32(odp_atomic_u32_t *atom, 
uint32_t val);
  * @param atomPointer to atomic variable
  * @param val Value to be subtracted from the variable
  */
-void odp_atomic_sub_rls_u32(odp_atomic_u32_t *atom, uint32_t val);
+void odp_atomic_sub_rel_u32(odp_atomic_u32_t *atom, uint32_t val);
 
 /**
  * Atomic operations
diff --git a/platform/linux-generic/include/odp/atomic.h 
b/platform/linux-generic/include/odp/atomic.h
index 005a0cd..9dffa09 100644
--- a/platform/linux-generic/include/odp/atomic.h
+++ b/platform/linux-generic/include/odp/atomic.h
@@ -272,19 +272,19 @@ static inline int odp_atomic_cas_acq_u32(odp_atomic_u32_t 
*atom,
   __ATOMIC_RELAXED);
 }
 
-static inline void odp_atomic_store_rls_u32(odp_atomic_u32_t *atom,
+static inline void odp_atomic_store_rel_u32(odp_atomic_u32_t *atom,
uint32_t val)
 {
__atomic_store_n(>v, val, __ATOMIC_RELEASE);
 }
 
-static inline void odp_atomic_add_rls_u32(odp_atomic_u32_t *atom,
+static inline void odp_atomic_add_rel_u32(odp_atomic_u32_t *atom,
  uint32_t val)
 {
(void)__atomic_fetch_add(>v, val, __ATOMIC_RELEASE);
 }
 
-static inline void odp_atomic_sub_rls_u32(odp_atomic_u32_t *atom,
+static inline void odp_atomic_sub_rel_u32(odp_atomic_u32_t *atom,
  uint32_t val)
 {
(void)__atomic_fetch_sub(>v, val, __ATOMIC_RELEASE);
-- 
2.6.3

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [API-NEXT PATCH v2 06/13] api: atomic: added relaxed exchange operation

2016-01-18 Thread Petri Savolainen
Added 32 and 64 bit atomic exchange operations in relaxed
memory ordering. These can be used e.g. to initialize a counter
while counting.

Signed-off-by: Petri Savolainen 
---
 include/odp/api/atomic.h | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/include/odp/api/atomic.h b/include/odp/api/atomic.h
index 1abaaf3..8626495 100644
--- a/include/odp/api/atomic.h
+++ b/include/odp/api/atomic.h
@@ -198,6 +198,19 @@ void odp_atomic_min_u32(odp_atomic_u32_t *atom, uint32_t 
new_min);
 int odp_atomic_cas_u32(odp_atomic_u32_t *atom, uint32_t *old_val,
   uint32_t new_val);
 
+/**
+ * Exchange value of atomic uint32 variable
+ *
+ * Atomically replaces the value of atomic variable with the new value. Returns
+ * the old value.
+ *
+ * @param atomPointer to atomic variable
+ * @param new_val New value of the atomic variable
+ *
+ * @return Value of the variable before the operation
+ */
+uint32_t odp_atomic_xchg_u32(odp_atomic_u32_t *atom, uint32_t new_val);
+
 /*
  * 64-bit operations in RELAXED memory ordering
  * 
@@ -336,6 +349,19 @@ void odp_atomic_min_u64(odp_atomic_u64_t *atom, uint64_t 
new_min);
 int odp_atomic_cas_u64(odp_atomic_u64_t *atom, uint64_t *old_val,
   uint64_t new_val);
 
+/**
+ * Exchange value of atomic uint64 variable
+ *
+ * Atomically replaces the value of atomic variable with the new value. Returns
+ * the old value.
+ *
+ * @param atomPointer to atomic variable
+ * @param new_val New value of the atomic variable
+ *
+ * @return Value of the variable before the operation
+ */
+uint64_t odp_atomic_xchg_u64(odp_atomic_u64_t *atom, uint64_t new_val);
+
 /*
  * 32-bit operations in non-RELAXED memory ordering
  * 
@@ -556,6 +582,7 @@ typedef union odp_atomic_op_t {
uint32_t min   : 1;  /**< Atomic minimum */
uint32_t max   : 1;  /**< Atomic maximum */
uint32_t cas   : 1;  /**< Atomic compare and swap */
+   uint32_t xchg  : 1;  /**< Atomic exchange */
} op;
 
/** All bits of the bit field structure.
-- 
2.6.3

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [API-NEXT PATCH v2 08/13] validation: atomic: added max and min tests

2016-01-18 Thread Petri Savolainen
Added validation tests for atomic max and min operations.
Results validation is a simple compare, since absolute min/max
values depend on the number of threads.

Signed-off-by: Petri Savolainen 
---
 test/validation/synchronizers/synchronizers.c | 111 --
 test/validation/synchronizers/synchronizers.h |   1 +
 2 files changed, 105 insertions(+), 7 deletions(-)

diff --git a/test/validation/synchronizers/synchronizers.c 
b/test/validation/synchronizers/synchronizers.c
index 0302069..1454264 100644
--- a/test/validation/synchronizers/synchronizers.c
+++ b/test/validation/synchronizers/synchronizers.c
@@ -33,8 +33,14 @@
 
 #define UNUSED __attribute__((__unused__))
 
+#define CHECK_MAX_MIN  (1 << 0)
+
 static odp_atomic_u32_t a32u;
 static odp_atomic_u64_t a64u;
+static odp_atomic_u32_t a32u_min;
+static odp_atomic_u32_t a32u_max;
+static odp_atomic_u64_t a64u_min;
+static odp_atomic_u64_t a64u_max;
 
 static volatile int temp_result;
 
@@ -1202,6 +1208,50 @@ static void test_atomic_fetch_sub_64(void)
odp_atomic_fetch_sub_u64(, ADD_SUB_CNT);
 }
 
+static void test_atomic_min_32(void)
+{
+   int i;
+   uint32_t tmp;
+
+   for (i = 0; i < CNT; i++) {
+   tmp = odp_atomic_fetch_dec_u32();
+   odp_atomic_min_u32(_min, tmp);
+   }
+}
+
+static void test_atomic_min_64(void)
+{
+   int i;
+   uint64_t tmp;
+
+   for (i = 0; i < CNT; i++) {
+   tmp = odp_atomic_fetch_dec_u64();
+   odp_atomic_min_u64(_min, tmp);
+   }
+}
+
+static void test_atomic_max_32(void)
+{
+   int i;
+   uint32_t tmp;
+
+   for (i = 0; i < CNT; i++) {
+   tmp = odp_atomic_fetch_inc_u32();
+   odp_atomic_max_u32(_max, tmp);
+   }
+}
+
+static void test_atomic_max_64(void)
+{
+   int i;
+   uint64_t tmp;
+
+   for (i = 0; i < CNT; i++) {
+   tmp = odp_atomic_fetch_inc_u64();
+   odp_atomic_max_u64(_max, tmp);
+   }
+}
+
 static void test_atomic_inc_dec_32(void)
 {
test_atomic_inc_32();
@@ -1250,22 +1300,50 @@ static void test_atomic_fetch_add_sub_64(void)
test_atomic_fetch_sub_64();
 }
 
+static void test_atomic_max_min_32(void)
+{
+   test_atomic_max_32();
+   test_atomic_min_32();
+}
+
+static void test_atomic_max_min_64(void)
+{
+   test_atomic_max_64();
+   test_atomic_min_64();
+}
+
 static void test_atomic_init(void)
 {
odp_atomic_init_u32(, 0);
odp_atomic_init_u64(, 0);
+   odp_atomic_init_u32(_min, 0);
+   odp_atomic_init_u32(_max, 0);
+   odp_atomic_init_u64(_min, 0);
+   odp_atomic_init_u64(_max, 0);
 }
 
 static void test_atomic_store(void)
 {
odp_atomic_store_u32(, U32_INIT_VAL);
odp_atomic_store_u64(, U64_INIT_VAL);
+   odp_atomic_store_u32(_min, U32_INIT_VAL);
+   odp_atomic_store_u32(_max, U32_INIT_VAL);
+   odp_atomic_store_u64(_min, U64_INIT_VAL);
+   odp_atomic_store_u64(_max, U64_INIT_VAL);
 }
 
-static void test_atomic_validate(void)
+static void test_atomic_validate(int check)
 {
CU_ASSERT(U32_INIT_VAL == odp_atomic_load_u32());
CU_ASSERT(U64_INIT_VAL == odp_atomic_load_u64());
+
+   if (check & CHECK_MAX_MIN) {
+   CU_ASSERT(odp_atomic_load_u32(_max) >
+ odp_atomic_load_u32(_min));
+
+   CU_ASSERT(odp_atomic_load_u64(_max) >
+ odp_atomic_load_u64(_min));
+   }
 }
 
 /* Barrier tests */
@@ -1574,7 +1652,20 @@ static void *test_atomic_fetch_add_sub_thread(void *arg 
UNUSED)
return NULL;
 }
 
-static void test_atomic_functional(void *func_ptr(void *))
+static void *test_atomic_max_min_thread(void *arg UNUSED)
+{
+   per_thread_mem_t *per_thread_mem;
+
+   per_thread_mem = thread_init();
+   test_atomic_max_min_32();
+   test_atomic_max_min_64();
+
+   thread_finalize(per_thread_mem);
+
+   return NULL;
+}
+
+static void test_atomic_functional(void *func_ptr(void *), int check)
 {
pthrd_arg arg;
 
@@ -1583,27 +1674,32 @@ static void test_atomic_functional(void *func_ptr(void 
*))
test_atomic_store();
odp_cunit_thread_create(func_ptr, );
odp_cunit_thread_exit();
-   test_atomic_validate();
+   test_atomic_validate(check);
 }
 
 void synchronizers_test_atomic_inc_dec(void)
 {
-   test_atomic_functional(test_atomic_inc_dec_thread);
+   test_atomic_functional(test_atomic_inc_dec_thread, 0);
 }
 
 void synchronizers_test_atomic_add_sub(void)
 {
-   test_atomic_functional(test_atomic_add_sub_thread);
+   test_atomic_functional(test_atomic_add_sub_thread, 0);
 }
 
 void synchronizers_test_atomic_fetch_inc_dec(void)
 {
-   test_atomic_functional(test_atomic_fetch_inc_dec_thread);
+   test_atomic_functional(test_atomic_fetch_inc_dec_thread, 0);
 }
 
 void synchronizers_test_atomic_fetch_add_sub(void)
 {
-   

[lng-odp] [API-NEXT PATCH v2 09/13] validation: atomic: added cas test

2016-01-18 Thread Petri Savolainen
Added validation test for CAS operations. Maintained the structure
of other atomic tests: one function increments and another decrements
a variable.

Signed-off-by: Petri Savolainen 
---
 test/validation/synchronizers/synchronizers.c | 83 +++
 test/validation/synchronizers/synchronizers.h |  1 +
 2 files changed, 84 insertions(+)

diff --git a/test/validation/synchronizers/synchronizers.c 
b/test/validation/synchronizers/synchronizers.c
index 1454264..ece9d4f 100644
--- a/test/validation/synchronizers/synchronizers.c
+++ b/test/validation/synchronizers/synchronizers.c
@@ -1252,6 +1252,58 @@ static void test_atomic_max_64(void)
}
 }
 
+static void test_atomic_cas_inc_32(void)
+{
+   int i;
+   uint32_t old;
+
+   for (i = 0; i < CNT; i++) {
+   old = odp_atomic_load_u32();
+
+   while (odp_atomic_cas_u32(, , old + 1) == 0)
+   ;
+   }
+}
+
+static void test_atomic_cas_dec_32(void)
+{
+   int i;
+   uint32_t old;
+
+   for (i = 0; i < CNT; i++) {
+   old = odp_atomic_load_u32();
+
+   while (odp_atomic_cas_u32(, , old - 1) == 0)
+   ;
+   }
+}
+
+static void test_atomic_cas_inc_64(void)
+{
+   int i;
+   uint64_t old;
+
+   for (i = 0; i < CNT; i++) {
+   old = odp_atomic_load_u64();
+
+   while (odp_atomic_cas_u64(, , old + 1) == 0)
+   ;
+   }
+}
+
+static void test_atomic_cas_dec_64(void)
+{
+   int i;
+   uint64_t old;
+
+   for (i = 0; i < CNT; i++) {
+   old = odp_atomic_load_u64();
+
+   while (odp_atomic_cas_u64(, , old - 1) == 0)
+   ;
+   }
+}
+
 static void test_atomic_inc_dec_32(void)
 {
test_atomic_inc_32();
@@ -1312,6 +1364,18 @@ static void test_atomic_max_min_64(void)
test_atomic_min_64();
 }
 
+static void test_atomic_cas_inc_dec_32(void)
+{
+   test_atomic_cas_inc_32();
+   test_atomic_cas_dec_32();
+}
+
+static void test_atomic_cas_inc_dec_64(void)
+{
+   test_atomic_cas_inc_64();
+   test_atomic_cas_dec_64();
+}
+
 static void test_atomic_init(void)
 {
odp_atomic_init_u32(, 0);
@@ -1665,6 +1729,19 @@ static void *test_atomic_max_min_thread(void *arg UNUSED)
return NULL;
 }
 
+static void *test_atomic_cas_inc_dec_thread(void *arg UNUSED)
+{
+   per_thread_mem_t *per_thread_mem;
+
+   per_thread_mem = thread_init();
+   test_atomic_cas_inc_dec_32();
+   test_atomic_cas_inc_dec_64();
+
+   thread_finalize(per_thread_mem);
+
+   return NULL;
+}
+
 static void test_atomic_functional(void *func_ptr(void *), int check)
 {
pthrd_arg arg;
@@ -1702,12 +1779,18 @@ void synchronizers_test_atomic_max_min(void)
test_atomic_functional(test_atomic_max_min_thread, CHECK_MAX_MIN);
 }
 
+void synchronizers_test_atomic_cas_inc_dec(void)
+{
+   test_atomic_functional(test_atomic_cas_inc_dec_thread, 0);
+}
+
 odp_testinfo_t synchronizers_suite_atomic[] = {
ODP_TEST_INFO(synchronizers_test_atomic_inc_dec),
ODP_TEST_INFO(synchronizers_test_atomic_add_sub),
ODP_TEST_INFO(synchronizers_test_atomic_fetch_inc_dec),
ODP_TEST_INFO(synchronizers_test_atomic_fetch_add_sub),
ODP_TEST_INFO(synchronizers_test_atomic_max_min),
+   ODP_TEST_INFO(synchronizers_test_atomic_cas_inc_dec),
ODP_TEST_INFO_NULL,
 };
 
diff --git a/test/validation/synchronizers/synchronizers.h 
b/test/validation/synchronizers/synchronizers.h
index b7531a0..4561d82 100644
--- a/test/validation/synchronizers/synchronizers.h
+++ b/test/validation/synchronizers/synchronizers.h
@@ -29,6 +29,7 @@ void synchronizers_test_atomic_add_sub(void);
 void synchronizers_test_atomic_fetch_inc_dec(void);
 void synchronizers_test_atomic_fetch_add_sub(void);
 void synchronizers_test_atomic_max_min(void);
+void synchronizers_test_atomic_cas_inc_dec(void);
 
 /* test arrays: */
 extern odp_testinfo_t synchronizers_suite_barrier[];
-- 
2.6.3

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v6] validation: system: add validation tests for odp_cpu_cycles_* calls

2016-01-18 Thread Savolainen, Petri (Nokia - FI/Espoo)
Not sure if "odp_cpu_cycles_*" will cause problems in git log history. May be 
Maxim can remove the '*' from the string during merge (e.g. just "... 
cpu_cycles calls").

Reviewed-by: Petri Savolainen 



> -Original Message-
> From: EXT Ivan Khoronzhuk [mailto:ivan.khoronz...@linaro.org]
> Sent: Monday, January 18, 2016 3:16 PM
> To: lng-odp@lists.linaro.org
> Cc: Savolainen, Petri (Nokia - FI/Espoo); Ivan Khoronzhuk
> Subject: [lng-odp] [PATCH v6] validation: system: add validation tests for
> odp_cpu_cycles_* calls
> 
> https://bugs.linaro.org/show_bug.cgi?id=1906
> 
> Signed-off-by: Ivan Khoronzhuk 
> ---
> Since v5:
> - add res instead of "1" while wrap
> - get cycle stamps a multiple of res instead direct valuues.
> - move resolution test before diff test
> 
> Since v3:
> - modified log "wrap is not detected"
> - increased try num for diff to match 16 seconds
> - decreased try num for resolution to match 1 second
> - allow resolution to be up to max / 1024
> - correct wrap detection for resolution
> 
> Since v2:
> - added c <= max
> - replaced etalon on tmp
> - added msg about skip
> - handled resolution wrap
> 
> # Please enter the commit message for your changes. Lines starting
> # with '#' will be ignored, and an empty message aborts the commit.
> # On branch validation_tests_corrections
> # Changes to be committed:
> # modified:   platform/linux-keystone2/odp_crypto.c
> # modified:   test/validation/system/system.c
> #
> # Changes not staged for commit:
> # modified:   platform/linux-keystone2/odp_schedule.c
> #
> # Untracked files:
> # .checkpatch-camelcase.git.81a3df4
> # example/traffic_mgmt/
> #
> 
>  test/validation/system/system.c | 125
> 
>  test/validation/system/system.h |   4 ++
>  2 files changed, 129 insertions(+)
> 
> diff --git a/test/validation/system/system.c
> b/test/validation/system/system.c
> index 7dc2cc0..7f54338 100644
> --- a/test/validation/system/system.c
> +++ b/test/validation/system/system.c
> @@ -10,6 +10,9 @@
>  #include "test_debug.h"
>  #include "system.h"
> 
> +#define DIFF_TRY_NUM 160
> +#define RES_TRY_NUM  10
> +
>  void system_test_odp_version_numbers(void)
>  {
>   int char_ok = 0;
> @@ -40,6 +43,124 @@ void system_test_odp_cpu_count(void)
>   CU_ASSERT(0 < cpus);
>  }
> 
> +void system_test_odp_cpu_cycles(void)
> +{
> + uint64_t c2, c1;
> +
> + c1 = odp_cpu_cycles();
> + odp_time_wait_ns(100);
> + c2 = odp_cpu_cycles();
> +
> + CU_ASSERT(c2 != c1);
> +}
> +
> +void system_test_odp_cpu_cycles_max(void)
> +{
> + uint64_t c2, c1;
> + uint64_t max1, max2;
> +
> + max1 = odp_cpu_cycles_max();
> + odp_time_wait_ns(100);
> + max2 = odp_cpu_cycles_max();
> +
> + CU_ASSERT(max1 >= UINT32_MAX / 2);
> + CU_ASSERT(max1 == max2);
> +
> + c1 = odp_cpu_cycles();
> + odp_time_wait_ns(1000);
> + c2 = odp_cpu_cycles();
> +
> + CU_ASSERT(c1 <= max1 && c2 <= max1);
> +}
> +
> +void system_test_odp_cpu_cycles_resolution(void)
> +{
> + int i;
> + uint64_t res;
> + uint64_t c2, c1, max;
> +
> + max = odp_cpu_cycles_max();
> +
> + res = odp_cpu_cycles_resolution();
> + CU_ASSERT(res != 0);
> + CU_ASSERT(res < max / 1024);
> +
> + for (i = 0; i < RES_TRY_NUM; i++) {
> + c1 = odp_cpu_cycles();
> + odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
> + c2 = odp_cpu_cycles();
> +
> + CU_ASSERT(c1 % res == 0);
> + CU_ASSERT(c2 % res == 0);
> + }
> +}
> +
> +void system_test_odp_cpu_cycles_diff(void)
> +{
> + int i;
> + uint64_t c2, c1, c3, max;
> + uint64_t tmp, diff, res;
> +
> + res = odp_cpu_cycles_resolution();
> + max = odp_cpu_cycles_max();
> +
> + /* check resolution for wrap */
> + c1 = max - 2 * res;
> + do
> + c2 = odp_cpu_cycles();
> + while (c1 < c2);
> +
> + diff = odp_cpu_cycles_diff(c1, c1);
> + CU_ASSERT(diff == 0);
> +
> + /* wrap */
> + tmp = c2 + (max - c1) + res;
> + diff = odp_cpu_cycles_diff(c2, c1);
> + CU_ASSERT(diff == tmp);
> + CU_ASSERT(diff % res == 0);
> +
> + /* no wrap, revert args */
> + tmp = c1 - c2;
> + diff = odp_cpu_cycles_diff(c1, c2);
> + CU_ASSERT(diff == tmp);
> + CU_ASSERT(diff % res == 0);
> +
> + c3 = odp_cpu_cycles();
> + for (i = 0; i < DIFF_TRY_NUM; i++) {
> + c1 = odp_cpu_cycles();
> + odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
> + c2 = odp_cpu_cycles();
> +
> + CU_ASSERT(c2 != c1);
> + CU_ASSERT(c1 % res == 0);
> + CU_ASSERT(c2 % res == 0);
> + CU_ASSERT(c1 <= max && c2 <= max);
> +
> + if (c2 > c1)
> + tmp = c2 - c1;
> + else
> + tmp = c2 + (max - c1) + res;
> +
> +  

Re: [lng-odp] [PATCH] test: change l2fwd pool size

2016-01-18 Thread Maxim Uvarov

strange that on make check l2fwd test fails due to small packet rate

1405 maximum packets per second.

without patch:
6475 maximum packets per second.

test consumes that less then 5000 is error.

Please check on your machine.

Maxim.


On 01/15/2016 16:27, Bill Fischofer wrote:



On Thu, Jan 14, 2016 at 11:12 AM, Zoltan Kiss > wrote:


The current code looks awkward, it defines pkt.num as 564. Clean
that up
and set it to 8k to make sure even several big descriptor rings
could be
accomodated.

Signed-off-by: Zoltan Kiss >


Reviewed-by: Bill Fischofer >



diff --git a/test/performance/odp_l2fwd.c
b/test/performance/odp_l2fwd.c
index a85b830..a4c6e49 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -33,7 +33,7 @@
 /** @def SHM_PKT_POOL_SIZE
  * @brief Size of the shared memory block
  */
-#define SHM_PKT_POOL_SIZE  (512*2048)
+#define SHM_PKT_POOL_SIZE  8192

 /** @def SHM_PKT_POOL_BUF_SIZE
  * @brief Buffer size of the packet pool buffer
@@ -535,7 +535,7 @@ int main(int argc, char *argv[])
odp_pool_param_init();
params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE;
params.pkt.len = SHM_PKT_POOL_BUF_SIZE;
-   params.pkt.num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE;
+   params.pkt.num = SHM_PKT_POOL_SIZE;
params.type= ODP_POOL_PACKET;

pool = odp_pool_create("packet pool", );
___
lng-odp mailing list
lng-odp@lists.linaro.org 
https://lists.linaro.org/mailman/listinfo/lng-odp




___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH API-NEXT] api: pktio: remove unused ODP_PKTIO_ANY

2016-01-18 Thread Savolainen, Petri (Nokia - FI/Espoo)
Reviewed-by: Petri Savolainen 


> -Original Message-
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT
> Stuart Haslam
> Sent: Friday, January 15, 2016 5:18 PM
> To: lng-odp@lists.linaro.org
> Subject: [lng-odp] [PATCH API-NEXT] api: pktio: remove unused
> ODP_PKTIO_ANY
> 
> ODP_PKTIO_ANY is defined in the API header but there's no description of
> its intended use and it wouldn't make sense to pass it to the majority
> of exisitng APIs that take odp_pktio_t handles.
> 
> It's not currently used anywhere, so remove it.
> 
> Signed-off-by: Stuart Haslam 
> ---
>  include/odp/api/packet_io.h   | 5 -
>  platform/linux-generic/include/odp/plat/packet_io_types.h | 2 --
>  2 files changed, 7 deletions(-)
> 
> diff --git a/include/odp/api/packet_io.h b/include/odp/api/packet_io.h
> index a0a2c12..4971108 100644
> --- a/include/odp/api/packet_io.h
> +++ b/include/odp/api/packet_io.h
> @@ -58,11 +58,6 @@ extern "C" {
>   */
> 
>  /**
> - * @def ODP_PKTIO_ANY
> - * odp_pktio_t value to indicate any port
> - */
> -
> -/**
>   * @def ODP_PKTIO_MACADDR_MAXSIZE
>   * Minimum size of output buffer for odp_pktio_mac_addr()
>   * Actual MAC address sizes may be different.
> diff --git a/platform/linux-generic/include/odp/plat/packet_io_types.h
> b/platform/linux-generic/include/odp/plat/packet_io_types.h
> index 25f7151..934d7de 100644
> --- a/platform/linux-generic/include/odp/plat/packet_io_types.h
> +++ b/platform/linux-generic/include/odp/plat/packet_io_types.h
> @@ -42,8 +42,6 @@ typedef struct odp_pktout_queue_t {
> 
>  #define ODP_PKTIO_INVALID _odp_cast_scalar(odp_pktio_t, 0)
> 
> -#define ODP_PKTIO_ANY _odp_cast_scalar(odp_pktio_t, ~0)
> -
>  #define ODP_PKTIO_MACADDR_MAXSIZE 16
> 
>  /** Get printable format of odp_pktio_t */
> --
> 2.1.1
> 
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH] linux-generic: init: handle local/global init/term cleanly

2016-01-18 Thread Maxim Uvarov

Merged,
Maxim.

On 01/15/2016 19:05, Ivan Khoronzhuk wrote:



On 14.01.16 23:21, Bill Fischofer wrote:

Restructure odp_init_global() and odp_init_local() so that they recover
cleanly if initialization fails. At exit any partial initialization is
reversed so that system is in the same state as before the failing call
was made. This includes adding dummy termination calls for functions 
that

do not require explicit cleanup for symmetry and future-proofing.

Note: This patch partially addresses the issues identified by Bug
https://bugs.linaro.org/show_bug.cgi?id=1706
Signed-off-by: Bill Fischofer 


Reviewed-by: Ivan Khoronzhuk 


---
  platform/linux-generic/include/odp_internal.h |  24 ++-
  platform/linux-generic/odp_init.c | 239 
++

  platform/linux-generic/odp_system_info.c  |   8 +
  platform/linux-generic/odp_time.c |   7 +-
  platform/linux-generic/odp_timer.c|   5 +
  5 files changed, 209 insertions(+), 74 deletions(-)

diff --git a/platform/linux-generic/include/odp_internal.h 
b/platform/linux-generic/include/odp_internal.h

index 113b700..b22f956 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -38,9 +38,29 @@ struct odp_global_data_s {
  odp_system_info_t system_info;
  };

+enum init_stage {
+NO_INIT = 0,/* No init stages completed */
+TIME_INIT = 1,
+SYSINFO_INIT = 2,
+SHM_INIT = 3,
+THREAD_INIT = 4,
+POOL_INIT = 5,
+QUEUE_INIT = 6,
+SCHED_INIT = 7,
+PKTIO_INIT = 8,
+TIMER_INIT = 9,
+CRYPTO_INIT = 10,
+CLASSIFICATION_INIT = 11,
+ALL_INIT = 12   /* All init stages completed */
+};
+
  extern struct odp_global_data_s odp_global_data;

+int _odp_term_global(enum init_stage stage);
+int _odp_term_local(enum init_stage stage);
+
  int odp_system_info_init(void);
+int odp_system_info_term(void);

  int odp_thread_init_global(void);
  int odp_thread_init_local(odp_thread_type_t type);
@@ -75,9 +95,11 @@ int odp_schedule_init_local(void);
  int odp_schedule_term_local(void);

  int odp_timer_init_global(void);
+int odp_timer_term_global(void);
  int odp_timer_disarm_all(void);

-int odp_time_global_init(void);
+int odp_time_init_global(void);
+int odp_time_term_global(void);

  void _odp_flush_caches(void);

diff --git a/platform/linux-generic/odp_init.c 
b/platform/linux-generic/odp_init.c

index ea99742..3a990d2 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -14,6 +14,7 @@ struct odp_global_data_s odp_global_data;
  int odp_init_global(const odp_init_t *params,
  const odp_platform_init_t *platform_params ODP_UNUSED)
  {
+enum init_stage stage = NO_INIT;
  odp_global_data.log_fn = odp_override_log;
  odp_global_data.abort_fn = odp_override_abort;

@@ -24,105 +25,170 @@ int odp_init_global(const odp_init_t *params,
  odp_global_data.abort_fn = params->abort_fn;
  }

-if (odp_time_global_init()) {
+if (odp_time_init_global()) {
  ODP_ERR("ODP time init failed.\n");
-return -1;
+goto init_failed;
  }
+stage = TIME_INIT;

  if (odp_system_info_init()) {
  ODP_ERR("ODP system_info init failed.\n");
-return -1;
+goto init_failed;
  }
+stage = SYSINFO_INIT;

  if (odp_shm_init_global()) {
  ODP_ERR("ODP shm init failed.\n");
-return -1;
+goto init_failed;
  }
+stage = SHM_INIT;

  if (odp_thread_init_global()) {
  ODP_ERR("ODP thread init failed.\n");
-return -1;
+goto init_failed;
  }
+stage = THREAD_INIT;

  if (odp_pool_init_global()) {
  ODP_ERR("ODP pool init failed.\n");
-return -1;
+goto init_failed;
  }
+stage = POOL_INIT;

  if (odp_queue_init_global()) {
  ODP_ERR("ODP queue init failed.\n");
-return -1;
+goto init_failed;
  }
+stage = QUEUE_INIT;

  if (odp_schedule_init_global()) {
  ODP_ERR("ODP schedule init failed.\n");
-return -1;
+goto init_failed;
  }
+stage = SCHED_INIT;

  if (odp_pktio_init_global()) {
  ODP_ERR("ODP packet io init failed.\n");
-return -1;
+goto init_failed;
  }
+stage = PKTIO_INIT;

  if (odp_timer_init_global()) {
  ODP_ERR("ODP timer init failed.\n");
-return -1;
+goto init_failed;
  }
+stage = TIMER_INIT;

  if (odp_crypto_init_global()) {
  ODP_ERR("ODP crypto init failed.\n");
-return -1;
+goto init_failed;
  }
+stage = CRYPTO_INIT;
+
  if (odp_classification_init_global()) {
  ODP_ERR("ODP classification init failed.\n");
-return -1;
+goto init_failed;
  }
+stage = CLASSIFICATION_INIT;

  return 0;
+
+init_failed:
+

Re: [lng-odp] [PATCHv19 9/9] linux-generic: internal ipc_pktio test

2016-01-18 Thread Stuart Haslam
On Mon, Jan 18, 2016 at 12:59:44PM +0300, Maxim Uvarov wrote:
> On 01/15/2016 15:57, Stuart Haslam wrote:
> >On Mon, Dec 21, 2015 at 01:56:11PM +0300, Maxim Uvarov wrote:
> >>2 example ipc pktio applications create ipc pktio to each other and do
> >>packet transfer, validation magic numbers and packets sequence counters
> >>inside it.
> >>
> >It looks like there's a race somewhere as I get occasional failures:
> >
> >#2  0x004138b9 in odp_override_abort () at odp_weak.c:40
> >#3  0x00407431 in _ipc_map_remote_pool (
> > name=name@entry=0x7fad1cb48020  > 0x7fad1cb48020>,
> > size=1310720) at pktio/ipc.c:265
> >#4  0x0040845c in _ipc_slave_start (pktio_entry=0x7fad1ca68240) at 
> >pktio/ipc.c:359
> >#5  ipc_start (pktio_entry=0x7fad1ca68240) at pktio/ipc.c:670
> >#6  0x00405930 in odp_pktio_start (id=0x1414, id@entry=0x1) at 
> >odp_packet_io.c:309
> >#7  0x004026c1 in ipc_second_process () at pktio_ipc2.c:66
> >#8  main (argc=, argv=) at pktio_ipc2.c:184
> >
> 
> Did you run make check? Maybe some files from previous wrong clean
> up were in shm?
> I tested make check bunch of time and did not see any fails. Will try again.
> 
> Maxim.

I was running pktio_ipc_run directly, which is just what "make check"
does so I imagine I'd be able to reproduce it with that too, it would
just take longer.

-- 
Stuart.
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v5 API-NEXT 12/12] linux-generic: sysinfo: rename variable cpu_hz to cpu_hz_max

2016-01-18 Thread hongbo . zhang
From: Hongbo Zhang 

The legacy variable cpu_hz holds the max frequency for odp_cpu_hz_max(),
so rename it to cpu_hz_max for better meaning.

Signed-off-by: Hongbo Zhang 
---
 platform/linux-generic/arch/mips64/odp_sysinfo_parse.c  | 2 +-
 platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c | 2 +-
 platform/linux-generic/arch/x86/odp_sysinfo_parse.c | 3 ++-
 platform/linux-generic/include/odp_internal.h   | 2 +-
 platform/linux-generic/odp_system_info.c| 4 ++--
 5 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
index 88c2066..c83d1d1 100644
--- a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
@@ -24,7 +24,7 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
if (pos) {
sscanf(pos, "BogoMIPS : %lf", );
/* bogomips seems to be 2x freq */
-   sysinfo->cpu_hz[id] = \
+   sysinfo->cpu_hz_max[id] = \
(uint64_t)(mhz * 100.0 / 2.0);
count--;
}
diff --git a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
index 1d122cc..9995b05 100644
--- a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
@@ -23,7 +23,7 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
 
if (pos) {
sscanf(pos, "clock : %lf", );
-   sysinfo->cpu_hz[id] = \
+   sysinfo->cpu_hz_max[id] = \
(uint64_t)(mhz * 100.0);
count--;
}
diff --git a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
index aeb3d8f..e20ffcc 100644
--- a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
@@ -25,7 +25,8 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
pos = strchr(sysinfo->model_str[id], '@');
*(pos - 1) = '\0';
if (sscanf(pos, "@ %lfGHz", ) == 1)
-   sysinfo->cpu_hz[id] = (uint64_t)(ghz * 
10.0);
+   sysinfo->cpu_hz_max[id] = \
+   (uint64_t)(ghz * 10.0);
 
id++;
}
diff --git a/platform/linux-generic/include/odp_internal.h 
b/platform/linux-generic/include/odp_internal.h
index d3cde5f..b30c0b3 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -27,7 +27,7 @@ extern __thread int __odp_errno;
 #define MAX_CPU_NUMBER 128
 
 typedef struct {
-   uint64_t cpu_hz[MAX_CPU_NUMBER];
+   uint64_t cpu_hz_max[MAX_CPU_NUMBER];
uint64_t huge_page_size;
uint64_t page_size;
int  cache_line_size;
diff --git a/platform/linux-generic/odp_system_info.c 
b/platform/linux-generic/odp_system_info.c
index c9cdcb4..36c1a77 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -168,7 +168,7 @@ static int systemcpu(odp_system_info_t *sysinfo)
ODP_DBG("Warning: use dummy values for freq and model string\n");
ODP_DBG("Refer to https://bugs.linaro.org/show_bug.cgi?id=1870\n;);
for (i = 0; i < MAX_CPU_NUMBER; i++) {
-   sysinfo->cpu_hz[i] = 14;
+   sysinfo->cpu_hz_max[i] = 14;
strcpy(sysinfo->model_str[i], "UNKNOWN");
}
 
@@ -231,7 +231,7 @@ uint64_t odp_cpu_hz_max(void)
 uint64_t odp_cpu_hz_max_id(int id)
 {
if (id >= 0 && id < MAX_CPU_NUMBER)
-   return odp_global_data.system_info.cpu_hz[id];
+   return odp_global_data.system_info.cpu_hz_max[id];
else
return 0;
 }
-- 
2.1.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v5 API-NEXT 11/12] linux-generic: sysinfo: apply per-CPU implementation to PowerPC

2016-01-18 Thread hongbo . zhang
From: Hongbo Zhang 

When per-CPU framework was introduced, it was only implemented on x86,
for other platforms, only the model_str[0] and cpu_hz[0] are set to pass
compile, this patch set all values for model_str[] and cpu_hz[] on the
PowerPC platform.

Signed-off-by: Hongbo Zhang 
---
 .../linux-generic/arch/powerpc/odp_sysinfo_parse.c   | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
index e221f10..1d122cc 100644
--- a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
@@ -14,14 +14,17 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t 
*sysinfo)
double mhz = 0.0;
int model = 0;
int count = 2;
+   int id = 0;
 
strcpy(sysinfo->cpu_arch_str, "powerpc");
-   while (fgets(str, sizeof(str), file) != NULL && count > 0) {
+   while (fgets(str, sizeof(str), file) != NULL && id < MAX_CPU_NUMBER) {
if (!mhz) {
pos = strstr(str, "clock");
 
if (pos) {
sscanf(pos, "clock : %lf", );
+   sysinfo->cpu_hz[id] = \
+   (uint64_t)(mhz * 100.0);
count--;
}
}
@@ -33,16 +36,21 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t 
*sysinfo)
int len;
 
pos = strchr(str, ':');
-   strncpy(sysinfo->model_str[0], pos + 2,
-   sizeof(sysinfo->model_str[0]));
-   len = strlen(sysinfo->model_str[0]);
-   sysinfo->model_str[0][len - 1] = 0;
+   strncpy(sysinfo->model_str[id], pos + 2,
+   sizeof(sysinfo->model_str[id]));
+   len = strlen(sysinfo->model_str[id]);
+   sysinfo->model_str[id][len - 1] = 0;
model = 1;
count--;
}
}
 
-   sysinfo->cpu_hz[0] = (uint64_t)(mhz * 100.0);
+   if (count == 0) {
+   mhz = 0.0;
+   model = 0;
+   count = 2;
+   id++;
+   }
}
 
return 0;
-- 
2.1.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v5 API-NEXT 03/12] linux-generic: sysinfo: rename odp_cpu_hz_current with odp_ prefix

2016-01-18 Thread hongbo . zhang
From: Hongbo Zhang 

This function will be moved to their own platform specific files too,
it is better to be named with a odp_ prefix.

Signed-off-by: Hongbo Zhang 
---
 platform/linux-generic/odp_system_info.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/platform/linux-generic/odp_system_info.c 
b/platform/linux-generic/odp_system_info.c
index a829b01..449e500 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -136,7 +136,7 @@ static int odp_cpuinfo_parser(FILE *file, odp_system_info_t 
*sysinfo)
return 0;
 }
 
-static uint64_t arch_cpu_hz_current(int id)
+static uint64_t odp_cpu_hz_current(int id)
 {
char str[1024];
FILE *file;
@@ -180,7 +180,7 @@ odp_system_info_t *sysinfo ODP_UNUSED)
return 0;
 }
 
-static uint64_t arch_cpu_hz_current(int id ODP_UNUSED)
+static uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
 {
return -1;
 }
@@ -227,7 +227,7 @@ static int odp_cpuinfo_parser(FILE *file, odp_system_info_t 
*sysinfo)
return 0;
 }
 
-static uint64_t arch_cpu_hz_current(int id ODP_UNUSED)
+static uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
 {
return -1;
 }
@@ -273,7 +273,7 @@ static int odp_cpuinfo_parser(FILE *file, odp_system_info_t 
*sysinfo)
return 0;
 }
 
-static uint64_t arch_cpu_hz_current(int id ODP_UNUSED)
+static uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
 {
return -1;
 }
@@ -394,12 +394,12 @@ uint64_t odp_cpu_hz(void)
 {
int id = sched_getcpu();
 
-   return arch_cpu_hz_current(id);
+   return odp_cpu_hz_current(id);
 }
 
 uint64_t odp_cpu_hz_id(int id)
 {
-   return arch_cpu_hz_current(id);
+   return odp_cpu_hz_current(id);
 }
 
 uint64_t odp_cpu_hz_max(void)
-- 
2.1.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v5 API-NEXT 06/12] linux-generic: sysinfo: move ARM system info codes to default arch file

2016-01-18 Thread hongbo . zhang
From: Hongbo Zhang 

This patch moves the ARM system info codes into the general arch file,
ARM sysinfo isn't implemented now and there is no need to create specific
arch file for it, but this can serve as the default implementaton instead.

Signed-off-by: Hongbo Zhang 
---
 platform/linux-generic/Makefile.am|  1 +
 platform/linux-generic/arch/linux/odp_sysinfo_parse.c | 19 +++
 platform/linux-generic/odp_system_info.c  | 15 +--
 3 files changed, 21 insertions(+), 14 deletions(-)
 create mode 100644 platform/linux-generic/arch/linux/odp_sysinfo_parse.c

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index d3802f8..b737135 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -164,6 +164,7 @@ __LIB__libodp_la_SOURCES = \
 
 EXTRA_DIST = \
 arch/linux/odp_cpu_arch.c \
+arch/linux/odp_sysinfo_parse.c \
 arch/mips64/odp_cpu_arch.c \
 arch/mips64/odp_sysinfo_parse.c \
 arch/x86/odp_cpu_arch.c \
diff --git a/platform/linux-generic/arch/linux/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/linux/odp_sysinfo_parse.c
new file mode 100644
index 000..d8f36a4
--- /dev/null
+++ b/platform/linux-generic/arch/linux/odp_sysinfo_parse.c
@@ -0,0 +1,19 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include 
+#include 
+
+int odp_cpuinfo_parser(FILE *file ODP_UNUSED,
+odp_system_info_t *sysinfo ODP_UNUSED)
+{
+   return 0;
+}
+
+uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
+{
+   return -1;
+}
diff --git a/platform/linux-generic/odp_system_info.c 
b/platform/linux-generic/odp_system_info.c
index 854bad0..5ff95e8 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -108,20 +108,7 @@ static int huge_page_size(void)
 /*
  * HW specific /proc/cpuinfo file parsing
  */
-#if defined __arm__ || defined __aarch64__
-
-static int odp_cpuinfo_parser(FILE *file ODP_UNUSED,
-odp_system_info_t *sysinfo ODP_UNUSED)
-{
-   return 0;
-}
-
-static uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
-{
-   return -1;
-}
-
-#elif defined __powerpc__
+#if defined __powerpc__
 static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
 {
char str[1024];
-- 
2.1.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v5 API-NEXT 05/12] linux-generic: sysinfo: move MIPS system info codes to its plarform file

2016-01-18 Thread hongbo . zhang
From: Hongbo Zhang 

This patch moves the MIPS system info codes into the newly added MIPS
specific platform file.

Signed-off-by: Hongbo Zhang 
---
 platform/linux-generic/Makefile.am |  1 +
 .../linux-generic/arch/mips64/odp_sysinfo_parse.c  | 53 ++
 platform/linux-generic/odp_system_info.c   | 47 ---
 3 files changed, 54 insertions(+), 47 deletions(-)
 create mode 100644 platform/linux-generic/arch/mips64/odp_sysinfo_parse.c

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index de43eff..d3802f8 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -165,6 +165,7 @@ __LIB__libodp_la_SOURCES = \
 EXTRA_DIST = \
 arch/linux/odp_cpu_arch.c \
 arch/mips64/odp_cpu_arch.c \
+arch/mips64/odp_sysinfo_parse.c \
 arch/x86/odp_cpu_arch.c \
 arch/x86/odp_sysinfo_parse.c
 
diff --git a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
new file mode 100644
index 000..cc75b96
--- /dev/null
+++ b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
@@ -0,0 +1,53 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include 
+#include 
+
+int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
+{
+   char str[1024];
+   char *pos;
+   double mhz = 0.0;
+   int model = 0;
+   int count = 2;
+
+   while (fgets(str, sizeof(str), file) != NULL && count > 0) {
+   if (!mhz) {
+   pos = strstr(str, "BogoMIPS");
+
+   if (pos) {
+   sscanf(pos, "BogoMIPS : %lf", );
+   count--;
+   }
+   }
+
+   if (!model) {
+   pos = strstr(str, "cpu model");
+
+   if (pos) {
+   int len;
+   pos = strchr(str, ':');
+   strncpy(sysinfo->model_str[0], pos + 2,
+   sizeof(sysinfo->model_str[0]));
+   len = strlen(sysinfo->model_str[0]);
+   sysinfo->model_str[0][len - 1] = 0;
+   model = 1;
+   count--;
+   }
+   }
+   }
+
+   /* bogomips seems to be 2x freq */
+   sysinfo->cpu_hz[0] = (uint64_t)(mhz * 100.0 / 2.0);
+
+   return 0;
+}
+
+uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
+{
+   return -1;
+}
diff --git a/platform/linux-generic/odp_system_info.c 
b/platform/linux-generic/odp_system_info.c
index 4824d55..854bad0 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -121,53 +121,6 @@ static uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
return -1;
 }
 
-#elif defined __OCTEON__
-
-static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
-{
-   char str[1024];
-   char *pos;
-   double mhz = 0.0;
-   int model = 0;
-   int count = 2;
-
-   while (fgets(str, sizeof(str), file) != NULL && count > 0) {
-   if (!mhz) {
-   pos = strstr(str, "BogoMIPS");
-
-   if (pos) {
-   sscanf(pos, "BogoMIPS : %lf", );
-   count--;
-   }
-   }
-
-   if (!model) {
-   pos = strstr(str, "cpu model");
-
-   if (pos) {
-   int len;
-   pos = strchr(str, ':');
-   strncpy(sysinfo->model_str[0], pos + 2,
-   sizeof(sysinfo->model_str[0]));
-   len = strlen(sysinfo->model_str[0]);
-   sysinfo->model_str[0][len - 1] = 0;
-   model = 1;
-   count--;
-   }
-   }
-   }
-
-   /* bogomips seems to be 2x freq */
-   sysinfo->cpu_hz[0] = (uint64_t)(mhz * 100.0 / 2.0);
-
-   return 0;
-}
-
-static uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
-{
-   return -1;
-}
-
 #elif defined __powerpc__
 static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
 {
-- 
2.1.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] What to do regarding cahe non coherant systems

2016-01-18 Thread Ola Liljedahl
On 15 January 2016 at 15:48, Christophe Milard  wrote:

> On Tuesday's ARCH call, we will be discussing the above topic.
> Nicolas (Kalray) will try to join, but he is very uncertain  at this stage
> (if he can be there)...
>
Cache coherence is the norm today, non-coherent is an exception.
My opinion: If possible and simple, make public interfaces not dependent on
cache coherence. The reference implementation could depend on cache
coherence. Anyone who wants to support non-coherent HW needs to provide the
necessary support.


>
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v5 API-NEXT 04/12] linux-generic: sysinfo: move x86 system info codes to its plarform file

2016-01-18 Thread hongbo . zhang
From: Hongbo Zhang 

This patch moves the x86 system info codes into the newly added x86
specific platform file.

Signed-off-by: Hongbo Zhang 
---
 platform/linux-generic/Makefile.am |  6 +-
 .../linux-generic/arch/x86/odp_sysinfo_parse.c | 70 ++
 platform/linux-generic/include/odp_internal.h  |  4 ++
 platform/linux-generic/odp_system_info.c   | 68 +
 4 files changed, 79 insertions(+), 69 deletions(-)
 create mode 100644 platform/linux-generic/arch/x86/odp_sysinfo_parse.c

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 9fbb3bd..de43eff 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -159,12 +159,14 @@ __LIB__libodp_la_SOURCES = \
   odp_traffic_mngr.c \
   odp_version.c \
   odp_weak.c \
-  arch/@ARCH@/odp_cpu_arch.c
+  arch/@ARCH@/odp_cpu_arch.c \
+  arch/@ARCH@/odp_sysinfo_parse.c
 
 EXTRA_DIST = \
 arch/linux/odp_cpu_arch.c \
 arch/mips64/odp_cpu_arch.c \
-arch/x86/odp_cpu_arch.c
+arch/x86/odp_cpu_arch.c \
+arch/x86/odp_sysinfo_parse.c
 
 if HAVE_PCAP
 __LIB__libodp_la_SOURCES += pktio/pcap.c
diff --git a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
new file mode 100644
index 000..85cc34c
--- /dev/null
+++ b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
@@ -0,0 +1,70 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include 
+#include 
+
+int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
+{
+   char str[1024];
+   char *pos;
+   double ghz = 0.0;
+   int id = 0;
+
+   while (fgets(str, sizeof(str), file) != NULL && id < MAX_CPU_NUMBER) {
+   pos = strstr(str, "model name");
+   if (pos) {
+   pos = strchr(str, ':');
+   strncpy(sysinfo->model_str[id], pos + 2,
+   sizeof(sysinfo->model_str[id]));
+
+   pos = strchr(sysinfo->model_str[id], '@');
+   *(pos - 1) = '\0';
+   if (sscanf(pos, "@ %lfGHz", ) == 1)
+   sysinfo->cpu_hz[id] = (uint64_t)(ghz * 
10.0);
+
+   id++;
+   }
+   }
+
+   return 0;
+}
+
+uint64_t odp_cpu_hz_current(int id)
+{
+   char str[1024];
+   FILE *file;
+   int cpu;
+   char *pos;
+   double mhz = 0.0;
+
+   file = fopen("/proc/cpuinfo", "rt");
+
+   /* find the correct processor instance */
+   while (fgets(str, sizeof(str), file) != NULL) {
+   pos = strstr(str, "processor");
+   if (pos) {
+   if (sscanf(pos, "processor : %d", ) == 1)
+   if (cpu == id)
+   break;
+   }
+   }
+
+   /* extract the cpu current speed */
+   while (fgets(str, sizeof(str), file) != NULL) {
+   pos = strstr(str, "cpu MHz");
+   if (pos) {
+   if (sscanf(pos, "cpu MHz : %lf", ) == 1)
+   break;
+   }
+   }
+
+   fclose(file);
+   if (mhz)
+   return (uint64_t)(mhz * 100.0);
+
+   return -1;
+}
diff --git a/platform/linux-generic/include/odp_internal.h 
b/platform/linux-generic/include/odp_internal.h
index 2eeba42..d3cde5f 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -20,6 +20,7 @@ extern "C" {
 
 #include 
 #include 
+#include 
 
 extern __thread int __odp_errno;
 
@@ -86,6 +87,9 @@ int odp_tm_init_global(void);
 
 void _odp_flush_caches(void);
 
+int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo);
+uint64_t odp_cpu_hz_current(int id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/platform/linux-generic/odp_system_info.c 
b/platform/linux-generic/odp_system_info.c
index 449e500..4824d55 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -108,71 +108,7 @@ static int huge_page_size(void)
 /*
  * HW specific /proc/cpuinfo file parsing
  */
-#if defined __x86_64__ || defined __i386__
-
-static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
-{
-   char str[1024];
-   char *pos;
-   double ghz = 0.0;
-   int id = 0;
-
-   while (fgets(str, sizeof(str), file) != NULL && id < MAX_CPU_NUMBER) {
-   pos = strstr(str, "model name");
-   if (pos) {
-   pos = strchr(str, ':');
-   

[lng-odp] [PATCH v5 API-NEXT 02/12] linux-generic: sysinfo: use uniform call odp_sysinfo_parser

2016-01-18 Thread hongbo . zhang
From: Hongbo Zhang 

It is common way that the general top layer calls a uniform interface to
initialize data structrure for different plarform, this patch introduces
odp_sysinfo_parser() instead of using different interfaces for each
platform, and also removes using structure odp_compiler_info_t since both
members inside it become useless now.
This is still another pre-step for separating platform specific codes into
their own arch files.

Signed-off-by: Hongbo Zhang 
---
 platform/linux-generic/odp_system_info.c | 34 +---
 1 file changed, 5 insertions(+), 29 deletions(-)

diff --git a/platform/linux-generic/odp_system_info.c 
b/platform/linux-generic/odp_system_info.c
index 8cbdd58..a829b01 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -24,12 +24,6 @@
 #include 
 
 
-
-typedef struct {
-   int (*cpuinfo_parser)(FILE *file, odp_system_info_t *sysinfo);
-
-} odp_compiler_info_t;
-
 #define CACHE_LNSZ_FILE \
"/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size"
 
@@ -116,7 +110,7 @@ static int huge_page_size(void)
  */
 #if defined __x86_64__ || defined __i386__
 
-static int cpuinfo_x86(FILE *file, odp_system_info_t *sysinfo)
+static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
 {
char str[1024];
char *pos;
@@ -180,7 +174,7 @@ static uint64_t arch_cpu_hz_current(int id)
 
 #elif defined __arm__ || defined __aarch64__
 
-static int cpuinfo_arm(FILE *file ODP_UNUSED,
+static int odp_cpuinfo_parser(FILE *file ODP_UNUSED,
 odp_system_info_t *sysinfo ODP_UNUSED)
 {
return 0;
@@ -193,7 +187,7 @@ static uint64_t arch_cpu_hz_current(int id ODP_UNUSED)
 
 #elif defined __OCTEON__
 
-static int cpuinfo_octeon(FILE *file, odp_system_info_t *sysinfo)
+static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
 {
char str[1024];
char *pos;
@@ -239,7 +233,7 @@ static uint64_t arch_cpu_hz_current(int id ODP_UNUSED)
 }
 
 #elif defined __powerpc__
-static int cpuinfo_powerpc(FILE *file, odp_system_info_t *sysinfo)
+static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
 {
char str[1024];
char *pos;
@@ -288,24 +282,6 @@ static uint64_t arch_cpu_hz_current(int id ODP_UNUSED)
#error GCC target not found
 #endif
 
-static odp_compiler_info_t compiler_info = {
-   #if defined __x86_64__ || defined __i386__
-   .cpuinfo_parser = cpuinfo_x86
-
-   #elif defined __arm__ || defined __aarch64__
-   .cpuinfo_parser = cpuinfo_arm
-
-   #elif defined __OCTEON__
-   .cpuinfo_parser = cpuinfo_octeon
-
-   #elif defined __powerpc__
-   .cpuinfo_parser = cpuinfo_powerpc
-
-   #else
-   #error GCC target not found
-   #endif
-};
-
 
 #if defined __x86_64__ || defined __i386__ || defined __OCTEON__ || \
 defined __powerpc__
@@ -397,7 +373,7 @@ int odp_system_info_init(void)
return -1;
}
 
-   compiler_info.cpuinfo_parser(file, _global_data.system_info);
+   odp_cpuinfo_parser(file, _global_data.system_info);
 
fclose(file);
 
-- 
2.1.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v5 API-NEXT 07/12] linux-generic: sysinfo: move PowerPC system info codes to its plarform file

2016-01-18 Thread hongbo . zhang
From: Hongbo Zhang 

This patch moves the PowerPC system info codes into the newly added PowerPC
specific platform file.
This patch also creates syslink to arch/linux/odp_cpu_cycles.c for PowerPC.

Signed-off-by: Hongbo Zhang 
---
 configure.ac   |  1 +
 platform/linux-generic/Makefile.am |  2 +
 platform/linux-generic/arch/powerpc/odp_cpu_arch.c |  1 +
 .../linux-generic/arch/powerpc/odp_sysinfo_parse.c | 53 ++
 platform/linux-generic/odp_system_info.c   | 53 --
 5 files changed, 57 insertions(+), 53 deletions(-)
 create mode 12 platform/linux-generic/arch/powerpc/odp_cpu_arch.c
 create mode 100644 platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c

diff --git a/configure.ac b/configure.ac
index 7e1678a..962ce93 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,6 +55,7 @@ AX_VALGRIND_CHECK
 AS_CASE([$host],
   [x86*], [ARCH=x86],
   [mips64*], [ARCH=mips64],
+  [powerpc*], [ARCH=powerpc],
   [ARCH=linux]
 )
 AC_SUBST([ARCH])
diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index b737135..21cde8a 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -167,6 +167,8 @@ EXTRA_DIST = \
 arch/linux/odp_sysinfo_parse.c \
 arch/mips64/odp_cpu_arch.c \
 arch/mips64/odp_sysinfo_parse.c \
+arch/powerpc/odp_cpu_cycles.c \
+arch/powerpc/odp_sysinfo_parse.c \
 arch/x86/odp_cpu_arch.c \
 arch/x86/odp_sysinfo_parse.c
 
diff --git a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c 
b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c
new file mode 12
index 000..fddea05
--- /dev/null
+++ b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c
@@ -0,0 +1 @@
+platform/linux-generic/arch/linux/odp_cpu_arch.c
\ No newline at end of file
diff --git a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
new file mode 100644
index 000..3f8743c
--- /dev/null
+++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
@@ -0,0 +1,53 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include 
+#include 
+
+int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
+{
+   char str[1024];
+   char *pos;
+   double mhz = 0.0;
+   int model = 0;
+   int count = 2;
+
+   while (fgets(str, sizeof(str), file) != NULL && count > 0) {
+   if (!mhz) {
+   pos = strstr(str, "clock");
+
+   if (pos) {
+   sscanf(pos, "clock : %lf", );
+   count--;
+   }
+   }
+
+   if (!model) {
+   pos = strstr(str, "cpu");
+
+   if (pos) {
+   int len;
+
+   pos = strchr(str, ':');
+   strncpy(sysinfo->model_str[0], pos + 2,
+   sizeof(sysinfo->model_str[0]));
+   len = strlen(sysinfo->model_str[0]);
+   sysinfo->model_str[0][len - 1] = 0;
+   model = 1;
+   count--;
+   }
+   }
+
+   sysinfo->cpu_hz[0] = (uint64_t)(mhz * 100.0);
+   }
+
+   return 0;
+}
+
+uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
+{
+   return -1;
+}
diff --git a/platform/linux-generic/odp_system_info.c 
b/platform/linux-generic/odp_system_info.c
index 5ff95e8..4ab17aa 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -104,59 +104,6 @@ static int huge_page_size(void)
 }
 
 
-
-/*
- * HW specific /proc/cpuinfo file parsing
- */
-#if defined __powerpc__
-static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
-{
-   char str[1024];
-   char *pos;
-   double mhz = 0.0;
-   int model = 0;
-   int count = 2;
-
-   while (fgets(str, sizeof(str), file) != NULL && count > 0) {
-   if (!mhz) {
-   pos = strstr(str, "clock");
-
-   if (pos) {
-   sscanf(pos, "clock : %lf", );
-   count--;
-   }
-   }
-
-   if (!model) {
-   pos = strstr(str, "cpu");
-
-   if (pos) {
-   int len;
-   pos = strchr(str, ':');
-   strncpy(sysinfo->model_str[0], pos + 2,
-   sizeof(sysinfo->model_str[0]));
-   len = 

Re: [lng-odp] [PATCHv19 8/9] linux-generic: add ipc pktio support

2016-01-18 Thread Maxim Uvarov

On 01/15/2016 16:01, Stuart Haslam wrote:

On Mon, Dec 21, 2015 at 01:56:10PM +0300, Maxim Uvarov wrote:

Signed-off-by: Maxim Uvarov 
---
  platform/linux-generic/Makefile.am |   3 +
  .../linux-generic/include/odp_buffer_internal.h|   3 +
  .../linux-generic/include/odp_packet_io_internal.h |  38 ++
  .../include/odp_packet_io_ipc_internal.h   |  47 ++
  platform/linux-generic/include/odp_shm_internal.h  |  21 +
  platform/linux-generic/odp_packet_io.c |   1 +
  platform/linux-generic/odp_pool.c  |  14 +-
  platform/linux-generic/odp_shared_memory.c |  14 +-
  platform/linux-generic/pktio/io_ops.c  |   1 +
  platform/linux-generic/pktio/ipc.c | 729 +
  10 files changed, 866 insertions(+), 5 deletions(-)
  create mode 100644 platform/linux-generic/include/odp_packet_io_ipc_internal.h
  create mode 100644 platform/linux-generic/include/odp_shm_internal.h
  create mode 100644 platform/linux-generic/pktio/ipc.c

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 3400557..cb4add5 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -90,6 +90,7 @@ noinst_HEADERS = \
  ${srcdir}/include/odp_internal.h \
  ${srcdir}/include/odp_packet_internal.h \
  ${srcdir}/include/odp_packet_io_internal.h \
+ ${srcdir}/include/odp_packet_io_ipc_internal.h \
  ${srcdir}/include/odp_packet_io_queue.h \
  ${srcdir}/include/odp_packet_io_ring_internal.h \
  ${srcdir}/include/odp_packet_netmap.h \
@@ -98,6 +99,7 @@ noinst_HEADERS = \
  ${srcdir}/include/odp_pool_internal.h \
  ${srcdir}/include/odp_queue_internal.h \
  ${srcdir}/include/odp_schedule_internal.h \
+ ${srcdir}/include/odp_shm_internal.h \
  ${srcdir}/include/odp_spin_internal.h \
  ${srcdir}/include/odp_timer_internal.h \
  ${srcdir}/include/odp_cpu_internal.h \
@@ -119,6 +121,7 @@ __LIB__libodp_la_SOURCES = \
   odp_packet_flags.c \
   odp_packet_io.c \
   pktio/io_ops.c \
+  pktio/ipc.c \
   pktio/loop.c \
   pktio/netmap.c \
   pktio/socket.c \
diff --git a/platform/linux-generic/include/odp_buffer_internal.h 
b/platform/linux-generic/include/odp_buffer_internal.h
index 74a0b5c..2ea594d 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -133,6 +133,9 @@ struct odp_buffer_hdr_t {
uint32_t uarea_size; /* size of user area */
uint32_t segcount;   /* segment count */
uint32_t segsize;/* segment size */
+   /* ipc mapped process can not walk over pointers,
+* offset has to be used */
+   uint64_t ipc_addr_offset[ODP_BUFFER_MAX_SEG];
void*addr[ODP_BUFFER_MAX_SEG]; /* block addrs */
uint64_t order;  /* sequence for ordered queues */
queue_entry_t   *origin_qe;  /* ordered queue origin */
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h 
b/platform/linux-generic/include/odp_packet_io_internal.h
index de29557..b3fb10b 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -26,6 +26,7 @@ extern "C" {
  #include 
  #include 
  #include 
+#include 
  
  #include 

  #include 
@@ -62,6 +63,41 @@ typedef struct {
  } pkt_pcap_t;
  #endif
  
+typedef	struct {

+   /* TX */
+   struct  {
+   _ring_t *send; /**< ODP ring for IPC msg packets
+   indexes transmitted to shared
+   memory */
+   _ring_t *free; /**< ODP ring for IPC msg packets
+   indexes already processed by remote
+   process */
+   } tx;
+   /* RX */
+   struct {
+   _ring_t *recv; /**< ODP ring for IPC msg packets
+   indexes received from shared
+memory (from remote process) */
+   _ring_t *free; /**< ODP ring for IPC msg packets
+   indexes already processed by
+   current process */
+   } rx; /* slave */
+   void*pool_base; /**< Remote pool base addr */
+   void*pool_mdata_base;   /**< Remote pool mdata base 
addr */
+   

Re: [lng-odp] [PATCHv19 9/9] linux-generic: internal ipc_pktio test

2016-01-18 Thread Maxim Uvarov

On 01/15/2016 15:57, Stuart Haslam wrote:

On Mon, Dec 21, 2015 at 01:56:11PM +0300, Maxim Uvarov wrote:

2 example ipc pktio applications create ipc pktio to each other and do
packet transfer, validation magic numbers and packets sequence counters
inside it.


It looks like there's a race somewhere as I get occasional failures:

#2  0x004138b9 in odp_override_abort () at odp_weak.c:40
#3  0x00407431 in _ipc_map_remote_pool (
 name=name@entry=0x7fad1cb48020 ,
 size=1310720) at pktio/ipc.c:265
#4  0x0040845c in _ipc_slave_start (pktio_entry=0x7fad1ca68240) at 
pktio/ipc.c:359
#5  ipc_start (pktio_entry=0x7fad1ca68240) at pktio/ipc.c:670
#6  0x00405930 in odp_pktio_start (id=0x1414, id@entry=0x1) at 
odp_packet_io.c:309
#7  0x004026c1 in ipc_second_process () at pktio_ipc2.c:66
#8  main (argc=, argv=) at pktio_ipc2.c:184



Did you run make check? Maybe some files from previous wrong clean up 
were in shm?

I tested make check bunch of time and did not see any fails. Will try again.

Maxim.


Signed-off-by: Maxim Uvarov 
---
  platform/linux-generic/m4/configure.m4 |   1 +
  platform/linux-generic/test/Makefile.am|   3 +-
  platform/linux-generic/test/pktio_ipc/.gitignore   |   2 +
  platform/linux-generic/test/pktio_ipc/Makefile.am  |  20 ++
  platform/linux-generic/test/pktio_ipc/ipc_common.c | 138 +
  platform/linux-generic/test/pktio_ipc/ipc_common.h |  87 ++
  platform/linux-generic/test/pktio_ipc/pktio_ipc1.c | 310 +
  platform/linux-generic/test/pktio_ipc/pktio_ipc2.c | 185 
  .../linux-generic/test/pktio_ipc/pktio_ipc_run |  68 +
  9 files changed, 813 insertions(+), 1 deletion(-)
  create mode 100644 platform/linux-generic/test/pktio_ipc/.gitignore
  create mode 100644 platform/linux-generic/test/pktio_ipc/Makefile.am
  create mode 100644 platform/linux-generic/test/pktio_ipc/ipc_common.c
  create mode 100644 platform/linux-generic/test/pktio_ipc/ipc_common.h
  create mode 100644 platform/linux-generic/test/pktio_ipc/pktio_ipc1.c
  create mode 100644 platform/linux-generic/test/pktio_ipc/pktio_ipc2.c
  create mode 100755 platform/linux-generic/test/pktio_ipc/pktio_ipc_run

diff --git a/platform/linux-generic/m4/configure.m4 
b/platform/linux-generic/m4/configure.m4
index 6bb159f..46aaf40 100644
--- a/platform/linux-generic/m4/configure.m4
+++ b/platform/linux-generic/m4/configure.m4
@@ -24,4 +24,5 @@ m4_include([platform/linux-generic/m4/odp_pcap.m4])
  AC_CONFIG_FILES([platform/linux-generic/Makefile
 platform/linux-generic/test/Makefile
 platform/linux-generic/test/pktio/Makefile
+platform/linux-generic/test/pktio_ipc/Makefile
 platform/linux-generic/test/ring/Makefile])
diff --git a/platform/linux-generic/test/Makefile.am 
b/platform/linux-generic/test/Makefile.am
index f81eeb8..6a05a54 100644
--- a/platform/linux-generic/test/Makefile.am
+++ b/platform/linux-generic/test/Makefile.am
@@ -1,11 +1,12 @@
  include $(top_srcdir)/test/Makefile.inc
  TESTS_ENVIRONMENT += TEST_DIR=${top_builddir}/test/validation
  
-ODP_MODULES = pktio ring

+ODP_MODULES = pktio pktio_ipc ring
  
  if test_vald

  TESTS = pktio/pktio_run \
pktio/pktio_run_tap \
+   pktio_ipc/pktio_ipc_run \
ring/ringtest$(EXEEXT) \
${top_builddir}/test/validation/buffer/buffer_main$(EXEEXT) \

${top_builddir}/test/validation/classification/classification_main$(EXEEXT) \
diff --git a/platform/linux-generic/test/pktio_ipc/.gitignore 
b/platform/linux-generic/test/pktio_ipc/.gitignore
new file mode 100644
index 000..49ee4fd
--- /dev/null
+++ b/platform/linux-generic/test/pktio_ipc/.gitignore
@@ -0,0 +1,2 @@
+pktio_ipc1
+pktio_ipc2
diff --git a/platform/linux-generic/test/pktio_ipc/Makefile.am 
b/platform/linux-generic/test/pktio_ipc/Makefile.am
new file mode 100644
index 000..bc224ae
--- /dev/null
+++ b/platform/linux-generic/test/pktio_ipc/Makefile.am
@@ -0,0 +1,20 @@
+include $(top_srcdir)/test/Makefile.inc
+TESTS_ENVIRONMENT += TEST_DIR=${top_builddir}/test/validation
+
+test_PROGRAMS = pktio_ipc1\
+   pktio_ipc2
+
+pktio_ipc1_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
+pktio_ipc1_LDFLAGS = $(AM_LDFLAGS) -static
+pktio_ipc2_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
+pktio_ipc2_LDFLAGS = $(AM_LDFLAGS) -static
+
+noinst_HEADERS = $(top_srcdir)/test/test_debug.h
+
+dist_pktio_ipc1_SOURCES = pktio_ipc1.c ipc_common.c
+dist_pktio_ipc2_SOURCES = pktio_ipc2.c ipc_common.c
+
+EXTRA_DIST = ipc_common.h
+
+dist_check_SCRIPTS = pktio_ipc_run
+test_SCRIPTS = $(dist_check_SCRIPTS)
diff --git a/platform/linux-generic/test/pktio_ipc/ipc_common.c 
b/platform/linux-generic/test/pktio_ipc/ipc_common.c
new file mode 100644
index 000..33775b0
--- /dev/null
+++ b/platform/linux-generic/test/pktio_ipc/ipc_common.c
@@ -0,0 +1,138 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All 

[lng-odp] [PATCH v5 API-NEXT 00/12] Separate CPU info codes into their platform files

2016-01-18 Thread hongbo . zhang
From: Hongbo Zhang 

v4->v5 changes:
 - rebase to latest api-next branch

v3->v4 changes:
 - update patch 9 of platform naming
 - add new patch 12 to rename cpu_hz to cpu_hz_max

v2->v3 changes:
use "api: cpu:" tag in patch 8/11 title instead of "linux-generic: sysinfo"

v1->v2 changes:
 - don't create arch/arm/ since there isn't implementation now, use arch/linux
as default choice
 - create symlink to arch/linux/odp_cpu_cycles.c for powerpc, if absent this
arch cannot be compiled
 - add some clean-ups patches 8~11, these patches are against the previous ones
so send them together for better review and merge.

v1 notes:
This patch set separates the CPU info codes into their own platform sepcific
files.
It is common sence that the top general layer call an uniform interface to
initialize some plarform specific data structures, and this uniform interface
is implemented in their own platform specific files.
This patch set makes it.

Hongbo Zhang (12):
  linux-generic: sysinfo: move cpu_arch_str to odp_system_info_t
  linux-generic: sysinfo: use uniform call odp_sysinfo_parser
  linux-generic: sysinfo: rename odp_cpu_hz_current with odp_ prefix
  linux-generic: sysinfo: move x86 system info codes to its plarform
file
  linux-generic: sysinfo: move MIPS system info codes to its plarform
file
  linux-generic: sysinfo: move ARM system info codes to default arch
file
  linux-generic: sysinfo: move PowerPC system info codes to its plarform
file
  api: cpu: make frequency API return 0 on failure
  linux-generic: sysinfo: set values for cpu_arch_str
  linux-generic: sysinfo: apply per-CPU implementation to MIPS
  linux-generic: sysinfo: apply per-CPU implementation to PowerPC
  linux-generic: sysinfo: rename variable cpu_hz to cpu_hz_max

 configure.ac   |   1 +
 include/odp/api/cpu.h  |   4 +
 platform/linux-generic/Makefile.am |  10 +-
 .../linux-generic/arch/linux/odp_sysinfo_parse.c   |  19 ++
 .../linux-generic/arch/mips64/odp_sysinfo_parse.c  |  62 ++
 platform/linux-generic/arch/powerpc/odp_cpu_arch.c |   1 +
 .../linux-generic/arch/powerpc/odp_sysinfo_parse.c |  62 ++
 .../linux-generic/arch/x86/odp_sysinfo_parse.c |  72 +++
 platform/linux-generic/include/odp_internal.h  |   7 +-
 platform/linux-generic/odp_system_info.c   | 220 +
 10 files changed, 241 insertions(+), 217 deletions(-)
 create mode 100644 platform/linux-generic/arch/linux/odp_sysinfo_parse.c
 create mode 100644 platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
 create mode 12 platform/linux-generic/arch/powerpc/odp_cpu_arch.c
 create mode 100644 platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
 create mode 100644 platform/linux-generic/arch/x86/odp_sysinfo_parse.c

-- 
2.1.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v5 API-NEXT 09/12] linux-generic: sysinfo: set values for cpu_arch_str

2016-01-18 Thread hongbo . zhang
From: Hongbo Zhang 

The values of cpu_arch_str were deleted due to codes reorganization, this
patch adds values to them again.

Signed-off-by: Hongbo Zhang 
---
 platform/linux-generic/arch/mips64/odp_sysinfo_parse.c  | 1 +
 platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c | 1 +
 platform/linux-generic/arch/x86/odp_sysinfo_parse.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
index fd3cb0a..bb1d5d8 100644
--- a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
@@ -15,6 +15,7 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
int model = 0;
int count = 2;
 
+   strcpy(sysinfo->cpu_arch_str, "mips64");
while (fgets(str, sizeof(str), file) != NULL && count > 0) {
if (!mhz) {
pos = strstr(str, "BogoMIPS");
diff --git a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
index c471a82..e221f10 100644
--- a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
@@ -15,6 +15,7 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
int model = 0;
int count = 2;
 
+   strcpy(sysinfo->cpu_arch_str, "powerpc");
while (fgets(str, sizeof(str), file) != NULL && count > 0) {
if (!mhz) {
pos = strstr(str, "clock");
diff --git a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
index 71c7c9f..aeb3d8f 100644
--- a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
@@ -14,6 +14,7 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
double ghz = 0.0;
int id = 0;
 
+   strcpy(sysinfo->cpu_arch_str, "x86");
while (fgets(str, sizeof(str), file) != NULL && id < MAX_CPU_NUMBER) {
pos = strstr(str, "model name");
if (pos) {
-- 
2.1.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v5 API-NEXT 08/12] api: cpu: make frequency API return 0 on failure

2016-01-18 Thread hongbo . zhang
From: Hongbo Zhang 

All the CPU frequency API return value type is uint64_t, this patch makes
them return 0 on failure instead of -1.

Signed-off-by: Hongbo Zhang 
---
 include/odp/api/cpu.h   | 4 
 platform/linux-generic/arch/linux/odp_sysinfo_parse.c   | 2 +-
 platform/linux-generic/arch/mips64/odp_sysinfo_parse.c  | 2 +-
 platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c | 2 +-
 platform/linux-generic/arch/x86/odp_sysinfo_parse.c | 2 +-
 platform/linux-generic/odp_system_info.c| 2 +-
 6 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/include/odp/api/cpu.h b/include/odp/api/cpu.h
index 4cbaf58..eaee24b 100644
--- a/include/odp/api/cpu.h
+++ b/include/odp/api/cpu.h
@@ -71,6 +71,7 @@ const char *odp_cpu_model_str_id(int id);
  * Returns current frequency of this CPU
  *
  * @return CPU frequency in Hz
+ * @retval 0 on failure
  */
 uint64_t odp_cpu_hz(void);
 
@@ -82,6 +83,7 @@ uint64_t odp_cpu_hz(void);
  * @param idCPU ID
  *
  * @return CPU frequency in Hz
+ * @retval 0 on failure
  */
 uint64_t odp_cpu_hz_id(int id);
 
@@ -91,6 +93,7 @@ uint64_t odp_cpu_hz_id(int id);
  * Returns maximum frequency of this CPU
  *
  * @return CPU frequency in Hz
+ * @retval 0 on failure
  */
 uint64_t odp_cpu_hz_max(void);
 
@@ -102,6 +105,7 @@ uint64_t odp_cpu_hz_max(void);
  * @param idCPU ID
  *
  * @return CPU frequency in Hz
+ * @retval 0 on failure
  */
 uint64_t odp_cpu_hz_max_id(int id);
 
diff --git a/platform/linux-generic/arch/linux/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/linux/odp_sysinfo_parse.c
index d8f36a4..cb5626e 100644
--- a/platform/linux-generic/arch/linux/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/linux/odp_sysinfo_parse.c
@@ -15,5 +15,5 @@ odp_system_info_t *sysinfo ODP_UNUSED)
 
 uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
 {
-   return -1;
+   return 0;
 }
diff --git a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
index cc75b96..fd3cb0a 100644
--- a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
@@ -49,5 +49,5 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
 
 uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
 {
-   return -1;
+   return 0;
 }
diff --git a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
index 3f8743c..c471a82 100644
--- a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
@@ -49,5 +49,5 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
 
 uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
 {
-   return -1;
+   return 0;
 }
diff --git a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
index 85cc34c..71c7c9f 100644
--- a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
@@ -66,5 +66,5 @@ uint64_t odp_cpu_hz_current(int id)
if (mhz)
return (uint64_t)(mhz * 100.0);
 
-   return -1;
+   return 0;
 }
diff --git a/platform/linux-generic/odp_system_info.c 
b/platform/linux-generic/odp_system_info.c
index 4ab17aa..c9cdcb4 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -233,7 +233,7 @@ uint64_t odp_cpu_hz_max_id(int id)
if (id >= 0 && id < MAX_CPU_NUMBER)
return odp_global_data.system_info.cpu_hz[id];
else
-   return -1;
+   return 0;
 }
 
 uint64_t odp_sys_huge_page_size(void)
-- 
2.1.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v5 API-NEXT 10/12] linux-generic: sysinfo: apply per-CPU implementation to MIPS

2016-01-18 Thread hongbo . zhang
From: Hongbo Zhang 

When per-CPU framework was introduced, it was only implemented on x86,
for other platforms, only the model_str[0] and cpu_hz[0] are set to pass
compile, this patch set all values for model_str[] and cpu_hz[] on the
MIPS platform.

Signed-off-by: Hongbo Zhang 
---
 .../linux-generic/arch/mips64/odp_sysinfo_parse.c  | 24 ++
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
index bb1d5d8..88c2066 100644
--- a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
@@ -14,14 +14,18 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t 
*sysinfo)
double mhz = 0.0;
int model = 0;
int count = 2;
+   int id = 0;
 
strcpy(sysinfo->cpu_arch_str, "mips64");
-   while (fgets(str, sizeof(str), file) != NULL && count > 0) {
+   while (fgets(str, sizeof(str), file) != NULL && id < MAX_CPU_NUMBER) {
if (!mhz) {
pos = strstr(str, "BogoMIPS");
 
if (pos) {
sscanf(pos, "BogoMIPS : %lf", );
+   /* bogomips seems to be 2x freq */
+   sysinfo->cpu_hz[id] = \
+   (uint64_t)(mhz * 100.0 / 2.0);
count--;
}
}
@@ -32,18 +36,22 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t 
*sysinfo)
if (pos) {
int len;
pos = strchr(str, ':');
-   strncpy(sysinfo->model_str[0], pos + 2,
-   sizeof(sysinfo->model_str[0]));
-   len = strlen(sysinfo->model_str[0]);
-   sysinfo->model_str[0][len - 1] = 0;
+   strncpy(sysinfo->model_str[id], pos + 2,
+   sizeof(sysinfo->model_str[id]));
+   len = strlen(sysinfo->model_str[id]);
+   sysinfo->model_str[id][len - 1] = 0;
model = 1;
count--;
}
}
-   }
 
-   /* bogomips seems to be 2x freq */
-   sysinfo->cpu_hz[0] = (uint64_t)(mhz * 100.0 / 2.0);
+   if (count == 0) {
+   mhz = 0.0;
+   model = 0;
+   count = 2;
+   id++;
+   }
+   }
 
return 0;
 }
-- 
2.1.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH] validation: pktio: fix check of pktio_stop() called twice

2016-01-18 Thread Ivan Khoronzhuk

ping

On 13.01.16 19:38, Ivan Khoronzhuk wrote:

The odp_pktio_stop() called is supposed to return error.

Signed-off-by: Ivan Khoronzhuk 
---
  test/validation/pktio/pktio.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index 29ad4ea..1ca4979 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -737,7 +737,7 @@ void pktio_test_start_stop(void)
/* Interfaces are stopped by default,
 * Check that stop when stopped generates an error */
ret = odp_pktio_stop(pktio[0]);
-   CU_ASSERT(ret <= 0);
+   CU_ASSERT(ret < 0);

/* start first */
ret = odp_pktio_start(pktio[0]);



--
Regards,
Ivan Khoronzhuk
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH] validation: pktio: use odp_time_ns() instead own function

2016-01-18 Thread Ivan Khoronzhuk

ping

On 13.01.16 19:18, Ivan Khoronzhuk wrote:

Now odp_time_wait_ns() can be used.

Signed-off-by: Ivan Khoronzhuk 
---
  test/validation/pktio/pktio.c | 13 +
  1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index 45c11c5..29ad4ea 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -259,17 +259,6 @@ static int default_pool_create(void)
return 0;
  }

-static void spin_wait(uint64_t ns)
-{
-   odp_time_t start, now, diff;
-
-   start = odp_time_local();
-   do {
-   now = odp_time_local();
-   diff = odp_time_diff(now, start);
-   } while (odp_time_to_ns(diff) < ns);
-}
-
  static odp_pktio_t create_pktio(int iface_idx, odp_pktio_input_mode_t imode,
odp_pktio_output_mode_t omode)
  {
@@ -294,7 +283,7 @@ static odp_pktio_t create_pktio(int iface_idx, 
odp_pktio_input_mode_t imode,
odp_pktio_print(pktio);

if (wait_for_network)
-   spin_wait(ODP_TIME_SEC_IN_NS / 4);
+   odp_time_wait_ns(ODP_TIME_SEC_IN_NS / 4);

return pktio;
  }



--
Regards,
Ivan Khoronzhuk
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH] validation: pktio: assign MAC address if one loop pktio is used

2016-01-18 Thread Ivan Khoronzhuk

ping

On 14.01.16 12:56, Ivan Khoronzhuk wrote:

In case of one loop pktio the MAC address is not set in the packets
but should be.

Signed-off-by: Ivan Khoronzhuk 
---
  test/validation/pktio/pktio.c | 18 ++
  1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index 536ef6c..a756af4 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -830,11 +830,21 @@ void pktio_test_start_stop(void)
pktio_init_packet(pkt);
if (num_ifaces > 1) {
pktio_pkt_set_macs(pkt, pktio[0], pktio[1]);
-   if (pktio_fixup_checksums(pkt) != 0) {
-   odp_packet_free(pkt);
-   break;
-   }
+   } else {
+   uint32_t len;
+   odph_ethhdr_t *eth;
+
+   eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, );
+   ret = odp_pktio_mac_addr(pktio[0],
+>dst, sizeof(eth->dst));
+   CU_ASSERT(ret == ODPH_ETHADDR_LEN);
}
+
+   if (pktio_fixup_checksums(pkt) != 0) {
+   odp_packet_free(pkt);
+   break;
+   }
+
tx_ev[alloc] = odp_packet_to_event(pkt);
}




--
Regards,
Ivan Khoronzhuk
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH] validation: pktio: don't continue if packet with > MTU is sent

2016-01-18 Thread Ivan Khoronzhuk

ping

On 15.01.16 17:55, Stuart Haslam wrote:

On Fri, Jan 15, 2016 at 05:53:20PM +0200, Ivan Khoronzhuk wrote:



On 15.01.16 17:51, Stuart Haslam wrote:

On Wed, Jan 13, 2016 at 06:46:57PM +0200, Ivan Khoronzhuk wrote:

If packet with size > MTU is sent the test can crash farther,
so better to stop here.

Signed-off-by: Ivan Khoronzhuk 


Signed-off-by: Stuart Haslam 

Reviewed-by?


Err, yup, wrong macro, I meant..

Reviewed-by: Stuart Haslam 


---
  test/validation/pktio/pktio.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index 8121f1e..45c11c5 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -968,7 +968,7 @@ void pktio_test_send_failure(void)
 * the initial short packets should be sent successfully */
odp_errno_zero();
ret = odp_pktio_send(pktio_tx, pkt_tbl, TX_BATCH_LEN);
-   CU_ASSERT(ret == long_pkt_idx);
+   CU_ASSERT_FATAL(ret == long_pkt_idx);
CU_ASSERT(odp_errno() == 0);

info_rx.id   = pktio_rx;
--
1.9.1



--
Regards,
Ivan Khoronzhuk




--
Regards,
Ivan Khoronzhuk
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [API-NEXT PATCH v3 0/6] Multi-queue pktio for poll mode

2016-01-18 Thread Stuart Haslam
On Mon, Jan 18, 2016 at 05:58:37PM +0300, Maxim Uvarov wrote:
> Stuart, can you please review this?
> 
> Maxim.

I've just run it through the validation tests and all seems well, I've
have a closer look at the changes tomorrow.

-- 
Stuart.
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH] validation: pktio: don't continue if packet with > MTU is sent

2016-01-18 Thread Maxim Uvarov

merged.
Maxim.

On 01/18/2016 20:54, Ivan Khoronzhuk wrote:

ping

On 15.01.16 17:55, Stuart Haslam wrote:

On Fri, Jan 15, 2016 at 05:53:20PM +0200, Ivan Khoronzhuk wrote:



On 15.01.16 17:51, Stuart Haslam wrote:

On Wed, Jan 13, 2016 at 06:46:57PM +0200, Ivan Khoronzhuk wrote:

If packet with size > MTU is sent the test can crash farther,
so better to stop here.

Signed-off-by: Ivan Khoronzhuk 


Signed-off-by: Stuart Haslam 

Reviewed-by?


Err, yup, wrong macro, I meant..

Reviewed-by: Stuart Haslam 


---
  test/validation/pktio/pktio.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/validation/pktio/pktio.c 
b/test/validation/pktio/pktio.c

index 8121f1e..45c11c5 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -968,7 +968,7 @@ void pktio_test_send_failure(void)
   * the initial short packets should be sent successfully */
  odp_errno_zero();
  ret = odp_pktio_send(pktio_tx, pkt_tbl, TX_BATCH_LEN);
-CU_ASSERT(ret == long_pkt_idx);
+CU_ASSERT_FATAL(ret == long_pkt_idx);
  CU_ASSERT(odp_errno() == 0);

  info_rx.id   = pktio_rx;
--
1.9.1



--
Regards,
Ivan Khoronzhuk






___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCHv19 9/9] linux-generic: internal ipc_pktio test

2016-01-18 Thread Maxim Uvarov

On 01/18/2016 19:10, Ivan Khoronzhuk wrote:

+int ipc_odp_packet_sendall(odp_pktio_t pktio,
+   odp_packet_t pkt_tbl[], int num)
+{
+int ret;
+int sent = 0;
+uint64_t start_cycle;
+uint64_t diff;
+uint64_t wait;
+
+wait = odp_time_local_from_ns(1 * ODP_TIME_SEC_IN_NS);
+start_cycle = odp_time_local();

1. cycle word should be avoided here.
2. 1 * can be removed
3. here better to use the following approach:

start = odp_time_local();
wait = odp_time_local_from_ns(ODP_TIME_SEC_IN_NS);
end_time = odp_time_sum(start, wait);
while (sent != num) {
...
if (odp_time_cmp(end, odp_time_local()) < 0)
return -1;
}



Ok, thanks.

Maxim.

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v5 API-NEXT 00/12] Separate CPU info codes into their platform files

2016-01-18 Thread Maxim Uvarov

please run ./scripts/checkpatch.pl
on patches, some of them have errors.

Maxim.

On 01/18/2016 13:09, hongbo.zh...@linaro.org wrote:

From: Hongbo Zhang 

v4->v5 changes:
  - rebase to latest api-next branch

v3->v4 changes:
  - update patch 9 of platform naming
  - add new patch 12 to rename cpu_hz to cpu_hz_max

v2->v3 changes:
use "api: cpu:" tag in patch 8/11 title instead of "linux-generic: sysinfo"

v1->v2 changes:
  - don't create arch/arm/ since there isn't implementation now, use arch/linux
as default choice
  - create symlink to arch/linux/odp_cpu_cycles.c for powerpc, if absent this
arch cannot be compiled
  - add some clean-ups patches 8~11, these patches are against the previous ones
so send them together for better review and merge.

v1 notes:
This patch set separates the CPU info codes into their own platform sepcific
files.
It is common sence that the top general layer call an uniform interface to
initialize some plarform specific data structures, and this uniform interface
is implemented in their own platform specific files.
This patch set makes it.

Hongbo Zhang (12):
   linux-generic: sysinfo: move cpu_arch_str to odp_system_info_t
   linux-generic: sysinfo: use uniform call odp_sysinfo_parser
   linux-generic: sysinfo: rename odp_cpu_hz_current with odp_ prefix
   linux-generic: sysinfo: move x86 system info codes to its plarform
 file
   linux-generic: sysinfo: move MIPS system info codes to its plarform
 file
   linux-generic: sysinfo: move ARM system info codes to default arch
 file
   linux-generic: sysinfo: move PowerPC system info codes to its plarform
 file
   api: cpu: make frequency API return 0 on failure
   linux-generic: sysinfo: set values for cpu_arch_str
   linux-generic: sysinfo: apply per-CPU implementation to MIPS
   linux-generic: sysinfo: apply per-CPU implementation to PowerPC
   linux-generic: sysinfo: rename variable cpu_hz to cpu_hz_max

  configure.ac   |   1 +
  include/odp/api/cpu.h  |   4 +
  platform/linux-generic/Makefile.am |  10 +-
  .../linux-generic/arch/linux/odp_sysinfo_parse.c   |  19 ++
  .../linux-generic/arch/mips64/odp_sysinfo_parse.c  |  62 ++
  platform/linux-generic/arch/powerpc/odp_cpu_arch.c |   1 +
  .../linux-generic/arch/powerpc/odp_sysinfo_parse.c |  62 ++
  .../linux-generic/arch/x86/odp_sysinfo_parse.c |  72 +++
  platform/linux-generic/include/odp_internal.h  |   7 +-
  platform/linux-generic/odp_system_info.c   | 220 +
  10 files changed, 241 insertions(+), 217 deletions(-)
  create mode 100644 platform/linux-generic/arch/linux/odp_sysinfo_parse.c
  create mode 100644 platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
  create mode 12 platform/linux-generic/arch/powerpc/odp_cpu_arch.c
  create mode 100644 platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
  create mode 100644 platform/linux-generic/arch/x86/odp_sysinfo_parse.c



___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v5] validation: system: add validation tests for odp_cpu_cycles_* calls

2016-01-18 Thread Savolainen, Petri (Nokia - FI/Espoo)


> -Original Message-
> From: EXT Ivan Khoronzhuk [mailto:ivan.khoronz...@linaro.org]
> Sent: Friday, January 15, 2016 5:07 PM
> To: lng-odp@lists.linaro.org
> Cc: Savolainen, Petri (Nokia - FI/Espoo); Ivan Khoronzhuk
> Subject: [lng-odp] [PATCH v5] validation: system: add validation tests for
> odp_cpu_cycles_* calls
> 
> https://bugs.linaro.org/show_bug.cgi?id=1906
> 
> Signed-off-by: Ivan Khoronzhuk 
> ---
>  test/validation/system/system.c | 130
> 
>  test/validation/system/system.h |   4 ++
>  2 files changed, 134 insertions(+)
> 
> diff --git a/test/validation/system/system.c
> b/test/validation/system/system.c
> index 7dc2cc0..f59c570 100644
> --- a/test/validation/system/system.c
> +++ b/test/validation/system/system.c
> @@ -10,6 +10,9 @@
>  #include "test_debug.h"
>  #include "system.h"
> 
> +#define DIFF_TRY_NUM 160
> +#define RES_TRY_NUM  10
> +
>  void system_test_odp_version_numbers(void)
>  {
>   int char_ok = 0;
> @@ -40,6 +43,129 @@ void system_test_odp_cpu_count(void)
>   CU_ASSERT(0 < cpus);
>  }
> 
> +void system_test_odp_cpu_cycles(void)
> +{
> + uint64_t c2, c1;
> +
> + c1 = odp_cpu_cycles();
> + odp_time_wait_ns(100);
> + c2 = odp_cpu_cycles();
> +
> + CU_ASSERT(c2 != c1);
> +}
> +
> +void system_test_odp_cpu_cycles_max(void)
> +{
> + uint64_t c2, c1;
> + uint64_t max1, max2;
> +
> + max1 = odp_cpu_cycles_max();
> + odp_time_wait_ns(100);
> + max2 = odp_cpu_cycles_max();
> +
> + CU_ASSERT(max1 >= UINT32_MAX / 2);
> + CU_ASSERT(max1 == max2);
> +
> + c1 = odp_cpu_cycles();
> + odp_time_wait_ns(1000);
> + c2 = odp_cpu_cycles();
> +
> + CU_ASSERT(c1 <= max1 && c2 <= max1);
> +}
> +
> +void system_test_odp_cpu_cycles_diff(void)
> +{
> + int i;
> + uint64_t c2, c1, c3;
> + uint64_t tmp, diff;
> +
> + c2 = 100;
> + c1 = 39;
> +
> + diff = odp_cpu_cycles_diff(c2, c2);
> + CU_ASSERT(diff == 0);
> +
> + tmp = c2 - c1;
> + diff = odp_cpu_cycles_diff(c2, c1);
> + CU_ASSERT(diff == tmp);
> +
> + tmp = c1 + (odp_cpu_cycles_max() - c2) + 1;


As noted before, '+1' in the equation holds only if resolution is 1. The 
equation should be:

diff = c2 + (odp_cpu_cycles_max() - c1) + odp_cpu_cycles_resolution();

It would be also more readable if c1 is always the first sample and c2 the 
second (c1 = 100, c2 = 39 in this test case).


Max: 90
Res: 10
Valid values: 0, 10, 20, ..., 80, 90

c1 = 90
 
c2 = 0

   c2   max  c1   res
diff = 0 + (90 - 90) + 10 = 10


-Petri


> + diff = odp_cpu_cycles_diff(c1, c2);
> + CU_ASSERT(diff == tmp);
> +
> + c3 = odp_cpu_cycles();
> +
> + /* must handle one wrap */
> + for (i = 0; i < DIFF_TRY_NUM; i++) {
> + c1 = odp_cpu_cycles();
> + odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
> + c2 = odp_cpu_cycles();
> +
> + CU_ASSERT(c2 != c1);
> +
> + if (c2 > c1)
> + tmp = c2 - c1;
> + else
> + tmp = c2 + (odp_cpu_cycles_max() - c1) + 1;
> +
> + diff = odp_cpu_cycles_diff(c2, c1);
> + CU_ASSERT(diff == tmp);
> +
> + /* wrap is detected and verified */
> + if (c2 < c1)
> + break;
> + }
> +
> + /* wrap was detected, no need to continue */
> + if (i < DIFF_TRY_NUM)
> + return;
> +
> + CU_ASSERT(odp_cpu_cycles_max() > UINT32_MAX);
> + CU_ASSERT((odp_cpu_cycles_max() - c3) > UINT32_MAX);
> +
> + printf("wrap was not detected...");
> +}
> +
> +void system_test_odp_cpu_cycles_resolution(void)
> +{
> + int i;
> + uint64_t rest;
> + uint64_t res, diff;
> + uint64_t c2, c1, max;
> +
> + max = odp_cpu_cycles_max();
> +
> + res = odp_cpu_cycles_resolution();
> + CU_ASSERT(res != 0);
> + CU_ASSERT(res < max / 1024);
> +
> + /* check resolution for wrap */
> + c1 = max - 2 * res;
> + do
> + c2 = odp_cpu_cycles();
> + while (c1 < c2);
> +
> + diff = odp_cpu_cycles_diff(c1, c2);
> + rest = diff % res;
> + CU_ASSERT(rest == 0);
> +
> + for (i = 0; i < RES_TRY_NUM; i++) {
> + c1 = odp_cpu_cycles();
> + odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
> + c2 = odp_cpu_cycles();
> +
> + diff = odp_cpu_cycles_diff(c2, c1);
> + rest = diff % res;
> + CU_ASSERT(rest == 0);
> +
> + rest = c1 % res;
> + CU_ASSERT(rest == 0);
> +
> + rest = c2 % res;
> + CU_ASSERT(rest == 0);
> + }
> +}
> +
>  void system_test_odp_sys_cache_line_size(void)
>  {
>   uint64_t cache_size;
> @@ -91,6 +217,10 @@ odp_testinfo_t system_suite[] = {
>   ODP_TEST_INFO(system_test_odp_sys_page_size),
>   ODP_TEST_INFO(system_test_odp_sys_huge_page_size),
>   

Re: [lng-odp] [PATCH API-NEXT] api: pktio: remove unused ODP_PKTIO_ANY

2016-01-18 Thread Maxim Uvarov

Merged.
Maxim.

On 01/18/2016 12:04, Savolainen, Petri (Nokia - FI/Espoo) wrote:

Reviewed-by: Petri Savolainen 



-Original Message-
From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT
Stuart Haslam
Sent: Friday, January 15, 2016 5:18 PM
To: lng-odp@lists.linaro.org
Subject: [lng-odp] [PATCH API-NEXT] api: pktio: remove unused
ODP_PKTIO_ANY

ODP_PKTIO_ANY is defined in the API header but there's no description of
its intended use and it wouldn't make sense to pass it to the majority
of exisitng APIs that take odp_pktio_t handles.

It's not currently used anywhere, so remove it.

Signed-off-by: Stuart Haslam 
---
  include/odp/api/packet_io.h   | 5 -
  platform/linux-generic/include/odp/plat/packet_io_types.h | 2 --
  2 files changed, 7 deletions(-)

diff --git a/include/odp/api/packet_io.h b/include/odp/api/packet_io.h
index a0a2c12..4971108 100644
--- a/include/odp/api/packet_io.h
+++ b/include/odp/api/packet_io.h
@@ -58,11 +58,6 @@ extern "C" {
   */

  /**
- * @def ODP_PKTIO_ANY
- * odp_pktio_t value to indicate any port
- */
-
-/**
   * @def ODP_PKTIO_MACADDR_MAXSIZE
   * Minimum size of output buffer for odp_pktio_mac_addr()
   * Actual MAC address sizes may be different.
diff --git a/platform/linux-generic/include/odp/plat/packet_io_types.h
b/platform/linux-generic/include/odp/plat/packet_io_types.h
index 25f7151..934d7de 100644
--- a/platform/linux-generic/include/odp/plat/packet_io_types.h
+++ b/platform/linux-generic/include/odp/plat/packet_io_types.h
@@ -42,8 +42,6 @@ typedef struct odp_pktout_queue_t {

  #define ODP_PKTIO_INVALID _odp_cast_scalar(odp_pktio_t, 0)

-#define ODP_PKTIO_ANY _odp_cast_scalar(odp_pktio_t, ~0)
-
  #define ODP_PKTIO_MACADDR_MAXSIZE 16

  /** Get printable format of odp_pktio_t */
--
2.1.1

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [API-NEXT PATCH v2 0/3] validation: cls: correct tests a little

2016-01-18 Thread Bala Manoharan
For the series:
Reviewed-by: Balasubramanian Manoharan 
Regards,
Bala


On 15 January 2016 at 22:58, Ivan Khoronzhuk  wrote:
> This patch series corrects classification tests to be a little bit
> adoptive.
>
> Since v1:
> - removed patch for deleting input queue, as it should be discussed first
> - removed patch for splitting, as new tests are supposed to be added
> - rebased on api-next to meet new requirements
> - assigned MAC address for every tests separately
>
> Ivan Khoronzhuk (3):
>   validation: cls: adopt for supported l3 PMR
>   validation: cls: assign default CoS before creating chain
>   validation: cls: use correct MAC addresses
>
>  test/validation/classification/classification.h|   6 +-
>  .../classification/odp_classification_basic.c  |   4 +-
>  .../classification/odp_classification_common.c |  52 ++
>  .../classification/odp_classification_test_pmr.c   | 108 
> +
>  .../classification/odp_classification_tests.c  |  25 ++---
>  .../classification/odp_classification_testsuites.h |   2 +
>  6 files changed, 156 insertions(+), 41 deletions(-)
>
> --
> 1.9.1
>
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v5] validation: system: add validation tests for odp_cpu_cycles_* calls

2016-01-18 Thread Ivan Khoronzhuk



On 18.01.16 13:37, Savolainen, Petri (Nokia - FI/Espoo) wrote:




-Original Message-
From: EXT Ivan Khoronzhuk [mailto:ivan.khoronz...@linaro.org]
Sent: Friday, January 15, 2016 5:07 PM
To: lng-odp@lists.linaro.org
Cc: Savolainen, Petri (Nokia - FI/Espoo); Ivan Khoronzhuk
Subject: [lng-odp] [PATCH v5] validation: system: add validation tests for
odp_cpu_cycles_* calls

https://bugs.linaro.org/show_bug.cgi?id=1906

Signed-off-by: Ivan Khoronzhuk 
---
  test/validation/system/system.c | 130

  test/validation/system/system.h |   4 ++
  2 files changed, 134 insertions(+)

diff --git a/test/validation/system/system.c
b/test/validation/system/system.c
index 7dc2cc0..f59c570 100644
--- a/test/validation/system/system.c
+++ b/test/validation/system/system.c
@@ -10,6 +10,9 @@
  #include "test_debug.h"
  #include "system.h"

+#define DIFF_TRY_NUM   160
+#define RES_TRY_NUM10
+
  void system_test_odp_version_numbers(void)
  {
int char_ok = 0;
@@ -40,6 +43,129 @@ void system_test_odp_cpu_count(void)
CU_ASSERT(0 < cpus);
  }

+void system_test_odp_cpu_cycles(void)
+{
+   uint64_t c2, c1;
+
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(100);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c2 != c1);
+}
+
+void system_test_odp_cpu_cycles_max(void)
+{
+   uint64_t c2, c1;
+   uint64_t max1, max2;
+
+   max1 = odp_cpu_cycles_max();
+   odp_time_wait_ns(100);
+   max2 = odp_cpu_cycles_max();
+
+   CU_ASSERT(max1 >= UINT32_MAX / 2);
+   CU_ASSERT(max1 == max2);
+
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(1000);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c1 <= max1 && c2 <= max1);
+}
+
+void system_test_odp_cpu_cycles_diff(void)
+{
+   int i;
+   uint64_t c2, c1, c3;
+   uint64_t tmp, diff;
+
+   c2 = 100;
+   c1 = 39;
+
+   diff = odp_cpu_cycles_diff(c2, c2);
+   CU_ASSERT(diff == 0);
+
+   tmp = c2 - c1;
+   diff = odp_cpu_cycles_diff(c2, c1);
+   CU_ASSERT(diff == tmp);
+
+   tmp = c1 + (odp_cpu_cycles_max() - c2) + 1;



As noted before, '+1' in the equation holds only if resolution is 1. The 
equation should be:

diff = c2 + (odp_cpu_cycles_max() - c1) + odp_cpu_cycles_resolution();

It would be also more readable if c1 is always the first sample and c2 the 
second (c1 = 100, c2 = 39 in this test case).

In one case it's used directly in other in reverse order, no see reason to 
assign it once again.
And I'll delete it at all and use the following instead:

/* check resolution for wrap */
c1 = max - 2 * res;
do
c2 = odp_cpu_cycles();
while (c2 < c1);

and use it for different cases:

diff = odp_cpu_cycles_diff(c1, c1);
CU_ASSERT(diff == 0);

tmp = c2 - c1;
// here c1 is supposed to be after c2, but in order to not read this values 
again...
diff = odp_cpu_cycles_diff(c2, c1);
CU_ASSERT(diff == tmp);
rest = diff % res;
CU_ASSERT(rest == 0);

tmp = c1 + (odp_cpu_cycles_max() - c2) + res;
diff = odp_cpu_cycles_diff(c1, c2);
CU_ASSERT(diff == tmp);
rest = diff % res;
CU_ASSERT(rest == 0);




Max: 90
Res: 10
Valid values: 0, 10, 20, ..., 80, 90

c1 = 90

c2 = 0

c2   max  c1   res
diff = 0 + (90 - 90) + 10 = 10


-Petri



+   diff = odp_cpu_cycles_diff(c1, c2);
+   CU_ASSERT(diff == tmp);
+
+   c3 = odp_cpu_cycles();
+
+   /* must handle one wrap */
+   for (i = 0; i < DIFF_TRY_NUM; i++) {
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c2 != c1);
+
+   if (c2 > c1)
+   tmp = c2 - c1;
+   else
+   tmp = c2 + (odp_cpu_cycles_max() - c1) + 1;
+
+   diff = odp_cpu_cycles_diff(c2, c1);
+   CU_ASSERT(diff == tmp);
+
+   /* wrap is detected and verified */
+   if (c2 < c1)
+   break;
+   }
+
+   /* wrap was detected, no need to continue */
+   if (i < DIFF_TRY_NUM)
+   return;
+
+   CU_ASSERT(odp_cpu_cycles_max() > UINT32_MAX);
+   CU_ASSERT((odp_cpu_cycles_max() - c3) > UINT32_MAX);
+
+   printf("wrap was not detected...");
+}
+
+void system_test_odp_cpu_cycles_resolution(void)


For this function I'll delete diff at all and move the test before diff test.


+{
+   int i;
+   uint64_t rest;
+   uint64_t res, diff;
+   uint64_t c2, c1, max;
+
+   max = odp_cpu_cycles_max();
+
+   res = odp_cpu_cycles_resolution();
+   CU_ASSERT(res != 0);
+   CU_ASSERT(res < max / 1024);
+
+   /* check resolution for wrap */
+   c1 = max - 2 * res;
+   do
+   c2 = odp_cpu_cycles();
+   while 

Re: [lng-odp] [API-NEXT PATCH 00/13] atomi api completion

2016-01-18 Thread Ola Liljedahl
On 8 January 2016 at 14:41, Petri Savolainen 
wrote:

> Completed additions to atomic API. Added exchange operation in relaxed
> memory
> model. Added CAS operations in rel and acq_rel memory order. Added 64 bit
> versions of all non-relaxed operations defined so far. Added all missing
> validation tests. Replaced internal atomics usage in lock, etc code
> (all except spinlock and timer) with API calls.
>
> This set of atomic calls seem to be sufficient to current linux-generic use
> cases. Timer and spinlock use atomic flag and 128 bit types, but does not
> require additional operation types (e.g. load_acq, store_rel, cas,
> cas_rel, etc
> are supported by the API).
>
> Additional operations can be added later if needed. Only commonly needed
> combinations of non-relaxed operations will be supported (added based on
> use
> case as any other ODP API). This set should already enable major part of
> lock-free algorithms.
>
>
> Petri Savolainen (13):
>   api: atomic: rename release ordering
>   api: atomic: added 32bit cas_rel and cas_acq_rel
>   linux-generic: atomic: 32bit cas_rel and cas_acq_rel
>   api: atomic: add non-relaxed 64bit operations
>   linux-generic: atomic: non-relaxed 64bit operations
>   api: atomic: added relaxed exchange operation
>   linux-generic: atomic: implemented exchange
>   validation: atomic: added max and min tests
>   validation: atomic: added cas test
>   validation: atomic: added xchg test
>   validation: atomic: added non-relaxed test
>   linux-generic: locks: replace internal atomics
>
This patch (http://patches.opendataplane.org/patch/4443/) fails to apply.
Applying: linux-generic: locks: replace internal atomics
error: patch failed: platform/linux-generic/odp_rwlock.c:6
error: platform/linux-generic/odp_rwlock.c: patch does not apply
error: patch failed: platform/linux-generic/odp_ticketlock.c:6
error: platform/linux-generic/odp_ticketlock.c: patch does not apply
Patch failed at 0012 linux-generic: locks: replace internal atomics

Probably because API-NEXT already has merged the earlier cpu_pause patch
set while the context of this patch still refers to  odp_spin().

  linux-generic: barrier: use API memory barrier
>
Same for this patch.

I could revert my local copy of API-NEXT to some suitable version (from the
time of this atomics patch set) but will the patches apply to API-NEXT when
we try to merge them? Perhaps we need a rebased version (of the last two
patches).



>  include/odp/api/atomic.h   | 220 --
>  platform/linux-generic/include/odp/atomic.h| 142 -
>  .../linux-generic/include/odp_atomic_internal.h|   6 -
>  platform/linux-generic/include/odp_pool_internal.h |   1 -
>  platform/linux-generic/odp_barrier.c   |   7 +-
>  platform/linux-generic/odp_pool.c  |   1 -
>  platform/linux-generic/odp_rwlock.c|  23 +-
>  platform/linux-generic/odp_ticketlock.c|  21 +-
>  test/validation/synchronizers/synchronizers.c  | 330
> -
>  test/validation/synchronizers/synchronizers.h  |   4 +
>  10 files changed, 671 insertions(+), 84 deletions(-)
>
> --
> 2.6.3
>
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v5 API-NEXT 04/12] linux-generic: sysinfo: move x86 system info codes to its plarform file

2016-01-18 Thread Maxim Uvarov

WARNING: line over 80 characters
#73: FILE: platform/linux-generic/arch/x86/odp_sysinfo_parse.c:27:
+sysinfo->cpu_hz[id] = (uint64_t)(ghz * 10.0);


On 01/18/2016 13:10, hongbo.zh...@linaro.org wrote:

From: Hongbo Zhang 

This patch moves the x86 system info codes into the newly added x86
specific platform file.

Signed-off-by: Hongbo Zhang 
---
  platform/linux-generic/Makefile.am |  6 +-
  .../linux-generic/arch/x86/odp_sysinfo_parse.c | 70 ++
  platform/linux-generic/include/odp_internal.h  |  4 ++
  platform/linux-generic/odp_system_info.c   | 68 +
  4 files changed, 79 insertions(+), 69 deletions(-)
  create mode 100644 platform/linux-generic/arch/x86/odp_sysinfo_parse.c

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 9fbb3bd..de43eff 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -159,12 +159,14 @@ __LIB__libodp_la_SOURCES = \
   odp_traffic_mngr.c \
   odp_version.c \
   odp_weak.c \
-  arch/@ARCH@/odp_cpu_arch.c
+  arch/@ARCH@/odp_cpu_arch.c \
+  arch/@ARCH@/odp_sysinfo_parse.c
  
  EXTRA_DIST = \

 arch/linux/odp_cpu_arch.c \
 arch/mips64/odp_cpu_arch.c \
-arch/x86/odp_cpu_arch.c
+arch/x86/odp_cpu_arch.c \
+arch/x86/odp_sysinfo_parse.c
  
  if HAVE_PCAP

  __LIB__libodp_la_SOURCES += pktio/pcap.c
diff --git a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c 
b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
new file mode 100644
index 000..85cc34c
--- /dev/null
+++ b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
@@ -0,0 +1,70 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include 
+#include 
+
+int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
+{
+   char str[1024];
+   char *pos;
+   double ghz = 0.0;
+   int id = 0;
+
+   while (fgets(str, sizeof(str), file) != NULL && id < MAX_CPU_NUMBER) {
+   pos = strstr(str, "model name");
+   if (pos) {
+   pos = strchr(str, ':');
+   strncpy(sysinfo->model_str[id], pos + 2,
+   sizeof(sysinfo->model_str[id]));
+
+   pos = strchr(sysinfo->model_str[id], '@');
+   *(pos - 1) = '\0';
+   if (sscanf(pos, "@ %lfGHz", ) == 1)
+   sysinfo->cpu_hz[id] = (uint64_t)(ghz * 
10.0);
+
+   id++;
+   }
+   }
+
+   return 0;
+}
+
+uint64_t odp_cpu_hz_current(int id)
+{
+   char str[1024];
+   FILE *file;
+   int cpu;
+   char *pos;
+   double mhz = 0.0;
+
+   file = fopen("/proc/cpuinfo", "rt");
+
+   /* find the correct processor instance */
+   while (fgets(str, sizeof(str), file) != NULL) {
+   pos = strstr(str, "processor");
+   if (pos) {
+   if (sscanf(pos, "processor : %d", ) == 1)
+   if (cpu == id)
+   break;
+   }
+   }
+
+   /* extract the cpu current speed */
+   while (fgets(str, sizeof(str), file) != NULL) {
+   pos = strstr(str, "cpu MHz");
+   if (pos) {
+   if (sscanf(pos, "cpu MHz : %lf", ) == 1)
+   break;
+   }
+   }
+
+   fclose(file);
+   if (mhz)
+   return (uint64_t)(mhz * 100.0);
+
+   return -1;
+}
diff --git a/platform/linux-generic/include/odp_internal.h 
b/platform/linux-generic/include/odp_internal.h
index 2eeba42..d3cde5f 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -20,6 +20,7 @@ extern "C" {
  
  #include 

  #include 
+#include 
  
  extern __thread int __odp_errno;
  
@@ -86,6 +87,9 @@ int odp_tm_init_global(void);
  
  void _odp_flush_caches(void);
  
+int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo);

+uint64_t odp_cpu_hz_current(int id);
+
  #ifdef __cplusplus
  }
  #endif
diff --git a/platform/linux-generic/odp_system_info.c 
b/platform/linux-generic/odp_system_info.c
index 449e500..4824d55 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -108,71 +108,7 @@ static int huge_page_size(void)
  /*
   * HW specific /proc/cpuinfo file parsing
   */
-#if defined __x86_64__ || defined __i386__
-
-static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
-{
-   char str[1024];
-   char *pos;
-   double ghz = 0.0;
-   int 

Re: [lng-odp] [PATCHv19 9/9] linux-generic: internal ipc_pktio test

2016-01-18 Thread Ivan Khoronzhuk



On 18.01.16 11:59, Maxim Uvarov wrote:

On 01/15/2016 15:57, Stuart Haslam wrote:

On Mon, Dec 21, 2015 at 01:56:11PM +0300, Maxim Uvarov wrote:

2 example ipc pktio applications create ipc pktio to each other and do
packet transfer, validation magic numbers and packets sequence counters
inside it.


It looks like there's a race somewhere as I get occasional failures:

#2  0x004138b9 in odp_override_abort () at odp_weak.c:40
#3  0x00407431 in _ipc_map_remote_pool (
 name=name@entry=0x7fad1cb48020 ,
 size=1310720) at pktio/ipc.c:265
#4  0x0040845c in _ipc_slave_start (pktio_entry=0x7fad1ca68240) at 
pktio/ipc.c:359
#5  ipc_start (pktio_entry=0x7fad1ca68240) at pktio/ipc.c:670
#6  0x00405930 in odp_pktio_start (id=0x1414, id@entry=0x1) at 
odp_packet_io.c:309
#7  0x004026c1 in ipc_second_process () at pktio_ipc2.c:66
#8  main (argc=, argv=) at pktio_ipc2.c:184



Did you run make check? Maybe some files from previous wrong clean up were in 
shm?
I tested make check bunch of time and did not see any fails. Will try again.

Maxim.


Signed-off-by: Maxim Uvarov 
---
  platform/linux-generic/m4/configure.m4 |   1 +
  platform/linux-generic/test/Makefile.am|   3 +-
  platform/linux-generic/test/pktio_ipc/.gitignore   |   2 +
  platform/linux-generic/test/pktio_ipc/Makefile.am  |  20 ++
  platform/linux-generic/test/pktio_ipc/ipc_common.c | 138 +
  platform/linux-generic/test/pktio_ipc/ipc_common.h |  87 ++
  platform/linux-generic/test/pktio_ipc/pktio_ipc1.c | 310 +
  platform/linux-generic/test/pktio_ipc/pktio_ipc2.c | 185 
  .../linux-generic/test/pktio_ipc/pktio_ipc_run |  68 +
  9 files changed, 813 insertions(+), 1 deletion(-)
  create mode 100644 platform/linux-generic/test/pktio_ipc/.gitignore
  create mode 100644 platform/linux-generic/test/pktio_ipc/Makefile.am
  create mode 100644 platform/linux-generic/test/pktio_ipc/ipc_common.c
  create mode 100644 platform/linux-generic/test/pktio_ipc/ipc_common.h
  create mode 100644 platform/linux-generic/test/pktio_ipc/pktio_ipc1.c
  create mode 100644 platform/linux-generic/test/pktio_ipc/pktio_ipc2.c
  create mode 100755 platform/linux-generic/test/pktio_ipc/pktio_ipc_run

diff --git a/platform/linux-generic/m4/configure.m4 
b/platform/linux-generic/m4/configure.m4
index 6bb159f..46aaf40 100644
--- a/platform/linux-generic/m4/configure.m4
+++ b/platform/linux-generic/m4/configure.m4
@@ -24,4 +24,5 @@ m4_include([platform/linux-generic/m4/odp_pcap.m4])
  AC_CONFIG_FILES([platform/linux-generic/Makefile
   platform/linux-generic/test/Makefile
   platform/linux-generic/test/pktio/Makefile
+ platform/linux-generic/test/pktio_ipc/Makefile
   platform/linux-generic/test/ring/Makefile])
diff --git a/platform/linux-generic/test/Makefile.am 
b/platform/linux-generic/test/Makefile.am
index f81eeb8..6a05a54 100644
--- a/platform/linux-generic/test/Makefile.am
+++ b/platform/linux-generic/test/Makefile.am
@@ -1,11 +1,12 @@
  include $(top_srcdir)/test/Makefile.inc
  TESTS_ENVIRONMENT += TEST_DIR=${top_builddir}/test/validation
-ODP_MODULES = pktio ring
+ODP_MODULES = pktio pktio_ipc ring
  if test_vald
  TESTS = pktio/pktio_run \
  pktio/pktio_run_tap \
+pktio_ipc/pktio_ipc_run \
  ring/ringtest$(EXEEXT) \
  ${top_builddir}/test/validation/buffer/buffer_main$(EXEEXT) \
  
${top_builddir}/test/validation/classification/classification_main$(EXEEXT) \
diff --git a/platform/linux-generic/test/pktio_ipc/.gitignore 
b/platform/linux-generic/test/pktio_ipc/.gitignore
new file mode 100644
index 000..49ee4fd
--- /dev/null
+++ b/platform/linux-generic/test/pktio_ipc/.gitignore
@@ -0,0 +1,2 @@
+pktio_ipc1
+pktio_ipc2
diff --git a/platform/linux-generic/test/pktio_ipc/Makefile.am 
b/platform/linux-generic/test/pktio_ipc/Makefile.am
new file mode 100644
index 000..bc224ae
--- /dev/null
+++ b/platform/linux-generic/test/pktio_ipc/Makefile.am
@@ -0,0 +1,20 @@
+include $(top_srcdir)/test/Makefile.inc
+TESTS_ENVIRONMENT += TEST_DIR=${top_builddir}/test/validation
+
+test_PROGRAMS = pktio_ipc1\
+pktio_ipc2
+
+pktio_ipc1_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
+pktio_ipc1_LDFLAGS = $(AM_LDFLAGS) -static
+pktio_ipc2_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
+pktio_ipc2_LDFLAGS = $(AM_LDFLAGS) -static
+
+noinst_HEADERS = $(top_srcdir)/test/test_debug.h
+
+dist_pktio_ipc1_SOURCES = pktio_ipc1.c ipc_common.c
+dist_pktio_ipc2_SOURCES = pktio_ipc2.c ipc_common.c
+
+EXTRA_DIST = ipc_common.h
+
+dist_check_SCRIPTS = pktio_ipc_run
+test_SCRIPTS = $(dist_check_SCRIPTS)
diff --git a/platform/linux-generic/test/pktio_ipc/ipc_common.c 
b/platform/linux-generic/test/pktio_ipc/ipc_common.c
new file mode 100644
index 000..33775b0
--- /dev/null
+++ b/platform/linux-generic/test/pktio_ipc/ipc_common.c
@@ -0,0 +1,138 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights 

[lng-odp] [PATCH] linux-generic: crypto: fix AES-GCM compatibility with old version of OpenSSL

2016-01-18 Thread Nicolas Morey-Chaisemartin
Old version of OpenSSL require SET_TAG to be called before
 decrypting the data. New versions are compatible either way

Signed-off-by: Nicolas Morey-Chaisemartin 
---

Repost due to previous mail tagged as SPAM

 platform/linux-generic/odp_crypto.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index 65e8503..92bc2f3 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -397,6 +397,7 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_params_t 
*params,
int plain_len = 0;
 
EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_enc);
+   EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, 16, tag);
 
/* Authenticate header data (if any) without encrypting them */
if (aad_head < cipherdata) {
@@ -414,8 +415,6 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_params_t 
*params,
  auth_len - (aad_tail - aad_head));
}
 
-   EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, 16, tag);
-
if (EVP_DecryptFinal_ex(ctx, cipherdata + cipher_len, _len) < 0)
return ODP_CRYPTO_ALG_ERR_ICV_CHECK;
 
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v6] validation: system: add validation tests for odp_cpu_cycles_* calls

2016-01-18 Thread Maxim Uvarov

Merged.

On 01/18/2016 16:40, Savolainen, Petri (Nokia - FI/Espoo) wrote:

Not sure if "odp_cpu_cycles_*" will cause problems in git log history. May be Maxim can 
remove the '*' from the string during merge (e.g. just "... cpu_cycles calls").

done.


Reviewed-by: Petri Savolainen 




-Original Message-
From: EXT Ivan Khoronzhuk [mailto:ivan.khoronz...@linaro.org]
Sent: Monday, January 18, 2016 3:16 PM
To: lng-odp@lists.linaro.org
Cc: Savolainen, Petri (Nokia - FI/Espoo); Ivan Khoronzhuk
Subject: [lng-odp] [PATCH v6] validation: system: add validation tests for
odp_cpu_cycles_* calls

https://bugs.linaro.org/show_bug.cgi?id=1906

Signed-off-by: Ivan Khoronzhuk 
---
Since v5:
- add res instead of "1" while wrap
- get cycle stamps a multiple of res instead direct valuues.
- move resolution test before diff test

Since v3:
- modified log "wrap is not detected"
- increased try num for diff to match 16 seconds
- decreased try num for resolution to match 1 second
- allow resolution to be up to max / 1024
- correct wrap detection for resolution

Since v2:
- added c <= max
- replaced etalon on tmp
- added msg about skip
- handled resolution wrap

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch validation_tests_corrections
# Changes to be committed:
#   modified:   platform/linux-keystone2/odp_crypto.c
#   modified:   test/validation/system/system.c
#
# Changes not staged for commit:
#   modified:   platform/linux-keystone2/odp_schedule.c
#
# Untracked files:
#   .checkpatch-camelcase.git.81a3df4
#   example/traffic_mgmt/
#

  test/validation/system/system.c | 125

  test/validation/system/system.h |   4 ++
  2 files changed, 129 insertions(+)

diff --git a/test/validation/system/system.c
b/test/validation/system/system.c
index 7dc2cc0..7f54338 100644
--- a/test/validation/system/system.c
+++ b/test/validation/system/system.c
@@ -10,6 +10,9 @@
  #include "test_debug.h"
  #include "system.h"

+#define DIFF_TRY_NUM   160
+#define RES_TRY_NUM10
+
  void system_test_odp_version_numbers(void)
  {
int char_ok = 0;
@@ -40,6 +43,124 @@ void system_test_odp_cpu_count(void)
CU_ASSERT(0 < cpus);
  }

+void system_test_odp_cpu_cycles(void)
+{
+   uint64_t c2, c1;
+
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(100);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c2 != c1);
+}
+
+void system_test_odp_cpu_cycles_max(void)
+{
+   uint64_t c2, c1;
+   uint64_t max1, max2;
+
+   max1 = odp_cpu_cycles_max();
+   odp_time_wait_ns(100);
+   max2 = odp_cpu_cycles_max();
+
+   CU_ASSERT(max1 >= UINT32_MAX / 2);
+   CU_ASSERT(max1 == max2);
+
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(1000);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c1 <= max1 && c2 <= max1);
+}
+
+void system_test_odp_cpu_cycles_resolution(void)
+{
+   int i;
+   uint64_t res;
+   uint64_t c2, c1, max;
+
+   max = odp_cpu_cycles_max();
+
+   res = odp_cpu_cycles_resolution();
+   CU_ASSERT(res != 0);
+   CU_ASSERT(res < max / 1024);
+
+   for (i = 0; i < RES_TRY_NUM; i++) {
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c1 % res == 0);
+   CU_ASSERT(c2 % res == 0);
+   }
+}
+
+void system_test_odp_cpu_cycles_diff(void)
+{
+   int i;
+   uint64_t c2, c1, c3, max;
+   uint64_t tmp, diff, res;
+
+   res = odp_cpu_cycles_resolution();
+   max = odp_cpu_cycles_max();
+
+   /* check resolution for wrap */
+   c1 = max - 2 * res;
+   do
+   c2 = odp_cpu_cycles();
+   while (c1 < c2);
+
+   diff = odp_cpu_cycles_diff(c1, c1);
+   CU_ASSERT(diff == 0);
+
+   /* wrap */
+   tmp = c2 + (max - c1) + res;
+   diff = odp_cpu_cycles_diff(c2, c1);
+   CU_ASSERT(diff == tmp);
+   CU_ASSERT(diff % res == 0);
+
+   /* no wrap, revert args */
+   tmp = c1 - c2;
+   diff = odp_cpu_cycles_diff(c1, c2);
+   CU_ASSERT(diff == tmp);
+   CU_ASSERT(diff % res == 0);
+
+   c3 = odp_cpu_cycles();
+   for (i = 0; i < DIFF_TRY_NUM; i++) {
+   c1 = odp_cpu_cycles();
+   odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
+   c2 = odp_cpu_cycles();
+
+   CU_ASSERT(c2 != c1);
+   CU_ASSERT(c1 % res == 0);
+   CU_ASSERT(c2 % res == 0);
+   CU_ASSERT(c1 <= max && c2 <= max);
+
+   if (c2 > c1)
+   tmp = c2 - c1;
+   else
+   tmp = c2 + (max - c1) + res;
+
+   diff = odp_cpu_cycles_diff(c2, c1);
+   CU_ASSERT(diff == tmp);
+  

Re: [lng-odp] [API-NEXT PATCH v2 10/13] validation: atomic: added xchg test

2016-01-18 Thread Ola Liljedahl
On 18 January 2016 at 16:25, Ola Liljedahl  wrote:

> On 18 January 2016 at 14:25, Petri Savolainen 
> wrote:
>
>> Added validation test for exchange operations.
>>
>> Signed-off-by: Petri Savolainen 
>> ---
>>  test/validation/synchronizers/synchronizers.c | 54
>> +++
>>  test/validation/synchronizers/synchronizers.h |  1 +
>>  2 files changed, 55 insertions(+)
>>
>> diff --git a/test/validation/synchronizers/synchronizers.c
>> b/test/validation/synchronizers/synchronizers.c
>> index ece9d4f..6fb122a 100644
>> --- a/test/validation/synchronizers/synchronizers.c
>> +++ b/test/validation/synchronizers/synchronizers.c
>> @@ -34,6 +34,7 @@
>>  #define UNUSED __attribute__((__unused__))
>>
>>  #define CHECK_MAX_MIN  (1 << 0)
>> +#define CHECK_XCHG (1 << 2)
>>
>>  static odp_atomic_u32_t a32u;
>>  static odp_atomic_u64_t a64u;
>> @@ -41,6 +42,8 @@ static odp_atomic_u32_t a32u_min;
>>  static odp_atomic_u32_t a32u_max;
>>  static odp_atomic_u64_t a64u_min;
>>  static odp_atomic_u64_t a64u_max;
>> +static odp_atomic_u32_t a32u_xchg;
>> +static odp_atomic_u64_t a64u_xchg;
>>
>>  static volatile int temp_result;
>>
>> @@ -1304,6 +1307,28 @@ static void test_atomic_cas_dec_64(void)
>> }
>>  }
>>
>> +static void test_atomic_xchg_32(void)
>> +{
>> +   int i;
>> +
>> +   for (i = 0; i < CNT; i++) {
>> +   odp_atomic_xchg_u32(_xchg, 0);
>>
> Not the most interesting test of an exchange operation. Should use/test
> the return value as well, for some purpose.
>
>
>> +
>> +   odp_atomic_inc_u32(_xchg);
>>
> Exchange (with 0) and inc operations are not atomic. We only know that inc
> happens after our own exchange but not how inc is ordered with the
> operations in other threads.
>
> +   }
>> +}
>> +
>> +static void test_atomic_xchg_64(void)
>> +{
>> +   int i;
>> +
>> +   for (i = 0; i < CNT; i++) {
>> +   odp_atomic_xchg_u64(_xchg, 0);
>>
> If I add 1 calls to odp_cpu_pause() here, the validation check 
> ("odp_atomic_load_u64(_xchg)
== 1" on line 1519) fails quite often. With 10 calls, it fails every
time.


> +
>> +   odp_atomic_inc_u64(_xchg);
>> +   }
>> +}
>> +
>>  static void test_atomic_inc_dec_32(void)
>>  {
>> test_atomic_inc_32();
>> @@ -1384,6 +1409,8 @@ static void test_atomic_init(void)
>> odp_atomic_init_u32(_max, 0);
>> odp_atomic_init_u64(_min, 0);
>> odp_atomic_init_u64(_max, 0);
>> +   odp_atomic_init_u32(_xchg, 0);
>> +   odp_atomic_init_u64(_xchg, 0);
>>  }
>>
>>  static void test_atomic_store(void)
>> @@ -1394,6 +1421,8 @@ static void test_atomic_store(void)
>> odp_atomic_store_u32(_max, U32_INIT_VAL);
>> odp_atomic_store_u64(_min, U64_INIT_VAL);
>> odp_atomic_store_u64(_max, U64_INIT_VAL);
>> +   odp_atomic_store_u32(_xchg, U32_INIT_VAL);
>> +   odp_atomic_store_u64(_xchg, U64_INIT_VAL);
>>  }
>>
>>  static void test_atomic_validate(int check)
>> @@ -1408,6 +1437,12 @@ static void test_atomic_validate(int check)
>> CU_ASSERT(odp_atomic_load_u64(_max) >
>>   odp_atomic_load_u64(_min));
>> }
>> +
>> +   if (check & CHECK_XCHG) {
>> +   /* every iteration resets count and increments once */
>> +   CU_ASSERT(odp_atomic_load_u32(_xchg) == 1);
>>
> Isn't the test running multiple threads using the same variable? Doesn't
> this mean that a43u_xchg could have the same value as the number of threads
> (N)? All threads perform the exchange operation, setting the shared
> variable to 0. Then all threads perform the inc operation which together
> increases the value with N.
>
>
> +   CU_ASSERT(odp_atomic_load_u64(_xchg) == 1);
>> +   }
>>  }
>>
>>  /* Barrier tests */
>> @@ -1742,6 +1777,19 @@ static void *test_atomic_cas_inc_dec_thread(void
>> *arg UNUSED)
>> return NULL;
>>  }
>>
>> +static void *test_atomic_xchg_thread(void *arg UNUSED)
>> +{
>> +   per_thread_mem_t *per_thread_mem;
>> +
>> +   per_thread_mem = thread_init();
>> +   test_atomic_xchg_32();
>> +   test_atomic_xchg_64();
>> +
>> +   thread_finalize(per_thread_mem);
>> +
>> +   return NULL;
>> +}
>> +
>>  static void test_atomic_functional(void *func_ptr(void *), int check)
>>  {
>> pthrd_arg arg;
>> @@ -1784,6 +1832,11 @@ void synchronizers_test_atomic_cas_inc_dec(void)
>> test_atomic_functional(test_atomic_cas_inc_dec_thread, 0);
>>  }
>>
>> +void synchronizers_test_atomic_xchg(void)
>> +{
>> +   test_atomic_functional(test_atomic_xchg_thread, CHECK_XCHG);
>> +}
>> +
>>  odp_testinfo_t synchronizers_suite_atomic[] = {
>> ODP_TEST_INFO(synchronizers_test_atomic_inc_dec),
>> ODP_TEST_INFO(synchronizers_test_atomic_add_sub),
>> @@ -1791,6 +1844,7 @@ odp_testinfo_t synchronizers_suite_atomic[] 

Re: [lng-odp] [API-NEXT PATCHv1 2/2] linux-generic/validation: wait for timer handler completiion after timer deletion

2016-01-18 Thread Ivan Khoronzhuk



On 15.01.16 11:14, Maxim Uvarov wrote:

Add test case based on previous seg fault code that pool destroy
does not fail if there are some timers in fight.

Signed-off-by: Maxim Uvarov 
---
  platform/linux-generic/odp_timer.c | 15 ++-
  test/validation/timer/timer.c  | 15 +++
  test/validation/timer/timer.h  |  1 +
  3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/platform/linux-generic/odp_timer.c 
b/platform/linux-generic/odp_timer.c
index b8f34fb..95fe130 100644
--- a/platform/linux-generic/odp_timer.c
+++ b/platform/linux-generic/odp_timer.c
@@ -259,6 +259,16 @@ static odp_timer_pool *odp_timer_pool_new(
return tp;
  }

+static void _finalyze_timers_handlers(void)
+{
+   struct timespec ts;
+
+   ts.tv_sec = 0;
+   ts.tv_nsec = 50 * ODP_TIME_MSEC_IN_NS;
+   if (nanosleep(, NULL) < 0)
+   ODP_ABORT("nanosleep failed");
+}
+

For linux generic maybe that's OK, but why not odp_time API


  static void odp_timer_pool_del(odp_timer_pool *tp)
  {
odp_spinlock_lock(>lock);
@@ -270,8 +280,11 @@ static void odp_timer_pool_del(odp_timer_pool *tp)
/* timer pool which is still in use */
ODP_ABORT("%s: timers in use\n", tp->name);
}
-   if (tp->param.clk_src == ODP_CLOCK_CPU)
+   if (tp->param.clk_src == ODP_CLOCK_CPU) {
itimer_fini(tp);
+   _finalyze_timers_handlers();
+   }
+

Why are you sure that it's still receiving events after finish.
Did you catch it?


int rc = odp_shm_free(tp->shm);
if (rc != 0)
ODP_ABORT("Failed to free shared memory (%d)\n", rc);
diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c
index db0a5ca..879ff67 100644
--- a/test/validation/timer/timer.c
+++ b/test/validation/timer/timer.c
@@ -22,6 +22,9 @@
  /** @private Number of timers per thread */
  #define NTIMERS 2000

+/** @private Dont wait for timers completition */
+static int dont_wait_for_timer_comp;
+
  /** @private Barrier for thread synchronisation */
  static odp_barrier_t test_barrier;

@@ -277,6 +280,9 @@ static void _wait_for_timers_expiration(void)
  {
struct timespec ts;

+   if (dont_wait_for_timer_comp)
+   return;
+

Pay attention, you've skipped not only "wait for timers expiration".
you also deleted delay in polling loop, decreased in the same time
timeout for receiving events, as result at the end of the test the
number of timeouts in the flight will be much more. That will increase
contrast of fail/true tests...presented here.


ts.tv_sec = 0;
ts.tv_nsec = 50 * ODP_TIME_MSEC_IN_NS;
if (nanosleep(, NULL) < 0)
@@ -539,11 +545,20 @@ void timer_test_odp_timer_all(void)
CU_PASS("ODP timer test");
  }

+/* @private Timer test case entrypoint */
+void timer_test_destroy_pool_with_scheduled_timers(void)
+{
+   dont_wait_for_timer_comp = 1;
+   timer_test_odp_timer_all();
+   dont_wait_for_timer_comp = 0;
+}
+
  odp_testinfo_t timer_suite[] = {
ODP_TEST_INFO(timer_test_timeout_pool_alloc),
ODP_TEST_INFO(timer_test_timeout_pool_free),
ODP_TEST_INFO(timer_test_odp_timer_cancel),
ODP_TEST_INFO(timer_test_odp_timer_all),
+   ODP_TEST_INFO(timer_test_destroy_pool_with_scheduled_timers),

Is it supposed to be before timer_test_odp_timer_all()?
Or test can continue after seg fault? :-|.
IMHO, no need in it.


ODP_TEST_INFO_NULL,
  };

diff --git a/test/validation/timer/timer.h b/test/validation/timer/timer.h
index 46ea8d7..4f805b4 100644
--- a/test/validation/timer/timer.h
+++ b/test/validation/timer/timer.h
@@ -14,6 +14,7 @@ void timer_test_timeout_pool_alloc(void);
  void timer_test_timeout_pool_free(void);
  void timer_test_odp_timer_cancel(void);
  void timer_test_odp_timer_all(void);
+void timer_test_destroy_pool_with_scheduled_timers(void);

  /* test arrays: */
  extern odp_testinfo_t timer_suite[];



--
Regards,
Ivan Khoronzhuk
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] What to do regarding cahe non coherant systems

2016-01-18 Thread Christophe Milard
We can discuss your proposal during the call, today.
I have a question, though. If the ODP_SHM_NONCOHERENT flag is implemeneted,
then I guess we are back to the need for a refresh() or similar function to
update the cache.
Or you could implement this flag in your implementation only, allocating
shmem memory with this flag for packet and other object which you know when
to "refresh" and leting a shm_reserve directely performed by the
application reserve non-ODP_SHM_NONCOHERENT memory...
I am not sure what is the proposal, but you are welcome to talk at the
meeting.
Regarding the ODP_SHM_PROC flag, I am non sure the code is correct: As I
can see from the code, the mapping is anonymous when the flag is not
present: This means the the function will behave differently depending on
if ODP threads are implemented as linux threads or as linux processes (also
depending on when the shm_reserve() is performed relative to the fork()). I
assume this is not the real intention: My understanding at this stage is
that shm_reserve() should always reserve shared memory visible from all ODP
threads (non depending on their implementation as linux process vs linux
thread). From the different discussion I have had,  I believe
the ODP_SHM_PROC flag is meant to enable this memory to also be sharable by
non-ODP processes (normal non ODP linux processes).

Christophe.

On 18 January 2016 at 20:59, Benoît Ganne  wrote:

> Hi all,
>
> Our problem is about shmem usage so far. After some discussions we believe
> we have an acceptable solution: add a new flag to odp_shm_reserve(). So far
> we have ODP_SHM_SW_ONLY and ODP_SHM_PROC, we would like to add something
> like ODP_SHM_NONCOHERENT or similar.
> It would allow to keep the default as it is today (and we will support it)
> but would allow for optimizations where it is performance sensitive.
> We can discuss the issue during the call and post a patch quickly if
> everybody agree.
>
> By the way, what is the exact semantic of ODP_SHM_SW_ONLY and
> ODP_SHM_PROC? From what I can see ODP_SHM_PROC relates to use MAP_ANONYMOUS
> vs shm_open(), so mainly publishes the name of the mapping (so other
> processes can use it) and I suspect that ODP_SHM_SW_ONLY relates to things
> like DMA cache-coherency (well, lack of)?
>
> ben
>
> On 01/18/2016 10:38 AM, Christophe Milard wrote:
>
>> This seems to be a common opinion. I think it is nevertheless fair to
>> give a chance to Nicolas to explain his case.
>>
>> On 18 January 2016 at 10:02, Ola Liljedahl > > wrote:
>>
>> On 15 January 2016 at 15:48, Christophe Milard
>> >
>> wrote:
>>
>> On Tuesday's ARCH call, we will be discussing the above topic.
>> Nicolas (Kalray) will try to join, but he is very uncertain  at
>> this stage (if he can be there)...
>>
>> Cache coherence is the norm today, non-coherent is an exception.
>> My opinion: If possible and simple, make public interfaces not
>> dependent on cache coherence. The reference implementation could
>> depend on cache coherence. Anyone who wants to support non-coherent
>> HW needs to provide the necessary support.
>>
>>
>> ___
>> lng-odp mailing list
>> lng-odp@lists.linaro.org 
>> https://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
>>
>>
>>
>> ___
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> https://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
>
> --
> Benoît GANNE
> Chief Architect, Kalray
> +33 (0)648 125 843
>
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] What to do regarding cahe non coherant systems

2016-01-18 Thread Benoît Ganne

Hi all,

Our problem is about shmem usage so far. After some discussions we 
believe we have an acceptable solution: add a new flag to 
odp_shm_reserve(). So far we have ODP_SHM_SW_ONLY and ODP_SHM_PROC, we 
would like to add something like ODP_SHM_NONCOHERENT or similar.
It would allow to keep the default as it is today (and we will support 
it) but would allow for optimizations where it is performance sensitive.
We can discuss the issue during the call and post a patch quickly if 
everybody agree.


By the way, what is the exact semantic of ODP_SHM_SW_ONLY and 
ODP_SHM_PROC? From what I can see ODP_SHM_PROC relates to use 
MAP_ANONYMOUS vs shm_open(), so mainly publishes the name of the mapping 
(so other processes can use it) and I suspect that ODP_SHM_SW_ONLY 
relates to things like DMA cache-coherency (well, lack of)?


ben

On 01/18/2016 10:38 AM, Christophe Milard wrote:

This seems to be a common opinion. I think it is nevertheless fair to
give a chance to Nicolas to explain his case.

On 18 January 2016 at 10:02, Ola Liljedahl > wrote:

On 15 January 2016 at 15:48, Christophe Milard
>
wrote:

On Tuesday's ARCH call, we will be discussing the above topic.
Nicolas (Kalray) will try to join, but he is very uncertain  at
this stage (if he can be there)...

Cache coherence is the norm today, non-coherent is an exception.
My opinion: If possible and simple, make public interfaces not
dependent on cache coherence. The reference implementation could
depend on cache coherence. Anyone who wants to support non-coherent
HW needs to provide the necessary support.


___
lng-odp mailing list
lng-odp@lists.linaro.org 
https://lists.linaro.org/mailman/listinfo/lng-odp





___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp




--
Benoît GANNE
Chief Architect, Kalray
+33 (0)648 125 843
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [API-NEXT PATCHv1 1/2] validation: increase timer expiration wait time

2016-01-18 Thread Ivan Khoronzhuk

Maxim,
in general, I had no look in this test, it was working for me and I was happy.
At fast glance I have some comments. Hope you will find time to correct it.

On 15.01.16 11:14, Maxim Uvarov wrote:

Following current test logic validation test should correctly
wait for all scheduled timer expirations. Setting that time
to 1ms is not correct due to code above schedules timer to 1.1ms
and context switch in linux takes 10ms.

Problem that odp_timer_pool_destroy() does not disarm all trigered
timers before freeing pool shared memory still exist. That should
be covered with separate test case.

Signed-off-by: Maxim Uvarov 
---
  test/validation/timer/timer.c | 38 --
  1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c
index dda5e4c..db0a5ca 100644
--- a/test/validation/timer/timer.c
+++ b/test/validation/timer/timer.c
@@ -266,6 +266,23 @@ static void handle_tmo(odp_event_t ev, bool stale, 
uint64_t prev_tick)
}
  }

+/* Delay to ensure timeouts for expired timers can be
+ * received.
+ * Delay time = (max timer expiration time) +
+ * (timer handler execution time) +
+ * (system overhead for thread creation and schedule
+ *  context switches)
+ */
+static void _wait_for_timers_expiration(void)

_wait_for* -> wait_for_*


+{
+   struct timespec ts;
+
+   ts.tv_sec = 0;
+   ts.tv_nsec = 50 * ODP_TIME_MSEC_IN_NS;
+   if (nanosleep(, NULL) < 0)
+   CU_FAIL_FATAL("nanosleep failed");
+}
+

use time API here
odp_time_wait_ns(50 * ODP_TIME_MSEC_IN_NS());

Maybe better to correct it with separate preparation patch.


  /* @private Worker thread entrypoint which performs timer 
alloc/set/cancel/free
   * tests */
  static void *worker_entrypoint(void *arg TEST_UNUSED)
@@ -305,7 +322,7 @@ static void *worker_entrypoint(void *arg TEST_UNUSED)
uint64_t tck = odp_timer_current_tick(tp) + 1 +
   odp_timer_ns_to_tick(tp,
(rand_r() % RANGE_MS)
-   * 100ULL);
+   * ODP_TIME_MSEC_IN_NS);
odp_timer_set_t rc;
rc = odp_timer_set_abs(tt[i].tim, tck, [i].ev);
if (rc != ODP_TIMER_SUCCESS) {
@@ -351,7 +368,8 @@ static void *worker_entrypoint(void *arg TEST_UNUSED)
/* Timer active => reset */
nreset++;
uint64_t tck = 1 + odp_timer_ns_to_tick(tp,
-  (rand_r() % RANGE_MS) * 100ULL);
+  (rand_r() % RANGE_MS) *
+  ODP_TIME_MSEC_IN_NS);

...it's not related to the patch, but maybe as preparation patch would be 
normal to
replace rand_r() usage on odp_random_data()...


odp_timer_set_t rc;
uint64_t cur_tick;
/* Loop until we manage to read cur_tick and set a
@@ -372,11 +390,8 @@ static void *worker_entrypoint(void *arg TEST_UNUSED)
tt[i].tick = cur_tick + tck;
}
}
-   struct timespec ts;
-   ts.tv_sec = 0;
-   ts.tv_nsec = 100; /* 1ms */
-   if (nanosleep(, NULL) < 0)
-   CU_FAIL_FATAL("nanosleep failed");
+
+   _wait_for_timers_expiration();

You've changed step here from 1ms to 50ms, but didn't change comment under loop.
It's not seen here, but after this description is not correct.
...
Also, delay is increased but step in the loop is still supposed 1ms.
The line below should be changed also:
for (ms = 0; ms < 7 * RANGE_MS / 10; ms++) {

ms += 50ms, but pay attention, maybe there is reason to tune (7 * RANGE_MS / 
10) a little.

But really I not fully understand why we need to increase step here.
IMHO, it's better to decrease it here. If in some case timeout is delivered to
early it should be caught, but if it's a little to late - it's normal.
Test simply checks if timeouts are received in right order and are not to early.

Simply increasing delay here in 50 times and not tuning iteration number you 
increased
time for receiving events in the loop. The events are spread in 2000 ms, and 
you are
lucky to fit in this range by doing like this. To increase time for receiving 
events
better to increase iteration number in:
for (ms = 0; ms < 7 * RANGE_MS / 10; ms++) {
to fit 2000 ms interval. That's enough to receive all events and no need to 
change polling timeout.


}

/* Cancel and free all timers */
@@ -401,13 +416,8 @@ static void *worker_entrypoint(void *arg TEST_UNUSED)
LOG_DBG("Thread %u: %" PRIu32 " stale timeout(s) after 
odp_timer_free()\n",