Re: [lng-odp] [PATCHv2] validation: packet: do not require a max packet length

2017-03-17 Thread Bill Fischofer
On Fri, Mar 17, 2017 at 9:45 AM, Maxim Uvarov 
wrote:

> On 03/14/17 16:55, Bill Fischofer wrote:
> > Address bug https://bugs.linaro.org/show_bug.cgi?id=2908 by adding
> > appropriate pool capability checks to the packet and crypto tests
> > to account for pkt.max_len, pkt.max_seg_len, or pkt.max_segs_per_pkt
> > being zero, indicating these limits are bound only by available
> > memory.
> >
> > Signed-off-by: Bill Fischofer 
> > ---
> >  test/common_plat/validation/api/crypto/crypto.c |  6 --
> >  test/common_plat/validation/api/packet/packet.c | 13 +++--
> >  2 files changed, 15 insertions(+), 4 deletions(-)
> >
> > diff --git a/test/common_plat/validation/api/crypto/crypto.c
> b/test/common_plat/validation/api/crypto/crypto.c
> > index e7c2bf32..94beb2f1 100644
> > --- a/test/common_plat/validation/api/crypto/crypto.c
> > +++ b/test/common_plat/validation/api/crypto/crypto.c
> > @@ -48,12 +48,14 @@ int crypto_init(odp_instance_t *inst)
> >   params.pkt.num = PKT_POOL_NUM;
> >   params.type= ODP_POOL_PACKET;
> >
> > - if (PKT_POOL_LEN > pool_capa.pkt.max_seg_len) {
> > + if (pool_capa.pkt.max_seg_len &&
> > + PKT_POOL_LEN > pool_capa.pkt.max_seg_len) {
> >   fprintf(stderr, "Warning: small packet segment length\n");
>
> what should user do when he sees that message?
>

It's simply a warning that the test is using a shorter packet length than
it would like because the max_seg_len is smaller than PKT_POOL_LEN. I
suspect when Bug https://bugs.linaro.org/show_bug.cgi?id=2895 is fixed this
can be relaxed. It's there, I believe, because currently crypto does not
support multi-segment packets as input. Nikhil may have additional input
here. The patch is simply to account for the possibility that the
max_seg_len == 0 (as is the case for odp-dpdk) which means that the
implementation doesn't have a hard-coded max_seg_len (and so PKT_POOL_LEN)
can be used here.


>
> Maxim.
>
>
> >   params.pkt.seg_len = pool_capa.pkt.max_seg_len;
> >   }
> >
> > - if (PKT_POOL_LEN > pool_capa.pkt.max_len) {
> > + if (pool_capa.pkt.max_len &&
> > + PKT_POOL_LEN > pool_capa.pkt.max_len) {
> >   fprintf(stderr, "Pool max packet length too small\n");
> >   return -1;
> >   }
> > diff --git a/test/common_plat/validation/api/packet/packet.c
> b/test/common_plat/validation/api/packet/packet.c
> > index 900c4263..669122a7 100644
> > --- a/test/common_plat/validation/api/packet/packet.c
> > +++ b/test/common_plat/validation/api/packet/packet.c
> > @@ -114,6 +114,8 @@ int packet_suite_init(void)
> >   printf("pool_capability failed\n");
> >   return -1;
> >   }
> > + if (capa.pkt.max_segs_per_pkt == 0)
> > + capa.pkt.max_segs_per_pkt = 10;
> >
> >   /* Pick a typical packet size and decrement it to the single
> segment
> >* limit if needed (min_seg_len maybe equal to max_len
> > @@ -366,6 +368,8 @@ void packet_test_alloc_segmented(void)
> >   int ret, i, num_alloc;
> >
> >   CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
> > + if (capa.pkt.max_segs_per_pkt == 0)
> > + capa.pkt.max_segs_per_pkt = 10;
> >
> >   if (capa.pkt.max_len)
> >   max_len = capa.pkt.max_len;
> > @@ -1847,6 +1851,9 @@ void packet_test_extend_ref(void)
> >  {
> >   odp_packet_t max_pkt, ref;
> >   uint32_t hr, tr, max_len;
> > + odp_pool_capability_t capa;
> > +
> > + CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
> >
> >   max_pkt = odp_packet_copy(segmented_test_packet,
> > odp_packet_pool(segmented_test_packet));
> > @@ -1860,8 +1867,10 @@ void packet_test_extend_ref(void)
> >   odp_packet_push_tail(max_pkt, tr);
> >
> >   /* Max packet should not be extendable at either end */
> > - CU_ASSERT(odp_packet_extend_tail(&max_pkt, 1, NULL, NULL) < 0);
> > - CU_ASSERT(odp_packet_extend_head(&max_pkt, 1, NULL, NULL) < 0);
> > + if (max_len == capa.pkt.max_len) {
> > + CU_ASSERT(odp_packet_extend_tail(&max_pkt, 1, NULL, NULL)
> < 0);
> > + CU_ASSERT(odp_packet_extend_head(&max_pkt, 1, NULL, NULL)
> < 0);
> > + }
> >
> >   /* See if we can trunc and extend anyway */
> >   CU_ASSERT(odp_packet_trunc_tail(&max_pkt, hr + tr + 1,
> >
>
>


Re: [lng-odp] [PATCHv2] validation: packet: do not require a max packet length

2017-03-17 Thread Maxim Uvarov
On 03/14/17 16:55, Bill Fischofer wrote:
> Address bug https://bugs.linaro.org/show_bug.cgi?id=2908 by adding
> appropriate pool capability checks to the packet and crypto tests
> to account for pkt.max_len, pkt.max_seg_len, or pkt.max_segs_per_pkt
> being zero, indicating these limits are bound only by available
> memory.
> 
> Signed-off-by: Bill Fischofer 
> ---
>  test/common_plat/validation/api/crypto/crypto.c |  6 --
>  test/common_plat/validation/api/packet/packet.c | 13 +++--
>  2 files changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/test/common_plat/validation/api/crypto/crypto.c 
> b/test/common_plat/validation/api/crypto/crypto.c
> index e7c2bf32..94beb2f1 100644
> --- a/test/common_plat/validation/api/crypto/crypto.c
> +++ b/test/common_plat/validation/api/crypto/crypto.c
> @@ -48,12 +48,14 @@ int crypto_init(odp_instance_t *inst)
>   params.pkt.num = PKT_POOL_NUM;
>   params.type= ODP_POOL_PACKET;
>  
> - if (PKT_POOL_LEN > pool_capa.pkt.max_seg_len) {
> + if (pool_capa.pkt.max_seg_len &&
> + PKT_POOL_LEN > pool_capa.pkt.max_seg_len) {
>   fprintf(stderr, "Warning: small packet segment length\n");

what should user do when he sees that message?

Maxim.


>   params.pkt.seg_len = pool_capa.pkt.max_seg_len;
>   }
>  
> - if (PKT_POOL_LEN > pool_capa.pkt.max_len) {
> + if (pool_capa.pkt.max_len &&
> + PKT_POOL_LEN > pool_capa.pkt.max_len) {
>   fprintf(stderr, "Pool max packet length too small\n");
>   return -1;
>   }
> diff --git a/test/common_plat/validation/api/packet/packet.c 
> b/test/common_plat/validation/api/packet/packet.c
> index 900c4263..669122a7 100644
> --- a/test/common_plat/validation/api/packet/packet.c
> +++ b/test/common_plat/validation/api/packet/packet.c
> @@ -114,6 +114,8 @@ int packet_suite_init(void)
>   printf("pool_capability failed\n");
>   return -1;
>   }
> + if (capa.pkt.max_segs_per_pkt == 0)
> + capa.pkt.max_segs_per_pkt = 10;
>  
>   /* Pick a typical packet size and decrement it to the single segment
>* limit if needed (min_seg_len maybe equal to max_len
> @@ -366,6 +368,8 @@ void packet_test_alloc_segmented(void)
>   int ret, i, num_alloc;
>  
>   CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
> + if (capa.pkt.max_segs_per_pkt == 0)
> + capa.pkt.max_segs_per_pkt = 10;
>  
>   if (capa.pkt.max_len)
>   max_len = capa.pkt.max_len;
> @@ -1847,6 +1851,9 @@ void packet_test_extend_ref(void)
>  {
>   odp_packet_t max_pkt, ref;
>   uint32_t hr, tr, max_len;
> + odp_pool_capability_t capa;
> +
> + CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
>  
>   max_pkt = odp_packet_copy(segmented_test_packet,
> odp_packet_pool(segmented_test_packet));
> @@ -1860,8 +1867,10 @@ void packet_test_extend_ref(void)
>   odp_packet_push_tail(max_pkt, tr);
>  
>   /* Max packet should not be extendable at either end */
> - CU_ASSERT(odp_packet_extend_tail(&max_pkt, 1, NULL, NULL) < 0);
> - CU_ASSERT(odp_packet_extend_head(&max_pkt, 1, NULL, NULL) < 0);
> + if (max_len == capa.pkt.max_len) {
> + CU_ASSERT(odp_packet_extend_tail(&max_pkt, 1, NULL, NULL) < 0);
> + CU_ASSERT(odp_packet_extend_head(&max_pkt, 1, NULL, NULL) < 0);
> + }
>  
>   /* See if we can trunc and extend anyway */
>   CU_ASSERT(odp_packet_trunc_tail(&max_pkt, hr + tr + 1,
> 



Re: [lng-odp] [PATCHv2] validation: packet: do not require a max packet length

2017-03-17 Thread Krishna Garapati
Reviewed-by: Balakrishna Garapati 

/Krishna

On 14 March 2017 at 14:55, Bill Fischofer  wrote:

> Address bug https://bugs.linaro.org/show_bug.cgi?id=2908 by adding
> appropriate pool capability checks to the packet and crypto tests
> to account for pkt.max_len, pkt.max_seg_len, or pkt.max_segs_per_pkt
> being zero, indicating these limits are bound only by available
> memory.
>
> Signed-off-by: Bill Fischofer 
> ---
>  test/common_plat/validation/api/crypto/crypto.c |  6 --
>  test/common_plat/validation/api/packet/packet.c | 13 +++--
>  2 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/test/common_plat/validation/api/crypto/crypto.c
> b/test/common_plat/validation/api/crypto/crypto.c
> index e7c2bf32..94beb2f1 100644
> --- a/test/common_plat/validation/api/crypto/crypto.c
> +++ b/test/common_plat/validation/api/crypto/crypto.c
> @@ -48,12 +48,14 @@ int crypto_init(odp_instance_t *inst)
> params.pkt.num = PKT_POOL_NUM;
> params.type= ODP_POOL_PACKET;
>
> -   if (PKT_POOL_LEN > pool_capa.pkt.max_seg_len) {
> +   if (pool_capa.pkt.max_seg_len &&
> +   PKT_POOL_LEN > pool_capa.pkt.max_seg_len) {
> fprintf(stderr, "Warning: small packet segment length\n");
> params.pkt.seg_len = pool_capa.pkt.max_seg_len;
> }
>
> -   if (PKT_POOL_LEN > pool_capa.pkt.max_len) {
> +   if (pool_capa.pkt.max_len &&
> +   PKT_POOL_LEN > pool_capa.pkt.max_len) {
> fprintf(stderr, "Pool max packet length too small\n");
> return -1;
> }
> diff --git a/test/common_plat/validation/api/packet/packet.c
> b/test/common_plat/validation/api/packet/packet.c
> index 900c4263..669122a7 100644
> --- a/test/common_plat/validation/api/packet/packet.c
> +++ b/test/common_plat/validation/api/packet/packet.c
> @@ -114,6 +114,8 @@ int packet_suite_init(void)
> printf("pool_capability failed\n");
> return -1;
> }
> +   if (capa.pkt.max_segs_per_pkt == 0)
> +   capa.pkt.max_segs_per_pkt = 10;
>
> /* Pick a typical packet size and decrement it to the single
> segment
>  * limit if needed (min_seg_len maybe equal to max_len
> @@ -366,6 +368,8 @@ void packet_test_alloc_segmented(void)
> int ret, i, num_alloc;
>
> CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
> +   if (capa.pkt.max_segs_per_pkt == 0)
> +   capa.pkt.max_segs_per_pkt = 10;
>
> if (capa.pkt.max_len)
> max_len = capa.pkt.max_len;
> @@ -1847,6 +1851,9 @@ void packet_test_extend_ref(void)
>  {
> odp_packet_t max_pkt, ref;
> uint32_t hr, tr, max_len;
> +   odp_pool_capability_t capa;
> +
> +   CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
>
> max_pkt = odp_packet_copy(segmented_test_packet,
>   odp_packet_pool(segmented_test_packet));
> @@ -1860,8 +1867,10 @@ void packet_test_extend_ref(void)
> odp_packet_push_tail(max_pkt, tr);
>
> /* Max packet should not be extendable at either end */
> -   CU_ASSERT(odp_packet_extend_tail(&max_pkt, 1, NULL, NULL) < 0);
> -   CU_ASSERT(odp_packet_extend_head(&max_pkt, 1, NULL, NULL) < 0);
> +   if (max_len == capa.pkt.max_len) {
> +   CU_ASSERT(odp_packet_extend_tail(&max_pkt, 1, NULL, NULL)
> < 0);
> +   CU_ASSERT(odp_packet_extend_head(&max_pkt, 1, NULL, NULL)
> < 0);
> +   }
>
> /* See if we can trunc and extend anyway */
> CU_ASSERT(odp_packet_trunc_tail(&max_pkt, hr + tr + 1,
> --
> 2.12.0.rc1
>
>


Re: [lng-odp] [PATCHv2 5/5] test: generator: use multiple TX queues in send UDP mode

2017-03-17 Thread Maxim Uvarov
On 03/14/17 14:15, Bogdan Pricope wrote:
> Signed-off-by: Bogdan Pricope 
> ---
>  example/generator/odp_generator.c | 136 
> +++---
>  1 file changed, 84 insertions(+), 52 deletions(-)
> 
> diff --git a/example/generator/odp_generator.c 
> b/example/generator/odp_generator.c
> index 9f0484f..1ed2868 100644
> --- a/example/generator/odp_generator.c
> +++ b/example/generator/odp_generator.c
> @@ -39,6 +39,17 @@
>  /** Get rid of path in filename - only for unix-type paths using '/' */
>  #define NO_PATH(file_name) (strrchr((file_name), '/') ? \
>   strrchr((file_name), '/') + 1 : (file_name))
> +
> +/**
> + * Interfaces
> + */
> +
> +typedef struct {
> + odp_pktio_t pktio;
> + odp_pktout_queue_t pktout[MAX_WORKERS];
> + unsigned pktout_count;
> +} interface_t;
> +
>  /**
>   * Parsed command line application arguments
>   */
> @@ -78,7 +89,7 @@ static struct {
>  /** * Thread specific arguments
>   */
>  typedef struct {
> - char *pktio_dev;/**< Interface name to use */
> + odp_pktout_queue_t pktout; /**< Packet output queue to use*/
>   odp_pool_t pool;/**< Pool for packet IO */
>   odp_timer_pool_t tp;/**< Timer pool handle */
>   odp_queue_t tq; /**< Queue for timeouts */
> @@ -382,30 +393,33 @@ static odp_packet_t pack_icmp_pkt(odp_pool_t pool, 
> odp_packet_t pkt_ref)
>   * @return The handle of the created pktio object.
>   * @warning This routine aborts if the create is unsuccessful.
>   */
> -static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool,
> - unsigned num_rx_queues)
> +static int create_pktio(const char *dev, odp_pool_t pool,
> + unsigned num_rx_queues,
> + unsigned num_tx_queues,
> + interface_t *ift)


probably typo 'ift', should be 'itf' or 'intf'



>  {
> - odp_pktio_t pktio;
>   odp_pktio_capability_t capa;
>   int ret;
>   odp_pktio_param_t pktio_param;
>   odp_pktin_queue_param_t pktin_param;
> + odp_pktout_queue_param_t pktout_param;
> + odp_pktio_op_mode_t pktout_mode;
>  
>   odp_pktio_param_init(&pktio_param);
>   pktio_param.in_mode = ODP_PKTIN_MODE_SCHED;
>  
>   /* Open a packet IO instance */
> - pktio = odp_pktio_open(dev, pool, &pktio_param);
> + ift->pktio = odp_pktio_open(dev, pool, &pktio_param);
>  
> - if (pktio == ODP_PKTIO_INVALID) {
> + if (ift->pktio == ODP_PKTIO_INVALID) {
>   EXAMPLE_ERR("Error: pktio create failed for %s\n", dev);
> - exit(EXIT_FAILURE);
> + return -1;
>   }
>  
> - if (odp_pktio_capability(pktio, &capa)) {
> + if (odp_pktio_capability(ift->pktio, &capa)) {
>   EXAMPLE_ERR("Error: Failed to get interface capabilities %s\n",
>   dev);
> - exit(EXIT_FAILURE);
> + return -1;
>   }
>   if (num_rx_queues > capa.max_input_queues)
>   num_rx_queues = capa.max_input_queues;
> @@ -414,27 +428,44 @@ static odp_pktio_t create_pktio(const char *dev, 
> odp_pool_t pool,
>   pktin_param.num_queues = num_rx_queues;
>   pktin_param.queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC;
>  
> - if (odp_pktin_queue_config(pktio, &pktin_param)) {
> + if (odp_pktin_queue_config(ift->pktio, &pktin_param)) {
>   EXAMPLE_ERR("Error: pktin queue config failed for %s\n", dev);
> - exit(EXIT_FAILURE);
> + return -1;
> + }
> +
> + pktout_mode = ODP_PKTIO_OP_MT_UNSAFE;
> + if (num_tx_queues > capa.max_output_queues) {
> + num_tx_queues = capa.max_output_queues;
> + pktout_mode = ODP_PKTIO_OP_MT;
>   }
>  
> - if (odp_pktout_queue_config(pktio, NULL)) {
> + odp_pktout_queue_param_init(&pktout_param);
> + pktout_param.num_queues = num_tx_queues;
> + pktout_param.op_mode = pktout_mode;
> +
> + if (odp_pktout_queue_config(ift->pktio, &pktout_param)) {
>   EXAMPLE_ERR("Error: pktout queue config failed for %s\n", dev);
> - exit(EXIT_FAILURE);
> + return -1;
>   }
>  
> - ret = odp_pktio_start(pktio);
> + ret = odp_pktio_start(ift->pktio);
>   if (ret)
>   EXAMPLE_ABORT("Error: unable to start %s\n", dev);
>  
> + ift->pktout_count = num_tx_queues;
> + if (odp_pktout_queue(ift->pktio, ift->pktout, ift->pktout_count) !=
> +  (int)ift->pktout_count) {
> + EXAMPLE_ERR("Error: failed to get output queues for %s\n", dev);
> + return -1;
> + }
> +
>   printf("  created pktio:%02" PRIu64
>  ", dev:%s, queue mode (ATOMIC queues)\n"
>  "  default pktio%02" PRIu64 "\n",
> -odp_pktio_to_u64(pktio), dev,
> -odp_pktio_to_u64(pktio));
> +odp_pktio_to_u64(ift->pktio), dev,
> +odp_pktio_to_u64(if

[lng-odp] [Bug 2911] unchecked return value may result in out of bounds access

2017-03-17 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2911

Matias Elo  changed:

   What|Removed |Added

 CC||matias@nokia.com

--- Comment #1 from Matias Elo  ---
The loop is never run if num (int) is negative:

  for (i = 0; i < num; i++) {

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

[lng-odp] [Bug 2911] New: unchecked return value may result in out of bounds access

2017-03-17 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2911

Bug ID: 2911
   Summary: unchecked return value may result in out of bounds
access
   Product: OpenDataPlane - linux- generic reference
   Version: v1.14.0.0
  Hardware: Other
OS: Linux
Status: UNCONFIRMED
  Severity: critical
  Priority: ---
 Component: Packet IO
  Assignee: maxim.uva...@linaro.org
  Reporter: josep.puigdem...@linaro.org
CC: lng-odp@lists.linaro.org
  Target Milestone: ---

in function netmap_pkt_to_odp() from file 
platform/linux-generic/pktio/netmap.c, the return value of packet_alloc_multi()
is not properly checked. It may return a negative number on error, in which
case the following loop will eventually result in an out of bounds access of
the slot_tlb array.

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

[lng-odp] [RFC, API-NEXT v1 1/1] comp:compression interface

2017-03-17 Thread Mahipal Challa
From: Shally Verma 

An API set to add compression/decompression support in ODP 
interface.

Signed-off-by: Shally Verma 
Signed-off-by: Mahipal Challa 
---
 include/odp/api/spec/comp.h | 668 
 1 file changed, 668 insertions(+)

diff --git a/include/odp/api/spec/comp.h b/include/odp/api/spec/comp.h
new file mode 100644
index 000..d8f6c68
--- /dev/null
+++ b/include/odp/api/spec/comp.h
@@ -0,0 +1,668 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP Compression
+ */
+
+#ifndef ODP_API_COMP_H_
+#define ODP_API_COMP_H_
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup odp_compression ODP COMP
+ *  ODP Compression defines interface to compress/decompress and authenticate
+ *  data.
+ *
+ *  Compression here implicilty refer to both compression and decompression.
+ *  Example, compression algo 'deflate' mean both 'deflate' and 'inflate'.
+ *
+ *  if opcode = ODP_COMP_COMPRESS, then it will Compress,
+ *  if opcode = ODP_COMP_DECOMPRESS, then it will Decompress.
+ *
+ *  Current version of Interface allow Compression ONLY,Authentication ONLY or
+ *  both Compression + Auth ONLY sessions.
+ *
+ *  Macros, enums, types and operations to utilise compression.
+ *  @{
+ */
+
+/**
+ * @def ODP_COMP_SESSION_INVALID
+ * Invalid session handle
+ */
+
+/**
+ * @typedef odp_comp_session_t (platform dependent)
+ * Comp API opaque session handle
+ */
+
+/**
+ * @typedef odp_comp_compl_t
+* Compression API completion event (platform dependent)
+*/
+
+/**
+ * Compression API operation mode
+ */
+typedef enum {
+   /** Synchronous, return results immediately */
+   ODP_COMP_SYNC,
+   /** Asynchronous, return results via event */
+   ODP_COMP_ASYNC,
+} odp_comp_op_mode_t;
+
+/**
+ * Comp API operation type
+ */
+typedef enum {
+   /** Compress and/or Compute ICV  */
+   ODP_COMP_OP_COMPRESS,
+   /** Decompress and/or Compute ICV */
+   ODP_COMP_OP_DECOMPRESS,
+} odp_comp_op_t;
+
+/**
+ * Comp API compression algorithm
+ *
+ *  Enum listing support Compression algo. Currently one
+ *  Compressor corresponds to 1 compliant decompressor.
+ *
+ */
+typedef enum {
+   /** No algorithm specified */
+   ODP_COMP_ALG_NULL,
+   /** DEFLATE -
+   *
+   * implicit Inflate in case of decode operation
+   *
+   */
+   ODP_COMP_ALG_DEFLATE,
+   /** ZLIB */
+   ODP_COMP_ALG_ZLIB,
+   /** LZS*/
+   ODP_COMP_ALG_LZS,
+   /** SHA1
+   *
+   * When given, imply Authentication ONLY operation
+   *
+   */
+   ODP_COMP_ALG_SHA1,
+   /** SHA256
+   *
+   * When given, imply Authentication ONLY operation
+   *
+   */
+   ODP_COMP_ALG_SHA256,
+   /** DEFLATE+SHA1  */
+   ODP_COMP_ALG_DEFLATE_SHA1,
+   /** DEFLATE+SHA256   */
+   ODP_COMP_ALG_DEFLATE_SHA256,
+   /** ZLIB+SHA  */
+   ODP_COMP_ALG_ZLIB_SHA1,
+   /** ZLIB+SHA256 */
+   ODP_COMP_ALG_ZLIB_SHA256,
+   /** LZS+SHA1   */
+   ODP_COMP_ALG_LZS_SHA1,
+   /** LZS+SHA256 */
+   ODP_COMP_ALG_LZS_SHA256
+} odp_comp_alg_t;
+
+/**
+ * Comp API session creation return code
+ */
+typedef enum {
+   /** Session created */
+   ODP_COMP_SES_CREATE_ERR_NONE,
+   /** Creation failed, no resources */
+   ODP_COMP_SES_CREATE_ERR_ENOMEM,
+   /** Creation failed, bad compression params */
+   ODP_COMP_SES_CREATE_ERR_INV_COMP,
+   /** Creation failed,requested configuration not supported*/
+   ODP_COMP_SES_CREATE_ERR_NOT_SUPPORTED
+} odp_comp_ses_create_err_t;
+
+/** Comp API operation return codes */
+typedef enum {
+   /** Operation completed successfully */
+   ODP_COMP_ERR_NONE,
+   /** Invalid user data pointers */
+   ODP_COMP_ERR_DATA_PTR,
+   /** Invalid input data size */
+   ODP_COMP_ERR_DATA_SIZE,
+   /**  Compression Algo fail error */
+   ODP_COMP_ERR_COMP_FAIL,
+   /** Error detected during DMA of data */
+   ODP_COMP_ERR_DMA,
+   /** Operation failed due to insufficient output buffer */
+   ODP_COMP_ERR_OUT_OF_SPACE,
+} odp_comp_err_t;
+
+/** Comp API enumeration for preferred compression level/speed.
+*
+* trade-off between speed and compression ratio.
+*
+* Please note this enumeration is only a peferential selection
+* but may not guarantee operation to committed level depending
+* on implementation support. Ex. SPEED_FASTEST and SPEED_FAST may
+* give same result on some platforms.
+*
+*/
+typedef enum {
+   /* Use implementaion default between ratio and speed */
+   ODP_COMP_SPEED_DEFAULT,
+   /** fastest speed, lowest compression */
+   ODP_COMP_SPEED_FASTEST,
+   /** fast speed, lower compression */
+   ODP_COMP_SPEED_FAST,
+   /** medium speed, medium compression  */
+   ODP_COMP_SPEED_MED,
+   /** slowest speed, maximum compression */

[lng-odp] [RFC, API-NEXT v1 0/1] comp:API for compression support

2017-03-17 Thread Mahipal Challa
From: Shally Verma 

This series adds an API set to support compression/decompression in
ODP interface.

Shally Verma (1):
  comp:compression interface

 include/odp/api/spec/comp.h | 668 
 1 file changed, 668 insertions(+)
 create mode 100644 include/odp/api/spec/comp.h

-- 
1.9.1



[lng-odp] [PATCH v2 1/3] linux-gen: add internal helper for reading system thread id

2017-03-17 Thread Matias Elo
Signed-off-by: Matias Elo 
---
 platform/linux-generic/Makefile.am   |  1 +
 platform/linux-generic/include/odp_thread_internal.h | 20 
 platform/linux-generic/odp_thread.c  | 10 ++
 3 files changed, 31 insertions(+)
 create mode 100644 platform/linux-generic/include/odp_thread_internal.h

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 056ba67..b2ae971 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -144,6 +144,7 @@ noinst_HEADERS = \
  ${srcdir}/include/odp_schedule_if.h \
  ${srcdir}/include/odp_sorted_list_internal.h \
  ${srcdir}/include/odp_shm_internal.h \
+ ${srcdir}/include/odp_thread_internal.h \
  ${srcdir}/include/odp_timer_internal.h \
  ${srcdir}/include/odp_timer_wheel_internal.h \
  ${srcdir}/include/odp_traffic_mngr_internal.h \
diff --git a/platform/linux-generic/include/odp_thread_internal.h 
b/platform/linux-generic/include/odp_thread_internal.h
new file mode 100644
index 000..9a8e482
--- /dev/null
+++ b/platform/linux-generic/include/odp_thread_internal.h
@@ -0,0 +1,20 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_THREAD_INTERNAL_H_
+#define ODP_THREAD_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+pid_t sys_thread_id(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-generic/odp_thread.c 
b/platform/linux-generic/odp_thread.c
index 33a8a7f..e98fa7a 100644
--- a/platform/linux-generic/odp_thread.c
+++ b/platform/linux-generic/odp_thread.c
@@ -17,15 +17,19 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
+#include 
+#include 
 
 typedef struct {
int thr;
int cpu;
odp_thread_type_t type;
+   pid_t sys_thr_id;
 } thread_state_t;
 
 
@@ -135,6 +139,11 @@ static int free_id(int thr)
return thread_globals->num;
 }
 
+pid_t sys_thread_id(void)
+{
+   return this_thread->sys_thr_id;
+}
+
 int odp_thread_init_local(odp_thread_type_t type)
 {
int id;
@@ -159,6 +168,7 @@ int odp_thread_init_local(odp_thread_type_t type)
thread_globals->thr[id].thr  = id;
thread_globals->thr[id].cpu  = cpu;
thread_globals->thr[id].type = type;
+   thread_globals->thr[id].sys_thr_id = (pid_t)syscall(SYS_gettid);
 
this_thread = &thread_globals->thr[id];
 
-- 
2.7.4



[lng-odp] [PATCH v2 2/3] linux-gen: netmap: use thread id to make vdev mac addresses unique

2017-03-17 Thread Matias Elo
Previously the mac addresses of virtual netmap devices would clash if
multiple odp processes were run on the same host.

Signed-off-by: Matias Elo 
---
V2:
- Use TID instead of PID (Maxim)

 platform/linux-generic/pktio/netmap.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/platform/linux-generic/pktio/netmap.c 
b/platform/linux-generic/pktio/netmap.c
index ae3db34..04df99f 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -386,6 +387,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, 
pktio_entry_t *pktio_entry,
 
if (pkt_nm->is_virtual) {
static unsigned mac;
+   uint32_t tid = sys_thread_id();
 
pkt_nm->capa.max_input_queues = 1;
pkt_nm->capa.set_op.op.promisc_mode = 0;
@@ -393,6 +395,10 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, 
pktio_entry_t *pktio_entry,
pktio_entry->s.stats_type = STATS_UNSUPPORTED;
/* Set MAC address for virtual interface */
pkt_nm->if_mac[0] = 0x2;
+   pkt_nm->if_mac[1] = (tid >> 24) & 0xff;
+   pkt_nm->if_mac[2] = (tid >> 16) & 0xff;
+   pkt_nm->if_mac[3] = (tid >> 8) & 0xff;
+   pkt_nm->if_mac[4] = tid & 0xff;
pkt_nm->if_mac[5] = ++mac;
 
return 0;
-- 
2.7.4



[lng-odp] [PATCH v2 3/3] linux-gen: netmap: remove minimum frame len check

2017-03-17 Thread Matias Elo
Checking the minimum frame length is unnecessary as netmap drops truncated
frames internally.

Signed-off-by: Matias Elo 
---
 platform/linux-generic/pktio/netmap.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/platform/linux-generic/pktio/netmap.c 
b/platform/linux-generic/pktio/netmap.c
index 04df99f..3b06602 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -643,11 +643,6 @@ static inline int netmap_pkt_to_odp(pktio_entry_t 
*pktio_entry,
goto fail;
}
 
-   if (odp_unlikely(len < _ODP_ETH_LEN_MIN)) {
-   ODP_ERR("RX: Frame truncated: %" PRIu16 "\n", len);
-   goto fail;
-   }
-
if (pktio_cls_enabled(pktio_entry)) {
if (cls_classify_packet(pktio_entry,
(const uint8_t *)slot.buf, len,
-- 
2.7.4



Re: [lng-odp] [PATCH 1/2] linux-gen: netmap: use pid to make vdev mac addresses unique

2017-03-17 Thread Elo, Matias (Nokia - FI/Espoo)

> On 16 Mar 2017, at 17:01, Bogdan Pricope  wrote:
> 
> Hi Matias,
> 
> Today, on "ODP Apps, Cloud, Demos, OFP" meeting I asked about the
> possibility/opportunity to add an odp_pktio_mac_addr_set() API.
> 
> This API may not make sense for some pktios but may be useful for
> others: OFP may (eventually) use tap pktio to replace existing tap
> functionality associated with slow path support if will be able to set
> the same MAC for tap interface and 'real' interface (e.g. tap
> interface and dpdk interface).
> 
> An odp_pktio_mac_addr_set() API will solve your problem? Or maybe you
> need an extra argument in odp_pktio_open()?
> 
> BR,
> Bogdan
> 

Hi Bogdan,

In this particular use case mac set api is not needed since I want to hide the
whole issue from the application. 

-Matias






Re: [lng-odp] [PATCH 1/2] linux-gen: netmap: use pid to make vdev mac addresses unique

2017-03-17 Thread Elo, Matias (Nokia - FI/Espoo)

> But for better support thread and process modes I think
> getpid()+gettid() is needed.
> 
> Maxim.


A valid point. Will be fixed in v2.

-Matias




[lng-odp] [PATCHv3] example:ipsec_offload: Adding ipsec_offload example

2017-03-17 Thread Nikhil Agarwal
Signed-off-by: Nikhil Agarwal 
---
 example/Makefile.am  |   1 +
 example/ipsec_offload/.gitignore |   1 +
 example/ipsec_offload/Makefile.am|  19 +
 example/ipsec_offload/odp_ipsec_offload.c| 872 +++
 example/ipsec_offload/odp_ipsec_offload_cache.c  | 148 
 example/ipsec_offload/odp_ipsec_offload_cache.h  |  78 ++
 example/ipsec_offload/odp_ipsec_offload_fwd_db.c | 223 ++
 example/ipsec_offload/odp_ipsec_offload_fwd_db.h | 198 +
 example/ipsec_offload/odp_ipsec_offload_misc.h   | 384 ++
 example/ipsec_offload/odp_ipsec_offload_sa_db.c  | 361 ++
 example/ipsec_offload/odp_ipsec_offload_sa_db.h  | 126 
 example/ipsec_offload/odp_ipsec_offload_sp_db.c  | 166 +
 example/ipsec_offload/odp_ipsec_offload_sp_db.h  |  72 ++
 example/ipsec_offload/run_left   |  14 +
 example/ipsec_offload/run_right  |  14 +
 example/m4/configure.m4  |   1 +
 16 files changed, 2678 insertions(+)
 create mode 100644 example/ipsec_offload/.gitignore
 create mode 100644 example/ipsec_offload/Makefile.am
 create mode 100644 example/ipsec_offload/odp_ipsec_offload.c
 create mode 100644 example/ipsec_offload/odp_ipsec_offload_cache.c
 create mode 100644 example/ipsec_offload/odp_ipsec_offload_cache.h
 create mode 100644 example/ipsec_offload/odp_ipsec_offload_fwd_db.c
 create mode 100644 example/ipsec_offload/odp_ipsec_offload_fwd_db.h
 create mode 100644 example/ipsec_offload/odp_ipsec_offload_misc.h
 create mode 100644 example/ipsec_offload/odp_ipsec_offload_sa_db.c
 create mode 100644 example/ipsec_offload/odp_ipsec_offload_sa_db.h
 create mode 100644 example/ipsec_offload/odp_ipsec_offload_sp_db.c
 create mode 100644 example/ipsec_offload/odp_ipsec_offload_sp_db.h
 create mode 100644 example/ipsec_offload/run_left
 create mode 100644 example/ipsec_offload/run_right

diff --git a/example/Makefile.am b/example/Makefile.am
index dfc07b6..24b9e52 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -2,6 +2,7 @@ SUBDIRS = classifier \
  generator \
  hello \
  ipsec \
+ ipsec_offload \
  l2fwd_simple \
  l3fwd \
  packet \
diff --git a/example/ipsec_offload/.gitignore b/example/ipsec_offload/.gitignore
new file mode 100644
index 000..2fc73aa
--- /dev/null
+++ b/example/ipsec_offload/.gitignore
@@ -0,0 +1 @@
+odp_ipsec_offload
diff --git a/example/ipsec_offload/Makefile.am 
b/example/ipsec_offload/Makefile.am
new file mode 100644
index 000..a61b923
--- /dev/null
+++ b/example/ipsec_offload/Makefile.am
@@ -0,0 +1,19 @@
+include $(top_srcdir)/example/Makefile.inc
+
+bin_PROGRAMS = odp_ipsec_offload$(EXEEXT)
+odp_ipsec_offload_LDFLAGS = $(AM_LDFLAGS) -static
+odp_ipsec_offload_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
+
+noinst_HEADERS = \
+ $(top_srcdir)/example/ipsec_offload/odp_ipsec_offload_cache.h 
\
+ 
$(top_srcdir)/example/ipsec_offload/odp_ipsec_offload_fwd_db.h \
+ $(top_srcdir)/example/ipsec_offload/odp_ipsec_offload_misc.h \
+ $(top_srcdir)/example/ipsec_offload/odp_ipsec_offload_sa_db.h 
\
+ $(top_srcdir)/example/ipsec_offload/odp_ipsec_offload_sp_db.h 
\
+ $(top_srcdir)/example/example_debug.h
+
+dist_odp_ipsec_offload_SOURCES = odp_ipsec_offload.c \
+odp_ipsec_offload_sa_db.c \
+odp_ipsec_offload_sp_db.c \
+odp_ipsec_offload_fwd_db.c \
+odp_ipsec_offload_cache.c
diff --git a/example/ipsec_offload/odp_ipsec_offload.c 
b/example/ipsec_offload/odp_ipsec_offload.c
new file mode 100644
index 000..ebf70d7
--- /dev/null
+++ b/example/ipsec_offload/odp_ipsec_offload.c
@@ -0,0 +1,872 @@
+/* Copyright (c) 2017, Linaro Limited
+ * Copyright (C) 2017 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * @example odp_ipsec_offload.c  ODP basic packet IO cross connect with IPsec
+ * test application
+ */
+
+#define _DEFAULT_SOURCE
+/* enable strtok */
+#define _POSIX_C_SOURCE 200112L
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MAX_WORKERS 32   /**< maximum number of worker threads */
+
+/**
+ * Parsed command line application arguments
+ */
+typedef struct {
+   int cpu_count;
+   int flows;
+   int if_count;   /**< Number of interfaces to be used */
+   char **if_names;/**< Array of pointers to interface names */
+   char *if_str;   /**< Storage for interface names */
+   int queue_type; /**< Queue synchronization type*/
+} appl_args_t;
+/*