[lng-odp] [PATCH 2.0 v3 1/2] linux-gen: packet: apply modular framework and create subsystem

2017-11-30 Thread Github ODP bot
From: Kevin Wang 

Move packet APIs to the modular framework.

Signed-off-by: Kevin Wang 
Reviewed-by: Ola Liljedahl 
Reviewed-by: Honnappa Nagarahalli 
Reviewed-by: Brian Brooks 
Reviewed-by: Yi He 
---
/** Email created from pull request 259 (kevinwangsk:2.0-packet-PR)
 ** https://github.com/Linaro/odp/pull/259
 ** Patch: https://github.com/Linaro/odp/pull/259.patch
 ** Base sha: 00c7441fae53949dd87855d48102f932f8f64537
 ** Merge commit sha: 86f7e0eb73981bba8f4d1bed7e1a30ce38acc72c
 **/
 include/Makefile.am   |   1 +
 include/subsystem/spec/packet_subsystem.h | 331 ++
 platform/linux-generic/Makefile.am|   1 +
 platform/linux-generic/packet/subsystem.c |  18 ++
 4 files changed, 351 insertions(+)
 create mode 100644 include/subsystem/spec/packet_subsystem.h
 create mode 100644 platform/linux-generic/packet/subsystem.c

diff --git a/include/Makefile.am b/include/Makefile.am
index b7c31c1f7..d7b440d93 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -71,6 +71,7 @@ odpdrvspecinclude_HEADERS = \
 subsystemspecincludedir= $(includedir)/subsystem/spec
 subsystemspecinclude_HEADERS = \
  subsystem/spec/buffer_subsystem.h \
+ subsystem/spec/packet_subsystem.h \
  subsystem/spec/pool_subsystem.h \
  subsystem/spec/queue_subsystem.h \
  subsystem/spec/schedule_subsystem.h
diff --git a/include/subsystem/spec/packet_subsystem.h 
b/include/subsystem/spec/packet_subsystem.h
new file mode 100644
index 0..6f33f726e
--- /dev/null
+++ b/include/subsystem/spec/packet_subsystem.h
@@ -0,0 +1,331 @@
+/* Copyright (c) 2017, ARM Limited. All rights reserved.
+ *
+ * Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#ifndef ODP_PACKET_SUBSYSTEM_H_
+#define ODP_PACKET_SUBSYSTEM_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+#include 
+
+#define PACKET_SUBSYSTEM_VERSION 0x0001UL
+
+/* ODP packet public APIs subsystem */
+ODP_SUBSYSTEM_DECLARE(packet);
+
+/* Subsystem APIs declarations */
+ODP_SUBSYSTEM_API(packet, odp_packet_t, alloc, odp_pool_t pool,
+ uint32_t len);
+ODP_SUBSYSTEM_API(packet, int, alloc_multi, odp_pool_t pool,
+ uint32_t len, odp_packet_t pkt[], int num);
+ODP_SUBSYSTEM_API(packet, void, free, odp_packet_t pkt);
+ODP_SUBSYSTEM_API(packet, void, free_multi, const odp_packet_t pkt[], int num);
+ODP_SUBSYSTEM_API(packet, int, has_error, odp_packet_t pkt);
+ODP_SUBSYSTEM_API(packet, void, prefetch, odp_packet_t pkt,
+ uint32_t offset, uint32_t len);
+ODP_SUBSYSTEM_API(packet, void *, data, odp_packet_t pkt);
+ODP_SUBSYSTEM_API(packet, int, input_index, odp_packet_t pkt);
+ODP_SUBSYSTEM_API(packet, int, reset, odp_packet_t pkt, uint32_t len);
+ODP_SUBSYSTEM_API(packet, odp_packet_t, from_event, odp_event_t ev);
+ODP_SUBSYSTEM_API(packet, odp_event_t, to_event, odp_packet_t pkt);
+ODP_SUBSYSTEM_API(packet, void *, head, odp_packet_t pkt);
+ODP_SUBSYSTEM_API(packet, uint32_t, buf_len, odp_packet_t pkt);
+ODP_SUBSYSTEM_API(packet, uint32_t, seg_len, odp_packet_t pkt);
+ODP_SUBSYSTEM_API(packet, uint32_t, len, odp_packet_t pkt);
+ODP_SUBSYSTEM_API(packet, uint32_t, headroom, odp_packet_t pkt);
+ODP_SUBSYSTEM_API(packet, uint32_t, tailroom, odp_packet_t pkt);
+ODP_SUBSYSTEM_API(packet, void *, tail, odp_packet_t pkt);
+ODP_SUBSYSTEM_API(packet, void *, offset, odp_packet_t pkt, uint32_t offset,
+ uint32_t *len, odp_packet_seg_t *seg);
+ODP_SUBSYSTEM_API(packet, void *, push_head, odp_packet_t pkt, uint32_t len);
+ODP_SUBSYSTEM_API(packet, void *, pull_head, odp_packet_t pkt, uint32_t len);
+ODP_SUBSYSTEM_API(packet, void *, push_tail, odp_packet_t pkt, uint32_t len);
+ODP_SUBSYSTEM_API(packet, void *, pull_tail, odp_packet_t pkt, uint32_t len);
+ODP_SUBSYSTEM_API(packet, int, extend_head, odp_packet_t *pkt,
+ uint32_t len, void **data_ptr, uint32_t *seg_len);
+ODP_SUBSYSTEM_API(packet, int, trunc_head, odp_packet_t *pkt,
+ uint32_t len, void **data_ptr, uint32_t *seg_len);
+ODP_SUBSYSTEM_API(packet, int, extend_tail, odp_packet_t *pkt,
+ uint32_t len, void **data_ptr, uint32_t *seg_len);
+ODP_SUBSYSTEM_API(packet, int, trunc_tail, odp_packet_t *pkt,
+ uint32_t len, void **tail_ptr, uint32_t *tailroom);
+ODP_SUBSYSTEM_API(packet, int, add_data, odp_packet_t *pkt,
+ uint32_t offset, uint32_t len);
+ODP_SUBSYSTEM_API(packet, int, rem_data, odp_packet_t *pkt,
+ uint32_t offset, uint32_t len);
+ODP_SUBSYSTEM_API(packet, int, align, odp_packet_t *pkt,
+ uint32_t offset, uint32_t len, uint32_t align);
+ODP_SUBSYSTEM_API(packet, int, is_segmented, odp_packet_t pkt);
+ODP_SUBSYSTEM_API(packet, 

[lng-odp] [PATCH 2.0 v3 2/2] linux-gen: packet: add generic implementation module

2017-11-30 Thread Github ODP bot
From: Kevin Wang 

Move linux-generic packet implementation to packet modular
framework.

Signed-off-by: Kevin Wang 
Reviewed-by: Ola Liljedahl 
Reviewed-by: Honnappa Nagarahalli 
Reviewed-by: Brian Brooks 
Reviewed-by: Yi He 
---
/** Email created from pull request 259 (kevinwangsk:2.0-packet-PR)
 ** https://github.com/Linaro/odp/pull/259
 ** Patch: https://github.com/Linaro/odp/pull/259.patch
 ** Base sha: 00c7441fae53949dd87855d48102f932f8f64537
 ** Merge commit sha: 86f7e0eb73981bba8f4d1bed7e1a30ce38acc72c
 **/
 platform/linux-generic/Makefile.am |   6 +-
 .../include/odp/api/plat/packet_flag_inlines.h |  16 -
 .../include/odp/api/plat/packet_inlines.h  |  13 -
 .../include/odp/api/plat/packet_inlines_api.h  | 108 ---
 .../linux-generic/include/odp_packet_internal.h|   1 +
 platform/linux-generic/odp_packet_flags.c  | 306 
 .../{odp_packet.c => packet/generic.c} | 826 +
 platform/linux-generic/packet/subsystem.c  | 683 +
 8 files changed, 1379 insertions(+), 580 deletions(-)
 delete mode 100644 
platform/linux-generic/include/odp/api/plat/packet_inlines_api.h
 delete mode 100644 platform/linux-generic/odp_packet_flags.c
 rename platform/linux-generic/{odp_packet.c => packet/generic.c} (68%)

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 86f880b0d..134a7f5f4 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -94,9 +94,7 @@ odpapiplatinclude_HEADERS = \
  include/odp/api/plat/init_types.h \
  include/odp/api/plat/ipsec_types.h \
  include/odp/api/plat/packet_flag_inlines.h \
- include/odp/api/plat/packet_flag_inlines_api.h \
  include/odp/api/plat/packet_inlines.h \
- include/odp/api/plat/packet_inlines_api.h \
  include/odp/api/plat/packet_types.h \
  include/odp/api/plat/packet_io_types.h \
  include/odp/api/plat/pool_types.h \
@@ -239,10 +237,9 @@ __LIB__libodp_linux_la_SOURCES = \
   odp_ipsec_events.c \
   odp_ipsec_sad.c \
   odp_name_table.c \
-  odp_packet.c \
-  odp_packet_flags.c \
   odp_packet_io.c \
   odp_packet_io_pool.c \
+  packet/generic.c \
   packet/subsystem.c \
   pktio/ethtool.c \
   pktio/subsystem.c \
@@ -351,6 +348,7 @@ endif
 
 pool/generic.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE
 buffer/generic.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE
+packet/generic.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE
 if ODP_SCHEDULE_SCALABLE
 __LIB__libodp_linux_la_SOURCES += schedule/scalable.c \
  schedule/scalable_ordered.c
diff --git a/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h 
b/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h
index 42003e317..ed41fb92f 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h
@@ -70,20 +70,4 @@ static inline int _odp_packet_has_ts(odp_packet_t pkt)
return flags.timestamp;
 }
 
-/* Include inlined versions of API functions */
-#include 
-#if ODP_ABI_COMPAT == 0
-
-/** @ingroup odp_packet
- *  @{
- */
-
-#include 
-
-/**
- * @}
- */
-
-#endif
-
 #endif
diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h 
b/platform/linux-generic/include/odp/api/plat/packet_inlines.h
index 06bcf8557..098f31a21 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h
@@ -159,18 +159,5 @@ static inline odp_buffer_t packet_to_buffer(odp_packet_t 
pkt)
 
 /* Include inlined versions of API functions */
 #include 
-#if ODP_ABI_COMPAT == 0
-
-/** @ingroup odp_packet
- *  @{
- */
-
-#include 
-
-/**
- * @}
- */
-
-#endif
 
 #endif
diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h 
b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h
deleted file mode 100644
index 7eaaa85ec..0
--- a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* Copyright (c) 2017, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-/**
- * @file
- *
- * Packet inline functions
- */
-
-#ifndef _ODP_PLAT_PACKET_INLINES_API_H_
-#define _ODP_PLAT_PACKET_INLINES_API_H_
-
-_ODP_INLINE void *odp_packet_data(odp_packet_t pkt)
-{
-   return _odp_packet_data(pkt);
-}
-
-_ODP_INLINE uint32_t 

[lng-odp] [PATCH 2.0 v3 0/2] Move packet to modular framework

2017-11-30 Thread Github ODP bot


github
/** Email created from pull request 259 (kevinwangsk:2.0-packet-PR)
 ** https://github.com/Linaro/odp/pull/259
 ** Patch: https://github.com/Linaro/odp/pull/259.patch
 ** Base sha: 00c7441fae53949dd87855d48102f932f8f64537
 ** Merge commit sha: 86f7e0eb73981bba8f4d1bed7e1a30ce38acc72c
 **/
/github

checkpatch.pl
total: 0 errors, 0 warnings, 0 checks, 363 lines checked


to_send-p-000.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 2105 lines checked


to_send-p-001.patch has no obvious style problems and is ready for submission.
/checkpatch.pl


Re: [lng-odp] [PATCH API-NEXT v9] IPsec IPv6 implementation

2017-11-30 Thread Github ODP bot
Bill Fischofer(Bill-Fischofer-Linaro) replied on github web page:

platform/linux-generic/odp_ipsec.c
@@ -158,7 +158,7 @@ static inline int _odp_ipv4_csum_update(odp_packet_t pkt)
2, );
 }
 
-#define ipv4_hdr_len(ip) (_ODP_IPV4HDR_IHL(ip->ver_ihl) * 4)
+#define ipv4_hdr_len(ip) (_ODP_IPV4HDR_IHL((ip)->ver_ihl) * 4)


Comment:
Are you really going to use this as `ipv4_hdr_len(pkt + 2)`? The parens in the 
expansion would obscure that.

> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
> Same comment here.


>> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
>> Causes a checkpatch warning. I assume this is temporary staging, but it 
>> would be good to include a comment explaining why this is needed for now.


https://github.com/Linaro/odp/pull/304#discussion_r154251992
updated_at 2017-12-01 02:23:24


Re: [lng-odp] [PATCH API-NEXT v9] IPsec IPv6 implementation

2017-11-30 Thread Github ODP bot
Bill Fischofer(Bill-Fischofer-Linaro) replied on github web page:

test/validation/api/ipsec/ipsec_test_in.c
@@ -1094,8 +1096,10 @@ odp_testinfo_t ipsec_in_suite[] = {
  ipsec_check_esp_aes_gcm_256),
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_mcgrew_gcm_4_esp,
  ipsec_check_esp_aes_gcm_128),
+#if 0


Comment:
Same comment here.

> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
> Causes a checkpatch warning. I assume this is temporary staging, but it would 
> be good to include a comment explaining why this is needed for now.


https://github.com/Linaro/odp/pull/304#discussion_r154251223
updated_at 2017-12-01 02:23:24


Re: [lng-odp] [PATCH API-NEXT v9] IPsec IPv6 implementation

2017-11-30 Thread Github ODP bot
Bill Fischofer(Bill-Fischofer-Linaro) replied on github web page:

test/validation/api/ipsec/ipsec_test_in.c
@@ -947,6 +947,7 @@ static void test_in_ipv4_mcgrew_gcm_4_esp(void)
ipsec_sa_destroy(sa);
 }
 
+#if 0


Comment:
Causes a checkpatch warning. I assume this is temporary staging, but it would 
be good to include a comment explaining why this is needed for now.

https://github.com/Linaro/odp/pull/304#discussion_r154251189
updated_at 2017-12-01 02:23:24


[lng-odp] [PATCH API-NEXT v9 15/15] validation: ipsec: add ODP_IPSEC_FRAG_CHECK checks

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 test/validation/api/ipsec/ipsec.c  |   4 +-
 test/validation/api/ipsec/ipsec.h  |   2 +
 test/validation/api/ipsec/ipsec_test_out.c | 194 +
 3 files changed, 198 insertions(+), 2 deletions(-)

diff --git a/test/validation/api/ipsec/ipsec.c 
b/test/validation/api/ipsec/ipsec.c
index aa46a236e..097216730 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -556,8 +556,8 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
memset(, 0, sizeof(param));
param.num_sa = 1;
param.sa = 
-   param.num_opt = 0;
-   param.opt = NULL;
+   param.num_opt = part->num_opt;
+   param.opt = >opt;
 
if (ODP_IPSEC_OP_MODE_SYNC == suite_context.outbound_op_mode) {
CU_ASSERT_EQUAL(part->out_pkt, odp_ipsec_out(, 1,
diff --git a/test/validation/api/ipsec/ipsec.h 
b/test/validation/api/ipsec/ipsec.h
index 9a24dd38c..f2ebd388c 100644
--- a/test/validation/api/ipsec/ipsec.h
+++ b/test/validation/api/ipsec/ipsec.h
@@ -45,6 +45,8 @@ typedef struct {
 typedef struct {
const ipsec_test_packet *pkt_in;
odp_bool_t lookup;
+   int num_opt;
+   odp_ipsec_out_opt_t opt;
int out_pkt;
struct {
odp_ipsec_op_status_t status;
diff --git a/test/validation/api/ipsec/ipsec_test_out.c 
b/test/validation/api/ipsec/ipsec_test_out.c
index 2ee8a1319..4751e6ec8 100644
--- a/test/validation/api/ipsec/ipsec_test_out.c
+++ b/test/validation/api/ipsec/ipsec_test_out.c
@@ -500,6 +500,192 @@ static void test_out_ipv4_esp_null_aes_gmac_128(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_out_ipv4_ah_sha256_frag_check(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   false, true, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.outbound.frag_mode = ODP_IPSEC_FRAG_CHECK;
+   param.outbound.mtu = 100;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.mtu = 1,
+ .pkt_out = NULL },
+   },
+   };
+
+   ipsec_test_part test2 = {
+   .pkt_in = _ipv4_icmp_0,
+   .num_opt = 1,
+   .opt = { .mode = ODP_IPSEC_FRAG_DISABLED, },
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0_ah_sha256_1 },
+   },
+   };
+
+   ipsec_check_out_one(, sa);
+
+   ipsec_check_out_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_out_ipv4_ah_sha256_frag_check_2(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   false, true, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.outbound.frag_mode = ODP_IPSEC_FRAG_CHECK;
+   param.outbound.mtu = 100;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.mtu = 1,
+ .pkt_out = NULL },
+   },
+   };
+
+   ipsec_test_part test2 = {
+   .pkt_in = _ipv4_icmp_0,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0_ah_sha256_1 },
+   },
+   };
+
+   ipsec_check_out_one(, sa);
+
+   odp_ipsec_sa_mtu_update(sa, 256);
+
+   ipsec_check_out_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_out_ipv4_esp_null_sha256_frag_check(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   false, false, 123, 

[lng-odp] [PATCH API-NEXT v9 14/15] validation: ipsec: fix out inline with NULL pkt_out

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

pkt_out can be NULL if we expect an error. IPsec outbound inline needs
proper outer header to function. Pass L2 header from inbound packet if
outbound packet is NULL.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 test/validation/api/ipsec/ipsec.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/test/validation/api/ipsec/ipsec.c 
b/test/validation/api/ipsec/ipsec.c
index 7b39c2c5a..aa46a236e 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -583,10 +583,18 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
} else {
struct odp_ipsec_out_inline_param_t inline_param;
odp_queue_t queue;
-   uint32_t hdr_len = part->out[0].pkt_out->l3_offset;
-   uint8_t hdr[hdr_len];
+   uint32_t hdr_len;
+   uint8_t hdr[32];
 
-   memcpy(hdr, part->out[0].pkt_out->data, hdr_len);
+   if (NULL != part->out[0].pkt_out) {
+   hdr_len = part->out[0].pkt_out->l3_offset;
+   CU_ASSERT_FATAL(hdr_len <= sizeof(hdr));
+   memcpy(hdr, part->out[0].pkt_out->data, hdr_len);
+   } else {
+   hdr_len = part->pkt_in->l3_offset;
+   CU_ASSERT_FATAL(hdr_len <= sizeof(hdr));
+   memcpy(hdr, part->pkt_in->data, hdr_len);
+   }
inline_param.pktio = suite_context.pktio;
inline_param.outer_hdr.ptr = hdr;
inline_param.outer_hdr.len = hdr_len;



[lng-odp] [PATCH API-NEXT v9 13/15] linux-gen: ipsec: support ODP_IPSEC_FRAG_CHECK

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Support checking MTU after IPsec transformation.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 platform/linux-generic/odp_ipsec.c | 39 ++
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index 3c539b515..a393c5051 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -990,7 +990,8 @@ static int ipsec_out_esp(odp_packet_t *pkt,
 ipsec_state_t *state,
 ipsec_sa_t *ipsec_sa,
 odp_crypto_packet_op_param_t *param,
-odp_ipsec_op_status_t *status)
+odp_ipsec_op_status_t *status,
+uint32_t mtu)
 {
_odp_esphdr_t esp;
_odp_esptrl_t esptrl;
@@ -1026,6 +1027,11 @@ static int ipsec_out_esp(odp_packet_t *pkt,
udphdr.chksum = 0; /* should be 0 by RFC */
}
 
+   if (state->ip_tot_len + hdr_len + trl_len > mtu) {
+   status->error.mtu = 1;
+   return -1;
+   }
+
if (ipsec_out_iv(state, ipsec_sa) < 0) {
status->error.alg = 1;
return -1;
@@ -1124,7 +1130,8 @@ static int ipsec_out_ah(odp_packet_t *pkt,
ipsec_state_t *state,
ipsec_sa_t *ipsec_sa,
odp_crypto_packet_op_param_t *param,
-   odp_ipsec_op_status_t *status)
+   odp_ipsec_op_status_t *status,
+   uint32_t mtu)
 {
_odp_ahhdr_t ah;
unsigned hdr_len = _ODP_AHHDR_LEN + ipsec_sa->esp_iv_len +
@@ -1132,6 +1139,11 @@ static int ipsec_out_ah(odp_packet_t *pkt,
uint16_t ipsec_offset = state->ip_offset + state->ip_hdr_len;
uint8_t proto = _ODP_IPPROTO_AH;
 
+   if (state->ip_tot_len + hdr_len > mtu) {
+   status->error.mtu = 1;
+   return -1;
+   }
+
memset(, 0, sizeof(ah));
ah.spi = odp_cpu_to_be_32(ipsec_sa->spi);
ah.seq_no = odp_cpu_to_be_32(ipsec_seq_no(ipsec_sa));
@@ -1228,7 +1240,7 @@ static void ipsec_out_ah_post(ipsec_state_t *state, 
odp_packet_t pkt)
 static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
odp_ipsec_sa_t sa,
odp_packet_t *pkt_out,
-   const odp_ipsec_out_opt_t *opt ODP_UNUSED,
+   const odp_ipsec_out_opt_t *opt,
odp_ipsec_op_status_t *status)
 {
ipsec_state_t state;
@@ -1237,6 +1249,7 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
int rc;
odp_crypto_packet_result_t crypto; /**< Crypto operation result */
odp_packet_hdr_t *pkt_hdr;
+   uint32_t mtu;
 
state.ip_offset = odp_packet_l3_offset(pkt);
ODP_ASSERT(ODP_PACKET_OFFSET_INVALID != state.ip_offset);
@@ -1247,6 +1260,12 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
ipsec_sa = _odp_ipsec_sa_use(sa);
ODP_ASSERT(NULL != ipsec_sa);
 
+   if ((opt && opt->mode == ODP_IPSEC_FRAG_CHECK) ||
+   (!opt && ipsec_sa->out.frag_mode == ODP_IPSEC_FRAG_CHECK))
+   mtu = ipsec_sa->out.mtu;
+   else
+   mtu = UINT32_MAX;
+
/* Initialize parameters block */
memset(, 0, sizeof(param));
 
@@ -1281,9 +1300,9 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
}
 
if (ODP_IPSEC_ESP == ipsec_sa->proto) {
-   rc = ipsec_out_esp(, , ipsec_sa, , status);
+   rc = ipsec_out_esp(, , ipsec_sa, , status, mtu);
} else if (ODP_IPSEC_AH == ipsec_sa->proto) {
-   rc = ipsec_out_ah(, , ipsec_sa, , status);
+   rc = ipsec_out_ah(, , ipsec_sa, , status, mtu);
} else {
status->error.alg = 1;
goto err;
@@ -1402,10 +1421,6 @@ int odp_ipsec_in(const odp_packet_t pkt_in[], int num_in,
return in_pkt;
 }
 
-static const odp_ipsec_out_opt_t default_opt = {
-   .mode = ODP_IPSEC_FRAG_DISABLED,
-};
-
 int odp_ipsec_out(const odp_packet_t pkt_in[], int num_in,
  odp_packet_t pkt_out[], int *num_out,
  const odp_ipsec_out_param_t *param)
@@ -1434,7 +1449,7 @@ int odp_ipsec_out(const odp_packet_t pkt_in[], int num_in,
ODP_ASSERT(ODP_IPSEC_SA_INVALID != sa);
 
if (0 == param->num_opt)
-   opt = _opt;
+   opt 

[lng-odp] [PATCH API-NEXT v9 12/15] linux-gen: ipsec: store mtu and frag_mode in SA

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 platform/linux-generic/include/odp_ipsec_internal.h |  2 ++
 platform/linux-generic/odp_ipsec_sad.c  | 14 +++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/platform/linux-generic/include/odp_ipsec_internal.h 
b/platform/linux-generic/include/odp_ipsec_internal.h
index 822c9016b..c6f241fac 100644
--- a/platform/linux-generic/include/odp_ipsec_internal.h
+++ b/platform/linux-generic/include/odp_ipsec_internal.h
@@ -156,6 +156,8 @@ struct ipsec_sa_s {
struct {
odp_atomic_u64_t counter; /* for CTR/GCM */
odp_atomic_u32_t seq;
+   odp_ipsec_frag_mode_t frag_mode;
+   uint32_t mtu;
 
union {
struct {
diff --git a/platform/linux-generic/odp_ipsec_sad.c 
b/platform/linux-generic/odp_ipsec_sad.c
index 82b3c4522..2d6321166 100644
--- a/platform/linux-generic/odp_ipsec_sad.c
+++ b/platform/linux-generic/odp_ipsec_sad.c
@@ -230,6 +230,8 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const 
odp_ipsec_sa_param_t *param)
odp_atomic_init_u64(_sa->in.antireplay, 0);
} else {
odp_atomic_store_u32(_sa->out.seq, 1);
+   ipsec_sa->out.frag_mode = param->outbound.frag_mode;
+   ipsec_sa->out.mtu = param->outbound.mtu;
}
ipsec_sa->dec_ttl = param->opt.dec_ttl;
ipsec_sa->copy_dscp = param->opt.copy_dscp;
@@ -489,10 +491,16 @@ uint64_t odp_ipsec_sa_to_u64(odp_ipsec_sa_t sa)
 
 int odp_ipsec_sa_mtu_update(odp_ipsec_sa_t sa, uint32_t mtu)
 {
-   (void)sa;
-   (void)mtu;
+   ipsec_sa_t *ipsec_sa;
+
+   ipsec_sa = _odp_ipsec_sa_use(sa);
+   ODP_ASSERT(NULL != ipsec_sa);
 
-   return -1;
+   ipsec_sa->out.mtu = mtu;
+
+   _odp_ipsec_sa_unuse(ipsec_sa);
+
+   return 0;
 }
 
 ipsec_sa_t *_odp_ipsec_sa_lookup(const ipsec_sa_lookup_t *lookup)



[lng-odp] [PATCH API-NEXT v9 11/15] validation: add UDP-encapsulated IPsec test cases

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 test/validation/api/ipsec/ipsec_test_in.c  | 134 +
 test/validation/api/ipsec/ipsec_test_out.c |  66 ++
 test/validation/api/ipsec/test_vectors.h   |  99 +
 3 files changed, 299 insertions(+)

diff --git a/test/validation/api/ipsec/ipsec_test_in.c 
b/test/validation/api/ipsec/ipsec_test_in.c
index 15e1fe14f..6262f4cb5 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -376,6 +376,69 @@ static void test_in_ipv4_esp_null_sha256_tun_ipv6(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv4_esp_udp_null_sha256(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.opt.udp_encap = 1;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0_esp_udp_null_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_in_ipv4_esp_udp_null_sha256_lookup(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.opt.udp_encap = 1;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0_esp_udp_null_sha256_1,
+   .lookup = 1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
 static void test_in_ipv4_ah_sha256_noreplay(void)
 {
odp_ipsec_sa_param_t param;
@@ -1317,6 +1380,69 @@ static void test_in_ipv6_esp_null_sha256_tun_ipv6(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv6_esp_udp_null_sha256(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.opt.udp_encap = 1;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv6_icmp_0_esp_udp_null_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv6_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_in_ipv6_esp_udp_null_sha256_lookup(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.opt.udp_encap = 1;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv6_icmp_0_esp_udp_null_sha256_1,
+   .lookup = 1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv6_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
 static void ipsec_test_capability(void)
 {
odp_ipsec_capability_t capa;
@@ -1372,6 +1498,10 @@ odp_testinfo_t 

[lng-odp] [PATCH API-NEXT v9 9/15] linux-gen: add support for UDP-encapsulated ESP packets

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 .../linux-generic/include/odp_ipsec_internal.h |  1 +
 platform/linux-generic/include/protocols/udp.h |  2 +
 platform/linux-generic/odp_ipsec.c | 53 +-
 platform/linux-generic/odp_ipsec_sad.c |  1 +
 4 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/platform/linux-generic/include/odp_ipsec_internal.h 
b/platform/linux-generic/include/odp_ipsec_internal.h
index b294e7c4a..822c9016b 100644
--- a/platform/linux-generic/include/odp_ipsec_internal.h
+++ b/platform/linux-generic/include/odp_ipsec_internal.h
@@ -131,6 +131,7 @@ struct ipsec_sa_s {
unsignedcopy_df : 1;
unsignedcopy_flabel : 1;
unsignedaes_ctr_iv : 1;
+   unsignedudp_encap : 1;
 
/* Only for outbound */
unsigneduse_counter_iv : 1;
diff --git a/platform/linux-generic/include/protocols/udp.h 
b/platform/linux-generic/include/protocols/udp.h
index 535aba855..85984c992 100644
--- a/platform/linux-generic/include/protocols/udp.h
+++ b/platform/linux-generic/include/protocols/udp.h
@@ -38,6 +38,8 @@ typedef struct ODP_PACKED {
 ODP_STATIC_ASSERT(sizeof(_odp_udphdr_t) == _ODP_UDPHDR_LEN,
  "_ODP_UDPHDR_T__SIZE_ERROR");
 
+#define _ODP_UDP_IPSEC_PORT 4500
+
 /**
  * @}
  */
diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index 2749268ae..20031bddc 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -378,9 +379,29 @@ static int ipsec_in_esp(odp_packet_t *pkt,
_odp_esphdr_t esp;
uint16_t ipsec_offset;
ipsec_sa_t *ipsec_sa;
+   odp_bool_t udp_encap = false;
 
ipsec_offset = state->ip_offset + state->ip_hdr_len;
 
+   if (_ODP_IPPROTO_UDP == state->ip_next_hdr) {
+   _odp_udphdr_t udp;
+   uint16_t ip_data_len = state->ip_tot_len -
+  state->ip_hdr_len;
+
+   odp_packet_copy_to_mem(*pkt, ipsec_offset,
+  _ODP_UDPHDR_LEN, );
+
+   if (udp.dst_port != odp_cpu_to_be_16(_ODP_UDP_IPSEC_PORT) ||
+   udp.length != odp_cpu_to_be_16(ip_data_len)) {
+   status->error.proto = 1;
+   return -1;
+   }
+
+   ipsec_offset += _ODP_UDPHDR_LEN;
+   state->ip_hdr_len += _ODP_UDPHDR_LEN;
+   udp_encap = true;
+   }
+
if (odp_packet_copy_to_mem(*pkt, ipsec_offset,
   sizeof(esp), ) < 0) {
status->error.alg = 1;
@@ -396,6 +417,11 @@ static int ipsec_in_esp(odp_packet_t *pkt,
if (status->error.all)
return -1;
 
+   if (!!ipsec_sa->udp_encap != udp_encap) {
+   status->error.proto = 1;
+   return -1;
+   }
+
if (ipsec_in_iv(*pkt, state, ipsec_sa,
ipsec_offset + _ODP_ESPHDR_LEN) < 0) {
status->error.alg = 1;
@@ -446,6 +472,11 @@ static int ipsec_in_esp_post(odp_packet_t pkt,
 ipsec_padding, esptrl.pad_len) != 0)
return -1;
 
+   if (udp_encap) {
+   state->ip_hdr_len -= _ODP_UDPHDR_LEN;
+   state->in.hdr_len += _ODP_UDPHDR_LEN;
+   }
+
odp_packet_copy_from_mem(pkt, state->ip_next_hdr_offset,
 1, _header);
state->in.trl_len += esptrl.pad_len;
@@ -603,7 +634,8 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
}
 
/* Check IP header for IPSec protocols and look it up */
-   if (_ODP_IPPROTO_ESP == state.ip_next_hdr) {
+   if (_ODP_IPPROTO_ESP == state.ip_next_hdr ||
+   _ODP_IPPROTO_UDP == state.ip_next_hdr) {
rc = ipsec_in_esp(, , _sa, sa, , status);
} else if (_ODP_IPPROTO_AH == state.ip_next_hdr) {
rc = ipsec_in_ah(, , _sa, sa, , status);
@@ -962,6 +994,7 @@ static int ipsec_out_esp(odp_packet_t *pkt,
 {
_odp_esphdr_t esp;
_odp_esptrl_t esptrl;
+   _odp_udphdr_t udphdr;
uint32_t encrypt_len;
uint16_t ip_data_len = state->ip_tot_len -
   state->ip_hdr_len;
@@ -983,6 +1016,16 @@ static int ipsec_out_esp(odp_packet_t *pkt,
   ip_data_len +
 

[lng-odp] [PATCH API-NEXT v9 10/15] linux-gen: packet: add flag for UDP-encapsulated IPsec packets

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 platform/linux-generic/include/odp/api/plat/packet_types.h |  1 +
 platform/linux-generic/odp_ipsec.c |  2 +-
 platform/linux-generic/odp_packet.c| 11 +++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/platform/linux-generic/include/odp/api/plat/packet_types.h 
b/platform/linux-generic/include/odp/api/plat/packet_types.h
index 82fc66e53..128e83148 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_types.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_types.h
@@ -151,6 +151,7 @@ typedef union {
 
uint64_t l3_chksum_done:1; /**< L3 checksum validation done */
uint64_t l4_chksum_done:1; /**< L4 checksum validation done */
+   uint64_t ipsec_udp:1; /**< UDP-encapsulated IPsec packet */
};
 
 } _odp_packet_input_flags_t;
diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index 20031bddc..3c539b515 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -472,7 +472,7 @@ static int ipsec_in_esp_post(odp_packet_t pkt,
 ipsec_padding, esptrl.pad_len) != 0)
return -1;
 
-   if (udp_encap) {
+   if (_ODP_IPPROTO_UDP == state->ip_next_hdr) {
state->ip_hdr_len -= _ODP_UDPHDR_LEN;
state->in.hdr_len += _ODP_UDPHDR_LEN;
}
diff --git a/platform/linux-generic/odp_packet.c 
b/platform/linux-generic/odp_packet.c
index bdcb482fa..167f8cbc6 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2141,6 +2141,17 @@ static inline void parse_udp(packet_parser_t *prs,
if (odp_unlikely(udplen < sizeof(_odp_udphdr_t)))
prs->error_flags.udp_err = 1;
 
+   if (odp_cpu_to_be_16(_ODP_UDP_IPSEC_PORT) == udp->dst_port &&
+   udplen > 4) {
+   uint32_t val;
+
+   memcpy(, udp + 1, 4);
+   if (val != 0) {
+   prs->input_flags.ipsec = 1;
+   prs->input_flags.ipsec_udp = 1;
+   }
+   }
+
if (offset)
*offset   += sizeof(_odp_udphdr_t);
*parseptr += sizeof(_odp_udphdr_t);



[lng-odp] [PATCH API-NEXT v9 8/15] linux-gen: ipsec: simplify seq no handling

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

There is no point in filling artificial AAD struct for AH just for the
sake of sequence number checking. Instead use AAD just for ESP and
provide separate seq_no field.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 platform/linux-generic/odp_ipsec.c | 32 ++--
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index 8088fabad..2749268ae 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -233,6 +233,7 @@ typedef struct {
struct {
uint16_t hdr_len;
uint16_t trl_len;
+   odp_u32be_t seq_no;
} in;
odp_u32be_t ipv4_addr;
uint8_t ipv6_addr[_ODP_IPV6ADDR_LEN];
@@ -247,8 +248,10 @@ typedef struct {
odp_u32be_t ver_tc_flow;
uint8_t hop_limit;
} ah_ipv6;
+   struct {
+   ipsec_aad_t aad;
+   } esp;
};
-   ipsec_aad_t aad;
uint8_t iv[IPSEC_MAX_IV_LEN];
 } ipsec_state_t;
 
@@ -409,10 +412,11 @@ static int ipsec_in_esp(odp_packet_t *pkt,
ipsec_sa->icv_len;
param->override_iv_ptr = state->iv;
 
-   state->aad.spi = esp.spi;
-   state->aad.seq_no = esp.seq_no;
+   state->esp.aad.spi = esp.spi;
+   state->esp.aad.seq_no = esp.seq_no;
+   state->in.seq_no = odp_be_to_cpu_32(esp.seq_no);
 
-   param->aad.ptr = (uint8_t *)>aad;
+   param->aad.ptr = (uint8_t *)>esp.aad;
 
param->auth_range.offset = ipsec_offset;
param->auth_range.length = state->ip_tot_len -
@@ -515,10 +519,7 @@ static int ipsec_in_ah(odp_packet_t *pkt,
ipv6hdr->hop_limit = 0;
}
 
-   state->aad.spi = ah.spi;
-   state->aad.seq_no = ah.seq_no;
-
-   param->aad.ptr = (uint8_t *)>aad;
+   state->in.seq_no = odp_be_to_cpu_32(ah.seq_no);
 
param->auth_range.offset = state->ip_offset;
param->auth_range.length = state->ip_tot_len;
@@ -614,7 +615,7 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
goto err;
 
if (_odp_ipsec_sa_replay_precheck(ipsec_sa,
- odp_be_to_cpu_32(state.aad.seq_no),
+ state.in.seq_no,
  status) < 0)
goto err;
 
@@ -659,7 +660,7 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
goto err;
 
if (_odp_ipsec_sa_replay_update(ipsec_sa,
-   odp_be_to_cpu_32(state.aad.seq_no),
+   state.in.seq_no,
status) < 0)
goto err;
 
@@ -993,10 +994,10 @@ static int ipsec_out_esp(odp_packet_t *pkt,
esp.spi = odp_cpu_to_be_32(ipsec_sa->spi);
esp.seq_no = odp_cpu_to_be_32(ipsec_seq_no(ipsec_sa));
 
-   state->aad.spi = esp.spi;
-   state->aad.seq_no = esp.seq_no;
+   state->esp.aad.spi = esp.spi;
+   state->esp.aad.seq_no = esp.seq_no;
 
-   param->aad.ptr = (uint8_t *)>aad;
+   param->aad.ptr = (uint8_t *)>esp.aad;
 
memset(, 0, sizeof(esptrl));
esptrl.pad_len = encrypt_len - ip_data_len - _ODP_ESPTRL_LEN;
@@ -1117,11 +1118,6 @@ static int ipsec_out_ah(odp_packet_t *pkt,
 
ah.ah_len = hdr_len / 4 - 2;
 
-   state->aad.spi = ah.spi;
-   state->aad.seq_no = ah.seq_no;
-
-   param->aad.ptr = (uint8_t *)>aad;
-
/* For GMAC */
if (ipsec_out_iv(state, ipsec_sa) < 0) {
status->error.alg = 1;



[lng-odp] [PATCH API-NEXT v9 7/15] validation: ipsec: add tests for IPv6 functionality

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 test/validation/api/ipsec/ipsec_test_in.c  | 262 +
 test/validation/api/ipsec/ipsec_test_out.c | 331 +
 test/validation/api/ipsec/test_vectors.h   | 443 +
 3 files changed, 1036 insertions(+)

diff --git a/test/validation/api/ipsec/ipsec_test_in.c 
b/test/validation/api/ipsec/ipsec_test_in.c
index 5af98112a..15e1fe14f 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -71,6 +71,37 @@ static void test_in_ipv4_ah_sha256_tun_ipv4(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv4_ah_sha256_tun_ipv6(void)
+{
+   odp_ipsec_tunnel_param_t tunnel = {};
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, true, 123, ,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0_ah_tun_ipv6_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
 static void test_in_ipv4_ah_sha256_tun_ipv4_notun(void)
 {
odp_ipsec_sa_param_t param;
@@ -314,6 +345,37 @@ static void test_in_ipv4_esp_null_sha256_tun_ipv4(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv4_esp_null_sha256_tun_ipv6(void)
+{
+   odp_ipsec_tunnel_param_t tunnel = {};
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, ,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0_esp_tun_ipv6_null_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
 static void test_in_ipv4_ah_sha256_noreplay(void)
 {
odp_ipsec_sa_param_t param;
@@ -1071,6 +1133,190 @@ static void test_in_ipv4_esp_null_aes_gmac_128(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv6_ah_sha256(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, true, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv6_icmp_0_ah_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv6_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_in_ipv6_ah_sha256_tun_ipv4(void)
+{
+   odp_ipsec_tunnel_param_t tunnel = {};
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, true, 123, ,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv6_icmp_0_ah_tun_ipv4_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv6_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void 

[lng-odp] [PATCH API-NEXT v9 3/15] validation: ipsec: fix next_header field in mcgrew gcm test vectors

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Test vectors from draft-mcgrew-gcm-test-01 contain invalid next_header
field in ESP trailers (0x01 = ICMP instead of 0x04 = IPv4). Correct test
vectors. Test 12 is disabled till NoNH packets are properly supported in
a defined way.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 test/validation/api/ipsec/ipsec_test_in.c |  4 
 test/validation/api/ipsec/test_vectors.h  | 30 +++---
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/test/validation/api/ipsec/ipsec_test_in.c 
b/test/validation/api/ipsec/ipsec_test_in.c
index daafaf69a..5af98112a 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -947,6 +947,7 @@ static void test_in_ipv4_mcgrew_gcm_4_esp(void)
ipsec_sa_destroy(sa);
 }
 
+#if 0
 static void test_in_ipv4_mcgrew_gcm_12_esp(void)
 {
odp_ipsec_tunnel_param_t tunnel = {};
@@ -977,6 +978,7 @@ static void test_in_ipv4_mcgrew_gcm_12_esp(void)
 
ipsec_sa_destroy(sa);
 }
+#endif
 
 static void test_in_ipv4_mcgrew_gcm_15_esp(void)
 {
@@ -1094,8 +1096,10 @@ odp_testinfo_t ipsec_in_suite[] = {
  ipsec_check_esp_aes_gcm_256),
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_mcgrew_gcm_4_esp,
  ipsec_check_esp_aes_gcm_128),
+#if 0
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_mcgrew_gcm_12_esp,
  ipsec_check_esp_aes_gcm_128),
+#endif
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_mcgrew_gcm_15_esp,
  ipsec_check_esp_null_aes_gmac_128),
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_ah_sha256,
diff --git a/test/validation/api/ipsec/test_vectors.h 
b/test/validation/api/ipsec/test_vectors.h
index 51aa97ccb..c057f7765 100644
--- a/test/validation/api/ipsec/test_vectors.h
+++ b/test/validation/api/ipsec/test_vectors.h
@@ -1021,9 +1021,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_2_esp 
= {
0x3d, 0xe8, 0x18, 0x27, 0xc1, 0x0e, 0x9a, 0x4f,
0x51, 0x33, 0x0d, 0x0e, 0xec, 0x41, 0x66, 0x42,
0xcf, 0xbb, 0x85, 0xa5, 0xb4, 0x7e, 0x48, 0xa4,
-   0xec, 0x3b, 0x9b, 0xa9, 0x5d, 0x91, 0x8b, 0xd1,
-   0x83, 0xb7, 0x0d, 0x3a, 0xa8, 0xbc, 0x6e, 0xe4,
-   0xc3, 0x09, 0xe9, 0xd8, 0x5a, 0x41, 0xad, 0x4a,
+   0xec, 0x3b, 0x9b, 0xa9, 0x5d, 0x91, 0x8b, 0xd4,
+   0x26, 0xf8, 0x39, 0x1b, 0x99, 0x27, 0xd0, 0xfc,
+   0xc9, 0x84, 0x56, 0x1b, 0xbb, 0xce, 0x9f, 0xc0,
},
 };
 
@@ -1078,9 +1078,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_3_esp 
= {
0x06, 0xef, 0xae, 0x9d, 0x65, 0xa5, 0xd7, 0x63,
0x74, 0x8a, 0x63, 0x79, 0x85, 0x77, 0x1d, 0x34,
0x7f, 0x05, 0x45, 0x65, 0x9f, 0x14, 0xe9, 0x9d,
-   0xef, 0x84, 0x2d, 0x8e, 0xb3, 0x35, 0xf4, 0xee,
-   0xcf, 0xdb, 0xf8, 0x31, 0x82, 0x4b, 0x4c, 0x49,
-   0x15, 0x95, 0x6c, 0x96,
+   0xef, 0x84, 0x2d, 0x8b, 0x42, 0xf5, 0x64, 0xf5,
+   0x2d, 0xfd, 0xd6, 0xee, 0xf4, 0xf9, 0x2e, 0xad,
+   0xba, 0xc2, 0x39, 0x90,
},
 };
 
@@ -1137,9 +1137,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_4_esp 
= {
0x45, 0x64, 0x76, 0x49, 0x27, 0x19, 0xff, 0xb6,
0x4d, 0xe7, 0xd9, 0xdc, 0xa1, 0xe1, 0xd8, 0x94,
0xbc, 0x3b, 0xd5, 0x78, 0x73, 0xed, 0x4d, 0x18,
-   0x1d, 0x19, 0xd4, 0xd5, 0xc8, 0xc1, 0x8a, 0xf3,
-   0xf8, 0x21, 0xd4, 0x96, 0xee, 0xb0, 0x96, 0xe9,
-   0x8a, 0xd2, 0xb6, 0x9e, 0x47, 0x99, 0xc7, 0x1d,
+   0x1d, 0x19, 0xd4, 0xd5, 0xc8, 0xc1, 0x8a, 0xf6,
+   0xfe, 0x1d, 0x73, 0x72, 0x22, 0x8a, 0x69, 0xf4,
+   0x0d, 0xeb, 0x37, 0x3d, 0xdc, 0x01, 0x67, 0x6b,
},
 };
 
@@ -1177,9 +1177,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_12_esp 
= {
0x43, 0x45, 0x7e, 0x91, 0x82, 0x44, 0x3b, 0xc6,
 
/* Data */
-   0x43, 0x7f, 0x86, 0x6b, 0xcb, 0x3f, 0x69, 0x9f,
-   0xe9, 0xb0, 0x82, 0x2b, 0xac, 0x96, 0x1c, 0x45,
-   0x04, 0xbe, 0xf2, 0x70,
+   0x43, 0x7f, 0x86, 0x51, 0x7e, 0xa5, 0x95, 0xd2,
+   0xca, 0x00, 0x4c, 0x33, 0x38, 0x8c, 0x46, 0x77,
+   0x0c, 0x59, 0x0a, 0xd6,
},
 };
 
@@ -1234,9 +1234,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_15_esp 
= {
0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64,
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
  

[lng-odp] [PATCH API-NEXT v9 5/15] linux-gen: protocols: ip: add more ipv6 defines

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 platform/linux-generic/include/protocols/ip.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/platform/linux-generic/include/protocols/ip.h 
b/platform/linux-generic/include/protocols/ip.h
index 0fc391abe..7b6b736a6 100644
--- a/platform/linux-generic/include/protocols/ip.h
+++ b/platform/linux-generic/include/protocols/ip.h
@@ -161,11 +161,13 @@ typedef struct ODP_PACKED {
 #define _ODP_IPPROTO_IPIP0x04 /**< IP Encapsulation within IP (4) */
 #define _ODP_IPPROTO_TCP 0x06 /**< Transmission Control Protocol (6) */
 #define _ODP_IPPROTO_UDP 0x11 /**< User Datagram Protocol (17) */
+#define _ODP_IPPROTO_IPV60x29 /**< IPv6 Routing header (41) */
 #define _ODP_IPPROTO_ROUTE   0x2B /**< IPv6 Routing header (43) */
 #define _ODP_IPPROTO_FRAG0x2C /**< IPv6 Fragment (44) */
 #define _ODP_IPPROTO_AH  0x33 /**< Authentication Header (51) */
 #define _ODP_IPPROTO_ESP 0x32 /**< Encapsulating Security Payload (50) */
 #define _ODP_IPPROTO_ICMPv6  0x3A /**< Internet Control Message Protocol (58) 
*/
+#define _ODP_IPPROTO_DEST0x3C /**< IPv6 Destination header (60) */
 #define _ODP_IPPROTO_SCTP0x84 /**< Stream Control Transmission protocol
   (132) */
 #define _ODP_IPPROTO_INVALID 0xFF /**< Reserved invalid by IANA */



[lng-odp] [PATCH API-NEXT v9 4/15] linux-gen: don't include odp_ipsec_internal.h in odp_packet_internal.h

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Such include adds unnecessary build dependencies. Just include
, which is enough.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 platform/linux-generic/include/odp_packet_internal.h | 2 +-
 platform/linux-generic/pktio/loop.c  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/platform/linux-generic/include/odp_packet_internal.h 
b/platform/linux-generic/include/odp_packet_internal.h
index ab31d0704..58b7ffe7f 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -25,7 +25,7 @@ extern "C" {
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/platform/linux-generic/pktio/loop.c 
b/platform/linux-generic/pktio/loop.c
index 8bb4b4f14..199aa482f 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 



[lng-odp] [PATCH API-NEXT v9 1/15] validation: ipsec: add ipv4 name parts

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

In preparation to add IPv6 support, add ipv4 everywhere (to test packets
and to test names).

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 test/validation/api/ipsec/ipsec_test_in.c  | 230 ++---
 test/validation/api/ipsec/ipsec_test_out.c | 125 +---
 test/validation/api/ipsec/test_vectors.h   |  38 +++--
 3 files changed, 178 insertions(+), 215 deletions(-)

diff --git a/test/validation/api/ipsec/ipsec_test_in.c 
b/test/validation/api/ipsec/ipsec_test_in.c
index 294e4a5d6..daafaf69a 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -10,7 +10,7 @@
 
 #include "test_vectors.h"
 
-static void test_in_ah_sha256(void)
+static void test_in_ipv4_ah_sha256(void)
 {
odp_ipsec_sa_param_t param;
odp_ipsec_sa_t sa;
@@ -26,12 +26,12 @@ static void test_in_ah_sha256(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_ah_sha256_1,
+   .pkt_in = _ipv4_icmp_0_ah_sha256_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0 },
+ .pkt_out = _ipv4_icmp_0 },
},
};
 
@@ -40,7 +40,7 @@ static void test_in_ah_sha256(void)
ipsec_sa_destroy(sa);
 }
 
-static void test_in_ah_sha256_tun(void)
+static void test_in_ipv4_ah_sha256_tun_ipv4(void)
 {
odp_ipsec_tunnel_param_t tunnel = {};
odp_ipsec_sa_param_t param;
@@ -57,12 +57,12 @@ static void test_in_ah_sha256_tun(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_ah_tun_sha256_1,
+   .pkt_in = _ipv4_icmp_0_ah_tun_ipv4_sha256_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0 },
+ .pkt_out = _ipv4_icmp_0 },
},
};
 
@@ -71,7 +71,7 @@ static void test_in_ah_sha256_tun(void)
ipsec_sa_destroy(sa);
 }
 
-static void test_in_ah_sha256_tun_notun(void)
+static void test_in_ipv4_ah_sha256_tun_ipv4_notun(void)
 {
odp_ipsec_sa_param_t param;
odp_ipsec_sa_t sa;
@@ -87,12 +87,12 @@ static void test_in_ah_sha256_tun_notun(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_ah_tun_sha256_1,
+   .pkt_in = _ipv4_icmp_0_ah_tun_ipv4_sha256_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0_ipip },
+ .pkt_out = _ipv4_icmp_0_ipip },
},
};
 
@@ -101,7 +101,7 @@ static void test_in_ah_sha256_tun_notun(void)
ipsec_sa_destroy(sa);
 }
 
-static void test_in_esp_null_sha256(void)
+static void test_in_ipv4_esp_null_sha256(void)
 {
odp_ipsec_sa_param_t param;
odp_ipsec_sa_t sa;
@@ -117,12 +117,12 @@ static void test_in_esp_null_sha256(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_esp_null_sha256_1,
+   .pkt_in = _ipv4_icmp_0_esp_null_sha256_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0 },
+ .pkt_out = _ipv4_icmp_0 },
},
};
 
@@ -131,7 +131,7 @@ static void test_in_esp_null_sha256(void)
ipsec_sa_destroy(sa);
 }
 
-static void test_in_esp_aes_cbc_null(void)
+static void test_in_ipv4_esp_aes_cbc_null(void)
 {
odp_ipsec_sa_param_t param;
odp_ipsec_sa_t sa;
@@ -147,12 +147,12 @@ static void test_in_esp_aes_cbc_null(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_esp_aes_cbc_null_1,
+   .pkt_in = _ipv4_icmp_0_esp_aes_cbc_null_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0 },
+ .pkt_out = _ipv4_icmp_0 },
  

[lng-odp] [PATCH API-NEXT v9 0/15] IPsec IPv6 implementation

2017-11-30 Thread Github ODP bot
This adds support for handling of IPv6 packets and IPv6 tunnels.

github
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
/github

checkpatch.pl
total: 0 errors, 0 warnings, 0 checks, 1153 lines checked


to_send-p-000.patch has no obvious style problems and is ready for submission.
WARNING: 'DONT' may be misspelled - perhaps 'DON'T'?
#695: FILE: platform/linux-generic/odp_ipsec.c:664:
+   state->out_tunnel.ip_df = _ODP_IPV4HDR_FLAGS_DONT_FRAG(flags);

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


to_send-p-001.patch has style problems, please review.

If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
CHECK: if this code is redundant consider removing it
#33: FILE: test/validation/api/ipsec/ipsec_test_in.c:950:
+#if 0

CHECK: if this code is redundant consider removing it
#49: FILE: test/validation/api/ipsec/ipsec_test_in.c:1099:
+#if 0

total: 0 errors, 0 warnings, 2 checks, 84 lines checked


to_send-p-002.patch has style problems, please review.

If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 0 warnings, 0 checks, 15 lines checked


to_send-p-003.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 13 lines checked


to_send-p-004.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 876 lines checked


to_send-p-005.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 1122 lines checked


to_send-p-006.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 83 lines checked


to_send-p-007.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 126 lines checked


to_send-p-008.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 32 lines checked


to_send-p-009.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 355 lines checked


to_send-p-010.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 35 lines checked


to_send-p-011.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 112 lines checked


to_send-p-012.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 21 lines checked


to_send-p-013.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 224 lines checked


to_send-p-014.patch has no obvious style problems and is ready for submission.
/checkpatch.pl


[lng-odp] [PATCH 2.0 v1 0/3] linux-dpdk: enable validation & crypto updates

2017-11-30 Thread Github ODP bot
This patch series has enabled the linux-dpdk validation & fixed the crypto that 
caused validation failure

github
/** Email created from pull request 317 
(GBalakrishna:port_syzmon_crypto_changes)
 ** https://github.com/Linaro/odp/pull/317
 ** Patch: https://github.com/Linaro/odp/pull/317.patch
 ** Base sha: 00c7441fae53949dd87855d48102f932f8f64537
 ** Merge commit sha: 47d0d3921c6a03fb7ac9b994e06521598c5bd982
 **/
/github

checkpatch.pl
total: 0 errors, 0 warnings, 0 checks, 18 lines checked


to_send-p-000.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 97 lines checked


to_send-p-001.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 104 lines checked


to_send-p-002.patch has no obvious style problems and is ready for submission.
/checkpatch.pl


[lng-odp] [PATCH 2.0 v1 3/3] linux-dpdk: crypto bug fixes

2017-11-30 Thread Github ODP bot
From: Balakrishna Garapati 

Signed-off-by: Balakrishna Garapati 
---
/** Email created from pull request 317 
(GBalakrishna:port_syzmon_crypto_changes)
 ** https://github.com/Linaro/odp/pull/317
 ** Patch: https://github.com/Linaro/odp/pull/317.patch
 ** Base sha: 00c7441fae53949dd87855d48102f932f8f64537
 ** Merge commit sha: 47d0d3921c6a03fb7ac9b994e06521598c5bd982
 **/
 platform/linux-dpdk/odp_crypto.c | 77 
 1 file changed, 46 insertions(+), 31 deletions(-)

diff --git a/platform/linux-dpdk/odp_crypto.c b/platform/linux-dpdk/odp_crypto.c
index 9844f2dd7..ea014c8e8 100644
--- a/platform/linux-dpdk/odp_crypto.c
+++ b/platform/linux-dpdk/odp_crypto.c
@@ -808,40 +808,53 @@ int odp_crypto_session_create(odp_crypto_session_param_t 
*param,
/* Default to successful result */
*status = ODP_CRYPTO_SES_CREATE_ERR_NONE;
 
-   /* Cipher Data */
-   cipher_xform.cipher.key.data = rte_malloc("crypto key",
-   param->cipher_key.length, 0);
-   if (cipher_xform.cipher.key.data == NULL) {
-   ODP_ERR("Failed to allocate memory for cipher key\n");
-   /* remove the crypto_session_entry_t */
-   memset(entry, 0, sizeof(*entry));
-   free_session(entry);
-   return -1;
-   }
-
cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
cipher_xform.next = NULL;
-   cipher_xform.cipher.key.length = param->cipher_key.length;
-   memcpy(cipher_xform.cipher.key.data,
-  param->cipher_key.data,
-  param->cipher_key.length);
-
-   /* Authentication Data */
-   auth_xform.auth.key.data = rte_malloc("auth key",
-   param->auth_key.length, 0);
-   if (auth_xform.auth.key.data == NULL) {
-   ODP_ERR("Failed to allocate memory for auth key\n");
-   /* remove the crypto_session_entry_t */
-   memset(entry, 0, sizeof(*entry));
-   free_session(entry);
-   return -1;
+
+   if (param->cipher_key.length) {
+   /* Cipher Data */
+   cipher_xform.cipher.key.data = rte_malloc("crypto key",
+  param->cipher_key.length, 0);
+   if (cipher_xform.cipher.key.data == NULL) {
+   ODP_ERR("Failed to allocate memory for cipher key\n");
+   /* remove the crypto_session_entry_t */
+   memset(entry, 0, sizeof(*entry));
+   free_session(entry);
+   return -1;
+   }
+
+   cipher_xform.cipher.key.length = param->cipher_key.length;
+   memcpy(cipher_xform.cipher.key.data,
+  param->cipher_key.data,
+  param->cipher_key.length);
+   } else {
+   cipher_xform.cipher.key.data = 0;
+   cipher_xform.cipher.key.length = 0;
}
+
auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
auth_xform.next = NULL;
-   auth_xform.auth.key.length = param->auth_key.length;
-   memcpy(auth_xform.auth.key.data,
-  param->auth_key.data,
-  param->auth_key.length);
+
+   if (param->auth_key.length) {
+   /* Authentication Data */
+   auth_xform.auth.key.data = rte_malloc("auth key",
+param->auth_key.length, 0);
+   if (auth_xform.auth.key.data == NULL) {
+   ODP_ERR("Failed to allocate memory for auth key\n");
+   /* remove the crypto_session_entry_t */
+   memset(entry, 0, sizeof(*entry));
+   free_session(entry);
+   return -1;
+   }
+   auth_xform.auth.key.length = param->auth_key.length;
+   memcpy(auth_xform.auth.key.data,
+  param->auth_key.data,
+  param->auth_key.length);
+   } else {
+   auth_xform.auth.key.data = 0;
+   auth_xform.auth.key.length = 0;
+   }
+
 
/* Derive order */
if (ODP_CRYPTO_OP_ENCODE == param->op)
@@ -1271,11 +1284,13 @@ int odp_crypto_int(odp_packet_t pkt_in,
memcpy(op->sym->cipher.iv.data,
   param->override_iv_ptr,
   entry->iv.length);
+   op->sym->cipher.iv.phys_addr =
+   rte_malloc_virt2phy(op->sym->cipher.iv.data);
+   op->sym->cipher.iv.length = entry->iv.length;
} else if (entry->iv.data) {
memcpy(op->sym->cipher.iv.data,
   entry->iv.data,
   entry->iv.length);
-
op->sym->cipher.iv.phys_addr =
   

[lng-odp] [PATCH 2.0 v1 2/3] linux-dpdk: Changes which are needed for odp_crypto to work.

2017-11-30 Thread Github ODP bot
From: Balakrishna Garapati 

All the changes are within the linux-dpdk/odp_crypto.c file:
1) Added missing brackets which made it impossible to
   to create a crypto session
2) Increased the number of queues created, from nb_queue_pairs - 1
   to nb_queue_pairs, what seems to work better
3) Removed a memory leak - the memory allocated for iv and aad
   were not freed

Signed-off-by: Szymon Sliwa 
Signed-off-by: Balakrishna Garapati 
---
/** Email created from pull request 317 
(GBalakrishna:port_syzmon_crypto_changes)
 ** https://github.com/Linaro/odp/pull/317
 ** Patch: https://github.com/Linaro/odp/pull/317.patch
 ** Base sha: 00c7441fae53949dd87855d48102f932f8f64537
 ** Merge commit sha: 47d0d3921c6a03fb7ac9b994e06521598c5bd982
 **/
 platform/linux-dpdk/odp_crypto.c | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/platform/linux-dpdk/odp_crypto.c b/platform/linux-dpdk/odp_crypto.c
index 8e0f8a9df..9844f2dd7 100644
--- a/platform/linux-dpdk/odp_crypto.c
+++ b/platform/linux-dpdk/odp_crypto.c
@@ -271,7 +271,7 @@ int odp_crypto_init_global(void)
 
qp_conf.nb_descriptors = NB_MBUF;
 
-   for (queue_pair = 0; queue_pair < nb_queue_pairs - 1;
+   for (queue_pair = 0; queue_pair < nb_queue_pairs;
queue_pair++) {
rc = rte_cryptodev_queue_pair_setup(cdev_id,
queue_pair,
@@ -898,11 +898,12 @@ int odp_crypto_session_create(odp_crypto_session_param_t 
*param,
/* Setup session */
session = rte_cryptodev_sym_session_create(cdev_id, first_xform);
 
-   if (session == NULL)
+   if (session == NULL) {
/* remove the crypto_session_entry_t */
memset(entry, 0, sizeof(*entry));
free_session(entry);
return -1;
+   }
 
entry->rte_session  = (intptr_t)session;
entry->cipher_xform = cipher_xform;
@@ -1216,6 +1217,9 @@ int odp_crypto_int(odp_packet_t pkt_in,
goto err;
}
 
+   op->sym->auth.aad.data = NULL;
+   op->sym->cipher.iv.data = NULL;
+
odp_spinlock_unlock(>lock);
 
/* Set crypto operation data parameters */
@@ -1242,9 +1246,8 @@ int odp_crypto_int(odp_packet_t pkt_in,
if (aad_len > 0) {
op->sym->auth.aad.data = rte_malloc("aad", aad_len, 0);
if (op->sym->auth.aad.data == NULL) {
-   rte_crypto_op_free(op);
ODP_ERR("Failed to allocate memory for AAD");
-   goto err;
+   goto err_op_free;
}
 
memcpy(op->sym->auth.aad.data, aad_head, aad_len);
@@ -1254,16 +1257,14 @@ int odp_crypto_int(odp_packet_t pkt_in,
}
 
if (entry->iv.length == 0) {
-   rte_crypto_op_free(op);
ODP_ERR("Wrong IV length");
-   goto err;
+   goto err_op_free;
}
 
op->sym->cipher.iv.data = rte_malloc("iv", entry->iv.length, 0);
if (op->sym->cipher.iv.data == NULL) {
-   rte_crypto_op_free(op);
ODP_ERR("Failed to allocate memory for IV");
-   goto err;
+   goto err_op_free;
}
 
if (param->override_iv_ptr) {
@@ -1300,18 +1301,16 @@ int odp_crypto_int(odp_packet_t pkt_in,
rc = rte_cryptodev_enqueue_burst(rte_session->dev_id,
 queue_pair, , 1);
if (rc == 0) {
-   rte_crypto_op_free(op);
ODP_ERR("Failed to enqueue packet");
-   goto err;
+   goto err_op_free;
}
 
rc = rte_cryptodev_dequeue_burst(rte_session->dev_id,
 queue_pair, , 1);
 
if (rc == 0) {
-   rte_crypto_op_free(op);
ODP_ERR("Failed to dequeue packet");
-   goto err;
+   goto err_op_free;
}
 
out_pkt = (odp_packet_t)op->sym->m_src;
@@ -1331,6 +1330,8 @@ int odp_crypto_int(odp_packet_t pkt_in,
op_result = get_op_result_from_packet(out_pkt);
*op_result = local_result;
 
+   rte_free(op->sym->cipher.iv.data);
+   rte_free(op->sym->auth.aad.data);
rte_crypto_op_free(op);
 
/* Synchronous, simply return results */
@@ -1338,6 +1339,11 @@ int odp_crypto_int(odp_packet_t pkt_in,
 
return 0;
 
+err_op_free:
+   rte_free(op->sym->cipher.iv.data);
+   rte_free(op->sym->auth.aad.data);
+   rte_crypto_op_free(op);
+
 err:
if (allocated) {
odp_packet_free(out_pkt);



[lng-odp] [PATCH 2.0 v1 1/3] test: enable dpdk initialization before running validation on linux-dpdk

2017-11-30 Thread Github ODP bot
From: Balakrishna Garapati 

Signed-off-by: Balakrishna Garapati 
---
/** Email created from pull request 317 
(GBalakrishna:port_syzmon_crypto_changes)
 ** https://github.com/Linaro/odp/pull/317
 ** Patch: https://github.com/Linaro/odp/pull/317.patch
 ** Base sha: 00c7441fae53949dd87855d48102f932f8f64537
 ** Merge commit sha: 47d0d3921c6a03fb7ac9b994e06521598c5bd982
 **/
 platform/linux-generic/test/wrapper-script.sh | 3 +++
 test/Makefile.inc | 2 ++
 test/performance/Makefile.am  | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100755 platform/linux-generic/test/wrapper-script.sh

diff --git a/platform/linux-generic/test/wrapper-script.sh 
b/platform/linux-generic/test/wrapper-script.sh
new file mode 100755
index 0..977a032ae
--- /dev/null
+++ b/platform/linux-generic/test/wrapper-script.sh
@@ -0,0 +1,3 @@
+#wrapper script for pre setting environment for validation suit.
+#currently this is empty but needs to be created to make it align with
+#linux-dpdk.
diff --git a/test/Makefile.inc b/test/Makefile.inc
index eaf791e08..3e7dfe57f 100644
--- a/test/Makefile.inc
+++ b/test/Makefile.inc
@@ -20,6 +20,8 @@ AM_CFLAGS = $(CUNIT_CFLAGS)
 
 AM_LDFLAGS = -L$(LIB) -static
 
+LOG_COMPILER = $(top_srcdir)/platform/@with_platform@/test/wrapper-script.sh
+
 @VALGRIND_CHECK_RULES@
 
 TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform} \
diff --git a/test/performance/Makefile.am b/test/performance/Makefile.am
index 1dccd82e1..4417c4843 100644
--- a/test/performance/Makefile.am
+++ b/test/performance/Makefile.am
@@ -31,6 +31,6 @@ odp_sched_latency_SOURCES = odp_sched_latency.c
 odp_scheduling_SOURCES = odp_scheduling.c
 odp_pktio_perf_SOURCES = odp_pktio_perf.c
 
-dist_check_SCRIPTS = $(TESTSCRIPTS)
+dist_check_SCRIPTS = $(TESTSCRIPTS) $(LOG_COMPILER)
 
 dist_check_DATA = udp64.pcap



Re: [lng-odp] [PATCH 2.0 v1] linux-dpdk: buffer: remove default queue meta data

2017-11-30 Thread Github ODP bot
nagarahalli replied on github web page:

platform/linux-dpdk/Makefile.am
line 19
@@ -348,8 +346,10 @@ endif
 endif
 endif
 if ODP_SCHEDULE_SCALABLE
+__LIB__libodp_dpdk_la_SOURCES += ../linux-generic/queue/scalable.c
 ../linux-generic/queue/scalable.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE
 else
+__LIB__libodp_dpdk_la_SOURCES += ../linux-generic/queue/generic.c
 ../linux-generic/queue/generic.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE
 endif
 


Comment:
As we discussed in the call today, this is temporary. Once the changes, not to 
use packet meta data, to default queue implementation is done, these can go 
away.

> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
> Is this intended to be a temporary change? The problem with conditional 
> compilation is that it's very easy to make changes that break another file 
> that isn't compiled unless some special config option is used. That's why in 
> today's config-based scheduler selection we compile all modules and the only 
> thing that's actually conditional is which entry points are plugged into the 
> scheduler interface table.
> 
> For 2.0 we want to eliminate config-time selections like this, so all 
> variants will necessarily have to be compiled to be included in the single 
> binary and selected dynamically at runtime. So I'm not sure this sort of 
> change is consistent with that goal. This seems to need more discussion as to 
> why we're doing this here.


https://github.com/Linaro/odp/pull/303#discussion_r154201269
updated_at 2017-11-30 21:07:18


[lng-odp] [PATCH API-NEXT v1 2/2] linux-gen: event: move event subtype to packet header

2017-11-30 Thread Github ODP bot
From: Matias Elo 

Event subtype is only used by packets, so move subtype to packet header to
optimize cache usage. This change fixes the ~30% performance penalty in
l2fwd (zero-copy dpdk pktio) caused by the initialization of event subtype.

Signed-off-by: Matias Elo 
---
/** Email created from pull request 316 (matiaselo:dev/pktio_perf_opt)
 ** https://github.com/Linaro/odp/pull/316
 ** Patch: https://github.com/Linaro/odp/pull/316.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: b728dd0b8a03da6348573ea695377bcceb10cd3c
 **/
 .../linux-generic/include/odp_buffer_inlines.h |  2 --
 .../linux-generic/include/odp_buffer_internal.h|  3 ---
 .../linux-generic/include/odp_packet_internal.h| 18 +++--
 platform/linux-generic/odp_crypto.c|  6 ++
 platform/linux-generic/odp_event.c | 14 ++---
 platform/linux-generic/odp_ipsec.c | 23 +++---
 platform/linux-generic/odp_pool.c  | 11 ---
 platform/linux-generic/pktio/loop.c|  6 ++
 8 files changed, 38 insertions(+), 45 deletions(-)

diff --git a/platform/linux-generic/include/odp_buffer_inlines.h 
b/platform/linux-generic/include/odp_buffer_inlines.h
index e095aec5f..a5658e815 100644
--- a/platform/linux-generic/include/odp_buffer_inlines.h
+++ b/platform/linux-generic/include/odp_buffer_inlines.h
@@ -21,8 +21,6 @@ extern "C" {
 
 odp_event_type_t _odp_buffer_event_type(odp_buffer_t buf);
 void _odp_buffer_event_type_set(odp_buffer_t buf, int ev);
-odp_event_subtype_t _odp_buffer_event_subtype(odp_buffer_t buf);
-void _odp_buffer_event_subtype_set(odp_buffer_t buf, int ev);
 int odp_buffer_snprint(char *str, uint32_t n, odp_buffer_t buf);
 
 static inline odp_buffer_t buf_from_buf_hdr(odp_buffer_hdr_t *hdr)
diff --git a/platform/linux-generic/include/odp_buffer_internal.h 
b/platform/linux-generic/include/odp_buffer_internal.h
index 64887d75b..c56c5b01b 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -104,9 +104,6 @@ struct odp_buffer_hdr_t {
/* User area pointer */
void*uarea_addr;
 
-   /* Event subtype. Should be ODP_EVENT_NO_SUBTYPE except packets. */
-   int8_tevent_subtype;
-
/* ipc mapped process can not walk over pointers,
 * offset has to be used */
uint64_t ipc_data_offset;
diff --git a/platform/linux-generic/include/odp_packet_internal.h 
b/platform/linux-generic/include/odp_packet_internal.h
index ab31d0704..a16ec3161 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -132,6 +132,9 @@ typedef struct {
uint16_t headroom;
uint16_t tailroom;
 
+   /* Event subtype */
+   int8_t subtype;
+
/*
 * Members below are not initialized by packet_init()
 */
@@ -195,6 +198,16 @@ static inline seg_entry_t *seg_entry_last(odp_packet_hdr_t 
*hdr)
return >buf_hdr.seg[last_seg];
 }
 
+static inline odp_event_subtype_t packet_subtype(odp_packet_t pkt)
+{
+   return odp_packet_hdr(pkt)->subtype;
+}
+
+static inline void packet_subtype_set(odp_packet_t pkt, int ev)
+{
+   odp_packet_hdr(pkt)->subtype = ev;
+}
+
 /**
  * Initialize packet
  */
@@ -234,9 +247,10 @@ static inline void packet_init(odp_packet_hdr_t *pkt_hdr, 
uint32_t len)
pkt_hdr->headroom  = CONFIG_PACKET_HEADROOM;
pkt_hdr->tailroom  = pool->seg_len - seg_len + CONFIG_PACKET_TAILROOM;
 
-   pkt_hdr->input = ODP_PKTIO_INVALID;
-   pkt_hdr->buf_hdr.event_subtype = ODP_EVENT_PACKET_BASIC;
+   if (odp_unlikely(pkt_hdr->subtype != ODP_EVENT_PACKET_BASIC))
+   pkt_hdr->subtype = ODP_EVENT_PACKET_BASIC;
 
+   pkt_hdr->input = ODP_PKTIO_INVALID;
 }
 
 static inline void copy_packet_parser_metadata(odp_packet_hdr_t *src_hdr,
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index b5f538dd7..b9cc21a15 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -1072,8 +1072,7 @@ odp_crypto_operation(odp_crypto_op_param_t *param,
/* Indicate to caller operation was sync */
*posted = 0;
 
-   _odp_buffer_event_subtype_set(packet_to_buffer(out_pkt),
- ODP_EVENT_PACKET_BASIC);
+   packet_subtype_set(out_pkt, ODP_EVENT_PACKET_BASIC);
 
/* Fill in result */
local_result.ctx = param->ctx;
@@ -1351,8 +1350,7 @@ int odp_crypto_int(odp_packet_t pkt_in,
}
 
/* Fill in result */
-   _odp_buffer_event_subtype_set(packet_to_buffer(out_pkt),
- ODP_EVENT_PACKET_CRYPTO);
+   packet_subtype_set(out_pkt, ODP_EVENT_PACKET_CRYPTO);
op_result = get_op_result_from_packet(out_pkt);

[lng-odp] [PATCH API-NEXT v1 0/2] optimize pktio performance

2017-11-30 Thread Github ODP bot
Optimize pktio performance by rearranging odp_buffer_hdr_t and odp_packet_hdr_t 
struct members.
Event subtype is only used by packets, so move subtype to packet header to 
optimize cache usage. This change fixes the ~30% performance penalty in l2fwd 
(zero-copy dpdk pktio) caused by the initialization of event subtype.

github
/** Email created from pull request 316 (matiaselo:dev/pktio_perf_opt)
 ** https://github.com/Linaro/odp/pull/316
 ** Patch: https://github.com/Linaro/odp/pull/316.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: b728dd0b8a03da6348573ea695377bcceb10cd3c
 **/
/github

checkpatch.pl
total: 0 errors, 0 warnings, 0 checks, 12 lines checked


to_send-p-000.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 215 lines checked


to_send-p-001.patch has no obvious style problems and is ready for submission.
/checkpatch.pl


[lng-odp] [Linaro/odp] 28a3b9: api: pktio: add max frame length

2017-11-30 Thread GitHub
  Branch: refs/heads/api-next
  Home:   https://github.com/Linaro/odp
  Commit: 28a3b9e30fb4e8784a8781e06e28d3f175e05749
  
https://github.com/Linaro/odp/commit/28a3b9e30fb4e8784a8781e06e28d3f175e05749
  Author: Petri Savolainen 
  Date:   2017-11-30 (Thu, 30 Nov 2017)

  Changed paths:
M include/odp/api/spec/packet_io.h

  Log Message:
  ---
  api: pktio: add max frame length

Added functions to request maximum packet input and output
frame lengths.

Signed-off-by: Petri Savolainen 
Reviewed-by: Balasubramanian Manoharan 
Signed-off-by: Maxim Uvarov 


  Commit: c370d7950524a968bbc148644f7c5fc619c78600
  
https://github.com/Linaro/odp/commit/c370d7950524a968bbc148644f7c5fc619c78600
  Author: Petri Savolainen 
  Date:   2017-11-30 (Thu, 30 Nov 2017)

  Changed paths:
M platform/linux-generic/odp_packet_io.c

  Log Message:
  ---
  linux-gen: pktio: implement frame length

Use mtu to implement frame length functions. Various packet
IO devices mtu functions need to be still updated to return
correct frame length values.

Signed-off-by: Petri Savolainen 
Reviewed-by: Balasubramanian Manoharan 
Signed-off-by: Maxim Uvarov 


  Commit: 2ae5d875aab20e728c231361af95e1c57336daa5
  
https://github.com/Linaro/odp/commit/2ae5d875aab20e728c231361af95e1c57336daa5
  Author: Petri Savolainen 
  Date:   2017-11-30 (Thu, 30 Nov 2017)

  Changed paths:
M include/odp/api/spec/packet_io.h
M platform/linux-generic/odp_packet_io.c
M test/validation/api/pktio/pktio.c

  Log Message:
  ---
  api: pktio: deprecate odp_pktio_mtu

MTU is not a well defined term for link layer maximum receive
and transmit frame sizes. Use odp_pktin_maxlen() and
odp_pktout_maxlen() instead.

Signed-off-by: Petri Savolainen 
Reviewed-by: Balasubramanian Manoharan 
Signed-off-by: Maxim Uvarov 


  Commit: 22441cdcb569d5c6147db5d67e62fde67a3daad5
  
https://github.com/Linaro/odp/commit/22441cdcb569d5c6147db5d67e62fde67a3daad5
  Author: Petri Savolainen 
  Date:   2017-11-30 (Thu, 30 Nov 2017)

  Changed paths:
M test/performance/odp_l2fwd.c

  Log Message:
  ---
  test: l2fwd: add verbose option

Added verbose command line option. When enabled, pktio interface
details are printed after open. This can be used for debugging
interface configuration.

Signed-off-by: Petri Savolainen 
Reviewed-by: Balasubramanian Manoharan 
Signed-off-by: Maxim Uvarov 


  Commit: e4b4bab2247e7724fb4b5983e54fd62676f1d206
  
https://github.com/Linaro/odp/commit/e4b4bab2247e7724fb4b5983e54fd62676f1d206
  Author: Petri Savolainen 
  Date:   2017-11-30 (Thu, 30 Nov 2017)

  Changed paths:
M platform/linux-generic/pktio/dpdk.c

  Log Message:
  ---
  linux-gen: dpdk: fix maximum frame length value

Returns maximum ethernet frame size instead of maximum IP
packet MTU.

Signed-off-by: Petri Savolainen 
Reviewed-by: Balasubramanian Manoharan 
Signed-off-by: Maxim Uvarov 


  Commit: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
  
https://github.com/Linaro/odp/commit/bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
  Author: Petri Savolainen 
  Date:   2017-11-30 (Thu, 30 Nov 2017)

  Changed paths:
M include/odp/api/spec/packet_io.h

  Log Message:
  ---
  api: pktio: clean up doxygen tags

Remove [in] from @param tags as by default parameters
are input only.

Signed-off-by: Petri Savolainen 
Reviewed-by: Balasubramanian Manoharan 
Signed-off-by: Maxim Uvarov 


Compare: https://github.com/Linaro/odp/compare/ad990bbf88d9...bdb7cbf620ad


[lng-odp] [Linaro/odp] d2a700: api: time: time difference in nsec

2017-11-30 Thread GitHub
  Branch: refs/heads/api-next
  Home:   https://github.com/Linaro/odp
  Commit: d2a70019d5fb5443f80a4896dd30b710d3988e8e
  
https://github.com/Linaro/odp/commit/d2a70019d5fb5443f80a4896dd30b710d3988e8e
  Author: Petri Savolainen 
  Date:   2017-11-30 (Thu, 30 Nov 2017)

  Changed paths:
M include/odp/api/spec/time.h

  Log Message:
  ---
  api: time: time difference in nsec

Added function which returns time difference in nanoseconds.
This short cuts a common pattern...

t1 = odp_time_global();
foo();
t2 = odp_time_global();
printf("foo() takes %u nsec\n", odp_time_diff_ns(t2, t1);

... by combining convert and diff functions.

Signed-off-by: Petri Savolainen 
Reviewed-by: Bill Fischofer 
Reviewed-by: Balasubramanian Manoharan 
Signed-off-by: Maxim Uvarov 


  Commit: d6be400839611af3ca47baa85e8fed12d0c87e29
  
https://github.com/Linaro/odp/commit/d6be400839611af3ca47baa85e8fed12d0c87e29
  Author: Petri Savolainen 
  Date:   2017-11-30 (Thu, 30 Nov 2017)

  Changed paths:
M platform/linux-generic/odp_time.c

  Log Message:
  ---
  linux-gen: time: implement odp_time_diff_ns

Implemented the new diff in nsec function.

Signed-off-by: Petri Savolainen 
Reviewed-by: Bill Fischofer 
Reviewed-by: Balasubramanian Manoharan 
Signed-off-by: Maxim Uvarov 


  Commit: ad990bbf88d95b2a4f9583b7fda718bf5d7d4212
  
https://github.com/Linaro/odp/commit/ad990bbf88d95b2a4f9583b7fda718bf5d7d4212
  Author: Petri Savolainen 
  Date:   2017-11-30 (Thu, 30 Nov 2017)

  Changed paths:
M test/validation/api/time/time.c

  Log Message:
  ---
  validation: time: test odp_time_diff_ns

Added tests for the new time difference in nsec function.

Signed-off-by: Petri Savolainen 
Reviewed-by: Bill Fischofer 
Reviewed-by: Balasubramanian Manoharan 
Signed-off-by: Maxim Uvarov 


Compare: https://github.com/Linaro/odp/compare/2526489e826f...ad990bbf88d9


[lng-odp] [Linaro/odp] 8ff99a: api: ipsec: add capabilities for fragmentation sup...

2017-11-30 Thread GitHub
  Branch: refs/heads/api-next
  Home:   https://github.com/Linaro/odp
  Commit: 8ff99a64d79b6e3e350037575b9d5bc9adeca267
  
https://github.com/Linaro/odp/commit/8ff99a64d79b6e3e350037575b9d5bc9adeca267
  Author: Dmitry Eremin-Solenikov 
  Date:   2017-11-30 (Thu, 30 Nov 2017)

  Changed paths:
M include/odp/api/spec/ipsec.h

  Log Message:
  ---
  api: ipsec: add capabilities for fragmentation support

It is expected that implementation can support any combination of
fragmentatation (after, before, both or none). Add capabilities to
report such support to application.

Signed-off-by: Dmitry Eremin-Solenikov 
Reviewed-by: Bill Fischofer 
Reviewed-by: Petri Savolainen 
Reviewed-by: Balasubramanian Manoharan 
Signed-off-by: Maxim Uvarov 


  Commit: 2526489e826f49dede472782621c0e0ba8976745
  
https://github.com/Linaro/odp/commit/2526489e826f49dede472782621c0e0ba8976745
  Author: Dmitry Eremin-Solenikov 
  Date:   2017-11-30 (Thu, 30 Nov 2017)

  Changed paths:
M include/odp/api/spec/ipsec.h
M platform/linux-generic/odp_ipsec.c

  Log Message:
  ---
  api: linux-gen: ipsec: constify in/out params

Mark all input and out params as constants

Signed-off-by: Dmitry Eremin-Solenikov 
Reviewed-by: Bill Fischofer 
Reviewed-by: Petri Savolainen 
Reviewed-by: Balasubramanian Manoharan 
Signed-off-by: Maxim Uvarov 


Compare: https://github.com/Linaro/odp/compare/4cb02e1caccb...2526489e826f


Re: [lng-odp] L4 offset

2017-11-30 Thread Savolainen, Petri (Nokia - FI/Espoo)


> -Original Message-
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of Liron
> Himi
> Sent: Wednesday, November 29, 2017 3:13 PM
> To: lng-odp@lists.linaro.org
> Subject: [lng-odp] L4 offset
> 
> Hi,
> 
> I'm trying to understand when pktio implementation should set the L4
> offset.
> In point of view, if there is a known L3 header than the L4 offset should
> be set to the L3-offset + L3 header length.
> I noticed that Linux generic implementation is not as above. E.g. if there
> is only IP header and payload, than L4 offset is set to
> 'ODP_PACKET_OFFSET_INVALID'.
> Is the above is the real intention?
> The API is documented as foolowed:
> /**
> * Layer 4 start offset
> *
> * Returns offset to the start of the layer 4 header. The offset is
> calculated
> * from the current odp_packet_data() position in bytes.
> *
> * User is responsible to update the offset when modifying the packet data
> * pointer position.
> *
> * @param pkt  Packet handle
> *
> * @return  Layer 4 start offset
> * @retval ODP_PACKET_OFFSET_INVALID packet does not contain a valid L4
> header
> *
> * @see odp_packet_l4_offset_set(), odp_packet_has_l4()
> */
> uint32_t odp_packet_l4_offset(odp_packet_t pkt);
> 
> What is the meaning of a valid L4 header? A payload is a valid L4? Maybe
> you should remove the 'header' and just mention that there is a L4 layer.
> 
> In order to calculate IP checksum, the IP-Header-length is needed and in
> absence of this exact value, the L4 offset can be used to calculate it.
> 
> Regards,
> Liron

I had planned to remove the word "valid" from there. This is an old function 
and since then we have added parser configuration options into pktio API.

/**
 * Parser configuration
 */
typedef struct odp_pktio_parser_config_t {
/** Protocol parsing level in packet input
  *
  * Parse protocol layers in minimum up to this level during packet
  * input. The default value is ODP_PKTIO_PARSER_LAYER_ALL. */
odp_pktio_parser_layer_t layer;

} odp_pktio_parser_config_t;


These l3/l4 offsets refer to the metadata set at packet input parsing time. I 
think we could update it to:


... Returns offset to the start of the layer 4...

* @return  Layer 4 start offset
* @retval  ODP_PACKET_OFFSET_INVALID packet does not contain L4


So, we could remove both "valid" and "header".

-Petri




Re: [lng-odp] [PATCH 2.0 v1] linux-dpdk: buffer: remove default queue meta data

2017-11-30 Thread Github ODP bot
Bill Fischofer(Bill-Fischofer-Linaro) replied on github web page:

platform/linux-dpdk/Makefile.am
line 19
@@ -348,8 +346,10 @@ endif
 endif
 endif
 if ODP_SCHEDULE_SCALABLE
+__LIB__libodp_dpdk_la_SOURCES += ../linux-generic/queue/scalable.c
 ../linux-generic/queue/scalable.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE
 else
+__LIB__libodp_dpdk_la_SOURCES += ../linux-generic/queue/generic.c
 ../linux-generic/queue/generic.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE
 endif
 


Comment:
Is this intended to be a temporary change? The problem with conditional 
compilation is that it's very easy to make changes that break another file that 
isn't compiled unless some special config option is used. That's why in today's 
config-based scheduler selection we compile all modules and the only thing 
that's actually conditional is which entry points are plugged into the 
scheduler interface table.

For 2.0 we want to eliminate config-time selections like this, so all variants 
will necessarily have to be compiled to be included in the single binary and 
selected dynamically at runtime. So I'm not sure this sort of change is 
consistent with that goal. This seems to need more discussion as to why we're 
doing this here.

https://github.com/Linaro/odp/pull/303#discussion_r153959965
updated_at 2017-11-30 00:53:16


Re: [lng-odp] [PATCH 2.0 v3] allocate ring memory based on pool size

2017-11-30 Thread Github ODP bot
nagarahalli replied on github web page:

platform/linux-dpdk/pool/dpdk.c
line 28
@@ -258,11 +258,6 @@ static int check_params(odp_pool_param_t *params)
 
switch (params->type) {
case ODP_POOL_BUFFER:
-   if (params->buf.num > capa.buf.max_num) {


Comment:
I think the check is unnecessary. capa.buf.max_num is set to 0 anyway. I do not 
see a reason for setting capa.buf.max_num to a non-zero value in the future.

> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
> And here too.


>> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
>> Same here:
>> ```
>> if (capa.buf.max_num && params->buf.num > capa.buf.max_num) ...
>> ```


>>> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
>>> Same comment here.


 Bill Fischofer(Bill-Fischofer-Linaro) wrote:
 If would probably be better to keep this and just correct it rather than 
 delete it:
 ```
 if (capa.buf.max_num && params->buf.num > capa.buf.max_num) ...
 ```


https://github.com/Linaro/odp/pull/312#discussion_r153690633
updated_at 2017-11-29 20:41:35


Re: [lng-odp] [PATCH 2.0 v3] allocate ring memory based on pool size

2017-11-30 Thread Github ODP bot
Bill Fischofer(Bill-Fischofer-Linaro) replied on github web page:

platform/linux-generic/pool/generic.c
line 72
@@ -550,10 +549,6 @@ static int check_params(odp_pool_param_t *params)
break;
 
case ODP_POOL_TIMEOUT:
-   if (params->tmo.num > capa.tmo.max_num) {


Comment:
And here too.

> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
> Same here:
> ```
> if (capa.buf.max_num && params->buf.num > capa.buf.max_num) ...
> ```


>> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
>> Same comment here.


>>> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
>>> If would probably be better to keep this and just correct it rather than 
>>> delete it:
>>> ```
>>> if (capa.buf.max_num && params->buf.num > capa.buf.max_num) ...
>>> ```


https://github.com/Linaro/odp/pull/312#discussion_r153660517
updated_at 2017-11-29 20:41:35


Re: [lng-odp] [PATCH 2.0 v3] allocate ring memory based on pool size

2017-11-30 Thread Github ODP bot
Bill Fischofer(Bill-Fischofer-Linaro) replied on github web page:

platform/linux-generic/pool/generic.c
line 60
@@ -506,11 +510,6 @@ static int check_params(odp_pool_param_t *params)
 
switch (params->type) {
case ODP_POOL_BUFFER:
-   if (params->buf.num > capa.buf.max_num) {


Comment:
Same here:
```
if (capa.buf.max_num && params->buf.num > capa.buf.max_num) ...
```

> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
> Same comment here.


>> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
>> If would probably be better to keep this and just correct it rather than 
>> delete it:
>> ```
>> if (capa.buf.max_num && params->buf.num > capa.buf.max_num) ...
>> ```


https://github.com/Linaro/odp/pull/312#discussion_r153660457
updated_at 2017-11-29 20:41:35


Re: [lng-odp] [PATCH API-NEXT v4] IPsec checksumming API

2017-11-30 Thread Github ODP bot
Dmitry Eremin-Solenikov(lumag) replied on github web page:

include/odp/api/spec/packet.h
@@ -1178,6 +1178,31 @@ int odp_packet_move_data(odp_packet_t pkt, uint32_t 
dst_offset,
  *
  */
 
+/**
+ * Flags to control payload checksum checking


Comment:
@Bill-Fischofer-Linaro updated

> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
> Why "payload"? Wouldn't "packet checksum checking" be more accurate?


https://github.com/Linaro/odp/pull/314#discussion_r154052796
updated_at 2017-11-30 11:43:22


Re: [lng-odp] [PATCH 2.0 v3] allocate ring memory based on pool size

2017-11-30 Thread Github ODP bot
Bill Fischofer(Bill-Fischofer-Linaro) replied on github web page:

platform/linux-dpdk/pool/dpdk.c
line 28
@@ -258,11 +258,6 @@ static int check_params(odp_pool_param_t *params)
 
switch (params->type) {
case ODP_POOL_BUFFER:
-   if (params->buf.num > capa.buf.max_num) {


Comment:
If would probably be better to keep this and just correct it rather than delete 
it:
```
if (capa.buf.max_num && params->buf.num > capa.buf.max_num) ...
```

https://github.com/Linaro/odp/pull/312#discussion_r153659144
updated_at 2017-11-29 20:41:35


Re: [lng-odp] [PATCH API-NEXT v4] IPsec checksumming API

2017-11-30 Thread Github ODP bot
Bill Fischofer(Bill-Fischofer-Linaro) replied on github web page:

include/odp/api/spec/packet.h
@@ -1178,6 +1178,31 @@ int odp_packet_move_data(odp_packet_t pkt, uint32_t 
dst_offset,
  *
  */
 
+/**
+ * Flags to control payload checksum checking


Comment:
Why "payload"? Wouldn't "packet checksum checking" be more accurate?

https://github.com/Linaro/odp/pull/314#discussion_r153965183
updated_at 2017-11-30 11:43:11


[lng-odp] [PATCH API-NEXT v8 13/16] api, linux-gen: ipsec: constify in/out params

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Mark all input and out params as constants

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 include/odp/api/spec/ipsec.h   |  6 +++---
 platform/linux-generic/odp_ipsec.c | 10 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h
index 4a33af8ea..cd168d080 100644
--- a/include/odp/api/spec/ipsec.h
+++ b/include/odp/api/spec/ipsec.h
@@ -1021,13 +1021,13 @@ typedef struct odp_ipsec_out_param_t {
int num_opt;
 
/** Pointer to an array of IPSEC SAs */
-   odp_ipsec_sa_t *sa;
+   const odp_ipsec_sa_t *sa;
 
/** Pointer to an array of outbound operation options
 *
 *  May be NULL when num_opt is zero.
 */
-   odp_ipsec_out_opt_t *opt;
+   const odp_ipsec_out_opt_t *opt;
 
 } odp_ipsec_out_param_t;
 
@@ -1055,7 +1055,7 @@ typedef struct odp_ipsec_in_param_t {
 *
 *  May be NULL when num_sa is zero.
 */
-   odp_ipsec_sa_t *sa;
+   const odp_ipsec_sa_t *sa;
 
 } odp_ipsec_in_param_t;
 
diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index 8bf4ced4c..3c539b515 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -1228,7 +1228,7 @@ static void ipsec_out_ah_post(ipsec_state_t *state, 
odp_packet_t pkt)
 static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
odp_ipsec_sa_t sa,
odp_packet_t *pkt_out,
-   odp_ipsec_out_opt_t *opt ODP_UNUSED,
+   const odp_ipsec_out_opt_t *opt ODP_UNUSED,
odp_ipsec_op_status_t *status)
 {
ipsec_state_t state;
@@ -1402,7 +1402,7 @@ int odp_ipsec_in(const odp_packet_t pkt_in[], int num_in,
return in_pkt;
 }
 
-static odp_ipsec_out_opt_t default_opt = {
+static const odp_ipsec_out_opt_t default_opt = {
.mode = ODP_IPSEC_FRAG_DISABLED,
 };
 
@@ -1426,7 +1426,7 @@ int odp_ipsec_out(const odp_packet_t pkt_in[], int num_in,
odp_ipsec_sa_t sa;
ipsec_sa_t *ipsec_sa;
odp_ipsec_packet_result_t *result;
-   odp_ipsec_out_opt_t *opt;
+   const odp_ipsec_out_opt_t *opt;
 
memset(, 0, sizeof(status));
 
@@ -1534,7 +1534,7 @@ int odp_ipsec_out_enq(const odp_packet_t pkt_in[], int 
num_in,
odp_ipsec_sa_t sa;
ipsec_sa_t *ipsec_sa;
odp_ipsec_packet_result_t *result;
-   odp_ipsec_out_opt_t *opt;
+   const odp_ipsec_out_opt_t *opt;
odp_queue_t queue;
 
memset(, 0, sizeof(status));
@@ -1626,7 +1626,7 @@ int odp_ipsec_out_inline(const odp_packet_t pkt_in[], int 
num_in,
odp_ipsec_sa_t sa;
ipsec_sa_t *ipsec_sa;
odp_ipsec_packet_result_t *result;
-   odp_ipsec_out_opt_t *opt;
+   const odp_ipsec_out_opt_t *opt;
uint32_t hdr_len, offset;
const void *ptr;
 



[lng-odp] [PATCH API-NEXT v8 9/16] linux-gen: add support for UDP-encapsulated ESP packets

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 .../linux-generic/include/odp_ipsec_internal.h |  1 +
 platform/linux-generic/include/protocols/udp.h |  2 +
 platform/linux-generic/odp_ipsec.c | 53 +-
 platform/linux-generic/odp_ipsec_sad.c |  1 +
 4 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/platform/linux-generic/include/odp_ipsec_internal.h 
b/platform/linux-generic/include/odp_ipsec_internal.h
index b294e7c4a..822c9016b 100644
--- a/platform/linux-generic/include/odp_ipsec_internal.h
+++ b/platform/linux-generic/include/odp_ipsec_internal.h
@@ -131,6 +131,7 @@ struct ipsec_sa_s {
unsignedcopy_df : 1;
unsignedcopy_flabel : 1;
unsignedaes_ctr_iv : 1;
+   unsignedudp_encap : 1;
 
/* Only for outbound */
unsigneduse_counter_iv : 1;
diff --git a/platform/linux-generic/include/protocols/udp.h 
b/platform/linux-generic/include/protocols/udp.h
index 535aba855..85984c992 100644
--- a/platform/linux-generic/include/protocols/udp.h
+++ b/platform/linux-generic/include/protocols/udp.h
@@ -38,6 +38,8 @@ typedef struct ODP_PACKED {
 ODP_STATIC_ASSERT(sizeof(_odp_udphdr_t) == _ODP_UDPHDR_LEN,
  "_ODP_UDPHDR_T__SIZE_ERROR");
 
+#define _ODP_UDP_IPSEC_PORT 4500
+
 /**
  * @}
  */
diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index a48312fe9..2f4c69924 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -378,9 +379,29 @@ static int ipsec_in_esp(odp_packet_t *pkt,
_odp_esphdr_t esp;
uint16_t ipsec_offset;
ipsec_sa_t *ipsec_sa;
+   odp_bool_t udp_encap = false;
 
ipsec_offset = state->ip_offset + state->ip_hdr_len;
 
+   if (_ODP_IPPROTO_UDP == state->ip_next_hdr) {
+   _odp_udphdr_t udp;
+   uint16_t ip_data_len = state->ip_tot_len -
+  state->ip_hdr_len;
+
+   odp_packet_copy_to_mem(*pkt, ipsec_offset,
+  _ODP_UDPHDR_LEN, );
+
+   if (udp.dst_port != odp_cpu_to_be_16(_ODP_UDP_IPSEC_PORT) ||
+   udp.length != odp_cpu_to_be_16(ip_data_len)) {
+   status->error.proto = 1;
+   return -1;
+   }
+
+   ipsec_offset += _ODP_UDPHDR_LEN;
+   state->ip_hdr_len += _ODP_UDPHDR_LEN;
+   udp_encap = true;
+   }
+
if (odp_packet_copy_to_mem(*pkt, ipsec_offset,
   sizeof(esp), ) < 0) {
status->error.alg = 1;
@@ -396,6 +417,11 @@ static int ipsec_in_esp(odp_packet_t *pkt,
if (status->error.all)
return -1;
 
+   if (!!ipsec_sa->udp_encap != udp_encap) {
+   status->error.proto = 1;
+   return -1;
+   }
+
if (ipsec_in_iv(*pkt, state, ipsec_sa,
ipsec_offset + _ODP_ESPHDR_LEN) < 0) {
status->error.alg = 1;
@@ -446,6 +472,11 @@ static int ipsec_in_esp_post(odp_packet_t pkt,
 ipsec_padding, esptrl.pad_len) != 0)
return -1;
 
+   if (udp_encap) {
+   state->ip_hdr_len -= _ODP_UDPHDR_LEN;
+   state->in.hdr_len += _ODP_UDPHDR_LEN;
+   }
+
odp_packet_copy_from_mem(pkt, state->ip_next_hdr_offset,
 1, _header);
state->in.trl_len += esptrl.pad_len;
@@ -603,7 +634,8 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
}
 
/* Check IP header for IPSec protocols and look it up */
-   if (_ODP_IPPROTO_ESP == state.ip_next_hdr) {
+   if (_ODP_IPPROTO_ESP == state.ip_next_hdr ||
+   _ODP_IPPROTO_UDP == state.ip_next_hdr) {
rc = ipsec_in_esp(, , _sa, sa, , status);
} else if (_ODP_IPPROTO_AH == state.ip_next_hdr) {
rc = ipsec_in_ah(, , _sa, sa, , status);
@@ -962,6 +994,7 @@ static int ipsec_out_esp(odp_packet_t *pkt,
 {
_odp_esphdr_t esp;
_odp_esptrl_t esptrl;
+   _odp_udphdr_t udphdr;
uint32_t encrypt_len;
uint16_t ip_data_len = state->ip_tot_len -
   state->ip_hdr_len;
@@ -983,6 +1016,16 @@ static int ipsec_out_esp(odp_packet_t *pkt,
   ip_data_len +
 

[lng-odp] [PATCH API-NEXT v8 16/16] validation: ipsec: add ODP_IPSEC_FRAG_CHECK checks

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 test/validation/api/ipsec/ipsec.c  |   4 +-
 test/validation/api/ipsec/ipsec.h  |   2 +
 test/validation/api/ipsec/ipsec_test_out.c | 194 +
 3 files changed, 198 insertions(+), 2 deletions(-)

diff --git a/test/validation/api/ipsec/ipsec.c 
b/test/validation/api/ipsec/ipsec.c
index aa46a236e..097216730 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -556,8 +556,8 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
memset(, 0, sizeof(param));
param.num_sa = 1;
param.sa = 
-   param.num_opt = 0;
-   param.opt = NULL;
+   param.num_opt = part->num_opt;
+   param.opt = >opt;
 
if (ODP_IPSEC_OP_MODE_SYNC == suite_context.outbound_op_mode) {
CU_ASSERT_EQUAL(part->out_pkt, odp_ipsec_out(, 1,
diff --git a/test/validation/api/ipsec/ipsec.h 
b/test/validation/api/ipsec/ipsec.h
index 9a24dd38c..f2ebd388c 100644
--- a/test/validation/api/ipsec/ipsec.h
+++ b/test/validation/api/ipsec/ipsec.h
@@ -45,6 +45,8 @@ typedef struct {
 typedef struct {
const ipsec_test_packet *pkt_in;
odp_bool_t lookup;
+   int num_opt;
+   odp_ipsec_out_opt_t opt;
int out_pkt;
struct {
odp_ipsec_op_status_t status;
diff --git a/test/validation/api/ipsec/ipsec_test_out.c 
b/test/validation/api/ipsec/ipsec_test_out.c
index 2ee8a1319..4751e6ec8 100644
--- a/test/validation/api/ipsec/ipsec_test_out.c
+++ b/test/validation/api/ipsec/ipsec_test_out.c
@@ -500,6 +500,192 @@ static void test_out_ipv4_esp_null_aes_gmac_128(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_out_ipv4_ah_sha256_frag_check(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   false, true, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.outbound.frag_mode = ODP_IPSEC_FRAG_CHECK;
+   param.outbound.mtu = 100;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.mtu = 1,
+ .pkt_out = NULL },
+   },
+   };
+
+   ipsec_test_part test2 = {
+   .pkt_in = _ipv4_icmp_0,
+   .num_opt = 1,
+   .opt = { .mode = ODP_IPSEC_FRAG_DISABLED, },
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0_ah_sha256_1 },
+   },
+   };
+
+   ipsec_check_out_one(, sa);
+
+   ipsec_check_out_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_out_ipv4_ah_sha256_frag_check_2(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   false, true, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.outbound.frag_mode = ODP_IPSEC_FRAG_CHECK;
+   param.outbound.mtu = 100;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.mtu = 1,
+ .pkt_out = NULL },
+   },
+   };
+
+   ipsec_test_part test2 = {
+   .pkt_in = _ipv4_icmp_0,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0_ah_sha256_1 },
+   },
+   };
+
+   ipsec_check_out_one(, sa);
+
+   odp_ipsec_sa_mtu_update(sa, 256);
+
+   ipsec_check_out_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_out_ipv4_esp_null_sha256_frag_check(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   false, false, 123, 

[lng-odp] [PATCH API-NEXT v8 14/16] linux-gen: ipsec: support ODP_IPSEC_FRAG_CHECK

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Support checking MTU after IPsec transformation.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 platform/linux-generic/odp_ipsec.c | 39 ++
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index 3c539b515..a393c5051 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -990,7 +990,8 @@ static int ipsec_out_esp(odp_packet_t *pkt,
 ipsec_state_t *state,
 ipsec_sa_t *ipsec_sa,
 odp_crypto_packet_op_param_t *param,
-odp_ipsec_op_status_t *status)
+odp_ipsec_op_status_t *status,
+uint32_t mtu)
 {
_odp_esphdr_t esp;
_odp_esptrl_t esptrl;
@@ -1026,6 +1027,11 @@ static int ipsec_out_esp(odp_packet_t *pkt,
udphdr.chksum = 0; /* should be 0 by RFC */
}
 
+   if (state->ip_tot_len + hdr_len + trl_len > mtu) {
+   status->error.mtu = 1;
+   return -1;
+   }
+
if (ipsec_out_iv(state, ipsec_sa) < 0) {
status->error.alg = 1;
return -1;
@@ -1124,7 +1130,8 @@ static int ipsec_out_ah(odp_packet_t *pkt,
ipsec_state_t *state,
ipsec_sa_t *ipsec_sa,
odp_crypto_packet_op_param_t *param,
-   odp_ipsec_op_status_t *status)
+   odp_ipsec_op_status_t *status,
+   uint32_t mtu)
 {
_odp_ahhdr_t ah;
unsigned hdr_len = _ODP_AHHDR_LEN + ipsec_sa->esp_iv_len +
@@ -1132,6 +1139,11 @@ static int ipsec_out_ah(odp_packet_t *pkt,
uint16_t ipsec_offset = state->ip_offset + state->ip_hdr_len;
uint8_t proto = _ODP_IPPROTO_AH;
 
+   if (state->ip_tot_len + hdr_len > mtu) {
+   status->error.mtu = 1;
+   return -1;
+   }
+
memset(, 0, sizeof(ah));
ah.spi = odp_cpu_to_be_32(ipsec_sa->spi);
ah.seq_no = odp_cpu_to_be_32(ipsec_seq_no(ipsec_sa));
@@ -1228,7 +1240,7 @@ static void ipsec_out_ah_post(ipsec_state_t *state, 
odp_packet_t pkt)
 static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
odp_ipsec_sa_t sa,
odp_packet_t *pkt_out,
-   const odp_ipsec_out_opt_t *opt ODP_UNUSED,
+   const odp_ipsec_out_opt_t *opt,
odp_ipsec_op_status_t *status)
 {
ipsec_state_t state;
@@ -1237,6 +1249,7 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
int rc;
odp_crypto_packet_result_t crypto; /**< Crypto operation result */
odp_packet_hdr_t *pkt_hdr;
+   uint32_t mtu;
 
state.ip_offset = odp_packet_l3_offset(pkt);
ODP_ASSERT(ODP_PACKET_OFFSET_INVALID != state.ip_offset);
@@ -1247,6 +1260,12 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
ipsec_sa = _odp_ipsec_sa_use(sa);
ODP_ASSERT(NULL != ipsec_sa);
 
+   if ((opt && opt->mode == ODP_IPSEC_FRAG_CHECK) ||
+   (!opt && ipsec_sa->out.frag_mode == ODP_IPSEC_FRAG_CHECK))
+   mtu = ipsec_sa->out.mtu;
+   else
+   mtu = UINT32_MAX;
+
/* Initialize parameters block */
memset(, 0, sizeof(param));
 
@@ -1281,9 +1300,9 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
}
 
if (ODP_IPSEC_ESP == ipsec_sa->proto) {
-   rc = ipsec_out_esp(, , ipsec_sa, , status);
+   rc = ipsec_out_esp(, , ipsec_sa, , status, mtu);
} else if (ODP_IPSEC_AH == ipsec_sa->proto) {
-   rc = ipsec_out_ah(, , ipsec_sa, , status);
+   rc = ipsec_out_ah(, , ipsec_sa, , status, mtu);
} else {
status->error.alg = 1;
goto err;
@@ -1402,10 +1421,6 @@ int odp_ipsec_in(const odp_packet_t pkt_in[], int num_in,
return in_pkt;
 }
 
-static const odp_ipsec_out_opt_t default_opt = {
-   .mode = ODP_IPSEC_FRAG_DISABLED,
-};
-
 int odp_ipsec_out(const odp_packet_t pkt_in[], int num_in,
  odp_packet_t pkt_out[], int *num_out,
  const odp_ipsec_out_param_t *param)
@@ -1434,7 +1449,7 @@ int odp_ipsec_out(const odp_packet_t pkt_in[], int num_in,
ODP_ASSERT(ODP_IPSEC_SA_INVALID != sa);
 
if (0 == param->num_opt)
-   opt = _opt;
+   opt 

[lng-odp] [PATCH API-NEXT v8 15/16] validation: ipsec: fix out inline with NULL pkt_out

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

pkt_out can be NULL if we expect an error. IPsec outbound inline needs
proper outer header to function. Pass L2 header from inbound packet if
outbound packet is NULL.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 test/validation/api/ipsec/ipsec.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/test/validation/api/ipsec/ipsec.c 
b/test/validation/api/ipsec/ipsec.c
index 7b39c2c5a..aa46a236e 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -583,10 +583,18 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
} else {
struct odp_ipsec_out_inline_param_t inline_param;
odp_queue_t queue;
-   uint32_t hdr_len = part->out[0].pkt_out->l3_offset;
-   uint8_t hdr[hdr_len];
+   uint32_t hdr_len;
+   uint8_t hdr[32];
 
-   memcpy(hdr, part->out[0].pkt_out->data, hdr_len);
+   if (NULL != part->out[0].pkt_out) {
+   hdr_len = part->out[0].pkt_out->l3_offset;
+   CU_ASSERT_FATAL(hdr_len <= sizeof(hdr));
+   memcpy(hdr, part->out[0].pkt_out->data, hdr_len);
+   } else {
+   hdr_len = part->pkt_in->l3_offset;
+   CU_ASSERT_FATAL(hdr_len <= sizeof(hdr));
+   memcpy(hdr, part->pkt_in->data, hdr_len);
+   }
inline_param.pktio = suite_context.pktio;
inline_param.outer_hdr.ptr = hdr;
inline_param.outer_hdr.len = hdr_len;



[lng-odp] [PATCH API-NEXT v8 7/16] validation: ipsec: add tests for IPv6 functionality

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 test/validation/api/ipsec/ipsec_test_in.c  | 262 +
 test/validation/api/ipsec/ipsec_test_out.c | 331 +
 test/validation/api/ipsec/test_vectors.h   | 443 +
 3 files changed, 1036 insertions(+)

diff --git a/test/validation/api/ipsec/ipsec_test_in.c 
b/test/validation/api/ipsec/ipsec_test_in.c
index 5af98112a..15e1fe14f 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -71,6 +71,37 @@ static void test_in_ipv4_ah_sha256_tun_ipv4(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv4_ah_sha256_tun_ipv6(void)
+{
+   odp_ipsec_tunnel_param_t tunnel = {};
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, true, 123, ,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0_ah_tun_ipv6_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
 static void test_in_ipv4_ah_sha256_tun_ipv4_notun(void)
 {
odp_ipsec_sa_param_t param;
@@ -314,6 +345,37 @@ static void test_in_ipv4_esp_null_sha256_tun_ipv4(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv4_esp_null_sha256_tun_ipv6(void)
+{
+   odp_ipsec_tunnel_param_t tunnel = {};
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, ,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0_esp_tun_ipv6_null_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
 static void test_in_ipv4_ah_sha256_noreplay(void)
 {
odp_ipsec_sa_param_t param;
@@ -1071,6 +1133,190 @@ static void test_in_ipv4_esp_null_aes_gmac_128(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv6_ah_sha256(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, true, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv6_icmp_0_ah_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv6_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_in_ipv6_ah_sha256_tun_ipv4(void)
+{
+   odp_ipsec_tunnel_param_t tunnel = {};
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, true, 123, ,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv6_icmp_0_ah_tun_ipv4_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv6_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void 

[lng-odp] [PATCH API-NEXT v8 6/16] linux-gen: ipsec: implement IPv6 protocol support

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Implement support for handling IPv6 packets and IPv6 tunnels.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 .../linux-generic/include/odp_ipsec_internal.h |  44 +-
 platform/linux-generic/odp_ipsec.c | 468 -
 platform/linux-generic/odp_ipsec_sad.c |  67 ++-
 3 files changed, 440 insertions(+), 139 deletions(-)

diff --git a/platform/linux-generic/include/odp_ipsec_internal.h 
b/platform/linux-generic/include/odp_ipsec_internal.h
index 06447870b..b294e7c4a 100644
--- a/platform/linux-generic/include/odp_ipsec_internal.h
+++ b/platform/linux-generic/include/odp_ipsec_internal.h
@@ -24,6 +24,8 @@ extern "C" {
 #include 
 #include 
 
+#include 
+
 /** @ingroup odp_ipsec
  *  @{
  */
@@ -127,10 +129,12 @@ struct ipsec_sa_s {
unsigneddec_ttl : 1;
unsignedcopy_dscp : 1;
unsignedcopy_df : 1;
+   unsignedcopy_flabel : 1;
unsignedaes_ctr_iv : 1;
 
/* Only for outbound */
unsigneduse_counter_iv : 1;
+   unsignedtun_ipv4 : 1;
 
/* Only for inbound */
unsignedantireplay : 1;
@@ -140,23 +144,38 @@ struct ipsec_sa_s {
union {
struct {
odp_ipsec_lookup_mode_t lookup_mode;
-   odp_u32be_t lookup_dst_ip;
+   odp_ipsec_ip_version_t lookup_ver;
+   union {
+   odp_u32be_t lookup_dst_ipv4;
+   uint8_t lookup_dst_ipv6[_ODP_IPV6ADDR_LEN];
+   };
odp_atomic_u64_t antireplay;
} in;
 
struct {
-   odp_u32be_t tun_src_ip;
-   odp_u32be_t tun_dst_ip;
-
-   /* 32-bit from which low 16 are used */
-   odp_atomic_u32_t tun_hdr_id;
-   odp_atomic_u32_t seq;
-
odp_atomic_u64_t counter; /* for CTR/GCM */
+   odp_atomic_u32_t seq;
 
-   uint8_t tun_ttl;
-   uint8_t tun_dscp;
-   uint8_t tun_df;
+   union {
+   struct {
+   odp_u32be_t src_ip;
+   odp_u32be_t dst_ip;
+
+   /* 32-bit from which low 16 are used */
+   odp_atomic_u32_t hdr_id;
+
+   uint8_t ttl;
+   uint8_t dscp;
+   uint8_t df;
+   } tun_ipv4;
+   struct {
+   uint8_t src_ip[_ODP_IPV6ADDR_LEN];
+   uint8_t dst_ip[_ODP_IPV6ADDR_LEN];
+   uint8_t hlimit;
+   uint8_t dscp;
+   uint32_tflabel;
+   } tun_ipv6;
+   };
} out;
};
 };
@@ -171,7 +190,8 @@ typedef struct odp_ipsec_sa_lookup_s {
/** SPI value */
uint32_t spi;
 
-   /* FIXME: IPv4 vs IPv6 */
+   /** IP protocol version */
+   odp_ipsec_ip_version_t ver;
 
/** IP destination address (NETWORK ENDIAN) */
void*dst_addr;
diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index 6ce5bc781..ae2fa10a4 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -125,6 +125,8 @@ static inline int _odp_ipv4_csum(odp_packet_t pkt,
 
 #define _ODP_IPV4HDR_CSUM_OFFSET ODP_OFFSETOF(_odp_ipv4hdr_t, chksum)
 #define _ODP_IPV4HDR_PROTO_OFFSET ODP_OFFSETOF(_odp_ipv4hdr_t, proto)
+#define _ODP_IPV6HDR_NHDR_OFFSET ODP_OFFSETOF(_odp_ipv6hdr_t, next_hdr)
+#define _ODP_IPV6HDREXT_NHDR_OFFSET ODP_OFFSETOF(_odp_ipv6hdr_ext_t, next_hdr)
 
 /**
  * Calculate and fill in IPv4 checksum
@@ -159,11 +161,6 @@ static inline int _odp_ipv4_csum_update(odp_packet_t pkt)
 }
 
 #define ipv4_hdr_len(ip) (_ODP_IPV4HDR_IHL((ip)->ver_ihl) * 4)
-static inline
-void ipv4_adjust_len(_odp_ipv4hdr_t *ip, int adj)
-{
-   ip->tot_len = odp_cpu_to_be_16(odp_be_to_cpu_16(ip->tot_len) + adj);
-}
 
 static const uint8_t 

[lng-odp] [PATCH API-NEXT v8 12/16] linux-gen: ipsec: store mtu and frag_mode in SA

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 platform/linux-generic/include/odp_ipsec_internal.h |  2 ++
 platform/linux-generic/odp_ipsec_sad.c  | 14 +++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/platform/linux-generic/include/odp_ipsec_internal.h 
b/platform/linux-generic/include/odp_ipsec_internal.h
index 822c9016b..c6f241fac 100644
--- a/platform/linux-generic/include/odp_ipsec_internal.h
+++ b/platform/linux-generic/include/odp_ipsec_internal.h
@@ -156,6 +156,8 @@ struct ipsec_sa_s {
struct {
odp_atomic_u64_t counter; /* for CTR/GCM */
odp_atomic_u32_t seq;
+   odp_ipsec_frag_mode_t frag_mode;
+   uint32_t mtu;
 
union {
struct {
diff --git a/platform/linux-generic/odp_ipsec_sad.c 
b/platform/linux-generic/odp_ipsec_sad.c
index 82b3c4522..2d6321166 100644
--- a/platform/linux-generic/odp_ipsec_sad.c
+++ b/platform/linux-generic/odp_ipsec_sad.c
@@ -230,6 +230,8 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const 
odp_ipsec_sa_param_t *param)
odp_atomic_init_u64(_sa->in.antireplay, 0);
} else {
odp_atomic_store_u32(_sa->out.seq, 1);
+   ipsec_sa->out.frag_mode = param->outbound.frag_mode;
+   ipsec_sa->out.mtu = param->outbound.mtu;
}
ipsec_sa->dec_ttl = param->opt.dec_ttl;
ipsec_sa->copy_dscp = param->opt.copy_dscp;
@@ -489,10 +491,16 @@ uint64_t odp_ipsec_sa_to_u64(odp_ipsec_sa_t sa)
 
 int odp_ipsec_sa_mtu_update(odp_ipsec_sa_t sa, uint32_t mtu)
 {
-   (void)sa;
-   (void)mtu;
+   ipsec_sa_t *ipsec_sa;
+
+   ipsec_sa = _odp_ipsec_sa_use(sa);
+   ODP_ASSERT(NULL != ipsec_sa);
 
-   return -1;
+   ipsec_sa->out.mtu = mtu;
+
+   _odp_ipsec_sa_unuse(ipsec_sa);
+
+   return 0;
 }
 
 ipsec_sa_t *_odp_ipsec_sa_lookup(const ipsec_sa_lookup_t *lookup)



[lng-odp] [PATCH API-NEXT v8 8/16] linux-gen: ipsec: simplify seq no handling

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

There is no point in filling artificial AAD struct for AH just for the
sake of sequence number checking. Instead use AAD just for ESP and
provide separate seq_no field.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 platform/linux-generic/odp_ipsec.c | 32 ++--
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index ae2fa10a4..a48312fe9 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -233,6 +233,7 @@ typedef struct {
struct {
uint16_t hdr_len;
uint16_t trl_len;
+   odp_u32be_t seq_no;
} in;
odp_u32be_t ipv4_addr;
uint8_t ipv6_addr[_ODP_IPV6ADDR_LEN];
@@ -247,8 +248,10 @@ typedef struct {
odp_u32be_t ver_tc_flow;
uint8_t hop_limit;
} ah_ipv6;
+   struct {
+   ipsec_aad_t aad;
+   } esp;
};
-   ipsec_aad_t aad;
uint8_t iv[IPSEC_MAX_IV_LEN];
 } ipsec_state_t;
 
@@ -409,10 +412,11 @@ static int ipsec_in_esp(odp_packet_t *pkt,
ipsec_sa->icv_len;
param->override_iv_ptr = state->iv;
 
-   state->aad.spi = esp.spi;
-   state->aad.seq_no = esp.seq_no;
+   state->esp.aad.spi = esp.spi;
+   state->esp.aad.seq_no = esp.seq_no;
+   state->in.seq_no = odp_be_to_cpu_32(esp.seq_no);
 
-   param->aad.ptr = (uint8_t *)>aad;
+   param->aad.ptr = (uint8_t *)>esp.aad;
 
param->auth_range.offset = ipsec_offset;
param->auth_range.length = state->ip_tot_len -
@@ -515,10 +519,7 @@ static int ipsec_in_ah(odp_packet_t *pkt,
ipv6hdr->hop_limit = 0;
}
 
-   state->aad.spi = ah.spi;
-   state->aad.seq_no = ah.seq_no;
-
-   param->aad.ptr = (uint8_t *)>aad;
+   state->in.seq_no = odp_be_to_cpu_32(ah.seq_no);
 
param->auth_range.offset = state->ip_offset;
param->auth_range.length = state->ip_tot_len;
@@ -614,7 +615,7 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
goto err;
 
if (_odp_ipsec_sa_replay_precheck(ipsec_sa,
- odp_be_to_cpu_32(state.aad.seq_no),
+ state.in.seq_no,
  status) < 0)
goto err;
 
@@ -659,7 +660,7 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
goto err;
 
if (_odp_ipsec_sa_replay_update(ipsec_sa,
-   odp_be_to_cpu_32(state.aad.seq_no),
+   state.in.seq_no,
status) < 0)
goto err;
 
@@ -993,10 +994,10 @@ static int ipsec_out_esp(odp_packet_t *pkt,
esp.spi = odp_cpu_to_be_32(ipsec_sa->spi);
esp.seq_no = odp_cpu_to_be_32(ipsec_seq_no(ipsec_sa));
 
-   state->aad.spi = esp.spi;
-   state->aad.seq_no = esp.seq_no;
+   state->esp.aad.spi = esp.spi;
+   state->esp.aad.seq_no = esp.seq_no;
 
-   param->aad.ptr = (uint8_t *)>aad;
+   param->aad.ptr = (uint8_t *)>esp.aad;
 
memset(, 0, sizeof(esptrl));
esptrl.pad_len = encrypt_len - ip_data_len - _ODP_ESPTRL_LEN;
@@ -1117,11 +1118,6 @@ static int ipsec_out_ah(odp_packet_t *pkt,
 
ah.ah_len = hdr_len / 4 - 2;
 
-   state->aad.spi = ah.spi;
-   state->aad.seq_no = ah.seq_no;
-
-   param->aad.ptr = (uint8_t *)>aad;
-
/* For GMAC */
if (ipsec_out_iv(state, ipsec_sa) < 0) {
status->error.alg = 1;



[lng-odp] [PATCH API-NEXT v8 10/16] linux-gen: packet: add flag for UDP-encapsulated IPsec packets

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 platform/linux-generic/include/odp/api/plat/packet_types.h |  1 +
 platform/linux-generic/odp_ipsec.c |  2 +-
 platform/linux-generic/odp_packet.c| 11 +++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/platform/linux-generic/include/odp/api/plat/packet_types.h 
b/platform/linux-generic/include/odp/api/plat/packet_types.h
index 82fc66e53..128e83148 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_types.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_types.h
@@ -151,6 +151,7 @@ typedef union {
 
uint64_t l3_chksum_done:1; /**< L3 checksum validation done */
uint64_t l4_chksum_done:1; /**< L4 checksum validation done */
+   uint64_t ipsec_udp:1; /**< UDP-encapsulated IPsec packet */
};
 
 } _odp_packet_input_flags_t;
diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index 2f4c69924..8bf4ced4c 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -472,7 +472,7 @@ static int ipsec_in_esp_post(odp_packet_t pkt,
 ipsec_padding, esptrl.pad_len) != 0)
return -1;
 
-   if (udp_encap) {
+   if (_ODP_IPPROTO_UDP == state->ip_next_hdr) {
state->ip_hdr_len -= _ODP_UDPHDR_LEN;
state->in.hdr_len += _ODP_UDPHDR_LEN;
}
diff --git a/platform/linux-generic/odp_packet.c 
b/platform/linux-generic/odp_packet.c
index bdcb482fa..167f8cbc6 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2141,6 +2141,17 @@ static inline void parse_udp(packet_parser_t *prs,
if (odp_unlikely(udplen < sizeof(_odp_udphdr_t)))
prs->error_flags.udp_err = 1;
 
+   if (odp_cpu_to_be_16(_ODP_UDP_IPSEC_PORT) == udp->dst_port &&
+   udplen > 4) {
+   uint32_t val;
+
+   memcpy(, udp + 1, 4);
+   if (val != 0) {
+   prs->input_flags.ipsec = 1;
+   prs->input_flags.ipsec_udp = 1;
+   }
+   }
+
if (offset)
*offset   += sizeof(_odp_udphdr_t);
*parseptr += sizeof(_odp_udphdr_t);



[lng-odp] [PATCH API-NEXT v8 11/16] validation: add UDP-encapsulated IPsec test cases

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 test/validation/api/ipsec/ipsec_test_in.c  | 134 +
 test/validation/api/ipsec/ipsec_test_out.c |  66 ++
 test/validation/api/ipsec/test_vectors.h   |  99 +
 3 files changed, 299 insertions(+)

diff --git a/test/validation/api/ipsec/ipsec_test_in.c 
b/test/validation/api/ipsec/ipsec_test_in.c
index 15e1fe14f..6262f4cb5 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -376,6 +376,69 @@ static void test_in_ipv4_esp_null_sha256_tun_ipv6(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv4_esp_udp_null_sha256(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.opt.udp_encap = 1;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0_esp_udp_null_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_in_ipv4_esp_udp_null_sha256_lookup(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.opt.udp_encap = 1;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0_esp_udp_null_sha256_1,
+   .lookup = 1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
 static void test_in_ipv4_ah_sha256_noreplay(void)
 {
odp_ipsec_sa_param_t param;
@@ -1317,6 +1380,69 @@ static void test_in_ipv6_esp_null_sha256_tun_ipv6(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv6_esp_udp_null_sha256(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.opt.udp_encap = 1;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv6_icmp_0_esp_udp_null_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv6_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_in_ipv6_esp_udp_null_sha256_lookup(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.opt.udp_encap = 1;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv6_icmp_0_esp_udp_null_sha256_1,
+   .lookup = 1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv6_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
 static void ipsec_test_capability(void)
 {
odp_ipsec_capability_t capa;
@@ -1372,6 +1498,10 @@ odp_testinfo_t 

[lng-odp] [PATCH API-NEXT v8 2/16] linux-gen: modularize IPsec implementation

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

To ease adding IPv6/IPcomp/etc modularize IPsec implementation,
refactoring out functions handling ESP/AH and header parsing/tunneling.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 platform/linux-generic/odp_ipsec.c | 1089 
 1 file changed, 597 insertions(+), 492 deletions(-)

diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index b17e4cd7b..6ce5bc781 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -123,8 +123,8 @@ static inline int _odp_ipv4_csum(odp_packet_t pkt,
return 0;
 }
 
-/** @internal Checksum offset in IPv4 header */
-#define _ODP_IPV4HDR_CSUM_OFFSET   10
+#define _ODP_IPV4HDR_CSUM_OFFSET ODP_OFFSETOF(_odp_ipv4hdr_t, chksum)
+#define _ODP_IPV4HDR_PROTO_OFFSET ODP_OFFSETOF(_odp_ipv4hdr_t, proto)
 
 /**
  * Calculate and fill in IPv4 checksum
@@ -158,7 +158,7 @@ static inline int _odp_ipv4_csum_update(odp_packet_t pkt)
2, );
 }
 
-#define ipv4_hdr_len(ip) (_ODP_IPV4HDR_IHL(ip->ver_ihl) * 4)
+#define ipv4_hdr_len(ip) (_ODP_IPV4HDR_IHL((ip)->ver_ihl) * 4)
 static inline
 void ipv4_adjust_len(_odp_ipv4hdr_t *ip, int adj)
 {
@@ -218,200 +218,310 @@ static inline odp_pktio_parser_layer_t 
parse_layer(odp_ipsec_proto_layer_t l)
return ODP_PKTIO_PARSER_LAYER_NONE;
 }
 
-static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
-  odp_ipsec_sa_t sa,
-  odp_packet_t *pkt_out,
-  odp_ipsec_op_status_t *status)
-{
-   ipsec_sa_t *ipsec_sa = NULL;
-   uint32_t ip_offset = odp_packet_l3_offset(pkt);
-   _odp_ipv4hdr_t *ip = odp_packet_l3_ptr(pkt, NULL);
-   uint16_t ip_hdr_len = ipv4_hdr_len(ip);
-   odp_crypto_packet_op_param_t param;
-   int rc;
+typedef struct {
+   _odp_ipv4hdr_t *ip;
unsigned stats_length;
-   uint16_t ipsec_offset;   /**< Offset of IPsec header from
- buffer start */
-   uint8_t iv[IPSEC_MAX_IV_LEN];  /**< ESP IV storage */
-   ipsec_aad_t aad; /**< AAD, note ESN is not fully supported */
-   unsigned hdr_len;/**< Length of IPsec headers */
-   unsigned trl_len;/**< Length of IPsec trailers */
-   uint8_t  ip_tos; /**< Saved IP TOS value */
-   uint8_t  ip_ttl; /**< Saved IP TTL value */
-   uint16_t ip_frag_offset; /**< Saved IP flags value */
-   odp_crypto_packet_result_t crypto; /**< Crypto operation result */
-   odp_packet_hdr_t *pkt_hdr;
+   uint16_t ip_offset;
+   uint16_t ip_hdr_len;
+   uint16_t ip_tot_len;
+   union {
+   struct {
+   uint16_t ip_df;
+   uint8_t  ip_tos;
+   } out_tunnel;
+   struct {
+   uint16_t hdr_len;
+   uint16_t trl_len;
+   } in;
+   };
+   union {
+   struct {
+   uint8_t  tos;
+   uint8_t  ttl;
+   uint16_t frag_offset;
+   } ah_ipv4;
+   };
+   ipsec_aad_t aad;
+   uint8_t iv[IPSEC_MAX_IV_LEN];
+} ipsec_state_t;
+
+static int ipsec_parse_ipv4(ipsec_state_t *state)
+{
+   if (_ODP_IPV4HDR_IS_FRAGMENT(odp_be_to_cpu_16(state->ip->frag_offset)))
+   return -1;
 
-   ODP_ASSERT(ODP_PACKET_OFFSET_INVALID != ip_offset);
-   ODP_ASSERT(NULL != ip);
+   state->ip_hdr_len = ipv4_hdr_len(state->ip);
+   state->ip_tot_len = odp_be_to_cpu_16(state->ip->tot_len);
 
-   ip_tos = 0;
-   ip_ttl = 0;
-   ip_frag_offset = 0;
+   return 0;
+}
 
-   /* Initialize parameters block */
-   memset(, 0, sizeof(param));
+static inline ipsec_sa_t *ipsec_get_sa(odp_ipsec_sa_t sa,
+  odp_ipsec_protocol_t proto,
+  uint32_t spi,
+  void *dst_addr,
+  odp_ipsec_op_status_t *status)
+{
+   ipsec_sa_t *ipsec_sa;
+
+   if (ODP_IPSEC_SA_INVALID == sa) {
+   ipsec_sa_lookup_t lookup;
+
+   lookup.proto = proto;
+   lookup.spi = spi;
+   lookup.dst_addr = dst_addr;
+
+   ipsec_sa = _odp_ipsec_sa_lookup();
+   if (NULL == ipsec_sa) {
+   status->error.sa_lookup = 1;
+   return NULL;
+   }
+   } else {
+   

[lng-odp] [PATCH API-NEXT v8 1/16] validation: ipsec: add ipv4 name parts

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

In preparation to add IPv6 support, add ipv4 everywhere (to test packets
and to test names).

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 test/validation/api/ipsec/ipsec_test_in.c  | 230 ++---
 test/validation/api/ipsec/ipsec_test_out.c | 125 +---
 test/validation/api/ipsec/test_vectors.h   |  38 +++--
 3 files changed, 178 insertions(+), 215 deletions(-)

diff --git a/test/validation/api/ipsec/ipsec_test_in.c 
b/test/validation/api/ipsec/ipsec_test_in.c
index 294e4a5d6..daafaf69a 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -10,7 +10,7 @@
 
 #include "test_vectors.h"
 
-static void test_in_ah_sha256(void)
+static void test_in_ipv4_ah_sha256(void)
 {
odp_ipsec_sa_param_t param;
odp_ipsec_sa_t sa;
@@ -26,12 +26,12 @@ static void test_in_ah_sha256(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_ah_sha256_1,
+   .pkt_in = _ipv4_icmp_0_ah_sha256_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0 },
+ .pkt_out = _ipv4_icmp_0 },
},
};
 
@@ -40,7 +40,7 @@ static void test_in_ah_sha256(void)
ipsec_sa_destroy(sa);
 }
 
-static void test_in_ah_sha256_tun(void)
+static void test_in_ipv4_ah_sha256_tun_ipv4(void)
 {
odp_ipsec_tunnel_param_t tunnel = {};
odp_ipsec_sa_param_t param;
@@ -57,12 +57,12 @@ static void test_in_ah_sha256_tun(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_ah_tun_sha256_1,
+   .pkt_in = _ipv4_icmp_0_ah_tun_ipv4_sha256_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0 },
+ .pkt_out = _ipv4_icmp_0 },
},
};
 
@@ -71,7 +71,7 @@ static void test_in_ah_sha256_tun(void)
ipsec_sa_destroy(sa);
 }
 
-static void test_in_ah_sha256_tun_notun(void)
+static void test_in_ipv4_ah_sha256_tun_ipv4_notun(void)
 {
odp_ipsec_sa_param_t param;
odp_ipsec_sa_t sa;
@@ -87,12 +87,12 @@ static void test_in_ah_sha256_tun_notun(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_ah_tun_sha256_1,
+   .pkt_in = _ipv4_icmp_0_ah_tun_ipv4_sha256_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0_ipip },
+ .pkt_out = _ipv4_icmp_0_ipip },
},
};
 
@@ -101,7 +101,7 @@ static void test_in_ah_sha256_tun_notun(void)
ipsec_sa_destroy(sa);
 }
 
-static void test_in_esp_null_sha256(void)
+static void test_in_ipv4_esp_null_sha256(void)
 {
odp_ipsec_sa_param_t param;
odp_ipsec_sa_t sa;
@@ -117,12 +117,12 @@ static void test_in_esp_null_sha256(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_esp_null_sha256_1,
+   .pkt_in = _ipv4_icmp_0_esp_null_sha256_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0 },
+ .pkt_out = _ipv4_icmp_0 },
},
};
 
@@ -131,7 +131,7 @@ static void test_in_esp_null_sha256(void)
ipsec_sa_destroy(sa);
 }
 
-static void test_in_esp_aes_cbc_null(void)
+static void test_in_ipv4_esp_aes_cbc_null(void)
 {
odp_ipsec_sa_param_t param;
odp_ipsec_sa_t sa;
@@ -147,12 +147,12 @@ static void test_in_esp_aes_cbc_null(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_esp_aes_cbc_null_1,
+   .pkt_in = _ipv4_icmp_0_esp_aes_cbc_null_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0 },
+ .pkt_out = _ipv4_icmp_0 },
  

[lng-odp] [PATCH API-NEXT v8 3/16] validation: ipsec: fix next_header field in mcgrew gcm test vectors

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Test vectors from draft-mcgrew-gcm-test-01 contain invalid next_header
field in ESP trailers (0x01 = ICMP instead of 0x04 = IPv4). Correct test
vectors. Test 12 is disabled till NoNH packets are properly supported in
a defined way.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 test/validation/api/ipsec/ipsec_test_in.c |  4 
 test/validation/api/ipsec/test_vectors.h  | 30 +++---
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/test/validation/api/ipsec/ipsec_test_in.c 
b/test/validation/api/ipsec/ipsec_test_in.c
index daafaf69a..5af98112a 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -947,6 +947,7 @@ static void test_in_ipv4_mcgrew_gcm_4_esp(void)
ipsec_sa_destroy(sa);
 }
 
+#if 0
 static void test_in_ipv4_mcgrew_gcm_12_esp(void)
 {
odp_ipsec_tunnel_param_t tunnel = {};
@@ -977,6 +978,7 @@ static void test_in_ipv4_mcgrew_gcm_12_esp(void)
 
ipsec_sa_destroy(sa);
 }
+#endif
 
 static void test_in_ipv4_mcgrew_gcm_15_esp(void)
 {
@@ -1094,8 +1096,10 @@ odp_testinfo_t ipsec_in_suite[] = {
  ipsec_check_esp_aes_gcm_256),
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_mcgrew_gcm_4_esp,
  ipsec_check_esp_aes_gcm_128),
+#if 0
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_mcgrew_gcm_12_esp,
  ipsec_check_esp_aes_gcm_128),
+#endif
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_mcgrew_gcm_15_esp,
  ipsec_check_esp_null_aes_gmac_128),
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_ah_sha256,
diff --git a/test/validation/api/ipsec/test_vectors.h 
b/test/validation/api/ipsec/test_vectors.h
index 51aa97ccb..c057f7765 100644
--- a/test/validation/api/ipsec/test_vectors.h
+++ b/test/validation/api/ipsec/test_vectors.h
@@ -1021,9 +1021,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_2_esp 
= {
0x3d, 0xe8, 0x18, 0x27, 0xc1, 0x0e, 0x9a, 0x4f,
0x51, 0x33, 0x0d, 0x0e, 0xec, 0x41, 0x66, 0x42,
0xcf, 0xbb, 0x85, 0xa5, 0xb4, 0x7e, 0x48, 0xa4,
-   0xec, 0x3b, 0x9b, 0xa9, 0x5d, 0x91, 0x8b, 0xd1,
-   0x83, 0xb7, 0x0d, 0x3a, 0xa8, 0xbc, 0x6e, 0xe4,
-   0xc3, 0x09, 0xe9, 0xd8, 0x5a, 0x41, 0xad, 0x4a,
+   0xec, 0x3b, 0x9b, 0xa9, 0x5d, 0x91, 0x8b, 0xd4,
+   0x26, 0xf8, 0x39, 0x1b, 0x99, 0x27, 0xd0, 0xfc,
+   0xc9, 0x84, 0x56, 0x1b, 0xbb, 0xce, 0x9f, 0xc0,
},
 };
 
@@ -1078,9 +1078,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_3_esp 
= {
0x06, 0xef, 0xae, 0x9d, 0x65, 0xa5, 0xd7, 0x63,
0x74, 0x8a, 0x63, 0x79, 0x85, 0x77, 0x1d, 0x34,
0x7f, 0x05, 0x45, 0x65, 0x9f, 0x14, 0xe9, 0x9d,
-   0xef, 0x84, 0x2d, 0x8e, 0xb3, 0x35, 0xf4, 0xee,
-   0xcf, 0xdb, 0xf8, 0x31, 0x82, 0x4b, 0x4c, 0x49,
-   0x15, 0x95, 0x6c, 0x96,
+   0xef, 0x84, 0x2d, 0x8b, 0x42, 0xf5, 0x64, 0xf5,
+   0x2d, 0xfd, 0xd6, 0xee, 0xf4, 0xf9, 0x2e, 0xad,
+   0xba, 0xc2, 0x39, 0x90,
},
 };
 
@@ -1137,9 +1137,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_4_esp 
= {
0x45, 0x64, 0x76, 0x49, 0x27, 0x19, 0xff, 0xb6,
0x4d, 0xe7, 0xd9, 0xdc, 0xa1, 0xe1, 0xd8, 0x94,
0xbc, 0x3b, 0xd5, 0x78, 0x73, 0xed, 0x4d, 0x18,
-   0x1d, 0x19, 0xd4, 0xd5, 0xc8, 0xc1, 0x8a, 0xf3,
-   0xf8, 0x21, 0xd4, 0x96, 0xee, 0xb0, 0x96, 0xe9,
-   0x8a, 0xd2, 0xb6, 0x9e, 0x47, 0x99, 0xc7, 0x1d,
+   0x1d, 0x19, 0xd4, 0xd5, 0xc8, 0xc1, 0x8a, 0xf6,
+   0xfe, 0x1d, 0x73, 0x72, 0x22, 0x8a, 0x69, 0xf4,
+   0x0d, 0xeb, 0x37, 0x3d, 0xdc, 0x01, 0x67, 0x6b,
},
 };
 
@@ -1177,9 +1177,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_12_esp 
= {
0x43, 0x45, 0x7e, 0x91, 0x82, 0x44, 0x3b, 0xc6,
 
/* Data */
-   0x43, 0x7f, 0x86, 0x6b, 0xcb, 0x3f, 0x69, 0x9f,
-   0xe9, 0xb0, 0x82, 0x2b, 0xac, 0x96, 0x1c, 0x45,
-   0x04, 0xbe, 0xf2, 0x70,
+   0x43, 0x7f, 0x86, 0x51, 0x7e, 0xa5, 0x95, 0xd2,
+   0xca, 0x00, 0x4c, 0x33, 0x38, 0x8c, 0x46, 0x77,
+   0x0c, 0x59, 0x0a, 0xd6,
},
 };
 
@@ -1234,9 +1234,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_15_esp 
= {
0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64,
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
  

[lng-odp] [PATCH API-NEXT v8 4/16] linux-gen: don't include odp_ipsec_internal.h in odp_packet_internal.h

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Such include adds unnecessary build dependencies. Just include
, which is enough.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 platform/linux-generic/include/odp_packet_internal.h | 2 +-
 platform/linux-generic/pktio/loop.c  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/platform/linux-generic/include/odp_packet_internal.h 
b/platform/linux-generic/include/odp_packet_internal.h
index ab31d0704..58b7ffe7f 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -25,7 +25,7 @@ extern "C" {
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/platform/linux-generic/pktio/loop.c 
b/platform/linux-generic/pktio/loop.c
index 8bb4b4f14..199aa482f 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 



[lng-odp] [PATCH API-NEXT v8 5/16] linux-gen: protocols: ip: add more ipv6 defines

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 platform/linux-generic/include/protocols/ip.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/platform/linux-generic/include/protocols/ip.h 
b/platform/linux-generic/include/protocols/ip.h
index 0fc391abe..7b6b736a6 100644
--- a/platform/linux-generic/include/protocols/ip.h
+++ b/platform/linux-generic/include/protocols/ip.h
@@ -161,11 +161,13 @@ typedef struct ODP_PACKED {
 #define _ODP_IPPROTO_IPIP0x04 /**< IP Encapsulation within IP (4) */
 #define _ODP_IPPROTO_TCP 0x06 /**< Transmission Control Protocol (6) */
 #define _ODP_IPPROTO_UDP 0x11 /**< User Datagram Protocol (17) */
+#define _ODP_IPPROTO_IPV60x29 /**< IPv6 Routing header (41) */
 #define _ODP_IPPROTO_ROUTE   0x2B /**< IPv6 Routing header (43) */
 #define _ODP_IPPROTO_FRAG0x2C /**< IPv6 Fragment (44) */
 #define _ODP_IPPROTO_AH  0x33 /**< Authentication Header (51) */
 #define _ODP_IPPROTO_ESP 0x32 /**< Encapsulating Security Payload (50) */
 #define _ODP_IPPROTO_ICMPv6  0x3A /**< Internet Control Message Protocol (58) 
*/
+#define _ODP_IPPROTO_DEST0x3C /**< IPv6 Destination header (60) */
 #define _ODP_IPPROTO_SCTP0x84 /**< Stream Control Transmission protocol
   (132) */
 #define _ODP_IPPROTO_INVALID 0xFF /**< Reserved invalid by IANA */



[lng-odp] [PATCH API-NEXT v8 0/16] IPsec IPv6 implementation

2017-11-30 Thread Github ODP bot
This adds support for handling of IPv6 packets and IPv6 tunnels.

github
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
/github

checkpatch.pl
total: 0 errors, 0 warnings, 0 checks, 1153 lines checked


to_send-p-000.patch has no obvious style problems and is ready for submission.
WARNING: 'DONT' may be misspelled - perhaps 'DON'T'?
#695: FILE: platform/linux-generic/odp_ipsec.c:664:
+   state->out_tunnel.ip_df = _ODP_IPV4HDR_FLAGS_DONT_FRAG(flags);

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


to_send-p-001.patch has style problems, please review.

If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
CHECK: if this code is redundant consider removing it
#33: FILE: test/validation/api/ipsec/ipsec_test_in.c:950:
+#if 0

CHECK: if this code is redundant consider removing it
#49: FILE: test/validation/api/ipsec/ipsec_test_in.c:1099:
+#if 0

total: 0 errors, 0 warnings, 2 checks, 84 lines checked


to_send-p-002.patch has style problems, please review.

If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 0 warnings, 0 checks, 15 lines checked


to_send-p-003.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 13 lines checked


to_send-p-004.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 876 lines checked


to_send-p-005.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 1122 lines checked


to_send-p-006.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 83 lines checked


to_send-p-007.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 126 lines checked


to_send-p-008.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 32 lines checked


to_send-p-009.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 355 lines checked


to_send-p-010.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 35 lines checked


to_send-p-011.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 63 lines checked


to_send-p-012.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 112 lines checked


to_send-p-013.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 21 lines checked


to_send-p-014.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 224 lines checked


to_send-p-015.patch has no obvious style problems and is ready for submission.
/checkpatch.pl


[lng-odp] [PATCH API-NEXT v7 15/15] validation: ipsec: add ODP_IPSEC_FRAG_CHECK checks

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 test/validation/api/ipsec/ipsec.c  |   4 +-
 test/validation/api/ipsec/ipsec.h  |   2 +
 test/validation/api/ipsec/ipsec_test_out.c | 194 +
 3 files changed, 198 insertions(+), 2 deletions(-)

diff --git a/test/validation/api/ipsec/ipsec.c 
b/test/validation/api/ipsec/ipsec.c
index 7b39c2c5a..4cd12b892 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -556,8 +556,8 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
memset(, 0, sizeof(param));
param.num_sa = 1;
param.sa = 
-   param.num_opt = 0;
-   param.opt = NULL;
+   param.num_opt = part->num_opt;
+   param.opt = >opt;
 
if (ODP_IPSEC_OP_MODE_SYNC == suite_context.outbound_op_mode) {
CU_ASSERT_EQUAL(part->out_pkt, odp_ipsec_out(, 1,
diff --git a/test/validation/api/ipsec/ipsec.h 
b/test/validation/api/ipsec/ipsec.h
index 9a24dd38c..f2ebd388c 100644
--- a/test/validation/api/ipsec/ipsec.h
+++ b/test/validation/api/ipsec/ipsec.h
@@ -45,6 +45,8 @@ typedef struct {
 typedef struct {
const ipsec_test_packet *pkt_in;
odp_bool_t lookup;
+   int num_opt;
+   odp_ipsec_out_opt_t opt;
int out_pkt;
struct {
odp_ipsec_op_status_t status;
diff --git a/test/validation/api/ipsec/ipsec_test_out.c 
b/test/validation/api/ipsec/ipsec_test_out.c
index 2ee8a1319..4751e6ec8 100644
--- a/test/validation/api/ipsec/ipsec_test_out.c
+++ b/test/validation/api/ipsec/ipsec_test_out.c
@@ -500,6 +500,192 @@ static void test_out_ipv4_esp_null_aes_gmac_128(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_out_ipv4_ah_sha256_frag_check(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   false, true, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.outbound.frag_mode = ODP_IPSEC_FRAG_CHECK;
+   param.outbound.mtu = 100;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.mtu = 1,
+ .pkt_out = NULL },
+   },
+   };
+
+   ipsec_test_part test2 = {
+   .pkt_in = _ipv4_icmp_0,
+   .num_opt = 1,
+   .opt = { .mode = ODP_IPSEC_FRAG_DISABLED, },
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0_ah_sha256_1 },
+   },
+   };
+
+   ipsec_check_out_one(, sa);
+
+   ipsec_check_out_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_out_ipv4_ah_sha256_frag_check_2(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   false, true, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.outbound.frag_mode = ODP_IPSEC_FRAG_CHECK;
+   param.outbound.mtu = 100;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.mtu = 1,
+ .pkt_out = NULL },
+   },
+   };
+
+   ipsec_test_part test2 = {
+   .pkt_in = _ipv4_icmp_0,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0_ah_sha256_1 },
+   },
+   };
+
+   ipsec_check_out_one(, sa);
+
+   odp_ipsec_sa_mtu_update(sa, 256);
+
+   ipsec_check_out_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_out_ipv4_esp_null_sha256_frag_check(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   false, false, 123, 

[lng-odp] [PATCH API-NEXT v7 14/15] linux-gen: ipsec: support ODP_IPSEC_FRAG_CHECK

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Support checking MTU after IPsec transformation.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 platform/linux-generic/odp_ipsec.c | 39 ++
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index 3c539b515..a393c5051 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -990,7 +990,8 @@ static int ipsec_out_esp(odp_packet_t *pkt,
 ipsec_state_t *state,
 ipsec_sa_t *ipsec_sa,
 odp_crypto_packet_op_param_t *param,
-odp_ipsec_op_status_t *status)
+odp_ipsec_op_status_t *status,
+uint32_t mtu)
 {
_odp_esphdr_t esp;
_odp_esptrl_t esptrl;
@@ -1026,6 +1027,11 @@ static int ipsec_out_esp(odp_packet_t *pkt,
udphdr.chksum = 0; /* should be 0 by RFC */
}
 
+   if (state->ip_tot_len + hdr_len + trl_len > mtu) {
+   status->error.mtu = 1;
+   return -1;
+   }
+
if (ipsec_out_iv(state, ipsec_sa) < 0) {
status->error.alg = 1;
return -1;
@@ -1124,7 +1130,8 @@ static int ipsec_out_ah(odp_packet_t *pkt,
ipsec_state_t *state,
ipsec_sa_t *ipsec_sa,
odp_crypto_packet_op_param_t *param,
-   odp_ipsec_op_status_t *status)
+   odp_ipsec_op_status_t *status,
+   uint32_t mtu)
 {
_odp_ahhdr_t ah;
unsigned hdr_len = _ODP_AHHDR_LEN + ipsec_sa->esp_iv_len +
@@ -1132,6 +1139,11 @@ static int ipsec_out_ah(odp_packet_t *pkt,
uint16_t ipsec_offset = state->ip_offset + state->ip_hdr_len;
uint8_t proto = _ODP_IPPROTO_AH;
 
+   if (state->ip_tot_len + hdr_len > mtu) {
+   status->error.mtu = 1;
+   return -1;
+   }
+
memset(, 0, sizeof(ah));
ah.spi = odp_cpu_to_be_32(ipsec_sa->spi);
ah.seq_no = odp_cpu_to_be_32(ipsec_seq_no(ipsec_sa));
@@ -1228,7 +1240,7 @@ static void ipsec_out_ah_post(ipsec_state_t *state, 
odp_packet_t pkt)
 static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
odp_ipsec_sa_t sa,
odp_packet_t *pkt_out,
-   const odp_ipsec_out_opt_t *opt ODP_UNUSED,
+   const odp_ipsec_out_opt_t *opt,
odp_ipsec_op_status_t *status)
 {
ipsec_state_t state;
@@ -1237,6 +1249,7 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
int rc;
odp_crypto_packet_result_t crypto; /**< Crypto operation result */
odp_packet_hdr_t *pkt_hdr;
+   uint32_t mtu;
 
state.ip_offset = odp_packet_l3_offset(pkt);
ODP_ASSERT(ODP_PACKET_OFFSET_INVALID != state.ip_offset);
@@ -1247,6 +1260,12 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
ipsec_sa = _odp_ipsec_sa_use(sa);
ODP_ASSERT(NULL != ipsec_sa);
 
+   if ((opt && opt->mode == ODP_IPSEC_FRAG_CHECK) ||
+   (!opt && ipsec_sa->out.frag_mode == ODP_IPSEC_FRAG_CHECK))
+   mtu = ipsec_sa->out.mtu;
+   else
+   mtu = UINT32_MAX;
+
/* Initialize parameters block */
memset(, 0, sizeof(param));
 
@@ -1281,9 +1300,9 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
}
 
if (ODP_IPSEC_ESP == ipsec_sa->proto) {
-   rc = ipsec_out_esp(, , ipsec_sa, , status);
+   rc = ipsec_out_esp(, , ipsec_sa, , status, mtu);
} else if (ODP_IPSEC_AH == ipsec_sa->proto) {
-   rc = ipsec_out_ah(, , ipsec_sa, , status);
+   rc = ipsec_out_ah(, , ipsec_sa, , status, mtu);
} else {
status->error.alg = 1;
goto err;
@@ -1402,10 +1421,6 @@ int odp_ipsec_in(const odp_packet_t pkt_in[], int num_in,
return in_pkt;
 }
 
-static const odp_ipsec_out_opt_t default_opt = {
-   .mode = ODP_IPSEC_FRAG_DISABLED,
-};
-
 int odp_ipsec_out(const odp_packet_t pkt_in[], int num_in,
  odp_packet_t pkt_out[], int *num_out,
  const odp_ipsec_out_param_t *param)
@@ -1434,7 +1449,7 @@ int odp_ipsec_out(const odp_packet_t pkt_in[], int num_in,
ODP_ASSERT(ODP_IPSEC_SA_INVALID != sa);
 
if (0 == param->num_opt)
-   opt = _opt;
+   opt 

[lng-odp] [PATCH API-NEXT v7 11/15] validation: add UDP-encapsulated IPsec test cases

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 test/validation/api/ipsec/ipsec_test_in.c  | 134 +
 test/validation/api/ipsec/ipsec_test_out.c |  66 ++
 test/validation/api/ipsec/test_vectors.h   |  99 +
 3 files changed, 299 insertions(+)

diff --git a/test/validation/api/ipsec/ipsec_test_in.c 
b/test/validation/api/ipsec/ipsec_test_in.c
index 15e1fe14f..6262f4cb5 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -376,6 +376,69 @@ static void test_in_ipv4_esp_null_sha256_tun_ipv6(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv4_esp_udp_null_sha256(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.opt.udp_encap = 1;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0_esp_udp_null_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_in_ipv4_esp_udp_null_sha256_lookup(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.opt.udp_encap = 1;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0_esp_udp_null_sha256_1,
+   .lookup = 1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
 static void test_in_ipv4_ah_sha256_noreplay(void)
 {
odp_ipsec_sa_param_t param;
@@ -1317,6 +1380,69 @@ static void test_in_ipv6_esp_null_sha256_tun_ipv6(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv6_esp_udp_null_sha256(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.opt.udp_encap = 1;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv6_icmp_0_esp_udp_null_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv6_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_in_ipv6_esp_udp_null_sha256_lookup(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+   param.opt.udp_encap = 1;
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv6_icmp_0_esp_udp_null_sha256_1,
+   .lookup = 1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv6_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
 static void ipsec_test_capability(void)
 {
odp_ipsec_capability_t capa;
@@ -1372,6 +1498,10 @@ odp_testinfo_t 

[lng-odp] [PATCH API-NEXT v7 12/15] linux-gen: ipsec: store mtu and frag_mode in SA

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 platform/linux-generic/include/odp_ipsec_internal.h |  2 ++
 platform/linux-generic/odp_ipsec_sad.c  | 14 +++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/platform/linux-generic/include/odp_ipsec_internal.h 
b/platform/linux-generic/include/odp_ipsec_internal.h
index 822c9016b..c6f241fac 100644
--- a/platform/linux-generic/include/odp_ipsec_internal.h
+++ b/platform/linux-generic/include/odp_ipsec_internal.h
@@ -156,6 +156,8 @@ struct ipsec_sa_s {
struct {
odp_atomic_u64_t counter; /* for CTR/GCM */
odp_atomic_u32_t seq;
+   odp_ipsec_frag_mode_t frag_mode;
+   uint32_t mtu;
 
union {
struct {
diff --git a/platform/linux-generic/odp_ipsec_sad.c 
b/platform/linux-generic/odp_ipsec_sad.c
index 82b3c4522..2d6321166 100644
--- a/platform/linux-generic/odp_ipsec_sad.c
+++ b/platform/linux-generic/odp_ipsec_sad.c
@@ -230,6 +230,8 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const 
odp_ipsec_sa_param_t *param)
odp_atomic_init_u64(_sa->in.antireplay, 0);
} else {
odp_atomic_store_u32(_sa->out.seq, 1);
+   ipsec_sa->out.frag_mode = param->outbound.frag_mode;
+   ipsec_sa->out.mtu = param->outbound.mtu;
}
ipsec_sa->dec_ttl = param->opt.dec_ttl;
ipsec_sa->copy_dscp = param->opt.copy_dscp;
@@ -489,10 +491,16 @@ uint64_t odp_ipsec_sa_to_u64(odp_ipsec_sa_t sa)
 
 int odp_ipsec_sa_mtu_update(odp_ipsec_sa_t sa, uint32_t mtu)
 {
-   (void)sa;
-   (void)mtu;
+   ipsec_sa_t *ipsec_sa;
+
+   ipsec_sa = _odp_ipsec_sa_use(sa);
+   ODP_ASSERT(NULL != ipsec_sa);
 
-   return -1;
+   ipsec_sa->out.mtu = mtu;
+
+   _odp_ipsec_sa_unuse(ipsec_sa);
+
+   return 0;
 }
 
 ipsec_sa_t *_odp_ipsec_sa_lookup(const ipsec_sa_lookup_t *lookup)



[lng-odp] [PATCH API-NEXT v7 13/15] api, linux-gen: ipsec: constify in/out params

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Mark all input and out params as constants

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 include/odp/api/spec/ipsec.h   |  6 +++---
 platform/linux-generic/odp_ipsec.c | 10 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h
index 4a33af8ea..cd168d080 100644
--- a/include/odp/api/spec/ipsec.h
+++ b/include/odp/api/spec/ipsec.h
@@ -1021,13 +1021,13 @@ typedef struct odp_ipsec_out_param_t {
int num_opt;
 
/** Pointer to an array of IPSEC SAs */
-   odp_ipsec_sa_t *sa;
+   const odp_ipsec_sa_t *sa;
 
/** Pointer to an array of outbound operation options
 *
 *  May be NULL when num_opt is zero.
 */
-   odp_ipsec_out_opt_t *opt;
+   const odp_ipsec_out_opt_t *opt;
 
 } odp_ipsec_out_param_t;
 
@@ -1055,7 +1055,7 @@ typedef struct odp_ipsec_in_param_t {
 *
 *  May be NULL when num_sa is zero.
 */
-   odp_ipsec_sa_t *sa;
+   const odp_ipsec_sa_t *sa;
 
 } odp_ipsec_in_param_t;
 
diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index 8bf4ced4c..3c539b515 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -1228,7 +1228,7 @@ static void ipsec_out_ah_post(ipsec_state_t *state, 
odp_packet_t pkt)
 static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
odp_ipsec_sa_t sa,
odp_packet_t *pkt_out,
-   odp_ipsec_out_opt_t *opt ODP_UNUSED,
+   const odp_ipsec_out_opt_t *opt ODP_UNUSED,
odp_ipsec_op_status_t *status)
 {
ipsec_state_t state;
@@ -1402,7 +1402,7 @@ int odp_ipsec_in(const odp_packet_t pkt_in[], int num_in,
return in_pkt;
 }
 
-static odp_ipsec_out_opt_t default_opt = {
+static const odp_ipsec_out_opt_t default_opt = {
.mode = ODP_IPSEC_FRAG_DISABLED,
 };
 
@@ -1426,7 +1426,7 @@ int odp_ipsec_out(const odp_packet_t pkt_in[], int num_in,
odp_ipsec_sa_t sa;
ipsec_sa_t *ipsec_sa;
odp_ipsec_packet_result_t *result;
-   odp_ipsec_out_opt_t *opt;
+   const odp_ipsec_out_opt_t *opt;
 
memset(, 0, sizeof(status));
 
@@ -1534,7 +1534,7 @@ int odp_ipsec_out_enq(const odp_packet_t pkt_in[], int 
num_in,
odp_ipsec_sa_t sa;
ipsec_sa_t *ipsec_sa;
odp_ipsec_packet_result_t *result;
-   odp_ipsec_out_opt_t *opt;
+   const odp_ipsec_out_opt_t *opt;
odp_queue_t queue;
 
memset(, 0, sizeof(status));
@@ -1626,7 +1626,7 @@ int odp_ipsec_out_inline(const odp_packet_t pkt_in[], int 
num_in,
odp_ipsec_sa_t sa;
ipsec_sa_t *ipsec_sa;
odp_ipsec_packet_result_t *result;
-   odp_ipsec_out_opt_t *opt;
+   const odp_ipsec_out_opt_t *opt;
uint32_t hdr_len, offset;
const void *ptr;
 



[lng-odp] [PATCH API-NEXT v7 4/15] linux-gen: don't include odp_ipsec_internal.h in odp_packet_internal.h

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Such include adds unnecessary build dependencies. Just include
, which is enough.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 platform/linux-generic/include/odp_packet_internal.h | 2 +-
 platform/linux-generic/pktio/loop.c  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/platform/linux-generic/include/odp_packet_internal.h 
b/platform/linux-generic/include/odp_packet_internal.h
index ab31d0704..58b7ffe7f 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -25,7 +25,7 @@ extern "C" {
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/platform/linux-generic/pktio/loop.c 
b/platform/linux-generic/pktio/loop.c
index 8bb4b4f14..199aa482f 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 



[lng-odp] [PATCH API-NEXT v7 10/15] linux-gen: packet: add flag for UDP-encapsulated IPsec packets

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 platform/linux-generic/include/odp/api/plat/packet_types.h |  1 +
 platform/linux-generic/odp_ipsec.c |  2 +-
 platform/linux-generic/odp_packet.c| 11 +++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/platform/linux-generic/include/odp/api/plat/packet_types.h 
b/platform/linux-generic/include/odp/api/plat/packet_types.h
index 82fc66e53..128e83148 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_types.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_types.h
@@ -151,6 +151,7 @@ typedef union {
 
uint64_t l3_chksum_done:1; /**< L3 checksum validation done */
uint64_t l4_chksum_done:1; /**< L4 checksum validation done */
+   uint64_t ipsec_udp:1; /**< UDP-encapsulated IPsec packet */
};
 
 } _odp_packet_input_flags_t;
diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index 2f4c69924..8bf4ced4c 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -472,7 +472,7 @@ static int ipsec_in_esp_post(odp_packet_t pkt,
 ipsec_padding, esptrl.pad_len) != 0)
return -1;
 
-   if (udp_encap) {
+   if (_ODP_IPPROTO_UDP == state->ip_next_hdr) {
state->ip_hdr_len -= _ODP_UDPHDR_LEN;
state->in.hdr_len += _ODP_UDPHDR_LEN;
}
diff --git a/platform/linux-generic/odp_packet.c 
b/platform/linux-generic/odp_packet.c
index bdcb482fa..167f8cbc6 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2141,6 +2141,17 @@ static inline void parse_udp(packet_parser_t *prs,
if (odp_unlikely(udplen < sizeof(_odp_udphdr_t)))
prs->error_flags.udp_err = 1;
 
+   if (odp_cpu_to_be_16(_ODP_UDP_IPSEC_PORT) == udp->dst_port &&
+   udplen > 4) {
+   uint32_t val;
+
+   memcpy(, udp + 1, 4);
+   if (val != 0) {
+   prs->input_flags.ipsec = 1;
+   prs->input_flags.ipsec_udp = 1;
+   }
+   }
+
if (offset)
*offset   += sizeof(_odp_udphdr_t);
*parseptr += sizeof(_odp_udphdr_t);



[lng-odp] [PATCH API-NEXT v7 8/15] linux-gen: ipsec: simplify seq no handling

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

There is no point in filling artificial AAD struct for AH just for the
sake of sequence number checking. Instead use AAD just for ESP and
provide separate seq_no field.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 platform/linux-generic/odp_ipsec.c | 32 ++--
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index ae2fa10a4..a48312fe9 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -233,6 +233,7 @@ typedef struct {
struct {
uint16_t hdr_len;
uint16_t trl_len;
+   odp_u32be_t seq_no;
} in;
odp_u32be_t ipv4_addr;
uint8_t ipv6_addr[_ODP_IPV6ADDR_LEN];
@@ -247,8 +248,10 @@ typedef struct {
odp_u32be_t ver_tc_flow;
uint8_t hop_limit;
} ah_ipv6;
+   struct {
+   ipsec_aad_t aad;
+   } esp;
};
-   ipsec_aad_t aad;
uint8_t iv[IPSEC_MAX_IV_LEN];
 } ipsec_state_t;
 
@@ -409,10 +412,11 @@ static int ipsec_in_esp(odp_packet_t *pkt,
ipsec_sa->icv_len;
param->override_iv_ptr = state->iv;
 
-   state->aad.spi = esp.spi;
-   state->aad.seq_no = esp.seq_no;
+   state->esp.aad.spi = esp.spi;
+   state->esp.aad.seq_no = esp.seq_no;
+   state->in.seq_no = odp_be_to_cpu_32(esp.seq_no);
 
-   param->aad.ptr = (uint8_t *)>aad;
+   param->aad.ptr = (uint8_t *)>esp.aad;
 
param->auth_range.offset = ipsec_offset;
param->auth_range.length = state->ip_tot_len -
@@ -515,10 +519,7 @@ static int ipsec_in_ah(odp_packet_t *pkt,
ipv6hdr->hop_limit = 0;
}
 
-   state->aad.spi = ah.spi;
-   state->aad.seq_no = ah.seq_no;
-
-   param->aad.ptr = (uint8_t *)>aad;
+   state->in.seq_no = odp_be_to_cpu_32(ah.seq_no);
 
param->auth_range.offset = state->ip_offset;
param->auth_range.length = state->ip_tot_len;
@@ -614,7 +615,7 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
goto err;
 
if (_odp_ipsec_sa_replay_precheck(ipsec_sa,
- odp_be_to_cpu_32(state.aad.seq_no),
+ state.in.seq_no,
  status) < 0)
goto err;
 
@@ -659,7 +660,7 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
goto err;
 
if (_odp_ipsec_sa_replay_update(ipsec_sa,
-   odp_be_to_cpu_32(state.aad.seq_no),
+   state.in.seq_no,
status) < 0)
goto err;
 
@@ -993,10 +994,10 @@ static int ipsec_out_esp(odp_packet_t *pkt,
esp.spi = odp_cpu_to_be_32(ipsec_sa->spi);
esp.seq_no = odp_cpu_to_be_32(ipsec_seq_no(ipsec_sa));
 
-   state->aad.spi = esp.spi;
-   state->aad.seq_no = esp.seq_no;
+   state->esp.aad.spi = esp.spi;
+   state->esp.aad.seq_no = esp.seq_no;
 
-   param->aad.ptr = (uint8_t *)>aad;
+   param->aad.ptr = (uint8_t *)>esp.aad;
 
memset(, 0, sizeof(esptrl));
esptrl.pad_len = encrypt_len - ip_data_len - _ODP_ESPTRL_LEN;
@@ -1117,11 +1118,6 @@ static int ipsec_out_ah(odp_packet_t *pkt,
 
ah.ah_len = hdr_len / 4 - 2;
 
-   state->aad.spi = ah.spi;
-   state->aad.seq_no = ah.seq_no;
-
-   param->aad.ptr = (uint8_t *)>aad;
-
/* For GMAC */
if (ipsec_out_iv(state, ipsec_sa) < 0) {
status->error.alg = 1;



[lng-odp] [PATCH API-NEXT v7 7/15] validation: ipsec: add tests for IPv6 functionality

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 test/validation/api/ipsec/ipsec_test_in.c  | 262 +
 test/validation/api/ipsec/ipsec_test_out.c | 331 +
 test/validation/api/ipsec/test_vectors.h   | 443 +
 3 files changed, 1036 insertions(+)

diff --git a/test/validation/api/ipsec/ipsec_test_in.c 
b/test/validation/api/ipsec/ipsec_test_in.c
index 5af98112a..15e1fe14f 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -71,6 +71,37 @@ static void test_in_ipv4_ah_sha256_tun_ipv4(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv4_ah_sha256_tun_ipv6(void)
+{
+   odp_ipsec_tunnel_param_t tunnel = {};
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, true, 123, ,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0_ah_tun_ipv6_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
 static void test_in_ipv4_ah_sha256_tun_ipv4_notun(void)
 {
odp_ipsec_sa_param_t param;
@@ -314,6 +345,37 @@ static void test_in_ipv4_esp_null_sha256_tun_ipv4(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv4_esp_null_sha256_tun_ipv6(void)
+{
+   odp_ipsec_tunnel_param_t tunnel = {};
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, false, 123, ,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv4_icmp_0_esp_tun_ipv6_null_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv4_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
 static void test_in_ipv4_ah_sha256_noreplay(void)
 {
odp_ipsec_sa_param_t param;
@@ -1071,6 +1133,190 @@ static void test_in_ipv4_esp_null_aes_gmac_128(void)
ipsec_sa_destroy(sa);
 }
 
+static void test_in_ipv6_ah_sha256(void)
+{
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, true, 123, NULL,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv6_icmp_0_ah_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv6_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void test_in_ipv6_ah_sha256_tun_ipv4(void)
+{
+   odp_ipsec_tunnel_param_t tunnel = {};
+   odp_ipsec_sa_param_t param;
+   odp_ipsec_sa_t sa;
+
+   ipsec_sa_param_fill(,
+   true, true, 123, ,
+   ODP_CIPHER_ALG_NULL, NULL,
+   ODP_AUTH_ALG_SHA256_HMAC, _5a_256,
+   NULL);
+
+   sa = odp_ipsec_sa_create();
+
+   CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+   ipsec_test_part test = {
+   .pkt_in = _ipv6_icmp_0_ah_tun_ipv4_sha256_1,
+   .out_pkt = 1,
+   .out = {
+   { .status.warn.all = 0,
+ .status.error.all = 0,
+ .pkt_out = _ipv6_icmp_0 },
+   },
+   };
+
+   ipsec_check_in_one(, sa);
+
+   ipsec_sa_destroy(sa);
+}
+
+static void 

[lng-odp] [PATCH API-NEXT v7 6/15] linux-gen: ipsec: implement IPv6 protocol support

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Implement support for handling IPv6 packets and IPv6 tunnels.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 .../linux-generic/include/odp_ipsec_internal.h |  44 +-
 platform/linux-generic/odp_ipsec.c | 468 -
 platform/linux-generic/odp_ipsec_sad.c |  67 ++-
 3 files changed, 440 insertions(+), 139 deletions(-)

diff --git a/platform/linux-generic/include/odp_ipsec_internal.h 
b/platform/linux-generic/include/odp_ipsec_internal.h
index 06447870b..b294e7c4a 100644
--- a/platform/linux-generic/include/odp_ipsec_internal.h
+++ b/platform/linux-generic/include/odp_ipsec_internal.h
@@ -24,6 +24,8 @@ extern "C" {
 #include 
 #include 
 
+#include 
+
 /** @ingroup odp_ipsec
  *  @{
  */
@@ -127,10 +129,12 @@ struct ipsec_sa_s {
unsigneddec_ttl : 1;
unsignedcopy_dscp : 1;
unsignedcopy_df : 1;
+   unsignedcopy_flabel : 1;
unsignedaes_ctr_iv : 1;
 
/* Only for outbound */
unsigneduse_counter_iv : 1;
+   unsignedtun_ipv4 : 1;
 
/* Only for inbound */
unsignedantireplay : 1;
@@ -140,23 +144,38 @@ struct ipsec_sa_s {
union {
struct {
odp_ipsec_lookup_mode_t lookup_mode;
-   odp_u32be_t lookup_dst_ip;
+   odp_ipsec_ip_version_t lookup_ver;
+   union {
+   odp_u32be_t lookup_dst_ipv4;
+   uint8_t lookup_dst_ipv6[_ODP_IPV6ADDR_LEN];
+   };
odp_atomic_u64_t antireplay;
} in;
 
struct {
-   odp_u32be_t tun_src_ip;
-   odp_u32be_t tun_dst_ip;
-
-   /* 32-bit from which low 16 are used */
-   odp_atomic_u32_t tun_hdr_id;
-   odp_atomic_u32_t seq;
-
odp_atomic_u64_t counter; /* for CTR/GCM */
+   odp_atomic_u32_t seq;
 
-   uint8_t tun_ttl;
-   uint8_t tun_dscp;
-   uint8_t tun_df;
+   union {
+   struct {
+   odp_u32be_t src_ip;
+   odp_u32be_t dst_ip;
+
+   /* 32-bit from which low 16 are used */
+   odp_atomic_u32_t hdr_id;
+
+   uint8_t ttl;
+   uint8_t dscp;
+   uint8_t df;
+   } tun_ipv4;
+   struct {
+   uint8_t src_ip[_ODP_IPV6ADDR_LEN];
+   uint8_t dst_ip[_ODP_IPV6ADDR_LEN];
+   uint8_t hlimit;
+   uint8_t dscp;
+   uint32_tflabel;
+   } tun_ipv6;
+   };
} out;
};
 };
@@ -171,7 +190,8 @@ typedef struct odp_ipsec_sa_lookup_s {
/** SPI value */
uint32_t spi;
 
-   /* FIXME: IPv4 vs IPv6 */
+   /** IP protocol version */
+   odp_ipsec_ip_version_t ver;
 
/** IP destination address (NETWORK ENDIAN) */
void*dst_addr;
diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index 6ce5bc781..ae2fa10a4 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -125,6 +125,8 @@ static inline int _odp_ipv4_csum(odp_packet_t pkt,
 
 #define _ODP_IPV4HDR_CSUM_OFFSET ODP_OFFSETOF(_odp_ipv4hdr_t, chksum)
 #define _ODP_IPV4HDR_PROTO_OFFSET ODP_OFFSETOF(_odp_ipv4hdr_t, proto)
+#define _ODP_IPV6HDR_NHDR_OFFSET ODP_OFFSETOF(_odp_ipv6hdr_t, next_hdr)
+#define _ODP_IPV6HDREXT_NHDR_OFFSET ODP_OFFSETOF(_odp_ipv6hdr_ext_t, next_hdr)
 
 /**
  * Calculate and fill in IPv4 checksum
@@ -159,11 +161,6 @@ static inline int _odp_ipv4_csum_update(odp_packet_t pkt)
 }
 
 #define ipv4_hdr_len(ip) (_ODP_IPV4HDR_IHL((ip)->ver_ihl) * 4)
-static inline
-void ipv4_adjust_len(_odp_ipv4hdr_t *ip, int adj)
-{
-   ip->tot_len = odp_cpu_to_be_16(odp_be_to_cpu_16(ip->tot_len) + adj);
-}
 
 static const uint8_t 

[lng-odp] [PATCH API-NEXT v7 9/15] linux-gen: add support for UDP-encapsulated ESP packets

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 .../linux-generic/include/odp_ipsec_internal.h |  1 +
 platform/linux-generic/include/protocols/udp.h |  2 +
 platform/linux-generic/odp_ipsec.c | 53 +-
 platform/linux-generic/odp_ipsec_sad.c |  1 +
 4 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/platform/linux-generic/include/odp_ipsec_internal.h 
b/platform/linux-generic/include/odp_ipsec_internal.h
index b294e7c4a..822c9016b 100644
--- a/platform/linux-generic/include/odp_ipsec_internal.h
+++ b/platform/linux-generic/include/odp_ipsec_internal.h
@@ -131,6 +131,7 @@ struct ipsec_sa_s {
unsignedcopy_df : 1;
unsignedcopy_flabel : 1;
unsignedaes_ctr_iv : 1;
+   unsignedudp_encap : 1;
 
/* Only for outbound */
unsigneduse_counter_iv : 1;
diff --git a/platform/linux-generic/include/protocols/udp.h 
b/platform/linux-generic/include/protocols/udp.h
index 535aba855..85984c992 100644
--- a/platform/linux-generic/include/protocols/udp.h
+++ b/platform/linux-generic/include/protocols/udp.h
@@ -38,6 +38,8 @@ typedef struct ODP_PACKED {
 ODP_STATIC_ASSERT(sizeof(_odp_udphdr_t) == _ODP_UDPHDR_LEN,
  "_ODP_UDPHDR_T__SIZE_ERROR");
 
+#define _ODP_UDP_IPSEC_PORT 4500
+
 /**
  * @}
  */
diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index a48312fe9..2f4c69924 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -378,9 +379,29 @@ static int ipsec_in_esp(odp_packet_t *pkt,
_odp_esphdr_t esp;
uint16_t ipsec_offset;
ipsec_sa_t *ipsec_sa;
+   odp_bool_t udp_encap = false;
 
ipsec_offset = state->ip_offset + state->ip_hdr_len;
 
+   if (_ODP_IPPROTO_UDP == state->ip_next_hdr) {
+   _odp_udphdr_t udp;
+   uint16_t ip_data_len = state->ip_tot_len -
+  state->ip_hdr_len;
+
+   odp_packet_copy_to_mem(*pkt, ipsec_offset,
+  _ODP_UDPHDR_LEN, );
+
+   if (udp.dst_port != odp_cpu_to_be_16(_ODP_UDP_IPSEC_PORT) ||
+   udp.length != odp_cpu_to_be_16(ip_data_len)) {
+   status->error.proto = 1;
+   return -1;
+   }
+
+   ipsec_offset += _ODP_UDPHDR_LEN;
+   state->ip_hdr_len += _ODP_UDPHDR_LEN;
+   udp_encap = true;
+   }
+
if (odp_packet_copy_to_mem(*pkt, ipsec_offset,
   sizeof(esp), ) < 0) {
status->error.alg = 1;
@@ -396,6 +417,11 @@ static int ipsec_in_esp(odp_packet_t *pkt,
if (status->error.all)
return -1;
 
+   if (!!ipsec_sa->udp_encap != udp_encap) {
+   status->error.proto = 1;
+   return -1;
+   }
+
if (ipsec_in_iv(*pkt, state, ipsec_sa,
ipsec_offset + _ODP_ESPHDR_LEN) < 0) {
status->error.alg = 1;
@@ -446,6 +472,11 @@ static int ipsec_in_esp_post(odp_packet_t pkt,
 ipsec_padding, esptrl.pad_len) != 0)
return -1;
 
+   if (udp_encap) {
+   state->ip_hdr_len -= _ODP_UDPHDR_LEN;
+   state->in.hdr_len += _ODP_UDPHDR_LEN;
+   }
+
odp_packet_copy_from_mem(pkt, state->ip_next_hdr_offset,
 1, _header);
state->in.trl_len += esptrl.pad_len;
@@ -603,7 +634,8 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
}
 
/* Check IP header for IPSec protocols and look it up */
-   if (_ODP_IPPROTO_ESP == state.ip_next_hdr) {
+   if (_ODP_IPPROTO_ESP == state.ip_next_hdr ||
+   _ODP_IPPROTO_UDP == state.ip_next_hdr) {
rc = ipsec_in_esp(, , _sa, sa, , status);
} else if (_ODP_IPPROTO_AH == state.ip_next_hdr) {
rc = ipsec_in_ah(, , _sa, sa, , status);
@@ -962,6 +994,7 @@ static int ipsec_out_esp(odp_packet_t *pkt,
 {
_odp_esphdr_t esp;
_odp_esptrl_t esptrl;
+   _odp_udphdr_t udphdr;
uint32_t encrypt_len;
uint16_t ip_data_len = state->ip_tot_len -
   state->ip_hdr_len;
@@ -983,6 +1016,16 @@ static int ipsec_out_esp(odp_packet_t *pkt,
   ip_data_len +
 

[lng-odp] [PATCH API-NEXT v7 5/15] linux-gen: protocols: ip: add more ipv6 defines

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 platform/linux-generic/include/protocols/ip.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/platform/linux-generic/include/protocols/ip.h 
b/platform/linux-generic/include/protocols/ip.h
index 0fc391abe..7b6b736a6 100644
--- a/platform/linux-generic/include/protocols/ip.h
+++ b/platform/linux-generic/include/protocols/ip.h
@@ -161,11 +161,13 @@ typedef struct ODP_PACKED {
 #define _ODP_IPPROTO_IPIP0x04 /**< IP Encapsulation within IP (4) */
 #define _ODP_IPPROTO_TCP 0x06 /**< Transmission Control Protocol (6) */
 #define _ODP_IPPROTO_UDP 0x11 /**< User Datagram Protocol (17) */
+#define _ODP_IPPROTO_IPV60x29 /**< IPv6 Routing header (41) */
 #define _ODP_IPPROTO_ROUTE   0x2B /**< IPv6 Routing header (43) */
 #define _ODP_IPPROTO_FRAG0x2C /**< IPv6 Fragment (44) */
 #define _ODP_IPPROTO_AH  0x33 /**< Authentication Header (51) */
 #define _ODP_IPPROTO_ESP 0x32 /**< Encapsulating Security Payload (50) */
 #define _ODP_IPPROTO_ICMPv6  0x3A /**< Internet Control Message Protocol (58) 
*/
+#define _ODP_IPPROTO_DEST0x3C /**< IPv6 Destination header (60) */
 #define _ODP_IPPROTO_SCTP0x84 /**< Stream Control Transmission protocol
   (132) */
 #define _ODP_IPPROTO_INVALID 0xFF /**< Reserved invalid by IANA */



[lng-odp] [PATCH API-NEXT v7 1/15] validation: ipsec: add ipv4 name parts

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

In preparation to add IPv6 support, add ipv4 everywhere (to test packets
and to test names).

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 test/validation/api/ipsec/ipsec_test_in.c  | 230 ++---
 test/validation/api/ipsec/ipsec_test_out.c | 125 +---
 test/validation/api/ipsec/test_vectors.h   |  38 +++--
 3 files changed, 178 insertions(+), 215 deletions(-)

diff --git a/test/validation/api/ipsec/ipsec_test_in.c 
b/test/validation/api/ipsec/ipsec_test_in.c
index 294e4a5d6..daafaf69a 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -10,7 +10,7 @@
 
 #include "test_vectors.h"
 
-static void test_in_ah_sha256(void)
+static void test_in_ipv4_ah_sha256(void)
 {
odp_ipsec_sa_param_t param;
odp_ipsec_sa_t sa;
@@ -26,12 +26,12 @@ static void test_in_ah_sha256(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_ah_sha256_1,
+   .pkt_in = _ipv4_icmp_0_ah_sha256_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0 },
+ .pkt_out = _ipv4_icmp_0 },
},
};
 
@@ -40,7 +40,7 @@ static void test_in_ah_sha256(void)
ipsec_sa_destroy(sa);
 }
 
-static void test_in_ah_sha256_tun(void)
+static void test_in_ipv4_ah_sha256_tun_ipv4(void)
 {
odp_ipsec_tunnel_param_t tunnel = {};
odp_ipsec_sa_param_t param;
@@ -57,12 +57,12 @@ static void test_in_ah_sha256_tun(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_ah_tun_sha256_1,
+   .pkt_in = _ipv4_icmp_0_ah_tun_ipv4_sha256_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0 },
+ .pkt_out = _ipv4_icmp_0 },
},
};
 
@@ -71,7 +71,7 @@ static void test_in_ah_sha256_tun(void)
ipsec_sa_destroy(sa);
 }
 
-static void test_in_ah_sha256_tun_notun(void)
+static void test_in_ipv4_ah_sha256_tun_ipv4_notun(void)
 {
odp_ipsec_sa_param_t param;
odp_ipsec_sa_t sa;
@@ -87,12 +87,12 @@ static void test_in_ah_sha256_tun_notun(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_ah_tun_sha256_1,
+   .pkt_in = _ipv4_icmp_0_ah_tun_ipv4_sha256_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0_ipip },
+ .pkt_out = _ipv4_icmp_0_ipip },
},
};
 
@@ -101,7 +101,7 @@ static void test_in_ah_sha256_tun_notun(void)
ipsec_sa_destroy(sa);
 }
 
-static void test_in_esp_null_sha256(void)
+static void test_in_ipv4_esp_null_sha256(void)
 {
odp_ipsec_sa_param_t param;
odp_ipsec_sa_t sa;
@@ -117,12 +117,12 @@ static void test_in_esp_null_sha256(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_esp_null_sha256_1,
+   .pkt_in = _ipv4_icmp_0_esp_null_sha256_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0 },
+ .pkt_out = _ipv4_icmp_0 },
},
};
 
@@ -131,7 +131,7 @@ static void test_in_esp_null_sha256(void)
ipsec_sa_destroy(sa);
 }
 
-static void test_in_esp_aes_cbc_null(void)
+static void test_in_ipv4_esp_aes_cbc_null(void)
 {
odp_ipsec_sa_param_t param;
odp_ipsec_sa_t sa;
@@ -147,12 +147,12 @@ static void test_in_esp_aes_cbc_null(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
 
ipsec_test_part test = {
-   .pkt_in = _icmp_0_esp_aes_cbc_null_1,
+   .pkt_in = _ipv4_icmp_0_esp_aes_cbc_null_1,
.out_pkt = 1,
.out = {
{ .status.warn.all = 0,
  .status.error.all = 0,
- .pkt_out = _icmp_0 },
+ .pkt_out = _ipv4_icmp_0 },
  

[lng-odp] [PATCH API-NEXT v7 2/15] linux-gen: modularize IPsec implementation

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

To ease adding IPv6/IPcomp/etc modularize IPsec implementation,
refactoring out functions handling ESP/AH and header parsing/tunneling.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 platform/linux-generic/odp_ipsec.c | 1089 
 1 file changed, 597 insertions(+), 492 deletions(-)

diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index b17e4cd7b..6ce5bc781 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -123,8 +123,8 @@ static inline int _odp_ipv4_csum(odp_packet_t pkt,
return 0;
 }
 
-/** @internal Checksum offset in IPv4 header */
-#define _ODP_IPV4HDR_CSUM_OFFSET   10
+#define _ODP_IPV4HDR_CSUM_OFFSET ODP_OFFSETOF(_odp_ipv4hdr_t, chksum)
+#define _ODP_IPV4HDR_PROTO_OFFSET ODP_OFFSETOF(_odp_ipv4hdr_t, proto)
 
 /**
  * Calculate and fill in IPv4 checksum
@@ -158,7 +158,7 @@ static inline int _odp_ipv4_csum_update(odp_packet_t pkt)
2, );
 }
 
-#define ipv4_hdr_len(ip) (_ODP_IPV4HDR_IHL(ip->ver_ihl) * 4)
+#define ipv4_hdr_len(ip) (_ODP_IPV4HDR_IHL((ip)->ver_ihl) * 4)
 static inline
 void ipv4_adjust_len(_odp_ipv4hdr_t *ip, int adj)
 {
@@ -218,200 +218,310 @@ static inline odp_pktio_parser_layer_t 
parse_layer(odp_ipsec_proto_layer_t l)
return ODP_PKTIO_PARSER_LAYER_NONE;
 }
 
-static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
-  odp_ipsec_sa_t sa,
-  odp_packet_t *pkt_out,
-  odp_ipsec_op_status_t *status)
-{
-   ipsec_sa_t *ipsec_sa = NULL;
-   uint32_t ip_offset = odp_packet_l3_offset(pkt);
-   _odp_ipv4hdr_t *ip = odp_packet_l3_ptr(pkt, NULL);
-   uint16_t ip_hdr_len = ipv4_hdr_len(ip);
-   odp_crypto_packet_op_param_t param;
-   int rc;
+typedef struct {
+   _odp_ipv4hdr_t *ip;
unsigned stats_length;
-   uint16_t ipsec_offset;   /**< Offset of IPsec header from
- buffer start */
-   uint8_t iv[IPSEC_MAX_IV_LEN];  /**< ESP IV storage */
-   ipsec_aad_t aad; /**< AAD, note ESN is not fully supported */
-   unsigned hdr_len;/**< Length of IPsec headers */
-   unsigned trl_len;/**< Length of IPsec trailers */
-   uint8_t  ip_tos; /**< Saved IP TOS value */
-   uint8_t  ip_ttl; /**< Saved IP TTL value */
-   uint16_t ip_frag_offset; /**< Saved IP flags value */
-   odp_crypto_packet_result_t crypto; /**< Crypto operation result */
-   odp_packet_hdr_t *pkt_hdr;
+   uint16_t ip_offset;
+   uint16_t ip_hdr_len;
+   uint16_t ip_tot_len;
+   union {
+   struct {
+   uint16_t ip_df;
+   uint8_t  ip_tos;
+   } out_tunnel;
+   struct {
+   uint16_t hdr_len;
+   uint16_t trl_len;
+   } in;
+   };
+   union {
+   struct {
+   uint8_t  tos;
+   uint8_t  ttl;
+   uint16_t frag_offset;
+   } ah_ipv4;
+   };
+   ipsec_aad_t aad;
+   uint8_t iv[IPSEC_MAX_IV_LEN];
+} ipsec_state_t;
+
+static int ipsec_parse_ipv4(ipsec_state_t *state)
+{
+   if (_ODP_IPV4HDR_IS_FRAGMENT(odp_be_to_cpu_16(state->ip->frag_offset)))
+   return -1;
 
-   ODP_ASSERT(ODP_PACKET_OFFSET_INVALID != ip_offset);
-   ODP_ASSERT(NULL != ip);
+   state->ip_hdr_len = ipv4_hdr_len(state->ip);
+   state->ip_tot_len = odp_be_to_cpu_16(state->ip->tot_len);
 
-   ip_tos = 0;
-   ip_ttl = 0;
-   ip_frag_offset = 0;
+   return 0;
+}
 
-   /* Initialize parameters block */
-   memset(, 0, sizeof(param));
+static inline ipsec_sa_t *ipsec_get_sa(odp_ipsec_sa_t sa,
+  odp_ipsec_protocol_t proto,
+  uint32_t spi,
+  void *dst_addr,
+  odp_ipsec_op_status_t *status)
+{
+   ipsec_sa_t *ipsec_sa;
+
+   if (ODP_IPSEC_SA_INVALID == sa) {
+   ipsec_sa_lookup_t lookup;
+
+   lookup.proto = proto;
+   lookup.spi = spi;
+   lookup.dst_addr = dst_addr;
+
+   ipsec_sa = _odp_ipsec_sa_lookup();
+   if (NULL == ipsec_sa) {
+   status->error.sa_lookup = 1;
+   return NULL;
+   }
+   } else {
+   

[lng-odp] [PATCH API-NEXT v7 3/15] validation: ipsec: fix next_header field in mcgrew gcm test vectors

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Test vectors from draft-mcgrew-gcm-test-01 contain invalid next_header
field in ESP trailers (0x01 = ICMP instead of 0x04 = IPv4). Correct test
vectors. Test 12 is disabled till NoNH packets are properly supported in
a defined way.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
 test/validation/api/ipsec/ipsec_test_in.c |  4 
 test/validation/api/ipsec/test_vectors.h  | 30 +++---
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/test/validation/api/ipsec/ipsec_test_in.c 
b/test/validation/api/ipsec/ipsec_test_in.c
index daafaf69a..5af98112a 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -947,6 +947,7 @@ static void test_in_ipv4_mcgrew_gcm_4_esp(void)
ipsec_sa_destroy(sa);
 }
 
+#if 0
 static void test_in_ipv4_mcgrew_gcm_12_esp(void)
 {
odp_ipsec_tunnel_param_t tunnel = {};
@@ -977,6 +978,7 @@ static void test_in_ipv4_mcgrew_gcm_12_esp(void)
 
ipsec_sa_destroy(sa);
 }
+#endif
 
 static void test_in_ipv4_mcgrew_gcm_15_esp(void)
 {
@@ -1094,8 +1096,10 @@ odp_testinfo_t ipsec_in_suite[] = {
  ipsec_check_esp_aes_gcm_256),
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_mcgrew_gcm_4_esp,
  ipsec_check_esp_aes_gcm_128),
+#if 0
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_mcgrew_gcm_12_esp,
  ipsec_check_esp_aes_gcm_128),
+#endif
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_mcgrew_gcm_15_esp,
  ipsec_check_esp_null_aes_gmac_128),
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_ah_sha256,
diff --git a/test/validation/api/ipsec/test_vectors.h 
b/test/validation/api/ipsec/test_vectors.h
index 51aa97ccb..c057f7765 100644
--- a/test/validation/api/ipsec/test_vectors.h
+++ b/test/validation/api/ipsec/test_vectors.h
@@ -1021,9 +1021,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_2_esp 
= {
0x3d, 0xe8, 0x18, 0x27, 0xc1, 0x0e, 0x9a, 0x4f,
0x51, 0x33, 0x0d, 0x0e, 0xec, 0x41, 0x66, 0x42,
0xcf, 0xbb, 0x85, 0xa5, 0xb4, 0x7e, 0x48, 0xa4,
-   0xec, 0x3b, 0x9b, 0xa9, 0x5d, 0x91, 0x8b, 0xd1,
-   0x83, 0xb7, 0x0d, 0x3a, 0xa8, 0xbc, 0x6e, 0xe4,
-   0xc3, 0x09, 0xe9, 0xd8, 0x5a, 0x41, 0xad, 0x4a,
+   0xec, 0x3b, 0x9b, 0xa9, 0x5d, 0x91, 0x8b, 0xd4,
+   0x26, 0xf8, 0x39, 0x1b, 0x99, 0x27, 0xd0, 0xfc,
+   0xc9, 0x84, 0x56, 0x1b, 0xbb, 0xce, 0x9f, 0xc0,
},
 };
 
@@ -1078,9 +1078,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_3_esp 
= {
0x06, 0xef, 0xae, 0x9d, 0x65, 0xa5, 0xd7, 0x63,
0x74, 0x8a, 0x63, 0x79, 0x85, 0x77, 0x1d, 0x34,
0x7f, 0x05, 0x45, 0x65, 0x9f, 0x14, 0xe9, 0x9d,
-   0xef, 0x84, 0x2d, 0x8e, 0xb3, 0x35, 0xf4, 0xee,
-   0xcf, 0xdb, 0xf8, 0x31, 0x82, 0x4b, 0x4c, 0x49,
-   0x15, 0x95, 0x6c, 0x96,
+   0xef, 0x84, 0x2d, 0x8b, 0x42, 0xf5, 0x64, 0xf5,
+   0x2d, 0xfd, 0xd6, 0xee, 0xf4, 0xf9, 0x2e, 0xad,
+   0xba, 0xc2, 0x39, 0x90,
},
 };
 
@@ -1137,9 +1137,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_4_esp 
= {
0x45, 0x64, 0x76, 0x49, 0x27, 0x19, 0xff, 0xb6,
0x4d, 0xe7, 0xd9, 0xdc, 0xa1, 0xe1, 0xd8, 0x94,
0xbc, 0x3b, 0xd5, 0x78, 0x73, 0xed, 0x4d, 0x18,
-   0x1d, 0x19, 0xd4, 0xd5, 0xc8, 0xc1, 0x8a, 0xf3,
-   0xf8, 0x21, 0xd4, 0x96, 0xee, 0xb0, 0x96, 0xe9,
-   0x8a, 0xd2, 0xb6, 0x9e, 0x47, 0x99, 0xc7, 0x1d,
+   0x1d, 0x19, 0xd4, 0xd5, 0xc8, 0xc1, 0x8a, 0xf6,
+   0xfe, 0x1d, 0x73, 0x72, 0x22, 0x8a, 0x69, 0xf4,
+   0x0d, 0xeb, 0x37, 0x3d, 0xdc, 0x01, 0x67, 0x6b,
},
 };
 
@@ -1177,9 +1177,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_12_esp 
= {
0x43, 0x45, 0x7e, 0x91, 0x82, 0x44, 0x3b, 0xc6,
 
/* Data */
-   0x43, 0x7f, 0x86, 0x6b, 0xcb, 0x3f, 0x69, 0x9f,
-   0xe9, 0xb0, 0x82, 0x2b, 0xac, 0x96, 0x1c, 0x45,
-   0x04, 0xbe, 0xf2, 0x70,
+   0x43, 0x7f, 0x86, 0x51, 0x7e, 0xa5, 0x95, 0xd2,
+   0xca, 0x00, 0x4c, 0x33, 0x38, 0x8c, 0x46, 0x77,
+   0x0c, 0x59, 0x0a, 0xd6,
},
 };
 
@@ -1234,9 +1234,9 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_15_esp 
= {
0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64,
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
  

[lng-odp] [PATCH API-NEXT v7 0/15] IPsec IPv6 implementation

2017-11-30 Thread Github ODP bot
This adds support for handling of IPv6 packets and IPv6 tunnels.

github
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 32adfc64ec5b4cc2948ab55456aeba75ae6816ff
 **/
/github

checkpatch.pl
total: 0 errors, 0 warnings, 0 checks, 1153 lines checked


to_send-p-000.patch has no obvious style problems and is ready for submission.
WARNING: 'DONT' may be misspelled - perhaps 'DON'T'?
#695: FILE: platform/linux-generic/odp_ipsec.c:664:
+   state->out_tunnel.ip_df = _ODP_IPV4HDR_FLAGS_DONT_FRAG(flags);

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


to_send-p-001.patch has style problems, please review.

If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
CHECK: if this code is redundant consider removing it
#33: FILE: test/validation/api/ipsec/ipsec_test_in.c:950:
+#if 0

CHECK: if this code is redundant consider removing it
#49: FILE: test/validation/api/ipsec/ipsec_test_in.c:1099:
+#if 0

total: 0 errors, 0 warnings, 2 checks, 84 lines checked


to_send-p-002.patch has style problems, please review.

If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 0 warnings, 0 checks, 15 lines checked


to_send-p-003.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 13 lines checked


to_send-p-004.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 876 lines checked


to_send-p-005.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 1122 lines checked


to_send-p-006.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 83 lines checked


to_send-p-007.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 126 lines checked


to_send-p-008.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 32 lines checked


to_send-p-009.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 355 lines checked


to_send-p-010.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 35 lines checked


to_send-p-011.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 63 lines checked


to_send-p-012.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 112 lines checked


to_send-p-013.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 224 lines checked


to_send-p-014.patch has no obvious style problems and is ready for submission.
/checkpatch.pl


[lng-odp] [PATCH API-NEXT v4 1/2] api: packet: separate checksum check flags

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Separate union controlling different checksum checks. It will be used by
IPsec API.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 314 (lumag:ipsec-chksum)
 ** https://github.com/Linaro/odp/pull/314
 ** Patch: https://github.com/Linaro/odp/pull/314.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6673dcd62b3b19902e452decdd5206958db67c58
 **/
 include/odp/api/spec/packet.h   | 46 +
 test/validation/api/packet/packet.c | 10 
 2 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index b897c9d3c..2917ebde0 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -1178,6 +1178,31 @@ int odp_packet_move_data(odp_packet_t pkt, uint32_t 
dst_offset,
  *
  */
 
+/**
+ * Flags to control packet data checksum checking
+ */
+typedef union odp_packet_parse_chksum_t {
+   /** Individual check bits. */
+   struct {
+   /** Check IPv4 header checksum */
+   uint32_t ipv4_chksum   : 1;
+
+   /** Check UDP checksum */
+   uint32_t udp_chksum: 1;
+
+   /** Check TCP checksum */
+   uint32_t tcp_chksum: 1;
+
+   /** Check SCTP checksum */
+   uint32_t sctp_chksum   : 1;
+
+   } check;
+
+   /** All check bits. This can be used to set/clear all flags. */
+   uint32_t all_check;
+
+} odp_packet_parse_chksum_t;
+
 /**
  * Packet parse parameters
  */
@@ -1194,26 +1219,7 @@ typedef struct odp_packet_parse_param_t {
 *  layer. Checksum checking status can be queried for each packet with
 *  odp_packet_l3_chksum_status() and odp_packet_l4_chksum_status().
 */
-   union {
-   /** Individual check bits. */
-   struct {
-   /** Check IPv4 header checksum */
-   uint32_t ipv4_chksum   : 1;
-
-   /** Check UDP checksum */
-   uint32_t udp_chksum: 1;
-
-   /** Check TCP checksum */
-   uint32_t tcp_chksum: 1;
-
-   /** Check SCTP checksum */
-   uint32_t sctp_chksum   : 1;
-
-   } check;
-
-   /** All check bits. This can be used to set/clear all flags. */
-   uint32_t all_check;
-   };
+   odp_packet_parse_chksum_t chksum;
 
 } odp_packet_parse_param_t;
 
diff --git a/test/validation/api/packet/packet.c 
b/test/validation/api/packet/packet.c
index ce4d66c0b..3f0f957f2 100644
--- a/test/validation/api/packet/packet.c
+++ b/test/validation/api/packet/packet.c
@@ -2451,7 +2451,7 @@ void packet_test_parse(void)
 
parse.proto = ODP_PROTO_ETH;
parse.layer = ODP_PROTO_LAYER_ALL;
-   parse.all_check = 0;
+   parse.chksum.all_check = 0;
 
CU_ASSERT(odp_packet_parse(pkt[0], offset[0], ) == 0);
CU_ASSERT(odp_packet_parse_multi([1], [1],
@@ -2482,7 +2482,7 @@ void packet_test_parse(void)
 
parse.proto = ODP_PROTO_IPV4;
parse.layer = ODP_PROTO_LAYER_L4;
-   parse.all_check = 0;
+   parse.chksum.all_check = 0;
 
CU_ASSERT(odp_packet_parse(pkt[0], offset[0], ) == 0);
CU_ASSERT(odp_packet_parse_multi([1], [1],
@@ -2512,7 +2512,7 @@ void packet_test_parse(void)
 
parse.proto = ODP_PROTO_ETH;
parse.layer = ODP_PROTO_LAYER_L4;
-   parse.all_check = 0;
+   parse.chksum.all_check = 0;
 
CU_ASSERT(odp_packet_parse(pkt[0], offset[0], ) == 0);
CU_ASSERT(odp_packet_parse_multi([1], [1],
@@ -2542,7 +2542,7 @@ void packet_test_parse(void)
 
parse.proto = ODP_PROTO_ETH;
parse.layer = ODP_PROTO_LAYER_L4;
-   parse.all_check = 0;
+   parse.chksum.all_check = 0;
 
CU_ASSERT(odp_packet_parse(pkt[0], offset[0], ) == 0);
CU_ASSERT(odp_packet_parse_multi([1], [1],
@@ -2573,7 +2573,7 @@ void packet_test_parse(void)
 
parse.proto = ODP_PROTO_ETH;
parse.layer = ODP_PROTO_LAYER_ALL;
-   parse.all_check = 0;
+   parse.chksum.all_check = 0;
 
CU_ASSERT(odp_packet_parse(pkt[0], offset[0], ) == 0);
CU_ASSERT(odp_packet_parse_multi([1], [1],



[lng-odp] [PATCH API-NEXT v4 2/2] api: ipsec: reuse checksum checking flags from packet API

2017-11-30 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Reuse odp_packet_parse_chksum_t from packet API to ease passing checksum
flags to packet parsing functions.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 314 (lumag:ipsec-chksum)
 ** https://github.com/Linaro/odp/pull/314
 ** Patch: https://github.com/Linaro/odp/pull/314.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6673dcd62b3b19902e452decdd5206958db67c58
 **/
 include/odp/api/spec/ipsec.h | 27 +--
 1 file changed, 1 insertion(+), 26 deletions(-)

diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h
index 4a33af8ea..15d7d25ff 100644
--- a/include/odp/api/spec/ipsec.h
+++ b/include/odp/api/spec/ipsec.h
@@ -159,32 +159,7 @@ typedef struct odp_ipsec_inbound_config_t {
 *  level. Checksum checking status can be queried for each packet with
 *  odp_packet_l3_chksum_status() and odp_packet_l4_chksum_status().
 */
-   union {
-   /** Mapping for individual bits */
-   struct {
-   /** Check IPv4 header checksum in IPSEC payload.
-*  Default value is 0. */
-   uint32_t ipv4_chksum   : 1;
-
-   /** Check UDP checksum in IPSEC payload.
-*  Default value is 0. */
-   uint32_t udp_chksum: 1;
-
-   /** Check TCP checksum in IPSEC payload.
-*  Default value is 0. */
-   uint32_t tcp_chksum: 1;
-
-   /** Check SCTP checksum in IPSEC payload.
-*  Default value is 0. */
-   uint32_t sctp_chksum   : 1;
-   } check;
-
-   /** All bits of the bit field structure
- *
- * This field can be used to set/clear all flags, or bitwise
- * operations over the entire structure. */
-   uint32_t all_check;
-   };
+   odp_packet_parse_chksum_t chksum;
 
 } odp_ipsec_inbound_config_t;
 



[lng-odp] [PATCH API-NEXT v4 0/2] IPsec checksumming API

2017-11-30 Thread Github ODP bot
Separate checksumming flags into separate type to be used by both packet parse 
and IPsec functions.

github
/** Email created from pull request 314 (lumag:ipsec-chksum)
 ** https://github.com/Linaro/odp/pull/314
 ** Patch: https://github.com/Linaro/odp/pull/314.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6673dcd62b3b19902e452decdd5206958db67c58
 **/
/github

checkpatch.pl
total: 0 errors, 0 warnings, 0 checks, 98 lines checked


to_send-p-000.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 33 lines checked


to_send-p-001.patch has no obvious style problems and is ready for submission.
/checkpatch.pl


[lng-odp] [PATCH API-NEXT v2 3/3] validation: queue: refer to blocking level

2017-11-30 Thread Github ODP bot
From: Petri Savolainen 

Refer to the new blocking level capability and parameter
fields to check that those exist.

Signed-off-by: Petri Savolainen 
---
/** Email created from pull request 302 (psavol:next-lockfree-queue)
 ** https://github.com/Linaro/odp/pull/302
 ** Patch: https://github.com/Linaro/odp/pull/302.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 2fb581ec76ff776f788da097894cb3f6b63ae23d
 **/
 test/validation/api/queue/queue.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/validation/api/queue/queue.c 
b/test/validation/api/queue/queue.c
index 1ec05b1fc..3c6db33ab 100644
--- a/test/validation/api/queue/queue.c
+++ b/test/validation/api/queue/queue.c
@@ -69,6 +69,8 @@ void queue_test_capa(void)
CU_ASSERT(capa.sched_prios != 0);
CU_ASSERT(capa.plain.max_num != 0);
CU_ASSERT(capa.sched.max_num != 0);
+   CU_ASSERT(capa.plain.nonblocking >= ODP_BLOCKING);
+   CU_ASSERT(capa.sched.nonblocking >= ODP_BLOCKING);
 
min = capa.plain.max_num;
if (min > capa.sched.max_num)
@@ -82,6 +84,7 @@ void queue_test_capa(void)
name[ODP_QUEUE_NAME_LEN - 1] = 0;
 
odp_queue_param_init();
+   CU_ASSERT(qparams.nonblocking == ODP_BLOCKING);
 
for (j = 0; j < 2; j++) {
if (j == 0) {



[lng-odp] [PATCH API-NEXT v2 1/3] api: queue: non-blocking level parameter

2017-11-30 Thread Github ODP bot
From: Petri Savolainen 

Add queue parameter and capability to indicate queue operation
blocking level. This guarantee of non-blocking is important for
real-time applications. HW based implementations may be always
non-blocking. Where as, SW based implementation need to trade-off
between block freedom and performance.

Signed-off-by: Petri Savolainen 
---
/** Email created from pull request 302 (psavol:next-lockfree-queue)
 ** https://github.com/Linaro/odp/pull/302
 ** Patch: https://github.com/Linaro/odp/pull/302.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 2fb581ec76ff776f788da097894cb3f6b63ae23d
 **/
 include/odp/api/spec/queue.h | 63 
 1 file changed, 63 insertions(+)

diff --git a/include/odp/api/spec/queue.h b/include/odp/api/spec/queue.h
index 73598be06..8069cf08d 100644
--- a/include/odp/api/spec/queue.h
+++ b/include/odp/api/spec/queue.h
@@ -96,6 +96,54 @@ typedef enum odp_queue_op_mode_t {
 
 } odp_queue_op_mode_t;
 
+/**
+ * Non-blocking level
+ *
+ * A non-blocking level defines implementation guarantees for application
+ * progress when multiple threads operate on the same resource (e.g. a queue)
+ * simultaneously. The first level (ODP_BLOCKING) does not have any block
+ * freedom guarantees, but a suspending thread may block the other threads for
+ * the entire time it remains suspended (infinitely if crashed).
+ * On the contrary, actual non-blocking levels provide guarantees of progress:
+ *
+ * ODP_NONBLOCKING_LF:  A non-blocking and lock-free implementation guarantees
+ *  that at least one of the threads successfully completes
+ *  its operations, regardless of what other threads do.
+ *  Application progress is guaranteed, but individual
+ *  threads may starve while trying to execute their
+ *  operations on the shared resource.
+ *
+ * ODP_NONBLOCKING_WF:  A non-blocking and wait-free implementation guarantees
+ *  application progress with starvation freedom. All
+ *  threads are guaranteed to complete their operations in
+ *  a bounded number of steps, regardless of what other
+ *  threads do.
+ *
+ * Non-blocking levels are listed from the weakest to the strongest guarantee 
of
+ * block freedom. Performance of a non-blocking implementation may be lower 
than
+ * the blocking one. Non-blocking guarantees are important e.g. for real-time
+ * applications when real-time and non real-time threads share a resource.
+ */
+typedef enum odp_nonblocking_t {
+   /** Blocking implementation. A suspeding thread may block all other
+*  threads, i.e. no block freedom guarantees. This is the lowest level.
+*/
+   ODP_BLOCKING = 0,
+
+   /** Non-blocking and lock-free implementation. Other threads can make
+*  progress while a thread is suspended. Starvation freedom is not
+*  guaranteed.
+*/
+   ODP_NONBLOCKING_LF,
+
+   /** Non-blocking and wait-free implementation. Other threads can make
+*  progress while a thread is suspended. Starvation freedom is
+*  guaranteed.
+*/
+   ODP_NONBLOCKING_WF
+
+} odp_nonblocking_t;
+
 /**
  * Queue capabilities
  */
@@ -125,6 +173,10 @@ typedef struct odp_queue_capability_t {
  * store all available events. */
uint32_t max_size;
 
+   /** The strongest guarantee of block freedom that is supported
+ * for plain queues. */
+   odp_nonblocking_t nonblocking;
+
} plain;
 
/** Scheduled queue capabilities */
@@ -138,6 +190,10 @@ typedef struct odp_queue_capability_t {
  * store all available events. */
uint32_t max_size;
 
+   /** The strongest guarantee of block freedom that is supported
+ * for scheduled queues. */
+   odp_nonblocking_t nonblocking;
+
} sched;
 
 } odp_queue_capability_t;
@@ -178,6 +234,13 @@ typedef struct odp_queue_param_t {
  * ODP_QUEUE_TYPE_SCHED. */
odp_schedule_param_t sched;
 
+   /** Non-blocking level
+ *
+ * Queue implementation must guarantee at least this level of block
+ * freedom for queue enqueue and dequeue/schedule operations.
+ * The default value is ODP_BLOCKING. */
+   odp_nonblocking_t nonblocking;
+
/** Queue context pointer
  *
  * User defined context pointer associated with the queue. The same



[lng-odp] [PATCH API-NEXT v2 2/3] linux-gen: queue: fill blocking capa

2017-11-30 Thread Github ODP bot
From: Petri Savolainen 

Currently, only blocking queues are implemented.

Signed-off-by: Petri Savolainen 
---
/** Email created from pull request 302 (psavol:next-lockfree-queue)
 ** https://github.com/Linaro/odp/pull/302
 ** Patch: https://github.com/Linaro/odp/pull/302.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 2fb581ec76ff776f788da097894cb3f6b63ae23d
 **/
 platform/linux-generic/odp_queue.c  | 3 +++
 platform/linux-generic/odp_queue_scalable.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/platform/linux-generic/odp_queue.c 
b/platform/linux-generic/odp_queue.c
index 3f355e695..58103930c 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -150,7 +150,9 @@ static int queue_capability(odp_queue_capability_t *capa)
capa->max_sched_groups  = sched_fn->num_grps();
capa->sched_prios   = odp_schedule_num_prio();
capa->plain.max_num = capa->max_queues;
+   capa->plain.nonblocking = ODP_BLOCKING;
capa->sched.max_num = capa->max_queues;
+   capa->sched.nonblocking = ODP_BLOCKING;
 
return 0;
 }
@@ -601,6 +603,7 @@ static void queue_param_init(odp_queue_param_t *params)
params->type = ODP_QUEUE_TYPE_PLAIN;
params->enq_mode = ODP_QUEUE_OP_MT;
params->deq_mode = ODP_QUEUE_OP_MT;
+   params->nonblocking = ODP_BLOCKING;
params->sched.prio  = ODP_SCHED_PRIO_DEFAULT;
params->sched.sync  = ODP_SCHED_SYNC_PARALLEL;
params->sched.group = ODP_SCHED_GROUP_ALL;
diff --git a/platform/linux-generic/odp_queue_scalable.c 
b/platform/linux-generic/odp_queue_scalable.c
index 07201ce7b..88a5a8c27 100644
--- a/platform/linux-generic/odp_queue_scalable.c
+++ b/platform/linux-generic/odp_queue_scalable.c
@@ -315,8 +315,10 @@ static int queue_capability(odp_queue_capability_t *capa)
capa->sched_prios   = odp_schedule_num_prio();
capa->plain.max_num = ODP_CONFIG_QUEUES - NUM_INTERNAL_QUEUES;
capa->plain.max_size= 0;
+   capa->plain.nonblocking = ODP_BLOCKING;
capa->sched.max_num = ODP_CONFIG_QUEUES - NUM_INTERNAL_QUEUES;
capa->sched.max_size= 0;
+   capa->sched.nonblocking = ODP_BLOCKING;
 
return 0;
 }
@@ -861,6 +863,7 @@ static void queue_param_init(odp_queue_param_t *params)
params->type = ODP_QUEUE_TYPE_PLAIN;
params->enq_mode = ODP_QUEUE_OP_MT;
params->deq_mode = ODP_QUEUE_OP_MT;
+   params->nonblocking = ODP_BLOCKING;
params->sched.prio = ODP_SCHED_PRIO_DEFAULT;
params->sched.sync = ODP_SCHED_SYNC_PARALLEL;
params->sched.group = ODP_SCHED_GROUP_ALL;



[lng-odp] [PATCH API-NEXT v2 0/3] api: queue: lockfree queue

2017-11-30 Thread Github ODP bot
Add queue parameter for indicating need for non-blocked operation. Non-blocking 
guarantee is important for real-time applications. E.g. when RT and non-RT 
threads uses queues for communication, RT threads must not block if an non-RT 
thread blocks (e.g. kernel interrupts it). Many HW implementations are 
inherently non-blocking, SW implementations need special care for non-block 
support.

github
/** Email created from pull request 302 (psavol:next-lockfree-queue)
 ** https://github.com/Linaro/odp/pull/302
 ** Patch: https://github.com/Linaro/odp/pull/302.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 2fb581ec76ff776f788da097894cb3f6b63ae23d
 **/
/github

checkpatch.pl
total: 0 errors, 0 warnings, 0 checks, 87 lines checked


to_send-p-000.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 33 lines checked


to_send-p-001.patch has no obvious style problems and is ready for submission.
total: 0 errors, 0 warnings, 0 checks, 15 lines checked


to_send-p-002.patch has no obvious style problems and is ready for submission.
/checkpatch.pl


[lng-odp] [PATCH v1 1/1] travis: add enable-deprecated test configuration

2017-11-30 Thread Github ODP bot
From: Matias Elo 

Test ODP build with 'enable-deprecated' flag set.

Signed-off-by: Matias Elo 
---
/** Email created from pull request 315 (matiaselo:dev/test_deprecated)
 ** https://github.com/Linaro/odp/pull/315
 ** Patch: https://github.com/Linaro/odp/pull/315.patch
 ** Base sha: 5329e5211c447b9b823149baf76112eedfeb07fb
 ** Merge commit sha: 1895582b1ffd725e4601aedc5e9e4fa7aec1071d
 **/
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index b5c1b6417..976f07639 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -69,6 +69,7 @@ cache:
 env:
 - CONF=""
 - CONF="--disable-abi-compat"
+- CONF="--enable-deprecated"
 - CONF="--enable-schedule-sp"
 - CONF="--enable-schedule-iquery"
 - CONF="--enable-dpdk-zero-copy"



[lng-odp] [PATCH v1 0/1] travis: add enable-deprecated test configuration

2017-11-30 Thread Github ODP bot
Test ODP build with 'enable-deprecated' flag set.
Signed-off-by: Matias Elo matias@nokia.com

github
/** Email created from pull request 315 (matiaselo:dev/test_deprecated)
 ** https://github.com/Linaro/odp/pull/315
 ** Patch: https://github.com/Linaro/odp/pull/315.patch
 ** Base sha: 5329e5211c447b9b823149baf76112eedfeb07fb
 ** Merge commit sha: 1895582b1ffd725e4601aedc5e9e4fa7aec1071d
 **/
/github

checkpatch.pl
total: 0 errors, 0 warnings, 0 checks, 7 lines checked


to_send-p-000.patch has no obvious style problems and is ready for submission.
/checkpatch.pl