Re: [lng-odp] [API-NEXT RFC 02/31] api: introducing the driver api definition file

2016-01-12 Thread Mike Holmes
On 11 January 2016 at 03:54, Savolainen, Petri (Nokia - FI/Espoo) <
petri.savolai...@nokia.com> wrote:

> CC’d the list again.
>
>
>
>
>
> *From:* EXT Christophe Milard [mailto:christophe.mil...@linaro.org]
> *Sent:* Monday, January 11, 2016 10:29 AM
> *To:* Savolainen, Petri (Nokia - FI/Espoo)
> *Subject:* Re: [API-NEXT RFC 02/31] api: introducing the driver api
> definition file
>
>
>
>
>
> On 11 January 2016 at 09:12, Savolainen, Petri (Nokia - FI/Espoo) <
> petri.savolai...@nokia.com> wrote:
>
>
>
> > -Original Message-
> > From: EXT Christophe Milard [mailto:christophe.mil...@linaro.org]
> > Sent: Friday, January 08, 2016 10:30 PM
> > To: anders.rox...@linaro.org; mike.hol...@linaro.org;
> > stuart.has...@linaro.org; maxim.uva...@linaro.org;
> > bill.fischo...@linaro.org; petri.savolai...@linaro.org;
> > eda...@broadcom.com
> > Cc: lng-odp@lists.linaro.org; Christophe Milard
> > Subject: [API-NEXT RFC 02/31] api: introducing the driver api definition
> > file
> >
> > include/odp.h defines the ODP-application API (as before).
> > include/odp_driver.h defines the new driver API.
> > Note that the two APIs (application API and driver API) are partly
> > overlapping: Some files such as byteorder.h, sync.h, hints.h... needs
> > obviously to be part of both APIs.
> >
> > Signed-off-by: Christophe Milard 
> > ---
> >  include/odp.h|  2 +-
> >  include/odp_driver.h | 34 ++
> >  2 files changed, 35 insertions(+), 1 deletion(-)
> >  create mode 100644 include/odp_driver.h
> >
> > diff --git a/include/odp.h b/include/odp.h
> > index 4a93c23..1c880df 100644
> > --- a/include/odp.h
> > +++ b/include/odp.h
> > @@ -7,7 +7,7 @@
> >  /**
> >   * @file
> >   *
> > - * The OpenDataPlane API
> > + * The OpenDataPlane API to applications
>
> This addition is not needed, since API ("Application Programming
> Interface") should be always defined for applications.
>
>
>
> OK
>
>
>
>
>
> >   *
> >   */
> >
> > diff --git a/include/odp_driver.h b/include/odp_driver.h
> > new file mode 100644
> > index 000..b59f7df
> > --- /dev/null
> > +++ b/include/odp_driver.h
> > @@ -0,0 +1,34 @@
> > +/* Copyright (c) 2015, Linaro Limited
> > + * All rights reserved
> > + *
> > + * SPDX-License-Identifier: BSD-3-Clause
> > + */
> > +
> > +/**
> > + * @file
> > + *
> > + * The OpenDataPlane API to NIC drivers
>
>
> To keep it simple, ODP API should always point towards applications. This
> can be named e.g. "ODP Driver Interface" (ODP-DI ?). It's an interface to
> connect drivers to ODP implementations, not an interface to develop
> applications (that are NIC drivers, etc).
>
> All driver interface data types and calls should be also prefixed with
> odpdrv_, odpd_, odpdi_ or something similar (other than odp_), so that it's
> clear which definitions belong to the API and which to the driver interface.
>
>
>
> That was my original intemtion, but how would you then handle the
> overlaping situation of these programming interfaces? shmem, byte order,
> barriers, locks, hints ... Many API things (according to your terminology)
> would also be part of the DI...  Would you then alias all these
> functions...?
>
>
>
>
>
> If driver interface needs some definitions from API side, then we include
> those from the API (and maintain those in sync with API) . New / additional
> definitions are prefixed with e.g. odpdi_.
>

odpdi_  would be clearer written as odpdr_or maybe longer but clearer
odpdrv_


> Driver API can consist of a bunch of odp_ defientions (re-used from API
> side) and odpdi_ definitions (only for drivers). Driver interface may have
> its own version numbering. An API change in those reused calls/definitions
> would also bump the driver interface version. We should select carefully
> which definitions and calls are really needed (or are useful) on driver
> side and include only those, which means that some of the headers
> (mentioned under) may need to be split into  API only vs. API + DI parts.
>
>
>
>
>
> Pseudo code for odp/include/odp/driver/odp_driver.h
>

This needs to be odp/include/odp_driver.h   Why complicate the structure
and place the interface for the drivers down deep, lets just put all the
interfaces under odp/include it is then nice and simple with all public
interfaces found at the same level. The structure of an interfaces includes
also then mirrors each other and the includes listed below do fall out as
written. There will be very little chance of confusion by app writers.



>
>
> #include 
> #include 
> #include < api/byteorder.h>
>
> #include 
> #include 
> #include 
> #include 
>
>
>
> #include 
>
> #include 
>
> #include 
>
> …
>
>
>
>
>
> -Petri
>
>
>
>
>
>
>
>
> -Petri
>
>
>
> > + *
> > + */
> > +
> > +#ifndef ODP_DRIVER_H_
> > +#define ODP_DRIVER_H_
> > +
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > 

Re: [lng-odp] Driver interface definition...

2016-01-12 Thread Savolainen, Petri (Nokia - FI/Espoo)
Hi,

First thing to remember is that the number of 
applications/application-/implementation-developers will be 1000x to 
drivers/driver developers. So the ODP API must be really clean: application 
includes odp.h and everything seen through that is prefixed with odp_ and 
available for applications to use.

Driver interface can be less optimal. It may be a mixture of odp_ and odpdi_ 
calls, etc. Although optimally, everything in driver interface would be odpdi_ 
prefixed even when the interface definition is 100% in sync with API. As Mike 
pointed out, it’s much easier to debug/read/maintain code when you can clearly 
see which side a call enters an ODP implementation. Also some driver interface 
definitions may diverge from the API counterpart, as API and driver interface 
versions evolve. So, may be it would be safest bet to just define driver 
interface as:

· Drivers include odpdi.h

· Everything seen through that is odpdi_ prefixed

Second thing to remember is that the build system and various header files and 
their content is linux-generic specific. ODP API spec only demands that odp.h 
is available and application sees the entire API through that. So, we can 
slice/combine/create/delete/modify any number of header files and makefiles to 
make this work for the API, the driver interface and the (linux-generic) 
implementation. Since it’s reference implementation the file/code structure 
should be clean/understandable, but still it’s just only one implementation. 
The file structure we choose does not obligate other implementations. Of course 
we try to make it easy for others to copy the structure and benefit from that, 
but since file structure is not a spec we can work on it as many times as 
needed. Even the driver interface is not a mandatory spec for implementations, 
each implementation may or may not adopt it and still be 100% compatible for 
ODP applications.


-Petri



From: EXT Christophe Milard [mailto:christophe.mil...@linaro.org]
Sent: Monday, January 11, 2016 7:31 PM
To: Petri Savolainen; Mike Holmes; Anders Roxell; Bill Fischofer; Ola 
Liljedahl; Krishna Garapati; LNG ODP Mailman List
Subject: Driver interface definition...

Hi,

Today the situation as I see it, is as follows:
We have a single interface to ODP, the application interface, A.
This interface is defined by a file which any application includes: 
include/odp.h

 includes in turn a set of platform//include/odp/.
These files are given a chance to define platform specific types by
including platform//include/odp/plat/.h, do their
own definitions (such as inlines functions) and finishes by including
/odp/include/odp/api/, which will mainly have for effect to check
that the platform definitions do match the generic api definition.

With the driver interface being defined, we are about to add another interface
D (D as driver).
It seems that some of you would like to have a /odp/include/odp/D directory
which would contains driver specific , e.g. dma.h.
While I understand the wish to keep interface separated, I am not conviced
that this really fits the job...:
How does this new directory work?.
an include file, called D.h (at the same level as odp.h, it seems we could
 agree here) would include what from the platform?
platform//include/D/? which in turn would include:
platform//include/D/plat/.h and finally 
/odp/include/odp/api_D/?
OK. that works. maybe complicated but does work. But more to the point: what
is the criteria for the modules to be in the A (normal appli api) or D 
directory?
D directories would contain any module just included by the D interface
whereas A directories woud contain modules either part of A and D or A only?
This overlap is where I see the main issue: What if an X interface has to be
created in the future (Petri named open stack as an exemple), and Y and Z?
All partly overlapping... What will be the criteria to place the different
modules (m.h) in the A, D,X, Y or Z directories? I cannot see that growing 
well...
Also the function prefix would get messy: should a function used in the A and D
 and Y interface be called A_f(), D_f(), Y_f() or ADY_f()? and change name when 
Z comes?

The other approach (chosen by the patch serie, but actually not fully
implemented there) is different:

platform//include/odp/*
platform//include/odp/plat/.h
and /odp/include/odp/api/ (which we should rename EPI (instead of API)
maybe, for External Programing Interface) would define all functions exported
by ODP. On ANY interface.
All these functions are prefixed by odp_*. as today. Saddly, one cannot tell by
the name of function only which interface it belongs to.
That actually makes sense as we accept functions to be part of many interfaces
at the same time.

The file include/odp/.h (e.g. Api.h, driver.h X.h,Y.h or Z.h)
just lists the functions (module .h files, that may have to be splitted if
modules define function for different interfaces) belonging to that interface.

Overlap is no longer a problem and 

Re: [lng-odp] [API-NEXT PATCH] Revert "api: pool: add packet user area initializer for pool creation parameters"

2016-01-12 Thread Elo, Matias (Nokia - FI/Espoo)
This seems to breaks build:

odp_pool.c: In function 'packet_uarea_init':
odp_pool.c:152:52: error: 'struct ' has no member named 'uarea_init'
  if (params->type == ODP_POOL_PACKET && params->pkt.uarea_init) {
^
odp_pool.c:155:14: error: 'struct ' has no member named 'uarea_init'
   params->pkt.uarea_init(pkt, params->pkt.uarea_init_arg);
  ^
odp_pool.c:155:42: error: 'struct ' has no member named 
'uarea_init_arg'
   params->pkt.uarea_init(pkt, params->pkt.uarea_init_arg);
  ^
make[1]: *** [odp_pool.lo] Error 1
make[1]: Leaving directory `/home/matelo/dev/odp.git/platform/linux-generic'
make: *** [check-recursive] Error 1


-Matias

> -Original Message-
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT Maxim
> Uvarov
> Sent: Tuesday, January 12, 2016 1:38 PM
> To: lng-odp@lists.linaro.org
> Subject: Re: [lng-odp] [API-NEXT PATCH] Revert "api: pool: add packet user 
> area
> initializer for pool creation parameters"
> 
> Merged,
> Maxim.
> 
> On 01/08/2016 19:35, Zoltan Kiss wrote:
> > This reverts commit 798c450fc41ee4195977a5af855dbc98d8aaec16. The use
> case
> > is not strong enough for this feature.
> >
> > Signed-off-by: Zoltan Kiss 
> > ---
> >   include/odp/api/packet.h |  3 ---
> >   include/odp/api/pool.h   | 26 --
> >   2 files changed, 29 deletions(-)
> >
> > diff --git a/include/odp/api/packet.h b/include/odp/api/packet.h
> > index 8651a47..9c63b5f 100644
> > --- a/include/odp/api/packet.h
> > +++ b/include/odp/api/packet.h
> > @@ -93,9 +93,6 @@ extern "C" {
> >* @note The default headroom and tailroom used for packets is specified 
> > by
> >* the ODP_CONFIG_PACKET_HEADROOM and
> ODP_CONFIG_PACKET_TAILROOM defines in
> >* odp_config.h.
> > - * @note Data changed in user area might be preserved by the platform from
> > - * previous usage of the buffer, so values preset in uarea_init() are not
> > - * guaranteed.
> >*/
> >   odp_packet_t odp_packet_alloc(odp_pool_t pool, uint32_t len);
> >
> > diff --git a/include/odp/api/pool.h b/include/odp/api/pool.h
> > index 01f770f..2e79a55 100644
> > --- a/include/odp/api/pool.h
> > +++ b/include/odp/api/pool.h
> > @@ -21,7 +21,6 @@ extern "C" {
> >
> >
> >   #include 
> > -#include 
> >
> >   /** @defgroup odp_pool ODP POOL
> >*  Operations on a pool.
> > @@ -42,23 +41,6 @@ extern "C" {
> >   #define ODP_POOL_NAME_LEN  32
> >
> >   /**
> > - * Packet user area initializer callback function for pools.
> > - *
> > - * @param pkt   Handle of the packet
> > - * @param uarea_init_argOpaque pointer defined in odp_pool_param_t
> > - *
> > - * @note If the application specifies this pointer, it expects that every 
> > buffer
> > - * is initialized exactly once with it when the underlying memory is 
> > allocated.
> > - * It is not called from odp_packet_alloc(), unless the platform chooses to
> > - * allocate the memory at that point. Applications can only assume that 
> > this
> > - * callback is called once before the packet is first used. Any subsequent
> > - * change to the user area might be preserved after odp_packet_free() is
> called,
> > - * so applications should take care of (re)initialization if they change 
> > data
> > - * preset by this function.
> > - */
> > -typedef void (odp_packet_uarea_init_t)(odp_packet_t pkt, void
> *uarea_init_arg);
> > -
> > -/**
> >* Pool parameters
> >* Used to communicate pool creation options.
> >*/
> > @@ -100,14 +82,6 @@ typedef struct odp_pool_param_t {
> > /** User area size in bytes. Specify as 0 if no user
> > area is needed. */
> > uint32_t uarea_size;
> > -
> > -   /** Initialize every packet's user area at allocation
> > -   time. Use NULL if no initialization needed. */
> > -   odp_packet_uarea_init_t *uarea_init;
> > -
> > -   /** Opaque pointer passed to packet user area
> > -   constructor. */
> > -   void *uarea_init_arg;
> > } pkt;
> > struct {
> > /** Number of timeouts in the pool */
> 
> ___
> 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] [PATCH] example:ipsec: Tunnel mode fixes

2016-01-12 Thread ion.grigore
From: Grigore Ion 

This patch fixes the following issues:
1. ETYPE field in the ETH header is not updated using the
BE byte order (PKT_STATE_IPSEC_IN_FINISH status).
2. IP addresses, from the packet, are not converted to
the CPU endianness, when the inbound policy is checked
(PKT_STATE_IPSEC_IN_FINISH status).
3. Identification field is not set in the outer IP header
when an IN packet is generated.
4. Total Length field is not set in the inner IP header
when an IN packet is generated.

Signed-off-by: Grigore Ion 
---
Note : The fix for the second issue was also proposed by Akhil
Goyal on Nov. 20, 2015 and by Stuart Haslam on Jan. 06, 2016

 example/ipsec/odp_ipsec.c|  6 +++---
 example/ipsec/odp_ipsec_cache.c  | 20 +---
 example/ipsec/odp_ipsec_stream.c | 11 +--
 3 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index fab1035..bdbe1a1 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -767,12 +767,12 @@ pkt_disposition_e do_ipsec_in_finish(odp_packet_t pkt,
odph_ethhdr_t *eth;
 
eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL);
-   eth->type = ODPH_ETHTYPE_IPV4;
+   eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);
ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
 
/* Check inbound policy */
-   if ((ip->src_addr != ctx->ipsec.src_ip ||
-ip->dst_addr != ctx->ipsec.dst_ip))
+   if (odp_be_to_cpu_32(ip->src_addr) != ctx->ipsec.src_ip ||
+   odp_be_to_cpu_32(ip->dst_addr) != ctx->ipsec.dst_ip)
return PKT_DROP;
 
return PKT_CONTINUE;
diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c
index 0883d4d..23b0762 100644
--- a/example/ipsec/odp_ipsec_cache.c
+++ b/example/ipsec/odp_ipsec_cache.c
@@ -138,21 +138,19 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,
}
 
if (tun) {
+   int ret;
+
entry->tun_src_ip = tun->tun_src_ip;
entry->tun_dst_ip = tun->tun_dst_ip;
mode = IPSEC_SA_MODE_TUNNEL;
 
-   int ret;
-
-   if (!in) {
-   /* init tun hdr id */
-   ret = odp_random_data((uint8_t *)
- >state.tun_hdr_id,
- sizeof(entry->state.tun_hdr_id),
- 1);
-   if (ret != sizeof(entry->state.tun_hdr_id))
-   return -1;
-   }
+   /* init tun hdr id */
+   ret = odp_random_data((uint8_t *)
+ >state.tun_hdr_id,
+ sizeof(entry->state.tun_hdr_id),
+ 1);
+   if (ret != sizeof(entry->state.tun_hdr_id))
+   return -1;
}
entry->mode = mode;
 
diff --git a/example/ipsec/odp_ipsec_stream.c b/example/ipsec/odp_ipsec_stream.c
index f750e18..9422b71 100644
--- a/example/ipsec/odp_ipsec_stream.c
+++ b/example/ipsec/odp_ipsec_stream.c
@@ -211,17 +211,21 @@ odp_packet_t create_ipv4_packet(stream_db_entry_t *stream,
/* Wait until almost finished to fill in mutable fields */
memset((char *)ip, 0, sizeof(*ip));
ip->ver_ihl = 0x45;
-   ip->id = odp_cpu_to_be_16(stream->id);
-   /* Outer IP header in tunnel mode */
if (entry && entry->mode == IPSEC_SA_MODE_TUNNEL &&
(entry == stream->input.entry)) {
+   /* Outer IP header in tunnel mode */
ip->proto = ODPH_IPV4;
ip->src_addr = odp_cpu_to_be_32(entry->tun_src_ip);
ip->dst_addr = odp_cpu_to_be_32(entry->tun_dst_ip);
+   /* New ID is generated for each outer IP header. */
+   if (!entry->state.tun_hdr_id)
+   entry->state.tun_hdr_id++;
+   ip->id = odp_cpu_to_be_16(entry->state.tun_hdr_id++);
} else {
ip->proto = ODPH_IPPROTO_ICMP;
ip->src_addr = odp_cpu_to_be_32(stream->src_ip);
ip->dst_addr = odp_cpu_to_be_32(stream->dst_ip);
+   ip->id = odp_cpu_to_be_16(stream->id);
}
 
/* AH (if specified) */
@@ -269,6 +273,9 @@ odp_packet_t create_ipv4_packet(stream_db_entry_t *stream,
inner_ip->frag_offset = 0;
inner_ip->src_addr = odp_cpu_to_be_32(stream->src_ip);
inner_ip->dst_addr = odp_cpu_to_be_32(stream->dst_ip);
+   inner_ip->tot_len = odp_cpu_to_be_16(sizeof(odph_ipv4hdr_t) +
+   sizeof(odph_icmphdr_t) + sizeof(stream_pkt_hdr_t) +
+   stream->length);
   

Re: [lng-odp] [API-NEXT PATCH] Revert "api: pool: add packet user area initializer for pool creation parameters"

2016-01-12 Thread Zoltan Kiss
Ahh, sorry, I forgot the implementation was also in the repo. I'll send 
a patch to revert that too.


On 12/01/16 13:06, Elo, Matias (Nokia - FI/Espoo) wrote:

This seems to breaks build:

odp_pool.c: In function 'packet_uarea_init':
odp_pool.c:152:52: error: 'struct ' has no member named 'uarea_init'
   if (params->type == ODP_POOL_PACKET && params->pkt.uarea_init) {
 ^
odp_pool.c:155:14: error: 'struct ' has no member named 'uarea_init'
params->pkt.uarea_init(pkt, params->pkt.uarea_init_arg);
   ^
odp_pool.c:155:42: error: 'struct ' has no member named 
'uarea_init_arg'
params->pkt.uarea_init(pkt, params->pkt.uarea_init_arg);
   ^
make[1]: *** [odp_pool.lo] Error 1
make[1]: Leaving directory `/home/matelo/dev/odp.git/platform/linux-generic'
make: *** [check-recursive] Error 1


-Matias


-Original Message-
From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT Maxim
Uvarov
Sent: Tuesday, January 12, 2016 1:38 PM
To: lng-odp@lists.linaro.org
Subject: Re: [lng-odp] [API-NEXT PATCH] Revert "api: pool: add packet user area
initializer for pool creation parameters"

Merged,
Maxim.

On 01/08/2016 19:35, Zoltan Kiss wrote:

This reverts commit 798c450fc41ee4195977a5af855dbc98d8aaec16. The use

case

is not strong enough for this feature.

Signed-off-by: Zoltan Kiss 
---
   include/odp/api/packet.h |  3 ---
   include/odp/api/pool.h   | 26 --
   2 files changed, 29 deletions(-)

diff --git a/include/odp/api/packet.h b/include/odp/api/packet.h
index 8651a47..9c63b5f 100644
--- a/include/odp/api/packet.h
+++ b/include/odp/api/packet.h
@@ -93,9 +93,6 @@ extern "C" {
* @note The default headroom and tailroom used for packets is specified by
* the ODP_CONFIG_PACKET_HEADROOM and

ODP_CONFIG_PACKET_TAILROOM defines in

* odp_config.h.
- * @note Data changed in user area might be preserved by the platform from
- * previous usage of the buffer, so values preset in uarea_init() are not
- * guaranteed.
*/
   odp_packet_t odp_packet_alloc(odp_pool_t pool, uint32_t len);

diff --git a/include/odp/api/pool.h b/include/odp/api/pool.h
index 01f770f..2e79a55 100644
--- a/include/odp/api/pool.h
+++ b/include/odp/api/pool.h
@@ -21,7 +21,6 @@ extern "C" {


   #include 
-#include 

   /** @defgroup odp_pool ODP POOL
*  Operations on a pool.
@@ -42,23 +41,6 @@ extern "C" {
   #define ODP_POOL_NAME_LEN  32

   /**
- * Packet user area initializer callback function for pools.
- *
- * @param pkt   Handle of the packet
- * @param uarea_init_argOpaque pointer defined in odp_pool_param_t
- *
- * @note If the application specifies this pointer, it expects that every 
buffer
- * is initialized exactly once with it when the underlying memory is allocated.
- * It is not called from odp_packet_alloc(), unless the platform chooses to
- * allocate the memory at that point. Applications can only assume that this
- * callback is called once before the packet is first used. Any subsequent
- * change to the user area might be preserved after odp_packet_free() is

called,

- * so applications should take care of (re)initialization if they change data
- * preset by this function.
- */
-typedef void (odp_packet_uarea_init_t)(odp_packet_t pkt, void

*uarea_init_arg);

-
-/**
* Pool parameters
* Used to communicate pool creation options.
*/
@@ -100,14 +82,6 @@ typedef struct odp_pool_param_t {
/** User area size in bytes. Specify as 0 if no user
area is needed. */
uint32_t uarea_size;
-
-   /** Initialize every packet's user area at allocation
-   time. Use NULL if no initialization needed. */
-   odp_packet_uarea_init_t *uarea_init;
-
-   /** Opaque pointer passed to packet user area
-   constructor. */
-   void *uarea_init_arg;
} pkt;
struct {
/** Number of timeouts in the pool */


___
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] [RFC API-NEXT PATCH] api: packet: add packet segment manipulation

2016-01-12 Thread Bala Manoharan
Hi,


On 11 January 2016 at 19:17, Petri Savolainen
 wrote:
> Packet segments can be allocated/freed/multi-referenced.
> Segments data pointer and length can be modified (push/pull).
> Segments can be linked to packets when needed (can exist also
> when not connected to packets).
>
> TODO: Packet pool params need tuning for segment length
> configuration.
>
> Signed-off-by: Petri Savolainen 
> ---
>  include/odp/api/packet.h | 82 
> +++-
>  1 file changed, 74 insertions(+), 8 deletions(-)
>
> diff --git a/include/odp/api/packet.h b/include/odp/api/packet.h
> index 8651a47..7d315ba 100644
> --- a/include/odp/api/packet.h
> +++ b/include/odp/api/packet.h
> @@ -118,6 +118,15 @@ int odp_packet_alloc_multi(odp_pool_t pool, uint32_t len,
>odp_packet_t pkt[], int num);
>
>  /**
> + * Create a new reference to the packet
> + *
> + * @param pkt   Packet handle
> + *
> + * @return New handle which refers to the input packet
> + */
> +odp_packet_t odp_packet_ref(odp_packet_t pkt);
> +
> +/**
>   * Free packet
>   *
>   * Frees the packet into the buffer pool it was allocated from.
> @@ -810,11 +819,44 @@ void odp_packet_shaper_len_adjust_set(odp_packet_t pkt, 
> int8_t adj);
>   */
>
>  /**
> + * Allocate a new segment
> + *
> + * Allocates a new segment from the specified packet pool. The segment
> + * is initialized with data pointers and lengths set according to the
> + * specified len. All other segment metadata are set to their default values.
> + *
> + * @param pool  Pool handle
> + * @param len   Segment data length
> + *
> + * @return Handle of allocated packet
> + * @retval ODP_PACKET_SEG_INVALID  Segment could not be allocated
> + */
> +odp_packet_seg_t odp_packet_seg_alloc(odp_pool_t pool, uint32_t len);

IMO, we can update the statement that the maximum allocatable length
will be only one segment. ie the segment alloc always alloc one
segment from the pool and size will be equal to segment size.

> +
> +/**
> + * Free segment
> + *
> + * Frees the segment into the pool it was allocated from. Segment must not be
> + * linked into any packet.
> + *
> + * @param seg   Segment handle
> + */
> +void odp_packet_seg_free(odp_packet_seg_t seg);

IMO, the above function needs additional description as to what
happens when a packet where this segment is linked to is freed. if the
segment has only one reference then does odp_packet_free() basically
free the attached segment also.

> +
> +/**
> + * Create a new reference to the segment
> + *
> + * @param seg   Segment handle
> + *
> + * @return New handle which refers to the input segment
> + */
> +odp_packet_seg_t odp_packet_seg_ref(odp_packet_seg_t seg);
> +
> +/**
>   * Segment buffer address
>   *
>   * Returns start address of the segment.
>   *
> - * @param pkt  Packet handle
>   * @param seg  Segment handle
>   *
>   * @return  Start address of the segment
> @@ -822,28 +864,26 @@ void odp_packet_shaper_len_adjust_set(odp_packet_t pkt, 
> int8_t adj);
>   *
>   * @see odp_packet_seg_buf_len()
>   */
> -void *odp_packet_seg_buf_addr(odp_packet_t pkt, odp_packet_seg_t seg);
> +void *odp_packet_seg_buf_addr(odp_packet_seg_t seg);
>
>  /**
>   * Segment buffer length
>   *
>   * Returns segment buffer length in bytes.
>   *
> - * @param pkt  Packet handle
>   * @param seg  Segment handle
>   *
>   * @return  Segment buffer length in bytes
>   *
>   * @see odp_packet_seg_buf_addr()
>   */
> -uint32_t odp_packet_seg_buf_len(odp_packet_t pkt, odp_packet_seg_t seg);
> +uint32_t odp_packet_seg_buf_len(odp_packet_seg_t seg);
>
>  /**
>   * Segment data pointer
>   *
>   * Returns pointer to the first byte of data in the segment.
>   *
> - * @param pkt  Packet handle
>   * @param seg  Segment handle
>   *
>   * @return  Pointer to the segment data
> @@ -851,21 +891,29 @@ uint32_t odp_packet_seg_buf_len(odp_packet_t pkt, 
> odp_packet_seg_t seg);
>   *
>   * @see odp_packet_seg_data_len()
>   */
> -void *odp_packet_seg_data(odp_packet_t pkt, odp_packet_seg_t seg);
> +void *odp_packet_seg_data(odp_packet_seg_t seg);
>
>  /**
>   * Segment data length
>   *
>   * Returns segment data length in bytes.
>   *
> - * @param pkt  Packet handle
>   * @param seg  Segment handle
>   *
>   * @return  Segment data length in bytes
>   *
>   * @see odp_packet_seg_data()
>   */
> -uint32_t odp_packet_seg_data_len(odp_packet_t pkt, odp_packet_seg_t seg);
> +uint32_t odp_packet_seg_data_len(odp_packet_seg_t seg);
> +
> +
> +void *odp_packet_seg_push_head(odp_packet_seg_t seg, uint32_t len);
> +
> +void *odp_packet_seg_pull_head(odp_packet_seg_t seg, uint32_t len);
> +
> +void *odp_packet_seg_push_tail(odp_packet_seg_t seg, uint32_t len);
> +
> +void *odp_packet_seg_pull_tail(odp_packet_seg_t seg, uint32_t len);

In the above APIs for push and pull at segment level it is better if
the application could pass the packet handle 

[lng-odp] [API-NEXT PATCH] Revert user area init implementation

2016-01-12 Thread Zoltan Kiss
This reverts commits:

2eb52b7277 "linux-generic: pool: implement user area init support"
9127b7408b "validation: packet: test if user area is properly set"

Signed-off-by: Zoltan Kiss 
---
 platform/linux-generic/odp_pool.c | 11 ---
 test/validation/packet/packet.c   | 18 --
 2 files changed, 4 insertions(+), 25 deletions(-)

diff --git a/platform/linux-generic/odp_pool.c 
b/platform/linux-generic/odp_pool.c
index 125d8e6..84d35bf 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -147,15 +147,6 @@ int odp_pool_term_local(void)
return 0;
 }
 
-static void packet_uarea_init(odp_pool_param_t *params, odp_buffer_hdr_t *tmp)
-{
-   if (params->type == ODP_POOL_PACKET && params->pkt.uarea_init) {
-   odp_packet_t pkt = _odp_packet_from_buffer(odp_hdr_to_buf(tmp));
-
-   params->pkt.uarea_init(pkt, params->pkt.uarea_init_arg);
-   }
-}
-
 /**
  * Pool creation
  */
@@ -376,8 +367,6 @@ odp_pool_t odp_pool_create(const char *name, 
odp_pool_param_t *params)
}
}
 
-   packet_uarea_init(params, tmp);
-
/* Push buffer onto pool's freelist */
ret_buf(>s, tmp);
buf  -= buf_stride;
diff --git a/test/validation/packet/packet.c b/test/validation/packet/packet.c
index 71282dc..2467dec 100644
--- a/test/validation/packet/packet.c
+++ b/test/validation/packet/packet.c
@@ -33,14 +33,6 @@ static struct udata_struct {
"abcdefg",
 };
 
-static void packet_uarea_init(odp_packet_t pkt, void *uarea_init_arg)
-{
-   void *uarea = odp_packet_user_area(pkt);
-   uint32_t uarea_size = odp_packet_user_area_size(pkt);
-
-   memcpy(uarea, uarea_init_arg, uarea_size);
-}
-
 int packet_suite_init(void)
 {
odp_pool_param_t params = {
@@ -49,8 +41,6 @@ int packet_suite_init(void)
.len = PACKET_BUF_LEN,
.num = 100,
.uarea_size = sizeof(struct udata_struct),
-   .uarea_init = packet_uarea_init,
-   .uarea_init_arg = (void *)_packet_udata
},
.type  = ODP_POOL_PACKET,
};
@@ -80,16 +70,16 @@ int packet_suite_init(void)
 
udat = odp_packet_user_area(test_packet);
udat_size = odp_packet_user_area_size(test_packet);
-   if (!udat || udat_size != sizeof(struct udata_struct) ||
-   memcmp(udat, (void *)_packet_udata, udat_size))
+   if (!udat || udat_size != sizeof(struct udata_struct))
return -1;
odp_pool_print(packet_pool);
+   memcpy(udat, _packet_udata, sizeof(struct udata_struct));
 
udat = odp_packet_user_area(segmented_test_packet);
udat_size = odp_packet_user_area_size(segmented_test_packet);
-   if (!udat || udat_size != sizeof(struct udata_struct) ||
-   memcmp(udat, (void *)_packet_udata, udat_size))
+   if (udat == NULL || udat_size != sizeof(struct udata_struct))
return -1;
+   memcpy(udat, _packet_udata, sizeof(struct udata_struct));
 
return 0;
 }
-- 
1.9.1

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


[lng-odp] [PATCH 0/5] validation: cls: correct tests a little

2016-01-12 Thread Ivan Khoronzhuk
This patch series corrects classification tests to be a little bit
adoptive.

Ivan Khoronzhuk (5):
  validation: cls: adopt for supported l3 PMR
  validation: cls: assign default CoS before creating chain
  validation: cls: test_pmr: don't create default input queue
  validation: cls: use correct MAC addresses
  validation: cls: split pmr chain test

 test/validation/classification/classification.h|  28 +--
 .../classification/odp_classification_basic.c  |   4 +-
 .../classification/odp_classification_common.c |  52 ++
 .../classification/odp_classification_test_pmr.c   | 205 -
 .../classification/odp_classification_tests.c  | 127 ++---
 .../classification/odp_classification_testsuites.h |   2 +
 6 files changed, 203 insertions(+), 215 deletions(-)

-- 
1.9.1

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


[lng-odp] [PATCH 2/5] validation: cls: assign default CoS before creating chain

2016-01-12 Thread Ivan Khoronzhuk
There is no big difference when to assign default CoS to pktio,
but in usual case it's done before creating any chain, if it's
needed to be also checked it can be done in separate test.

Signed-off-by: Ivan Khoronzhuk 
---
 .../classification/odp_classification_test_pmr.c   | 35 +-
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/test/validation/classification/odp_classification_test_pmr.c 
b/test/validation/classification/odp_classification_test_pmr.c
index 6644b53..75d2a95 100644
--- a/test/validation/classification/odp_classification_test_pmr.c
+++ b/test/validation/classification/odp_classification_test_pmr.c
@@ -166,6 +166,9 @@ void classification_test_pmr_term_tcp_dport(void)
retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
CU_ASSERT(retval == 0);
 
+   configure_default_cos(pktio, _cos,
+ _queue, _pool);
+
match.term = ODP_PMR_TCP_DPORT;
match.val = 
match.mask = 
@@ -193,8 +196,6 @@ void classification_test_pmr_term_tcp_dport(void)
retval = odp_pktio_pmr_cos(pmr, pktio, cos);
CU_ASSERT(retval == 0);
 
-   configure_default_cos(pktio, _cos,
- _queue, _pool);
pkt = create_packet(pkt_pool, false, , false);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
@@ -275,6 +276,9 @@ void classification_test_pmr_term_tcp_sport(void)
retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
CU_ASSERT(retval == 0);
 
+   configure_default_cos(pktio, _cos,
+ _queue, _pool);
+
match.term = ODP_PMR_TCP_SPORT;
match.val = 
match.mask = 
@@ -301,8 +305,6 @@ void classification_test_pmr_term_tcp_sport(void)
retval = odp_pktio_pmr_cos(pmr, pktio, cos);
CU_ASSERT(retval == 0);
 
-   configure_default_cos(pktio, _cos,
- _queue, _pool);
pkt = create_packet(pkt_pool, false, , false);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
@@ -381,6 +383,9 @@ void classification_test_pmr_term_udp_dport(void)
retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
CU_ASSERT(retval == 0);
 
+   configure_default_cos(pktio, _cos,
+ _queue, _pool);
+
match.term = ODP_PMR_UDP_DPORT;
match.val = 
match.mask = 
@@ -407,8 +412,6 @@ void classification_test_pmr_term_udp_dport(void)
retval = odp_pktio_pmr_cos(pmr, pktio, cos);
CU_ASSERT(retval == 0);
 
-   configure_default_cos(pktio, _cos,
- _queue, _pool);
pkt = create_packet(pkt_pool, false, , true);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
@@ -488,6 +491,9 @@ void classification_test_pmr_term_udp_sport(void)
retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
CU_ASSERT(retval == 0);
 
+   configure_default_cos(pktio, _cos,
+ _queue, _pool);
+
match.term = ODP_PMR_UDP_SPORT;
match.val = 
match.mask = 
@@ -514,8 +520,6 @@ void classification_test_pmr_term_udp_sport(void)
retval = odp_pktio_pmr_cos(pmr, pktio, cos);
CU_ASSERT(retval == 0);
 
-   configure_default_cos(pktio, _cos,
- _queue, _pool);
pkt = create_packet(pkt_pool, false, , true);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
@@ -593,6 +597,9 @@ void classification_test_pmr_term_ipproto(void)
retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
CU_ASSERT(retval == 0);
 
+   configure_default_cos(pktio, _cos,
+ _queue, _pool);
+
match.term = ODP_PMR_IPPROTO;
match.val = 
match.mask = 
@@ -619,8 +626,6 @@ void classification_test_pmr_term_ipproto(void)
retval = odp_pktio_pmr_cos(pmr, pktio, cos);
CU_ASSERT(retval == 0);
 
-   configure_default_cos(pktio, _cos,
- _queue, _pool);
pkt = create_packet(pkt_pool, false, , true);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
@@ -694,6 +699,9 @@ static void classification_test_pmr_pool_set(void)
retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
CU_ASSERT(retval == 0);
 
+   configure_default_cos(pktio, _cos,
+ _queue, _pool);
+
match.term = ODP_PMR_IPPROTO;
match.val = 
match.mask = 
@@ -727,8 +735,6 @@ static void classification_test_pmr_pool_set(void)
retval = odp_pktio_pmr_cos(pmr, pktio, cos);
CU_ASSERT(retval == 0);
 
-   configure_default_cos(pktio, _cos,
- _queue, _pool);
pkt = create_packet(pkt_pool, false, , true);

[lng-odp] [PATCH 3/5] validation: cls: test_pmr: don't create default input queue

2016-01-12 Thread Ivan Khoronzhuk
There is no need to create default input queue for pktio if
default CoS is assigned.

Signed-off-by: Ivan Khoronzhuk 
---
 .../classification/odp_classification_test_pmr.c   | 54 --
 1 file changed, 54 deletions(-)

diff --git a/test/validation/classification/odp_classification_test_pmr.c 
b/test/validation/classification/odp_classification_test_pmr.c
index 75d2a95..0b3f279 100644
--- a/test/validation/classification/odp_classification_test_pmr.c
+++ b/test/validation/classification/odp_classification_test_pmr.c
@@ -55,39 +55,6 @@ odp_pktio_t create_pktio(odp_queue_type_t q_type)
return pktio;
 }
 
-int create_default_inq(odp_pktio_t pktio, odp_queue_type_t qtype)
-{
-   odp_queue_param_t qparam;
-   odp_queue_t inq_def;
-   char inq_name[ODP_QUEUE_NAME_LEN];
-
-   odp_queue_param_init();
-   qparam.sched.prio  = ODP_SCHED_PRIO_DEFAULT;
-   qparam.sched.sync  = ODP_SCHED_SYNC_ATOMIC;
-   qparam.sched.group = ODP_SCHED_GROUP_ALL;
-
-   snprintf(inq_name, sizeof(inq_name), "inq-pktio-%" PRIu64,
-odp_pktio_to_u64(pktio));
-   inq_def = odp_queue_lookup(inq_name);
-   if (inq_def == ODP_QUEUE_INVALID)
-   inq_def = odp_queue_create(
-   inq_name,
-   ODP_QUEUE_TYPE_PKTIN,
-   qtype == ODP_QUEUE_TYPE_POLL ? NULL : );
-
-   CU_ASSERT_FATAL(inq_def != ODP_QUEUE_INVALID);
-
-   if (0 > odp_pktio_inq_setdef(pktio, inq_def))
-   return -1;
-
-   if (odp_pktio_start(pktio)) {
-   fprintf(stderr, "unable to start loop\n");
-   return -1;
-   }
-
-   return 0;
-}
-
 void configure_default_cos(odp_pktio_t pktio, odp_cos_t *cos,
   odp_queue_t *queue, odp_pool_t *pool)
 {
@@ -163,8 +130,6 @@ void classification_test_pmr_term_tcp_dport(void)
 
pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
-   retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
-   CU_ASSERT(retval == 0);
 
configure_default_cos(pktio, _cos,
  _queue, _pool);
@@ -237,7 +202,6 @@ void classification_test_pmr_term_tcp_dport(void)
odp_cos_destroy(cos);
odp_cos_destroy(default_cos);
odp_pmr_destroy(pmr);
-   destroy_inq(pktio);
odp_queue_destroy(queue);
odp_queue_destroy(default_queue);
odp_pool_destroy(pool);
@@ -273,8 +237,6 @@ void classification_test_pmr_term_tcp_sport(void)
 
pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
-   retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
-   CU_ASSERT(retval == 0);
 
configure_default_cos(pktio, _cos,
  _queue, _pool);
@@ -344,7 +306,6 @@ void classification_test_pmr_term_tcp_sport(void)
odp_cos_destroy(cos);
odp_cos_destroy(default_cos);
odp_pmr_destroy(pmr);
-   destroy_inq(pktio);
odp_pool_destroy(default_pool);
odp_pool_destroy(pool);
odp_queue_destroy(queue);
@@ -380,8 +341,6 @@ void classification_test_pmr_term_udp_dport(void)
 
pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
-   retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
-   CU_ASSERT(retval == 0);
 
configure_default_cos(pktio, _cos,
  _queue, _pool);
@@ -452,7 +411,6 @@ void classification_test_pmr_term_udp_dport(void)
odp_cos_destroy(cos);
odp_cos_destroy(default_cos);
odp_pmr_destroy(pmr);
-   destroy_inq(pktio);
odp_queue_destroy(queue);
odp_queue_destroy(default_queue);
odp_pool_destroy(default_pool);
@@ -488,8 +446,6 @@ void classification_test_pmr_term_udp_sport(void)
 
pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
-   retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
-   CU_ASSERT(retval == 0);
 
configure_default_cos(pktio, _cos,
  _queue, _pool);
@@ -559,7 +515,6 @@ void classification_test_pmr_term_udp_sport(void)
odp_cos_destroy(cos);
odp_cos_destroy(default_cos);
odp_pmr_destroy(pmr);
-   destroy_inq(pktio);
odp_pool_destroy(default_pool);
odp_pool_destroy(pool);
odp_queue_destroy(queue);
@@ -594,8 +549,6 @@ void classification_test_pmr_term_ipproto(void)
 
pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
-   retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
-   CU_ASSERT(retval == 0);
 
configure_default_cos(pktio, _cos,
  _queue, _pool);
@@ -660,7 +613,6 @@ void classification_test_pmr_term_ipproto(void)

[lng-odp] [PATCH 5/5] validation: cls: split pmr chain test

2016-01-12 Thread Ivan Khoronzhuk
These tests are simple classification tests and better to see results
for each of them separately.

Signed-off-by: Ivan Khoronzhuk 
---
 test/validation/classification/classification.h| 22 ---
 .../classification/odp_classification_tests.c  | 72 --
 2 files changed, 38 insertions(+), 56 deletions(-)

diff --git a/test/validation/classification/classification.h 
b/test/validation/classification/classification.h
index f363812..6d2e55f 100644
--- a/test/validation/classification/classification.h
+++ b/test/validation/classification/classification.h
@@ -13,7 +13,6 @@
 #define SHM_PKT_BUF_SIZE1024
 
 /* Config values for Default CoS */
-#define TEST_DEFAULT   1
 #defineCLS_DEFAULT 0
 #define CLS_DEFAULT_SADDR  "10.0.0.1/32"
 #define CLS_DEFAULT_DADDR  "10.0.0.100/32"
@@ -21,29 +20,24 @@
 #define CLS_DEFAULT_DPORT  2048
 
 /* Config values for Error CoS */
-#define TEST_ERROR 1
 #define CLS_ERROR  1
 
 /* Config values for PMR_CHAIN */
-#define TEST_PMR_CHAIN 1
 #define CLS_PMR_CHAIN_SRC  2
 #define CLS_PMR_CHAIN_DST  3
 #define CLS_PMR_CHAIN_SADDR"10.0.0.5/32"
 #define CLS_PMR_CHAIN_PORT 3000
 
 /* Config values for PMR */
-#define TEST_PMR   1
 #define CLS_PMR4
 #define CLS_PMR_PORT   4000
 
 /* Config values for PMR SET */
-#define TEST_PMR_SET   1
 #define CLS_PMR_SET5
 #define CLS_PMR_SET_SADDR  "10.0.0.6/32"
 #define CLS_PMR_SET_PORT   5000
 
 /* Config values for CoS L2 Priority */
-#define TEST_L2_QOS1
 #define CLS_L2_QOS_0   6
 #define CLS_L2_QOS_MAX 5
 
@@ -68,8 +62,20 @@ void classification_test_pktio_set_skip(void);
 void classification_test_pktio_set_headroom(void);
 void classification_test_pmr_terms_avail(void);
 void classification_test_pmr_terms_cap(void);
-void classification_test_pktio_configure(void);
-void classification_test_pktio_test(void);
+
+void classification_test_configure_pktio_default_cos(void);
+void classification_test_configure_pktio_error_cos(void);
+void classification_test_configure_cls_pmr_chain(void);
+void classification_test_configure_cos_with_l2_priority(void);
+void classification_test_configure_pmr_cos(void);
+void classification_test_configure_pktio_pmr_match_set_cos(void);
+
+void classification_test_pktio_default_cos(void);
+void classification_test_pktio_error_cos(void);
+void classification_test_cls_pmr_chain(void);
+void classification_test_cos_with_l2_priority(void);
+void classification_test_pmr_cos(void);
+void classification_test_pktio_pmr_match_set_cos(void);
 
 void classification_test_pmr_term_tcp_dport(void);
 void classification_test_pmr_term_tcp_sport(void);
diff --git a/test/validation/classification/odp_classification_tests.c 
b/test/validation/classification/odp_classification_tests.c
index 34fc570..482e2d0 100644
--- a/test/validation/classification/odp_classification_tests.c
+++ b/test/validation/classification/odp_classification_tests.c
@@ -133,7 +133,7 @@ cls_create_packet(bool vlan, odp_atomic_u32_t *seq, bool 
flag_udp)
return pkt;
 }
 
-void configure_cls_pmr_chain(void)
+void classification_test_configure_cls_pmr_chain(void)
 {
/* PKTIO --> PMR_SRC(SRC IP ADDR) --> PMR_DST (TCP SPORT) */
 
@@ -230,7 +230,7 @@ void configure_cls_pmr_chain(void)
CU_ASSERT(retval == 0);
 }
 
-void test_cls_pmr_chain(void)
+void classification_test_cls_pmr_chain(void)
 {
odp_packet_t pkt;
odph_ipv4hdr_t *ip;
@@ -284,7 +284,7 @@ void test_cls_pmr_chain(void)
odp_packet_free(pkt);
 }
 
-void configure_pktio_default_cos(void)
+void classification_test_configure_pktio_default_cos(void)
 {
int retval;
odp_queue_param_t qparam;
@@ -318,7 +318,7 @@ void configure_pktio_default_cos(void)
CU_ASSERT(retval == 0);
 }
 
-void test_pktio_default_cos(void)
+void classification_test_pktio_default_cos(void)
 {
odp_packet_t pkt;
odp_queue_t queue;
@@ -344,7 +344,7 @@ void test_pktio_default_cos(void)
odp_packet_free(pkt);
 }
 
-void configure_pktio_error_cos(void)
+void classification_test_configure_pktio_error_cos(void)
 {
int retval;
odp_queue_param_t qparam;
@@ -380,7 +380,7 @@ void configure_pktio_error_cos(void)
CU_ASSERT(retval == 0);
 }
 
-void test_pktio_error_cos(void)
+void classification_test_pktio_error_cos(void)
 {
odp_queue_t queue;
odp_packet_t pkt;
@@ -434,7 +434,7 @@ void classification_test_pktio_set_headroom(void)
CU_ASSERT(retval < 0);
 }
 
-void configure_cos_with_l2_priority(void)
+void classification_test_configure_cos_with_l2_priority(void)
 {
uint8_t num_qos = CLS_L2_QOS_MAX;
odp_cos_t cos_tbl[CLS_L2_QOS_MAX];
@@ -487,7 +487,7 @@ void configure_cos_with_l2_priority(void)
CU_ASSERT(retval == 0);
 }
 
-void test_cos_with_l2_priority(void)

[lng-odp] [PATCH] doc: identify asciidocs to search engines

2016-01-12 Thread Mike Holmes
Search engines are not currently indexing the documentation, add a title
and description in addition to Google analytics to the documents.

Signed-off-by: Mike Holmes 
---
 doc/implementers-guide/implementers-guide.adoc | 22 ++
 doc/process-guide/release-guide.adoc   | 20 +---
 doc/users-guide/users-guide.adoc   | 21 +
 3 files changed, 52 insertions(+), 11 deletions(-)

diff --git a/doc/implementers-guide/implementers-guide.adoc 
b/doc/implementers-guide/implementers-guide.adoc
index de0b9b1..9486b90 100644
--- a/doc/implementers-guide/implementers-guide.adoc
+++ b/doc/implementers-guide/implementers-guide.adoc
@@ -1,12 +1,26 @@
-OpenDataPlane (ODP)  Implementers Guide
-===
+:doctitle: OpenDataPlane (ODP) Implementers-Guide
+:description: This document is intended to guide a new OpenDataPlane +
+implementation developer.
+
+
+
+  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new 
Date();a=s.createElement(o),
+  
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+  ga('create', 'UA-16756069-15', 'auto');
+  ga('send', 'pageview');
+
+
+
+
 :toc:
-
 :numbered!:
 [abstract]
 Abstract
 
-This document is intended to guide a new ODP developer.
+This document is intended to guide a new ODP implementation developer.
 Further details about ODP may be found at http://opendataplane.org[ODP 
homepage]
 
 
diff --git a/doc/process-guide/release-guide.adoc 
b/doc/process-guide/release-guide.adoc
index 5bef890..d317650 100644
--- a/doc/process-guide/release-guide.adoc
+++ b/doc/process-guide/release-guide.adoc
@@ -1,7 +1,21 @@
-OpenDataPlane (ODP) Release-Guide
-=
+:doctitle: OpenDataPlane (ODP) Release-Guide
+:description: This document is intended to guide a new OpenDataPlane +
+application developer in understanding the git work flow of the project
+
+
+
+  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new 
Date();a=s.createElement(o),
+  
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+  ga('create', 'UA-16756069-15', 'auto');
+  ga('send', 'pageview');
+
+
+
+
 :toc:
-
 :numbered!:
 [abstract]
 Abstract
diff --git a/doc/users-guide/users-guide.adoc b/doc/users-guide/users-guide.adoc
index 542b7d1..3a976d3 100644
--- a/doc/users-guide/users-guide.adoc
+++ b/doc/users-guide/users-guide.adoc
@@ -1,8 +1,21 @@
-OpenDataPlane (ODP)  Users-Guide
-
+:doctitle: OpenDataPlane (ODP) Users-Guide
+:description: This document is intended to guide a new OpenDataPlane +
+application developer.
+
+
+
+  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new 
Date();a=s.createElement(o),
+  
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+  ga('create', 'UA-16756069-15', 'auto');
+  ga('send', 'pageview');
+
+
+
+
 :toc:
-
-
 :numbered!:
 [abstract]
 Abstract
-- 
2.5.0

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


[lng-odp] [PATCH 1/5] validation: cls: adopt for supported l3 PMR

2016-01-12 Thread Ivan Khoronzhuk
The classification tests should use supported l3 PMR where it's
not important. For validating concrete PMRs the separate test exists.

Signed-off-by: Ivan Khoronzhuk 
---
 test/validation/classification/classification.h|  6 +--
 .../classification/odp_classification_basic.c  |  4 +-
 .../classification/odp_classification_common.c | 52 ++
 .../classification/odp_classification_tests.c  | 25 +--
 .../classification/odp_classification_testsuites.h |  2 +
 5 files changed, 69 insertions(+), 20 deletions(-)

diff --git a/test/validation/classification/classification.h 
b/test/validation/classification/classification.h
index a186339..f363812 100644
--- a/test/validation/classification/classification.h
+++ b/test/validation/classification/classification.h
@@ -29,18 +29,18 @@
 #define CLS_PMR_CHAIN_SRC  2
 #define CLS_PMR_CHAIN_DST  3
 #define CLS_PMR_CHAIN_SADDR"10.0.0.5/32"
-#define CLS_PMR_CHAIN_SPORT3000
+#define CLS_PMR_CHAIN_PORT 3000
 
 /* Config values for PMR */
 #define TEST_PMR   1
 #define CLS_PMR4
-#define CLS_PMR_SPORT  4000
+#define CLS_PMR_PORT   4000
 
 /* Config values for PMR SET */
 #define TEST_PMR_SET   1
 #define CLS_PMR_SET5
 #define CLS_PMR_SET_SADDR  "10.0.0.6/32"
-#define CLS_PMR_SET_SPORT  5000
+#define CLS_PMR_SET_PORT   5000
 
 /* Config values for CoS L2 Priority */
 #define TEST_L2_QOS1
diff --git a/test/validation/classification/odp_classification_basic.c 
b/test/validation/classification/odp_classification_basic.c
index f0b7a42..81077b6 100644
--- a/test/validation/classification/odp_classification_basic.c
+++ b/test/validation/classification/odp_classification_basic.c
@@ -78,7 +78,7 @@ void classification_test_create_pmr_match(void)
 
val = 1024;
mask = 0x;
-   match.term = ODP_PMR_TCP_SPORT;
+   match.term = find_first_supported_l3_pmr();
match.val = 
match.mask = 
match.val_sz = sizeof(val);
@@ -99,7 +99,7 @@ void classification_test_destroy_pmr(void)
 
val = 1024;
mask = 0x;
-   match.term = ODP_PMR_TCP_SPORT;
+   match.term = find_first_supported_l3_pmr();
match.val = 
match.mask = 
match.val_sz = sizeof(val);
diff --git a/test/validation/classification/odp_classification_common.c 
b/test/validation/classification/odp_classification_common.c
index afcea45..b1c1750 100644
--- a/test/validation/classification/odp_classification_common.c
+++ b/test/validation/classification/odp_classification_common.c
@@ -299,3 +299,55 @@ odp_packet_t create_packet(odp_pool_t pool, bool vlan,
 
return pkt;
 }
+
+odp_pmr_term_e find_first_supported_l3_pmr(void)
+{
+   odp_pmr_term_e term;
+   unsigned long long cap;
+
+   /* choose supported PMR */
+   cap = odp_pmr_terms_cap();
+   if (cap & (1 << ODP_PMR_UDP_SPORT))
+   term = ODP_PMR_UDP_SPORT;
+   else if (cap & (1 << ODP_PMR_UDP_DPORT))
+   term = ODP_PMR_UDP_DPORT;
+   else if (cap & (1 << ODP_PMR_TCP_SPORT))
+   term = ODP_PMR_TCP_SPORT;
+   else if (cap & (1 << ODP_PMR_TCP_DPORT))
+   term = ODP_PMR_TCP_DPORT;
+   else
+   CU_FAIL("Implementations doesn't support any TCP/UDP PMR");
+
+   return term;
+}
+
+int set_first_supported_pmr_port(odp_packet_t pkt, uint16_t port)
+{
+   odph_udphdr_t *udp;
+   odph_tcphdr_t *tcp;
+   odp_pmr_term_e term;
+
+   udp = (odph_udphdr_t *)odp_packet_l4_ptr(pkt, NULL);
+   tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL);
+   port = odp_cpu_to_be_16(port);
+   term = find_first_supported_l3_pmr();
+   switch (term) {
+   case ODP_PMR_UDP_SPORT:
+   udp->src_port = port;
+   break;
+   case ODP_PMR_UDP_DPORT:
+   udp->dst_port = port;
+   break;
+   case ODP_PMR_TCP_DPORT:
+   tcp->dst_port = port;
+   break;
+   case ODP_PMR_TCP_SPORT:
+   tcp->src_port = port;
+   break;
+   default:
+   CU_FAIL("Unsupported L3 term");
+   return -1;
+   }
+
+   return 0;
+}
diff --git a/test/validation/classification/odp_classification_tests.c 
b/test/validation/classification/odp_classification_tests.c
index e11c3d8..a118728 100644
--- a/test/validation/classification/odp_classification_tests.c
+++ b/test/validation/classification/odp_classification_tests.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static odp_cos_t cos_list[CLS_ENTRIES];
 static odp_pmr_t pmr_list[CLS_ENTRIES];
@@ -195,9 +196,9 @@ void configure_cls_pmr_chain(void)
pmr_list[CLS_PMR_CHAIN_SRC] = odp_pmr_create();
CU_ASSERT_FATAL(pmr_list[CLS_PMR_CHAIN_SRC] != ODP_PMR_INVAL);
 
-   val = CLS_PMR_CHAIN_SPORT;
+   val = 

[lng-odp] Maintain code copy-pasted from linux-generic in ODP-DPDK

2016-01-12 Thread Zoltan Kiss

Hi,

We have a couple of places where the entire source file couldn't be 
copied from linux-generic, but some of the functions are. E.g. the 
loopback implementation from linux-generic's pktio code is something 
like that. It would be nice to somehow get the updates and fixes for 
this codebase, but my current best way is to compare the code of these 
copies and based on the differences use diff to figure out which commits 
are relevant for us.

Does anyone have a more automated idea for this problem?

Regards,

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


Re: [lng-odp] Maintain code copy-pasted from linux-generic in ODP-DPDK

2016-01-12 Thread Nicolas Morey-Chaisemartin
Hi,

I have the same issue with our implementation.
I usually either work from the git diff of linux generic before and post update 
and backport changed or to a diff of the diff of linux-generic vs mppa platform 
before and after the merge.
Theoretically the diff you be clode to void (except line changed) once you 
backport everything.

I've looked a bit around and if your code is close enough to the official one 
(ours start to be quite different on many files), you can try something like 
this:
MBOX=$(mktemp); (cd platform/linux-generic/ && git format-patch --relative 
COMMIT1..COMMIT2 --stdout -- . > $MBOX) && git am -3 --directory platform/dpdk/ 
$MBOX

It will try to apply all the patches that went into the linux-generic file into 
the dpdk platform.
It seems to work OK although I can see a lot of conflicts (trying to merge API 
next into our master may be a bit hard for a first try)

I'll give it a try when master gets few commits in linux-generic post 1.6

Nicolas

On 01/12/2016 07:57 PM, Zoltan Kiss wrote:
> Hi,
>
> We have a couple of places where the entire source file couldn't be copied 
> from linux-generic, but some of the functions are. E.g. the loopback 
> implementation from linux-generic's pktio code is something like that. It 
> would be nice to somehow get the updates and fixes for this codebase, but my 
> current best way is to compare the code of these copies and based on the 
> differences use diff to figure out which commits are relevant for us.
> Does anyone have a more automated idea for this problem?
>
> Regards,
>
> Zoltan Kiss
> ___
> 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] Revert "api: pool: add packet user area initializer for pool creation parameters"

2016-01-12 Thread Maxim Uvarov

Merged,
Maxim.

On 01/08/2016 19:35, Zoltan Kiss wrote:

This reverts commit 798c450fc41ee4195977a5af855dbc98d8aaec16. The use case
is not strong enough for this feature.

Signed-off-by: Zoltan Kiss 
---
  include/odp/api/packet.h |  3 ---
  include/odp/api/pool.h   | 26 --
  2 files changed, 29 deletions(-)

diff --git a/include/odp/api/packet.h b/include/odp/api/packet.h
index 8651a47..9c63b5f 100644
--- a/include/odp/api/packet.h
+++ b/include/odp/api/packet.h
@@ -93,9 +93,6 @@ extern "C" {
   * @note The default headroom and tailroom used for packets is specified by
   * the ODP_CONFIG_PACKET_HEADROOM and ODP_CONFIG_PACKET_TAILROOM defines in
   * odp_config.h.
- * @note Data changed in user area might be preserved by the platform from
- * previous usage of the buffer, so values preset in uarea_init() are not
- * guaranteed.
   */
  odp_packet_t odp_packet_alloc(odp_pool_t pool, uint32_t len);
  
diff --git a/include/odp/api/pool.h b/include/odp/api/pool.h

index 01f770f..2e79a55 100644
--- a/include/odp/api/pool.h
+++ b/include/odp/api/pool.h
@@ -21,7 +21,6 @@ extern "C" {
  
  
  #include 

-#include 
  
  /** @defgroup odp_pool ODP POOL

   *  Operations on a pool.
@@ -42,23 +41,6 @@ extern "C" {
  #define ODP_POOL_NAME_LEN  32
  
  /**

- * Packet user area initializer callback function for pools.
- *
- * @param pkt   Handle of the packet
- * @param uarea_init_argOpaque pointer defined in odp_pool_param_t
- *
- * @note If the application specifies this pointer, it expects that every 
buffer
- * is initialized exactly once with it when the underlying memory is allocated.
- * It is not called from odp_packet_alloc(), unless the platform chooses to
- * allocate the memory at that point. Applications can only assume that this
- * callback is called once before the packet is first used. Any subsequent
- * change to the user area might be preserved after odp_packet_free() is 
called,
- * so applications should take care of (re)initialization if they change data
- * preset by this function.
- */
-typedef void (odp_packet_uarea_init_t)(odp_packet_t pkt, void *uarea_init_arg);
-
-/**
   * Pool parameters
   * Used to communicate pool creation options.
   */
@@ -100,14 +82,6 @@ typedef struct odp_pool_param_t {
/** User area size in bytes. Specify as 0 if no user
area is needed. */
uint32_t uarea_size;
-
-   /** Initialize every packet's user area at allocation
-   time. Use NULL if no initialization needed. */
-   odp_packet_uarea_init_t *uarea_init;
-
-   /** Opaque pointer passed to packet user area
-   constructor. */
-   void *uarea_init_arg;
} pkt;
struct {
/** Number of timeouts in the pool */


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


Re: [lng-odp] [RFC API-NEXT PATCH] api: packet: add packet segment manipulation

2016-01-12 Thread Savolainen, Petri (Nokia - FI/Espoo)


From: EXT Bill Fischofer [mailto:bill.fischo...@linaro.org]
Sent: Tuesday, January 12, 2016 4:29 AM
To: Savolainen, Petri (Nokia - FI/Espoo)
Cc: LNG ODP Mailman List
Subject: Re: [lng-odp] [RFC API-NEXT PATCH] api: packet: add packet segment 
manipulation



On Mon, Jan 11, 2016 at 7:47 AM, Petri Savolainen 
> wrote:
Packet segments can be allocated/freed/multi-referenced.
Segments data pointer and length can be modified (push/pull).
Segments can be linked to packets when needed (can exist also
when not connected to packets).

TODO: Packet pool params need tuning for segment length
configuration.

Signed-off-by: Petri Savolainen 
>
---
 include/odp/api/packet.h | 82 +++-
 1 file changed, 74 insertions(+), 8 deletions(-)

diff --git a/include/odp/api/packet.h b/include/odp/api/packet.h
index 8651a47..7d315ba 100644
--- a/include/odp/api/packet.h
+++ b/include/odp/api/packet.h
@@ -118,6 +118,15 @@ int odp_packet_alloc_multi(odp_pool_t pool, uint32_t len,
   odp_packet_t pkt[], int num);

 /**
+ * Create a new reference to the packet
+ *
+ * @param pkt   Packet handle
+ *
+ * @return New handle which refers to the input packet
+ */
+odp_packet_t odp_packet_ref(odp_packet_t pkt);

Do we need to distinguish between non-shared vs. shared references?  That was 
something we discussed earlier, which is why I had a 2nd parameter in my 
proposed version of this API.  Under this form this implies that all references 
are shared, meaning that a change to the underlying packet via any handle is 
visible to all other references to that packet.  OK if that's what we want, but 
we need to note this behavior.

A non-shared reference to a full packet is a new copy of the packet,  and we 
have odp_packet_copy() defined for that.
I think we need to specify only if packet metadata is duplicated or not. If 
not, this is just a reference counter increment. If metadata is duplicated, 
this allows sharing the (payload) data and adding new head segment(s) to it 
(create N new packets from the same payload part). This was demonstrated on my 
example code. See “[RFC API-NEXT PATCH] packet segmentation”.

So, yes I think the “duplicate vs share metadata” parameter is needed.


+
+/**
  * Free packet
  *
  * Frees the packet into the buffer pool it was allocated from.
@@ -810,11 +819,44 @@ void odp_packet_shaper_len_adjust_set(odp_packet_t pkt, 
int8_t adj);
  */

 /**
+ * Allocate a new segment
+ *
+ * Allocates a new segment from the specified packet pool. The segment
+ * is initialized with data pointers and lengths set according to the
+ * specified len. All other segment metadata are set to their default values.
+ *
+ * @param pool  Pool handle
+ * @param len   Segment data length
+ *
+ * @return Handle of allocated packet
+ * @retval ODP_PACKET_SEG_INVALID  Segment could not be allocated
+ */
+odp_packet_seg_t odp_packet_seg_alloc(odp_pool_t pool, uint32_t len);

The problem I have with this proposed API is that segments are used to 
represent the physical organization of packets at a platform level, which 
controls contiguous addressability.  This is why the various packet APIs that 
return addresses also return a seg_len output parameter which tells the caller 
how many bytes are contiguously addressable from the returned address. Since 
segment lengths are inherently platform-specific, what happens if the caller 
requests a len that's larger than one of these platform-defined segment 
lengths?  That would seem to get awkward as alloc calls would either fail 
unpredictably from platform to platform or else the implementation would have 
to allocate multiple physical segments and chain them together into a "logical 
segment" that would share the same ODP data type as a physical segment 
(odp_packet_seg_t), which would also be confusing and ambiguous.

We already have seg_len packet pool parameter which (currently) ensures that 
the first segment has at least seg_len bytes. In practice, most HW 
pools/pktios/etc work on scatter-gather lists and fixed sized segments. An 
implementation just needs to choose the segment size during pool initialization.

Valid value for  ‘len’ here is 0 to pool_param.pkt.seg_len (or similar, the 
pool param definition needs also an update). Len is used for initialization of 
the segment data pointer and length.


But a logical segment, as envisioned here is effectively what a packet is, 
which is why I've proposed that composites be packet-based rather than segment 
based.  The difference is the amount of metadata that's carried.  A simple 
solution would be to provide a hint to the implementation that full metadata is 
not required for one of these packets that are intended to be used as composite 
packet components.  I'd rather tackle the metadata management issue separately 
rather 

Re: [lng-odp] [API-NEXT PATCH 1/2] api: classifier: align enum type naming

2016-01-12 Thread Savolainen, Petri (Nokia - FI/Espoo)
Ping. Bala and Bill have reviewed this set.


> -Original Message-
> From: EXT Bala Manoharan [mailto:bala.manoha...@linaro.org]
> Sent: Thursday, January 07, 2016 2:34 PM
> To: Savolainen, Petri (Nokia - FI/Espoo)
> Cc: LNG ODP Mailman List
> Subject: Re: [lng-odp] [API-NEXT PATCH 1/2] api: classifier: align enum
> type naming
> 
> Reviewed-by: Balasubramanian Manoharan 
> Regards,
> Bala
> 
> 
> On 7 January 2016 at 17:46, Petri Savolainen 
> wrote:
> > All ODP API enums are typedef'd and type name has
> > a '_t' post-fix.
> >
> > Signed-off-by: Petri Savolainen 
> > ---
> >  example/classifier/odp_classifier.c  | 12 ++---
> ---
> >  include/odp/api/classification.h | 16 -
> ---
> >  .../linux-generic/include/odp_classification_datamodel.h |  2 +-
> >  3 files changed, 15 insertions(+), 15 deletions(-)
> >
> > diff --git a/example/classifier/odp_classifier.c
> b/example/classifier/odp_classifier.c
> > index c14f89e..efb5cf9 100644
> > --- a/example/classifier/odp_classifier.c
> > +++ b/example/classifier/odp_classifier.c
> > @@ -56,7 +56,7 @@ typedef struct {
> > odp_atomic_u64_t pool_pkt_count; /**< count of received packets
> */
> > char cos_name[ODP_COS_NAME_LEN];/**< cos name */
> > struct {
> > -   odp_pmr_term_e term;/**< odp pmr term value */
> > +   odp_pmr_term_t term;/**< odp pmr term value */
> > uint64_t val;   /**< pmr term value */
> > uint64_t mask;  /**< pmr term mask */
> > uint32_t val_sz;/**< size of the pmr term */
> > @@ -89,7 +89,7 @@ static void print_info(char *progname, appl_args_t
> *appl_args);
> >  static void usage(char *progname);
> >  static void configure_cos(odp_pktio_t pktio, appl_args_t *args);
> >  static void configure_default_cos(odp_pktio_t pktio, appl_args_t
> *args);
> > -static int convert_str_to_pmr_enum(char *token, odp_pmr_term_e *term,
> > +static int convert_str_to_pmr_enum(char *token, odp_pmr_term_t *term,
> >uint32_t *offset);
> >  static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char
> *optarg);
> >
> > @@ -691,7 +691,7 @@ static void swap_pkt_addrs(odp_packet_t pkt_tbl[],
> unsigned len)
> > }
> >  }
> >
> > -static int convert_str_to_pmr_enum(char *token, odp_pmr_term_e *term,
> > +static int convert_str_to_pmr_enum(char *token, odp_pmr_term_t *term,
> >uint32_t *offset)
> >  {
> > if (NULL == token)
> > @@ -717,7 +717,7 @@ static int parse_pmr_policy(appl_args_t *appl_args,
> char *argv[], char *optarg)
> > int policy_count;
> > char *token;
> > size_t len;
> > -   odp_pmr_term_e term;
> > +   odp_pmr_term_t term;
> > global_statistics *stats;
> > char *pmr_str;
> > uint32_t offset;
> > @@ -922,9 +922,9 @@ static void usage(char *progname)
> > "\n"
> > "Mandatory OPTIONS:\n"
> > "  -i, --interface Eth interface\n"
> > -   "  -p, --policy
> [|]:::\n"
> > +   "  -p, --policy
> [|]:::\n"
> > "\n"
> > -   "   Packet Matching Rule
> defined with odp_pmr_term_e "
> > +   "   Packet Matching Rule
> defined with odp_pmr_term_t "
> > "for the policy\n"
> > "   Absolute offset in bytes
> from frame start to define a "
> > "ODP_PMR_CUSTOM_FRAME Packet Matching Rule for
> the policy\n"
> > diff --git a/include/odp/api/classification.h
> b/include/odp/api/classification.h
> > index c9493c2..f46912e 100644
> > --- a/include/odp/api/classification.h
> > +++ b/include/odp/api/classification.h
> > @@ -62,7 +62,7 @@ extern "C" {
> >  /**
> >   * class of service packet drop policies
> >   */
> > -typedef enum odp_cls_drop {
> > +typedef enum {
> > ODP_COS_DROP_POOL,/**< Follow buffer pool drop policy */
> > ODP_COS_DROP_NEVER,/**< Never drop, ignoring buffer pool
> policy */
> >  } odp_cls_drop_t;
> > @@ -72,7 +72,7 @@ typedef enum odp_cls_drop {
> >   * for fields that may be used to calculate
> >   * the flow signature, if present in a packet.
> >   */
> > -typedef enum odp_cos_hdr_flow_fields {
> > +typedef enum {
> > ODP_COS_FHDR_IN_PKTIO,  /**< Ingress port number */
> > ODP_COS_FHDR_L2_SAP,/**< Ethernet Source MAC address */
> > ODP_COS_FHDR_L2_DAP,/**< Ethernet Destination MAC address */
> > @@ -86,7 +86,7 @@ typedef enum odp_cos_hdr_flow_fields {
> > ODP_COS_FHDR_IPSEC_SPI, /**< IPsec session identifier */
> > ODP_COS_FHDR_LD_VNI,/**< NVGRE/VXLAN network identifier */
> > ODP_COS_FHDR_USER   

Re: [lng-odp] [API-NEXT PATCH 5/5] linux-generic: removed spin_internal

2016-01-12 Thread Savolainen, Petri (Nokia - FI/Espoo)
Ping.


From: EXT Bill Fischofer [mailto:bill.fischo...@linaro.org]
Sent: Thursday, January 07, 2016 2:30 PM
To: Savolainen, Petri (Nokia - FI/Espoo)
Cc: LNG ODP Mailman List
Subject: Re: [lng-odp] [API-NEXT PATCH 5/5] linux-generic: removed spin_internal

OK, thanks.

For this Series:

Reviewed-by: Bill Fischofer 
>

On Thu, Jan 7, 2016 at 6:21 AM, Savolainen, Petri (Nokia - FI/Espoo) 
> wrote:


From: EXT Bill Fischofer 
[mailto:bill.fischo...@linaro.org]
Sent: Thursday, January 07, 2016 2:11 PM

To: Savolainen, Petri (Nokia - FI/Espoo)
Cc: LNG ODP Mailman List
Subject: Re: [lng-odp] [API-NEXT PATCH 5/5] linux-generic: removed spin_internal


On Thu, Jan 7, 2016 at 2:50 AM, Savolainen, Petri (Nokia - FI/Espoo) 
> wrote:


From: lng-odp 
[mailto:lng-odp-boun...@lists.linaro.org]
 On Behalf Of EXT Savolainen, Petri (Nokia - FI/Espoo)
Sent: Thursday, January 07, 2016 10:44 AM
To: EXT Bill Fischofer

Cc: LNG ODP Mailman List
Subject: Re: [lng-odp] [API-NEXT PATCH 5/5] linux-generic: removed spin_internal



From: EXT Bill Fischofer [mailto:bill.fischo...@linaro.org]
Sent: Tuesday, January 05, 2016 8:01 PM
To: Savolainen, Petri (Nokia - FI/Espoo)
Cc: LNG ODP Mailman List
Subject: Re: [lng-odp] [API-NEXT PATCH 5/5] linux-generic: removed spin_internal


diff --git a/platform/linux-generic/odp_barrier.c 
b/platform/linux-generic/odp_barrier.c
index 53d83c0..0bfc0f0 100644
--- a/platform/linux-generic/odp_barrier.c
+++ b/platform/linux-generic/odp_barrier.c
@@ -6,7 +6,7 @@

 #include 
 #include 
-#include 
+#include 
 #include 

 void odp_barrier_init(odp_barrier_t *barrier, int count)
@@ -43,7 +43,7 @@ void odp_barrier_wait(odp_barrier_t *barrier)
} else {
while ((odp_atomic_load_u32(>bar) < barrier->count)
== wasless)
-   odp_spin();
+   odp_cpu_pause();

Why wouldn't you just want to change the implementation of odp_spin() to use 
the pause instruction here?  These are spin lock waits but nowhere does ODP 
specify that spins must be implemented inefficiently.

Since odp_cpu_pause() is intended for exactly this use case, it’s better to use 
the call also internally to highlight the correct usage (and eat our own dog 
food).

The implementation is arch specific (“pause” vs. “nop” vs. empty). For example, 
on multi-core x86 “pause” improves lock performance since CPUs are not 
stressing the interconnect at 100% speed. Pause instruction was designed for 
this use case.

-Petri

Also odp_cpu_pause() is implemented as static inline function - so there’s no 
function call, it will be the “pause” instruction directly.

I agree completely with the implementation change for all the reasons you cite, 
just questioning why it needs to be reflected in an API name change that 
implies a specific implementation. What if SoC X doesn't have a pause 
instruction but instead uses a delay instruction or some other technique for 
efficient waiting?  odp_spin() is as good a "neutral" name as any to say "I 
don't have anything to do here other than delay for a bit". We expect each ODP 
API to be implemented as efficiently as possible, and on X86 that means using 
the native pause instruction, so that's just how odp_spin() would be 
implemented here. It would also be an inline function on this architecture.

odp_spin() was an internal function, not an API. Odp_cpu_pause() is a new API 
call. It does not do any spinning but pauses the cpu for a very short while. 
Actual spin logic calls the pause. It’s in the API so that when application 
implements its own lock-free, etc algorithms it can also pause  within its spin 
loop.

-Petri



-Petri



}

_ODP_FULL_BARRIER();



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


Re: [lng-odp] [API-NEXT PATCH 1/2] api: cpumask: documented string format

2016-01-12 Thread Savolainen, Petri (Nokia - FI/Espoo)
Ping.


From: EXT Bill Fischofer [mailto:bill.fischo...@linaro.org]
Sent: Monday, January 04, 2016 6:43 PM
To: Savolainen, Petri (Nokia - FI/Espoo)
Cc: LNG ODP Mailman List
Subject: Re: [lng-odp] [API-NEXT PATCH 1/2] api: cpumask: documented string 
format



On Mon, Jan 4, 2016 at 7:07 AM, Petri Savolainen 
> wrote:
Documented string format for odp_cpumask_from_str()
and _to_str(). Format is permissive in input, but
fixed on output.

Signed-off-by: Petri Savolainen 
>

Reviewed-by: Bill Fischofer 
>

---
 include/odp/api/cpumask.h | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/include/odp/api/cpumask.h b/include/odp/api/cpumask.h
index b616cb3..4407b10 100644
--- a/include/odp/api/cpumask.h
+++ b/include/odp/api/cpumask.h
@@ -33,27 +33,37 @@ extern "C" {

 /**
  * @def ODP_CPUMASK_STR_SIZE
- * Minimum size of output buffer for odp_cpumask_to_str()
+ * The maximum number of characters needed to record any CPU mask as
+ * a string (output of odp_cpumask_to_str()).
  */

 /**
  * Add CPU mask bits from a string
  *
+ * Each bit set in the string represents a CPU to be added into the mask.
+ * The string is null terminated and consists of hexadecimal digits. It may be
+ * prepended with '0x' and may contain leading zeros (e.g. 0x0001, 0x1 or 1).
+ * CPU #0 is located at the least significant bit (0x1).
+ *
  * @param mask   CPU mask to modify
- * @param strHexadecimal digits in a string. CPU #0 is located
- *   at the least significant bit (0x1).
+ * @param strString of hexadecimal digits
  */
 void odp_cpumask_from_str(odp_cpumask_t *mask, const char *str);

 /**
- * Format CPU mask as a string of hexadecimal digits
+ * Format a string from CPU mask
  *
- * @param mask CPU mask to format
- * @param[out] str Output buffer (use ODP_CPUMASK_STR_SIZE)
- * @param size Size of output buffer
+ * Output string format is defined in odp_cpumask_from_str() documentation,
+ * except that the string is always prepended with '0x' and does not have any
+ * leading zeros (e.g. outputs always 0x1 instead of 0x0001 or 1).
  *
- * @return number of characters written (including terminating null char)
- * @retval <0 on failure (buffer too small)
+ * @param  mask  CPU mask
+ * @param[out] str   String pointer for output
+ * @param  size  Size of output buffer. Buffer size ODP_CPUMASK_STR_SIZE
+ *   or larger will have enough space for any CPU mask.
+ *
+ * @return Number of characters written (including terminating null char)
+ * @retval <0 on failure (e.g. buffer too small)
  */
 int32_t odp_cpumask_to_str(const odp_cpumask_t *mask, char *str, int32_t size);

--
2.6.3

___
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] [PATCH] pool:support to create pool on user's own memory

2016-01-12 Thread Bill Fischofer
Some quick comments:

1. This patch should be marked API-NEXT since it proposes an API change

2. In general I like the idea behind this patch, however I'd also like to
see it incorporate NUMA considerations (perhaps that's why it's being
proposed?) as that's one of the areas that we need to add to ODP pool
management.  The approach seems correct to extend the odp_pool_param_t with
additional capabilities.  We've discussed adding NUMA zone information to
this structure as well, so perhaps these can be combined.

More detailed comments inline

On Tue, Jan 12, 2016 at 1:22 AM, Zaibo Xu  wrote:

> As user initiates pool params with its own memory reserving and
> un-reserving functions,
> pool will be created on its own memory, or on odp share memory as before.
>
> Signed-off-by: Zaibo Xu 
> ---
>  include/odp/api/pool.h| 12 
>  platform/linux-generic/odp_pool.c | 34 +-
>  2 files changed, 37 insertions(+), 9 deletions(-)
>
> diff --git a/include/odp/api/pool.h b/include/odp/api/pool.h
> index 2e79a55..fce0592 100644
> --- a/include/odp/api/pool.h
> +++ b/include/odp/api/pool.h
> @@ -40,6 +40,12 @@ extern "C" {
>  /** Maximum queue name length in chars */
>  #define ODP_POOL_NAME_LEN  32
>
> +/** For user's memory reserve function */
> +typedef void* (*odp_usr_resv_mem_t)(uint32_t len);
>

Why not use the same parameter count/format as odp_shm_reserve() here? That
would seem to offer the most flexibility. Also, for symmetry a better name
for this function might be odp_user_mem_reserve()


> +
> +/** For user's memory un-reserve function */
> +typedef int (*odp_usr_unresv_mem_t)(void *addr);


For symmetry with odp_shm_free() a better name here might be
odp_user_mem_free()


> +
>  /**
>   * Pool parameters
>   * Used to communicate pool creation options.
> @@ -48,6 +54,12 @@ typedef struct odp_pool_param_t {
> /** Pool type */
> int type;
>
> +   /** Odp pool can be created on user's own memory.
> +   there are memory reserve and un-reserve
> +   functions of user. */
> +   odp_usr_resv_mem_t resv_mem_fn;
> +   odp_usr_unresv_mem_t unresv_mem_fn;
> +
> union {
> struct {
> /** Number of buffers in the pool */
> diff --git a/platform/linux-generic/odp_pool.c
> b/platform/linux-generic/odp_pool.c
> index 84d35bf..eb8b153 100644
> --- a/platform/linux-generic/odp_pool.c
> +++ b/platform/linux-generic/odp_pool.c
> @@ -295,15 +295,27 @@ odp_pool_t odp_pool_create(const char *name,
> odp_pool_param_t *params)
>   mdata_size +
>   udata_size);
>
> -   shm = odp_shm_reserve(pool->s.name,
> - pool->s.pool_size,
> - ODP_PAGE_SIZE, 0);
> -   if (shm == ODP_SHM_INVALID) {
> -   POOL_UNLOCK(>s.lock);
> -   return ODP_POOL_INVALID;
> +   if (pool->s.params.resv_mem_fn != NULL) {
> +   void *addr = pool->s.params.resv_mem_fn(
> +   (uint32_t)pool->s.pool_size);
> +
> +   if (addr == NULL) {
> +   POOL_UNLOCK(>s.lock);
> +   return ODP_POOL_INVALID;
> +   }
> +   pool->s.pool_base_addr = (uint8_t *)addr;
> +   pool->s.pool_shm = (odp_shm_t)!ODP_SHM_INVALID;
>

This is used as an indication that the pool entry is unallocated.  Need to
modify the odp_pool_create() routine to account for this change.
Similarly, odp_pool_destroy() needs modification to account for this as
does odp_pool_term_global()


> +   } else {
> +   shm = odp_shm_reserve(pool->s.name,
> + pool->s.pool_size,
> + ODP_PAGE_SIZE, 0);
> +   if (shm == ODP_SHM_INVALID) {
> +   POOL_UNLOCK(>s.lock);
> +   return ODP_POOL_INVALID;
> +   }
> +   pool->s.pool_base_addr = odp_shm_addr(shm);
> +   pool->s.pool_shm = shm;
> }
> -   pool->s.pool_base_addr = odp_shm_addr(shm);
> -   pool->s.pool_shm = shm;
>
> /* Now safe to unlock since pool entry has been allocated
> */
> POOL_UNLOCK(>s.lock);
> @@ -473,7 +485,11 @@ int odp_pool_destroy(odp_pool_t pool_hdl)
> return -1;
> }
>
> -   odp_shm_free(pool->s.pool_shm);
> +   if (pool->s.params.unresv_mem_fn != NULL)
> +   pool->s.params.unresv_mem_fn((void
> *)pool->s.pool_base_addr);
> +   else
> +   

Re: [lng-odp] [API-NEXT PATCH] Revert user area init implementation

2016-01-12 Thread Maxim Uvarov
Ok, I just reverted that 2 patches to better see match between original 
patch and reverted.

Added your sign-off there.

Maxim.

On 01/12/2016 16:54, Zoltan Kiss wrote:

This reverts commits:

2eb52b7277 "linux-generic: pool: implement user area init support"
9127b7408b "validation: packet: test if user area is properly set"

Signed-off-by: Zoltan Kiss 
---
  platform/linux-generic/odp_pool.c | 11 ---
  test/validation/packet/packet.c   | 18 --
  2 files changed, 4 insertions(+), 25 deletions(-)

diff --git a/platform/linux-generic/odp_pool.c 
b/platform/linux-generic/odp_pool.c
index 125d8e6..84d35bf 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -147,15 +147,6 @@ int odp_pool_term_local(void)
return 0;
  }
  
-static void packet_uarea_init(odp_pool_param_t *params, odp_buffer_hdr_t *tmp)

-{
-   if (params->type == ODP_POOL_PACKET && params->pkt.uarea_init) {
-   odp_packet_t pkt = _odp_packet_from_buffer(odp_hdr_to_buf(tmp));
-
-   params->pkt.uarea_init(pkt, params->pkt.uarea_init_arg);
-   }
-}
-
  /**
   * Pool creation
   */
@@ -376,8 +367,6 @@ odp_pool_t odp_pool_create(const char *name, 
odp_pool_param_t *params)
}
}
  
-			packet_uarea_init(params, tmp);

-
/* Push buffer onto pool's freelist */
ret_buf(>s, tmp);
buf  -= buf_stride;
diff --git a/test/validation/packet/packet.c b/test/validation/packet/packet.c
index 71282dc..2467dec 100644
--- a/test/validation/packet/packet.c
+++ b/test/validation/packet/packet.c
@@ -33,14 +33,6 @@ static struct udata_struct {
"abcdefg",
  };
  
-static void packet_uarea_init(odp_packet_t pkt, void *uarea_init_arg)

-{
-   void *uarea = odp_packet_user_area(pkt);
-   uint32_t uarea_size = odp_packet_user_area_size(pkt);
-
-   memcpy(uarea, uarea_init_arg, uarea_size);
-}
-
  int packet_suite_init(void)
  {
odp_pool_param_t params = {
@@ -49,8 +41,6 @@ int packet_suite_init(void)
.len = PACKET_BUF_LEN,
.num = 100,
.uarea_size = sizeof(struct udata_struct),
-   .uarea_init = packet_uarea_init,
-   .uarea_init_arg = (void *)_packet_udata
},
.type  = ODP_POOL_PACKET,
};
@@ -80,16 +70,16 @@ int packet_suite_init(void)
  
  	udat = odp_packet_user_area(test_packet);

udat_size = odp_packet_user_area_size(test_packet);
-   if (!udat || udat_size != sizeof(struct udata_struct) ||
-   memcmp(udat, (void *)_packet_udata, udat_size))
+   if (!udat || udat_size != sizeof(struct udata_struct))
return -1;
odp_pool_print(packet_pool);
+   memcpy(udat, _packet_udata, sizeof(struct udata_struct));
  
  	udat = odp_packet_user_area(segmented_test_packet);

udat_size = odp_packet_user_area_size(segmented_test_packet);
-   if (!udat || udat_size != sizeof(struct udata_struct) ||
-   memcmp(udat, (void *)_packet_udata, udat_size))
+   if (udat == NULL || udat_size != sizeof(struct udata_struct))
return -1;
+   memcpy(udat, _packet_udata, sizeof(struct udata_struct));
  
  	return 0;

  }


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


Re: [lng-odp] ODP 1.5 - Crash while cleanup ODP/ODP timer pool

2016-01-12 Thread Mike Holmes
Bogdan

CI sees instability in the timer also  and Ivan is looking although he is
on vacation this week, see https://bugs.linaro.org/show_bug.cgi?id=1940.

If that is not the same is it possible for you to share a simple case that
forces the issue  and create a new bug ?

Mike

On 11 January 2016 at 08:35, Bogdan Pricope  wrote:

> Hi,
>
>
>
> I am using ODP-LNG 1.5 and I am getting this crash while trying to cleanup
> ODP timer pool + other resources.
>
>
>
> Program received signal SIGSEGV, Segmentation fault.
>
> [Switching to Thread 0x7fffe700 (LWP 27019)]
>
> timer_notify (sigval=sigval@entry=...) at odp_timer.c:638
>
> 638 overrun = timer_getoverrun(tp->timerid);
>
> (gdb) bt
>
> #0  timer_notify (sigval=sigval@entry=...) at odp_timer.c:638
>
> #1  0x76fb80ff in timer_sigev_thread (arg=0x78c0) at
> ../nptl/sysdeps/unix/sysv/linux/timer_routines.c:63
>
> #2  0x77589182 in start_thread (arg=0x7fffe700) at
> pthread_create.c:312
>
> #3  0x772b5efd in clone () at
> ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
>
> (gdb) print tp
>
> $1 = (odp_timer_pool *) 0x77dfd000
>
> (gdb) print *tp
>
> Cannot access memory at address 0x77dfd000
>
> (gdb) print sigval
>
> $2 = {sival_int = -136327168, sival_ptr = 0x77dfd000}
>
>
>
>
>
> This ‘timer_notify()’ is the callback for timer associated with an ODP
> timer pool.
>
>
>
> See this:
>
> http://man7.org/linux/man-pages/man2/timer_delete.2.html
>
>
>
> This crash may be related to:
>
> „The treatment of any pending signal generated by the
>
>deleted timer is unspecified.
>
> ”
>
>
>
> Any thoughts?
>
>
>
>
>
> Best regards,
>
> Bogdan
>
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
>


-- 
Mike Holmes
Technical Manager - Linaro Networking Group
Linaro.org  *│ *Open source software for ARM SoCs
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH] test: perf: l2fwd detect missing odp_generator

2016-01-12 Thread Mike Holmes
The script did not check that the odp_generator was present and worse it
failed silently if it was not present.

Signed-off-by: Mike Holmes 
---
 test/performance/odp_l2fwd_run | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/test/performance/odp_l2fwd_run b/test/performance/odp_l2fwd_run
index 001d8c2..a1446e8 100755
--- a/test/performance/odp_l2fwd_run
+++ b/test/performance/odp_l2fwd_run
@@ -54,6 +54,16 @@ run_l2fwd()
exit $TEST_SKIPPED
fi
 
+   type odp_generator > /dev/null
+   if [ $? -ne 0 ]; then
+   echo "odp_generator not installed. Aborting."
+   cleanup_pktio_env
+   if [ $? -ne 0 ]; then
+   echo "cleanup_pktio_env error $?"
+   fi
+   exit 1
+   fi
+
#@todo: limit odp_generator to cores
#https://bugs.linaro.org/show_bug.cgi?id=1398
(odp_generator${EXEEXT} -I $IF0 \
-- 
2.5.0

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


[lng-odp] [PATCH 4/5] validation: cls: use correct MAC addresses

2016-01-12 Thread Ivan Khoronzhuk
If pktion is in not promisc mode, a packet should contain correct
MAC address.

Signed-off-by: Ivan Khoronzhuk 
---
 .../classification/odp_classification_test_pmr.c   | 158 ++---
 .../classification/odp_classification_tests.c  |  30 +++-
 2 files changed, 96 insertions(+), 92 deletions(-)

diff --git a/test/validation/classification/odp_classification_test_pmr.c 
b/test/validation/classification/odp_classification_test_pmr.c
index 0b3f279..bb69794 100644
--- a/test/validation/classification/odp_classification_test_pmr.c
+++ b/test/validation/classification/odp_classification_test_pmr.c
@@ -13,22 +13,11 @@
 #include 
 
 static odp_pool_t pkt_pool;
+static odp_pktio_t pktio_loop;
 
 /** sequence number of IP packets */
 odp_atomic_u32_t seq;
 
-int classification_suite_pmr_init(void)
-{
-   pkt_pool = pool_create("classification_pmr_pool");
-   if (ODP_POOL_INVALID == pkt_pool) {
-   fprintf(stderr, "Packet pool creation failed.\n");
-   return -1;
-   }
-
-   odp_atomic_init_u32(, 0);
-   return 0;
-}
-
 odp_pktio_t create_pktio(odp_queue_type_t q_type)
 {
odp_pktio_t pktio;
@@ -55,6 +44,35 @@ odp_pktio_t create_pktio(odp_queue_type_t q_type)
return pktio;
 }
 
+int classification_suite_pmr_init(void)
+{
+   pkt_pool = pool_create("classification_pmr_pool");
+   if (ODP_POOL_INVALID == pkt_pool) {
+   fprintf(stderr, "Packet pool creation failed.\n");
+   return -1;
+   }
+
+   pktio_loop = create_pktio(ODP_QUEUE_TYPE_SCHED);
+
+   odp_atomic_init_u32(, 0);
+   return 0;
+}
+
+static odp_packet_t
+cls_create_packet(bool vlan, odp_atomic_u32_t *seq, bool flag_udp)
+{
+   odp_packet_t pkt;
+   odph_ethhdr_t *eth;
+
+   pkt = create_packet(pkt_pool, vlan, seq, flag_udp);
+
+   eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL);
+   odp_pktio_mac_addr(pktio_loop, eth->src.addr, ODPH_ETHADDR_LEN);
+   odp_pktio_mac_addr(pktio_loop, eth->dst.addr, ODPH_ETHADDR_LEN);
+
+   return pkt;
+}
+
 void configure_default_cos(odp_pktio_t pktio, odp_cos_t *cos,
   odp_queue_t *queue, odp_pool_t *pool)
 {
@@ -93,6 +111,11 @@ int classification_suite_pmr_term(void)
 {
int retcode = 0;
 
+   if (odp_pktio_close(pktio_loop)) {
+   fprintf(stderr, "unable to close pktio_loop.\n");
+   retcode = -1;
+   }
+
if (0 != odp_pool_destroy(pkt_pool)) {
fprintf(stderr, "pkt_pool destroy failed.\n");
retcode = -1;
@@ -109,7 +132,6 @@ void classification_test_pmr_term_tcp_dport(void)
uint16_t val;
uint16_t mask;
int retval;
-   odp_pktio_t pktio;
odp_queue_t queue;
odp_queue_t retqueue;
odp_queue_t default_queue;
@@ -128,10 +150,7 @@ void classification_test_pmr_term_tcp_dport(void)
mask = 0x;
seqno = 0;
 
-   pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
-   CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
-
-   configure_default_cos(pktio, _cos,
+   configure_default_cos(pktio_loop, _cos,
  _queue, _pool);
 
match.term = ODP_PMR_TCP_DPORT;
@@ -158,10 +177,10 @@ void classification_test_pmr_term_tcp_dport(void)
cos = odp_cls_cos_create(cosname, _param);
CU_ASSERT(cos != ODP_COS_INVALID);
 
-   retval = odp_pktio_pmr_cos(pmr, pktio, cos);
+   retval = odp_pktio_pmr_cos(pmr, pktio_loop, cos);
CU_ASSERT(retval == 0);
 
-   pkt = create_packet(pkt_pool, false, , false);
+   pkt = cls_create_packet(false, , false);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
CU_ASSERT(seqno != TEST_SEQ_INVALID);
@@ -169,7 +188,7 @@ void classification_test_pmr_term_tcp_dport(void)
tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL);
tcp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);
 
-   enqueue_pktio_interface(pkt, pktio);
+   enqueue_pktio_interface(pkt, pktio_loop);
 
pkt = receive_packet(, ODP_TIME_SEC_IN_NS);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
@@ -181,7 +200,7 @@ void classification_test_pmr_term_tcp_dport(void)
odp_packet_free(pkt);
 
/* Other packets are delivered to default queue */
-   pkt = create_packet(pkt_pool, false, , false);
+   pkt = cls_create_packet(false, , false);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
CU_ASSERT(seqno != TEST_SEQ_INVALID);
@@ -189,7 +208,7 @@ void classification_test_pmr_term_tcp_dport(void)
tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL);
tcp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT + 1);
 
-   enqueue_pktio_interface(pkt, pktio);
+   enqueue_pktio_interface(pkt, pktio_loop);
 
pkt = receive_packet(, ODP_TIME_SEC_IN_NS);
CU_ASSERT_FATAL(pkt != 

[lng-odp] [PATCH v2] doc: process: add by-laws

2016-01-12 Thread Mike Holmes
The by-laws were only recorded as part of the website, move them to git
where they can be tracked.

Signed-off-by: Mike Holmes 
---
v2:
   Comments from Maxim

 doc/process-guide/Makefile.am   |   6 +-
 doc/process-guide/bylaws-guide.adoc | 119 
 2 files changed, 123 insertions(+), 2 deletions(-)
 create mode 100644 doc/process-guide/bylaws-guide.adoc

diff --git a/doc/process-guide/Makefile.am b/doc/process-guide/Makefile.am
index 95915c0..9fc3b80 100644
--- a/doc/process-guide/Makefile.am
+++ b/doc/process-guide/Makefile.am
@@ -1,8 +1,10 @@
 include ../Makefile.inc
 
-TARGET = release-guide.html
+TARGET = bylaws-guide.html \
+release-guide.html
 
-EXTRA_DIST = release-guide.adoc
+EXTRA_DIST = bylaws-guide.adoc \
+release-guide.adoc
 
 all-local: $(TARGET)
 
diff --git a/doc/process-guide/bylaws-guide.adoc 
b/doc/process-guide/bylaws-guide.adoc
new file mode 100644
index 000..509e479
--- /dev/null
+++ b/doc/process-guide/bylaws-guide.adoc
@@ -0,0 +1,119 @@
+:doctitle: OpenDataPlane (ODP)  By-laws-Guide
+:description: This document is intended to guide a new application developer +
+in understanding the by-laws
+
+
+
+  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new 
Date();a=s.createElement(o),
+  
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+  ga('create', 'UA-16756069-15', 'auto');
+  ga('send', 'pageview');
+
+
+
+
+:toc:
+:numbered!:
+[abstract]
+Abstract
+
+This document is intended to guide a new application developer in
+understanding the by-laws.
+
+The ODP project has established a set of by-laws defining the operational
+processes by which direction of ODP resources is determined and how the product
+is managed.
+
+The by-laws define roles, stewardship/management, patch approvals, voting
+procedures, and reporting (Roadmap) requirements.
+
+Further details about ODP may be found at the http://opendataplane.org[ODP]
+home page.
+
+:numbered:
+
+== Roles considered
+=== Users
+People that use the project and submit bugs and request new features to the
+project.
+
+=== Contributors
+All of the volunteers who are contributing time, code, documentation, or
+resources to the project. A contributor that makes sustained, welcome
+contributions to the project may be invited to become a maintainer, though the
+exact timing of such invitations depends on many factors.
+
+If a contributor wants to move the project in direction X or add feature Y, and
+that requires a lot of rewrite in the existing code-base then:
+
+* explain that in an email to the mailing list.
+* send out RFCs (early and often) with example code, so the community (and
+maintainers) can see what you want and say if it fits or not.
+
+The above helps find and solve common problems among contributors.
+
+=== Maintainer(s)
+* The maintainer for a project have push rights to the main repo. Only one
+maintainer. The most trustworthy sub-maintainer shall step in and take over the
+maintainer ship as required.
+* Sub-maintainer(s) one or many for the different modules in the project.
+* Sub-maintainers shall focus on ensuring that the current code base has good
+quality and review new patches to maintain that good quality.
+* When Maintainers accept code, they have to deal with it until they die or rip
+it out (so its important that they understand what the code does and why they
+need it). The contributor shall convince the maintainer to take their code (the
+maintainer should feel like he would be stupid to not accept the code…)
+
+=== Release Manager ===
+
+* The RM shall publish a Release Plan on the roadmap. One week before the
+release the candidate list will be reviewed.
+* The RM is responsible for building consensus around the content of the
+Release.
+
+== Roadmap
+The roadmap shall state projected future releases and the expected content.
+
+== Steering Committee (SC)
+* Defining the requirements for the project’s shared resources, email
+  lists and the homepage.
+* Speaking on behalf of the project.
+* Resolving license disputes regarding products of the project.
+* Nominating new PMC members and committers.
+* Maintaining these by-laws and other guidelines of the project.
+* Planning the roadmap (shall state projected future releases and the expected
+content).
+
+=== Patch approval
+Reviewed-by is only replied to the list after inspecting the code. If you have
+review comments they should be constructive and not just saying “no”.
+Reviewed-by and Signed-off-by implies that you are co-responsible for any bugs
+found in the code.
+
+If you don’t respond you are assumed to agree with the patch.
+
+== Voting ==
+Voting is necessary if consensus not has been reached. Must have established
+quorum.
+
+* “Yes”, “Agree”,"+1"  the action 

[lng-odp] 答复: [PATCH] pool:support to create pool on user's own memory

2016-01-12 Thread Xu Zaibo
Hi Bill,
Thanks for your advices.

1. Sorry for not being marked API-NEXT, as this is my first patch for LNG.



2. Generally, my intention for this mending of pool API is from most of our 
product requests. Sometimes, they just want to use the memory of themselves. 
Moreover, they even don’t like using of odp_shm_reserve in ODP, as their memory 
system may be affected by ODP’s odp_shm_reserve.



3. Seemly, I think this additional API can be NUMA memory or some other 
special memory operations from users.

More detailed comments inline

发件人: Bill Fischofer [mailto:bill.fischo...@linaro.org]
发送时间: 2016年1月12日 21:10
收件人: Xu Zaibo
抄送: Tangchaofei; Liuzhongzhu; chenlizhi; yangfajun; Huwei (Xavier); LNG ODP 
Mailman List
主题: Re: [lng-odp] [PATCH] pool:support to create pool on user's own memory

Some quick comments:

1. This patch should be marked API-NEXT since it proposes an API change

2. In general I like the idea behind this patch, however I'd also like to see 
it incorporate NUMA considerations (perhaps that's why it's being proposed?) as 
that's one of the areas that we need to add to ODP pool management.  The 
approach seems correct to extend the odp_pool_param_t with additional 
capabilities.  We've discussed adding NUMA zone information to this structure 
as well, so perhaps these can be combined.

More detailed comments inline

On Tue, Jan 12, 2016 at 1:22 AM, Zaibo Xu 
> wrote:
As user initiates pool params with its own memory reserving and un-reserving 
functions,
pool will be created on its own memory, or on odp share memory as before.

Signed-off-by: Zaibo Xu >
---
 include/odp/api/pool.h| 12 
 platform/linux-generic/odp_pool.c | 34 +-
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/include/odp/api/pool.h b/include/odp/api/pool.h
index 2e79a55..fce0592 100644
--- a/include/odp/api/pool.h
+++ b/include/odp/api/pool.h
@@ -40,6 +40,12 @@ extern "C" {
 /** Maximum queue name length in chars */
 #define ODP_POOL_NAME_LEN  32

+/** For user's memory reserve function */
+typedef void* (*odp_usr_resv_mem_t)(uint32_t len);

Why not use the same parameter count/format as odp_shm_reserve() here? That 
would seem to offer the most flexibility. Also, for symmetry a better name for 
this function might be odp_user_mem_reserve()
I think it’s a good idea of using the same parameters as odp_shm_reserve with 
odp_user_mem_reserve() instead.

+
+/** For user's memory un-reserve function */
+typedef int (*odp_usr_unresv_mem_t)(void *addr);

For symmetry with odp_shm_free() a better name here might be odp_user_mem_free()
 Also for odp_user_mem_free() instead.
+
 /**
  * Pool parameters
  * Used to communicate pool creation options.
@@ -48,6 +54,12 @@ typedef struct odp_pool_param_t {
/** Pool type */
int type;

+   /** Odp pool can be created on user's own memory.
+   there are memory reserve and un-reserve
+   functions of user. */
+   odp_usr_resv_mem_t resv_mem_fn;
+   odp_usr_unresv_mem_t unresv_mem_fn;
+
union {
struct {
/** Number of buffers in the pool */
diff --git a/platform/linux-generic/odp_pool.c 
b/platform/linux-generic/odp_pool.c
index 84d35bf..eb8b153 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -295,15 +295,27 @@ odp_pool_t odp_pool_create(const char *name, 
odp_pool_param_t *params)
  mdata_size +
  udata_size);

-   shm = odp_shm_reserve(pool->s.name,
- pool->s.pool_size,
- ODP_PAGE_SIZE, 0);
-   if (shm == ODP_SHM_INVALID) {
-   POOL_UNLOCK(>s.lock);
-   return ODP_POOL_INVALID;
+   if (pool->s.params.resv_mem_fn != NULL) {
+   void *addr = pool->s.params.resv_mem_fn(
+   (uint32_t)pool->s.pool_size);
+
+   if (addr == NULL) {
+   POOL_UNLOCK(>s.lock);
+   return ODP_POOL_INVALID;
+   }
+   pool->s.pool_base_addr = (uint8_t *)addr;
+   pool->s.pool_shm = (odp_shm_t)!ODP_SHM_INVALID;

This is used as an indication that the pool entry is unallocated.  Need to 
modify the odp_pool_create() routine to account for this change.  Similarly, 
odp_pool_destroy() needs modification to account for this as does 
odp_pool_term_global()
 Right now, I still cannot figure out how to initiate ‘pool->s.pool_shm’, so 
just using this awkward way. Hopefully , we can have a special macro as 
ODP_SHM_INVALID to indicate that this pool memory is 

[lng-odp] [PATCH] linux-generic: crypto: fix AES-GCM compatibility with old version of OpenSSL

2016-01-12 Thread Nicolas Morey-Chaisemartin
Old version of OpenSSL require SET_TAG to be called before
 decrypting the data. New versions are compatible either way

Signed-off-by: Nicolas Morey-Chaisemartin 
---
 platform/linux-generic/odp_crypto.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index 65e8503..92bc2f3 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -397,6 +397,7 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_params_t 
*params,
int plain_len = 0;
 
EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_enc);
+   EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, 16, tag);
 
/* Authenticate header data (if any) without encrypting them */
if (aad_head < cipherdata) {
@@ -414,8 +415,6 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_params_t 
*params,
  auth_len - (aad_tail - aad_head));
}
 
-   EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, 16, tag);
-
if (EVP_DecryptFinal_ex(ctx, cipherdata + cipher_len, _len) < 0)
return ODP_CRYPTO_ALG_ERR_ICV_CHECK;
 
-- 
2.6.3.372.gcb93895

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