Re: [lng-odp] [PATCH] doc: guides: embed icons and images in html

2015-12-04 Thread Bill Fischofer
On Fri, Dec 4, 2015 at 2:46 PM, Mike Holmes  wrote:

> The icons in the generated guide have a system dependent location.
> If the system used to view the docs does not have asciidoc installed
> no icons will be displayed.
>
> Embed the images so that the output is self-contained.
>
> Signed-off-by: Mike Holmes 
>

Reviewed-by: Bill Fischofer 


> ---
>  doc/implementers-guide/Makefile.am | 2 +-
>  doc/users-guide/Makefile.am| 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/doc/implementers-guide/Makefile.am
> b/doc/implementers-guide/Makefile.am
> index d653968..f0832f1 100644
> --- a/doc/implementers-guide/Makefile.am
> +++ b/doc/implementers-guide/Makefile.am
> @@ -6,7 +6,7 @@ all-local: $(TARGET)
>
>  $(TARGET): implementers-guide.adoc
> @mkdir -p $(top_srcdir)/doc/output
> -   asciidoc -b html5  -a icons -a toc2  -a max-width=55em
> --out-file=$@ $<
> +   asciidoc -a data-uri -b html5  -a icons -a toc2  -a max-width=55em
> --out-file=$@ $<
>
>  clean-local:
> rm -f $(TARGET)
> diff --git a/doc/users-guide/Makefile.am b/doc/users-guide/Makefile.am
> index 8e60312..383894a 100644
> --- a/doc/users-guide/Makefile.am
> +++ b/doc/users-guide/Makefile.am
> @@ -6,7 +6,7 @@ all-local: $(TARGET)
>
>  $(TARGET): users-guide.adoc
> @mkdir -p $(top_srcdir)/doc/output
> -   asciidoc -b html5  -a icons -a toc2  -a max-width=55em
> --out-file=$@ $<
> +   asciidoc -a data-uri -b html5  -a icons -a toc2  -a max-width=55em
> --out-file=$@ $<
>
>  clean-local:
> rm -f $(TARGET)
> --
> 2.5.0
>
> ___
> 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] doc: guides: embed icons and images in html

2015-12-04 Thread Mike Holmes
The icons in the generated guide have a system dependent location.
If the system used to view the docs does not have asciidoc installed
no icons will be displayed.

Embed the images so that the output is self-contained.

Signed-off-by: Mike Holmes 
---
 doc/implementers-guide/Makefile.am | 2 +-
 doc/users-guide/Makefile.am| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/implementers-guide/Makefile.am 
b/doc/implementers-guide/Makefile.am
index d653968..f0832f1 100644
--- a/doc/implementers-guide/Makefile.am
+++ b/doc/implementers-guide/Makefile.am
@@ -6,7 +6,7 @@ all-local: $(TARGET)
 
 $(TARGET): implementers-guide.adoc
@mkdir -p $(top_srcdir)/doc/output
-   asciidoc -b html5  -a icons -a toc2  -a max-width=55em --out-file=$@ $<
+   asciidoc -a data-uri -b html5  -a icons -a toc2  -a max-width=55em 
--out-file=$@ $<
 
 clean-local:
rm -f $(TARGET)
diff --git a/doc/users-guide/Makefile.am b/doc/users-guide/Makefile.am
index 8e60312..383894a 100644
--- a/doc/users-guide/Makefile.am
+++ b/doc/users-guide/Makefile.am
@@ -6,7 +6,7 @@ all-local: $(TARGET)
 
 $(TARGET): users-guide.adoc
@mkdir -p $(top_srcdir)/doc/output
-   asciidoc -b html5  -a icons -a toc2  -a max-width=55em --out-file=$@ $<
+   asciidoc -a data-uri -b html5  -a icons -a toc2  -a max-width=55em 
--out-file=$@ $<
 
 clean-local:
rm -f $(TARGET)
-- 
2.5.0

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


Re: [lng-odp] [API-NEXT PATCH v6] 0/9] api: time: update local time to be monotonic

2015-12-04 Thread Ivan Khoronzhuk

Maxim,
I've corrected the defects in v7.
Please, merge.

On 04.12.15 11:36, Maxim Uvarov wrote:

Hello Ivan,

The hole patch set looks like good. But it looks like patch order is wrong or 
some patches needs to be merged.

If I apply only 8 patches there is error:
   Test: time_test_odp_negative_diff ...FAILED
 1. time.c:42  - odp_time_cmp(diff, ODP_TIME_NULL) > 0

If only 7 patches then odp_pktio_perf test fails.

Also running odp-check I saw segfault on some patches.

And patches short message is: "[API-NEXT PATCH v6] 0/9]", but it has to be [API-NEXT 
PATCHv6 0/9]".

Maxim.

On 12/03/2015 17:07, Savolainen, Petri (Nokia - FI/Espoo) wrote:

Entire patch set:

Reviewed-by: Petri Savolainen 




-Original Message-
From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT
Ivan Khoronzhuk
Sent: Thursday, December 03, 2015 2:49 PM
To: lng-odp@lists.linaro.org
Subject: [lng-odp] [API-NEXT PATCH v6] 0/9] api: time: update local time
to be monotonic

This series is intended to modify time API to be used as monotonic wall
time in order to simplify time API usage and create prerequisites for
adding global time API.

Since v5
   linux-generic: align with new wall time API
- deleted _odp prefix for local functions
- avoided modulo operation
- used common global var for start time

Since v3:
- "api: time: make odp_local_time to be monotonic wall time"
   splitted on;
   "linux-generic: align with new wall time API"
   "test/example: use local time API as wall time"
- increased BUSY_LOOP_CNT to fit in resolution and 4+ sec

Since v2:
- removed patch changing type of ODP_TIME_*
- added new patch:
   test: performance: pktio: don't use direct arithmetic operations with
 odp_time_t
- added new patch:
   performance: sched: use ODP time API instead of clock_gettime
- combined monotonic and wall time patches
- removed odp_time_local_val() and odp_time_val_to_ns()
- replaced terms monotonic and wall in API desc

Since v1:
- corrected name of the series to be api-next
- use thread local for holding start time

Ivan Khoronzhuk (9):
   validation: time: don't assign int directly to odp_time_t
   test: performance: pktio: don't use direct arithmetic operations with
 odp_time_t
   linux-generic: schedule: use schedule time in ns
   linux-generic: odp_time: don't use cpu cycle API to get time
   performance: sched: use ODP time API instead of clock_gettime
   api: time: make odp_local_time to be monotonic wall time
   linux-generic: align with new wall time API
   test/example: use local time API as wall time
   validation: time: align tests with current time API

  example/generator/odp_generator.c  |  10 +-
  include/odp/api/time.h |   3 +-
  platform/linux-generic/Makefile.am |   1 -
  .../linux-generic/include/odp/plat/time_types.h|   6 +-
  platform/linux-generic/include/odp_cpu_internal.h  |  29 ---
  platform/linux-generic/include/odp_internal.h  |   2 +
  platform/linux-generic/odp_cpu.c   |   6 +-
  platform/linux-generic/odp_init.c  |   4 +
  platform/linux-generic/odp_schedule.c  |  18 +-
  platform/linux-generic/odp_time.c  | 112 +++---
  test/performance/odp_pktio_perf.c  |  24 +--
  test/performance/odp_scheduling.c  |  37 +---
  test/validation/pktio/pktio.c  |  21 +-
  test/validation/time/time.c| 228
++---
  test/validation/time/time.h|   7 +-
  15 files changed, 346 insertions(+), 162 deletions(-)
  delete mode 100644 platform/linux-generic/include/odp_cpu_internal.h

--
1.9.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


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


[lng-odp] [API-NEXT PATCH v7 9/9] test/example: use local time API as wall time

2015-12-04 Thread Ivan Khoronzhuk
The local time API is supposed to behave like wall time now,
so correct it in examples and tests.

Reviewed-by: Petri Savolainen 
Signed-off-by: Ivan Khoronzhuk 
---
 example/generator/odp_generator.c | 10 +-
 test/performance/odp_pktio_perf.c | 27 ---
 test/validation/pktio/pktio.c | 21 -
 3 files changed, 25 insertions(+), 33 deletions(-)

diff --git a/example/generator/odp_generator.c 
b/example/generator/odp_generator.c
index 9d79f89..2de530d 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -586,7 +586,7 @@ static void *gen_recv_thread(void *arg)
  */
 static void print_global_stats(int num_workers)
 {
-   odp_time_t start, wait, diff;
+   odp_time_t cur, wait, next;
uint64_t pkts, pkts_prev = 0, pps, maximum_pps = 0;
int verbose_interval = 20;
odp_thrmask_t thrd_mask;
@@ -595,7 +595,7 @@ static void print_global_stats(int num_workers)
continue;
 
wait = odp_time_local_from_ns(verbose_interval * ODP_TIME_SEC_IN_NS);
-   start = odp_time_local();
+   next = odp_time_sum(odp_time_local(), wait);
 
while (odp_thrmask_worker(&thrd_mask) == num_workers) {
if (args->appl.number != -1 &&
@@ -604,11 +604,11 @@ static void print_global_stats(int num_workers)
break;
}
 
-   diff = odp_time_diff(odp_time_local(), start);
-   if (odp_time_cmp(wait, diff) > 0)
+   cur = odp_time_local();
+   if (odp_time_cmp(next, cur) > 0)
continue;
 
-   start = odp_time_local();
+   next = odp_time_sum(cur, wait);
 
if (args->appl.mode == APPL_MODE_RCV) {
pkts = odp_atomic_load_u64(&counters.udp);
diff --git a/test/performance/odp_pktio_perf.c 
b/test/performance/odp_pktio_perf.c
index ec67d55..8737bc8 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -305,8 +305,8 @@ static void *run_thread_tx(void *arg)
int thr_id;
odp_queue_t outq;
pkt_tx_stats_t *stats;
-   odp_time_t start_time, cur_time, send_duration;
-   odp_time_t burst_start_time, burst_gap;
+   odp_time_t cur_time, send_time_end, send_duration;
+   odp_time_t burst_gap_end, burst_gap;
uint32_t batch_len;
int unsent_pkts = 0;
odp_event_t  tx_event[BATCH_LEN_MAX];
@@ -336,22 +336,19 @@ static void *run_thread_tx(void *arg)
odp_barrier_wait(&globals->tx_barrier);
 
cur_time = odp_time_local();
-   start_time   = cur_time;
-   burst_start_time = odp_time_diff(cur_time, burst_gap);
-   while (odp_time_cmp(send_duration,
-   odp_time_diff(cur_time, start_time)) > 0) {
+   send_time_end = odp_time_sum(cur_time, send_duration);
+   burst_gap_end = cur_time;
+   while (odp_time_cmp(send_time_end, cur_time) > 0) {
unsigned alloc_cnt = 0, tx_cnt;
 
-   if (odp_time_cmp(burst_gap,
-odp_time_diff(cur_time, burst_start_time))
-> 0) {
+   if (odp_time_cmp(burst_gap_end, cur_time) > 0) {
cur_time = odp_time_local();
if (!odp_time_cmp(idle_start, ODP_TIME_NULL))
idle_start = cur_time;
continue;
}
 
-   if (odp_time_cmp(idle_start, ODP_TIME_NULL)) {
+   if (odp_time_cmp(idle_start, ODP_TIME_NULL) > 0) {
odp_time_t diff = odp_time_diff(cur_time, idle_start);
 
stats->s.idle_ticks =
@@ -360,7 +357,7 @@ static void *run_thread_tx(void *arg)
idle_start = ODP_TIME_NULL;
}
 
-   burst_start_time = odp_time_sum(burst_start_time, burst_gap);
+   burst_gap_end = odp_time_sum(burst_gap_end, burst_gap);
 
alloc_cnt = alloc_packets(tx_event, batch_len - unsent_pkts);
if (alloc_cnt != batch_len)
@@ -598,13 +595,13 @@ static int setup_txrx_masks(odp_cpumask_t *thd_mask_tx,
  */
 static void busy_loop_ns(uint64_t wait_ns)
 {
-   odp_time_t diff;
-   odp_time_t start_time = odp_time_local();
odp_time_t wait = odp_time_local_from_ns(wait_ns);
+   odp_time_t cur = odp_time_local();
+   odp_time_t end_time = odp_time_sum(cur, wait);
 
do {
-   diff = odp_time_diff(odp_time_local(), start_time);
-   } while (odp_time_cmp(wait, diff) > 0);
+   cur = odp_time_local();
+   } while (odp_time_cmp(end_time, cur) > 0);
 }
 
 /*
diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index 0a6592c..002c26b 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -336,18 +336,16 @@ static int destroy_

[lng-odp] [API-NEXT PATCH v7 8/9] linux-generic: align with new wall time API

2015-12-04 Thread Ivan Khoronzhuk
The local time API supposes the time source is wall time.
So correct linux-generic implementation.

Reviewed-by: Petri Savolainen 
Signed-off-by: Ivan Khoronzhuk 
---
 platform/linux-generic/include/odp_internal.h |  2 +
 platform/linux-generic/odp_init.c |  4 ++
 platform/linux-generic/odp_schedule.c |  9 ++--
 platform/linux-generic/odp_time.c | 61 ++-
 4 files changed, 49 insertions(+), 27 deletions(-)

diff --git a/platform/linux-generic/include/odp_internal.h 
b/platform/linux-generic/include/odp_internal.h
index 74e48a9..49e23d9 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -79,6 +79,8 @@ int odp_schedule_term_local(void);
 int odp_timer_init_global(void);
 int odp_timer_disarm_all(void);
 
+int odp_time_global_init(void);
+
 int odp_tm_init_global(void);
 
 void _odp_flush_caches(void);
diff --git a/platform/linux-generic/odp_init.c 
b/platform/linux-generic/odp_init.c
index 7f35962..d93dab8 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -24,6 +24,10 @@ int odp_init_global(const odp_init_t *params,
odp_global_data.abort_fn = params->abort_fn;
}
 
+   if (odp_time_global_init()) {
+   ODP_ERR("ODP time init failed.\n");
+   return -1;
+   }
 
odp_system_info_init();
 
diff --git a/platform/linux-generic/odp_schedule.c 
b/platform/linux-generic/odp_schedule.c
index 96b3ac5..3017876 100644
--- a/platform/linux-generic/odp_schedule.c
+++ b/platform/linux-generic/odp_schedule.c
@@ -586,7 +586,7 @@ static int schedule_loop(odp_queue_t *out_queue, uint64_t 
wait,
 odp_event_t out_ev[],
 unsigned int max_num, unsigned int max_deq)
 {
-   odp_time_t start_time, time, diff, wtime;
+   odp_time_t next, wtime;
int first = 1;
int ret;
 
@@ -604,15 +604,12 @@ static int schedule_loop(odp_queue_t *out_queue, uint64_t 
wait,
 
if (first) {
wtime = odp_time_local_from_ns(wait);
-   start_time = odp_time_local();
+   next = odp_time_sum(odp_time_local(), wtime);
first = 0;
continue;
}
 
-   time = odp_time_local();
-   diff = odp_time_diff(time, start_time);
-
-   if (odp_time_cmp(wtime, diff) < 0)
+   if (odp_time_cmp(next, odp_time_local()) < 0)
break;
}
 
diff --git a/platform/linux-generic/odp_time.c 
b/platform/linux-generic/odp_time.c
index 89bbf0c..1c7c214 100644
--- a/platform/linux-generic/odp_time.c
+++ b/platform/linux-generic/odp_time.c
@@ -11,28 +11,24 @@
 #include 
 #include 
 
-odp_time_t odp_time_local(void)
+static struct timespec start_time;
+
+static inline
+uint64_t time_to_ns(odp_time_t time)
 {
-   int ret;
-   struct timespec time;
+   uint64_t ns;
 
-   ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time);
-   if (odp_unlikely(ret != 0))
-   ODP_ABORT("clock_gettime failed\n");
+   ns = time.tv_sec * ODP_TIME_SEC_IN_NS;
+   ns += time.tv_nsec;
 
-   return time;
+   return ns;
 }
 
-odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1)
+static inline
+odp_time_t time_diff(odp_time_t t2, odp_time_t t1)
 {
-   uint64_t ns1, ns2;
struct timespec time;
 
-   ns1 = odp_time_to_ns(t1);
-   ns2 = odp_time_to_ns(t2);
-   if (ns2 < ns1)
-   return (struct timespec) {0, 1};
-
time.tv_sec = t2.tv_sec - t1.tv_sec;
time.tv_nsec = t2.tv_nsec - t1.tv_nsec;
 
@@ -44,14 +40,26 @@ odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1)
return time;
 }
 
-uint64_t odp_time_to_ns(odp_time_t time)
+odp_time_t odp_time_local(void)
 {
-   uint64_t ns;
+   int ret;
+   struct timespec time;
 
-   ns = time.tv_sec * ODP_TIME_SEC_IN_NS;
-   ns += time.tv_nsec;
+   ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time);
+   if (odp_unlikely(ret != 0))
+   ODP_ABORT("clock_gettime failed\n");
 
-   return ns;
+   return time_diff(time, start_time);
+}
+
+odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1)
+{
+   return time_diff(t2, t1);
+}
+
+uint64_t odp_time_to_ns(odp_time_t time)
+{
+   return time_to_ns(time);
 }
 
 odp_time_t odp_time_local_from_ns(uint64_t ns)
@@ -59,7 +67,7 @@ odp_time_t odp_time_local_from_ns(uint64_t ns)
struct timespec time;
 
time.tv_sec = ns / ODP_TIME_SEC_IN_NS;
-   time.tv_nsec = ns % ODP_TIME_SEC_IN_NS;
+   time.tv_nsec = ns - time.tv_sec * ODP_TIME_SEC_IN_NS;
 
return time;
 }
@@ -102,10 +110,21 @@ uint64_t odp_time_to_u64(odp_time_t time)
 
resolution = (uint64_t)tres.tv_nsec;
 
-   return odp_time_to_ns(time) / resolution;
+   return time_to_ns(time) / resolutio

[lng-odp] [API-NEXT PATCH v7 7/9] validation: time: align tests with current time API

2015-12-04 Thread Ivan Khoronzhuk
Add test for odp_time_sum, odp_time_cmp, odp_time_to_u64 APIs.
Sophisticate a little tests for odp_time_diff, odp_time_local_from_ns,
odp_time_local_to_ns APIs. Check time on monotony.

Reviewed-by: Petri Savolainen 
Signed-off-by: Ivan Khoronzhuk 
---
 test/validation/time/time.c | 228 +++-
 test/validation/time/time.h |   7 +-
 2 files changed, 210 insertions(+), 25 deletions(-)

diff --git a/test/validation/time/time.c b/test/validation/time/time.c
index 3d05a6f..0303eb3 100644
--- a/test/validation/time/time.c
+++ b/test/validation/time/time.c
@@ -9,7 +9,107 @@
 #include "time.h"
 
 #define TOLERANCE 1
-#define BUSY_LOOP_CNT 100
+#define BUSY_LOOP_CNT  3000/* used for t > min resolution */
+#define BUSY_LOOP_CNT_LONG 120 /* used for t > 4 sec */
+
+
+/* check that related conversions come back to the same value */
+void time_test_odp_conversion(void)
+{
+   uint64_t ns1, ns2;
+   odp_time_t time;
+   uint64_t upper_limit, lower_limit;
+
+   ns1 = 100;
+   time = odp_time_local_from_ns(ns1);
+
+   ns2 = odp_time_to_ns(time);
+
+   /* need to check within arithmetic tolerance that the same
+* value in ns is returned after conversions */
+   upper_limit = ns1 + TOLERANCE;
+   lower_limit = ns1 - TOLERANCE;
+   CU_ASSERT((ns2 <= upper_limit) && (ns2 >= lower_limit));
+
+   ns1 = 60 * 11 * ODP_TIME_SEC_IN_NS;
+   time = odp_time_local_from_ns(ns1);
+
+   ns2 = odp_time_to_ns(time);
+
+   /* need to check within arithmetic tolerance that the same
+* value in ns is returned after conversions */
+   upper_limit = ns1 + TOLERANCE;
+   lower_limit = ns1 - TOLERANCE;
+   CU_ASSERT((ns2 <= upper_limit) && (ns2 >= lower_limit));
+}
+
+void time_test_monotony(void)
+{
+   volatile unsigned long count = 0;
+   odp_time_t t1, t2, t3;
+   uint64_t ns1, ns2, ns3;
+
+   t1 = odp_time_local();
+
+   while (count < BUSY_LOOP_CNT) {
+   count++;
+   };
+
+   t2 = odp_time_local();
+
+   while (count < BUSY_LOOP_CNT_LONG) {
+   count++;
+   };
+
+   t3 = odp_time_local();
+
+   ns1 = odp_time_to_ns(t1);
+   ns2 = odp_time_to_ns(t2);
+   ns3 = odp_time_to_ns(t3);
+
+   CU_ASSERT(ns2 > ns1);
+   CU_ASSERT(ns3 > ns2);
+}
+
+void time_test_odp_cmp(void)
+{
+   /* volatile to stop optimization of busy loop */
+   volatile int count = 0;
+   odp_time_t t1, t2, t3;
+
+   t1 = odp_time_local();
+
+   while (count < BUSY_LOOP_CNT) {
+   count++;
+   };
+
+   t2 = odp_time_local();
+
+   while (count < BUSY_LOOP_CNT * 2) {
+   count++;
+   };
+
+   t3 = odp_time_local();
+
+   CU_ASSERT(odp_time_cmp(t2, t1) > 0);
+   CU_ASSERT(odp_time_cmp(t3, t2) > 0);
+   CU_ASSERT(odp_time_cmp(t3, t1) > 0);
+   CU_ASSERT(odp_time_cmp(t1, t2) < 0);
+   CU_ASSERT(odp_time_cmp(t2, t3) < 0);
+   CU_ASSERT(odp_time_cmp(t1, t3) < 0);
+   CU_ASSERT(odp_time_cmp(t1, t1) == 0);
+   CU_ASSERT(odp_time_cmp(t2, t2) == 0);
+   CU_ASSERT(odp_time_cmp(t3, t3) == 0);
+
+   t2 = odp_time_local_from_ns(60 * 10 * ODP_TIME_SEC_IN_NS);
+   t1 = odp_time_local_from_ns(3);
+
+   CU_ASSERT(odp_time_cmp(t2, t1) > 0);
+   CU_ASSERT(odp_time_cmp(t1, t2) < 0);
+
+   t1 = odp_time_local_from_ns(0);
+   CU_ASSERT(odp_time_cmp(t1, ODP_TIME_NULL) == 0);
+}
 
 /* check that a time difference gives a reasonable result */
 void time_test_odp_diff(void)
@@ -17,7 +117,10 @@ void time_test_odp_diff(void)
/* volatile to stop optimization of busy loop */
volatile int count = 0;
odp_time_t diff, t1, t2;
+   uint64_t nsdiff, ns1, ns2, ns;
+   uint64_t upper_limit, lower_limit;
 
+   /* test timestamp diff */
t1 = odp_time_local();
 
while (count < BUSY_LOOP_CNT) {
@@ -29,43 +132,122 @@ void time_test_odp_diff(void)
 
diff = odp_time_diff(t2, t1);
CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0);
-}
 
-/* check that a negative time difference gives a reasonable result */
-void time_test_odp_negative_diff(void)
-{
-   odp_time_t diff, t1, t2;
+   ns1 = odp_time_to_ns(t1);
+   ns2 = odp_time_to_ns(t2);
+   ns = ns2 - ns1;
+   nsdiff = odp_time_to_ns(diff);
 
-   t1 = odp_time_local_from_ns(10);
-   t2 = odp_time_local_from_ns(5);
+   upper_limit = ns + TOLERANCE;
+   lower_limit = ns - TOLERANCE;
+   CU_ASSERT((nsdiff <= upper_limit) && (nsdiff >= lower_limit));
+
+   /* test timestamp and interval diff */
+   ns1 = 54;
+   t1 = odp_time_local_from_ns(ns1);
+   ns = ns2 - ns1;
+
+   diff = odp_time_diff(t2, t1);
+   CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0);
+   nsdiff = odp_time_to_ns(diff);
+
+   upper_limit = ns + TOLERANCE;
+   lower_limit = ns - TOLERANCE;
+   CU_ASSERT((nsdiff <= u

[lng-odp] [API-NEXT PATCH v7 6/9] api: time: make odp_local_time to be monotonic wall time

2015-12-04 Thread Ivan Khoronzhuk
It's more convenient the local time to be a monotonic wall time.
That means time starts from 0 and not wraps. It allows to use local
time in similar manner as it's supposed to be used with global time
and the 64-bit timer is enough to guarantee it.

Reviewed-by: Petri Savolainen 
Signed-off-by: Ivan Khoronzhuk 
---
 include/odp/api/time.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/odp/api/time.h b/include/odp/api/time.h
index 50a0bf5..9865d81 100644
--- a/include/odp/api/time.h
+++ b/include/odp/api/time.h
@@ -45,7 +45,8 @@ extern "C" {
  * Current local time
  *
  * Returns current local time stamp value. The local time source provides high
- * resolution time.
+ * resolution time, it is initialized to zero during ODP startup and will not
+ * wrap around in at least 10 years.
  *
  * @return Local time stamp.
  */
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCH v7 5/9] performance: sched: use ODP time API instead of clock_gettime

2015-12-04 Thread Ivan Khoronzhuk
The time API can be used instead of Posix clock_gettime as more
accurate and OS independent.

Reviewed-by: Petri Savolainen 
Signed-off-by: Ivan Khoronzhuk 
---
 test/performance/odp_scheduling.c | 37 +
 1 file changed, 9 insertions(+), 28 deletions(-)

diff --git a/test/performance/odp_scheduling.c 
b/test/performance/odp_scheduling.c
index 5d17c47..2c5262f 100644
--- a/test/performance/odp_scheduling.c
+++ b/test/performance/odp_scheduling.c
@@ -702,7 +702,7 @@ static void *run_thread(void *arg)
  */
 static void test_cpu_freq(void)
 {
-   struct timespec tp1, tp2;
+   odp_time_t cur_time, test_time, start_time, end_time;
uint64_t c1, c2, cycles;
uint64_t nsec;
double diff_max_hz, max_cycles;
@@ -710,40 +710,21 @@ static void test_cpu_freq(void)
printf("\nCPU cycle count frequency test (runs about %i sec)\n",
   TEST_SEC);
 
-   if (clock_gettime(CLOCK_MONOTONIC, &tp2)) {
-   LOG_ERR("clock_gettime failed.\n");
-   return;
-   }
-
-   /* Wait until clock moves to the next second. It enables easy comparison
-* during the measurement. */
-   do {
-   if (clock_gettime(CLOCK_MONOTONIC, &tp1)) {
-   LOG_ERR("clock_gettime failed.\n");
-   return;
-   }
-
-   } while (tp1.tv_sec == tp2.tv_sec);
+   test_time = odp_time_local_from_ns(TEST_SEC * ODP_TIME_SEC_IN_NS);
+   start_time = odp_time_local();
+   end_time = odp_time_sum(start_time, test_time);
 
/* Start the measurement */
c1 = odp_cpu_cycles();
 
do {
-   if (clock_gettime(CLOCK_MONOTONIC, &tp2)) {
-   LOG_ERR("clock_gettime failed.\n");
-   return;
-   }
-
-   } while ((tp2.tv_sec - tp1.tv_sec) < TEST_SEC);
+   cur_time = odp_time_local();
+   } while (odp_time_cmp(end_time, cur_time) > 0);
 
c2 = odp_cpu_cycles();
 
-   nsec = (tp2.tv_sec - tp1.tv_sec) * 10;
-
-   if (tp2.tv_nsec > tp1.tv_nsec)
-   nsec += tp2.tv_nsec - tp1.tv_nsec;
-   else
-   nsec -= tp1.tv_nsec - tp2.tv_nsec;
+   test_time = odp_time_diff(cur_time, start_time);
+   nsec = odp_time_to_ns(test_time);
 
cycles = odp_cpu_cycles_diff(c2, c1);
max_cycles = (nsec * odp_cpu_hz_max()) / 10.0;
@@ -751,7 +732,7 @@ static void test_cpu_freq(void)
/* Compare measured CPU cycles to maximum theoretical CPU cycle count */
diff_max_hz = ((double)(cycles) - max_cycles) / max_cycles;
 
-   printf("clock_gettime  %" PRIu64 " ns\n", nsec);
+   printf("odp_time   %" PRIu64 " ns\n", nsec);
printf("odp_cpu_cycles %" PRIu64 " CPU cycles\n", cycles);
printf("odp_sys_cpu_hz %" PRIu64 " hz\n", odp_cpu_hz_max());
printf("Diff from max CPU freq %f%%\n", diff_max_hz * 100.0);
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCH v7 4/9] linux-generic: odp_time: don't use cpu cycle API to get time

2015-12-04 Thread Ivan Khoronzhuk
The linux-generic time API implementation shouldn't depend on cpu
cycle API wich is not stable enough to measure time period due to
dynamic frequency scaling.

Reviewed-by: Petri Savolainen 
Signed-off-by: Ivan Khoronzhuk 
---
 platform/linux-generic/Makefile.am |   1 -
 .../linux-generic/include/odp/plat/time_types.h|   6 +-
 platform/linux-generic/include/odp_cpu_internal.h  |  29 --
 platform/linux-generic/odp_cpu.c   |   6 +-
 platform/linux-generic/odp_time.c  | 105 +
 5 files changed, 73 insertions(+), 74 deletions(-)
 delete mode 100644 platform/linux-generic/include/odp_cpu_internal.h

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 102f11e..ba220c0 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -110,7 +110,6 @@ noinst_HEADERS = \
  ${srcdir}/include/odp_timer_internal.h \
  ${srcdir}/include/odp_timer_wheel_internal.h \
  ${srcdir}/include/odp_traffic_mngr_internal.h \
- ${srcdir}/include/odp_cpu_internal.h \
  ${srcdir}/Makefile.inc
 
 __LIB__libodp_la_SOURCES = \
diff --git a/platform/linux-generic/include/odp/plat/time_types.h 
b/platform/linux-generic/include/odp/plat/time_types.h
index 9ba1508..e5765ec 100644
--- a/platform/linux-generic/include/odp/plat/time_types.h
+++ b/platform/linux-generic/include/odp/plat/time_types.h
@@ -21,9 +21,11 @@ extern "C" {
  *  @{
  **/
 
-typedef uint64_t odp_time_t;
+typedef struct timespec odp_time_t;
 
-#define ODP_TIME_NULL ((odp_time_t)0)
+odp_time_t odp_time_null(void);
+
+#define ODP_TIME_NULL  odp_time_null()
 
 /**
  * @}
diff --git a/platform/linux-generic/include/odp_cpu_internal.h 
b/platform/linux-generic/include/odp_cpu_internal.h
deleted file mode 100644
index 664e2df..000
--- a/platform/linux-generic/include/odp_cpu_internal.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (c) 2015, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef ODP_CPU_INTERNAL_H_
-#define ODP_CPU_INTERNAL_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include 
-
-static inline
-uint64_t _odp_cpu_cycles_diff(uint64_t c2, uint64_t c1)
-{
-   if (odp_likely(c2 >= c1))
-   return c2 - c1;
-
-   return c2 + (odp_cpu_cycles_max() - c1) + 1;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/platform/linux-generic/odp_cpu.c b/platform/linux-generic/odp_cpu.c
index 636f811..4bd6a9a 100644
--- a/platform/linux-generic/odp_cpu.c
+++ b/platform/linux-generic/odp_cpu.c
@@ -6,9 +6,11 @@
 
 #include 
 #include 
-#include 
 
 uint64_t odp_cpu_cycles_diff(uint64_t c2, uint64_t c1)
 {
-   return _odp_cpu_cycles_diff(c2, c1);
+   if (odp_likely(c2 >= c1))
+   return c2 - c1;
+
+   return c2 + (odp_cpu_cycles_max() - c1) + 1;
 }
diff --git a/platform/linux-generic/odp_time.c 
b/platform/linux-generic/odp_time.c
index a2e4046..89bbf0c 100644
--- a/platform/linux-generic/odp_time.c
+++ b/platform/linux-generic/odp_time.c
@@ -6,81 +6,106 @@
 
 #define _POSIX_C_SOURCE 200809L
 
+#include 
 #include 
 #include 
-#include 
-#include 
-#include 
+#include 
 
-#define GIGA 10
-
-static inline
-uint64_t time_to_tick(odp_time_t time)
+odp_time_t odp_time_local(void)
 {
-   return (uint64_t)time;
-}
+   int ret;
+   struct timespec time;
 
-static inline
-odp_time_t tick_to_time(uint64_t tick)
-{
-   return (odp_time_t)tick;
-}
+   ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time);
+   if (odp_unlikely(ret != 0))
+   ODP_ABORT("clock_gettime failed\n");
 
-odp_time_t odp_time_local(void)
-{
-   return tick_to_time(odp_cpu_cycles());
+   return time;
 }
 
 odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1)
 {
-   return tick_to_time(_odp_cpu_cycles_diff(t2, t1));
+   uint64_t ns1, ns2;
+   struct timespec time;
+
+   ns1 = odp_time_to_ns(t1);
+   ns2 = odp_time_to_ns(t2);
+   if (ns2 < ns1)
+   return (struct timespec) {0, 1};
+
+   time.tv_sec = t2.tv_sec - t1.tv_sec;
+   time.tv_nsec = t2.tv_nsec - t1.tv_nsec;
+
+   if (time.tv_nsec < 0) {
+   time.tv_nsec += ODP_TIME_SEC_IN_NS;
+   --time.tv_sec;
+   }
+
+   return time;
 }
 
 uint64_t odp_time_to_ns(odp_time_t time)
 {
-   uint64_t hz = odp_cpu_hz_max();
-   uint64_t tick = time_to_tick(time);
+   uint64_t ns;
 
-   if (tick > (UINT64_MAX / GIGA))
-   return (tick / hz) * GIGA;
+   ns = time.tv_sec * ODP_TIME_SEC_IN_NS;
+   ns += time.tv_nsec;
 
-   return (tick * GIGA) / hz;
+   return ns;
 }
 
-
 odp_time_t odp_time_local_from_ns(uint64_t ns)
 {
-   uint64_t hz = odp_cpu_hz_max();
+   struct timespec time;
 
-   if (ns > (UINT64_MAX / hz))
-   return tick_to_time((ns / GIGA) * hz);
+   time.

[lng-odp] [API-NEXT PATCH v7 3/9] linux-generic: schedule: use schedule time in ns

2015-12-04 Thread Ivan Khoronzhuk
In the schedule_loop the wait time is passed in units of scheduler
time. At this moment there is no difference between wait time and
odp_time, but in case if odp_time is smth different from uint64_t,
it cannot be directly passed as uint64_t. So better to pass scheduler
time as ns and convert them before entering a loop.

Reviewed-by: Petri Savolainen 
Signed-off-by: Ivan Khoronzhuk 
---
 platform/linux-generic/odp_schedule.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/platform/linux-generic/odp_schedule.c 
b/platform/linux-generic/odp_schedule.c
index 884ae60..96b3ac5 100644
--- a/platform/linux-generic/odp_schedule.c
+++ b/platform/linux-generic/odp_schedule.c
@@ -586,11 +586,10 @@ static int schedule_loop(odp_queue_t *out_queue, uint64_t 
wait,
 odp_event_t out_ev[],
 unsigned int max_num, unsigned int max_deq)
 {
-   odp_time_t start_time, time, diff;
+   odp_time_t start_time, time, diff, wtime;
+   int first = 1;
int ret;
 
-   start_time = ODP_TIME_NULL;
-
while (1) {
ret = schedule(out_queue, out_ev, max_num, max_deq);
 
@@ -603,15 +602,17 @@ static int schedule_loop(odp_queue_t *out_queue, uint64_t 
wait,
if (wait == ODP_SCHED_NO_WAIT)
break;
 
-   if (!odp_time_cmp(ODP_TIME_NULL, start_time)) {
+   if (first) {
+   wtime = odp_time_local_from_ns(wait);
start_time = odp_time_local();
+   first = 0;
continue;
}
 
time = odp_time_local();
diff = odp_time_diff(time, start_time);
 
-   if (odp_time_cmp(wait, diff) < 0)
+   if (odp_time_cmp(wtime, diff) < 0)
break;
}
 
@@ -652,7 +653,7 @@ void odp_schedule_resume(void)
 
 uint64_t odp_schedule_wait_time(uint64_t ns)
 {
-   return odp_time_to_u64(odp_time_local_from_ns(ns));
+   return ns;
 }
 
 
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCH v7 1/9] validation: time: don't assign int directly to odp_time_t

2015-12-04 Thread Ivan Khoronzhuk
Under opaque type can be structure that cannot be used with direct
values, So, use conversion functions to get time_t to avoid build
issues.

Reviewed-by: Petri Savolainen 
Signed-off-by: Ivan Khoronzhuk 
---
 test/validation/time/time.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/validation/time/time.c b/test/validation/time/time.c
index f70c776..3d05a6f 100644
--- a/test/validation/time/time.c
+++ b/test/validation/time/time.c
@@ -36,8 +36,8 @@ void time_test_odp_negative_diff(void)
 {
odp_time_t diff, t1, t2;
 
-   t1 = 10;
-   t2 = 5;
+   t1 = odp_time_local_from_ns(10);
+   t2 = odp_time_local_from_ns(5);
diff = odp_time_diff(t2, t1);
CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0);
 }
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCH v7 2/9] test: performance: pktio: don't use direct arithmetic operations with odp_time_t

2015-12-04 Thread Ivan Khoronzhuk
It was missed while unbinding cycles from time API names.
Correct is as it prevents for adding structure under odp_time_t.

Reviewed-by: Petri Savolainen 
Signed-off-by: Ivan Khoronzhuk 
---
 test/performance/odp_pktio_perf.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/test/performance/odp_pktio_perf.c 
b/test/performance/odp_pktio_perf.c
index ffe9844..ec67d55 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -338,10 +338,13 @@ static void *run_thread_tx(void *arg)
cur_time = odp_time_local();
start_time   = cur_time;
burst_start_time = odp_time_diff(cur_time, burst_gap);
-   while (odp_time_diff(cur_time, start_time) < send_duration) {
+   while (odp_time_cmp(send_duration,
+   odp_time_diff(cur_time, start_time)) > 0) {
unsigned alloc_cnt = 0, tx_cnt;
 
-   if (odp_time_diff(cur_time, burst_start_time) < burst_gap) {
+   if (odp_time_cmp(burst_gap,
+odp_time_diff(cur_time, burst_start_time))
+> 0) {
cur_time = odp_time_local();
if (!odp_time_cmp(idle_start, ODP_TIME_NULL))
idle_start = cur_time;
@@ -357,7 +360,7 @@ static void *run_thread_tx(void *arg)
idle_start = ODP_TIME_NULL;
}
 
-   burst_start_time += burst_gap;
+   burst_start_time = odp_time_sum(burst_start_time, burst_gap);
 
alloc_cnt = alloc_packets(tx_event, batch_len - unsent_pkts);
if (alloc_cnt != batch_len)
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCH v7 0/9] api: time: update local time to be monotonic

2015-12-04 Thread Ivan Khoronzhuk
This series is intended to modify time API to be used as monotonic wall
time in order to simplify time API usage and create prerequisites for
adding global time API.

Since v6:
- changed patch order a little to pass validation tests
- fixed issue with pktio perf test
- no functional changes

Since v5:
  linux-generic: align with new wall time API
- deleted _odp prefix for local functions
- avoided modulo operation
- used common global var for start time

Since v3:
- "api: time: make odp_local_time to be monotonic wall time"
  splitted on;
  "linux-generic: align with new wall time API"
  "test/example: use local time API as wall time"
- increased BUSY_LOOP_CNT to fit in resolution and 4+ sec

Since v2:
- removed patch changing type of ODP_TIME_*
- added new patch:
  test: performance: pktio: don't use direct arithmetic operations with
odp_time_t
- added new patch:
  performance: sched: use ODP time API instead of clock_gettime
- combined monotonic and wall time patches
- removed odp_time_local_val() and odp_time_val_to_ns()
- replaced terms monotonic and wall in API desc

Since v1:
- corrected name of the series to be api-next
- use thread local for holding start time

Ivan Khoronzhuk (9):
  validation: time: don't assign int directly to odp_time_t
  test: performance: pktio: don't use direct arithmetic operations with
odp_time_t
  linux-generic: schedule: use schedule time in ns
  linux-generic: odp_time: don't use cpu cycle API to get time
  performance: sched: use ODP time API instead of clock_gettime
  api: time: make odp_local_time to be monotonic wall time
  validation: time: align tests with current time API
  linux-generic: align with new wall time API
  test/example: use local time API as wall time

 example/generator/odp_generator.c  |  10 +-
 include/odp/api/time.h |   3 +-
 platform/linux-generic/Makefile.am |   1 -
 .../linux-generic/include/odp/plat/time_types.h|   6 +-
 platform/linux-generic/include/odp_cpu_internal.h  |  29 ---
 platform/linux-generic/include/odp_internal.h  |   2 +
 platform/linux-generic/odp_cpu.c   |   6 +-
 platform/linux-generic/odp_init.c  |   4 +
 platform/linux-generic/odp_schedule.c  |  18 +-
 platform/linux-generic/odp_time.c  | 112 +++---
 test/performance/odp_pktio_perf.c  |  24 +--
 test/performance/odp_scheduling.c  |  37 +---
 test/validation/pktio/pktio.c  |  21 +-
 test/validation/time/time.c| 228 ++---
 test/validation/time/time.h|   7 +-
 15 files changed, 346 insertions(+), 162 deletions(-)
 delete mode 100644 platform/linux-generic/include/odp_cpu_internal.h

-- 
1.9.1

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


Re: [lng-odp] [PATCH] validation: scheduler: use fail timeout when waiting on events in chaos

2015-12-04 Thread Bill Fischofer
On Thu, Dec 3, 2015 at 10:37 AM, Ivan Khoronzhuk  wrote:

> In case if smth bad was happened and events are not received,
> it's better finish than looping forever.
>
> Signed-off-by: Ivan Khoronzhuk 
>

Reviewed-by: Bill Fischofer 


> ---
>  test/validation/scheduler/scheduler.c | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/test/validation/scheduler/scheduler.c
> b/test/validation/scheduler/scheduler.c
> index fb36d20..2e157a5 100644
> --- a/test/validation/scheduler/scheduler.c
> +++ b/test/validation/scheduler/scheduler.c
> @@ -46,6 +46,7 @@
>  #define CHAOS_DEBUG (CHAOS_NUM_ROUNDS < 1000)
>  #define CHAOS_PTR_TO_NDX(p) ((uint64_t)(uint32_t)(uintptr_t)p)
>  #define CHAOS_NDX_TO_PTR(n) ((void *)(uintptr_t)n)
> +#define CHAOS_WAIT_FAIL (5 * ODP_TIME_SEC_IN_NS)
>
>  /* Test global variables */
>  typedef struct {
> @@ -401,7 +402,7 @@ void scheduler_test_groups(void)
>
>  static void *chaos_thread(void *arg)
>  {
> -   uint64_t i;
> +   uint64_t i, wait;
> int rc;
> chaos_buf *cbuf;
> odp_event_t ev;
> @@ -417,8 +418,9 @@ static void *chaos_thread(void *arg)
> odp_barrier_wait(&globals->barrier);
>
> /* Run the test */
> +   wait = odp_schedule_wait_time(CHAOS_WAIT_FAIL);
> for (i = 0; i < CHAOS_NUM_ROUNDS * CHAOS_NUM_EVENTS; i++) {
> -   ev = odp_schedule(&from, ODP_SCHED_WAIT);
> +   ev = odp_schedule(&from, wait);
> CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID);
> cbuf = odp_buffer_addr(odp_buffer_from_event(ev));
> CU_ASSERT_FATAL(cbuf != NULL);
> @@ -481,6 +483,7 @@ void scheduler_test_chaos(void)
> odp_shm_t shm;
> odp_queue_t from;
> int i, rc;
> +   uint64_t wait;
> odp_schedule_sync_t sync[] = {ODP_SCHED_SYNC_NONE,
>   ODP_SCHED_SYNC_ATOMIC,
>   ODP_SCHED_SYNC_ORDERED};
> @@ -554,9 +557,10 @@ void scheduler_test_chaos(void)
>odp_thread_id());
>
> /* Cleanup: Drain queues, free events */
> +   wait = odp_schedule_wait_time(CHAOS_WAIT_FAIL);
> while (odp_atomic_fetch_dec_u32(
>&globals->chaos_pending_event_count) > 0) {
> -   ev = odp_schedule(&from, ODP_SCHED_WAIT);
> +   ev = odp_schedule(&from, wait);
> CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID);
> cbuf = odp_buffer_addr(odp_buffer_from_event(ev));
> if (CHAOS_DEBUG)
> --
> 1.9.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] helper: fix strncpy in table support

2015-12-04 Thread Bill Fischofer
On Thu, Dec 3, 2015 at 12:49 PM, Mike Holmes  wrote:

> Fixes Bug 1905 - CID 154167:
>
> Calling strncpy with a maximum size argument of ODP_TABLE_NAME_LEN
> bytes on destination array tbl->name of size ODP_TABLE_NAME_LEN bytes
> might leave the destination string unterminated if the copied string is
> also of the maximum size ODP_TABLE_NAME_LEN.
>
> Make the copy leave one char for the null terminator.
>
> Signed-off-by: Mike Holmes 
>

Reviewed-by: Bill Fischofer 


> ---
>  helper/hashtable.c   | 2 +-
>  helper/lineartable.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/helper/hashtable.c b/helper/hashtable.c
> index 1121beb..e0f562e 100644
> --- a/helper/hashtable.c
> +++ b/helper/hashtable.c
> @@ -92,7 +92,7 @@ odph_table_t odph_hash_table_create(const char *name,
> uint32_t capacity,
> memset(tbl, 0, capacity << 20);
>
> tbl->init_cap = capacity << 20;
> -   strncpy(tbl->name, name, ODPH_TABLE_NAME_LEN);
> +   strncpy(tbl->name, name, ODPH_TABLE_NAME_LEN - 1);
> tbl->key_size = key_size;
> tbl->value_size = value_size;
>
> diff --git a/helper/lineartable.c b/helper/lineartable.c
> index b0759f9..68d9350 100644
> --- a/helper/lineartable.c
> +++ b/helper/lineartable.c
> @@ -73,7 +73,7 @@ odph_table_t odph_linear_table_create(const char *name,
> uint32_t capacity,
>
> tbl->init_cap = capacity < 20;
>
> -   strncpy(tbl->name, name, ODPH_TABLE_NAME_LEN);
> +   strncpy(tbl->name, name, ODPH_TABLE_NAME_LEN - 1);
>
> /* for linear table, the key is just the index, without confict
>  * so we just need to record the value content
> --
> 2.5.0
>
> ___
> 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] [PATCHv2] helper : Fix UDP checksum computation

2015-12-04 Thread Bill Fischofer
On Thu, Oct 22, 2015 at 7:02 AM,  wrote:

> From: Grigore Ion 
>
> This patch fixes the following problems:
> - checksum computation for LE platforms
> - checksum is computed in the CPU endianness. The returned result
> must be converted to the BE ordering when it is used to update the
> UDP checksum in a packet.
> - checksum computation for packets having the UDP length not a
> multiple of 2.
>
> Signed-off-by: Grigore Ion 
>

Reviewed-by: Bill Fischofer 


> ---
>  v2:
>  - patch updated to the last master (Maxim Uvarov)
>  v1:
>  - Move variables declaration on top of block. (Maxim Uvarov)
>  - Check patch with checkpatch script.  (Maxim Uvarov)
>  - L3 header presence is tested twice. (Alexandru Badicioiu)
>  - Remove unnecessary check for L3 header presence. (Bill Fischofer)
>  - Modify check of odp_packet_l4_offset() return. (Bill Fischofer)
>
>  helper/include/odp/helper/udp.h |   32 +---
>  1 files changed, 13 insertions(+), 19 deletions(-)
>
> diff --git a/helper/include/odp/helper/udp.h
> b/helper/include/odp/helper/udp.h
> index 06c439b..6fce3f2 100644
> --- a/helper/include/odp/helper/udp.h
> +++ b/helper/include/odp/helper/udp.h
> @@ -44,20 +44,16 @@ typedef struct ODP_PACKED {
>   * This function uses odp packet to calc checksum
>   *
>   * @param pkt  calculate chksum for pkt
> - * @return  checksum value
> + * @return  checksum value in CPU endianness
>   */
>  static inline uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt)
>  {
> -   uint32_t sum = 0;
> +   uint32_t sum;
> odph_udphdr_t *udph;
> odph_ipv4hdr_t *iph;
> -   uint16_t udplen;
> -   uint8_t *buf;
> +   uint16_t udplen, *buf;
>
> -   if (!odp_packet_l3_offset(pkt))
> -   return 0;
> -
> -   if (!odp_packet_l4_offset(pkt))
> +   if (odp_packet_l4_offset(pkt) == ODP_PACKET_OFFSET_INVALID)
> return 0;
>
> iph = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
> @@ -67,23 +63,21 @@ static inline uint16_t
> odph_ipv4_udp_chksum(odp_packet_t pkt)
> /* 32-bit sum of all 16-bit words covered by UDP chksum */
> sum = (iph->src_addr & 0x) + (iph->src_addr >> 16) +
>   (iph->dst_addr & 0x) + (iph->dst_addr >> 16) +
> - (uint16_t)iph->proto + udplen;
> -   for (buf = (uint8_t *)udph; udplen > 1; udplen -= 2) {
> -   sum += ((*buf << 8) + *(buf + 1));
> -   buf += 2;
> -   }
> + odp_be_to_cpu_16(iph->proto) + udph->length;
> +   for (buf = (uint16_t *)((void *)udph); udplen > 1; udplen -= 2)
> +   sum += *buf++;
> +   if (udplen) /* If length is not a multiple of 2 bytes */
> +   sum += odp_be_to_cpu_16(*((uint8_t *)buf) << 8);
>
> /* Fold sum to 16 bits: add carrier to result */
> -   while (sum >> 16)
> -   sum = (sum & 0x) + (sum >> 16);
> +   sum = (sum & 0x) + (sum >> 16);
> +   sum += (sum >> 16);
>
> /* 1's complement */
> sum = ~sum;
>
> -   /* set computation result */
> -   sum = (sum == 0x0) ? 0x : sum;
> -
> -   return sum;
> +   /* set computation result in CPU endianness*/
> +   return (sum == 0x0) ? 0x : odp_be_to_cpu_16(sum);
>  }
>
>  /** @internal Compile time assert */
> --
> 1.7.3.4
>
> ___
> 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] [PATCHv2] validation:pktio : Fix UDP checksum computation

2015-12-04 Thread Bill Fischofer
On Thu, Oct 22, 2015 at 8:55 AM,  wrote:

> From: Grigore Ion 
>
> The UDP checksum is computed in the CPU endianness. The returned result
> must be converted to the BE ordering when it is used to update the UDP
> checksum in a packet.
>
> Signed-off-by: Grigore Ion 
>

Reviewed-by: Bill Fischofer 


> ---
> v2:
> - patch updated to the last master (Maxim Uvarov)
> v1:
> - Add PATCH version information (Maxim Uvarov)
> - Check patch with checkpatch script. (Bill Fischofer)
>
>  test/validation/pktio/pktio.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
> index d4b447a..7a878fe 100644
> --- a/test/validation/pktio/pktio.c
> +++ b/test/validation/pktio/pktio.c
> @@ -223,7 +223,7 @@ static int pktio_fixup_checksums(odp_packet_t pkt)
> ip->chksum = 0;
> odph_ipv4_csum_update(pkt);
> udp->chksum = 0;
> -   udp->chksum = odph_ipv4_udp_chksum(pkt);
> +   udp->chksum = odp_cpu_to_be_16(odph_ipv4_udp_chksum(pkt));
>
> return 0;
>  }
> --
> 1.7.3.4
>
> ___
> 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] doc: build users and implementers guide in the build tree instead of the source tree

2015-12-04 Thread Bill Fischofer
If the packaging philosophy is to put things into the build trees then this
would seem to be consistent since you'd want the documentation to be
packaged with the distribution.

On Fri, Dec 4, 2015 at 8:11 AM, Mike Holmes  wrote:

> git clean -xdf && ./bootstrap && mkdir doctest && cd doctest &&
> ../configure --enable-user-guides && make -C doc
>
> If you do this the doc will not have the images linked correctly, open the
> html to see this
> odp/doctest/doc/output/users-guide.html
>
> Currently the images get generated and stay in the image directory with
> the html pointing at them with ../images/
>
> What do you think about making the html and the images both get installed
> in the output directory ?
>
>
> On 2 December 2015 at 09:15, Nicolas Morey-Chaisemartin 
> wrote:
>
>> Signed-off-by: Nicolas Morey-Chaisemartin 
>
> ---
>>  doc/implementers-guide/Makefile.am | 4 ++--
>>  doc/users-guide/Makefile.am| 4 ++--
>>  2 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/doc/implementers-guide/Makefile.am
>> b/doc/implementers-guide/Makefile.am
>> index d653968..591e9d6 100644
>> --- a/doc/implementers-guide/Makefile.am
>> +++ b/doc/implementers-guide/Makefile.am
>> @@ -1,11 +1,11 @@
>> -TARGET = $(top_srcdir)/doc/output/implementers-guide.html
>> +TARGET = $(top_builddir)/doc/output/implementers-guide.html
>>
>>  EXTRA_DIST = implementers-guide.adoc
>>
>>  all-local: $(TARGET)
>>
>>  $(TARGET): implementers-guide.adoc
>> -   @mkdir -p $(top_srcdir)/doc/output
>> +   @mkdir -p $(top_builddir)/doc/output
>> asciidoc -b html5  -a icons -a toc2  -a max-width=55em
>> --out-file=$@ $<
>>
>>  clean-local:
>> diff --git a/doc/users-guide/Makefile.am b/doc/users-guide/Makefile.am
>> index 8e60312..700e03f 100644
>> --- a/doc/users-guide/Makefile.am
>> +++ b/doc/users-guide/Makefile.am
>> @@ -1,11 +1,11 @@
>> -TARGET = $(top_srcdir)/doc/output/users-guide.html
>> +TARGET = $(top_builddir)/doc/output/users-guide.html
>>
>>  EXTRA_DIST = users-guide.adoc
>>
>>  all-local: $(TARGET)
>>
>>  $(TARGET): users-guide.adoc
>> -   @mkdir -p $(top_srcdir)/doc/output
>> +   @mkdir -p $(top_builddir)/doc/output
>> asciidoc -b html5  -a icons -a toc2  -a max-width=55em
>> --out-file=$@ $<
>>
>>  clean-local:
>> --
>> 2.6.3.372.gcb93895
>>
>>
>
>
> --
> Mike Holmes
> Technical Manager - Linaro Networking Group
> Linaro.org  *│ *Open source software for ARM SoCs
>
>
>
> ___
> 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] doc: build users and implementers guide in the build tree instead of the source tree

2015-12-04 Thread Mike Holmes
git clean -xdf && ./bootstrap && mkdir doctest && cd doctest &&
../configure --enable-user-guides && make -C doc

If you do this the doc will not have the images linked correctly, open the
html to see this
odp/doctest/doc/output/users-guide.html

Currently the images get generated and stay in the image directory with the
html pointing at them with ../images/

What do you think about making the html and the images both get installed
in the output directory ?


On 2 December 2015 at 09:15, Nicolas Morey-Chaisemartin 
wrote:

> Signed-off-by: Nicolas Morey-Chaisemartin 

---
>  doc/implementers-guide/Makefile.am | 4 ++--
>  doc/users-guide/Makefile.am| 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/doc/implementers-guide/Makefile.am
> b/doc/implementers-guide/Makefile.am
> index d653968..591e9d6 100644
> --- a/doc/implementers-guide/Makefile.am
> +++ b/doc/implementers-guide/Makefile.am
> @@ -1,11 +1,11 @@
> -TARGET = $(top_srcdir)/doc/output/implementers-guide.html
> +TARGET = $(top_builddir)/doc/output/implementers-guide.html
>
>  EXTRA_DIST = implementers-guide.adoc
>
>  all-local: $(TARGET)
>
>  $(TARGET): implementers-guide.adoc
> -   @mkdir -p $(top_srcdir)/doc/output
> +   @mkdir -p $(top_builddir)/doc/output
> asciidoc -b html5  -a icons -a toc2  -a max-width=55em
> --out-file=$@ $<
>
>  clean-local:
> diff --git a/doc/users-guide/Makefile.am b/doc/users-guide/Makefile.am
> index 8e60312..700e03f 100644
> --- a/doc/users-guide/Makefile.am
> +++ b/doc/users-guide/Makefile.am
> @@ -1,11 +1,11 @@
> -TARGET = $(top_srcdir)/doc/output/users-guide.html
> +TARGET = $(top_builddir)/doc/output/users-guide.html
>
>  EXTRA_DIST = users-guide.adoc
>
>  all-local: $(TARGET)
>
>  $(TARGET): users-guide.adoc
> -   @mkdir -p $(top_srcdir)/doc/output
> +   @mkdir -p $(top_builddir)/doc/output
> asciidoc -b html5  -a icons -a toc2  -a max-width=55em
> --out-file=$@ $<
>
>  clean-local:
> --
> 2.6.3.372.gcb93895
>
>


-- 
Mike Holmes
Technical Manager - Linaro Networking Group
Linaro.org  *│ *Open source software for ARM SoCs
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [API-NEXT PATCH] linux-generic: tm: use odp_hash_crc32c() api to avoid arch issues

2015-12-04 Thread Bill Fischofer
Per our discussion a few moments ago, When I run the following:

GIT_BRANCH=api-next PATCH_DIR=$HOME/linaro/tmcrcfix CLEANUP=0 ./build.sh

it executes cleanly for me, so I'm not sure what the problem is.

On Fri, Dec 4, 2015 at 5:52 AM, Maxim Uvarov 
wrote:

> Bill, here is the same problem which I had with mine updated IPC patches.
>
> odp-check says that there is no hash_main binary so test fails.
>
> I think something like that is needed. But it does not help:
>
> +++ b/test/validation/hash/Makefile.am
> @@ -3,7 +3,7 @@ include ../Makefile.inc
>  noinst_LTLIBRARIES = libtesthash.la
>  libtesthash_la_SOURCES = hash.c
>
> -bin_PROGRAMS = hash_main$(EXEEXT)
> +test_PROGRAMS = hash_main$(EXEEXT)
>
> CC Anders as autotools expert :)
>
> Maxim.
>
>
> On 12/04/2015 06:49, Bill Fischofer wrote:
>
>> Ping.  This patch needs a review as it fixes critical bug
>> https://bugs.linaro.org/show_bug.cgi?id=1930 that is breaking CI for
>> api-next.
>>
>> Thanks.
>>
>> On Wed, Dec 2, 2015 at 3:56 PM, Bill Fischofer > > wrote:
>>
>> Change the internal hash_name_and_kind() function to eliminate the use
>> of architecture-specific hash instructions. This eliminates build
>> issues
>> surrounding ARM variants. Future optimizations will use the arch
>> directory
>> consistent with other ODP modules.
>>
>> Signed-off-by: Bill Fischofer > >
>>
>> ---
>>  platform/linux-generic/odp_name_table.c | 182
>> +---
>>  1 file changed, 1 insertion(+), 181 deletions(-)
>>
>> diff --git a/platform/linux-generic/odp_name_table.c
>> b/platform/linux-generic/odp_name_table.c
>> index 10a760e..610f034 100644
>> --- a/platform/linux-generic/odp_name_table.c
>> +++ b/platform/linux-generic/odp_name_table.c
>> @@ -48,140 +48,6 @@
>>
>>  #define SECONDARY_HASH_HISTO_PRINT  1
>>
>> - /* #define USE_AES */
>> -
>> -#if defined __x86_64__ || defined __i386__
>> -
>> -#ifdef USE_AES
>> -
>> -typedef long long int v2di __attribute__((vector_size(16)));
>> -
>> -static const v2di HASH_CONST1 = { 0x123456,  0xFEBCDA383   };
>> -static const v2di HASH_CONST2 = { 0x493BA3F689, 0x102F5D73A8C };
>> -
>> -#define PLATFORM_HASH_STATE v2di
>> -
>> -#define PLATFORM_HASH32_INIT(hash_state, name_len) \
>> -   ({ \
>> -   hash_state = HASH_CONST1;\
>> -   hash_state[0] ^= name_len; \
>> -   })
>> -
>> -#define PLATFORM_HASH32(hash_state, name_word)\
>> -   ({\
>> -   v2di data;\
>> -   \
>> -   data[0]= name_word;   \
>> -   data[1]= name_word << 1;   \
>> -   hash_state = __builtin_ia32_aesenc128(hash_state,
>> data); \
>> -   })
>> -
>> -#define PLATFORM_HASH32_FINISH(hash_state, kind) \
>> -   ({ \
>> -   uint64_t result; \
>> -   v2di data; \
>> -\
>> -   data[0]= name_kind;\
>> -   data[1]= name_kind << 7;   \
>> -   hash_state = __builtin_ia32_aesenc128(hash_state,
>> data); \
>> -   hash_state = __builtin_ia32_aesenc128(hash_state,
>>   \
>> -  HASH_CONST2); \
>> -   hash_state = __builtin_ia32_aesenc128(hash_state,
>>   \
>> -  HASH_CONST1); \
>> -   result = (uint64_t)hash_state[0] ^
>> hash_state[1];   \
>> -   result = result ^ result >> 32;  \
>> -   (uint32_t)result;\
>> -   })
>> -
>> -#else
>> -
>> -#define PLATFORM_HASH_STATE uint64_t
>> -
>> -#define PLATFORM_HASH32_INIT(hash_state, name_len)\
>> -   ({\
>> -   hash_state  = (uint64_t)name_len; \
>> -   hash_state |= hash_state << 8; \
>> -   hash_state |= hash_state << 16;  \
>> -   hash_state |= hash_state << 32;\
>> -   })
>> -
>> -#define PLATFORM_HASH32(hash_state, name_word) \
>> -   ({ \
>> -   uint64_t temp; \
>> -\
>> -   temp= ((uint64_t)name_word) * 0xFEFDFCF5;
>>   \
>> -   hash_state  = hash_state * 0xFF; \
>> -   hash_state ^= temp ^ (uint64_t)name_word;\
>> -   })
>> -
>> -#define PLATFORM_HASH32_FINISH(hash_state, kind) \
>> -   ({ \
>> -   hash_state ^= (((uint32_t)kind) << 13); \
>> -   hash_state  = hash_state * 0xF

Re: [lng-odp] [PATCHv2] validation:pktio : Fix UDP checksum computation

2015-12-04 Thread Ion Grigore
Hi,

What is the status of this patch ?

"pktio" test application may fail on LE platforms.

Thanks,
Grig

-Original Message-
From: ion.grig...@freescale.com [mailto:ion.grig...@freescale.com] 
Sent: Thursday, October 22, 2015 4:56 PM
To: lng-odp@lists.linaro.org
Cc: Grigore Ion-B17953 
Subject: [PATCHv2] validation:pktio : Fix UDP checksum computation

From: Grigore Ion 

The UDP checksum is computed in the CPU endianness. The returned result must be 
converted to the BE ordering when it is used to update the UDP checksum in a 
packet.

Signed-off-by: Grigore Ion 
---
v2:
- patch updated to the last master (Maxim Uvarov)
v1:
- Add PATCH version information (Maxim Uvarov)
- Check patch with checkpatch script. (Bill Fischofer)

 test/validation/pktio/pktio.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c 
index d4b447a..7a878fe 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -223,7 +223,7 @@ static int pktio_fixup_checksums(odp_packet_t pkt)
ip->chksum = 0;
odph_ipv4_csum_update(pkt);
udp->chksum = 0;
-   udp->chksum = odph_ipv4_udp_chksum(pkt);
+   udp->chksum = odp_cpu_to_be_16(odph_ipv4_udp_chksum(pkt));
 
return 0;
 }
--
1.7.3.4

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


Re: [lng-odp] [PATCHv2] helper : Fix UDP checksum computation

2015-12-04 Thread Ion Grigore
Hi,

What is the status of this patch ?

Example or test applications using odph_ipv4_udp_chksum function
may fail on LE platforms.

Thanks,
Grig

-Original Message-
From: ion.grig...@freescale.com [mailto:ion.grig...@freescale.com] 
Sent: Thursday, October 22, 2015 3:03 PM
To: lng-odp@lists.linaro.org
Cc: Grigore Ion-B17953 
Subject: [PATCHv2] helper : Fix UDP checksum computation

From: Grigore Ion 

This patch fixes the following problems:
- checksum computation for LE platforms
- checksum is computed in the CPU endianness. The returned result must be 
converted to the BE ordering when it is used to update the UDP checksum in a 
packet.
- checksum computation for packets having the UDP length not a multiple of 2.

Signed-off-by: Grigore Ion 
---
 v2:
 - patch updated to the last master (Maxim Uvarov)
 v1:
 - Move variables declaration on top of block. (Maxim Uvarov)
 - Check patch with checkpatch script.  (Maxim Uvarov)
 - L3 header presence is tested twice. (Alexandru Badicioiu)
 - Remove unnecessary check for L3 header presence. (Bill Fischofer)
 - Modify check of odp_packet_l4_offset() return. (Bill Fischofer)

 helper/include/odp/helper/udp.h |   32 +---
 1 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/helper/include/odp/helper/udp.h b/helper/include/odp/helper/udp.h 
index 06c439b..6fce3f2 100644
--- a/helper/include/odp/helper/udp.h
+++ b/helper/include/odp/helper/udp.h
@@ -44,20 +44,16 @@ typedef struct ODP_PACKED {
  * This function uses odp packet to calc checksum
  *
  * @param pkt  calculate chksum for pkt
- * @return  checksum value
+ * @return  checksum value in CPU endianness
  */
 static inline uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt)  {
-   uint32_t sum = 0;
+   uint32_t sum;
odph_udphdr_t *udph;
odph_ipv4hdr_t *iph;
-   uint16_t udplen;
-   uint8_t *buf;
+   uint16_t udplen, *buf;
 
-   if (!odp_packet_l3_offset(pkt))
-   return 0;
-
-   if (!odp_packet_l4_offset(pkt))
+   if (odp_packet_l4_offset(pkt) == ODP_PACKET_OFFSET_INVALID)
return 0;
 
iph = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); @@ -67,23 +63,21 
@@ static inline uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt)
/* 32-bit sum of all 16-bit words covered by UDP chksum */
sum = (iph->src_addr & 0x) + (iph->src_addr >> 16) +
  (iph->dst_addr & 0x) + (iph->dst_addr >> 16) +
- (uint16_t)iph->proto + udplen;
-   for (buf = (uint8_t *)udph; udplen > 1; udplen -= 2) {
-   sum += ((*buf << 8) + *(buf + 1));
-   buf += 2;
-   }
+ odp_be_to_cpu_16(iph->proto) + udph->length;
+   for (buf = (uint16_t *)((void *)udph); udplen > 1; udplen -= 2)
+   sum += *buf++;
+   if (udplen) /* If length is not a multiple of 2 bytes */
+   sum += odp_be_to_cpu_16(*((uint8_t *)buf) << 8);
 
/* Fold sum to 16 bits: add carrier to result */
-   while (sum >> 16)
-   sum = (sum & 0x) + (sum >> 16);
+   sum = (sum & 0x) + (sum >> 16);
+   sum += (sum >> 16);
 
/* 1's complement */
sum = ~sum;
 
-   /* set computation result */
-   sum = (sum == 0x0) ? 0x : sum;
-
-   return sum;
+   /* set computation result in CPU endianness*/
+   return (sum == 0x0) ? 0x : odp_be_to_cpu_16(sum);
 }
 
 /** @internal Compile time assert */
--
1.7.3.4

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


Re: [lng-odp] [API-NEXT PATCH] linux-generic: tm: use odp_hash_crc32c() api to avoid arch issues

2015-12-04 Thread Maxim Uvarov

Bill, here is the same problem which I had with mine updated IPC patches.

odp-check says that there is no hash_main binary so test fails.

I think something like that is needed. But it does not help:

+++ b/test/validation/hash/Makefile.am
@@ -3,7 +3,7 @@ include ../Makefile.inc
 noinst_LTLIBRARIES = libtesthash.la
 libtesthash_la_SOURCES = hash.c

-bin_PROGRAMS = hash_main$(EXEEXT)
+test_PROGRAMS = hash_main$(EXEEXT)

CC Anders as autotools expert :)

Maxim.


On 12/04/2015 06:49, Bill Fischofer wrote:
Ping.  This patch needs a review as it fixes critical bug 
https://bugs.linaro.org/show_bug.cgi?id=1930 that is breaking CI for 
api-next.


Thanks.

On Wed, Dec 2, 2015 at 3:56 PM, Bill Fischofer 
mailto:bill.fischo...@linaro.org>> wrote:


Change the internal hash_name_and_kind() function to eliminate the use
of architecture-specific hash instructions. This eliminates build
issues
surrounding ARM variants. Future optimizations will use the arch
directory
consistent with other ODP modules.

Signed-off-by: Bill Fischofer mailto:bill.fischo...@linaro.org>>
---
 platform/linux-generic/odp_name_table.c | 182
+---
 1 file changed, 1 insertion(+), 181 deletions(-)

diff --git a/platform/linux-generic/odp_name_table.c
b/platform/linux-generic/odp_name_table.c
index 10a760e..610f034 100644
--- a/platform/linux-generic/odp_name_table.c
+++ b/platform/linux-generic/odp_name_table.c
@@ -48,140 +48,6 @@

 #define SECONDARY_HASH_HISTO_PRINT  1

- /* #define USE_AES */
-
-#if defined __x86_64__ || defined __i386__
-
-#ifdef USE_AES
-
-typedef long long int v2di __attribute__((vector_size(16)));
-
-static const v2di HASH_CONST1 = { 0x123456,  0xFEBCDA383   };
-static const v2di HASH_CONST2 = { 0x493BA3F689, 0x102F5D73A8C };
-
-#define PLATFORM_HASH_STATE v2di
-
-#define PLATFORM_HASH32_INIT(hash_state, name_len) \
-   ({ \
-   hash_state = HASH_CONST1;\
-   hash_state[0] ^= name_len; \
-   })
-
-#define PLATFORM_HASH32(hash_state, name_word)\
-   ({\
-   v2di data;\
-   \
-   data[0]= name_word;   \
-   data[1]= name_word << 1;   \
-   hash_state = __builtin_ia32_aesenc128(hash_state,
data); \
-   })
-
-#define PLATFORM_HASH32_FINISH(hash_state, kind) \
-   ({ \
-   uint64_t result; \
-   v2di data; \
-\
-   data[0]= name_kind;\
-   data[1]= name_kind << 7;   \
-   hash_state = __builtin_ia32_aesenc128(hash_state,
data); \
-   hash_state = __builtin_ia32_aesenc128(hash_state, 
 \

-  HASH_CONST2); \
-   hash_state = __builtin_ia32_aesenc128(hash_state, 
 \

-  HASH_CONST1); \
-   result = (uint64_t)hash_state[0] ^
hash_state[1];   \
-   result = result ^ result >> 32;  \
-   (uint32_t)result;\
-   })
-
-#else
-
-#define PLATFORM_HASH_STATE uint64_t
-
-#define PLATFORM_HASH32_INIT(hash_state, name_len)\
-   ({\
-   hash_state  = (uint64_t)name_len; \
-   hash_state |= hash_state << 8; \
-   hash_state |= hash_state << 16;  \
-   hash_state |= hash_state << 32;\
-   })
-
-#define PLATFORM_HASH32(hash_state, name_word) \
-   ({ \
-   uint64_t temp; \
-\
-   temp= ((uint64_t)name_word) * 0xFEFDFCF5; 
 \

-   hash_state  = hash_state * 0xFF; \
-   hash_state ^= temp ^ (uint64_t)name_word;\
-   })
-
-#define PLATFORM_HASH32_FINISH(hash_state, kind) \
-   ({ \
-   hash_state ^= (((uint32_t)kind) << 13); \
-   hash_state  = hash_state * 0xFEFDFCF5; \
-   hash_state  = hash_state ^ hash_state >> 32;\
-   hash_state  = hash_state % 0xFEEDDCCBBAA1; \
-   hash_state  = hash_state ^ hash_state >> 32;\
-   (uint32_t)hash_state;\
-   })
-
-#endif
-
-#elif defined(__tile_gx__)
-
-#define PLATFORM_HASH_STATE  uint32_t
-
-#define PLATFORM_HASH32_INIT(hash_state, name_len) \
-   ({ \
-   hash_state = 0xFEFDFCF5;\
-   hash_state = __insn_crc_32_32(hash_sta

Re: [lng-odp] [API-NEXT PATCH v6] 0/9] api: time: update local time to be monotonic

2015-12-04 Thread Ivan Khoronzhuk

Lets check with HO, they were applied fine last time.

On 04.12.15 11:36, Maxim Uvarov wrote:

Hello Ivan,

The hole patch set looks like good. But it looks like patch order is wrong or 
some patches needs to be merged.

If I apply only 8 patches there is error:
   Test: time_test_odp_negative_diff ...FAILED
 1. time.c:42  - odp_time_cmp(diff, ODP_TIME_NULL) > 0

If only 7 patches then odp_pktio_perf test fails.

Also running odp-check I saw segfault on some patches.

And patches short message is: "[API-NEXT PATCH v6] 0/9]", but it has to be [API-NEXT 
PATCHv6 0/9]".

Maxim.

On 12/03/2015 17:07, Savolainen, Petri (Nokia - FI/Espoo) wrote:

Entire patch set:

Reviewed-by: Petri Savolainen 




-Original Message-
From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT
Ivan Khoronzhuk
Sent: Thursday, December 03, 2015 2:49 PM
To: lng-odp@lists.linaro.org
Subject: [lng-odp] [API-NEXT PATCH v6] 0/9] api: time: update local time
to be monotonic

This series is intended to modify time API to be used as monotonic wall
time in order to simplify time API usage and create prerequisites for
adding global time API.

Since v5
   linux-generic: align with new wall time API
- deleted _odp prefix for local functions
- avoided modulo operation
- used common global var for start time

Since v3:
- "api: time: make odp_local_time to be monotonic wall time"
   splitted on;
   "linux-generic: align with new wall time API"
   "test/example: use local time API as wall time"
- increased BUSY_LOOP_CNT to fit in resolution and 4+ sec

Since v2:
- removed patch changing type of ODP_TIME_*
- added new patch:
   test: performance: pktio: don't use direct arithmetic operations with
 odp_time_t
- added new patch:
   performance: sched: use ODP time API instead of clock_gettime
- combined monotonic and wall time patches
- removed odp_time_local_val() and odp_time_val_to_ns()
- replaced terms monotonic and wall in API desc

Since v1:
- corrected name of the series to be api-next
- use thread local for holding start time

Ivan Khoronzhuk (9):
   validation: time: don't assign int directly to odp_time_t
   test: performance: pktio: don't use direct arithmetic operations with
 odp_time_t
   linux-generic: schedule: use schedule time in ns
   linux-generic: odp_time: don't use cpu cycle API to get time
   performance: sched: use ODP time API instead of clock_gettime
   api: time: make odp_local_time to be monotonic wall time
   linux-generic: align with new wall time API
   test/example: use local time API as wall time
   validation: time: align tests with current time API

  example/generator/odp_generator.c  |  10 +-
  include/odp/api/time.h |   3 +-
  platform/linux-generic/Makefile.am |   1 -
  .../linux-generic/include/odp/plat/time_types.h|   6 +-
  platform/linux-generic/include/odp_cpu_internal.h  |  29 ---
  platform/linux-generic/include/odp_internal.h  |   2 +
  platform/linux-generic/odp_cpu.c   |   6 +-
  platform/linux-generic/odp_init.c  |   4 +
  platform/linux-generic/odp_schedule.c  |  18 +-
  platform/linux-generic/odp_time.c  | 112 +++---
  test/performance/odp_pktio_perf.c  |  24 +--
  test/performance/odp_scheduling.c  |  37 +---
  test/validation/pktio/pktio.c  |  21 +-
  test/validation/time/time.c| 228
++---
  test/validation/time/time.h|   7 +-
  15 files changed, 346 insertions(+), 162 deletions(-)
  delete mode 100644 platform/linux-generic/include/odp_cpu_internal.h

--
1.9.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


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


Re: [lng-odp] [PATCHv2 0/3] TAP pktio

2015-12-04 Thread Maxim Uvarov

Hi Stuart,

can you please also review that pktio change?

Maxim.

On 12/02/2015 16:13, Ilya Maximets wrote:

Creates a new pktio type that allows for creating and
sending/receiving packets through TAP interface.
Detailed description in commit-message of patch
"[PATCHv2 2/3] linux-generic: pktio: add tap pktio type".

Changelog:

Version 2:
* Validation tests added
* Pktio tests fixed to work with real-world
  interfaces.
* MAC of pktio now is not a kernel interface's MAC
* Interfaces are UP after pktio_open()
* Fixed getting mtu, getting/setting promisc mode
* Misclenious fixes

Ilya Maximets (3):
   validation: pktio: initialize mac addresses for all packets
   linux-generic: pktio: add tap pktio type
   linux-generic: pktio: add test for tap pktio

  platform/linux-generic/Makefile.am |   2 +
  .../linux-generic/include/odp_packet_io_internal.h |   3 +
  platform/linux-generic/include/odp_packet_tap.h|  21 ++
  platform/linux-generic/pktio/io_ops.c  |   1 +
  platform/linux-generic/pktio/tap.c | 317 +
  platform/linux-generic/test/Makefile.am|   1 +
  platform/linux-generic/test/pktio/Makefile.am  |   3 +-
  platform/linux-generic/test/pktio/pktio_run_tap| 111 
  test/validation/pktio/pktio.c  |  46 ++-
  9 files changed, 497 insertions(+), 8 deletions(-)
  create mode 100644 platform/linux-generic/include/odp_packet_tap.h
  create mode 100644 platform/linux-generic/pktio/tap.c
  create mode 100755 platform/linux-generic/test/pktio/pktio_run_tap



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


Re: [lng-odp] [API-NEXT PATCH] api: pool: redefine packet user area init

2015-12-04 Thread Savolainen, Petri (Nokia - FI/Espoo)


> -Original Message-
> From: EXT Zoltan Kiss [mailto:zoltan.k...@linaro.org]
> Sent: Thursday, December 03, 2015 8:27 PM
> To: Savolainen, Petri (Nokia - FI/Espoo); lng-odp@lists.linaro.org
> Subject: Re: [lng-odp] [API-NEXT PATCH] api: pool: redefine packet user
> area init
> 
> 
> 
> On 03/12/15 09:52, Savolainen, Petri (Nokia - FI/Espoo) wrote:
> >>> Why? Why do you need to access the packet, when it's not yet a packet
> >> (at init time)? You'll get handle after the packet is received (when
> it's
> >> a packet).
> >>
> >> I think I've explained it several times why this whole thing is
> >> necessary, but let me try again: OVS needs to store the packet handle
> in
> >> the user area (in a field in struct dp_packet), so it doesn't have to
> do
> >> that every time it receives a packet. It needs the packet handle so it
> >> can use it in odp_packet_*() calls. If we store a yet-another-unique-id
> >> instead, we would need to get the handle in some way.
> >> So in this user area init function it doesn't need to access it as a
> >> packet, but only to store the handle. Also, through the handle it can
> >> retrieve the user area pointer and size (though the app should know the
> >> latter), and the pool handle.
> >>
> >> Petri, let's cut this short: if you don't agree that the packet handle
> >> should be a parameter of the user init function, please say that, and
> >> I'll send a revert patch to api-next to revoke my original, and let's
> >> forget this whole thing, the small performance gain doesn't prove the
> >> additional engineering effort.
> >> We had a working proposal, in the past one week I've spend >6 hours
> >> trying to explain why your proposed changes make the whole thing
> >> useless. It simply doesn't seem to work out. If someone needs this
> >> thing, we can just recommend them to use DPDK.
> >
> >
> > Is said before, the main problem is that you cache a (packet) handle and
> expect the handle remains the same between destroy (packet free) and
> create calls (alloc).
> 
> Yes, and I expect if the platform can't guarantee that the handle
> remains the same, it should run the init function when it generates the
> new handle. In other words: the init function is called when the handle
> is generated AND associated with the underlying memory. Platforms which
> do either of these for a new packet couldn't win performance with this
> init function, but the others could.

If packet handle is associated with user area, implementation must call init 
every time it changes the binding, even when user does not cache handle in 
there. When handle and area are separated, user is responsible to update the 
handle when caching it. If it does not cache the handle, neither user or 
implementation does not need to call init or update the handle.

> 
> > You cannot do the same to other handle type (e.g. queues) either.
> 
> And I don't plan anything similar to other handle types either.
> 
> > In addition to index or pointer, a  handle may carry implementation
> specific information: generation counter, thread or HW block ID which
> allocated it, etc. Separate alloc calls, may result different handles for
> debugging, HW specific or performance optimization reasons.
> >
> > What you can still do, is:
> > - ask for persistent user area and init the packet handle to invalid
> 
> Btw. I've mentioned in an another mail that the persistent ("type 1")
> approach is flawed: the app don't have an easy way to access those
> preallocated resources in the user area.
> My understanding is that the benefit would be that you can store there
> preallocated resources (e.g. a timer for every packet), and you win on
> avoiding allocating them. But what happens if it wants to free them?
> E.g. because you destroy the pool? Or destroy the pool where these
> timers come from? Or you need to release just some of them? Or iterate
> through them for some reason?

timer_t packet_timer[MAX_NUM_PACKETS];

create_timers()
{
for(i=0; i < MAX_NUM_PACKETS; i++)
packet_timer[i] = create_timer();
}

destroy_timers()
{
for(i=0; i < MAX_NUM_PACKETS; i++)
destroy_timer(packet_timer[i]);
}

struct packet_ctx
{
timer_t timer;
};

user_area_init(odp_pool_t pool, void *init_arg, void *user_area, uint32_t size, 
uint32_t pkt_index)
{
struct packet_ctx *ctx = user_area;

ctx->timer = packet_timer[pkt_index];
}


You run create_timers() before pool creation and destroy_timers() after pool 
destroy. You have dedicated timer for every packet, but don't care which timer 
serves which incoming packet. Maximum number of packet in a pool cannot be 
changed dynamically. But if it could 'pkt_index' would continue from where it 
was left of in original pool creation.





> 
> > - when received a packet: compare if, received packet handle == cached
> packet handle
> > - true: continue, you got lucky and just saved a write
> 
> At the price of a read and a conditional

Re: [lng-odp] [API-NEXT PATCH v6] 0/9] api: time: update local time to be monotonic

2015-12-04 Thread Maxim Uvarov

Hello Ivan,

The hole patch set looks like good. But it looks like patch order is 
wrong or some patches needs to be merged.


If I apply only 8 patches there is error:
  Test: time_test_odp_negative_diff ...FAILED
1. time.c:42  - odp_time_cmp(diff, ODP_TIME_NULL) > 0

If only 7 patches then odp_pktio_perf test fails.

Also running odp-check I saw segfault on some patches.

And patches short message is: "[API-NEXT PATCH v6] 0/9]", but it has to 
be [API-NEXT PATCHv6 0/9]".


Maxim.

On 12/03/2015 17:07, Savolainen, Petri (Nokia - FI/Espoo) wrote:

Entire patch set:

Reviewed-by: Petri Savolainen 




-Original Message-
From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT
Ivan Khoronzhuk
Sent: Thursday, December 03, 2015 2:49 PM
To: lng-odp@lists.linaro.org
Subject: [lng-odp] [API-NEXT PATCH v6] 0/9] api: time: update local time
to be monotonic

This series is intended to modify time API to be used as monotonic wall
time in order to simplify time API usage and create prerequisites for
adding global time API.

Since v5
   linux-generic: align with new wall time API
- deleted _odp prefix for local functions
- avoided modulo operation
- used common global var for start time

Since v3:
- "api: time: make odp_local_time to be monotonic wall time"
   splitted on;
   "linux-generic: align with new wall time API"
   "test/example: use local time API as wall time"
- increased BUSY_LOOP_CNT to fit in resolution and 4+ sec

Since v2:
- removed patch changing type of ODP_TIME_*
- added new patch:
   test: performance: pktio: don't use direct arithmetic operations with
 odp_time_t
- added new patch:
   performance: sched: use ODP time API instead of clock_gettime
- combined monotonic and wall time patches
- removed odp_time_local_val() and odp_time_val_to_ns()
- replaced terms monotonic and wall in API desc

Since v1:
- corrected name of the series to be api-next
- use thread local for holding start time

Ivan Khoronzhuk (9):
   validation: time: don't assign int directly to odp_time_t
   test: performance: pktio: don't use direct arithmetic operations with
 odp_time_t
   linux-generic: schedule: use schedule time in ns
   linux-generic: odp_time: don't use cpu cycle API to get time
   performance: sched: use ODP time API instead of clock_gettime
   api: time: make odp_local_time to be monotonic wall time
   linux-generic: align with new wall time API
   test/example: use local time API as wall time
   validation: time: align tests with current time API

  example/generator/odp_generator.c  |  10 +-
  include/odp/api/time.h |   3 +-
  platform/linux-generic/Makefile.am |   1 -
  .../linux-generic/include/odp/plat/time_types.h|   6 +-
  platform/linux-generic/include/odp_cpu_internal.h  |  29 ---
  platform/linux-generic/include/odp_internal.h  |   2 +
  platform/linux-generic/odp_cpu.c   |   6 +-
  platform/linux-generic/odp_init.c  |   4 +
  platform/linux-generic/odp_schedule.c  |  18 +-
  platform/linux-generic/odp_time.c  | 112 +++---
  test/performance/odp_pktio_perf.c  |  24 +--
  test/performance/odp_scheduling.c  |  37 +---
  test/validation/pktio/pktio.c  |  21 +-
  test/validation/time/time.c| 228
++---
  test/validation/time/time.h|   7 +-
  15 files changed, 346 insertions(+), 162 deletions(-)
  delete mode 100644 platform/linux-generic/include/odp_cpu_internal.h

--
1.9.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