Re: [lng-odp] [PATCHv1 1/5] helper: add table api

2015-10-19 Thread Maxim Uvarov

On 10/16/2015 12:35, huanggaoyang wrote:

Signed-off-by: huanggaoyang 
---
  helper/include/odp/helper/table.h | 199 ++
  1 file changed, 199 insertions(+)
  create mode 100644 helper/include/odp/helper/table.h

diff --git a/helper/include/odp/helper/table.h 
b/helper/include/odp/helper/table.h
new file mode 100644
index 000..891b115
--- /dev/null
+++ b/helper/include/odp/helper/table.h
@@ -0,0 +1,199 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */


This file provides ODP api. How is above Intel copyright related to it?

Maxim.


+
+/**
+ * @file
+ *
+ * ODP table
+ *
+ * Table designed to provide a standard interface to implement different
+ * types of tables for data processing.
+ * Use case:
+ * Table is publicly used in the following scenarios in data plane:
+ * ARP Table, IP Routing Table, MAC address filtering, ACL, interworking etc.
+ * The features of the "table":
+ * 1) All these different types of "table" have the common operations:
+ *Create a table, destroy a table, add an entry (key/value pairs),
+ *delete an entry, and lookup the value via the key.
+ *Usually these operations are software based, but also can be
+ *hardware accelerated if cost, power consumption are not the concern
+ *in your platform.
+ * 2) Different types of "table" can use different algorithms to
+ *add/delete/lookup the entry.
+ *
+ */
+
+#ifndef ODPH_TABLE_H_
+#define ODPH_TABLE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ODPH_TABLE_NAME_LEN  32
+
+typedef ODP_HANDLE_T(odph_table_t);
+
+/**
+* create a table
+* Generally, tables only support key-value pair both with fixed size
+*
+* @param name
+*name of this table, max ODPH_TABLE_NAME_LEN - 1
+*May be specified as NULL for anonymous table
+* @param capacity
+*Max memory usage this table use, in MBytes
+* @param key_size
+*fixed size of the 'key' in bytes.
+* @param value_size
+*fixed size of the 'value' in bytes.
+* @return
+*   Handle to table instance or NULL if failed
+* @note
+*/
+typedef odph_table_t (*odph_table_create)(const char *name,
+   uint32_t capacity,
+   uint32_t key_size,
+   uint32_t value_size);
+
+/**
+ * Find a table by name
+ *
+ * @param name:  Name of the table
+ *
+ * @return Handle of found table
+ * @retval NULL  table could not be found
+ *
+ * @note
+ * This routine cannot be used to look up an anonymous
+ * table (one created with no name).
+ * This API supports Multiprocess
+ */
+typedef odph_table_t (*odph_table_lookup)(const char *name);
+
+/**
+ * Destroy a table previously created by odph_table_create()
+ *
+ * @param table: Handle of the table to be destroyed
+ *
+ * @retval 0 Success
+ * @retval -1 Failure
+ *
+ * @note
+ *   This routine destroys a previously created pool
+ *   also should free any memory allocated at creation
+ *
+ */
+typedef int (*odph_table_destroy)(odph_table_t table);
+
+/**
+ * table element add
+ *
+ * @param table:Handle of the table that the element be 

Re: [lng-odp] [PATCHv9 7/8] linux-generic: add ipc pktio support

2015-10-19 Thread Maxim Uvarov

On 10/16/2015 21:16, Stuart Haslam wrote:

It would be better to do away with the master/slave naming and instead use
names that match their function, e.g.; rx.recv/rx.free and tx.recv/tx.free


Stuart you have also about the same question bellow in the code. I also
don't line naming ipc.rx.recv and ipc.tx.free.

That is not rx or tx because of pkio is bidirectional. There is process 
with creates
shm and processes which connect to that shm. They are very symmetrical 
and difference
is only used flag and expected some information to be already filled. I 
deceived to name
it master and slave. I.e. master is process which creates shm and other 
processes which reuse it.


Change name is easy find and replace in the patch. But we can try to 
think which name is more

suitable. How about:

ipc.proc0
ipc.procX

ipc.parent
ipc.child

ipc.initial
ipc.secondary

ipc.batman
ipc.robin

?

In that version I support only 2 processes connected to each other using 
single pktio. But we can update it
to use multi version. For that needed to export information about 3-rd 
process to first and second. It should
not be complex but I would like to do it in separate patch after that 
series included.


Other comments looks reasonable. Will send updated patches.

Maxim.


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


Re: [lng-odp] [PATCH 1/2] linux-generic: netmap: wait for the interface to become active

2015-10-19 Thread Elo, Matias (Nokia - FI/Espoo)
> -Original Message-
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT Maxim
> Uvarov
> Sent: Friday, October 16, 2015 7:00 PM
> To: lng-odp@lists.linaro.org
> Subject: Re: [lng-odp] [PATCH 1/2] linux-generic: netmap: wait for the 
> interface
> to become active
> 
> On 10/16/2015 15:45, Matias Elo wrote:
> > Netmap interface takes a few seconds to become active after
> > setup. This caused several test applications to fail.
> > Check link status at the end of netmap_open() to fix this.
> >
> > Signed-off-by: Matias Elo 
> > ---
> >   platform/linux-generic/pktio/netmap.c | 20 +---
> >   1 file changed, 17 insertions(+), 3 deletions(-)
> >
> > diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-
> generic/pktio/netmap.c
> > index ab4667e..0c9ad35 100644
> > --- a/platform/linux-generic/pktio/netmap.c
> > +++ b/platform/linux-generic/pktio/netmap.c
> > @@ -28,6 +28,7 @@ static struct nm_desc mmap_desc;  /** Used to store
> the mmap address;
> >   filled in first time, used for
> >   subsequent calls to nm_open */
> >
> > +#define NM_OPEN_RETRIES 5
> >   #define NM_INJECT_RETRIES 10
> >
> >   struct dispatch_args {
> > @@ -70,6 +71,10 @@ static int netmap_do_ioctl(pktio_entry_t *pktio_entry,
> unsigned long cmd,
> > pkt_nm->if_flags = (ifr.ifr_flags << 16) |
> > (0x & ifr.ifr_flags);
> > break;
> > +   case SIOCETHTOOL:
> > +   if (subcmd == ETHTOOL_GLINK)
> > +   return !eval.data;
> > +   break;
> > default:
> > break;
> > }
> > @@ -84,9 +89,10 @@ static int netmap_close(pktio_entry_t *pktio_entry)
> >   {
> > pkt_netmap_t *pkt_nm = _entry->s.pkt_nm;
> >
> > -   if (pkt_nm->desc != NULL)
> > +   if (pkt_nm->desc != NULL) {
> > nm_close(pkt_nm->desc);
> > -
> > +   mmap_desc.mem = NULL;
> > +   }
> > if (pkt_nm->sockfd != -1 && close(pkt_nm->sockfd) != 0) {
> > __odp_errno = errno;
> > ODP_ERR("close(sockfd): %s\n", strerror(errno));
> > @@ -101,6 +107,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED,
> pktio_entry_t *pktio_entry,
> > char ifname[IFNAMSIZ + 7]; /* netmap: */
> > int err;
> > int sockfd;
> > +   int i;
> > pkt_netmap_t *pkt_nm = _entry->s.pkt_nm;
> >
> > if (getenv("ODP_PKTIO_DISABLE_NETMAP"))
> > @@ -155,7 +162,14 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED,
> pktio_entry_t *pktio_entry,
> > if (err)
> > goto error;
> >
> > -   return 0;
> > +   /* Wait for the link to come up */
> > +   for (i = 0; i < NM_OPEN_RETRIES; i++) {
> > +   err = netmap_do_ioctl(pktio_entry, SIOCETHTOOL,
> ETHTOOL_GLINK);
> > +   if (err == 0)
> > +   return 0;
> > +   sleep(1);
> > +   }
> > +   ODP_ERR("%s didn't come up\n", pktio_entry->s.name);
> 
> before usage pktio you need to call odp_pktio_start(). Maybe it's more
> reasonable on start() check that link is up?
> 
> Maxim.

OK. I would suggest that we merge this patch first as a bug fix. The start/stop 
functions would be implemented in a separate patch. They are also missing from 
the socket pktio implementations.

-Matias

> 
> >
> >   error:
> > netmap_close(pktio_entry);
> 
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCHv1 3/5] helper: table: add impl of lineartable

2015-10-19 Thread Maxim Uvarov

On 10/16/2015 12:35, huanggaoyang wrote:

Signed-off-by: huanggaoyang 
---
  helper/lineartable.c  | 211 ++
  helper/odph_lineartable.h |  42 +
  2 files changed, 253 insertions(+)
  create mode 100644 helper/lineartable.c
  create mode 100644 helper/odph_lineartable.h

diff --git a/helper/lineartable.c b/helper/lineartable.c
new file mode 100644
index 000..f04a2ca
--- /dev/null
+++ b/helper/lineartable.c
@@ -0,0 +1,211 @@
+/* Copyright (c) 2013, Linaro Limited

2015

+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:BSD-3-Clause
+ */
+
+#include 
+#include 
+#include 
+
+#include "odph_lineartable.h"
+#include "odph_debug.h"
+#include 
+
+#define ODPH_SUCCESS   0
+#define ODPH_FAIL  -1
+
+/** @magic word, write to the first byte of the memory block
+ *  to indicate this block is used by a linear table structure
+ */
+#define ODPH_LINEAR_TABLE_MAGIC_WORD   0xEFEFFEFE
+
+/**< @internal table struct
+ *   For linear table, value is orgnized as a big array,
+ *   and key is the index of this array, so we just need to record the
+ *   content of value, and make sure the key won't overflow
+ */
+typedef struct {
+   uint32_t magicword; /**< for check */
+   uint32_t init_cap; /**< input param of capacity */
+   /**< given the capacity, caculate out the max supported nodes number */
+   uint32_t node_sum;
+   /**< size of a lineartable element,including the rwlock in the head */
+   uint32_t value_size;
+   /**< value pool in array format */
+   void *value_array;
+   char name[ODPH_TABLE_NAME_LEN]; /**< name of the table */
+} odph_linear_table_imp;
+
+odph_table_t odph_linear_table_create(const char *name, uint32_t capacity,
+ uint32_t key_size, uint32_t value_size)

uint32_t ODP_IGNORED

+{
+   int idx;
+   uint32_t node_num;
+   odp_shm_t shmem;
+   odph_linear_table_imp *tbl;
+   /* Note: for linear table, key must be an number, its size is fixed 4.
+* So, we ignore the input key_size here
+*/
+   (void)key_size;

remove above line.

+
+   if (strlen(name) >= ODPH_TABLE_NAME_LEN || capacity < 1 ||
+   capacity >= 0x1000 || value_size == 0) {
+   printf("create para input error or less than !");
+   return NULL;
+   }
+   /* check name confict in shm*/
+   tbl = (odph_linear_table_imp *)odp_shm_addr(odp_shm_lookup(name));
+   if (tbl != NULL) {
+   ODPH_DBG("name already exist\n");
+   return NULL;
+   }
+
+   /* alloc memory from shm */
+   shmem = odp_shm_reserve(name, capacity << 20, 64, ODP_SHM_SW_ONLY);
+   if (shmem == ODP_SHM_INVALID) {
+   ODPH_DBG("shm reserve fail\n");
+   return NULL;
+   }
+   tbl = (odph_linear_table_imp *)odp_shm_addr(shmem);
+
+   /* clean this block of memory */
+   memset(tbl, 0, capacity << 20);
+
+   tbl->init_cap = capacity < 20;
+
+   strncpy(tbl->name, name, ODPH_TABLE_NAME_LEN);
+
+   /* for linear table, the key is just the index, without confict
+* so we just need to record the value content
+* there is a rwlock in the head of every node
+*/
+
+   tbl->value_size = value_size + sizeof(odp_rwlock_t);
+
+   node_num = tbl->init_cap / tbl->value_size;
+   tbl->node_sum = node_num;
+
+   tbl->value_array = (void *)((char *)tbl
+   + sizeof(odph_linear_table_imp));
+
+   /* initialize rwlock*/
+   for (idx = 0; idx < tbl->node_sum; idx++) {
+   odp_rwlock_t *lock = (odp_rwlock_t *)((char *)tbl->value_array
+   + idx * tbl->value_size);
+   odp_rwlock_init(lock);
+   }
+
+   tbl->magicword = ODPH_LINEAR_TABLE_MAGIC_WORD;
+
+   return (odph_table_t)(tbl);
+}
+
+int odph_linear_table_destroy(odph_table_t table)
+{
+   int ret;
+   odph_linear_table_imp *linear_tbl = NULL;
+
+   if (table != NULL) {
+   linear_tbl = (odph_linear_table_imp *)table;
+
+   /* check magicword, make sure the memory is used by a table */
+   if (linear_tbl->magicword != ODPH_LINEAR_TABLE_MAGIC_WORD)
+   return ODPH_FAIL;
+
+   ret = odp_shm_free(odp_shm_lookup(linear_tbl->name));
+   if (ret != 0) {
+   ODPH_DBG("free fail\n");
+   return ret;
+   }
+
+   return ODPH_SUCCESS;
+   }
+   return ODPH_FAIL;
+}
+
+odph_table_t odph_linear_table_lookup(const char *name)
+{
+   int idx;
+   odph_linear_table_imp *tbl;
+
+   if (name == NULL || strlen(name) >= ODPH_TABLE_NAME_LEN)
+   return NULL;
+
+   tbl = (odph_linear_table_imp *)odp_shm_addr(odp_shm_lookup(name));
+
+   /* check magicword to make sure the 

[lng-odp] [odp-lng][PATCH v0] test: performance: add crypto test

2015-10-19 Thread alexandru.badicioiu
From: Alexandru Badicioiu 

Test program to measure crypto operation performance.
Measures the time required to launch and get the result
of ODP crypto operations in async and sync API mode with
configurable payload size, crypto algorithms and iteration
number.
Both asynchronous scheduled and polled are supported.
In scheduled mode a separate worker thread is used to
get the crypto completion events.
Output packet can be reused as the input of the next
operation or a new packet can be allocated for each
operation.
Based on a previous work :
https://lists.linaro.org/pipermail/lng-odp/2014-September/003251.html.

Signed-off-by: Alexandru Badicioiu 
---
 test/performance/Makefile.am  |   5 +-
 test/performance/odp_cspeed.c | 946 ++
 2 files changed, 950 insertions(+), 1 deletion(-)
 create mode 100644 test/performance/odp_cspeed.c

diff --git a/test/performance/Makefile.am b/test/performance/Makefile.am
index 721615b..351dc97 100644
--- a/test/performance/Makefile.am
+++ b/test/performance/Makefile.am
@@ -2,7 +2,7 @@ include $(top_srcdir)/test/Makefile.inc
 
 TESTS_ENVIRONMENT += TEST_DIR=${builddir}
 
-EXECUTABLES = odp_atomic$(EXEEXT) odp_pktio_perf$(EXEEXT)
+EXECUTABLES = odp_atomic$(EXEEXT) odp_pktio_perf$(EXEEXT) odp_cspeed$(EXEEXT)
 
 COMPILE_ONLY = odp_l2fwd$(EXEEXT) \
   odp_scheduling$(EXEEXT)
@@ -20,6 +20,8 @@ odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static
 odp_atomic_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/test
 odp_scheduling_LDFLAGS = $(AM_LDFLAGS) -static
 odp_scheduling_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/test
+odp_cspeed_LDFLAGS = $(AM_LDFLAGS) -static
+odp_cspeed_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/test
 
 noinst_HEADERS = \
  $(top_srcdir)/test/test_debug.h
@@ -27,5 +29,6 @@ noinst_HEADERS = \
 dist_odp_atomic_SOURCES = odp_atomic.c
 dist_odp_scheduling_SOURCES = odp_scheduling.c
 dist_odp_pktio_perf_SOURCES = odp_pktio_perf.c
+dist_odp_cspeed_SOURCES = odp_cspeed.c
 
 EXTRA_DIST = $(TESTSCRIPTS)
diff --git a/test/performance/odp_cspeed.c b/test/performance/odp_cspeed.c
new file mode 100644
index 000..28ac1d5
--- /dev/null
+++ b/test/performance/odp_cspeed.c
@@ -0,0 +1,946 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:BSD-3-Clause
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif /* _GNU_SOURCE */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define app_err(fmt, ...) \
+   fprintf(stderr, "%s:%d:%s(): Error: " fmt, __FILE__, \
+   __LINE__, __func__, ##__VA_ARGS__)
+
+/** @def SHM_PKT_POOL_SIZE
+ * @brief Size of the shared memory block
+ */
+#define SHM_PKT_POOL_SIZE  (512 * 2048 * 2)
+
+/** @def SHM_PKT_POOL_BUF_SIZE
+ * @brief Buffer size of the packet pool buffer
+ */
+#define SHM_PKT_POOL_BUF_SIZE  (1024 * 32)
+
+static uint8_t test_iv[8] = "01234567";
+
+static uint8_t test_key16[16] = { 0x01, 0x02, 0x03, 0x04, 0x05,
+ 0x06, 0x07, 0x08, 0x09, 0x0a,
+ 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10,
+};
+
+static uint8_t test_key24[24] = { 0x01, 0x02, 0x03, 0x04, 0x05,
+ 0x06, 0x07, 0x08, 0x09, 0x0a,
+ 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14,
+ 0x15, 0x16, 0x17, 0x18
+};
+
+/**
+ * Structure that holds template for session create call
+ * for different algorithms supported by test
+ */
+typedef struct {
+   const char *name; /**< Algorithm name */
+   odp_crypto_session_params_t session;  /**< Prefilled crypto session 
params */
+   unsigned int hash_adjust; /**< Size of hash */
+} cspeed_alg_config_t;
+
+/**
+ * Parsed command line cspeed arguments. Describes test configuration.
+ */
+typedef struct {
+   /**
+* If non zero prints content of packets. Enabled by -d or
+* --debug option.
+*/
+   int debug_packets;
+
+   /**
+* If non zero Try to run crypto operation in place. Note some
+* implementation may not support such mode. Enabled by -n or
+* --inplace option.
+*/
+   int in_place;
+
+   /**
+* If non zeor output of previous operation taken as input for
+* next encrypt operations. Enabled by -r or --reuse option.
+*/
+   int reuse_packet;
+
+   /**
+* Maximum number of outstanding encryption requests. Note code
+* poll for results over queue and if nothing is available it can
+* submit more encryption requests up to maximum number specified by
+* this option. Specified through -f or --flight option.
+*/
+   int in_flight;
+
+   /**
+* Number of core to run on. Currently is 

Re: [lng-odp] [API-NEXT PATCH v4 0/5] api: time: unbind CPU cycles from time API

2015-10-19 Thread Ivan Khoronzhuk

Petri,
Could you please review this series.

On 15.10.15 16:02, Ivan Khoronzhuk wrote:

This seres is intended to unbind time API names from CPU "cycles".
Also remove usage of word "cycle" from appropriate places as it's
no more valid. This patch series only change API names and adds
calls required for that and doesn't add new API functionality.
API to get rate of time and delay call will be added separately as
they require to modify some examples and tests.

v3:
api: time: change API to use ticks instead of cycles
https://lists.linaro.org/pipermail/lng-odp/2015-August/014198.html

Since v3:
- don't use "tick" word in API names
- added opaque type odp_time_t
- added additional function: cmpr, sum, to_u64
- use "time stamp" word instead of "handle"
- described more clearly timestamps order in functions
- two new patches:
   performance: odp_pktio_perf: fix potential overflow in wait loop
   example: generator: compare ticks instead of ns in loop

Since v1, v2:
- changed series name a little bit
- added opaque type odp_time_t
- added missed spaces in printf
- removed legacy "count" words

Ivan Khoronzhuk (5):
   performance: odp_pktio_perf: fix potential overflow in wait loop
   example: generator: compare ticks instead of ns in loop
   api: time: unbind CPU cycles from time API
   linux-generic: align implementation with new time API
   test/example: avoid "cycle" word usage

  example/generator/odp_generator.c  | 14 ++---
  include/odp/api/time.h | 65 +-
  platform/linux-generic/Makefile.am |  1 +
  .../linux-generic/include/odp/plat/time_types.h| 36 
  platform/linux-generic/include/odp/time.h  |  1 +
  platform/linux-generic/odp_schedule.c  | 16 +++---
  platform/linux-generic/odp_time.c  | 62 +
  test/performance/odp_pktio_perf.c  | 56 ++-
  test/validation/pktio/pktio.c  | 20 +++
  test/validation/scheduler/scheduler.c  |  4 +-
  test/validation/time/time.c| 47 
  test/validation/time/time.h|  6 +-
  12 files changed, 225 insertions(+), 103 deletions(-)
  create mode 100644 platform/linux-generic/include/odp/plat/time_types.h



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


Re: [lng-odp] [PATCHv9 7/8] linux-generic: add ipc pktio support

2015-10-19 Thread Maxim Uvarov

On 10/19/2015 13:43, Stuart Haslam wrote:

On Mon, Oct 19, 2015 at 10:56:01AM +0300, Maxim Uvarov wrote:

On 10/16/2015 21:16, Stuart Haslam wrote:

It would be better to do away with the master/slave naming and instead use
names that match their function, e.g.; rx.recv/rx.free and tx.recv/tx.free

Stuart you have also about the same question bellow in the code. I also
don't line naming ipc.rx.recv and ipc.tx.free.

That is not rx or tx because of pkio is bidirectional. There is
process with creates
shm and processes which connect to that shm. They are very
symmetrical and difference
is only used flag and expected some information to be already
filled. I deceived to name
it master and slave. I.e. master is process which creates shm and
other processes which reuse it.

Yes I got that, I'm suggesting that the conditional check for whether
this end of the pktio is a master or a slave can be done only once at
open time rather than in every send/recv, since it doesn't change
after the open.

You have four rings with different uses depending on which end of the
link you're on -

m.prod   master: enqueue to send
  slave:  dequeue to recv
m.cons   master: dequeue to free transmitted packets
  slave:  enqueue to request free of received packets
s.prod   master: dequeue to recv
  slave:  enqueue to send
s.cons   master: enqueue to request free of received packets
  slave:  dequeue to free transmitted packets

So the pointers can be setup like this on open -

if (master) {
tx.send = m.prod;
tx.free = m.cons;
rx.recv = s.prod;
rx.free = s.cons;
} else {
tx.send = s.prod;
tx.free = s.cons;
rx.recv = m.prod;
rx.free = m.cons;
}

Obviously not exactly like that, but I hope you get the idea.


Ok, that looks reasonable.

Maxim.

Change name is easy find and replace in the patch. But we can try to
think which name is more
suitable. How about:

ipc.proc0
ipc.procX

ipc.parent
ipc.child

ipc.initial
ipc.secondary

ipc.batman
ipc.robin

?

In that version I support only 2 processes connected to each other
using single pktio. But we can update it
to use multi version. For that needed to export information about
3-rd process to first and second. It should
not be complex but I would like to do it in separate patch after
that series included.

Other comments looks reasonable. Will send updated patches.

Maxim.




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


Re: [lng-odp] [PATCH v3 0/6] l2fwd test improvements

2015-10-19 Thread Savolainen, Petri (Nokia - FI/Espoo)
Reviewed-by: Petri Savolainen 


> -Original Message-
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT
> Matias Elo
> Sent: Friday, October 16, 2015 4:01 PM
> To: lng-odp@lists.linaro.org
> Subject: [lng-odp] [PATCH v3 0/6] l2fwd test improvements
> 
> Added various improvements to the l2fwd test application:
> - Supports using odd number of ports
> - Scheduler queue type can be selected
> - Added options for enabling/disabling eth address filling
> 
> New options:
> -d, --dst_change <0/1>: Enable/disable changing packets' dst eth addresses
> -s, --src_change <0/1>: Enable/disable changing packets' src eth addresses
> -m, --mode <0>: Send packets directly from NIC (default)
><1>: Send packets through scheduler sync none queues
><2>: Send packets through scheduler sync atomic queues
><3>: Send packets through scheduler sync ordered queues
> 
> v2:
> - Rebased to master
> - Word copy ethernet addresses
> 
> v3:
> - Rebased to master
> 
> Matias Elo (6):
>   test: l2fwd: add option to change destination eth addresses
>   test: l2fwd: add option to select scheduler queue type
>   test: l2fwd: fix crash when accuracy is set to 0
>   test: l2fwd: add support for using odd number of ports
>   test: l2fwd: add option to disable filling eth addresses
>   test: l2fwd: word copy ethernet addresses
> 
>  test/performance/odp_l2fwd.c | 272 +--
> 
>  1 file changed, 183 insertions(+), 89 deletions(-)
> 
> --
> 1.9.1
> 
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] Bug 1851 - odp_pool_destroy() failure

2015-10-19 Thread Bill Fischofer
This is an important discussion, especially as we look to high-performance
SW implementations of ODP. Obviously we can stipulate any functional
behavior we want. The question is how much overhead is acceptable to
achieve such stipulated functionality? One of the reasons DPDK does not
support mempool destroys is this issue of distributed cache management. If
we don't want the application to take any responsibility in this area, then
the implementation needs to impose additional bookkeeping overhead that
will likely impact the performance of normal operation.

What's needed is some sort of indication that a thread is not just freeing
a buffer, but is done with operations on a pool. One way of doing this is
to add an odp_pool_finished() API that tells the implementation that this
thread is done with the pool (e.g., asserts that no further alloc() calls
will be made by this thread on it).  My suggestion in the response to the
bug was that odp_pool_destory() can serve this purpose, however I'd have no
problem with adding another API that serves the same notification purpose.

Without such an API, it's not clear how we can achieve the desired
functionality without a lot of additional overhead or removing any sort of
safety checks.  If the latter is acceptable, we could say that
odp_pool_destroy() always succeeds and if the application had any
outstanding buffers or tries to use the pool handle following a destroy()
call then the result is undefined.



On Mon, Oct 19, 2015 at 5:48 AM, Savolainen, Petri (Nokia - FI/Espoo) <
petri.savolai...@nokia.com> wrote:

> Hi,
>
> Linux-generic pool implementation has a bug (
> https://bugs.linaro.org/show_bug.cgi?id=1851 ) that prevents dynamic pool
> destroy. From API point of view, any resource (e.g. pool) is created once (
> xxx_create call returns a handle) and destroyed once (pass the handle to
> xxx_destroy). Any thread can create a resource and any thread can destroy
> it. Application threads  must synchronize resource usage and destroy call,
> but not implementation specifics like potential usage of per thread stashes
> or flush of those.
>
> For example, this valid usage of the pool API:
>
> Thread 1Thread 2  Thread 3
> --
>
> init_global()
> init_local()init_local()  init_local()
>
> pool = pool_create()
>
> barrier()   barrier() barrier()
> buf = alloc(pool)   buf = alloc(pool) buf = alloc(pool)
> free(buf)   free(buf) free(buf)
> barrier()   barrier() barrier()
>
> pool_destroy(pool)
>
> barrier()   barrier() barrier()
> do_something()  do_something()do_something()
> term_local()term_local()  term_local()
>   term_global()
>
>
> So, e.g. pool_destroy must succeed when all buffers have been freed before
> the call - no matter:
> * which thread calls it
> * has the calling thread itself called alloc or free
> * have other threads called already term_local
>
>
> -Petri
>
>
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [Bug 1854] New: CID 152857: Error handling issues: odp_pktio_term_global

2015-10-19 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=1854

Bug ID: 1854
   Summary: CID 152857:  Error handling issues:
odp_pktio_term_global
   Product: OpenDataPlane - linux- generic reference
   Version: 1.3
  Hardware: Other
OS: Linux
Status: UNCONFIRMED
  Severity: enhancement
  Priority: ---
 Component: Packet IO
  Assignee: maxim.uva...@linaro.org
  Reporter: mike.hol...@linaro.org
CC: lng-odp@lists.linaro.org

/platform/linux-generic/odp_packet_io.c: 96 in odp_pktio_term_global()
90  int ret = 0;
91  int id;
92  int pktio_if;
93
94  for (id = 1; id <= ODP_CONFIG_PKTIO_ENTRIES; ++id) {
95  pktio_entry = _tbl->entries[id - 1];
>>> CID 152857:  Error handling issues  (CHECKED_RETURN)
>>> Calling "odp_pktio_close" without checking return value (as is done 
>>> elsewhere 12 out of 13 times).
96  odp_pktio_close(pktio_entry->s.handle);
97  odp_queue_destroy(pktio_entry->s.outq_default);
98  }
99
100 for (pktio_if = 0; pktio_if_ops[pktio_if]; ++pktio_if) {
101 if (pktio_if_ops[pktio_if]->term)

-- 
You are receiving this mail because:
You are on the CC list for the bug.___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH] validation: pktio: check that packet_len is smaller than MTU

2015-10-19 Thread Stuart Haslam
On Fri, Oct 16, 2015 at 10:06:13AM +0200, Nicolas Morey-Chaisemartin wrote:
> Before sending/receiving packet, check that the packet_len configured
>  is supported by the pktios MTU.
> This allows interface that do not support jumbo frame to pass the test.
> However it has the bad side effect of not thoroughly checking the
> pktio if PKT_LEN_NORMAL is smaller than the MTU.

This test does a similar thing;

http://patches.opendataplane.org/patch/3294/

But the test is reported as being inactive rather than just not running
it and reporting it as passed. It depends on the ODP_CUNIT_INFO_CONDITIONAL
series that was merged last week;

http://patches.opendataplane.org/patch/3273/

With that you could make pktio_test_jumbo conditional and leave all
non-jumbo tests unchanged.

> 
> Signed-off-by: Nicolas Morey-Chaisemartin 
> ---
>  test/validation/pktio/pktio.c | 16 
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
> index 5c0799b..8fadbf7 100644
> --- a/test/validation/pktio/pktio.c
> +++ b/test/validation/pktio/pktio.c
> @@ -455,6 +455,7 @@ static void test_txrx(odp_queue_type_t q_type, int 
> num_pkts)
>   int ret, i, if_b;
>   pktio_info_t pktios[MAX_NUM_IFACES];
>   pktio_info_t *io;
> + uint32_t mtu, min_mtu = UINT32_MAX;
>  
>   /* create pktios and associate input/output queues */
>   for (i = 0; i < num_ifaces; ++i) {
> @@ -475,12 +476,19 @@ static void test_txrx(odp_queue_type_t q_type, int 
> num_pkts)
>  
>   ret = odp_pktio_start(io->id);
>   CU_ASSERT(ret == 0);
> +
> + mtu = odp_pktio_mtu(io->id);
> + if (mtu < min_mtu)
> + min_mtu = mtu;
>   }
>  
> - /* if we have two interfaces then send through one and receive on
> -  * another but if there's only one assume it's a loopback */
> - if_b = (num_ifaces == 1) ? 0 : 1;
> - pktio_txrx_multi([0], [if_b], num_pkts);
> + /* Skip test if packet len is larger than the MTU */
> + if (min_mtu >= packet_len) {
> + /* if we have two interfaces then send through one and receive
> +  * on another but if there's only one assume it's a loopback */
> + if_b = (num_ifaces == 1) ? 0 : 1;
> + pktio_txrx_multi([0], [if_b], num_pkts);
> + }
>  
>   for (i = 0; i < num_ifaces; ++i) {
>   destroy_inq(pktios[i].id);
> -- 
> 2.6.1.3.g8d02103
> 
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCHv2 2/5] helper: table: add impl of hashtable

2015-10-19 Thread huanggaoyang
Signed-off-by: huanggaoyang 
---
 helper/hashtable.c  | 346 
 helper/odph_hashtable.h |  42 ++
 helper/odph_list_internal.h |  85 +++
 3 files changed, 473 insertions(+)
 create mode 100644 helper/hashtable.c
 create mode 100644 helper/odph_hashtable.h
 create mode 100644 helper/odph_list_internal.h

diff --git a/helper/hashtable.c b/helper/hashtable.c
new file mode 100644
index 000..e49c63b
--- /dev/null
+++ b/helper/hashtable.c
@@ -0,0 +1,346 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:   BSD-3-Clause
+ */
+#include 
+#include 
+#include 
+
+#include "odph_hashtable.h"
+#include "odph_list_internal.h"
+#include "odph_debug.h"
+#include 
+
+#defineODPH_SUCCESS0
+#defineODPH_FAIL   -1
+
+/** @magic word, write to the first byte of the memory block
+ * to indicate this block is used by a hash table structure
+ */
+#defineODPH_HASH_TABLE_MAGIC_WORD  0xABABBABA
+
+/** @support 64k buckets. Bucket is a list that composed of
+ * elements with the same HASH-value but different keys
+ */
+#defineODPH_MAX_BUCKET_NUM 0x1
+
+/** @inner element structure of hash table
+ * To resolve the hash confict:
+ * we put the elements with different keys but a same HASH-value
+ * into a list
+ */
+typedef struct odph_hash_node {
+   /**< list structure,for list opt */
+   odph_list_object list_node;
+   /**< Flexible Array,memory will be alloced when table has been created
+* Its length is key_size + value_size,
+* suppose key_size = m; value_size = n;
+* its structure is like:
+* k_byte1 k_byte2...k_byten v_byte1...v_bytem
+*/
+   char content[0];
+} odph_hash_node;
+
+typedef struct {
+   uint32_t magicword; /**< for check */
+   uint32_t key_size; /**< input param when create,in Bytes */
+   uint32_t value_size; /**< input param when create,in Bytes */
+   uint32_t init_cap; /**< input param when create,in Bytes */
+   /**< multi-process support,every list has one rw lock */
+   odp_rwlock_t *lock_pool;
+   /**< table bucket pool,every hash value has one list head */
+   odph_list_head *list_head_pool;
+   /**< number of the list head in list_head_pool */
+   uint32_t head_num;
+   /**< table element pool */
+   odph_hash_node *hash_node_pool;
+   /**< number of element in the hash_node_pool */
+   uint32_t hash_node_num;
+   char rsv[7]; /**< Reserved,for alignment */
+   char name[ODPH_TABLE_NAME_LEN]; /**< table name */
+} odph_hash_table_imp;
+
+odph_table_t odph_hash_table_create(const char *name, uint32_t capacity,
+   uint32_t key_size,
+   uint32_t value_size)
+{
+   int idx, i;
+   uint32_t node_num;
+   odph_hash_table_imp *tbl;
+   odp_shm_t shmem;
+   uint32_t node_mem;
+
+   if (strlen(name) >= ODPH_TABLE_NAME_LEN || capacity < 1 ||
+   capacity >= 0x1000 || key_size == 0 || value_size == 0) {
+   ODPH_DBG("create para input error!\n");
+   return NULL;
+   }
+   tbl = (odph_hash_table_imp *)odp_shm_addr(odp_shm_lookup(name));
+   if (tbl != NULL) {
+   ODPH_DBG("name already exist\n");
+   return NULL;
+   }
+   shmem = odp_shm_reserve(name, capacity << 20, 64, ODP_SHM_SW_ONLY);
+   if (shmem == ODP_SHM_INVALID) {
+   ODPH_DBG("shm reserve fail\n");
+   return NULL;
+   }
+   tbl = (odph_hash_table_imp *)odp_shm_addr(shmem);
+
+   /* clean this block of memory */
+   memset(tbl, 0, capacity << 20);
+
+   tbl->init_cap = capacity << 20;
+   strncpy(tbl->name, name, ODPH_TABLE_NAME_LEN);
+   tbl->key_size = key_size;
+   tbl->value_size = value_size;
+
+   /* header of this mem block is the table control struct,
+* then the lock pool, then the list header pool
+* the last part is the element node pool
+*/
+
+   tbl->lock_pool = (odp_rwlock_t *)((char *)tbl
+   + sizeof(odph_hash_table_imp));
+   tbl->list_head_pool = (odph_list_head *)((char *)tbl->lock_pool
+   + ODPH_MAX_BUCKET_NUM * sizeof(odp_rwlock_t));
+
+   node_mem = tbl->init_cap - sizeof(odph_hash_table_imp)
+   - ODPH_MAX_BUCKET_NUM * sizeof(odph_list_head)
+   - ODPH_MAX_BUCKET_NUM * sizeof(odp_rwlock_t);
+
+   node_num = node_mem / (sizeof(odph_hash_node) + key_size + value_size);
+   tbl->hash_node_num = node_num;
+   tbl->hash_node_pool = (odph_hash_node *)((char *)tbl->list_head_pool
+   + ODPH_MAX_BUCKET_NUM * sizeof(odph_list_head));
+
+   /* init every list head and rw lock */
+   for (i = 0; i < ODPH_MAX_BUCKET_NUM; i++) {
+   

[lng-odp] Bug 1851 - odp_pool_destroy() failure

2015-10-19 Thread Savolainen, Petri (Nokia - FI/Espoo)
Hi,

Linux-generic pool implementation has a bug ( 
https://bugs.linaro.org/show_bug.cgi?id=1851 ) that prevents dynamic pool 
destroy. From API point of view, any resource (e.g. pool) is created once ( 
xxx_create call returns a handle) and destroyed once (pass the handle to 
xxx_destroy). Any thread can create a resource and any thread can destroy it. 
Application threads  must synchronize resource usage and destroy call, but not 
implementation specifics like potential usage of per thread stashes or flush of 
those.

For example, this valid usage of the pool API:

Thread 1Thread 2  Thread 3
--

init_global()
init_local()init_local()  init_local()

pool = pool_create()

barrier()   barrier() barrier()
buf = alloc(pool)   buf = alloc(pool) buf = alloc(pool)
free(buf)   free(buf) free(buf)
barrier()   barrier() barrier()

pool_destroy(pool)

barrier()   barrier() barrier()
do_something()  do_something()do_something()
term_local()term_local()  term_local()
  term_global()


So, e.g. pool_destroy must succeed when all buffers have been freed before the 
call - no matter:
* which thread calls it
* has the calling thread itself called alloc or free
* have other threads called already term_local


-Petri


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


Re: [lng-odp] [PATCHv9 7/8] linux-generic: add ipc pktio support

2015-10-19 Thread Maxim Uvarov

On 10/16/2015 21:16, Stuart Haslam wrote:

And a more general question, are multiple slaves supported or is this
intended to be a 1-1 pipe? I can't see anything explicitly preventing
multiple slaves but it looks like all slaves would map the same rings.
The rings as accessed with mp/mc safe functions so I guess it will work
but the master/slave relationship is exposed (packets sent be the master
go to only one of the slaves, all packets sent by the slaves go to the
master) but the application has no way of knowing which it is.

I want to have separate patch for it.

In general needed some array  for rings + process identifier in main
shared memory.

| p0 packet pool |
| p0 tx ring|
| p0 rx ring|
| p1 packet pool |
| p1 tx ring|
| p1 rx ring|
| p2 packet pool |
| p2 tx ring |
| p2 rx ring |

Because of p0 (process 0) can place packet to p1 and p2 it has to be 
connected with it's own

rx/tx link (which is done as odp ring). So it will be something like:

| p0 packet pool |
| int number of processes |
| p0 tx ring array |
| p0 rx ring array |

Plus some notification that new process opened pktio with the same name 
and want to connect to it.


But because it's not clear for me how to define which process should 
take packet in case if there are several
processes then I think first version is reasonable to be 1-1. Assuming 
that you can create banch of different pktios ipc-1, ipc-2, ipc-3 and etc.
If we will accept Nikitas idea to support hw queues for pktio, that I 
can reuse that api for ipc.


Maxim.





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


Re: [lng-odp] [PATCHv9 7/8] linux-generic: add ipc pktio support

2015-10-19 Thread Stuart Haslam
On Mon, Oct 19, 2015 at 10:56:01AM +0300, Maxim Uvarov wrote:
> On 10/16/2015 21:16, Stuart Haslam wrote:
> >It would be better to do away with the master/slave naming and instead use
> >names that match their function, e.g.; rx.recv/rx.free and tx.recv/tx.free
> 
> Stuart you have also about the same question bellow in the code. I also
> don't line naming ipc.rx.recv and ipc.tx.free.
> 
> That is not rx or tx because of pkio is bidirectional. There is
> process with creates
> shm and processes which connect to that shm. They are very
> symmetrical and difference
> is only used flag and expected some information to be already
> filled. I deceived to name
> it master and slave. I.e. master is process which creates shm and
> other processes which reuse it.

Yes I got that, I'm suggesting that the conditional check for whether
this end of the pktio is a master or a slave can be done only once at
open time rather than in every send/recv, since it doesn't change
after the open.

You have four rings with different uses depending on which end of the
link you're on -

m.prod   master: enqueue to send
 slave:  dequeue to recv
m.cons   master: dequeue to free transmitted packets
 slave:  enqueue to request free of received packets
s.prod   master: dequeue to recv
 slave:  enqueue to send
s.cons   master: enqueue to request free of received packets
 slave:  dequeue to free transmitted packets

So the pointers can be setup like this on open -

if (master) {
tx.send = m.prod;
tx.free = m.cons;
rx.recv = s.prod;
rx.free = s.cons;
} else {
tx.send = s.prod;
tx.free = s.cons;
rx.recv = m.prod;
rx.free = m.cons;
}

Obviously not exactly like that, but I hope you get the idea.

> 
> Change name is easy find and replace in the patch. But we can try to
> think which name is more
> suitable. How about:
> 
> ipc.proc0
> ipc.procX
> 
> ipc.parent
> ipc.child
> 
> ipc.initial
> ipc.secondary
> 
> ipc.batman
> ipc.robin
> 
> ?
> 
> In that version I support only 2 processes connected to each other
> using single pktio. But we can update it
> to use multi version. For that needed to export information about
> 3-rd process to first and second. It should
> not be complex but I would like to do it in separate patch after
> that series included.
> 
> Other comments looks reasonable. Will send updated patches.
> 
> Maxim.
> 
> 
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCHv2 3/5] helper: table: add impl of lineartable

2015-10-19 Thread huanggaoyang
Signed-off-by: huanggaoyang 
---
 helper/lineartable.c  | 211 ++
 helper/odph_lineartable.h |  41 +
 2 files changed, 252 insertions(+)
 create mode 100644 helper/lineartable.c
 create mode 100644 helper/odph_lineartable.h

diff --git a/helper/lineartable.c b/helper/lineartable.c
new file mode 100644
index 000..4dacdb3
--- /dev/null
+++ b/helper/lineartable.c
@@ -0,0 +1,211 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:BSD-3-Clause
+ */
+
+#include 
+#include 
+#include 
+
+#include "odph_lineartable.h"
+#include "odph_debug.h"
+#include 
+
+#define ODPH_SUCCESS   0
+#define ODPH_FAIL  -1
+
+/** @magic word, write to the first byte of the memory block
+ *  to indicate this block is used by a linear table structure
+ */
+#define ODPH_LINEAR_TABLE_MAGIC_WORD   0xEFEFFEFE
+
+/**< @internal table struct
+ *   For linear table, value is orgnized as a big array,
+ *   and key is the index of this array, so we just need to record the
+ *   content of value, and make sure the key won't overflow
+ */
+typedef struct {
+   uint32_t magicword; /**< for check */
+   uint32_t init_cap; /**< input param of capacity */
+   /**< given the capacity, caculate out the max supported nodes number */
+   uint32_t node_sum;
+   /**< size of a lineartable element,including the rwlock in the head */
+   uint32_t value_size;
+   /**< value pool in array format */
+   void *value_array;
+   char name[ODPH_TABLE_NAME_LEN]; /**< name of the table */
+} odph_linear_table_imp;
+
+/** Note: for linear table, key must be an number, its size is fixed 4.
+ *  So, we ignore the input key_size here
+ */
+
+odph_table_t odph_linear_table_create(const char *name, uint32_t capacity,
+ uint32_t ODP_IGNORED, uint32_t value_size)
+{
+   int idx;
+   uint32_t node_num;
+   odp_shm_t shmem;
+   odph_linear_table_imp *tbl;
+
+   if (strlen(name) >= ODPH_TABLE_NAME_LEN || capacity < 1 ||
+   capacity >= 0x1000 || value_size == 0) {
+   printf("create para input error or less than !");
+   return NULL;
+   }
+   /* check name confict in shm*/
+   tbl = (odph_linear_table_imp *)odp_shm_addr(odp_shm_lookup(name));
+   if (tbl != NULL) {
+   ODPH_DBG("name already exist\n");
+   return NULL;
+   }
+
+   /* alloc memory from shm */
+   shmem = odp_shm_reserve(name, capacity << 20, 64, ODP_SHM_SW_ONLY);
+   if (shmem == ODP_SHM_INVALID) {
+   ODPH_DBG("shm reserve fail\n");
+   return NULL;
+   }
+   tbl = (odph_linear_table_imp *)odp_shm_addr(shmem);
+
+   /* clean this block of memory */
+   memset(tbl, 0, capacity << 20);
+
+   tbl->init_cap = capacity < 20;
+
+   strncpy(tbl->name, name, ODPH_TABLE_NAME_LEN);
+
+   /* for linear table, the key is just the index, without confict
+* so we just need to record the value content
+* there is a rwlock in the head of every node
+*/
+
+   tbl->value_size = value_size + sizeof(odp_rwlock_t);
+
+   node_num = tbl->init_cap / tbl->value_size;
+   tbl->node_sum = node_num;
+
+   tbl->value_array = (void *)((char *)tbl
+   + sizeof(odph_linear_table_imp));
+
+   /* initialize rwlock*/
+   for (idx = 0; idx < tbl->node_sum; idx++) {
+   odp_rwlock_t *lock = (odp_rwlock_t *)((char *)tbl->value_array
+   + idx * tbl->value_size);
+   odp_rwlock_init(lock);
+   }
+
+   tbl->magicword = ODPH_LINEAR_TABLE_MAGIC_WORD;
+
+   return (odph_table_t)(tbl);
+}
+
+int odph_linear_table_destroy(odph_table_t table)
+{
+   int ret;
+   odph_linear_table_imp *linear_tbl = NULL;
+
+   if (table != NULL) {
+   linear_tbl = (odph_linear_table_imp *)table;
+
+   /* check magicword, make sure the memory is used by a table */
+   if (linear_tbl->magicword != ODPH_LINEAR_TABLE_MAGIC_WORD)
+   return ODPH_FAIL;
+
+   ret = odp_shm_free(odp_shm_lookup(linear_tbl->name));
+   if (ret != 0) {
+   ODPH_DBG("free fail\n");
+   return ret;
+   }
+
+   return ODPH_SUCCESS;
+   }
+   return ODPH_FAIL;
+}
+
+odph_table_t odph_linear_table_lookup(const char *name)
+{
+   int idx;
+   odph_linear_table_imp *tbl;
+
+   if (name == NULL || strlen(name) >= ODPH_TABLE_NAME_LEN)
+   return NULL;
+
+   tbl = (odph_linear_table_imp *)odp_shm_addr(odp_shm_lookup(name));
+
+   /* check magicword to make sure the memory block is used by a table */
+   if (tbl != NULL &&
+   tbl->magicword == ODPH_LINEAR_TABLE_MAGIC_WORD &&
+   

Re: [lng-odp] [API-NEXT PATCH] api: clib: added standard c library api

2015-10-19 Thread Jerin Jacob
On Fri, Oct 16, 2015 at 03:13:48PM +0300, Petri Savolainen wrote:
> Some C library calls are often used in data plane code. This
> API enables possibility to HW optimized implementation of those.
> Added first memcpy and memset.
> 
> Signed-off-by: Petri Savolainen 

Reviewed-by: Jerin Jacob 

> ---
>  include/odp.h |  1 +
>  include/odp/api/std_clib.h| 64 
> +++
>  platform/linux-generic/Makefile.am|  2 +
>  platform/linux-generic/include/odp/std_clib.h | 30 +
>  4 files changed, 97 insertions(+)
>  create mode 100644 include/odp/api/std_clib.h
>  create mode 100644 platform/linux-generic/include/odp/std_clib.h
> 
> diff --git a/include/odp.h b/include/odp.h
> index 825c7e1..f2cd2d3 100644
> --- a/include/odp.h
> +++ b/include/odp.h
> @@ -56,6 +56,7 @@ extern "C" {
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #ifdef __cplusplus
>  }
> diff --git a/include/odp/api/std_clib.h b/include/odp/api/std_clib.h
> new file mode 100644
> index 000..2119ec4
> --- /dev/null
> +++ b/include/odp/api/std_clib.h
> @@ -0,0 +1,64 @@
> +/* Copyright (c) 2015, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier: BSD-3-Clause
> + */
> +
> +/**
> + * @file
> + *
> + * ODP version of often used C library calls
> + */
> +
> +#ifndef ODP_API_STD_CLIB_H_
> +#define ODP_API_STD_CLIB_H_
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +/**
> + * @defgroup odp_std_clib ODP STD CLIB
> + * @details
> + * ODP version of often used C library calls
> + * @{
> + */
> +
> +/**
> + * Memcpy
> + *
> + * ODP version of C library memcpy function. It copies 'num' bytes from 
> source
> + * to destination address. Source and destination memory blocks must not
> + * overlap.
> + *
> + * @param dstPointer to destination memory block
> + * @param srcPointer to source memory block
> + * @param numNumber of bytes to copy
> + *
> + * @return 'dst' address
> + */
> +void *odp_memcpy(void *dst, const void *src, size_t num);
> +
> +/**
> + * Memset
> + *
> + * ODP version of C library memset function. It sets 'value' to first 'num'
> + * bytes of memory block pointed by 'ptr'.
> + *
> + * @param ptrPointer to the memory block
> + * @param value  Value to be set
> + * @param numNumber of bytes to set
> + *
> + * @return 'ptr' address
> + */
> +void *odp_memset(void *ptr, int value, size_t num);
> +
> +/**
> + * @}
> + */
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> diff --git a/platform/linux-generic/Makefile.am 
> b/platform/linux-generic/Makefile.am
> index 85c976d..fc202cc 100644
> --- a/platform/linux-generic/Makefile.am
> +++ b/platform/linux-generic/Makefile.am
> @@ -41,6 +41,7 @@ odpinclude_HEADERS = \
> $(srcdir)/include/odp/shared_memory.h \
> $(srcdir)/include/odp/spinlock.h \
> $(srcdir)/include/odp/spinlock_recursive.h \
> +   $(srcdir)/include/odp/std_clib.h \
> $(srcdir)/include/odp/std_types.h \
> $(srcdir)/include/odp/sync.h \
> $(srcdir)/include/odp/system_info.h \
> @@ -108,6 +109,7 @@ odpapiinclude_HEADERS = \
> $(top_srcdir)/include/odp/api/shared_memory.h \
> $(top_srcdir)/include/odp/api/spinlock.h \
> $(top_srcdir)/include/odp/api/spinlock_recursive.h \
> +   $(top_srcdir)/include/odp/api/std_clib.h \
> $(top_srcdir)/include/odp/api/std_types.h \
> $(top_srcdir)/include/odp/api/sync.h \
> $(top_srcdir)/include/odp/api/system_info.h \
> diff --git a/platform/linux-generic/include/odp/std_clib.h 
> b/platform/linux-generic/include/odp/std_clib.h
> new file mode 100644
> index 000..c939c48
> --- /dev/null
> +++ b/platform/linux-generic/include/odp/std_clib.h
> @@ -0,0 +1,30 @@
> +/* Copyright (c) 2015, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier: BSD-3-Clause
> + */
> +
> +#ifndef ODP_PLAT_STD_CLIB_H_
> +#define ODP_PLAT_STD_CLIB_H_
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#include 
> +
> +static inline void *odp_memcpy(void *dst, const void *src, size_t num)
> +{
> + return memcpy(dst, src, num);
> +}
> +
> +static inline void *odp_memset(void *ptr, int value, size_t num)
> +{
> + return memset(ptr, value, num);
> +}
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> -- 
> 2.6.0
> 
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCHv2 5/5] helper: test add a simple test case for hashtable

2015-10-19 Thread huanggaoyang
Signed-off-by: huanggaoyang 
---
 helper/test/odp_table.c | 134 
 1 file changed, 134 insertions(+)
 create mode 100644 helper/test/odp_table.c

diff --git a/helper/test/odp_table.c b/helper/test/odp_table.c
new file mode 100644
index 000..16de165
--- /dev/null
+++ b/helper/test/odp_table.c
@@ -0,0 +1,134 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:BSD-3-Clause
+ */
+
+#include 
+#include <../odph_hashtable.h>
+#include <../odph_lineartable.h>
+#include 
+
+/**
+ * Address Resolution Protocol (ARP)
+ * Description: Once a route has been identified for an IP packet (so the
+ * output interface and the IP address of the next hop station are known),
+ * the MAC address of the next hop station is needed in order to send this
+ * packet onto the next leg of the journey towards its destination
+ * (as identified by its destination IP address). The MAC address of the next
+ * hop station becomes the destination MAC address of the outgoing
+ * Ethernet frame.
+ * Hash table name: ARP table
+ * Number of keys: Thousands
+ * Key format: The pair of (Output interface, Next Hop IP address),
+ *which is typically 5 bytes for IPv4 and 17 bytes for IPv6.
+ * value (data): MAC address of the next hop station (6 bytes).
+ */
+
+int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED)
+{
+   int ret = 0;
+   odph_table_t table;
+   odph_table_t tmp_tbl;
+   struct odp_table_ops *test_ops;
+   char tmp[32];
+   char ip_addr1[] = "12345678";
+   char ip_addr2[] = "11223344";
+   char ip_addr3[] = "55667788";
+   char mac_addr1[] = "0A1122334401";
+   char mac_addr2[] = "0A1122334402";
+   char mac_addr3[] = "0B4433221101";
+   char mac_addr4[] = "0B4433221102";
+
+   ret = odp_init_global(NULL, NULL);
+   if (ret != 0) {
+   LOG_ERR("odp_shm_init_global fail\n");
+   exit(EXIT_FAILURE);
+   }
+   ret = odp_init_local(ODP_THREAD_WORKER);
+   if (ret != 0) {
+   LOG_ERR("odp_shm_init_local fail\n");
+   exit(EXIT_FAILURE);
+   }
+
+   printf("test hash table:\n");
+   test_ops = _hash_table_ops;
+
+   table = test_ops->f_create("test", 2, 4, 16);
+   if (table == NULL) {
+   printf("table create fail\n");
+   return -1;
+   }
+   ret += test_ops->f_put(table, _addr1, mac_addr1);
+
+   ret += test_ops->f_put(table, _addr2, mac_addr2);
+
+   ret += test_ops->f_put(table, _addr3, mac_addr3);
+
+   if (ret != 0) {
+   printf("put value fail\n");
+   return -1;
+   }
+
+   ret = test_ops->f_get(table, _addr1, , 32);
+   if (ret != 0) {
+   printf("get value fail\n");
+   return -1;
+   }
+   printf("\t1  get '123' tmp = %s,\n", tmp);
+
+   ret = test_ops->f_put(table, _addr1, mac_addr4);
+   if (ret != 0) {
+   printf("repeat put value fail\n");
+   return -1;
+   }
+
+   ret = test_ops->f_get(table, _addr1, , 32);
+   if (ret != 0 || strcmp(tmp, mac_addr4) != 0) {
+   printf("get value fail\n");
+   return -1;
+   }
+
+   printf("\t2  repeat get '123' value = %s\n", tmp);
+
+   ret = test_ops->f_remove(table, _addr1);
+   if (ret != 0) {
+   printf("remove value fail\n");
+   return -1;
+   }
+   ret = test_ops->f_get(table, _addr1, tmp, 32);
+   if (ret == 0) {
+   printf("remove value fail actually\n");
+   return -1;
+   }
+   printf("\t3  remove success!\n");
+
+   tmp_tbl = test_ops->f_lookup("test");
+   if (tmp_tbl != table) {
+   printf("lookup table fail!!!\n");
+   return -1;
+   }
+   printf("\t4  lookup table success!\n");
+
+   ret = test_ops->f_des(table);
+   if (ret != 0) {
+   printf("destroy table fail!!!\n");
+   exit(EXIT_FAILURE);
+   }
+   printf("\t5  destroy table success!\n");
+
+   printf("all test finished success!!\n");
+
+   if (odp_term_local()) {
+   LOG_ERR("Error: ODP local term failed.\n");
+   exit(EXIT_FAILURE);
+   }
+
+   if (odp_term_global()) {
+   LOG_ERR("Error: ODP global term failed.\n");
+   exit(EXIT_FAILURE);
+   }
+
+   return 0;
+}
+
-- 
1.9.1


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


[lng-odp] [PATCHv2 1/5] helper: add table api

2015-10-19 Thread huanggaoyang
Signed-off-by: huanggaoyang 
---
 helper/include/odp/helper/table.h | 166 ++
 1 file changed, 166 insertions(+)
 create mode 100644 helper/include/odp/helper/table.h

diff --git a/helper/include/odp/helper/table.h 
b/helper/include/odp/helper/table.h
new file mode 100644
index 000..80a5ae1
--- /dev/null
+++ b/helper/include/odp/helper/table.h
@@ -0,0 +1,166 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP table
+ *
+ * Table designed to provide a standard interface to implement different
+ * types of tables for data processing.
+ * Use case:
+ * Table is publicly used in the following scenarios in data plane:
+ * ARP Table, IP Routing Table, MAC address filtering, ACL, interworking etc.
+ * The features of the "table":
+ * 1) All these different types of "table" have the common operations:
+ *Create a table, destroy a table, add an entry (key/value pairs),
+ *delete an entry, and lookup the value via the key.
+ *Usually these operations are software based, but also can be
+ *hardware accelerated if cost, power consumption are not the concern
+ *in your platform.
+ * 2) Different types of "table" can use different algorithms to
+ *add/delete/lookup the entry.
+ *
+ */
+
+#ifndef ODPH_TABLE_H_
+#define ODPH_TABLE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ODPH_TABLE_NAME_LEN  32
+
+typedef ODP_HANDLE_T(odph_table_t);
+
+/**
+* create a table
+* Generally, tables only support key-value pair both with fixed size
+*
+* @param name
+*name of this table, max ODPH_TABLE_NAME_LEN - 1
+*May be specified as NULL for anonymous table
+* @param capacity
+*Max memory usage this table use, in MBytes
+* @param key_size
+*fixed size of the 'key' in bytes.
+* @param value_size
+*fixed size of the 'value' in bytes.
+* @return
+*   Handle to table instance or NULL if failed
+* @note
+*/
+typedef odph_table_t (*odph_table_create)(const char *name,
+   uint32_t capacity,
+   uint32_t key_size,
+   uint32_t value_size);
+
+/**
+ * Find a table by name
+ *
+ * @param name:  Name of the table
+ *
+ * @return Handle of found table
+ * @retval NULL  table could not be found
+ *
+ * @note
+ * This routine cannot be used to look up an anonymous
+ * table (one created with no name).
+ * This API supports Multiprocess
+ */
+typedef odph_table_t (*odph_table_lookup)(const char *name);
+
+/**
+ * Destroy a table previously created by odph_table_create()
+ *
+ * @param table: Handle of the table to be destroyed
+ *
+ * @retval 0 Success
+ * @retval -1 Failure
+ *
+ * @note
+ *   This routine destroys a previously created pool
+ *   also should free any memory allocated at creation
+ *
+ */
+typedef int (*odph_table_destroy)(odph_table_t table);
+
+/**
+ * table element add
+ *
+ * @param table:Handle of the table that the element be added
+ *
+ * @param key : address of 'key' in key-value pair.
+ *  User should make sure the address and 'key_size' bytes after
+ *  are accessible
+ * @param value : address of 'value' in key-value pair
+ *  User should make sure the address and 'value_size' bytes after
+ *  are accessible
+ * @retval 0 Success
+ * @retval -1 Failure
+ *
+ * @note: Add a same key again with a new value, the older one will be covered.
+ *This API supports Multiprocess
+ */
+typedef int (*odph_table_put_value)(odph_table_t table, void *key,
+   void *value);
+
+/**
+ * table element lookup
+ *
+ * @param table: Handle of the table that the element be added
+ *
+ * @param key : address of 'key' in key-value pair
+ *  User should make sure the address and key_size bytes after
+ *  are accessible
+ *
+ * @param buffer : output The buffer address to the 'value'
+ * After successfully found, the content of 'value' will be
+ * copied to this address
+ * User should make sure the address and value_size bytes after
+ * are accessible
+ * @param buffer_size: size of the buffer
+ * should be equal or bigger than value_size
+ * @retval 0 Success
+ * @retval -1 Failure
+ *
+ * @note: This API supports Multiprocess
+ */
+typedef int (*odph_table_get_value)(odph_table_t table, void *key,
+   void *buffer,
+   uint32_t buffer_size);
+/**
+ * table element remove
+ *
+ * @param table: Handle of the table that the element will be removed from
+ *
+ * @param key : address of 'key' in key-value pair
+ *  User should make sure the address and key_size 

[lng-odp] [PATCH][PATCHv2 0/5] helper: add table module

2015-10-19 Thread huanggaoyang
thank you for carefully reviewing on my last patch, pointing out mistakes 
in Copyright.

v1: helper: added base api of Table
added two impls of Table:hash table & linear table

v2: 1. fix mistakes in Copyright Info of files
2. change the name of an useless param of function odph_linear_table_create
   to ODP_IGNORED 

Table designed to provide a standard interface to implement different
 types of tables for data processing.
 Use case:
 Table is publicly used in the following scenarios in data plane:
 ARP Table, IP Routing Table, MAC address filtering, ACL, interworking etc.
 The features of the "table":
 1) All these different types of "table" have the common operations:
 Create a table, destroy a table, add an entry (key/value pairs),
 delete an entry, and lookup the value via the key.
 Usually these operations are software based, but also can be
 hardware accelerated if cost, power consumption are not the concern
 in your platform.
 2) Different types of "table" can use different algorithms to
 add/delete/lookup the entry.
 
huanggaoyang (5):
  helper: add table api
  helper: table: add impl of hashtable
  helper: table: add impl of lineartable
  helper: add the new source files to Makefile
  helper: test add a simple test case for hashtable

 helper/Makefile.am|   5 +-
 helper/hashtable.c| 346 ++
 helper/include/odp/helper/table.h | 166 ++
 helper/lineartable.c  | 211 +++
 helper/odph_hashtable.h   |  42 +
 helper/odph_lineartable.h |  41 +
 helper/odph_list_internal.h   |  85 ++
 helper/test/Makefile.am   |   5 +-
 helper/test/odp_table.c   | 134 +++
 9 files changed, 1033 insertions(+), 2 deletions(-)
 create mode 100644 helper/hashtable.c
 create mode 100644 helper/include/odp/helper/table.h
 create mode 100644 helper/lineartable.c
 create mode 100644 helper/odph_hashtable.h
 create mode 100644 helper/odph_lineartable.h
 create mode 100644 helper/odph_list_internal.h
 create mode 100644 helper/test/odp_table.c

-- 
1.9.1


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


[lng-odp] [PATCHv2 4/5] helper: add the new source files to Makefile

2015-10-19 Thread huanggaoyang
Signed-off-by: huanggaoyang 
---
 helper/Makefile.am  | 5 -
 helper/test/Makefile.am | 5 -
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/helper/Makefile.am b/helper/Makefile.am
index 1a74e8e..196d887 100644
--- a/helper/Makefile.am
+++ b/helper/Makefile.am
@@ -17,6 +17,7 @@ helperinclude_HEADERS = \
  $(srcdir)/include/odp/helper/ip.h\
  $(srcdir)/include/odp/helper/ipsec.h\
  $(srcdir)/include/odp/helper/tcp.h\
+ $(srcdir)/include/odp/helper/table.h\
  $(srcdir)/include/odp/helper/udp.h
 
 noinst_HEADERS = \
@@ -25,6 +26,8 @@ noinst_HEADERS = \
 
 __LIB__libodphelper_la_SOURCES = \
linux.c \
-   ring.c
+   ring.c \
+   hashtable.c \
+   lineartable.c
 
 lib_LTLIBRARIES = $(LIB)/libodphelper.la
diff --git a/helper/test/Makefile.am b/helper/test/Makefile.am
index fbf5a9b..0984e2e 100644
--- a/helper/test/Makefile.am
+++ b/helper/test/Makefile.am
@@ -8,7 +8,8 @@ TESTS_ENVIRONMENT += TEST_DIR=${builddir}
 EXECUTABLES = odp_chksum$(EXEEXT) \
   odp_thread$(EXEEXT) \
   odp_process$(EXEEXT)\
-  odph_pause$(EXEEXT)
+  odph_pause$(EXEEXT)\
+  odp_table$(EXEEXT)
 
 COMPILE_ONLY =
 
@@ -29,3 +30,5 @@ odp_thread_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la
 dist_odp_process_SOURCES = odp_process.c
 odp_process_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la
 odph_pause_SOURCES = odph_pause.c
+dist_odp_table_SOURCES = odp_table.c
+dist_odp_table_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la
-- 
1.9.1


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


Re: [lng-odp] [PATCH 1/2] linux-generic: netmap: wait for the interface to become active

2015-10-19 Thread Elo, Matias (Nokia - FI/Espoo)
> -Original Message-
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT 
> Stuart
> Haslam
> Sent: Friday, October 16, 2015 8:43 PM
> To: Maxim Uvarov 
> Cc: lng-odp@lists.linaro.org
> Subject: Re: [lng-odp] [PATCH 1/2] linux-generic: netmap: wait for the 
> interface
> to become active
> 
> On Fri, Oct 16, 2015 at 06:59:42PM +0300, Maxim Uvarov wrote:
> > On 10/16/2015 15:45, Matias Elo wrote:
> > >Netmap interface takes a few seconds to become active after
> > >setup. This caused several test applications to fail.
> > >Check link status at the end of netmap_open() to fix this.
> > >
> > >Signed-off-by: Matias Elo 
> > >---
> > >  platform/linux-generic/pktio/netmap.c | 20 +---
> > >  1 file changed, 17 insertions(+), 3 deletions(-)
> > >
> > >diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-
> generic/pktio/netmap.c
> > >index ab4667e..0c9ad35 100644
> > >--- a/platform/linux-generic/pktio/netmap.c
> > >+++ b/platform/linux-generic/pktio/netmap.c
> > >@@ -28,6 +28,7 @@ static struct nm_desc mmap_desc; /** Used to store
> the mmap address;
> > > filled in first time, used for
> > > subsequent calls to nm_open */
> > >+#define NM_OPEN_RETRIES 5
> > >  #define NM_INJECT_RETRIES 10
> > >  struct dispatch_args {
> > >@@ -70,6 +71,10 @@ static int netmap_do_ioctl(pktio_entry_t *pktio_entry,
> unsigned long cmd,
> > >   pkt_nm->if_flags = (ifr.ifr_flags << 16) |
> > >   (0x & ifr.ifr_flags);
> > >   break;
> > >+  case SIOCETHTOOL:
> > >+  if (subcmd == ETHTOOL_GLINK)
> > >+  return !eval.data;
> > >+  break;
> > >   default:
> > >   break;
> > >   }
> > >@@ -84,9 +89,10 @@ static int netmap_close(pktio_entry_t *pktio_entry)
> > >  {
> > >   pkt_netmap_t *pkt_nm = _entry->s.pkt_nm;
> > >-  if (pkt_nm->desc != NULL)
> > >+  if (pkt_nm->desc != NULL) {
> > >   nm_close(pkt_nm->desc);
> > >-
> > >+  mmap_desc.mem = NULL;
> > >+  }
> > >   if (pkt_nm->sockfd != -1 && close(pkt_nm->sockfd) != 0) {
> > >   __odp_errno = errno;
> > >   ODP_ERR("close(sockfd): %s\n", strerror(errno));
> > >@@ -101,6 +107,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED,
> pktio_entry_t *pktio_entry,
> > >   char ifname[IFNAMSIZ + 7]; /* netmap: */
> > >   int err;
> > >   int sockfd;
> > >+  int i;
> > >   pkt_netmap_t *pkt_nm = _entry->s.pkt_nm;
> > >   if (getenv("ODP_PKTIO_DISABLE_NETMAP"))
> > >@@ -155,7 +162,14 @@ static int netmap_open(odp_pktio_t id
> ODP_UNUSED, pktio_entry_t *pktio_entry,
> > >   if (err)
> > >   goto error;
> > >-  return 0;
> > >+  /* Wait for the link to come up */
> > >+  for (i = 0; i < NM_OPEN_RETRIES; i++) {
> > >+  err = netmap_do_ioctl(pktio_entry, SIOCETHTOOL,
> ETHTOOL_GLINK);
> > >+  if (err == 0)
> > >+  return 0;
> > >+  sleep(1);
> > >+  }
> > >+  ODP_ERR("%s didn't come up\n", pktio_entry->s.name);
> >
> > before usage pktio you need to call odp_pktio_start(). Maybe it's
> > more reasonable on start() check that link is up?
> >
> > Maxim.
> >
> 
> The issue is that the nm_open() call puts the interface into netmap
> mode, which makes it drop the link briefly (about 3 seconds in my case).
> 
> I suppose it would be marginally better to check the link state before
> the nm_open() call and avoid waiting for it to come up if it wasn't up
> before. This way the error would only be reported if the link had
> unexpectedly failed to come back up, but you'd still be able to open an
> interface whose link was down.
> 

The current implementation is based on the assumption that the netmap_open() 
call should not bring the interface up if it was down to begin with (e.g. set 
down using ifconfig). Currently, netmap_open() will always return an error in 
this case.

I'm implementing the start/stop calls next and in that patch I could enable 
opening interfaces whose link is down.

-Matias

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


Re: [lng-odp] Bug 1851 - odp_pool_destroy() failure

2015-10-19 Thread Savolainen, Petri (Nokia - FI/Espoo)
A SW implementation can place the per thread stash into shared memory where the 
thread calling destroy() can see stashes of all  other threads. Since  
application must synchronize the destroy call (to happen only after all free() 
calls have returned), implementation must just ensure that the destroy call 
reads fresh stash status data (== it has correct memory read/write barriers in 
place). Performance should be still good – it’s matter of moving the per thread 
stash from TLS to shared memory (no additional synchronization per alloc/free).
-Petri


From: EXT Bill Fischofer [mailto:bill.fischo...@linaro.org]
Sent: Monday, October 19, 2015 2:26 PM
To: Savolainen, Petri (Nokia - FI/Espoo)
Cc: LNG ODP Mailman List
Subject: Re: [lng-odp] Bug 1851 - odp_pool_destroy() failure

This is an important discussion, especially as we look to high-performance SW 
implementations of ODP. Obviously we can stipulate any functional behavior we 
want. The question is how much overhead is acceptable to achieve such 
stipulated functionality? One of the reasons DPDK does not support mempool 
destroys is this issue of distributed cache management. If we don't want the 
application to take any responsibility in this area, then the implementation 
needs to impose additional bookkeeping overhead that will likely impact the 
performance of normal operation.

What's needed is some sort of indication that a thread is not just freeing a 
buffer, but is done with operations on a pool. One way of doing this is to add 
an odp_pool_finished() API that tells the implementation that this thread is 
done with the pool (e.g., asserts that no further alloc() calls will be made by 
this thread on it).  My suggestion in the response to the bug was that 
odp_pool_destory() can serve this purpose, however I'd have no problem with 
adding another API that serves the same notification purpose.

Without such an API, it's not clear how we can achieve the desired 
functionality without a lot of additional overhead or removing any sort of 
safety checks.  If the latter is acceptable, we could say that 
odp_pool_destroy() always succeeds and if the application had any outstanding 
buffers or tries to use the pool handle following a destroy() call then the 
result is undefined.



On Mon, Oct 19, 2015 at 5:48 AM, Savolainen, Petri (Nokia - FI/Espoo) 
> wrote:
Hi,

Linux-generic pool implementation has a bug ( 
https://bugs.linaro.org/show_bug.cgi?id=1851 ) that prevents dynamic pool 
destroy. From API point of view, any resource (e.g. pool) is created once ( 
xxx_create call returns a handle) and destroyed once (pass the handle to 
xxx_destroy). Any thread can create a resource and any thread can destroy it. 
Application threads  must synchronize resource usage and destroy call, but not 
implementation specifics like potential usage of per thread stashes or flush of 
those.

For example, this valid usage of the pool API:

Thread 1Thread 2  Thread 3
--

init_global()
init_local()init_local()  init_local()

pool = pool_create()

barrier()   barrier() barrier()
buf = alloc(pool)   buf = alloc(pool) buf = alloc(pool)
free(buf)   free(buf) free(buf)
barrier()   barrier() barrier()

pool_destroy(pool)

barrier()   barrier() barrier()
do_something()  do_something()do_something()
term_local()term_local()  term_local()
  term_global()


So, e.g. pool_destroy must succeed when all buffers have been freed before the 
call - no matter:
* which thread calls it
* has the calling thread itself called alloc or free
* have other threads called already term_local


-Petri


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

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


Re: [lng-odp] Bug 1851 - odp_pool_destroy() failure

2015-10-19 Thread Ola Liljedahl
On 19 October 2015 at 16:43, Bill Fischofer 
wrote:

> We could do that in linux-generic, which has a fairly small number of
> threads supported.  I'd be concerned about how that would scale to systems
> that can support many more threads, especially when NUMA considerations
> come into play.  Is it simply unacceptable to have some sort of "finished"
> API call?  That would seem so solve the problem in a clean and scalable
> manner.
>
Isn't this conceptually similar to the stop scheduling call so that I can
drain the prescheduling queue and then stop participating in event
processing? In order to allow for "non-ideal" implementations (because
instant sharing of all resources isn't always very performant), we create
API's that tell ODP that this thread wishes to withdraw from processing
using shared resources.


>
> On Mon, Oct 19, 2015 at 9:15 AM, Savolainen, Petri (Nokia - FI/Espoo) <
> petri.savolai...@nokia.com> wrote:
>
>> A SW implementation can place the per thread stash into shared memory
>> where the thread calling destroy() can see stashes of all  other threads.
>> Since  application must synchronize the destroy call (to happen only after
>> all free() calls have returned), implementation must just ensure that the
>> destroy call reads fresh stash status data (== it has correct memory
>> read/write barriers in place). Performance should be still good – it’s
>> matter of moving the per thread stash from TLS to shared memory (no
>> additional synchronization per alloc/free).
>>
>> -Petri
>>
>>
>>
>>
>>
>> *From:* EXT Bill Fischofer [mailto:bill.fischo...@linaro.org]
>> *Sent:* Monday, October 19, 2015 2:26 PM
>> *To:* Savolainen, Petri (Nokia - FI/Espoo)
>> *Cc:* LNG ODP Mailman List
>> *Subject:* Re: [lng-odp] Bug 1851 - odp_pool_destroy() failure
>>
>>
>>
>> This is an important discussion, especially as we look to
>> high-performance SW implementations of ODP. Obviously we can stipulate any
>> functional behavior we want. The question is how much overhead is
>> acceptable to achieve such stipulated functionality? One of the reasons
>> DPDK does not support mempool destroys is this issue of distributed cache
>> management. If we don't want the application to take any responsibility in
>> this area, then the implementation needs to impose additional bookkeeping
>> overhead that will likely impact the performance of normal operation.
>>
>>
>>
>> What's needed is some sort of indication that a thread is not just
>> freeing a buffer, but is done with operations on a pool. One way of doing
>> this is to add an odp_pool_finished() API that tells the implementation
>> that this thread is done with the pool (e.g., asserts that no further
>> alloc() calls will be made by this thread on it).  My suggestion in the
>> response to the bug was that odp_pool_destory() can serve this purpose,
>> however I'd have no problem with adding another API that serves the same
>> notification purpose.
>>
>>
>>
>> Without such an API, it's not clear how we can achieve the desired
>> functionality without a lot of additional overhead or removing any sort of
>> safety checks.  If the latter is acceptable, we could say that
>> odp_pool_destroy() always succeeds and if the application had any
>> outstanding buffers or tries to use the pool handle following a destroy()
>> call then the result is undefined.
>>
>>
>>
>>
>>
>>
>>
>> On Mon, Oct 19, 2015 at 5:48 AM, Savolainen, Petri (Nokia - FI/Espoo) <
>> petri.savolai...@nokia.com> wrote:
>>
>> Hi,
>>
>> Linux-generic pool implementation has a bug (
>> https://bugs.linaro.org/show_bug.cgi?id=1851 ) that prevents dynamic
>> pool destroy. From API point of view, any resource (e.g. pool) is created
>> once ( xxx_create call returns a handle) and destroyed once (pass the
>> handle to xxx_destroy). Any thread can create a resource and any thread can
>> destroy it. Application threads  must synchronize resource usage and
>> destroy call, but not implementation specifics like potential usage of per
>> thread stashes or flush of those.
>>
>> For example, this valid usage of the pool API:
>>
>> Thread 1Thread 2  Thread 3
>> --
>>
>> init_global()
>> init_local()init_local()  init_local()
>>
>> pool = pool_create()
>>
>> barrier()   barrier() barrier()
>> buf = alloc(pool)   buf = alloc(pool) buf = alloc(pool)
>> free(buf)   free(buf) free(buf)
>> barrier()   barrier() barrier()
>>
>> pool_destroy(pool)
>>
>> barrier()   barrier() barrier()
>> do_something()  do_something()do_something()
>> term_local()term_local()  term_local()
>>   term_global()
>>
>>
>> So, e.g. pool_destroy must succeed when all buffers have been freed
>> before the call - no matter:
>> * which thread calls it
>> * has the calling 

Re: [lng-odp] Bug 1851 - odp_pool_destroy() failure

2015-10-19 Thread Bill Fischofer
On Mon, Oct 19, 2015 at 10:07 AM, Ola Liljedahl 
wrote:

> On 19 October 2015 at 16:43, Bill Fischofer 
> wrote:
>
>> We could do that in linux-generic, which has a fairly small number of
>> threads supported.  I'd be concerned about how that would scale to systems
>> that can support many more threads, especially when NUMA considerations
>> come into play.  Is it simply unacceptable to have some sort of "finished"
>> API call?  That would seem so solve the problem in a clean and scalable
>> manner.
>>
> Isn't this conceptually similar to the stop scheduling call so that I can
> drain the prescheduling queue and then stop participating in event
> processing? In order to allow for "non-ideal" implementations (because
> instant sharing of all resources isn't always very performant), we create
> API's that tell ODP that this thread wishes to withdraw from processing
> using shared resources.
>

I think that's a useful analogy.  We've recently added stop/start APIs to
pktio for similar reasons, and of course we have odp_schedule_pause() that
serves the same advisory function.  We don't need a "start" API for pools
(though if you wanted one for symmetry I don't see any harm there) but you
really do want a "stop" API.


>
>
>>
>> On Mon, Oct 19, 2015 at 9:15 AM, Savolainen, Petri (Nokia - FI/Espoo) <
>> petri.savolai...@nokia.com> wrote:
>>
>>> A SW implementation can place the per thread stash into shared memory
>>> where the thread calling destroy() can see stashes of all  other threads.
>>> Since  application must synchronize the destroy call (to happen only after
>>> all free() calls have returned), implementation must just ensure that the
>>> destroy call reads fresh stash status data (== it has correct memory
>>> read/write barriers in place). Performance should be still good – it’s
>>> matter of moving the per thread stash from TLS to shared memory (no
>>> additional synchronization per alloc/free).
>>>
>>> -Petri
>>>
>>>
>>>
>>>
>>>
>>> *From:* EXT Bill Fischofer [mailto:bill.fischo...@linaro.org]
>>> *Sent:* Monday, October 19, 2015 2:26 PM
>>> *To:* Savolainen, Petri (Nokia - FI/Espoo)
>>> *Cc:* LNG ODP Mailman List
>>> *Subject:* Re: [lng-odp] Bug 1851 - odp_pool_destroy() failure
>>>
>>>
>>>
>>> This is an important discussion, especially as we look to
>>> high-performance SW implementations of ODP. Obviously we can stipulate any
>>> functional behavior we want. The question is how much overhead is
>>> acceptable to achieve such stipulated functionality? One of the reasons
>>> DPDK does not support mempool destroys is this issue of distributed cache
>>> management. If we don't want the application to take any responsibility in
>>> this area, then the implementation needs to impose additional bookkeeping
>>> overhead that will likely impact the performance of normal operation.
>>>
>>>
>>>
>>> What's needed is some sort of indication that a thread is not just
>>> freeing a buffer, but is done with operations on a pool. One way of doing
>>> this is to add an odp_pool_finished() API that tells the implementation
>>> that this thread is done with the pool (e.g., asserts that no further
>>> alloc() calls will be made by this thread on it).  My suggestion in the
>>> response to the bug was that odp_pool_destory() can serve this purpose,
>>> however I'd have no problem with adding another API that serves the same
>>> notification purpose.
>>>
>>>
>>>
>>> Without such an API, it's not clear how we can achieve the desired
>>> functionality without a lot of additional overhead or removing any sort of
>>> safety checks.  If the latter is acceptable, we could say that
>>> odp_pool_destroy() always succeeds and if the application had any
>>> outstanding buffers or tries to use the pool handle following a destroy()
>>> call then the result is undefined.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Mon, Oct 19, 2015 at 5:48 AM, Savolainen, Petri (Nokia - FI/Espoo) <
>>> petri.savolai...@nokia.com> wrote:
>>>
>>> Hi,
>>>
>>> Linux-generic pool implementation has a bug (
>>> https://bugs.linaro.org/show_bug.cgi?id=1851 ) that prevents dynamic
>>> pool destroy. From API point of view, any resource (e.g. pool) is created
>>> once ( xxx_create call returns a handle) and destroyed once (pass the
>>> handle to xxx_destroy). Any thread can create a resource and any thread can
>>> destroy it. Application threads  must synchronize resource usage and
>>> destroy call, but not implementation specifics like potential usage of per
>>> thread stashes or flush of those.
>>>
>>> For example, this valid usage of the pool API:
>>>
>>> Thread 1Thread 2  Thread 3
>>> --
>>>
>>> init_global()
>>> init_local()init_local()  init_local()
>>>
>>> pool = pool_create()
>>>
>>> barrier()   barrier() barrier()
>>> buf = alloc(pool)   buf = alloc(pool) buf = alloc(pool)
>>> 

Re: [lng-odp] Bug 1851 - odp_pool_destroy() failure

2015-10-19 Thread Bill Fischofer
We could do that in linux-generic, which has a fairly small number of
threads supported.  I'd be concerned about how that would scale to systems
that can support many more threads, especially when NUMA considerations
come into play.  Is it simply unacceptable to have some sort of "finished"
API call?  That would seem so solve the problem in a clean and scalable
manner.

On Mon, Oct 19, 2015 at 9:15 AM, Savolainen, Petri (Nokia - FI/Espoo) <
petri.savolai...@nokia.com> wrote:

> A SW implementation can place the per thread stash into shared memory
> where the thread calling destroy() can see stashes of all  other threads.
> Since  application must synchronize the destroy call (to happen only after
> all free() calls have returned), implementation must just ensure that the
> destroy call reads fresh stash status data (== it has correct memory
> read/write barriers in place). Performance should be still good – it’s
> matter of moving the per thread stash from TLS to shared memory (no
> additional synchronization per alloc/free).
>
> -Petri
>
>
>
>
>
> *From:* EXT Bill Fischofer [mailto:bill.fischo...@linaro.org]
> *Sent:* Monday, October 19, 2015 2:26 PM
> *To:* Savolainen, Petri (Nokia - FI/Espoo)
> *Cc:* LNG ODP Mailman List
> *Subject:* Re: [lng-odp] Bug 1851 - odp_pool_destroy() failure
>
>
>
> This is an important discussion, especially as we look to high-performance
> SW implementations of ODP. Obviously we can stipulate any functional
> behavior we want. The question is how much overhead is acceptable to
> achieve such stipulated functionality? One of the reasons DPDK does not
> support mempool destroys is this issue of distributed cache management. If
> we don't want the application to take any responsibility in this area, then
> the implementation needs to impose additional bookkeeping overhead that
> will likely impact the performance of normal operation.
>
>
>
> What's needed is some sort of indication that a thread is not just freeing
> a buffer, but is done with operations on a pool. One way of doing this is
> to add an odp_pool_finished() API that tells the implementation that this
> thread is done with the pool (e.g., asserts that no further alloc() calls
> will be made by this thread on it).  My suggestion in the response to the
> bug was that odp_pool_destory() can serve this purpose, however I'd have no
> problem with adding another API that serves the same notification purpose.
>
>
>
> Without such an API, it's not clear how we can achieve the desired
> functionality without a lot of additional overhead or removing any sort of
> safety checks.  If the latter is acceptable, we could say that
> odp_pool_destroy() always succeeds and if the application had any
> outstanding buffers or tries to use the pool handle following a destroy()
> call then the result is undefined.
>
>
>
>
>
>
>
> On Mon, Oct 19, 2015 at 5:48 AM, Savolainen, Petri (Nokia - FI/Espoo) <
> petri.savolai...@nokia.com> wrote:
>
> Hi,
>
> Linux-generic pool implementation has a bug (
> https://bugs.linaro.org/show_bug.cgi?id=1851 ) that prevents dynamic pool
> destroy. From API point of view, any resource (e.g. pool) is created once (
> xxx_create call returns a handle) and destroyed once (pass the handle to
> xxx_destroy). Any thread can create a resource and any thread can destroy
> it. Application threads  must synchronize resource usage and destroy call,
> but not implementation specifics like potential usage of per thread stashes
> or flush of those.
>
> For example, this valid usage of the pool API:
>
> Thread 1Thread 2  Thread 3
> --
>
> init_global()
> init_local()init_local()  init_local()
>
> pool = pool_create()
>
> barrier()   barrier() barrier()
> buf = alloc(pool)   buf = alloc(pool) buf = alloc(pool)
> free(buf)   free(buf) free(buf)
> barrier()   barrier() barrier()
>
> pool_destroy(pool)
>
> barrier()   barrier() barrier()
> do_something()  do_something()do_something()
> term_local()term_local()  term_local()
>   term_global()
>
>
> So, e.g. pool_destroy must succeed when all buffers have been freed before
> the call - no matter:
> * which thread calls it
> * has the calling thread itself called alloc or free
> * have other threads called already term_local
>
>
> -Petri
>
>
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [API-NEXT PATCHv2] api: pktio link

2015-10-19 Thread Ola Liljedahl
On 16 October 2015 at 17:55, Maxim Uvarov  wrote:

> On 10/16/2015 13:24, Savolainen, Petri (Nokia - FI/Espoo) wrote:
>
>> RFC 3635 helps also here to define properties of an Ethernet-like
>> interface. It's not so as crucial to follow RFC terms and definitions here
>> as it's with counters, but we can use it as a guide line. Addresses and
>> promisc mode are classification issues. Name and pktio status (stopped /
>> started) ( == ifAdminStatus) are pktio level data.
>>
>>
>> typedef struct odp_pktio_link_state_t {
>> uint8_t  type;// 0: Ethernet (or enum
>> ODP_PKTIO_ETHERNET), ...
>>
>
> type is not state.  I think there might be odp_pktio_info_t which is
> filled by init of each pktio.
> and some call like:
>  const odp_pktio_info_t * odp_pktio_info(pktio);
>
> where
> odp_pktio_info_t {
>
> char *name;
> uint8_t  type;// 0: Ethernet (or enum ODP_PKTIO_ETHERNET)
>
> // what also do we need, i/o address space, number of hw queues, nodes and
> etc.
> }
>
> But it looks like Bill right pointed that for now we have separate call
> for each function.
> We already have mtu and name for example. So we need to understand if we
> are going
> to modify existence API or add new.
>
> Also I can understand that:
> 1. speed -  might be needed to set up some timeout setting.
> 2.  status link up/down and logical pktio started / stopped is needed to
> check why odp_schedule() returns timeouts instead of packets.
>
> But I have no idea why application needs type, autoneg and duplex.
>
> I think for first try we need to stay just with:
> +typedef struct odp_pktio_link_state_t {
> +   uint32_t speed; /**< Speed in Mbps: 10, 100, 1000 etc */
> +   odp_bool_t up;  /**< 1 - link up, 0 - link down */
> +   odp_bool_t stopped; /**< 1 - pktio stopped, 0 - started */
>
Again, "stopped" is a poor name. Why not "running"?


> +} odp_pktio_link_state_t;
>
> I want to have up and stopped in one struct to speed that data plane calls.
>
Are these calls performance critical?



> Most likely it will be the following check
>
> ev = odp_schedule(wait_time);
> if (ev == ODP_EVENT_INVALID) {
>odp_pktio_link_state(pktio, _state);
>if (!link_state.up || link_state.stopped) {
> 
>   
>   continue;
> } else {
> 
> continue;
>   }
> }
>
> I.e. try to not do 2 calls and roll stack for 2 calls.
>
The example up doesn't look like it requires (or even benefits from) link
state and interface status to be obtained in the absolutely shortest time,
they are not called when we are actually processing an event.


> Does that reasonable?

No.

Interface (pktio) and physical link are different concepts which I do not
think should be mixed.



>
>
> Maxim.
>
>
>
> uint8_t  status;  // 1: link up, 0: down, -1 not_present (==
>> ifOperStatus )
>> uint8_t  autoneg; // 1: autoneg on, 0: off, -1: not supported
>> uint8_t  duplex;  // 1: full duplex, 0: half duplex
>> uint32_t speed_mbps;  // Speed in Mbps. This leaves room for
>>// speed_bps which would support odd
>> (Mbps) link speeds
>> uint32_t mtu; // MTU in bytes
>> } odp_pktio_link_state_t;
>>
>>
>> Better to use int (uint8_t) than bool to enable extendable status
>> definitions. E.g. ifOperStatus == not_present means that some HW component
>> is missing, rather than user have configured link down.
>>
>>
>> -Petri
>>
>>
>>
>> -Original Message-
>>> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT
>>> Maxim Uvarov
>>> Sent: Tuesday, October 13, 2015 3:39 PM
>>> To: lng-odp@lists.linaro.org
>>> Subject: [lng-odp] [API-NEXT PATCHv2] api: pktio link
>>>
>>> Define API to get pktio link state: seed, autoneg, link up/down,
>>> duplex, started/stopped state.
>>>
>>> Signed-off-by: Maxim Uvarov 
>>> ---
>>>   v2: - use simple struct to return pktio link state;
>>>   - odp will not modify link, only ready it's state;
>>>
>>>
>>>   include/odp/api/packet_io.h | 22 ++
>>>   1 file changed, 22 insertions(+)
>>>
>>> diff --git a/include/odp/api/packet_io.h b/include/odp/api/packet_io.h
>>> index d8e69ed..6c77e8d 100644
>>> --- a/include/odp/api/packet_io.h
>>> +++ b/include/odp/api/packet_io.h
>>> @@ -96,6 +96,28 @@ typedef struct odp_pktio_param_t {
>>>   } odp_pktio_param_t;
>>>
>>>   /**
>>> + * Packet IO link state information
>>> + */
>>> +typedef struct odp_pktio_link_state_t {
>>> +   uint32_t speed; /**< Speed in Mbps: 10, 100, 1000 etc */
>>> +   odp_bool_t up;  /**< 1 - link up, 0 - link down */
>>> +   odp_bool_t autoneg; /**< 1 - autoneg on, 0 - off */
>>> +   odp_bool_t fd;  /**< 1 - full duplex, 0 - half duplex */
>>> +   odp_bool_t stopped; /**< 1 - pktio stopped, 0 - started */
>>> +} odp_pktio_link_state_t;
>>> +
>>> +/**

Re: [lng-odp] [API-NEXT PATCHv2] api: pktio link

2015-10-19 Thread Maxim Uvarov

On 10/19/2015 18:20, Ola Liljedahl wrote:
On 16 October 2015 at 17:55, Maxim Uvarov > wrote:


On 10/16/2015 13:24, Savolainen, Petri (Nokia - FI/Espoo) wrote:

RFC 3635 helps also here to define properties of an
Ethernet-like interface. It's not so as crucial to follow RFC
terms and definitions here as it's with counters, but we can
use it as a guide line. Addresses and promisc mode are
classification issues. Name and pktio status (stopped /
started) ( == ifAdminStatus) are pktio level data.


typedef struct odp_pktio_link_state_t {
uint8_t  type;// 0: Ethernet (or enum
ODP_PKTIO_ETHERNET), ...


type is not state.  I think there might be odp_pktio_info_t which
is filled by init of each pktio.
and some call like:
 const odp_pktio_info_t * odp_pktio_info(pktio);

where
odp_pktio_info_t {

char *name;
uint8_t  type;// 0: Ethernet (or enum ODP_PKTIO_ETHERNET)

// what also do we need, i/o address space, number of hw queues,
nodes and etc.
}

But it looks like Bill right pointed that for now we have separate
call for each function.
We already have mtu and name for example. So we need to understand
if we are going
to modify existence API or add new.

Also I can understand that:
1. speed -  might be needed to set up some timeout setting.
2.  status link up/down and logical pktio started / stopped is
needed to check why odp_schedule() returns timeouts instead of
packets.

But I have no idea why application needs type, autoneg and duplex.

I think for first try we need to stay just with:
+typedef struct odp_pktio_link_state_t {
+   uint32_t speed; /**< Speed in Mbps: 10, 100, 1000
etc */
+   odp_bool_t up;  /**< 1 - link up, 0 - link down */
+   odp_bool_t stopped; /**< 1 - pktio stopped, 0 - started */

Again, "stopped" is a poor name. Why not "running"?


Just serious why "stopped" is poor name and "running" is good name? In 
future we might
have several states for pktio, something like paused. More likely it 
will be better to have just

state which is some state enum.


+} odp_pktio_link_state_t;

I want to have up and stopped in one struct to speed that data
plane calls.

Are these calls performance critical?

Most likely it will be the following check

ev = odp_schedule(wait_time);
if (ev == ODP_EVENT_INVALID) {
   odp_pktio_link_state(pktio, _state);
   if (!link_state.up || link_state.stopped) {

  
  continue;
} else {

continue;
  }
}

I.e. try to not do 2 calls and roll stack for 2 calls.

The example up doesn't look like it requires (or even benefits from) 
link state and interface status to be obtained in the absolutely 
shortest time, they are not called when we are actually processing an 
event.



Does that reasonable?

No.

Interface (pktio) and physical link are different concepts which I do 
not think should be mixed.




Ok, if there is no reason, then I will send patch only with  up/down and 
speed.


Maxim.




Maxim.



  uint8_t  status;  // 1: link up, 0: down, -1
not_present (== ifOperStatus )
uint8_t  autoneg; // 1: autoneg on, 0: off, -1:
not supported
uint8_t  duplex;  // 1: full duplex, 0: half duplex
uint32_t speed_mbps;  // Speed in Mbps. This leaves
room for
   // speed_bps which would
support odd (Mbps) link speeds
uint32_t mtu; // MTU in bytes
} odp_pktio_link_state_t;


Better to use int (uint8_t) than bool to enable extendable
status definitions. E.g. ifOperStatus == not_present means
that some HW component is missing, rather than user have
configured link down.


-Petri



-Original Message-
From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org
] On Behalf Of EXT
Maxim Uvarov
Sent: Tuesday, October 13, 2015 3:39 PM
To: lng-odp@lists.linaro.org 
Subject: [lng-odp] [API-NEXT PATCHv2] api: pktio link

Define API to get pktio link state: seed, autoneg, link
up/down,
duplex, started/stopped state.

Signed-off-by: Maxim Uvarov >
---
  v2: - use simple struct to return pktio link state;
  - odp will not modify link, only ready it's state;


  include/odp/api/packet_io.h | 22 ++
 

Re: [lng-odp] [PATCHv7 3/4] api: pktio: remove odp_pktio_set_mtu

2015-10-19 Thread Ola Liljedahl
On 16 October 2015 at 15:39, Agrawal Hemant  wrote:

> Can we add following APIs to pktio
>
> - odp_pktio_mtu_set
>
And the MTU is defined as excluding any layer-2 headers? What's the
relationship between the MTU and the necessary RX buffer size (which must
hold all layer-2 headers as well)?

Is MTU a layer-2 or layer-3 concept?



>
> Changing the MTU by the applications is not uncommon.
>
> If some hardware is not supporting, they may choose return not supported.
>
>
> Regards,
> Hemant
>
> -Original Message-
> From: lng-odp-boun...@lists.linaro.org [mailto:
> lng-odp-boun...@lists.linaro.org] On Behalf Of Maxim Uvarov
> Sent: Friday, December 19, 2014 5:17 PM
> To: lng-odp@lists.linaro.org
> Subject: [lng-odp] [PATCHv7 3/4] api: pktio: remove odp_pktio_set_mtu
>
> Not all hardware can change MTU size from ODP application.
>
> Signed-off-by: Maxim Uvarov 
> ---
>  example/packet/odp_pktio.c | 27 --
>  platform/linux-generic/include/api/odp_packet_io.h | 13 ---
>  platform/linux-generic/odp_packet_io.c | 42
> --
>  3 files changed, 82 deletions(-)
>
> diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index
> a323ec2..0a38ec2 100644
> --- a/example/packet/odp_pktio.c
> +++ b/example/packet/odp_pktio.c
> @@ -70,7 +70,6 @@ typedef struct {
> char **if_names;/**< Array of pointers to interface names
> */
> int mode;   /**< Packet IO mode */
> odp_buffer_pool_t pool; /**< Buffer pool for packet IO */
> -   int mtu;/**< Pktio dev MTU */
>  } appl_args_t;
>
>  /**
> @@ -80,7 +79,6 @@ typedef struct {
> char *pktio_dev;/**< Interface name to use */
> odp_buffer_pool_t pool; /**< Buffer pool for packet IO */
> int mode;   /**< Thread mode */
> -   int mtu;/**< Pktio dev MTU */
>  } thread_args_t;
>
>  /**
> @@ -145,14 +143,6 @@ static void *pktio_queue_thread(void *arg)
> return NULL;
> }
>
> -   /* Change mtu if requested */
> -   if (thr_args->mtu) {
> -   ret = odp_pktio_set_mtu(pktio, thr_args->mtu);
> -   if (ret != 0)
> -   EXAMPLE_ERR("setting MTU to %d failed\n",
> -   thr_args->mtu);
> -   }
> -
> mtu = odp_pktio_mtu(pktio);
> if (mtu > 0)
> printf("PKTIO: %d, dev %s, MTU: %d\n", @@ -251,7 +241,6 @@
> static void *pktio_ifburst_thread(void *arg)
> unsigned long err_cnt = 0;
> unsigned long tmp = 0;
> int mtu;
> -   int ret;
>
> thr = odp_thread_id();
> thr_args = arg;
> @@ -273,14 +262,6 @@ static void *pktio_ifburst_thread(void *arg)
> return NULL;
> }
>
> -   /* Change mtu if requested */
> -   if (thr_args->mtu) {
> -   ret = odp_pktio_set_mtu(pktio, thr_args->mtu);
> -   if (ret != 0)
> -   EXAMPLE_ERR("setting MTU to %d failed\n",
> -   thr_args->mtu);
> -   }
> -
> mtu = odp_pktio_mtu(pktio);
> if (mtu > 0)
> printf("PKTIO: %d, dev %s, MTU: %d\n", @@ -409,7 +390,6 @@
> int main(int argc, char *argv[])
> args->thread[i].pktio_dev = args->appl.if_names[if_idx];
> args->thread[i].pool = pool;
> args->thread[i].mode = args->appl.mode;
> -   args->thread[i].mtu = args->appl.mtu;
>
> if (args->appl.mode == APPL_MODE_PKT_BURST)
> thr_run_func = pktio_ifburst_thread; @@ -520,13
> +500,11 @@ static void parse_args(int argc, char *argv[], appl_args_t
> *appl_args)
> {"count", required_argument, NULL, 'c'},
> {"interface", required_argument, NULL, 'i'},/* return
> 'i' */
> {"mode", required_argument, NULL, 'm'}, /* return
> 'm' */
> -   {"mtu", required_argument, NULL, 't'},  /* return
> 't' */
> {"help", no_argument, NULL, 'h'},   /* return
> 'h' */
> {NULL, 0, NULL, 0}
> };
>
> appl_args->mode = -1; /* Invalid, must be changed by parsing */
> -   appl_args->mtu = 0;
>
> while (1) {
> opt = getopt_long(argc, argv, "+c:i:m:t:h", @@ -589,10
> +567,6 @@ static void parse_args(int argc, char *argv[], appl_args_t
> *appl_args)
> else
> appl_args->mode = APPL_MODE_PKT_QUEUE;
> break;
> -   case 't':
> -   appl_args->mtu = atoi(optarg);
> -   break;
> -
> case 'h':
> usage(argv[0]);
> exit(EXIT_SUCCESS);
> @@ -666,7 +640,6 @@ static void usage(char *progname)
>  

[lng-odp] [PATCHv10 1/8] helper: ring: update ring with shm proc argument

2015-10-19 Thread Maxim Uvarov
Signed-off-by: Maxim Uvarov 
---
 helper/include/odp/helper/ring.h | 2 ++
 helper/ring.c| 9 -
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/helper/include/odp/helper/ring.h b/helper/include/odp/helper/ring.h
index 65c32ad..5e640a7 100644
--- a/helper/include/odp/helper/ring.h
+++ b/helper/include/odp/helper/ring.h
@@ -158,6 +158,8 @@ typedef struct odph_ring {
 
 #define ODPH_RING_F_SP_ENQ 0x0001 /* The default enqueue is 
"single-producer".*/
 #define ODPH_RING_F_SC_DEQ 0x0002 /* The default dequeue is 
"single-consumer".*/
+#define ODPH_RING_SHM_PROC 0x0004 /* If set - ring is visible from different
+   processes. Default is thread visible. */
 #define ODPH_RING_QUOT_EXCEED (1 << 31)  /* Quota exceed for burst ops */
 #define ODPH_RING_SZ_MASK  (unsigned)(0x0fff) /* Ring size mask */
 
diff --git a/helper/ring.c b/helper/ring.c
index 3122173..844abf7 100644
--- a/helper/ring.c
+++ b/helper/ring.c
@@ -158,8 +158,14 @@ odph_ring_create(const char *name, unsigned count, 
unsigned flags)
char ring_name[ODPH_RING_NAMESIZE];
odph_ring_t *r;
size_t ring_size;
+   uint32_t shm_flag;
odp_shm_t shm;
 
+   if (flags & ODPH_RING_SHM_PROC)
+   shm_flag = ODP_SHM_PROC;
+   else
+   shm_flag = 0;
+
/* count must be a power of 2 */
if (!RING_VAL_IS_POWER_2(count) || (count > ODPH_RING_SZ_MASK)) {
ODPH_ERR("Requested size is invalid, must be power of 2, and do 
not exceed the size limit %u\n",
@@ -172,7 +178,8 @@ odph_ring_create(const char *name, unsigned count, unsigned 
flags)
 
odp_rwlock_write_lock();
/* reserve a memory zone for this ring.*/
-   shm = odp_shm_reserve(ring_name, ring_size, ODP_CACHE_LINE_SIZE, 0);
+   shm = odp_shm_reserve(ring_name, ring_size, ODP_CACHE_LINE_SIZE,
+ shm_flag);
 
r = odp_shm_addr(shm);
 
-- 
1.9.1

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


[lng-odp] [PATCHv10 7/8] linux-generic: add ipc pktio support

2015-10-19 Thread Maxim Uvarov
Signed-off-by: Maxim Uvarov 
---
 platform/linux-generic/Makefile.am |   2 +
 .../linux-generic/include/odp_buffer_internal.h|   3 +
 .../linux-generic/include/odp_packet_io_internal.h |  47 ++
 .../include/odp_packet_io_ipc_internal.h   |  51 ++
 platform/linux-generic/include/odp_shm_internal.h  |  21 +
 platform/linux-generic/odp_packet_io.c |   1 +
 platform/linux-generic/odp_pool.c  |  11 +-
 platform/linux-generic/odp_shared_memory.c |  12 +-
 platform/linux-generic/pktio/io_ops.c  |   1 +
 platform/linux-generic/pktio/ipc.c | 703 +
 platform/linux-generic/pktio/ring.c|   1 +
 11 files changed, 849 insertions(+), 4 deletions(-)
 create mode 100644 platform/linux-generic/include/odp_packet_io_ipc_internal.h
 create mode 100644 platform/linux-generic/include/odp_shm_internal.h
 create mode 100644 platform/linux-generic/pktio/ipc.c
 create mode 12 platform/linux-generic/pktio/ring.c

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index b9ed3b0..71353dd 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -151,9 +151,11 @@ __LIB__libodp_la_SOURCES = \
   odp_packet_flags.c \
   odp_packet_io.c \
   pktio/io_ops.c \
+  pktio/ipc.c \
   pktio/loop.c \
   pktio/socket.c \
   pktio/socket_mmap.c \
+  pktio/ring.c \
   odp_pool.c \
   odp_queue.c \
   odp_rwlock.c \
diff --git a/platform/linux-generic/include/odp_buffer_internal.h 
b/platform/linux-generic/include/odp_buffer_internal.h
index 4cacca1..a078e52 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -132,6 +132,9 @@ struct odp_buffer_hdr_t {
uint32_t uarea_size; /* size of user area */
uint32_t segcount;   /* segment count */
uint32_t segsize;/* segment size */
+   /* ipc mapped process can not walk over pointers,
+* offset has to be used */
+   uint64_t ipc_addr_offset[ODP_BUFFER_MAX_SEG];
void*addr[ODP_BUFFER_MAX_SEG]; /* block addrs */
uint64_t order;  /* sequence for ordered queues */
queue_entry_t   *origin_qe;  /* ordered queue origin */
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h 
b/platform/linux-generic/include/odp_packet_io_internal.h
index 6b03051..9fe1554 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -23,6 +23,7 @@ extern "C" {
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -36,6 +37,50 @@ typedef struct {
odp_bool_t promisc; /**< promiscuous mode state */
 } pkt_loop_t;
 
+typedefstruct {
+   /* TX */
+   struct  {
+   odph_ring_t *prod; /**< ODP ring for IPC msg packets
+ indexes transmitted to shared
+ memory */
+   odph_ring_t *cons; /**< ODP ring for IPC msg packets
+   indexes already processed by remote
+   process */
+   } m; /* master */
+   /* RX */
+   struct {
+   odph_ring_t *prod; /**< ODP ring for IPC msg packets
+   indexes received from shared
+memory (from remote process) */
+   odph_ring_t *cons; /**< ODP ring for IPC msg packets
+   indexes already processed by
+   current process */
+   } s; /* slave */
+   struct {
+   odph_ring_t *r;   /**< ring to receive from */
+   odph_ring_t *r_p; /**< after recv is done place packet descr to
+  that produced ring */
+   } recv; /* remapped above rings for easy usage in recv() */
+   struct {
+   odph_ring_t *r; /**< ring to transmit packets */
+   odph_ring_t *r_p; /**< ring with already transmitted packets */
+   } tx; /* remapped above rings for easy usage in send() */
+   void*pool_base; /**< Remote pool base addr */
+   void*pool_mdata_base;   /**< Remote pool mdata base 
addr */
+   uint64_tpkt_size;   /**< Packet size in remote pool 
*/
+   odp_pool_t  pool;   /**< Pool 

Re: [lng-odp] [API-NEXT PATCHv2] api: pktio link

2015-10-19 Thread Ola Liljedahl
On 19 October 2015 at 17:33, Maxim Uvarov  wrote:

> On 10/19/2015 18:20, Ola Liljedahl wrote:
>
>> On 16 October 2015 at 17:55, Maxim Uvarov > > wrote:
>>
>> On 10/16/2015 13:24, Savolainen, Petri (Nokia - FI/Espoo) wrote:
>>
>> RFC 3635 helps also here to define properties of an
>> Ethernet-like interface. It's not so as crucial to follow RFC
>> terms and definitions here as it's with counters, but we can
>> use it as a guide line. Addresses and promisc mode are
>> classification issues. Name and pktio status (stopped /
>> started) ( == ifAdminStatus) are pktio level data.
>>
>>
>> typedef struct odp_pktio_link_state_t {
>> uint8_t  type;// 0: Ethernet (or enum
>> ODP_PKTIO_ETHERNET), ...
>>
>>
>> type is not state.  I think there might be odp_pktio_info_t which
>> is filled by init of each pktio.
>> and some call like:
>>  const odp_pktio_info_t * odp_pktio_info(pktio);
>>
>> where
>> odp_pktio_info_t {
>>
>> char *name;
>> uint8_t  type;// 0: Ethernet (or enum ODP_PKTIO_ETHERNET)
>>
>> // what also do we need, i/o address space, number of hw queues,
>> nodes and etc.
>> }
>>
>> But it looks like Bill right pointed that for now we have separate
>> call for each function.
>> We already have mtu and name for example. So we need to understand
>> if we are going
>> to modify existence API or add new.
>>
>> Also I can understand that:
>> 1. speed -  might be needed to set up some timeout setting.
>> 2.  status link up/down and logical pktio started / stopped is
>> needed to check why odp_schedule() returns timeouts instead of
>> packets.
>>
>> But I have no idea why application needs type, autoneg and duplex.
>>
>> I think for first try we need to stay just with:
>> +typedef struct odp_pktio_link_state_t {
>> +   uint32_t speed; /**< Speed in Mbps: 10, 100, 1000
>> etc */
>> +   odp_bool_t up;  /**< 1 - link up, 0 - link down */
>> +   odp_bool_t stopped; /**< 1 - pktio stopped, 0 - started */
>>
>> Again, "stopped" is a poor name. Why not "running"?
>>
>
> Just serious why "stopped" is poor name and "running" is good name?

Because "stopped" (or "started") relates to the action (e.g. stop or start)
you requested in order to change the state.
We don't call the link state variable "upped" or "downed" etc.



> In future we might
> have several states for pktio, something like paused. More likely it will
> be better to have just
> state which is some state enum.
>
> +} odp_pktio_link_state_t;
>>
> Yes better.


>
>> I want to have up and stopped in one struct to speed that data
>> plane calls.
>>
>> Are these calls performance critical?
>>
>> Most likely it will be the following check
>>
>> ev = odp_schedule(wait_time);
>> if (ev == ODP_EVENT_INVALID) {
>>odp_pktio_link_state(pktio, _state);
>>if (!link_state.up || link_state.stopped) {
>> 
>>   
>>   continue;
>> } else {
>> 
>> continue;
>>   }
>> }
>>
>> I.e. try to not do 2 calls and roll stack for 2 calls.
>>
>> The example up doesn't look like it requires (or even benefits from) link
>> state and interface status to be obtained in the absolutely shortest time,
>> they are not called when we are actually processing an event.
>>
>>
>> Does that reasonable?
>>
>> No.
>>
>> Interface (pktio) and physical link are different concepts which I do not
>> think should be mixed.
>>
>>
> Ok, if there is no reason, then I will send patch only with  up/down and
> speed.
>
Good.


>
> Maxim.
>
>
>>
>> Maxim.
>>
>>
>>
>>   uint8_t  status;  // 1: link up, 0: down, -1
>> not_present (== ifOperStatus )
>> uint8_t  autoneg; // 1: autoneg on, 0: off, -1:
>> not supported
>> uint8_t  duplex;  // 1: full duplex, 0: half duplex
>> uint32_t speed_mbps;  // Speed in Mbps. This leaves
>> room for
>>// speed_bps which would
>> support odd (Mbps) link speeds
>> uint32_t mtu; // MTU in bytes
>> } odp_pktio_link_state_t;
>>
>>
>> Better to use int (uint8_t) than bool to enable extendable
>> status definitions. E.g. ifOperStatus == not_present means
>> that some HW component is missing, rather than user have
>> configured link down.
>>
>>
>> -Petri
>>
>>
>>
>> -Original Message-
>> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org
>> ] On Behalf Of EXT
>> Maxim Uvarov
>> Sent: Tuesday, 

Re: [lng-odp] [API-NEXT PATCHv4 1/2] api: define pktio statistics api

2015-10-19 Thread Ola Liljedahl
On 16 October 2015 at 15:25, Maxim Uvarov  wrote:

> Signed-off-by: Maxim Uvarov 
> ---
>  include/odp/api/packet_io_stats.h  | 166
> +
>  platform/linux-generic/include/odp/packet_io.h |   1 +
>  2 files changed, 167 insertions(+)
>  create mode 100644 include/odp/api/packet_io_stats.h
>
> diff --git a/include/odp/api/packet_io_stats.h
> b/include/odp/api/packet_io_stats.h
> new file mode 100644
> index 000..94af18c
> --- /dev/null
> +++ b/include/odp/api/packet_io_stats.h
> @@ -0,0 +1,166 @@
> +/* Copyright (c) 2015, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier: BSD-3-Clause
> + */
> +
> +/**
> + * @file
> + *
> + * ODP Packet IO
> + */
> +
> +#ifndef ODP_API_PACKET_IO_STATS_H_
> +#define ODP_API_PACKET_IO_STATS_H_
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +/** @defgroup odp_packet_io ODP PACKET IO
> + *  @{
> + */
> +
> +/**
> + * Packet IO statistics
> + *
> + * Packet IO statictics counters follow RFCs for Management Information
> Base
> + * (MIB)for use with network management protocols in the Internet
> community:
> + * https://tools.ietf.org/html/rfc3635
> + * https://tools.ietf.org/html/rfc2863
> + * https://tools.ietf.org/html/rfc2819
> + */
> +typedef struct odp_pktio_stats_t {
> +   /**
> +* The number of octets in valid MAC frames received on this
> interface,
> +* including the MAC header and FCS. See ifHCInOctets counter
> +* description in RFC 3635 for details.
> +*/
> +   uint64_t in_octets;
> +   /**
> +* The number of packets, delivered by this sub-layer to a higher
> +* (sub-)layer, which were not addressed to a multicast or
> broadcast
> +* address at this sub-layer. See InUcastPkts in RFC 2863.
> +*/
> +   uint64_t in_ucast_pkts;
> +   /**
> +* The number of inbound packets which were chosen to be discarded
> +* even though no errors had been detected to preven their being
> +* deliverable to a higher-layer protocol.  One possible reason for
> +* discarding such a packet could be to free up buffer space.
> +* See InDiscards in RFC 2863.
> +*/
> +   uint64_t in_discards;
> +   /**
> +* The sum for this interface of AlignmentErrors, FCSErrors,
> FrameTooLongs,
> +* InternalMacReceiveErrors. See InErrors in RFC 3635.
> +*/
> +   uint64_t in_errors;
> +   /**
> +* For packet-oriented interfaces, the number of packets received
> via
> +* the interface which were discarded because of an unknown or
> +* unsupported protocol.  For character-oriented or fixed-length
> +* interfaces that support protocol multiplexing the number of
> +* transmission units received via the interface which were
> discarded
> +* because of an unknown or unsupported protocol.  For any
> interface
> +* that does not support protocol multiplexing, this counter will
> always
> +* be 0. See InUnknownProtos in RFC 2863.
> +*/
> +   uint64_t in_unknown_protos;
> +   /**
> +* The number of octets transmitted in valid MAC frames on this
> +* interface, including the MAC header and FCS.  This does include
> +* the number of octets in valid MAC Control frames transmitted on
> +* this interface. See OutOctets in RFC 3635.
> +*/
> +   uint64_t out_octets;
> +   /**
> +* The total number of packets that higher-level protocols
> requested
> +* be transmitted, and which were not addressed to a multicast or
> +* broadcast address at this sub-layer, including those that were
> +* discarded or not sent. does not include MAC Control frames.
> +* See OutUcastPkts in RFC 2863, 3635.
> +*/
> +   uint64_t out_ucast_pkts;
> +   /**
> +* The number of outbound packets which were chosen to be discarded
> +* even though no errors had been detected to prevent their being
> +* transmitted.  One possible reason for discarding such a packet
> could
> +* be to free up buffer space.  See  OutDiscards in  RFC 2863.
> +*/
> +   uint64_t out_discards;
> +   /**
> +* The sum for this interface of SQETestErrors, LateCollisions,
> +* ExcessiveCollisions, InternalMacTransmitErrors and
> +* CarrierSenseErrors. See OutErrors in RFC 3635.
> +*/
> +   uint64_t out_errors;
> +} odp_pktio_stats_t;
> +
> +/** Bit in odp_pktio_stats_mask_t defines if in_octets counter
> + * of odp_pktio_stats_t struct is supported */
> +#define ODP_PKTIO_STATS_IN_OCTETS  (1 << 0)
> +/** Bit in odp_pktio_stats_mask_t defines if in_ucast_pkts counter
> + * of odp_pktio_stats_t struct is supported */
> +#define ODP_PKTIO_STATS_IN_UCAST_PKTS  (1 << 1)
> +/** Bit in odp_pktio_stats_mask_t defines if 

Re: [lng-odp] [API-NEXT PATCHv4 1/2] api: define pktio statistics api

2015-10-19 Thread Maxim Uvarov

On 10/19/2015 18:49, Ola Liljedahl wrote:
On 16 October 2015 at 15:25, Maxim Uvarov > wrote:


Signed-off-by: Maxim Uvarov >
---
 include/odp/api/packet_io_stats.h  | 166
+
 platform/linux-generic/include/odp/packet_io.h |   1 +
 2 files changed, 167 insertions(+)
 create mode 100644 include/odp/api/packet_io_stats.h

diff --git a/include/odp/api/packet_io_stats.h
b/include/odp/api/packet_io_stats.h
new file mode 100644
index 000..94af18c
--- /dev/null
+++ b/include/odp/api/packet_io_stats.h
@@ -0,0 +1,166 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP Packet IO
+ */
+
+#ifndef ODP_API_PACKET_IO_STATS_H_
+#define ODP_API_PACKET_IO_STATS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup odp_packet_io ODP PACKET IO
+ *  @{
+ */
+
+/**
+ * Packet IO statistics
+ *
+ * Packet IO statictics counters follow RFCs for Management
Information Base
+ * (MIB)for use with network management protocols in the Internet
community:
+ * https://tools.ietf.org/html/rfc3635
+ * https://tools.ietf.org/html/rfc2863
+ * https://tools.ietf.org/html/rfc2819
+ */
+typedef struct odp_pktio_stats_t {
+   /**
+* The number of octets in valid MAC frames received on
this interface,
+* including the MAC header and FCS. See ifHCInOctets counter
+* description in RFC 3635 for details.
+*/
+   uint64_t in_octets;
+   /**
+* The number of packets, delivered by this sub-layer to a
higher
+* (sub-)layer, which were not addressed to a multicast or
broadcast
+* address at this sub-layer. See InUcastPkts in RFC 2863.
+*/
+   uint64_t in_ucast_pkts;
+   /**
+* The number of inbound packets which were chosen to be
discarded
+* even though no errors had been detected to preven their
being
+* deliverable to a higher-layer protocol.  One possible
reason for
+* discarding such a packet could be to free up buffer space.
+* See InDiscards in RFC 2863.
+*/
+   uint64_t in_discards;
+   /**
+* The sum for this interface of AlignmentErrors,
FCSErrors, FrameTooLongs,
+* InternalMacReceiveErrors. See InErrors in RFC 3635.
+*/
+   uint64_t in_errors;
+   /**
+* For packet-oriented interfaces, the number of packets
received via
+* the interface which were discarded because of an unknown or
+* unsupported protocol.  For character-oriented or
fixed-length
+* interfaces that support protocol multiplexing the number of
+* transmission units received via the interface which
were discarded
+* because of an unknown or unsupported protocol. For any
interface
+* that does not support protocol multiplexing, this
counter will always
+* be 0. See InUnknownProtos in RFC 2863.
+*/
+   uint64_t in_unknown_protos;
+   /**
+* The number of octets transmitted in valid MAC frames on
this
+* interface, including the MAC header and FCS. This does
include
+* the number of octets in valid MAC Control frames
transmitted on
+* this interface. See OutOctets in RFC 3635.
+*/
+   uint64_t out_octets;
+   /**
+* The total number of packets that higher-level protocols
requested
+* be transmitted, and which were not addressed to a
multicast or
+* broadcast address at this sub-layer, including those
that were
+* discarded or not sent. does not include MAC Control frames.
+* See OutUcastPkts in RFC 2863, 3635.
+*/
+   uint64_t out_ucast_pkts;
+   /**
+* The number of outbound packets which were chosen to be
discarded
+* even though no errors had been detected to prevent
their being
+* transmitted.  One possible reason for discarding such a
packet could
+* be to free up buffer space.  See  OutDiscards in  RFC 2863.
+*/
+   uint64_t out_discards;
+   /**
+* The sum for this interface of SQETestErrors,
LateCollisions,
+* ExcessiveCollisions, InternalMacTransmitErrors and
+* CarrierSenseErrors. See OutErrors in RFC 3635.
+*/
+   uint64_t out_errors;
+} 

[lng-odp] [PATCHv10 6/8] helper: move ring test to helper

2015-10-19 Thread Maxim Uvarov
Move ring test to helper and kill not needed api_test
directory. Unfortunately odp_ring_test.c had some old
dirty code so I had to clean up it to to use cunit and
latest helper apis.

Signed-off-by: Maxim Uvarov 
---
 configure.ac   |   1 -
 helper/ring.c  |   1 +
 helper/test/Makefile.am|   6 +-
 .../api_test/odp_ring_test.c => helper/test/ring.c | 100 -
 test/Makefile.am   |   2 +-
 test/api_test/.gitignore   |   2 -
 test/api_test/Makefile.am  |  13 ---
 test/api_test/odp_common.c |  91 ---
 test/api_test/odp_common.h |  42 -
 9 files changed, 63 insertions(+), 195 deletions(-)
 rename test/api_test/odp_ring_test.c => helper/test/ring.c (86%)
 delete mode 100644 test/api_test/.gitignore
 delete mode 100644 test/api_test/Makefile.am
 delete mode 100644 test/api_test/odp_common.c
 delete mode 100644 test/api_test/odp_common.h

diff --git a/configure.ac b/configure.ac
index 15dc6cf..d90b09b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -292,7 +292,6 @@ AC_CONFIG_FILES([Makefile
 pkgconfig/libodphelper.pc
 scripts/Makefile
 test/Makefile
-test/api_test/Makefile
 test/performance/Makefile
 test/validation/Makefile
 test/validation/buffer/Makefile
diff --git a/helper/ring.c b/helper/ring.c
index fe01c5d..9052628 100644
--- a/helper/ring.c
+++ b/helper/ring.c
@@ -644,3 +644,4 @@ int odph_ring_dequeue_burst(odph_ring_t *r, void 
**obj_table, unsigned n)
else
return odph_ring_mc_dequeue_burst(r, obj_table, n);
 }
+
diff --git a/helper/test/Makefile.am b/helper/test/Makefile.am
index f6a3f83..3e0df0b 100644
--- a/helper/test/Makefile.am
+++ b/helper/test/Makefile.am
@@ -1,13 +1,15 @@
 include $(top_srcdir)/test/Makefile.inc
 
 AM_CFLAGS += -I$(srcdir)/common
+AM_CFLAGS += -I$(top_srcdir)/test/validation/common
 AM_LDFLAGS += -static
 
 TESTS_ENVIRONMENT += TEST_DIR=${builddir}
 
 EXECUTABLES = chksum$(EXEEXT) \
   thread$(EXEEXT) \
-  process$(EXEEXT)
+  process$(EXEEXT) \
+  ring$(EXEEXT)
 
 COMPILE_ONLY =
 
@@ -27,3 +29,5 @@ dist_thread_SOURCES = thread.c
 thread_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la
 dist_process_SOURCES = process.c
 process_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la
+dist_ring_SOURCES = ring.c
+ring_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la
diff --git a/test/api_test/odp_ring_test.c b/helper/test/ring.c
similarity index 86%
rename from test/api_test/odp_ring_test.c
rename to helper/test/ring.c
index e8a962a..ca2199d 100644
--- a/test/api_test/odp_ring_test.c
+++ b/helper/test/ring.c
@@ -37,7 +37,6 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-
 /**
  * @file
  *
@@ -48,14 +47,24 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
+#include 
 
 #define RING_SIZE 4096
 #define MAX_BULK 32
 
-#define RING_TEST_BASIC
+enum {
+   ODP_RING_TEST_BASIC,
+   ODP_RING_TEST_STRESS,
+};
+
+/* local struct for ring_thread argument */
+typedef struct {
+   pthrd_arg thrdarg;
+   int stress_type;
+} ring_arg_t;
 
 static int test_ring_basic(odph_ring_t *r)
 {
@@ -64,24 +73,24 @@ static int test_ring_basic(odph_ring_t *r)
unsigned i, num_elems;
 
/* alloc dummy object pointers */
-   src = malloc(RING_SIZE*2*sizeof(void *));
+   src = malloc(RING_SIZE * 2 * sizeof(void *));
if (src == NULL) {
LOG_ERR("failed to allocate test ring src memory\n");
goto fail;
}
-   for (i = 0; i < RING_SIZE*2; i++)
+   for (i = 0; i < RING_SIZE * 2; i++)
src[i] = (void *)(unsigned long)i;
 
cur_src = src;
 
/* alloc some room for copied objects */
-   dst = malloc(RING_SIZE*2*sizeof(void *));
+   dst = malloc(RING_SIZE * 2 * sizeof(void *));
if (dst == NULL) {
LOG_ERR("failed to allocate test ring dst memory\n");
goto fail;
}
 
-   memset(dst, 0, RING_SIZE*2*sizeof(void *));
+   memset(dst, 0, RING_SIZE * 2 * sizeof(void *));
cur_dst = dst;
 
printf("Test SP & SC basic functions\n");
@@ -251,7 +260,7 @@ static int producer_fn(void)
void **src = NULL;
 
/* alloc dummy object pointers */
-   src = malloc(MAX_BULK*2*sizeof(void *));
+   src = malloc(MAX_BULK * 2 * sizeof(void *));
if (src == NULL) {
LOG_ERR("failed to allocate producer memory.\n");
return -1;
@@ -275,7 +284,7 @@ static int consumer_fn(void)
void **src = NULL;
 
/* alloc dummy object pointers */
-   src = 

[lng-odp] [PATCHv10 3/8] move odph_pause inside linux-generic

2015-10-19 Thread Maxim Uvarov
Move odph_pause inside linux-generic. Validation test is also useless
with such move.

Signed-off-by: Maxim Uvarov 
---
 helper/Makefile.am |  4 +---
 helper/ring.c  |  2 +-
 helper/test/Makefile.am|  4 +---
 helper/test/odph_pause.c   | 14 --
 platform/linux-generic/Makefile.am |  1 +
 .../linux-generic/include/odp_pause_internal.h |  4 ++--
 6 files changed, 6 insertions(+), 23 deletions(-)
 delete mode 100644 helper/test/odph_pause.c
 rename helper/odph_pause.h => 
platform/linux-generic/include/odp_pause_internal.h (93%)

diff --git a/helper/Makefile.am b/helper/Makefile.am
index 1a74e8e..cde8af2 100644
--- a/helper/Makefile.am
+++ b/helper/Makefile.am
@@ -19,9 +19,7 @@ helperinclude_HEADERS = \
  $(srcdir)/include/odp/helper/tcp.h\
  $(srcdir)/include/odp/helper/udp.h
 
-noinst_HEADERS = \
-$(srcdir)/odph_debug.h \
-$(srcdir)/odph_pause.h
+noinst_HEADERS = $(srcdir)/odph_debug.h
 
 __LIB__libodphelper_la_SOURCES = \
linux.c \
diff --git a/helper/ring.c b/helper/ring.c
index 844abf7..6bb2bda 100644
--- a/helper/ring.c
+++ b/helper/ring.c
@@ -71,7 +71,7 @@
 
 #include 
 #include 
-#include "odph_pause.h"
+#include "odp_pause_internal.h"
 #include 
 #include 
 #include 
diff --git a/helper/test/Makefile.am b/helper/test/Makefile.am
index fbf5a9b..7b73602 100644
--- a/helper/test/Makefile.am
+++ b/helper/test/Makefile.am
@@ -7,8 +7,7 @@ TESTS_ENVIRONMENT += TEST_DIR=${builddir}
 
 EXECUTABLES = odp_chksum$(EXEEXT) \
   odp_thread$(EXEEXT) \
-  odp_process$(EXEEXT)\
-  odph_pause$(EXEEXT)
+  odp_process$(EXEEXT)
 
 COMPILE_ONLY =
 
@@ -28,4 +27,3 @@ dist_odp_thread_SOURCES = odp_thread.c
 odp_thread_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la
 dist_odp_process_SOURCES = odp_process.c
 odp_process_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la
-odph_pause_SOURCES = odph_pause.c
diff --git a/helper/test/odph_pause.c b/helper/test/odph_pause.c
deleted file mode 100644
index f5f5da3..000
--- a/helper/test/odph_pause.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Copyright (c) 2015, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include 
-#include "../odph_pause.h"
-
-int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED)
-{
-   odph_pause();
-   return 0;
-}
diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 4c79730..b9ed3b0 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -128,6 +128,7 @@ noinst_HEADERS = \
  ${srcdir}/include/odp_packet_io_internal.h \
  ${srcdir}/include/odp_packet_io_queue.h \
  ${srcdir}/include/odp_packet_socket.h \
+ ${srcdir}/include/odp_pause_internal.h \
  ${srcdir}/include/odp_pool_internal.h \
  ${srcdir}/include/odp_queue_internal.h \
  ${srcdir}/include/odp_schedule_internal.h \
diff --git a/helper/odph_pause.h 
b/platform/linux-generic/include/odp_pause_internal.h
similarity index 93%
rename from helper/odph_pause.h
rename to platform/linux-generic/include/odp_pause_internal.h
index 5618f1f..ad2c628 100644
--- a/helper/odph_pause.h
+++ b/platform/linux-generic/include/odp_pause_internal.h
@@ -4,8 +4,8 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#ifndef ODPH_PAUSE_H_
-#define ODPH_PAUSE_H_
+#ifndef ODP_PAUSE_INTERNAL_H_
+#define ODP_PAUSE_INTERNAL_H_
 
 #ifdef __cplusplus
 extern "C" {
-- 
1.9.1

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


[lng-odp] [PATCHv10 8/8] linux-generic: internal ipc_pktio test

2015-10-19 Thread Maxim Uvarov
2 example ipc pktio applications create ipc pktio to each other and do
packet transfer, validation magic numbers and packets sequence counters
inside it.

Signed-off-by: Maxim Uvarov 
---
 platform/linux-generic/Makefile.am |   1 +
 platform/linux-generic/m4/configure.m4 |   3 +-
 platform/linux-generic/test/Makefile.am|   3 +-
 platform/linux-generic/test/pktio_ipc/.gitignore   |   1 +
 platform/linux-generic/test/pktio_ipc/Makefile.am  |  15 ++
 platform/linux-generic/test/pktio_ipc/ipc_common.c | 150 
 platform/linux-generic/test/pktio_ipc/ipc_common.h |  71 ++
 platform/linux-generic/test/pktio_ipc/pktio_ipc1.c | 268 +
 platform/linux-generic/test/pktio_ipc/pktio_ipc2.c | 142 +++
 .../linux-generic/test/pktio_ipc/pktio_ipc_run |  55 +
 10 files changed, 707 insertions(+), 2 deletions(-)
 create mode 100644 platform/linux-generic/test/pktio_ipc/.gitignore
 create mode 100644 platform/linux-generic/test/pktio_ipc/Makefile.am
 create mode 100644 platform/linux-generic/test/pktio_ipc/ipc_common.c
 create mode 100644 platform/linux-generic/test/pktio_ipc/ipc_common.h
 create mode 100644 platform/linux-generic/test/pktio_ipc/pktio_ipc1.c
 create mode 100644 platform/linux-generic/test/pktio_ipc/pktio_ipc2.c
 create mode 100755 platform/linux-generic/test/pktio_ipc/pktio_ipc_run

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 71353dd..6fe2f1a 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -5,6 +5,7 @@ include $(top_srcdir)/platform/Makefile.inc
 
 AM_CFLAGS +=  -I$(srcdir)/include
 AM_CFLAGS +=  -I$(top_srcdir)/include
+AM_CFLAGS +=  -I$(top_srcdir)/helper
 AM_CFLAGS +=  -I$(top_srcdir)/helper/include
 
 include_HEADERS = \
diff --git a/platform/linux-generic/m4/configure.m4 
b/platform/linux-generic/m4/configure.m4
index 9658274..3a2d743 100644
--- a/platform/linux-generic/m4/configure.m4
+++ b/platform/linux-generic/m4/configure.m4
@@ -21,4 +21,5 @@ m4_include([platform/linux-generic/m4/odp_openssl.m4])
 
 AC_CONFIG_FILES([platform/linux-generic/Makefile
 platform/linux-generic/test/Makefile
-platform/linux-generic/test/pktio/Makefile])
+platform/linux-generic/test/pktio/Makefile
+platform/linux-generic/test/pktio_ipc/Makefile])
diff --git a/platform/linux-generic/test/Makefile.am 
b/platform/linux-generic/test/Makefile.am
index 7d1ce1b..db98d28 100644
--- a/platform/linux-generic/test/Makefile.am
+++ b/platform/linux-generic/test/Makefile.am
@@ -1,10 +1,11 @@
 include $(top_srcdir)/test/Makefile.inc
 TESTS_ENVIRONMENT += TEST_DIR=${top_builddir}/test/validation
 
-ODP_MODULES = pktio
+ODP_MODULES = pktio pktio_ipc
 
 if test_vald
 TESTS = pktio/pktio_run \
+   pktio_ipc/pktio_ipc_run \
${top_builddir}/test/validation/buffer/buffer_main$(EXEEXT) \

${top_builddir}/test/validation/classification/classification_main$(EXEEXT) \
${top_builddir}/test/validation/cpumask/cpumask_main$(EXEEXT) \
diff --git a/platform/linux-generic/test/pktio_ipc/.gitignore 
b/platform/linux-generic/test/pktio_ipc/.gitignore
new file mode 100644
index 000..d2a7ce2
--- /dev/null
+++ b/platform/linux-generic/test/pktio_ipc/.gitignore
@@ -0,0 +1 @@
+pktio_ipc
diff --git a/platform/linux-generic/test/pktio_ipc/Makefile.am 
b/platform/linux-generic/test/pktio_ipc/Makefile.am
new file mode 100644
index 000..adf6294
--- /dev/null
+++ b/platform/linux-generic/test/pktio_ipc/Makefile.am
@@ -0,0 +1,15 @@
+include $(top_srcdir)/test/Makefile.inc
+TESTS_ENVIRONMENT += TEST_DIR=${top_builddir}/test/validation
+
+bin_PROGRAMS = pktio_ipc1\
+   pktio_ipc2
+
+pktio_ipc1_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
+pktio_ipc1_LDFLAGS = $(AM_LDFLAGS) -static
+pktio_ipc2_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
+pktio_ipc2_LDFLAGS = $(AM_LDFLAGS) -static
+
+noinst_HEADERS = $(top_srcdir)/test/test_debug.h
+
+dist_pktio_ipc1_SOURCES = pktio_ipc1.c ipc_common.c
+dist_pktio_ipc2_SOURCES = pktio_ipc2.c ipc_common.c
diff --git a/platform/linux-generic/test/pktio_ipc/ipc_common.c 
b/platform/linux-generic/test/pktio_ipc/ipc_common.c
new file mode 100644
index 000..7a84b07
--- /dev/null
+++ b/platform/linux-generic/test/pktio_ipc/ipc_common.c
@@ -0,0 +1,150 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "ipc_common.h"
+
+/** Application argument */
+char *pktio_name;
+
+/** Run time in seconds */
+int run_time_sec;
+
+int ipc_odp_packet_sendall(odp_pktio_t pktio,
+  odp_packet_t pkt_tbl[], int num)
+{
+   int ret;
+   int sent = 0;
+   uint64_t start_cycle;
+   uint64_t diff;
+
+   start_cycle = odp_time_cycles();
+
+   while (sent != num) {
+   ret = odp_pktio_send(pktio, _tbl[sent], num 

Re: [lng-odp] [PATCHv9 7/8] linux-generic: add ipc pktio support

2015-10-19 Thread Maxim Uvarov

On 10/13/2015 16:50, Nicolas Morey-Chaisemartin wrote:


On 10/09/2015 01:59 PM, Maxim Uvarov wrote:

Signed-off-by: Maxim Uvarov 
---
  platform/linux-generic/Makefile.am |   2 +
  .../linux-generic/include/odp_buffer_internal.h|   3 +
  .../linux-generic/include/odp_packet_io_internal.h |  35 +
  .../include/odp_packet_io_ipc_internal.h   |  51 ++
  platform/linux-generic/include/odp_shm_internal.h  |  20 +
  platform/linux-generic/odp_packet_io.c |   1 +
  platform/linux-generic/odp_pool.c  |  11 +-
  platform/linux-generic/odp_shared_memory.c |  10 +-
  platform/linux-generic/pktio/io_ops.c  |   1 +
  platform/linux-generic/pktio/ipc.c | 720 +
  platform/linux-generic/pktio/ring.c|   1 +
  11 files changed, 851 insertions(+), 4 deletions(-)
  create mode 100644 platform/linux-generic/include/odp_packet_io_ipc_internal.h
  create mode 100644 platform/linux-generic/include/odp_shm_internal.h
  create mode 100644 platform/linux-generic/pktio/ipc.c
  create mode 12 platform/linux-generic/pktio/ring.c

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index b9ed3b0..71353dd 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -151,9 +151,11 @@ __LIB__libodp_la_SOURCES = \
   odp_packet_flags.c \
   odp_packet_io.c \
   pktio/io_ops.c \
+  pktio/ipc.c \
   pktio/loop.c \
   pktio/socket.c \
   pktio/socket_mmap.c \
+  pktio/ring.c \
   odp_pool.c \
   odp_queue.c \
   odp_rwlock.c \
diff --git a/platform/linux-generic/include/odp_buffer_internal.h 
b/platform/linux-generic/include/odp_buffer_internal.h
index 4cacca1..a078e52 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -132,6 +132,9 @@ struct odp_buffer_hdr_t {
uint32_t uarea_size; /* size of user area */
uint32_t segcount;   /* segment count */
uint32_t segsize;/* segment size */
+   /* ipc mapped process can not walk over pointers,
+* offset has to be used */
+   uint64_t ipc_addr_offset[ODP_BUFFER_MAX_SEG];
void*addr[ODP_BUFFER_MAX_SEG]; /* block addrs */
uint64_t order;  /* sequence for ordered queues */
queue_entry_t   *origin_qe;  /* ordered queue origin */

I haven't been through everything yet but should this be an union with the addr 
?
The odp_buffer_hdr_t is already quite large as it is.

Nicolas
Unfortunately that can not be union. Because of pool can be used by 
current process and also with other process which mapped this pool
I will have the same code in new version until I will find better 
solution to lower this struct size. Might be we don't need u64 for 
offsets here.


Maxim.


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


[lng-odp] [PATCHv10 2/8] linux-generic: create internal pool create function with shm flags

2015-10-19 Thread Maxim Uvarov
On init odp creates odp_sched_pool. We can not modify API to add new
parameter to odp_pool_param_t and this pool should not be shared
between different processes. To do that implemented internal linux-generic
function with parameters to created shm.
Note: create shm before and then provide it to the pool does not work
because shm argument likely will be dropped from odp_pool_create() (patch
already posted.).

Signed-off-by: Maxim Uvarov 
---
 platform/linux-generic/include/odp_pool_internal.h |  4 
 platform/linux-generic/odp_pool.c  | 11 +--
 platform/linux-generic/odp_schedule.c  |  3 +--
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/platform/linux-generic/include/odp_pool_internal.h 
b/platform/linux-generic/include/odp_pool_internal.h
index 136db2c..6781703 100644
--- a/platform/linux-generic/include/odp_pool_internal.h
+++ b/platform/linux-generic/include/odp_pool_internal.h
@@ -347,6 +347,10 @@ static inline uint32_t odp_buffer_pool_tailroom(odp_pool_t 
pool)
return odp_pool_to_entry(pool)->s.tailroom;
 }
 
+odp_pool_t _pool_create(const char *name,
+   odp_pool_param_t *params,
+   uint32_t shmflags);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/platform/linux-generic/odp_pool.c 
b/platform/linux-generic/odp_pool.c
index 30d4b2b..2036c2a 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -144,7 +144,9 @@ int odp_pool_term_local(void)
  * Pool creation
  */
 
-odp_pool_t odp_pool_create(const char *name, odp_pool_param_t *params)
+odp_pool_t _pool_create(const char *name,
+   odp_pool_param_t *params,
+   uint32_t shmflags)
 {
odp_pool_t pool_hdl = ODP_POOL_INVALID;
pool_entry_t *pool;
@@ -290,7 +292,7 @@ odp_pool_t odp_pool_create(const char *name, 
odp_pool_param_t *params)
 
shm = odp_shm_reserve(pool->s.name,
  pool->s.pool_size,
- ODP_PAGE_SIZE, 0);
+ ODP_PAGE_SIZE, shmflags);
if (shm == ODP_SHM_INVALID) {
POOL_UNLOCK(>s.lock);
return ODP_POOL_INVALID;
@@ -403,6 +405,11 @@ odp_pool_t odp_pool_create(const char *name, 
odp_pool_param_t *params)
return pool_hdl;
 }
 
+odp_pool_t odp_pool_create(const char *name,
+  odp_pool_param_t *params)
+{
+   return _pool_create(name, params, ODP_SHM_PROC);
+}
 
 odp_pool_t odp_pool_lookup(const char *name)
 {
diff --git a/platform/linux-generic/odp_schedule.c 
b/platform/linux-generic/odp_schedule.c
index 827fcf0..c66c177 100644
--- a/platform/linux-generic/odp_schedule.c
+++ b/platform/linux-generic/odp_schedule.c
@@ -140,8 +140,7 @@ int odp_schedule_init_global(void)
params.buf.num   = NUM_SCHED_CMD;
params.type  = ODP_POOL_BUFFER;
 
-   pool = odp_pool_create("odp_sched_pool", );
-
+   pool = _pool_create("odp_sched_pool", , 0);
if (pool == ODP_POOL_INVALID) {
ODP_ERR("Schedule init: Pool create failed.\n");
return -1;
-- 
1.9.1

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


[lng-odp] [PATCHv10 4/8] helper: flag to not link ring to linked list

2015-10-19 Thread Maxim Uvarov
Add flag ODPH_RING_NO_LIST to ring to not link it to linked list.

Signed-off-by: Maxim Uvarov 
---
 helper/include/odp/helper/ring.h | 7 ---
 helper/ring.c| 3 ++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/helper/include/odp/helper/ring.h b/helper/include/odp/helper/ring.h
index 5e640a7..c3c2f6a 100644
--- a/helper/include/odp/helper/ring.h
+++ b/helper/include/odp/helper/ring.h
@@ -156,10 +156,11 @@ typedef struct odph_ring {
 } odph_ring_t;
 
 
-#define ODPH_RING_F_SP_ENQ 0x0001 /* The default enqueue is 
"single-producer".*/
-#define ODPH_RING_F_SC_DEQ 0x0002 /* The default dequeue is 
"single-consumer".*/
-#define ODPH_RING_SHM_PROC 0x0004 /* If set - ring is visible from different
+#define ODPH_RING_F_SP_ENQ (1 << 0) /* The default enqueue is 
"single-producer".*/
+#define ODPH_RING_F_SC_DEQ (1 << 1) /* The default dequeue is 
"single-consumer".*/
+#define ODPH_RING_SHM_PROC (1 << 2) /* If set - ring is visible from different
processes. Default is thread visible. */
+#define ODPH_RING_NO_LIST  (1 << 3) /* Do not link ring to linked list. */
 #define ODPH_RING_QUOT_EXCEED (1 << 31)  /* Quota exceed for burst ops */
 #define ODPH_RING_SZ_MASK  (unsigned)(0x0fff) /* Ring size mask */
 
diff --git a/helper/ring.c b/helper/ring.c
index 6bb2bda..fe01c5d 100644
--- a/helper/ring.c
+++ b/helper/ring.c
@@ -199,7 +199,8 @@ odph_ring_create(const char *name, unsigned count, unsigned 
flags)
r->prod.tail = 0;
r->cons.tail = 0;
 
-   TAILQ_INSERT_TAIL(_ring_list, r, next);
+   if (!(flags & ODPH_RING_NO_LIST))
+   TAILQ_INSERT_TAIL(_ring_list, r, next);
} else {
ODPH_ERR("Cannot reserve memory\n");
}
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCHv3 4/4] example: tm: traffic manager example

2015-10-19 Thread Bill Fischofer
From: Barry Spinney 

This commit includes all of the changes to build the traffic_mgr example
application.

Signed-off-by: Barry Spinney 
Signed-off-by: Bill Fischofer 
---
 configure.ac|   1 +
 example/Makefile.am |   2 +-
 example/traffic_mgmt/.gitignore |   1 +
 example/traffic_mgmt/Makefile.am|   9 +
 example/traffic_mgmt/odp_traffic_mgmt.c | 775 
 5 files changed, 787 insertions(+), 1 deletion(-)
 create mode 100644 example/traffic_mgmt/.gitignore
 create mode 100644 example/traffic_mgmt/Makefile.am
 create mode 100644 example/traffic_mgmt/odp_traffic_mgmt.c

diff --git a/configure.ac b/configure.ac
index a7e7413..a6ad770 100644
--- a/configure.ac
+++ b/configure.ac
@@ -302,6 +302,7 @@ AC_CONFIG_FILES([Makefile
 example/ipsec/Makefile
 example/packet/Makefile
 example/timer/Makefile
+example/traffic_mgmt/Makefile
 helper/Makefile
 helper/test/Makefile
 pkgconfig/libodp.pc
diff --git a/example/Makefile.am b/example/Makefile.am
index 353f397..6b67bf5 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -1 +1 @@
-SUBDIRS = classifier generator ipsec packet timer
+SUBDIRS = classifier generator ipsec packet timer traffic_mgmt
diff --git a/example/traffic_mgmt/.gitignore b/example/traffic_mgmt/.gitignore
new file mode 100644
index 000..9e742f0
--- /dev/null
+++ b/example/traffic_mgmt/.gitignore
@@ -0,0 +1 @@
+odp_traffic_mgmt
\ No newline at end of file
diff --git a/example/traffic_mgmt/Makefile.am b/example/traffic_mgmt/Makefile.am
new file mode 100644
index 000..c8ff797
--- /dev/null
+++ b/example/traffic_mgmt/Makefile.am
@@ -0,0 +1,9 @@
+include $(top_srcdir)/example/Makefile.inc
+
+bin_PROGRAMS = odp_traffic_mgmt$(EXEEXT)
+odp_traffic_mgmt_LDFLAGS = $(AM_LDFLAGS) -static
+odp_traffic_mgmt_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
+
+noinst_HEADERS = $(top_srcdir)/example/example_debug.h
+
+dist_odp_traffic_mgmt_SOURCES = odp_traffic_mgmt.c
diff --git a/example/traffic_mgmt/odp_traffic_mgmt.c 
b/example/traffic_mgmt/odp_traffic_mgmt.c
new file mode 100644
index 000..d2e0411
--- /dev/null
+++ b/example/traffic_mgmt/odp_traffic_mgmt.c
@@ -0,0 +1,775 @@
+/* Copyright 2015 EZchip Semiconductor Ltd. All Rights Reserved.
+ *
+ * Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#define _GNU_SOURCE
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define NUM_SVC_CLASSES 4
+#define USERS_PER_SVC_CLASS 2
+#define APPS_PER_USER   2
+#define TM_QUEUES_PER_APP   2
+#define NUM_USERS   (USERS_PER_SVC_CLASS * NUM_SVC_CLASSES)
+#define NUM_TM_QUEUES   (NUM_USERS * APPS_PER_USER * TM_QUEUES_PER_APP)
+#define TM_QUEUES_PER_USER  (TM_QUEUES_PER_APP * APPS_PER_USER)
+#define TM_QUEUES_PER_CLASS (USERS_PER_SVC_CLASS * TM_QUEUES_PER_USER)
+
+#define Kbps   1000
+#define Mbps   100
+#define PERCENT(percent)  (100 * percent)
+
+#define FALSE  0
+#define TRUE   1
+
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+
+#define RANDOM_BUF_LEN  1024
+
+typedef struct {
+   odp_tm_shaper_params_tshaper_params;
+   odp_tm_threshold_params_t threshold_params;
+   odp_tm_wred_params_t  wred_params[ODP_NUM_PKT_COLORS];
+} profile_params_set_t;
+
+typedef struct {
+   odp_tm_shaper_tshaper_profile;
+   odp_tm_threshold_t threshold_profile;
+   odp_tm_wred_t  wred_profiles[ODP_NUM_PKT_COLORS];
+} profile_set_t;
+
+static const odp_init_t ODP_INIT_PARAMS = {
+   .log_fn   = odp_override_log,
+   .abort_fn = odp_override_abort
+};
+
+static const odp_platform_init_t PLATFORM_PARAMS = {
+};
+
+static profile_params_set_t COMPANY_PROFILE_PARAMS = {
+   .shaper_params = {
+   .commit_bps = 50  * Mbps,  .commit_burst  = 100,
+   .peak_bps   = 0,   .peak_burst= 0,
+   .dual_rate  = FALSE,   .shaper_len_adjust = 20
+   },
+
+   .threshold_params = {
+   .max_pkts  = 10,.enable_max_pkts  = TRUE,
+   .max_bytes = 1000,  .enable_max_bytes = TRUE
+   },
+
+   .wred_params = {
+   [PKT_GREEN ... PKT_YELLOW] = {
+   .min_threshold = PERCENT(70),
+   .med_threshold = PERCENT(90),
+   .med_drop_prob = PERCENT(80),
+   .max_drop_prob = PERCENT(100),
+   .enable_wred   = TRUE,
+   .use_byte_fullness = FALSE,
+   },
+
+   [PKT_RED] = {
+   .min_threshold = PERCENT(40),
+   .med_threshold   

[lng-odp] [API-NEXT PATCHv3 0/4] Egress Traffic Manager

2015-10-19 Thread Bill Fischofer
Changes in v3
- Fix checkpatch errors (Bill)

Changes in v2
- Full patch submission (Barry)

Barry Spinney (4):
  api: tm: add tm API definitions
  linux-generic: tm: implement traffic manager
  linux-generic: tm: add tm to build
  example: tm: traffic manager example

 configure.ac   |1 +
 example/Makefile.am|2 +-
 example/traffic_mgmt/.gitignore|1 +
 example/traffic_mgmt/Makefile.am   |9 +
 example/traffic_mgmt/odp_traffic_mgmt.c|  775 +
 include/odp.h  |1 +
 include/odp/api/packet_flags.h |   49 +
 include/odp/api/traffic_mngr.h | 1617 ++
 platform/linux-generic/Makefile.am |   12 +
 .../linux-generic/include/odp/plat/packet_types.h  |   11 +
 .../include/odp/plat/traffic_mngr_types.h  |  188 ++
 platform/linux-generic/include/odp/traffic_mngr.h  |   35 +
 platform/linux-generic/include/odp_internal.h  |2 +
 .../include/odp_name_table_internal.h  |   61 +
 .../linux-generic/include/odp_packet_internal.h|5 +
 .../linux-generic/include/odp_pkt_queue_internal.h |   62 +
 .../include/odp_sorted_list_internal.h |   77 +
 .../include/odp_timer_wheel_internal.h |   68 +
 platform/linux-generic/odp_init.c  |5 +
 platform/linux-generic/odp_name_table.c| 1367 +
 platform/linux-generic/odp_packet_flags.c  |   45 +
 platform/linux-generic/odp_pkt_queue.c |  379 +++
 platform/linux-generic/odp_sorted_list.c   |  270 ++
 platform/linux-generic/odp_timer_wheel.c   |  907 ++
 platform/linux-generic/odp_traffic_mngr.c  | 3077 
 25 files changed, 9025 insertions(+), 1 deletion(-)
 create mode 100644 example/traffic_mgmt/.gitignore
 create mode 100644 example/traffic_mgmt/Makefile.am
 create mode 100644 example/traffic_mgmt/odp_traffic_mgmt.c
 create mode 100644 include/odp/api/traffic_mngr.h
 create mode 100644 platform/linux-generic/include/odp/plat/traffic_mngr_types.h
 create mode 100644 platform/linux-generic/include/odp/traffic_mngr.h
 create mode 100644 platform/linux-generic/include/odp_name_table_internal.h
 create mode 100644 platform/linux-generic/include/odp_pkt_queue_internal.h
 create mode 100644 platform/linux-generic/include/odp_sorted_list_internal.h
 create mode 100644 platform/linux-generic/include/odp_timer_wheel_internal.h
 create mode 100644 platform/linux-generic/odp_name_table.c
 create mode 100644 platform/linux-generic/odp_pkt_queue.c
 create mode 100644 platform/linux-generic/odp_sorted_list.c
 create mode 100644 platform/linux-generic/odp_timer_wheel.c
 create mode 100644 platform/linux-generic/odp_traffic_mngr.c

-- 
2.1.4

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


[lng-odp] [API-NEXT PATCHv3 3/4] linux-generic: tm: add tm to build

2015-10-19 Thread Bill Fischofer
From: Barry Spinney 

This commit causes the traffic_mgr to become part of the ODP linux-generic
build.

Signed-off-by: Barry Spinney 
Signed-off-by: Bill Fischofer 
---
 platform/linux-generic/Makefile.am| 12 +++
 platform/linux-generic/include/odp_internal.h |  2 ++
 platform/linux-generic/odp_init.c |  5 +++
 platform/linux-generic/odp_packet_flags.c | 45 +++
 4 files changed, 64 insertions(+)

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 85c976d..115ac1c 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -49,6 +49,7 @@ odpinclude_HEADERS = \
  $(srcdir)/include/odp/ticketlock.h \
  $(srcdir)/include/odp/time.h \
  $(srcdir)/include/odp/timer.h \
+ $(srcdir)/include/odp/traffic_mngr.h \
  $(srcdir)/include/odp/version.h
 
 odpplatincludedir= $(includedir)/odp/plat
@@ -75,6 +76,7 @@ odpplatinclude_HEADERS = \
  $(srcdir)/include/odp/plat/thrmask_types.h \
  $(srcdir)/include/odp/plat/ticketlock_types.h \
  $(srcdir)/include/odp/plat/timer_types.h \
+ $(srcdir)/include/odp/plat/traffic_mngr_types.h \
  $(srcdir)/include/odp/plat/version_types.h
 
 odpapiincludedir= $(includedir)/odp/api
@@ -116,6 +118,7 @@ odpapiinclude_HEADERS = \
  $(top_srcdir)/include/odp/api/ticketlock.h \
  $(top_srcdir)/include/odp/api/time.h \
  $(top_srcdir)/include/odp/api/timer.h \
+ $(top_srcdir)/include/odp/api/traffic_mngr.h \
  $(top_srcdir)/include/odp/api/version.h
 
 noinst_HEADERS = \
@@ -131,16 +134,20 @@ noinst_HEADERS = \
  ${srcdir}/include/odp_debug_internal.h \
  ${srcdir}/include/odp_forward_typedefs_internal.h \
  ${srcdir}/include/odp_internal.h \
+ ${srcdir}/include/odp_name_table_internal.h \
  ${srcdir}/include/odp_packet_internal.h \
  ${srcdir}/include/odp_packet_io_internal.h \
  ${srcdir}/include/odp_packet_io_queue.h \
  ${srcdir}/include/odp_packet_netmap.h \
  ${srcdir}/include/odp_packet_socket.h \
+ ${srcdir}/include/odp_pkt_queue_internal.h \
  ${srcdir}/include/odp_pool_internal.h \
  ${srcdir}/include/odp_queue_internal.h \
  ${srcdir}/include/odp_schedule_internal.h \
+ ${srcdir}/include/odp_sorted_list_internal.h \
  ${srcdir}/include/odp_spin_internal.h \
  ${srcdir}/include/odp_timer_internal.h \
+ ${srcdir}/include/odp_timer_wheel_internal.h \
  ${srcdir}/include/odp_cpu_internal.h \
  ${srcdir}/Makefile.inc
 
@@ -156,6 +163,7 @@ __LIB__libodp_la_SOURCES = \
   odp_event.c \
   odp_init.c \
   odp_impl.c \
+  odp_name_table.c \
   odp_packet.c \
   odp_packet_flags.c \
   odp_packet_io.c \
@@ -164,12 +172,14 @@ __LIB__libodp_la_SOURCES = \
   pktio/netmap.c \
   pktio/socket.c \
   pktio/socket_mmap.c \
+  odp_pkt_queue.c \
   odp_pool.c \
   odp_queue.c \
   odp_rwlock.c \
   odp_rwlock_recursive.c \
   odp_schedule.c \
   odp_shared_memory.c \
+  odp_sorted_list.c \
   odp_spinlock.c \
   odp_spinlock_recursive.c \
   odp_system_info.c \
@@ -178,6 +188,8 @@ __LIB__libodp_la_SOURCES = \
   odp_ticketlock.c \
   odp_time.c \
   odp_timer.c \
+  odp_timer_wheel.c \
+  odp_traffic_mngr.c \
   odp_version.c \
   odp_weak.c \
   arch/@ARCH@/odp_cpu_cycles.c
diff --git a/platform/linux-generic/include/odp_internal.h 
b/platform/linux-generic/include/odp_internal.h
index 8a1a219..a852c5b 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -78,6 +78,8 @@ int odp_schedule_term_local(void);
 int odp_timer_init_global(void);
 int odp_timer_disarm_all(void);
 
+int odp_tm_init_global(void);
+
 void _odp_flush_caches(void);
 
 #ifdef __cplusplus
diff --git a/platform/linux-generic/odp_init.c 

[lng-odp] [API-NEXT PATCHv3 1/4] api: tm: add tm API definitions

2015-10-19 Thread Bill Fischofer
From: Barry Spinney 

This introduces an API for configuring and using Traffic Management
systems.

The purpose of this API is as a general packet scheduling system that
accepts packets from input queues and applies strict priority
scheduling, weighted fair queuing scheduling and/or bandwidth controls
to decide which input packet should be chosen as the next output
packet and when this output packet can be sent onwards.

Signed-off-by: Barry Spinney 
Signed-off-by: Bill Fischofer 
---
 include/odp.h  |1 +
 include/odp/api/packet_flags.h |   49 +
 include/odp/api/traffic_mngr.h | 1617 
 .../linux-generic/include/odp/plat/packet_types.h  |   11 +
 .../include/odp/plat/traffic_mngr_types.h  |  188 +++
 platform/linux-generic/include/odp/traffic_mngr.h  |   35 +
 .../linux-generic/include/odp_packet_internal.h|5 +
 7 files changed, 1906 insertions(+)
 create mode 100644 include/odp/api/traffic_mngr.h
 create mode 100644 platform/linux-generic/include/odp/plat/traffic_mngr_types.h
 create mode 100644 platform/linux-generic/include/odp/traffic_mngr.h

diff --git a/include/odp.h b/include/odp.h
index 825c7e1..f6a6ea9 100644
--- a/include/odp.h
+++ b/include/odp.h
@@ -56,6 +56,7 @@ extern "C" {
 #include 
 #include 
 #include 
+#include 
 
 #ifdef __cplusplus
 }
diff --git a/include/odp/api/packet_flags.h b/include/odp/api/packet_flags.h
index 7c3b247..d45e836 100644
--- a/include/odp/api/packet_flags.h
+++ b/include/odp/api/packet_flags.h
@@ -345,6 +345,55 @@ void odp_packet_has_icmp_set(odp_packet_t pkt, int val);
 void odp_packet_has_flow_hash_clr(odp_packet_t pkt);
 
 /**
+ * Get packet color
+ * @param pkt Packet handle
+ * @return packet color
+ */
+odp_pkt_color_t odp_packet_color(odp_packet_t pkt);
+
+/**
+ * Set packet color
+ *
+ * @param pkt Packet handle
+ * @param color Color to set
+ */
+void odp_packet_color_set(odp_packet_t pkt, odp_pkt_color_t color);
+
+/**
+ * Get drop eligible status
+ *
+ * @param pkt Packet handle
+ * @return Packet drop eligibility status
+ * @retval 0 Packet is not drop eligible
+ * @retval 1 Packet is drop
+ */
+odp_bool_t odp_packet_drop_eligible(odp_packet_t pkt);
+
+/**
+ * Set drop eligible status
+ *
+ * @param pkt Packet handle
+ * @param status Drop eligibility status
+ */
+void odp_packet_drop_eligible_set(odp_packet_t pkt, odp_bool_t status);
+
+/**
+ * Get shaper length adjustment
+ *
+ * @param pkt Packet handle
+ * @return Shaper adjustment (-128..127)
+ */
+int8_t odp_packet_shaper_len_adjust(odp_packet_t pkt);
+
+/**
+ * Set shaper length adjustment
+ *
+ * @param pkt Packet handle
+ * @param adj Signed adjustment value
+ */
+void odp_packet_shaper_len_adjust_set(odp_packet_t pkt, int8_t adj);
+
+/**
  * @}
  */
 
diff --git a/include/odp/api/traffic_mngr.h b/include/odp/api/traffic_mngr.h
new file mode 100644
index 000..694cb8e
--- /dev/null
+++ b/include/odp/api/traffic_mngr.h
@@ -0,0 +1,1617 @@
+/** Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_TRAFFIC_MNGR_H_
+#define ODP_TRAFFIC_MNGR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+#include 
+
+/**
+ * @file
+ *
+ */
+
+/** @defgroup odp_traffic_mngr ODP TRAFFIC MNGR
+ * @{
+ *
+ * An API for configuring and using Traffic Management systems
+ *
+ * This file forms a simple interface for creating, configuring and using
+ * Traffic Management (TM) subsystems.  By TM subsystem it is meant a general
+ * packet scheduling system that accepts packets from input queues and applies
+ * strict priority scheduling, weighted fair queueing scheduling and/or
+ * bandwidth controls to decide which input packet should be chosen as the
+ * next output packet and when this output packet can be sent onwards.
+ *
+ * A given platform supporting this TM API could support one or more pure
+ * hardware based packet scheduling systems, one or more pure software
+ * based systems or one or more hybrid systems - where because of
+ * hardware constraints some of the packet scheduling is done in hardware
+ * and some is done in software.  In addition, there may also be additional
+ * API's beyond those described here for (a) controlling advanced capabilities
+ * supported by specific hardware, software or hybrid subsystems or (b)
+ * dealing with constraints and limitations of specific implementations.
+ * The intention here is to be the simplest API that covers the vast majority
+ * of packet scheduling requirements.
+ *
+ * Often a TM subsystem's output(s) will be directly connected
+ * to a device's physical (or virtual) output interfaces/links, in which case
+ * sometimes such a system will be called an Egress Packet Scheduler or an
+ * Output Link Shaper, etc..  While the TM subsystems configured by this API
+ * can be used in such a way, this API 

Re: [lng-odp] [PATCH] example:ipsec: Using environment varibale for pktio mode.

2015-10-19 Thread Agarwal Nikhil Agarwal
Ping.

-Original Message-
From: nikhil.agar...@freescale.com [mailto:nikhil.agar...@freescale.com] 
Sent: Wednesday, October 07, 2015 3:54 PM
To: lng-odp@lists.linaro.org
Cc: Agarwal Nikhil-B38457 
Subject: [PATCH] example:ipsec: Using environment varibale for pktio mode.

From: Nikhil Agarwal 

Pktio input mode of operation should be derived from environment variable input 
instead of compile time flag.

Signed-off-by: Nikhil Agarwal 
---
 example/ipsec/odp_ipsec.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 
96effe2..bc1d00e 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -515,11 +515,10 @@ void initialize_intf(char *intf)
 
memset(_param, 0, sizeof(pktio_param));
 
-#ifdef IPSEC_POLL_QUEUES
-   pktio_param.in_mode = ODP_PKTIN_MODE_POLL;
-#else
-   pktio_param.in_mode = ODP_PKTIN_MODE_SCHED;
-#endif
+   if (getenv("ODP_IPSEC_USE_POLL_QUEUES"))
+   pktio_param.in_mode = ODP_PKTIN_MODE_POLL;
+   else
+   pktio_param.in_mode = ODP_PKTIN_MODE_SCHED;
 
/*
 * Open a packet IO instance for thread and get default output queue
--
2.5.0

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


Re: [lng-odp] [PATCHv10 8/8] linux-generic: internal ipc_pktio test

2015-10-19 Thread Christophe Milard
Shouldn't all this go in example rather than test?

Christophe

On 19 October 2015 at 18:08, Maxim Uvarov  wrote:

> 2 example ipc pktio applications create ipc pktio to each other and do
> packet transfer, validation magic numbers and packets sequence counters
> inside it.
>
> Signed-off-by: Maxim Uvarov 
> ---
>  platform/linux-generic/Makefile.am |   1 +
>  platform/linux-generic/m4/configure.m4 |   3 +-
>  platform/linux-generic/test/Makefile.am|   3 +-
>  platform/linux-generic/test/pktio_ipc/.gitignore   |   1 +
>  platform/linux-generic/test/pktio_ipc/Makefile.am  |  15 ++
>  platform/linux-generic/test/pktio_ipc/ipc_common.c | 150 
>  platform/linux-generic/test/pktio_ipc/ipc_common.h |  71 ++
>  platform/linux-generic/test/pktio_ipc/pktio_ipc1.c | 268
> +
>  platform/linux-generic/test/pktio_ipc/pktio_ipc2.c | 142 +++
>  .../linux-generic/test/pktio_ipc/pktio_ipc_run |  55 +
>  10 files changed, 707 insertions(+), 2 deletions(-)
>  create mode 100644 platform/linux-generic/test/pktio_ipc/.gitignore
>  create mode 100644 platform/linux-generic/test/pktio_ipc/Makefile.am
>  create mode 100644 platform/linux-generic/test/pktio_ipc/ipc_common.c
>  create mode 100644 platform/linux-generic/test/pktio_ipc/ipc_common.h
>  create mode 100644 platform/linux-generic/test/pktio_ipc/pktio_ipc1.c
>  create mode 100644 platform/linux-generic/test/pktio_ipc/pktio_ipc2.c
>  create mode 100755 platform/linux-generic/test/pktio_ipc/pktio_ipc_run
>
> diff --git a/platform/linux-generic/Makefile.am
> b/platform/linux-generic/Makefile.am
> index 71353dd..6fe2f1a 100644
> --- a/platform/linux-generic/Makefile.am
> +++ b/platform/linux-generic/Makefile.am
> @@ -5,6 +5,7 @@ include $(top_srcdir)/platform/Makefile.inc
>
>  AM_CFLAGS +=  -I$(srcdir)/include
>  AM_CFLAGS +=  -I$(top_srcdir)/include
> +AM_CFLAGS +=  -I$(top_srcdir)/helper
>  AM_CFLAGS +=  -I$(top_srcdir)/helper/include
>
>  include_HEADERS = \
> diff --git a/platform/linux-generic/m4/configure.m4
> b/platform/linux-generic/m4/configure.m4
> index 9658274..3a2d743 100644
> --- a/platform/linux-generic/m4/configure.m4
> +++ b/platform/linux-generic/m4/configure.m4
> @@ -21,4 +21,5 @@ m4_include([platform/linux-generic/m4/odp_openssl.m4])
>
>  AC_CONFIG_FILES([platform/linux-generic/Makefile
>  platform/linux-generic/test/Makefile
> -platform/linux-generic/test/pktio/Makefile])
> +platform/linux-generic/test/pktio/Makefile
> +platform/linux-generic/test/pktio_ipc/Makefile])
> diff --git a/platform/linux-generic/test/Makefile.am
> b/platform/linux-generic/test/Makefile.am
> index 7d1ce1b..db98d28 100644
> --- a/platform/linux-generic/test/Makefile.am
> +++ b/platform/linux-generic/test/Makefile.am
> @@ -1,10 +1,11 @@
>  include $(top_srcdir)/test/Makefile.inc
>  TESTS_ENVIRONMENT += TEST_DIR=${top_builddir}/test/validation
>
> -ODP_MODULES = pktio
> +ODP_MODULES = pktio pktio_ipc
>
>  if test_vald
>  TESTS = pktio/pktio_run \
> +   pktio_ipc/pktio_ipc_run \
> ${top_builddir}/test/validation/buffer/buffer_main$(EXEEXT) \
>
> ${top_builddir}/test/validation/classification/classification_main$(EXEEXT)
> \
> ${top_builddir}/test/validation/cpumask/cpumask_main$(EXEEXT) \
> diff --git a/platform/linux-generic/test/pktio_ipc/.gitignore
> b/platform/linux-generic/test/pktio_ipc/.gitignore
> new file mode 100644
> index 000..d2a7ce2
> --- /dev/null
> +++ b/platform/linux-generic/test/pktio_ipc/.gitignore
> @@ -0,0 +1 @@
> +pktio_ipc
> diff --git a/platform/linux-generic/test/pktio_ipc/Makefile.am
> b/platform/linux-generic/test/pktio_ipc/Makefile.am
> new file mode 100644
> index 000..adf6294
> --- /dev/null
> +++ b/platform/linux-generic/test/pktio_ipc/Makefile.am
> @@ -0,0 +1,15 @@
> +include $(top_srcdir)/test/Makefile.inc
> +TESTS_ENVIRONMENT += TEST_DIR=${top_builddir}/test/validation
> +
> +bin_PROGRAMS = pktio_ipc1\
> +   pktio_ipc2
> +
> +pktio_ipc1_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
> +pktio_ipc1_LDFLAGS = $(AM_LDFLAGS) -static
> +pktio_ipc2_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
> +pktio_ipc2_LDFLAGS = $(AM_LDFLAGS) -static
> +
> +noinst_HEADERS = $(top_srcdir)/test/test_debug.h
> +
> +dist_pktio_ipc1_SOURCES = pktio_ipc1.c ipc_common.c
> +dist_pktio_ipc2_SOURCES = pktio_ipc2.c ipc_common.c
> diff --git a/platform/linux-generic/test/pktio_ipc/ipc_common.c
> b/platform/linux-generic/test/pktio_ipc/ipc_common.c
> new file mode 100644
> index 000..7a84b07
> --- /dev/null
> +++ b/platform/linux-generic/test/pktio_ipc/ipc_common.c
> @@ -0,0 +1,150 @@
> +/* Copyright (c) 2015, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier: BSD-3-Clause
> + */
> +
> +#include "ipc_common.h"
> +
> +/** Application argument */
> +char *pktio_name;
> +
> +/** Run time in seconds */
> 

Re: [lng-odp] [RFC API-NEXT PATCH 0/6] Multiple queue packet IO API

2015-10-19 Thread Alexandru Badicioiu
On 19 October 2015 at 19:16, Nikita Kalyazin  wrote:

> Hi Stuart,
>
>
> Thanks for your feedback.
>
> > One thing that is missing here is a method for the application to
> > configure how packets are distributed, i.e. which fields in the packet
> > are used when calculating the flow hash (not necessarily the hash
> > algorithm itself, that can be implementation defined).
> >
> > For example with the netmap implementation here, if you have a
> > compatible interface, I assume the user can control distribution to RX
> > queues using something like;
> >
> >   ethtool --config-ntuple rx-flow-hash esp4
> >
> > But it would be better if this were configurable via the ODP API. Petri
> > had a suggestion a while back related to this to add a structure to the
> > odp_pktio_params_t;
> >
> > enum odp_pktio_input_hash {
> >   /** No specific fields defined */
> >   ODP_PKTIN_HASH_NONE = 0,
> >   /** IPv4/v6 addresses */
> >   ODP_PKTIN_HASH_IP,
> >   /** UDP ports and IPv4/v6 addresses */
> >   ODP_PKTIN_HASH_UDP_IP,
> >   /** TCP ports and IPv4/v6 addresses */
> >   ODP_PKTIN_HASH_TCP_IP
> > };
> Thanks, I plan to think about it.
> Btw, NICs provide wide variety of settings regarding distribution of
> packets across the queues.  Is it supposed to extend the proposed
> structure to support more flexible configuration?
>
> > How about:
> >
> > int odp_pktio_inq_create(odp_pktio_t pktio, const char *name,
> >  const odp_queue_param_t *param,
> >  odp_queue_t queues[], int num);
> >
> > Which would return the number of queues created, and ensure that all
> > queues had the same parameters. Or, maybe it's time to start using
> > odp_queue_group_t, which we have always intended to be a group of queues
> > that all have the same properties.
> Good point.  I'll consider the cleaner approach.
>
> > I'm not keen on the odp_pktio_recv/send_queue() APIs as the queues
> > referred to there are not ODP queues so it makes things a bit less clear,
> > and in general we should be moving away from using the direct _send/_recv
> > APIs. If we're explicitly using queues then we should use the queue
> and/or
> > scheduler APIs.
> Right, these API names look a bit confusing, because same word is used to
> refer to both hardware NIC queues and ODP (software) queues.
>
[Alex] ODP queues are neither software nor hardware by definition, each
implementation is free to implement them as they see fit. Also PacketI/O
abstraction is not an abstraction for a NIC device. The ODP way to use
multiple queues for ingress is through the classifier. There was a former
proposal of enabling RSS at pktio level but it was not accepted. I also
noticed that this patch tries to introduce multiple default queues which is
kind of confusing - default traffic is all traffic which does not satisfy
classifier criteria. For output, multiple queues are used by the means of
TM api.

> However, I think it would be useful to preserve explicit send/recv APIs,
> since in many cases they might appear more efficient (odp-ovs is an example
> of such applications), and rename those to make them more obvious.
>
> > Are you able to join the meeting on Tuesday to discuss?
> >
> > http://www.opendataplane.org/meetings/
> Thanks, I'm going to join the meeting.
>
> --
>
> Best regards,
>
> Nikita Kalyazin,
> n.kalya...@samsung.com
>
> Software Engineer
> Virtualization Group
> Samsung R Institute Russia
> Tel: +7 (495) 797-25-00 #3816
> Tel: +7 (495) 797-25-03
> Office #1501, 12-1, Dvintsev str.,
> Moscow, 127018, Russia
>
> On Fri, Oct 16, 2015 at 07:15:43PM +0100, Stuart Haslam wrote:
> > On Wed, Oct 14, 2015 at 02:32:37PM +0300, Nikita Kalyazin wrote:
> > > This series is a proposal of multiqueue API for ODP.
> > > Modern network adapters (both physical and virtual) support multiple
> > > hardware queues.  Assigning separate CPU core for processing of each
> > > queue allows to scale throughput (in best case - linearly).
> > >
> >
> > Thanks for the contribution, we do need something like this, in
> > particular hash based distribution has been on the todo list for a
> > little while. I've not reviewed the implementation in detail but have
> > focused on the API changes specifically and have a few initial thoughts
> > below.
> >
> > One thing that is missing here is a method for the application to
> > configure how packets are distributed, i.e. which fields in the packet
> > are used when calculating the flow hash (not necessarily the hash
> > algorithm itself, that can be implementation defined).
> >
> > For example with the netmap implementation here, if you have a
> > compatible interface, I assume the user can control distribution to RX
> > queues using something like;
> >
> >   ethtool --config-ntuple rx-flow-hash esp4
> >
> > But it would be better if this were configurable via the ODP API. Petri
> > had a suggestion a while back related to this to add a structure to the

Re: [lng-odp] [PATCH v3 6/6] test: l2fwd: word copy ethernet addresses

2015-10-19 Thread Ola Liljedahl
On 16 October 2015 at 15:01, Matias Elo  wrote:

> Optimize ethernet address filling by using word copy.
>
> Signed-off-by: Matias Elo 
> ---
>  test/performance/odp_l2fwd.c | 43
> +++
>  1 file changed, 31 insertions(+), 12 deletions(-)
>
> diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
> index 5332b9a..e8d05a5 100644
> --- a/test/performance/odp_l2fwd.c
> +++ b/test/performance/odp_l2fwd.c
> @@ -92,6 +92,14 @@ typedef struct {
>  } thread_args_t;
>
>  /**
> + * Optimized type for storing ethernet addresses
> + */
> +typedef union {
> +   uint8_t u8[6];
> +   uint16_t u16[3];
> +} eth_addr_t;
> +
> +/**
>   * Grouping of all global data
>   */
>  typedef struct {
> @@ -102,9 +110,9 @@ typedef struct {
> /** Table of pktio handles */
> odp_pktio_t pktios[ODP_CONFIG_PKTIO_ENTRIES];
> /** Table of port ethernet addresses */
> -   odph_ethaddr_t port_eth_addr[ODP_CONFIG_PKTIO_ENTRIES];
> +   eth_addr_t port_eth_addr[ODP_CONFIG_PKTIO_ENTRIES];
> /** Table of dst ethernet addresses */
> -   odph_ethaddr_t dst_eth_addr[ODP_CONFIG_PKTIO_ENTRIES];
> +   eth_addr_t dst_eth_addr[ODP_CONFIG_PKTIO_ENTRIES];
> /** Table of port default output queues */
> odp_queue_t outq_def[ODP_CONFIG_PKTIO_ENTRIES];
> /** Table of dst ports */
> @@ -435,7 +443,7 @@ int main(int argc, char *argv[])
> odp_shm_t shm;
> odp_cpumask_t cpumask;
> char cpumaskstr[ODP_CPUMASK_STR_SIZE];
> -   odph_ethaddr_t new_addr;
> +   eth_addr_t new_addr;
> odp_pktio_t pktio;
> odp_pool_param_t params;
> int ret;
> @@ -510,7 +518,7 @@ int main(int argc, char *argv[])
> gbl_args->pktios[i] = pktio;
>
> /* Save interface ethernet address */
> -   if (odp_pktio_mac_addr(pktio,
> gbl_args->port_eth_addr[i].addr,
> +   if (odp_pktio_mac_addr(pktio,
> gbl_args->port_eth_addr[i].u8,
>ODPH_ETHADDR_LEN) !=
> ODPH_ETHADDR_LEN) {
> LOG_ERR("Error: interface ethernet address
> unknown\n");
> exit(EXIT_FAILURE);
> @@ -523,9 +531,9 @@ int main(int argc, char *argv[])
> /* Save destination eth address */
> if (gbl_args->appl.dst_change) {
> /* 02:00:00:00:00:XX */
> -   memset(_addr, 0, sizeof(odph_ethaddr_t));
> -   new_addr.addr[0] = 0x02;
> -   new_addr.addr[5] = i;
> +   memset(_addr, 0, sizeof(eth_addr_t));
> +   new_addr.u8[0] = 0x02;
> +   new_addr.u8[5] = i;
> gbl_args->dst_eth_addr[i] = new_addr;
> }
>
> @@ -628,6 +636,8 @@ static void fill_eth_addrs(odp_packet_t pkt_tbl[],
> unsigned num, int dst_port)
> odp_packet_t pkt;
> odph_ethhdr_t *eth;
> unsigned i;
> +   uint16_t *dw;
> +   uint16_t *sw;
>
> if (!gbl_args->appl.dst_change && !gbl_args->appl.src_change)
> return;
> @@ -637,11 +647,20 @@ static void fill_eth_addrs(odp_packet_t pkt_tbl[],
> unsigned num, int dst_port)
> if (odp_packet_has_eth(pkt)) {
> eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt,
> NULL);
>
> -   if (gbl_args->appl.src_change)
> -   eth->src =
> gbl_args->port_eth_addr[dst_port];
> -
> -   if (gbl_args->appl.dst_change)
> -   eth->dst =
> gbl_args->dst_eth_addr[dst_port];
> +   if (gbl_args->appl.src_change) {
> +   sw = gbl_args->port_eth_addr[dst_port].u16;
> +   dw = (uint16_t *)eth->src.addr;
> +   dw[0] = sw[0];
> +   dw[1] = sw[1];
> +   dw[2] = sw[2];
> +   }
> +   if (gbl_args->appl.dst_change) {
> +   sw = gbl_args->dst_eth_addr[dst_port].u16;
> +   dw = (uint16_t *)eth->dst.addr;
> +   dw[0] = sw[0];
> +   dw[1] = sw[1];
> +   dw[2] = sw[2];
>
If you want to be really nit-picky about performance, you load all fields
before storing them because compilers have problems optimising array
accesses (e.g. different arrays/pointers of the same type may refer to the
same object so array access must be performed in the original order). This
allows the compiler to minimise load-to-use latency. I could see the
difference on e.g. PowerPC e500. A more aggressive CPU (with more out of
order loads) might not see the same benefits. Using the restrict keyword
might give the 

Re: [lng-odp] [PATCHv10 4/8] helper: flag to not link ring to linked list

2015-10-19 Thread Ola Liljedahl
On 19 October 2015 at 18:07, Maxim Uvarov  wrote:

> Add flag ODPH_RING_NO_LIST to ring to not link it to linked list.
>
And the purpose of this is?
Either we want to be able to look up resources by name or not. Is there any
specific reason why this is a per-object (per-ring) configuration?


>
> Signed-off-by: Maxim Uvarov 
> ---
>  helper/include/odp/helper/ring.h | 7 ---
>  helper/ring.c| 3 ++-
>  2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/helper/include/odp/helper/ring.h
> b/helper/include/odp/helper/ring.h
> index 5e640a7..c3c2f6a 100644
> --- a/helper/include/odp/helper/ring.h
> +++ b/helper/include/odp/helper/ring.h
> @@ -156,10 +156,11 @@ typedef struct odph_ring {
>  } odph_ring_t;
>
>
> -#define ODPH_RING_F_SP_ENQ 0x0001 /* The default enqueue is
> "single-producer".*/
> -#define ODPH_RING_F_SC_DEQ 0x0002 /* The default dequeue is
> "single-consumer".*/
> -#define ODPH_RING_SHM_PROC 0x0004 /* If set - ring is visible from
> different
> +#define ODPH_RING_F_SP_ENQ (1 << 0) /* The default enqueue is
> "single-producer".*/
> +#define ODPH_RING_F_SC_DEQ (1 << 1) /* The default dequeue is
> "single-consumer".*/
> +#define ODPH_RING_SHM_PROC (1 << 2) /* If set - ring is visible from
> different
> processes. Default is thread visible.
>*/
> +#define ODPH_RING_NO_LIST  (1 << 3) /* Do not link ring to linked list. */
>  #define ODPH_RING_QUOT_EXCEED (1 << 31)  /* Quota exceed for burst ops */
>  #define ODPH_RING_SZ_MASK  (unsigned)(0x0fff) /* Ring size mask */
>
> diff --git a/helper/ring.c b/helper/ring.c
> index 6bb2bda..fe01c5d 100644
> --- a/helper/ring.c
> +++ b/helper/ring.c
> @@ -199,7 +199,8 @@ odph_ring_create(const char *name, unsigned count,
> unsigned flags)
> r->prod.tail = 0;
> r->cons.tail = 0;
>
> -   TAILQ_INSERT_TAIL(_ring_list, r, next);
> +   if (!(flags & ODPH_RING_NO_LIST))
> +   TAILQ_INSERT_TAIL(_ring_list, r, next);
> } else {
> ODPH_ERR("Cannot reserve memory\n");
> }
> --
> 1.9.1
>
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [RFC API-NEXT PATCH 0/6] Multiple queue packet IO API

2015-10-19 Thread Nikita Kalyazin
Hi Stuart,


Thanks for your feedback.

> One thing that is missing here is a method for the application to
> configure how packets are distributed, i.e. which fields in the packet
> are used when calculating the flow hash (not necessarily the hash
> algorithm itself, that can be implementation defined).
>
> For example with the netmap implementation here, if you have a
> compatible interface, I assume the user can control distribution to RX
> queues using something like;
> 
>   ethtool --config-ntuple rx-flow-hash esp4
> 
> But it would be better if this were configurable via the ODP API. Petri
> had a suggestion a while back related to this to add a structure to the
> odp_pktio_params_t;
> 
> enum odp_pktio_input_hash {
>   /** No specific fields defined */
>   ODP_PKTIN_HASH_NONE = 0,
>   /** IPv4/v6 addresses */
>   ODP_PKTIN_HASH_IP,
>   /** UDP ports and IPv4/v6 addresses */
>   ODP_PKTIN_HASH_UDP_IP,
>   /** TCP ports and IPv4/v6 addresses */
>   ODP_PKTIN_HASH_TCP_IP
> };
Thanks, I plan to think about it.
Btw, NICs provide wide variety of settings regarding distribution of
packets across the queues.  Is it supposed to extend the proposed
structure to support more flexible configuration?

> How about:
> 
> int odp_pktio_inq_create(odp_pktio_t pktio, const char *name,
>  const odp_queue_param_t *param,
>  odp_queue_t queues[], int num);
>
> Which would return the number of queues created, and ensure that all
> queues had the same parameters. Or, maybe it's time to start using
> odp_queue_group_t, which we have always intended to be a group of queues
> that all have the same properties.
Good point.  I'll consider the cleaner approach.

> I'm not keen on the odp_pktio_recv/send_queue() APIs as the queues
> referred to there are not ODP queues so it makes things a bit less clear,
> and in general we should be moving away from using the direct _send/_recv
> APIs. If we're explicitly using queues then we should use the queue and/or
> scheduler APIs.
Right, these API names look a bit confusing, because same word is used to
refer to both hardware NIC queues and ODP (software) queues.
However, I think it would be useful to preserve explicit send/recv APIs,
since in many cases they might appear more efficient (odp-ovs is an example
of such applications), and rename those to make them more obvious.

> Are you able to join the meeting on Tuesday to discuss?
> 
> http://www.opendataplane.org/meetings/
Thanks, I'm going to join the meeting.

-- 

Best regards,

Nikita Kalyazin,
n.kalya...@samsung.com

Software Engineer
Virtualization Group
Samsung R Institute Russia
Tel: +7 (495) 797-25-00 #3816
Tel: +7 (495) 797-25-03
Office #1501, 12-1, Dvintsev str.,
Moscow, 127018, Russia

On Fri, Oct 16, 2015 at 07:15:43PM +0100, Stuart Haslam wrote:
> On Wed, Oct 14, 2015 at 02:32:37PM +0300, Nikita Kalyazin wrote:
> > This series is a proposal of multiqueue API for ODP.
> > Modern network adapters (both physical and virtual) support multiple
> > hardware queues.  Assigning separate CPU core for processing of each
> > queue allows to scale throughput (in best case - linearly).
> > 
> 
> Thanks for the contribution, we do need something like this, in
> particular hash based distribution has been on the todo list for a
> little while. I've not reviewed the implementation in detail but have
> focused on the API changes specifically and have a few initial thoughts
> below.
> 
> One thing that is missing here is a method for the application to
> configure how packets are distributed, i.e. which fields in the packet
> are used when calculating the flow hash (not necessarily the hash
> algorithm itself, that can be implementation defined).
> 
> For example with the netmap implementation here, if you have a
> compatible interface, I assume the user can control distribution to RX
> queues using something like;
> 
>   ethtool --config-ntuple rx-flow-hash esp4
> 
> But it would be better if this were configurable via the ODP API. Petri
> had a suggestion a while back related to this to add a structure to the
> odp_pktio_params_t;
> 
> enum odp_pktio_input_hash {
>   /** No specific fields defined */
>   ODP_PKTIN_HASH_NONE = 0,
>   /** IPv4/v6 addresses */
>   ODP_PKTIN_HASH_IP,
>   /** UDP ports and IPv4/v6 addresses */
>   ODP_PKTIN_HASH_UDP_IP,
>   /** TCP ports and IPv4/v6 addresses */
>   ODP_PKTIN_HASH_TCP_IP
> };
> 
> As for RX queue creation, rather than proposed sequence that looks like
> this:
> 
> odp_pktio_max_num_queues()
> odp_pktio_configure()
> foreach inq
> odp_queue_create()
> 
> How about:
> 
> int odp_pktio_inq_create(odp_pktio_t pktio, const char *name,
>  const odp_queue_param_t *param,
>  odp_queue_t queues[], int num);
> 
> Which would return the number of queues created, and ensure that all
> queues had the same parameters. Or, maybe it's time to 

Re: [lng-odp] [API-NEXT PATCHv4 1/2] api: define pktio statistics api

2015-10-19 Thread Ola Liljedahl
On 19 October 2015 at 17:58, Maxim Uvarov  wrote:

> On 10/19/2015 18:49, Ola Liljedahl wrote:
>
>> On 16 October 2015 at 15:25, Maxim Uvarov > > wrote:
>>
>> Signed-off-by: Maxim Uvarov > >
>> ---
>>  include/odp/api/packet_io_stats.h  | 166
>> +
>>  platform/linux-generic/include/odp/packet_io.h |   1 +
>>  2 files changed, 167 insertions(+)
>>  create mode 100644 include/odp/api/packet_io_stats.h
>>
>> diff --git a/include/odp/api/packet_io_stats.h
>> b/include/odp/api/packet_io_stats.h
>> new file mode 100644
>> index 000..94af18c
>> --- /dev/null
>> +++ b/include/odp/api/packet_io_stats.h
>> @@ -0,0 +1,166 @@
>> +/* Copyright (c) 2015, Linaro Limited
>> + * All rights reserved.
>> + *
>> + * SPDX-License-Identifier: BSD-3-Clause
>> + */
>> +
>> +/**
>> + * @file
>> + *
>> + * ODP Packet IO
>> + */
>> +
>> +#ifndef ODP_API_PACKET_IO_STATS_H_
>> +#define ODP_API_PACKET_IO_STATS_H_
>> +
>> +#ifdef __cplusplus
>> +extern "C" {
>> +#endif
>> +
>> +/** @defgroup odp_packet_io ODP PACKET IO
>> + *  @{
>> + */
>> +
>> +/**
>> + * Packet IO statistics
>> + *
>> + * Packet IO statictics counters follow RFCs for Management
>> Information Base
>> + * (MIB)for use with network management protocols in the Internet
>> community:
>> + * https://tools.ietf.org/html/rfc3635
>> + * https://tools.ietf.org/html/rfc2863
>> + * https://tools.ietf.org/html/rfc2819
>> + */
>> +typedef struct odp_pktio_stats_t {
>> +   /**
>> +* The number of octets in valid MAC frames received on
>> this interface,
>> +* including the MAC header and FCS. See ifHCInOctets counter
>> +* description in RFC 3635 for details.
>> +*/
>> +   uint64_t in_octets;
>> +   /**
>> +* The number of packets, delivered by this sub-layer to a
>> higher
>> +* (sub-)layer, which were not addressed to a multicast or
>> broadcast
>> +* address at this sub-layer. See InUcastPkts in RFC 2863.
>> +*/
>> +   uint64_t in_ucast_pkts;
>> +   /**
>> +* The number of inbound packets which were chosen to be
>> discarded
>> +* even though no errors had been detected to preven their
>> being
>> +* deliverable to a higher-layer protocol.  One possible
>> reason for
>> +* discarding such a packet could be to free up buffer space.
>> +* See InDiscards in RFC 2863.
>> +*/
>> +   uint64_t in_discards;
>> +   /**
>> +* The sum for this interface of AlignmentErrors,
>> FCSErrors, FrameTooLongs,
>> +* InternalMacReceiveErrors. See InErrors in RFC 3635.
>> +*/
>> +   uint64_t in_errors;
>> +   /**
>> +* For packet-oriented interfaces, the number of packets
>> received via
>> +* the interface which were discarded because of an unknown or
>> +* unsupported protocol.  For character-oriented or
>> fixed-length
>> +* interfaces that support protocol multiplexing the number of
>> +* transmission units received via the interface which
>> were discarded
>> +* because of an unknown or unsupported protocol. For any
>> interface
>> +* that does not support protocol multiplexing, this
>> counter will always
>> +* be 0. See InUnknownProtos in RFC 2863.
>> +*/
>> +   uint64_t in_unknown_protos;
>> +   /**
>> +* The number of octets transmitted in valid MAC frames on
>> this
>> +* interface, including the MAC header and FCS. This does
>> include
>> +* the number of octets in valid MAC Control frames
>> transmitted on
>> +* this interface. See OutOctets in RFC 3635.
>> +*/
>> +   uint64_t out_octets;
>> +   /**
>> +* The total number of packets that higher-level protocols
>> requested
>> +* be transmitted, and which were not addressed to a
>> multicast or
>> +* broadcast address at this sub-layer, including those
>> that were
>> +* discarded or not sent. does not include MAC Control frames.
>> +* See OutUcastPkts in RFC 2863, 3635.
>> +*/
>> +   uint64_t out_ucast_pkts;
>> +   /**
>> +* The number of outbound packets which were chosen to be
>> discarded
>> +* even though no errors had been detected to prevent
>> their being
>> +* transmitted.  One 

[lng-odp] [PATCHv10 5/8] helpers: remove odp_ prefix for tests source files

2015-10-19 Thread Maxim Uvarov
Prefixed were removed for validation test suite and to
be consistent we need to do the same for helpers.

Signed-off-by: Maxim Uvarov 
---
 helper/test/.gitignore   |  9 +
 helper/test/Makefile.am  | 16 
 helper/test/{odp_chksum.c => chksum.c}   |  3 +--
 helper/test/{odp_process.c => process.c} |  3 ++-
 helper/test/{odp_thread.c => thread.c}   |  3 ++-
 5 files changed, 18 insertions(+), 16 deletions(-)
 rename helper/test/{odp_chksum.c => chksum.c} (98%)
 rename helper/test/{odp_process.c => process.c} (96%)
 rename helper/test/{odp_thread.c => thread.c} (96%)

diff --git a/helper/test/.gitignore b/helper/test/.gitignore
index 213bc5e..0c7e81f 100644
--- a/helper/test/.gitignore
+++ b/helper/test/.gitignore
@@ -1,6 +1,7 @@
 *.trs
 *.log
-odp_chksum
-odp_process
-odp_thread
-odph_pause
+chksum
+process
+thread
+pause
+ring
diff --git a/helper/test/Makefile.am b/helper/test/Makefile.am
index 7b73602..f6a3f83 100644
--- a/helper/test/Makefile.am
+++ b/helper/test/Makefile.am
@@ -5,9 +5,9 @@ AM_LDFLAGS += -static
 
 TESTS_ENVIRONMENT += TEST_DIR=${builddir}
 
-EXECUTABLES = odp_chksum$(EXEEXT) \
-  odp_thread$(EXEEXT) \
-  odp_process$(EXEEXT)
+EXECUTABLES = chksum$(EXEEXT) \
+  thread$(EXEEXT) \
+  process$(EXEEXT)
 
 COMPILE_ONLY =
 
@@ -22,8 +22,8 @@ dist_bin_SCRIPTS =
 bin_PROGRAMS = $(EXECUTABLES) $(COMPILE_ONLY)
 
 
-dist_odp_chksum_SOURCES = odp_chksum.c
-dist_odp_thread_SOURCES = odp_thread.c
-odp_thread_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la
-dist_odp_process_SOURCES = odp_process.c
-odp_process_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la
+dist_chksum_SOURCES = chksum.c
+dist_thread_SOURCES = thread.c
+thread_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la
+dist_process_SOURCES = process.c
+process_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la
diff --git a/helper/test/odp_chksum.c b/helper/test/chksum.c
similarity index 98%
rename from helper/test/odp_chksum.c
rename to helper/test/chksum.c
index 1d417a8..c987905 100644
--- a/helper/test/odp_chksum.c
+++ b/helper/test/chksum.c
@@ -64,10 +64,9 @@ static int scan_ip(const char *buf, unsigned int *paddr)
if (paddr)
*paddr = part1 << 24 | part2 << 16 | part3 << 8 | part4;
return 1;
-   } else {
-   printf("not good ip %d:%d:%d:%d/n", part1, part2, part3, part4);
}
 
+   printf("not good ip %d:%d:%d:%d/n", part1, part2, part3, part4);
return 0;
 }
 
diff --git a/helper/test/odp_process.c b/helper/test/process.c
similarity index 96%
rename from helper/test/odp_process.c
rename to helper/test/process.c
index d3a5943..280b0ff 100644
--- a/helper/test/odp_process.c
+++ b/helper/test/process.c
@@ -53,7 +53,8 @@ int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED)
cpu = odp_cpumask_first(_mask);
printf("the first CPU:  %i\n", cpu);
 
-   /* reserve cpu 0 for the control plane so remove it from the default 
mask */
+   /* reserve cpu 0 for the control plane so remove it from
+* the default mask */
odp_cpumask_clr(_mask, 0);
num_workers = odp_cpumask_count(_mask);
(void)odp_cpumask_to_str(_mask, cpumaskstr, sizeof(cpumaskstr));
diff --git a/helper/test/odp_thread.c b/helper/test/thread.c
similarity index 96%
rename from helper/test/odp_thread.c
rename to helper/test/thread.c
index 1de30ab..87b4c57 100644
--- a/helper/test/odp_thread.c
+++ b/helper/test/thread.c
@@ -54,7 +54,8 @@ int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED)
cpu = odp_cpumask_first(_mask);
printf("the first CPU:  %i\n", cpu);
 
-   /* reserve cpu 0 for the control plane so remove it from the default 
mask */
+   /* reserve cpu 0 for the control plane so remove it from
+* the default mask */
odp_cpumask_clr(_mask, 0);
num_workers = odp_cpumask_count(_mask);
(void)odp_cpumask_to_str(_mask, cpumaskstr, sizeof(cpumaskstr));
-- 
1.9.1

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


Re: [lng-odp] [API-NEXT PATCHv2] api: pktio link

2015-10-19 Thread Maxim Uvarov

On 10/19/2015 18:39, Ola Liljedahl wrote:
On 19 October 2015 at 17:33, Maxim Uvarov > wrote:


On 10/19/2015 18:20, Ola Liljedahl wrote:

On 16 October 2015 at 17:55, Maxim Uvarov

>> wrote:

On 10/16/2015 13:24, Savolainen, Petri (Nokia - FI/Espoo)
wrote:

RFC 3635 helps also here to define properties of an
Ethernet-like interface. It's not so as crucial to
follow RFC
terms and definitions here as it's with counters, but
we can
use it as a guide line. Addresses and promisc mode are
classification issues. Name and pktio status (stopped /
started) ( == ifAdminStatus) are pktio level data.


typedef struct odp_pktio_link_state_t {
uint8_t  type;// 0: Ethernet (or enum
ODP_PKTIO_ETHERNET), ...


type is not state.  I think there might be
odp_pktio_info_t which
is filled by init of each pktio.
and some call like:
 const odp_pktio_info_t * odp_pktio_info(pktio);

where
odp_pktio_info_t {

char *name;
uint8_t  type;// 0: Ethernet (or enum
ODP_PKTIO_ETHERNET)

// what also do we need, i/o address space, number of hw
queues,
nodes and etc.
}

But it looks like Bill right pointed that for now we have
separate
call for each function.
We already have mtu and name for example. So we need to
understand
if we are going
to modify existence API or add new.

Also I can understand that:
1. speed -  might be needed to set up some timeout setting.
2.  status link up/down and logical pktio started / stopped is
needed to check why odp_schedule() returns timeouts instead of
packets.

But I have no idea why application needs type, autoneg and
duplex.

I think for first try we need to stay just with:
+typedef struct odp_pktio_link_state_t {
+   uint32_t speed; /**< Speed in Mbps: 10,
100, 1000
etc */
+   odp_bool_t up;  /**< 1 - link up, 0 - link
down */
+   odp_bool_t stopped; /**< 1 - pktio stopped, 0
- started */

Again, "stopped" is a poor name. Why not "running"?


Just serious why "stopped" is poor name and "running" is good name?

Because "stopped" (or "started") relates to the action (e.g. stop or 
start) you requested in order to change the state.

We don't call the link state variable "upped" or "downed" etc.



got it, thanks.


In future we might
have several states for pktio, something like paused. More likely
it will be better to have just
state which is some state enum.

+} odp_pktio_link_state_t;

Yes better.


I want to have up and stopped in one struct to speed that data
plane calls.

Are these calls performance critical?

Most likely it will be the following check

ev = odp_schedule(wait_time);
if (ev == ODP_EVENT_INVALID) {
   odp_pktio_link_state(pktio, _state);
   if (!link_state.up || link_state.stopped) {

  
  continue;
} else {

continue;
  }
}

I.e. try to not do 2 calls and roll stack for 2 calls.

The example up doesn't look like it requires (or even benefits
from) link state and interface status to be obtained in the
absolutely shortest time, they are not called when we are
actually processing an event.


Does that reasonable?

No.

Interface (pktio) and physical link are different concepts
which I do not think should be mixed.


Ok, if there is no reason, then I will send patch only with 
up/down and speed.


Good.


Maxim.



Maxim.



  uint8_t  status;  // 1: link up, 0: down, -1
not_present (== ifOperStatus )
uint8_t  autoneg; // 1: autoneg on, 0:
off, -1:
not supported
uint8_t  duplex;  // 1: full duplex, 0:
half duplex
uint32_t speed_mbps;  // Speed in Mbps. This
leaves
room for
   // speed_bps which
would
support 

Re: [lng-odp] [PATCHv10 4/8] helper: flag to not link ring to linked list

2015-10-19 Thread Maxim Uvarov

On 10/19/2015 19:13, Ola Liljedahl wrote:
On 19 October 2015 at 18:07, Maxim Uvarov > wrote:


Add flag ODPH_RING_NO_LIST to ring to not link it to linked list.

And the purpose of this is?
Either we want to be able to look up resources by name or not. Is 
there any specific reason why this is a per-object (per-ring) 
configuration?


ring used odp_shm_reserve() with the same name. It's possible to find 
that name and free. If original core is used then I have to init odp helper
ring list pointer so that all new created odph_rings attached to it. I 
found it's ugly and prefer just to not add each link to that linked list.


Maxim.



Signed-off-by: Maxim Uvarov >
---
 helper/include/odp/helper/ring.h | 7 ---
 helper/ring.c| 3 ++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/helper/include/odp/helper/ring.h
b/helper/include/odp/helper/ring.h
index 5e640a7..c3c2f6a 100644
--- a/helper/include/odp/helper/ring.h
+++ b/helper/include/odp/helper/ring.h
@@ -156,10 +156,11 @@ typedef struct odph_ring {
 } odph_ring_t;


-#define ODPH_RING_F_SP_ENQ 0x0001 /* The default enqueue is
"single-producer".*/
-#define ODPH_RING_F_SC_DEQ 0x0002 /* The default dequeue is
"single-consumer".*/
-#define ODPH_RING_SHM_PROC 0x0004 /* If set - ring is visible
from different
+#define ODPH_RING_F_SP_ENQ (1 << 0) /* The default enqueue is
"single-producer".*/
+#define ODPH_RING_F_SC_DEQ (1 << 1) /* The default dequeue is
"single-consumer".*/
+#define ODPH_RING_SHM_PROC (1 << 2) /* If set - ring is visible
from different
processes. Default is thread
visible. */
+#define ODPH_RING_NO_LIST  (1 << 3) /* Do not link ring to linked
list. */
 #define ODPH_RING_QUOT_EXCEED (1 << 31)  /* Quota exceed for
burst ops */
 #define ODPH_RING_SZ_MASK  (unsigned)(0x0fff) /* Ring size
mask */

diff --git a/helper/ring.c b/helper/ring.c
index 6bb2bda..fe01c5d 100644
--- a/helper/ring.c
+++ b/helper/ring.c
@@ -199,7 +199,8 @@ odph_ring_create(const char *name, unsigned
count, unsigned flags)
r->prod.tail = 0;
r->cons.tail = 0;

-   TAILQ_INSERT_TAIL(_ring_list, r, next);
+   if (!(flags & ODPH_RING_NO_LIST))
+  TAILQ_INSERT_TAIL(_ring_list, r, next);
} else {
ODPH_ERR("Cannot reserve memory\n");
}
--
1.9.1

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




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