[lng-odp] [Linaro/odp] 9126ce: linux-gen: modular-framework: move buffer subsyste...

2017-11-28 Thread GitHub
  Branch: refs/heads/2.0
  Home:   https://github.com/Linaro/odp
  Commit: 9126cea4346f5b715e335a54b9d72ec89533187a
  
https://github.com/Linaro/odp/commit/9126cea4346f5b715e335a54b9d72ec89533187a
  Author: Bogdan Pricope 
  Date:   2017-11-29 (Wed, 29 Nov 2017)

  Changed paths:
M include/Makefile.am
A include/subsystem/spec/buffer_subsystem.h
M platform/linux-dpdk/Makefile.am
M platform/linux-dpdk/buffer/dpdk.c
M platform/linux-generic/Makefile.am
M platform/linux-generic/buffer/generic.c
M platform/linux-generic/buffer/subsystem.c
R platform/linux-generic/include/odp_buffer_subsystem.h

  Log Message:
  ---
  linux-gen: modular-framework: move buffer subsystem header to a public folder

Move buffer subsystem header to a public folder.

Signed-off-by: Bogdan Pricope 
Reviewed-by: Honnappa Nagarahalli 
Signed-off-by: Yi He 


  Commit: f47262a495ce304a924a3c5eb00eb349faeb3666
  
https://github.com/Linaro/odp/commit/f47262a495ce304a924a3c5eb00eb349faeb3666
  Author: Bogdan Pricope 
  Date:   2017-11-29 (Wed, 29 Nov 2017)

  Changed paths:
M include/Makefile.am
A include/subsystem/spec/pool_subsystem.h
M platform/linux-dpdk/Makefile.am
M platform/linux-dpdk/include/odp_pool_internal.h
M platform/linux-generic/Makefile.am
M platform/linux-generic/include/odp_pool_internal.h
R platform/linux-generic/include/odp_pool_subsystem.h
M platform/linux-generic/pool/subsystem.c

  Log Message:
  ---
  linux-gen: modular-framework: move pool subsystem header to a public folder

Move pool subsystem header to a public folder.

Signed-off-by: Bogdan Pricope 
Reviewed-by: Honnappa Nagarahalli 
Signed-off-by: Yi He 


  Commit: cb4d057c0f35fbd9855c4b4a08481aab69be3e07
  
https://github.com/Linaro/odp/commit/cb4d057c0f35fbd9855c4b4a08481aab69be3e07
  Author: Bogdan Pricope 
  Date:   2017-11-29 (Wed, 29 Nov 2017)

  Changed paths:
M include/Makefile.am
A include/subsystem/spec/queue_subsystem.h
M platform/linux-dpdk/Makefile.am
M platform/linux-generic/Makefile.am
R platform/linux-generic/include/odp_queue_subsystem.h
M platform/linux-generic/queue/generic.c
M platform/linux-generic/queue/scalable.c
M platform/linux-generic/queue/subsystem.c

  Log Message:
  ---
  linux-gen: modular-framework: move queue subsystem header to a public folder

Move queue subsystem header to a public folder.

Signed-off-by: Bogdan Pricope 
Reviewed-by: Honnappa Nagarahalli 
Signed-off-by: Yi He 


  Commit: ff5ecde9f73158f00df5df7da6f6ceb9ad4fe0f2
  
https://github.com/Linaro/odp/commit/ff5ecde9f73158f00df5df7da6f6ceb9ad4fe0f2
  Author: Bogdan Pricope 
  Date:   2017-11-29 (Wed, 29 Nov 2017)

  Changed paths:
M include/Makefile.am
A include/subsystem/spec/schedule_subsystem.h
M platform/linux-dpdk/Makefile.am
M platform/linux-generic/Makefile.am
R platform/linux-generic/include/odp_schedule_subsystem.h
M platform/linux-generic/schedule/generic.c
M platform/linux-generic/schedule/iquery.c
M platform/linux-generic/schedule/scalable.c
M platform/linux-generic/schedule/sp.c
M platform/linux-generic/schedule/subsystem.c

  Log Message:
  ---
  linux-gen: modular-framework: move schedule subsystem header to a public 
folder

Move schedule subsystem header to a public folder.

Signed-off-by: Bogdan Pricope 
Reviewed-by: Honnappa Nagarahalli 
Signed-off-by: Yi He 


  Commit: 00c7441fae53949dd87855d48102f932f8f64537
  
https://github.com/Linaro/odp/commit/00c7441fae53949dd87855d48102f932f8f64537
  Author: Bogdan Pricope 
  Date:   2017-11-29 (Wed, 29 Nov 2017)

  Changed paths:
M doc/application-api-guide/Doxyfile

  Log Message:
  ---
  doc: application-api-guide: exclude subsystem files

Exclude subsystem files form application API guide document.
Documentation will be added when API will be stable.

Signed-off-by: Bogdan Pricope 
Reviewed-by: Honnappa Nagarahalli 
Signed-off-by: Yi He 


Compare: https://github.com/Linaro/odp/compare/8c1cb083f8ba...00c7441fae53


[lng-odp] [Linaro/odp] 0e8647: linux-gen: pool: rearrange pool_t to separate cont...

2017-11-28 Thread GitHub
  Branch: refs/heads/2.0
  Home:   https://github.com/Linaro/odp
  Commit: 0e8647378bfbe730101e5f089e134356dea00cda
  
https://github.com/Linaro/odp/commit/0e8647378bfbe730101e5f089e134356dea00cda
  Author: Kevin Wang 
  Date:   2017-11-29 (Wed, 29 Nov 2017)

  Changed paths:
M platform/linux-generic/include/odp_pool_internal.h

  Log Message:
  ---
  linux-gen: pool: rearrange pool_t to separate control and data plane

Separate the pool's control plane and data plane data structures.
This avoids sharing control plane related data and dataplane
related data on the same cache line.

Signed-off-by: Kevin Wang 
Reviewed-by: Honnappa Nagarahalli 
Reviewed-by: Ola Liljedahl 
Reviewed-by: Brian Brooks 
Reviewed-by: Yi He 
Reviewed-by: Bill Fischofer 


  Commit: 8c1cb083f8bacd0c1fe56a759591ff7e0633be37
  
https://github.com/Linaro/odp/commit/8c1cb083f8bacd0c1fe56a759591ff7e0633be37
  Author: Kevin Wang 
  Date:   2017-11-29 (Wed, 29 Nov 2017)

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

  Log Message:
  ---
  linux-gen: packet: get pool_hdl from odp_buffer_hdr_t

In odp_packet_rem_data() and odp_packet_add_data(), pool_hdl is
able to be gotten from odp_packet_hdr_t, don't need to get from
pool_t indirectly.

Signed-off-by: Kevin Wang 
Reviewed-by: Honnappa Nagarahalli 
Reviewed-by: Ola Liljedahl 
Reviewed-by: Brian Brooks 
Reviewed-by: Yi He 
Reviewed-by: Bill Fischofer 


Compare: https://github.com/Linaro/odp/compare/7074b71b266d...8c1cb083f8ba


[lng-odp] [PATCH 2.0 v2 2/2] linux-dpdk: pool: Remove unused CONFIG_POOL_MAX_NUM

2017-11-28 Thread Github ODP bot
From: Honnappa Nagarahalli 

CONFIG_POOL_MAX_NUM is not used in linux-dpdk.

Signed-off-by: Honnappa Nagarahalli 
Reviewed-by: Ola Liljedahl 
---
/** Email created from pull request 312 (nagarahalli:2.0-pool-ring-alloc-mem)
 ** https://github.com/Linaro/odp/pull/312
 ** Patch: https://github.com/Linaro/odp/pull/312.patch
 ** Base sha: 7074b71b266de9c4eb5bf03513186a72ea27b2bc
 ** Merge commit sha: 8d4900e5306183f080ba61fae9c2f32fa03ce21e
 **/
 platform/linux-dpdk/include/odp_config_internal.h |  5 -
 platform/linux-dpdk/pool/dpdk.c   | 15 +++
 2 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/platform/linux-dpdk/include/odp_config_internal.h 
b/platform/linux-dpdk/include/odp_config_internal.h
index 6aadc93f3..f36fcb929 100644
--- a/platform/linux-dpdk/include/odp_config_internal.h
+++ b/platform/linux-dpdk/include/odp_config_internal.h
@@ -119,11 +119,6 @@ extern "C" {
  */
 #define CONFIG_BURST_SIZE 16
 
-/*
- * Maximum number of events in a pool
- */
-#define CONFIG_POOL_MAX_NUM (1 * 1024 * 1024)
-
 /*
  * Maximum number of events in a thread local pool cache
  */
diff --git a/platform/linux-dpdk/pool/dpdk.c b/platform/linux-dpdk/pool/dpdk.c
index 90d2d7c61..e0035756f 100644
--- a/platform/linux-dpdk/pool/dpdk.c
+++ b/platform/linux-dpdk/pool/dpdk.c
@@ -137,12 +137,12 @@ static int dpdk_pool_capability(odp_pool_capability_t 
*capa)
capa->buf.max_pools = ODP_CONFIG_POOLS;
capa->buf.max_align = ODP_CONFIG_BUFFER_ALIGN_MAX;
capa->buf.max_size  = MAX_SIZE;
-   capa->buf.max_num   = CONFIG_POOL_MAX_NUM;
+   capa->buf.max_num   = 0;
 
/* Packet pools */
capa->pkt.max_pools= ODP_CONFIG_POOLS;
capa->pkt.max_len  = 0;
-   capa->pkt.max_num  = CONFIG_POOL_MAX_NUM;
+   capa->pkt.max_num  = 0;
capa->pkt.min_headroom = CONFIG_PACKET_HEADROOM;
capa->pkt.min_tailroom = CONFIG_PACKET_TAILROOM;
capa->pkt.max_segs_per_pkt = CONFIG_PACKET_MAX_SEGS;
@@ -152,7 +152,7 @@ static int dpdk_pool_capability(odp_pool_capability_t *capa)
 
/* Timeout pools */
capa->tmo.max_pools = ODP_CONFIG_POOLS;
-   capa->tmo.max_num   = CONFIG_POOL_MAX_NUM;
+   capa->tmo.max_num   = 0;
 
return 0;
 }
@@ -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) {
-   printf("buf.num too large %u\n", params->buf.num);
-   return -1;
-   }
-
if (params->buf.size > capa.buf.max_size) {
printf("buf.size too large %u\n", params->buf.size);
return -1;
@@ -297,10 +292,6 @@ static int check_params(odp_pool_param_t *params)
break;
 
case ODP_POOL_TIMEOUT:
-   if (params->tmo.num > capa.tmo.max_num) {
-   printf("tmo.num too large %u\n", params->tmo.num);
-   return -1;
-   }
break;
 
default:



[lng-odp] [PATCH 2.0 v2 1/2] linux-generic: pool: allocate ring memory based on pool size

2017-11-28 Thread Github ODP bot
From: Honnappa Nagarahalli 

Adjust the size of ring based on configured number of
buffers in the pool.

Signed-off-by: Honnappa Nagarahalli 
Reviewed-by: Ola Liljedahl 
---
/** Email created from pull request 312 (nagarahalli:2.0-pool-ring-alloc-mem)
 ** https://github.com/Linaro/odp/pull/312
 ** Patch: https://github.com/Linaro/odp/pull/312.patch
 ** Base sha: 7074b71b266de9c4eb5bf03513186a72ea27b2bc
 ** Merge commit sha: 8d4900e5306183f080ba61fae9c2f32fa03ce21e
 **/
 .../linux-generic/include/odp_config_internal.h|  5 ---
 platform/linux-generic/include/odp_pool_internal.h |  2 +-
 platform/linux-generic/pool/generic.c  | 37 ++
 3 files changed, 17 insertions(+), 27 deletions(-)

diff --git a/platform/linux-generic/include/odp_config_internal.h 
b/platform/linux-generic/include/odp_config_internal.h
index 9b334df49..9720581a3 100644
--- a/platform/linux-generic/include/odp_config_internal.h
+++ b/platform/linux-generic/include/odp_config_internal.h
@@ -147,11 +147,6 @@
  */
 #define CONFIG_BURST_SIZE 16
 
-/*
- * Maximum number of events in a pool
- */
-#define CONFIG_POOL_MAX_NUM (1 * 1024 * 1024)
-
 /*
  * Maximum number of events in a thread local pool cache
  */
diff --git a/platform/linux-generic/include/odp_pool_internal.h 
b/platform/linux-generic/include/odp_pool_internal.h
index 5004e283c..72e550ce2 100644
--- a/platform/linux-generic/include/odp_pool_internal.h
+++ b/platform/linux-generic/include/odp_pool_internal.h
@@ -41,7 +41,7 @@ typedef struct {
ring_t   hdr;
 
/* Ring data: buffer handles */
-   uint32_t buf[CONFIG_POOL_MAX_NUM];
+   uint32_t buf[];
 
 } pool_ring_t ODP_ALIGNED_CACHE;
 
diff --git a/platform/linux-generic/pool/generic.c 
b/platform/linux-generic/pool/generic.c
index c55f67575..7a068472c 100644
--- a/platform/linux-generic/pool/generic.c
+++ b/platform/linux-generic/pool/generic.c
@@ -156,11 +156,12 @@ static int generic_pool_term_local(void)
return 0;
 }
 
-static pool_t *reserve_pool(void)
+static pool_t *reserve_pool(uint32_t ring_size)
 {
int i;
pool_t *pool;
char ring_name[ODP_POOL_NAME_LEN];
+   uint32_t ring_shm_size;
 
for (i = 0; i < ODP_CONFIG_POOLS; i++) {
pool = pool_entry(i);
@@ -169,10 +170,13 @@ static pool_t *reserve_pool(void)
if (pool->reserved == 0) {
pool->reserved = 1;
UNLOCK(>lock);
-   sprintf(ring_name, "pool_ring_%d", i);
+   snprintf(ring_name, ODP_POOL_NAME_LEN,
+"pool_ring_%d", i);
+   ring_shm_size = sizeof(pool_ring_t) +
+   sizeof(pool->ring->buf[0]) * ring_size;
pool->ring_shm =
odp_shm_reserve(ring_name,
-   sizeof(pool_ring_t),
+   ring_shm_size,
ODP_CACHE_LINE_SIZE, 0);
if (odp_unlikely(pool->ring_shm == ODP_SHM_INVALID)) {
ODP_ERR("Unable to alloc pool ring %d\n", i);
@@ -395,7 +399,12 @@ static odp_pool_t pool_create(const char *name, 
odp_pool_param_t *params,
if (uarea_size)
uarea_size = ROUNDUP_CACHE_LINE(uarea_size);
 
-   pool = reserve_pool();
+   if (num <= RING_SIZE_MIN)
+   ring_size = RING_SIZE_MIN;
+   else
+   ring_size = ROUNDUP_POWER2_U32(num);
+
+   pool = reserve_pool(ring_size);
 
if (pool == NULL) {
ODP_ERR("No more free pools");
@@ -431,11 +440,6 @@ static odp_pool_t pool_create(const char *name, 
odp_pool_param_t *params,
FIRST_HP_SIZE - 1) / FIRST_HP_SIZE);
}
 
-   if (num <= RING_SIZE_MIN)
-   ring_size = RING_SIZE_MIN;
-   else
-   ring_size = ROUNDUP_POWER2_U32(num);
-
pool->ring_mask  = ring_size - 1;
pool->num= num;
pool->align  = align;
@@ -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) {
-   printf("buf.num too large %u\n", params->buf.num);
-   return -1;
-   }
-
if (params->buf.size > capa.buf.max_size) {
printf("buf.size too large %u\n", params->buf.size);
return -1;
@@ -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) {
-   printf("tmo.num too large %u\n", 

[lng-odp] [PATCH 2.0 v2 0/2] allocate ring memory based on pool size

2017-11-28 Thread Github ODP bot
The maximum size of the pool ring is 1M entries as it uses an array. However, 
the application provides the number of buffers in a pool during pool creation. 
Hence, the maximum pool ring size can be dynamic.

github
/** Email created from pull request 312 (nagarahalli:2.0-pool-ring-alloc-mem)
 ** https://github.com/Linaro/odp/pull/312
 ** Patch: https://github.com/Linaro/odp/pull/312.patch
 ** Base sha: 7074b71b266de9c4eb5bf03513186a72ea27b2bc
 ** Merge commit sha: 8d4900e5306183f080ba61fae9c2f32fa03ce21e
 **/
/github

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


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


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


Re: [lng-odp] Preparing for ODP 2.0

2017-11-28 Thread Honnappa Nagarahalli
My understanding is that Linux-Generic implementation is a reference
implementation meant to showcase clarity. I do not think optimizations
go well with that objective.

On 28 November 2017 at 04:43, Maxim Uvarov  wrote:
> If patch is suitable for master or api-next (like cache line optimizations)
> it has to go to master/api-next first. As well as all bug fixes for master
> branch should go directly to master.
> Only than patch can be taken to development branch.
>
> Maxim.
>
>
> On 28 November 2017 at 12:43, Dmitry Eremin-Solenikov <
> dmitry.ereminsoleni...@linaro.org> wrote:
>
>> On 28/11/17 00:57, Bill Fischofer wrote:
>> > As a way of easing the sync burden on the 2.0 development branch, what do
>> > folks think of the idea of asking that new PRs being posted to api-next
>> > also be posted to 2.0? The contributions to api-next should be winding
>> down
>> > as we approach Tiger Moth freeze, so this will help keep things in sync
>> as
>> > we transition back into a single development target post-Tiger Moth.
>> >
>> > Please share your views on this.
>>
>> No, current '2.0' should be refactored as a set of PRs against
>> master/api-next. When its development was started, it was promised that
>> 2.0 will be reviewed before merging to master/api-next.
>>
>>
>> --
>> With best wishes
>> Dmitry
>>


[lng-odp] [PATCH 2.0 v1 2/2] linux-dpdk: pool: Remove unused CONFIG_POOL_MAX_NUM

2017-11-28 Thread Github ODP bot
From: Honnappa Nagarahalli 

CONFIG_POOL_MAX_NUM is not used in linux-dpdk.

Signed-off-by: Honnappa Nagarahalli 
Reviewed-by: Ola Liljedahl 
---
/** Email created from pull request 312 (nagarahalli:2.0-pool-ring-alloc-mem)
 ** https://github.com/Linaro/odp/pull/312
 ** Patch: https://github.com/Linaro/odp/pull/312.patch
 ** Base sha: 7074b71b266de9c4eb5bf03513186a72ea27b2bc
 ** Merge commit sha: f6e1b802c13d4f93d96e8b309712f74109d1cfd3
 **/
 platform/linux-dpdk/include/odp_config_internal.h |  5 -
 platform/linux-dpdk/pool/dpdk.c   | 15 +++
 2 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/platform/linux-dpdk/include/odp_config_internal.h 
b/platform/linux-dpdk/include/odp_config_internal.h
index 6aadc93f3..f36fcb929 100644
--- a/platform/linux-dpdk/include/odp_config_internal.h
+++ b/platform/linux-dpdk/include/odp_config_internal.h
@@ -119,11 +119,6 @@ extern "C" {
  */
 #define CONFIG_BURST_SIZE 16
 
-/*
- * Maximum number of events in a pool
- */
-#define CONFIG_POOL_MAX_NUM (1 * 1024 * 1024)
-
 /*
  * Maximum number of events in a thread local pool cache
  */
diff --git a/platform/linux-dpdk/pool/dpdk.c b/platform/linux-dpdk/pool/dpdk.c
index 90d2d7c61..e0035756f 100644
--- a/platform/linux-dpdk/pool/dpdk.c
+++ b/platform/linux-dpdk/pool/dpdk.c
@@ -137,12 +137,12 @@ static int dpdk_pool_capability(odp_pool_capability_t 
*capa)
capa->buf.max_pools = ODP_CONFIG_POOLS;
capa->buf.max_align = ODP_CONFIG_BUFFER_ALIGN_MAX;
capa->buf.max_size  = MAX_SIZE;
-   capa->buf.max_num   = CONFIG_POOL_MAX_NUM;
+   capa->buf.max_num   = 0;
 
/* Packet pools */
capa->pkt.max_pools= ODP_CONFIG_POOLS;
capa->pkt.max_len  = 0;
-   capa->pkt.max_num  = CONFIG_POOL_MAX_NUM;
+   capa->pkt.max_num  = 0;
capa->pkt.min_headroom = CONFIG_PACKET_HEADROOM;
capa->pkt.min_tailroom = CONFIG_PACKET_TAILROOM;
capa->pkt.max_segs_per_pkt = CONFIG_PACKET_MAX_SEGS;
@@ -152,7 +152,7 @@ static int dpdk_pool_capability(odp_pool_capability_t *capa)
 
/* Timeout pools */
capa->tmo.max_pools = ODP_CONFIG_POOLS;
-   capa->tmo.max_num   = CONFIG_POOL_MAX_NUM;
+   capa->tmo.max_num   = 0;
 
return 0;
 }
@@ -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) {
-   printf("buf.num too large %u\n", params->buf.num);
-   return -1;
-   }
-
if (params->buf.size > capa.buf.max_size) {
printf("buf.size too large %u\n", params->buf.size);
return -1;
@@ -297,10 +292,6 @@ static int check_params(odp_pool_param_t *params)
break;
 
case ODP_POOL_TIMEOUT:
-   if (params->tmo.num > capa.tmo.max_num) {
-   printf("tmo.num too large %u\n", params->tmo.num);
-   return -1;
-   }
break;
 
default:



[lng-odp] [PATCH 2.0 v1 1/2] linux-generic: pool: allocate ring memory based on pool size

2017-11-28 Thread Github ODP bot
From: Honnappa Nagarahalli 

Adjust the size of ring based on configured number of
buffers in the pool.

Signed-off-by: Honnappa Nagarahalli 
Reviewed-by: Ola Liljedahl 
---
/** Email created from pull request 312 (nagarahalli:2.0-pool-ring-alloc-mem)
 ** https://github.com/Linaro/odp/pull/312
 ** Patch: https://github.com/Linaro/odp/pull/312.patch
 ** Base sha: 7074b71b266de9c4eb5bf03513186a72ea27b2bc
 ** Merge commit sha: f6e1b802c13d4f93d96e8b309712f74109d1cfd3
 **/
 .../linux-generic/include/odp_config_internal.h|  5 ---
 platform/linux-generic/include/odp_pool_internal.h |  2 +-
 platform/linux-generic/pool/generic.c  | 37 ++
 3 files changed, 17 insertions(+), 27 deletions(-)

diff --git a/platform/linux-generic/include/odp_config_internal.h 
b/platform/linux-generic/include/odp_config_internal.h
index 9b334df49..9720581a3 100644
--- a/platform/linux-generic/include/odp_config_internal.h
+++ b/platform/linux-generic/include/odp_config_internal.h
@@ -147,11 +147,6 @@
  */
 #define CONFIG_BURST_SIZE 16
 
-/*
- * Maximum number of events in a pool
- */
-#define CONFIG_POOL_MAX_NUM (1 * 1024 * 1024)
-
 /*
  * Maximum number of events in a thread local pool cache
  */
diff --git a/platform/linux-generic/include/odp_pool_internal.h 
b/platform/linux-generic/include/odp_pool_internal.h
index 5004e283c..72e550ce2 100644
--- a/platform/linux-generic/include/odp_pool_internal.h
+++ b/platform/linux-generic/include/odp_pool_internal.h
@@ -41,7 +41,7 @@ typedef struct {
ring_t   hdr;
 
/* Ring data: buffer handles */
-   uint32_t buf[CONFIG_POOL_MAX_NUM];
+   uint32_t buf[];
 
 } pool_ring_t ODP_ALIGNED_CACHE;
 
diff --git a/platform/linux-generic/pool/generic.c 
b/platform/linux-generic/pool/generic.c
index c55f67575..025b4b5aa 100644
--- a/platform/linux-generic/pool/generic.c
+++ b/platform/linux-generic/pool/generic.c
@@ -156,11 +156,12 @@ static int generic_pool_term_local(void)
return 0;
 }
 
-static pool_t *reserve_pool(void)
+static pool_t *reserve_pool(uint32_t ring_size)
 {
int i;
pool_t *pool;
char ring_name[ODP_POOL_NAME_LEN];
+   uint32_t ring_shm_size;
 
for (i = 0; i < ODP_CONFIG_POOLS; i++) {
pool = pool_entry(i);
@@ -169,10 +170,13 @@ static pool_t *reserve_pool(void)
if (pool->reserved == 0) {
pool->reserved = 1;
UNLOCK(>lock);
-   sprintf(ring_name, "pool_ring_%d", i);
+   snprintf(ring_name, ODP_POOL_NAME_LEN,
+   "pool_ring_%d", i);
+   ring_shm_size = sizeof(pool_ring_t) +
+   sizeof(pool->ring->buf[0]) * ring_size;
pool->ring_shm =
odp_shm_reserve(ring_name,
-   sizeof(pool_ring_t),
+   ring_shm_size,
ODP_CACHE_LINE_SIZE, 0);
if (odp_unlikely(pool->ring_shm == ODP_SHM_INVALID)) {
ODP_ERR("Unable to alloc pool ring %d\n", i);
@@ -395,7 +399,12 @@ static odp_pool_t pool_create(const char *name, 
odp_pool_param_t *params,
if (uarea_size)
uarea_size = ROUNDUP_CACHE_LINE(uarea_size);
 
-   pool = reserve_pool();
+   if (num <= RING_SIZE_MIN)
+   ring_size = RING_SIZE_MIN;
+   else
+   ring_size = ROUNDUP_POWER2_U32(num);
+
+   pool = reserve_pool(ring_size);
 
if (pool == NULL) {
ODP_ERR("No more free pools");
@@ -431,11 +440,6 @@ static odp_pool_t pool_create(const char *name, 
odp_pool_param_t *params,
FIRST_HP_SIZE - 1) / FIRST_HP_SIZE);
}
 
-   if (num <= RING_SIZE_MIN)
-   ring_size = RING_SIZE_MIN;
-   else
-   ring_size = ROUNDUP_POWER2_U32(num);
-
pool->ring_mask  = ring_size - 1;
pool->num= num;
pool->align  = align;
@@ -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) {
-   printf("buf.num too large %u\n", params->buf.num);
-   return -1;
-   }
-
if (params->buf.size > capa.buf.max_size) {
printf("buf.size too large %u\n", params->buf.size);
return -1;
@@ -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) {
-   printf("tmo.num too large %u\n", 

[lng-odp] [PATCH 2.0 v1 0/2] allocate ring memory based on pool size

2017-11-28 Thread Github ODP bot
The maximum size of the pool ring is 1M entries as it uses an array. However, 
the application provides the number of buffers in a pool during pool creation. 
Hence, the maximum pool ring size can be dynamic.

github
/** Email created from pull request 312 (nagarahalli:2.0-pool-ring-alloc-mem)
 ** https://github.com/Linaro/odp/pull/312
 ** Patch: https://github.com/Linaro/odp/pull/312.patch
 ** Base sha: 7074b71b266de9c4eb5bf03513186a72ea27b2bc
 ** Merge commit sha: f6e1b802c13d4f93d96e8b309712f74109d1cfd3
 **/
/github

checkpatch.pl
CHECK: Alignment should match open parenthesis
#78: FILE: platform/linux-generic/pool/generic.c:174:
+   snprintf(ring_name, ODP_POOL_NAME_LEN,
+   "pool_ring_%d", i);

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


to_send-p-000.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, 54 lines checked


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


Re: [lng-odp] IPsec: handling dummy packets (NH=59)

2017-11-28 Thread Bill Fischofer
On Tue, Nov 28, 2017 at 9:28 AM, Dmitry Eremin-Solenikov <
dmitry.ereminsoleni...@linaro.org> wrote:

> Hello,
>
> On 20/11/17 18:23, Bill Fischofer wrote:
> > Traffic Flow Confidentiality (TFC) is a feature of SAs according to RFC
> > 4303 that must be negotiated on a per-SA basis before it is used. So
> > This would need to be hooked into higher-level protocols.
> >
> > From an ODP perspective, it would be an additional set of parameters on
> > the odp_ipsec_sa_create() API. Not clear this is something we should
> > worry about for Tiger Moth, but something to consider as an addition in
> > the future.
>
> In fact I think that control can go to application level. I was thinking
> about allowing application to specify if outgoing packet is dummy or
> not. In fact I'm going to propose the possibility to specify if outgoing
> packet is IPv4, IPv6 or dummy.
>

Whether the outbound packets are IPv4 or IPv6 is controlled by the tunnel
mode configuration. For transport mode the input packet already has the
L3/L4 headers it needs.

TFC enablement should be another odp_ipsec_sa_param_t option. Dummy packets
for output can be another odp_ipsec_out_opt_t bit setting. For RX, I think
we'd want to report dummy packet receipt as another odp_ipsec_warn_t bit.
I'm very reluctant to have ODP discard anything as that means that the
application can never see it and we'd have to maintain stats for these
discards anyway. Applications using IPsec should understand these packets
since they have to negotiate them anyway and should take whatever action
they wish with them. ODP should not limit application freedom of action in
this regard by making these decisions itself.


>
> >
> > On Mon, Nov 20, 2017 at 8:37 AM, Dmitry Eremin-Solenikov
> >  > > wrote:
> >
> > Hello,
> >
> > I was thinking about another minor part of IPsec RFCs: dummy packets
> > used to mask traffic statistics. IPsec implementation is required to
> > drop ESP packets with NH = 59 (no next header) on receiver side and
> is
> > expected to be able to generate these packets on transmitter side.
> > Currently we do not provide a way to inject these packets in any way.
> >
> > Possible solutions:
> >
> > TX side:
> >  - Add API call to transmit single packet.
> >
> >  - Extend transmit parameters to specify next header (IPv4, IPv6 or
> > NoNH) for each packet to be transmitted (per-packet or per-odp call).
> >
> >  - ???
> >
> > RX side:
> >  - Silently drop NoNH packets
> >
> >  - Report NoNH packets to app via error or status event mechanism.
> >
> >  - ???
> >
> > --
> > With best wishes
> > Dmitry
> >
> >
>
>
> --
> With best wishes
> Dmitry
>


Re: [lng-odp] [PATCH v4] one more try to add nice stats for Shippable

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

test/common/odp_cunit_common.c
line 17
@@ -7,13 +8,15 @@
 #include "config.h"
 
 #include 
+#include 
 #include 
 #include "odp_cunit_common.h"
 #include 
 /* Globals */
 static odph_odpthread_t thread_tbl[MAX_WORKERS];
 static odp_instance_t instance;
 
+extern const char *__progname;


Comment:
@muvarov yes

> muvarov wrote
> yep, thanks it's copy paste text


>> muvarov wrote
>> save argv[0] in some global variable?


>>> Dmitry Eremin-Solenikov(lumag) wrote:
>>> This looks like an overkill. I'd suggest to use Autoconf variable rather 
>>> than Automake conditional here.


 Dmitry Eremin-Solenikov(lumag) wrote:
 This is just incorrect


> Dmitry Eremin-Solenikov(lumag) wrote:
> This should be refactored to a function which is selected basing on 
> `TEST_CUNIT_XML`, rather than having `#ifdef` directly in the function 
> body.


>> Dmitry Eremin-Solenikov(lumag) wrote:
>> Please use a copy of `argv[0]` instead of progname.


https://github.com/Linaro/odp/pull/309#discussion_r153518159
updated_at 2017-11-28 15:04:21


[lng-odp] [PATCH API-NEXT v2 1/2] api: ipsec: add capabilities for fragmentation support

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

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 
---
/** Email created from pull request 311 (lumag:ipsec-caps)
 ** https://github.com/Linaro/odp/pull/311
 ** Patch: https://github.com/Linaro/odp/pull/311.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 63ff9ce47f9c9abab3f9e75acfffb4737cfca756
 **/
 include/odp/api/spec/ipsec.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h
index 4a33af8ea..0be9664eb 100644
--- a/include/odp/api/spec/ipsec.h
+++ b/include/odp/api/spec/ipsec.h
@@ -260,6 +260,12 @@ typedef struct odp_ipsec_capability_t {
/** IP Authenticated Header (ODP_IPSEC_AH) support */
odp_support_t proto_ah;
 
+   /** Fragment after IPsec support */
+   odp_support_t frag_after;
+
+   /** Fragment before IPsec support */
+   odp_support_t frag_before;
+
/**
 * Support of pipelined classification (ODP_IPSEC_PIPELINE_CLS) of
 *  resulting inbound packets



[lng-odp] [PATCH API-NEXT v2 2/2] api, linux-gen: ipsec: constify in/out params

2017-11-28 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 311 (lumag:ipsec-caps)
 ** https://github.com/Linaro/odp/pull/311
 ** Patch: https://github.com/Linaro/odp/pull/311.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 63ff9ce47f9c9abab3f9e75acfffb4737cfca756
 **/
 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 0be9664eb..d57815ed2 100644
--- a/include/odp/api/spec/ipsec.h
+++ b/include/odp/api/spec/ipsec.h
@@ -1027,13 +1027,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;
 
@@ -1061,7 +1061,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 b17e4cd7b..18ae8ece4 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -582,7 +582,7 @@ uint32_t ipsec_seq_no(ipsec_sa_t *ipsec_sa)
 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_sa_t *ipsec_sa = NULL;
@@ -998,7 +998,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,
 };
 
@@ -1022,7 +1022,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));
 
@@ -1130,7 +1130,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));
@@ -1222,7 +1222,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 v2 0/2] IPsec API update

2017-11-28 Thread Github ODP bot


github
/** Email created from pull request 311 (lumag:ipsec-caps)
 ** https://github.com/Linaro/odp/pull/311
 ** Patch: https://github.com/Linaro/odp/pull/311.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 63ff9ce47f9c9abab3f9e75acfffb4737cfca756
 **/
/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, 63 lines checked


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


Re: [lng-odp] IPsec: handling dummy packets (NH=59)

2017-11-28 Thread Dmitry Eremin-Solenikov
Hello,

On 20/11/17 18:23, Bill Fischofer wrote:
> Traffic Flow Confidentiality (TFC) is a feature of SAs according to RFC
> 4303 that must be negotiated on a per-SA basis before it is used. So
> This would need to be hooked into higher-level protocols.
> 
> From an ODP perspective, it would be an additional set of parameters on
> the odp_ipsec_sa_create() API. Not clear this is something we should
> worry about for Tiger Moth, but something to consider as an addition in
> the future.

In fact I think that control can go to application level. I was thinking
about allowing application to specify if outgoing packet is dummy or
not. In fact I'm going to propose the possibility to specify if outgoing
packet is IPv4, IPv6 or dummy.

> 
> On Mon, Nov 20, 2017 at 8:37 AM, Dmitry Eremin-Solenikov
>  > wrote:
> 
> Hello,
> 
> I was thinking about another minor part of IPsec RFCs: dummy packets
> used to mask traffic statistics. IPsec implementation is required to
> drop ESP packets with NH = 59 (no next header) on receiver side and is
> expected to be able to generate these packets on transmitter side.
> Currently we do not provide a way to inject these packets in any way.
> 
> Possible solutions:
> 
> TX side:
>  - Add API call to transmit single packet.
> 
>  - Extend transmit parameters to specify next header (IPv4, IPv6 or
> NoNH) for each packet to be transmitted (per-packet or per-odp call).
> 
>  - ???
> 
> RX side:
>  - Silently drop NoNH packets
> 
>  - Report NoNH packets to app via error or status event mechanism.
> 
>  - ???
> 
> --
> With best wishes
> Dmitry
> 
> 


-- 
With best wishes
Dmitry


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

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 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 v6 14/15] linux-gen: ipsec: support ODP_IPSEC_FRAG_CHECK

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 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 v6 12/15] linux-gen: ipsec: store mtu and frag_mode in SA

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 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 v6 11/15] validation: add UDP-encapsulated IPsec test cases

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 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 v6 6/15] linux-gen: ipsec: implement IPv6 protocol support

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 .../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 v6 9/15] linux-gen: add support for UDP-encapsulated ESP packets

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 .../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 v6 10/15] linux-gen: packet: add flag for UDP-encapsulated IPsec packets

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 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 v6 7/15] validation: ipsec: add tests for IPv6 functionality

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 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 v6 8/15] linux-gen: ipsec: simplify seq no handling

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 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 v6 5/15] linux-gen: protocols: ip: add more ipv6 defines

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 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 v6 3/15] validation: ipsec: fix next_header field in mcgrew gcm test vectors

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 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 v6 2/15] linux-gen: modularize IPsec implementation

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 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 v6 4/15] linux-gen: don't include odp_ipsec_internal.h in odp_packet_internal.h

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 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 v6 1/15] validation: ipsec: add ipv4 name parts

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
 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 v1 3/3] api, linux-gen: ipsec: constify in/out params

2017-11-28 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 311 (lumag:ipsec-caps)
 ** https://github.com/Linaro/odp/pull/311
 ** Patch: https://github.com/Linaro/odp/pull/311.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: aa57ba9cce8dd6a7ae0d02117c362aa07d0985a4
 **/
 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 697278f90..daa5d92ce 100644
--- a/include/odp/api/spec/ipsec.h
+++ b/include/odp/api/spec/ipsec.h
@@ -1030,13 +1030,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;
 
@@ -1064,7 +1064,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 b17e4cd7b..18ae8ece4 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -582,7 +582,7 @@ uint32_t ipsec_seq_no(ipsec_sa_t *ipsec_sa)
 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_sa_t *ipsec_sa = NULL;
@@ -998,7 +998,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,
 };
 
@@ -1022,7 +1022,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));
 
@@ -1130,7 +1130,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));
@@ -1222,7 +1222,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 v6 0/15] IPsec IPv6 implementation

2017-11-28 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: 58c25c5ed099e25c8738c9220274c3bcf3fb66d2
 **/
/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, 155 lines checked


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


[lng-odp] [PATCH API-NEXT v1 1/3] api: ipsec: add capability for ESN support

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

ESN support is marked as SHOULD by RFC 4302/4303, so add capability for
ESN support.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 311 (lumag:ipsec-caps)
 ** https://github.com/Linaro/odp/pull/311
 ** Patch: https://github.com/Linaro/odp/pull/311.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: aa57ba9cce8dd6a7ae0d02117c362aa07d0985a4
 **/
 include/odp/api/spec/ipsec.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h
index 4a33af8ea..c1307194e 100644
--- a/include/odp/api/spec/ipsec.h
+++ b/include/odp/api/spec/ipsec.h
@@ -260,6 +260,9 @@ typedef struct odp_ipsec_capability_t {
/** IP Authenticated Header (ODP_IPSEC_AH) support */
odp_support_t proto_ah;
 
+   /** Extended Sequence Numbers support */
+   odp_support_t esn;
+
/**
 * Support of pipelined classification (ODP_IPSEC_PIPELINE_CLS) of
 *  resulting inbound packets



[lng-odp] [PATCH API-NEXT v1 2/3] api: ipsec: add capabilities for fragmentation support

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

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 
---
/** Email created from pull request 311 (lumag:ipsec-caps)
 ** https://github.com/Linaro/odp/pull/311
 ** Patch: https://github.com/Linaro/odp/pull/311.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: aa57ba9cce8dd6a7ae0d02117c362aa07d0985a4
 **/
 include/odp/api/spec/ipsec.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h
index c1307194e..697278f90 100644
--- a/include/odp/api/spec/ipsec.h
+++ b/include/odp/api/spec/ipsec.h
@@ -263,6 +263,12 @@ typedef struct odp_ipsec_capability_t {
/** Extended Sequence Numbers support */
odp_support_t esn;
 
+   /** Fragment after IPsec support */
+   odp_support_t frag_after;
+
+   /** Fragment before IPsec support */
+   odp_support_t frag_before;
+
/**
 * Support of pipelined classification (ODP_IPSEC_PIPELINE_CLS) of
 *  resulting inbound packets



[lng-odp] [PATCH API-NEXT v1 0/3] IPsec API update

2017-11-28 Thread Github ODP bot


github
/** Email created from pull request 311 (lumag:ipsec-caps)
 ** https://github.com/Linaro/odp/pull/311
 ** Patch: https://github.com/Linaro/odp/pull/311.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: aa57ba9cce8dd6a7ae0d02117c362aa07d0985a4
 **/
/github

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


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


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


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


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

2017-11-28 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: 38498451ec522810c4433d56c78af6c4be05a7c7
 **/
 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 v5 6/11] linux-gen: ipsec: implement IPv6 protocol support

2017-11-28 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: 38498451ec522810c4433d56c78af6c4be05a7c7
 **/
 .../linux-generic/include/odp_ipsec_internal.h |  44 +-
 platform/linux-generic/odp_ipsec.c | 462 -
 platform/linux-generic/odp_ipsec_sad.c |  67 ++-
 3 files changed, 437 insertions(+), 136 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 9f066badc..df7ac5c72 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 v5 11/11] validation: add UDP-encapsulated IPsec test cases

2017-11-28 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: 38498451ec522810c4433d56c78af6c4be05a7c7
 **/
 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 v5 9/11] linux-gen: add support for UDP-encapsulated ESP packets

2017-11-28 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: 38498451ec522810c4433d56c78af6c4be05a7c7
 **/
 .../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 b01325f50..0dffd98cf 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);
@@ -961,6 +993,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;
@@ -1000,6 +1033,16 @@ static int ipsec_out_esp(odp_packet_t *pkt,
esptrl.pad_len = encrypt_len - 

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

2017-11-28 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: 38498451ec522810c4433d56c78af6c4be05a7c7
 **/
 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 0dffd98cf..31b5e687e 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 v5 8/11] linux-gen: ipsec: simplify seq no handling

2017-11-28 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: 38498451ec522810c4433d56c78af6c4be05a7c7
 **/
 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 df7ac5c72..b01325f50 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;
 
@@ -990,10 +991,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;
@@ -,11 +1112,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)
return -1;



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

2017-11-28 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: 38498451ec522810c4433d56c78af6c4be05a7c7
 **/
 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 v5 2/11] linux-gen: modularize IPsec implementation

2017-11-28 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: 38498451ec522810c4433d56c78af6c4be05a7c7
 **/
 platform/linux-generic/odp_ipsec.c | 1083 
 1 file changed, 589 insertions(+), 494 deletions(-)

diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index b17e4cd7b..9f066badc 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 v5 1/11] validation: ipsec: add ipv4 name parts

2017-11-28 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: 38498451ec522810c4433d56c78af6c4be05a7c7
 **/
 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 v5 3/11] validation: ipsec: fix next_header field in mcgrew gcm test vectors

2017-11-28 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: 38498451ec522810c4433d56c78af6c4be05a7c7
 **/
 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 v5 4/11] linux-gen: don't include odp_ipsec_internal.h in odp_packet_internal.h

2017-11-28 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: 38498451ec522810c4433d56c78af6c4be05a7c7
 **/
 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 v5 0/11] IPsec IPv6 implementation

2017-11-28 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: 38498451ec522810c4433d56c78af6c4be05a7c7
 **/
/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, 1244 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, 864 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.
/checkpatch.pl


Re: [lng-odp] Preparing for ODP 2.0

2017-11-28 Thread Maxim Uvarov
If patch is suitable for master or api-next (like cache line optimizations)
it has to go to master/api-next first. As well as all bug fixes for master
branch should go directly to master.
Only than patch can be taken to development branch.

Maxim.


On 28 November 2017 at 12:43, Dmitry Eremin-Solenikov <
dmitry.ereminsoleni...@linaro.org> wrote:

> On 28/11/17 00:57, Bill Fischofer wrote:
> > As a way of easing the sync burden on the 2.0 development branch, what do
> > folks think of the idea of asking that new PRs being posted to api-next
> > also be posted to 2.0? The contributions to api-next should be winding
> down
> > as we approach Tiger Moth freeze, so this will help keep things in sync
> as
> > we transition back into a single development target post-Tiger Moth.
> >
> > Please share your views on this.
>
> No, current '2.0' should be refactored as a set of PRs against
> master/api-next. When its development was started, it was promised that
> 2.0 will be reviewed before merging to master/api-next.
>
>
> --
> With best wishes
> Dmitry
>


[lng-odp] dpdk 17.08 backward compatibility issues with odp crypto

2017-11-28 Thread Krishna Garapati
Hi,

I am working on moving odp-dpdk from dpdk 17.02 to 17.08. But due to
updates in dpdk crypto which are not backward compatible, makes it
difficult to implement changes in odp-dpdk. One major update is moving
"AES_GCM & AES_CCM" algorithms to a separate enum called
"rte_crypto_aead_algorithm". This means dpdk now has three enums  auth,
cipher & aead. They each have separate crypto_xforms in terms of getting
capability params & their validation. From ODP crypto api perspective,
AES_GCM & AES_CCM are still part of both cipher_alogos & auth_algos.
Complexity arises when application asks for,

- capability for cipher & auth, implementation first needs to convert
cipher_algos to rte_cipher_algo or rte_aead_algo and set the cipher_xform
or aead_xform before asking dpdk for capability and map those capabilities
to odp_crypto_cipher_capability_t array. Same goes with Auth_algo. This
makes the implementation logic be unreadable.

- In 17.08 dpdk also supports cipher only, auth only. So when mixing this
feature with algos conversion also introduces complexity.

- getting the device based on cipher, auth, aead algos. In 17.08 dpdk
facilitates api's for respective crypto_xform for capability verification.
Currently when application wants to create a session, implementations
fetches the device that suits to the params sent in odp_session_params. So
when try to cross verify the params with corresponding crypto algo,
Implementation again does the conversion and set the right transform and
probe the corresponding crypto api.

I am starting this thread to see if it would be feasible to change the
crypto api in order to make the odp & implementation be more compatible
with dpdk and make use of all the new api's that were introduced in the
newer dpdk versions.

/Krishna


[lng-odp] [Bug 3491] l2fwd segfaults on api-next with dpdk checksum insertion override

2017-11-28 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=3491

--- Comment #1 from Maxim Uvarov  ---
https://github.com/Linaro/odp/commit/4cb02e1caccb9179575e95448fd46979e17d0905
refs/heads/api-next
2017-11-28T13:27:30+03:00
Petri Savolainen petri.savolai...@linaro.org
linux-gen: dpdk: check L3 offset validity

Application is required to set L3 offset when it requests
checksum offload. It caused segfault to assume that L3
offset is always set. Minimize the number of if-clauses
in non-checksum path by first checking L3 offset.

This fixes https://bugs.linaro.org/show_bug.cgi?id=3491

Signed-off-by: Petri Savolainen 
Reviewed-by: Bogdan Pricope 
Reviewed-by: Bill Fischofer 
Signed-off-by: Maxim Uvarov 

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

[lng-odp] [Linaro/odp] 4cb02e: linux-gen: dpdk: check L3 offset validity

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

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

  Log Message:
  ---
  linux-gen: dpdk: check L3 offset validity

Application is required to set L3 offset when it requests
checksum offload. It caused segfault to assume that L3
offset is always set. Minimize the number of if-clauses
in non-checksum path by first checking L3 offset.

This fixes https://bugs.linaro.org/show_bug.cgi?id=3491

Signed-off-by: Petri Savolainen 
Reviewed-by: Bogdan Pricope 
Reviewed-by: Bill Fischofer 
Signed-off-by: Maxim Uvarov 




Re: [lng-odp] Preparing for ODP 2.0

2017-11-28 Thread Dmitry Eremin-Solenikov
On 28/11/17 00:57, Bill Fischofer wrote:
> As a way of easing the sync burden on the 2.0 development branch, what do
> folks think of the idea of asking that new PRs being posted to api-next
> also be posted to 2.0? The contributions to api-next should be winding down
> as we approach Tiger Moth freeze, so this will help keep things in sync as
> we transition back into a single development target post-Tiger Moth.
> 
> Please share your views on this.

No, current '2.0' should be refactored as a set of PRs against
master/api-next. When its development was started, it was promised that
2.0 will be reviewed before merging to master/api-next.


-- 
With best wishes
Dmitry