[lng-odp] shmem in process mode.

2016-04-21 Thread Christophe Milard
Hi,

This is partly an answer to Gary's mail included below. it is about shmem
allocation in process mode. I don't think I really agree with you, Gary: As
Ola, I believe it is important (for performance) that shmem areas are seen
at the same address in their virtual space on different ODP threads, even
if the latter happens to be implemented as linux processes.

I do see a solution for doing this but it implies redefining ODP threads as
we (Gary and myself)  originially wanted them to be:

"in linux, an odp thread is any thread or process *descendant of the ODP
initiation process* which has called odp_init_local()" (def 1)

This definition was rejected (mostly by Petri) who wanted to define an ODP
thread as: "in linux, an odp thread is any thread or process which has
called odp_init_local()" (def 2). This was accepted as the definition, but
I still believe we should go for def 1 instead.

Indeed, if the main ODP instantiation process performs a huge virtual space
reservation, e.g something like:

shmem_base = mmap(NULL, SHM_TOT_SZ, PROT_NONE, MAP_ANONYMOUS,
FLAG_NO_RESERVE);
madvise(shmem_base, SHM_TOT_SZ, MADV_DONTNEED)

where SHM_TOT is the grand max of the sum of all possible shmem areas, then
this area will be mapped in all processes and threads descendant from the
odp instantiation process, ie all odpthread if def 1 is accepted.
Note than the only goal of these two system calls is to reserve virtual
space, not memory. I have an open question with Barry to see if there are
better way to do so.
But my point is that, if we accept definition 1 instead of def 2, we can
pre-reserve a huge virtual address space in the instantiation process and
know for sure that this will be inherited by all odp threads (threads as
processes).

shmem_base to shmem_base + SHM_TOT_SZ can now be handled as the address
range where any odp shared memory will be mmapped: we need a algorythm to
retrieve addresses withing this range, e.g. two ODP internal functions:
void* _odp_shm_space_alloc(int size)
_odp_shm_space_free(void *ptr)
which retrieve address within this range and handle defragmentation.

Then, when a odp_shm_reserve(area1_sz) is performed, the real memory can be
allocaded and mmap with the MAP_FIXED flag to the address returned by
 _odp_shm_space_alloc(area1_sz).
Any other odp thread performng a odp_shm_lookup() and odp_shm_get_addr() on
an existing handle would then mmap it on the same existing address using
the MAP_FIXED flag.
Note that we MAP_FIXED is used, the kernel replaces any existing mapping
with the new one, which is exactely the behaviour we want here.

An odp_free would of course call _odp_shm_space_free(), returning the
address range to the "pool" and remapping it with the NO_RESERVE flag or
whatever better way to tell the kernel that this is just a virtual space
reservation.

As far as I can see, there is a huge performance gain to be able to
guarantee that a given shm area maps at the same address in any odp thread.
Accepting def 1 gives this possibility. If not, I cannot see how 2
unrelated processes could be guarantedd to have the same address range
available at any time within their respectice address space...

Christophe.


The mail received from Gary:

I had intended to try some patches on the ODP Linux-generic shmem
implementation in order to allow child processes to access shared memory as
reliably as well as pthreads do now.  Essentially the problem is that while
pthreads share a single memory space with all threads within their thread
group(except for thread-local storage, that is) - forked processes have
unique memory spaces and shared memory or memory-mapped files CANNOT BE
GUARANTEED to be mapped at the same address from one process to the next.
Hence instances of both of these memory areas must be referenced between
processes via the use of shared memory object names known to all processes
in question.  Each process then binds that shared memory object to an
address unique to its local address space - and elements within the shared
memory / file space are referenced via known offsets from the local base
address.  I do not believe there is any reasonable means for the kernel to
guarantee matching virtual addresses across processes for memory-mapped
system-scoped objects... it would necessitate dynamic remapping of the rest
of a given process's virtual address space when a shared object was mapped
in.  What a nightmare that could be!

In the case of ODP there seems to be a "master catalog" of shared memory
created by the parent ODP instance - and the addresses of shared memory
objects reserved by ODP threads belonging to that instance are stored in
this 'catalog' and then later referenced by the children.  Neither the
address of the 'master catalog' itself nor the addresses of the reserved
areas listed within the 'catalog' may be used reliably from forked child
processes.  Forked processes will have to reference all of these shared
memory objects via filenames  - so the 'master catalog' itself

Re: [lng-odp] [API-NEXT PATCHv4 00/11] add pktin timestamping support

2016-04-21 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: Thursday, April 21, 2016 9:30 AM
> To: lng-odp@lists.linaro.org
> Subject: Re: [lng-odp] [API-NEXT PATCHv4 00/11] add pktin timestamping
> support
> 
> clang should be more smart of datatypes then gcc:
> 
> pktio.c:1765:15: error: implicit conversion from enumeration type 'enum
> odp_pktin_mode_t' to different enumeration type 'txrx_mode_e'
>[-Werror,-Wenum-conversion]
> 1, ODP_PKTIN_MODE_DIRECT,
>^
> 

Thanks, I'll fix this.

-Matias

> 
> On 04/21/16 03:14, Bill Fischofer wrote:
> > This patch set adds initial support for packet input timestamping using odp
> > global time. Set adds also related validation tests.
> >
> > Implemented functions:
> > - odp_packet_ts()
> > - odp_packet_ts_set()
> > - odp_packet_has_ts()
> > - odp_packet_has_ts_clr()
> > - odp_pktin_ts_res()
> > - odp_pktin_ts_from_ns()
> > - odp_pktio_config()
> >
> > V4:
> > + Rebase
> > + Added Review-and-tested-by Bill
> >
> > V3:
> > + Rebase
> >
> > V2:
> > + Check magic number in pktio_test_pktin_ts() validation test
> >
> > Matias Elo (11):
> >linux-generic: packet: move flow_hash present flag to correct location
> >linux-generic: packet: implement timestamp support
> >linux-generic: pktio: implement odp_pktin_ts_res()
> >linux-generic: pktio: implement odp_pktin_ts_from_ns()
> >linux-generic: pktio: implement odp_pktio_config()
> >validation: pktio: add helper function for creating test packets
> >validation: pktio: add pktio config test
> >validation: pktio: add pktin timestamping test
> >linux-generic: packet: add inline helper function for setting packet
> >  timestamp
> >linux-generic: pktio: add pktin timestamp argument to
> >  _odp_packet_cls_enq()
> >linux-generic: pktio: add pktin timestamping support
> >
> >   .../linux-generic/include/odp_packet_internal.h|  13 +-
> >   .../linux-generic/include/odp_packet_io_internal.h |   8 +-
> >   platform/linux-generic/odp_packet.c|  17 +-
> >   platform/linux-generic/odp_packet_flags.c  |  18 +-
> >   platform/linux-generic/odp_packet_io.c |  61 -
> >   platform/linux-generic/pktio/dpdk.c|  58 +++--
> >   platform/linux-generic/pktio/ipc.c |   5 +-
> >   platform/linux-generic/pktio/loop.c|  30 ++-
> >   platform/linux-generic/pktio/netmap.c  |  86 +--
> >   platform/linux-generic/pktio/pcap.c|  31 ++-
> >   platform/linux-generic/pktio/pktio_common.c|  18 +-
> >   platform/linux-generic/pktio/socket.c  |  39 ++-
> >   platform/linux-generic/pktio/socket_mmap.c |  34 ++-
> >   platform/linux-generic/pktio/tap.c |  42 +++-
> >   test/validation/packet/packet.c|   8 +
> >   test/validation/pktio/pktio.c  | 280 
> > ++---
> >   test/validation/pktio/pktio.h  |   3 +
> >   17 files changed, 591 insertions(+), 160 deletions(-)
> >
> 
> ___
> 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] [API-NEXT PATCH v5 00/11] add pktin timestamping support

2016-04-21 Thread Matias Elo
This patch set adds initial support for packet input timestamping using odp
global time. Set adds also related validation tests.

Implemented functions:
- odp_packet_ts()
- odp_packet_ts_set()
- odp_packet_has_ts()
- odp_packet_has_ts_clr()
- odp_pktin_ts_res()
- odp_pktin_ts_from_ns()
- odp_pktio_config()

V5:
+ Fixed wrong enum type usage in pktio_test_pktin_ts() (Maxim)

V4:
+ Rebase
+ Added Review-and-tested-by Bill

V3:
+ Rebase

V2:
+ Check magic number in pktio_test_pktin_ts() validation test


Matias Elo (11):
  linux-generic: packet: move flow_hash present flag to correct location
  linux-generic: packet: implement timestamp support
  linux-generic: pktio: implement odp_pktin_ts_res()
  linux-generic: pktio: implement odp_pktin_ts_from_ns()
  linux-generic: pktio: implement odp_pktio_config()
  validation: pktio: add helper function for creating test packets
  validation: pktio: add pktio config test
  validation: pktio: add pktin timestamping test
  linux-generic: packet: add inline helper function for setting packet
timestamp
  linux-generic: pktio: add pktin timestamp argument to
_odp_packet_cls_enq()
  linux-generic: pktio: add pktin timestamping support

 .../linux-generic/include/odp_packet_internal.h|  13 +-
 .../linux-generic/include/odp_packet_io_internal.h |   8 +-
 platform/linux-generic/odp_packet.c|  17 +-
 platform/linux-generic/odp_packet_flags.c  |  18 +-
 platform/linux-generic/odp_packet_io.c |  61 -
 platform/linux-generic/pktio/dpdk.c|  58 +++--
 platform/linux-generic/pktio/ipc.c |   5 +-
 platform/linux-generic/pktio/loop.c|  30 ++-
 platform/linux-generic/pktio/netmap.c  |  86 +--
 platform/linux-generic/pktio/pcap.c|  31 ++-
 platform/linux-generic/pktio/pktio_common.c|  18 +-
 platform/linux-generic/pktio/socket.c  |  39 ++-
 platform/linux-generic/pktio/socket_mmap.c |  34 ++-
 platform/linux-generic/pktio/tap.c |  42 +++-
 test/validation/packet/packet.c|   8 +
 test/validation/pktio/pktio.c  | 280 ++---
 test/validation/pktio/pktio.h  |   3 +
 17 files changed, 591 insertions(+), 160 deletions(-)

-- 
1.9.1

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


[lng-odp] [API-NEXT PATCH v5 03/11] linux-generic: pktio: implement odp_pktin_ts_res()

2016-04-21 Thread Matias Elo
Add default implementations for odp_pktin_ts_res() using
odp global time.

Signed-off-by: Matias Elo 
---
 platform/linux-generic/include/odp_packet_io_internal.h |  1 +
 platform/linux-generic/odp_packet_io.c  | 17 +
 platform/linux-generic/pktio/dpdk.c |  1 +
 platform/linux-generic/pktio/ipc.c  |  3 ++-
 platform/linux-generic/pktio/loop.c |  1 +
 platform/linux-generic/pktio/netmap.c   |  1 +
 platform/linux-generic/pktio/pcap.c |  1 +
 platform/linux-generic/pktio/socket.c   |  1 +
 platform/linux-generic/pktio/socket_mmap.c  |  1 +
 platform/linux-generic/pktio/tap.c  |  3 ++-
 10 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/platform/linux-generic/include/odp_packet_io_internal.h 
b/platform/linux-generic/include/odp_packet_io_internal.h
index aaa9387..c76ea1f 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -184,6 +184,7 @@ typedef struct pktio_if_ops {
int (*stop)(pktio_entry_t *pktio_entry);
int (*stats)(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats);
int (*stats_reset)(pktio_entry_t *pktio_entry);
+   uint64_t (*pktin_ts_res)(pktio_entry_t *pktio_entry);
int (*recv)(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[],
unsigned len);
int (*send)(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[],
diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index 472efc6..15a7de7 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -931,6 +931,23 @@ int odp_pktio_index(odp_pktio_t pktio)
return pktio_to_id(pktio);
 }
 
+uint64_t odp_pktin_ts_res(odp_pktio_t id)
+{
+   pktio_entry_t *entry;
+
+   entry = get_pktio_entry(id);
+
+   if (entry == NULL) {
+   ODP_DBG("pktio entry %d does not exist\n", id);
+   return 0;
+   }
+
+   if (entry->s.ops->pktin_ts_res)
+   return entry->s.ops->pktin_ts_res(entry);
+
+   return odp_time_global_res();
+}
+
 void odp_pktio_print(odp_pktio_t id)
 {
pktio_entry_t *entry;
diff --git a/platform/linux-generic/pktio/dpdk.c 
b/platform/linux-generic/pktio/dpdk.c
index 0e57d90..d67fb01 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -927,6 +927,7 @@ const pktio_if_ops_t dpdk_pktio_ops = {
.promisc_mode_get = dpdk_promisc_mode_get,
.mac_get = dpdk_mac_addr_get,
.capability = dpdk_capability,
+   .pktin_ts_res = NULL,
.input_queues_config = dpdk_input_queues_config,
.output_queues_config = dpdk_output_queues_config
 };
diff --git a/platform/linux-generic/pktio/ipc.c 
b/platform/linux-generic/pktio/ipc.c
index 18fa5c6..ca8eaa5 100644
--- a/platform/linux-generic/pktio/ipc.c
+++ b/platform/linux-generic/pktio/ipc.c
@@ -725,5 +725,6 @@ const pktio_if_ops_t ipc_pktio_ops = {
.mtu_get = ipc_mtu_get,
.promisc_mode_set = NULL,
.promisc_mode_get = NULL,
-   .mac_get = ipc_mac_addr_get
+   .mac_get = ipc_mac_addr_get,
+   .pktin_ts_res = NULL,
 };
diff --git a/platform/linux-generic/pktio/loop.c 
b/platform/linux-generic/pktio/loop.c
index 0ea6d0e..1a7a572 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -184,6 +184,7 @@ const pktio_if_ops_t loopback_pktio_ops = {
.mac_get = loopback_mac_addr_get,
.link_status = loopback_link_status,
.capability = NULL,
+   .pktin_ts_res = NULL,
.input_queues_config = NULL,
.output_queues_config = NULL,
.recv_queue = NULL,
diff --git a/platform/linux-generic/pktio/netmap.c 
b/platform/linux-generic/pktio/netmap.c
index 0e160c5..cf116fe 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -861,6 +861,7 @@ const pktio_if_ops_t netmap_pktio_ops = {
.promisc_mode_get = netmap_promisc_mode_get,
.mac_get = netmap_mac_addr_get,
.capability = netmap_capability,
+   .pktin_ts_res = NULL,
.input_queues_config = netmap_input_queues_config,
.output_queues_config = netmap_output_queues_config,
.recv_queue = netmap_recv_queue,
diff --git a/platform/linux-generic/pktio/pcap.c 
b/platform/linux-generic/pktio/pcap.c
index d1458bf..d33f04f 100644
--- a/platform/linux-generic/pktio/pcap.c
+++ b/platform/linux-generic/pktio/pcap.c
@@ -407,6 +407,7 @@ const pktio_if_ops_t pcap_pktio_ops = {
.promisc_mode_get = pcapif_promisc_mode_get,
.mac_get = pcapif_mac_addr_get,
.capability = NULL,
+   .pktin_ts_res = NULL,
.input_queues_config = NULL,
.output_queues_config = NULL,
.recv_queue = NULL,
diff --git a/pla

[lng-odp] [API-NEXT PATCH v5 01/11] linux-generic: packet: move flow_hash present flag to correct location

2016-04-21 Thread Matias Elo
Move flow_hash present flag to the same location as all the
other packet input and protocol flags.

Signed-off-by: Matias Elo 
---
 platform/linux-generic/include/odp_packet_internal.h | 3 ++-
 platform/linux-generic/odp_packet.c  | 2 +-
 platform/linux-generic/odp_packet_flags.c| 4 ++--
 platform/linux-generic/pktio/dpdk.c  | 6 ++
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/platform/linux-generic/include/odp_packet_internal.h 
b/platform/linux-generic/include/odp_packet_internal.h
index 47f4ff8..edff533 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -41,6 +41,8 @@ typedef union {
uint32_t parsed_l2:1; /**< L2 parsed */
uint32_t parsed_all:1;/**< Parsing complete */
 
+   uint32_t flow_hash:1; /**< Flow hash present */
+
uint32_t l2:1;/**< known L2 protocol present */
uint32_t l3:1;/**< known L3 protocol present */
uint32_t l4:1;/**< known L4 protocol present */
@@ -149,7 +151,6 @@ typedef struct {
 
odp_pktio_t input;
 
-   uint32_t has_hash:1;  /**< Flow hash present */
uint32_t flow_hash;  /**< Flow hash value */
 
odp_crypto_generic_op_result_t op_result;  /**< Result for crypto */
diff --git a/platform/linux-generic/odp_packet.c 
b/platform/linux-generic/odp_packet.c
index ef0a7d3..2c06e97 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -453,7 +453,7 @@ void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t 
flow_hash)
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
 
pkt_hdr->flow_hash = flow_hash;
-   pkt_hdr->has_hash = 1;
+   pkt_hdr->input_flags.flow_hash = 1;
 }
 
 int odp_packet_is_segmented(odp_packet_t pkt)
diff --git a/platform/linux-generic/odp_packet_flags.c 
b/platform/linux-generic/odp_packet_flags.c
index ecaa3a3..5d93f57 100644
--- a/platform/linux-generic/odp_packet_flags.c
+++ b/platform/linux-generic/odp_packet_flags.c
@@ -176,7 +176,7 @@ int odp_packet_has_flow_hash(odp_packet_t pkt)
 {
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
 
-   return pkt_hdr->has_hash;
+   return pkt_hdr->input_flags.flow_hash;
 }
 
 odp_packet_color_t odp_packet_color(odp_packet_t pkt)
@@ -335,5 +335,5 @@ void odp_packet_has_flow_hash_clr(odp_packet_t pkt)
 {
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
 
-   pkt_hdr->has_hash = 0;
+   pkt_hdr->input_flags.flow_hash = 0;
 }
diff --git a/platform/linux-generic/pktio/dpdk.c 
b/platform/linux-generic/pktio/dpdk.c
index 4aff57c..0e57d90 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -701,10 +701,8 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry,
 
pkt_hdr->input = pktio_entry->s.handle;
 
-   if (mbuf->ol_flags & PKT_RX_RSS_HASH) {
-   pkt_hdr->has_hash = 1;
-   pkt_hdr->flow_hash = mbuf->hash.rss;
-   }
+   if (mbuf->ol_flags & PKT_RX_RSS_HASH)
+   odp_packet_flow_hash_set(pkt, mbuf->hash.rss);
 
pkt_table[nb_pkts++] = pkt;
}
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCH v5 02/11] linux-generic: packet: implement timestamp support

2016-04-21 Thread Matias Elo
Implements support for packet timestamps and adds related
validation tests.

Signed-off-by: Matias Elo 
---
 platform/linux-generic/include/odp_packet_internal.h |  2 ++
 platform/linux-generic/odp_packet.c  | 15 +++
 platform/linux-generic/odp_packet_flags.c| 14 ++
 test/validation/packet/packet.c  |  8 
 4 files changed, 39 insertions(+)

diff --git a/platform/linux-generic/include/odp_packet_internal.h 
b/platform/linux-generic/include/odp_packet_internal.h
index edff533..1005535 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -42,6 +42,7 @@ typedef union {
uint32_t parsed_all:1;/**< Parsing complete */
 
uint32_t flow_hash:1; /**< Flow hash present */
+   uint32_t timestamp:1; /**< Timestamp present */
 
uint32_t l2:1;/**< known L2 protocol present */
uint32_t l3:1;/**< known L3 protocol present */
@@ -152,6 +153,7 @@ typedef struct {
odp_pktio_t input;
 
uint32_t flow_hash;  /**< Flow hash value */
+   odp_time_t timestamp;/**< Timestamp value */
 
odp_crypto_generic_op_result_t op_result;  /**< Result for crypto */
 } odp_packet_hdr_t;
diff --git a/platform/linux-generic/odp_packet.c 
b/platform/linux-generic/odp_packet.c
index 2c06e97..fe4f819 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -456,6 +456,21 @@ void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t 
flow_hash)
pkt_hdr->input_flags.flow_hash = 1;
 }
 
+odp_time_t odp_packet_ts(odp_packet_t pkt)
+{
+   odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+   return pkt_hdr->timestamp;
+}
+
+void odp_packet_ts_set(odp_packet_t pkt, odp_time_t timestamp)
+{
+   odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+   pkt_hdr->timestamp = timestamp;
+   pkt_hdr->input_flags.timestamp = 1;
+}
+
 int odp_packet_is_segmented(odp_packet_t pkt)
 {
return odp_packet_hdr(pkt)->buf_hdr.segcount > 1;
diff --git a/platform/linux-generic/odp_packet_flags.c 
b/platform/linux-generic/odp_packet_flags.c
index 5d93f57..3acdc53 100644
--- a/platform/linux-generic/odp_packet_flags.c
+++ b/platform/linux-generic/odp_packet_flags.c
@@ -179,6 +179,13 @@ int odp_packet_has_flow_hash(odp_packet_t pkt)
return pkt_hdr->input_flags.flow_hash;
 }
 
+int odp_packet_has_ts(odp_packet_t pkt)
+{
+   odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+   return pkt_hdr->input_flags.timestamp;
+}
+
 odp_packet_color_t odp_packet_color(odp_packet_t pkt)
 {
retflag(pkt, input_flags.color);
@@ -337,3 +344,10 @@ void odp_packet_has_flow_hash_clr(odp_packet_t pkt)
 
pkt_hdr->input_flags.flow_hash = 0;
 }
+
+void odp_packet_has_ts_clr(odp_packet_t pkt)
+{
+   odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+   pkt_hdr->input_flags.timestamp = 0;
+}
diff --git a/test/validation/packet/packet.c b/test/validation/packet/packet.c
index bac5f1d..63c4085 100644
--- a/test/validation/packet/packet.c
+++ b/test/validation/packet/packet.c
@@ -245,6 +245,7 @@ void packet_test_event_conversion(void)
 void packet_test_basic_metadata(void)
 {
odp_packet_t pkt = test_packet;
+   odp_time_t ts;
 
CU_ASSERT_PTR_NOT_NULL(odp_packet_head(pkt));
CU_ASSERT_PTR_NOT_NULL(odp_packet_data(pkt));
@@ -259,6 +260,13 @@ void packet_test_basic_metadata(void)
CU_ASSERT(odp_packet_flow_hash(pkt) == UINT32_MAX);
odp_packet_has_flow_hash_clr(pkt);
CU_ASSERT(!odp_packet_has_flow_hash(pkt));
+
+   ts = odp_time_global();
+   odp_packet_ts_set(pkt, ts);
+   CU_ASSERT_FATAL(odp_packet_has_ts(pkt));
+   CU_ASSERT(!odp_time_cmp(ts, odp_packet_ts(pkt)));
+   odp_packet_has_ts_clr(pkt);
+   CU_ASSERT(!odp_packet_has_ts(pkt));
 }
 
 void packet_test_length(void)
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCH v5 04/11] linux-generic: pktio: implement odp_pktin_ts_from_ns()

2016-04-21 Thread Matias Elo
Add default implementations for odp_pktin_ts_from_ns() using
odp global time.

Signed-off-by: Matias Elo 
---
 platform/linux-generic/include/odp_packet_io_internal.h |  1 +
 platform/linux-generic/odp_packet_io.c  | 17 +
 platform/linux-generic/pktio/dpdk.c |  1 +
 platform/linux-generic/pktio/ipc.c  |  1 +
 platform/linux-generic/pktio/loop.c |  1 +
 platform/linux-generic/pktio/netmap.c   |  1 +
 platform/linux-generic/pktio/pcap.c |  1 +
 platform/linux-generic/pktio/socket.c   |  1 +
 platform/linux-generic/pktio/socket_mmap.c  |  1 +
 platform/linux-generic/pktio/tap.c  |  1 +
 10 files changed, 26 insertions(+)

diff --git a/platform/linux-generic/include/odp_packet_io_internal.h 
b/platform/linux-generic/include/odp_packet_io_internal.h
index c76ea1f..ee7fc71 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -185,6 +185,7 @@ typedef struct pktio_if_ops {
int (*stats)(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats);
int (*stats_reset)(pktio_entry_t *pktio_entry);
uint64_t (*pktin_ts_res)(pktio_entry_t *pktio_entry);
+   odp_time_t (*pktin_ts_from_ns)(pktio_entry_t *pktio_entry, uint64_t ns);
int (*recv)(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[],
unsigned len);
int (*send)(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[],
diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index 15a7de7..2650124 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -948,6 +948,23 @@ uint64_t odp_pktin_ts_res(odp_pktio_t id)
return odp_time_global_res();
 }
 
+odp_time_t odp_pktin_ts_from_ns(odp_pktio_t id, uint64_t ns)
+{
+   pktio_entry_t *entry;
+
+   entry = get_pktio_entry(id);
+
+   if (entry == NULL) {
+   ODP_DBG("pktio entry %d does not exist\n", id);
+   return ODP_TIME_NULL;
+   }
+
+   if (entry->s.ops->pktin_ts_from_ns)
+   return entry->s.ops->pktin_ts_from_ns(entry, ns);
+
+   return odp_time_global_from_ns(ns);
+}
+
 void odp_pktio_print(odp_pktio_t id)
 {
pktio_entry_t *entry;
diff --git a/platform/linux-generic/pktio/dpdk.c 
b/platform/linux-generic/pktio/dpdk.c
index d67fb01..ea7b925 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -928,6 +928,7 @@ const pktio_if_ops_t dpdk_pktio_ops = {
.mac_get = dpdk_mac_addr_get,
.capability = dpdk_capability,
.pktin_ts_res = NULL,
+   .pktin_ts_from_ns = NULL,
.input_queues_config = dpdk_input_queues_config,
.output_queues_config = dpdk_output_queues_config
 };
diff --git a/platform/linux-generic/pktio/ipc.c 
b/platform/linux-generic/pktio/ipc.c
index ca8eaa5..cd7e32f 100644
--- a/platform/linux-generic/pktio/ipc.c
+++ b/platform/linux-generic/pktio/ipc.c
@@ -727,4 +727,5 @@ const pktio_if_ops_t ipc_pktio_ops = {
.promisc_mode_get = NULL,
.mac_get = ipc_mac_addr_get,
.pktin_ts_res = NULL,
+   .pktin_ts_from_ns = NULL,
 };
diff --git a/platform/linux-generic/pktio/loop.c 
b/platform/linux-generic/pktio/loop.c
index 1a7a572..396b769 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -185,6 +185,7 @@ const pktio_if_ops_t loopback_pktio_ops = {
.link_status = loopback_link_status,
.capability = NULL,
.pktin_ts_res = NULL,
+   .pktin_ts_from_ns = NULL,
.input_queues_config = NULL,
.output_queues_config = NULL,
.recv_queue = NULL,
diff --git a/platform/linux-generic/pktio/netmap.c 
b/platform/linux-generic/pktio/netmap.c
index cf116fe..c2a6b34 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -862,6 +862,7 @@ const pktio_if_ops_t netmap_pktio_ops = {
.mac_get = netmap_mac_addr_get,
.capability = netmap_capability,
.pktin_ts_res = NULL,
+   .pktin_ts_from_ns = NULL,
.input_queues_config = netmap_input_queues_config,
.output_queues_config = netmap_output_queues_config,
.recv_queue = netmap_recv_queue,
diff --git a/platform/linux-generic/pktio/pcap.c 
b/platform/linux-generic/pktio/pcap.c
index d33f04f..c8769f5 100644
--- a/platform/linux-generic/pktio/pcap.c
+++ b/platform/linux-generic/pktio/pcap.c
@@ -408,6 +408,7 @@ const pktio_if_ops_t pcap_pktio_ops = {
.mac_get = pcapif_mac_addr_get,
.capability = NULL,
.pktin_ts_res = NULL,
+   .pktin_ts_from_ns = NULL,
.input_queues_config = NULL,
.output_queues_config = NULL,
.recv_queue = NULL,
diff --git a/platform/linux-generic/pktio/socket.c 
b/platform/linux-generic

[lng-odp] [API-NEXT PATCH v5 05/11] linux-generic: pktio: implement odp_pktio_config()

2016-04-21 Thread Matias Elo
Add default implementations for odp_pktio_config().

Signed-off-by: Matias Elo 
---
 .../linux-generic/include/odp_packet_io_internal.h |  3 +++
 platform/linux-generic/odp_packet_io.c | 27 +-
 platform/linux-generic/pktio/dpdk.c|  1 +
 platform/linux-generic/pktio/ipc.c |  1 +
 platform/linux-generic/pktio/loop.c|  1 +
 platform/linux-generic/pktio/netmap.c  |  1 +
 platform/linux-generic/pktio/pcap.c|  1 +
 platform/linux-generic/pktio/socket.c  |  1 +
 platform/linux-generic/pktio/socket_mmap.c |  1 +
 platform/linux-generic/pktio/tap.c |  1 +
 10 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/platform/linux-generic/include/odp_packet_io_internal.h 
b/platform/linux-generic/include/odp_packet_io_internal.h
index ee7fc71..a807d13 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -131,6 +131,7 @@ struct pktio_entry {
STATE_STOPPED   /**< Same as OPENED, but only happens
after STARTED */
} state;
+   odp_pktio_config_t config;  /**< Device configuration */
classifier_t cls;   /**< classifier linked with this pktio*/
odp_pktio_stats_t stats;/**< statistic counters for pktio */
enum {
@@ -197,6 +198,8 @@ typedef struct pktio_if_ops {
int (*link_status)(pktio_entry_t *pktio_entry);
int (*capability)(pktio_entry_t *pktio_entry,
  odp_pktio_capability_t *capa);
+   int (*config)(pktio_entry_t *pktio_entry,
+ const odp_pktio_config_t *config);
int (*input_queues_config)(pktio_entry_t *pktio_entry,
   const odp_pktin_queue_param_t *param);
int (*output_queues_config)(pktio_entry_t *pktio_entry,
diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index 2650124..c597e83 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -384,7 +384,9 @@ int odp_pktio_close(odp_pktio_t id)
 int odp_pktio_config(odp_pktio_t id, const odp_pktio_config_t *config)
 {
pktio_entry_t *entry;
+   odp_pktio_capability_t capa;
odp_pktio_config_t default_config;
+   int res = 0;
 
entry = get_pktio_entry(id);
if (!entry)
@@ -395,21 +397,34 @@ int odp_pktio_config(odp_pktio_t id, const 
odp_pktio_config_t *config)
config = &default_config;
}
 
-   /* Currently nothing is supported. Capability returns 0 for both bit
-* fields. */
-   if (config->pktin.all_bits != 0 ||
-   config->pktout.all_bits != 0)
+   if (odp_pktio_capability(id, &capa))
return -1;
 
+   /* Check config for invalid values */
+   if (config->pktin.all_bits & ~capa.config.pktin.all_bits) {
+   ODP_ERR("Unsupported input configuration option\n");
+   return -1;
+   }
+   if (config->pktout.all_bits & ~capa.config.pktout.all_bits) {
+   ODP_ERR("Unsupported output configuration option\n");
+   return -1;
+   }
+
lock_entry(entry);
-   if (entry->s.state != STATE_STARTED) {
+   if (entry->s.state == STATE_STARTED) {
unlock_entry(entry);
+   ODP_DBG("pktio %s: not stopped\n", entry->s.name);
return -1;
}
 
+   entry->s.config = *config;
+
+   if (entry->s.ops->config)
+   res = entry->s.ops->config(entry, config);
+
unlock_entry(entry);
 
-   return 0;
+   return res;
 }
 
 int odp_pktio_start(odp_pktio_t id)
diff --git a/platform/linux-generic/pktio/dpdk.c 
b/platform/linux-generic/pktio/dpdk.c
index ea7b925..83fb1ba 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -929,6 +929,7 @@ const pktio_if_ops_t dpdk_pktio_ops = {
.capability = dpdk_capability,
.pktin_ts_res = NULL,
.pktin_ts_from_ns = NULL,
+   .config = NULL,
.input_queues_config = dpdk_input_queues_config,
.output_queues_config = dpdk_output_queues_config
 };
diff --git a/platform/linux-generic/pktio/ipc.c 
b/platform/linux-generic/pktio/ipc.c
index cd7e32f..18dbe15 100644
--- a/platform/linux-generic/pktio/ipc.c
+++ b/platform/linux-generic/pktio/ipc.c
@@ -728,4 +728,5 @@ const pktio_if_ops_t ipc_pktio_ops = {
.mac_get = ipc_mac_addr_get,
.pktin_ts_res = NULL,
.pktin_ts_from_ns = NULL,
+   .config = NULL
 };
diff --git a/platform/linux-generic/pktio/loop.c 
b/platform/linux-generic/pktio/loop.c
index 396b769..2fc1381 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -186,6 +186,7 @@ const pktio_if_ops_t loopback_pktio_ops = {
 

[lng-odp] [API-NEXT PATCH v5 07/11] validation: pktio: add pktio config test

2016-04-21 Thread Matias Elo
Add new validation test for odp_pktio_config().

Signed-off-by: Matias Elo 
---
 test/validation/pktio/pktio.c | 24 
 test/validation/pktio/pktio.h |  1 +
 2 files changed, 25 insertions(+)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index 6dc6505..f7dbf2e 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -978,6 +978,29 @@ static void pktio_test_print(void)
}
 }
 
+void pktio_test_pktio_config(void)
+{
+   odp_pktio_t pktio;
+   odp_pktio_capability_t capa;
+   odp_pktio_config_t config;
+
+   pktio = create_pktio(0, ODP_PKTIN_MODE_DIRECT, ODP_PKTOUT_MODE_DIRECT);
+   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
+
+   odp_pktio_config_init(&config);
+
+   CU_ASSERT(odp_pktio_config(pktio, NULL) == 0);
+
+   CU_ASSERT(odp_pktio_config(pktio, &config) == 0);
+
+   CU_ASSERT_FATAL(odp_pktio_capability(pktio, &capa) == 0);
+
+   config = capa.config;
+   CU_ASSERT(odp_pktio_config(pktio, &config) == 0);
+
+   CU_ASSERT_FATAL(odp_pktio_close(pktio) == 0);
+}
+
 void pktio_test_pktin_queue_config_direct(void)
 {
odp_pktio_t pktio;
@@ -1750,6 +1773,7 @@ odp_testinfo_t pktio_suite_unsegmented[] = {
ODP_TEST_INFO(pktio_test_lookup),
ODP_TEST_INFO(pktio_test_index),
ODP_TEST_INFO(pktio_test_print),
+   ODP_TEST_INFO(pktio_test_pktio_config),
ODP_TEST_INFO(pktio_test_pktin_queue_config_direct),
ODP_TEST_INFO(pktio_test_pktin_queue_config_sched),
ODP_TEST_INFO(pktio_test_pktin_queue_config_queue),
diff --git a/test/validation/pktio/pktio.h b/test/validation/pktio/pktio.h
index 495031b..9c1b210 100644
--- a/test/validation/pktio/pktio.h
+++ b/test/validation/pktio/pktio.h
@@ -26,6 +26,7 @@ void pktio_test_open(void);
 void pktio_test_lookup(void);
 void pktio_test_index(void);
 void pktio_test_inq(void);
+void pktio_test_pktio_config(void);
 void pktio_test_pktin_queue_config_direct(void);
 void pktio_test_pktin_queue_config_sched(void);
 void pktio_test_pktin_queue_config_queue(void);
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCH v5 09/11] linux-generic: packet: add inline helper function for setting packet timestamp

2016-04-21 Thread Matias Elo
Signed-off-by: Matias Elo 
---
 platform/linux-generic/include/odp_packet_internal.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/platform/linux-generic/include/odp_packet_internal.h 
b/platform/linux-generic/include/odp_packet_internal.h
index 1005535..7421d71 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -285,6 +285,14 @@ static inline int packet_hdr_has_eth(odp_packet_hdr_t 
*pkt_hdr)
return pkt_hdr->input_flags.eth;
 }
 
+static inline void packet_set_ts(odp_packet_hdr_t *pkt_hdr, odp_time_t *ts)
+{
+   if (ts != NULL) {
+   pkt_hdr->timestamp = *ts;
+   pkt_hdr->input_flags.timestamp = 1;
+   }
+}
+
 int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr);
 
 int _odp_cls_parse(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr);
-- 
1.9.1

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


[lng-odp] [API-NEXT PATCH v5 06/11] validation: pktio: add helper function for creating test packets

2016-04-21 Thread Matias Elo
Add helper function for creating test packets to reduce
duplicate code.

Signed-off-by: Matias Elo 
---
 test/validation/pktio/pktio.c | 134 +++---
 1 file changed, 46 insertions(+), 88 deletions(-)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index b141cd6..6dc6505 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -372,6 +372,33 @@ static int flush_input_queue(odp_pktio_t pktio, 
odp_pktin_mode_t imode)
return 0;
 }
 
+static int create_packets(odp_packet_t pkt_tbl[], uint32_t pkt_seq[], int num,
+ odp_pktio_t pktio_src, odp_pktio_t pktio_dst)
+{
+   int i;
+
+   for (i = 0; i < num; i++) {
+   pkt_tbl[i] = odp_packet_alloc(default_pkt_pool, packet_len);
+   if (pkt_tbl[i] == ODP_PACKET_INVALID)
+   break;
+
+   pkt_seq[i] = pktio_init_packet(pkt_tbl[i]);
+   if (pkt_seq[i] == TEST_SEQ_INVALID) {
+   odp_packet_free(pkt_tbl[i]);
+   break;
+   }
+
+   pktio_pkt_set_macs(pkt_tbl[i], pktio_src, pktio_dst);
+
+   if (pktio_fixup_checksums(pkt_tbl[i]) != 0) {
+   odp_packet_free(pkt_tbl[i]);
+   break;
+   }
+   }
+
+   return i;
+}
+
 static int get_packets(pktio_info_t *pktio_rx, odp_packet_t pkt_tbl[],
   int num, txrx_mode_e mode)
 {
@@ -512,25 +539,9 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, 
pktio_info_t *pktio_b,
}
 
/* generate test packets to send */
-   for (i = 0; i < num_pkts; ++i) {
-   tx_pkt[i] = odp_packet_alloc(default_pkt_pool, packet_len);
-   if (tx_pkt[i] == ODP_PACKET_INVALID)
-   break;
-
-   tx_seq[i] = pktio_init_packet(tx_pkt[i]);
-   if (tx_seq[i] == TEST_SEQ_INVALID) {
-   odp_packet_free(tx_pkt[i]);
-   break;
-   }
-
-   pktio_pkt_set_macs(tx_pkt[i], pktio_a->id, pktio_b->id);
-   if (pktio_fixup_checksums(tx_pkt[i]) != 0) {
-   odp_packet_free(tx_pkt[i]);
-   break;
-   }
-   }
-
-   if (i != num_pkts) {
+   ret = create_packets(tx_pkt, tx_seq, num_pkts, pktio_a->id,
+pktio_b->id);
+   if (ret != num_pkts) {
CU_FAIL("failed to generate test packets");
return;
}
@@ -738,25 +749,9 @@ void pktio_test_recv_queue(void)
pktio_rx = pktio_tx;
 
/* Allocate and initialize test packets */
-   for (i = 0; i < TX_BATCH_LEN; i++) {
-   pkt_tbl[i] = odp_packet_alloc(default_pkt_pool, packet_len);
-   if (pkt_tbl[i] == ODP_PACKET_INVALID)
-   break;
-
-   pkt_seq[i] = pktio_init_packet(pkt_tbl[i]);
-   if (pkt_seq[i] == TEST_SEQ_INVALID) {
-   odp_packet_free(pkt_tbl[i]);
-   break;
-   }
-
-   pktio_pkt_set_macs(pkt_tbl[i], pktio_tx, pktio_rx);
-
-   if (pktio_fixup_checksums(pkt_tbl[i]) != 0) {
-   odp_packet_free(pkt_tbl[i]);
-   break;
-   }
-   }
-   if (i != TX_BATCH_LEN) {
+   ret = create_packets(pkt_tbl, pkt_seq, TX_BATCH_LEN, pktio_tx,
+pktio_rx);
+   if (ret != TX_BATCH_LEN) {
CU_FAIL("Failed to generate test packets");
return;
}
@@ -799,6 +794,8 @@ void pktio_test_recv_queue(void)
} while (num_rx < TX_BATCH_LEN &&
 odp_time_cmp(end, odp_time_local()) > 0);
 
+   CU_ASSERT(num_rx == TX_BATCH_LEN);
+
for (i = 0; i < num_rx; i++)
odp_packet_free(pkt_tbl[i]);
 
@@ -1192,6 +1189,7 @@ void pktio_test_statistics_counters(void)
odp_pktio_t pktio[MAX_NUM_IFACES];
odp_packet_t pkt;
odp_packet_t tx_pkt[1000];
+   uint32_t pkt_seq[1000];
odp_event_t ev;
int i, pkts, tx_pkts, ret, alloc = 0;
odp_pktout_queue_t pktout;
@@ -1223,19 +1221,7 @@ void pktio_test_statistics_counters(void)
odp_event_free(ev);
}
 
-   /* alloc */
-   for (alloc = 0; alloc < 1000; alloc++) {
-   pkt = odp_packet_alloc(default_pkt_pool, packet_len);
-   if (pkt == ODP_PACKET_INVALID)
-   break;
-   pktio_init_packet(pkt);
-   pktio_pkt_set_macs(pkt, pktio_tx, pktio_rx);
-   if (pktio_fixup_checksums(pkt) != 0) {
-   odp_packet_free(pkt);
-   break;
-   }
-   tx_pkt[alloc] = pkt;
-   }
+   alloc = create_packets(tx_pkt, pkt_seq, 1000, pktio_tx, pktio_rx);
 
re

[lng-odp] [API-NEXT PATCH v5 08/11] validation: pktio: add pktin timestamping test

2016-04-21 Thread Matias Elo
Add validation test for packet input timestamping. Tests
also odp_pktin_ts_res() and odp_pktin_ts_from_ns().

Signed-off-by: Matias Elo 
---
 test/validation/pktio/pktio.c | 122 ++
 test/validation/pktio/pktio.h |   2 +
 2 files changed, 124 insertions(+)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index f7dbf2e..3b40c7b 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -26,6 +26,11 @@
 #define TX_BATCH_LEN   4
 #define MAX_QUEUES 128
 
+#define PKTIN_TS_INTERVAL  (50 * ODP_TIME_MSEC_IN_NS)
+#define PKTIN_TS_MIN_RES   1000
+#define PKTIN_TS_MAX_RES   100
+#define PKTIN_TS_CMP_RES   1
+
 #undef DEBUG_STATS
 
 /** interface names used for testing */
@@ -1666,6 +1671,121 @@ void pktio_test_send_on_ronly(void)
CU_ASSERT_FATAL(ret == 0);
 }
 
+int pktio_check_pktin_ts(void)
+{
+   odp_pktio_t pktio;
+   odp_pktio_capability_t capa;
+   odp_pktio_param_t pktio_param;
+   int ret;
+
+   odp_pktio_param_init(&pktio_param);
+   pktio_param.in_mode = ODP_PKTIN_MODE_DIRECT;
+
+   pktio = odp_pktio_open(iface_name[0], pool[0], &pktio_param);
+   if (pktio == ODP_PKTIO_INVALID)
+   return ODP_TEST_INACTIVE;
+
+   ret = odp_pktio_capability(pktio, &capa);
+   (void)odp_pktio_close(pktio);
+
+   if (ret < 0 || !capa.config.pktin.bit.ts_all)
+   return ODP_TEST_INACTIVE;
+
+   return ODP_TEST_ACTIVE;
+}
+
+void pktio_test_pktin_ts(void)
+{
+   odp_pktio_t pktio_tx, pktio_rx;
+   odp_pktio_t pktio[MAX_NUM_IFACES];
+   pktio_info_t pktio_rx_info;
+   odp_pktio_capability_t capa;
+   odp_pktio_config_t config;
+   odp_pktout_queue_t pktout_queue;
+   odp_packet_t pkt_tbl[TX_BATCH_LEN];
+   uint32_t pkt_seq[TX_BATCH_LEN];
+   uint64_t ns1, ns2;
+   uint64_t res;
+   odp_time_t ts_prev;
+   odp_time_t ts;
+   int num_rx = 0;
+   int ret;
+   int i;
+
+   CU_ASSERT_FATAL(num_ifaces >= 1);
+
+   /* Open and configure interfaces */
+   for (i = 0; i < num_ifaces; ++i) {
+   pktio[i] = create_pktio(i, ODP_PKTIN_MODE_DIRECT,
+   ODP_PKTOUT_MODE_DIRECT);
+   CU_ASSERT_FATAL(pktio[i] != ODP_PKTIO_INVALID);
+
+   CU_ASSERT_FATAL(odp_pktio_capability(pktio[i], &capa) == 0);
+   CU_ASSERT_FATAL(capa.config.pktin.bit.ts_all);
+
+   odp_pktio_config_init(&config);
+   config.pktin.bit.ts_all = 1;
+   CU_ASSERT_FATAL(odp_pktio_config(pktio[i], &config) == 0);
+
+   CU_ASSERT_FATAL(odp_pktio_start(pktio[i]) == 0);
+   }
+
+   for (i = 0; i < num_ifaces; i++)
+   _pktio_wait_linkup(pktio[i]);
+
+   pktio_tx = pktio[0];
+   pktio_rx = (num_ifaces > 1) ? pktio[1] : pktio_tx;
+   pktio_rx_info.id   = pktio_rx;
+   pktio_rx_info.inq  = ODP_QUEUE_INVALID;
+   pktio_rx_info.in_mode = ODP_PKTIN_MODE_DIRECT;
+
+   /* Test odp_pktin_ts_res() and odp_pktin_ts_from_ns() */
+   res = odp_pktin_ts_res(pktio_tx);
+   CU_ASSERT(res > PKTIN_TS_MIN_RES);
+   CU_ASSERT(res < PKTIN_TS_MAX_RES);
+   ns1 = 100;
+   ts = odp_pktin_ts_from_ns(pktio_tx, ns1);
+   ns2 = odp_time_to_ns(ts);
+   /* Allow some arithmetic tolerance */
+   CU_ASSERT((ns2 <= (ns1 + PKTIN_TS_CMP_RES)) &&
+ (ns2 >= (ns1 - PKTIN_TS_CMP_RES)));
+
+   ret = create_packets(pkt_tbl, pkt_seq, TX_BATCH_LEN, pktio_tx,
+pktio_rx);
+   CU_ASSERT_FATAL(ret == TX_BATCH_LEN);
+
+   ret = odp_pktout_queue(pktio_tx, &pktout_queue, 1);
+   CU_ASSERT_FATAL(ret > 0);
+
+   /* Send packets one at a time and add delay between the packets */
+   for (i = 0; i < TX_BATCH_LEN;  i++) {
+   CU_ASSERT_FATAL(odp_pktout_send(pktout_queue,
+   &pkt_tbl[i], 1) == 1);
+   ret = wait_for_packets(&pktio_rx_info, &pkt_tbl[i], &pkt_seq[i],
+  1, TXRX_MODE_SINGLE, ODP_TIME_SEC_IN_NS);
+   if (ret != 1)
+   break;
+   odp_time_wait_ns(PKTIN_TS_INTERVAL);
+   }
+   num_rx = i;
+   CU_ASSERT(num_rx == TX_BATCH_LEN);
+
+   ts_prev = ODP_TIME_NULL;
+   for (i = 0; i < num_rx; i++) {
+   ts = odp_packet_ts(pkt_tbl[i]);
+
+   CU_ASSERT(odp_time_cmp(ts, ts_prev) > 0);
+
+   ts_prev = ts;
+   odp_packet_free(pkt_tbl[i]);
+   }
+
+   for (i = 0; i < num_ifaces; i++) {
+   CU_ASSERT_FATAL(odp_pktio_stop(pktio[i]) == 0);
+   CU_ASSERT_FATAL(odp_pktio_close(pktio[i]) == 0);
+   }
+}
+
 static int create_pool(const char *iface, int num)
 {
char pool_name[ODP_POOL_NAME_LEN];
@@ -1799,6 +1919,8 @@ odp_testinfo_t pktio_sui

[lng-odp] [API-NEXT PATCH v5 10/11] linux-generic: pktio: add pktin timestamp argument to _odp_packet_cls_enq()

2016-04-21 Thread Matias Elo
_odp_packet_cls_enq() allocates new odp packets internally.
Add new packet timestamp argument to enable adding input
timestamps to these packets.

Signed-off-by: Matias Elo 
---
 .../linux-generic/include/odp_packet_io_internal.h |  3 ++-
 platform/linux-generic/pktio/dpdk.c|  2 +-
 platform/linux-generic/pktio/netmap.c  |  2 +-
 platform/linux-generic/pktio/pktio_common.c| 18 +++---
 platform/linux-generic/pktio/socket.c  |  3 ++-
 platform/linux-generic/pktio/socket_mmap.c |  3 ++-
 6 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/platform/linux-generic/include/odp_packet_io_internal.h 
b/platform/linux-generic/include/odp_packet_io_internal.h
index a807d13..9fc13a9 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -211,7 +211,8 @@ typedef struct pktio_if_ops {
 } pktio_if_ops_t;
 
 int _odp_packet_cls_enq(pktio_entry_t *pktio_entry, const uint8_t *base,
-   uint16_t buf_len, odp_packet_t *pkt_ret);
+   uint16_t buf_len, odp_time_t *ts,
+   odp_packet_t *pkt_ret);
 
 extern void *pktio_entry_ptr[];
 
diff --git a/platform/linux-generic/pktio/dpdk.c 
b/platform/linux-generic/pktio/dpdk.c
index 83fb1ba..3845448 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -677,7 +677,7 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry,
if (pktio_cls_enabled(pktio_entry)) {
if (_odp_packet_cls_enq(pktio_entry,
(const uint8_t *)buf, pkt_len,
-   &pkt_table[nb_pkts]))
+   NULL, &pkt_table[nb_pkts]))
nb_pkts++;
} else {
pkt = packet_alloc(pktio_entry->s.pkt_dpdk.pool,
diff --git a/platform/linux-generic/pktio/netmap.c 
b/platform/linux-generic/pktio/netmap.c
index 0b794a0..9112ba3 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -586,7 +586,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t 
*pktio_entry,
 
if (pktio_cls_enabled(pktio_entry)) {
ret = _odp_packet_cls_enq(pktio_entry, (const uint8_t *)buf,
- len, pkt_out);
+ len, NULL, pkt_out);
if (ret)
return 0;
return -1;
diff --git a/platform/linux-generic/pktio/pktio_common.c 
b/platform/linux-generic/pktio/pktio_common.c
index c568da3..e7bb3d8 100644
--- a/platform/linux-generic/pktio/pktio_common.c
+++ b/platform/linux-generic/pktio/pktio_common.c
@@ -10,18 +10,19 @@
 
 int _odp_packet_cls_enq(pktio_entry_t *pktio_entry,
const uint8_t *base, uint16_t buf_len,
-   odp_packet_t *pkt_ret)
+   odp_time_t *ts, odp_packet_t *pkt_ret)
 {
cos_t *cos;
odp_packet_t pkt;
-   odp_packet_hdr_t pkt_hdr;
+   odp_packet_hdr_t *pkt_hdr;
+   odp_packet_hdr_t src_pkt_hdr;
int ret;
odp_pool_t pool;
 
-   packet_parse_reset(&pkt_hdr);
+   packet_parse_reset(&src_pkt_hdr);
 
-   _odp_cls_parse(&pkt_hdr, base);
-   cos = pktio_select_cos(pktio_entry, base, &pkt_hdr);
+   _odp_cls_parse(&src_pkt_hdr, base);
+   cos = pktio_select_cos(pktio_entry, base, &src_pkt_hdr);
 
/* if No CoS found then drop the packet */
if (cos == NULL || cos->s.queue == NULL || cos->s.pool == NULL)
@@ -32,15 +33,18 @@ int _odp_packet_cls_enq(pktio_entry_t *pktio_entry,
pkt = odp_packet_alloc(pool, buf_len);
if (odp_unlikely(pkt == ODP_PACKET_INVALID))
return 0;
+   pkt_hdr = odp_packet_hdr(pkt);
 
-   copy_packet_parser_metadata(&pkt_hdr, odp_packet_hdr(pkt));
-   odp_packet_hdr(pkt)->input = pktio_entry->s.handle;
+   copy_packet_parser_metadata(&src_pkt_hdr, pkt_hdr);
+   pkt_hdr->input = pktio_entry->s.handle;
 
if (odp_packet_copydata_in(pkt, 0, buf_len, base) != 0) {
odp_packet_free(pkt);
return 0;
}
 
+   packet_set_ts(pkt_hdr, ts);
+
/* Parse and set packet header data */
odp_packet_pull_tail(pkt, odp_packet_len(pkt) - buf_len);
ret = queue_enq(cos->s.queue, odp_buf_to_hdr((odp_buffer_t)pkt), 0);
diff --git a/platform/linux-generic/pktio/socket.c 
b/platform/linux-generic/pktio/socket.c
index 44f18c2..e28fd07 100644
--- a/platform/linux-generic/pktio/socket.c
+++ b/platform/linux-generic/pktio/socket.c
@@ -650,7 +650,8 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry,
continue;
 
ret = _odp_packet_cls_enq(pktio_entry, base,

[lng-odp] [API-NEXT PATCH v5 11/11] linux-generic: pktio: add pktin timestamping support

2016-04-21 Thread Matias Elo
Adds packet input timestamping support using odp global
time. Also implements odp_pktio_capability() for pktio types
still lacking it.

Signed-off-by: Matias Elo 
---
 platform/linux-generic/pktio/dpdk.c| 49 +-
 platform/linux-generic/pktio/loop.c| 27 +-
 platform/linux-generic/pktio/netmap.c  | 83 +-
 platform/linux-generic/pktio/pcap.c| 28 +-
 platform/linux-generic/pktio/socket.c  | 35 +++--
 platform/linux-generic/pktio/socket_mmap.c | 30 ++-
 platform/linux-generic/pktio/tap.c | 37 +++--
 7 files changed, 241 insertions(+), 48 deletions(-)

diff --git a/platform/linux-generic/pktio/dpdk.c 
b/platform/linux-generic/pktio/dpdk.c
index 3845448..9089715 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -485,6 +485,27 @@ static int dpdk_output_queues_config(pktio_entry_t 
*pktio_entry,
return 0;
 }
 
+static void dpdk_init_capability(pktio_entry_t *pktio_entry)
+{
+   pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk;
+   odp_pktio_capability_t *capa = &pkt_dpdk->capa;
+   struct rte_eth_dev_info dev_info;
+
+   memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
+   memset(capa, 0, sizeof(odp_pktio_capability_t));
+
+   rte_eth_dev_info_get(pkt_dpdk->port_id, &dev_info);
+   capa->max_input_queues = RTE_MIN(dev_info.max_rx_queues,
+PKTIO_MAX_QUEUES);
+   capa->max_output_queues = RTE_MIN(dev_info.max_tx_queues,
+ PKTIO_MAX_QUEUES);
+   capa->set_op.op.promisc_mode = 1;
+
+   odp_pktio_config_init(&capa->config);
+   capa->config.pktin.bit.ts_all = 1;
+   capa->config.pktin.bit.ts_ptp = 1;
+}
+
 static int dpdk_open(odp_pktio_t id ODP_UNUSED,
 pktio_entry_t *pktio_entry,
 const char *netdev,
@@ -535,13 +556,7 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED,
return -1;
}
 
-   memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
-   rte_eth_dev_info_get(pkt_dpdk->port_id, &dev_info);
-   pkt_dpdk->capa.max_input_queues = RTE_MIN(dev_info.max_rx_queues,
- PKTIO_MAX_QUEUES);
-   pkt_dpdk->capa.max_output_queues = RTE_MIN(dev_info.max_tx_queues,
-  PKTIO_MAX_QUEUES);
-   pkt_dpdk->capa.set_op.op.promisc_mode = 1;
+   dpdk_init_capability(pktio_entry);
 
mtu = dpdk_mtu_get(pktio_entry);
if (mtu == 0) {
@@ -652,7 +667,7 @@ static int dpdk_stop(pktio_entry_t *pktio_entry)
 static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry,
  odp_packet_t pkt_table[],
  struct rte_mbuf *mbuf_table[],
- uint16_t num)
+ uint16_t num, odp_time_t *ts)
 {
odp_packet_t pkt;
odp_packet_hdr_t *pkt_hdr;
@@ -677,7 +692,7 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry,
if (pktio_cls_enabled(pktio_entry)) {
if (_odp_packet_cls_enq(pktio_entry,
(const uint8_t *)buf, pkt_len,
-   NULL, &pkt_table[nb_pkts]))
+   ts, &pkt_table[nb_pkts]))
nb_pkts++;
} else {
pkt = packet_alloc(pktio_entry->s.pkt_dpdk.pool,
@@ -704,6 +719,8 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry,
if (mbuf->ol_flags & PKT_RX_RSS_HASH)
odp_packet_flow_hash_set(pkt, mbuf->hash.rss);
 
+   packet_set_ts(pkt_hdr, ts);
+
pkt_table[nb_pkts++] = pkt;
}
rte_pktmbuf_free(mbuf);
@@ -765,6 +782,8 @@ static int dpdk_recv_queue(pktio_entry_t *pktio_entry,
 {
pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk;
pkt_cache_t *rx_cache = &pkt_dpdk->rx_cache[index];
+   odp_time_t ts_val;
+   odp_time_t *ts = NULL;
int nb_rx;
struct rte_mbuf *rx_mbufs[num];
int i;
@@ -795,7 +814,6 @@ static int dpdk_recv_queue(pktio_entry_t *pktio_entry,
 
nb_rx = rte_eth_rx_burst(pktio_entry->s.pkt_dpdk.port_id, index,
 new_mbufs, pkt_dpdk->min_rx_burst);
-
rx_cache->s.idx = 0;
for (i = 0; i < nb_rx; i++) {
if (i < num) {
@@ -813,8 +831,15 @@ static int dpdk_recv_queue(pktio_entry_t *pktio_entry,
 rx_mbufs, num);
}
 
-   if (nb_rx > 0)
-   nb_rx = mbuf_to_pkt(pktio_entry, pkt_table, rx_mbufs, nb_rx);
+   if (nb_rx > 0) {
+   if (pktio_entry->s.co

Re: [lng-odp] [PATCH] validation: time: shorten test duration

2016-04-21 Thread Savolainen, Petri (Nokia - FI/Espoo)
> -Original Message-
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT
> Maxim Uvarov
> Sent: Wednesday, April 20, 2016 7:04 PM
> To: lng-odp@lists.linaro.org
> Subject: Re: [lng-odp] [PATCH] validation: time: shorten test duration
> 
> that patch is not part of current series,  please skip it. Other 2
> paches are good for review.
> 
> Maxim.
>

What do you mean? There's no series, you merged v2 of this already into master 
- and hopefully from there to api-next soon.

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


Re: [lng-odp] [PATCH] validation: time: shorten test duration

2016-04-21 Thread Maxim Uvarov

On 04/21/16 11:18, Savolainen, Petri (Nokia - FI/Espoo) wrote:

-Original Message-
From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT
Maxim Uvarov
Sent: Wednesday, April 20, 2016 7:04 PM
To: lng-odp@lists.linaro.org
Subject: Re: [lng-odp] [PATCH] validation: time: shorten test duration

that patch is not part of current series,  please skip it. Other 2
paches are good for review.

Maxim.


What do you mean? There's no series, you merged v2 of this already into master 
- and hopefully from there to api-next soon.

-Petri
  
Your patch was in my git  and I did not delete it. So it was send inside 
my patch serries, but it should not be sent.

It's already reviewed and applied inside your patchset.

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


Re: [lng-odp] [API-NEXT PATCH v2 3/4] api: packet: add data align

2016-04-21 Thread Savolainen, Petri (Nokia - FI/Espoo)


From: EXT Bill Fischofer [mailto:bill.fischo...@linaro.org]
Sent: Wednesday, April 20, 2016 8:22 PM
To: Savolainen, Petri (Nokia - FI/Espoo) 
Cc: LNG ODP Mailman List 
Subject: Re: [lng-odp] [API-NEXT PATCH v2 3/4] api: packet: add data align



On Wed, Apr 20, 2016 at 10:12 AM, Petri Savolainen 
mailto:petri.savolai...@nokia.com>> wrote:
Align an area of packet data (e.g. IP/UDP headers) so that
it is contiguous in memory and starts in a specified
minimum alignment.

Signed-off-by: Petri Savolainen 
mailto:petri.savolai...@nokia.com>>
---
 include/odp/api/spec/packet.h | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index 22775ad..8cdcc0f 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -620,6 +620,40 @@ odp_packet_t odp_packet_add_data(odp_packet_t pkt, 
uint32_t offset,
 odp_packet_t odp_packet_rem_data(odp_packet_t pkt, uint32_t offset,
 uint32_t len);

+/**
+ * Align packet data
+ *
+ * Modify packet data alignment so that 'len' bytes between 'offset' and
+ * 'offset' plus 'len' are contiguous in memory and start in minimum alignment
+ * of 'align' bytes.
+ *
+ * A successful operation overwrites the packet handle with a new handle, which
+ * application must use as the reference to the packet instead of the old
+ * handle. Depending on the implementation, the old and new handles may be
+ * equal.
+ *
+ * The operation return value indicates if any packet data outside of the
+ * requested area or metadata (e.g. user_area) were moved in memory during
+ * the operation. If some other memory areas were moved, application must use
+ * new packet/segment handles to update data pointers. Otherwise, old
+ * pointers remain valid.
+ *
+ * Packet is not modified if operation fails.
+ *
+ * @param[in, out] pkt  Pointer to packet handle. A successful operation 
outputs
+ *  the new packet handle.
+ * @param offsetByte offset of the contiguous area
+ * @param len   Byte length of the contiguous area (0 ... packet_len)
+ * @param align Minimum byte alignment of the contiguous area.
+ *  Implementation rounds up to nearest power of two.
+ *
+ * @retval 0   Operation successful, old pointers remain valid
+ * @retval >0  Operation successful, old pointers need to be updated
+ * @retval <0  Operation failed
+ */
+int odp_packet_align(odp_packet_t *pkt, uint32_t offset, uint32_t len,
+uint32_t align);
+

Since packet handles are opaque, ODP packets are not addressable until they are 
made addressable via a subsequent call (e.g., odp_packet_offset()) so there is 
no requirement that they even exist in addressable memory (let alone contiguous 
and/or aligned memory) until such calls are made. So I think this API needs to 
be rethought.

We will not make the packet API any more opaque than is necessary for the main 
platforms. All main platforms save data into buffers when it arrives into the 
system (into some buffer and address decided by the input HW). When application 
receives a  packet and calls e.g. odp_packet_data(), it may notice that e.g. 
IPv4 header starts in bad align (e.g. 2 byte align instead of 4 byte align) and 
it uses this call to modify data alignment in the packet. The output is a new 
packet handle with corrected alignment.


There are two ways of thinking about this.  First, this API could be setting 
packet metadata such that if and when a subsequent request for addressability 
is made this metadata guides the implementation in how to materialize the 
requested section of the packet for the application. But that's sort of awkward 
because how many such pieces of metadata would need to be maintained and how do 
we deal with conflicting requests?

So a better way is to include these sort of items as part of the APIs that make 
parts of packets addressable. That's one of the reasons I originally proposed 
having explicit map and unmap calls for packets to handle these sort of 
considerations.

No. A better way is to define more packet input configuration parameters: e.g. 
“place IPv4/UDP header always into single segment and IP header alignment must 
be always at least 4 bytes”. But HW is not always capable on that, and there 
are many other reason why alignment may not be what application needs.

So, this function is needed anyway to modify alignment and linearity of the 
data.



Today we have the basic API:

void *odp_packet_offset(odp_packet_t pkt, uint32_t offset, uint32_t *len, 
odp_packet_seg_t *seg);

Since we're cleaning up these APIs I'd suggest deleting that vestigial segment 
handle output, which is of dubious utility, and adding these additional input 
parameters to the request.  Recasting into the new "standard format" for these 
sort of APIs it might look like:

int odp_packet_offset(odp_packet_t *pkt, uint32_t offset, uint32_t len, 
[uin

Re: [lng-odp] [API-NEXT PATCH v2 2/4] api: packet: rename and add copy functions

2016-04-21 Thread Savolainen, Petri (Nokia - FI/Espoo)


From: EXT Bill Fischofer [mailto:bill.fischo...@linaro.org]
Sent: Wednesday, April 20, 2016 8:38 PM
To: Savolainen, Petri (Nokia - FI/Espoo) 
Cc: LNG ODP Mailman List 
Subject: Re: [lng-odp] [API-NEXT PATCH v2 2/4] api: packet: rename and add copy 
functions

It would be better if this were in two parts: the first that does the renames 
to the existing APIs and the second that introduces the new APIs since these 
are orthogonal changes.

I made it one part so that the reader sees names of all copy functions at once. 
The requirement for the rename comes from the new functions and someone may 
have complained that these must be in the same patch because of that…



On Wed, Apr 20, 2016 at 10:12 AM, Petri Savolainen 
mailto:petri.savolai...@nokia.com>> wrote:
Added packet copy functions:
 * partial packet copy
 * data copy data from another packet
 * data copy within packet
 * data move within packet (allow overlap)

Renamed copydata_in and _out functions, so that "to/from memory"
functions are clearly distinctive from the new packet copy
functions.

Signed-off-by: Petri Savolainen 
mailto:petri.savolai...@nokia.com>>
---
 helper/include/odp/helper/ip.h |  4 +-
 include/odp/api/spec/packet.h  | 98 +++---
 platform/linux-generic/odp_packet.c|  8 +-
 platform/linux-generic/pktio/dpdk.c|  7 +-
 platform/linux-generic/pktio/netmap.c  |  4 +-
 platform/linux-generic/pktio/pcap.c|  4 +-
 platform/linux-generic/pktio/pktio_common.c|  2 +-
 platform/linux-generic/pktio/socket_mmap.c |  6 +-
 platform/linux-generic/pktio/tap.c |  4 +-
 test/performance/odp_pktio_perf.c  |  9 +-
 .../classification/odp_classification_common.c | 16 ++--
 test/validation/packet/packet.c|  4 +-
 test/validation/pktio/pktio.c  |  9 +-
 test/validation/traffic_mngr/traffic_mngr.c|  6 +-
 14 files changed, 131 insertions(+), 50 deletions(-)

diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h
index 4df41d9..fa7121a 100644
--- a/helper/include/odp/helper/ip.h
+++ b/helper/include/odp/helper/ip.h
@@ -92,8 +92,8 @@ static inline int odph_ipv4_csum_valid(odp_packet_t pkt)
if (!odp_packet_l3_offset(pkt))
return 0;

-   odp_packet_copydata_out(pkt, odp_packet_l3_offset(pkt),
-   sizeof(odph_ipv4hdr_t), &ip);
+   odp_packet_copy_to_mem(pkt, odp_packet_l3_offset(pkt),
+  sizeof(odph_ipv4hdr_t), &ip);

w = (uint16_t *)(void *)&ip;
chksum = ip.chksum;
diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index b356f0f..22775ad 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -793,7 +793,7 @@ int odp_packet_split(odp_packet_t *pkt, uint32_t len, 
odp_packet_t *tail);
  */

 /**
- * Copy packet
+ * Full copy of a packet
  *
  * Create a new copy of the packet. The new packet is exact copy of the source
  * packet (incl. data and metadata). The pool must have been created with
@@ -808,10 +808,30 @@ int odp_packet_split(odp_packet_t *pkt, uint32_t len, 
odp_packet_t *tail);
 odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_pool_t pool);

 /**
- * Copy data from packet
+ * Partial copy of a packet
  *
- * Copy 'len' bytes of data from the packet level offset to the destination
- * address.
+ * Copy 'len' bytes of data starting from 'offset' into a new packet.
+ * Metadata in the new packet is initialized with default values. Maximum 
number
+ * of bytes to copy is packet data length minus the offset. The pool must be
+ * a packet pool.
+ *
+ * @param pktPacket handle
+ * @param offset Byte offset into the packet
+ * @param lenNumber of bytes to copy
+ * @param pool   Packet pool for allocation of the new packet
+ *
+ * @return Handle for the new packet
+ * @retval ODP_PACKET_INVALID on failure
+ */
+odp_packet_t odp_packet_copy_part(odp_packet_t pkt, uint32_t offset,
+ uint32_t len, odp_pool_t pool);
+
+/**
+ * Copy data from packet to memory
+ *
+ * Copy 'len' bytes of data starting from 'offset' to the destination
+ * address. Maximum number of bytes to copy is packet data length minus the
+ * offset.
  *
  * @param pktPacket handle
  * @param offset Byte offset into the packet
@@ -821,13 +841,13 @@ odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_pool_t 
pool);
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_packet_copydata_out(odp_packet_t pkt, uint32_t offset,
-   uint32_t len, void *dst);
+int odp_packet_copy_to_mem(odp_packet_t pkt, uint32_t offset,
+  uint32_t len, void *dst);

 /**
- * Copy data into packet
+ * Copy data from memory to packet
  *
- * Copy'len' bytes of data from the source address into the packet level
+ * Copy 'len' byte

[lng-odp] [API-NEXT PATCH v3 2/4] api: packet: rename and add copy functions

2016-04-21 Thread Petri Savolainen
Added packet copy functions:
 * partial packet copy
 * data copy data from another packet
 * data copy within packet
 * data move within packet (allow overlap)

Renamed copydata_in and _out functions, so that "to/from memory"
functions are clearly distinctive from the new packet copy
functions.

Signed-off-by: Petri Savolainen 
---
 helper/include/odp/helper/ip.h |  4 +-
 include/odp/api/spec/packet.h  | 99 +++---
 platform/linux-generic/odp_packet.c|  8 +-
 platform/linux-generic/pktio/dpdk.c|  7 +-
 platform/linux-generic/pktio/netmap.c  |  4 +-
 platform/linux-generic/pktio/pcap.c|  4 +-
 platform/linux-generic/pktio/pktio_common.c|  2 +-
 platform/linux-generic/pktio/socket_mmap.c |  6 +-
 platform/linux-generic/pktio/tap.c |  4 +-
 test/performance/odp_pktio_perf.c  |  9 +-
 .../classification/odp_classification_common.c | 16 ++--
 test/validation/packet/packet.c|  4 +-
 test/validation/pktio/pktio.c  |  9 +-
 test/validation/traffic_mngr/traffic_mngr.c|  6 +-
 14 files changed, 132 insertions(+), 50 deletions(-)

diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h
index 4df41d9..fa7121a 100644
--- a/helper/include/odp/helper/ip.h
+++ b/helper/include/odp/helper/ip.h
@@ -92,8 +92,8 @@ static inline int odph_ipv4_csum_valid(odp_packet_t pkt)
if (!odp_packet_l3_offset(pkt))
return 0;
 
-   odp_packet_copydata_out(pkt, odp_packet_l3_offset(pkt),
-   sizeof(odph_ipv4hdr_t), &ip);
+   odp_packet_copy_to_mem(pkt, odp_packet_l3_offset(pkt),
+  sizeof(odph_ipv4hdr_t), &ip);
 
w = (uint16_t *)(void *)&ip;
chksum = ip.chksum;
diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index 800219a..2214ba2 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -794,7 +794,7 @@ int odp_packet_split(odp_packet_t *pkt, uint32_t len, 
odp_packet_t *tail);
  */
 
 /**
- * Copy packet
+ * Full copy of a packet
  *
  * Create a new copy of the packet. The new packet is exact copy of the source
  * packet (incl. data and metadata). The pool must have been created with
@@ -809,10 +809,30 @@ int odp_packet_split(odp_packet_t *pkt, uint32_t len, 
odp_packet_t *tail);
 odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_pool_t pool);
 
 /**
- * Copy data from packet
+ * Partial copy of a packet
  *
- * Copy 'len' bytes of data from the packet level offset to the destination
- * address.
+ * Copy 'len' bytes of data starting from 'offset' into a new packet.
+ * Metadata in the new packet is initialized with default values. Maximum 
number
+ * of bytes to copy is packet data length minus the offset. The pool must be
+ * a packet pool.
+ *
+ * @param pktPacket handle
+ * @param offset Byte offset into the packet
+ * @param lenNumber of bytes to copy
+ * @param pool   Packet pool for allocation of the new packet
+ *
+ * @return Handle for the new packet
+ * @retval ODP_PACKET_INVALID on failure
+ */
+odp_packet_t odp_packet_copy_part(odp_packet_t pkt, uint32_t offset,
+ uint32_t len, odp_pool_t pool);
+
+/**
+ * Copy data from packet to memory
+ *
+ * Copy 'len' bytes of data starting from 'offset' to the destination
+ * address. Maximum number of bytes to copy is packet data length minus the
+ * offset.
  *
  * @param pktPacket handle
  * @param offset Byte offset into the packet
@@ -822,13 +842,13 @@ odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_pool_t 
pool);
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_packet_copydata_out(odp_packet_t pkt, uint32_t offset,
-   uint32_t len, void *dst);
+int odp_packet_copy_to_mem(odp_packet_t pkt, uint32_t offset,
+  uint32_t len, void *dst);
 
 /**
- * Copy data into packet
+ * Copy data from memory to packet
  *
- * Copy'len' bytes of data from the source address into the packet level
+ * Copy 'len' bytes of data from the source address into the packet level
  * offset. Maximum number of bytes to copy is packet data length minus the
  * offset. Packet is not modified on an error.
  *
@@ -840,8 +860,67 @@ int odp_packet_copydata_out(odp_packet_t pkt, uint32_t 
offset,
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_packet_copydata_in(odp_packet_t pkt, uint32_t offset,
-  uint32_t len, const void *src);
+int odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset,
+uint32_t len, const void *src);
+
+/**
+ * Copy data from another packet
+ *
+ * Copy 'len' bytes of data from 'src' packet to 'dst' packet. Copy starts from
+ * the specified source and destination packet offsets. Copied areas
+ * (offset ... offset + len) mu

[lng-odp] [API-NEXT PATCH v3 3/4] api: packet: add data align

2016-04-21 Thread Petri Savolainen
Align an area of packet data (e.g. IP/UDP headers) so that
it is contiguous in memory and starts in a specified
minimum alignment.

Signed-off-by: Petri Savolainen 
---
 include/odp/api/spec/packet.h | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index 2214ba2..da246e2 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -621,6 +621,40 @@ odp_packet_t odp_packet_add_data(odp_packet_t pkt, 
uint32_t offset,
 odp_packet_t odp_packet_rem_data(odp_packet_t pkt, uint32_t offset,
 uint32_t len);
 
+/**
+ * Align packet data
+ *
+ * Modify packet data alignment so that 'len' bytes between 'offset' and
+ * 'offset' plus 'len' are contiguous in memory and start in minimum alignment
+ * of 'align' bytes.
+ *
+ * A successful operation overwrites the packet handle with a new handle, which
+ * application must use as the reference to the packet instead of the old
+ * handle. Depending on the implementation, the old and new handles may be
+ * equal.
+ *
+ * The operation return value indicates if any packet data outside of the
+ * requested area or metadata (e.g. user_area) were moved in memory during
+ * the operation. If some other memory areas were moved, application must use
+ * new packet/segment handles to update data pointers. Otherwise, old
+ * pointers remain valid.
+ *
+ * Packet is not modified if operation fails.
+ *
+ * @param[in, out] pkt  Pointer to packet handle. A successful operation 
outputs
+ *  the new packet handle.
+ * @param offsetByte offset of the contiguous area
+ * @param len   Byte length of the contiguous area (0 ... packet_len)
+ * @param align Minimum byte alignment of the contiguous area.
+ *  Implementation rounds up to nearest power of two.
+ *
+ * @retval 0   Operation successful, old pointers remain valid
+ * @retval >0  Operation successful, old pointers need to be updated
+ * @retval <0  Operation failed
+ */
+int odp_packet_align(odp_packet_t *pkt, uint32_t offset, uint32_t len,
+uint32_t align);
+
 /*
  *
  * Segmentation
-- 
2.7.2

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


[lng-odp] [API-NEXT PATCH v3 4/4] api: packet: update add_data and rem_data definition

2016-04-21 Thread Petri Savolainen
Updated odp_packet_add_data and _rem_data definitions to match
other calls that may or may not move data. The new packet
handle is output through packet handle pointer parameter and
return codes indicate if old data was moved or not, or if
the operation failed.

Signed-off-by: Petri Savolainen 
---
 include/odp/api/spec/packet.h   | 71 -
 platform/linux-generic/odp_packet.c | 68 ++-
 test/validation/packet/packet.c | 15 
 3 files changed, 91 insertions(+), 63 deletions(-)

diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index da246e2..de128df 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -586,40 +586,61 @@ int odp_packet_trunc_tail(odp_packet_t *pkt, uint32_t 
len, void **tail_ptr,
 /**
  * Add data into an offset
  *
- * Increases packet data length by adding new data area into the specified
- * offset. The operation returns a new packet handle on success. It may modify
- * packet segmentation and move data. Handles and pointers must be updated
- * after the operation. User is responsible to update packet metadata offsets
- * when needed. The packet is not modified on an error.
+ * Increase packet data length by adding new data area into the specified
+ * offset. The operation may modify packet segmentation and move data.
  *
- * @param pkt Packet handle
- * @param offset  Byte offset into the packet
- * @param len Number of bytes to add into the offset
+ * A successful operation overwrites the packet handle with a new handle, which
+ * application must use as the reference to the packet instead of the old
+ * handle. Depending on the implementation, the old and new handles may be
+ * equal.
  *
- * @return New packet handle
- * @retval ODP_PACKET_INVALID on failure
+ * The operation return value indicates if any packet data or metadata (e.g.
+ * user_area) were moved in memory during the operation. If some memory areas
+ * were moved, application must use new packet/segment handles to update
+ * data pointers. Otherwise, all old pointers remain valid.
+ *
+ * User is responsible to update packet metadata offsets when needed. Packet
+ * is not modified if operation fails.
+ *
+ * @param[in, out] pkt  Pointer to packet handle. A successful operation 
outputs
+ *  the new packet handle.
+ * @param offsetByte offset into the packet
+ * @param len   Number of bytes to add into the offset
+ *
+ * @retval 0   Operation successful, old pointers remain valid
+ * @retval >0  Operation successful, old pointers need to be updated
+ * @retval <0  Operation failed
  */
-odp_packet_t odp_packet_add_data(odp_packet_t pkt, uint32_t offset,
-uint32_t len);
+int odp_packet_add_data(odp_packet_t *pkt, uint32_t offset, uint32_t len);
 
 /**
  * Remove data from an offset
  *
- * Decreases packet data length by removing data from the specified offset.
- * The operation returns a new packet handle on success, and may modify
- * packet segmentation and move data. Handles and pointers must be updated
- * after the operation. User is responsible to update packet metadata offsets
- * when needed. The packet is not modified on an error.
+ * Decrease packet data length by removing data area from the specified
+ * offset. The operation may modify packet segmentation and move data.
  *
- * @param pkt Packet handle
- * @param offset  Byte offset into the packet
- * @param len Number of bytes to remove from the offset
+ * A successful operation overwrites the packet handle with a new handle, which
+ * application must use as the reference to the packet instead of the old
+ * handle. Depending on the implementation, the old and new handles may be
+ * equal.
  *
- * @return New packet handle
- * @retval ODP_PACKET_INVALID on failure
- */
-odp_packet_t odp_packet_rem_data(odp_packet_t pkt, uint32_t offset,
-uint32_t len);
+ * The operation return value indicates if any packet data or metadata (e.g.
+ * user_area) were moved in memory during the operation. If some memory areas
+ * were moved, application must use new packet/segment handles to update
+ * data pointers. Otherwise, all old pointers remain valid.
+ *
+ * User is responsible to update packet metadata offsets when needed. Packet
+ * is not modified if operation fails.
+ *
+ * @param[in, out] pkt  Pointer to packet handle. A successful operation 
outputs
+ *  the new packet handle.
+ * @param offsetByte offset into the packet
+ * @param len   Number of bytes to remove from the offset
+ *
+ * @retval 0   Operation successful, old pointers remain valid
+ * @retval >0  Operation successful, old pointers need to be updated
+ * @retval <0  Operation failed */
+int odp_packet_rem_data(odp_packet_t *pkt, uint32_t offset, uint32_t len);
 
 /**
  * Align packet data
diff --git a/platform/linux-ge

[lng-odp] [API-NEXT PATCH v3 1/4] api: packet: add packet concat and split

2016-04-21 Thread Petri Savolainen
Added odp_packet_concat() and _split(). Two packets may be
concatenated one after another, and split at any offset. This
suites the common use cases of packet reassembly and
fragmentation. Reassembly is done on complete packets, while
fragmentation may be needed on any offset.

Signed-off-by: Petri Savolainen 
---
 include/odp/api/spec/packet.h | 70 +++
 1 file changed, 70 insertions(+)

diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index e52fb29..800219a 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -716,6 +716,76 @@ void *odp_packet_seg_data(odp_packet_t pkt, 
odp_packet_seg_t seg);
  */
 uint32_t odp_packet_seg_data_len(odp_packet_t pkt, odp_packet_seg_t seg);
 
+/**
+ * Concatenate two packets
+ *
+ * Concatenate all packet data from 'src' packet into tail of 'dst' packet.
+ * Operation preserves 'dst' packet metadata in the resulting packet,
+ * while 'src' packet handle, metadata and old segment handles for both packets
+ * become invalid.
+ *
+ * A successful operation overwrites 'dst' packet handle with a new handle,
+ * which application must use as the reference to the resulting packet
+ * instead of the old handle. Depending on the implementation, the old and new
+ * handles may be equal.
+ *
+ * The operation return value indicates if any packet data or metadata (e.g.
+ * user_area) were moved in memory during the operation. If some memory areas
+ * were moved, application must use new packet/segment handles to update
+ * data pointers. Otherwise, all old pointers remain valid.
+ *
+ * The resulting packet is always allocated from the same pool as
+ * the destination packet. The source packet may have been allocate from
+ * any pool.
+ *
+ * On failure, both handles remain valid and packets are not modified.
+ *
+ * @param[in, out] dst   Pointer to destination packet handle. A successful
+ *   operation outputs the new packet handle.
+ * @param srcSource packet handle
+ *
+ * @retval 0   Operation successful, old pointers remain valid
+ * @retval >0  Operation successful, old pointers need to be updated
+ * @retval <0  Operation failed
+ */
+int odp_packet_concat(odp_packet_t *dst, odp_packet_t src);
+
+/**
+ * Split packet into two packets
+ *
+ * Split the packet after 'len' bytes. The first 'len' bytes of data and
+ * metadata remain in the head packet. A successful operation outputs a handle
+ * for the tail packet and overwrites 'pkt' packet handle with a new
+ * handle, which application must use as the reference to the resulting head
+ * packet. Depending on the implementation, the old and new 'pkt' handles
+ * may be equal.
+ *
+ * The operation return value indicates if any packet data or metadata (e.g.
+ * user_area) were moved in memory during the operation. If some memory areas
+ * were moved, application must use new packet/segment handles to update
+ * data pointers. Otherwise, all old pointers remain valid.
+ *
+ * The tail packet holds the rest of the data (odp_packet_len() - 'len' bytes).
+ * The packet is allocated from the same pool as the original packet and
+ * metadata is initialized with default values.
+ *
+ * For performance reasons (zero copy), the head packet may have zero tailroom
+ * and the tail packet may have zero headroom length after the operation.
+ * Both packets may be extended normally.
+ *
+ * The original packet is not modified on failure.
+ *
+ * @param[in, out] pkt   Pointer to packet handle. A successful operation
+ *   outputs a new packet handle for the head packet.
+ * @param lenData length remaining in the head packet
+ * @param tail   Pointer to output the tail packet handle
+ *
+ * @retval 0   Operation successful, old pointers remain valid
+ * @retval >0  Operation successful, old pointers need to be updated
+ * @retval <0  Operation failed
+ */
+int odp_packet_split(odp_packet_t *pkt, uint32_t len, odp_packet_t *tail);
+
 /*
  *
  * Copy
-- 
2.7.2

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


[lng-odp] [API-NEXT PATCH v2] api: queue: add queue context length

2016-04-21 Thread Petri Savolainen
Added queue context length parameter, which is a hint for
the implementation for how much to prefetch. Added the same in
to the set function. It's not needed for get function since
application can store the same into context data and
implementation may avoid to save the length if it does not
need it (e.g. always prefetches a fixed number of bytes).

Signed-off-by: Petri Savolainen 
---
 include/odp/api/spec/queue.h  | 10 +-
 platform/linux-generic/odp_queue.c|  3 ++-
 test/validation/queue/queue.c | 10 ++
 test/validation/scheduler/scheduler.c |  6 +++---
 4 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/include/odp/api/spec/queue.h b/include/odp/api/spec/queue.h
index 7626ca7..7cc031d 100644
--- a/include/odp/api/spec/queue.h
+++ b/include/odp/api/spec/queue.h
@@ -140,6 +140,13 @@ typedef struct odp_queue_param_t {
  * pointer for prefetching the context data. Default value of the
  * pointer is NULL. */
void *context;
+
+   /** Queue context data length
+ *
+ * User defined context data length in bytes for prefetching.
+ * The implementation may use this value as a hint for the number of
+ * context data bytes to prefetch. Default value is zero (no hint). */
+   uint32_t context_len;
 } odp_queue_param_t;
 
 /**
@@ -192,11 +199,12 @@ odp_queue_t odp_queue_lookup(const char *name);
  *
  * @param queueQueue handle
  * @param context  Address to the queue context
+ * @param len  Queue context data length in bytes
  *
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_queue_context_set(odp_queue_t queue, void *context);
+int odp_queue_context_set(odp_queue_t queue, void *context, uint32_t len);
 
 /**
  * Get queue context
diff --git a/platform/linux-generic/odp_queue.c 
b/platform/linux-generic/odp_queue.c
index 342ffa2..9a9462d 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -344,7 +344,8 @@ int odp_queue_destroy(odp_queue_t handle)
return 0;
 }
 
-int odp_queue_context_set(odp_queue_t handle, void *context)
+int odp_queue_context_set(odp_queue_t handle, void *context,
+ uint32_t len ODP_UNUSED)
 {
queue_entry_t *queue;
queue = queue_to_qentry(handle);
diff --git a/test/validation/queue/queue.c b/test/validation/queue/queue.c
index 50c6857..96d21fa 100644
--- a/test/validation/queue/queue.c
+++ b/test/validation/queue/queue.c
@@ -12,7 +12,7 @@
 #define MSG_POOL_SIZE   (4 * 1024 * 1024)
 #define CONFIG_MAX_ITERATION(100)
 
-static int queue_contest = 0xff;
+static int queue_context = 0xff;
 static odp_pool_t pool;
 
 int queue_suite_init(void)
@@ -76,10 +76,11 @@ void queue_test_sunnydays(void)
CU_ASSERT_EQUAL(ODP_SCHED_SYNC_PARALLEL,
odp_queue_sched_type(queue_id));
 
-   CU_ASSERT(0 == odp_queue_context_set(queue_id, &queue_contest));
+   CU_ASSERT(0 == odp_queue_context_set(queue_id, &queue_context,
+sizeof(queue_context)));
 
prtn = odp_queue_context(queue_id);
-   CU_ASSERT(&queue_contest == (int *)prtn);
+   CU_ASSERT(&queue_context == (int *)prtn);
 
msg_pool = odp_pool_lookup("msg_pool");
buf = odp_buffer_alloc(msg_pool);
@@ -144,7 +145,8 @@ void queue_test_info(void)
/* Create a plain queue and set context */
q_plain = odp_queue_create(nq_plain, NULL);
CU_ASSERT(ODP_QUEUE_INVALID != q_plain);
-   CU_ASSERT(odp_queue_context_set(q_plain, q_plain_ctx) == 0);
+   CU_ASSERT(odp_queue_context_set(q_plain, q_plain_ctx,
+   sizeof(q_plain_ctx)) == 0);
 
/* Create a scheduled ordered queue with explicitly set params */
odp_queue_param_init(¶m);
diff --git a/test/validation/scheduler/scheduler.c 
b/test/validation/scheduler/scheduler.c
index ae98401..dae859e 100644
--- a/test/validation/scheduler/scheduler.c
+++ b/test/validation/scheduler/scheduler.c
@@ -592,7 +592,7 @@ static void chaos_run(unsigned int qtype)
CU_ASSERT_FATAL(globals->chaos_q[i].handle !=
ODP_QUEUE_INVALID);
rc = odp_queue_context_set(globals->chaos_q[i].handle,
-  CHAOS_NDX_TO_PTR(i));
+  CHAOS_NDX_TO_PTR(i), 0);
CU_ASSERT_FATAL(rc == 0);
}
 
@@ -1374,7 +1374,7 @@ static int create_queues(void)
pqctx->ctx_handle = queue_ctx_buf;
pqctx->sequence = 0;
 
-   rc = odp_queue_context_set(pq, pqctx);
+   rc = odp_queue_context_set(pq, pqctx, 0);
 
if (rc != 0) {
printf("Cannot set plain queue context\n");
@@ -1419,7 +1419,7 @@ static int create_queues(void)
qctx->lock_seque

Re: [lng-odp] [API-NEXT 1/4] api: classification: Adds capability and PMR range

2016-04-21 Thread Savolainen, Petri (Nokia - FI/Espoo)


> -Original Message-
> From: EXT Balasubramanian Manoharan [mailto:bala.manoha...@linaro.org]
> Sent: Thursday, April 21, 2016 9:19 AM
> To: lng-odp@lists.linaro.org
> Cc: Savolainen, Petri (Nokia - FI/Espoo) ;
> Balasubramanian Manoharan 
> Subject: [API-NEXT 1/4] api: classification: Adds capability and PMR range
> 
> Adds classification capability structure and PMR range functionality.
> odp_cls_capability_t structure defines system level classification
> capability.
> 
> Signed-off-by: Balasubramanian Manoharan 
> ---
>  include/odp/api/spec/classification.h | 134 -
> -
>  1 file changed, 112 insertions(+), 22 deletions(-)
> 
> diff --git a/include/odp/api/spec/classification.h
> b/include/odp/api/spec/classification.h
> index 076b3de..28619a9 100644
> --- a/include/odp/api/spec/classification.h
> +++ b/include/odp/api/spec/classification.h
> @@ -55,6 +55,76 @@ extern "C" {
>   */
> 
>  /**
> + * Supported PMR term values
> + *
> + * Supported Packet Matching Rule term values in a bit field structure.
> + */
> +typedef union odp_cls_pmr_supported_t {
> + struct {
> + /** Total length of received packet */
> + uint64_tpmr_len:1;

This should be shortly "len".

> + /** Initial (outer) Ethertype only */
> + uint64_tethtype_0:1;
> + /** Ethertype of most inner VLAN tag */
> + uint64_tethtype_x:1;
> + /** First VLAN ID (outer) */
> + uint64_tvlan_id_0:1;
> + /** Last VLAN ID (inner) */
> + uint64_tvlan_id_x:1;
> + /** destination MAC address */
> + uint64_tdmac:1;
> + /** IP Protocol or IPv6 Next Header */
> + uint64_tip_proto:1;
> + /** Destination UDP port, implies IPPROTO=17 */
> + uint64_tudp_dport:1;
> + /** Destination TCP port implies IPPROTO=6 */
> + uint64_ttcp_dport:1;
> + /** Source UDP Port */
> + uint64_tudp_sport:1;
> + /** Source TCP port */
> + uint64_ttcp_sport:1;
> + /** Source IP address */
> + uint64_tsip_addr:1;
> + /** Destination IP address */
> + uint64_tdip_addr:1;
> + /** Source IP address */
> + uint64_tsip6_addr:1;
> + /** Destination IP address */
> + uint64_tdip6_addr:1;
> + /** IPsec session identifier */
> + uint64_tipsec_spi:1;
> + /** NVGRE/VXLAN network identifier */
> + uint64_tld_vni:1;
> + /** Custom match rule, offset from start of
> +  * frame. The match is defined by the offset, the
> +  * expected value, and its size.
> +  */
> + uint64_tcustom_frame:1;
> +
> + } proto;

I'd use "bit" here, proto is definitely wrong here since there are fields that 
are not protocols (len, address, custom  ...). Proto is copy-paste from hash 
struct, but bit would be better also there.

pmr_terms.all_bits = 0;
pmr_terms.bit.len   = 1;
pmr_terms.bit.udp_sport = 1;
...


> + uint64_t all_bits;
> +} odp_cls_pmr_supported_t;


Since this is a general list of pmr terms, a better name for the type would be 
odp_cls_pmr_terms_t, which may then be used for multiple purposes (supported, 
not supported, hw offloaded, etc).



> +
> +/**
> + * Classification capabilities
> + * This capability structure defines system level classfication
> capability
> + */
> +typedef struct odp_cls_capability_t {
> + /** PMR terms supported by the classifier
> +  * A mask one bit for each of odp_pmr_term_t

"A bit mask of one bit for each ..."

> +  */
> + odp_cls_pmr_supported_t pmr_terms;

odp_cls_pmr_terms_t supported;


> + /** Maximum number of PMR terms */
> + unsigned max_pmr_terms;

A line feed between every struct field would make this code more readable.

> + /** Number of PMR terms available for use now */
> + unsigned available_pmr_terms;
> + /** Maximum number of CoS supported */
> + unsigned max_cos;
> + /** A Boolean to denote support of PMR range */
> + odp_bool_t pmr_range_supported;
> +} odp_cls_capability_t;
> +
> +/**
>   * class of service packet drop policies
>   */
>  typedef enum {
> @@ -103,6 +173,17 @@ typedef struct odp_cls_cos_param {
>  void odp_cls_cos_param_init(odp_cls_cos_param_t *param);
> 
>  /**
> + * Query classification capabilities
> + *
> + * Outputs classification capabilities on success.
> + *
> + * @param[out]   capability  Classification capability structure for
> output

"Pointer to classification ... "


> + * @retval   0 on success
> + * @retval   <0 on failure
> + */
> +int odp_cls_capability(odp_cls_capability_t *capability);
> +
> +/**
>   * Create 

[lng-odp] [PATCH] example/ipsec: crash with invalid route parameters

2016-04-21 Thread akhil.goyal
From: Akhil Goyal 

If invalid interface is passed in route config parameters,
then the application crashes.
So Matching the entered interface with the parameters configured
in -i parameters.

Signed-off-by: Akhil Goyal 
---
 example/ipsec/odp_ipsec.c|  3 ++-
 example/ipsec/odp_ipsec_fwd_db.c | 15 +--
 example/ipsec/odp_ipsec_fwd_db.h |  6 +-
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 79c6022..74c99b0 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1450,7 +1450,8 @@ static void parse_args(int argc, char *argv[], 
appl_args_t *appl_args)
break;
 
case 'r':
-   rc = create_fwd_db_entry(optarg);
+   rc = create_fwd_db_entry(optarg, appl_args->if_names,
+appl_args->if_count);
break;
 
case 'p':
diff --git a/example/ipsec/odp_ipsec_fwd_db.c b/example/ipsec/odp_ipsec_fwd_db.c
index 7b0bc08..e1f6384 100644
--- a/example/ipsec/odp_ipsec_fwd_db.c
+++ b/example/ipsec/odp_ipsec_fwd_db.c
@@ -39,9 +39,9 @@ void init_fwd_db(void)
memset(fwd_db, 0, sizeof(*fwd_db));
 }
 
-int create_fwd_db_entry(char *input)
+int create_fwd_db_entry(char *input, char **if_names, int if_count)
 {
-   int pos = 0;
+   int pos = 0, i, match = 0;
char *local;
char *str;
char *save;
@@ -76,6 +76,17 @@ int create_fwd_db_entry(char *input)
case 1:
strncpy(entry->oif, token, OIF_LEN - 1);
entry->oif[OIF_LEN - 1] = 0;
+   for (i = 0; i < if_count; i++) {
+   if (!strcmp(if_names[i], entry->oif)) {
+   match = 1;
+   break;
+   }
+   }
+   if (!match) {
+   printf("ERROR: interface name not correct for 
route\n");
+   free(local);
+   return -1;
+   }
break;
case 2:
parse_mac_string(token, entry->dst_mac);
diff --git a/example/ipsec/odp_ipsec_fwd_db.h b/example/ipsec/odp_ipsec_fwd_db.h
index 094253e..748ae04 100644
--- a/example/ipsec/odp_ipsec_fwd_db.h
+++ b/example/ipsec/odp_ipsec_fwd_db.h
@@ -51,9 +51,13 @@ void init_fwd_db(void);
  *
  * @param input  Pointer to string describing route
  *
+ * @param if_names  Array of Name of the interfaces available
+ *
+ * @param if_count  number of interfaces in if_names array
+ *
  * @return 0 if successful else -1
  */
-int create_fwd_db_entry(char *input);
+int create_fwd_db_entry(char *input, char **if_names, int if_count);
 
 /**
  * Scan FWD DB entries and resolve output queue and source MAC address
-- 
2.7.0

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


[lng-odp] [PATCH] validation: lock: tuning the iteration number

2016-04-21 Thread Christophe Milard
fixing: https://bugs.linaro.org/show_bug.cgi?id=2108

The no_lock_functional_test does not really tests the ODP functionality:
Instead, it actually checks that race conditions can be created between
concurrent running threads (by making these threads writing shared
variables without lock, and later noting the value written was changed by
some of the concurrent threads).
This test therefore validates other tests: if this test passes -i.e. if
we do have race condition- then if the following tests suppress these
race conditions by using some synchronization mechanism, these
synchronization mechanisms can be said to be efficient.
If, on the other hand, the no_lock_functional_test "fails", it says
that the following tests are really inconclusive as the effect of the
tested synchronization mechanism is not proven.

When running with valgrind, no_lock_functional_test failed, probably
because the extra execution time introduced by valgrind itself made
the chance to run the critical section of the different threads "at
the same time" much less probable.

The simple solution is to increase the critical section running time
(by largely increasing the number of iterations performed).
The solution taken here is actually to tune the critical section running
time (currentely to ITER_MPLY_FACTOR=3 times the time needed to note
the first race condition).
This means that the test will take longer to run with valgrind,
but will remain short without valgrind.

Signed-off-by: Christophe Milard 
---
 test/validation/lock/lock.c | 71 -
 1 file changed, 64 insertions(+), 7 deletions(-)

diff --git a/test/validation/lock/lock.c b/test/validation/lock/lock.c
index f1f6d69..515bc77 100644
--- a/test/validation/lock/lock.c
+++ b/test/validation/lock/lock.c
@@ -12,7 +12,10 @@
 #include "lock.h"
 
 #define VERBOSE0
-#define MAX_ITERATIONS 1000
+
+#define MIN_ITERATIONS 1000
+#define MAX_ITERATIONS 3
+#define ITER_MPLY_FACTOR   3
 
 #define SLOW_BARRIER_DELAY 400
 #define BASE_DELAY 6
@@ -325,6 +328,12 @@ static void *rwlock_recursive_api_tests(void *arg UNUSED)
return NULL;
 }
 
+/*
+ * Tests that we do have contention between threads when running.
+ * Also adjust the number of iterations to be done (by other tests)
+ * so we have a fair chance to see that the tested synchronizer
+ * does avoid the race condition.
+ */
 static void *no_lock_functional_test(void *arg UNUSED)
 {
global_shared_mem_t *global_mem;
@@ -335,17 +344,36 @@ static void *no_lock_functional_test(void *arg UNUSED)
thread_num = odp_cpu_id() + 1;
per_thread_mem = thread_init();
global_mem = per_thread_mem->global_mem;
-   iterations = global_mem->g_iterations;
+   iterations = 0;
 
odp_barrier_wait(&global_mem->global_barrier);
 
sync_failures = 0;
current_errs = 0;
rs_idx = 0;
-   resync_cnt = iterations / NUM_RESYNC_BARRIERS;
+   resync_cnt = MAX_ITERATIONS / NUM_RESYNC_BARRIERS;
lock_owner_delay = BASE_DELAY;
 
-   for (cnt = 1; cnt <= iterations; cnt++) {
+   /*
+   * Tunning the iteration number:
+   * Here, we search for an iteration number that guarantees to show
+   * race conditions between the odp threads.
+   * Iterations is set to ITER_MPLY_FACTOR * cnt where cnt is when
+   * the threads start to see "errors" (i.e. effect of other threads
+   * running concurrentely without any synchronisation mechanism).
+   * In other words, "iterations" is set to ITER_MPLY_FACTOR times the
+   * minimum loop count necessary to see a need for synchronisation
+   * mechanism.
+   * If, later, these "errors" disappear when running other tests up to
+   * "iterations" with synchro, the effect of the tested synchro mechanism
+   * is likely proven.
+   * If we reach "MAX_ITERATIONS", and "iteration" remains zero,
+   * it means that we cannot see any race condition between the different
+   * running theads (e.g. the OS is not preemptive) and all other tests
+   * being passed won't tell much about the functionality of the
+   * tested synchro mechanism.
+   */
+   for (cnt = 1; cnt <=  MAX_ITERATIONS; cnt++) {
global_mem->global_lock_owner = thread_num;
odp_mb_full();
thread_delay(per_thread_mem, lock_owner_delay);
@@ -353,6 +381,8 @@ static void *no_lock_functional_test(void *arg UNUSED)
if (global_mem->global_lock_owner != thread_num) {
current_errs++;
sync_failures++;
+   if (!iterations)
+   iterations = cnt;
}
 
global_mem->global_lock_owner = 0;
@@ -362,6 +392,8 @@ static void *no_lock_functional_test(void *arg UNUSED)
if (global_mem->global_lock_owner == thread_num) {
  

Re: [lng-odp] [PATCH] test: performance: return when pkt alloc fails

2016-04-21 Thread Krishna Garapati
ping

/Krishna

On 11 April 2016 at 11:11, Balakrishna Garapati <
balakrishna.garap...@linaro.org> wrote:

> Resolving https://bugs.linaro.org/show_bug.cgi?id=2135 by return
> over packet allocation failure.
>
> Signed-off-by: Balakrishna Garapati 
> ---
>  test/performance/odp_crypto.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/test/performance/odp_crypto.c b/test/performance/odp_crypto.c
> index fe1c7b4..ca461e5 100644
> --- a/test/performance/odp_crypto.c
> +++ b/test/performance/odp_crypto.c
> @@ -550,6 +550,7 @@ run_measure_one(crypto_args_t *cargs,
> if (pkt == ODP_PACKET_INVALID) {
> app_err("failed to allocate
> buffer\n");
> rc = -1;
> +   return rc;
> } else {
> void *mem = odp_packet_data(pkt);
>
> --
> 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 PATCH v5 00/11] add pktin timestamping support

2016-04-21 Thread Maxim Uvarov

Merged,
Maxim.

On 04/21/16 10:59, Matias Elo wrote:

This patch set adds initial support for packet input timestamping using odp
global time. Set adds also related validation tests.

Implemented functions:
- odp_packet_ts()
- odp_packet_ts_set()
- odp_packet_has_ts()
- odp_packet_has_ts_clr()
- odp_pktin_ts_res()
- odp_pktin_ts_from_ns()
- odp_pktio_config()

V5:
+ Fixed wrong enum type usage in pktio_test_pktin_ts() (Maxim)

V4:
+ Rebase
+ Added Review-and-tested-by Bill

V3:
+ Rebase

V2:
+ Check magic number in pktio_test_pktin_ts() validation test


Matias Elo (11):
   linux-generic: packet: move flow_hash present flag to correct location
   linux-generic: packet: implement timestamp support
   linux-generic: pktio: implement odp_pktin_ts_res()
   linux-generic: pktio: implement odp_pktin_ts_from_ns()
   linux-generic: pktio: implement odp_pktio_config()
   validation: pktio: add helper function for creating test packets
   validation: pktio: add pktio config test
   validation: pktio: add pktin timestamping test
   linux-generic: packet: add inline helper function for setting packet
 timestamp
   linux-generic: pktio: add pktin timestamp argument to
 _odp_packet_cls_enq()
   linux-generic: pktio: add pktin timestamping support

  .../linux-generic/include/odp_packet_internal.h|  13 +-
  .../linux-generic/include/odp_packet_io_internal.h |   8 +-
  platform/linux-generic/odp_packet.c|  17 +-
  platform/linux-generic/odp_packet_flags.c  |  18 +-
  platform/linux-generic/odp_packet_io.c |  61 -
  platform/linux-generic/pktio/dpdk.c|  58 +++--
  platform/linux-generic/pktio/ipc.c |   5 +-
  platform/linux-generic/pktio/loop.c|  30 ++-
  platform/linux-generic/pktio/netmap.c  |  86 +--
  platform/linux-generic/pktio/pcap.c|  31 ++-
  platform/linux-generic/pktio/pktio_common.c|  18 +-
  platform/linux-generic/pktio/socket.c  |  39 ++-
  platform/linux-generic/pktio/socket_mmap.c |  34 ++-
  platform/linux-generic/pktio/tap.c |  42 +++-
  test/validation/packet/packet.c|   8 +
  test/validation/pktio/pktio.c  | 280 ++---
  test/validation/pktio/pktio.h  |   3 +
  17 files changed, 591 insertions(+), 160 deletions(-)



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


Re: [lng-odp] [API-NEXT PATCH v5 00/11] add pktin timestamping support

2016-04-21 Thread Bill Fischofer
This should retain my Reviewed-and-tested-by from v4

On Thu, Apr 21, 2016 at 2:59 AM, Matias Elo  wrote:

> This patch set adds initial support for packet input timestamping using odp
> global time. Set adds also related validation tests.
>
> Implemented functions:
> - odp_packet_ts()
> - odp_packet_ts_set()
> - odp_packet_has_ts()
> - odp_packet_has_ts_clr()
> - odp_pktin_ts_res()
> - odp_pktin_ts_from_ns()
> - odp_pktio_config()
>
> V5:
> + Fixed wrong enum type usage in pktio_test_pktin_ts() (Maxim)
>
> V4:
> + Rebase
> + Added Review-and-tested-by Bill
>
> V3:
> + Rebase
>
> V2:
> + Check magic number in pktio_test_pktin_ts() validation test
>
>
> Matias Elo (11):
>   linux-generic: packet: move flow_hash present flag to correct location
>   linux-generic: packet: implement timestamp support
>   linux-generic: pktio: implement odp_pktin_ts_res()
>   linux-generic: pktio: implement odp_pktin_ts_from_ns()
>   linux-generic: pktio: implement odp_pktio_config()
>   validation: pktio: add helper function for creating test packets
>   validation: pktio: add pktio config test
>   validation: pktio: add pktin timestamping test
>   linux-generic: packet: add inline helper function for setting packet
> timestamp
>   linux-generic: pktio: add pktin timestamp argument to
> _odp_packet_cls_enq()
>   linux-generic: pktio: add pktin timestamping support
>
>  .../linux-generic/include/odp_packet_internal.h|  13 +-
>  .../linux-generic/include/odp_packet_io_internal.h |   8 +-
>  platform/linux-generic/odp_packet.c|  17 +-
>  platform/linux-generic/odp_packet_flags.c  |  18 +-
>  platform/linux-generic/odp_packet_io.c |  61 -
>  platform/linux-generic/pktio/dpdk.c|  58 +++--
>  platform/linux-generic/pktio/ipc.c |   5 +-
>  platform/linux-generic/pktio/loop.c|  30 ++-
>  platform/linux-generic/pktio/netmap.c  |  86 +--
>  platform/linux-generic/pktio/pcap.c|  31 ++-
>  platform/linux-generic/pktio/pktio_common.c|  18 +-
>  platform/linux-generic/pktio/socket.c  |  39 ++-
>  platform/linux-generic/pktio/socket_mmap.c |  34 ++-
>  platform/linux-generic/pktio/tap.c |  42 +++-
>  test/validation/packet/packet.c|   8 +
>  test/validation/pktio/pktio.c  | 280
> ++---
>  test/validation/pktio/pktio.h  |   3 +
>  17 files changed, 591 insertions(+), 160 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] [API-NEXT PATCH v5 00/11] add pktin timestamping support

2016-04-21 Thread Maxim Uvarov

On 04/21/16 16:01, Bill Fischofer wrote:

This should retain my Reviewed-and-tested-by from v4


I added.

Maxim.



On Thu, Apr 21, 2016 at 2:59 AM, Matias Elo > wrote:


This patch set adds initial support for packet input timestamping
using odp
global time. Set adds also related validation tests.

Implemented functions:
- odp_packet_ts()
- odp_packet_ts_set()
- odp_packet_has_ts()
- odp_packet_has_ts_clr()
- odp_pktin_ts_res()
- odp_pktin_ts_from_ns()
- odp_pktio_config()

V5:
+ Fixed wrong enum type usage in pktio_test_pktin_ts() (Maxim)

V4:
+ Rebase
+ Added Review-and-tested-by Bill

V3:
+ Rebase

V2:
+ Check magic number in pktio_test_pktin_ts() validation test


Matias Elo (11):
  linux-generic: packet: move flow_hash present flag to correct
location
  linux-generic: packet: implement timestamp support
  linux-generic: pktio: implement odp_pktin_ts_res()
  linux-generic: pktio: implement odp_pktin_ts_from_ns()
  linux-generic: pktio: implement odp_pktio_config()
  validation: pktio: add helper function for creating test packets
  validation: pktio: add pktio config test
  validation: pktio: add pktin timestamping test
  linux-generic: packet: add inline helper function for setting packet
timestamp
  linux-generic: pktio: add pktin timestamp argument to
_odp_packet_cls_enq()
  linux-generic: pktio: add pktin timestamping support

 .../linux-generic/include/odp_packet_internal.h| 13 +-
 .../linux-generic/include/odp_packet_io_internal.h |  8 +-
 platform/linux-generic/odp_packet.c| 17 +-
 platform/linux-generic/odp_packet_flags.c  | 18 +-
 platform/linux-generic/odp_packet_io.c | 61 -
 platform/linux-generic/pktio/dpdk.c| 58 +++--
 platform/linux-generic/pktio/ipc.c |  5 +-
 platform/linux-generic/pktio/loop.c| 30 ++-
 platform/linux-generic/pktio/netmap.c  | 86 +--
 platform/linux-generic/pktio/pcap.c| 31 ++-
 platform/linux-generic/pktio/pktio_common.c| 18 +-
 platform/linux-generic/pktio/socket.c  | 39 ++-
 platform/linux-generic/pktio/socket_mmap.c | 34 ++-
 platform/linux-generic/pktio/tap.c | 42 +++-
 test/validation/packet/packet.c|  8 +
 test/validation/pktio/pktio.c  | 280
++---
 test/validation/pktio/pktio.h  |  3 +
 17 files changed, 591 insertions(+), 160 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


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


Re: [lng-odp] [API-NEXT PATCH] api: crypto: add crypto capability

2016-04-21 Thread Maxim Uvarov

Merged,
Maxim.

On 04/20/16 15:20, Krishna Garapati wrote:
ping. Maxim, are you still waiting for any response for the comments 
on this patch other than petri's explanation provided yesterday ?


/Krishna

On 18 April 2016 at 14:52, Maxim Uvarov > wrote:


On 04/15/16 12:36, Petri Savolainen wrote:

Added crypto capability structure and cipher/authentication
algorithm bit masks needed by the structure.

Signed-off-by: Petri Savolainen mailto:petri.savolai...@nokia.com>>
---
  include/odp/api/spec/crypto.h | 88
+++
  1 file changed, 88 insertions(+)

diff --git a/include/odp/api/spec/crypto.h
b/include/odp/api/spec/crypto.h
index 7c6f9bc..ef106f6 100644
--- a/include/odp/api/spec/crypto.h
+++ b/include/odp/api/spec/crypto.h
@@ -89,6 +89,61 @@ typedef enum {
  } odp_auth_alg_t;
/**
+ * Cipher algorithms in a bit field structure
+ */
+typedef union odp_crypto_cipher_algos_t {
+   /** Cipher algorithms */
+   struct {
+   /** ODP_CIPHER_ALG_NULL */
+   uint32_t null   : 1;


Should NULL be here? Or just all fields need to be zero?

Also variable name null might be not really good name for C, but
we already use it.

Maxim.


+
+   /** ODP_CIPHER_ALG_DES */
+   uint32_t des: 1;
+
+   /** ODP_CIPHER_ALG_3DES_CBC */
+   uint32_t trides_cbc : 1;
+
+   /** ODP_CIPHER_ALG_AES128_CBC */
+   uint32_t aes128_cbc : 1;
+
+   /** ODP_CIPHER_ALG_AES128_GCM */
+   uint32_t aes128_gcm : 1;
+   } bit;
+
+   /** All bits of the bit field structure
+ *
+ * This field can be used to set/clear all flags, or
bitwise
+ * operations over the entire structure. */
+   uint32_t all_bits;
+} odp_crypto_cipher_algos_t;
+
+/**
+ * Authentication algorithms in a bit field structure
+ */
+typedef union odp_crypto_auth_algos_t {
+   /** Authentication algorithms */
+   struct {
+   /** ODP_AUTH_ALG_NULL */
+   uint32_t null   : 1;
+
+   /** ODP_AUTH_ALG_MD5_96 */
+   uint32_t md5_96 : 1;
+
+   /** ODP_AUTH_ALG_SHA256_128 */
+   uint32_t sha256_128 : 1;
+
+   /** ODP_AUTH_ALG_AES128_GCM */
+   uint32_t aes128_gcm : 1;
+   } bit;
+
+   /** All bits of the bit field structure
+ *
+ * This field can be used to set/clear all flags, or
bitwise
+ * operations over the entire structure. */
+   uint32_t all_bits;
+} odp_crypto_auth_algos_t;
+
+/**
   * Crypto API key structure
   */
  typedef struct odp_crypto_key {
@@ -254,6 +309,39 @@ typedef struct odp_crypto_op_result {
  } odp_crypto_op_result_t;
/**
+ * Crypto capabilities
+ */
+typedef struct odp_crypto_capability_t {
+   /** Maximum number of crypto sessions */
+   uint32_t max_sessions;
+
+   /** Supported chipher algorithms */
+   odp_crypto_cipher_algos_t chiphers;
+
+   /** Chipher algorithms implemented with HW offload */
+   odp_crypto_cipher_algos_t hw_chiphers;
+
+   /** Supported authentication algorithms */
+   odp_crypto_auth_algos_t   auths;
+
+   /** Authentication algorithms implemented with HW
offload */
+   odp_crypto_auth_algos_t   hw_auths;
+
+} odp_crypto_capability_t;
+
+/**
+ * Query crypto capabilities
+ *
+ * Outputs crypto capabilities on success.
+ *
+ * @param[out] capa   Pointer to capability structure for output
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_crypto_capability(odp_crypto_capability_t *capa);
+
+/**
   * Crypto session creation (synchronous)
   *
   * @param paramsSession parameters


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




___
lng-odp mailing list
lng-odp@list

Re: [lng-odp] [PATCH] test: performance: return when pkt alloc fails

2016-04-21 Thread Maxim Uvarov

That will go after 1.9 release.

Maxim.

On 04/21/16 15:51, Krishna Garapati wrote:

ping

/Krishna

On 11 April 2016 at 11:11, Balakrishna Garapati 
> wrote:


Resolving https://bugs.linaro.org/show_bug.cgi?id=2135 by return
over packet allocation failure.

Signed-off-by: Balakrishna Garapati
mailto:balakrishna.garap...@linaro.org>>
---
 test/performance/odp_crypto.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/performance/odp_crypto.c
b/test/performance/odp_crypto.c
index fe1c7b4..ca461e5 100644
--- a/test/performance/odp_crypto.c
+++ b/test/performance/odp_crypto.c
@@ -550,6 +550,7 @@ run_measure_one(crypto_args_t *cargs,
if (pkt == ODP_PACKET_INVALID) {
app_err("failed to
allocate buffer\n");
rc = -1;
+   return rc;
} else {
void *mem =
odp_packet_data(pkt);

--
1.9.1




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


Re: [lng-odp] building from a tar source

2016-04-21 Thread Maxim Uvarov

Hello Leonard,

1. your email when to spam directory and probably did not go to ML. 
Usually the cause is missing DKIM email signature.


2. complete build is hot topic. There are were bunch of patches to fix 
it.  I think finally everything will be fixed in 1.9 which

we release very soon.

Best regards,
Maxim.

On 04/19/16 19:00, Leonard Bush wrote:

Hi,

Changes went into the ODP release around v1.4 to use the git 
information to set the
version information for the build via scripts/git_hash.sh (rather than 
scripts/odp_version.sh).


With the latest scripts/git_hash.sh, I cannot build from a tar source.
This is interesting, since there was a specific fix and release notes 
in v.1.3 to allow that.


What is the current positioning of building ODP from a tar source?

Thanks, Leonard Bush.
___
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] [GIT PULL ODPv2] running things in process mode

2016-04-21 Thread Christophe Milard
Since v1:
-variable declaration gathered in function 's head (Petri)
-linux prefix removed from helper's types and function names (Mike, Christophe)

Hi,

This patch series adds the ability to run tests/ exemples / perf-test
in "process mode" (i.e letting OPD threads being linux processes)
It it hence tackling ODP-171.

This is achieved in 2 main steps:

A]
The 2 pairs of helper functions:
odph_linux_pthread_create(), odph_linux_pthread_join()
and
odph_linux_process_fork_n(), odph_linux_process_wait_n()
are replaced by:
odph_linux_odpthreads_create() and odph_linux_odpthreads_join()
The latter's callers are unaware of the actual implementation of the ODP
thread (making test truly platform agnostic).
The helper functions decide at run time whether an odp thread is to be
a linux process or pthread based on the command line argument.

B] each test/example now calls a new helper function,
odph_linux_parse_options(), so that the helper can get its own arguments
out of the command line.
Currentely supported args are: --odph_proc, --odph_thread.
Defaults assumes thread. specifying both options runs in mixed mode.

The changed are first done on the shmem tests, and thereafter propagated
to other helper users.
Note that this patch series enable the option but does not affect
make check at this time: make check still calls the tests with no options
which default to thread mode.

This patch series nicely splits it two groups (you can split your review
there):
1) up to "validation: pktio: adding command line argument parsing", the new
helper functions are introduced, and used in the validation tests.
2) from "helper: adding a function to merge getopt parameters" the ability
to parse command line arguments in subset in added and applied to
the example and performance tests.

Hope this makes sence for you too!




The following changes since commit 69d0a401c92807852b503418612812242ba9f8f2:

  configure: default ODP_DEBUG to false (2016-04-20 23:00:59 +0300)

are available in the git repository at:

  https://git.linaro.org/people/christophe.milard/odp.git 
test_in_process_mode_v2

for you to fetch changes up to 53a81edc1c77dc7aac08d97cd28e8cc5f7d9d842:

  helper: removing dead code (2016-04-21 17:26:26 +0200)


Christophe Milard (56):
  helpers: adding command line argument parsing
  validation: common: adding command line argument parsing
  validation: shmem: adding command line argument parsing
  helpers: linux: creating common entry for process and thread
  helpers: linux: creating functions to handle odpthreads
  helper: test: adding odpthread functions tests
  validation: using implementation agnostic function for ODP threads
  validation: traffic_mngr: adding command line argument parsing
  validation: timer: adding command line argument parsing
  validation: time: adding command line argument parsing
  validation: thread: adding command line argument parsing
  validation: system: adding command line argument parsing
  validation: std_clib: adding command line argument parsing
  validation: scheduler: adding command line argument parsing
  validation: random: adding command line argument parsing
  validation: queue: adding command line argument parsing
  validation: pool: adding command line argument parsing
  validation: packet: adding command line argument parsing
  validation: lock: adding command line argument parsing
  validation: init: adding command line argument parsing
  validation: hash: adding command line argument parsing
  validation: errno: adding command line argument parsing
  validation: crypto: adding command line argument parsing
  validation: cpumask: adding command line argument parsing
  validation: config: adding command line argument parsing
  validation: classification: adding command line argument parsing
  validation: buffer: adding command line argument parsing
  validation: barrier: adding command line argument parsing
  validation: atomic: adding command line argument parsing
  validation: pktio: adding command line argument parsing
  helper: adding a function to merge getopt parameters
  helper: parsing the complete set of options
  performance: odp_scheduling: proc mode done by helper
  performance: odp_pktio_perf: using agnostic function for ODP threads
  performance: odp_pktio_perf: adding helper cmd line parsing
  performance: odp_l2fwd: using agnostic function for ODP threads
  performance: odp_l2fwd: adding helper cmd line parsing
  performance: crypto: using agnostic function for ODP threads
  performance: crypto: adding helper cmd line parsing
  example: classifier: using agnostic function for ODP threads
  example: classifier: adding helper cmd line parsing
  example: generator: using agnostic function for ODP threads
  example: generator:

Re: [lng-odp] [API-NEXT PATCH v2 4/4] api: packet: update add_data and rem_data definition

2016-04-21 Thread Maxim Uvarov

Merged,
Maxim.

On 04/20/16 20:58, Bill Fischofer wrote:

For this part only:

On Wed, Apr 20, 2016 at 10:12 AM, Petri Savolainen 
mailto:petri.savolai...@nokia.com>> wrote:


Updated odp_packet_add_data and _rem_data definitions to match
other calls that may or may not move data. The new packet
handle is output through packet handle pointer parameter and
return codes indicate if old data was moved or not, or if
the operation failed.

Signed-off-by: Petri Savolainen mailto:petri.savolai...@nokia.com>>


Reviewed-by: Bill Fischofer >


---
 include/odp/api/spec/packet.h   | 71
-
 platform/linux-generic/odp_packet.c | 68
++-
 test/validation/packet/packet.c | 15 
 3 files changed, 91 insertions(+), 63 deletions(-)

diff --git a/include/odp/api/spec/packet.h
b/include/odp/api/spec/packet.h
index 8cdcc0f..0dbc8d3 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -585,40 +585,61 @@ int odp_packet_trunc_tail(odp_packet_t *pkt,
uint32_t len, void **tail_ptr,
 /**
  * Add data into an offset
  *
- * Increases packet data length by adding new data area into the
specified
- * offset. The operation returns a new packet handle on success.
It may modify
- * packet segmentation and move data. Handles and pointers must
be updated
- * after the operation. User is responsible to update packet
metadata offsets
- * when needed. The packet is not modified on an error.
+ * Increase packet data length by adding new data area into the
specified
+ * offset. The operation may modify packet segmentation and move
data.
  *
- * @param pkt Packet handle
- * @param offset  Byte offset into the packet
- * @param len Number of bytes to add into the offset
+ * A successful operation overwrites the packet handle with a new
handle, which
+ * application must use as the reference to the packet instead of
the old
+ * handle. Depending on the implementation, the old and new
handles may be
+ * equal.
  *
- * @return New packet handle
- * @retval ODP_PACKET_INVALID on failure
+ * The operation return value indicates if any packet data or
metadata (e.g.
+ * user_area) were moved in memory during the operation. If some
memory areas
+ * were moved, application must use new packet/segment handles to
update
+ * data pointers. Otherwise, all old pointers remain valid.
+ *
+ * User is responsible to update packet metadata offsets when
needed. Packet
+ * is not modified if operation fails.
+ *
+ * @param[in, out] pkt  Pointer to packet handle. A successful
operation outputs
+ *  the new packet handle.
+ * @param offsetByte offset into the packet
+ * @param len   Number of bytes to add into the offset
+ *
+ * @retval 0   Operation successful, old pointers remain valid
+ * @retval >0  Operation successful, old pointers need to be updated
+ * @retval <0  Operation failed
  */
-odp_packet_t odp_packet_add_data(odp_packet_t pkt, uint32_t offset,
-uint32_t len);
+int odp_packet_add_data(odp_packet_t *pkt, uint32_t offset,
uint32_t len);

 /**
  * Remove data from an offset
  *
- * Decreases packet data length by removing data from the
specified offset.
- * The operation returns a new packet handle on success, and may
modify
- * packet segmentation and move data. Handles and pointers must
be updated
- * after the operation. User is responsible to update packet
metadata offsets
- * when needed. The packet is not modified on an error.
+ * Decrease packet data length by removing data area from the
specified
+ * offset. The operation may modify packet segmentation and move
data.
  *
- * @param pkt Packet handle
- * @param offset  Byte offset into the packet
- * @param len Number of bytes to remove from the offset
+ * A successful operation overwrites the packet handle with a new
handle, which
+ * application must use as the reference to the packet instead of
the old
+ * handle. Depending on the implementation, the old and new
handles may be
+ * equal.
  *
- * @return New packet handle
- * @retval ODP_PACKET_INVALID on failure
- */
-odp_packet_t odp_packet_rem_data(odp_packet_t pkt, uint32_t offset,
-uint32_t len);
+ * The operation return value indicates if any packet data or
metadata (e.g.
+ * user_area) were moved in memory during the operation. If some
memory areas
+ * were moved, application must use new packet/segment handles to
update
+ * da

Re: [lng-odp] [API-NEXT PATCH v2 1/4] api: packet: add packet concat and split

2016-04-21 Thread Maxim Uvarov

Merged,
Maxim.

On 04/20/16 20:29, Bill Fischofer wrote:

For this part only.

On Wed, Apr 20, 2016 at 10:12 AM, Petri Savolainen 
mailto:petri.savolai...@nokia.com>> wrote:


Added odp_packet_concat() and _split(). Two packets may be
concatenated one after another, and split at any offset. This
suites the common use cases of packet reassembly and
fragmentation. Reassembly is done on complete packets, while
fragmentation may be needed on any offset.

Signed-off-by: Petri Savolainen mailto:petri.savolai...@nokia.com>>


Reviewed-by: Bill Fischofer >


---
 include/odp/api/spec/packet.h | 70
+++
 1 file changed, 70 insertions(+)

diff --git a/include/odp/api/spec/packet.h
b/include/odp/api/spec/packet.h
index 094e846..b356f0f 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -715,6 +715,76 @@ void *odp_packet_seg_data(odp_packet_t pkt,
odp_packet_seg_t seg);
  */
 uint32_t odp_packet_seg_data_len(odp_packet_t pkt,
odp_packet_seg_t seg);

+/**
+ * Concatenate two packets
+ *
+ * Concatenate all packet data from 'src' packet into tail of
'dst' packet.
+ * Operation preserves 'dst' packet metadata in the resulting packet,
+ * while 'src' packet handle, metadata and old segment handles
for both packets
+ * become invalid.
+ *
+ * A successful operation overwrites 'dst' packet handle with a
new handle,
+ * which application must use as the reference to the resulting
packet
+ * instead of the old handle. Depending on the implementation,
the old and new
+ * handles may be equal.
+ *
+ * The operation return value indicates if any packet data or
metadata (e.g.
+ * user_area) were moved in memory during the operation. If some
memory areas
+ * were moved, application must use new packet/segment handles to
update
+ * data pointers. Otherwise, all old pointers remain valid.
+ *
+ * The resulting packet is always allocated from the same pool as
+ * the destination packet. The source packet may have been
allocate from
+ * any pool.
+ *
+ * On failure, both handles remain valid and packets are not
modified.
+ *
+ * @param[in, out] dst   Pointer to destination packet handle. A
successful
+ *   operation outputs the new packet handle.
+ * @param srcSource packet handle
+ *
+ * @retval 0   Operation successful, old pointers remain valid
+ * @retval >0  Operation successful, old pointers need to be updated
+ * @retval <0  Operation failed
+ */
+int odp_packet_concat(odp_packet_t *dst, odp_packet_t src);
+
+/**
+ * Split packet into two packets
+ *
+ * Split the packet after 'len' bytes. The first 'len' bytes of
data and
+ * metadata remain in the head packet. A successful operation
outputs a handle
+ * for the tail packet and overwrites 'pkt' packet handle with a new
+ * handle, which application must use as the reference to the
resulting head
+ * packet. Depending on the implementation, the old and new 'pkt'
handles
+ * may be equal.
+ *
+ * The operation return value indicates if any packet data or
metadata (e.g.
+ * user_area) were moved in memory during the operation. If some
memory areas
+ * were moved, application must use new packet/segment handles to
update
+ * data pointers. Otherwise, all old pointers remain valid.
+ *
+ * The tail packet holds the rest of the data (odp_packet_len() -
'len' bytes).
+ * The packet is allocated from the same pool as the original
packet and
+ * metadata is initialized with default values.
+ *
+ * For performance reasons (zero copy), the head packet may have
zero tailroom
+ * and the tail packet may have zero headroom length after the
operation.
+ * Both packets may be extended normally.
+ *
+ * The original packet is not modified on failure.
+ *
+ * @param[in, out] pkt   Pointer to packet handle. A successful
operation
+ *   outputs a new packet handle for the head
packet.
+ * @param lenData length remaining in the head packet
+ * @param tail   Pointer to output the tail packet handle
+ *
+ * @retval 0   Operation successful, old pointers remain valid
+ * @retval >0  Operation successful, old pointers need to be updated
+ * @retval <0  Operation failed
+ */
+int odp_packet_split(odp_packet_t *pkt, uint32_t len,
odp_packet_t *tail);
+
 /*
  *
  * Copy
--
2.7.2

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

Re: [lng-odp] shmem in process mode.

2016-04-21 Thread Gary S. Robertson



On 04/21/2016 02:03 AM, Christophe Milard wrote:

Hi,
Indeed, if the main ODP instantiation process performs a huge virtual 
space reservation, e.g something like:


shmem_base = mmap(NULL, SHM_TOT_SZ, PROT_NONE, MAP_ANONYMOUS, 
FLAG_NO_RESERVE);

madvise(shmem_base, SHM_TOT_SZ, MADV_DONTNEED)

where SHM_TOT is the grand max of the sum of all possible shmem areas, 
then this area will be mapped in all processes and threads descendant 
from the odp instantiation process, ie all odpthread if def 1 is accepted.
This only holds true until the forked child process replaces its memory 
space with a different executable image than that of its parent - eg. 
via exec*().  At that time the memory space of the child is remapped to 
the replacement image and any shared memory mapping inherited from the 
parent is subject to being remapped.  I am not aware of any guarantees 
that shared memory mapped by the parent with a 'MAP_FIXED' attribute 
will be remapped at the same address in the new image.  I am not certain 
that such a guarantee is even possible given the unknown and 
unconstrained memory footprint of the replacement image.


I believe that to be safe and portable we cannot rely upon shared memory 
or memory mapped files to be consistently addressable at the same 
location across processes - descendant or otherwise.  Without a 
guarantee of such consistency in the POSIX specifications, even if it 
works today it may be broken by future code changes in the kernel or the 
loader.


Regarding the performance aspect, other than additional overhead in 
initial setup and teardown/cleanup I don't see a performance difference 
between base addresses obtained from a "global" shared data structure 
and a process-local one.  Since the process-local addess table avoids 
the risky behaviour of relying on consistent mapping across processes it 
seems to me the obvious way to go.


If both the "shared global" object reference/naming table and 
process-local object mapping tables are "indexed" by a platform-agnostic 
handle for each shared memory object then I believe that performance of 
access to the shared memory objects will be a "wash".  This would be the 
most portable and "best practice" implementation - which I believe is 
also an important consideration for a reference platform.


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


Re: [lng-odp] [PATCH v2] linux-generic: classification: fix error checking _odp_packet_classifier()

2016-04-21 Thread Zoltan Kiss

Maxim, what's the planned time to apply this?

On 15/04/16 06:31, Bala Manoharan wrote:

Reviewed-by: Balasubramanian Manoharan mailto:bala.manoha...@linaro.org>>

On 13 April 2016 at 19:50, Zoltan Kiss mailto:zoltan.k...@linaro.org>> wrote:

In case of error the 'pkt' should be released by the calling function.
Currently loopback gives it back to the receiver and report it as
success
in the stats.

Signed-off-by: Zoltan Kiss mailto:zoltan.k...@linaro.org>>
---

v2: handle release in caller instead, and adjust stats.

  platform/linux-generic/odp_classification.c | 10 +++---
  platform/linux-generic/pktio/loop.c |  9 ++---
  2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/platform/linux-generic/odp_classification.c
b/platform/linux-generic/odp_classification.c
index 8522023..3a18a78 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -745,21 +745,17 @@ int _odp_packet_classifier(pktio_entry_t
*entry, odp_packet_t pkt)
 if (cos == NULL)
 return -1;

-   if (cos->s.pool == NULL) {
-   odp_packet_free(pkt);
+   if (cos->s.pool == NULL)
 return -1;
-   }

-   if (cos->s.queue == NULL) {
-   odp_packet_free(pkt);
+   if (cos->s.queue == NULL)
 return -1;
-   }

 if (odp_packet_pool(pkt) != cos->s.pool->s.pool_hdl) {
 new_pkt = odp_packet_copy(pkt,
cos->s.pool->s.pool_hdl);
-   odp_packet_free(pkt);
 if (new_pkt == ODP_PACKET_INVALID)
 return -1;
+   odp_packet_free(pkt);
 } else {
 new_pkt = pkt;
 }
diff --git a/platform/linux-generic/pktio/loop.c
b/platform/linux-generic/pktio/loop.c
index 0ea6d0e..f6a8c1d 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -70,10 +70,13 @@ static int loopback_recv(pktio_entry_t
*pktio_entry, odp_packet_t pkts[],
 pkt_hdr = odp_packet_hdr(pkt);
 packet_parse_reset(pkt_hdr);
 packet_parse_l2(pkt_hdr);
-   if (0 > _odp_packet_classifier(pktio_entry,
pkt)) {
-   pkts[j++] = pkt;
+   if (!_odp_packet_classifier(pktio_entry, pkt)) {
 pktio_entry->s.stats.in_octets +=
-   odp_packet_len(pkts[i]);
+   odp_packet_len(pkt);
+   } else {
+   pktio_entry->s.stats.in_errors +=
+   odp_packet_len(pkt);
+   odp_packet_free(pkt);
 }
 }
 nbr = j;
--
1.9.1



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


[lng-odp] [API-NEXT PATCH] api: queue: remove const qualifier of passed down event array

2016-04-21 Thread Zoltan Kiss
As the description says, normally this function consumes the events, which
means there is no point to expect the array to stay intact. Other functions
like odp_pktout_send() doesn't do that as well.

Signed-off-by: Zoltan Kiss 
---

diff --git a/include/odp/api/spec/queue.h b/include/odp/api/spec/queue.h
index 7626ca7..c420fde 100644
--- a/include/odp/api/spec/queue.h
+++ b/include/odp/api/spec/queue.h
@@ -237,7 +237,7 @@ int odp_queue_enq(odp_queue_t queue, odp_event_t ev);
  * @return Number of events actually enqueued (0 ... num)
  * @retval <0 on failure
  */
-int odp_queue_enq_multi(odp_queue_t queue, const odp_event_t events[], int 
num);
+int odp_queue_enq_multi(odp_queue_t queue, odp_event_t events[], int num);
 
 /**
  * Queue dequeue
diff --git a/platform/linux-generic/odp_queue.c 
b/platform/linux-generic/odp_queue.c
index 342ffa2..29faa29 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -647,7 +647,7 @@ int queue_enq_multi(queue_entry_t *queue, odp_buffer_hdr_t 
*buf_hdr[],
return num; /* All events enqueued */
 }
 
-int odp_queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int num)
+int odp_queue_enq_multi(odp_queue_t handle, odp_event_t ev[], int num)
 {
odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX];
queue_entry_t *queue;
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v2] linux-generic: classification: fix error checking _odp_packet_classifier()

2016-04-21 Thread Maxim Uvarov

On 04/21/16 21:08, Zoltan Kiss wrote:

Maxim, what's the planned time to apply this?


just after current 1.9 tag. (tomorrow)

Maxim.


On 15/04/16 06:31, Bala Manoharan wrote:

Reviewed-by: Balasubramanian Manoharan mailto:bala.manoha...@linaro.org>>

On 13 April 2016 at 19:50, Zoltan Kiss mailto:zoltan.k...@linaro.org>> wrote:

In case of error the 'pkt' should be released by the calling 
function.

Currently loopback gives it back to the receiver and report it as
success
in the stats.

Signed-off-by: Zoltan Kiss mailto:zoltan.k...@linaro.org>>
---

v2: handle release in caller instead, and adjust stats.

  platform/linux-generic/odp_classification.c | 10 +++---
  platform/linux-generic/pktio/loop.c |  9 ++---
  2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/platform/linux-generic/odp_classification.c
b/platform/linux-generic/odp_classification.c
index 8522023..3a18a78 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -745,21 +745,17 @@ int _odp_packet_classifier(pktio_entry_t
*entry, odp_packet_t pkt)
 if (cos == NULL)
 return -1;

-   if (cos->s.pool == NULL) {
-   odp_packet_free(pkt);
+   if (cos->s.pool == NULL)
 return -1;
-   }

-   if (cos->s.queue == NULL) {
-   odp_packet_free(pkt);
+   if (cos->s.queue == NULL)
 return -1;
-   }

 if (odp_packet_pool(pkt) != cos->s.pool->s.pool_hdl) {
 new_pkt = odp_packet_copy(pkt,
cos->s.pool->s.pool_hdl);
-   odp_packet_free(pkt);
 if (new_pkt == ODP_PACKET_INVALID)
 return -1;
+   odp_packet_free(pkt);
 } else {
 new_pkt = pkt;
 }
diff --git a/platform/linux-generic/pktio/loop.c
b/platform/linux-generic/pktio/loop.c
index 0ea6d0e..f6a8c1d 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -70,10 +70,13 @@ static int loopback_recv(pktio_entry_t
*pktio_entry, odp_packet_t pkts[],
 pkt_hdr = odp_packet_hdr(pkt);
 packet_parse_reset(pkt_hdr);
 packet_parse_l2(pkt_hdr);
-   if (0 > _odp_packet_classifier(pktio_entry,
pkt)) {
-   pkts[j++] = pkt;
+   if (!_odp_packet_classifier(pktio_entry, 
pkt)) {

pktio_entry->s.stats.in_octets +=
- odp_packet_len(pkts[i]);
+   odp_packet_len(pkt);
+   } else {
+ pktio_entry->s.stats.in_errors +=
+   odp_packet_len(pkt);
+   odp_packet_free(pkt);
 }
 }
 nbr = j;
--
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 PATCH] api: queue: remove const qualifier of passed down event array

2016-04-21 Thread Bill Fischofer
On Thu, Apr 21, 2016 at 1:31 PM, Zoltan Kiss  wrote:

> As the description says, normally this function consumes the events, which
> means there is no point to expect the array to stay intact. Other functions
> like odp_pktout_send() doesn't do that as well.
>
> Signed-off-by: Zoltan Kiss 
>

Reviewed-by: Bill Fischofer 


> ---
>
> diff --git a/include/odp/api/spec/queue.h b/include/odp/api/spec/queue.h
> index 7626ca7..c420fde 100644
> --- a/include/odp/api/spec/queue.h
> +++ b/include/odp/api/spec/queue.h
> @@ -237,7 +237,7 @@ int odp_queue_enq(odp_queue_t queue, odp_event_t ev);
>   * @return Number of events actually enqueued (0 ... num)
>   * @retval <0 on failure
>   */
> -int odp_queue_enq_multi(odp_queue_t queue, const odp_event_t events[],
> int num);
> +int odp_queue_enq_multi(odp_queue_t queue, odp_event_t events[], int num);
>
>  /**
>   * Queue dequeue
> diff --git a/platform/linux-generic/odp_queue.c
> b/platform/linux-generic/odp_queue.c
> index 342ffa2..29faa29 100644
> --- a/platform/linux-generic/odp_queue.c
> +++ b/platform/linux-generic/odp_queue.c
> @@ -647,7 +647,7 @@ int queue_enq_multi(queue_entry_t *queue,
> odp_buffer_hdr_t *buf_hdr[],
> return num; /* All events enqueued */
>  }
>
> -int odp_queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int
> num)
> +int odp_queue_enq_multi(odp_queue_t handle, odp_event_t ev[], int num)
>  {
> odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX];
> queue_entry_t *queue;
>
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH] validation: pktio: remove octet check from stats test

2016-04-21 Thread Zoltan Kiss



On 15/04/16 14:45, Maxim Uvarov wrote:

On 04/05/16 19:16, Zoltan Kiss wrote:

This test sets up two interface and connect them to each other, so in
theory these two numbers should be the same. However when you use a pktio
which doesn't have full control of the interface, it could happen that
other players, e.g. various services of the operating system start to
send traffic out on the newly created interfaces. It won't be visible
for ODP when going out, but coming in it will increase the counters.
This breaks the test on ODP-DPDK, unnecessarily. On ODP-Linux it does
not,
because it checks the system level statistics, not the ODP level ones.

Signed-off-by: Zoltan Kiss 
---
diff --git a/test/validation/pktio/pktio.c
b/test/validation/pktio/pktio.c
index cb403a6..73b702c 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -1256,7 +1256,6 @@ void pktio_test_statistics_counters(void)
  CU_ASSERT((stats[1].in_ucast_pkts == 0) ||
(stats[1].in_ucast_pkts >= (uint64_t)pkts));

that is strange that if:

  CU_ASSERT(stats[0].out_ucast_pkts == stats[1].in_ucast_pkts);

passes and this:

-CU_ASSERT(stats[0].out_octets == stats[1].in_octets);

is not.

number of packet should be linked to number of bytes. Might be skip this
test in pktio_check_statistics_counters()
if we see some traffic after start?


It's actually because ODP-DPDK sets ucast_pkts counters to 0, because it 
doesn't have a separate counter for unicast packets. I'll resend




Maxim.

  CU_ASSERT((stats[0].out_octets == 0) ||
(stats[0].out_octets >=
(PKT_LEN_NORMAL * (uint64_t)pkts)));



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


[lng-odp] [PATCH v2] validation: pktio: remove checks from stats test

2016-04-21 Thread Zoltan Kiss
This test sets up two interfaces and connect them to each other, so in
theory these numbers should be the same. However when you use a pktio
which doesn't have full control of the interface, it could happen that
other players, e.g. various services of the operating system start to
send traffic out on the newly created interfaces. It won't be visible
for ODP when going out, but coming in it will increase the counters.
This breaks the test on ODP-DPDK, unnecessarily. On ODP-Linux it does not,
because it checks the system level statistics, not the ODP level ones.

Signed-off-by: Zoltan Kiss 
---

v2:
- fix commit log typo
- remove pkt number check as well, and edit the title

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index d52a520..78cf44a 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -1258,8 +1258,6 @@ void pktio_test_statistics_counters(void)
CU_ASSERT(ret == 0);
CU_ASSERT((stats[1].in_ucast_pkts == 0) ||
  (stats[1].in_ucast_pkts >= (uint64_t)pkts));
-   CU_ASSERT(stats[0].out_ucast_pkts == stats[1].in_ucast_pkts);
-   CU_ASSERT(stats[0].out_octets == stats[1].in_octets);
CU_ASSERT((stats[0].out_octets == 0) ||
  (stats[0].out_octets >=
  (PKT_LEN_NORMAL * (uint64_t)pkts)));
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] odp v1.9.0.0 release is out

2016-04-21 Thread Maxim Uvarov

Hello,

I'm glad to announce that current v1.9.0.0 point release just out.

A focus has been made on improving the packaging support of ODP for 
distributions such as Debian.
Improved creation of source tar ball and packaging scenarios moved to 
https://git.linaro.org/lng/odp-packaging.git


For current release we also maintain release notes separately here:
https://git.linaro.org/lng/odp-release-notes.git

Please see generated output at temporary location:
http://people.linaro.org/~mike.holmes/odp-release-notes-v1.9/odp-release-notes.html

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


Re: [lng-odp] [API-NEXT PATCH v2] api: queue: add queue context length

2016-04-21 Thread Bill Fischofer
On Thu, Apr 21, 2016 at 6:21 AM, Petri Savolainen <
petri.savolai...@nokia.com> wrote:

> Added queue context length parameter, which is a hint for
> the implementation for how much to prefetch. Added the same in
> to the set function. It's not needed for get function since
> application can store the same into context data and
> implementation may avoid to save the length if it does not
> need it (e.g. always prefetches a fixed number of bytes).
>
> Signed-off-by: Petri Savolainen 
>

Reviewed-by: Bill Fischofer 


> ---
>  include/odp/api/spec/queue.h  | 10 +-
>  platform/linux-generic/odp_queue.c|  3 ++-
>  test/validation/queue/queue.c | 10 ++
>  test/validation/scheduler/scheduler.c |  6 +++---
>  4 files changed, 20 insertions(+), 9 deletions(-)
>
> diff --git a/include/odp/api/spec/queue.h b/include/odp/api/spec/queue.h
> index 7626ca7..7cc031d 100644
> --- a/include/odp/api/spec/queue.h
> +++ b/include/odp/api/spec/queue.h
> @@ -140,6 +140,13 @@ typedef struct odp_queue_param_t {
>   * pointer for prefetching the context data. Default value of the
>   * pointer is NULL. */
> void *context;
> +
> +   /** Queue context data length
> + *
> + * User defined context data length in bytes for prefetching.
> + * The implementation may use this value as a hint for the number
> of
> + * context data bytes to prefetch. Default value is zero (no
> hint). */
> +   uint32_t context_len;
>  } odp_queue_param_t;
>
>  /**
> @@ -192,11 +199,12 @@ odp_queue_t odp_queue_lookup(const char *name);
>   *
>   * @param queueQueue handle
>   * @param context  Address to the queue context
> + * @param len  Queue context data length in bytes
>   *
>   * @retval 0 on success
>   * @retval <0 on failure
>   */
> -int odp_queue_context_set(odp_queue_t queue, void *context);
> +int odp_queue_context_set(odp_queue_t queue, void *context, uint32_t len);
>
>  /**
>   * Get queue context
> diff --git a/platform/linux-generic/odp_queue.c
> b/platform/linux-generic/odp_queue.c
> index 342ffa2..9a9462d 100644
> --- a/platform/linux-generic/odp_queue.c
> +++ b/platform/linux-generic/odp_queue.c
> @@ -344,7 +344,8 @@ int odp_queue_destroy(odp_queue_t handle)
> return 0;
>  }
>
> -int odp_queue_context_set(odp_queue_t handle, void *context)
> +int odp_queue_context_set(odp_queue_t handle, void *context,
> + uint32_t len ODP_UNUSED)
>  {
> queue_entry_t *queue;
> queue = queue_to_qentry(handle);
> diff --git a/test/validation/queue/queue.c b/test/validation/queue/queue.c
> index 50c6857..96d21fa 100644
> --- a/test/validation/queue/queue.c
> +++ b/test/validation/queue/queue.c
> @@ -12,7 +12,7 @@
>  #define MSG_POOL_SIZE   (4 * 1024 * 1024)
>  #define CONFIG_MAX_ITERATION(100)
>
> -static int queue_contest = 0xff;
> +static int queue_context = 0xff;
>  static odp_pool_t pool;
>
>  int queue_suite_init(void)
> @@ -76,10 +76,11 @@ void queue_test_sunnydays(void)
> CU_ASSERT_EQUAL(ODP_SCHED_SYNC_PARALLEL,
> odp_queue_sched_type(queue_id));
>
> -   CU_ASSERT(0 == odp_queue_context_set(queue_id, &queue_contest));
> +   CU_ASSERT(0 == odp_queue_context_set(queue_id, &queue_context,
> +sizeof(queue_context)));
>
> prtn = odp_queue_context(queue_id);
> -   CU_ASSERT(&queue_contest == (int *)prtn);
> +   CU_ASSERT(&queue_context == (int *)prtn);
>
> msg_pool = odp_pool_lookup("msg_pool");
> buf = odp_buffer_alloc(msg_pool);
> @@ -144,7 +145,8 @@ void queue_test_info(void)
> /* Create a plain queue and set context */
> q_plain = odp_queue_create(nq_plain, NULL);
> CU_ASSERT(ODP_QUEUE_INVALID != q_plain);
> -   CU_ASSERT(odp_queue_context_set(q_plain, q_plain_ctx) == 0);
> +   CU_ASSERT(odp_queue_context_set(q_plain, q_plain_ctx,
> +   sizeof(q_plain_ctx)) == 0);
>
> /* Create a scheduled ordered queue with explicitly set params */
> odp_queue_param_init(¶m);
> diff --git a/test/validation/scheduler/scheduler.c
> b/test/validation/scheduler/scheduler.c
> index ae98401..dae859e 100644
> --- a/test/validation/scheduler/scheduler.c
> +++ b/test/validation/scheduler/scheduler.c
> @@ -592,7 +592,7 @@ static void chaos_run(unsigned int qtype)
> CU_ASSERT_FATAL(globals->chaos_q[i].handle !=
> ODP_QUEUE_INVALID);
> rc = odp_queue_context_set(globals->chaos_q[i].handle,
> -  CHAOS_NDX_TO_PTR(i));
> +  CHAOS_NDX_TO_PTR(i), 0);
> CU_ASSERT_FATAL(rc == 0);
> }
>
> @@ -1374,7 +1374,7 @@ static int create_queues(void)
> pqctx->ctx_handle = queue_ctx_buf;
> pqctx->sequence = 0;
>
> -  

Re: [lng-odp] [API-NEXT PATCH v3 4/4] api: packet: update add_data and rem_data definition

2016-04-21 Thread Bill Fischofer
For this part only:

On Thu, Apr 21, 2016 at 6:01 AM, Petri Savolainen <
petri.savolai...@nokia.com> wrote:

> Updated odp_packet_add_data and _rem_data definitions to match
> other calls that may or may not move data. The new packet
> handle is output through packet handle pointer parameter and
> return codes indicate if old data was moved or not, or if
> the operation failed.
>
> Signed-off-by: Petri Savolainen 
>

Reviewed-by: Bill Fischofer 


> ---
>  include/odp/api/spec/packet.h   | 71
> -
>  platform/linux-generic/odp_packet.c | 68
> ++-
>  test/validation/packet/packet.c | 15 
>  3 files changed, 91 insertions(+), 63 deletions(-)
>
> diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
> index da246e2..de128df 100644
> --- a/include/odp/api/spec/packet.h
> +++ b/include/odp/api/spec/packet.h
> @@ -586,40 +586,61 @@ int odp_packet_trunc_tail(odp_packet_t *pkt,
> uint32_t len, void **tail_ptr,
>  /**
>   * Add data into an offset
>   *
> - * Increases packet data length by adding new data area into the specified
> - * offset. The operation returns a new packet handle on success. It may
> modify
> - * packet segmentation and move data. Handles and pointers must be updated
> - * after the operation. User is responsible to update packet metadata
> offsets
> - * when needed. The packet is not modified on an error.
> + * Increase packet data length by adding new data area into the specified
> + * offset. The operation may modify packet segmentation and move data.
>   *
> - * @param pkt Packet handle
> - * @param offset  Byte offset into the packet
> - * @param len Number of bytes to add into the offset
> + * A successful operation overwrites the packet handle with a new handle,
> which
> + * application must use as the reference to the packet instead of the old
> + * handle. Depending on the implementation, the old and new handles may be
> + * equal.
>   *
> - * @return New packet handle
> - * @retval ODP_PACKET_INVALID on failure
> + * The operation return value indicates if any packet data or metadata
> (e.g.
> + * user_area) were moved in memory during the operation. If some memory
> areas
> + * were moved, application must use new packet/segment handles to update
> + * data pointers. Otherwise, all old pointers remain valid.
> + *
> + * User is responsible to update packet metadata offsets when needed.
> Packet
> + * is not modified if operation fails.
> + *
> + * @param[in, out] pkt  Pointer to packet handle. A successful operation
> outputs
> + *  the new packet handle.
> + * @param offsetByte offset into the packet
> + * @param len   Number of bytes to add into the offset
> + *
> + * @retval 0   Operation successful, old pointers remain valid
> + * @retval >0  Operation successful, old pointers need to be updated
> + * @retval <0  Operation failed
>   */
> -odp_packet_t odp_packet_add_data(odp_packet_t pkt, uint32_t offset,
> -uint32_t len);
> +int odp_packet_add_data(odp_packet_t *pkt, uint32_t offset, uint32_t len);
>
>  /**
>   * Remove data from an offset
>   *
> - * Decreases packet data length by removing data from the specified
> offset.
> - * The operation returns a new packet handle on success, and may modify
> - * packet segmentation and move data. Handles and pointers must be updated
> - * after the operation. User is responsible to update packet metadata
> offsets
> - * when needed. The packet is not modified on an error.
> + * Decrease packet data length by removing data area from the specified
> + * offset. The operation may modify packet segmentation and move data.
>   *
> - * @param pkt Packet handle
> - * @param offset  Byte offset into the packet
> - * @param len Number of bytes to remove from the offset
> + * A successful operation overwrites the packet handle with a new handle,
> which
> + * application must use as the reference to the packet instead of the old
> + * handle. Depending on the implementation, the old and new handles may be
> + * equal.
>   *
> - * @return New packet handle
> - * @retval ODP_PACKET_INVALID on failure
> - */
> -odp_packet_t odp_packet_rem_data(odp_packet_t pkt, uint32_t offset,
> -uint32_t len);
> + * The operation return value indicates if any packet data or metadata
> (e.g.
> + * user_area) were moved in memory during the operation. If some memory
> areas
> + * were moved, application must use new packet/segment handles to update
> + * data pointers. Otherwise, all old pointers remain valid.
> + *
> + * User is responsible to update packet metadata offsets when needed.
> Packet
> + * is not modified if operation fails.
> + *
> + * @param[in, out] pkt  Pointer to packet handle. A successful operation
> outputs
> + *  the new packet handle.
> + * @param offsetByte offset into the packet
> + * @param len

[lng-odp] [Bug 2138] CID 158518: CID 158519: Unchecked return value: odp_packet_io.c

2016-04-21 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2138

Mike Holmes  changed:

   What|Removed |Added

 Status|IN_PROGRESS |RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from Mike Holmes  ---
166af73

-- 
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


[lng-odp] [Bug 2160] Building natively on AARch64 fails

2016-04-21 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2160

Mike Holmes  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|CONFIRMED   |RESOLVED

--- Comment #2 from Mike Holmes  ---
9eca376

-- 
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


[lng-odp] [Bug 2102] make distcheck does not inherit original options

2016-04-21 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2102

Mike Holmes  changed:

   What|Removed |Added

 Status|CONFIRMED   |RESOLVED
 Resolution|--- |FIXED

--- Comment #1 from Mike Holmes  ---
Maxims test now passes

-- 
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


[lng-odp] [Bug 2186] odp_queue_create() fails to clean up if schedule_queue_init fails

2016-04-21 Thread bugzilla-daemon
https://bugs.linaro.org/show_bug.cgi?id=2186

--- Comment #2 from Bill Fischofer  ---
Patch v2 posted at http://patches.opendataplane.org/patch/5636/

-- 
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] [API-NEXT 1/4] api: classification: Adds capability and PMR range

2016-04-21 Thread Bala Manoharan
On 21 April 2016 at 17:30, Savolainen, Petri (Nokia - FI/Espoo) <
petri.savolai...@nokia.com> wrote:

>
>
> > -Original Message-
> > From: EXT Balasubramanian Manoharan [mailto:bala.manoha...@linaro.org]
> > Sent: Thursday, April 21, 2016 9:19 AM
> > To: lng-odp@lists.linaro.org
> > Cc: Savolainen, Petri (Nokia - FI/Espoo) ;
> > Balasubramanian Manoharan 
> > Subject: [API-NEXT 1/4] api: classification: Adds capability and PMR
> range
> >
> > Adds classification capability structure and PMR range functionality.
> > odp_cls_capability_t structure defines system level classification
> > capability.
> >
> > Signed-off-by: Balasubramanian Manoharan 
> > ---
> >  include/odp/api/spec/classification.h | 134
> -
> > -
> >  1 file changed, 112 insertions(+), 22 deletions(-)
> >
> > diff --git a/include/odp/api/spec/classification.h
> > b/include/odp/api/spec/classification.h
> > index 076b3de..28619a9 100644
> > --- a/include/odp/api/spec/classification.h
> > +++ b/include/odp/api/spec/classification.h
> > @@ -55,6 +55,76 @@ extern "C" {
> >   */
> >
> >  /**
> > + * Supported PMR term values
> > + *
> > + * Supported Packet Matching Rule term values in a bit field structure.
> > + */
> > +typedef union odp_cls_pmr_supported_t {
> > + struct {
> > + /** Total length of received packet */
> > + uint64_tpmr_len:1;
>
> This should be shortly "len".
>

 Maybe we can rename as packet_len. Since this field is used to identify
length of the packet.

>
> > + /** Initial (outer) Ethertype only */
> > + uint64_tethtype_0:1;
> > + /** Ethertype of most inner VLAN tag */
> > + uint64_tethtype_x:1;
> > + /** First VLAN ID (outer) */
> > + uint64_tvlan_id_0:1;
> > + /** Last VLAN ID (inner) */
> > + uint64_tvlan_id_x:1;
> > + /** destination MAC address */
> > + uint64_tdmac:1;
> > + /** IP Protocol or IPv6 Next Header */
> > + uint64_tip_proto:1;
> > + /** Destination UDP port, implies IPPROTO=17 */
> > + uint64_tudp_dport:1;
> > + /** Destination TCP port implies IPPROTO=6 */
> > + uint64_ttcp_dport:1;
> > + /** Source UDP Port */
> > + uint64_tudp_sport:1;
> > + /** Source TCP port */
> > + uint64_ttcp_sport:1;
> > + /** Source IP address */
> > + uint64_tsip_addr:1;
> > + /** Destination IP address */
> > + uint64_tdip_addr:1;
> > + /** Source IP address */
> > + uint64_tsip6_addr:1;
> > + /** Destination IP address */
> > + uint64_tdip6_addr:1;
> > + /** IPsec session identifier */
> > + uint64_tipsec_spi:1;
> > + /** NVGRE/VXLAN network identifier */
> > + uint64_tld_vni:1;
> > + /** Custom match rule, offset from start of
> > +  * frame. The match is defined by the offset, the
> > +  * expected value, and its size.
> > +  */
> > + uint64_tcustom_frame:1;
> > +
> > + } proto;
>
> I'd use "bit" here, proto is definitely wrong here since there are fields
> that are not protocols (len, address, custom  ...). Proto is copy-paste
> from hash struct, but bit would be better also there.
>
> pmr_terms.all_bits = 0;
> pmr_terms.bit.len   = 1;
> pmr_terms.bit.udp_sport = 1;
>

Should the name be "bit" or "field"?

> ...
>
>
> > + uint64_t all_bits;
> > +} odp_cls_pmr_supported_t;
>
>
> Since this is a general list of pmr terms, a better name for the type
> would be odp_cls_pmr_terms_t, which may then be used for multiple purposes
> (supported, not supported, hw offloaded, etc).
>

Okay.

>
>
>
> > +
> > +/**
> > + * Classification capabilities
> > + * This capability structure defines system level classfication
> > capability
> > + */
> > +typedef struct odp_cls_capability_t {
> > + /** PMR terms supported by the classifier
> > +  * A mask one bit for each of odp_pmr_term_t
>
> "A bit mask of one bit for each ..."
>
> > +  */
> > + odp_cls_pmr_supported_t pmr_terms;
>
> odp_cls_pmr_terms_t supported;
>
>
> > + /** Maximum number of PMR terms */
> > + unsigned max_pmr_terms;
>
> A line feed between every struct field would make this code more readable.
>

Agreed.

>
> > + /** Number of PMR terms available for use now */
> > + unsigned available_pmr_terms;
> > + /** Maximum number of CoS supported */
> > + unsigned max_cos;
> > + /** A Boolean to denote support of PMR range */
> > + odp_bool_t pmr_range_supported;
> > +} odp_cls_capability_t;
> > +
> > +/**
> >   * class of service packet drop policies
> >   */
> >  typedef enum {

Re: [lng-odp] shmem in process mode.

2016-04-21 Thread Christophe Milard
On 21 April 2016 at 18:30, Gary S. Robertson 
wrote:

>
>
> On 04/21/2016 02:03 AM, Christophe Milard wrote:
>
> Hi,
> Indeed, if the main ODP instantiation process performs a huge virtual
> space reservation, e.g something like:
>
> shmem_base = mmap(NULL, SHM_TOT_SZ, PROT_NONE, MAP_ANONYMOUS,
> FLAG_NO_RESERVE);
> madvise(shmem_base, SHM_TOT_SZ, MADV_DONTNEED)
>
> where SHM_TOT is the grand max of the sum of all possible shmem areas,
> then this area will be mapped in all processes and threads descendant from
> the odp instantiation process, ie all odpthread if def 1 is accepted.
>
> This only holds true until the forked child process replaces its memory
> space with a different executable image than that of its parent - eg. via
> exec*().  At that time the memory space of the child is remapped to the
> replacement image and any shared memory mapping inherited from the parent
> is subject to being remapped.  I am not aware of any guarantees that shared
> memory mapped by the parent with a 'MAP_FIXED' attribute will be remapped
> at the same address in the new image.  I am not certain that such a
> guarantee is even possible given the unknown and unconstrained memory
> footprint of the replacement image.
>
> I believe that to be safe and portable we cannot rely upon shared memory
> or memory mapped files to be consistently addressable at the same location
> across processes - descendant or otherwise.  Without a guarantee of such
> consistency in the POSIX specifications, even if it works today it may be
> broken by future code changes in the kernel or the loader.
>
>
Of course, you are right here: But is an ODP thread performing an exec*()
still an ODP thread?
Once again, it depends on the definition of what an ODP thread is! I
assumed that calling exec*() would definitively disqualify the process for
remaining an ODP thread. After exec(), most of what odp_*_init() could have
done will be wiped out (apart from opened file descriptors)
As far as I understood, the intention of supporting process mode was to
perform concurrent processing without enforcing the need of common shared
global memory between the different ODP threads. Hence systems with NUMA
could use local memory for different processes and just use some limited
amount of shared memory for the stuff that really needs to be shared.

So maybe, the definition of an ODP process should be:
"any process descendant from the ODP main instantiation process, which has
called odp_local_init(), and not called any if the exec*() system call".


Regarding the performance aspect, other than additional overhead in initial
> setup and teardown/cleanup I don't see a performance difference between
> base addresses obtained from a "global" shared data structure and a
> process-local one.  Since the process-local addess table avoids the risky
> behaviour of relying on consistent mapping across processes it seems to me
> the obvious way to go.
>
> If both the "shared global" object reference/naming table and
> process-local object mapping tables are "indexed" by a platform-agnostic
> handle for each shared memory object then I believe that performance of
> access to the shared memory objects will be a "wash".  This would be the
> most portable and "best practice" implementation - which I believe is also
> an important consideration for a reference platform.
>
> I is clear for me that an application being able to use the same set of
pointers over its different threads/process will gain in performance:
Assuming the contents of the shared memory contains some complex structure,
it is likely it will be referenced by pointers within some code, and
possibly these pointers will need to be shared as well. It seems reasonable
to believe that sharing the same set of pointers (and being able to pass
then between ODP threads) will be performing better.

And last but not least: thanks for your comments, Gary!

Christophe

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


Re: [lng-odp] [API-NEXT 1/4] api: classification: Adds capability and PMR range

2016-04-21 Thread Savolainen, Petri (Nokia - FI/Espoo)


From: EXT Bala Manoharan [mailto:bala.manoha...@linaro.org]
Sent: Friday, April 22, 2016 8:43 AM
To: Savolainen, Petri (Nokia - FI/Espoo) 
Cc: lng-odp@lists.linaro.org
Subject: Re: [API-NEXT 1/4] api: classification: Adds capability and PMR range


On 21 April 2016 at 17:30, Savolainen, Petri (Nokia - FI/Espoo) 
mailto:petri.savolai...@nokia.com>> wrote:


> -Original Message-
> From: EXT Balasubramanian Manoharan 
> [mailto:bala.manoha...@linaro.org]
> Sent: Thursday, April 21, 2016 9:19 AM
> To: lng-odp@lists.linaro.org
> Cc: Savolainen, Petri (Nokia - FI/Espoo) 
> mailto:petri.savolai...@nokia.com>>;
> Balasubramanian Manoharan 
> mailto:bala.manoha...@linaro.org>>
> Subject: [API-NEXT 1/4] api: classification: Adds capability and PMR range
>
> Adds classification capability structure and PMR range functionality.
> odp_cls_capability_t structure defines system level classification
> capability.
>
> Signed-off-by: Balasubramanian Manoharan 
> mailto:bala.manoha...@linaro.org>>
> ---
>  include/odp/api/spec/classification.h | 134 -
> -
>  1 file changed, 112 insertions(+), 22 deletions(-)
>
> diff --git a/include/odp/api/spec/classification.h
> b/include/odp/api/spec/classification.h
> index 076b3de..28619a9 100644
> --- a/include/odp/api/spec/classification.h
> +++ b/include/odp/api/spec/classification.h
> @@ -55,6 +55,76 @@ extern "C" {
>   */
>
>  /**
> + * Supported PMR term values
> + *
> + * Supported Packet Matching Rule term values in a bit field structure.
> + */
> +typedef union odp_cls_pmr_supported_t {
> + struct {
> + /** Total length of received packet */
> + uint64_tpmr_len:1;
This should be shortly "len".

 Maybe we can rename as packet_len. Since this field is used to identify length 
of the packet.

That’s OK, but then the enum value should be renamed also (everything else here 
matches the enum).



> + /** Initial (outer) Ethertype only */
> + uint64_tethtype_0:1;
> + /** Ethertype of most inner VLAN tag */
> + uint64_tethtype_x:1;
> + /** First VLAN ID (outer) */
> + uint64_tvlan_id_0:1;
> + /** Last VLAN ID (inner) */
> + uint64_tvlan_id_x:1;
> + /** destination MAC address */
> + uint64_tdmac:1;
> + /** IP Protocol or IPv6 Next Header */
> + uint64_tip_proto:1;
> + /** Destination UDP port, implies IPPROTO=17 */
> + uint64_tudp_dport:1;
> + /** Destination TCP port implies IPPROTO=6 */
> + uint64_ttcp_dport:1;
> + /** Source UDP Port */
> + uint64_tudp_sport:1;
> + /** Source TCP port */
> + uint64_ttcp_sport:1;
> + /** Source IP address */
> + uint64_tsip_addr:1;
> + /** Destination IP address */
> + uint64_tdip_addr:1;
> + /** Source IP address */
> + uint64_tsip6_addr:1;
> + /** Destination IP address */
> + uint64_tdip6_addr:1;
> + /** IPsec session identifier */
> + uint64_tipsec_spi:1;
> + /** NVGRE/VXLAN network identifier */
> + uint64_tld_vni:1;
> + /** Custom match rule, offset from start of
> +  * frame. The match is defined by the offset, the
> +  * expected value, and its size.
> +  */
> + uint64_tcustom_frame:1;
> +
> + } proto;
I'd use "bit" here, proto is definitely wrong here since there are fields that 
are not protocols (len, address, custom  ...). Proto is copy-paste from hash 
struct, but bit would be better also there.

pmr_terms.all_bits = 0;
pmr_terms.bit.len   = 1;
pmr_terms.bit.udp_sport = 1;

Should the name be "bit" or "field"?

Bit, since it’s used already for the same purpose in other APIs. Also it’s easy 
to see that “all_bits” and “bit.x, bit.y, …” refer to the same data.


-Petri

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