[lng-odp] [API-NEXT 2/4] api: crypto: add HMAC-SHA-256-128 support

2015-11-05 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 include/odp/api/crypto.h   |  2 +
 .../linux-generic/include/odp_crypto_internal.h|  4 +
 platform/linux-generic/odp_crypto.c| 89 ++
 3 files changed, 95 insertions(+)

diff --git a/include/odp/api/crypto.h b/include/odp/api/crypto.h
index cc204a1..579354d 100644
--- a/include/odp/api/crypto.h
+++ b/include/odp/api/crypto.h
@@ -78,6 +78,8 @@ typedef enum {
ODP_AUTH_ALG_NULL,
/** HMAC-MD5 with 96 bit key */
ODP_AUTH_ALG_MD5_96,
+   /** SHA256 with 128 bit key */
+   ODP_AUTH_ALG_SHA256_128,
 } odp_auth_alg_t;
 
 /**
diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index 23fec04..10bcfd4 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -56,6 +56,10 @@ struct odp_crypto_generic_session {
uint8_t  key[16];
uint32_t bytes;
} md5;
+   struct {
+   uint8_t  key[32];
+   uint32_t bytes;
+   } sha256;
} data;
crypto_func_t func;
} auth;
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index e3bc557..ed3d14c 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -140,6 +140,72 @@ 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_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint8_t *icv   = data;
+   uint32_t len   = params->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;
+
+   /* Hash it */
+   HMAC(EVP_sha256(),
+session->auth.data.sha256.key,
+32,
+data,
+len,
+hash,
+NULL);
+
+   /* Copy to the output location */
+   memcpy(icv, hash, session->auth.data.sha256.bytes);
+
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
+odp_crypto_alg_err_t sha256_check(odp_crypto_op_params_t *params,
+ odp_crypto_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint8_t *icv   = data;
+   uint32_t len   = params->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 += params->auth_range.offset;
+   icv  += params->hash_result_offset;
+
+   /* Copy current value out and clear it before authentication */
+   memset(hash_in, 0, sizeof(hash_in));
+   memcpy(hash_in, icv, bytes);
+   memset(icv, 0, bytes);
+   memset(hash_out, 0, sizeof(hash_out));
+
+   /* Hash it */
+   HMAC(EVP_sha256(),
+session->auth.data.sha256.key,
+32,
+data,
+len,
+hash_out,
+NULL);
+
+   /* Verify match */
+   if (0 != memcmp(hash_in, hash_out, bytes))
+   return ODP_CRYPTO_ALG_ERR_ICV_CHECK;
+
+   /* Matched */
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
 odp_crypto_alg_err_t des_encrypt(odp_crypto_op_params_t *params,
 odp_crypto_generic_session_t *session)
 {
@@ -261,6 +327,26 @@ int process_md5_params(odp_crypto_generic_session_t 
*session,
return 0;
 }
 
+static
+int process_sha256_params(odp_crypto_generic_session_t *session,
+ odp_crypto_session_params_t *params,
+ uint32_t bits)
+{
+   /* Set function */
+   if (ODP_CRYPTO_OP_ENCODE == params->op)
+   session->auth.func = sha256_gen;
+   else
+   session->auth.func = sha256_check;
+
+   /* Number of valid bytes */
+   session->auth.data.sha256.bytes = bits / 8;
+
+   /* Convert keys */
+   memcpy(session->auth.data.sha256.key, params->auth_key.data, 32);
+
+   return 0;
+}
+
 int
 odp_crypto_session_create(odp_crypto_session_params_t *params,
  odp_crypto_session_t *session_out,
@@ -323,6 +409,9 @@ odp_crypto_session_create(odp_crypto_session_params_t 
*params,
case ODP_AUTH_ALG_MD5_96:
rc = process_md5_params(session, params, 96);
break;
+   case ODP_AUTH_ALG_SHA256_128:
+   rc = process_sha2

[lng-odp] [API-NEXT 3/4] validation: crypto: add test for HMAC-SHA-256-128

2015-11-05 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/crypto.h  |  1 +
 test/validation/crypto/odp_crypto_test_inp.c | 37 ++
 test/validation/crypto/test_vectors.h| 46 
 test/validation/crypto/test_vectors_len.h|  6 
 4 files changed, 90 insertions(+)

diff --git a/test/validation/crypto/crypto.h b/test/validation/crypto/crypto.h
index 7cb60d4..fe23e04 100644
--- a/test/validation/crypto/crypto.h
+++ b/test/validation/crypto/crypto.h
@@ -15,6 +15,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void);
 void crypto_test_dec_alg_3des_cbc(void);
 void crypto_test_dec_alg_3des_cbc_ovr_iv(void);
 void crypto_test_alg_hmac_md5(void);
+void crypto_test_alg_hmac_sha256(void);
 
 /* test arrays: */
 extern odp_testinfo_t crypto_suite[];
diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 05b6885..838edc4 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -295,6 +295,42 @@ void crypto_test_alg_hmac_md5(void)
}
 }
 
+/* This test verifies the correctness of HMAC_MD5 digest operation.
+ * The output check length is truncated to 12 bytes (96 bits) as
+ * returned by the crypto operation API call.
+ * Note that hash digest is a one-way operation.
+ * In addition the test verifies if the implementation can use the
+ * packet buffer as completion event buffer.
+ * */
+void crypto_test_alg_hmac_sha256(void)
+{
+   odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+auth_key   = { .data = NULL, .length = 0 };
+   odp_crypto_iv_t iv = { .data = NULL, .length = 0 };
+
+   unsigned int test_vec_num = (sizeof(hmac_sha256_reference_length) /
+sizeof(hmac_sha256_reference_length[0]));
+
+   unsigned int i;
+
+   for (i = 0; i < test_vec_num; i++) {
+   auth_key.data = hmac_sha256_reference_key[i];
+   auth_key.length = sizeof(hmac_sha256_reference_key[i]);
+
+   alg_test(ODP_CRYPTO_OP_ENCODE,
+ODP_CIPHER_ALG_NULL,
+iv,
+iv.data,
+cipher_key,
+ODP_AUTH_ALG_SHA256_128,
+auth_key,
+hmac_sha256_reference_plaintext[i],
+hmac_sha256_reference_length[i],
+hmac_sha256_reference_digest[i],
+HMAC_SHA256_128_CHECK_LEN);
+   }
+}
+
 int crypto_suite_sync_init(void)
 {
suite_context.pool = odp_pool_lookup("packet_pool");
@@ -325,5 +361,6 @@ odp_testinfo_t crypto_suite[] = {
ODP_TEST_INFO(crypto_test_enc_alg_3des_cbc_ovr_iv),
ODP_TEST_INFO(crypto_test_dec_alg_3des_cbc_ovr_iv),
ODP_TEST_INFO(crypto_test_alg_hmac_md5),
+   ODP_TEST_INFO(crypto_test_alg_hmac_sha256),
ODP_TEST_INFO_NULL,
 };
diff --git a/test/validation/crypto/test_vectors.h 
b/test/validation/crypto/test_vectors.h
index 490a3bc..6dede96 100644
--- a/test/validation/crypto/test_vectors.h
+++ b/test/validation/crypto/test_vectors.h
@@ -87,4 +87,50 @@ static uint8_t 
hmac_md5_reference_digest[][HMAC_MD5_DIGEST_LEN] = {
  0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 }
 };
 
+static uint8_t hmac_sha256_reference_key[][HMAC_SHA256_KEY_LEN] = {
+   { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b },
+
+   /* "Jefe" */
+   { 0x4a, 0x65, 0x66, 0x65 },
+
+   { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }
+};
+
+static uint32_t hmac_sha256_reference_length[] = { 8, 28, 50 };
+
+static uint8_t
+hmac_sha256_reference_plaintext[][HMAC_SHA256_MAX_DATA_LEN] = {
+   /* "Hi There" */
+   { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+
+   /* what do ya want for nothing?*/
+   { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+
+   { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd }
+};
+
+static uint8_t hmac_sha256_reference_digest[][HMAC_SHA256_DIGEST_LEN] = {
+   { 0x19, 0x8a, 0x60, 0x7e, 0xb4, 0x4b, 0xfb,

[lng-odp] [API-NEXT 0/4] Add HMAC-SHA-256-128 support

2015-11-05 Thread Nicolas Morey-Chaisemartin
The first patch is a cleanup suggested by Petri.
All the crypto enums are moved from linux-generic back to ODP API, and renamed 
(odp__t)
Following patches add support for the new HMAC function, then a validation test 
and finally support in odp-ipsec

Nicolas Morey-Chaisemartin (4):
  crypto: move enums from platform types to odp and rename to fit the
API format
  api: crypto: add HMAC-SHA-256-128 support
  validation: crypto: add test for HMAC-SHA-256-128
  example: ipsec: add support for HMAC-SHA-256-128

 example/ipsec/odp_ipsec.c  |   2 +-
 example/ipsec/odp_ipsec_cache.c|   2 +-
 example/ipsec/odp_ipsec_cache.h|   4 +-
 example/ipsec/odp_ipsec_misc.h |  12 +-
 example/ipsec/odp_ipsec_sa_db.c|   4 +
 example/ipsec/odp_ipsec_stream.c   |   3 +-
 include/odp/api/crypto.h   | 142 ++---
 .../linux-generic/include/odp/plat/crypto_types.h  |  42 --
 .../linux-generic/include/odp_crypto_internal.h|  16 ++-
 platform/linux-generic/odp_crypto.c| 116 +++--
 test/validation/crypto/crypto.h|   1 +
 test/validation/crypto/odp_crypto_test_inp.c   |  47 ++-
 test/validation/crypto/test_vectors.h  |  46 +++
 test/validation/crypto/test_vectors_len.h  |   6 +
 14 files changed, 290 insertions(+), 153 deletions(-)

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


[lng-odp] [API-NEXT 4/4] example: ipsec: add support for HMAC-SHA-256-128

2015-11-05 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 example/ipsec/odp_ipsec.c| 2 +-
 example/ipsec/odp_ipsec_misc.h   | 8 ++--
 example/ipsec/odp_ipsec_sa_db.c  | 4 
 example/ipsec/odp_ipsec_stream.c | 3 ++-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index e76e6eb..d784c31 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1554,7 +1554,7 @@ static void usage(char *progname)
   " -r, --route SubNet:Intf:NextHopMAC\n"
   " -p, --policy SrcSubNet:DstSubNet:(in|out):(ah|esp|both)\n"
   " -e, --esp SrcIP:DstIP:(3des|null):SPI:Key192\n"
-  " -a, --ah SrcIP:DstIP:(md5|null):SPI:Key128\n"
+  " -a, --ah SrcIP:DstIP:(sha256|md5|null):SPI:Key(256|128)\n"
   "\n"
   "  Where: NextHopMAC is raw hex/dot notation, i.e. 
03.BA.44.9A.CE.02\n"
   " IP is decimal/dot notation, i.e. 192.168.1.1\n"
diff --git a/example/ipsec/odp_ipsec_misc.h b/example/ipsec/odp_ipsec_misc.h
index 85c5f6a..e583c01 100644
--- a/example/ipsec/odp_ipsec_misc.h
+++ b/example/ipsec/odp_ipsec_misc.h
@@ -28,8 +28,9 @@ extern "C" {
 #define MAX_STRING  32   /**< maximum string length */
 #define MAX_IV_LEN  32   /**< Maximum IV length in bytes */
 
-#define KEY_BITS_3DES  192  /**< 3DES cipher key length in bits */
-#define KEY_BITS_MD5_96128  /**< MD5_96 auth key length in bits */
+#define KEY_BITS_3DES   192  /**< 3DES cipher key length in bits */
+#define KEY_BITS_MD5_96 128  /**< MD5_96 auth key length in bits */
+#define KEY_BITS_SHA256_128 256  /**< SHA256_128 auth key length in bits */
 
 /**< Number of bits represnted by a string of hexadecimal characters */
 #define KEY_STR_BITS(str) (4 * strlen(str))
@@ -102,6 +103,9 @@ int parse_key_string(char *keystring,
if ((alg->u.auth == ODP_AUTH_ALG_MD5_96) &&
(KEY_BITS_MD5_96 == key_bits_in))
key->length = key_bits_in / 8;
+   else if ((alg->u.auth == ODP_AUTH_ALG_SHA256_128) &&
+(KEY_BITS_SHA256_128 == key_bits_in))
+   key->length = key_bits_in / 8;
}
 
for (idx = 0; idx < key->length; idx++) {
diff --git a/example/ipsec/odp_ipsec_sa_db.c b/example/ipsec/odp_ipsec_sa_db.c
index 7967614..928c4cb 100644
--- a/example/ipsec/odp_ipsec_sa_db.c
+++ b/example/ipsec/odp_ipsec_sa_db.c
@@ -111,6 +111,10 @@ int create_sa_db_entry(char *input, odp_bool_t cipher)
entry->alg.u.auth =
ODP_AUTH_ALG_MD5_96;
entry->icv_len= 12;
+   } else if (!strcmp(token, "sha256")) {
+   entry->alg.u.auth =
+   ODP_AUTH_ALG_SHA256_128;
+   entry->icv_len= 16;
} else {
entry->alg.u.auth = ODP_AUTH_ALG_NULL;
}
diff --git a/example/ipsec/odp_ipsec_stream.c b/example/ipsec/odp_ipsec_stream.c
index 8a1cc56..f750e18 100644
--- a/example/ipsec/odp_ipsec_stream.c
+++ b/example/ipsec/odp_ipsec_stream.c
@@ -227,7 +227,8 @@ odp_packet_t create_ipv4_packet(stream_db_entry_t *stream,
/* AH (if specified) */
if (entry && (entry == stream->input.entry) &&
(ODP_AUTH_ALG_NULL != entry->ah.alg)) {
-   if (ODP_AUTH_ALG_MD5_96 != entry->ah.alg)
+   if (entry->ah.alg != ODP_AUTH_ALG_MD5_96 &&
+   entry->ah.alg != ODP_AUTH_ALG_SHA256_128)
abort();
 
ah = (odph_ahhdr_t *)data;
-- 
2.6.2.406.gaaaec35

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


Re: [lng-odp] pktio in/out mode

2015-11-05 Thread Nicolas Morey-Chaisemartin
I just realized that we cannot do that yet.
pktio entries point to a pktio_ops struct (static/const) shared by all pktios 
of this type.
We either need to duplicate the struct within the pktio so some functions can 
be overriden, or add a check within odp_pktio_(send|recv)

Nicolas

On 11/05/2015 11:25 AM, Nicolas Morey-Chaisemartin wrote:
> I didn't thought of that. it's a great idea.
>
> On 11/05/2015 11:20 AM, Savolainen, Petri (Nokia - FI/Espoo) wrote:
>> In this case e.g. the recv callback function should be set to something that 
>> reports the bug and exits. Application should never call recv if it first 
>> declares pktio input disabled.
>>
>> -Petri
>>
>>> -Original Message-
>>> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of
>>> EXT Nicolas Morey-Chaisemartin
>>> Sent: Thursday, November 05, 2015 12:10 PM
>>> To: LNG ODP Mailman List
>>> Subject: [lng-odp] pktio in/out mode
>>>
>>> Hi,
>>>
>>> In the current implementation, it is possible to open a pktio and
>>> disable Rx, Tx (or even both) using odp_pktio_params_t.
>>> However these value are never checked. So if a user calls send/recv
>>> while it is disabled, the pktio specific implementation is still
>>> called.
>>>
>>> As the goal of one way pktio is to free resources, there's a high
>>> probability that things might go wrong if a user call goes through.
>>> I can check that in my implementation but I fill that like start/stop
>>> check, these checks should be done at the pktio level and not in the
>>> pktio specific implementation.
>>>
>>> If every one agrees, I'll post a patch.
>>>
>>> Nicolas
>>> ___
>>> lng-odp mailing list
>>> lng-odp@lists.linaro.org
>>> https://lists.linaro.org/mailman/listinfo/lng-odp
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp

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


Re: [lng-odp] [API-NEXT PATCH] api: sync: update spec and add odp_sync_loads

2015-11-05 Thread Nicolas Morey-Chaisemartin
Sorry for the late feedback. I missed this one

On 10/26/2015 05:07 PM, Petri Savolainen wrote:
> Updated odp_sync_stores() specification and added odp_sync_loads
> to pair it. Used GCC __atomic_thread_fence to implement both of
> those.
>
> Signed-off-by: Petri Savolainen 
> ---
...
> +/**
> + * Synchronize loads
> + *
> + * This call implements a read memory barrier. It ensures that all 
> (non-atomic
> + * or relaxed atomic) loads that precede this call happen before any load
> + * operation that follows it. It prevents loads moving from after the call to
> + * before it.
> + *
> + * ODP synchronization mechanisms (e.g. barrier, locks, queue dequeues)
> + * include read barrier, so this call is not needed when using those.
> + *
The API here is fine. What bothers me is the footnote about all ODP sync 
mechanisms calling this.
Because Kalray architecture does not have cache coherency, a read memory 
barrier is *very* expensive.
We have to invalidate the complete cache (cheap) but then refill it later.

What our current implementation does is simply invalidate the appropriate 
structure as needed.
barriers and locks only cause write memory barrier. Queue dequeue also ensure 
that the dequeued struct (packet, timer, buffer, etc.) are up to date with the 
other threads and devices.

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


Re: [lng-odp] [PATCH] configure: move HAVE_PCAP AM_CONDITIONAL to configure.ac

2015-11-05 Thread Nicolas Morey-Chaisemartin
Ping

On 10/21/2015 02:49 PM, Nicolas Morey-Chaisemartin wrote:
> Platform specific m4 files cannot define AM_CONDITIONAL.
>
> Signed-off-by: Nicolas Morey-Chaisemartin 
> ---
>  configure.ac  | 1 +
>  platform/linux-generic/m4/odp_pcap.m4 | 1 -
>  2 files changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/configure.ac b/configure.ac
> index 5d84f92..641a7c1 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -100,6 +100,7 @@ fi
>  # Set conditionals as computed within platform specific files
>  ##
>  AM_CONDITIONAL([netmap_support], [test x$netmap_support = xyes ])
> +AM_CONDITIONAL([HAVE_PCAP], [test $have_pcap = yes])
>  
>  
>  AC_ARG_WITH([sdk-install-path],
> diff --git a/platform/linux-generic/m4/odp_pcap.m4 
> b/platform/linux-generic/m4/odp_pcap.m4
> index 734b790..0439c60 100644
> --- a/platform/linux-generic/m4/odp_pcap.m4
> +++ b/platform/linux-generic/m4/odp_pcap.m4
> @@ -8,7 +8,6 @@ AC_CHECK_HEADER(pcap/pcap.h,
>  [])],
>  [])
>  
> -AM_CONDITIONAL([HAVE_PCAP], [test $have_pcap = yes])
>  if test $have_pcap == yes; then
>  AM_CFLAGS="$AM_CFLAGS -DHAVE_PCAP"
>  LIBS="$LIBS -lpcap"

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


Re: [lng-odp] [API-NEXT PATCH] api: sync: update spec and add odp_sync_loads

2015-11-05 Thread Nicolas Morey-Chaisemartin


On 11/05/2015 04:21 PM, Bill Fischofer wrote:
> Perhaps the note could be changed to read:
>
> ODP synchronization mechanisms (e.g., barrier, locks, queue dequeues) are 
> guaranteed to be coherent, so this call is not needed when using those.
>
> No need to specify how coherency is achieved on a given platform for these 
> ops.

This sounds much better.

>
> On Thu, Nov 5, 2015 at 9:05 AM, Nicolas Morey-Chaisemartin  <mailto:nmo...@kalray.eu>> wrote:
>
> Sorry for the late feedback. I missed this one
>
> On 10/26/2015 05:07 PM, Petri Savolainen wrote:
> > Updated odp_sync_stores() specification and added odp_sync_loads
> > to pair it. Used GCC __atomic_thread_fence to implement both of
> > those.
> >
> > Signed-off-by: Petri Savolainen  <mailto:petri.savolai...@nokia.com>>
> > ---
> ...
> > +/**
> > + * Synchronize loads
> > + *
> > + * This call implements a read memory barrier. It ensures that all 
> (non-atomic
> > + * or relaxed atomic) loads that precede this call happen before any 
> load
> > + * operation that follows it. It prevents loads moving from after the 
> call to
> > + * before it.
> > + *
> > + * ODP synchronization mechanisms (e.g. barrier, locks, queue dequeues)
> > + * include read barrier, so this call is not needed when using those.
> > + *
> The API here is fine. What bothers me is the footnote about all ODP sync 
> mechanisms calling this.
> Because Kalray architecture does not have cache coherency, a read memory 
> barrier is *very* expensive.
> We have to invalidate the complete cache (cheap) but then refill it later.
>
> What our current implementation does is simply invalidate the appropriate 
> structure as needed.
> barriers and locks only cause write memory barrier. Queue dequeue also 
> ensure that the dequeued struct (packet, timer, buffer, etc.) are up to date 
> with the other threads and devices.
>
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
>

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


Re: [lng-odp] [API-NEXT PATCH] api: sync: update spec and add odp_sync_loads

2015-11-05 Thread Nicolas Morey-Chaisemartin


On 11/05/2015 04:54 PM, Savolainen, Petri (Nokia - FI/Espoo) wrote:
>
> Majority of platforms are cache coherent, for a  non-coherent platform you’d 
> need to define some additional API calls. This is documenting the current 
> assumption that application does this …
>
>  
>
> // data in shared memory
>
> int foo;
>
>  
>
> Thread A  Thread B
>
>  
>
> ev = schedule();
>
> msg = event_to_message(ev);
>
>  
>
> if (msg == UPDATE_FOO) {
>
> foo++;
>
> msg = FOO_UPDATED;
>
> queue_enq(msg);
>
> }
>
>  
>
>  ev = 
> schedule();
>
>  msg = 
> event_to_message(ev);
>
>  
>
>  if (msg == 
> FOO_UPDATED) {
>
>  
> printf(“foo is now %\n”, foo);
>
>  }
>
>  
>
>  
>
> … intead of this …
>
>  
>
> Thread A  Thread B
>
>  
>
> ev = schedule();
>
> msg = event_to_message(ev);
>
>  
>
> if (msg == UPDATE_FOO) {
>
> *// Make sure that load of “foo” is not moved before schedule()*
>
> *odp_sync_loads();*
>
> foo++;
>
> *// Make sure that store of “foo” is not moved after queue_enq()*
>
>*odp_sync_stores();*
>
> msg = FOO_UPDATED;
>
> queue_enq(msg);
>
> }
>
>  
>
>  ev = 
> schedule();
>
>  msg = 
> event_to_message(ev);
>
>  
>
>  if (msg == 
> FOO_UPDATED) {
>
> * // Make 
> sure that load of “foo” is not moved before schedule()*
>
> * 
> odp_sync_loads();*
>
>  
> printf(“foo is now %\n”, foo);
>
>  }
>
>  
>
>  
>
> As you can see it would a lot of waste if application must always sync for 
> stores and loads explicitly.
>
I see your point.
I re-read carefully the documentation and maybe we can work around it.
The sync_stores explicitly states that all store operations are globally 
visible. So cache needs to be flushed.
The load part only states that previous memory operations are complete, and 
cannot be reordered around it.
It does not explicitly states that the cache needs to be up-to-date. We 
internally use "read memory barrier" internally as DINVAL + FENCE but it is not 
necessary the case.

If my understanding of the function fits with yours, I'm good with this 
patches. If not, we need to discuss things some more.

Nicolas

 

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


Re: [lng-odp] [API-NEXT 3/4] validation: crypto: add test for HMAC-SHA-256-128

2015-11-05 Thread Nicolas Morey-Chaisemartin


On 11/05/2015 03:01 PM, Nicolas Morey-Chaisemartin wrote:
> Signed-off-by: Nicolas Morey-Chaisemartin 
> ---
>  test/validation/crypto/crypto.h  |  1 +
>  test/validation/crypto/odp_crypto_test_inp.c | 37 ++
>  test/validation/crypto/test_vectors.h| 46 
> 
>  test/validation/crypto/test_vectors_len.h|  6 
>  4 files changed, 90 insertions(+)
>
> diff --git a/test/validation/crypto/crypto.h b/test/validation/crypto/crypto.h
> index 7cb60d4..fe23e04 100644
> --- a/test/validation/crypto/crypto.h
> +++ b/test/validation/crypto/crypto.h
> @@ -15,6 +15,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void);
>  void crypto_test_dec_alg_3des_cbc(void);
>  void crypto_test_dec_alg_3des_cbc_ovr_iv(void);
>  void crypto_test_alg_hmac_md5(void);
> +void crypto_test_alg_hmac_sha256(void);
>  
>  /* test arrays: */
>  extern odp_testinfo_t crypto_suite[];
> diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
> b/test/validation/crypto/odp_crypto_test_inp.c
> index 05b6885..838edc4 100644
> --- a/test/validation/crypto/odp_crypto_test_inp.c
> +++ b/test/validation/crypto/odp_crypto_test_inp.c
> @@ -295,6 +295,42 @@ void crypto_test_alg_hmac_md5(void)
>   }
>  }
>  
> +/* This test verifies the correctness of HMAC_MD5 digest operation.
> + * The output check length is truncated to 12 bytes (96 bits) as
> + * returned by the crypto operation API call.
> + * Note that hash digest is a one-way operation.
> + * In addition the test verifies if the implementation can use the
> + * packet buffer as completion event buffer.
> + * */
> +void crypto_test_alg_hmac_sha256(void)
> +{
> + odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
> +  auth_key   = { .data = NULL, .length = 0 };
> + odp_crypto_iv_t iv = { .data = NULL, .length = 0 };
> +
> + unsigned int test_vec_num = (sizeof(hmac_sha256_reference_length) /
> +  sizeof(hmac_sha256_reference_length[0]));
> +
> + unsigned int i;
> +
> + for (i = 0; i < test_vec_num; i++) {
> + auth_key.data = hmac_sha256_reference_key[i];
> + auth_key.length = sizeof(hmac_sha256_reference_key[i]);
> +
> + alg_test(ODP_CRYPTO_OP_ENCODE,
> +  ODP_CIPHER_ALG_NULL,
> +  iv,
> +  iv.data,
> +  cipher_key,
> +  ODP_AUTH_ALG_SHA256_128,
> +  auth_key,
> +  hmac_sha256_reference_plaintext[i],
> +  hmac_sha256_reference_length[i],
> +  hmac_sha256_reference_digest[i],
> +  HMAC_SHA256_128_CHECK_LEN);
> + }
> +}
> +
>  int crypto_suite_sync_init(void)
>  {
>   suite_context.pool = odp_pool_lookup("packet_pool");
> @@ -325,5 +361,6 @@ odp_testinfo_t crypto_suite[] = {
>   ODP_TEST_INFO(crypto_test_enc_alg_3des_cbc_ovr_iv),
>   ODP_TEST_INFO(crypto_test_dec_alg_3des_cbc_ovr_iv),
>   ODP_TEST_INFO(crypto_test_alg_hmac_md5),
> + ODP_TEST_INFO(crypto_test_alg_hmac_sha256),
>   ODP_TEST_INFO_NULL,
>  };
> diff --git a/test/validation/crypto/test_vectors.h 
> b/test/validation/crypto/test_vectors.h
> index 490a3bc..6dede96 100644
> --- a/test/validation/crypto/test_vectors.h
> +++ b/test/validation/crypto/test_vectors.h
> @@ -87,4 +87,50 @@ static uint8_t 
> hmac_md5_reference_digest[][HMAC_MD5_DIGEST_LEN] = {
> 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 }
>  };
>  
> +static uint8_t hmac_sha256_reference_key[][HMAC_SHA256_KEY_LEN] = {
> + { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
> +   0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
> +   0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
> +   0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b },
> +
> + /* "Jefe" */
> + { 0x4a, 0x65, 0x66, 0x65 },
> +
> + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
> +   0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
> +   0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
> +   0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }
> +};
> +
> +static uint32_t hmac_sha256_reference_length[] = { 8, 28, 50 };
> +
> +static uint8_t
> +hmac_sha256_reference_plaintext[][HMAC_SHA256_MAX_DATA_LEN] = {
> + /* "Hi There" */
> + { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
> +
> + /* what do ya want for nothing?*/
> + { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
> +   0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
> +   0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0

[lng-odp] [API-NEXTv2 0/4] Add HMAC-SHA-256-128 support

2015-11-06 Thread Nicolas Morey-Chaisemartin
The first patch is a cleanup suggested by Petri.
All the crypto enums are moved from linux-generic back to ODP API, and renamed 
(odp__t)
Following patches add support for the new HMAC function, then a validation test 
and finally support in odp-ipsec

v2:
Correct test vectors to match the ones from RFC4868

Nicolas Morey-Chaisemartin (4):
  crypto: move enums from platform types to odp and rename to fit the
API format
  api: crypto: add HMAC-SHA-256-128 support
  validation: crypto: add test for HMAC-SHA-256-128
  example: ipsec: add support for HMAC-SHA-256-128

 example/ipsec/odp_ipsec.c  |   2 +-
 example/ipsec/odp_ipsec_cache.c|   2 +-
 example/ipsec/odp_ipsec_cache.h|   4 +-
 example/ipsec/odp_ipsec_misc.h |  12 +-
 example/ipsec/odp_ipsec_sa_db.c|   4 +
 example/ipsec/odp_ipsec_stream.c   |   3 +-
 include/odp/api/crypto.h   | 142 ++---
 .../linux-generic/include/odp/plat/crypto_types.h  |  42 --
 .../linux-generic/include/odp_crypto_internal.h|  16 ++-
 platform/linux-generic/odp_crypto.c| 116 +++--
 test/validation/crypto/crypto.h|   1 +
 test/validation/crypto/odp_crypto_test_inp.c   |  47 ++-
 test/validation/crypto/test_vectors.h  |  44 +++
 test/validation/crypto/test_vectors_len.h  |   6 +
 14 files changed, 288 insertions(+), 153 deletions(-)

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


[lng-odp] [API-NEXTv2 1/4] crypto: move enums from platform types to odp and rename to fit the API format

2015-11-06 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 example/ipsec/odp_ipsec_cache.c|   2 +-
 example/ipsec/odp_ipsec_cache.h|   4 +-
 example/ipsec/odp_ipsec_misc.h |   4 +-
 include/odp/api/crypto.h   | 140 ++---
 .../linux-generic/include/odp/plat/crypto_types.h  |  42 ---
 .../linux-generic/include/odp_crypto_internal.h|  12 +-
 platform/linux-generic/odp_crypto.c|  29 +++--
 test/validation/crypto/odp_crypto_test_inp.c   |  10 +-
 8 files changed, 93 insertions(+), 150 deletions(-)

diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c
index 6a8f3c9..0883d4d 100644
--- a/example/ipsec/odp_ipsec_cache.c
+++ b/example/ipsec/odp_ipsec_cache.c
@@ -46,7 +46,7 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,
 {
odp_crypto_session_params_t params;
ipsec_cache_entry_t *entry;
-   enum odp_crypto_ses_create_err ses_create_rc;
+   odp_crypto_ses_create_err_t ses_create_rc;
odp_crypto_session_t session;
sa_mode_t mode = IPSEC_SA_MODE_TRANSPORT;
 
diff --git a/example/ipsec/odp_ipsec_cache.h b/example/ipsec/odp_ipsec_cache.h
index 5706007..91d9d7e 100644
--- a/example/ipsec/odp_ipsec_cache.h
+++ b/example/ipsec/odp_ipsec_cache.h
@@ -38,14 +38,14 @@ typedef struct ipsec_cache_entry_s {
uint32_t tun_src_ip;  /**< Tunnel src IPv4 addr */
uint32_t tun_dst_ip;  /**< Tunnel dst IPv4 addr */
struct {
-   enum  odp_cipher_alg alg; /**< Cipher algorithm */
+   odp_cipher_alg_t alg; /**< Cipher algorithm */
uint32_t spi; /**< Cipher SPI */
uint32_t block_len;   /**< Cipher block length */
uint32_t iv_len;  /**< Cipher IV length */
ipsec_key_t  key; /**< Cipher key */
} esp;
struct {
-   enum  odp_auth_alg   alg; /**< Auth algorithm */
+   odp_auth_alg_t   alg; /**< Auth algorithm */
uint32_t spi; /**< Auth SPI */
uint32_t icv_len; /**< Auth ICV length */
ipsec_key_t  key; /**< Auth key */
diff --git a/example/ipsec/odp_ipsec_misc.h b/example/ipsec/odp_ipsec_misc.h
index f6a12b5..85c5f6a 100644
--- a/example/ipsec/odp_ipsec_misc.h
+++ b/example/ipsec/odp_ipsec_misc.h
@@ -59,8 +59,8 @@ typedef struct {
 typedef struct {
odp_bool_t cipher;
union {
-   enum odp_cipher_alg cipher;
-   enum odp_auth_alg   auth;
+   odp_cipher_alg_t cipher;
+   odp_auth_alg_t   auth;
} u;
 } ipsec_alg_t;
 
diff --git a/include/odp/api/crypto.h b/include/odp/api/crypto.h
index a9a2a1d..cc204a1 100644
--- a/include/odp/api/crypto.h
+++ b/include/odp/api/crypto.h
@@ -39,51 +39,46 @@ extern "C" {
 */
 
 /**
- * @enum odp_crypto_op_mode
  * Crypto API operation mode
- *
- * @enum odp_crypto_op_mode:ODP_CRYPTO_SYNC
- * Synchronous, return results immediately
- *
- * @enum odp_crypto_op_mode:ODP_CRYPTO_ASYNC
- * Aynchronous, return results via posted event
  */
+typedef enum {
+   /** Synchronous, return results immediately */
+   ODP_CRYPTO_SYNC,
+   /** Aynchronous, return results via posted event */
+   ODP_CRYPTO_ASYNC,
+} odp_crypto_op_mode_t;
 
 /**
- * @enum odp_crypto_op
  * Crypto API operation type
- *
- * @enum odp_crypto_op:ODP_CRYPTO_OP_ENCODE
- * Encrypt and/or compute authentication ICV
- *
- * @enum odp_crypto_op:ODP_CRYPTO_OP_DECODE
- * Decrypt and/or verify authentication ICV
  */
+typedef enum {
+   /** Encrypt and/or compute authentication ICV */
+   ODP_CRYPTO_OP_ENCODE,
+   /** Decrypt and/or verify authentication ICV */
+   ODP_CRYPTO_OP_DECODE,
+} odp_crypto_op_t;
 
 /**
- * @enum odp_cipher_alg
  * Crypto API cipher algorithm
- *
- * @enum odp_cipher_alg:ODP_CIPHER_ALG_NULL
- * No cipher algorithm specified
- *
- * @enum odp_cipher_alg:ODP_CIPHER_ALG_DES
- * DES
- *
- * @enum odp_cipher_alg:ODP_CIPHER_ALG_3DES_CBC
- * Triple DES with cipher block chaining
  */
+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,
+} odp_cipher_alg_t;
 
 /**
- * @enum odp_auth_alg
  * Crypto API authentication algorithm
- *
- * @enum odp_auth_alg:ODP_AUTH_ALG_NULL
- * No authentication algorithm specified
- *
- * @enum odp_auth_alg:ODP_AUTH_ALG_MD5_96
- * HMAC-MD5 with 96 bit key
  */
+typedef enum {
+/** No authentication algorithm specified */
+   ODP_AUTH_ALG_NULL,
+   /** HMAC-MD5 with 96 bit key */
+   ODP_AUTH_ALG_MD5

[lng-odp] [API-NEXTv2 3/4] validation: crypto: add test for HMAC-SHA-256-128

2015-11-06 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/crypto.h  |  1 +
 test/validation/crypto/odp_crypto_test_inp.c | 37 +++
 test/validation/crypto/test_vectors.h| 44 
 test/validation/crypto/test_vectors_len.h|  6 
 4 files changed, 88 insertions(+)

diff --git a/test/validation/crypto/crypto.h b/test/validation/crypto/crypto.h
index 7cb60d4..fe23e04 100644
--- a/test/validation/crypto/crypto.h
+++ b/test/validation/crypto/crypto.h
@@ -15,6 +15,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void);
 void crypto_test_dec_alg_3des_cbc(void);
 void crypto_test_dec_alg_3des_cbc_ovr_iv(void);
 void crypto_test_alg_hmac_md5(void);
+void crypto_test_alg_hmac_sha256(void);
 
 /* test arrays: */
 extern odp_testinfo_t crypto_suite[];
diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 05b6885..838edc4 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -295,6 +295,42 @@ void crypto_test_alg_hmac_md5(void)
}
 }
 
+/* This test verifies the correctness of HMAC_MD5 digest operation.
+ * The output check length is truncated to 12 bytes (96 bits) as
+ * returned by the crypto operation API call.
+ * Note that hash digest is a one-way operation.
+ * In addition the test verifies if the implementation can use the
+ * packet buffer as completion event buffer.
+ * */
+void crypto_test_alg_hmac_sha256(void)
+{
+   odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+auth_key   = { .data = NULL, .length = 0 };
+   odp_crypto_iv_t iv = { .data = NULL, .length = 0 };
+
+   unsigned int test_vec_num = (sizeof(hmac_sha256_reference_length) /
+sizeof(hmac_sha256_reference_length[0]));
+
+   unsigned int i;
+
+   for (i = 0; i < test_vec_num; i++) {
+   auth_key.data = hmac_sha256_reference_key[i];
+   auth_key.length = sizeof(hmac_sha256_reference_key[i]);
+
+   alg_test(ODP_CRYPTO_OP_ENCODE,
+ODP_CIPHER_ALG_NULL,
+iv,
+iv.data,
+cipher_key,
+ODP_AUTH_ALG_SHA256_128,
+auth_key,
+hmac_sha256_reference_plaintext[i],
+hmac_sha256_reference_length[i],
+hmac_sha256_reference_digest[i],
+HMAC_SHA256_128_CHECK_LEN);
+   }
+}
+
 int crypto_suite_sync_init(void)
 {
suite_context.pool = odp_pool_lookup("packet_pool");
@@ -325,5 +361,6 @@ odp_testinfo_t crypto_suite[] = {
ODP_TEST_INFO(crypto_test_enc_alg_3des_cbc_ovr_iv),
ODP_TEST_INFO(crypto_test_dec_alg_3des_cbc_ovr_iv),
ODP_TEST_INFO(crypto_test_alg_hmac_md5),
+   ODP_TEST_INFO(crypto_test_alg_hmac_sha256),
ODP_TEST_INFO_NULL,
 };
diff --git a/test/validation/crypto/test_vectors.h 
b/test/validation/crypto/test_vectors.h
index 490a3bc..09cf9c2 100644
--- a/test/validation/crypto/test_vectors.h
+++ b/test/validation/crypto/test_vectors.h
@@ -87,4 +87,48 @@ static uint8_t 
hmac_md5_reference_digest[][HMAC_MD5_DIGEST_LEN] = {
  0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 }
 };
 
+static uint8_t hmac_sha256_reference_key[][HMAC_SHA256_KEY_LEN] = {
+   { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b },
+
+   /* "Jefe" */
+   { 0x4a, 0x65, 0x66, 0x65 },
+
+   { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa }
+};
+
+static uint32_t hmac_sha256_reference_length[] = { 8, 28, 50 };
+
+static uint8_t
+hmac_sha256_reference_plaintext[][HMAC_SHA256_MAX_DATA_LEN] = {
+   /* "Hi There" */
+   { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+
+   /* what do ya want for nothing?*/
+   { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+
+   { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd }
+};
+
+static uint8_t hmac_sha256_reference_digest[][HMAC_SHA256_DIGEST_LEN] = {
+   { 0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53,
+ 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b },
+
+   { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
+ 0x6a, 0x04, 0

[lng-odp] [API-NEXTv2 2/4] api: crypto: add HMAC-SHA-256-128 support

2015-11-06 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 include/odp/api/crypto.h   |  2 +
 .../linux-generic/include/odp_crypto_internal.h|  4 +
 platform/linux-generic/odp_crypto.c| 89 ++
 3 files changed, 95 insertions(+)

diff --git a/include/odp/api/crypto.h b/include/odp/api/crypto.h
index cc204a1..579354d 100644
--- a/include/odp/api/crypto.h
+++ b/include/odp/api/crypto.h
@@ -78,6 +78,8 @@ typedef enum {
ODP_AUTH_ALG_NULL,
/** HMAC-MD5 with 96 bit key */
ODP_AUTH_ALG_MD5_96,
+   /** SHA256 with 128 bit key */
+   ODP_AUTH_ALG_SHA256_128,
 } odp_auth_alg_t;
 
 /**
diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index 23fec04..10bcfd4 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -56,6 +56,10 @@ struct odp_crypto_generic_session {
uint8_t  key[16];
uint32_t bytes;
} md5;
+   struct {
+   uint8_t  key[32];
+   uint32_t bytes;
+   } sha256;
} data;
crypto_func_t func;
} auth;
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index e3bc557..ed3d14c 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -140,6 +140,72 @@ 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_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint8_t *icv   = data;
+   uint32_t len   = params->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;
+
+   /* Hash it */
+   HMAC(EVP_sha256(),
+session->auth.data.sha256.key,
+32,
+data,
+len,
+hash,
+NULL);
+
+   /* Copy to the output location */
+   memcpy(icv, hash, session->auth.data.sha256.bytes);
+
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
+odp_crypto_alg_err_t sha256_check(odp_crypto_op_params_t *params,
+ odp_crypto_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint8_t *icv   = data;
+   uint32_t len   = params->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 += params->auth_range.offset;
+   icv  += params->hash_result_offset;
+
+   /* Copy current value out and clear it before authentication */
+   memset(hash_in, 0, sizeof(hash_in));
+   memcpy(hash_in, icv, bytes);
+   memset(icv, 0, bytes);
+   memset(hash_out, 0, sizeof(hash_out));
+
+   /* Hash it */
+   HMAC(EVP_sha256(),
+session->auth.data.sha256.key,
+32,
+data,
+len,
+hash_out,
+NULL);
+
+   /* Verify match */
+   if (0 != memcmp(hash_in, hash_out, bytes))
+   return ODP_CRYPTO_ALG_ERR_ICV_CHECK;
+
+   /* Matched */
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
 odp_crypto_alg_err_t des_encrypt(odp_crypto_op_params_t *params,
 odp_crypto_generic_session_t *session)
 {
@@ -261,6 +327,26 @@ int process_md5_params(odp_crypto_generic_session_t 
*session,
return 0;
 }
 
+static
+int process_sha256_params(odp_crypto_generic_session_t *session,
+ odp_crypto_session_params_t *params,
+ uint32_t bits)
+{
+   /* Set function */
+   if (ODP_CRYPTO_OP_ENCODE == params->op)
+   session->auth.func = sha256_gen;
+   else
+   session->auth.func = sha256_check;
+
+   /* Number of valid bytes */
+   session->auth.data.sha256.bytes = bits / 8;
+
+   /* Convert keys */
+   memcpy(session->auth.data.sha256.key, params->auth_key.data, 32);
+
+   return 0;
+}
+
 int
 odp_crypto_session_create(odp_crypto_session_params_t *params,
  odp_crypto_session_t *session_out,
@@ -323,6 +409,9 @@ odp_crypto_session_create(odp_crypto_session_params_t 
*params,
case ODP_AUTH_ALG_MD5_96:
rc = process_md5_params(session, params, 96);
break;
+   case ODP_AUTH_ALG_SHA256_128:
+   rc = process_sha2

[lng-odp] [API-NEXTv2 4/4] example: ipsec: add support for HMAC-SHA-256-128

2015-11-06 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 example/ipsec/odp_ipsec.c| 2 +-
 example/ipsec/odp_ipsec_misc.h   | 8 ++--
 example/ipsec/odp_ipsec_sa_db.c  | 4 
 example/ipsec/odp_ipsec_stream.c | 3 ++-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index e76e6eb..d784c31 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1554,7 +1554,7 @@ static void usage(char *progname)
   " -r, --route SubNet:Intf:NextHopMAC\n"
   " -p, --policy SrcSubNet:DstSubNet:(in|out):(ah|esp|both)\n"
   " -e, --esp SrcIP:DstIP:(3des|null):SPI:Key192\n"
-  " -a, --ah SrcIP:DstIP:(md5|null):SPI:Key128\n"
+  " -a, --ah SrcIP:DstIP:(sha256|md5|null):SPI:Key(256|128)\n"
   "\n"
   "  Where: NextHopMAC is raw hex/dot notation, i.e. 
03.BA.44.9A.CE.02\n"
   " IP is decimal/dot notation, i.e. 192.168.1.1\n"
diff --git a/example/ipsec/odp_ipsec_misc.h b/example/ipsec/odp_ipsec_misc.h
index 85c5f6a..e583c01 100644
--- a/example/ipsec/odp_ipsec_misc.h
+++ b/example/ipsec/odp_ipsec_misc.h
@@ -28,8 +28,9 @@ extern "C" {
 #define MAX_STRING  32   /**< maximum string length */
 #define MAX_IV_LEN  32   /**< Maximum IV length in bytes */
 
-#define KEY_BITS_3DES  192  /**< 3DES cipher key length in bits */
-#define KEY_BITS_MD5_96128  /**< MD5_96 auth key length in bits */
+#define KEY_BITS_3DES   192  /**< 3DES cipher key length in bits */
+#define KEY_BITS_MD5_96 128  /**< MD5_96 auth key length in bits */
+#define KEY_BITS_SHA256_128 256  /**< SHA256_128 auth key length in bits */
 
 /**< Number of bits represnted by a string of hexadecimal characters */
 #define KEY_STR_BITS(str) (4 * strlen(str))
@@ -102,6 +103,9 @@ int parse_key_string(char *keystring,
if ((alg->u.auth == ODP_AUTH_ALG_MD5_96) &&
(KEY_BITS_MD5_96 == key_bits_in))
key->length = key_bits_in / 8;
+   else if ((alg->u.auth == ODP_AUTH_ALG_SHA256_128) &&
+(KEY_BITS_SHA256_128 == key_bits_in))
+   key->length = key_bits_in / 8;
}
 
for (idx = 0; idx < key->length; idx++) {
diff --git a/example/ipsec/odp_ipsec_sa_db.c b/example/ipsec/odp_ipsec_sa_db.c
index 7967614..928c4cb 100644
--- a/example/ipsec/odp_ipsec_sa_db.c
+++ b/example/ipsec/odp_ipsec_sa_db.c
@@ -111,6 +111,10 @@ int create_sa_db_entry(char *input, odp_bool_t cipher)
entry->alg.u.auth =
ODP_AUTH_ALG_MD5_96;
entry->icv_len= 12;
+   } else if (!strcmp(token, "sha256")) {
+   entry->alg.u.auth =
+   ODP_AUTH_ALG_SHA256_128;
+   entry->icv_len= 16;
} else {
entry->alg.u.auth = ODP_AUTH_ALG_NULL;
}
diff --git a/example/ipsec/odp_ipsec_stream.c b/example/ipsec/odp_ipsec_stream.c
index 8a1cc56..f750e18 100644
--- a/example/ipsec/odp_ipsec_stream.c
+++ b/example/ipsec/odp_ipsec_stream.c
@@ -227,7 +227,8 @@ odp_packet_t create_ipv4_packet(stream_db_entry_t *stream,
/* AH (if specified) */
if (entry && (entry == stream->input.entry) &&
(ODP_AUTH_ALG_NULL != entry->ah.alg)) {
-   if (ODP_AUTH_ALG_MD5_96 != entry->ah.alg)
+   if (entry->ah.alg != ODP_AUTH_ALG_MD5_96 &&
+   entry->ah.alg != ODP_AUTH_ALG_SHA256_128)
abort();
 
ah = (odph_ahhdr_t *)data;
-- 
2.6.2.406.gaaaec35

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


Re: [lng-odp] [PATCHv2] linux-generic: check return codes in odp_pktio_term_global

2015-11-06 Thread Nicolas Morey-Chaisemartin
Reviewed-by: Nicolas Morey-Chaisemartin 

On 11/05/2015 04:58 PM, Maxim Uvarov wrote:
> According to API odp_pktio_close() can be called only for stopped
> pktio. So in odp_pktio_term_global try to stop it first then
> call close. Also check all returns codes.
> https://bugs.linaro.org/show_bug.cgi?id=1854
>
> Signed-off-by: Maxim Uvarov 
> ---
>  v2: lock pktio for stop and close in odp_pktio_term_global() (Nicolases note)
>
>  platform/linux-generic/odp_packet_io.c | 119 
> ++---
>  1 file changed, 79 insertions(+), 40 deletions(-)
>
> diff --git a/platform/linux-generic/odp_packet_io.c 
> b/platform/linux-generic/odp_packet_io.c
> index 1246bff..c3bc6a0 100644
> --- a/platform/linux-generic/odp_packet_io.c
> +++ b/platform/linux-generic/odp_packet_io.c
> @@ -84,33 +84,6 @@ int odp_pktio_init_global(void)
>   return 0;
>  }
>  
> -int odp_pktio_term_global(void)
> -{
> - pktio_entry_t *pktio_entry;
> - int ret = 0;
> - int id;
> - int pktio_if;
> -
> - for (id = 1; id <= ODP_CONFIG_PKTIO_ENTRIES; ++id) {
> - pktio_entry = &pktio_tbl->entries[id - 1];
> - odp_pktio_close(pktio_entry->s.handle);
> - odp_queue_destroy(pktio_entry->s.outq_default);
> - }
> -
> - for (pktio_if = 0; pktio_if_ops[pktio_if]; ++pktio_if) {
> - if (pktio_if_ops[pktio_if]->term)
> - if (pktio_if_ops[pktio_if]->term())
> - ODP_ERR("failed to terminate pktio type %d",
> - pktio_if);
> - }
> -
> - ret = odp_shm_free(odp_shm_lookup("odp_pktio_entries"));
> - if (ret < 0)
> - ODP_ERR("shm free failed for odp_pktio_entries");
> -
> - return ret;
> -}
> -
>  int odp_pktio_init_local(void)
>  {
>   return 0;
> @@ -284,10 +257,22 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_pool_t 
> pool,
>   return id;
>  }
>  
> +static int _pktio_close(pktio_entry_t *entry)
> +{
> + int ret;
> +
> + ret = entry->s.ops->close(entry);
> + if (ret)
> + return -1;
> +
> + set_free(entry);
> + return 0;
> +}
> +
>  int odp_pktio_close(odp_pktio_t id)
>  {
>   pktio_entry_t *entry;
> - int res = -1;
> + int res;
>  
>   entry = get_pktio_entry(id);
>   if (entry == NULL)
> @@ -295,14 +280,12 @@ int odp_pktio_close(odp_pktio_t id)
>  
>   lock_entry(entry);
>   if (!is_free(entry)) {
> - res = entry->s.ops->close(entry);
> - res |= free_pktio_entry(id);
> + res = _pktio_close(entry);
> + if (res)
> + ODP_ABORT("unable to close pktio\n");
>   }
>   unlock_entry(entry);
>  
> - if (res != 0)
> - return -1;
> -
>   return 0;
>  }
>  
> @@ -325,20 +308,29 @@ int odp_pktio_start(odp_pktio_t id)
>   return res;
>  }
>  
> -int odp_pktio_stop(odp_pktio_t id)
> +static int _pktio_stop(pktio_entry_t *entry)
>  {
> - pktio_entry_t *entry;
>   int res = 0;
>  
> - entry = get_pktio_entry(id);
> - if (!entry)
> - return -1;
> -
> - lock_entry(entry);
>   if (entry->s.ops->stop)
>   res = entry->s.ops->stop(entry);
>   if (!res)
>   entry->s.state = STATE_STOP;
> +
> + return res;
> +}
> +
> +int odp_pktio_stop(odp_pktio_t id)
> +{
> + pktio_entry_t *entry;
> + int res;
> +
> + entry = get_pktio_entry(id);
> + if (!entry)
> + return -1;
> +
> + lock_entry(entry);
> + res = _pktio_stop(entry);
>   unlock_entry(entry);
>  
>   return res;
> @@ -822,3 +814,50 @@ void odp_pktio_param_init(odp_pktio_param_t *params)
>  {
>   memset(params, 0, sizeof(odp_pktio_param_t));
>  }
> +
> +int odp_pktio_term_global(void)
> +{
> + int ret;
> + int id;
> + int pktio_if;
> +
> + for (id = 0; id < ODP_CONFIG_PKTIO_ENTRIES; ++id) {
> + pktio_entry_t *pktio_entry;
> +
> + pktio_entry = &pktio_tbl->entries[id];
> +
> + ret = odp_queue_destroy(pktio_entry->s.outq_default);
> + if (ret)
> + ODP_ABORT("unable to destroy outq %s\n",
> +   pktio_entry->s.name);
> +
> + if (is_free(pktio_entry))
> + continue;
> +
> + lock_entry(pktio_entry);
> + if (

Re: [lng-odp] [PATCHv2] linux-generic: check return codes in odp_pktio_term_global

2015-11-06 Thread Nicolas Morey-Chaisemartin
On a side note, what is the expected behavior when stopping a stopped interface 
or starting a started one?

On 11/05/2015 04:58 PM, Maxim Uvarov wrote:
> According to API odp_pktio_close() can be called only for stopped
> pktio. So in odp_pktio_term_global try to stop it first then
> call close. Also check all returns codes.
> https://bugs.linaro.org/show_bug.cgi?id=1854
>
> Signed-off-by: Maxim Uvarov 
> ---
>  v2: lock pktio for stop and close in odp_pktio_term_global() (Nicolases note)
>
>  platform/linux-generic/odp_packet_io.c | 119 
> ++---
>  1 file changed, 79 insertions(+), 40 deletions(-)
>
> diff --git a/platform/linux-generic/odp_packet_io.c 
> b/platform/linux-generic/odp_packet_io.c
> index 1246bff..c3bc6a0 100644
> --- a/platform/linux-generic/odp_packet_io.c
> +++ b/platform/linux-generic/odp_packet_io.c
> @@ -84,33 +84,6 @@ int odp_pktio_init_global(void)
>   return 0;
>  }
>  
> -int odp_pktio_term_global(void)
> -{
> - pktio_entry_t *pktio_entry;
> - int ret = 0;
> - int id;
> - int pktio_if;
> -
> - for (id = 1; id <= ODP_CONFIG_PKTIO_ENTRIES; ++id) {
> - pktio_entry = &pktio_tbl->entries[id - 1];
> - odp_pktio_close(pktio_entry->s.handle);
> - odp_queue_destroy(pktio_entry->s.outq_default);
> - }
> -
> - for (pktio_if = 0; pktio_if_ops[pktio_if]; ++pktio_if) {
> - if (pktio_if_ops[pktio_if]->term)
> - if (pktio_if_ops[pktio_if]->term())
> - ODP_ERR("failed to terminate pktio type %d",
> - pktio_if);
> - }
> -
> - ret = odp_shm_free(odp_shm_lookup("odp_pktio_entries"));
> - if (ret < 0)
> - ODP_ERR("shm free failed for odp_pktio_entries");
> -
> - return ret;
> -}
> -
>  int odp_pktio_init_local(void)
>  {
>   return 0;
> @@ -284,10 +257,22 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_pool_t 
> pool,
>   return id;
>  }
>  
> +static int _pktio_close(pktio_entry_t *entry)
> +{
> + int ret;
> +
> + ret = entry->s.ops->close(entry);
> + if (ret)
> + return -1;
> +
> + set_free(entry);
> + return 0;
> +}
> +
>  int odp_pktio_close(odp_pktio_t id)
>  {
>   pktio_entry_t *entry;
> - int res = -1;
> + int res;
>  
>   entry = get_pktio_entry(id);
>   if (entry == NULL)
> @@ -295,14 +280,12 @@ int odp_pktio_close(odp_pktio_t id)
>  
>   lock_entry(entry);
>   if (!is_free(entry)) {
> - res = entry->s.ops->close(entry);
> - res |= free_pktio_entry(id);
> + res = _pktio_close(entry);
> + if (res)
> + ODP_ABORT("unable to close pktio\n");
>   }
>   unlock_entry(entry);
>  
> - if (res != 0)
> - return -1;
> -
>   return 0;
>  }
>  
> @@ -325,20 +308,29 @@ int odp_pktio_start(odp_pktio_t id)
>   return res;
>  }
>  
> -int odp_pktio_stop(odp_pktio_t id)
> +static int _pktio_stop(pktio_entry_t *entry)
>  {
> - pktio_entry_t *entry;
>   int res = 0;
>  
> - entry = get_pktio_entry(id);
> - if (!entry)
> - return -1;
> -
> - lock_entry(entry);
>   if (entry->s.ops->stop)
>   res = entry->s.ops->stop(entry);
>   if (!res)
>   entry->s.state = STATE_STOP;
> +
> + return res;
> +}
> +
> +int odp_pktio_stop(odp_pktio_t id)
> +{
> + pktio_entry_t *entry;
> + int res;
> +
> + entry = get_pktio_entry(id);
> + if (!entry)
> + return -1;
> +
> + lock_entry(entry);
> + res = _pktio_stop(entry);
>   unlock_entry(entry);
>  
>   return res;
> @@ -822,3 +814,50 @@ void odp_pktio_param_init(odp_pktio_param_t *params)
>  {
>   memset(params, 0, sizeof(odp_pktio_param_t));
>  }
> +
> +int odp_pktio_term_global(void)
> +{
> + int ret;
> + int id;
> + int pktio_if;
> +
> + for (id = 0; id < ODP_CONFIG_PKTIO_ENTRIES; ++id) {
> + pktio_entry_t *pktio_entry;
> +
> + pktio_entry = &pktio_tbl->entries[id];
> +
> + ret = odp_queue_destroy(pktio_entry->s.outq_default);
> + if (ret)
> + ODP_ABORT("unable to destroy outq %s\n",
> +   pktio_entry->s.name);
> +
> + if (is_free(pktio_entry))
> + continue;
> +
> + lock_entry(pktio_entry);
> + if (pktio_entry->s.state != STATE_STOP) {
> + ret = _pktio_stop(pktio_entry);
> + if (ret)
> + ODP_ABORT("unable to stop pktio %s\n",
> +   pktio_entry->s.name);
> + }
> + ret = _pktio_close(pktio_entry);
> + if (ret)
> + ODP_ABORT("unable to close pktio %s\n",
> +   pktio_entry->s.name);
> + unlock_entry(pktio_entry);
> + }
>

Re: [lng-odp] [PATCHv2] linux-generic: check return codes in odp_pktio_term_global

2015-11-06 Thread Nicolas Morey-Chaisemartin
Ok. I have a patch series added check like for things like start when started, 
send when pktio is RONLY or config changes when pktio is started.
As soon as your patch go through, I'll rebase and post.

On 11/06/2015 09:51 AM, Maxim Uvarov wrote:
> On 11/06/2015 11:45, Nicolas Morey-Chaisemartin wrote:
>> On a side note, what is the expected behavior when stopping a stopped 
>> interface or starting a started one?
>
> Current api does not say anything about it except first sentence. I think we 
> should prevent double stop
> and double start and refine doc for it.
>
> /**
>  * Stop packet receive and transmit
>  *
>  * Stop packet receive and transmit on a previously started interface. New
>  * packets are not received from or transmitted to the network. Packets 
> already
>  * received from the network may be still available from interface and
>  * application can receive those normally. New packets may not be accepted for
>  * transmit. Packets already stored for transmit are not freed. A following
>  * odp_packet_start() call restarts packet receive and transmit.
>  *
>  * @param pktio  Packet IO handle
>  *
>  * @retval 0 on success
>  * @retval <0 on failure
>  *
>  * @see odp_pktio_start(), odp_pktio_close()
>  */
> int odp_pktio_stop(odp_pktio_t pktio);
>
>
>
> Maxim.
>
>> On 11/05/2015 04:58 PM, Maxim Uvarov wrote:
>>> According to API odp_pktio_close() can be called only for stopped
>>> pktio. So in odp_pktio_term_global try to stop it first then
>>> call close. Also check all returns codes.
>>> https://bugs.linaro.org/show_bug.cgi?id=1854
>>>
>>> Signed-off-by: Maxim Uvarov 
>>> ---
>>>   v2: lock pktio for stop and close in odp_pktio_term_global() (Nicolases 
>>> note)
>>>
>>>   platform/linux-generic/odp_packet_io.c | 119 
>>> ++---
>>>   1 file changed, 79 insertions(+), 40 deletions(-)
>>>
>>> diff --git a/platform/linux-generic/odp_packet_io.c 
>>> b/platform/linux-generic/odp_packet_io.c
>>> index 1246bff..c3bc6a0 100644
>>> --- a/platform/linux-generic/odp_packet_io.c
>>> +++ b/platform/linux-generic/odp_packet_io.c
>>> @@ -84,33 +84,6 @@ int odp_pktio_init_global(void)
>>>   return 0;
>>>   }
>>>   -int odp_pktio_term_global(void)
>>> -{
>>> -pktio_entry_t *pktio_entry;
>>> -int ret = 0;
>>> -int id;
>>> -int pktio_if;
>>> -
>>> -for (id = 1; id <= ODP_CONFIG_PKTIO_ENTRIES; ++id) {
>>> -pktio_entry = &pktio_tbl->entries[id - 1];
>>> -odp_pktio_close(pktio_entry->s.handle);
>>> -odp_queue_destroy(pktio_entry->s.outq_default);
>>> -}
>>> -
>>> -for (pktio_if = 0; pktio_if_ops[pktio_if]; ++pktio_if) {
>>> -if (pktio_if_ops[pktio_if]->term)
>>> -if (pktio_if_ops[pktio_if]->term())
>>> -ODP_ERR("failed to terminate pktio type %d",
>>> -pktio_if);
>>> -}
>>> -
>>> -ret = odp_shm_free(odp_shm_lookup("odp_pktio_entries"));
>>> -if (ret < 0)
>>> -ODP_ERR("shm free failed for odp_pktio_entries");
>>> -
>>> -return ret;
>>> -}
>>> -
>>>   int odp_pktio_init_local(void)
>>>   {
>>>   return 0;
>>> @@ -284,10 +257,22 @@ odp_pktio_t odp_pktio_open(const char *dev, 
>>> odp_pool_t pool,
>>>   return id;
>>>   }
>>>   +static int _pktio_close(pktio_entry_t *entry)
>>> +{
>>> +int ret;
>>> +
>>> +ret = entry->s.ops->close(entry);
>>> +if (ret)
>>> +return -1;
>>> +
>>> +set_free(entry);
>>> +return 0;
>>> +}
>>> +
>>>   int odp_pktio_close(odp_pktio_t id)
>>>   {
>>>   pktio_entry_t *entry;
>>> -int res = -1;
>>> +int res;
>>> entry = get_pktio_entry(id);
>>>   if (entry == NULL)
>>> @@ -295,14 +280,12 @@ int odp_pktio_close(odp_pktio_t id)
>>> lock_entry(entry);
>>>   if (!is_free(entry)) {
>>> -res = entry->s.ops->close(entry);
>>> -res |= free_pktio_entry(id);
>>> +res = _pktio_close(entry);
>>> +if (res)
>>> +ODP_ABORT("unable to close pktio\n");
>>>   }
>>>   unlo

Re: [lng-odp] [API-NEXT PATCHv2 2/6] linux-generic: queue: add utility functions for restructure

2015-11-09 Thread Nicolas Morey-Chaisemartin


On 11/08/2015 09:42 PM, Bill Fischofer wrote:
> Signed-off-by: Bill Fischofer 
> ---
>  .../linux-generic/include/odp_queue_internal.h | 44 
> ++
>  platform/linux-generic/odp_queue.c |  7 
>  2 files changed, 51 insertions(+)
>
> diff --git a/platform/linux-generic/include/odp_queue_internal.h 
> b/platform/linux-generic/include/odp_queue_internal.h
> index 6322948..32e3288 100644
> --- a/platform/linux-generic/include/odp_queue_internal.h
> +++ b/platform/linux-generic/include/odp_queue_internal.h
> @@ -159,6 +159,50 @@ static inline int queue_prio(queue_entry_t *qe)
>   return qe->s.param.sched.prio;
>  }
>  
> +static inline odp_buffer_hdr_t *get_buf_tail(odp_buffer_hdr_t *buf_hdr)
> +{
> + odp_buffer_hdr_t *buf_tail = buf_hdr->link ? buf_hdr->link : buf_hdr;
> +
> + buf_hdr->next = buf_hdr->link;
> + buf_hdr->link = NULL;
> +
> + while (buf_tail->next)
> + buf_tail = buf_tail->next;
> +
> + return buf_tail;
> +}
> +
I think this one should have a different name as it deals with a "chain" (using 
->link) and not the regular list the other one do (->next)
Maybe get_buf_chain_tail ?

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


Re: [lng-odp] [API-NEXT PATCHv2 3/6] linux-generic: queue: add ordered_queue_enq() routine - part 1

2015-11-09 Thread Nicolas Morey-Chaisemartin


On 11/08/2015 09:42 PM, Bill Fischofer wrote:
> Add the new ordered_queue_enq() internal routine. This is done in two
> parts to make the diffs easier to follow. Part 1 adds the new routine
> while Part 2 replaces queue_enq() to use it.
>
> Signed-off-by: Bill Fischofer 
> ---
>  .../linux-generic/include/odp_queue_internal.h |   2 +
>  platform/linux-generic/odp_queue.c | 118 
> +
>  2 files changed, 120 insertions(+)
>
> diff --git a/platform/linux-generic/include/odp_queue_internal.h 
> b/platform/linux-generic/include/odp_queue_internal.h
> index 32e3288..1bd365b 100644
> --- a/platform/linux-generic/include/odp_queue_internal.h
> +++ b/platform/linux-generic/include/odp_queue_internal.h
> @@ -96,6 +96,8 @@ union queue_entry_u {
>  queue_entry_t *get_qentry(uint32_t queue_id);
>  
>  int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr, int sustain);
> +int ordered_queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr,
> +   int systain, queue_entry_t *origin_qe, uint64_t order);
>  odp_buffer_hdr_t *queue_deq(queue_entry_t *queue);
>  
>  int queue_enq_internal(odp_buffer_hdr_t *buf_hdr);
> diff --git a/platform/linux-generic/odp_queue.c 
> b/platform/linux-generic/odp_queue.c
> index bcc8190..a545927 100644
> --- a/platform/linux-generic/odp_queue.c
> +++ b/platform/linux-generic/odp_queue.c
> @@ -529,6 +529,124 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t 
> *buf_hdr, int sustain)
>   return 0;
>  }
>  
> +int ordered_queue_enq(queue_entry_t *queue,
> +   odp_buffer_hdr_t *buf_hdr,
> +   int sustain,
> +   queue_entry_t *origin_qe,
> +   uint64_t order)
> +{
> + odp_buffer_hdr_t *reorder_buf;
> + odp_buffer_hdr_t *next_buf;
> + odp_buffer_hdr_t *reorder_prev;
> + odp_buffer_hdr_t *placeholder_buf = NULL;
> + int   release_count, placeholder_count;
> + int   sched = 0;
> +
> + /* Need two locks for enq operations from ordered queues */
> + get_qe_locks(origin_qe, queue);
> +
> + if (odp_unlikely(origin_qe->s.status < QUEUE_STATUS_READY ||
> +  queue->s.status < QUEUE_STATUS_READY)) {
> + free_qe_locks(queue, origin_qe);
> + ODP_ERR("Bad queue status\n");
> + ODP_ERR("queue = %s, origin q = %s, buf = %p\n",
> + queue->s.name, origin_qe->s.name, buf_hdr);
> + return -1;
> + }
> +
> + /* Remember that enq was called for this order */
> + sched_enq_called();
> +
> + /* We can only complete this enq if we're in order */
> + if (order > origin_qe->s.order_out) {
> + reorder_enq(queue, order, origin_qe, buf_hdr, sustain);
> +
> + /* This enq can't complete until order is restored, so
> +  * we're done here.
> +  */
> + free_qe_locks(queue, origin_qe);
> + return 0;
> + }
> +
> + /* Resolve order if requested */
> + if (!sustain) {
> + order_release(origin_qe, 1);
> + sched_order_resolved(buf_hdr);
> + }
> +
> + /* Update queue status */
> + if (queue->s.status == QUEUE_STATUS_NOTSCHED) {
> + queue->s.status = QUEUE_STATUS_SCHED;
> + sched = 1;
> + }
> +
> + /* We're in order, however the reorder queue may have other buffers
> +  * sharing this order on it and this buffer must not be enqueued ahead
> +  * of them. If the reorder queue is empty we can short-cut and
> +  * simply add to the target queue directly.
> +  */
> +
> + if (!origin_qe->s.reorder_head) {
> + queue_add_chain(queue, buf_hdr);
> + free_qe_locks(queue, origin_qe);
> +
> + /* Add queue to scheduling */
> + if (sched && schedule_queue(queue))
> + ODP_ABORT("schedule_queue failed\n");
> + return 0;
> + }
> +
> + /* The reorder_queue is non-empty, so sort this buffer into it.  Note
> +  * that we force the sustain bit on here because we'll be removing
> +  * this immediately and we already accounted for this order earlier.
> +  */
> + reorder_enq(queue, order, origin_qe, buf_hdr, 1);
> +
Do we really need this call?
When we reach this point in the code, buf_hdr is next inline to be queued, and 
what we want is pull out of the reorder queue the buffer that might be right 
after this one.
In this case we push buf_hdr to the reorder queue just to pull it back 
afterward. It works but I'm not sure this is completely necessary.
> + /* Pick up this element, and all others resolved by this enq,
> +  * and add them to the target queue.
> +  */
> + reorder_deq(queue, origin_qe, &reorder_buf, &reorder_prev,
> + &placeholder_buf, &release_count, &placeholder_count);
> +
> + /* Move the list from the reorder queue to the target queue */

Re: [lng-odp] [API-NEXT PATCHv2 3/6] linux-generic: queue: add ordered_queue_enq() routine - part 1

2015-11-09 Thread Nicolas Morey-Chaisemartin
You're right. In my mind order was linked to the buffer,not the thread meaning 
A would have enq b1 too.

On 11/09/2015 11:05 AM, Bill Fischofer wrote:
> It is necessary, and illustrates one of the complexities of ordered queuing.  
> Consider the following sequence with QOrigin having current order 4:
>
> Thread A (Order 4)Thread B (Order 5)
>  enq (Q, b1)
>
>enq(Q, a1)
>release_order()
>   enq(Q b2)
>
> Thread B enqueues first but since the QOrigin is at order 4 it's element goes 
> onto QOrigin's reorder queue.  Thread A now enqueues and resolves order 4.  
> Thread B now tries to enqueue another element onto Q and this time it has the 
> current order, however element b2 needs to follow element b1, which is on the 
> reorder queue.  The reorder_enq() routine sorts elements into the reorder 
> queue so that b2 correctly follows any other elements sharing the same order 
> before they are all moved to the target queue.
>
> On Mon, Nov 9, 2015 at 3:54 AM, Nicolas Morey-Chaisemartin  <mailto:nmo...@kalray.eu>> wrote:
>
>
>
> On 11/08/2015 09:42 PM, Bill Fischofer wrote:
> > Add the new ordered_queue_enq() internal routine. This is done in two
> > parts to make the diffs easier to follow. Part 1 adds the new routine
> > while Part 2 replaces queue_enq() to use it.
> >
> > Signed-off-by: Bill Fischofer  <mailto:bill.fischo...@linaro.org>>
> > ---
> >  .../linux-generic/include/odp_queue_internal.h |   2 +
> >  platform/linux-generic/odp_queue.c | 118 
> +
> >  2 files changed, 120 insertions(+)
> >
> > diff --git a/platform/linux-generic/include/odp_queue_internal.h 
> b/platform/linux-generic/include/odp_queue_internal.h
> > index 32e3288..1bd365b 100644
> > --- a/platform/linux-generic/include/odp_queue_internal.h
> > +++ b/platform/linux-generic/include/odp_queue_internal.h
> > @@ -96,6 +96,8 @@ union queue_entry_u {
> >  queue_entry_t *get_qentry(uint32_t queue_id);
> >
> >  int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr, int 
> sustain);
> > +int ordered_queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr,
> > +   int systain, queue_entry_t *origin_qe, uint64_t 
> order);
> >  odp_buffer_hdr_t *queue_deq(queue_entry_t *queue);
> >
> >  int queue_enq_internal(odp_buffer_hdr_t *buf_hdr);
> > diff --git a/platform/linux-generic/odp_queue.c 
> b/platform/linux-generic/odp_queue.c
> > index bcc8190..a545927 100644
> > --- a/platform/linux-generic/odp_queue.c
> > +++ b/platform/linux-generic/odp_queue.c
> > @@ -529,6 +529,124 @@ int queue_enq(queue_entry_t *queue, 
> odp_buffer_hdr_t *buf_hdr, int sustain)
> >   return 0;
> >  }
> >
> > +int ordered_queue_enq(queue_entry_t *queue,
> > +   odp_buffer_hdr_t *buf_hdr,
> > +   int sustain,
> > +   queue_entry_t *origin_qe,
> > +   uint64_t order)
> > +{
> > + odp_buffer_hdr_t *reorder_buf;
> > + odp_buffer_hdr_t *next_buf;
> > + odp_buffer_hdr_t *reorder_prev;
> > + odp_buffer_hdr_t *placeholder_buf = NULL;
> > + int   release_count, placeholder_count;
> > + int   sched = 0;
> > +
> > + /* Need two locks for enq operations from ordered queues */
> > + get_qe_locks(origin_qe, queue);
> > +
> > + if (odp_unlikely(origin_qe->s.status < QUEUE_STATUS_READY ||
> > +  queue->s.status < QUEUE_STATUS_READY)) {
> > + free_qe_locks(queue, origin_qe);
> > + ODP_ERR("Bad queue status\n");
> > + ODP_ERR("queue = %s, origin q = %s, buf = %p\n",
> > + queue->s.name <http://s.name>, origin_qe->s.name 
> <http://s.name>, buf_hdr);
> > + return -1;
> > + }
> > +
> > + /* Remember that enq was called for this order */
> > + sched_enq_called();
> > +
> > + /* We can only complete this enq if we're in order */
> > + if (order > origin_qe->s.order_out) {
> > + reorder_enq(queue, order, origin_qe, buf_hdr, sustain);
> > +
&

[lng-odp] [API-NEXT PATCH v3 0/6] Add HMAC-SHA-256-128 and AES128 CBC support

2015-11-09 Thread Nicolas Morey-Chaisemartin
The first patch is a cleanup suggested by Petri.
All the crypto enums are moved from linux-generic back to ODP API, and renamed 
(odp__t)
Following patches add support for the new HMAC function, then a validation test 
and finally support in odp-ipsec
And then same things for AES128

v3:
 * correct patch name
 * add AES128 CBC support
v2:
 * Correct test vectors to match the ones from RFC4868

Jerome Reybert (1):
  crypto: add AES128-CBC encrypt/decrypt methods

Nicolas Morey-Chaisemartin (5):
  api: crypto: move enums from platform types to odp and rename to fit
the API format
  api: crypto: add HMAC-SHA-256-128 support
  validation: crypto: add test for HMAC-SHA-256-128
  example: ipsec: add support for HMAC-SHA-256-128
  validation: crypto: add test for AES128 CBC

 example/ipsec/odp_ipsec.c  |   2 +-
 example/ipsec/odp_ipsec_cache.c|   2 +-
 example/ipsec/odp_ipsec_cache.h|   4 +-
 example/ipsec/odp_ipsec_misc.h |  12 +-
 example/ipsec/odp_ipsec_sa_db.c|   4 +
 example/ipsec/odp_ipsec_stream.c   |   3 +-
 include/odp/api/crypto.h   | 144 +++
 .../linux-generic/include/odp/plat/crypto_types.h  |  42 -
 .../linux-generic/include/odp_crypto_internal.h|  20 +-
 platform/linux-generic/odp_crypto.c| 205 +++--
 test/validation/crypto/crypto.h|   5 +
 test/validation/crypto/odp_crypto_test_inp.c   | 182 +-
 test/validation/crypto/test_vectors.h  | 111 +++
 test/validation/crypto/test_vectors_len.h  |  10 +
 14 files changed, 592 insertions(+), 154 deletions(-)

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


[lng-odp] [API-NEXT PATCH v3 1/6] api: crypto: move enums from platform types to odp and rename to fit the API format

2015-11-09 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 example/ipsec/odp_ipsec_cache.c|   2 +-
 example/ipsec/odp_ipsec_cache.h|   4 +-
 example/ipsec/odp_ipsec_misc.h |   4 +-
 include/odp/api/crypto.h   | 140 ++---
 .../linux-generic/include/odp/plat/crypto_types.h  |  42 ---
 .../linux-generic/include/odp_crypto_internal.h|  12 +-
 platform/linux-generic/odp_crypto.c|  29 +++--
 test/validation/crypto/odp_crypto_test_inp.c   |  10 +-
 8 files changed, 93 insertions(+), 150 deletions(-)

diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c
index 6a8f3c9..0883d4d 100644
--- a/example/ipsec/odp_ipsec_cache.c
+++ b/example/ipsec/odp_ipsec_cache.c
@@ -46,7 +46,7 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,
 {
odp_crypto_session_params_t params;
ipsec_cache_entry_t *entry;
-   enum odp_crypto_ses_create_err ses_create_rc;
+   odp_crypto_ses_create_err_t ses_create_rc;
odp_crypto_session_t session;
sa_mode_t mode = IPSEC_SA_MODE_TRANSPORT;
 
diff --git a/example/ipsec/odp_ipsec_cache.h b/example/ipsec/odp_ipsec_cache.h
index 5706007..91d9d7e 100644
--- a/example/ipsec/odp_ipsec_cache.h
+++ b/example/ipsec/odp_ipsec_cache.h
@@ -38,14 +38,14 @@ typedef struct ipsec_cache_entry_s {
uint32_t tun_src_ip;  /**< Tunnel src IPv4 addr */
uint32_t tun_dst_ip;  /**< Tunnel dst IPv4 addr */
struct {
-   enum  odp_cipher_alg alg; /**< Cipher algorithm */
+   odp_cipher_alg_t alg; /**< Cipher algorithm */
uint32_t spi; /**< Cipher SPI */
uint32_t block_len;   /**< Cipher block length */
uint32_t iv_len;  /**< Cipher IV length */
ipsec_key_t  key; /**< Cipher key */
} esp;
struct {
-   enum  odp_auth_alg   alg; /**< Auth algorithm */
+   odp_auth_alg_t   alg; /**< Auth algorithm */
uint32_t spi; /**< Auth SPI */
uint32_t icv_len; /**< Auth ICV length */
ipsec_key_t  key; /**< Auth key */
diff --git a/example/ipsec/odp_ipsec_misc.h b/example/ipsec/odp_ipsec_misc.h
index f6a12b5..85c5f6a 100644
--- a/example/ipsec/odp_ipsec_misc.h
+++ b/example/ipsec/odp_ipsec_misc.h
@@ -59,8 +59,8 @@ typedef struct {
 typedef struct {
odp_bool_t cipher;
union {
-   enum odp_cipher_alg cipher;
-   enum odp_auth_alg   auth;
+   odp_cipher_alg_t cipher;
+   odp_auth_alg_t   auth;
} u;
 } ipsec_alg_t;
 
diff --git a/include/odp/api/crypto.h b/include/odp/api/crypto.h
index a9a2a1d..cc204a1 100644
--- a/include/odp/api/crypto.h
+++ b/include/odp/api/crypto.h
@@ -39,51 +39,46 @@ extern "C" {
 */
 
 /**
- * @enum odp_crypto_op_mode
  * Crypto API operation mode
- *
- * @enum odp_crypto_op_mode:ODP_CRYPTO_SYNC
- * Synchronous, return results immediately
- *
- * @enum odp_crypto_op_mode:ODP_CRYPTO_ASYNC
- * Aynchronous, return results via posted event
  */
+typedef enum {
+   /** Synchronous, return results immediately */
+   ODP_CRYPTO_SYNC,
+   /** Aynchronous, return results via posted event */
+   ODP_CRYPTO_ASYNC,
+} odp_crypto_op_mode_t;
 
 /**
- * @enum odp_crypto_op
  * Crypto API operation type
- *
- * @enum odp_crypto_op:ODP_CRYPTO_OP_ENCODE
- * Encrypt and/or compute authentication ICV
- *
- * @enum odp_crypto_op:ODP_CRYPTO_OP_DECODE
- * Decrypt and/or verify authentication ICV
  */
+typedef enum {
+   /** Encrypt and/or compute authentication ICV */
+   ODP_CRYPTO_OP_ENCODE,
+   /** Decrypt and/or verify authentication ICV */
+   ODP_CRYPTO_OP_DECODE,
+} odp_crypto_op_t;
 
 /**
- * @enum odp_cipher_alg
  * Crypto API cipher algorithm
- *
- * @enum odp_cipher_alg:ODP_CIPHER_ALG_NULL
- * No cipher algorithm specified
- *
- * @enum odp_cipher_alg:ODP_CIPHER_ALG_DES
- * DES
- *
- * @enum odp_cipher_alg:ODP_CIPHER_ALG_3DES_CBC
- * Triple DES with cipher block chaining
  */
+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,
+} odp_cipher_alg_t;
 
 /**
- * @enum odp_auth_alg
  * Crypto API authentication algorithm
- *
- * @enum odp_auth_alg:ODP_AUTH_ALG_NULL
- * No authentication algorithm specified
- *
- * @enum odp_auth_alg:ODP_AUTH_ALG_MD5_96
- * HMAC-MD5 with 96 bit key
  */
+typedef enum {
+/** No authentication algorithm specified */
+   ODP_AUTH_ALG_NULL,
+   /** HMAC-MD5 with 96 bit key */
+   ODP_AUTH_ALG_MD5

[lng-odp] [API-NEXT PATCH v3 2/6] api: crypto: add HMAC-SHA-256-128 support

2015-11-09 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 include/odp/api/crypto.h   |  2 +
 .../linux-generic/include/odp_crypto_internal.h|  4 +
 platform/linux-generic/odp_crypto.c| 89 ++
 3 files changed, 95 insertions(+)

diff --git a/include/odp/api/crypto.h b/include/odp/api/crypto.h
index cc204a1..579354d 100644
--- a/include/odp/api/crypto.h
+++ b/include/odp/api/crypto.h
@@ -78,6 +78,8 @@ typedef enum {
ODP_AUTH_ALG_NULL,
/** HMAC-MD5 with 96 bit key */
ODP_AUTH_ALG_MD5_96,
+   /** SHA256 with 128 bit key */
+   ODP_AUTH_ALG_SHA256_128,
 } odp_auth_alg_t;
 
 /**
diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index 23fec04..10bcfd4 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -56,6 +56,10 @@ struct odp_crypto_generic_session {
uint8_t  key[16];
uint32_t bytes;
} md5;
+   struct {
+   uint8_t  key[32];
+   uint32_t bytes;
+   } sha256;
} data;
crypto_func_t func;
} auth;
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index e3bc557..ed3d14c 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -140,6 +140,72 @@ 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_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint8_t *icv   = data;
+   uint32_t len   = params->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;
+
+   /* Hash it */
+   HMAC(EVP_sha256(),
+session->auth.data.sha256.key,
+32,
+data,
+len,
+hash,
+NULL);
+
+   /* Copy to the output location */
+   memcpy(icv, hash, session->auth.data.sha256.bytes);
+
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
+odp_crypto_alg_err_t sha256_check(odp_crypto_op_params_t *params,
+ odp_crypto_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint8_t *icv   = data;
+   uint32_t len   = params->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 += params->auth_range.offset;
+   icv  += params->hash_result_offset;
+
+   /* Copy current value out and clear it before authentication */
+   memset(hash_in, 0, sizeof(hash_in));
+   memcpy(hash_in, icv, bytes);
+   memset(icv, 0, bytes);
+   memset(hash_out, 0, sizeof(hash_out));
+
+   /* Hash it */
+   HMAC(EVP_sha256(),
+session->auth.data.sha256.key,
+32,
+data,
+len,
+hash_out,
+NULL);
+
+   /* Verify match */
+   if (0 != memcmp(hash_in, hash_out, bytes))
+   return ODP_CRYPTO_ALG_ERR_ICV_CHECK;
+
+   /* Matched */
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
 odp_crypto_alg_err_t des_encrypt(odp_crypto_op_params_t *params,
 odp_crypto_generic_session_t *session)
 {
@@ -261,6 +327,26 @@ int process_md5_params(odp_crypto_generic_session_t 
*session,
return 0;
 }
 
+static
+int process_sha256_params(odp_crypto_generic_session_t *session,
+ odp_crypto_session_params_t *params,
+ uint32_t bits)
+{
+   /* Set function */
+   if (ODP_CRYPTO_OP_ENCODE == params->op)
+   session->auth.func = sha256_gen;
+   else
+   session->auth.func = sha256_check;
+
+   /* Number of valid bytes */
+   session->auth.data.sha256.bytes = bits / 8;
+
+   /* Convert keys */
+   memcpy(session->auth.data.sha256.key, params->auth_key.data, 32);
+
+   return 0;
+}
+
 int
 odp_crypto_session_create(odp_crypto_session_params_t *params,
  odp_crypto_session_t *session_out,
@@ -323,6 +409,9 @@ odp_crypto_session_create(odp_crypto_session_params_t 
*params,
case ODP_AUTH_ALG_MD5_96:
rc = process_md5_params(session, params, 96);
break;
+   case ODP_AUTH_ALG_SHA256_128:
+   rc = process_sha2

[lng-odp] [API-NEXT PATCH v3 3/6] validation: crypto: add test for HMAC-SHA-256-128

2015-11-09 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/crypto.h  |  1 +
 test/validation/crypto/odp_crypto_test_inp.c | 37 +++
 test/validation/crypto/test_vectors.h| 44 
 test/validation/crypto/test_vectors_len.h|  6 
 4 files changed, 88 insertions(+)

diff --git a/test/validation/crypto/crypto.h b/test/validation/crypto/crypto.h
index 7cb60d4..fe23e04 100644
--- a/test/validation/crypto/crypto.h
+++ b/test/validation/crypto/crypto.h
@@ -15,6 +15,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void);
 void crypto_test_dec_alg_3des_cbc(void);
 void crypto_test_dec_alg_3des_cbc_ovr_iv(void);
 void crypto_test_alg_hmac_md5(void);
+void crypto_test_alg_hmac_sha256(void);
 
 /* test arrays: */
 extern odp_testinfo_t crypto_suite[];
diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 05b6885..838edc4 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -295,6 +295,42 @@ void crypto_test_alg_hmac_md5(void)
}
 }
 
+/* This test verifies the correctness of HMAC_MD5 digest operation.
+ * The output check length is truncated to 12 bytes (96 bits) as
+ * returned by the crypto operation API call.
+ * Note that hash digest is a one-way operation.
+ * In addition the test verifies if the implementation can use the
+ * packet buffer as completion event buffer.
+ * */
+void crypto_test_alg_hmac_sha256(void)
+{
+   odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+auth_key   = { .data = NULL, .length = 0 };
+   odp_crypto_iv_t iv = { .data = NULL, .length = 0 };
+
+   unsigned int test_vec_num = (sizeof(hmac_sha256_reference_length) /
+sizeof(hmac_sha256_reference_length[0]));
+
+   unsigned int i;
+
+   for (i = 0; i < test_vec_num; i++) {
+   auth_key.data = hmac_sha256_reference_key[i];
+   auth_key.length = sizeof(hmac_sha256_reference_key[i]);
+
+   alg_test(ODP_CRYPTO_OP_ENCODE,
+ODP_CIPHER_ALG_NULL,
+iv,
+iv.data,
+cipher_key,
+ODP_AUTH_ALG_SHA256_128,
+auth_key,
+hmac_sha256_reference_plaintext[i],
+hmac_sha256_reference_length[i],
+hmac_sha256_reference_digest[i],
+HMAC_SHA256_128_CHECK_LEN);
+   }
+}
+
 int crypto_suite_sync_init(void)
 {
suite_context.pool = odp_pool_lookup("packet_pool");
@@ -325,5 +361,6 @@ odp_testinfo_t crypto_suite[] = {
ODP_TEST_INFO(crypto_test_enc_alg_3des_cbc_ovr_iv),
ODP_TEST_INFO(crypto_test_dec_alg_3des_cbc_ovr_iv),
ODP_TEST_INFO(crypto_test_alg_hmac_md5),
+   ODP_TEST_INFO(crypto_test_alg_hmac_sha256),
ODP_TEST_INFO_NULL,
 };
diff --git a/test/validation/crypto/test_vectors.h 
b/test/validation/crypto/test_vectors.h
index 490a3bc..09cf9c2 100644
--- a/test/validation/crypto/test_vectors.h
+++ b/test/validation/crypto/test_vectors.h
@@ -87,4 +87,48 @@ static uint8_t 
hmac_md5_reference_digest[][HMAC_MD5_DIGEST_LEN] = {
  0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 }
 };
 
+static uint8_t hmac_sha256_reference_key[][HMAC_SHA256_KEY_LEN] = {
+   { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b },
+
+   /* "Jefe" */
+   { 0x4a, 0x65, 0x66, 0x65 },
+
+   { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa }
+};
+
+static uint32_t hmac_sha256_reference_length[] = { 8, 28, 50 };
+
+static uint8_t
+hmac_sha256_reference_plaintext[][HMAC_SHA256_MAX_DATA_LEN] = {
+   /* "Hi There" */
+   { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+
+   /* what do ya want for nothing?*/
+   { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+
+   { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd }
+};
+
+static uint8_t hmac_sha256_reference_digest[][HMAC_SHA256_DIGEST_LEN] = {
+   { 0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53,
+ 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b },
+
+   { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
+ 0x6a, 0x04, 0

[lng-odp] [API-NEXT PATCH v3 4/6] example: ipsec: add support for HMAC-SHA-256-128

2015-11-09 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 example/ipsec/odp_ipsec.c| 2 +-
 example/ipsec/odp_ipsec_misc.h   | 8 ++--
 example/ipsec/odp_ipsec_sa_db.c  | 4 
 example/ipsec/odp_ipsec_stream.c | 3 ++-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index e76e6eb..d784c31 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1554,7 +1554,7 @@ static void usage(char *progname)
   " -r, --route SubNet:Intf:NextHopMAC\n"
   " -p, --policy SrcSubNet:DstSubNet:(in|out):(ah|esp|both)\n"
   " -e, --esp SrcIP:DstIP:(3des|null):SPI:Key192\n"
-  " -a, --ah SrcIP:DstIP:(md5|null):SPI:Key128\n"
+  " -a, --ah SrcIP:DstIP:(sha256|md5|null):SPI:Key(256|128)\n"
   "\n"
   "  Where: NextHopMAC is raw hex/dot notation, i.e. 
03.BA.44.9A.CE.02\n"
   " IP is decimal/dot notation, i.e. 192.168.1.1\n"
diff --git a/example/ipsec/odp_ipsec_misc.h b/example/ipsec/odp_ipsec_misc.h
index 85c5f6a..e583c01 100644
--- a/example/ipsec/odp_ipsec_misc.h
+++ b/example/ipsec/odp_ipsec_misc.h
@@ -28,8 +28,9 @@ extern "C" {
 #define MAX_STRING  32   /**< maximum string length */
 #define MAX_IV_LEN  32   /**< Maximum IV length in bytes */
 
-#define KEY_BITS_3DES  192  /**< 3DES cipher key length in bits */
-#define KEY_BITS_MD5_96128  /**< MD5_96 auth key length in bits */
+#define KEY_BITS_3DES   192  /**< 3DES cipher key length in bits */
+#define KEY_BITS_MD5_96 128  /**< MD5_96 auth key length in bits */
+#define KEY_BITS_SHA256_128 256  /**< SHA256_128 auth key length in bits */
 
 /**< Number of bits represnted by a string of hexadecimal characters */
 #define KEY_STR_BITS(str) (4 * strlen(str))
@@ -102,6 +103,9 @@ int parse_key_string(char *keystring,
if ((alg->u.auth == ODP_AUTH_ALG_MD5_96) &&
(KEY_BITS_MD5_96 == key_bits_in))
key->length = key_bits_in / 8;
+   else if ((alg->u.auth == ODP_AUTH_ALG_SHA256_128) &&
+(KEY_BITS_SHA256_128 == key_bits_in))
+   key->length = key_bits_in / 8;
}
 
for (idx = 0; idx < key->length; idx++) {
diff --git a/example/ipsec/odp_ipsec_sa_db.c b/example/ipsec/odp_ipsec_sa_db.c
index 7967614..928c4cb 100644
--- a/example/ipsec/odp_ipsec_sa_db.c
+++ b/example/ipsec/odp_ipsec_sa_db.c
@@ -111,6 +111,10 @@ int create_sa_db_entry(char *input, odp_bool_t cipher)
entry->alg.u.auth =
ODP_AUTH_ALG_MD5_96;
entry->icv_len= 12;
+   } else if (!strcmp(token, "sha256")) {
+   entry->alg.u.auth =
+   ODP_AUTH_ALG_SHA256_128;
+   entry->icv_len= 16;
} else {
entry->alg.u.auth = ODP_AUTH_ALG_NULL;
}
diff --git a/example/ipsec/odp_ipsec_stream.c b/example/ipsec/odp_ipsec_stream.c
index 8a1cc56..f750e18 100644
--- a/example/ipsec/odp_ipsec_stream.c
+++ b/example/ipsec/odp_ipsec_stream.c
@@ -227,7 +227,8 @@ odp_packet_t create_ipv4_packet(stream_db_entry_t *stream,
/* AH (if specified) */
if (entry && (entry == stream->input.entry) &&
(ODP_AUTH_ALG_NULL != entry->ah.alg)) {
-   if (ODP_AUTH_ALG_MD5_96 != entry->ah.alg)
+   if (entry->ah.alg != ODP_AUTH_ALG_MD5_96 &&
+   entry->ah.alg != ODP_AUTH_ALG_SHA256_128)
abort();
 
ah = (odph_ahhdr_t *)data;
-- 
2.6.2.406.gaaaec35


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


[lng-odp] [API-NEXT PATCH v3 5/6] crypto: add AES128-CBC encrypt/decrypt methods

2015-11-09 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 include/odp/api/crypto.h   |  2 +
 .../linux-generic/include/odp_crypto_internal.h|  4 +
 platform/linux-generic/odp_crypto.c| 89 ++
 3 files changed, 95 insertions(+)

diff --git a/include/odp/api/crypto.h b/include/odp/api/crypto.h
index 579354d..de0afcb 100644
--- a/include/odp/api/crypto.h
+++ b/include/odp/api/crypto.h
@@ -68,6 +68,8 @@ typedef enum {
ODP_CIPHER_ALG_DES,
/** Triple DES with cipher block chaining */
ODP_CIPHER_ALG_3DES_CBC,
+   /** AES128 with cipher block chaining */
+   ODP_CIPHER_ALG_AES128_CBC,
 } odp_cipher_alg_t;
 
 /**
diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index 10bcfd4..b9128a4 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -12,6 +12,7 @@ extern "C" {
 #endif
 
 #include 
+#include 
 
 #define OP_RESULT_MAGIC 0x91919191
 
@@ -46,6 +47,9 @@ struct odp_crypto_generic_session {
DES_key_schedule ks2;
DES_key_schedule ks3;
} des;
+   struct {
+   AES_KEY key;
+   } aes;
} data;
crypto_func_t func;
} cipher;
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index ed3d14c..17fced9 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -206,6 +206,92 @@ odp_crypto_alg_err_t sha256_check(odp_crypto_op_params_t 
*params,
 }
 
 static
+odp_crypto_alg_err_t aes_encrypt(odp_crypto_op_params_t *params,
+odp_crypto_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint32_t len   = params->cipher_range.length;
+   unsigned char iv_enc[AES_BLOCK_SIZE];
+   void *iv_ptr;
+
+   if (params->override_iv_ptr)
+   iv_ptr = params->override_iv_ptr;
+   else if (session->cipher.iv.data)
+   iv_ptr = session->cipher.iv.data;
+   else
+   return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+
+   /*
+* Create a copy of the IV.  The DES library modifies IV
+* and if we are processing packets on parallel threads
+* we could get corruption.
+*/
+   memcpy(iv_enc, iv_ptr, AES_BLOCK_SIZE);
+
+   /* Adjust pointer for beginning of area to cipher */
+   data += params->cipher_range.offset;
+   /* Encrypt it */
+   AES_cbc_encrypt(data, data, len, &session->cipher.data.aes.key,
+   iv_enc, AES_ENCRYPT);
+
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
+odp_crypto_alg_err_t aes_decrypt(odp_crypto_op_params_t *params,
+odp_crypto_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint32_t len   = params->cipher_range.length;
+   unsigned char iv_enc[AES_BLOCK_SIZE];
+   void *iv_ptr;
+
+   if (params->override_iv_ptr)
+   iv_ptr = params->override_iv_ptr;
+   else if (session->cipher.iv.data)
+   iv_ptr = session->cipher.iv.data;
+   else
+   return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+
+   /*
+* Create a copy of the IV.  The DES library modifies IV
+* and if we are processing packets on parallel threads
+* we could get corruption.
+*/
+   memcpy(iv_enc, iv_ptr, AES_BLOCK_SIZE);
+
+   /* Adjust pointer for beginning of area to cipher */
+   data += params->cipher_range.offset;
+   /* Encrypt it */
+   AES_cbc_encrypt(data, data, len, &session->cipher.data.aes.key,
+   iv_enc, AES_DECRYPT);
+
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
+int process_aes_params(odp_crypto_generic_session_t *session,
+  odp_crypto_session_params_t *params)
+{
+   /* Verify IV len is either 0 or 16 */
+   if (!((0 == params->iv.length) || (16 == params->iv.length)))
+   return -1;
+
+   /* Set function */
+   if (ODP_CRYPTO_OP_ENCODE == params->op) {
+   session->cipher.func = aes_encrypt;
+   AES_set_encrypt_key(params->cipher_key.data, 128,
+   &session->cipher.data.aes.key);
+   } else {
+   session->cipher.func = aes_decrypt;
+   AES_set_decrypt_key(params->cipher_key.data, 128,
+   &session->cipher.data.aes.key);
+   }
+
+   return 0;
+}
+
+static
 odp_crypto_alg_err_t des_encrypt(odp_crypto_op_params_t *params,
 odp_crypto_generic_session_t *session

[lng-odp] [API-NEXT PATCH v3 6/6] validation: crypto: add test for AES128 CBC

2015-11-09 Thread Nicolas Morey-Chaisemartin
Test reference vectors from RFC3602

Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/crypto.h  |   4 +
 test/validation/crypto/odp_crypto_test_inp.c | 135 ++-
 test/validation/crypto/test_vectors.h|  67 +
 test/validation/crypto/test_vectors_len.h|   4 +
 4 files changed, 209 insertions(+), 1 deletion(-)

diff --git a/test/validation/crypto/crypto.h b/test/validation/crypto/crypto.h
index fe23e04..4769fad 100644
--- a/test/validation/crypto/crypto.h
+++ b/test/validation/crypto/crypto.h
@@ -14,6 +14,10 @@ void crypto_test_enc_alg_3des_cbc(void);
 void crypto_test_enc_alg_3des_cbc_ovr_iv(void);
 void crypto_test_dec_alg_3des_cbc(void);
 void crypto_test_dec_alg_3des_cbc_ovr_iv(void);
+void crypto_test_enc_alg_aes128_cbc(void);
+void crypto_test_enc_alg_aes128_cbc_ovr_iv(void);
+void crypto_test_dec_alg_aes128_cbc(void);
+void crypto_test_dec_alg_aes128_cbc_ovr_iv(void);
 void crypto_test_alg_hmac_md5(void);
 void crypto_test_alg_hmac_sha256(void);
 
diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 838edc4..5295c63 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -63,7 +63,7 @@ static void alg_test(odp_crypto_op_t op,
ses_params.auth_key = auth_key;
 
rc = odp_crypto_session_create(&ses_params, &session, &status);
-   CU_ASSERT(!rc);
+   CU_ASSERT_FATAL(!rc);
CU_ASSERT(status == ODP_CRYPTO_SES_CREATE_ERR_NONE);
CU_ASSERT(odp_crypto_session_to_u64(session) !=
  odp_crypto_session_to_u64(ODP_CRYPTO_SESSION_INVALID));
@@ -259,6 +259,135 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void)
}
 }
 
+/* This test verifies the correctness of encode (plaintext -> ciphertext)
+ * operation for AES128_CBC algorithm. IV for the operation is the session IV.
+ * In addition the test verifies if the implementation can use the
+ * packet buffer as completion event buffer.*/
+void crypto_test_enc_alg_aes128_cbc(void)
+{
+   odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+auth_key   = { .data = NULL, .length = 0 };
+   odp_crypto_iv_t iv;
+   unsigned int test_vec_num = (sizeof(aes128_cbc_reference_length) /
+sizeof(aes128_cbc_reference_length[0]));
+   unsigned int i;
+
+   for (i = 0; i < test_vec_num; i++) {
+   cipher_key.data = aes128_cbc_reference_key[i];
+   cipher_key.length = sizeof(aes128_cbc_reference_key[i]);
+   iv.data = aes128_cbc_reference_iv[i];
+   iv.length = sizeof(aes128_cbc_reference_iv[i]);
+
+   alg_test(ODP_CRYPTO_OP_ENCODE,
+ODP_CIPHER_ALG_AES128_CBC,
+iv,
+NULL,
+cipher_key,
+ODP_AUTH_ALG_NULL,
+auth_key,
+aes128_cbc_reference_plaintext[i],
+aes128_cbc_reference_length[i],
+aes128_cbc_reference_ciphertext[i],
+aes128_cbc_reference_length[i]);
+   }
+}
+
+/* This test verifies the correctness of encode (plaintext -> ciphertext)
+ * operation for AES128_CBC algorithm. IV for the operation is the operation 
IV.
+ * */
+void crypto_test_enc_alg_aes128_cbc_ovr_iv(void)
+{
+   odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+auth_key   = { .data = NULL, .length = 0 };
+   odp_crypto_iv_t iv = { .data = NULL, .length = AES128_CBC_IV_LEN };
+   unsigned int test_vec_num = (sizeof(aes128_cbc_reference_length) /
+sizeof(aes128_cbc_reference_length[0]));
+   unsigned int i;
+
+   for (i = 0; i < test_vec_num; i++) {
+   cipher_key.data = aes128_cbc_reference_key[i];
+   cipher_key.length = sizeof(aes128_cbc_reference_key[i]);
+
+   alg_test(ODP_CRYPTO_OP_ENCODE,
+ODP_CIPHER_ALG_AES128_CBC,
+iv,
+aes128_cbc_reference_iv[i],
+cipher_key,
+ODP_AUTH_ALG_NULL,
+auth_key,
+aes128_cbc_reference_plaintext[i],
+aes128_cbc_reference_length[i],
+aes128_cbc_reference_ciphertext[i],
+aes128_cbc_reference_length[i]);
+   }
+}
+
+/* This test verifies the correctness of decode (ciphertext -> plaintext)
+ * operation for AES128_CBC algorithm. IV for the operation is the session IV
+ * In addition the test verifies if the implementation can use the
+ * packet buffer as completion event buffer.
+ * */
+void crypto_test_dec_alg_aes128_cbc(void)
+{
+   odp_crypto_key_t 

Re: [lng-odp] [API-NEXT PATCH v3 5/6] crypto: add AES128-CBC encrypt/decrypt methods

2015-11-09 Thread Nicolas Morey-Chaisemartin


On 11/09/2015 04:18 PM, Savolainen, Petri (Nokia - FI/Espoo) wrote:
> Subject / git log entry misses "api:"
>
> api: crypto: add AES128-CBC encrypt/decrypt methods
Grmbl. Missed one again.
>
>
> Also, the typo in the first patch could be corrected at the same time (maybe 
> you missed the same  comment from v2). See under.
>
> Patch 1/6:
>
> diff --git a/include/odp/api/crypto.h b/include/odp/api/crypto.h
> index a9a2a1d..cc204a1 100644
> --- a/include/odp/api/crypto.h
> +++ b/include/odp/api/crypto.h
> @@ -39,51 +39,46 @@ extern "C" {
>  */
>  
>  /**
> - * @enum odp_crypto_op_mode
>   * Crypto API operation mode
> - *
> - * @enum odp_crypto_op_mode:ODP_CRYPTO_SYNC
> - * Synchronous, return results immediately
> - *
> - * @enum odp_crypto_op_mode:ODP_CRYPTO_ASYNC
> - * Aynchronous, return results via posted event
>   */
> +typedef enum {
> + /** Synchronous, return results immediately */
> + ODP_CRYPTO_SYNC,
> + /** Aynchronous, return results via posted event */
>
> Asynchronous
>
> -Petri
I blindy copy pasted the previous comments so typo stayed where they were. I'll 
fix it too.

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


Re: [lng-odp] Runtime inlining

2015-11-10 Thread Nicolas Morey-Chaisemartin
As I said in the call last week, the problem is wider than that.

ODP specifies a lot of types but not their sizes, a lot of enums/defines 
(things like ODP_PKTIO_INVALID) but not their value either.
For our port a lot of those values were changed for performance/implementation 
reason. So I'm not even compatible between one version of our ODP port and 
another one.

The only way I can see to solve this is for ODP to fix the size of all these 
types.
Default/Invalid values are not that easy, as a pointer would have a completely 
different behaviour from structs/bitfields

Nicolas

On 11/06/2015 03:48 PM, Zoltan Kiss wrote:
> Hi,
>
> We have a packaging/linking/optimization problem at LNG, I hope you guys can 
> give us some advice on that. (Cc'ing ODP list in case someone want to add 
> something)
> We have OpenDataPlane (ODP), an API stretching between userspace applications 
> and hardware SDKs. It's defined in the form of C headers, and we already have 
> several implementations to face SDKs (or whathever is actually controlling 
> the hardware), e.g. linux-generic, a DPDK one etc.
> And we have applications, like Open vSwitch (OVS), which now is able to work 
> with any ODP platform implementation which implements this API
> When it comes to packaging, the ideal scenario would be to create one package 
> for the application, e.g. openvswitch.deb, and one for each platform, e.g 
> odp-generic.deb, odp-dpdk.deb. The latter would contain the implementations 
> in the form of a libodp.so file, so the application can dynamically load the 
> actually installed platform's library runtime, with all the benefits of 
> dynamic linking.
> The trouble is that we have several accessor functions in the API which are 
> very short and __very__ frequently used. The best example is "uint32_t 
> odp_packet_len(odp_packet_t pkt)", which returns the length of the packet. 
> odp_packet_t is an opaque type defined by the implementation, often a pointer 
> to the packet's actual metadata, so the actual function call yields to a 
> simple load from that metadata pointer (+offset). Having it wrapped into a 
> function call brings a significant performance decrease: when forwarding 64 
> byte packets at 10 Gbps, I got 13.2 Mpps with function calls. When I've 
> inlined that function it brought 13.8 Mpps, that's ~5% difference. And there 
> are a lot of other frequently used short accessor functions with the same 
> problem.
> But obviously if I inline these functions I break the ABI, and I need to 
> compile the application for each platform (and create packages like 
> openvswitch-odp-dpdk.deb, containing the platform statically linked). I've 
> tried to look around on Google and in gcc manual, but I couldn't find a good 
> solution for this kind of problem.
> I've checked link time optimization (-flto), but it only helps with static 
> linking. Is there any way to keep the ODP application and platform 
> implementation binaries in separate files while having the performance 
> benefit of inlining?
>
> Regards,
>
> Zoltan
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp

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


[lng-odp] [API-NEXT PATCHv4 0/6] Add HMAC-SHA-256-128 and AES128 CBC support

2015-11-10 Thread Nicolas Morey-Chaisemartin
The first patch is a cleanup suggested by Petri.
All the crypto enums are moved from linux-generic back to ODP API, and renamed 
(odp__t)
Following patches add support for the new HMAC function, then a validation test 
and finally support in odp-ipsec
And then same things for AES128

v4:
 * add mising "api:"
 * Fix typo in API doxygen
v3:
 * correct patch name
 * add AES128 CBC support
v2:
 * Correct test vectors to match the ones from RFC4868

Jerome Reybert (1):
  api: crypto: add AES128-CBC encrypt/decrypt methods

Nicolas Morey-Chaisemartin (5):
  api: crypto: move enums from platform types to odp and rename to fit
the API format
  api: crypto: add HMAC-SHA-256-128 support
  validation: crypto: add test for HMAC-SHA-256-128
  example: ipsec: add support for HMAC-SHA-256-128
  validation: crypto: add test for AES128 CBC

 example/ipsec/odp_ipsec.c  |   2 +-
 example/ipsec/odp_ipsec_cache.c|   2 +-
 example/ipsec/odp_ipsec_cache.h|   4 +-
 example/ipsec/odp_ipsec_misc.h |  12 +-
 example/ipsec/odp_ipsec_sa_db.c|   4 +
 example/ipsec/odp_ipsec_stream.c   |   3 +-
 include/odp/api/crypto.h   | 144 +++
 .../linux-generic/include/odp/plat/crypto_types.h  |  42 -
 .../linux-generic/include/odp_crypto_internal.h|  20 +-
 platform/linux-generic/odp_crypto.c| 205 +++--
 test/validation/crypto/crypto.h|   5 +
 test/validation/crypto/odp_crypto_test_inp.c   | 182 +-
 test/validation/crypto/test_vectors.h  | 111 +++
 test/validation/crypto/test_vectors_len.h  |  10 +
 14 files changed, 592 insertions(+), 154 deletions(-)

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


[lng-odp] [API-NEXT PATCHv4 2/6] api: crypto: add HMAC-SHA-256-128 support

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 include/odp/api/crypto.h   |  2 +
 .../linux-generic/include/odp_crypto_internal.h|  4 +
 platform/linux-generic/odp_crypto.c| 89 ++
 3 files changed, 95 insertions(+)

diff --git a/include/odp/api/crypto.h b/include/odp/api/crypto.h
index 28d345b..47c3fd6 100644
--- a/include/odp/api/crypto.h
+++ b/include/odp/api/crypto.h
@@ -78,6 +78,8 @@ typedef enum {
ODP_AUTH_ALG_NULL,
/** HMAC-MD5 with 96 bit key */
ODP_AUTH_ALG_MD5_96,
+   /** SHA256 with 128 bit key */
+   ODP_AUTH_ALG_SHA256_128,
 } odp_auth_alg_t;
 
 /**
diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index 23fec04..10bcfd4 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -56,6 +56,10 @@ struct odp_crypto_generic_session {
uint8_t  key[16];
uint32_t bytes;
} md5;
+   struct {
+   uint8_t  key[32];
+   uint32_t bytes;
+   } sha256;
} data;
crypto_func_t func;
} auth;
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index e3bc557..ed3d14c 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -140,6 +140,72 @@ 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_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint8_t *icv   = data;
+   uint32_t len   = params->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;
+
+   /* Hash it */
+   HMAC(EVP_sha256(),
+session->auth.data.sha256.key,
+32,
+data,
+len,
+hash,
+NULL);
+
+   /* Copy to the output location */
+   memcpy(icv, hash, session->auth.data.sha256.bytes);
+
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
+odp_crypto_alg_err_t sha256_check(odp_crypto_op_params_t *params,
+ odp_crypto_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint8_t *icv   = data;
+   uint32_t len   = params->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 += params->auth_range.offset;
+   icv  += params->hash_result_offset;
+
+   /* Copy current value out and clear it before authentication */
+   memset(hash_in, 0, sizeof(hash_in));
+   memcpy(hash_in, icv, bytes);
+   memset(icv, 0, bytes);
+   memset(hash_out, 0, sizeof(hash_out));
+
+   /* Hash it */
+   HMAC(EVP_sha256(),
+session->auth.data.sha256.key,
+32,
+data,
+len,
+hash_out,
+NULL);
+
+   /* Verify match */
+   if (0 != memcmp(hash_in, hash_out, bytes))
+   return ODP_CRYPTO_ALG_ERR_ICV_CHECK;
+
+   /* Matched */
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
 odp_crypto_alg_err_t des_encrypt(odp_crypto_op_params_t *params,
 odp_crypto_generic_session_t *session)
 {
@@ -261,6 +327,26 @@ int process_md5_params(odp_crypto_generic_session_t 
*session,
return 0;
 }
 
+static
+int process_sha256_params(odp_crypto_generic_session_t *session,
+ odp_crypto_session_params_t *params,
+ uint32_t bits)
+{
+   /* Set function */
+   if (ODP_CRYPTO_OP_ENCODE == params->op)
+   session->auth.func = sha256_gen;
+   else
+   session->auth.func = sha256_check;
+
+   /* Number of valid bytes */
+   session->auth.data.sha256.bytes = bits / 8;
+
+   /* Convert keys */
+   memcpy(session->auth.data.sha256.key, params->auth_key.data, 32);
+
+   return 0;
+}
+
 int
 odp_crypto_session_create(odp_crypto_session_params_t *params,
  odp_crypto_session_t *session_out,
@@ -323,6 +409,9 @@ odp_crypto_session_create(odp_crypto_session_params_t 
*params,
case ODP_AUTH_ALG_MD5_96:
rc = process_md5_params(session, params, 96);
break;
+   case ODP_AUTH_ALG_SHA256_128:
+   rc = process_sha2

[lng-odp] [API-NEXT PATCHv4 1/6] api: crypto: move enums from platform types to odp and rename to fit the API format

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 example/ipsec/odp_ipsec_cache.c|   2 +-
 example/ipsec/odp_ipsec_cache.h|   4 +-
 example/ipsec/odp_ipsec_misc.h |   4 +-
 include/odp/api/crypto.h   | 140 ++---
 .../linux-generic/include/odp/plat/crypto_types.h  |  42 ---
 .../linux-generic/include/odp_crypto_internal.h|  12 +-
 platform/linux-generic/odp_crypto.c|  29 +++--
 test/validation/crypto/odp_crypto_test_inp.c   |  10 +-
 8 files changed, 93 insertions(+), 150 deletions(-)

diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c
index 6a8f3c9..0883d4d 100644
--- a/example/ipsec/odp_ipsec_cache.c
+++ b/example/ipsec/odp_ipsec_cache.c
@@ -46,7 +46,7 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,
 {
odp_crypto_session_params_t params;
ipsec_cache_entry_t *entry;
-   enum odp_crypto_ses_create_err ses_create_rc;
+   odp_crypto_ses_create_err_t ses_create_rc;
odp_crypto_session_t session;
sa_mode_t mode = IPSEC_SA_MODE_TRANSPORT;
 
diff --git a/example/ipsec/odp_ipsec_cache.h b/example/ipsec/odp_ipsec_cache.h
index 5706007..91d9d7e 100644
--- a/example/ipsec/odp_ipsec_cache.h
+++ b/example/ipsec/odp_ipsec_cache.h
@@ -38,14 +38,14 @@ typedef struct ipsec_cache_entry_s {
uint32_t tun_src_ip;  /**< Tunnel src IPv4 addr */
uint32_t tun_dst_ip;  /**< Tunnel dst IPv4 addr */
struct {
-   enum  odp_cipher_alg alg; /**< Cipher algorithm */
+   odp_cipher_alg_t alg; /**< Cipher algorithm */
uint32_t spi; /**< Cipher SPI */
uint32_t block_len;   /**< Cipher block length */
uint32_t iv_len;  /**< Cipher IV length */
ipsec_key_t  key; /**< Cipher key */
} esp;
struct {
-   enum  odp_auth_alg   alg; /**< Auth algorithm */
+   odp_auth_alg_t   alg; /**< Auth algorithm */
uint32_t spi; /**< Auth SPI */
uint32_t icv_len; /**< Auth ICV length */
ipsec_key_t  key; /**< Auth key */
diff --git a/example/ipsec/odp_ipsec_misc.h b/example/ipsec/odp_ipsec_misc.h
index f6a12b5..85c5f6a 100644
--- a/example/ipsec/odp_ipsec_misc.h
+++ b/example/ipsec/odp_ipsec_misc.h
@@ -59,8 +59,8 @@ typedef struct {
 typedef struct {
odp_bool_t cipher;
union {
-   enum odp_cipher_alg cipher;
-   enum odp_auth_alg   auth;
+   odp_cipher_alg_t cipher;
+   odp_auth_alg_t   auth;
} u;
 } ipsec_alg_t;
 
diff --git a/include/odp/api/crypto.h b/include/odp/api/crypto.h
index a9a2a1d..28d345b 100644
--- a/include/odp/api/crypto.h
+++ b/include/odp/api/crypto.h
@@ -39,51 +39,46 @@ extern "C" {
 */
 
 /**
- * @enum odp_crypto_op_mode
  * Crypto API operation mode
- *
- * @enum odp_crypto_op_mode:ODP_CRYPTO_SYNC
- * Synchronous, return results immediately
- *
- * @enum odp_crypto_op_mode:ODP_CRYPTO_ASYNC
- * Aynchronous, return results via posted event
  */
+typedef enum {
+   /** Synchronous, return results immediately */
+   ODP_CRYPTO_SYNC,
+   /** Asynchronous, return results via posted event */
+   ODP_CRYPTO_ASYNC,
+} odp_crypto_op_mode_t;
 
 /**
- * @enum odp_crypto_op
  * Crypto API operation type
- *
- * @enum odp_crypto_op:ODP_CRYPTO_OP_ENCODE
- * Encrypt and/or compute authentication ICV
- *
- * @enum odp_crypto_op:ODP_CRYPTO_OP_DECODE
- * Decrypt and/or verify authentication ICV
  */
+typedef enum {
+   /** Encrypt and/or compute authentication ICV */
+   ODP_CRYPTO_OP_ENCODE,
+   /** Decrypt and/or verify authentication ICV */
+   ODP_CRYPTO_OP_DECODE,
+} odp_crypto_op_t;
 
 /**
- * @enum odp_cipher_alg
  * Crypto API cipher algorithm
- *
- * @enum odp_cipher_alg:ODP_CIPHER_ALG_NULL
- * No cipher algorithm specified
- *
- * @enum odp_cipher_alg:ODP_CIPHER_ALG_DES
- * DES
- *
- * @enum odp_cipher_alg:ODP_CIPHER_ALG_3DES_CBC
- * Triple DES with cipher block chaining
  */
+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,
+} odp_cipher_alg_t;
 
 /**
- * @enum odp_auth_alg
  * Crypto API authentication algorithm
- *
- * @enum odp_auth_alg:ODP_AUTH_ALG_NULL
- * No authentication algorithm specified
- *
- * @enum odp_auth_alg:ODP_AUTH_ALG_MD5_96
- * HMAC-MD5 with 96 bit key
  */
+typedef enum {
+/** No authentication algorithm specified */
+   ODP_AUTH_ALG_NULL,
+   /** HMAC-MD5 with 96 bit key */
+   ODP_AUTH_ALG_MD5

[lng-odp] [API-NEXT PATCHv4 3/6] validation: crypto: add test for HMAC-SHA-256-128

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/crypto.h  |  1 +
 test/validation/crypto/odp_crypto_test_inp.c | 37 +++
 test/validation/crypto/test_vectors.h| 44 
 test/validation/crypto/test_vectors_len.h|  6 
 4 files changed, 88 insertions(+)

diff --git a/test/validation/crypto/crypto.h b/test/validation/crypto/crypto.h
index 7cb60d4..fe23e04 100644
--- a/test/validation/crypto/crypto.h
+++ b/test/validation/crypto/crypto.h
@@ -15,6 +15,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void);
 void crypto_test_dec_alg_3des_cbc(void);
 void crypto_test_dec_alg_3des_cbc_ovr_iv(void);
 void crypto_test_alg_hmac_md5(void);
+void crypto_test_alg_hmac_sha256(void);
 
 /* test arrays: */
 extern odp_testinfo_t crypto_suite[];
diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 05b6885..838edc4 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -295,6 +295,42 @@ void crypto_test_alg_hmac_md5(void)
}
 }
 
+/* This test verifies the correctness of HMAC_MD5 digest operation.
+ * The output check length is truncated to 12 bytes (96 bits) as
+ * returned by the crypto operation API call.
+ * Note that hash digest is a one-way operation.
+ * In addition the test verifies if the implementation can use the
+ * packet buffer as completion event buffer.
+ * */
+void crypto_test_alg_hmac_sha256(void)
+{
+   odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+auth_key   = { .data = NULL, .length = 0 };
+   odp_crypto_iv_t iv = { .data = NULL, .length = 0 };
+
+   unsigned int test_vec_num = (sizeof(hmac_sha256_reference_length) /
+sizeof(hmac_sha256_reference_length[0]));
+
+   unsigned int i;
+
+   for (i = 0; i < test_vec_num; i++) {
+   auth_key.data = hmac_sha256_reference_key[i];
+   auth_key.length = sizeof(hmac_sha256_reference_key[i]);
+
+   alg_test(ODP_CRYPTO_OP_ENCODE,
+ODP_CIPHER_ALG_NULL,
+iv,
+iv.data,
+cipher_key,
+ODP_AUTH_ALG_SHA256_128,
+auth_key,
+hmac_sha256_reference_plaintext[i],
+hmac_sha256_reference_length[i],
+hmac_sha256_reference_digest[i],
+HMAC_SHA256_128_CHECK_LEN);
+   }
+}
+
 int crypto_suite_sync_init(void)
 {
suite_context.pool = odp_pool_lookup("packet_pool");
@@ -325,5 +361,6 @@ odp_testinfo_t crypto_suite[] = {
ODP_TEST_INFO(crypto_test_enc_alg_3des_cbc_ovr_iv),
ODP_TEST_INFO(crypto_test_dec_alg_3des_cbc_ovr_iv),
ODP_TEST_INFO(crypto_test_alg_hmac_md5),
+   ODP_TEST_INFO(crypto_test_alg_hmac_sha256),
ODP_TEST_INFO_NULL,
 };
diff --git a/test/validation/crypto/test_vectors.h 
b/test/validation/crypto/test_vectors.h
index 490a3bc..09cf9c2 100644
--- a/test/validation/crypto/test_vectors.h
+++ b/test/validation/crypto/test_vectors.h
@@ -87,4 +87,48 @@ static uint8_t 
hmac_md5_reference_digest[][HMAC_MD5_DIGEST_LEN] = {
  0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 }
 };
 
+static uint8_t hmac_sha256_reference_key[][HMAC_SHA256_KEY_LEN] = {
+   { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b },
+
+   /* "Jefe" */
+   { 0x4a, 0x65, 0x66, 0x65 },
+
+   { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa }
+};
+
+static uint32_t hmac_sha256_reference_length[] = { 8, 28, 50 };
+
+static uint8_t
+hmac_sha256_reference_plaintext[][HMAC_SHA256_MAX_DATA_LEN] = {
+   /* "Hi There" */
+   { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+
+   /* what do ya want for nothing?*/
+   { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+
+   { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd }
+};
+
+static uint8_t hmac_sha256_reference_digest[][HMAC_SHA256_DIGEST_LEN] = {
+   { 0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53,
+ 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b },
+
+   { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
+ 0x6a, 0x04, 0

[lng-odp] [API-NEXT PATCHv4 6/6] validation: crypto: add test for AES128 CBC

2015-11-10 Thread Nicolas Morey-Chaisemartin
Test reference vectors from RFC3602

Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/crypto.h  |   4 +
 test/validation/crypto/odp_crypto_test_inp.c | 135 ++-
 test/validation/crypto/test_vectors.h|  67 +
 test/validation/crypto/test_vectors_len.h|   4 +
 4 files changed, 209 insertions(+), 1 deletion(-)

diff --git a/test/validation/crypto/crypto.h b/test/validation/crypto/crypto.h
index fe23e04..4769fad 100644
--- a/test/validation/crypto/crypto.h
+++ b/test/validation/crypto/crypto.h
@@ -14,6 +14,10 @@ void crypto_test_enc_alg_3des_cbc(void);
 void crypto_test_enc_alg_3des_cbc_ovr_iv(void);
 void crypto_test_dec_alg_3des_cbc(void);
 void crypto_test_dec_alg_3des_cbc_ovr_iv(void);
+void crypto_test_enc_alg_aes128_cbc(void);
+void crypto_test_enc_alg_aes128_cbc_ovr_iv(void);
+void crypto_test_dec_alg_aes128_cbc(void);
+void crypto_test_dec_alg_aes128_cbc_ovr_iv(void);
 void crypto_test_alg_hmac_md5(void);
 void crypto_test_alg_hmac_sha256(void);
 
diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 838edc4..5295c63 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -63,7 +63,7 @@ static void alg_test(odp_crypto_op_t op,
ses_params.auth_key = auth_key;
 
rc = odp_crypto_session_create(&ses_params, &session, &status);
-   CU_ASSERT(!rc);
+   CU_ASSERT_FATAL(!rc);
CU_ASSERT(status == ODP_CRYPTO_SES_CREATE_ERR_NONE);
CU_ASSERT(odp_crypto_session_to_u64(session) !=
  odp_crypto_session_to_u64(ODP_CRYPTO_SESSION_INVALID));
@@ -259,6 +259,135 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void)
}
 }
 
+/* This test verifies the correctness of encode (plaintext -> ciphertext)
+ * operation for AES128_CBC algorithm. IV for the operation is the session IV.
+ * In addition the test verifies if the implementation can use the
+ * packet buffer as completion event buffer.*/
+void crypto_test_enc_alg_aes128_cbc(void)
+{
+   odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+auth_key   = { .data = NULL, .length = 0 };
+   odp_crypto_iv_t iv;
+   unsigned int test_vec_num = (sizeof(aes128_cbc_reference_length) /
+sizeof(aes128_cbc_reference_length[0]));
+   unsigned int i;
+
+   for (i = 0; i < test_vec_num; i++) {
+   cipher_key.data = aes128_cbc_reference_key[i];
+   cipher_key.length = sizeof(aes128_cbc_reference_key[i]);
+   iv.data = aes128_cbc_reference_iv[i];
+   iv.length = sizeof(aes128_cbc_reference_iv[i]);
+
+   alg_test(ODP_CRYPTO_OP_ENCODE,
+ODP_CIPHER_ALG_AES128_CBC,
+iv,
+NULL,
+cipher_key,
+ODP_AUTH_ALG_NULL,
+auth_key,
+aes128_cbc_reference_plaintext[i],
+aes128_cbc_reference_length[i],
+aes128_cbc_reference_ciphertext[i],
+aes128_cbc_reference_length[i]);
+   }
+}
+
+/* This test verifies the correctness of encode (plaintext -> ciphertext)
+ * operation for AES128_CBC algorithm. IV for the operation is the operation 
IV.
+ * */
+void crypto_test_enc_alg_aes128_cbc_ovr_iv(void)
+{
+   odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+auth_key   = { .data = NULL, .length = 0 };
+   odp_crypto_iv_t iv = { .data = NULL, .length = AES128_CBC_IV_LEN };
+   unsigned int test_vec_num = (sizeof(aes128_cbc_reference_length) /
+sizeof(aes128_cbc_reference_length[0]));
+   unsigned int i;
+
+   for (i = 0; i < test_vec_num; i++) {
+   cipher_key.data = aes128_cbc_reference_key[i];
+   cipher_key.length = sizeof(aes128_cbc_reference_key[i]);
+
+   alg_test(ODP_CRYPTO_OP_ENCODE,
+ODP_CIPHER_ALG_AES128_CBC,
+iv,
+aes128_cbc_reference_iv[i],
+cipher_key,
+ODP_AUTH_ALG_NULL,
+auth_key,
+aes128_cbc_reference_plaintext[i],
+aes128_cbc_reference_length[i],
+aes128_cbc_reference_ciphertext[i],
+aes128_cbc_reference_length[i]);
+   }
+}
+
+/* This test verifies the correctness of decode (ciphertext -> plaintext)
+ * operation for AES128_CBC algorithm. IV for the operation is the session IV
+ * In addition the test verifies if the implementation can use the
+ * packet buffer as completion event buffer.
+ * */
+void crypto_test_dec_alg_aes128_cbc(void)
+{
+   odp_crypto_key_t 

[lng-odp] [API-NEXT PATCHv4 4/6] example: ipsec: add support for HMAC-SHA-256-128

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 example/ipsec/odp_ipsec.c| 2 +-
 example/ipsec/odp_ipsec_misc.h   | 8 ++--
 example/ipsec/odp_ipsec_sa_db.c  | 4 
 example/ipsec/odp_ipsec_stream.c | 3 ++-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index e76e6eb..d784c31 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1554,7 +1554,7 @@ static void usage(char *progname)
   " -r, --route SubNet:Intf:NextHopMAC\n"
   " -p, --policy SrcSubNet:DstSubNet:(in|out):(ah|esp|both)\n"
   " -e, --esp SrcIP:DstIP:(3des|null):SPI:Key192\n"
-  " -a, --ah SrcIP:DstIP:(md5|null):SPI:Key128\n"
+  " -a, --ah SrcIP:DstIP:(sha256|md5|null):SPI:Key(256|128)\n"
   "\n"
   "  Where: NextHopMAC is raw hex/dot notation, i.e. 
03.BA.44.9A.CE.02\n"
   " IP is decimal/dot notation, i.e. 192.168.1.1\n"
diff --git a/example/ipsec/odp_ipsec_misc.h b/example/ipsec/odp_ipsec_misc.h
index 85c5f6a..e583c01 100644
--- a/example/ipsec/odp_ipsec_misc.h
+++ b/example/ipsec/odp_ipsec_misc.h
@@ -28,8 +28,9 @@ extern "C" {
 #define MAX_STRING  32   /**< maximum string length */
 #define MAX_IV_LEN  32   /**< Maximum IV length in bytes */
 
-#define KEY_BITS_3DES  192  /**< 3DES cipher key length in bits */
-#define KEY_BITS_MD5_96128  /**< MD5_96 auth key length in bits */
+#define KEY_BITS_3DES   192  /**< 3DES cipher key length in bits */
+#define KEY_BITS_MD5_96 128  /**< MD5_96 auth key length in bits */
+#define KEY_BITS_SHA256_128 256  /**< SHA256_128 auth key length in bits */
 
 /**< Number of bits represnted by a string of hexadecimal characters */
 #define KEY_STR_BITS(str) (4 * strlen(str))
@@ -102,6 +103,9 @@ int parse_key_string(char *keystring,
if ((alg->u.auth == ODP_AUTH_ALG_MD5_96) &&
(KEY_BITS_MD5_96 == key_bits_in))
key->length = key_bits_in / 8;
+   else if ((alg->u.auth == ODP_AUTH_ALG_SHA256_128) &&
+(KEY_BITS_SHA256_128 == key_bits_in))
+   key->length = key_bits_in / 8;
}
 
for (idx = 0; idx < key->length; idx++) {
diff --git a/example/ipsec/odp_ipsec_sa_db.c b/example/ipsec/odp_ipsec_sa_db.c
index 7967614..928c4cb 100644
--- a/example/ipsec/odp_ipsec_sa_db.c
+++ b/example/ipsec/odp_ipsec_sa_db.c
@@ -111,6 +111,10 @@ int create_sa_db_entry(char *input, odp_bool_t cipher)
entry->alg.u.auth =
ODP_AUTH_ALG_MD5_96;
entry->icv_len= 12;
+   } else if (!strcmp(token, "sha256")) {
+   entry->alg.u.auth =
+   ODP_AUTH_ALG_SHA256_128;
+   entry->icv_len= 16;
} else {
entry->alg.u.auth = ODP_AUTH_ALG_NULL;
}
diff --git a/example/ipsec/odp_ipsec_stream.c b/example/ipsec/odp_ipsec_stream.c
index 8a1cc56..f750e18 100644
--- a/example/ipsec/odp_ipsec_stream.c
+++ b/example/ipsec/odp_ipsec_stream.c
@@ -227,7 +227,8 @@ odp_packet_t create_ipv4_packet(stream_db_entry_t *stream,
/* AH (if specified) */
if (entry && (entry == stream->input.entry) &&
(ODP_AUTH_ALG_NULL != entry->ah.alg)) {
-   if (ODP_AUTH_ALG_MD5_96 != entry->ah.alg)
+   if (entry->ah.alg != ODP_AUTH_ALG_MD5_96 &&
+   entry->ah.alg != ODP_AUTH_ALG_SHA256_128)
abort();
 
ah = (odph_ahhdr_t *)data;
-- 
2.6.2.406.gaaaec35


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


[lng-odp] [API-NEXT PATCHv4 5/6] api: crypto: add AES128-CBC encrypt/decrypt methods

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 include/odp/api/crypto.h   |  2 +
 .../linux-generic/include/odp_crypto_internal.h|  4 +
 platform/linux-generic/odp_crypto.c| 89 ++
 3 files changed, 95 insertions(+)

diff --git a/include/odp/api/crypto.h b/include/odp/api/crypto.h
index 47c3fd6..c62021e 100644
--- a/include/odp/api/crypto.h
+++ b/include/odp/api/crypto.h
@@ -68,6 +68,8 @@ typedef enum {
ODP_CIPHER_ALG_DES,
/** Triple DES with cipher block chaining */
ODP_CIPHER_ALG_3DES_CBC,
+   /** AES128 with cipher block chaining */
+   ODP_CIPHER_ALG_AES128_CBC,
 } odp_cipher_alg_t;
 
 /**
diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index 10bcfd4..b9128a4 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -12,6 +12,7 @@ extern "C" {
 #endif
 
 #include 
+#include 
 
 #define OP_RESULT_MAGIC 0x91919191
 
@@ -46,6 +47,9 @@ struct odp_crypto_generic_session {
DES_key_schedule ks2;
DES_key_schedule ks3;
} des;
+   struct {
+   AES_KEY key;
+   } aes;
} data;
crypto_func_t func;
} cipher;
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index ed3d14c..17fced9 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -206,6 +206,92 @@ odp_crypto_alg_err_t sha256_check(odp_crypto_op_params_t 
*params,
 }
 
 static
+odp_crypto_alg_err_t aes_encrypt(odp_crypto_op_params_t *params,
+odp_crypto_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint32_t len   = params->cipher_range.length;
+   unsigned char iv_enc[AES_BLOCK_SIZE];
+   void *iv_ptr;
+
+   if (params->override_iv_ptr)
+   iv_ptr = params->override_iv_ptr;
+   else if (session->cipher.iv.data)
+   iv_ptr = session->cipher.iv.data;
+   else
+   return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+
+   /*
+* Create a copy of the IV.  The DES library modifies IV
+* and if we are processing packets on parallel threads
+* we could get corruption.
+*/
+   memcpy(iv_enc, iv_ptr, AES_BLOCK_SIZE);
+
+   /* Adjust pointer for beginning of area to cipher */
+   data += params->cipher_range.offset;
+   /* Encrypt it */
+   AES_cbc_encrypt(data, data, len, &session->cipher.data.aes.key,
+   iv_enc, AES_ENCRYPT);
+
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
+odp_crypto_alg_err_t aes_decrypt(odp_crypto_op_params_t *params,
+odp_crypto_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint32_t len   = params->cipher_range.length;
+   unsigned char iv_enc[AES_BLOCK_SIZE];
+   void *iv_ptr;
+
+   if (params->override_iv_ptr)
+   iv_ptr = params->override_iv_ptr;
+   else if (session->cipher.iv.data)
+   iv_ptr = session->cipher.iv.data;
+   else
+   return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+
+   /*
+* Create a copy of the IV.  The DES library modifies IV
+* and if we are processing packets on parallel threads
+* we could get corruption.
+*/
+   memcpy(iv_enc, iv_ptr, AES_BLOCK_SIZE);
+
+   /* Adjust pointer for beginning of area to cipher */
+   data += params->cipher_range.offset;
+   /* Encrypt it */
+   AES_cbc_encrypt(data, data, len, &session->cipher.data.aes.key,
+   iv_enc, AES_DECRYPT);
+
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
+int process_aes_params(odp_crypto_generic_session_t *session,
+  odp_crypto_session_params_t *params)
+{
+   /* Verify IV len is either 0 or 16 */
+   if (!((0 == params->iv.length) || (16 == params->iv.length)))
+   return -1;
+
+   /* Set function */
+   if (ODP_CRYPTO_OP_ENCODE == params->op) {
+   session->cipher.func = aes_encrypt;
+   AES_set_encrypt_key(params->cipher_key.data, 128,
+   &session->cipher.data.aes.key);
+   } else {
+   session->cipher.func = aes_decrypt;
+   AES_set_decrypt_key(params->cipher_key.data, 128,
+   &session->cipher.data.aes.key);
+   }
+
+   return 0;
+}
+
+static
 odp_crypto_alg_err_t des_encrypt(odp_crypto_op_params_t *params,
 odp_crypto_generic_session_t *session

[lng-odp] [PATCH 00/10] Pktio checks

2015-11-10 Thread Nicolas Morey-Chaisemartin
This series add several tests for pktios and fixes the issue they raised.
The main features checked are:
* RONLY pktio cannot be sent to
* WONLY pktio cannot be read from
* stopped pktio cannot be stopped
* started pktio cannot be started
* started pktio cannot be configured

Nicolas Morey-Chaisemartin (10):
  linux-generic: pktio: check interface mode is compatible before
receiving or sending
  validation: pktio: add customizable out mode for pktios
  validation: pktio: add tests for rrecv() on WONLY, and send on RONLY
pktios
  validation: pktio: stop interfaces before removing the default inq
  validation: pktio: remove unneeded stop as interface is stopped after
open()
  validation: classification: start pktio after setting inq and stop it
before removing it
  validation: classification: stronger checks to avoid SEGV on pktio
failure
  linux-generic: pktio: check for pktio_start when started and
pktio_stop when stopped
  linux-generic: pktio: configuration functions check that interface is
stopped
  validation: pktio: add test for start when started and stop when
stopped()

 platform/linux-generic/odp_packet_io.c |  25 -
 .../classification/odp_classification_common.c |   2 +
 .../classification/odp_classification_test_pmr.c   |  25 +++--
 test/validation/pktio/pktio.c  | 116 ++---
 4 files changed, 140 insertions(+), 28 deletions(-)

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


[lng-odp] [PATCH 02/10] validation: pktio: add customizable out mode for pktios

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/pktio/pktio.c | 35 +++
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index a2da47b..b52da06 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -252,7 +252,8 @@ static int default_pool_create(void)
return 0;
 }
 
-static odp_pktio_t create_pktio(int iface_idx, odp_pktio_input_mode_t mode)
+static odp_pktio_t create_pktio(int iface_idx, odp_pktio_input_mode_t imode,
+   odp_pktio_output_mode_t omode)
 {
odp_pktio_t pktio;
odp_pktio_param_t pktio_param;
@@ -260,7 +261,8 @@ static odp_pktio_t create_pktio(int iface_idx, 
odp_pktio_input_mode_t mode)
 
odp_pktio_param_init(&pktio_param);
 
-   pktio_param.in_mode = mode;
+   pktio_param.in_mode = imode;
+   pktio_param.out_mode = omode;
 
pktio = odp_pktio_open(iface, pool[iface_idx], &pktio_param);
if (pktio == ODP_PKTIO_INVALID)
@@ -469,7 +471,7 @@ static void test_txrx(odp_pktio_input_mode_t in_mode, int 
num_pkts)
io = &pktios[i];
 
io->name = iface_name[i];
-   io->id   = create_pktio(i, in_mode);
+   io->id   = create_pktio(i, in_mode, ODP_PKTOUT_MODE_SEND);
if (io->id == ODP_PKTIO_INVALID) {
CU_FAIL("failed to open iface");
return;
@@ -544,7 +546,8 @@ void pktio_test_mtu(void)
int ret;
int mtu;
 
-   odp_pktio_t pktio = create_pktio(0, ODP_PKTIN_MODE_SCHED);
+   odp_pktio_t pktio = create_pktio(0, ODP_PKTIN_MODE_SCHED,
+ODP_PKTOUT_MODE_SEND);
CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 
mtu = odp_pktio_mtu(pktio);
@@ -560,7 +563,8 @@ void pktio_test_promisc(void)
 {
int ret;
 
-   odp_pktio_t pktio = create_pktio(0, ODP_PKTIN_MODE_SCHED);
+   odp_pktio_t pktio = create_pktio(0, ODP_PKTIN_MODE_SCHED,
+ODP_PKTOUT_MODE_SEND);
CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 
ret = odp_pktio_promisc_mode_set(pktio, 1);
@@ -588,7 +592,8 @@ void pktio_test_mac(void)
int ret;
odp_pktio_t pktio;
 
-   pktio = create_pktio(0, ODP_PKTIN_MODE_SCHED);
+   pktio = create_pktio(0, ODP_PKTIN_MODE_SCHED,
+ODP_PKTOUT_MODE_SEND);
CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 
printf("testing mac for %s\n", iface_name[0]);
@@ -616,7 +621,8 @@ void pktio_test_inq_remdef(void)
uint64_t wait;
int i;
 
-   pktio = create_pktio(0, ODP_PKTIN_MODE_SCHED);
+   pktio = create_pktio(0, ODP_PKTIN_MODE_SCHED,
+ODP_PKTOUT_MODE_SEND);
CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
CU_ASSERT(create_inq(pktio, ODP_QUEUE_TYPE_POLL) == 0);
inq = odp_pktio_inq_getdef(pktio);
@@ -644,7 +650,8 @@ void pktio_test_open(void)
 
/* test the sequence open->close->open->close() */
for (i = 0; i < 2; ++i) {
-   pktio = create_pktio(0, ODP_PKTIN_MODE_SCHED);
+   pktio = create_pktio(0, ODP_PKTIN_MODE_SCHED,
+ODP_PKTOUT_MODE_SEND);
CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
CU_ASSERT(odp_pktio_close(pktio) == 0);
}
@@ -683,7 +690,8 @@ void pktio_test_inq(void)
 {
odp_pktio_t pktio;
 
-   pktio = create_pktio(0, ODP_PKTIN_MODE_POLL);
+   pktio = create_pktio(0, ODP_PKTIN_MODE_POLL,
+ODP_PKTOUT_MODE_SEND);
CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 
CU_ASSERT(create_inq(pktio, ODP_QUEUE_TYPE_POLL) == 0);
@@ -702,7 +710,8 @@ static void pktio_test_start_stop(void)
uint64_t wait = odp_schedule_wait_time(ODP_TIME_MSEC);
 
for (i = 0; i < num_ifaces; i++) {
-   pktio[i] = create_pktio(i, ODP_PKTIN_MODE_SCHED);
+   pktio[i] = create_pktio(i, ODP_PKTIN_MODE_SCHED,
+   ODP_PKTOUT_MODE_SEND);
CU_ASSERT_FATAL(pktio[i] != ODP_PKTIO_INVALID);
create_inq(pktio[i],  ODP_QUEUE_TYPE_SCHED);
}
@@ -850,7 +859,8 @@ static void pktio_test_send_failure(void)
int long_pkt_idx = TX_BATCH_LEN / 2;
pktio_info_t info_rx;
 
-   pktio_tx = create_pktio(0, ODP_PKTIN_MODE_RECV);
+   pktio_tx = create_pktio(0, ODP_PKTIN_MODE_RECV,
+   ODP_PKTOUT_MODE_SEND);
if (pktio_tx == ODP_PKTIO_INVALID) {
CU_FAIL("failed to open pktio");
return;
@@ -873,7 +883,8 @@ static void pktio_test_send_failure(void)
CU_ASSERT_FATAL(pkt_pool != ODP_POOL_INVALID);
 
if (num_ifaces 

[lng-odp] [PATCH 04/10] validation: pktio: stop interfaces before removing the default inq

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/pktio/pktio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index d39251c..81f03db 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -497,6 +497,8 @@ static void test_txrx(odp_pktio_input_mode_t in_mode, int 
num_pkts)
pktio_txrx_multi(&pktios[0], &pktios[if_b], num_pkts);
 
for (i = 0; i < num_ifaces; ++i) {
+   ret = odp_pktio_stop(pktios[i].id);
+   CU_ASSERT(ret == 0);
if (in_mode != ODP_PKTIN_MODE_RECV)
destroy_inq(pktios[i].id);
ret = odp_pktio_close(pktios[i].id);
@@ -811,6 +813,7 @@ static void pktio_test_start_stop(void)
CU_ASSERT(pkts == alloc);
 
for (i = 0; i < num_ifaces; i++) {
+   CU_ASSERT(odp_pktio_stop(pktio[i]) == 0);
destroy_inq(pktio[i]);
CU_ASSERT(odp_pktio_close(pktio[i]) == 0);
}
-- 
2.6.2.406.gaaaec35


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


[lng-odp] [PATCH 01/10] linux-generic: pktio: check interface mode is compatible before receiving or sending

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 platform/linux-generic/odp_packet_io.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index c3bc6a0..4d574ad 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -378,7 +378,8 @@ int odp_pktio_recv(odp_pktio_t id, odp_packet_t 
pkt_table[], int len)
return -1;
 
lock_entry(pktio_entry);
-   if (pktio_entry->s.state == STATE_STOP) {
+   if (pktio_entry->s.state == STATE_STOP ||
+   pktio_entry->s.param.in_mode == ODP_PKTIN_MODE_DISABLED) {
unlock_entry(pktio_entry);
__odp_errno = EPERM;
return -1;
@@ -404,7 +405,8 @@ int odp_pktio_send(odp_pktio_t id, odp_packet_t 
pkt_table[], int len)
return -1;
 
lock_entry(pktio_entry);
-   if (pktio_entry->s.state == STATE_STOP) {
+   if (pktio_entry->s.state == STATE_STOP ||
+   pktio_entry->s.param.out_mode == ODP_PKTOUT_MODE_DISABLED) {
unlock_entry(pktio_entry);
__odp_errno = EPERM;
return -1;
-- 
2.6.2.406.gaaaec35


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


[lng-odp] [PATCH 03/10] validation: pktio: add tests for rrecv() on WONLY, and send on RONLY pktios

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/pktio/pktio.c | 67 +++
 1 file changed, 67 insertions(+)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index b52da06..d39251c 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -958,6 +958,71 @@ static void pktio_test_send_failure(void)
CU_ASSERT(odp_pool_destroy(pkt_pool) == 0);
 }
 
+static void pktio_test_recv_on_wonly(void)
+{
+   odp_pktio_t pktio;
+   odp_packet_t pkt;
+   int ret;
+
+   pktio = create_pktio(0, ODP_PKTIN_MODE_DISABLED,
+ODP_PKTOUT_MODE_SEND);
+
+   if (pktio == ODP_PKTIO_INVALID) {
+   CU_FAIL("failed to open pktio");
+   return;
+   }
+
+   ret = odp_pktio_start(pktio);
+   CU_ASSERT_FATAL(ret == 0);
+
+   ret = odp_pktio_recv(pktio, &pkt, 1);
+   CU_ASSERT(ret < 0);
+
+   if (ret > 0)
+   odp_packet_free(pkt);
+
+   ret = odp_pktio_stop(pktio);
+   CU_ASSERT_FATAL(ret == 0);
+
+   ret = odp_pktio_close(pktio);
+   CU_ASSERT_FATAL(ret == 0);
+}
+
+static void pktio_test_send_on_ronly(void)
+{
+   odp_pktio_t pktio;
+   odp_packet_t pkt;
+   int ret;
+
+   pktio = create_pktio(0, ODP_PKTIN_MODE_RECV,
+ODP_PKTOUT_MODE_DISABLED);
+
+   if (pktio == ODP_PKTIO_INVALID) {
+   CU_FAIL("failed to open pktio");
+   return;
+   }
+
+   ret = odp_pktio_start(pktio);
+   CU_ASSERT_FATAL(ret == 0);
+
+   pkt = odp_packet_alloc(default_pkt_pool, packet_len);
+   CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID)
+
+   pktio_init_packet(pkt);
+
+   ret = odp_pktio_send(pktio, &pkt, 1);
+   CU_ASSERT(ret < 0);
+
+   if (ret <= 0)
+   odp_packet_free(pkt);
+
+   ret = odp_pktio_stop(pktio);
+   CU_ASSERT_FATAL(ret == 0);
+
+   ret = odp_pktio_close(pktio);
+   CU_ASSERT_FATAL(ret == 0);
+}
+
 static int create_pool(const char *iface, int num)
 {
char pool_name[ODP_POOL_NAME_LEN];
@@ -1073,6 +1138,8 @@ odp_testinfo_t pktio_suite_unsegmented[] = {
ODP_TEST_INFO(pktio_test_mac),
ODP_TEST_INFO(pktio_test_inq_remdef),
ODP_TEST_INFO(pktio_test_start_stop),
+   ODP_TEST_INFO(pktio_test_recv_on_wonly),
+   ODP_TEST_INFO(pktio_test_send_on_ronly),
ODP_TEST_INFO_NULL
 };
 
-- 
2.6.2.406.gaaaec35


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


[lng-odp] [PATCH 05/10] validation: pktio: remove unneeded stop as interface is stopped after open()

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/pktio/pktio.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index 81f03db..e5458c4 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -737,10 +737,6 @@ static void pktio_test_start_stop(void)
tx_ev[alloc] = odp_packet_to_event(pkt);
}
 
-   /* stop second and send packets*/
-   ret = odp_pktio_stop(pktio[1]);
-   CU_ASSERT(ret == 0);
-
for (pkts = 0; pkts != alloc; ) {
ret = odp_queue_enq_multi(outq, &tx_ev[pkts],
  alloc - pkts);
-- 
2.6.2.406.gaaaec35


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


[lng-odp] [PATCH 06/10] validation: classification: start pktio after setting inq and stop it before removing it

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/classification/odp_classification_common.c   |  2 ++
 test/validation/classification/odp_classification_test_pmr.c | 11 +--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/test/validation/classification/odp_classification_common.c 
b/test/validation/classification/odp_classification_common.c
index e2999ad..665e67c 100644
--- a/test/validation/classification/odp_classification_common.c
+++ b/test/validation/classification/odp_classification_common.c
@@ -29,6 +29,8 @@ int destroy_inq(odp_pktio_t pktio)
return -1;
}
 
+   odp_pktio_stop(pktio);
+
if (0 > odp_pktio_inq_remdef(pktio))
return -1;
 
diff --git a/test/validation/classification/odp_classification_test_pmr.c 
b/test/validation/classification/odp_classification_test_pmr.c
index 73ba6f5..94bd698 100644
--- a/test/validation/classification/odp_classification_test_pmr.c
+++ b/test/validation/classification/odp_classification_test_pmr.c
@@ -60,12 +60,6 @@ odp_pktio_t create_pktio(odp_queue_type_t q_type)
return ODP_PKTIO_INVALID;
}
 
-   ret = odp_pktio_start(pktio);
-   if (ret) {
-   fprintf(stderr, "unable to start loop\n");
-   return ODP_PKTIO_INVALID;
-   }
-
return pktio;
 }
 
@@ -94,6 +88,11 @@ odp_queue_t create_default_inq(odp_pktio_t pktio, 
odp_queue_type_t qtype)
if (0 > odp_pktio_inq_setdef(pktio, inq_def))
return ODP_QUEUE_INVALID;
 
+   if (odp_pktio_start(pktio)) {
+   fprintf(stderr, "unable to start loop\n");
+   return ODP_QUEUE_INVALID;
+   }
+
return inq_def;
 }
 
-- 
2.6.2.406.gaaaec35


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


[lng-odp] [PATCH 09/10] linux-generic: pktio: configuration functions check that interface is stopped

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 platform/linux-generic/odp_packet_io.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index 9d5c971..1e9d08c 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -438,6 +438,10 @@ int odp_pktio_inq_setdef(odp_pktio_t id, odp_queue_t queue)
return -1;
 
lock_entry(pktio_entry);
+   if (pktio_entry->s.state != STATE_STOP) {
+   unlock_entry(pktio_entry);
+   return -1;
+   }
pktio_entry->s.inq_default = queue;
unlock_entry(pktio_entry);
 
@@ -476,6 +480,10 @@ int odp_pktio_inq_remdef(odp_pktio_t id)
return -1;
 
lock_entry(pktio_entry);
+   if (pktio_entry->s.state != STATE_STOP) {
+   unlock_entry(pktio_entry);
+   return -1;
+   }
queue = pktio_entry->s.inq_default;
qentry = queue_to_qentry(queue);
 
@@ -756,6 +764,10 @@ int odp_pktio_promisc_mode_set(odp_pktio_t id, odp_bool_t 
enable)
ODP_DBG("already freed pktio\n");
return -1;
}
+   if (entry->s.state != STATE_STOP) {
+   unlock_entry(entry);
+   return -1;
+   }
 
ret = entry->s.ops->promisc_mode_set(entry, enable);
 
-- 
2.6.2.406.gaaaec35


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


[lng-odp] [PATCH 08/10] linux-generic: pktio: check for pktio_start when started and pktio_stop when stopped

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 platform/linux-generic/odp_packet_io.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index 4d574ad..9d5c971 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -299,6 +299,10 @@ int odp_pktio_start(odp_pktio_t id)
return -1;
 
lock_entry(entry);
+   if (entry->s.state == STATE_START) {
+   unlock_entry(entry);
+   return -1;
+   }
if (entry->s.ops->start)
res = entry->s.ops->start(entry);
if (!res)
@@ -312,6 +316,9 @@ static int _pktio_stop(pktio_entry_t *entry)
 {
int res = 0;
 
+   if (entry->s.state == STATE_STOP)
+   return -1;
+
if (entry->s.ops->stop)
res = entry->s.ops->stop(entry);
if (!res)
-- 
2.6.2.406.gaaaec35


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


[lng-odp] [PATCH 07/10] validation: classification: stronger checks to avoid SEGV on pktio failure

2015-11-10 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 .../classification/odp_classification_test_pmr.c   | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/test/validation/classification/odp_classification_test_pmr.c 
b/test/validation/classification/odp_classification_test_pmr.c
index 94bd698..909ea3e 100644
--- a/test/validation/classification/odp_classification_test_pmr.c
+++ b/test/validation/classification/odp_classification_test_pmr.c
@@ -83,7 +83,7 @@ odp_queue_t create_default_inq(odp_pktio_t pktio, 
odp_queue_type_t qtype)
ODP_QUEUE_TYPE_PKTIN,
qtype == ODP_QUEUE_TYPE_POLL ? NULL : &qparam);
 
-   CU_ASSERT(inq_def != ODP_QUEUE_INVALID);
+   CU_ASSERT_FATAL(inq_def != ODP_QUEUE_INVALID);
 
if (0 > odp_pktio_inq_setdef(pktio, inq_def))
return ODP_QUEUE_INVALID;
@@ -131,9 +131,9 @@ static void classification_test_pmr_term_tcp_dport(void)
seqno = 0;
 
pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
-   CU_ASSERT(pktio != ODP_PKTIO_INVALID);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
defqueue = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
-   CU_ASSERT(defqueue != ODP_QUEUE_INVALID);
+   CU_ASSERT_FATAL(defqueue != ODP_QUEUE_INVALID);
 
match.term = ODP_PMR_TCP_DPORT;
match.val = &val;
@@ -220,7 +220,9 @@ static void classification_test_pmr_term_tcp_sport(void)
seqno = 0;
 
pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
defqueue = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
+   CU_ASSERT_FATAL(defqueue != ODP_QUEUE_INVALID);
 
match.term = ODP_PMR_TCP_SPORT;
match.val = &val;
@@ -305,7 +307,9 @@ static void classification_test_pmr_term_udp_dport(void)
seqno = 0;
 
pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
defqueue = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
+   CU_ASSERT_FATAL(defqueue != ODP_QUEUE_INVALID);
 
match.term = ODP_PMR_UDP_DPORT;
match.val = &val;
@@ -391,7 +395,9 @@ static void classification_test_pmr_term_udp_sport(void)
seqno = 0;
 
pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
defqueue = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
+   CU_ASSERT_FATAL(defqueue != ODP_QUEUE_INVALID);
 
match.term = ODP_PMR_UDP_SPORT;
match.val = &val;
@@ -475,7 +481,9 @@ static void classification_test_pmr_term_ipproto(void)
seqno = 0;
 
pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
defqueue = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
+   CU_ASSERT_FATAL(defqueue != ODP_QUEUE_INVALID);
 
match.term = ODP_PMR_IPPROTO;
match.val = &val;
-- 
2.6.2.406.gaaaec35


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


[lng-odp] [PATCH 10/10] validation: pktio: add test for start when started and stop when stopped()

2015-11-10 Thread Nicolas Morey-Chaisemartin
Also checks that interface are stopped by default

Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/pktio/pktio.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index e5458c4..8d41a2f 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -720,12 +720,17 @@ static void pktio_test_start_stop(void)
 
outq = odp_pktio_outq_getdef(pktio[0]);
 
+   /* Interfaces are stopped by default,
+* Check that stop when stopped generates an error */
ret = odp_pktio_stop(pktio[0]);
-   CU_ASSERT(ret == 0);
+   CU_ASSERT(ret <= 0);
 
/* start first */
ret = odp_pktio_start(pktio[0]);
CU_ASSERT(ret == 0);
+   /* Check that start when started generates an error */
+   ret = odp_pktio_start(pktio[0]);
+   CU_ASSERT(ret < 0);
 
/* Test Rx on a stopped interface. Only works if there are 2 */
if (num_ifaces > 1) {
-- 
2.6.2.406.gaaaec35

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


[lng-odp] [PATCH 0/4] AES128-GCM support

2015-11-12 Thread Nicolas Morey-Chaisemartin
This patch series ads support for AES128-GCM;
The first 2 patches changes slightly the validation tests to allow check of 
both cipher and auth at the same time.


Nicolas Morey-Chaisemartin (4):
  validation: crypto: support validating both cipher and auth at the
same time
  validation: crypto: allow custom auth/cipher range
  api: crypto: Add AES1268-GCM support
  validation: crypto: add test for AES128-GCM

 include/odp/api/crypto.h   |   4 +
 .../linux-generic/include/odp_crypto_internal.h|   3 +
 platform/linux-generic/odp_crypto.c| 183 
 test/validation/crypto/crypto.h|   4 +
 test/validation/crypto/odp_crypto_test_inp.c   | 235 ++---
 test/validation/crypto/test_vectors.h  | 152 +
 test/validation/crypto/test_vectors_len.h  |   7 +
 7 files changed, 561 insertions(+), 27 deletions(-)

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


[lng-odp] [API-NEXT PATCH 1/4] validation: crypto: support validating both cipher and auth at the same time

2015-11-12 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/odp_crypto_test_inp.c | 64 +++-
 1 file changed, 35 insertions(+), 29 deletions(-)

diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 5295c63..3b95f20 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -35,10 +35,13 @@ static void alg_test(odp_crypto_op_t op,
 odp_crypto_key_t cipher_key,
 odp_auth_alg_t auth_alg,
 odp_crypto_key_t auth_key,
-uint8_t *input_vec,
-unsigned int input_vec_len,
-uint8_t *output_vec,
-unsigned int output_vec_len)
+const uint8_t *plaintext,
+unsigned int plaintext_len,
+const uint8_t *ciphertext,
+unsigned int ciphertext_len,
+const uint8_t *digest,
+unsigned int digest_len
+)
 {
odp_crypto_session_t session;
int rc;
@@ -69,10 +72,11 @@ static void alg_test(odp_crypto_op_t op,
  odp_crypto_session_to_u64(ODP_CRYPTO_SESSION_INVALID));
 
/* Prepare input data */
-   odp_packet_t pkt = odp_packet_alloc(suite_context.pool, input_vec_len);
+   odp_packet_t pkt = odp_packet_alloc(suite_context.pool,
+   plaintext_len + digest_len);
CU_ASSERT(pkt != ODP_PACKET_INVALID);
uint8_t *data_addr = odp_packet_data(pkt);
-   memcpy(data_addr, input_vec, input_vec_len);
+   memcpy(data_addr, plaintext, plaintext_len);
const int data_off = 0;
 
/* Prepare input/output params */
@@ -82,20 +86,15 @@ static void alg_test(odp_crypto_op_t op,
op_params.pkt = pkt;
op_params.out_pkt = pkt;
op_params.ctx = (void *)0xdeadbeef;
-   if (cipher_alg != ODP_CIPHER_ALG_NULL &&
-   auth_alg == ODP_AUTH_ALG_NULL) {
-   op_params.cipher_range.offset = data_off;
-   op_params.cipher_range.length = input_vec_len;
-   if (op_iv_ptr)
-   op_params.override_iv_ptr = op_iv_ptr;
-   } else if (cipher_alg == ODP_CIPHER_ALG_NULL &&
-auth_alg != ODP_AUTH_ALG_NULL) {
-   op_params.auth_range.offset = data_off;
-   op_params.auth_range.length = input_vec_len;
-   op_params.hash_result_offset = data_off;
-   } else {
-   CU_FAIL("%s : not implemented for combined alg mode\n");
-   }
+
+   op_params.cipher_range.offset = data_off;
+   op_params.cipher_range.length = plaintext_len;
+   if (op_iv_ptr)
+   op_params.override_iv_ptr = op_iv_ptr;
+
+   op_params.auth_range.offset = data_off;
+   op_params.auth_range.length = plaintext_len;
+   op_params.hash_result_offset = plaintext_len;
 
rc = odp_crypto_operation(&op_params, &posted, &result);
if (rc < 0) {
@@ -119,7 +118,12 @@ static void alg_test(odp_crypto_op_t op,
CU_ASSERT(result.ok);
CU_ASSERT(result.pkt == pkt);
 
-   CU_ASSERT(!memcmp(data_addr, output_vec, output_vec_len));
+   if (cipher_alg != ODP_CIPHER_ALG_NULL)
+   CU_ASSERT(!memcmp(data_addr, ciphertext, ciphertext_len));
+
+   if (op == ODP_CRYPTO_OP_ENCODE && auth_alg != ODP_AUTH_ALG_NULL)
+   CU_ASSERT(!memcmp(data_addr + op_params.hash_result_offset,
+ digest, digest_len));
 
CU_ASSERT(result.ctx == (void *)0xdeadbeef);
 cleanup:
@@ -158,7 +162,7 @@ void crypto_test_enc_alg_3des_cbc(void)
 tdes_cbc_reference_plaintext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_ciphertext[i],
-tdes_cbc_reference_length[i]);
+tdes_cbc_reference_length[i], NULL, 0);
}
 }
 
@@ -188,7 +192,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void)
 tdes_cbc_reference_plaintext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_ciphertext[i],
-tdes_cbc_reference_length[i]);
+tdes_cbc_reference_length[i], NULL, 0);
}
 }
 
@@ -223,7 +227,7 @@ void crypto_test_dec_alg_3des_cbc(void)
 tdes_cbc_reference_ciphertext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_plaintext[i],
-tdes_cbc_reference_length[i]);
+tdes_cbc_reference_length[i], NULL, 0);
}
 }
 
@@ -255,7 +259,7 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void)
   

[lng-odp] [API-NEXT PATCH 2/4] validation: crypto: allow custom auth/cipher range

2015-11-12 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/odp_crypto_test_inp.c | 31 +++-
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 3b95f20..30cb35e 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -35,6 +35,8 @@ static void alg_test(odp_crypto_op_t op,
 odp_crypto_key_t cipher_key,
 odp_auth_alg_t auth_alg,
 odp_crypto_key_t auth_key,
+odp_crypto_data_range_t *cipher_range,
+odp_crypto_data_range_t *auth_range,
 const uint8_t *plaintext,
 unsigned int plaintext_len,
 const uint8_t *ciphertext,
@@ -77,7 +79,7 @@ static void alg_test(odp_crypto_op_t op,
CU_ASSERT(pkt != ODP_PACKET_INVALID);
uint8_t *data_addr = odp_packet_data(pkt);
memcpy(data_addr, plaintext, plaintext_len);
-   const int data_off = 0;
+   int data_off = 0;
 
/* Prepare input/output params */
odp_crypto_op_params_t op_params;
@@ -87,13 +89,22 @@ static void alg_test(odp_crypto_op_t op,
op_params.out_pkt = pkt;
op_params.ctx = (void *)0xdeadbeef;
 
-   op_params.cipher_range.offset = data_off;
-   op_params.cipher_range.length = plaintext_len;
+   if (cipher_range) {
+   op_params.cipher_range = *cipher_range;
+   data_off = cipher_range->offset;
+   } else {
+   op_params.cipher_range.offset = data_off;
+   op_params.cipher_range.length = plaintext_len;
+   }
+   if (auth_range) {
+   op_params.auth_range = *auth_range;
+   } else {
+   op_params.auth_range.offset = data_off;
+   op_params.auth_range.length = plaintext_len;
+   }
if (op_iv_ptr)
op_params.override_iv_ptr = op_iv_ptr;
 
-   op_params.auth_range.offset = data_off;
-   op_params.auth_range.length = plaintext_len;
op_params.hash_result_offset = plaintext_len;
 
rc = odp_crypto_operation(&op_params, &posted, &result);
@@ -159,6 +170,7 @@ void crypto_test_enc_alg_3des_cbc(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 tdes_cbc_reference_plaintext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_ciphertext[i],
@@ -189,6 +201,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 tdes_cbc_reference_plaintext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_ciphertext[i],
@@ -224,6 +237,7 @@ void crypto_test_dec_alg_3des_cbc(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 tdes_cbc_reference_ciphertext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_plaintext[i],
@@ -256,6 +270,7 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 tdes_cbc_reference_ciphertext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_plaintext[i],
@@ -289,6 +304,7 @@ void crypto_test_enc_alg_aes128_cbc(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 aes128_cbc_reference_plaintext[i],
 aes128_cbc_reference_length[i],
 aes128_cbc_reference_ciphertext[i],
@@ -319,6 +335,7 @@ void crypto_test_enc_alg_aes128_cbc_ovr_iv(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 aes128_cbc_reference_plaintext[i],
 aes128_cbc_reference_length[i],
 aes128_cbc_reference_ciphertext[i],
@@ -353,6 +370,7 @@ void crypto_test_dec_alg_aes128_cbc(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 aes128_cbc_reference_ciphertext[i],
 aes128_cbc_ref

[lng-odp] [API-NEXT PATCH 3/4] api: crypto: Add AES1268-GCM support

2015-11-12 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 include/odp/api/crypto.h   |   4 +
 .../linux-generic/include/odp_crypto_internal.h|   3 +
 platform/linux-generic/odp_crypto.c| 183 +
 3 files changed, 190 insertions(+)

diff --git a/include/odp/api/crypto.h b/include/odp/api/crypto.h
index c62021e..41beedb 100644
--- a/include/odp/api/crypto.h
+++ b/include/odp/api/crypto.h
@@ -70,6 +70,8 @@ typedef enum {
ODP_CIPHER_ALG_3DES_CBC,
/** AES128 with cipher block chaining */
ODP_CIPHER_ALG_AES128_CBC,
+   /** AES128 in Galois/Counter Mode */
+   ODP_CIPHER_ALG_AES128_GCM,
 } odp_cipher_alg_t;
 
 /**
@@ -82,6 +84,8 @@ typedef enum {
ODP_AUTH_ALG_MD5_96,
/** SHA256 with 128 bit key */
ODP_AUTH_ALG_SHA256_128,
+   /** AES128 in Galois/Counter Mode */
+   ODP_AUTH_ALG_AES128_GCM,
 } odp_auth_alg_t;
 
 /**
diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index b9128a4..7b104af 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -50,6 +50,9 @@ struct odp_crypto_generic_session {
struct {
AES_KEY key;
} aes;
+   struct {
+   EVP_CIPHER_CTX *ctx;
+   } aes_gcm;
} data;
crypto_func_t func;
} cipher;
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index 17fced9..65e8503 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -292,6 +292,170 @@ int process_aes_params(odp_crypto_generic_session_t 
*session,
 }
 
 static
+odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_params_t *params,
+odp_crypto_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint32_t plain_len   = params->cipher_range.length;
+   uint8_t *aad_head = data + params->auth_range.offset;
+   uint8_t *aad_tail = data + params->cipher_range.offset +
+   params->cipher_range.length;
+   uint32_t auth_len = params->auth_range.length;
+   unsigned char iv_enc[AES_BLOCK_SIZE];
+   void *iv_ptr;
+   uint8_t *tag = data + params->hash_result_offset;
+
+   if (params->override_iv_ptr)
+   iv_ptr = params->override_iv_ptr;
+   else if (session->cipher.iv.data)
+   iv_ptr = session->cipher.iv.data;
+   else
+   return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+
+   /* All cipher data must be part of the authentication */
+   if (params->auth_range.offset > params->cipher_range.offset ||
+   params->auth_range.offset + auth_len <
+   params->cipher_range.offset + plain_len)
+   return ODP_CRYPTO_ALG_ERR_DATA_SIZE;
+
+   /*
+* Create a copy of the IV.  The DES library modifies IV
+* and if we are processing packets on parallel threads
+* we could get corruption.
+*/
+   memcpy(iv_enc, iv_ptr, AES_BLOCK_SIZE);
+
+   /* Adjust pointer for beginning of area to cipher/auth */
+   uint8_t *plaindata = data + params->cipher_range.offset;
+
+   /* Encrypt it */
+   EVP_CIPHER_CTX *ctx = session->cipher.data.aes_gcm.ctx;
+   int cipher_len = 0;
+
+   EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_enc);
+
+   /* Authenticate header data (if any) without encrypting them */
+   if (aad_head < plaindata) {
+   EVP_EncryptUpdate(ctx, NULL, &cipher_len,
+ aad_head, plaindata - aad_head);
+   }
+
+   EVP_EncryptUpdate(ctx, plaindata, &cipher_len,
+ plaindata, plain_len);
+   cipher_len = plain_len;
+
+   /* Authenticate footer data (if any) without encrypting them */
+   if (aad_head + auth_len > plaindata + plain_len) {
+   EVP_EncryptUpdate(ctx, NULL, NULL, aad_tail,
+ auth_len - (aad_tail - aad_head));
+   }
+
+   EVP_EncryptFinal_ex(ctx, plaindata + cipher_len, &cipher_len);
+   EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, 16, tag);
+
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
+odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_params_t *params,
+odp_crypto_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint32_t cipher_len   = params->cipher_range.length;
+   uint8_t *aad_head = data + params->auth_range.offset;
+   uint8_t *aad_tail = data + params->cipher_range.offset +
+   params->cipher_range.length;
+   uint32_t auth_len = par

[lng-odp] [API-NEXT PATCH 4/4] validation: crypto: add test for AES128-GCM

2015-11-12 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/crypto.h  |   4 +
 test/validation/crypto/odp_crypto_test_inp.c | 154 +++
 test/validation/crypto/test_vectors.h| 152 ++
 test/validation/crypto/test_vectors_len.h|   7 ++
 4 files changed, 317 insertions(+)

diff --git a/test/validation/crypto/crypto.h b/test/validation/crypto/crypto.h
index 4769fad..5224e47 100644
--- a/test/validation/crypto/crypto.h
+++ b/test/validation/crypto/crypto.h
@@ -18,6 +18,10 @@ void crypto_test_enc_alg_aes128_cbc(void);
 void crypto_test_enc_alg_aes128_cbc_ovr_iv(void);
 void crypto_test_dec_alg_aes128_cbc(void);
 void crypto_test_dec_alg_aes128_cbc_ovr_iv(void);
+void crypto_test_enc_alg_aes128_gcm(void);
+void crypto_test_enc_alg_aes128_gcm_ovr_iv(void);
+void crypto_test_dec_alg_aes128_gcm(void);
+void crypto_test_dec_alg_aes128_gcm_ovr_iv(void);
 void crypto_test_alg_hmac_md5(void);
 void crypto_test_alg_hmac_sha256(void);
 
diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 30cb35e..b6fcb12 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -279,6 +279,156 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void)
 }
 
 /* This test verifies the correctness of encode (plaintext -> ciphertext)
+ * operation for AES128_GCM algorithm. IV for the operation is the session IV.
+ * In addition the test verifies if the implementation can use the
+ * packet buffer as completion event buffer.*/
+void crypto_test_enc_alg_aes128_gcm(void)
+{
+   odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+auth_key   = { .data = NULL, .length = 0 };
+   odp_crypto_iv_t iv = { .data = NULL, .length = AES128_GCM_IV_LEN };
+   unsigned int test_vec_num = (sizeof(aes128_gcm_reference_length) /
+sizeof(aes128_gcm_reference_length[0]));
+   unsigned int i;
+
+   for (i = 0; i < test_vec_num; i++) {
+   cipher_key.data = aes128_gcm_reference_key[i];
+   cipher_key.length = sizeof(aes128_gcm_reference_key[i]);
+   iv.data = aes128_gcm_reference_iv[i];
+   iv.length = sizeof(aes128_gcm_reference_iv[i]);
+
+   alg_test(ODP_CRYPTO_OP_ENCODE,
+ODP_CIPHER_ALG_AES128_GCM,
+iv,
+NULL,
+cipher_key,
+ODP_AUTH_ALG_AES128_GCM,
+auth_key,
+&aes128_gcm_cipher_range[i],
+&aes128_gcm_auth_range[i],
+aes128_gcm_reference_plaintext[i],
+aes128_gcm_reference_length[i],
+aes128_gcm_reference_ciphertext[i],
+aes128_gcm_reference_length[i],
+aes128_gcm_reference_ciphertext[i] +
+aes128_gcm_reference_length[i],
+AES128_GCM_CHECK_LEN);
+   }
+}
+
+/* This test verifies the correctness of encode (plaintext -> ciphertext)
+ * operation for AES128_GCM algorithm. IV for the operation is the session IV.
+ * In addition the test verifies if the implementation can use the
+ * packet buffer as completion event buffer.*/
+void crypto_test_enc_alg_aes128_gcm_ovr_iv(void)
+{
+   odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+auth_key   = { .data = NULL, .length = 0 };
+   odp_crypto_iv_t iv = { .data = NULL, .length = AES128_GCM_IV_LEN };
+   unsigned int test_vec_num = (sizeof(aes128_gcm_reference_length) /
+sizeof(aes128_gcm_reference_length[0]));
+   unsigned int i;
+
+   for (i = 0; i < test_vec_num; i++) {
+   cipher_key.data = aes128_gcm_reference_key[i];
+   cipher_key.length = sizeof(aes128_gcm_reference_key[i]);
+
+   alg_test(ODP_CRYPTO_OP_ENCODE,
+ODP_CIPHER_ALG_AES128_GCM,
+iv,
+aes128_gcm_reference_iv[i],
+cipher_key,
+ODP_AUTH_ALG_AES128_GCM,
+auth_key,
+&aes128_gcm_cipher_range[i],
+&aes128_gcm_auth_range[i],
+aes128_gcm_reference_plaintext[i],
+aes128_gcm_reference_length[i],
+aes128_gcm_reference_ciphertext[i],
+aes128_gcm_reference_length[i],
+aes128_gcm_reference_ciphertext[i] +
+aes128_gcm_reference_length[i],
+AES128_GCM_CHECK_LEN);
+   }
+}
+
+/* This test verifies the correctness of decode (ciphertext -> plaintext)
+ * operation for

Re: [lng-odp] pktio selection

2015-11-12 Thread Nicolas Morey-Chaisemartin
Hi,

I like this.
It seems more robust and easier extended than all the environment variable.

We should also keep the basic portname. Ideally io_ops should be in performance 
order so if I write generic code that uses en0,
 it'll try netmap, then sock_mmap and finally fallback to standard sockets if 
others won't work.

And/ Or a way to manually specify fallbacks:
NETMAP::SOCKET_MMAP::SOCKET:eth0

Nicolas

On 11/12/2015 02:38 PM, Bala Manoharan wrote:
> Hi,
>
> I went through the same issue as well..
> In ODP we have defined that the dev-name is implementation specific
> and hence I like the idea to add socket type to dev-name something
> like "SOCKET_MMAP:eth0"/ "NETMAP: eth0" and this maps well with the
> ODP definition for device name.
>
> Regards,
> Bala
>
> On 12 November 2015 at 18:23, Christophe Milard
>  wrote:
>> Hi,
>>
>> Today, as far as I can see (at least for linux generic), the type of pktio
>> selected at open time depends on:
>> 1) the priority order defined in pktio_io/io_ops.c (currentely: netmap mmap
>> socket and usual sockets)
>> 2)A set of environment variable (ODP_PKTIO_DISABLE_NETMAP,
>> ODP_PKTIO_DISABLE_SOCKET_MMAP...) from which the order defined in 1) can be
>> changed...
>> 3)Some mechanism taking the device name as a hint (looback, pcap...)
>>
>> I am not sure I really understand why this is done so, and how these
>> mechanism can be extented:
>>
>> I can see a future in which a odp application will need to talk (read send
>> and receive packet) to different type of pktio at the same time. Possibly
>> one to the linux jernel (Ravineet's work), some  normal sockets (possibly
>> netmapped) and some NICs (possibly many) -my problem- and surely some
>> more to come.
>>
>> Aren't we missing a proper pktio selection mechanism? Can/Should the
>> application be really pktio-type (un)aware?.
>>
>> A first hack could be having a dev name like: "NIC:" to start a
>> PMD driver on the nic at that address, but by choosing specific dev name the
>> application becomes well aware of the  pktio devices anyway
>> The underlying question is also whether ODP should be performing PCI
>> enumeration and how NIC should be selected...
>>
>> Christophe.
>>
>>
>>
>>
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp

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


[lng-odp] [PATCH] platform: move list of API files to Makefile.inc so it is common to all platforms

2015-11-12 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 platform/Makefile.inc  | 39 ++
 platform/linux-generic/Makefile.am | 39 --
 2 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/platform/Makefile.inc b/platform/Makefile.inc
index 8e8e97b..14e134c 100644
--- a/platform/Makefile.inc
+++ b/platform/Makefile.inc
@@ -15,3 +15,42 @@ AM_LDFLAGS += -version-number '$(ODP_LIBSO_VERSION)'
 GIT_DESC = `$(top_srcdir)/scripts/git_hash.sh $(top_srcdir)`
 AM_CFLAGS += "-DGIT_HASH=$(GIT_DESC)"
 AM_CFLAGS += -DPLATFORM=${with_platform}
+
+odpapiincludedir= $(includedir)/odp/api
+odpapiinclude_HEADERS = \
+ $(top_srcdir)/include/odp/api/align.h \
+ $(top_srcdir)/include/odp/api/atomic.h \
+ $(top_srcdir)/include/odp/api/barrier.h \
+ $(top_srcdir)/include/odp/api/buffer.h \
+ $(top_srcdir)/include/odp/api/byteorder.h \
+ $(top_srcdir)/include/odp/api/classification.h \
+ $(top_srcdir)/include/odp/api/compiler.h \
+ $(top_srcdir)/include/odp/api/config.h \
+ $(top_srcdir)/include/odp/api/cpu.h \
+ $(top_srcdir)/include/odp/api/cpumask.h \
+ $(top_srcdir)/include/odp/api/crypto.h \
+ $(top_srcdir)/include/odp/api/debug.h \
+ $(top_srcdir)/include/odp/api/errno.h \
+ $(top_srcdir)/include/odp/api/event.h \
+ $(top_srcdir)/include/odp/api/hints.h \
+ $(top_srcdir)/include/odp/api/init.h \
+ $(top_srcdir)/include/odp/api/packet.h \
+ $(top_srcdir)/include/odp/api/packet_flags.h \
+ $(top_srcdir)/include/odp/api/packet_io.h \
+ $(top_srcdir)/include/odp/api/pool.h \
+ $(top_srcdir)/include/odp/api/queue.h \
+ $(top_srcdir)/include/odp/api/random.h \
+ $(top_srcdir)/include/odp/api/rwlock.h \
+ $(top_srcdir)/include/odp/api/schedule.h \
+ $(top_srcdir)/include/odp/api/schedule_types.h \
+ $(top_srcdir)/include/odp/api/shared_memory.h \
+ $(top_srcdir)/include/odp/api/spinlock.h \
+ $(top_srcdir)/include/odp/api/std_types.h \
+ $(top_srcdir)/include/odp/api/sync.h \
+ $(top_srcdir)/include/odp/api/system_info.h \
+ $(top_srcdir)/include/odp/api/thread.h \
+ $(top_srcdir)/include/odp/api/thrmask.h \
+ $(top_srcdir)/include/odp/api/ticketlock.h \
+ $(top_srcdir)/include/odp/api/time.h \
+ $(top_srcdir)/include/odp/api/timer.h \
+ $(top_srcdir)/include/odp/api/version.h
\ No newline at end of file
diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 0135947..610e04d 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -73,45 +73,6 @@ odpplatinclude_HEADERS = \
  $(srcdir)/include/odp/plat/timer_types.h \
  $(srcdir)/include/odp/plat/version_types.h
 
-odpapiincludedir= $(includedir)/odp/api
-odpapiinclude_HEADERS = \
- $(top_srcdir)/include/odp/api/align.h \
- $(top_srcdir)/include/odp/api/atomic.h \
- $(top_srcdir)/include/odp/api/barrier.h \
- $(top_srcdir)/include/odp/api/buffer.h \
- $(top_srcdir)/include/odp/api/byteorder.h \
- $(top_srcdir)/include/odp/api/classification.h \
- $(top_srcdir)/include/odp/api/compiler.h \
- $(top_srcdir)/include/odp/api/config.h \
- $(top_srcdir)/include/odp/api/cpu.h \
- $(top_srcdir)/include/odp/api/cpumask.h \
- $(top_srcdir)/include/odp/api/crypto.h \
- $(top_srcdir)/include/odp/api/debug.h \
- $(top_srcdir)/include/odp/api/errno.h \
- $(top_srcdir)/include/odp/api/event.h \
- $(top_srcdir)/include/odp/api/hints.h \
- $(top_srcdir)/include/odp/api/init.h \
- $(top_srcdir)/include/odp/api/packet.h \
- $(top_srcdir)/include/odp/api/packet_flags.h \
- $(top_srcdir)/include/odp/api/packet_io.h \
- $(top_srcdir)/include/odp/api/pool.h \
- $(top_srcdir)/include/odp/api/queue.h \
- $(top_srcdir)/include/odp/api/random.h \
- $(top_srcdir)/include/odp/api/rwlock.h \
- $(top_srcdir)/include/odp/api/schedule.h \
- $(top_srcdir)/include/odp/api/schedule_types.h \
- $(top_srcdir)/include/odp/api/shared_memory.h \
- $(top_srcdir)/include/odp/api/spinlock.h \
- $(top_srcdir)/include

[lng-odp] [PATCH] validation: crypto: limit packet size to maximum supported by platform

2015-11-12 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/crypto.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/validation/crypto/crypto.c b/test/validation/crypto/crypto.c
index 9229cab..1234f78 100644
--- a/test/validation/crypto/crypto.c
+++ b/test/validation/crypto/crypto.c
@@ -42,6 +42,9 @@ int crypto_init(void)
params.pkt.num = SHM_PKT_POOL_SIZE / SHM_PKT_POOL_BUF_SIZE;
params.type= ODP_POOL_PACKET;
 
+   if (SHM_PKT_POOL_BUF_SIZE > odp_config_packet_buf_len_max())
+   params.pkt.len = odp_config_packet_buf_len_max();
+
pool = odp_pool_create("packet_pool", ¶ms);
 
if (ODP_POOL_INVALID == pool) {
-- 
2.6.2.406.gaaaec35

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


Re: [lng-odp] [PATCH 1/1] Initial addition of isolation support

2015-11-13 Thread Nicolas Morey-Chaisemartin


On 11/13/2015 07:56 PM, Mike Holmes wrote:
>
>
> On 13 November 2015 at 13:51, Gary Robertson  > wrote:
>
> Oops - clicked the wrong reply option.
>
> Nicolas raises an excellent point.  I think at least a configuration 
> option may be needed to enable or disable isolation.
>
>
> I think that ./configure should check for the support and it if it is 
> available provided the configure option --enable-test-isolated, this is how 
> nearly all our other optional capabilities work. In this case if support is 
> there the default would be to enable --enable-test-isolated
It is. But the latest talk about RPM packaging and runtime compatibility tends 
to move thing another way.
I guess we want to move as many things as possible to runtime init so a single 
compile binary can leverage the best performance on whatever platform it is 
running (as long as it is ABI compliant)

Nicolas

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


[lng-odp] [API-NEXT PATCHv2 0/4] AES125-GCM support

2015-11-16 Thread Nicolas Morey-Chaisemartin
This patch series adds support for AES128-GCM;
The first 2 patches changes slightly the validation tests to allow check of 
both cipher and auth at the same time.

v2:
* Fix typo in 3rd patch name

API changed
Reviewed-by: Petri Savolainen 

Nicolas Morey-Chaisemartin (4):
  validation: crypto: support validating both cipher and auth at the
same time
  validation: crypto: allow custom auth/cipher range
  api: crypto: Add AES128-GCM support
  validation: crypto: add test for AES128-GCM

 include/odp/api/crypto.h   |   4 +
 .../linux-generic/include/odp_crypto_internal.h|   3 +
 platform/linux-generic/odp_crypto.c| 183 
 test/validation/crypto/crypto.h|   4 +
 test/validation/crypto/odp_crypto_test_inp.c   | 235 ++---
 test/validation/crypto/test_vectors.h  | 152 +
 test/validation/crypto/test_vectors_len.h  |   7 +
 7 files changed, 561 insertions(+), 27 deletions(-)

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


[lng-odp] [API-NEXT PATCHv2 1/4] validation: crypto: support validating both cipher and auth at the same time

2015-11-16 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/odp_crypto_test_inp.c | 64 +++-
 1 file changed, 35 insertions(+), 29 deletions(-)

diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 5295c63..3b95f20 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -35,10 +35,13 @@ static void alg_test(odp_crypto_op_t op,
 odp_crypto_key_t cipher_key,
 odp_auth_alg_t auth_alg,
 odp_crypto_key_t auth_key,
-uint8_t *input_vec,
-unsigned int input_vec_len,
-uint8_t *output_vec,
-unsigned int output_vec_len)
+const uint8_t *plaintext,
+unsigned int plaintext_len,
+const uint8_t *ciphertext,
+unsigned int ciphertext_len,
+const uint8_t *digest,
+unsigned int digest_len
+)
 {
odp_crypto_session_t session;
int rc;
@@ -69,10 +72,11 @@ static void alg_test(odp_crypto_op_t op,
  odp_crypto_session_to_u64(ODP_CRYPTO_SESSION_INVALID));
 
/* Prepare input data */
-   odp_packet_t pkt = odp_packet_alloc(suite_context.pool, input_vec_len);
+   odp_packet_t pkt = odp_packet_alloc(suite_context.pool,
+   plaintext_len + digest_len);
CU_ASSERT(pkt != ODP_PACKET_INVALID);
uint8_t *data_addr = odp_packet_data(pkt);
-   memcpy(data_addr, input_vec, input_vec_len);
+   memcpy(data_addr, plaintext, plaintext_len);
const int data_off = 0;
 
/* Prepare input/output params */
@@ -82,20 +86,15 @@ static void alg_test(odp_crypto_op_t op,
op_params.pkt = pkt;
op_params.out_pkt = pkt;
op_params.ctx = (void *)0xdeadbeef;
-   if (cipher_alg != ODP_CIPHER_ALG_NULL &&
-   auth_alg == ODP_AUTH_ALG_NULL) {
-   op_params.cipher_range.offset = data_off;
-   op_params.cipher_range.length = input_vec_len;
-   if (op_iv_ptr)
-   op_params.override_iv_ptr = op_iv_ptr;
-   } else if (cipher_alg == ODP_CIPHER_ALG_NULL &&
-auth_alg != ODP_AUTH_ALG_NULL) {
-   op_params.auth_range.offset = data_off;
-   op_params.auth_range.length = input_vec_len;
-   op_params.hash_result_offset = data_off;
-   } else {
-   CU_FAIL("%s : not implemented for combined alg mode\n");
-   }
+
+   op_params.cipher_range.offset = data_off;
+   op_params.cipher_range.length = plaintext_len;
+   if (op_iv_ptr)
+   op_params.override_iv_ptr = op_iv_ptr;
+
+   op_params.auth_range.offset = data_off;
+   op_params.auth_range.length = plaintext_len;
+   op_params.hash_result_offset = plaintext_len;
 
rc = odp_crypto_operation(&op_params, &posted, &result);
if (rc < 0) {
@@ -119,7 +118,12 @@ static void alg_test(odp_crypto_op_t op,
CU_ASSERT(result.ok);
CU_ASSERT(result.pkt == pkt);
 
-   CU_ASSERT(!memcmp(data_addr, output_vec, output_vec_len));
+   if (cipher_alg != ODP_CIPHER_ALG_NULL)
+   CU_ASSERT(!memcmp(data_addr, ciphertext, ciphertext_len));
+
+   if (op == ODP_CRYPTO_OP_ENCODE && auth_alg != ODP_AUTH_ALG_NULL)
+   CU_ASSERT(!memcmp(data_addr + op_params.hash_result_offset,
+ digest, digest_len));
 
CU_ASSERT(result.ctx == (void *)0xdeadbeef);
 cleanup:
@@ -158,7 +162,7 @@ void crypto_test_enc_alg_3des_cbc(void)
 tdes_cbc_reference_plaintext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_ciphertext[i],
-tdes_cbc_reference_length[i]);
+tdes_cbc_reference_length[i], NULL, 0);
}
 }
 
@@ -188,7 +192,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void)
 tdes_cbc_reference_plaintext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_ciphertext[i],
-tdes_cbc_reference_length[i]);
+tdes_cbc_reference_length[i], NULL, 0);
}
 }
 
@@ -223,7 +227,7 @@ void crypto_test_dec_alg_3des_cbc(void)
 tdes_cbc_reference_ciphertext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_plaintext[i],
-tdes_cbc_reference_length[i]);
+tdes_cbc_reference_length[i], NULL, 0);
}
 }
 
@@ -255,7 +259,7 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void)
   

[lng-odp] [API-NEXT PATCHv2 2/4] validation: crypto: allow custom auth/cipher range

2015-11-16 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/odp_crypto_test_inp.c | 31 +++-
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 3b95f20..30cb35e 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -35,6 +35,8 @@ static void alg_test(odp_crypto_op_t op,
 odp_crypto_key_t cipher_key,
 odp_auth_alg_t auth_alg,
 odp_crypto_key_t auth_key,
+odp_crypto_data_range_t *cipher_range,
+odp_crypto_data_range_t *auth_range,
 const uint8_t *plaintext,
 unsigned int plaintext_len,
 const uint8_t *ciphertext,
@@ -77,7 +79,7 @@ static void alg_test(odp_crypto_op_t op,
CU_ASSERT(pkt != ODP_PACKET_INVALID);
uint8_t *data_addr = odp_packet_data(pkt);
memcpy(data_addr, plaintext, plaintext_len);
-   const int data_off = 0;
+   int data_off = 0;
 
/* Prepare input/output params */
odp_crypto_op_params_t op_params;
@@ -87,13 +89,22 @@ static void alg_test(odp_crypto_op_t op,
op_params.out_pkt = pkt;
op_params.ctx = (void *)0xdeadbeef;
 
-   op_params.cipher_range.offset = data_off;
-   op_params.cipher_range.length = plaintext_len;
+   if (cipher_range) {
+   op_params.cipher_range = *cipher_range;
+   data_off = cipher_range->offset;
+   } else {
+   op_params.cipher_range.offset = data_off;
+   op_params.cipher_range.length = plaintext_len;
+   }
+   if (auth_range) {
+   op_params.auth_range = *auth_range;
+   } else {
+   op_params.auth_range.offset = data_off;
+   op_params.auth_range.length = plaintext_len;
+   }
if (op_iv_ptr)
op_params.override_iv_ptr = op_iv_ptr;
 
-   op_params.auth_range.offset = data_off;
-   op_params.auth_range.length = plaintext_len;
op_params.hash_result_offset = plaintext_len;
 
rc = odp_crypto_operation(&op_params, &posted, &result);
@@ -159,6 +170,7 @@ void crypto_test_enc_alg_3des_cbc(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 tdes_cbc_reference_plaintext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_ciphertext[i],
@@ -189,6 +201,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 tdes_cbc_reference_plaintext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_ciphertext[i],
@@ -224,6 +237,7 @@ void crypto_test_dec_alg_3des_cbc(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 tdes_cbc_reference_ciphertext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_plaintext[i],
@@ -256,6 +270,7 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 tdes_cbc_reference_ciphertext[i],
 tdes_cbc_reference_length[i],
 tdes_cbc_reference_plaintext[i],
@@ -289,6 +304,7 @@ void crypto_test_enc_alg_aes128_cbc(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 aes128_cbc_reference_plaintext[i],
 aes128_cbc_reference_length[i],
 aes128_cbc_reference_ciphertext[i],
@@ -319,6 +335,7 @@ void crypto_test_enc_alg_aes128_cbc_ovr_iv(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 aes128_cbc_reference_plaintext[i],
 aes128_cbc_reference_length[i],
 aes128_cbc_reference_ciphertext[i],
@@ -353,6 +370,7 @@ void crypto_test_dec_alg_aes128_cbc(void)
 cipher_key,
 ODP_AUTH_ALG_NULL,
 auth_key,
+NULL, NULL,
 aes128_cbc_reference_ciphertext[i],
 aes128_cbc_ref

[lng-odp] [API-NEXT PATCHv2 3/4] api: crypto: Add AES128-GCM support

2015-11-16 Thread Nicolas Morey-Chaisemartin

Signed-off-by: Nicolas Morey-Chaisemartin 
---
 include/odp/api/crypto.h   |   4 +
 .../linux-generic/include/odp_crypto_internal.h|   3 +
 platform/linux-generic/odp_crypto.c| 183 +
 3 files changed, 190 insertions(+)

diff --git a/include/odp/api/crypto.h b/include/odp/api/crypto.h
index c62021e..41beedb 100644
--- a/include/odp/api/crypto.h
+++ b/include/odp/api/crypto.h
@@ -70,6 +70,8 @@ typedef enum {
ODP_CIPHER_ALG_3DES_CBC,
/** AES128 with cipher block chaining */
ODP_CIPHER_ALG_AES128_CBC,
+   /** AES128 in Galois/Counter Mode */
+   ODP_CIPHER_ALG_AES128_GCM,
 } odp_cipher_alg_t;
 
 /**
@@ -82,6 +84,8 @@ typedef enum {
ODP_AUTH_ALG_MD5_96,
/** SHA256 with 128 bit key */
ODP_AUTH_ALG_SHA256_128,
+   /** AES128 in Galois/Counter Mode */
+   ODP_AUTH_ALG_AES128_GCM,
 } odp_auth_alg_t;
 
 /**
diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index b9128a4..7b104af 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -50,6 +50,9 @@ struct odp_crypto_generic_session {
struct {
AES_KEY key;
} aes;
+   struct {
+   EVP_CIPHER_CTX *ctx;
+   } aes_gcm;
} data;
crypto_func_t func;
} cipher;
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index 17fced9..65e8503 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -292,6 +292,170 @@ int process_aes_params(odp_crypto_generic_session_t 
*session,
 }
 
 static
+odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_params_t *params,
+odp_crypto_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint32_t plain_len   = params->cipher_range.length;
+   uint8_t *aad_head = data + params->auth_range.offset;
+   uint8_t *aad_tail = data + params->cipher_range.offset +
+   params->cipher_range.length;
+   uint32_t auth_len = params->auth_range.length;
+   unsigned char iv_enc[AES_BLOCK_SIZE];
+   void *iv_ptr;
+   uint8_t *tag = data + params->hash_result_offset;
+
+   if (params->override_iv_ptr)
+   iv_ptr = params->override_iv_ptr;
+   else if (session->cipher.iv.data)
+   iv_ptr = session->cipher.iv.data;
+   else
+   return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+
+   /* All cipher data must be part of the authentication */
+   if (params->auth_range.offset > params->cipher_range.offset ||
+   params->auth_range.offset + auth_len <
+   params->cipher_range.offset + plain_len)
+   return ODP_CRYPTO_ALG_ERR_DATA_SIZE;
+
+   /*
+* Create a copy of the IV.  The DES library modifies IV
+* and if we are processing packets on parallel threads
+* we could get corruption.
+*/
+   memcpy(iv_enc, iv_ptr, AES_BLOCK_SIZE);
+
+   /* Adjust pointer for beginning of area to cipher/auth */
+   uint8_t *plaindata = data + params->cipher_range.offset;
+
+   /* Encrypt it */
+   EVP_CIPHER_CTX *ctx = session->cipher.data.aes_gcm.ctx;
+   int cipher_len = 0;
+
+   EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_enc);
+
+   /* Authenticate header data (if any) without encrypting them */
+   if (aad_head < plaindata) {
+   EVP_EncryptUpdate(ctx, NULL, &cipher_len,
+ aad_head, plaindata - aad_head);
+   }
+
+   EVP_EncryptUpdate(ctx, plaindata, &cipher_len,
+ plaindata, plain_len);
+   cipher_len = plain_len;
+
+   /* Authenticate footer data (if any) without encrypting them */
+   if (aad_head + auth_len > plaindata + plain_len) {
+   EVP_EncryptUpdate(ctx, NULL, NULL, aad_tail,
+ auth_len - (aad_tail - aad_head));
+   }
+
+   EVP_EncryptFinal_ex(ctx, plaindata + cipher_len, &cipher_len);
+   EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, 16, tag);
+
+   return ODP_CRYPTO_ALG_ERR_NONE;
+}
+
+static
+odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_params_t *params,
+odp_crypto_generic_session_t *session)
+{
+   uint8_t *data  = odp_packet_data(params->out_pkt);
+   uint32_t cipher_len   = params->cipher_range.length;
+   uint8_t *aad_head = data + params->auth_range.offset;
+   uint8_t *aad_tail = data + params->cipher_range.offset +
+   params->cipher_range.length;
+   uint32_t auth_len = par

[lng-odp] [API-NEXT PATCHv2 4/4] validation: crypto: add test for AES128-GCM

2015-11-16 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/crypto.h  |   4 +
 test/validation/crypto/odp_crypto_test_inp.c | 154 +++
 test/validation/crypto/test_vectors.h| 152 ++
 test/validation/crypto/test_vectors_len.h|   7 ++
 4 files changed, 317 insertions(+)

diff --git a/test/validation/crypto/crypto.h b/test/validation/crypto/crypto.h
index 4769fad..5224e47 100644
--- a/test/validation/crypto/crypto.h
+++ b/test/validation/crypto/crypto.h
@@ -18,6 +18,10 @@ void crypto_test_enc_alg_aes128_cbc(void);
 void crypto_test_enc_alg_aes128_cbc_ovr_iv(void);
 void crypto_test_dec_alg_aes128_cbc(void);
 void crypto_test_dec_alg_aes128_cbc_ovr_iv(void);
+void crypto_test_enc_alg_aes128_gcm(void);
+void crypto_test_enc_alg_aes128_gcm_ovr_iv(void);
+void crypto_test_dec_alg_aes128_gcm(void);
+void crypto_test_dec_alg_aes128_gcm_ovr_iv(void);
 void crypto_test_alg_hmac_md5(void);
 void crypto_test_alg_hmac_sha256(void);
 
diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 30cb35e..b6fcb12 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -279,6 +279,156 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void)
 }
 
 /* This test verifies the correctness of encode (plaintext -> ciphertext)
+ * operation for AES128_GCM algorithm. IV for the operation is the session IV.
+ * In addition the test verifies if the implementation can use the
+ * packet buffer as completion event buffer.*/
+void crypto_test_enc_alg_aes128_gcm(void)
+{
+   odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+auth_key   = { .data = NULL, .length = 0 };
+   odp_crypto_iv_t iv = { .data = NULL, .length = AES128_GCM_IV_LEN };
+   unsigned int test_vec_num = (sizeof(aes128_gcm_reference_length) /
+sizeof(aes128_gcm_reference_length[0]));
+   unsigned int i;
+
+   for (i = 0; i < test_vec_num; i++) {
+   cipher_key.data = aes128_gcm_reference_key[i];
+   cipher_key.length = sizeof(aes128_gcm_reference_key[i]);
+   iv.data = aes128_gcm_reference_iv[i];
+   iv.length = sizeof(aes128_gcm_reference_iv[i]);
+
+   alg_test(ODP_CRYPTO_OP_ENCODE,
+ODP_CIPHER_ALG_AES128_GCM,
+iv,
+NULL,
+cipher_key,
+ODP_AUTH_ALG_AES128_GCM,
+auth_key,
+&aes128_gcm_cipher_range[i],
+&aes128_gcm_auth_range[i],
+aes128_gcm_reference_plaintext[i],
+aes128_gcm_reference_length[i],
+aes128_gcm_reference_ciphertext[i],
+aes128_gcm_reference_length[i],
+aes128_gcm_reference_ciphertext[i] +
+aes128_gcm_reference_length[i],
+AES128_GCM_CHECK_LEN);
+   }
+}
+
+/* This test verifies the correctness of encode (plaintext -> ciphertext)
+ * operation for AES128_GCM algorithm. IV for the operation is the session IV.
+ * In addition the test verifies if the implementation can use the
+ * packet buffer as completion event buffer.*/
+void crypto_test_enc_alg_aes128_gcm_ovr_iv(void)
+{
+   odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+auth_key   = { .data = NULL, .length = 0 };
+   odp_crypto_iv_t iv = { .data = NULL, .length = AES128_GCM_IV_LEN };
+   unsigned int test_vec_num = (sizeof(aes128_gcm_reference_length) /
+sizeof(aes128_gcm_reference_length[0]));
+   unsigned int i;
+
+   for (i = 0; i < test_vec_num; i++) {
+   cipher_key.data = aes128_gcm_reference_key[i];
+   cipher_key.length = sizeof(aes128_gcm_reference_key[i]);
+
+   alg_test(ODP_CRYPTO_OP_ENCODE,
+ODP_CIPHER_ALG_AES128_GCM,
+iv,
+aes128_gcm_reference_iv[i],
+cipher_key,
+ODP_AUTH_ALG_AES128_GCM,
+auth_key,
+&aes128_gcm_cipher_range[i],
+&aes128_gcm_auth_range[i],
+aes128_gcm_reference_plaintext[i],
+aes128_gcm_reference_length[i],
+aes128_gcm_reference_ciphertext[i],
+aes128_gcm_reference_length[i],
+aes128_gcm_reference_ciphertext[i] +
+aes128_gcm_reference_length[i],
+AES128_GCM_CHECK_LEN);
+   }
+}
+
+/* This test verifies the correctness of decode (ciphertext -> plaintext)
+ * operation for

Re: [lng-odp] Runtime inlining

2015-11-16 Thread Nicolas Morey-Chaisemartin


On 11/11/2015 09:45 AM, Savolainen, Petri (Nokia - FI/Espoo) wrote:
>
>> -Original Message-
>> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of
>> EXT Nicolas Morey-Chaisemartin
>> Sent: Tuesday, November 10, 2015 5:13 PM
>> To: Zoltan Kiss; linaro-toolch...@lists.linaro.org
>> Cc: lng-odp
>> Subject: Re: [lng-odp] Runtime inlining
>>
>> As I said in the call last week, the problem is wider than that.
>>
>> ODP specifies a lot of types but not their sizes, a lot of
>> enums/defines (things like ODP_PKTIO_INVALID) but not their value
>> either.
>> For our port a lot of those values were changed for
>> performance/implementation reason. So I'm not even compatible between
>> one version of our ODP port and another one.
>>
>> The only way I can see to solve this is for ODP to fix the size of all
>> these types.
>> Default/Invalid values are not that easy, as a pointer would have a
>> completely different behaviour from structs/bitfields
>>
>> Nicolas
>>
> Type sizes do not need to be fixed in general, but only when an application 
> is build for binary compatibility (the use case we are talking here). Binary 
> compatibility and thus the fixed type sizes are defined per ISA.
>
> We can e.g. define a configure target (for our reference implementation == 
> linux-generic) "--binary-compatible=armv8.x" or "--binary-compatible=x86_64". 
> When you build your application with that option, "platform dependent" types 
> and constants would be fixed to pre-defined values specified in (new) ODP API 
> arch files.
>
> So instead of building against 
> odp/platform/linux-generic/include/odp/plat/queue_types.h ...
>
> typedef ODP_HANDLE_T(odp_queue_t);
> #define ODP_QUEUE_INVALID  _odp_cast_scalar(odp_queue_t, 0)
> #define ODP_QUEUE_NAME_LEN 32
>
>
> ... you'd build against odp/arch/armv8.x/include/odp/queue_types.h ...
>
> typedef uintptr_t odp_queue_t;
> #define ODP_QUEUE_INVALID  ((uintptr_t)0)
> #define ODP_QUEUE_NAME_LEN 64
>
>
> ... or odp/arch/x86_64/include/odp/queue_types.h
>
> typedef uint64_t odp_queue_t;
> #define ODP_QUEUE_INVALID  ((uint64_t)0x)
> #define ODP_QUEUE_NAME_LEN 32
>
>
> For highest performance on a fixed target platform, you'd still build against 
> the platform directly
>
> odp/platform//include/odp/plat/queue_types.h
>
> typedef xyz_queue_desc_t * odp_queue_t;
> #define ODP_QUEUE_INVALID  ((xyz_queue_desc_t *)0xdeadbeef)
> #define ODP_QUEUE_NAME_LEN 20
>
>
> -Petri
>

It still means that you need to enforce a type for all ODP implementation on a 
given arch. Which could be problematic.
As a precise example: the way handles are used now for odp_packet_t brings some 
useful features for checks and memory savings, but performance wise, they are a 
"disaster". One of the first thing I did was to switch them to pointers. And if 
I wanted a high perf linux x86_64 implementation, I'd probably do the same.

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


Re: [lng-odp] [PATCH] platform: move list of API files to Makefile.inc so it is common to all platforms

2015-11-17 Thread Nicolas Morey-Chaisemartin
I have read few things here and there about the repo split but haven't seen the 
full plan of the ML (maybe I missed it).
Is there some more information somewhere ?

Nicolas

On 11/17/2015 05:21 AM, Bill Fischofer wrote:
> This seems reasonable, but is probably already part of the new odp-api.git 
> repo creation activity.
>
> On Thu, Nov 12, 2015 at 8:22 AM, Nicolas Morey-Chaisemartin  <mailto:nmo...@kalray.eu>> wrote:
>
>     Signed-off-by: Nicolas Morey-Chaisemartin  <mailto:nmo...@kalray.eu>>
> ---
>  platform/Makefile.inc  | 39 
> ++
>  platform/linux-generic/Makefile.am | 39 
> --
>  2 files changed, 39 insertions(+), 39 deletions(-)
>
> diff --git a/platform/Makefile.inc b/platform/Makefile.inc
> index 8e8e97b..14e134c 100644
> --- a/platform/Makefile.inc
> +++ b/platform/Makefile.inc
> @@ -15,3 +15,42 @@ AM_LDFLAGS += -version-number '$(ODP_LIBSO_VERSION)'
>  GIT_DESC = `$(top_srcdir)/scripts/git_hash.sh $(top_srcdir)`
>  AM_CFLAGS += "-DGIT_HASH=$(GIT_DESC)"
>  AM_CFLAGS += -DPLATFORM=${with_platform}
> +
> +odpapiincludedir= $(includedir)/odp/api
> +odpapiinclude_HEADERS = \
> + $(top_srcdir)/include/odp/api/align.h \
> + $(top_srcdir)/include/odp/api/atomic.h \
> + $(top_srcdir)/include/odp/api/barrier.h \
> + $(top_srcdir)/include/odp/api/buffer.h \
> + $(top_srcdir)/include/odp/api/byteorder.h \
> + $(top_srcdir)/include/odp/api/classification.h \
> + $(top_srcdir)/include/odp/api/compiler.h \
> + $(top_srcdir)/include/odp/api/config.h \
> + $(top_srcdir)/include/odp/api/cpu.h \
> + $(top_srcdir)/include/odp/api/cpumask.h \
> + $(top_srcdir)/include/odp/api/crypto.h \
> + $(top_srcdir)/include/odp/api/debug.h \
> + $(top_srcdir)/include/odp/api/errno.h \
> + $(top_srcdir)/include/odp/api/event.h \
> + $(top_srcdir)/include/odp/api/hints.h \
> + $(top_srcdir)/include/odp/api/init.h \
> + $(top_srcdir)/include/odp/api/packet.h \
> + $(top_srcdir)/include/odp/api/packet_flags.h \
> + $(top_srcdir)/include/odp/api/packet_io.h \
> + $(top_srcdir)/include/odp/api/pool.h \
> + $(top_srcdir)/include/odp/api/queue.h \
> + $(top_srcdir)/include/odp/api/random.h \
> + $(top_srcdir)/include/odp/api/rwlock.h \
> + $(top_srcdir)/include/odp/api/schedule.h \
> + $(top_srcdir)/include/odp/api/schedule_types.h \
> + $(top_srcdir)/include/odp/api/shared_memory.h \
> + $(top_srcdir)/include/odp/api/spinlock.h \
> + $(top_srcdir)/include/odp/api/std_types.h \
> + $(top_srcdir)/include/odp/api/sync.h \
> + $(top_srcdir)/include/odp/api/system_info.h \
> + $(top_srcdir)/include/odp/api/thread.h \
> + $(top_srcdir)/include/odp/api/thrmask.h \
> + $(top_srcdir)/include/odp/api/ticketlock.h \
> + $(top_srcdir)/include/odp/api/time.h \
> + $(top_srcdir)/include/odp/api/timer.h \
> + $(top_srcdir)/include/odp/api/version.h
> \ No newline at end of file
> diff --git a/platform/linux-generic/Makefile.am 
> b/platform/linux-generic/Makefile.am
> index 0135947..610e04d 100644
> --- a/platform/linux-generic/Makefile.am
> +++ b/platform/linux-generic/Makefile.am
> @@ -73,45 +73,6 @@ odpplatinclude_HEADERS = \
>   $(srcdir)/include/odp/plat/timer_types.h \
>   $(srcdir)/include/odp/plat/version_types.h
>
> -odpapiincludedir= $(includedir)/odp/api
> -odpapiinclude_HEADERS = \
> - $(top_srcdir)/include/odp/api/align.h \
> - $(top_srcdir)/include/odp/api/atomic.h \
> - $(top_srcdir)/include/odp/api/barrier.h \
> - $(top_srcdir)/include/odp/api/buffer.h \
> - $(top_srcdir)/include/odp/api/byteorder.h \
> - $(top_srcdir)/include/odp/api/classification.h \
> - $(top_srcdir)/include/odp/api/compiler.h \
> - $(top_srcdir)/include/odp/api/config.h \
> - 

Re: [lng-odp] [API-NEXT PATCHv2 0/4] AES125-GCM support

2015-11-17 Thread Nicolas Morey-Chaisemartin
I have prepared a serie to validate md5_check and sha265_check but as they will 
conflict with this serie, i'll wait for it to get in first.

Nicolas

On 11/16/2015 02:07 PM, Nicolas Morey-Chaisemartin wrote:
> This patch series adds support for AES128-GCM;
> The first 2 patches changes slightly the validation tests to allow check of 
> both cipher and auth at the same time.
>
> v2:
> * Fix typo in 3rd patch name
>
> API changed
> Reviewed-by: Petri Savolainen 
>
> Nicolas Morey-Chaisemartin (4):
>   validation: crypto: support validating both cipher and auth at the
> same time
>   validation: crypto: allow custom auth/cipher range
>   api: crypto: Add AES128-GCM support
>   validation: crypto: add test for AES128-GCM
>
>  include/odp/api/crypto.h   |   4 +
>  .../linux-generic/include/odp_crypto_internal.h|   3 +
>  platform/linux-generic/odp_crypto.c| 183 
>  test/validation/crypto/crypto.h|   4 +
>  test/validation/crypto/odp_crypto_test_inp.c   | 235 
> ++---
>  test/validation/crypto/test_vectors.h  | 152 +
>  test/validation/crypto/test_vectors_len.h  |   7 +
>  7 files changed, 561 insertions(+), 27 deletions(-)
>
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp

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


[lng-odp] [PATCH] scripts: git_hash: support gitfiles

2015-11-17 Thread Nicolas Morey-Chaisemartin
With recent git releases, the .git at the top of a repo is not necessary
 a directory but can be a gitfile pointing to a remote git directory.
This is commonly used by git-worktree and git-submodule.
This patch changes the check for .git to allow for any file (symlinks too)

Signed-off-by: Nicolas Morey-Chaisemartin 
---
 scripts/git_hash.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/git_hash.sh b/scripts/git_hash.sh
index ccd62ab..e7f43f2 100755
--- a/scripts/git_hash.sh
+++ b/scripts/git_hash.sh
@@ -6,7 +6,7 @@ if [ -z ${1} ]; then
 fi
 ROOTDIR=${1}
 
-if [ -d ${ROOTDIR}/.git ]; then
+if [ -e ${ROOTDIR}/.git ]; then
hash=$(git --git-dir=${ROOTDIR}/.git describe | tr -d "\n")
if [[ $(git --git-dir=${ROOTDIR}/.git diff --shortstat 2> /dev/null \
| tail -n1) != "" ]]; then
@@ -18,7 +18,7 @@ if [ -d ${ROOTDIR}/.git ]; then
sed -i "s|-|.git|" ${ROOTDIR}/.scmversion
sed -i "s|-|.|g" ${ROOTDIR}/.scmversion
sed -i "s|^v||g" ${ROOTDIR}/.scmversion
-elif [ ! -d ${ROOTDIR}/.git -a ! -f ${ROOTDIR}/.scmversion ]; then
+elif [ ! -e ${ROOTDIR}/.git -a ! -f ${ROOTDIR}/.scmversion ]; then
echo -n "File ROOTDIR/.scmversion not found, "
echo "and not inside a git repository"
echo "Bailing out! Not recoverable!"
-- 
2.6.3.372.gcb93895

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


[lng-odp] [PATCH 1/2] configure.ac: do not set linux-generic as default platform

2015-11-18 Thread Nicolas Morey-Chaisemartin
This prepares for the second patch and add support for repo
 which do not have a linux-generic platform

Signed-off-by: Nicolas Morey-Chaisemartin 
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index be21eaf..0d7860b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,7 +73,7 @@ AC_ARG_WITH([platform],
 [AS_HELP_STRING([--with-platform=platform],
 [select platform to be used, default linux-generic])],
 [],
-[with_platform=linux-generic
+[AC_MSG_ERROR([No platform specified. Use --with-platform])
 ])
 
 AC_SUBST([with_platform])
-- 
2.6.3.372.gcb93895


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


[lng-odp] [PATCH 2/2] bootstrap: auto generate platform list

2015-11-18 Thread Nicolas Morey-Chaisemartin
This list all the available platforms looking for
 platform/*/m4/configure.m4 and generate the appropriate m4
 file for the configure.ac to include

Signed-off-by: Nicolas Morey-Chaisemartin 
---
 bootstrap| 23 +++
 configure.ac |  9 +
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/bootstrap b/bootstrap
index 7c3d220..daa8c58 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,5 +1,28 @@
 #! /bin/sh
 set -x
+
+# Auto generate the platform list
+PLATFORM_M4S=$(ls platform/*/m4/configure.m4)
+PLATFORMS=$(basename -a ${PLATFORM_M4S//\/m4\/configure\.m4/})
+GEN_M4="m4/platforms.m4"
+
+prefix=""
+echo "# Auto-Generated platform list" > $GEN_M4
+for platform in $PLATFORMS; do
+   cat << EOF >> $GEN_M4
+${prefix}if test "\${with_platform}" == "${platform}";
+then
+   m4_include([./platform/${platform}/m4/configure.m4])
+EOF
+   prefix="el"
+done
+cat << EOF >> $GEN_M4
+else
+echo "UNSUPPORTED PLATFORM: \${with_platform}"
+exit 1
+fi
+EOF
+
 aclocal -I config -I m4
 libtoolize --copy
 autoheader
diff --git a/configure.ac b/configure.ac
index 0d7860b..157e5f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,14 +87,7 @@ netmap_support=no
 
 ##
 # Run platform specific checks and settings
-##
-if test "${with_platform}" == "linux-generic";
-then
-m4_include([./platform/linux-generic/m4/configure.m4])
-else
-echo "UNSUPPORTED PLATFORM: ${with_platform}"
-exit 1
-fi
+m4_include([m4/platforms.m4])
 
 ##
 # Set conditionals as computed within platform specific files
-- 
2.6.3.372.gcb93895

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


Re: [lng-odp] [PATCH 2/2] bootstrap: auto generate platform list

2015-11-19 Thread Nicolas Morey-Chaisemartin


On 11/19/2015 11:04 AM, Anders Roxell wrote:
> On 2015-11-19 08:43, Nicolas Morey-Chaisemartin wrote:
>> This list all the available platforms looking for
>>  platform/*/m4/configure.m4 and generate the appropriate m4
>>  file for the configure.ac to include
>>
>> Signed-off-by: Nicolas Morey-Chaisemartin 
>> ---
>>  bootstrap| 23 +++
>>  configure.ac |  9 +
>>  2 files changed, 24 insertions(+), 8 deletions(-)
>>
>> diff --git a/bootstrap b/bootstrap
>> index 7c3d220..daa8c58 100755
>> --- a/bootstrap
>> +++ b/bootstrap
>> @@ -1,5 +1,28 @@
>>  #! /bin/sh
>>  set -x
>> +
>> +# Auto generate the platform list
>> +PLATFORM_M4S=$(ls platform/*/m4/configure.m4)
>> +PLATFORMS=$(basename -a ${PLATFORM_M4S//\/m4\/configure\.m4/})
>> +GEN_M4="m4/platforms.m4"
>> +
>> +prefix=""
>> +echo "# Auto-Generated platform list" > $GEN_M4
>> +for platform in $PLATFORMS; do
>> +cat << EOF >> $GEN_M4
>> +${prefix}if test "\${with_platform}" == "${platform}";
>> +then
>> +m4_include([./platform/${platform}/m4/configure.m4])
>> +EOF
>> +prefix="el"
>> +done
>> +cat << EOF >> $GEN_M4
>> +else
>> +echo "UNSUPPORTED PLATFORM: \${with_platform}"
>> +exit 1
>> +fi
>> +EOF
>> +
>>  aclocal -I config -I m4
>>  libtoolize --copy
>>  autoheader
>> diff --git a/configure.ac b/configure.ac
>> index 0d7860b..157e5f3 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -87,14 +87,7 @@ netmap_support=no
>>  
>>  ##
>>  # Run platform specific checks and settings
>> -##
>> -if test "${with_platform}" == "linux-generic";
>> -then
>> -m4_include([./platform/linux-generic/m4/configure.m4])
>> -else
>> -echo "UNSUPPORTED PLATFORM: ${with_platform}"
>> -exit 1
>> -fi
>> +m4_include([m4/platforms.m4])
>>  
>>  ##
>>  # Set conditionals as computed within platform specific files
>> -- 
>> 2.6.3.372.gcb93895
>>
> + ls platform/linux-generic/m4/configure.m4
> platform/linux-satan/m4/configure.m4
> + PLATFORM_M4S=platform/linux-generic/m4/configure.m4
> platform/linux-satan/m4/configure.m4
> ./bootstrap: 6: ./bootstrap: Bad substitution
> + PLATFORMS=
> + GEN_M4=m4/platforms.m4
> + prefix=
> + echo # Auto-Generated platform list
> + cat
> + aclocal -I config -I m4
>
>
> what do you think about adding this, think it fixed it for me.
>
> diff --git a/bootstrap b/bootstrap
> index daa8c58..75523f0 100755
> --- a/bootstrap
> +++ b/bootstrap
> @@ -3,16 +3,16 @@ set -x
>  
>  # Auto generate the platform list
>  PLATFORM_M4S=$(ls platform/*/m4/configure.m4)
> -PLATFORMS=$(basename -a ${PLATFORM_M4S//\/m4\/configure\.m4/})
>  GEN_M4="m4/platforms.m4"
>  
>  prefix=""
>  echo "# Auto-Generated platform list" > $GEN_M4
> -for platform in $PLATFORMS; do
> +for platform_m4 in $PLATFORM_M4S; do
> +   platform=$(echo ${platform_m4}|awk -F'/' '{print $2}')
> cat << EOF >> $GEN_M4
>  ${prefix}if test "\${with_platform}" == "${platform}";
>  then
> -   m4_include([./platform/${platform}/m4/configure.m4])
> +m4_include([./${platform_m4}])
>  EOF
> prefix="el"
>  done
>
>
> Cheers,
> Anders
If it works, I'm OK with this.
Althoutgh I'd rather do the awk at the same time as the ls so the list can be 
reused multiple times without having to extract the platform name each time (I 
have another patch pending that generates more includes).

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


[lng-odp] [PATCH 0/4] "Dynamic" platform handling

2015-11-19 Thread Nicolas Morey-Chaisemartin
The goal of this patch series is to auto generate the platform list and avoid 
platform maintaners to have to change
the configure.ac to add/remove platforms depending on the setup.

It will also work and make sense if odp-api is split from linux generic.
As autoconf requires all m4 to be included and does not have a simple way to 
include wildcard, 
bootstrap now generates a m4 files with the appropriate m4_include of the 
different platforms.

I also moved the linux-generic AM_CONDITIONAL definition to a specific file.
configure requires all AM_CONDITIONAL to be defined even if not used in the 
current setup (because all the Makefile for all the platforms are parsed)

So the idea is to include
platform//m4/configure.m4 in the current if ${with_platform} == 
 test 
and then always include platform//m4/conditionals.m4 so it exists so 
the build system will keep working even if multiple platforms with different 
AM_CONDITIONAL are available.

Nicolas Morey-Chaisemartin (4):
  configure.ac: do not set linux-generic as default platform
  bootstrap: auto generate platform list
  bootstrap: auto-include platform specific conditional definitions
  configure.ac: move linux-generic conditionals to platform side

 bootstrap | 34 +++
 configure.ac  | 23 ++---
 platform/linux-generic/m4/conditionals.m4 |  2 ++
 3 files changed, 38 insertions(+), 21 deletions(-)
 create mode 100644 platform/linux-generic/m4/conditionals.m4

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


[lng-odp] [PATCH 1/4] configure.ac: do not set linux-generic as default platform

2015-11-19 Thread Nicolas Morey-Chaisemartin
This prepares for the second patch and add support for repo
 which do not have a linux-generic platform

Signed-off-by: Nicolas Morey-Chaisemartin 
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index be21eaf..0d7860b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,7 +73,7 @@ AC_ARG_WITH([platform],
 [AS_HELP_STRING([--with-platform=platform],
 [select platform to be used, default linux-generic])],
 [],
-[with_platform=linux-generic
+[AC_MSG_ERROR([No platform specified. Use --with-platform])
 ])
 
 AC_SUBST([with_platform])
-- 
2.6.3.372.gcb93895


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


[lng-odp] [PATCH 3/4] bootstrap: auto-include platform specific conditional definitions

2015-11-19 Thread Nicolas Morey-Chaisemartin
Conditionals must always be defined if reference in a Makefile.am
 even if the Makefile does not apply to the platform being built.
As long as all the conditional are defined with default values in
platform//m4/conditionals.m4, bootstrap will automatically
include them so there won't be any issue when including multiple
platforms in the same repo

Signed-off-by: Nicolas Morey-Chaisemartin 
---
 bootstrap | 12 
 1 file changed, 12 insertions(+)

diff --git a/bootstrap b/bootstrap
index 2c9e000..39fe8a7 100755
--- a/bootstrap
+++ b/bootstrap
@@ -7,6 +7,7 @@ GEN_M4="m4/platforms.m4"
 
 prefix=""
 echo "# Auto-Generated platform list" > $GEN_M4
+
 for platform in $PLATFORMS; do
cat << EOF >> $GEN_M4
 ${prefix}if test "\${with_platform}" == "${platform}";
@@ -22,6 +23,17 @@ else
 fi
 EOF
 
+echo "# Include conditionals definitions if the platform has any" >> $GEN_M4
+for platform in $PLATFORMS; do
+   if [ ! -f platform/${platform}/m4/conditionals.m4 ]; then
+   continue
+   fi
+   cat << EOF >> $GEN_M4
+# Include conditional definitions for platform '${platform}'
+m4_include([./platform/${platform}/m4/conditionals.m4])
+EOF
+done;
+
 aclocal -I config -I m4
 libtoolize --copy
 autoheader
-- 
2.6.3.372.gcb93895


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


[lng-odp] [PATCH 4/4] configure.ac: move linux-generic conditionals to platform side

2015-11-19 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 configure.ac  | 12 
 platform/linux-generic/m4/conditionals.m4 |  2 ++
 2 files changed, 2 insertions(+), 12 deletions(-)
 create mode 100644 platform/linux-generic/m4/conditionals.m4

diff --git a/configure.ac b/configure.ac
index 157e5f3..3b8fbbc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -81,21 +81,9 @@ AC_SUBST([platform_with_platform], 
["platform/${with_platform}"])
 AC_SUBST([platform_with_platform_test], ["platform/${with_platform}/test"])
 
 ##
-# Prepare default values for platform specific optional features
-##
-netmap_support=no
-
-##
 # Run platform specific checks and settings
 m4_include([m4/platforms.m4])
 
-##
-# Set conditionals as computed within platform specific files
-##
-AM_CONDITIONAL([netmap_support], [test x$netmap_support = xyes ])
-AM_CONDITIONAL([HAVE_PCAP], [test $have_pcap = yes])
-
-
 AC_ARG_WITH([sdk-install-path],
 AC_HELP_STRING([--with-sdk-install-path=DIR path to external libs and headers],
  [(or in the default path if not specified).]),
diff --git a/platform/linux-generic/m4/conditionals.m4 
b/platform/linux-generic/m4/conditionals.m4
new file mode 100644
index 000..8970c5e
--- /dev/null
+++ b/platform/linux-generic/m4/conditionals.m4
@@ -0,0 +1,2 @@
+AM_CONDITIONAL([netmap_support], [test x$netmap_support = xyes ])
+AM_CONDITIONAL([HAVE_PCAP], [test x$have_pcap = xyes])
-- 
2.6.3.372.gcb93895

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


[lng-odp] [PATCH 2/4] bootstrap: auto generate platform list

2015-11-19 Thread Nicolas Morey-Chaisemartin
This list all the available platforms looking for
 platform/*/m4/configure.m4 and generate the appropriate m4
 file for the configure.ac to include

Signed-off-by: Nicolas Morey-Chaisemartin 
---
 bootstrap| 22 ++
 configure.ac |  9 +
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/bootstrap b/bootstrap
index 7c3d220..2c9e000 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,5 +1,27 @@
 #! /bin/sh
 set -x
+
+# Auto generate the platform list
+PLATFORMS=$(ls platform/*/m4/configure.m4 | awk -F '/' '{ print $2}')
+GEN_M4="m4/platforms.m4"
+
+prefix=""
+echo "# Auto-Generated platform list" > $GEN_M4
+for platform in $PLATFORMS; do
+   cat << EOF >> $GEN_M4
+${prefix}if test "\${with_platform}" == "${platform}";
+then
+   m4_include([./platform/${platform}/m4/configure.m4])
+EOF
+   prefix="el"
+done
+cat << EOF >> $GEN_M4
+else
+echo "UNSUPPORTED PLATFORM: \${with_platform}"
+exit 1
+fi
+EOF
+
 aclocal -I config -I m4
 libtoolize --copy
 autoheader
diff --git a/configure.ac b/configure.ac
index 0d7860b..157e5f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,14 +87,7 @@ netmap_support=no
 
 ##
 # Run platform specific checks and settings
-##
-if test "${with_platform}" == "linux-generic";
-then
-m4_include([./platform/linux-generic/m4/configure.m4])
-else
-echo "UNSUPPORTED PLATFORM: ${with_platform}"
-exit 1
-fi
+m4_include([m4/platforms.m4])
 
 ##
 # Set conditionals as computed within platform specific files
-- 
2.6.3.372.gcb93895


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


[lng-odp] PKTIN queues and polling

2015-11-23 Thread Nicolas Morey-Chaisemartin
Hi all,

I've been tracking a bug in my code for a while and ended up in a case where 
I'm not sure how things work.
The test is pktio_test_poll_multi in the pktio test suite.

Here is what I think is happening iny my case:

* create pktio in polling mode
* create a default inq.
 => The inq is of type PKTIN so default state is QUEUE_STATUS_UNSCHEDULED

* send all the buffers
* call odp_queue_deq on the inq
 => Some packets are moved from the pktio to the inq and some returned to the 
user
 => This causes the inq to be marked as scheduled and pushed to the scheduler
* call odp_queue_deq few more times until the queue is empty
 => Queue is now marked unscheduled although still the scheduler !
* call odp_queue_deq
 => Some packets are moved from the pktio to the inq and some returned to the 
user
 => This causes the inq to be marked as scheduled and pushed to the scheduler 
AGAIN !

From this point all hell breaks loose.
I had a quick look to linux-generic code and it seems to have the same behaviour

If not:
 - What did I miss that is suppose to avoid that?
If yes:
 - What do we do about it?
   - Not mark as UNSCHEDULED if the deq was not called by the scheduler.
   - Forbid to poll and schedule on pktin queue at the same time ? (In this 
case we need another type of queue?)


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


Re: [lng-odp] PKTIN queues and polling

2015-11-23 Thread Nicolas Morey Chaisemartin
It seems the test does 3 different types of recv/poll
* odp_pktio_recv
* odp_queue_deq(inq)
* odp_schedule

So i guess the 2nd one should be removed


Envoyé depuis un mobile Samsung.

 Message d'origine De : Bill Fischofer 
 Date :23/11/2015  19:45  (GMT+01:00) 
À : Nicolas Morey-Chaisemartin  Cc : 
LNG ODP Mailman List  Objet : Re: 
[lng-odp] PKTIN queues and polling 
The relevant code in odp_pktio_inq_setdef() seems to be:

switch (qentry->s.type) {
/* Change to ODP_QUEUE_TYPE_POLL when ODP_QUEUE_TYPE_PKTIN is removed */
case ODP_QUEUE_TYPE_PKTIN:
/* User polls the input queue */
queue_lock(qentry);
qentry->s.pktin = id;
queue_unlock(qentry);

/* Uncomment when ODP_QUEUE_TYPE_PKTIN is removed
break;
case ODP_QUEUE_TYPE_SCHED:
*/
/* Packet input through the scheduler */
if (schedule_pktio_start(id, ODP_SCHED_PRIO_LOWEST)) {
ODP_ERR("Schedule pktio start failed\n");
return -1;
}
break;
default:
ODP_ABORT("Bad queue type\n");
}

>From this it appears that linux-generic does not currently support direct
polling of the default input queues associated with pktio objects.  I
suspect the existing example code does odp_pktio_recv() calls when
operating in polling mode rather than going through the default input
queues.

Since this is clearly marked as a "todo" in the current code, I'd open a
bug about this so it can be addressed.

On Mon, Nov 23, 2015 at 12:09 PM, Nicolas Morey-Chaisemartin <
nmo...@kalray.eu> wrote:

> Hi all,
>
> I've been tracking a bug in my code for a while and ended up in a case
> where I'm not sure how things work.
> The test is pktio_test_poll_multi in the pktio test suite.
>
> Here is what I think is happening iny my case:
>
> * create pktio in polling mode
> * create a default inq.
>  => The inq is of type PKTIN so default state is QUEUE_STATUS_UNSCHEDULED
>
> * send all the buffers
> * call odp_queue_deq on the inq
>  => Some packets are moved from the pktio to the inq and some returned to
> the user
>  => This causes the inq to be marked as scheduled and pushed to the
> scheduler
> * call odp_queue_deq few more times until the queue is empty
>  => Queue is now marked unscheduled although still the scheduler !
> * call odp_queue_deq
>  => Some packets are moved from the pktio to the inq and some returned to
> the user
>  => This causes the inq to be marked as scheduled and pushed to the
> scheduler AGAIN !
>
> From this point all hell breaks loose.
> I had a quick look to linux-generic code and it seems to have the same
> behaviour
>
> If not:
>  - What did I miss that is suppose to avoid that?
> If yes:
>  - What do we do about it?
>- Not mark as UNSCHEDULED if the deq was not called by the scheduler.
>- Forbid to poll and schedule on pktin queue at the same time ? (In
> this case we need another type of queue?)
>
>
> Nicolas
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] PKTIN queues and polling

2015-11-24 Thread Nicolas Morey-Chaisemartin
Multi queue may/will solve this in the long term but this is a current bug in 
the master branch.
I don't by which miracle it has been working but the validation test should not 
work.

I suggest that we comment out the _poll tests from pktio (to be put back later 
when it makes sense for multiqueue).
We could even add a check in odp_queue_deq/deq_multi that the queue is not of 
type PKTIN as odp_schedule directly calls the internal function and does not go 
through the API call.

Nicolas

On 11/24/2015 10:37 AM, Savolainen, Petri (Nokia - FI/Espoo) wrote:
>
> The multi-queue pktio API has started the process for cleaner pktio queue 
> definition. The goal is to remove ODP_QUEUE_TYPE_PKTIN queue type. Either 
> application polls directly the interface queues or receives events through 
> _POLL or _SCHED queues (which are well defined).
>
>  
>
> Please review the multi-queue patch set. When that’s in, we can start to 
> remove old single queue APIs (odp_pktio_inq_setdef(), etc). Input and output  
> queues would be created by the implementation (not the application directly 
> by calling odp_queue_create()).
>
>  
>
> -Petri
>
>  
>
>  
>
> *From:*lng-odp [mailto:lng-odp-boun...@lists.linaro.org] *On Behalf Of *EXT 
> Bill Fischofer
> *Sent:* Monday, November 23, 2015 11:50 PM
> *To:* Nicolas Morey Chaisemartin
> *Cc:* LNG ODP Mailman List
> *Subject:* Re: [lng-odp] PKTIN queues and polling
>
>  
>
> We should close on how we want to handle this architecturally.  Mike: perhaps 
> something to add to tomorrow's ODP public call agenda?  Mike will be hosting 
> tomorrow since I'll be out.
>
>  
>
> On Mon, Nov 23, 2015 at 1:23 PM, Nicolas Morey Chaisemartin  <mailto:nmo...@kalray.eu>> wrote:
>
> It seems the test does 3 different types of recv/poll
>
> * odp_pktio_recv
>
> * odp_queue_deq(inq)
>
> * odp_schedule
>
>  
>
> So i guess the 2nd one should be removed
>
>  
>
>  
>
> Envoyé depuis un mobile Samsung.
>
>  
>
>  Message d'origine 
>
> De : Bill Fischofer
>
> Date :23/11/2015 19:45 (GMT+01:00)
>
> À : Nicolas Morey-Chaisemartin
>
> Cc : LNG ODP Mailman List
>
> Objet : Re: [lng-odp] PKTIN queues and polling
>
>  
>
>  
>
> The relevant code in odp_pktio_inq_setdef() seems to be:
>
>  
>
> switch (qentry->s.type) {
>
> /* Change to ODP_QUEUE_TYPE_POLL when ODP_QUEUE_TYPE_PKTIN is removed */
>
> case ODP_QUEUE_TYPE_PKTIN:
>
> /* User polls the input queue */
>
> queue_lock(qentry);
>
> qentry->s.pktin = id;
>
> queue_unlock(qentry);
>
>  
>
> /* Uncomment when ODP_QUEUE_TYPE_PKTIN is removed
>
> break;
>
> case ODP_QUEUE_TYPE_SCHED:
>
> */
>
> /* Packet input through the scheduler */
>
> if (schedule_pktio_start(id, ODP_SCHED_PRIO_LOWEST)) {
>
> ODP_ERR("Schedule pktio start failed\n");
>
> return -1;
>
> }
>
> break;
>
> default:
>
> ODP_ABORT("Bad queue type\n");
>
> }
>
>  
>
> From this it appears that linux-generic does not currently support direct 
> polling of the default input queues associated with pktio objects.  I suspect 
> the existing example code does odp_pktio_recv() calls when operating in 
> polling mode rather than going through the default input queues.
>
>  
>
> Since this is clearly marked as a "todo" in the current code, I'd open a 
> bug about this so it can be addressed.
>
>  
>
> On Mon, Nov 23, 2015 at 12:09 PM, Nicolas Morey-Chaisemartin 
> mailto:nmo...@kalray.eu>> wrote:
>
> Hi all,
>
> I've been tracking a bug in my code for a while and ended up in a 
> case where I'm not sure how things work.
> The test is pktio_test_poll_multi in the pktio test suite.
>
> Here is what I think is happening iny my case:
>
> * create pktio in polling mode
> * create a default inq.
>  => The inq is of type PKTIN so default state is 
> QUEUE_STATUS_UNSCHEDULED
>
> * send all the buffers
> * call odp_queue_deq on the inq
>  => Some packets are moved from the pktio to the inq and some 
> returned to the user
>  => This causes the inq to be marked as scheduled and pushed to the 
> scheduler
> * call odp_queue_deq few more times until the queue is empty
>  => Queue is now marked unscheduled although still the scheduler !
> 

Re: [lng-odp] [PATCH v2] remove hard platform links

2015-11-24 Thread Nicolas Morey-Chaisemartin
Reviewed-by: Nicolas Morey-Chaisemartin 


On 11/17/2015 10:40 PM, Mike Holmes wrote:
> Signed-off-by: Mike Holmes 
> ---
>  example/Makefile.inc | 1 -
>  helper/Makefile.am   | 1 -
>  test/Makefile.inc| 1 -
>  3 files changed, 3 deletions(-)
>
> diff --git a/example/Makefile.inc b/example/Makefile.inc
> index 05021d4..170f32e 100644
> --- a/example/Makefile.inc
> +++ b/example/Makefile.inc
> @@ -5,7 +5,6 @@ AM_CFLAGS += \
>   -I$(srcdir) \
>   -I$(top_srcdir)/example \
>   -I$(top_srcdir)/platform/@with_platform@/include \
> - -I$(top_srcdir)/platform/linux-generic/include \
>   -I$(top_srcdir)/include/ \
>   -I$(top_srcdir)/helper/include
>  
> diff --git a/helper/Makefile.am b/helper/Makefile.am
> index e72507e..bed8683 100644
> --- a/helper/Makefile.am
> +++ b/helper/Makefile.am
> @@ -4,7 +4,6 @@ pkgconfig_DATA = $(top_builddir)/pkgconfig/libodphelper.pc
>  LIB   = $(top_builddir)/lib
>  AM_CFLAGS  = -I$(srcdir)/include
>  AM_CFLAGS += -I$(top_srcdir)/platform/@with_platform@/include
> -AM_CFLAGS += -I$(top_srcdir)/platform/linux-generic/include
>  AM_CFLAGS += -I$(top_srcdir)/include
>  
>  helperincludedir = $(includedir)/odp/helper/
> diff --git a/test/Makefile.inc b/test/Makefile.inc
> index 2700b18..183d0a5 100644
> --- a/test/Makefile.inc
> +++ b/test/Makefile.inc
> @@ -8,7 +8,6 @@ LDADD = $(PRE_LDADD) $(LIB)/libodphelper.la $(LIB)/libodp.la
>  
>  INCFLAGS = -I$(top_srcdir)/test \
>   -I$(top_srcdir)/platform/@with_platform@/include \
> - -I$(top_srcdir)/platform/linux-generic/include \
>   -I$(top_srcdir)/include \
>   -I$(top_srcdir)/helper/include
>  AM_CFLAGS += $(INCFLAGS)

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


Re: [lng-odp] [API-NEXT PATCHv2 0/4] AES125-GCM support

2015-11-24 Thread Nicolas Morey-Chaisemartin
Ping

On 11/17/2015 04:43 PM, Nicolas Morey-Chaisemartin wrote:
> I have prepared a serie to validate md5_check and sha265_check but as they 
> will conflict with this serie, i'll wait for it to get in first.
>
> Nicolas
>
> On 11/16/2015 02:07 PM, Nicolas Morey-Chaisemartin wrote:
>> This patch series adds support for AES128-GCM;
>> The first 2 patches changes slightly the validation tests to allow check of 
>> both cipher and auth at the same time.
>>
>> v2:
>> * Fix typo in 3rd patch name
>>
>> API changed
>> Reviewed-by: Petri Savolainen 
>>
>> Nicolas Morey-Chaisemartin (4):
>>   validation: crypto: support validating both cipher and auth at the
>> same time
>>   validation: crypto: allow custom auth/cipher range
>>   api: crypto: Add AES128-GCM support
>>   validation: crypto: add test for AES128-GCM
>>
>>  include/odp/api/crypto.h   |   4 +
>>  .../linux-generic/include/odp_crypto_internal.h|   3 +
>>  platform/linux-generic/odp_crypto.c| 183 
>>  test/validation/crypto/crypto.h|   4 +
>>  test/validation/crypto/odp_crypto_test_inp.c   | 235 
>> ++---
>>  test/validation/crypto/test_vectors.h  | 152 +
>>  test/validation/crypto/test_vectors_len.h  |   7 +
>>  7 files changed, 561 insertions(+), 27 deletions(-)
>>
>> ___
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> https://lists.linaro.org/mailman/listinfo/lng-odp
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp

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


[lng-odp] [RFC] api: queue: remove ODP_QUEUE_TYPE_PKTIN

2015-11-24 Thread Nicolas Morey-Chaisemartin
Type to use is now ODP_QUEUE_TYPE_POLL or ODP_QUEUE_TYPE_SCHED
  depending on the pktio it will be associated to.
These queues behave as normal queues until they are associated to a pktio
using odp_pktio_inq_setdef and will behave as standard queues after
a call to odp_pktio_inq_remdef

Signed-off-by: Nicolas Morey-Chaisemartin 
---

Following the discussion in the call, this is a very quickly made patch that 
removes ODP_QUEUE_TYPE_PKTIN.
Unless I am missing something, there are no deep issues with this change that 
prevent it from doing it now 
(apart from probable conflicts with TM and or multiple defq series)

 example/classifier/odp_classifier.c|  2 +-
 example/generator/odp_generator.c  |  2 +-
 example/ipsec/odp_ipsec.c  |  7 ++-
 example/packet/odp_pktio.c |  4 +-
 include/odp/api/queue.h|  5 ---
 .../linux-generic/include/odp/plat/queue_types.h   |  3 +-
 platform/linux-generic/odp_packet_io.c | 50 +-
 platform/linux-generic/odp_queue.c | 12 +-
 test/performance/odp_l2fwd.c   |  5 ++-
 test/performance/odp_pktio_perf.c  |  3 +-
 .../classification/odp_classification_test_pmr.c   |  3 +-
 .../classification/odp_classification_tests.c  |  2 +-
 test/validation/pktio/pktio.c  |  3 +-
 13 files changed, 63 insertions(+), 38 deletions(-)

diff --git a/example/classifier/odp_classifier.c 
b/example/classifier/odp_classifier.c
index 365c748..a1681f4 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -248,7 +248,7 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t 
pool)
 odp_pktio_to_u64(pktio));
inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0';
 
-   inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam);
+   inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_SCHED, &qparam);
if (inq_def == ODP_QUEUE_INVALID) {
EXAMPLE_ERR("pktio inq create failed for %s\n", dev);
exit(EXIT_FAILURE);
diff --git a/example/generator/odp_generator.c 
b/example/generator/odp_generator.c
index 9d79f89..dcc3fc8 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -352,7 +352,7 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t 
pool)
 odp_pktio_to_u64(pktio));
inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0';
 
-   inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam);
+   inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_SCHED, &qparam);
if (inq_def == ODP_QUEUE_INVALID)
EXAMPLE_ABORT("Error: pktio inq create failed for %s\n", dev);
 
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index d784c31..960ad1d 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -249,7 +249,7 @@ odp_queue_t polled_odp_queue_create(const char *name,
 
my_queue = odp_queue_create(name, my_type, NULL);
 
-   if ((ODP_QUEUE_TYPE_SCHED == type) || (ODP_QUEUE_TYPE_PKTIN == type)) {
+   if (ODP_QUEUE_TYPE_SCHED == type) {
poll_queues[num_polled_queues++] = my_queue;
printf("%s: adding %"PRIu64"\n", __func__,
   odp_queue_to_u64(my_queue));
@@ -525,7 +525,10 @@ void initialize_intf(char *intf)
 odp_pktio_to_u64(pktio));
inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0';
 
-   inq_def = queue_create(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam);
+   inq_def = queue_create(inq_name,
+  pktio_param.in_mode == ODP_PKTIN_MODE_POLL ?
+  ODP_QUEUE_TYPE_POLL : ODP_QUEUE_TYPE_SCHED,
+  &qparam);
if (ODP_QUEUE_INVALID == inq_def) {
EXAMPLE_ERR("Error: pktio queue creation failed for %s\n",
intf);
diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
index 93c38f5..9419db4 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -152,7 +152,7 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t 
pool, int mode)
return pktio;
case APPL_MODE_PKT_QUEUE:
inq_def = odp_queue_create(inq_name,
-  ODP_QUEUE_TYPE_PKTIN, NULL);
+  ODP_QUEUE_TYPE_POLL, NULL);
break;
case APPL_MODE_PKT_SCHED:
odp_queue_param_init(&qparam);
@@ -161,7 +161,7 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t 
pool, int mode)
qparam.sched.group = ODP_SCHED_GROUP_ALL;
 
inq_def = odp_queue_create(inq_name,
- 

[lng-odp] [API-NEXT 0/3] Add validation for crypto auth decoding

2015-11-27 Thread Nicolas Morey-Chaisemartin
This adds tests for the auth/hash check function in crypto

Nicolas Morey-Chaisemartin (3):
  validation: crypto: support auth decoding
  validation: crypto: validate md5_check
  validation: crypto: validate sha256_check function

 test/validation/crypto/odp_crypto_test_inp.c | 35 
 1 file changed, 35 insertions(+)

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


[lng-odp] [API-NEXT 1/3] validation: crypto: support auth decoding

2015-11-27 Thread Nicolas Morey-Chaisemartin
Copy the expected digest at the end of the plaintext
to validate Auth decode functions

Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/odp_crypto_test_inp.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index b6fcb12..dc3ee52 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -81,6 +81,11 @@ static void alg_test(odp_crypto_op_t op,
memcpy(data_addr, plaintext, plaintext_len);
int data_off = 0;
 
+   if (op == ODP_CRYPTO_OP_DECODE && auth_alg != ODP_AUTH_ALG_NULL) {
+   /* Copy the digest at the end of the message */
+   memcpy(data_addr + plaintext_len, digest, digest_len);
+   }
+
/* Prepare input/output params */
odp_crypto_op_params_t op_params;
memset(&op_params, 0, sizeof(op_params));
-- 
2.6.3.372.gcb93895


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


[lng-odp] [API-NEXT 3/3] validation: crypto: validate sha256_check function

2015-11-27 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/odp_crypto_test_inp.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 401d225..f3ac4e0 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -654,6 +654,21 @@ void crypto_test_alg_hmac_sha256(void)
 NULL, 0,
 hmac_sha256_reference_digest[i],
 HMAC_SHA256_128_CHECK_LEN);
+
+   /* Now "decode" to validate the auth check function */
+   alg_test(ODP_CRYPTO_OP_DECODE,
+ODP_CIPHER_ALG_NULL,
+iv,
+iv.data,
+cipher_key,
+ODP_AUTH_ALG_SHA256_128,
+auth_key,
+NULL, NULL,
+hmac_sha256_reference_plaintext[i],
+hmac_sha256_reference_length[i],
+NULL, 0,
+hmac_sha256_reference_digest[i],
+HMAC_SHA256_128_CHECK_LEN);
}
 }
 
-- 
2.6.3.372.gcb93895

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


[lng-odp] [API-NEXT 2/3] validation: crypto: validate md5_check

2015-11-27 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/odp_crypto_test_inp.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index dc3ee52..401d225 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -601,6 +601,21 @@ void crypto_test_alg_hmac_md5(void)
 NULL, 0,
 hmac_md5_reference_digest[i],
 HMAC_MD5_96_CHECK_LEN);
+
+   /* Now "decode" to validate the auth check function */
+   alg_test(ODP_CRYPTO_OP_DECODE,
+ODP_CIPHER_ALG_NULL,
+iv,
+iv.data,
+cipher_key,
+ODP_AUTH_ALG_MD5_96,
+auth_key,
+NULL, NULL,
+hmac_md5_reference_plaintext[i],
+hmac_md5_reference_length[i],
+NULL, 0,
+hmac_md5_reference_digest[i],
+HMAC_MD5_96_CHECK_LEN);
}
 }
 
-- 
2.6.3.372.gcb93895


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


Re: [lng-odp] [API-NEXT 0/3] Add validation for crypto auth decoding

2015-11-30 Thread Nicolas Morey-Chaisemartin
Except they do not apply on master because of the API in the crypto validation 
suite brought by the AES-GCM.


On 11/30/2015 06:09 PM, Mike Holmes wrote:
> These should apply to master not API-NEXT since they don't touch the API.
>
>
> On 27 November 2015 at 03:42, Nicolas Morey-Chaisemartin  <mailto:nmo...@kalray.eu>> wrote:
>
> This adds tests for the auth/hash check function in crypto
>
> Nicolas Morey-Chaisemartin (3):
>   validation: crypto: support auth decoding
>   validation: crypto: validate md5_check
>   validation: crypto: validate sha256_check function
>
>  test/validation/crypto/odp_crypto_test_inp.c | 35 
> 
>  1 file changed, 35 insertions(+)
>
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> -- 
> Mike Holmes
> Technical Manager - Linaro Networking Group
> Linaro.org <http://www.linaro.org/>* **│ *Open source software for ARM SoCs
>

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


Re: [lng-odp] [PATCH] linux-generic: schedule: set sched_local.pool correctly

2015-12-01 Thread Nicolas Morey-Chaisemartin
I don't think there is any guarantee that all buffer returned by 
queue_deq_multi come from the same pool.
So this should probably be updated when we copy an event out of the local cache 
at the beginning of schedule()

Nicolas

On 12/01/2015 02:14 PM, Bill Fischofer wrote:
> This corrects bug https://bugs.linaro.org/show_bug.cgi?id=1921
>
> Signed-off-by: Bill Fischofer 
> ---
>  platform/linux-generic/odp_schedule.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/platform/linux-generic/odp_schedule.c 
> b/platform/linux-generic/odp_schedule.c
> index 884ae60..9b7cd57 100644
> --- a/platform/linux-generic/odp_schedule.c
> +++ b/platform/linux-generic/odp_schedule.c
> @@ -553,6 +553,8 @@ static int schedule(odp_queue_t *out_queue, odp_event_t 
> out_ev[],
>   sched_local.origin_qe = qe;
>   sched_local.order =
>   sched_local.buf_hdr[0]->order;
> + sched_local.pool =
> + sched_local.buf_hdr[0]->pool_hdl;
>   for (k = 0;
>k < qe->s.param.sched.lock_count;
>k++) {

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


Re: [lng-odp] [PATCH v2 2/3] CHANGELOG: initial revision

2015-12-02 Thread Nicolas Morey-Chaisemartin
Wouldn't it make sense to also install the CHANGELOG (with the doc for example) 
?

On 12/01/2015 08:27 PM, Mike Holmes wrote:
> With the addition of an RPM package to the existing debian package we
> need to have a single change log for the ODP API and the linux-generic
> implementation.
> The debian and RPM change logs then just list packaging changes.
>
> Create an initial copy of the old debian log.
>
> Signed-off-by: Mike Holmes 
> Reviewed-by: Anders Roxell 
> ---
>  CHANGELOG   | 520 
> 
>  Makefile.am |   2 +-
>  2 files changed, 521 insertions(+), 1 deletion(-)
>  create mode 100644 CHANGELOG
>
> diff --git a/CHANGELOG b/CHANGELOG
> new file mode 100644
> index 000..cd8c387
> --- /dev/null
> +++ b/CHANGELOG
> @@ -0,0 +1,520 @@
> +opendataplane (1.4.1.0)
> +   * Validation
> +   - pktio: test transmit error recovery
> +   - schedule: add chaos test
> +   - check return code from odp_queue_lock_count()
> +   - scheduler: test ordered queue reorder processing
> +   - pktio: initialize queue parameters correctly
> +   - pktio: test for transmit error handling
> +   - pktio: add support for direct receive
> +   - pktio: pass interface index rather than name
> +   - pktio: fix start_stop test
> +   - test: l2fwd: separate rx and tx drop counters
> +   - test: l2fwd: increase burst size
> +   - test: l2fwd: optimize statistics usage
> +   - test: l2fwd: optimize queue mode
> +   - test: l2fwd: start pktios after worker thread create
> +   - test: l2fwd: added option to disable error check
> +   - example/ipsec: Increase ip_data_len for Tunnel mode
> +   - example: ipsec: check push_tail return code
> +   * General:
> +   - linux-generic: pktio: handle transmit errors correctly
> +   - pktio socket_mmap: recover from transmit errors but 1890
> +   - pktio: increase MTU of loop interface
> +   - ordered queues: fix race condition during order release
> + and out of order.
> +   - configure: move HAVE_PCAP AM_CONDITIONAL to configure.ac
> +   * ODP helper:
> +   - linux: checkpatch cleaning for helper/linux.c
> +   - linux: examine the cause for child process termination
> +   - linux: request SIGTERM if parent process dies
> +
> +opendataplane (1.4.0.0)
> +   * API:
> +   - ** Classification **
> +   - odp_cos_set_queue() renamed to odp_cos_queue_set()
> +   - int odp_cos_set_drop renamed to odp_cos_drop_set()
> +   - new: odp_queue_t odp_cos_queue(odp_cos_t cos_id)
> +   - new: odp_drop_e odp_cos_drop(odp_cos_t cos_id)
> +   - ODP_PMR_CUSTOM_FRAME support in classification
> +   - odp_pmr_create() arguments passing change to use struct
> +   - odp_pmr_match_set_create() added id argument
> +   - ** Config **
> +   - new: odp_config_...() API introduced instead of ODP_CONFIG_ defines
> +   - ** Cpu, Threads and Scheduler **
> +   - new: uint64_t odp_cpu_cycles(void)
> +   - new: uint64_t odp_cpu_cycles_diff(uint64_t c1, uint64_t c2);
> +   - new: uint64_t odp_cpu_cycles_max(void);
> +   - new: uint64_t odp_cpu_cycles_resolution(void);
> +   - odp_cpumask_def_worker() renamed to odp_cpumask_default_worker()
> +   - odp_cpumask_def_control() renamed to odp_cpumask_default_control()
> +   - odp init extended with num worker and control threads
> +   - new: int odp_queue_lock_count(odp_queue_t queue);
> +   - refine api doc for scheduler and schedule orderd locks
> +   - argument of odp_schedule_order_lock() and odp_schedule_order_unlock 
> changed to unsigned
> +   - new: int odp_thread_count_max(void)
> +   - ** Packet **
> +   - new: uint32_t odp_packet_flow_hash(odp_packet_t pkt)
> +   - new: void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t 
> flow_hash)
> +   - new: int odp_packet_has_flow_hash(odp_packet_t pkt);
> +   - new: void odp_packet_has_flow_hash_clr(odp_packet_t pkt);
> +   - ** Pktio **
> +   - pktio can be configuread as receive or transmit only
> +   - pktio: refined api doc for start() and stop()
> +   - new: void odp_pktio_param_init(odp_pktio_param_t *param)
> +   * ODP docs:
> +   - implementers-guide: update names of test module libraries
> +   - implementers-guide: update section on skipping tests
> +   * Test framework
> +   - update README files
> +   - renaming module libs
> +   - add odp_cunit_update() to modify registered tests
> +   - add ability to mark tests inactive
> +   * Validation
> +   - ** Classification **
> +   - Add fix for classification tests
> +   - remove redundant pool lookup function
> +   - remove redundant sequence number check
> +   - use tcp data offset field to calculate data offset
> +   - move destroy_inq() to common file
> +   - add odp_pktio_param_init() API
> +   - added additional suite to test indi

[lng-odp] [PATCH] doc: build users and implementers guide in the build tree instead of the source tree

2015-12-02 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 doc/implementers-guide/Makefile.am | 4 ++--
 doc/users-guide/Makefile.am| 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

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

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


Re: [lng-odp] [PATCH v2 2/3] CHANGELOG: initial revision

2015-12-02 Thread Nicolas Morey-Chaisemartin


On 12/02/2015 04:58 PM, Mike Holmes wrote:
>
> On 2 December 2015 at 03:46, Nicolas Morey-Chaisemartin  <mailto:nmo...@kalray.eu>> wrote:
>
> Wouldn't it make sense to also install the CHANGELOG (with the doc for 
> example) ?
>
>
> I dont know if installed apps usually copy the changelog, but I think it 
> would then go into /usr/share/doc/packagename/. [1] if we do that.
>
>
> https://www.debian.org/doc/manuals/maint-guide/dother.en.html
>
I'm not sure either but except if API changes are on top of the documentation, 
it's one of the documents users must review when they update to know what to 
look for and what to fix.
If it is not installed by ODP, they have to go look for the releases notes 
online or in git.

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


Re: [lng-odp] [PATCH] doc: build users and implementers guide in the build tree instead of the source tree

2015-12-07 Thread Nicolas Morey-Chaisemartin
You're right. I have a custom "make install" build above that that packages 
everything.

I'll post an updated patch soon.

Nicolas

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

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


Re: [lng-odp] [PATCH v2] test: performance: add crypto test

2015-12-16 Thread Nicolas Morey-Chaisemartin


On 12/16/2015 11:50 PM, Mike Holmes wrote:
> with apply and build
>
> Using patch: lng-odp_PATCH_v2_test_performance_add_crypto_test.mbox
>   Trying to apply patch
>   Patch applied
>
> WARNING: 'Imediately' may be misspelled - perhaps 'Immediately'?
> #645: FILE: test/performance/odp_crypto.c:582:
> + print_mem("Imediately encrypted packet", mem,
>
> total: 0 errors, 1 warnings, 0 checks, 958 lines checked
>
> And compiling
>
> odp_crypto.c: In function ‘create_session_from_config’:
> odp_crypto.c:428:33: error: storage size of ‘ses_create_rc’ isn’t known
>   enum odp_crypto_ses_create_err ses_create_rc;
>  ^
> odp_crypto.c:428:33: error: unused variable ‘ses_create_rc’ 
> [-Werror=unused-variable]
> odp_crypto.c: In function ‘main’:
> odp_crypto.c:777:17: error: implicit declaration of function 
> ‘odp_cpumask_def_worker’ [-Werror=implicit-function-declaration]
>num_workers = odp_cpumask_def_worker(&cpumask,
>  ^
> odp_crypto.c:777:3: error: nested extern declaration of 
> ‘odp_cpumask_def_worker’ [-Werror=nested-externs]
>num_workers = odp_cpumask_def_worker(&cpumask,
>^
> odp_crypto.c:795:4: error: too few arguments to function 
> ‘odph_linux_pthread_create’
> odph_linux_pthread_create(&thr, &cpumask,
> ^
> In file included from odp_crypto.c:20:0:
> ../../helper/include/odp/helper/linux.h:67:5: note: declared here
>  int odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl,
>  ^
> cc1: all warnings being treated as errors
>
> So it looks like it needs a rebase.
>
> On 4 November 2015 at 10:07, Nicolas Morey-Chaisemartin  <mailto:nmo...@kalray.eu>> wrote:
>
>
> On 11/04/2015 09:12 AM, alexandru.badici...@linaro.org 
> <mailto:alexandru.badici...@linaro.org> wrote:
> > From: Alexandru Badicioiu  <mailto:alexandru.badici...@linaro.org>>
> >
> > Test program to measure crypto operation performance.
> > Measures the time required to launch and get the result
> > of ODP crypto operations in async and sync API mode with
> > configurable payload size, crypto algorithms and iteration
> > number.
> > Both asynchronous scheduled and polled are supported.
> > In scheduled mode a separate worker thread is used to
> > get the crypto completion events.
> > Output packet can be reused as the input of the next
> > operation or a new packet can be allocated for each
> > operation.
> > Based on a previous work :
> > https://lists.linaro.org/pipermail/lng-odp/2014-September/003251.html.
> >
> > Signed-off-by: Alexandru Badicioiu  <mailto:alexandru.badici...@linaro.org>>
> > v1
> > ---
> > - replaced cspeed with crypto
> > - removed unused parameter core_count
> > v2
> > --
> > - alphabetical order in Makefile.am
> > - replaced pool params memset with init call
> >
> > ---
> >  test/performance/Makefile.am  |   5 +-
> >  test/performance/odp_crypto.c | 935 
> ++
> >  2 files changed, 939 insertions(+), 1 deletion(-)
> >  create mode 100644 test/performance/odp_crypto.c
>
> > +/**
> > + * Snap current time values and put them into 'rec'.
> > + */
> > +static void
> > +fill_time_record(time_record_t *rec)
> > +{
> > + gettimeofday(&rec->tv, NULL);
> > + getrusage(RUSAGE_SELF, &rec->ru_self);
> > + getrusage(RUSAGE_THREAD, &rec->ru_thread);
> This is *very* linux oriented and not platform agnostic.
> getrusage is POSIX 2001 (though we don't support it) but RUSAGE_THREAD is 
> _GNU_SOURCE and kernel > 2.6.26
>
> Couldn't we use ODP API to keep track of time ?
>
>
> Nicolas, in the call today we put out the idea that it would be better to use 
> an odp time api, but that maybe it was ok to use linux for now.
> Re reading the patch I think this is problem since it will break on your 
> platform and not just be less clean, is that correct ?
>
Yes it will. I can get it to compile by removing the getrusage but a perf test 
without perf isn't very useful.

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


Re: [lng-odp] [PATCH v2] test: performance: add crypto test

2015-12-16 Thread Nicolas Morey-Chaisemartin


On 12/17/2015 07:51 AM, Alexandru Badicioiu wrote:
>
>
> On 17 December 2015 at 00:50, Mike Holmes  > wrote:
>
> with apply and build
>
> Using patch: lng-odp_PATCH_v2_test_performance_add_crypto_test.mbox
>   Trying to apply patch
>   Patch applied
>
> WARNING: 'Imediately' may be misspelled - perhaps 'Immediately'?
> #645: FILE: test/performance/odp_crypto.c:582:
> + print_mem("Imediately encrypted packet", mem,
>
> total: 0 errors, 1 warnings, 0 checks, 958 lines checked
>
> And compiling
>
[...]
>
>  
>
> > + } else if (cargs.poll) {
> > + printf("Run in async poll mode\n");
> > + } else {
> > + printf("Run in sync mode\n");
> > + }
> > +
> > + if (cargs.alg_config) {
> > + if (cargs.schedule) {
> > + odph_linux_pthread_create(&thr, &cpumask,
> > +   run_thr_func, 
> &thr_arg);
> > + odph_linux_pthread_join(&thr, num_workers);
> > + } else {
> > + run_measure_one_config(&cargs, 
> cargs.alg_config);
> > + }
> Why is there only multithreading in schedule mode?
>
>
> Not sure, Alex is there a technical reason ?
>
> [Alex] Not sure I understand the question - I guess the intent was to ask 
> "why is there only one thread". Or the question was "why there's a separate 
> thread to run the test"? 
>
>

Your test supports both schedule and poll mode. In schedule mode you spawn 
several threads but in poll mode, you use only one.
It's been a long time since I've read this patch so I'm not sure but I think my 
question is why is multithreading linked to the schedule mode?
Couldn't we select schedule vs poll, single vs multi thread

Nicolas

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


[lng-odp] [PATCH] example: classifier: use SCN macro to scan uint32_t

2016-01-05 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 example/classifier/odp_classifier.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/example/classifier/odp_classifier.c 
b/example/classifier/odp_classifier.c
index fe1c3b6..6b443d7 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -167,7 +167,8 @@ int parse_ipv4_addr(const char *ipaddress, uint64_t *addr)
uint32_t b[4];
int converted;
 
-   converted = sscanf(ipaddress, "%d.%d.%d.%d",
+   converted = sscanf(ipaddress,
+  "%" SCNu32 ".%" SCNu32 ".%" SCNu32 ".%" SCNu32 "",
   &b[3], &b[2], &b[1], &b[0]);
if (4 != converted)
return -1;
-- 
2.6.3.373.g6d475bf.dirty

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


Re: [lng-odp] [PATCH] scripts: git_hash: support gitfiles

2016-01-05 Thread Nicolas Morey-Chaisemartin
Ping.

On 11/17/2015 04:48 PM, Nicolas Morey-Chaisemartin wrote:
> With recent git releases, the .git at the top of a repo is not necessary
>  a directory but can be a gitfile pointing to a remote git directory.
> This is commonly used by git-worktree and git-submodule.
> This patch changes the check for .git to allow for any file (symlinks too)
>
> Signed-off-by: Nicolas Morey-Chaisemartin 
> ---
>  scripts/git_hash.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/git_hash.sh b/scripts/git_hash.sh
> index ccd62ab..e7f43f2 100755
> --- a/scripts/git_hash.sh
> +++ b/scripts/git_hash.sh
> @@ -6,7 +6,7 @@ if [ -z ${1} ]; then
>  fi
>  ROOTDIR=${1}
>  
> -if [ -d ${ROOTDIR}/.git ]; then
> +if [ -e ${ROOTDIR}/.git ]; then
>   hash=$(git --git-dir=${ROOTDIR}/.git describe | tr -d "\n")
>   if [[ $(git --git-dir=${ROOTDIR}/.git diff --shortstat 2> /dev/null \
>   | tail -n1) != "" ]]; then
> @@ -18,7 +18,7 @@ if [ -d ${ROOTDIR}/.git ]; then
>   sed -i "s|-|.git|" ${ROOTDIR}/.scmversion
>   sed -i "s|-|.|g" ${ROOTDIR}/.scmversion
>   sed -i "s|^v||g" ${ROOTDIR}/.scmversion
> -elif [ ! -d ${ROOTDIR}/.git -a ! -f ${ROOTDIR}/.scmversion ]; then
> +elif [ ! -e ${ROOTDIR}/.git -a ! -f ${ROOTDIR}/.scmversion ]; then
>   echo -n "File ROOTDIR/.scmversion not found, "
>   echo "and not inside a git repository"
>   echo "Bailing out! Not recoverable!"

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


Re: [lng-odp] [PATCH 0/4] "Dynamic" platform handling

2016-01-05 Thread Nicolas Morey-Chaisemartin
Ping?

On 11/19/2015 11:43 AM, Nicolas Morey-Chaisemartin wrote:
> The goal of this patch series is to auto generate the platform list and avoid 
> platform maintaners to have to change
> the configure.ac to add/remove platforms depending on the setup.
>
> It will also work and make sense if odp-api is split from linux generic.
> As autoconf requires all m4 to be included and does not have a simple way to 
> include wildcard, 
> bootstrap now generates a m4 files with the appropriate m4_include of the 
> different platforms.
>
> I also moved the linux-generic AM_CONDITIONAL definition to a specific file.
> configure requires all AM_CONDITIONAL to be defined even if not used in the 
> current setup (because all the Makefile for all the platforms are parsed)
>
> So the idea is to include
> platform//m4/configure.m4 in the current if ${with_platform} == 
>  test 
> and then always include platform//m4/conditionals.m4 so it exists 
> so the build system will keep working even if multiple platforms with 
> different AM_CONDITIONAL are available.
>
> Nicolas Morey-Chaisemartin (4):
>   configure.ac: do not set linux-generic as default platform
>   bootstrap: auto generate platform list
>   bootstrap: auto-include platform specific conditional definitions
>   configure.ac: move linux-generic conditionals to platform side
>
>  bootstrap | 34 
> +++
>  configure.ac  | 23 ++---
>  platform/linux-generic/m4/conditionals.m4 |  2 ++
>  3 files changed, 38 insertions(+), 21 deletions(-)
>  create mode 100644 platform/linux-generic/m4/conditionals.m4
>
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp

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


[lng-odp] [PATCH v2 0/3] Add validation for crypto auth decoding

2016-01-05 Thread Nicolas Morey-Chaisemartin
This adds tests for the auth/hash check function in crypto

v2:
Rebased on master branch (was API-NEXT due to required AES-GCM patch series)

Nicolas Morey-Chaisemartin (3):
  validation: crypto: support auth decoding
  validation: crypto: validate md5_check
  validation: crypto: validate sha256_check function

 test/validation/crypto/odp_crypto_test_inp.c | 35 
 1 file changed, 35 insertions(+)

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


[lng-odp] [PATCH v2 1/3] validation: crypto: support auth decoding

2016-01-05 Thread Nicolas Morey-Chaisemartin
Copy the expected digest at the end of the plaintext
to validate Auth decode functions

Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/odp_crypto_test_inp.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index b6fcb12..dc3ee52 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -81,6 +81,11 @@ static void alg_test(odp_crypto_op_t op,
memcpy(data_addr, plaintext, plaintext_len);
int data_off = 0;
 
+   if (op == ODP_CRYPTO_OP_DECODE && auth_alg != ODP_AUTH_ALG_NULL) {
+   /* Copy the digest at the end of the message */
+   memcpy(data_addr + plaintext_len, digest, digest_len);
+   }
+
/* Prepare input/output params */
odp_crypto_op_params_t op_params;
memset(&op_params, 0, sizeof(op_params));
-- 
2.6.3.372.gcb93895


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


[lng-odp] [PATCH v2 2/3] validation: crypto: validate md5_check

2016-01-05 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/odp_crypto_test_inp.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index dc3ee52..401d225 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -601,6 +601,21 @@ void crypto_test_alg_hmac_md5(void)
 NULL, 0,
 hmac_md5_reference_digest[i],
 HMAC_MD5_96_CHECK_LEN);
+
+   /* Now "decode" to validate the auth check function */
+   alg_test(ODP_CRYPTO_OP_DECODE,
+ODP_CIPHER_ALG_NULL,
+iv,
+iv.data,
+cipher_key,
+ODP_AUTH_ALG_MD5_96,
+auth_key,
+NULL, NULL,
+hmac_md5_reference_plaintext[i],
+hmac_md5_reference_length[i],
+NULL, 0,
+hmac_md5_reference_digest[i],
+HMAC_MD5_96_CHECK_LEN);
}
 }
 
-- 
2.6.3.372.gcb93895


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


[lng-odp] [PATCH v2 3/3] validation: crypto: validate sha256_check function

2016-01-05 Thread Nicolas Morey-Chaisemartin
Signed-off-by: Nicolas Morey-Chaisemartin 
---
 test/validation/crypto/odp_crypto_test_inp.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 401d225..f3ac4e0 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -654,6 +654,21 @@ void crypto_test_alg_hmac_sha256(void)
 NULL, 0,
 hmac_sha256_reference_digest[i],
 HMAC_SHA256_128_CHECK_LEN);
+
+   /* Now "decode" to validate the auth check function */
+   alg_test(ODP_CRYPTO_OP_DECODE,
+ODP_CIPHER_ALG_NULL,
+iv,
+iv.data,
+cipher_key,
+ODP_AUTH_ALG_SHA256_128,
+auth_key,
+NULL, NULL,
+hmac_sha256_reference_plaintext[i],
+hmac_sha256_reference_length[i],
+NULL, 0,
+hmac_sha256_reference_digest[i],
+HMAC_SHA256_128_CHECK_LEN);
}
 }
 
-- 
2.6.3.372.gcb93895

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


Re: [lng-odp] [API-NEXT PATCH v3 5/6] validation: time: add test for odp_time_local_res() and use resolution

2016-01-06 Thread Nicolas Morey-Chaisemartin


On 12/17/2015 04:29 PM, Ivan Khoronzhuk wrote:
> This function is used to get resolution, test uses it to
> check other APIs.
>
> Signed-off-by: Ivan Khoronzhuk 
> ---
>  test/validation/time/time.c | 46 
> ++---
>  test/validation/time/time.h |  1 +
>  2 files changed, 32 insertions(+), 15 deletions(-)
>
> diff --git a/test/validation/time/time.c b/test/validation/time/time.c
> index cef..0fe8c5a 100644
> --- a/test/validation/time/time.c
> +++ b/test/validation/time/time.c
> @@ -8,9 +8,12 @@
>  #include "odp_cunit_common.h"
>  #include "time.h"
>  
> -#define TOLERANCE 1
>  #define BUSY_LOOP_CNT3000/* used for t > min 
> resolution */
>  #define BUSY_LOOP_CNT_LONG   120 /* used for t > 4 sec */
> +#define MIN_TIME_RATE32000
> +#define MAX_TIME_RATE150
> +
> +static uint64_t res;
>  
>  void time_test_odp_constants(void)
>  {
> @@ -22,6 +25,18 @@ void time_test_odp_constants(void)
>   CU_ASSERT(ns == ODP_TIME_USEC_IN_NS);
>  }
>  
> +void time_test_res(void)
> +{
> + uint64_t rate;
> +
> + rate = odp_time_local_res();
> + CU_ASSERT(rate > MIN_TIME_RATE);
> + CU_ASSERT(rate < MAX_TIME_RATE);
> +
> + res = ODP_TIME_SEC_IN_NS / rate;
> + res = res ? res : 1;
> +}
> +

Sorry. I'm a bit late on that.
Why can't the clock resolution be lower than 32000 ns ?
As long as resolution is > 0, and not "huge", shouldn't it be OK ?

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


<    1   2   3   4   5   6   7   >