Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test

2014-12-10 Thread Anders Roxell
On 2014-12-09 17:56, Mike Holmes wrote:
 Has checkpatch issues
 
 Using patch:
 /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
 git am
 /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
   Patch applied, building...
 WARNING: line over 80 characters
 #238: FILE: test/validation/odp_timer.c:185:
 + CU_FAIL(Failed to set timer (tooearly/toolate));
 
 total: 0 errors, 1 warnings, 0 checks, 359 lines checked
 
 NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS
 
 0001-test-odp_timer.h-cunit-test.patch has style problems, please review.

Do we want to split up this printout?
If you're not familiar with the code and you run the validation tests
and got this failure printed out. I would grep for that failure message
(the string) in the code too see how I got there.
And if we split this string up into multiple rows just to make
check-patch happy it will make it harder to search after the failure
message then right?

Cheers,
Anders

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


Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test

2014-12-10 Thread Ola Liljedahl
On 10 December 2014 at 09:13, Anders Roxell anders.rox...@linaro.org wrote:
 On 2014-12-09 17:56, Mike Holmes wrote:
 Has checkpatch issues

 Using patch:
 /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
 git am
 /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
   Patch applied, building...
 WARNING: line over 80 characters
 #238: FILE: test/validation/odp_timer.c:185:
 + CU_FAIL(Failed to set timer (tooearly/toolate));

 total: 0 errors, 1 warnings, 0 checks, 359 lines checked

 NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS

 0001-test-odp_timer.h-cunit-test.patch has style problems, please review.

 Do we want to split up this printout?
No.

 If you're not familiar with the code and you run the validation tests
 and got this failure printed out. I would grep for that failure message
 (the string) in the code too see how I got there.
Exactly.

 And if we split this string up into multiple rows just to make
 check-patch happy it will make it harder to search after the failure
 message then right?
Correct.
And I even think checkpatch for this reason will complain if you split
the string.

-- Ola


 Cheers,
 Anders

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


Re: [lng-odp] Build failure with older GCC versions...

2014-12-10 Thread Ola Liljedahl
On 9 December 2014 at 17:48, Robbie King (robking) robk...@cisco.com wrote:
 After cloning tip just now, I found that I couldn’t build the fresh

 workspace due to having GCC 4.6.3 (the C11 changes to the atomics

 bumps minimum GCC up to 4.8 as best I can tell).  I’m not very familiar
GCC 4.7 according to https://gcc.gnu.org/gcc-4.7/changes.html

Is support for older versions of GCC needed?


 with what “./configure” can and can’t do, but it seems we should verify

 the compiler supports these constructs and fail during the configure

 phase (as opposed to build time).



 Thanks,

 Robbie


 ___
 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] Build failure with older GCC versions...

2014-12-10 Thread Ola Liljedahl
On 9 December 2014 at 18:17, Bill Fischofer bill.fischo...@linaro.org wrote:
 I suggest we turn on that by default.  It's the one way to ensure that the
 issues will get fixed.  Is this a stop-on-first-error situation or can we
 have it carry on so we get a complete list of what the c99 issues are?
Just specifying -std=c99 to gcc will not actually limit it to using
Standard C only, GCC is rather fond of its extensions and won't give
up on them easily. Perhaps we should see what happens when adding
-ansi. To check for complete compliance, add -pedantic (this will
break compilation as e.g. linux-generic relies in a lot of GCC
extensions, possibly already -ansi will break compilation though).
https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/C-Dialect-Options.html


 On Tue, Dec 9, 2014 at 11:02 AM, Mike Holmes mike.hol...@linaro.org wrote:

 This might also be the right time to adhere to the use of only C99 in
 linux-generics implementation ?

 CFLAGS=-std=c99 ./configure
 make

 Throws up other issues, the first is in packet_io

 mike@fedora1:~/git/odp$ make
 Making all in platform
 make[1]: Entering directory '/home/mike/git/odp/platform'
 Making all in linux-generic
 make[2]: Entering directory '/home/mike/git/odp/platform/linux-generic'
   CC   odp_packet_io.lo
 odp_packet_io.c: In function 'odp_pktio_set_mtu':
 odp_packet_io.c:512:35: error: 'caddr_t' undeclared (first use in this
 function)
   ret = ioctl(sockfd, SIOCSIFMTU, (caddr_t)ifr);
^
 odp_packet_io.c:512:35: note: each undeclared identifier is reported only
 once for each function it appears in
 Makefile:560: recipe for target 'odp_packet_io.lo' failed



 Mike

 On 9 December 2014 at 11:48, Robbie King (robking) robk...@cisco.com
 wrote:

 After cloning tip just now, I found that I couldn’t build the fresh

 workspace due to having GCC 4.6.3 (the C11 changes to the atomics

 bumps minimum GCC up to 4.8 as best I can tell).  I’m not very familiar

 with what “./configure” can and can’t do, but it seems we should verify

 the compiler supports these constructs and fail during the configure

 phase (as opposed to build time).



 Thanks,

 Robbie


 ___
 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 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] [PATCH 1/2] api: queue: add odp_queue_sched_prio and odp_queue_sched_group

2014-12-10 Thread Ciprian Barbu
On Wed, Dec 10, 2014 at 11:59 AM, Ciprian Barbu
ciprian.ba...@linaro.org wrote:
 On Tue, Dec 9, 2014 at 4:16 PM, Ciprian Barbu ciprian.ba...@linaro.org 
 wrote:
 On Tue, Dec 9, 2014 at 3:46 PM, Savolainen, Petri (NSN - FI/Espoo)
 petri.savolai...@nsn.com wrote:
 After the minor documentation change (see under), for the entire patch set:

 Yeah, sorry about that. Thanks!

 Anders spotted I'm missing checks, v2 on the way.



 Reviewed-by: Petri Savolainen petri.savolai...@linaro.org


 -Original Message-
 From: lng-odp-boun...@lists.linaro.org [mailto:lng-odp-
 boun...@lists.linaro.org] On Behalf Of ext Ciprian Barbu
 Sent: Monday, December 08, 2014 3:59 PM
 To: lng-odp@lists.linaro.org
 Subject: [lng-odp] [PATCH 1/2] api: queue: add odp_queue_sched_prio and
 odp_queue_sched_group

 Signed-off-by: Ciprian Barbu ciprian.ba...@linaro.org
 ---
  platform/linux-generic/include/api/odp_queue.h | 18 ++
  1 file changed, 18 insertions(+)

 diff --git a/platform/linux-generic/include/api/odp_queue.h
 b/platform/linux-generic/include/api/odp_queue.h
 index b8ac4bb..d25fd65 100644
 --- a/platform/linux-generic/include/api/odp_queue.h
 +++ b/platform/linux-generic/include/api/odp_queue.h
 @@ -222,6 +222,24 @@ odp_queue_type_t odp_queue_type(odp_queue_t queue);
  odp_schedule_sync_t odp_queue_sched_type(odp_queue_t queue);

  /**
 + * Queue priority

 Queue schedule priority

 + *
 + * @param queue   Queue handle
 + *
 + * @return Queue priority

 @return Queue schedule priority

Question: Can these two APIs fail (e.g. invalid queue handle) ? What
should the return value be if the queue handle is invalid? Maybe
introduce a ODP_SCHEDULE_PRIO_INVALID?


 + */
 +odp_schedule_prio_t odp_queue_sched_prio(odp_queue_t queue);
 +
 +/**
 + * Queue group

 Queue schedule group

 + *
 + * @param queue   Queue handle
 + *
 + * @return Queue group

 @return Queue schedule group

 + */
 +odp_schedule_group_t odp_queue_sched_group(odp_queue_t queue);
 +
 +/**
   * @}
   */

 --
 1.8.3.2


 ___
 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] Build failure with older GCC versions...

2014-12-10 Thread Maxim Uvarov

On 12/10/2014 08:32 AM, Bill Fischofer wrote:
Just as an FYI, I took a stab at classifying the issues with std=c99. 
The root issue is that c99 is more than just a C language issue--it 
also implies that you're restricted to using the standard C library 
,and most of the examples (and odp_shared_memory.c) violate this 
restriction.




I think for examples there is no need to be C99. Examples is only odp 
library usage. So it can be even C++, python. I think.


Maxim.


The cheat is to include the line:

#define _BSD_SOURCE

which unhides the non-standard library functions. But the real 
answer is that to be strictly c99 compliant you need to go back and 
replace the non-standard library calls with their standard 
equivalents. Unfortunately many of these do not have standard 
equivalents, or at least not strict equivalents, so this may involve 
redesigning the code.


For the examples, the cheat is probably OK since they are illustrating 
application use of ODP and we never said that ODP /applications/ need 
to be c99 compliant. However odp_shared_memory.c /is/ part of ODP and 
hence should be held to that higher standard. In this routine's case 
the offending routine is ftruncate(). I'm not a C library guru so I'm 
not sure how one would replace that call with something that passes 
muster, but that's the key sticking point.


The existing odp_timer.c routine has similar issues, but since that's 
being replaced with Ola's new timer code I assume that shouldn't be a 
problem.


Moral: If you learned to program C applications prior to C99, you 
probably aren't writing C99-compliant code because you're naturally 
reaching for non-standard library routines without thinking about this 
problem.


Bill

On Tue, Dec 9, 2014 at 1:46 PM, Bill Fischofer 
bill.fischo...@linaro.org mailto:bill.fischo...@linaro.org wrote:


Thanks! I'll fix that in the v3 patch as well.

Bill

On Tue, Dec 9, 2014 at 1:22 PM, Stuart Haslam
stuart.has...@arm.com mailto:stuart.has...@arm.com wrote:

On Tue, Dec 09, 2014 at 06:20:02PM +, Bill Fischofer wrote:
 I'll take a look at odp_shared_memory. Maxim/Stuart should
take a look at odp_packet_io.c. I assume Ola's new timer code
is compliant. If not, it should be.

 Bill

I just sent a patch that clears the caddr_t failure.

Note that I also get build failures on one of my dev branches
which has
the buffer pool patch applied, due to the use of typeof.

--
Stuart.


 On Tue, Dec 9, 2014 at 12:10 PM, Mike Holmes
mike.hol...@linaro.org
mailto:mike.hol...@linaro.orgmailto:mike.hol...@linaro.org
mailto:mike.hol...@linaro.org wrote:


 On 9 December 2014 at 12:57, Bill Fischofer
bill.fischo...@linaro.org
mailto:bill.fischo...@linaro.orgmailto:bill.fischo...@linaro.org
mailto:bill.fischo...@linaro.org wrote:
 If we can get a complete list of which files currently have
issues I'm thinking that would be an excellent list to mull
over during the Christmas break.

 For a list just add the cflags line ./configure
CFLAGS=-std=c99 and then make -k 21 | grep ^.*\.c:

 Api is currently

 odp_packet_io.c
 odp_shared_memory.c
 odp_timer.c

 There are more in the examples

 For those of us who will be off we may still want a coding
fix for an hour or so. :)

 Also it's an excellent way for those on the ODP mailing list
who want to get their hands dirty with ODP code to tackle
something small and focused.

 Bill

 On Tue, Dec 9, 2014 at 11:54 AM, Mike Holmes mike.hol...@linaro.org
mailto:mike.hol...@linaro.orgmailto:mike.hol...@linaro.org
mailto:mike.hol...@linaro.org wrote:
 I think adding it explicitly when using the patch checking
tool apply-and-build.sh might be a way forward.

 If we can get agreement on C99, then bugzilla already has
many of these bugs

listed,https://bugs.linaro.org/buglist.cgi?component=Generallist_id=3080product=OpenDataPlaneresolution=---
including the source of Robbies issue. All we need is
agreement that C99 is our direction and git blame will show us
the likely best person to fix each issue.

 On 9 December 2014 at 12:48, Bill Fischofer
bill.fischo...@linaro.org
mailto:bill.fischo...@linaro.orgmailto:bill.fischo...@linaro.org
mailto:bill.fischo...@linaro.org wrote:
 OK, I understand this is perhaps a longer-term project, but
is there a file-level way we can enable this check? If yes,
then we can ask that as part of modules that are currently
being patched that c99 checks be included in them. That way
files will be 

Re: [lng-odp] [PATCH v6 3/3] linux-generic: classification initial implementation

2014-12-10 Thread Ciprian Barbu
On Tue, Dec 9, 2014 at 7:53 PM, Bill Fischofer
bill.fischo...@linaro.org wrote:
 If you've already received the packet there's not much point in classifying
 it since the output of classification is the queue that the packet should be
 sent to (and the buffer pool it should be stored in for non-linux-generic
 implementations).  In my packet patch I include the odp_packet_parse()
 function but it's an internal API for now since it isn't part of the v0.5
 external spec.  Parsing would be useful independent of classification.

I agree with always parsing packets received from the interface, but
for real platforms it's not clear to me if it can be an independent
process, like it can be for linux-generic. Looking at the
Classification document I see parsing as in integral part of the
classifier, if I'm reading it correctly.

To be clear, I'm ok to give a go to the patch series as they are, just
wanted to get an idea of the differences between linux-generic and
other platforms in regards to classification.

So please add my Reviewed-by to this patch also.


 On Tue, Dec 9, 2014 at 10:47 AM, Ciprian Barbu ciprian.ba...@linaro.org
 wrote:

 I have one question that just came to me. See below.

 On Tue, Dec 9, 2014 at 4:23 AM, Bill Fischofer
 bill.fischo...@linaro.org wrote:
 
 
  On Mon, Dec 8, 2014 at 6:02 AM, Balasubramanian Manoharan
  bala.manoha...@linaro.org wrote:
 
  The following features are implemented in this classification
  implementation:
  * Attaches PMR, PMR_SET to a Pktio entry
  * Adds classifier object to pktio entry
  * Attaches CoS values for L2 and L3 QoS to a Pktio entry
  * Selects ClassOfService for a packet based on PMR, L2 QoS and L3 QoS
  values
  * Selects a default CoS if packet does not match any of the assigned
  rules
  * Selects an Error CoS for an Error packet
  * Enqueues the packet to the queue associated with the selected CoS
 
  Signed-off-by: Balasubramanian Manoharan bala.manoha...@linaro.org
 
 
  Reviewed-by: Bill Fischofer bill.fischo...@linaro.org
 
 
  ---
  V6: Incorporates review comments from Bill
   helper/include/odph_ip.h   |   6 +
   platform/linux-generic/include/api/odp.h   |   1 +
   .../include/odp_buffer_pool_internal.h |   9 +
   .../include/odp_classification_datamodel.h | 201 +
   .../include/odp_classification_inlines.h   | 259 ++
   .../include/odp_classification_internal.h  | 173 
   platform/linux-generic/include/odp_internal.h  |   2 +
   .../linux-generic/include/odp_packet_io_internal.h |   2 +
   platform/linux-generic/odp_buffer_pool.c   |  10 -
   platform/linux-generic/odp_classification.c| 883
  +++--
   platform/linux-generic/odp_init.c  |   4 +
   platform/linux-generic/odp_packet_io.c |  47 +-
   12 files changed, 1498 insertions(+), 99 deletions(-)
   create mode 100644
  platform/linux-generic/include/odp_classification_datamodel.h
   create mode 100644
  platform/linux-generic/include/odp_classification_inlines.h
   create mode 100644
  platform/linux-generic/include/odp_classification_internal.h
 
  diff --git a/helper/include/odph_ip.h b/helper/include/odph_ip.h
  index 2c83c0f..f78724e 100644
  --- a/helper/include/odph_ip.h
  +++ b/helper/include/odph_ip.h
  @@ -35,6 +35,9 @@ extern C {
   /** @internal Returns IPv4 header length */
   #define ODPH_IPV4HDR_IHL(ver_ihl) ((ver_ihl)  0x0f)
 
  +/** @internal Returns IPv4 DSCP */
  +#define ODPH_IPV4HDR_DSCP(tos) (((tos)  0xfc)  2)
  +
   /** @internal Returns IPv4 Don't fragment */
   #define ODPH_IPV4HDR_FLAGS_DONT_FRAG(frag_offset)  ((frag_offset) 
  0x4000)
 
  @@ -47,6 +50,9 @@ extern C {
   /** @internal Returns true if IPv4 packet is a fragment */
   #define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset)  0x3fff)
 
  +/** @internal Returns IPv4 DSCP */
  +#define ODPH_IPV6HDR_DSCP(ver_tc_flow) (uint8_t)ver_tc_flow) 
  0x0fc0)  22)  0xff)
  +
   /** IPv4 header */
   typedef struct ODP_PACKED {
  uint8_tver_ihl; /** Version / Header length */
  diff --git a/platform/linux-generic/include/api/odp.h
  b/platform/linux-generic/include/api/odp.h
  index 6e4f69e..b7b1ca9 100644
  --- a/platform/linux-generic/include/api/odp.h
  +++ b/platform/linux-generic/include/api/odp.h
  @@ -47,6 +47,7 @@ extern C {
   #include odp_packet_flags.h
   #include odp_packet_io.h
   #include odp_crypto.h
  +#include odp_classification.h
   #include odp_rwlock.h
 
   #ifdef __cplusplus
  diff --git a/platform/linux-generic/include/odp_buffer_pool_internal.h
  b/platform/linux-generic/include/odp_buffer_pool_internal.h
  index e0210bd..07602fe 100644
  --- a/platform/linux-generic/include/odp_buffer_pool_internal.h
  +++ b/platform/linux-generic/include/odp_buffer_pool_internal.h
  @@ -22,6 +22,7 @@ extern C {
   #include odp_buffer_pool.h
   #include odp_buffer_internal.h
   #include odp_align.h
  +#include odp_align_internal.h
   

[lng-odp] [PATCH] linux-generic: odp_ticketlock.h: implement trylock()

2014-12-10 Thread Ola Liljedahl
Signed-off-by: Ola Liljedahl ola.liljed...@linaro.org
---
(This document/code contribution attached is provided under the terms of
agreement LES-LTM-21309)
Implemented the missing odp_ticketlock_trylock().

 platform/linux-generic/odp_ticketlock.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/platform/linux-generic/odp_ticketlock.c 
b/platform/linux-generic/odp_ticketlock.c
index 682b01b..6525786 100644
--- a/platform/linux-generic/odp_ticketlock.c
+++ b/platform/linux-generic/odp_ticketlock.c
@@ -34,6 +34,36 @@ void odp_ticketlock_lock(odp_ticketlock_t *ticketlock)
odp_spin();
 }
 
+int odp_ticketlock_trylock(odp_ticketlock_t *tklock)
+{
+   /* We read 'next_ticket' and 'cur_ticket' non-atomically which should
+* not be a problem as they are not independent of each other.
+* 'cur_ticket' is always = to 'next_ticket' and if we see an
+* older value of 'cur_ticket', this only means the lock will
+* look busy and trylock will fail. */
+   uint32_t next = odp_atomic_load_u32(tklock-next_ticket);
+   uint32_t cur = odp_atomic_load_u32(tklock-cur_ticket);
+   /* First check that lock is available and possible to take without
+* spinning. */
+   if (next == cur) {
+   /* Then try to take the lock by incrementing 'next_ticket'
+* but only if it still has the original value which is
+* equal to 'cur_ticket'.
+* We don't have to include 'cur_ticket' in the comparison
+* because it cannot be larger than 'next_ticket' (only
+* smaller if the lock is busy).
+* If CAS fails, it means some other thread intercepted and
+* took a ticket which means the lock is not available
+* anymore */
+   if (_odp_atomic_u32_cmp_xchg_strong_mm(tklock-next_ticket,
+  next,
+  next + 1,
+  _ODP_MEMMODEL_ACQ,
+  _ODP_MEMMODEL_RLX))
+   return 1;
+   }
+   return 0;
+}
 
 void odp_ticketlock_unlock(odp_ticketlock_t *ticketlock)
 {
-- 
1.9.1


___
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_sched_prio and odp_queue_sched_group

2014-12-10 Thread Ola Liljedahl
On 10 December 2014 at 11:18, Ciprian Barbu ciprian.ba...@linaro.org wrote:
 On Wed, Dec 10, 2014 at 11:59 AM, Ciprian Barbu
 ciprian.ba...@linaro.org wrote:
 On Tue, Dec 9, 2014 at 4:16 PM, Ciprian Barbu ciprian.ba...@linaro.org 
 wrote:
 On Tue, Dec 9, 2014 at 3:46 PM, Savolainen, Petri (NSN - FI/Espoo)
 petri.savolai...@nsn.com wrote:
 After the minor documentation change (see under), for the entire patch set:

 Yeah, sorry about that. Thanks!

 Anders spotted I'm missing checks, v2 on the way.



 Reviewed-by: Petri Savolainen petri.savolai...@linaro.org


 -Original Message-
 From: lng-odp-boun...@lists.linaro.org [mailto:lng-odp-
 boun...@lists.linaro.org] On Behalf Of ext Ciprian Barbu
 Sent: Monday, December 08, 2014 3:59 PM
 To: lng-odp@lists.linaro.org
 Subject: [lng-odp] [PATCH 1/2] api: queue: add odp_queue_sched_prio and
 odp_queue_sched_group

 Signed-off-by: Ciprian Barbu ciprian.ba...@linaro.org
 ---
  platform/linux-generic/include/api/odp_queue.h | 18 ++
  1 file changed, 18 insertions(+)

 diff --git a/platform/linux-generic/include/api/odp_queue.h
 b/platform/linux-generic/include/api/odp_queue.h
 index b8ac4bb..d25fd65 100644
 --- a/platform/linux-generic/include/api/odp_queue.h
 +++ b/platform/linux-generic/include/api/odp_queue.h
 @@ -222,6 +222,24 @@ odp_queue_type_t odp_queue_type(odp_queue_t queue);
  odp_schedule_sync_t odp_queue_sched_type(odp_queue_t queue);

  /**
 + * Queue priority

 Queue schedule priority

 + *
 + * @param queue   Queue handle
 + *
 + * @return Queue priority

 @return Queue schedule priority

 Question: Can these two APIs fail (e.g. invalid queue handle) ? What
 should the return value be if the queue handle is invalid? Maybe
 introduce a ODP_SCHEDULE_PRIO_INVALID?
Is it expected that these functions are called with queue handles that
can reasonably become invalid, e.g. because some other thread has a
legal need for destroying the queues without properly synchronizing
with other threads that might use the queue handles? In such case, we
need to handle invalid queue handles gracefully. But until this is
proven, I prefer to treat all such cases as programming errors and
call abort (e.g. through ODP_ABORT). We can always loosen up the
semantics later if necessary, e.g. define some error code to be
returned for parameter errors.



 + */
 +odp_schedule_prio_t odp_queue_sched_prio(odp_queue_t queue);
 +
 +/**
 + * Queue group

 Queue schedule group

 + *
 + * @param queue   Queue handle
 + *
 + * @return Queue group

 @return Queue schedule group

 + */
 +odp_schedule_group_t odp_queue_sched_group(odp_queue_t queue);
 +
 +/**
   * @}
   */

 --
 1.8.3.2


 ___
 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 mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] ODP classification API questions

2014-12-10 Thread Radu-Andrei Bulie
I have some classification API questions:


1.A packet that was classified on a pmr or pmr_set would finally reach a 
target cos which will be translated in a queue or
a queue group that will be scheduled by the scheduler (frame ordering being 
insured if the queue is synched ATOMIC or ORDERED).
So the queue is selected based on the classification process. What is purpose 
of flow signature and what is the relation with the pmrs/pmr sets and also with 
queues?
Can you give a calling sequence example of using flow signature in the context 
of classification?


2.In the classification document there is a statement:

If multiple PMRs match the implementation MAY define an inherent precedence or 
it MAY be unpredictable as to which PMR will determine the assigned CoS..  
Suppose we have two different platforms; on both of them we set two pmrs - 
ip.src and the other udp.sport (in this order). Due to

the different support and implementation on these platforms, udp.sport could be 
applied first on one of the platforms. Does this mean that we shall have

different functionality depending on the platform(and in the same time 
different output results from platform to platform)?



3.odp_pmr_terms_avail(void) - if this gives the number of pmrs available 
for use in the system what about pmr_sets?(There is no function for this)


4.odp_pmr_match_count(odp_pmr_t pmr_id) - this function gives the number of 
packets that matched a pmr. What about pmr sets? (There is no function for this)





5.odp_cos_set_drop - only configures/changes the existing action on a cos 
to drop(no matter if we have cascade pmrs, pmrs or pmr sets)?  If not, can you 
explain this in the context with the buffer pool drop policy?



6. I see that TCP and UDP header fields such as SPORT, DPORT can be used in 
the PMR rules. Some hardware/software implementation support IP reassembly 
before PMR match can be done. Some implementation may not be able to do that. 
How does ODP reconcile to it? I did not see any text indicating the expected 
behavior if the fragmented packets are received





Regards,



Radu




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


Re: [lng-odp] [PATCH v6 3/3] linux-generic: classification initial implementation

2014-12-10 Thread Bala Manoharan
On Wed, Dec 10, 2014 at 12:54:38PM +0200, Ciprian Barbu wrote:
 On Tue, Dec 9, 2014 at 7:53 PM, Bill Fischofer
 bill.fischo...@linaro.org wrote:
  If you've already received the packet there's not much point in classifying
  it since the output of classification is the queue that the packet should be
  sent to (and the buffer pool it should be stored in for non-linux-generic
  implementations).  In my packet patch I include the odp_packet_parse()
  function but it's an internal API for now since it isn't part of the v0.5
  external spec.  Parsing would be useful independent of classification.
 
 I agree with always parsing packets received from the interface, but
 for real platforms it's not clear to me if it can be an independent
 process, like it can be for linux-generic. Looking at the
 Classification document I see parsing as in integral part of the
 classifier, if I'm reading it correctly.
 
 To be clear, I'm ok to give a go to the patch series as they are, just
 wanted to get an idea of the differences between linux-generic and
 other platforms in regards to classification.
 
 So please add my Reviewed-by to this patch also.

If the application wants to use the feature of classification for 
user-generated packet
it will have to send the packet through a loop back interface and the 
classification engine
can classify the packet and enqueue to correct queue.
The same will be the used in-case for Encrypted packet which gets de-crypted by 
the application
and classification is applied by sending them over a virtual loopback 
interface. 
 
  On Tue, Dec 9, 2014 at 10:47 AM, Ciprian Barbu ciprian.ba...@linaro.org
  wrote:
 
  I have one question that just came to me. See below.
 
  On Tue, Dec 9, 2014 at 4:23 AM, Bill Fischofer
  bill.fischo...@linaro.org wrote:
  
  
   On Mon, Dec 8, 2014 at 6:02 AM, Balasubramanian Manoharan
   bala.manoha...@linaro.org wrote:
  
   The following features are implemented in this classification
   implementation:
   * Attaches PMR, PMR_SET to a Pktio entry
   * Adds classifier object to pktio entry
   * Attaches CoS values for L2 and L3 QoS to a Pktio entry
   * Selects ClassOfService for a packet based on PMR, L2 QoS and L3 QoS
   values
   * Selects a default CoS if packet does not match any of the assigned
   rules
   * Selects an Error CoS for an Error packet
   * Enqueues the packet to the queue associated with the selected CoS
  
   Signed-off-by: Balasubramanian Manoharan bala.manoha...@linaro.org
  
  
   Reviewed-by: Bill Fischofer bill.fischo...@linaro.org
  
  
   ---
   V6: Incorporates review comments from Bill
helper/include/odph_ip.h   |   6 +
platform/linux-generic/include/api/odp.h   |   1 +
.../include/odp_buffer_pool_internal.h |   9 +
.../include/odp_classification_datamodel.h | 201 +
.../include/odp_classification_inlines.h   | 259 ++
.../include/odp_classification_internal.h  | 173 
platform/linux-generic/include/odp_internal.h  |   2 +
.../linux-generic/include/odp_packet_io_internal.h |   2 +
platform/linux-generic/odp_buffer_pool.c   |  10 -
platform/linux-generic/odp_classification.c| 883
   +++--
platform/linux-generic/odp_init.c  |   4 +
platform/linux-generic/odp_packet_io.c |  47 +-
12 files changed, 1498 insertions(+), 99 deletions(-)
create mode 100644
   platform/linux-generic/include/odp_classification_datamodel.h
create mode 100644
   platform/linux-generic/include/odp_classification_inlines.h
create mode 100644
   platform/linux-generic/include/odp_classification_internal.h
  
   diff --git a/helper/include/odph_ip.h b/helper/include/odph_ip.h
   index 2c83c0f..f78724e 100644
   --- a/helper/include/odph_ip.h
   +++ b/helper/include/odph_ip.h
   @@ -35,6 +35,9 @@ extern C {
/** @internal Returns IPv4 header length */
#define ODPH_IPV4HDR_IHL(ver_ihl) ((ver_ihl)  0x0f)
  
   +/** @internal Returns IPv4 DSCP */
   +#define ODPH_IPV4HDR_DSCP(tos) (((tos)  0xfc)  2)
   +
/** @internal Returns IPv4 Don't fragment */
#define ODPH_IPV4HDR_FLAGS_DONT_FRAG(frag_offset)  ((frag_offset) 
   0x4000)
  
   @@ -47,6 +50,9 @@ extern C {
/** @internal Returns true if IPv4 packet is a fragment */
#define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset)  0x3fff)
  
   +/** @internal Returns IPv4 DSCP */
   +#define ODPH_IPV6HDR_DSCP(ver_tc_flow) (uint8_t)ver_tc_flow) 
   0x0fc0)  22)  0xff)
   +
/** IPv4 header */
typedef struct ODP_PACKED {
   uint8_tver_ihl; /** Version / Header length */
   diff --git a/platform/linux-generic/include/api/odp.h
   b/platform/linux-generic/include/api/odp.h
   index 6e4f69e..b7b1ca9 100644
   --- a/platform/linux-generic/include/api/odp.h
   +++ b/platform/linux-generic/include/api/odp.h
   @@ -47,6 +47,7 @@ extern C {
#include odp_packet_flags.h

Re: [lng-odp] Build failure with older GCC versions...

2014-12-10 Thread Robbie King (robking)
Hi Ola, I don't think ODP necessarily needs to support
older versions of GCC, but if the GCC configure finds
is not compatible it would be nice to fail then as opposed
to cryptic build failures.

-Original Message-
From: Ola Liljedahl [mailto:ola.liljed...@linaro.org] 
Sent: Wednesday, December 10, 2014 4:32 AM
To: Robbie King (robking)
Cc: lng-odp-forward (lng-odp@lists.linaro.org)
Subject: Re: [lng-odp] Build failure with older GCC versions...

On 9 December 2014 at 17:48, Robbie King (robking) robk...@cisco.com wrote:
 After cloning tip just now, I found that I couldn’t build the fresh

 workspace due to having GCC 4.6.3 (the C11 changes to the atomics

 bumps minimum GCC up to 4.8 as best I can tell).  I’m not very familiar
GCC 4.7 according to https://gcc.gnu.org/gcc-4.7/changes.html

Is support for older versions of GCC needed?


 with what “./configure” can and can’t do, but it seems we should verify

 the compiler supports these constructs and fail during the configure

 phase (as opposed to build time).



 Thanks,

 Robbie


 ___
 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] linux-generic: pktio: prevent pktin_dequeue storing returned buffer

2014-12-10 Thread Stuart Haslam
The buffer being returned shouldn't be enqueued as this will cause it to
be returned again on the next dequeue, by which point it may have been
freed via the returned reference.

Signed-off-by: Stuart Haslam stuart.has...@arm.com
---
(This code contribution is provided under the terms of agreement LES-LTM-21309)

 platform/linux-generic/odp_packet_io.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index 7e3eca2..451e0f7 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -440,7 +440,9 @@ odp_buffer_hdr_t *pktin_dequeue(queue_entry_t *qentry)
tmp_hdr_tbl[i] = odp_buf_to_hdr(buf);
}
 
-   queue_enq_multi(qentry, tmp_hdr_tbl, pkts);
+   if (pkts  1)
+   queue_enq_multi(qentry, tmp_hdr_tbl[1], pkts-1);
+
buf_hdr = tmp_hdr_tbl[0];
return buf_hdr;
 }
-- 
2.1.1



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


Re: [lng-odp] Build failure with older GCC versions...

2014-12-10 Thread Ola Liljedahl
On 10 December 2014 at 13:46, Robbie King (robking) robk...@cisco.com wrote:
 Hi Ola, I don't think ODP necessarily needs to support
 older versions of GCC, but if the GCC configure finds
 is not compatible it would be nice to fail then as opposed
 to cryptic build failures.
OK. Because I could have added backwards compatibility with degraded
performance but I'd rather not.



 -Original Message-
 From: Ola Liljedahl [mailto:ola.liljed...@linaro.org]
 Sent: Wednesday, December 10, 2014 4:32 AM
 To: Robbie King (robking)
 Cc: lng-odp-forward (lng-odp@lists.linaro.org)
 Subject: Re: [lng-odp] Build failure with older GCC versions...

 On 9 December 2014 at 17:48, Robbie King (robking) robk...@cisco.com wrote:
 After cloning tip just now, I found that I couldn’t build the fresh

 workspace due to having GCC 4.6.3 (the C11 changes to the atomics

 bumps minimum GCC up to 4.8 as best I can tell).  I’m not very familiar
 GCC 4.7 according to https://gcc.gnu.org/gcc-4.7/changes.html

 Is support for older versions of GCC needed?


 with what “./configure” can and can’t do, but it seems we should verify

 the compiler supports these constructs and fail during the configure

 phase (as opposed to build time).



 Thanks,

 Robbie


 ___
 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] [PATCH v6 1/3] helper: odph_tcp header description

2014-12-10 Thread Maxim Uvarov

Patch set is merged,

Thanks!
Maxim.

On 12/08/2014 03:02 PM, Balasubramanian Manoharan wrote:

Adds TCP header description struct odph_tcphdr_t in helper directory.
This structure is used for accessing TCP header information from the packet

Signed-off-by: Balasubramanian Manoharan bala.manoha...@linaro.org
---
V6: Incoporates review comments from Bill
  helper/include/odph_tcp.h  | 81 ++
  platform/linux-generic/include/api/odp_byteorder.h |  7 ++
  2 files changed, 88 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..3992ecf
--- /dev/null
+++ b/helper/include/odph_tcp.h
@@ -0,0 +1,81 @@
+/* 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
+
+/** TCP header */
+typedef struct ODP_PACKED {
+   uint16be_t src_port; /** Source port */
+   uint16be_t dst_port; /** Destination port */
+   uint32be_t seq_no;   /** Sequence number */
+   uint32be_t ack_no;   /** Acknowledgment number */
+   union {
+   uint16be_t doffset_flags;
+#if defined(ODP_BIG_ENDIAN_BITFIELD)
+   struct {
+   uint16be_t rsvd1:8;
+   uint16be_t flags:8; /** TCP flags as a byte */
+   };
+   struct {
+   uint16be_t hl:4;/** Hdr len, in words */
+   uint16be_t rsvd3:4; /** Reserved */
+   uint16be_t cwr:1;
+   uint16be_t ece:1;
+   uint16be_t urg:1;
+   uint16be_t ack:1;
+   uint16be_t psh:1;
+   uint16be_t rst:1;
+   uint16be_t syn:1;
+   uint16be_t fin:1;
+   };
+#elif defined(ODP_LITTLE_ENDIAN_BITFIELD)
+   struct {
+   uint16be_t flags:8;
+   uint16be_t rsvd1:8; /** TCP flags as a byte */
+   };
+   struct {
+   uint16be_t rsvd3:4; /** Reserved */
+   uint16be_t hl:4;/** Hdr len, in words */
+   uint16be_t fin:1;
+   uint16be_t syn:1;
+   uint16be_t rst:1;
+   uint16be_t psh:1;
+   uint16be_t ack:1;
+   uint16be_t urg:1;
+   uint16be_t ece:1;
+   uint16be_t cwr:1;
+   };
+
+#else
+#error Endian BitField order not defined!
+#endif
+   };
+   uint16be_t window; /** Window size */
+   uint16be_t cksm;   /** Checksum */
+   uint16be_t urgptr; /** Urgent pointer */
+} odph_tcphdr_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-generic/include/api/odp_byteorder.h 
b/platform/linux-generic/include/api/odp_byteorder.h
index 79ddd75..5d7cceb 100644
--- a/platform/linux-generic/include/api/odp_byteorder.h
+++ b/platform/linux-generic/include/api/odp_byteorder.h
@@ -19,6 +19,7 @@ extern C {
  #endif
  
  #include endian.h

+#include asm/byteorder.h
  #include odp_std_types.h
  #include odp_compiler.h
  
@@ -45,6 +46,12 @@ extern C {

  /** Little endian byte order */
  #define ODP_LITTLE_ENDIAN __LITTLE_ENDIAN
  
+/** Big endian bit field */

+#define ODP_BIG_ENDIAN_BITFIELD __BIG_ENDIAN_BITFIELD
+
+/** Little endian bit field */
+#define ODP_LITTLE_ENDIAN_BITFIELD __LITTLE_ENDIAN_BITFIELD
+
  /** Selected byte order */
  #if __BYTE_ORDER == __LITTLE_ENDIAN
  #define ODP_BYTE_ORDER ODP_LITTLE_ENDIAN



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


Re: [lng-odp] [PATCHv8 3/6] API: pktio: mac addr get function

2014-12-10 Thread Ciprian Barbu
On Tue, Dec 9, 2014 at 8:09 PM, Victor Kamensky
victor.kamen...@linaro.org wrote:
 On 9 December 2014 at 09:44, Maxim Uvarov maxim.uva...@linaro.org wrote:
 Define API to get MAC address for specific packet i/o and
 implement linux-generic version.

 Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
 Reviewed-by: Petri Savolainen petri.savolai...@linaro.org

 Reviewed-by: Victor Kamensky victor.kamen...@linaro.org

Reviewed-by: Ciprian Barbu ciprian.ba...@linaro.org


 ---
  platform/linux-generic/include/api/odp_packet_io.h | 12 +++
  platform/linux-generic/odp_packet_io.c | 42 
 ++
  2 files changed, 54 insertions(+)

 diff --git a/platform/linux-generic/include/api/odp_packet_io.h 
 b/platform/linux-generic/include/api/odp_packet_io.h
 index 742ea59..63c047c 100644
 --- a/platform/linux-generic/include/api/odp_packet_io.h
 +++ b/platform/linux-generic/include/api/odp_packet_io.h
 @@ -175,6 +175,18 @@ int odp_pktio_promisc_mode_set(odp_pktio_t id, 
 odp_bool_t enable);
  int odp_pktio_promisc_mode(odp_pktio_t id);

  /**
 + * Get the default MAC address of a packet IO interface.
 + *
 + * @param  idODP packet IO handle.
 + * @param[out] mac_addr  Storage for MAC address of the packet IO interface.
 + * @param  addr_size Storage size for the address
 + *
 + * @retval Number of bytes written on success, 0 on failure.
 + */
 +size_t odp_pktio_mac_addr(odp_pktio_t id, void *mac_addr,
 + size_t addr_size);
 +
 +/**
   * @}
   */

 diff --git a/platform/linux-generic/odp_packet_io.c 
 b/platform/linux-generic/odp_packet_io.c
 index 43cf641..541072b 100644
 --- a/platform/linux-generic/odp_packet_io.c
 +++ b/platform/linux-generic/odp_packet_io.c
 @@ -21,6 +21,7 @@

  #include string.h
  #include sys/ioctl.h
 +#include linux/if_arp.h

  typedef struct {
 pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES];
 @@ -650,3 +651,44 @@ int odp_pktio_promisc_mode(odp_pktio_t id)
 else
 return 0;
  }
 +
 +size_t odp_pktio_mac_addr(odp_pktio_t id, void *mac_addr,
 +  size_t addr_size)
 +{
 +   pktio_entry_t *entry;
 +
 +   if (addr_size  ETH_ALEN)
 +   return 0;
 +
 +   entry = get_entry(id);
 +   if (entry == NULL) {
 +   ODP_DBG(pktio entry %d does not exist\n, id);
 +   return 0;
 +   }
 +
 +   lock_entry(entry);
 +
 +   if (odp_unlikely(is_free(entry))) {
 +   unlock_entry(entry);
 +   ODP_DBG(already freed pktio\n);
 +   return -1;
 +   }
 +
 +   switch (entry-s.type) {
 +   case ODP_PKTIO_TYPE_SOCKET_BASIC:
 +   case ODP_PKTIO_TYPE_SOCKET_MMSG:
 +   memcpy(mac_addr, entry-s.pkt_sock.if_mac,
 +  ETH_ALEN);
 +   break;
 +   case ODP_PKTIO_TYPE_SOCKET_MMAP:
 +   memcpy(mac_addr, entry-s.pkt_sock_mmap.if_mac,
 +  ETH_ALEN);
 +   break;
 +   default:
 +   ODP_ABORT(Wrong socket type %d\n, entry-s.type);
 +   }
 +
 +   unlock_entry(entry);
 +
 +   return ETH_ALEN;
 +}
 --
 1.8.5.1.163.gd7aced9


 ___
 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 mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH] validation: XFAIL crypto until API is implemented

2014-12-10 Thread Stuart Haslam
On Tue, Dec 09, 2014 at 08:05:27PM +, Mike Holmes wrote:
 Works around https://bugs.linaro.org/show_bug.cgi?id=975
 
 Signed-off-by: Mike Holmes mike.hol...@linaro.org
 ---
  test/validation/Makefile.am | 4 
  1 file changed, 4 insertions(+)
 
 diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
 index 3670c76..d0b5426 100644
 --- a/test/validation/Makefile.am
 +++ b/test/validation/Makefile.am
 @@ -25,3 +25,7 @@ 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_schedule_SOURCES = odp_schedule.c common/odp_cunit_common.c
 +
 +#For Linux generic the unimplemented crypto API functions break the
 +#regression TODO: https://bugs.linaro.org/show_bug.cgi?id=975
 +XFAIL_TESTS=odp_crypto

This seems a bit coarse grained. It now expects *all* tests in
odp_crypto to fail on *all* platforms, so you could easily mask other
failures that aren't really expected.

How about removing the specific cunit test that fails for now?..
or perhaps adding a special case for unimplemented APIs failures.

Anyhow, what's the problem with the test failing? it's a fairly good
reminder that something needs to be fixed (much harder to ignore than a
bugzilla entry)

-- 
Stuart.


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


Re: [lng-odp] [PATCH] linux-generic: odp_ticketlock.h: implement trylock()

2014-12-10 Thread Bill Fischofer
On Wed, Dec 10, 2014 at 4:55 AM, Ola Liljedahl ola.liljed...@linaro.org
wrote:

 Signed-off-by: Ola Liljedahl ola.liljed...@linaro.org


Reviewed-by: Bill Fischofer bill.fischo...@linaro.org


 ---
 (This document/code contribution attached is provided under the terms of
 agreement LES-LTM-21309)
 Implemented the missing odp_ticketlock_trylock().

  platform/linux-generic/odp_ticketlock.c | 30
 ++
  1 file changed, 30 insertions(+)

 diff --git a/platform/linux-generic/odp_ticketlock.c
 b/platform/linux-generic/odp_ticketlock.c
 index 682b01b..6525786 100644
 --- a/platform/linux-generic/odp_ticketlock.c
 +++ b/platform/linux-generic/odp_ticketlock.c
 @@ -34,6 +34,36 @@ void odp_ticketlock_lock(odp_ticketlock_t *ticketlock)
 odp_spin();
  }

 +int odp_ticketlock_trylock(odp_ticketlock_t *tklock)
 +{
 +   /* We read 'next_ticket' and 'cur_ticket' non-atomically which
 should
 +* not be a problem as they are not independent of each other.
 +* 'cur_ticket' is always = to 'next_ticket' and if we see an
 +* older value of 'cur_ticket', this only means the lock will
 +* look busy and trylock will fail. */
 +   uint32_t next = odp_atomic_load_u32(tklock-next_ticket);
 +   uint32_t cur = odp_atomic_load_u32(tklock-cur_ticket);
 +   /* First check that lock is available and possible to take without
 +* spinning. */
 +   if (next == cur) {
 +   /* Then try to take the lock by incrementing 'next_ticket'
 +* but only if it still has the original value which is
 +* equal to 'cur_ticket'.
 +* We don't have to include 'cur_ticket' in the comparison
 +* because it cannot be larger than 'next_ticket' (only
 +* smaller if the lock is busy).
 +* If CAS fails, it means some other thread intercepted and
 +* took a ticket which means the lock is not available
 +* anymore */
 +   if
 (_odp_atomic_u32_cmp_xchg_strong_mm(tklock-next_ticket,
 +  next,
 +  next + 1,
 +  _ODP_MEMMODEL_ACQ,
 +  _ODP_MEMMODEL_RLX))
 +   return 1;
 +   }
 +   return 0;
 +}

  void odp_ticketlock_unlock(odp_ticketlock_t *ticketlock)
  {
 --
 1.9.1


 ___
 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] [PATCHv7 6/6] cunit: pktio: mtu/promisc/mac

2014-12-10 Thread Mike Holmes
On 8 December 2014 at 09:58, Maxim Uvarov maxim.uva...@linaro.org wrote:

 Add cunit tests for new pktio api:
 - MAC address get;
 - Promisc mode set / test;
 - MTU value set / get;

 Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
 ---
  test/validation/.gitignore  |   3 +-
  test/validation/Makefile.am |   4 +-
  test/validation/odp_pktio.c | 155
 
  3 files changed, 160 insertions(+), 2 deletions(-)
  create mode 100644 test/validation/odp_pktio.c

 diff --git a/test/validation/.gitignore b/test/validation/.gitignore
 index 37e2594..78e18f9 100644
 --- a/test/validation/.gitignore
 +++ b/test/validation/.gitignore
 @@ -1,6 +1,7 @@
  *.log
  *.trs
 +odp_crypto
  odp_init
 +odp_pktio
  odp_queue
 -odp_crypto
  odp_shm
 diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
 index f603036..0b7797e 100644
 --- a/test/validation/Makefile.am
 +++ b/test/validation/Makefile.am
 @@ -5,13 +5,14 @@ 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_pktio
  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)
 +odp_pktio_LDFLAGS = $(AM_LDFLAGS)
  endif

  dist_odp_init_SOURCES = odp_init.c
 @@ -21,3 +22,4 @@ dist_odp_crypto_SOURCES =
 crypto/odp_crypto_test_async_inp.c \
   crypto/odp_crypto_test_rng.c \
   odp_crypto.c
  dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
 +dist_odp_pktio_SOURCES = odp_pktio.c
 diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c
 new file mode 100644
 index 000..db6aaf0
 --- /dev/null
 +++ b/test/validation/odp_pktio.c
 @@ -0,0 +1,155 @@
 +/* Copyright (c) 2014, Linaro Limited
 + * All rights reserved.
 + *
 + * SPDX-License-Identifier:BSD-3-Clause
 + */
 +
 +#include odp.h
 +#include CUnit/Basic.h
 +#include linux/if_ether.h


Does this include break bare metal or other platforms ?
If we take this patch now I think we need to add a TODO that links to a bug
to remove this include


 +
 +#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_SIZE128
 +
 +static odp_pktio_t pktio;
 +
 +static void test_pktio_mac(void)
 +{
 +   unsigned char mac_addr[ETH_ALEN];
 +   size_t mac_len;
 +
 +   mac_len = odp_pktio_mac_addr(pktio, mac_addr, ETH_ALEN);
 +   CU_ASSERT(ETH_ALEN == mac_len);
 +
 +   printf( %X:%X:%X:%X:%X:%X ,
 +  mac_addr[0], mac_addr[1], mac_addr[2],
 +  mac_addr[3], mac_addr[4], mac_addr[5]);
 +
 +   /* Fail case */
 +   mac_len = odp_pktio_mac_addr(pktio, mac_addr, 2);
 +   CU_ASSERT(0 == mac_len);
 +
 +   return;
 +}
 +
 +static void test_pktio_mtu(void)
 +{
 +   int i;
 +   int ret;
 +   int def;
 +
 +   def = odp_pktio_mtu(pktio);
 +   CU_ASSERT(def  0);
 +
 +   for (i = 64; i  9000; i *= 2) {
 +   printf( %d , i);
 +
 +   ret = odp_pktio_set_mtu(pktio, i);
 +   CU_ASSERT(0 == ret);
 +
 +   ret = odp_pktio_mtu(pktio);
 +   CU_ASSERT(i == ret);
 +   }
 +
 +   ret = odp_pktio_set_mtu(pktio, def);
 +   CU_ASSERT(0 == ret);
 +
 +   return;
 +}
 +
 +static void test_pktio_promisc(void)
 +{
 +   int ret;
 +
 +   ret = odp_pktio_promisc_mode_set(pktio, 1);
 +   CU_ASSERT(0 == ret);
 +
 +   /* Check */
 +   ret = odp_pktio_promisc_mode(pktio);
 +   CU_ASSERT(1 == ret);
 +
 +   ret = odp_pktio_promisc_mode_set(pktio, 0);
 +   CU_ASSERT(0 == ret);
 +
 +   /* Check */
 +   ret = odp_pktio_promisc_mode(pktio);
 +   CU_ASSERT(0 == ret);
 +
 +   return;
 +}
 +
 +static CU_TestInfo test_pktio[] = {
 +   {mac, test_pktio_mac },
 +   {mtu, test_pktio_mtu },
 +   {promisc, test_pktio_promisc },
 +   CU_TEST_INFO_NULL,
 +};
 +
 +static CU_SuiteInfo suites[] = {
 +   { Packet I/O , NULL, NULL, NULL, NULL, test_pktio },
 +   CU_SUITE_INFO_NULL,
 +};
 +
 +int main(void)



Main needs to reuse the main in validation/common, it has hooks for
initialization.


 +{
 +   int ret;
 +   odp_shm_t shm;
 +   void *pool_base;
 +   odp_buffer_pool_t pool;
 +
 +   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);
 +
 +   pool_base = odp_shm_addr(shm);
 +   if (!pool_base) {
 + 

Re: [lng-odp] [PATCH] linux-generic: Add space to avoid C++11 literal/identifier warning

2014-12-10 Thread Maxim Uvarov

Merged!

Thanks Simon. Hope to see next products on ODP ;)

Maxim.

On 12/09/2014 11:15 AM, Simon Kågström wrote:

When building with --std=c++0x or --std=c++11, you will otherwise get
this warning:

   C++11 requires a space between literal and identifier [-Wliteral-suffix]
 ODP_VERSION_TO_STR(ODP_VERSION_API_GENERATION) .\

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
  platform/linux-generic/include/api/odp_version.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_version.h 
b/platform/linux-generic/include/api/odp_version.h
index 41708ca..b3b345a 100644
--- a/platform/linux-generic/include/api/odp_version.h
+++ b/platform/linux-generic/include/api/odp_version.h
@@ -56,8 +56,8 @@ extern C {
  
  /** @internal API version string */

  #define ODP_VERSION_API_STR \
-ODP_VERSION_TO_STR(ODP_VERSION_API_GENERATION) .\
-ODP_VERSION_TO_STR(ODP_VERSION_API_MAJOR) .\
+ODP_VERSION_TO_STR(ODP_VERSION_API_GENERATION) . \
+ODP_VERSION_TO_STR(ODP_VERSION_API_MAJOR) . \
  ODP_VERSION_TO_STR(ODP_VERSION_API_MINOR)
  
  /**



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


[lng-odp] [RFC v2 2/3] Add completion event updates to implementation

2014-12-10 Thread Robbie King
Signed-off-by: Robbie King robk...@cisco.com
---
 .../linux-generic/include/odp_crypto_internal.h|  2 +
 platform/linux-generic/odp_crypto.c| 98 ++
 2 files changed, 83 insertions(+), 17 deletions(-)

diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index 04db333..40fe9d2 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -67,6 +67,8 @@ struct odp_crypto_generic_session {
  */
 typedef struct odp_crypto_generic_op_result {
uint32_t magic;
+   void *ctx;
+   odp_packet_t pkt;
odp_crypto_compl_status_t cipher;
odp_crypto_compl_status_t auth;
 } odp_crypto_generic_op_result_t;
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index d3cdec7..5a74831 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -53,6 +53,15 @@ odp_crypto_generic_op_result_t 
*get_op_result_from_buffer(odp_buffer_t buf)
return result;
 }
 
+static odp_crypto_generic_op_result_t *
+get_op_result_from_compl_event(odp_crypto_compl_event_t completion_event)
+{
+   if (completion_event.is_buffer) 
+   return get_op_result_from_buffer(completion_event.buffer);
+   else
+   return completion_event.ptr;
+}
+
 static
 odp_crypto_generic_session_t *alloc_session(void)
 {
@@ -338,13 +347,14 @@ 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)
+odp_crypto_compl_event_t completion_event)
 {
enum crypto_alg_err rc_cipher = ODP_CRYPTO_ALG_ERR_NONE;
enum crypto_alg_err rc_auth = ODP_CRYPTO_ALG_ERR_NONE;
odp_crypto_generic_session_t *session;
odp_crypto_generic_op_result_t *result;
-
+   void *ctx = odp_crypto_get_operation_compl_ctx(completion_event);
+   
*posted = 0;
session = (odp_crypto_generic_session_t *)(intptr_t)params-session;
 
@@ -357,8 +367,8 @@ odp_crypto_operation(odp_crypto_op_params_t *params,
if (odp_unlikely(ODP_PACKET_INVALID == params-out_pkt))
abort();
odp_packet_copy(params-out_pkt, params-pkt);
-   if (completion_event == odp_packet_to_buffer(params-pkt))
-   completion_event =
+   if (completion_event.buffer == 
odp_packet_to_buffer(params-pkt))
+   completion_event.buffer = 
odp_packet_to_buffer(params-out_pkt);
odph_packet_free(params-pkt);
params-pkt = ODP_PACKET_INVALID;
@@ -374,8 +384,10 @@ odp_crypto_operation(odp_crypto_op_params_t *params,
}
 
/* Build Result (no HW so no errors) */
-   result = get_op_result_from_buffer(completion_event);
+   result = get_op_result_from_compl_event(completion_event);
result-magic = OP_RESULT_MAGIC;
+   result-ctx = ctx;
+   result-pkt = params-out_pkt;
result-cipher.alg_err = rc_cipher;
result-cipher.hw_err = ODP_CRYPTO_HW_ERR_NONE;
result-auth.alg_err = rc_auth;
@@ -383,7 +395,7 @@ odp_crypto_operation(odp_crypto_op_params_t *params,
 
/* If specified during creation post event to completion queue */
if (ODP_QUEUE_INVALID != session-compl_queue) {
-   odp_queue_enq(session-compl_queue, completion_event);
+   odp_queue_enq(session-compl_queue, completion_event.buffer);
*posted = 1;
}
return 0;
@@ -422,14 +434,16 @@ odp_hw_random_get(uint8_t *buf, size_t *len, bool 
use_entropy ODP_UNUSED)
return ((1 == rc) ? 0 : -1);
 }
 
+static __thread odp_crypto_generic_op_result_t sync_result;
+
 void
-odp_crypto_get_operation_compl_status(odp_buffer_t completion_event,
+odp_crypto_get_operation_compl_status(odp_crypto_compl_event_t 
completion_event,
  odp_crypto_compl_status_t *auth,
  odp_crypto_compl_status_t *cipher)
 {
odp_crypto_generic_op_result_t *result;
 
-   result = get_op_result_from_buffer(completion_event);
+   result = get_op_result_from_compl_event(completion_event);
 
if (OP_RESULT_MAGIC != result-magic)
abort();
@@ -440,22 +454,72 @@ 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_crypto_compl_event_t completion_event,
+  void *ctx)
 {
-   ODP_UNIMPLEMENTED();
+   odp_crypto_generic_op_result_t *result;
+
+   result = 

Re: [lng-odp] [PATCH 1/2] test: Remove use of ODP_UNUSED

2014-12-10 Thread Maxim Uvarov

Merged,
thanks,
Maxim.

On 12/09/2014 12:02 AM, Mike Holmes wrote:

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
  test/api_test/odp_ring_test.c  | 3 ++-
  test/api_test/odp_shm_test.c   | 3 ++-
  test/api_test/odp_timer_ping.c | 3 ++-
  3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/test/api_test/odp_ring_test.c b/test/api_test/odp_ring_test.c
index 15a9a7d..54398f0 100644
--- a/test/api_test/odp_ring_test.c
+++ b/test/api_test/odp_ring_test.c
@@ -418,7 +418,8 @@ static void *test_ring(void *arg)
  }
  
  
-int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)

+int main(int argc __attribute__((__unused__)),
+char *argv[] __attribute__((__unused__)))
  {
ring_arg_t rarg;
  
diff --git a/test/api_test/odp_shm_test.c b/test/api_test/odp_shm_test.c

index 5cfde7d..5163337 100644
--- a/test/api_test/odp_shm_test.c
+++ b/test/api_test/odp_shm_test.c
@@ -40,7 +40,8 @@ static void *run_thread(void *arg)
return parg;
  }
  
-int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)

+int main(int argc __attribute__((__unused__)),
+char *argv[] __attribute__((__unused__)))
  {
pthrd_arg thrdarg;
odp_shm_t shm;
diff --git a/test/api_test/odp_timer_ping.c b/test/api_test/odp_timer_ping.c
index 48f1885..d958815 100644
--- a/test/api_test/odp_timer_ping.c
+++ b/test/api_test/odp_timer_ping.c
@@ -315,7 +315,8 @@ static int ping_init(int count, char *name[])
return 0;
  }
  
-int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)

+int main(int argc __attribute__((__unused__)),
+char *argv[] __attribute__((__unused__)))
  {
odph_linux_pthread_t thread_tbl[MAX_WORKERS];
ping_arg_t pingarg;



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


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

2014-12-10 Thread Stuart Haslam
On Tue, Dec 09, 2014 at 10:27:51PM +, Bill Fischofer wrote:
 Signed-off-by: Bill Fischofer bill.fischo...@linaro.org
 ---
 v3 of this patch incorporates the following changes based on
 review comments by Petri and Stuart
 
 - Remove use of typeof for C99 compliance
 - Use intmax_t instead of ssize_t for C99 compliance
 - Move odp_buffer_alloc() and odp_buffer_free() back to odp_buffer_pool.h
 - Move odp_buffer_pool() to odp_buffer.h
 - Add @retval white space for .h file readability
 - Rename odp_config.h packet vars per Petri's preference
 - Add odp_config.h vars for controlling buffer alignment
 - Properly support buffer alignment per spec.  Supported range is 8 to 4096
 
 v2 of this patch incorporates comments from Bala and Petri.
 In particular:
 
 - buf_size and buf_align in odp_buffer_pool_param_t are now uint32_t
 - odp_buffer_pool_info_t has been changed to add the shm
 - odp_buffer_pool_info() has been changed to reflect the above change
 - odp_config.h adds config vars for default headroom and tailroom
 - odp_buffer_alloc() and odp_buffer_free() moved to odp_buffer.h
 - miscellaneous comment improvements and typo corrections
 
  example/generator/odp_generator.c  |  19 +-
  example/ipsec/odp_ipsec.c  |  57 +-
  example/l2fwd/odp_l2fwd.c  |  19 +-
  example/odp_example/odp_example.c  |  18 +-
  example/packet/odp_pktio.c |  19 +-
  example/timer/odp_timer_test.c |  13 +-
  platform/linux-generic/include/api/odp_buffer.h|  13 +-
  .../linux-generic/include/api/odp_buffer_pool.h| 117 ++-
  platform/linux-generic/include/api/odp_config.h|  70 ++
  .../linux-generic/include/api/odp_platform_types.h |  12 +
  .../linux-generic/include/api/odp_shared_memory.h  |  10 +-
  .../linux-generic/include/odp_buffer_inlines.h | 150 
  .../linux-generic/include/odp_buffer_internal.h| 152 ++--
  .../include/odp_buffer_pool_internal.h | 351 +++--
  platform/linux-generic/include/odp_internal.h  |   2 +
  .../linux-generic/include/odp_packet_internal.h|  50 +-
  .../linux-generic/include/odp_timer_internal.h |  11 +-
  platform/linux-generic/odp_buffer.c|  33 +-
  platform/linux-generic/odp_buffer_pool.c   | 797 
 +++--
  platform/linux-generic/odp_linux.c |   4 +-
  platform/linux-generic/odp_packet.c|  41 +-
  platform/linux-generic/odp_queue.c |   1 +
  platform/linux-generic/odp_schedule.c  |  20 +-
  platform/linux-generic/odp_timer.c |   3 +-
  test/api_test/odp_timer_ping.c |  19 +-
  test/validation/odp_crypto.c   |  43 +-
  test/validation/odp_queue.c|  19 +-
  27 files changed, 1292 insertions(+), 771 deletions(-)
  create mode 100644 platform/linux-generic/include/odp_buffer_inlines.h
 

[...]

 diff --git a/platform/linux-generic/include/odp_buffer_pool_internal.h 
 b/platform/linux-generic/include/odp_buffer_pool_internal.h
 index e0210bd..88bf0cd 100644
 --- a/platform/linux-generic/include/odp_buffer_pool_internal.h
 +++ b/platform/linux-generic/include/odp_buffer_pool_internal.h
 @@ -19,12 +19,44 @@ extern C {
  #endif
 
  #include odp_std_types.h
 +#include odp_align.h
 +#include odp_align_internal.h
  #include odp_buffer_pool.h
  #include odp_buffer_internal.h
 -#include odp_align.h
  #include odp_hints.h
  #include odp_config.h
  #include odp_debug.h
 +#include odp_shared_memory.h
 +#include odp_atomic.h
 +#include odp_atomic_internal.h
 +#include string.h
 +
 +/**
 + * Buffer initialization routine prototype
 + *
 + * @note Routines of this type MAY be passed as part of the
 + * _odp_buffer_pool_init_t structure to be called whenever a
 + * buffer is allocated to initialize the user metadata
 + * associated with that buffer.
 + */
 +typedef void (_odp_buf_init_t)(odp_buffer_t buf, void *buf_init_arg);
 +
 +/**
 + * Buffer pool initialization parameters
 + * Used to communicate buffer pool initialization options. Internal for now.
 + */
 +typedef struct _odp_buffer_pool_init_t {
 +   size_t udata_size; /** Size of user metadata for each buffer 
 */
 +   _odp_buf_init_t *buf_init; /** Buffer initialization routine to use 
 */
 +   void *buf_init_arg;/** Argument to be passed to buf_init() */
 +} _odp_buffer_pool_init_t; /** Type of buffer initialization struct 
 */
 +
 +/* Local cache for buffer alloc/free acceleration */
 +typedef struct local_cache_t {
 +   odp_buffer_hdr_t *buf_freelist;  /* The local cache */
 +   uint64_t bufallocs;  /* Local buffer alloc count */
 +   uint64_t buffrees;   /* Local buffer free count */
 +} local_cache_t;
 
  /* Use ticketlock instead of spinlock */
  #define POOL_USE_TICKETLOCK
 @@ -39,6 +71,17 @@ extern C {
  #include odp_spinlock.h
  

Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test

2014-12-10 Thread Mike Holmes
Agreed, this is one of the exceptions.

On 10 December 2014 at 04:22, Ola Liljedahl ola.liljed...@linaro.org
wrote:

 On 10 December 2014 at 09:13, Anders Roxell anders.rox...@linaro.org
 wrote:
  On 2014-12-09 17:56, Mike Holmes wrote:
  Has checkpatch issues
 
  Using patch:
  /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
  git am
  /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
Patch applied, building...
  WARNING: line over 80 characters
  #238: FILE: test/validation/odp_timer.c:185:
  + CU_FAIL(Failed to set timer (tooearly/toolate));
 
  total: 0 errors, 1 warnings, 0 checks, 359 lines checked
 
  NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS
 
  0001-test-odp_timer.h-cunit-test.patch has style problems, please
 review.
 
  Do we want to split up this printout?
 No.

  If you're not familiar with the code and you run the validation tests
  and got this failure printed out. I would grep for that failure message
  (the string) in the code too see how I got there.
 Exactly.

  And if we split this string up into multiple rows just to make
  check-patch happy it will make it harder to search after the failure
  message then right?
 Correct.
 And I even think checkpatch for this reason will complain if you split
 the string.

 -- Ola

 
  Cheers,
  Anders




-- 
*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] [PATCHv2] validation: schedule: initial testcases

2014-12-10 Thread Ciprian Barbu
On Tue, Dec 9, 2014 at 11:24 PM, Mike Holmes mike.hol...@linaro.org wrote:
 Need to add .gitignore odp_schedule

 comments inline below


 On 9 December 2014 at 07:49, Ciprian Barbu ciprian.ba...@linaro.org wrote:

 Signed-off-by: Ciprian Barbu ciprian.ba...@linaro.org
 ---
 v2:
  - rebased against ODP tip
  - fixed some bugs
  - added some defines to clearly see the testcase parameters


  test/validation/Makefile.am|   5 +-
  test/validation/odp_schedule.c | 605
 +
  2 files changed, 609 insertions(+), 1 deletion(-)
  create mode 100644 test/validation/odp_schedule.c

 diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
 index 8547085..3670c76 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_schedule
  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_schedule_CFLAGS = $(AM_CFLAGS)
 +odp_schedule_LDFLAGS = $(AM_LDFLAGS)
  endif

  dist_odp_init_SOURCES = odp_init.c
 @@ -22,3 +24,4 @@ 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_schedule_SOURCES = odp_schedule.c common/odp_cunit_common.c
 diff --git a/test/validation/odp_schedule.c
 b/test/validation/odp_schedule.c
 new file mode 100644
 index 000..ce9e9f8
 --- /dev/null
 +++ b/test/validation/odp_schedule.c
 @@ -0,0 +1,605 @@
 +/* Copyright (c) 2014, Linaro Limited
 + * All rights reserved.
 + *
 + * SPDX-License-Identifier: BSD-3-Clause
 + */
 +
 +#include odp.h


 Should be #include odp.h


 +#include odp_cunit_common.h
 +
 +#define MAX_WORKERS32/* Max worker threads */


 should the define be  MAX_WORKER_THREADS and drop the comment?

 +#define MSG_POOL_SIZE   (4*1024*1024)


 You have spaces above and tabs elsewhere


 +#define QUEUES_PER_PRIO16/* Queue per
 priority */


 Does the comment add value - define looks fine


 +#define BUF_SIZE   64
 +#define TEST_NUM_BUFS  100
 +#define MULTI_BUFS_MAX 4 /* Buffer burst size */


 should the define be BUFF_BURST_SIZE then you don't need the comment.

 In general can the comments be dropped if the variable or define has a
 better name ?




 +#define TEST_NUM_BUFS_EXCL 1
 +
 +#define ONE_Q  1
 +#define MANY_QSQUEUES_PER_PRIO
 +#define ONE_PRIO   1
 +#define SCHD_ONE   0
 +#define SCHD_MULTI 1
 +
 +#define GLOBALS_SHM_NAME   test_globals
 +#define MSG_POOL_NAME  msg_pool
 +#define SHM_MSG_POOL_NAME  shm_msg_pool
 +#define SHM_THR_ARGS_NAME  shm_thr_args
 +
 +
 +/* Test global variables */
 +typedef struct {
 +   int core_count;
 +   odp_barrier_t barrier;  /* Barrier for test
 synchronisation */
 +   odp_schedule_prio_t prio;   /* Current prio */
 +   int buf_count;  /* Number of bufs for current prio
 */
 +   odp_spinlock_t count_lock;  /* Used for accessing prio
 counters */
 +   odp_spinlock_t atomic_lock; /* Used verify schedule on ATOMIC
 qs */
 +} test_globals_t;
 +
 +typedef struct ODP_PACKED {
 +   pthrd_arg thrdarg;
 +   odp_schedule_sync_t sync;
 +   int num_queues;
 +   int num_prio;
 +   int num_bufs;   /* Number of buffers to enqueue */

 +   int num_cores;  /* Number of cores used for the
 test */
 +   int multi;  /* Flag for using
 odp_schedule_multi */


 int enable_sched_multi; Makes more sense to readers  - no need of comment?


 +   int excl;   /* Test ATOMIC exclusive access */


 int enable_excl_atomic; Makes more sense to readers   - no need of comment?

 +} thread_args_t;
 +
 +odp_buffer_pool_t pool;
 +
 +static void test_schedule_wait_time(void)
 +{
 +   uint64_t wait_time;
 +
 +   wait_time = odp_schedule_wait_time(0);
 +   CU_ASSERT(wait_time  0);
 +
 +   wait_time = odp_schedule_wait_time(1);
 +   CU_ASSERT(wait_time  0);
 +
 +   wait_time = odp_schedule_wait_time((uint64_t)-1LL);
 +   CU_ASSERT(wait_time  0);
 +}
 +
 +static void test_schedule_num_prio(void)
 +{
 +   int prio;
 +
 +   prio = odp_schedule_num_prio();
 +
 +   CU_ASSERT(prio  0);
 +   /* Just common sense but why not */


 Is this a question to the reviewer ? If it is needed dont comment, 

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

2014-12-10 Thread Bill Fischofer
The merge conflict with the classification code was well know before.  Now
that it's been merged I'll resolve this as part of the v4 patch I'll post
today.  Getting these various conflicts resolved will happen as part of the
merge process.

The agreed-to sequence is:
- classifier
- buffers/packets
- timers, pktio

Thanks.

Bill

On Wed, Dec 10, 2014 at 10:28 AM, Stuart Haslam stuart.has...@arm.com
wrote:

 On Tue, Dec 09, 2014 at 10:27:51PM +, Bill Fischofer wrote:
  Signed-off-by: Bill Fischofer bill.fischo...@linaro.org
  ---
  v3 of this patch incorporates the following changes based on
  review comments by Petri and Stuart
 
  - Remove use of typeof for C99 compliance
  - Use intmax_t instead of ssize_t for C99 compliance
  - Move odp_buffer_alloc() and odp_buffer_free() back to odp_buffer_pool.h
  - Move odp_buffer_pool() to odp_buffer.h
  - Add @retval white space for .h file readability
  - Rename odp_config.h packet vars per Petri's preference
  - Add odp_config.h vars for controlling buffer alignment
  - Properly support buffer alignment per spec.  Supported range is 8 to
 4096
 
  v2 of this patch incorporates comments from Bala and Petri.
  In particular:
 
  - buf_size and buf_align in odp_buffer_pool_param_t are now uint32_t
  - odp_buffer_pool_info_t has been changed to add the shm
  - odp_buffer_pool_info() has been changed to reflect the above change
  - odp_config.h adds config vars for default headroom and tailroom
  - odp_buffer_alloc() and odp_buffer_free() moved to odp_buffer.h
  - miscellaneous comment improvements and typo corrections
 
   example/generator/odp_generator.c  |  19 +-
   example/ipsec/odp_ipsec.c  |  57 +-
   example/l2fwd/odp_l2fwd.c  |  19 +-
   example/odp_example/odp_example.c  |  18 +-
   example/packet/odp_pktio.c |  19 +-
   example/timer/odp_timer_test.c |  13 +-
   platform/linux-generic/include/api/odp_buffer.h|  13 +-
   .../linux-generic/include/api/odp_buffer_pool.h| 117 ++-
   platform/linux-generic/include/api/odp_config.h|  70 ++
   .../linux-generic/include/api/odp_platform_types.h |  12 +
   .../linux-generic/include/api/odp_shared_memory.h  |  10 +-
   .../linux-generic/include/odp_buffer_inlines.h | 150 
   .../linux-generic/include/odp_buffer_internal.h| 152 ++--
   .../include/odp_buffer_pool_internal.h | 351 +++--
   platform/linux-generic/include/odp_internal.h  |   2 +
   .../linux-generic/include/odp_packet_internal.h|  50 +-
   .../linux-generic/include/odp_timer_internal.h |  11 +-
   platform/linux-generic/odp_buffer.c|  33 +-
   platform/linux-generic/odp_buffer_pool.c   | 797
 +++--
   platform/linux-generic/odp_linux.c |   4 +-
   platform/linux-generic/odp_packet.c|  41 +-
   platform/linux-generic/odp_queue.c |   1 +
   platform/linux-generic/odp_schedule.c  |  20 +-
   platform/linux-generic/odp_timer.c |   3 +-
   test/api_test/odp_timer_ping.c |  19 +-
   test/validation/odp_crypto.c   |  43 +-
   test/validation/odp_queue.c|  19 +-
   27 files changed, 1292 insertions(+), 771 deletions(-)
   create mode 100644 platform/linux-generic/include/odp_buffer_inlines.h
 

 [...]

  diff --git a/platform/linux-generic/include/odp_buffer_pool_internal.h
 b/platform/linux-generic/include/odp_buffer_pool_internal.h
  index e0210bd..88bf0cd 100644
  --- a/platform/linux-generic/include/odp_buffer_pool_internal.h
  +++ b/platform/linux-generic/include/odp_buffer_pool_internal.h
  @@ -19,12 +19,44 @@ extern C {
   #endif
 
   #include odp_std_types.h
  +#include odp_align.h
  +#include odp_align_internal.h
   #include odp_buffer_pool.h
   #include odp_buffer_internal.h
  -#include odp_align.h
   #include odp_hints.h
   #include odp_config.h
   #include odp_debug.h
  +#include odp_shared_memory.h
  +#include odp_atomic.h
  +#include odp_atomic_internal.h
  +#include string.h
  +
  +/**
  + * Buffer initialization routine prototype
  + *
  + * @note Routines of this type MAY be passed as part of the
  + * _odp_buffer_pool_init_t structure to be called whenever a
  + * buffer is allocated to initialize the user metadata
  + * associated with that buffer.
  + */
  +typedef void (_odp_buf_init_t)(odp_buffer_t buf, void *buf_init_arg);
  +
  +/**
  + * Buffer pool initialization parameters
  + * Used to communicate buffer pool initialization options. Internal for
 now.
  + */
  +typedef struct _odp_buffer_pool_init_t {
  +   size_t udata_size; /** Size of user metadata for each
 buffer */
  +   _odp_buf_init_t *buf_init; /** Buffer initialization routine to
 use */
  +   void *buf_init_arg;/** Argument to be passed to
 buf_init() */
  +} _odp_buffer_pool_init_t; 

Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test

2014-12-10 Thread Bill Fischofer
Rather than having a list of privileged code that gets special
exceptions, why not just increase the checkpatch line length limit beyond
the arbitrary 80-char limit?  We're not coding on punch cards any more.  :)

Raising the limit to say 100 chars would eliminate the vast majority of
these spurious issues.  I know I've had to torture the buffer code in
several places to comply with this procrustean standard.

Bill

On Wed, Dec 10, 2014 at 10:33 AM, Mike Holmes mike.hol...@linaro.org
wrote:

 Agreed, this is one of the exceptions.

 On 10 December 2014 at 04:22, Ola Liljedahl ola.liljed...@linaro.org
 wrote:

 On 10 December 2014 at 09:13, Anders Roxell anders.rox...@linaro.org
 wrote:
  On 2014-12-09 17:56, Mike Holmes wrote:
  Has checkpatch issues
 
  Using patch:
  /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
  git am
  /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
Patch applied, building...
  WARNING: line over 80 characters
  #238: FILE: test/validation/odp_timer.c:185:
  + CU_FAIL(Failed to set timer (tooearly/toolate));
 
  total: 0 errors, 1 warnings, 0 checks, 359 lines checked
 
  NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS
 
  0001-test-odp_timer.h-cunit-test.patch has style problems, please
 review.
 
  Do we want to split up this printout?
 No.

  If you're not familiar with the code and you run the validation tests
  and got this failure printed out. I would grep for that failure message
  (the string) in the code too see how I got there.
 Exactly.

  And if we split this string up into multiple rows just to make
  check-patch happy it will make it harder to search after the failure
  message then right?
 Correct.
 And I even think checkpatch for this reason will complain if you split
 the string.

 -- Ola

 
  Cheers,
  Anders




 --
 *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 mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v2] odp_ipsec: fix odp_crypto_get_operation_compl_status arg order

2014-12-10 Thread Mike Holmes
This fixes https://bugs.linaro.org/show_bug.cgi?id=714

Signed-off-by: Alexandru Badicioiu alexandru.badici...@linaro.org
Signed-off-by: Mike Holmes mike.hol...@linaro.org
---

This extends a prvious patch from Alex to cover all the cases. With this patch
Coverity no longer produces warnings.

 example/ipsec/odp_ipsec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 76d27c5..dec39e8 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -772,7 +772,7 @@ pkt_disposition_e do_ipsec_in_finish(odp_packet_t pkt,
 
/* Check crypto result */
event = odp_packet_to_buffer(pkt);
-   odp_crypto_get_operation_compl_status(event, cipher_rc, auth_rc);
+   odp_crypto_get_operation_compl_status(event, auth_rc, cipher_rc);
if (!is_crypto_compl_status_ok(cipher_rc))
return PKT_DROP;
if (!is_crypto_compl_status_ok(auth_rc))
@@ -1004,7 +1004,7 @@ pkt_disposition_e do_ipsec_out_finish(odp_packet_t pkt,
 
/* Check crypto result */
event = odp_packet_to_buffer(pkt);
-   odp_crypto_get_operation_compl_status(event, cipher_rc, auth_rc);
+   odp_crypto_get_operation_compl_status(event, auth_rc, cipher_rc);
if (!is_crypto_compl_status_ok(cipher_rc))
return PKT_DROP;
if (!is_crypto_compl_status_ok(auth_rc))
-- 
2.1.0


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


[lng-odp] [PATCHv3] validation: schedule: initial testcases

2014-12-10 Thread Ciprian Barbu
Signed-off-by: Ciprian Barbu ciprian.ba...@linaro.org
---
v3:
 - changes after Mike's review
 - removed duplicate check of end of test in schedule_common_
v2:
 - rebased against ODP tip
 - fixed some bugs
 - added some defines to clearly see the testcase parameters

 test/validation/Makefile.am|   5 +-
 test/validation/odp_schedule.c | 608 +
 2 files changed, 612 insertions(+), 1 deletion(-)
 create mode 100644 test/validation/odp_schedule.c

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 8547085..3670c76 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_schedule
 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_schedule_CFLAGS = $(AM_CFLAGS)
+odp_schedule_LDFLAGS = $(AM_LDFLAGS)
 endif
 
 dist_odp_init_SOURCES = odp_init.c
@@ -22,3 +24,4 @@ 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_schedule_SOURCES = odp_schedule.c common/odp_cunit_common.c
diff --git a/test/validation/odp_schedule.c b/test/validation/odp_schedule.c
new file mode 100644
index 000..faca497
--- /dev/null
+++ b/test/validation/odp_schedule.c
@@ -0,0 +1,608 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include odp.h
+#include odp_cunit_common.h
+
+#define MAX_WORKERS_THREADS32
+#define MSG_POOL_SIZE  (4*1024*1024)
+#define QUEUES_PER_PRIO16
+#define BUF_SIZE   64
+#define TEST_NUM_BUFS  100
+#define BURST_BUF_SIZE 4
+#define TEST_NUM_BUFS_EXCL 1
+
+#define GLOBALS_SHM_NAME   test_globals
+#define MSG_POOL_NAME  msg_pool
+#define SHM_MSG_POOL_NAME  shm_msg_pool
+#define SHM_THR_ARGS_NAME  shm_thr_args
+
+#define ONE_Q  1
+#define MANY_QSQUEUES_PER_PRIO
+
+#define ONE_PRIO   1
+
+#define SCHD_ONE   0
+#define SCHD_MULTI 1
+
+#define DISABLE_EXCL_ATOMIC0
+#define ENABLE_EXCL_ATOMIC 1
+
+
+/* Test global variables */
+typedef struct {
+   int core_count;
+   odp_barrier_t barrier;
+   odp_schedule_prio_t current_prio;
+   int prio_buf_count;
+   odp_spinlock_t count_lock;
+   odp_spinlock_t atomic_lock;
+} test_globals_t;
+
+typedef struct ODP_PACKED {
+   pthrd_arg thrdarg;
+   odp_schedule_sync_t sync;
+   int num_queues;
+   int num_prio;
+   int num_bufs;
+   int num_cores;
+   int enable_schd_multi;
+   int enable_excl_atomic;
+} thread_args_t;
+
+odp_buffer_pool_t pool;
+
+static void test_schedule_wait_time(void)
+{
+   uint64_t wait_time;
+
+   wait_time = odp_schedule_wait_time(0);
+   CU_ASSERT(wait_time  0);
+
+   wait_time = odp_schedule_wait_time(1);
+   CU_ASSERT(wait_time  0);
+
+   wait_time = odp_schedule_wait_time((uint64_t)-1LL);
+   CU_ASSERT(wait_time  0);
+}
+
+static void test_schedule_num_prio(void)
+{
+   int prio;
+
+   prio = odp_schedule_num_prio();
+
+   CU_ASSERT(prio  0);
+   CU_ASSERT(prio == odp_schedule_num_prio());
+}
+
+static void *schedule_common_(void *arg)
+{
+   thread_args_t *args = (thread_args_t *)arg;
+   odp_schedule_sync_t sync;
+   int num_queues, num_prio, num_bufs, num_cores;
+   odp_shm_t shm;
+   test_globals_t *globals;
+
+   sync = args-sync;
+   num_queues = args-num_queues;
+   num_prio = args-num_prio;
+   num_bufs = args-num_bufs;
+   num_cores = args-num_cores;
+
+   shm = odp_shm_lookup(GLOBALS_SHM_NAME);
+   CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
+   globals = odp_shm_addr(shm);
+   CU_ASSERT_FATAL(globals != NULL);
+
+
+   if (num_cores == globals-core_count)
+   odp_barrier_wait(globals-barrier);
+
+   while (1) {
+   odp_buffer_t buf;
+   odp_queue_t from;
+   int num = 0;
+   int locked;
+
+   odp_spinlock_lock(globals-count_lock);
+   if (globals-prio_buf_count ==
+   num_bufs * num_queues * num_prio) {
+   odp_spinlock_unlock(globals-count_lock);
+   break;
+   }
+   odp_spinlock_unlock(globals-count_lock);
+
+   if (args-enable_schd_multi) {
+   odp_buffer_t 

Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test

2014-12-10 Thread Ola Liljedahl
On 10 December 2014 at 17:33, Mike Holmes mike.hol...@linaro.org wrote:
 Agreed, this is one of the exceptions.
It should be possible to fix checkpatch so that it does not warn for
too long lines when that line is a string constant.
I could remove some of the indentation but I assume checkpatch would
complain on that intstead.


 On 10 December 2014 at 04:22, Ola Liljedahl ola.liljed...@linaro.org
 wrote:

 On 10 December 2014 at 09:13, Anders Roxell anders.rox...@linaro.org
 wrote:
  On 2014-12-09 17:56, Mike Holmes wrote:
  Has checkpatch issues
 
  Using patch:
  /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
  git am
  /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
Patch applied, building...
  WARNING: line over 80 characters
  #238: FILE: test/validation/odp_timer.c:185:
  + CU_FAIL(Failed to set timer (tooearly/toolate));
 
  total: 0 errors, 1 warnings, 0 checks, 359 lines checked
 
  NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS
 
  0001-test-odp_timer.h-cunit-test.patch has style problems, please
  review.
 
  Do we want to split up this printout?
 No.

  If you're not familiar with the code and you run the validation tests
  and got this failure printed out. I would grep for that failure message
  (the string) in the code too see how I got there.
 Exactly.

  And if we split this string up into multiple rows just to make
  check-patch happy it will make it harder to search after the failure
  message then right?
 Correct.
 And I even think checkpatch for this reason will complain if you split
 the string.

 -- Ola

 
  Cheers,
  Anders




 --
 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 3/3] test: odp_timer.h: cunit test

2014-12-10 Thread Mike Holmes
On 10 December 2014 at 11:58, Bill Fischofer bill.fischo...@linaro.org
wrote:

 Rather than having a list of privileged code that gets special
 exceptions,


I don't think it is privileged, but as checkpatch docs say, if you have a
good case for ignoring a guideline in a given case - ok


 why not just increase the checkpatch line length limit beyond the
 arbitrary 80-char limit?


We can start that thread again but it went in huge loops last time with no
agreement between large camps on suggestions between 120 or 80 chars



   We're not coding on punch cards any more.  :)


That was the argument form the 120 crowd :)



 Raising the limit to say 100 chars would eliminate the vast majority of
 these spurious issues.  I know I've had to torture the buffer code in
 several places to comply with this procrustean standard.


If we get a quorum - why not change it, I have no issue.



 Bill

 On Wed, Dec 10, 2014 at 10:33 AM, Mike Holmes mike.hol...@linaro.org
 wrote:

 Agreed, this is one of the exceptions.

 On 10 December 2014 at 04:22, Ola Liljedahl ola.liljed...@linaro.org
 wrote:

 On 10 December 2014 at 09:13, Anders Roxell anders.rox...@linaro.org
 wrote:
  On 2014-12-09 17:56, Mike Holmes wrote:
  Has checkpatch issues
 
  Using patch:
  /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
  git am
  /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
Patch applied, building...
  WARNING: line over 80 characters
  #238: FILE: test/validation/odp_timer.c:185:
  + CU_FAIL(Failed to set timer (tooearly/toolate));
 
  total: 0 errors, 1 warnings, 0 checks, 359 lines checked
 
  NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS
 
  0001-test-odp_timer.h-cunit-test.patch has style problems, please
 review.
 
  Do we want to split up this printout?
 No.

  If you're not familiar with the code and you run the validation tests
  and got this failure printed out. I would grep for that failure message
  (the string) in the code too see how I got there.
 Exactly.

  And if we split this string up into multiple rows just to make
  check-patch happy it will make it harder to search after the failure
  message then right?
 Correct.
 And I even think checkpatch for this reason will complain if you split
 the string.

 -- Ola

 
  Cheers,
  Anders




 --
 *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





-- 
*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] [PATCHv2] validation: schedule: initial testcases

2014-12-10 Thread Mike Holmes

 snip

.

  +
  +   for (i = 0; i  prios; i++) {
  +   odp_queue_param_t p;
  +   p.sched.prio  = i;
  +   p.sched.group = ODP_SCHED_GROUP_DEFAULT;
  +
  +   for (j = 0; j  QUEUES_PER_PRIO; j++) {
  +   /* Per sched sync type */
  +   char name[32];
  +   odp_queue_t q;
  +
  +   snprintf(name, sizeof(name), sched_%d_%d_n, i,
  j);
  +   p.sched.sync = ODP_SCHED_SYNC_NONE;
  +   q = odp_queue_create(name, ODP_QUEUE_TYPE_SCHED,
  p);
  +
  +   if (q == ODP_QUEUE_INVALID) {
  +   printf(Schedule queue create
 failed.\n);
  +   return -1;
  +   }
  +
  +   snprintf(name, sizeof(name), sched_%d_%d_a, i,
  j);
  +   p.sched.sync = ODP_SCHED_SYNC_ATOMIC;
  +   q = odp_queue_create(name, ODP_QUEUE_TYPE_SCHED,
  p);
  +
  +   if (q == ODP_QUEUE_INVALID) {
  +   printf(Schedule queue create
 failed.\n);
  +   return -1;
  +   }
  +
  +   snprintf(name, sizeof(name), sched_%d_%d_o, i,
  j);
  +   p.sched.sync = ODP_SCHED_SYNC_ORDERED;
  +   q = odp_queue_create(name, ODP_QUEUE_TYPE_SCHED,
  p);
  +
  +   if (q == ODP_QUEUE_INVALID) {
  +   printf(Schedule queue create
 failed.\n);
  +   return -1;
  +   }
  +   }
  +   }
 
 
  I find the detail obscures the intent with these large loops in loops. A
  comment would help, however better than that could it self document and
 be a
  function that creates a given number of named queues with a name to
 match ?
  Maybe this would become something used by other tests ?

 I don't think I catch your drift, do you mean adding a new function
 that creates a queue? to which you pass sched type and name?



I meant that the program flow would be clearer with a sub routine.

It could be as it is now where it calls ODP functions that describe at a
high level what you intend to happen
and then rather than starting 30 lines code with of loops of loops with

for (i = 0; i  prios; i++) {



It said instead create_quesues_for_tests ( args ..)

Making this overall function easier to comprehend at a glance, just a
suggestion.



 snip ...

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


Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test

2014-12-10 Thread Bill Fischofer
Earlier the debates were pure philosophy.  We now have a substantial body
of code and that sleek and stylish 80-char straightjacket is a lot less
comfortable for daily wear than it may have looked on the rack before we
bought it.

Even a bump to 85 would be a welcome relief.  100 or 132 would be equally
arbitrary and I'd have no problem with removing the limit altogether and
simply relying on the consensus of reviewers as to when lines are too
long.  The point is that there's no real justification for keeping 80
other than well, Linux does it that way.  But ODP is not Linux and we've
already abandoned Linux''s ban on typedefs so obviously we're not
constrained by what Linux does.

Bill

On Wed, Dec 10, 2014 at 11:19 AM, Ola Liljedahl ola.liljed...@linaro.org
wrote:

 VT100 forever!
 However 132 chars per line was supported even back then. I guess only
 PC text consoles are limited to 80 chars.


 On 10 December 2014 at 17:58, Bill Fischofer bill.fischo...@linaro.org
 wrote:
  Rather than having a list of privileged code that gets special
 exceptions,
  why not just increase the checkpatch line length limit beyond the
 arbitrary
  80-char limit?  We're not coding on punch cards any more.  :)
 
  Raising the limit to say 100 chars would eliminate the vast majority of
  these spurious issues.  I know I've had to torture the buffer code in
  several places to comply with this procrustean standard.
 
  Bill
 
  On Wed, Dec 10, 2014 at 10:33 AM, Mike Holmes mike.hol...@linaro.org
  wrote:
 
  Agreed, this is one of the exceptions.
 
  On 10 December 2014 at 04:22, Ola Liljedahl ola.liljed...@linaro.org
  wrote:
 
  On 10 December 2014 at 09:13, Anders Roxell anders.rox...@linaro.org
  wrote:
   On 2014-12-09 17:56, Mike Holmes wrote:
   Has checkpatch issues
  
   Using patch:
  
 /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
   git am
  
 /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox
 Patch applied, building...
   WARNING: line over 80 characters
   #238: FILE: test/validation/odp_timer.c:185:
   + CU_FAIL(Failed to set timer (tooearly/toolate));
  
   total: 0 errors, 1 warnings, 0 checks, 359 lines checked
  
   NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS
  
   0001-test-odp_timer.h-cunit-test.patch has style problems, please
   review.
  
   Do we want to split up this printout?
  No.
 
   If you're not familiar with the code and you run the validation tests
   and got this failure printed out. I would grep for that failure
 message
   (the string) in the code too see how I got there.
  Exactly.
 
   And if we split this string up into multiple rows just to make
   check-patch happy it will make it harder to search after the failure
   message then right?
  Correct.
  And I even think checkpatch for this reason will complain if you split
  the string.
 
  -- Ola
 
  
   Cheers,
   Anders
 
 
 
 
  --
  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 mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCHv2 2/3] RFC: Implemement v0.5 level packet APIs

2014-12-10 Thread Stuart Haslam
On Tue, Dec 09, 2014 at 10:28:09PM +, Bill Fischofer wrote:
 Signed-off-by: Bill Fischofer bill.fischo...@linaro.org
 ---
 v2 reflects review comments by Stuart
 
 - Correct miscelaneous errors in packet parser
 
  example/generator/odp_generator.c  |  82 +-
  example/ipsec/odp_ipsec.c  |  37 +-
  example/ipsec/odp_ipsec_stream.c   |  25 +-
  example/l2fwd/odp_l2fwd.c  |   3 +-
  example/packet/odp_pktio.c |   9 +-
  helper/include/odph_ip.h   |  35 +-
  helper/include/odph_packet.h   |  97 ---
  helper/include/odph_udp.h  |   5 +-
  platform/linux-generic/Makefile.am |   1 -
  platform/linux-generic/include/api/odp_packet.h| 727 
  .../linux-generic/include/api/odp_platform_types.h |  21 +-
  .../linux-generic/include/odp_buffer_inlines.h |  54 ++
  .../linux-generic/include/odp_buffer_internal.h|   1 +
  .../linux-generic/include/odp_packet_internal.h|  81 +-
  platform/linux-generic/odp_crypto.c|  11 +-
  platform/linux-generic/odp_packet.c| 912 
 -
  platform/linux-generic/odp_packet_socket.c |  93 +--
  17 files changed, 1558 insertions(+), 636 deletions(-)
  delete mode 100644 helper/include/odph_packet.h
 

[...]

 +int odp_packet_copydata_out(odp_packet_t pkt, uint32_t offset,
 +   uint32_t len, void *dst)
  {
 -   if (ipv6-next_hdr == ODPH_IPPROTO_ESP ||
 -   ipv6-next_hdr == ODPH_IPPROTO_AH) {
 -   pkt_hdr-input_flags.ipopt = 1;
 -   pkt_hdr-input_flags.ipsec = 1;
 -   return 0;
 +   void *mapaddr;
 +   uint32_t seglen, cpylen;
 +   uint8_t *dstaddr = (uint8_t *)dst;
 +   odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
 +
 +   while (len  0) {
 +   mapaddr = packet_offset_map(pkt_hdr, offset, seglen);
 +   if (mapaddr == NULL)
 +   return -1;
 +   cpylen = len  seglen ? seglen : len;
 +   memcpy(dstaddr, mapaddr, cpylen);
 +   offset  += cpylen;
 +   dstaddr += cpylen;
 +   len -= cpylen;
 }

If seglen winds up being 0 the above loop never exits so I suppose that
should be checked along with the mapaddr.

I just hit this issue when trying to update the pktio unit test to use
this API, it could well be that I screwed something up (still looking)
but even so the infinite loop can be avoided.

[...]

 +int odp_packet_copydata_in(odp_packet_t pkt, uint32_t offset,
 +  uint32_t len, const void *src)
 +{
 +   void *mapaddr;
 +   uint32_t seglen, cpylen;
 +   const uint8_t *srcaddr = (const uint8_t *)src;
 +   odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
 +
 +   while (len  0) {
 +   mapaddr = packet_offset_map(pkt_hdr, offset, seglen);
 +   if (mapaddr == NULL)
 +   return -1;
 +   cpylen = len  seglen ? seglen : len;
 +   memcpy(mapaddr, srcaddr, cpylen);
 +   offset  += cpylen;
 +   srcaddr += cpylen;
 +   len -= cpylen;
 }

Same here.

-- 
Stuart.


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


[lng-odp] [PATCH] validation: inform when tests_global_init fails

2014-12-10 Thread Mike Holmes
Currently a test can fail tests_gloabl_init without indicating to the user.
This patch ensures that an indication is always given via stdout.

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
 test/validation/common/odp_cunit_common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/validation/common/odp_cunit_common.c 
b/test/validation/common/odp_cunit_common.c
index 950bd18..1fc5725 100644
--- a/test/validation/common/odp_cunit_common.c
+++ b/test/validation/common/odp_cunit_common.c
@@ -58,8 +58,10 @@ int main(void)
}
 
ret = tests_global_init();
-   if (ret)
+   if (ret) {
+   printf(tests_global_init fail.\n);
return ret;
+   }
 
CU_set_error_action(CUEA_ABORT);
 
-- 
2.1.0


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


Re: [lng-odp] [PATCHv2 2/3] RFC: Implemement v0.5 level packet APIs

2014-12-10 Thread Stuart Haslam
On Tue, Dec 09, 2014 at 10:28:09PM +, Bill Fischofer wrote:
 Signed-off-by: Bill Fischofer bill.fischo...@linaro.org
 ---
 v2 reflects review comments by Stuart
 
 - Correct miscelaneous errors in packet parser
 
  example/generator/odp_generator.c  |  82 +-
  example/ipsec/odp_ipsec.c  |  37 +-
  example/ipsec/odp_ipsec_stream.c   |  25 +-
  example/l2fwd/odp_l2fwd.c  |   3 +-
  example/packet/odp_pktio.c |   9 +-
  helper/include/odph_ip.h   |  35 +-
  helper/include/odph_packet.h   |  97 ---
  helper/include/odph_udp.h  |   5 +-
  platform/linux-generic/Makefile.am |   1 -
  platform/linux-generic/include/api/odp_packet.h| 727 
  .../linux-generic/include/api/odp_platform_types.h |  21 +-
  .../linux-generic/include/odp_buffer_inlines.h |  54 ++
  .../linux-generic/include/odp_buffer_internal.h|   1 +
  .../linux-generic/include/odp_packet_internal.h|  81 +-
  platform/linux-generic/odp_crypto.c|  11 +-
  platform/linux-generic/odp_packet.c| 912 
 -
  platform/linux-generic/odp_packet_socket.c |  93 +--
  17 files changed, 1558 insertions(+), 636 deletions(-)
  delete mode 100644 helper/include/odph_packet.h


[...]

 +static inline void *packet_offset_map(odp_packet_hdr_t *pkt_hdr,
 + uint32_t offset, uint32_t *seglen)
 +{
 +   if (offset  pkt_hdr-frame_len)
 +   return NULL;
 +
 +   return buffer_map(pkt_hdr-buf_hdr,
 + pkt_hdr-headroom + offset,
 + seglen, pkt_hdr-frame_len);

Shouldn't the last argument be pkt_hdr-headroom + pkt_hdr-frame_len?

-- 
Stuart.


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


Re: [lng-odp] [PATCHv2 2/3] RFC: Implemement v0.5 level packet APIs

2014-12-10 Thread Bill Fischofer
I believe you are correct.  But another notch on your debugging gun.  :)

On Wed, Dec 10, 2014 at 12:42 PM, Stuart Haslam stuart.has...@arm.com
wrote:

 On Tue, Dec 09, 2014 at 10:28:09PM +, Bill Fischofer wrote:
  Signed-off-by: Bill Fischofer bill.fischo...@linaro.org
  ---
  v2 reflects review comments by Stuart
 
  - Correct miscelaneous errors in packet parser
 
   example/generator/odp_generator.c  |  82 +-
   example/ipsec/odp_ipsec.c  |  37 +-
   example/ipsec/odp_ipsec_stream.c   |  25 +-
   example/l2fwd/odp_l2fwd.c  |   3 +-
   example/packet/odp_pktio.c |   9 +-
   helper/include/odph_ip.h   |  35 +-
   helper/include/odph_packet.h   |  97 ---
   helper/include/odph_udp.h  |   5 +-
   platform/linux-generic/Makefile.am |   1 -
   platform/linux-generic/include/api/odp_packet.h| 727
 
   .../linux-generic/include/api/odp_platform_types.h |  21 +-
   .../linux-generic/include/odp_buffer_inlines.h |  54 ++
   .../linux-generic/include/odp_buffer_internal.h|   1 +
   .../linux-generic/include/odp_packet_internal.h|  81 +-
   platform/linux-generic/odp_crypto.c|  11 +-
   platform/linux-generic/odp_packet.c| 912
 -
   platform/linux-generic/odp_packet_socket.c |  93 +--
   17 files changed, 1558 insertions(+), 636 deletions(-)
   delete mode 100644 helper/include/odph_packet.h
 

 [...]

  +static inline void *packet_offset_map(odp_packet_hdr_t *pkt_hdr,
  + uint32_t offset, uint32_t *seglen)
  +{
  +   if (offset  pkt_hdr-frame_len)
  +   return NULL;
  +
  +   return buffer_map(pkt_hdr-buf_hdr,
  + pkt_hdr-headroom + offset,
  + seglen, pkt_hdr-frame_len);

 Shouldn't the last argument be pkt_hdr-headroom + pkt_hdr-frame_len?

 --
 Stuart.


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


Re: [lng-odp] [PATCHv2 2/3] RFC: Implemement v0.5 level packet APIs

2014-12-10 Thread Bill Fischofer
There are a few other places where this issue arises in similar packet
calls.  I'll address them all in v3.  Thanks.

On Wed, Dec 10, 2014 at 12:51 PM, Bill Fischofer bill.fischo...@linaro.org
wrote:

 I believe you are correct.  But another notch on your debugging gun.  :)

 On Wed, Dec 10, 2014 at 12:42 PM, Stuart Haslam stuart.has...@arm.com
 wrote:

 On Tue, Dec 09, 2014 at 10:28:09PM +, Bill Fischofer wrote:
  Signed-off-by: Bill Fischofer bill.fischo...@linaro.org
  ---
  v2 reflects review comments by Stuart
 
  - Correct miscelaneous errors in packet parser
 
   example/generator/odp_generator.c  |  82 +-
   example/ipsec/odp_ipsec.c  |  37 +-
   example/ipsec/odp_ipsec_stream.c   |  25 +-
   example/l2fwd/odp_l2fwd.c  |   3 +-
   example/packet/odp_pktio.c |   9 +-
   helper/include/odph_ip.h   |  35 +-
   helper/include/odph_packet.h   |  97 ---
   helper/include/odph_udp.h  |   5 +-
   platform/linux-generic/Makefile.am |   1 -
   platform/linux-generic/include/api/odp_packet.h| 727
 
   .../linux-generic/include/api/odp_platform_types.h |  21 +-
   .../linux-generic/include/odp_buffer_inlines.h |  54 ++
   .../linux-generic/include/odp_buffer_internal.h|   1 +
   .../linux-generic/include/odp_packet_internal.h|  81 +-
   platform/linux-generic/odp_crypto.c|  11 +-
   platform/linux-generic/odp_packet.c| 912
 -
   platform/linux-generic/odp_packet_socket.c |  93 +--
   17 files changed, 1558 insertions(+), 636 deletions(-)
   delete mode 100644 helper/include/odph_packet.h
 

 [...]

  +static inline void *packet_offset_map(odp_packet_hdr_t *pkt_hdr,
  + uint32_t offset, uint32_t *seglen)
  +{
  +   if (offset  pkt_hdr-frame_len)
  +   return NULL;
  +
  +   return buffer_map(pkt_hdr-buf_hdr,
  + pkt_hdr-headroom + offset,
  + seglen, pkt_hdr-frame_len);

 Shouldn't the last argument be pkt_hdr-headroom + pkt_hdr-frame_len?

 --
 Stuart.



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


[lng-odp] [PATCH] api: align: remove internal macros from API

2014-12-10 Thread Mike Holmes
Move remaining API macros that were tagged @internal to the internal
header file.

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
 platform/linux-generic/include/api/odp_align.h | 44 --
 .../linux-generic/include/odp_align_internal.h | 21 +++
 2 files changed, 21 insertions(+), 44 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_align.h 
b/platform/linux-generic/include/api/odp_align.h
index 6ec5a0a..741f9fd 100644
--- a/platform/linux-generic/include/api/odp_align.h
+++ b/platform/linux-generic/include/api/odp_align.h
@@ -79,50 +79,6 @@ extern C {
 /** Page size */
 #define ODP_PAGE_SIZE   4096
 
-
-/*
- * Round up
- */
-
-
-/**
- * @internal
- * Round up pointer 'x' to alignment 'align'
- */
-#define ODP_ALIGN_ROUNDUP_PTR(x, align)\
-   ((void *)ODP_ALIGN_ROUNDUP((uintptr_t)(x), (uintptr_t)(align)))
-
-
-/**
- * @internal
- * Round up pointer 'x' to cache line size alignment
- */
-#define ODP_CACHE_LINE_SIZE_ROUNDUP_PTR(x)\
-   ((void *)ODP_CACHE_LINE_SIZE_ROUNDUP((uintptr_t)(x)))
-
-
-
-/*
- * Round down
- */
-
-
-/**
- * @internal
- * Round down pointer 'x' to 'align' alignment, which is a power of two
- */
-#define ODP_ALIGN_ROUNDDOWN_PTR_POWER_2(x, align)\
-((void *)ODP_ALIGN_ROUNDDOWN_POWER_2((uintptr_t)(x), (uintptr_t)(align)))
-
-
-/**
- * @internal
- * Round down pointer 'x' to cache line size alignment
- */
-#define ODP_CACHE_LINE_SIZE_ROUNDDOWN_PTR(x)\
-   ((void *)ODP_CACHE_LINE_SIZE_ROUNDDOWN((uintptr_t)(x)))
-
-
 /** Defines type/struct/variable to be cache line size aligned */
 #define ODP_ALIGNED_CACHE   ODP_ALIGNED(ODP_CACHE_LINE_SIZE)
 
diff --git a/platform/linux-generic/include/odp_align_internal.h 
b/platform/linux-generic/include/odp_align_internal.h
index 498a7a9..068f0ca 100644
--- a/platform/linux-generic/include/odp_align_internal.h
+++ b/platform/linux-generic/include/odp_align_internal.h
@@ -43,6 +43,13 @@ extern C {
 
 /**
  * @internal
+ * Round up pointer 'x' to cache line size alignment
+ */
+#define ODP_CACHE_LINE_SIZE_ROUNDUP_PTR(x)\
+   ((void *)ODP_CACHE_LINE_SIZE_ROUNDUP((uintptr_t)(x)))
+
+/**
+ * @internal
  * Round up 'x' to cache line size alignment
  */
 #define ODP_CACHE_LINE_SIZE_ROUNDUP(x)\
@@ -72,6 +79,20 @@ extern C {
 #define ODP_CACHE_LINE_SIZE_ROUNDDOWN(x)\
ODP_ALIGN_ROUNDDOWN_POWER_2(x, ODP_CACHE_LINE_SIZE)
 
+/**
+ * @internal
+ * Round down pointer 'x' to 'align' alignment, which is a power of two
+ */
+#define ODP_ALIGN_ROUNDDOWN_PTR_POWER_2(x, align)\
+   ((void *)ODP_ALIGN_ROUNDDOWN_POWER_2((uintptr_t)(x),\
+   (uintptr_t)(align)))
+/**
+ * @internal
+ * Round down pointer 'x' to cache line size alignment
+ */
+#define ODP_CACHE_LINE_SIZE_ROUNDDOWN_PTR(x)\
+   ((void *)ODP_CACHE_LINE_SIZE_ROUNDDOWN((uintptr_t)(x)))
+
 /*
  * Check align
  */
-- 
2.1.0


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


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

2014-12-10 Thread Mike Holmes
ping

On 1 December 2014 at 10:35, Mike Holmes mike.hol...@linaro.org wrote:

 Signed-off-by: Mike Holmes mike.hol...@linaro.org
 ---
  api_guide_lines.dox | 5 +
  1 file changed, 5 insertions(+)

 diff --git a/api_guide_lines.dox b/api_guide_lines.dox
 index be23e9a..4cfe088 100644
 --- a/api_guide_lines.dox
 +++ b/api_guide_lines.dox
 @@ -144,6 +144,11 @@ 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 _.
 +- 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.

 --
 2.1.0




-- 
*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] [PATCHv2 2/3] RFC: Implemement v0.5 level packet APIs

2014-12-10 Thread Ola Liljedahl
On 10 December 2014 at 19:40, Bill Fischofer bill.fischo...@linaro.org wrote:
 Good point on the parser since it's validating as well as parsing the
 packet.  I'll add those checks in v3.  For the other case, these are ODP
 owned and maintained data structures and are assumed to be valid.  In
 particular, we don't support zero-length segments so the returned seglen
 must be non-zero here.
Could always use an assert on that.

  If a bogus handle is passed then of course results
 are undefined, but that's a separate issue.

 On Wed, Dec 10, 2014 at 12:07 PM, Stuart Haslam stuart.has...@arm.com
 wrote:

 On Tue, Dec 09, 2014 at 10:28:09PM +, Bill Fischofer wrote:
  Signed-off-by: Bill Fischofer bill.fischo...@linaro.org
  ---
  v2 reflects review comments by Stuart
 
  - Correct miscelaneous errors in packet parser
 
   example/generator/odp_generator.c  |  82 +-
   example/ipsec/odp_ipsec.c  |  37 +-
   example/ipsec/odp_ipsec_stream.c   |  25 +-
   example/l2fwd/odp_l2fwd.c  |   3 +-
   example/packet/odp_pktio.c |   9 +-
   helper/include/odph_ip.h   |  35 +-
   helper/include/odph_packet.h   |  97 ---
   helper/include/odph_udp.h  |   5 +-
   platform/linux-generic/Makefile.am |   1 -
   platform/linux-generic/include/api/odp_packet.h| 727
  
   .../linux-generic/include/api/odp_platform_types.h |  21 +-
   .../linux-generic/include/odp_buffer_inlines.h |  54 ++
   .../linux-generic/include/odp_buffer_internal.h|   1 +
   .../linux-generic/include/odp_packet_internal.h|  81 +-
   platform/linux-generic/odp_crypto.c|  11 +-
   platform/linux-generic/odp_packet.c| 912
  -
   platform/linux-generic/odp_packet_socket.c |  93 +--
   17 files changed, 1558 insertions(+), 636 deletions(-)
   delete mode 100644 helper/include/odph_packet.h
 

 [...]

  +int odp_packet_copydata_out(odp_packet_t pkt, uint32_t offset,
  +   uint32_t len, void *dst)
   {
  -   if (ipv6-next_hdr == ODPH_IPPROTO_ESP ||
  -   ipv6-next_hdr == ODPH_IPPROTO_AH) {
  -   pkt_hdr-input_flags.ipopt = 1;
  -   pkt_hdr-input_flags.ipsec = 1;
  -   return 0;
  +   void *mapaddr;
  +   uint32_t seglen, cpylen;
  +   uint8_t *dstaddr = (uint8_t *)dst;
  +   odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
  +
  +   while (len  0) {
  +   mapaddr = packet_offset_map(pkt_hdr, offset, seglen);
  +   if (mapaddr == NULL)
  +   return -1;
  +   cpylen = len  seglen ? seglen : len;
  +   memcpy(dstaddr, mapaddr, cpylen);
  +   offset  += cpylen;
  +   dstaddr += cpylen;
  +   len -= cpylen;
  }

 If seglen winds up being 0 the above loop never exits so I suppose that
 should be checked along with the mapaddr.

 I just hit this issue when trying to update the pktio unit test to use
 this API, it could well be that I screwed something up (still looking)
 but even so the infinite loop can be avoided.

 [...]

  +int odp_packet_copydata_in(odp_packet_t pkt, uint32_t offset,
  +  uint32_t len, const void *src)
  +{
  +   void *mapaddr;
  +   uint32_t seglen, cpylen;
  +   const uint8_t *srcaddr = (const uint8_t *)src;
  +   odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
  +
  +   while (len  0) {
  +   mapaddr = packet_offset_map(pkt_hdr, offset, seglen);
  +   if (mapaddr == NULL)
  +   return -1;
  +   cpylen = len  seglen ? seglen : len;
  +   memcpy(mapaddr, srcaddr, cpylen);
  +   offset  += cpylen;
  +   srcaddr += cpylen;
  +   len -= cpylen;
  }

 Same here.

 --
 Stuart.



 ___
 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] [PATCH] validation:add atomic test in odp syncronizers

2014-12-10 Thread Mike Holmes
I think odp_syne would be better as odp_sync  throughout the patch

Does Barrys patch cover atomics in an overlapping way, or do we have both
as separate suites ? I think this one is much more sunny day as we had
originally planned.
Mario were you able to make the final changes to create a patch for tip
from Barrys files, do we need to wait until we can see that patch along
side this one ?

Mike


On 9 December 2014 at 22:19, Yan Sonming yan.songm...@linaro.org wrote:

 Remove odp_atomic_test in test/api_test and  add the odp_atomic_test
 to test/validation as one part of odp syncronizers test


syncronizers



 Signed-off-by: Yan Songming yan.songm...@linaro.org
 ---
  test/api_test/Makefile.am  |   5 +-
  test/api_test/odp_atomic_test.c| 299
 -
  test/api_test/odp_atomic_test.h|  51 --
  test/api_test/odp_common.c |   1 -
  test/validation/.gitignore |   1 +
  test/validation/Makefile.am|   6 +-
  test/validation/odp_syne.c |  15 ++
  test/validation/syne/odp_test_atomic.c | 258 
  test/validation/syne/odp_test_atomic.h |  14 ++
  9 files changed, 294 insertions(+), 356 deletions(-)
  delete mode 100644 test/api_test/odp_atomic_test.c
  delete mode 100644 test/api_test/odp_atomic_test.h
  create mode 100644 test/validation/odp_syne.c
  create mode 100644 test/validation/syne/odp_test_atomic.c
  create mode 100644 test/validation/syne/odp_test_atomic.h

 diff --git a/test/api_test/Makefile.am b/test/api_test/Makefile.am
 index 74e8612..ce301ce 100644
 --- a/test/api_test/Makefile.am
 +++ b/test/api_test/Makefile.am
 @@ -1,18 +1,15 @@
  include $(top_srcdir)/test/Makefile.inc

 -bin_PROGRAMS = odp_atomic odp_shm odp_ring odp_timer_ping
 +bin_PROGRAMS = odp_shm odp_ring odp_timer_ping

 -odp_atomic_CFLAGS = $(AM_CFLAGS)
  odp_shm_CFLAGS = $(AM_CFLAGS)
  odp_ring_CFLAGS = $(AM_CFLAGS)
  odp_timer_ping_CFLAGS = $(AM_CFLAGS)

 -odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static
  odp_shm_LDFLAGS = $(AM_LDFLAGS) -static
  odp_ring_LDFLAGS = $(AM_LDFLAGS) -static
  odp_timer_ping_LDFLAGS = $(AM_LDFLAGS) -static

 -dist_odp_atomic_SOURCES = odp_atomic_test.c odp_common.c
  dist_odp_shm_SOURCES = odp_shm_test.c odp_common.c
  dist_odp_ring_SOURCES = odp_ring_test.c odp_common.c
  dist_odp_timer_ping_SOURCES = odp_timer_ping.c odp_common.c
 diff --git a/test/api_test/odp_atomic_test.c
 b/test/api_test/odp_atomic_test.c
 deleted file mode 100644
 index 5563606..000
 --- a/test/api_test/odp_atomic_test.c
 +++ /dev/null
 @@ -1,299 +0,0 @@
 -/* Copyright (c) 2013, Linaro Limited
 - * All rights reserved.
 - *
 - * SPDX-License-Identifier: BSD-3-Clause
 - */
 -
 -#include string.h
 -#include sys/time.h
 -#include odp_common.h
 -#include odp_atomic_test.h
 -#include test_debug.h
 -
 -static odp_atomic_u32_t a32u;
 -static odp_atomic_u64_t a64u;
 -
 -static odp_barrier_t barrier;
 -
 -static const char * const test_name[] = {
 -   dummy,
 -   test atomic all (add/sub/inc/dec) on 32- and 64-bit atomic ints,
 -   test atomic inc/dec of 32-bit atomic int,
 -   test atomic add/sub of 32-bit atomic int,
 -   test atomic inc/dec of 64-bit atomic int,
 -   test atomic add/sub of 64-bit atomic int
 -};
 -
 -static struct timeval tv0[MAX_WORKERS], tv1[MAX_WORKERS];
 -
 -static void usage(void)
 -{
 -   printf(\n./odp_atomic -t testcase [-n numthreads]\n\n
 -  \ttestcase is\n
 -  \t\t1 - Test all (inc/dec/add/sub on 32/64-bit atomic
 ints)\n
 -  \t\t2 - Test inc/dec of 32-bit atomic int\n
 -  \t\t3 - Test add/sub of 32-bit atomic int\n
 -  \t\t4 - Test inc/dec of 64-bit atomic int\n
 -  \t\t5 - Test add/sub of 64-bit atomic int\n
 -  \t\t-n 1 - 31 - no of threads to start\n
 -  \t\tif user doesn't specify this option, then\n
 -  \t\tno of threads created is equivalent to no of cores\n
 -  \t\tavailable in the system\n
 -  \tExample usage:\n
 -  \t\t./odp_atomic -t 2\n
 -  \t\t./odp_atomic -t 3 -n 12\n);
 -}
 -
 -
 -void test_atomic_inc_u32(void)
 -{
 -   int i;
 -
 -   for (i = 0; i  CNT; i++)
 -   odp_atomic_inc_u32(a32u);
 -}
 -
 -void test_atomic_inc_64(void)
 -{
 -   int i;
 -
 -   for (i = 0; i  CNT; i++)
 -   odp_atomic_inc_u64(a64u);
 -}
 -
 -void test_atomic_dec_u32(void)
 -{
 -   int i;
 -
 -   for (i = 0; i  CNT; i++)
 -   odp_atomic_dec_u32(a32u);
 -}
 -
 -void test_atomic_dec_64(void)
 -{
 -   int i;
 -
 -   for (i = 0; i  CNT; i++)
 -   odp_atomic_dec_u64(a64u);
 -}
 -
 -void test_atomic_add_u32(void)
 -{
 -   int i;
 -
 -   for (i = 0; i  (CNT / ADD_SUB_CNT); i++)
 -   odp_atomic_fetch_add_u32(a32u, ADD_SUB_CNT);
 -}
 -
 -void test_atomic_add_64(void)
 -{
 -   int i;
 -
 -   for (i = 0; i  

Re: [lng-odp] [PATCH] fix loop

2014-12-10 Thread Mike Holmes
Patch does not describe why the loop needed fixing, the message also does
not indicate if it was an example, test or implementation change.

On 8 December 2014 at 09:58, Maxim Uvarov maxim.uva...@linaro.org wrote:

 Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
 ---
  platform/linux-generic/odp_packet_io.c | 58
 --
  1 file changed, 13 insertions(+), 45 deletions(-)

 diff --git a/platform/linux-generic/odp_packet_io.c
 b/platform/linux-generic/odp_packet_io.c
 index 833725e..4399ef9 100644
 --- a/platform/linux-generic/odp_packet_io.c
 +++ b/platform/linux-generic/odp_packet_io.c
 @@ -155,33 +155,6 @@ static int free_pktio_entry(odp_pktio_t id)
 return 0;
  }

 -static int find_loop_dev(char loop[IFNAMSIZ])
 -{
 -   struct ifaddrs *ifap, *ifa;
 -
 -   getifaddrs(ifap);
 -
 -   for (ifa = ifap; ifa; ifa = ifa-ifa_next) {
 -   if (ifa-ifa_addr 
 -   ifa-ifa_addr-sa_family == AF_INET) {
 -   if ((ifa-ifa_flags  (IFF_LOOPBACK |
 - IFF_POINTOPOINT |
 - IFF_NOARP)) ||
 -   (!memcmp(ifa-ifa_name, lxcbr, 5)) ||
 -   (!memcmp(ifa-ifa_name, wlan, 4)) ||
 -   (!memcmp(ifa-ifa_name, veth, 4)) ||
 -   (!memcmp(ifa-ifa_name, virbr, 5)))
 -   continue;
 -   memcpy(loop, ifa-ifa_name, IFNAMSIZ);
 -   freeifaddrs(ifap);
 -   return 0;
 -   }
 -   }
 -
 -   freeifaddrs(ifap);
 -   return -1;
 -}
 -
  odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool)
  {
 odp_pktio_t id;
 @@ -203,26 +176,21 @@ odp_pktio_t odp_pktio_open(const char *dev,
 odp_buffer_pool_t pool)
  */
 loop_hint = getenv(ODP_PKTIO_LOOPDEV);
 if (!strcmp(dev, loop)) {
 -   if (loop_hint  (strlen(loop_hint)  0)) {
 -   if (strlen(loop_hint) = IFNAMSIZ) {
 -   ODP_ERR(pktio name %s is too big, limit
 is %d bytes\n,
 -   loop_hint, IFNAMSIZ);
 -   return ODP_PKTIO_INVALID;
 -   }
 +   if (!loop_hint || (strlen(loop_hint) == 0)) {
 +   ODP_ERR(Set loop with ODP_PKTIO_LOOPDEV=ethX\n);
 +   return ODP_PKTIO_INVALID;
 +   }

 -   memset(loop, 0, IFNAMSIZ);
 -   memcpy(loop, loop_hint, strlen(loop_hint));
 -   dev = loop;
 -   ODP_DBG(pktio using %s as loopback device\n,
 loop_hint);
 -   } else {
 -   if (!find_loop_dev(loop)) {
 -   ODP_DBG(pktio rename loop to %s\n, loop);
 -   dev = loop;
 -   } else {
 -   ODP_DBG(pktio: No suitable netdev.\n);
 -   return ODP_PKTIO_INVALID;
 -   }
 +   if (strlen(loop_hint) = IFNAMSIZ) {
 +   ODP_ERR(pktio name %s is too big, limit is %d
 bytes\n,
 +   loop_hint, IFNAMSIZ);
 +   return ODP_PKTIO_INVALID;
 }
 +
 +   memset(loop, 0, IFNAMSIZ);
 +   memcpy(loop, loop_hint, strlen(loop_hint));
 +   dev = loop;
 +   ODP_DBG(pktio using %s as loopback device\n, loop_hint);
 }

 id = alloc_lock_pktio_entry();
 --
 1.8.5.1.163.gd7aced9


 ___
 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] [PATCHv2 2/3] RFC: Implemement v0.5 level packet APIs

2014-12-10 Thread Bill Fischofer
Since these are internal APIs I'd rather do the checking in the called
routine once rather than having every caller clutter the code with
asserts.  But point taken.

On Wed, Dec 10, 2014 at 1:34 PM, Ola Liljedahl ola.liljed...@linaro.org
wrote:

 On 10 December 2014 at 19:40, Bill Fischofer bill.fischo...@linaro.org
 wrote:
  Good point on the parser since it's validating as well as parsing the
  packet.  I'll add those checks in v3.  For the other case, these are ODP
  owned and maintained data structures and are assumed to be valid.  In
  particular, we don't support zero-length segments so the returned seglen
  must be non-zero here.
 Could always use an assert on that.

   If a bogus handle is passed then of course results
  are undefined, but that's a separate issue.
 
  On Wed, Dec 10, 2014 at 12:07 PM, Stuart Haslam stuart.has...@arm.com
  wrote:
 
  On Tue, Dec 09, 2014 at 10:28:09PM +, Bill Fischofer wrote:
   Signed-off-by: Bill Fischofer bill.fischo...@linaro.org
   ---
   v2 reflects review comments by Stuart
  
   - Correct miscelaneous errors in packet parser
  
example/generator/odp_generator.c  |  82 +-
example/ipsec/odp_ipsec.c  |  37 +-
example/ipsec/odp_ipsec_stream.c   |  25 +-
example/l2fwd/odp_l2fwd.c  |   3 +-
example/packet/odp_pktio.c |   9 +-
helper/include/odph_ip.h   |  35 +-
helper/include/odph_packet.h   |  97 ---
helper/include/odph_udp.h  |   5 +-
platform/linux-generic/Makefile.am |   1 -
platform/linux-generic/include/api/odp_packet.h| 727
   
.../linux-generic/include/api/odp_platform_types.h |  21 +-
.../linux-generic/include/odp_buffer_inlines.h |  54 ++
.../linux-generic/include/odp_buffer_internal.h|   1 +
.../linux-generic/include/odp_packet_internal.h|  81 +-
platform/linux-generic/odp_crypto.c|  11 +-
platform/linux-generic/odp_packet.c| 912
   -
platform/linux-generic/odp_packet_socket.c |  93 +--
17 files changed, 1558 insertions(+), 636 deletions(-)
delete mode 100644 helper/include/odph_packet.h
  
 
  [...]
 
   +int odp_packet_copydata_out(odp_packet_t pkt, uint32_t offset,
   +   uint32_t len, void *dst)
{
   -   if (ipv6-next_hdr == ODPH_IPPROTO_ESP ||
   -   ipv6-next_hdr == ODPH_IPPROTO_AH) {
   -   pkt_hdr-input_flags.ipopt = 1;
   -   pkt_hdr-input_flags.ipsec = 1;
   -   return 0;
   +   void *mapaddr;
   +   uint32_t seglen, cpylen;
   +   uint8_t *dstaddr = (uint8_t *)dst;
   +   odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
   +
   +   while (len  0) {
   +   mapaddr = packet_offset_map(pkt_hdr, offset, seglen);
   +   if (mapaddr == NULL)
   +   return -1;
   +   cpylen = len  seglen ? seglen : len;
   +   memcpy(dstaddr, mapaddr, cpylen);
   +   offset  += cpylen;
   +   dstaddr += cpylen;
   +   len -= cpylen;
   }
 
  If seglen winds up being 0 the above loop never exits so I suppose that
  should be checked along with the mapaddr.
 
  I just hit this issue when trying to update the pktio unit test to use
  this API, it could well be that I screwed something up (still looking)
  but even so the infinite loop can be avoided.
 
  [...]
 
   +int odp_packet_copydata_in(odp_packet_t pkt, uint32_t offset,
   +  uint32_t len, const void *src)
   +{
   +   void *mapaddr;
   +   uint32_t seglen, cpylen;
   +   const uint8_t *srcaddr = (const uint8_t *)src;
   +   odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
   +
   +   while (len  0) {
   +   mapaddr = packet_offset_map(pkt_hdr, offset, seglen);
   +   if (mapaddr == NULL)
   +   return -1;
   +   cpylen = len  seglen ? seglen : len;
   +   memcpy(mapaddr, srcaddr, cpylen);
   +   offset  += cpylen;
   +   srcaddr += cpylen;
   +   len -= cpylen;
   }
 
  Same here.
 
  --
  Stuart.
 
 
 
  ___
  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] [PATCH] fix loop

2014-12-10 Thread Maxim Uvarov
Skip that patch.

Maxim.

 Исходное сообщение 
От: Mike Holmes mike.hol...@linaro.org 
Дата:10.12.2014  23:13  (GMT+03:00) 
Кому: Maxim Uvarov maxim.uva...@linaro.org 
Копия: lng-odp lng-odp@lists.linaro.org 
Тема: Re: [lng-odp] [PATCH] fix loop 

Patch does not describe why the loop needed fixing, the message also does not 
indicate if it was an example, test or implementation change.

On 8 December 2014 at 09:58, Maxim Uvarov maxim.uva...@linaro.org wrote:
Signed-off-by: Maxim Uvarov maxim.uva...@linaro.org
---
 platform/linux-generic/odp_packet_io.c | 58 --
 1 file changed, 13 insertions(+), 45 deletions(-)

diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index 833725e..4399ef9 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -155,33 +155,6 @@ static int free_pktio_entry(odp_pktio_t id)
        return 0;
 }

-static int find_loop_dev(char loop[IFNAMSIZ])
-{
-       struct ifaddrs *ifap, *ifa;
-
-       getifaddrs(ifap);
-
-       for (ifa = ifap; ifa; ifa = ifa-ifa_next) {
-               if (ifa-ifa_addr 
-                   ifa-ifa_addr-sa_family == AF_INET) {
-                       if ((ifa-ifa_flags  (IFF_LOOPBACK |
-                                             IFF_POINTOPOINT |
-                                             IFF_NOARP)) ||
-                           (!memcmp(ifa-ifa_name, lxcbr, 5)) ||
-                           (!memcmp(ifa-ifa_name, wlan, 4)) ||
-                           (!memcmp(ifa-ifa_name, veth, 4)) ||
-                           (!memcmp(ifa-ifa_name, virbr, 5)))
-                               continue;
-                       memcpy(loop, ifa-ifa_name, IFNAMSIZ);
-                       freeifaddrs(ifap);
-                       return 0;
-               }
-       }
-
-       freeifaddrs(ifap);
-       return -1;
-}
-
 odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool)
 {
        odp_pktio_t id;
@@ -203,26 +176,21 @@ odp_pktio_t odp_pktio_open(const char *dev, 
odp_buffer_pool_t pool)
         */
        loop_hint = getenv(ODP_PKTIO_LOOPDEV);
        if (!strcmp(dev, loop)) {
-               if (loop_hint  (strlen(loop_hint)  0)) {
-                       if (strlen(loop_hint) = IFNAMSIZ) {
-                               ODP_ERR(pktio name %s is too big, limit is %d 
bytes\n,
-                                       loop_hint, IFNAMSIZ);
-                               return ODP_PKTIO_INVALID;
-                       }
+               if (!loop_hint || (strlen(loop_hint) == 0)) {
+                       ODP_ERR(Set loop with ODP_PKTIO_LOOPDEV=ethX\n);
+                       return ODP_PKTIO_INVALID;
+               }

-                       memset(loop, 0, IFNAMSIZ);
-                       memcpy(loop, loop_hint, strlen(loop_hint));
-                       dev = loop;
-                       ODP_DBG(pktio using %s as loopback device\n, 
loop_hint);
-               } else {
-                       if (!find_loop_dev(loop)) {
-                               ODP_DBG(pktio rename loop to %s\n, loop);
-                               dev = loop;
-                       } else {
-                               ODP_DBG(pktio: No suitable netdev.\n);
-                               return ODP_PKTIO_INVALID;
-                       }
+               if (strlen(loop_hint) = IFNAMSIZ) {
+                       ODP_ERR(pktio name %s is too big, limit is %d bytes\n,
+                               loop_hint, IFNAMSIZ);
+                       return ODP_PKTIO_INVALID;
                }
+
+               memset(loop, 0, IFNAMSIZ);
+               memcpy(loop, loop_hint, strlen(loop_hint));
+               dev = loop;
+               ODP_DBG(pktio using %s as loopback device\n, loop_hint);
        }

        id = alloc_lock_pktio_entry();
--
1.8.5.1.163.gd7aced9


___
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] api: rename ODP_STATIC_ASSERT to _ODP_STATIC_ASSERT

2014-12-10 Thread Mike Holmes
This assert is used in the public API but is not intended for use in
applications and so it is marked with an underscore.

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---

The checkpatch warning for camel case cannot be avoided, the offending
function is defined externally to ODP.

#145: FILE: platform/linux-generic/include/api/odp_debug.h:48:
+#define _ODP_STATIC_ASSERT(cond, msg)  _Static_assert(cond, msg


 helper/include/odph_eth.h|  6 +++---
 helper/include/odph_icmp.h   |  2 +-
 helper/include/odph_ip.h |  4 ++--
 helper/include/odph_ipsec.h  |  6 +++---
 helper/include/odph_udp.h|  2 +-
 platform/linux-generic/include/api/odp_debug.h   |  2 +-
 platform/linux-generic/include/odp_buffer_internal.h |  3 ++-
 platform/linux-generic/include/odp_packet_internal.h | 18 +++---
 platform/linux-generic/include/odp_packet_io_queue.h |  4 ++--
 platform/linux-generic/include/odp_packet_socket.h   |  4 ++--
 platform/linux-generic/include/odp_timer_internal.h  | 10 +-
 platform/linux-generic/odp_buffer_pool.c |  4 ++--
 platform/linux-generic/odp_schedule.c|  3 ++-
 13 files changed, 37 insertions(+), 31 deletions(-)

diff --git a/helper/include/odph_eth.h b/helper/include/odph_eth.h
index 065a94b..6a29b76 100644
--- a/helper/include/odph_eth.h
+++ b/helper/include/odph_eth.h
@@ -39,7 +39,7 @@ typedef struct ODP_PACKED {
 } odph_ethaddr_t;
 
 /** @internal Compile time assert */
-ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN, 
ODPH_ETHADDR_T__SIZE_ERROR);
+_ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN, 
ODPH_ETHADDR_T__SIZE_ERROR);
 
 /**
  * Ethernet header
@@ -51,7 +51,7 @@ typedef struct ODP_PACKED {
 } odph_ethhdr_t;
 
 /** @internal Compile time assert */
-ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN, 
ODPH_ETHHDR_T__SIZE_ERROR);
+_ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN, 
ODPH_ETHHDR_T__SIZE_ERROR);
 
 /**
  * VLAN header
@@ -64,7 +64,7 @@ typedef struct ODP_PACKED {
 } odph_vlanhdr_t;
 
 /** @internal Compile time assert */
-ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN, 
ODPH_VLANHDR_T__SIZE_ERROR);
+_ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN, 
ODPH_VLANHDR_T__SIZE_ERROR);
 
 
 /* Ethernet header Ether Type ('type') values, a selected few */
diff --git a/helper/include/odph_icmp.h b/helper/include/odph_icmp.h
index 8533fb5..bc97008 100644
--- a/helper/include/odph_icmp.h
+++ b/helper/include/odph_icmp.h
@@ -90,7 +90,7 @@ typedef struct ODP_PACKED {
exceeded*/
 
 /** @internal Compile time assert */
-ODP_STATIC_ASSERT(sizeof(odph_icmphdr_t) == ODPH_ICMPHDR_LEN, 
ODPH_ICMPHDR_T__SIZE_ERROR);
+_ODP_STATIC_ASSERT(sizeof(odph_icmphdr_t) == ODPH_ICMPHDR_LEN, 
ODPH_ICMPHDR_T__SIZE_ERROR);
 
 #ifdef __cplusplus
 }
diff --git a/helper/include/odph_ip.h b/helper/include/odph_ip.h
index f78724e..5b803a0 100644
--- a/helper/include/odph_ip.h
+++ b/helper/include/odph_ip.h
@@ -68,7 +68,7 @@ typedef struct ODP_PACKED {
 } odph_ipv4hdr_t;
 
 /** @internal Compile time assert */
-ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, 
ODPH_IPV4HDR_T__SIZE_ERROR);
+_ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, 
ODPH_IPV4HDR_T__SIZE_ERROR);
 
 /**
  * Check if IPv4 checksum is valid
@@ -141,7 +141,7 @@ typedef struct ODP_PACKED {
 } odph_ipv6hdr_t;
 
 /** @internal Compile time assert */
-ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, 
ODPH_IPV6HDR_T__SIZE_ERROR);
+_ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, 
ODPH_IPV6HDR_T__SIZE_ERROR);
 
 /** @name
  * IP protocol values (IPv4:'proto' or IPv6:'next_hdr')
diff --git a/helper/include/odph_ipsec.h b/helper/include/odph_ipsec.h
index c58a1c8..fd72bc6 100644
--- a/helper/include/odph_ipsec.h
+++ b/helper/include/odph_ipsec.h
@@ -37,7 +37,7 @@ typedef struct ODP_PACKED {
 } odph_esphdr_t;
 
 /** @internal Compile time assert */
-ODP_STATIC_ASSERT(sizeof(odph_esphdr_t) == ODPH_ESPHDR_LEN, 
ODPH_ESPHDR_T__SIZE_ERROR);
+_ODP_STATIC_ASSERT(sizeof(odph_esphdr_t) == ODPH_ESPHDR_LEN, 
ODPH_ESPHDR_T__SIZE_ERROR);
 
 /**
  * IPSec ESP trailer
@@ -49,7 +49,7 @@ typedef struct ODP_PACKED {
 } odph_esptrl_t;
 
 /** @internal Compile time assert */
-ODP_STATIC_ASSERT(sizeof(odph_esptrl_t) == ODPH_ESPTRL_LEN, 
ODPH_ESPTRL_T__SIZE_ERROR);
+_ODP_STATIC_ASSERT(sizeof(odph_esptrl_t) == ODPH_ESPTRL_LEN, 
ODPH_ESPTRL_T__SIZE_ERROR);
 
 /**
  * IPSec AH header
@@ -64,7 +64,7 @@ typedef struct ODP_PACKED {
 } odph_ahhdr_t;
 
 /** @internal Compile time assert */
-ODP_STATIC_ASSERT(sizeof(odph_ahhdr_t) == ODPH_AHHDR_LEN, 
ODPH_AHHDR_T__SIZE_ERROR);
+_ODP_STATIC_ASSERT(sizeof(odph_ahhdr_t) == ODPH_AHHDR_LEN, 
ODPH_AHHDR_T__SIZE_ERROR);
 
 #ifdef __cplusplus
 }
diff --git 

Re: [lng-odp] [PATCH] api: rename ODP_STATIC_ASSERT to _ODP_STATIC_ASSERT

2014-12-10 Thread Stuart Haslam
On Wed, Dec 10, 2014 at 09:49:46PM +, Mike Holmes wrote:
 This assert is used in the public API but is not intended for use in
 applications and so it is marked with an underscore.
 

Any reason not to also move it to odp_debug_internal.h so that it can't
be used externally?

--
Stuart.

 Signed-off-by: Mike Holmes mike.hol...@linaro.org
 ---
 
 The checkpatch warning for camel case cannot be avoided, the offending
 function is defined externally to ODP.
 
 #145: FILE: platform/linux-generic/include/api/odp_debug.h:48:
 +#define _ODP_STATIC_ASSERT(cond, msg)  _Static_assert(cond, msg
 
 
  helper/include/odph_eth.h|  6 +++---
  helper/include/odph_icmp.h   |  2 +-
  helper/include/odph_ip.h |  4 ++--
  helper/include/odph_ipsec.h  |  6 +++---
  helper/include/odph_udp.h|  2 +-
  platform/linux-generic/include/api/odp_debug.h   |  2 +-
  platform/linux-generic/include/odp_buffer_internal.h |  3 ++-
  platform/linux-generic/include/odp_packet_internal.h | 18 +++---
  platform/linux-generic/include/odp_packet_io_queue.h |  4 ++--
  platform/linux-generic/include/odp_packet_socket.h   |  4 ++--
  platform/linux-generic/include/odp_timer_internal.h  | 10 +-
  platform/linux-generic/odp_buffer_pool.c |  4 ++--
  platform/linux-generic/odp_schedule.c|  3 ++-
  13 files changed, 37 insertions(+), 31 deletions(-)
 
 diff --git a/helper/include/odph_eth.h b/helper/include/odph_eth.h
 index 065a94b..6a29b76 100644
 --- a/helper/include/odph_eth.h
 +++ b/helper/include/odph_eth.h
 @@ -39,7 +39,7 @@ typedef struct ODP_PACKED {
  } odph_ethaddr_t;
 
  /** @internal Compile time assert */
 -ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN, 
 ODPH_ETHADDR_T__SIZE_ERROR);
 +_ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN, 
 ODPH_ETHADDR_T__SIZE_ERROR);
 
  /**
   * Ethernet header
 @@ -51,7 +51,7 @@ typedef struct ODP_PACKED {
  } odph_ethhdr_t;
 
  /** @internal Compile time assert */
 -ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN, 
 ODPH_ETHHDR_T__SIZE_ERROR);
 +_ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN, 
 ODPH_ETHHDR_T__SIZE_ERROR);
 
  /**
   * VLAN header
 @@ -64,7 +64,7 @@ typedef struct ODP_PACKED {
  } odph_vlanhdr_t;
 
  /** @internal Compile time assert */
 -ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN, 
 ODPH_VLANHDR_T__SIZE_ERROR);
 +_ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN, 
 ODPH_VLANHDR_T__SIZE_ERROR);
 
 
  /* Ethernet header Ether Type ('type') values, a selected few */
 diff --git a/helper/include/odph_icmp.h b/helper/include/odph_icmp.h
 index 8533fb5..bc97008 100644
 --- a/helper/include/odph_icmp.h
 +++ b/helper/include/odph_icmp.h
 @@ -90,7 +90,7 @@ typedef struct ODP_PACKED {
 exceeded*/
 
  /** @internal Compile time assert */
 -ODP_STATIC_ASSERT(sizeof(odph_icmphdr_t) == ODPH_ICMPHDR_LEN, 
 ODPH_ICMPHDR_T__SIZE_ERROR);
 +_ODP_STATIC_ASSERT(sizeof(odph_icmphdr_t) == ODPH_ICMPHDR_LEN, 
 ODPH_ICMPHDR_T__SIZE_ERROR);
 
  #ifdef __cplusplus
  }
 diff --git a/helper/include/odph_ip.h b/helper/include/odph_ip.h
 index f78724e..5b803a0 100644
 --- a/helper/include/odph_ip.h
 +++ b/helper/include/odph_ip.h
 @@ -68,7 +68,7 @@ typedef struct ODP_PACKED {
  } odph_ipv4hdr_t;
 
  /** @internal Compile time assert */
 -ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, 
 ODPH_IPV4HDR_T__SIZE_ERROR);
 +_ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, 
 ODPH_IPV4HDR_T__SIZE_ERROR);
 
  /**
   * Check if IPv4 checksum is valid
 @@ -141,7 +141,7 @@ typedef struct ODP_PACKED {
  } odph_ipv6hdr_t;
 
  /** @internal Compile time assert */
 -ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, 
 ODPH_IPV6HDR_T__SIZE_ERROR);
 +_ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, 
 ODPH_IPV6HDR_T__SIZE_ERROR);
 
  /** @name
   * IP protocol values (IPv4:'proto' or IPv6:'next_hdr')
 diff --git a/helper/include/odph_ipsec.h b/helper/include/odph_ipsec.h
 index c58a1c8..fd72bc6 100644
 --- a/helper/include/odph_ipsec.h
 +++ b/helper/include/odph_ipsec.h
 @@ -37,7 +37,7 @@ typedef struct ODP_PACKED {
  } odph_esphdr_t;
 
  /** @internal Compile time assert */
 -ODP_STATIC_ASSERT(sizeof(odph_esphdr_t) == ODPH_ESPHDR_LEN, 
 ODPH_ESPHDR_T__SIZE_ERROR);
 +_ODP_STATIC_ASSERT(sizeof(odph_esphdr_t) == ODPH_ESPHDR_LEN, 
 ODPH_ESPHDR_T__SIZE_ERROR);
 
  /**
   * IPSec ESP trailer
 @@ -49,7 +49,7 @@ typedef struct ODP_PACKED {
  } odph_esptrl_t;
 
  /** @internal Compile time assert */
 -ODP_STATIC_ASSERT(sizeof(odph_esptrl_t) == ODPH_ESPTRL_LEN, 
 ODPH_ESPTRL_T__SIZE_ERROR);
 +_ODP_STATIC_ASSERT(sizeof(odph_esptrl_t) == ODPH_ESPTRL_LEN, 
 ODPH_ESPTRL_T__SIZE_ERROR);
 
  /**
   * IPSec AH header
 @@ -64,7 +64,7 @@ typedef struct ODP_PACKED {
  } 

[lng-odp] [PATCH] api: doxygen: test_odp_sys_cpu_model_str

2014-12-10 Thread Mike Holmes
Specify more clearly the behaviour of the function.

Signed-off-by: Mike Holmes mike.hol...@linaro.org
---
 platform/linux-generic/include/api/odp_system_info.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/platform/linux-generic/include/api/odp_system_info.h 
b/platform/linux-generic/include/api/odp_system_info.h
index bcd08d7..bf5896c 100644
--- a/platform/linux-generic/include/api/odp_system_info.h
+++ b/platform/linux-generic/include/api/odp_system_info.h
@@ -48,6 +48,8 @@ uint64_t odp_sys_page_size(void);
 
 /**
  * CPU model name
+ * The string is 128 chars long and will be NULL terminatied.
+ * The pointer will never be NULL, but it may be an empty string.
  *
  * @return Pointer to CPU model name string
  */
-- 
2.1.0


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


Re: [lng-odp] [PATCH] api: rename ODP_STATIC_ASSERT to _ODP_STATIC_ASSERT

2014-12-10 Thread Mike Holmes
On 10 December 2014 at 16:58, Stuart Haslam stuart.has...@arm.com wrote:

 On Wed, Dec 10, 2014 at 09:49:46PM +, Mike Holmes wrote:
  This assert is used in the public API but is not intended for use in
  applications and so it is marked with an underscore.
 

 Any reason not to also move it to odp_debug_internal.h so that it can't
 be used externally?


Yes, the public API uses it so it becomes circular with the public API
including the internal API.



 --
 Stuart.

  Signed-off-by: Mike Holmes mike.hol...@linaro.org
  ---
 
  The checkpatch warning for camel case cannot be avoided, the offending
  function is defined externally to ODP.
 
  #145: FILE: platform/linux-generic/include/api/odp_debug.h:48:
  +#define _ODP_STATIC_ASSERT(cond, msg)  _Static_assert(cond, msg
 
 
   helper/include/odph_eth.h|  6 +++---
   helper/include/odph_icmp.h   |  2 +-
   helper/include/odph_ip.h |  4 ++--
   helper/include/odph_ipsec.h  |  6 +++---
   helper/include/odph_udp.h|  2 +-
   platform/linux-generic/include/api/odp_debug.h   |  2 +-
   platform/linux-generic/include/odp_buffer_internal.h |  3 ++-
   platform/linux-generic/include/odp_packet_internal.h | 18
 +++---
   platform/linux-generic/include/odp_packet_io_queue.h |  4 ++--
   platform/linux-generic/include/odp_packet_socket.h   |  4 ++--
   platform/linux-generic/include/odp_timer_internal.h  | 10 +-
   platform/linux-generic/odp_buffer_pool.c |  4 ++--
   platform/linux-generic/odp_schedule.c|  3 ++-
   13 files changed, 37 insertions(+), 31 deletions(-)
 
  diff --git a/helper/include/odph_eth.h b/helper/include/odph_eth.h
  index 065a94b..6a29b76 100644
  --- a/helper/include/odph_eth.h
  +++ b/helper/include/odph_eth.h
  @@ -39,7 +39,7 @@ typedef struct ODP_PACKED {
   } odph_ethaddr_t;
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN,
 ODPH_ETHADDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN,
 ODPH_ETHADDR_T__SIZE_ERROR);
 
   /**
* Ethernet header
  @@ -51,7 +51,7 @@ typedef struct ODP_PACKED {
   } odph_ethhdr_t;
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN,
 ODPH_ETHHDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN,
 ODPH_ETHHDR_T__SIZE_ERROR);
 
   /**
* VLAN header
  @@ -64,7 +64,7 @@ typedef struct ODP_PACKED {
   } odph_vlanhdr_t;
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN,
 ODPH_VLANHDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN,
 ODPH_VLANHDR_T__SIZE_ERROR);
 
 
   /* Ethernet header Ether Type ('type') values, a selected few */
  diff --git a/helper/include/odph_icmp.h b/helper/include/odph_icmp.h
  index 8533fb5..bc97008 100644
  --- a/helper/include/odph_icmp.h
  +++ b/helper/include/odph_icmp.h
  @@ -90,7 +90,7 @@ typedef struct ODP_PACKED {
 
  exceeded*/
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_icmphdr_t) == ODPH_ICMPHDR_LEN,
 ODPH_ICMPHDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_icmphdr_t) == ODPH_ICMPHDR_LEN,
 ODPH_ICMPHDR_T__SIZE_ERROR);
 
   #ifdef __cplusplus
   }
  diff --git a/helper/include/odph_ip.h b/helper/include/odph_ip.h
  index f78724e..5b803a0 100644
  --- a/helper/include/odph_ip.h
  +++ b/helper/include/odph_ip.h
  @@ -68,7 +68,7 @@ typedef struct ODP_PACKED {
   } odph_ipv4hdr_t;
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN,
 ODPH_IPV4HDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN,
 ODPH_IPV4HDR_T__SIZE_ERROR);
 
   /**
* Check if IPv4 checksum is valid
  @@ -141,7 +141,7 @@ typedef struct ODP_PACKED {
   } odph_ipv6hdr_t;
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN,
 ODPH_IPV6HDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN,
 ODPH_IPV6HDR_T__SIZE_ERROR);
 
   /** @name
* IP protocol values (IPv4:'proto' or IPv6:'next_hdr')
  diff --git a/helper/include/odph_ipsec.h b/helper/include/odph_ipsec.h
  index c58a1c8..fd72bc6 100644
  --- a/helper/include/odph_ipsec.h
  +++ b/helper/include/odph_ipsec.h
  @@ -37,7 +37,7 @@ typedef struct ODP_PACKED {
   } odph_esphdr_t;
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_esphdr_t) == ODPH_ESPHDR_LEN,
 ODPH_ESPHDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_esphdr_t) == ODPH_ESPHDR_LEN,
 ODPH_ESPHDR_T__SIZE_ERROR);
 
   /**
* IPSec ESP trailer
  @@ -49,7 +49,7 @@ typedef struct ODP_PACKED {
   } odph_esptrl_t;
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_esptrl_t) == ODPH_ESPTRL_LEN,
 

Re: [lng-odp] [PATCH] api: rename ODP_STATIC_ASSERT to _ODP_STATIC_ASSERT

2014-12-10 Thread Stuart Haslam
On Wed, Dec 10, 2014 at 09:58:23PM +, Stuart Haslam wrote:
 On Wed, Dec 10, 2014 at 09:49:46PM +, Mike Holmes wrote:
  This assert is used in the public API but is not intended for use in
  applications and so it is marked with an underscore.
 
 
 Any reason not to also move it to odp_debug_internal.h so that it can't
 be used externally?
 

Err, ignore that.. the used in the public API bit went over my head.

 
  Signed-off-by: Mike Holmes mike.hol...@linaro.org

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

  ---
 
  The checkpatch warning for camel case cannot be avoided, the offending
  function is defined externally to ODP.
 
  #145: FILE: platform/linux-generic/include/api/odp_debug.h:48:
  +#define _ODP_STATIC_ASSERT(cond, msg)  _Static_assert(cond, msg
 
 
   helper/include/odph_eth.h|  6 +++---
   helper/include/odph_icmp.h   |  2 +-
   helper/include/odph_ip.h |  4 ++--
   helper/include/odph_ipsec.h  |  6 +++---
   helper/include/odph_udp.h|  2 +-
   platform/linux-generic/include/api/odp_debug.h   |  2 +-
   platform/linux-generic/include/odp_buffer_internal.h |  3 ++-
   platform/linux-generic/include/odp_packet_internal.h | 18 
  +++---
   platform/linux-generic/include/odp_packet_io_queue.h |  4 ++--
   platform/linux-generic/include/odp_packet_socket.h   |  4 ++--
   platform/linux-generic/include/odp_timer_internal.h  | 10 +-
   platform/linux-generic/odp_buffer_pool.c |  4 ++--
   platform/linux-generic/odp_schedule.c|  3 ++-
   13 files changed, 37 insertions(+), 31 deletions(-)
 
  diff --git a/helper/include/odph_eth.h b/helper/include/odph_eth.h
  index 065a94b..6a29b76 100644
  --- a/helper/include/odph_eth.h
  +++ b/helper/include/odph_eth.h
  @@ -39,7 +39,7 @@ typedef struct ODP_PACKED {
   } odph_ethaddr_t;
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN, 
  ODPH_ETHADDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN, 
  ODPH_ETHADDR_T__SIZE_ERROR);
 
   /**
* Ethernet header
  @@ -51,7 +51,7 @@ typedef struct ODP_PACKED {
   } odph_ethhdr_t;
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN, 
  ODPH_ETHHDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN, 
  ODPH_ETHHDR_T__SIZE_ERROR);
 
   /**
* VLAN header
  @@ -64,7 +64,7 @@ typedef struct ODP_PACKED {
   } odph_vlanhdr_t;
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN, 
  ODPH_VLANHDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN, 
  ODPH_VLANHDR_T__SIZE_ERROR);
 
 
   /* Ethernet header Ether Type ('type') values, a selected few */
  diff --git a/helper/include/odph_icmp.h b/helper/include/odph_icmp.h
  index 8533fb5..bc97008 100644
  --- a/helper/include/odph_icmp.h
  +++ b/helper/include/odph_icmp.h
  @@ -90,7 +90,7 @@ typedef struct ODP_PACKED {
  exceeded*/
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_icmphdr_t) == ODPH_ICMPHDR_LEN, 
  ODPH_ICMPHDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_icmphdr_t) == ODPH_ICMPHDR_LEN, 
  ODPH_ICMPHDR_T__SIZE_ERROR);
 
   #ifdef __cplusplus
   }
  diff --git a/helper/include/odph_ip.h b/helper/include/odph_ip.h
  index f78724e..5b803a0 100644
  --- a/helper/include/odph_ip.h
  +++ b/helper/include/odph_ip.h
  @@ -68,7 +68,7 @@ typedef struct ODP_PACKED {
   } odph_ipv4hdr_t;
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, 
  ODPH_IPV4HDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, 
  ODPH_IPV4HDR_T__SIZE_ERROR);
 
   /**
* Check if IPv4 checksum is valid
  @@ -141,7 +141,7 @@ typedef struct ODP_PACKED {
   } odph_ipv6hdr_t;
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, 
  ODPH_IPV6HDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, 
  ODPH_IPV6HDR_T__SIZE_ERROR);
 
   /** @name
* IP protocol values (IPv4:'proto' or IPv6:'next_hdr')
  diff --git a/helper/include/odph_ipsec.h b/helper/include/odph_ipsec.h
  index c58a1c8..fd72bc6 100644
  --- a/helper/include/odph_ipsec.h
  +++ b/helper/include/odph_ipsec.h
  @@ -37,7 +37,7 @@ typedef struct ODP_PACKED {
   } odph_esphdr_t;
 
   /** @internal Compile time assert */
  -ODP_STATIC_ASSERT(sizeof(odph_esphdr_t) == ODPH_ESPHDR_LEN, 
  ODPH_ESPHDR_T__SIZE_ERROR);
  +_ODP_STATIC_ASSERT(sizeof(odph_esphdr_t) == ODPH_ESPHDR_LEN, 
  ODPH_ESPHDR_T__SIZE_ERROR);
 
   /**
* IPSec ESP trailer
  @@ -49,7 +49,7 @@ typedef struct ODP_PACKED {
   } odph_esptrl_t;
 
   /** @internal Compile 

Re: [lng-odp] [PATCH] validation:add atomic test in odp syncronizers

2014-12-10 Thread Maxim Uvarov

On 12/10/2014 10:42 PM, Mike Holmes wrote:

+#include CUnit/TestDB.h

CUnit/TestDB.h

___
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


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

2014-12-10 Thread Bill Fischofer
Signed-off-by: Bill Fischofer bill.fischo...@linaro.org
---
v4 Removes RFC, incorporates doxygen change recommended by Anders and PEtri
and incorporates bug fixes that enable it to pass Taras' buffer tests.

 example/generator/odp_generator.c  |  19 +-
 example/ipsec/odp_ipsec.c  |  57 +-
 example/l2fwd/odp_l2fwd.c  |  19 +-
 example/odp_example/odp_example.c  |  18 +-
 example/packet/odp_pktio.c |  19 +-
 example/timer/odp_timer_test.c |  13 +-
 platform/linux-generic/include/api/odp_buffer.h|  15 +-
 .../linux-generic/include/api/odp_buffer_pool.h| 114 ++-
 platform/linux-generic/include/api/odp_config.h|  70 ++
 .../linux-generic/include/api/odp_platform_types.h |  12 +
 .../linux-generic/include/api/odp_shared_memory.h  |  10 +-
 .../linux-generic/include/odp_buffer_inlines.h | 150 
 .../linux-generic/include/odp_buffer_internal.h| 152 ++--
 .../include/odp_buffer_pool_internal.h | 346 +++--
 platform/linux-generic/include/odp_internal.h  |   2 +
 .../linux-generic/include/odp_packet_internal.h|  50 +-
 .../linux-generic/include/odp_timer_internal.h |  11 +-
 platform/linux-generic/odp_buffer.c|  33 +-
 platform/linux-generic/odp_buffer_pool.c   | 816 +++--
 platform/linux-generic/odp_linux.c |   4 +-
 platform/linux-generic/odp_packet.c|  41 +-
 platform/linux-generic/odp_queue.c |   1 +
 platform/linux-generic/odp_schedule.c  |  20 +-
 platform/linux-generic/odp_timer.c |   3 +-
 test/api_test/odp_timer_ping.c |  19 +-
 test/validation/odp_crypto.c   |  43 +-
 test/validation/odp_queue.c|  19 +-
 27 files changed, 1303 insertions(+), 773 deletions(-)
 create mode 100644 platform/linux-generic/include/odp_buffer_inlines.h

diff --git a/example/generator/odp_generator.c 
b/example/generator/odp_generator.c
index 8c227bc..a67910e 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -522,11 +522,11 @@ int main(int argc, char *argv[])
odph_linux_pthread_t thread_tbl[MAX_WORKERS];
odp_buffer_pool_t pool;
int num_workers;
-   void *pool_base;
int i;
int first_core;
int core_count;
odp_shm_t shm;
+   odp_buffer_pool_param_t params;
 
/* Init ODP before calling anything else */
if (odp_init_global(NULL, NULL)) {
@@ -589,20 +589,13 @@ int main(int argc, char *argv[])
printf(First core: %i\n\n, first_core);
 
/* Create packet pool */
-   shm = odp_shm_reserve(shm_packet_pool,
- SHM_PKT_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
-   pool_base = odp_shm_addr(shm);
+   params.buf_size  = SHM_PKT_POOL_BUF_SIZE;
+   params.buf_align = 0;
+   params.num_bufs  = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE;
+   params.buf_type  = ODP_BUFFER_TYPE_PACKET;
 
-   if (pool_base == NULL) {
-   EXAMPLE_ERR(Error: packet pool mem alloc failed.\n);
-   exit(EXIT_FAILURE);
-   }
+   pool = odp_buffer_pool_create(packet_pool, ODP_SHM_NULL, params);
 
-   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) {
EXAMPLE_ERR(Error: packet pool create failed.\n);
exit(EXIT_FAILURE);
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index aeeb1ba..354be1f 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -367,8 +367,7 @@ static
 void ipsec_init_pre(void)
 {
odp_queue_param_t qparam;
-   void *pool_base;
-   odp_shm_t shm;
+   odp_buffer_pool_param_t params;
 
/*
 * Create queues
@@ -401,16 +400,12 @@ void ipsec_init_pre(void)
}
 
/* Create output buffer pool */
-   shm = odp_shm_reserve(shm_out_pool,
- SHM_OUT_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0);
-
-   pool_base = odp_shm_addr(shm);
+   params.buf_size  = SHM_OUT_POOL_BUF_SIZE;
+   params.buf_align = 0;
+   params.num_bufs  = SHM_PKT_POOL_BUF_COUNT;
+   params.buf_type  = ODP_BUFFER_TYPE_PACKET;
 
-   out_pool = odp_buffer_pool_create(out_pool, pool_base,
- SHM_OUT_POOL_SIZE,
- SHM_OUT_POOL_BUF_SIZE,
- ODP_CACHE_LINE_SIZE,
- ODP_BUFFER_TYPE_PACKET);
+   out_pool = odp_buffer_pool_create(out_pool, 

[lng-odp] [PATCHv3] Implement v0.5 level packet APIs

2014-12-10 Thread Bill Fischofer
Signed-off-by: Bill Fischofer bill.fischo...@linaro.org
---
v3 removes RFC, incorporates bug fixes from Stuart, and doxygen
usage recommendations fram Anders and Petri

 example/generator/odp_generator.c  |  82 +-
 example/ipsec/odp_ipsec.c  |  32 +-
 example/ipsec/odp_ipsec_stream.c   |  22 +-
 example/l2fwd/odp_l2fwd.c  |   3 +-
 example/packet/odp_pktio.c |   8 +-
 helper/include/odph_ip.h   |  35 +-
 helper/include/odph_packet.h   |  97 ---
 helper/include/odph_udp.h  |   5 +-
 platform/linux-generic/Makefile.am |   1 -
 platform/linux-generic/include/api/odp_packet.h| 737 +
 .../linux-generic/include/api/odp_platform_types.h |  21 +-
 .../linux-generic/include/odp_buffer_inlines.h |  54 ++
 .../linux-generic/include/odp_buffer_internal.h|   1 +
 .../linux-generic/include/odp_packet_internal.h|  81 +-
 platform/linux-generic/odp_classification.c|   2 +-
 platform/linux-generic/odp_crypto.c|  11 +-
 platform/linux-generic/odp_packet.c| 921 -
 platform/linux-generic/odp_packet_socket.c |  93 +--
 18 files changed, 1569 insertions(+), 637 deletions(-)
 delete mode 100644 helper/include/odph_packet.h

diff --git a/example/generator/odp_generator.c 
b/example/generator/odp_generator.c
index a67910e..04d3d83 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -21,7 +21,6 @@
 #include odp.h
 
 #include odph_linux.h
-#include odph_packet.h
 #include odph_eth.h
 #include odph_ip.h
 #include odph_udp.h
@@ -171,32 +170,31 @@ static int scan_mac(char *in, odph_ethaddr_t *des)
  *
  * @param obuf packet buffer
 */
-static void pack_udp_pkt(odp_buffer_t obuf)
+static odp_packet_t pack_udp_pkt(odp_buffer_pool_t pool)
 {
-   char *buf;
-   int max;
odp_packet_t pkt;
+   char *buf;
odph_ethhdr_t *eth;
odph_ipv4hdr_t *ip;
odph_udphdr_t *udp;
unsigned short seq;
 
-   buf = odp_buffer_addr(obuf);
-   if (buf == NULL)
-   return;
-   max = odp_buffer_size(obuf);
-   if (max = 0)
-   return;
+   pkt = odp_packet_alloc(pool, args-appl.payload + ODPH_UDPHDR_LEN +
+  ODPH_IPV4HDR_LEN + ODPH_ETHHDR_LEN);
+
+   if (pkt == ODP_PACKET_INVALID)
+   return pkt;
+
+   buf = odp_packet_data(pkt);
 
-   pkt = odp_packet_from_buffer(obuf);
/* ether */
-   odp_packet_set_l2_offset(pkt, 0);
+   odp_packet_l2_offset_set(pkt, 0);
eth = (odph_ethhdr_t *)buf;
memcpy((char *)eth-src.addr, args-appl.srcmac.addr, ODPH_ETHADDR_LEN);
memcpy((char *)eth-dst.addr, args-appl.dstmac.addr, ODPH_ETHADDR_LEN);
eth-type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);
/* ip */
-   odp_packet_set_l3_offset(pkt, ODPH_ETHHDR_LEN);
+   odp_packet_l3_offset_set(pkt, ODPH_ETHHDR_LEN);
ip = (odph_ipv4hdr_t *)(buf + ODPH_ETHHDR_LEN);
ip-dst_addr = odp_cpu_to_be_32(args-appl.dstip);
ip-src_addr = odp_cpu_to_be_32(args-appl.srcip);
@@ -209,15 +207,15 @@ static void pack_udp_pkt(odp_buffer_t obuf)
ip-chksum = 0;
odph_ipv4_csum_update(pkt);
/* udp */
-   odp_packet_set_l4_offset(pkt, ODPH_ETHHDR_LEN + ODPH_IPV4HDR_LEN);
+   odp_packet_l4_offset_set(pkt, ODPH_ETHHDR_LEN + ODPH_IPV4HDR_LEN);
udp = (odph_udphdr_t *)(buf + ODPH_ETHHDR_LEN + ODPH_IPV4HDR_LEN);
udp-src_port = 0;
udp-dst_port = 0;
udp-length = odp_cpu_to_be_16(args-appl.payload + ODPH_UDPHDR_LEN);
udp-chksum = 0;
udp-chksum = odp_cpu_to_be_16(odph_ipv4_udp_chksum(pkt));
-   odp_packet_set_len(pkt, args-appl.payload + ODPH_UDPHDR_LEN +
-  ODPH_IPV4HDR_LEN + ODPH_ETHHDR_LEN);
+
+   return pkt;
 }
 
 /**
@@ -225,11 +223,10 @@ static void pack_udp_pkt(odp_buffer_t obuf)
  *
  * @param obuf packet buffer
 */
-static void pack_icmp_pkt(odp_buffer_t obuf)
+static odp_packet_t pack_icmp_pkt(odp_buffer_pool_t pool)
 {
-   char *buf;
-   int max;
odp_packet_t pkt;
+   char *buf;
odph_ethhdr_t *eth;
odph_ipv4hdr_t *ip;
odph_icmphdr_t *icmp;
@@ -237,23 +234,23 @@ static void pack_icmp_pkt(odp_buffer_t obuf)
uint8_t *tval_d;
unsigned short seq;
 
-   buf = odp_buffer_addr(obuf);
-   if (buf == NULL)
-   return;
-   max = odp_buffer_size(obuf);
-   if (max = 0)
-   return;
-
args-appl.payload = 56;
-   pkt = odp_packet_from_buffer(obuf);
+   pkt = odp_packet_alloc(pool, args-appl.payload + ODPH_ICMPHDR_LEN +
+  ODPH_IPV4HDR_LEN + ODPH_ETHHDR_LEN);
+
+   if (pkt == ODP_PACKET_INVALID)
+   return pkt;
+
+   

Re: [lng-odp] [PATCHv3] validation: schedule: initial testcases

2014-12-10 Thread Jerin Jacob
On Wed, Dec 10, 2014 at 07:12:43PM +0200, Ciprian Barbu wrote:
 Signed-off-by: Ciprian Barbu ciprian.ba...@linaro.org
 ---
 v3:
  - changes after Mike's review
  - removed duplicate check of end of test in schedule_common_
 v2:
  - rebased against ODP tip
  - fixed some bugs
  - added some defines to clearly see the testcase parameters
 
  test/validation/Makefile.am|   5 +-
  test/validation/odp_schedule.c | 608 
 +


Add odp_schedule in .gitignore


  2 files changed, 612 insertions(+), 1 deletion(-)
  create mode 100644 test/validation/odp_schedule.c
 
 diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
 index 8547085..3670c76 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_schedule
  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_schedule_CFLAGS = $(AM_CFLAGS)
 +odp_schedule_LDFLAGS = $(AM_LDFLAGS)
  endif
  
  dist_odp_init_SOURCES = odp_init.c
 @@ -22,3 +24,4 @@ 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_schedule_SOURCES = odp_schedule.c common/odp_cunit_common.c
 diff --git a/test/validation/odp_schedule.c b/test/validation/odp_schedule.c
 new file mode 100644
 index 000..faca497
 --- /dev/null
 +++ b/test/validation/odp_schedule.c
 @@ -0,0 +1,608 @@
 +/* Copyright (c) 2014, Linaro Limited
 + * All rights reserved.
 + *
 + * SPDX-License-Identifier: BSD-3-Clause
 + */
 +
 +#include odp.h
 +#include odp_cunit_common.h
 +
 +#define MAX_WORKERS_THREADS  32
 +#define MSG_POOL_SIZE(4*1024*1024)
 +#define QUEUES_PER_PRIO  16
 +#define BUF_SIZE 64
 +#define TEST_NUM_BUFS100
 +#define BURST_BUF_SIZE   4
 +#define TEST_NUM_BUFS_EXCL   1
 +
 +#define GLOBALS_SHM_NAME test_globals
 +#define MSG_POOL_NAMEmsg_pool
 +#define SHM_MSG_POOL_NAMEshm_msg_pool
 +#define SHM_THR_ARGS_NAMEshm_thr_args
 +
 +#define ONE_Q1
 +#define MANY_QS  QUEUES_PER_PRIO
 +
 +#define ONE_PRIO 1
 +
 +#define SCHD_ONE 0
 +#define SCHD_MULTI   1
 +
 +#define DISABLE_EXCL_ATOMIC  0
 +#define ENABLE_EXCL_ATOMIC   1
 +
 +
 +/* Test global variables */
 +typedef struct {
 + int core_count;
 + odp_barrier_t barrier;
 + odp_schedule_prio_t current_prio;
 + int prio_buf_count;
 + odp_spinlock_t count_lock;
 + odp_spinlock_t atomic_lock;
 +} test_globals_t;
 +
 +typedef struct ODP_PACKED {
 + pthrd_arg thrdarg;
 + odp_schedule_sync_t sync;
 + int num_queues;
 + int num_prio;
 + int num_bufs;
 + int num_cores;
 + int enable_schd_multi;
 + int enable_excl_atomic;
 +} thread_args_t;
 +
 +odp_buffer_pool_t pool;
 +
 +static void test_schedule_wait_time(void)
 +{
 + uint64_t wait_time;
 +
 + wait_time = odp_schedule_wait_time(0);
 + CU_ASSERT(wait_time  0);

IMO, Its an invalid assert as odp_schedule_wait_time(0) very well can be 0
and wait_time is unsigned.

 +
 + wait_time = odp_schedule_wait_time(1);
 + CU_ASSERT(wait_time  0);
 +
 + wait_time = odp_schedule_wait_time((uint64_t)-1LL);
 + CU_ASSERT(wait_time  0);
 +}
 +
 +static void test_schedule_num_prio(void)
 +{
 + int prio;
 +
 + prio = odp_schedule_num_prio();
 +
 + CU_ASSERT(prio  0);
 + CU_ASSERT(prio == odp_schedule_num_prio());
 +}
 +
 +static void *schedule_common_(void *arg)
 +{
 + thread_args_t *args = (thread_args_t *)arg;
 + odp_schedule_sync_t sync;
 + int num_queues, num_prio, num_bufs, num_cores;
 + odp_shm_t shm;
 + test_globals_t *globals;
 +
 + sync = args-sync;
 + num_queues = args-num_queues;
 + num_prio = args-num_prio;
 + num_bufs = args-num_bufs;
 + num_cores = args-num_cores;
 +
 + shm = odp_shm_lookup(GLOBALS_SHM_NAME);
 + CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
 + globals = odp_shm_addr(shm);
 + CU_ASSERT_FATAL(globals != NULL);
 +
 +
 + if (num_cores == globals-core_count)
 + odp_barrier_wait(globals-barrier);
 +
 + while (1) {
 + odp_buffer_t buf;
 + odp_queue_t from;
 + int num = 0;
 + int locked;
 +
 + odp_spinlock_lock(globals-count_lock);
 + if (globals-prio_buf_count ==
 + num_bufs * num_queues * num_prio)