[lng-odp] [PATCHv6 7/7] api: buffer: update documentation comments

2014-12-15 Thread Taras Kondratiuk
From: Bill Fischofer bill.fischo...@linaro.org

Signed-off-by: Bill Fischofer bill.fischo...@linaro.org
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/include/api/odp_buffer.h  |  4 ++--
 platform/linux-generic/include/api/odp_buffer_pool.h | 13 +
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_buffer.h 
b/platform/linux-generic/include/api/odp_buffer.h
index a7036e8..3c23035 100644
--- a/platform/linux-generic/include/api/odp_buffer.h
+++ b/platform/linux-generic/include/api/odp_buffer.h
@@ -62,13 +62,13 @@ int odp_buffer_type(odp_buffer_t buf);
 #define ODP_BUFFER_TYPE_PACKET2  /** Packet buffer */
 #define ODP_BUFFER_TYPE_TIMEOUT   3  /** Timeout buffer */
 
-
 /**
  * Tests if buffer is valid
  *
  * @param buf  Buffer handle
  *
- * @return 1 if valid, otherwise 0
+ * @retval 1 Buffer handle represents a valid buffer.
+ * @retval 0 Buffer handle does not represent a valid buffer.
  */
 int odp_buffer_is_valid(odp_buffer_t buf);
 
diff --git a/platform/linux-generic/include/api/odp_buffer_pool.h 
b/platform/linux-generic/include/api/odp_buffer_pool.h
index e6bf5a7..4da5f84 100644
--- a/platform/linux-generic/include/api/odp_buffer_pool.h
+++ b/platform/linux-generic/include/api/odp_buffer_pool.h
@@ -100,7 +100,11 @@ int odp_buffer_pool_destroy(odp_buffer_pool_t pool);
  *
  * @param name  Name of the pool
  *
- * @return Buffer pool handle, or ODP_BUFFER_POOL_INVALID if not found.
+ * @return Handle of found buffer pool
+ * @retval ODP_BUFFER_POOL_INVALID  Buffer pool could not be found
+ *
+ * @note This routine cannot be used to look up an anonymous pool (one created
+ * with no name).
  */
 odp_buffer_pool_t odp_buffer_pool_lookup(const char *name);
 
@@ -138,21 +142,22 @@ int odp_buffer_pool_info(odp_buffer_pool_t pool,
  *
  * @param pool  Pool handle
  *
+ * @note This routine writes implementation-defined information about the
+ * specified buffer pool to the ODP log. The intended use is for debugging.
  */
 void odp_buffer_pool_print(odp_buffer_pool_t pool);
 
-
 /**
  * Buffer alloc
  *
  * The validity of a buffer can be cheked at any time with 
odp_buffer_is_valid()
  * @param pool  Pool handle
  *
- * @return Buffer handle or ODP_BUFFER_INVALID
+ * @return Handle of allocated buffer
+ * @retval ODP_BUFFER_INVALID  Buffer could not be allocated
  */
 odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t pool);
 
-
 /**
  * Buffer free
  *
-- 
1.9.1


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


[lng-odp] [PATCHv6 6/7] api: buffer: add pool info query

2014-12-15 Thread Taras Kondratiuk
From: Bill Fischofer bill.fischo...@linaro.org

Signed-off-by: Bill Fischofer bill.fischo...@linaro.org
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 .../linux-generic/include/api/odp_buffer_pool.h| 28 ++
 platform/linux-generic/odp_buffer_pool.c   | 20 
 2 files changed, 48 insertions(+)

diff --git a/platform/linux-generic/include/api/odp_buffer_pool.h 
b/platform/linux-generic/include/api/odp_buffer_pool.h
index 312b5f6..e6bf5a7 100644
--- a/platform/linux-generic/include/api/odp_buffer_pool.h
+++ b/platform/linux-generic/include/api/odp_buffer_pool.h
@@ -104,6 +104,34 @@ int odp_buffer_pool_destroy(odp_buffer_pool_t pool);
  */
 odp_buffer_pool_t odp_buffer_pool_lookup(const char *name);
 
+/**
+ * Buffer pool information struct
+ * Used to get information about a buffer pool.
+ */
+typedef struct odp_buffer_pool_info_t {
+   const char *name; /** pool name */
+   odp_shm_t shm;/** handle of shared memory area
+supplied by application to
+contain buffer pool, or
+ODP_SHM_NULL if this pool is
+managed by ODP */
+   odp_buffer_pool_param_t params;   /** pool parameters */
+} odp_buffer_pool_info_t;
+
+/**
+ * Retrieve information about a buffer pool
+ *
+ * @param pool Buffer pool handle
+ *
+ * @param[out] infoReceives an odp_buffer_pool_info_t object
+ * that describes the pool.
+ *
+ * @retval 0 Success
+ * @retval -1 Failure.  Info could not be retrieved.
+ */
+
+int odp_buffer_pool_info(odp_buffer_pool_t pool,
+odp_buffer_pool_info_t *info);
 
 /**
  * Print buffer pool info
diff --git a/platform/linux-generic/odp_buffer_pool.c 
b/platform/linux-generic/odp_buffer_pool.c
index e2511af..e947dde 100644
--- a/platform/linux-generic/odp_buffer_pool.c
+++ b/platform/linux-generic/odp_buffer_pool.c
@@ -390,6 +390,26 @@ odp_buffer_pool_t odp_buffer_pool_lookup(const char *name)
return ODP_BUFFER_POOL_INVALID;
 }
 
+int odp_buffer_pool_info(odp_buffer_pool_t pool_hdl,
+odp_buffer_pool_info_t *info)
+{
+   uint32_t pool_id = pool_handle_to_index(pool_hdl);
+   pool_entry_t *pool = get_pool_entry(pool_id);
+
+   if (pool == NULL || info == NULL)
+   return -1;
+
+   info-name = pool-s.name;
+   info-shm  = pool-s.flags.user_supplied_shm ?
+   pool-s.pool_shm : ODP_SHM_NULL;
+   info-params.buf_size  = pool-s.params.buf_size;
+   info-params.buf_align = pool-s.params.buf_align;
+   info-params.num_bufs  = pool-s.params.num_bufs;
+   info-params.buf_type  = pool-s.params.buf_type;
+
+   return 0;
+}
+
 int odp_buffer_pool_destroy(odp_buffer_pool_t pool_hdl)
 {
uint32_t pool_id = pool_handle_to_index(pool_hdl);
-- 
1.9.1


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


[lng-odp] [PATCHv6 3/7] api: buffer: move odp_buffer_pool to odp_buffer.h

2014-12-15 Thread Taras Kondratiuk
From: Bill Fischofer bill.fischo...@linaro.org

Signed-off-by: Bill Fischofer bill.fischo...@linaro.org
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/include/api/odp_buffer.h  |  9 +
 platform/linux-generic/include/api/odp_buffer_pool.h | 10 --
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_buffer.h 
b/platform/linux-generic/include/api/odp_buffer.h
index da23120..a7036e8 100644
--- a/platform/linux-generic/include/api/odp_buffer.h
+++ b/platform/linux-generic/include/api/odp_buffer.h
@@ -73,6 +73,15 @@ int odp_buffer_type(odp_buffer_t buf);
 int odp_buffer_is_valid(odp_buffer_t buf);
 
 /**
+ * Buffer pool of the buffer
+ *
+ * @param buf   Buffer handle
+ *
+ * @return Handle of buffer pool buffer belongs to
+ */
+odp_buffer_pool_t odp_buffer_pool(odp_buffer_t buf);
+
+/**
  * Print buffer metadata to STDOUT
  *
  * @param buf  Buffer handle
diff --git a/platform/linux-generic/include/api/odp_buffer_pool.h 
b/platform/linux-generic/include/api/odp_buffer_pool.h
index c12d718..b287f79 100644
--- a/platform/linux-generic/include/api/odp_buffer_pool.h
+++ b/platform/linux-generic/include/api/odp_buffer_pool.h
@@ -88,16 +88,6 @@ odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t pool);
  */
 void odp_buffer_free(odp_buffer_t buf);
 
-
-/**
- * Buffer pool of the buffer
- *
- * @param buf   Buffer handle
- *
- * @return Buffer pool the buffer was allocated from
- */
-odp_buffer_pool_t odp_buffer_pool(odp_buffer_t buf);
-
 /**
  * @}
  */
-- 
1.9.1


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


[lng-odp] [PATCH] validation: crypto: remove data offset workaround

2014-12-13 Thread Taras Kondratiuk
Current crypto tests calculate range offsets expecting a bug in crypto
implementation: data offsets are applied relatively to a start of a
buffer instead of start of data in a packet. This bug is fixed in
linux-generic by recent buffer/packet rework patches, so all crypto
tests fails now. Remove this workaround.

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
This patch should be merged just after Bill's buffer/packet changes
for v0.5.
---
 test/validation/crypto/odp_crypto_test_async_inp.c | 4 +---
 test/validation/crypto/odp_crypto_test_sync_inp.c  | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/test/validation/crypto/odp_crypto_test_async_inp.c 
b/test/validation/crypto/odp_crypto_test_async_inp.c
index c140c0f..96d4c3f 100644
--- a/test/validation/crypto/odp_crypto_test_async_inp.c
+++ b/test/validation/crypto/odp_crypto_test_async_inp.c
@@ -67,9 +67,7 @@ static void alg_test(enum odp_crypto_op op,
CU_ASSERT(pkt != ODP_PACKET_INVALID);
uint8_t *data_addr = odp_packet_data(pkt);
memcpy(data_addr, input_vec, input_vec_len);
-   /* offsets are relative to buffer address (not packet data)
-   until https://bugs.linaro.org/show_bug.cgi?id=387 is fixed */
-   int data_off = data_addr - (uint8_t *)odp_buffer_addr(buf);
+   const int data_off = 0;
 
/* Prepare input/output params */
odp_crypto_op_params_t op_params;
diff --git a/test/validation/crypto/odp_crypto_test_sync_inp.c 
b/test/validation/crypto/odp_crypto_test_sync_inp.c
index b63fd4d..f37ad54 100644
--- a/test/validation/crypto/odp_crypto_test_sync_inp.c
+++ b/test/validation/crypto/odp_crypto_test_sync_inp.c
@@ -56,9 +56,7 @@ static void alg_test(enum odp_crypto_op op,
CU_ASSERT(pkt != ODP_PACKET_INVALID);
uint8_t *data_addr = odp_packet_data(pkt);
memcpy(data_addr, input_vec, input_vec_len);
-   /* offsets are relative to buffer address (not packet data)
-   until https://bugs.linaro.org/show_bug.cgi?id=387 is fixed */
-   int data_off = data_addr - (uint8_t *)odp_buffer_addr(buf);
+   const int data_off = 0;
 
/* Prepare input/output params */
odp_crypto_op_params_t op_params;
-- 
1.9.1


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


[lng-odp] ODP handles comparison

2014-12-12 Thread Taras Kondratiuk
Hi

It seems to be useful to be able to compare two ODP handles. For example
compare odp_packet_pool() return value with previously created
pool to check that packet is from that pool.

ODP types are opaques handles, so comparing them directly with == may
give a wrong results. For example handles that point to the same object
(queue, pool, etc) can have generation number in it, so direct
comparison will return false.

Do we need to add corresponding comparison API for each handle type? Or
we just say that any two handles of the same ODP object should be equal
and == is enough?

-- 
Taras Kondratiuk

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


Re: [lng-odp] [PATCH] configure.ac check for atomic operations support

2014-12-12 Thread Taras Kondratiuk
On 12/12/2014 05:03 PM, Maxim Uvarov wrote:
 Odp atomic operations based on compiler build-ins. Make
 sure that compiler supports such operation at configure
 stage.

This check should be limited to platforms that use gcc atomics.

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


Re: [lng-odp] [PATCH] configure.ac check for atomic operations support

2014-12-12 Thread Taras Kondratiuk
On 12/12/2014 05:51 PM, Maxim Uvarov wrote:
 On 12/12/2014 06:47 PM, Taras Kondratiuk wrote:
 On 12/12/2014 05:03 PM, Maxim Uvarov wrote:
 Odp atomic operations based on compiler build-ins. Make
 sure that compiler supports such operation at configure
 stage.
 This check should be limited to platforms that use gcc atomics.
 Do we have such platforms?

I assume you question was: do we have platform that *don't* use gcc
atomics? Currently all public platform do use gcc atomics, but we
shouldn't assume this for other platforms. Some of them may use older
version of gcc which doesn't have these built-ins.
Can this check be done/enabled per platform?

-- 
Taras Kondratiuk

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


[lng-odp] [PATCH 3/3] validation: buffer: add initial packet tests

2014-12-12 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 test/validation/Makefile.am|   1 +
 test/validation/buffer/odp_buffer_testsuites.h |   4 +
 test/validation/buffer/odp_packet_test.c   | 659 +
 test/validation/odp_buffer.c   |   5 +
 4 files changed, 669 insertions(+)
 create mode 100644 test/validation/buffer/odp_packet_test.c

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 41c48ec..2ceb27a 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -26,4 +26,5 @@ dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
 dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
 dist_odp_buffer_SOURCES = buffer/odp_buffer_pool_test.c \
  buffer/odp_buffer_test.c \
+ buffer/odp_packet_test.c \
  odp_buffer.c common/odp_cunit_common.c
diff --git a/test/validation/buffer/odp_buffer_testsuites.h 
b/test/validation/buffer/odp_buffer_testsuites.h
index ca42c2d..715d9ac 100644
--- a/test/validation/buffer/odp_buffer_testsuites.h
+++ b/test/validation/buffer/odp_buffer_testsuites.h
@@ -16,10 +16,14 @@
 
 extern CU_TestInfo buffer_pool_tests[];
 extern CU_TestInfo buffer_tests[];
+extern CU_TestInfo packet_tests[];
 
 extern int buffer_testsuite_init(void);
 extern int buffer_testsuite_finalize(void);
 
+extern int packet_testsuite_init(void);
+extern int packet_testsuite_finalize(void);
+
 odp_buffer_pool_t pool_create(int buf_num, int buf_size, int buf_type);
 
 #endif /* ODP_BUFFER_TESTSUITES_H_ */
diff --git a/test/validation/buffer/odp_packet_test.c 
b/test/validation/buffer/odp_packet_test.c
new file mode 100644
index 000..fbce0df
--- /dev/null
+++ b/test/validation/buffer/odp_packet_test.c
@@ -0,0 +1,659 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:BSD-3-Clause
+ */
+
+#include odp_buffer_testsuites.h
+#include stdlib.h
+
+#define BUFFER_LENGTH  1500
+static odp_buffer_pool_t packet_pool;
+static const uint32_t packet_len = BUFFER_LENGTH;
+
+odp_packet_t test_packet;
+
+int packet_testsuite_init(void)
+{
+   odp_buffer_pool_param_t params = {
+   .buf_size  = BUFFER_LENGTH + ODP_CONFIG_PACKET_HEADROOM,
+   .buf_align = ODP_CACHE_LINE_SIZE,
+   .num_bufs  = 100,
+   .buf_type  = ODP_BUFFER_TYPE_PACKET,
+   };
+
+   packet_pool = odp_buffer_pool_create(packet_pool, ODP_SHM_INVALID,
+params);
+   if (packet_pool == ODP_BUFFER_POOL_INVALID)
+   return -1;
+
+   test_packet = odp_packet_alloc(packet_pool, packet_len);
+   if (odp_packet_is_valid(test_packet) == 0)
+   return -1;
+
+   return 0;
+}
+
+int packet_testsuite_finalize(void)
+{
+   odp_packet_free(test_packet);
+   if (odp_buffer_pool_destroy(packet_pool) != 0)
+   return -1;
+   return 0;
+}
+
+static void packet_alloc_free(void)
+{
+   odp_buffer_pool_t pool;
+   odp_packet_t packet;
+   const uint32_t length = 64;
+   pool = pool_create(1, length + ODP_CONFIG_PACKET_HEADROOM,
+  ODP_BUFFER_TYPE_PACKET);
+
+   /* Allocate the only buffer from the pool */
+   packet = odp_packet_alloc(pool, length);
+   CU_ASSERT_FATAL(packet != ODP_PACKET_INVALID);
+   CU_ASSERT(odp_packet_len(packet) == length);
+   /** @todo: is it correct to assume the pool had only one buffer? */
+   CU_ASSERT_FATAL(odp_packet_alloc(pool, length) == ODP_PACKET_INVALID)
+
+   odp_packet_free(packet);
+
+   /* Check that the buffer was returned back to the pool */
+   packet = odp_packet_alloc(pool, length);
+   CU_ASSERT_FATAL(packet != ODP_PACKET_INVALID);
+   CU_ASSERT(odp_packet_len(packet) == length);
+
+   odp_packet_free(packet);
+   CU_ASSERT(odp_buffer_pool_destroy(pool) == 0);
+}
+
+static void packet_alloc_segmented(void)
+{
+   odp_packet_t pkt;
+   pkt = odp_packet_alloc(packet_pool, BUFFER_LENGTH * 10);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+   odp_packet_free(pkt);
+}
+
+static void packet_buffer_conversion(void)
+{
+   odp_packet_t pkt = test_packet;
+   odp_packet_t tmp_pkt;
+   odp_buffer_t buf;
+
+   buf = odp_packet_to_buffer(pkt);
+   CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID);
+   CU_ASSERT(odp_buffer_type(buf) == ODP_BUFFER_TYPE_PACKET);
+   CU_ASSERT(odp_buffer_size(buf) == odp_packet_buf_len(pkt));
+
+   tmp_pkt = odp_packet_from_buffer(buf);
+   CU_ASSERT_FATAL(tmp_pkt != ODP_PACKET_INVALID);
+   /** @todo: Need an API to compare packets */
+}
+
+static void packet_basic_metadata(void)
+{
+   odp_packet_t pkt = test_packet;
+   CU_ASSERT(odp_packet_head(pkt) != NULL);
+   CU_ASSERT(odp_packet_data(pkt) != NULL);
+
+   CU_ASSERT(odp_packet_pool(pkt

[lng-odp] [PATCH 1/3] validation: buffer: add initial buffer pool tests

2014-12-12 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 test/validation/.gitignore |   1 +
 test/validation/Makefile.am|   6 +-
 test/validation/buffer/odp_buffer_pool_test.c  | 212 +
 test/validation/buffer/odp_buffer_testsuites.h |  21 +++
 test/validation/odp_buffer.c   |  14 ++
 5 files changed, 253 insertions(+), 1 deletion(-)
 create mode 100644 test/validation/buffer/odp_buffer_pool_test.c
 create mode 100644 test/validation/buffer/odp_buffer_testsuites.h
 create mode 100644 test/validation/odp_buffer.c

diff --git a/test/validation/.gitignore b/test/validation/.gitignore
index 37e2594..6bf11bd 100644
--- a/test/validation/.gitignore
+++ b/test/validation/.gitignore
@@ -4,3 +4,4 @@ odp_init
 odp_queue
 odp_crypto
 odp_shm
+odp_buffer
diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 8547085..81fd933 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -6,13 +6,15 @@ AM_LDFLAGS += -static
 if ODP_CUNIT_ENABLED
 TESTS = ${bin_PROGRAMS}
 check_PROGRAMS = ${bin_PROGRAMS}
-bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm
+bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_buffer
 odp_init_LDFLAGS = $(AM_LDFLAGS)
 odp_queue_LDFLAGS = $(AM_LDFLAGS)
 odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
 odp_crypto_LDFLAGS = $(AM_LDFLAGS)
 odp_shm_CFLAGS = $(AM_CFLAGS)
 odp_shm_LDFLAGS = $(AM_LDFLAGS)
+odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer
+odp_buffer_LDFLAGS = $(AM_LDFLAGS)
 endif
 
 dist_odp_init_SOURCES = odp_init.c
@@ -22,3 +24,5 @@ dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
  crypto/odp_crypto_test_rng.c \
  odp_crypto.c common/odp_cunit_common.c
 dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
+dist_odp_buffer_SOURCES = buffer/odp_buffer_pool_test.c \
+ odp_buffer.c common/odp_cunit_common.c
diff --git a/test/validation/buffer/odp_buffer_pool_test.c 
b/test/validation/buffer/odp_buffer_pool_test.c
new file mode 100644
index 000..b41fe4d
--- /dev/null
+++ b/test/validation/buffer/odp_buffer_pool_test.c
@@ -0,0 +1,212 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:BSD-3-Clause
+ */
+
+#include odp_buffer_testsuites.h
+
+static int pool_name_number = 1;
+static const int default_buffer_size = 1500;
+static const int default_buffer_num = 1000;
+
+odp_buffer_pool_t pool_create(int buf_num, int buf_size, int buf_type)
+{
+   odp_buffer_pool_t pool;
+   char pool_name[ODP_BUFFER_POOL_NAME_LEN];
+   odp_buffer_pool_param_t params = {
+   .buf_size  = buf_size,
+   .buf_align = ODP_CACHE_LINE_SIZE,
+   .num_bufs  = buf_num,
+   .buf_type  = buf_type,
+   };
+
+   snprintf(pool_name, sizeof(pool_name),
+test_buffer_pool-%d, pool_name_number++);
+
+   pool = odp_buffer_pool_create(pool_name, ODP_SHM_INVALID, params);
+   CU_ASSERT_FATAL(pool != ODP_BUFFER_POOL_INVALID);
+
+   return pool;
+}
+
+static void pool_create_destroy_type(int type)
+{
+   odp_buffer_pool_t pool;
+   pool = pool_create(default_buffer_num, default_buffer_size, type);
+
+   CU_ASSERT(odp_buffer_pool_destroy(pool) == 0);
+}
+
+static void pool_create_destroy_raw(void)
+{
+   pool_create_destroy_type(ODP_BUFFER_TYPE_RAW);
+}
+
+static void pool_create_destroy_packet(void)
+{
+   pool_create_destroy_type(ODP_BUFFER_TYPE_PACKET);
+}
+
+static void pool_create_destroy_timeout(void)
+{
+   pool_create_destroy_type(ODP_BUFFER_TYPE_TIMEOUT);
+}
+
+static void pool_create_destroy_any(void)
+{
+   pool_create_destroy_type(ODP_BUFFER_TYPE_ANY);
+}
+
+static void pool_create_destroy_raw_shm(void)
+{
+   odp_buffer_pool_t pool;
+   odp_shm_t test_shm;
+   odp_buffer_pool_param_t params = {
+   .buf_size  = 1500,
+   .buf_align = ODP_CACHE_LINE_SIZE,
+   .num_bufs  = 10,
+   .buf_type  = ODP_BUFFER_TYPE_RAW,
+   };
+
+   test_shm = odp_shm_reserve(test_shm,
+  params.buf_size * params.num_bufs * 2,
+  ODP_CACHE_LINE_SIZE,
+  0);
+   CU_ASSERT_FATAL(test_shm != ODP_SHM_INVALID);
+
+   pool = odp_buffer_pool_create(test_shm_pool, test_shm, params);
+   CU_ASSERT_FATAL(pool != ODP_BUFFER_POOL_INVALID);
+
+   CU_ASSERT(odp_buffer_pool_destroy(pool) == 0);
+   CU_ASSERT(odp_shm_free(test_shm) == 0);
+}
+
+static void pool_lookup_info_print(void)
+{
+   odp_buffer_pool_t pool;
+   const char pool_name[] = pool_for_lookup_test;
+   odp_buffer_pool_info_t info;
+   odp_buffer_pool_param_t params = {
+   .buf_size  = default_buffer_size

[lng-odp] [PATCH 0/3] validation: buffer: add initial tests

2014-12-12 Thread Taras Kondratiuk
Initial version of sunny day buffer pool, buffer and packet API tests.
Based on Bill's buffer  packets patches for v0.5.

linux-generic doesn't support segmented packets in v0.5, so two tests are
failing.



Taras Kondratiuk (3):
  validation: buffer: add initial buffer pool tests
  validation: buffer: add initial buffer tests
  validation: buffer: add initial packet tests

 test/validation/.gitignore |   1 +
 test/validation/Makefile.am|   8 +-
 test/validation/buffer/odp_buffer_pool_test.c  | 212 
 test/validation/buffer/odp_buffer_test.c   |  52 ++
 test/validation/buffer/odp_buffer_testsuites.h |  29 ++
 test/validation/buffer/odp_packet_test.c   | 659 +
 test/validation/odp_buffer.c   |  24 +
 7 files changed, 984 insertions(+), 1 deletion(-)
 create mode 100644 test/validation/buffer/odp_buffer_pool_test.c
 create mode 100644 test/validation/buffer/odp_buffer_test.c
 create mode 100644 test/validation/buffer/odp_buffer_testsuites.h
 create mode 100644 test/validation/buffer/odp_packet_test.c
 create mode 100644 test/validation/odp_buffer.c

-- 
1.9.1


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


[lng-odp] [PATCH 0/3] validation: buffer: add initial tests

2014-12-12 Thread Taras Kondratiuk
Initial version of sunny day buffer pool, buffer and packet API tests.
Based on Bill's buffer  packets patches for v0.5.

linux-generic doesn't support segmented packets in v0.5, so two tests are
failing. Test results:

Suite: buffer Pool tests
  Test: pool_create_destroy_raw ...passed
  Test: pool_create_destroy_packet ...passed
  Test: pool_create_destroy_timeout ...passed
  Test: pool_create_destroy_any ...passed
  Test: pool_create_destroy_raw_shm ...passed
  Test: pool_lookup_info_print ...passed
  Test: pool_alloc_buffer_raw ...passed
  Test: pool_alloc_buffer_packet ...passed
  Test: pool_alloc_buffer_timeout ...passed
  Test: pool_alloc_buffer_any ...passed
  Test: pool_free_buffer ...passed
Suite: buffer tests
  Test: buffer_management_basic ...passed
Suite: packet tests
  Test: packet_alloc_free ...passed
  Test: packet_alloc_segmented ...FAILED
1. ../../../../odp/test/validation/buffer/odp_packet_test.c:75  - pkt != 
ODP_PACKET_INVALID
  Test: packet_basic_metadata ...passed
  Test: packet_debug ...passed
  Test: packet_length ...passed
  Test: packet_headroom ...passed
  Test: packet_tailroom ...passed
  Test: packet_context ...passed
  Test: packet_buffer_conversion ...passed
  Test: packet_layer_offsets ...passed
  Test: packet_segments ...passed
  Test: packet_segment_last ...passed
  Test: packet_in_flags ...passed
  Test: packet_out_flags ...passed
  Test: packet_error_flags ...passed
  Test: packet_add_rem_data ...FAILED
1. ../../../../odp/test/validation/buffer/odp_packet_test.c:440  - new_pkt 
!= ODP_PACKET_INVALID
  Test: packet_copy ...passed
  Test: packet_copydata ...passed
  Test: packet_offset ...passed

Run Summary:Type  TotalRan Passed Failed Inactive
  suites  3  3n/a  00
   tests 31 31 29  20
 asserts238238236  2  n/a

Taras Kondratiuk (3):
  validation: buffer: add initial buffer pool tests
  validation: buffer: add initial buffer tests
  validation: buffer: add initial packet tests

 test/validation/.gitignore |   1 +
 test/validation/Makefile.am|   8 +-
 test/validation/buffer/odp_buffer_pool_test.c  | 212 
 test/validation/buffer/odp_buffer_test.c   |  52 ++
 test/validation/buffer/odp_buffer_testsuites.h |  29 ++
 test/validation/buffer/odp_packet_test.c   | 659 +
 test/validation/odp_buffer.c   |  24 +
 7 files changed, 984 insertions(+), 1 deletion(-)
 create mode 100644 test/validation/buffer/odp_buffer_pool_test.c
 create mode 100644 test/validation/buffer/odp_buffer_test.c
 create mode 100644 test/validation/buffer/odp_buffer_testsuites.h
 create mode 100644 test/validation/buffer/odp_packet_test.c
 create mode 100644 test/validation/odp_buffer.c

-- 
1.9.1


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


[lng-odp] [PATCH 2/3] validation: buffer: add initial buffer tests

2014-12-12 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 test/validation/Makefile.am|  1 +
 test/validation/buffer/odp_buffer_test.c   | 52 ++
 test/validation/buffer/odp_buffer_testsuites.h |  4 ++
 test/validation/odp_buffer.c   |  5 +++
 4 files changed, 62 insertions(+)
 create mode 100644 test/validation/buffer/odp_buffer_test.c

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 81fd933..41c48ec 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -25,4 +25,5 @@ dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
  odp_crypto.c common/odp_cunit_common.c
 dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
 dist_odp_buffer_SOURCES = buffer/odp_buffer_pool_test.c \
+ buffer/odp_buffer_test.c \
  odp_buffer.c common/odp_cunit_common.c
diff --git a/test/validation/buffer/odp_buffer_test.c 
b/test/validation/buffer/odp_buffer_test.c
new file mode 100644
index 000..73ae4cb
--- /dev/null
+++ b/test/validation/buffer/odp_buffer_test.c
@@ -0,0 +1,52 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:BSD-3-Clause
+ */
+
+#include odp_buffer_testsuites.h
+
+static odp_buffer_pool_t raw_pool;
+static odp_buffer_t raw_buffer = ODP_BUFFER_INVALID;
+static const size_t raw_buffer_size = 1500;
+
+int buffer_testsuite_init(void)
+{
+   odp_buffer_pool_param_t params = {
+   .buf_size  = raw_buffer_size,
+   .buf_align = ODP_CACHE_LINE_SIZE,
+   .num_bufs  = 100,
+   .buf_type  = ODP_BUFFER_TYPE_RAW,
+   };
+
+   raw_pool = odp_buffer_pool_create(raw_pool, ODP_SHM_INVALID, params);
+   if (raw_pool == ODP_BUFFER_POOL_INVALID)
+   return -1;
+   raw_buffer = odp_buffer_alloc(raw_pool);
+   if (raw_buffer == ODP_BUFFER_INVALID)
+   return -1;
+   return 0;
+}
+
+int buffer_testsuite_finalize(void)
+{
+   odp_buffer_free(raw_buffer);
+   if (odp_buffer_pool_destroy(raw_pool) != 0)
+   return -1;
+   return 0;
+}
+
+static void buffer_management_basic(void)
+{
+   CU_ASSERT(odp_buffer_is_valid(raw_buffer) == 1);
+   CU_ASSERT(odp_buffer_pool(raw_buffer) != ODP_BUFFER_POOL_INVALID);
+   CU_ASSERT(odp_buffer_type(raw_buffer) == ODP_BUFFER_TYPE_RAW);
+   CU_ASSERT(odp_buffer_size(raw_buffer) = raw_buffer_size);
+   CU_ASSERT(odp_buffer_addr(raw_buffer) != NULL);
+   odp_buffer_print(raw_buffer);
+}
+
+CU_TestInfo buffer_tests[] = {
+   _CU_TEST_INFO(buffer_management_basic),
+   CU_TEST_INFO_NULL,
+};
diff --git a/test/validation/buffer/odp_buffer_testsuites.h 
b/test/validation/buffer/odp_buffer_testsuites.h
index 08fb4e0..ca42c2d 100644
--- a/test/validation/buffer/odp_buffer_testsuites.h
+++ b/test/validation/buffer/odp_buffer_testsuites.h
@@ -15,6 +15,10 @@
 #define _CU_TEST_INFO(test_func) {#test_func, test_func}
 
 extern CU_TestInfo buffer_pool_tests[];
+extern CU_TestInfo buffer_tests[];
+
+extern int buffer_testsuite_init(void);
+extern int buffer_testsuite_finalize(void);
 
 odp_buffer_pool_t pool_create(int buf_num, int buf_size, int buf_type);
 
diff --git a/test/validation/odp_buffer.c b/test/validation/odp_buffer.c
index bfd9f6d..8aa61a9 100644
--- a/test/validation/odp_buffer.c
+++ b/test/validation/odp_buffer.c
@@ -10,5 +10,10 @@ CU_SuiteInfo odp_testsuites[] = {
{ .pName = buffer Pool tests,
.pTests = buffer_pool_tests,
},
+   { .pName = buffer tests,
+   .pTests = buffer_tests,
+   .pInitFunc = buffer_testsuite_init,
+   .pCleanupFunc = buffer_testsuite_finalize,
+   },
CU_SUITE_INFO_NULL,
 };
-- 
1.9.1


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


Re: [lng-odp] [PATCH 0/3] validation: buffer: add initial tests

2014-12-12 Thread Taras Kondratiuk
On 12/12/2014 06:38 PM, Taras Kondratiuk wrote:
 Initial version of sunny day buffer pool, buffer and packet API tests.
 Based on Bill's buffer  packets patches for v0.5.
 
 linux-generic doesn't support segmented packets in v0.5, so two tests are
 failing.

Ugh. This duplicated message is from temporary file.

-- 
Taras Kondratiuk

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


[lng-odp] [PATCH 0/3] linux-generic: crypto: fix validation tests failures

2014-12-12 Thread Taras Kondratiuk
This series fixes all crypto tests failures.

Suite: odp_crypto_sync_inp
  Test: ENC_ALG_3DES_CBC ...passed
  Test: DEC_ALG_3DES_CBC ...passed
  Test: ENC_ALG_3DES_CBC_OVR_IV ...passed
  Test: DEC_ALG_3DES_CBC_OVR_IV ...passed
  Test: ALG_HMAC_MD5 ...passed
Suite: odp_crypto_async_inp
  Test: ENC_ALG_3DES_CBC ...passed
  Test: DEC_ALG_3DES_CBC ...passed
  Test: ENC_ALG_3DES_CBC_OVR_IV ...passed
  Test: DEC_ALG_3DES_CBC_OVR_IV ...passed
  Test: ALG_HMAC_MD5 ...passed
  Test: ENC_ALG_3DES_CBC_COMPL_NEW ...passed
Suite: ODP_CRYPTO_RNG
  Test: RNG_GET_SIZE ...passed

Run Summary:Type  TotalRan Passed Failed Inactive
  suites  3  3n/a  00
   tests 12 12 12  00
 asserts299299299  0  n/a

Taras Kondratiuk (3):
  linux-generic: crypto: always make a copy of IV
  linux-generic: crypto: implement completion event context
  linux-generic: crypto: implement odp_crypto_get_operation_compl_packet()

 .../linux-generic/include/odp_crypto_internal.h|  2 +
 platform/linux-generic/odp_crypto.c| 91 ++
 2 files changed, 62 insertions(+), 31 deletions(-)

-- 
1.9.1


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


[lng-odp] [PATCH 1/3] linux-generic: crypto: always make a copy of IV

2014-12-12 Thread Taras Kondratiuk
DES library modifies IV buffer in-place. Current code handles this
correctly only in case of encryption operation with session IV.
To prevent user buffer modifications always make a copy of a
provided IV.

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/odp_crypto.c | 50 +
 1 file changed, 28 insertions(+), 22 deletions(-)

diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index d3cdec7..a2d4ab8 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -147,30 +147,25 @@ enum crypto_alg_err des_encrypt(odp_crypto_op_params_t 
*params,
 {
uint8_t *data  = odp_packet_addr(params-out_pkt);
uint32_t len   = params-cipher_range.length;
-   DES_cblock *iv = NULL;
-   DES_cblock iv_temp;
+   DES_cblock iv;
+   void *iv_ptr;
+
+   if (params-override_iv_ptr)
+   iv_ptr = params-override_iv_ptr;
+   else if (session-cipher.iv.data)
+   iv_ptr = session-cipher.iv.data;
+   else
+   return ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER;
 
/*
 * Create a copy of the IV.  The DES library modifies IV
 * and if we are processing packets on parallel threads
 * we could get corruption.
 */
-   if (session-cipher.iv.data) {
-   memcpy(iv_temp, session-cipher.iv.data, sizeof(iv_temp));
-   iv = iv_temp;
-   }
+   memcpy(iv, iv_ptr, sizeof(iv));
 
/* Adjust pointer for beginning of area to cipher */
data += params-cipher_range.offset;
-
-   /* Override IV if requested */
-   if (params-override_iv_ptr)
-   iv = (DES_cblock *)params-override_iv_ptr;
-
-   /* No session or operation IV */
-   if (!iv)
-   return ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER;
-
/* Encrypt it */
DES_ede3_cbc_encrypt(data,
 data,
@@ -178,7 +173,7 @@ enum crypto_alg_err des_encrypt(odp_crypto_op_params_t 
*params,
 session-cipher.data.des.ks1,
 session-cipher.data.des.ks2,
 session-cipher.data.des.ks3,
-iv,
+iv,
 1);
 
return ODP_CRYPTO_ALG_ERR_NONE;
@@ -190,15 +185,26 @@ enum crypto_alg_err des_decrypt(odp_crypto_op_params_t 
*params,
 {
uint8_t *data  = odp_packet_addr(params-out_pkt);
uint32_t len   = params-cipher_range.length;
-   DES_cblock *iv = (DES_cblock *)session-cipher.iv.data;
+   DES_cblock iv;
+   void *iv_ptr;
+
+   if (params-override_iv_ptr)
+   iv_ptr = params-override_iv_ptr;
+   else if (session-cipher.iv.data)
+   iv_ptr = session-cipher.iv.data;
+   else
+   return ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER;
+
+   /*
+* Create a copy of the IV.  The DES library modifies IV
+* and if we are processing packets on parallel threads
+* we could get corruption.
+*/
+   memcpy(iv, iv_ptr, sizeof(iv));
 
/* Adjust pointer for beginning of area to cipher */
data += params-cipher_range.offset;
 
-   /* Override IV if requested */
-   if (params-override_iv_ptr)
-   iv = (DES_cblock *)params-override_iv_ptr;
-
/* Decrypt it */
DES_ede3_cbc_encrypt(data,
 data,
@@ -206,7 +212,7 @@ enum crypto_alg_err des_decrypt(odp_crypto_op_params_t 
*params,
 session-cipher.data.des.ks1,
 session-cipher.data.des.ks2,
 session-cipher.data.des.ks3,
-iv,
+iv,
 0);
 
return ODP_CRYPTO_ALG_ERR_NONE;
-- 
1.9.1


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


[lng-odp] [PATCH 2/3] linux-generic: crypto: implement completion event context

2014-12-12 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 .../linux-generic/include/odp_crypto_internal.h|  1 +
 platform/linux-generic/odp_crypto.c| 28 +-
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index 04db333..6ecfe80 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -69,6 +69,7 @@ typedef struct odp_crypto_generic_op_result {
uint32_t magic;
odp_crypto_compl_status_t cipher;
odp_crypto_compl_status_t auth;
+   void* op_context;
 } odp_crypto_generic_op_result_t;
 
 /**
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index a2d4ab8..e605d59 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -446,17 +446,33 @@ odp_crypto_get_operation_compl_status(odp_buffer_t 
completion_event,
 
 
 void
-odp_crypto_set_operation_compl_ctx(odp_buffer_t completion_event ODP_UNUSED,
-  void *ctx ODP_UNUSED)
+odp_crypto_set_operation_compl_ctx(odp_buffer_t completion_event,
+  void *ctx)
 {
-   ODP_UNIMPLEMENTED();
+   odp_crypto_generic_op_result_t *result;
+
+   result = get_op_result_from_buffer(completion_event);
+   /*
+* Completion event magic can't be checked here, because it is filled
+* later in odp_crypto_operation() function.
+*/
+   ODP_ASSERT(odp_buffer_type(completion_event == ODP_BUFFER_TYPE_PACKET),
+   Completion is not a packet);
+
+   result-op_context = ctx;
 }
 
 void
-*odp_crypto_get_operation_compl_ctx(odp_buffer_t completion_event ODP_UNUSED)
+*odp_crypto_get_operation_compl_ctx(odp_buffer_t completion_event)
 {
-   ODP_UNIMPLEMENTED();
-   return NULL;
+   odp_crypto_generic_op_result_t *result;
+
+   result = get_op_result_from_buffer(completion_event);
+   ODP_ASSERT(OP_RESULT_MAGIC == result-magic, Bad completion magic);
+   ODP_ASSERT(odp_buffer_type(completion_event == ODP_BUFFER_TYPE_PACKET),
+   Completion is not a packet);
+
+   return result-op_context;
 }
 
 odp_packet_t
-- 
1.9.1


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


Re: [lng-odp] [RFC v2 3/3] Update IPsec example app to use new completion event constructs

2014-12-11 Thread Taras Kondratiuk
On 12/11/2014 04:25 PM, Robbie King (robking) wrote:
 See [rk] below.
 
 -Original Message-
 From: Taras Kondratiuk [mailto:taras.kondrat...@linaro.org] 
 Sent: Wednesday, December 10, 2014 7:12 PM
 To: Robbie King (robking); lng-odp@lists.linaro.org
 Subject: Re: [lng-odp] [RFC v2 3/3] Update IPsec example app to use new 
 completion event constructs
 
 On 12/10/2014 05:12 PM, Robbie King wrote:
 @@ -761,9 +766,9 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt,
   */
  static
  pkt_disposition_e do_ipsec_in_finish(odp_packet_t pkt,
 - pkt_ctx_t *ctx)
 + pkt_ctx_t *ctx,
 + odp_crypto_compl_event_t event)
  {
 -odp_buffer_t event;
  odp_crypto_compl_status_t cipher_rc;
  odp_crypto_compl_status_t auth_rc;
  odph_ipv4hdr_t *ip;
 @@ -771,8 +776,8 @@ pkt_disposition_e do_ipsec_in_finish(odp_packet_t pkt,
  int trl_len = 0;
  
  /* Check crypto result */
 -event = odp_packet_to_buffer(pkt);
  odp_crypto_get_operation_compl_status(event, cipher_rc, auth_rc);
 +odp_crypto_release_compl_event(event);
 
 If operation is done synchronously but out of place, then 'pkt' is an
 old packet.
 
 [rk] The packet handle passed back through the completion event should
 be the output packet handle (see below), and in my changes pkt is 
 extracted from the completion event.  Are you talking about the 
 line event = ...(pkt) above that was deleted?
 
   /* Build Result (no HW so no errors) */
   result = get_op_result_from_compl_event(completion_event);
   result-magic = OP_RESULT_MAGIC;
   result-ctx = ctx;
   result-pkt = params-out_pkt;
 

Maybe I'm missing something, but in a current patch packet is extracted
from completion event only in asynchronous case when packet is dequeued
from a queue. In synchronous case PKT_CONTINUE is returned from this
function and old packet is used for a next step.

-- 
Taras Kondratiuk

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


Re: [lng-odp] [RFC v2 1/3] Add completion event updates to odp_crypto.h

2014-12-11 Thread Taras Kondratiuk
On 12/11/2014 04:29 PM, Robbie King (robking) wrote:
 Instead of replying to all the other emails I'm just going to hit this on. :-)
 
 I agree with Taras that we can do away with the two API calls by making ctx
 a parameter value for the operation (making the completion event an output 
 only).
 
 My changes to make the completion event opaque (allowing the implementation
 freedom to avoid using buffers) was to address Bala's concern.  Taras and 
 Bala can debate that one, but in general I would like to remove the knowledge
 from the application that a completion event is a buffer.  The implementation
 should be free to do whatever it wishes in the synchronous case while 
 allowing the
 application to be the same for both models.
 
 I will modify my RFC to:
 
 1) make ctx a parameter to odp_crypto_operation
 2) eliminate the two function calls
 3) make completion event an output of odp_crypto_operation

So we have an agreement that completion event can to be output only.
Let's make this change first without introducing a new completion event
abstractions. This will be beneficial for both sync and async modes.
Then we can optimize further.

 
 To Bala's comment about the various get routines for accessing
 the completion event (ctx, pkt, and return codes), I would like to think
 these could be inline's in a typical implementation.  What I have in
 linux-generic is inefficient due to mixing both approaches for a
 a completion event at run time.  A real implementation wouldn't need
 that overhead.
 
 Making one routine with a bunch of outputs means if you ever want to
 add another output, all existing code is broken when you update the API.
 
 As an alternative, we could have one data structure that is used
 to return everything (if someone adds a field it is still backwards
 compatible):
 
 typedef struct {
 odp_crypto_compl_status_t auth;
 odp_crypto_compl_status_t cipher;
 odp_packet_t pkt;
 void *ctx;
 } odp_crypto_compl_event_out_t;
 
 void
 odp_crypto_get_operation_completion(odp_crypto_compl_event_t completion_event,
 odp_crypto_compl_event_out_t *out);

After step one (output only completion) we still have a few
inefficient places:
1. Need to deal with a completion event in synchronous case while it is
   really needed only for async case. Why can't we just return results
   directly?

int
odp_crypto_operation(odp_crypto_op_params_t *params,
 odp_crypto_compl_event_out_t* sync_result);

2. API is not optimized for a fast path. Detailed error status need to
   be checked before getting an output packet. IMO it would be better to
   return ODP_PACKET_INVALID from odp_crypto_get_operation_compl_packet()
   in case of any error. If application is interested in cause of error
   it can then request a detailed errors status.

 
 -Original Message-
 From: Taras Kondratiuk [mailto:taras.kondrat...@linaro.org] 
 Sent: Thursday, December 11, 2014 8:27 AM
 To: Bala; Robbie King (robking); lng-odp@lists.linaro.org
 Subject: Re: [lng-odp] [RFC v2 1/3] Add completion event updates to 
 odp_crypto.h
 
 On 12/11/2014 01:00 PM, Bala wrote:

 On Thursday 11 December 2014 05:30 AM, Taras Kondratiuk wrote:
 On 12/10/2014 05:12 PM, Robbie King wrote:
 Signed-off-by: Robbie Kingrobk...@cisco.com
 ---
   platform/linux-generic/include/api/odp_crypto.h | 77 
 -
   1 file changed, 63 insertions(+), 14 deletions(-)

 diff --git a/platform/linux-generic/include/api/odp_crypto.h 
 b/platform/linux-generic/include/api/odp_crypto.h
 index 337e7cf..7780a09 100644
 --- a/platform/linux-generic/include/api/odp_crypto.h
 +++ b/platform/linux-generic/include/api/odp_crypto.h
 @@ -210,6 +210,16 @@ typedef struct odp_crypto_compl_status {
enum crypto_hw_err  hw_err;   /** Hardware specific return code */
   } odp_crypto_compl_status_t;
   
 +/**
 + * Cryto API completion event
 + */
 +typedef struct odp_crypto_compl_event {
 +  bool is_buffer;
 +  union {
 +  void*ptr; /** Sync, single request 
 outstanding */
 +  odp_buffer_t buffer;  /** Async and multi sync request 
 */
 +  };
 +} odp_crypto_compl_event_t;
   
   /**
* Crypto session creation (synchronous)
 @@ -225,6 +235,55 @@ odp_crypto_session_create(odp_crypto_session_params_t 
 *params,
  odp_crypto_session_t *session,
  enum odp_crypto_ses_create_err *status);
   
 +/**
 + * Obtain crypto completion event for upcoming request
 + *
 + * Retrieve an appropriate completion event based on the request we are
 + * getting ready to issue.  Getting the event handle ahead of time allows
 + * us to perform any extra initialization (such as set user context).
 Actually user context is an attribute of a crypto operation. Completion
 event is used only as a transport to be able to obtain the context
 after operation is completed. It would be more logical to add operation

Re: [lng-odp] [PATCHv4] Implement v0.5 buffer pool APIs

2014-12-11 Thread Taras Kondratiuk
On 12/11/2014 07:00 AM, Bill Fischofer wrote:
 +odp_buffer_pool_t odp_buffer_pool_create(const char *name,
 +  odp_shm_t shm,
 +  odp_buffer_pool_param_t *params)
  {
 - odp_buffer_chunk_hdr_t *chunk_hdr;
 -
 - chunk_hdr = pool-s.head;
 - if (chunk_hdr == NULL) {
 - /* Pool is empty */
 - return NULL;
 - }
 -
 - pool-s.head = next_chunk(pool, chunk_hdr);
 - pool-s.free_bufs -= ODP_BUFS_PER_CHUNK;
 + odp_buffer_pool_t pool_hdl = ODP_BUFFER_POOL_INVALID;
 + pool_entry_t *pool;
 + uint32_t i, headroom = 0, tailroom = 0;
  
 - /* unlink */
 - rem_buf_index(chunk_hdr);
 - return chunk_hdr;
 -}
 + /* Default initialization paramters */
 + static _odp_buffer_pool_init_t default_init_params = {
 + .udata_size = 0,
 + .buf_init = NULL,
 + .buf_init_arg = NULL,
 + };
  
 + _odp_buffer_pool_init_t *init_params = default_init_params;
  
 -static void add_chunk(pool_entry_t *pool, odp_buffer_chunk_hdr_t *chunk_hdr)
 -{
 - if (pool-s.head) /* link pool head to the chunk */
 - add_buf_index(chunk_hdr, pool-s.head-buf_hdr.index);
 - else
 - add_buf_index(chunk_hdr, NULL_INDEX);
 + if (params == NULL)
 + return ODP_BUFFER_POOL_INVALID;
  
 - pool-s.head = chunk_hdr;
 - pool-s.free_bufs += ODP_BUFS_PER_CHUNK;
 -}
 + /* Restriction for v1.0: All buffers are unsegmented */
 + const int unsegmented = 1;

Shouldn't packet pools be segmented? Otherwise allocation of packets
greater that a pool buffer size will fail.

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


Re: [lng-odp] [PATCHv4] Implement v0.5 buffer pool APIs

2014-12-11 Thread Taras Kondratiuk
On 12/12/2014 12:10 AM, Bill Fischofer wrote:
 Packet pools support segmentation, however not in v0.5 because
 odp_packet_socket.c can't deal with segmented I/O so there is currently
 no way to Rx or Tx a segmented packet.  This needs to be addressed prior
 to v1.0.
 
 This is the reason why ODP_CONFIG_PACKET_BUF_LEN_MIN is set to 1664 in
 v0.5, so packet pool segments are large enough to deal with 1500-byte
 Ethernet packets.   The caller of odp_buffer_pool_create() is of course
 free to create a pool with whatever buf_size is needed to support Jumbo
 frames or larger.  

So this is a limitation of linux-generic only, but not v0.5 API. Right?
Tests are going to test segmented packets anyway.


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


Re: [lng-odp] [RFC v2 1/3] Add completion event updates to odp_crypto.h

2014-12-10 Thread Taras Kondratiuk
On 12/10/2014 05:12 PM, Robbie King wrote:
 Signed-off-by: Robbie King robk...@cisco.com
 ---
  platform/linux-generic/include/api/odp_crypto.h | 77 
 -
  1 file changed, 63 insertions(+), 14 deletions(-)
 
 diff --git a/platform/linux-generic/include/api/odp_crypto.h 
 b/platform/linux-generic/include/api/odp_crypto.h
 index 337e7cf..7780a09 100644
 --- a/platform/linux-generic/include/api/odp_crypto.h
 +++ b/platform/linux-generic/include/api/odp_crypto.h
 @@ -210,6 +210,16 @@ typedef struct odp_crypto_compl_status {
   enum crypto_hw_err  hw_err;   /** Hardware specific return code */
  } odp_crypto_compl_status_t;
  
 +/**
 + * Cryto API completion event
 + */
 +typedef struct odp_crypto_compl_event {
 + bool is_buffer;
 + union {
 + void*ptr; /** Sync, single request 
 outstanding */
 + odp_buffer_t buffer;  /** Async and multi sync request 
 */
 + };
 +} odp_crypto_compl_event_t;
  
  /**
   * Crypto session creation (synchronous)
 @@ -225,6 +235,55 @@ odp_crypto_session_create(odp_crypto_session_params_t 
 *params,
 odp_crypto_session_t *session,
 enum odp_crypto_ses_create_err *status);
  
 +/**
 + * Obtain crypto completion event for upcoming request
 + *
 + * Retrieve an appropriate completion event based on the request we are
 + * getting ready to issue.  Getting the event handle ahead of time allows
 + * us to perform any extra initialization (such as set user context).

Actually user context is an attribute of a crypto operation. Completion
event is used only as a transport to be able to obtain the context
after operation is completed. It would be more logical to add operation
user context as an additional field in odp_crypto_op_params_t.
Implementation will store it in a proper place if needed.
So two APIs can be dropped without sacrificing any functionality:
- odp_crypto_get_compl_event()
- odp_crypto_set_operation_compl_ctx()

 + *
 + * @param paramsOperation parameters
 + * 
 + * @return completion event (error handling?)
 + */
 +odp_crypto_compl_event_t
 +odp_crypto_get_compl_event(odp_crypto_op_params_t *params);
 +
 +/**
 + * Release crypto completion event
 + *
 + * @param completion_event  Completion event we are done accessing
 + */
 +void
 +odp_crypto_release_compl_event(odp_crypto_compl_event_t completion_event);
 +
 +/**
 + * Reset crypto completion event
 + *
 + * @param completion_event  Completion event we are initializing
 + */
 +void
 +odp_crypto_reset_compl_event(odp_crypto_compl_event_t *completion_event);
 +
 +/**
 + * Convert buffer to completion event
 + *
 + * @param buffer   Generic ODP buffer
 + *
 + * @return Completion event
 + */
 +odp_crypto_compl_event_t
 +odp_crypto_compl_event_from_buffer(odp_buffer_t buffer);
 +
 +/**
 + * Crypto per packet operation set user context in completion event
 + *
 + * @param completion_event  Event containing operation results
 + * @param ctx   User data
 + */
 +void
 +odp_crypto_set_operation_compl_ctx(odp_crypto_compl_event_t completion_event,
 +void *ctx);
  
  /**
   * Crypto per packet operation
 @@ -247,17 +306,7 @@ odp_crypto_session_create(odp_crypto_session_params_t 
 *params,
  int
  odp_crypto_operation(odp_crypto_op_params_t *params,
bool *posted,
 -  odp_buffer_t completion_event);
 -
 -/**
 - * Crypto per packet operation set user context in completion event
 - *
 - * @param completion_event  Event containing operation results
 - * @param ctx   User data
 - */
 -void
 -odp_crypto_set_operation_compl_ctx(odp_buffer_t completion_event,
 -void *ctx);
 +  odp_crypto_compl_event_t completion_event);

If my assumption above is correct than we don't need to pass any
completion event on operation submit. Implementation already have all
necessary information that need to be stored in a completion event.
This gives freedom to implementation to handle completion event in an
optimal way.

-- 
Taras Kondratiuk

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


Re: [lng-odp] [RFC v2 3/3] Update IPsec example app to use new completion event constructs

2014-12-10 Thread Taras Kondratiuk
On 12/10/2014 05:12 PM, Robbie King wrote:
 @@ -761,9 +766,9 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt,
   */
  static
  pkt_disposition_e do_ipsec_in_finish(odp_packet_t pkt,
 -  pkt_ctx_t *ctx)
 +  pkt_ctx_t *ctx,
 +  odp_crypto_compl_event_t event)
  {
 - odp_buffer_t event;
   odp_crypto_compl_status_t cipher_rc;
   odp_crypto_compl_status_t auth_rc;
   odph_ipv4hdr_t *ip;
 @@ -771,8 +776,8 @@ pkt_disposition_e do_ipsec_in_finish(odp_packet_t pkt,
   int trl_len = 0;
  
   /* Check crypto result */
 - event = odp_packet_to_buffer(pkt);
   odp_crypto_get_operation_compl_status(event, cipher_rc, auth_rc);
 + odp_crypto_release_compl_event(event);

If operation is done synchronously but out of place, then 'pkt' is an
old packet.

-- 
Taras Kondratiuk

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


Re: [lng-odp] [RFC v2 0/3] Proposed crypto completion event implementation

2014-12-10 Thread Taras Kondratiuk
On 12/10/2014 05:12 PM, Robbie King wrote:
 v1 - Illustrates abstracting completion event out to be a unique data
  type.  What is here still uses packet to serve as completion event
  however application is no longer aware of the fact and simply converts
  the received buffer to a completion context and uses accessor 
  functions from there on out.
 
  Subsequent version of patch will (hopefully) demonstrate how 
  a synchronous only implementation can be achieved relatively
  effeciently using the same API.
 
 v2 - Added support for using thread local storage instead of an ODP buffer
  for the completion event when operating synchronously.  Code is not
  performance oriented but meant to demonstrate how we might enable
  more effecient synchronous support while allowing the application
  to be implementation agnostic.

Hi Robby

Can you describe what advantage does it have over my RFC?

As per my understanding they both try to abstracts completion event
handling in a portable way. But this one is more complex and it seems to
have higher overhead on both implementation and application sides.

-- 
Taras Kondratiuk

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


Re: [lng-odp] RFC linux-dpdk support for DPDK 1.7.0

2014-12-09 Thread Taras Kondratiuk
On 12/09/2014 03:02 PM, Venkatesh Vivekanandan wrote:
 Hi All,
 
 DPDK changed its way of loading the driver from 1.7.0. We can support 
 this change in ODP in two ways.
 
 1. Wrap intel_dpdk archive with --whole-archive/--no-whole-archive in 
 all odp applications OR
 2. Compile DPDK with shared lib option enabled and load intel_dpdk as 
 shared lib with ODP.
 
 Currently option 1 doesn't look feasible. Looking out for solution.
 
 For option 2:
 Change given below is needed to pass the dpdk's lib path to all the 
 applications when odp is compiled for linux-dpdk. Is this acceptable?. 
 May be, this is useful for other platforms as well.

Hardcoding a path there is not very nice. I need 'usr/lib' there for
example. Can you use platform Makefile.inc for this?

https://git.linaro.org/people/taras.kondratiuk/odp.git/blob/HEAD:/platform/linux-keystone2/Makefile.inc

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


Re: [lng-odp] [RFC] api: crypto: Move completion event allocation to implementation

2014-12-08 Thread Taras Kondratiuk

On 12/08/2014 10:58 AM, Alexandru Badicioiu wrote:

Some comments inline.

Alex

On 5 December 2014 at 17:45, Taras Kondratiuk
taras.kondrat...@linaro.org mailto:taras.kondrat...@linaro.org wrote:

On 12/05/2014 04:16 PM, Alexandru Badicioiu wrote:

Hi ,
what this patch wants to accomplish can be done with the actual
API this
way : if the implementation really cannot reuse the input packet
as the
completion event (are there implementations which cannot?) it
can return
an error and the application could allocate a separate
completion event:
There is a little overhead with the first assignment and with
the failed
crypto operation in case of platforms which do not support
reusing the
packet but the API doesn't need to be modified (only adding a
new error
code).

odp_buffer_t compl = odp_packet_to_buffer(op___params.pkt);
rc = odp_crypto_operation(op___params, posted, compl);
if (odp_unlikely(ODP_CRYPTO___INVALID_COMPL_EVENT == rc)) {
compl = odp_buffer_alloc();
rc = odp_crypto_operation(op___params, posted, compl);
}


This approach really looks like a hack and it has several issues:


1. Application have to remember to free completion in case it was
allocated.

  [Alex] This is normal, right? If the application allocated something,
shouldn't have the responsibility to free it?


Sure freeing previously allocated buffer is normal, but *allocating* it
in a first place is *not necessary*. So no need to free anything.


I think it is the case of your patch when the application has to
remember to free something which it did not allocate.
You have proposed completion_event_free API but there is no alloc call
which is unbalanced. The call is in fact no different
than normal buffer free and for implementations which reuse the packet
it will be empty, as it is in the patch.


No. Difference is that application have to 'free' it *always*. No need
to determine action per event.
Regarding API balancing. It is the same use-case as ingress packets
processing: application can free them, but they are not allocated by
application.



In asynchronous case completion event may be dequeued
in another thread, so 'need to be freed' information should be
passed somehow along with the completion event. Implementation is in
much better position to handle this case.

[Alex] The operation context is meant to pass something along with the
completion event,
in case the application really needs this. However, the code example was
only to show
that the application has a mean to handle this packet vs new completion
event issue.
I think the API should be changed only if there's no other acceptable
way of doing something.
The cleanest approach is probably to introduce a capability call and the
application can check if
it can pass the input packet as the completion event.


Right, but IMO the approach you have proposed is not acceptable. It
doesn't make sense to freeze the API if small API changes can optimize
application and implementation sides. Especially at these early ODP
versions.

Unfortunately capability call won't solve the issue. Current crypto API
design was build on assumption that implementation can chose to process
a packet differently depending on its characteristics (size, cypher
algorithm, etc.). Depending on a type of processing chosen a completion
event may or may not be needed.




2. Implicitly passing packet as a completion event may mislead
application developer, because he may assume that he will get it
back
in exactly the same state (that's exactly what happened in our IPsec
application).

[Alex] The underlying buffer is passed, not the packet as such.
Implementation
knows where the packet and its metadata are in the packet and if no
INVALID_COMPLETION_EVENT error is returned it should be guaranteed
that the packet state is preserved. As I remember from the design,
the completion event is just a buffer where the crypto operation
returns the completion information. The only opaque
thing is how the crypto uses the buffer and how it lays out the output
information.


Preserving an original completion buffer content is a wrong assumption.
Current specification doesn't say anything about it. Robby
initially used this as a workaround to avoid completion event
allocation on application side. That's exactly what this RFC is
addressing.



But accordingly to the specification completion event
is an opaque token, so developer should not assume that its state is
preserved. Instead we have accessors functions to get information
from the completion event.





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


Re: [lng-odp] [RFC] api: crypto: Move completion event allocation to implementation

2014-12-08 Thread Taras Kondratiuk

On 12/08/2014 01:30 PM, Bala wrote:


On Friday 05 December 2014 10:16 PM, Taras Kondratiuk wrote:

On 12/05/2014 04:38 PM, Bala Manoharan wrote:

Hi,

In case of synchronous crypto operation the completion event is need
only in case of an error hence the application can check the return code
for failure and get info from completion event buffer only during that
scenario. This will greatly optimize the performance in synchronous
crypto operations.

This RFC aims to eliminate completion event handling by application, so
implementation (if capable) can optimize it and use output packet
instead. Both sync and async implementation will benefit in the same
way.

What you are asking is a separate optimization for sync mode which also
can be achieved on top of this RFC. We can add a note to
odp_crypto_operation() description: if the function succeeded and it
was synchronous an output packet can be queried without status check.


- implementation ---
int
odp_crypto_operation(odp_crypto_op_params_t *params,
  odp_buffer_t *completion_event)
{
...
process_packet(params-in_pkt, params-out_pkt);
*completion_event = odp_packet_to_buffer(params-out_pkt)
 ...
return 0;
}

odp_packet_t
odp_crypto_get_operation_compl_packet(odp_buffer_t completion_event)
{
 return odp_packet_from_buffer(completion_event);
}

void
odp_crypto_operation_compl_free(odp_buffer_t completion_event)
{
}

- application (odp_ipsec.c)

/* Issue crypto request */
 if (odp_crypto_operation(params, completion)) {
/* Call odp_crypto_get_operation_status(completion) if details
are needed */
return PKT_DROP;
}

if (completion != ODP_BUFFER_INVALID) {
*pkt = odp_crypto_get_operation_compl_packet(completion);
return (*pkt != ODP_PACKET_INVALID) ? PKT_CONTINUE :
PKT_DROP:
} else {
return PKT_POSTED;

If buffer-packet conversion is just casting, then overhead is zero.
Will it work for you?

In Sync crypto operation the output pkt is specified as part of the
odp_crypto_op_params_t by the original design.
Hence it will not required to get the packet from completion event. The
completion event needs to be checked
only during failure and during success the same can be ignored by the
application.


Actually sync/async mode doesn't change a way how output packet is
handled from application point of view. There are two options:
1. Packet is allocated by application and specified in out_pkt.
   If operation is finished synchronously and successfully, then output
   packet is present in out_pkt.
2. out_pkt is set to ODP_PACKET_INVALID, so implementation allocates it.
   In this case output packet have to be obtained as in the code above.

So in general, will it help you to have next to zero overhead?

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


Re: [lng-odp] [PATCH] api: move internal debug macros

2014-12-05 Thread Taras Kondratiuk

On 12/05/2014 09:25 AM, Maxim Uvarov wrote:

Merged,
Maxim.


Guys you are too quick in merging this. Most of us even didn't have
a chance to look at some of patches merged tonight.



On 12/05/2014 01:12 AM, Bill Fischofer wrote:



On Thu, Dec 4, 2014 at 4:08 PM, Mike Holmes mike.hol...@linaro.org
mailto:mike.hol...@linaro.org wrote:

Remove the following from the external API and make them internal
ODP_DBG
ODP_ERR
ODP_ABORT


Other macros (ODP_PRINT, ODP_LOG, ODP_ASSERT, ODP_ASSERT_STATIC) should
also be internal. Why they are not addressed in this patch?

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


Re: [lng-odp] [PATCH] api: odp_align: move internal macros

2014-12-05 Thread Taras Kondratiuk

On 12/04/2014 10:25 PM, Mike Holmes wrote:

@@ -138,12 +114,6 @@ extern C {
  #define ODP_ALIGN_ROUNDDOWN_PTR_POWER_2(x, align)\
  ((void *)ODP_ALIGN_ROUNDDOWN_POWER_2((uintptr_t)(x), (uintptr_t)(align)))


Only part of internal macros were moved. For example why
ODP_ALIGN_ROUNDDOWN_PTR_POWER_2() is still in public header?
What was the criteria to choose which function to move?

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


Re: [lng-odp] [PATCH] api: move internal debug macros

2014-12-05 Thread Taras Kondratiuk

On 12/05/2014 05:07 PM, Mike Holmes wrote:

They were not part of the the API Doc
https://docs.google.com/a/linaro.org/document/d/1BRVyW8IIVMTq4nhB_vUz5y-te6TEdu5g1XgolujjY6c/edit#heading=h.98203k4q66lm,
happy to do more if approved by Petri


Ok I've added also ODP_ASSERT to the document.

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


Re: [lng-odp] [RFC] api: crypto: Move completion event allocation to implementation

2014-12-05 Thread Taras Kondratiuk
On 12/05/2014 04:38 PM, Bala Manoharan wrote:
 Hi,
 
 In case of synchronous crypto operation the completion event is need 
 only in case of an error hence the application can check the return code 
 for failure and get info from completion event buffer only during that 
 scenario. This will greatly optimize the performance in synchronous 
 crypto operations.

This RFC aims to eliminate completion event handling by application, so
implementation (if capable) can optimize it and use output packet
instead. Both sync and async implementation will benefit in the same
way.

What you are asking is a separate optimization for sync mode which also
can be achieved on top of this RFC. We can add a note to
odp_crypto_operation() description: if the function succeeded and it
was synchronous an output packet can be queried without status check.


- implementation ---
int
odp_crypto_operation(odp_crypto_op_params_t *params,
 odp_buffer_t *completion_event)
{
...
process_packet(params-in_pkt, params-out_pkt);
*completion_event = odp_packet_to_buffer(params-out_pkt)
...
return 0;
}

odp_packet_t
odp_crypto_get_operation_compl_packet(odp_buffer_t completion_event)
{
return odp_packet_from_buffer(completion_event);
}

void
odp_crypto_operation_compl_free(odp_buffer_t completion_event)
{
}

- application (odp_ipsec.c)

/* Issue crypto request */
if (odp_crypto_operation(params, completion)) {
/* Call odp_crypto_get_operation_status(completion) if details 
are needed */
return PKT_DROP;
}

if (completion != ODP_BUFFER_INVALID) {
*pkt = odp_crypto_get_operation_compl_packet(completion);
return (*pkt != ODP_PACKET_INVALID) ? PKT_CONTINUE : PKT_DROP:
} else {
return PKT_POSTED;

If buffer-packet conversion is just casting, then overhead is zero.
Will it work for you?

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


Re: [lng-odp] [PATCHv2 1/5] validation: shm: move main() to a common place

2014-12-04 Thread Taras Kondratiuk

On 12/03/2014 03:45 PM, Stuart Haslam wrote:

On Wed, Dec 03, 2014 at 09:22:17AM +, Taras Kondratiuk wrote:

Most of test application will have the same main function.
Move main() from odp_shm to a common place where it can be reused by
other test applications.
Unifying main() will also simplify transition to a combined single test
application in future.



A couple of very minor nits below, but otherwise the series looks good
to me.


I agree with those comment, but those parts are preserved form the
original main() function. I'd better add these fixes as a follow
up patches. Will post them separately.

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


Re: [lng-odp] [PATCHv2 0/5] validation: harmonize test applications

2014-12-04 Thread Taras Kondratiuk

On 12/03/2014 09:44 PM, Mike Holmes wrote:

I also can add reviewed by with the exception of the 77 issue in main.

Maxim for expediency could you alter main to test for non zero and
return -1 as you pull the series in ?
Taras are you ok with that ?


As I've just replied to Stuart, that is an original functionality. I'd
be more logical to fix it in a separate patch. Will post it right now.

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


[lng-odp] [PATCH] validation: common: fix application exit status

2014-12-04 Thread Taras Kondratiuk
An exit status of 77 from a test application will denote a skipped test
for automake. So if exactly 77 failed we'd get a wrong result. Just
return -1 if any failure detected.

Reported-by: Stuart Haslam stuart.has...@arm.com
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---

Automake test manual:
http://www.gnu.org/software/automake/manual/html_node/Scripts_002dbased-Testsuites.html
---
 test/validation/common/odp_cunit_common.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/validation/common/odp_cunit_common.c 
b/test/validation/common/odp_cunit_common.c
index 14ba840..5ae457d 100644
--- a/test/validation/common/odp_cunit_common.c
+++ b/test/validation/common/odp_cunit_common.c
@@ -75,5 +75,5 @@ int main(void)
odp_term_local();
odp_term_global();
 
-   return ret;
+   return (ret) ? -1 : 0;
 }
-- 
1.7.9.5


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


Re: [lng-odp] [PATCHv2 3/5] validation: queue: reuse common main() function

2014-12-04 Thread Taras Kondratiuk

On 12/03/2014 03:35 PM, Taras Kondratiuk wrote:

Mike, Yan,

Could you please review this patch, to get the series merged?
This series needs rebase again, because another test change was just
merged.


ping

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


Re: [lng-odp] [PATCHv4 1/2] platform: debug: replace fprintf() with odp_override_log()

2014-12-03 Thread Taras Kondratiuk

On 12/02/2014 08:35 PM, Mike Holmes wrote:


- * ODP default LOG macro.
+ * ODP log function
+ *
+ * Instead of direct prints to stdout/stderr all logging in ODP
implementation
+ * should be done via this function or its wrappers.
+ * ODP platform MUST provide a default *weak* implementation of
this function.

MUST - must


This follows our specification approach to use RFC 2119.



+ * Application MAY override the function if needed by providing a
strong


MAY - may

+ * function.
+ *
+ * @param level   Log level


doxygen in or out

+ * @param fmt printf-style message format


doxygen in or out

+ */


need @return description or if possible @retval if there are specific
cases


Will add.



+extern int odp_override_log(odp_log_level_e level, const char *fmt,
...);


level does not appear to be the best name, these are output streams with
different characteristics rather than a single stream with different levels


No. This is a level. It even has type of odp_log_level_e.
Mapping it to streams is an implementation/application choice.



+
+/**
+ * ODP LOG macro.
   */
  #define ODP_LOG(level, fmt, ...) \
  do { \
 switch (level) { \
 case ODP_LOG_ERR: \
-   fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
 __LINE__, __func__, ##__VA_ARGS__); \
 break; \
 case ODP_LOG_DBG: \
 if (ODP_DEBUG_PRINT == 1) \
-   fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s(): fmt,
__FILE__, \
 __LINE__, __func__, ##__VA_ARGS__); \
 break; \
 case ODP_LOG_PRINT: \
-   fprintf(stdout,   fmt, ##__VA_ARGS__); \
+   odp_override_log(level,   fmt, ##__VA_ARGS__); \
 break; \
 case ODP_LOG_ABORT: \
-   fprintf(stderr, %s:%d:%s():  fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s():  fmt, __FILE__, \
 __LINE__, __func__, ##__VA_ARGS__); \
 abort(); \
 break; \
 case ODP_LOG_UNIMPLEMENTED: \
-   fprintf(stderr, \
+   odp_override_log(level, \
 %s:%d:The function %s() is not
implemented\n \
 fmt, __FILE__, __LINE__, __func__,
##__VA_ARGS__); \
 break; \
 default: \
-   fprintf(stderr, Unknown LOG level); \
+   odp_override_log(level, Unknown LOG level); \
 break;\
 } \
  } while (0)

  /**
- * Printing macro, which prints output when the application
- * calls one of the ODP APIs specifically for dumping internal data.
+ * Log print message when the application calls one of the ODP APIs
+ * specifically for dumping internal data.
   */
  #define ODP_PRINT(fmt, ...) \
 ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)

  /**
- * Debug printing macro, which prints output when DEBUG flag is set.
+ * Log debug message if DEBUG flag is set.


The flag is ODP_DEBUG_PRINT


I didn't change the original flag name. Will update it.



   */
  #define ODP_DBG(fmt, ...) \
 ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__)

  /**
- * Print output to stderr (file, line and function).
+ * Log error message.


We should say that this is not maskable


None of them is maskable except DEBUG level. Do you want to add
an explicit note to each of them?



   */
  #define ODP_ERR(fmt, ...) \
 ODP_LOG(ODP_LOG_ERR, fmt, ##__VA_ARGS__)

  /**
- * Print output to stderr (file, line and function),
- * then abort.
+ * Log abort message and then stop execution (by default call abort()).
+ * This function should not return.
   */
  #define ODP_ABORT(fmt, ...) \
 ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__)
diff --git a/platform/linux-generic/odp_weak.c
b/platform/linux-generic/odp_weak.c
new file mode 100644
index 000..fccbc3f
--- /dev/null
+++ b/platform/linux-generic/odp_weak.c
@@ -0,0 +1,23 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include odp_internal.h
+#include odp_debug.h
+#include odp_debug_internal.h
+#include odp_hints.h
+
+ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level ODP_UNUSED,
+const char *fmt, ...)


Why is this ODP_UNUSED, is it needed ?


Because level is unused in this default definition.


To use it 

Re: [lng-odp] [PATCHv4 2/2] platform: debug: Simplify ODP_LOG() macro

2014-12-03 Thread Taras Kondratiuk

On 12/02/2014 07:50 PM, Zoltan Kiss wrote:



On 02/12/14 17:07, Taras Kondratiuk wrote:

On 12/02/2014 06:42 PM, Zoltan Kiss wrote:

Hi,

At the moment, the careless developer look at enum odp_log_level and
starts using ODP_LOG(ODP_LOG_DBG, ...) instead of ODP_DBG.
I think it would be good to provide either ODP_LOG(loglevel, ...) or
ODP_[loglevel](...), but not both.


These are internal functions, so it is up to a platform
developer/maintainer to decide how he want to use them.


platform/linux-generic/include/api/odp_debug.h can be used by
applications, as my recent patch showed, the OVS interface does that for
example.


That is a mistake. We agreed that these functions are not public and can 
be used only inside of platform implementation.

We should move them to odp_debug_internal.h to avoid confusions.
The only thing that should stay in odp_debug.h it a declaration of
odp_override_log().


And this problem applies to ODP_LOG_ABORT as well: ODP_ABORT
will call abort(), while ODP_LOG(ODP_LOG_ABORT, ...) doesn't.
I think you can just drop the wholw ODP_LOG macro completely, as far as
I see nothing uses it anymore.


ODP_LOG is used as helper macro. If you wish I can call it _ODP_LOG, but 
honestly I don't see a real reason to do it.


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


Re: [lng-odp] [PATCH 3/5] validation: queue: reuse common main() function

2014-12-03 Thread Taras Kondratiuk

On 12/02/2014 09:08 PM, Mike Holmes wrote:

On 1 December 2014 at 12:05, Taras Kondratiuk
taras.kondrat...@linaro.org mailto:taras.kondrat...@linaro.org wrote:
+CU_SuiteInfo odp_testsuites[] = {
+   {Queue, init_suite, NULL, NULL, NULL, test_odp_queue},


No need to have init_suite just call test_odp_buffer_pool_init directly.


Will drop one redundant function.

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


[lng-odp] [PATCHv2 4/5] validation: crypto: reuse common main() function

2014-12-03 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
Reviewed-by: Mike Holmes mike.hol...@linaro.org
---
 test/validation/Makefile.am  |2 +-
 test/validation/odp_crypto.c |   43 ++
 2 files changed, 7 insertions(+), 38 deletions(-)

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 183fb0c..ecb1170 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -19,5 +19,5 @@ dist_odp_init_SOURCES = odp_init.c
 dist_odp_queue_SOURCES = odp_queue.c common/odp_cunit_common.c
 dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
  crypto/odp_crypto_test_sync_inp.c \
- odp_crypto.c
+ odp_crypto.c common/odp_cunit_common.c
 dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
diff --git a/test/validation/odp_crypto.c b/test/validation/odp_crypto.c
index 9342aca..ec3f16a 100644
--- a/test/validation/odp_crypto.c
+++ b/test/validation/odp_crypto.c
@@ -5,8 +5,7 @@
  */
 
 #include odp.h
-#include CUnit/Basic.h
-#include CUnit/TestDB.h
+#include odp_cunit_common.h
 #include odp_crypto_test_async_inp.h
 #include odp_crypto_test_sync_inp.h
 
@@ -16,32 +15,19 @@
 #define SHM_COMPL_POOL_SIZE(128*1024)
 #define SHM_COMPL_POOL_BUF_SIZE128
 
-static int init_suite(void)
-{
-   printf(\tODP API version: %s\n, odp_version_api_str());
-   printf(\tODP implementation version: %s\n, odp_version_impl_str());
-   return 0;
-}
-
-CU_SuiteInfo suites[] = {
-   {ODP_CRYPTO_SYNC_INP, init_suite, NULL, NULL, NULL, test_array_sync },
-   {ODP_CRYPTO_ASYNC_INP, init_suite, NULL, NULL, NULL, test_array_async },
+CU_SuiteInfo odp_testsuites[] = {
+   {ODP_CRYPTO_SYNC_INP, NULL, NULL, NULL, NULL, test_array_sync },
+   {ODP_CRYPTO_ASYNC_INP, NULL, NULL, NULL, NULL, test_array_async },
CU_SUITE_INFO_NULL,
 };
 
-int main(void)
+int tests_global_init(void)
 {
odp_shm_t shm;
void *pool_base;
odp_buffer_pool_t pool;
odp_queue_t out_queue;
 
-   if (odp_init_global(NULL, NULL)) {
-   printf(ODP global init failed.\n);
-   return -1;
-   }
-   odp_init_local();
-
shm = odp_shm_reserve(shm_packet_pool,
  SHM_PKT_POOL_SIZE,
  ODP_CACHE_LINE_SIZE, 0);
@@ -86,22 +72,5 @@ int main(void)
return -1;
}
 
-   printf(\tODP version: %s\n, odp_version_api_str());
-
-
-   /* initialize the CUnit test registry */
-   if (CUE_SUCCESS != CU_initialize_registry())
-   return CU_get_error();
-
-   /* register suites */
-   CU_register_suites(suites);
-   /* Run all tests using the CUnit Basic interface */
-   CU_basic_set_mode(CU_BRM_VERBOSE);
-   CU_basic_run_tests();
-   CU_cleanup_registry();
-
-   odp_term_local();
-   odp_term_global();
-
-   return CU_get_error();
+   return 0;
 }
-- 
1.7.9.5


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


[lng-odp] [PATCHv2 3/5] validation: queue: reuse common main() function

2014-12-03 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 test/validation/Makefile.am |2 +-
 test/validation/odp_queue.c |   64 +++
 2 files changed, 11 insertions(+), 55 deletions(-)

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 837ae95..183fb0c 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -16,7 +16,7 @@ odp_shm_LDFLAGS = $(AM_LDFLAGS)
 endif
 
 dist_odp_init_SOURCES = odp_init.c
-dist_odp_queue_SOURCES = odp_queue.c
+dist_odp_queue_SOURCES = odp_queue.c common/odp_cunit_common.c
 dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
  crypto/odp_crypto_test_sync_inp.c \
  odp_crypto.c
diff --git a/test/validation/odp_queue.c b/test/validation/odp_queue.c
index 09dba0e..2c8fe80 100644
--- a/test/validation/odp_queue.c
+++ b/test/validation/odp_queue.c
@@ -5,7 +5,7 @@
  */
 
 #include odp.h
-#include CUnit/Basic.h
+#include odp_cunit_common.h
 
 #define MAX_BUFFER_QUEUE(8)
 #define MSG_POOL_SIZE   (4*1024*1024)
@@ -13,7 +13,7 @@
 
 static int queue_contest = 0xff;
 
-static int test_odp_buffer_pool_init(void)
+static int init_queue_suite(void)
 {
odp_buffer_pool_t pool;
void *pool_base;
@@ -105,56 +105,12 @@ static void test_odp_queue_sunnyday(void)
return;
 }
 
-static int init_suite(void)
-{
-   printf(\tODP API version: %s\n, odp_version_api_str());
-   printf(\tODP implementation version: %s\n, odp_version_impl_str());
-
-   if (0 != odp_init_global(NULL, NULL)) {
-   printf(odp_init_global fail.\n);
-   return -1;
-   }
-   if (0 != odp_init_local()) {
-   printf(odp_init_local fail.\n);
-   return -1;
-   }
-   if (0 != test_odp_buffer_pool_init()) {
-   printf(test_odp_buffer_pool_init fail.\n);
-   return -1;
-   }
-   return 0;
-}
-
-static int finalize(void)
-{
-   odp_term_local();
-   odp_term_global();
-   return 0;
-}
-
-int main(void)
-{
-   CU_pSuite ptr_suite = NULL;
-
-   /* initialize the CUnit test registry */
-   if (CUE_SUCCESS != CU_initialize_registry())
-   return CU_get_error();
+CU_TestInfo test_odp_queue[] = {
+   {queue sunnyday,  test_odp_queue_sunnyday},
+   CU_TEST_INFO_NULL,
+};
 
-   /* add the tests to the queue suite */
-   ptr_suite = CU_add_suite(__FILE__, init_suite, finalize);
-   if (NULL == ptr_suite) {
-   CU_cleanup_registry();
-   return CU_get_error();
-   }
-
-   if (NULL == CU_ADD_TEST(ptr_suite, test_odp_queue_sunnyday)) {
-   CU_cleanup_registry();
-   return CU_get_error();
-   }
-
-   /* Run all tests using the CUnit Basic interface */
-   CU_basic_set_mode(CU_BRM_VERBOSE);
-   CU_basic_run_tests();
-   CU_cleanup_registry();
-   return CU_get_error();
-}
+CU_SuiteInfo odp_testsuites[] = {
+   {Queue, init_queue_suite, NULL, NULL, NULL, test_odp_queue},
+   CU_SUITE_INFO_NULL,
+};
-- 
1.7.9.5


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


Re: [lng-odp] [PATCHv2 1/3] ODP buffer pool restructure

2014-12-03 Thread Taras Kondratiuk

On 12/03/2014 01:07 PM, Anders Roxell wrote:

Hi,

This is the proposed way to break up your patch:
1. break circular dependencies
2. move inline functions to a new odp_buffer_inlines.h file.
3. restructuring ODP buffer pool
4. odp_buffer_pool_create
5. odp_buffer_pool_destroy
6. odp_buffer_pool_info


I agree. It would be better to have refactoring first and then clean
API changes. 1-3 patches may be squashed if changes are interdependent.

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


Re: [lng-odp] [PATCHv4 2/2] platform: debug: Simplify ODP_LOG() macro

2014-12-03 Thread Taras Kondratiuk

On 12/03/2014 04:15 PM, Zoltan Kiss wrote:



On 03/12/14 08:41, Taras Kondratiuk wrote:

On 12/02/2014 07:50 PM, Zoltan Kiss wrote:

And this problem applies to ODP_LOG_ABORT as well: ODP_ABORT
will call abort(), while ODP_LOG(ODP_LOG_ABORT, ...) doesn't.
I think you can just drop the wholw ODP_LOG macro completely, as far as
I see nothing uses it anymore.


ODP_LOG is used as helper macro. If you wish I can call it _ODP_LOG, but
honestly I don't see a real reason to do it.

I mean ODP_LOG is used now twice, in ODP_DBG and ODP_ABORT, to add
(__FILE__, __LINE__, __func__) to the string. In the meantime ODP_PRINT
and ODP_UNIMPLEMENTED calls odp_override_log directly. I think we should
just ditch ODP_LOG and call odp_override_log directly from everywhere,
so noone gets tempted to use it in a platform implementation.


ODP_LOG is actually used three times (ODP_ERR is not shown in the
patch). ODP_PRINT was also using ODP_LOG until recent changes.
IMO even with three places it worth to have a common ODP_LOG instead of 
copying format string.


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


[lng-odp] [PATCHv5 1/2] platform: debug: replace fprintf() with odp_override_log()

2014-12-03 Thread Taras Kondratiuk
ODP application may want to override default ODP logging behaviour
and use custom logging function. Add a weak odp_override_log() function
for this purpose instead of default fprintf().

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/Makefile.am |3 +-
 platform/linux-generic/include/api/odp_debug.h |   44 +---
 platform/linux-generic/odp_weak.c  |   23 +
 3 files changed, 56 insertions(+), 14 deletions(-)
 create mode 100644 platform/linux-generic/odp_weak.c

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index e709700..cc78de3 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -75,4 +75,5 @@ __LIB__libodp_la_SOURCES = \
   odp_thread.c \
   odp_ticketlock.c \
   odp_time.c \
-  odp_timer.c
+  odp_timer.c \
+  odp_weak.c
diff --git a/platform/linux-generic/include/api/odp_debug.h 
b/platform/linux-generic/include/api/odp_debug.h
index e853be4..aa99e29 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -14,6 +14,7 @@
 
 #include stdio.h
 #include stdlib.h
+#include stdarg.h
 
 #ifdef __cplusplus
 extern C {
@@ -81,61 +82,78 @@ typedef enum odp_log_level {
 } odp_log_level_e;
 
 /**
- * ODP default LOG macro.
+ * ODP log function
+ *
+ * Instead of direct prints to stdout/stderr all logging in ODP implementation
+ * should be done via this function or its wrappers.
+ * ODP platform MUST provide a default *weak* implementation of this function.
+ * Application MAY override the function if needed by providing a strong
+ * function.
+ *
+ * @param[in] level   Log level
+ * @param[in] fmt printf-style message format
+ *
+ * @return The number of characters logged if succeeded. Otherwise returns
+ * a negative number.
+ */
+extern int odp_override_log(odp_log_level_e level, const char *fmt, ...);
+
+/**
+ * ODP LOG macro.
  */
 #define ODP_LOG(level, fmt, ...) \
 do { \
switch (level) { \
case ODP_LOG_ERR: \
-   fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
__LINE__, __func__, ##__VA_ARGS__); \
break; \
case ODP_LOG_DBG: \
if (ODP_DEBUG_PRINT == 1) \
-   fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
__LINE__, __func__, ##__VA_ARGS__); \
break; \
case ODP_LOG_PRINT: \
-   fprintf(stdout,   fmt, ##__VA_ARGS__); \
+   odp_override_log(level,   fmt, ##__VA_ARGS__); \
break; \
case ODP_LOG_ABORT: \
-   fprintf(stderr, %s:%d:%s():  fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s():  fmt, __FILE__, \
__LINE__, __func__, ##__VA_ARGS__); \
abort(); \
break; \
case ODP_LOG_UNIMPLEMENTED: \
-   fprintf(stderr, \
+   odp_override_log(level, \
%s:%d:The function %s() is not implemented\n \
fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
break; \
default: \
-   fprintf(stderr, Unknown LOG level); \
+   odp_override_log(level, Unknown LOG level); \
break;\
} \
 } while (0)
 
 /**
- * Printing macro, which prints output when the application
- * calls one of the ODP APIs specifically for dumping internal data.
+ * Log print message when the application calls one of the ODP APIs
+ * specifically for dumping internal data.
  */
 #define ODP_PRINT(fmt, ...) \
ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
 
 /**
- * Debug printing macro, which prints output when DEBUG flag is set.
+ * Log debug message if ODP_DEBUG_PRINT flag is set.
  */
 #define ODP_DBG(fmt, ...) \
ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__)
 
 /**
- * Print output to stderr (file, line and function).
+ * Log error message.
  */
 #define ODP_ERR(fmt, ...) \
ODP_LOG(ODP_LOG_ERR, fmt, ##__VA_ARGS__)
 
 /**
- * Print output to stderr (file, line and function),
- * then abort.
+ * Log abort message and then stop execution (by default call abort()).
+ * This function should not return.
  */
 #define ODP_ABORT(fmt, ...) \
ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__)
diff --git a/platform/linux-generic/odp_weak.c 
b/platform/linux-generic/odp_weak.c
new file mode 100644
index 000..fccbc3f
--- /dev/null
+++ b/platform/linux-generic/odp_weak.c
@@ -0,0 +1,23 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License

[lng-odp] [PATCHv5 2/2] platform: debug: Simplify ODP_LOG() macro

2014-12-03 Thread Taras Kondratiuk
Move additional functionality out of ODP_LOG. Keep only logging.

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/include/api/odp_debug.h |   43 +---
 .../linux-generic/include/odp_debug_internal.h |6 ++-
 2 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_debug.h 
b/platform/linux-generic/include/api/odp_debug.h
index aa99e29..1f5eaff 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -102,48 +102,24 @@ extern int odp_override_log(odp_log_level_e level, const 
char *fmt, ...);
  * ODP LOG macro.
  */
 #define ODP_LOG(level, fmt, ...) \
-do { \
-   switch (level) { \
-   case ODP_LOG_ERR: \
-   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_DBG: \
-   if (ODP_DEBUG_PRINT == 1) \
-   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_PRINT: \
-   odp_override_log(level,   fmt, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_ABORT: \
-   odp_override_log(level, %s:%d:%s():  fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   abort(); \
-   break; \
-   case ODP_LOG_UNIMPLEMENTED: \
-   odp_override_log(level, \
-   %s:%d:The function %s() is not implemented\n \
-   fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   default: \
-   odp_override_log(level, Unknown LOG level); \
-   break;\
-   } \
-} while (0)
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
+   __LINE__, __func__, ##__VA_ARGS__)
 
 /**
  * Log print message when the application calls one of the ODP APIs
  * specifically for dumping internal data.
  */
 #define ODP_PRINT(fmt, ...) \
-   ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
+   odp_override_log(ODP_LOG_PRINT,   fmt, ##__VA_ARGS__)
 
 /**
  * Log debug message if ODP_DEBUG_PRINT flag is set.
  */
 #define ODP_DBG(fmt, ...) \
-   ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__)
+   do { \
+   if (ODP_DEBUG_PRINT == 1) \
+   ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__);\
+   } while (0)
 
 /**
  * Log error message.
@@ -156,7 +132,10 @@ do { \
  * This function should not return.
  */
 #define ODP_ABORT(fmt, ...) \
-   ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__)
+   do { \
+   ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__); \
+   abort(); \
+   } while (0)
 
 /**
  * @}
diff --git a/platform/linux-generic/include/odp_debug_internal.h 
b/platform/linux-generic/include/odp_debug_internal.h
index a87552f..ee3c543 100644
--- a/platform/linux-generic/include/odp_debug_internal.h
+++ b/platform/linux-generic/include/odp_debug_internal.h
@@ -25,8 +25,10 @@ extern C {
 /**
  * This macro is used to indicate when a given function is not implemented
  */
-#define ODP_UNIMPLEMENTED(fmt, ...) \
-   ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
+#define ODP_UNIMPLEMENTED() \
+   odp_override_log(ODP_LOG_UNIMPLEMENTED, \
+   %s:%d:The function %s() is not implemented\n, \
+   __FILE__, __LINE__, __func__)
 
 #ifdef __cplusplus
 }
-- 
1.7.9.5


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


[lng-odp] [PATCHv5 0/2] Add a way to override default ODP_LOG behavior

2014-12-03 Thread Taras Kondratiuk
This series adds a default weak odp_override_log() function which can
be replaced by application.

v5: Updated doxygen comment
v4: Move abort() back into ODP_ABORT() to prevent uninitialized
variables warnings.
v3: Rebased and fixed conflicts with merged patches.
v2: Fixed missed comma in ODP_UNIMPLEMENTED() macro.

Taras Kondratiuk (2):
  platform: debug: replace fprintf() with odp_override_log()
  platform: debug: Simplify ODP_LOG() macro

 platform/linux-generic/Makefile.am |3 +-
 platform/linux-generic/include/api/odp_debug.h |   75 ++--
 .../linux-generic/include/odp_debug_internal.h |6 +-
 platform/linux-generic/odp_weak.c  |   23 ++
 4 files changed, 65 insertions(+), 42 deletions(-)
 create mode 100644 platform/linux-generic/odp_weak.c

-- 
1.7.9.5


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


Re: [lng-odp] [PATCH 1/5] validation: shm: move main() to a common place

2014-12-02 Thread Taras Kondratiuk

On 12/01/2014 08:52 PM, Mike Holmes wrote:



On 1 December 2014 at 12:05, Taras Kondratiuk
taras.kondrat...@linaro.org mailto:taras.kondrat...@linaro.org wrote:
+
+int main(void)
+{
+   int ret;
+
+   printf(\tODP API version: %s\n, odp_version_api_str());
+   printf(\tODP implementation version: %s\n,
odp_version_impl_str());


I don't think this will work long term.

I think that we need to view a test_suite as an odp application, and any
number of suites could be run in any order.
We dont want to focus on the batch mode main() because when we migrate
to a library there will not be a main when calling tests interactively
if so desired. I expect we will have a wrapper batch mode main() that
will call all the suites however so that make check still has
something to call.


I can't agree on the next points:
1. test suite is an ODP application. It is *not*, because they are
executed as a part of a single application. According to a current
specification odp_global_init() is called only *once* per application.
If you really want to allow several global_init(), then this use case
should be mentioned in the specification. But you should understand,
that this may significantly complicate implementation. For example
linux-generic don't have odp_term_global() and it works fine because OS
takes care about resources. If we allow several odp_global_init()
calls, then implementation have to carefully clear resources by itself.

2. when we migrate to a library there will not be a main(). There
will be main() which select either batch or interactive mode.



I think a suite_init should perform the global init and suite_finalize
  should do a odp_finalize. To that end with a suite being generally
smallest unit of testing that can be run,  it should also print up what
it is being run on - the prints above. I don't see a lot of use for
test_init because I don't think we want to be doing odp_global_init per
test although you could argue every test should be as independent as
possible.


Those printfs prints API and implementation versions which are
attributes of library, but not a testsuite. That's why they should be 
print only once per test application start, but not on every testsuite 
execution.




I know there is an argument that HW vs SW implementations change how
completely calling odp global finalize really creates a clean
environment for the next test, but to my mind if suites = odp_apps they
should work, OPNFV will require clean teardown without reboot.


That's the point where we disagree suites = odp app. I expect a lot of 
issues with vendor's SDKs, because this is not a normal usecase for them 
to reinitialize environment in the same process. They may rely for 
example on zero'ed static variables which will have some values on a 
second init.


I'd like to get comments from Bala and Alex here.



With a good argument to keep odp calls in main I could be swayed but
right now I think it needs to be in the init and finalize function for a
suite.


Please see above why they can't be there.

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


[lng-odp] [PATCHv4 2/2] platform: debug: Simplify ODP_LOG() macro

2014-12-02 Thread Taras Kondratiuk
Move additional functionality out of ODP_LOG. Keep only logging.

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/include/api/odp_debug.h |   43 +---
 .../linux-generic/include/odp_debug_internal.h |6 ++-
 2 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_debug.h 
b/platform/linux-generic/include/api/odp_debug.h
index 4b51038..13c3939 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -99,48 +99,24 @@ extern int odp_override_log(odp_log_level_e level, const 
char *fmt, ...);
  * ODP LOG macro.
  */
 #define ODP_LOG(level, fmt, ...) \
-do { \
-   switch (level) { \
-   case ODP_LOG_ERR: \
-   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_DBG: \
-   if (ODP_DEBUG_PRINT == 1) \
-   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_PRINT: \
-   odp_override_log(level,   fmt, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_ABORT: \
-   odp_override_log(level, %s:%d:%s():  fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   abort(); \
-   break; \
-   case ODP_LOG_UNIMPLEMENTED: \
-   odp_override_log(level, \
-   %s:%d:The function %s() is not implemented\n \
-   fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   default: \
-   odp_override_log(level, Unknown LOG level); \
-   break;\
-   } \
-} while (0)
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
+   __LINE__, __func__, ##__VA_ARGS__)
 
 /**
  * Log print message when the application calls one of the ODP APIs
  * specifically for dumping internal data.
  */
 #define ODP_PRINT(fmt, ...) \
-   ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
+   odp_override_log(ODP_LOG_PRINT,   fmt, ##__VA_ARGS__)
 
 /**
  * Log debug message if DEBUG flag is set.
  */
 #define ODP_DBG(fmt, ...) \
-   ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__)
+   do { \
+   if (ODP_DEBUG_PRINT == 1) \
+   ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__);\
+   } while (0)
 
 /**
  * Log error message.
@@ -153,7 +129,10 @@ do { \
  * This function should not return.
  */
 #define ODP_ABORT(fmt, ...) \
-   ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__)
+   do { \
+   ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__); \
+   abort(); \
+   } while (0)
 
 /**
  * @}
diff --git a/platform/linux-generic/include/odp_debug_internal.h 
b/platform/linux-generic/include/odp_debug_internal.h
index a87552f..ee3c543 100644
--- a/platform/linux-generic/include/odp_debug_internal.h
+++ b/platform/linux-generic/include/odp_debug_internal.h
@@ -25,8 +25,10 @@ extern C {
 /**
  * This macro is used to indicate when a given function is not implemented
  */
-#define ODP_UNIMPLEMENTED(fmt, ...) \
-   ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
+#define ODP_UNIMPLEMENTED() \
+   odp_override_log(ODP_LOG_UNIMPLEMENTED, \
+   %s:%d:The function %s() is not implemented\n, \
+   __FILE__, __LINE__, __func__)
 
 #ifdef __cplusplus
 }
-- 
1.7.9.5


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


[lng-odp] [PATCHv2 2/2] platform: implement odp_queue_destroy()

2014-12-02 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 .../linux-generic/include/odp_queue_internal.h |   23 +--
 platform/linux-generic/odp_queue.c |   72 +++-
 platform/linux-generic/odp_schedule.c  |3 +-
 3 files changed, 92 insertions(+), 6 deletions(-)

diff --git a/platform/linux-generic/include/odp_queue_internal.h 
b/platform/linux-generic/include/odp_queue_internal.h
index 8b6c517..501f727 100644
--- a/platform/linux-generic/include/odp_queue_internal.h
+++ b/platform/linux-generic/include/odp_queue_internal.h
@@ -34,10 +34,11 @@ extern C {
 
 #define QUEUE_MULTI_MAX 8
 
-#define QUEUE_STATUS_FREE 0
-#define QUEUE_STATUS_READY1
-#define QUEUE_STATUS_NOTSCHED 2
-#define QUEUE_STATUS_SCHED3
+#define QUEUE_STATUS_FREE 0
+#define QUEUE_STATUS_READY1
+#define QUEUE_STATUS_NOTSCHED 2
+#define QUEUE_STATUS_SCHED3
+#define QUEUE_STATUS_DESTROYED4
 
 /* forward declaration */
 union queue_entry_u;
@@ -89,6 +90,12 @@ odp_buffer_hdr_t *queue_deq(queue_entry_t *queue);
 int queue_enq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int 
num);
 int queue_deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int 
num);
 
+int queue_enq_dummy(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr);
+int queue_enq_multi_dummy(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[],
+ int num);
+int queue_deq_multi_destroy(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[],
+   int num);
+
 void queue_lock(queue_entry_t *queue);
 void queue_unlock(queue_entry_t *queue);
 
@@ -113,6 +120,14 @@ static inline queue_entry_t *queue_to_qentry(odp_queue_t 
handle)
return get_qentry(queue_id);
 }
 
+static inline int queue_is_destroyed(odp_queue_t handle)
+{
+   queue_entry_t *queue;
+
+   queue = queue_to_qentry(handle);
+
+   return queue-s.status == QUEUE_STATUS_DESTROYED;
+}
 #ifdef __cplusplus
 }
 #endif
diff --git a/platform/linux-generic/odp_queue.c 
b/platform/linux-generic/odp_queue.c
index 1318bcd..b87b354 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -192,6 +192,49 @@ odp_queue_t odp_queue_create(const char *name, 
odp_queue_type_t type,
return handle;
 }
 
+int odp_queue_destroy(odp_queue_t handle)
+{
+   queue_entry_t *queue;
+   queue = queue_to_qentry(handle);
+
+   if (queue-s.status == QUEUE_STATUS_FREE)
+   return -1; /* Queue is alredy freed */
+
+   LOCK(queue-s.lock);
+   if (queue-s.head != NULL) {
+   UNLOCK(queue-s.lock);
+   return -1; /* Queue is not empty */
+   }
+
+   queue-s.enqueue = queue_enq_dummy;
+   queue-s.enqueue_multi = queue_enq_multi_dummy;
+
+   if (queue-s.type == ODP_QUEUE_TYPE_POLL ||
+   queue-s.type == ODP_QUEUE_TYPE_PKTOUT) {
+   queue-s.status = QUEUE_STATUS_FREE;
+   queue-s.head = NULL;
+   queue-s.tail = NULL;
+   } else if (queue-s.type == ODP_QUEUE_TYPE_SCHED) {
+   if (queue-s.status == QUEUE_STATUS_SCHED)  {
+   /*
+* Override dequeue_multi to destroy queue when it will
+* be scheduled next time.
+*/
+   queue-s.status = QUEUE_STATUS_DESTROYED;
+   queue-s.dequeue_multi = queue_deq_multi_destroy;
+   } else {
+   /* Queue won't be scheduled anymore */
+   odp_buffer_free(queue-s.sched_buf);
+   queue-s.sched_buf = ODP_BUFFER_INVALID;
+   queue-s.status = QUEUE_STATUS_FREE;
+   queue-s.head = NULL;
+   queue-s.tail = NULL;
+   }
+   }
+   UNLOCK(queue-s.lock);
+
+   return 0;
+}
 
 odp_buffer_t queue_sched_buf(odp_queue_t handle)
 {
@@ -279,7 +322,6 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t 
*buf_hdr)
return 0;
 }
 
-
 int queue_enq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num)
 {
int sched = 0;
@@ -314,6 +356,18 @@ int queue_enq_multi(queue_entry_t *queue, odp_buffer_hdr_t 
*buf_hdr[], int num)
return 0;
 }
 
+int queue_enq_dummy(queue_entry_t *queue ODP_UNUSED,
+   odp_buffer_hdr_t *buf_hdr ODP_UNUSED)
+{
+   return -1;
+}
+
+int queue_enq_multi_dummy(queue_entry_t *queue ODP_UNUSED,
+ odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED,
+ int num ODP_UNUSED)
+{
+   return -1;
+}
 
 int odp_queue_enq_multi(odp_queue_t handle, odp_buffer_t buf[], int num)
 {
@@ -407,6 +461,22 @@ int queue_deq_multi(queue_entry_t *queue, odp_buffer_hdr_t 
*buf_hdr[], int num)
return i;
 }
 
+int queue_deq_multi_destroy(queue_entry_t *queue,
+   odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED

Re: [lng-odp] [PATCHv4 2/2] platform: debug: Simplify ODP_LOG() macro

2014-12-02 Thread Taras Kondratiuk

On 12/02/2014 06:42 PM, Zoltan Kiss wrote:

Hi,

At the moment, the careless developer look at enum odp_log_level and
starts using ODP_LOG(ODP_LOG_DBG, ...) instead of ODP_DBG.
I think it would be good to provide either ODP_LOG(loglevel, ...) or
ODP_[loglevel](...), but not both.


These are internal functions, so it is up to a platform
developer/maintainer to decide how he want to use them.

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


Re: [lng-odp] [PATCH] ODP buffer pool restructure for v1.0 APIs

2014-12-02 Thread Taras Kondratiuk

On 12/01/2014 03:47 AM, Bill Fischofer wrote:

+int odp_buffer_pool_destroy(odp_buffer_pool_t pool_hdl)
+{
+   uint32_t pool_id = pool_handle_to_index(pool_hdl);
+   pool_entry_t *pool = get_pool_entry(pool_id);

-   if (chunk-chunk.num_bufs == 0) {
-   /* give the chunk buffer */
-   local_chunk[pool_id] = NULL;
-   chunk-buf_hdr.type = pool-s.buf_type;
+   if (pool == NULL)
+   return -1;

-   handle = chunk-buf_hdr.handle;
-   } else {
-   odp_buffer_hdr_t *hdr;
-   uint32_t index;
-   index = rem_buf_index(chunk);
-   hdr = index_to_hdr(pool, index);
+   LOCK(pool-s.lock);

-   handle = hdr-handle;
+   if (pool-s.pool_shm == ODP_SHM_INVALID ||
+   odp_atomic_load_u32(pool-s.bufcount)  0 ||
+   pool-s.flags.predefined) {
+   UNLOCK(pool-s.lock);
+   return -1;
}

-   return handle.u32;
-}
+   if (!pool-s.flags.user_supplied_shm)
+   odp_shm_free(pool-s.pool_shm);

+   pool-s.pool_shm = 0;


should be ODP_SHM_INVALID instead of 0.


+   UNLOCK(pool-s.lock);


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


Re: [lng-odp] [PATCH v6] cunit: add shm test

2014-12-01 Thread Taras Kondratiuk

On 11/29/2014 10:43 AM, Yan Sonming wrote:

diff --git a/test/validation/common/odp_cunit_common.h 
b/test/validation/common/odp_cunit_common.h
new file mode 100644
index 000..5eec376
--- /dev/null
+++ b/test/validation/common/odp_cunit_common.h
@@ -0,0 +1,35 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP test application common headers
+ */
+
+#ifndef ODP_CUNICT_COMMON_H
+#define ODP_CUNICT_COMMON_H
+
+#define MAX_WORKERS 32 /** Maximum number of work threads */
+
+typedef struct {
+   uint32_t foo;
+   uint32_t bar;
+} test_shared_data_t;
+
+/**
+ * Thread argument
+ */
+typedef struct {
+   int testcase; /** specifies which set of API's to exercise */
+   int numthrds; /** no of pthreads to create */
+} pthrd_arg;
+
+/** create thread fro start_routine function */
+extern int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg);
+extern int odp_cunit_thread_exit(pthrd_arg *);
+
+#endif /* ODP_COMMON_H */


You have missed a nit from Jerin. s/ODP_COMMON_H/ODP_CUNICT_COMMON_H/
Maybe Maxim can fix it.

Rewieved-by: Taras Kondratiuk taras.kondrat...@linaro.org

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


Re: [lng-odp] [PATCH v1] validation: queue: use CU_register_suites() for tests registration

2014-12-01 Thread Taras Kondratiuk

On 12/01/2014 01:58 PM, Maxim Uvarov wrote:

Taras, I think you need to send your patch without RFC.

Yan, please provide your reviewed-by to Taras patch series.


It is RFC, because depends in Yan's shm test patch in-flight.
I'll repost it after Yan's patch is merged.

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


Re: [lng-odp] [PATCH] linux-generic: fix queue handle check in odp_pktio_inq_setdef

2014-12-01 Thread Taras Kondratiuk

On 11/27/2014 11:39 AM, Stuart Haslam wrote:

queue_to_qentry doesn't do any validation of the queue handle so will
never return NULL and ends up returning an invalid pointer if passed
ODP_QUEUE_INVALID.


Reviewed-by: Taras Kondratiuk taras.kondrat...@linaro.org

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


Re: [lng-odp] [PATCH] linux-generic: fix sockfd store and lookup errors

2014-12-01 Thread Taras Kondratiuk

On 11/27/2014 11:38 AM, Stuart Haslam wrote:

In ODP_PACKET_SOCKET_MMSG or ODP_PACKET_SOCKET_BASIC modes, when the
same interface is opened multiple times an attempt is made to use a
single socket descriptor for all instances. There are a few issues with
the implementation though;

  - a desciptor value of 0 is used to indicate an unused entry, but
this is a valid value for a socket descriptor
  - the first call to odp_pktio_close() will close the socket leaving
any other instances with a stale descriptor
  - descriptors are never removed from the raw_sockets list, so the
sequence open-close-open for a single interface results in a
stale descriptor


Reviewed-by: Taras Kondratiuk taras.kondrat...@linaro.org

Wouldn't it be simpler to add refcounting at pktio level and just return 
the same handle to all threads on odp_pktio_open()?

What is the advantage of having separate pktio handles in each thread?
Any pktio parameters that can be configured differently per thread?

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


[lng-odp] [PATCH 1/5] validation: shm: move main() to a common place

2014-12-01 Thread Taras Kondratiuk
Most of test application will have the same main function.
Move main() from odp_shm to a common place where it can be reused by
other test applications.
Unifying main() will also simplify transition to a combined single test
application in future.

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 test/validation/Makefile.am   |4 +--
 test/validation/common/odp_cunit_common.c |   33 +++
 test/validation/common/odp_cunit_common.h |9 +++
 test/validation/odp_shm.c |   42 ++---
 4 files changed, 46 insertions(+), 42 deletions(-)

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 4bee2ab..8b55bad 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -1,6 +1,6 @@
 include $(top_srcdir)/test/Makefile.inc
 
-AM_CFLAGS += -I$(CUNIT_PATH)/include
+AM_CFLAGS += -I$(CUNIT_PATH)/include -I$(srcdir)/common
 AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
 
 if ODP_CUNIT_ENABLED
@@ -11,7 +11,7 @@ odp_init_LDFLAGS = $(AM_LDFLAGS)
 odp_queue_LDFLAGS = $(AM_LDFLAGS)
 odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
 odp_crypto_LDFLAGS = $(AM_LDFLAGS)
-odp_shm_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/common
+odp_shm_CFLAGS = $(AM_CFLAGS)
 odp_shm_LDFLAGS = $(AM_LDFLAGS)
 endif
 
diff --git a/test/validation/common/odp_cunit_common.c 
b/test/validation/common/odp_cunit_common.c
index 885b981..c87e103 100644
--- a/test/validation/common/odp_cunit_common.c
+++ b/test/validation/common/odp_cunit_common.c
@@ -35,3 +35,36 @@ int odp_cunit_thread_exit(pthrd_arg *arg)
 
return 0;
 }
+
+int main(void)
+{
+   int ret;
+
+   printf(\tODP API version: %s\n, odp_version_api_str());
+   printf(\tODP implementation version: %s\n, odp_version_impl_str());
+
+   if (0 != odp_init_global(NULL, NULL)) {
+   printf(odp_init_global fail.\n);
+   return -1;
+   }
+   if (0 != odp_init_local()) {
+   printf(odp_init_local fail.\n);
+   return -1;
+   }
+
+   CU_set_error_action(CUEA_ABORT);
+
+   CU_initialize_registry();
+   CU_register_suites(odp_testsuites);
+   CU_basic_set_mode(CU_BRM_VERBOSE);
+   CU_basic_run_tests();
+
+   ret = CU_get_number_of_failure_records();
+
+   CU_cleanup_registry();
+
+   odp_term_local();
+   odp_term_global();
+
+   return ret;
+}
diff --git a/test/validation/common/odp_cunit_common.h 
b/test/validation/common/odp_cunit_common.h
index 71a3350..1f30788 100644
--- a/test/validation/common/odp_cunit_common.h
+++ b/test/validation/common/odp_cunit_common.h
@@ -13,8 +13,17 @@
 #ifndef ODP_CUNICT_COMMON_H
 #define ODP_CUNICT_COMMON_H
 
+#include CUnit/Basic.h
+
 #define MAX_WORKERS 32 /** Maximum number of work threads */
 
+/**
+ * Array of testsuites provided by a test application. Array must be terminated
+ * by CU_SUITE_INFO_NULL and must be suitable to be used by
+ * CU_register_suites().
+ */
+extern CU_SuiteInfo odp_testsuites[];
+
 typedef struct {
uint32_t foo;
uint32_t bar;
diff --git a/test/validation/odp_shm.c b/test/validation/odp_shm.c
index bcd46c7..8a991b1 100644
--- a/test/validation/odp_shm.c
+++ b/test/validation/odp_shm.c
@@ -5,7 +5,6 @@
  */
 
 #include odp.h
-#include CUnit/Basic.h
 #include odp_cunit_common.h
 
 #define ALIGE_SIZE  (128)
@@ -71,50 +70,13 @@ static void test_odp_shm_sunnyday(void)
odp_cunit_thread_exit(thrdarg);
 }
 
-static int init(void)
-{
-   printf(\tODP API version: %s\n, odp_version_api_str());
-   printf(\tODP implementation version: %s\n, odp_version_impl_str());
-   return 0;
-}
-
 CU_TestInfo test_odp_shm[] = {
{test_odp_shm_creat,  test_odp_shm_sunnyday},
CU_TEST_INFO_NULL,
 };
 
-CU_SuiteInfo suites[] = {
-   {odp_system, init, NULL, NULL, NULL, test_odp_shm},
+CU_SuiteInfo odp_testsuites[] = {
+   {Shared Memory, NULL, NULL, NULL, NULL, test_odp_shm},
CU_SUITE_INFO_NULL,
 };
 
-
-int main(void)
-{
-   int ret;
-
-   if (0 != odp_init_global(NULL, NULL)) {
-   printf(odp_init_global fail.\n);
-   return -1;
-   }
-   if (0 != odp_init_local()) {
-   printf(odp_init_local fail.\n);
-   return -1;
-   }
-
-   CU_set_error_action(CUEA_ABORT);
-
-   CU_initialize_registry();
-   CU_register_suites(suites);
-   CU_basic_set_mode(CU_BRM_VERBOSE);
-   CU_basic_run_tests();
-
-   ret = CU_get_number_of_failure_records();
-
-   CU_cleanup_registry();
-
-   odp_term_local();
-   odp_term_global();
-
-   return ret;
-}
-- 
1.7.9.5


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


[lng-odp] [PATCH 0/5] validation: harmonize test applications

2014-12-01 Thread Taras Kondratiuk
Avoid duplicating the same code by using a common main() function
in most of test applications.

Taras Kondratiuk (5):
  validation: shm: move main() to a common place
  validation: common: add tests_global_init() function
  validation: queue: reuse common main() function
  validation: crypto: reuse common main() function
  validation: init: use CU_register_suites() for tests registration

 test/validation/Makefile.am   |8 ++---
 test/validation/common/odp_cunit_common.c |   42 +++
 test/validation/common/odp_cunit_common.h |   23 +
 test/validation/odp_crypto.c  |   43 ---
 test/validation/odp_init.c|   47 -
 test/validation/odp_queue.c   |   53 +
 test/validation/odp_shm.c |   42 ++-
 7 files changed, 107 insertions(+), 151 deletions(-)

-- 
1.7.9.5


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


[lng-odp] [PATCH 3/5] validation: queue: reuse common main() function

2014-12-01 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 test/validation/Makefile.am |2 +-
 test/validation/odp_queue.c |   53 ---
 2 files changed, 10 insertions(+), 45 deletions(-)

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 8b55bad..1f5eed4 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -16,7 +16,7 @@ odp_shm_LDFLAGS = $(AM_LDFLAGS)
 endif
 
 dist_odp_init_SOURCES = odp_init.c
-dist_odp_queue_SOURCES = odp_queue.c
+dist_odp_queue_SOURCES = odp_queue.c common/odp_cunit_common.c
 dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
  crypto/odp_crypto_test_sync_inp.c \
  odp_crypto.c
diff --git a/test/validation/odp_queue.c b/test/validation/odp_queue.c
index 09dba0e..50df6d4 100644
--- a/test/validation/odp_queue.c
+++ b/test/validation/odp_queue.c
@@ -5,7 +5,7 @@
  */
 
 #include odp.h
-#include CUnit/Basic.h
+#include odp_cunit_common.h
 
 #define MAX_BUFFER_QUEUE(8)
 #define MSG_POOL_SIZE   (4*1024*1024)
@@ -107,17 +107,6 @@ static void test_odp_queue_sunnyday(void)
 
 static int init_suite(void)
 {
-   printf(\tODP API version: %s\n, odp_version_api_str());
-   printf(\tODP implementation version: %s\n, odp_version_impl_str());
-
-   if (0 != odp_init_global(NULL, NULL)) {
-   printf(odp_init_global fail.\n);
-   return -1;
-   }
-   if (0 != odp_init_local()) {
-   printf(odp_init_local fail.\n);
-   return -1;
-   }
if (0 != test_odp_buffer_pool_init()) {
printf(test_odp_buffer_pool_init fail.\n);
return -1;
@@ -125,36 +114,12 @@ static int init_suite(void)
return 0;
 }
 
-static int finalize(void)
-{
-   odp_term_local();
-   odp_term_global();
-   return 0;
-}
-
-int main(void)
-{
-   CU_pSuite ptr_suite = NULL;
-
-   /* initialize the CUnit test registry */
-   if (CUE_SUCCESS != CU_initialize_registry())
-   return CU_get_error();
-
-   /* add the tests to the queue suite */
-   ptr_suite = CU_add_suite(__FILE__, init_suite, finalize);
-   if (NULL == ptr_suite) {
-   CU_cleanup_registry();
-   return CU_get_error();
-   }
-
-   if (NULL == CU_ADD_TEST(ptr_suite, test_odp_queue_sunnyday)) {
-   CU_cleanup_registry();
-   return CU_get_error();
-   }
+CU_TestInfo test_odp_queue[] = {
+   {queue sunnyday,  test_odp_queue_sunnyday},
+   CU_TEST_INFO_NULL,
+};
 
-   /* Run all tests using the CUnit Basic interface */
-   CU_basic_set_mode(CU_BRM_VERBOSE);
-   CU_basic_run_tests();
-   CU_cleanup_registry();
-   return CU_get_error();
-}
+CU_SuiteInfo odp_testsuites[] = {
+   {Queue, init_suite, NULL, NULL, NULL, test_odp_queue},
+   CU_SUITE_INFO_NULL,
+};
-- 
1.7.9.5


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


[lng-odp] [PATCH 4/5] validation: crypto: reuse common main() function

2014-12-01 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 test/validation/Makefile.am  |2 +-
 test/validation/odp_crypto.c |   43 ++
 2 files changed, 7 insertions(+), 38 deletions(-)

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 1f5eed4..d8dcb59 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -19,5 +19,5 @@ dist_odp_init_SOURCES = odp_init.c
 dist_odp_queue_SOURCES = odp_queue.c common/odp_cunit_common.c
 dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
  crypto/odp_crypto_test_sync_inp.c \
- odp_crypto.c
+ odp_crypto.c common/odp_cunit_common.c
 dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
diff --git a/test/validation/odp_crypto.c b/test/validation/odp_crypto.c
index 9342aca..ec3f16a 100644
--- a/test/validation/odp_crypto.c
+++ b/test/validation/odp_crypto.c
@@ -5,8 +5,7 @@
  */
 
 #include odp.h
-#include CUnit/Basic.h
-#include CUnit/TestDB.h
+#include odp_cunit_common.h
 #include odp_crypto_test_async_inp.h
 #include odp_crypto_test_sync_inp.h
 
@@ -16,32 +15,19 @@
 #define SHM_COMPL_POOL_SIZE(128*1024)
 #define SHM_COMPL_POOL_BUF_SIZE128
 
-static int init_suite(void)
-{
-   printf(\tODP API version: %s\n, odp_version_api_str());
-   printf(\tODP implementation version: %s\n, odp_version_impl_str());
-   return 0;
-}
-
-CU_SuiteInfo suites[] = {
-   {ODP_CRYPTO_SYNC_INP, init_suite, NULL, NULL, NULL, test_array_sync },
-   {ODP_CRYPTO_ASYNC_INP, init_suite, NULL, NULL, NULL, test_array_async },
+CU_SuiteInfo odp_testsuites[] = {
+   {ODP_CRYPTO_SYNC_INP, NULL, NULL, NULL, NULL, test_array_sync },
+   {ODP_CRYPTO_ASYNC_INP, NULL, NULL, NULL, NULL, test_array_async },
CU_SUITE_INFO_NULL,
 };
 
-int main(void)
+int tests_global_init(void)
 {
odp_shm_t shm;
void *pool_base;
odp_buffer_pool_t pool;
odp_queue_t out_queue;
 
-   if (odp_init_global(NULL, NULL)) {
-   printf(ODP global init failed.\n);
-   return -1;
-   }
-   odp_init_local();
-
shm = odp_shm_reserve(shm_packet_pool,
  SHM_PKT_POOL_SIZE,
  ODP_CACHE_LINE_SIZE, 0);
@@ -86,22 +72,5 @@ int main(void)
return -1;
}
 
-   printf(\tODP version: %s\n, odp_version_api_str());
-
-
-   /* initialize the CUnit test registry */
-   if (CUE_SUCCESS != CU_initialize_registry())
-   return CU_get_error();
-
-   /* register suites */
-   CU_register_suites(suites);
-   /* Run all tests using the CUnit Basic interface */
-   CU_basic_set_mode(CU_BRM_VERBOSE);
-   CU_basic_run_tests();
-   CU_cleanup_registry();
-
-   odp_term_local();
-   odp_term_global();
-
-   return CU_get_error();
+   return 0;
 }
-- 
1.7.9.5


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


Re: [lng-odp] [PATCH 1/2] api: queue: add odp_queue_destroy()

2014-11-28 Thread Taras Kondratiuk

On 11/28/2014 06:37 AM, Bill Fischofer wrote:

You cannot gracefully destroy a queue without some sort of quiesce
function that prohibits further enqueues to the queue while allowing
items on the queue to be dequeued until the queue is empty.  To position
for this, I'd include a check that rejects the destroy attempt if the
queue is not empty.  It's then up to the caller to ensure that the queue
is empty by its own means for v1.0.


There is an issue with quiesce functions. If queue is used by some HW
block like pktio or crypto in may not be possible to prevent enqueues.
At least on Keystone queue should be detached from HW first (i.e.
replaced by another one). This should be coordinated from application
side.

I've mentioned in the description that behavior is undefined if queue
is not empty or used by some HW block.



We have the same issue in buffer pools.  We have an
odp_buffer_pool_destroy() but unless the application can somehow ensure
that the pool is empty the call will fail.  We can talk about adding a
pool quiesce function to facilitate this post-v1.0.



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


Re: [lng-odp] [PATCH 1/5] implement odp_bool type

2014-11-28 Thread Taras Kondratiuk

On 11/27/2014 07:38 PM, Bill Fischofer wrote:

I agree.  This type is supposed to be just documentation so

typedef int odp_bool_t;

is simplest and best.


Won't enum be more clear? {ODP_FALSE, ODP_TRUE}

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


Re: [lng-odp] [PATCH v5] cunit: add shm test

2014-11-28 Thread Taras Kondratiuk

On 11/28/2014 05:03 AM, Yan Sonming wrote:

Add odp_cunit_common.c for common cunit function and add the cunit
test for the api in odp_share_memory.h which include the new api implement
odp_shm_free

Signed-off-by: Yan Songming yan.songm...@linaro.org
---
v5 fix the problem which Jerin and Taras found.
v4 change the style of cunit test.
v3 change common file to test/common and fix the problem Jerin found.
v2 fix some problem which maxim and mike found.
---
  test/validation/Makefile.am   |   5 +-
  test/validation/common/odp_cunit_common.c |  37 +
  test/validation/common/odp_cunit_common.h |  35 +
  test/validation/odp_shm.c | 124 ++
  4 files changed, 200 insertions(+), 1 deletion(-)
  create mode 100644 test/validation/common/odp_cunit_common.c
  create mode 100644 test/validation/common/odp_cunit_common.h
  create mode 100644 test/validation/odp_shm.c

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 0b831d0..4bee2ab 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -6,11 +6,13 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
  if ODP_CUNIT_ENABLED
  TESTS = ${bin_PROGRAMS}
  check_PROGRAMS = ${bin_PROGRAMS}
-bin_PROGRAMS = odp_init odp_queue odp_crypto
+bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm
  odp_init_LDFLAGS = $(AM_LDFLAGS)
  odp_queue_LDFLAGS = $(AM_LDFLAGS)
  odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
  odp_crypto_LDFLAGS = $(AM_LDFLAGS)
+odp_shm_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/common
+odp_shm_LDFLAGS = $(AM_LDFLAGS)
  endif

  dist_odp_init_SOURCES = odp_init.c
@@ -18,3 +20,4 @@ dist_odp_queue_SOURCES = odp_queue.c
  dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
  crypto/odp_crypto_test_sync_inp.c \
  odp_crypto.c
+dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
diff --git a/test/validation/common/odp_cunit_common.c 
b/test/validation/common/odp_cunit_common.c
new file mode 100644
index 000..885b981
--- /dev/null
+++ b/test/validation/common/odp_cunit_common.c
@@ -0,0 +1,37 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP test application common
+ */
+
+#include string.h
+#include odp.h
+#include odp_cunit_common.h
+#include odph_linux.h
+/* Globals */
+static odph_linux_pthread_t thread_tbl[MAX_WORKERS];
+
+/** create test thread */
+int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg)
+{
+   /* Create and init additional threads */
+   odph_linux_pthread_create(thread_tbl, arg-numthrds, 0, func_ptr,
+ (void *)arg);
+
+   return 0;
+}
+
+/** exit from test thread */
+int odp_cunit_thread_exit(pthrd_arg *arg)
+{
+   /* Wait for other threads to exit */
+   odph_linux_pthread_join(thread_tbl, arg-numthrds);
+
+   return 0;
+}
diff --git a/test/validation/common/odp_cunit_common.h 
b/test/validation/common/odp_cunit_common.h
new file mode 100644
index 000..5eec376
--- /dev/null
+++ b/test/validation/common/odp_cunit_common.h
@@ -0,0 +1,35 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP test application common headers
+ */
+
+#ifndef ODP_CUNICT_COMMON_H
+#define ODP_CUNICT_COMMON_H
+
+#define MAX_WORKERS 32 /** Maximum number of work threads */
+
+typedef struct {
+   uint32_t foo;
+   uint32_t bar;
+} test_shared_data_t;
+
+/**
+ * Thread argument
+ */
+typedef struct {
+   int testcase; /** specifies which set of API's to exercise */
+   int numthrds; /** no of pthreads to create */
+} pthrd_arg;
+
+/** create thread fro start_routine function */
+extern int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg);
+extern int odp_cunit_thread_exit(pthrd_arg *);
+
+#endif /* ODP_COMMON_H */
diff --git a/test/validation/odp_shm.c b/test/validation/odp_shm.c
new file mode 100644
index 000..be2b52b
--- /dev/null
+++ b/test/validation/odp_shm.c
@@ -0,0 +1,124 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include odp.h
+#include CUnit/Basic.h
+#include odp_cunit_common.h
+
+#define ALIGE_SIZE  (128)
+#define TESTNAME cunit_test_shared_data
+#define TEST_SHARE_FOO (0xf0f0f0f0)
+#define TEST_SHARE_BAR (0xf0f0f0f)
+
+static void *run_shm_thread(void *arg)
+{
+   odp_shm_info_t  info;
+   odp_shm_t shm;
+   test_shared_data_t *test_shared_data;
+   int thr;
+
+   thr = odp_thread_id();
+   printf(Thread %i starts\n, thr);
+
+   shm = odp_shm_lookup(TESTNAME);
+   CU_ASSERT(ODP_SHM_INVALID != shm);
+   test_shared_data = odp_shm_addr(shm);
+   CU_ASSERT(TEST_SHARE_FOO == test_shared_data-foo);
+   CU_ASSERT(TEST_SHARE_BAR == test_shared_data-bar);
+  

Re: [lng-odp] [PATCH] linux-generic: pktio: abort on enq to pktin or deq from pktout

2014-11-28 Thread Taras Kondratiuk

On 11/28/2014 01:47 PM, Stuart Haslam wrote:

On Fri, Nov 28, 2014 at 09:48:29AM +, Alexandru Badicioiu wrote:



On 27 November 2014 at 18:56, Stuart Haslam 
stuart.has...@arm.commailto:stuart.has...@arm.com wrote:
Attempts to enq to a pktin queue or deq from a pktout queue are
programming errors, so abort.
[Alex] Is this an ODP convention valid for all implementations? I f we talk 
about HW I think these are debatable and SoC dependent.
In the most general case a queue may have multiple producers and multiple 
consumers. For example FSL DPAA does not impose any restriction on enqueue - 
any accelerator(port) or core can enqueue on any queue by placing commands to 
Queue manager block.  However, on dequeue, for pktout queues (assumed to be 
consumed by a  singleTx port) only the port can dequeue.



Behaviour needs to be consistent across implementations so if there are
valid use cases for enqueue to a pktio inq, and they can be supported,
we need to define the semantics as it's currently not clear.

Taras, I see the keystone implementation currently doesn't support
enqueue to a pktio inq, is that because the platform doesn't support it
or it's just not implemented?


It is not implemented, because I've considered it as a programming
error. There is no limitation in HW, just packet should be formatted 
properly, to be correctly handled by dequeue function.


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


[lng-odp] [RFC 0/5] validation: harmonize test application

2014-11-28 Thread Taras Kondratiuk
Avoid duplicating the same code by using a common main() function
in most of test applications.

Series is based on top of Yan's shm test patch [1].

[1] http://lists.linaro.org/pipermail/lng-odp/2014-November/005580.html

Taras Kondratiuk (5):
  validation: shm: move main() to a common place
  validation: common: add tests_global_init() function
  validation: queue: reuse common main() function
  validation: crypto: reuse common main() function
  validation: init: use CU_register_suites() for tests registration

 test/validation/Makefile.am   |8 ++---
 test/validation/common/odp_cunit_common.c |   42 +++
 test/validation/common/odp_cunit_common.h |   23 +
 test/validation/odp_crypto.c  |   43 ---
 test/validation/odp_init.c|   47 -
 test/validation/odp_queue.c   |   53 +
 test/validation/odp_shm.c |   47 ++---
 7 files changed, 107 insertions(+), 156 deletions(-)

-- 
1.7.9.5


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


[lng-odp] [RFC 4/5] validation: crypto: reuse common main() function

2014-11-28 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 test/validation/Makefile.am  |2 +-
 test/validation/odp_crypto.c |   43 ++
 2 files changed, 7 insertions(+), 38 deletions(-)

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 1f5eed4..d8dcb59 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -19,5 +19,5 @@ dist_odp_init_SOURCES = odp_init.c
 dist_odp_queue_SOURCES = odp_queue.c common/odp_cunit_common.c
 dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
  crypto/odp_crypto_test_sync_inp.c \
- odp_crypto.c
+ odp_crypto.c common/odp_cunit_common.c
 dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
diff --git a/test/validation/odp_crypto.c b/test/validation/odp_crypto.c
index 9342aca..ec3f16a 100644
--- a/test/validation/odp_crypto.c
+++ b/test/validation/odp_crypto.c
@@ -5,8 +5,7 @@
  */
 
 #include odp.h
-#include CUnit/Basic.h
-#include CUnit/TestDB.h
+#include odp_cunit_common.h
 #include odp_crypto_test_async_inp.h
 #include odp_crypto_test_sync_inp.h
 
@@ -16,32 +15,19 @@
 #define SHM_COMPL_POOL_SIZE(128*1024)
 #define SHM_COMPL_POOL_BUF_SIZE128
 
-static int init_suite(void)
-{
-   printf(\tODP API version: %s\n, odp_version_api_str());
-   printf(\tODP implementation version: %s\n, odp_version_impl_str());
-   return 0;
-}
-
-CU_SuiteInfo suites[] = {
-   {ODP_CRYPTO_SYNC_INP, init_suite, NULL, NULL, NULL, test_array_sync },
-   {ODP_CRYPTO_ASYNC_INP, init_suite, NULL, NULL, NULL, test_array_async },
+CU_SuiteInfo odp_testsuites[] = {
+   {ODP_CRYPTO_SYNC_INP, NULL, NULL, NULL, NULL, test_array_sync },
+   {ODP_CRYPTO_ASYNC_INP, NULL, NULL, NULL, NULL, test_array_async },
CU_SUITE_INFO_NULL,
 };
 
-int main(void)
+int tests_global_init(void)
 {
odp_shm_t shm;
void *pool_base;
odp_buffer_pool_t pool;
odp_queue_t out_queue;
 
-   if (odp_init_global(NULL, NULL)) {
-   printf(ODP global init failed.\n);
-   return -1;
-   }
-   odp_init_local();
-
shm = odp_shm_reserve(shm_packet_pool,
  SHM_PKT_POOL_SIZE,
  ODP_CACHE_LINE_SIZE, 0);
@@ -86,22 +72,5 @@ int main(void)
return -1;
}
 
-   printf(\tODP version: %s\n, odp_version_api_str());
-
-
-   /* initialize the CUnit test registry */
-   if (CUE_SUCCESS != CU_initialize_registry())
-   return CU_get_error();
-
-   /* register suites */
-   CU_register_suites(suites);
-   /* Run all tests using the CUnit Basic interface */
-   CU_basic_set_mode(CU_BRM_VERBOSE);
-   CU_basic_run_tests();
-   CU_cleanup_registry();
-
-   odp_term_local();
-   odp_term_global();
-
-   return CU_get_error();
+   return 0;
 }
-- 
1.7.9.5


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


Re: [lng-odp] [PATCH 1/2] api: queue: add odp_queue_destroy()

2014-11-27 Thread Taras Kondratiuk
On 11/26/2014 07:11 PM, Mike Holmes wrote:
 
 
 On 26 November 2014 at 12:03, Taras Kondratiuk
 taras.kondrat...@linaro.org mailto:taras.kondrat...@linaro.org wrote:
 
 Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
 mailto:taras.kondrat...@linaro.org
 ---
  platform/linux-generic/include/api/odp_queue.h |9 +
  1 file changed, 9 insertions(+)
 
 diff --git a/platform/linux-generic/include/api/odp_queue.h
 b/platform/linux-generic/include/api/odp_queue.h
 index b8ac4bb..3321950 100644
 --- a/platform/linux-generic/include/api/odp_queue.h
 +++ b/platform/linux-generic/include/api/odp_queue.h
 @@ -124,6 +124,15 @@ odp_queue_t odp_queue_create(const char *name,
 odp_queue_type_t type,
  odp_queue_param_t *param);
 
  /**
 + * Destroy ODP queue
 + *
 
 
 Does it need the queue to be drained, will it drain the queue, will if
 free buffers if it drains the queue.
 does it wait if the queue is full
 Are there any @warnings about its behaviour?

For v1.0 this function can have minimal functionality. Later we can
extend it to ensure correct teardown sequence and simplify operations
needed from application side.

/**
 * Destroy ODP queue
 *
 * Destroys ODP queue. The queue must be empty and detached from other
 * ODP API (crypto, pktio, etc). Application must ensure that no
 * other operations on this queue are invoked in parallel. Otherwise
 * behavior is undefined.
 */

   Otherwise behavior is undefined.
 
 + * @param queueQueue handle
 
 
 in or out ?

Will fix to [in]

  
 
 + *
 + * @return 0 if successful
 
 
 what cases cause a failure, what is returned value in those case?

I've added requirements to the description. Violating the requirements
will cause a failure. Some failure cases can be platform dependent. Do
you think there is a reason to enumerate all possible error cases?

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


Re: [lng-odp] [PATCH ARCH] api_guide_lines: Internal functions

2014-11-27 Thread Taras Kondratiuk
On 11/26/2014 10:13 PM, Mike Holmes wrote:
 Signed-off-by: Mike Holmes mike.hol...@linaro.org
 ---
  api_guide_lines.dox | 6 ++
  1 file changed, 6 insertions(+)
 
 diff --git a/api_guide_lines.dox b/api_guide_lines.dox
 index be23e9a..1f83c53 100644
 --- a/api_guide_lines.dox
 +++ b/api_guide_lines.dox
 @@ -144,6 +144,12 @@ The values  !0 = true, 0 = false are used for this 
 purpose.
  Pass indications are integers (int) and SHOULD also be used for APIs that 
 return a simple success/failure indication to the caller.
  In this case the return value 0 indicates success while non-zero (typically 
 -1) indicates failure and errno is set to a reason code that indicates the 
 nature of the failure.
  
 +@subsection odp_internal Internal APIs
 +When an interface is defined in a header file and is intended to to be 
 reused internally it will follow these rules:-
 +- Be prefixed with an underscore _.
 +- It may not be placed in include/api.

Is this item necessary?
I have some internal APIs that are used by ODP API which implemented as
'static inline' functions directly in API headers. These internal APIs
have to be placed in include/api.

 +- All the required definitions for the API are to use an underscore, this 
 includes MACROS, typedefs, enums and function names.
 +
  @section implementation Implementation Considerations
  To support application portability and preserve implementation flexibility, 
 ODP APIs MUST be designed with several guiding principles in mind.
  
 


-- 
Taras Kondratiuk

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


[lng-odp] [PATCHv3 0/2] Add a way to override default ODP_LOG behavior

2014-11-27 Thread Taras Kondratiuk
This series adds a default weak odp_override_log() function which can
be replaced by application.

v3: Rebased and fixed conflicts with merged patches.
v2: Fixed missed comma in ODP_UNIMPLEMENTED() macro.

Taras Kondratiuk (2):
  platform: debug: replace fprintf() with odp_override_log()
  platform: debug: Simplify ODP_LOG() macro

 platform/linux-generic/Makefile.am |3 +-
 platform/linux-generic/include/api/odp_debug.h |   67 +---
 .../linux-generic/include/odp_debug_internal.h |6 +-
 platform/linux-generic/odp_weak.c  |   26 
 4 files changed, 61 insertions(+), 41 deletions(-)
 create mode 100644 platform/linux-generic/odp_weak.c

-- 
1.7.9.5


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


[lng-odp] [PATCHv3 2/2] platform: debug: Simplify ODP_LOG() macro

2014-11-27 Thread Taras Kondratiuk
Move additional functionality out of ODP_LOG. Move abort() call to
odp_override_log(), so application will be able to implement custom
abort handling.

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/include/api/odp_debug.h |   38 
 .../linux-generic/include/odp_debug_internal.h |6 ++--
 platform/linux-generic/odp_weak.c  |5 ++-
 3 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_debug.h 
b/platform/linux-generic/include/api/odp_debug.h
index 4b51038..875c813 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -99,48 +99,24 @@ extern int odp_override_log(odp_log_level_e level, const 
char *fmt, ...);
  * ODP LOG macro.
  */
 #define ODP_LOG(level, fmt, ...) \
-do { \
-   switch (level) { \
-   case ODP_LOG_ERR: \
-   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_DBG: \
-   if (ODP_DEBUG_PRINT == 1) \
-   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_PRINT: \
-   odp_override_log(level,   fmt, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_ABORT: \
-   odp_override_log(level, %s:%d:%s():  fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   abort(); \
-   break; \
-   case ODP_LOG_UNIMPLEMENTED: \
-   odp_override_log(level, \
-   %s:%d:The function %s() is not implemented\n \
-   fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   default: \
-   odp_override_log(level, Unknown LOG level); \
-   break;\
-   } \
-} while (0)
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
+   __LINE__, __func__, ##__VA_ARGS__)
 
 /**
  * Log print message when the application calls one of the ODP APIs
  * specifically for dumping internal data.
  */
 #define ODP_PRINT(fmt, ...) \
-   ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
+   odp_override_log(ODP_LOG_PRINT,   fmt, ##__VA_ARGS__)
 
 /**
  * Log debug message if DEBUG flag is set.
  */
 #define ODP_DBG(fmt, ...) \
-   ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__)
+   do { \
+   if (ODP_DEBUG_PRINT == 1) \
+   ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__);\
+   } while (0)
 
 /**
  * Log error message.
diff --git a/platform/linux-generic/include/odp_debug_internal.h 
b/platform/linux-generic/include/odp_debug_internal.h
index a87552f..ee3c543 100644
--- a/platform/linux-generic/include/odp_debug_internal.h
+++ b/platform/linux-generic/include/odp_debug_internal.h
@@ -25,8 +25,10 @@ extern C {
 /**
  * This macro is used to indicate when a given function is not implemented
  */
-#define ODP_UNIMPLEMENTED(fmt, ...) \
-   ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
+#define ODP_UNIMPLEMENTED() \
+   odp_override_log(ODP_LOG_UNIMPLEMENTED, \
+   %s:%d:The function %s() is not implemented\n, \
+   __FILE__, __LINE__, __func__)
 
 #ifdef __cplusplus
 }
diff --git a/platform/linux-generic/odp_weak.c 
b/platform/linux-generic/odp_weak.c
index fccbc3f..3cc3d45 100644
--- a/platform/linux-generic/odp_weak.c
+++ b/platform/linux-generic/odp_weak.c
@@ -9,7 +9,7 @@
 #include odp_debug_internal.h
 #include odp_hints.h
 
-ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level ODP_UNUSED,
+ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level,
 const char *fmt, ...)
 {
va_list args;
@@ -19,5 +19,8 @@ ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level 
ODP_UNUSED,
r = vfprintf(stderr, fmt, args);
va_end(args);
 
+   if (level == ODP_LOG_ABORT)
+   abort();
+
return r;
 }
-- 
1.7.9.5


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


Re: [lng-odp] [PATCH 2/2] platform: implement odp_queue_destroy()

2014-11-27 Thread Taras Kondratiuk

On 11/27/2014 05:57 PM, Ciprian Barbu wrote:

On Thu, Nov 27, 2014 at 5:49 PM, Ciprian Barbu ciprian.ba...@linaro.org wrote:

On Wed, Nov 26, 2014 at 7:03 PM, Taras Kondratiuk
taras.kondrat...@linaro.org wrote:

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
  platform/linux-generic/odp_queue.c |   17 +
  1 file changed, 17 insertions(+)

diff --git a/platform/linux-generic/odp_queue.c 
b/platform/linux-generic/odp_queue.c
index 1318bcd..f44aba0 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -192,6 +192,23 @@ odp_queue_t odp_queue_create(const char *name, 
odp_queue_type_t type,
 return handle;
  }

+int odp_queue_destroy(odp_queue_t handle)
+{
+   queue_entry_t *queue;
+   queue = queue_to_qentry(handle);
+
+   if (queue-s.status == QUEUE_STATUS_FREE)
+   return -1; /* Queue is alredy freed */
+
+   LOCK(queue-s.lock);
+   queue-s.status = QUEUE_STATUS_FREE;
+   queue-s.head = NULL;
+   queue-s.tail = NULL;
+   queue-s.sched_buf = ODP_BUFFER_INVALID;


What happens with sched_buf that was allocated with
odp_schedule_buffer_alloc? It needs to be freed as well, not to
mention that there should be a way to protect from scheduling a queue
that was destroyed. With this implementation sched_buf is set to
invalid, but if the queue was scheduled prior to destroying it then
sched_buf would still exist in the priority queue (see
https://git.linaro.org/lng/odp.git/blob/945e8be94ea2779f55cc2fe91d3098361589bcb0:/platform/linux-generic/odp_schedule.c#l200)


And here is where sched_buf is dequeued from the priority queue:
https://git.linaro.org/lng/odp.git/blob/945e8be94ea2779f55cc2fe91d3098361589bcb0:/platform/linux-generic/odp_schedule.c#l286

Although the queue's sched_buf handle is set to ODP_BUFFER_INVALID the
same is not true for the priority queue.


Thanks. I forgot about scheduler. Will think how to handle this.

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


Re: [lng-odp] [PATCH] netdev-odp: Use VLOG_ERR instead of ODP_ERR

2014-11-26 Thread Taras Kondratiuk

On 11/25/2014 06:54 PM, Mike Holmes wrote:

Taras is submitting a patch that allows you to replace the output stream
for ODP_ERR etc with the applications prefered stream - see
https://mail.google.com/mail/u/1/#inbox/149e780e4e57d70c


Taking into account that ODP_ERR() is not a part of public API Zoltan's
patch looks correct. OVS should not use ODP_ERR().

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


Re: [lng-odp] [PATCH] DEPENDENCIES: Update CUnit instructions

2014-11-26 Thread Taras Kondratiuk

On 11/26/2014 12:08 AM, Mike Holmes wrote:

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
  DEPENDENCIES | 18 ++
  1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/DEPENDENCIES b/DEPENDENCIES
index f70a1d4..11452ff 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -78,23 +78,33 @@ Prerequisites for building the OpenDataPlane (ODP) API

  4.0 Packages needed to build API tests

-   Cunit test framework
+   Cunit test framework version 2.1-3 is required
 Cunit prvodes a framework to run the API test suite that proves 
conformance to the
 ODP API. The home page http://cunit.sourceforge.net/doc/introduction.html

  4.1 Native Cunit install

-   # Debian/Ubuntu
+   # Debian/Ubuntu check it is 2.1-3
 $ apt-get install libcunit1-dev

-4.2 Cross compile of Cunit
+4.2 Built from src
+
+   export CUNIT_VERSION=2.1-3
+   curl -sSOL 
http://sourceforge.net/projects/cunit/files/CUnit/${CUNIT_VERSION}/CUnit-${CUNIT_VERSION}.
 ar.bz2


tar.bz2 ?

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


Re: [lng-odp] [PATCH] netdev-odp: Use VLOG_ERR instead of ODP_ERR

2014-11-26 Thread Taras Kondratiuk

On 11/26/2014 02:54 PM, Zoltan Kiss wrote:

But independent from this, OVS should overwrite the log function, right?
So ODP internal log messages won't be lost.


Right.
I assume it should direct log messages into its own logging subsystem.

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


Re: [lng-odp] [PATCH 2/2] linux-generic: odp_pktio_open loop0 support

2014-11-26 Thread Taras Kondratiuk

On 11/26/2014 03:23 PM, Jerin Jacob wrote:

On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:

On 11/26/2014 12:25 PM, Ola Liljedahl wrote:

On 26 November 2014 at 09:39, Alexandru Badicioiu
alexandru.badici...@linaro.org wrote:

This patch has no description. The title is not self explanatory either.
Also the existence of eth0 should be verified  before mapping the loop0 to
eth0 - some platforms may use other interface names (e.g. fmX-gby for FSL
DPAA platforms).  I think a better solution would be to enumerate the
available interfaces  and pick a suitable one.

I second that opinion. On my ChromeBook (great development
platforms!), the only Ethernet-like
interface is called mlan0.

Hm, renaming should be done to some predictable name. eth0 is very common
for linux.
If it's not so that can be changed with export ODP_PKTIO_LOOPDEV=mlan0.

I can walk over the list but not sure how to select interface that can be
used.


IMO we should  have an ODP API to enumerate all the available pktio ports
in a given platform as strings along with a bitmap to represent their 
capability(like PKTIO_CAP_LOOPBACK)
So that application can choose the pktio based on the capability.
We can use our odp___next API model for enumeration.


+1

Instead of bitmap it can some struct.

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


Re: [lng-odp] [PATCH 2/2] linux-generic: odp_pktio_open loop0 support

2014-11-26 Thread Taras Kondratiuk

On 11/26/2014 04:05 PM, Maxim Uvarov wrote:

On 11/26/2014 04:33 PM, Taras Kondratiuk wrote:

On 11/26/2014 03:23 PM, Jerin Jacob wrote:

On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:

On 11/26/2014 12:25 PM, Ola Liljedahl wrote:

On 26 November 2014 at 09:39, Alexandru Badicioiu
alexandru.badici...@linaro.org wrote:

This patch has no description. The title is not self explanatory
either.
Also the existence of eth0 should be verified  before mapping the
loop0 to
eth0 - some platforms may use other interface names (e.g. fmX-gby
for FSL
DPAA platforms).  I think a better solution would be to enumerate the
available interfaces  and pick a suitable one.

I second that opinion. On my ChromeBook (great development
platforms!), the only Ethernet-like
interface is called mlan0.

Hm, renaming should be done to some predictable name. eth0 is very
common
for linux.
If it's not so that can be changed with export
ODP_PKTIO_LOOPDEV=mlan0.

I can walk over the list but not sure how to select interface that
can be
used.


IMO we should  have an ODP API to enumerate all the available pktio
ports
in a given platform as strings along with a bitmap to represent their
capability(like PKTIO_CAP_LOOPBACK)
So that application can choose the pktio based on the capability.
We can use our odp___next API model for enumeration.


+1

Instead of bitmap it can some struct.



Any hint how that can be implemented on linux-generic for v1?


SIOCGIFCONF ioctl can be used to get a list of interfaces.
Or read /proc/net/dev directly. Then read flags with SIOCGIFFLAGS ioctl.

I'm not sure if we need this for v1.

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


[lng-odp] [PATCH 2/2] platform: implement odp_queue_destroy()

2014-11-26 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/odp_queue.c |   17 +
 1 file changed, 17 insertions(+)

diff --git a/platform/linux-generic/odp_queue.c 
b/platform/linux-generic/odp_queue.c
index 1318bcd..f44aba0 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -192,6 +192,23 @@ odp_queue_t odp_queue_create(const char *name, 
odp_queue_type_t type,
return handle;
 }
 
+int odp_queue_destroy(odp_queue_t handle)
+{
+   queue_entry_t *queue;
+   queue = queue_to_qentry(handle);
+
+   if (queue-s.status == QUEUE_STATUS_FREE)
+   return -1; /* Queue is alredy freed */
+
+   LOCK(queue-s.lock);
+   queue-s.status = QUEUE_STATUS_FREE;
+   queue-s.head = NULL;
+   queue-s.tail = NULL;
+   queue-s.sched_buf = ODP_BUFFER_INVALID;
+   UNLOCK(queue-s.lock);
+
+   return 0;
+}
 
 odp_buffer_t queue_sched_buf(odp_queue_t handle)
 {
-- 
1.7.9.5


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


[lng-odp] [PATCH 1/2] api: queue: add odp_queue_destroy()

2014-11-26 Thread Taras Kondratiuk
Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/include/api/odp_queue.h |9 +
 1 file changed, 9 insertions(+)

diff --git a/platform/linux-generic/include/api/odp_queue.h 
b/platform/linux-generic/include/api/odp_queue.h
index b8ac4bb..3321950 100644
--- a/platform/linux-generic/include/api/odp_queue.h
+++ b/platform/linux-generic/include/api/odp_queue.h
@@ -124,6 +124,15 @@ odp_queue_t odp_queue_create(const char *name, 
odp_queue_type_t type,
 odp_queue_param_t *param);
 
 /**
+ * Destroy ODP queue
+ *
+ * @param queueQueue handle
+ *
+ * @return 0 if successful
+ */
+int odp_queue_destroy(odp_queue_t queue);
+
+/**
  * Find a queue by name
  *
  * @param nameQueue name
-- 
1.7.9.5


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


Re: [lng-odp] [PATCH v2] test: Display implementation version

2014-11-25 Thread Taras Kondratiuk

On 11/24/2014 10:11 PM, Mike Holmes wrote:

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
  test/validation/odp_crypto.c | 11 +--
  test/validation/odp_init.c   |  7 ---
  test/validation/odp_queue.c  |  7 +--
  3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/test/validation/odp_crypto.c b/test/validation/odp_crypto.c
index 985302a..9342aca 100644
--- a/test/validation/odp_crypto.c
+++ b/test/validation/odp_crypto.c
@@ -16,9 +16,16 @@
  #define SHM_COMPL_POOL_SIZE   (128*1024)
  #define SHM_COMPL_POOL_BUF_SIZE   128

+static int init_suite(void)
+{
+   printf(\tODP API version: %s\n, odp_version_api_str());
+   printf(\tODP implementation version: %s\n, odp_version_impl_str());
+   return 0;
+}
+
  CU_SuiteInfo suites[] = {
-   { ODP_CRYPTO_SYNC_INP , NULL, NULL, NULL, NULL, test_array_sync },
-   { ODP_CRYPTO_ASYNC_INP , NULL, NULL, NULL, NULL, test_array_async },
+   {ODP_CRYPTO_SYNC_INP, init_suite, NULL, NULL, NULL, test_array_sync },
+   {ODP_CRYPTO_ASYNC_INP, init_suite, NULL, NULL, NULL, test_array_async },
CU_SUITE_INFO_NULL,
  };

diff --git a/test/validation/odp_init.c b/test/validation/odp_init.c
index 88e6235..aa7439d 100644
--- a/test/validation/odp_init.c
+++ b/test/validation/odp_init.c
@@ -20,9 +20,10 @@ static void test_odp_init_global(void)
CU_ASSERT(status == 0);
  }

-static int init(void)
+static int init_suite(void)
  {
-   printf(\tODP version: %s\n, odp_version_api_str());
+   printf(\tODP API version: %s\n, odp_version_api_str());
+   printf(\tODP implementation version: %s\n, odp_version_impl_str());


Suite init function should perform necessary actions to prepare system 
for a suit execution. Printing ODP info has nothing to do with this.
Also this information is the same for all test suites, so normally it 
should be printed directly from main().


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


Re: [lng-odp] odp_pktio_open(NULL) return default pktio for platform

2014-11-25 Thread Taras Kondratiuk

On 11/25/2014 02:19 PM, Alexandru Badicioiu wrote:

I guess any Ethernet interface can be configured to work in loopback
mode ( at least with SDK provided tools/functions). Loopback interface
applied to HW is confusing - usually loopback is software only; how a HW
packet classifier would be tested with a loopback interface? For this
purpose a real interface is required, backed up by real HW.


Right, but this is implementation details. If application needs a 
loopback interface it should not care how it is implemented.


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


Re: [lng-odp] [PATCH] .gitignore: add CUnit-Memory-Dump.xml

2014-11-25 Thread Taras Kondratiuk

On 11/25/2014 02:43 PM, Mike Holmes wrote:



On 25 November 2014 at 07:15, Maxim Uvarov maxim.uva...@linaro.org
mailto:maxim.uva...@linaro.org wrote:

On 11/25/2014 01:18 AM, Mike Holmes wrote:

Does no one else see this ?


Files are in the same directory where you run the test. So please
remove path from the patch
and add others:


 CUnit-Memory-Dump.xml
 example/packet/core
 test/validation/CUnit-Memory-__Dump.xml
 test/validation/crypto/.__dirstamp

Maxim.



no problem, thanks for confirming.


Git supports hierarchical .gitignore files. Each directory may have its 
own .gitignore. Instead of adding everything in a root .gitignore it 
makes sense to create at least two additional:

test/validation/.gitignore
example/.gitignore

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


Re: [lng-odp] [PATCH v0] crypto : cunit test suite for rng

2014-11-25 Thread Taras Kondratiuk

On 11/25/2014 12:21 PM, Alexandru Badicioiu wrote:


 +
 +/*
 + * This test verifies that HW random number generator is able
 + * to produce an IV for TDES_CBC cipher algorithm.
 + * */
 +#define RNG_GET_SIZE   RNG_GET_SIZE
 +static void rng_get_size(void)
 +{
 +   int ret;
 +   size_t len = TDES_CBC_IV_LEN;
 +   uint8_t buf[TDES_CBC_IV_LEN];
 +
 +   ret = odp_hw_random_get(buf, len, false);
 +   CU_ASSERT(!ret);
 +   CU_ASSERT(len == TDES_CBC_IV_LEN);
 +}
 +
 +CU_TestInfo test_rng[] = {
 +   { RNG_GET_SIZE, rng_get_size },
 +   CU_TEST_INFO_NULL,

Size of test_rng is defined as a size of one in the header but is size
of two elements here.

[Alex] CUnit does not use the declared size of the array  - I guess this
is the purpose of the end marker (CU_TEST_INFO_NULL). Declaring a
pointer only it will not compile :
odp_crypto.c:23:2: error: initializer element is not constant
odp_crypto.c:23:2: error: (near initialization for 'suites[2].pTests')
odp_crypto.c:23:2: error: missing initializer
[-Werror=missing-field-initializers]
odp_crypto.c:23:2: error: (near initialization for 'suites[2].pTests')
[-Werror=missing-field-initializers]
Trying to declare the array as flexible will not work either
(CU_TestInfo test_rng[];):
In file included from odp_crypto.c:12:0:
./crypto/odp_crypto_test_rng.h:15:13: error: array 'test_rng' assumed to
have one element [-Werror]
cc1: all warnings being treated as errors
This is the reason I used 1 as the declared size of the array.


This should work:
extern CU_TestInfo test_rng[];


 +
 +#endif
 +
 diff --git a/test/validation/crypto/test_vectors.h 
b/test/validation/crypto/test_vectors.h
 index c151952..aaf0103 100644
 --- a/test/validation/crypto/test_vectors.h
 +++ b/test/validation/crypto/test_vectors.h
 @@ -13,7 +13,7 @@
  #define TDES_CBC_IV_LEN8   /* IV length(in bytes) 
for tdes-cbc */
  #define TDES_CBC_MAX_DATA_LEN  16  /* max. plain text length(in 
bytes) */

 -static uint8_t tdes_cbc_reference_key[][TDES_CBC_KEY_LEN] = {
 +static uint8_t tdes_cbc_reference_key[][TDES_CBC_KEY_LEN] ODP_UNUSED

Not sure why this is flagged unused it appears to be used in
crypto/odp_crypto_test_async_inp.c and
crypto/odp_crypto_test_sync_inp.c

[Alex] These are static declaration, as such they are reported unused in
test_rng.c file where they are unused. To avoid unused, they should be
moved to a .c file and only be declared in test_vectors.h.


That's a hacky solution. You can split these structures into a separate
.h and not include them in RNG tests.

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


Re: [lng-odp] odp_pktio_open(NULL) return default pktio for platform

2014-11-25 Thread Taras Kondratiuk

On 11/25/2014 03:06 PM, Bala Manoharan wrote:

Yes. But for testing the basic pktio APIs which I believe is Maxim's
requirement it can be done using loopback interface (configuring a HW
interface as loop is an implementation detail) so that there is no need
for any HW configuration as such while running the validation suite.


I'm not sure what you are arguing to, but I agree that loopback should 
be enough for basic pktio API verification.



Packet classifier testing can be done using an example program which
will receive packet from a HW interface.


Verification tests should be done as self-contained applications.
So classification tests should also use a loopback interface.

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


Re: [lng-odp] odp_pktio_open(NULL) return default pktio for platform

2014-11-25 Thread Taras Kondratiuk

On 11/25/2014 03:30 PM, Alexandru Badicioiu wrote:

What is a self-contained application? An application which uses only ODP
calls?


I mean an application that doesn't need any external equipment.


Regarding the classification tests and loopbacks, why there's a need for
a special kind of  ODP loopback interface?
Why the following scenario is not acceptable for a test -  open a pktio
(ethernet), configure it in loopback mode and transmit the test traffic
over the pktio with odp_pktio_send(), for example.


It can work this way also for test, but consider a use-case:
application processes IPsec tunneled traffic and after decryption it
wants to reclassify a packet. We agreed before that such 
reclassification will be done via some loopback pktio interface. Should 
it be a real physical interface in a loopback mode or it can be a 
special kind of loopback?


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


Re: [lng-odp] [PATCH 2/2] platform: debug: Simplify ODP_LOG() macro

2014-11-25 Thread Taras Kondratiuk

On 11/24/2014 02:05 PM, Maxim Uvarov wrote:

Do weak symbols work also for dynamic linking?


It does work for dynamic libraries also.

I've found an issue in ODP_UNIMPLEMENTED() macro.
Will post v2.

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


[lng-odp] [PATCHv2 2/2] platform: debug: Simplify ODP_LOG() macro

2014-11-25 Thread Taras Kondratiuk
Move additional functionality out of ODP_LOG. Move abort() call to
odp_override_log(), so application will be able to implement custom
abort handling.

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/include/api/odp_debug.h |   37 
 .../linux-generic/include/odp_debug_internal.h |6 ++--
 platform/linux-generic/odp_weak.c  |5 ++-
 3 files changed, 14 insertions(+), 34 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_debug.h 
b/platform/linux-generic/include/api/odp_debug.h
index cb5bc83..0fbd6b9 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -99,36 +99,8 @@ extern int odp_override_log(odp_log_level_e level, const 
char *fmt, ...);
  * ODP LOG macro.
  */
 #define ODP_LOG(level, fmt, ...) \
-do { \
-   switch (level) { \
-   case ODP_LOG_ERR: \
-   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_DBG: \
-   if (ODP_DEBUG_PRINT == 1) \
-   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_PRINT: \
-   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_ABORT: \
-   odp_override_log(level, %s:%d:%s():  fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   abort(); \
-   break; \
-   case ODP_LOG_UNIMPLEMENTED: \
-   odp_override_log(level, \
-   %s:%d:The function %s() is not implemented\n \
-   fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   default: \
-   odp_override_log(level, Unknown LOG level); \
-   break;\
-   } \
-} while (0)
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
+   __LINE__, __func__, ##__VA_ARGS__)
 
 /**
  * Log print message when the application calls one of the ODP APIs
@@ -141,7 +113,10 @@ do { \
  * Log debug message if DEBUG flag is set.
  */
 #define ODP_DBG(fmt, ...) \
-   ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__)
+   do { \
+   if (ODP_DEBUG_PRINT == 1) \
+   ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__);\
+   } while (0)
 
 /**
  * Log error message.
diff --git a/platform/linux-generic/include/odp_debug_internal.h 
b/platform/linux-generic/include/odp_debug_internal.h
index a87552f..ee3c543 100644
--- a/platform/linux-generic/include/odp_debug_internal.h
+++ b/platform/linux-generic/include/odp_debug_internal.h
@@ -25,8 +25,10 @@ extern C {
 /**
  * This macro is used to indicate when a given function is not implemented
  */
-#define ODP_UNIMPLEMENTED(fmt, ...) \
-   ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
+#define ODP_UNIMPLEMENTED() \
+   odp_override_log(ODP_LOG_UNIMPLEMENTED, \
+   %s:%d:The function %s() is not implemented\n, \
+   __FILE__, __LINE__, __func__)
 
 #ifdef __cplusplus
 }
diff --git a/platform/linux-generic/odp_weak.c 
b/platform/linux-generic/odp_weak.c
index fccbc3f..3cc3d45 100644
--- a/platform/linux-generic/odp_weak.c
+++ b/platform/linux-generic/odp_weak.c
@@ -9,7 +9,7 @@
 #include odp_debug_internal.h
 #include odp_hints.h
 
-ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level ODP_UNUSED,
+ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level,
 const char *fmt, ...)
 {
va_list args;
@@ -19,5 +19,8 @@ ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level 
ODP_UNUSED,
r = vfprintf(stderr, fmt, args);
va_end(args);
 
+   if (level == ODP_LOG_ABORT)
+   abort();
+
return r;
 }
-- 
1.7.9.5


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


[lng-odp] [PATCHv2 1/2] platform: debug: replace fprintf() with odp_override_log()

2014-11-25 Thread Taras Kondratiuk
ODP application may want to override default ODP logging behaviour
and use custom logging function. Add a weak odp_override_log() function
for this purpose instead of default fprintf().

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/Makefile.am |3 +-
 platform/linux-generic/include/api/odp_debug.h |   41 
 platform/linux-generic/odp_weak.c  |   23 +
 3 files changed, 53 insertions(+), 14 deletions(-)
 create mode 100644 platform/linux-generic/odp_weak.c

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index e709700..cc78de3 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -75,4 +75,5 @@ __LIB__libodp_la_SOURCES = \
   odp_thread.c \
   odp_ticketlock.c \
   odp_time.c \
-  odp_timer.c
+  odp_timer.c \
+  odp_weak.c
diff --git a/platform/linux-generic/include/api/odp_debug.h 
b/platform/linux-generic/include/api/odp_debug.h
index 5c3adde..cb5bc83 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -14,6 +14,7 @@
 
 #include stdio.h
 #include stdlib.h
+#include stdarg.h
 
 #ifdef __cplusplus
 extern C {
@@ -81,62 +82,76 @@ typedef enum odp_log_level {
 } odp_log_level_e;
 
 /**
- * ODP default LOG macro.
+ * ODP log function
+ *
+ * Instead of direct prints to stdout/stderr all logging in ODP implementation
+ * should be done via this function or its wrappers.
+ * ODP platform MUST provide a default *weak* implementation of this function.
+ * Application MAY override the function if needed by providing a strong
+ * function.
+ *
+ * @param level   Log level
+ * @param fmt printf-style message format
+ */
+extern int odp_override_log(odp_log_level_e level, const char *fmt, ...);
+
+/**
+ * ODP LOG macro.
  */
 #define ODP_LOG(level, fmt, ...) \
 do { \
switch (level) { \
case ODP_LOG_ERR: \
-   fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
__LINE__, __func__, ##__VA_ARGS__); \
break; \
case ODP_LOG_DBG: \
if (ODP_DEBUG_PRINT == 1) \
-   fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
__LINE__, __func__, ##__VA_ARGS__); \
break; \
case ODP_LOG_PRINT: \
-   fprintf(stdout, %s:%d:%s(): fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
__LINE__, __func__, ##__VA_ARGS__); \
break; \
case ODP_LOG_ABORT: \
-   fprintf(stderr, %s:%d:%s():  fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s():  fmt, __FILE__, \
__LINE__, __func__, ##__VA_ARGS__); \
abort(); \
break; \
case ODP_LOG_UNIMPLEMENTED: \
-   fprintf(stderr, \
+   odp_override_log(level, \
%s:%d:The function %s() is not implemented\n \
fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
break; \
default: \
-   fprintf(stderr, Unknown LOG level); \
+   odp_override_log(level, Unknown LOG level); \
break;\
} \
 } while (0)
 
 /**
- * Printing macro, which prints output when the application
- * calls one of the ODP APIs specifically for dumping internal data.
+ * Log print message when the application calls one of the ODP APIs
+ * specifically for dumping internal data.
  */
 #define ODP_PRINT(fmt, ...) \
ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
 
 /**
- * Debug printing macro, which prints output when DEBUG flag is set.
+ * Log debug message if DEBUG flag is set.
  */
 #define ODP_DBG(fmt, ...) \
ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__)
 
 /**
- * Print output to stderr (file, line and function).
+ * Log error message.
  */
 #define ODP_ERR(fmt, ...) \
ODP_LOG(ODP_LOG_ERR, fmt, ##__VA_ARGS__)
 
 /**
- * Print output to stderr (file, line and function),
- * then abort.
+ * Log abort message and then stop execution (by default call abort()).
+ * This function should not return.
  */
 #define ODP_ABORT(fmt, ...) \
ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__)
diff --git a/platform/linux-generic/odp_weak.c 
b/platform/linux-generic/odp_weak.c
new file mode 100644
index 000..fccbc3f
--- /dev/null
+++ b/platform/linux-generic/odp_weak.c
@@ -0,0 +1,23 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include odp_internal.h
+#include

Re: [lng-odp] [RFC PATCH 1/2] platform: debug: replace fprintf() with odp_override_log()

2014-11-24 Thread Taras Kondratiuk

On 11/22/2014 12:54 AM, Mike Holmes wrote:



On 21 November 2014 04:11, Taras Kondratiuk taras.kondrat...@linaro.org
mailto:taras.kondrat...@linaro.org wrote:

On 11/20/2014 08:42 PM, Maxim Uvarov wrote:

On 11/20/2014 09:36 PM, Maxim Uvarov wrote:

On 11/20/2014 08:27 PM, Taras Kondratiuk wrote:

ODP application may want to override default ODP logging
behaviour
and use custom logging function. Add a weak
odp_override_log() function
for this purpose instead of default fprintf().

Signed-off-by: Taras Kondratiuk
taras.kondrat...@linaro.org
mailto:taras.kondrat...@linaro.org
---
   platform/linux-generic/__include/api/odp_debug.h |   24
++--
   platform/linux-generic/odp___init.c  |
  14 ++
   2 files changed, 28 insertions(+), 10 deletions(-)

diff --git
a/platform/linux-generic/__include/api/odp_debug.h
b/platform/linux-generic/__include/api/odp_debug.h
index c9b2edd..be73318 100644
--- a/platform/linux-generic/__include/api/odp_debug.h
+++ b/platform/linux-generic/__include/api/odp_debug.h
@@ -14,6 +14,7 @@
 #include stdio.h
   #include stdlib.h
+#include stdarg.h
 #ifdef __cplusplus
   extern C {
@@ -79,6 +80,9 @@ typedef enum odp_log_level {
   ODP_LOG_ABORT
   } odp_log_level_e;
   +
+extern int odp_override_log(odp_log___level_e level,
const char *fmt,
...);
+
   /**
* ODP default LOG macro.
*/
@@ -86,45 +90,45 @@ typedef enum odp_log_level {
   do { \
   switch (level) { \
   case ODP_LOG_ERR: \
-fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
+odp_override_log(level, %s:%d:%s(): fmt,
__FILE__, \
   __LINE__, __func__, ##__VA_ARGS__); \
   break; \
   case ODP_LOG_DBG: \
   if (ODP_DEBUG_PRINT == 1) \
-fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
-__LINE__, __func__, ##__VA_ARGS__); \
+odp_override_log(level, %s:%d:%s(): fmt,
__FILE__, \
+__LINE__, __func__, ##__VA_ARGS__); \
   break; \
   case ODP_LOG_ABORT: \
-fprintf(stderr, %s:%d:%s():  fmt, __FILE__, \
+odp_override_log(level, %s:%d:%s():  fmt,
__FILE__, \
   __LINE__, __func__, ##__VA_ARGS__); \
   abort(); \
   break; \
   case ODP_LOG_UNIMPLEMENTED: \
-fprintf(stderr, \
+odp_override_log(level, \
   %s:%d:The function %s() is not
implemented\n \
   fmt, __FILE__, __LINE__, __func__,
##__VA_ARGS__); \
   break; \
   default: \
-fprintf(stderr, Unknown LOG level); \
+odp_override_log(level, Unknown LOG level); \
   break;\
   } \
   } while (0)
 /**
- * Debug printing macro, which prints output when DEBUG
flag is set.
+ * Log debug message if DEBUG flag is set.
*/
   #define ODP_DBG(fmt, ...) \
   ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__)
 /**
- * Print output to stderr (file, line and function).
+ * Log error message.
*/
   #define ODP_ERR(fmt, ...) \
   ODP_LOG(ODP_LOG_ERR, fmt, ##__VA_ARGS__)
 /**
- * Print output to stderr (file, line and function),
- * then abort.
+ * Log abort message and then stop execution (by
default call abort()).
+ * This function should not return.
*/
   #define ODP_ABORT(fmt, ...) \
   ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__)
diff --git a/platform/linux-generic/odp___init.c
b/platform/linux

Re: [lng-odp] splitting patches which can not be split

2014-11-24 Thread Taras Kondratiuk
On 11/24/2014 11:31 AM, Anders Roxell wrote:
 Hi,
 
 I still think its better to say no way to all big patches. =)
 
 Othervice  if we do like this, we create a backdoor for people that
 doesn't want's
 to split up their patches or lack the knowledge how to do it.

In case of API changes there may be no way to decrease a patch size.
If you change even one API function you have to update it in all tests
and examples at the same time to have a buildable patch. But that is
*ok*, because it is easy to review one function change per patch even
if this patch is big.

I'm not a fan of current proposal. RFC is usually not for review, but
just to demonstrate some idea or direction of change. It is used just to
save time and get comments earlier. If there are no major objections,
then a full PATCH can be produced, which should be thoroughly reviewed.

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


[lng-odp] [PATCH 2/2] platform: debug: Simplify ODP_LOG() macro

2014-11-24 Thread Taras Kondratiuk
Move additional functionality out of ODP_LOG. Move abort() call to
odp_override_log(), so application will be able to implement custom
abort handling.

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/include/api/odp_debug.h |   37 
 .../linux-generic/include/odp_debug_internal.h |6 ++--
 platform/linux-generic/odp_weak.c  |5 ++-
 3 files changed, 14 insertions(+), 34 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_debug.h 
b/platform/linux-generic/include/api/odp_debug.h
index cb5bc83..0fbd6b9 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -99,36 +99,8 @@ extern int odp_override_log(odp_log_level_e level, const 
char *fmt, ...);
  * ODP LOG macro.
  */
 #define ODP_LOG(level, fmt, ...) \
-do { \
-   switch (level) { \
-   case ODP_LOG_ERR: \
-   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_DBG: \
-   if (ODP_DEBUG_PRINT == 1) \
-   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_PRINT: \
-   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   case ODP_LOG_ABORT: \
-   odp_override_log(level, %s:%d:%s():  fmt, __FILE__, \
-   __LINE__, __func__, ##__VA_ARGS__); \
-   abort(); \
-   break; \
-   case ODP_LOG_UNIMPLEMENTED: \
-   odp_override_log(level, \
-   %s:%d:The function %s() is not implemented\n \
-   fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
-   break; \
-   default: \
-   odp_override_log(level, Unknown LOG level); \
-   break;\
-   } \
-} while (0)
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
+   __LINE__, __func__, ##__VA_ARGS__)
 
 /**
  * Log print message when the application calls one of the ODP APIs
@@ -141,7 +113,10 @@ do { \
  * Log debug message if DEBUG flag is set.
  */
 #define ODP_DBG(fmt, ...) \
-   ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__)
+   do { \
+   if (ODP_DEBUG_PRINT == 1) \
+   ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__);\
+   } while (0)
 
 /**
  * Log error message.
diff --git a/platform/linux-generic/include/odp_debug_internal.h 
b/platform/linux-generic/include/odp_debug_internal.h
index a87552f..006e8ab 100644
--- a/platform/linux-generic/include/odp_debug_internal.h
+++ b/platform/linux-generic/include/odp_debug_internal.h
@@ -25,8 +25,10 @@ extern C {
 /**
  * This macro is used to indicate when a given function is not implemented
  */
-#define ODP_UNIMPLEMENTED(fmt, ...) \
-   ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
+#define ODP_UNIMPLEMENTED() \
+   odp_override_log(ODP_LOG_UNIMPLEMENTED, \
+   %s:%d:The function %s() is not implemented\n \
+   __FILE__, __LINE__, __func__)
 
 #ifdef __cplusplus
 }
diff --git a/platform/linux-generic/odp_weak.c 
b/platform/linux-generic/odp_weak.c
index fccbc3f..3cc3d45 100644
--- a/platform/linux-generic/odp_weak.c
+++ b/platform/linux-generic/odp_weak.c
@@ -9,7 +9,7 @@
 #include odp_debug_internal.h
 #include odp_hints.h
 
-ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level ODP_UNUSED,
+ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level,
 const char *fmt, ...)
 {
va_list args;
@@ -19,5 +19,8 @@ ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level 
ODP_UNUSED,
r = vfprintf(stderr, fmt, args);
va_end(args);
 
+   if (level == ODP_LOG_ABORT)
+   abort();
+
return r;
 }
-- 
1.7.9.5


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


[lng-odp] [PATCH 0/2] Add a way to override default ODP_LOG behavior

2014-11-24 Thread Taras Kondratiuk
This series adds a default weak odp_override_log() function which can
be replaced by application.

Taras Kondratiuk (2):
  platform: debug: replace fprintf() with odp_override_log()
  platform: debug: Simplify ODP_LOG() macro

 platform/linux-generic/Makefile.am |3 +-
 platform/linux-generic/include/api/odp_debug.h |   66 +---
 .../linux-generic/include/odp_debug_internal.h |6 +-
 platform/linux-generic/odp_weak.c  |   26 
 4 files changed, 60 insertions(+), 41 deletions(-)
 create mode 100644 platform/linux-generic/odp_weak.c

-- 
1.7.9.5


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


[lng-odp] [PATCH 1/2] platform: debug: replace fprintf() with odp_override_log()

2014-11-24 Thread Taras Kondratiuk
ODP application may want to override default ODP logging behaviour
and use custom logging function. Add a weak odp_override_log() function
for this purpose instead of default fprintf().

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-generic/Makefile.am |3 +-
 platform/linux-generic/include/api/odp_debug.h |   41 
 platform/linux-generic/odp_weak.c  |   23 +
 3 files changed, 53 insertions(+), 14 deletions(-)
 create mode 100644 platform/linux-generic/odp_weak.c

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index e709700..cc78de3 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -75,4 +75,5 @@ __LIB__libodp_la_SOURCES = \
   odp_thread.c \
   odp_ticketlock.c \
   odp_time.c \
-  odp_timer.c
+  odp_timer.c \
+  odp_weak.c
diff --git a/platform/linux-generic/include/api/odp_debug.h 
b/platform/linux-generic/include/api/odp_debug.h
index 5c3adde..cb5bc83 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -14,6 +14,7 @@
 
 #include stdio.h
 #include stdlib.h
+#include stdarg.h
 
 #ifdef __cplusplus
 extern C {
@@ -81,62 +82,76 @@ typedef enum odp_log_level {
 } odp_log_level_e;
 
 /**
- * ODP default LOG macro.
+ * ODP log function
+ *
+ * Instead of direct prints to stdout/stderr all logging in ODP implementation
+ * should be done via this function or its wrappers.
+ * ODP platform MUST provide a default *weak* implementation of this function.
+ * Application MAY override the function if needed by providing a strong
+ * function.
+ *
+ * @param level   Log level
+ * @param fmt printf-style message format
+ */
+extern int odp_override_log(odp_log_level_e level, const char *fmt, ...);
+
+/**
+ * ODP LOG macro.
  */
 #define ODP_LOG(level, fmt, ...) \
 do { \
switch (level) { \
case ODP_LOG_ERR: \
-   fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
__LINE__, __func__, ##__VA_ARGS__); \
break; \
case ODP_LOG_DBG: \
if (ODP_DEBUG_PRINT == 1) \
-   fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
__LINE__, __func__, ##__VA_ARGS__); \
break; \
case ODP_LOG_PRINT: \
-   fprintf(stdout, %s:%d:%s(): fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
__LINE__, __func__, ##__VA_ARGS__); \
break; \
case ODP_LOG_ABORT: \
-   fprintf(stderr, %s:%d:%s():  fmt, __FILE__, \
+   odp_override_log(level, %s:%d:%s():  fmt, __FILE__, \
__LINE__, __func__, ##__VA_ARGS__); \
abort(); \
break; \
case ODP_LOG_UNIMPLEMENTED: \
-   fprintf(stderr, \
+   odp_override_log(level, \
%s:%d:The function %s() is not implemented\n \
fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
break; \
default: \
-   fprintf(stderr, Unknown LOG level); \
+   odp_override_log(level, Unknown LOG level); \
break;\
} \
 } while (0)
 
 /**
- * Printing macro, which prints output when the application
- * calls one of the ODP APIs specifically for dumping internal data.
+ * Log print message when the application calls one of the ODP APIs
+ * specifically for dumping internal data.
  */
 #define ODP_PRINT(fmt, ...) \
ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
 
 /**
- * Debug printing macro, which prints output when DEBUG flag is set.
+ * Log debug message if DEBUG flag is set.
  */
 #define ODP_DBG(fmt, ...) \
ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__)
 
 /**
- * Print output to stderr (file, line and function).
+ * Log error message.
  */
 #define ODP_ERR(fmt, ...) \
ODP_LOG(ODP_LOG_ERR, fmt, ##__VA_ARGS__)
 
 /**
- * Print output to stderr (file, line and function),
- * then abort.
+ * Log abort message and then stop execution (by default call abort()).
+ * This function should not return.
  */
 #define ODP_ABORT(fmt, ...) \
ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__)
diff --git a/platform/linux-generic/odp_weak.c 
b/platform/linux-generic/odp_weak.c
new file mode 100644
index 000..fccbc3f
--- /dev/null
+++ b/platform/linux-generic/odp_weak.c
@@ -0,0 +1,23 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include odp_internal.h
+#include

Re: [lng-odp] [PATCH v1 1/5] helper: odph_tcp header description

2014-11-24 Thread Taras Kondratiuk
On 11/24/2014 12:42 PM, Maxim Uvarov wrote:
 Taras, Veky is that good for you?
 
 Needed some more review for classification patches. They block packet 
 i/o things which also
 needed to be delivered on that week.
 
 Thanks,
 Maxim.
 
 On 11/21/2014 11:53 AM, Balasubramanian Manoharan wrote:
 This patch adds TCP header description structure odph_tcphdr.
 This structure is used for accessing TCP header information from the 
 packet

 Signed-off-by: Balasubramanian Manoharan bala.manoha...@linaro.org
 ---
   helper/include/odph_tcp.h | 61 
 +++
   1 file changed, 61 insertions(+)
   create mode 100644 helper/include/odph_tcp.h

 diff --git a/helper/include/odph_tcp.h b/helper/include/odph_tcp.h
 new file mode 100644
 index 000..4c5912b
 --- /dev/null
 +++ b/helper/include/odph_tcp.h
 @@ -0,0 +1,61 @@
 +/* Copyright (c) 2014, Linaro Limited
 + * All rights reserved.
 + *
 + * SPDX-License-Identifier: BSD-3-Clause
 + */
 +
 +
 +/**
 + * @file
 + *
 + * ODP TCP header
 + */
 +
 +#ifndef ODPH_TCP_H_
 +#define ODPH_TCP_H_
 +
 +#ifdef __cplusplus
 +extern C {
 +#endif
 +
 +#include odp_align.h
 +#include odp_debug.h
 +#include odp_byteorder.h
 +
 +/** UDP header length */
 +#define ODPH_TCPHDR_LEN 8
 +
 +/** TCP header */
 +typedef struct ODP_PACKED {
 +uint16be_t src_port; /** Source port */
 +uint16be_t dst_port; /** Destinatino port */
 +uint32be_t seq_no;   /** Sequence number */
 +uint32be_t ack_no;   /** Acknowledgment number */
 +union {
 +uint32be_t flags_and_window;
 +struct {
 +uint32be_t rsvd1:8;
 +uint32be_t flags:8; /** TCP flags as a byte */
 +uint32be_t rsvd2:16;
 +};
 +struct {
 +uint32be_t hl:4;/** Hdr len, in words */
 +uint32be_t rsvd3:6; /** Reserved */
 +uint32be_t urg:1;   /** ACK */
 +uint32be_t ack:1;
 +uint32be_t psh:1;
 +uint32be_t rst:1;
 +uint32be_t syn:1;
 +uint32be_t fin:1;
 +uint32be_t window:16; /** Window size */
 +};

Using bit fields is not a portable solution. The order is not defined
by C99 standard.

An implementation may allocate any addressable storage unit large enough to 
hold a bit-

field. If enough space remains, a bit-field that immediately follows another 
bit-field in a

structure shall be packed into adjacent bits of the same unit. If insufficient 
space remains,

whether a bit-field that does not fit is put into the next unit or overlaps 
adjacent units is

implementation-defined. The order of allocation of bit-fields within a unit 
(high-order to

low-order or low-order to high-order) is implementation-defined. The alignment 
of the

addressable storage unit is unspecified.

 +};
 +uint16be_t cksm;   /** Checksum */
 +uint16be_t urgptr; /** Urgent pointer */
 +} odph_tcphdr_t;
 +
 +#ifdef __cplusplus
 +}
 +#endif
 +
 +#endif
 


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


Re: [lng-odp] [PATCH v2 4/9] linux-generic: odp_barrier.c use __atomic

2014-11-24 Thread Taras Kondratiuk

On 11/24/2014 12:20 PM, Ola Liljedahl wrote:

No, it is still there (slightly changed) in my code (at least after
applying all the patches):
 __atomic_thread_fence(__ATOMIC_SEQ_CST);
 count   = odp_atomic_fetch_inc_u32(barrier-bar);
 wasless = count  barrier-count;

 if (count == 2*barrier-count-1) {

More likely a result of doing git add -i incorrectly than of git
being confused...

Oh man now I have to redo that whole procedure...


No need to redo all. Just update one line in one patch with
'git rebase -i'

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


[lng-odp] [PATCH KS2] linux-keystone2: init: update init for McSDK 3.01.01.04

2014-11-24 Thread Taras Kondratiuk
Update initialization to be compatible with a new McSDK release.

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-keystone2/mcsdk/mcsdk_init.c |   85 ++-
 1 file changed, 58 insertions(+), 27 deletions(-)

diff --git a/platform/linux-keystone2/mcsdk/mcsdk_init.c 
b/platform/linux-keystone2/mcsdk/mcsdk_init.c
index 5820464..44eb0ae 100644
--- a/platform/linux-keystone2/mcsdk/mcsdk_init.c
+++ b/platform/linux-keystone2/mcsdk/mcsdk_init.c
@@ -49,27 +49,24 @@ struct mcsdk_cfg_s default_mcsdk_cfg = {
  */
 #define NWAL_CONFIG_SEC_CONTEXT_SZ 384
 
-#define NWAL_CONFIG_BUFSIZE_NWAL_HANDLE3400
-
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC   256
-#define NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN 256
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_IP128
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT  128
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR  128
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_LOC_CONTEXT   384
+#define NWAL_CONFIG_BUFSIZE_HANDLE 3400
+
+#define NWAL_CONFIG_BUFSIZE_PER_MAC256
+#define NWAL_CONFIG_BUFSIZE_IPSEC_HANDLE_PER_CHAN  256
+#define NWAL_CONFIG_BUFSIZE_PER_IP 128
+#define NWAL_CONFIG_BUFSIZE_PER_PORT   128
+#define NWAL_CONFIG_BUFSIZE_PER_L2L3_HDR   128
+#define NWAL_CONFIG_BUFSIZE_PER_LOC_CONTEXT384
 #define NWAL_CHAN_HANDLE_SIZE  \
-   ((NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC * TUNE_NETAPI_MAX_NUM_MAC) + \
-(NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN * \
+   ((NWAL_CONFIG_BUFSIZE_PER_MAC * TUNE_NETAPI_MAX_NUM_MAC) + \
+(NWAL_CONFIG_BUFSIZE_IPSEC_HANDLE_PER_CHAN * \
TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2) + \
-(NWAL_CONFIG_BUFSIZE_NWAL_PER_IP * TUNE_NETAPI_MAX_NUM_IP) + \
-(NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT * TUNE_NETAPI_MAX_NUM_PORTS) + \
-(NWAL_CONFIG_BUFSIZE_NWAL_PER_LOC_CONTEXT * TUNE_NETAPI_NUM_CORES) + \
-(NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR * \
+(NWAL_CONFIG_BUFSIZE_PER_IP * TUNE_NETAPI_MAX_NUM_IP) + \
+(NWAL_CONFIG_BUFSIZE_PER_PORT * TUNE_NETAPI_MAX_NUM_PORTS) + \
+(NWAL_CONFIG_BUFSIZE_PER_LOC_CONTEXT * TUNE_NETAPI_NUM_CORES) + \
+(NWAL_CONFIG_BUFSIZE_PER_L2L3_HDR * \
TUNE_NETAPI_MAX_NUM_L2_L3_HDRS))
 
-uint8_t nwal_inst_mem[NWAL_CONFIG_BUFSIZE_NWAL_HANDLE] ODP_ALIGNED_CACHE;
-uint8_t nwal_handle_mem[NWAL_CHAN_HANDLE_SIZE] ODP_ALIGNED_CACHE;
-
 /**
  * @todo: Check if below size information can be made available
  * from PA interface file
@@ -99,6 +96,11 @@ struct sa_global {
ODP_ALIGNED_CACHE;
 };
 
+struct nwal_global {
+   uint8_t nwal_inst_mem[NWAL_CONFIG_BUFSIZE_HANDLE] ODP_ALIGNED_CACHE;
+   uint8_t nwal_handle_mem[NWAL_CHAN_HANDLE_SIZE]ODP_ALIGNED_CACHE;
+};
+
 static uint8_t *cma_mem_alloc(uint32_t size)
 {
return (uint8_t *)hplib_vmMemAlloc(
@@ -131,9 +133,14 @@ int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable 
*p_table)
void *base = NULL;
struct pa_global *pa_entry = NULL;
struct sa_global *sa_entry = NULL;
+   struct nwal_global *nwal_entry = NULL;
+   nwalBaseAddrCfg_t base_addr_cfg;
+   uint32_t local_ctx_size = 0;
+   void *nwal_loc_ctx_mem = NULL;
 
memset(odp_global-nwal, 0, sizeof(odp_global-nwal));
memset(nwal_global_cfg, 0, sizeof(nwal_global_cfg));
+   memset(base_addr_cfg, 0, sizeof(base_addr_cfg));
 
nwal_global_cfg.rmHandle = odp_proc.rm_service;
 
@@ -143,20 +150,30 @@ int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable 
*p_table)
== hplib_OK) {
pa_entry = (struct pa_global *)hplib_shmGetEntry(
base, PA_ENTRY);
-   nwal_global_cfg.instPoolBaseAddr = (void *)pa_entry;
+   base_addr_cfg.pInstPoolPaBaseAddr = (void *)pa_entry;
} else {
odp_pr_err(Unable to Add shared memory segment for 
PASS\n);
return -1;
}
+
if (hplib_shmAddEntry(base, sizeof(struct sa_global), SA_ENTRY)
== hplib_OK) {
sa_entry = (struct sa_global *)hplib_shmGetEntry(
base, SA_ENTRY);
-   nwal_global_cfg.instPoolSaBaseAddr = (void *)sa_entry;
+   base_addr_cfg.pInstPoolSaBaseAddr = (void *)sa_entry;
} else {
odp_pr_err(Unable to Add shared memory segment for 
SASS\n);
return -1;
}
+
+   if (hplib_shmAddEntry(base, sizeof(struct sa_global),
+ NWAL_ENTRY) == hplib_OK

[lng-odp] [PATCHv2 KS2] linux-keystone2: init: update init for McSDK 3.01.01.04

2014-11-24 Thread Taras Kondratiuk
Update initialization to be compatible with a new McSDK release.

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
v2: Fixed NWAL_ENTRY size.

 platform/linux-keystone2/mcsdk/mcsdk_init.c |   85 ++-
 1 file changed, 58 insertions(+), 27 deletions(-)

diff --git a/platform/linux-keystone2/mcsdk/mcsdk_init.c 
b/platform/linux-keystone2/mcsdk/mcsdk_init.c
index 5820464..24c357a 100644
--- a/platform/linux-keystone2/mcsdk/mcsdk_init.c
+++ b/platform/linux-keystone2/mcsdk/mcsdk_init.c
@@ -49,27 +49,24 @@ struct mcsdk_cfg_s default_mcsdk_cfg = {
  */
 #define NWAL_CONFIG_SEC_CONTEXT_SZ 384
 
-#define NWAL_CONFIG_BUFSIZE_NWAL_HANDLE3400
-
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC   256
-#define NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN 256
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_IP128
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT  128
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR  128
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_LOC_CONTEXT   384
+#define NWAL_CONFIG_BUFSIZE_HANDLE 3400
+
+#define NWAL_CONFIG_BUFSIZE_PER_MAC256
+#define NWAL_CONFIG_BUFSIZE_IPSEC_HANDLE_PER_CHAN  256
+#define NWAL_CONFIG_BUFSIZE_PER_IP 128
+#define NWAL_CONFIG_BUFSIZE_PER_PORT   128
+#define NWAL_CONFIG_BUFSIZE_PER_L2L3_HDR   128
+#define NWAL_CONFIG_BUFSIZE_PER_LOC_CONTEXT384
 #define NWAL_CHAN_HANDLE_SIZE  \
-   ((NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC * TUNE_NETAPI_MAX_NUM_MAC) + \
-(NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN * \
+   ((NWAL_CONFIG_BUFSIZE_PER_MAC * TUNE_NETAPI_MAX_NUM_MAC) + \
+(NWAL_CONFIG_BUFSIZE_IPSEC_HANDLE_PER_CHAN * \
TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2) + \
-(NWAL_CONFIG_BUFSIZE_NWAL_PER_IP * TUNE_NETAPI_MAX_NUM_IP) + \
-(NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT * TUNE_NETAPI_MAX_NUM_PORTS) + \
-(NWAL_CONFIG_BUFSIZE_NWAL_PER_LOC_CONTEXT * TUNE_NETAPI_NUM_CORES) + \
-(NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR * \
+(NWAL_CONFIG_BUFSIZE_PER_IP * TUNE_NETAPI_MAX_NUM_IP) + \
+(NWAL_CONFIG_BUFSIZE_PER_PORT * TUNE_NETAPI_MAX_NUM_PORTS) + \
+(NWAL_CONFIG_BUFSIZE_PER_LOC_CONTEXT * TUNE_NETAPI_NUM_CORES) + \
+(NWAL_CONFIG_BUFSIZE_PER_L2L3_HDR * \
TUNE_NETAPI_MAX_NUM_L2_L3_HDRS))
 
-uint8_t nwal_inst_mem[NWAL_CONFIG_BUFSIZE_NWAL_HANDLE] ODP_ALIGNED_CACHE;
-uint8_t nwal_handle_mem[NWAL_CHAN_HANDLE_SIZE] ODP_ALIGNED_CACHE;
-
 /**
  * @todo: Check if below size information can be made available
  * from PA interface file
@@ -99,6 +96,11 @@ struct sa_global {
ODP_ALIGNED_CACHE;
 };
 
+struct nwal_global {
+   uint8_t nwal_inst_mem[NWAL_CONFIG_BUFSIZE_HANDLE] ODP_ALIGNED_CACHE;
+   uint8_t nwal_handle_mem[NWAL_CHAN_HANDLE_SIZE]ODP_ALIGNED_CACHE;
+};
+
 static uint8_t *cma_mem_alloc(uint32_t size)
 {
return (uint8_t *)hplib_vmMemAlloc(
@@ -131,9 +133,14 @@ int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable 
*p_table)
void *base = NULL;
struct pa_global *pa_entry = NULL;
struct sa_global *sa_entry = NULL;
+   struct nwal_global *nwal_entry = NULL;
+   nwalBaseAddrCfg_t base_addr_cfg;
+   uint32_t local_ctx_size = 0;
+   void *nwal_loc_ctx_mem = NULL;
 
memset(odp_global-nwal, 0, sizeof(odp_global-nwal));
memset(nwal_global_cfg, 0, sizeof(nwal_global_cfg));
+   memset(base_addr_cfg, 0, sizeof(base_addr_cfg));
 
nwal_global_cfg.rmHandle = odp_proc.rm_service;
 
@@ -143,20 +150,30 @@ int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable 
*p_table)
== hplib_OK) {
pa_entry = (struct pa_global *)hplib_shmGetEntry(
base, PA_ENTRY);
-   nwal_global_cfg.instPoolBaseAddr = (void *)pa_entry;
+   base_addr_cfg.pInstPoolPaBaseAddr = (void *)pa_entry;
} else {
odp_pr_err(Unable to Add shared memory segment for 
PASS\n);
return -1;
}
+
if (hplib_shmAddEntry(base, sizeof(struct sa_global), SA_ENTRY)
== hplib_OK) {
sa_entry = (struct sa_global *)hplib_shmGetEntry(
base, SA_ENTRY);
-   nwal_global_cfg.instPoolSaBaseAddr = (void *)sa_entry;
+   base_addr_cfg.pInstPoolSaBaseAddr = (void *)sa_entry;
} else {
odp_pr_err(Unable to Add shared memory segment for 
SASS\n);
return -1;
}
+
+   if (hplib_shmAddEntry(base, sizeof(struct nwal_global

[lng-odp] [PATCH KS2] linux-keystone2: allocate memregion from RM

2014-11-24 Thread Taras Kondratiuk
Instead of hardcoding memory region number and start link memory index
allocate them from RM.

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 platform/linux-keystone2/include/api/mcsdk_tune.h  |   17 -
 platform/linux-keystone2/include/api/odp_state.h   |2 ++
 .../linux-keystone2/include/api/odp_ti_mcsdk.h |2 +-
 .../linux-keystone2/include/odp_debug_internal.h   |2 +-
 platform/linux-keystone2/mcsdk/mcsdk_init.c|   16 +---
 platform/linux-keystone2/mcsdk/mcsdk_navig.c   |8 +---
 platform/linux-keystone2/odp_buffer_pool.c |2 +-
 7 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/platform/linux-keystone2/include/api/mcsdk_tune.h 
b/platform/linux-keystone2/include/api/mcsdk_tune.h
index 204330e..e87fd3c 100644
--- a/platform/linux-keystone2/include/api/mcsdk_tune.h
+++ b/platform/linux-keystone2/include/api/mcsdk_tune.h
@@ -102,23 +102,6 @@ extern C {
 #define TUNE_NETAPI_DESC_SIZE  128
 
 #ifdef NETAPI_USE_DDR
-/**
- * @ingroup tune_parameters
- * @def  TUNE_NETAPI_QM_START_INDEX
- *  This defines the queue manager start index
- * @note This must reflect what the kernel is uding for their region,
- *   see device tree blob for details.
- */
-#define TUNE_NETAPI_QM_START_INDEX  0
-
-/**
- * @ingroup tune_parameters
- * @def  TUNE_NETAPI_QM_GLOBAL_REGION
- *   This defines the queue manager global region
- * @note This must reflect what the kernel is using for their region,
- *   see device tree blob for details.
- */
-#define TUNE_NETAPI_QM_GLOBAL_REGION 18
 
 #else /* use msmc */
 #define TUNE_NETAPI_QM_START_INDEX  0
diff --git a/platform/linux-keystone2/include/api/odp_state.h 
b/platform/linux-keystone2/include/api/odp_state.h
index 7975ca8..2406245 100644
--- a/platform/linux-keystone2/include/api/odp_state.h
+++ b/platform/linux-keystone2/include/api/odp_state.h
@@ -25,6 +25,7 @@ struct odp_global_s {
Pktlib_HeapHandle sa2pa_heap; /** Internal SA-PA heap */
Pktlib_HeapHandle pa2sa_heap; /** Internal PA-SA head */
} nwal; /** Global NWAL state */
+   Qmss_MemRegion public_desc_memregion;
 };
 
 /** @internal Per process ODP state */
@@ -35,6 +36,7 @@ struct odp_proc_s {
Pktlib_HeapHandle netcp_control_tx_heap; /** tx control 
messages */
} nwal; /** Per process NWAL state */
Rm_ServiceHandle *rm_service;   /** Resource Manager service handle */
+   void *descriptor_mem_base;
 };
 
 /** @internal Per thread ODP state */
diff --git a/platform/linux-keystone2/include/api/odp_ti_mcsdk.h 
b/platform/linux-keystone2/include/api/odp_ti_mcsdk.h
index 21b609d..6dd0dd1 100644
--- a/platform/linux-keystone2/include/api/odp_ti_mcsdk.h
+++ b/platform/linux-keystone2/include/api/odp_ti_mcsdk.h
@@ -42,7 +42,7 @@ int mcsdk_qmss_init(int max_descriptors);
 int mcsdk_qmss_start(void);
 int mcsdk_cppi_start(void);
 int mcsdk_qmss_setup_memregion(uint32_t desc_num, uint32_t desc_size,
-   uint32_t *desc_mem_base, Qmss_MemRegion mem_region);
+   uint32_t *desc_mem_base);
 int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table);
 int mcsdk_nwal_start(Pktlib_HeapHandle pkt_heap,
 Pktlib_HeapHandle cmd_rx_heap,
diff --git a/platform/linux-keystone2/include/odp_debug_internal.h 
b/platform/linux-keystone2/include/odp_debug_internal.h
index 7b9c361..a93e282 100644
--- a/platform/linux-keystone2/include/odp_debug_internal.h
+++ b/platform/linux-keystone2/include/odp_debug_internal.h
@@ -25,7 +25,7 @@ extern C {
 #define ODP_PRINT_LEVEL_VDBG 6
 #define ODP_PRINT_LEVEL_MAX  7
 
-#define ODP_PRINT_LEVEL ODP_PRINT_LEVEL_WARN
+#define ODP_PRINT_LEVEL ODP_PRINT_LEVEL_DBG
 
 /**
  * Internal debug printing macro
diff --git a/platform/linux-keystone2/mcsdk/mcsdk_init.c 
b/platform/linux-keystone2/mcsdk/mcsdk_init.c
index 24c357a..fbc9bb5 100644
--- a/platform/linux-keystone2/mcsdk/mcsdk_init.c
+++ b/platform/linux-keystone2/mcsdk/mcsdk_init.c
@@ -20,7 +20,6 @@ hplib_virtualAddrInfo_T odp_vm_info;
  * Global variables which needs to be populated with memory pool attributes
  * which is passed to HPLIB for memory pool initialization
  */
-void *global_descriptor_mem_base;
 void *sa_context_mem_base;
 
 static uint8_t *cma_mem_alloc(uint32_t size);
@@ -533,12 +532,16 @@ int mcsdk_global_init(void)
 #endif
 
/* Allocate QM region from contiguous chunk above */
-   global_descriptor_mem_base = hplib_vmMemAlloc(
+   odp_proc.descriptor_mem_base = hplib_vmMemAlloc(
(odp_global-cfg.def_tot_descriptors_for_us
* TUNE_NETAPI_DESC_SIZE),
128, 0);
 
-   odp_pr_dbg(global desc region=%p\n, global_descriptor_mem_base);
+   odp_pr_dbg(global desc region=%p\n, odp_proc.descriptor_mem_base);
+   if (!odp_proc.descriptor_mem_base

Re: [lng-odp] [RFC PATCH 1/2] platform: debug: replace fprintf() with odp_override_log()

2014-11-21 Thread Taras Kondratiuk

On 11/20/2014 08:42 PM, Maxim Uvarov wrote:

On 11/20/2014 09:36 PM, Maxim Uvarov wrote:

On 11/20/2014 08:27 PM, Taras Kondratiuk wrote:

ODP application may want to override default ODP logging behaviour
and use custom logging function. Add a weak odp_override_log() function
for this purpose instead of default fprintf().

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
  platform/linux-generic/include/api/odp_debug.h |   24
++--
  platform/linux-generic/odp_init.c  |   14 ++
  2 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_debug.h
b/platform/linux-generic/include/api/odp_debug.h
index c9b2edd..be73318 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -14,6 +14,7 @@
#include stdio.h
  #include stdlib.h
+#include stdarg.h
#ifdef __cplusplus
  extern C {
@@ -79,6 +80,9 @@ typedef enum odp_log_level {
  ODP_LOG_ABORT
  } odp_log_level_e;
  +
+extern int odp_override_log(odp_log_level_e level, const char *fmt,
...);
+
  /**
   * ODP default LOG macro.
   */
@@ -86,45 +90,45 @@ typedef enum odp_log_level {
  do { \
  switch (level) { \
  case ODP_LOG_ERR: \
-fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
+odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
  __LINE__, __func__, ##__VA_ARGS__); \
  break; \
  case ODP_LOG_DBG: \
  if (ODP_DEBUG_PRINT == 1) \
-fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
-__LINE__, __func__, ##__VA_ARGS__); \
+odp_override_log(level, %s:%d:%s(): fmt, __FILE__, \
+__LINE__, __func__, ##__VA_ARGS__); \
  break; \
  case ODP_LOG_ABORT: \
-fprintf(stderr, %s:%d:%s():  fmt, __FILE__, \
+odp_override_log(level, %s:%d:%s():  fmt, __FILE__, \
  __LINE__, __func__, ##__VA_ARGS__); \
  abort(); \
  break; \
  case ODP_LOG_UNIMPLEMENTED: \
-fprintf(stderr, \
+odp_override_log(level, \
  %s:%d:The function %s() is not implemented\n \
  fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
  break; \
  default: \
-fprintf(stderr, Unknown LOG level); \
+odp_override_log(level, Unknown LOG level); \
  break;\
  } \
  } while (0)
/**
- * Debug printing macro, which prints output when DEBUG flag is set.
+ * Log debug message if DEBUG flag is set.
   */
  #define ODP_DBG(fmt, ...) \
  ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__)
/**
- * Print output to stderr (file, line and function).
+ * Log error message.
   */
  #define ODP_ERR(fmt, ...) \
  ODP_LOG(ODP_LOG_ERR, fmt, ##__VA_ARGS__)
/**
- * Print output to stderr (file, line and function),
- * then abort.
+ * Log abort message and then stop execution (by default call abort()).
+ * This function should not return.
   */
  #define ODP_ABORT(fmt, ...) \
  ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__)
diff --git a/platform/linux-generic/odp_init.c
b/platform/linux-generic/odp_init.c
index 672b3d6..7fbfe36 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -8,6 +8,7 @@
  #include odp_internal.h
  #include odp_debug.h
  #include odp_debug_internal.h
+#include odp_hints.h
  int odp_init_global(odp_init_t *params  ODP_UNUSED,
@@ -89,3 +90,16 @@ int odp_term_local(void)
  ODP_UNIMPLEMENTED();
  return 0;
  }
+
+ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level,
+ const char *fmt, ...)
+{
+va_list args;
+int r;
+(void)level;
+va_start(args, fmt);
+r = vfprintf(stdout, fmt, args);


don't like stdout here. It might be stderr or file descriptor.

Maxim.


Ah, it's weak function. And you provided level also. Withdraw my note.


That actually was stderr first. But for testing I've changed it to
stdout and forget to change it back. Will update in the next version.

Is odp_init.c a good place for this function or it should be in a
separate file? Like odp_log.c or odp_weaks.c



Maxim.


+va_end(args);
+
+return r;
+}





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



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


Re: [lng-odp] [RFC] cunit: add tests for scheduler API

2014-11-21 Thread Taras Kondratiuk

On 11/21/2014 12:18 PM, Alexandru Badicioiu wrote:

Hi,
the scheduling tests in odp_example were discussed some time ago and
there was an agreement, at least for FSL and TI platforms, that fair
scheduling assumed by the following loop:
for (i = 0; i  QUEUE_ROUNDS; i++) {
buf = odp_schedule_one(queue, ODP_SCHED_WAIT);

if (odp_queue_enq(queue, buf)) {
ODP_ERR(  [%i] Queue enqueue failed.\n, thr);
return -1;
}
}

for an ATOMIC queue doesn't make sense as the behavior of an ATOMIC
hardware queue is to be scheduled to the same core as long as there are
packets in the queue and the core has room to dequeue them (other
platforms please confirm or infirm). On my specific platform I can force
this with a particular HW configuration, but this configuration
effectively disables the use of POLL queues.
I think we need scheduling tests for the most general case (SYNC_NONE
and no assumption about how many buffers are scheduled to a particular
core).


I agree. Tests should not assume fair scheduling.

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


[lng-odp] [RFC PATCHv2] cunit: buffer: add buffer tests

2014-11-21 Thread Taras Kondratiuk
Initial version of buffer pool, buffer and packet API tests.
Based on Bill's buffer pool API update series [1].
Queue and Crypto tests are not updated by that series, so they have to
be disabled or reverted.
odp_packet_seg_*() functions are not implemented in linux-generic, so
these tests are guarded by TEST_PACKET_SEGMENTS define.

Current linux-generic has issue in odp_buffer_pool_create(). Created
buffer has a wrong number of buffers, so many tests are failing.

RFC v1..v2: - Moved from cunit to validation directory.
- Removed additional Makefile and used
  test/validation/Makefile.am instead.

[1] http://lists.linaro.org/pipermail/lng-odp/2014-November/004992.html

Signed-off-by: Taras Kondratiuk taras.kondrat...@linaro.org
---
 test/validation/Makefile.am|8 +-
 test/validation/buffer/odp_buffer_pool_test.c  |  213 +++
 test/validation/buffer/odp_buffer_test.c   |   52 
 test/validation/buffer/odp_buffer_testsuites.h |   30 +++
 test/validation/buffer/odp_packet_test.c   |  337 
 test/validation/odp_buffer.c   |   51 
 6 files changed, 690 insertions(+), 1 deletion(-)
 create mode 100644 test/validation/buffer/odp_buffer_pool_test.c
 create mode 100644 test/validation/buffer/odp_buffer_test.c
 create mode 100644 test/validation/buffer/odp_buffer_testsuites.h
 create mode 100644 test/validation/buffer/odp_packet_test.c
 create mode 100644 test/validation/odp_buffer.c

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 0b831d0..c5c1ae2 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -6,11 +6,13 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
 if ODP_CUNIT_ENABLED
 TESTS = ${bin_PROGRAMS}
 check_PROGRAMS = ${bin_PROGRAMS}
-bin_PROGRAMS = odp_init odp_queue odp_crypto
+bin_PROGRAMS = odp_init odp_queue odp_crypto odp_buffer
 odp_init_LDFLAGS = $(AM_LDFLAGS)
 odp_queue_LDFLAGS = $(AM_LDFLAGS)
 odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
 odp_crypto_LDFLAGS = $(AM_LDFLAGS)
+odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer
+odp_buffer_LDFLAGS = $(AM_LDFLAGS)
 endif
 
 dist_odp_init_SOURCES = odp_init.c
@@ -18,3 +20,7 @@ dist_odp_queue_SOURCES = odp_queue.c
 dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
  crypto/odp_crypto_test_sync_inp.c \
  odp_crypto.c
+dist_odp_buffer_SOURCES = buffer/odp_buffer_pool_test.c \
+ buffer/odp_buffer_test.c \
+ buffer/odp_packet_test.c \
+ odp_buffer.c
diff --git a/test/validation/buffer/odp_buffer_pool_test.c 
b/test/validation/buffer/odp_buffer_pool_test.c
new file mode 100644
index 000..cd7711e
--- /dev/null
+++ b/test/validation/buffer/odp_buffer_pool_test.c
@@ -0,0 +1,213 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:BSD-3-Clause
+ */
+
+#include odp_buffer_testsuites.h
+
+static int pool_name_number = 1;
+static const int default_buffer_size = 1500;
+static const int default_buffer_num = 1000;
+
+odp_buffer_pool_t pool_create(int buf_num, int buf_size, int buf_type)
+{
+   odp_buffer_pool_t pool;
+   char pool_name[ODP_BUFFER_POOL_NAME_LEN];
+   odp_buffer_pool_param_t params = {
+   .buf_size  = buf_size,
+   .buf_align = ODP_CACHE_LINE_SIZE,
+   .num_bufs  = buf_num,
+   .buf_type  = buf_type,
+   };
+
+   snprintf(pool_name, sizeof(pool_name),
+test_buffer_pool-%d, pool_name_number++);
+
+   pool = odp_buffer_pool_create(pool_name, ODP_SHM_INVALID, params);
+   CU_ASSERT_FATAL(pool != ODP_BUFFER_POOL_INVALID);
+
+   return pool;
+}
+
+static void pool_create_destroy_type(int type)
+{
+   odp_buffer_pool_t pool;
+   pool = pool_create(default_buffer_num, default_buffer_size, type);
+
+   CU_ASSERT(odp_buffer_pool_destroy(pool) == 0);
+}
+
+static void pool_create_destroy_raw(void)
+{
+   pool_create_destroy_type(ODP_BUFFER_TYPE_RAW);
+}
+
+static void pool_create_destroy_packet(void)
+{
+   pool_create_destroy_type(ODP_BUFFER_TYPE_PACKET);
+}
+
+static void pool_create_destroy_timeout(void)
+{
+   pool_create_destroy_type(ODP_BUFFER_TYPE_TIMEOUT);
+}
+
+static void pool_create_destroy_any(void)
+{
+   pool_create_destroy_type(ODP_BUFFER_TYPE_ANY);
+}
+
+static void pool_create_destroy_raw_shm(void)
+{
+   odp_buffer_pool_t pool;
+   odp_shm_t test_shm;
+   odp_buffer_pool_param_t params = {
+   .buf_size  = 1500,
+   .buf_align = ODP_CACHE_LINE_SIZE,
+   .num_bufs  = 10,
+   .buf_type  = ODP_BUFFER_TYPE_RAW,
+   };
+
+   test_shm = odp_shm_reserve(test_shm,
+  params.buf_size * params.num_bufs * 2

Re: [lng-odp] [RFC] cunit: add tests for scheduler API

2014-11-21 Thread Taras Kondratiuk

On 11/20/2014 09:02 PM, Ciprian Barbu wrote:

Signed-off-by: Ciprian Barbu ciprian.ba...@linaro.org
---
The testcases are based almost entirely on the odp_example.
There are no alloc tests and I added a test case for odp_schedule_wait_time.
The major differencs between the odp_example and this cunit is the partition
into testcases, the odp_example calls every test case from one big function.

I had to work some magic in order to be able to pass arguments to test cases,
I hope is not too hard to follow.

  configure.ac  |   1 +
  test/cunit/Makefile.am|   2 +
  test/cunit/schedule/Makefile.am   |  10 +
  test/cunit/schedule/odp_schedule_test.c   | 844 ++
  test/cunit/schedule/odp_schedule_testsuites.c |  35 ++
  test/cunit/schedule/odp_schedule_testsuites.h |  21 +
  6 files changed, 913 insertions(+)
  create mode 100644 test/cunit/schedule/Makefile.am
  create mode 100644 test/cunit/schedule/odp_schedule_test.c
  create mode 100644 test/cunit/schedule/odp_schedule_testsuites.c
  create mode 100644 test/cunit/schedule/odp_schedule_testsuites.h

diff --git a/configure.ac b/configure.ac
index fcd7279..a47db72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -173,6 +173,7 @@ AC_CONFIG_FILES([Makefile
 test/Makefile
 test/api_test/Makefile
   test/cunit/Makefile
+ test/cunit/schedule/Makefile
 pkgconfig/libodp.pc])

  AC_SEARCH_LIBS([timer_create],[rt posix4])
diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am
index 439e134..b6033ee 100644
--- a/test/cunit/Makefile.am
+++ b/test/cunit/Makefile.am
@@ -3,6 +3,8 @@ include $(top_srcdir)/test/Makefile.inc
  AM_CFLAGS += -I$(CUNIT_PATH)/include
  AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit

+SUBDIRS = schedule
+


Don't create a separate makefile, so all test binaries will be the same
directory.


  if ODP_CUNIT_ENABLED
  TESTS = ${bin_PROGRAMS}
  check_PROGRAMS = ${bin_PROGRAMS}



+
+struct CU_TestInfo schedule_tests[] = {
+   _CU_TEST_INFO(schedule_wait_time),
+   _CU_TEST_INFO(schedule_one_single_lo),
+   _CU_TEST_INFO(schedule_single_lo),
+   _CU_TEST_INFO(schedule_one_many_lo),
+   _CU_TEST_INFO(schedule_many_lo),
+   _CU_TEST_INFO(schedule_multi_lo),
+   _CU_TEST_INFO(schedule_one_single_hi),
+   _CU_TEST_INFO(schedule_single_hi),
+   _CU_TEST_INFO(schedule_one_many_hi),
+   _CU_TEST_INFO(schedule_many_hi),
+   _CU_TEST_INFO(schedule_multi_hi),
+   CU_TEST_INFO_NULL,
+};


schedule_one() will be dropped, so these tests also can be dropped.

I think odp_example is not a good base for scheduler tests. It was
written as benchmark, but not as a verification test.

Basic scheduler tests are missing:
- verify that priority works correctly.
- verify that atomicity works correctly for ATOMIC queues.
- verify order for ORDERED queues.

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


Re: [lng-odp] [PATCHv2 1/3] test/example changes for v1.0 buffer pool APIs

2014-11-21 Thread Taras Kondratiuk

On 11/21/2014 02:15 PM, Maxim Uvarov wrote:

On 11/21/2014 03:45 AM, Bill Fischofer wrote:

OK, I'm confused here.  The patches to effect API changes are large
because they need to change three things:

1. The .h files that define the API.
2. The revised implementation of the API.
3. The example/test programs that use the API.

None of these can be separated and result in a buildable system.
However when I first submitted one of these changes I was told it was
too large and needed to be broken up, which is why they're now being
posted in parts for review convenience.


That is very common situation. It's better to provide small patches for
review. And I can merge them on applying.
To give me a hint that several patches have to be merged together you
can name them like this:
test/example changes for v1.0 buffer pool APIs - part1: API
test/example changes for v1.0 buffer pool APIs - part2: Implementation
test/example changes for v1.0 buffer pool APIs - part3: Tests


I don't think it is a good idea.
How will you merge commit messages and Reviewed-by tags?

Patches should be reviewed in the same way they are going to be merged.
If smaller patch is needed than this patch can be split by functional 
changes, but not by directories it touches.


1. Update odp_buffer_pool_create() API everywhere.
2. Add odp_buffer_pool_destroy().
3. Add odp_buffer_pool_info().

The last two are small and may be squashed.

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


Re: [lng-odp] [RFC] cunit: add tests for scheduler API

2014-11-21 Thread Taras Kondratiuk

On 11/21/2014 03:44 PM, Ciprian Barbu wrote:

On Fri, Nov 21, 2014 at 1:31 PM, Taras Kondratiuk
taras.kondrat...@linaro.org wrote:

On 11/20/2014 09:02 PM, Ciprian Barbu wrote:


Signed-off-by: Ciprian Barbu ciprian.ba...@linaro.org
---
The testcases are based almost entirely on the odp_example.
There are no alloc tests and I added a test case for
odp_schedule_wait_time.
The major differencs between the odp_example and this cunit is the
partition
into testcases, the odp_example calls every test case from one big
function.

I had to work some magic in order to be able to pass arguments to test
cases,
I hope is not too hard to follow.

   configure.ac  |   1 +
   test/cunit/Makefile.am|   2 +
   test/cunit/schedule/Makefile.am   |  10 +
   test/cunit/schedule/odp_schedule_test.c   | 844
++
   test/cunit/schedule/odp_schedule_testsuites.c |  35 ++
   test/cunit/schedule/odp_schedule_testsuites.h |  21 +
   6 files changed, 913 insertions(+)
   create mode 100644 test/cunit/schedule/Makefile.am
   create mode 100644 test/cunit/schedule/odp_schedule_test.c
   create mode 100644 test/cunit/schedule/odp_schedule_testsuites.c
   create mode 100644 test/cunit/schedule/odp_schedule_testsuites.h

diff --git a/configure.ac b/configure.ac
index fcd7279..a47db72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -173,6 +173,7 @@ AC_CONFIG_FILES([Makefile
  test/Makefile
  test/api_test/Makefile
test/cunit/Makefile
+ test/cunit/schedule/Makefile
  pkgconfig/libodp.pc])

   AC_SEARCH_LIBS([timer_create],[rt posix4])
diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am
index 439e134..b6033ee 100644
--- a/test/cunit/Makefile.am
+++ b/test/cunit/Makefile.am
@@ -3,6 +3,8 @@ include $(top_srcdir)/test/Makefile.inc
   AM_CFLAGS += -I$(CUNIT_PATH)/include
   AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit

+SUBDIRS = schedule
+



Don't create a separate makefile, so all test binaries will be the same
directory.


Did you get that feedback on private? I don't see it in the comments.
Anyway, I can drop the extra Makefile no problem.


Anders complained that 'make check' has some issues with this. And I've 
noticed that Alex have changed Crypto tests in this way.







   if ODP_CUNIT_ENABLED
   TESTS = ${bin_PROGRAMS}
   check_PROGRAMS = ${bin_PROGRAMS}




+
+struct CU_TestInfo schedule_tests[] = {
+   _CU_TEST_INFO(schedule_wait_time),
+   _CU_TEST_INFO(schedule_one_single_lo),
+   _CU_TEST_INFO(schedule_single_lo),
+   _CU_TEST_INFO(schedule_one_many_lo),
+   _CU_TEST_INFO(schedule_many_lo),
+   _CU_TEST_INFO(schedule_multi_lo),
+   _CU_TEST_INFO(schedule_one_single_hi),
+   _CU_TEST_INFO(schedule_single_hi),
+   _CU_TEST_INFO(schedule_one_many_hi),
+   _CU_TEST_INFO(schedule_many_hi),
+   _CU_TEST_INFO(schedule_multi_hi),
+   CU_TEST_INFO_NULL,
+};



schedule_one() will be dropped, so these tests also can be dropped.


Yes I know I had to drop them. I kept them in for this RFC for easy
comparison against odp_example



I think odp_example is not a good base for scheduler tests. It was
written as benchmark, but not as a verification test.


That's actually not the feedback I got from Mike, correct me if I'm wrong.


My main concerns about odp_example:
- it does millions of iterations which is not necessary for functional 
verification (at least for basic).

- it makes wrong assumption about scheduler fairness.
- it doesn't check main functional features mentioned in a quote below.

It would be better to start from scratch, that try to modify
odp_example.

I imagine basic scheduler testing in following steps:
1. One queue, single thread. odp_schedule() return all enqueued buffers.
   Test each queue type (PARALLEL, ATOMIC, ORDERED).
2. Many queues, single thread. odp_schedule() return all enqueued
   buffers. Verify buffer source queue. Test each queue type.
3. Queues with different priorities, single thread. odp_schedule()
   return all buffers according to queue priorities. Test each queue
   type.
4. Same as 3 but multi-threaded.
5. One ATOMIC queue, several threads. Verify that only one thread at a
   time can get a buffer from that queue.
6. Same as 5, but use odp_schedule_release_atomic() and check that one
   more thread could get an event. That is an optional test, because
   odp_schedule_release_atomic() is a hint and may be ignored by
   platform.
7. Two queues one of them ORDERED, several threads. Verify that buffers
   scheduled from ORDERED queue are enqueue into the second queue in
   correct order.
8. Test scheduler timeout APIs.






Basic scheduler tests are missing:
- verify that priority works correctly.
- verify that atomicity works correctly for ATOMIC queues.
- verify order for ORDERED queues.


That's good input, thank you

<    1   2   3   4   >