[lng-odp] [Bug 2464] strict priority schedule is not tested under CI

2016-12-08 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2464

--- Comment #3 from Yi He  ---
in api-next branch
After Petri/Matias' pool/ordered queue patchsets, SP scheduler can pass
validation test suite, this patch fixes the last issue as reported and
SP scheduler can pass make check after then.

http://patches.opendataplane.org/patch/7616/

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[lng-odp] [API-NEXT PATCH] linux-gen: sched: fix SP scheduler hang in process mode

2016-12-08 Thread Yi He
SP scheduler hangs in process mode performance test
due to global data structure were not created in shared
memory region.

Signed-off-by: Yi He 
---
Fixes: https://bugs.linaro.org/show_bug.cgi?id=2464
After Petri/Matias' pool/ordered queue patchsets, SP scheduler can pass
validation test suite, this patch fixes the last issue as reported and
SP scheduler can pass make check after then.

 platform/linux-generic/odp_schedule_sp.c | 89 
 1 file changed, 56 insertions(+), 33 deletions(-)

diff --git a/platform/linux-generic/odp_schedule_sp.c 
b/platform/linux-generic/odp_schedule_sp.c
index 76d1357..d9f861f 100644
--- a/platform/linux-generic/odp_schedule_sp.c
+++ b/platform/linux-generic/odp_schedule_sp.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -85,6 +86,7 @@ typedef struct {
sched_cmd_t   pktio_cmd[NUM_PKTIO];
prio_queue_t  prio_queue[NUM_PRIO];
sched_group_t sched_group;
+   odp_shm_t shm;
 } sched_global_t;
 
 typedef struct {
@@ -93,32 +95,47 @@ typedef struct {
int  thr_id;
 } sched_local_t;
 
-static sched_global_t sched_global;
+static sched_global_t *sched_global;
 static __thread sched_local_t sched_local;
 
 static int init_global(void)
 {
int i;
-   sched_group_t *sched_group = _global.sched_group;
+   odp_shm_t shm;
+   sched_group_t *sched_group = NULL;
 
ODP_DBG("Using SP scheduler\n");
 
-   memset(_global, 0, sizeof(sched_global_t));
+   shm = odp_shm_reserve("sp_scheduler",
+ sizeof(sched_global_t),
+ ODP_CACHE_LINE_SIZE, 0);
+
+   sched_global = odp_shm_addr(shm);
+
+   if (sched_global == NULL) {
+   ODP_ERR("Schedule init: Shm reserve failed.\n");
+   return -1;
+   }
+
+   memset(sched_global, 0, sizeof(sched_global_t));
+
+   sched_global->shm = shm;
 
for (i = 0; i < NUM_QUEUE; i++) {
-   sched_global.queue_cmd[i].s.type  = CMD_QUEUE;
-   sched_global.queue_cmd[i].s.index = i;
+   sched_global->queue_cmd[i].s.type  = CMD_QUEUE;
+   sched_global->queue_cmd[i].s.index = i;
}
 
for (i = 0; i < NUM_PKTIO; i++) {
-   sched_global.pktio_cmd[i].s.type  = CMD_PKTIO;
-   sched_global.pktio_cmd[i].s.index = i;
-   sched_global.pktio_cmd[i].s.prio  = PKTIN_PRIO;
+   sched_global->pktio_cmd[i].s.type  = CMD_PKTIO;
+   sched_global->pktio_cmd[i].s.index = i;
+   sched_global->pktio_cmd[i].s.prio  = PKTIN_PRIO;
}
 
for (i = 0; i < NUM_PRIO; i++)
-   odp_ticketlock_init(_global.prio_queue[i].s.lock);
+   odp_ticketlock_init(_global->prio_queue[i].s.lock);
 
+   sched_group = _global->sched_group;
odp_ticketlock_init(_group->s.lock);
 
strncpy(sched_group->s.group[GROUP_ALL].name, "__group_all",
@@ -149,16 +166,22 @@ static int init_local(void)
 
 static int term_global(void)
 {
-   int qi;
+   int qi, ret = 0;
 
for (qi = 0; qi < NUM_QUEUE; qi++) {
-   if (sched_global.queue_cmd[qi].s.init) {
+   if (sched_global->queue_cmd[qi].s.init) {
/* todo: dequeue until empty ? */
sched_cb_queue_destroy_finalize(qi);
}
}
 
-   return 0;
+   ret = odp_shm_free(sched_global->shm);
+   if (ret < 0) {
+   ODP_ERR("Shm free failed for sp_scheduler");
+   ret = -1;
+   }
+
+   return ret;
 }
 
 static int term_local(void)
@@ -173,7 +196,7 @@ static unsigned max_ordered_locks(void)
 
 static int thr_add(odp_schedule_group_t group, int thr)
 {
-   sched_group_t *sched_group = _global.sched_group;
+   sched_group_t *sched_group = _global->sched_group;
 
if (group < 0 || group >= NUM_GROUP)
return -1;
@@ -194,7 +217,7 @@ static int thr_add(odp_schedule_group_t group, int thr)
 
 static int thr_rem(odp_schedule_group_t group, int thr)
 {
-   sched_group_t *sched_group = _global.sched_group;
+   sched_group_t *sched_group = _global->sched_group;
 
if (group < 0 || group >= NUM_GROUP)
return -1;
@@ -220,7 +243,7 @@ static int num_grps(void)
 
 static int init_queue(uint32_t qi, const odp_schedule_param_t *sched_param)
 {
-   sched_group_t *sched_group = _global.sched_group;
+   sched_group_t *sched_group = _global->sched_group;
odp_schedule_group_t group = sched_param->group;
int prio = 0;
 
@@ -233,25 +256,25 @@ static int init_queue(uint32_t qi, const 
odp_schedule_param_t *sched_param)
if (sched_param->prio > 0)
prio = LOWEST_QUEUE_PRIO;
 
-   sched_global.queue_cmd[qi].s.prio  = prio;
-   sched_global.queue_cmd[qi].s.group = group;
-   

Re: [lng-odp] [PATCH] validation: classification: increase SHM_PKT_BUF_SIZE

2016-12-08 Thread Bala Manoharan
I understand the issue the better fix would be to reduce the length
packet while calling create_packet_len() function in
odp_classification_test_pmr.c:807. It is better to keep the segment
size as a power of 2.

Regards,
Bala


On 7 December 2016 at 14:51, Nicolas Morey-Chaisemartin
 wrote:
> classification_test_pmr_term_packet_len allocs a packet with 1024
>  of payload + headers which is greater than the segsize used to allocate
>  the pool and breaks on implementation without segmentation support
>
> Signed-off-by: Nicolas Morey-Chaisemartin 
> ---
>
> Should be aplied on monarch_lts too. Applies without conflict apart from path 
> change
>
>  test/common_plat/validation/api/classification/classification.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/test/common_plat/validation/api/classification/classification.h 
> b/test/common_plat/validation/api/classification/classification.h
> index d73c821..73de40a 100644
> --- a/test/common_plat/validation/api/classification/classification.h
> +++ b/test/common_plat/validation/api/classification/classification.h
> @@ -10,7 +10,7 @@
>  #include 
>
>  #define SHM_PKT_NUM_BUFS32
> -#define SHM_PKT_BUF_SIZE1024
> +#define SHM_PKT_BUF_SIZE1088
>
>  /* Config values for Default CoS */
>  #define TEST_DEFAULT   1
> --
> 2.10.1.4.g0ffc436
>


Re: [lng-odp] [API-NEXT PATCH v3 00/10] crypto key length capability

2016-12-08 Thread Bill Fischofer
I'm happy with this series, but I think Bala and Nikhil should be the
reviewers since we want to be sure it doesn't impact their crypto
implementations.

On Thu, Dec 8, 2016 at 8:05 AM, Petri Savolainen
 wrote:
> Various cipher and authentication algorithms support multiple key/IV/digest
> lengths. It's not a scalable solution to define these lengths as part of
> algorithm enumeration. This patch set deprecates enumerations (e.g.
> ODP_CIPHER_ALG_AES128_CBC) with length definitions. Those are still supported
> but will be removed in next API version. New enumerations define only
> algorithm names, with the exception of SHA-2 family of algorithms which are
> commonly referred with their digest length (such as SHA-256). The supported
> key/IV/digest lengths are requested with two new functions
> odp_crypto_cipher_capa() and odp_crypto_auth_capa(). Usage of HMAC is included
> into authentication algorithm name (it used to be implicit). Only currently
> supported and validation tested algorithms are defined, but later on e.g. MD5
> or SHA-256 (without HMAC) may be defined as well as a set of new algorithms.
>
> Supported key/IV/digest lengths are set to values that pass current validation
> test suite. Some tests may need to be updated with their key/IV/digest length
> usage. For example, AES-GCM authentication test uses key length of zero bytes
> (since it's paired with AES-GCM cipher).
>
>
> v2:
>   * deprecate _params_t and use _param_t instead
>   * rename cipher/auth_capa_t to _capability_t
>   * rename cipher/auth_capa() to _capability()
>
>
> Petri Savolainen (10):
>   api: crypto: rename _params_t to _param_t
>   linux-gen: crypto: rename params to param
>   api: crypto: decouple key length from algorithm enumeration
>   linux-gen: crypto: add algo capability functions
>   linux-gen: crypto: add support to new enumerations
>   api: crypto: added session param init
>   api: crypto: documentation clean up
>   test: crypto: use odp_crypto_session_param_init
>   validation: crypto: use algorithm capability
>   example: ipsec: use op_param_t instead of op_params_t
>
>  example/ipsec/odp_ipsec.c  |   6 +-
>  example/ipsec/odp_ipsec_cache.c|   4 +-
>  include/odp/api/spec/crypto.h  | 441 ++-
>  .../linux-generic/include/odp_crypto_internal.h|  21 +-
>  platform/linux-generic/odp_crypto.c| 489 
> +
>  test/common_plat/performance/odp_crypto.c  |   9 +-
>  .../validation/api/crypto/odp_crypto_test_inp.c| 120 +++--
>  7 files changed, 744 insertions(+), 346 deletions(-)
>
> --
> 2.8.1
>


Re: [lng-odp] [API-NEXT PATCH v3 01/10] api: crypto: rename _params_t to _param_t

2016-12-08 Thread Bill Fischofer
Excellent idea about deprecating the old names while introducing the new ones.

On Thu, Dec 8, 2016 at 8:25 AM, Petri Savolainen
 wrote:
> The common naming convention for parameter types is _param_t
> (without 's'). Old type names remain for backwards compatibility,
> but are deprecated.
>
> Signed-off-by: Petri Savolainen 

Reviewed-by: Bill Fischofer 

> ---
>  include/odp/api/spec/crypto.h | 22 ++
>  1 file changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
> index 0cb8814..f24f527 100644
> --- a/include/odp/api/spec/crypto.h
> +++ b/include/odp/api/spec/crypto.h
> @@ -171,7 +171,7 @@ typedef struct odp_crypto_data_range {
>  /**
>   * Crypto API session creation parameters
>   */
> -typedef struct odp_crypto_session_params {
> +typedef struct odp_crypto_session_param_t {
> odp_crypto_op_t op;/**< Encode versus decode */
> odp_bool_t auth_cipher_text;   /**< Authenticate/cipher ordering 
> */
> odp_crypto_op_mode_t pref_mode;/**< Preferred sync vs async */
> @@ -182,7 +182,10 @@ typedef struct odp_crypto_session_params {
> odp_crypto_key_t auth_key; /**< Authentication key */
> odp_queue_t compl_queue;   /**< Async mode completion event 
> queue */
> odp_pool_t output_pool;/**< Output buffer pool */
> -} odp_crypto_session_params_t;
> +} odp_crypto_session_param_t;
> +
> +/** @deprecated  Use odp_crypto_session_param_t instead */
> +typedef odp_crypto_session_param_t odp_crypto_session_params_t;
>
>  /**
>   * @var odp_crypto_session_params_t::auth_cipher_text
> @@ -209,7 +212,7 @@ typedef struct odp_crypto_session_params {
>  /**
>   * Crypto API per packet operation parameters
>   */
> -typedef struct odp_crypto_op_params {
> +typedef struct odp_crypto_op_param_t {
> odp_crypto_session_t session;   /**< Session handle from creation */
> void *ctx;  /**< User context */
> odp_packet_t pkt;   /**< Input packet buffer */
> @@ -218,7 +221,10 @@ typedef struct odp_crypto_op_params {
> uint32_t hash_result_offset;/**< Offset from start of packet 
> buffer for hash result */
> odp_crypto_data_range_t cipher_range;   /**< Data range to apply 
> cipher */
> odp_crypto_data_range_t auth_range; /**< Data range to 
> authenticate */
> -} odp_crypto_op_params_t;
> +} odp_crypto_op_param_t;
> +
> +/** @deprecated  Use odp_crypto_op_param_t instead */
> +typedef odp_crypto_op_param_t odp_crypto_op_params_t;
>
>  /**
>   * @var odp_crypto_op_params_t::pkt
> @@ -349,14 +355,14 @@ int odp_crypto_capability(odp_crypto_capability_t 
> *capa);
>  /**
>   * Crypto session creation (synchronous)
>   *
> - * @param paramsSession parameters
> + * @param param Session parameters
>   * @param session   Created session else ODP_CRYPTO_SESSION_INVALID
>   * @param statusFailure code if unsuccessful
>   *
>   * @retval 0 on success
>   * @retval <0 on failure
>   */
> -int odp_crypto_session_create(odp_crypto_session_params_t *params,
> +int odp_crypto_session_create(odp_crypto_session_param_t *param,
>   odp_crypto_session_t *session,
>   odp_crypto_ses_create_err_t *status);
>
> @@ -410,14 +416,14 @@ void odp_crypto_compl_free(odp_crypto_compl_t 
> completion_event);
>   * If "posted" returns TRUE the result will be delivered via the completion
>   * queue specified when the session was created.
>   *
> - * @param paramsOperation parameters
> + * @param param Operation parameters
>   * @param postedPointer to return posted, TRUE for async 
> operation
>   * @param resultResults of operation (when posted returns FALSE)
>   *
>   * @retval 0 on success
>   * @retval <0 on failure
>   */
> -int odp_crypto_operation(odp_crypto_op_params_t *params,
> +int odp_crypto_operation(odp_crypto_op_param_t *param,
>  odp_bool_t *posted,
>  odp_crypto_op_result_t *result);
>
> --
> 2.8.1
>


Re: [lng-odp] [API-NEXT PATCHv7 1/3] api: random: add explicit controls over random data

2016-12-08 Thread Bill Fischofer
On Thu, Dec 8, 2016 at 2:05 AM, Savolainen, Petri (Nokia - FI/Espoo)
 wrote:
>>  /**
>> + * Random kind selector
>> + *
>> + * The kind of random denotes the statistical quality of the random data
>> + * returned. Basic random simply appears uniformly distributed,
>> Cryptographic
>> + * random is statistically random and suitable for use by cryptographic
>> + * functions. True random is generated from a hardware entropy source
>> rather
>> + * than an algorithm and is thus completely unpredictable. These form a
>> + * hierarchy where higher quality data is presumably more costly to
>> generate
>> + * than lower quality data.
>> + */
>> +typedef enum {
>> + /** Basic random, presumably pseudo-random generated by SW */
>> + ODP_RANDOM_BASIC,
>> + /** Cryptographic quality random */
>> + ODP_RANDOM_CRYPTO,
>> + /** True random, generated from a HW entropy source */
>> + ODP_RANDOM_TRUE,
>> +} odp_random_kind_t;
>> +
>> +/**
>> + * Query random max kind
>> + *
>> + * Implementations support the returned max kind and all kinds weaker
>> than it.
>
> I think this is still not explicit enough on the order: which end is "max" on 
> the enumeration. Something like:
>
> "The maximum kind value is ODP_RANDOM_TRUE."
>
> Or in the enum:
>
> /** True random, generated from a HW entropy source. This is the maximum kind 
> value. */
> ODP_RANDOM_TRUE,
>
>
>> + *
>> + * @return kind The maximum odp_random_kind_t supported by this
>> implementation
>> + */
>> +odp_random_kind_t odp_random_max_kind(void);
>> +
>
>> +
>> +/**
>> + * Generate repeatable random byte data
>> + *
>> + * For testing purposes it is often useful to generate "random" sequences
>> that
>> + * are repeatable. This is accomplished by supplying a seed value that is
>> used
>> + * for pseudo-random data generation. The caller-provided seed value is
>> + * updated for each call to continue the sequence. Restarting a series of
>> + * calls with the same initial seed value will generate the same sequence
>> of
>> + * random test data.
>> + *
>> + * This function should be used only for testing purposes. Use
>> + * odp_random_data() for production.
>>   *
>> - * @todo Define the implication of the use_entropy parameter
>> + * @param[out]buf  Output buffer
>> + * @param len  Length of output buffer in bytes
>> + * @param kind Specifies the type of random data required.
>> Request
>> + * will fail if the implementation is unable to
>> provide
>> + * repeatable random of the requested type. This is
>> + * always true for true random and may be true for
>> + * cryptographic random.
>> + * @param[in,out] seed Seed value to use
>>   *
>>   * @return Number of bytes written
>>   * @retval <0 on failure
>>   */
>> -int32_t odp_random_data(uint8_t *buf, int32_t size, odp_bool_t
>> use_entropy);
>> +int32_t odp_random_repeatable_data(uint8_t *buf, uint32_t len,
>> +odp_random_kind_t kind, uint32_t *seed);
>
>
>
> It seems that you missed my proposal for the prototype. See under.
>
> /**
>  * Generate repeatable random data for testing purposes
>  *
>  * For testing purposes it is often useful to generate "random" sequences
>  * that are repeatable...
>  *
>  * This function should be used only for testing purposes, use 
> odp_random_data()
>  * for production.
>  */
> int32_t odp_random_test_data(uint8_t *buf, uint32_t len, odp_random_kind_t 
> kind, uint64_t *seed);
>
>
> It's a function to generate random data for testing purposes. Also note the 
> longer seed, which enables usage of e.g. 48 bit random libraries.
>

v8 submitted with suggested changes except seed is kept as uint32_t
since these alternate rand functions have been deprecated. See
http://stackoverflow.com/questions/25269428/why-are-drand48-and-friends-obsolete
for a discussion.

>
> -Petri
>
>
>
>
>
>
>


[lng-odp] [API-NEXT PATCHv8 3/3] doc: userguide: expand crypto documentation to cover random apis

2016-12-08 Thread Bill Fischofer
Clean up the crypto section of the User Guide and expand on the
ODP random data APIs.

Signed-off-by: Bill Fischofer 
---
 doc/users-guide/users-guide-crypto.adoc | 93 +
 1 file changed, 72 insertions(+), 21 deletions(-)

diff --git a/doc/users-guide/users-guide-crypto.adoc 
b/doc/users-guide/users-guide-crypto.adoc
index 04b3e87..fa49a0f 100644
--- a/doc/users-guide/users-guide-crypto.adoc
+++ b/doc/users-guide/users-guide-crypto.adoc
@@ -1,7 +1,8 @@
 == Cryptographic services
 
 ODP provides APIs to perform cryptographic operations required by various
-communication protocols (e.g. IPSec). ODP cryptographic APIs are session based.
+communication protocols (_e.g.,_ IPsec). ODP cryptographic APIs are session
+based.
 
 ODP provides APIs for following cryptographic services:
 
@@ -19,24 +20,26 @@ ODP supports synchronous and asynchronous crypto sessions. 
For asynchronous
 sessions, the output of crypto operation is posted in a queue defined as
 the completion queue in its session parameters.
 
-ODP crypto APIs support chained operation sessions in which hashing and 
ciphering
-both can be achieved using a single session and operation call. The order of
-cipher and hashing can be controlled by the `auth_cipher_text` session 
parameter.
+ODP crypto APIs support chained operation sessions in which hashing and
+ciphering both can be achieved using a single session and operation call. The
+order of cipher and hashing can be controlled by the `auth_cipher_text`
+session parameter.
 
 Other Session parameters include algorithms, keys, initialization vector
-(optional), encode or decode, output queue for async mode and output packet 
pool
-for allocation of an output packet if required.
+(optional), encode or decode, output queue for async mode and output packet
+pool for allocation of an output packet if required.
 
 === Crypto operations
 
 After session creation, a cryptographic operation can be applied to a packet
 using the `odp_crypto_operation()` API. Applications may indicate a preference
-for synchronous or asynchronous processing in the session's `pref_mode` 
parameter.
-However crypto operations may complete synchronously even if an asynchronous
-preference is indicated, and applications must examine the `posted` output
-parameter from `odp_crypto_operation()` to determine whether the operation has
-completed or if an `ODP_EVENT_CRYPTO_COMPL` notification is expected. In the 
case
-of an async operation, the `posted` output parameter will be set to true.
+for synchronous or asynchronous processing in the session's `pref_mode`
+parameter.  However crypto operations may complete synchronously even if an
+asynchronous preference is indicated, and applications must examine the
+`posted` output parameter from `odp_crypto_operation()` to determine whether
+the operation has completed or if an `ODP_EVENT_CRYPTO_COMPL` notification is
+expected. In the case of an async operation, the `posted` output parameter
+will be set to true.
 
 
 The operation arguments specify for each packet the areas that are to be
@@ -49,9 +52,9 @@ In case of out-of-place mode output packet is different from 
input packet as
 specified by the application, while in new buffer mode implementation allocates
 a new output buffer from the session’s output pool.
 
-The application can also specify a context associated with a given operation 
that
-will be retained during async operation and can be retrieved via the completion
-event.
+The application can also specify a context associated with a given operation
+that will be retained during async operation and can be retrieved via the
+completion event.
 
 Results of an asynchronous session will be posted as completion events to the
 session’s completion queue, which can be accessed directly or via the ODP
@@ -60,12 +63,60 @@ result. The application has the responsibility to free the 
completion event.
 
 === Random number Generation
 
-ODP provides an API `odp_random_data()` to generate random data bytes. It has
-an argument to specify whether to use system entropy source for random number
-generation or not.
+ODP provides two APIs to generate various kinds of random data bytes. Random
+data is characterized by _kind_, which specifies the "quality" of the
+randomness required. ODP support three kinds of random data:
+
+ODP_RANDOM_BASIC:: No specific requirement other than the data appear to be
+uniformly distributed. Suitable for load-balancing or other non-cryptographic
+use.
+
+ODP_RANDOM_CRYPTO:: Data suitable for cryptographic use. This is a more
+stringent requirement that the data pass tests for statistical randomness.
+
+ODP_RANDOM_TRUE:: Data generated from a hardware entropy source rather than
+any software generated pseudo-random data. May not be available on all
+platforms.
+
+These form a hierarchy with BASIC being the lowest kind of random and TRUE
+behing the highest. The main API for accessing random data is:
+

[lng-odp] [API-NEXT PATCHv8 1/3] api: random: add explicit controls over random data

2016-12-08 Thread Bill Fischofer
Rework the odp_random_data() API to replace the use_entropy with an
explicit odp_random_kind parameter that controls the type of random
desired. Two new APIs are also introduced:

- odp_random_max_kind() returns the maximum kind of random data available

- odp_random_test_data() permits applications to generate repeatable
  random sequences for testing purposes

Signed-off-by: Bill Fischofer 
---
Changes in v8:
- Clarify random kind hierarchy more explicitly
- Rename odp_random_repeatable_data() to odp_random_test_data()

Changes in v7:
- Clarify hierarchy of random kinds
- Expand on intended use of odp_random_repeatable_data()

Changes in v6:
- Add odp_random_max_kind() API instead of adding this to the
  odp_crypto_capability() API.
- Rename odp_random_seeded_data() to odp_random_repeatable_data()
- Merge API defs, implementation, and validation to preserve bisectability

Changes in v5:
- Change return type from int to int32_t for random APIs

Changes in v4:
- Normalize random API signatures with other ODP APIs
- Add new odp_random_seeded_data() API for repeatable random data generation
- Add additional tests for new odp_random_seeded_data() API
- Break out crypto section of User Guide to its own sub-document
- Add User Guide docuemntation for ODP random data API.

Changes in v3:
- Address commments by Petri
- Rename ODP_RAND_NORMAL to ODP_RANDOM_BASIC to avoid confusion with the
mathematical term "normal"

 include/odp/api/spec/random.h   | 76 +++--
 platform/linux-generic/odp_crypto.c | 50 ++--
 test/common_plat/validation/api/random/random.c | 54 +-
 test/common_plat/validation/api/random/random.h |  2 +
 4 files changed, 172 insertions(+), 10 deletions(-)

diff --git a/include/odp/api/spec/random.h b/include/odp/api/spec/random.h
index 00fa15b..bf1ca4a 100644
--- a/include/odp/api/spec/random.h
+++ b/include/odp/api/spec/random.h
@@ -24,18 +24,86 @@ extern "C" {
  */
 
 /**
+ * Random kind selector
+ *
+ * The kind of random denotes the statistical quality of the random data
+ * returned. Basic random simply appears uniformly distributed, Cryptographic
+ * random is statistically random and suitable for use by cryptographic
+ * functions. True random is generated from a hardware entropy source rather
+ * than an algorithm and is thus completely unpredictable. These form a
+ * hierarchy where higher quality data is presumably more costly to generate
+ * than lower quality data.
+ */
+typedef enum {
+   /** Basic random, presumably pseudo-random generated by SW. This
+*  is the lowest kind of random */
+   ODP_RANDOM_BASIC,
+   /** Cryptographic quality random */
+   ODP_RANDOM_CRYPTO,
+   /** True random, generated from a HW entropy source. This is the
+*  highest kind of random */
+   ODP_RANDOM_TRUE,
+} odp_random_kind_t;
+
+/**
+ * Query random max kind
+ *
+ * Implementations support the returned max kind and all kinds weaker than it.
+ *
+ * @return kind The maximum odp_random_kind_t supported by this implementation
+ */
+odp_random_kind_t odp_random_max_kind(void);
+
+/**
  * Generate random byte data
  *
+ * The intent in supporting different kinds of random data is to allow
+ * tradeoffs between performance and the quality of random data needed. The
+ * assumption is that basic random is cheap while true random is relatively
+ * expensive in terms of time to generate, with cryptographic random being
+ * something in between. Implementations that support highly efficient true
+ * random are free to use this for all requested kinds. So it is always
+ * permissible to "upgrade" a random data request, but never to "downgrade"
+ * such requests.
+ *
  * @param[out]buf   Output buffer
- * @param size  Size of output buffer
- * @param use_entropy   Use entropy
+ * @param len   Length of output buffer in bytes
+ * @param kind  Specifies the type of random data required. Request
+ *  is expected to fail if the implementation is unable to
+ *  provide the requested type.
+ *
+ * @return Number of bytes written
+ * @retval <0 on failure
+ */
+int32_t odp_random_data(uint8_t *buf, uint32_t len, odp_random_kind_t kind);
+
+/**
+ * Generate repeatable random data for testing purposes
+ *
+ * For testing purposes it is often useful to generate "random" sequences that
+ * are repeatable. This is accomplished by supplying a seed value that is used
+ * for pseudo-random data generation. The caller-provided seed value is
+ * updated for each call to continue the sequence. Restarting a series of
+ * calls with the same initial seed value will generate the same sequence of
+ * random test data.
+ *
+ * This function should be used only for testing purposes. Use
+ * odp_random_data() for production.
  *
- * @todo Define the implication of the use_entropy parameter
+ * @param[out]buf  Output buffer
+ * 

[lng-odp] [API-NEXT PATCHv8 2/3] doc: userguide: move crypto documentation to its own sub-document

2016-12-08 Thread Bill Fischofer
Signed-off-by: Bill Fischofer 
---
 doc/users-guide/Makefile.am |  1 +
 doc/users-guide/users-guide-crypto.adoc | 71 
 doc/users-guide/users-guide.adoc| 72 +
 3 files changed, 73 insertions(+), 71 deletions(-)
 create mode 100644 doc/users-guide/users-guide-crypto.adoc

diff --git a/doc/users-guide/Makefile.am b/doc/users-guide/Makefile.am
index a01c717..01b4df3 100644
--- a/doc/users-guide/Makefile.am
+++ b/doc/users-guide/Makefile.am
@@ -2,6 +2,7 @@ include ../Makefile.inc
 
 SRC= $(top_srcdir)/doc/users-guide/users-guide.adoc \
 $(top_srcdir)/doc/users-guide/users-guide-cls.adoc \
+$(top_srcdir)/doc/users-guide/users-guide-crypto.adoc \
 $(top_srcdir)/doc/users-guide/users-guide-packet.adoc \
 $(top_srcdir)/doc/users-guide/users-guide-pktio.adoc \
 $(top_srcdir)/doc/users-guide/users-guide-timer.adoc \
diff --git a/doc/users-guide/users-guide-crypto.adoc 
b/doc/users-guide/users-guide-crypto.adoc
new file mode 100644
index 000..04b3e87
--- /dev/null
+++ b/doc/users-guide/users-guide-crypto.adoc
@@ -0,0 +1,71 @@
+== Cryptographic services
+
+ODP provides APIs to perform cryptographic operations required by various
+communication protocols (e.g. IPSec). ODP cryptographic APIs are session based.
+
+ODP provides APIs for following cryptographic services:
+
+* Ciphering
+* Authentication/data integrity via Keyed-Hashing (HMAC)
+* Random number generation
+* Crypto capability inquiries
+
+=== Crypto Sessions
+
+To apply a cryptographic operation to a packet a session must be created. All
+packets processed by a session share the parameters that define the session.
+
+ODP supports synchronous and asynchronous crypto sessions. For asynchronous
+sessions, the output of crypto operation is posted in a queue defined as
+the completion queue in its session parameters.
+
+ODP crypto APIs support chained operation sessions in which hashing and 
ciphering
+both can be achieved using a single session and operation call. The order of
+cipher and hashing can be controlled by the `auth_cipher_text` session 
parameter.
+
+Other Session parameters include algorithms, keys, initialization vector
+(optional), encode or decode, output queue for async mode and output packet 
pool
+for allocation of an output packet if required.
+
+=== Crypto operations
+
+After session creation, a cryptographic operation can be applied to a packet
+using the `odp_crypto_operation()` API. Applications may indicate a preference
+for synchronous or asynchronous processing in the session's `pref_mode` 
parameter.
+However crypto operations may complete synchronously even if an asynchronous
+preference is indicated, and applications must examine the `posted` output
+parameter from `odp_crypto_operation()` to determine whether the operation has
+completed or if an `ODP_EVENT_CRYPTO_COMPL` notification is expected. In the 
case
+of an async operation, the `posted` output parameter will be set to true.
+
+
+The operation arguments specify for each packet the areas that are to be
+encrypted or decrypted and authenticated. Also, there is an option of 
overriding
+the initialization vector specified in session parameters.
+
+An operation can be executed in in-place, out-of-place or new buffer mode.
+In in-place mode output packet is same as the input packet.
+In case of out-of-place mode output packet is different from input packet as
+specified by the application, while in new buffer mode implementation allocates
+a new output buffer from the session’s output pool.
+
+The application can also specify a context associated with a given operation 
that
+will be retained during async operation and can be retrieved via the completion
+event.
+
+Results of an asynchronous session will be posted as completion events to the
+session’s completion queue, which can be accessed directly or via the ODP
+scheduler. The completion event contains the status of the operation and the
+result. The application has the responsibility to free the completion event.
+
+=== Random number Generation
+
+ODP provides an API `odp_random_data()` to generate random data bytes. It has
+an argument to specify whether to use system entropy source for random number
+generation or not.
+
+=== Capability inquiries
+
+ODP provides an API interface `odp_crypto_capability()` to inquire 
implementation’s
+crypto capabilities. This interface returns a bitmask for supported algorithms
+and hardware backed algorithms.
diff --git a/doc/users-guide/users-guide.adoc b/doc/users-guide/users-guide.adoc
index 9a427fa..41c57d1 100755
--- a/doc/users-guide/users-guide.adoc
+++ b/doc/users-guide/users-guide.adoc
@@ -1018,77 +1018,7 @@ include::users-guide-pktio.adoc[]
 
 include::users-guide-timer.adoc[]
 
-== Cryptographic services
-
-ODP provides APIs to perform cryptographic operations required by various
-communication protocols (e.g. IPSec). 

Re: [lng-odp] [API-NEXT PATCH v2 4/7] api: crypto: added session params init

2016-12-08 Thread Mike Holmes
If we do it now there is a long lead time to TigerMoth for people to become
aware of the change

On 7 December 2016 at 05:29, Savolainen, Petri (Nokia - FI/Espoo) <
petri.savolai...@nokia-bell-labs.com> wrote:

> > >  /**
> > > + * Initialize crypto session parameters
> > > + *
> > > + * Initialize an odp_crypto_session_params_t to its default values for
> > > + * all fields.
> > > + *
> > > + * @param params   Pointer to odp_crypto_session_params_t to be
> > initialized
> > > + */
> > > +void odp_crypto_session_params_init(odp_crypto_session_params_t
> > *params);
> >
> > Since we're cleaning up and adding this for completeness, the
> > underlying struct should be changed to odp_crypto_session_param_t and
> > this API should be odp_crypto_session_param_init() for consistency
> > with all other odp_xxx_param_t and odp_xxx_param_init() functions. The
> > inconsistent use of params instead of param in the crypto API was an
> > oversight in Monarch.
> >
>
> It would be nice if only _param_t would be used throughout all APIs, but
> this would not be the only one to change. This is the list of all _params_t:
>
> odp_crypto_session_params_t
> odp_crypto_op_params_t
>
> odp_tm_shaper_params_t
> odp_tm_sched_params_t
> odp_tm_threshold_params_t
> odp_tm_wred_params_t
> odp_tm_node_params_t
> odp_tm_queue_params_t
>
> odph_linux_thr_params_t
> odph_odpthread_params_t
>
>
> It's questionable if it pays off to rename 8 types in the API, since type
> name change is non-backward compatible and the gain is rather cosmetic /
> nice-to-have. I could deprecated old type names for crypto in this patch
> set and add new ones if everybody agrees.
>
> -Petri
>
>


-- 
Mike Holmes
Program Manager - Linaro Networking Group
Linaro.org  *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"


Re: [lng-odp] [PATCH v2 4/6] helper: use ODP_LIB_FLAVOR to generate libodp name

2016-12-08 Thread Mike Holmes
So this https://github.com/mike-holmes-linaro/odp/tree/helpers-os is what I
was thinking

It moves the Linux specifics to helper/os/linux and selects the helper os
to be built in the configure step
It renames the linux.h helper include to threads.h which is what it
predominately is
It also removes the unused Linux specific  APIs since no odp test or
example uses them and they break having an OS agnostic helper suite.

On 8 December 2016 at 13:44, Mike Holmes  wrote:

>
>
> On 7 December 2016 at 01:54, Nicolas Morey-Chaisemartin 
> wrote:
>
>>
>>
>> Le 12/06/2016 à 09:37 PM, Mike Holmes a écrit :
>> > On 6 December 2016 at 12:08, Nicolas Morey-Chaisemartin
>> >  wrote:
>> >> Signed-off-by: Nicolas Morey-Chaisemartin 
>> >> ---
>> >>  helper/Makefile.am  | 6 +++---
>> >>  helper/test/Makefile.am | 6 +++---
>> >>  2 files changed, 6 insertions(+), 6 deletions(-)
>> >>
>> >> diff --git a/helper/Makefile.am b/helper/Makefile.am
>> >> index d09d900..c75db00 100644
>> >> --- a/helper/Makefile.am
>> >> +++ b/helper/Makefile.am
>> >> @@ -1,7 +1,7 @@
>> >>  include $(top_srcdir)/platform/@with_platform@/Makefile.inc
>> >>
>> >>  pkgconfigdir = $(libdir)/pkgconfig
>> >> -pkgconfig_DATA = $(top_builddir)/pkgconfig/libodphelper-linux.pc
>> >> +pkgconfig_DATA = $(top_builddir)/pkgconfig/libo
>> dphelper@ODP_LIB_FLAVOR@.pc
>> > Why would the helpers be tied to the implementation being built ? They
>> > should be agnostic and depend on the OS
>> I agree that they should not depend on the implementation of ODP. But as
>> for libodp, helper might not be ABI compatible.
>> The issue is that there's no evident place in the connfigure to select
>> which implementation of the helper should be used.
>> platform configure.m4 are the easiest place to add this which ties this
>> to the platform.
>> But I could add an ODPH_LIB_IMPL. So several platforms could use the same
>> helper, while keeping the possibility of using non ABI compatible versions
>> in other platforms.
>>
>> > I think the helpers are broken or we need an alternative to linux.c in
>> > there, perhaps a odp/helpers/platform/linux/linux.c and
>> > odp/helpers/platform/mpaa/linux.c
>> I changed it in our git tree. helper/linux.c got moved to
>> helper/os/linux/linux.c
>> And we added helper/os/nodeos/linux.c and helper/os/mos/linux.c (we have
>> 2 OS flavors usable with ODP)
>> The platform configure.m4 is in charge of selecting the OS depending on
>> flags & compiler selected.
>>
>
> I would be keen to do the same thing master, if it is OS differences then
> that is much more in keeping with the intent.
> I will play with a patch to move linux.c under and OS directory called
> linux
>
>
>> >
>> >>  LIB   = $(top_builddir)/lib
>> >>  AM_CFLAGS  = -I$(srcdir)/include
>> >> @@ -31,7 +31,7 @@ noinst_HEADERS = \
>> >>  $(srcdir)/odph_lineartable.h \
>> >>  $(srcdir)/odph_list_internal.h
>> >>
>> >> -__LIB__libodphelper_linux_la_SOURCES = \
>> >> +__LIB__libodphelper@ODP_LIB_FLAVOR@_la_SOURCES = \
>> >> eth.c \
>> >> ip.c \
>> >> chksum.c \
>> >> @@ -39,4 +39,4 @@ __LIB__libodphelper_linux_la_SOURCES = \
>> >> hashtable.c \
>> >> lineartable.c
>> >>
>> >> -lib_LTLIBRARIES = $(LIB)/libodphelper-linux.la
>> >> +lib_LTLIBRARIES = $(LIB)/libodphelper@ODP_LIB_FLAVOR@.la
>> >> diff --git a/helper/test/Makefile.am b/helper/test/Makefile.am
>> >> index 545db73..02c260c 100644
>> >> --- a/helper/test/Makefile.am
>> >> +++ b/helper/test/Makefile.am
>> >> @@ -28,10 +28,10 @@ EXTRA_DIST = odpthreads_as_processes
>> odpthreads_as_pthreads
>> >>
>> >>  dist_chksum_SOURCES = chksum.c
>> >>  dist_odpthreads_SOURCES = odpthreads.c
>> >> -odpthreads_LDADD = $(LIB)/libodphelper-linux.la $(LIB)/
>> libodp-linux.la
>> >> +odpthreads_LDADD = $(LIB)/libodphelper@ODP_LIB_FLAVOR@.la
>> $(LIB)/libodp@ODP_LIB_FLAVOR@.la
>> >>  dist_thread_SOURCES = thread.c
>> >> -thread_LDADD = $(LIB)/libodphelper-linux.la $(LIB)/libodp-linux.la
>> >> +thread_LDADD = $(LIB)/libodphelper@ODP_LIB_FLAVOR@.la
>> $(LIB)/libodp@ODP_LIB_FLAVOR@.la
>> >>  dist_process_SOURCES = process.c
>> >>  dist_parse_SOURCES = parse.c
>> >> -process_LDADD = $(LIB)/libodphelper-linux.la $(LIB)/libodp-linux.la
>> >> +process_LDADD = $(LIB)/libodphelper@ODP_LIB_FLAVOR@.la
>> $(LIB)/libodp@ODP_LIB_FLAVOR@.la
>> >>  dist_table_SOURCES = table.c
>> >> --
>> >> 2.10.1.4.g0ffc436
>> >>
>> >>
>> >
>> >
>>
>>
>
>
> --
> Mike Holmes
> Program Manager - Linaro Networking Group
> Linaro.org  *│ *Open source software for ARM SoCs
> "Work should be fun and collaborative, the rest follows"
>
>
>


-- 
Mike Holmes
Program Manager - Linaro Networking Group
Linaro.org  *│ *Open source software for 

Re: [lng-odp] [PATCH v2 4/6] helper: use ODP_LIB_FLAVOR to generate libodp name

2016-12-08 Thread Mike Holmes
On 7 December 2016 at 01:54, Nicolas Morey-Chaisemartin 
wrote:

>
>
> Le 12/06/2016 à 09:37 PM, Mike Holmes a écrit :
> > On 6 December 2016 at 12:08, Nicolas Morey-Chaisemartin
> >  wrote:
> >> Signed-off-by: Nicolas Morey-Chaisemartin 
> >> ---
> >>  helper/Makefile.am  | 6 +++---
> >>  helper/test/Makefile.am | 6 +++---
> >>  2 files changed, 6 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/helper/Makefile.am b/helper/Makefile.am
> >> index d09d900..c75db00 100644
> >> --- a/helper/Makefile.am
> >> +++ b/helper/Makefile.am
> >> @@ -1,7 +1,7 @@
> >>  include $(top_srcdir)/platform/@with_platform@/Makefile.inc
> >>
> >>  pkgconfigdir = $(libdir)/pkgconfig
> >> -pkgconfig_DATA = $(top_builddir)/pkgconfig/libodphelper-linux.pc
> >> +pkgconfig_DATA = $(top_builddir)/pkgconfig/libodphelper@ODP_LIB_FLAVOR
> @.pc
> > Why would the helpers be tied to the implementation being built ? They
> > should be agnostic and depend on the OS
> I agree that they should not depend on the implementation of ODP. But as
> for libodp, helper might not be ABI compatible.
> The issue is that there's no evident place in the connfigure to select
> which implementation of the helper should be used.
> platform configure.m4 are the easiest place to add this which ties this to
> the platform.
> But I could add an ODPH_LIB_IMPL. So several platforms could use the same
> helper, while keeping the possibility of using non ABI compatible versions
> in other platforms.
>
> > I think the helpers are broken or we need an alternative to linux.c in
> > there, perhaps a odp/helpers/platform/linux/linux.c and
> > odp/helpers/platform/mpaa/linux.c
> I changed it in our git tree. helper/linux.c got moved to
> helper/os/linux/linux.c
> And we added helper/os/nodeos/linux.c and helper/os/mos/linux.c (we have 2
> OS flavors usable with ODP)
> The platform configure.m4 is in charge of selecting the OS depending on
> flags & compiler selected.
>

I would be keen to do the same thing master, if it is OS differences then
that is much more in keeping with the intent.
I will play with a patch to move linux.c under and OS directory called linux


> >
> >>  LIB   = $(top_builddir)/lib
> >>  AM_CFLAGS  = -I$(srcdir)/include
> >> @@ -31,7 +31,7 @@ noinst_HEADERS = \
> >>  $(srcdir)/odph_lineartable.h \
> >>  $(srcdir)/odph_list_internal.h
> >>
> >> -__LIB__libodphelper_linux_la_SOURCES = \
> >> +__LIB__libodphelper@ODP_LIB_FLAVOR@_la_SOURCES = \
> >> eth.c \
> >> ip.c \
> >> chksum.c \
> >> @@ -39,4 +39,4 @@ __LIB__libodphelper_linux_la_SOURCES = \
> >> hashtable.c \
> >> lineartable.c
> >>
> >> -lib_LTLIBRARIES = $(LIB)/libodphelper-linux.la
> >> +lib_LTLIBRARIES = $(LIB)/libodphelper@ODP_LIB_FLAVOR@.la
> >> diff --git a/helper/test/Makefile.am b/helper/test/Makefile.am
> >> index 545db73..02c260c 100644
> >> --- a/helper/test/Makefile.am
> >> +++ b/helper/test/Makefile.am
> >> @@ -28,10 +28,10 @@ EXTRA_DIST = odpthreads_as_processes
> odpthreads_as_pthreads
> >>
> >>  dist_chksum_SOURCES = chksum.c
> >>  dist_odpthreads_SOURCES = odpthreads.c
> >> -odpthreads_LDADD = $(LIB)/libodphelper-linux.la $(LIB)/libodp-linux.la
> >> +odpthreads_LDADD = $(LIB)/libodphelper@ODP_LIB_FLAVOR@.la
> $(LIB)/libodp@ODP_LIB_FLAVOR@.la
> >>  dist_thread_SOURCES = thread.c
> >> -thread_LDADD = $(LIB)/libodphelper-linux.la $(LIB)/libodp-linux.la
> >> +thread_LDADD = $(LIB)/libodphelper@ODP_LIB_FLAVOR@.la
> $(LIB)/libodp@ODP_LIB_FLAVOR@.la
> >>  dist_process_SOURCES = process.c
> >>  dist_parse_SOURCES = parse.c
> >> -process_LDADD = $(LIB)/libodphelper-linux.la $(LIB)/libodp-linux.la
> >> +process_LDADD = $(LIB)/libodphelper@ODP_LIB_FLAVOR@.la
> $(LIB)/libodp@ODP_LIB_FLAVOR@.la
> >>  dist_table_SOURCES = table.c
> >> --
> >> 2.10.1.4.g0ffc436
> >>
> >>
> >
> >
>
>


-- 
Mike Holmes
Program Manager - Linaro Networking Group
Linaro.org  *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"


Re: [lng-odp] [PATCH] validation: classification: increase SHM_PKT_BUF_SIZE

2016-12-08 Thread Mike Holmes
I assume we want to support systems without segmentation support, but this
shows that it was not transparent to the application.
Does it mean that applications (in this case test) should have a way to
know this and thus not break or should it be hidden in the implimentation ?

Before commit to relaxing the test just wanted to be sure we dont need a
better  API in master

On 7 December 2016 at 04:21, Nicolas Morey-Chaisemartin 
wrote:

> classification_test_pmr_term_packet_len allocs a packet with 1024
>  of payload + headers which is greater than the segsize used to allocate
>  the pool and breaks on implementation without segmentation support
>
> Signed-off-by: Nicolas Morey-Chaisemartin 
> ---
>
> Should be aplied on monarch_lts too. Applies without conflict apart from
> path change
>
>  test/common_plat/validation/api/classification/classification.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/test/common_plat/validation/api/classification/classification.h
> b/test/common_plat/validation/api/classification/classification.h
> index d73c821..73de40a 100644
> --- a/test/common_plat/validation/api/classification/classification.h
> +++ b/test/common_plat/validation/api/classification/classification.h
> @@ -10,7 +10,7 @@
>  #include 
>
>  #define SHM_PKT_NUM_BUFS32
> -#define SHM_PKT_BUF_SIZE1024
> +#define SHM_PKT_BUF_SIZE1088
>
>  /* Config values for Default CoS */
>  #define TEST_DEFAULT   1
> --
> 2.10.1.4.g0ffc436
>
>


-- 
Mike Holmes
Program Manager - Linaro Networking Group
Linaro.org  *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"


Re: [lng-odp] [PATCH] validation: packet: remove todos from packet tests

2016-12-08 Thread Mike Holmes
On 12 September 2016 at 16:48, Bill Fischofer 
wrote:

> Resolve Bug https://bugs.linaro.org/show_bug.cgi?id=2405 by removing
> todos in packet validation test. Add additional tests for todos that can
> be resolved within current ODP API set and remove the rest to be deferred
> for latest updates.
>
> Signed-off-by: Bill Fischofer 
>

Reviewed-by: Mike Holmes 


> ---
>  test/common_plat/validation/api/packet/packet.c | 56
> -
>  1 file changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/test/common_plat/validation/api/packet/packet.c
> b/test/common_plat/validation/api/packet/packet.c
> index a4426e2..c75cde9 100644
> --- a/test/common_plat/validation/api/packet/packet.c
> +++ b/test/common_plat/validation/api/packet/packet.c
> @@ -32,6 +32,28 @@ static struct udata_struct {
> "abcdefg",
>  };
>
> +static void _packet_compare_data(odp_packet_t pkt1, odp_packet_t pkt2)
> +{
> +   uint32_t len = odp_packet_len(pkt1);
> +   uint32_t offset = 0;
> +   uint32_t seglen1, seglen2, cmplen;
> +
> +   CU_ASSERT_FATAL(len == odp_packet_len(pkt2));
> +
> +   while (len > 0) {
> +   void *pkt1map = odp_packet_offset(pkt1, offset, ,
> NULL);
> +   void *pkt2map = odp_packet_offset(pkt2, offset, ,
> NULL);
> +
> +   CU_ASSERT_PTR_NOT_NULL_FATAL(pkt1map);
> +   CU_ASSERT_PTR_NOT_NULL_FATAL(pkt2map);
> +   cmplen = seglen1 < seglen2 ? seglen1 : seglen2;
> +   CU_ASSERT(!memcmp(pkt1map, pkt2map, cmplen));
> +
> +   offset += cmplen;
> +   len-= cmplen;
> +   }
> +}
> +
>  int packet_suite_init(void)
>  {
> odp_pool_param_t params;
> @@ -298,7 +320,8 @@ void packet_test_event_conversion(void)
>
> tmp_pkt = odp_packet_from_event(ev);
> CU_ASSERT_FATAL(tmp_pkt != ODP_PACKET_INVALID);
> -   /** @todo: Need an API to compare packets */
> +   CU_ASSERT(tmp_pkt == pkt);
> +   _packet_compare_data(tmp_pkt, pkt);
>  }
>
>  void packet_test_basic_metadata(void)
> @@ -502,7 +525,7 @@ void packet_test_headroom(void)
>
> seg_data_len = odp_packet_seg_len(pkt);
> CU_ASSERT(seg_data_len >= 1);
> -   /** @todo: should be len - 1 */
> +
> pull_val = seg_data_len / 2;
> push_val = room;
>
> @@ -625,7 +648,7 @@ void packet_test_tailroom(void)
>
> seg_data_len = odp_packet_seg_data_len(pkt, segment);
> CU_ASSERT(seg_data_len >= 1);
> -   /** @todo: should be len - 1 */
> +
> pull_val = seg_data_len / 2;
> /* Leave one byte in a tailroom for odp_packet_tail() to succeed */
> push_val = (room > 0) ? room - 1 : room;
> @@ -681,10 +704,10 @@ void packet_test_segments(void)
> CU_ASSERT_PTR_NOT_NULL(seg_data);
> CU_ASSERT(odp_packet_seg_to_u64(seg) !=
>   odp_packet_seg_to_u64(ODP_PACKET_SEG_INVALID));
> +   CU_ASSERT(odp_memcmp(seg_data, seg_data, seg_data_len) ==
> 0);
>
> data_len += seg_data_len;
>
> -   /** @todo: touch memory in a segment */
> seg_index++;
> seg = odp_packet_next_seg(pkt, seg);
> }
> @@ -713,10 +736,10 @@ void packet_test_segments(void)
> CU_ASSERT(seg_data != NULL);
> CU_ASSERT(odp_packet_seg_to_u64(seg) !=
>   odp_packet_seg_to_u64(ODP_PACKET_SEG_INVALID));
> +   CU_ASSERT(odp_memcmp(seg_data, seg_data, seg_data_len) ==
> 0);
>
> data_len += seg_data_len;
>
> -   /** @todo: touch memory in a segment */
> seg_index++;
> seg = odp_packet_next_seg(seg_pkt, seg);
> }
> @@ -784,7 +807,6 @@ void packet_test_error_flags(void)
> /**
>  * The packet have not been classified so it doesn't have error
> flags
>  * properly set. Just check that functions return one of allowed
> values.
> -* @todo: try with known good and bad packets.
>  */
> err = odp_packet_has_error(pkt);
> CU_ASSERT(err == 0 || err == 1);
> @@ -922,28 +944,6 @@ static void _packet_compare_inflags(odp_packet_t
> pkt1, odp_packet_t pkt2)
> COMPARE_INFLAG(pkt1, pkt2, shaper_len_adjust);
>  }
>
> -static void _packet_compare_data(odp_packet_t pkt1, odp_packet_t pkt2)
> -{
> -   uint32_t len = odp_packet_len(pkt1);
> -   uint32_t offset = 0;
> -   uint32_t seglen1, seglen2, cmplen;
> -
> -   CU_ASSERT_FATAL(len == odp_packet_len(pkt2));
> -
> -   while (len > 0) {
> -   void *pkt1map = odp_packet_offset(pkt1, offset, ,
> NULL);
> -   void *pkt2map = odp_packet_offset(pkt2, offset, ,
> NULL);
> -
> -   CU_ASSERT_PTR_NOT_NULL_FATAL(pkt1map);
> -   CU_ASSERT_PTR_NOT_NULL_FATAL(pkt2map);
> -   cmplen = seglen1 < 

Re: [lng-odp] [PATCH 1/2] configure: if no ABI reset .so to 0

2016-12-08 Thread Maxim Uvarov
On 12/08/16 18:58, Mike Holmes wrote:
> Thanks Petri
> 
> Maxim can you fix typo on commit  ?
> 

yes, will fix.


> On 8 December 2016 at 02:32, Savolainen, Petri (Nokia - FI/Espoo) <
> petri.savolai...@nokia-bell-labs.com> wrote:
> 
>>
>>
>>> -Original Message-
>>> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of
>> Mike
>>> Holmes
>>> Sent: Wednesday, December 07, 2016 9:43 PM
>>> To: lng-odp@lists.linaro.org
>>> Subject: [lng-odp] [PATCH 1/2] configure: if no ABI reset .so to 0
>>>
>>> Signed-off-by: Mike Holmes 
>>> ---
>>>  configure.ac | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/configure.ac b/configure.ac
>>> index 3e89b0a..543f535 100644
>>> --- a/configure.ac
>>> +++ b/configure.ac
>>> @@ -254,6 +254,8 @@ AC_ARG_ENABLE([abi-compat],
>>>   ODP_ABI_COMPAT=0
>>>   abi_compat=no
>>>   enable_shared=no
>>> + #if there is no API compatibility the .so numbers are meaningless
>>
>> Typo: API => ABI
>>
>> -Petri
>>
>>> + ODP_LIBSO_VERSION=0:0:0
>>>  fi])
>>>  AC_SUBST(ODP_ABI_COMPAT)
>>>
>>> --
>>> 2.9.3
>>
>>
> 
> 



[lng-odp] [Bug 2494] Extend odp_pktio_capability_t to include minimal pool size required by pktio implementation.

2016-12-08 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2494

--- Comment #10 from Bala Manoharan  ---
Hi Mike,

I had a discussion with Maciej, I am looking at his requirement.
Will send an update soon.

Regards,
Bala

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Re: [lng-odp] [PATCH 1/2] configure: if no ABI reset .so to 0

2016-12-08 Thread Mike Holmes
Thanks Petri

Maxim can you fix typo on commit  ?

On 8 December 2016 at 02:32, Savolainen, Petri (Nokia - FI/Espoo) <
petri.savolai...@nokia-bell-labs.com> wrote:

>
>
> > -Original Message-
> > From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of
> Mike
> > Holmes
> > Sent: Wednesday, December 07, 2016 9:43 PM
> > To: lng-odp@lists.linaro.org
> > Subject: [lng-odp] [PATCH 1/2] configure: if no ABI reset .so to 0
> >
> > Signed-off-by: Mike Holmes 
> > ---
> >  configure.ac | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/configure.ac b/configure.ac
> > index 3e89b0a..543f535 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -254,6 +254,8 @@ AC_ARG_ENABLE([abi-compat],
> >   ODP_ABI_COMPAT=0
> >   abi_compat=no
> >   enable_shared=no
> > + #if there is no API compatibility the .so numbers are meaningless
>
> Typo: API => ABI
>
> -Petri
>
> > + ODP_LIBSO_VERSION=0:0:0
> >  fi])
> >  AC_SUBST(ODP_ABI_COMPAT)
> >
> > --
> > 2.9.3
>
>


-- 
Mike Holmes
Program Manager - Linaro Networking Group
Linaro.org  *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"


Re: [lng-odp] [PATCHv2, 1/1] validation: pktio: fix invalid mac addr

2016-12-08 Thread Josep Puigdemont
On Thu, Nov 10, 2016 at 07:58:39PM +0530, Bala Manoharan wrote:
> Fixes https://bugs.linaro.org/show_bug.cgi?id=2496
> 
> Signed-off-by: Balasubramanian Manoharan 
> ---
> v2: Incorporate review comments
>  test/common_plat/validation/api/pktio/pktio.c | 24 +---
>  1 file changed, 21 insertions(+), 3 deletions(-)
> 
> -- 
> 1.9.1
> Signed-off-by: Balasubramanian Manoharan 
> 
> diff --git a/test/common_plat/validation/api/pktio/pktio.c 
> b/test/common_plat/validation/api/pktio/pktio.c
> index a6a18c3..7115def 100644
> --- a/test/common_plat/validation/api/pktio/pktio.c
> +++ b/test/common_plat/validation/api/pktio/pktio.c
> @@ -31,6 +31,8 @@
>  #define PKTIN_TS_MAX_RES   100
>  #define PKTIN_TS_CMP_RES   1
>  
> +#define PKTIO_SRC_MAC{1, 2, 3, 4, 5, 6}
> +#define PKTIO_DST_MAC{1, 2, 3, 4, 5, 6}
>  #undef DEBUG_STATS
>  
>  /** interface names used for testing */
> @@ -241,16 +243,32 @@ static uint32_t pktio_init_packet(odp_packet_t pkt)
>   odph_udphdr_t *udp;
>   char *buf;
>   uint16_t seq;
> - uint8_t mac[ODP_PKTIO_MACADDR_MAXSIZE] = {0};
> + uint8_t src_mac[ODP_PKTIO_MACADDR_MAXSIZE] = PKTIO_SRC_MAC;
> + uint8_t dst_mac[ODP_PKTIO_MACADDR_MAXSIZE] = PKTIO_DST_MAC;
> + uint8_t src_mac_be[ODP_PKTIO_MACADDR_MAXSIZE];
> + uint8_t dst_mac_be[ODP_PKTIO_MACADDR_MAXSIZE];

we don't need big endian versions of the MAC address, it's a string of
bytes, so it has no endianess.

>   int pkt_len = odp_packet_len(pkt);
> + int i;
> +
> + #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
> + for (i = 0; i < ODP_PKTIO_MACADDR_MAXSIZE; i++) {
> + src_mac_be[i] = src_mac[i];
> + dst_mac_be[i] = dst_mac[i];
> + }
> + #else
> + for (i = 0; i < ODP_PKTIO_MACADDR_MAXSIZE; i++) {
> + src_mac_be[i] = src_mac[ODP_PKTIO_MACADDR_MAXSIZE - i];
> + dst_mac_be[i] = dst_mac[ODP_PKTIO_MACADDR_MAXSIZE - i];
> + }
> + #endif

this is not needed.
For other than ODP_LITTLE_ENDIAN this just reverses the MAC address, but I
guess it wouldn't matter for the test.

>  
>   buf = odp_packet_data(pkt);
>  
>   /* Ethernet */
>   odp_packet_l2_offset_set(pkt, 0);
>   eth = (odph_ethhdr_t *)buf;
> - memcpy(eth->src.addr, mac, ODPH_ETHADDR_LEN);
> - memcpy(eth->dst.addr, mac, ODPH_ETHADDR_LEN);
> + memcpy(eth->src.addr, _mac_be, ODPH_ETHADDR_LEN);
> + memcpy(eth->dst.addr, _mac_be, ODPH_ETHADDR_LEN);

use src_mac and dst_mac instead.

Sorry for the late reply, I missed this earlier.

/Josep
>   eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);
>  
>   /* IP */


Re: [lng-odp] odp_rwlock_read_trylock

2016-12-08 Thread Nicolas Morey-Chaisemartin


Le 12/08/2016 à 03:50 PM, Savolainen, Petri (Nokia - FI/Espoo) a écrit :
>
>> -Original Message-
>> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of
>> Nicolas Morey-Chaisemartin
>> Sent: Wednesday, December 07, 2016 10:12 AM
>> To: LNG ODP Mailman List 
>> Subject: [lng-odp] odp_rwlock_read_trylock
>>
>> HI,
>>
>>
>> While looking into the test/code, I noticed something weird in the
>> implementation of the rwlock read trylock on monarch.
>>
>> int odp_rwlock_read_trylock(odp_rwlock_t *rwlock)
>> {
>> uint32_t zero = 0;
>>
>> return odp_atomic_cas_acq_u32(>cnt, , (uint32_t)1);
>> }
>>
>>
>> This mean the trylock only succeed if no one was using the lock. But it
>> will fail if someone was owning it *even* if it is a reader.
>> Is this something expected? If yes, it should probably be detailed in the
>> API.
> /**
>  * Try to acquire read permission to a reader/writer lock.
>  *
>  * @param rwlock Pointer to a reader/writer lock
>  *
>  * @retval  0 Lock was not available for read access
>  * @retval !0 Read access to lock acquired
>  */
> int odp_rwlock_read_trylock(odp_rwlock_t *rwlock);
>
>
> The spec just says that "read access" was not available. Implementation 
> decides when it's available and application just needs to re-try later on. 
> So, this implementation is OK by the spec. Supporting multiple readers would 
> improve parallelism, but it may not be optimal for performance if the lock is 
> free in the common case.
>
>
>>
>> The lock implementation I wrote allows to get the lock if a reader already
>> owns it. And causes the testsuite to deadlock:
>>
>> odp_rwlock_init(rw_lock);
>> /* CU_ASSERT(odp_rwlock_is_locked(rw_lock) == 0); */
>>
>> odp_rwlock_read_lock(rw_lock); => Lock is owned in read
>>
>> rc = odp_rwlock_read_trylock(rw_lock); => Locked is owned a second
>> time in read (rc = 1)
>
> You cannot do this on a single thread (lock the same lock twice). You must 
> use recursive locks if the thread holding a lock will lock it again.
>  

The issue is odp_rwlock_read_trylock fails here, but odp_rwlock_read_lock would 
succeed.
Usually rwlock are recursive on the read side as it doesn't really matter to 
the lock if the same thread owns it N times, or N threads own it once each.
IMHO, in a non-concurrent setup, read_trylock should always succeed if 
read_lock would succeed.
(I say non concurrent here to not acount for the case of contention on the lock 
where many retries could be needed to get the lock).

>
>> CU_ASSERT(rc == 0);
>> rc = odp_rwlock_write_trylock(rw_lock); => Expected failure
>> CU_ASSERT(rc == 0);
>>
>> odp_rwlock_read_unlock(rw_lock); => Lock is still owned once.
>>
>>
>> So either the API should describe more accurately what are the expected
>> success/failure case, or the test and implementation changed.
>>
>> On a side note, the API explicitly says that reader have the priority on
>> writers on rwlock. Is this really an API requirement?
>> Our rwlocks are the other way around to avoid the starvation issue. Do I
>> need to change them ? Or is it OK with the API?
>>
> Do you mean this:
>  * A reader/writer lock allows multiple simultaneous readers but only one
>  * writer at a time. A thread that wants write access will have to wait until
>  * there are no threads that want read access. This causes a risk for
>  * starvation. The trylock variants can be used to avoid blocking when
>  * the lock is not immediately available.
>
> It could be softened with "may have to wait" and "may cause a risk". 
> Different RW lock implementations should be possible.
>
> -Petri
What bothers me is this:

A thread that wants write access will have to wait until
 * there are no threads that want read access.

This clearly states that a writer cannot get the write lock if a reader *wants* 
it.
I think

A thread that wants write access will have to wait until
 * there are no threads that own read permission on the lock.


would relax this constraint and allow for write-priority rwlock.


[lng-odp] [Bug 2494] Extend odp_pktio_capability_t to include minimal pool size required by pktio implementation.

2016-12-08 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2494

--- Comment #9 from Mike Holmes  ---
Maciej How do we close on this, are you submitting a patch ?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[lng-odp] [Bug 2411] linux-generic/odp_schedule_sp.c contains todo items

2016-12-08 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2411

--- Comment #3 from Mike Holmes  ---
Petri, is this fixed with your latest patches ?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[lng-odp] [Bug 2644] Event order doesn't always hold when new events are allocated within an ordered context

2016-12-08 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2644

Mike Holmes  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 CC||mike.hol...@linaro.org
 Resolution|--- |FIXED

--- Comment #4 from Mike Holmes  ---
2796eef79f73c47e29c0d40d411a5547277836ee commited  for
http://patches.opendataplane.org/patch/7528/

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Re: [lng-odp] odp_rwlock_read_trylock

2016-12-08 Thread Savolainen, Petri (Nokia - FI/Espoo)


> -Original Message-
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of
> Nicolas Morey-Chaisemartin
> Sent: Wednesday, December 07, 2016 10:12 AM
> To: LNG ODP Mailman List 
> Subject: [lng-odp] odp_rwlock_read_trylock
> 
> HI,
> 
> 
> While looking into the test/code, I noticed something weird in the
> implementation of the rwlock read trylock on monarch.
> 
> int odp_rwlock_read_trylock(odp_rwlock_t *rwlock)
> {
> uint32_t zero = 0;
> 
> return odp_atomic_cas_acq_u32(>cnt, , (uint32_t)1);
> }
> 
> 
> This mean the trylock only succeed if no one was using the lock. But it
> will fail if someone was owning it *even* if it is a reader.
> Is this something expected? If yes, it should probably be detailed in the
> API.

/**
 * Try to acquire read permission to a reader/writer lock.
 *
 * @param rwlock Pointer to a reader/writer lock
 *
 * @retval  0 Lock was not available for read access
 * @retval !0 Read access to lock acquired
 */
int odp_rwlock_read_trylock(odp_rwlock_t *rwlock);


The spec just says that "read access" was not available. Implementation decides 
when it's available and application just needs to re-try later on. So, this 
implementation is OK by the spec. Supporting multiple readers would improve 
parallelism, but it may not be optimal for performance if the lock is free in 
the common case.


> 
> 
> The lock implementation I wrote allows to get the lock if a reader already
> owns it. And causes the testsuite to deadlock:
> 
> odp_rwlock_init(rw_lock);
> /* CU_ASSERT(odp_rwlock_is_locked(rw_lock) == 0); */
> 
> odp_rwlock_read_lock(rw_lock); => Lock is owned in read
> 
> rc = odp_rwlock_read_trylock(rw_lock); => Locked is owned a second
> time in read (rc = 1)


You cannot do this on a single thread (lock the same lock twice). You must use 
recursive locks if the thread holding a lock will lock it again.
 


> CU_ASSERT(rc == 0);
> rc = odp_rwlock_write_trylock(rw_lock); => Expected failure
> CU_ASSERT(rc == 0);
> 
> odp_rwlock_read_unlock(rw_lock); => Lock is still owned once.
> 
> 
> So either the API should describe more accurately what are the expected
> success/failure case, or the test and implementation changed.
> 
> On a side note, the API explicitly says that reader have the priority on
> writers on rwlock. Is this really an API requirement?
> Our rwlocks are the other way around to avoid the starvation issue. Do I
> need to change them ? Or is it OK with the API?
> 

Do you mean this:
 * A reader/writer lock allows multiple simultaneous readers but only one
 * writer at a time. A thread that wants write access will have to wait until
 * there are no threads that want read access. This causes a risk for
 * starvation. The trylock variants can be used to avoid blocking when
 * the lock is not immediately available.

It could be softened with "may have to wait" and "may cause a risk". Different 
RW lock implementations should be possible.

-Petri


[lng-odp] [Bug 2512] validation: TCP checksum update

2016-12-08 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2512

--- Comment #6 from Mike Holmes  ---
pinged Nikhil to see if he can review

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[lng-odp] [Bug 2683] Orphan odp_generator process after make check

2016-12-08 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2683

Mike Holmes  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 CC||mike.hol...@linaro.org
 Resolution|--- |FIXED

--- Comment #1 from Mike Holmes  ---
 f0d6c01 :2016-11-25 - (origin/api-next) linux-gen: _fdserver: request sigterm
if parent dies 

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[lng-odp] [API-NEXT PATCH v3 10/10] example: ipsec: use op_param_t instead of op_params_t

2016-12-08 Thread Petri Savolainen
Type name odp_crypto_op_params_t is deprecated.

Signed-off-by: Petri Savolainen 
---
 example/ipsec/odp_ipsec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 6a9a9fe..c51922a 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -148,7 +148,7 @@ typedef struct {
uint32_t dst_ip; /**< SA dest IP address */
 
/* Output only */
-   odp_crypto_op_params_t params;  /**< Parameters for crypto call */
+   odp_crypto_op_param_t params;   /**< Parameters for crypto call */
uint32_t *ah_seq;   /**< AH sequence number location */
uint32_t *esp_seq;  /**< ESP sequence number location */
uint16_t *tun_hdr_id;   /**< Tunnel header ID > */
@@ -644,7 +644,7 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt,
odph_ahhdr_t *ah = NULL;
odph_esphdr_t *esp = NULL;
ipsec_cache_entry_t *entry;
-   odp_crypto_op_params_t params;
+   odp_crypto_op_param_t params;
odp_bool_t posted = 0;
 
/* Default to skip IPsec */
@@ -823,7 +823,7 @@ pkt_disposition_e do_ipsec_out_classify(odp_packet_t pkt,
uint16_t ip_data_len = ipv4_data_len(ip);
uint8_t *ip_data = ipv4_data_p(ip);
ipsec_cache_entry_t *entry;
-   odp_crypto_op_params_t params;
+   odp_crypto_op_param_t params;
int hdr_len = 0;
int trl_len = 0;
odph_ahhdr_t *ah = NULL;
-- 
2.8.1



[lng-odp] [API-NEXT PATCH v3 04/10] linux-gen: crypto: add algo capability functions

2016-12-08 Thread Petri Savolainen
Implemented cipher and authentication algorithm capability
functions.

Signed-off-by: Petri Savolainen 
---
 platform/linux-generic/odp_crypto.c | 108 
 1 file changed, 108 insertions(+)

diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index 70d3a97..44b8e06 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -27,6 +27,37 @@
 
 #define MAX_SESSIONS 32
 
+/*
+ * Cipher algorithm capabilities
+ *
+ * Keep sorted: first by key length, then by IV length
+ */
+static const odp_crypto_cipher_capability_t cipher_capa_des[] = {
+{.key_len = 24, .iv_len = 8} };
+
+static const odp_crypto_cipher_capability_t cipher_capa_trides_cbc[] = {
+{.key_len = 24, .iv_len = 8} };
+
+static const odp_crypto_cipher_capability_t cipher_capa_aes_cbc[] = {
+{.key_len = 16, .iv_len = 16} };
+
+static const odp_crypto_cipher_capability_t cipher_capa_aes_gcm[] = {
+{.key_len = 16, .iv_len = 12} };
+
+/*
+ * Authentication algorithm capabilities
+ *
+ * Keep sorted: first by digest length, then by key length
+ */
+static const odp_crypto_auth_capability_t auth_capa_md5_hmac[] = {
+{.digest_len = 12, .key_len = 16, .aad_len = {.min = 0, .max = 0, .inc = 0} } 
};
+
+static const odp_crypto_auth_capability_t auth_capa_sha256_hmac[] = {
+{.digest_len = 16, .key_len = 32, .aad_len = {.min = 0, .max = 0, .inc = 0} } 
};
+
+static const odp_crypto_auth_capability_t auth_capa_aes_gcm[] = {
+{.digest_len = 16, .key_len = 0, .aad_len = {.min = 8, .max = 12, .inc = 4} } 
};
+
 typedef struct odp_crypto_global_s odp_crypto_global_t;
 
 struct odp_crypto_global_s {
@@ -623,6 +654,83 @@ int odp_crypto_capability(odp_crypto_capability_t *capa)
return 0;
 }
 
+int odp_crypto_cipher_capability(odp_cipher_alg_t cipher,
+odp_crypto_cipher_capability_t dst[],
+int num_copy)
+{
+   const odp_crypto_cipher_capability_t *src;
+   int num;
+   int size = sizeof(odp_crypto_cipher_capability_t);
+
+   switch (cipher) {
+   case ODP_CIPHER_ALG_NULL:
+   src = NULL;
+   num = 0;
+   break;
+   case ODP_CIPHER_ALG_DES:
+   src = cipher_capa_des;
+   num = sizeof(cipher_capa_des) / size;
+   break;
+   case ODP_CIPHER_ALG_3DES_CBC:
+   src = cipher_capa_trides_cbc;
+   num = sizeof(cipher_capa_trides_cbc) / size;
+   break;
+   case ODP_CIPHER_ALG_AES_CBC:
+   src = cipher_capa_aes_cbc;
+   num = sizeof(cipher_capa_aes_cbc) / size;
+   break;
+   case ODP_CIPHER_ALG_AES_GCM:
+   src = cipher_capa_aes_gcm;
+   num = sizeof(cipher_capa_aes_gcm) / size;
+   break;
+   default:
+   return -1;
+   }
+
+   if (num < num_copy)
+   num_copy = num;
+
+   memcpy(dst, src, num_copy * size);
+
+   return num;
+}
+
+int odp_crypto_auth_capability(odp_auth_alg_t auth,
+  odp_crypto_auth_capability_t dst[], int num_copy)
+{
+   const odp_crypto_auth_capability_t *src;
+   int num;
+   int size = sizeof(odp_crypto_auth_capability_t);
+
+   switch (auth) {
+   case ODP_AUTH_ALG_NULL:
+   src = NULL;
+   num = 0;
+   break;
+   case ODP_AUTH_ALG_MD5_HMAC:
+   src = auth_capa_md5_hmac;
+   num = sizeof(auth_capa_md5_hmac) / size;
+   break;
+   case ODP_AUTH_ALG_SHA256_HMAC:
+   src = auth_capa_sha256_hmac;
+   num = sizeof(auth_capa_sha256_hmac) / size;
+   break;
+   case ODP_AUTH_ALG_AES_GCM:
+   src = auth_capa_aes_gcm;
+   num = sizeof(auth_capa_aes_gcm) / size;
+   break;
+   default:
+   return -1;
+   }
+
+   if (num < num_copy)
+   num_copy = num;
+
+   memcpy(dst, src, num_copy * size);
+
+   return num;
+}
+
 int
 odp_crypto_session_create(odp_crypto_session_param_t *param,
  odp_crypto_session_t *session_out,
-- 
2.8.1



[lng-odp] [API-NEXT PATCH v3 01/10] api: crypto: rename _params_t to _param_t

2016-12-08 Thread Petri Savolainen
The common naming convention for parameter types is _param_t
(without 's'). Old type names remain for backwards compatibility,
but are deprecated.

Signed-off-by: Petri Savolainen 
---
 include/odp/api/spec/crypto.h | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
index 0cb8814..f24f527 100644
--- a/include/odp/api/spec/crypto.h
+++ b/include/odp/api/spec/crypto.h
@@ -171,7 +171,7 @@ typedef struct odp_crypto_data_range {
 /**
  * Crypto API session creation parameters
  */
-typedef struct odp_crypto_session_params {
+typedef struct odp_crypto_session_param_t {
odp_crypto_op_t op;/**< Encode versus decode */
odp_bool_t auth_cipher_text;   /**< Authenticate/cipher ordering */
odp_crypto_op_mode_t pref_mode;/**< Preferred sync vs async */
@@ -182,7 +182,10 @@ typedef struct odp_crypto_session_params {
odp_crypto_key_t auth_key; /**< Authentication key */
odp_queue_t compl_queue;   /**< Async mode completion event 
queue */
odp_pool_t output_pool;/**< Output buffer pool */
-} odp_crypto_session_params_t;
+} odp_crypto_session_param_t;
+
+/** @deprecated  Use odp_crypto_session_param_t instead */
+typedef odp_crypto_session_param_t odp_crypto_session_params_t;
 
 /**
  * @var odp_crypto_session_params_t::auth_cipher_text
@@ -209,7 +212,7 @@ typedef struct odp_crypto_session_params {
 /**
  * Crypto API per packet operation parameters
  */
-typedef struct odp_crypto_op_params {
+typedef struct odp_crypto_op_param_t {
odp_crypto_session_t session;   /**< Session handle from creation */
void *ctx;  /**< User context */
odp_packet_t pkt;   /**< Input packet buffer */
@@ -218,7 +221,10 @@ typedef struct odp_crypto_op_params {
uint32_t hash_result_offset;/**< Offset from start of packet buffer 
for hash result */
odp_crypto_data_range_t cipher_range;   /**< Data range to apply cipher 
*/
odp_crypto_data_range_t auth_range; /**< Data range to authenticate 
*/
-} odp_crypto_op_params_t;
+} odp_crypto_op_param_t;
+
+/** @deprecated  Use odp_crypto_op_param_t instead */
+typedef odp_crypto_op_param_t odp_crypto_op_params_t;
 
 /**
  * @var odp_crypto_op_params_t::pkt
@@ -349,14 +355,14 @@ int odp_crypto_capability(odp_crypto_capability_t *capa);
 /**
  * Crypto session creation (synchronous)
  *
- * @param paramsSession parameters
+ * @param param Session parameters
  * @param session   Created session else ODP_CRYPTO_SESSION_INVALID
  * @param statusFailure code if unsuccessful
  *
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_crypto_session_create(odp_crypto_session_params_t *params,
+int odp_crypto_session_create(odp_crypto_session_param_t *param,
  odp_crypto_session_t *session,
  odp_crypto_ses_create_err_t *status);
 
@@ -410,14 +416,14 @@ void odp_crypto_compl_free(odp_crypto_compl_t 
completion_event);
  * If "posted" returns TRUE the result will be delivered via the completion
  * queue specified when the session was created.
  *
- * @param paramsOperation parameters
+ * @param param Operation parameters
  * @param postedPointer to return posted, TRUE for async operation
  * @param resultResults of operation (when posted returns FALSE)
  *
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_crypto_operation(odp_crypto_op_params_t *params,
+int odp_crypto_operation(odp_crypto_op_param_t *param,
 odp_bool_t *posted,
 odp_crypto_op_result_t *result);
 
-- 
2.8.1



[lng-odp] [API-NEXT PATCH v3 02/10] linux-gen: crypto: rename params to param

2016-12-08 Thread Petri Savolainen
Use new _param_t type names instead of _params_t.

Signed-off-by: Petri Savolainen 
---
 .../linux-generic/include/odp_crypto_internal.h|   2 +-
 platform/linux-generic/odp_crypto.c| 288 ++---
 2 files changed, 145 insertions(+), 145 deletions(-)

diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index 7b104af..7b4eb61 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -23,7 +23,7 @@ typedef struct odp_crypto_generic_session 
odp_crypto_generic_session_t;
  * Algorithm handler function prototype
  */
 typedef
-odp_crypto_alg_err_t (*crypto_func_t)(odp_crypto_op_params_t *params,
+odp_crypto_alg_err_t (*crypto_func_t)(odp_crypto_op_param_t *param,
  odp_crypto_generic_session_t *session);
 
 /**
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index 7e686ff..70d3a97 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -69,24 +69,24 @@ void free_session(odp_crypto_generic_session_t *session)
 }
 
 static odp_crypto_alg_err_t
-null_crypto_routine(odp_crypto_op_params_t *params ODP_UNUSED,
+null_crypto_routine(odp_crypto_op_param_t *param ODP_UNUSED,
odp_crypto_generic_session_t *session ODP_UNUSED)
 {
return ODP_CRYPTO_ALG_ERR_NONE;
 }
 
 static
-odp_crypto_alg_err_t md5_gen(odp_crypto_op_params_t *params,
+odp_crypto_alg_err_t md5_gen(odp_crypto_op_param_t *param,
 odp_crypto_generic_session_t *session)
 {
-   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint8_t *data  = odp_packet_data(param->out_pkt);
uint8_t *icv   = data;
-   uint32_t len   = params->auth_range.length;
+   uint32_t len   = param->auth_range.length;
uint8_t  hash[EVP_MAX_MD_SIZE];
 
/* Adjust pointer for beginning of area to auth */
-   data += params->auth_range.offset;
-   icv  += params->hash_result_offset;
+   data += param->auth_range.offset;
+   icv  += param->hash_result_offset;
 
/* Hash it */
HMAC(EVP_md5(),
@@ -104,19 +104,19 @@ odp_crypto_alg_err_t md5_gen(odp_crypto_op_params_t 
*params,
 }
 
 static
-odp_crypto_alg_err_t md5_check(odp_crypto_op_params_t *params,
+odp_crypto_alg_err_t md5_check(odp_crypto_op_param_t *param,
   odp_crypto_generic_session_t *session)
 {
-   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint8_t *data  = odp_packet_data(param->out_pkt);
uint8_t *icv   = data;
-   uint32_t len   = params->auth_range.length;
+   uint32_t len   = param->auth_range.length;
uint32_t bytes = session->auth.data.md5.bytes;
uint8_t  hash_in[EVP_MAX_MD_SIZE];
uint8_t  hash_out[EVP_MAX_MD_SIZE];
 
/* Adjust pointer for beginning of area to auth */
-   data += params->auth_range.offset;
-   icv  += params->hash_result_offset;
+   data += param->auth_range.offset;
+   icv  += param->hash_result_offset;
 
/* Copy current value out and clear it before authentication */
memset(hash_in, 0, sizeof(hash_in));
@@ -142,17 +142,17 @@ odp_crypto_alg_err_t md5_check(odp_crypto_op_params_t 
*params,
 }
 
 static
-odp_crypto_alg_err_t sha256_gen(odp_crypto_op_params_t *params,
+odp_crypto_alg_err_t sha256_gen(odp_crypto_op_param_t *param,
odp_crypto_generic_session_t *session)
 {
-   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint8_t *data  = odp_packet_data(param->out_pkt);
uint8_t *icv   = data;
-   uint32_t len   = params->auth_range.length;
+   uint32_t len   = param->auth_range.length;
uint8_t  hash[EVP_MAX_MD_SIZE];
 
/* Adjust pointer for beginning of area to auth */
-   data += params->auth_range.offset;
-   icv  += params->hash_result_offset;
+   data += param->auth_range.offset;
+   icv  += param->hash_result_offset;
 
/* Hash it */
HMAC(EVP_sha256(),
@@ -170,19 +170,19 @@ odp_crypto_alg_err_t sha256_gen(odp_crypto_op_params_t 
*params,
 }
 
 static
-odp_crypto_alg_err_t sha256_check(odp_crypto_op_params_t *params,
+odp_crypto_alg_err_t sha256_check(odp_crypto_op_param_t *param,
  odp_crypto_generic_session_t *session)
 {
-   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint8_t *data  = odp_packet_data(param->out_pkt);
uint8_t *icv   = data;
-   uint32_t len   = params->auth_range.length;
+   uint32_t len   = param->auth_range.length;
uint32_t bytes = session->auth.data.sha256.bytes;
uint8_t  hash_in[EVP_MAX_MD_SIZE];
uint8_t  hash_out[EVP_MAX_MD_SIZE];
 
/* Adjust pointer for beginning of area to auth */
-   data += 

[lng-odp] [API-NEXT PATCH v3 05/10] linux-gen: crypto: add support to new enumerations

2016-12-08 Thread Petri Savolainen
Added support for new algorithm enumerations and algorithm
capability functions.

Signed-off-by: Petri Savolainen 
---
 .../linux-generic/include/odp_crypto_internal.h|  19 +--
 platform/linux-generic/odp_crypto.c| 180 +++--
 2 files changed, 107 insertions(+), 92 deletions(-)

diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index 7b4eb61..c7b893a 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -14,6 +14,7 @@ extern "C" {
 #include 
 #include 
 
+#define MAX_IV_LEN  64
 #define OP_RESULT_MAGIC 0x91919191
 
 /** Forward declaration of session structure */
@@ -31,16 +32,16 @@ odp_crypto_alg_err_t (*crypto_func_t)(odp_crypto_op_param_t 
*param,
  */
 struct odp_crypto_generic_session {
struct odp_crypto_generic_session *next;
-   odp_crypto_op_t op;
+
+   /* Session creation parameters */
+   odp_crypto_session_param_t p;
+
odp_bool_t do_cipher_first;
-   odp_queue_t compl_queue;
-   odp_pool_t output_pool;
+
struct {
-   odp_cipher_alg_t   alg;
-   struct {
-   uint8_t *data;
-   size_t   len;
-   } iv;
+   /* Copy of session IV data */
+   uint8_t iv_data[MAX_IV_LEN];
+
union {
struct {
DES_key_schedule ks1;
@@ -56,8 +57,8 @@ struct odp_crypto_generic_session {
} data;
crypto_func_t func;
} cipher;
+
struct {
-   odp_auth_alg_t  alg;
union {
struct {
uint8_t  key[16];
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index 44b8e06..fd121c8 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -249,8 +249,8 @@ odp_crypto_alg_err_t aes_encrypt(odp_crypto_op_param_t 
*param,
 
if (param->override_iv_ptr)
iv_ptr = param->override_iv_ptr;
-   else if (session->cipher.iv.data)
-   iv_ptr = session->cipher.iv.data;
+   else if (session->p.iv.data)
+   iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
 
@@ -281,8 +281,8 @@ odp_crypto_alg_err_t aes_decrypt(odp_crypto_op_param_t 
*param,
 
if (param->override_iv_ptr)
iv_ptr = param->override_iv_ptr;
-   else if (session->cipher.iv.data)
-   iv_ptr = session->cipher.iv.data;
+   else if (session->p.iv.data)
+   iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
 
@@ -302,22 +302,20 @@ odp_crypto_alg_err_t aes_decrypt(odp_crypto_op_param_t 
*param,
return ODP_CRYPTO_ALG_ERR_NONE;
 }
 
-static
-int process_aes_param(odp_crypto_generic_session_t *session,
- odp_crypto_session_param_t *param)
+static int process_aes_param(odp_crypto_generic_session_t *session)
 {
/* Verify IV len is either 0 or 16 */
-   if (!((0 == param->iv.length) || (16 == param->iv.length)))
+   if (!((0 == session->p.iv.length) || (16 == session->p.iv.length)))
return -1;
 
/* Set function */
-   if (ODP_CRYPTO_OP_ENCODE == param->op) {
+   if (ODP_CRYPTO_OP_ENCODE == session->p.op) {
session->cipher.func = aes_encrypt;
-   AES_set_encrypt_key(param->cipher_key.data, 128,
+   AES_set_encrypt_key(session->p.cipher_key.data, 128,
>cipher.data.aes.key);
} else {
session->cipher.func = aes_decrypt;
-   AES_set_decrypt_key(param->cipher_key.data, 128,
+   AES_set_decrypt_key(session->p.cipher_key.data, 128,
>cipher.data.aes.key);
}
 
@@ -340,8 +338,8 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t 
*param,
 
if (param->override_iv_ptr)
iv_ptr = param->override_iv_ptr;
-   else if (session->cipher.iv.data)
-   iv_ptr = session->cipher.iv.data;
+   else if (session->p.iv.data)
+   iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
 
@@ -405,8 +403,8 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t 
*param,
 
if (param->override_iv_ptr)
iv_ptr = param->override_iv_ptr;
-   else if (session->cipher.iv.data)
-   iv_ptr = session->cipher.iv.data;
+   else if (session->p.iv.data)
+   iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
 
@@ -455,19 +453,17 @@ odp_crypto_alg_err_t 

[lng-odp] [API-NEXT PATCH v3 07/10] api: crypto: documentation clean up

2016-12-08 Thread Petri Savolainen
Moved documentation of struct fields over each field. Removed
references to buffers as crypto API works only with packets.

Signed-off-by: Petri Savolainen 
---
 include/odp/api/spec/crypto.h | 235 ++
 1 file changed, 149 insertions(+), 86 deletions(-)

diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
index 0fb6d05..9855bf9 100644
--- a/include/odp/api/spec/crypto.h
+++ b/include/odp/api/spec/crypto.h
@@ -198,117 +198,166 @@ typedef union odp_crypto_auth_algos_t {
  * Crypto API key structure
  */
 typedef struct odp_crypto_key {
-   uint8_t *data;   /**< Key data */
-   uint32_t length; /**< Key length in bytes */
+   /** Key data */
+   uint8_t *data;
+
+   /** Key length in bytes */
+   uint32_t length;
+
 } odp_crypto_key_t;
 
 /**
  * Crypto API IV structure
  */
 typedef struct odp_crypto_iv {
-   uint8_t *data;  /**< IV data */
-   uint32_t length;/**< IV length in bytes */
+   /** IV data */
+   uint8_t *data;
+
+   /** IV length in bytes */
+   uint32_t length;
+
 } odp_crypto_iv_t;
 
 /**
  * Crypto API data range specifier
  */
 typedef struct odp_crypto_data_range {
-   uint32_t offset;  /**< Offset from beginning of buffer (chain) */
-   uint32_t length;  /**< Length of data to operate on */
+   /** Offset from beginning of packet */
+   uint32_t offset;
+
+   /** Length of data to operate on */
+   uint32_t length;
+
 } odp_crypto_data_range_t;
 
 /**
  * Crypto API session creation parameters
  */
 typedef struct odp_crypto_session_param_t {
-   odp_crypto_op_t op;/**< Encode versus decode */
-   odp_bool_t auth_cipher_text;   /**< Authenticate/cipher ordering */
-   odp_crypto_op_mode_t pref_mode;/**< Preferred sync vs async */
-   odp_cipher_alg_t cipher_alg;   /**< Cipher algorithm */
-   odp_crypto_key_t cipher_key;   /**< Cipher key */
-   odp_crypto_iv_t  iv;   /**< Cipher Initialization Vector 
(IV) */
-   odp_auth_alg_t auth_alg;   /**< Authentication algorithm */
-   odp_crypto_key_t auth_key; /**< Authentication key */
-   odp_queue_t compl_queue;   /**< Async mode completion event 
queue */
-   odp_pool_t output_pool;/**< Output buffer pool */
+   /** Encode vs. decode operation */
+   odp_crypto_op_t op;
+
+   /** Authenticate cipher vs. plain text
+*
+*  Controls ordering of authentication and cipher operations,
+*  and is relative to the operation (encode vs decode). When encoding,
+*  TRUE indicates the authentication operation should be performed
+*  after the cipher operation else before. When decoding, TRUE
+*  indicates the reverse order of operation.
+*
+*  true:  Authenticate cipher text
+*  false: Authenticate plain text
+*/
+   odp_bool_t auth_cipher_text;
+
+   /** Preferred sync vs. async */
+   odp_crypto_op_mode_t pref_mode;
+
+   /** Cipher algorithm
+*
+*  Use odp_crypto_capability() for supported algorithms.
+*/
+   odp_cipher_alg_t cipher_alg;
+
+   /** Cipher key
+*
+* Use odp_crypto_cipher_capa() for supported key and IV lengths.
+*/
+   odp_crypto_key_t cipher_key;
+
+   /** Cipher Initialization Vector (IV) */
+   odp_crypto_iv_t iv;
+
+   /** Authentication algorithm
+*
+*  Use odp_crypto_capability() for supported algorithms.
+*/
+   odp_auth_alg_t auth_alg;
+
+   /** Authentication key
+*
+*  Use odp_crypto_auth_capa() for supported digest and key lengths.
+*/
+   odp_crypto_key_t auth_key;
+
+   /** Async mode completion event queue
+*
+*  When odp_crypto_operation() is asynchronous, the completion queue is
+*  used to return the completion status of the operation to the
+*  application.
+*/
+   odp_queue_t compl_queue;
+
+   /** Output pool
+*
+*  When the output packet is not specified during the call to
+*  odp_crypto_operation(), the output packet will be allocated
+*  from this pool.
+*/
+   odp_pool_t output_pool;
+
 } odp_crypto_session_param_t;
 
 /** @deprecated  Use odp_crypto_session_param_t instead */
 typedef odp_crypto_session_param_t odp_crypto_session_params_t;
 
 /**
- * @var odp_crypto_session_params_t::auth_cipher_text
- *
- *   Controls ordering of authentication and cipher operations,
- *   and is relative to the operation (encode vs decode).
- *   When encoding, @c TRUE indicates the authentication operation
- *   should be performed @b after the cipher operation else before.
- *   When decoding, @c TRUE indicates the reverse order of operation.
- *
- * @var odp_crypto_session_params_t::compl_queue
- *
- 

[lng-odp] [API-NEXT PATCH v3 09/10] validation: crypto: use algorithm capability

2016-12-08 Thread Petri Savolainen
Use new algorithm enumerations and capability functions.

Signed-off-by: Petri Savolainen 
---
 .../validation/api/crypto/odp_crypto_test_inp.c| 114 -
 1 file changed, 86 insertions(+), 28 deletions(-)

diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c 
b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
index 55fc6aa..de9d6e4 100644
--- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
@@ -11,6 +11,8 @@
 #include "odp_crypto_test_inp.h"
 #include "crypto.h"
 
+#define MAX_ALG_CAPA 32
+
 struct suite_context_s {
odp_crypto_op_mode_t pref_mode;
odp_pool_t pool;
@@ -42,8 +44,7 @@ static void alg_test(odp_crypto_op_t op,
 const uint8_t *ciphertext,
 unsigned int ciphertext_len,
 const uint8_t *digest,
-unsigned int digest_len
-)
+uint32_t digest_len)
 {
odp_crypto_session_t session;
odp_crypto_capability_t capability;
@@ -57,6 +58,10 @@ static void alg_test(odp_crypto_op_t op,
odp_crypto_op_param_t op_params;
uint8_t *data_addr;
int data_off;
+   odp_crypto_cipher_capability_t cipher_capa[MAX_ALG_CAPA];
+   odp_crypto_auth_capability_t   auth_capa[MAX_ALG_CAPA];
+   int num, i;
+   int found;
 
rc = odp_crypto_capability();
CU_ASSERT(!rc);
@@ -65,36 +70,36 @@ static void alg_test(odp_crypto_op_t op,
if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
!(capability.hw_ciphers.bit.trides_cbc))
rc = -1;
-   if (cipher_alg == ODP_CIPHER_ALG_AES128_CBC &&
-   !(capability.hw_ciphers.bit.aes128_cbc))
+   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
+   !(capability.hw_ciphers.bit.aes_cbc))
rc = -1;
-   if (cipher_alg == ODP_CIPHER_ALG_AES128_GCM &&
-   !(capability.hw_ciphers.bit.aes128_gcm))
+   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
+   !(capability.hw_ciphers.bit.aes_gcm))
rc = -1;
} else {
if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
!(capability.ciphers.bit.trides_cbc))
rc = -1;
-   if (cipher_alg == ODP_CIPHER_ALG_AES128_CBC &&
-   !(capability.ciphers.bit.aes128_cbc))
+   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
+   !(capability.ciphers.bit.aes_cbc))
rc = -1;
-   if (cipher_alg == ODP_CIPHER_ALG_AES128_GCM &&
-   !(capability.ciphers.bit.aes128_gcm))
+   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
+   !(capability.ciphers.bit.aes_gcm))
rc = -1;
}
 
CU_ASSERT(!rc);
 
if (capability.hw_auths.all_bits) {
-   if (auth_alg == ODP_AUTH_ALG_AES128_GCM &&
-   !(capability.hw_auths.bit.aes128_gcm))
+   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
+   !(capability.hw_auths.bit.aes_gcm))
rc = -1;
if (auth_alg == ODP_AUTH_ALG_NULL &&
!(capability.hw_auths.bit.null))
rc = -1;
} else {
-   if (auth_alg == ODP_AUTH_ALG_AES128_GCM &&
-   !(capability.auths.bit.aes128_gcm))
+   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
+   !(capability.auths.bit.aes_gcm))
rc = -1;
if (auth_alg == ODP_AUTH_ALG_NULL &&
!(capability.auths.bit.null))
@@ -103,6 +108,59 @@ static void alg_test(odp_crypto_op_t op,
 
CU_ASSERT(!rc);
 
+   num = odp_crypto_cipher_capability(cipher_alg, cipher_capa,
+  MAX_ALG_CAPA);
+
+   if (cipher_alg != ODP_CIPHER_ALG_NULL) {
+   CU_ASSERT(num > 0);
+   found = 0;
+   } else {
+   CU_ASSERT(num == 0);
+   found = 1;
+   }
+
+   CU_ASSERT(num <= MAX_ALG_CAPA);
+
+   if (num > MAX_ALG_CAPA)
+   num = MAX_ALG_CAPA;
+
+   /* Search for the test case */
+   for (i = 0; i < num; i++) {
+   if (cipher_capa[i].key_len == cipher_key.length &&
+   cipher_capa[i].iv_len  == ses_iv.length) {
+   found = 1;
+   break;
+   }
+   }
+
+   CU_ASSERT(found);
+
+   num = odp_crypto_auth_capability(auth_alg, auth_capa, MAX_ALG_CAPA);
+
+   if (auth_alg != ODP_AUTH_ALG_NULL) {
+   CU_ASSERT(num > 0);
+   found = 0;
+   } else {
+   CU_ASSERT(num == 0);
+   found = 1;
+  

[lng-odp] [API-NEXT PATCH v3 03/10] api: crypto: decouple key length from algorithm enumeration

2016-12-08 Thread Petri Savolainen
Enumerations for cipher and authentication algorithms grow
fast if key and digest lengths are included into the enum.
Decoupled lengths from algorithm names, only exception is
SHA-2 family of authentication algorithms which has established
naming convention with digest lengths (SHA-224, SHA-256, ...).
Old enumerations are still functional but deprecated.

Algotrithm level capability functions provide a flexible way to
handle all possible key/digest/iv length combinations.

Signed-off-by: Petri Savolainen 
---
 include/odp/api/spec/crypto.h | 168 --
 1 file changed, 147 insertions(+), 21 deletions(-)

diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
index f24f527..4b94824 100644
--- a/include/odp/api/spec/crypto.h
+++ b/include/odp/api/spec/crypto.h
@@ -65,14 +65,28 @@ typedef enum {
 typedef enum {
/** No cipher algorithm specified */
ODP_CIPHER_ALG_NULL,
+
/** DES */
ODP_CIPHER_ALG_DES,
+
/** Triple DES with cipher block chaining */
ODP_CIPHER_ALG_3DES_CBC,
-   /** AES128 with cipher block chaining */
+
+   /** AES with cipher block chaining */
+   ODP_CIPHER_ALG_AES_CBC,
+
+   /** AES in Galois/Counter Mode
+*
+*  @note Must be paired with cipher ODP_AUTH_ALG_AES_GCM
+*/
+   ODP_CIPHER_ALG_AES_GCM,
+
+   /** @deprecated  Use ODP_CIPHER_ALG_AES_CBC instead */
ODP_CIPHER_ALG_AES128_CBC,
-   /** AES128 in Galois/Counter Mode */
-   ODP_CIPHER_ALG_AES128_GCM,
+
+   /** @deprecated  Use ODP_CIPHER_ALG_AES_GCM instead */
+   ODP_CIPHER_ALG_AES128_GCM
+
 } odp_cipher_alg_t;
 
 /**
@@ -81,12 +95,33 @@ typedef enum {
 typedef enum {
 /** No authentication algorithm specified */
ODP_AUTH_ALG_NULL,
-   /** HMAC-MD5 with 96 bit key */
+
+   /** HMAC-MD5
+*
+* MD5 algorithm in HMAC mode
+*/
+   ODP_AUTH_ALG_MD5_HMAC,
+
+   /** HMAC-SHA-256
+*
+*  SHA-256 algorithm in HMAC mode
+*/
+   ODP_AUTH_ALG_SHA256_HMAC,
+
+   /** AES in Galois/Counter Mode
+*
+*  @note Must be paired with cipher ODP_CIPHER_ALG_AES_GCM
+*/
+   ODP_AUTH_ALG_AES_GCM,
+
+   /** @deprecated  Use ODP_AUTH_ALG_MD5_HMAC instead */
ODP_AUTH_ALG_MD5_96,
-   /** SHA256 with 128 bit key */
+
+   /** @deprecated  Use ODP_AUTH_ALG_SHA256_HMAC instead */
ODP_AUTH_ALG_SHA256_128,
-   /** AES128 in Galois/Counter Mode */
-   ODP_AUTH_ALG_AES128_GCM,
+
+   /** @deprecated  Use ODP_AUTH_ALG_AES_GCM instead */
+   ODP_AUTH_ALG_AES128_GCM
 } odp_auth_alg_t;
 
 /**
@@ -96,19 +131,25 @@ typedef union odp_crypto_cipher_algos_t {
/** Cipher algorithms */
struct {
/** ODP_CIPHER_ALG_NULL */
-   uint32_t null   : 1;
+   uint32_t null: 1;
 
/** ODP_CIPHER_ALG_DES */
-   uint32_t des: 1;
+   uint32_t des : 1;
 
/** ODP_CIPHER_ALG_3DES_CBC */
-   uint32_t trides_cbc : 1;
+   uint32_t trides_cbc  : 1;
+
+   /** ODP_CIPHER_ALG_AES_CBC */
+   uint32_t aes_cbc : 1;
 
-   /** ODP_CIPHER_ALG_AES128_CBC */
-   uint32_t aes128_cbc : 1;
+   /** ODP_CIPHER_ALG_AES_GCM */
+   uint32_t aes_gcm : 1;
 
-   /** ODP_CIPHER_ALG_AES128_GCM */
-   uint32_t aes128_gcm : 1;
+   /** @deprecated  Use aes_cbc instead */
+   uint32_t aes128_cbc  : 1;
+
+   /** @deprecated  Use aes_gcm instead */
+   uint32_t aes128_gcm  : 1;
} bit;
 
/** All bits of the bit field structure
@@ -125,16 +166,25 @@ typedef union odp_crypto_auth_algos_t {
/** Authentication algorithms */
struct {
/** ODP_AUTH_ALG_NULL */
-   uint32_t null   : 1;
+   uint32_t null: 1;
+
+   /** ODP_AUTH_ALG_MD5_HMAC */
+   uint32_t md5_hmac: 1;
+
+   /** ODP_AUTH_ALG_SHA256_HMAC */
+   uint32_t sha256_hmac : 1;
 
-   /** ODP_AUTH_ALG_MD5_96 */
-   uint32_t md5_96 : 1;
+   /** ODP_AUTH_ALG_AES_GCM */
+   uint32_t aes_gcm : 1;
 
-   /** ODP_AUTH_ALG_SHA256_128 */
-   uint32_t sha256_128 : 1;
+   /** @deprecated  Use md5_hmac instead */
+   uint32_t md5_96  : 1;
 
-   /** ODP_AUTH_ALG_AES128_GCM */
-   uint32_t aes128_gcm : 1;
+   /** @deprecated  Use sha256_hmac instead */
+   uint32_t sha256_128  : 1;
+
+   /** @deprecated  Use aes_gcm instead */
+   uint32_t aes128_gcm  : 1;
} bit;
 
/** All bits of the bit field structure
@@ -341,6 

[lng-odp] [API-NEXT PATCH v3 08/10] test: crypto: use odp_crypto_session_param_init

2016-12-08 Thread Petri Savolainen
Use session param init function instead of memset() to zero.

Signed-off-by: Petri Savolainen 
---
 example/ipsec/odp_ipsec_cache.c  | 4 +++-
 test/common_plat/performance/odp_crypto.c| 9 +
 test/common_plat/validation/api/crypto/odp_crypto_test_inp.c | 6 +++---
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c
index 2bd44cf..b2a91c2 100644
--- a/example/ipsec/odp_ipsec_cache.c
+++ b/example/ipsec/odp_ipsec_cache.c
@@ -44,7 +44,7 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,
 odp_queue_t completionq,
 odp_pool_t out_pool)
 {
-   odp_crypto_session_params_t params;
+   odp_crypto_session_param_t params;
ipsec_cache_entry_t *entry;
odp_crypto_ses_create_err_t ses_create_rc;
odp_crypto_session_t session;
@@ -60,6 +60,8 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,
(cipher_sa->mode != auth_sa->mode))
return -1;
 
+   odp_crypto_session_param_init();
+
/* Setup parameters and call crypto library to create session */
params.op = (in) ? ODP_CRYPTO_OP_DECODE : ODP_CRYPTO_OP_ENCODE;
params.auth_cipher_text = TRUE;
diff --git a/test/common_plat/performance/odp_crypto.c 
b/test/common_plat/performance/odp_crypto.c
index 39df78b..9936288 100644
--- a/test/common_plat/performance/odp_crypto.c
+++ b/test/common_plat/performance/odp_crypto.c
@@ -49,7 +49,7 @@ static uint8_t test_key24[24] = { 0x01, 0x02, 0x03, 0x04, 
0x05,
  */
 typedef struct {
const char *name; /**< Algorithm name */
-   odp_crypto_session_params_t session;  /**< Prefilled crypto session 
params */
+   odp_crypto_session_param_t session;   /**< Prefilled crypto session 
params */
unsigned int hash_adjust; /**< Size of hash */
 } crypto_alg_config_t;
 
@@ -420,12 +420,13 @@ create_session_from_config(odp_crypto_session_t *session,
   crypto_alg_config_t *config,
   crypto_args_t *cargs)
 {
-   odp_crypto_session_params_t params;
+   odp_crypto_session_param_t params;
odp_crypto_ses_create_err_t ses_create_rc;
odp_pool_t pkt_pool;
odp_queue_t out_queue;
 
-   memcpy(, >session, sizeof(odp_crypto_session_params_t));
+   odp_crypto_session_param_init();
+   memcpy(, >session, sizeof(odp_crypto_session_param_t));
params.op = ODP_CRYPTO_OP_ENCODE;
params.pref_mode   = ODP_CRYPTO_SYNC;
 
@@ -468,7 +469,7 @@ run_measure_one(crypto_args_t *cargs,
unsigned int payload_length,
crypto_run_result_t *result)
 {
-   odp_crypto_op_params_t params;
+   odp_crypto_op_param_t params;
 
odp_pool_t pkt_pool;
odp_queue_t out_queue;
diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c 
b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
index 4ac4a07..55fc6aa 100644
--- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
@@ -53,8 +53,8 @@ static void alg_test(odp_crypto_op_t op,
odp_event_t event;
odp_crypto_compl_t compl_event;
odp_crypto_op_result_t result;
-   odp_crypto_session_params_t ses_params;
-   odp_crypto_op_params_t op_params;
+   odp_crypto_session_param_t ses_params;
+   odp_crypto_op_param_t op_params;
uint8_t *data_addr;
int data_off;
 
@@ -104,7 +104,7 @@ static void alg_test(odp_crypto_op_t op,
CU_ASSERT(!rc);
 
/* Create a crypto session */
-   memset(_params, 0, sizeof(ses_params));
+   odp_crypto_session_param_init(_params);
ses_params.op = op;
ses_params.auth_cipher_text = false;
ses_params.pref_mode = suite_context.pref_mode;
-- 
2.8.1



[lng-odp] [API-NEXT PATCH v3 00/10] crypto key length capability

2016-12-08 Thread Petri Savolainen
Various cipher and authentication algorithms support multiple key/IV/digest 
lengths. It's not a scalable solution to define these lengths as part of 
algorithm enumeration. This patch set deprecates enumerations (e.g. 
ODP_CIPHER_ALG_AES128_CBC) with length definitions. Those are still supported 
but will be removed in next API version. New enumerations define only
algorithm names, with the exception of SHA-2 family of algorithms which are 
commonly referred with their digest length (such as SHA-256). The supported 
key/IV/digest lengths are requested with two new functions 
odp_crypto_cipher_capa() and odp_crypto_auth_capa(). Usage of HMAC is included 
into authentication algorithm name (it used to be implicit). Only currently 
supported and validation tested algorithms are defined, but later on e.g. MD5 
or SHA-256 (without HMAC) may be defined as well as a set of new algorithms.

Supported key/IV/digest lengths are set to values that pass current validation 
test suite. Some tests may need to be updated with their key/IV/digest length 
usage. For example, AES-GCM authentication test uses key length of zero bytes 
(since it's paired with AES-GCM cipher).


v2:
  * deprecate _params_t and use _param_t instead
  * rename cipher/auth_capa_t to _capability_t
  * rename cipher/auth_capa() to _capability()


Petri Savolainen (10):
  api: crypto: rename _params_t to _param_t
  linux-gen: crypto: rename params to param
  api: crypto: decouple key length from algorithm enumeration
  linux-gen: crypto: add algo capability functions
  linux-gen: crypto: add support to new enumerations
  api: crypto: added session param init
  api: crypto: documentation clean up
  test: crypto: use odp_crypto_session_param_init
  validation: crypto: use algorithm capability
  example: ipsec: use op_param_t instead of op_params_t

 example/ipsec/odp_ipsec.c  |   6 +-
 example/ipsec/odp_ipsec_cache.c|   4 +-
 include/odp/api/spec/crypto.h  | 441 ++-
 .../linux-generic/include/odp_crypto_internal.h|  21 +-
 platform/linux-generic/odp_crypto.c| 489 +
 test/common_plat/performance/odp_crypto.c  |   9 +-
 .../validation/api/crypto/odp_crypto_test_inp.c| 120 +++--
 7 files changed, 744 insertions(+), 346 deletions(-)

-- 
2.8.1



[lng-odp] [API-NEXT PATCH v3 06/10] api: crypto: added session param init

2016-12-08 Thread Petri Savolainen
Added session parameter init function which should be
used to initialize the structure before calling
odp_crypto_session_create().

Signed-off-by: Petri Savolainen 
---
 include/odp/api/spec/crypto.h   | 16 +++-
 platform/linux-generic/odp_crypto.c |  5 +
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
index 4b94824..0fb6d05 100644
--- a/include/odp/api/spec/crypto.h
+++ b/include/odp/api/spec/crypto.h
@@ -479,7 +479,11 @@ int odp_crypto_auth_capability(odp_auth_alg_t auth,
   odp_crypto_auth_capability_t capa[], int num);
 
 /**
- * Crypto session creation (synchronous)
+ * Crypto session creation
+ *
+ * Create a crypto session according to the session parameters. Use
+ * odp_crypto_session_param_init() to initialize parameters into their
+ * default values.
  *
  * @param param Session parameters
  * @param session   Created session else ODP_CRYPTO_SESSION_INVALID
@@ -589,6 +593,16 @@ uint64_t odp_crypto_session_to_u64(odp_crypto_session_t 
hdl);
 uint64_t odp_crypto_compl_to_u64(odp_crypto_compl_t hdl);
 
 /**
+ * Initialize crypto session parameters
+ *
+ * Initialize an odp_crypto_session_param_t to its default values for
+ * all fields.
+ *
+ * @param param   Pointer to odp_crypto_session_param_t to be initialized
+ */
+void odp_crypto_session_param_init(odp_crypto_session_param_t *param);
+
+/**
  * @}
  */
 
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index fd121c8..6b7d60e 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -1042,3 +1042,8 @@ odp_crypto_compl_free(odp_crypto_compl_t completion_event)
odp_buffer_from_event((odp_event_t)completion_event),
ODP_EVENT_PACKET);
 }
+
+void odp_crypto_session_param_init(odp_crypto_session_param_t *param)
+{
+   memset(param, 0, sizeof(odp_crypto_session_param_t));
+}
-- 
2.8.1



[lng-odp] [Bug 2733] Allocated hugepages are not released after 'make check'

2016-12-08 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2733

Mike Holmes  changed:

   What|Removed |Added

   Assignee|maxim.uva...@linaro.org |christophe.mil...@linaro.or
   ||g
 CC||mike.hol...@linaro.org

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[lng-odp] [Bug 2733] Allocated hugepages are not released after 'make check'

2016-12-08 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2733

--- Comment #2 from Christophe Milard  ---
https://lists.linaro.org/pipermail/lng-odp/2016-December/026945.html
Should fix this problem which occurs in abnormal terminason. (I think make
check has a case of that but not fully sure where this is done though)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[lng-odp] [Bug 2733] Allocated hugepages are not released after 'make check'

2016-12-08 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2733

Christophe Milard  changed:

   What|Removed |Added

 CC||christophe.mil...@linaro.or
   ||g

--- Comment #1 from Christophe Milard  ---
https://lists.linaro.org/pipermail/lng-odp/2016-December/026945.html
Should fix this problem.
Waiting for review

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[lng-odp] [Bug 2733] New: Allocated hugepages are not released after 'make check'

2016-12-08 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2733

Bug ID: 2733
   Summary: Allocated hugepages are not released after 'make
check'
   Product: OpenDataPlane - linux- generic reference
   Version: api-next
  Hardware: x86
OS: Ubuntu
Status: UNCONFIRMED
  Severity: major
  Priority: ---
 Component: General ODP
  Assignee: maxim.uva...@linaro.org
  Reporter: matias@nokia.com
CC: lng-odp@lists.linaro.org
  Target Milestone: ---

When running 'make check' used hugepages are not released correctly. For
example before running '$ sudo make check' my server has 1024 free 2MB pages.
After a successful test run only 261 pages are available.

The same thing happens when an ODP example application (e.g. odp_l2fwd) is
closed with SIGINT. When the application is restarted it isn't able to reuse
these "leaked" pages.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[lng-odp] [RFC API-NEXT PATCHv3] test: adding test for driver loading

2016-12-08 Thread Christophe Milard
Trying to fix a proper structure for driver tests in the hard world
of autotools:
Staticaly linked drivers fails with autotools as the linker would need the
"--whole-archive" option which autotools cannot handle.
This patch load an empty driver as a shared library (.so), and is the
result of a long series of trial and errors with autotools.

Signed-off-by: Christophe Milard 
---

Note: must be applied on top of:
 [API-NEXT PATCHv4 0/5] driver initialisation framework

Since V2: includes a needed change for V4 of "driver initialisation framework"
  Still problem with clang and ther -dlreopen Aututools option...
Since V1: updates for V4 of "driver initialisation framework"

Is this good enough to go in the test structure?
I assumed this is linux test, i.e. not platform dependent...
(based on the ARCH decision where we said all linux we consider have dlopen())
Fails with Clang:
clang: error: argument unused during compilation: '-dlreopen'

 test/common_plat/m4/configure.m4   |  3 ++
 test/common_plat/validation/Makefile.inc   |  1 -
 test/common_plat/validation/drv/Makefile.am|  1 +
 test/common_plat/validation/drv/drvinit/.gitignore |  3 ++
 .../common_plat/validation/drv/drvinit/Makefile.am | 27 ++
 test/common_plat/validation/drv/drvinit/drvinit.c  | 62 ++
 test/common_plat/validation/drv/drvinit/drvinit.h  | 24 +
 .../validation/drv/drvinit/drvinit_main.c  | 12 +
 .../validation/drv/drvinit/empty_driver.c  | 40 ++
 .../common_plat/validation/drv/drvinit/odp.conf.in |  8 +++
 .../validation/drv/drvinit/odp_conf_path.h.in  |  4 ++
 test/linux-generic/Makefile.am |  1 +
 12 files changed, 185 insertions(+), 1 deletion(-)
 create mode 100644 test/common_plat/validation/drv/drvinit/.gitignore
 create mode 100644 test/common_plat/validation/drv/drvinit/Makefile.am
 create mode 100644 test/common_plat/validation/drv/drvinit/drvinit.c
 create mode 100644 test/common_plat/validation/drv/drvinit/drvinit.h
 create mode 100644 test/common_plat/validation/drv/drvinit/drvinit_main.c
 create mode 100644 test/common_plat/validation/drv/drvinit/empty_driver.c
 create mode 100644 test/common_plat/validation/drv/drvinit/odp.conf.in
 create mode 100644 test/common_plat/validation/drv/drvinit/odp_conf_path.h.in

diff --git a/test/common_plat/m4/configure.m4 b/test/common_plat/m4/configure.m4
index 1fc350d..3ff90fb 100644
--- a/test/common_plat/m4/configure.m4
+++ b/test/common_plat/m4/configure.m4
@@ -33,4 +33,7 @@ AC_CONFIG_FILES([test/common_plat/Makefile
 test/common_plat/validation/api/traffic_mngr/Makefile
 test/common_plat/validation/drv/Makefile
 test/common_plat/validation/drv/drvatomic/Makefile
+test/common_plat/validation/drv/drvinit/Makefile
+test/common_plat/validation/drv/drvinit/odp.conf
+test/common_plat/validation/drv/drvinit/odp_conf_path.h
 test/common_plat/validation/drv/drvshmem/Makefile])
diff --git a/test/common_plat/validation/Makefile.inc 
b/test/common_plat/validation/Makefile.inc
index ffba620..36c9899 100644
--- a/test/common_plat/validation/Makefile.inc
+++ b/test/common_plat/validation/Makefile.inc
@@ -8,7 +8,6 @@ COMMON_DIR = $(top_builddir)/test/common_plat/common
 AUTOMAKE_OPTIONS = nostdinc
 
 AM_CFLAGS += -I$(top_srcdir)/test/common_plat/common
-AM_LDFLAGS += -static
 
 LIBCUNIT_COMMON = $(COMMON_DIR)/libcunit_common.la
 LIBCPUMASK_COMMON = $(COMMON_DIR)/libcpumask_common.la
diff --git a/test/common_plat/validation/drv/Makefile.am 
b/test/common_plat/validation/drv/Makefile.am
index bcdb92e..1574f3d 100644
--- a/test/common_plat/validation/drv/Makefile.am
+++ b/test/common_plat/validation/drv/Makefile.am
@@ -1,4 +1,5 @@
 ODPDRV_MODULES = drvatomic \
+drvinit \
 drvshmem
 
 SUBDIRS = $(ODPDRV_MODULES)
diff --git a/test/common_plat/validation/drv/drvinit/.gitignore 
b/test/common_plat/validation/drv/drvinit/.gitignore
new file mode 100644
index 000..0d56fa9
--- /dev/null
+++ b/test/common_plat/validation/drv/drvinit/.gitignore
@@ -0,0 +1,3 @@
+drvinit_main
+odp_conf_path.h
+odp.conf
diff --git a/test/common_plat/validation/drv/drvinit/Makefile.am 
b/test/common_plat/validation/drv/drvinit/Makefile.am
new file mode 100644
index 000..622bbf3
--- /dev/null
+++ b/test/common_plat/validation/drv/drvinit/Makefile.am
@@ -0,0 +1,27 @@
+include ../Makefile.inc
+include $(top_srcdir)/platform/@with_platform@/Makefile.inc
+
+ABS_TEST_BUILDDIR = $(abs_top_builddir)/test/common_plat/validation/drv/drvinit
+
+noinst_LTLIBRARIES = libtestdrvinit.la
+libtestdrvinit_la_SOURCES = drvinit.c
+
+# the minimalist driver:
+lib_LTLIBRARIES = empty_driver.la
+empty_driver_la_SOURCES = empty_driver.c
+empty_driver_la_LDFLAGS = $(AM_LDFLAGS) -module -shared -export-dynamic \
+ 

Re: [lng-odp] [API-NEXT PATCH v3] api: ipsec: added IPSEC API

2016-12-08 Thread Savolainen, Petri (Nokia - FI/Espoo)


> -Original Message-
> From: Bala Manoharan [mailto:bala.manoha...@linaro.org]
> Sent: Thursday, December 08, 2016 11:16 AM
> To: Savolainen, Petri (Nokia - FI/Espoo)  labs.com>
> Cc: lng-odp-forward 
> Subject: Re: [lng-odp] [API-NEXT PATCH v3] api: ipsec: added IPSEC API
> 
> Regards,
> Bala
> 
> 
> On 8 December 2016 at 14:37, Savolainen, Petri (Nokia - FI/Espoo)
>  wrote:
> >
> >> > +
> >> > +/**
> >> > + * Fragmentation mode
> >> > + *
> >> > + * These options control outbound IP packet fragmentation offload.
> When
> >> offload
> >> > + * is enabled, IPSEC operation will determine if fragmentation is
> >> needed and
> >> > + * does it according to the mode.
> >> > + */
> >> > +typedef enum odp_ipsec_frag_mode_t {
> >> > +   /** Do not fragment IP packets */
> >> > +   ODP_IPSEC_FRAG_DISABLED = 0,
> >> > +
> >> > +   /** Fragment IP packet before IPSEC operation */
> >> > +   ODP_IPSEC_FRAG_BEFORE,
> >> > +
> >> > +   /** Fragment IP packet after IPSEC operation */
> >> > +   ODP_IPSEC_FRAG_AFTER,
> >> > +
> >> > +   /** Only check if IP fragmentation is needed,
> >> > + * do not fragment packets. */
> >> > +   ODP_IPSEC_FRAG_CHECK
> >>
> >> What is the expected behaviour for this case of ODP_IPSEC_FRAG_CHECK?
> >> Does the implementation send an error code if the packet needs to be
> >> fragmented?
> >>
> >> -Bala
> >
> >
> > Yes, implementation checks packet length against MTU and returns this
> status ...
> 
> Okay. This could be done but it is simple and could be done by the
> application itself right? There is no value addition in implementation
> doing this.
> 

ODP_IPSEC_FRAG_DISABLED is there to indicate that even check is not needed. 
ODP_IPSEC_FRAG_CHECK offloads IPSEC header, pad, etc size calculation from 
application. Implementation needs to have size calculation code anyway for 
fragmentation offload anyway. Application is simpler when it does not need to 
include size calculation code for all IPSEC modes and algorithms.

-Petri


[lng-odp] [API-NEXT PATCH] linux-gen: schedule_sp: use ring as priority queue

2016-12-08 Thread Petri Savolainen
Improve scalability by replacing lock protected linked list
with a ring. Schedule group supported was updated also, since
ring does not support peek of the head item.

Signed-off-by: Petri Savolainen 
---
 platform/linux-generic/odp_schedule_sp.c | 271 +++
 1 file changed, 199 insertions(+), 72 deletions(-)

diff --git a/platform/linux-generic/odp_schedule_sp.c 
b/platform/linux-generic/odp_schedule_sp.c
index 76d1357..5150d28 100644
--- a/platform/linux-generic/odp_schedule_sp.c
+++ b/platform/linux-generic/odp_schedule_sp.c
@@ -13,9 +13,12 @@
 #include 
 #include 
 #include 
+#include 
 
+#define NUM_THREADODP_THREAD_COUNT_MAX
 #define NUM_QUEUE ODP_CONFIG_QUEUES
 #define NUM_PKTIO ODP_CONFIG_PKTIO_ENTRIES
+#define NUM_ORDERED_LOCKS 1
 #define NUM_PRIO  3
 #define NUM_STATIC_GROUP  3
 #define NUM_GROUP (NUM_STATIC_GROUP + 9)
@@ -28,9 +31,17 @@
 #define GROUP_ALL ODP_SCHED_GROUP_ALL
 #define GROUP_WORKER  ODP_SCHED_GROUP_WORKER
 #define GROUP_CONTROL ODP_SCHED_GROUP_CONTROL
-#define MAX_ORDERED_LOCKS_PER_QUEUE 1
+#define GROUP_PKTIN   GROUP_ALL
 
-ODP_STATIC_ASSERT(MAX_ORDERED_LOCKS_PER_QUEUE <= CONFIG_QUEUE_MAX_ORD_LOCKS,
+/* Maximum number of commands: one priority/group for all queues and pktios */
+#define RING_SIZE (ODP_ROUNDUP_POWER_2(NUM_QUEUE + NUM_PKTIO))
+#define RING_MASK (RING_SIZE - 1)
+
+/* Ring size must be power of two */
+ODP_STATIC_ASSERT(ODP_VAL_IS_POWER_2(RING_SIZE),
+ "Ring_size_is_not_power_of_two");
+
+ODP_STATIC_ASSERT(NUM_ORDERED_LOCKS <= CONFIG_QUEUE_MAX_ORD_LOCKS,
  "Too_many_ordered_locks");
 
 struct sched_cmd_t;
@@ -38,6 +49,7 @@ struct sched_cmd_t;
 struct sched_cmd_s {
struct sched_cmd_t *next;
uint32_t   index;
+   uint32_t   ring_idx;
inttype;
intprio;
intgroup;
@@ -52,38 +64,49 @@ typedef struct sched_cmd_t {
   sizeof(struct sched_cmd_s)];
 } sched_cmd_t ODP_ALIGNED_CACHE;
 
-struct prio_queue_s {
-   odp_ticketlock_t  lock;
-   sched_cmd_t   *head;
-   sched_cmd_t   *tail;
-};
+typedef struct {
+   /* Ring header */
+   ring_t ring;
+
+   /* Ring data: queue indexes */
+   uint32_t ring_idx[RING_SIZE];
 
-typedefstruct prio_queue_t {
-   struct prio_queue_s s;
-   uint8_t pad[ROUNDUP_CACHE(sizeof(struct prio_queue_s)) -
-   sizeof(struct prio_queue_s)];
 } prio_queue_t ODP_ALIGNED_CACHE;
 
-struct sched_group_s {
-   odp_ticketlock_t  lock;
+typedef struct thr_group_t {
+   /* A generation counter for fast comparison if groups have changed */
+   odp_atomic_u32_t gen_cnt;
 
-   struct {
-   char  name[ODP_SCHED_GROUP_NAME_LEN + 1];
-   odp_thrmask_t mask;
-   int   allocated;
-   } group[NUM_GROUP];
-};
+   /* Number of groups the thread belongs to */
+   int num_group;
+
+   /* The groups the thread belongs to */
+   int group[NUM_GROUP];
+
+} thr_group_t;
 
 typedef struct sched_group_t {
-   struct sched_group_s s;
-   uint8_t  pad[ROUNDUP_CACHE(sizeof(struct sched_group_s)) -
-sizeof(struct sched_group_s)];
+   struct {
+   odp_ticketlock_t  lock;
+
+   /* All groups */
+   struct {
+   char  name[ODP_SCHED_GROUP_NAME_LEN + 1];
+   odp_thrmask_t mask;
+   int   allocated;
+   } group[NUM_GROUP];
+
+   /* Per thread group information */
+   thr_group_t thr[NUM_THREAD];
+
+   } s;
+
 } sched_group_t ODP_ALIGNED_CACHE;
 
 typedef struct {
sched_cmd_t   queue_cmd[NUM_QUEUE];
sched_cmd_t   pktio_cmd[NUM_PKTIO];
-   prio_queue_t  prio_queue[NUM_PRIO];
+   prio_queue_t  prio_queue[NUM_GROUP][NUM_PRIO];
sched_group_t sched_group;
 } sched_global_t;
 
@@ -91,14 +114,37 @@ typedef struct {
sched_cmd_t *cmd;
int  pause;
int  thr_id;
+   uint32_t gen_cnt;
+   int  num_group;
+   int  group[NUM_GROUP];
 } sched_local_t;
 
 static sched_global_t sched_global;
 static __thread sched_local_t sched_local;
 
+static inline uint32_t index_to_ring_idx(int pktio, uint32_t index)
+{
+   if (pktio)
+   return (0x8000 | index);
+
+   return index;
+}
+
+static inline uint32_t index_from_ring_idx(uint32_t *index, uint32_t ring_idx)
+{
+   uint32_t pktio = ring_idx & 0x8000;
+
+   if (pktio)
+   *index = ring_idx & (~0x8000);
+   else
+   *index = ring_idx;
+
+   return pktio;
+}
+
 static int init_global(void)
 {
-   int i;
+   int 

[lng-odp] [RFC API-NEXT PATCHv2] test: adding test for driver loading

2016-12-08 Thread Christophe Milard
Trying to fix a proper structure for driver tests in the hard world
of autotools:
Staticaly linked drivers fails with autotools as the linker would need the
"--whole-archive" option which autotools cannot handle.
This patch load an empty driver as a shared library (.so), and is the
result of a long series of trial and errors with autotools.

Signed-off-by: Christophe Milard 
---

Note: must be applied on top of:
 [API-NEXT PATCHv4 0/5] driver initialisation framework

Since V1: updates for V4 of "driver initialisation framework"

Is this good enough to go in the test structure?
I assumed this is linux test, i.e. not platform dependent...
(based on the ARCH decision where we said all linux we consider have dlopen())
Fails with Clang:
clang: error: argument unused during compilation: '-dlreopen'

 test/common_plat/m4/configure.m4   |  3 ++
 test/common_plat/validation/Makefile.inc   |  1 -
 test/common_plat/validation/drv/Makefile.am|  1 +
 test/common_plat/validation/drv/drvinit/.gitignore |  3 ++
 .../common_plat/validation/drv/drvinit/Makefile.am | 27 ++
 test/common_plat/validation/drv/drvinit/drvinit.c  | 62 ++
 test/common_plat/validation/drv/drvinit/drvinit.h  | 24 +
 .../validation/drv/drvinit/drvinit_main.c  | 12 +
 .../validation/drv/drvinit/empty_driver.c  | 42 +++
 .../common_plat/validation/drv/drvinit/odp.conf.in |  8 +++
 .../validation/drv/drvinit/odp_conf_path.h.in  |  4 ++
 test/linux-generic/Makefile.am |  1 +
 12 files changed, 187 insertions(+), 1 deletion(-)
 create mode 100644 test/common_plat/validation/drv/drvinit/.gitignore
 create mode 100644 test/common_plat/validation/drv/drvinit/Makefile.am
 create mode 100644 test/common_plat/validation/drv/drvinit/drvinit.c
 create mode 100644 test/common_plat/validation/drv/drvinit/drvinit.h
 create mode 100644 test/common_plat/validation/drv/drvinit/drvinit_main.c
 create mode 100644 test/common_plat/validation/drv/drvinit/empty_driver.c
 create mode 100644 test/common_plat/validation/drv/drvinit/odp.conf.in
 create mode 100644 test/common_plat/validation/drv/drvinit/odp_conf_path.h.in

diff --git a/test/common_plat/m4/configure.m4 b/test/common_plat/m4/configure.m4
index 1fc350d..3ff90fb 100644
--- a/test/common_plat/m4/configure.m4
+++ b/test/common_plat/m4/configure.m4
@@ -33,4 +33,7 @@ AC_CONFIG_FILES([test/common_plat/Makefile
 test/common_plat/validation/api/traffic_mngr/Makefile
 test/common_plat/validation/drv/Makefile
 test/common_plat/validation/drv/drvatomic/Makefile
+test/common_plat/validation/drv/drvinit/Makefile
+test/common_plat/validation/drv/drvinit/odp.conf
+test/common_plat/validation/drv/drvinit/odp_conf_path.h
 test/common_plat/validation/drv/drvshmem/Makefile])
diff --git a/test/common_plat/validation/Makefile.inc 
b/test/common_plat/validation/Makefile.inc
index ffba620..36c9899 100644
--- a/test/common_plat/validation/Makefile.inc
+++ b/test/common_plat/validation/Makefile.inc
@@ -8,7 +8,6 @@ COMMON_DIR = $(top_builddir)/test/common_plat/common
 AUTOMAKE_OPTIONS = nostdinc
 
 AM_CFLAGS += -I$(top_srcdir)/test/common_plat/common
-AM_LDFLAGS += -static
 
 LIBCUNIT_COMMON = $(COMMON_DIR)/libcunit_common.la
 LIBCPUMASK_COMMON = $(COMMON_DIR)/libcpumask_common.la
diff --git a/test/common_plat/validation/drv/Makefile.am 
b/test/common_plat/validation/drv/Makefile.am
index bcdb92e..1574f3d 100644
--- a/test/common_plat/validation/drv/Makefile.am
+++ b/test/common_plat/validation/drv/Makefile.am
@@ -1,4 +1,5 @@
 ODPDRV_MODULES = drvatomic \
+drvinit \
 drvshmem
 
 SUBDIRS = $(ODPDRV_MODULES)
diff --git a/test/common_plat/validation/drv/drvinit/.gitignore 
b/test/common_plat/validation/drv/drvinit/.gitignore
new file mode 100644
index 000..0d56fa9
--- /dev/null
+++ b/test/common_plat/validation/drv/drvinit/.gitignore
@@ -0,0 +1,3 @@
+drvinit_main
+odp_conf_path.h
+odp.conf
diff --git a/test/common_plat/validation/drv/drvinit/Makefile.am 
b/test/common_plat/validation/drv/drvinit/Makefile.am
new file mode 100644
index 000..622bbf3
--- /dev/null
+++ b/test/common_plat/validation/drv/drvinit/Makefile.am
@@ -0,0 +1,27 @@
+include ../Makefile.inc
+include $(top_srcdir)/platform/@with_platform@/Makefile.inc
+
+ABS_TEST_BUILDDIR = $(abs_top_builddir)/test/common_plat/validation/drv/drvinit
+
+noinst_LTLIBRARIES = libtestdrvinit.la
+libtestdrvinit_la_SOURCES = drvinit.c
+
+# the minimalist driver:
+lib_LTLIBRARIES = empty_driver.la
+empty_driver_la_SOURCES = empty_driver.c
+empty_driver_la_LDFLAGS = $(AM_LDFLAGS) -module -shared -export-dynamic \
+ -avoid-version
+
+# the program trying to load the driver:
+# autotools ack: poking straight into .libs to find the ".so" file...
+# and hardcoding rpath...

Re: [lng-odp] [API-NEXT PATCH v3] api: ipsec: added IPSEC API

2016-12-08 Thread Bala Manoharan
Regards,
Bala


On 8 December 2016 at 14:37, Savolainen, Petri (Nokia - FI/Espoo)
 wrote:
>
>> > +
>> > +/**
>> > + * Fragmentation mode
>> > + *
>> > + * These options control outbound IP packet fragmentation offload. When
>> offload
>> > + * is enabled, IPSEC operation will determine if fragmentation is
>> needed and
>> > + * does it according to the mode.
>> > + */
>> > +typedef enum odp_ipsec_frag_mode_t {
>> > +   /** Do not fragment IP packets */
>> > +   ODP_IPSEC_FRAG_DISABLED = 0,
>> > +
>> > +   /** Fragment IP packet before IPSEC operation */
>> > +   ODP_IPSEC_FRAG_BEFORE,
>> > +
>> > +   /** Fragment IP packet after IPSEC operation */
>> > +   ODP_IPSEC_FRAG_AFTER,
>> > +
>> > +   /** Only check if IP fragmentation is needed,
>> > + * do not fragment packets. */
>> > +   ODP_IPSEC_FRAG_CHECK
>>
>> What is the expected behaviour for this case of ODP_IPSEC_FRAG_CHECK?
>> Does the implementation send an error code if the packet needs to be
>> fragmented?
>>
>> -Bala
>
>
> Yes, implementation checks packet length against MTU and returns this status 
> ...

Okay. This could be done but it is simple and could be done by the
application itself right? There is no value addition in implementation
doing this.

>
> /** Packet does not fit into the given MTU size */
>uint32_t mtu  : 1;
>
> ... if it does not fit. User needs to fragment the packet and try again.
>
>
> -Petri
>
>
>
>


Re: [lng-odp] [API-NEXT PATCH v3] api: ipsec: added IPSEC API

2016-12-08 Thread Savolainen, Petri (Nokia - FI/Espoo)

> > +
> > +/**
> > + * Fragmentation mode
> > + *
> > + * These options control outbound IP packet fragmentation offload. When
> offload
> > + * is enabled, IPSEC operation will determine if fragmentation is
> needed and
> > + * does it according to the mode.
> > + */
> > +typedef enum odp_ipsec_frag_mode_t {
> > +   /** Do not fragment IP packets */
> > +   ODP_IPSEC_FRAG_DISABLED = 0,
> > +
> > +   /** Fragment IP packet before IPSEC operation */
> > +   ODP_IPSEC_FRAG_BEFORE,
> > +
> > +   /** Fragment IP packet after IPSEC operation */
> > +   ODP_IPSEC_FRAG_AFTER,
> > +
> > +   /** Only check if IP fragmentation is needed,
> > + * do not fragment packets. */
> > +   ODP_IPSEC_FRAG_CHECK
> 
> What is the expected behaviour for this case of ODP_IPSEC_FRAG_CHECK?
> Does the implementation send an error code if the packet needs to be
> fragmented?
> 
> -Bala


Yes, implementation checks packet length against MTU and returns this status ...

/** Packet does not fit into the given MTU size */
   uint32_t mtu  : 1;

... if it does not fit. User needs to fragment the packet and try again.


-Petri






Re: [lng-odp] [API-NEXT PATCH v3] api: ipsec: added IPSEC API

2016-12-08 Thread Bala Manoharan
Comment inline...

Regards,
Bala


On 1 December 2016 at 14:47, Petri Savolainen
 wrote:
> Added definitions for a look-a-side IPSEC offload API. In addition to
> IPSEC packet transformations, it also supports:
> * inbound SA look up
> * outbound IP fragmentation
>
> Signed-off-by: Petri Savolainen 
> ---
>
> Changes in v3:
> * Reword packet ordering specification
>
> Changes in v2:
> * Specify that synchronous calls cannot process all packets
>   if output.num_pkt < input.num_pkt
> * Specify that resulting event must be freed before calling using packets
> * Added soft/hard sec limit capability
> * Improved packet order specification
>
> Changes in v1:
> * renamed odp_ipsec_proto_t to renamed odp_ipsec_protocol_t
> * specify that lifetime sec limit is from the SA creation
> * added odp_ipsec_sa_context()
> * pool for output packets is the same as packet input pool
> * added antireplay check and protocol error codes
> * specified which input / output packet offsets and flags are set
> * moved sync/async mode selection to global config (odp_ipsec_config())
> * added IPSEC capability to aid mode selection
> * specify that also packet user area is copied from input to output packet
>
>
>  include/odp/api/spec/event.h   |   2 +-
>  include/odp/api/spec/ipsec.h   | 883 
> +
>  include/odp_api.h  |   1 +
>  platform/Makefile.inc  |   1 +
>  platform/linux-generic/Makefile.am |   2 +
>  platform/linux-generic/include/odp/api/ipsec.h |  36 +
>  .../include/odp/api/plat/event_types.h |   1 +
>  .../include/odp/api/plat/ipsec_types.h |  39 +
>  8 files changed, 964 insertions(+), 1 deletion(-)
>  create mode 100644 include/odp/api/spec/ipsec.h
>  create mode 100644 platform/linux-generic/include/odp/api/ipsec.h
>  create mode 100644 platform/linux-generic/include/odp/api/plat/ipsec_types.h
>
> diff --git a/include/odp/api/spec/event.h b/include/odp/api/spec/event.h
> index fdfa52d..75c0bbc 100644
> --- a/include/odp/api/spec/event.h
> +++ b/include/odp/api/spec/event.h
> @@ -39,7 +39,7 @@ extern "C" {
>   * @typedef odp_event_type_t
>   * ODP event types:
>   * ODP_EVENT_BUFFER, ODP_EVENT_PACKET, ODP_EVENT_TIMEOUT,
> - * ODP_EVENT_CRYPTO_COMPL
> + * ODP_EVENT_CRYPTO_COMPL, ODP_EVENT_IPSEC_RESULT
>   */
>
>  /**
> diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h
> new file mode 100644
> index 000..86f66e6
> --- /dev/null
> +++ b/include/odp/api/spec/ipsec.h
> @@ -0,0 +1,883 @@
> +/* Copyright (c) 2016, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier: BSD-3-Clause
> + */
> +
> +/**
> + * @file
> + *
> + * ODP IPSEC API
> + */
> +
> +#ifndef ODP_API_IPSEC_H_
> +#define ODP_API_IPSEC_H_
> +#include 
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#include 
> +
> +/** @defgroup odp_ipsec ODP IPSEC
> + *  Operations of IPSEC API.
> + *  @{
> + */
> +
> +/**
> + * @typedef odp_ipsec_sa_t
> + * IPSEC Security Association (SA)
> + */
> +
> + /**
> + * @def ODP_IPSEC_SA_INVALID
> + * Invalid IPSEC SA
> + */
> +
> +/**
> + * IPSEC operation mode
> + */
> +typedef enum odp_ipsec_op_mode_t {
> +   /** Synchronous IPSEC operation
> + *
> + * Application uses synchronous IPSEC operations,
> + * which output all results on function return.
> + */
> +   ODP_IPSEC_OP_MODE_SYNC = 0,
> +
> +   /** Asynchronous IPSEC operation
> + *
> + * Application uses asynchronous IPSEC operations,
> + * which return results via events.
> + */
> +   ODP_IPSEC_OP_MODE_ASYNC
> +
> +} odp_ipsec_op_mode_t;
> +
> +/**
> + * IPSEC capability
> + */
> +typedef struct odp_ipsec_capability_t {
> +   /** Maximum number of IPSEC SAs */
> +   uint32_t max_num_sa;
> +
> +   /** Synchronous IPSEC operation mode (ODP_IPSEC_OP_MODE_SYNC) support
> +*
> +*  0: Synchronous mode is not supported
> +*  1: Synchronous mode is supported
> +*  2: Synchronous mode is supported and preferred
> +*/
> +   uint8_t op_mode_sync;
> +
> +   /** Asynchronous IPSEC operation mode (ODP_IPSEC_OP_MODE_ASYNC) 
> support
> +*
> +*  0: Asynchronous mode is not supported
> +*  1: Asynchronous mode is supported
> +*  2: Asynchronous mode is supported and preferred
> +*/
> +   uint8_t op_mode_async;
> +
> +   /** Soft expiry limit in seconds support
> +*
> +*  0: Limit is not supported
> +*  1: Limit is supported
> +*/
> +   uint8_t soft_limit_sec;
> +
> +   /** Hard expiry limit in seconds support
> +*
> +*  0: Limit is not supported
> +*  1: Limit is supported
> +*/
> +   uint8_t hard_limit_sec;
> +
> +   /** Supported cipher algorithms 

[lng-odp] [API-NEXT PATCHv4 5/5] linux-gen: drv_drivers: loading modules from config file

2016-12-08 Thread Christophe Milard
The shared objects listed in the ODP configuration files are
loaded at init time. The odp configuration file list the
shared objects to be loaded as shown in the following example:
module = {
modules = ["enumerator1.so", "driver1.so"];
};

Signed-off-by: Christophe Milard 
---
 configure.ac  |  4 +--
 platform/linux-generic/drv_driver.c   | 41 +++
 platform/linux-generic/include/odp_internal.h |  3 ++
 platform/linux-generic/m4/configure.m4|  1 +
 platform/linux-generic/m4/odp_drivers.m4  | 11 +++
 platform/linux-generic/odp_init.c |  7 +
 6 files changed, 65 insertions(+), 2 deletions(-)
 create mode 100644 platform/linux-generic/m4/odp_drivers.m4

diff --git a/configure.ac b/configure.ac
index 7a2c7a1..0f90287 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,7 +47,7 @@ AC_PROG_MAKE_SET
 
 AM_PROG_AR
 #Use libtool
-LT_INIT([])
+LT_INIT([dlopen])
 AC_SUBST([LIBTOOL_DEPS])
 AM_PROG_LIBTOOL
 
@@ -58,7 +58,7 @@ AC_CHECK_FUNCS([bzero clock_gettime gethostbyname getpagesize 
gettimeofday memse
 
 # Checks for header files.
 AC_HEADER_RESOLV
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h limits.h netdb.h netinet/in.h 
stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h 
unistd.h])
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h limits.h netdb.h netinet/in.h 
stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h 
unistd.h dlfcn.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_HEADER_STDBOOL
diff --git a/platform/linux-generic/drv_driver.c 
b/platform/linux-generic/drv_driver.c
index c520d1d..c6513df 100644
--- a/platform/linux-generic/drv_driver.c
+++ b/platform/linux-generic/drv_driver.c
@@ -9,6 +9,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 int odrdrv_enum_class_register(odpdrv_enum_class_t *enum_class)
 {
@@ -41,3 +43,42 @@ int odpdrv_driver_register(odpdrv_driver_t *driver)
 
return 0;
 }
+
+static int load_modules(void)
+{
+   const config_setting_t *modules_section;
+   const char *drv_name;
+   int i;
+   config_t *cf;
+   int drv_count;
+
+   cf = _global_data.configuration;
+   modules_section = config_lookup(cf, "module.modules");
+   if (!modules_section)
+   return 0;
+
+   drv_count = config_setting_length(modules_section);
+   if (!drv_count)
+   return 0;
+
+   for (i = 0; i < drv_count; i++) {
+   drv_name = config_setting_get_string_elem(modules_section, i);
+   if (dlopen(drv_name, RTLD_NOW) == NULL) {
+   ODP_ERR("dlopen failed for %s: %s\n",
+   drv_name, dlerror());
+   return -1;
+   }
+   ODP_DBG("module %s loaded.\n", drv_name);
+   }
+
+   return 0;
+}
+
+int _odpdrv_driver_init_global(void)
+{
+   /* load modules (enumerator and drivers...) */
+   if (load_modules())
+   return -1;
+
+   return 0;
+}
diff --git a/platform/linux-generic/include/odp_internal.h 
b/platform/linux-generic/include/odp_internal.h
index 9d2c78b..88b8f3a 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -72,6 +72,7 @@ enum init_stage {
CLASSIFICATION_INIT,
TRAFFIC_MNGR_INIT,
NAME_TABLE_INIT,
+   DRIVER_INIT,
ALL_INIT  /* All init stages completed */
 };
 
@@ -130,6 +131,8 @@ int _odp_ishm_init_local(void);
 int _odp_ishm_term_global(void);
 int _odp_ishm_term_local(void);
 
+int _odpdrv_driver_init_global(void);
+
 int cpuinfo_parser(FILE *file, system_info_t *sysinfo);
 uint64_t odp_cpu_hz_current(int id);
 
diff --git a/platform/linux-generic/m4/configure.m4 
b/platform/linux-generic/m4/configure.m4
index 5fab0cc..96bec46 100644
--- a/platform/linux-generic/m4/configure.m4
+++ b/platform/linux-generic/m4/configure.m4
@@ -46,6 +46,7 @@ m4_include([platform/linux-generic/m4/odp_netmap.m4])
 m4_include([platform/linux-generic/m4/odp_dpdk.m4])
 m4_include([platform/linux-generic/m4/odp_ipc.m4])
 m4_include([platform/linux-generic/m4/odp_schedule.m4])
+m4_include([platform/linux-generic/m4/odp_drivers.m4])
 
 AC_CONFIG_FILES([platform/linux-generic/Makefile
  platform/linux-generic/include/odp/api/plat/static_inline.h])
diff --git a/platform/linux-generic/m4/odp_drivers.m4 
b/platform/linux-generic/m4/odp_drivers.m4
new file mode 100644
index 000..03f61f8
--- /dev/null
+++ b/platform/linux-generic/m4/odp_drivers.m4
@@ -0,0 +1,11 @@
+##
+# Check for dlopen and lt equivalent availability
+##
+
+AC_SEARCH_LIBS([dlopen], [dl dld],
+[
+   AM_LDFLAGS="$AM_LDFLAGS -ldl"
+],
+[
+   

[lng-odp] [API-NEXT PATCHv4 3/5] linux-gen: init: adding configuration file parsing

2016-12-08 Thread Christophe Milard
The parsing of the odp.conf configuration file is added.
The file is searched first in the local directory (.) and
then is the $prefix/etc directory.
This requires libconfig (sudo apt-get install libconfig-dev)

Signed-off-by: Christophe Milard 
---
 DEPENDENCIES  |  2 +-
 platform/linux-generic/Makefile.am|  1 +
 platform/linux-generic/include/odp_internal.h |  2 +
 platform/linux-generic/m4/configure.m4| 11 +
 platform/linux-generic/odp_init.c | 70 +++
 5 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/DEPENDENCIES b/DEPENDENCIES
index f1f0edd..a24b1c8 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -18,7 +18,7 @@ Prerequisites for building the OpenDataPlane (ODP) API
 
 3. Required libraries
 
-   Libraries currently required to link: openssl
+   Libraries currently required to link: openssl, libconfig-dev
 
 3.1 OpenSSL native compile
 
diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 2ed8043..19e11e3 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -8,6 +8,7 @@ AM_CFLAGS +=  -I$(srcdir)/include
 AM_CFLAGS +=  -I$(top_srcdir)/include
 AM_CFLAGS +=  -I$(top_builddir)/include
 AM_CFLAGS +=  -Iinclude
+AM_CFLAGS +=  -DSYSCONFDIR=\"@sysconfdir@\"
 
 include_HEADERS = \
  $(top_srcdir)/include/odp.h \
diff --git a/platform/linux-generic/include/odp_internal.h 
b/platform/linux-generic/include/odp_internal.h
index 6a80d9d..9d2c78b 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -22,6 +22,7 @@ extern "C" {
 #include 
 #include 
 #include 
+#include 
 
 extern __thread int __odp_errno;
 
@@ -51,6 +52,7 @@ struct odp_global_data_s {
odp_cpumask_t worker_cpus;
int num_cpus_installed;
int ipc_ns;
+   config_t configuration;
 };
 
 enum init_stage {
diff --git a/platform/linux-generic/m4/configure.m4 
b/platform/linux-generic/m4/configure.m4
index d3e5528..5fab0cc 100644
--- a/platform/linux-generic/m4/configure.m4
+++ b/platform/linux-generic/m4/configure.m4
@@ -28,6 +28,17 @@ AC_LINK_IFELSE(
 echo "Use newer version. For gcc > 4.7.0"
 exit -1)
 
+# Check for libconfig (required)
+AC_CHECK_HEADERS([libconfig.h], HEADER_LIBCONFIG="yes")
+PKG_CHECK_MODULES([PKGCONFIG], [libconfig >= 1.3.2], LIBRARY_LIBCONFIG="yes")
+if test "x$LIBRARY_LIBCONFIG" != "x" && test "x$HEADER_LIBCONFIG" != "x" ; then
+CFLAGS="$CFLAGS $PKGCONFIG_CFLAGS"
+LIBS="$LIBS $PKGCONFIG_LIBS"
+AM_CPPFLAGS="$AM_CPPFLAGS `pkg-config --cflags-only-I libconfig`"
+else
+AC_MSG_FAILURE([libconfig not found (required)])
+fi
+
 m4_include([platform/linux-generic/m4/odp_pthread.m4])
 m4_include([platform/linux-generic/m4/odp_openssl.m4])
 m4_include([platform/linux-generic/m4/odp_pcap.m4])
diff --git a/platform/linux-generic/odp_init.c 
b/platform/linux-generic/odp_init.c
index d40a83c..797c60a 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -10,6 +10,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -21,6 +23,15 @@
 #define _ODP_FILES_FMT "odp-%d-"
 #define _ODP_TMPDIR"/tmp"
 
+/* the name of the ODP configuration file: */
+#define CONFIGURATION_FILE_ENV_NONE "none"
+#define CONFIGURATION_FILE "odp.conf"
+#define CONFIGURATION_FILE_REL ("./" CONFIGURATION_FILE)
+#define CONFIGURATION_FILE_ABS (SYSCONFDIR "/" CONFIGURATION_FILE)
+
+/* the ODP configuration file name can also be oveerwritten by env. variable: 
*/
+#define ODP_SYSCONFIG_FILE_ENV "ODP_SYSCONFIG_FILE"
+
 struct odp_global_data_s odp_global_data;
 
 /* remove all files staring with "odp-" from a directory "dir" */
@@ -65,6 +76,62 @@ static int cleanup_files(const char *dirpath, int odp_pid)
return 0;
 }
 
+/* read the odp configuration file
+ *
+ * the configuration file is read from:
+ * 1) Wherever env variable ODP_SYSCONFIG_FILE says (or "none")
+ * 2) ./odp.conf
+ * 3) the @sysconfig@/odp.conf
+ * (checked in reversed order overwritting each-other)
+ * So the environment variable setting supperseeds any other file.
+ * If the environment variable exists and set to the string "none"
+ * the configuration file reading is inibited (used to prevent
+ * test which do not need a file to read the user or system files)
+ */
+static int read_configfile(void)
+{
+   char *env_config_filename;
+   const char *config_filename;
+   config_t *cf;
+
+   /* initialize and read the configuration file if any: */
+   cf = _global_data.configuration;
+   config_init(cf);
+   config_filename = NULL;
+   if (access(CONFIGURATION_FILE_ABS, R_OK) != -1)
+   config_filename = CONFIGURATION_FILE_ABS;
+   if (access(CONFIGURATION_FILE_REL, R_OK) != -1)
+   config_filename = CONFIGURATION_FILE_REL;
+   

[lng-odp] [API-NEXT PATCHv4 4/5] test: preventing odp.conf loading for tests

2016-12-08 Thread Christophe Milard
The tests should not be affected by any system or user ODP configuration
file. The ODP_SYSCONFIG_FILE environment variables is therefore set
to "none" in TESTS_ENVIRONMENT.
Tests which needs specific a configuration file will have to overwrite
this setting.
Note that tests ran manually (not using make check) may be affected
by configuration files. Setting ODP_SYSCONFIG_FILE to an appropriate value
(possibly "none") may be required.

Signed-off-by: Christophe Milard 
---
 test/Makefile.inc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/Makefile.inc b/test/Makefile.inc
index 1ebc047..8d17b56 100644
--- a/test/Makefile.inc
+++ b/test/Makefile.inc
@@ -22,4 +22,6 @@ AM_LDFLAGS += -L$(LIB)
 @VALGRIND_CHECK_RULES@
 valgrind_tools = memcheck
 
-TESTS_ENVIRONMENT= ODP_PLATFORM=${with_platform} EXEEXT=${EXEEXT}
+TESTS_ENVIRONMENT= ODP_PLATFORM=${with_platform} \
+  EXEEXT=${EXEEXT} \
+  ODP_SYSCONFIG_FILE=none
-- 
2.7.4



[lng-odp] [API-NEXT PATCHv4 0/5] driver initialisation framework

2016-12-08 Thread Christophe Milard
Since V3:
 -minor interface simplification and name change (Christophe)
 -Fix for clang (Bill)
 -Google doc describing the driver and device frameworks structure:
https://docs.google.com/document/d/1eCKPJF6uSlOllXi_sKDvRwUD2BXm-ZzxZoKT0nVEsl4/edit#heading=h.osxoshqj1bj

Since V2:
 -function odp_load_driver removed. replaced by config file. (Petri, FF)
 -configuration file "odp.conf" added. Configuration file is:
1) as specified in env variable ODP_SYSCONFIG_FILE (which can be "none").
2) ./odp.conf
3) $(prefix)/etc/odp.conf
 -test removed: will be sent in a separate patch as many questions remains.
 -All libdl tests removed: libdl is assumed to always be on linux (Maxim)

Since V1:
 -enum names prefixed by ODPDRV (Yi)
 -better commit message for last patch (Christophe)
 -typo fix (Christophe)

Christophe Milard (5):
  drv: adding driver registration interface (stub)
  linux-gen: adding enum, devio and driver registration interface (stub)
  linux-gen: init: adding configuration file parsing
  test: preventing odp.conf loading for tests
  linux-gen: drv_drivers: loading modules from config file

 DEPENDENCIES|   2 +-
 configure.ac|   4 +-
 include/odp/drv/spec/driver.h   | 299 
 include/odp_drv.h   |   1 +
 platform/Makefile.inc   |   1 +
 platform/linux-generic/Makefile.am  |   3 +
 platform/linux-generic/drv_driver.c |  84 +++
 platform/linux-generic/include/odp/drv/driver.h |  27 +++
 platform/linux-generic/include/odp_internal.h   |   5 +
 platform/linux-generic/m4/configure.m4  |  12 +
 platform/linux-generic/m4/odp_drivers.m4|  11 +
 platform/linux-generic/odp_init.c   |  77 ++
 test/Makefile.inc   |   4 +-
 13 files changed, 526 insertions(+), 4 deletions(-)
 create mode 100644 include/odp/drv/spec/driver.h
 create mode 100644 platform/linux-generic/drv_driver.c
 create mode 100644 platform/linux-generic/include/odp/drv/driver.h
 create mode 100644 platform/linux-generic/m4/odp_drivers.m4

-- 
2.7.4



[lng-odp] [API-NEXT PATCHv4 2/5] linux-gen: adding enum, devio and driver registration interface (stub)

2016-12-08 Thread Christophe Milard
The linux implementation for the enumerator class registration function,
enumerator instance registration function,
devio and driver registration functions (stub)

Signed-off-by: Christophe Milard 
---
 include/odp_drv.h   |  1 +
 platform/linux-generic/Makefile.am  |  2 ++
 platform/linux-generic/drv_driver.c | 43 +
 platform/linux-generic/include/odp/drv/driver.h | 27 
 4 files changed, 73 insertions(+)
 create mode 100644 platform/linux-generic/drv_driver.c
 create mode 100644 platform/linux-generic/include/odp/drv/driver.h

diff --git a/include/odp_drv.h b/include/odp_drv.h
index 0959879..96d81ba 100644
--- a/include/odp_drv.h
+++ b/include/odp_drv.h
@@ -23,6 +23,7 @@ extern C {
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index adbe24d..2ed8043 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -107,6 +107,7 @@ odpdrvinclude_HEADERS = \
  $(srcdir)/include/odp/drv/barrier.h \
  $(srcdir)/include/odp/drv/byteorder.h \
  $(srcdir)/include/odp/drv/compiler.h \
+ $(srcdir)/include/odp/drv/driver.h \
  $(srcdir)/include/odp/drv/shm.h \
  $(srcdir)/include/odp/drv/spinlock.h \
  $(srcdir)/include/odp/drv/std_types.h \
@@ -225,6 +226,7 @@ __LIB__libodp_linux_la_SOURCES = \
   odp_weak.c \
   drv_atomic.c \
   drv_barrier.c \
+  drv_driver.c \
   drv_shm.c \
   drv_spinlock.c \
   arch/@ARCH_DIR@/odp_cpu_arch.c \
diff --git a/platform/linux-generic/drv_driver.c 
b/platform/linux-generic/drv_driver.c
new file mode 100644
index 000..c520d1d
--- /dev/null
+++ b/platform/linux-generic/drv_driver.c
@@ -0,0 +1,43 @@
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int odrdrv_enum_class_register(odpdrv_enum_class_t *enum_class)
+{
+   ODP_ERR("NOT Supported yet! Enumerator Class %s Registration!\n.",
+   enum_class->name);
+
+   return 0;
+}
+
+int odpdrv_enum_register(odpdrv_enum_t *enumerator)
+{
+   ODP_ERR("NOT Supported yet! Enumerator instance %s Registration!\n.",
+   enumerator->class_name);
+
+   return 0;
+}
+
+int odpdrv_devio_register(odpdrv_devio_t *devio)
+{
+   ODP_ERR("NOT Supported yet! Driver %s Registration!\n.",
+   devio->devio_api_name);
+
+   return 0;
+}
+
+int odpdrv_driver_register(odpdrv_driver_t *driver)
+{
+   ODP_ERR("NOT Supported yet! Driver %s Registration!\n.",
+   driver->name);
+
+   return 0;
+}
diff --git a/platform/linux-generic/include/odp/drv/driver.h 
b/platform/linux-generic/include/odp/drv/driver.h
new file mode 100644
index 000..9eb6962
--- /dev/null
+++ b/platform/linux-generic/include/odp/drv/driver.h
@@ -0,0 +1,27 @@
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODPDRV drivers
+ */
+
+#ifndef ODPDRV_PLAT_DRIVER_H_
+#define ODPDRV_PLAT_DRIVER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+#include 
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-- 
2.7.4



[lng-odp] [API-NEXT PATCHv4 1/5] drv: adding driver registration interface (stub)

2016-12-08 Thread Christophe Milard
The enumerator class, enumerator instance, devio and driver registration
functions prototypes (and a draft of their parameters) are
defined, the goal being to define the registration framework only.

Signed-off-by: Christophe Milard 
---
 include/odp/drv/spec/driver.h | 299 ++
 platform/Makefile.inc |   1 +
 2 files changed, 300 insertions(+)
 create mode 100644 include/odp/drv/spec/driver.h

diff --git a/include/odp/drv/spec/driver.h b/include/odp/drv/spec/driver.h
new file mode 100644
index 000..e882237
--- /dev/null
+++ b/include/odp/drv/spec/driver.h
@@ -0,0 +1,299 @@
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODPDRV driver
+ */
+
+#ifndef ODPDRV_DRIVER_H_
+#define ODPDRV_DRIVER_H_
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* @addtogroup odpdrv_driver
+* @details
+* enumerator and driver interface to ODP
+*
+*  1) ODP load the different modules (i.e. it loads shared libraries, *.so).
+* In the context of drivers, shared libraries may contain enumerators,
+* drivers and devios. These register in step 2.
+*
+*  2)  odpdrv_enum_class_register(int (probe*)()...)
+*  --->
+*  odrdrv_driver_register(int (probe*)()...)
+*  --->
+*  odpdrv devio register()
+*  --->
+*  A number of device_enumerator_classes are registered at the ODP startup.
+*  Many classes are expected: static, ACPI, PCI, switchdev, virtual, DPAA2...
+*  A number of drivers also register to ODP (passing their own probe function).
+*  A number of device IO may also register to ODP (defining available devices
+*  interfaces).
+*
+*  3)  ODP calls the probe function of each enumerator class
+*  <---
+*  odrdrv_emum_register(int (probe*)()...)
+*  --->
+*  --->
+*  --->
+*  odrdrv_devio_register(...)
+*  --->
+*  --->
+*  --->
+*  ODP calls the probe function of each registered enumerator_class.
+*  This result in the enumerator_class registering some
+*  enumerators (instances of the class) by calling
+*  odrdrv_emumerator_register() for each instance.
+*  A given enumerator_class may create many enumerators based on its platform:
+*  For instance Linux defines a number of PCI domains that can be viewed as
+*  multiple PCI enumerators. In addition, it could be considered that each PCI
+*  root of each processor socket in a NUMA environment has its own PCI
+*  enumerator.
+*  For enumerator class PCI, there could be one instance for each PCI
+*  domain.
+*  Note that the probe function of a given class may be recalled at any time
+*  (Hotplug)
+*  The devios delivered with their enumarator may also register at this stage.
+*
+*  4) For each enumerator instance , odp calls the probe function to retrieve
+*  the list of devices enumerated by the given enumerator instance.
+*  Note that the probe function of a given enumerator may be recalled at any
+*  time(Hotplug)
+*
+*  5) The driver framework calls the drivers probe(D,I) functions of the
+*  drivers, with device D and devio I as parameter, assuming that:
+*  -devio I was on the driver supported list of devio (and version matches)
+*  -the devio I is registered and found its enumerator interface(E) api
+*   (name and version)
+*  -device D was enumerated by an enumerator providing interface E.
+*  The return value of the driver probe function tells whether the driver
+*  can handle the device or not.
+*
+* @{
+*/
+
+/* forward declarations for a top down description of structures */
+typedef struct odpdrv_enum_class_t odpdrv_enum_class_t;
+typedef struct odpdrv_enum_t odpdrv_enum_t;
+typedef struct odpdrv_enumerated_dev_t odpdrv_enumerated_dev_t;
+typedef struct odpdrv_devio_t odpdrv_devio_t;
+typedef struct odpdrv_driver_t odpdrv_driver_t;
+
+/** maximum size for driver and enumerator names: */
+#define ODPDRV_NAME_MAX_SZ 32
+
+/** maximum size for the enumerator dependent address: */
+#define ODPDRV_NAME_ADDR_SZ 64
+
+/** The maximum number of interfaces an driver may support: */
+#define ODPDRV_MAX_DEVIOS 3
+
+/**
+* Parameter to be given at enumerator class registration:
+*/
+struct odpdrv_enum_class_t {
+   /** enumerator name: mostly used for debug purpose.
+* Name must be unique (e.g. "PCI-DPAA2")
+*/
+   const char 

Re: [lng-odp] [API-NEXT PATCHv7 1/3] api: random: add explicit controls over random data

2016-12-08 Thread Savolainen, Petri (Nokia - FI/Espoo)
>  /**
> + * Random kind selector
> + *
> + * The kind of random denotes the statistical quality of the random data
> + * returned. Basic random simply appears uniformly distributed,
> Cryptographic
> + * random is statistically random and suitable for use by cryptographic
> + * functions. True random is generated from a hardware entropy source
> rather
> + * than an algorithm and is thus completely unpredictable. These form a
> + * hierarchy where higher quality data is presumably more costly to
> generate
> + * than lower quality data.
> + */
> +typedef enum {
> + /** Basic random, presumably pseudo-random generated by SW */
> + ODP_RANDOM_BASIC,
> + /** Cryptographic quality random */
> + ODP_RANDOM_CRYPTO,
> + /** True random, generated from a HW entropy source */
> + ODP_RANDOM_TRUE,
> +} odp_random_kind_t;
> +
> +/**
> + * Query random max kind
> + *
> + * Implementations support the returned max kind and all kinds weaker
> than it.

I think this is still not explicit enough on the order: which end is "max" on 
the enumeration. Something like:

"The maximum kind value is ODP_RANDOM_TRUE."

Or in the enum:

/** True random, generated from a HW entropy source. This is the maximum kind 
value. */
ODP_RANDOM_TRUE,


> + *
> + * @return kind The maximum odp_random_kind_t supported by this
> implementation
> + */
> +odp_random_kind_t odp_random_max_kind(void);
> +

> +
> +/**
> + * Generate repeatable random byte data
> + *
> + * For testing purposes it is often useful to generate "random" sequences
> that
> + * are repeatable. This is accomplished by supplying a seed value that is
> used
> + * for pseudo-random data generation. The caller-provided seed value is
> + * updated for each call to continue the sequence. Restarting a series of
> + * calls with the same initial seed value will generate the same sequence
> of
> + * random test data.
> + *
> + * This function should be used only for testing purposes. Use
> + * odp_random_data() for production.
>   *
> - * @todo Define the implication of the use_entropy parameter
> + * @param[out]buf  Output buffer
> + * @param len  Length of output buffer in bytes
> + * @param kind Specifies the type of random data required.
> Request
> + * will fail if the implementation is unable to
> provide
> + * repeatable random of the requested type. This is
> + * always true for true random and may be true for
> + * cryptographic random.
> + * @param[in,out] seed Seed value to use
>   *
>   * @return Number of bytes written
>   * @retval <0 on failure
>   */
> -int32_t odp_random_data(uint8_t *buf, int32_t size, odp_bool_t
> use_entropy);
> +int32_t odp_random_repeatable_data(uint8_t *buf, uint32_t len,
> +odp_random_kind_t kind, uint32_t *seed);



It seems that you missed my proposal for the prototype. See under.

/**
 * Generate repeatable random data for testing purposes
 *
 * For testing purposes it is often useful to generate "random" sequences
 * that are repeatable...
 *
 * This function should be used only for testing purposes, use odp_random_data()
 * for production.
 */
int32_t odp_random_test_data(uint8_t *buf, uint32_t len, odp_random_kind_t 
kind, uint64_t *seed);


It's a function to generate random data for testing purposes. Also note the 
longer seed, which enables usage of e.g. 48 bit random libraries.


-Petri









Re: [lng-odp] [API-NEXT PATCH] linux-gen: scheduler: solve ordered context inversion

2016-12-08 Thread Yi He
I see Petri, I'll resend with iquery patchset together.

Thanks and Best Regards, Yi

On 8 December 2016 at 15:52, Savolainen, Petri (Nokia - FI/Espoo) <
petri.savolai...@nokia-bell-labs.com> wrote:

> Hi,
>
> The point is that it cannot be reviewed as stand alone, since reviwer does
> not see the reason why it's needed. Other two schedulers do not need it,
> since those do not call dequeue simultaneously from multiple threads for
> the same queue.
>
> -Petri
>
>
> From: Yi He [mailto:yi...@linaro.org]
> Sent: Thursday, December 08, 2016 9:40 AM
> To: Savolainen, Petri (Nokia - FI/Espoo)  labs.com>
> Cc: lng-odp@lists.linaro.org; bill.fischo...@linaro.org; Elo, Matias
> (Nokia - FI/Espoo) 
> Subject: Re: [lng-odp] [API-NEXT PATCH] linux-gen: scheduler: solve
> ordered context inversion
>
> Hi, Petri
>
> I think this patch can stand alone for the problem it explains and solves,
> the two actions (dequeue events and get context sequence) are non-atomic
> and preemptable.
>
> This patch suggest that in queue dequeue operation, to add a
> sched->save_context() callback in an atomic manner.
>
> So lately default scheduler and SP scheduler can also move the context
> saving code into this call back, what do you think?
>
> Best Regards, Yi
>
> On 8 December 2016 at 15:29, Savolainen, Petri (Nokia - FI/Espoo) <
> petri.savolai...@nokia-bell-labs.com> wrote:
> This patch belongs to the iquery scheduler patch set. Without the rest of
> the code, it's impossible to tell if this change is needed or correct.
>
> -Petri
>
>
> > -Original Message-
> > From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of Yi
> He
> > Sent: Thursday, December 08, 2016 8:33 AM
> > To: lng-odp@lists.linaro.org; bill.fischo...@linaro.org; Elo, Matias
> > (Nokia - FI/Espoo) 
> > Subject: [lng-odp] [API-NEXT PATCH] linux-gen: scheduler: solve ordered
> > context inversion
> >
> > For ordered queue, a thread consumes events (dequeue) and
> > acquires its unique sequential context in two steps, non
> > atomic and preemptable.
> >
> > This leads to potential ordered context inversion in case
> > the thread consumes prior events acquired subsequent context,
> > while the thread consumes subsequent events but acquired
> > prior context.
> >
> > This patch insert the ordered context acquisition into
> > event dequeue operation to make these two steps atomic.
> >
> > Signed-off-by: Yi He 
> > ---
> > When I'm rebase iquery scheduler onto Matias' new ordered
> > queue impl I found this potential ordered context inversion
> > issue, it didnot happen to the default scheduler but happens
> > to the iquery scheduler, so after patchset will rely on this
> > patch. please help review thanks.
> >
> >  platform/linux-generic/include/odp_schedule_if.h | 3 +++
> >  platform/linux-generic/odp_queue.c   | 3 +++
> >  platform/linux-generic/odp_schedule.c| 7 ++-
> >  platform/linux-generic/odp_schedule_sp.c | 7 ++-
> >  4 files changed, 18 insertions(+), 2 deletions(-)
> >
> > diff --git a/platform/linux-generic/include/odp_schedule_if.h
> > b/platform/linux-generic/include/odp_schedule_if.h
> > index 6c2b050..c0aee42 100644
> > --- a/platform/linux-generic/include/odp_schedule_if.h
> > +++ b/platform/linux-generic/include/odp_schedule_if.h
> > @@ -12,6 +12,7 @@ extern "C" {
> >  #endif
> >
> >  #include 
> > +#include 
> >  #include 
> >
> >  typedef void (*schedule_pktio_start_fn_t)(int pktio_index, int
> > num_in_queue,
> > @@ -33,6 +34,7 @@ typedef int (*schedule_term_local_fn_t)(void);
> >  typedef void (*schedule_order_lock_fn_t)(void);
> >  typedef void (*schedule_order_unlock_fn_t)(void);
> >  typedef unsigned (*schedule_max_ordered_locks_fn_t)(void);
> > +typedef void (*schedule_save_context_fn_t)(queue_entry_t *queue);
> >
> >  typedef struct schedule_fn_t {
> >   schedule_pktio_start_fn_t   pktio_start;
> > @@ -50,6 +52,7 @@ typedef struct schedule_fn_t {
> >   schedule_order_lock_fn_torder_lock;
> >   schedule_order_unlock_fn_t  order_unlock;
> >   schedule_max_ordered_locks_fn_t max_ordered_locks;
> > + schedule_save_context_fn_t  save_context;
> >  } schedule_fn_t;
> >
> >  /* Interface towards the scheduler */
> > diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-
> > generic/odp_queue.c
> > index d9cb9f3..3b6a68b 100644
> > --- a/platform/linux-generic/odp_queue.c
> > +++ b/platform/linux-generic/odp_queue.c
> > @@ -568,6 +568,9 @@ static inline int deq_multi(queue_entry_t *queue,
> > odp_buffer_hdr_t *buf_hdr[],
> >   if (hdr == NULL)
> >   queue->s.tail = NULL;
> >
> > + if (queue->s.type == ODP_QUEUE_TYPE_SCHED)
> > + sched_fn->save_context(queue);
> > +
> >   UNLOCK(>s.lock);
> >
> >   return i;
> > diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-
> > generic/odp_schedule.c
>