[lng-odp] [Linaro/odp] 0242ec: linux-dpdk: introduce pool modular framework

2017-08-24 Thread GitHub
  Branch: refs/heads/cloud-dev
  Home:   https://github.com/Linaro/odp
  Commit: 0242ecfa64a663b7584054edcf02a8f9913391d6
  
https://github.com/Linaro/odp/commit/0242ecfa64a663b7584054edcf02a8f9913391d6
  Author: Balakrishna Garapati 
  Date:   2017-08-25 (Fri, 25 Aug 2017)

  Changed paths:
M platform/linux-dpdk/Makefile.am
M platform/linux-dpdk/include/odp_pool_internal.h
M platform/linux-dpdk/odp_buffer.c
R platform/linux-dpdk/odp_pool.c
A platform/linux-dpdk/pool/dpdk.c

  Log Message:
  ---
  linux-dpdk: introduce pool modular framework

Signed-off-by: Balakrishna Garapati 
Reviewed-by: Brian Brooks 
Reviewed-by: Yi He 




[lng-odp] [Linaro/odp]

2017-08-24 Thread GitHub
  Branch: refs/tags/v1.11.0.1_monarch
  Home:   https://github.com/Linaro/odp


[lng-odp] [Linaro/odp] 0e9e56: configure.ac: inc library version

2017-08-24 Thread GitHub
  Branch: refs/heads/monarch_lts
  Home:   https://github.com/Linaro/odp
  Commit: 0e9e5654cf04c6f92a3539fec06f6cf51a86168d
  
https://github.com/Linaro/odp/commit/0e9e5654cf04c6f92a3539fec06f6cf51a86168d
  Author: Maxim Uvarov 
  Date:   2017-08-24 (Thu, 24 Aug 2017)

  Changed paths:
M configure.ac

  Log Message:
  ---
  configure.ac: inc library version

only source code was changed to inc only middle number.

Signed-off-by: Maxim Uvarov 
Reviewed-by: Bill Fischofer 




[lng-odp] [Bug 3209] parse_ipv4 incorrectly sets ip_bcast flag

2017-08-24 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=3209

Bill Fischofer  changed:

   What|Removed |Added

 CC||bill.fischo...@linaro.org

--- Comment #1 from Bill Fischofer  ---
This is by design. The simple parser in linux-generic is context-free and has
no access to netmask info.

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

[lng-odp] [PATCH API-NEXT v12 5/8] test: validation: add IPsec API testsuite

2017-08-24 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Add several basic tests for IPsec API.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 81 (lumag:ipsec-packet-impl-2)
 ** https://github.com/Linaro/odp/pull/81
 ** Patch: https://github.com/Linaro/odp/pull/81.patch
 ** Base sha: 859293ad9b3c862264bb0fbfe8e7037b5e04d084
 ** Merge commit sha: 3c4b4ab58168f2d1ffc93503027bbb5a5d2847d8
 **/
 test/common_plat/validation/api/ipsec/Makefile.am  |  27 +-
 test/common_plat/validation/api/ipsec/ipsec.c  | 868 +-
 test/common_plat/validation/api/ipsec/ipsec.h  |  82 +-
 .../common_plat/validation/api/ipsec/ipsec_async.c |  53 ++
 .../validation/api/ipsec/ipsec_inline_in.c |  54 ++
 .../validation/api/ipsec/ipsec_inline_out.c|  54 ++
 test/common_plat/validation/api/ipsec/ipsec_main.c |  12 -
 test/common_plat/validation/api/ipsec/ipsec_sync.c |  51 ++
 .../validation/api/ipsec/ipsec_sync_in.c   |  25 +
 .../validation/api/ipsec/ipsec_test_in.c   | 813 +
 .../validation/api/ipsec/ipsec_test_out.c  | 346 
 .../validation/api/ipsec/test_vectors.h| 965 +
 test/linux-generic/Makefile.am |   5 +-
 13 files changed, 3311 insertions(+), 44 deletions(-)
 create mode 100644 test/common_plat/validation/api/ipsec/ipsec_async.c
 create mode 100644 test/common_plat/validation/api/ipsec/ipsec_inline_in.c
 create mode 100644 test/common_plat/validation/api/ipsec/ipsec_inline_out.c
 delete mode 100644 test/common_plat/validation/api/ipsec/ipsec_main.c
 create mode 100644 test/common_plat/validation/api/ipsec/ipsec_sync.c
 create mode 100644 test/common_plat/validation/api/ipsec/ipsec_sync_in.c
 create mode 100644 test/common_plat/validation/api/ipsec/ipsec_test_in.c
 create mode 100644 test/common_plat/validation/api/ipsec/ipsec_test_out.c
 create mode 100644 test/common_plat/validation/api/ipsec/test_vectors.h

diff --git a/test/common_plat/validation/api/ipsec/Makefile.am 
b/test/common_plat/validation/api/ipsec/Makefile.am
index 106b8dce..5a4652f5 100644
--- a/test/common_plat/validation/api/ipsec/Makefile.am
+++ b/test/common_plat/validation/api/ipsec/Makefile.am
@@ -1,10 +1,27 @@
 include ../Makefile.inc
 
+AM_CPPFLAGS += -Wno-error=missing-field-initializers
+
 noinst_LTLIBRARIES = libtestipsec.la
-libtestipsec_la_SOURCES = ipsec.c
+libtestipsec_la_SOURCES = \
+   test_vectors.h \
+   ipsec_test_in.c \
+   ipsec_test_out.c \
+   ipsec.h \
+   ipsec.c
+
+test_PROGRAMS = \
+   ipsec_sync$(EXEEXT) \
+   ipsec_async$(EXEEXT) \
+   ipsec_inline_in$(EXEEXT) \
+   ipsec_inline_out$(EXEEXT)
 
-test_PROGRAMS = ipsec_main$(EXEEXT)
-dist_ipsec_main_SOURCES = ipsec_main.c
-ipsec_main_LDADD = libtestipsec.la $(LIBCUNIT_COMMON) $(LIBODP)
+ipsec_sync_SOURCES = ipsec_sync.c
+ipsec_async_SOURCES = ipsec_async.c
+ipsec_inline_in_SOURCES = ipsec_inline_in.c
+ipsec_inline_out_SOURCES = ipsec_inline_out.c
 
-EXTRA_DIST = ipsec.h
+ipsec_sync_LDADD = libtestipsec.la $(LIBCUNIT_COMMON) $(LIBODP)
+ipsec_async_LDADD = libtestipsec.la $(LIBCUNIT_COMMON) $(LIBODP)
+ipsec_inline_in_LDADD = libtestipsec.la $(LIBCUNIT_COMMON) $(LIBODP)
+ipsec_inline_out_LDADD = libtestipsec.la $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/common_plat/validation/api/ipsec/ipsec.c 
b/test/common_plat/validation/api/ipsec/ipsec.c
index 78348032..3d6bdeb4 100644
--- a/test/common_plat/validation/api/ipsec/ipsec.c
+++ b/test/common_plat/validation/api/ipsec/ipsec.c
@@ -10,35 +10,867 @@
 
 #include "ipsec.h"
 
-void ipsec_test_capability(void)
+#include "test_vectors.h"
+
+struct suite_context_s suite_context;
+
+#define PKT_POOL_NUM  64
+#define PKT_POOL_LEN  (1 * 1024)
+
+static odp_pktio_t pktio_create(odp_pool_t pool)
+{
+   odp_pktio_t pktio;
+   odp_pktio_param_t pktio_param;
+   odp_pktin_queue_param_t pktin_param;
+   odp_pktio_capability_t capa;
+
+   int ret;
+
+   if (pool == ODP_POOL_INVALID)
+   return ODP_PKTIO_INVALID;
+
+   odp_pktio_param_init(_param);
+   pktio_param.in_mode = ODP_PKTIN_MODE_QUEUE;
+
+   pktio = odp_pktio_open("loop", pool, _param);
+   if (pktio == ODP_PKTIO_INVALID) {
+   ret = odp_pool_destroy(pool);
+   if (ret)
+   fprintf(stderr, "unable to destroy pool.\n");
+   return ODP_PKTIO_INVALID;
+   }
+
+   if (odp_pktio_capability(pktio, )) {
+   fprintf(stderr, "pktio capabilities failed.\n");
+   return ODP_PKTIO_INVALID;
+   }
+
+   odp_pktin_queue_param_init(_param);
+   pktin_param.queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC;
+
+   if (odp_pktin_queue_config(pktio, _param)) {
+   fprintf(stderr, "pktin queue config failed.\n");
+   return ODP_PKTIO_INVALID;
+   }
+
+   if 

[lng-odp] [PATCH API-NEXT v12 8/8] linux-generic: ipsec: draft IPsec implementation

2017-08-24 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

For now it's only a preview with the following limitation:
 - Only IPv4 support
 - No pipeline_cls and outer header retaining support
 - No zeroing of mutable IPv4 options for AH ICV calculation
 - No replay protection
 - No ESN support
 - No UDP encapsulation support

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 81 (lumag:ipsec-packet-impl-2)
 ** https://github.com/Linaro/odp/pull/81
 ** Patch: https://github.com/Linaro/odp/pull/81.patch
 ** Base sha: 859293ad9b3c862264bb0fbfe8e7037b5e04d084
 ** Merge commit sha: 3c4b4ab58168f2d1ffc93503027bbb5a5d2847d8
 **/
 .../linux-generic/include/odp_ipsec_internal.h |7 +
 .../linux-generic/include/odp_packet_internal.h|4 +
 platform/linux-generic/odp_ipsec.c | 1176 +++-
 3 files changed, 1138 insertions(+), 49 deletions(-)

diff --git a/platform/linux-generic/include/odp_ipsec_internal.h 
b/platform/linux-generic/include/odp_ipsec_internal.h
index 64ef8ab7..74085c95 100644
--- a/platform/linux-generic/include/odp_ipsec_internal.h
+++ b/platform/linux-generic/include/odp_ipsec_internal.h
@@ -183,6 +183,13 @@ int _odp_ipsec_sa_update_stats(ipsec_sa_t *ipsec_sa, 
uint32_t len,
   odp_ipsec_op_status_t *status);
 
 /**
+ * Try inline IPsec processing of provided packet.
+ *
+ * @retval 0 if packet was processed and sent using IPsec inline processing
+ */
+int _odp_ipsec_try_inline(odp_packet_t pkt);
+
+/**
  * @}
  */
 
diff --git a/platform/linux-generic/include/odp_packet_internal.h 
b/platform/linux-generic/include/odp_packet_internal.h
index 91fba1ea..ff677308 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -27,6 +27,7 @@ extern "C" {
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -159,6 +160,9 @@ typedef struct odp_packet_hdr_t {
uint8_t extra[PKT_EXTRA_LEN] ODP_ALIGNED_CACHE;
 #endif
 
+   /* Context for IPsec */
+   odp_ipsec_packet_result_t ipsec_ctx;
+
/* Packet data storage */
uint8_t data[0];
 } odp_packet_hdr_t;
diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index d0ca027c..92c1fa9c 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -6,125 +6,1203 @@
 
 #include 
 
+#include 
+#include 
 #include 
 
+#include 
+#include 
+
 #include 
 
+typedef struct ODP_PACKED {
+   odp_u32be_t spi; /**< Security Parameter Index */
+   odp_u32be_t seq_no;  /**< Sequence Number */
+} ipsec_aad_t;
+
 int odp_ipsec_capability(odp_ipsec_capability_t *capa)
 {
+   int rc;
+   odp_crypto_capability_t crypto_capa;
+   odp_queue_capability_t queue_capa;
+
memset(capa, 0, sizeof(odp_ipsec_capability_t));
 
+   capa->op_mode_sync = ODP_SUPPORT_PREFERRED;
+   capa->op_mode_async = ODP_SUPPORT_PREFERRED;
+   capa->op_mode_inline_in = ODP_SUPPORT_PREFERRED;
+   capa->op_mode_inline_out = ODP_SUPPORT_PREFERRED;
+
+   capa->proto_ah = ODP_SUPPORT_YES;
+
+   capa->max_num_sa = ODP_CONFIG_IPSEC_SAS;
+
+   rc = odp_crypto_capability(_capa);
+   if (rc < 0)
+   return rc;
+
+   capa->ciphers = crypto_capa.ciphers;
+   capa->auths = crypto_capa.auths;
+
+   rc = odp_queue_capability(_capa);
+   if (rc < 0)
+   return rc;
+
+   capa->max_queues = queue_capa.max_queues;
+
return 0;
 }
 
 int odp_ipsec_cipher_capability(odp_cipher_alg_t cipher,
odp_crypto_cipher_capability_t capa[], int num)
 {
-   (void)cipher;
-   (void)capa;
-   (void)num;
-
-   return -1;
+   return odp_crypto_cipher_capability(cipher, capa, num);
 }
 
 int odp_ipsec_auth_capability(odp_auth_alg_t auth,
  odp_crypto_auth_capability_t capa[], int num)
 {
-   (void)auth;
-   (void)capa;
-   (void)num;
-
-   return -1;
+   return odp_crypto_auth_capability(auth, capa, num);
 }
 
 void odp_ipsec_config_init(odp_ipsec_config_t *config)
 {
memset(config, 0, sizeof(odp_ipsec_config_t));
+   config->inbound_mode = ODP_IPSEC_OP_MODE_SYNC;
+   config->outbound_mode = ODP_IPSEC_OP_MODE_SYNC;
+   config->max_num_sa = ODP_CONFIG_IPSEC_SAS;
+   config->inbound.default_queue = ODP_QUEUE_INVALID;
+   config->inbound.lookup.min_spi = 0;
+   config->inbound.lookup.max_spi = UINT32_MAX;
 }
 
+static odp_ipsec_config_t ipsec_config;
+
 int odp_ipsec_config(const odp_ipsec_config_t *config)
 {
-   (void)config;
+   if (ODP_CONFIG_IPSEC_SAS > config->max_num_sa)
+   return -1;
+
+   ipsec_config = *config;
+
+   return 0;
+}
+
+static odp_ipsec_packet_result_t *ipsec_pkt_result(odp_packet_t packet)
+{
+   ODP_ASSERT(ODP_EVENT_PACKET_IPSEC ==
+

[lng-odp] [PATCH API-NEXT v12 7/8] linux-generic: ipsec: implement IPsec SAD

2017-08-24 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Implement SA database and SA handling.

- only IPv4 is supported for now

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 81 (lumag:ipsec-packet-impl-2)
 ** https://github.com/Linaro/odp/pull/81
 ** Patch: https://github.com/Linaro/odp/pull/81.patch
 ** Base sha: 859293ad9b3c862264bb0fbfe8e7037b5e04d084
 ** Merge commit sha: 3c4b4ab58168f2d1ffc93503027bbb5a5d2847d8
 **/
 platform/linux-generic/Makefile.am |   1 +
 platform/linux-generic/include/odp_internal.h  |   4 +
 .../linux-generic/include/odp_ipsec_internal.h | 109 +
 platform/linux-generic/odp_init.c  |  13 +
 platform/linux-generic/odp_ipsec.c |  46 --
 platform/linux-generic/odp_ipsec_sad.c | 500 +
 6 files changed, 627 insertions(+), 46 deletions(-)
 create mode 100644 platform/linux-generic/odp_ipsec_sad.c

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 1a3e1c6f..9060e4a6 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -250,6 +250,7 @@ __LIB__libodp_linux_la_SOURCES = \
   odp_impl.c \
   odp_ipsec.c \
   odp_ipsec_events.c \
+  odp_ipsec_sad.c \
   odp_name_table.c \
   odp_packet.c \
   odp_packet_flags.c \
diff --git a/platform/linux-generic/include/odp_internal.h 
b/platform/linux-generic/include/odp_internal.h
index f916631b..8725dec8 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -75,6 +75,7 @@ enum init_stage {
TRAFFIC_MNGR_INIT,
NAME_TABLE_INIT,
IPSEC_EVENTS_INIT,
+   IPSEC_SAD_INIT,
MODULES_INIT,
ALL_INIT  /* All init stages completed */
 };
@@ -134,6 +135,9 @@ int _odp_ishm_init_local(void);
 int _odp_ishm_term_global(void);
 int _odp_ishm_term_local(void);
 
+int _odp_ipsec_sad_init_global(void);
+int _odp_ipsec_sad_term_global(void);
+
 int _odp_ipsec_events_init_global(void);
 int _odp_ipsec_events_term_global(void);
 
diff --git a/platform/linux-generic/include/odp_ipsec_internal.h 
b/platform/linux-generic/include/odp_ipsec_internal.h
index b31f048f..64ef8ab7 100644
--- a/platform/linux-generic/include/odp_ipsec_internal.h
+++ b/platform/linux-generic/include/odp_ipsec_internal.h
@@ -20,7 +20,9 @@ extern "C" {
 #include 
 #include 
 
+#include 
 #include 
+#include 
 
 /** @ingroup odp_ipsec
  *  @{
@@ -31,6 +33,8 @@ typedef ODP_HANDLE_T(ipsec_status_t);
 #define ODP_IPSEC_STATUS_INVALID \
_odp_cast_scalar(ipsec_status_t, 0x)
 
+typedef struct ipsec_sa_s ipsec_sa_t;
+
 /**
  * @internal Get ipsec_status handle from event
  *
@@ -73,6 +77,111 @@ int _odp_ipsec_status_send(odp_queue_t queue,
   int result,
   odp_ipsec_warn_t warn);
 
+#define IPSEC_MAX_IV_LEN   32   /**< Maximum IV length in bytes */
+
+#define IPSEC_MAX_SALT_LEN 4/**< Maximum salt length in bytes */
+
+/**
+ * Maximum number of available SAs
+ */
+#define ODP_CONFIG_IPSEC_SAS   8
+
+struct ipsec_sa_s {
+   odp_atomic_u32_t state ODP_ALIGNED_CACHE;
+
+   uint32_tipsec_sa_idx;
+   odp_ipsec_sa_t  ipsec_sa_hdl;
+
+   odp_ipsec_protocol_t proto;
+   uint32_tspi;
+
+   odp_ipsec_mode_t mode;
+
+   /* Limits */
+   uint64_t soft_limit_bytes;
+   uint64_t soft_limit_packets;
+   uint64_t hard_limit_bytes;
+   uint64_t hard_limit_packets;
+
+   /* Statistics for soft/hard expiration */
+   odp_atomic_u64_t bytes;
+   odp_atomic_u64_t packets;
+
+   odp_crypto_session_t session;
+   void*context;
+   odp_queue_t queue;
+
+   uint32_ticv_len;
+   uint32_tesp_iv_len;
+   uint32_tesp_block_len;
+
+   uint8_t salt[IPSEC_MAX_SALT_LEN];
+   uint32_tsalt_length;
+
+   unsigneddec_ttl : 1;
+   unsignedcopy_dscp : 1;
+   unsignedcopy_df : 1;
+
+   union {
+   struct {
+   odp_ipsec_lookup_mode_t lookup_mode;
+   odp_u32be_t lookup_dst_ip;
+   } 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;
+
+   uint8_t tun_ttl;
+   uint8_t tun_dscp;
+   uint8_t tun_df;
+   } out;
+   };
+};
+
+/**
+ * IPSEC Security 

[lng-odp] [PATCH API-NEXT v12 6/8] linux-generic: ipsec: implement events handling

2017-08-24 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Add functions implementing IPsec events support.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 81 (lumag:ipsec-packet-impl-2)
 ** https://github.com/Linaro/odp/pull/81
 ** Patch: https://github.com/Linaro/odp/pull/81.patch
 ** Base sha: 859293ad9b3c862264bb0fbfe8e7037b5e04d084
 ** Merge commit sha: 3c4b4ab58168f2d1ffc93503027bbb5a5d2847d8
 **/
 platform/linux-generic/Makefile.am |   2 +
 platform/linux-generic/include/odp_internal.h  |   4 +
 .../linux-generic/include/odp_ipsec_internal.h |  84 +++
 platform/linux-generic/odp_event.c |   4 +
 platform/linux-generic/odp_init.c  |  13 ++
 platform/linux-generic/odp_ipsec.c |  10 +-
 platform/linux-generic/odp_ipsec_events.c  | 154 +
 7 files changed, 263 insertions(+), 8 deletions(-)
 create mode 100644 platform/linux-generic/include/odp_ipsec_internal.h
 create mode 100644 platform/linux-generic/odp_ipsec_events.c

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index cfccaa98..1a3e1c6f 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -175,6 +175,7 @@ noinst_HEADERS = \
  ${srcdir}/include/odp_errno_define.h \
  ${srcdir}/include/odp_forward_typedefs_internal.h \
  ${srcdir}/include/odp_internal.h \
+ ${srcdir}/include/odp_ipsec_internal.h \
  ${srcdir}/include/odp_llqueue.h \
  ${srcdir}/include/odp_name_table_internal.h \
  ${srcdir}/include/odp_packet_internal.h \
@@ -248,6 +249,7 @@ __LIB__libodp_linux_la_SOURCES = \
   odp_init.c \
   odp_impl.c \
   odp_ipsec.c \
+  odp_ipsec_events.c \
   odp_name_table.c \
   odp_packet.c \
   odp_packet_flags.c \
diff --git a/platform/linux-generic/include/odp_internal.h 
b/platform/linux-generic/include/odp_internal.h
index ab935ff8..f916631b 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -74,6 +74,7 @@ enum init_stage {
CLASSIFICATION_INIT,
TRAFFIC_MNGR_INIT,
NAME_TABLE_INIT,
+   IPSEC_EVENTS_INIT,
MODULES_INIT,
ALL_INIT  /* All init stages completed */
 };
@@ -133,6 +134,9 @@ int _odp_ishm_init_local(void);
 int _odp_ishm_term_global(void);
 int _odp_ishm_term_local(void);
 
+int _odp_ipsec_events_init_global(void);
+int _odp_ipsec_events_term_global(void);
+
 int _odp_modules_init_global(void);
 
 int cpuinfo_parser(FILE *file, system_info_t *sysinfo);
diff --git a/platform/linux-generic/include/odp_ipsec_internal.h 
b/platform/linux-generic/include/odp_ipsec_internal.h
new file mode 100644
index ..b31f048f
--- /dev/null
+++ b/platform/linux-generic/include/odp_ipsec_internal.h
@@ -0,0 +1,84 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP internal IPsec routines
+ */
+
+#ifndef ODP_IPSEC_INTERNAL_H_
+#define ODP_IPSEC_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+#include 
+
+#include 
+
+/** @ingroup odp_ipsec
+ *  @{
+ */
+
+typedef ODP_HANDLE_T(ipsec_status_t);
+
+#define ODP_IPSEC_STATUS_INVALID \
+   _odp_cast_scalar(ipsec_status_t, 0x)
+
+/**
+ * @internal Get ipsec_status handle from event
+ *
+ * Converts an ODP_EVENT_IPSEC_STATUS type event to an IPsec status event.
+ *
+ * @param ev   Event handle
+ *
+ * @return IPsec status handle
+ *
+ * @see odp_event_type()
+ */
+ipsec_status_t _odp_ipsec_status_from_event(odp_event_t ev);
+
+/**
+ * @internal Free IPsec status event
+ *
+ * Frees the ipsec_status into the ipsec_status pool it was allocated from.
+ *
+ * @param res   IPsec status handle
+ */
+void _odp_ipsec_status_free(ipsec_status_t status);
+
+/**
+ * @internal Send ODP_IPSEC_STATUS event
+ *
+ * Sends the ipsec_status event using provided information
+ *
+ * @param queue destination queue
+ * @param idstatus id
+ * @param saSA respective to the operation
+ * @param resultstatus value
+ * @param warn  generated warning
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int _odp_ipsec_status_send(odp_queue_t queue,
+  odp_ipsec_status_id_t id,
+  odp_ipsec_sa_t sa,
+  int result,
+  odp_ipsec_warn_t warn);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-generic/odp_event.c 
b/platform/linux-generic/odp_event.c
index 23b410d8..f03faa64 100644

[lng-odp] [PATCH API-NEXT v12 2/8] linux-gen: pktio: loop: support IPsec inbound inline

2017-08-24 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Add support for inbound inline IPsec packet processing on loop
interface.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 81 (lumag:ipsec-packet-impl-2)
 ** https://github.com/Linaro/odp/pull/81
 ** Patch: https://github.com/Linaro/odp/pull/81.patch
 ** Base sha: 859293ad9b3c862264bb0fbfe8e7037b5e04d084
 ** Merge commit sha: 3c4b4ab58168f2d1ffc93503027bbb5a5d2847d8
 **/
 platform/linux-generic/pktio/loop.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/platform/linux-generic/pktio/loop.c 
b/platform/linux-generic/pktio/loop.c
index c755d0b6..19f1d029 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -133,6 +133,13 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int 
index ODP_UNUSED,
 
packet_set_ts(pkt_hdr, ts);
pkt_hdr->input = pktio_entry->s.handle;
+
+   /* Try IPsec inline processing */
+   if (pktio_entry->s.config.inbound_ipsec &&
+   odp_packet_has_ipsec(pkt) &&
+   _odp_ipsec_try_inline(pkt) == 0)
+   continue;
+
pktio_entry->s.stats.in_octets += pkt_len;
pkts[num_rx++] = pkt;
}
@@ -227,6 +234,7 @@ static int loopback_capability(pktio_entry_t *pktio_entry 
ODP_UNUSED,
odp_pktio_config_init(>config);
capa->config.pktin.bit.ts_all = 1;
capa->config.pktin.bit.ts_ptp = 1;
+   capa->config.inbound_ipsec = 1;
capa->config.outbound_ipsec = 1;
 
return 0;



[lng-odp] [PATCH v5 3/3] helper: chksum: verify odph_ipv4_chksum_*() functions

2017-08-24 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 132 (lumag:fix-checksum)
 ** https://github.com/Linaro/odp/pull/132
 ** Patch: https://github.com/Linaro/odp/pull/132.patch
 ** Base sha: 8705e548f330d23173283fcca62f4afb835a6380
 ** Merge commit sha: e256e0810a3feee8b1b91b8d61f21bdfdd339dff
 **/
 helper/test/chksum.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/helper/test/chksum.c b/helper/test/chksum.c
index 1beae47f..4a957c32 100644
--- a/helper/test/chksum.c
+++ b/helper/test/chksum.c
@@ -108,9 +108,17 @@ int main(int argc ODPH_UNUSED, char *argv[] ODPH_UNUSED)
   ODPH_IPV4HDR_LEN);
ip->proto = ODPH_IPPROTO_UDP;
ip->id = odp_cpu_to_be_16(1);
-   ip->chksum = 0;
odp_packet_has_ipv4_set(test_packet, 1);
-   odph_ipv4_csum_update(test_packet);
+   if (odph_ipv4_csum_update(test_packet) < 0)
+   status = -1;
+
+   if (!odph_ipv4_csum_valid(test_packet))
+   status = -1;
+
+   printf("IP chksum = 0x%x\n", odp_be_to_cpu_16(ip->chksum));
+
+   if (odp_be_to_cpu_16(ip->chksum) != 0x3965)
+   status = -1;
 
/* udp */
odp_packet_l4_offset_set(test_packet, ODPH_ETHHDR_LEN



[lng-odp] [PATCH API-NEXT v12 4/8] linux-gen: packet: add support for IP-in-IP (RFC 2003) encap

2017-08-24 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Don't barf on IP-in-IP packets parsing, just ignore L4 (=L3) header.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 81 (lumag:ipsec-packet-impl-2)
 ** https://github.com/Linaro/odp/pull/81
 ** Patch: https://github.com/Linaro/odp/pull/81.patch
 ** Base sha: 859293ad9b3c862264bb0fbfe8e7037b5e04d084
 ** Merge commit sha: 3c4b4ab58168f2d1ffc93503027bbb5a5d2847d8
 **/
 platform/linux-generic/include/protocols/ip.h | 1 +
 platform/linux-generic/odp_packet.c   | 4 
 2 files changed, 5 insertions(+)

diff --git a/platform/linux-generic/include/protocols/ip.h 
b/platform/linux-generic/include/protocols/ip.h
index 2b34a753..0fc391ab 100644
--- a/platform/linux-generic/include/protocols/ip.h
+++ b/platform/linux-generic/include/protocols/ip.h
@@ -158,6 +158,7 @@ typedef struct ODP_PACKED {
  * @{*/
 #define _ODP_IPPROTO_HOPOPTS 0x00 /**< IPv6 hop-by-hop options */
 #define _ODP_IPPROTO_ICMPv4  0x01 /**< Internet Control Message Protocol (1) */
+#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_ROUTE   0x2B /**< IPv6 Routing header (43) */
diff --git a/platform/linux-generic/odp_packet.c 
b/platform/linux-generic/odp_packet.c
index 432e91da..f896612e 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2405,6 +2405,10 @@ int packet_parse_common(packet_parser_t *prs, const 
uint8_t *ptr,
prs->input_flags.icmp = 1;
break;
 
+   case _ODP_IPPROTO_IPIP:
+   /* Do nothing */
+   break;
+
case _ODP_IPPROTO_TCP:
if (odp_unlikely(offset + _ODP_TCPHDR_LEN > seg_len))
return -1;



[lng-odp] [PATCH API-NEXT v12 1/8] linux-gen: pktio: loop: support IPsec outbound inline

2017-08-24 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Add support for outbound inline IPsec packet processing on loop
interface.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 81 (lumag:ipsec-packet-impl-2)
 ** https://github.com/Linaro/odp/pull/81
 ** Patch: https://github.com/Linaro/odp/pull/81.patch
 ** Base sha: 859293ad9b3c862264bb0fbfe8e7037b5e04d084
 ** Merge commit sha: 3c4b4ab58168f2d1ffc93503027bbb5a5d2847d8
 **/
 platform/linux-generic/pktio/loop.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/platform/linux-generic/pktio/loop.c 
b/platform/linux-generic/pktio/loop.c
index 68abb6d8..c755d0b6 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -162,6 +162,22 @@ static int loopback_send(pktio_entry_t *pktio_entry, int 
index ODP_UNUSED,
bytes += odp_packet_len(pkt_tbl[i]);
}
 
+   if (pktio_entry->s.config.outbound_ipsec)
+   for (i = 0; i < len; ++i) {
+   odp_buffer_t buf = buf_from_buf_hdr(hdr_tbl[i]);
+   odp_ipsec_packet_result_t result;
+
+   if (_odp_buffer_event_subtype(buf) !=
+   ODP_EVENT_PACKET_IPSEC)
+   continue;
+
+   /* Possibly postprocessing packet */
+   odp_ipsec_result(, pkt_tbl[i]);
+
+   _odp_buffer_event_subtype_set(buf,
+ ODP_EVENT_PACKET_BASIC);
+   }
+
odp_ticketlock_lock(_entry->s.txl);
 
queue = queue_fn->from_ext(pktio_entry->s.pkt_loop.loopq);
@@ -211,6 +227,8 @@ static int loopback_capability(pktio_entry_t *pktio_entry 
ODP_UNUSED,
odp_pktio_config_init(>config);
capa->config.pktin.bit.ts_all = 1;
capa->config.pktin.bit.ts_ptp = 1;
+   capa->config.outbound_ipsec = 1;
+
return 0;
 }
 



[lng-odp] [PATCH API-NEXT v12 3/8] linux-gen: packet: factor out L2 header parsing

2017-08-24 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Function parse_packet_common() now becomes just a multiplexer calling
other low-level parsing functions.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 81 (lumag:ipsec-packet-impl-2)
 ** https://github.com/Linaro/odp/pull/81
 ** Patch: https://github.com/Linaro/odp/pull/81.patch
 ** Base sha: 859293ad9b3c862264bb0fbfe8e7037b5e04d084
 ** Merge commit sha: 3c4b4ab58168f2d1ffc93503027bbb5a5d2847d8
 **/
 platform/linux-generic/odp_packet.c | 139 
 1 file changed, 77 insertions(+), 62 deletions(-)

diff --git a/platform/linux-generic/odp_packet.c 
b/platform/linux-generic/odp_packet.c
index bbad4bf3..432e91da 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2118,6 +2118,78 @@ int _odp_packet_copy_md_to_packet(odp_packet_t srcpkt, 
odp_packet_t dstpkt)
return dsthdr->buf_hdr.uarea_size < srchdr->buf_hdr.uarea_size;
 }
 
+/** Parser helper function for Ethernet packets */
+static inline uint16_t parse_eth(packet_parser_t *prs, const uint8_t 
**parseptr,
+uint32_t *offset, uint32_t frame_len)
+{
+   uint16_t ethtype;
+   const _odp_ethhdr_t *eth;
+   uint16_t macaddr0, macaddr2, macaddr4;
+   const _odp_vlanhdr_t *vlan;
+
+   /* Detect jumbo frames */
+   if (frame_len > _ODP_ETH_LEN_MAX)
+   prs->input_flags.jumbo = 1;
+
+   eth = (const _odp_ethhdr_t *)*parseptr;
+
+   /* Handle Ethernet broadcast/multicast addresses */
+   macaddr0 = odp_be_to_cpu_16(*((const uint16_t *)(const void *)eth));
+   prs->input_flags.eth_mcast = (macaddr0 & 0x0100) == 0x0100;
+
+   if (macaddr0 == 0x) {
+   macaddr2 =
+   odp_be_to_cpu_16(*((const uint16_t *)
+  (const void *)eth + 1));
+   macaddr4 =
+   odp_be_to_cpu_16(*((const uint16_t *)
+  (const void *)eth + 2));
+   prs->input_flags.eth_bcast =
+   (macaddr2 == 0x) && (macaddr4 == 0x);
+   } else {
+   prs->input_flags.eth_bcast = 0;
+   }
+
+   /* Get Ethertype */
+   ethtype = odp_be_to_cpu_16(eth->type);
+   *offset += sizeof(*eth);
+   *parseptr += sizeof(*eth);
+
+   /* Check for SNAP vs. DIX */
+   if (ethtype < _ODP_ETH_LEN_MAX) {
+   prs->input_flags.snap = 1;
+   if (ethtype > frame_len - *offset) {
+   prs->error_flags.snap_len = 1;
+   return 0;
+   }
+   ethtype = odp_be_to_cpu_16(*((const uint16_t *)(uintptr_t)
+(parseptr + 6)));
+   *offset   += 8;
+   *parseptr += 8;
+   }
+
+   /* Parse the VLAN header(s), if present */
+   if (ethtype == _ODP_ETHTYPE_VLAN_OUTER) {
+   prs->input_flags.vlan_qinq = 1;
+   prs->input_flags.vlan = 1;
+
+   vlan = (const _odp_vlanhdr_t *)*parseptr;
+   ethtype = odp_be_to_cpu_16(vlan->type);
+   *offset += sizeof(_odp_vlanhdr_t);
+   *parseptr += sizeof(_odp_vlanhdr_t);
+   }
+
+   if (ethtype == _ODP_ETHTYPE_VLAN) {
+   prs->input_flags.vlan = 1;
+   vlan = (const _odp_vlanhdr_t *)*parseptr;
+   ethtype = odp_be_to_cpu_16(vlan->type);
+   *offset += sizeof(_odp_vlanhdr_t);
+   *parseptr += sizeof(_odp_vlanhdr_t);
+   }
+
+   return ethtype;
+}
+
 /**
  * Parser helper function for IPv4
  */
@@ -2272,9 +2344,9 @@ int packet_parse_common(packet_parser_t *prs, const 
uint8_t *ptr,
uint16_t ethtype;
const uint8_t *parseptr;
uint8_t  ip_proto;
-   const _odp_ethhdr_t *eth;
-   uint16_t macaddr0, macaddr2, macaddr4;
-   const _odp_vlanhdr_t *vlan;
+
+   parseptr = ptr;
+   offset = 0;
 
if (layer == ODP_PKTIO_PARSER_LAYER_NONE)
return 0;
@@ -2283,65 +2355,8 @@ int packet_parse_common(packet_parser_t *prs, const 
uint8_t *ptr,
prs->input_flags.eth = 1;
/* Assume valid L2 header, no CRC/FCS check in SW */
prs->input_flags.l2 = 1;
-   /* Detect jumbo frames */
-   if (frame_len > _ODP_ETH_LEN_MAX)
-   prs->input_flags.jumbo = 1;
-
-   offset = sizeof(_odp_ethhdr_t);
-   eth = (const _odp_ethhdr_t *)ptr;
 
-   /* Handle Ethernet broadcast/multicast addresses */
-   macaddr0 = odp_be_to_cpu_16(*((const uint16_t *)(const void *)eth));
-   prs->input_flags.eth_mcast = (macaddr0 & 0x0100) == 0x0100;
-
-   if (macaddr0 == 0x) {
-   macaddr2 =
-   odp_be_to_cpu_16(*((const uint16_t *)
-  

[lng-odp] [PATCH API-NEXT v12 0/8] IPsec implementation based on packet interface

2017-08-24 Thread Github ODP bot
This PR replaces #28 by providing new IPsec implementation based on latest API 
additions.

github
/** Email created from pull request 81 (lumag:ipsec-packet-impl-2)
 ** https://github.com/Linaro/odp/pull/81
 ** Patch: https://github.com/Linaro/odp/pull/81.patch
 ** Base sha: 859293ad9b3c862264bb0fbfe8e7037b5e04d084
 ** Merge commit sha: 3c4b4ab58168f2d1ffc93503027bbb5a5d2847d8
 **/
/github

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


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


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


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


to_send-p-003.patch has no obvious style problems and is ready for submission.
CHECK: Avoid CamelCase: 
#800: FILE: test/common_plat/validation/api/ipsec/ipsec.c:713:
+   for (i = 0; suite[i].pName; i++) {

CHECK: Alignment should match open parenthesis
#2542: FILE: test/common_plat/validation/api/ipsec/test_vectors.h:18:
+KEY(key_a5_128, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
+   0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5);

CHECK: Alignment should match open parenthesis
#2544: FILE: test/common_plat/validation/api/ipsec/test_vectors.h:20:
+KEY(key_5a_128, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a,
+   0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a);

CHECK: Alignment should match open parenthesis
#2546: FILE: test/common_plat/validation/api/ipsec/test_vectors.h:22:
+KEY(key_a5_256, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
+   0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,

CHECK: Alignment should match open parenthesis
#2550: FILE: test/common_plat/validation/api/ipsec/test_vectors.h:26:
+KEY(key_5a_256, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a,
+   0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a,

CHECK: Alignment should match open parenthesis
#2555: FILE: test/common_plat/validation/api/ipsec/test_vectors.h:31:
+KEY(key_rfc3602, 0x90, 0xd3, 0x82, 0xb4, 0x10, 0xee, 0xba, 0x7a,
+0xd9, 0x38, 0xc4, 0x6c, 0xec, 0x1a, 0x82, 0xbf);

CHECK: Alignment should match open parenthesis
#2557: FILE: test/common_plat/validation/api/ipsec/test_vectors.h:33:
+KEY(key_rfc3602_2, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+  0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef);

CHECK: Alignment should match open parenthesis
#2559: FILE: test/common_plat/validation/api/ipsec/test_vectors.h:35:
+KEY(key_mcgrew_gcm_2, 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08);

CHECK: Alignment should match open parenthesis
#2562: FILE: test/common_plat/validation/api/ipsec/test_vectors.h:38:
+KEY(key_mcgrew_gcm_3, 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23,
+ 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab,

CHECK: Alignment should match open parenthesis
#2567: FILE: test/common_plat/validation/api/ipsec/test_vectors.h:43:
+KEY(key_mcgrew_gcm_4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);

CHECK: Alignment should match open parenthesis
#2570: FILE: test/common_plat/validation/api/ipsec/test_vectors.h:46:
+KEY(key_mcgrew_gcm_12, 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25,
+  0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47);

total: 0 errors, 0 warnings, 11 checks, 3379 lines checked


to_send-p-004.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, 331 lines checked


to_send-p-005.patch has no obvious style problems and is ready for submission.
ERROR: space prohibited after that '&' (ctx:WxW)
#432: FILE: platform/linux-generic/odp_ipsec_sad.c:131:
+   if (state & IPSEC_SA_STATE_DISABLE)
  ^

ERROR: space prohibited after that '-' (ctx:WxW)
#450: FILE: platform/linux-generic/odp_ipsec_sad.c:149:
+state - 1);
   ^

ERROR: space prohibited after that '&' (ctx:WxW)
#666: FILE: platform/linux-generic/odp_ipsec_sad.c:365:
+   if (state & IPSEC_SA_STATE_DISABLE)
  ^

total: 3 errors, 0 warnings, 0 checks, 732 lines checked


to_send-p-006.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, 1281 lines checked



[lng-odp] [PATCH v5 1/3] helper: chksum: calculate checksum in network byte order

2017-08-24 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

All examples and usecases assumed network byte order for odph_chksum()
return value. Instead of changing this convention, rather document that
odph_chksum returns value in network byte order.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 132 (lumag:fix-checksum)
 ** https://github.com/Linaro/odp/pull/132
 ** Patch: https://github.com/Linaro/odp/pull/132.patch
 ** Base sha: 8705e548f330d23173283fcca62f4afb835a6380
 ** Merge commit sha: e256e0810a3feee8b1b91b8d61f21bdfdd339dff
 **/
 helper/include/odp/helper/chksum.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/helper/include/odp/helper/chksum.h 
b/helper/include/odp/helper/chksum.h
index 520e9275..2da0303e 100644
--- a/helper/include/odp/helper/chksum.h
+++ b/helper/include/odp/helper/chksum.h
@@ -40,16 +40,16 @@ typedef enum {
  * @param buffer calculate chksum for buffer
  * @param lenbuffer length
  *
- * @return checksum value in host cpu order
+ * @return checksum value in network order
  */
 static inline odp_u16sum_t odph_chksum(void *buffer, int len)
 {
-   uint16_t *buf = (uint16_t *)buffer;
+   odp_u16be_t *buf = (odp_u16be_t *)buffer;
uint32_t sum = 0;
uint16_t result;
 
for (sum = 0; len > 1; len -= 2)
-   sum += *buf++;
+   sum += odp_be_to_cpu_16(*buf++);
 
if (len == 1)
sum += *(unsigned char *)buf;
@@ -58,7 +58,7 @@ static inline odp_u16sum_t odph_chksum(void *buffer, int len)
sum += (sum >> 16);
result = ~sum;
 
-   return  (__odp_force odp_u16sum_t) result;
+   return odp_cpu_to_be_16(result);
 }
 
 /**



[lng-odp] [PATCH v5 0/3] helper: ip: correct ipv4 header checksum calculation

2017-08-24 Thread Github ODP bot
Current code for IPv4 header checksum calculation assumes that packet
data is aligned on 2-byte boundary, that there are no optional headers,
etc. Rewrite checksumming code to properly copy & process headers.
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsoleni...@linaro.org

github
/** Email created from pull request 132 (lumag:fix-checksum)
 ** https://github.com/Linaro/odp/pull/132
 ** Patch: https://github.com/Linaro/odp/pull/132.patch
 ** Base sha: 8705e548f330d23173283fcca62f4afb835a6380
 ** Merge commit sha: e256e0810a3feee8b1b91b8d61f21bdfdd339dff
 **/
/github

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


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


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


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


[lng-odp] [PATCH v5 2/3] helper: ip: correct ipv4 header checksum calculation

2017-08-24 Thread Github ODP bot
From: Dmitry Eremin-Solenikov 

Current code for IPv4 header checksum calculation assumes that packet
data is aligned on 2-byte boundary, that there are no optional headers,
etc. Rewrite checksumming code to properly copy & process headers.

Signed-off-by: Dmitry Eremin-Solenikov 
---
/** Email created from pull request 132 (lumag:fix-checksum)
 ** https://github.com/Linaro/odp/pull/132
 ** Patch: https://github.com/Linaro/odp/pull/132.patch
 ** Base sha: 8705e548f330d23173283fcca62f4afb835a6380
 ** Merge commit sha: e256e0810a3feee8b1b91b8d61f21bdfdd339dff
 **/
 helper/include/odp/helper/ip.h | 75 +++---
 .../api/classification/odp_classification_common.c |  3 +-
 .../classification/odp_classification_test_pmr.c   |  2 +-
 .../api/classification/odp_classification_tests.c  |  9 +--
 4 files changed, 58 insertions(+), 31 deletions(-)

diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h
index 91776fad..e0d5c3bf 100644
--- a/helper/include/odp/helper/ip.h
+++ b/helper/include/odp/helper/ip.h
@@ -74,6 +74,9 @@ extern "C" {
 /** @internal Returns true if IPv4 packet is a fragment */
 #define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff)
 
+/** @internal Checksum offset in IPv4 header */
+#define ODPH_IPV4HDR_CSUM_OFFSET   10
+
 /** IPv4 header */
 typedef struct ODP_PACKED {
uint8_tver_ihl; /**< Version / Header length */
@@ -92,6 +95,28 @@ typedef struct ODP_PACKED {
 ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN,
  "ODPH_IPV4HDR_T__SIZE_ERROR");
 
+static inline int odph_ipv4_csum(odp_packet_t pkt,
+uint32_t offset,
+odph_ipv4hdr_t *ip,
+odp_u16sum_t *chksum)
+{
+   int nleft = ODPH_IPV4HDR_IHL(ip->ver_ihl) * 4;
+   uint16_t buf[nleft / 2];
+   int res;
+
+   ip->chksum = 0;
+   memcpy(buf, ip, sizeof(*ip));
+   res = odp_packet_copy_to_mem(pkt, offset + sizeof(*ip),
+nleft - sizeof(*ip),
+buf + sizeof(*ip) / 2);
+   if (odp_unlikely(res < 0))
+   return res;
+
+   *chksum = odph_chksum(buf, nleft);
+
+   return 0;
+}
+
 /**
  * Check if IPv4 checksum is valid
  *
@@ -102,11 +127,9 @@ ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == 
ODPH_IPV4HDR_LEN,
 static inline int odph_ipv4_csum_valid(odp_packet_t pkt)
 {
uint32_t offset;
-   odp_u16be_t res = 0;
-   uint16_t *w;
-   int nleft = sizeof(odph_ipv4hdr_t);
+   int res;
odph_ipv4hdr_t ip;
-   odp_u16be_t chksum;
+   odp_u16sum_t chksum, cur_chksum;
 
offset = odp_packet_l3_offset(pkt);
if (offset == ODP_PACKET_OFFSET_INVALID)
@@ -114,37 +137,45 @@ static inline int odph_ipv4_csum_valid(odp_packet_t pkt)
 
odp_packet_copy_to_mem(pkt, offset, sizeof(odph_ipv4hdr_t), );
 
-   w = (uint16_t *)(void *)
chksum = ip.chksum;
-   ip.chksum = 0x0;
 
-   res = odph_chksum(w, nleft);
-   return (res == chksum) ? 1 : 0;
+   res = odph_ipv4_csum(pkt, offset, , _chksum);
+   if (odp_unlikely(res < 0))
+   return 0;
+
+   return (cur_chksum == chksum) ? 1 : 0;
 }
 
 /**
  * Calculate and fill in IPv4 checksum
  *
- * @note when using this api to populate data destined for the wire
- * odp_cpu_to_be_16() can be used to remove sparse warnings
- *
  * @param pkt  ODP packet
  *
- * @return IPv4 checksum in host cpu order, or 0 on failure
+ * @retval 0 on success
+ * @retval <0 on failure
  */
-static inline odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt)
+static inline int odph_ipv4_csum_update(odp_packet_t pkt)
 {
-   uint16_t *w;
-   odph_ipv4hdr_t *ip;
-   int nleft = sizeof(odph_ipv4hdr_t);
+   uint32_t offset;
+   odph_ipv4hdr_t ip;
+   odp_u16sum_t chksum;
+   int res;
 
-   ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
-   if (ip == NULL)
-   return 0;
+   offset = odp_packet_l3_offset(pkt);
+   if (offset == ODP_PACKET_OFFSET_INVALID)
+   return -1;
+
+   res = odp_packet_copy_to_mem(pkt, offset, sizeof(ip), );
+   if (odp_unlikely(res < 0))
+   return res;
+
+   res = odph_ipv4_csum(pkt, offset, , );
+   if (odp_unlikely(res < 0))
+   return res;
 
-   w = (uint16_t *)(void *)ip;
-   ip->chksum = odph_chksum(w, nleft);
-   return ip->chksum;
+   return odp_packet_copy_from_mem(pkt,
+   offset + ODPH_IPV4HDR_CSUM_OFFSET,
+   2, );
 }
 
 /** IPv6 version */
diff --git 
a/test/common_plat/validation/api/classification/odp_classification_common.c 
b/test/common_plat/validation/api/classification/odp_classification_common.c
index de8a9327..e4c49648 100644

[lng-odp] [Bug 3210] New: packet header parsing routines should verify header checksums

2017-08-24 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=3210

Bug ID: 3210
   Summary: packet header parsing routines should verify header
checksums
   Product: OpenDataPlane - linux- generic reference
   Version: master
  Hardware: Other
OS: Linux
Status: UNCONFIRMED
  Severity: enhancement
  Priority: ---
 Component: Packet IO
  Assignee: maxim.uva...@linaro.org
  Reporter: dmitry.ereminsoleni...@linaro.org
CC: lng-odp@lists.linaro.org
  Target Milestone: ---

packet parsing routines should verify IPv4/TCP/UDP/ICMP/etc header checksums
and return an error if checksum is invalid.

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

[lng-odp] [Bug 3209] New: parse_ipv4 incorrectly sets ip_bcast flag

2017-08-24 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=3209

Bug ID: 3209
   Summary: parse_ipv4 incorrectly sets ip_bcast flag
   Product: OpenDataPlane - linux- generic reference
   Version: master
  Hardware: Other
OS: Linux
Status: UNCONFIRMED
  Severity: enhancement
  Priority: ---
 Component: Packet IO
  Assignee: maxim.uva...@linaro.org
  Reporter: dmitry.ereminsoleni...@linaro.org
CC: lng-odp@lists.linaro.org
  Target Milestone: ---

parse_ipv4() will set broadcast flag only if destination address is
255.255.255.255, not taking into account interface settings for
netmask/broadcast address.

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