Re: [lng-odp] [PATCH] Removed odp_atomic_int_t

2014-11-06 Thread Savolainen, Petri (NSN - FI/Espoo)


From: ext Santosh Shukla [mailto:santosh.shu...@linaro.org]
Sent: Wednesday, November 05, 2014 2:57 PM
To: Petri Savolainen
Cc: lng-odp-forward
Subject: Re: [lng-odp] [PATCH] Removed odp_atomic_int_t



On 31 October 2014 19:09, Petri Savolainen 
petri.savolai...@linaro.orgmailto:petri.savolai...@linaro.org wrote:
Integer version is not needed. Unsigned 32 and 64 bit atomics
are used instead. If signed 32/64 bits can be added later

instead - if signed 32/64 bits required then can be added later on need basis.

Yes. The word “needed” missing from commit message. Is it obvious from the 
context or could e.g. Maxim add that.


on need basis.

Signed-off-by: Petri Savolainen 
petri.savolai...@linaro.orgmailto:petri.savolai...@linaro.org
---
 platform/linux-generic/include/api/odp_atomic.h| 115 -
 platform/linux-generic/include/api/odp_barrier.h   |   4 +-
 .../linux-generic/include/odp_buffer_internal.h|   2 +-
 platform/linux-generic/odp_barrier.c   |   6 +-
 platform/linux-generic/odp_thread.c|   6 +-
 test/api_test/odp_atomic_test.c|  80 ++
 test/api_test/odp_atomic_test.h|   9 --
 7 files changed, 16 insertions(+), 206 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_atomic.h 
b/platform/linux-generic/include/api/odp_atomic.h
index 213c81f..5c83b39 100644
--- a/platform/linux-generic/include/api/odp_atomic.h
+++ b/platform/linux-generic/include/api/odp_atomic.h
@@ -26,10 +26,6 @@ extern C {
  *  @{
  */

-/**
- * Atomic integer
- */
-typedef volatile int32_t odp_atomic_int_t;

 /**
  * Atomic unsigned integer 64 bits
@@ -43,117 +39,6 @@ typedef volatile uint32_t odp_atomic_u32_t;


 /**
- * Initialize atomic integer
- *
- * @param ptrAn integer atomic variable
- *
- * @note The operation is not synchronized with other threads
- */
-static inline void odp_atomic_init_int(odp_atomic_int_t *ptr)
-{
-   *ptr = 0;
-}
-
-/**
- * Load value of atomic integer
- *
- * @param ptrAn atomic variable
- *
- * @return atomic integer value
- *
- * @note The operation is not synchronized with other threads
- */
-static inline int odp_atomic_load_int(odp_atomic_int_t *ptr)
-{
-   return *ptr;
-}
-
-/**
- * Store value to atomic integer
- *
- * @param ptrAn atomic variable
- * @param new_value  Store new_value to a variable
- *
- * @note The operation is not synchronized with other threads
- */
-static inline void odp_atomic_store_int(odp_atomic_int_t *ptr, int new_value)
-{
-   *ptr = new_value;
-}
-
-/**
- * Fetch and add atomic integer
- *
- * @param ptrAn atomic variable
- * @param value  A value to be added to the variable
- *
- * @return Value of the variable before the operation
- */
-static inline int odp_atomic_fetch_add_int(odp_atomic_int_t *ptr, int value)
-{
-   return __sync_fetch_and_add(ptr, value);
-}
-
-/**
- * Fetch and subtract atomic integer
- *
- * @param ptrAn atomic integer variable
- * @param value  A value to be subtracted from the variable
- *
- * @return Value of the variable before the operation
- */
-static inline int odp_atomic_fetch_sub_int(odp_atomic_int_t *ptr, int value)
-{
-   return __sync_fetch_and_sub(ptr, value);
-}
-
-/**
- * Fetch and increment atomic integer by 1
- *
- * @param ptrAn atomic variable
- *
- * @return Value of the variable before the operation
- */
-static inline int odp_atomic_fetch_inc_int(odp_atomic_int_t *ptr)
-{
-   return odp_atomic_fetch_add_int(ptr, 1);
-}
-
-/**
- * Increment atomic integer by 1
- *
- * @param ptrAn atomic variable
- *
- */
-static inline void odp_atomic_inc_int(odp_atomic_int_t *ptr)
-{
-   odp_atomic_fetch_add_int(ptr, 1);
-}
-
-/**
- * Fetch and decrement atomic integer by 1
- *
- * @param ptrAn atomic int variable
- *
- * @return Value of the variable before the operation
- */
-static inline int odp_atomic_fetch_dec_int(odp_atomic_int_t *ptr)
-{
-   return odp_atomic_fetch_sub_int(ptr, 1);
-}
-
-/**
- * Decrement atomic integer by 1
- *
- * @param ptrAn atomic variable
- *
- */
-static inline void odp_atomic_dec_int(odp_atomic_int_t *ptr)
-{
-   odp_atomic_fetch_sub_int(ptr, 1);
-}
-
-/**
  * Initialize atomic uint32
  *
  * @param ptrAn atomic variable
diff --git a/platform/linux-generic/include/api/odp_barrier.h 
b/platform/linux-generic/include/api/odp_barrier.h
index 866648f..fb02a9d 100644
--- a/platform/linux-generic/include/api/odp_barrier.h
+++ b/platform/linux-generic/include/api/odp_barrier.h
@@ -31,8 +31,8 @@ extern C {
  * ODP execution barrier
  */
 typedef struct odp_barrier_t {
-   int  count;  /** @private Thread count */
-   odp_atomic_int_t bar;/** @private Barrier counter */
+   uint32_t count;  /** @private Thread count */
+   odp_atomic_u32_t bar;/** @private Barrier counter */
 } odp_barrier_t;


diff --git a/platform/linux-generic/include/odp_buffer_internal.h 

Re: [lng-odp] [PATCH] Removed odp_atomic_int_t

2014-11-06 Thread Santosh Shukla



 -void test_atomic_inc_dec_32(void);
 -void test_atomic_add_sub_32(void);
  void test_atomic_inc_dec_u32(void);
  void test_atomic_add_sub_u32(void);
  void test_atomic_inc_dec_64(void);
  void test_atomic_add_sub_64(void);



 so as we should replace above 2 api from _64 to _u64, right?



 I believe this is your code. I didn’t rename functions, just removed those
 using int atomics (signed 32). The _64 functions calls _u64 atomic APIs.
 So, would you like to align function naming  after this patch has been
 merged?




Okay.I'll send out patch depedent on this one.



  -Petri



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


Re: [lng-odp] [PATCH] Removed odp_atomic_int_t

2014-11-06 Thread Savolainen, Petri (NSN - FI/Espoo)
This is the one thing from Ola's patch that everybody agrees (I guess). After 
rebase, Ola can send out separate patches each solving an individual problem. 


-Petri



 -Original Message-
 From: lng-odp-boun...@lists.linaro.org [mailto:lng-odp-
 boun...@lists.linaro.org] On Behalf Of ext Maxim Uvarov
 Sent: Thursday, November 06, 2014 12:54 AM
 To: lng-odp@lists.linaro.org
 Subject: Re: [lng-odp] [PATCH] Removed odp_atomic_int_t
 
 Applying this patch will conflict with Ola's work right? Do we need take
 decision about Ola's patch?
 Which way we go with that patch or with Ola's?
 
 Maxim.
 
 On 11/05/2014 03:56 PM, Santosh Shukla wrote:
 
 
  On 31 October 2014 19:09, Petri Savolainen
  petri.savolai...@linaro.org mailto:petri.savolai...@linaro.org
 wrote:
 
  Integer version is not needed. Unsigned 32 and 64 bit atomics
  are used instead. If signed 32/64 bits can be added later
 
 
  instead - if signed 32/64 bits required then can be added later on
  need basis.
 
 
  on need basis.
 
  Signed-off-by: Petri Savolainen petri.savolai...@linaro.org
  mailto:petri.savolai...@linaro.org
  ---
   platform/linux-generic/include/api/odp_atomic.h| 115
  -
   platform/linux-generic/include/api/odp_barrier.h   |   4 +-
   .../linux-generic/include/odp_buffer_internal.h|   2 +-
   platform/linux-generic/odp_barrier.c   |   6 +-
   platform/linux-generic/odp_thread.c|   6 +-
   test/api_test/odp_atomic_test.c|  80
  ++
   test/api_test/odp_atomic_test.h|   9 --
   7 files changed, 16 insertions(+), 206 deletions(-)
 
  diff --git a/platform/linux-generic/include/api/odp_atomic.h
  b/platform/linux-generic/include/api/odp_atomic.h
  index 213c81f..5c83b39 100644
  --- a/platform/linux-generic/include/api/odp_atomic.h
  +++ b/platform/linux-generic/include/api/odp_atomic.h
  @@ -26,10 +26,6 @@ extern C {
*  @{
*/
 
  -/**
  - * Atomic integer
  - */
  -typedef volatile int32_t odp_atomic_int_t;
 
   /**
* Atomic unsigned integer 64 bits
  @@ -43,117 +39,6 @@ typedef volatile uint32_t odp_atomic_u32_t;
 
 
   /**
  - * Initialize atomic integer
  - *
  - * @param ptrAn integer atomic variable
  - *
  - * @note The operation is not synchronized with other threads
  - */
  -static inline void odp_atomic_init_int(odp_atomic_int_t *ptr)
  -{
  -   *ptr = 0;
  -}
  -
  -/**
  - * Load value of atomic integer
  - *
  - * @param ptrAn atomic variable
  - *
  - * @return atomic integer value
  - *
  - * @note The operation is not synchronized with other threads
  - */
  -static inline int odp_atomic_load_int(odp_atomic_int_t *ptr)
  -{
  -   return *ptr;
  -}
  -
  -/**
  - * Store value to atomic integer
  - *
  - * @param ptrAn atomic variable
  - * @param new_value  Store new_value to a variable
  - *
  - * @note The operation is not synchronized with other threads
  - */
  -static inline void odp_atomic_store_int(odp_atomic_int_t *ptr,
  int new_value)
  -{
  -   *ptr = new_value;
  -}
  -
  -/**
  - * Fetch and add atomic integer
  - *
  - * @param ptrAn atomic variable
  - * @param value  A value to be added to the variable
  - *
  - * @return Value of the variable before the operation
  - */
  -static inline int odp_atomic_fetch_add_int(odp_atomic_int_t *ptr,
  int value)
  -{
  -   return __sync_fetch_and_add(ptr, value);
  -}
  -
  -/**
  - * Fetch and subtract atomic integer
  - *
  - * @param ptrAn atomic integer variable
  - * @param value  A value to be subtracted from the variable
  - *
  - * @return Value of the variable before the operation
  - */
  -static inline int odp_atomic_fetch_sub_int(odp_atomic_int_t *ptr,
  int value)
  -{
  -   return __sync_fetch_and_sub(ptr, value);
  -}
  -
  -/**
  - * Fetch and increment atomic integer by 1
  - *
  - * @param ptrAn atomic variable
  - *
  - * @return Value of the variable before the operation
  - */
  -static inline int odp_atomic_fetch_inc_int(odp_atomic_int_t *ptr)
  -{
  -   return odp_atomic_fetch_add_int(ptr, 1);
  -}
  -
  -/**
  - * Increment atomic integer by 1
  - *
  - * @param ptrAn atomic variable
  - *
  - */
  -static inline void odp_atomic_inc_int(odp_atomic_int_t *ptr)
  -{
  -   odp_atomic_fetch_add_int(ptr, 1);
  -}
  -
  -/**
  - * Fetch and decrement atomic integer by 1
  - *
  - * @param ptrAn atomic int variable
  - *
  - * @return Value of the 

Re: [lng-odp] [PATCH] Removed odp_atomic_int_t

2014-11-06 Thread Maxim Uvarov

On 11/06/2014 12:02 PM, Savolainen, Petri (NSN - FI/Espoo) wrote:

This is the one thing from Ola's patch that everybody agrees (I guess). After 
rebase, Ola can send out separate patches each solving an individual problem.


-Petri

Ola, do you confirm?

Maxim.






-Original Message-
From: lng-odp-boun...@lists.linaro.org [mailto:lng-odp-
boun...@lists.linaro.org] On Behalf Of ext Maxim Uvarov
Sent: Thursday, November 06, 2014 12:54 AM
To: lng-odp@lists.linaro.org
Subject: Re: [lng-odp] [PATCH] Removed odp_atomic_int_t

Applying this patch will conflict with Ola's work right? Do we need take
decision about Ola's patch?
Which way we go with that patch or with Ola's?

Maxim.

On 11/05/2014 03:56 PM, Santosh Shukla wrote:


On 31 October 2014 19:09, Petri Savolainen
petri.savolai...@linaro.org mailto:petri.savolai...@linaro.org

wrote:

 Integer version is not needed. Unsigned 32 and 64 bit atomics
 are used instead. If signed 32/64 bits can be added later


instead - if signed 32/64 bits required then can be added later on
need basis.


 on need basis.

 Signed-off-by: Petri Savolainen petri.savolai...@linaro.org
 mailto:petri.savolai...@linaro.org
 ---
  platform/linux-generic/include/api/odp_atomic.h| 115
 -
  platform/linux-generic/include/api/odp_barrier.h   |   4 +-
  .../linux-generic/include/odp_buffer_internal.h|   2 +-
  platform/linux-generic/odp_barrier.c   |   6 +-
  platform/linux-generic/odp_thread.c|   6 +-
  test/api_test/odp_atomic_test.c|  80
 ++
  test/api_test/odp_atomic_test.h|   9 --
  7 files changed, 16 insertions(+), 206 deletions(-)

 diff --git a/platform/linux-generic/include/api/odp_atomic.h
 b/platform/linux-generic/include/api/odp_atomic.h
 index 213c81f..5c83b39 100644
 --- a/platform/linux-generic/include/api/odp_atomic.h
 +++ b/platform/linux-generic/include/api/odp_atomic.h
 @@ -26,10 +26,6 @@ extern C {
   *  @{
   */

 -/**
 - * Atomic integer
 - */
 -typedef volatile int32_t odp_atomic_int_t;

  /**
   * Atomic unsigned integer 64 bits
 @@ -43,117 +39,6 @@ typedef volatile uint32_t odp_atomic_u32_t;


  /**
 - * Initialize atomic integer
 - *
 - * @param ptrAn integer atomic variable
 - *
 - * @note The operation is not synchronized with other threads
 - */
 -static inline void odp_atomic_init_int(odp_atomic_int_t *ptr)
 -{
 -   *ptr = 0;
 -}
 -
 -/**
 - * Load value of atomic integer
 - *
 - * @param ptrAn atomic variable
 - *
 - * @return atomic integer value
 - *
 - * @note The operation is not synchronized with other threads
 - */
 -static inline int odp_atomic_load_int(odp_atomic_int_t *ptr)
 -{
 -   return *ptr;
 -}
 -
 -/**
 - * Store value to atomic integer
 - *
 - * @param ptrAn atomic variable
 - * @param new_value  Store new_value to a variable
 - *
 - * @note The operation is not synchronized with other threads
 - */
 -static inline void odp_atomic_store_int(odp_atomic_int_t *ptr,
 int new_value)
 -{
 -   *ptr = new_value;
 -}
 -
 -/**
 - * Fetch and add atomic integer
 - *
 - * @param ptrAn atomic variable
 - * @param value  A value to be added to the variable
 - *
 - * @return Value of the variable before the operation
 - */
 -static inline int odp_atomic_fetch_add_int(odp_atomic_int_t *ptr,
 int value)
 -{
 -   return __sync_fetch_and_add(ptr, value);
 -}
 -
 -/**
 - * Fetch and subtract atomic integer
 - *
 - * @param ptrAn atomic integer variable
 - * @param value  A value to be subtracted from the variable
 - *
 - * @return Value of the variable before the operation
 - */
 -static inline int odp_atomic_fetch_sub_int(odp_atomic_int_t *ptr,
 int value)
 -{
 -   return __sync_fetch_and_sub(ptr, value);
 -}
 -
 -/**
 - * Fetch and increment atomic integer by 1
 - *
 - * @param ptrAn atomic variable
 - *
 - * @return Value of the variable before the operation
 - */
 -static inline int odp_atomic_fetch_inc_int(odp_atomic_int_t *ptr)
 -{
 -   return odp_atomic_fetch_add_int(ptr, 1);
 -}
 -
 -/**
 - * Increment atomic integer by 1
 - *
 - * @param ptrAn atomic variable
 - *
 - */
 -static inline void odp_atomic_inc_int(odp_atomic_int_t *ptr)
 -{
 -   odp_atomic_fetch_add_int(ptr, 1);
 -}
 -
 -/**
 - * Fetch and decrement atomic integer by 1
 - *
 - * @param ptrAn atomic int variable
 - *
 - * @return Value of the variable before the operation
 - */
 -static inline int 

Re: [lng-odp] ODP_PACKET_MAX_HEADROOM

2014-11-06 Thread Bill Fischofer
I'd think that would be reasonable.  The idea behind implementation limits
like this is to accommodate a range of underlying hardware capabilities.
As ODP applications get developed and deployed I suspect we'll have a
better understanding about what applications actually need with regard to
things like this.

On Wed, Nov 5, 2014 at 9:50 PM, Job Abraham job.abra...@avagotech.com
wrote:

 Hi

 As I understand, each ODP implementation can define
 ODP_PACKET_MAX_HEADROOM.
 Is 64 a sufficient number to handle most use cases of ODP applications?

 Regards,
 Job

 ___
 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] [PATCHv3] ipc linux-generic implementation based on pktio

2014-11-06 Thread Savolainen, Petri (NSN - FI/Espoo)

 +int lg_odp_pktio_lookup(const char *dev, pktio_entry_t *pktio_entry)
 +{
 + int ret = -1;
 + char ipc_shm_name[ODPH_RING_NAMESIZE];
 + size_t ring_size;
 +
 + if (!(lg_odp_shm_lookup_pktio(dev) == 0 
 +   odp_shm_lookup_ipc(shm_packet_pool) == 0)) {
 + ODP_DBG(pid %d unable to find ipc object: %s.\n,
 + getpid(), dev);
 + goto error;
 + }

So, the role of the new odp_shm_lookup_ipc() call is just check if a shm has 
been created. I'm against adding xxx_ipc() versions of existing API calls. You 
should be able to just use the normal lookup. Maybe ODP (global init) needs to 
be informed that application runs in multi-process mode, so that ODP internal 
data structures are mapped so that multiple processes can lookup from those. 

If you check e.g. Multi-process Sample Application chapter in DPDK sample 
apps guide. It gives a cleaner framework how to handle the multi-process case.

 +
 + ODP_DBG(pid %d odp_shm_lookup_ipc found shared object\n,
 + getpid());
 + ring_size =  PKTIO_IPC_ENTRIES * sizeof(void *) +
 + sizeof(odph_ring_t);
 +
 + memset(ipc_shm_name, 0, ODPH_RING_NAMESIZE);
 + memcpy(ipc_shm_name, dev, strlen(dev));
 + memcpy(ipc_shm_name + strlen(dev), _r, 2);
 +
 + /* allocate shared memory for buffers needed to be produced */
 + odp_shm_t shm = odp_shm_reserve(ipc_shm_name, ring_size,
 + ODP_CACHE_LINE_SIZE,
 + ODP_SHM_PROC_NOCREAT);

This should be replaced by the normal (multi-process capable) lookup.

 +
 + pktio_entry-s.ipc_r = odp_shm_addr(shm);
 + if (!pktio_entry-s.ipc_r) {
 + ODP_DBG(pid %d unable to find ipc ring %s name\n,
 + getpid(), dev);
 + goto error;
 + }
 +
 + memcpy(ipc_shm_name + strlen(dev), _p, 2);
 + /* allocate shared memory for produced ring buffer handlers. That
 +  * buffers will be cleaned up after they are produced by other
 process.
 +  */
 + shm = odp_shm_reserve(ipc_shm_name, ring_size,
 + ODP_CACHE_LINE_SIZE,
 + ODP_SHM_PROC_NOCREAT);

Same thing here.

-Petri

 +
 + pktio_entry-s.ipc_p = odp_shm_addr(shm);
 + if (!pktio_entry-s.ipc_p) {
 + ODP_DBG(pid %d unable to find ipc ring %s name\n,
 + getpid(), dev);
 + goto error;
 + }
 +
 + pktio_entry-s.type = ODP_PKTIO_TYPE_IPC;
 +
 + /* Get info about remote pool */
 + struct pktio_info *pinfo = lng_map_shm_pool_info(dev,
 + ODP_SHM_PROC_NOCREAT);
 + pktio_entry-s.ipc_pool_base = map_remote_pool(pinfo);
 + pktio_entry-s.ipc_pkt_size = pinfo-shm_pkt_size;
 +
 + /* @todo: to simplify in linux-generic implementation we create pool
 for
 +  * packets from IPC queue. On receive implementation copies packets
 to
 +  * that pool. Later we can try to reuse original tool without
 packets
 +  * copying.
 +  */
 + pktio_entry-s.pkt_sock.pool = lg_odp_alloc_and_create_pool(
 + pinfo-shm_pkt_pool_size, pinfo-shm_pkt_size);
 +
 + ret = 0;
 + ODP_DBG(%s OK.\n, __func__);
 +error:
 + /* @todo free shm on error (api not impemented yet) */
 + return ret;
 +}
 +


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


Re: [lng-odp] [PATCH] API version not dependent on test suite version

2014-11-06 Thread Savolainen, Petri (NSN - FI/Espoo)
Ping. We decided to break the dependency in the call yesterday.

-Petri

 -Original Message-
 From: ext Petri Savolainen [mailto:petri.savolai...@linaro.org]
 Sent: Thursday, October 30, 2014 4:42 PM
 To: lng-odp@lists.linaro.org
 Cc: Petri Savolainen
 Subject: [PATCH] API version not dependent on test suite version
 
 Signed-off-by: Petri Savolainen petri.savolai...@linaro.org
 ---
 
 Notes:
 Test suite code is not part of the API spec. It's written
 against an API version. Test suite development and versioning runs
 in parallel to API versioning. E.g. test suite version 0.3.0-17 may
 be the latest test suite version for API version 0.3.0 and may have
 90% coverage. The next version (0.3.0-18) would improve coverage and
 fix bugs in tests, etc
 
  platform/linux-generic/include/api/odp_version.h | 8 +++-
  1 file changed, 3 insertions(+), 5 deletions(-)
 
 diff --git a/platform/linux-generic/include/api/odp_version.h
 b/platform/linux-generic/include/api/odp_version.h
 index 0e5b8e0..4450452 100644
 --- a/platform/linux-generic/include/api/odp_version.h
 +++ b/platform/linux-generic/include/api/odp_version.h
 @@ -41,12 +41,10 @@ extern C {
 
  /**
   * ODP API minor version
 + *
   * Minor version is incremented when introducing backward compatible
 changes
 - * to the API.
 - * For an API with common generation and major version, but with
 different
 - * minor numbers the two versions are backward compatible.
 - * Changes to the test suite will increment this digit.
 - * Changes to linux-generic will not increment this digit.
 + * to the API. For an API with common generation and major version, but
 with
 + * different minor numbers the two versions are backward compatible.
   */
  #define ODP_VERSION_API_MINOR 0
 
 --
 2.1.1


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


[lng-odp] [Bug 627] Implementation of odp_pktio_get_mac_address API in linux-keystone2 and linux-dpdk platforms

2014-11-06 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=627

--- Comment #5 from Bala Manoharan bala.manoha...@linaro.org ---
The API is under discussion in pktio design doc. 
Would prefer to have the doc as frozen before posting linux generic patch

-- 
You are receiving this mail because:
You are on the CC list for the bug.___
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCHv3] ipc linux-generic implementation based on pktio

2014-11-06 Thread Maxim Uvarov

On 11/06/2014 02:59 PM, Savolainen, Petri (NSN - FI/Espoo) wrote:

+int lg_odp_pktio_lookup(const char *dev, pktio_entry_t *pktio_entry)
+{
+   int ret = -1;
+   char ipc_shm_name[ODPH_RING_NAMESIZE];
+   size_t ring_size;
+
+   if (!(lg_odp_shm_lookup_pktio(dev) == 0 
+ odp_shm_lookup_ipc(shm_packet_pool) == 0)) {
+   ODP_DBG(pid %d unable to find ipc object: %s.\n,
+   getpid(), dev);
+   goto error;
+   }

So, the role of the new odp_shm_lookup_ipc() call is just check if a shm has 
been created. I'm against adding xxx_ipc() versions of existing API calls. You 
should be able to just use the normal lookup. Maybe ODP (global init) needs to 
be informed that application runs in multi-process mode, so that ODP internal 
data structures are mapped so that multiple processes can lookup from those.


It is internal implementation. This look up should be for 2 separate 
processes. Might be _ipc prefix is very confusing here, but it's just 
function to check if there is such shm or not. It can be 
pktio_in_shm(dev) and pool_in_shm(name). Also I need to think how to 
remove this predefined value shm_packet_pool, skipped that on clean up.


Taras also mentioned about such flag to odp_global_init.



If you check e.g. Multi-process Sample Application chapter in DPDK sample 
apps guide. It gives a cleaner framework how to handle the multi-process case.


+
+   ODP_DBG(pid %d odp_shm_lookup_ipc found shared object\n,
+   getpid());
+   ring_size =  PKTIO_IPC_ENTRIES * sizeof(void *) +
+   sizeof(odph_ring_t);
+
+   memset(ipc_shm_name, 0, ODPH_RING_NAMESIZE);
+   memcpy(ipc_shm_name, dev, strlen(dev));
+   memcpy(ipc_shm_name + strlen(dev), _r, 2);
+
+   /* allocate shared memory for buffers needed to be produced */
+   odp_shm_t shm = odp_shm_reserve(ipc_shm_name, ring_size,
+   ODP_CACHE_LINE_SIZE,
+   ODP_SHM_PROC_NOCREAT);

This should be replaced by the normal (multi-process capable) lookup.


Why not to reuse odp_shm_reserve() here? I can put it to separate 
function, no problem or even better just to replace to shm_open() call.
My point is when we will have clean up function for odp_shm_reserve() 
then we can use it for that memory also.





+
+   pktio_entry-s.ipc_r = odp_shm_addr(shm);
+   if (!pktio_entry-s.ipc_r) {
+   ODP_DBG(pid %d unable to find ipc ring %s name\n,
+   getpid(), dev);
+   goto error;
+   }
+
+   memcpy(ipc_shm_name + strlen(dev), _p, 2);
+   /* allocate shared memory for produced ring buffer handlers. That
+* buffers will be cleaned up after they are produced by other
process.
+*/
+   shm = odp_shm_reserve(ipc_shm_name, ring_size,
+   ODP_CACHE_LINE_SIZE,
+   ODP_SHM_PROC_NOCREAT);

Same thing here.

-Petri


+
+   pktio_entry-s.ipc_p = odp_shm_addr(shm);
+   if (!pktio_entry-s.ipc_p) {
+   ODP_DBG(pid %d unable to find ipc ring %s name\n,
+   getpid(), dev);
+   goto error;
+   }
+
+   pktio_entry-s.type = ODP_PKTIO_TYPE_IPC;
+
+   /* Get info about remote pool */
+   struct pktio_info *pinfo = lng_map_shm_pool_info(dev,
+   ODP_SHM_PROC_NOCREAT);
+   pktio_entry-s.ipc_pool_base = map_remote_pool(pinfo);
+   pktio_entry-s.ipc_pkt_size = pinfo-shm_pkt_size;
+
+   /* @todo: to simplify in linux-generic implementation we create pool
for
+* packets from IPC queue. On receive implementation copies packets
to
+* that pool. Later we can try to reuse original tool without
packets
+* copying.
+*/
+   pktio_entry-s.pkt_sock.pool = lg_odp_alloc_and_create_pool(
+   pinfo-shm_pkt_pool_size, pinfo-shm_pkt_size);
+
+   ret = 0;
+   ODP_DBG(%s OK.\n, __func__);
+error:
+   /* @todo free shm on error (api not impemented yet) */
+   return ret;
+}
+



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


Re: [lng-odp] Raw Socket question

2014-11-06 Thread Maxim Uvarov

On 11/06/2014 03:56 PM, Bill Fischofer wrote:
In reworking the packet code, one point I'm not clear on is how the 
linux-generic raw socket I/O model is supposed to deal with segmented 
packets on both receive and transmit paths.


Transmit is presumably more straightforward.  Here's a snippet from 
odp_packet_socket.c (routine


while (i  len) { pkt = pkt_table[i]; frame = odp_packet_l2(pkt); 
frame_len = odp_packet_get_len(pkt); ret = send(sockfd, frame, 
frame_len, flags); if (odp_unlikely(ret == -1)) { if (odp_likely(errno 
== EAGAIN)) { flags = 0; /* blocking for next rounds */ continue; /* 
resend buffer */ } else { break; } } i++; } /* end while */


The current code assumes that it has contiguous addressability to the 
entire packet.  Is that a requirement of the raw socket interface?  If 
not then it would seem this could be replaced by the following more 
general code:


while (i  len) {
pkt = pkt_table[i];

frame_len = odp_packet_len(pkt);
frame_offset = 0;

while (frame_len  0) {
frame = odp_packet_offset_map(pkt,frame_offset,seglen);
if (frame == NULL)
break;
ret = send(sockfd, frame, seg_len, flags);


I think raw sockets expect that packet is in continuous memory. You can 
relay on that on receive but on send you never know how that packet was 
created.
For example app can create segmented packets, segments are in different 
address. In that case you need to copy that data to temporary buffer 
before sending.


 ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
Works with vectors:

   struct msghdr {
   void *msg_name;   /* optional address */
   socklen_t msg_namelen;/* size of address */
   struct iovec *msg_iov;/* scatter/gather array */
   size_tmsg_iovlen; /* # elements in msg_iov */
   void *msg_control;/* ancillary data, see 
below */
   size_tmsg_controllen; /* ancillary data buffer 
len */
   int   msg_flags;  /* flags on received 
message */

   };

But for raw sockets more likely that each entry in vector will be 
separate packet. But it's needed to check if it's so or not.


Maxim.


if (odp_unlikely(ret == -1)) {
if (odp_likely(errno == EAGAIN)) {
flags = 0;/* blocking for next rounds */
continue;/* resend buffer */
} else {
frame_offset += seg_len;
frame_len  -= seg_len;
}
}
}
i++;
}/* end while */

Would this code be functionally correct from a raw socket perspective?

Receive processing has similar issues.  I've not been able to find any 
raw socket examples (via googling) that don't assume they can receive 
an entire packet into a single contiguous buffer. Is that a 
requirement of the interface?


Is there support for scatter/gather lists in these APIs?  If so then 
we may need some additional ODP APIs (possibly internal) to allow the 
segment lists to be manipulated as a whole rather than one-by-one.


Thanks.

Bill


___
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


[lng-odp] [PATCH NETMAP] Removed netmap specific example

2014-11-06 Thread Ciprian Barbu
Signed-off-by: Ciprian Barbu ciprian.ba...@linaro.org
---

This patch removes the packet_netmap example and adds instruction on how to use
the regular packet example but with the added limitation of using a single
thread.

 configure.ac  |   1 -
 example/Makefile.am   |   2 +-
 example/packet_netmap/Makefile.am |   8 -
 example/packet_netmap/odp_pktio_netmap.c  | 587 --
 platform/linux-netmap/README  |  38 +-
 platform/linux-netmap/include/odp_packet_netmap.h |  66 +++
 platform/linux-netmap/odp_packet_netmap.c | 132 ++---
 platform/linux-netmap/odp_packet_netmap.h |  67 ---
 8 files changed, 125 insertions(+), 776 deletions(-)
 delete mode 100644 example/packet_netmap/Makefile.am
 delete mode 100644 example/packet_netmap/odp_pktio_netmap.c
 create mode 100644 platform/linux-netmap/include/odp_packet_netmap.h
 delete mode 100644 platform/linux-netmap/odp_packet_netmap.h

diff --git a/configure.ac b/configure.ac
index a1c68ba..f8ea5a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -157,7 +157,6 @@ AC_CONFIG_FILES([Makefile
 example/l2fwd/Makefile
 example/odp_example/Makefile
 example/packet/Makefile
-example/packet_netmap/Makefile
 example/timer/Makefile
 test/Makefile
 test/api_test/Makefile
diff --git a/example/Makefile.am b/example/Makefile.am
index 72663b9..b2a22a3 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -1 +1 @@
-SUBDIRS = generator ipsec l2fwd odp_example packet packet_netmap timer
+SUBDIRS = generator ipsec l2fwd odp_example packet timer
diff --git a/example/packet_netmap/Makefile.am 
b/example/packet_netmap/Makefile.am
deleted file mode 100644
index 5a5913c..000
--- a/example/packet_netmap/Makefile.am
+++ /dev/null
@@ -1,8 +0,0 @@
-include $(top_srcdir)/example/Makefile.inc
-
-if ODP_NETMAP_ENABLED
-bin_PROGRAMS = odp_pktio_netmap
-odp_pktio_netmap_LDFLAGS = $(AM_LDFLAGS) -static
-endif
-
-dist_odp_pktio_netmap_SOURCES = odp_pktio_netmap.c
diff --git a/example/packet_netmap/odp_pktio_netmap.c 
b/example/packet_netmap/odp_pktio_netmap.c
deleted file mode 100644
index a2756ee..000
--- a/example/packet_netmap/odp_pktio_netmap.c
+++ /dev/null
@@ -1,587 +0,0 @@
-/* Copyright (c) 2013, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-/**
- * @file
- *
- * ODP basic packet IO loopback test application
- */
-
-#include stdlib.h
-#include string.h
-#include stdio.h
-#include getopt.h
-#include unistd.h
-
-#include linux/if_ether.h
-#include linux/ip.h
-#include arpa/inet.h
-
-#include odp.h
-#include odph_linux.h
-#include odph_packet.h
-#include odph_eth.h
-#include odph_ip.h
-#include odph_packet.h
-
-#include odp_pktio_netmap.h
-
-/** @def MAX_WORKERS
- * @brief Maximum number of worker threads
- */
-#define MAX_WORKERS32
-
-/** @def MAX_IFS
- * @brief Maximum number of netmap interfaces
- */
-#define MAX_IFS16
-
-/** @def SHM_PKT_POOL_SIZE
- * @brief Size of the shared memory block
- */
-#define SHM_PKT_POOL_SIZE  (512*2048)
-
-/** @def SHM_PKT_POOL_BUF_SIZE
- * @brief Buffer size of the packet pool buffer
- */
-#define SHM_PKT_POOL_BUF_SIZE  1856
-
-/** @def MAX_PKT_BURST
- * @brief Maximum number of packet bursts
- */
-#define MAX_PKT_BURST  16
-
-/** @def PKTIO_MODE_SOCK
- * @brief PKTIO is set in socket mode
- */
-#define PKTIO_MODE_SOCK0
-
-/** @def PKTIO_MODE_NETMAP
- * @brief PKTIO is set in netmap mode
- */
-#define PKTIO_MODE_NETMAP  1
-
-/** Get rid of path in filename - only for unix-type paths using '/' */
-#define NO_PATH(file_name) (strrchr((file_name), '/') ? \
-   strrchr((file_name), '/') + 1 : (file_name))
-
-/**
- * Interface parameters obatained from app arguments
- */
-typedef struct {
-   char if_name[32];   /** Interface name */
-   int pktio_mode; /** Socket mode or netmap mode */
-} if_info_t;
-
-/**
- * Parsed command line application arguments
- */
-typedef struct {
-   int if_count;   /** Number of interfaces to be used */
-   if_info_t *ifs; /** Array of interface config options */
-   odp_buffer_pool_t pool; /** Buffer pool for packet IO */
-} appl_args_t;
-
-/**
- * Thread specific arguments
- * In this netmap example, there is a thread polling a network interface
- * and another thread polling the ring that is used by the software stack
- * to send packets to the same network interface. Each of the two threads
- * needs to know which is the output queue corresponding to the other thread
- * to be able to pass packets between the stack and the nic. This queue is
- * defined by bridge_q below.
- */
-typedef struct {
-   odp_pktio_t pktio;  /** ODP packet IO handler */
-   odp_buffer_pool_t pool; /** Buffer 

[lng-odp] [PATCHv2 NETMAP] Removed netmap specific example

2014-11-06 Thread Ciprian Barbu
Signed-off-by: Ciprian Barbu ciprian.ba...@linaro.org
---
v2: Using git format-patch -M to mark that odp_packet_netmap.h was moved

 configure.ac   |   1 -
 example/Makefile.am|   2 +-
 example/packet_netmap/Makefile.am  |   8 -
 example/packet_netmap/odp_pktio_netmap.c   | 587 -
 platform/linux-netmap/README   |  38 +-
 .../linux-netmap/{ = include}/odp_packet_netmap.h |   1 -
 platform/linux-netmap/odp_packet_netmap.c  | 132 ++---
 7 files changed, 59 insertions(+), 710 deletions(-)
 delete mode 100644 example/packet_netmap/Makefile.am
 delete mode 100644 example/packet_netmap/odp_pktio_netmap.c
 rename platform/linux-netmap/{ = include}/odp_packet_netmap.h (98%)

diff --git a/configure.ac b/configure.ac
index a1c68ba..f8ea5a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -157,7 +157,6 @@ AC_CONFIG_FILES([Makefile
 example/l2fwd/Makefile
 example/odp_example/Makefile
 example/packet/Makefile
-example/packet_netmap/Makefile
 example/timer/Makefile
 test/Makefile
 test/api_test/Makefile
diff --git a/example/Makefile.am b/example/Makefile.am
index 72663b9..b2a22a3 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -1 +1 @@
-SUBDIRS = generator ipsec l2fwd odp_example packet packet_netmap timer
+SUBDIRS = generator ipsec l2fwd odp_example packet timer
diff --git a/example/packet_netmap/Makefile.am 
b/example/packet_netmap/Makefile.am
deleted file mode 100644
index 5a5913c..000
--- a/example/packet_netmap/Makefile.am
+++ /dev/null
@@ -1,8 +0,0 @@
-include $(top_srcdir)/example/Makefile.inc
-
-if ODP_NETMAP_ENABLED
-bin_PROGRAMS = odp_pktio_netmap
-odp_pktio_netmap_LDFLAGS = $(AM_LDFLAGS) -static
-endif
-
-dist_odp_pktio_netmap_SOURCES = odp_pktio_netmap.c
diff --git a/example/packet_netmap/odp_pktio_netmap.c 
b/example/packet_netmap/odp_pktio_netmap.c
deleted file mode 100644
index a2756ee..000
--- a/example/packet_netmap/odp_pktio_netmap.c
+++ /dev/null
@@ -1,587 +0,0 @@
-/* Copyright (c) 2013, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-/**
- * @file
- *
- * ODP basic packet IO loopback test application
- */
-
-#include stdlib.h
-#include string.h
-#include stdio.h
-#include getopt.h
-#include unistd.h
-
-#include linux/if_ether.h
-#include linux/ip.h
-#include arpa/inet.h
-
-#include odp.h
-#include odph_linux.h
-#include odph_packet.h
-#include odph_eth.h
-#include odph_ip.h
-#include odph_packet.h
-
-#include odp_pktio_netmap.h
-
-/** @def MAX_WORKERS
- * @brief Maximum number of worker threads
- */
-#define MAX_WORKERS32
-
-/** @def MAX_IFS
- * @brief Maximum number of netmap interfaces
- */
-#define MAX_IFS16
-
-/** @def SHM_PKT_POOL_SIZE
- * @brief Size of the shared memory block
- */
-#define SHM_PKT_POOL_SIZE  (512*2048)
-
-/** @def SHM_PKT_POOL_BUF_SIZE
- * @brief Buffer size of the packet pool buffer
- */
-#define SHM_PKT_POOL_BUF_SIZE  1856
-
-/** @def MAX_PKT_BURST
- * @brief Maximum number of packet bursts
- */
-#define MAX_PKT_BURST  16
-
-/** @def PKTIO_MODE_SOCK
- * @brief PKTIO is set in socket mode
- */
-#define PKTIO_MODE_SOCK0
-
-/** @def PKTIO_MODE_NETMAP
- * @brief PKTIO is set in netmap mode
- */
-#define PKTIO_MODE_NETMAP  1
-
-/** Get rid of path in filename - only for unix-type paths using '/' */
-#define NO_PATH(file_name) (strrchr((file_name), '/') ? \
-   strrchr((file_name), '/') + 1 : (file_name))
-
-/**
- * Interface parameters obatained from app arguments
- */
-typedef struct {
-   char if_name[32];   /** Interface name */
-   int pktio_mode; /** Socket mode or netmap mode */
-} if_info_t;
-
-/**
- * Parsed command line application arguments
- */
-typedef struct {
-   int if_count;   /** Number of interfaces to be used */
-   if_info_t *ifs; /** Array of interface config options */
-   odp_buffer_pool_t pool; /** Buffer pool for packet IO */
-} appl_args_t;
-
-/**
- * Thread specific arguments
- * In this netmap example, there is a thread polling a network interface
- * and another thread polling the ring that is used by the software stack
- * to send packets to the same network interface. Each of the two threads
- * needs to know which is the output queue corresponding to the other thread
- * to be able to pass packets between the stack and the nic. This queue is
- * defined by bridge_q below.
- */
-typedef struct {
-   odp_pktio_t pktio;  /** ODP packet IO handler */
-   odp_buffer_pool_t pool; /** Buffer pool for packet IO */
-   char *pktio_dev;/** Interface name to use */
-   int netmap_mode;/** Either poll the hardware rings or the
-rings associated with 

[lng-odp] [PATCH v5] add queue test

2014-11-06 Thread Yan Songming
From: yan.songming yan.songm...@linaro.org

Add the cunit test for none syne queue. Test the base queue function

Signed-off-by: yan.songming yan.songm...@linaro.org
---
Fix spelling problem and commend problem. Add term_local and term_global.
Move cunit queue test to test_odp_queue_base for none syn queue.
---
 test/cunit/Makefile.am  |   8 ++-
 test/cunit/odp_queue_test.c | 158 
 2 files changed, 163 insertions(+), 3 deletions(-)
 create mode 100644 test/cunit/odp_queue_test.c

diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am
index 927a5a5..74a0deb 100644
--- a/test/cunit/Makefile.am
+++ b/test/cunit/Makefile.am
@@ -1,13 +1,15 @@
 include $(top_srcdir)/test/Makefile.inc
 
 AM_CFLAGS += -I$(CUNIT_PATH)/include
-AM_LDFLAGS += -L$(CUNIT_PATH)/lib
+AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
 
 if ODP_CUNIT_ENABLED
 TESTS = ${bin_PROGRAMS}
 check_PROGRAMS = ${bin_PROGRAMS}
-bin_PROGRAMS = odp_init
-odp_init_LDFLAGS = $(AM_LDFLAGS) -static -lcunit
+bin_PROGRAMS = odp_init odp_queue
+odp_init_LDFLAGS = $(AM_LDFLAGS)
+odp_queue_LDFLAGS = $(AM_LDFLAGS)
 endif
 
 dist_odp_init_SOURCES = odp_init_test.c
+dist_odp_queue_SOURCES = odp_queue_test.c
diff --git a/test/cunit/odp_queue_test.c b/test/cunit/odp_queue_test.c
new file mode 100644
index 000..63e5d56
--- /dev/null
+++ b/test/cunit/odp_queue_test.c
@@ -0,0 +1,158 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include odp.h
+#include CUnit/Basic.h
+
+#define MAX_BUFFER_QUEUE(8)
+#define MSG_POOL_SIZE   (4*1024*1024)
+
+static int queue_contest = 0xff;
+
+static int test_odp_buffer_pool_init(void)
+{
+   odp_buffer_pool_t pool;
+   void *pool_base;
+   odp_shm_t shm;
+
+   shm = odp_shm_reserve(msg_pool,
+ MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
+
+   pool_base = odp_shm_addr(shm);
+
+   if (NULL == pool_base) {
+   printf(Shared memory reserve failed.\n);
+   return -1;
+   }
+
+   pool = odp_buffer_pool_create(msg_pool, pool_base, MSG_POOL_SIZE, 0,
+ ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW);
+
+   if (ODP_BUFFER_POOL_INVALID == pool) {
+   printf(Pool create failed.\n);
+   return -1;
+   }
+   return 0;
+}
+
+static void test_odp_queue_base(void)
+{
+   odp_queue_t queue_creat_id;
+   odp_queue_t queue_id;
+   odp_buffer_t enbuf[MAX_BUFFER_QUEUE];
+   odp_buffer_t debuf[MAX_BUFFER_QUEUE];
+   odp_buffer_pool_t msg_pool;
+   odp_queue_param_t param;
+
+   int i;
+   odp_buffer_t buf;
+   void *prtn = NULL;
+
+   memset(param, 0, sizeof(param));
+   param.sched.sync  = ODP_SCHED_SYNC_NONE;
+
+   queue_creat_id = odp_queue_create(test_queue,
+ ODP_QUEUE_TYPE_POLL, param);
+   CU_ASSERT(ODP_QUEUE_INVALID != queue_creat_id);
+
+   CU_ASSERT_EQUAL(ODP_QUEUE_TYPE_POLL,
+   odp_queue_type(queue_creat_id));
+   CU_ASSERT_EQUAL(ODP_SCHED_SYNC_NONE,
+   odp_queue_sched_type(queue_creat_id));
+
+   /* test odp_queue_lookup */
+   queue_id = odp_queue_lookup(test_queue);
+   CU_ASSERT_EQUAL(queue_creat_id, queue_id);
+
+   /* test odp_queue_set_context */
+   CU_ASSERT(0 == odp_queue_set_context(queue_id, queue_contest));
+
+   /* test odp_queue_get_context*/
+   prtn = odp_queue_get_context(queue_id);
+   CU_ASSERT(queue_contest == (int *)prtn);
+
+   /* apply for buffer */
+   msg_pool = odp_buffer_pool_lookup(msg_pool);
+   buf = odp_buffer_alloc(msg_pool);
+
+   /* test odp_queue_deq and odp_queue_deq */
+   odp_queue_enq(queue_id, buf);
+   CU_ASSERT_EQUAL(buf, odp_queue_deq(queue_id));
+   odp_buffer_free(buf);
+
+   /* apply for mutili buffer */
+   for (i = 0; i  MAX_BUFFER_QUEUE; i++)
+   enbuf[i] = odp_buffer_alloc(msg_pool);
+
+   /* test odp_queue_enq_multi and odp_queue_enq_multi */
+   odp_queue_enq_multi(queue_id, enbuf, MAX_BUFFER_QUEUE);
+   CU_ASSERT_EQUAL(MAX_BUFFER_QUEUE,
+   odp_queue_deq_multi(queue_id, debuf, MAX_BUFFER_QUEUE));
+
+   for (i = 0; i  MAX_BUFFER_QUEUE; i++) {
+   /* test odp_queue_deq_multi */
+   CU_ASSERT_EQUAL(enbuf[i], debuf[i]);
+   odp_buffer_free(enbuf[i]);
+   }
+   return;
+}
+
+static void test_odp_queue(void)
+{
+   int status;
+   status = odp_init_global(NULL, NULL);
+   CU_ASSERT_FATAL(0 == status);
+
+   CU_ASSERT(0 == odp_init_local())
+
+   CU_ASSERT_FATAL(0 == test_odp_buffer_pool_init());
+
+   test_odp_queue_base();
+
+   status = odp_term_local();
+   CU_ASSERT(0 == status);
+
+   status = odp_term_global();
+   CU_ASSERT(0 == status);
+   return;
+}
+
+static 

[lng-odp] [Bug 787] odp_shared_memory.c i snot std=c99 compliant

2014-11-06 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=787

Mike Holmes mike.hol...@linaro.org changed:

   What|Removed |Added

   Assignee|mike.hol...@linaro.org  |lng-odp@lists.linaro.org

-- 
You are receiving this mail because:
You are the assignee for the bug.___
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [Bug 290] Linux-generic cannot compile with clang

2014-11-06 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=290

Mike Holmes mike.hol...@linaro.org changed:

   What|Removed |Added

   Assignee|petri.savolai...@linaro.org |lng-odp@lists.linaro.org

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.___
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v5] add queue test

2014-11-06 Thread Anders Roxell
On 2014-11-06 23:08, Yan Songming wrote:
 From: yan.songming yan.songm...@linaro.org
 
 Add the cunit test for none syne queue. Test the base queue function
 
 Signed-off-by: yan.songming yan.songm...@linaro.org
 ---
 Fix spelling problem and commend problem. Add term_local and term_global.
 Move cunit queue test to test_odp_queue_base for none syn queue.
 ---
  test/cunit/Makefile.am  |   8 ++-
  test/cunit/odp_queue_test.c | 158 
 
  2 files changed, 163 insertions(+), 3 deletions(-)
  create mode 100644 test/cunit/odp_queue_test.c
 
 diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am
 index 927a5a5..74a0deb 100644
 --- a/test/cunit/Makefile.am
 +++ b/test/cunit/Makefile.am
 @@ -1,13 +1,15 @@
  include $(top_srcdir)/test/Makefile.inc
  
  AM_CFLAGS += -I$(CUNIT_PATH)/include
 -AM_LDFLAGS += -L$(CUNIT_PATH)/lib
 +AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
  
  if ODP_CUNIT_ENABLED
  TESTS = ${bin_PROGRAMS}
  check_PROGRAMS = ${bin_PROGRAMS}
 -bin_PROGRAMS = odp_init
 -odp_init_LDFLAGS = $(AM_LDFLAGS) -static -lcunit
 +bin_PROGRAMS = odp_init odp_queue
 +odp_init_LDFLAGS = $(AM_LDFLAGS)
 +odp_queue_LDFLAGS = $(AM_LDFLAGS)
  endif
  
  dist_odp_init_SOURCES = odp_init_test.c
 +dist_odp_queue_SOURCES = odp_queue_test.c
 diff --git a/test/cunit/odp_queue_test.c b/test/cunit/odp_queue_test.c
 new file mode 100644
 index 000..63e5d56
 --- /dev/null
 +++ b/test/cunit/odp_queue_test.c
 @@ -0,0 +1,158 @@
 +/* Copyright (c) 2014, Linaro Limited
 + * All rights reserved.
 + *
 + * SPDX-License-Identifier: BSD-3-Clause
 + */
 +
 +#include odp.h
 +#include CUnit/Basic.h
 +
 +#define MAX_BUFFER_QUEUE(8)
 +#define MSG_POOL_SIZE   (4*1024*1024)
 +
 +static int queue_contest = 0xff;
 +
 +static int test_odp_buffer_pool_init(void)
 +{
 + odp_buffer_pool_t pool;
 + void *pool_base;
 + odp_shm_t shm;
 +
 + shm = odp_shm_reserve(msg_pool,
 +   MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
 +
 + pool_base = odp_shm_addr(shm);
 +
 + if (NULL == pool_base) {
 + printf(Shared memory reserve failed.\n);
 + return -1;
 + }
 +
 + pool = odp_buffer_pool_create(msg_pool, pool_base, MSG_POOL_SIZE, 0,
 +   ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW);
 +
 + if (ODP_BUFFER_POOL_INVALID == pool) {
 + printf(Pool create failed.\n);
 + return -1;
 + }
 + return 0;
 +}
 +
 +static void test_odp_queue_base(void)
 +{
 + odp_queue_t queue_creat_id;
 + odp_queue_t queue_id;
 + odp_buffer_t enbuf[MAX_BUFFER_QUEUE];
 + odp_buffer_t debuf[MAX_BUFFER_QUEUE];
 + odp_buffer_pool_t msg_pool;
 + odp_queue_param_t param;
 +
 + int i;
 + odp_buffer_t buf;
 + void *prtn = NULL;
 +
 + memset(param, 0, sizeof(param));
 + param.sched.sync  = ODP_SCHED_SYNC_NONE;
 +
 + queue_creat_id = odp_queue_create(test_queue,
 +   ODP_QUEUE_TYPE_POLL, param);
 + CU_ASSERT(ODP_QUEUE_INVALID != queue_creat_id);
 +
 + CU_ASSERT_EQUAL(ODP_QUEUE_TYPE_POLL,
 + odp_queue_type(queue_creat_id));
 + CU_ASSERT_EQUAL(ODP_SCHED_SYNC_NONE,
 + odp_queue_sched_type(queue_creat_id));
 +
 + /* test odp_queue_lookup */

Make comments valuable or remove them.

The same goes for all comments.

 + queue_id = odp_queue_lookup(test_queue);
 + CU_ASSERT_EQUAL(queue_creat_id, queue_id);
 +
 + /* test odp_queue_set_context */
 + CU_ASSERT(0 == odp_queue_set_context(queue_id, queue_contest));
 +
 + /* test odp_queue_get_context*/
 + prtn = odp_queue_get_context(queue_id);
 + CU_ASSERT(queue_contest == (int *)prtn);
 +
 + /* apply for buffer */
 + msg_pool = odp_buffer_pool_lookup(msg_pool);
 + buf = odp_buffer_alloc(msg_pool);
 +
 + /* test odp_queue_deq and odp_queue_deq */
 + odp_queue_enq(queue_id, buf);
 + CU_ASSERT_EQUAL(buf, odp_queue_deq(queue_id));
 + odp_buffer_free(buf);
 +
 + /* apply for mutili buffer */
 + for (i = 0; i  MAX_BUFFER_QUEUE; i++)
 + enbuf[i] = odp_buffer_alloc(msg_pool);
 +
 + /* test odp_queue_enq_multi and odp_queue_enq_multi */
 + odp_queue_enq_multi(queue_id, enbuf, MAX_BUFFER_QUEUE);
 + CU_ASSERT_EQUAL(MAX_BUFFER_QUEUE,
 + odp_queue_deq_multi(queue_id, debuf, MAX_BUFFER_QUEUE));
 +
 + for (i = 0; i  MAX_BUFFER_QUEUE; i++) {
 + /* test odp_queue_deq_multi */
 + CU_ASSERT_EQUAL(enbuf[i], debuf[i]);
 + odp_buffer_free(enbuf[i]);
 + }
 + return;
 +}
 +
 +static void test_odp_queue(void)

The name of this test is displayed when CUnit runs, so it needs to make
sense what it tests, e.g., test_odp_queue_sunnyday


Cheers,
Anders

 +{
 + int status;
 + status = odp_init_global(NULL, NULL);
 + CU_ASSERT_FATAL(0 == status);
 +
 + CU_ASSERT(0 == 

Re: [lng-odp] [PATCH] API version not dependent on test suite version

2014-11-06 Thread Mike Holmes
On 6 November 2014 10:14, Stuart Haslam stuart.has...@arm.com wrote:

 On Thu, Nov 06, 2014 at 12:27:02PM +, Savolainen, Petri (NSN -
 FI/Espoo) wrote:
  Ping. We decided to break the dependency in the call yesterday.
 
  -Petri

 I agree test suite versioning should be independent and there's no need
 to specify what *isn't* covered by the version here as the _API_ naming
 makes it clear it covers the API.

 
   -Original Message-
   From: ext Petri Savolainen [mailto:petri.savolai...@linaro.org]
   Sent: Thursday, October 30, 2014 4:42 PM
   To: lng-odp@lists.linaro.org
   Cc: Petri Savolainen
   Subject: [PATCH] API version not dependent on test suite version
  
   Signed-off-by: Petri Savolainen petri.savolai...@linaro.org

 Reviewed-by: Stuart Haslam stuart.has...@arm.com

Reviewed-by: Mike Holmes mike.hol...@linaro.org


   ---
  
   Notes:
   Test suite code is not part of the API spec. It's written
   against an API version. Test suite development and versioning runs
   in parallel to API versioning. E.g. test suite version 0.3.0-17 may
   be the latest test suite version for API version 0.3.0 and may have
   90% coverage. The next version (0.3.0-18) would improve coverage
 and
   fix bugs in tests, etc
  
platform/linux-generic/include/api/odp_version.h | 8 +++-
1 file changed, 3 insertions(+), 5 deletions(-)
  
   diff --git a/platform/linux-generic/include/api/odp_version.h
   b/platform/linux-generic/include/api/odp_version.h
   index 0e5b8e0..4450452 100644
   --- a/platform/linux-generic/include/api/odp_version.h
   +++ b/platform/linux-generic/include/api/odp_version.h
   @@ -41,12 +41,10 @@ extern C {
  
/**
 * ODP API minor version
   + *
 * Minor version is incremented when introducing backward compatible
   changes
   - * to the API.
   - * For an API with common generation and major version, but with
   different
   - * minor numbers the two versions are backward compatible.
   - * Changes to the test suite will increment this digit.
   - * Changes to linux-generic will not increment this digit.
   + * to the API. For an API with common generation and major version,
 but
   with
   + * different minor numbers the two versions are backward compatible.
 */
#define ODP_VERSION_API_MINOR 0
  
   --
   2.1.1
 

 --
 Stuart.


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




-- 
*Mike Holmes*
Linaro  Sr Technical Manager
LNG - ODP
___
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH] API version not dependent on test suite version

2014-11-06 Thread Maxim Uvarov

Merged!

Maxim.

On 10/30/2014 05:41 PM, Petri Savolainen wrote:

Signed-off-by: Petri Savolainen petri.savolai...@linaro.org
---

Notes:
 Test suite code is not part of the API spec. It's written
 against an API version. Test suite development and versioning runs
 in parallel to API versioning. E.g. test suite version 0.3.0-17 may
 be the latest test suite version for API version 0.3.0 and may have
 90% coverage. The next version (0.3.0-18) would improve coverage and
 fix bugs in tests, etc

  platform/linux-generic/include/api/odp_version.h | 8 +++-
  1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_version.h 
b/platform/linux-generic/include/api/odp_version.h
index 0e5b8e0..4450452 100644
--- a/platform/linux-generic/include/api/odp_version.h
+++ b/platform/linux-generic/include/api/odp_version.h
@@ -41,12 +41,10 @@ extern C {
  
  /**

   * ODP API minor version
+ *
   * Minor version is incremented when introducing backward compatible changes
- * to the API.
- * For an API with common generation and major version, but with different
- * minor numbers the two versions are backward compatible.
- * Changes to the test suite will increment this digit.
- * Changes to linux-generic will not increment this digit.
+ * to the API. For an API with common generation and major version, but with
+ * different minor numbers the two versions are backward compatible.
   */
  #define ODP_VERSION_API_MINOR 0
  



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


Re: [lng-odp] [PATCH v2 1/1] cunit : add tests for crypto APIs

2014-11-06 Thread Maxim Uvarov

Please review / test this patch.

Maxim.

On 11/05/2014 12:00 PM, alexandru.badici...@linaro.org wrote:

From: Alexandru Badicioiu alexandru.badici...@linaro.org

This patch adds a suite for sync and async inplace mode of crypto APIs.
Correctness of crypto operation output is verified with known test
vectors. Various options and functionalities like use session IV
or operation IV for ciphering are exercised for both modes.
For async mode there are options to use input packet buffer or a
separate buffer as the completion event and to set and retrieve the
context associated with an operation from the completion event.

Signed-off-by: Alexandru Badicioiu alexandru.badici...@linaro.org
---
  configure.ac  |1 +
  test/cunit/Makefile.am|2 +
  test/cunit/crypto/Makefile.am |   10 +
  test/cunit/crypto/odp_crypto_test.c   |  114 
  test/cunit/crypto/odp_crypto_test_async_inp.c |  371 +
  test/cunit/crypto/odp_crypto_test_async_inp.h |   17 ++
  test/cunit/crypto/odp_crypto_test_sync_inp.c  |  260 +
  test/cunit/crypto/odp_crypto_test_sync_inp.h  |   17 ++
  test/cunit/crypto/test_vectors.h  |   94 +++
  9 files changed, 886 insertions(+), 0 deletions(-)
  create mode 100644 test/cunit/crypto/Makefile.am
  create mode 100644 test/cunit/crypto/odp_crypto_test.c
  create mode 100644 test/cunit/crypto/odp_crypto_test_async_inp.c
  create mode 100644 test/cunit/crypto/odp_crypto_test_async_inp.h
  create mode 100644 test/cunit/crypto/odp_crypto_test_sync_inp.c
  create mode 100644 test/cunit/crypto/odp_crypto_test_sync_inp.h
  create mode 100644 test/cunit/crypto/test_vectors.h

diff --git a/configure.ac b/configure.ac
index 1c061e9..298d50b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -177,6 +177,7 @@ AC_CONFIG_FILES([Makefile
 test/Makefile
 test/api_test/Makefile
   test/cunit/Makefile
+test/cunit/crypto/Makefile
 pkgconfig/libodp.pc])
  
  AC_SEARCH_LIBS([timer_create],[rt posix4])

diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am
index 927a5a5..7611145 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
  
+SUBDIRS = crypto

+
  if ODP_CUNIT_ENABLED
  TESTS = ${bin_PROGRAMS}
  check_PROGRAMS = ${bin_PROGRAMS}
diff --git a/test/cunit/crypto/Makefile.am b/test/cunit/crypto/Makefile.am
new file mode 100644
index 000..0eb06df
--- /dev/null
+++ b/test/cunit/crypto/Makefile.am
@@ -0,0 +1,10 @@
+include $(top_srcdir)/test/Makefile.inc
+
+if ODP_CUNIT_ENABLED
+bin_PROGRAMS = odp_crypto
+odp_crypto_LDFLAGS = $(AM_LDFLAGS) -static -lcunit
+endif
+
+dist_odp_crypto_SOURCES = odp_crypto_test_async_inp.c \
+ odp_crypto_test_sync_inp.c \
+ odp_crypto_test.c
diff --git a/test/cunit/crypto/odp_crypto_test.c 
b/test/cunit/crypto/odp_crypto_test.c
new file mode 100644
index 000..dbf245a
--- /dev/null
+++ b/test/cunit/crypto/odp_crypto_test.c
@@ -0,0 +1,114 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:BSD-3-Clause
+ */
+
+#include odp.h
+#include CUnit/Headers/Basic.h
+#include CUnit/Headers/TestDB.h
+#include odp_crypto_test_async_inp.h
+#include odp_crypto_test_sync_inp.h
+
+#define SHM_PKT_POOL_SIZE  (512*2048*2)
+#define SHM_PKT_POOL_BUF_SIZE  (1024 * 32)
+
+#define SHM_COMPL_POOL_SIZE(128*1024)
+#define SHM_COMPL_POOL_BUF_SIZE 128
+
+
+/* Suites init/finalize funcs */
+/* ODP global/local initialization
+ * Packet/Completion event pool creation
+ * Crypto output queue creation
+*/
+
+static int init(void)
+{
+   odp_shm_t shm;
+   void *pool_base = NULL;
+   odp_buffer_pool_t pool;
+   odp_queue_t out_queue;
+
+   if (odp_init_global(NULL, NULL)) {
+   ODP_ERR(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);
+
+   pool_base = odp_shm_addr(shm);
+   if (!pool_base) {
+   ODP_ERR(Packet pool allocation failed.\n);
+   return -1;
+   }
+
+   pool = odp_buffer_pool_create(packet_pool, pool_base,
+ SHM_PKT_POOL_SIZE,
+ SHM_PKT_POOL_BUF_SIZE,
+ ODP_CACHE_LINE_SIZE,
+ ODP_BUFFER_TYPE_PACKET);
+   if (pool == ODP_BUFFER_POOL_INVALID) {
+   ODP_ERR(Packet pool creation failed.\n);
+   /* TODO - cleanup */
+   return -1;
+   }
+   out_queue = odp_queue_create(crypto-out,
+   

Re: [lng-odp] [PATCH v2 1/1] cunit : add tests for crypto APIs

2014-11-06 Thread Mike Holmes
Alex and I are discussing things off list, I hope to add reviewed-by

On 6 November 2014 13:59, Maxim Uvarov maxim.uva...@linaro.org wrote:

 Please review / test this patch.

 Maxim.


 On 11/05/2014 12:00 PM, alexandru.badici...@linaro.org wrote:

 From: Alexandru Badicioiu alexandru.badici...@linaro.org

 This patch adds a suite for sync and async inplace mode of crypto APIs.
 Correctness of crypto operation output is verified with known test
 vectors. Various options and functionalities like use session IV
 or operation IV for ciphering are exercised for both modes.
 For async mode there are options to use input packet buffer or a
 separate buffer as the completion event and to set and retrieve the
 context associated with an operation from the completion event.

 Signed-off-by: Alexandru Badicioiu alexandru.badici...@linaro.org
 ---
   configure.ac  |1 +
   test/cunit/Makefile.am|2 +
   test/cunit/crypto/Makefile.am |   10 +
   test/cunit/crypto/odp_crypto_test.c   |  114 
   test/cunit/crypto/odp_crypto_test_async_inp.c |  371
 +
   test/cunit/crypto/odp_crypto_test_async_inp.h |   17 ++
   test/cunit/crypto/odp_crypto_test_sync_inp.c  |  260 +
   test/cunit/crypto/odp_crypto_test_sync_inp.h  |   17 ++
   test/cunit/crypto/test_vectors.h  |   94 +++
   9 files changed, 886 insertions(+), 0 deletions(-)
   create mode 100644 test/cunit/crypto/Makefile.am
   create mode 100644 test/cunit/crypto/odp_crypto_test.c
   create mode 100644 test/cunit/crypto/odp_crypto_test_async_inp.c
   create mode 100644 test/cunit/crypto/odp_crypto_test_async_inp.h
   create mode 100644 test/cunit/crypto/odp_crypto_test_sync_inp.c
   create mode 100644 test/cunit/crypto/odp_crypto_test_sync_inp.h
   create mode 100644 test/cunit/crypto/test_vectors.h

 diff --git a/configure.ac b/configure.ac
 index 1c061e9..298d50b 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -177,6 +177,7 @@ AC_CONFIG_FILES([Makefile
  test/Makefile
  test/api_test/Makefile
test/cunit/Makefile
 +test/cunit/crypto/Makefile
  pkgconfig/libodp.pc])
 AC_SEARCH_LIBS([timer_create],[rt posix4])
 diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am
 index 927a5a5..7611145 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
   +SUBDIRS = crypto
 +
   if ODP_CUNIT_ENABLED
   TESTS = ${bin_PROGRAMS}
   check_PROGRAMS = ${bin_PROGRAMS}
 diff --git a/test/cunit/crypto/Makefile.am b/test/cunit/crypto/Makefile.
 am
 new file mode 100644
 index 000..0eb06df
 --- /dev/null
 +++ b/test/cunit/crypto/Makefile.am
 @@ -0,0 +1,10 @@
 +include $(top_srcdir)/test/Makefile.inc
 +
 +if ODP_CUNIT_ENABLED
 +bin_PROGRAMS = odp_crypto
 +odp_crypto_LDFLAGS = $(AM_LDFLAGS) -static -lcunit
 +endif
 +
 +dist_odp_crypto_SOURCES = odp_crypto_test_async_inp.c \
 + odp_crypto_test_sync_inp.c \
 + odp_crypto_test.c
 diff --git a/test/cunit/crypto/odp_crypto_test.c b/test/cunit/crypto/odp_
 crypto_test.c
 new file mode 100644
 index 000..dbf245a
 --- /dev/null
 +++ b/test/cunit/crypto/odp_crypto_test.c
 @@ -0,0 +1,114 @@
 +/* Copyright (c) 2014, Linaro Limited
 + * All rights reserved.
 + *
 + * SPDX-License-Identifier:BSD-3-Clause
 + */
 +
 +#include odp.h
 +#include CUnit/Headers/Basic.h
 +#include CUnit/Headers/TestDB.h
 +#include odp_crypto_test_async_inp.h
 +#include odp_crypto_test_sync_inp.h
 +
 +#define SHM_PKT_POOL_SIZE  (512*2048*2)
 +#define SHM_PKT_POOL_BUF_SIZE  (1024 * 32)
 +
 +#define SHM_COMPL_POOL_SIZE(128*1024)
 +#define SHM_COMPL_POOL_BUF_SIZE 128
 +
 +
 +/* Suites init/finalize funcs */
 +/* ODP global/local initialization
 + * Packet/Completion event pool creation
 + * Crypto output queue creation
 +*/
 +
 +static int init(void)
 +{
 +   odp_shm_t shm;
 +   void *pool_base = NULL;
 +   odp_buffer_pool_t pool;
 +   odp_queue_t out_queue;
 +
 +   if (odp_init_global(NULL, NULL)) {
 +   ODP_ERR(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);
 +
 +   pool_base = odp_shm_addr(shm);
 +   if (!pool_base) {
 +   ODP_ERR(Packet pool allocation failed.\n);
 +   return -1;
 +   }
 +
 +   pool = odp_buffer_pool_create(packet_pool, pool_base,
 + SHM_PKT_POOL_SIZE,
 + SHM_PKT_POOL_BUF_SIZE,
 + ODP_CACHE_LINE_SIZE,
 +

Re: [lng-odp] [PATCH] example: Remove use of ODP API logging

2014-11-06 Thread Maxim Uvarov

Looks reasonable.
ACK.

Can merge it if no objections.

Maxim.

On 11/06/2014 12:30 AM, Mike Holmes wrote:

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
  example/example_debug.h   | 88 +++
  example/generator/Makefile.am |  1 +
  example/generator/odp_generator.c | 44 +++-
  example/ipsec/Makefile.am |  1 +
  example/ipsec/odp_ipsec.c | 47 -
  example/ipsec/odp_ipsec_cache.c   |  4 +-
  example/ipsec/odp_ipsec_fwd_db.c  |  4 +-
  example/ipsec/odp_ipsec_loop_db.c |  4 +-
  example/ipsec/odp_ipsec_sa_db.c   |  4 +-
  example/ipsec/odp_ipsec_sp_db.c   |  4 +-
  example/ipsec/odp_ipsec_stream.c  |  9 ++--
  example/l2fwd/Makefile.am |  1 +
  example/l2fwd/odp_l2fwd.c | 47 +++--
  example/odp_example/Makefile.am   |  1 +
  example/odp_example/odp_example.c | 75 +
  example/packet/Makefile.am|  1 +
  example/packet/odp_pktio.c| 34 ---
  example/timer/Makefile.am |  1 +
  example/timer/odp_timer_test.c| 22 +-
  19 files changed, 262 insertions(+), 130 deletions(-)
  create mode 100644 example/example_debug.h

diff --git a/example/example_debug.h b/example/example_debug.h
new file mode 100644
index 000..b83667c
--- /dev/null
+++ b/example/example_debug.h
@@ -0,0 +1,88 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+/**
+ * @file
+ *
+ * example debug
+ */
+
+#ifndef EXAMPLE_DEBUG_H_
+#define EXAMPLE_DEBUG_H_
+
+#include stdio.h
+#include stdlib.h
+
+#ifdef __cplusplus
+extern C {
+#endif
+
+#ifndef EXAMPLE_DEBUG_PRINT
+#define EXAMPLE_DEBUG_PRINT 1
+#endif
+
+/**
+ * log level.
+ */
+typedef enum example_log_level {
+   EXAMPLE_LOG_DBG,
+   EXAMPLE_LOG_ERR,
+   EXAMPLE_LOG_ABORT
+} example_log_level_e;
+
+/**
+ * default LOG macro.
+ */
+#define EXAMPLE_LOG(level, fmt, ...) \
+do { \
+   switch (level) { \
+   case EXAMPLE_LOG_ERR: \
+   fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
+   __LINE__, __func__, ##__VA_ARGS__); \
+   break; \
+   case EXAMPLE_LOG_DBG: \
+   if (EXAMPLE_DEBUG_PRINT == 1) \
+   fprintf(stderr, %s:%d:%s(): fmt, __FILE__, \
+   __LINE__, __func__, ##__VA_ARGS__); \
+   break; \
+   case EXAMPLE_LOG_ABORT: \
+   fprintf(stderr, %s:%d:%s():  fmt, __FILE__, \
+   __LINE__, __func__, ##__VA_ARGS__); \
+   abort(); \
+   break; \
+   default: \
+   fprintf(stderr, Unknown LOG level); \
+   break;\
+   } \
+} while (0)
+
+/**
+ * Debug printing macro, which prints output when DEBUG flag is set.
+ */
+#define EXAMPLE_DBG(fmt, ...) \
+   EXAMPLE_LOG(EXAMPLE_LOG_DBG, fmt, ##__VA_ARGS__)
+
+/**
+ * Print output to stderr (file, line and function).
+ */
+#define EXAMPLE_ERR(fmt, ...) \
+   EXAMPLE_LOG(EXAMPLE_LOG_ERR, fmt, ##__VA_ARGS__)
+
+/**
+ * Print output to stderr (file, line and function),
+ * then abort.
+ */
+#define EXAMPLE_ABORT(fmt, ...) \
+   EXAMPLE_LOG(EXAMPLE_LOG_ABORT, fmt, ##__VA_ARGS__)
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/example/generator/Makefile.am b/example/generator/Makefile.am
index 5b3d55a..394985f 100644
--- a/example/generator/Makefile.am
+++ b/example/generator/Makefile.am
@@ -2,5 +2,6 @@ include $(top_srcdir)/example/Makefile.inc
  
  bin_PROGRAMS = odp_generator

  odp_generator_LDFLAGS = $(AM_LDFLAGS) -static
+odp_generator_CFLAGS = $(AM_CFLAGS) -I../
  
  dist_odp_generator_SOURCES = odp_generator.c

diff --git a/example/generator/odp_generator.c 
b/example/generator/odp_generator.c
index ffa5e62..e2e0ba4 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -16,6 +16,8 @@
  #include unistd.h
  #include sys/time.h
  
+#include example_debug.h

+
  #include odp.h
  
  #include odph_linux.h

@@ -55,7 +57,8 @@ typedef struct {
int number; /** packets number to be sent */
int payload;/** data len */
int timeout;/** wait time */
-   int interval;   /** wait interval ms between sending each 
packet */
+   int interval;   /** wait interval ms between sending
+each packet */
  } appl_args_t;
  
  /**

@@ -303,13 +306,13 @@ static void *gen_send_thread(void *arg)
/* Open a packet IO instance for this thread */
pktio = odp_pktio_open(thr_args-pktio_dev, thr_args-pool);
if (pktio == ODP_PKTIO_INVALID) {
-   ODP_ERR(  [%02i] Error: pktio create failed\n, thr);
+   EXAMPLE_ERR(  [%02i] Error: pktio create failed\n, thr);
return NULL;
}
  
  	outq_def = odp_pktio_outq_getdef(pktio);


Re: [lng-odp] [PATCH] linux-generic: fix SEGV on deq from an empty pktin queue

2014-11-06 Thread Maxim Uvarov

On 11/05/2014 05:18 PM, Stuart Haslam wrote:

Running the odp_ipsec application built with IPSEC_POLLED_QUEUES
enabled triggers a crash (on linux-generic).

pktin_dequeue can end up calling queue_enq_multi with the num
parameter set to 0, num-1 is then used as an array index causing a
SEGV. There's also a minor issue with pktin_deq_multi returning 0
buffers immediately after it had received some from the pktio, so
fix both and refactor a bit at the same time.

Signed-off-by: Stuart Haslam stuart.has...@arm.com
---
  platform/linux-generic/odp_packet_io.c | 66 +++---
  1 file changed, 28 insertions(+), 38 deletions(-)

diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index f35193f..560740f 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -413,34 +413,38 @@ int pktin_enqueue(queue_entry_t *qentry, odp_buffer_hdr_t 
*buf_hdr)
return queue_enq(qentry, buf_hdr);
  }
  
+static inline int pktin_recv_multi(queue_entry_t *qentry,

+  odp_buffer_hdr_t *buf_hdr[], int num)
+{
+   odp_packet_t pkt_tbl[QUEUE_MULTI_MAX];
+   odp_buffer_hdr_t *tmp_hdr_tbl[QUEUE_MULTI_MAX];
+   odp_buffer_t buf;
+   int pkts, i, j, nbr = 0;
+
+   pkts = odp_pktio_recv(qentry-s.pktin, pkt_tbl, QUEUE_MULTI_MAX);
+   if (pkts  0) {
+   for (i = 0, j = 0; i  pkts; ++i) {
+   buf = odp_packet_to_buffer(pkt_tbl[i]);
+   if (i  num)
+   buf_hdr[nbr++] = odp_buf_to_hdr(buf);
+   else
+   tmp_hdr_tbl[j++] = odp_buf_to_hdr(buf);
+   }
+   if (j  0)
+   queue_enq_multi(qentry, tmp_hdr_tbl, j);


I think it's bad idea to do that. Looks you ask for MAX packets if you 
receive more then requested (num)

then you push packets back to the queue.

So 2 problems:
1. Reordering;
2. At that time other thread can do read / queue, but you already got 
MAX packets in one thread.


so I think you need to calculate requested packets as min(num, 
QUEUE_MULTI_MAX);


BR,
Maxim.

+   }
+
+   return nbr;
+}
+
  odp_buffer_hdr_t *pktin_dequeue(queue_entry_t *qentry)
  {
odp_buffer_hdr_t *buf_hdr;
  
  	buf_hdr = queue_deq(qentry);
  
-	if (buf_hdr == NULL) {

-   odp_packet_t pkt;
-   odp_buffer_t buf;
-   odp_packet_t pkt_tbl[QUEUE_MULTI_MAX];
-   odp_buffer_hdr_t *tmp_hdr_tbl[QUEUE_MULTI_MAX];
-   int pkts, i, j;
-
-   pkts = odp_pktio_recv(qentry-s.pktin, pkt_tbl,
- QUEUE_MULTI_MAX);
-
-   if (pkts  0) {
-   pkt = pkt_tbl[0];
-   buf = odp_packet_to_buffer(pkt);
-   buf_hdr = odp_buf_to_hdr(buf);
-
-   for (i = 1, j = 0; i  pkts; ++i) {
-   buf = odp_packet_to_buffer(pkt_tbl[i]);
-   tmp_hdr_tbl[j++] = odp_buf_to_hdr(buf);
-   }
-   queue_enq_multi(qentry, tmp_hdr_tbl, j);
-   }
-   }
+   if (buf_hdr == NULL)
+   pktin_recv_multi(qentry, buf_hdr, 1);
  
  	return buf_hdr;

  }
@@ -457,22 +461,8 @@ int pktin_deq_multi(queue_entry_t *qentry, 
odp_buffer_hdr_t *buf_hdr[], int num)
  
  	nbr = queue_deq_multi(qentry, buf_hdr, num);
  
-	if (nbr  num) {

-   odp_packet_t pkt_tbl[QUEUE_MULTI_MAX];
-   odp_buffer_hdr_t *tmp_hdr_tbl[QUEUE_MULTI_MAX];
-   odp_buffer_t buf;
-   int pkts, i;
-
-   pkts = odp_pktio_recv(qentry-s.pktin, pkt_tbl,
- QUEUE_MULTI_MAX);
-   if (pkts  0) {
-   for (i = 0; i  pkts; ++i) {
-   buf = odp_packet_to_buffer(pkt_tbl[i]);
-   tmp_hdr_tbl[i] = odp_buf_to_hdr(buf);
-   }
-   queue_enq_multi(qentry, tmp_hdr_tbl, pkts);
-   }
-   }
+   if (nbr  num)
+   nbr += pktin_recv_multi(qentry, buf_hdr[nbr], num-nbr);
  
  	return nbr;

  }



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


Re: [lng-odp] [PATCH] api/odp_shared_memory.h: add odp_shm_free

2014-11-06 Thread Maxim Uvarov

On 11/06/2014 11:12 PM, Mike Holmes wrote:

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
  platform/linux-generic/include/api/odp_shared_memory.h | 13 +
  platform/linux-generic/odp_shared_memory.c |  6 ++
  2 files changed, 19 insertions(+)

diff --git a/platform/linux-generic/include/api/odp_shared_memory.h 
b/platform/linux-generic/include/api/odp_shared_memory.h
index d8d40dd..1a59824 100644
--- a/platform/linux-generic/include/api/odp_shared_memory.h
+++ b/platform/linux-generic/include/api/odp_shared_memory.h
@@ -72,6 +72,19 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, 
uint64_t align,
  uint32_t flags);
  
  /**

+ * Free a contiguous block of shared memory
+ *
+ * Frees a previously reserved block of shared memory.
+ * @note Freeing memory that is in use will result in UNDEFINED behaviour.
+ *
+ * @param[in] shm Block handle
+ *
+ * @retval 0 for success
+ * @retval 1 on failure
+ */
+int odp_shm_free(odp_shm_t shm);
+
+/**
   * Lookup for a block of shared memory
   *
   * @param name   Name of the block
diff --git a/platform/linux-generic/odp_shared_memory.c 
b/platform/linux-generic/odp_shared_memory.c
index c770a80..479ea4d 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -10,6 +10,7 @@
  #include odp_align.h
  #include odp_system_info.h
  #include odp_debug.h
+#include odp_debug_internal.h
  
  #include unistd.h

  #include sys/mman.h
@@ -219,6 +220,11 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, 
uint64_t align,
return block-hdl;
  }
  
+int odp_shm_free(odp_shm_t shmi ODP_UNUSED)
shmi? why not to implement this function? I think it's simple unmap of 
requested address.

+{
+   ODP_UNIMPLEMENTED();
+   return 0;
+}
  
  odp_shm_t odp_shm_lookup(const char *name)

  {



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


Re: [lng-odp] [PATCH] api/odp_shared_memory.h: add odp_shm_free

2014-11-06 Thread Mike Holmes
On 6 November 2014 16:08, Maxim Uvarov maxim.uva...@linaro.org wrote:

 On 11/06/2014 11:12 PM, Mike Holmes wrote:

 Signed-off-by: Mike Holmes mike.hol...@linaro.org
 ---
   platform/linux-generic/include/api/odp_shared_memory.h | 13
 +
   platform/linux-generic/odp_shared_memory.c |  6 ++
   2 files changed, 19 insertions(+)

 diff --git a/platform/linux-generic/include/api/odp_shared_memory.h
 b/platform/linux-generic/include/api/odp_shared_memory.h
 index d8d40dd..1a59824 100644
 --- a/platform/linux-generic/include/api/odp_shared_memory.h
 +++ b/platform/linux-generic/include/api/odp_shared_memory.h
 @@ -72,6 +72,19 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t
 size, uint64_t align,
   uint32_t flags);
 /**
 + * Free a contiguous block of shared memory
 + *
 + * Frees a previously reserved block of shared memory.
 + * @note Freeing memory that is in use will result in UNDEFINED
 behaviour.
 + *
 + * @param[in] shm Block handle
 + *
 + * @retval 0 for success
 + * @retval 1 on failure
 + */
 +int odp_shm_free(odp_shm_t shm);
 +
 +/**
* Lookup for a block of shared memory
*
* @param name   Name of the block
 diff --git a/platform/linux-generic/odp_shared_memory.c
 b/platform/linux-generic/odp_shared_memory.c
 index c770a80..479ea4d 100644
 --- a/platform/linux-generic/odp_shared_memory.c
 +++ b/platform/linux-generic/odp_shared_memory.c
 @@ -10,6 +10,7 @@
   #include odp_align.h
   #include odp_system_info.h
   #include odp_debug.h
 +#include odp_debug_internal.h
 #include unistd.h
   #include sys/mman.h
 @@ -219,6 +220,11 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t
 size, uint64_t align,
 return block-hdl;
   }
   +int odp_shm_free(odp_shm_t shmi ODP_UNUSED)

 shmi?


Oh - I was in Vi, will fix it now.


 why not to implement this function? I think it's simple unmap of requested
 address.


Because establishing the API was my goal to get the ODP API complete, this
is in the vein of a sequence of small patches that lead to the result you
want.



  +{
 +   ODP_UNIMPLEMENTED();
 +   return 0;
 +}
 odp_shm_t odp_shm_lookup(const char *name)
   {



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




-- 
*Mike Holmes*
Linaro  Sr Technical Manager
LNG - ODP
___
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v2] api/odp_shared_memory.h: add odp_shm_free

2014-11-06 Thread Mike Holmes
Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
 platform/linux-generic/include/api/odp_shared_memory.h | 13 +
 platform/linux-generic/odp_shared_memory.c |  6 ++
 2 files changed, 19 insertions(+)

diff --git a/platform/linux-generic/include/api/odp_shared_memory.h 
b/platform/linux-generic/include/api/odp_shared_memory.h
index d8d40dd..1a59824 100644
--- a/platform/linux-generic/include/api/odp_shared_memory.h
+++ b/platform/linux-generic/include/api/odp_shared_memory.h
@@ -72,6 +72,19 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, 
uint64_t align,
  uint32_t flags);
 
 /**
+ * Free a contiguous block of shared memory
+ *
+ * Frees a previously reserved block of shared memory.
+ * @note Freeing memory that is in use will result in UNDEFINED behaviour.
+ *
+ * @param[in] shm Block handle
+ *
+ * @retval 0 for success
+ * @retval 1 on failure
+ */
+int odp_shm_free(odp_shm_t shm);
+
+/**
  * Lookup for a block of shared memory
  *
  * @param name   Name of the block
diff --git a/platform/linux-generic/odp_shared_memory.c 
b/platform/linux-generic/odp_shared_memory.c
index c770a80..4e0f05e 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -10,6 +10,7 @@
 #include odp_align.h
 #include odp_system_info.h
 #include odp_debug.h
+#include odp_debug_internal.h
 
 #include unistd.h
 #include sys/mman.h
@@ -219,6 +220,11 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, 
uint64_t align,
return block-hdl;
 }
 
+int odp_shm_free(odp_shm_t shm ODP_UNUSED)
+{
+   ODP_UNIMPLEMENTED();
+   return 0;
+}
 
 odp_shm_t odp_shm_lookup(const char *name)
 {
-- 
2.1.0


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


Re: [lng-odp] [Q] Memory allocation in ODP applications

2014-11-06 Thread Mike Holmes
I think in a perfect world to achieve portability all ODP APIs should be
mandatory, but that may be unrealistic and certainly some solutions would
have terrible performance when emulated

Are there any dissenters from the idea that all ODP APIs are mandatory for
1.0 ?
If not that is the plan of record for 1.0 and all APIs must function as
specified.

On 4 November 2014 11:35, Bill Fischofer bill.fischo...@linaro.org wrote:

 We we want to call everything we've documented mandatory in v1.0 I'm OK
 with that.  What I don't want is for us to say that and then as we approach
 end of year someone says but I really can't do (formerly optional) feature
 X.

 Quick poll: Are there any APIs currently marked optional that anyone does
 not plan to implement in their v1.0 release?

 On Tue, Nov 4, 2014 at 9:58 AM, Gilad Ben Yossef gil...@ezchip.com
 wrote:


 True, but maybe there is a middle way -
 What if instead of a mad matrix of optional features we have 2 or 3
 levels of features?
 Say:
 ODP Basic support - all mandatory features are supported.
 ODP Full support - mandatory + all what we now call optional features are
 supported.
 And maybe, if it makes sense -
 ODP Intermediate support - mandatory + a certain pre-defined set of now
 called optional features supported.
 This let application writer to say: My application targets Basic,
 Intermediate or Full support and the application writer knows exactly what
 to expect.
 The platform vendor can say: I support ODP Basic, Intermediate or Full.
 So you know what you get.

 Gilad

 Gilad Ben-Yossef
 Software Architect
 EZchip Technologies Ltd.
 37 Israel Pollak Ave, Kiryat Gat 82025 ,Israel
 Tel: +972-4-959- ext. 576, Fax: +972-8-681-1483
 Mobile: +972-52-826-0388, US Mobile: +1-973-826-0388
 Email: gil...@ezchip.com, Web: http://www.ezchip.com

 Ethernet always wins.
 — Andy Bechtolsheim

  -Original Message-
  From: lng-odp-boun...@lists.linaro.org [mailto:lng-odp-
  boun...@lists.linaro.org] On Behalf Of Victor Kamensky
  Sent: Tuesday, November 04, 2014 5:33 PM
  To: Bill Fischofer
  Cc: Savolainen, Petri (NSN - FI/Espoo); lng-odp@lists.linaro.org
  Subject: Re: [lng-odp] [Q] Memory allocation in ODP applications
 
  I did express the same in the past and agree with Petri
  '“optional” is next to non-existent'. It creates fragmentation
  that we don't need. When I need to figure out what optional
  pieces implemented by specific ODP implementation and
  how to match one that not implemented from that point
  it is not very far for me just to create my own wrappers/shims
  on top of specific SDKs.
 
  For optional APIs being present and return error in run-time
  even worse in my opinion. Build time link error would be much
  better. Because as usual run-time errors much harder to get
  compared to build time errors. Build errors I discover during
  single build, run-time errors I may need to create bunch of
  specific scenarios to get complete coverage for pieces that
  my app uses.
 
  Thanks,
  Victor
 
 
  On 4 November 2014 05:38, Bill Fischofer bill.fischo...@linaro.org
  wrote:
   That's precisely why we've said that all implementations must provide
  at
   least stubs for all of the ODP APIs (even those marked optional).  Not
  every
   ODP application will be able to run on every ODP implementation, but
  that's
   OK.  You don't need your home office router to have enterprise-level
   features.  Requiring every ODP implementation to provide identical
   functionality will either force us to adopt a least-common-denominator
   approach to what are acceptable APIs or else we'll severely limit the
  range
   of platforms that can participate in the ecosystem.
  
   Do you have a specific list of APIs that are currently marked optional
  that
   you'd like to see promoted to mandatory?
  
  
   On Tue, Nov 4, 2014 at 7:26 AM, Savolainen, Petri (NSN - FI/Espoo)
   petri.savolai...@nsn.com wrote:
  
   I’m concerned that the API gets too fragmented already in v1.0 and
  the
   ecosystem will be limited by that. For example, it’s hard to
  integrate 3rd
   party (or open source) SW into a system, if my app uses optional
  feature X,
   the 3rd party lib uses optional feature Y and the implementation
  provides
   only one of those, or neither.
  
  
  
   -Petri
  
  
  
  
  
   From: ext Bill Fischofer [mailto:bill.fischo...@linaro.org]
   Sent: Tuesday, November 04, 2014 3:16 PM
   To: Savolainen, Petri (NSN - FI/Espoo)
   Cc: Shmulik Ladkani; lng-odp@lists.linaro.org
  
  
   Subject: Re: [lng-odp] [Q] Memory allocation in ODP applications
  
  
  
   I think the criteria I outlined above for considering an API optional
  are
   reasonable.  Recall that the reason certain APIs are designated as
  optional
   is because we received feedback that they were not feasible on
  specific
   platforms.  It's RECOMMENDED that platforms provide all of these
  APIs,
   however I'm not eager to say platform X can't have a conforming ODP
   

Re: [lng-odp] [PATCHv3] ipc linux-generic implementation based on pktio

2014-11-06 Thread Maxim Uvarov
Petri, I'm trying to understand how much work also is needed to have 
this patch accepted.
If current comments will be fixed can you sign this or patch needs more 
detailed review?


Thanks,
Maxim.


On 11/06/2014 05:10 PM, Maxim Uvarov wrote:

On 11/06/2014 02:59 PM, Savolainen, Petri (NSN - FI/Espoo) wrote:

+int lg_odp_pktio_lookup(const char *dev, pktio_entry_t *pktio_entry)
+{
+int ret = -1;
+char ipc_shm_name[ODPH_RING_NAMESIZE];
+size_t ring_size;
+
+if (!(lg_odp_shm_lookup_pktio(dev) == 0 
+  odp_shm_lookup_ipc(shm_packet_pool) == 0)) {
+ODP_DBG(pid %d unable to find ipc object: %s.\n,
+getpid(), dev);
+goto error;
+}
So, the role of the new odp_shm_lookup_ipc() call is just check if a 
shm has been created. I'm against adding xxx_ipc() versions of 
existing API calls. You should be able to just use the normal lookup. 
Maybe ODP (global init) needs to be informed that application runs in 
multi-process mode, so that ODP internal data structures are mapped 
so that multiple processes can lookup from those.


It is internal implementation. This look up should be for 2 separate 
processes. Might be _ipc prefix is very confusing here, but it's just 
function to check if there is such shm or not. It can be 
pktio_in_shm(dev) and pool_in_shm(name). Also I need to think how to 
remove this predefined value shm_packet_pool, skipped that on clean up.


Taras also mentioned about such flag to odp_global_init.



If you check e.g. Multi-process Sample Application chapter in DPDK 
sample apps guide. It gives a cleaner framework how to handle the 
multi-process case.



+
+ODP_DBG(pid %d odp_shm_lookup_ipc found shared object\n,
+getpid());
+ring_size =  PKTIO_IPC_ENTRIES * sizeof(void *) +
+sizeof(odph_ring_t);
+
+memset(ipc_shm_name, 0, ODPH_RING_NAMESIZE);
+memcpy(ipc_shm_name, dev, strlen(dev));
+memcpy(ipc_shm_name + strlen(dev), _r, 2);
+
+/* allocate shared memory for buffers needed to be produced */
+odp_shm_t shm = odp_shm_reserve(ipc_shm_name, ring_size,
+ODP_CACHE_LINE_SIZE,
+ODP_SHM_PROC_NOCREAT);

This should be replaced by the normal (multi-process capable) lookup.


Why not to reuse odp_shm_reserve() here? I can put it to separate 
function, no problem or even better just to replace to shm_open() call.
My point is when we will have clean up function for odp_shm_reserve() 
then we can use it for that memory also.





+
+pktio_entry-s.ipc_r = odp_shm_addr(shm);
+if (!pktio_entry-s.ipc_r) {
+ODP_DBG(pid %d unable to find ipc ring %s name\n,
+getpid(), dev);
+goto error;
+}
+
+memcpy(ipc_shm_name + strlen(dev), _p, 2);
+/* allocate shared memory for produced ring buffer handlers. That
+ * buffers will be cleaned up after they are produced by other
process.
+ */
+shm = odp_shm_reserve(ipc_shm_name, ring_size,
+ODP_CACHE_LINE_SIZE,
+ODP_SHM_PROC_NOCREAT);

Same thing here.

-Petri


+
+pktio_entry-s.ipc_p = odp_shm_addr(shm);
+if (!pktio_entry-s.ipc_p) {
+ODP_DBG(pid %d unable to find ipc ring %s name\n,
+getpid(), dev);
+goto error;
+}
+
+pktio_entry-s.type = ODP_PKTIO_TYPE_IPC;
+
+/* Get info about remote pool */
+struct pktio_info *pinfo = lng_map_shm_pool_info(dev,
+ODP_SHM_PROC_NOCREAT);
+pktio_entry-s.ipc_pool_base = map_remote_pool(pinfo);
+pktio_entry-s.ipc_pkt_size = pinfo-shm_pkt_size;
+
+/* @todo: to simplify in linux-generic implementation we create 
pool

for
+ * packets from IPC queue. On receive implementation copies 
packets

to
+ * that pool. Later we can try to reuse original tool without
packets
+ * copying.
+ */
+pktio_entry-s.pkt_sock.pool = lg_odp_alloc_and_create_pool(
+pinfo-shm_pkt_pool_size, pinfo-shm_pkt_size);
+
+ret = 0;
+ODP_DBG(%s OK.\n, __func__);
+error:
+/* @todo free shm on error (api not impemented yet) */
+return ret;
+}
+





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


Re: [lng-odp] [PATCH v5] add queue test

2014-11-06 Thread yan.songm...@linaro.org
Anders,

 +static void test_odp_queue(void)
The name of this test is displayed when CUnit runs, so it needs to make
sense what it tests, e.g., test_odp_queue_sunnyday

Yan : The test_odp_queue means the whole test of queue. It calls 
test_odp_queue_base. This function is the sunnyday test.
 Maybe we should add other deep test later. It may calls 
test_odp_queue_deep or something else in  test_odp_queue.
 So i think it make sense.

 



yan.songm...@linaro.org
 
From: Anders Roxell
Date: 2014-11-07 00:43
To: Yan Songming
CC: lng-odp
Subject: Re: [lng-odp] [PATCH v5] add queue test
On 2014-11-06 23:08, Yan Songming wrote:
 From: yan.songming yan.songm...@linaro.org
 
 Add the cunit test for none syne queue. Test the base queue function
 
 Signed-off-by: yan.songming yan.songm...@linaro.org
 ---
 Fix spelling problem and commend problem. Add term_local and term_global.
 Move cunit queue test to test_odp_queue_base for none syn queue.
 ---
  test/cunit/Makefile.am  |   8 ++-
  test/cunit/odp_queue_test.c | 158 
 
  2 files changed, 163 insertions(+), 3 deletions(-)
  create mode 100644 test/cunit/odp_queue_test.c
 
 diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am
 index 927a5a5..74a0deb 100644
 --- a/test/cunit/Makefile.am
 +++ b/test/cunit/Makefile.am
 @@ -1,13 +1,15 @@
  include $(top_srcdir)/test/Makefile.inc
  
  AM_CFLAGS += -I$(CUNIT_PATH)/include
 -AM_LDFLAGS += -L$(CUNIT_PATH)/lib
 +AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
  
  if ODP_CUNIT_ENABLED
  TESTS = ${bin_PROGRAMS}
  check_PROGRAMS = ${bin_PROGRAMS}
 -bin_PROGRAMS = odp_init
 -odp_init_LDFLAGS = $(AM_LDFLAGS) -static -lcunit
 +bin_PROGRAMS = odp_init odp_queue
 +odp_init_LDFLAGS = $(AM_LDFLAGS)
 +odp_queue_LDFLAGS = $(AM_LDFLAGS)
  endif
  
  dist_odp_init_SOURCES = odp_init_test.c
 +dist_odp_queue_SOURCES = odp_queue_test.c
 diff --git a/test/cunit/odp_queue_test.c b/test/cunit/odp_queue_test.c
 new file mode 100644
 index 000..63e5d56
 --- /dev/null
 +++ b/test/cunit/odp_queue_test.c
 @@ -0,0 +1,158 @@
 +/* Copyright (c) 2014, Linaro Limited
 + * All rights reserved.
 + *
 + * SPDX-License-Identifier: BSD-3-Clause
 + */
 +
 +#include odp.h
 +#include CUnit/Basic.h
 +
 +#define MAX_BUFFER_QUEUE(8)
 +#define MSG_POOL_SIZE   (4*1024*1024)
 +
 +static int queue_contest = 0xff;
 +
 +static int test_odp_buffer_pool_init(void)
 +{
 + odp_buffer_pool_t pool;
 + void *pool_base;
 + odp_shm_t shm;
 +
 + shm = odp_shm_reserve(msg_pool,
 +   MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
 +
 + pool_base = odp_shm_addr(shm);
 +
 + if (NULL == pool_base) {
 + printf(Shared memory reserve failed.\n);
 + return -1;
 + }
 +
 + pool = odp_buffer_pool_create(msg_pool, pool_base, MSG_POOL_SIZE, 0,
 +   ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW);
 +
 + if (ODP_BUFFER_POOL_INVALID == pool) {
 + printf(Pool create failed.\n);
 + return -1;
 + }
 + return 0;
 +}
 +
 +static void test_odp_queue_base(void)
 +{
 + odp_queue_t queue_creat_id;
 + odp_queue_t queue_id;
 + odp_buffer_t enbuf[MAX_BUFFER_QUEUE];
 + odp_buffer_t debuf[MAX_BUFFER_QUEUE];
 + odp_buffer_pool_t msg_pool;
 + odp_queue_param_t param;
 +
 + int i;
 + odp_buffer_t buf;
 + void *prtn = NULL;
 +
 + memset(param, 0, sizeof(param));
 + param.sched.sync  = ODP_SCHED_SYNC_NONE;
 +
 + queue_creat_id = odp_queue_create(test_queue,
 +   ODP_QUEUE_TYPE_POLL, param);
 + CU_ASSERT(ODP_QUEUE_INVALID != queue_creat_id);
 +
 + CU_ASSERT_EQUAL(ODP_QUEUE_TYPE_POLL,
 + odp_queue_type(queue_creat_id));
 + CU_ASSERT_EQUAL(ODP_SCHED_SYNC_NONE,
 + odp_queue_sched_type(queue_creat_id));
 +
 + /* test odp_queue_lookup */
 
Make comments valuable or remove them.
 
The same goes for all comments.
 
 + queue_id = odp_queue_lookup(test_queue);
 + CU_ASSERT_EQUAL(queue_creat_id, queue_id);
 +
 + /* test odp_queue_set_context */
 + CU_ASSERT(0 == odp_queue_set_context(queue_id, queue_contest));
 +
 + /* test odp_queue_get_context*/
 + prtn = odp_queue_get_context(queue_id);
 + CU_ASSERT(queue_contest == (int *)prtn);
 +
 + /* apply for buffer */
 + msg_pool = odp_buffer_pool_lookup(msg_pool);
 + buf = odp_buffer_alloc(msg_pool);
 +
 + /* test odp_queue_deq and odp_queue_deq */
 + odp_queue_enq(queue_id, buf);
 + CU_ASSERT_EQUAL(buf, odp_queue_deq(queue_id));
 + odp_buffer_free(buf);
 +
 + /* apply for mutili buffer */
 + for (i = 0; i  MAX_BUFFER_QUEUE; i++)
 + enbuf[i] = odp_buffer_alloc(msg_pool);
 +
 + /* test odp_queue_enq_multi and odp_queue_enq_multi */
 + odp_queue_enq_multi(queue_id, enbuf, MAX_BUFFER_QUEUE);
 + CU_ASSERT_EQUAL(MAX_BUFFER_QUEUE,
 + odp_queue_deq_multi(queue_id, debuf, MAX_BUFFER_QUEUE));
 +
 + for (i = 0; i  MAX_BUFFER_QUEUE; i++) {
 + /* test odp_queue_deq_multi */
 + CU_ASSERT_EQUAL(enbuf[i], debuf[i]);
 + odp_buffer_free(enbuf[i]);
 + }
 + return;
 +}
 +
 +static void test_odp_queue(void)
 
The name of this test is displayed when CUnit runs, so it needs to make
sense what it tests, e.g.,